@astryxdesign/core 0.7.7-canary.4a8a76e → 0.7.7-canary.4e495ec
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/useCloseMobileDrawerOnActivate.d.ts +13 -0
- package/dist/AppShell/useCloseMobileDrawerOnActivate.d.ts.map +1 -0
- package/dist/AppShell/useCloseMobileDrawerOnActivate.js +45 -0
- package/dist/BottomSheet/BottomSheet.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheet.js +79 -9
- package/dist/BottomSheet/BottomSheetPanel.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheetPanel.js +1 -1
- package/dist/BottomSheet/bottomSheetStack.d.ts.map +1 -1
- package/dist/BottomSheet/bottomSheetStack.js +5 -4
- package/dist/Breadcrumbs/BreadcrumbItem.d.ts +2 -1
- package/dist/Breadcrumbs/BreadcrumbItem.d.ts.map +1 -1
- package/dist/Breadcrumbs/BreadcrumbItem.js +7 -3
- package/dist/CheckboxList/CheckboxList.d.ts.map +1 -1
- package/dist/CheckboxList/CheckboxList.js +7 -1
- package/dist/CheckboxList/CheckboxListContext.d.ts +6 -0
- package/dist/CheckboxList/CheckboxListContext.d.ts.map +1 -1
- package/dist/CheckboxList/CheckboxListItem.d.ts.map +1 -1
- package/dist/CheckboxList/CheckboxListItem.js +10 -2
- package/dist/DateInput/DateInput.d.ts.map +1 -1
- package/dist/DateInput/DateInput.js +5 -2
- package/dist/DateTimeInput/DateTimeInput.d.ts.map +1 -1
- package/dist/DateTimeInput/DateTimeInput.js +5 -2
- package/dist/Dialog/Dialog.d.ts.map +1 -1
- package/dist/Dialog/Dialog.js +16 -14
- package/dist/Drawer/Drawer.d.ts.map +1 -1
- package/dist/Drawer/Drawer.js +15 -11
- package/dist/Drawer/useDrawerDialogPresence.d.ts.map +1 -1
- package/dist/Drawer/useDrawerDialogPresence.js +5 -1
- package/dist/Field/PanelSearchInput.d.ts +9 -1
- package/dist/Field/PanelSearchInput.d.ts.map +1 -1
- package/dist/Field/PanelSearchInput.js +3 -1
- package/dist/InfoTip/InfoTip.d.ts +2 -2
- package/dist/InfoTip/InfoTip.js +4 -4
- package/dist/Layer/layerAnimations.stylex.d.ts +7 -8
- package/dist/Layer/layerAnimations.stylex.d.ts.map +1 -1
- package/dist/Layer/layerAnimations.stylex.js +25 -20
- package/dist/Layer/useBackdropPress.d.ts +27 -0
- package/dist/Layer/useBackdropPress.d.ts.map +1 -0
- package/dist/Layer/useBackdropPress.js +53 -0
- package/dist/Layer/usePressPin.d.ts +3 -5
- package/dist/Layer/usePressPin.d.ts.map +1 -1
- package/dist/Layer/usePressPin.js +4 -6
- package/dist/MobileNav/MobileNav.js +0 -1
- package/dist/MultiSelector/hooks.d.ts.map +1 -1
- package/dist/MultiSelector/hooks.js +2 -4
- package/dist/Outline/Outline.d.ts +2 -4
- package/dist/Outline/Outline.d.ts.map +1 -1
- package/dist/Outline/Outline.js +4 -52
- package/dist/Outline/useOutlineFromMarkdown.d.ts.map +1 -1
- package/dist/Outline/useOutlineFromMarkdown.js +1 -0
- package/dist/Outline/useScrollSpy.js +3 -3
- package/dist/PowerSearch/PowerSearch.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearch.js +134 -179
- package/dist/RadioList/RadioList.d.ts.map +1 -1
- package/dist/RadioList/RadioList.js +5 -0
- package/dist/Resizable/ResizeHandle.d.ts.map +1 -1
- package/dist/Resizable/ResizeHandle.js +118 -260
- package/dist/Resizable/resizeGesture.d.ts +91 -0
- package/dist/Resizable/resizeGesture.d.ts.map +1 -0
- package/dist/Resizable/resizeGesture.js +251 -0
- package/dist/SegmentedControl/SegmentedControl.d.ts +3 -1
- package/dist/SegmentedControl/SegmentedControl.d.ts.map +1 -1
- package/dist/SegmentedControl/SegmentedControl.js +115 -8
- package/dist/SegmentedControl/SegmentedControlContext.d.ts +6 -0
- package/dist/SegmentedControl/SegmentedControlContext.d.ts.map +1 -1
- package/dist/SegmentedControl/SegmentedControlItem.d.ts +1 -0
- package/dist/SegmentedControl/SegmentedControlItem.d.ts.map +1 -1
- package/dist/SegmentedControl/SegmentedControlItem.js +8 -1
- package/dist/SegmentedControl/useSegmentedSelectionMotion.d.ts +357 -0
- package/dist/SegmentedControl/useSegmentedSelectionMotion.d.ts.map +1 -0
- package/dist/SegmentedControl/useSegmentedSelectionMotion.js +1349 -0
- package/dist/SegmentedControl/useSegmentedTouchTracking.d.ts +70 -0
- package/dist/SegmentedControl/useSegmentedTouchTracking.d.ts.map +1 -0
- package/dist/SegmentedControl/useSegmentedTouchTracking.js +264 -0
- package/dist/Selector/Selector.d.ts.map +1 -1
- package/dist/Selector/Selector.js +96 -67
- package/dist/Selector/optionShape.d.ts +24 -0
- package/dist/Selector/optionShape.d.ts.map +1 -0
- package/dist/Selector/optionShape.js +48 -0
- package/dist/Selector/selectableOptionEntries.d.ts +20 -0
- package/dist/Selector/selectableOptionEntries.d.ts.map +1 -0
- package/dist/Selector/selectableOptionEntries.js +38 -0
- package/dist/Selector/utils.d.ts +2 -17
- package/dist/Selector/utils.d.ts.map +1 -1
- package/dist/Selector/utils.js +3 -51
- package/dist/SideNav/SideNavItem.d.ts.map +1 -1
- package/dist/SideNav/SideNavItem.js +3 -9
- package/dist/Switch/switchTouch.d.ts +0 -7
- package/dist/Switch/switchTouch.d.ts.map +1 -1
- package/dist/Switch/switchTouch.js +2 -10
- package/dist/Switch/useSwitchTouch.d.ts +2 -11
- package/dist/Switch/useSwitchTouch.d.ts.map +1 -1
- package/dist/Switch/useSwitchTouch.js +26 -85
- package/dist/Token/Token.d.ts +2 -2
- package/dist/Token/Token.d.ts.map +1 -1
- package/dist/Token/Token.js +12 -4
- package/dist/Token/TokenNamingContext.d.ts +14 -0
- package/dist/Token/TokenNamingContext.d.ts.map +1 -0
- package/dist/Token/TokenNamingContext.js +23 -0
- package/dist/Tokenizer/Tokenizer.d.ts +46 -59
- package/dist/Tokenizer/Tokenizer.d.ts.map +1 -1
- package/dist/Tokenizer/Tokenizer.js +35 -58
- package/dist/Tokenizer/TokenizerBottomSheet.d.ts +25 -28
- package/dist/Tokenizer/TokenizerBottomSheet.d.ts.map +1 -1
- package/dist/Tokenizer/TokenizerBottomSheet.js +157 -54
- package/dist/Tokenizer/TokenizerItemRemovableContext.d.ts.map +1 -1
- package/dist/Tokenizer/TokenizerItemRemovableContext.js +5 -3
- package/dist/Tooltip/Tooltip.d.ts +25 -30
- package/dist/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/Tooltip/Tooltip.js +24 -5
- package/dist/Tooltip/index.d.ts +1 -1
- package/dist/Tooltip/index.d.ts.map +1 -1
- package/dist/Tooltip/useTooltip.d.ts +28 -29
- package/dist/Tooltip/useTooltip.d.ts.map +1 -1
- package/dist/Tooltip/useTooltip.js +20 -8
- package/dist/TopNav/TopNavItem.d.ts.map +1 -1
- package/dist/TopNav/TopNavItem.js +4 -7
- package/dist/TopNav/TopNavMegaMenuItem.d.ts.map +1 -1
- package/dist/TopNav/TopNavMegaMenuItem.js +4 -7
- package/dist/TopNav/TopNavMenu.d.ts.map +1 -1
- package/dist/TopNav/TopNavMenu.js +4 -7
- package/dist/astryx.css +76 -5
- package/dist/gestures/GestureHost.d.ts.map +1 -1
- package/dist/gestures/GestureHost.js +53 -5
- package/dist/hooks/actionGroupTracker.d.ts +3 -3
- package/dist/hooks/actionGroupTracker.d.ts.map +1 -1
- package/dist/hooks/actionGroupTracker.js +6 -53
- package/dist/hooks/useHighlightedOptionScroll.d.ts +11 -1
- package/dist/hooks/useHighlightedOptionScroll.d.ts.map +1 -1
- package/dist/hooks/useHighlightedOptionScroll.js +112 -11
- package/dist/hooks/useMediaQuery.d.ts +2 -1
- package/dist/hooks/useMediaQuery.d.ts.map +1 -1
- package/dist/hooks/useMediaQuery.js +7 -4
- package/dist/hooks/useMenuPress.d.ts.map +1 -1
- package/dist/hooks/useMenuPress.js +4 -2
- package/dist/i18n/generated-english/PowerSearch/PowerSearch.generated.d.ts.map +1 -1
- package/dist/i18n/generated-english/PowerSearch/PowerSearch.generated.js +1 -0
- package/dist/i18n/generated-english/Tokenizer/TokenizerBottomSheet.generated.d.ts.map +1 -1
- package/dist/i18n/generated-english/Tokenizer/TokenizerBottomSheet.generated.js +7 -1
- package/dist/i18n/generated-locales/en.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/en.generated.js +1 -0
- package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/pseudo.generated.js +1 -0
- package/dist/internal/SheetConfirmation.d.ts +11 -0
- package/dist/internal/SheetConfirmation.d.ts.map +1 -0
- package/dist/internal/SheetConfirmation.js +92 -0
- package/dist/internal/sheetDraft.d.ts +35 -0
- package/dist/internal/sheetDraft.d.ts.map +1 -0
- package/dist/internal/sheetDraft.js +65 -0
- package/dist/internal/touch-sheet.d.ts +21 -0
- package/dist/internal/touch-sheet.d.ts.map +1 -0
- package/dist/internal/touch-sheet.js +19 -0
- package/dist/internal/useDismissSearchOnTouchDrag.d.ts +24 -0
- package/dist/internal/useDismissSearchOnTouchDrag.d.ts.map +1 -0
- package/dist/internal/useDismissSearchOnTouchDrag.js +56 -0
- package/dist/motion/roles.d.ts +7 -1
- package/dist/motion/roles.d.ts.map +1 -1
- package/dist/motion/roles.js +20 -1
- package/dist/motion/uikit/index.d.ts +6 -5
- package/dist/motion/uikit/index.d.ts.map +1 -1
- package/dist/motion/uikit/index.js +6 -5
- package/dist/motion/uikit/segmented.d.ts +55 -0
- package/dist/motion/uikit/segmented.d.ts.map +1 -0
- package/dist/motion/uikit/segmented.js +77 -0
- package/dist/motion/uikit/springs.d.ts +0 -18
- package/dist/motion/uikit/springs.d.ts.map +1 -1
- package/dist/motion/uikit/springs.js +5 -21
- package/dist/privateAttributes/segmentTitle.stylex.d.ts +5 -0
- package/dist/privateAttributes/segmentTitle.stylex.d.ts.map +1 -0
- package/dist/privateAttributes/segmentTitle.stylex.js +22 -0
- package/dist/utils/browserClickWait.d.ts +35 -0
- package/dist/utils/browserClickWait.d.ts.map +1 -0
- package/dist/utils/browserClickWait.js +123 -0
- package/dist/utils/clickGuard.d.ts +8 -1
- package/dist/utils/clickGuard.d.ts.map +1 -1
- package/dist/utils/clickGuard.js +24 -1
- package/locales/en.json +4 -0
- package/locales/pseudo.json +3 -0
- package/package.json +8 -8
- package/src/AppShell/useCloseMobileDrawerOnActivate.ts +52 -0
- package/src/BottomSheet/BottomSheet.tsx +95 -10
- package/src/BottomSheet/BottomSheetPanel.tsx +7 -2
- package/src/BottomSheet/bottomSheetStack.ts +8 -4
- package/src/Breadcrumbs/BreadcrumbItem.tsx +13 -3
- package/src/CheckboxList/CheckboxList.doc.mjs +4 -2
- package/src/CheckboxList/CheckboxList.tsx +6 -0
- package/src/CheckboxList/CheckboxListContext.tsx +6 -0
- package/src/CheckboxList/CheckboxListItem.tsx +11 -2
- package/src/DateInput/DateInput.tsx +8 -2
- package/src/DateTimeInput/DateTimeInput.tsx +8 -2
- package/src/Dialog/Dialog.tsx +44 -14
- package/src/Drawer/Drawer.tsx +28 -11
- package/src/Drawer/useDrawerDialogPresence.ts +5 -1
- package/src/Field/PanelSearchInput.tsx +11 -0
- package/src/InfoTip/InfoTip.doc.mjs +3 -3
- package/src/InfoTip/InfoTip.tsx +5 -5
- package/src/Layer/layerAnimations.stylex.ts +24 -16
- package/src/Layer/useBackdropPress.ts +81 -0
- package/src/Layer/usePressPin.ts +5 -11
- package/src/MobileNav/MobileNav.tsx +1 -1
- package/src/MultiSelector/hooks.ts +2 -4
- package/src/Outline/Outline.doc.mjs +177 -51
- package/src/Outline/Outline.tsx +5 -57
- package/src/Outline/useOutlineFromMarkdown.doc.mjs +157 -0
- package/src/Outline/useOutlineFromMarkdown.ts +1 -0
- package/src/Outline/useScrollSpy.ts +3 -3
- package/src/PowerSearch/PowerSearch.doc.mjs +3 -3
- package/src/PowerSearch/PowerSearch.tsx +196 -183
- package/src/RadioList/RadioList.doc.mjs +4 -2
- package/src/RadioList/RadioList.tsx +4 -0
- package/src/Resizable/ResizeHandle.tsx +133 -328
- package/src/Resizable/resizeGesture.ts +368 -0
- package/src/SegmentedControl/SegmentedControl.doc.mjs +3 -3
- package/src/SegmentedControl/SegmentedControl.tsx +179 -5
- package/src/SegmentedControl/SegmentedControlContext.ts +6 -0
- package/src/SegmentedControl/SegmentedControlItem.tsx +12 -1
- package/src/SegmentedControl/useSegmentedSelectionMotion.ts +1637 -0
- package/src/SegmentedControl/useSegmentedTouchTracking.ts +308 -0
- package/src/Selector/Selector.tsx +136 -89
- package/src/Selector/optionShape.ts +64 -0
- package/src/Selector/selectableOptionEntries.ts +39 -0
- package/src/Selector/utils.ts +9 -68
- package/src/SideNav/SideNavItem.tsx +3 -7
- package/src/Switch/switchTouch.ts +2 -10
- package/src/Switch/useSwitchTouch.ts +26 -96
- package/src/Token/Token.tsx +13 -4
- package/src/Token/TokenNamingContext.ts +28 -0
- package/src/Tokenizer/Tokenizer.doc.mjs +16 -0
- package/src/Tokenizer/Tokenizer.tsx +81 -86
- package/src/Tokenizer/TokenizerBottomSheet.tsx +219 -93
- package/src/Tokenizer/TokenizerItemRemovableContext.ts +5 -3
- package/src/Tooltip/Tooltip.doc.mjs +123 -54
- package/src/Tooltip/Tooltip.tsx +36 -39
- package/src/Tooltip/index.ts +0 -1
- package/src/Tooltip/useTooltip.doc.mjs +147 -33
- package/src/Tooltip/useTooltip.tsx +39 -32
- package/src/TopNav/TopNavItem.tsx +6 -5
- package/src/TopNav/TopNavMegaMenuItem.tsx +6 -5
- package/src/TopNav/TopNavMenu.tsx +6 -5
- package/src/gestures/GestureHost.ts +73 -4
- package/src/hooks/actionGroupTracker.ts +12 -56
- package/src/hooks/useHighlightedOptionScroll.ts +123 -15
- package/src/hooks/useMediaQuery.doc.mjs +2 -2
- package/src/hooks/useMediaQuery.ts +13 -4
- package/src/hooks/useMenuPress.ts +8 -2
- package/src/i18n/generated-english/PowerSearch/PowerSearch.generated.ts +1 -0
- package/src/i18n/generated-english/Tokenizer/TokenizerBottomSheet.generated.ts +7 -1
- package/src/i18n/generated-locales/en.generated.ts +1 -0
- package/src/i18n/generated-locales/pseudo.generated.ts +1 -0
- package/src/internal/SheetConfirmation.tsx +101 -0
- package/src/internal/sheetDraft.ts +80 -0
- package/src/internal/touch-sheet.ts +21 -0
- package/src/internal/useDismissSearchOnTouchDrag.ts +69 -0
- package/src/motion/MEASUREMENTS.md +7 -0
- package/src/motion/README.md +1 -0
- package/src/motion/roles.ts +20 -1
- package/src/motion/uikit/index.ts +5 -5
- package/src/motion/uikit/segmented.ts +74 -0
- package/src/motion/uikit/springs.ts +5 -21
- package/src/privateAttributes/segmentTitle.stylex.ts +22 -0
- package/src/utils/browserClickWait.ts +133 -0
- package/src/utils/clickGuard.ts +37 -1
- package/dist/internal/tokenizer-presentation.d.ts +0 -21
- package/dist/internal/tokenizer-presentation.d.ts.map +0 -1
- package/dist/internal/tokenizer-presentation.js +0 -21
- package/src/internal/tokenizer-presentation.ts +0 -25
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectableOptionEntries.d.ts","sourceRoot":"","sources":["../../src/Selector/selectableOptionEntries.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAC,kBAAkB,EAAE,kBAAkB,EAAC,MAAM,SAAS,CAAC;AAGpE,6DAA6D;AAC7D,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,kBAAkB,CAAC;IAC7C,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAC;CACnC;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,kBAAkB,EAAE,GAC5B,qBAAqB,EAAE,CAYzB"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file selectableOptionEntries.ts
|
|
5
|
+
* @input Selector options, with sections and dividers
|
|
6
|
+
* @output `getSelectableOptionEntries`: each selectable item with the option
|
|
7
|
+
* it was given as
|
|
8
|
+
* @position Internal; the one walk behind utils.ts's `getSelectableOptions`
|
|
9
|
+
* and Selector's rows
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { isOptionData, isSection, normalizeOption } from "./optionShape.js";
|
|
13
|
+
|
|
14
|
+
/** A selectable option as given, and its normalized data. */
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Every selectable option (sections flattened, dividers skipped), each with
|
|
18
|
+
* the option it was given as.
|
|
19
|
+
*/
|
|
20
|
+
export function getSelectableOptionEntries(options) {
|
|
21
|
+
const result = [];
|
|
22
|
+
for (const option of options) {
|
|
23
|
+
if (isOptionData(option)) {
|
|
24
|
+
result.push({
|
|
25
|
+
source: option,
|
|
26
|
+
item: normalizeOption(option)
|
|
27
|
+
});
|
|
28
|
+
} else if (isSection(option)) {
|
|
29
|
+
for (const opt of option.options) {
|
|
30
|
+
result.push({
|
|
31
|
+
source: opt,
|
|
32
|
+
item: normalizeOption(opt)
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
}
|
package/dist/Selector/utils.d.ts
CHANGED
|
@@ -3,23 +3,8 @@
|
|
|
3
3
|
* @output Utility functions for Selector
|
|
4
4
|
* @position Utilities; used by Selector.tsx
|
|
5
5
|
*/
|
|
6
|
-
import type { SelectorOptionType, SelectorOptionData
|
|
7
|
-
|
|
8
|
-
* Type guard: check if option is a selectable option (string or OptionData)
|
|
9
|
-
*/
|
|
10
|
-
export declare function isOptionData(option: SelectorOptionType): option is SelectorOptionData | string;
|
|
11
|
-
/**
|
|
12
|
-
* Type guard: check if option is a divider
|
|
13
|
-
*/
|
|
14
|
-
export declare function isDivider(option: SelectorOptionType): option is SelectorDivider;
|
|
15
|
-
/**
|
|
16
|
-
* Type guard: check if option is a section
|
|
17
|
-
*/
|
|
18
|
-
export declare function isSection(option: SelectorOptionType): option is SelectorSection;
|
|
19
|
-
/**
|
|
20
|
-
* Normalize string or option to consistent shape
|
|
21
|
-
*/
|
|
22
|
-
export declare function normalizeOption(option: string | SelectorOptionData): SelectorOptionData;
|
|
6
|
+
import type { SelectorOptionType, SelectorOptionData } from './types.js';
|
|
7
|
+
export { isOptionData, isDivider, isSection, normalizeOption, } from './optionShape.js';
|
|
23
8
|
/**
|
|
24
9
|
* Get all selectable options (flattening sections)
|
|
25
10
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/Selector/utils.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/Selector/utils.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AAEH,OAAO,KAAK,EAAC,kBAAkB,EAAE,kBAAkB,EAAC,MAAM,SAAS,CAAC;AAGpE,OAAO,EACL,YAAY,EACZ,SAAS,EACT,SAAS,EACT,eAAe,GAChB,MAAM,eAAe,CAAC;AAEvB;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,kBAAkB,EAAE,GAC5B,kBAAkB,EAAE,CAEtB"}
|
package/dist/Selector/utils.js
CHANGED
|
@@ -6,60 +6,12 @@
|
|
|
6
6
|
* @position Utilities; used by Selector.tsx
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*/
|
|
12
|
-
export function isOptionData(option) {
|
|
13
|
-
if (typeof option === 'string') {
|
|
14
|
-
return true;
|
|
15
|
-
}
|
|
16
|
-
return !('type' in option);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Type guard: check if option is a divider
|
|
21
|
-
*/
|
|
22
|
-
export function isDivider(option) {
|
|
23
|
-
return typeof option === 'object' && 'type' in option && option.type === 'divider';
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Type guard: check if option is a section
|
|
28
|
-
*/
|
|
29
|
-
export function isSection(option) {
|
|
30
|
-
return typeof option === 'object' && 'type' in option && option.type === 'section';
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Normalize string or option to consistent shape
|
|
35
|
-
*/
|
|
36
|
-
export function normalizeOption(option) {
|
|
37
|
-
if (typeof option === 'string') {
|
|
38
|
-
return {
|
|
39
|
-
value: option,
|
|
40
|
-
label: option
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
return {
|
|
44
|
-
...option,
|
|
45
|
-
label: option.label ?? option.value
|
|
46
|
-
};
|
|
47
|
-
}
|
|
9
|
+
import { getSelectableOptionEntries } from "./selectableOptionEntries.js";
|
|
10
|
+
export { isOptionData, isDivider, isSection, normalizeOption } from "./optionShape.js";
|
|
48
11
|
|
|
49
12
|
/**
|
|
50
13
|
* Get all selectable options (flattening sections)
|
|
51
14
|
*/
|
|
52
15
|
export function getSelectableOptions(options) {
|
|
53
|
-
|
|
54
|
-
for (const option of options) {
|
|
55
|
-
if (isOptionData(option)) {
|
|
56
|
-
result.push(normalizeOption(option));
|
|
57
|
-
} else if (isSection(option)) {
|
|
58
|
-
for (const opt of option.options) {
|
|
59
|
-
result.push(normalizeOption(opt));
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
// Skip dividers
|
|
63
|
-
}
|
|
64
|
-
return result;
|
|
16
|
+
return getSelectableOptionEntries(options).map(entry => entry.item);
|
|
65
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SideNavItem.d.ts","sourceRoot":"","sources":["../../src/SideNav/SideNavItem.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAOL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAYf,OAAO,EAAuB,KAAK,QAAQ,EAAC,MAAM,SAAS,CAAC;AAE5D,OAA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,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;IACxC;;;;OAIG;IACH,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;;;;;;;;OAUG;IACH,WAAW,CAAC,EACR,OAAO,GACP;QACE,kBAAkB,CAAC,EAAE,OAAO,CAAC;QAC7B,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,iBAAiB,CAAC,EAAE,CAAC,WAAW,EAAE,OAAO,KAAK,IAAI,CAAC;KACpD,CAAC;IACN;;;OAGG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,WAAW,CAAC,EAC1B,EAAE,EACF,KAAK,EACL,IAAI,EACJ,YAAY,EACZ,UAAkB,EAClB,UAAkB,EAClB,IAAI,EACJ,OAAO,EACP,UAAU,EACV,OAAO,EACP,QAAQ,EACR,WAAW,EAAE,eAAe,EAC5B,IAAW,EACX,aAAa,EAAE,MAAM,EACrB,GAAG,EACH,MAAM,EACN,GAAG,IAAI,EACR,EAAE,gBAAgB,sCA4clB;yBA9de,WAAW"}
|
|
@@ -50,7 +50,7 @@ import { interactionOverlayStyles } from "../utils/interactionOverlay.stylex.js"
|
|
|
50
50
|
import { usePressFeedback } from "../hooks/usePressFeedback.js";
|
|
51
51
|
import { useSideNavCollapse, SideNavCollapseContext } from "./SideNavCollapseContext.js";
|
|
52
52
|
import { useSideNavRenderMode } from "./SideNavRenderContext.js";
|
|
53
|
-
import {
|
|
53
|
+
import { useCloseMobileDrawerOnActivate } from "../AppShell/useCloseMobileDrawerOnActivate.js";
|
|
54
54
|
import { themeProps } from "../utils/themeProps.js";
|
|
55
55
|
import { disabledInteractionProps } from "../utils/disabledInteraction.js";
|
|
56
56
|
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
@@ -319,10 +319,8 @@ export function SideNavItem({
|
|
|
319
319
|
isCollapsed
|
|
320
320
|
} = useSideNavCollapse();
|
|
321
321
|
const renderMode = useSideNavRenderMode();
|
|
322
|
-
const {
|
|
323
|
-
closeMobileNav
|
|
324
|
-
} = useAppShellMobile();
|
|
325
322
|
const isInDrawer = renderMode === 'drawer' || renderMode === 'drawer-content';
|
|
323
|
+
const closeDrawerAfter = useCloseMobileDrawerOnActivate(isInDrawer);
|
|
326
324
|
const id = useId();
|
|
327
325
|
const hasChildren = !!children;
|
|
328
326
|
const depth = use(SideNavItemDepthContext);
|
|
@@ -396,11 +394,7 @@ export function SideNavItem({
|
|
|
396
394
|
toggleItemCollapse();
|
|
397
395
|
return;
|
|
398
396
|
}
|
|
399
|
-
onClick?.(e);
|
|
400
|
-
// Close the mobile nav when a nav item is activated inside the drawer
|
|
401
|
-
if (isInDrawer) {
|
|
402
|
-
closeMobileNav();
|
|
403
|
-
}
|
|
397
|
+
closeDrawerAfter(onClick)?.(e);
|
|
404
398
|
};
|
|
405
399
|
const handleToggleClick = e => {
|
|
406
400
|
e.preventDefault();
|
|
@@ -57,13 +57,6 @@ export declare function startFlip(isOn: boolean): SwitchFlip;
|
|
|
57
57
|
* landed along the writing direction (positive toward the on end).
|
|
58
58
|
*/
|
|
59
59
|
export declare function stepFlip(flip: SwitchFlip, translation: number, geometry: SwitchTouchGeometry): SwitchFlip;
|
|
60
|
-
/**
|
|
61
|
-
* Passive: how long a lift waits for the browser's own click before the
|
|
62
|
-
* switch clicks its input itself, ms. The browser sends that click with the
|
|
63
|
-
* lift's `touchend`. The surface's `touch-action` leaves no double-tap delay.
|
|
64
|
-
* So this only runs out for a lift the browser does not count as a click.
|
|
65
|
-
*/
|
|
66
|
-
export declare const BROWSER_CLICK_WAIT_MS = 300;
|
|
67
60
|
/**
|
|
68
61
|
* What a release commits: the side a drag flipped to; when nothing flipped,
|
|
69
62
|
* the other side of the value, wherever the finger lifts. A press slid off
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switchTouch.d.ts","sourceRoot":"","sources":["../../src/Switch/switchTouch.ts"],"names":[],"mappings":"AAmBA,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,6BAA6B;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,4EAA4E;IAC5E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,6CAA6C;IAC7C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B;;;;;OAKG;IACH,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACrC,sEAAsE;IACtE,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;CAC/B;AAMD;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,KAAK,CAAC,EAAE;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAC,GACxD,mBAAmB,CAoCrB;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,mBAAmB,GAC5B,MAAM,CAOR;AAED,mEAAmE;AACnE,MAAM,WAAW,UAAU;IACzB,wCAAwC;IACxC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,8EAA8E;IAC9E,QAAQ,CAAC,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AK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,mBAAmB,GAC5B,MAAM,CAOR;AAED,mEAAmE;AACnE,MAAM,WAAW,UAAU;IACzB,wCAAwC;IACxC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,8EAA8E;IAC9E,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,0CAA0C;IAC1C,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,UAAU,CAEnD;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CACtB,IAAI,EAAE,UAAU,EAChB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,mBAAmB,GAC5B,UAAU,CAkBZ;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,UAAU,GAAG,IAAI,EACvB,IAAI,EAAE,OAAO,GACZ,OAAO,CAET;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CACxB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,EAChB,aAAa,GAAE,MAAoC,GAClD,MAAM,CAER"}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* @file switchTouch.ts
|
|
5
5
|
* @input The UIKit switch constants (motion/uikit/switch.ts) and a track size
|
|
6
6
|
* @output The pure model of Switch's touch presentation: thumb geometry, the
|
|
7
|
-
* drag's target, the flip rule, the commit on release and
|
|
8
|
-
*
|
|
7
|
+
* drag's target, the flip rule, the commit on release, and when the lifted
|
|
8
|
+
* thumb may settle
|
|
9
9
|
* @position Pure half of Switch's touch presentation; driven by
|
|
10
10
|
* useSwitchTouch.ts, tested by switchTouch.test.ts without a browser
|
|
11
11
|
*
|
|
@@ -104,14 +104,6 @@ export function stepFlip(flip, translation, geometry) {
|
|
|
104
104
|
};
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
/**
|
|
108
|
-
* Passive: how long a lift waits for the browser's own click before the
|
|
109
|
-
* switch clicks its input itself, ms. The browser sends that click with the
|
|
110
|
-
* lift's `touchend`. The surface's `touch-action` leaves no double-tap delay.
|
|
111
|
-
* So this only runs out for a lift the browser does not count as a click.
|
|
112
|
-
*/
|
|
113
|
-
export const BROWSER_CLICK_WAIT_MS = 300;
|
|
114
|
-
|
|
115
107
|
/**
|
|
116
108
|
* What a release commits: the side a drag flipped to; when nothing flipped,
|
|
117
109
|
* the other side of the value, wherever the finger lifts. A press slid off
|
|
@@ -152,11 +152,8 @@ export declare class SwitchTouchController {
|
|
|
152
152
|
private isTracking;
|
|
153
153
|
/** Which presentation the switch has: the touch one, or its own. */
|
|
154
154
|
private presentation;
|
|
155
|
-
/**
|
|
156
|
-
private
|
|
157
|
-
private pressListenersTimer;
|
|
158
|
-
/** Passive: a lift is waiting for the browser's own click. */
|
|
159
|
-
private browserClickTimer;
|
|
155
|
+
/** Passive: a lift is waiting for the browser's own click; this ends it. */
|
|
156
|
+
private endBrowserClickWait;
|
|
160
157
|
private reconcileTimer;
|
|
161
158
|
constructor(isOn: boolean, geometry: SwitchTouchGeometry);
|
|
162
159
|
get isAttached(): boolean;
|
|
@@ -169,12 +166,6 @@ export declare class SwitchTouchController {
|
|
|
169
166
|
* takes for its scroll yields with no toggle.
|
|
170
167
|
*/
|
|
171
168
|
private attachPassive;
|
|
172
|
-
/** Under a fine pointer: adds the switch's own listeners for a press. */
|
|
173
|
-
private listenForPress;
|
|
174
|
-
private startPressListeners;
|
|
175
|
-
/** The press's click window is over: its listeners go. */
|
|
176
|
-
private endPressListeners;
|
|
177
|
-
private stopPressListeners;
|
|
178
169
|
/** Undo everything: listeners, timers, animations and inline styles. */
|
|
179
170
|
detach(): void;
|
|
180
171
|
setInteractive(isInteractive: boolean): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSwitchTouch.d.ts","sourceRoot":"","sources":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AAuE;IACvE,OAAO,CAAC,UAAU;IAKlB;;;;OAIG;IACH,OAAO,CAAC,IAAI;IAmBZ;;;;OAIG;IACH,OAAO,CAAC,MAAM;IAyCd;;;;OAIG;IACH,OAAO,CAAC,YAAY;IAsCpB,OAAO,CAAC,WAAW;CAQpB;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,gBAAgB,EACvB,EACE,IAAI,EACJ,aAAa,EACb,UAAU,EACV,SAAS,EACT,eAAe,GAChB,EAAE,kBAAkB,GACpB,IAAI,CAsDN"}
|
|
@@ -25,8 +25,9 @@ import { solveSpring, toSpring } from "../motion/spring.js";
|
|
|
25
25
|
import { UIKIT_GESTURES } from "../motion/uikit/gestures.js";
|
|
26
26
|
import { registerSwitchTable, switchControl } from "../motion/uikit/switch.js";
|
|
27
27
|
import { useTouchPresentation } from "../utils/touchPresentation.js";
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
28
|
+
import { awaitBrowserClick, clickForLift } from "../utils/browserClickWait.js";
|
|
29
|
+
import { armClickGuard } from "../utils/clickGuard.js";
|
|
30
|
+
import { commitOnRelease, dragTarget, settleTime, startFlip, stepFlip, switchTouchGeometry } from "./switchTouch.js";
|
|
30
31
|
import { readFillOf, sameTrackState, trackStateOf } from "./switchFill.js";
|
|
31
32
|
/** The fade layer's colour, set on the track for its ::after (Switch.tsx). */
|
|
32
33
|
const FADE_FILL = '--_switch-fade-fill';
|
|
@@ -176,11 +177,8 @@ export class SwitchTouchController {
|
|
|
176
177
|
isTracking = false;
|
|
177
178
|
/** Which presentation the switch has: the touch one, or its own. */
|
|
178
179
|
presentation = 'touch';
|
|
179
|
-
/**
|
|
180
|
-
|
|
181
|
-
pressListenersTimer = null;
|
|
182
|
-
/** Passive: a lift is waiting for the browser's own click. */
|
|
183
|
-
browserClickTimer = null;
|
|
180
|
+
/** Passive: a lift is waiting for the browser's own click; this ends it. */
|
|
181
|
+
endBrowserClickWait = null;
|
|
184
182
|
reconcileTimer = null;
|
|
185
183
|
constructor(isOn, geometry) {
|
|
186
184
|
this.isOn = isOn;
|
|
@@ -255,63 +253,7 @@ export class SwitchTouchController {
|
|
|
255
253
|
}
|
|
256
254
|
}
|
|
257
255
|
});
|
|
258
|
-
|
|
259
|
-
// clicks nothing itself.
|
|
260
|
-
const onClick = event => {
|
|
261
|
-
if (event.isTrusted && this.browserClickTimer != null) {
|
|
262
|
-
clearTimeout(this.browserClickTimer);
|
|
263
|
-
this.browserClickTimer = null;
|
|
264
|
-
this.scheduleReconcile();
|
|
265
|
-
}
|
|
266
|
-
};
|
|
267
|
-
const listen = () => {
|
|
268
|
-
surface.addEventListener('click', onClick, true);
|
|
269
|
-
return () => {
|
|
270
|
-
surface.removeEventListener('click', onClick, true);
|
|
271
|
-
};
|
|
272
|
-
};
|
|
273
|
-
if (this.presentation === 'pointer') {
|
|
274
|
-
// Under a fine pointer only the press the host arms listens at rest.
|
|
275
|
-
// The switch's click listener comes with a press and goes after its
|
|
276
|
-
// click wait.
|
|
277
|
-
this.listenForPress = listen;
|
|
278
|
-
return [host.attachConsumer(surface, tracker), () => tracker.dispose(), () => this.stopPressListeners()];
|
|
279
|
-
}
|
|
280
|
-
return [host.attachConsumer(surface, tracker), () => tracker.dispose(), listen()];
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
/** Under a fine pointer: adds the switch's own listeners for a press. */
|
|
284
|
-
listenForPress = null;
|
|
285
|
-
startPressListeners() {
|
|
286
|
-
if (this.pressListenersTimer != null) {
|
|
287
|
-
clearTimeout(this.pressListenersTimer);
|
|
288
|
-
this.pressListenersTimer = null;
|
|
289
|
-
}
|
|
290
|
-
if (this.pressListeners == null && this.listenForPress != null) {
|
|
291
|
-
this.pressListeners = this.listenForPress();
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
/** The press's click window is over: its listeners go. */
|
|
296
|
-
endPressListeners(afterMs) {
|
|
297
|
-
if (this.pressListeners == null) {
|
|
298
|
-
return;
|
|
299
|
-
}
|
|
300
|
-
if (this.pressListenersTimer != null) {
|
|
301
|
-
clearTimeout(this.pressListenersTimer);
|
|
302
|
-
}
|
|
303
|
-
this.pressListenersTimer = setTimeout(() => {
|
|
304
|
-
this.pressListenersTimer = null;
|
|
305
|
-
this.stopPressListeners();
|
|
306
|
-
}, afterMs);
|
|
307
|
-
}
|
|
308
|
-
stopPressListeners() {
|
|
309
|
-
if (this.pressListenersTimer != null) {
|
|
310
|
-
clearTimeout(this.pressListenersTimer);
|
|
311
|
-
this.pressListenersTimer = null;
|
|
312
|
-
}
|
|
313
|
-
this.pressListeners?.();
|
|
314
|
-
this.pressListeners = null;
|
|
256
|
+
return [host.attachConsumer(surface, tracker), () => tracker.dispose()];
|
|
315
257
|
}
|
|
316
258
|
|
|
317
259
|
/** Undo everything: listeners, timers, animations and inline styles. */
|
|
@@ -320,7 +262,6 @@ export class SwitchTouchController {
|
|
|
320
262
|
detach();
|
|
321
263
|
}
|
|
322
264
|
this.detachers = [];
|
|
323
|
-
this.listenForPress = null;
|
|
324
265
|
this.clearTimers();
|
|
325
266
|
for (const animator of [this.thumb, this.fade, this.shadow]) {
|
|
326
267
|
const element = animator?.element;
|
|
@@ -487,7 +428,6 @@ export class SwitchTouchController {
|
|
|
487
428
|
switch (event) {
|
|
488
429
|
case 'touchDown':
|
|
489
430
|
this.isTracking = true;
|
|
490
|
-
this.startPressListeners();
|
|
491
431
|
this.touchDown(time);
|
|
492
432
|
return;
|
|
493
433
|
case 'touchDragInside':
|
|
@@ -523,7 +463,6 @@ export class SwitchTouchController {
|
|
|
523
463
|
byBrowserClick: true,
|
|
524
464
|
clicksIfNoBrowserClick: touch.pointerType === 'touch'
|
|
525
465
|
});
|
|
526
|
-
this.endPressListeners(BROWSER_CLICK_WAIT_MS);
|
|
527
466
|
return;
|
|
528
467
|
}
|
|
529
468
|
if (touch.pointerType !== 'touch' && (event === 'touchUpOutside' || this.drag?.flip.didFlip !== true)) {
|
|
@@ -533,7 +472,6 @@ export class SwitchTouchController {
|
|
|
533
472
|
// off toggles.
|
|
534
473
|
this.released = true;
|
|
535
474
|
this.abandon(time);
|
|
536
|
-
this.endPressListeners(0);
|
|
537
475
|
return;
|
|
538
476
|
}
|
|
539
477
|
// A drag that flipped, or a press slid off and lifted outside, which
|
|
@@ -545,7 +483,6 @@ export class SwitchTouchController {
|
|
|
545
483
|
armClickGuard(this.elements.input.ownerDocument);
|
|
546
484
|
}
|
|
547
485
|
this.release(time);
|
|
548
|
-
this.endPressListeners(0);
|
|
549
486
|
return;
|
|
550
487
|
case 'touchCancel':
|
|
551
488
|
// The browser took the touch for its scroll, or a recognizer above
|
|
@@ -555,7 +492,6 @@ export class SwitchTouchController {
|
|
|
555
492
|
this.released = true;
|
|
556
493
|
this.abandon(time);
|
|
557
494
|
}
|
|
558
|
-
this.endPressListeners(0);
|
|
559
495
|
return;
|
|
560
496
|
case 'touchDragEnter':
|
|
561
497
|
case 'touchDragExit':
|
|
@@ -638,14 +574,23 @@ export class SwitchTouchController {
|
|
|
638
574
|
this.showSide(commit, time, undefined, true);
|
|
639
575
|
}
|
|
640
576
|
this.pressEnded(time, true);
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
577
|
+
const surface = this.elements?.surface;
|
|
578
|
+
if (byBrowserClick && surface != null) {
|
|
579
|
+
// The lift's own click activates the input natively: the switch then
|
|
580
|
+
// clicks nothing itself.
|
|
581
|
+
this.endBrowserClickWait = awaitBrowserClick(surface, {
|
|
582
|
+
onClicked: () => {
|
|
583
|
+
this.endBrowserClickWait = null;
|
|
584
|
+
this.scheduleReconcile();
|
|
585
|
+
},
|
|
586
|
+
onNoClick: () => {
|
|
587
|
+
this.endBrowserClickWait = null;
|
|
588
|
+
if (clicksIfNoBrowserClick && commit !== this.isOn) {
|
|
589
|
+
this.clickInput();
|
|
590
|
+
}
|
|
591
|
+
this.scheduleReconcile();
|
|
646
592
|
}
|
|
647
|
-
|
|
648
|
-
}, BROWSER_CLICK_WAIT_MS);
|
|
593
|
+
});
|
|
649
594
|
return;
|
|
650
595
|
}
|
|
651
596
|
if (commit !== this.isOn) {
|
|
@@ -662,11 +607,9 @@ export class SwitchTouchController {
|
|
|
662
607
|
*/
|
|
663
608
|
clickInput() {
|
|
664
609
|
const input = this.elements?.input;
|
|
665
|
-
if (input
|
|
666
|
-
|
|
610
|
+
if (input != null) {
|
|
611
|
+
clickForLift(input);
|
|
667
612
|
}
|
|
668
|
-
armClickGuard(input.ownerDocument);
|
|
669
|
-
withoutClickGuard(() => input.click());
|
|
670
613
|
}
|
|
671
614
|
|
|
672
615
|
/** If the owner kept the old value, the visuals go back to it. */
|
|
@@ -925,10 +868,8 @@ export class SwitchTouchController {
|
|
|
925
868
|
}
|
|
926
869
|
}
|
|
927
870
|
clearTimers() {
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
this.browserClickTimer = null;
|
|
931
|
-
}
|
|
871
|
+
this.endBrowserClickWait?.();
|
|
872
|
+
this.endBrowserClickWait = null;
|
|
932
873
|
if (this.reconcileTimer != null) {
|
|
933
874
|
clearTimeout(this.reconcileTimer);
|
|
934
875
|
this.reconcileTimer = null;
|
package/dist/Token/Token.d.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* - /apps/storybook/stories/Token.stories.tsx (storybook stories)
|
|
13
13
|
* - /packages/cli/assets/templates/blocks/components/Token/ (showcase blocks)
|
|
14
14
|
*/
|
|
15
|
-
import type
|
|
15
|
+
import { type ReactNode } from 'react';
|
|
16
16
|
import type { BaseProps } from '../BaseProps.js';
|
|
17
17
|
import type { TokenColorMap } from './index.js';
|
|
18
18
|
/**
|
|
@@ -95,7 +95,7 @@ export interface TokenProps extends BaseProps<HTMLElement> {
|
|
|
95
95
|
* <Token label="Link" href="/path" />
|
|
96
96
|
* ```
|
|
97
97
|
*/
|
|
98
|
-
export declare function Token({ label, size, color, icon, isDisabled, onRemove, onClick, href, description, endContent, isLabelHidden, xstyle, className, style, 'data-testid': testId, 'aria-labelledby': ariaLabelledBy, 'aria-describedby': ariaDescribedBy, ref, ...rest }: TokenProps): import("react").JSX.Element;
|
|
98
|
+
export declare function Token({ label, size, color, icon, isDisabled, onRemove, onClick, href, description, endContent, isLabelHidden, xstyle, className, style, 'data-testid': testId, 'aria-labelledby': ariaLabelledBy, 'aria-describedby': ariaDescribedBy, 'aria-haspopup': ariaHasPopup, 'aria-expanded': ariaExpanded, ref, ...rest }: TokenProps): import("react").JSX.Element;
|
|
99
99
|
export declare namespace Token {
|
|
100
100
|
var displayName: string;
|
|
101
101
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Token.d.ts","sourceRoot":"","sources":["../../src/Token/Token.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"Token.d.ts","sourceRoot":"","sources":["../../src/Token/Token.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAM,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AAiB1C,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAK5C,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,SAAS,CAAC;AAe3C;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC;AAE7C,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE3C,MAAM,WAAW,UAAW,SAAQ,SAAS,CAAC,WAAW,CAAC;IACxD,wCAAwC;IACxC,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC7B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;;OAGG;IACH,KAAK,CAAC,EAAE,UAAU,CAAC;IACnB;;OAEG;IACH,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;IACzC;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;IACxC;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AA6JD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,KAAK,CAAC,EACpB,KAAK,EACL,IAAW,EACX,KAAiB,EACjB,IAAI,EACJ,UAAkB,EAClB,QAAQ,EACR,OAAO,EACP,IAAI,EACJ,WAAW,EACX,UAAU,EACV,aAAqB,EACrB,MAAM,EACN,SAAS,EACT,KAAK,EACL,aAAa,EAAE,MAAM,EACrB,iBAAiB,EAAE,cAAc,EACjC,kBAAkB,EAAE,eAAe,EACnC,eAAe,EAAE,YAAY,EAC7B,eAAe,EAAE,YAAY,EAC7B,GAAG,EACH,GAAG,IAAI,EACR,EAAE,UAAU,+BA8QZ;yBApSe,KAAK"}
|
package/dist/Token/Token.js
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
* - /apps/storybook/stories/Token.stories.tsx (storybook stories)
|
|
17
17
|
* - /packages/cli/assets/templates/blocks/components/Token/ (showcase blocks)
|
|
18
18
|
*/
|
|
19
|
+
import { use } from 'react';
|
|
19
20
|
import * as stylex from '@stylexjs/stylex';
|
|
20
21
|
import "../theme/tokens.stylex.js";
|
|
21
22
|
import { colorVars, spacingVars, radiusVars, sizeVars, durationVars, easeVars, fontWeightVars, typeScaleVars } from "../theme/tokens.stylex.js";
|
|
@@ -29,6 +30,7 @@ import { focusOutlineProps } from "../utils/focusOutline.stylex.js";
|
|
|
29
30
|
import { interactionOverlayStyles } from "../utils/interactionOverlay.stylex.js";
|
|
30
31
|
import { usePressFeedback } from "../hooks/usePressFeedback.js";
|
|
31
32
|
import { disabledInteractionProps } from "../utils/disabledInteraction.js";
|
|
33
|
+
import { TokenNamingContext } from "./TokenNamingContext.js";
|
|
32
34
|
import { registerEnglishFallback, useComponentTranslator } from "../i18n/useComponentTranslator.js";
|
|
33
35
|
import english from "../i18n/generated-english/Token/Token.generated.js";
|
|
34
36
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -216,6 +218,8 @@ export function Token({
|
|
|
216
218
|
'data-testid': testId,
|
|
217
219
|
'aria-labelledby': ariaLabelledBy,
|
|
218
220
|
'aria-describedby': ariaDescribedBy,
|
|
221
|
+
'aria-haspopup': ariaHasPopup,
|
|
222
|
+
'aria-expanded': ariaExpanded,
|
|
219
223
|
ref,
|
|
220
224
|
...rest
|
|
221
225
|
}) {
|
|
@@ -230,6 +234,7 @@ export function Token({
|
|
|
230
234
|
onClick,
|
|
231
235
|
isDisabled
|
|
232
236
|
});
|
|
237
|
+
const naming = use(TokenNamingContext);
|
|
233
238
|
|
|
234
239
|
// When role is 'button' via context (no explicit onClick), treat as
|
|
235
240
|
// if onClick was provided — the popover attaches its own handler.
|
|
@@ -237,7 +242,7 @@ export function Token({
|
|
|
237
242
|
const removeButton = onRemove != null && /*#__PURE__*/_jsx("button", {
|
|
238
243
|
type: "button",
|
|
239
244
|
"aria-label": t('@astryx.token.remove', {
|
|
240
|
-
label
|
|
245
|
+
label: naming?.removeName ?? label
|
|
241
246
|
}),
|
|
242
247
|
onClick: e => {
|
|
243
248
|
e.stopPropagation();
|
|
@@ -268,12 +273,14 @@ export function Token({
|
|
|
268
273
|
}), endContent, removeButton]
|
|
269
274
|
});
|
|
270
275
|
|
|
271
|
-
// Naming inputs reach the element that owns the token's action:
|
|
272
|
-
// button of a clickable token, otherwise the root
|
|
276
|
+
// Naming and popup inputs reach the element that owns the token's action:
|
|
277
|
+
// the inner button of a clickable token, otherwise the root
|
|
273
278
|
// (architecture:public-component-api INV5).
|
|
274
279
|
const labellingProps = {
|
|
275
280
|
'aria-labelledby': ariaLabelledBy,
|
|
276
|
-
'aria-describedby': ariaDescribedBy
|
|
281
|
+
'aria-describedby': ariaDescribedBy,
|
|
282
|
+
'aria-haspopup': ariaHasPopup,
|
|
283
|
+
'aria-expanded': ariaExpanded
|
|
277
284
|
};
|
|
278
285
|
const sharedProps = {
|
|
279
286
|
'data-testid': testId,
|
|
@@ -398,6 +405,7 @@ export function Token({
|
|
|
398
405
|
children: [icon, /*#__PURE__*/_jsx("button", {
|
|
399
406
|
type: "button",
|
|
400
407
|
onClick: effectiveOnClick,
|
|
408
|
+
"aria-label": ariaLabelledBy == null ? naming?.actionName : undefined,
|
|
401
409
|
...labellingProps,
|
|
402
410
|
"aria-disabled": isDisabled || undefined,
|
|
403
411
|
...(isDisabled ? disabledInteractionProps() : null),
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Names for a Token whose visible text runs past its label. PowerSearch
|
|
3
|
+
* provides them: its tokens show the value as `endContent`.
|
|
4
|
+
*
|
|
5
|
+
* - `actionName` names a clickable token's inner button in place of `label`.
|
|
6
|
+
* - `removeName` names the remove button in place of `label`. The remove word
|
|
7
|
+
* still comes from the catalog, so each locale keeps its word order.
|
|
8
|
+
*/
|
|
9
|
+
export interface TokenNaming {
|
|
10
|
+
actionName?: string;
|
|
11
|
+
removeName?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const TokenNamingContext: import("react").Context<TokenNaming | null>;
|
|
14
|
+
//# sourceMappingURL=TokenNamingContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TokenNamingContext.d.ts","sourceRoot":"","sources":["../../src/Token/TokenNamingContext.ts"],"names":[],"mappings":"AAaA;;;;;;;GAOG;AACH,MAAM,WAAW,WAAW;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,eAAO,MAAM,kBAAkB,6CAA0C,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @file TokenNamingContext.ts
|
|
7
|
+
* @input Naming parts from a caller whose token value renders outside its label
|
|
8
|
+
* @output Internal context: the names of a token's action and remove button
|
|
9
|
+
* @position Internal to Core; not exported from the Token entry point
|
|
10
|
+
*/
|
|
11
|
+
import { createContext } from 'react';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Names for a Token whose visible text runs past its label. PowerSearch
|
|
15
|
+
* provides them: its tokens show the value as `endContent`.
|
|
16
|
+
*
|
|
17
|
+
* - `actionName` names a clickable token's inner button in place of `label`.
|
|
18
|
+
* - `removeName` names the remove button in place of `label`. The remove word
|
|
19
|
+
* still comes from the catalog, so each locale keeps its word order.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
export const TokenNamingContext = /*#__PURE__*/createContext(null);
|
|
23
|
+
TokenNamingContext.displayName = 'TokenNamingContext';
|