@viasat/beam-react 2.2.1 → 2.9.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/Checkbox.css +1 -1
- package/assets/RadioButton.css +1 -1
- package/assets/Search.Results.css +1 -0
- package/assets/card.css +1 -1
- package/assets/panel.css +1 -0
- package/chunks/ActionList.Group.B4PX5SKS.js +111 -0
- package/chunks/ActionList.Group.C2R56u2A.js +1 -0
- package/chunks/ActionList.Item.5Y-SwzjK.js +1 -0
- package/chunks/{ActionList.Item.Dg_KHGsm.js → ActionList.Item.BFcT86lS.js} +3 -2
- package/chunks/Search.Results.Item.CLmMBPz1.js +41 -0
- package/chunks/Search.Results.Item.Dkh2yo4p.js +1 -0
- package/chunks/card.module.8KnCe1uR.js +1 -0
- package/chunks/{card.module.Dy87qmTH.js → card.module.ByBYpexJ.js} +12 -6
- package/chunks/dom.DGM-dxLe.js +21 -0
- package/chunks/dom.zgzOBFUw.js +1 -0
- package/chunks/{form.context.B1PXIJNq.js → form.context.B26th8Od.js} +1 -1
- package/chunks/{form.context.CNWjF5qA.js → form.context.CfsTSQpm.js} +1 -1
- package/chunks/panel.module.BVm3KvDs.js +40 -0
- package/chunks/panel.module.BX1x4FlX.js +1 -0
- package/chunks/tokens.BD_71qmL.js +19 -0
- package/chunks/tokens.Bc11gmpN.js +1 -0
- package/index.cjs.js +1 -1
- package/index.es.js +17 -15
- package/lib/ActionList/ActionList.Group.cjs.js +1 -1
- package/lib/ActionList/ActionList.Group.d.ts +7 -4
- package/lib/ActionList/ActionList.Group.es.js +2 -2
- package/lib/ActionList/ActionList.IconButton.cjs.js +1 -1
- package/lib/ActionList/ActionList.IconButton.es.js +1 -1
- package/lib/ActionList/ActionList.Item.cjs.js +1 -1
- package/lib/ActionList/ActionList.Item.es.js +3 -3
- package/lib/ActionList/ActionList.cjs.js +1 -1
- package/lib/ActionList/ActionList.d.ts +1 -1
- package/lib/ActionList/ActionList.es.js +54 -54
- package/lib/ActionList/useActionListChildren.cjs.js +1 -1
- package/lib/ActionList/useActionListChildren.es.js +2 -2
- package/lib/Autocomplete/Autocomplete.cjs.js +1 -1
- package/lib/Autocomplete/Autocomplete.es.js +1 -1
- package/lib/Autocomplete/AutocompleteDropdown.cjs.js +1 -1
- package/lib/Autocomplete/AutocompleteDropdown.es.js +1 -1
- package/lib/Autocomplete/useAutocompleteA11y.cjs.js +1 -1
- package/lib/Autocomplete/useAutocompleteA11y.es.js +1 -1
- package/lib/Autocomplete/useAutocompleteDropdown.cjs.js +1 -1
- package/lib/Autocomplete/useAutocompleteDropdown.es.js +1 -1
- package/lib/Box/utils.cjs.js +1 -0
- package/lib/Box/utils.d.ts +6 -0
- package/lib/Box/utils.es.js +12 -0
- package/lib/Button/Button.cjs.js +1 -1
- package/lib/Button/Button.es.js +1 -1
- package/lib/Card/Card.Body.cjs.js +1 -1
- package/lib/Card/Card.Body.es.js +1 -1
- package/lib/Card/Card.Content.cjs.js +1 -1
- package/lib/Card/Card.Content.es.js +12 -17
- package/lib/Card/Card.Footer.cjs.js +1 -1
- package/lib/Card/Card.Footer.d.ts +1 -1
- package/lib/Card/Card.Footer.es.js +1 -1
- package/lib/Card/Card.Header.cjs.js +1 -1
- package/lib/Card/Card.Header.es.js +1 -1
- package/lib/Card/Card.Media.cjs.js +1 -1
- package/lib/Card/Card.Media.es.js +1 -1
- package/lib/Card/Card.cjs.js +1 -1
- package/lib/Card/Card.d.ts +61 -18
- package/lib/Card/Card.es.js +181 -82
- package/lib/Card/CardContext.cjs.js +1 -1
- package/lib/Card/CardContext.d.ts +10 -8
- package/lib/Card/CardContext.es.js +7 -12
- package/lib/Card/CardGroup.cjs.js +1 -0
- package/lib/Card/CardGroup.d.ts +55 -0
- package/lib/Card/CardGroup.es.js +67 -0
- package/lib/Card/card.utils.cjs.js +1 -0
- package/lib/Card/card.utils.d.ts +7 -0
- package/lib/Card/card.utils.es.js +14 -0
- package/lib/Card/index.cjs.js +1 -1
- package/lib/Card/index.d.ts +9 -1
- package/lib/Card/index.es.js +4 -2
- package/lib/Card/useCardGroup.cjs.js +1 -0
- package/lib/Card/useCardGroup.d.ts +27 -0
- package/lib/Card/useCardGroup.es.js +42 -0
- package/lib/Card/useCardGroupValue.cjs.js +1 -0
- package/lib/Card/useCardGroupValue.d.ts +14 -0
- package/lib/Card/useCardGroupValue.es.js +29 -0
- package/lib/Checkbox/Checkbox.cjs.js +1 -1
- package/lib/Checkbox/Checkbox.es.js +1 -1
- package/lib/Dialog/Dialog.Trigger.cjs.js +1 -1
- package/lib/Dialog/Dialog.Trigger.es.js +7 -6
- package/lib/EmptyState/EmptyState.cjs.js +1 -1
- package/lib/EmptyState/EmptyState.es.js +1 -1
- package/lib/FileUpload/FileUpload.List.Item.cjs.js +1 -1
- package/lib/FileUpload/FileUpload.List.Item.es.js +20 -20
- package/lib/FileUpload/FileUpload.cjs.js +1 -1
- package/lib/FileUpload/FileUpload.es.js +1 -1
- package/lib/FloatingUI/index.cjs.js +1 -1
- package/lib/FloatingUI/index.d.ts +1 -0
- package/lib/FloatingUI/index.es.js +7 -5
- package/lib/FloatingUI/useBlur.cjs.js +1 -0
- package/lib/FloatingUI/useBlur.d.ts +8 -0
- package/lib/FloatingUI/useBlur.es.js +15 -0
- package/lib/FloatingUI/useTyping.cjs.js +1 -0
- package/lib/FloatingUI/useTyping.d.ts +10 -0
- package/lib/FloatingUI/useTyping.es.js +42 -0
- package/lib/Form/Form.cjs.js +1 -1
- package/lib/Form/Form.es.js +1 -1
- package/lib/Form/contexts/form.context.cjs.js +1 -1
- package/lib/Form/contexts/form.context.es.js +1 -1
- package/lib/Form/contexts/index.cjs.js +1 -1
- package/lib/Form/contexts/index.es.js +1 -1
- package/lib/Form/hooks/index.cjs.js +1 -1
- package/lib/Form/hooks/index.es.js +1 -1
- package/lib/Form/hooks/useFieldValidator.hook.cjs.js +1 -1
- package/lib/Form/hooks/useFieldValidator.hook.es.js +2 -2
- package/lib/HelperText/HelperText.cjs.js +1 -1
- package/lib/HelperText/HelperText.es.js +1 -1
- package/lib/HelperText/index.cjs.js +1 -1
- package/lib/HelperText/index.es.js +1 -1
- package/lib/InputChoiceGroup/InputChoiceGroup.cjs.js +1 -1
- package/lib/InputChoiceGroup/InputChoiceGroup.es.js +1 -1
- package/lib/Label/Label.cjs.js +1 -1
- package/lib/Label/Label.es.js +1 -1
- package/lib/Link/Link.cjs.js +1 -1
- package/lib/Link/Link.es.js +6 -6
- package/lib/NativeSelect/NativeSelect.cjs.js +1 -1
- package/lib/NativeSelect/NativeSelect.es.js +1 -1
- package/lib/Popover/Popover.cjs.js +1 -1
- package/lib/Popover/Popover.es.js +1 -1
- package/lib/Popover/Popover.trigger.cjs.js +1 -1
- package/lib/Popover/Popover.trigger.es.js +7 -6
- package/lib/Popover/Popover.utils.cjs.js +1 -1
- package/lib/Popover/Popover.utils.es.js +1 -1
- package/lib/ProgressBar/ProgressBar.cjs.js +1 -1
- package/lib/ProgressBar/ProgressBar.es.js +1 -1
- package/lib/RadioButton/RadioButton.cjs.js +1 -1
- package/lib/RadioButton/RadioButton.es.js +1 -1
- package/lib/Select/Select.cjs.js +1 -1
- package/lib/Select/Select.es.js +1 -1
- package/lib/Select/SelectDropdown.cjs.js +1 -1
- package/lib/Select/SelectDropdown.es.js +1 -1
- package/lib/Select/useSelectA11y.cjs.js +1 -1
- package/lib/Select/useSelectA11y.es.js +1 -1
- package/lib/SideNav/SideNavActionListGroup.cjs.js +1 -1
- package/lib/SideNav/SideNavActionListGroup.es.js +1 -1
- package/lib/SideNav/SideNavActionListItem.cjs.js +1 -1
- package/lib/SideNav/SideNavActionListItem.es.js +1 -1
- package/lib/SideNav/SideNavActionListItemExpandable.cjs.js +1 -1
- package/lib/SideNav/SideNavActionListItemExpandable.es.js +1 -1
- package/lib/SideNav/SideNavActionListItemFlyout.cjs.js +1 -1
- package/lib/SideNav/SideNavActionListItemFlyout.es.js +1 -1
- package/lib/Slider/DualSlider.cjs.js +1 -1
- package/lib/Slider/DualSlider.d.ts +1 -1
- package/lib/Slider/DualSlider.es.js +73 -72
- package/lib/Slider/SingleSlider.cjs.js +1 -1
- package/lib/Slider/SingleSlider.d.ts +1 -1
- package/lib/Slider/SingleSlider.es.js +52 -51
- package/lib/Slider/Slider.Error.cjs.js +1 -1
- package/lib/Slider/Slider.Error.es.js +1 -1
- package/lib/Slider/Slider.Thumb.cjs.js +1 -1
- package/lib/Slider/Slider.Thumb.es.js +1 -1
- package/lib/Slider/Slider.cjs.js +1 -1
- package/lib/Slider/Slider.d.ts +1 -3
- package/lib/Slider/Slider.es.js +13 -11
- package/lib/Slider/Slider.types.d.ts +1 -1
- package/lib/Slider/hooks/useSliderBase.cjs.js +1 -1
- package/lib/Slider/hooks/useSliderBase.es.js +1 -1
- package/lib/Switch/Switch.cjs.js +1 -1
- package/lib/Switch/Switch.es.js +1 -1
- package/lib/Tabs/Tabs.Group.cjs.js +1 -1
- package/lib/Tabs/Tabs.Group.es.js +1 -1
- package/lib/TextArea/TextArea.cjs.js +1 -1
- package/lib/TextArea/TextArea.es.js +1 -1
- package/lib/TextField/TextField.cjs.js +1 -1
- package/lib/TextField/TextField.es.js +1 -1
- package/lib/Tooltip/Tooltip.cjs.js +1 -1
- package/lib/Tooltip/Tooltip.es.js +9 -9
- package/lib/_Options/useSelectValue.cjs.js +1 -1
- package/lib/_Options/useSelectValue.es.js +1 -1
- package/lib/index.cjs.js +1 -1
- package/lib/index.es.js +18 -16
- package/lib/wip/Panel/Panel.Body.cjs.js +1 -0
- package/lib/wip/Panel/Panel.Body.d.ts +11 -0
- package/lib/wip/Panel/Panel.Body.es.js +17 -0
- package/lib/wip/Panel/Panel.Footer.Actions.cjs.js +1 -0
- package/lib/wip/Panel/Panel.Footer.Actions.d.ts +17 -0
- package/lib/wip/Panel/Panel.Footer.Actions.es.js +22 -0
- package/lib/wip/Panel/Panel.Footer.cjs.js +1 -0
- package/lib/wip/Panel/Panel.Footer.d.ts +20 -0
- package/lib/wip/Panel/Panel.Footer.es.js +24 -0
- package/lib/wip/Panel/Panel.Header.ContentAfter.cjs.js +1 -0
- package/lib/wip/Panel/Panel.Header.ContentAfter.d.ts +11 -0
- package/lib/wip/Panel/Panel.Header.ContentAfter.es.js +17 -0
- package/lib/wip/Panel/Panel.Header.ContentBefore.cjs.js +1 -0
- package/lib/wip/Panel/Panel.Header.ContentBefore.d.ts +11 -0
- package/lib/wip/Panel/Panel.Header.ContentBefore.es.js +17 -0
- package/lib/wip/Panel/Panel.Header.Description.cjs.js +1 -0
- package/lib/wip/Panel/Panel.Header.Description.d.ts +11 -0
- package/lib/wip/Panel/Panel.Header.Description.es.js +17 -0
- package/lib/wip/Panel/Panel.Header.Heading.cjs.js +1 -0
- package/lib/wip/Panel/Panel.Header.Heading.d.ts +11 -0
- package/lib/wip/Panel/Panel.Header.Heading.es.js +17 -0
- package/lib/wip/Panel/Panel.Header.Row.cjs.js +1 -0
- package/lib/wip/Panel/Panel.Header.Row.d.ts +11 -0
- package/lib/wip/Panel/Panel.Header.Row.es.js +29 -0
- package/lib/wip/Panel/Panel.Header.Subheader.cjs.js +1 -0
- package/lib/wip/Panel/Panel.Header.Subheader.d.ts +11 -0
- package/lib/wip/Panel/Panel.Header.Subheader.es.js +17 -0
- package/lib/wip/Panel/Panel.Header.cjs.js +1 -0
- package/lib/wip/Panel/Panel.Header.d.ts +40 -0
- package/lib/wip/Panel/Panel.Header.es.js +34 -0
- package/lib/wip/Panel/Panel.cjs.js +1 -0
- package/lib/wip/Panel/Panel.context.cjs.js +1 -0
- package/lib/wip/Panel/Panel.context.d.ts +21 -0
- package/lib/wip/Panel/Panel.context.es.js +11 -0
- package/lib/wip/Panel/Panel.d.ts +45 -0
- package/lib/wip/Panel/Panel.es.js +117 -0
- package/lib/wip/Panel/Panel.helpers.cjs.js +1 -0
- package/lib/wip/Panel/Panel.helpers.d.ts +13 -0
- package/lib/wip/Panel/Panel.helpers.es.js +40 -0
- package/lib/wip/Panel/Panel.types.cjs.js +1 -0
- package/lib/wip/Panel/Panel.types.d.ts +76 -0
- package/lib/wip/Panel/Panel.types.es.js +1 -0
- package/lib/wip/Panel/index.cjs.js +1 -0
- package/lib/wip/Panel/index.d.ts +12 -0
- package/lib/wip/Panel/index.es.js +4 -0
- package/lib/wip/Search/Search.Results.Item.cjs.js +1 -0
- package/lib/wip/Search/Search.Results.Item.d.ts +8 -0
- package/lib/wip/Search/Search.Results.Item.es.js +12 -0
- package/lib/wip/Search/Search.Results.cjs.js +1 -0
- package/lib/wip/Search/Search.Results.d.ts +12 -0
- package/lib/wip/Search/Search.Results.es.js +19 -0
- package/lib/wip/Search/Search.cjs.js +1 -0
- package/lib/wip/Search/Search.d.ts +88 -0
- package/lib/wip/Search/Search.es.js +157 -0
- package/lib/wip/Search/SearchDropdown.cjs.js +1 -0
- package/lib/wip/Search/SearchDropdown.d.ts +19 -0
- package/lib/wip/Search/SearchDropdown.es.js +71 -0
- package/lib/wip/Search/index.cjs.js +1 -0
- package/lib/wip/Search/index.d.ts +1 -0
- package/lib/wip/Search/index.es.js +4 -0
- package/lib/wip/Search/useSearchDropdown.cjs.js +1 -0
- package/lib/wip/Search/useSearchDropdown.d.ts +875 -0
- package/lib/wip/Search/useSearchDropdown.es.js +92 -0
- package/lib/wip/index.cjs.js +1 -1
- package/lib/wip/index.d.ts +2 -0
- package/lib/wip/index.es.js +6 -1
- 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 +33 -31
- package/utils/hooks/useDebounced.cjs.js +1 -0
- package/utils/hooks/useDebounced.d.ts +5 -0
- package/utils/hooks/useDebounced.es.js +18 -0
- package/utils/hooks/useEffectAfterMount.cjs.js +1 -0
- package/utils/hooks/useEffectAfterMount.d.ts +2 -0
- package/utils/hooks/useEffectAfterMount.es.js +14 -0
- package/utils/hooks/useInteractiveProps.cjs.js +1 -0
- package/utils/hooks/useInteractiveProps.d.ts +24 -0
- package/utils/hooks/useInteractiveProps.es.js +31 -0
- package/chunks/ActionList.Group.Bv9vgU22.js +0 -1
- package/chunks/ActionList.Group.DuNxYNZQ.js +0 -107
- package/chunks/ActionList.Item.D7Rg5iMb.js +0 -1
- package/chunks/card.module.BG9mkRao.js +0 -1
- package/chunks/dom.CVmkHCnh.js +0 -21
- package/chunks/dom.PCrm8EUc.js +0 -1
- package/chunks/tokens.Bgac_JPh.js +0 -1
- package/chunks/tokens.CXaNS8Cf.js +0 -13
package/lib/Card/Card.es.js
CHANGED
|
@@ -1,98 +1,197 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useCallback as
|
|
3
|
-
import
|
|
4
|
-
import { g as
|
|
1
|
+
import { jsxs as le, jsx as E } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as ne, useMemo as de, useCallback as g } from "react";
|
|
3
|
+
import R from "clsx";
|
|
4
|
+
import { g as ce } from "../../chunks/classNames.DNsS4J__.js";
|
|
5
5
|
import "../../chunks/constants.BBi77pmH.js";
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
6
|
+
import { Box as ue } from "../Box/Box.es.js";
|
|
7
|
+
import "../../chunks/CSSLookup.Cjf6o2Gz.js";
|
|
8
|
+
import "../../utils/hooks/useId.es.js";
|
|
9
|
+
import { useInteractiveProps as me } from "../../utils/hooks/useInteractiveProps.es.js";
|
|
10
|
+
import { s as t } from "../../chunks/card.module.ByBYpexJ.js";
|
|
11
|
+
import { BOX_BORDER_RADIUS_TO_CSS_VAR as fe } from "../Box/utils.es.js";
|
|
12
|
+
import { MediaAbove as be } from "./Card.MediaAbove.es.js";
|
|
13
|
+
import { Header as pe } from "./Card.Header.es.js";
|
|
14
|
+
import { MediaBelow as he } from "./Card.MediaBelow.es.js";
|
|
15
|
+
import { Body as ye } from "./Card.Body.es.js";
|
|
16
|
+
import { Content as $e } from "./Card.Content.es.js";
|
|
17
|
+
import { Footer as Ie } from "./Card.Footer.es.js";
|
|
18
|
+
import { useCardGroupContext as ve } from "./CardContext.es.js";
|
|
19
|
+
import { useCardGroup as Ne } from "./useCardGroup.es.js";
|
|
20
|
+
import { StateLayer as Ce } from "../StateLayer/StateLayer.es.js";
|
|
21
|
+
const { baseClassNamePrefix: d, classModifierPrefix: n, subElementClassPrefix: c } = ce("card"), Ee = 'button, a, input:not([data-card-input]), select, textarea, [role="button"], [role="link"], [tabindex]:not([tabindex="-1"])', l = ({
|
|
22
|
+
children: T,
|
|
23
|
+
className: A,
|
|
24
|
+
density: x = "md",
|
|
25
|
+
borderColor: w,
|
|
26
|
+
borderRadius: b,
|
|
27
|
+
backgroundColor: S,
|
|
28
|
+
shadow: B,
|
|
29
|
+
type: D,
|
|
30
|
+
as: L,
|
|
31
|
+
disabled: k = !1,
|
|
32
|
+
href: M,
|
|
33
|
+
target: O,
|
|
34
|
+
rel: G,
|
|
35
|
+
onClick: i,
|
|
36
|
+
selectionMode: H = "single",
|
|
37
|
+
showIndicator: V = !1,
|
|
38
|
+
selected: j,
|
|
39
|
+
defaultSelected: F = !1,
|
|
40
|
+
onSelect: K,
|
|
41
|
+
name: U,
|
|
42
|
+
value: W,
|
|
43
|
+
style: p,
|
|
44
|
+
...u
|
|
33
45
|
}) => {
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
46
|
+
const h = ve();
|
|
47
|
+
process.env.NODE_ENV !== "production" && h && D === "clickable" && console.warn(
|
|
48
|
+
'Card: type="clickable" is ignored when Card is inside a CardGroup; treating as selectable instead.'
|
|
49
|
+
);
|
|
50
|
+
const y = h ? "selectable" : D, $ = !!y, r = y === "clickable", o = y === "selectable", {
|
|
51
|
+
selected: I,
|
|
52
|
+
handleChange: X,
|
|
53
|
+
resolvedValue: q,
|
|
54
|
+
isSelectionEligible: v,
|
|
55
|
+
resolvedDisabled: a,
|
|
56
|
+
resolvedName: z,
|
|
57
|
+
resolvedShowIndicator: J,
|
|
58
|
+
inputType: _
|
|
59
|
+
} = Ne({
|
|
60
|
+
cardGroup: h,
|
|
61
|
+
selected: j,
|
|
62
|
+
defaultSelected: F,
|
|
63
|
+
value: W,
|
|
64
|
+
id: u.id,
|
|
65
|
+
disabled: k,
|
|
66
|
+
name: U,
|
|
67
|
+
selectionMode: H,
|
|
68
|
+
showIndicator: V,
|
|
69
|
+
onSelect: K
|
|
70
|
+
}), N = ne(null), m = L ?? (r && M ? "a" : "div"), Q = de(() => b ? {
|
|
71
|
+
...p,
|
|
72
|
+
"--bm-card-radius-outer": fe[b]
|
|
73
|
+
} : p, [b, p]), f = g(
|
|
74
|
+
(e) => {
|
|
75
|
+
if (!e || !(e instanceof Element)) return !1;
|
|
76
|
+
const C = e.closest(Ee);
|
|
77
|
+
if (!C) return !1;
|
|
78
|
+
const s = e.closest(`.${t[d]}`);
|
|
79
|
+
return C !== s;
|
|
41
80
|
},
|
|
42
81
|
[]
|
|
43
|
-
),
|
|
44
|
-
(
|
|
45
|
-
if (
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
82
|
+
), Y = g(
|
|
83
|
+
(e) => {
|
|
84
|
+
if (a) return;
|
|
85
|
+
if (f(e.target)) {
|
|
86
|
+
if (r && m === "a") {
|
|
87
|
+
const s = e.target, P = s == null ? void 0 : s.closest('a, [role="link"]');
|
|
88
|
+
(!P || P === e.currentTarget) && e.preventDefault();
|
|
49
89
|
}
|
|
50
|
-
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if (r && (i == null || i(e)), o) {
|
|
93
|
+
if (!v) return;
|
|
94
|
+
const s = e.target;
|
|
95
|
+
if (s.tagName === "INPUT" && s.hasAttribute("data-card-input"))
|
|
96
|
+
return;
|
|
97
|
+
N.current && N.current.click();
|
|
51
98
|
}
|
|
52
99
|
},
|
|
53
|
-
[
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
100
|
+
[
|
|
101
|
+
r,
|
|
102
|
+
o,
|
|
103
|
+
v,
|
|
104
|
+
f,
|
|
105
|
+
m,
|
|
106
|
+
i,
|
|
107
|
+
a
|
|
108
|
+
]
|
|
109
|
+
), Z = g(
|
|
110
|
+
(e) => {
|
|
111
|
+
a || e.key !== "Enter" && e.key !== " " || f(e.target) || (e.preventDefault(), r && (i == null || i(e)));
|
|
57
112
|
},
|
|
58
|
-
[r,
|
|
59
|
-
),
|
|
60
|
-
|
|
61
|
-
!
|
|
62
|
-
|
|
63
|
-
!
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
113
|
+
[r, f, i, a]
|
|
114
|
+
), ee = R(
|
|
115
|
+
t[d],
|
|
116
|
+
!S && t[`${d}--default-background`],
|
|
117
|
+
!B && t[`${d}--default-shadow`],
|
|
118
|
+
!w && t[`${d}--default-border`],
|
|
119
|
+
$ && t[`${n}interactive`],
|
|
120
|
+
r && t[`${n}clickable`],
|
|
121
|
+
o && t[`${n}selectable`],
|
|
122
|
+
o && I && t[`${n}selected`],
|
|
123
|
+
a && t[`${n}disabled`],
|
|
124
|
+
x && t[`${n}density-${x}`],
|
|
125
|
+
A
|
|
126
|
+
), te = me({
|
|
127
|
+
isInteractive: $,
|
|
128
|
+
disabled: a,
|
|
129
|
+
isClickable: r,
|
|
130
|
+
elementType: m,
|
|
131
|
+
href: r ? M : void 0,
|
|
132
|
+
target: r ? O : void 0,
|
|
133
|
+
rel: r ? G : void 0,
|
|
134
|
+
onClick: Y,
|
|
135
|
+
onKeyDown: Z
|
|
136
|
+
}), re = () => !o || !v ? null : /* @__PURE__ */ E(
|
|
137
|
+
"input",
|
|
138
|
+
{
|
|
139
|
+
ref: N,
|
|
140
|
+
type: _,
|
|
141
|
+
className: t[`${c}hidden-input`],
|
|
142
|
+
checked: I,
|
|
143
|
+
disabled: a,
|
|
144
|
+
name: z,
|
|
145
|
+
value: q,
|
|
146
|
+
onChange: X,
|
|
147
|
+
"aria-label": u["aria-label"],
|
|
148
|
+
"aria-labelledby": u["aria-labelledby"],
|
|
149
|
+
"data-card-input": ""
|
|
150
|
+
}
|
|
151
|
+
), ae = () => {
|
|
152
|
+
if (!o || !J) return null;
|
|
153
|
+
const e = R(
|
|
154
|
+
t[`${c}selection-indicator`],
|
|
155
|
+
t[`${c}selection-indicator--${_}`],
|
|
156
|
+
I && t[`${c}selection-indicator--checked`],
|
|
157
|
+
a && t[`${c}selection-indicator--disabled`]
|
|
158
|
+
);
|
|
159
|
+
return /* @__PURE__ */ E("span", { className: e, "aria-hidden": "true" });
|
|
160
|
+
}, {
|
|
161
|
+
"aria-label": ie,
|
|
162
|
+
"aria-labelledby": oe,
|
|
163
|
+
...se
|
|
164
|
+
} = u;
|
|
165
|
+
return /* @__PURE__ */ le(
|
|
166
|
+
ue,
|
|
72
167
|
{
|
|
73
|
-
as:
|
|
74
|
-
className:
|
|
75
|
-
borderColor:
|
|
76
|
-
borderRadius: x,
|
|
168
|
+
as: m,
|
|
169
|
+
className: ee,
|
|
170
|
+
borderColor: w,
|
|
77
171
|
borderWidth: "md",
|
|
78
|
-
backgroundColor:
|
|
79
|
-
shadow:
|
|
80
|
-
|
|
81
|
-
...
|
|
172
|
+
backgroundColor: S,
|
|
173
|
+
shadow: B,
|
|
174
|
+
style: Q,
|
|
175
|
+
...te,
|
|
176
|
+
...se,
|
|
177
|
+
"aria-label": o ? void 0 : ie,
|
|
178
|
+
"aria-labelledby": o ? void 0 : oe,
|
|
82
179
|
children: [
|
|
83
|
-
|
|
84
|
-
|
|
180
|
+
re(),
|
|
181
|
+
ae(),
|
|
182
|
+
$ && !a && /* @__PURE__ */ E(Ce, {}),
|
|
183
|
+
T
|
|
85
184
|
]
|
|
86
185
|
}
|
|
87
|
-
)
|
|
186
|
+
);
|
|
88
187
|
};
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
188
|
+
l.displayName = "Card";
|
|
189
|
+
l.MediaAbove = be;
|
|
190
|
+
l.MediaBelow = he;
|
|
191
|
+
l.Header = pe;
|
|
192
|
+
l.Body = ye;
|
|
193
|
+
l.Content = $e;
|
|
194
|
+
l.Footer = Ie;
|
|
96
195
|
export {
|
|
97
|
-
|
|
196
|
+
l as Card
|
|
98
197
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),r=require("react"),e=r.createContext(void 0),n=({children:t,value:o})=>u.jsx(e.Provider,{value:o,children:t}),s=()=>r.useContext(e);exports.CardGroupProvider=n;exports.useCardGroupContext=s;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
interface
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { CardGroupSelectionMode } from '@viasat/beam-shared/components/card';
|
|
3
|
+
export interface CardGroupContextValue {
|
|
4
|
+
selectionMode?: CardGroupSelectionMode;
|
|
5
|
+
showIndicator?: boolean;
|
|
6
|
+
name?: string;
|
|
6
7
|
disabled?: boolean;
|
|
8
|
+
value?: string | string[];
|
|
9
|
+
onItemSelect?: (value: string, event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
7
10
|
}
|
|
8
|
-
export declare const
|
|
11
|
+
export declare const CardGroupProvider: ({ children, value, }: {
|
|
9
12
|
children: React.ReactNode;
|
|
10
|
-
value:
|
|
13
|
+
value: CardGroupContextValue;
|
|
11
14
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
-
export declare const
|
|
13
|
-
export {};
|
|
15
|
+
export declare const useCardGroupContext: () => CardGroupContextValue | undefined;
|
|
@@ -1,15 +1,10 @@
|
|
|
1
1
|
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import { createContext as n, useContext as
|
|
3
|
-
const
|
|
4
|
-
children:
|
|
5
|
-
value:
|
|
6
|
-
}) => /* @__PURE__ */ e(
|
|
7
|
-
const r = d(t);
|
|
8
|
-
if (!r)
|
|
9
|
-
throw new Error("useCard must be used within a CardProvider");
|
|
10
|
-
return r;
|
|
11
|
-
};
|
|
2
|
+
import { createContext as n, useContext as u } from "react";
|
|
3
|
+
const r = n(void 0), p = ({
|
|
4
|
+
children: o,
|
|
5
|
+
value: t
|
|
6
|
+
}) => /* @__PURE__ */ e(r.Provider, { value: t, children: o }), s = () => u(r);
|
|
12
7
|
export {
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
p as CardGroupProvider,
|
|
9
|
+
s as useCardGroupContext
|
|
15
10
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),y=require("react"),f=require("clsx"),h=require("../../chunks/classNames.DAeKwerT.js");require("../../chunks/constants.hwjHOsvT.js");const G=require("../../chunks/card.module.8KnCe1uR.js");require("../../chunks/CSSLookup.DESAWWRT.js");const I=require("../../utils/hooks/useId.cjs.js"),M=require("./CardContext.cjs.js"),V=require("./useCardGroupValue.cjs.js"),{classModifierPrefix:j}=h.getBEMClassNames("card"),i=u=>{const{children:d,className:c,disabled:e=!1,selectionMode:a="single",showIndicator:r=!1,name:n,value:m,defaultValue:b,onChange:C,"aria-label":p,"aria-labelledby":q,...g}=u,v=I.useId(),s=n??v,{currentValue:l,handleItemSelect:o}=V.useCardGroupValue({value:m,defaultValue:b,selectionMode:a,onChange:C}),N=f(e&&G.styles[`${j}disabled`],c),_=a==="single"?"radiogroup":"group",x=y.useMemo(()=>({selectionMode:a,showIndicator:r,name:s,disabled:e,value:l,onItemSelect:o}),[a,r,s,e,l,o]);return t.jsx("div",{role:_,"aria-disabled":e||void 0,"aria-label":p,"aria-labelledby":q,className:N,...g,children:t.jsx(M.CardGroupProvider,{value:x,children:d})})};i.displayName="CardGroup";exports.CardGroup=i;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { CardGroupSelectionMode } from '@viasat/beam-shared/components/card';
|
|
3
|
+
export type CardGroupProps = Omit<React.ComponentPropsWithoutRef<'div'>, 'onChange'> & {
|
|
4
|
+
/**
|
|
5
|
+
* The Cards that belong to this CardGroup
|
|
6
|
+
*/
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
/**
|
|
9
|
+
* Accessible group label
|
|
10
|
+
*/
|
|
11
|
+
'aria-label'?: string;
|
|
12
|
+
/**
|
|
13
|
+
* ID(s) of elements that label the group
|
|
14
|
+
*/
|
|
15
|
+
'aria-labelledby'?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Specify if all cards in the group are disabled
|
|
18
|
+
* @default false
|
|
19
|
+
*/
|
|
20
|
+
'disabled'?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Specify the selection mode for the group
|
|
23
|
+
* @default 'single'
|
|
24
|
+
*/
|
|
25
|
+
'selectionMode'?: CardGroupSelectionMode;
|
|
26
|
+
/**
|
|
27
|
+
* When true, shows a visual selection indicator (radio or checkbox) on cards
|
|
28
|
+
* @default false
|
|
29
|
+
*/
|
|
30
|
+
'showIndicator'?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Specify the shared name attribute for form integration when selectable.
|
|
33
|
+
* When omitted, CardGroup will auto-generate a name
|
|
34
|
+
*/
|
|
35
|
+
'name'?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Controlled value for the group.
|
|
38
|
+
*
|
|
39
|
+
* - single selection expects a string
|
|
40
|
+
* - multiple selection expects a string[]
|
|
41
|
+
*/
|
|
42
|
+
'value'?: string | string[];
|
|
43
|
+
/**
|
|
44
|
+
* Uncontrolled initial value for the group
|
|
45
|
+
*/
|
|
46
|
+
'defaultValue'?: string | string[];
|
|
47
|
+
/**
|
|
48
|
+
* Callback invoked when the group selection changes
|
|
49
|
+
*/
|
|
50
|
+
'onChange'?: (value: string | string[] | undefined, event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
51
|
+
};
|
|
52
|
+
export declare const CardGroup: {
|
|
53
|
+
(props: CardGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
54
|
+
displayName: string;
|
|
55
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as x } from "react";
|
|
3
|
+
import y from "clsx";
|
|
4
|
+
import { g as G } from "../../chunks/classNames.DNsS4J__.js";
|
|
5
|
+
import "../../chunks/constants.BBi77pmH.js";
|
|
6
|
+
import { s as I } from "../../chunks/card.module.ByBYpexJ.js";
|
|
7
|
+
import "../../chunks/CSSLookup.Cjf6o2Gz.js";
|
|
8
|
+
import { useId as M } from "../../utils/hooks/useId.es.js";
|
|
9
|
+
import { CardGroupProvider as V } from "./CardContext.es.js";
|
|
10
|
+
import { useCardGroupValue as B } from "./useCardGroupValue.es.js";
|
|
11
|
+
const { classModifierPrefix: L } = G("card"), P = (i) => {
|
|
12
|
+
const {
|
|
13
|
+
children: m,
|
|
14
|
+
className: d,
|
|
15
|
+
disabled: e = !1,
|
|
16
|
+
selectionMode: a = "single",
|
|
17
|
+
showIndicator: r = !1,
|
|
18
|
+
name: n,
|
|
19
|
+
value: c,
|
|
20
|
+
defaultValue: u,
|
|
21
|
+
onChange: p,
|
|
22
|
+
"aria-label": f,
|
|
23
|
+
"aria-labelledby": b,
|
|
24
|
+
...g
|
|
25
|
+
} = i, v = M(), o = n ?? v, { currentValue: l, handleItemSelect: s } = B({
|
|
26
|
+
value: c,
|
|
27
|
+
defaultValue: u,
|
|
28
|
+
selectionMode: a,
|
|
29
|
+
onChange: p
|
|
30
|
+
}), N = y(
|
|
31
|
+
e && I[`${L}disabled`],
|
|
32
|
+
d
|
|
33
|
+
), C = a === "single" ? "radiogroup" : "group", h = x(
|
|
34
|
+
() => ({
|
|
35
|
+
selectionMode: a,
|
|
36
|
+
showIndicator: r,
|
|
37
|
+
name: o,
|
|
38
|
+
disabled: e,
|
|
39
|
+
value: l,
|
|
40
|
+
onItemSelect: s
|
|
41
|
+
}),
|
|
42
|
+
[
|
|
43
|
+
a,
|
|
44
|
+
r,
|
|
45
|
+
o,
|
|
46
|
+
e,
|
|
47
|
+
l,
|
|
48
|
+
s
|
|
49
|
+
]
|
|
50
|
+
);
|
|
51
|
+
return /* @__PURE__ */ t(
|
|
52
|
+
"div",
|
|
53
|
+
{
|
|
54
|
+
role: C,
|
|
55
|
+
"aria-disabled": e || void 0,
|
|
56
|
+
"aria-label": f,
|
|
57
|
+
"aria-labelledby": b,
|
|
58
|
+
className: N,
|
|
59
|
+
...g,
|
|
60
|
+
children: /* @__PURE__ */ t(V, { value: h, children: m })
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
P.displayName = "CardGroup";
|
|
65
|
+
export {
|
|
66
|
+
P as CardGroup
|
|
67
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function e(r){return r==="single"?"radio":"checkbox"}function o(r){return Array.isArray(r)?r[0]:r}function n(r){return r?Array.isArray(r)?r:[r]:[]}exports.getInputType=e;exports.normalizeToArray=n;exports.normalizeToSingle=o;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CardGroupSelectionMode } from '@viasat/beam-shared/components/card';
|
|
2
|
+
/**
|
|
3
|
+
* Maps selection mode to the underlying input/indicator type.
|
|
4
|
+
*/
|
|
5
|
+
export declare function getInputType(selectionMode?: CardGroupSelectionMode): 'radio' | 'checkbox';
|
|
6
|
+
export declare function normalizeToSingle(input?: string | string[]): string | undefined;
|
|
7
|
+
export declare function normalizeToArray(input?: string | string[]): string[];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function e(r) {
|
|
2
|
+
return r === "single" ? "radio" : "checkbox";
|
|
3
|
+
}
|
|
4
|
+
function n(r) {
|
|
5
|
+
return Array.isArray(r) ? r[0] : r;
|
|
6
|
+
}
|
|
7
|
+
function o(r) {
|
|
8
|
+
return r ? Array.isArray(r) ? r : [r] : [];
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
e as getInputType,
|
|
12
|
+
o as normalizeToArray,
|
|
13
|
+
n as normalizeToSingle
|
|
14
|
+
};
|
package/lib/Card/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./Card.cjs.js");exports.Card=r.Card;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./Card.cjs.js"),e=require("./CardGroup.cjs.js");exports.Card=r.Card;exports.CardGroup=e.CardGroup;
|
package/lib/Card/index.d.ts
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
import { Card, CardProps } from './Card';
|
|
2
|
-
|
|
2
|
+
import { CardGroup, CardGroupProps } from './CardGroup';
|
|
3
|
+
export { Card, type CardProps, CardGroup, type CardGroupProps };
|
|
4
|
+
export type { CardBodyProps } from './Card.Body';
|
|
5
|
+
export type { CardContentProps } from './Card.Content';
|
|
6
|
+
export type { CardFooterProps, CardFooterActionsProps } from './Card.Footer';
|
|
7
|
+
export type { CardHeaderProps, CardHeaderHeadingProps, CardHeaderHeadingTextProps, CardHeaderEyebrowProps, CardHeaderSupportingTextProps, CardHeaderContentBeforeProps, CardHeaderContentAfterProps, } from './Card.Header';
|
|
8
|
+
export type { CardMediaProps } from './Card.Media';
|
|
9
|
+
export type { CardMediaAboveProps } from './Card.MediaAbove';
|
|
10
|
+
export type { CardMediaBelowProps } from './Card.MediaBelow';
|
package/lib/Card/index.es.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react"),k=require("./card.utils.cjs.js");function q({cardGroup:e,selected:C,defaultSelected:S,value:b,id:m,disabled:I,name:y,selectionMode:M,showIndicator:a,onSelect:n}){const t=!!e,s=b??m,o=!t||!!s;l.useEffect(()=>{process.env.NODE_ENV!=="production"&&t&&!s&&console.warn("Card: A Card inside a CardGroup is missing a `value` or `id` prop. It will not participate in group selection.")},[]);const f=I||(e==null?void 0:e.disabled)||!1,c=(e==null?void 0:e.name)??y,h=(e==null?void 0:e.showIndicator)??a,w=(e==null?void 0:e.selectionMode)??M??"single",E=k.getInputType(w),[_,A]=l.useState(()=>t?!1:S),N=C!==void 0?C:_,i=e==null?void 0:e.value,v=(e==null?void 0:e.selectionMode)??"single",T=l.useMemo(()=>!t||!s?null:v==="single"?i===s:Array.isArray(i)?i.includes(s):!1,[i,v,t,s]),V=t?T??!1:N,d=l.useCallback(g=>{f||!o||(e!=null&&e.onItemSelect&&s?e.onItemSelect(s,g):A(g.target.checked),n==null||n(g))},[f,o,e,s,n]);return{selected:V,handleChange:d,resolvedValue:s,isSelectionEligible:o,resolvedDisabled:f,resolvedName:c,resolvedShowIndicator:h,inputType:E}}exports.useCardGroup=q;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { CardGroupSelectionMode } from '@viasat/beam-shared/components/card';
|
|
3
|
+
import { CardGroupContextValue } from './CardContext';
|
|
4
|
+
interface UseCardGroupParams {
|
|
5
|
+
cardGroup: CardGroupContextValue | undefined;
|
|
6
|
+
selected: boolean | undefined;
|
|
7
|
+
defaultSelected: boolean;
|
|
8
|
+
value: string | undefined;
|
|
9
|
+
id: string | undefined;
|
|
10
|
+
disabled: boolean;
|
|
11
|
+
name: string | undefined;
|
|
12
|
+
selectionMode?: CardGroupSelectionMode;
|
|
13
|
+
showIndicator: boolean;
|
|
14
|
+
onSelect?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
15
|
+
}
|
|
16
|
+
interface UseCardGroupReturn {
|
|
17
|
+
selected: boolean;
|
|
18
|
+
handleChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
19
|
+
resolvedValue: string | undefined;
|
|
20
|
+
isSelectionEligible: boolean;
|
|
21
|
+
resolvedDisabled: boolean;
|
|
22
|
+
resolvedName: string | undefined;
|
|
23
|
+
resolvedShowIndicator: boolean;
|
|
24
|
+
inputType: 'radio' | 'checkbox';
|
|
25
|
+
}
|
|
26
|
+
export declare function useCardGroup({ cardGroup, selected: controlledSelected, defaultSelected, value, id, disabled, name, selectionMode, showIndicator, onSelect, }: UseCardGroupParams): UseCardGroupReturn;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useEffect as O, useState as _, useMemo as j, useCallback as q } from "react";
|
|
2
|
+
import { getInputType as z } from "./card.utils.es.js";
|
|
3
|
+
function J({
|
|
4
|
+
cardGroup: e,
|
|
5
|
+
selected: g,
|
|
6
|
+
defaultSelected: C,
|
|
7
|
+
value: v,
|
|
8
|
+
id: I,
|
|
9
|
+
disabled: S,
|
|
10
|
+
name: h,
|
|
11
|
+
selectionMode: M,
|
|
12
|
+
showIndicator: b,
|
|
13
|
+
onSelect: n
|
|
14
|
+
}) {
|
|
15
|
+
const t = !!e, s = v ?? I, l = !t || !!s;
|
|
16
|
+
O(() => {
|
|
17
|
+
process.env.NODE_ENV !== "production" && t && !s && console.warn(
|
|
18
|
+
"Card: A Card inside a CardGroup is missing a `value` or `id` prop. It will not participate in group selection."
|
|
19
|
+
);
|
|
20
|
+
}, []);
|
|
21
|
+
const o = S || (e == null ? void 0 : e.disabled) || !1, w = (e == null ? void 0 : e.name) ?? h, y = (e == null ? void 0 : e.showIndicator) ?? b, E = (e == null ? void 0 : e.selectionMode) ?? M ?? "single", A = z(E), [N, V] = _(
|
|
22
|
+
() => t ? !1 : C
|
|
23
|
+
), k = g !== void 0 ? g : N, i = e == null ? void 0 : e.value, m = (e == null ? void 0 : e.selectionMode) ?? "single", D = j(() => !t || !s ? null : m === "single" ? i === s : Array.isArray(i) ? i.includes(s) : !1, [i, m, t, s]), T = t ? D ?? !1 : k, x = q(
|
|
24
|
+
(f) => {
|
|
25
|
+
o || !l || (e != null && e.onItemSelect && s ? e.onItemSelect(s, f) : V(f.target.checked), n == null || n(f));
|
|
26
|
+
},
|
|
27
|
+
[o, l, e, s, n]
|
|
28
|
+
);
|
|
29
|
+
return {
|
|
30
|
+
selected: T,
|
|
31
|
+
handleChange: x,
|
|
32
|
+
resolvedValue: s,
|
|
33
|
+
isSelectionEligible: l,
|
|
34
|
+
resolvedDisabled: o,
|
|
35
|
+
resolvedName: w,
|
|
36
|
+
resolvedShowIndicator: y,
|
|
37
|
+
inputType: A
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
J as useCardGroup
|
|
42
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react"),s=require("./card.utils.cjs.js");function b({value:o,defaultValue:n,selectionMode:t,onChange:r}){const u=o!==void 0,[d,y]=a.useState(()=>t==="single"?s.normalizeToSingle(n):s.normalizeToArray(n)),i=u?o:d,e=a.useMemo(()=>t==="single"?s.normalizeToSingle(i):s.normalizeToArray(i),[i,t]),f=a.useCallback((l,S)=>{if(t==="single"){u||y(l),r==null||r(l,S);return}const c=s.normalizeToArray(e),T=c.includes(l)?c.filter(z=>z!==l):[...c,l];u||y(T),r==null||r(T,S)},[t,e,u,r]);return{currentValue:e,handleItemSelect:f}}exports.useCardGroupValue=b;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { CardGroupSelectionMode } from '@viasat/beam-shared/components/card';
|
|
3
|
+
interface UseCardGroupValueParams {
|
|
4
|
+
value: string | string[] | undefined;
|
|
5
|
+
defaultValue: string | string[] | undefined;
|
|
6
|
+
selectionMode: CardGroupSelectionMode;
|
|
7
|
+
onChange?: (value: string | string[] | undefined, event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
8
|
+
}
|
|
9
|
+
interface UseCardGroupValueReturn {
|
|
10
|
+
currentValue: string | string[] | undefined;
|
|
11
|
+
handleItemSelect: (itemValue: string, event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
12
|
+
}
|
|
13
|
+
export declare function useCardGroupValue({ value, defaultValue, selectionMode, onChange, }: UseCardGroupValueParams): UseCardGroupValueReturn;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useState as I, useMemo as T, useCallback as a } from "react";
|
|
2
|
+
import { normalizeToSingle as x, normalizeToArray as f } from "./card.utils.es.js";
|
|
3
|
+
function w({
|
|
4
|
+
value: m,
|
|
5
|
+
defaultValue: o,
|
|
6
|
+
selectionMode: t,
|
|
7
|
+
onChange: r
|
|
8
|
+
}) {
|
|
9
|
+
const l = m !== void 0, [y, p] = I(
|
|
10
|
+
() => t === "single" ? x(o) : f(o)
|
|
11
|
+
), u = l ? m : y, c = T(
|
|
12
|
+
() => t === "single" ? x(u) : f(u),
|
|
13
|
+
[u, t]
|
|
14
|
+
), z = a(
|
|
15
|
+
(s, n) => {
|
|
16
|
+
if (t === "single") {
|
|
17
|
+
l || p(s), r == null || r(s, n);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const i = f(c), S = i.includes(s) ? i.filter((A) => A !== s) : [...i, s];
|
|
21
|
+
l || p(S), r == null || r(S, n);
|
|
22
|
+
},
|
|
23
|
+
[t, c, l, r]
|
|
24
|
+
);
|
|
25
|
+
return { currentValue: c, handleItemSelect: z };
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
w as useCardGroupValue
|
|
29
|
+
};
|