@astryxdesign/core 0.7.15 → 0.7.16-canary.g8514aae
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/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/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/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/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/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 +10 -10
- 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/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 +2 -0
- package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/pseudo.generated.js +2 -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/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 +9 -1
- package/locales/pseudo.json +6 -0
- package/package.json +5 -5
- 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/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/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/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/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/Table/plugins/infiniteScroll/useTableInfiniteScroll.generated.ts +13 -0
- package/src/i18n/generated-locales/en.generated.ts +2 -0
- package/src/i18n/generated-locales/pseudo.generated.ts +2 -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/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
|
@@ -41,24 +41,28 @@ import "../theme/tokens.stylex.js";
|
|
|
41
41
|
import { durationVars, easeVars, spacingVars } from "../theme/tokens.stylex.js";
|
|
42
42
|
|
|
43
43
|
// The layer runtime writes the side a shown anchored layer landed on. It
|
|
44
|
-
// writes a step toward the trigger on each axis (-1, 0 or 1)
|
|
45
|
-
//
|
|
46
|
-
// nothing is written.
|
|
44
|
+
// writes a step toward the trigger on each axis (-1, 0 or 1) and the scale's
|
|
45
|
+
// origin. It also writes the room to the trigger, which caps the step. Each
|
|
46
|
+
// fallback is the placement's own side, used when nothing is written.
|
|
47
47
|
const ENTER_X = '--_astryx-layer-enter-x';
|
|
48
48
|
const ENTER_Y = '--_astryx-layer-enter-y';
|
|
49
49
|
const ENTER_ORIGIN = '--_astryx-layer-enter-origin';
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
const
|
|
50
|
+
const ENTER_GAP = '--_astryx-layer-enter-gap';
|
|
51
|
+
// One step: the spacing token, or the room to the trigger when that is less.
|
|
52
|
+
// Without a written gap, the step is the token.
|
|
53
|
+
const STEP = `min(${spacingVars['--spacing-2']}, var(${ENTER_GAP}, ${spacingVars['--spacing-2']}))`;
|
|
54
|
+
const enterBelow = "x1fbltco-B";
|
|
55
|
+
const enterAbove = "xmqt0mh-B";
|
|
56
|
+
const enterEnd = "x1yqd01s-B";
|
|
57
|
+
const enterStart = "x12ghk8m-B";
|
|
54
58
|
|
|
55
59
|
// RTL: the horizontal fallback is a physical translateX, so it mirrors under
|
|
56
60
|
// RTL. A layer on the inline-end or inline-start side then slides in from
|
|
57
61
|
// the physical side that follows the reading flow. Only the horizontal
|
|
58
62
|
// fallbacks mirror; the vertical ones are direction-neutral. The side the
|
|
59
63
|
// runtime writes is physical already.
|
|
60
|
-
const enterEndRtl = "
|
|
61
|
-
const enterStartRtl = "
|
|
64
|
+
const enterEndRtl = "x12ghk8m-B";
|
|
65
|
+
const enterStartRtl = "x1yqd01s-B";
|
|
62
66
|
|
|
63
67
|
// Reduce Motion under a finger: the same entrance without its travel. A touch
|
|
64
68
|
// presentation substitutes a cross-fade for motion, never a jump.
|
|
@@ -95,7 +99,7 @@ const animationBase = {
|
|
|
95
99
|
*/
|
|
96
100
|
export const layerAnimations = {
|
|
97
101
|
below: {
|
|
98
|
-
kKVMdj: "
|
|
102
|
+
kKVMdj: "x1d5jn3a x2g3n7u xaqowwx",
|
|
99
103
|
k44tkh: "x9uej1z x10got5w",
|
|
100
104
|
kyAemX: "x128ha8g",
|
|
101
105
|
kWV6AL: "xskzprw",
|
|
@@ -103,7 +107,7 @@ export const layerAnimations = {
|
|
|
103
107
|
$$css: true
|
|
104
108
|
},
|
|
105
109
|
above: {
|
|
106
|
-
kKVMdj: "
|
|
110
|
+
kKVMdj: "xksu0ym x2g3n7u xaqowwx",
|
|
107
111
|
k44tkh: "x9uej1z x10got5w",
|
|
108
112
|
kyAemX: "x128ha8g",
|
|
109
113
|
kWV6AL: "xskzprw",
|
|
@@ -111,7 +115,7 @@ export const layerAnimations = {
|
|
|
111
115
|
$$css: true
|
|
112
116
|
},
|
|
113
117
|
end: {
|
|
114
|
-
kKVMdj: "
|
|
118
|
+
kKVMdj: "xyzx0um xixcm9l x2g3n7u xaqowwx",
|
|
115
119
|
k44tkh: "x9uej1z x10got5w",
|
|
116
120
|
kyAemX: "x128ha8g",
|
|
117
121
|
kWV6AL: "xskzprw",
|
|
@@ -119,7 +123,7 @@ export const layerAnimations = {
|
|
|
119
123
|
$$css: true
|
|
120
124
|
},
|
|
121
125
|
start: {
|
|
122
|
-
kKVMdj: "
|
|
126
|
+
kKVMdj: "x1qqotkc x1g7o29q x2g3n7u xaqowwx",
|
|
123
127
|
k44tkh: "x9uej1z x10got5w",
|
|
124
128
|
kyAemX: "x128ha8g",
|
|
125
129
|
kWV6AL: "xskzprw",
|
|
@@ -4,6 +4,8 @@ export declare const LAYER_ENTER_X_PROPERTY = "--_astryx-layer-enter-x";
|
|
|
4
4
|
export declare const LAYER_ENTER_Y_PROPERTY = "--_astryx-layer-enter-y";
|
|
5
5
|
/** The scale's origin, in px from the layer's top-left corner. */
|
|
6
6
|
export declare const LAYER_ENTER_ORIGIN_PROPERTY = "--_astryx-layer-enter-origin";
|
|
7
|
+
/** The room between the layer and its anchor: the longest step it takes. */
|
|
8
|
+
export declare const LAYER_ENTER_GAP_PROPERTY = "--_astryx-layer-enter-gap";
|
|
7
9
|
interface Box {
|
|
8
10
|
readonly left: number;
|
|
9
11
|
readonly top: number;
|
|
@@ -17,15 +19,25 @@ export interface LayerEntranceSide {
|
|
|
17
19
|
/** Where the layer meets its anchor, in px from the layer's top-left. */
|
|
18
20
|
readonly originX: number;
|
|
19
21
|
readonly originY: number;
|
|
22
|
+
/**
|
|
23
|
+
* The room between the layer and its anchor on the step's axis, in px.
|
|
24
|
+
* `null` for a point anchor, at most a pixel each way, such as a menu's
|
|
25
|
+
* cursor anchor.
|
|
26
|
+
*/
|
|
27
|
+
readonly gap: number | null;
|
|
20
28
|
}
|
|
21
29
|
/**
|
|
22
30
|
* The side that `layer` sits on against `anchor`, with the step toward the
|
|
23
|
-
* anchor. The origin is where the two meet: on the layer's edge that faces
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
31
|
+
* anchor. The origin is where the two meet: on the layer's edge that faces the
|
|
32
|
+
* anchor, on the anchor's center line. It stays on that edge. The gap is the
|
|
33
|
+
* room between the two on the step's axis. The step never goes past it, so no
|
|
34
|
+
* frame of the entrance covers a sized anchor. A layer flush against or over
|
|
35
|
+
* its anchor takes no step. An anchor of at most a pixel each way, such as a
|
|
36
|
+
* menu's cursor anchor, is a point. A point has no gap, and its layer takes the
|
|
37
|
+
* whole step. The side is the axis on which the two centers are furthest apart,
|
|
38
|
+
* in half their joint size. A layer that overlaps its anchor by a few pixels (a
|
|
39
|
+
* submenu against its row) thus still has a side. A layer over its anchor's
|
|
40
|
+
* center (a list over its selected item) has no side. It does not move, and it
|
|
29
41
|
* scales about that center. `null` for a box without size.
|
|
30
42
|
*/
|
|
31
43
|
export declare function layerEntranceSide(layer: Box, anchor: Box): LayerEntranceSide | null;
|
|
@@ -37,10 +49,12 @@ export declare function layerEntranceSide(layer: Box, anchor: Box): LayerEntranc
|
|
|
37
49
|
export declare function readLayerEntranceSide(layer: HTMLElement, anchor: Element): LayerEntranceSide | null;
|
|
38
50
|
/**
|
|
39
51
|
* Gives the layer's entrance the side the layer landed on after any flip.
|
|
40
|
-
* The entrance then slides from that side,
|
|
41
|
-
* the layer meets its anchor.
|
|
42
|
-
*
|
|
43
|
-
*
|
|
52
|
+
* The entrance then slides from that side, no further than the gap, and
|
|
53
|
+
* scales about the point where the layer meets its anchor. A layer at a
|
|
54
|
+
* point, as a menu at its cursor anchor, has no gap and takes the whole
|
|
55
|
+
* step. It only writes, so it can follow a pass that read the boxes. `null`
|
|
56
|
+
* sets the properties to `initial`. The entrance then keeps its placement's
|
|
57
|
+
* side, and a layer inside never inherits the values.
|
|
44
58
|
*/
|
|
45
59
|
export declare function writeLayerEntranceSide(layer: HTMLElement, side: LayerEntranceSide | null): void;
|
|
46
60
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layerEntranceSide.d.ts","sourceRoot":"","sources":["../../src/Layer/layerEntranceSide.ts"],"names":[],"mappings":"AAkBA,mEAAmE;AACnE,eAAO,MAAM,sBAAsB,4BAA4B,CAAC;AAChE,8DAA8D;AAC9D,eAAO,MAAM,sBAAsB,4BAA4B,CAAC;AAChE,kEAAkE;AAClE,eAAO,MAAM,2BAA2B,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"layerEntranceSide.d.ts","sourceRoot":"","sources":["../../src/Layer/layerEntranceSide.ts"],"names":[],"mappings":"AAkBA,mEAAmE;AACnE,eAAO,MAAM,sBAAsB,4BAA4B,CAAC;AAChE,8DAA8D;AAC9D,eAAO,MAAM,sBAAsB,4BAA4B,CAAC;AAChE,kEAAkE;AAClE,eAAO,MAAM,2BAA2B,iCAAiC,CAAC;AAC1E,4EAA4E;AAC5E,eAAO,MAAM,wBAAwB,8BAA8B,CAAC;AAEpE,UAAU,GAAG;IACX,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,iBAAiB;IAChC,wEAAwE;IACxE,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACvB,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACvB,yEAAyE;IACzE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAID;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,GAAG,EACV,MAAM,EAAE,GAAG,GACV,iBAAiB,GAAG,IAAI,CAuD1B;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,OAAO,GACd,iBAAiB,GAAG,IAAI,CAG1B;AAID;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,WAAW,EAClB,IAAI,EAAE,iBAAiB,GAAG,IAAI,GAC7B,IAAI,CAmBN"}
|
|
@@ -22,16 +22,22 @@ export const LAYER_ENTER_X_PROPERTY = '--_astryx-layer-enter-x';
|
|
|
22
22
|
export const LAYER_ENTER_Y_PROPERTY = '--_astryx-layer-enter-y';
|
|
23
23
|
/** The scale's origin, in px from the layer's top-left corner. */
|
|
24
24
|
export const LAYER_ENTER_ORIGIN_PROPERTY = '--_astryx-layer-enter-origin';
|
|
25
|
+
/** The room between the layer and its anchor: the longest step it takes. */
|
|
26
|
+
export const LAYER_ENTER_GAP_PROPERTY = '--_astryx-layer-enter-gap';
|
|
25
27
|
const clamp = (value, max) => Math.min(max, Math.max(0, value));
|
|
26
28
|
|
|
27
29
|
/**
|
|
28
30
|
* The side that `layer` sits on against `anchor`, with the step toward the
|
|
29
|
-
* anchor. The origin is where the two meet: on the layer's edge that faces
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
31
|
+
* anchor. The origin is where the two meet: on the layer's edge that faces the
|
|
32
|
+
* anchor, on the anchor's center line. It stays on that edge. The gap is the
|
|
33
|
+
* room between the two on the step's axis. The step never goes past it, so no
|
|
34
|
+
* frame of the entrance covers a sized anchor. A layer flush against or over
|
|
35
|
+
* its anchor takes no step. An anchor of at most a pixel each way, such as a
|
|
36
|
+
* menu's cursor anchor, is a point. A point has no gap, and its layer takes the
|
|
37
|
+
* whole step. The side is the axis on which the two centers are furthest apart,
|
|
38
|
+
* in half their joint size. A layer that overlaps its anchor by a few pixels (a
|
|
39
|
+
* submenu against its row) thus still has a side. A layer over its anchor's
|
|
40
|
+
* center (a list over its selected item) has no side. It does not move, and it
|
|
35
41
|
* scales about that center. `null` for a box without size.
|
|
36
42
|
*/
|
|
37
43
|
export function layerEntranceSide(layer, anchor) {
|
|
@@ -42,13 +48,15 @@ export function layerEntranceSide(layer, anchor) {
|
|
|
42
48
|
const anchorY = anchor.top + anchor.height / 2;
|
|
43
49
|
const originX = clamp(anchorX - layer.left, layer.width);
|
|
44
50
|
const originY = clamp(anchorY - layer.top, layer.height);
|
|
51
|
+
const isPoint = anchor.width <= 1 && anchor.height <= 1;
|
|
45
52
|
const coversAnchor = originX > 0 && originX < layer.width && originY > 0 && originY < layer.height;
|
|
46
53
|
if (coversAnchor) {
|
|
47
54
|
return {
|
|
48
55
|
x: 0,
|
|
49
56
|
y: 0,
|
|
50
57
|
originX,
|
|
51
|
-
originY
|
|
58
|
+
originY,
|
|
59
|
+
gap: 0
|
|
52
60
|
};
|
|
53
61
|
}
|
|
54
62
|
const apartX = (layer.left + layer.width / 2 - anchorX) / ((layer.width + anchor.width) / 2);
|
|
@@ -59,7 +67,8 @@ export function layerEntranceSide(layer, anchor) {
|
|
|
59
67
|
x: 0,
|
|
60
68
|
y: below ? -1 : 1,
|
|
61
69
|
originX,
|
|
62
|
-
originY: below ? 0 : layer.height
|
|
70
|
+
originY: below ? 0 : layer.height,
|
|
71
|
+
gap: isPoint ? null : Math.max(0, below ? layer.top - (anchor.top + anchor.height) : anchor.top - (layer.top + layer.height))
|
|
63
72
|
};
|
|
64
73
|
}
|
|
65
74
|
const right = apartX > 0;
|
|
@@ -67,7 +76,8 @@ export function layerEntranceSide(layer, anchor) {
|
|
|
67
76
|
x: right ? -1 : 1,
|
|
68
77
|
y: 0,
|
|
69
78
|
originX: right ? 0 : layer.width,
|
|
70
|
-
originY
|
|
79
|
+
originY,
|
|
80
|
+
gap: isPoint ? null : Math.max(0, right ? layer.left - (anchor.left + anchor.width) : anchor.left - (layer.left + layer.width))
|
|
71
81
|
};
|
|
72
82
|
}
|
|
73
83
|
|
|
@@ -84,13 +94,18 @@ const px = value => `${Math.round(value * 1000) / 1000}px`;
|
|
|
84
94
|
|
|
85
95
|
/**
|
|
86
96
|
* Gives the layer's entrance the side the layer landed on after any flip.
|
|
87
|
-
* The entrance then slides from that side,
|
|
88
|
-
* the layer meets its anchor.
|
|
89
|
-
*
|
|
90
|
-
*
|
|
97
|
+
* The entrance then slides from that side, no further than the gap, and
|
|
98
|
+
* scales about the point where the layer meets its anchor. A layer at a
|
|
99
|
+
* point, as a menu at its cursor anchor, has no gap and takes the whole
|
|
100
|
+
* step. It only writes, so it can follow a pass that read the boxes. `null`
|
|
101
|
+
* sets the properties to `initial`. The entrance then keeps its placement's
|
|
102
|
+
* side, and a layer inside never inherits the values.
|
|
91
103
|
*/
|
|
92
104
|
export function writeLayerEntranceSide(layer, side) {
|
|
93
105
|
layer.style.setProperty(LAYER_ENTER_X_PROPERTY, side == null ? 'initial' : String(side.x));
|
|
94
106
|
layer.style.setProperty(LAYER_ENTER_Y_PROPERTY, side == null ? 'initial' : String(side.y));
|
|
95
107
|
layer.style.setProperty(LAYER_ENTER_ORIGIN_PROPERTY, side == null ? 'initial' : `${px(side.originX)} ${px(side.originY)}`);
|
|
108
|
+
// Floored, so rounding never carries the step past the anchor's edge.
|
|
109
|
+
const gap = side?.gap == null ? null : Math.floor(side.gap * 1000) / 1000;
|
|
110
|
+
layer.style.setProperty(LAYER_ENTER_GAP_PROPERTY, gap == null ? 'initial' : `${gap}px`);
|
|
96
111
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLayer.d.ts","sourceRoot":"","sources":["../../src/Layer/useLayer.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,EAQZ,KAAK,SAAS,EACd,KAAK,WAAW,EACjB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"useLayer.d.ts","sourceRoot":"","sources":["../../src/Layer/useLayer.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,EAQZ,KAAK,SAAS,EACd,KAAK,WAAW,EACjB,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,kBAAkB,CAAC;AAgLnD;;GAEG;AACH,UAAU,kBAAkB;IAC1B,aAAa,EAAE,KAAK,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC;IACtD;;;OAGG;IACH,cAAc,EAAE,KAAK,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;CACtD;AAED;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,CAAC;AAEjE;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;AAExD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;;;;;;;;;;;OAcG;IACH,WAAW,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAClC;;;OAGG;IACH,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B;;;OAGG;IACH,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,MAAM,CAAC,EAAE,YAAY,CAAC;IAC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Ac,EAAE,OAAO,GACtB,KAAK,CAAC,aAAa,CAQrB;AA4BD;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,OAAO,GACd,kBAAkB,CAqCpB;AAyuCD,wBAAgB,QAAQ,CAAC,OAAO,EAAE,mBAAmB,GAAG,kBAAkB,CAAC;AAC3E,wBAAgB,QAAQ,CAAC,OAAO,EAAE,iBAAiB,GAAG,gBAAgB,CAAC;AAOvE;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,2BAA2B,GACnC,kBAAkB,CAAC;AACtB,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,GAAG,gBAAgB,CAAC"}
|
package/dist/Layer/useLayer.js
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* - /packages/core/src/Layer/index.ts
|
|
15
15
|
*/
|
|
16
16
|
import React, { useCallback, useEffect, useId, useMemo, useRef, useState, useSyncExternalStore } from 'react';
|
|
17
|
+
import { useCommittedRef, useCommittedRefInto } from "../hooks/useCommittedRef.js";
|
|
17
18
|
import * as stylex from '@stylexjs/stylex';
|
|
18
19
|
import { createPortal } from 'react-dom';
|
|
19
20
|
import { LayerContentBoundary } from "./layerScopedContext.js";
|
|
@@ -793,16 +794,18 @@ function getGutterStyles(placement, alignment) {
|
|
|
793
794
|
* of the public useLayer or usePopover return types.
|
|
794
795
|
*/
|
|
795
796
|
export function useKeepLayerOpenProps(id, isOpen) {
|
|
796
|
-
const isOpenRef = useRef(isOpen);
|
|
797
|
-
isOpenRef.current = isOpen;
|
|
798
797
|
return useMemo(() => ({
|
|
799
798
|
onPointerDown: event => {
|
|
800
|
-
|
|
799
|
+
const control = event.currentTarget;
|
|
800
|
+
const doc = control.ownerDocument;
|
|
801
|
+
// The runtime shows the layer before its open state commits. The
|
|
802
|
+
// layer renders in the control's own tree, a shadow root included.
|
|
803
|
+
const root = control.getRootNode();
|
|
804
|
+
const layer = (isShadowRoot(root) ? root : doc).getElementById(id);
|
|
805
|
+
if (!isOpen && (layer == null || !isShownAsPopover(layer))) {
|
|
801
806
|
return;
|
|
802
807
|
}
|
|
803
808
|
// The browser reads the invoker relationship at both ends of the press.
|
|
804
|
-
const control = event.currentTarget;
|
|
805
|
-
const doc = control.ownerDocument;
|
|
806
809
|
control.setAttribute('popovertarget', id);
|
|
807
810
|
const onPressEnd = () => {
|
|
808
811
|
doc.removeEventListener('pointerup', onPressEnd);
|
|
@@ -823,7 +826,7 @@ export function useKeepLayerOpenProps(id, isOpen) {
|
|
|
823
826
|
control.removeAttribute('popovertarget');
|
|
824
827
|
}
|
|
825
828
|
}
|
|
826
|
-
}), [id]);
|
|
829
|
+
}), [id, isOpen]);
|
|
827
830
|
}
|
|
828
831
|
|
|
829
832
|
/**
|
|
@@ -852,8 +855,8 @@ function useLayerImplementation(options) {
|
|
|
852
855
|
const keepsAnchorClear = mode === 'context' ? options.keepsAnchorClear ?? false : false;
|
|
853
856
|
const watchesOutsidePans = mode === 'context' ? options.watchesOutsidePans : undefined;
|
|
854
857
|
const writesEntranceSide = mode === 'context' ? options.writesEntranceSide ?? false : false;
|
|
855
|
-
const
|
|
856
|
-
onCloseStartRef
|
|
858
|
+
const onCloseStart = mode === 'context' ? options.onCloseStart : undefined;
|
|
859
|
+
const onCloseStartRef = useCommittedRef(onCloseStart);
|
|
857
860
|
const id = useId();
|
|
858
861
|
const anchorId = `--astryx-layer-${id.replace(/:/g, '')}`;
|
|
859
862
|
const [isOpen, setIsOpen] = useState(false);
|
|
@@ -1332,12 +1335,12 @@ function useLayerImplementation(options) {
|
|
|
1332
1335
|
}
|
|
1333
1336
|
releaseAnchor(popoverRef.current);
|
|
1334
1337
|
clearContextMount();
|
|
1335
|
-
}, [onHide, clearContextMount, releaseAnchor, cancelPendingAnchorWait, stopOutsidePanWatch]);
|
|
1338
|
+
}, [onHide, clearContextMount, releaseAnchor, cancelPendingAnchorWait, stopOutsidePanWatch, onCloseStartRef]);
|
|
1336
1339
|
|
|
1337
1340
|
// A deferred show() replays through a ref so the queued closure reaches the
|
|
1338
1341
|
// current callback rather than the one captured when it was queued.
|
|
1339
1342
|
const showRef = useRef(show);
|
|
1340
|
-
showRef
|
|
1343
|
+
useCommittedRefInto(showRef, show);
|
|
1341
1344
|
|
|
1342
1345
|
// The open-state geometry observers of a layer that keeps its anchor clear
|
|
1343
1346
|
// (`observeAnchorClearance`), as their teardown. The open-state layout
|
|
@@ -1531,7 +1534,7 @@ function useLayerImplementation(options) {
|
|
|
1531
1534
|
exitRef.current = null;
|
|
1532
1535
|
removeAnchorName(trigger, anchorId);
|
|
1533
1536
|
}
|
|
1534
|
-
}, [anchorId]);
|
|
1537
|
+
}, [anchorId, onCloseStartRef]);
|
|
1535
1538
|
const handleToggle = useCallback(e => {
|
|
1536
1539
|
const toggleEvent = e;
|
|
1537
1540
|
if (toggleEvent.newState === 'closed' && isOpenRef.current) {
|
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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AAC,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;IAExC;;;;;;;;OAQG;IACH,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAErD;;;OAGG;IACH,IAAI,CAAC,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","s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,0EAA0E;AAC1E,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;IAErC,mEAAmE;IACnE,KAAK,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC;CACvB;AAED,8CAA8C;AAC9C,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
|