@astryxdesign/core 0.7.15 → 0.7.16-canary.g54dd64e
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/AppShell/AppShell.d.ts.map +1 -1
- package/dist/AppShell/AppShell.js +8 -2
- package/dist/BottomSheet/BottomSheet.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheet.js +11 -6
- package/dist/DateInput/DateInput.d.ts +3 -3
- package/dist/DateInput/DateInput.d.ts.map +1 -1
- package/dist/DateInput/DateInput.js +13 -2
- package/dist/DateInput/NativeDateField.d.ts +1 -1
- package/dist/DateInput/NativeDateField.d.ts.map +1 -1
- package/dist/DateInput/NativeDateField.js +48 -31
- package/dist/DateInput/useTypedDate.d.ts +66 -6
- package/dist/DateInput/useTypedDate.d.ts.map +1 -1
- package/dist/DateInput/useTypedDate.js +151 -21
- package/dist/DateTimeInput/DateTimeInput.d.ts +3 -3
- package/dist/DateTimeInput/DateTimeInput.d.ts.map +1 -1
- package/dist/DateTimeInput/DateTimeInput.js +26 -3
- package/dist/DateTimeInput/NativeDateSegment.d.ts +8 -1
- package/dist/DateTimeInput/NativeDateSegment.d.ts.map +1 -1
- package/dist/DateTimeInput/NativeDateSegment.js +20 -14
- package/dist/DropdownMenu/DropdownMenu.d.ts.map +1 -1
- package/dist/DropdownMenu/DropdownMenu.js +10 -3
- package/dist/Field/InputClearButton.d.ts.map +1 -1
- package/dist/Field/InputClearButton.js +4 -2
- package/dist/InfoTip/InfoTip.d.ts +1 -1
- package/dist/InfoTip/InfoTip.d.ts.map +1 -1
- package/dist/InfoTip/InfoTip.js +4 -1
- package/dist/Layer/layerAnimations.stylex.d.ts.map +1 -1
- package/dist/Layer/layerAnimations.stylex.js +17 -13
- package/dist/Layer/layerEntranceSide.d.ts +24 -10
- package/dist/Layer/layerEntranceSide.d.ts.map +1 -1
- package/dist/Layer/layerEntranceSide.js +28 -13
- package/dist/Layer/useLayer.d.ts.map +1 -1
- package/dist/Layer/useLayer.js +14 -11
- package/dist/Lightbox/Lightbox.d.ts.map +1 -1
- package/dist/Lightbox/Lightbox.js +625 -180
- package/dist/List/ListItem.d.ts +3 -2
- package/dist/List/ListItem.d.ts.map +1 -1
- package/dist/List/ListReorderHandle.d.ts +7 -0
- package/dist/List/ListReorderHandle.d.ts.map +1 -1
- package/dist/List/ListReorderHandle.js +42 -58
- package/dist/List/listReorderContext.d.ts.map +1 -1
- package/dist/List/listReorderContext.js +4 -4
- package/dist/List/listReorderEngine.d.ts +50 -2
- package/dist/List/listReorderEngine.d.ts.map +1 -1
- package/dist/List/listReorderEngine.js +205 -10
- package/dist/MoreMenu/MoreMenu.d.ts +1 -1
- package/dist/MoreMenu/MoreMenu.d.ts.map +1 -1
- package/dist/MoreMenu/MoreMenu.js +4 -1
- package/dist/PowerSearch/PowerSearch.d.ts +1 -1
- package/dist/PowerSearch/PowerSearch.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearch.js +8 -4
- package/dist/PowerSearch/PowerSearchEditPopover.d.ts +4 -1
- package/dist/PowerSearch/PowerSearchEditPopover.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearchEditPopover.js +4 -1
- package/dist/PowerSearch/PowerSearchFilterEditor.d.ts +1 -1
- package/dist/PowerSearch/PowerSearchFilterEditor.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearchFilterEditor.js +7 -3
- package/dist/PowerSearch/PowerSearchToken.d.ts +1 -1
- package/dist/PowerSearch/PowerSearchToken.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearchToken.js +4 -1
- package/dist/Selector/useSelectorPresentation.d.ts.map +1 -1
- package/dist/Selector/useSelectorPresentation.js +13 -12
- package/dist/Slider/Slider.d.ts.map +1 -1
- package/dist/Slider/Slider.js +6 -8
- package/dist/Table/BaseTable.d.ts +1 -1
- package/dist/Table/BaseTable.d.ts.map +1 -1
- package/dist/Table/BaseTable.js +265 -197
- package/dist/Table/Table.d.ts +5 -1
- package/dist/Table/Table.d.ts.map +1 -1
- package/dist/Table/index.d.ts +5 -3
- package/dist/Table/index.d.ts.map +1 -1
- package/dist/Table/index.js +2 -1
- package/dist/Table/plugins/infiniteScroll/TableInfiniteScrollWide.a11y.chromium.spec.d.ts.map +1 -0
- package/dist/Table/plugins/infiniteScroll/index.d.ts +9 -0
- package/dist/Table/plugins/infiniteScroll/index.d.ts.map +1 -0
- package/dist/Table/plugins/infiniteScroll/index.js +9 -0
- package/dist/Table/plugins/infiniteScroll/useTableInfiniteScroll.d.ts +29 -0
- package/dist/Table/plugins/infiniteScroll/useTableInfiniteScroll.d.ts.map +1 -0
- package/dist/Table/plugins/infiniteScroll/useTableInfiniteScroll.js +394 -0
- package/dist/Table/plugins/sortable/useTableSortableState.d.ts.map +1 -1
- package/dist/Table/plugins/sortable/useTableSortableState.js +4 -4
- package/dist/Table/plugins/stickyColumns/useTableStickyColumns.d.ts.map +1 -1
- package/dist/Table/plugins/stickyColumns/useTableStickyColumns.js +21 -1
- package/dist/Table/plugins/virtualization/TableColumnWindow.d.ts +4 -0
- package/dist/Table/plugins/virtualization/TableColumnWindow.d.ts.map +1 -0
- package/dist/Table/plugins/virtualization/TableColumnWindow.js +109 -0
- package/dist/Table/plugins/virtualization/index.d.ts +3 -1
- package/dist/Table/plugins/virtualization/index.d.ts.map +1 -1
- package/dist/Table/plugins/virtualization/index.js +3 -2
- package/dist/Table/plugins/virtualization/useTableColumnWindow.d.ts +33 -0
- package/dist/Table/plugins/virtualization/useTableColumnWindow.d.ts.map +1 -0
- package/dist/Table/plugins/virtualization/useTableColumnWindow.js +143 -0
- package/dist/Table/plugins/virtualization/useTableColumnsVirtualization.d.ts +23 -0
- package/dist/Table/plugins/virtualization/useTableColumnsVirtualization.d.ts.map +1 -0
- package/dist/Table/plugins/virtualization/useTableColumnsVirtualization.js +37 -0
- package/dist/Table/tableColumnWindowing.d.ts +85 -0
- package/dist/Table/tableColumnWindowing.d.ts.map +1 -0
- package/dist/Table/tableColumnWindowing.js +47 -0
- package/dist/Table/tablePinnedColumnRuns.d.ts +23 -0
- package/dist/Table/tablePinnedColumnRuns.d.ts.map +1 -0
- package/dist/Table/tablePinnedColumnRuns.js +41 -0
- package/dist/Table/tableRuntime.d.ts +14 -2
- package/dist/Table/tableRuntime.d.ts.map +1 -1
- package/dist/Table/tableRuntime.js +32 -11
- package/dist/Table/types.d.ts +28 -2
- package/dist/Table/types.d.ts.map +1 -1
- package/dist/Table/useBaseTablePlugins.js +2 -2
- package/dist/Text/useTruncation.d.ts +6 -1
- package/dist/Text/useTruncation.d.ts.map +1 -1
- package/dist/Text/useTruncation.js +53 -35
- package/dist/TextArea/TextArea.d.ts +10 -1
- package/dist/TextArea/TextArea.d.ts.map +1 -1
- package/dist/TextArea/TextArea.js +2 -0
- package/dist/Toast/Toast.d.ts +1 -1
- package/dist/Toast/Toast.d.ts.map +1 -1
- package/dist/Toast/Toast.js +4 -2
- package/dist/astryx.css +22 -11
- package/dist/dragToSnapPoints/createDragToSnapPoints.d.ts +156 -0
- package/dist/dragToSnapPoints/createDragToSnapPoints.d.ts.map +1 -1
- package/dist/dragToSnapPoints/createDragToSnapPoints.js +313 -97
- package/dist/gestures/createPanGesture.d.ts +41 -0
- package/dist/gestures/createPanGesture.d.ts.map +1 -1
- package/dist/gestures/createPanGesture.js +66 -22
- package/dist/hooks/useMenuPress.d.ts.map +1 -1
- package/dist/hooks/useMenuPress.js +36 -2
- package/dist/i18n/generated-english/DateInput/NativeDateField.generated.d.ts.map +1 -1
- package/dist/i18n/generated-english/DateInput/NativeDateField.generated.js +0 -1
- package/dist/i18n/generated-english/DateTimeInput/NativeDateSegment.generated.d.ts.map +1 -1
- package/dist/i18n/generated-english/DateTimeInput/NativeDateSegment.generated.js +0 -1
- package/dist/i18n/generated-english/Lightbox/Lightbox.generated.d.ts.map +1 -1
- package/dist/i18n/generated-english/Lightbox/Lightbox.generated.js +2 -0
- package/dist/i18n/generated-english/Table/plugins/infiniteScroll/useTableInfiniteScroll.generated.d.ts +8 -0
- package/dist/i18n/generated-english/Table/plugins/infiniteScroll/useTableInfiniteScroll.generated.d.ts.map +1 -0
- package/dist/i18n/generated-english/Table/plugins/infiniteScroll/useTableInfiniteScroll.generated.js +12 -0
- package/dist/i18n/generated-locales/en.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/en.generated.js +32 -0
- package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/pseudo.generated.js +32 -0
- package/dist/internal/touch.d.ts +1 -1
- package/dist/internal/touch.d.ts.map +1 -1
- package/dist/internal/touch.js +1 -1
- package/dist/motion/animator.d.ts +28 -1
- package/dist/motion/animator.d.ts.map +1 -1
- package/dist/motion/animator.js +99 -19
- package/dist/theme/generateThemeRules.d.ts.map +1 -1
- package/dist/theme/generateThemeRules.js +14 -3
- package/dist/theme/tokenReferences.d.ts +7 -15
- package/dist/theme/tokenReferences.d.ts.map +1 -1
- package/dist/theme/tokenReferences.js +49 -7
- package/dist/utils/clickGuard.d.ts +8 -1
- package/dist/utils/clickGuard.d.ts.map +1 -1
- package/dist/utils/clickGuard.js +24 -4
- package/dist/utils/sharedResizeObserver.d.ts +18 -2
- package/dist/utils/sharedResizeObserver.d.ts.map +1 -1
- package/dist/utils/sharedResizeObserver.js +43 -2
- package/dist/utils/themeProps.d.ts +8 -0
- package/dist/utils/themeProps.d.ts.map +1 -1
- package/dist/utils/themeProps.js +17 -0
- package/dist/utils/timeParser.d.ts +3 -1
- package/dist/utils/timeParser.d.ts.map +1 -1
- package/dist/utils/timeParser.js +7 -3
- package/dist/virtualization/listWindow.d.ts +18 -2
- package/dist/virtualization/listWindow.d.ts.map +1 -1
- package/dist/virtualization/listWindow.js +55 -2
- package/dist/virtualization/useInlineListWindow.d.ts +40 -0
- package/dist/virtualization/useInlineListWindow.d.ts.map +1 -0
- package/dist/virtualization/useInlineListWindow.js +58 -0
- package/locales/en.json +129 -1
- package/locales/pseudo.json +96 -0
- package/package.json +5 -5
- package/src/AppShell/AppShell.tsx +12 -3
- package/src/BottomSheet/BottomSheet.tsx +12 -8
- package/src/ButtonGroup/ButtonGroup.doc.mjs +5 -0
- package/src/CheckboxInput/CheckboxInput.doc.mjs +3 -0
- package/src/DateInput/DateInput.doc.mjs +3 -3
- package/src/DateInput/DateInput.tsx +27 -5
- package/src/DateInput/NativeDateField.tsx +58 -36
- package/src/DateInput/useTypedDate.ts +226 -55
- package/src/DateTimeInput/DateTimeInput.doc.mjs +3 -3
- package/src/DateTimeInput/DateTimeInput.tsx +38 -5
- package/src/DateTimeInput/NativeDateSegment.tsx +35 -13
- package/src/DropdownMenu/DropdownMenu.tsx +10 -3
- package/src/Field/InputClearButton.tsx +3 -1
- package/src/InfoTip/InfoTip.doc.mjs +2 -2
- package/src/InfoTip/InfoTip.tsx +3 -0
- package/src/Layer/layerAnimations.stylex.ts +13 -9
- package/src/Layer/layerEntranceSide.ts +48 -11
- package/src/Layer/useLayer.tsx +14 -12
- package/src/Lightbox/Lightbox.doc.mjs +2 -1
- package/src/Lightbox/Lightbox.tsx +864 -257
- package/src/List/ListItem.tsx +3 -2
- package/src/List/ListReorderHandle.tsx +59 -77
- package/src/List/listReorderContext.ts +3 -4
- package/src/List/listReorderEngine.tsx +246 -11
- package/src/MoreMenu/MoreMenu.doc.mjs +2 -2
- package/src/MoreMenu/MoreMenu.tsx +3 -0
- package/src/NumberInput/NumberInput.doc.mjs +3 -0
- package/src/PowerSearch/PowerSearch.doc.mjs +2 -2
- package/src/PowerSearch/PowerSearch.tsx +7 -3
- package/src/PowerSearch/PowerSearchEditPopover.tsx +12 -2
- package/src/PowerSearch/PowerSearchFilterEditor.tsx +3 -0
- package/src/PowerSearch/PowerSearchToken.tsx +3 -0
- package/src/ProgressBar/ProgressBar.doc.mjs +3 -0
- package/src/SegmentedControl/SegmentedControl.doc.mjs +5 -0
- package/src/Selector/useSelectorPresentation.ts +16 -12
- package/src/Slider/Slider.tsx +6 -8
- package/src/StatusDot/StatusDot.doc.mjs +3 -0
- package/src/Switch/Switch.doc.mjs +3 -0
- package/src/TabList/TabList.doc.mjs +4 -0
- package/src/Table/BaseTable.tsx +406 -287
- package/src/Table/Table.doc.mjs +2 -2
- package/src/Table/Table.tsx +5 -1
- package/src/Table/index.ts +8 -1
- package/src/Table/plugins/infiniteScroll/index.ts +10 -0
- package/src/Table/plugins/infiniteScroll/useTableInfiniteScroll.tsx +523 -0
- package/src/Table/plugins/sortable/useTableSortableState.tsx +4 -4
- package/src/Table/plugins/stickyColumns/useTableStickyColumns.tsx +31 -1
- package/src/Table/plugins/virtualization/TableColumnWindow.tsx +150 -0
- package/src/Table/plugins/virtualization/index.ts +3 -1
- package/src/Table/plugins/virtualization/useTableColumnWindow.ts +168 -0
- package/src/Table/plugins/virtualization/useTableColumnsVirtualization.ts +53 -0
- package/src/Table/tableColumnWindowing.ts +131 -0
- package/src/Table/tablePinnedColumnRuns.ts +55 -0
- package/src/Table/tableRuntime.ts +44 -11
- package/src/Table/types.ts +25 -2
- package/src/Table/useBaseTablePlugins.ts +2 -2
- package/src/Table/useTableColumnsVirtualization.doc.mjs +29 -0
- package/src/Table/useTableInfiniteScroll.doc.mjs +58 -0
- package/src/Text/Heading.doc.mjs +3 -0
- package/src/Text/useTruncation.doc.mjs +10 -0
- package/src/Text/useTruncation.ts +53 -35
- package/src/TextArea/TextArea.doc.mjs +15 -0
- package/src/TextArea/TextArea.tsx +11 -0
- package/src/TextInput/TextInput.doc.mjs +3 -0
- package/src/Toast/Toast.doc.mjs +2 -2
- package/src/Toast/Toast.tsx +3 -1
- package/src/TopNav/TopNav.doc.mjs +4 -0
- package/src/dragToSnapPoints/createDragToSnapPoints.ts +437 -119
- package/src/gestures/createPanGesture.ts +112 -39
- package/src/hooks/useMenuPress.ts +39 -0
- package/src/i18n/generated-english/DateInput/NativeDateField.generated.ts +0 -1
- package/src/i18n/generated-english/DateTimeInput/NativeDateSegment.generated.ts +0 -1
- package/src/i18n/generated-english/Lightbox/Lightbox.generated.ts +2 -0
- package/src/i18n/generated-english/Table/plugins/infiniteScroll/useTableInfiniteScroll.generated.ts +13 -0
- package/src/i18n/generated-locales/en.generated.ts +34 -0
- package/src/i18n/generated-locales/pseudo.generated.ts +34 -0
- package/src/internal/touch.ts +5 -1
- package/src/motion/animator.ts +181 -23
- package/src/theme/generateThemeRules.ts +14 -3
- package/src/theme/tokenReferences.ts +48 -7
- package/src/utils/clickGuard.ts +30 -3
- package/src/utils/sharedResizeObserver.ts +46 -2
- package/src/utils/themeProps.ts +17 -0
- package/src/utils/timeParser.ts +7 -9
- package/src/virtualization/listWindow.ts +76 -2
- package/src/virtualization/useInlineListWindow.ts +119 -0
package/dist/List/ListItem.d.ts
CHANGED
|
@@ -61,12 +61,13 @@ export interface ListItemProps extends BaseProps<HTMLLIElement> {
|
|
|
61
61
|
*/
|
|
62
62
|
description?: ReactNode;
|
|
63
63
|
/**
|
|
64
|
-
* Content
|
|
64
|
+
* Content before the label, inside the row (icon, avatar, checkbox).
|
|
65
65
|
* Uses start/end naming for RTL support.
|
|
66
66
|
*/
|
|
67
67
|
startContent?: ReactNode;
|
|
68
68
|
/**
|
|
69
|
-
* Content
|
|
69
|
+
* Content after the label and description, inside the row (badge, action
|
|
70
|
+
* button, chevron).
|
|
70
71
|
*/
|
|
71
72
|
endContent?: ReactNode;
|
|
72
73
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListItem.d.ts","sourceRoot":"","sources":["../../src/List/ListItem.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAuB,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AAS3D,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAU5C,OAAO,KAAK,EAAC,SAAS,EAAE,gBAAgB,EAAE,iBAAiB,EAAC,MAAM,SAAS,CAAC;AAa5E,MAAM,WAAW,aAAc,SAAQ,SAAS,CAAC,aAAa,CAAC;IAC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EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAE1B;;;;OAIG;IACH,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAEhC;;;;OAIG;IACH,aAAa,CAAC,EAAE,iBAAiB,CAAC;CACnC;AA6PD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,QAAQ,CAAC,EACvB,KAAK,EACL,WAAW,EACX,YAAY,EACZ,UAAU,EACV,OAAO,EACP,cAAc,EACd,IAAI,EACJ,MAAM,EACN,GAAG,EACH,UAAkB,EAClB,UAAkB,EAClB,OAAO,EACP,KAAK,EACL,MAAM,EACN,SAAS,EACT,KAAK,EACL,GAAG,EACH,GAAG,SAAS,EACb,EAAE,aAAa,+BA8Mf;yBAjOe,QAAQ"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as stylex from '@stylexjs/stylex';
|
|
2
2
|
import type { ListReorderHandleProps, ListReorderRowNameProps } from './listReorderContext.js';
|
|
3
|
+
import type { ListReorderHandleName } from './listReorderEngine.js';
|
|
3
4
|
/**
|
|
4
5
|
* The style of a row that ends with a handle, which ListItem applies. Its
|
|
5
6
|
* ring on focus within stays off for the handle, which rings itself.
|
|
@@ -47,6 +48,12 @@ export declare function ListReorderHandle({ label, itemKey, isDisabled, rowLabel
|
|
|
47
48
|
export declare namespace ListReorderHandle {
|
|
48
49
|
var displayName: string;
|
|
49
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* A handle's name before the session reads it: its server snapshot, and the
|
|
53
|
+
* session's answer for a handle it has not read. One object keeps the
|
|
54
|
+
* snapshot through hydration and the first read.
|
|
55
|
+
*/
|
|
56
|
+
export declare const UNREAD_HANDLE_NAME: ListReorderHandleName;
|
|
50
57
|
/**
|
|
51
58
|
* Names a reorderable List's row that has no handle, for the announcements
|
|
52
59
|
* of the moves beside it. That is a row that stays, or one without an item
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListReorderHandle.d.ts","sourceRoot":"","sources":["../../src/List/ListReorderHandle.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ListReorderHandle.d.ts","sourceRoot":"","sources":["../../src/List/ListReorderHandle.tsx"],"names":[],"mappings":"AA2CA,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAoB3C,OAAO,KAAK,EACV,sBAAsB,EACtB,uBAAuB,EACxB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAEV,qBAAqB,EACtB,MAAM,qBAAqB,CAAC;AA+G7B;;;GAGG;AACH,eAAO,MAAM,eAAe;;;;;EAAqC,CAAC;AAElE,2EAA2E;AAC3E,eAAO,MAAM,wBAAwB,IAAI,CAAC;AA6B1C,6EAA6E;AAC7E,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;KAA4C,CAAC;AAW1E;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,KAAK,EACL,OAAO,EACP,UAAkB,EAClB,QAAQ,EACR,aAAa,EACb,QAAQ,GACT,EAAE,sBAAsB,sCAuJxB;yBA9Je,iBAAiB;;;AAoKjC;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,EAAE,qBAGhC,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,EAAC,GAAG,EAAE,KAAK,EAAC,EAAE,uBAAuB,QAUvE;yBAVe,kBAAkB"}
|
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
* @file ListReorderHandle.tsx
|
|
7
7
|
* @input The List's reorder session (List/listReorderEngine.tsx, through
|
|
8
8
|
* ListContext's `reorder`), the translator and theme tokens
|
|
9
|
-
* @output `ListReorderHandle`, `ListReorderRowName` and
|
|
10
|
-
* The handle ends a reorderable List row. A finger
|
|
11
|
-
* it, and so does a pen where the primary pointer is
|
|
12
|
-
* pen where it is fine, drags it at once. It is also a
|
|
13
|
-
* (`aria-pressed`): a click, Space or Enter turns its row's reorder
|
|
14
|
-
* and off. The row name serves a row without one, and the style a
|
|
15
|
-
* has one
|
|
9
|
+
* @output `ListReorderHandle`, `ListReorderRowName`, `reorderRowStyle` and
|
|
10
|
+
* `UNREAD_HANDLE_NAME`. The handle ends a reorderable List row. A finger
|
|
11
|
+
* held still on it drags it, and so does a pen where the primary pointer is
|
|
12
|
+
* coarse. A mouse, or a pen where it is fine, drags it at once. It is also a
|
|
13
|
+
* toggle (`aria-pressed`): a click, Space or Enter turns its row's reorder
|
|
14
|
+
* mode on and off. The row name serves a row without one, and the style a
|
|
15
|
+
* row that has one
|
|
16
16
|
* @position Part of the reorder machinery that createReorderable carries.
|
|
17
17
|
* ListItem renders it, from the List's context, at the end of each row
|
|
18
18
|
* that can move
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
* SYNC: When modified, update List/listReorderEngine.tsx and
|
|
32
32
|
* List/ListItem.tsx.
|
|
33
33
|
*/
|
|
34
|
-
import { use,
|
|
34
|
+
import { use, useRef, useSyncExternalStore, useId } from 'react';
|
|
35
35
|
import { useIsomorphicLayoutEffect } from "../hooks/useIsomorphicLayoutEffect.js";
|
|
36
36
|
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
37
37
|
import * as stylex from '@stylexjs/stylex';
|
|
@@ -46,7 +46,6 @@ import { useTouchHitArea } from "../utils/touchHitArea.js";
|
|
|
46
46
|
import { touchHitAreaStyles } from "../internal/touchHitArea.stylex.js";
|
|
47
47
|
import { registerEnglishFallback, useComponentTranslator } from "../i18n/useComponentTranslator.js";
|
|
48
48
|
import english from "../i18n/generated-english/List/ListReorderHandle.generated.js";
|
|
49
|
-
import { createDevWarnings } from "../utils/devWarning.js";
|
|
50
49
|
import { getNodeText } from "../utils/getNodeText.js";
|
|
51
50
|
import { ItemLabelContext } from "../Item/ItemLabelContext.js";
|
|
52
51
|
import { ListContext } from "./ListContext.js";
|
|
@@ -147,17 +146,6 @@ function labelTextOf(handle, labelID) {
|
|
|
147
146
|
return (element?.textContent ?? '').replace(/\s+/g, ' ').trim();
|
|
148
147
|
}
|
|
149
148
|
|
|
150
|
-
/**
|
|
151
|
-
* Whether the row's label element names it: it shows text, or holds an icon
|
|
152
|
-
* or image with an accessible name of its own.
|
|
153
|
-
*/
|
|
154
|
-
function namesRow(element) {
|
|
155
|
-
if (element == null) {
|
|
156
|
-
return false;
|
|
157
|
-
}
|
|
158
|
-
return (element.textContent ?? '').trim() !== '' || element.querySelector('[aria-label]:not([aria-label=""]), [aria-labelledby], img[alt]:not([alt=""])') != null;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
149
|
/**
|
|
162
150
|
* The reorder handle of a List row. Renders nothing outside a reorderable
|
|
163
151
|
* List.
|
|
@@ -186,7 +174,9 @@ export function ListReorderHandle({
|
|
|
186
174
|
const labelledBy = callerLabel != null ? undefined : rowLabelledBy ?? labelID ?? undefined;
|
|
187
175
|
const named = callerLabel != null || labelledBy != null || text !== '';
|
|
188
176
|
const verb = t('@astryx.list.reorderHandleVerb');
|
|
189
|
-
|
|
177
|
+
// Named by Item's label element only while it shows a name: a label of an
|
|
178
|
+
// unnamed icon alone falls back to the place.
|
|
179
|
+
const byLabel = labelID != null && labelledBy === labelID;
|
|
190
180
|
// Syncs the handle into the reorder session, which lives outside React. The
|
|
191
181
|
// session moves the row only with its handle recorded, and reports its
|
|
192
182
|
// moves with the row's key.
|
|
@@ -194,10 +184,19 @@ export function ListReorderHandle({
|
|
|
194
184
|
// Syncs the row's name into the session, which announces the moves with
|
|
195
185
|
// it. A new name keeps the handle recorded, so its row stays in reorder
|
|
196
186
|
// mode. A component label's text is read from its element, rendered by now.
|
|
187
|
+
// The session also reads, from the DOM, whether the label element names the
|
|
188
|
+
// row and where the row sits, for the handle's name.
|
|
197
189
|
useIsomorphicLayoutEffect(() => {
|
|
198
|
-
const
|
|
199
|
-
|
|
200
|
-
|
|
190
|
+
const handle = ref.current;
|
|
191
|
+
const spoken = callerLabel ?? (text !== '' ? text : labelTextOf(handle, labelID ?? null));
|
|
192
|
+
const unname = controller?.registerName(handle, spoken);
|
|
193
|
+
const unlabel = controller?.registerHandleLabel(handle, byLabel ? labelID ?? null : null, named);
|
|
194
|
+
return () => {
|
|
195
|
+
unname?.();
|
|
196
|
+
unlabel?.();
|
|
197
|
+
};
|
|
198
|
+
}, [controller, callerLabel, text, labelID, byLabel, named]);
|
|
199
|
+
const shown = useSyncExternalStore(controller?.subscribeHandleNames ?? subscribeNothing, () => controller?.handleNameOf(ref.current) ?? UNREAD_HANDLE_NAME, () => UNREAD_HANDLE_NAME);
|
|
201
200
|
const isPressed = useSyncExternalStore(controller?.subscribeMode ?? subscribeNothing, () => controller?.isInMode(ref.current) ?? false, () => false);
|
|
202
201
|
const isEnabled = controller != null && !isDisabled;
|
|
203
202
|
// A finger's target: the shared touch hit area grows the handle's hit
|
|
@@ -214,51 +213,26 @@ export function ListReorderHandle({
|
|
|
214
213
|
}
|
|
215
214
|
return () => controller.release(handle);
|
|
216
215
|
}, [controller, isEnabled]);
|
|
217
|
-
// That place is read from the DOM after each commit (the row does not
|
|
218
|
-
// know its index). A passive effect: the list's own ref is attached after
|
|
219
|
-
// its rows' layout effects run.
|
|
220
|
-
useEffect(() => {
|
|
221
|
-
const handle = ref.current;
|
|
222
|
-
if (handle == null) {
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
225
|
-
// Named by Item's label element only while it shows a name: a label of
|
|
226
|
-
// an unnamed icon alone falls back to the place.
|
|
227
|
-
if (labelID != null && labelledBy === labelID) {
|
|
228
|
-
if (namesRow(handle.ownerDocument.getElementById(labelID))) {
|
|
229
|
-
handle.setAttribute('aria-labelledby', `${verbID} ${labelID}`);
|
|
230
|
-
handle.setAttribute('aria-label', verb);
|
|
231
|
-
return;
|
|
232
|
-
}
|
|
233
|
-
handle.removeAttribute('aria-labelledby');
|
|
234
|
-
} else if (named) {
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
const position = controller?.positionOf(handle) ?? null;
|
|
238
|
-
if (position == null) {
|
|
239
|
-
return;
|
|
240
|
-
}
|
|
241
|
-
// Named after its place only: a person hears "Reorder item 3" with
|
|
242
|
-
// nothing to tell the rows apart. Development says so, once a handle.
|
|
243
|
-
warn('ListItem', 'A reorderable row has no accessible name, so its reorder handle is ' + 'named after its place ("Reorder item N"). Give the row a text ' + 'label or an aria-label.');
|
|
244
|
-
handle.setAttribute('aria-label', t('@astryx.list.reorderHandleAt', {
|
|
245
|
-
position
|
|
246
|
-
}));
|
|
247
|
-
});
|
|
248
216
|
if (controller == null) {
|
|
249
217
|
return null;
|
|
250
218
|
}
|
|
219
|
+
// A label element that shows no name falls back to the row's place.
|
|
220
|
+
const labelShowsName = byLabel && !shown.labelShowsNoName;
|
|
221
|
+
const byPlace = byLabel ? !labelShowsName : !named;
|
|
222
|
+
const shownLabelledBy = byLabel && !labelShowsName ? undefined : labelledBy;
|
|
251
223
|
// Named through the label element. The handle's own `aria-label` is the
|
|
252
224
|
// verb. It lists itself first in its `aria-labelledby`, which reads its
|
|
253
225
|
// `aria-label` there: "Reorder", then the row's label.
|
|
254
|
-
const name =
|
|
226
|
+
const name = byPlace && shown.position != null ? t('@astryx.list.reorderHandleAt', {
|
|
227
|
+
position: shown.position
|
|
228
|
+
}) : callerLabel != null ? t('@astryx.list.reorderHandle', {
|
|
255
229
|
label: callerLabel
|
|
256
230
|
}) : labelledBy != null ? verb : text !== '' ? t('@astryx.list.reorderHandle', {
|
|
257
231
|
label: text
|
|
258
232
|
}) : undefined;
|
|
259
233
|
return /*#__PURE__*/_jsx("button", {
|
|
260
234
|
ref: handleRef,
|
|
261
|
-
id:
|
|
235
|
+
id: shownLabelledBy == null ? undefined : verbID,
|
|
262
236
|
type: "button",
|
|
263
237
|
...listReorderHandleProps,
|
|
264
238
|
// The handle takes its own press, so the row does not highlight under
|
|
@@ -268,7 +242,7 @@ export function ListReorderHandle({
|
|
|
268
242
|
,
|
|
269
243
|
...ownRingProps,
|
|
270
244
|
"aria-label": name,
|
|
271
|
-
"aria-labelledby":
|
|
245
|
+
"aria-labelledby": shownLabelledBy == null ? undefined : `${verbID} ${shownLabelledBy}`,
|
|
272
246
|
"aria-describedby": controller.hintId,
|
|
273
247
|
"aria-disabled": isDisabled || undefined,
|
|
274
248
|
"aria-pressed": isPressed
|
|
@@ -307,6 +281,16 @@ export function ListReorderHandle({
|
|
|
307
281
|
ListReorderHandle.displayName = 'ListReorderHandle';
|
|
308
282
|
const subscribeNothing = () => () => {};
|
|
309
283
|
|
|
284
|
+
/**
|
|
285
|
+
* A handle's name before the session reads it: its server snapshot, and the
|
|
286
|
+
* session's answer for a handle it has not read. One object keeps the
|
|
287
|
+
* snapshot through hydration and the first read.
|
|
288
|
+
*/
|
|
289
|
+
export const UNREAD_HANDLE_NAME = {
|
|
290
|
+
position: null,
|
|
291
|
+
labelShowsNoName: false
|
|
292
|
+
};
|
|
293
|
+
|
|
310
294
|
/**
|
|
311
295
|
* Names a reorderable List's row that has no handle, for the announcements
|
|
312
296
|
* of the moves beside it. That is a row that stays, or one without an item
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listReorderContext.d.ts","sourceRoot":"","sources":["../../src/List/listReorderContext.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAC5C,OAAO,
|
|
1
|
+
{"version":3,"file":"listReorderContext.d.ts","sourceRoot":"","sources":["../../src/List/listReorderContext.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAC5C,OAAO,EAEL,KAAK,aAAa,EAClB,KAA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C,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;CACtC;AAED,oEAAoE;AACpE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAC5C,QAAQ,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI,CAAC;CAC7C;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,WAAW,GAAG,SAAS,EACpC,OAAO,EAAE,MAAM,WAAW,GAAG,IAAI,EACjC,MAAM,EAAE,MAAM,GACb,gBAAgB,CASlB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI,GAAG,IAAI,CAKzE"}
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
* List/ListContext.tsx, List/listReorderEngine.tsx and
|
|
21
21
|
* reorderable/createReorderable.ts.
|
|
22
22
|
*/
|
|
23
|
-
import { useMemo
|
|
23
|
+
import { useMemo } from 'react';
|
|
24
|
+
import { useCommittedRef } from "../hooks/useCommittedRef.js";
|
|
24
25
|
import { useIsomorphicLayoutEffect } from "../hooks/useIsomorphicLayoutEffect.js";
|
|
25
26
|
import { sharedKey } from "../utils/sharedRealm.js";
|
|
26
27
|
/**
|
|
@@ -61,9 +62,8 @@ export const REORDER_ENGINE = sharedKey('list/reorder-engine', 1);
|
|
|
61
62
|
export function useReorderSession(reorderable, getList, hintId) {
|
|
62
63
|
const reorder = reorderable;
|
|
63
64
|
const engine = reorder?.[REORDER_ENGINE];
|
|
64
|
-
const getListRef =
|
|
65
|
-
getListRef.current
|
|
66
|
-
const session = useMemo(() => engine?.createSession(() => getListRef.current(), hintId) ?? null, [engine, hintId]);
|
|
65
|
+
const getListRef = useCommittedRef(getList);
|
|
66
|
+
const session = useMemo(() => engine?.createSession(() => getListRef.current(), hintId) ?? null, [engine, hintId, getListRef]);
|
|
67
67
|
return {
|
|
68
68
|
session,
|
|
69
69
|
options: reorder?.options ?? null
|
|
@@ -71,6 +71,16 @@ import type { ListReorderContextValue, ListReorderEngine, ListReorderOptions, Li
|
|
|
71
71
|
* (DateInput/usePointerDragScroll.ts `DRAG_SLOP`); a test keeps them equal.
|
|
72
72
|
*/
|
|
73
73
|
export declare const MOUSE_DRAG_SLOP = 4;
|
|
74
|
+
/**
|
|
75
|
+
* What names a handle besides its own text, as the list last showed it. Its
|
|
76
|
+
* row's 1-based place among the list's rows, null until the session reads
|
|
77
|
+
* it. And whether Item's label element shows no name: an unread label counts
|
|
78
|
+
* as one that shows a name, so a first read that finds a name changes nothing.
|
|
79
|
+
*/
|
|
80
|
+
export interface ListReorderHandleName {
|
|
81
|
+
readonly position: number | null;
|
|
82
|
+
readonly labelShowsNoName: boolean;
|
|
83
|
+
}
|
|
74
84
|
/** The strings the controller announces, from the translator. */
|
|
75
85
|
interface ReorderMessages {
|
|
76
86
|
/**
|
|
@@ -155,6 +165,23 @@ export declare class ListReorderController implements ListReorderSession {
|
|
|
155
165
|
* text) and each handle-less row's own.
|
|
156
166
|
*/
|
|
157
167
|
private readonly names;
|
|
168
|
+
/**
|
|
169
|
+
* For each handle: the id of Item's label element, when that element names
|
|
170
|
+
* the row. Also whether the handle is named some other way.
|
|
171
|
+
*/
|
|
172
|
+
private readonly handleLabels;
|
|
173
|
+
/** Each handle's place and label naming, as the list last showed them. */
|
|
174
|
+
private readonly handleNames;
|
|
175
|
+
private readonly nameListeners;
|
|
176
|
+
/**
|
|
177
|
+
* The list's rows and the label elements, watched through Core's shared
|
|
178
|
+
* mutation observer while the list is up, with each registration's release.
|
|
179
|
+
*/
|
|
180
|
+
private namesWatch;
|
|
181
|
+
private namesQueued;
|
|
182
|
+
/** The handles already warned for being named after their place. */
|
|
183
|
+
private readonly warnedNameless;
|
|
184
|
+
private namelessCount;
|
|
158
185
|
/** The handle whose row is in reorder mode, if any. */
|
|
159
186
|
private modeHandle;
|
|
160
187
|
private readonly modeListeners;
|
|
@@ -215,6 +242,29 @@ export declare class ListReorderController implements ListReorderSession {
|
|
|
215
242
|
registerHandle(handle: Element | null, key: Key): () => void;
|
|
216
243
|
/** Records the name of a row, or of its handle; returns the removal. */
|
|
217
244
|
registerName(row: Element | null, name: string): () => void;
|
|
245
|
+
/**
|
|
246
|
+
* Records how `handle` is named besides its place: by Item's label element
|
|
247
|
+
* `labelId`, or otherwise (`isNamed`). Returns the removal.
|
|
248
|
+
*/
|
|
249
|
+
registerHandleLabel(handle: Element | null, labelId: string | null, isNamed: boolean): () => void;
|
|
250
|
+
/** `handle`'s place and label naming, as the list last showed them. */
|
|
251
|
+
handleNameOf(handle: Element | null): ListReorderHandleName;
|
|
252
|
+
/** Calls `listener` when a handle's place or label naming changes. */
|
|
253
|
+
subscribeHandleNames: (listener: () => void) => (() => void);
|
|
254
|
+
/**
|
|
255
|
+
* Watches the list's rows and the handles' label elements through Core's
|
|
256
|
+
* shared mutation observer. A row's place, and whether its label names it,
|
|
257
|
+
* come from the DOM. Returns the release.
|
|
258
|
+
*/
|
|
259
|
+
attachNames(): () => void;
|
|
260
|
+
private readonly onNamesMutation;
|
|
261
|
+
/** Reads the names once the current commit is done, for every handle. */
|
|
262
|
+
private queueNames;
|
|
263
|
+
/**
|
|
264
|
+
* Reads each handle's place and label naming from the DOM. Only a change
|
|
265
|
+
* reaches the handles. A handle named after its place warns, once.
|
|
266
|
+
*/
|
|
267
|
+
private refreshNames;
|
|
218
268
|
/** What the announcements call the row at `index`. */
|
|
219
269
|
private nameOf;
|
|
220
270
|
/** Whether `handle`'s row is in reorder mode: its `aria-pressed`. */
|
|
@@ -370,8 +420,6 @@ export declare class ListReorderController implements ListReorderSession {
|
|
|
370
420
|
* whatever its tag. Null outside the list.
|
|
371
421
|
*/
|
|
372
422
|
rowOf(element: Element | null): HTMLElement | null;
|
|
373
|
-
/** The 1-based place of the row that holds `element`, or null. */
|
|
374
|
-
positionOf(element: Element | null): number | null;
|
|
375
423
|
/**
|
|
376
424
|
* A handle's key in reorder mode: the arrows move its
|
|
377
425
|
* row a place at once, and Escape ends the mode, keeping the moves. Space
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listReorderEngine.d.ts","sourceRoot":"","sources":["../../src/List/listReorderEngine.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAEH,OAAO,EAGL,KAAK,GAAG,EACR,KAAK,aAAa,EAEnB,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"listReorderEngine.d.ts","sourceRoot":"","sources":["../../src/List/listReorderEngine.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AAEH,OAAO,EAGL,KAAK,GAAG,EACR,KAAK,aAAa,EAEnB,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAG3C,OAAO,EAEL,KAAK,UAAU,EAEhB,MAAM,sBAAsB,CAAC;AAmD9B,OAAO,EAEL,iBAAiB,EACjB,kBAAkB,EAInB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EACV,uBAAuB,EACvB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,WAAW,EACZ,MAAM,sBAAsB,CAAC;AAU9B;;;;;GAKG;AACH,eAAO,MAAM,eAAe,IAAI,CAAC;AA4FjC;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;CACpC;AA8VD,iEAAiE;AACjE,UAAU,eAAe;IACvB;;;OAGG;IACH,KAAK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,qBAAqB;IAgB7B;;;;OAIG;IACH,IAAI,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI,GAAG,IAAI;IAwBhE;;;OAGG;IACH,OAAO,CAAC,YAAY;IAyBpB,OAAO,IAAI,IAAI;CAqBhB;AAWD;;;;;GAKG;AACH,iBAAS,eAAe,CAAC,EAAC,OAAO,EAAC,EAAE;IAAC,OAAO,EAAE,uBAAuB,CAAA;CAAC,+BAgDrE;AA+ID,sEAAsE;AACtE,eAAO,MAAM,iBAAiB,EAAE,iBAqB/B,CAAC"}
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
*/
|
|
66
66
|
import { useRef, useSyncExternalStore } from 'react';
|
|
67
67
|
import * as stylex from '@stylexjs/stylex';
|
|
68
|
+
import { useCommittedRef } from "../hooks/useCommittedRef.js";
|
|
68
69
|
import { useIsomorphicLayoutEffect } from "../hooks/useIsomorphicLayoutEffect.js";
|
|
69
70
|
import { useAnnounce } from "../hooks/useAnnounce.js";
|
|
70
71
|
import { registerEnglishFallback, useComponentTranslator } from "../i18n/useComponentTranslator.js";
|
|
@@ -87,13 +88,14 @@ import { useTouchPresentation } from "../utils/touchPresentation.js";
|
|
|
87
88
|
import { useTouchHitArea } from "../utils/touchHitArea.js";
|
|
88
89
|
import { touchHitAreaStyles } from "../internal/touchHitArea.stylex.js";
|
|
89
90
|
import { createDevWarnings, devWarn } from "../utils/devWarning.js";
|
|
91
|
+
import { observeMutations } from "../utils/sharedMutationObserver.js";
|
|
90
92
|
import { isLeaving, markLeaving } from "../privateAttributes/leaving.stylex.js";
|
|
91
93
|
import { closestReorderHandle, reorderHandlesIn } from "../privateAttributes/listReorder.stylex.js";
|
|
92
94
|
import { clearReorderSource, markReorderSource } from "../privateAttributes/reorderSource.stylex.js";
|
|
93
95
|
import { markReorderPreview } from "../privateAttributes/reorderPreview.stylex.js";
|
|
94
96
|
import { hideReorderLine, showReorderLine } from "../privateAttributes/reorderLine.stylex.js";
|
|
95
97
|
import { clearReordering, isReordering, markReordering } from "../privateAttributes/reordering.stylex.js";
|
|
96
|
-
import { INSERTION_LINE_THICKNESS, ListReorderHandle, ListReorderRowName, reorderListStyle, reorderRowStyle } from "./ListReorderHandle.js";
|
|
98
|
+
import { INSERTION_LINE_THICKNESS, ListReorderHandle, ListReorderRowName, UNREAD_HANDLE_NAME, reorderListStyle, reorderRowStyle } from "./ListReorderHandle.js";
|
|
97
99
|
import { attachTouchHold, touchMotion } from "./ListReorderTouch.js";
|
|
98
100
|
import { autoscrollStep, clampTop, dropPosition } from "./reorderModel.js";
|
|
99
101
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -159,6 +161,33 @@ function settleAtRest(element, value, moving) {
|
|
|
159
161
|
releaseMotion(element, 'translate');
|
|
160
162
|
}
|
|
161
163
|
|
|
164
|
+
/**
|
|
165
|
+
* Whether the row's label element names it: it shows text, or holds an icon
|
|
166
|
+
* or image with an accessible name of its own.
|
|
167
|
+
*/
|
|
168
|
+
function namesRow(element) {
|
|
169
|
+
if (element == null) {
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
return (element.textContent ?? '').trim() !== '' || element.querySelector('[aria-label]:not([aria-label=""]), [aria-labelledby], img[alt]:not([alt=""])') != null;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/** What a label element's change that can rename its row looks like. */
|
|
176
|
+
const LABEL_WATCH = {
|
|
177
|
+
subtree: true,
|
|
178
|
+
childList: true,
|
|
179
|
+
characterData: true,
|
|
180
|
+
attributes: true,
|
|
181
|
+
attributeFilter: ['aria-label', 'aria-labelledby', 'alt']
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* What names a handle besides its own text, as the list last showed it. Its
|
|
186
|
+
* row's 1-based place among the list's rows, null until the session reads
|
|
187
|
+
* it. And whether Item's label element shows no name: an unread label counts
|
|
188
|
+
* as one that shows a name, so a first read that finds a name changes nothing.
|
|
189
|
+
*/
|
|
190
|
+
|
|
162
191
|
/**
|
|
163
192
|
* The list's rows: its element children. A removed row put back for its exit
|
|
164
193
|
* holds no place in the order, so it is left out (`markLeaving`).
|
|
@@ -470,6 +499,23 @@ export class ListReorderController {
|
|
|
470
499
|
* text) and each handle-less row's own.
|
|
471
500
|
*/
|
|
472
501
|
names = new Map();
|
|
502
|
+
/**
|
|
503
|
+
* For each handle: the id of Item's label element, when that element names
|
|
504
|
+
* the row. Also whether the handle is named some other way.
|
|
505
|
+
*/
|
|
506
|
+
handleLabels = new Map();
|
|
507
|
+
/** Each handle's place and label naming, as the list last showed them. */
|
|
508
|
+
handleNames = new Map();
|
|
509
|
+
nameListeners = new Set();
|
|
510
|
+
/**
|
|
511
|
+
* The list's rows and the label elements, watched through Core's shared
|
|
512
|
+
* mutation observer while the list is up, with each registration's release.
|
|
513
|
+
*/
|
|
514
|
+
namesWatch = null;
|
|
515
|
+
namesQueued = false;
|
|
516
|
+
/** The handles already warned for being named after their place. */
|
|
517
|
+
warnedNameless = new WeakSet();
|
|
518
|
+
namelessCount = 0;
|
|
473
519
|
/** The handle whose row is in reorder mode, if any. */
|
|
474
520
|
modeHandle = null;
|
|
475
521
|
modeListeners = new Set();
|
|
@@ -565,6 +611,160 @@ export class ListReorderController {
|
|
|
565
611
|
};
|
|
566
612
|
}
|
|
567
613
|
|
|
614
|
+
/**
|
|
615
|
+
* Records how `handle` is named besides its place: by Item's label element
|
|
616
|
+
* `labelId`, or otherwise (`isNamed`). Returns the removal.
|
|
617
|
+
*/
|
|
618
|
+
registerHandleLabel(handle, labelId, isNamed) {
|
|
619
|
+
if (handle == null) {
|
|
620
|
+
return () => {};
|
|
621
|
+
}
|
|
622
|
+
const label = {
|
|
623
|
+
labelId,
|
|
624
|
+
isNamed
|
|
625
|
+
};
|
|
626
|
+
this.handleLabels.set(handle, label);
|
|
627
|
+
this.queueNames();
|
|
628
|
+
return () => {
|
|
629
|
+
if (this.handleLabels.get(handle) === label) {
|
|
630
|
+
this.handleLabels.delete(handle);
|
|
631
|
+
this.queueNames();
|
|
632
|
+
}
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
/** `handle`'s place and label naming, as the list last showed them. */
|
|
637
|
+
handleNameOf(handle) {
|
|
638
|
+
return (handle == null ? null : this.handleNames.get(handle)) ?? UNREAD_HANDLE_NAME;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
/** Calls `listener` when a handle's place or label naming changes. */
|
|
642
|
+
subscribeHandleNames = listener => {
|
|
643
|
+
this.nameListeners.add(listener);
|
|
644
|
+
return () => {
|
|
645
|
+
this.nameListeners.delete(listener);
|
|
646
|
+
};
|
|
647
|
+
};
|
|
648
|
+
|
|
649
|
+
/**
|
|
650
|
+
* Watches the list's rows and the handles' label elements through Core's
|
|
651
|
+
* shared mutation observer. A row's place, and whether its label names it,
|
|
652
|
+
* come from the DOM. Returns the release.
|
|
653
|
+
*/
|
|
654
|
+
attachNames() {
|
|
655
|
+
const list = this.getList();
|
|
656
|
+
if (list == null) {
|
|
657
|
+
return () => {};
|
|
658
|
+
}
|
|
659
|
+
const watch = {
|
|
660
|
+
list,
|
|
661
|
+
unwatchRows: observeMutations(list, {
|
|
662
|
+
childList: true
|
|
663
|
+
}, this.onNamesMutation),
|
|
664
|
+
labels: new Map()
|
|
665
|
+
};
|
|
666
|
+
this.namesWatch = watch;
|
|
667
|
+
this.refreshNames();
|
|
668
|
+
return () => {
|
|
669
|
+
watch.unwatchRows();
|
|
670
|
+
for (const unwatch of watch.labels.values()) {
|
|
671
|
+
unwatch();
|
|
672
|
+
}
|
|
673
|
+
watch.labels.clear();
|
|
674
|
+
if (this.namesWatch === watch) {
|
|
675
|
+
this.namesWatch = null;
|
|
676
|
+
}
|
|
677
|
+
};
|
|
678
|
+
}
|
|
679
|
+
onNamesMutation = () => {
|
|
680
|
+
this.refreshNames();
|
|
681
|
+
};
|
|
682
|
+
|
|
683
|
+
/** Reads the names once the current commit is done, for every handle. */
|
|
684
|
+
queueNames() {
|
|
685
|
+
if (this.namesQueued) {
|
|
686
|
+
return;
|
|
687
|
+
}
|
|
688
|
+
this.namesQueued = true;
|
|
689
|
+
queueMicrotask(() => {
|
|
690
|
+
this.namesQueued = false;
|
|
691
|
+
this.refreshNames();
|
|
692
|
+
});
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
/**
|
|
696
|
+
* Reads each handle's place and label naming from the DOM. Only a change
|
|
697
|
+
* reaches the handles. A handle named after its place warns, once.
|
|
698
|
+
*/
|
|
699
|
+
refreshNames() {
|
|
700
|
+
const list = this.getList();
|
|
701
|
+
if (list == null) {
|
|
702
|
+
return;
|
|
703
|
+
}
|
|
704
|
+
const places = new Map(this.rows.read(list).map((row, index) => [row, index + 1]));
|
|
705
|
+
const watch = this.namesWatch;
|
|
706
|
+
// The List renders a new element when its numbering turns on or off (an
|
|
707
|
+
// `ol` or a `ul`). Its remounted handles refresh the names, which moves
|
|
708
|
+
// the watch onto it.
|
|
709
|
+
if (watch != null && watch.list !== list) {
|
|
710
|
+
watch.unwatchRows();
|
|
711
|
+
watch.list = list;
|
|
712
|
+
watch.unwatchRows = observeMutations(list, {
|
|
713
|
+
childList: true
|
|
714
|
+
}, this.onNamesMutation);
|
|
715
|
+
}
|
|
716
|
+
const watched = new Set();
|
|
717
|
+
let changed = false;
|
|
718
|
+
for (const handle of this.keys.keys()) {
|
|
719
|
+
const label = this.handleLabels.get(handle);
|
|
720
|
+
const element = label?.labelId == null ? null : list.ownerDocument.getElementById(label.labelId);
|
|
721
|
+
if (element != null && watch != null) {
|
|
722
|
+
watched.add(element);
|
|
723
|
+
if (!watch.labels.has(element)) {
|
|
724
|
+
watch.labels.set(element, observeMutations(element, LABEL_WATCH, this.onNamesMutation));
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
const labelShowsNoName = label?.labelId != null && !namesRow(element);
|
|
728
|
+
const byPlace = label != null && (label.labelId != null ? labelShowsNoName : !label.isNamed);
|
|
729
|
+
// Only a handle named after its place keeps it, so a reorder leaves
|
|
730
|
+
// the handles named some other way alone.
|
|
731
|
+
const row = byPlace ? this.rowOf(handle) : null;
|
|
732
|
+
const position = row == null ? null : places.get(row) ?? null;
|
|
733
|
+
const previous = this.handleNameOf(handle);
|
|
734
|
+
if (previous.position !== position || previous.labelShowsNoName !== labelShowsNoName) {
|
|
735
|
+
this.handleNames.set(handle, {
|
|
736
|
+
position,
|
|
737
|
+
labelShowsNoName
|
|
738
|
+
});
|
|
739
|
+
changed = true;
|
|
740
|
+
}
|
|
741
|
+
if (byPlace && position != null && !this.warnedNameless.has(handle)) {
|
|
742
|
+
// Named after its place only: a person hears "Reorder item 3" with
|
|
743
|
+
// nothing to tell the rows apart.
|
|
744
|
+
this.warnedNameless.add(handle);
|
|
745
|
+
this.namelessCount += 1;
|
|
746
|
+
this.warn('ListItem', 'A reorderable row has no accessible name, so its reorder handle is ' + 'named after its place ("Reorder item N"). Give the row a text ' + 'label or an aria-label.', `nameless-row-${this.namelessCount}`);
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
for (const handle of this.handleNames.keys()) {
|
|
750
|
+
if (!this.keys.has(handle)) {
|
|
751
|
+
this.handleNames.delete(handle);
|
|
752
|
+
changed = true;
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
for (const [element, unwatch] of watch?.labels ?? []) {
|
|
756
|
+
if (!watched.has(element)) {
|
|
757
|
+
unwatch();
|
|
758
|
+
watch?.labels.delete(element);
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
if (changed) {
|
|
762
|
+
for (const listener of [...this.nameListeners]) {
|
|
763
|
+
listener();
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
|
|
568
768
|
/** What the announcements call the row at `index`. */
|
|
569
769
|
nameOf(row, index) {
|
|
570
770
|
const handle = this.handleIn(row);
|
|
@@ -1659,13 +1859,6 @@ export class ListReorderController {
|
|
|
1659
1859
|
return node instanceof HTMLElement ? node : null;
|
|
1660
1860
|
}
|
|
1661
1861
|
|
|
1662
|
-
/** The 1-based place of the row that holds `element`, or null. */
|
|
1663
|
-
positionOf(element) {
|
|
1664
|
-
const list = this.getList();
|
|
1665
|
-
const row = this.rowOf(element);
|
|
1666
|
-
return list == null || row == null ? null : this.rows.read(list).indexOf(row) + 1;
|
|
1667
|
-
}
|
|
1668
|
-
|
|
1669
1862
|
// --- Keys ------------------------------------------------------------
|
|
1670
1863
|
|
|
1671
1864
|
/**
|
|
@@ -1893,6 +2086,9 @@ function ListReorderHost({
|
|
|
1893
2086
|
});
|
|
1894
2087
|
// The list's own pointer listeners, on its DOM element.
|
|
1895
2088
|
useIsomorphicLayoutEffect(() => controller.attachMouse(), [controller]);
|
|
2089
|
+
// Syncs the handles' names with the list's rows and their label elements
|
|
2090
|
+
// in the DOM, through the session's observer.
|
|
2091
|
+
useIsomorphicLayoutEffect(() => controller.attachNames(), [controller]);
|
|
1896
2092
|
// The owner's options, for an object a Lab collection adapted from the
|
|
1897
2093
|
// owner's.
|
|
1898
2094
|
const startedBy = options.startedBy ?? options;
|
|
@@ -1983,8 +2179,7 @@ function ListReorderModeHint({
|
|
|
1983
2179
|
});
|
|
1984
2180
|
// The latest layer handle, for the effect below, which re-runs only when
|
|
1985
2181
|
// the mode's row changes.
|
|
1986
|
-
const layerRef =
|
|
1987
|
-
layerRef.current = layer;
|
|
2182
|
+
const layerRef = useCommittedRef(layer);
|
|
1988
2183
|
const hintRef = useRef(null);
|
|
1989
2184
|
// External system: the hint's popover in the top layer (useLayer),
|
|
1990
2185
|
// anchored to the handle of the row in reorder mode. Shown while that row
|
|
@@ -98,7 +98,7 @@ export interface MoreMenuProps extends Pick<BaseProps, 'xstyle' | 'className' |
|
|
|
98
98
|
* />
|
|
99
99
|
* ```
|
|
100
100
|
*/
|
|
101
|
-
export declare function MoreMenu({ items, label: labelFromProps, variant, size: sizeProp, icon, isDisabled, placement, alignment, presentation, isMenuOpen, onOpenChange, xstyle, className: classNameProp, style, 'data-testid': testId, ref, }: MoreMenuProps): import("react").JSX.Element;
|
|
101
|
+
export declare function MoreMenu({ items, label: labelFromProps, variant, size: sizeProp, icon, isDisabled, placement, alignment, presentation, isMenuOpen, onOpenChange, xstyle, className: classNameProp, style, 'data-testid': testId, ref, ...rest }: MoreMenuProps): import("react").JSX.Element;
|
|
102
102
|
export declare namespace MoreMenu {
|
|
103
103
|
var displayName: string;
|
|
104
104
|
}
|