@akad/design-system 1.1.10 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2,6 +2,29 @@ import { PushClickEventOptions } from '@akad/data-owl';
|
|
|
2
2
|
import { default as PropTypes } from 'prop-types';
|
|
3
3
|
import { HTMLAttributes, ReactNode } from 'react';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Named keys of `PushClickEventOptions`. The data-owl base options carry a
|
|
7
|
+
* `[key: string]: unknown` index signature (custom properties), which makes
|
|
8
|
+
* `Omit`/`keyof` collapse every named key into the index signature — this
|
|
9
|
+
* mapped type strips it so the required fields stay required.
|
|
10
|
+
*/
|
|
11
|
+
type PushClickEventKnownOptions = {
|
|
12
|
+
[K in keyof PushClickEventOptions as string extends K ? never : number extends K ? never : K]: PushClickEventOptions[K];
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Tracking payload for DsButton (data-owl 2.0.0).
|
|
16
|
+
*
|
|
17
|
+
* The consumer provides the element identity (`elementName`) and the shared
|
|
18
|
+
* business context (`product`, `productCategory`, `squadId`, `source`,
|
|
19
|
+
* `handler`, `businessFlow`). The button fills in what only it knows at click
|
|
20
|
+
* time — `elementType`, the page context (`pagePath`/`pageTitle`/`pageUrl`/
|
|
21
|
+
* `pageReferrer`) and `elementText` — but any value passed here always wins
|
|
22
|
+
* over those defaults.
|
|
23
|
+
*/
|
|
24
|
+
export type DsButtonTrackingData = Omit<PushClickEventKnownOptions, 'elementType' | 'pagePath' | 'pageTitle' | 'pageUrl' | 'pageReferrer'> & Partial<Pick<PushClickEventKnownOptions, 'elementType' | 'pagePath' | 'pageTitle' | 'pageUrl' | 'pageReferrer'>> & {
|
|
25
|
+
/** Any additional custom properties (converted to snake_case by data-owl). */
|
|
26
|
+
[key: string]: unknown;
|
|
27
|
+
};
|
|
5
28
|
export interface DsButtonProps extends HTMLAttributes<HTMLButtonElement> {
|
|
6
29
|
children: string | ReactNode;
|
|
7
30
|
className?: string;
|
|
@@ -16,7 +39,7 @@ export interface DsButtonProps extends HTMLAttributes<HTMLButtonElement> {
|
|
|
16
39
|
iconFill?: boolean;
|
|
17
40
|
iconPosition?: string;
|
|
18
41
|
fullSize?: boolean;
|
|
19
|
-
trackingData?:
|
|
42
|
+
trackingData?: DsButtonTrackingData;
|
|
20
43
|
}
|
|
21
44
|
declare const DsButton: {
|
|
22
45
|
({ children, className, onClick, size, disabled, icon, id, testId, elevation, variant, color, iconFill, iconPosition, fullSize, trackingData, }: DsButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -31,7 +54,16 @@ declare const DsButton: {
|
|
|
31
54
|
testId: PropTypes.Requireable<string>;
|
|
32
55
|
id: PropTypes.Requireable<string>;
|
|
33
56
|
fullSize: PropTypes.Requireable<boolean>;
|
|
34
|
-
trackingData: PropTypes.Requireable<
|
|
57
|
+
trackingData: PropTypes.Requireable<PropTypes.InferProps<{
|
|
58
|
+
elementName: PropTypes.Validator<string>;
|
|
59
|
+
elementType: PropTypes.Requireable<string>;
|
|
60
|
+
product: PropTypes.Validator<string>;
|
|
61
|
+
productCategory: PropTypes.Validator<string>;
|
|
62
|
+
squadId: PropTypes.Validator<string>;
|
|
63
|
+
source: PropTypes.Validator<string>;
|
|
64
|
+
handler: PropTypes.Validator<string>;
|
|
65
|
+
businessFlow: PropTypes.Validator<string>;
|
|
66
|
+
}>>;
|
|
35
67
|
};
|
|
36
68
|
displayName: string;
|
|
37
69
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BusinessFlow, EventHandler, EventSource, ProductCategory, Squad } from '@akad/data-owl';
|
|
1
2
|
import { Meta } from '@storybook/react';
|
|
2
3
|
import { DsButtonProps } from './Button';
|
|
3
4
|
import { ThemeProviderProps } from '../../molecules/ThemeProvider';
|
|
@@ -15,3 +16,28 @@ export declare const Default: {
|
|
|
15
16
|
onClick: import('@storybook/addon-actions').HandlerFunction;
|
|
16
17
|
};
|
|
17
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* Exemplo com tracking do data-owl 2.0.0: o consumidor passa a identidade do
|
|
21
|
+
* elemento e o contexto de negócio; o botão preenche `elementType`,
|
|
22
|
+
* `elementText` e o contexto de página no momento do clique.
|
|
23
|
+
*/
|
|
24
|
+
export declare const WithTracking: {
|
|
25
|
+
render: import('storybook/internal/types').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, ThemeProviderProps & DsButtonProps>;
|
|
26
|
+
args: {
|
|
27
|
+
trackingData: {
|
|
28
|
+
elementName: string;
|
|
29
|
+
product: string;
|
|
30
|
+
productCategory: ProductCategory;
|
|
31
|
+
squadId: Squad;
|
|
32
|
+
source: EventSource;
|
|
33
|
+
handler: EventHandler;
|
|
34
|
+
businessFlow: BusinessFlow;
|
|
35
|
+
};
|
|
36
|
+
variant: import('./Button.config').ButtonVariant;
|
|
37
|
+
fullSize: boolean;
|
|
38
|
+
iconFill: boolean;
|
|
39
|
+
size: import('./Button.config').ButtonSize;
|
|
40
|
+
disabled: boolean;
|
|
41
|
+
onClick: import('@storybook/addon-actions').HandlerFunction;
|
|
42
|
+
};
|
|
43
|
+
};
|