@leaflink/stash 45.1.1 → 45.1.2
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/dist/AddressSelect.js +1 -1
- package/dist/CurrencyInput.js +1 -1
- package/dist/DataViewFilters.js +1 -1
- package/dist/DatePicker.js +1 -1
- package/dist/Field.js +1 -1
- package/dist/Field.vue_vue_type_script_setup_true_lang-e1e4ff03.js +93 -0
- package/dist/Field.vue_vue_type_script_setup_true_lang-e1e4ff03.js.map +1 -0
- package/dist/FilterSelect.js +1 -1
- package/dist/Filters.js +1 -1
- package/dist/InlineEdit.js +1 -1
- package/dist/Input.js +1 -1
- package/dist/InputOptions.js +1 -1
- package/dist/ListView.js +1 -1
- package/dist/RadioGroup.js +78 -74
- package/dist/RadioGroup.js.map +1 -1
- package/dist/SearchBar.js +1 -1
- package/dist/Select.js +1 -1
- package/dist/SelectStatus.js +1 -1
- package/dist/Textarea.js +1 -1
- package/dist/components.css +1 -1
- package/package.json +1 -2
- package/dist/Field.vue_vue_type_script_setup_true_lang-224ab33a.js +0 -96
- package/dist/Field.vue_vue_type_script_setup_true_lang-224ab33a.js.map +0 -1
package/dist/AddressSelect.js
CHANGED
|
@@ -24,7 +24,7 @@ import "./Icon.js";
|
|
|
24
24
|
import "./index-79ce320f.js";
|
|
25
25
|
import "./Icon.vue_used_vue_type_style_index_0_lang.module-eb359559.js";
|
|
26
26
|
import "./_plugin-vue_export-helper-dad06003.js";
|
|
27
|
-
import "./Field.vue_vue_type_script_setup_true_lang-
|
|
27
|
+
import "./Field.vue_vue_type_script_setup_true_lang-e1e4ff03.js";
|
|
28
28
|
import "./Label.vue_vue_type_script_setup_true_lang-4b02087f.js";
|
|
29
29
|
import "./locale.js";
|
|
30
30
|
const _ = "address-select-", ve = /* @__PURE__ */ M({
|
package/dist/CurrencyInput.js
CHANGED
|
@@ -6,7 +6,7 @@ import "./utils/i18n.js";
|
|
|
6
6
|
import "./constants.js";
|
|
7
7
|
import "./locale.js";
|
|
8
8
|
import "lodash-es/get";
|
|
9
|
-
import "./Field.vue_vue_type_script_setup_true_lang-
|
|
9
|
+
import "./Field.vue_vue_type_script_setup_true_lang-e1e4ff03.js";
|
|
10
10
|
import "lodash-es/uniqueId";
|
|
11
11
|
import "./Label.vue_vue_type_script_setup_true_lang-4b02087f.js";
|
|
12
12
|
import "./Icon.js";
|
package/dist/DataViewFilters.js
CHANGED
|
@@ -26,7 +26,7 @@ import "./Backdrop.js";
|
|
|
26
26
|
import "./Input.js";
|
|
27
27
|
import "lodash-es/isNil";
|
|
28
28
|
import "./utils/i18n.js";
|
|
29
|
-
import "./Field.vue_vue_type_script_setup_true_lang-
|
|
29
|
+
import "./Field.vue_vue_type_script_setup_true_lang-e1e4ff03.js";
|
|
30
30
|
function Pe({
|
|
31
31
|
schema: a,
|
|
32
32
|
dataViewRef: w
|
package/dist/DatePicker.js
CHANGED
|
@@ -20,7 +20,7 @@ import "./index-79ce320f.js";
|
|
|
20
20
|
import "./Icon.vue_used_vue_type_style_index_0_lang.module-eb359559.js";
|
|
21
21
|
import "lodash-es/isNil";
|
|
22
22
|
import "./utils/i18n.js";
|
|
23
|
-
import "./Field.vue_vue_type_script_setup_true_lang-
|
|
23
|
+
import "./Field.vue_vue_type_script_setup_true_lang-e1e4ff03.js";
|
|
24
24
|
import "./Label.vue_vue_type_script_setup_true_lang-4b02087f.js";
|
|
25
25
|
function Uf(e, t) {
|
|
26
26
|
he(2, arguments);
|
package/dist/Field.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as o } from "./Field.vue_vue_type_script_setup_true_lang-
|
|
1
|
+
import { _ as o } from "./Field.vue_vue_type_script_setup_true_lang-e1e4ff03.js";
|
|
2
2
|
import "vue";
|
|
3
3
|
import "lodash-es/uniqueId";
|
|
4
4
|
import "./Label.vue_vue_type_script_setup_true_lang-4b02087f.js";
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { defineComponent as _, useAttrs as T, useSlots as k, computed as l, openBlock as s, createBlock as w, resolveDynamicComponent as B, mergeProps as O, unref as f, withCtx as m, normalizeClass as R, createTextVNode as q, toDisplayString as h, createCommentVNode as v, createElementBlock as o, renderSlot as u } from "vue";
|
|
2
|
+
import p from "lodash-es/uniqueId";
|
|
3
|
+
import { _ as E } from "./Label.vue_vue_type_script_setup_true_lang-4b02087f.js";
|
|
4
|
+
const L = ["aria-labelledby"], S = ["id"], C = {
|
|
5
|
+
key: 4,
|
|
6
|
+
class: "stash-field-hint tw-mt-1 tw-block tw-whitespace-pre-line tw-text-xs",
|
|
7
|
+
"data-test": "stash-field-hint"
|
|
8
|
+
}, g = {
|
|
9
|
+
key: 5,
|
|
10
|
+
class: "stash-field-hint tw-mt-1 tw-whitespace-pre-line tw-text-xs",
|
|
11
|
+
"data-test": "stash-field-hint"
|
|
12
|
+
}, N = /* @__PURE__ */ _({
|
|
13
|
+
inheritAttrs: !1,
|
|
14
|
+
__name: "Field",
|
|
15
|
+
props: {
|
|
16
|
+
addBottomSpace: { type: Boolean, default: !1 },
|
|
17
|
+
errorText: { default: void 0 },
|
|
18
|
+
hintText: { default: void 0 },
|
|
19
|
+
id: { default: void 0 },
|
|
20
|
+
errorId: { default: void 0 },
|
|
21
|
+
isReadOnly: { type: Boolean },
|
|
22
|
+
isRequired: { type: Boolean, default: !1 },
|
|
23
|
+
label: { default: void 0 },
|
|
24
|
+
showOptionalInLabel: { type: Boolean, default: !1 },
|
|
25
|
+
fieldset: { type: Boolean, default: !1 }
|
|
26
|
+
},
|
|
27
|
+
setup(b) {
|
|
28
|
+
const e = b, y = T(), r = k(), i = l(() => e.id || p("stash-field-")), d = l(() => e.errorId || p("stash-field-error-")), a = l(() => p("stash-field-label-")), n = l(() => !!e.errorText), I = l(() => e.fieldset ? "fieldset" : "div"), x = l(() => {
|
|
29
|
+
const { placeholder: t, ...c } = y;
|
|
30
|
+
return c;
|
|
31
|
+
});
|
|
32
|
+
return (t, c) => (s(), w(B(I.value), O({
|
|
33
|
+
"data-test": "stash-field",
|
|
34
|
+
class: ["stash-field", [
|
|
35
|
+
{ "tw-p-0": e.fieldset },
|
|
36
|
+
{ "tw-mb-9": e.addBottomSpace && !e.errorText && !e.hintText && !f(r).hint },
|
|
37
|
+
{ "tw-mb-4": e.addBottomSpace && (e.errorText || e.hintText || f(r).hint) }
|
|
38
|
+
]]
|
|
39
|
+
}, x.value), {
|
|
40
|
+
default: m(() => [
|
|
41
|
+
e.label ? (s(), w(E, {
|
|
42
|
+
key: 0,
|
|
43
|
+
id: a.value,
|
|
44
|
+
class: R({ "tw-mb-1.5": !!e.isReadOnly }),
|
|
45
|
+
for: i.value,
|
|
46
|
+
"has-error": n.value,
|
|
47
|
+
"is-required": t.isRequired,
|
|
48
|
+
"show-optional": e.showOptionalInLabel,
|
|
49
|
+
legend: e.fieldset
|
|
50
|
+
}, {
|
|
51
|
+
default: m(() => [
|
|
52
|
+
q(h(e.label), 1)
|
|
53
|
+
]),
|
|
54
|
+
_: 1
|
|
55
|
+
}, 8, ["id", "class", "for", "has-error", "is-required", "show-optional", "legend"])) : v("", !0),
|
|
56
|
+
e.isReadOnly ? (s(), o("div", {
|
|
57
|
+
key: 1,
|
|
58
|
+
"aria-labelledby": a.value
|
|
59
|
+
}, [
|
|
60
|
+
u(t.$slots, "default", {
|
|
61
|
+
fieldId: i.value,
|
|
62
|
+
fieldErrorId: d.value,
|
|
63
|
+
hasError: n.value,
|
|
64
|
+
isRequired: t.isRequired,
|
|
65
|
+
labelId: a.value,
|
|
66
|
+
showOptionalInLabel: e.showOptionalInLabel
|
|
67
|
+
})
|
|
68
|
+
], 8, L)) : u(t.$slots, "default", {
|
|
69
|
+
key: 2,
|
|
70
|
+
fieldId: i.value,
|
|
71
|
+
fieldErrorId: d.value,
|
|
72
|
+
hasError: n.value,
|
|
73
|
+
isRequired: t.isRequired,
|
|
74
|
+
labelId: a.value,
|
|
75
|
+
showOptionalInLabel: e.showOptionalInLabel
|
|
76
|
+
}),
|
|
77
|
+
e.errorText ? (s(), o("span", {
|
|
78
|
+
key: 3,
|
|
79
|
+
id: d.value,
|
|
80
|
+
class: "stash-field-error tw-mt-1 tw-block tw-whitespace-pre-line tw-text-xs tw-text-red-500",
|
|
81
|
+
"data-test": "stash-field-error"
|
|
82
|
+
}, h(e.errorText), 9, S)) : e.hintText && !e.isReadOnly ? (s(), o("span", C, h(e.hintText), 1)) : f(r).hint && !e.isReadOnly ? (s(), o("div", g, [
|
|
83
|
+
u(t.$slots, "hint")
|
|
84
|
+
])) : v("", !0)
|
|
85
|
+
]),
|
|
86
|
+
_: 3
|
|
87
|
+
}, 16, ["class"]));
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
export {
|
|
91
|
+
N as _
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=Field.vue_vue_type_script_setup_true_lang-e1e4ff03.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Field.vue_vue_type_script_setup_true_lang-e1e4ff03.js","sources":["../src/components/Field/Field.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import uniqueId from 'lodash-es/uniqueId';\n import { computed, useAttrs, useSlots } from 'vue';\n\n import Label from '../Label/Label.vue';\n\n defineOptions({\n inheritAttrs: false,\n });\n\n export interface FieldProps {\n /**\n * Adds spacing under the field that is consistent whether hint/error text is displayed.\n */\n addBottomSpace?: boolean;\n\n /**\n * Error text to display. Replaces `hintText` (if provided) & adds error styling.\n */\n errorText?: string;\n\n /**\n * Displays text below the input; hidden when the isReadOnly prop is truthy.\n */\n hintText?: string;\n\n /**\n * ID for the Label and Input; must be unique\n */\n id?: string;\n\n /**\n * ID for the error text element; useful for aria-errormessage\n */\n errorId?: string;\n\n /**\n * Whether it's a readonly field.\n */\n isReadOnly?: boolean;\n\n /**\n * Whether the field is required.\n */\n isRequired?: boolean;\n\n /**\n * Label to render above the input.\n */\n label?: string;\n\n /**\n * Show \"(optional)\" to the right of the label text\n */\n showOptionalInLabel?: boolean;\n\n /**\n * Indicates wheter the field is a fieldset or not\n */\n fieldset?: boolean;\n }\n\n const props = withDefaults(defineProps<FieldProps>(), {\n addBottomSpace: false,\n errorText: undefined,\n hintText: undefined,\n id: undefined,\n errorId: undefined,\n isRequired: false,\n label: undefined,\n showOptionalInLabel: false,\n fieldset: false,\n });\n const attrs = useAttrs();\n const slots = useSlots();\n const fieldId = computed(() => props.id || uniqueId('stash-field-'));\n const fieldErrorId = computed(() => props.errorId || uniqueId('stash-field-error-'));\n const labelId = computed(() => uniqueId('stash-field-label-'));\n const hasError = computed(() => !!props.errorText);\n const wrapperElement = computed(() => (props.fieldset ? 'fieldset' : 'div'));\n\n // Any attributes that are unique to form elements, you want to exclude from\n // being bound from the root element.\n const rootAttrs = computed(() => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { placeholder, ...otherAttrs } = attrs;\n\n return otherAttrs;\n });\n</script>\n\n<template>\n <component\n :is=\"wrapperElement\"\n data-test=\"stash-field\"\n class=\"stash-field\"\n :class=\"[\n { 'tw-p-0': props.fieldset },\n { 'tw-mb-9': props.addBottomSpace && !props.errorText && !props.hintText && !slots.hint },\n { 'tw-mb-4': props.addBottomSpace && (props.errorText || props.hintText || slots.hint) },\n ]\"\n v-bind=\"rootAttrs\"\n >\n <Label\n v-if=\"props.label\"\n :id=\"labelId\"\n :class=\"{ 'tw-mb-1.5': !!props.isReadOnly }\"\n :for=\"fieldId\"\n :has-error=\"hasError\"\n :is-required=\"isRequired\"\n :show-optional=\"props.showOptionalInLabel\"\n :legend=\"props.fieldset\"\n >\n {{ props.label }}\n </Label>\n\n <!-- @slot for the form field; the Label can also be rendered here instead of using the label prop -->\n <template v-if=\"props.isReadOnly\">\n <div :aria-labelledby=\"labelId\">\n <slot\n :field-id=\"fieldId\"\n :field-error-id=\"fieldErrorId\"\n :has-error=\"hasError\"\n :is-required=\"isRequired\"\n :label-id=\"labelId\"\n :show-optional-in-label=\"props.showOptionalInLabel\"\n ></slot>\n </div>\n </template>\n <template v-else>\n <slot\n :field-id=\"fieldId\"\n :field-error-id=\"fieldErrorId\"\n :has-error=\"hasError\"\n :is-required=\"isRequired\"\n :label-id=\"labelId\"\n :show-optional-in-label=\"props.showOptionalInLabel\"\n ></slot>\n </template>\n\n <span\n v-if=\"props.errorText\"\n :id=\"fieldErrorId\"\n class=\"stash-field-error tw-mt-1 tw-block tw-whitespace-pre-line tw-text-xs tw-text-red-500\"\n data-test=\"stash-field-error\"\n >\n {{ props.errorText }}\n </span>\n\n <span\n v-else-if=\"props.hintText && !props.isReadOnly\"\n class=\"stash-field-hint tw-mt-1 tw-block tw-whitespace-pre-line tw-text-xs\"\n data-test=\"stash-field-hint\"\n >\n {{ props.hintText }}\n </span>\n\n <div\n v-else-if=\"slots.hint && !props.isReadOnly\"\n class=\"stash-field-hint tw-mt-1 tw-whitespace-pre-line tw-text-xs\"\n data-test=\"stash-field-hint\"\n >\n <!-- @slot for displaying hint text below the field -->\n <slot name=\"hint\"></slot>\n </div>\n </component>\n</template>\n"],"names":["attrs","useAttrs","slots","useSlots","fieldId","computed","props","uniqueId","fieldErrorId","labelId","hasError","wrapperElement","rootAttrs","placeholder","otherAttrs"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;iBAyEQA,IAAQC,KACRC,IAAQC,KACRC,IAAUC,EAAS,MAAMC,EAAM,MAAMC,EAAS,cAAc,CAAC,GAC7DC,IAAeH,EAAS,MAAMC,EAAM,WAAWC,EAAS,oBAAoB,CAAC,GAC7EE,IAAUJ,EAAS,MAAME,EAAS,oBAAoB,CAAC,GACvDG,IAAWL,EAAS,MAAM,CAAC,CAACC,EAAM,SAAS,GAC3CK,IAAiBN,EAAS,MAAOC,EAAM,WAAW,aAAa,KAAM,GAIrEM,IAAYP,EAAS,MAAM;AAE/B,YAAM,EAAE,aAAAQ,GAAa,GAAGC,EAAA,IAAed;AAEhC,aAAAc;AAAA,IAAA,CACR;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/FilterSelect.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { defineComponent as S, computed as p, openBlock as r, createBlock as $, withCtx as u, createElementVNode as s, createElementBlock as d, withDirectives as f, vModelCheckbox as v, createVNode as _, withKeys as h, createTextVNode as b, toDisplayString as x, unref as C, createCommentVNode as K, Fragment as A, renderList as B } from "vue";
|
|
2
2
|
import { t as E } from "./locale.js";
|
|
3
|
-
import { _ as N } from "./Field.vue_vue_type_script_setup_true_lang-
|
|
3
|
+
import { _ as N } from "./Field.vue_vue_type_script_setup_true_lang-e1e4ff03.js";
|
|
4
4
|
import y from "./FilterChip.js";
|
|
5
5
|
import "lodash-es/get";
|
|
6
6
|
import "lodash-es/uniqueId";
|
package/dist/Filters.js
CHANGED
|
@@ -38,7 +38,7 @@ import "./index-79ce320f.js";
|
|
|
38
38
|
import "./Icon.vue_used_vue_type_style_index_0_lang.module-eb359559.js";
|
|
39
39
|
import "lodash-es/isNil";
|
|
40
40
|
import "./utils/i18n.js";
|
|
41
|
-
import "./Field.vue_vue_type_script_setup_true_lang-
|
|
41
|
+
import "./Field.vue_vue_type_script_setup_true_lang-e1e4ff03.js";
|
|
42
42
|
import "./Label.vue_vue_type_script_setup_true_lang-4b02087f.js";
|
|
43
43
|
import "lodash-es/isEmpty";
|
|
44
44
|
import "lodash-es/isEqual";
|
package/dist/InlineEdit.js
CHANGED
|
@@ -5,7 +5,7 @@ import "./constants.js";
|
|
|
5
5
|
import "./locale.js";
|
|
6
6
|
import "lodash-es/get";
|
|
7
7
|
import "lodash-es/isNil";
|
|
8
|
-
import "./Field.vue_vue_type_script_setup_true_lang-
|
|
8
|
+
import "./Field.vue_vue_type_script_setup_true_lang-e1e4ff03.js";
|
|
9
9
|
import "lodash-es/uniqueId";
|
|
10
10
|
import "./Label.vue_vue_type_script_setup_true_lang-4b02087f.js";
|
|
11
11
|
import "./Icon.js";
|
package/dist/Input.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineComponent as P, useSlots as U, useCssModule as G, useAttrs as L, ref as f, computed as v, watchEffect as O, onMounted as W, openBlock as m, createBlock as g, mergeProps as V, unref as o, createSlots as j, withCtx as k, createElementVNode as N, withDirectives as q, vModelDynamic as H, createElementBlock as x, normalizeClass as C, renderSlot as y, createCommentVNode as I } from "vue";
|
|
2
2
|
import $ from "lodash-es/isNil";
|
|
3
3
|
import { convertDecimal as B, sanitizeDecimal as J, decimalSeparator as _ } from "./utils/i18n.js";
|
|
4
|
-
import { _ as K } from "./Field.vue_vue_type_script_setup_true_lang-
|
|
4
|
+
import { _ as K } from "./Field.vue_vue_type_script_setup_true_lang-e1e4ff03.js";
|
|
5
5
|
import Q from "./Icon.js";
|
|
6
6
|
import { _ as R } from "./_plugin-vue_export-helper-dad06003.js";
|
|
7
7
|
import "./constants.js";
|
package/dist/InputOptions.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineComponent as B, useAttrs as S, useSlots as k, useCssModule as T, ref as d, computed as c, watchEffect as $, watch as v, openBlock as b, createBlock as E, mergeProps as m, createSlots as A, withCtx as f, createElementVNode as M, normalizeClass as O, unref as u, createVNode as h, renderSlot as z } from "vue";
|
|
2
|
-
import { _ as F } from "./Field.vue_vue_type_script_setup_true_lang-
|
|
2
|
+
import { _ as F } from "./Field.vue_vue_type_script_setup_true_lang-e1e4ff03.js";
|
|
3
3
|
import N from "./Input.js";
|
|
4
4
|
import U from "./Select.js";
|
|
5
5
|
import { _ as P } from "./_plugin-vue_export-helper-dad06003.js";
|
package/dist/ListView.js
CHANGED
|
@@ -46,7 +46,7 @@ import "./utils/formatDateTime.js";
|
|
|
46
46
|
import "./utils/normalizeDate.js";
|
|
47
47
|
import "./toTimeZone-e6e9ab75.js";
|
|
48
48
|
import "./InputOptions.js";
|
|
49
|
-
import "./Field.vue_vue_type_script_setup_true_lang-
|
|
49
|
+
import "./Field.vue_vue_type_script_setup_true_lang-e1e4ff03.js";
|
|
50
50
|
import "./Label.vue_vue_type_script_setup_true_lang-4b02087f.js";
|
|
51
51
|
import "./Select.js";
|
|
52
52
|
import "lodash-es/isEmpty";
|
package/dist/RadioGroup.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { defineComponent as $, inject as
|
|
2
|
-
import
|
|
3
|
-
import { _ as O } from "./Field.vue_vue_type_script_setup_true_lang-
|
|
1
|
+
import { defineComponent as $, inject as k, useCssModule as V, openBlock as s, createElementBlock as d, normalizeClass as _, unref as e, Fragment as B, renderList as R, createElementVNode as r, toDisplayString as h, provide as C, computed as v, createBlock as I, withCtx as M, renderSlot as T, resolveDynamicComponent as G } from "vue";
|
|
2
|
+
import E from "lodash-es/uniqueId";
|
|
3
|
+
import { _ as O } from "./Field.vue_vue_type_script_setup_true_lang-e1e4ff03.js";
|
|
4
4
|
import { R as y } from "./RadioGroup.keys-974818d6.js";
|
|
5
|
-
import { _ as
|
|
5
|
+
import { _ as x } from "./_plugin-vue_export-helper-dad06003.js";
|
|
6
6
|
import "./Label.vue_vue_type_script_setup_true_lang-4b02087f.js";
|
|
7
7
|
import "./locale.js";
|
|
8
8
|
import "lodash-es/get";
|
|
9
9
|
const W = ["id", "name", "value", "checked", "disabled"], j = ["for"], q = /* @__PURE__ */ $({
|
|
10
10
|
__name: "VariantButton",
|
|
11
11
|
setup(u) {
|
|
12
|
-
const o =
|
|
12
|
+
const o = k(y.key);
|
|
13
13
|
if (!o)
|
|
14
14
|
throw new Error("VariantButton must be used with a RadioGroup instance.");
|
|
15
|
-
const { name: t, disabled:
|
|
16
|
-
return (
|
|
15
|
+
const { name: t, disabled: m, fullWidth: f, modelValue: l, options: i, update: n } = o, p = V();
|
|
16
|
+
return (g, c) => (s(), d("div", {
|
|
17
17
|
class: _(["tw-flex", e(p).root])
|
|
18
18
|
}, [
|
|
19
|
-
(
|
|
19
|
+
(s(!0), d(B, null, R(e(i), (a) => (s(), d("div", {
|
|
20
20
|
key: `${e(t)}-${a.id}`,
|
|
21
|
-
class: _([{ "tw-w-full": e(
|
|
21
|
+
class: _([{ "tw-w-full": e(f) }])
|
|
22
22
|
}, [
|
|
23
23
|
r("input", {
|
|
24
24
|
id: `${e(t)}-${a.id}`,
|
|
@@ -26,10 +26,10 @@ const W = ["id", "name", "value", "checked", "disabled"], j = ["for"], q = /* @_
|
|
|
26
26
|
type: "radio",
|
|
27
27
|
name: e(t),
|
|
28
28
|
value: a.value,
|
|
29
|
-
checked: e(
|
|
30
|
-
disabled: e(
|
|
29
|
+
checked: e(l) === a.value,
|
|
30
|
+
disabled: e(m) || a.disabled,
|
|
31
31
|
onInput: c[0] || (c[0] = //@ts-ignore
|
|
32
|
-
(...b) => e(
|
|
32
|
+
(...b) => e(n) && e(n)(...b))
|
|
33
33
|
}, null, 40, W),
|
|
34
34
|
r("label", {
|
|
35
35
|
for: `${e(t)}-${a.id}`
|
|
@@ -41,19 +41,19 @@ const W = ["id", "name", "value", "checked", "disabled"], j = ["for"], q = /* @_
|
|
|
41
41
|
root: S
|
|
42
42
|
}, L = {
|
|
43
43
|
$style: D
|
|
44
|
-
}, N = /* @__PURE__ */
|
|
44
|
+
}, N = /* @__PURE__ */ x(q, [["__cssModules", L]]), z = ["id", "name", "value", "checked", "disabled"], A = ["for"], F = /* @__PURE__ */ $({
|
|
45
45
|
__name: "VariantChip",
|
|
46
46
|
setup(u) {
|
|
47
|
-
const o =
|
|
47
|
+
const o = k(y.key);
|
|
48
48
|
if (!o)
|
|
49
49
|
throw new Error("VariantChip must be used with a RadioGroup instance.");
|
|
50
|
-
const { name: t, disabled:
|
|
51
|
-
return (
|
|
50
|
+
const { name: t, disabled: m, fullWidth: f, modelValue: l, options: i, update: n } = o, p = V();
|
|
51
|
+
return (g, c) => (s(), d("div", {
|
|
52
52
|
class: _(["tw-my-1.5 tw-flex tw-flex-wrap", e(p).root])
|
|
53
53
|
}, [
|
|
54
|
-
(
|
|
54
|
+
(s(!0), d(B, null, R(e(i), (a) => (s(), d("div", {
|
|
55
55
|
key: `${e(t)}-${a.id}`,
|
|
56
|
-
class: _([{ "tw-w-full": e(
|
|
56
|
+
class: _([{ "tw-w-full": e(f) }])
|
|
57
57
|
}, [
|
|
58
58
|
r("input", {
|
|
59
59
|
id: `${e(t)}-${a.id}`,
|
|
@@ -61,10 +61,10 @@ const W = ["id", "name", "value", "checked", "disabled"], j = ["for"], q = /* @_
|
|
|
61
61
|
type: "radio",
|
|
62
62
|
name: e(t),
|
|
63
63
|
value: a.value,
|
|
64
|
-
checked: e(
|
|
65
|
-
disabled: e(
|
|
64
|
+
checked: e(l) === a.value,
|
|
65
|
+
disabled: e(m) || a.disabled,
|
|
66
66
|
onInput: c[0] || (c[0] = //@ts-ignore
|
|
67
|
-
(...b) => e(
|
|
67
|
+
(...b) => e(n) && e(n)(...b))
|
|
68
68
|
}, null, 40, z),
|
|
69
69
|
r("label", {
|
|
70
70
|
for: `${e(t)}-${a.id}`
|
|
@@ -76,29 +76,29 @@ const W = ["id", "name", "value", "checked", "disabled"], j = ["for"], q = /* @_
|
|
|
76
76
|
root: J
|
|
77
77
|
}, U = {
|
|
78
78
|
$style: P
|
|
79
|
-
}, H = /* @__PURE__ */
|
|
79
|
+
}, H = /* @__PURE__ */ x(F, [["__cssModules", U]]), K = ["id", "name", "value", "checked", "disabled"], Q = ["for"], X = /* @__PURE__ */ $({
|
|
80
80
|
__name: "VariantRadio",
|
|
81
81
|
setup(u) {
|
|
82
|
-
const o =
|
|
82
|
+
const o = k(y.key);
|
|
83
83
|
if (!o)
|
|
84
84
|
throw new Error("VariantRadio must be used with a RadioGroup instance.");
|
|
85
|
-
const { name: t, disabled:
|
|
86
|
-
return (
|
|
85
|
+
const { name: t, disabled: m, fullWidth: f, modelValue: l, options: i, update: n } = o, p = V();
|
|
86
|
+
return (g, c) => (s(), d("div", {
|
|
87
87
|
class: _(["tw-flex tw-flex-wrap", e(p).root])
|
|
88
88
|
}, [
|
|
89
|
-
(
|
|
89
|
+
(s(!0), d(B, null, R(e(i), (a) => (s(), d("div", {
|
|
90
90
|
key: `${e(t)}-${a.id}`,
|
|
91
|
-
class: _([{ "tw-w-full": e(
|
|
91
|
+
class: _([{ "tw-w-full": e(f) }])
|
|
92
92
|
}, [
|
|
93
93
|
r("input", {
|
|
94
94
|
id: `${e(t)}-${a.id}`,
|
|
95
95
|
type: "radio",
|
|
96
96
|
name: e(t),
|
|
97
97
|
value: a.value,
|
|
98
|
-
checked: e(
|
|
99
|
-
disabled: e(
|
|
98
|
+
checked: e(l) === a.value,
|
|
99
|
+
disabled: e(m) || a.disabled,
|
|
100
100
|
onInput: c[0] || (c[0] = //@ts-ignore
|
|
101
|
-
(...b) => e(
|
|
101
|
+
(...b) => e(n) && e(n)(...b))
|
|
102
102
|
}, null, 40, K),
|
|
103
103
|
r("label", {
|
|
104
104
|
for: `${e(t)}-${a.id}`
|
|
@@ -110,27 +110,27 @@ const W = ["id", "name", "value", "checked", "disabled"], j = ["for"], q = /* @_
|
|
|
110
110
|
root: Y
|
|
111
111
|
}, ee = {
|
|
112
112
|
$style: Z
|
|
113
|
-
}, te = /* @__PURE__ */
|
|
113
|
+
}, te = /* @__PURE__ */ x(X, [["__cssModules", ee]]), ae = ["for"], se = ["id", "name", "value", "checked", "disabled"], le = { class: "tw-m-0 tw-text-ice-900" }, oe = { class: "tw-m-0 tw-text-ice-700" }, re = /* @__PURE__ */ $({
|
|
114
114
|
__name: "VariantTile",
|
|
115
115
|
setup(u) {
|
|
116
|
-
const o =
|
|
116
|
+
const o = k(y.key);
|
|
117
117
|
if (!o)
|
|
118
118
|
throw new Error("VariantTile must be used with a RadioGroup instance.");
|
|
119
|
-
const { name: t, disabled:
|
|
120
|
-
return (
|
|
119
|
+
const { name: t, disabled: m, fullWidth: f, modelValue: l, options: i, update: n } = o, p = V();
|
|
120
|
+
return (g, c) => (s(), d("div", {
|
|
121
121
|
class: _(["tw-flex tw-flex-wrap", e(p).root])
|
|
122
122
|
}, [
|
|
123
|
-
(
|
|
123
|
+
(s(!0), d(B, null, R(e(i), (a) => (s(), d("label", {
|
|
124
124
|
key: `${e(t)}-${a.id}`,
|
|
125
|
-
class: _([e(p)["tile-container"], { "tw-w-full": e(
|
|
125
|
+
class: _([e(p)["tile-container"], { "tw-w-full": e(f) }]),
|
|
126
126
|
for: `${e(t)}-${a.id}`
|
|
127
127
|
}, [
|
|
128
128
|
r("div", {
|
|
129
129
|
class: _(["tw-flex tw-border", [
|
|
130
130
|
e(p)["tile-header"],
|
|
131
131
|
{
|
|
132
|
-
"tw-border-blue-500 tw-bg-blue-100 tw-text-ice-900": e(
|
|
133
|
-
"tw-border-ice-500 tw-bg-ice-100 tw-text-ice-700": e(
|
|
132
|
+
"tw-border-blue-500 tw-bg-blue-100 tw-text-ice-900": e(l) === a.value,
|
|
133
|
+
"tw-border-ice-500 tw-bg-ice-100 tw-text-ice-700": e(l) !== a.value
|
|
134
134
|
}
|
|
135
135
|
]])
|
|
136
136
|
}, [
|
|
@@ -140,10 +140,10 @@ const W = ["id", "name", "value", "checked", "disabled"], j = ["for"], q = /* @_
|
|
|
140
140
|
type: "radio",
|
|
141
141
|
name: e(t),
|
|
142
142
|
value: a.value,
|
|
143
|
-
checked: e(
|
|
144
|
-
disabled: e(
|
|
143
|
+
checked: e(l) === a.value,
|
|
144
|
+
disabled: e(m) || a.disabled,
|
|
145
145
|
onInput: c[0] || (c[0] = //@ts-ignore
|
|
146
|
-
(...b) => e(
|
|
146
|
+
(...b) => e(n) && e(n)(...b))
|
|
147
147
|
}, null, 40, se),
|
|
148
148
|
r("div", null, [
|
|
149
149
|
r("span", null, h(a.text), 1)
|
|
@@ -153,8 +153,8 @@ const W = ["id", "name", "value", "checked", "disabled"], j = ["for"], q = /* @_
|
|
|
153
153
|
class: _(["tw-border-x tw-border-b", [
|
|
154
154
|
e(p)["tile-body"],
|
|
155
155
|
{
|
|
156
|
-
"tw-border-ice-500": e(
|
|
157
|
-
"tw-border-blue-500": e(
|
|
156
|
+
"tw-border-ice-500": e(l) !== a.value,
|
|
157
|
+
"tw-border-blue-500": e(l) === a.value
|
|
158
158
|
}
|
|
159
159
|
]])
|
|
160
160
|
}, [
|
|
@@ -164,16 +164,16 @@ const W = ["id", "name", "value", "checked", "disabled"], j = ["for"], q = /* @_
|
|
|
164
164
|
], 10, ae))), 128))
|
|
165
165
|
], 2));
|
|
166
166
|
}
|
|
167
|
-
}),
|
|
168
|
-
root:
|
|
167
|
+
}), de = "_root_1sppn_2", ie = {
|
|
168
|
+
root: de,
|
|
169
169
|
"tile-container": "_tile-container_1sppn_23",
|
|
170
170
|
"tile-header": "_tile-header_1sppn_30",
|
|
171
171
|
"tile-body": "_tile-body_1sppn_31"
|
|
172
172
|
}, ne = {
|
|
173
|
-
$style:
|
|
174
|
-
}, ue = /* @__PURE__ */
|
|
175
|
-
var
|
|
176
|
-
const
|
|
173
|
+
$style: ie
|
|
174
|
+
}, ue = /* @__PURE__ */ x(re, [["__cssModules", ne]]);
|
|
175
|
+
var w = /* @__PURE__ */ ((u) => (u.Radio = "radio", u.Button = "button", u.Chip = "chip", u.Tile = "tile", u))(w || {});
|
|
176
|
+
const ce = /* @__PURE__ */ $({
|
|
177
177
|
__name: "RadioGroup",
|
|
178
178
|
props: {
|
|
179
179
|
name: { default: void 0 },
|
|
@@ -192,40 +192,34 @@ const he = /* @__PURE__ */ $({
|
|
|
192
192
|
},
|
|
193
193
|
emits: ["update:modelValue"],
|
|
194
194
|
setup(u, { emit: o }) {
|
|
195
|
-
const t = u,
|
|
196
|
-
[
|
|
197
|
-
[
|
|
198
|
-
[
|
|
199
|
-
[
|
|
195
|
+
const t = u, m = {
|
|
196
|
+
[w.Button]: N,
|
|
197
|
+
[w.Chip]: H,
|
|
198
|
+
[w.Radio]: te,
|
|
199
|
+
[w.Tile]: ue
|
|
200
200
|
};
|
|
201
|
-
function
|
|
201
|
+
function f(i) {
|
|
202
202
|
o("update:modelValue", i.target.value);
|
|
203
203
|
}
|
|
204
|
-
const
|
|
205
|
-
return
|
|
204
|
+
const l = E("radio-group-field-error-");
|
|
205
|
+
return C(y.key, {
|
|
206
206
|
name: v(() => t.name),
|
|
207
207
|
disabled: v(() => t.disabled),
|
|
208
208
|
fullWidth: v(() => t.fullWidth),
|
|
209
209
|
modelValue: v(() => t.modelValue),
|
|
210
210
|
options: v(() => t.options),
|
|
211
211
|
variant: v(() => t.variant),
|
|
212
|
-
update:
|
|
213
|
-
}), (i,
|
|
214
|
-
class:
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
"tw-flex-wrap": !t.options && (t.variant === e(m).Chip || t.variant === e(m).Radio),
|
|
218
|
-
"tw-gap-x-1.5 tw-gap-y-3": !t.options && t.variant === e(m).Chip,
|
|
219
|
-
"tw-gap-6": !t.options && (t.variant === e(m).Radio || t.variant === e(m).Tile)
|
|
220
|
-
}
|
|
221
|
-
]),
|
|
222
|
-
"aria-errormessage": e(s),
|
|
212
|
+
update: f
|
|
213
|
+
}), (i, n) => (s(), I(O, {
|
|
214
|
+
class: "stash-radio-group",
|
|
215
|
+
"data-test": "stash-radio-group",
|
|
216
|
+
"aria-errormessage": e(l),
|
|
223
217
|
"aria-invalid": !!t.errorText,
|
|
224
218
|
role: "radiogroup",
|
|
225
219
|
fieldset: "",
|
|
226
220
|
label: t.label,
|
|
227
221
|
"add-bottom-space": t.addBottomSpace,
|
|
228
|
-
"error-id": e(
|
|
222
|
+
"error-id": e(l),
|
|
229
223
|
"error-text": t.errorText,
|
|
230
224
|
"hint-text": t.hintText,
|
|
231
225
|
"show-optional-in-label": t.showOptionalInLabel,
|
|
@@ -234,16 +228,26 @@ const he = /* @__PURE__ */ $({
|
|
|
234
228
|
}, {
|
|
235
229
|
default: M(() => [
|
|
236
230
|
t.options ? T(i.$slots, "default", { key: 0 }, () => [
|
|
237
|
-
(
|
|
238
|
-
]) :
|
|
231
|
+
(s(), I(G(m[t.variant])))
|
|
232
|
+
], !0) : (s(), d("div", {
|
|
233
|
+
key: 1,
|
|
234
|
+
class: _(["tw-flex", {
|
|
235
|
+
"tw-flex-wrap": t.variant !== e(w).Button,
|
|
236
|
+
"tw-gap-x-1.5 tw-gap-y-3": t.variant === e(w).Chip,
|
|
237
|
+
"tw-gap-6": t.variant === e(w).Radio || t.variant === e(w).Tile
|
|
238
|
+
}])
|
|
239
|
+
}, [
|
|
240
|
+
T(i.$slots, "default", {}, void 0, !0)
|
|
241
|
+
], 2))
|
|
239
242
|
]),
|
|
240
243
|
_: 3
|
|
241
|
-
}, 8, ["
|
|
244
|
+
}, 8, ["aria-errormessage", "aria-invalid", "label", "add-bottom-space", "error-id", "error-text", "hint-text", "show-optional-in-label", "is-required", "is-read-only"]));
|
|
242
245
|
}
|
|
243
246
|
});
|
|
247
|
+
const $e = /* @__PURE__ */ x(ce, [["__scopeId", "data-v-a6627a68"]]);
|
|
244
248
|
export {
|
|
245
249
|
y as RADIO_GROUP_INJECTION,
|
|
246
|
-
|
|
247
|
-
|
|
250
|
+
w as RadioGroupVariant,
|
|
251
|
+
$e as default
|
|
248
252
|
};
|
|
249
253
|
//# 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: 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","<script lang=\"ts\">\n import { RadioGroupOption, RadioGroupVariant, RadioGroupVariants } from './RadioGroup.types';\n\n export * from './RadioGroup.keys';\n export * from './RadioGroup.types';\n\n export interface RadioGroupProps {\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 entire group should be disabled\n */\n disabled?: boolean;\n\n /**\n * Whether the group should expand to the parent's width\n */\n fullWidth?: boolean;\n\n /**\n * Adds spacing under the field that is consistent whether hint/error text is displayed.\n */\n addBottomSpace?: boolean;\n\n /**\n * Error text to display. Replaces `hintText` (if provided) & adds error styling.\n */\n errorText?: string;\n\n /**\n * Displays text below the input; hidden when the isReadOnly prop is truthy.\n */\n hintText?: string;\n\n /**\n * Whether it's a readonly field.\n */\n isReadOnly?: boolean;\n\n /**\n * Whether the field is required.\n */\n isRequired?: boolean;\n\n /**\n * Label to render above the input.\n */\n label?: string;\n\n /**\n * Show \"(optional)\" to the right of the label text\n */\n showOptionalInLabel?: boolean;\n }\n</script>\n\n<script setup lang=\"ts\">\n import uniqueId from 'lodash-es/uniqueId';\n import { computed, provide } from 'vue';\n\n import Field from '../Field/Field.vue';\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 disabled: false,\n fullWidth: false,\n errorText: undefined,\n hintText: undefined,\n label: undefined,\n modelValue: undefined,\n name: undefined,\n options: undefined,\n });\n\n const emit =\n 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 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.disabled),\n fullWidth: computed(() => props.fullWidth),\n modelValue: computed(() => props.modelValue),\n options: computed(() => props.options),\n variant: computed(() => props.variant),\n update,\n });\n</script>\n\n<template>\n <Field\n :class=\"[\n {\n 'tw-flex': !props.options,\n 'tw-flex-wrap':\n !props.options && (props.variant === RadioGroupVariant.Chip || props.variant === RadioGroupVariant.Radio),\n 'tw-gap-x-1.5 tw-gap-y-3': !props.options && props.variant === RadioGroupVariant.Chip,\n 'tw-gap-6':\n !props.options && (props.variant === RadioGroupVariant.Radio || props.variant === RadioGroupVariant.Tile),\n },\n ]\"\n :aria-errormessage=\"errorId\"\n :aria-invalid=\"!!props.errorText\"\n role=\"radiogroup\"\n fieldset\n :label=\"props.label\"\n :add-bottom-space=\"props.addBottomSpace\"\n :error-id=\"errorId\"\n :error-text=\"props.errorText\"\n :hint-text=\"props.hintText\"\n :show-optional-in-label=\"props.showOptionalInLabel\"\n :is-required=\"props.isRequired\"\n :is-read-only=\"props.isReadOnly\"\n >\n <slot v-if=\"props.options\">\n <component :is=\"variantComponentsMap[props.variant]\" />\n </slot>\n <slot v-else></slot>\n </Field>\n</template>\n"],"names":["radioGroupInjection","inject","RADIO_GROUP_INJECTION","name","disabled","fullWidth","modelValue","options","update","classes","useCssModule","RadioGroupVariant","variantComponentsMap","VariantButton","VariantChip","VariantRadio","VariantTile","e","emit","errorId","uniqueId","provide","computed","props"],"mappings":";;;;;;;;;;;AAKQ,UAAAA,IAAsBC,EAAOC,EAAsB,GAAG;AAE5D,QAAI,CAACF;AACG,YAAA,IAAI,MAAM,wDAAwD;AAG1E,UAAM,EAAE,MAAAG,GAAM,UAAAC,GAAU,WAAAC,GAAW,YAAAC,GAAY,SAAAC,GAAS,QAAAC,EAAW,IAAAR,GAC7DS,IAAUC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACPV,UAAAV,IAAsBC,EAAOC,EAAsB,GAAG;AAE5D,QAAI,CAACF;AACG,YAAA,IAAI,MAAM,sDAAsD;AAGxE,UAAM,EAAE,MAAAG,GAAM,UAAAC,GAAU,WAAAC,GAAW,YAAAC,GAAY,SAAAC,GAAS,QAAAC,EAAW,IAAAR,GAC7DS,IAAUC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACPV,UAAAV,IAAsBC,EAAOC,EAAsB,GAAG;AAE5D,QAAI,CAACF;AACG,YAAA,IAAI,MAAM,uDAAuD;AAGzE,UAAM,EAAE,MAAAG,GAAM,UAAAC,GAAU,WAAAC,GAAW,YAAAC,GAAY,SAAAC,GAAS,QAAAC,EAAW,IAAAR,GAC7DS,IAAUC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACPV,UAAAV,IAAsBC,EAAOC,EAAsB,GAAG;AAE5D,QAAI,CAACF;AACG,YAAA,IAAI,MAAM,sDAAsD;AAGxE,UAAM,EAAE,MAAAG,GAAM,UAAAC,GAAU,WAAAC,GAAW,YAAAC,GAAY,SAAAC,GAAS,QAAAC,EAAW,IAAAR,GAC7DS,IAAUC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACVN,IAAAC,sBAAAA,OACVA,EAAA,QAAQ,SACRA,EAAA,SAAS,UACTA,EAAA,OAAO,QACPA,EAAA,OAAO,QAJGA,IAAAA,KAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;iBCoFJC,IAAuB;AAAA,MAC3B,CAACD,EAAkB,MAAM,GAAGE;AAAA,MAC5B,CAACF,EAAkB,IAAI,GAAGG;AAAA,MAC1B,CAACH,EAAkB,KAAK,GAAGI;AAAA,MAC3B,CAACJ,EAAkB,IAAI,GAAGK;AAAA,IAAA;AAuB5B,aAASR,EAAOS,GAAU;AACnB,MAAAC,EAAA,qBAAsBD,EAAE,OAA4B,KAAK;AAAA,IAChE;AAEM,UAAAE,IAAUC,EAAS,0BAA0B;AAEnD,WAAAC,EAAQnB,EAAsB,KAAK;AAAA,MACjC,MAAMoB,EAAS,MAAMC,EAAM,IAAI;AAAA,MAC/B,UAAUD,EAAS,MAAMC,EAAM,QAAQ;AAAA,MACvC,WAAWD,EAAS,MAAMC,EAAM,SAAS;AAAA,MACzC,YAAYD,EAAS,MAAMC,EAAM,UAAU;AAAA,MAC3C,SAASD,EAAS,MAAMC,EAAM,OAAO;AAAA,MACrC,SAASD,EAAS,MAAMC,EAAM,OAAO;AAAA,MACrC,QAAAf;AAAA,IAAA,CACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
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: 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","<script lang=\"ts\">\n import { RadioGroupOption, RadioGroupVariant, RadioGroupVariants } from './RadioGroup.types';\n\n export * from './RadioGroup.keys';\n export * from './RadioGroup.types';\n\n export interface RadioGroupProps {\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 entire group should be disabled\n */\n disabled?: boolean;\n\n /**\n * Whether the group should expand to the parent's width\n */\n fullWidth?: boolean;\n\n /**\n * Adds spacing under the field that is consistent whether hint/error text is displayed.\n */\n addBottomSpace?: boolean;\n\n /**\n * Error text to display. Replaces `hintText` (if provided) & adds error styling.\n */\n errorText?: string;\n\n /**\n * Displays text below the input; hidden when the isReadOnly prop is truthy.\n */\n hintText?: string;\n\n /**\n * Whether it's a readonly field.\n */\n isReadOnly?: boolean;\n\n /**\n * Whether the field is required.\n */\n isRequired?: boolean;\n\n /**\n * Label to render above the input.\n */\n label?: string;\n\n /**\n * Show \"(optional)\" to the right of the label text\n */\n showOptionalInLabel?: boolean;\n }\n</script>\n\n<script setup lang=\"ts\">\n import uniqueId from 'lodash-es/uniqueId';\n import { computed, provide } from 'vue';\n\n import Field from '../Field/Field.vue';\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 disabled: false,\n fullWidth: false,\n errorText: undefined,\n hintText: undefined,\n label: undefined,\n modelValue: undefined,\n name: undefined,\n options: undefined,\n });\n\n const emit =\n 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 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.disabled),\n fullWidth: computed(() => props.fullWidth),\n modelValue: computed(() => props.modelValue),\n options: computed(() => props.options),\n variant: computed(() => props.variant),\n update,\n });\n</script>\n\n<template>\n <Field\n class=\"stash-radio-group\"\n data-test=\"stash-radio-group\"\n :aria-errormessage=\"errorId\"\n :aria-invalid=\"!!props.errorText\"\n role=\"radiogroup\"\n fieldset\n :label=\"props.label\"\n :add-bottom-space=\"props.addBottomSpace\"\n :error-id=\"errorId\"\n :error-text=\"props.errorText\"\n :hint-text=\"props.hintText\"\n :show-optional-in-label=\"props.showOptionalInLabel\"\n :is-required=\"props.isRequired\"\n :is-read-only=\"props.isReadOnly\"\n >\n <slot v-if=\"props.options\">\n <component :is=\"variantComponentsMap[props.variant]\" />\n </slot>\n <div\n v-else\n class=\"tw-flex\"\n :class=\"{\n 'tw-flex-wrap': props.variant !== RadioGroupVariant.Button,\n 'tw-gap-x-1.5 tw-gap-y-3': props.variant === RadioGroupVariant.Chip,\n 'tw-gap-6': props.variant === RadioGroupVariant.Radio || props.variant === RadioGroupVariant.Tile,\n }\"\n >\n <slot></slot>\n </div>\n </Field>\n</template>\n\n<style scoped>\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: 6px;\n }\n</style>\n"],"names":["radioGroupInjection","inject","RADIO_GROUP_INJECTION","name","disabled","fullWidth","modelValue","options","update","classes","useCssModule","RadioGroupVariant","variantComponentsMap","VariantButton","VariantChip","VariantRadio","VariantTile","e","emit","errorId","uniqueId","provide","computed","props"],"mappings":";;;;;;;;;;;AAKQ,UAAAA,IAAsBC,EAAOC,EAAsB,GAAG;AAE5D,QAAI,CAACF;AACG,YAAA,IAAI,MAAM,wDAAwD;AAG1E,UAAM,EAAE,MAAAG,GAAM,UAAAC,GAAU,WAAAC,GAAW,YAAAC,GAAY,SAAAC,GAAS,QAAAC,EAAW,IAAAR,GAC7DS,IAAUC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACPV,UAAAV,IAAsBC,EAAOC,EAAsB,GAAG;AAE5D,QAAI,CAACF;AACG,YAAA,IAAI,MAAM,sDAAsD;AAGxE,UAAM,EAAE,MAAAG,GAAM,UAAAC,GAAU,WAAAC,GAAW,YAAAC,GAAY,SAAAC,GAAS,QAAAC,EAAW,IAAAR,GAC7DS,IAAUC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACPV,UAAAV,IAAsBC,EAAOC,EAAsB,GAAG;AAE5D,QAAI,CAACF;AACG,YAAA,IAAI,MAAM,uDAAuD;AAGzE,UAAM,EAAE,MAAAG,GAAM,UAAAC,GAAU,WAAAC,GAAW,YAAAC,GAAY,SAAAC,GAAS,QAAAC,EAAW,IAAAR,GAC7DS,IAAUC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACPV,UAAAV,IAAsBC,EAAOC,EAAsB,GAAG;AAE5D,QAAI,CAACF;AACG,YAAA,IAAI,MAAM,sDAAsD;AAGxE,UAAM,EAAE,MAAAG,GAAM,UAAAC,GAAU,WAAAC,GAAW,YAAAC,GAAY,SAAAC,GAAS,QAAAC,EAAW,IAAAR,GAC7DS,IAAUC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACVN,IAAAC,sBAAAA,OACVA,EAAA,QAAQ,SACRA,EAAA,SAAS,UACTA,EAAA,OAAO,QACPA,EAAA,OAAO,QAJGA,IAAAA,KAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;iBCoFJC,IAAuB;AAAA,MAC3B,CAACD,EAAkB,MAAM,GAAGE;AAAA,MAC5B,CAACF,EAAkB,IAAI,GAAGG;AAAA,MAC1B,CAACH,EAAkB,KAAK,GAAGI;AAAA,MAC3B,CAACJ,EAAkB,IAAI,GAAGK;AAAA,IAAA;AAuB5B,aAASR,EAAOS,GAAU;AACnB,MAAAC,EAAA,qBAAsBD,EAAE,OAA4B,KAAK;AAAA,IAChE;AAEM,UAAAE,IAAUC,EAAS,0BAA0B;AAEnD,WAAAC,EAAQnB,EAAsB,KAAK;AAAA,MACjC,MAAMoB,EAAS,MAAMC,EAAM,IAAI;AAAA,MAC/B,UAAUD,EAAS,MAAMC,EAAM,QAAQ;AAAA,MACvC,WAAWD,EAAS,MAAMC,EAAM,SAAS;AAAA,MACzC,YAAYD,EAAS,MAAMC,EAAM,UAAU;AAAA,MAC3C,SAASD,EAAS,MAAMC,EAAM,OAAO;AAAA,MACrC,SAASD,EAAS,MAAMC,EAAM,OAAO;AAAA,MACrC,QAAAf;AAAA,IAAA,CACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|