@leaflink/stash 52.0.3 → 53.0.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/README.md +50 -49
- package/dist/Accordion.js +16 -16
- package/dist/Accordion.js.map +1 -1
- package/dist/AccordionGroup.js +7 -7
- package/dist/AccordionGroup.js.map +1 -1
- package/dist/ActionsDropdown.js +16 -16
- package/dist/ActionsDropdown.js.map +1 -1
- package/dist/AddressSelect.js.map +1 -1
- package/dist/AddressSelect.vue.d.ts +1 -1
- package/dist/Alert.js +34 -34
- package/dist/Alert.js.map +1 -1
- package/dist/AppNavigationItem.js +31 -31
- package/dist/AppNavigationItem.js.map +1 -1
- package/dist/AppSidebar.js +19 -19
- package/dist/AppSidebar.js.map +1 -1
- package/dist/AppTopbar.js +32 -32
- package/dist/AppTopbar.js.map +1 -1
- package/dist/Avatar.js +18 -18
- package/dist/Avatar.js.map +1 -1
- package/dist/Backdrop.js +5 -5
- package/dist/Backdrop.js.map +1 -1
- package/dist/Badge.js +38 -38
- package/dist/Badge.js.map +1 -1
- package/dist/Box.js +1 -1
- package/dist/{Box.vue_vue_type_script_setup_true_lang-rFnvwLVY.js → Box.vue_vue_type_script_setup_true_lang-dFFZN40_.js} +6 -6
- package/dist/{Box.vue_vue_type_script_setup_true_lang-rFnvwLVY.js.map → Box.vue_vue_type_script_setup_true_lang-dFFZN40_.js.map} +1 -1
- package/dist/Button.js +21 -21
- package/dist/Button.js.map +1 -1
- package/dist/ButtonGroup.js +26 -26
- package/dist/ButtonGroup.js.map +1 -1
- package/dist/Card.js +14 -14
- package/dist/Card.js.map +1 -1
- package/dist/CardContent.js +1 -1
- package/dist/CardContent.js.map +1 -1
- package/dist/CardFooter.js +1 -1
- package/dist/CardFooter.js.map +1 -1
- package/dist/CardHeader.js +4 -4
- package/dist/CardHeader.js.map +1 -1
- package/dist/CardMedia.js +20 -20
- package/dist/CardMedia.js.map +1 -1
- package/dist/Carousel.js +60 -60
- package/dist/Carousel.js.map +1 -1
- package/dist/Checkbox.js +30 -30
- package/dist/Checkbox.js.map +1 -1
- package/dist/Checkbox.vue.d.ts +0 -3
- package/dist/Chip.js +33 -33
- package/dist/Chip.js.map +1 -1
- package/dist/ConfirmationCodeInput.js +72 -72
- package/dist/ConfirmationCodeInput.js.map +1 -1
- package/dist/ContextSwitcher.js +27 -27
- package/dist/ContextSwitcher.js.map +1 -1
- package/dist/Copy.js +47 -48
- package/dist/Copy.js.map +1 -1
- package/dist/CurrencyInput.js +1 -1
- package/dist/CurrencyInput.js.map +1 -1
- package/dist/CurrencyInput.vue.d.ts +5 -5
- package/dist/DataView.js +23 -23
- package/dist/DataView.js.map +1 -1
- package/dist/DataViewFilters.js +26 -26
- package/dist/DataViewFilters.js.map +1 -1
- package/dist/DataViewSortButton.js +22 -22
- package/dist/DataViewSortButton.js.map +1 -1
- package/dist/DataViewToolbar.js +52 -52
- package/dist/DataViewToolbar.js.map +1 -1
- package/dist/DatePicker.js +10 -10
- package/dist/DatePicker.js.map +1 -1
- package/dist/DescriptionList.js +2 -2
- package/dist/DescriptionList.js.map +1 -1
- package/dist/DescriptionListDetail.js +2 -2
- package/dist/DescriptionListDetail.js.map +1 -1
- package/dist/DescriptionListGroup.js +9 -9
- package/dist/DescriptionListGroup.js.map +1 -1
- package/dist/DescriptionListTerm.js +8 -8
- package/dist/DescriptionListTerm.js.map +1 -1
- package/dist/Dialog.js +47 -47
- package/dist/Dialog.js.map +1 -1
- package/dist/Divider.js +6 -6
- package/dist/Divider.js.map +1 -1
- package/dist/Dropdown.js +20 -20
- package/dist/Dropdown.js.map +1 -1
- package/dist/EmptyState.js +26 -26
- package/dist/EmptyState.js.map +1 -1
- package/dist/Field.js +1 -1
- package/dist/{Field.vue_vue_type_script_setup_true_lang-DI6z3AE9.js → Field.vue_vue_type_script_setup_true_lang-dAGKfjf5.js} +17 -17
- package/dist/Field.vue_vue_type_script_setup_true_lang-dAGKfjf5.js.map +1 -0
- package/dist/FileUpload.js +47 -49
- package/dist/FileUpload.js.map +1 -1
- package/dist/FilterChip.js +20 -20
- package/dist/FilterChip.js.map +1 -1
- package/dist/FilterDrawerItem.js +13 -13
- package/dist/FilterDrawerItem.js.map +1 -1
- package/dist/FilterDropdown.js +27 -27
- package/dist/FilterDropdown.js.map +1 -1
- package/dist/FilterSelect.js +33 -33
- package/dist/FilterSelect.js.map +1 -1
- package/dist/Filters.js +29 -29
- package/dist/Filters.js.map +1 -1
- package/dist/Filters.vue.d.ts +2 -8
- package/dist/HttpError.js +29 -29
- package/dist/HttpError.js.map +1 -1
- package/dist/HttpError.vue.d.ts +0 -3
- package/dist/Icon.js +12 -12
- package/dist/Icon.js.map +1 -1
- package/dist/IconLabel.js +19 -19
- package/dist/IconLabel.js.map +1 -1
- package/dist/IconLabel.vue.d.ts +1 -1
- package/dist/Illustration.js +2 -2
- package/dist/{Illustration.vue_vue_type_script_setup_true_lang-BrqEF8xe.js → Illustration.vue_vue_type_script_setup_true_lang-C1bPkWZZ.js} +4 -4
- package/dist/{Illustration.vue_vue_type_script_setup_true_lang-BrqEF8xe.js.map → Illustration.vue_vue_type_script_setup_true_lang-C1bPkWZZ.js.map} +1 -1
- package/dist/Image.js +2 -2
- package/dist/Image.vue.d.ts +0 -3
- package/dist/{Image.vue_vue_type_script_setup_true_lang-D5u4av0_.js → Image.vue_vue_type_script_setup_true_lang-CAj0FH9h.js} +11 -11
- package/dist/Image.vue_vue_type_script_setup_true_lang-CAj0FH9h.js.map +1 -0
- package/dist/InlineEdit.js +8 -8
- package/dist/InlineEdit.js.map +1 -1
- package/dist/Input.js +29 -29
- package/dist/Input.js.map +1 -1
- package/dist/InputOptions.js +87 -84
- package/dist/InputOptions.js.map +1 -1
- package/dist/InputOptions.vue.d.ts +2 -2
- package/dist/IntegrationIcon.js +11 -11
- package/dist/IntegrationIcon.js.map +1 -1
- package/dist/Label.js +1 -1
- package/dist/{Label.vue_vue_type_script_setup_true_lang-CNquF3AP.js → Label.vue_vue_type_script_setup_true_lang-xwY3X-iV.js} +16 -16
- package/dist/{Label.vue_vue_type_script_setup_true_lang-CNquF3AP.js.map → Label.vue_vue_type_script_setup_true_lang-xwY3X-iV.js.map} +1 -1
- package/dist/ListItem.js +14 -14
- package/dist/ListItem.js.map +1 -1
- package/dist/ListItem.vue.d.ts +0 -6
- package/dist/ListItemCell.js +9 -9
- package/dist/ListItemCell.js.map +1 -1
- package/dist/ListView.js +138 -141
- package/dist/ListView.js.map +1 -1
- package/dist/ListView.vue.d.ts +2 -26
- package/dist/Loading.js +8 -8
- package/dist/Loading.js.map +1 -1
- package/dist/Logo.js +1 -1
- package/dist/{Logo.vue_vue_type_script_setup_true_lang-Dz8c98sc.js → Logo.vue_vue_type_script_setup_true_lang-DghNC_k6.js} +3 -3
- package/dist/{Logo.vue_vue_type_script_setup_true_lang-Dz8c98sc.js.map → Logo.vue_vue_type_script_setup_true_lang-DghNC_k6.js.map} +1 -1
- package/dist/Menu.js +5 -5
- package/dist/Menu.js.map +1 -1
- package/dist/MenuItem.js +12 -12
- package/dist/MenuItem.js.map +1 -1
- package/dist/Metric.js +24 -24
- package/dist/Metric.js.map +1 -1
- package/dist/Modal.js +60 -60
- package/dist/Modal.js.map +1 -1
- package/dist/Modals.js +1 -1
- package/dist/Modals.js.map +1 -1
- package/dist/Module.js +6 -6
- package/dist/Module.js.map +1 -1
- package/dist/ModuleContent.js +16 -16
- package/dist/ModuleContent.js.map +1 -1
- package/dist/ModuleFooter.js +13 -13
- package/dist/ModuleFooter.js.map +1 -1
- package/dist/ModuleHeader.js +29 -29
- package/dist/ModuleHeader.js.map +1 -1
- package/dist/MoreActions.js +81 -84
- package/dist/MoreActions.js.map +1 -1
- package/dist/ObfuscateText.js +4 -4
- package/dist/ObfuscateText.js.map +1 -1
- package/dist/PageContent.js +13 -13
- package/dist/PageContent.js.map +1 -1
- package/dist/PageHeader.js +28 -28
- package/dist/PageHeader.js.map +1 -1
- package/dist/PageNavigation.js +1 -1
- package/dist/Paginate.js +45 -45
- package/dist/Paginate.js.map +1 -1
- package/dist/QuickAction.js +18 -18
- package/dist/QuickAction.js.map +1 -1
- package/dist/Radio.js +17 -17
- package/dist/Radio.js.map +1 -1
- package/dist/RadioGroup.js +121 -121
- package/dist/RadioGroup.js.map +1 -1
- package/dist/RadioNew.js +80 -80
- package/dist/RadioNew.js.map +1 -1
- package/dist/RadioNew.vue.d.ts +0 -3
- package/dist/RangeInput.js +2 -2
- package/dist/RangeInput.js.map +1 -1
- package/dist/SearchBar.js +9 -9
- package/dist/SearchBar.js.map +1 -1
- package/dist/SectionHeader.js +14 -14
- package/dist/SectionHeader.js.map +1 -1
- package/dist/Select.js +369 -366
- package/dist/Select.js.map +1 -1
- package/dist/SelectStatus.js +26 -26
- package/dist/SelectStatus.js.map +1 -1
- package/dist/Skeleton.js +20 -20
- package/dist/Skeleton.js.map +1 -1
- package/dist/Step.js +37 -40
- package/dist/Step.js.map +1 -1
- package/dist/Stepper.js +17 -17
- package/dist/Stepper.js.map +1 -1
- package/dist/Switch.js +57 -57
- package/dist/Switch.js.map +1 -1
- package/dist/Tab.js +17 -19
- package/dist/Tab.js.map +1 -1
- package/dist/TabPanel.js +1 -1
- package/dist/TabPanel.js.map +1 -1
- package/dist/Table.js +22 -22
- package/dist/Table.js.map +1 -1
- package/dist/TableCell.js +32 -32
- package/dist/TableCell.js.map +1 -1
- package/dist/TableHeaderCell.js +35 -35
- package/dist/TableHeaderCell.js.map +1 -1
- package/dist/TableHeaderRow.js +10 -10
- package/dist/TableHeaderRow.js.map +1 -1
- package/dist/TableRow.js +51 -51
- package/dist/TableRow.js.map +1 -1
- package/dist/Tabs.js +2 -2
- package/dist/{Tabs.vue_vue_type_script_setup_true_lang-B3Irnlcd.js → Tabs.vue_vue_type_script_setup_true_lang-BVTCcK6M.js} +33 -33
- package/dist/Tabs.vue_vue_type_script_setup_true_lang-BVTCcK6M.js.map +1 -0
- package/dist/TextEditor.js +8 -8
- package/dist/TextEditor.js.map +1 -1
- package/dist/Textarea.js +15 -15
- package/dist/Textarea.js.map +1 -1
- package/dist/Thumbnail.js +41 -41
- package/dist/Thumbnail.js.map +1 -1
- package/dist/ThumbnailEmpty.js +3 -3
- package/dist/ThumbnailEmpty.js.map +1 -1
- package/dist/ThumbnailGroup.js +22 -22
- package/dist/ThumbnailGroup.js.map +1 -1
- package/dist/Timeline.js +3 -3
- package/dist/Timeline.js.map +1 -1
- package/dist/TimelineItem.js +22 -22
- package/dist/TimelineItem.js.map +1 -1
- package/dist/Toast.js +29 -29
- package/dist/Toast.js.map +1 -1
- package/dist/Toast.vue.d.ts +3 -0
- package/dist/Toasts.js +11 -11
- package/dist/Toasts.js.map +1 -1
- package/dist/Tooltip.js +2 -81
- package/dist/Tooltip.js.map +1 -1
- package/dist/Tooltip.vue.d.ts +1 -1
- package/dist/Tooltip.vue_vue_type_script_setup_true_lang-mzBLSXy3.js +84 -0
- package/dist/Tooltip.vue_vue_type_script_setup_true_lang-mzBLSXy3.js.map +1 -0
- package/dist/components.css +2 -2
- package/dist/constants.d.ts +9 -9
- package/dist/constants.js +17 -17
- package/dist/constants.js.map +1 -1
- package/dist/directives/tooltip.js +2 -2
- package/dist/directives/tooltip.js.map +1 -1
- package/dist/{index-C14LhAwV.js → index-DBV9Uz0C.js} +3 -3
- package/dist/{index-C14LhAwV.js.map → index-DBV9Uz0C.js.map} +1 -1
- package/dist/tailwind-base.js.d.ts +12 -0
- package/dist/tailwind-base.js.map +1 -1
- package/dist/useSortable.js +1 -1
- package/dist/utils/helpers.js +15 -15
- package/dist/utils/helpers.js.map +1 -1
- package/package.json +15 -15
- package/styles/backwards-compat.css +373 -2851
- package/styles/main.css +8 -0
- package/styles/sofia-font.css +23 -27
- package/styles/theme.css +1033 -0
- package/dist/Field.vue_vue_type_script_setup_true_lang-DI6z3AE9.js.map +0 -1
- package/dist/Image.vue_vue_type_script_setup_true_lang-D5u4av0_.js.map +0 -1
- package/dist/Tabs.vue_vue_type_script_setup_true_lang-B3Irnlcd.js.map +0 -1
- package/dist/tailwind-base.d.ts +0 -333
- package/styles/base.css +0 -902
- package/tailwind-base.ts +0 -455
package/dist/RadioGroup.js
CHANGED
|
@@ -1,176 +1,176 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as w, inject as V, useCssModule as g, createElementBlock as _, openBlock as n, normalizeClass as v, unref as e, Fragment as R, renderList as I, createElementVNode as c, toDisplayString as $, provide as S, computed as f, ref as j, useTemplateRef as D, onMounted as q, onUnmounted as A, watchEffect as L, createBlock as M, mergeProps as N, withCtx as P, renderSlot as T, resolveDynamicComponent as U } from "vue";
|
|
2
2
|
import F from "lodash-es/uniqueId";
|
|
3
3
|
import { R as k } from "./RadioGroup.keys-CqfiKkNz.js";
|
|
4
4
|
import { _ as B } from "./_plugin-vue_export-helper-CHgC5LLL.js";
|
|
5
|
-
import { _ as J } from "./Field.vue_vue_type_script_setup_true_lang-
|
|
6
|
-
const H = ["id", "name", "value", "checked", "disabled"], K = ["for"], Q = /* @__PURE__ */
|
|
5
|
+
import { _ as J } from "./Field.vue_vue_type_script_setup_true_lang-dAGKfjf5.js";
|
|
6
|
+
const H = ["id", "name", "value", "checked", "disabled"], K = ["for"], Q = /* @__PURE__ */ w({
|
|
7
7
|
__name: "VariantButton",
|
|
8
8
|
setup(p) {
|
|
9
9
|
const d = V(k.key);
|
|
10
10
|
if (!d)
|
|
11
11
|
throw new Error("VariantButton must be used with a RadioGroup instance.");
|
|
12
|
-
const { name:
|
|
13
|
-
return (
|
|
14
|
-
class:
|
|
12
|
+
const { name: o, disabled: a, fullWidth: m, modelValue: u, options: b, update: i } = d, l = g();
|
|
13
|
+
return (y, r) => (n(), _("div", {
|
|
14
|
+
class: v(["flex", e(l).root])
|
|
15
15
|
}, [
|
|
16
|
-
(n(!0), _(R, null, I(e(
|
|
17
|
-
key: `${e(
|
|
18
|
-
class:
|
|
16
|
+
(n(!0), _(R, null, I(e(b), (t) => (n(), _("div", {
|
|
17
|
+
key: `${e(o)}-${t.id}`,
|
|
18
|
+
class: v([{ "w-full": e(m) }])
|
|
19
19
|
}, [
|
|
20
20
|
c("input", {
|
|
21
|
-
id: `${e(
|
|
22
|
-
class: "
|
|
21
|
+
id: `${e(o)}-${t.id}`,
|
|
22
|
+
class: "sr-only",
|
|
23
23
|
type: "radio",
|
|
24
|
-
name: e(
|
|
24
|
+
name: e(o),
|
|
25
25
|
value: t.value,
|
|
26
26
|
checked: e(u) === t.value,
|
|
27
27
|
disabled: e(a) || t.disabled,
|
|
28
28
|
onInput: r[0] || (r[0] = //@ts-ignore
|
|
29
|
-
(...
|
|
29
|
+
(...h) => e(i) && e(i)(...h))
|
|
30
30
|
}, null, 40, H),
|
|
31
31
|
c("label", {
|
|
32
|
-
for: `${e(
|
|
33
|
-
},
|
|
32
|
+
for: `${e(o)}-${t.id}`
|
|
33
|
+
}, $(t.text), 9, K)
|
|
34
34
|
], 2))), 128))
|
|
35
35
|
], 2));
|
|
36
36
|
}
|
|
37
|
-
}), X = "
|
|
37
|
+
}), X = "_root_1yqgv_3", Y = {
|
|
38
38
|
root: X
|
|
39
39
|
}, Z = {
|
|
40
40
|
$style: Y
|
|
41
|
-
}, ee = /* @__PURE__ */ B(Q, [["__cssModules", Z]]), te = ["id", "name", "value", "checked", "disabled"], ae = ["for"],
|
|
41
|
+
}, ee = /* @__PURE__ */ B(Q, [["__cssModules", Z]]), te = ["id", "name", "value", "checked", "disabled"], ae = ["for"], oe = /* @__PURE__ */ w({
|
|
42
42
|
__name: "VariantChip",
|
|
43
43
|
setup(p) {
|
|
44
44
|
const d = V(k.key);
|
|
45
45
|
if (!d)
|
|
46
46
|
throw new Error("VariantChip must be used with a RadioGroup instance.");
|
|
47
|
-
const { name:
|
|
48
|
-
return (
|
|
49
|
-
class:
|
|
47
|
+
const { name: o, disabled: a, fullWidth: m, modelValue: u, options: b, update: i } = d, l = g();
|
|
48
|
+
return (y, r) => (n(), _("div", {
|
|
49
|
+
class: v(["my-1.5 flex flex-wrap", e(l).root])
|
|
50
50
|
}, [
|
|
51
|
-
(n(!0), _(R, null, I(e(
|
|
52
|
-
key: `${e(
|
|
53
|
-
class:
|
|
51
|
+
(n(!0), _(R, null, I(e(b), (t) => (n(), _("div", {
|
|
52
|
+
key: `${e(o)}-${t.id}`,
|
|
53
|
+
class: v([{ "w-full": e(m) }])
|
|
54
54
|
}, [
|
|
55
55
|
c("input", {
|
|
56
|
-
id: `${e(
|
|
57
|
-
class: "
|
|
56
|
+
id: `${e(o)}-${t.id}`,
|
|
57
|
+
class: "sr-only",
|
|
58
58
|
type: "radio",
|
|
59
|
-
name: e(
|
|
59
|
+
name: e(o),
|
|
60
60
|
value: t.value,
|
|
61
61
|
checked: e(u) === t.value,
|
|
62
62
|
disabled: e(a) || t.disabled,
|
|
63
63
|
onInput: r[0] || (r[0] = //@ts-ignore
|
|
64
|
-
(...
|
|
64
|
+
(...h) => e(i) && e(i)(...h))
|
|
65
65
|
}, null, 40, te),
|
|
66
66
|
c("label", {
|
|
67
|
-
for: `${e(
|
|
68
|
-
},
|
|
67
|
+
for: `${e(o)}-${t.id}`
|
|
68
|
+
}, $(t.text), 9, ae)
|
|
69
69
|
], 2))), 128))
|
|
70
70
|
], 2));
|
|
71
71
|
}
|
|
72
|
-
}),
|
|
73
|
-
root:
|
|
72
|
+
}), se = "_root_1vzbj_5", le = {
|
|
73
|
+
root: se
|
|
74
74
|
}, re = {
|
|
75
75
|
$style: le
|
|
76
|
-
}, ne = /* @__PURE__ */ B(
|
|
76
|
+
}, ne = /* @__PURE__ */ B(oe, [["__cssModules", re]]), ie = ["id", "name", "value", "checked", "disabled"], de = ["for"], ue = /* @__PURE__ */ w({
|
|
77
77
|
__name: "VariantRadio",
|
|
78
78
|
setup(p) {
|
|
79
79
|
const d = V(k.key);
|
|
80
80
|
if (!d)
|
|
81
81
|
throw new Error("VariantRadio must be used with a RadioGroup instance.");
|
|
82
|
-
const { name:
|
|
83
|
-
return (
|
|
84
|
-
class:
|
|
82
|
+
const { name: o, disabled: a, fullWidth: m, modelValue: u, options: b, update: i } = d, l = g();
|
|
83
|
+
return (y, r) => (n(), _("div", {
|
|
84
|
+
class: v(["flex flex-wrap", e(l).root])
|
|
85
85
|
}, [
|
|
86
|
-
(n(!0), _(R, null, I(e(
|
|
87
|
-
key: `${e(
|
|
88
|
-
class:
|
|
86
|
+
(n(!0), _(R, null, I(e(b), (t) => (n(), _("div", {
|
|
87
|
+
key: `${e(o)}-${t.id}`,
|
|
88
|
+
class: v([{ "w-full": e(m) }])
|
|
89
89
|
}, [
|
|
90
90
|
c("input", {
|
|
91
|
-
id: `${e(
|
|
91
|
+
id: `${e(o)}-${t.id}`,
|
|
92
92
|
type: "radio",
|
|
93
|
-
name: e(
|
|
93
|
+
name: e(o),
|
|
94
94
|
value: t.value,
|
|
95
95
|
checked: e(u) === t.value,
|
|
96
96
|
disabled: e(a) || t.disabled,
|
|
97
97
|
onInput: r[0] || (r[0] = //@ts-ignore
|
|
98
|
-
(...
|
|
98
|
+
(...h) => e(i) && e(i)(...h))
|
|
99
99
|
}, null, 40, ie),
|
|
100
100
|
c("label", {
|
|
101
|
-
for: `${e(
|
|
102
|
-
},
|
|
101
|
+
for: `${e(o)}-${t.id}`
|
|
102
|
+
}, $(t.text), 9, de)
|
|
103
103
|
], 2))), 128))
|
|
104
104
|
], 2));
|
|
105
105
|
}
|
|
106
|
-
}), ce = "
|
|
106
|
+
}), ce = "_root_3kb5v_5", _e = {
|
|
107
107
|
root: ce
|
|
108
108
|
}, pe = {
|
|
109
109
|
$style: _e
|
|
110
|
-
},
|
|
110
|
+
}, ve = /* @__PURE__ */ B(ue, [["__cssModules", pe]]), fe = ["for"], me = ["id", "name", "value", "checked", "disabled"], be = { class: "m-0 text-ice-900" }, he = { class: "m-0 text-ice-700" }, $e = /* @__PURE__ */ w({
|
|
111
111
|
__name: "VariantTile",
|
|
112
112
|
setup(p) {
|
|
113
113
|
const d = V(k.key);
|
|
114
114
|
if (!d)
|
|
115
115
|
throw new Error("VariantTile must be used with a RadioGroup instance.");
|
|
116
|
-
const { name:
|
|
117
|
-
return (
|
|
118
|
-
class:
|
|
116
|
+
const { name: o, disabled: a, fullWidth: m, modelValue: u, options: b, update: i } = d, l = g();
|
|
117
|
+
return (y, r) => (n(), _("div", {
|
|
118
|
+
class: v(["flex flex-wrap", e(l).root])
|
|
119
119
|
}, [
|
|
120
|
-
(n(!0), _(R, null, I(e(
|
|
121
|
-
key: `${e(
|
|
122
|
-
class:
|
|
123
|
-
for: `${e(
|
|
120
|
+
(n(!0), _(R, null, I(e(b), (t) => (n(), _("label", {
|
|
121
|
+
key: `${e(o)}-${t.id}`,
|
|
122
|
+
class: v([e(l)["tile-container"], { "w-full": e(m) }]),
|
|
123
|
+
for: `${e(o)}-${t.id}`
|
|
124
124
|
}, [
|
|
125
125
|
c("div", {
|
|
126
|
-
class:
|
|
126
|
+
class: v(["flex border", [
|
|
127
127
|
e(l)["tile-header"],
|
|
128
128
|
{
|
|
129
|
-
"
|
|
130
|
-
"
|
|
129
|
+
"border-blue-500 bg-blue-100 text-ice-900": e(u) === t.value,
|
|
130
|
+
"border-ice-500 bg-ice-100 text-ice-700": e(u) !== t.value
|
|
131
131
|
}
|
|
132
132
|
]])
|
|
133
133
|
}, [
|
|
134
134
|
c("input", {
|
|
135
|
-
id: `${e(
|
|
136
|
-
class: "
|
|
135
|
+
id: `${e(o)}-${t.id}`,
|
|
136
|
+
class: "sr-only",
|
|
137
137
|
type: "radio",
|
|
138
|
-
name: e(
|
|
138
|
+
name: e(o),
|
|
139
139
|
value: t.value,
|
|
140
140
|
checked: e(u) === t.value,
|
|
141
141
|
disabled: e(a) || t.disabled,
|
|
142
142
|
onInput: r[0] || (r[0] = //@ts-ignore
|
|
143
|
-
(...
|
|
143
|
+
(...h) => e(i) && e(i)(...h))
|
|
144
144
|
}, null, 40, me),
|
|
145
145
|
c("div", null, [
|
|
146
|
-
c("span", null,
|
|
146
|
+
c("span", null, $(t.text), 1)
|
|
147
147
|
])
|
|
148
148
|
], 2),
|
|
149
149
|
c("div", {
|
|
150
|
-
class:
|
|
150
|
+
class: v(["border-x border-b", [
|
|
151
151
|
e(l)["tile-body"],
|
|
152
152
|
{
|
|
153
|
-
"
|
|
154
|
-
"
|
|
153
|
+
"border-ice-500": e(u) !== t.value,
|
|
154
|
+
"border-blue-500": e(u) === t.value
|
|
155
155
|
}
|
|
156
156
|
]])
|
|
157
157
|
}, [
|
|
158
|
-
c("p",
|
|
159
|
-
c("p",
|
|
158
|
+
c("p", be, $(t.subTitle), 1),
|
|
159
|
+
c("p", he, $(t.subText), 1)
|
|
160
160
|
], 2)
|
|
161
|
-
], 10,
|
|
161
|
+
], 10, fe))), 128))
|
|
162
162
|
], 2));
|
|
163
163
|
}
|
|
164
|
-
}),
|
|
165
|
-
root:
|
|
166
|
-
"tile-container": "_tile-
|
|
167
|
-
"tile-header": "_tile-
|
|
168
|
-
"tile-body": "_tile-
|
|
169
|
-
},
|
|
170
|
-
$style:
|
|
171
|
-
}, ge = /* @__PURE__ */ B(
|
|
172
|
-
var
|
|
173
|
-
const ke = /* @__PURE__ */
|
|
164
|
+
}), ye = "_root_x2xjj_5", xe = {
|
|
165
|
+
root: ye,
|
|
166
|
+
"tile-container": "_tile-container_x2xjj_26",
|
|
167
|
+
"tile-header": "_tile-header_x2xjj_33",
|
|
168
|
+
"tile-body": "_tile-body_x2xjj_34"
|
|
169
|
+
}, we = {
|
|
170
|
+
$style: xe
|
|
171
|
+
}, ge = /* @__PURE__ */ B($e, [["__cssModules", we]]);
|
|
172
|
+
var x = /* @__PURE__ */ ((p) => (p.Radio = "radio", p.Button = "button", p.Chip = "chip", p.Tile = "tile", p))(x || {});
|
|
173
|
+
const ke = /* @__PURE__ */ w({
|
|
174
174
|
__name: "RadioGroup",
|
|
175
175
|
props: {
|
|
176
176
|
name: { default: void 0 },
|
|
@@ -195,55 +195,55 @@ const ke = /* @__PURE__ */ x({
|
|
|
195
195
|
},
|
|
196
196
|
emits: ["update:modelValue"],
|
|
197
197
|
setup(p, { emit: d }) {
|
|
198
|
-
const
|
|
199
|
-
[
|
|
200
|
-
[
|
|
201
|
-
[
|
|
202
|
-
[
|
|
198
|
+
const o = {
|
|
199
|
+
[x.Button]: ee,
|
|
200
|
+
[x.Chip]: ne,
|
|
201
|
+
[x.Radio]: ve,
|
|
202
|
+
[x.Tile]: ge
|
|
203
203
|
}, a = p, m = d, u = g();
|
|
204
|
-
function
|
|
205
|
-
m("update:modelValue",
|
|
204
|
+
function b(s) {
|
|
205
|
+
m("update:modelValue", s.target.value);
|
|
206
206
|
}
|
|
207
207
|
const i = F("radio-group-field-error-");
|
|
208
|
-
|
|
209
|
-
name:
|
|
210
|
-
disabled:
|
|
211
|
-
fullWidth:
|
|
212
|
-
modelValue:
|
|
213
|
-
options:
|
|
214
|
-
variant:
|
|
215
|
-
orientation:
|
|
216
|
-
update:
|
|
208
|
+
S(k.key, {
|
|
209
|
+
name: f(() => a.name),
|
|
210
|
+
disabled: f(() => a.isDisabled || a.disabled),
|
|
211
|
+
fullWidth: f(() => a.fullWidth),
|
|
212
|
+
modelValue: f(() => a.modelValue),
|
|
213
|
+
options: f(() => a.options),
|
|
214
|
+
variant: f(() => a.variant),
|
|
215
|
+
orientation: f(() => l.value),
|
|
216
|
+
update: b
|
|
217
217
|
});
|
|
218
|
-
const l =
|
|
219
|
-
"
|
|
220
|
-
"
|
|
221
|
-
"
|
|
222
|
-
"
|
|
223
|
-
})), r =
|
|
224
|
-
var
|
|
225
|
-
return (
|
|
226
|
-
}),
|
|
227
|
-
var
|
|
228
|
-
return a.variant !== "button" ? [] : Array.from((
|
|
218
|
+
const l = j(a.orientation), y = f(() => ({
|
|
219
|
+
"flex-wrap": a.variant !== "button",
|
|
220
|
+
"gap-x-1.5 gap-y-3": a.variant === "chip" && l.value === "horizontal",
|
|
221
|
+
"gap-6": a.variant === "radio" || a.variant === "tile" || a.variant === "chip" && l.value === "vertical",
|
|
222
|
+
"flex-col": l.value === "vertical"
|
|
223
|
+
})), r = j(null), t = D("radioGroup"), h = f(() => {
|
|
224
|
+
var s;
|
|
225
|
+
return (s = t.value) == null ? void 0 : s.$el.parentElement;
|
|
226
|
+
}), W = f(() => {
|
|
227
|
+
var s;
|
|
228
|
+
return a.variant !== "button" ? [] : Array.from((s = t.value) == null ? void 0 : s.$el.querySelectorAll("[data-variant-button]")) || [];
|
|
229
229
|
});
|
|
230
|
-
function
|
|
231
|
-
return
|
|
232
|
-
const
|
|
233
|
-
return
|
|
230
|
+
function z() {
|
|
231
|
+
return W.value.reduce((s, G) => {
|
|
232
|
+
const O = G.getBoundingClientRect().width;
|
|
233
|
+
return s + O;
|
|
234
234
|
}, 0);
|
|
235
235
|
}
|
|
236
|
-
const
|
|
237
|
-
l.value =
|
|
236
|
+
const C = j(0), E = (s) => {
|
|
237
|
+
l.value = C.value > s.contentBoxSize[0].inlineSize ? "vertical" : a.orientation;
|
|
238
238
|
};
|
|
239
239
|
return q(() => {
|
|
240
|
-
a.variant === "button" && !a.fullWidth && (
|
|
240
|
+
a.variant === "button" && !a.fullWidth && (C.value = z(), r.value = new ResizeObserver((s) => E(s[0])), r.value.observe(h.value));
|
|
241
241
|
}), A(() => {
|
|
242
|
-
var
|
|
243
|
-
a.variant === "button" && r.value && ((
|
|
242
|
+
var s;
|
|
243
|
+
a.variant === "button" && r.value && ((s = r.value) == null || s.disconnect());
|
|
244
244
|
}), L(() => {
|
|
245
245
|
l.value = a.orientation;
|
|
246
|
-
}), (
|
|
246
|
+
}), (s, G) => (n(), M(J, N(a, {
|
|
247
247
|
ref: "radioGroup",
|
|
248
248
|
class: ["stash-radio-group", e(u)["stash-radio-group"]],
|
|
249
249
|
"data-test": "stash-radio-group",
|
|
@@ -254,27 +254,27 @@ const ke = /* @__PURE__ */ x({
|
|
|
254
254
|
fieldset: ""
|
|
255
255
|
}), {
|
|
256
256
|
default: P(() => [
|
|
257
|
-
a.options ?
|
|
258
|
-
(n(),
|
|
257
|
+
a.options ? T(s.$slots, "default", { key: 0 }, () => [
|
|
258
|
+
(n(), M(U(o[a.variant])))
|
|
259
259
|
]) : (n(), _("div", {
|
|
260
260
|
key: 1,
|
|
261
|
-
class:
|
|
261
|
+
class: v(["flex", y.value]),
|
|
262
262
|
"data-test": "stash-radio-group|default-slot"
|
|
263
263
|
}, [
|
|
264
|
-
|
|
264
|
+
T(s.$slots, "default")
|
|
265
265
|
], 2))
|
|
266
266
|
]),
|
|
267
267
|
_: 3
|
|
268
268
|
}, 16, ["class", "aria-errormessage", "error-id", "aria-invalid"]));
|
|
269
269
|
}
|
|
270
270
|
}), Be = {
|
|
271
|
-
"stash-radio-group": "_stash-radio-
|
|
271
|
+
"stash-radio-group": "_stash-radio-group_184u1_3"
|
|
272
272
|
}, Ve = {
|
|
273
273
|
$style: Be
|
|
274
|
-
},
|
|
274
|
+
}, Me = /* @__PURE__ */ B(ke, [["__cssModules", Ve]]);
|
|
275
275
|
export {
|
|
276
276
|
k as RADIO_GROUP_INJECTION,
|
|
277
|
-
|
|
278
|
-
|
|
277
|
+
x as RadioGroupVariant,
|
|
278
|
+
Me as default
|
|
279
279
|
};
|
|
280
280
|
//# sourceMappingURL=RadioGroup.js.map
|
package/dist/RadioGroup.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioGroup.js","sources":["../src/components/RadioGroup/components/VariantButton.vue","../src/components/RadioGroup/components/VariantChip.vue","../src/components/RadioGroup/components/VariantRadio.vue","../src/components/RadioGroup/components/VariantTile.vue","../src/components/RadioGroup/RadioGroup.types.ts","../src/components/RadioGroup/RadioGroup.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { inject, useCssModule } from 'vue';\n\n import { RADIO_GROUP_INJECTION } from '../RadioGroup.keys';\n\n const radioGroupInjection = inject(RADIO_GROUP_INJECTION.key);\n\n if (!radioGroupInjection) {\n throw new Error('VariantButton must be used with a RadioGroup instance.');\n }\n\n const { name, disabled, fullWidth, modelValue, options, update } = radioGroupInjection;\n const classes = useCssModule();\n</script>\n\n<template>\n <div class=\"tw-flex\" :class=\"classes.root\">\n <div v-for=\"option in options\" :key=\"`${name}-${option.id}`\" :class=\"[{ 'tw-w-full': fullWidth }]\">\n <input\n :id=\"`${name}-${option.id}`\"\n class=\"tw-sr-only\"\n type=\"radio\"\n :name=\"name\"\n :value=\"option.value\"\n :checked=\"modelValue === option.value\"\n :disabled=\"disabled || option.disabled\"\n @input=\"update\"\n />\n <label :for=\"`${name}-${option.id}`\">\n {{ option.text }}\n </label>\n </div>\n </div>\n</template>\n\n<style module>\n .root label {\n padding: 8px 30px;\n border: 1px solid var(--color-ice-500);\n font-weight: theme('fontWeight.semibold');\n color: var(--color-ice-700);\n cursor: pointer;\n transition: all 0.2s;\n user-select: none;\n display: block;\n text-align: center;\n }\n\n .root > div:first-child label {\n border-top-left-radius: theme('borderRadius.DEFAULT');\n border-bottom-left-radius: theme('borderRadius.DEFAULT');\n }\n\n .root > div:last-child label {\n border-top-right-radius: theme('borderRadius.DEFAULT');\n border-bottom-right-radius: theme('borderRadius.DEFAULT');\n }\n\n .root > div:not(:first-child) label {\n margin-left: -1px;\n }\n\n .root > div:not(:last-child) label {\n border-right-color: transparent;\n }\n\n .root input:disabled ~ label {\n background-color: var(--color-ice-200);\n color: var(--color-ice-500);\n cursor: auto;\n }\n\n .root input:not(:checked, :disabled) ~ label:hover {\n border-color: var(--color-blue-500);\n color: var(--color-blue-500);\n z-index: 1;\n position: relative;\n }\n\n .root input:checked:not(:disabled) ~ label {\n border-color: var(--color-blue-500);\n color: var(--color-blue-500);\n background-color: var(--color-blue-100);\n z-index: 1;\n position: relative;\n }\n</style>\n","<script setup lang=\"ts\">\n import { inject, useCssModule } from 'vue';\n\n import { RADIO_GROUP_INJECTION } from '../RadioGroup.keys';\n\n const radioGroupInjection = inject(RADIO_GROUP_INJECTION.key);\n\n if (!radioGroupInjection) {\n throw new Error('VariantChip must be used with a RadioGroup instance.');\n }\n\n const { name, disabled, fullWidth, modelValue, options, update } = radioGroupInjection;\n const classes = useCssModule();\n</script>\n\n<template>\n <div class=\"tw-my-1.5 tw-flex tw-flex-wrap\" :class=\"classes.root\">\n <div v-for=\"option in options\" :key=\"`${name}-${option.id}`\" :class=\"[{ 'tw-w-full': fullWidth }]\">\n <input\n :id=\"`${name}-${option.id}`\"\n class=\"tw-sr-only\"\n type=\"radio\"\n :name=\"name\"\n :value=\"option.value\"\n :checked=\"modelValue === option.value\"\n :disabled=\"disabled || option.disabled\"\n @input=\"update\"\n />\n <label :for=\"`${name}-${option.id}`\">\n {{ option.text }}\n </label>\n </div>\n </div>\n</template>\n\n<style module>\n .root {\n gap: theme('spacing.6');\n }\n\n .root label {\n padding: theme('spacing[1.5]') theme('spacing.3');\n border: 1px solid var(--color-ice-500);\n font-weight: theme('fontWeight.normal');\n color: var(--color-ice-900);\n cursor: pointer;\n transition: all 0.2s;\n user-select: none;\n border-radius: 9999px;\n white-space: nowrap;\n }\n\n .root input:disabled ~ label {\n background-color: var(--color-ice-200);\n color: var(--color-ice-500);\n cursor: auto;\n }\n\n .root input:checked:not(:disabled) ~ label {\n border-color: var(--color-blue-500);\n color: var(--color-white);\n background-color: var(--color-blue-500);\n font-weight: theme('fontWeight.bold');\n }\n\n .root input:not(:checked, :disabled) ~ label:hover {\n border-color: var(--color-blue-500);\n }\n</style>\n","<script setup lang=\"ts\">\n import { inject, useCssModule } from 'vue';\n\n import { RADIO_GROUP_INJECTION } from '../RadioGroup.keys';\n\n const radioGroupInjection = inject(RADIO_GROUP_INJECTION.key);\n\n if (!radioGroupInjection) {\n throw new Error('VariantRadio must be used with a RadioGroup instance.');\n }\n\n const { name, disabled, fullWidth, modelValue, options, update } = radioGroupInjection;\n const classes = useCssModule();\n</script>\n\n<template>\n <div class=\"tw-flex tw-flex-wrap\" :class=\"classes.root\">\n <div v-for=\"option in options\" :key=\"`${name}-${option.id}`\" :class=\"[{ 'tw-w-full': fullWidth }]\">\n <input\n :id=\"`${name}-${option.id}`\"\n type=\"radio\"\n :name=\"name\"\n :value=\"option.value\"\n :checked=\"modelValue === option.value\"\n :disabled=\"disabled || option.disabled\"\n @input=\"update\"\n />\n <label :for=\"`${name}-${option.id}`\">\n {{ option.text }}\n </label>\n </div>\n </div>\n</template>\n\n<style module>\n .root {\n gap: theme('spacing.6');\n }\n\n .root label {\n font-weight: theme('fontWeight.medium');\n user-select: none;\n cursor: pointer;\n padding: 0 theme('spacing.3');\n }\n\n .root input {\n appearance: none;\n border-radius: 50%;\n width: 20px;\n height: 20px;\n border: 1px solid var(--color-ice-500);\n transition: all 0.2s;\n position: relative;\n cursor: pointer;\n top: 5px;\n }\n\n .root input:checked {\n background-image: radial-gradient(var(--color-blue-500) 50%, transparent 54%);\n }\n\n .root input:disabled {\n background: #eef2f4;\n }\n\n .root input:disabled ~ label {\n cursor: auto;\n }\n\n .root input:disabled:checked {\n background-image: radial-gradient(var(--color-ice-500) 50%, transparent 54%);\n }\n\n .root input:hover:not(:disabled) {\n border-color: var(--color-blue-500);\n }\n\n .root input:hover:not(:disabled) ~ label {\n color: var(--color-ice-900);\n }\n\n .root input:not(:disabled) ~ label:hover {\n color: var(--color-ice-900);\n }\n</style>\n","<script setup lang=\"ts\">\n import { inject, useCssModule } from 'vue';\n\n import { RADIO_GROUP_INJECTION } from '../RadioGroup.keys';\n\n const radioGroupInjection = inject(RADIO_GROUP_INJECTION.key);\n\n if (!radioGroupInjection) {\n throw new Error('VariantTile must be used with a RadioGroup instance.');\n }\n\n const { name, disabled, fullWidth, modelValue, options, update } = radioGroupInjection;\n const classes = useCssModule();\n</script>\n\n<template>\n <div class=\"tw-flex tw-flex-wrap\" :class=\"classes.root\">\n <label\n v-for=\"option in options\"\n :key=\"`${name}-${option.id}`\"\n :class=\"[classes['tile-container'], { 'tw-w-full': fullWidth }]\"\n :for=\"`${name}-${option.id}`\"\n >\n <div\n class=\"tw-flex tw-border\"\n :class=\"[\n classes['tile-header'],\n {\n 'tw-border-blue-500 tw-bg-blue-100 tw-text-ice-900': modelValue === option.value,\n 'tw-border-ice-500 tw-bg-ice-100 tw-text-ice-700': modelValue !== option.value,\n },\n ]\"\n >\n <input\n :id=\"`${name}-${option.id}`\"\n class=\"tw-sr-only\"\n type=\"radio\"\n :name=\"name\"\n :value=\"option.value\"\n :checked=\"modelValue === option.value\"\n :disabled=\"disabled || option.disabled\"\n @input=\"update\"\n />\n <div>\n <span>\n {{ option.text }}\n </span>\n </div>\n </div>\n <div\n class=\"tw-border-x tw-border-b\"\n :class=\"[\n classes['tile-body'],\n {\n 'tw-border-ice-500': modelValue !== option.value,\n 'tw-border-blue-500': modelValue === option.value,\n },\n ]\"\n >\n <p class=\"tw-m-0 tw-text-ice-900\">{{ option.subTitle }}</p>\n <p class=\"tw-m-0 tw-text-ice-700\">{{ option.subText }}</p>\n </div>\n </label>\n </div>\n</template>\n\n<style module>\n .root {\n gap: theme('spacing.6');\n }\n\n .root label {\n cursor: pointer;\n user-select: none;\n }\n\n .root input:disabled ~ label {\n cursor: auto;\n }\n\n .root input:hover:not(:disabled) ~ label {\n color: var(--color-ice-900);\n }\n\n .root input:not(:disabled) ~ label:hover {\n color: var(--color-ice-900);\n }\n\n .root label.tile-container {\n border-radius: theme('borderRadius.DEFAULT');\n display: flex;\n flex: 1;\n flex-direction: column;\n }\n\n .tile-header,\n .tile-body {\n transition: all 0.2s;\n }\n\n .tile-header {\n border-radius: theme('borderRadius.DEFAULT') theme('borderRadius.DEFAULT') 0 0;\n padding: theme('spacing.3') 0;\n }\n\n .root label.tile-container:hover .tile-header {\n background-color: var(--color-blue-100) !important;\n border-color: var(--color-blue-500) !important;\n color: var(--color-ice-900) !important;\n transition: all 0.2s;\n }\n\n .tile-body {\n border-radius: 0 0 theme('borderRadius.DEFAULT') theme('borderRadius.DEFAULT');\n background-color: var(--color-white);\n padding: theme('spacing.6');\n display: flex;\n flex-direction: column;\n }\n\n .root label.tile-container:hover .tile-body {\n border-color: var(--color-blue-500) !important;\n transition: all 0.2s;\n }\n\n .root input {\n appearance: none;\n background-color: var(--color-white);\n border-radius: 50%;\n width: 20px;\n height: 20px;\n border: 1px solid var(--color-ice-500);\n transition: all 0.2s;\n position: relative;\n cursor: pointer;\n top: 2px;\n }\n\n .root input ~ div {\n font-weight: theme('fontWeight.medium');\n user-select: none;\n cursor: pointer;\n padding: 0 theme('spacing.3');\n }\n\n .root input:disabled {\n background: #eef2f4;\n }\n\n .root input:checked {\n background-image: radial-gradient(var(--color-blue-500) 50%, transparent 54%);\n }\n\n .root label.tile-container input {\n margin-left: theme('spacing.3');\n }\n\n .root input:disabled:checked {\n background-image: radial-gradient(var(--color-ice-500) 50%, transparent 54%);\n }\n\n @media screen and (width <= 640px) {\n .root {\n flex-direction: column;\n }\n }\n</style>\n","import { ComputedRef } from 'vue';\n\nexport enum RadioGroupVariant {\n Radio = 'radio',\n Button = 'button',\n Chip = 'chip',\n Tile = 'tile',\n}\n\nexport type RadioGroupVariants = `${RadioGroupVariant}`;\n\n/**\n * An individual radio `<input>` within a RadioGroup instance\n */\nexport interface RadioGroupOption {\n /**\n * Disables the RadioGroupOption if truthy\n */\n disabled?: boolean;\n\n /**\n * The unique identifier for the option\n */\n id: number | string;\n\n /**\n * The text to be displayed for the option\n */\n text: string;\n\n /**\n * The value of the option. Used for the modelValue of the RadioGroup.\n */\n value: string;\n\n /**\n * The subtitle for tile variant\n */\n subTitle?: string;\n\n /**\n * The subtext for tile variant\n */\n subText?: string;\n}\n\n/**\n * Properties and utilities provided to children of a RadioGroup instance\n */\nexport interface RadioGroupInjection {\n /**\n * This type should match RadioGroupProps['disabled']\n */\n disabled: ComputedRef<boolean | undefined>;\n\n /**\n * This type should match RadioGroupProps['fullWidth']\n */\n fullWidth: ComputedRef<boolean | undefined>;\n\n /**\n * This type should match RadioGroupProps['modelValue']\n */\n modelValue: ComputedRef<string | undefined>;\n\n /**\n * This type should match RadioGroupProps['name']\n */\n name: ComputedRef<string | undefined>;\n\n /**\n * This type should match RadioGroupProps['options']\n */\n options: ComputedRef<RadioGroupOption[] | undefined>;\n\n /**\n * Triggered when the user changes their selection; updates the v-model.\n */\n update: (e: Event) => void;\n\n /**\n * This type should match RadioGroupProps['variant']\n * @default 'radio'\n */\n variant: ComputedRef<RadioGroupVariants | undefined>;\n\n /**\n * Default orientation. If the variant is `button` and the group is wider than its parent it will be displayed in a column, and this prop will be ignored.\n *\n * Note: This does not work with the deprecated `options` prop. Update those instances to use the `RadioNew` component and default slot.\n */\n orientation?: ComputedRef<'horizontal' | 'vertical'>;\n}\n","<script lang=\"ts\">\n import { FieldProps } from '../Field/Field.types';\n import Field from '../Field/Field.vue';\n import { RadioGroupOption, RadioGroupVariant, RadioGroupVariants } from './RadioGroup.types';\n\n export * from './RadioGroup.keys';\n export * from './RadioGroup.types';\n\n export interface RadioGroupProps extends FieldProps {\n /**\n * Passed to the \"name\" attribute of the `<input>` elements within the RadioGroup.\n */\n name?: string;\n\n /**\n * Deprecated - Compose your radio group with the `Radio` component instead\n * @deprecated\n */\n options?: RadioGroupOption[];\n\n /**\n * The value of the selected radio option. Use this prop with the `update:modelValue` event to create a controlled component.\n */\n modelValue?: RadioGroupOption['value'];\n\n /**\n * @defaultValue 'radio'\n */\n variant?: RadioGroupVariants;\n\n /**\n * Whether the group should expand to the parent's width\n */\n fullWidth?: boolean;\n\n /**\n * Default orientation. If the variant is `button` and the group is wider than its parent it will be displayed in a column, and this prop will be ignored.\n *\n * Note: This does not work with the deprecated `options` prop. Update those instances to use the `RadioNew` component and default slot.\n *\n * @defaultValue 'horizontal'\n */\n orientation?: 'horizontal' | 'vertical';\n }\n</script>\n\n<script setup lang=\"ts\">\n import uniqueId from 'lodash-es/uniqueId';\n import { computed, onMounted, onUnmounted, provide, ref, useCssModule, useTemplateRef, watchEffect } from 'vue';\n\n import VariantButton from './components/VariantButton.vue';\n import VariantChip from './components/VariantChip.vue';\n import VariantRadio from './components/VariantRadio.vue';\n import VariantTile from './components/VariantTile.vue';\n import { RADIO_GROUP_INJECTION } from './RadioGroup.keys';\n\n const variantComponentsMap = {\n [RadioGroupVariant.Button]: VariantButton,\n [RadioGroupVariant.Chip]: VariantChip,\n [RadioGroupVariant.Radio]: VariantRadio,\n [RadioGroupVariant.Tile]: VariantTile,\n };\n\n const props = withDefaults(defineProps<RadioGroupProps>(), {\n variant: 'radio',\n fullWidth: false,\n modelValue: undefined,\n name: undefined,\n options: undefined,\n orientation: 'horizontal',\n });\n\n const emit = defineEmits<{\n /**\n * Occurs when the user selects a radio option. Also, it enables v-model usage on the component.\n */\n (e: 'update:modelValue', value: RadioGroupOption['value']): void;\n }>();\n\n const classes = useCssModule();\n\n function update(e: Event) {\n emit('update:modelValue', (e.target as HTMLInputElement).value);\n }\n\n const errorId = uniqueId('radio-group-field-error-');\n\n provide(RADIO_GROUP_INJECTION.key, {\n name: computed(() => props.name),\n disabled: computed(() => props.isDisabled || props.disabled),\n fullWidth: computed(() => props.fullWidth),\n modelValue: computed(() => props.modelValue),\n options: computed(() => props.options),\n variant: computed(() => props.variant),\n orientation: computed(() => internalOrientation.value),\n update,\n });\n\n const internalOrientation = ref(props.orientation);\n\n const defaultSlotClasses = computed(() => {\n return {\n 'tw-flex-wrap': props.variant !== 'button',\n 'tw-gap-x-1.5 tw-gap-y-3': props.variant === 'chip' && internalOrientation.value === 'horizontal',\n 'tw-gap-6':\n props.variant === 'radio' ||\n props.variant === 'tile' ||\n (props.variant === 'chip' && internalOrientation.value === 'vertical'),\n 'tw-flex-col': internalOrientation.value === 'vertical',\n };\n });\n\n const resizeObserver = ref<ResizeObserver | null>(null);\n const radioGroupRef = useTemplateRef('radioGroup');\n const radioGroupParent = computed(() => radioGroupRef.value?.$el.parentElement);\n const radioGroupButtons = computed(() => {\n if (props.variant !== 'button') {\n return [];\n }\n\n return Array.from<HTMLElement>(radioGroupRef.value?.$el.querySelectorAll('[data-variant-button]')) || [];\n });\n\n function getButtonsWidth() {\n return radioGroupButtons.value.reduce((acc, button) => {\n const buttonWidth = button.getBoundingClientRect().width;\n return acc + buttonWidth;\n }, 0);\n }\n\n const initialTotalButtonsWidth = ref(0);\n\n const handleResize = (entry: ResizeObserverEntry) => {\n internalOrientation.value =\n initialTotalButtonsWidth.value > entry.contentBoxSize[0].inlineSize ? 'vertical' : props.orientation;\n };\n\n onMounted(() => {\n // If the width of the buttons is greater than the parent element,\n // set orientation to vertical\n if (props.variant === 'button' && !props.fullWidth) {\n initialTotalButtonsWidth.value = getButtonsWidth();\n resizeObserver.value = new ResizeObserver((entries) => handleResize(entries[0]));\n\n resizeObserver.value.observe(radioGroupParent.value);\n }\n });\n\n onUnmounted(() => {\n if (props.variant === 'button' && resizeObserver.value) {\n resizeObserver.value?.disconnect();\n }\n });\n\n watchEffect(() => {\n internalOrientation.value = props.orientation;\n });\n</script>\n\n<template>\n <Field\n v-bind=\"props\"\n ref=\"radioGroup\"\n class=\"stash-radio-group\"\n :class=\"classes['stash-radio-group']\"\n data-test=\"stash-radio-group\"\n :aria-errormessage=\"errorId\"\n :error-id=\"errorId\"\n :aria-invalid=\"!!props.errorText\"\n role=\"radiogroup\"\n fieldset\n >\n <slot v-if=\"props.options\">\n <component :is=\"variantComponentsMap[props.variant]\" />\n </slot>\n <div v-else class=\"tw-flex\" data-test=\"stash-radio-group|default-slot\" :class=\"defaultSlotClasses\">\n <slot></slot>\n </div>\n </Field>\n</template>\n\n<style module>\n .stash-radio-group :global(.stash-field-hint),\n .stash-radio-group :global(.stash-field-error) {\n display: block;\n width: 100%;\n }\n\n .stash-radio-group > :global(.stash-label) {\n margin-bottom: 4px;\n }\n</style>\n"],"names":["radioGroupInjection","inject","RADIO_GROUP_INJECTION","name","disabled","fullWidth","modelValue","options","update","classes","useCssModule","RadioGroupVariant","variantComponentsMap","VariantButton","VariantChip","VariantRadio","VariantTile","props","__props","emit","__emit","e","errorId","uniqueId","provide","computed","internalOrientation","ref","defaultSlotClasses","resizeObserver","radioGroupRef","useTemplateRef","radioGroupParent","_a","radioGroupButtons","getButtonsWidth","acc","button","buttonWidth","initialTotalButtonsWidth","handleResize","entry","onMounted","entries","onUnmounted","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AS,MAAM;;AACvC,aAAIR,EAAM,YAAY,WACb,CAAA,IAGF,MAAM,MAAkBgB,IAAAH,EAAc,UAAd,gBAAAG,EAAqB,IAAI,iBAAiB,wBAAwB,KAAK,CAAA;AAAA,IACxG,CAAC;AAED,aAASE,IAAkB;AACzB,aAAOD,EAAkB,MAAM,OAAO,CAACE,GAAKC,MAAW;AACrD,cAAMC,IAAcD,EAAO,sBAAA,EAAwB;AACnD,eAAOD,IAAME;AAAA,MACf,GAAG,CAAC;AAAA,IACN;AAEA,UAAMC,IAA2BZ,EAAI,CAAC,GAEhCa,IAAe,CAACC,MAA+B;AACnD,MAAAf,EAAoB,QAClBa,EAAyB,QAAQE,EAAM,eAAe,CAAC,EAAE,aAAa,aAAaxB,EAAM;AAAA,IAC7F;AAEA,WAAAyB,EAAU,MAAM;AAGd,MAAIzB,EAAM,YAAY,YAAY,CAACA,EAAM,cACvCsB,EAAyB,QAAQJ,EAAA,GACjCN,EAAe,QAAQ,IAAI,eAAe,CAACc,MAAYH,EAAaG,EAAQ,CAAC,CAAC,CAAC,GAE/Ed,EAAe,MAAM,QAAQG,EAAiB,KAAK;AAAA,IAEvD,CAAC,GAEDY,EAAY,MAAM;;AAChB,MAAI3B,EAAM,YAAY,YAAYY,EAAe,WAC/CI,IAAAJ,EAAe,UAAf,QAAAI,EAAsB;AAAA,IAE1B,CAAC,GAEDY,EAAY,MAAM;AAChB,MAAAnB,EAAoB,QAAQT,EAAM;AAAA,IACpC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"RadioGroup.js","sources":["../src/components/RadioGroup/components/VariantButton.vue","../src/components/RadioGroup/components/VariantChip.vue","../src/components/RadioGroup/components/VariantRadio.vue","../src/components/RadioGroup/components/VariantTile.vue","../src/components/RadioGroup/RadioGroup.types.ts","../src/components/RadioGroup/RadioGroup.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { inject, useCssModule } from 'vue';\n\n import { RADIO_GROUP_INJECTION } from '../RadioGroup.keys';\n\n const radioGroupInjection = inject(RADIO_GROUP_INJECTION.key);\n\n if (!radioGroupInjection) {\n throw new Error('VariantButton must be used with a RadioGroup instance.');\n }\n\n const { name, disabled, fullWidth, modelValue, options, update } = radioGroupInjection;\n const classes = useCssModule();\n</script>\n\n<template>\n <div class=\"flex\" :class=\"classes.root\">\n <div v-for=\"option in options\" :key=\"`${name}-${option.id}`\" :class=\"[{ 'w-full': fullWidth }]\">\n <input\n :id=\"`${name}-${option.id}`\"\n class=\"sr-only\"\n type=\"radio\"\n :name=\"name\"\n :value=\"option.value\"\n :checked=\"modelValue === option.value\"\n :disabled=\"disabled || option.disabled\"\n @input=\"update\"\n />\n <label :for=\"`${name}-${option.id}`\">\n {{ option.text }}\n </label>\n </div>\n </div>\n</template>\n\n<style module>\n @layer utilities {\n .root label {\n padding: 8px 30px;\n border: 1px solid var(--color-ice-500);\n font-weight: var(--font-weight-semibold);\n color: var(--color-ice-700);\n cursor: pointer;\n transition: all 0.2s;\n user-select: none;\n display: block;\n text-align: center;\n }\n\n .root > div:first-child label {\n border-top-left-radius: var(--radius-sm);\n border-bottom-left-radius: var(--radius-sm);\n }\n\n .root > div:last-child label {\n border-top-right-radius: var(--radius-sm);\n border-bottom-right-radius: var(--radius-sm);\n }\n\n .root > div:not(:first-child) label {\n margin-left: -1px;\n }\n\n .root > div:not(:last-child) label {\n border-right-color: transparent;\n }\n\n .root input:disabled ~ label {\n background-color: var(--color-ice-200);\n color: var(--color-ice-500);\n cursor: auto;\n }\n\n .root input:not(:checked, :disabled) ~ label:hover {\n border-color: var(--color-blue-500);\n color: var(--color-blue-500);\n z-index: 1;\n position: relative;\n }\n\n .root input:checked:not(:disabled) ~ label {\n border-color: var(--color-blue-500);\n color: var(--color-blue-500);\n background-color: var(--color-blue-100);\n z-index: 1;\n position: relative;\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import { inject, useCssModule } from 'vue';\n\n import { RADIO_GROUP_INJECTION } from '../RadioGroup.keys';\n\n const radioGroupInjection = inject(RADIO_GROUP_INJECTION.key);\n\n if (!radioGroupInjection) {\n throw new Error('VariantChip must be used with a RadioGroup instance.');\n }\n\n const { name, disabled, fullWidth, modelValue, options, update } = radioGroupInjection;\n const classes = useCssModule();\n</script>\n\n<template>\n <div class=\"my-1.5 flex flex-wrap\" :class=\"classes.root\">\n <div v-for=\"option in options\" :key=\"`${name}-${option.id}`\" :class=\"[{ 'w-full': fullWidth }]\">\n <input\n :id=\"`${name}-${option.id}`\"\n class=\"sr-only\"\n type=\"radio\"\n :name=\"name\"\n :value=\"option.value\"\n :checked=\"modelValue === option.value\"\n :disabled=\"disabled || option.disabled\"\n @input=\"update\"\n />\n <label :for=\"`${name}-${option.id}`\">\n {{ option.text }}\n </label>\n </div>\n </div>\n</template>\n\n<style module>\n @reference \"../../../../styles/main.css\";\n\n @layer utilities {\n .root {\n gap: --spacing(6);\n }\n\n .root label {\n padding: --spacing(1.5) --spacing(3);\n border: 1px solid var(--color-ice-500);\n font-weight: var(--font-weight-normal);\n color: var(--color-ice-900);\n cursor: pointer;\n transition: all 0.2s;\n user-select: none;\n border-radius: 9999px;\n white-space: nowrap;\n }\n\n .root input:disabled ~ label {\n background-color: var(--color-ice-200);\n color: var(--color-ice-500);\n cursor: auto;\n }\n\n .root input:checked:not(:disabled) ~ label {\n border-color: var(--color-blue-500);\n color: var(--color-white);\n background-color: var(--color-blue-500);\n font-weight: var(--font-weight-bold);\n }\n\n .root input:not(:checked, :disabled) ~ label:hover {\n border-color: var(--color-blue-500);\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import { inject, useCssModule } from 'vue';\n\n import { RADIO_GROUP_INJECTION } from '../RadioGroup.keys';\n\n const radioGroupInjection = inject(RADIO_GROUP_INJECTION.key);\n\n if (!radioGroupInjection) {\n throw new Error('VariantRadio must be used with a RadioGroup instance.');\n }\n\n const { name, disabled, fullWidth, modelValue, options, update } = radioGroupInjection;\n const classes = useCssModule();\n</script>\n\n<template>\n <div class=\"flex flex-wrap\" :class=\"classes.root\">\n <div v-for=\"option in options\" :key=\"`${name}-${option.id}`\" :class=\"[{ 'w-full': fullWidth }]\">\n <input\n :id=\"`${name}-${option.id}`\"\n type=\"radio\"\n :name=\"name\"\n :value=\"option.value\"\n :checked=\"modelValue === option.value\"\n :disabled=\"disabled || option.disabled\"\n @input=\"update\"\n />\n <label :for=\"`${name}-${option.id}`\">\n {{ option.text }}\n </label>\n </div>\n </div>\n</template>\n\n<style module>\n @reference \"../../../../styles/main.css\";\n\n @layer utilities {\n .root {\n gap: --spacing(6);\n }\n\n .root label {\n font-weight: var(--font-weight-medium);\n user-select: none;\n cursor: pointer;\n padding: 0 --spacing(3);\n }\n\n .root input {\n appearance: none;\n border-radius: 50%;\n width: 20px;\n height: 20px;\n border: 1px solid var(--color-ice-500);\n transition: all 0.2s;\n position: relative;\n cursor: pointer;\n top: 5px;\n }\n\n .root input:checked {\n background-image: radial-gradient(var(--color-blue-500) 50%, transparent 54%);\n }\n\n .root input:disabled {\n background: #eef2f4;\n }\n\n .root input:disabled ~ label {\n cursor: auto;\n }\n\n .root input:disabled:checked {\n background-image: radial-gradient(var(--color-ice-500) 50%, transparent 54%);\n }\n\n .root input:hover:not(:disabled) {\n border-color: var(--color-blue-500);\n }\n\n .root input:hover:not(:disabled) ~ label {\n color: var(--color-ice-900);\n }\n\n .root input:not(:disabled) ~ label:hover {\n color: var(--color-ice-900);\n }\n }\n</style>\n","<script setup lang=\"ts\">\n import { inject, useCssModule } from 'vue';\n\n import { RADIO_GROUP_INJECTION } from '../RadioGroup.keys';\n\n const radioGroupInjection = inject(RADIO_GROUP_INJECTION.key);\n\n if (!radioGroupInjection) {\n throw new Error('VariantTile must be used with a RadioGroup instance.');\n }\n\n const { name, disabled, fullWidth, modelValue, options, update } = radioGroupInjection;\n const classes = useCssModule();\n</script>\n\n<template>\n <div class=\"flex flex-wrap\" :class=\"classes.root\">\n <label\n v-for=\"option in options\"\n :key=\"`${name}-${option.id}`\"\n :class=\"[classes['tile-container'], { 'w-full': fullWidth }]\"\n :for=\"`${name}-${option.id}`\"\n >\n <div\n class=\"flex border\"\n :class=\"[\n classes['tile-header'],\n {\n 'border-blue-500 bg-blue-100 text-ice-900': modelValue === option.value,\n 'border-ice-500 bg-ice-100 text-ice-700': modelValue !== option.value,\n },\n ]\"\n >\n <input\n :id=\"`${name}-${option.id}`\"\n class=\"sr-only\"\n type=\"radio\"\n :name=\"name\"\n :value=\"option.value\"\n :checked=\"modelValue === option.value\"\n :disabled=\"disabled || option.disabled\"\n @input=\"update\"\n />\n <div>\n <span>\n {{ option.text }}\n </span>\n </div>\n </div>\n <div\n class=\"border-x border-b\"\n :class=\"[\n classes['tile-body'],\n {\n 'border-ice-500': modelValue !== option.value,\n 'border-blue-500': modelValue === option.value,\n },\n ]\"\n >\n <p class=\"m-0 text-ice-900\">{{ option.subTitle }}</p>\n <p class=\"m-0 text-ice-700\">{{ option.subText }}</p>\n </div>\n </label>\n </div>\n</template>\n\n<style module>\n @reference \"../../../../styles/main.css\";\n\n @layer utilities {\n .root {\n gap: --spacing(6);\n }\n\n .root label {\n cursor: pointer;\n user-select: none;\n }\n\n .root input:disabled ~ label {\n cursor: auto;\n }\n\n .root input:hover:not(:disabled) ~ label {\n color: var(--color-ice-900);\n }\n\n .root input:not(:disabled) ~ label:hover {\n color: var(--color-ice-900);\n }\n\n .root label.tile-container {\n border-radius: var(--radius-sm);\n display: flex;\n flex: 1;\n flex-direction: column;\n }\n\n .tile-header,\n .tile-body {\n transition: all 0.2s;\n }\n\n .tile-header {\n border-radius: var(--radius-sm) var(--radius-sm) 0 0;\n padding: --spacing(3) 0;\n }\n\n .root label.tile-container:hover .tile-header {\n background-color: var(--color-blue-100) !important;\n border-color: var(--color-blue-500) !important;\n color: var(--color-ice-900) !important;\n transition: all 0.2s;\n }\n\n .tile-body {\n border-radius: 0 0 var(--radius-sm) var(--radius-sm);\n background-color: var(--color-white);\n padding: --spacing(6);\n display: flex;\n flex-direction: column;\n }\n\n .root label.tile-container:hover .tile-body {\n border-color: var(--color-blue-500) !important;\n transition: all 0.2s;\n }\n\n .root input {\n appearance: none;\n background-color: var(--color-white);\n border-radius: 50%;\n width: 20px;\n height: 20px;\n border: 1px solid var(--color-ice-500);\n transition: all 0.2s;\n position: relative;\n cursor: pointer;\n top: 2px;\n }\n\n .root input ~ div {\n font-weight: var(--font-weight-medium);\n user-select: none;\n cursor: pointer;\n padding: 0 --spacing(3);\n }\n\n .root input:disabled {\n background: #eef2f4;\n }\n\n .root input:checked {\n background-image: radial-gradient(var(--color-blue-500) 50%, transparent 54%);\n }\n\n .root label.tile-container input {\n margin-left: --spacing(3);\n }\n\n .root input:disabled:checked {\n background-image: radial-gradient(var(--color-ice-500) 50%, transparent 54%);\n }\n\n @media screen and (width <= 640px) {\n .root {\n flex-direction: column;\n }\n }\n }\n</style>\n","import { ComputedRef } from 'vue';\n\nexport enum RadioGroupVariant {\n Radio = 'radio',\n Button = 'button',\n Chip = 'chip',\n Tile = 'tile',\n}\n\nexport type RadioGroupVariants = `${RadioGroupVariant}`;\n\n/**\n * An individual radio `<input>` within a RadioGroup instance\n */\nexport interface RadioGroupOption {\n /**\n * Disables the RadioGroupOption if truthy\n */\n disabled?: boolean;\n\n /**\n * The unique identifier for the option\n */\n id: number | string;\n\n /**\n * The text to be displayed for the option\n */\n text: string;\n\n /**\n * The value of the option. Used for the modelValue of the RadioGroup.\n */\n value: string;\n\n /**\n * The subtitle for tile variant\n */\n subTitle?: string;\n\n /**\n * The subtext for tile variant\n */\n subText?: string;\n}\n\n/**\n * Properties and utilities provided to children of a RadioGroup instance\n */\nexport interface RadioGroupInjection {\n /**\n * This type should match RadioGroupProps['disabled']\n */\n disabled: ComputedRef<boolean | undefined>;\n\n /**\n * This type should match RadioGroupProps['fullWidth']\n */\n fullWidth: ComputedRef<boolean | undefined>;\n\n /**\n * This type should match RadioGroupProps['modelValue']\n */\n modelValue: ComputedRef<string | undefined>;\n\n /**\n * This type should match RadioGroupProps['name']\n */\n name: ComputedRef<string | undefined>;\n\n /**\n * This type should match RadioGroupProps['options']\n */\n options: ComputedRef<RadioGroupOption[] | undefined>;\n\n /**\n * Triggered when the user changes their selection; updates the v-model.\n */\n update: (e: Event) => void;\n\n /**\n * This type should match RadioGroupProps['variant']\n * @default 'radio'\n */\n variant: ComputedRef<RadioGroupVariants | undefined>;\n\n /**\n * Default orientation. If the variant is `button` and the group is wider than its parent it will be displayed in a column, and this prop will be ignored.\n *\n * Note: This does not work with the deprecated `options` prop. Update those instances to use the `RadioNew` component and default slot.\n */\n orientation?: ComputedRef<'horizontal' | 'vertical'>;\n}\n","<script lang=\"ts\">\n import { FieldProps } from '../Field/Field.types';\n import Field from '../Field/Field.vue';\n import { RadioGroupOption, RadioGroupVariant, RadioGroupVariants } from './RadioGroup.types';\n\n export * from './RadioGroup.keys';\n export * from './RadioGroup.types';\n\n export interface RadioGroupProps extends FieldProps {\n /**\n * Passed to the \"name\" attribute of the `<input>` elements within the RadioGroup.\n */\n name?: string;\n\n /**\n * Deprecated - Compose your radio group with the `Radio` component instead\n * @deprecated\n */\n options?: RadioGroupOption[];\n\n /**\n * The value of the selected radio option. Use this prop with the `update:modelValue` event to create a controlled component.\n */\n modelValue?: RadioGroupOption['value'];\n\n /**\n * @defaultValue 'radio'\n */\n variant?: RadioGroupVariants;\n\n /**\n * Whether the group should expand to the parent's width\n */\n fullWidth?: boolean;\n\n /**\n * Default orientation. If the variant is `button` and the group is wider than its parent it will be displayed in a column, and this prop will be ignored.\n *\n * Note: This does not work with the deprecated `options` prop. Update those instances to use the `RadioNew` component and default slot.\n *\n * @defaultValue 'horizontal'\n */\n orientation?: 'horizontal' | 'vertical';\n }\n</script>\n\n<script setup lang=\"ts\">\n import uniqueId from 'lodash-es/uniqueId';\n import { computed, onMounted, onUnmounted, provide, ref, useCssModule, useTemplateRef, watchEffect } from 'vue';\n\n import VariantButton from './components/VariantButton.vue';\n import VariantChip from './components/VariantChip.vue';\n import VariantRadio from './components/VariantRadio.vue';\n import VariantTile from './components/VariantTile.vue';\n import { RADIO_GROUP_INJECTION } from './RadioGroup.keys';\n\n const variantComponentsMap = {\n [RadioGroupVariant.Button]: VariantButton,\n [RadioGroupVariant.Chip]: VariantChip,\n [RadioGroupVariant.Radio]: VariantRadio,\n [RadioGroupVariant.Tile]: VariantTile,\n };\n\n const props = withDefaults(defineProps<RadioGroupProps>(), {\n variant: 'radio',\n fullWidth: false,\n modelValue: undefined,\n name: undefined,\n options: undefined,\n orientation: 'horizontal',\n });\n\n const emit = defineEmits<{\n /**\n * Occurs when the user selects a radio option. Also, it enables v-model usage on the component.\n */\n (e: 'update:modelValue', value: RadioGroupOption['value']): void;\n }>();\n\n const classes = useCssModule();\n\n function update(e: Event) {\n emit('update:modelValue', (e.target as HTMLInputElement).value);\n }\n\n const errorId = uniqueId('radio-group-field-error-');\n\n provide(RADIO_GROUP_INJECTION.key, {\n name: computed(() => props.name),\n disabled: computed(() => props.isDisabled || props.disabled),\n fullWidth: computed(() => props.fullWidth),\n modelValue: computed(() => props.modelValue),\n options: computed(() => props.options),\n variant: computed(() => props.variant),\n orientation: computed(() => internalOrientation.value),\n update,\n });\n\n const internalOrientation = ref(props.orientation);\n\n const defaultSlotClasses = computed(() => {\n return {\n 'flex-wrap': props.variant !== 'button',\n 'gap-x-1.5 gap-y-3': props.variant === 'chip' && internalOrientation.value === 'horizontal',\n 'gap-6':\n props.variant === 'radio' ||\n props.variant === 'tile' ||\n (props.variant === 'chip' && internalOrientation.value === 'vertical'),\n 'flex-col': internalOrientation.value === 'vertical',\n };\n });\n\n const resizeObserver = ref<ResizeObserver | null>(null);\n const radioGroupRef = useTemplateRef('radioGroup');\n const radioGroupParent = computed(() => radioGroupRef.value?.$el.parentElement);\n const radioGroupButtons = computed(() => {\n if (props.variant !== 'button') {\n return [];\n }\n\n return Array.from<HTMLElement>(radioGroupRef.value?.$el.querySelectorAll('[data-variant-button]')) || [];\n });\n\n function getButtonsWidth() {\n return radioGroupButtons.value.reduce((acc, button) => {\n const buttonWidth = button.getBoundingClientRect().width;\n return acc + buttonWidth;\n }, 0);\n }\n\n const initialTotalButtonsWidth = ref(0);\n\n const handleResize = (entry: ResizeObserverEntry) => {\n internalOrientation.value =\n initialTotalButtonsWidth.value > entry.contentBoxSize[0].inlineSize ? 'vertical' : props.orientation;\n };\n\n onMounted(() => {\n // If the width of the buttons is greater than the parent element,\n // set orientation to vertical\n if (props.variant === 'button' && !props.fullWidth) {\n initialTotalButtonsWidth.value = getButtonsWidth();\n resizeObserver.value = new ResizeObserver((entries) => handleResize(entries[0]));\n\n resizeObserver.value.observe(radioGroupParent.value);\n }\n });\n\n onUnmounted(() => {\n if (props.variant === 'button' && resizeObserver.value) {\n resizeObserver.value?.disconnect();\n }\n });\n\n watchEffect(() => {\n internalOrientation.value = props.orientation;\n });\n</script>\n\n<template>\n <Field\n v-bind=\"props\"\n ref=\"radioGroup\"\n class=\"stash-radio-group\"\n :class=\"classes['stash-radio-group']\"\n data-test=\"stash-radio-group\"\n :aria-errormessage=\"errorId\"\n :error-id=\"errorId\"\n :aria-invalid=\"!!props.errorText\"\n role=\"radiogroup\"\n fieldset\n >\n <slot v-if=\"props.options\">\n <component :is=\"variantComponentsMap[props.variant]\" />\n </slot>\n <div v-else class=\"flex\" data-test=\"stash-radio-group|default-slot\" :class=\"defaultSlotClasses\">\n <slot></slot>\n </div>\n </Field>\n</template>\n\n<style module>\n @layer utilities {\n .stash-radio-group :global(.stash-field-hint),\n .stash-radio-group :global(.stash-field-error) {\n display: block;\n width: 100%;\n }\n\n .stash-radio-group > :global(.stash-label) {\n margin-bottom: 4px;\n }\n }\n</style>\n"],"names":["radioGroupInjection","inject","RADIO_GROUP_INJECTION","name","disabled","fullWidth","modelValue","options","update","classes","useCssModule","RadioGroupVariant","variantComponentsMap","VariantButton","VariantChip","VariantRadio","VariantTile","props","__props","emit","__emit","e","errorId","uniqueId","provide","computed","internalOrientation","ref","defaultSlotClasses","resizeObserver","radioGroupRef","useTemplateRef","radioGroupParent","_a","radioGroupButtons","getButtonsWidth","acc","button","buttonWidth","initialTotalButtonsWidth","handleResize","entry","onMounted","entries","onUnmounted","watchEffect"],"mappings":";;;;;;;;AAKE,UAAMA,IAAsBC,EAAOC,EAAsB,GAAG;AAE5D,QAAI,CAACF;AACH,YAAM,IAAI,MAAM,wDAAwD;AAG1E,UAAM,EAAE,MAAAG,GAAM,UAAAC,GAAU,WAAAC,GAAW,YAAAC,GAAY,SAAAC,GAAS,QAAAC,MAAWR,GAC7DS,IAAUC,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACPhB,UAAMV,IAAsBC,EAAOC,EAAsB,GAAG;AAE5D,QAAI,CAACF;AACH,YAAM,IAAI,MAAM,sDAAsD;AAGxE,UAAM,EAAE,MAAAG,GAAM,UAAAC,GAAU,WAAAC,GAAW,YAAAC,GAAY,SAAAC,GAAS,QAAAC,MAAWR,GAC7DS,IAAUC,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACPhB,UAAMV,IAAsBC,EAAOC,EAAsB,GAAG;AAE5D,QAAI,CAACF;AACH,YAAM,IAAI,MAAM,uDAAuD;AAGzE,UAAM,EAAE,MAAAG,GAAM,UAAAC,GAAU,WAAAC,GAAW,YAAAC,GAAY,SAAAC,GAAS,QAAAC,MAAWR,GAC7DS,IAAUC,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACPhB,UAAMV,IAAsBC,EAAOC,EAAsB,GAAG;AAE5D,QAAI,CAACF;AACH,YAAM,IAAI,MAAM,sDAAsD;AAGxE,UAAM,EAAE,MAAAG,GAAM,UAAAC,GAAU,WAAAC,GAAW,YAAAC,GAAY,SAAAC,GAAS,QAAAC,MAAWR,GAC7DS,IAAUC,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACVX,IAAKC,sBAAAA,OACVA,EAAA,QAAQ,SACRA,EAAA,SAAS,UACTA,EAAA,O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