@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,12 +1,12 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import W, { useState as Y, useCallback as
|
|
1
|
+
import { jsxs as d, jsx as a, Fragment as Q } from "react/jsx-runtime";
|
|
2
|
+
import W, { useState as Y, useCallback as k } from "react";
|
|
3
3
|
import { useMergeRefs as Z } from "@floating-ui/react";
|
|
4
|
-
import { s as
|
|
4
|
+
import { s as A } from "../../chunks/slider.module.C__JUl2f.js";
|
|
5
5
|
import { Label as b } from "../Label/Label.es.js";
|
|
6
6
|
import { SliderTickMarks as rr } from "./Slider.TickMarks.es.js";
|
|
7
7
|
import { SliderValueAxisLabels as er } from "./Slider.ValueAxisLabels.es.js";
|
|
8
8
|
import { SliderError as ir } from "./Slider.Error.es.js";
|
|
9
|
-
import { SliderTextField as
|
|
9
|
+
import { SliderTextField as P } from "./Slider.TextField.es.js";
|
|
10
10
|
import { SliderThumb as N } from "./Slider.Thumb.es.js";
|
|
11
11
|
import { useDualSliderLogic as lr } from "./hooks/useDualSliderLogic.es.js";
|
|
12
12
|
import "../../chunks/constants.CKKGf1-i.js";
|
|
@@ -15,11 +15,11 @@ import { LabelProvider as ar } from "../Form/contexts/label.context.es.js";
|
|
|
15
15
|
import { HelperTextProvider as nr } from "../Form/contexts/helperText.context.es.js";
|
|
16
16
|
import "../../chunks/CSSLookup.DOOy1rxJ.js";
|
|
17
17
|
import "../../utils/hooks/useId.es.js";
|
|
18
|
-
import { validateDualSliderDefaultValue as
|
|
19
|
-
import { clientXToValue as
|
|
18
|
+
import { validateDualSliderDefaultValue as tr } from "./utils/slider.validation.utils.es.js";
|
|
19
|
+
import { clientXToValue as dr, calculatePercentage as C } from "./utils/slider.rendering.utils.es.js";
|
|
20
20
|
import { DEFAULT_TEXT_FIELD_WIDTH as mr, toCqw as w } from "./slider.constants.es.js";
|
|
21
21
|
import { useSliderFormReset as or, useSliderPointerEvents as ur } from "./hooks/useSliderEvents.es.js";
|
|
22
|
-
const
|
|
22
|
+
const Ar = W.forwardRef(
|
|
23
23
|
function({
|
|
24
24
|
base: r,
|
|
25
25
|
value: B,
|
|
@@ -37,7 +37,7 @@ const Pr = W.forwardRef(
|
|
|
37
37
|
onChange: H,
|
|
38
38
|
...X
|
|
39
39
|
}, j) {
|
|
40
|
-
const U = Z([r.containerRef, j]), x =
|
|
40
|
+
const U = Z([r.containerRef, j]), x = tr(
|
|
41
41
|
_,
|
|
42
42
|
r.normalizedMin,
|
|
43
43
|
r.normalizedMax
|
|
@@ -74,17 +74,17 @@ const Pr = W.forwardRef(
|
|
|
74
74
|
l
|
|
75
75
|
]
|
|
76
76
|
);
|
|
77
|
-
const G =
|
|
77
|
+
const G = k(
|
|
78
78
|
(e) => {
|
|
79
79
|
if (r.disabled || r.readOnly) return;
|
|
80
80
|
const [u, f] = i, p = Math.abs(e - u), M = Math.abs(e - f);
|
|
81
81
|
p < M ? l([e, f]) : l([u, e]);
|
|
82
82
|
},
|
|
83
83
|
[r.disabled, r.readOnly, l, i]
|
|
84
|
-
), V =
|
|
84
|
+
), V = k(
|
|
85
85
|
(e, u) => {
|
|
86
86
|
if (r.disabled || r.readOnly || !r.trackRef.current) return;
|
|
87
|
-
const f = r.trackRef.current.getBoundingClientRect(), [p, M] = r.normalizedRange,
|
|
87
|
+
const f = r.trackRef.current.getBoundingClientRect(), [p, M] = r.normalizedRange, t = dr(
|
|
88
88
|
e,
|
|
89
89
|
f,
|
|
90
90
|
p,
|
|
@@ -92,12 +92,12 @@ const Pr = W.forwardRef(
|
|
|
92
92
|
r.isRTL
|
|
93
93
|
), [v, h] = i;
|
|
94
94
|
if (u === "left")
|
|
95
|
-
l([
|
|
95
|
+
l([t, h]);
|
|
96
96
|
else if (u === "right")
|
|
97
|
-
l([v,
|
|
97
|
+
l([v, t]);
|
|
98
98
|
else {
|
|
99
|
-
const J = Math.abs(
|
|
100
|
-
J < K ? (l([
|
|
99
|
+
const J = Math.abs(t - v), K = Math.abs(t - h);
|
|
100
|
+
J < K ? (l([t, h]), o("left")) : (l([v, t]), o("right"));
|
|
101
101
|
}
|
|
102
102
|
},
|
|
103
103
|
[
|
|
@@ -105,6 +105,7 @@ const Pr = W.forwardRef(
|
|
|
105
105
|
r.readOnly,
|
|
106
106
|
r.normalizedRange,
|
|
107
107
|
r.isRTL,
|
|
108
|
+
r.trackRef,
|
|
108
109
|
l,
|
|
109
110
|
i
|
|
110
111
|
]
|
|
@@ -118,7 +119,7 @@ const Pr = W.forwardRef(
|
|
|
118
119
|
]
|
|
119
120
|
);
|
|
120
121
|
const [E, O] = r.normalizedRange, I = C(i[0], E, O), $ = C(i[1], E, O);
|
|
121
|
-
return /* @__PURE__ */
|
|
122
|
+
return /* @__PURE__ */ d("div", { ref: U, className: r.classNames.container, ...X, children: [
|
|
122
123
|
/* @__PURE__ */ a(
|
|
123
124
|
ar,
|
|
124
125
|
{
|
|
@@ -129,16 +130,16 @@ const Pr = W.forwardRef(
|
|
|
129
130
|
children: r.label && typeof r.label == "string" ? /* @__PURE__ */ a(b, { children: r.label }) : r.label
|
|
130
131
|
}
|
|
131
132
|
),
|
|
132
|
-
/* @__PURE__ */
|
|
133
|
+
/* @__PURE__ */ d("div", { className: r.classNames.contentContainer, role: "group", children: [
|
|
133
134
|
T && /* @__PURE__ */ a(
|
|
134
135
|
"div",
|
|
135
136
|
{
|
|
136
|
-
className:
|
|
137
|
+
className: A[`${r.bem.subElementClassPrefix}content-before`],
|
|
137
138
|
children: T
|
|
138
139
|
}
|
|
139
140
|
),
|
|
140
141
|
R && /* @__PURE__ */ a(
|
|
141
|
-
|
|
142
|
+
P,
|
|
142
143
|
{
|
|
143
144
|
value: i[0],
|
|
144
145
|
readOnly: r.readOnly,
|
|
@@ -157,8 +158,8 @@ const Pr = W.forwardRef(
|
|
|
157
158
|
ariaLabel: r.isRTL ? r.aria.label ? `${r.aria.label} (maximum)` : "Maximum value" : r.aria.label ? `${r.aria.label} (minimum)` : "Minimum value"
|
|
158
159
|
}
|
|
159
160
|
),
|
|
160
|
-
/* @__PURE__ */
|
|
161
|
-
/* @__PURE__ */
|
|
161
|
+
/* @__PURE__ */ d("div", { style: { width: "100%" }, children: [
|
|
162
|
+
/* @__PURE__ */ d(
|
|
162
163
|
"div",
|
|
163
164
|
{
|
|
164
165
|
ref: r.trackRef,
|
|
@@ -259,7 +260,7 @@ const Pr = W.forwardRef(
|
|
|
259
260
|
)
|
|
260
261
|
] }),
|
|
261
262
|
R && /* @__PURE__ */ a(
|
|
262
|
-
|
|
263
|
+
P,
|
|
263
264
|
{
|
|
264
265
|
value: i[1],
|
|
265
266
|
readOnly: r.readOnly,
|
|
@@ -281,12 +282,12 @@ const Pr = W.forwardRef(
|
|
|
281
282
|
D && /* @__PURE__ */ a(
|
|
282
283
|
"div",
|
|
283
284
|
{
|
|
284
|
-
className:
|
|
285
|
+
className: A[`${r.bem.subElementClassPrefix}content-after`],
|
|
285
286
|
children: D
|
|
286
287
|
}
|
|
287
288
|
)
|
|
288
289
|
] }),
|
|
289
|
-
r.name && /* @__PURE__ */
|
|
290
|
+
r.name && /* @__PURE__ */ d(Q, { children: [
|
|
290
291
|
/* @__PURE__ */ a(
|
|
291
292
|
"input",
|
|
292
293
|
{
|
|
@@ -309,7 +310,7 @@ const Pr = W.forwardRef(
|
|
|
309
310
|
}
|
|
310
311
|
)
|
|
311
312
|
] }),
|
|
312
|
-
/* @__PURE__ */
|
|
313
|
+
/* @__PURE__ */ d(nr, { ctxId: r.ids.helperText, ctxDisabled: r.disabled, children: [
|
|
313
314
|
q,
|
|
314
315
|
/* @__PURE__ */ a(ir, { error: r.error, errorId: r.ids.error })
|
|
315
316
|
] }),
|
|
@@ -318,6 +319,6 @@ const Pr = W.forwardRef(
|
|
|
318
319
|
}
|
|
319
320
|
);
|
|
320
321
|
export {
|
|
321
|
-
|
|
322
|
-
|
|
322
|
+
Ar as DualSlider,
|
|
323
|
+
Ar as default
|
|
323
324
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("react/jsx-runtime"),a=require("react"),B=require("@floating-ui/react"),R=require("../../chunks/slider.module.hYyjcVRE.js"),H=require("../Label/Label.cjs.js"),X=require("./Slider.TickMarks.cjs.js"),W=require("./Slider.ValueAxisLabels.cjs.js"),$=require("./Slider.Error.cjs.js"),Q=require("./Slider.TextField.cjs.js"),U=require("./Slider.Thumb.cjs.js"),Z=require("./hooks/useSingleSliderLogic.cjs.js");require("../../chunks/constants.hwjHOsvT.js");require("../../chunks/form.context.hesWPMlU.js");const G=require("../Form/contexts/label.context.cjs.js"),J=require("../Form/contexts/helperText.context.cjs.js");require("../../chunks/CSSLookup.DESAWWRT.js");require("../../utils/hooks/useId.cjs.js");const K=require("./utils/slider.validation.utils.cjs.js"),v=require("./utils/slider.rendering.utils.cjs.js"),c=require("./slider.constants.cjs.js"),h=require("./hooks/useSliderEvents.cjs.js"),q=a.forwardRef(function({base:e,value:L,defaultValue:p,marksSource:y="none",restrictToValueAxis:u=!1,showTextField:M=!1,textFieldWidth:z=c.DEFAULT_TEXT_FIELD_WIDTH,persistentTooltip:T=!1,disabledTooltip:
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("react/jsx-runtime"),a=require("react"),B=require("@floating-ui/react"),R=require("../../chunks/slider.module.hYyjcVRE.js"),H=require("../Label/Label.cjs.js"),X=require("./Slider.TickMarks.cjs.js"),W=require("./Slider.ValueAxisLabels.cjs.js"),$=require("./Slider.Error.cjs.js"),Q=require("./Slider.TextField.cjs.js"),U=require("./Slider.Thumb.cjs.js"),Z=require("./hooks/useSingleSliderLogic.cjs.js");require("../../chunks/constants.hwjHOsvT.js");require("../../chunks/form.context.hesWPMlU.js");const G=require("../Form/contexts/label.context.cjs.js"),J=require("../Form/contexts/helperText.context.cjs.js");require("../../chunks/CSSLookup.DESAWWRT.js");require("../../utils/hooks/useId.cjs.js");const K=require("./utils/slider.validation.utils.cjs.js"),v=require("./utils/slider.rendering.utils.cjs.js"),c=require("./slider.constants.cjs.js"),h=require("./hooks/useSliderEvents.cjs.js"),q=a.forwardRef(function({base:e,value:L,defaultValue:p,marksSource:y="none",restrictToValueAxis:u=!1,showTextField:M=!1,textFieldWidth:z=c.DEFAULT_TEXT_FIELD_WIDTH,persistentTooltip:T=!1,disabledTooltip:k=!1,helperText:j,contentBefore:m,contentAfter:x,onChange:E,...V},A){const C=B.useMergeRefs([e.containerRef,A]),t=K.validateSingleSliderDefaultValue(p,e.normalizedMin,e.normalizedMax),[_,o]=a.useState(!1),{value:n,setValue:l,markValues:g,step:s,getValidValue:d}=Z.useSingleSliderLogic({value:L,defaultValue:t,range:e.normalizedRange,min:e.normalizedMin,max:e.normalizedMax,step:e.normalizedStep,valueAxis:e.valueAxis,restrictToValueAxis:u,onChange:E});h.useSliderFormReset(e.internalInputRef,t??e.normalizedMin??e.normalizedRange[0],i=>l(d(i)),[t,e.normalizedMin,e.normalizedRange,l,d]);const N=a.useCallback(i=>{e.disabled||e.readOnly||l(i)},[e.disabled,e.readOnly,l]),S=a.useCallback(i=>{if(e.disabled||e.readOnly||!e.trackRef.current)return;const I=e.trackRef.current.getBoundingClientRect(),[P,w]=e.normalizedRange,F=v.clientXToValue(i,I,P,w,e.isRTL);l(F),o(!0)},[e.disabled,e.readOnly,e.normalizedRange,e.isRTL,e.trackRef,l]);h.useSliderPointerEvents(_,S,()=>o(!1));const[O,D]=e.normalizedRange,f=v.calculatePercentage(Number(n),O,D);return r.jsxs("div",{ref:C,className:e.classNames.container,...V,children:[r.jsx(G.LabelProvider,{ctxHtmlFor:e.ids.input,ctxDisabled:e.disabled,ctxRequired:e.required,ctxId:e.aria.labelledBy,children:e.label&&typeof e.label=="string"?r.jsx(H.Label,{children:e.label}):e.label}),r.jsxs("div",{className:e.classNames.contentContainer,role:"group",children:[m&&r.jsx("div",{className:R.styles[`${e.bem.subElementClassPrefix}content-before`],children:m}),r.jsxs("div",{style:{width:"100%"},children:[r.jsxs("div",{ref:e.trackRef,className:e.classNames.track,onPointerDown:i=>{e.disabled||e.readOnly||S(i.clientX)},children:[r.jsx("div",{className:e.classNames.fill,style:{[e.bem.variable("min-percentage")]:c.ZERO_CQW,[e.bem.variable("max-percentage")]:c.toCqw(f)}}),r.jsx(X.SliderTickMarks,{valueAxis:e.valueAxis,markValues:g,range:e.normalizedRange,step:s,marksSource:y}),r.jsx(U.SliderThumb,{isRTL:e.isRTL,error:e.hasError,isDragging:_,setIsDragging:o,currentPercentage:f,disabled:e.disabled,readOnly:e.readOnly,value:n,range:e.normalizedRange,min:e.normalizedMin,max:e.normalizedMax,step:s,persistentTooltip:T,disabledTooltip:k,getValidValue:d,setValue:l,ariaLabelledby:e.aria.labelledBy,ariaLabel:e.aria.label,valueAxis:e.valueAxis,restrictToValueAxis:u})]}),r.jsx(W.SliderValueAxisLabels,{valueAxis:e.valueAxis,markValues:g,range:e.normalizedRange,showValueAxisLabels:e.showValueAxisLabels,onMarkClick:N,isRTL:e.isRTL})]}),M&&r.jsx(Q.SliderTextField,{value:n,readOnly:e.readOnly,disabled:e.disabled,error:e.hasError,getValidValue:d,setValue:l,textFieldWidth:z,min:e.normalizedMin,max:e.normalizedMax,step:s,errorId:e.ids.error,ariaLabelledby:e.aria.labelledBy,ariaLabel:e.aria.label}),x&&r.jsx("div",{className:R.styles[`${e.bem.subElementClassPrefix}content-after`],children:x})]}),e.name&&r.jsx("input",{type:"hidden",ref:e.internalInputRef,id:e.ids.input,name:e.name,value:n,disabled:e.disabled}),r.jsxs(J.HelperTextProvider,{ctxId:e.ids.helperText,ctxDisabled:e.disabled,children:[j,r.jsx($.SliderError,{error:e.error,errorId:e.ids.error})]}),e.showErrors(e.ids.validationErrors)]})});exports.SingleSlider=q;exports.default=q;
|
|
@@ -85,7 +85,7 @@ const kr = F.forwardRef(function({
|
|
|
85
85
|
);
|
|
86
86
|
l(_), o(!0);
|
|
87
87
|
},
|
|
88
|
-
[r.disabled, r.readOnly, r.normalizedRange, r.isRTL, l]
|
|
88
|
+
[r.disabled, r.readOnly, r.normalizedRange, r.isRTL, r.trackRef, l]
|
|
89
89
|
);
|
|
90
90
|
ir(s, p, () => o(!1));
|
|
91
91
|
const [D, O] = r.normalizedRange, x = Y(Number(a), D, O);
|
package/lib/Slider/Slider.es.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
-
import D from "react";
|
|
2
|
+
import { forwardRef as D } from "react";
|
|
3
3
|
import { SingleSlider as L } from "./SingleSlider.es.js";
|
|
4
|
-
import { DualSlider as
|
|
5
|
-
import { useSliderBase as
|
|
6
|
-
const
|
|
4
|
+
import { DualSlider as g } from "./DualSlider.es.js";
|
|
5
|
+
import { useSliderBase as w } from "./hooks/useSliderBase.es.js";
|
|
6
|
+
const B = D(
|
|
7
7
|
function(a, e) {
|
|
8
8
|
const {
|
|
9
9
|
name: o,
|
|
@@ -11,10 +11,10 @@ const w = D.forwardRef(
|
|
|
11
11
|
disabled: t,
|
|
12
12
|
readOnly: d,
|
|
13
13
|
required: n,
|
|
14
|
-
className:
|
|
15
|
-
range:
|
|
16
|
-
step:
|
|
17
|
-
min:
|
|
14
|
+
className: m,
|
|
15
|
+
range: u,
|
|
16
|
+
step: b,
|
|
17
|
+
min: f,
|
|
18
18
|
max: c,
|
|
19
19
|
label: y,
|
|
20
20
|
valueAxis: S,
|
|
@@ -23,17 +23,17 @@ const w = D.forwardRef(
|
|
|
23
23
|
"aria-label": x,
|
|
24
24
|
"aria-labelledby": v,
|
|
25
25
|
...r
|
|
26
|
-
} = a, l =
|
|
26
|
+
} = a, l = w(
|
|
27
27
|
{
|
|
28
28
|
name: o,
|
|
29
29
|
validationRules: s,
|
|
30
30
|
disabled: t,
|
|
31
31
|
readOnly: d,
|
|
32
32
|
required: n,
|
|
33
|
-
className:
|
|
34
|
-
range:
|
|
35
|
-
step:
|
|
36
|
-
min:
|
|
33
|
+
className: m,
|
|
34
|
+
range: u,
|
|
35
|
+
step: b,
|
|
36
|
+
min: f,
|
|
37
37
|
max: c,
|
|
38
38
|
label: y,
|
|
39
39
|
valueAxis: S,
|
|
@@ -45,7 +45,7 @@ const w = D.forwardRef(
|
|
|
45
45
|
e
|
|
46
46
|
);
|
|
47
47
|
return Array.isArray(a.value) || Array.isArray(a.defaultValue) ? /* @__PURE__ */ i(
|
|
48
|
-
|
|
48
|
+
g,
|
|
49
49
|
{
|
|
50
50
|
ref: e,
|
|
51
51
|
base: l,
|
|
@@ -60,8 +60,8 @@ const w = D.forwardRef(
|
|
|
60
60
|
}
|
|
61
61
|
);
|
|
62
62
|
}
|
|
63
|
-
),
|
|
63
|
+
), N = B;
|
|
64
64
|
export {
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
N as Slider,
|
|
66
|
+
N as default
|
|
67
67
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react"),n=require("../utils/sliderLogic.utils.cjs.js");function D({value:
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react"),n=require("../utils/sliderLogic.utils.cjs.js");function D({value:d,defaultValue:g,range:[S,f],min:l,max:e,step:a,valueAxis:k,restrictToValueAxis:C=!1,onChange:M,minGap:h}){const o=h??a,r=c.useMemo(()=>n.calculateMarkValues(k,S,f),[k,S,f]),_=c.useCallback(u=>n.getClosestMark(u,r,l,e),[r,l,e]),F=c.useCallback(u=>n.getClosestStep(u,l,e,a),[l,e,a]),i=c.useCallback(u=>n.getValidValue(u,C,r,l,e,a),[C,r,l,e,a]),b=d!==void 0,L=()=>g!==void 0?g:[l,e],[q,w]=c.useState(L()),V=d!==void 0?d:q,y=c.useCallback(u=>{let[t,s]=u;t=i(t),s=i(s),s-t<o&&(t!==V[0]?t=Math.min(t,s-o):s=Math.max(s,t+o)),t=Math.max(l,Math.min(t,e-o)),s=Math.max(t+o,Math.min(s,e));const v=[t,s];b||w(v),M&&M(v)},[i,b,M,V,o,l,e]);return{value:V,setValue:y,markValues:r,getClosestMark:_,getClosestStep:F,getValidValue:i,min:l,max:e,step:a}}exports.useDualSliderLogic=D;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { useMemo as I, useCallback as n, useState as L } from "react";
|
|
2
2
|
import { calculateMarkValues as U, getClosestMark as j, getClosestStep as q, getValidValue as y } from "../utils/sliderLogic.utils.es.js";
|
|
3
3
|
function H({
|
|
4
|
-
value:
|
|
5
|
-
defaultValue:
|
|
6
|
-
range: [
|
|
4
|
+
value: i,
|
|
5
|
+
defaultValue: f,
|
|
6
|
+
range: [d, g],
|
|
7
7
|
min: l,
|
|
8
8
|
max: e,
|
|
9
9
|
step: a,
|
|
10
|
-
valueAxis:
|
|
11
|
-
restrictToValueAxis:
|
|
10
|
+
valueAxis: k,
|
|
11
|
+
restrictToValueAxis: v = !1,
|
|
12
12
|
onChange: V,
|
|
13
13
|
minGap: h
|
|
14
14
|
}) {
|
|
15
15
|
const r = h ?? a, u = I(
|
|
16
|
-
() => U(
|
|
17
|
-
[
|
|
16
|
+
() => U(k, d, g),
|
|
17
|
+
[k, d, g]
|
|
18
18
|
), F = n(
|
|
19
19
|
(s) => j(s, u, l, e),
|
|
20
20
|
[u, l, e]
|
|
@@ -22,20 +22,20 @@ function H({
|
|
|
22
22
|
(s) => q(s, l, e, a),
|
|
23
23
|
[l, e, a]
|
|
24
24
|
), c = n(
|
|
25
|
-
(s) => y(s,
|
|
26
|
-
[
|
|
27
|
-
),
|
|
25
|
+
(s) => y(s, v, u, l, e, a),
|
|
26
|
+
[v, u, l, e, a]
|
|
27
|
+
), C = i !== void 0, w = () => f !== void 0 ? f : [l, e], [b, D] = L(
|
|
28
28
|
w()
|
|
29
|
-
), M = i ?
|
|
29
|
+
), M = i !== void 0 ? i : b, G = n(
|
|
30
30
|
(s) => {
|
|
31
31
|
let [t, o] = s;
|
|
32
32
|
t = c(t), o = c(o), o - t < r && (t !== M[0] ? t = Math.min(t, o - r) : o = Math.max(o, t + r)), t = Math.max(l, Math.min(t, e - r)), o = Math.max(t + r, Math.min(o, e));
|
|
33
|
-
const
|
|
34
|
-
|
|
33
|
+
const S = [t, o];
|
|
34
|
+
C || D(S), V && V(S);
|
|
35
35
|
},
|
|
36
36
|
[
|
|
37
37
|
c,
|
|
38
|
-
|
|
38
|
+
C,
|
|
39
39
|
V,
|
|
40
40
|
M,
|
|
41
41
|
r,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react"),r=require("../utils/sliderLogic.utils.cjs.js");function q({value:
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react"),r=require("../utils/sliderLogic.utils.cjs.js");function q({value:c,defaultValue:d,range:[g,n],min:e,max:l,step:o,valueAxis:S,restrictToValueAxis:V=!1,onChange:a}){const u=s.useMemo(()=>r.calculateMarkValues(S,g,n),[S,g,n]),b=s.useCallback(t=>r.getClosestMark(t,u,e,l),[u,e,l]),v=s.useCallback(t=>r.getClosestStep(t,e,l,o),[e,l,o]),i=s.useCallback(t=>r.getValidValue(t,V,u,e,l,o),[V,u,e,l,o]),k=c!==void 0,f=()=>d!==void 0?d:e,[M,_]=s.useState(f()),F=c!==void 0?c:M,L=s.useCallback(t=>{const C=i(t);k||_(C),a&&a(C)},[i,k,a]);return{value:F,setValue:L,markValues:u,getClosestMark:b,getClosestStep:v,getValidValue:i,min:e,max:l,step:o}}exports.useSingleSliderLogic=q;
|
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
import { useMemo as I, useCallback as r, useState as L } from "react";
|
|
2
2
|
import { calculateMarkValues as U, getClosestMark as j, getClosestStep as q, getValidValue as w } from "../utils/sliderLogic.utils.es.js";
|
|
3
3
|
function B({
|
|
4
|
-
value:
|
|
5
|
-
defaultValue:
|
|
6
|
-
range: [
|
|
4
|
+
value: u,
|
|
5
|
+
defaultValue: V,
|
|
6
|
+
range: [d, g],
|
|
7
7
|
min: e,
|
|
8
8
|
max: t,
|
|
9
9
|
step: o,
|
|
10
|
-
valueAxis:
|
|
11
|
-
restrictToValueAxis:
|
|
12
|
-
onChange:
|
|
10
|
+
valueAxis: i,
|
|
11
|
+
restrictToValueAxis: n = !1,
|
|
12
|
+
onChange: a
|
|
13
13
|
}) {
|
|
14
14
|
const s = I(
|
|
15
|
-
() => U(
|
|
16
|
-
[
|
|
15
|
+
() => U(i, d, g),
|
|
16
|
+
[i, d, g]
|
|
17
17
|
), k = r(
|
|
18
18
|
(l) => j(l, s, e, t),
|
|
19
19
|
[s, e, t]
|
|
20
20
|
), C = r(
|
|
21
21
|
(l) => q(l, e, t, o),
|
|
22
22
|
[e, t, o]
|
|
23
|
-
),
|
|
24
|
-
(l) => w(l,
|
|
25
|
-
[
|
|
26
|
-
),
|
|
23
|
+
), c = r(
|
|
24
|
+
(l) => w(l, n, s, e, t, o),
|
|
25
|
+
[n, s, e, t, o]
|
|
26
|
+
), S = u !== void 0, v = () => V !== void 0 ? V : e, [F, M] = L(
|
|
27
27
|
v()
|
|
28
|
-
), p =
|
|
28
|
+
), p = u !== void 0 ? u : F, b = r(
|
|
29
29
|
(l) => {
|
|
30
|
-
const f =
|
|
31
|
-
|
|
30
|
+
const f = c(l);
|
|
31
|
+
S || M(f), a && a(f);
|
|
32
32
|
},
|
|
33
|
-
[
|
|
33
|
+
[c, S, a]
|
|
34
34
|
);
|
|
35
35
|
return {
|
|
36
36
|
value: p,
|
|
@@ -38,7 +38,7 @@ function B({
|
|
|
38
38
|
markValues: s,
|
|
39
39
|
getClosestMark: k,
|
|
40
40
|
getClosestStep: C,
|
|
41
|
-
getValidValue:
|
|
41
|
+
getValidValue: c,
|
|
42
42
|
min: e,
|
|
43
43
|
max: t,
|
|
44
44
|
step: o
|
package/lib/Tabs/Tabs.Group.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ComponentPropsWithoutRef, ReactElement } from 'react';
|
|
2
2
|
import { Box } from '../Box/Box';
|
|
3
3
|
import { TabsItemProps } from './Tabs.Item';
|
|
4
|
-
export interface TabsGroupProps extends
|
|
4
|
+
export interface TabsGroupProps extends ComponentPropsWithoutRef<typeof Box> {
|
|
5
5
|
/**
|
|
6
6
|
* Specify the items for the group
|
|
7
7
|
*/
|
package/lib/Tabs/Tabs.Item.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
2
|
-
export interface TabsItemProps extends
|
|
1
|
+
import { default as React, ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
export interface TabsItemProps extends ComponentPropsWithoutRef<'div'> {
|
|
3
3
|
/**
|
|
4
4
|
* Specify the value of the item
|
|
5
5
|
*/
|
package/lib/Tabs/Tabs.Panel.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
2
|
-
export interface TabsPanelProps extends
|
|
1
|
+
import { default as React, ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
export interface TabsPanelProps extends ComponentPropsWithoutRef<'div'> {
|
|
3
3
|
/**
|
|
4
4
|
* Specify the value of the panel
|
|
5
5
|
*/
|
package/lib/Text/Text.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
1
|
+
import { default as React, HTMLAttributes } from 'react';
|
|
2
2
|
import { TextAlignment, TextColor, TextKind, TextWordBreak } from '@viasat/beam-shared/components/text';
|
|
3
3
|
import { ThemeTypes } from '@viasat/beam-shared/utils/constants';
|
|
4
|
-
export interface TextProps extends
|
|
4
|
+
export interface TextProps extends HTMLAttributes<HTMLElement> {
|
|
5
5
|
/**
|
|
6
6
|
* The text content
|
|
7
7
|
*/
|
package/lib/Text/Text.es.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import "../../assets/Text.css";
|
|
2
2
|
import { jsx as I } from "react/jsx-runtime";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { p as
|
|
6
|
-
import { g as
|
|
7
|
-
const d = `${
|
|
3
|
+
import A from "clsx";
|
|
4
|
+
import { forwardRef as P } from "react";
|
|
5
|
+
import { p as E, t as N } from "../../chunks/constants.CKKGf1-i.js";
|
|
6
|
+
import { g as T } from "../../chunks/classNames.BTJmrO_L.js";
|
|
7
|
+
const d = `${E}sem-typo-`, _ = "compact-", k = {
|
|
8
8
|
// defaults
|
|
9
9
|
"heading-6xl": "h1",
|
|
10
10
|
"heading-5xl": "h2",
|
|
@@ -124,7 +124,7 @@ const d = `${P}sem-typo-`, T = "compact-", k = {
|
|
|
124
124
|
"bm-text--expressiveStronger": "bm-text--expressiveStronger",
|
|
125
125
|
"bm-text--expressiveInverse": "bm-text--expressiveInverse",
|
|
126
126
|
"bm-text--expressiveInverseStronger": "bm-text--expressiveInverseStronger"
|
|
127
|
-
}, { baseClassNamePrefix: C, classModifierPrefix: t } =
|
|
127
|
+
}, { baseClassNamePrefix: C, classModifierPrefix: t } = T("text"), M = P(
|
|
128
128
|
({
|
|
129
129
|
kind: m = "body-md",
|
|
130
130
|
color: b,
|
|
@@ -142,19 +142,19 @@ const d = `${P}sem-typo-`, T = "compact-", k = {
|
|
|
142
142
|
children: c,
|
|
143
143
|
className: v,
|
|
144
144
|
...f
|
|
145
|
-
},
|
|
146
|
-
const
|
|
145
|
+
}, $) => {
|
|
146
|
+
const u = x || k[m], p = !m.includes("body");
|
|
147
147
|
s && p && console.warn(
|
|
148
148
|
"The `bold` prop is not supported for heading, label or detail `kind` variants. Use the `bold` for body `kind` variants."
|
|
149
149
|
);
|
|
150
|
-
const S =
|
|
150
|
+
const S = A(
|
|
151
151
|
e[C],
|
|
152
|
-
a &&
|
|
152
|
+
a && N(a),
|
|
153
153
|
// no need to redo typography tokens, fonts are already defined in typography.classes.css
|
|
154
154
|
m && e[`${d}${m}`],
|
|
155
155
|
// no need to redo compact typography tokens, if a font does not support compact, this class will
|
|
156
156
|
// not exist and therefore not be applied
|
|
157
|
-
i && e[`${d}${
|
|
157
|
+
i && e[`${d}${_}${m}`],
|
|
158
158
|
s && !p && e[`${t}body-bold`],
|
|
159
159
|
b && e[`${t}${b}`],
|
|
160
160
|
o && e[`${t}${o}`],
|
|
@@ -166,7 +166,7 @@ const d = `${P}sem-typo-`, T = "compact-", k = {
|
|
|
166
166
|
h && e[`${t}italic`],
|
|
167
167
|
v
|
|
168
168
|
);
|
|
169
|
-
return /* @__PURE__ */ I(
|
|
169
|
+
return /* @__PURE__ */ I(u, { ref: $, className: S, ...f, children: c });
|
|
170
170
|
}
|
|
171
171
|
);
|
|
172
172
|
M.displayName = "Text";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const b=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const b=require("react/jsx-runtime"),s=require("react"),g=require("./Option.context.cjs.js"),m=require("./OptionGroup.context.cjs.js"),q=require("../../utils/functions.cjs.js"),v=require("../../utils/hooks/useId.cjs.js"),d=({className:C,label:u,value:f,children:t,...i})=>{const o=s.useMemo(()=>u??q.extractTextFromReactNode(t),[u,t]),n=f??o,{selectOption:r,deselectOption:c,registerOption:l,unregisterOption:a,setOptionProps:p}=g.useOptionsContext(),{groupId:O}=m.useOptionGroupContext(),e=v.useId()??"",_=s.useCallback(x=>{x?r(e):c(e)},[c,e,r]);return s.useLayoutEffect(()=>(l(e,O),()=>a(e)),[e,O,l,a]),s.useEffect(()=>{p(e,{...i,label:o,value:n,children:t,onSelectionChange:_})},[t,e,o,_,i,p,n]),b.jsx("option",{value:n,children:o})};exports.Option=d;exports.default=d;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),V=r.createContext(null),D=V.Provider,L=()=>{const o=r.useContext(V);if(!o)throw new Error("useOptionsContext must be used within an OptionsProvider");return o},z=o=>Array.isArray(o)?o:o!==void 0?[o]:[],F=(o,u,a)=>{const g=r.useRef(void 0),[c,M]=r.useState(()=>new Map),[i,k]=r.useState(()=>[]),[A,w]=r.useState(()=>new Map),[C,b]=r.useState(()=>new Map),[x,d]=r.useState(()=>[]),O=r.useRef(c);O.current=c;const l=r.useMemo(()=>z(o),[o]),p=r.useRef(l);p.current=l,r.useMemo(()=>{if(!l.length)g.current=void 0;else{const n=l[l.length-1],t=i.map(e=>c.get(e)).findIndex(e=>(e==null?void 0:e.value)===n);g.current=t}},[l,i,c]);const m=r.useCallback(n=>{const t=O.current.get(n),e=t==null?void 0:t.value,s=p.current;t&&e&&u(a?[...s.filter(f=>f!==e),e]:e)},[a,u]),y=r.useCallback(n=>{const t=O.current.get(n),e=t==null?void 0:t.value,s=p.current;if(t&&e)if(a){if(!s.includes(e))return;u(s.filter(f=>f!==e))}else return},[a,u]),B=r.useCallback(n=>{if(!a||n===void 0)return;const e=z(n)[0];if(!e)return;const s=p.current;s.includes(e)&&u(s.filter(f=>f!==e))},[a,u]),v=r.useCallback((n,t)=>{k(e=>[...e,n]),b(e=>{const s=new Map(e);return s.set(n,t),s}),t===null&&d(e=>[...e,{kind:"option",id:n}])},[]),S=r.useCallback(n=>{k(t=>t.filter(e=>e!==n)),M(t=>{const e=new Map(t);return e.delete(n),e}),b(t=>{const e=new Map(t);return e.delete(n),e}),d(t=>t.filter(e=>!(e.kind==="option"&&e.id===n)))},[]),h=r.useCallback((n,t)=>M(e=>{const s=new Map(e);return s.set(n,t),s}),[]),I=r.useCallback(n=>{d(t=>[...t,{kind:"group",id:n}])},[]),P=r.useCallback(n=>{w(t=>{const e=new Map(t);return e.delete(n),e}),d(t=>t.filter(e=>!(e.kind==="group"&&e.id===n)))},[]),G=r.useCallback((n,t)=>w(e=>{const s=new Map(e);return s.set(n,t),s}),[]),E=r.useMemo(()=>({setValue:u,registerOption:v,unregisterOption:S,setOptionProps:h,selectOption:m,deselectOption:y,registerGroup:I,unregisterGroup:P,setGroupProps:G}),[u,v,S,h,m,y,I,P,G]),T=r.useMemo(()=>{if(!o||!c.size)return[];const n=Array.from(c.values()),t=new Map(n.map(e=>[e.value,e]));return p.current.length===0?[]:p.current.map(e=>t.get(e)).filter(Boolean)},[o,c]),R=r.useCallback(n=>O.current.get(n),[]),j=r.useCallback(n=>{const t=i[n];if(t)return R(t)},[R,i]),q=r.useMemo(()=>{const n=new Map;return x.forEach(t=>{t.kind==="group"&&n.set(t.id,[])}),i.forEach(t=>{const e=C.get(t);if(e!=null){const s=n.get(e);s&&s.push(t)}}),n},[x,i,C]);return{optionsContext:E,selectedOptionsProps:T,optionIds:i,optionsProps:c,deselectOptionValue:B,indexOfLastSelectedOptionRef:g,getOptionByIndex:j,structureIds:x,groupsProps:A,optionGroupOf:C,optionIdsByGroup:q}};exports.OptionsProvider=D;exports.useCreateOptionsContext=F;exports.useOptionsContext=L;
|
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
import { SelectHTMLAttributes } from 'react';
|
|
2
|
-
import { OptionProps } from './Option.types';
|
|
2
|
+
import { OptionGroupProps, OptionProps } from './Option.types';
|
|
3
|
+
export type StructureNode = {
|
|
4
|
+
kind: 'option';
|
|
5
|
+
id: string;
|
|
6
|
+
} | {
|
|
7
|
+
kind: 'group';
|
|
8
|
+
id: string;
|
|
9
|
+
};
|
|
3
10
|
interface OptionsContextValue {
|
|
4
|
-
selectOption: (id:
|
|
5
|
-
deselectOption: (id:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
11
|
+
selectOption: (id: string) => void;
|
|
12
|
+
deselectOption: (id: string) => void;
|
|
13
|
+
/** Register an Option. Pass `null` for `groupId` when the Option is rendered at the root (not inside any OptionGroup). */
|
|
14
|
+
registerOption: (id: string, groupId: string | null) => void;
|
|
15
|
+
unregisterOption: (id: string) => void;
|
|
16
|
+
setOptionProps: (id: string, optionProps: OptionProps) => void;
|
|
17
|
+
registerGroup: (id: string) => void;
|
|
18
|
+
unregisterGroup: (id: string) => void;
|
|
19
|
+
setGroupProps: (id: string, groupProps: OptionGroupProps) => void;
|
|
9
20
|
}
|
|
10
21
|
export declare const OptionsProvider: import('react').Provider<OptionsContextValue | null>;
|
|
11
22
|
export declare const useOptionsContext: () => OptionsContextValue;
|
|
@@ -13,17 +24,24 @@ type ValueType = SelectHTMLAttributes<HTMLSelectElement>['value'];
|
|
|
13
24
|
export declare const useCreateOptionsContext: (value: ValueType, setValue: (value: ValueType) => void, multiple: boolean) => {
|
|
14
25
|
optionsContext: {
|
|
15
26
|
setValue: (value: ValueType) => void;
|
|
16
|
-
registerOption: (id:
|
|
17
|
-
unregisterOption: (id:
|
|
18
|
-
setOptionProps: (id:
|
|
19
|
-
selectOption: (id:
|
|
20
|
-
deselectOption: (id:
|
|
27
|
+
registerOption: (id: string, groupId: string | null) => void;
|
|
28
|
+
unregisterOption: (id: string) => void;
|
|
29
|
+
setOptionProps: (id: string, optionProps: OptionProps) => void;
|
|
30
|
+
selectOption: (id: string) => void;
|
|
31
|
+
deselectOption: (id: string) => void;
|
|
32
|
+
registerGroup: (id: string) => void;
|
|
33
|
+
unregisterGroup: (id: string) => void;
|
|
34
|
+
setGroupProps: (id: string, groupProps: OptionGroupProps) => void;
|
|
21
35
|
};
|
|
22
36
|
selectedOptionsProps: OptionProps[];
|
|
23
|
-
optionIds:
|
|
24
|
-
optionsProps: Map<
|
|
37
|
+
optionIds: string[];
|
|
38
|
+
optionsProps: Map<string, OptionProps>;
|
|
25
39
|
deselectOptionValue: (value: ValueType) => void;
|
|
26
40
|
indexOfLastSelectedOptionRef: import('react').MutableRefObject<number | undefined>;
|
|
27
41
|
getOptionByIndex: (index: number) => OptionProps | undefined;
|
|
42
|
+
structureIds: StructureNode[];
|
|
43
|
+
groupsProps: Map<string, OptionGroupProps>;
|
|
44
|
+
optionGroupOf: Map<string, string | null>;
|
|
45
|
+
optionIdsByGroup: Map<string, string[]>;
|
|
28
46
|
};
|
|
29
47
|
export {};
|