@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,43 @@
|
|
|
1
|
+
import { stringifyAsLabel as l } from "../../../utils/resolveValueLabel.js";
|
|
2
|
+
const f = /* @__PURE__ */ new Map();
|
|
3
|
+
function h(e) {
|
|
4
|
+
return Array.isArray(e) ? e.map((c) => h(c)).join(",") : e == null ? "" : String(e);
|
|
5
|
+
}
|
|
6
|
+
function m(e = {}) {
|
|
7
|
+
const c = {
|
|
8
|
+
usage: "search",
|
|
9
|
+
sensitivity: "base",
|
|
10
|
+
ignorePunctuation: !0,
|
|
11
|
+
...e
|
|
12
|
+
}, a = `${h(e.locale)}|${JSON.stringify(c)}`, g = f.get(a);
|
|
13
|
+
if (g)
|
|
14
|
+
return g;
|
|
15
|
+
const o = new Intl.Collator(e.locale, c), u = {
|
|
16
|
+
contains(i, t, s) {
|
|
17
|
+
if (!t)
|
|
18
|
+
return !0;
|
|
19
|
+
const n = l(i, s);
|
|
20
|
+
for (let r = 0; r <= n.length - t.length; r += 1)
|
|
21
|
+
if (o.compare(n.slice(r, r + t.length), t) === 0)
|
|
22
|
+
return !0;
|
|
23
|
+
return !1;
|
|
24
|
+
},
|
|
25
|
+
startsWith(i, t, s) {
|
|
26
|
+
if (!t)
|
|
27
|
+
return !0;
|
|
28
|
+
const n = l(i, s);
|
|
29
|
+
return o.compare(n.slice(0, t.length), t) === 0;
|
|
30
|
+
},
|
|
31
|
+
endsWith(i, t, s) {
|
|
32
|
+
if (!t)
|
|
33
|
+
return !0;
|
|
34
|
+
const n = l(i, s), r = t.length;
|
|
35
|
+
return n.length >= r && o.compare(n.slice(n.length - r), t) === 0;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
return f.set(a, u), u;
|
|
39
|
+
}
|
|
40
|
+
const S = m;
|
|
41
|
+
export {
|
|
42
|
+
S as useCoreFilter
|
|
43
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as o from "react";
|
|
2
|
+
const t = /* @__PURE__ */ o.createContext(!1);
|
|
3
|
+
process.env.NODE_ENV !== "production" && (t.displayName = "ComboboxRowContext");
|
|
4
|
+
function e() {
|
|
5
|
+
return o.useContext(t);
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
t as ComboboxRowContext,
|
|
9
|
+
e as useComboboxRowContext
|
|
10
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { compareItemEquality as r } from "../utils/itemEquality.js";
|
|
2
|
+
import { hasNullItemLabel as s } from "../utils/resolveValueLabel.js";
|
|
3
|
+
import { createSelector as t } from "../../../utils/esm/store/createSelector.js";
|
|
4
|
+
const d = {
|
|
5
|
+
id: t((e) => e.id),
|
|
6
|
+
labelId: t((e) => e.labelId),
|
|
7
|
+
query: t((e) => e.query),
|
|
8
|
+
items: t((e) => e.items),
|
|
9
|
+
selectedValue: t((e) => e.selectedValue),
|
|
10
|
+
hasSelectionChips: t((e) => {
|
|
11
|
+
const l = e.selectedValue;
|
|
12
|
+
return Array.isArray(l) && l.length > 0;
|
|
13
|
+
}),
|
|
14
|
+
hasSelectedValue: t((e) => {
|
|
15
|
+
const {
|
|
16
|
+
selectedValue: l,
|
|
17
|
+
selectionMode: i
|
|
18
|
+
} = e;
|
|
19
|
+
return l == null ? !1 : i === "multiple" && Array.isArray(l) ? l.length > 0 : !0;
|
|
20
|
+
}),
|
|
21
|
+
hasNullItemLabel: t((e, l) => l ? s(e.items) : !1),
|
|
22
|
+
open: t((e) => e.open),
|
|
23
|
+
mounted: t((e) => e.mounted),
|
|
24
|
+
forceMounted: t((e) => e.forceMounted),
|
|
25
|
+
inline: t((e) => e.inline),
|
|
26
|
+
activeIndex: t((e) => e.activeIndex),
|
|
27
|
+
selectedIndex: t((e) => e.selectedIndex),
|
|
28
|
+
isActive: t((e, l) => e.activeIndex === l),
|
|
29
|
+
isSelected: t((e, l) => {
|
|
30
|
+
const i = e.isItemEqualToValue, n = e.selectedValue;
|
|
31
|
+
return Array.isArray(n) ? n.some((o) => r(l, o, i)) : r(l, n, i);
|
|
32
|
+
}),
|
|
33
|
+
transitionStatus: t((e) => e.transitionStatus),
|
|
34
|
+
popupProps: t((e) => e.popupProps),
|
|
35
|
+
inputProps: t((e) => e.inputProps),
|
|
36
|
+
triggerProps: t((e) => e.triggerProps),
|
|
37
|
+
getItemProps: t((e) => e.getItemProps),
|
|
38
|
+
positionerElement: t((e) => e.positionerElement),
|
|
39
|
+
listElement: t((e) => e.listElement),
|
|
40
|
+
triggerElement: t((e) => e.triggerElement),
|
|
41
|
+
inputElement: t((e) => e.inputElement),
|
|
42
|
+
inputGroupElement: t((e) => e.inputGroupElement),
|
|
43
|
+
popupSide: t((e) => e.popupSide),
|
|
44
|
+
openMethod: t((e) => e.openMethod),
|
|
45
|
+
inputInsidePopup: t((e) => e.inputInsidePopup),
|
|
46
|
+
selectionMode: t((e) => e.selectionMode),
|
|
47
|
+
listRef: t((e) => e.listRef),
|
|
48
|
+
labelsRef: t((e) => e.labelsRef),
|
|
49
|
+
popupRef: t((e) => e.popupRef),
|
|
50
|
+
emptyRef: t((e) => e.emptyRef),
|
|
51
|
+
inputRef: t((e) => e.inputRef),
|
|
52
|
+
keyboardActiveRef: t((e) => e.keyboardActiveRef),
|
|
53
|
+
chipsContainerRef: t((e) => e.chipsContainerRef),
|
|
54
|
+
clearRef: t((e) => e.clearRef),
|
|
55
|
+
valuesRef: t((e) => e.valuesRef),
|
|
56
|
+
allValuesRef: t((e) => e.allValuesRef),
|
|
57
|
+
name: t((e) => e.name),
|
|
58
|
+
disabled: t((e) => e.disabled),
|
|
59
|
+
readOnly: t((e) => e.readOnly),
|
|
60
|
+
required: t((e) => e.required),
|
|
61
|
+
grid: t((e) => e.grid),
|
|
62
|
+
isGrouped: t((e) => e.isGrouped),
|
|
63
|
+
virtualized: t((e) => e.virtualized),
|
|
64
|
+
onOpenChangeComplete: t((e) => e.onOpenChangeComplete),
|
|
65
|
+
openOnInputClick: t((e) => e.openOnInputClick),
|
|
66
|
+
itemToStringLabel: t((e) => e.itemToStringLabel),
|
|
67
|
+
isItemEqualToValue: t((e) => e.isItemEqualToValue),
|
|
68
|
+
modal: t((e) => e.modal),
|
|
69
|
+
autoHighlight: t((e) => e.autoHighlight),
|
|
70
|
+
submitOnItemClick: t((e) => e.submitOnItemClick)
|
|
71
|
+
};
|
|
72
|
+
export {
|
|
73
|
+
d as selectors
|
|
74
|
+
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import * as R from "react";
|
|
2
|
+
import { useStableCallback as pe } from "../../../../utils/esm/useStableCallback.js";
|
|
3
|
+
import { useTimeout as me } from "../../../../utils/esm/useTimeout.js";
|
|
4
|
+
import { ownerDocument as fe } from "../../../../utils/esm/owner.js";
|
|
5
|
+
import { useRenderElement as be } from "../../utils/useRenderElement.js";
|
|
6
|
+
import { useComboboxRootContext as ge, useComboboxDerivedItemsContext as xe, useComboboxFloatingContext as Ee, useComboboxInputValueContext as Re } from "../root/ComboboxRootContext.js";
|
|
7
|
+
import { triggerStateAttributesMapping as Te } from "../utils/stateAttributesMapping.js";
|
|
8
|
+
import { selectors as t } from "../store.js";
|
|
9
|
+
import { useFieldRootContext as Ce } from "../../field/root/FieldRootContext.js";
|
|
10
|
+
import { useLabelableContext as Ie } from "../../labelable-provider/LabelableContext.js";
|
|
11
|
+
import { getPseudoElementBounds as he } from "../../utils/getPseudoElementBounds.js";
|
|
12
|
+
import { createChangeEventDetails as T } from "../../utils/createBaseUIEventDetails.js";
|
|
13
|
+
import { useLabelableId as ye } from "../../labelable-provider/useLabelableId.js";
|
|
14
|
+
import { resolveAriaLabelledBy as Pe } from "../../utils/resolveAriaLabelledBy.js";
|
|
15
|
+
import { useTypeahead as Se } from "../../floating-ui-react/hooks/useTypeahead.js";
|
|
16
|
+
import { useClick as Ve } from "../../floating-ui-react/hooks/useClick.js";
|
|
17
|
+
import { useButton as De } from "../../use-button/useButton.js";
|
|
18
|
+
import { useStore as o } from "../../../../utils/esm/store/useStore.js";
|
|
19
|
+
import { stopEvent as we } from "../../floating-ui-react/utils/event.js";
|
|
20
|
+
import { contains as f, getTarget as Me } from "../../floating-ui-react/utils/element.js";
|
|
21
|
+
import { listNavigation as ve } from "../../utils/reason-parts.js";
|
|
22
|
+
const b = 2, Be = /* @__PURE__ */ R.forwardRef(function(C, w) {
|
|
23
|
+
const {
|
|
24
|
+
render: Oe,
|
|
25
|
+
className: ke,
|
|
26
|
+
nativeButton: M = !0,
|
|
27
|
+
disabled: v = !1,
|
|
28
|
+
id: g,
|
|
29
|
+
...I
|
|
30
|
+
} = C, {
|
|
31
|
+
state: B,
|
|
32
|
+
disabled: L,
|
|
33
|
+
setTouched: O,
|
|
34
|
+
setFocused: h,
|
|
35
|
+
validationMode: k,
|
|
36
|
+
validation: x
|
|
37
|
+
} = Ce(), {
|
|
38
|
+
labelId: A
|
|
39
|
+
} = Ie(), e = ge(), {
|
|
40
|
+
filteredItems: F
|
|
41
|
+
} = xe(), y = o(e, t.selectionMode), E = o(e, t.disabled), c = o(e, t.readOnly), N = o(e, t.required), U = o(e, t.mounted), q = o(e, t.popupSide), P = o(e, t.positionerElement), Y = o(e, t.listElement), X = o(e, t.triggerProps), i = o(e, t.triggerElement), r = o(e, t.inputInsidePopup), _ = o(e, t.id), z = o(e, t.labelId), u = o(e, t.open), H = o(e, t.selectedValue), K = o(e, t.activeIndex), j = o(e, t.selectedIndex), G = o(e, t.hasSelectedValue), s = Ee(), J = Re(), Q = me(), d = L || E || v, W = F.length === 0, Z = U && P ? q : null;
|
|
42
|
+
ye({
|
|
43
|
+
id: r ? g : void 0
|
|
44
|
+
});
|
|
45
|
+
const $ = r ? g ?? _ : g, ee = Pe(A, z), S = R.useRef("");
|
|
46
|
+
function V(n) {
|
|
47
|
+
S.current = n.pointerType;
|
|
48
|
+
}
|
|
49
|
+
const D = s.useState("domReferenceElement");
|
|
50
|
+
R.useEffect(() => {
|
|
51
|
+
r && i && i !== D && s.set("domReferenceElement", i);
|
|
52
|
+
}, [i, D, s, r]);
|
|
53
|
+
const {
|
|
54
|
+
reference: te
|
|
55
|
+
} = Se(s, {
|
|
56
|
+
enabled: !u && !c && !E && y === "single",
|
|
57
|
+
listRef: e.state.labelsRef,
|
|
58
|
+
activeIndex: K,
|
|
59
|
+
selectedIndex: j,
|
|
60
|
+
onMatch(n) {
|
|
61
|
+
const a = e.state.valuesRef.current[n];
|
|
62
|
+
a !== void 0 && e.state.setSelectedValue(a, T("none"));
|
|
63
|
+
}
|
|
64
|
+
}), {
|
|
65
|
+
reference: oe
|
|
66
|
+
} = Ve(s, {
|
|
67
|
+
enabled: !c && !E,
|
|
68
|
+
event: "mousedown"
|
|
69
|
+
}), {
|
|
70
|
+
buttonRef: ne,
|
|
71
|
+
getButtonProps: re
|
|
72
|
+
} = De({
|
|
73
|
+
native: M,
|
|
74
|
+
disabled: d
|
|
75
|
+
}), ie = {
|
|
76
|
+
...B,
|
|
77
|
+
open: u,
|
|
78
|
+
disabled: d,
|
|
79
|
+
popupSide: Z,
|
|
80
|
+
listEmpty: W,
|
|
81
|
+
placeholder: !G
|
|
82
|
+
}, se = pe((n) => {
|
|
83
|
+
e.set("triggerElement", n);
|
|
84
|
+
});
|
|
85
|
+
return be("button", C, {
|
|
86
|
+
ref: [w, ne, se],
|
|
87
|
+
state: ie,
|
|
88
|
+
props: [X, oe, te, {
|
|
89
|
+
id: $,
|
|
90
|
+
tabIndex: r ? 0 : -1,
|
|
91
|
+
role: r ? "combobox" : void 0,
|
|
92
|
+
"aria-expanded": u ? "true" : "false",
|
|
93
|
+
"aria-haspopup": r ? "dialog" : "listbox",
|
|
94
|
+
"aria-controls": u ? Y?.id : void 0,
|
|
95
|
+
"aria-required": r && N || void 0,
|
|
96
|
+
"aria-labelledby": ee,
|
|
97
|
+
onPointerDown: V,
|
|
98
|
+
onPointerEnter: V,
|
|
99
|
+
onFocus() {
|
|
100
|
+
h(!0), !(d || c) && Q.start(0, e.state.forceMount);
|
|
101
|
+
},
|
|
102
|
+
onBlur(n) {
|
|
103
|
+
if (!f(P, n.relatedTarget) && (O(!0), h(!1), k === "onBlur")) {
|
|
104
|
+
const a = y === "none" ? J : H;
|
|
105
|
+
x.commit(a);
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
onMouseDown(n) {
|
|
109
|
+
if (d || c || (r || s.set("domReferenceElement", n.currentTarget), e.state.forceMount(), S.current !== "touch" && (e.state.inputRef.current?.focus(), r || n.preventDefault()), u))
|
|
110
|
+
return;
|
|
111
|
+
const a = fe(n.currentTarget);
|
|
112
|
+
function ae(l) {
|
|
113
|
+
if (!i)
|
|
114
|
+
return;
|
|
115
|
+
const p = Me(l), le = e.state.positionerElement, ce = e.state.listElement;
|
|
116
|
+
if (f(i, p) || f(le, p) || f(ce, p) || p === i)
|
|
117
|
+
return;
|
|
118
|
+
const m = he(i), ue = l.clientX >= m.left - b && l.clientX <= m.right + b, de = l.clientY >= m.top - b && l.clientY <= m.bottom + b;
|
|
119
|
+
ue && de || e.state.setOpen(!1, T("cancel-open", l));
|
|
120
|
+
}
|
|
121
|
+
r && a.addEventListener("mouseup", ae, {
|
|
122
|
+
once: !0
|
|
123
|
+
});
|
|
124
|
+
},
|
|
125
|
+
onKeyDown(n) {
|
|
126
|
+
d || c || (n.key === "ArrowDown" || n.key === "ArrowUp") && (we(n), e.state.setOpen(!0, T(ve, n.nativeEvent)), e.state.inputRef.current?.focus());
|
|
127
|
+
}
|
|
128
|
+
}, x ? x.getValidationProps(I) : I, re],
|
|
129
|
+
stateAttributesMapping: Te
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
process.env.NODE_ENV !== "production" && (Be.displayName = "ComboboxTrigger");
|
|
133
|
+
export {
|
|
134
|
+
Be as ComboboxTrigger
|
|
135
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import * as a from "react";
|
|
2
|
+
import { useMergedRefs as f } from "../../../../utils/esm/useMergedRefs.js";
|
|
3
|
+
import { useStableCallback as l } from "../../../../utils/esm/useStableCallback.js";
|
|
4
|
+
import { visuallyHiddenInput as p } from "../../../../utils/esm/visuallyHidden.js";
|
|
5
|
+
import { createChangeEventDetails as u } from "../../utils/createBaseUIEventDetails.js";
|
|
6
|
+
import { useComboboxRootContext as c } from "../root/ComboboxRootContext.js";
|
|
7
|
+
import { jsx as b } from "react/jsx-runtime";
|
|
8
|
+
import { useButton as d } from "../../use-button/useButton.js";
|
|
9
|
+
import { closePress as x } from "../../utils/reason-parts.js";
|
|
10
|
+
const C = /* @__PURE__ */ a.forwardRef(function(R, t) {
|
|
11
|
+
const e = c(), {
|
|
12
|
+
buttonRef: s,
|
|
13
|
+
getButtonProps: r
|
|
14
|
+
} = d({
|
|
15
|
+
native: !1
|
|
16
|
+
}), n = f(t, s), i = l((o) => {
|
|
17
|
+
e.state.setOpen(!1, u(x, o.nativeEvent, o.currentTarget));
|
|
18
|
+
}), m = r({
|
|
19
|
+
onClick: i
|
|
20
|
+
});
|
|
21
|
+
return /* @__PURE__ */ b("span", {
|
|
22
|
+
ref: n,
|
|
23
|
+
...m,
|
|
24
|
+
"aria-label": "Dismiss",
|
|
25
|
+
tabIndex: void 0,
|
|
26
|
+
style: p
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
process.env.NODE_ENV !== "production" && (C.displayName = "ComboboxInternalDismissButton");
|
|
30
|
+
export {
|
|
31
|
+
C as ComboboxInternalDismissButton
|
|
32
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { pressableTriggerOpenStateMapping as t } from "../../utils/popupStateMapping.js";
|
|
2
|
+
import { fieldValidityMapping as i } from "../../field/utils/constants.js";
|
|
3
|
+
const r = {
|
|
4
|
+
...t,
|
|
5
|
+
...i,
|
|
6
|
+
popupSide: (p) => p ? {
|
|
7
|
+
"data-popup-side": p
|
|
8
|
+
} : null,
|
|
9
|
+
listEmpty: (p) => p ? {
|
|
10
|
+
"data-list-empty": ""
|
|
11
|
+
} : null
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
r as triggerStateAttributesMapping
|
|
15
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as d from "react";
|
|
2
|
+
import { useComboboxRootContext as b } from "../root/ComboboxRootContext.js";
|
|
3
|
+
import { resolveMultipleLabels as h, resolveSelectedLabel as L } from "../../utils/resolveValueLabel.js";
|
|
4
|
+
import { selectors as o } from "../store.js";
|
|
5
|
+
import { jsx as S } from "react/jsx-runtime";
|
|
6
|
+
import { useStore as t } from "../../../../utils/esm/store/useStore.js";
|
|
7
|
+
function N(a) {
|
|
8
|
+
const {
|
|
9
|
+
children: s,
|
|
10
|
+
placeholder: n
|
|
11
|
+
} = a, e = b(), i = t(e, o.itemToStringLabel), r = t(e, o.selectedValue), c = t(e, o.items), u = t(e, o.selectionMode) === "multiple", m = t(e, o.hasSelectedValue), f = !m && n != null && s == null, p = t(e, o.hasNullItemLabel, f);
|
|
12
|
+
let l = null;
|
|
13
|
+
return typeof s == "function" ? l = s(r) : s != null ? l = s : !m && n != null && !p ? l = n : u && Array.isArray(r) ? l = h(r, c, i) : l = L(r, c, i), /* @__PURE__ */ S(d.Fragment, {
|
|
14
|
+
children: l
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
N as ComboboxValue
|
|
19
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import * as a from "react";
|
|
2
|
+
import { useRefWithInit as T } from "../../../../utils/esm/useRefWithInit.js";
|
|
3
|
+
import { useStableCallback as l } from "../../../../utils/esm/useStableCallback.js";
|
|
4
|
+
import { useIsoLayoutEffect as f } from "../../../../utils/esm/useIsoLayoutEffect.js";
|
|
5
|
+
import { CompositeListContext as D } from "./CompositeListContext.js";
|
|
6
|
+
import { jsx as L } from "react/jsx-runtime";
|
|
7
|
+
function k(h) {
|
|
8
|
+
const {
|
|
9
|
+
children: N,
|
|
10
|
+
elementsRef: t,
|
|
11
|
+
labelsRef: o,
|
|
12
|
+
onMapChange: _
|
|
13
|
+
} = h, C = l(_), O = a.useRef(0), d = T(R).current, i = T(P).current, [p, M] = a.useState(0), c = a.useRef(p), E = l((e, u) => {
|
|
14
|
+
i.set(e, u ?? null), c.current += 1, M(c.current);
|
|
15
|
+
}), I = l((e) => {
|
|
16
|
+
i.delete(e), c.current += 1, M(c.current);
|
|
17
|
+
}), r = a.useMemo(() => {
|
|
18
|
+
const e = /* @__PURE__ */ new Map();
|
|
19
|
+
return Array.from(i.keys()).filter((n) => n.isConnected).sort(S).forEach((n, m) => {
|
|
20
|
+
const s = i.get(n) ?? {};
|
|
21
|
+
e.set(n, {
|
|
22
|
+
...s,
|
|
23
|
+
index: m
|
|
24
|
+
});
|
|
25
|
+
}), e;
|
|
26
|
+
}, [i, p]);
|
|
27
|
+
f(() => {
|
|
28
|
+
if (typeof MutationObserver != "function" || r.size === 0)
|
|
29
|
+
return;
|
|
30
|
+
const e = new MutationObserver((u) => {
|
|
31
|
+
const n = /* @__PURE__ */ new Set(), m = (s) => n.has(s) ? n.delete(s) : n.add(s);
|
|
32
|
+
u.forEach((s) => {
|
|
33
|
+
s.removedNodes.forEach(m), s.addedNodes.forEach(m);
|
|
34
|
+
}), n.size === 0 && (c.current += 1, M(c.current));
|
|
35
|
+
});
|
|
36
|
+
return r.forEach((u, n) => {
|
|
37
|
+
n.parentElement && e.observe(n.parentElement, {
|
|
38
|
+
childList: !0
|
|
39
|
+
});
|
|
40
|
+
}), () => {
|
|
41
|
+
e.disconnect();
|
|
42
|
+
};
|
|
43
|
+
}, [r]), f(() => {
|
|
44
|
+
c.current === p && (t.current.length !== r.size && (t.current.length = r.size), o && o.current.length !== r.size && (o.current.length = r.size), O.current = r.size), C(r);
|
|
45
|
+
}, [C, r, t, o, p]), f(() => () => {
|
|
46
|
+
t.current = [];
|
|
47
|
+
}, [t]), f(() => () => {
|
|
48
|
+
o && (o.current = []);
|
|
49
|
+
}, [o]);
|
|
50
|
+
const g = l((e) => (d.add(e), () => {
|
|
51
|
+
d.delete(e);
|
|
52
|
+
}));
|
|
53
|
+
f(() => {
|
|
54
|
+
d.forEach((e) => e(r));
|
|
55
|
+
}, [d, r]);
|
|
56
|
+
const b = a.useMemo(() => ({
|
|
57
|
+
register: E,
|
|
58
|
+
unregister: I,
|
|
59
|
+
subscribeMapChange: g,
|
|
60
|
+
elementsRef: t,
|
|
61
|
+
labelsRef: o,
|
|
62
|
+
nextIndexRef: O
|
|
63
|
+
}), [E, I, g, t, o, O]);
|
|
64
|
+
return /* @__PURE__ */ L(D.Provider, {
|
|
65
|
+
value: b,
|
|
66
|
+
children: N
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
function P() {
|
|
70
|
+
return /* @__PURE__ */ new Map();
|
|
71
|
+
}
|
|
72
|
+
function R() {
|
|
73
|
+
return /* @__PURE__ */ new Set();
|
|
74
|
+
}
|
|
75
|
+
function S(h, N) {
|
|
76
|
+
const t = h.compareDocumentPosition(N);
|
|
77
|
+
return t & Node.DOCUMENT_POSITION_FOLLOWING || t & Node.DOCUMENT_POSITION_CONTAINED_BY ? -1 : t & Node.DOCUMENT_POSITION_PRECEDING || t & Node.DOCUMENT_POSITION_CONTAINS ? 1 : 0;
|
|
78
|
+
}
|
|
79
|
+
export {
|
|
80
|
+
k as CompositeList
|
|
81
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as e from "react";
|
|
2
|
+
const t = /* @__PURE__ */ e.createContext({
|
|
3
|
+
register: () => {
|
|
4
|
+
},
|
|
5
|
+
unregister: () => {
|
|
6
|
+
},
|
|
7
|
+
subscribeMapChange: () => () => {
|
|
8
|
+
},
|
|
9
|
+
elementsRef: {
|
|
10
|
+
current: []
|
|
11
|
+
},
|
|
12
|
+
nextIndexRef: {
|
|
13
|
+
current: 0
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
process.env.NODE_ENV !== "production" && (t.displayName = "CompositeListContext");
|
|
17
|
+
function n() {
|
|
18
|
+
return e.useContext(t);
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
t as CompositeListContext,
|
|
22
|
+
n as useCompositeListContext
|
|
23
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as u from "react";
|
|
2
|
+
import { useIsoLayoutEffect as g } from "../../../../utils/esm/useIsoLayoutEffect.js";
|
|
3
|
+
import { useCompositeListContext as F } from "./CompositeListContext.js";
|
|
4
|
+
let I = /* @__PURE__ */ (function(t) {
|
|
5
|
+
return t[t.None = 0] = "None", t[t.GuessFromOrder = 1] = "GuessFromOrder", t;
|
|
6
|
+
})({});
|
|
7
|
+
function N(t = {}) {
|
|
8
|
+
const {
|
|
9
|
+
label: c,
|
|
10
|
+
metadata: l,
|
|
11
|
+
textRef: d,
|
|
12
|
+
indexGuessBehavior: L,
|
|
13
|
+
index: r
|
|
14
|
+
} = t, {
|
|
15
|
+
register: m,
|
|
16
|
+
unregister: a,
|
|
17
|
+
subscribeMapChange: x,
|
|
18
|
+
elementsRef: R,
|
|
19
|
+
labelsRef: i,
|
|
20
|
+
nextIndexRef: p
|
|
21
|
+
} = F(), f = u.useRef(-1), [n, C] = u.useState(r ?? (L === I.GuessFromOrder ? () => {
|
|
22
|
+
if (f.current === -1) {
|
|
23
|
+
const e = p.current;
|
|
24
|
+
p.current += 1, f.current = e;
|
|
25
|
+
}
|
|
26
|
+
return f.current;
|
|
27
|
+
} : -1)), s = u.useRef(null), b = u.useCallback((e) => {
|
|
28
|
+
if (s.current = e, n !== -1 && e !== null && (R.current[n] = e, i)) {
|
|
29
|
+
const o = c !== void 0;
|
|
30
|
+
i.current[n] = o ? c : d?.current?.textContent ?? e.textContent;
|
|
31
|
+
}
|
|
32
|
+
}, [n, R, i, c, d]);
|
|
33
|
+
return g(() => {
|
|
34
|
+
if (r != null)
|
|
35
|
+
return;
|
|
36
|
+
const e = s.current;
|
|
37
|
+
if (e)
|
|
38
|
+
return m(e, l), () => {
|
|
39
|
+
a(e);
|
|
40
|
+
};
|
|
41
|
+
}, [r, m, a, l]), g(() => {
|
|
42
|
+
if (r == null)
|
|
43
|
+
return x((e) => {
|
|
44
|
+
const o = s.current ? e.get(s.current)?.index : null;
|
|
45
|
+
o != null && C(o);
|
|
46
|
+
});
|
|
47
|
+
}, [r, x, C]), u.useMemo(() => ({
|
|
48
|
+
ref: b,
|
|
49
|
+
index: n
|
|
50
|
+
}), [n, b]);
|
|
51
|
+
}
|
|
52
|
+
export {
|
|
53
|
+
I as IndexGuessBehavior,
|
|
54
|
+
N as useCompositeListItem
|
|
55
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
let a = /* @__PURE__ */ (function(d) {
|
|
2
|
+
return d.disabled = "data-disabled", d.valid = "data-valid", d.invalid = "data-invalid", d.touched = "data-touched", d.dirty = "data-dirty", d.filled = "data-filled", d.focused = "data-focused", d;
|
|
3
|
+
})({});
|
|
4
|
+
export {
|
|
5
|
+
a as FieldControlDataAttributes
|
|
6
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import r from "../../../../utils/esm/formatErrorMessage.js";
|
|
2
|
+
import * as n from "react";
|
|
3
|
+
import { DEFAULT_FIELD_ROOT_STATE as l, DEFAULT_FIELD_STATE_ATTRIBUTES as i, DEFAULT_VALIDITY_STATE as s } from "../utils/constants.js";
|
|
4
|
+
import { NOOP as e, EMPTY_OBJECT as a } from "../../../../utils/esm/empty.js";
|
|
5
|
+
const d = /* @__PURE__ */ n.createContext({
|
|
6
|
+
invalid: void 0,
|
|
7
|
+
name: void 0,
|
|
8
|
+
validityData: {
|
|
9
|
+
state: s,
|
|
10
|
+
errors: [],
|
|
11
|
+
error: "",
|
|
12
|
+
value: "",
|
|
13
|
+
initialValue: null
|
|
14
|
+
},
|
|
15
|
+
setValidityData: e,
|
|
16
|
+
disabled: void 0,
|
|
17
|
+
touched: i.touched,
|
|
18
|
+
setTouched: e,
|
|
19
|
+
dirty: i.dirty,
|
|
20
|
+
setDirty: e,
|
|
21
|
+
filled: i.filled,
|
|
22
|
+
setFilled: e,
|
|
23
|
+
focused: i.focused,
|
|
24
|
+
setFocused: e,
|
|
25
|
+
validate: () => null,
|
|
26
|
+
validationMode: "onSubmit",
|
|
27
|
+
validationDebounceTime: 0,
|
|
28
|
+
shouldValidateOnChange: () => !1,
|
|
29
|
+
state: l,
|
|
30
|
+
markedDirtyRef: {
|
|
31
|
+
current: !1
|
|
32
|
+
},
|
|
33
|
+
validation: {
|
|
34
|
+
getValidationProps: (t = a) => t,
|
|
35
|
+
getInputValidationProps: (t = a) => t,
|
|
36
|
+
inputRef: {
|
|
37
|
+
current: null
|
|
38
|
+
},
|
|
39
|
+
commit: async () => {
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
process.env.NODE_ENV !== "production" && (d.displayName = "FieldRootContext");
|
|
44
|
+
function m(t = !0) {
|
|
45
|
+
const o = n.useContext(d);
|
|
46
|
+
if (o.setValidityData === e && !t)
|
|
47
|
+
throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: FieldRootContext is missing. Field parts must be placed within <Field.Root>." : r(28));
|
|
48
|
+
return o;
|
|
49
|
+
}
|
|
50
|
+
export {
|
|
51
|
+
d as FieldRootContext,
|
|
52
|
+
m as useFieldRootContext
|
|
53
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as p from "react-dom";
|
|
2
|
+
import { useIsoLayoutEffect as f } from "../../../utils/esm/useIsoLayoutEffect.js";
|
|
3
|
+
import { useStableCallback as D } from "../../../utils/esm/useStableCallback.js";
|
|
4
|
+
import { getCombinedFieldValidityData as v } from "./utils/getCombinedFieldValidityData.js";
|
|
5
|
+
import { useFormContext as R } from "../form/FormContext.js";
|
|
6
|
+
import { useFieldRootContext as b } from "./root/FieldRootContext.js";
|
|
7
|
+
function S(d) {
|
|
8
|
+
const {
|
|
9
|
+
enabled: a = !0,
|
|
10
|
+
value: r,
|
|
11
|
+
id: t,
|
|
12
|
+
name: m,
|
|
13
|
+
controlRef: s,
|
|
14
|
+
commit: u
|
|
15
|
+
} = d, {
|
|
16
|
+
formRef: n
|
|
17
|
+
} = R(), {
|
|
18
|
+
invalid: c,
|
|
19
|
+
markedDirtyRef: V,
|
|
20
|
+
validityData: o,
|
|
21
|
+
setValidityData: y
|
|
22
|
+
} = b(), l = D(d.getValue);
|
|
23
|
+
f(() => {
|
|
24
|
+
if (!a)
|
|
25
|
+
return;
|
|
26
|
+
let e = r;
|
|
27
|
+
e === void 0 && (e = l()), o.initialValue === null && e !== null && y((i) => ({
|
|
28
|
+
...i,
|
|
29
|
+
initialValue: e
|
|
30
|
+
}));
|
|
31
|
+
}, [a, y, r, o.initialValue, l]), f(() => {
|
|
32
|
+
!a || !t || n.current.fields.set(t, {
|
|
33
|
+
getValue: l,
|
|
34
|
+
name: m,
|
|
35
|
+
controlRef: s,
|
|
36
|
+
validityData: v(o, c),
|
|
37
|
+
validate(e = !0) {
|
|
38
|
+
let i = r;
|
|
39
|
+
i === void 0 && (i = l()), V.current = !0, e ? p.flushSync(() => u(i)) : u(i);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}, [u, s, a, n, l, t, c, V, m, o, r]), f(() => {
|
|
43
|
+
const e = n.current.fields;
|
|
44
|
+
return () => {
|
|
45
|
+
t && e.delete(t);
|
|
46
|
+
};
|
|
47
|
+
}, [n, t]);
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
S as useField
|
|
51
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { FieldControlDataAttributes as e } from "../control/FieldControlDataAttributes.js";
|
|
2
|
+
const t = {
|
|
3
|
+
badInput: !1,
|
|
4
|
+
customError: !1,
|
|
5
|
+
patternMismatch: !1,
|
|
6
|
+
rangeOverflow: !1,
|
|
7
|
+
rangeUnderflow: !1,
|
|
8
|
+
stepMismatch: !1,
|
|
9
|
+
tooLong: !1,
|
|
10
|
+
tooShort: !1,
|
|
11
|
+
typeMismatch: !1,
|
|
12
|
+
valid: null,
|
|
13
|
+
valueMissing: !1
|
|
14
|
+
}, a = {
|
|
15
|
+
valid: null,
|
|
16
|
+
touched: !1,
|
|
17
|
+
dirty: !1,
|
|
18
|
+
filled: !1,
|
|
19
|
+
focused: !1
|
|
20
|
+
}, f = {
|
|
21
|
+
disabled: !1,
|
|
22
|
+
...a
|
|
23
|
+
}, i = {
|
|
24
|
+
valid(l) {
|
|
25
|
+
return l === null ? null : l ? {
|
|
26
|
+
[e.valid]: ""
|
|
27
|
+
} : {
|
|
28
|
+
[e.invalid]: ""
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
export {
|
|
33
|
+
f as DEFAULT_FIELD_ROOT_STATE,
|
|
34
|
+
a as DEFAULT_FIELD_STATE_ATTRIBUTES,
|
|
35
|
+
t as DEFAULT_VALIDITY_STATE,
|
|
36
|
+
i as fieldValidityMapping
|
|
37
|
+
};
|