@viasat/beam-react 2.30.0 → 2.37.0
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/assets/ActionList.css +1 -1
- package/assets/Avatar.css +1 -1
- package/assets/Badge.css +1 -1
- package/assets/Button.css +1 -1
- package/assets/Checkbox.css +1 -1
- package/assets/Chip.css +1 -1
- package/assets/ChipGroup.css +1 -1
- package/assets/CloseButton.css +1 -1
- package/assets/DateField.css +1 -0
- package/assets/EmptyState.css +1 -1
- package/assets/FloatingUI.css +1 -0
- package/assets/InputChoiceGroup.css +1 -1
- package/assets/Link.css +1 -1
- package/assets/NativeSelect.css +1 -1
- package/assets/Pagination.css +1 -1
- package/assets/ProgressBar.css +1 -1
- package/assets/RadioButton.css +1 -1
- package/assets/Search.css +1 -1
- package/assets/SpinnerWrap.css +1 -1
- package/assets/Switch.css +1 -1
- package/assets/TextArea.css +1 -1
- package/assets/TextField.css +1 -1
- package/assets/card.css +1 -1
- package/assets/combobox.css +1 -1
- package/assets/dialog.css +1 -1
- package/assets/fileUpload.css +1 -1
- package/assets/header.css +1 -1
- package/assets/index.css +1 -1
- package/assets/panel.css +1 -1
- package/assets/segmentedControl.css +1 -1
- package/assets/slider.css +1 -1
- package/assets/stepper.css +1 -1
- package/chunks/DateField.Segment.7oCeBSNo.js +1 -0
- package/chunks/DateField.Segment.DbjGMAPP.js +99 -0
- package/chunks/FloatingUI.arrow.BK0jH2ge.js +1 -0
- package/chunks/FloatingUI.arrow.BXR2atOC.js +28 -0
- package/chunks/dialog.module.Djvqgz-x.js +1 -0
- package/chunks/{dialog.module.TRHzVysh.js → dialog.module.vokt9Lwb.js} +2 -1
- package/chunks/panel.module.BVmRxZHo.js +1 -0
- package/chunks/{panel.module.BblnuBjO.js → panel.module.CnHWv4EZ.js} +1 -3
- package/lib/ActionList/ActionList.Group.d.ts +1 -1
- package/lib/Autocomplete/Autocomplete.cjs.js +1 -1
- package/lib/Autocomplete/Autocomplete.d.ts +5 -5
- package/lib/Autocomplete/Autocomplete.es.js +296 -268
- package/lib/Autocomplete/AutocompleteDropdown.cjs.js +1 -1
- package/lib/Autocomplete/AutocompleteDropdown.es.js +15 -12
- package/lib/Breadcrumbs/BreadcrumbsItem.d.ts +1 -1
- package/lib/Dialog/Dialog.Body.cjs.js +1 -1
- package/lib/Dialog/Dialog.Body.es.js +1 -1
- package/lib/Dialog/Dialog.Content.cjs.js +1 -1
- package/lib/Dialog/Dialog.Content.es.js +1 -1
- package/lib/Dialog/Dialog.Footer.cjs.js +1 -1
- package/lib/Dialog/Dialog.Footer.es.js +1 -1
- package/lib/Dialog/Dialog.Header.cjs.js +1 -1
- package/lib/Dialog/Dialog.Header.es.js +1 -1
- package/lib/Dialog/Dialog.cjs.js +1 -1
- package/lib/Dialog/Dialog.es.js +1 -1
- package/lib/FloatingUI/FloatingUI.arrow.cjs.js +1 -1
- package/lib/FloatingUI/FloatingUI.arrow.es.js +6 -17
- package/lib/FloatingUI/FloatingUI.content.cjs.js +1 -1
- package/lib/FloatingUI/FloatingUI.content.es.js +31 -32
- package/lib/Search/SearchDropdown.cjs.js +1 -1
- package/lib/Search/SearchDropdown.es.js +1 -1
- package/lib/Select/Select.cjs.js +1 -1
- package/lib/Select/Select.d.ts +3 -2
- package/lib/Select/Select.es.js +208 -195
- package/lib/Select/SelectDropdown.cjs.js +1 -1
- package/lib/Select/SelectDropdown.es.js +15 -12
- package/lib/SideNav/SideNavActionList.es.js +1 -0
- package/lib/SideNav/SideNavActionListItemLabel.d.ts +1 -1
- package/lib/Slider/DualSlider.cjs.js +1 -1
- package/lib/Slider/DualSlider.es.js +28 -27
- package/lib/Slider/SingleSlider.cjs.js +1 -1
- package/lib/Slider/SingleSlider.es.js +1 -1
- package/lib/Slider/Slider.es.js +17 -17
- package/lib/Slider/hooks/useDualSliderLogic.cjs.js +1 -1
- package/lib/Slider/hooks/useDualSliderLogic.es.js +14 -14
- package/lib/Slider/hooks/useSingleSliderLogic.cjs.js +1 -1
- package/lib/Slider/hooks/useSingleSliderLogic.es.js +17 -17
- package/lib/Tabs/Tabs.Group.d.ts +2 -2
- package/lib/Tabs/Tabs.Item.d.ts +2 -2
- package/lib/Tabs/Tabs.Panel.d.ts +2 -2
- package/lib/Text/Text.d.ts +2 -2
- package/lib/Text/Text.es.js +12 -12
- package/lib/_Options/Option.cjs.js +1 -1
- package/lib/_Options/Option.context.cjs.js +1 -1
- package/lib/_Options/Option.context.d.ts +31 -13
- package/lib/_Options/Option.context.es.js +133 -88
- package/lib/_Options/Option.es.js +23 -21
- package/lib/_Options/Option.types.d.ts +23 -0
- package/lib/_Options/OptionGroup.cjs.js +1 -0
- package/lib/_Options/OptionGroup.context.cjs.js +1 -0
- package/lib/_Options/OptionGroup.context.d.ts +6 -0
- package/lib/_Options/OptionGroup.context.es.js +6 -0
- package/lib/_Options/OptionGroup.d.ts +3 -0
- package/lib/_Options/OptionGroup.es.js +22 -0
- package/lib/_Options/getLastVisibleStructureIndex.cjs.js +1 -0
- package/lib/_Options/getLastVisibleStructureIndex.d.ts +15 -0
- package/lib/_Options/getLastVisibleStructureIndex.es.js +14 -0
- package/lib/_Options/index.cjs.js +1 -1
- package/lib/_Options/index.d.ts +4 -0
- package/lib/_Options/index.es.js +13 -4
- package/lib/_Options/useRenderOption.cjs.js +1 -0
- package/lib/_Options/useRenderOption.d.ts +30 -0
- package/lib/_Options/useRenderOption.es.js +43 -0
- package/lib/wip/DateField/DateField.Segment.cjs.js +1 -0
- package/lib/wip/DateField/DateField.Segment.d.ts +2 -0
- package/lib/wip/DateField/DateField.Segment.es.js +8 -0
- package/lib/wip/DateField/DateField.Segments.cjs.js +1 -0
- package/lib/wip/DateField/DateField.Segments.d.ts +17 -0
- package/lib/wip/DateField/DateField.Segments.es.js +61 -0
- package/lib/wip/DateField/DateField.cjs.js +1 -0
- package/lib/wip/DateField/DateField.d.ts +3 -0
- package/lib/wip/DateField/DateField.es.js +191 -0
- package/lib/wip/DateField/DateField.types.cjs.js +1 -0
- package/lib/wip/DateField/DateField.types.d.ts +118 -0
- package/lib/wip/DateField/DateField.types.es.js +1 -0
- package/lib/wip/DateField/DateField.utils.cjs.js +1 -0
- package/lib/wip/DateField/DateField.utils.d.ts +26 -0
- package/lib/wip/DateField/DateField.utils.es.js +45 -0
- package/lib/wip/DateField/DateField.validation.cjs.js +1 -0
- package/lib/wip/DateField/DateField.validation.d.ts +26 -0
- package/lib/wip/DateField/DateField.validation.es.js +24 -0
- package/lib/wip/DateField/index.cjs.js +1 -0
- package/lib/wip/DateField/index.d.ts +2 -0
- package/lib/wip/DateField/index.es.js +4 -0
- package/lib/wip/DateField/useDateFieldFocus.cjs.js +1 -0
- package/lib/wip/DateField/useDateFieldFocus.d.ts +23 -0
- package/lib/wip/DateField/useDateFieldFocus.es.js +65 -0
- package/lib/wip/DateField/useDateFieldForm.cjs.js +1 -0
- package/lib/wip/DateField/useDateFieldForm.d.ts +32 -0
- package/lib/wip/DateField/useDateFieldForm.es.js +51 -0
- package/lib/wip/DateField/useDateFieldSegments.cjs.js +1 -0
- package/lib/wip/DateField/useDateFieldSegments.d.ts +7 -0
- package/lib/wip/DateField/useDateFieldSegments.es.js +13 -0
- package/lib/wip/DateField/useDateFieldValidity.cjs.js +1 -0
- package/lib/wip/DateField/useDateFieldValidity.d.ts +23 -0
- package/lib/wip/DateField/useDateFieldValidity.es.js +19 -0
- package/lib/wip/DateField/useDateFieldValue.cjs.js +1 -0
- package/lib/wip/DateField/useDateFieldValue.d.ts +19 -0
- package/lib/wip/DateField/useDateFieldValue.es.js +62 -0
- package/lib/wip/DateField/useInvalidState.cjs.js +1 -0
- package/lib/wip/DateField/useInvalidState.d.ts +13 -0
- package/lib/wip/DateField/useInvalidState.es.js +8 -0
- package/lib/wip/Panel/Footer/Panel.Footer.Actions.cjs.js +1 -1
- package/lib/wip/Panel/Footer/Panel.Footer.Actions.es.js +1 -1
- package/lib/wip/Panel/Footer/Panel.Footer.cjs.js +1 -1
- package/lib/wip/Panel/Footer/Panel.Footer.es.js +1 -1
- package/lib/wip/Panel/Header/Panel.Header.ContentAfter.cjs.js +1 -1
- package/lib/wip/Panel/Header/Panel.Header.ContentAfter.es.js +1 -1
- package/lib/wip/Panel/Header/Panel.Header.ContentBefore.cjs.js +1 -1
- package/lib/wip/Panel/Header/Panel.Header.ContentBefore.es.js +1 -1
- package/lib/wip/Panel/Header/Panel.Header.Description.cjs.js +1 -1
- package/lib/wip/Panel/Header/Panel.Header.Description.es.js +1 -1
- package/lib/wip/Panel/Header/Panel.Header.Heading.cjs.js +1 -1
- package/lib/wip/Panel/Header/Panel.Header.Heading.es.js +1 -1
- package/lib/wip/Panel/Header/Panel.Header.Row.cjs.js +1 -1
- package/lib/wip/Panel/Header/Panel.Header.Row.es.js +1 -1
- package/lib/wip/Panel/Header/Panel.Header.Subheader.cjs.js +1 -1
- package/lib/wip/Panel/Header/Panel.Header.Subheader.es.js +1 -1
- package/lib/wip/Panel/Header/Panel.Header.cjs.js +1 -1
- package/lib/wip/Panel/Header/Panel.Header.es.js +1 -1
- package/lib/wip/Panel/Panel.Body.cjs.js +1 -1
- package/lib/wip/Panel/Panel.Body.es.js +1 -1
- package/lib/wip/Panel/Panel.Inline.cjs.js +1 -1
- package/lib/wip/Panel/Panel.Inline.d.ts +3 -1
- package/lib/wip/Panel/Panel.Inline.es.js +44 -40
- package/lib/wip/Panel/Panel.Overlay.cjs.js +1 -1
- package/lib/wip/Panel/Panel.Overlay.d.ts +18 -2
- package/lib/wip/Panel/Panel.Overlay.es.js +110 -84
- package/lib/wip/Panel/Panel.ResizeHandle.cjs.js +1 -1
- package/lib/wip/Panel/Panel.ResizeHandle.es.js +1 -1
- package/lib/wip/Panel/Panel.cjs.js +1 -1
- package/lib/wip/Panel/Panel.d.ts +1 -1
- package/lib/wip/Panel/Panel.es.js +125 -94
- package/lib/wip/Panel/Panel.helpers.cjs.js +1 -1
- package/lib/wip/Panel/Panel.helpers.d.ts +2 -1
- package/lib/wip/Panel/Panel.helpers.es.js +37 -35
- package/lib/wip/Panel/Panel.types.d.ts +64 -10
- package/lib/wip/Panel/Panel.useResize.cjs.js +1 -1
- package/lib/wip/Panel/Panel.useResize.d.ts +3 -1
- package/lib/wip/Panel/Panel.useResize.es.js +34 -30
- package/lib/wip/index.cjs.js +1 -1
- package/lib/wip/index.d.ts +1 -0
- package/lib/wip/index.es.js +4 -2
- package/package.json +6 -6
- package/utils/hooks/index.cjs.js +1 -1
- package/utils/hooks/index.d.ts +1 -0
- package/utils/hooks/index.es.js +12 -10
- package/utils/hooks/useElementResize.cjs.js +1 -1
- package/utils/hooks/useElementResize.d.ts +1 -1
- package/utils/hooks/useElementResize.es.js +33 -33
- package/utils/hooks/usePrevious.cjs.js +1 -0
- package/utils/hooks/usePrevious.d.ts +5 -0
- package/utils/hooks/usePrevious.es.js +10 -0
- package/assets/floatingui.css +0 -1
- package/chunks/dialog.module.C_6Qrg4w.js +0 -1
- package/chunks/floatingui.module.BcBFebz0.js +0 -10
- package/chunks/floatingui.module.D3Aw_aYe.js +0 -1
- package/chunks/panel.module.CVyUzyCZ.js +0 -1
|
@@ -1,123 +1,168 @@
|
|
|
1
|
-
import { createContext as
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
if (!
|
|
1
|
+
import { createContext as H, useRef as C, useState as d, useMemo as O, useCallback as s, useContext as J } from "react";
|
|
2
|
+
const S = H(null), N = S.Provider, Q = () => {
|
|
3
|
+
const o = J(S);
|
|
4
|
+
if (!o)
|
|
5
5
|
throw new Error("useOptionsContext must be used within an OptionsProvider");
|
|
6
|
-
return
|
|
7
|
-
},
|
|
8
|
-
const
|
|
6
|
+
return o;
|
|
7
|
+
}, E = (o) => Array.isArray(o) ? o : o !== void 0 ? [o] : [], U = (o, c, p) => {
|
|
8
|
+
const w = C(void 0), [i, h] = d(
|
|
9
9
|
() => /* @__PURE__ */ new Map()
|
|
10
|
-
), [
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
), [u, y] = d(() => []), [D, I] = d(
|
|
11
|
+
() => /* @__PURE__ */ new Map()
|
|
12
|
+
), [M, v] = d(
|
|
13
|
+
() => /* @__PURE__ */ new Map()
|
|
14
|
+
), [m, g] = d(() => []), x = C(i);
|
|
15
|
+
x.current = i;
|
|
16
|
+
const a = O(() => E(o), [o]), f = C(a);
|
|
17
|
+
f.current = a, O(() => {
|
|
18
|
+
if (!a.length)
|
|
19
|
+
w.current = void 0;
|
|
16
20
|
else {
|
|
17
|
-
const e =
|
|
18
|
-
|
|
21
|
+
const e = a[a.length - 1], n = u.map((t) => i.get(t)).findIndex((t) => (t == null ? void 0 : t.value) === e);
|
|
22
|
+
w.current = n;
|
|
19
23
|
}
|
|
20
|
-
}, [
|
|
21
|
-
const
|
|
24
|
+
}, [a, u, i]);
|
|
25
|
+
const G = s(
|
|
22
26
|
(e) => {
|
|
23
|
-
const n =
|
|
24
|
-
n && t &&
|
|
27
|
+
const n = x.current.get(e), t = n == null ? void 0 : n.value, r = f.current;
|
|
28
|
+
n && t && c(p ? [...r.filter((l) => l !== t), t] : t);
|
|
25
29
|
},
|
|
26
|
-
[
|
|
27
|
-
),
|
|
30
|
+
[p, c]
|
|
31
|
+
), k = s(
|
|
28
32
|
(e) => {
|
|
29
|
-
const n =
|
|
33
|
+
const n = x.current.get(e), t = n == null ? void 0 : n.value, r = f.current;
|
|
30
34
|
if (n && t)
|
|
31
|
-
if (
|
|
32
|
-
if (!
|
|
33
|
-
|
|
35
|
+
if (p) {
|
|
36
|
+
if (!r.includes(t)) return;
|
|
37
|
+
c(r.filter((l) => l !== t));
|
|
34
38
|
} else
|
|
35
39
|
return;
|
|
36
40
|
},
|
|
37
|
-
[
|
|
38
|
-
),
|
|
41
|
+
[p, c]
|
|
42
|
+
), L = s(
|
|
39
43
|
(e) => {
|
|
40
|
-
if (!
|
|
41
|
-
const t =
|
|
44
|
+
if (!p || e === void 0) return;
|
|
45
|
+
const t = E(e)[0];
|
|
42
46
|
if (!t) return;
|
|
43
|
-
const
|
|
44
|
-
|
|
47
|
+
const r = f.current;
|
|
48
|
+
r.includes(t) && c(r.filter((l) => l !== t));
|
|
49
|
+
},
|
|
50
|
+
[p, c]
|
|
51
|
+
), z = s(
|
|
52
|
+
(e, n) => {
|
|
53
|
+
y((t) => [...t, e]), v((t) => {
|
|
54
|
+
const r = new Map(t);
|
|
55
|
+
return r.set(e, n), r;
|
|
56
|
+
}), n === null && g((t) => [...t, { kind: "option", id: e }]);
|
|
57
|
+
},
|
|
58
|
+
[]
|
|
59
|
+
), P = s(
|
|
60
|
+
(e) => {
|
|
61
|
+
y((n) => n.filter((t) => t !== e)), h((n) => {
|
|
62
|
+
const t = new Map(n);
|
|
63
|
+
return t.delete(e), t;
|
|
64
|
+
}), v((n) => {
|
|
65
|
+
const t = new Map(n);
|
|
66
|
+
return t.delete(e), t;
|
|
67
|
+
}), g(
|
|
68
|
+
(n) => n.filter((t) => !(t.kind === "option" && t.id === e))
|
|
69
|
+
);
|
|
70
|
+
},
|
|
71
|
+
[]
|
|
72
|
+
), V = s(
|
|
73
|
+
(e, n) => h((t) => {
|
|
74
|
+
const r = new Map(t);
|
|
75
|
+
return r.set(e, n), r;
|
|
76
|
+
}),
|
|
77
|
+
[]
|
|
78
|
+
), A = s(
|
|
79
|
+
(e) => {
|
|
80
|
+
g((n) => [...n, { kind: "group", id: e }]);
|
|
45
81
|
},
|
|
46
|
-
[
|
|
47
|
-
),
|
|
48
|
-
(e) => g((n) => [...n, e]),
|
|
49
|
-
[g]
|
|
50
|
-
), I = i(
|
|
82
|
+
[]
|
|
83
|
+
), B = s(
|
|
51
84
|
(e) => {
|
|
52
|
-
|
|
85
|
+
I((n) => {
|
|
53
86
|
const t = new Map(n);
|
|
54
87
|
return t.delete(e), t;
|
|
55
|
-
})
|
|
88
|
+
}), g(
|
|
89
|
+
(n) => n.filter((t) => !(t.kind === "group" && t.id === e))
|
|
90
|
+
);
|
|
56
91
|
},
|
|
57
|
-
[
|
|
58
|
-
),
|
|
59
|
-
(e, n) =>
|
|
60
|
-
const
|
|
61
|
-
return
|
|
92
|
+
[]
|
|
93
|
+
), R = s(
|
|
94
|
+
(e, n) => I((t) => {
|
|
95
|
+
const r = new Map(t);
|
|
96
|
+
return r.set(e, n), r;
|
|
62
97
|
}),
|
|
63
|
-
[
|
|
64
|
-
),
|
|
98
|
+
[]
|
|
99
|
+
), T = O(
|
|
65
100
|
() => ({
|
|
66
|
-
setValue:
|
|
101
|
+
setValue: c,
|
|
67
102
|
registerOption: z,
|
|
68
|
-
unregisterOption:
|
|
69
|
-
setOptionProps:
|
|
70
|
-
selectOption:
|
|
71
|
-
deselectOption:
|
|
103
|
+
unregisterOption: P,
|
|
104
|
+
setOptionProps: V,
|
|
105
|
+
selectOption: G,
|
|
106
|
+
deselectOption: k,
|
|
107
|
+
registerGroup: A,
|
|
108
|
+
unregisterGroup: B,
|
|
109
|
+
setGroupProps: R
|
|
72
110
|
}),
|
|
73
111
|
[
|
|
74
|
-
|
|
112
|
+
c,
|
|
75
113
|
z,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
114
|
+
P,
|
|
115
|
+
V,
|
|
116
|
+
G,
|
|
117
|
+
k,
|
|
118
|
+
A,
|
|
119
|
+
B,
|
|
120
|
+
R
|
|
80
121
|
]
|
|
81
|
-
),
|
|
82
|
-
if (!
|
|
83
|
-
const e = Array.from(
|
|
122
|
+
), j = O(() => {
|
|
123
|
+
if (!o || !i.size) return [];
|
|
124
|
+
const e = Array.from(i.values()), n = new Map(
|
|
84
125
|
e.map((t) => [t.value, t])
|
|
85
126
|
);
|
|
86
127
|
return f.current.length === 0 ? [] : f.current.map((t) => n.get(t)).filter(Boolean);
|
|
87
|
-
}, [
|
|
88
|
-
(e) =>
|
|
128
|
+
}, [o, i]), b = s(
|
|
129
|
+
(e) => x.current.get(e),
|
|
89
130
|
[]
|
|
90
|
-
),
|
|
131
|
+
), q = s(
|
|
91
132
|
(e) => {
|
|
92
|
-
const n =
|
|
133
|
+
const n = u[e];
|
|
93
134
|
if (n)
|
|
94
|
-
return
|
|
135
|
+
return b(n);
|
|
95
136
|
},
|
|
96
|
-
[
|
|
97
|
-
)
|
|
98
|
-
|
|
99
|
-
() =>
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}),
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
137
|
+
[b, u]
|
|
138
|
+
), F = O(() => {
|
|
139
|
+
const e = /* @__PURE__ */ new Map();
|
|
140
|
+
return m.forEach((n) => {
|
|
141
|
+
n.kind === "group" && e.set(n.id, []);
|
|
142
|
+
}), u.forEach((n) => {
|
|
143
|
+
const t = M.get(n);
|
|
144
|
+
if (t != null) {
|
|
145
|
+
const r = e.get(t);
|
|
146
|
+
r && r.push(n);
|
|
147
|
+
}
|
|
148
|
+
}), e;
|
|
149
|
+
}, [m, u, M]);
|
|
150
|
+
return {
|
|
151
|
+
optionsContext: T,
|
|
152
|
+
selectedOptionsProps: j,
|
|
153
|
+
optionIds: u,
|
|
154
|
+
optionsProps: i,
|
|
155
|
+
deselectOptionValue: L,
|
|
156
|
+
indexOfLastSelectedOptionRef: w,
|
|
157
|
+
getOptionByIndex: q,
|
|
158
|
+
structureIds: m,
|
|
159
|
+
groupsProps: D,
|
|
160
|
+
optionGroupOf: M,
|
|
161
|
+
optionIdsByGroup: F
|
|
162
|
+
};
|
|
118
163
|
};
|
|
119
164
|
export {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
165
|
+
N as OptionsProvider,
|
|
166
|
+
U as useCreateOptionsContext,
|
|
167
|
+
Q as useOptionsContext
|
|
123
168
|
};
|
|
@@ -1,31 +1,33 @@
|
|
|
1
1
|
import { jsx as x } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import { useOptionsContext as
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
import { useMemo as d, useCallback as g, useLayoutEffect as C, useEffect as N } from "react";
|
|
3
|
+
import { useOptionsContext as b } from "./Option.context.es.js";
|
|
4
|
+
import { useOptionGroupContext as v } from "./OptionGroup.context.es.js";
|
|
5
|
+
import { extractTextFromReactNode as E } from "../../utils/functions.es.js";
|
|
6
|
+
import { useId as I } from "../../utils/hooks/useId.es.js";
|
|
7
|
+
const P = ({
|
|
8
|
+
className: j,
|
|
9
|
+
label: r,
|
|
10
|
+
value: l,
|
|
11
|
+
children: o,
|
|
12
|
+
...n
|
|
11
13
|
}) => {
|
|
12
|
-
const
|
|
14
|
+
const e = d(() => r ?? E(o), [r, o]), s = l ?? e, {
|
|
13
15
|
selectOption: i,
|
|
14
|
-
deselectOption:
|
|
15
|
-
registerOption:
|
|
16
|
+
deselectOption: p,
|
|
17
|
+
registerOption: u,
|
|
16
18
|
unregisterOption: m,
|
|
17
|
-
setOptionProps:
|
|
18
|
-
} =
|
|
19
|
+
setOptionProps: a
|
|
20
|
+
} = b(), { groupId: c } = v(), t = I() ?? "", f = g(
|
|
19
21
|
(O) => {
|
|
20
|
-
O ? i(t) :
|
|
22
|
+
O ? i(t) : p(t);
|
|
21
23
|
},
|
|
22
|
-
[
|
|
24
|
+
[p, t, i]
|
|
23
25
|
);
|
|
24
|
-
return
|
|
25
|
-
|
|
26
|
-
}, [
|
|
26
|
+
return C(() => (u(t, c), () => m(t)), [t, c, u, m]), N(() => {
|
|
27
|
+
a(t, { ...n, label: e, value: s, children: o, onSelectionChange: f });
|
|
28
|
+
}, [o, t, e, f, n, a, s]), /* @__PURE__ */ x("option", { value: s, children: e });
|
|
27
29
|
};
|
|
28
30
|
export {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
P as Option,
|
|
32
|
+
P as default
|
|
31
33
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
1
2
|
import { ActionListItemProps } from '../ActionList/ActionList.Item';
|
|
2
3
|
export interface OptionProps extends Omit<ActionListItemProps, 'defaultSelected' | 'kind' | 'indent' | 'role'> {
|
|
3
4
|
/**
|
|
@@ -9,3 +10,25 @@ export interface OptionProps extends Omit<ActionListItemProps, 'defaultSelected'
|
|
|
9
10
|
*/
|
|
10
11
|
label?: string;
|
|
11
12
|
}
|
|
13
|
+
export interface OptionGroupProps {
|
|
14
|
+
/**
|
|
15
|
+
* Visible group label rendered above the group's options. Used as the source for `aria-label` on the group container.
|
|
16
|
+
*/
|
|
17
|
+
heading?: string | ReactNode;
|
|
18
|
+
/**
|
|
19
|
+
* Render a visual separator below the group.
|
|
20
|
+
*
|
|
21
|
+
* @default false
|
|
22
|
+
*/
|
|
23
|
+
divider?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Disables every Option inside the group. Heading remains visible; options are non-interactive.
|
|
26
|
+
*
|
|
27
|
+
* @default false
|
|
28
|
+
*/
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* `Option` components. Nested `OptionGroup`s are not supported.
|
|
32
|
+
*/
|
|
33
|
+
children?: ReactNode;
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("react/jsx-runtime"),t=require("react"),O=require("./Option.context.cjs.js"),G=require("./OptionGroup.context.cjs.js"),a=require("../../utils/hooks/useId.cjs.js"),p=({heading:o,divider:u,disabled:r,children:c})=>{const{registerGroup:s,unregisterGroup:n,setGroupProps:i}=O.useOptionsContext(),e=a.useId()??"";t.useLayoutEffect(()=>(s(e),()=>n(e)),[e,s,n]),t.useEffect(()=>{i(e,{heading:o,divider:u,disabled:r})},[e,o,u,r,i]);const _=t.useMemo(()=>({groupId:e}),[e]);return l.jsx(G.OptionGroupProvider,{value:_,children:c})};exports.OptionGroup=p;exports.default=p;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react"),t=o.createContext({groupId:null}),e=t.Provider,r=()=>o.useContext(t);exports.OptionGroupProvider=e;exports.useOptionGroupContext=r;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as f } from "react/jsx-runtime";
|
|
2
|
+
import { useLayoutEffect as i, useEffect as c, useMemo as G } from "react";
|
|
3
|
+
import { useOptionsContext as x } from "./Option.context.es.js";
|
|
4
|
+
import { OptionGroupProvider as a } from "./OptionGroup.context.es.js";
|
|
5
|
+
import { useId as O } from "../../utils/hooks/useId.es.js";
|
|
6
|
+
const j = ({
|
|
7
|
+
heading: r,
|
|
8
|
+
divider: t,
|
|
9
|
+
disabled: e,
|
|
10
|
+
children: m
|
|
11
|
+
}) => {
|
|
12
|
+
const { registerGroup: u, unregisterGroup: p, setGroupProps: s } = x(), o = O() ?? "";
|
|
13
|
+
i(() => (u(o), () => p(o)), [o, u, p]), c(() => {
|
|
14
|
+
s(o, { heading: r, divider: t, disabled: e });
|
|
15
|
+
}, [o, r, t, e, s]);
|
|
16
|
+
const n = G(() => ({ groupId: o }), [o]);
|
|
17
|
+
return /* @__PURE__ */ f(a, { value: n, children: m });
|
|
18
|
+
};
|
|
19
|
+
export {
|
|
20
|
+
j as OptionGroup,
|
|
21
|
+
j as default
|
|
22
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function s(i,o,n={}){for(let t=i.length-1;t>=0;t--){const e=i[t];if(e.kind==="option"){if(!n[e.id])return t}else if((o.get(e.id)??[]).some(r=>!n[r]))return t}return-1}exports.getLastVisibleStructureIndex=s;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { StructureNode } from './Option.context';
|
|
2
|
+
/**
|
|
3
|
+
* Find the index of the last visible node in an options dropdown structure.
|
|
4
|
+
*
|
|
5
|
+
* Used to determine which group should suppress its trailing divider (the one
|
|
6
|
+
* that ends up as the last visible thing in the dropdown).
|
|
7
|
+
*
|
|
8
|
+
* - For an option node: visible when not filtered out.
|
|
9
|
+
* - For a group node: visible when at least one of its options is not filtered.
|
|
10
|
+
*
|
|
11
|
+
* Pass `filteredOptionsById` when the consumer supports filtering (Autocomplete).
|
|
12
|
+
* Omit it for non-filtering consumers (Select); options are then treated as
|
|
13
|
+
* always visible and groups are treated as visible when non-empty.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getLastVisibleStructureIndex(structureIds: StructureNode[], optionIdsByGroup: Map<string, string[]>, filteredOptionsById?: Record<string, boolean>): number;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function u(t, e, o = {}) {
|
|
2
|
+
for (let i = t.length - 1; i >= 0; i--) {
|
|
3
|
+
const n = t[i];
|
|
4
|
+
if (n.kind === "option") {
|
|
5
|
+
if (!o[n.id]) return i;
|
|
6
|
+
} else if ((e.get(n.id) ?? []).some(
|
|
7
|
+
(s) => !o[s]
|
|
8
|
+
)) return i;
|
|
9
|
+
}
|
|
10
|
+
return -1;
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
u as getLastVisibleStructureIndex
|
|
14
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./Option.context.cjs.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./Option.context.cjs.js"),o=require("./Option.cjs.js"),i=require("./OptionGroup.cjs.js"),t=require("./OptionGroup.context.cjs.js"),n=require("./getLastVisibleStructureIndex.cjs.js"),r=require("./useRenderOption.cjs.js"),s=require("./useSelectValue.cjs.js");exports.OptionsProvider=e.OptionsProvider;exports.useCreateOptionsContext=e.useCreateOptionsContext;exports.useOptionsContext=e.useOptionsContext;exports.Option=o.Option;exports.OptionGroup=i.OptionGroup;exports.OptionGroupProvider=t.OptionGroupProvider;exports.useOptionGroupContext=t.useOptionGroupContext;exports.getLastVisibleStructureIndex=n.getLastVisibleStructureIndex;exports.useRenderOption=r.useRenderOption;exports.useSelectValue=s.useSelectValue;
|
package/lib/_Options/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
export * from './Option.types';
|
|
2
2
|
export * from './Option.context';
|
|
3
3
|
export * from './Option';
|
|
4
|
+
export * from './OptionGroup';
|
|
5
|
+
export * from './OptionGroup.context';
|
|
6
|
+
export * from './getLastVisibleStructureIndex';
|
|
7
|
+
export * from './useRenderOption';
|
|
4
8
|
export * from './useSelectValue';
|
package/lib/_Options/index.es.js
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import { OptionsProvider as t, useCreateOptionsContext as r, useOptionsContext as p } from "./Option.context.es.js";
|
|
2
|
-
import { Option as
|
|
3
|
-
import {
|
|
2
|
+
import { Option as i } from "./Option.es.js";
|
|
3
|
+
import { OptionGroup as x } from "./OptionGroup.es.js";
|
|
4
|
+
import { OptionGroupProvider as O, useOptionGroupContext as f } from "./OptionGroup.context.es.js";
|
|
5
|
+
import { getLastVisibleStructureIndex as d } from "./getLastVisibleStructureIndex.es.js";
|
|
6
|
+
import { useRenderOption as a } from "./useRenderOption.es.js";
|
|
7
|
+
import { useSelectValue as G } from "./useSelectValue.es.js";
|
|
4
8
|
export {
|
|
5
|
-
|
|
9
|
+
i as Option,
|
|
10
|
+
x as OptionGroup,
|
|
11
|
+
O as OptionGroupProvider,
|
|
6
12
|
t as OptionsProvider,
|
|
13
|
+
d as getLastVisibleStructureIndex,
|
|
7
14
|
r as useCreateOptionsContext,
|
|
15
|
+
f as useOptionGroupContext,
|
|
8
16
|
p as useOptionsContext,
|
|
9
|
-
|
|
17
|
+
a as useRenderOption,
|
|
18
|
+
G as useSelectValue
|
|
10
19
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react"),d=require("clsx"),S=require("../ActionList/ActionList.cjs.js");function g({optionsProps:t,selectionStrategy:n,value:r,multiple:i,optionClassName:l,filteredOptionsById:c}){return a.useCallback((s,o)=>{const e=t.get(s);if(!e)return null;const b=n.isSelected(e.value,r),u=(c==null?void 0:c[s])??!1,k=u||e.disabled||!!o;return a.createElement(S.ActionList.Item,{...e,className:d(l,e.className),disabled:k,hidden:u,defaultSelected:b,key:s,kind:i?"checkbox":"singleCheckMark",role:"option"})},[t,n,r,i,l,c])}exports.useRenderOption=g;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { OptionProps } from './Option.types';
|
|
2
|
+
import { SelectionStrategy, SelectValue } from './strategies/SelectionStrategy';
|
|
3
|
+
export interface UseRenderOptionParams {
|
|
4
|
+
/** Live options registry from `useCreateOptionsContext`. */
|
|
5
|
+
optionsProps: Map<string, OptionProps>;
|
|
6
|
+
/** Selection strategy (single vs multi) from `createSelectionStrategy`. */
|
|
7
|
+
selectionStrategy: SelectionStrategy;
|
|
8
|
+
/** Current selected value (single string or array for multi). */
|
|
9
|
+
value: SelectValue;
|
|
10
|
+
/** Whether the parent is in multiselect mode (affects item kind). */
|
|
11
|
+
multiple: boolean;
|
|
12
|
+
/** CSS class applied to each rendered `ActionList.Item` for parent-specific styling. */
|
|
13
|
+
optionClassName?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Per-option "filtered out" map (Autocomplete only). When set, filtered
|
|
16
|
+
* options render with `hidden` and `disabled` so keyboard navigation skips
|
|
17
|
+
* them while their `useListItem` index stays stable. Omit on consumers that
|
|
18
|
+
* don't filter (Select).
|
|
19
|
+
*/
|
|
20
|
+
filteredOptionsById?: Record<string, boolean>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Shared per-option renderer for `Autocomplete` and `Select` dropdowns.
|
|
24
|
+
*
|
|
25
|
+
* Returns a stable `(optionId, groupDisabled?)` callback the parent invokes
|
|
26
|
+
* while walking its rendered structure. Centralises the `ActionList.Item`
|
|
27
|
+
* wiring (className, disabled cascade, selection mirror, role, key) so both
|
|
28
|
+
* components stay in lockstep.
|
|
29
|
+
*/
|
|
30
|
+
export declare function useRenderOption({ optionsProps, selectionStrategy, value, multiple, optionClassName, filteredOptionsById, }: UseRenderOptionParams): (optionId: string, groupDisabled?: boolean) => import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { useCallback as b, createElement as i } from "react";
|
|
2
|
+
import h from "clsx";
|
|
3
|
+
import { ActionList as x } from "../ActionList/ActionList.es.js";
|
|
4
|
+
function g({
|
|
5
|
+
optionsProps: s,
|
|
6
|
+
selectionStrategy: a,
|
|
7
|
+
value: l,
|
|
8
|
+
multiple: n,
|
|
9
|
+
optionClassName: m,
|
|
10
|
+
filteredOptionsById: c
|
|
11
|
+
}) {
|
|
12
|
+
return b(
|
|
13
|
+
(r, u) => {
|
|
14
|
+
const e = s.get(r);
|
|
15
|
+
if (!e) return null;
|
|
16
|
+
const k = a.isSelected(e.value, l), t = (c == null ? void 0 : c[r]) ?? !1, o = t || e.disabled || !!u;
|
|
17
|
+
return /* @__PURE__ */ i(
|
|
18
|
+
x.Item,
|
|
19
|
+
{
|
|
20
|
+
...e,
|
|
21
|
+
className: h(m, e.className),
|
|
22
|
+
disabled: o,
|
|
23
|
+
hidden: t,
|
|
24
|
+
defaultSelected: k,
|
|
25
|
+
key: r,
|
|
26
|
+
kind: n ? "checkbox" : "singleCheckMark",
|
|
27
|
+
role: "option"
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
},
|
|
31
|
+
[
|
|
32
|
+
s,
|
|
33
|
+
a,
|
|
34
|
+
l,
|
|
35
|
+
n,
|
|
36
|
+
m,
|
|
37
|
+
c
|
|
38
|
+
]
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
export {
|
|
42
|
+
g as useRenderOption
|
|
43
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("react/jsx-runtime");require("clsx");require("react");const e=require("../../../chunks/DateField.Segment.7oCeBSNo.js");require("./DateField.utils.cjs.js");exports.DateFieldSegment=e.DateFieldSegment;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { DateFieldSegmentProps } from './DateField.types';
|
|
2
|
+
export declare const DateFieldSegment: ({ type, value, displayValue, isPlaceholder, isActive, disabled, readOnly, onFocus, onBlur, onInput, segmentRef, }: DateFieldSegmentProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),t=require("../../../chunks/DateField.Segment.7oCeBSNo.js"),l=require("./DateField.utils.cjs.js"),i=[{type:"month",value:""},{type:"literal",value:"/"},{type:"day",value:""},{type:"literal",value:"/"},{type:"year",value:""}],F={month:"MM",day:"DD",year:"YYYY"},R=l.getSegmentOrder(i),v=({segmentText:n,segmentValues:r,focusedSegment:o,disabled:u,readOnly:c,onSegmentFocus:d,onSegmentBlur:y,onSegmentInput:m,registerSegmentRef:p})=>a.jsx("span",{className:t.styles[t.staticDateFieldClassNames.segments],children:i.map((s,D)=>{if(s.type==="literal")return a.jsx("span",{"aria-hidden":"true",className:t.styles[t.staticDateFieldClassNames.separator],children:s.value},`literal-${D}`);const e=s.type,g=F[e],{displayValue:S,isPlaceholder:_}=l.getSegmentDisplay(e,n[e],g);return a.jsx(t.DateFieldSegment,{type:e,value:r[e],displayValue:S,isPlaceholder:_,isActive:o===e,disabled:u,readOnly:c,onFocus:()=>d(e),onBlur:y,onInput:m,segmentRef:p(e)},e)})});exports.DateFieldSegments=v;exports.PARTS_ORDER=R;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { FocusEvent } from 'react';
|
|
2
|
+
import { FocusTarget, SegmentText, SegmentType, SegmentValues } from './DateField.types';
|
|
3
|
+
export declare const PARTS_ORDER: ReadonlyArray<SegmentType>;
|
|
4
|
+
export interface DateFieldSegmentsProps {
|
|
5
|
+
/** Per-segment raw strings — the single source of truth for display. */
|
|
6
|
+
segmentText: SegmentText;
|
|
7
|
+
/** Derived per-segment numbers for `aria-valuenow`. */
|
|
8
|
+
segmentValues: SegmentValues;
|
|
9
|
+
focusedSegment: FocusTarget;
|
|
10
|
+
disabled: boolean;
|
|
11
|
+
readOnly: boolean;
|
|
12
|
+
onSegmentFocus: (segment: SegmentType) => void;
|
|
13
|
+
onSegmentBlur: (event: FocusEvent<HTMLSpanElement>) => void;
|
|
14
|
+
onSegmentInput: (segment: SegmentType, char: string) => void;
|
|
15
|
+
registerSegmentRef: (segment: SegmentType) => (element: HTMLSpanElement | null) => void;
|
|
16
|
+
}
|
|
17
|
+
export declare const DateFieldSegments: ({ segmentText, segmentValues, focusedSegment, disabled, readOnly, onSegmentFocus, onSegmentBlur, onSegmentInput, registerSegmentRef, }: DateFieldSegmentsProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { s, a as l, D as h } from "../../../chunks/DateField.Segment.DbjGMAPP.js";
|
|
3
|
+
import { getSegmentOrder as R, getSegmentDisplay as f } from "./DateField.utils.es.js";
|
|
4
|
+
const n = [
|
|
5
|
+
{ type: "month", value: "" },
|
|
6
|
+
{ type: "literal", value: "/" },
|
|
7
|
+
{ type: "day", value: "" },
|
|
8
|
+
{ type: "literal", value: "/" },
|
|
9
|
+
{ type: "year", value: "" }
|
|
10
|
+
], A = {
|
|
11
|
+
month: "MM",
|
|
12
|
+
day: "DD",
|
|
13
|
+
year: "YYYY"
|
|
14
|
+
}, P = R(n), Y = ({
|
|
15
|
+
segmentText: r,
|
|
16
|
+
segmentValues: o,
|
|
17
|
+
focusedSegment: i,
|
|
18
|
+
disabled: m,
|
|
19
|
+
readOnly: p,
|
|
20
|
+
onSegmentFocus: c,
|
|
21
|
+
onSegmentBlur: y,
|
|
22
|
+
onSegmentInput: u,
|
|
23
|
+
registerSegmentRef: d
|
|
24
|
+
}) => /* @__PURE__ */ a("span", { className: s[l.segments], children: n.map((t, g) => {
|
|
25
|
+
if (t.type === "literal")
|
|
26
|
+
return /* @__PURE__ */ a(
|
|
27
|
+
"span",
|
|
28
|
+
{
|
|
29
|
+
"aria-hidden": "true",
|
|
30
|
+
className: s[l.separator],
|
|
31
|
+
children: t.value
|
|
32
|
+
},
|
|
33
|
+
`literal-${g}`
|
|
34
|
+
);
|
|
35
|
+
const e = t.type, D = A[e], { displayValue: v, isPlaceholder: S } = f(
|
|
36
|
+
e,
|
|
37
|
+
r[e],
|
|
38
|
+
D
|
|
39
|
+
);
|
|
40
|
+
return /* @__PURE__ */ a(
|
|
41
|
+
h,
|
|
42
|
+
{
|
|
43
|
+
type: e,
|
|
44
|
+
value: o[e],
|
|
45
|
+
displayValue: v,
|
|
46
|
+
isPlaceholder: S,
|
|
47
|
+
isActive: i === e,
|
|
48
|
+
disabled: m,
|
|
49
|
+
readOnly: p,
|
|
50
|
+
onFocus: () => c(e),
|
|
51
|
+
onBlur: y,
|
|
52
|
+
onInput: u,
|
|
53
|
+
segmentRef: d(e)
|
|
54
|
+
},
|
|
55
|
+
e
|
|
56
|
+
);
|
|
57
|
+
}) });
|
|
58
|
+
export {
|
|
59
|
+
Y as DateFieldSegments,
|
|
60
|
+
P as PARTS_ORDER
|
|
61
|
+
};
|