@astryxdesign/core 0.1.4-canary.570c837 → 0.1.4-canary.575d8bf
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/dist/Banner/Banner.d.ts.map +1 -1
- package/dist/Banner/Banner.js +8 -1
- package/dist/Calendar/Calendar.d.ts.map +1 -1
- package/dist/Calendar/Calendar.js +31 -11
- package/dist/Calendar/styles.d.ts +2 -2
- package/dist/Calendar/styles.d.ts.map +1 -1
- package/dist/Calendar/styles.js +2 -2
- package/dist/Carousel/Carousel.d.ts.map +1 -1
- package/dist/Carousel/Carousel.js +1 -0
- package/dist/Chat/ChatToolCalls.d.ts.map +1 -1
- package/dist/Chat/ChatToolCalls.js +8 -1
- package/dist/CodeBlock/CodeBlock.d.ts +10 -1
- package/dist/CodeBlock/CodeBlock.d.ts.map +1 -1
- package/dist/CodeBlock/CodeBlock.js +23 -5
- package/dist/Collapsible/Collapsible.d.ts +9 -3
- package/dist/Collapsible/Collapsible.d.ts.map +1 -1
- package/dist/Collapsible/Collapsible.js +101 -13
- package/dist/Collapsible/CollapsibleGroup.d.ts +39 -7
- package/dist/Collapsible/CollapsibleGroup.d.ts.map +1 -1
- package/dist/Collapsible/CollapsibleGroup.js +70 -9
- package/dist/Collapsible/CollapsibleGroupContext.d.ts +31 -0
- package/dist/Collapsible/CollapsibleGroupContext.d.ts.map +1 -1
- package/dist/Collapsible/CollapsibleGroupContext.js +33 -3
- package/dist/Collapsible/index.d.ts +1 -0
- package/dist/Collapsible/index.d.ts.map +1 -1
- package/dist/ContextMenu/ContextMenu.d.ts.map +1 -1
- package/dist/ContextMenu/ContextMenu.js +2 -0
- package/dist/DateTimeInput/DateTimeInput.d.ts.map +1 -1
- package/dist/DateTimeInput/DateTimeInput.js +2 -0
- package/dist/Grid/Grid.d.ts +4 -3
- package/dist/Grid/Grid.d.ts.map +1 -1
- package/dist/Grid/Grid.js +26 -9
- package/dist/Icon/Icon.d.ts.map +1 -1
- package/dist/Icon/Icon.js +5 -1
- package/dist/Lightbox/Lightbox.d.ts.map +1 -1
- package/dist/Lightbox/Lightbox.js +26 -2
- package/dist/NumberInput/NumberInput.d.ts.map +1 -1
- package/dist/NumberInput/NumberInput.js +32 -16
- package/dist/Pagination/Pagination.d.ts.map +1 -1
- package/dist/Pagination/Pagination.js +87 -36
- package/dist/ProgressBar/ProgressBar.d.ts.map +1 -1
- package/dist/ProgressBar/ProgressBar.js +2 -1
- package/dist/Resizable/ResizeHandle.d.ts.map +1 -1
- package/dist/Resizable/ResizeHandle.js +10 -2
- package/dist/SideNav/SideNav.d.ts.map +1 -1
- package/dist/SideNav/SideNav.js +6 -2
- package/dist/TabList/TabMenu.d.ts.map +1 -1
- package/dist/TabList/TabMenu.js +34 -7
- package/dist/Table/BaseTable.d.ts.map +1 -1
- package/dist/Table/BaseTable.js +12 -2
- package/dist/Table/plugins/columnResize/useTableColumnResize.d.ts.map +1 -1
- package/dist/Table/plugins/columnResize/useTableColumnResize.js +5 -2
- package/dist/Table/plugins/pagination/paginateData.d.ts.map +1 -1
- package/dist/Table/plugins/pagination/paginateData.js +5 -1
- package/dist/Table/plugins/selection/useTableSelectionState.d.ts.map +1 -1
- package/dist/Table/plugins/selection/useTableSelectionState.js +11 -1
- package/dist/Table/plugins/sortable/useTableSortableState.d.ts.map +1 -1
- package/dist/Table/plugins/sortable/useTableSortableState.js +8 -4
- package/dist/Thumbnail/Thumbnail.d.ts +3 -2
- package/dist/Thumbnail/Thumbnail.d.ts.map +1 -1
- package/dist/Thumbnail/Thumbnail.js +1 -0
- package/dist/TimeInput/TimeInput.d.ts.map +1 -1
- package/dist/TimeInput/TimeInput.js +6 -1
- package/dist/Toast/Toast.d.ts.map +1 -1
- package/dist/Toast/Toast.js +11 -3
- package/dist/Toast/ToastViewport.d.ts.map +1 -1
- package/dist/Toast/ToastViewport.js +12 -0
- package/dist/Typeahead/BaseTypeahead.d.ts.map +1 -1
- package/dist/Typeahead/BaseTypeahead.js +5 -2
- package/dist/astryx.css +1 -0
- package/dist/astryx.umd.js +48 -48
- package/dist/astryx.umd.js.map +4 -4
- package/dist/hooks/focusableSelector.d.ts +1 -1
- package/dist/hooks/focusableSelector.d.ts.map +1 -1
- package/dist/hooks/focusableSelector.js +1 -1
- package/dist/hooks/useFocusTrap.d.ts +3 -0
- package/dist/hooks/useFocusTrap.d.ts.map +1 -1
- package/dist/hooks/useFocusTrap.js +38 -1
- package/dist/theme/defineTheme.d.ts +1 -1
- package/dist/theme/defineTheme.d.ts.map +1 -1
- package/dist/theme/expandColorScale.d.ts.map +1 -1
- package/dist/theme/expandColorScale.js +10 -3
- package/dist/theme/hct.d.ts +0 -15
- package/dist/theme/hct.d.ts.map +1 -1
- package/dist/theme/hct.js +9 -9
- package/dist/theme/tokens.d.ts +10 -2
- package/dist/theme/tokens.d.ts.map +1 -1
- package/dist/theme/tokens.js +220 -4
- package/dist/utils/color.d.ts +42 -0
- package/dist/utils/color.d.ts.map +1 -0
- package/dist/utils/color.js +150 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -1
- package/dist/utils/timeParser.d.ts.map +1 -1
- package/dist/utils/timeParser.js +8 -5
- package/package.json +1 -1
- package/src/Avatar/Avatar.doc.mjs +11 -0
- package/src/Banner/Banner.doc.mjs +8 -0
- package/src/Banner/Banner.test.tsx +38 -0
- package/src/Banner/Banner.tsx +8 -1
- package/src/Calendar/Calendar.doc.mjs +1 -1
- package/src/Calendar/Calendar.test.tsx +112 -4
- package/src/Calendar/Calendar.tsx +26 -5
- package/src/Calendar/styles.ts +12 -2
- package/src/Carousel/Carousel.doc.mjs +12 -12
- package/src/Carousel/Carousel.test.tsx +13 -0
- package/src/Carousel/Carousel.tsx +1 -0
- package/src/Chat/Chat.doc.mjs +1 -1
- package/src/Chat/ChatToolCalls.test.tsx +55 -0
- package/src/Chat/ChatToolCalls.tsx +10 -12
- package/src/CheckboxInput/CheckboxInput.doc.mjs +3 -3
- package/src/Citation/Citation.doc.mjs +5 -0
- package/src/CodeBlock/CodeBlock.doc.mjs +7 -2
- package/src/CodeBlock/CodeBlock.test.tsx +87 -3
- package/src/CodeBlock/CodeBlock.tsx +43 -3
- package/src/Collapsible/Collapsible.doc.mjs +8 -4
- package/src/Collapsible/Collapsible.tsx +86 -10
- package/src/Collapsible/CollapsibleGroup.doc.mjs +27 -3
- package/src/Collapsible/CollapsibleGroup.test.tsx +288 -0
- package/src/Collapsible/CollapsibleGroup.tsx +107 -9
- package/src/Collapsible/CollapsibleGroupContext.tsx +42 -2
- package/src/Collapsible/index.ts +4 -0
- package/src/CommandPalette/CommandPaletteEmpty.doc.mjs +5 -0
- package/src/CommandPalette/CommandPaletteGroup.doc.mjs +10 -0
- package/src/CommandPalette/CommandPaletteInput.doc.mjs +6 -0
- package/src/CommandPalette/CommandPaletteItem.doc.mjs +6 -0
- package/src/CommandPalette/CommandPaletteList.doc.mjs +9 -0
- package/src/ContextMenu/ContextMenu.doc.mjs +15 -0
- package/src/ContextMenu/ContextMenu.test.tsx +15 -0
- package/src/ContextMenu/ContextMenu.tsx +2 -0
- package/src/ContextMenu/ContextMenuItem.doc.mjs +6 -0
- package/src/DateTimeInput/DateTimeInput.test.tsx +70 -0
- package/src/DateTimeInput/DateTimeInput.tsx +2 -0
- package/src/Dialog/DialogHeader.doc.mjs +45 -0
- package/src/DropdownMenu/DropdownMenu.doc.mjs +1 -1
- package/src/Field/FieldLabel.test.tsx +2 -2
- package/src/FormLayout/__snapshots__/FormLayout.test.tsx.snap +0 -3
- package/src/Grid/Grid.test.tsx +43 -18
- package/src/Grid/Grid.tsx +26 -9
- package/src/Icon/Icon.test.tsx +41 -29
- package/src/Icon/Icon.tsx +6 -2
- package/src/Layout/LayoutContent.doc.mjs +12 -0
- package/src/Layout/LayoutPanel.doc.mjs +40 -0
- package/src/Lightbox/Lightbox.doc.mjs +5 -0
- package/src/Lightbox/Lightbox.test.tsx +123 -2
- package/src/Lightbox/Lightbox.tsx +29 -1
- package/src/NavMenu/NavMenu.doc.mjs +15 -0
- package/src/NumberInput/NumberInput.test.tsx +48 -3
- package/src/NumberInput/NumberInput.tsx +32 -15
- package/src/Overlay/Overlay.doc.mjs +6 -0
- package/src/Pagination/Pagination.test.tsx +143 -0
- package/src/Pagination/Pagination.tsx +75 -23
- package/src/Popover/Popover.test.tsx +65 -0
- package/src/ProgressBar/ProgressBar.test.tsx +10 -0
- package/src/ProgressBar/ProgressBar.tsx +2 -1
- package/src/Resizable/ResizeHandle.test.tsx +180 -0
- package/src/Resizable/ResizeHandle.tsx +10 -2
- package/src/SegmentedControl/SegmentedControl.doc.mjs +1 -1
- package/src/SelectableCard/SelectableCard.doc.mjs +1 -1
- package/src/SideNav/SideNav.doc.mjs +7 -1
- package/src/SideNav/SideNav.test.tsx +20 -0
- package/src/SideNav/SideNav.tsx +6 -2
- package/src/TabList/TabList.test.tsx +185 -1
- package/src/TabList/TabMenu.tsx +45 -9
- package/src/Table/BaseTable.tsx +11 -1
- package/src/Table/Table.test.tsx +51 -0
- package/src/Table/plugins/columnResize/useTableColumnResize.test.tsx +13 -0
- package/src/Table/plugins/columnResize/useTableColumnResize.tsx +3 -1
- package/src/Table/plugins/pagination/paginateData.ts +5 -1
- package/src/Table/plugins/pagination/useTablePagination.test.tsx +13 -0
- package/src/Table/plugins/selection/useTableSelectionState.test.tsx +23 -0
- package/src/Table/plugins/selection/useTableSelectionState.tsx +11 -6
- package/src/Table/plugins/sortable/useTableSortableState.test.tsx +35 -1
- package/src/Table/plugins/sortable/useTableSortableState.tsx +8 -4
- package/src/TextArea/TextArea.test.tsx +3 -3
- package/src/TextInput/TextInput.test.tsx +3 -3
- package/src/Thumbnail/Thumbnail.test.tsx +36 -2
- package/src/Thumbnail/Thumbnail.tsx +4 -2
- package/src/TimeInput/TimeInput.test.tsx +37 -0
- package/src/TimeInput/TimeInput.tsx +11 -1
- package/src/Timestamp/Timestamp.doc.mjs +1 -1
- package/src/Toast/Toast.tsx +11 -3
- package/src/Toast/ToastViewport.test.tsx +64 -0
- package/src/Toast/ToastViewport.tsx +12 -0
- package/src/ToggleButton/ToggleButton.doc.mjs +1 -0
- package/src/Tokenizer/Tokenizer.doc.mjs +2 -2
- package/src/TopNav/TopNav.doc.mjs +1 -1
- package/src/TreeList/TreeList.doc.mjs +2 -2
- package/src/Typeahead/BaseTypeahead.doc.mjs +19 -0
- package/src/Typeahead/BaseTypeahead.tsx +5 -2
- package/src/Typeahead/Typeahead.doc.mjs +1 -1
- package/src/Typeahead/Typeahead.test.tsx +45 -1
- package/src/__tests__/TestIcon.tsx +26 -0
- package/src/docPropReferences.test.ts +178 -0
- package/src/hooks/focusableSelector.ts +1 -1
- package/src/hooks/useFocusTrap.doc.mjs +4 -2
- package/src/hooks/useFocusTrap.test.tsx +149 -1
- package/src/hooks/useFocusTrap.ts +50 -1
- package/src/theme/SyntaxTheme.doc.mjs +4 -4
- package/src/theme/defineTheme.ts +4 -13
- package/src/theme/derivedVarRegistry.test.ts +2 -2
- package/src/theme/expandColorScale.test.ts +29 -0
- package/src/theme/expandColorScale.ts +11 -6
- package/src/theme/hct.ts +9 -17
- package/src/theme/tokens.test.ts +182 -9
- package/src/theme/tokens.ts +239 -4
- package/src/theme/useTheme.test.tsx +20 -0
- package/src/utils/color.test.ts +133 -0
- package/src/utils/color.ts +148 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/timeParser.test.ts +13 -0
- package/src/utils/timeParser.ts +8 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Banner.d.ts","sourceRoot":"","sources":["../../src/Banner/Banner.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"Banner.d.ts","sourceRoot":"","sources":["../../src/Banner/Banner.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAkB,KAAK,SAA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AC,EACrB,MAAM,EACN,KAAK,EACL,WAAW,EACX,IAAI,EACJ,aAAqB,EACrB,SAAS,EACT,UAAU,EACV,SAAkB,EAClB,iBAAyB,EACzB,QAAQ,EACR,MAAM,EACN,SAAS,EACT,KAAK,EACL,GAAG,EACH,GAAG,IAAI,EACR,EAAE,WAAW,sCAiIb;yBAjJe,MAAM"}
|
package/dist/Banner/Banner.js
CHANGED
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
* - /apps/storybook/stories/Banner.stories.tsx (storybook stories)
|
|
31
31
|
* - /packages/cli/templates/blocks/components/Banner/ (showcase blocks)
|
|
32
32
|
*/
|
|
33
|
-
import { useState } from 'react';
|
|
33
|
+
import { useId, useState } from 'react';
|
|
34
34
|
import * as stylex from '@stylexjs/stylex';
|
|
35
35
|
import { Button } from "../Button/index.js";
|
|
36
36
|
import { Icon } from "../Icon/index.js";
|
|
@@ -249,6 +249,11 @@ export function Banner({
|
|
|
249
249
|
}) {
|
|
250
250
|
const [isDismissed, setIsDismissed] = useState(false);
|
|
251
251
|
const [isExpanded, setIsExpanded] = useState(defaultIsExpanded);
|
|
252
|
+
// Links the expand/collapse toggle to the content region it shows/hides so
|
|
253
|
+
// assistive tech can move from the button to its controlled content
|
|
254
|
+
// (disclosure pattern). The region is conditionally rendered, so aria-controls
|
|
255
|
+
// below is set only while it's mounted to avoid a dangling reference.
|
|
256
|
+
const contentId = useId();
|
|
252
257
|
const defaultIconName = defaultIconNames[status];
|
|
253
258
|
const role = statusRole[status];
|
|
254
259
|
const iconColor = statusIconColor[status];
|
|
@@ -333,6 +338,7 @@ export function Banner({
|
|
|
333
338
|
}),
|
|
334
339
|
onClick: handleToggleExpand,
|
|
335
340
|
"aria-expanded": isExpanded,
|
|
341
|
+
"aria-controls": showContent ? contentId : undefined,
|
|
336
342
|
isIconOnly: true
|
|
337
343
|
}), isDismissable && /*#__PURE__*/_jsx(Button, {
|
|
338
344
|
variant: "ghost",
|
|
@@ -349,6 +355,7 @@ export function Banner({
|
|
|
349
355
|
})]
|
|
350
356
|
})]
|
|
351
357
|
}), showContent && /*#__PURE__*/_jsx("div", {
|
|
358
|
+
id: contentId,
|
|
352
359
|
...mergeProps(themeProps('banner-content', {
|
|
353
360
|
container,
|
|
354
361
|
status
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Calendar.d.ts","sourceRoot":"","sources":["../../src/Calendar/Calendar.tsx"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AA8C5C,YAAY,EACV,aAAa,EACb,SAAS,EACT,aAAa,EACb,SAAS,GACV,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EACV,aAAa,EACb,SAAS,EACT,aAAa,EACb,SAAS,EACV,MAAM,oBAAoB,CAAC;AAI5B,+CAA+C;AAE/C,MAAM,WAAW,cAAc;IAC7B,wEAAwE;IACxE,UAAU,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,IAAI,CAAC;CAC3C;AAID,UAAU,iBAAkB,SAAQ,IAAI,CACtC,SAAS,CAAC,cAAc,CAAC,EACzB,UAAU,GAAG,cAAc,CAC5B;IACC,kDAAkD;IAClD,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAChC,qDAAqD;IACrD,SAAS,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACtC,+CAA+C;IAC/C,cAAc,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IAEvB,4CAA4C;IAC5C,GAAG,CAAC,EAAE,aAAa,CAAC;IAEpB,4CAA4C;IAC5C,GAAG,CAAC,EAAE,aAAa,CAAC;IAEpB;;;OAGG;IACH,eAAe,CAAC,EAAE,aAAa,CAAC,CAAC,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,CAAC;IAEzD;;;OAGG;IACH,SAAS,CAAC,EAAE,aAAa,CAAC;IAE1B,yDAAyD;IACzD,iBAAiB,CAAC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AC;IAEtB,0CAA0C;IAC1C,YAAY,CAAC,EAAE,aAAa,CAAC;IAE7B,qCAAqC;IACrC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,IAAI,KAAK,IAAI,CAAC;CAC9D;AAED,UAAU,kBAAmB,SAAQ,iBAAiB;IACpD,qBAAqB;IACrB,IAAI,EAAE,OAAO,CAAC;IAEd,0BAA0B;IAC1B,KAAK,CAAC,EAAE,SAAS,CAAC;IAElB,0CAA0C;IAC1C,YAAY,CAAC,EAAE,SAAS,CAAC;IAEzB,sCAAsC;IACtC,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;CACvC;AAED,MAAM,MAAM,aAAa,GAAG,mBAAmB,GAAG,kBAAkB,CAAC;AAMrE;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,EAAC,GAAG,EAAE,GAAG,KAAK,EAAC,EAAE,aAAa,+BA4StD;yBA5Se,QAAQ"}
|
|
@@ -62,7 +62,7 @@ export function Calendar({
|
|
|
62
62
|
value,
|
|
63
63
|
defaultValue,
|
|
64
64
|
onChange,
|
|
65
|
-
numberOfMonths = 1,
|
|
65
|
+
numberOfMonths: numberOfMonthsProp = 1,
|
|
66
66
|
min,
|
|
67
67
|
max,
|
|
68
68
|
dateConstraints,
|
|
@@ -82,6 +82,11 @@ export function Calendar({
|
|
|
82
82
|
// DayOfWeek so all downstream date math keeps working with an index.
|
|
83
83
|
const weekStartsOn = normalizeDayOfWeek(weekStartsOnProp);
|
|
84
84
|
|
|
85
|
+
// `numberOfMonths` is typed `1 | 2`; defensively clamp anything else that
|
|
86
|
+
// slips through at runtime to 1 so `Array.from({length})` can't render an
|
|
87
|
+
// absurd number of month grids (e.g. `numberOfMonths={1000}`).
|
|
88
|
+
const numberOfMonths = numberOfMonthsProp === 2 ? 2 : 1;
|
|
89
|
+
|
|
85
90
|
// Today's date (memoized)
|
|
86
91
|
const today = useMemo(() => plainDateToday(), []);
|
|
87
92
|
|
|
@@ -246,10 +251,18 @@ export function Calendar({
|
|
|
246
251
|
children: [/*#__PURE__*/_jsx(Button, {
|
|
247
252
|
label: "Previous month",
|
|
248
253
|
variant: "ghost",
|
|
249
|
-
icon:
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
254
|
+
icon:
|
|
255
|
+
/*#__PURE__*/
|
|
256
|
+
// Wrapper span (not Icon props): Icon's string mode clobbers
|
|
257
|
+
// caller classNames, so the RTL mirror must live on its own
|
|
258
|
+
// element.
|
|
259
|
+
_jsx("span", {
|
|
260
|
+
...stylex.props(calendarStyles.navIcon),
|
|
261
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
262
|
+
icon: "chevronLeft",
|
|
263
|
+
size: "sm",
|
|
264
|
+
color: "inherit"
|
|
265
|
+
})
|
|
253
266
|
}),
|
|
254
267
|
onClick: () => navigateMonth(-1),
|
|
255
268
|
isDisabled: !canNavigatePrevious,
|
|
@@ -260,10 +273,13 @@ export function Calendar({
|
|
|
260
273
|
}), /*#__PURE__*/_jsx(Button, {
|
|
261
274
|
label: "Next month",
|
|
262
275
|
variant: "ghost",
|
|
263
|
-
icon: /*#__PURE__*/_jsx(
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
276
|
+
icon: /*#__PURE__*/_jsx("span", {
|
|
277
|
+
...stylex.props(calendarStyles.navIcon),
|
|
278
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
279
|
+
icon: "chevronRight",
|
|
280
|
+
size: "sm",
|
|
281
|
+
color: "inherit"
|
|
282
|
+
})
|
|
267
283
|
}),
|
|
268
284
|
onClick: () => navigateMonth(1),
|
|
269
285
|
isDisabled: !canNavigateNext,
|
|
@@ -634,6 +650,7 @@ function DayCell({
|
|
|
634
650
|
});
|
|
635
651
|
return /*#__PURE__*/_jsxs("div", {
|
|
636
652
|
role: "gridcell",
|
|
653
|
+
"aria-selected": state.isSelected || state.isInRange || undefined,
|
|
637
654
|
...stylex.props(dayCellStyles.cell),
|
|
638
655
|
children: [state.isInRange && /*#__PURE__*/_jsx("div", {
|
|
639
656
|
...stylex.props(dayCellStyles.rangeBg, dayCellTheme.rangeBg, rangeRounding.roundLeft && dayCellStyles.rangeBgRadiusLeft, rangeRounding.roundRight && dayCellStyles.rangeBgRadiusRight, state.isRangeStart && dayCellStyles.rangeInsetLeft, state.isRangeStart && rangeRounding.roundRight && dayCellStyles.rangeInsetRight, state.isRangeEnd && dayCellStyles.rangeInsetRight, state.isRangeStart && rangeRounding.roundLeft && dayCellStyles.rangeInsetLeft)
|
|
@@ -643,8 +660,11 @@ function DayCell({
|
|
|
643
660
|
type: "button",
|
|
644
661
|
"data-date": day.iso,
|
|
645
662
|
"aria-label": plainDateFormat(date, DATE_FORMAT_WITH_WEEKDAY),
|
|
646
|
-
"aria-
|
|
647
|
-
|
|
663
|
+
"aria-disabled": state.effectivelyDisabled || undefined
|
|
664
|
+
// Mark today's cell programmatically (APG date-picker pattern), not just
|
|
665
|
+
// visually, so screen-reader users can identify the current date.
|
|
666
|
+
,
|
|
667
|
+
"aria-current": state.isToday ? 'date' : undefined,
|
|
648
668
|
disabled: isDisabled
|
|
649
669
|
// Initial roving tab-stop seed; useGridFocus owns it after mount.
|
|
650
670
|
,
|
|
@@ -47,8 +47,8 @@ export declare const calendarStyles: Readonly<{
|
|
|
47
47
|
readonly borderWidth: stylex.StyleXClassNameFor<"borderWidth", 0>;
|
|
48
48
|
}>;
|
|
49
49
|
readonly navIcon: Readonly<{
|
|
50
|
-
readonly
|
|
51
|
-
readonly
|
|
50
|
+
readonly display: stylex.StyleXClassNameFor<"display", "inline-flex">;
|
|
51
|
+
readonly transform: stylex.StyleXClassNameFor<"transform", "scaleX(-1)" | null>;
|
|
52
52
|
}>;
|
|
53
53
|
}>;
|
|
54
54
|
export declare const monthGridStyles: Readonly<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/Calendar/styles.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAgB3C,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/Calendar/styles.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAgB3C,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiDzB,CAAC;AAMH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuC1B,CAAC;AAMH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4GxB,CAAC;AAMH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAoEvB,CAAC"}
|
package/dist/Calendar/styles.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Carousel.d.ts","sourceRoot":"","sources":["../../src/Carousel/Carousel.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAC,KAAK,SAAS,EAA2C,MAAM,OAAO,CAAC;AAc/E,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAE5C,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAGhD,MAAM,WAAW,aAAc,SAAQ,SAAS,CAAC,cAAc,CAAC;IAC9D,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAChC,kEAAkE;IAClE,QAAQ,EAAE,SAAS,CAAC;IACpB;;;OAGG;IAC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AC;IACpC;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAyJD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,QAAQ,CAAC,EACvB,GAAG,EACH,QAAQ,EACR,GAAO,EACP,UAAiB,EACjB,WAAkB,EAClB,OAAe,EACf,OAAO,EACP,YAAY,EAAE,SAAsB,EACpC,MAAM,EACN,SAAS,EACT,KAAK,EACL,aAAa,EAAE,MAAM,EACrB,GAAG,SAAS,EACb,EAAE,aAAa,+BAgJf;yBA9Je,QAAQ"}
|
|
@@ -264,6 +264,7 @@ export function Carousel({
|
|
|
264
264
|
...htmlProps,
|
|
265
265
|
children: [/*#__PURE__*/_jsx("div", {
|
|
266
266
|
ref: composedRef,
|
|
267
|
+
tabIndex: 0,
|
|
267
268
|
...stylex.props(styles.scroller, gapStyles[gap], padding != null && paddingStyles[padding], hasSnap && styles.snap, fadeStyle),
|
|
268
269
|
children: Children.map(children, child => /*#__PURE__*/_jsx("div", {
|
|
269
270
|
...{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatToolCalls.d.ts","sourceRoot":"","sources":["../../src/Chat/ChatToolCalls.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"ChatToolCalls.d.ts","sourceRoot":"","sources":["../../src/Chat/ChatToolCalls.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,EAA+B,KAAK,SAAS,EAAC,MAAM,OAAO,C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;;;;;;;GAoBG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,4BAqJtD;yBArJe,aAAa"}
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
* data prop matches that shape directly — no nested compound components
|
|
18
18
|
* for builders to wire up.
|
|
19
19
|
*/
|
|
20
|
-
import React, { useState, useCallback } from 'react';
|
|
20
|
+
import React, { useState, useCallback, useId } from 'react';
|
|
21
21
|
import * as stylex from '@stylexjs/stylex';
|
|
22
22
|
import "../theme/tokens.stylex.js";
|
|
23
23
|
import { colorVars, spacingVars, typeScaleVars, typographyVars, fontWeightVars, radiusVars, durationVars, easeVars } from "../theme/tokens.stylex.js";
|
|
@@ -106,10 +106,13 @@ function CallRow({
|
|
|
106
106
|
const status = call.status ?? 'complete';
|
|
107
107
|
const hasDetail = call.resultDetail != null;
|
|
108
108
|
const [isDetailOpen, setIsDetailOpen] = useState(false);
|
|
109
|
+
const detailId = useId();
|
|
109
110
|
const toggleDetail = hasDetail ? () => setIsDetailOpen(prev => !prev) : undefined;
|
|
110
111
|
const row = /*#__PURE__*/_jsxs("div", {
|
|
111
112
|
role: hasDetail ? 'button' : undefined,
|
|
112
113
|
tabIndex: hasDetail ? 0 : undefined,
|
|
114
|
+
"aria-expanded": hasDetail ? isDetailOpen : undefined,
|
|
115
|
+
"aria-controls": hasDetail && isDetailOpen ? detailId : undefined,
|
|
113
116
|
onClick: toggleDetail,
|
|
114
117
|
onKeyDown: hasDetail ? e => {
|
|
115
118
|
if (e.key === 'Enter' || e.key === ' ') {
|
|
@@ -205,6 +208,7 @@ function CallRow({
|
|
|
205
208
|
}
|
|
206
209
|
return /*#__PURE__*/_jsxs("div", {
|
|
207
210
|
children: [row, isDetailOpen && /*#__PURE__*/_jsx("div", {
|
|
211
|
+
id: detailId,
|
|
208
212
|
...{
|
|
209
213
|
className: "x1f43n9v x1wesfrj"
|
|
210
214
|
},
|
|
@@ -253,6 +257,7 @@ export function ChatToolCalls(props) {
|
|
|
253
257
|
} = props;
|
|
254
258
|
const autoDefault = defaultIsExpanded ?? false;
|
|
255
259
|
const [internalExpanded, setInternalExpanded] = useState(autoDefault);
|
|
260
|
+
const contentId = useId();
|
|
256
261
|
const isControlled = controlledExpanded !== undefined;
|
|
257
262
|
const isExpanded = isControlled ? controlledExpanded : internalExpanded;
|
|
258
263
|
const toggle = useCallback(() => {
|
|
@@ -289,6 +294,7 @@ export function ChatToolCalls(props) {
|
|
|
289
294
|
role: "button",
|
|
290
295
|
tabIndex: 0,
|
|
291
296
|
"aria-expanded": isExpanded,
|
|
297
|
+
"aria-controls": contentId,
|
|
292
298
|
onClick: toggle,
|
|
293
299
|
onKeyDown: e => {
|
|
294
300
|
if (e.key === 'Enter' || e.key === ' ') {
|
|
@@ -378,6 +384,7 @@ export function ChatToolCalls(props) {
|
|
|
378
384
|
})
|
|
379
385
|
})]
|
|
380
386
|
}), /*#__PURE__*/_jsx("div", {
|
|
387
|
+
id: contentId,
|
|
381
388
|
...{
|
|
382
389
|
0: {
|
|
383
390
|
className: "xrvj5dj xihq33y xb0j27v"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import type { BaseProps } from '../BaseProps';
|
|
3
|
+
import { type SyntaxThemeDefinition } from '../theme/syntax';
|
|
3
4
|
export interface CodeBlockProps extends BaseProps<HTMLPreElement> {
|
|
4
5
|
ref?: React.Ref<HTMLPreElement>;
|
|
5
6
|
code: string;
|
|
@@ -39,6 +40,14 @@ export interface CodeBlockProps extends BaseProps<HTMLPreElement> {
|
|
|
39
40
|
end: number;
|
|
40
41
|
}[];
|
|
41
42
|
highlightMode?: 'auto' | 'ranges' | 'spans';
|
|
43
|
+
/**
|
|
44
|
+
* Per-instance syntax theme override. Shorthand for wrapping this block in
|
|
45
|
+
* `<SyntaxTheme theme={...}>` — accepts a preset from
|
|
46
|
+
* `@astryxdesign/core/theme/syntax` or a theme created with
|
|
47
|
+
* `defineSyntaxTheme()`. Without it, the block uses the theme-level syntax
|
|
48
|
+
* colors from the nearest SyntaxTheme ancestor or `defineTheme({ syntax })`.
|
|
49
|
+
*/
|
|
50
|
+
syntaxTheme?: SyntaxThemeDefinition;
|
|
42
51
|
}
|
|
43
52
|
/**
|
|
44
53
|
* Read-only code display with syntax highlighting, line numbers,
|
|
@@ -49,7 +58,7 @@ export interface CodeBlockProps extends BaseProps<HTMLPreElement> {
|
|
|
49
58
|
* <CodeBlock code="const x = 42;" language="javascript" />
|
|
50
59
|
* ```
|
|
51
60
|
*/
|
|
52
|
-
export declare function CodeBlock({ code, language, title, hasLanguageLabel, hasLineNumbers, highlightLines, hasCopyButton, onCopy, isWrapped, maxHeight, isCollapsible, collapsibleThreshold, size, width: widthProp, container, tokenizer: customTokenizer, highlightMode, xstyle, className, style, ref, ...props }: CodeBlockProps): React.JSX.Element;
|
|
61
|
+
export declare function CodeBlock({ code, language, title, hasLanguageLabel, hasLineNumbers, highlightLines, hasCopyButton, onCopy, isWrapped, maxHeight, isCollapsible, collapsibleThreshold, size, width: widthProp, container, tokenizer: customTokenizer, highlightMode, syntaxTheme, xstyle, className, style, ref, ...props }: CodeBlockProps): React.JSX.Element;
|
|
53
62
|
export declare namespace CodeBlock {
|
|
54
63
|
var displayName: string;
|
|
55
64
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CodeBlock.d.ts","sourceRoot":"","sources":["../../src/CodeBlock/CodeBlock.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CodeBlock.d.ts","sourceRoot":"","sources":["../../src/CodeBlock/CodeBlock.tsx"],"names":[],"mappings":"AAoBA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AA0B5C,OAAO,EAAc,KAAK,qBAAqB,EAAC,MAAM,iBAAiB,CAAC;AAyTxE,MAAM,WAAW,cAAe,SAAQ,SAAS,CAAC,cAAc,CAAC;IAC/D,GAAG,CAA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B,EAClB,SAAS,EAAE,eAAe,EAC1B,aAAsB,EACtB,WAAW,EACX,MAAM,EACN,SAAS,EACT,KAAK,EACL,GAAG,EACH,GAAG,KAAK,EACT,EAAE,cAAc,qBAmNhB;yBA3Oe,SAAS"}
|
|
@@ -4,21 +4,23 @@
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @file CodeBlock.tsx
|
|
7
|
-
* @input Uses React, StyleX, theme tokens, CSS Custom Highlight API
|
|
7
|
+
* @input Uses React, StyleX, theme tokens, CSS Custom Highlight API, SyntaxTheme provider
|
|
8
8
|
* @output Exports CodeBlock component and CodeBlockProps
|
|
9
9
|
* @position Core implementation; read-only syntax-highlighted code display
|
|
10
10
|
*/
|
|
11
|
-
import { useInsertionEffect, useEffect, useRef, useState, useCallback, useMemo } from 'react';
|
|
11
|
+
import { useInsertionEffect, useEffect, useId, useRef, useState, useCallback, useMemo } from 'react';
|
|
12
12
|
import * as React from 'react';
|
|
13
13
|
import * as stylex from '@stylexjs/stylex';
|
|
14
14
|
import "../theme/tokens.stylex.js";
|
|
15
15
|
import { colorVars, spacingVars, radiusVars, typographyVars, fontWeightVars, typeScaleVars, borderVars, durationVars, easeVars } from "../theme/tokens.stylex.js";
|
|
16
16
|
import { mergeProps } from "../utils/index.js";
|
|
17
|
+
import { useAnnounce } from "../hooks/useAnnounce.js";
|
|
17
18
|
import { Icon } from "../Icon/index.js";
|
|
18
19
|
import { tokenize, tokenizeAsync, flatTokensToLines, SYNC_TOKENIZE_THRESHOLD } from "./tokenizer.js";
|
|
19
20
|
import { ensureHighlightStyles } from "./highlightStyles.js";
|
|
20
21
|
import { applyHighlightRangesChunked } from "./highlightRanges.js";
|
|
21
22
|
import { themeProps } from "../utils/themeProps.js";
|
|
23
|
+
import { SyntaxTheme } from "../theme/syntax/index.js";
|
|
22
24
|
|
|
23
25
|
// ---------------------------------------------------------------------------
|
|
24
26
|
// Styles
|
|
@@ -369,6 +371,7 @@ export function CodeBlock({
|
|
|
369
371
|
container = 'card',
|
|
370
372
|
tokenizer: customTokenizer,
|
|
371
373
|
highlightMode = 'auto',
|
|
374
|
+
syntaxTheme,
|
|
372
375
|
xstyle,
|
|
373
376
|
className,
|
|
374
377
|
style,
|
|
@@ -376,6 +379,7 @@ export function CodeBlock({
|
|
|
376
379
|
...props
|
|
377
380
|
}) {
|
|
378
381
|
const [copied, setCopied] = useState(false);
|
|
382
|
+
const announce = useAnnounce();
|
|
379
383
|
const useSpans = highlightMode === 'spans' || highlightMode === 'auto' && !hasHighlightAPI() || highlightMode === 'auto' && isSafari();
|
|
380
384
|
const lines = useMemo(() => {
|
|
381
385
|
const l = code.split('\n');
|
|
@@ -390,18 +394,26 @@ export function CodeBlock({
|
|
|
390
394
|
try {
|
|
391
395
|
await navigator.clipboard.writeText(code);
|
|
392
396
|
setCopied(true);
|
|
397
|
+
// Swapping the button's aria-label alone isn't reliably announced by
|
|
398
|
+
// screen readers, so confirm the copy via a polite live region.
|
|
399
|
+
announce('Copied');
|
|
393
400
|
onCopy?.();
|
|
394
401
|
setTimeout(() => setCopied(false), 2000);
|
|
395
402
|
} catch {
|
|
396
403
|
// Clipboard failures leave the copied state unchanged.
|
|
397
404
|
}
|
|
398
|
-
}, [code, onCopy]);
|
|
405
|
+
}, [code, onCopy, announce]);
|
|
399
406
|
const sizeStyle = size === 'sm' ? styles.sizeSm : styles.sizeMd;
|
|
400
407
|
const gutterSizeStyle = size === 'sm' ? styles.gutterSm : styles.gutterMd;
|
|
401
408
|
const languageLabel = hasLanguageLabel && language !== 'plaintext' ? language : null;
|
|
402
409
|
const showHeader = title != null || languageLabel != null;
|
|
403
410
|
const canCollapse = isCollapsible && lines.length >= collapsibleThreshold;
|
|
404
411
|
const [isCollapsed, setIsCollapsed] = useState(false);
|
|
412
|
+
// Links the collapsible header to the code region it shows/hides so assistive
|
|
413
|
+
// tech can move from the button to its controlled content (disclosure
|
|
414
|
+
// pattern). The region stays mounted when collapsed (CSS grid animation), so
|
|
415
|
+
// this is always a resolvable reference — aria-controls can be unconditional.
|
|
416
|
+
const regionId = useId();
|
|
405
417
|
const scrollContainerRef = useRef(null);
|
|
406
418
|
const scrollStyle = maxHeight ? {
|
|
407
419
|
maxHeight: typeof maxHeight === 'number' ? `${maxHeight}px` : maxHeight
|
|
@@ -442,6 +454,7 @@ export function CodeBlock({
|
|
|
442
454
|
role: canCollapse ? 'button' : undefined,
|
|
443
455
|
tabIndex: canCollapse ? 0 : undefined,
|
|
444
456
|
"aria-expanded": canCollapse ? !isCollapsed : undefined,
|
|
457
|
+
"aria-controls": canCollapse ? regionId : undefined,
|
|
445
458
|
onClick: canCollapse ? () => setIsCollapsed(prev => !prev) : undefined,
|
|
446
459
|
onKeyDown: canCollapse ? e => {
|
|
447
460
|
if (e.key === 'Enter' || e.key === ' ') {
|
|
@@ -454,7 +467,7 @@ export function CodeBlock({
|
|
|
454
467
|
className: "x78zum5 x6s0dn4 x98rzlu xeuugli x1717udv xjbqb8w x1heor9g xln7xf2 x1yc453h"
|
|
455
468
|
},
|
|
456
469
|
1: {
|
|
457
|
-
className: "x78zum5 x6s0dn4 x98rzlu xeuugli x1717udv xjbqb8w x1heor9g xln7xf2 x1yc453h x1ypdohk x87ps6o"
|
|
470
|
+
className: "x78zum5 x6s0dn4 x98rzlu xeuugli x1717udv xjbqb8w x1heor9g xln7xf2 x1yc453h x1ypdohk x87ps6o x17nn4n9 x1wfwxd8 x7s97pk"
|
|
458
471
|
}
|
|
459
472
|
}[!!canCollapse << 0],
|
|
460
473
|
children: /*#__PURE__*/_jsxs("span", {
|
|
@@ -530,7 +543,7 @@ export function CodeBlock({
|
|
|
530
543
|
})]
|
|
531
544
|
})
|
|
532
545
|
});
|
|
533
|
-
|
|
546
|
+
const block = /*#__PURE__*/_jsxs("pre", {
|
|
534
547
|
ref: ref,
|
|
535
548
|
...mergeProps(themeProps('codeblock', {
|
|
536
549
|
size,
|
|
@@ -539,6 +552,7 @@ export function CodeBlock({
|
|
|
539
552
|
}), stylex.props(styles.root, dynamicStyles.width(widthProp), containerStyles[container], xstyle), className, style),
|
|
540
553
|
...props,
|
|
541
554
|
children: [headerEl, canCollapse ? /*#__PURE__*/_jsx("div", {
|
|
555
|
+
id: regionId,
|
|
542
556
|
...{
|
|
543
557
|
0: {
|
|
544
558
|
className: "xrvj5dj x1tu4anv x1qn9uv2 x80gvsz xlr8y92"
|
|
@@ -555,5 +569,9 @@ export function CodeBlock({
|
|
|
555
569
|
})
|
|
556
570
|
}) : codeBody, !showHeader && copyButtonEl]
|
|
557
571
|
});
|
|
572
|
+
return syntaxTheme ? /*#__PURE__*/_jsx(SyntaxTheme, {
|
|
573
|
+
theme: syntaxTheme,
|
|
574
|
+
children: block
|
|
575
|
+
}) : block;
|
|
558
576
|
}
|
|
559
577
|
CodeBlock.displayName = 'CodeBlock';
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file Collapsible.tsx
|
|
3
|
-
* @input Uses React, StyleX, useCollapsible hook, getIcon, theme tokens
|
|
3
|
+
* @input Uses React, StyleX, useCollapsible hook, CollapsibleGroupPresentationContext, getIcon, theme tokens
|
|
4
4
|
* @output Exports Collapsible component and CollapsibleProps
|
|
5
5
|
* @position Collapsible content primitive — trigger toggles visibility of children
|
|
6
6
|
*
|
|
7
7
|
* Collapsible is a standalone primitive that makes any content collapsible.
|
|
8
8
|
* It renders a trigger area (always visible) and a content area that toggles.
|
|
9
|
-
* Handles state management, accessibility (aria-expanded
|
|
9
|
+
* Handles state management, accessibility (aria-expanded + aria-controls linking
|
|
10
|
+
* the trigger to its content region), and chevron indicator.
|
|
10
11
|
*
|
|
11
12
|
* Works standalone or coordinated by CollapsibleGroup via the `value` prop.
|
|
13
|
+
* When the surrounding CollapsibleGroup enables `dividers`, each Collapsible
|
|
14
|
+
* draws its own row chrome (borderBlockStart suppressed on :first-child, plus
|
|
15
|
+
* density padding) from CollapsibleGroupPresentationContext — StyleX has no
|
|
16
|
+
* child selectors, so the group cannot draw it from outside. The presentation
|
|
17
|
+
* context is reset around children so nested collapsibles stay chrome-free.
|
|
12
18
|
*
|
|
13
19
|
* SYNC: When modified, update these files to stay in sync:
|
|
14
20
|
* - /packages/core/src/Collapsible/index.ts (exports)
|
|
@@ -16,7 +22,7 @@
|
|
|
16
22
|
* - /apps/storybook/stories/Collapsible.stories.tsx
|
|
17
23
|
* - /packages/cli/templates/blocks/components/Collapsible/ (showcase blocks)
|
|
18
24
|
*/
|
|
19
|
-
import type
|
|
25
|
+
import { type ReactNode } from 'react';
|
|
20
26
|
import type { BaseProps } from '../BaseProps';
|
|
21
27
|
export interface CollapsibleProps extends BaseProps {
|
|
22
28
|
/** Ref forwarded to the root element */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Collapsible.d.ts","sourceRoot":"","sources":["../../src/Collapsible/Collapsible.tsx"],"names":[],"mappings":"AAIA
|
|
1
|
+
{"version":3,"file":"Collapsible.d.ts","sourceRoot":"","sources":["../../src/Collapsible/Collapsible.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAa,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AAgBjD,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAkG5C,MAAM,WAAW,gBAAiB,SAAQ,SAAS;IACjD,wCAAwC;IACxC,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAChC;;;OAGG;IACH,OAAO,EAAE,SAAS,CAAC;IAEnB;;OAEG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IAErB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IAExB;;OAEG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;OAEG;IACH,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IAEzC;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,wBAAgB,WAAW,CAAC,EAC1B,OAAO,EACP,QAAQ,EACR,aAAa,EACb,MAAM,EAAE,gBAAgB,EACxB,YAAY,EACZ,KAAK,EACL,GAAG,EACH,MAAM,EACN,SAAS,EACT,KAAK,EACL,GAAG,KAAK,EACT,EAAE,gBAAgB,+BAsElB;yBAlFe,WAAW"}
|
|
@@ -4,15 +4,21 @@
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @file Collapsible.tsx
|
|
7
|
-
* @input Uses React, StyleX, useCollapsible hook, getIcon, theme tokens
|
|
7
|
+
* @input Uses React, StyleX, useCollapsible hook, CollapsibleGroupPresentationContext, getIcon, theme tokens
|
|
8
8
|
* @output Exports Collapsible component and CollapsibleProps
|
|
9
9
|
* @position Collapsible content primitive — trigger toggles visibility of children
|
|
10
10
|
*
|
|
11
11
|
* Collapsible is a standalone primitive that makes any content collapsible.
|
|
12
12
|
* It renders a trigger area (always visible) and a content area that toggles.
|
|
13
|
-
* Handles state management, accessibility (aria-expanded
|
|
13
|
+
* Handles state management, accessibility (aria-expanded + aria-controls linking
|
|
14
|
+
* the trigger to its content region), and chevron indicator.
|
|
14
15
|
*
|
|
15
16
|
* Works standalone or coordinated by CollapsibleGroup via the `value` prop.
|
|
17
|
+
* When the surrounding CollapsibleGroup enables `dividers`, each Collapsible
|
|
18
|
+
* draws its own row chrome (borderBlockStart suppressed on :first-child, plus
|
|
19
|
+
* density padding) from CollapsibleGroupPresentationContext — StyleX has no
|
|
20
|
+
* child selectors, so the group cannot draw it from outside. The presentation
|
|
21
|
+
* context is reset around children so nested collapsibles stay chrome-free.
|
|
16
22
|
*
|
|
17
23
|
* SYNC: When modified, update these files to stay in sync:
|
|
18
24
|
* - /packages/core/src/Collapsible/index.ts (exports)
|
|
@@ -20,10 +26,12 @@
|
|
|
20
26
|
* - /apps/storybook/stories/Collapsible.stories.tsx
|
|
21
27
|
* - /packages/cli/templates/blocks/components/Collapsible/ (showcase blocks)
|
|
22
28
|
*/
|
|
29
|
+
import { use, useId } from 'react';
|
|
23
30
|
import * as stylex from '@stylexjs/stylex';
|
|
24
31
|
import "../theme/tokens.stylex.js";
|
|
25
|
-
import { colorVars, typographyVars, fontWeightVars, spacingVars, typeScaleVars, durationVars, easeVars } from "../theme/tokens.stylex.js";
|
|
32
|
+
import { borderVars, colorVars, typographyVars, fontWeightVars, spacingVars, typeScaleVars, durationVars, easeVars } from "../theme/tokens.stylex.js";
|
|
26
33
|
import { useCollapsible } from "./useCollapsible.js";
|
|
34
|
+
import { CollapsibleGroupPresentationContext } from "./CollapsibleGroupContext.js";
|
|
27
35
|
import { getIcon } from "../Icon/globalIconRegistry.js";
|
|
28
36
|
import { mergeProps } from "../utils/index.js";
|
|
29
37
|
import { themeProps } from "../utils/themeProps.js";
|
|
@@ -32,8 +40,79 @@ const styles = {
|
|
|
32
40
|
root: {
|
|
33
41
|
kzqmXN: "xh8yej3",
|
|
34
42
|
$$css: true
|
|
43
|
+
},
|
|
44
|
+
trigger: {
|
|
45
|
+
kB7OPa: "x9f619",
|
|
46
|
+
k1xSpc: "x78zum5",
|
|
47
|
+
kGNEyG: "x6s0dn4",
|
|
48
|
+
kjj79g: "x1qughib",
|
|
49
|
+
kzqmXN: "xh8yej3",
|
|
50
|
+
kkrTdU: "x1ypdohk",
|
|
51
|
+
kMv6JI: "x9ynric",
|
|
52
|
+
kGuDYH: "x18juvz8",
|
|
53
|
+
k63SB2: "x2mo6ok",
|
|
54
|
+
kMwMTN: "x1tgivj0",
|
|
55
|
+
k9WMMc: "x1yc453h",
|
|
56
|
+
k8WAf4: "xt970qd",
|
|
57
|
+
kI3sdo: "x17nn4n9",
|
|
58
|
+
kInvED: "x1wfwxd8 x7s97pk",
|
|
59
|
+
$$css: true
|
|
60
|
+
},
|
|
61
|
+
contentHidden: {
|
|
62
|
+
k1xSpc: "x1s85apg",
|
|
63
|
+
$$css: true
|
|
64
|
+
},
|
|
65
|
+
content: {
|
|
66
|
+
kLKAdn: "xfsso4q",
|
|
67
|
+
$$css: true
|
|
68
|
+
},
|
|
69
|
+
divided: {
|
|
70
|
+
kEafiO: "x11xkdxz x1g31smg",
|
|
71
|
+
kPef9Z: "x13fuv20",
|
|
72
|
+
kLZC3w: "x1pc3f07",
|
|
73
|
+
$$css: true
|
|
35
74
|
}
|
|
36
75
|
};
|
|
76
|
+
|
|
77
|
+
// Density padding for divided/padded accordion rows. paddingBlock mapping
|
|
78
|
+
// follows Table's density scale (spacing-1/2/3); content only pads its end
|
|
79
|
+
// so text doesn't sit on the divider below (block-start stays spacing-1).
|
|
80
|
+
const densityStyles = {
|
|
81
|
+
triggerCompact: {
|
|
82
|
+
k8WAf4: "xu0wf1k",
|
|
83
|
+
$$css: true
|
|
84
|
+
},
|
|
85
|
+
triggerBalanced: {
|
|
86
|
+
k8WAf4: "xce4md1",
|
|
87
|
+
$$css: true
|
|
88
|
+
},
|
|
89
|
+
triggerSpacious: {
|
|
90
|
+
k8WAf4: "x8o8v82",
|
|
91
|
+
$$css: true
|
|
92
|
+
},
|
|
93
|
+
contentCompact: {
|
|
94
|
+
kGO01o: "xy143xn",
|
|
95
|
+
$$css: true
|
|
96
|
+
},
|
|
97
|
+
contentBalanced: {
|
|
98
|
+
kGO01o: "x1wesfrj",
|
|
99
|
+
$$css: true
|
|
100
|
+
},
|
|
101
|
+
contentSpacious: {
|
|
102
|
+
kGO01o: "xvmdzux",
|
|
103
|
+
$$css: true
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
const triggerDensity = {
|
|
107
|
+
compact: densityStyles.triggerCompact,
|
|
108
|
+
balanced: densityStyles.triggerBalanced,
|
|
109
|
+
spacious: densityStyles.triggerSpacious
|
|
110
|
+
};
|
|
111
|
+
const contentDensity = {
|
|
112
|
+
compact: densityStyles.contentCompact,
|
|
113
|
+
balanced: densityStyles.contentBalanced,
|
|
114
|
+
spacious: densityStyles.contentSpacious
|
|
115
|
+
};
|
|
37
116
|
/**
|
|
38
117
|
* A primitive that makes any content collapsible.
|
|
39
118
|
*
|
|
@@ -99,18 +178,27 @@ export function Collapsible({
|
|
|
99
178
|
isCollapsible: collapsibleConfig,
|
|
100
179
|
value
|
|
101
180
|
});
|
|
181
|
+
const presentation = use(CollapsibleGroupPresentationContext);
|
|
182
|
+
const isDivided = presentation != null && presentation.dividers !== 'none';
|
|
183
|
+
const density = presentation?.density ?? null;
|
|
102
184
|
const chevronIcon = getIcon('chevronDown');
|
|
185
|
+
|
|
186
|
+
// Links the trigger to the region it shows/hides so assistive tech can move
|
|
187
|
+
// from the button to its controlled content (disclosure pattern).
|
|
188
|
+
const contentId = useId();
|
|
103
189
|
return /*#__PURE__*/_jsxs("div", {
|
|
104
190
|
ref: ref,
|
|
105
|
-
...mergeProps(themeProps('collapsible'
|
|
191
|
+
...mergeProps(themeProps('collapsible', {
|
|
192
|
+
dividers: isDivided ? presentation.dividers : undefined,
|
|
193
|
+
density: density ?? undefined
|
|
194
|
+
}), stylex.props(styles.root, isDivided && styles.divided, xstyle), className, style),
|
|
106
195
|
...props,
|
|
107
196
|
children: [/*#__PURE__*/_jsxs("button", {
|
|
108
197
|
type: "button",
|
|
109
198
|
onClick: toggle,
|
|
110
199
|
"aria-expanded": isOpen,
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
},
|
|
200
|
+
"aria-controls": contentId,
|
|
201
|
+
...stylex.props(styles.trigger, density != null && triggerDensity[density]),
|
|
114
202
|
children: [/*#__PURE__*/_jsx("span", {
|
|
115
203
|
...{
|
|
116
204
|
className: "x1b2iylo xwgcxoh"
|
|
@@ -128,12 +216,12 @@ export function Collapsible({
|
|
|
128
216
|
children: chevronIcon
|
|
129
217
|
})]
|
|
130
218
|
}), /*#__PURE__*/_jsx("div", {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
219
|
+
id: contentId,
|
|
220
|
+
...stylex.props(styles.content, density != null && contentDensity[density], !isOpen && styles.contentHidden),
|
|
221
|
+
children: presentation != null ? /*#__PURE__*/_jsx(CollapsibleGroupPresentationContext, {
|
|
222
|
+
value: null,
|
|
223
|
+
children: children
|
|
224
|
+
}) : children
|
|
137
225
|
})]
|
|
138
226
|
});
|
|
139
227
|
}
|