gantri-components 2.252.2 → 2.253.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.
Files changed (50) hide show
  1. package/dist/components/aspect-ratio/aspect-ratio.types.d.ts +8 -0
  2. package/dist/components/badge/badge.types.d.ts +9 -0
  3. package/dist/components/banner/banner.types.d.ts +9 -0
  4. package/dist/components/box/box.types.d.ts +8 -0
  5. package/dist/components/breadcrumbs/breadcrumbs.types.d.ts +9 -0
  6. package/dist/components/button/button.types.d.ts +17 -0
  7. package/dist/components/button-menu/button-menu.types.d.ts +9 -0
  8. package/dist/components/carousel/carousel.types.d.ts +9 -0
  9. package/dist/components/cell/cell.types.d.ts +8 -0
  10. package/dist/components/checkbox/checkbox.types.d.ts +9 -0
  11. package/dist/components/checkbox-list/checkbox-list.types.d.ts +9 -0
  12. package/dist/components/circular-progress/circular-progress.types.d.ts +9 -0
  13. package/dist/components/color-picker/color-picker.types.d.ts +9 -0
  14. package/dist/components/confirmation-modal/confirmation-modal.types.d.ts +8 -0
  15. package/dist/components/dropdown/dropdown.types.d.ts +9 -0
  16. package/dist/components/dropdown-menu/dropdown-menu.types.d.ts +9 -0
  17. package/dist/components/file-uploader/file-uploader.types.d.ts +9 -0
  18. package/dist/components/filter-button/filter-button.types.d.ts +9 -0
  19. package/dist/components/icon/icon.types.d.ts +9 -0
  20. package/dist/components/image/image.types.d.ts +8 -0
  21. package/dist/components/label/label.types.d.ts +11 -0
  22. package/dist/components/line/line.types.d.ts +9 -0
  23. package/dist/components/linear-progress/linear-progress.types.d.ts +9 -0
  24. package/dist/components/max-width/max-width.types.d.ts +8 -0
  25. package/dist/components/modal/modal.types.d.ts +15 -0
  26. package/dist/components/multi-select-list/multi-select-list.types.d.ts +9 -0
  27. package/dist/components/option-selector/option-selector.types.d.ts +9 -0
  28. package/dist/components/overlay/overlay.types.d.ts +8 -0
  29. package/dist/components/picture/picture.types.d.ts +8 -0
  30. package/dist/components/pills/components/pill/pill.types.d.ts +9 -0
  31. package/dist/components/pills/pills.types.d.ts +9 -0
  32. package/dist/components/quantity/quantity.types.d.ts +9 -0
  33. package/dist/components/radio/radio.types.d.ts +9 -0
  34. package/dist/components/radio-list/radio-list.types.d.ts +9 -0
  35. package/dist/components/slider/slider.types.d.ts +9 -0
  36. package/dist/components/table/table.types.d.ts +8 -0
  37. package/dist/components/tabs/tabs.types.d.ts +9 -0
  38. package/dist/components/text-field/text-field.types.d.ts +9 -0
  39. package/dist/components/toggle/toggle.types.d.ts +8 -0
  40. package/dist/components/tooltip/tooltip.types.d.ts +9 -0
  41. package/dist/components/typography/typography.types.d.ts +8 -0
  42. package/dist/components/video/video.types.d.ts +14 -0
  43. package/dist/helpers/data-component/__tests__/data-component.test.d.ts +1 -0
  44. package/dist/helpers/data-component/data-component.d.ts +43 -0
  45. package/dist/helpers/data-component/data-component.types.d.ts +10 -0
  46. package/dist/helpers/data-component/index.d.ts +2 -0
  47. package/dist/helpers/index.d.ts +1 -0
  48. package/dist/index.cjs.js +1 -1
  49. package/dist/index.esm.js +1 -1
  50. package/package.json +1 -1
@@ -12,6 +12,14 @@ export interface ToggleProps extends Pick<DetailedHTMLProps<InputHTMLAttributes<
12
12
  labelVariant?: TextVariant;
13
13
  name?: string;
14
14
  onSelected?: (value: boolean) => void;
15
+ /**
16
+ * Escape hatch for end-to-end tests when no other prop distinguishes two
17
+ * sibling Toggles. When provided, the root receives
18
+ * `data-testid={testId}` in addition to the auto-emitted
19
+ * `data-component="toggle"`, `data-name`, `data-tx`, and `data-label`
20
+ * attributes. Rarely needed.
21
+ */
22
+ testId?: string;
15
23
  value?: boolean;
16
24
  variant?: ToggleVariant;
17
25
  }
@@ -13,6 +13,15 @@ export type TooltipProps = Partial<TooltipDefaultProps> & Pick<OverlayProps, 'on
13
13
  descriptionHtmlText?: string;
14
14
  descriptionTx?: string;
15
15
  hideOnNonDesktops?: boolean;
16
+ /**
17
+ * Escape hatch for end-to-end tests when no other prop distinguishes two
18
+ * sibling instances. When provided, the root receives
19
+ * `data-testid={testId}` in addition to the auto-emitted `data-component`
20
+ * and projected `data-*` attributes. Rarely needed — the auto-emitted
21
+ * attributes (`data-component`, `data-name`, `data-tx`, `data-label`, etc.)
22
+ * are usually sufficient. See `helpers/data-component`.
23
+ */
24
+ testId?: string;
16
25
  title?: string;
17
26
  titleHtmlText?: string;
18
27
  titleTx?: string;
@@ -27,6 +27,14 @@ export interface TypographyProps extends Partial<TypographyDefaultProps>, AriaAt
27
27
  minWidth?: ResolutionAwareProp<string>;
28
28
  onClick?: (event: any) => void;
29
29
  style?: CSSProperties;
30
+ /**
31
+ * Escape hatch for end-to-end tests when no other prop distinguishes two
32
+ * sibling instances. When provided, the root receives
33
+ * `data-testid={testId}` in addition to the auto-emitted `data-component`
34
+ * and projected `data-*` attributes. Rarely needed — the auto-emitted
35
+ * attributes are usually sufficient. See `helpers/data-component`.
36
+ */
37
+ testId?: string;
30
38
  text?: string | number;
31
39
  textShadow?: Property.TextShadow;
32
40
  textStyle?: TextStyle;
@@ -26,8 +26,22 @@ export interface VideoProps extends Partial<VideoDefaultProps>, Omit<VideoHTMLAt
26
26
  onOpenFullscreen?: (videoUrl: string) => void;
27
27
  src: ResolutionAwareProp<string>;
28
28
  style?: CSSProperties;
29
+ /**
30
+ * Escape hatch for end-to-end tests when no other prop distinguishes two
31
+ * sibling instances. When provided, the root receives
32
+ * `data-testid={testId}` in addition to the auto-emitted `data-component`
33
+ * and projected `data-*` attributes. Rarely needed — the auto-emitted
34
+ * attributes are usually sufficient. See `helpers/data-component`.
35
+ */
36
+ testId?: string;
29
37
  transformations?: VideoTransformations;
30
38
  width?: Optional<ResolutionAwareProp<ImageDimension>>;
39
+ /**
40
+ * Optional alt-like description for the video. Only used to project
41
+ * `data-alt` for end-to-end tests; the underlying `<video>` element does
42
+ * not natively accept `alt`.
43
+ */
44
+ alt?: string;
31
45
  }
32
46
  export interface VideoTransformations {
33
47
  aspectRatio?: Optional<ResolutionAwareProp<AspectRatio>>;
@@ -0,0 +1,43 @@
1
+ import { DataComponentAttrs, DataComponentProjections } from './data-component.types';
2
+ /**
3
+ * Slugify free-form text for use as a `data-*` value selector in end-to-end
4
+ * tests. Returns undefined when the input is missing, empty, all
5
+ * non-alphanumeric, or longer than 60 characters (in which case the slug
6
+ * would be unwieldy and is intentionally omitted).
7
+ *
8
+ * Examples:
9
+ * slug('Action only') → 'action-only'
10
+ * slug('Add to cart') → 'add-to-cart'
11
+ * slug('Bestsellers — limited') → 'bestsellers-limited'
12
+ * slug(' ') → undefined
13
+ * slug('A'.repeat(80)) → undefined (too long)
14
+ * slug(undefined) → undefined
15
+ */
16
+ export declare const slug: (input?: string | null) => string | undefined;
17
+ /**
18
+ * Build the set of `data-*` attributes a gantri-components component emits
19
+ * on its root element so end-to-end tests can target it without the
20
+ * consumer adding any new props.
21
+ *
22
+ * - The root always receives `data-component={componentName}`.
23
+ * - Each entry in `projections` becomes `data-<key>="<value>"` when the
24
+ * value is non-null and non-empty. Null / undefined / empty values are
25
+ * skipped, so consumers who pass partial props get partial attributes
26
+ * without any boilerplate.
27
+ * - An optional `testId` becomes `data-testid="..."` — kept as an escape
28
+ * hatch for the rare case when no projected prop distinguishes two
29
+ * sibling instances.
30
+ *
31
+ * Example (Toggle):
32
+ * <StyledToggleContainer
33
+ * {...dataComponentProps('toggle', {
34
+ * name,
35
+ * tx: labelTx,
36
+ * label: slug(labelText),
37
+ * }, testId)}
38
+ * />
39
+ *
40
+ * <Toggle name="active-only" labelText="Action only" />
41
+ * // renders: data-component="toggle" data-name="active-only" data-label="action-only"
42
+ */
43
+ export declare const dataComponentProps: (componentName: string, projections?: DataComponentProjections, testId?: string) => DataComponentAttrs;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Map of `data-<key>` attributes to emit on a component's root.
3
+ * The library helper filters out null / undefined / empty values automatically.
4
+ */
5
+ export type DataComponentProjections = Record<string, string | number | null | undefined>;
6
+ /**
7
+ * The strongly-typed return of `dataComponentProps`. Each key is `data-<x>`.
8
+ * Spread directly onto a JSX element: `<div {...dataComponentProps(...)} />`.
9
+ */
10
+ export type DataComponentAttrs = Record<`data-${string}`, string>;
@@ -0,0 +1,2 @@
1
+ export * from './data-component';
2
+ export * from './data-component.types';
@@ -2,3 +2,4 @@ export * from './layout.helpers';
2
2
  export * from './get-file-url';
3
3
  export * from './get-folder-structure';
4
4
  export * from './generate-skus-functions';
5
+ export * from './data-component';