@dxos/react-ui-searchlist 0.8.4-main.f9ba587 → 0.8.4-main.fffef41
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/lib/browser/index.mjs +285 -139
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +285 -139
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/components/Combobox/Combobox.d.ts +44 -0
- package/dist/types/src/components/Combobox/Combobox.d.ts.map +1 -0
- package/dist/types/src/components/Combobox/Combobox.stories.d.ts +21 -0
- package/dist/types/src/components/Combobox/Combobox.stories.d.ts.map +1 -0
- package/dist/types/src/components/Combobox/index.d.ts +2 -0
- package/dist/types/src/components/Combobox/index.d.ts.map +1 -0
- package/dist/types/src/components/Listbox/Listbox.d.ts +31 -0
- package/dist/types/src/components/Listbox/Listbox.d.ts.map +1 -0
- package/dist/types/src/components/Listbox/Listbox.stories.d.ts +21 -0
- package/dist/types/src/components/Listbox/Listbox.stories.d.ts.map +1 -0
- package/dist/types/src/components/Listbox/index.d.ts +2 -0
- package/dist/types/src/components/Listbox/index.d.ts.map +1 -0
- package/dist/types/src/components/{SearchList.d.ts → SearchList/SearchList.d.ts} +7 -27
- package/dist/types/src/components/SearchList/SearchList.d.ts.map +1 -0
- package/dist/types/src/components/SearchList/SearchList.stories.d.ts +25 -0
- package/dist/types/src/components/SearchList/SearchList.stories.d.ts.map +1 -0
- package/dist/types/src/components/SearchList/index.d.ts +2 -0
- package/dist/types/src/components/SearchList/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +2 -0
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +0 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +3 -1
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +17 -16
- package/src/components/Combobox/Combobox.stories.tsx +57 -0
- package/src/components/Combobox/Combobox.tsx +335 -0
- package/src/components/Combobox/index.ts +5 -0
- package/src/components/Listbox/Listbox.stories.tsx +53 -0
- package/src/components/Listbox/Listbox.tsx +209 -0
- package/src/components/Listbox/index.ts +5 -0
- package/src/components/SearchList/SearchList.stories.tsx +64 -0
- package/src/components/SearchList/SearchList.tsx +163 -0
- package/src/components/SearchList/index.ts +5 -0
- package/src/components/index.ts +2 -0
- package/src/index.ts +0 -1
- package/src/translations.ts +3 -1
- package/dist/types/src/components/SearchList.d.ts.map +0 -1
- package/dist/types/src/components/SearchList.stories.d.ts +0 -15
- package/dist/types/src/components/SearchList.stories.d.ts.map +0 -1
- package/dist/types/src/composites/PopoverCombobox.d.ts +0 -32
- package/dist/types/src/composites/PopoverCombobox.d.ts.map +0 -1
- package/dist/types/src/composites/PopoverCombobox.stories.d.ts +0 -28
- package/dist/types/src/composites/PopoverCombobox.stories.d.ts.map +0 -1
- package/dist/types/src/composites/index.d.ts +0 -2
- package/dist/types/src/composites/index.d.ts.map +0 -1
- package/src/components/SearchList.stories.tsx +0 -47
- package/src/components/SearchList.tsx +0 -250
- package/src/composites/PopoverCombobox.stories.tsx +0 -44
- package/src/composites/PopoverCombobox.tsx +0 -186
- package/src/composites/index.ts +0 -5
|
@@ -1,23 +1,42 @@
|
|
|
1
|
-
// src/components/
|
|
2
|
-
import { useSignals as
|
|
3
|
-
import { CaretDown } from "@phosphor-icons/react";
|
|
1
|
+
// src/components/Combobox/Combobox.tsx
|
|
2
|
+
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
4
3
|
import { createContext } from "@radix-ui/react-context";
|
|
5
4
|
import { useControllableState } from "@radix-ui/react-use-controllable-state";
|
|
5
|
+
import React2, { forwardRef as forwardRef2, useCallback } from "react";
|
|
6
|
+
import { Button, Icon, Popover } from "@dxos/react-ui";
|
|
7
|
+
import { useId } from "@dxos/react-ui";
|
|
8
|
+
import { mx as mx2, staticPlaceholderText } from "@dxos/react-ui-theme";
|
|
9
|
+
|
|
10
|
+
// src/components/SearchList/SearchList.tsx
|
|
11
|
+
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
6
12
|
import { CommandEmpty, CommandInput, CommandItem, CommandList, CommandRoot } from "cmdk";
|
|
7
|
-
import React, { forwardRef
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
13
|
+
import React, { forwardRef } from "react";
|
|
14
|
+
import { useDensityContext, useElevationContext, useThemeContext, useTranslation } from "@dxos/react-ui";
|
|
15
|
+
import { mx } from "@dxos/react-ui-theme";
|
|
16
|
+
|
|
17
|
+
// src/translations.ts
|
|
18
|
+
var translationKey = "react-ui-searchlist";
|
|
19
|
+
var translations = [
|
|
20
|
+
{
|
|
21
|
+
"en-US": {
|
|
22
|
+
[translationKey]: {
|
|
23
|
+
"search.placeholder": "Search..."
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
];
|
|
28
|
+
|
|
29
|
+
// src/components/SearchList/SearchList.tsx
|
|
30
|
+
var commandItem = "flex items-center overflow-hidden";
|
|
31
|
+
var searchListItem = "plb-1 pli-2 rounded-sm select-none cursor-pointer data-[selected]:bg-hoverOverlay hover:bg-hoverOverlay";
|
|
12
32
|
var SEARCHLIST_NAME = "SearchList";
|
|
13
33
|
var SEARCHLIST_ITEM_NAME = "SearchListItem";
|
|
14
|
-
var [ComboboxProvider, useComboboxContext] = createContext(COMBOBOX_NAME, {});
|
|
15
34
|
var SearchListRoot = /* @__PURE__ */ forwardRef(({ children, classNames, ...props }, forwardedRef) => {
|
|
16
35
|
var _effect = _useSignals();
|
|
17
36
|
try {
|
|
18
37
|
return /* @__PURE__ */ React.createElement(CommandRoot, {
|
|
19
38
|
...props,
|
|
20
|
-
className: mx(
|
|
39
|
+
className: mx(classNames),
|
|
21
40
|
ref: forwardedRef
|
|
22
41
|
}, children);
|
|
23
42
|
} finally {
|
|
@@ -25,15 +44,18 @@ var SearchListRoot = /* @__PURE__ */ forwardRef(({ children, classNames, ...prop
|
|
|
25
44
|
}
|
|
26
45
|
});
|
|
27
46
|
SearchListRoot.displayName = SEARCHLIST_NAME;
|
|
28
|
-
var SearchListInput = /* @__PURE__ */ forwardRef(({
|
|
47
|
+
var SearchListInput = /* @__PURE__ */ forwardRef(({ classNames, density: propsDensity, elevation: propsElevation, variant, ...props }, forwardedRef) => {
|
|
29
48
|
var _effect = _useSignals();
|
|
30
49
|
try {
|
|
50
|
+
const { t } = useTranslation(translationKey);
|
|
51
|
+
const placeholder = props.placeholder ?? t("search.placeholder");
|
|
31
52
|
const { hasIosKeyboard } = useThemeContext();
|
|
32
53
|
const { tx } = useThemeContext();
|
|
33
54
|
const density = useDensityContext(propsDensity);
|
|
34
55
|
const elevation = useElevationContext(propsElevation);
|
|
35
56
|
return /* @__PURE__ */ React.createElement(CommandInput, {
|
|
36
57
|
...props,
|
|
58
|
+
placeholder,
|
|
37
59
|
className: tx("input.input", "input", {
|
|
38
60
|
variant,
|
|
39
61
|
disabled: props.disabled,
|
|
@@ -73,23 +95,12 @@ var SearchListEmpty = /* @__PURE__ */ forwardRef(({ children, classNames, ...pro
|
|
|
73
95
|
_effect.f();
|
|
74
96
|
}
|
|
75
97
|
});
|
|
76
|
-
var SearchListItem = /* @__PURE__ */ forwardRef(({ children, classNames,
|
|
98
|
+
var SearchListItem = /* @__PURE__ */ forwardRef(({ children, classNames, ...props }, forwardedRef) => {
|
|
77
99
|
var _effect = _useSignals();
|
|
78
100
|
try {
|
|
79
|
-
const { onValueChange, onOpenChange } = useComboboxContext(SEARCHLIST_ITEM_NAME);
|
|
80
|
-
const handleSelect = useCallback((nextValue) => {
|
|
81
|
-
onValueChange?.(nextValue);
|
|
82
|
-
onOpenChange?.(false);
|
|
83
|
-
onSelect?.(nextValue);
|
|
84
|
-
}, [
|
|
85
|
-
onValueChange,
|
|
86
|
-
onOpenChange,
|
|
87
|
-
onSelect
|
|
88
|
-
]);
|
|
89
101
|
return /* @__PURE__ */ React.createElement(CommandItem, {
|
|
90
102
|
...props,
|
|
91
|
-
|
|
92
|
-
className: mx("p-1 rounded select-none cursor-pointer data-[selected]:bg-hoverOverlay", classNames),
|
|
103
|
+
className: mx(searchListItem, classNames),
|
|
93
104
|
ref: forwardedRef
|
|
94
105
|
}, children);
|
|
95
106
|
} finally {
|
|
@@ -97,8 +108,22 @@ var SearchListItem = /* @__PURE__ */ forwardRef(({ children, classNames, onSelec
|
|
|
97
108
|
}
|
|
98
109
|
});
|
|
99
110
|
SearchListItem.displayName = SEARCHLIST_ITEM_NAME;
|
|
100
|
-
var
|
|
101
|
-
|
|
111
|
+
var SearchList = {
|
|
112
|
+
Root: SearchListRoot,
|
|
113
|
+
Input: SearchListInput,
|
|
114
|
+
Content: SearchListContent,
|
|
115
|
+
Empty: SearchListEmpty,
|
|
116
|
+
Item: SearchListItem
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
// src/components/Combobox/Combobox.tsx
|
|
120
|
+
var COMBOBOX_NAME = "Combobox";
|
|
121
|
+
var COMBOBOX_CONTENT_NAME = "ComboboxContent";
|
|
122
|
+
var COMBOBOX_ITEM_NAME = "ComboboxItem";
|
|
123
|
+
var COMBOBOX_TRIGGER_NAME = "ComboboxTrigger";
|
|
124
|
+
var [ComboboxProvider, useComboboxContext] = createContext(COMBOBOX_NAME, {});
|
|
125
|
+
var ComboboxRoot = ({ modal, modalId: propsModalId, open: propsOpen, defaultOpen, onOpenChange: propsOnOpenChange, value: propsValue, defaultValue, onValueChange: propsOnValueChange, placeholder, children }) => {
|
|
126
|
+
var _effect = _useSignals2();
|
|
102
127
|
try {
|
|
103
128
|
const modalId = useId(COMBOBOX_NAME, propsModalId);
|
|
104
129
|
const [open = false, onOpenChange] = useControllableState({
|
|
@@ -111,22 +136,63 @@ var ComboboxRoot = ({ modalId: propsModalId, open: propsOpen, defaultOpen, onOpe
|
|
|
111
136
|
onChange: propsOnValueChange,
|
|
112
137
|
defaultProp: defaultValue
|
|
113
138
|
});
|
|
114
|
-
return /* @__PURE__ */
|
|
139
|
+
return /* @__PURE__ */ React2.createElement(Popover.Root, {
|
|
140
|
+
open,
|
|
141
|
+
onOpenChange,
|
|
142
|
+
modal
|
|
143
|
+
}, /* @__PURE__ */ React2.createElement(ComboboxProvider, {
|
|
115
144
|
isCombobox: true,
|
|
116
145
|
modalId,
|
|
146
|
+
placeholder,
|
|
117
147
|
open,
|
|
118
148
|
onOpenChange,
|
|
119
149
|
value,
|
|
120
|
-
onValueChange
|
|
121
|
-
|
|
122
|
-
}, children);
|
|
150
|
+
onValueChange
|
|
151
|
+
}, children));
|
|
123
152
|
} finally {
|
|
124
153
|
_effect.f();
|
|
125
154
|
}
|
|
126
155
|
};
|
|
127
|
-
|
|
128
|
-
var
|
|
129
|
-
|
|
156
|
+
var ComboboxContent = /* @__PURE__ */ forwardRef2(({ side = "bottom", collisionPadding = 48, sideOffset, align, alignOffset, avoidCollisions, collisionBoundary, arrowPadding, sticky, hideWhenDetached, onOpenAutoFocus, onCloseAutoFocus, onEscapeKeyDown, onPointerDownOutside, onFocusOutside, onInteractOutside, forceMount, children, classNames, ...props }, forwardedRef) => {
|
|
157
|
+
var _effect = _useSignals2();
|
|
158
|
+
try {
|
|
159
|
+
const { modalId } = useComboboxContext(COMBOBOX_CONTENT_NAME);
|
|
160
|
+
return /* @__PURE__ */ React2.createElement(Popover.Content, {
|
|
161
|
+
side,
|
|
162
|
+
sideOffset,
|
|
163
|
+
align,
|
|
164
|
+
alignOffset,
|
|
165
|
+
avoidCollisions,
|
|
166
|
+
collisionBoundary,
|
|
167
|
+
collisionPadding,
|
|
168
|
+
arrowPadding,
|
|
169
|
+
sticky,
|
|
170
|
+
hideWhenDetached,
|
|
171
|
+
onOpenAutoFocus,
|
|
172
|
+
onCloseAutoFocus,
|
|
173
|
+
onEscapeKeyDown,
|
|
174
|
+
onPointerDownOutside,
|
|
175
|
+
onFocusOutside,
|
|
176
|
+
onInteractOutside,
|
|
177
|
+
forceMount,
|
|
178
|
+
classNames: [
|
|
179
|
+
"is-[--radix-popover-trigger-width] max-bs-[--radix-popover-content-available-height] grid grid-rows-[min-content_1fr]",
|
|
180
|
+
classNames
|
|
181
|
+
],
|
|
182
|
+
id: modalId,
|
|
183
|
+
ref: forwardedRef
|
|
184
|
+
}, /* @__PURE__ */ React2.createElement(SearchList.Root, {
|
|
185
|
+
...props,
|
|
186
|
+
classNames: "contents density-fine",
|
|
187
|
+
role: "none"
|
|
188
|
+
}, children));
|
|
189
|
+
} finally {
|
|
190
|
+
_effect.f();
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
ComboboxContent.displayName = COMBOBOX_CONTENT_NAME;
|
|
194
|
+
var ComboboxTrigger = /* @__PURE__ */ forwardRef2(({ children, onClick, ...props }, forwardedRef) => {
|
|
195
|
+
var _effect = _useSignals2();
|
|
130
196
|
try {
|
|
131
197
|
const { modalId, open, onOpenChange, placeholder, value } = useComboboxContext(COMBOBOX_TRIGGER_NAME);
|
|
132
198
|
const handleClick = useCallback((event) => {
|
|
@@ -136,7 +202,9 @@ var ComboboxTrigger = /* @__PURE__ */ forwardRef(({ children, onClick, ...props
|
|
|
136
202
|
onClick,
|
|
137
203
|
onOpenChange
|
|
138
204
|
]);
|
|
139
|
-
return /* @__PURE__ */
|
|
205
|
+
return /* @__PURE__ */ React2.createElement(Popover.Trigger, {
|
|
206
|
+
asChild: true
|
|
207
|
+
}, /* @__PURE__ */ React2.createElement(Button, {
|
|
140
208
|
...props,
|
|
141
209
|
role: "combobox",
|
|
142
210
|
"aria-expanded": open,
|
|
@@ -144,150 +212,228 @@ var ComboboxTrigger = /* @__PURE__ */ forwardRef(({ children, onClick, ...props
|
|
|
144
212
|
"aria-haspopup": "dialog",
|
|
145
213
|
onClick: handleClick,
|
|
146
214
|
ref: forwardedRef
|
|
147
|
-
}, children ?? /* @__PURE__ */
|
|
148
|
-
className:
|
|
149
|
-
}, value || placeholder), /* @__PURE__ */
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
})));
|
|
215
|
+
}, children ?? /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement("span", {
|
|
216
|
+
className: mx2("font-normal text-start flex-1 min-is-0 truncate mie-2", !value && staticPlaceholderText)
|
|
217
|
+
}, value || placeholder), /* @__PURE__ */ React2.createElement(Icon, {
|
|
218
|
+
icon: "ph--caret-down--bold",
|
|
219
|
+
size: 3
|
|
220
|
+
}))));
|
|
153
221
|
} finally {
|
|
154
222
|
_effect.f();
|
|
155
223
|
}
|
|
156
224
|
});
|
|
157
225
|
ComboboxTrigger.displayName = COMBOBOX_TRIGGER_NAME;
|
|
158
|
-
var
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
226
|
+
var ComboboxVirtualTrigger = Popover.VirtualTrigger;
|
|
227
|
+
var ComboboxInput = /* @__PURE__ */ forwardRef2(({ classNames, ...props }, forwardedRef) => {
|
|
228
|
+
var _effect = _useSignals2();
|
|
229
|
+
try {
|
|
230
|
+
return /* @__PURE__ */ React2.createElement(SearchList.Input, {
|
|
231
|
+
...props,
|
|
232
|
+
classNames: [
|
|
233
|
+
"mli-cardSpacingChrome mbs-cardSpacingChrome mbe-0 is-[calc(100%-2*var(--dx-cardSpacingChrome))]",
|
|
234
|
+
classNames
|
|
235
|
+
],
|
|
236
|
+
ref: forwardedRef
|
|
237
|
+
});
|
|
238
|
+
} finally {
|
|
239
|
+
_effect.f();
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
var ComboboxList = /* @__PURE__ */ forwardRef2(({ classNames, ...props }, forwardedRef) => {
|
|
243
|
+
var _effect = _useSignals2();
|
|
244
|
+
try {
|
|
245
|
+
return /* @__PURE__ */ React2.createElement(SearchList.Content, {
|
|
246
|
+
...props,
|
|
247
|
+
classNames: [
|
|
248
|
+
"min-bs-0 overflow-y-auto plb-cardSpacingChrome",
|
|
249
|
+
classNames
|
|
250
|
+
],
|
|
251
|
+
ref: forwardedRef
|
|
252
|
+
});
|
|
253
|
+
} finally {
|
|
254
|
+
_effect.f();
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
var ComboboxItem = /* @__PURE__ */ forwardRef2(({ classNames, onSelect, ...props }, forwardedRef) => {
|
|
258
|
+
var _effect = _useSignals2();
|
|
259
|
+
try {
|
|
260
|
+
const { onValueChange, onOpenChange } = useComboboxContext(COMBOBOX_ITEM_NAME);
|
|
261
|
+
const handleSelect = useCallback((nextValue) => {
|
|
262
|
+
onSelect?.(nextValue);
|
|
263
|
+
onValueChange?.(nextValue);
|
|
264
|
+
onOpenChange?.(false);
|
|
265
|
+
}, [
|
|
266
|
+
onSelect,
|
|
267
|
+
onValueChange,
|
|
268
|
+
onOpenChange
|
|
269
|
+
]);
|
|
270
|
+
return /* @__PURE__ */ React2.createElement(SearchList.Item, {
|
|
271
|
+
...props,
|
|
272
|
+
classNames: [
|
|
273
|
+
"mli-cardSpacingChrome pli-cardSpacingChrome",
|
|
274
|
+
classNames
|
|
275
|
+
],
|
|
276
|
+
onSelect: handleSelect,
|
|
277
|
+
ref: forwardedRef
|
|
278
|
+
});
|
|
279
|
+
} finally {
|
|
280
|
+
_effect.f();
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
ComboboxItem.displayName = COMBOBOX_ITEM_NAME;
|
|
284
|
+
var ComboboxArrow = Popover.Arrow;
|
|
285
|
+
var ComboboxEmpty = SearchList.Empty;
|
|
165
286
|
var Combobox = {
|
|
166
287
|
Root: ComboboxRoot,
|
|
288
|
+
Content: ComboboxContent,
|
|
167
289
|
Trigger: ComboboxTrigger,
|
|
168
|
-
|
|
290
|
+
VirtualTrigger: ComboboxVirtualTrigger,
|
|
291
|
+
Input: ComboboxInput,
|
|
292
|
+
List: ComboboxList,
|
|
293
|
+
Item: ComboboxItem,
|
|
294
|
+
Arrow: ComboboxArrow,
|
|
295
|
+
Empty: ComboboxEmpty
|
|
169
296
|
};
|
|
170
297
|
|
|
171
|
-
// src/
|
|
172
|
-
import { useSignals as
|
|
298
|
+
// src/components/Listbox/Listbox.tsx
|
|
299
|
+
import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
|
|
300
|
+
import { useArrowNavigationGroup } from "@fluentui/react-tabster";
|
|
301
|
+
import { useComposedRefs } from "@radix-ui/react-compose-refs";
|
|
302
|
+
import { createContextScope } from "@radix-ui/react-context";
|
|
173
303
|
import { useControllableState as useControllableState2 } from "@radix-ui/react-use-controllable-state";
|
|
174
|
-
import
|
|
175
|
-
import {
|
|
176
|
-
|
|
177
|
-
|
|
304
|
+
import React3, { forwardRef as forwardRef3, useCallback as useCallback2, useEffect, useRef } from "react";
|
|
305
|
+
import { Icon as Icon2 } from "@dxos/react-ui";
|
|
306
|
+
import { mx as mx3 } from "@dxos/react-ui-theme";
|
|
307
|
+
var LISTBOX_NAME = "Listbox";
|
|
308
|
+
var LISTBOX_OPTION_NAME = "ListboxOption";
|
|
309
|
+
var LISTBOX_OPTION_LABEL_NAME = "ListboxOptionLabel";
|
|
310
|
+
var LISTBOX_OPTION_INDICATOR_NAME = "ListboxOptionIndicator";
|
|
311
|
+
var [createListboxContext, createListboxScope] = createContextScope(LISTBOX_NAME, []);
|
|
312
|
+
var [createListboxOptionContext, createListboxOptionScope] = createContextScope(LISTBOX_OPTION_NAME, [
|
|
313
|
+
createListboxScope
|
|
314
|
+
]);
|
|
315
|
+
var [ListboxProvider, useListboxContext] = createListboxContext(LISTBOX_NAME);
|
|
316
|
+
var [ListboxOptionProvider, useListboxOptionContext] = createListboxOptionContext(LISTBOX_OPTION_NAME);
|
|
317
|
+
var ListboxRoot = /* @__PURE__ */ forwardRef3((props, forwardedRef) => {
|
|
318
|
+
var _effect = _useSignals3();
|
|
178
319
|
try {
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
defaultProp: defaultOpen
|
|
320
|
+
const { __listboxScope, children, classNames, value: propsValue, defaultValue, onValueChange, autoFocus, ...rootProps } = props;
|
|
321
|
+
const arrowGroup = useArrowNavigationGroup({
|
|
322
|
+
axis: "vertical"
|
|
183
323
|
});
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
324
|
+
const ref = useRef(null);
|
|
325
|
+
const rootRef = useComposedRefs(ref, forwardedRef);
|
|
326
|
+
const [selectedValue, setSelectedValue] = useControllableState2({
|
|
327
|
+
prop: propsValue,
|
|
328
|
+
defaultProp: defaultValue,
|
|
329
|
+
onChange: onValueChange
|
|
330
|
+
});
|
|
331
|
+
const handleValueChange = (value) => {
|
|
332
|
+
setSelectedValue(value);
|
|
333
|
+
};
|
|
334
|
+
useEffect(() => {
|
|
335
|
+
ref.current?.querySelector('[aria-selected="true"]')?.focus();
|
|
336
|
+
}, [
|
|
337
|
+
autoFocus
|
|
338
|
+
]);
|
|
339
|
+
return /* @__PURE__ */ React3.createElement(ListboxProvider, {
|
|
340
|
+
scope: __listboxScope,
|
|
341
|
+
selectedValue,
|
|
342
|
+
onValueChange: handleValueChange
|
|
343
|
+
}, /* @__PURE__ */ React3.createElement("ul", {
|
|
344
|
+
role: "listbox",
|
|
345
|
+
...rootProps,
|
|
346
|
+
className: mx3("is-full p-cardSpacingChrome", classNames),
|
|
347
|
+
ref: rootRef,
|
|
348
|
+
...arrowGroup
|
|
192
349
|
}, children));
|
|
193
350
|
} finally {
|
|
194
351
|
_effect.f();
|
|
195
352
|
}
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
var
|
|
199
|
-
var _effect =
|
|
353
|
+
});
|
|
354
|
+
ListboxRoot.displayName = LISTBOX_NAME;
|
|
355
|
+
var ListboxOption = /* @__PURE__ */ forwardRef3((props, forwardedRef) => {
|
|
356
|
+
var _effect = _useSignals3();
|
|
200
357
|
try {
|
|
201
|
-
const {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
358
|
+
const { __listboxScope, children, classNames, value, ...rootProps } = props;
|
|
359
|
+
const { selectedValue, onValueChange } = useListboxContext(LISTBOX_OPTION_NAME, __listboxScope);
|
|
360
|
+
const isSelected = selectedValue === value;
|
|
361
|
+
const handleSelect = useCallback2(() => {
|
|
362
|
+
onValueChange(value);
|
|
363
|
+
}, [
|
|
364
|
+
value,
|
|
365
|
+
onValueChange
|
|
366
|
+
]);
|
|
367
|
+
return /* @__PURE__ */ React3.createElement(ListboxOptionProvider, {
|
|
368
|
+
scope: __listboxScope,
|
|
369
|
+
value,
|
|
370
|
+
isSelected
|
|
371
|
+
}, /* @__PURE__ */ React3.createElement("li", {
|
|
372
|
+
role: "option",
|
|
373
|
+
...rootProps,
|
|
374
|
+
"aria-selected": isSelected,
|
|
375
|
+
tabIndex: 0,
|
|
376
|
+
className: mx3("dx-focus-ring", commandItem, searchListItem, classNames),
|
|
377
|
+
onClick: handleSelect,
|
|
378
|
+
onKeyDown: ({ key }) => {
|
|
379
|
+
if ([
|
|
380
|
+
"Enter",
|
|
381
|
+
" "
|
|
382
|
+
].includes(key)) {
|
|
383
|
+
handleSelect();
|
|
384
|
+
}
|
|
385
|
+
},
|
|
222
386
|
ref: forwardedRef
|
|
223
|
-
},
|
|
224
|
-
...props,
|
|
225
|
-
classNames: "contents",
|
|
226
|
-
role: "none"
|
|
227
|
-
}, children)));
|
|
387
|
+
}, children));
|
|
228
388
|
} finally {
|
|
229
389
|
_effect.f();
|
|
230
390
|
}
|
|
231
391
|
});
|
|
232
|
-
|
|
233
|
-
var
|
|
234
|
-
var _effect =
|
|
392
|
+
ListboxOption.displayName = LISTBOX_OPTION_NAME;
|
|
393
|
+
var ListboxOptionLabel = /* @__PURE__ */ forwardRef3(({ children, classNames, ...rootProps }, forwardedRef) => {
|
|
394
|
+
var _effect = _useSignals3();
|
|
235
395
|
try {
|
|
236
|
-
return /* @__PURE__ */
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
...props,
|
|
396
|
+
return /* @__PURE__ */ React3.createElement("span", {
|
|
397
|
+
...rootProps,
|
|
398
|
+
className: mx3("grow truncate", classNames),
|
|
240
399
|
ref: forwardedRef
|
|
241
|
-
})
|
|
400
|
+
}, children);
|
|
242
401
|
} finally {
|
|
243
402
|
_effect.f();
|
|
244
403
|
}
|
|
245
404
|
});
|
|
246
|
-
|
|
247
|
-
var
|
|
248
|
-
var
|
|
249
|
-
var _effect = _useSignals2();
|
|
405
|
+
ListboxOptionLabel.displayName = LISTBOX_OPTION_LABEL_NAME;
|
|
406
|
+
var ListboxOptionIndicator = /* @__PURE__ */ forwardRef3((props, forwardedRef) => {
|
|
407
|
+
var _effect = _useSignals3();
|
|
250
408
|
try {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
...
|
|
409
|
+
const { __listboxOptionScope, classNames, ...rootProps } = props;
|
|
410
|
+
const { isSelected } = useListboxOptionContext(LISTBOX_OPTION_INDICATOR_NAME, __listboxOptionScope);
|
|
411
|
+
return /* @__PURE__ */ React3.createElement(Icon2, {
|
|
412
|
+
icon: "ph--check--regular",
|
|
413
|
+
...rootProps,
|
|
414
|
+
classNames: mx3(!isSelected && "invisible", classNames),
|
|
256
415
|
ref: forwardedRef
|
|
257
|
-
})
|
|
416
|
+
});
|
|
258
417
|
} finally {
|
|
259
418
|
_effect.f();
|
|
260
419
|
}
|
|
261
420
|
});
|
|
262
|
-
|
|
263
|
-
var
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
Trigger: PopoverComboboxTrigger,
|
|
269
|
-
VirtualTrigger: PopoverComboboxVirtualTrigger,
|
|
270
|
-
Input: PopoverComboboxInput,
|
|
271
|
-
List: PopoverComboboxList,
|
|
272
|
-
Item: PopoverComboboxItem,
|
|
273
|
-
Arrow: PopoverComboboxArrow,
|
|
274
|
-
Empty: PopoverComboboxEmpty
|
|
421
|
+
ListboxOptionIndicator.displayName = LISTBOX_OPTION_INDICATOR_NAME;
|
|
422
|
+
var Listbox = {
|
|
423
|
+
Root: ListboxRoot,
|
|
424
|
+
Option: ListboxOption,
|
|
425
|
+
OptionLabel: ListboxOptionLabel,
|
|
426
|
+
OptionIndicator: ListboxOptionIndicator
|
|
275
427
|
};
|
|
276
|
-
|
|
277
|
-
// src/translations.ts
|
|
278
|
-
var translationKey = "react-ui-searchlist";
|
|
279
|
-
var translations = [
|
|
280
|
-
{
|
|
281
|
-
"en-US": {
|
|
282
|
-
[translationKey]: {}
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
];
|
|
286
428
|
export {
|
|
287
429
|
Combobox,
|
|
288
|
-
|
|
430
|
+
Listbox,
|
|
289
431
|
SearchList,
|
|
432
|
+
commandItem,
|
|
433
|
+
createListboxScope,
|
|
434
|
+
searchListItem,
|
|
290
435
|
translationKey,
|
|
291
|
-
translations
|
|
436
|
+
translations,
|
|
437
|
+
useListboxContext
|
|
292
438
|
};
|
|
293
439
|
//# sourceMappingURL=index.mjs.map
|