diff --git a/.eslintrc b/.eslintrc index 19f5c0b80..0138c2e29 100644 --- a/.eslintrc +++ b/.eslintrc @@ -69,11 +69,15 @@ "linebreak-style": "off", "no-debugger": "off", "no-alert": "off", - "no-use-before-define": "warn", - "no-unused-vars": [ + "no-use-before-define": "off", + "@typescript-eslint/no-use-before-define": ["error"], + "no-unused-vars": "off", + "@typescript-eslint/no-unused-vars": [ "warn", { - "argsIgnorePattern": "res|next|^err" + "argsIgnorePattern": "res|next|^err|^_", + "varsIgnorePattern": "^_", + "caughtErrorsIgnorePattern": "^_" } ], "prefer-const": [ @@ -110,20 +114,8 @@ "consistent-return": "off", "jsx-a11y/accessible-emoji": "off", "radix": "off", - "no-shadow": [ - 2, - { - "hoist": "all", - "allow": [ - "resolve", - "reject", - "done", - "next", - "err", - "error" - ] - } - ], + "no-shadow": "off", + "@typescript-eslint/no-shadow": ["warn"], "quotes": [ 2, "single", diff --git a/CHANGELOG.md b/CHANGELOG.md index 3852ea521..b56da700e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,193 @@ All notable changes to this project will be documented in this file. +# [2.5.28] - 29.09.2022 + +## Added + +- Add `disabled` for Dropdown options +# [2.5.27] - 04.08.2022 + +## Added + +- Changed the color of the text in the footer for Previews from fixed value to a value from the theme colors + +# [2.5.26] - 21.07.2022 + +## Added + +- Add `hasItemEntries` prop for Table component + +# [2.5.25] - 04.04.2022 + +## Added + +- Add `displayFormat` prop for DayPicker component + +# [2.5.24] - 09.03.2022 + +## Added + +- New `useAnalytics` hook as an alternative to `AnalyticsComponent` + +# [2.5.23] - 21.02.2022 + +## Change + +- Buy button tag name on paywall previews + +# [2.5.22] - 04.02.2022 + +## Added + +- Option in column table to make fields(columns) editable +- onBlur function to trigger persa when input and textarea are focused-out + +# [2.5.21] - 25.01.2022 + +## Change + +- Styling changes in preview templates for restricted asset +- FooterText component refactored + +# [2.5.20] - 21.01.2022 + +## Fixes + +- TextArea by providing the required props + +# [2.5.19] - 21.01.2022 + +## Added + +- Handlers for Input, TextArea, Pagination, Accordion and Switch. +- Tagging Paywall previews + +## Fixes + +- TabNavigation handler type + +# [2.5.18] - 10.01.2022 + +## Added + +- Handlers for Checkbox, Radiobutton, Daypicker and Datepicker. +- Handler for selected Tab change. + +# [2.5.17] - 12.11.2021 + +## Added + +- Tagging for StepWizard + +## Fixes + +- Dropdown component tag sent in tracker + +# [2.5.16] - 12.11.2021 + +## Added + +- Analytics handler for dropdown component +- Tagging for pagination and navbar + +# [2.5.15] - 02.11.2021 + +## Fixes + +- Tab component import bug + +### Change + +- Accordion component to be analytics ready + +# [2.5.14] - 27.10.2021 + +## Added + +- Analytics handler for button component + +# [2.5.13] - 05-10-2021 + +## Added + +- AnalyticsProps type to the components in index.d.ts file. + +# [2.5.12] - 28-09-2021 + +## Added + +- Explicit exports for components, types and interfaces from `src/analytics`. + +# [2.5.11] - 28-09-2021 + +## Added + +- Analytics tracking adds forgotten import for React. + +# [2.5.10] - 27-09-2021 + +### Added + +- Analytics tracking props for all components. + +# [2.5.9] - 23-09-2021 + +### Added + +- Add another type of datepicker component with dropdown presets +- Drawer component functionality and design + +# [2.5.8] - 19-08-2021 + +### Change + +- Return Accordion panel label when toggling it. + +# [2.5.7] - 17-06-2021 + +### Change + +- Changes connected with logo re-branding + +# [2.5.6] - 09-04-2021 + +### Fixes + +- Changed width, height and padding-left of Checkbox component's top wrapper to be in `em` instead of `rem` + +# [2.5.5] - 22-03-2021 + +### Change + +- Add styling changes for asset restrictions in preview templates + +# [2.5.4] - 12-03-2021 + +### Change + +- Add missing className for Switch component in order to externaly style it with styled-components + +# [2.5.3] - 23-02-2021 + +### Fixes + +- Daypicker moment type error + +# [2.5.2] - 22-01-2021 + +### Change + +- Use pixels instead of rem for font sizes + +# [2.5.1] - 15-01-2021 + +### Added + +- Add the possibility to have more than one table button + # [2.5.0] - 12-01-2021 + ### Changes - Change footer text depending on user auth state diff --git a/README.md b/README.md index 232fb5464..1f5cf7f44 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +**THIS REPOSITORY IS MOVED TO GITLAB** + +
diff --git a/index.d.ts b/index.d.ts
index 4570f85ef..d9ddbd48b 100644
--- a/index.d.ts
+++ b/index.d.ts
@@ -19,7 +19,113 @@ import { FocusedInputShape } from 'react-dates';
export { FocusedInputShape } from 'react-dates';
-export interface ContainerProps {
+export type AnalyticsTag = string;
+
+/**
+ * Props present on various components which aid in the tracking of analytics events.
+ */
+export interface AnalyticsProps {
+ /** Unique identifier of the component within the logical page hierarchy. */
+ tag?: AnalyticsTag;
+
+ /** Posiition of the component within a table-like component. */
+ position?: {
+ /** Unique ID of the row (usually what you would use as a key in react). */
+ id: string;
+
+ /** Row index. */
+ row?: number;
+
+ /** Column index or name. */
+ column?: number | string;
+ };
+}
+
+export declare class AnalyticsTracker {
+ registerHandler: (fn: AnalyticsHandlerFn) => void;
+ deregisterHandler: (fn: AnalyticsHandlerFn) => void;
+ track: (event: Event) => void;
+}
+
+export interface AnalyticsContextValue {
+ pages: AnalyticsPage[];
+ tracker: AnalyticsTracker;
+ merchantId: number;
+ ip: string;
+}
+
+export type AnalyticsPageProps = {
+ /** Tag of this page. */
+ tag: AnalyticsTag;
+
+ /** Type of this page. */
+ type: AnalyticsPageType;
+
+ /** Children in the page. */
+ children?: React.ReactNode;
+
+ /** merchant id */
+ merchantId?: number;
+
+ /** user ip address */
+ ip?: string;
+};
+
+export type AnalyticsComponentProps = {
+ children: (context: AnalyticsContextValue) => React.ReactNode;
+};
+
+export declare const ROOT_ANALYTICS_CONTEXT: AnalyticsContextValue;
+
+export enum AnalyticsEvents {
+ CLICK = 'click',
+ DROPDOWN_CHANGE = 'dropdown_change',
+ SWITCH_ON = 'switch_on',
+ SWITCH_OFF = 'switch_off',
+ DROPDOWN_SELECT = 'dropdown_select',
+ CHECKBOX_ON = 'checkbox_on',
+ CHECKBOX_OFF = 'checkbox_off',
+ RADIOBUTTON_SELECT = 'radiobutton_select',
+ DATEPICKER_CHANGE = 'datepicker_date_change',
+ DAYPICKER_CHANGE = 'daypicker_date_change',
+ KEYBOARD_EVENT = 'keyboard_event',
+}
+
+export enum AnalyticsComponentType {
+ BUTTON = 'button',
+ DROPDOWN = 'dropdown',
+ SWITCH = 'switch',
+ PAGINATION = 'pagination',
+ ICON = 'icon',
+ LINK = 'link',
+ CHECKBOX = 'checkbox',
+ DATEPICKER = 'datepicker',
+ DAYPICKER = 'daypicker',
+ DATEPICKER_PRESET = 'datepicker_preset',
+ TAB = 'tab',
+ ACCORDION = 'accordion',
+ MODAL = 'modal',
+ INPUT = 'input',
+ TEXTAREA = 'textarea',
+ TAB_NAVIGATION = 'tab_navigation',
+}
+
+export interface Event {
+ // temporarily mark them as strings
+ event: AnalyticsEvents | string;
+ type: AnalyticsComponentType | string;
+ tag: AnalyticsTag;
+ pages: AnalyticsPage[];
+ merchantId?: number;
+ ip?: string;
+}
+
+export type AnalyticsHandlerFn = (event: Record