@ledgerhq/lumen-ui-react 0.1.16 → 0.1.17
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/ai-rules/RULES.md +1 -1
- package/dist/index.js +148 -142
- package/dist/lib/Components/BaseInput/BaseInput.d.ts.map +1 -1
- package/dist/lib/Components/BaseInput/BaseInput.js +70 -77
- package/dist/lib/Components/MediaImage/MediaImage.d.ts +19 -0
- package/dist/lib/Components/MediaImage/MediaImage.d.ts.map +1 -0
- package/dist/lib/Components/MediaImage/MediaImage.js +75 -0
- package/dist/lib/Components/MediaImage/index.d.ts +3 -0
- package/dist/lib/Components/MediaImage/index.d.ts.map +1 -0
- package/dist/lib/Components/MediaImage/types.d.ts +38 -0
- package/dist/lib/Components/MediaImage/types.d.ts.map +1 -0
- package/dist/lib/Components/SearchInput/SearchInput.d.ts +1 -1
- package/dist/lib/Components/SearchInput/SearchInput.d.ts.map +1 -1
- package/dist/lib/Components/SearchInput/SearchInput.js +24 -20
- package/dist/lib/Components/SearchInput/types.d.ts +1 -1
- package/dist/lib/Components/SearchInput/types.d.ts.map +1 -1
- package/dist/lib/Components/Select/Select.d.ts +27 -12
- package/dist/lib/Components/Select/Select.d.ts.map +1 -1
- package/dist/lib/Components/Select/Select.js +356 -202
- package/dist/lib/Components/Select/SelectContext.d.ts +3 -1
- package/dist/lib/Components/Select/SelectContext.d.ts.map +1 -1
- package/dist/lib/Components/Select/index.d.ts +1 -1
- package/dist/lib/Components/Select/index.d.ts.map +1 -1
- package/dist/lib/Components/Select/types.d.ts +171 -140
- package/dist/lib/Components/Select/types.d.ts.map +1 -1
- package/dist/lib/Components/Select/useSelectItems/index.d.ts +2 -0
- package/dist/lib/Components/Select/useSelectItems/index.d.ts.map +1 -0
- package/dist/lib/Components/Select/useSelectItems/useSelectItems.d.ts +30 -0
- package/dist/lib/Components/Select/useSelectItems/useSelectItems.d.ts.map +1 -0
- package/dist/lib/Components/Select/useSelectItems/useSelectItems.js +42 -0
- package/dist/lib/Components/Select/utils/groupItems.d.ts +13 -0
- package/dist/lib/Components/Select/utils/groupItems.d.ts.map +1 -0
- package/dist/lib/Components/Select/utils/groupItems.js +16 -0
- package/dist/lib/Components/Select/utils/index.d.ts +2 -0
- package/dist/lib/Components/Select/utils/index.d.ts.map +1 -0
- package/dist/lib/Components/index.d.ts +1 -0
- package/dist/lib/Components/index.d.ts.map +1 -1
- package/dist/libs/utils-shared/dist/index.js +151 -124
- package/dist/node_modules/@base-ui/react/esm/combobox/chips/ComboboxChipsContext.js +10 -0
- package/dist/node_modules/@base-ui/react/esm/combobox/collection/ComboboxCollection.js +17 -0
- package/dist/node_modules/@base-ui/react/esm/combobox/collection/GroupCollectionContext.js +23 -0
- package/dist/node_modules/@base-ui/react/esm/combobox/empty/ComboboxEmpty.js +26 -0
- package/dist/node_modules/@base-ui/react/esm/combobox/group/ComboboxGroup.js +34 -0
- package/dist/node_modules/@base-ui/react/esm/combobox/group/ComboboxGroupContext.js +14 -0
- package/dist/node_modules/@base-ui/react/esm/combobox/group-label/ComboboxGroupLabel.js +27 -0
- package/dist/node_modules/@base-ui/react/esm/combobox/input/ComboboxInput.js +221 -0
- package/dist/node_modules/@base-ui/react/esm/combobox/item/ComboboxItem.js +113 -0
- package/dist/node_modules/@base-ui/react/esm/combobox/item/ComboboxItemContext.js +14 -0
- package/dist/node_modules/@base-ui/react/esm/combobox/item-indicator/ComboboxItemIndicator.js +52 -0
- package/dist/node_modules/@base-ui/react/esm/combobox/list/ComboboxList.js +65 -0
- package/dist/node_modules/@base-ui/react/esm/combobox/popup/ComboboxPopup.js +76 -0
- package/dist/node_modules/@base-ui/react/esm/combobox/portal/ComboboxPortal.js +24 -0
- package/dist/node_modules/@base-ui/react/esm/combobox/portal/ComboboxPortalContext.js +14 -0
- package/dist/node_modules/@base-ui/react/esm/combobox/positioner/ComboboxPositioner.js +102 -0
- package/dist/node_modules/@base-ui/react/esm/combobox/positioner/ComboboxPositionerContext.js +14 -0
- package/dist/node_modules/@base-ui/react/esm/combobox/root/AriaCombobox.js +596 -0
- package/dist/node_modules/@base-ui/react/esm/combobox/root/ComboboxRoot.js +23 -0
- package/dist/node_modules/@base-ui/react/esm/combobox/root/ComboboxRootContext.js +41 -0
- package/dist/node_modules/@base-ui/react/esm/combobox/root/utils/constants.js +8 -0
- package/dist/node_modules/@base-ui/react/esm/combobox/root/utils/index.js +23 -0
- package/dist/node_modules/@base-ui/react/esm/combobox/root/utils/useFilter.js +43 -0
- package/dist/node_modules/@base-ui/react/esm/combobox/row/ComboboxRowContext.js +10 -0
- package/dist/node_modules/@base-ui/react/esm/combobox/store.js +74 -0
- package/dist/node_modules/@base-ui/react/esm/combobox/trigger/ComboboxTrigger.js +135 -0
- package/dist/node_modules/@base-ui/react/esm/combobox/utils/ComboboxInternalDismissButton.js +32 -0
- package/dist/node_modules/@base-ui/react/esm/combobox/utils/stateAttributesMapping.js +15 -0
- package/dist/node_modules/@base-ui/react/esm/combobox/value/ComboboxValue.js +19 -0
- package/dist/node_modules/@base-ui/react/esm/composite/list/CompositeList.js +81 -0
- package/dist/node_modules/@base-ui/react/esm/composite/list/CompositeListContext.js +23 -0
- package/dist/node_modules/@base-ui/react/esm/composite/list/useCompositeListItem.js +55 -0
- package/dist/node_modules/@base-ui/react/esm/field/control/FieldControlDataAttributes.js +6 -0
- package/dist/node_modules/@base-ui/react/esm/field/root/FieldRootContext.js +53 -0
- package/dist/node_modules/@base-ui/react/esm/field/useField.js +51 -0
- package/dist/node_modules/@base-ui/react/esm/field/utils/constants.js +37 -0
- package/dist/node_modules/@base-ui/react/esm/field/utils/getCombinedFieldValidityData.js +12 -0
- package/dist/node_modules/@base-ui/react/esm/floating-ui-react/hooks/useListNavigation.js +287 -0
- package/dist/node_modules/@base-ui/react/esm/floating-ui-react/hooks/useTypeahead.js +71 -0
- package/dist/node_modules/@base-ui/react/esm/floating-ui-react/utils/composite.js +218 -4
- package/dist/node_modules/@base-ui/react/esm/floating-ui-react/utils/constants.js +7 -3
- package/dist/node_modules/@base-ui/react/esm/floating-ui-react/utils/element.js +3 -3
- package/dist/node_modules/@base-ui/react/esm/form/FormContext.js +23 -0
- package/dist/node_modules/@base-ui/react/esm/labelable-provider/LabelableContext.js +19 -0
- package/dist/node_modules/@base-ui/react/esm/labelable-provider/useLabelableId.js +44 -0
- package/dist/node_modules/@base-ui/react/esm/utils/constants.js +11 -8
- package/dist/node_modules/@base-ui/react/esm/utils/createBaseUIEventDetails.js +22 -13
- package/dist/node_modules/@base-ui/react/esm/utils/getPseudoElementBounds.js +18 -0
- package/dist/node_modules/@base-ui/react/esm/utils/itemEquality.js +20 -0
- package/dist/node_modules/@base-ui/react/esm/utils/reason-parts.js +13 -6
- package/dist/node_modules/@base-ui/react/esm/utils/resolveAriaLabelledBy.js +6 -0
- package/dist/node_modules/@base-ui/react/esm/utils/resolveValueLabel.js +73 -0
- package/dist/node_modules/@base-ui/react/esm/utils/serializeValue.js +14 -0
- package/dist/node_modules/@base-ui/utils/esm/detectBrowser.js +8 -7
- package/dist/node_modules/@base-ui/utils/esm/empty.js +3 -2
- package/dist/node_modules/@base-ui/utils/esm/useControlled.js +31 -0
- package/dist/node_modules/@base-ui/utils/esm/visuallyHidden.js +5 -1
- package/dist/package.json +1 -2
- package/package.json +1 -2
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import * as x from "react";
|
|
2
|
+
import { useStableCallback as he } from "../../../../utils/esm/useStableCallback.js";
|
|
3
|
+
import { isAndroid as be, isFirefox as N } from "../../../../utils/esm/detectBrowser.js";
|
|
4
|
+
import { useBaseUiId as ye } from "../../utils/useBaseUiId.js";
|
|
5
|
+
import { useRenderElement as ve } from "../../utils/useRenderElement.js";
|
|
6
|
+
import { useComboboxRootContext as Ce, useComboboxDerivedItemsContext as ke, useComboboxInputValueContext as Re } from "../root/ComboboxRootContext.js";
|
|
7
|
+
import { triggerStateAttributesMapping as Ee } from "../utils/stateAttributesMapping.js";
|
|
8
|
+
import { selectors as o } from "../store.js";
|
|
9
|
+
import { useFieldRootContext as Ae } from "../../field/root/FieldRootContext.js";
|
|
10
|
+
import { DEFAULT_FIELD_STATE_ATTRIBUTES as Te } from "../../field/utils/constants.js";
|
|
11
|
+
import { useLabelableContext as De } from "../../labelable-provider/LabelableContext.js";
|
|
12
|
+
import { useComboboxChipsContext as Ve } from "../chips/ComboboxChipsContext.js";
|
|
13
|
+
import { useComboboxPositionerContext as Pe } from "../positioner/ComboboxPositionerContext.js";
|
|
14
|
+
import { createChangeEventDetails as c } from "../../utils/createBaseUIEventDetails.js";
|
|
15
|
+
import { useDirection as Se } from "../../direction-provider/DirectionContext.js";
|
|
16
|
+
import { resolveAriaLabelledBy as Oe } from "../../utils/resolveAriaLabelledBy.js";
|
|
17
|
+
import { ComboboxInternalDismissButton as we } from "../utils/ComboboxInternalDismissButton.js";
|
|
18
|
+
import { jsxs as Be, jsx as Le } from "react/jsx-runtime";
|
|
19
|
+
import { useStore as i } from "../../../../utils/esm/store/useStore.js";
|
|
20
|
+
import { none as V, escapeKey as Me, inputClear as q, inputChange as k } from "../../utils/reason-parts.js";
|
|
21
|
+
import { stopEvent as P } from "../../floating-ui-react/utils/event.js";
|
|
22
|
+
const Fe = /* @__PURE__ */ x.forwardRef(function(R, _) {
|
|
23
|
+
const {
|
|
24
|
+
render: Ke,
|
|
25
|
+
className: Ne,
|
|
26
|
+
disabled: j = !1,
|
|
27
|
+
id: U,
|
|
28
|
+
...S
|
|
29
|
+
} = R, {
|
|
30
|
+
state: W,
|
|
31
|
+
disabled: z,
|
|
32
|
+
setTouched: G,
|
|
33
|
+
setFocused: O,
|
|
34
|
+
validationMode: J,
|
|
35
|
+
validation: E
|
|
36
|
+
} = Ae(), {
|
|
37
|
+
labelId: Q
|
|
38
|
+
} = De(), d = Ve(), b = !!Pe(!0), e = Ce(), {
|
|
39
|
+
filteredItems: X
|
|
40
|
+
} = ke(), w = Re(), Y = Se(), B = i(e, o.required), Z = i(e, o.disabled), f = i(e, o.readOnly), L = i(e, o.name), m = i(e, o.selectionMode), M = i(e, o.autoHighlight), $ = i(e, o.inputProps), ee = i(e, o.triggerProps), g = i(e, o.open), F = i(e, o.mounted), r = i(e, o.selectedValue), te = i(e, o.popupSide), ne = i(e, o.positionerElement), oe = i(e, o.id), y = i(e, o.inline), ie = i(e, o.modal), v = !!M, se = F && ne ? te : null, h = z || Z || j, re = X.length === 0, H = b || y, ae = !H || ie, le = ye(U ?? (H ? void 0 : oe)), ue = Oe(Q, void 0), ce = b ? Te : W, [de, A] = x.useState(null), C = x.useRef(!1), K = x.useRef(null), T = x.useRef(!1), pe = he((t) => {
|
|
41
|
+
const n = b || e.state.inline;
|
|
42
|
+
n && !e.state.hasInputValue && e.state.setInputValue("", c(V)), e.update({
|
|
43
|
+
inputElement: t,
|
|
44
|
+
inputInsidePopup: n
|
|
45
|
+
});
|
|
46
|
+
}), fe = b || !E ? S : E.getValidationProps(S), me = {
|
|
47
|
+
...ce,
|
|
48
|
+
open: g,
|
|
49
|
+
disabled: h,
|
|
50
|
+
readOnly: f,
|
|
51
|
+
popupSide: se,
|
|
52
|
+
listEmpty: re
|
|
53
|
+
};
|
|
54
|
+
function Ie(t) {
|
|
55
|
+
if (!d)
|
|
56
|
+
return;
|
|
57
|
+
let n;
|
|
58
|
+
const {
|
|
59
|
+
highlightedChipIndex: a
|
|
60
|
+
} = d;
|
|
61
|
+
if (a !== void 0) {
|
|
62
|
+
if (t.key === "ArrowLeft")
|
|
63
|
+
t.preventDefault(), a > 0 ? n = a - 1 : n = void 0;
|
|
64
|
+
else if (t.key === "ArrowRight")
|
|
65
|
+
t.preventDefault(), a < r.length - 1 ? n = a + 1 : n = void 0;
|
|
66
|
+
else if (t.key === "Backspace" || t.key === "Delete") {
|
|
67
|
+
t.preventDefault();
|
|
68
|
+
const l = a >= r.length - 1 ? r.length - 2 : a;
|
|
69
|
+
n = l >= 0 ? l : void 0, e.state.setIndices({
|
|
70
|
+
activeIndex: null,
|
|
71
|
+
selectedIndex: null,
|
|
72
|
+
type: "keyboard"
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return n;
|
|
76
|
+
}
|
|
77
|
+
return t.key === "ArrowLeft" && (t.currentTarget.selectionStart ?? 0) === 0 && r.length > 0 ? (t.preventDefault(), n = Math.max(r.length - 1, 0)) : t.key === "Backspace" && t.currentTarget.value === "" && r.length > 0 && (e.state.setIndices({
|
|
78
|
+
activeIndex: null,
|
|
79
|
+
selectedIndex: null,
|
|
80
|
+
type: "keyboard"
|
|
81
|
+
}), t.preventDefault()), n;
|
|
82
|
+
}
|
|
83
|
+
const xe = ve("input", R, {
|
|
84
|
+
state: me,
|
|
85
|
+
ref: [_, e.state.inputRef, pe],
|
|
86
|
+
props: [$, ee, {
|
|
87
|
+
type: "text",
|
|
88
|
+
value: R.value ?? de ?? w,
|
|
89
|
+
"aria-readonly": f || void 0,
|
|
90
|
+
"aria-required": B || void 0,
|
|
91
|
+
"aria-labelledby": ue,
|
|
92
|
+
disabled: h,
|
|
93
|
+
readOnly: f,
|
|
94
|
+
required: m === "none" ? B : void 0,
|
|
95
|
+
...m === "none" && L && {
|
|
96
|
+
name: L
|
|
97
|
+
},
|
|
98
|
+
id: le,
|
|
99
|
+
onFocus() {
|
|
100
|
+
if (O(!0), !y || !T.current)
|
|
101
|
+
return;
|
|
102
|
+
T.current = !1;
|
|
103
|
+
const t = K.current;
|
|
104
|
+
t == null || // `valuesRef` can be sparse, so guard against restoring a removed slot.
|
|
105
|
+
!Object.hasOwn(e.state.valuesRef.current, t) || e.state.setIndices({
|
|
106
|
+
activeIndex: t
|
|
107
|
+
});
|
|
108
|
+
},
|
|
109
|
+
onBlur() {
|
|
110
|
+
G(!0), O(!1);
|
|
111
|
+
const t = e.state.activeIndex;
|
|
112
|
+
if (y && t !== null && M !== "always" && (K.current = t, T.current = !0, e.state.setIndices({
|
|
113
|
+
activeIndex: null
|
|
114
|
+
})), J === "onBlur") {
|
|
115
|
+
const n = m === "none" ? w : r;
|
|
116
|
+
E.commit(n);
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
onCompositionStart(t) {
|
|
120
|
+
be || (C.current = !0, A(t.currentTarget.value));
|
|
121
|
+
},
|
|
122
|
+
onCompositionEnd(t) {
|
|
123
|
+
C.current = !1;
|
|
124
|
+
const n = t.currentTarget.value;
|
|
125
|
+
A(null), e.state.setInputValue(n, c(k, t.nativeEvent));
|
|
126
|
+
},
|
|
127
|
+
onChange(t) {
|
|
128
|
+
const n = t.nativeEvent.inputType, a = !n || n === "insertReplacementText", l = C.current || !a;
|
|
129
|
+
if (C.current) {
|
|
130
|
+
const u = t.currentTarget.value;
|
|
131
|
+
A(u), u === "" && !e.state.openOnInputClick && !e.state.inputInsidePopup && e.state.setOpen(!1, c(q, t.nativeEvent));
|
|
132
|
+
const p = u.trim(), ge = v && p !== "";
|
|
133
|
+
!f && !h && p && l && (e.state.setOpen(!0, c(k, t.nativeEvent)), v || e.state.setIndices({
|
|
134
|
+
activeIndex: null,
|
|
135
|
+
selectedIndex: null,
|
|
136
|
+
type: e.state.keyboardActiveRef.current ? "keyboard" : "pointer"
|
|
137
|
+
})), g && e.state.activeIndex !== null && !ge && e.state.setIndices({
|
|
138
|
+
activeIndex: null,
|
|
139
|
+
selectedIndex: null,
|
|
140
|
+
type: e.state.keyboardActiveRef.current ? "keyboard" : "pointer"
|
|
141
|
+
});
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
e.state.setInputValue(t.currentTarget.value, c(k, t.nativeEvent));
|
|
145
|
+
const D = t.currentTarget.value === "", I = c(q, t.nativeEvent);
|
|
146
|
+
D && !e.state.inputInsidePopup && (m === "single" && e.state.setSelectedValue(null, I), e.state.openOnInputClick || e.state.setOpen(!1, I));
|
|
147
|
+
const s = t.currentTarget.value.trim();
|
|
148
|
+
!f && !h && s && l && (e.state.setOpen(!0, c(k, t.nativeEvent)), v || e.state.setIndices({
|
|
149
|
+
activeIndex: null,
|
|
150
|
+
selectedIndex: null,
|
|
151
|
+
type: e.state.keyboardActiveRef.current ? "keyboard" : "pointer"
|
|
152
|
+
})), g && e.state.activeIndex !== null && !v && e.state.setIndices({
|
|
153
|
+
activeIndex: null,
|
|
154
|
+
selectedIndex: null,
|
|
155
|
+
type: e.state.keyboardActiveRef.current ? "keyboard" : "pointer"
|
|
156
|
+
});
|
|
157
|
+
},
|
|
158
|
+
onKeyDown(t) {
|
|
159
|
+
if (h || f || t.ctrlKey || t.shiftKey || t.altKey || t.metaKey)
|
|
160
|
+
return;
|
|
161
|
+
e.state.keyboardActiveRef.current = !0;
|
|
162
|
+
const n = t.currentTarget, a = n.scrollWidth - n.clientWidth, l = Y === "rtl";
|
|
163
|
+
if (t.key === "Home") {
|
|
164
|
+
P(t);
|
|
165
|
+
const s = N && l ? n.value.length : 0;
|
|
166
|
+
n.setSelectionRange(s, s), n.scrollLeft = 0;
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
if (t.key === "End") {
|
|
170
|
+
P(t);
|
|
171
|
+
const s = N && l ? 0 : n.value.length;
|
|
172
|
+
n.setSelectionRange(s, s), n.scrollLeft = l ? -a : a;
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
if (!F && t.key === "Escape") {
|
|
176
|
+
const s = m === "multiple" && Array.isArray(r) ? r.length === 0 : r === null, u = c(Me, t.nativeEvent), p = m === "multiple" ? [] : null;
|
|
177
|
+
e.state.setInputValue("", u), e.state.setSelectedValue(p, u), !s && !e.state.inline && !u.isPropagationAllowed && t.stopPropagation();
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
if (d && t.key === "Backspace" && n.value === "" && d.highlightedChipIndex === void 0 && Array.isArray(r) && r.length > 0) {
|
|
181
|
+
const s = r.slice(0, -1);
|
|
182
|
+
e.state.setIndices({
|
|
183
|
+
activeIndex: null,
|
|
184
|
+
selectedIndex: null,
|
|
185
|
+
type: e.state.keyboardActiveRef.current ? "keyboard" : "pointer"
|
|
186
|
+
}), e.state.setSelectedValue(s, c(V, t.nativeEvent));
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
const D = d?.highlightedChipIndex !== void 0, I = Ie(t);
|
|
190
|
+
if (d?.setHighlightedChipIndex(I), I !== void 0 ? d?.chipsRef.current[I]?.focus() : D && e.state.inputRef.current?.focus(), t.which !== 229 && t.key === "Enter" && g) {
|
|
191
|
+
const s = e.state.activeIndex, u = t.nativeEvent;
|
|
192
|
+
if (s === null) {
|
|
193
|
+
if (y)
|
|
194
|
+
return;
|
|
195
|
+
e.state.setOpen(!1, c(V, u));
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
P(t);
|
|
199
|
+
const p = e.state.listRef.current[s];
|
|
200
|
+
p && (e.state.selectionEventRef.current = u, p.click(), e.state.selectionEventRef.current = null);
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
onPointerMove() {
|
|
204
|
+
e.state.keyboardActiveRef.current = !1;
|
|
205
|
+
},
|
|
206
|
+
onPointerDown() {
|
|
207
|
+
e.state.keyboardActiveRef.current = !1;
|
|
208
|
+
}
|
|
209
|
+
}, fe],
|
|
210
|
+
stateAttributesMapping: Ee
|
|
211
|
+
});
|
|
212
|
+
return /* @__PURE__ */ Be(x.Fragment, {
|
|
213
|
+
children: [g && ae && /* @__PURE__ */ Le(we, {
|
|
214
|
+
ref: e.state.startDismissRef
|
|
215
|
+
}), xe]
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
process.env.NODE_ENV !== "production" && (Fe.displayName = "ComboboxInput");
|
|
219
|
+
export {
|
|
220
|
+
Fe as ComboboxInput
|
|
221
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import * as l from "react";
|
|
2
|
+
import * as j from "react-dom";
|
|
3
|
+
import { useIsoLayoutEffect as C } from "../../../../utils/esm/useIsoLayoutEffect.js";
|
|
4
|
+
import { useComboboxRootContext as U, useComboboxDerivedItemsContext as W } from "../root/ComboboxRootContext.js";
|
|
5
|
+
import { useCompositeListItem as _, IndexGuessBehavior as H } from "../../composite/list/useCompositeListItem.js";
|
|
6
|
+
import { useRenderElement as J } from "../../utils/useRenderElement.js";
|
|
7
|
+
import { ComboboxItemContext as K } from "./ComboboxItemContext.js";
|
|
8
|
+
import { selectors as s } from "../store.js";
|
|
9
|
+
import { useComboboxRowContext as Q } from "../row/ComboboxRowContext.js";
|
|
10
|
+
import { findItemIndex as X, compareItemEquality as Y } from "../../utils/itemEquality.js";
|
|
11
|
+
import { jsx as Z } from "react/jsx-runtime";
|
|
12
|
+
import { useButton as ee } from "../../use-button/useButton.js";
|
|
13
|
+
import { useStore as r } from "../../../../utils/esm/store/useStore.js";
|
|
14
|
+
const te = /* @__PURE__ */ l.memo(/* @__PURE__ */ l.forwardRef(function(V, O) {
|
|
15
|
+
const {
|
|
16
|
+
render: ne,
|
|
17
|
+
className: se,
|
|
18
|
+
value: i = null,
|
|
19
|
+
index: a,
|
|
20
|
+
disabled: d = !1,
|
|
21
|
+
nativeButton: M = !1,
|
|
22
|
+
...w
|
|
23
|
+
} = V, m = l.useRef(!1), p = l.useRef(null), x = _({
|
|
24
|
+
index: a,
|
|
25
|
+
textRef: p,
|
|
26
|
+
indexGuessBehavior: H.GuessFromOrder
|
|
27
|
+
}), e = U(), B = Q(), {
|
|
28
|
+
flatFilteredItems: q,
|
|
29
|
+
hasItems: f
|
|
30
|
+
} = W(), E = r(e, s.open), b = r(e, s.selectionMode), P = r(e, s.readOnly), I = r(e, s.virtualized), v = r(e, s.isItemEqualToValue), S = b !== "none", o = a ?? (I ? X(q, i, v) : x.index), u = x.index !== -1, g = r(e, s.id), R = r(e, s.isActive, o), N = r(e, s.isSelected, i), A = r(e, s.getItemProps), y = l.useRef(null), F = g != null && u ? `${g}-${o}` : void 0, c = N && S;
|
|
31
|
+
C(() => {
|
|
32
|
+
if (!(u && (I || a != null)))
|
|
33
|
+
return;
|
|
34
|
+
const n = e.state.listRef.current;
|
|
35
|
+
return n[o] = y.current, () => {
|
|
36
|
+
delete n[o];
|
|
37
|
+
};
|
|
38
|
+
}, [u, I, o, a, e]), C(() => {
|
|
39
|
+
if (!u || f)
|
|
40
|
+
return;
|
|
41
|
+
const t = e.state.valuesRef.current;
|
|
42
|
+
return t[o] = i, b !== "none" && e.state.allValuesRef.current.push(i), () => {
|
|
43
|
+
delete t[o];
|
|
44
|
+
};
|
|
45
|
+
}, [u, f, o, i, e, b]), C(() => {
|
|
46
|
+
if (!E) {
|
|
47
|
+
m.current = !1;
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (!u || f)
|
|
51
|
+
return;
|
|
52
|
+
const t = e.state.selectedValue, n = Array.isArray(t) ? t[t.length - 1] : t;
|
|
53
|
+
Y(i, n, v) && e.set("selectedIndex", o);
|
|
54
|
+
}, [u, f, E, e, o, i, v]);
|
|
55
|
+
const G = {
|
|
56
|
+
disabled: d,
|
|
57
|
+
selected: c,
|
|
58
|
+
highlighted: R
|
|
59
|
+
}, h = A({
|
|
60
|
+
active: R,
|
|
61
|
+
selected: c
|
|
62
|
+
});
|
|
63
|
+
h.id = void 0, h.onFocus = void 0;
|
|
64
|
+
const {
|
|
65
|
+
getButtonProps: k,
|
|
66
|
+
buttonRef: z
|
|
67
|
+
} = ee({
|
|
68
|
+
disabled: d,
|
|
69
|
+
focusableWhenDisabled: !0,
|
|
70
|
+
native: M,
|
|
71
|
+
composite: !0
|
|
72
|
+
});
|
|
73
|
+
function D(t) {
|
|
74
|
+
function n() {
|
|
75
|
+
e.state.handleSelection(t, i);
|
|
76
|
+
}
|
|
77
|
+
e.state.submitOnItemClick ? (j.flushSync(n), e.state.requestSubmit()) : n();
|
|
78
|
+
}
|
|
79
|
+
const L = {
|
|
80
|
+
id: F,
|
|
81
|
+
role: B ? "gridcell" : "option",
|
|
82
|
+
"aria-selected": S ? c : void 0,
|
|
83
|
+
// Focusable items steal focus from the input upon mouseup.
|
|
84
|
+
// Warn if the user renders a natively focusable element like `<button>`,
|
|
85
|
+
// as it should be a `<div>` instead.
|
|
86
|
+
tabIndex: void 0,
|
|
87
|
+
onPointerDownCapture(t) {
|
|
88
|
+
m.current = !0, t.preventDefault();
|
|
89
|
+
},
|
|
90
|
+
onClick(t) {
|
|
91
|
+
d || P || D(t.nativeEvent);
|
|
92
|
+
},
|
|
93
|
+
onMouseUp(t) {
|
|
94
|
+
const n = m.current;
|
|
95
|
+
m.current = !1, !(d || P || t.button !== 0 || n || !R) && D(t.nativeEvent);
|
|
96
|
+
}
|
|
97
|
+
}, T = J("div", V, {
|
|
98
|
+
ref: [z, O, x.ref, y],
|
|
99
|
+
state: G,
|
|
100
|
+
props: [h, L, w, k]
|
|
101
|
+
}), $ = l.useMemo(() => ({
|
|
102
|
+
selected: c,
|
|
103
|
+
textRef: p
|
|
104
|
+
}), [c, p]);
|
|
105
|
+
return /* @__PURE__ */ Z(K.Provider, {
|
|
106
|
+
value: $,
|
|
107
|
+
children: T
|
|
108
|
+
});
|
|
109
|
+
}));
|
|
110
|
+
process.env.NODE_ENV !== "production" && (te.displayName = "ComboboxItem");
|
|
111
|
+
export {
|
|
112
|
+
te as ComboboxItem
|
|
113
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import n from "../../../../utils/esm/formatErrorMessage.js";
|
|
2
|
+
import * as t from "react";
|
|
3
|
+
const e = /* @__PURE__ */ t.createContext(void 0);
|
|
4
|
+
process.env.NODE_ENV !== "production" && (e.displayName = "ComboboxItemContext");
|
|
5
|
+
function m() {
|
|
6
|
+
const o = t.useContext(e);
|
|
7
|
+
if (!o)
|
|
8
|
+
throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: ComboboxItemContext is missing. ComboboxItem parts must be placed within <Combobox.Item>." : n(19));
|
|
9
|
+
return o;
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
e as ComboboxItemContext,
|
|
13
|
+
m as useComboboxItemContext
|
|
14
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as o from "react";
|
|
2
|
+
import { useComboboxItemContext as d } from "../item/ComboboxItemContext.js";
|
|
3
|
+
import { useTransitionStatus as l } from "../../utils/useTransitionStatus.js";
|
|
4
|
+
import { useOpenChangeComplete as b } from "../../utils/useOpenChangeComplete.js";
|
|
5
|
+
import { useRenderElement as I } from "../../utils/useRenderElement.js";
|
|
6
|
+
import { transitionStatusMapping as C } from "../../utils/stateAttributesMapping.js";
|
|
7
|
+
import { jsx as R } from "react/jsx-runtime";
|
|
8
|
+
const x = /* @__PURE__ */ o.forwardRef(function(e, r) {
|
|
9
|
+
const s = e.keepMounted ?? !1, {
|
|
10
|
+
selected: i
|
|
11
|
+
} = d();
|
|
12
|
+
return s || i ? /* @__PURE__ */ R(p, {
|
|
13
|
+
...e,
|
|
14
|
+
ref: r
|
|
15
|
+
}) : null;
|
|
16
|
+
});
|
|
17
|
+
process.env.NODE_ENV !== "production" && (x.displayName = "ComboboxItemIndicator");
|
|
18
|
+
const p = /* @__PURE__ */ o.memo(/* @__PURE__ */ o.forwardRef((n, e) => {
|
|
19
|
+
const {
|
|
20
|
+
render: r,
|
|
21
|
+
className: s,
|
|
22
|
+
keepMounted: i,
|
|
23
|
+
...a
|
|
24
|
+
} = n, {
|
|
25
|
+
selected: t
|
|
26
|
+
} = d(), m = o.useRef(null), {
|
|
27
|
+
transitionStatus: u,
|
|
28
|
+
setMounted: c
|
|
29
|
+
} = l(t), f = I("span", n, {
|
|
30
|
+
ref: [e, m],
|
|
31
|
+
state: {
|
|
32
|
+
selected: t,
|
|
33
|
+
transitionStatus: u
|
|
34
|
+
},
|
|
35
|
+
props: [{
|
|
36
|
+
"aria-hidden": !0,
|
|
37
|
+
children: "✔️"
|
|
38
|
+
}, a],
|
|
39
|
+
stateAttributesMapping: C
|
|
40
|
+
});
|
|
41
|
+
return b({
|
|
42
|
+
open: t,
|
|
43
|
+
ref: m,
|
|
44
|
+
onComplete() {
|
|
45
|
+
t || c(!1);
|
|
46
|
+
}
|
|
47
|
+
}), f;
|
|
48
|
+
}));
|
|
49
|
+
process.env.NODE_ENV !== "production" && (p.displayName = "Inner");
|
|
50
|
+
export {
|
|
51
|
+
x as ComboboxItemIndicator
|
|
52
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import * as a from "react";
|
|
2
|
+
import { useStableCallback as f } from "../../../../utils/esm/useStableCallback.js";
|
|
3
|
+
import { useRenderElement as A } from "../../utils/useRenderElement.js";
|
|
4
|
+
import { useComboboxRootContext as K, useComboboxFloatingContext as _, useComboboxDerivedItemsContext as j } from "../root/ComboboxRootContext.js";
|
|
5
|
+
import { useComboboxPositionerContext as B } from "../positioner/ComboboxPositionerContext.js";
|
|
6
|
+
import { selectors as t } from "../store.js";
|
|
7
|
+
import { ComboboxCollection as F } from "../collection/ComboboxCollection.js";
|
|
8
|
+
import { CompositeList as V } from "../../composite/list/CompositeList.js";
|
|
9
|
+
import { jsx as u } from "react/jsx-runtime";
|
|
10
|
+
import { useStore as o } from "../../../../utils/esm/store/useStore.js";
|
|
11
|
+
import { stopEvent as q } from "../../floating-ui-react/utils/event.js";
|
|
12
|
+
const G = /* @__PURE__ */ a.forwardRef(function(r, d) {
|
|
13
|
+
var i;
|
|
14
|
+
const {
|
|
15
|
+
render: J,
|
|
16
|
+
className: Q,
|
|
17
|
+
children: s,
|
|
18
|
+
...p
|
|
19
|
+
} = r, e = K(), b = _(), C = !!B(!0), {
|
|
20
|
+
filteredItems: x
|
|
21
|
+
} = j(), v = o(e, t.items), R = o(e, t.labelsRef), E = o(e, t.listRef), y = o(e, t.selectionMode), g = o(e, t.grid), I = o(e, t.popupProps), h = o(e, t.disabled), P = o(e, t.readOnly), k = o(e, t.virtualized), L = y === "multiple", D = x.length === 0, M = f((n) => {
|
|
22
|
+
e.set("positionerElement", n);
|
|
23
|
+
}), N = f((n) => {
|
|
24
|
+
e.set("listElement", n);
|
|
25
|
+
}), w = a.useMemo(() => typeof s == "function" ? i || (i = /* @__PURE__ */ u(F, {
|
|
26
|
+
children: s
|
|
27
|
+
})) : s, [s]), O = {
|
|
28
|
+
empty: D
|
|
29
|
+
}, S = b.useState("floatingId"), l = A("div", r, {
|
|
30
|
+
state: O,
|
|
31
|
+
ref: [d, N, C ? null : M],
|
|
32
|
+
props: [I, {
|
|
33
|
+
children: w,
|
|
34
|
+
tabIndex: -1,
|
|
35
|
+
id: S,
|
|
36
|
+
role: g ? "grid" : "listbox",
|
|
37
|
+
"aria-multiselectable": L ? "true" : void 0,
|
|
38
|
+
onKeyDown(n) {
|
|
39
|
+
if (!(h || P) && n.key === "Enter") {
|
|
40
|
+
const c = e.state.activeIndex;
|
|
41
|
+
if (c == null)
|
|
42
|
+
return;
|
|
43
|
+
q(n);
|
|
44
|
+
const z = n.nativeEvent, m = e.state.listRef.current[c];
|
|
45
|
+
m && (e.state.selectionEventRef.current = z, m.click(), e.state.selectionEventRef.current = null);
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
onKeyDownCapture() {
|
|
49
|
+
e.state.keyboardActiveRef.current = !0;
|
|
50
|
+
},
|
|
51
|
+
onPointerMoveCapture() {
|
|
52
|
+
e.state.keyboardActiveRef.current = !1;
|
|
53
|
+
}
|
|
54
|
+
}, p]
|
|
55
|
+
});
|
|
56
|
+
return k ? l : /* @__PURE__ */ u(V, {
|
|
57
|
+
elementsRef: E,
|
|
58
|
+
labelsRef: v ? void 0 : R,
|
|
59
|
+
children: l
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
process.env.NODE_ENV !== "production" && (G.displayName = "ComboboxList");
|
|
63
|
+
export {
|
|
64
|
+
G as ComboboxList
|
|
65
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import * as g from "react";
|
|
2
|
+
import { useRenderElement as S } from "../../utils/useRenderElement.js";
|
|
3
|
+
import { useComboboxRootContext as y, useComboboxFloatingContext as N, useComboboxDerivedItemsContext as T } from "../root/ComboboxRootContext.js";
|
|
4
|
+
import { selectors as o } from "../store.js";
|
|
5
|
+
import { popupStateMapping as O } from "../../utils/popupStateMapping.js";
|
|
6
|
+
import { useComboboxPositionerContext as j } from "../positioner/ComboboxPositionerContext.js";
|
|
7
|
+
import { useOpenChangeComplete as H } from "../../utils/useOpenChangeComplete.js";
|
|
8
|
+
import { transitionStatusMapping as w } from "../../utils/stateAttributesMapping.js";
|
|
9
|
+
import { getDisabledMountTransitionStyles as A } from "../../utils/getDisabledMountTransitionStyles.js";
|
|
10
|
+
import { ComboboxInternalDismissButton as B } from "../utils/ComboboxInternalDismissButton.js";
|
|
11
|
+
import { jsx as b, jsxs as V } from "react/jsx-runtime";
|
|
12
|
+
import { FloatingFocusManager as _ } from "../../floating-ui-react/components/FloatingFocusManager.js";
|
|
13
|
+
import { useStore as e } from "../../../../utils/esm/store/useStore.js";
|
|
14
|
+
import { getTarget as k, contains as q } from "../../floating-ui-react/utils/element.js";
|
|
15
|
+
const z = {
|
|
16
|
+
...O,
|
|
17
|
+
...w
|
|
18
|
+
}, G = /* @__PURE__ */ g.forwardRef(function(p, x) {
|
|
19
|
+
const {
|
|
20
|
+
render: K,
|
|
21
|
+
className: L,
|
|
22
|
+
initialFocus: m,
|
|
23
|
+
finalFocus: u,
|
|
24
|
+
...C
|
|
25
|
+
} = p, t = y(), i = j(), F = N(), {
|
|
26
|
+
filteredItems: R
|
|
27
|
+
} = T(), h = e(t, o.mounted), r = e(t, o.open), c = e(t, o.openMethod), l = e(t, o.transitionStatus), n = e(t, o.inputInsidePopup), I = e(t, o.inputElement), D = e(t, o.modal), M = R.length === 0;
|
|
28
|
+
H({
|
|
29
|
+
open: r,
|
|
30
|
+
ref: t.state.popupRef,
|
|
31
|
+
onComplete() {
|
|
32
|
+
r && t.state.onOpenChangeComplete(!0);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
const E = {
|
|
36
|
+
open: r,
|
|
37
|
+
side: i.side,
|
|
38
|
+
align: i.align,
|
|
39
|
+
anchorHidden: i.anchorHidden,
|
|
40
|
+
transitionStatus: l,
|
|
41
|
+
empty: M
|
|
42
|
+
}, v = S("div", p, {
|
|
43
|
+
state: E,
|
|
44
|
+
ref: [x, t.state.popupRef],
|
|
45
|
+
props: [{
|
|
46
|
+
role: n ? "dialog" : "presentation",
|
|
47
|
+
tabIndex: -1,
|
|
48
|
+
onFocus(s) {
|
|
49
|
+
const f = k(s.nativeEvent);
|
|
50
|
+
c !== "touch" && (q(t.state.listElement, f) || f === s.currentTarget) && t.state.inputRef.current?.focus();
|
|
51
|
+
}
|
|
52
|
+
}, A(l), C],
|
|
53
|
+
stateAttributesMapping: z
|
|
54
|
+
}), P = m === void 0 ? n ? (s) => s === "touch" ? t.state.popupRef.current : I : !1 : m;
|
|
55
|
+
let a;
|
|
56
|
+
u != null ? a = u : a = n ? void 0 : !1;
|
|
57
|
+
const d = !n || D;
|
|
58
|
+
return /* @__PURE__ */ b(_, {
|
|
59
|
+
context: F,
|
|
60
|
+
disabled: !h,
|
|
61
|
+
modal: d,
|
|
62
|
+
openInteractionType: c,
|
|
63
|
+
initialFocus: P,
|
|
64
|
+
returnFocus: a,
|
|
65
|
+
getInsideElements: () => [t.state.startDismissRef.current, t.state.endDismissRef.current],
|
|
66
|
+
children: /* @__PURE__ */ V(g.Fragment, {
|
|
67
|
+
children: [v, d && /* @__PURE__ */ b(B, {
|
|
68
|
+
ref: t.state.endDismissRef
|
|
69
|
+
})]
|
|
70
|
+
})
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
process.env.NODE_ENV !== "production" && (G.displayName = "ComboboxPopup");
|
|
74
|
+
export {
|
|
75
|
+
G as ComboboxPopup
|
|
76
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as u from "react";
|
|
2
|
+
import { useComboboxRootContext as a } from "../root/ComboboxRootContext.js";
|
|
3
|
+
import { ComboboxPortalContext as c } from "./ComboboxPortalContext.js";
|
|
4
|
+
import { selectors as t } from "../store.js";
|
|
5
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
6
|
+
import { FloatingPortal as d } from "../../floating-ui-react/components/FloatingPortal.js";
|
|
7
|
+
import { useStore as n } from "../../../../utils/esm/store/useStore.js";
|
|
8
|
+
const p = /* @__PURE__ */ u.forwardRef(function(m, s) {
|
|
9
|
+
const {
|
|
10
|
+
keepMounted: o = !1,
|
|
11
|
+
...f
|
|
12
|
+
} = m, r = a(), l = n(r, t.mounted), i = n(r, t.forceMounted);
|
|
13
|
+
return l || o || i ? /* @__PURE__ */ e(c.Provider, {
|
|
14
|
+
value: o,
|
|
15
|
+
children: /* @__PURE__ */ e(d, {
|
|
16
|
+
ref: s,
|
|
17
|
+
...f
|
|
18
|
+
})
|
|
19
|
+
}) : null;
|
|
20
|
+
});
|
|
21
|
+
process.env.NODE_ENV !== "production" && (p.displayName = "ComboboxPortal");
|
|
22
|
+
export {
|
|
23
|
+
p as ComboboxPortal
|
|
24
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import r from "../../../../utils/esm/formatErrorMessage.js";
|
|
2
|
+
import * as t from "react";
|
|
3
|
+
const e = /* @__PURE__ */ t.createContext(void 0);
|
|
4
|
+
process.env.NODE_ENV !== "production" && (e.displayName = "ComboboxPortalContext");
|
|
5
|
+
function s() {
|
|
6
|
+
const o = t.useContext(e);
|
|
7
|
+
if (o === void 0)
|
|
8
|
+
throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: <Combobox.Portal> is missing." : r(20));
|
|
9
|
+
return o;
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
e as ComboboxPortalContext,
|
|
13
|
+
s as useComboboxPortalContext
|
|
14
|
+
};
|