@viasat/beam-react 2.30.0 → 2.36.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 → FloatingUI.css} +1 -1
- 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/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.DFhYQv_F.js +1 -0
- package/chunks/FloatingUI.arrow.tN5_IctZ.js +27 -0
- package/chunks/panel.module.BVmRxZHo.js +1 -0
- package/chunks/{panel.module.BblnuBjO.js → panel.module.CnHWv4EZ.js} +1 -3
- package/index.cjs.js +1 -1
- package/index.es.js +35 -33
- 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/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 +17 -18
- 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/_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/index.cjs.js +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.es.js +27 -25
- 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/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/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,124 +1,155 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import { useMemo as
|
|
4
|
-
import { g as
|
|
1
|
+
import { jsx as A } from "react/jsx-runtime";
|
|
2
|
+
import H from "clsx";
|
|
3
|
+
import { useMemo as K } from "react";
|
|
4
|
+
import { g as oe } from "../../../chunks/classNames.BTJmrO_L.js";
|
|
5
5
|
import "../../../chunks/constants.CKKGf1-i.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
6
|
+
import { usePrevious as R } from "../../../utils/hooks/usePrevious.es.js";
|
|
7
|
+
import { Header as ne } from "./Header/Panel.Header.es.js";
|
|
8
|
+
import { Body as se } from "./Panel.Body.es.js";
|
|
9
|
+
import { Footer as ie } from "./Footer/Panel.Footer.es.js";
|
|
10
|
+
import { resolveOffset as te, usePanelClose as re, getPanelDividerState as ae, PANEL_TRANSITION_DURATION_MS as le, getResolvedPanelPosition as ce, isPresetSize as fe } from "./Panel.helpers.es.js";
|
|
11
|
+
import { InlinePanel as me } from "./Panel.Inline.es.js";
|
|
12
|
+
import { OverlayPanel as ve } from "./Panel.Overlay.es.js";
|
|
13
|
+
import { s as n } from "../../../chunks/panel.module.CnHWv4EZ.js";
|
|
14
|
+
const pe = 165, de = 100, ue = (e, v) => {
|
|
15
|
+
if (!e) return;
|
|
16
|
+
const p = v === "bottom", a = typeof e == "object" ? e : {}, t = a.minSize ?? (p ? de : pe), d = a.maxSize ?? 1 / 0, f = a.storageKey ?? "";
|
|
17
|
+
return { minSize: t, maxSize: d, storageKey: f };
|
|
18
|
+
}, { baseClassNamePrefix: s, variable: ye } = oe("panel");
|
|
19
|
+
function ge(e) {
|
|
20
|
+
return fe(e) ? {
|
|
21
|
+
overlaySizeClass: n[`${s}--size-${e}`],
|
|
22
|
+
inlineSizeClass: n[`${s}__inline-wrapper--size-${e}`],
|
|
23
|
+
sizeStyle: void 0
|
|
24
|
+
} : e !== void 0 ? {
|
|
25
|
+
overlaySizeClass: void 0,
|
|
26
|
+
inlineSizeClass: void 0,
|
|
27
|
+
sizeStyle: { [ye("size")]: e }
|
|
28
|
+
} : { overlaySizeClass: void 0, inlineSizeClass: void 0, sizeStyle: void 0 };
|
|
29
|
+
}
|
|
30
|
+
const m = ({
|
|
31
|
+
children: e,
|
|
32
|
+
className: v,
|
|
20
33
|
padding: p = "md",
|
|
21
|
-
onOpenChange:
|
|
22
|
-
open:
|
|
23
|
-
size:
|
|
34
|
+
onOpenChange: a,
|
|
35
|
+
open: t,
|
|
36
|
+
size: d,
|
|
24
37
|
dismissible: f = !0,
|
|
25
|
-
closeButtonAriaLabel:
|
|
26
|
-
kind:
|
|
38
|
+
closeButtonAriaLabel: P = "Close panel",
|
|
39
|
+
kind: o = "inline",
|
|
27
40
|
position: u,
|
|
28
|
-
divider:
|
|
29
|
-
dividerColor:
|
|
30
|
-
isAnimated:
|
|
31
|
-
onBeforeClose:
|
|
41
|
+
divider: F = !0,
|
|
42
|
+
dividerColor: S,
|
|
43
|
+
isAnimated: C = !0,
|
|
44
|
+
onBeforeClose: j,
|
|
32
45
|
modalType: l,
|
|
33
|
-
offset:
|
|
34
|
-
resizable:
|
|
35
|
-
id:
|
|
36
|
-
...
|
|
46
|
+
offset: z,
|
|
47
|
+
resizable: L,
|
|
48
|
+
id: h,
|
|
49
|
+
...N
|
|
37
50
|
}) => {
|
|
38
|
-
const r =
|
|
51
|
+
const r = ce(u), c = ue(L, r), V = !!c, { container: O, triggerRef: W, ...w } = N, i = o === "overlay" ? O : void 0;
|
|
39
52
|
if (process.env.NODE_ENV !== "production") {
|
|
40
53
|
c && !c.storageKey && console.warn(
|
|
41
54
|
"Panel: provide a `storageKey` in the `resizable` config to persist panel size across sessions."
|
|
42
55
|
), l === "alert" && f && console.warn(
|
|
43
56
|
'Panel: `dismissible` is ignored when `modalType="alert"`. The close button is always hidden.'
|
|
44
57
|
);
|
|
45
|
-
const { closeOnOutsidePress:
|
|
46
|
-
|
|
58
|
+
const { closeOnOutsidePress: ee } = N;
|
|
59
|
+
if (ee && l !== "nonModal" && l !== void 0 && console.warn(
|
|
47
60
|
'Panel: `closeOnOutsidePress` has no effect when `modalType` is not `"nonModal"`.'
|
|
48
|
-
)
|
|
61
|
+
), O && o === "inline" && console.warn('Panel: `container` has no effect when `kind="inline"`.'), i)
|
|
62
|
+
try {
|
|
63
|
+
if (typeof getComputedStyle == "function") {
|
|
64
|
+
const y = getComputedStyle(i);
|
|
65
|
+
y.position === "static" && console.warn(
|
|
66
|
+
"Panel: container element should have `position: relative` (or another non-static value) for proper scoping."
|
|
67
|
+
);
|
|
68
|
+
const g = r === "bottom" ? y.overflowY : y.overflowX;
|
|
69
|
+
(g === "visible" || g === "auto" || g === "scroll") && console.warn(
|
|
70
|
+
"Panel: container element should use `overflow: hidden` (or `clip`) so the slide-in/out transform does not trigger a transient scrollbar."
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
} catch {
|
|
74
|
+
}
|
|
49
75
|
}
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
76
|
+
const _ = l === "alert" ? !1 : f, { overlaySizeClass: q, inlineSizeClass: G, sizeStyle: $ } = ge(d), b = o === "overlay" && z ? te(z) : void 0, I = !!b, E = H(
|
|
77
|
+
n[s],
|
|
78
|
+
n[`${s}--${o}`],
|
|
79
|
+
o === "overlay" && q,
|
|
80
|
+
n[`${s}--padding-${p}`],
|
|
81
|
+
n[`${s}--position-${r}`],
|
|
82
|
+
I && n[`${s}--floating`],
|
|
83
|
+
V && n[`${s}--resizable`],
|
|
84
|
+
o === "overlay" && i && n[`${s}--contained`],
|
|
85
|
+
v
|
|
86
|
+
), U = H(
|
|
87
|
+
n[`${s}__inline-wrapper`],
|
|
88
|
+
G
|
|
89
|
+
), { requestClose: M, handleOverlayOpenChange: X } = re(
|
|
90
|
+
j,
|
|
91
|
+
a
|
|
92
|
+
), x = K(
|
|
66
93
|
() => ({
|
|
67
|
-
kind:
|
|
68
|
-
dismissible:
|
|
69
|
-
closeButtonAriaLabel:
|
|
94
|
+
kind: o,
|
|
95
|
+
dismissible: _,
|
|
96
|
+
closeButtonAriaLabel: P,
|
|
70
97
|
position: u,
|
|
71
|
-
requestClose:
|
|
98
|
+
requestClose: M
|
|
72
99
|
}),
|
|
73
|
-
[
|
|
74
|
-
), { showDivider:
|
|
75
|
-
() => ({ duration:
|
|
76
|
-
[
|
|
77
|
-
),
|
|
78
|
-
return
|
|
79
|
-
|
|
100
|
+
[o, _, P, u, M]
|
|
101
|
+
), { showDivider: Y, dividerBefore: J, dividerInner: Q, dividerAfter: Z } = ae(F && !I, r), D = K(
|
|
102
|
+
() => ({ duration: C ? le : 0 }),
|
|
103
|
+
[C]
|
|
104
|
+
), B = R(o), k = R(i), T = B !== void 0 && B !== o && t === !0 || k === null && i != null && t === !0;
|
|
105
|
+
return i === null ? null : o === "inline" ? /* @__PURE__ */ A(
|
|
106
|
+
me,
|
|
80
107
|
{
|
|
81
|
-
contextValue:
|
|
82
|
-
panelClassName:
|
|
83
|
-
inlineWrapperClassName:
|
|
108
|
+
contextValue: x,
|
|
109
|
+
panelClassName: E,
|
|
110
|
+
inlineWrapperClassName: U,
|
|
84
111
|
resolvedPosition: r,
|
|
85
|
-
dividerBefore:
|
|
86
|
-
dividerInner:
|
|
87
|
-
dividerAfter:
|
|
88
|
-
dividerColor:
|
|
89
|
-
open:
|
|
90
|
-
transitionConfig:
|
|
112
|
+
dividerBefore: J,
|
|
113
|
+
dividerInner: Q,
|
|
114
|
+
dividerAfter: Z,
|
|
115
|
+
dividerColor: S,
|
|
116
|
+
open: t,
|
|
117
|
+
transitionConfig: D,
|
|
91
118
|
resizeConfig: c,
|
|
92
|
-
skipMountAnimation:
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
119
|
+
skipMountAnimation: T,
|
|
120
|
+
sizeStyle: $,
|
|
121
|
+
id: h,
|
|
122
|
+
...w,
|
|
123
|
+
children: e
|
|
96
124
|
}
|
|
97
|
-
) : /* @__PURE__ */
|
|
98
|
-
|
|
125
|
+
) : /* @__PURE__ */ A(
|
|
126
|
+
ve,
|
|
99
127
|
{
|
|
100
|
-
contextValue:
|
|
101
|
-
panelClassName:
|
|
128
|
+
contextValue: x,
|
|
129
|
+
panelClassName: E,
|
|
102
130
|
resolvedPosition: r,
|
|
103
|
-
showDivider:
|
|
104
|
-
dividerColor:
|
|
131
|
+
showDivider: Y,
|
|
132
|
+
dividerColor: S,
|
|
105
133
|
modalType: l,
|
|
106
|
-
floatingOffset:
|
|
107
|
-
open:
|
|
108
|
-
onOpenChange:
|
|
109
|
-
transitionConfig:
|
|
134
|
+
floatingOffset: b,
|
|
135
|
+
open: t,
|
|
136
|
+
onOpenChange: X,
|
|
137
|
+
transitionConfig: D,
|
|
110
138
|
resizeConfig: c,
|
|
111
|
-
skipMountAnimation:
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
139
|
+
skipMountAnimation: T,
|
|
140
|
+
sizeStyle: $,
|
|
141
|
+
id: h,
|
|
142
|
+
...w,
|
|
143
|
+
container: i,
|
|
144
|
+
triggerRef: W,
|
|
145
|
+
children: e
|
|
115
146
|
}
|
|
116
147
|
);
|
|
117
148
|
};
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
149
|
+
m.displayName = "Panel";
|
|
150
|
+
m.Header = ne;
|
|
151
|
+
m.Body = se;
|
|
152
|
+
m.Footer = ie;
|
|
122
153
|
export {
|
|
123
|
-
|
|
154
|
+
m as Panel
|
|
124
155
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react"),o=e=>e==="sm"||e==="md"||e==="lg",a=400;function P(e){return e===!0?{x:"1rem",y:"1rem"}:typeof e=="string"?{x:e,y:e}:{x:e.x,y:e.y}}const d="01",f=e=>e||"end",D=(e,s)=>({showDivider:e,dividerBefore:e&&s!=="start"&&s!=="bottom",dividerInner:e&&s==="bottom",dividerAfter:e&&s==="start"}),_=(e,s)=>{if(e!=="isModal")return e==="alert"?{escapeKey:!1,outsidePress:!1}:{escapeKey:!0,outsidePress:s??!1}},v=e=>e==="escape-key"?"escapeKey":e==="outside-press"?"outsidePress":"programmatic",y=(e,s)=>{const i=c.useCallback(l=>{if(!e){s==null||s(!1);return}const r=e(l);r instanceof Promise?r.then(t=>{t&&(s==null||s(!1))}).catch(t=>{process.env.NODE_ENV!=="production"&&console.warn("Panel: `onBeforeClose` rejected; close cancelled (panel stays open). If this was not intentional, handle the error inside `onBeforeClose`.",t)}):r&&(s==null||s(!1))},[e,s]),u=c.useCallback((l,r,t)=>{l?s==null||s(!0):i(v(t))},[s,i]);return{requestClose:i,handleOverlayOpenChange:u}};exports.DEFAULT_PANEL_DIVIDER_COLOR=d;exports.PANEL_TRANSITION_DURATION_MS=a;exports.getPanelDismissConfig=_;exports.getPanelDividerState=D;exports.getResolvedPanelPosition=f;exports.isPresetSize=o;exports.resolveOffset=P;exports.usePanelClose=y;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { OpenChangeReason } from '@floating-ui/react';
|
|
2
|
-
import { OverlayPanelProps, PanelCloseReason, PanelDividerColor, PanelModalType, PanelPosition, PanelProps, ResolvedPanelOffset } from './Panel.types';
|
|
2
|
+
import { OverlayPanelProps, PanelCloseReason, PanelDividerColor, PanelModalType, PanelPosition, PanelProps, PanelSize, ResolvedPanelOffset } from './Panel.types';
|
|
3
|
+
export declare const isPresetSize: (s: PanelSize | undefined) => s is "sm" | "md" | "lg";
|
|
3
4
|
export declare const PANEL_TRANSITION_DURATION_MS = 400;
|
|
4
5
|
export declare function resolveOffset(offset: Exclude<OverlayPanelProps['offset'], false | undefined>): ResolvedPanelOffset;
|
|
5
6
|
export declare const DEFAULT_PANEL_DIVIDER_COLOR: PanelDividerColor;
|
|
@@ -1,49 +1,51 @@
|
|
|
1
|
-
import { useCallback as
|
|
2
|
-
const
|
|
3
|
-
function
|
|
1
|
+
import { useCallback as c } from "react";
|
|
2
|
+
const o = (t) => t === "sm" || t === "md" || t === "lg", a = 400;
|
|
3
|
+
function P(t) {
|
|
4
4
|
return t === !0 ? { x: "1rem", y: "1rem" } : typeof t == "string" ? { x: t, y: t } : { x: t.x, y: t.y };
|
|
5
5
|
}
|
|
6
|
-
const m = "01", y = (t) => t || "end",
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
dividerAfter: s && r === "start"
|
|
15
|
-
};
|
|
16
|
-
}, _ = (t, r) => {
|
|
6
|
+
const m = "01", y = (t) => t || "end", v = (t, e) => ({
|
|
7
|
+
showDivider: t,
|
|
8
|
+
dividerBefore: t && e !== "start" && e !== "bottom",
|
|
9
|
+
// For 'bottom' panels the divider must sit inside the scrollable wrapper (above the content),
|
|
10
|
+
// not outside it — so it is rendered via dividerInner rather than dividerBefore.
|
|
11
|
+
dividerInner: t && e === "bottom",
|
|
12
|
+
dividerAfter: t && e === "start"
|
|
13
|
+
}), D = (t, e) => {
|
|
17
14
|
if (t !== "isModal")
|
|
18
|
-
return t === "alert" ? { escapeKey: !1, outsidePress: !1 } : { escapeKey: !0, outsidePress:
|
|
19
|
-
},
|
|
20
|
-
const
|
|
21
|
-
(
|
|
15
|
+
return t === "alert" ? { escapeKey: !1, outsidePress: !1 } : { escapeKey: !0, outsidePress: e ?? !1 };
|
|
16
|
+
}, f = (t) => t === "escape-key" ? "escapeKey" : t === "outside-press" ? "outsidePress" : "programmatic", _ = (t, e) => {
|
|
17
|
+
const i = c(
|
|
18
|
+
(l) => {
|
|
22
19
|
if (!t) {
|
|
23
|
-
|
|
20
|
+
e == null || e(!1);
|
|
24
21
|
return;
|
|
25
22
|
}
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}).catch(() => {
|
|
30
|
-
|
|
23
|
+
const s = t(l);
|
|
24
|
+
s instanceof Promise ? s.then((r) => {
|
|
25
|
+
r && (e == null || e(!1));
|
|
26
|
+
}).catch((r) => {
|
|
27
|
+
process.env.NODE_ENV !== "production" && console.warn(
|
|
28
|
+
"Panel: `onBeforeClose` rejected; close cancelled (panel stays open). If this was not intentional, handle the error inside `onBeforeClose`.",
|
|
29
|
+
r
|
|
30
|
+
);
|
|
31
|
+
}) : s && (e == null || e(!1));
|
|
31
32
|
},
|
|
32
|
-
[t,
|
|
33
|
-
),
|
|
34
|
-
(
|
|
35
|
-
|
|
33
|
+
[t, e]
|
|
34
|
+
), u = c(
|
|
35
|
+
(l, s, r) => {
|
|
36
|
+
l ? e == null || e(!0) : i(f(r));
|
|
36
37
|
},
|
|
37
|
-
[
|
|
38
|
+
[e, i]
|
|
38
39
|
);
|
|
39
|
-
return { requestClose:
|
|
40
|
+
return { requestClose: i, handleOverlayOpenChange: u };
|
|
40
41
|
};
|
|
41
42
|
export {
|
|
42
43
|
m as DEFAULT_PANEL_DIVIDER_COLOR,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
a as PANEL_TRANSITION_DURATION_MS,
|
|
45
|
+
D as getPanelDismissConfig,
|
|
46
|
+
v as getPanelDividerState,
|
|
46
47
|
y as getResolvedPanelPosition,
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
o as isPresetSize,
|
|
49
|
+
P as resolveOffset,
|
|
50
|
+
_ as usePanelClose
|
|
49
51
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ComponentPropsWithoutRef } from 'react';
|
|
1
|
+
import { ComponentPropsWithoutRef, RefObject } from 'react';
|
|
2
2
|
import { PanelDividerColor, PanelDividerColors } from '@viasat/beam-shared/components/panel';
|
|
3
3
|
export type { PanelDividerColor };
|
|
4
4
|
export { PanelDividerColors };
|
|
@@ -7,9 +7,9 @@ export type ResolvedPanelOffset = {
|
|
|
7
7
|
x: string;
|
|
8
8
|
y: string;
|
|
9
9
|
};
|
|
10
|
-
export type PanelPosition = 'start' | 'end' | 'bottom'
|
|
10
|
+
export type PanelPosition = 'start' | 'end' | 'bottom';
|
|
11
11
|
export type PanelModalType = 'nonModal' | 'isModal' | 'alert';
|
|
12
|
-
export type PanelSize = 'sm' | 'md' | 'lg' |
|
|
12
|
+
export type PanelSize = 'sm' | 'md' | 'lg' | (string & {});
|
|
13
13
|
export type PanelPadding = 'sm' | 'md';
|
|
14
14
|
/**
|
|
15
15
|
* Configuration for resizable panels.
|
|
@@ -60,9 +60,20 @@ interface BasePanelProps extends ComponentPropsWithoutRef<'aside'> {
|
|
|
60
60
|
onOpenChange?: (open: boolean) => void;
|
|
61
61
|
/**
|
|
62
62
|
* Specify the size of the Panel.
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
63
|
+
*
|
|
64
|
+
* **Named presets** (`'sm'`, `'md'`, `'lg'`) map to design tokens via the
|
|
65
|
+
* `.bm-panel--size-{sm|md|lg}` modifier class, which sets `--bm-comp-panel-size`.
|
|
66
|
+
*
|
|
67
|
+
* **Arbitrary strings** (e.g. `"480px"`, `"100dvh"`) are applied directly as
|
|
68
|
+
* `--bm-comp-panel-size` via inline style, giving full CSS flexibility.
|
|
69
|
+
*
|
|
70
|
+
* For `position="bottom"`, the variable drives `height` instead of `width`
|
|
71
|
+
* (axis-awareness is in SCSS). Width is always `100%` for bottom panels.
|
|
72
|
+
*
|
|
73
|
+
* When omitted: non-bottom panels fall back to the `md` token; bottom panels
|
|
74
|
+
* fall back to `auto` (content-driven height, capped at `90dvh`). Prefer
|
|
75
|
+
* omitting `size` over `size="auto"` for bottom panels — explicitly passing
|
|
76
|
+
* `"auto"` sets `max-height: auto`, removing the `90dvh` viewport cap.
|
|
66
77
|
*/
|
|
67
78
|
size?: PanelSize;
|
|
68
79
|
/**
|
|
@@ -83,7 +94,10 @@ interface BasePanelProps extends ComponentPropsWithoutRef<'aside'> {
|
|
|
83
94
|
*/
|
|
84
95
|
closeButtonAriaLabel?: string;
|
|
85
96
|
/**
|
|
86
|
-
* Whether to animate the panel on open/close
|
|
97
|
+
* Whether to animate the panel on open/close.
|
|
98
|
+
* When `false`, floating-ui's transition timing collapses to zero, which clips
|
|
99
|
+
* the close animation. CSS `transition-duration` values in the stylesheet are
|
|
100
|
+
* unaffected — use `prefers-reduced-motion` in SCSS for motion-sensitive contexts.
|
|
87
101
|
* @default true
|
|
88
102
|
*/
|
|
89
103
|
isAnimated?: boolean;
|
|
@@ -98,15 +112,15 @@ interface BasePanelProps extends ComponentPropsWithoutRef<'aside'> {
|
|
|
98
112
|
*/
|
|
99
113
|
dividerColor?: PanelDividerColor;
|
|
100
114
|
/**
|
|
101
|
-
* Specify the position of the Panel
|
|
102
|
-
* 'start' | 'end' | 'bottom'
|
|
115
|
+
* Specify the position of the Panel.
|
|
116
|
+
* `'start'` | `'end'` | `'bottom'`
|
|
103
117
|
* @default 'end'
|
|
104
118
|
*/
|
|
105
119
|
position?: PanelPosition;
|
|
106
120
|
/**
|
|
107
121
|
* Enables user-resizing via a drag handle at the panel edge.
|
|
108
122
|
* Pass `true` to use default min/max constraints, or an object to set custom
|
|
109
|
-
* values in pixels.
|
|
123
|
+
* values in pixels.
|
|
110
124
|
* Provide a `storageKey` in the config object to persist the panel's last-used size across sessions.
|
|
111
125
|
* @default false
|
|
112
126
|
*/
|
|
@@ -186,6 +200,46 @@ export interface OverlayPanelProps extends BasePanelProps {
|
|
|
186
200
|
x: string;
|
|
187
201
|
y: string;
|
|
188
202
|
};
|
|
203
|
+
/**
|
|
204
|
+
* Portal target for the overlay. When set, the panel renders inside this
|
|
205
|
+
* element using `position: absolute` instead of `position: fixed`. The
|
|
206
|
+
* container must:
|
|
207
|
+
* - establish a containing block (e.g. `position: relative`)
|
|
208
|
+
* - have an appropriate `z-index`
|
|
209
|
+
* - use `overflow: hidden` (or `clip`) so the panel's slide-in/out
|
|
210
|
+
* transform doesn't trigger a transient scrollbar on the container.
|
|
211
|
+
*
|
|
212
|
+
* Pass the resolved element (or `null` until it exists) — the consumer owns
|
|
213
|
+
* resolution. Use a callback ref or state so the value is reactive; when it
|
|
214
|
+
* flips from `null` to the element, the panel re-renders into the container.
|
|
215
|
+
* A plain `useRef` whose `.current` is mutated will not trigger that update.
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* ```tsx
|
|
219
|
+
* const [container, setContainer] = useState<HTMLElement | null>(null);
|
|
220
|
+
* return (
|
|
221
|
+
* <div ref={setContainer} style={{ position: 'relative', overflow: 'hidden' }}>
|
|
222
|
+
* <Panel kind="overlay" container={container} ... />
|
|
223
|
+
* </div>
|
|
224
|
+
* );
|
|
225
|
+
* ```
|
|
226
|
+
*
|
|
227
|
+
* Has no effect on `kind="inline"`.
|
|
228
|
+
*/
|
|
229
|
+
container?: HTMLElement | null;
|
|
230
|
+
/**
|
|
231
|
+
* The element that opens the panel; clicks on it are excluded from outside-press
|
|
232
|
+
* dismissal so it can toggle the panel without the close immediately re-firing.
|
|
233
|
+
* Focus returns to the previously-focused element (typically this trigger) on close.
|
|
234
|
+
* No effect on `kind="inline"`.
|
|
235
|
+
*
|
|
236
|
+
* Note: the exclusion is implemented as a raw `outsidePress` predicate rather than
|
|
237
|
+
* a FloatingUI reference registration. This avoids `autoUpdate` re-renders that
|
|
238
|
+
* interfere with the slide-in CSS transition, but means FloatingUI's nested-floating
|
|
239
|
+
* tree-scoping (`__outsidePressBubbles`) is bypassed for this panel. Avoid using
|
|
240
|
+
* `triggerRef` when the panel is nested inside another FloatingUI floating element.
|
|
241
|
+
*/
|
|
242
|
+
triggerRef?: RefObject<HTMLElement | null>;
|
|
189
243
|
}
|
|
190
244
|
export type PanelProps = InlinePanelProps | OverlayPanelProps;
|
|
191
245
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react"),R=require("../../../utils/hooks/useElementResize.cjs.js"),g=require("../../../utils/hooks/useLocalStorage.cjs.js"),x=({resizeConfig:i,position:s,floatingRef:o,requireMount:n=!1,container:r})=>{const l=!!i,{minSize:f=0,maxSize:S=0,storageKey:c=""}=i??{},m=t.useCallback(()=>{const e=r;return e?s==="bottom"?e.clientHeight*.9:e.clientWidth*.5:1/0},[r,s]),_=r&&S===1/0?m:S,d=t.useRef(null),[a,y]=t.useState(!1),k=t.useCallback(e=>{d.current=e,n&&y(!!e)},[n]),[b,z]=g.useLocalStorage(c||"__panel_no_key__","0",l&&!!c),u=l&&Number(b)>0?Number(b):0,h=t.useCallback(e=>{c&&z(e.toString())},[c,z]);return R.useElementResize(n?l&&a:l,o,d,f,_,u,s==="bottom"?"y":"x",s==="end",h),t.useEffect(()=>{if(!n||!a||!u||!o.current)return;const e=s==="bottom"?"blockSize":"inlineSize";o.current.style[e]=`${u}px`},[a]),{handleRef:k}};exports.usePanelResize=x;
|
|
@@ -10,8 +10,10 @@ type UsePanelResizeOptions = {
|
|
|
10
10
|
* ref and re-applies the stored size each time the panel opens.
|
|
11
11
|
*/
|
|
12
12
|
requireMount?: boolean;
|
|
13
|
+
/** When set, max resize bounds are derived from this element instead of the viewport. */
|
|
14
|
+
container?: HTMLElement;
|
|
13
15
|
};
|
|
14
|
-
export declare const usePanelResize: ({ resizeConfig, position, floatingRef, requireMount, }: UsePanelResizeOptions) => {
|
|
16
|
+
export declare const usePanelResize: ({ resizeConfig, position, floatingRef, requireMount, container, }: UsePanelResizeOptions) => {
|
|
15
17
|
handleRef: (el: HTMLDivElement | null) => void;
|
|
16
18
|
};
|
|
17
19
|
export {};
|
|
@@ -1,42 +1,46 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useElementResize as
|
|
3
|
-
import { useLocalStorage as
|
|
1
|
+
import { useCallback as a, useRef as p, useState as k, useEffect as E } from "react";
|
|
2
|
+
import { useElementResize as H } from "../../../utils/hooks/useElementResize.es.js";
|
|
3
|
+
import { useLocalStorage as R } from "../../../utils/hooks/useLocalStorage.es.js";
|
|
4
4
|
const N = ({
|
|
5
|
-
resizeConfig:
|
|
6
|
-
position:
|
|
7
|
-
floatingRef:
|
|
8
|
-
requireMount:
|
|
5
|
+
resizeConfig: m,
|
|
6
|
+
position: t,
|
|
7
|
+
floatingRef: o,
|
|
8
|
+
requireMount: n = !1,
|
|
9
|
+
container: c
|
|
9
10
|
}) => {
|
|
10
|
-
const
|
|
11
|
+
const s = !!m, { minSize: z = 0, maxSize: f = 0, storageKey: r = "" } = m ?? {}, b = a(() => {
|
|
12
|
+
const e = c;
|
|
13
|
+
return e ? t === "bottom" ? e.clientHeight * 0.9 : e.clientWidth * 0.5 : 1 / 0;
|
|
14
|
+
}, [c, t]), x = c && f === 1 / 0 ? b : f, u = p(null), [l, y] = k(!1), _ = a(
|
|
11
15
|
(e) => {
|
|
12
|
-
|
|
16
|
+
u.current = e, n && y(!!e);
|
|
13
17
|
},
|
|
14
|
-
[
|
|
15
|
-
), [
|
|
16
|
-
|
|
18
|
+
[n]
|
|
19
|
+
), [d, S] = R(
|
|
20
|
+
r || "__panel_no_key__",
|
|
17
21
|
"0",
|
|
18
|
-
|
|
19
|
-
),
|
|
22
|
+
s && !!r
|
|
23
|
+
), i = s && Number(d) > 0 ? Number(d) : 0, h = a(
|
|
20
24
|
(e) => {
|
|
21
|
-
|
|
25
|
+
r && S(e.toString());
|
|
22
26
|
},
|
|
23
|
-
[
|
|
27
|
+
[r, S]
|
|
24
28
|
);
|
|
25
|
-
return
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
S,
|
|
29
|
+
return H(
|
|
30
|
+
n ? s && l : s,
|
|
31
|
+
o,
|
|
32
|
+
u,
|
|
30
33
|
z,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
x,
|
|
35
|
+
i,
|
|
36
|
+
t === "bottom" ? "y" : "x",
|
|
37
|
+
t === "end",
|
|
38
|
+
h
|
|
39
|
+
), E(() => {
|
|
40
|
+
if (!n || !l || !i || !o.current) return;
|
|
41
|
+
const e = t === "bottom" ? "blockSize" : "inlineSize";
|
|
42
|
+
o.current.style[e] = `${i}px`;
|
|
43
|
+
}, [l]), { handleRef: _ };
|
|
40
44
|
};
|
|
41
45
|
export {
|
|
42
46
|
N as usePanelResize
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viasat/beam-react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.36.0",
|
|
4
4
|
"description": "React component library for the Beam design system",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Viasat",
|
|
@@ -59,11 +59,11 @@
|
|
|
59
59
|
"access": "public"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@viasat/beam-fonts": "2.
|
|
63
|
-
"@viasat/beam-shared": "2.
|
|
64
|
-
"@viasat/beam-styles": "2.
|
|
65
|
-
"@viasat/beam-tokens": "2.
|
|
66
|
-
"@viasat/beam-icons": "2.
|
|
62
|
+
"@viasat/beam-fonts": "2.36.0",
|
|
63
|
+
"@viasat/beam-shared": "2.36.0",
|
|
64
|
+
"@viasat/beam-styles": "2.36.0",
|
|
65
|
+
"@viasat/beam-tokens": "2.36.0",
|
|
66
|
+
"@viasat/beam-icons": "2.36.0",
|
|
67
67
|
"clsx": "^1.2.1",
|
|
68
68
|
"@floating-ui/react": "^0.26.18",
|
|
69
69
|
"@stepperize/react": "^5.1.5",
|
package/utils/hooks/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react"),d=require("../../chunks/constants.hwjHOsvT.js"),p=require("../../chunks/helpers.COm6C5Gf.js"),a=require("../../chunks/CSSLookup.DESAWWRT.js"),w=require("./useId.cjs.js"),f=require("./useInteractiveProps.cjs.js");function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react"),d=require("../../chunks/constants.hwjHOsvT.js"),p=require("../../chunks/helpers.COm6C5Gf.js"),a=require("../../chunks/CSSLookup.DESAWWRT.js"),w=require("./useId.cjs.js"),f=require("./usePrevious.cjs.js"),g=require("./useInteractiveProps.cjs.js");function h(e,t=window.getComputedStyle(e)){return parseInt(t.getPropertyValue("-webkit-line-clamp"),10)>=1&&t.getPropertyValue("display")==="-webkit-box"&&t.getPropertyValue("overflow")==="hidden"}function v(e,t=window.getComputedStyle(e)){return t.getPropertyValue("text-overflow")==="ellipsis"&&t.getPropertyValue("white-space")==="nowrap"&&t.getPropertyValue("overflow")==="hidden"&&e.scrollWidth>e.clientWidth}function S(e){return e.scrollWidth>e.clientWidth||e.scrollHeight>e.clientHeight}function b(e){if(!e)return!1;if(S(e))return!0;const t=window.getComputedStyle(e);return h(e,t)||v(e,t)}const m=e=>{if(!e)return!1;const t=e.cloneNode(!0);t.style.position="absolute",t.style.whiteSpace="nowrap",t.style.width="auto",t.style.height="auto",t.style.visibility="hidden",document.body.appendChild(t);const n=t.offsetWidth>e.offsetWidth;return document.body.removeChild(t),n},l=(e,t=d.FPS_120,n=[])=>{const r=s.useRef(null);return s.useLayoutEffect(()=>{const{current:i}=r;if(!i)return;e();const u=p.debounce(()=>{e()},t),c=new ResizeObserver(u);return c.observe(i),()=>{c.disconnect(),u.cancel()}},[r,e,t,n]),{ref:r}},y=()=>{const[e,t]=s.useState(!1),n=()=>{r.current&&t(b(r.current))},{ref:r}=l(n);return{ref:r,isOverFlowing:e}},C=e=>{const[t,n]=s.useState(!1),r=()=>{i.current&&n(m(i.current))},{ref:i}=l(r,200);return{ref:i,isTextWrapping:t}},W=e=>{const[t,n]=s.useState(()=>a.CSSManager.findVar(e)??"");return s.useEffect(()=>{const r=i=>{n(i)};return a.CSSManager.findVar(e,r),()=>{a.CSSManager.unsubscribe(e,r)}},[e]),t};function P(e){const[t,n]=s.useState(!1);return s.useLayoutEffect(()=>{if(typeof window>"u")return;const r=o=>o?getComputedStyle(o).direction:"ltr",i=()=>{const o=e.current;return o?r(o)==="rtl"||!!o.closest('[dir="rtl"]')||r(document.documentElement)==="rtl":!1};n(i());const u=new MutationObserver(()=>n(i()));u.observe(document.documentElement,{attributes:!0,attributeFilter:["dir","class"],subtree:!0});const c=requestAnimationFrame(function o(){n(i()),requestAnimationFrame(o)});return()=>{u.disconnect(),cancelAnimationFrame(c)}},[e]),t}const I=()=>{const[e,t]=s.useState(!1);return s.useEffect(()=>{if(typeof window>"u")return;const n=()=>{const r="ontouchstart"in window||navigator.maxTouchPoints>0,i=window.innerHeight>window.innerWidth,u=i?window.innerWidth:window.innerHeight,c=i?window.innerHeight:window.innerWidth,o=u<1024||c<768;t(r&&o)};return n(),window.addEventListener("resize",n,{passive:!0}),window.addEventListener("orientationchange",n,{passive:!0}),()=>{window.removeEventListener("resize",n),window.removeEventListener("orientationchange",n)}},[]),e};exports.useId=w.useId;exports.usePrevious=f.usePrevious;exports.useInteractiveProps=g.useInteractiveProps;exports.useCSSLookup=W;exports.useIsOverFlowing=y;exports.useIsTextWrapping=C;exports.useMobileDetection=I;exports.useRTLDirection=P;exports.useResizeObserver=l;
|
package/utils/hooks/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { default as React } from 'react';
|
|
|
2
2
|
import { VoidFunction } from '@viasat/beam-shared/utils/constants';
|
|
3
3
|
import { debounce } from '@viasat/beam-shared/utils/helpers';
|
|
4
4
|
export { useId } from './useId';
|
|
5
|
+
export { usePrevious } from './usePrevious';
|
|
5
6
|
export { useInteractiveProps, type UseInteractivePropsOptions, type InteractiveProps, type InteractiveElementType, } from './useInteractiveProps';
|
|
6
7
|
type WaitFor = Parameters<typeof debounce>[1];
|
|
7
8
|
/**
|