@astryxdesign/core 0.6.0 → 0.6.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 (203) hide show
  1. package/CHANGELOG.md +41 -3
  2. package/dist/AppShell/AppShell.d.ts.map +1 -1
  3. package/dist/BottomSheet/BottomSheetSwitcher.d.ts +12 -1
  4. package/dist/BottomSheet/BottomSheetSwitcher.d.ts.map +1 -1
  5. package/dist/BottomSheet/BottomSheetSwitcher.js +44 -15
  6. package/dist/Breadcrumbs/BreadcrumbItem.d.ts +3 -2
  7. package/dist/Breadcrumbs/BreadcrumbItem.d.ts.map +1 -1
  8. package/dist/Breadcrumbs/BreadcrumbItem.js +3 -7
  9. package/dist/Center/Center.d.ts +23 -16
  10. package/dist/Center/Center.d.ts.map +1 -1
  11. package/dist/Center/Center.js +7 -5
  12. package/dist/CodeBlock/CodeBlock.js +2 -2
  13. package/dist/DateInput/DateInput.d.ts.map +1 -1
  14. package/dist/DateInput/DateInput.js +12 -2
  15. package/dist/DateTimeInput/DateTimeInput.d.ts.map +1 -1
  16. package/dist/DateTimeInput/DateTimeInput.js +12 -2
  17. package/dist/Field/Field.d.ts.map +1 -1
  18. package/dist/Field/Field.js +1 -0
  19. package/dist/Field/InputClearButton.d.ts +2 -2
  20. package/dist/Field/InputClearButton.d.ts.map +1 -1
  21. package/dist/Field/InputClearButton.js +5 -1
  22. package/dist/Field/PanelSearchInput.d.ts.map +1 -1
  23. package/dist/Field/PanelSearchInput.js +16 -4
  24. package/dist/FileInput/FileInput.d.ts.map +1 -1
  25. package/dist/FileInput/FileInput.js +12 -1
  26. package/dist/HoverCard/useHoverCard.js +2 -2
  27. package/dist/Indicator/CheckboxIndicator.js +2 -2
  28. package/dist/Indicator/RadioIndicator.js +2 -2
  29. package/dist/Layer/layerStack.d.ts +10 -0
  30. package/dist/Layer/layerStack.d.ts.map +1 -1
  31. package/dist/Layer/layerStack.js +21 -9
  32. package/dist/Layer/useLayerDismissal.d.ts +2 -3
  33. package/dist/Layer/useLayerDismissal.d.ts.map +1 -1
  34. package/dist/Layer/useLayerDismissal.js +2 -3
  35. package/dist/NavIcon/NavIcon.js +2 -2
  36. package/dist/NumberInput/NumberInput.d.ts.map +1 -1
  37. package/dist/NumberInput/NumberInput.js +12 -2
  38. package/dist/Popover/usePopover.d.ts +3 -2
  39. package/dist/Popover/usePopover.d.ts.map +1 -1
  40. package/dist/Popover/usePopover.js +4 -2
  41. package/dist/ProgressBar/ProgressBar.js +2 -2
  42. package/dist/ScrollableArea/ScrollableArea.d.ts +79 -0
  43. package/dist/ScrollableArea/ScrollableArea.d.ts.map +1 -0
  44. package/dist/ScrollableArea/ScrollableArea.js +144 -0
  45. package/dist/ScrollableArea/index.d.ts +11 -0
  46. package/dist/ScrollableArea/index.d.ts.map +1 -0
  47. package/dist/ScrollableArea/index.js +11 -0
  48. package/dist/StatusDot/StatusDot.js +2 -2
  49. package/dist/TextArea/TextArea.js +2 -2
  50. package/dist/TextInput/TextInput.d.ts.map +1 -1
  51. package/dist/TextInput/TextInput.js +19 -4
  52. package/dist/TimeInput/TimeInput.d.ts.map +1 -1
  53. package/dist/TimeInput/TimeInput.js +12 -2
  54. package/dist/Typeahead/BaseTypeahead.d.ts +21 -14
  55. package/dist/Typeahead/BaseTypeahead.d.ts.map +1 -1
  56. package/dist/Typeahead/BaseTypeahead.js +56 -20
  57. package/dist/astryx.css +15 -0
  58. package/dist/hooks/index.d.ts +2 -0
  59. package/dist/hooks/index.d.ts.map +1 -1
  60. package/dist/hooks/index.js +1 -0
  61. package/dist/hooks/scrollGeometry.d.ts +24 -0
  62. package/dist/hooks/scrollGeometry.d.ts.map +1 -0
  63. package/dist/hooks/scrollGeometry.js +86 -0
  64. package/dist/hooks/scrollOwnerRegistry.d.ts +15 -0
  65. package/dist/hooks/scrollOwnerRegistry.d.ts.map +1 -0
  66. package/dist/hooks/scrollOwnerRegistry.js +24 -0
  67. package/dist/hooks/useFocusTrap.d.ts +8 -0
  68. package/dist/hooks/useFocusTrap.d.ts.map +1 -1
  69. package/dist/hooks/useFocusTrap.js +22 -11
  70. package/dist/hooks/useScrollableArea.d.ts +51 -0
  71. package/dist/hooks/useScrollableArea.d.ts.map +1 -0
  72. package/dist/hooks/useScrollableArea.js +287 -0
  73. package/dist/index.d.ts +1 -0
  74. package/dist/index.d.ts.map +1 -1
  75. package/dist/index.js +1 -0
  76. package/dist/theme/defineTheme.d.ts +2 -6
  77. package/dist/theme/defineTheme.d.ts.map +1 -1
  78. package/dist/theme/defineTheme.js +1 -1
  79. package/dist/theme/derivedVarRegistry.js +1 -1
  80. package/dist/theme/localTokens.d.ts +8 -11
  81. package/dist/theme/localTokens.d.ts.map +1 -1
  82. package/dist/theme/localTokens.js +17 -71
  83. package/dist/theme/themeAdaptations.d.ts.map +1 -1
  84. package/dist/theme/themeAdaptations.js +4 -4
  85. package/dist/utils/themeProps.d.ts +10 -10
  86. package/dist/utils/themeProps.d.ts.map +1 -1
  87. package/dist/utils/themeProps.js +27 -10
  88. package/locales/en.json +16 -0
  89. package/locales/pseudo.json +12 -0
  90. package/package.json +7 -2
  91. package/src/AppShell/AppShell.test.tsx +36 -0
  92. package/src/AppShell/AppShell.tsx +4 -1
  93. package/src/AspectRatio/AspectRatio.doc.mjs +3 -3
  94. package/src/Banner/Banner.test.tsx +3 -1
  95. package/src/BottomSheet/BottomSheetSwitcher.doc.mjs +56 -1
  96. package/src/BottomSheet/BottomSheetSwitcher.spec.md +211 -0
  97. package/src/BottomSheet/BottomSheetSwitcher.test.tsx +134 -2
  98. package/src/BottomSheet/BottomSheetSwitcher.tsx +43 -20
  99. package/src/Breadcrumbs/BreadcrumbItem.doc.mjs +10 -5
  100. package/src/Breadcrumbs/BreadcrumbItem.spec.md +225 -0
  101. package/src/Breadcrumbs/BreadcrumbItem.tsx +8 -13
  102. package/src/Breadcrumbs/Breadcrumbs.doc.mjs +2 -2
  103. package/src/Breadcrumbs/Breadcrumbs.test.tsx +49 -2
  104. package/src/Center/Center.doc.mjs +32 -28
  105. package/src/Center/Center.spec.md +225 -0
  106. package/src/Center/Center.test.tsx +42 -4
  107. package/src/Center/Center.tsx +24 -17
  108. package/src/Chat/ChatSystemMessage.test.tsx +2 -9
  109. package/src/CodeBlock/CodeBlock.doc.mjs +2 -2
  110. package/src/CodeBlock/CodeBlock.tsx +2 -2
  111. package/src/DateInput/DateInput.test.tsx +4 -4
  112. package/src/DateInput/DateInput.tsx +15 -4
  113. package/src/DateRangeInput/DateRangeInput.test.tsx +2 -2
  114. package/src/DateTimeInput/DateTimeInput.test.tsx +6 -4
  115. package/src/DateTimeInput/DateTimeInput.tsx +18 -7
  116. package/src/DropdownMenu/DropdownMenuSelectable.test.tsx +4 -77
  117. package/src/Field/Field.test.tsx +42 -0
  118. package/src/Field/Field.tsx +6 -0
  119. package/src/Field/InputClearButton.test.tsx +35 -1
  120. package/src/Field/InputClearButton.tsx +7 -3
  121. package/src/Field/PanelSearchInput.tsx +21 -8
  122. package/src/FieldStatus/FieldStatus.spec.md +27 -17
  123. package/src/FieldStatus/FieldStatus.test.tsx +7 -5
  124. package/src/FieldStatus/__tests__/StatusMessage.a11y.chromium.spec.ts +198 -0
  125. package/src/FieldStatus/__tests__/StatusMessage.a11y.known-failures.ts +13 -0
  126. package/src/FieldStatus/__tests__/StatusMessage.a11y.renders.tsx +305 -0
  127. package/src/FieldStatus/__tests__/StatusMessage.a11y.states.ts +317 -0
  128. package/src/FieldStatus/__tests__/StatusMessage.a11y.test.tsx +155 -0
  129. package/src/FileInput/FileInput.tsx +10 -1
  130. package/src/FormLayout/__snapshots__/FormLayout.test.tsx.snap +3 -3
  131. package/src/HoverCard/HoverCard.doc.mjs +4 -4
  132. package/src/HoverCard/useHoverCard.tsx +2 -2
  133. package/src/Indicator/CheckboxIndicator.tsx +2 -2
  134. package/src/Indicator/Indicator.doc.mjs +2 -2
  135. package/src/Indicator/Indicator.test.tsx +1 -1
  136. package/src/Indicator/RadioIndicator.tsx +2 -2
  137. package/src/Layer/layerStack.ts +20 -9
  138. package/src/Layer/useLayerDismissal.ts +2 -3
  139. package/src/MultiSelector/MultiSelector.test.tsx +4 -4
  140. package/src/NavIcon/NavIcon.doc.mjs +4 -4
  141. package/src/NavIcon/NavIcon.tsx +2 -2
  142. package/src/NumberInput/NumberInput.tsx +18 -7
  143. package/src/Popover/Popover.doc.mjs +10 -10
  144. package/src/Popover/Popover.spec.md +55 -65
  145. package/src/Popover/Popover.test.tsx +29 -0
  146. package/src/Popover/usePopover.doc.mjs +4 -4
  147. package/src/Popover/usePopover.tsx +7 -4
  148. package/src/ProgressBar/ProgressBar.doc.mjs +4 -4
  149. package/src/ProgressBar/ProgressBar.test.tsx +1 -31
  150. package/src/ProgressBar/ProgressBar.tsx +2 -2
  151. package/src/RadioList/RadioList.test.tsx +5 -144
  152. package/src/RadioList/__tests__/RadioGroup.a11y.chromium.spec.ts +255 -0
  153. package/src/RadioList/__tests__/RadioGroup.a11y.known-failures.ts +12 -0
  154. package/src/RadioList/__tests__/RadioGroup.a11y.renders.tsx +232 -0
  155. package/src/RadioList/__tests__/RadioGroup.a11y.states.ts +503 -0
  156. package/src/RadioList/__tests__/RadioGroup.a11y.test.tsx +217 -0
  157. package/src/ScrollableArea/ScrollableArea.doc.mjs +100 -0
  158. package/src/ScrollableArea/ScrollableArea.spec.md +189 -0
  159. package/src/ScrollableArea/ScrollableArea.test.tsx +299 -0
  160. package/src/ScrollableArea/ScrollableArea.tsx +259 -0
  161. package/src/ScrollableArea/index.ts +26 -0
  162. package/src/ScrollableArea/modules/useScrollableArea.spec.md +121 -0
  163. package/src/SegmentedControl/SegmentedControl.test.tsx +5 -172
  164. package/src/Selector/Selector.test.tsx +4 -4
  165. package/src/Spinner/Spinner.test.tsx +0 -18
  166. package/src/StatusDot/StatusDot.doc.mjs +4 -4
  167. package/src/StatusDot/StatusDot.tsx +2 -2
  168. package/src/TabList/TabList.test.tsx +5 -9
  169. package/src/TabList/__tests__/Tabs.a11y.chromium.spec.ts +191 -0
  170. package/src/TabList/__tests__/Tabs.a11y.known-failures.ts +45 -0
  171. package/src/TabList/__tests__/Tabs.a11y.renders.tsx +92 -0
  172. package/src/TabList/__tests__/Tabs.a11y.states.ts +247 -0
  173. package/src/TabList/__tests__/Tabs.a11y.test.tsx +153 -0
  174. package/src/Table/Table.doc.mjs +2 -2
  175. package/src/TextArea/TextArea.doc.mjs +4 -4
  176. package/src/TextArea/TextArea.tsx +2 -2
  177. package/src/TextInput/TextInput.doc.mjs +2 -1
  178. package/src/TextInput/TextInput.test.tsx +94 -0
  179. package/src/TextInput/TextInput.tsx +22 -6
  180. package/src/TimeInput/TimeInput.tsx +18 -7
  181. package/src/Toast/ToastViewport.test.tsx +1 -39
  182. package/src/Typeahead/BaseTypeahead.doc.mjs +229 -33
  183. package/src/Typeahead/BaseTypeahead.spec.md +269 -0
  184. package/src/Typeahead/BaseTypeahead.test.tsx +200 -0
  185. package/src/Typeahead/BaseTypeahead.tsx +99 -30
  186. package/src/hooks/index.ts +13 -0
  187. package/src/hooks/scrollGeometry.ts +155 -0
  188. package/src/hooks/scrollOwnerRegistry.ts +47 -0
  189. package/src/hooks/useFocusTrap.ts +22 -11
  190. package/src/hooks/useFocusTrapEscapeShim.test.tsx +4 -3
  191. package/src/hooks/useScrollableArea.doc.mjs +108 -0
  192. package/src/hooks/useScrollableArea.test.tsx +437 -0
  193. package/src/hooks/useScrollableArea.ts +469 -0
  194. package/src/index.ts +1 -0
  195. package/src/theme/defineTheme.test.ts +65 -105
  196. package/src/theme/defineTheme.ts +3 -9
  197. package/src/theme/derivedVarRegistry.ts +1 -1
  198. package/src/theme/localTokens.ts +25 -96
  199. package/src/theme/publicThemeHelperContract.test.ts +2 -2
  200. package/src/theme/themeAdaptations.test.ts +16 -42
  201. package/src/theme/themeAdaptations.ts +6 -9
  202. package/src/utils/themeProps.test.ts +29 -10
  203. package/src/utils/themeProps.ts +36 -17
@@ -1,6 +1,6 @@
1
1
  // Copyright (c) Meta Platforms, Inc. and affiliates.
2
2
 
3
- import {describe, it, expect} from 'vitest';
3
+ import {describe, expect, it} from 'vitest';
4
4
  import {themeDataAttributes, themeProps} from './themeProps';
5
5
 
6
6
  describe('themeProps', () => {
@@ -8,19 +8,38 @@ describe('themeProps', () => {
8
8
  expect(themeProps('card').className).toBe('astryx-card');
9
9
  });
10
10
 
11
- it('does not emit bare prop-value classes', () => {
11
+ it('continues to emit released bare prop and state classes through 0.7.0', () => {
12
12
  expect(
13
13
  themeProps('button', {variant: 'secondary', size: 'sm'}).className,
14
- ).toBe('astryx-button');
15
- expect(themeProps('heading', {level: 1}).className).toBe('astryx-heading');
14
+ ).toBe('astryx-button secondary sm');
15
+ expect(themeProps('switch', {checked: 'checked'}).className).toBe(
16
+ 'astryx-switch checked',
17
+ );
18
+ });
19
+
20
+ it('prefixes numeric compatibility classes with the prop name', () => {
21
+ expect(themeProps('heading', {level: 1}).className).toBe(
22
+ 'astryx-heading level-1',
23
+ );
24
+ expect(themeProps('heading', {level: '3'}).className).toBe(
25
+ 'astryx-heading level-3',
26
+ );
27
+ });
28
+
29
+ it('skips nullish compatibility classes', () => {
30
+ expect(
31
+ themeProps('button', {variant: 'primary', size: undefined}).className,
32
+ ).toBe('astryx-button primary');
16
33
  });
17
34
 
18
35
  it('continues to emit deprecated target-name aliases when requested', () => {
19
36
  expect(
20
- themeProps('progress-bar', undefined, {
21
- legacyNames: ['progressbar'],
22
- }).className,
23
- ).toBe('astryx-progress-bar astryx-progressbar');
37
+ themeProps(
38
+ 'progress-bar',
39
+ {variant: 'positive'},
40
+ {legacyNames: ['progressbar']},
41
+ ).className,
42
+ ).toBe('astryx-progress-bar positive astryx-progressbar');
24
43
  });
25
44
 
26
45
  it('reflects visual props as data attributes', () => {
@@ -45,9 +64,9 @@ describe('themeProps', () => {
45
64
  });
46
65
  });
47
66
 
48
- it('returns the target class and data attributes together', () => {
67
+ it('returns compatibility classes and canonical data attributes together', () => {
49
68
  expect(themeProps('button', {variant: 'primary', size: 'sm'})).toEqual({
50
- className: 'astryx-button',
69
+ className: 'astryx-button primary sm',
51
70
  'data-variant': 'primary',
52
71
  'data-size': 'sm',
53
72
  });
@@ -11,13 +11,20 @@ export function themeDataAttributeName(prop: string): `data-${string}` {
11
11
  return `data-${prop.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase()}`;
12
12
  }
13
13
 
14
+ function legacyClassTokenForPropValue(prop: string, value: string): string {
15
+ // CSS classes cannot start with a digit, so preserve the released prop prefix.
16
+ return /^\d/.test(value) ? `${prop}-${value}` : value;
17
+ }
18
+
14
19
  /**
15
20
  * Build the stable astryx-* class name string for a component.
16
21
  *
17
22
  * Every component renders one stable target class (`astryx-button`,
18
- * `astryx-card`, etc.). Visual props and runtime states are reflected only as
19
- * data attributes (`data-variant`, `data-size`, `data-selected`, etc.), which
20
- * preserve the axis name and cannot collide when two axes share a value.
23
+ * `astryx-card`, etc.). Visual props and runtime states use explicit data
24
+ * attributes (`data-variant`, `data-size`, `data-selected`, etc.) as their
25
+ * canonical selector surface. Released bare value/state classes remain on the
26
+ * same element as deprecated compatibility aliases until their 0.7.0 removal
27
+ * window.
21
28
  *
22
29
  * The `astryx-` prefix comes from the centralized naming module
23
30
  * (`packages/core/src/naming.ts`) so the namespace lives in one place.
@@ -26,10 +33,22 @@ export function themeDataAttributeName(prop: string): `data-${string}` {
26
33
  * <!-- SYNC: packages/core/src/utils/parseStyleKey.ts -->
27
34
  *
28
35
  * @param component - Component name in lowercase (e.g. 'button', 'card')
29
- * @returns Stable class name (e.g. "astryx-button")
36
+ * @param props - Visual prop values whose released bare classes remain aliases
37
+ * @returns Stable target and deprecated compatibility classes
30
38
  */
31
- function buildClassName(component: string): string {
32
- return stableClassName(component);
39
+ function buildClassName(component: string, props?: ClassProps): string {
40
+ const classes = [stableClassName(component)];
41
+
42
+ if (props) {
43
+ for (const [prop, value] of Object.entries(props)) {
44
+ if (value == null) {
45
+ continue;
46
+ }
47
+ classes.push(legacyClassTokenForPropValue(prop, String(value)));
48
+ }
49
+ }
50
+
51
+ return classes.join(' ');
33
52
  }
34
53
 
35
54
  /**
@@ -58,12 +77,13 @@ export function themeDataAttributes(props?: ClassProps): ThemeDataAttributes {
58
77
  * Build the props object components should spread onto the same element that
59
78
  * receives the stable Astryx class name.
60
79
  *
61
- * This emits one stable astryx target class plus data-attribute reflection for
62
- * visual props and runtime states. For example:
80
+ * This emits one stable Astryx target, deprecated bare compatibility classes,
81
+ * and canonical data-attribute reflection for visual props and runtime states.
82
+ * For example:
63
83
  *
64
84
  * ```ts
65
85
  * themeProps('button', { variant: 'primary', size: 'sm' })
66
- * // → { className: 'astryx-button', data-variant: 'primary', data-size: 'sm' }
86
+ * // → { className: 'astryx-button primary sm', data-variant: 'primary', data-size: 'sm' }
67
87
  * ```
68
88
  */
69
89
  /**
@@ -71,17 +91,16 @@ export function themeDataAttributes(props?: ClassProps): ThemeDataAttributes {
71
91
  */
72
92
  export type ThemePropsOptions = {
73
93
  /**
74
- * Stable class names to emit ALONGSIDE the component's own, for targets that
75
- * have been renamed.
94
+ * Stable target names to emit alongside the canonical target for backwards
95
+ * compatibility.
76
96
  *
77
97
  * A theme target is public API: renaming one silently breaks every theme
78
- * that styles it. Emitting the old name beside the new one keeps those
79
- * themes working through a deprecation window, at the cost of one extra
80
- * class on the element until the old name is dropped in a major.
98
+ * that styles it. Keep aliases emitted unless a separate compatibility
99
+ * decision explicitly retires them.
81
100
  *
82
101
  * Pass plain string literals — the theming guards scan for them statically.
83
- * Document the old name with `deprecated` in the component's
84
- * `theming.targets` so the docsite says which to use.
102
+ * Document each old name with `deprecatedFor` in the component's
103
+ * `theming.targets` so discovery and diagnostics name the replacement.
85
104
  */
86
105
  legacyNames?: ReadonlyArray<string>;
87
106
  };
@@ -91,7 +110,7 @@ export function themeProps(
91
110
  props?: ClassProps,
92
111
  options?: ThemePropsOptions,
93
112
  ): ThemeProps {
94
- const className = buildClassName(component);
113
+ const className = buildClassName(component, props);
95
114
  const legacy = options?.legacyNames?.map(name => stableClassName(name)) ?? [];
96
115
 
97
116
  return {