@astryxdesign/core 0.7.7-canary.ae97fa8 → 0.7.7-canary.b377b21
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/AlertDialog/AlertDialog.d.ts +4 -1
- package/dist/AlertDialog/AlertDialog.d.ts.map +1 -1
- package/dist/AlertDialog/AlertDialog.js +36 -6
- package/dist/BottomSheet/BottomSheetPanel.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheetPanel.js +22 -3
- package/dist/BottomSheet/useSheetGestures.d.ts.map +1 -1
- package/dist/BottomSheet/useSheetGestures.js +3 -1
- package/dist/Button/Button.d.ts.map +1 -1
- package/dist/Button/Button.js +17 -1
- package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
- package/dist/CheckboxInput/CheckboxInput.js +13 -2
- package/dist/ComplexSelector/ComplexSelector.d.ts +4 -1
- package/dist/ComplexSelector/ComplexSelector.d.ts.map +1 -1
- package/dist/ComplexSelector/ComplexSelector.js +14 -4
- package/dist/ContextMenu/ContextMenu.js +2 -2
- package/dist/Dialog/Dialog.d.ts.map +1 -1
- package/dist/Dialog/Dialog.js +7 -31
- package/dist/Field/Field.js +2 -2
- package/dist/HoverCard/HoverCard.d.ts +4 -3
- package/dist/HoverCard/HoverCard.d.ts.map +1 -1
- package/dist/HoverCard/useHoverCard.d.ts +5 -4
- package/dist/HoverCard/useHoverCard.d.ts.map +1 -1
- package/dist/HoverCard/useHoverCard.js +17 -31
- package/dist/Icon/Icon.d.ts +5 -1
- package/dist/Icon/Icon.d.ts.map +1 -1
- package/dist/Icon/Icon.js +5 -2
- package/dist/Layer/usePressPin.d.ts +17 -5
- package/dist/Layer/usePressPin.d.ts.map +1 -1
- package/dist/Layer/usePressPin.js +62 -12
- package/dist/Lightbox/Lightbox.d.ts.map +1 -1
- package/dist/Lightbox/Lightbox.js +18 -0
- package/dist/PowerSearch/PowerSearch.d.ts +36 -3
- package/dist/PowerSearch/PowerSearch.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearch.js +433 -127
- package/dist/PowerSearch/PowerSearchBottomSheet.d.ts +100 -0
- package/dist/PowerSearch/PowerSearchBottomSheet.d.ts.map +1 -0
- package/dist/PowerSearch/PowerSearchBottomSheet.js +1913 -0
- package/dist/PowerSearch/PowerSearchEditPopover.d.ts +32 -1
- package/dist/PowerSearch/PowerSearchEditPopover.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearchEditPopover.js +17 -6
- package/dist/PowerSearch/PowerSearchValueEditor.d.ts +38 -3
- package/dist/PowerSearch/PowerSearchValueEditor.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearchValueEditor.js +170 -61
- package/dist/PowerSearch/formatFilterValue.d.ts +7 -0
- package/dist/PowerSearch/formatFilterValue.d.ts.map +1 -1
- package/dist/PowerSearch/formatFilterValue.js +11 -1
- package/dist/PowerSearch/formatTokenValue.d.ts +28 -0
- package/dist/PowerSearch/formatTokenValue.d.ts.map +1 -0
- package/dist/PowerSearch/formatTokenValue.js +160 -0
- package/dist/PowerSearch/powerSearchSheetUtils.d.ts +65 -0
- package/dist/PowerSearch/powerSearchSheetUtils.d.ts.map +1 -0
- package/dist/PowerSearch/powerSearchSheetUtils.js +168 -0
- package/dist/RadioList/RadioList.d.ts.map +1 -1
- package/dist/RadioList/RadioList.js +3 -2
- package/dist/RadioList/RadioListItem.d.ts +1 -1
- package/dist/RadioList/RadioListItem.d.ts.map +1 -1
- package/dist/RadioList/RadioListItem.js +5 -3
- package/dist/Resizable/ResizeHandle.d.ts +2 -1
- package/dist/Resizable/ResizeHandle.d.ts.map +1 -1
- package/dist/Resizable/ResizeHandle.js +99 -77
- package/dist/SegmentedControl/useSegmentedSelectionMotion.d.ts.map +1 -1
- package/dist/SegmentedControl/useSegmentedSelectionMotion.js +3 -3
- package/dist/Slider/sliderTouchController.js +2 -2
- package/dist/Spinner/Spinner.d.ts +1 -1
- package/dist/Spinner/Spinner.d.ts.map +1 -1
- package/dist/Spinner/Spinner.js +60 -58
- package/dist/Switch/useSwitchTouch.js +4 -4
- package/dist/Table/BaseTable.d.ts.map +1 -1
- package/dist/Table/BaseTable.js +29 -8
- package/dist/TextInput/TextInput.d.ts +2 -2
- package/dist/TextInput/TextInput.d.ts.map +1 -1
- package/dist/TextInput/TextInput.js +10 -7
- package/dist/Toast/Toast.d.ts +11 -1
- package/dist/Toast/Toast.d.ts.map +1 -1
- package/dist/Toast/Toast.js +25 -15
- package/dist/Toast/ToastViewport.d.ts.map +1 -1
- package/dist/Toast/ToastViewport.js +94 -34
- package/dist/Toast/types.d.ts +9 -3
- package/dist/Toast/types.d.ts.map +1 -1
- package/dist/Tooltip/useTooltip.d.ts +19 -1
- package/dist/Tooltip/useTooltip.d.ts.map +1 -1
- package/dist/Tooltip/useTooltip.js +34 -53
- package/dist/Typeahead/TypeaheadItem.d.ts +2 -1
- package/dist/Typeahead/TypeaheadItem.d.ts.map +1 -1
- package/dist/animator/createAnimator.d.ts +98 -0
- package/dist/animator/createAnimator.d.ts.map +1 -0
- package/dist/animator/createAnimator.js +259 -0
- package/dist/astryx.css +35 -6
- package/dist/gestures/PressTracker.d.ts.map +1 -1
- package/dist/gestures/PressTracker.js +4 -3
- package/dist/hooks/actionGroupTracker.d.ts +4 -1
- package/dist/hooks/actionGroupTracker.d.ts.map +1 -1
- package/dist/hooks/actionGroupTracker.js +13 -3
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/pressGroupContext.d.ts +6 -0
- package/dist/hooks/pressGroupContext.d.ts.map +1 -0
- package/dist/hooks/pressGroupContext.js +20 -0
- package/dist/hooks/useActionGroupTracking.d.ts +53 -0
- package/dist/hooks/useActionGroupTracking.d.ts.map +1 -0
- package/dist/hooks/useActionGroupTracking.js +174 -0
- package/dist/hooks/useAnimator.d.ts +41 -0
- package/dist/hooks/useAnimator.d.ts.map +1 -0
- package/dist/hooks/useAnimator.js +70 -0
- package/dist/hooks/useAttachment.d.ts +1 -1
- package/dist/hooks/useAttachment.js +1 -1
- package/dist/hooks/useInputStatusIcon.d.ts +1 -1
- package/dist/hooks/useInputStatusIcon.d.ts.map +1 -1
- package/dist/hooks/useInputStatusIcon.js +2 -2
- package/dist/hooks/useLongPress.d.ts +6 -2
- package/dist/hooks/useLongPress.d.ts.map +1 -1
- package/dist/hooks/useLongPress.js +95 -15
- package/dist/i18n/generated-english/PowerSearch/PowerSearchBottomSheet.generated.d.ts +8 -0
- package/dist/i18n/generated-english/PowerSearch/PowerSearchBottomSheet.generated.d.ts.map +1 -0
- package/dist/i18n/generated-english/PowerSearch/PowerSearchBottomSheet.generated.js +42 -0
- package/dist/i18n/generated-english/PowerSearch/PowerSearchValueEditor.generated.d.ts.map +1 -1
- package/dist/i18n/generated-english/PowerSearch/PowerSearchValueEditor.generated.js +6 -0
- package/dist/i18n/generated-english/PowerSearch/formatTokenValue.generated.d.ts +8 -0
- package/dist/i18n/generated-english/PowerSearch/formatTokenValue.generated.d.ts.map +1 -0
- package/dist/i18n/generated-english/PowerSearch/formatTokenValue.generated.js +14 -0
- package/dist/i18n/generated-locales/en.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/en.generated.js +30 -0
- package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/pseudo.generated.js +30 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/internal/indicatorPress.stylex.d.ts +20 -0
- package/dist/internal/indicatorPress.stylex.d.ts.map +1 -0
- package/dist/internal/indicatorPress.stylex.js +26 -0
- package/dist/motion/animator.d.ts +14 -14
- package/dist/motion/animator.d.ts.map +1 -1
- package/dist/motion/animator.js +41 -18
- package/dist/motion/uikit/alert.d.ts +41 -0
- package/dist/motion/uikit/alert.d.ts.map +1 -0
- package/dist/motion/uikit/alert.js +43 -0
- package/dist/privateAttributes/pressGroupItem.stylex.d.ts +15 -0
- package/dist/privateAttributes/pressGroupItem.stylex.d.ts.map +1 -0
- package/dist/privateAttributes/pressGroupItem.stylex.js +23 -0
- package/dist/utils/focusReturn.d.ts +15 -0
- package/dist/utils/focusReturn.d.ts.map +1 -1
- package/dist/utils/focusReturn.js +28 -0
- package/dist/utils/interactionOverlay.stylex.d.ts +3 -2
- package/dist/utils/interactionOverlay.stylex.d.ts.map +1 -1
- package/dist/utils/interactionOverlay.stylex.js +3 -2
- package/dist/utils/pressFeedback.d.ts.map +1 -1
- package/dist/utils/pressFeedback.js +19 -6
- package/dist/utils/triggerFocus.d.ts +36 -0
- package/dist/utils/triggerFocus.d.ts.map +1 -0
- package/dist/utils/triggerFocus.js +65 -0
- package/locales/en.json +120 -0
- package/locales/pseudo.json +90 -0
- package/package.json +9 -4
- package/src/AlertDialog/AlertDialog.doc.mjs +2 -2
- package/src/AlertDialog/AlertDialog.tsx +37 -5
- package/src/BottomSheet/BottomSheetPanel.tsx +33 -3
- package/src/BottomSheet/useSheetGestures.ts +3 -1
- package/src/Button/Button.tsx +26 -4
- package/src/CheckboxInput/CheckboxInput.doc.mjs +18 -0
- package/src/CheckboxInput/CheckboxInput.tsx +36 -9
- package/src/ComplexSelector/ComplexSelector.tsx +20 -5
- package/src/ContextMenu/ContextMenu.tsx +2 -2
- package/src/Dialog/Dialog.tsx +10 -31
- package/src/Field/Field.tsx +2 -2
- package/src/HoverCard/HoverCard.doc.mjs +4 -2
- package/src/HoverCard/HoverCard.tsx +4 -3
- package/src/HoverCard/useHoverCard.doc.mjs +178 -36
- package/src/HoverCard/useHoverCard.tsx +46 -52
- package/src/Icon/Icon.doc.mjs +49 -8
- package/src/Icon/Icon.tsx +15 -7
- package/src/Layer/usePressPin.ts +81 -15
- package/src/Lightbox/Lightbox.tsx +18 -0
- package/src/PowerSearch/PowerSearch.doc.mjs +54 -5
- package/src/PowerSearch/PowerSearch.tsx +609 -155
- package/src/PowerSearch/PowerSearchBottomSheet.tsx +2515 -0
- package/src/PowerSearch/PowerSearchEditPopover.tsx +28 -6
- package/src/PowerSearch/PowerSearchValueEditor.tsx +203 -38
- package/src/PowerSearch/formatFilterValue.ts +18 -1
- package/src/PowerSearch/formatTokenValue.ts +215 -0
- package/src/PowerSearch/powerSearchSheetUtils.ts +224 -0
- package/src/RadioList/RadioList.tsx +3 -2
- package/src/RadioList/RadioListItem.tsx +5 -3
- package/src/Resizable/Resizable.doc.mjs +5 -4
- package/src/Resizable/ResizeHandle.tsx +167 -109
- package/src/SegmentedControl/useSegmentedSelectionMotion.ts +6 -3
- package/src/Slider/sliderTouchController.ts +2 -2
- package/src/Spinner/Spinner.tsx +77 -63
- package/src/Switch/useSwitchTouch.ts +4 -4
- package/src/Table/BaseTable.tsx +46 -12
- package/src/TextInput/TextInput.tsx +11 -10
- package/src/Toast/Toast.doc.mjs +4 -3
- package/src/Toast/Toast.tsx +52 -32
- package/src/Toast/ToastViewport.tsx +121 -35
- package/src/Toast/types.ts +9 -3
- package/src/Tooltip/useTooltip.doc.mjs +24 -0
- package/src/Tooltip/useTooltip.tsx +61 -56
- package/src/Typeahead/TypeaheadItem.doc.mjs +6 -3
- package/src/Typeahead/TypeaheadItem.tsx +2 -1
- package/src/animator/createAnimator.doc.mjs +153 -0
- package/src/animator/createAnimator.ts +324 -0
- package/src/gestures/PressTracker.ts +4 -3
- package/src/gestures/README.md +7 -1
- package/src/hooks/actionGroupTracker.ts +20 -5
- package/src/hooks/index.ts +2 -0
- package/src/hooks/pressGroupContext.ts +21 -0
- package/src/hooks/useActionGroupTracking.ts +224 -0
- package/src/hooks/useAnimator.doc.mjs +109 -0
- package/src/hooks/useAnimator.ts +67 -0
- package/src/hooks/useAttachment.ts +1 -1
- package/src/hooks/useInputStatusIcon.tsx +3 -2
- package/src/hooks/useLongPress.doc.mjs +2 -2
- package/src/hooks/useLongPress.ts +136 -15
- package/src/i18n/generated-english/PowerSearch/PowerSearchBottomSheet.generated.ts +43 -0
- package/src/i18n/generated-english/PowerSearch/PowerSearchValueEditor.generated.ts +6 -0
- package/src/i18n/generated-english/PowerSearch/formatTokenValue.generated.ts +15 -0
- package/src/i18n/generated-locales/en.generated.ts +41 -0
- package/src/i18n/generated-locales/pseudo.generated.ts +42 -0
- package/src/index.ts +13 -0
- package/src/internal/indicatorPress.stylex.ts +24 -0
- package/src/motion/README.md +8 -5
- package/src/motion/animator.ts +61 -29
- package/src/motion/uikit/alert.ts +43 -0
- package/src/privateAttributes/pressGroupItem.stylex.ts +23 -0
- package/src/utils/focusReturn.ts +30 -0
- package/src/utils/interactionOverlay.stylex.ts +3 -2
- package/src/utils/pressFeedback.ts +19 -6
- package/src/utils/triggerFocus.ts +80 -0
|
@@ -4,16 +4,19 @@
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* @file PowerSearch.tsx
|
|
7
|
-
* @input PowerSearchConfig, filters, onChange
|
|
7
|
+
* @input PowerSearchConfig, filters, onChange; Tokenizer, Field parts, Token,
|
|
8
|
+
* useAdaptivePresentation, and PowerSearchBottomSheet (lazy)
|
|
8
9
|
* @output Structured filter bar with token-based filter management
|
|
9
10
|
* @position Main component; forwards DOM ref and exposes tokenizer control via
|
|
10
|
-
* handleRef
|
|
11
|
+
* handleRef. The experimental `presentation` option swaps the tokenizer
|
|
12
|
+
* field and editor popover for one trigger that opens PowerSearchBottomSheet.
|
|
11
13
|
*
|
|
12
14
|
* SYNC: When modified, update:
|
|
13
15
|
* - /packages/core/src/PowerSearch/index.ts
|
|
16
|
+
* - /packages/core/src/PowerSearch/PowerSearchBottomSheet.tsx (sheet presentation)
|
|
14
17
|
* - /packages/cli/assets/templates/blocks/components/PowerSearch/ (showcase blocks)
|
|
15
18
|
*/
|
|
16
|
-
import React, { useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
19
|
+
import React, { lazy, Suspense, useCallback, useEffect, useId, useImperativeHandle, useMemo, useRef, useState } from 'react';
|
|
17
20
|
import * as stylex from '@stylexjs/stylex';
|
|
18
21
|
import { Tokenizer } from "../Tokenizer/index.js";
|
|
19
22
|
import { TokenizerClearAllMessageContext } from "../Tokenizer/TokenizerClearAllMessageContext.js";
|
|
@@ -23,22 +26,31 @@ import { Token } from "../Token/index.js";
|
|
|
23
26
|
import { TokenNamingContext } from "../Token/TokenNamingContext.js";
|
|
24
27
|
import { Avatar } from "../Avatar/index.js";
|
|
25
28
|
import { layerAnimations } from "../Layer/layerAnimations.stylex.js";
|
|
26
|
-
import { Icon } from "../Icon/index.js";
|
|
29
|
+
import { Icon, renderIconSlot } from "../Icon/index.js";
|
|
30
|
+
import { Field } from "../Field/Field.js";
|
|
31
|
+
import { inputStatusBorderStyles, inputStatusFocusWithinStyles, inputStatusHoverShadowStyles, inputWrapperStyles } from "../Field/inputStyles.stylex.js";
|
|
27
32
|
import { usePopover } from "../Popover/usePopover.js";
|
|
33
|
+
import { useTooltip } from "../Tooltip/useTooltip.js";
|
|
28
34
|
import "../Layer/layerViewportInset.stylex.js";
|
|
29
35
|
import { layerViewportInset } from "../Layer/layerViewportInset.stylex.js";
|
|
30
36
|
import { useAnnounce } from "../hooks/useAnnounce.js";
|
|
37
|
+
import { useAdaptivePresentation } from "../hooks/useAdaptivePresentation.js";
|
|
38
|
+
import { useDevWarning } from "../hooks/useDevWarning.js";
|
|
39
|
+
import { useIsHydrating } from "../hooks/useIsHydrating.js";
|
|
31
40
|
import "../theme/tokens.stylex.js";
|
|
32
|
-
import { spacingVars, colorVars, typeScaleVars, fontWeightVars } from "../theme/tokens.stylex.js";
|
|
41
|
+
import { spacingVars, colorVars, sizeVars, typeScaleVars, typographyVars, fontWeightVars } from "../theme/tokens.stylex.js";
|
|
33
42
|
import { useSize } from "../SizeContext/SizeContext.js";
|
|
43
|
+
import { isFocusDetached } from "../utils/focusReturn.js";
|
|
44
|
+
import { isRenderable } from "../utils/isRenderable.js";
|
|
34
45
|
import { useInternalConfig } from "./useInternalConfig.js";
|
|
35
46
|
import { usePowerSearchSource } from "./usePowerSearchSource.js";
|
|
36
|
-
import { formatFilterValue
|
|
37
|
-
import { PowerSearchEditPopover } from "./PowerSearchEditPopover.js";
|
|
47
|
+
import { formatFilterValue } from "./formatFilterValue.js";
|
|
48
|
+
import { NestedEditor, PowerSearchEditPopover } from "./PowerSearchEditPopover.js";
|
|
49
|
+
import { buildRelativeDateOptions, PowerSearchValueEditor } from "./PowerSearchValueEditor.js";
|
|
38
50
|
import { resolveOperatorLabel } from "./resolveOperatorLabel.js";
|
|
39
51
|
import { themeProps } from "../utils/themeProps.js";
|
|
40
|
-
import { truncateCharacters } from "../utils/characters.js";
|
|
41
52
|
import { useLocale } from "../i18n/useLocale.js";
|
|
53
|
+
import { formatTokenValueText } from "./formatTokenValue.js";
|
|
42
54
|
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
43
55
|
import { registerEnglishFallback, useComponentTranslator } from "../i18n/useComponentTranslator.js";
|
|
44
56
|
import english from "../i18n/generated-english/PowerSearch/PowerSearch.generated.js";
|
|
@@ -83,106 +95,76 @@ const popoverLayerStyles = {
|
|
|
83
95
|
$$css: true
|
|
84
96
|
}
|
|
85
97
|
};
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
98
|
+
// The sheet presentation's trigger field: the same control box as the
|
|
99
|
+
// tokenizer field, with display-only tokens and one button as its only tab
|
|
100
|
+
// stop.
|
|
101
|
+
const sheetTriggerSizeStyles = {
|
|
102
|
+
sm: {
|
|
103
|
+
kAzted: "x1gdqauq",
|
|
104
|
+
$$css: true
|
|
105
|
+
},
|
|
106
|
+
md: {
|
|
107
|
+
kAzted: "x1uogy3y",
|
|
108
|
+
$$css: true
|
|
109
|
+
},
|
|
110
|
+
lg: {
|
|
111
|
+
kAzted: "x1xf4nls",
|
|
112
|
+
$$css: true
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
const sheetTriggerStyles = {
|
|
116
|
+
wrapper: {
|
|
117
|
+
kVAEAm: "x1n2onr6",
|
|
118
|
+
kwnvtZ: "xozqiw3",
|
|
119
|
+
kOIVth: "xzye2dw",
|
|
120
|
+
kZKoxP: "xt7dq6l",
|
|
121
|
+
kkrTdU: "x1ypdohk xvivl9a",
|
|
122
|
+
$$css: true
|
|
123
|
+
},
|
|
124
|
+
wrapperWithTokens: {
|
|
125
|
+
k8WAf4: "x1x7cmac",
|
|
126
|
+
kg3NbH: "xx2oswg",
|
|
127
|
+
$$css: true
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
// The sheet flow (three standalone sheets, the sheet editors) only
|
|
132
|
+
// renders for the bottom-sheet presentation. Loading it on demand keeps it out
|
|
133
|
+
// of pages whose PowerSearch stays a tokenizer field.
|
|
134
|
+
// One import promise, shared by the preload and the lazy element: the sheet
|
|
135
|
+
// presentation loads the flow's chunk as soon as it is active, so the first
|
|
136
|
+
// press does not wait for the network, while nothing of the flow is rendered
|
|
137
|
+
// until a press.
|
|
138
|
+
const loadPowerSearchBottomSheet = async () => import("./PowerSearchBottomSheet.js");
|
|
139
|
+
const LazyPowerSearchBottomSheet = /*#__PURE__*/lazy(async () => loadPowerSearchBottomSheet().then(module => ({
|
|
140
|
+
default: module.PowerSearchBottomSheet
|
|
141
|
+
})));
|
|
142
|
+
// The value step reuses the popover presentation's editors, which this
|
|
143
|
+
// module already loads; see PowerSearchSheetEditors.
|
|
144
|
+
const SHEET_EDITORS = {
|
|
145
|
+
NestedEditor,
|
|
146
|
+
PowerSearchValueEditor,
|
|
147
|
+
buildRelativeDateOptions
|
|
148
|
+
};
|
|
94
149
|
|
|
95
150
|
/**
|
|
96
|
-
*
|
|
97
|
-
*
|
|
151
|
+
* Hosts the lazily loaded sheet flow. Renders nothing on the server or in the
|
|
152
|
+
* render that hydrates server HTML: a lazy component that has not loaded yet
|
|
153
|
+
* would leave server markup incomplete and abort hydration. The closed flow
|
|
154
|
+
* has no visible markup, so it first renders right after hydration.
|
|
98
155
|
*/
|
|
99
|
-
function
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
case 'string':
|
|
104
|
-
return truncateString(filterValue.value, maxLength);
|
|
105
|
-
case 'integer':
|
|
106
|
-
case 'float':
|
|
107
|
-
return String(filterValue.value);
|
|
108
|
-
case 'enum':
|
|
109
|
-
if (operatorValue.type === 'enum') {
|
|
110
|
-
return truncateString(getEnumLabel(operatorValue.values, filterValue.value), maxLength);
|
|
111
|
-
}
|
|
112
|
-
return truncateString(filterValue.value, maxLength);
|
|
113
|
-
case 'string_list':
|
|
114
|
-
{
|
|
115
|
-
const items = filterValue.value;
|
|
116
|
-
if (items.length === 0) {
|
|
117
|
-
return null;
|
|
118
|
-
}
|
|
119
|
-
if (items.length === 1) {
|
|
120
|
-
return truncateString(items[0], maxLength);
|
|
121
|
-
}
|
|
122
|
-
const totalLength = items.reduce((sum, s) => sum + s.length, 0);
|
|
123
|
-
if (totalLength > maxLength) {
|
|
124
|
-
return `${items.length} items`;
|
|
125
|
-
}
|
|
126
|
-
return items.join(', ');
|
|
127
|
-
}
|
|
128
|
-
case 'enum_list':
|
|
129
|
-
{
|
|
130
|
-
const items = filterValue.value;
|
|
131
|
-
if (items.length === 0) {
|
|
132
|
-
return null;
|
|
133
|
-
}
|
|
134
|
-
if (operatorValue.type === 'enum_list') {
|
|
135
|
-
const labels = items.map(v => getEnumLabel(operatorValue.values, v));
|
|
136
|
-
if (labels.length === 1) {
|
|
137
|
-
return truncateString(labels[0], maxLength);
|
|
138
|
-
}
|
|
139
|
-
const totalLength = labels.reduce((sum, s) => sum + s.length, 0);
|
|
140
|
-
if (totalLength > maxLength) {
|
|
141
|
-
return `${labels.length} items`;
|
|
142
|
-
}
|
|
143
|
-
return labels.join(', ');
|
|
144
|
-
}
|
|
145
|
-
if (items.length === 1) {
|
|
146
|
-
return truncateString(items[0], maxLength);
|
|
147
|
-
}
|
|
148
|
-
return `${items.length} items`;
|
|
149
|
-
}
|
|
150
|
-
case 'entity_list':
|
|
151
|
-
{
|
|
152
|
-
const entities = filterValue.value;
|
|
153
|
-
if (entities.length === 0) {
|
|
154
|
-
return null;
|
|
155
|
-
}
|
|
156
|
-
if (entities.length === 1) {
|
|
157
|
-
return truncateString(entities[0].label, maxLength);
|
|
158
|
-
}
|
|
159
|
-
const totalLength = entities.reduce((sum, e) => sum + e.label.length, 0);
|
|
160
|
-
if (totalLength > maxLength) {
|
|
161
|
-
return `${entities.length} items`;
|
|
162
|
-
}
|
|
163
|
-
return entities.map(e => e.label).join(', ');
|
|
164
|
-
}
|
|
165
|
-
case 'time':
|
|
166
|
-
return filterValue.value;
|
|
167
|
-
case 'date_absolute':
|
|
168
|
-
return truncateString(formatDateAbsoluteCompact(filterValue.unixSeconds, locale), maxLength);
|
|
169
|
-
case 'date_relative':
|
|
170
|
-
return truncateString(filterValue.value, maxLength);
|
|
171
|
-
case 'date_range':
|
|
172
|
-
return 'date range';
|
|
173
|
-
case 'custom':
|
|
174
|
-
if (operatorValue.type === 'custom') {
|
|
175
|
-
return truncateString(operatorValue.getString(filterValue.value), maxLength);
|
|
176
|
-
}
|
|
177
|
-
return filterValue.value;
|
|
178
|
-
case 'nested':
|
|
179
|
-
{
|
|
180
|
-
const count = filterValue.value.length;
|
|
181
|
-
return count === 1 ? '1 filter' : `${count} filters`;
|
|
182
|
-
}
|
|
183
|
-
default:
|
|
184
|
-
return null;
|
|
156
|
+
function PowerSearchSheetHost(props) {
|
|
157
|
+
const isHydrating = useIsHydrating();
|
|
158
|
+
if (isHydrating) {
|
|
159
|
+
return null;
|
|
185
160
|
}
|
|
161
|
+
return /*#__PURE__*/_jsx(Suspense, {
|
|
162
|
+
fallback: null,
|
|
163
|
+
children: /*#__PURE__*/_jsx(LazyPowerSearchBottomSheet, {
|
|
164
|
+
...props,
|
|
165
|
+
editors: SHEET_EDITORS
|
|
166
|
+
})
|
|
167
|
+
});
|
|
186
168
|
}
|
|
187
169
|
function PowerSearchTokenValue({
|
|
188
170
|
text
|
|
@@ -314,7 +296,8 @@ export function PowerSearch({
|
|
|
314
296
|
xstyle,
|
|
315
297
|
className,
|
|
316
298
|
style,
|
|
317
|
-
components: componentOverrides
|
|
299
|
+
components: componentOverrides,
|
|
300
|
+
experimental
|
|
318
301
|
}) {
|
|
319
302
|
const size = useSize(sizeProp, 'md');
|
|
320
303
|
const config = useInternalConfig(configProp);
|
|
@@ -325,6 +308,87 @@ export function PowerSearch({
|
|
|
325
308
|
const placeholder = placeholderFromProps ?? t('@astryx.powersearch.placeholder');
|
|
326
309
|
const popoverSaveButtonLabel = popoverSaveButtonLabelFromProps ?? t('@astryx.powersearch.editor.apply');
|
|
327
310
|
const tokenizerRef = useRef(null);
|
|
311
|
+
|
|
312
|
+
// Experimental presentation. `adaptive`
|
|
313
|
+
// resolves through the policy the selection controls share; an open flow
|
|
314
|
+
// keeps its presentation until it closes, so a resolution change mid-task
|
|
315
|
+
// cannot pull the surface out from under the person.
|
|
316
|
+
const presentation = experimental?.presentation ?? 'popover';
|
|
317
|
+
const resolvedPresentation = useAdaptivePresentation(presentation);
|
|
318
|
+
const [isSheetOpen, setIsSheetOpen] = useState(false);
|
|
319
|
+
// Latched for the flow's lifetime: the flow stays presented after it closes
|
|
320
|
+
// until the sheets have run their exit and handed focus back to the trigger.
|
|
321
|
+
// Without the latch, `adaptive` resolving to `popover` mid-session (a phone
|
|
322
|
+
// turned to landscape) would unmount the sheets and the trigger they return
|
|
323
|
+
// focus to in the same render, dropping focus to the page body.
|
|
324
|
+
const [isSheetPresented, setIsSheetPresented] = useState(false);
|
|
325
|
+
const isSheetPresentation = isSheetOpen || isSheetPresented || resolvedPresentation === 'bottom-sheet';
|
|
326
|
+
const triggerRef = useRef(null);
|
|
327
|
+
// `hasAutoFocus` applies only to the control the field first mounts. A
|
|
328
|
+
// presentation swap remounts the control (combobox input or trigger), and
|
|
329
|
+
// React's `autoFocus` on the new one would pull focus from wherever on the
|
|
330
|
+
// page it was; the roots' callback refs hand over the focus the field held
|
|
331
|
+
// instead. A field that never swaps keeps `autoFocus` on every render, so a
|
|
332
|
+
// Dialog that keeps it mounted still finds its `data-autofocus` on open.
|
|
333
|
+
const [autoFocusState, setAutoFocusState] = useState({
|
|
334
|
+
presentation: isSheetPresentation,
|
|
335
|
+
isFirstControl: true
|
|
336
|
+
});
|
|
337
|
+
if (autoFocusState.presentation !== isSheetPresentation) {
|
|
338
|
+
setAutoFocusState({
|
|
339
|
+
presentation: isSheetPresentation,
|
|
340
|
+
isFirstControl: false
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
const autoFocusOnMount = hasAutoFocus && autoFocusState.isFirstControl && autoFocusState.presentation === isSheetPresentation;
|
|
344
|
+
// A focus the swap moves continues the same visit to the field: the
|
|
345
|
+
// control that held focus is gone (no blur fires for a removed element), so
|
|
346
|
+
// the caller is told of neither a blur nor a new focus.
|
|
347
|
+
const isSwapFocusRef = useRef(false);
|
|
348
|
+
const focusAfterSwap = useCallback(control => {
|
|
349
|
+
if (control == null) {
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
isSwapFocusRef.current = true;
|
|
353
|
+
try {
|
|
354
|
+
control.focus();
|
|
355
|
+
} finally {
|
|
356
|
+
isSwapFocusRef.current = false;
|
|
357
|
+
}
|
|
358
|
+
}, []);
|
|
359
|
+
const handleFieldFocus = useCallback(event => {
|
|
360
|
+
if (!isSwapFocusRef.current) {
|
|
361
|
+
onFocus?.(event);
|
|
362
|
+
}
|
|
363
|
+
}, [onFocus]);
|
|
364
|
+
const handleFieldBlur = useCallback(event => {
|
|
365
|
+
onBlur?.(event);
|
|
366
|
+
}, [onBlur]);
|
|
367
|
+
// While the flow is open, the sheet announces its own content from inside
|
|
368
|
+
// its dialog; this component announces only with the flow closed, and
|
|
369
|
+
// `useAnnounce` routes those messages by where the field is — into a Dialog
|
|
370
|
+
// or modal Drawer that holds it, or the shared channel when no modal does.
|
|
371
|
+
// A result count that changed during the flow's exit is spoken once the
|
|
372
|
+
// flow has fully closed and focus is back on the trigger: the closing
|
|
373
|
+
// dialog stays modal through its exit, so neither its region nor the
|
|
374
|
+
// page-body channel is heard before.
|
|
375
|
+
const afterCloseResultCountRef = useRef(null);
|
|
376
|
+
const triggerId = useId();
|
|
377
|
+
const triggerLabelId = useId();
|
|
378
|
+
const triggerContentId = useId();
|
|
379
|
+
const statusMessageId = useId();
|
|
380
|
+
// A field that becomes disabled cannot keep its flow open, and must not
|
|
381
|
+
// reopen it when re-enabled. Adjusted in the
|
|
382
|
+
// render that sees the change, not an effect, so no frame shows both.
|
|
383
|
+
const [wasDisabled, setWasDisabled] = useState(isDisabled);
|
|
384
|
+
if (isDisabled !== wasDisabled) {
|
|
385
|
+
setWasDisabled(isDisabled);
|
|
386
|
+
if (isDisabled && isSheetOpen) {
|
|
387
|
+
setIsSheetOpen(false);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
useDevWarning('PowerSearch', '`menuWidth` has no surface in the bottom-sheet presentation: the sheet flow has no typeahead popover to size. Scope it to the popover presentation or leave it out.', isSheetPresentation && menuWidth != null);
|
|
391
|
+
useDevWarning('PowerSearch', '`tokenOverflowBehavior` has no surface in the bottom-sheet presentation: the trigger wraps its display-only tokens. Scope it to the popover presentation or leave it out.', isSheetPresentation && tokenOverflowBehavior != null);
|
|
328
392
|
const [popoverState, setPopoverStateRaw] = useState({
|
|
329
393
|
type: 'idle'
|
|
330
394
|
});
|
|
@@ -338,7 +402,7 @@ export function PowerSearch({
|
|
|
338
402
|
const fieldLabel = field?.label ?? '';
|
|
339
403
|
const operatorLabel = operator ? resolveOperatorLabel(operator, t) : '';
|
|
340
404
|
const label = `${fieldLabel}: ${operatorLabel}`.trim();
|
|
341
|
-
const value = operator ?
|
|
405
|
+
const value = operator ? formatTokenValueText(operator.value, filter.value, Math.max(maxTokenLength - fieldLabel.length - operatorLabel.length, 10), locale) : null;
|
|
342
406
|
return {
|
|
343
407
|
label,
|
|
344
408
|
value,
|
|
@@ -350,9 +414,23 @@ export function PowerSearch({
|
|
|
350
414
|
const editedFilter = popoverState.type === 'editing' ? filters[popoverState.filterIndex] : undefined;
|
|
351
415
|
const editedOperator = editedFilter != null ? config.getOperator(editedFilter.field, editedFilter.operator) : undefined;
|
|
352
416
|
const editedBuiltInFilter = editedOperator == null || componentOverrides?.[editedOperator.value.type]?.Token == null ? editedFilter : undefined;
|
|
417
|
+
// Whether the editor popover is open, for the hand-off below, which runs
|
|
418
|
+
// in the commit that swaps presentations.
|
|
419
|
+
const isPopoverOpenRef = useRef(false);
|
|
420
|
+
// When `adaptive` flips to the sheet while the editor popover is open (a
|
|
421
|
+
// phone rotated), the editing ends with the popover: its state returns to
|
|
422
|
+
// idle (through the raw setter, since the tokenizer input is gone), in the
|
|
423
|
+
// render that sees the swap, so a later switch back does not reopen a stale
|
|
424
|
+
// editor.
|
|
425
|
+
if (isSheetPresentation && popoverState.type !== 'idle') {
|
|
426
|
+
setPopoverStateRaw({
|
|
427
|
+
type: 'idle'
|
|
428
|
+
});
|
|
429
|
+
}
|
|
353
430
|
|
|
354
431
|
// Layer for positioning the edit popover anchored to the tokenizer
|
|
355
432
|
const handleLayerHide = useCallback(() => {
|
|
433
|
+
isPopoverOpenRef.current = false;
|
|
356
434
|
setPopoverStateRaw({
|
|
357
435
|
type: 'idle'
|
|
358
436
|
});
|
|
@@ -371,8 +449,47 @@ export function PowerSearch({
|
|
|
371
449
|
dialogLabel: editedBuiltInFilter != null ? tokenText(editedBuiltInFilter).full : undefined
|
|
372
450
|
});
|
|
373
451
|
|
|
452
|
+
// A presentation swap removes the focused control, so the other
|
|
453
|
+
// presentation's primary control (the combobox input or the trigger) takes
|
|
454
|
+
// focus and focus never falls to the page body. Each presentation keys its
|
|
455
|
+
// root, so a swap mounts a new root. The detaching root notes that it held
|
|
456
|
+
// focus, which also covers an input focused by server-rendered `autofocus`
|
|
457
|
+
// before hydration. The editor popover is portaled outside the root, so an
|
|
458
|
+
// open editor counts as held focus. The attaching root gives focus to its
|
|
459
|
+
// primary control when focus has fallen to the page body; the sheet root
|
|
460
|
+
// also hides a popover layer left open.
|
|
461
|
+
const isFocusPendingHandOffRef = useRef(false);
|
|
462
|
+
const hidePopover = popover.hide;
|
|
463
|
+
const handOffFocusRef = useCallback(node => {
|
|
464
|
+
if (node == null) {
|
|
465
|
+
return;
|
|
466
|
+
}
|
|
467
|
+
const trigger = triggerRef.current;
|
|
468
|
+
const isSheetRoot = trigger != null && node.contains(trigger);
|
|
469
|
+
// The sheet presentation preloads the flow's chunk, so the first press
|
|
470
|
+
// opens without waiting for the network; nothing renders.
|
|
471
|
+
if (isSheetRoot) {
|
|
472
|
+
void loadPowerSearchBottomSheet();
|
|
473
|
+
}
|
|
474
|
+
if (isSheetRoot && isPopoverOpenRef.current) {
|
|
475
|
+
isPopoverOpenRef.current = false;
|
|
476
|
+
hidePopover();
|
|
477
|
+
}
|
|
478
|
+
const takesFocus = isFocusPendingHandOffRef.current;
|
|
479
|
+
isFocusPendingHandOffRef.current = false;
|
|
480
|
+
if (takesFocus && isFocusDetached(node.ownerDocument)) {
|
|
481
|
+
focusAfterSwap(isSheetRoot ? trigger : tokenizerRef.current);
|
|
482
|
+
}
|
|
483
|
+
return () => {
|
|
484
|
+
if (node.contains(node.ownerDocument.activeElement) || isPopoverOpenRef.current) {
|
|
485
|
+
isFocusPendingHandOffRef.current = true;
|
|
486
|
+
}
|
|
487
|
+
};
|
|
488
|
+
}, [focusAfterSwap, hidePopover]);
|
|
489
|
+
|
|
374
490
|
// Wrapper that manages layer visibility and tokenizer focus alongside state
|
|
375
491
|
const setPopoverState = useCallback(state => {
|
|
492
|
+
isPopoverOpenRef.current = state.type !== 'idle';
|
|
376
493
|
setPopoverStateRaw(state);
|
|
377
494
|
if (state.type !== 'idle') {
|
|
378
495
|
// Schedule after the current frame so React can render the popover
|
|
@@ -387,13 +504,22 @@ export function PowerSearch({
|
|
|
387
504
|
}
|
|
388
505
|
}, [popover]);
|
|
389
506
|
|
|
390
|
-
// Expose imperative handle
|
|
507
|
+
// Expose imperative handle; in the sheet presentation the trigger is the
|
|
508
|
+
// field's focusable control.
|
|
391
509
|
useImperativeHandle(handleRef, () => ({
|
|
392
510
|
focusTypeahead() {
|
|
393
|
-
|
|
511
|
+
if (isSheetPresentation) {
|
|
512
|
+
triggerRef.current?.focus();
|
|
513
|
+
} else {
|
|
514
|
+
tokenizerRef.current?.focus();
|
|
515
|
+
}
|
|
394
516
|
},
|
|
395
517
|
blurTypeahead() {
|
|
396
|
-
|
|
518
|
+
if (isSheetPresentation) {
|
|
519
|
+
triggerRef.current?.blur();
|
|
520
|
+
} else {
|
|
521
|
+
tokenizerRef.current?.blur();
|
|
522
|
+
}
|
|
397
523
|
}
|
|
398
524
|
}));
|
|
399
525
|
|
|
@@ -554,15 +680,17 @@ export function PowerSearch({
|
|
|
554
680
|
});
|
|
555
681
|
}, [setPopoverState]);
|
|
556
682
|
|
|
557
|
-
//
|
|
558
|
-
//
|
|
559
|
-
|
|
683
|
+
// Token renderer for both presentations. Given `onRemove`, the token is
|
|
684
|
+
// the tokenizer field's: click edits, × removes. Without it (the sheet
|
|
685
|
+
// presentation's trigger) the token is display-only; the field as a whole
|
|
686
|
+
// opens the flow.
|
|
687
|
+
const renderFilterToken = useCallback((item, onRemove) => {
|
|
560
688
|
const auxData = item.auxiliaryData;
|
|
561
689
|
const filterIndex = auxData?.filterIndex ?? -1;
|
|
562
690
|
const filter = filterIndex >= 0 ? filters[filterIndex] : undefined;
|
|
563
691
|
const field = auxData ? config.getField(auxData.fieldKey) : undefined;
|
|
564
692
|
const operator = auxData?.operatorKey ? config.getOperator(auxData.fieldKey, auxData.operatorKey) : undefined;
|
|
565
|
-
const canInteract = !isReadOnly && !isDisabled && !filter?.isReadOnly;
|
|
693
|
+
const canInteract = onRemove != null && !isReadOnly && !isDisabled && !filter?.isReadOnly;
|
|
566
694
|
const handleClick = canInteract ? () => handleTokenClick(filterIndex) : undefined;
|
|
567
695
|
const handleRemove = canInteract ? onRemove : undefined;
|
|
568
696
|
|
|
@@ -636,6 +764,7 @@ export function PowerSearch({
|
|
|
636
764
|
})
|
|
637
765
|
});
|
|
638
766
|
}, [filters, config, configProp, maxTokenLength, size, isReadOnly, isDisabled, handleTokenClick, componentOverrides, t, popoverState, tokenText]);
|
|
767
|
+
const renderToken = useCallback((item, onRemove) => renderFilterToken(item, onRemove), [renderFilterToken]);
|
|
639
768
|
|
|
640
769
|
// Custom typeahead item renderer — adds field icon and description
|
|
641
770
|
const renderItem = useCallback(item => {
|
|
@@ -723,28 +852,38 @@ export function PowerSearch({
|
|
|
723
852
|
return resultCount;
|
|
724
853
|
}, [resultCount, t]);
|
|
725
854
|
|
|
726
|
-
//
|
|
727
|
-
//
|
|
728
|
-
//
|
|
729
|
-
//
|
|
730
|
-
//
|
|
731
|
-
//
|
|
732
|
-
//
|
|
855
|
+
// This Effect synchronizes a polite live region with the result count,
|
|
856
|
+
// mirroring the way Typeahead announces its dropdown result count: the count
|
|
857
|
+
// is otherwise only shown visually and stays silent to assistive tech. The
|
|
858
|
+
// region follows where the field is: the modal that holds the field (a
|
|
859
|
+
// Dialog, a modal Drawer), else the shared channel. While a sheet of the flow is open the sheet itself announces the
|
|
860
|
+
// count from inside its dialog, and this Effect stays quiet. Only a
|
|
861
|
+
// change after mount is spoken — the count present on mount is not
|
|
862
|
+
// announced unprompted — and the guard compares against the last announced
|
|
863
|
+
// text rather than a mounted flag, so StrictMode's effect replay announces
|
|
864
|
+
// nothing either. A change that lands while the flow is closing waits for
|
|
865
|
+
// the trigger focus, since the dialog is still modal through its exit. The
|
|
866
|
+
// announcement acquires no resource, so there is no cleanup.
|
|
733
867
|
const announce = useAnnounce();
|
|
734
868
|
// PowerSearch words its Clear all as its record does; the field announces
|
|
735
869
|
// these words instead of Tokenizer's (component:Tokenizer AR7).
|
|
736
870
|
const hasReadOnlyFilter = filters.some(filter => filter.isReadOnly);
|
|
737
871
|
const clearAllMessage = useMemo(() => hasReadOnlyFilter ? t('@astryx.powersearch.editableFiltersRemoved') : t('@astryx.powersearch.allFiltersRemoved'), [hasReadOnlyFilter, t]);
|
|
738
872
|
const announcedResultCountRef = useRef(resultCountText);
|
|
873
|
+
const isSheetExiting = isSheetPresented && !isSheetOpen;
|
|
739
874
|
useEffect(() => {
|
|
740
875
|
if (resultCountText === announcedResultCountRef.current) {
|
|
741
876
|
return;
|
|
742
877
|
}
|
|
743
878
|
announcedResultCountRef.current = resultCountText;
|
|
744
879
|
if (resultCountText != null) {
|
|
745
|
-
|
|
880
|
+
if (isSheetExiting) {
|
|
881
|
+
afterCloseResultCountRef.current = resultCountText;
|
|
882
|
+
} else if (!isSheetOpen) {
|
|
883
|
+
announce(resultCountText);
|
|
884
|
+
}
|
|
746
885
|
}
|
|
747
|
-
}, [resultCountText, announce]);
|
|
886
|
+
}, [resultCountText, announce, isSheetExiting, isSheetOpen]);
|
|
748
887
|
|
|
749
888
|
// Build combined endContent from resultCount + endContent props
|
|
750
889
|
const combinedEndContent = useMemo(() => {
|
|
@@ -763,9 +902,176 @@ export function PowerSearch({
|
|
|
763
902
|
}
|
|
764
903
|
return resultCountNode || endContent || undefined;
|
|
765
904
|
}, [resultCountText, endContent]);
|
|
905
|
+
|
|
906
|
+
// ------------------------------------------------------- sheet trigger --
|
|
907
|
+
|
|
908
|
+
// Disabled-reason tooltip for the sheet trigger. Disabled controls swallow
|
|
909
|
+
// pointer events, so the listeners attach to the field's control box; the
|
|
910
|
+
// trigger stays perceivable through aria-disabled.
|
|
911
|
+
const showsDisabledMessage = isDisabled && !!disabledMessage;
|
|
912
|
+
const disabledMessageTooltip = useTooltip({
|
|
913
|
+
placement: 'above',
|
|
914
|
+
focusTrigger: 'always',
|
|
915
|
+
isEnabled: isSheetPresentation && showsDisabledMessage
|
|
916
|
+
});
|
|
917
|
+
const rootRef = useMergedRefs(ref, popover.triggerRef, handOffFocusRef);
|
|
918
|
+
const openSheet = useCallback(() => {
|
|
919
|
+
if (isDisabled) {
|
|
920
|
+
return;
|
|
921
|
+
}
|
|
922
|
+
// The flow restores focus to the element that was active when it opened;
|
|
923
|
+
// make sure that is the trigger even for a tap on a token.
|
|
924
|
+
triggerRef.current?.focus({
|
|
925
|
+
preventScroll: true
|
|
926
|
+
});
|
|
927
|
+
setIsSheetPresented(true);
|
|
928
|
+
setIsSheetOpen(true);
|
|
929
|
+
}, [isDisabled]);
|
|
930
|
+
|
|
931
|
+
// The field's end lane — the result count and `endContent` — sits outside
|
|
932
|
+
// the trigger button: a caller's action button there keeps its own tab stop
|
|
933
|
+
// and taps, and an interactive control must not nest in a component
|
|
934
|
+
// button, so a tap on it must not open the flow.
|
|
935
|
+
const endLaneRef = useRef(null);
|
|
936
|
+
const handleTriggerWrapperClick = useCallback(event => {
|
|
937
|
+
// Tokens are display-only; a tap on them or the empty space around them
|
|
938
|
+
// opens the flow. The trigger button handles its own click, and the end
|
|
939
|
+
// lane handles its own.
|
|
940
|
+
if (event.target instanceof Node && (triggerRef.current?.contains(event.target) || endLaneRef.current?.contains(event.target))) {
|
|
941
|
+
return;
|
|
942
|
+
}
|
|
943
|
+
openSheet();
|
|
944
|
+
}, [openSheet]);
|
|
945
|
+
const handleTriggerFocusWithin = useCallback(event => {
|
|
946
|
+
// The flow focuses the trigger only after its exit completes; that focus
|
|
947
|
+
// is the signal that the retained sheets can leave. If the resolution
|
|
948
|
+
// moved to the popover meanwhile, the tokenizer input takes over the
|
|
949
|
+
// focus once it mounts (the hand-off above).
|
|
950
|
+
if (!isSheetOpen && isSheetPresented) {
|
|
951
|
+
setIsSheetPresented(false);
|
|
952
|
+
// The dialogs have closed: the page-body channel is exposed again.
|
|
953
|
+
const resultCount = afterCloseResultCountRef.current;
|
|
954
|
+
afterCloseResultCountRef.current = null;
|
|
955
|
+
if (resultCount != null) {
|
|
956
|
+
announce(resultCount);
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
if (!(event.relatedTarget instanceof Node) || !event.currentTarget.contains(event.relatedTarget)) {
|
|
960
|
+
handleFieldFocus(event);
|
|
961
|
+
}
|
|
962
|
+
}, [announce, handleFieldFocus, isSheetOpen, isSheetPresented]);
|
|
963
|
+
const handleTriggerBlurWithin = useCallback(event => {
|
|
964
|
+
if (!(event.relatedTarget instanceof Node) || !event.currentTarget.contains(event.relatedTarget)) {
|
|
965
|
+
handleFieldBlur(event);
|
|
966
|
+
}
|
|
967
|
+
}, [handleFieldBlur]);
|
|
968
|
+
if (isSheetPresentation) {
|
|
969
|
+
const triggerDescribedBy = [status?.message ? statusMessageId : null, showsDisabledMessage ? disabledMessageTooltip.describedBy : null].filter(Boolean).join(' ') || undefined;
|
|
970
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
971
|
+
ref: rootRef,
|
|
972
|
+
...themeProps('power-search'),
|
|
973
|
+
children: [/*#__PURE__*/_jsxs(Field, {
|
|
974
|
+
label: label,
|
|
975
|
+
isLabelHidden: isLabelHidden,
|
|
976
|
+
inputID: triggerId,
|
|
977
|
+
labelID: triggerLabelId,
|
|
978
|
+
isDisabled: isDisabled,
|
|
979
|
+
status: status ? {
|
|
980
|
+
type: status.type,
|
|
981
|
+
message: status.message,
|
|
982
|
+
messageID: status.message ? statusMessageId : undefined
|
|
983
|
+
} : undefined,
|
|
984
|
+
statusVariant: statusVariant,
|
|
985
|
+
xstyle: xstyle,
|
|
986
|
+
className: className,
|
|
987
|
+
style: style,
|
|
988
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
|
989
|
+
ref: disabledMessageTooltip.ref,
|
|
990
|
+
onClick: handleTriggerWrapperClick,
|
|
991
|
+
onFocus: handleTriggerFocusWithin,
|
|
992
|
+
onBlur: handleTriggerBlurWithin,
|
|
993
|
+
"aria-disabled": isDisabled ? true : undefined,
|
|
994
|
+
...stylex.props(inputWrapperStyles.base, sheetTriggerStyles.wrapper, filters.length > 0 && sheetTriggerStyles.wrapperWithTokens, sheetTriggerSizeStyles[size], isDisabled && inputWrapperStyles.disabled, status && inputStatusBorderStyles[status.type], status && !isDisabled && inputStatusHoverShadowStyles[status.type], status && inputStatusFocusWithinStyles[status.type]),
|
|
995
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
|
996
|
+
id: triggerContentId,
|
|
997
|
+
...{
|
|
998
|
+
className: "x1n2onr6 xeuugli x1iyjqo2 x78zum5 x6s0dn4 x1a02dak x1lfs0n9 xajebq8"
|
|
999
|
+
},
|
|
1000
|
+
children: [isRenderable(startIcon) && /*#__PURE__*/_jsx("span", {
|
|
1001
|
+
...{
|
|
1002
|
+
0: {},
|
|
1003
|
+
1: {
|
|
1004
|
+
className: "x1xrm450"
|
|
1005
|
+
}
|
|
1006
|
+
}[!!(filters.length > 0) << 0],
|
|
1007
|
+
children: renderIconSlot(startIcon, {
|
|
1008
|
+
size: 'sm',
|
|
1009
|
+
color: 'secondary'
|
|
1010
|
+
})
|
|
1011
|
+
}), tokenizerValue.map(item => /*#__PURE__*/_jsx(React.Fragment, {
|
|
1012
|
+
children: renderFilterToken(item, undefined)
|
|
1013
|
+
}, item.id)), /*#__PURE__*/_jsx("button", {
|
|
1014
|
+
type: "button",
|
|
1015
|
+
id: triggerId,
|
|
1016
|
+
ref: triggerRef
|
|
1017
|
+
// The field's primary control: `data-testid` lands here, as it
|
|
1018
|
+
// lands on the combobox input in the popover presentation.
|
|
1019
|
+
,
|
|
1020
|
+
"data-testid": testId,
|
|
1021
|
+
autoFocus: autoFocusOnMount,
|
|
1022
|
+
onClick: openSheet,
|
|
1023
|
+
"aria-disabled": isDisabled ? true : undefined,
|
|
1024
|
+
"aria-haspopup": "dialog",
|
|
1025
|
+
"aria-expanded": isSheetOpen,
|
|
1026
|
+
"aria-labelledby": `${triggerLabelId} ${triggerContentId}`,
|
|
1027
|
+
"aria-describedby": triggerDescribedBy,
|
|
1028
|
+
...{
|
|
1029
|
+
0: {
|
|
1030
|
+
className: "xjyslct xfoc8du x1fns5xo xkh2ocl x78zum5 x6s0dn4 xt970qd x7a5moj x1ghz6dp xc342km xng3xce xjbqb8w xv1l7n4 x9ynric xjm74w1 xw6l6zx x1yc453h xuxw1ft x1ypdohk xvivl9a x1a2a7pz"
|
|
1031
|
+
},
|
|
1032
|
+
1: {
|
|
1033
|
+
className: "xjyslct xfoc8du xkh2ocl x78zum5 x6s0dn4 xt970qd x7a5moj x1ghz6dp xc342km xng3xce xjbqb8w xv1l7n4 x9ynric xjm74w1 xw6l6zx x1yc453h xuxw1ft x1ypdohk xvivl9a x1a2a7pz x10l6tqk x10a8y8t xeuugli x1717udv"
|
|
1034
|
+
}
|
|
1035
|
+
}[!!(filters.length > 0) << 0],
|
|
1036
|
+
children: filters.length === 0 ? placeholder : null
|
|
1037
|
+
})]
|
|
1038
|
+
}), (endContent || isRenderable(resultCountText)) && /*#__PURE__*/_jsxs("div", {
|
|
1039
|
+
ref: endLaneRef,
|
|
1040
|
+
...{
|
|
1041
|
+
className: "x78zum5 x6s0dn4 x1txdalj x2lah0s x1nryj5t"
|
|
1042
|
+
},
|
|
1043
|
+
children: [isRenderable(resultCountText) && /*#__PURE__*/_jsx("span", {
|
|
1044
|
+
...{
|
|
1045
|
+
className: "x141an7d x1ltkj2j xv1l7n4 xuxw1ft"
|
|
1046
|
+
},
|
|
1047
|
+
children: resultCountText
|
|
1048
|
+
}), endContent]
|
|
1049
|
+
})]
|
|
1050
|
+
}), showsDisabledMessage && disabledMessageTooltip.renderTooltip(disabledMessage)]
|
|
1051
|
+
}), (isSheetOpen || isSheetPresented) && /*#__PURE__*/_jsx(PowerSearchSheetHost, {
|
|
1052
|
+
isOpen: isSheetOpen,
|
|
1053
|
+
onOpenChange: setIsSheetOpen,
|
|
1054
|
+
finalFocusRef: triggerRef,
|
|
1055
|
+
resultCountText: resultCountText,
|
|
1056
|
+
config: config,
|
|
1057
|
+
configProp: configProp,
|
|
1058
|
+
filters: filters,
|
|
1059
|
+
onChange: onChange,
|
|
1060
|
+
searchSource: searchSource,
|
|
1061
|
+
placeholder: placeholder,
|
|
1062
|
+
isReadOnly: isReadOnly,
|
|
1063
|
+
isDisabled: isDisabled,
|
|
1064
|
+
hasClear: hasClear,
|
|
1065
|
+
maxOperatorMenuItems: maxOperatorMenuItems,
|
|
1066
|
+
maxSearchResults: maxSearchResults,
|
|
1067
|
+
saveButtonLabel: popoverSaveButtonLabelFromProps,
|
|
1068
|
+
components: componentOverrides
|
|
1069
|
+
})]
|
|
1070
|
+
}, "sheet");
|
|
1071
|
+
}
|
|
766
1072
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
767
1073
|
children: [/*#__PURE__*/_jsx("div", {
|
|
768
|
-
ref:
|
|
1074
|
+
ref: rootRef,
|
|
769
1075
|
...themeProps('power-search'),
|
|
770
1076
|
children: /*#__PURE__*/_jsx(TokenizerClearAllMessageContext, {
|
|
771
1077
|
value: clearAllMessage,
|
|
@@ -783,7 +1089,7 @@ export function PowerSearch({
|
|
|
783
1089
|
maxMenuItems: MAX_BROWSE_MENU_ITEMS,
|
|
784
1090
|
menuWidth: menuWidth,
|
|
785
1091
|
placeholder: filters.length === 0 ? placeholder : '',
|
|
786
|
-
hasAutoFocus:
|
|
1092
|
+
hasAutoFocus: autoFocusOnMount,
|
|
787
1093
|
hasClear: hasClear && !isReadOnly,
|
|
788
1094
|
startIcon: startIcon,
|
|
789
1095
|
endContent: combinedEndContent,
|
|
@@ -795,8 +1101,8 @@ export function PowerSearch({
|
|
|
795
1101
|
debounceMs: 0,
|
|
796
1102
|
status: status,
|
|
797
1103
|
statusVariant: statusVariant,
|
|
798
|
-
onFocus:
|
|
799
|
-
onBlur:
|
|
1104
|
+
onFocus: handleFieldFocus,
|
|
1105
|
+
onBlur: handleFieldBlur,
|
|
800
1106
|
containerXstyle: xstyle,
|
|
801
1107
|
containerClassName: className,
|
|
802
1108
|
containerStyle: style,
|
|
@@ -804,7 +1110,7 @@ export function PowerSearch({
|
|
|
804
1110
|
})
|
|
805
1111
|
})
|
|
806
1112
|
})
|
|
807
|
-
}), popover.render(popoverContent, {
|
|
1113
|
+
}, "popover"), popover.render(popoverContent, {
|
|
808
1114
|
placement: 'below',
|
|
809
1115
|
alignment: 'start',
|
|
810
1116
|
offset: spacingVars['--spacing-1'],
|