@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.
- package/CHANGELOG.md +41 -3
- package/dist/AppShell/AppShell.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheetSwitcher.d.ts +12 -1
- package/dist/BottomSheet/BottomSheetSwitcher.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheetSwitcher.js +44 -15
- package/dist/Breadcrumbs/BreadcrumbItem.d.ts +3 -2
- package/dist/Breadcrumbs/BreadcrumbItem.d.ts.map +1 -1
- package/dist/Breadcrumbs/BreadcrumbItem.js +3 -7
- package/dist/Center/Center.d.ts +23 -16
- package/dist/Center/Center.d.ts.map +1 -1
- package/dist/Center/Center.js +7 -5
- package/dist/CodeBlock/CodeBlock.js +2 -2
- package/dist/DateInput/DateInput.d.ts.map +1 -1
- package/dist/DateInput/DateInput.js +12 -2
- package/dist/DateTimeInput/DateTimeInput.d.ts.map +1 -1
- package/dist/DateTimeInput/DateTimeInput.js +12 -2
- package/dist/Field/Field.d.ts.map +1 -1
- package/dist/Field/Field.js +1 -0
- package/dist/Field/InputClearButton.d.ts +2 -2
- package/dist/Field/InputClearButton.d.ts.map +1 -1
- package/dist/Field/InputClearButton.js +5 -1
- package/dist/Field/PanelSearchInput.d.ts.map +1 -1
- package/dist/Field/PanelSearchInput.js +16 -4
- package/dist/FileInput/FileInput.d.ts.map +1 -1
- package/dist/FileInput/FileInput.js +12 -1
- package/dist/HoverCard/useHoverCard.js +2 -2
- package/dist/Indicator/CheckboxIndicator.js +2 -2
- package/dist/Indicator/RadioIndicator.js +2 -2
- package/dist/Layer/layerStack.d.ts +10 -0
- package/dist/Layer/layerStack.d.ts.map +1 -1
- package/dist/Layer/layerStack.js +21 -9
- package/dist/Layer/useLayerDismissal.d.ts +2 -3
- package/dist/Layer/useLayerDismissal.d.ts.map +1 -1
- package/dist/Layer/useLayerDismissal.js +2 -3
- package/dist/NavIcon/NavIcon.js +2 -2
- package/dist/NumberInput/NumberInput.d.ts.map +1 -1
- package/dist/NumberInput/NumberInput.js +12 -2
- package/dist/Popover/usePopover.d.ts +3 -2
- package/dist/Popover/usePopover.d.ts.map +1 -1
- package/dist/Popover/usePopover.js +4 -2
- package/dist/ProgressBar/ProgressBar.js +2 -2
- package/dist/ScrollableArea/ScrollableArea.d.ts +79 -0
- package/dist/ScrollableArea/ScrollableArea.d.ts.map +1 -0
- package/dist/ScrollableArea/ScrollableArea.js +144 -0
- package/dist/ScrollableArea/index.d.ts +11 -0
- package/dist/ScrollableArea/index.d.ts.map +1 -0
- package/dist/ScrollableArea/index.js +11 -0
- package/dist/StatusDot/StatusDot.js +2 -2
- package/dist/TextArea/TextArea.js +2 -2
- package/dist/TextInput/TextInput.d.ts.map +1 -1
- package/dist/TextInput/TextInput.js +19 -4
- package/dist/TimeInput/TimeInput.d.ts.map +1 -1
- package/dist/TimeInput/TimeInput.js +12 -2
- package/dist/Typeahead/BaseTypeahead.d.ts +21 -14
- package/dist/Typeahead/BaseTypeahead.d.ts.map +1 -1
- package/dist/Typeahead/BaseTypeahead.js +56 -20
- package/dist/astryx.css +15 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/scrollGeometry.d.ts +24 -0
- package/dist/hooks/scrollGeometry.d.ts.map +1 -0
- package/dist/hooks/scrollGeometry.js +86 -0
- package/dist/hooks/scrollOwnerRegistry.d.ts +15 -0
- package/dist/hooks/scrollOwnerRegistry.d.ts.map +1 -0
- package/dist/hooks/scrollOwnerRegistry.js +24 -0
- package/dist/hooks/useFocusTrap.d.ts +8 -0
- package/dist/hooks/useFocusTrap.d.ts.map +1 -1
- package/dist/hooks/useFocusTrap.js +22 -11
- package/dist/hooks/useScrollableArea.d.ts +51 -0
- package/dist/hooks/useScrollableArea.d.ts.map +1 -0
- package/dist/hooks/useScrollableArea.js +287 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/theme/defineTheme.d.ts +2 -6
- package/dist/theme/defineTheme.d.ts.map +1 -1
- package/dist/theme/defineTheme.js +1 -1
- package/dist/theme/derivedVarRegistry.js +1 -1
- package/dist/theme/localTokens.d.ts +8 -11
- package/dist/theme/localTokens.d.ts.map +1 -1
- package/dist/theme/localTokens.js +17 -71
- package/dist/theme/themeAdaptations.d.ts.map +1 -1
- package/dist/theme/themeAdaptations.js +4 -4
- package/dist/utils/themeProps.d.ts +10 -10
- package/dist/utils/themeProps.d.ts.map +1 -1
- package/dist/utils/themeProps.js +27 -10
- package/locales/en.json +16 -0
- package/locales/pseudo.json +12 -0
- package/package.json +7 -2
- package/src/AppShell/AppShell.test.tsx +36 -0
- package/src/AppShell/AppShell.tsx +4 -1
- package/src/AspectRatio/AspectRatio.doc.mjs +3 -3
- package/src/Banner/Banner.test.tsx +3 -1
- package/src/BottomSheet/BottomSheetSwitcher.doc.mjs +56 -1
- package/src/BottomSheet/BottomSheetSwitcher.spec.md +211 -0
- package/src/BottomSheet/BottomSheetSwitcher.test.tsx +134 -2
- package/src/BottomSheet/BottomSheetSwitcher.tsx +43 -20
- package/src/Breadcrumbs/BreadcrumbItem.doc.mjs +10 -5
- package/src/Breadcrumbs/BreadcrumbItem.spec.md +225 -0
- package/src/Breadcrumbs/BreadcrumbItem.tsx +8 -13
- package/src/Breadcrumbs/Breadcrumbs.doc.mjs +2 -2
- package/src/Breadcrumbs/Breadcrumbs.test.tsx +49 -2
- package/src/Center/Center.doc.mjs +32 -28
- package/src/Center/Center.spec.md +225 -0
- package/src/Center/Center.test.tsx +42 -4
- package/src/Center/Center.tsx +24 -17
- package/src/Chat/ChatSystemMessage.test.tsx +2 -9
- package/src/CodeBlock/CodeBlock.doc.mjs +2 -2
- package/src/CodeBlock/CodeBlock.tsx +2 -2
- package/src/DateInput/DateInput.test.tsx +4 -4
- package/src/DateInput/DateInput.tsx +15 -4
- package/src/DateRangeInput/DateRangeInput.test.tsx +2 -2
- package/src/DateTimeInput/DateTimeInput.test.tsx +6 -4
- package/src/DateTimeInput/DateTimeInput.tsx +18 -7
- package/src/DropdownMenu/DropdownMenuSelectable.test.tsx +4 -77
- package/src/Field/Field.test.tsx +42 -0
- package/src/Field/Field.tsx +6 -0
- package/src/Field/InputClearButton.test.tsx +35 -1
- package/src/Field/InputClearButton.tsx +7 -3
- package/src/Field/PanelSearchInput.tsx +21 -8
- package/src/FieldStatus/FieldStatus.spec.md +27 -17
- package/src/FieldStatus/FieldStatus.test.tsx +7 -5
- package/src/FieldStatus/__tests__/StatusMessage.a11y.chromium.spec.ts +198 -0
- package/src/FieldStatus/__tests__/StatusMessage.a11y.known-failures.ts +13 -0
- package/src/FieldStatus/__tests__/StatusMessage.a11y.renders.tsx +305 -0
- package/src/FieldStatus/__tests__/StatusMessage.a11y.states.ts +317 -0
- package/src/FieldStatus/__tests__/StatusMessage.a11y.test.tsx +155 -0
- package/src/FileInput/FileInput.tsx +10 -1
- package/src/FormLayout/__snapshots__/FormLayout.test.tsx.snap +3 -3
- package/src/HoverCard/HoverCard.doc.mjs +4 -4
- package/src/HoverCard/useHoverCard.tsx +2 -2
- package/src/Indicator/CheckboxIndicator.tsx +2 -2
- package/src/Indicator/Indicator.doc.mjs +2 -2
- package/src/Indicator/Indicator.test.tsx +1 -1
- package/src/Indicator/RadioIndicator.tsx +2 -2
- package/src/Layer/layerStack.ts +20 -9
- package/src/Layer/useLayerDismissal.ts +2 -3
- package/src/MultiSelector/MultiSelector.test.tsx +4 -4
- package/src/NavIcon/NavIcon.doc.mjs +4 -4
- package/src/NavIcon/NavIcon.tsx +2 -2
- package/src/NumberInput/NumberInput.tsx +18 -7
- package/src/Popover/Popover.doc.mjs +10 -10
- package/src/Popover/Popover.spec.md +55 -65
- package/src/Popover/Popover.test.tsx +29 -0
- package/src/Popover/usePopover.doc.mjs +4 -4
- package/src/Popover/usePopover.tsx +7 -4
- package/src/ProgressBar/ProgressBar.doc.mjs +4 -4
- package/src/ProgressBar/ProgressBar.test.tsx +1 -31
- package/src/ProgressBar/ProgressBar.tsx +2 -2
- package/src/RadioList/RadioList.test.tsx +5 -144
- package/src/RadioList/__tests__/RadioGroup.a11y.chromium.spec.ts +255 -0
- package/src/RadioList/__tests__/RadioGroup.a11y.known-failures.ts +12 -0
- package/src/RadioList/__tests__/RadioGroup.a11y.renders.tsx +232 -0
- package/src/RadioList/__tests__/RadioGroup.a11y.states.ts +503 -0
- package/src/RadioList/__tests__/RadioGroup.a11y.test.tsx +217 -0
- package/src/ScrollableArea/ScrollableArea.doc.mjs +100 -0
- package/src/ScrollableArea/ScrollableArea.spec.md +189 -0
- package/src/ScrollableArea/ScrollableArea.test.tsx +299 -0
- package/src/ScrollableArea/ScrollableArea.tsx +259 -0
- package/src/ScrollableArea/index.ts +26 -0
- package/src/ScrollableArea/modules/useScrollableArea.spec.md +121 -0
- package/src/SegmentedControl/SegmentedControl.test.tsx +5 -172
- package/src/Selector/Selector.test.tsx +4 -4
- package/src/Spinner/Spinner.test.tsx +0 -18
- package/src/StatusDot/StatusDot.doc.mjs +4 -4
- package/src/StatusDot/StatusDot.tsx +2 -2
- package/src/TabList/TabList.test.tsx +5 -9
- package/src/TabList/__tests__/Tabs.a11y.chromium.spec.ts +191 -0
- package/src/TabList/__tests__/Tabs.a11y.known-failures.ts +45 -0
- package/src/TabList/__tests__/Tabs.a11y.renders.tsx +92 -0
- package/src/TabList/__tests__/Tabs.a11y.states.ts +247 -0
- package/src/TabList/__tests__/Tabs.a11y.test.tsx +153 -0
- package/src/Table/Table.doc.mjs +2 -2
- package/src/TextArea/TextArea.doc.mjs +4 -4
- package/src/TextArea/TextArea.tsx +2 -2
- package/src/TextInput/TextInput.doc.mjs +2 -1
- package/src/TextInput/TextInput.test.tsx +94 -0
- package/src/TextInput/TextInput.tsx +22 -6
- package/src/TimeInput/TimeInput.tsx +18 -7
- package/src/Toast/ToastViewport.test.tsx +1 -39
- package/src/Typeahead/BaseTypeahead.doc.mjs +229 -33
- package/src/Typeahead/BaseTypeahead.spec.md +269 -0
- package/src/Typeahead/BaseTypeahead.test.tsx +200 -0
- package/src/Typeahead/BaseTypeahead.tsx +99 -30
- package/src/hooks/index.ts +13 -0
- package/src/hooks/scrollGeometry.ts +155 -0
- package/src/hooks/scrollOwnerRegistry.ts +47 -0
- package/src/hooks/useFocusTrap.ts +22 -11
- package/src/hooks/useFocusTrapEscapeShim.test.tsx +4 -3
- package/src/hooks/useScrollableArea.doc.mjs +108 -0
- package/src/hooks/useScrollableArea.test.tsx +437 -0
- package/src/hooks/useScrollableArea.ts +469 -0
- package/src/index.ts +1 -0
- package/src/theme/defineTheme.test.ts +65 -105
- package/src/theme/defineTheme.ts +3 -9
- package/src/theme/derivedVarRegistry.ts +1 -1
- package/src/theme/localTokens.ts +25 -96
- package/src/theme/publicThemeHelperContract.test.ts +2 -2
- package/src/theme/themeAdaptations.test.ts +16 -42
- package/src/theme/themeAdaptations.ts +6 -9
- package/src/utils/themeProps.test.ts +29 -10
- 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,
|
|
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('
|
|
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('
|
|
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(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
|
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
|
});
|
package/src/utils/themeProps.ts
CHANGED
|
@@ -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
|
|
19
|
-
*
|
|
20
|
-
*
|
|
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
|
-
* @
|
|
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
|
-
|
|
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
|
|
62
|
-
* visual props and runtime states.
|
|
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
|
|
75
|
-
*
|
|
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.
|
|
79
|
-
*
|
|
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
|
|
84
|
-
* `theming.targets` so
|
|
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 {
|