@leaflink/stash 51.1.1 → 51.3.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/dist/CurrencyInput.js +1 -0
- package/dist/CurrencyInput.js.map +1 -1
- package/dist/CurrencyInput.vue.d.ts +4 -0
- package/dist/DataViewFilters.js +1 -1
- package/dist/EmptyState.js +22 -21
- package/dist/EmptyState.js.map +1 -1
- package/dist/EmptyState.vue.d.ts +7 -0
- package/dist/Field.js +1 -1
- package/dist/Field.vue.d.ts +7 -0
- package/dist/{Field.vue_vue_type_script_setup_true_lang-DRaKs9Lm.js → Field.vue_vue_type_script_setup_true_lang-DI6z3AE9.js} +21 -19
- package/dist/Field.vue_vue_type_script_setup_true_lang-DI6z3AE9.js.map +1 -0
- package/dist/FilterSelect.js +16 -15
- package/dist/FilterSelect.js.map +1 -1
- package/dist/FilterSelect.vue.d.ts +4 -0
- package/dist/Filters.vue.d.ts +27 -0
- package/dist/Input.js +16 -15
- package/dist/Input.js.map +1 -1
- package/dist/Input.vue.d.ts +4 -0
- package/dist/InputOptions.js +20 -19
- package/dist/InputOptions.js.map +1 -1
- package/dist/InputOptions.vue.d.ts +4 -0
- package/dist/Label.js +1 -1
- package/dist/Label.vue.d.ts +7 -0
- package/dist/{Label.vue_vue_type_script_setup_true_lang-DPnNUfc6.js → Label.vue_vue_type_script_setup_true_lang-CNquF3AP.js} +13 -11
- package/dist/Label.vue_vue_type_script_setup_true_lang-CNquF3AP.js.map +1 -0
- package/dist/ListView.vue.d.ts +66 -0
- package/dist/RadioGroup.js +48 -47
- package/dist/RadioGroup.js.map +1 -1
- package/dist/RadioGroup.vue.d.ts +4 -0
- package/dist/Select.js +2 -1
- package/dist/Select.js.map +1 -1
- package/dist/Select.vue.d.ts +4 -0
- package/dist/TextEditor.js +2 -1
- package/dist/TextEditor.js.map +1 -1
- package/dist/TextEditor.vue.d.ts +4 -0
- package/dist/Textarea.js +24 -23
- package/dist/Textarea.js.map +1 -1
- package/dist/Textarea.vue.d.ts +4 -0
- package/package.json +1 -1
- package/dist/Field.vue_vue_type_script_setup_true_lang-DRaKs9Lm.js.map +0 -1
- package/dist/Label.vue_vue_type_script_setup_true_lang-DPnNUfc6.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Label.vue_vue_type_script_setup_true_lang-CNquF3AP.js","sources":["../src/components/Label/Label.vue"],"sourcesContent":["<script setup lang=\"ts\">\n import { computed } from 'vue';\n\n import { t } from '../../locale';\n\n export interface LabelProps {\n /**\n * The `id` of the input element that this label is associated with.\n */\n for?: string;\n\n /**\n * Indicates whether the label should be styled as an error.\n */\n hasError?: boolean;\n\n /**\n * Indicates whether the input element that this label is associated with is required.\n */\n isRequired?: boolean;\n\n /**\n * Indicates whether the label should show that the input is optional.\n */\n showOptional?: boolean;\n\n /**\n * Indicates whether the wrapper element to be rendered should be a label or a legend.\n */\n legend?: boolean;\n\n /**\n * Indicates whether the label is disabled.\n */\n disabled?: boolean;\n\n /**\n * Indicates whether the label should be visually hidden (screen reader only).\n */\n isSrOnly?: boolean;\n }\n\n const props = withDefaults(defineProps<LabelProps>(), {\n for: undefined,\n hasError: false,\n isRequired: false,\n showOptional: false,\n legend: false,\n isDisabled: false,\n isSrOnly: false,\n });\n\n const is = computed(() => {\n return props.legend ? 'legend' : 'label';\n });\n</script>\n\n<template>\n <component\n :is=\"is\"\n class=\"stash-label tw-block tw-truncate tw-text-sm tw-font-medium tw-leading-6\"\n :class=\"{\n 'tw-animate-shake': props.hasError,\n 'stash-label--disabled tw-text-ice-700': props.disabled,\n 'tw-text-ice-900': !props.disabled,\n 'tw-sr-only': props.isSrOnly,\n }\"\n :for=\"props.for\"\n data-test=\"stash-label\"\n >\n <!-- @slot The label text -->\n <slot></slot>\n <span v-if=\"props.isRequired\" class=\"tw-font-semibold tw-text-red-500\" title=\"Required\" aria-label=\"required\">\n *\n </span>\n <span v-else-if=\"props.showOptional\" class=\"tw-text-ice-700\"> ({{ t('ll.optional') }})</span>\n </component>\n</template>\n"],"names":["props","__props","is","computed"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA0CE,UAAMA,IAAQC,GAURC,IAAKC,EAAS,MACXH,EAAM,SAAS,WAAW,OAClC;;;;;;;;;;;;;;;;;;;"}
|
package/dist/ListView.vue.d.ts
CHANGED
|
@@ -1798,6 +1798,9 @@ type: PropType<boolean>;
|
|
|
1798
1798
|
showOptionalInLabel: {
|
|
1799
1799
|
type: PropType<boolean>;
|
|
1800
1800
|
};
|
|
1801
|
+
isLabelSrOnly: {
|
|
1802
|
+
type: PropType<boolean>;
|
|
1803
|
+
};
|
|
1801
1804
|
placeholder: {
|
|
1802
1805
|
type: PropType<string>;
|
|
1803
1806
|
default: undefined;
|
|
@@ -1880,6 +1883,9 @@ type: PropType<boolean>;
|
|
|
1880
1883
|
showOptionalInLabel: {
|
|
1881
1884
|
type: PropType<boolean>;
|
|
1882
1885
|
};
|
|
1886
|
+
isLabelSrOnly: {
|
|
1887
|
+
type: PropType<boolean>;
|
|
1888
|
+
};
|
|
1883
1889
|
placeholder: {
|
|
1884
1890
|
type: PropType<string>;
|
|
1885
1891
|
default: undefined;
|
|
@@ -1954,6 +1960,9 @@ type: PropType<boolean>;
|
|
|
1954
1960
|
showOptionalInLabel: {
|
|
1955
1961
|
type: PropType<boolean>;
|
|
1956
1962
|
};
|
|
1963
|
+
isLabelSrOnly: {
|
|
1964
|
+
type: PropType<boolean>;
|
|
1965
|
+
};
|
|
1957
1966
|
placeholder: {
|
|
1958
1967
|
type: PropType<string>;
|
|
1959
1968
|
default: undefined;
|
|
@@ -2041,6 +2050,9 @@ type: PropType<boolean>;
|
|
|
2041
2050
|
showOptionalInLabel: {
|
|
2042
2051
|
type: PropType<boolean>;
|
|
2043
2052
|
};
|
|
2053
|
+
isLabelSrOnly: {
|
|
2054
|
+
type: PropType<boolean>;
|
|
2055
|
+
};
|
|
2044
2056
|
placeholder: {
|
|
2045
2057
|
type: PropType<string>;
|
|
2046
2058
|
default: undefined;
|
|
@@ -2156,6 +2168,9 @@ type: PropType<boolean>;
|
|
|
2156
2168
|
showOptionalInLabel: {
|
|
2157
2169
|
type: PropType<boolean>;
|
|
2158
2170
|
};
|
|
2171
|
+
isLabelSrOnly: {
|
|
2172
|
+
type: PropType<boolean>;
|
|
2173
|
+
};
|
|
2159
2174
|
placeholder: {
|
|
2160
2175
|
type: PropType<string>;
|
|
2161
2176
|
default: undefined;
|
|
@@ -2255,6 +2270,9 @@ type: PropType<boolean>;
|
|
|
2255
2270
|
showOptionalInLabel: {
|
|
2256
2271
|
type: PropType<boolean>;
|
|
2257
2272
|
};
|
|
2273
|
+
isLabelSrOnly: {
|
|
2274
|
+
type: PropType<boolean>;
|
|
2275
|
+
};
|
|
2258
2276
|
placeholder: {
|
|
2259
2277
|
type: PropType<string>;
|
|
2260
2278
|
default: undefined;
|
|
@@ -2446,6 +2464,9 @@ type: PropType<boolean>;
|
|
|
2446
2464
|
showOptionalInLabel: {
|
|
2447
2465
|
type: PropType<boolean>;
|
|
2448
2466
|
};
|
|
2467
|
+
isLabelSrOnly: {
|
|
2468
|
+
type: PropType<boolean>;
|
|
2469
|
+
};
|
|
2449
2470
|
placeholder: {
|
|
2450
2471
|
type: PropType<string>;
|
|
2451
2472
|
default: string;
|
|
@@ -2655,6 +2676,9 @@ type: PropType<boolean>;
|
|
|
2655
2676
|
showOptionalInLabel: {
|
|
2656
2677
|
type: PropType<boolean>;
|
|
2657
2678
|
};
|
|
2679
|
+
isLabelSrOnly: {
|
|
2680
|
+
type: PropType<boolean>;
|
|
2681
|
+
};
|
|
2658
2682
|
placeholder: {
|
|
2659
2683
|
type: PropType<string>;
|
|
2660
2684
|
default: string;
|
|
@@ -2854,6 +2878,9 @@ type: PropType<boolean>;
|
|
|
2854
2878
|
showOptionalInLabel: {
|
|
2855
2879
|
type: PropType<boolean>;
|
|
2856
2880
|
};
|
|
2881
|
+
isLabelSrOnly: {
|
|
2882
|
+
type: PropType<boolean>;
|
|
2883
|
+
};
|
|
2857
2884
|
placeholder: {
|
|
2858
2885
|
type: PropType<string>;
|
|
2859
2886
|
default: string;
|
|
@@ -3520,6 +3547,10 @@ footnote: {
|
|
|
3520
3547
|
type: PropType<string>;
|
|
3521
3548
|
default: string;
|
|
3522
3549
|
};
|
|
3550
|
+
vignetteSize: {
|
|
3551
|
+
type: PropType<number>;
|
|
3552
|
+
default: number;
|
|
3553
|
+
};
|
|
3523
3554
|
}>> & Readonly<{}>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, PublicProps, {
|
|
3524
3555
|
title: string;
|
|
3525
3556
|
image: {
|
|
@@ -3530,6 +3561,7 @@ text: string;
|
|
|
3530
3561
|
subtitle: string;
|
|
3531
3562
|
vignette: "map" | "search" | "calendar" | "dashboard" | "edit" | "megaphone" | "truck" | "warehouse" | "payments" | "light-bulb" | "messages" | "pie-chart" | "api" | "bank" | "basket" | "brand-menu" | "deals" | "document-search" | "empty-tray" | "graph" | "integrations" | "money-bank" | "notifications" | "orders-empty" | "product-cards" | "product-display" | "search-storefront" | "store" | "todo" | "users" | "warehouse-delivery";
|
|
3532
3563
|
footnote: string;
|
|
3564
|
+
vignetteSize: number;
|
|
3533
3565
|
}, true, {}, {}, GlobalComponents, GlobalDirectives, string, {}, any, ComponentProvideOptions, {
|
|
3534
3566
|
P: {};
|
|
3535
3567
|
B: {};
|
|
@@ -3568,6 +3600,10 @@ footnote: {
|
|
|
3568
3600
|
type: PropType<string>;
|
|
3569
3601
|
default: string;
|
|
3570
3602
|
};
|
|
3603
|
+
vignetteSize: {
|
|
3604
|
+
type: PropType<number>;
|
|
3605
|
+
default: number;
|
|
3606
|
+
};
|
|
3571
3607
|
}>> & Readonly<{}>, {}, {}, {}, {}, {
|
|
3572
3608
|
title: string;
|
|
3573
3609
|
image: {
|
|
@@ -3578,6 +3614,7 @@ text: string;
|
|
|
3578
3614
|
subtitle: string;
|
|
3579
3615
|
vignette: "map" | "search" | "calendar" | "dashboard" | "edit" | "megaphone" | "truck" | "warehouse" | "payments" | "light-bulb" | "messages" | "pie-chart" | "api" | "bank" | "basket" | "brand-menu" | "deals" | "document-search" | "empty-tray" | "graph" | "integrations" | "money-bank" | "notifications" | "orders-empty" | "product-cards" | "product-display" | "search-storefront" | "store" | "todo" | "users" | "warehouse-delivery";
|
|
3580
3616
|
footnote: string;
|
|
3617
|
+
vignetteSize: number;
|
|
3581
3618
|
}>;
|
|
3582
3619
|
__isFragment?: undefined;
|
|
3583
3620
|
__isTeleport?: undefined;
|
|
@@ -3613,6 +3650,10 @@ footnote: {
|
|
|
3613
3650
|
type: PropType<string>;
|
|
3614
3651
|
default: string;
|
|
3615
3652
|
};
|
|
3653
|
+
vignetteSize: {
|
|
3654
|
+
type: PropType<number>;
|
|
3655
|
+
default: number;
|
|
3656
|
+
};
|
|
3616
3657
|
}>> & Readonly<{}>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, {
|
|
3617
3658
|
title: string;
|
|
3618
3659
|
image: {
|
|
@@ -3623,6 +3664,7 @@ text: string;
|
|
|
3623
3664
|
subtitle: string;
|
|
3624
3665
|
vignette: "map" | "search" | "calendar" | "dashboard" | "edit" | "megaphone" | "truck" | "warehouse" | "payments" | "light-bulb" | "messages" | "pie-chart" | "api" | "bank" | "basket" | "brand-menu" | "deals" | "document-search" | "empty-tray" | "graph" | "integrations" | "money-bank" | "notifications" | "orders-empty" | "product-cards" | "product-display" | "search-storefront" | "store" | "todo" | "users" | "warehouse-delivery";
|
|
3625
3666
|
footnote: string;
|
|
3667
|
+
vignetteSize: number;
|
|
3626
3668
|
}, {}, string, {}, GlobalComponents, GlobalDirectives, string, ComponentProvideOptions> & VNodeProps & AllowedComponentProps & ComponentCustomProps & (new () => {
|
|
3627
3669
|
$slots: Readonly<EmptyStateSlots> & EmptyStateSlots;
|
|
3628
3670
|
});
|
|
@@ -4515,6 +4557,9 @@ type: PropType<boolean>;
|
|
|
4515
4557
|
showOptionalInLabel: {
|
|
4516
4558
|
type: PropType<boolean>;
|
|
4517
4559
|
};
|
|
4560
|
+
isLabelSrOnly: {
|
|
4561
|
+
type: PropType<boolean>;
|
|
4562
|
+
};
|
|
4518
4563
|
placeholder: {
|
|
4519
4564
|
type: PropType<string>;
|
|
4520
4565
|
default: undefined;
|
|
@@ -4597,6 +4642,9 @@ type: PropType<boolean>;
|
|
|
4597
4642
|
showOptionalInLabel: {
|
|
4598
4643
|
type: PropType<boolean>;
|
|
4599
4644
|
};
|
|
4645
|
+
isLabelSrOnly: {
|
|
4646
|
+
type: PropType<boolean>;
|
|
4647
|
+
};
|
|
4600
4648
|
placeholder: {
|
|
4601
4649
|
type: PropType<string>;
|
|
4602
4650
|
default: undefined;
|
|
@@ -4671,6 +4719,9 @@ type: PropType<boolean>;
|
|
|
4671
4719
|
showOptionalInLabel: {
|
|
4672
4720
|
type: PropType<boolean>;
|
|
4673
4721
|
};
|
|
4722
|
+
isLabelSrOnly: {
|
|
4723
|
+
type: PropType<boolean>;
|
|
4724
|
+
};
|
|
4674
4725
|
placeholder: {
|
|
4675
4726
|
type: PropType<string>;
|
|
4676
4727
|
default: undefined;
|
|
@@ -5300,6 +5351,10 @@ footnote: {
|
|
|
5300
5351
|
type: PropType<string>;
|
|
5301
5352
|
default: string;
|
|
5302
5353
|
};
|
|
5354
|
+
vignetteSize: {
|
|
5355
|
+
type: PropType<number>;
|
|
5356
|
+
default: number;
|
|
5357
|
+
};
|
|
5303
5358
|
}>> & Readonly<{}>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, PublicProps, {
|
|
5304
5359
|
title: string;
|
|
5305
5360
|
image: {
|
|
@@ -5310,6 +5365,7 @@ text: string;
|
|
|
5310
5365
|
subtitle: string;
|
|
5311
5366
|
vignette: "map" | "search" | "calendar" | "dashboard" | "edit" | "megaphone" | "truck" | "warehouse" | "payments" | "light-bulb" | "messages" | "pie-chart" | "api" | "bank" | "basket" | "brand-menu" | "deals" | "document-search" | "empty-tray" | "graph" | "integrations" | "money-bank" | "notifications" | "orders-empty" | "product-cards" | "product-display" | "search-storefront" | "store" | "todo" | "users" | "warehouse-delivery";
|
|
5312
5367
|
footnote: string;
|
|
5368
|
+
vignetteSize: number;
|
|
5313
5369
|
}, true, {}, {}, GlobalComponents, GlobalDirectives, string, {}, any, ComponentProvideOptions, {
|
|
5314
5370
|
P: {};
|
|
5315
5371
|
B: {};
|
|
@@ -5348,6 +5404,10 @@ footnote: {
|
|
|
5348
5404
|
type: PropType<string>;
|
|
5349
5405
|
default: string;
|
|
5350
5406
|
};
|
|
5407
|
+
vignetteSize: {
|
|
5408
|
+
type: PropType<number>;
|
|
5409
|
+
default: number;
|
|
5410
|
+
};
|
|
5351
5411
|
}>> & Readonly<{}>, {}, {}, {}, {}, {
|
|
5352
5412
|
title: string;
|
|
5353
5413
|
image: {
|
|
@@ -5358,6 +5418,7 @@ text: string;
|
|
|
5358
5418
|
subtitle: string;
|
|
5359
5419
|
vignette: "map" | "search" | "calendar" | "dashboard" | "edit" | "megaphone" | "truck" | "warehouse" | "payments" | "light-bulb" | "messages" | "pie-chart" | "api" | "bank" | "basket" | "brand-menu" | "deals" | "document-search" | "empty-tray" | "graph" | "integrations" | "money-bank" | "notifications" | "orders-empty" | "product-cards" | "product-display" | "search-storefront" | "store" | "todo" | "users" | "warehouse-delivery";
|
|
5360
5420
|
footnote: string;
|
|
5421
|
+
vignetteSize: number;
|
|
5361
5422
|
}>;
|
|
5362
5423
|
__isFragment?: undefined;
|
|
5363
5424
|
__isTeleport?: undefined;
|
|
@@ -5393,6 +5454,10 @@ footnote: {
|
|
|
5393
5454
|
type: PropType<string>;
|
|
5394
5455
|
default: string;
|
|
5395
5456
|
};
|
|
5457
|
+
vignetteSize: {
|
|
5458
|
+
type: PropType<number>;
|
|
5459
|
+
default: number;
|
|
5460
|
+
};
|
|
5396
5461
|
}>> & Readonly<{}>, {}, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, {
|
|
5397
5462
|
title: string;
|
|
5398
5463
|
image: {
|
|
@@ -5403,6 +5468,7 @@ text: string;
|
|
|
5403
5468
|
subtitle: string;
|
|
5404
5469
|
vignette: "map" | "search" | "calendar" | "dashboard" | "edit" | "megaphone" | "truck" | "warehouse" | "payments" | "light-bulb" | "messages" | "pie-chart" | "api" | "bank" | "basket" | "brand-menu" | "deals" | "document-search" | "empty-tray" | "graph" | "integrations" | "money-bank" | "notifications" | "orders-empty" | "product-cards" | "product-display" | "search-storefront" | "store" | "todo" | "users" | "warehouse-delivery";
|
|
5405
5470
|
footnote: string;
|
|
5471
|
+
vignetteSize: number;
|
|
5406
5472
|
}, {}, string, {}, GlobalComponents, GlobalDirectives, string, ComponentProvideOptions> & VNodeProps & AllowedComponentProps & ComponentCustomProps & (new () => {
|
|
5407
5473
|
$slots: Readonly<EmptyStateSlots> & EmptyStateSlots;
|
|
5408
5474
|
});
|
package/dist/RadioGroup.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { defineComponent as x, inject as g, useCssModule as V, createElementBlock as c, openBlock as
|
|
1
|
+
import { defineComponent as x, inject as g, useCssModule as V, createElementBlock as c, openBlock as s, normalizeClass as v, unref as e, Fragment as R, renderList as I, createElementVNode as u, toDisplayString as $, provide as S, computed as m, ref as C, useTemplateRef as j, onMounted as D, onUnmounted as q, watchEffect as A, createBlock as M, mergeProps as L, withCtx as N, renderSlot as W, resolveDynamicComponent as P } from "vue";
|
|
2
2
|
import U 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 F } from "./Field.vue_vue_type_script_setup_true_lang-
|
|
5
|
+
import { _ as F } from "./Field.vue_vue_type_script_setup_true_lang-DI6z3AE9.js";
|
|
6
6
|
const J = ["id", "name", "value", "checked", "disabled"], H = ["for"], K = /* @__PURE__ */ x({
|
|
7
7
|
__name: "VariantButton",
|
|
8
8
|
setup(p) {
|
|
9
9
|
const i = g(k.key);
|
|
10
10
|
if (!i)
|
|
11
11
|
throw new Error("VariantButton must be used with a RadioGroup instance.");
|
|
12
|
-
const { name: o, disabled: a, fullWidth:
|
|
13
|
-
return (h, n) => (
|
|
12
|
+
const { name: o, disabled: a, fullWidth: b, modelValue: d, options: f, update: l } = i, _ = V();
|
|
13
|
+
return (h, n) => (s(), c("div", {
|
|
14
14
|
class: v(["tw-flex", e(_).root])
|
|
15
15
|
}, [
|
|
16
|
-
(
|
|
16
|
+
(s(!0), c(R, null, I(e(f), (t) => (s(), c("div", {
|
|
17
17
|
key: `${e(o)}-${t.id}`,
|
|
18
|
-
class: v([{ "tw-w-full": e(
|
|
18
|
+
class: v([{ "tw-w-full": e(b) }])
|
|
19
19
|
}, [
|
|
20
20
|
u("input", {
|
|
21
21
|
id: `${e(o)}-${t.id}`,
|
|
@@ -26,7 +26,7 @@ const J = ["id", "name", "value", "checked", "disabled"], H = ["for"], K = /* @_
|
|
|
26
26
|
checked: e(d) === t.value,
|
|
27
27
|
disabled: e(a) || t.disabled,
|
|
28
28
|
onInput: n[0] || (n[0] = //@ts-ignore
|
|
29
|
-
(...
|
|
29
|
+
(...w) => e(l) && e(l)(...w))
|
|
30
30
|
}, null, 40, J),
|
|
31
31
|
u("label", {
|
|
32
32
|
for: `${e(o)}-${t.id}`
|
|
@@ -44,13 +44,13 @@ const J = ["id", "name", "value", "checked", "disabled"], H = ["for"], K = /* @_
|
|
|
44
44
|
const i = g(k.key);
|
|
45
45
|
if (!i)
|
|
46
46
|
throw new Error("VariantChip must be used with a RadioGroup instance.");
|
|
47
|
-
const { name: o, disabled: a, fullWidth:
|
|
48
|
-
return (h, n) => (
|
|
47
|
+
const { name: o, disabled: a, fullWidth: b, modelValue: d, options: f, update: l } = i, _ = V();
|
|
48
|
+
return (h, n) => (s(), c("div", {
|
|
49
49
|
class: v(["tw-my-1.5 tw-flex tw-flex-wrap", e(_).root])
|
|
50
50
|
}, [
|
|
51
|
-
(
|
|
51
|
+
(s(!0), c(R, null, I(e(f), (t) => (s(), c("div", {
|
|
52
52
|
key: `${e(o)}-${t.id}`,
|
|
53
|
-
class: v([{ "tw-w-full": e(
|
|
53
|
+
class: v([{ "tw-w-full": e(b) }])
|
|
54
54
|
}, [
|
|
55
55
|
u("input", {
|
|
56
56
|
id: `${e(o)}-${t.id}`,
|
|
@@ -61,7 +61,7 @@ const J = ["id", "name", "value", "checked", "disabled"], H = ["for"], K = /* @_
|
|
|
61
61
|
checked: e(d) === t.value,
|
|
62
62
|
disabled: e(a) || t.disabled,
|
|
63
63
|
onInput: n[0] || (n[0] = //@ts-ignore
|
|
64
|
-
(...
|
|
64
|
+
(...w) => e(l) && e(l)(...w))
|
|
65
65
|
}, null, 40, ee),
|
|
66
66
|
u("label", {
|
|
67
67
|
for: `${e(o)}-${t.id}`
|
|
@@ -71,21 +71,21 @@ const J = ["id", "name", "value", "checked", "disabled"], H = ["for"], K = /* @_
|
|
|
71
71
|
}
|
|
72
72
|
}), oe = "_root_kagur_2", re = {
|
|
73
73
|
root: oe
|
|
74
|
-
},
|
|
74
|
+
}, le = {
|
|
75
75
|
$style: re
|
|
76
|
-
},
|
|
76
|
+
}, se = /* @__PURE__ */ B(ae, [["__cssModules", le]]), ne = ["id", "name", "value", "checked", "disabled"], ie = ["for"], de = /* @__PURE__ */ x({
|
|
77
77
|
__name: "VariantRadio",
|
|
78
78
|
setup(p) {
|
|
79
79
|
const i = g(k.key);
|
|
80
80
|
if (!i)
|
|
81
81
|
throw new Error("VariantRadio must be used with a RadioGroup instance.");
|
|
82
|
-
const { name: o, disabled: a, fullWidth:
|
|
83
|
-
return (h, n) => (
|
|
82
|
+
const { name: o, disabled: a, fullWidth: b, modelValue: d, options: f, update: l } = i, _ = V();
|
|
83
|
+
return (h, n) => (s(), c("div", {
|
|
84
84
|
class: v(["tw-flex tw-flex-wrap", e(_).root])
|
|
85
85
|
}, [
|
|
86
|
-
(
|
|
86
|
+
(s(!0), c(R, null, I(e(f), (t) => (s(), c("div", {
|
|
87
87
|
key: `${e(o)}-${t.id}`,
|
|
88
|
-
class: v([{ "tw-w-full": e(
|
|
88
|
+
class: v([{ "tw-w-full": e(b) }])
|
|
89
89
|
}, [
|
|
90
90
|
u("input", {
|
|
91
91
|
id: `${e(o)}-${t.id}`,
|
|
@@ -95,7 +95,7 @@ const J = ["id", "name", "value", "checked", "disabled"], H = ["for"], K = /* @_
|
|
|
95
95
|
checked: e(d) === t.value,
|
|
96
96
|
disabled: e(a) || t.disabled,
|
|
97
97
|
onInput: n[0] || (n[0] = //@ts-ignore
|
|
98
|
-
(...
|
|
98
|
+
(...w) => e(l) && e(l)(...w))
|
|
99
99
|
}, null, 40, ne),
|
|
100
100
|
u("label", {
|
|
101
101
|
for: `${e(o)}-${t.id}`
|
|
@@ -107,19 +107,19 @@ const J = ["id", "name", "value", "checked", "disabled"], H = ["for"], K = /* @_
|
|
|
107
107
|
root: ue
|
|
108
108
|
}, _e = {
|
|
109
109
|
$style: ce
|
|
110
|
-
}, pe = /* @__PURE__ */ B(de, [["__cssModules", _e]]), ve = ["for"], fe = ["id", "name", "value", "checked", "disabled"], me = { class: "tw-m-0 tw-text-ice-900" },
|
|
110
|
+
}, pe = /* @__PURE__ */ B(de, [["__cssModules", _e]]), ve = ["for"], fe = ["id", "name", "value", "checked", "disabled"], me = { class: "tw-m-0 tw-text-ice-900" }, be = { class: "tw-m-0 tw-text-ice-700" }, we = /* @__PURE__ */ x({
|
|
111
111
|
__name: "VariantTile",
|
|
112
112
|
setup(p) {
|
|
113
113
|
const i = g(k.key);
|
|
114
114
|
if (!i)
|
|
115
115
|
throw new Error("VariantTile must be used with a RadioGroup instance.");
|
|
116
|
-
const { name: o, disabled: a, fullWidth:
|
|
117
|
-
return (h, n) => (
|
|
116
|
+
const { name: o, disabled: a, fullWidth: b, modelValue: d, options: f, update: l } = i, _ = V();
|
|
117
|
+
return (h, n) => (s(), c("div", {
|
|
118
118
|
class: v(["tw-flex tw-flex-wrap", e(_).root])
|
|
119
119
|
}, [
|
|
120
|
-
(
|
|
120
|
+
(s(!0), c(R, null, I(e(f), (t) => (s(), c("label", {
|
|
121
121
|
key: `${e(o)}-${t.id}`,
|
|
122
|
-
class: v([e(_)["tile-container"], { "tw-w-full": e(
|
|
122
|
+
class: v([e(_)["tile-container"], { "tw-w-full": e(b) }]),
|
|
123
123
|
for: `${e(o)}-${t.id}`
|
|
124
124
|
}, [
|
|
125
125
|
u("div", {
|
|
@@ -140,7 +140,7 @@ const J = ["id", "name", "value", "checked", "disabled"], H = ["for"], K = /* @_
|
|
|
140
140
|
checked: e(d) === t.value,
|
|
141
141
|
disabled: e(a) || t.disabled,
|
|
142
142
|
onInput: n[0] || (n[0] = //@ts-ignore
|
|
143
|
-
(...
|
|
143
|
+
(...w) => e(l) && e(l)(...w))
|
|
144
144
|
}, null, 40, fe),
|
|
145
145
|
u("div", null, [
|
|
146
146
|
u("span", null, $(t.text), 1)
|
|
@@ -156,7 +156,7 @@ const J = ["id", "name", "value", "checked", "disabled"], H = ["for"], K = /* @_
|
|
|
156
156
|
]])
|
|
157
157
|
}, [
|
|
158
158
|
u("p", me, $(t.subTitle), 1),
|
|
159
|
-
u("p",
|
|
159
|
+
u("p", be, $(t.subText), 1)
|
|
160
160
|
], 2)
|
|
161
161
|
], 10, ve))), 128))
|
|
162
162
|
], 2));
|
|
@@ -168,7 +168,7 @@ const J = ["id", "name", "value", "checked", "disabled"], H = ["for"], K = /* @_
|
|
|
168
168
|
"tile-body": "_tile-body_1sppn_31"
|
|
169
169
|
}, ye = {
|
|
170
170
|
$style: $e
|
|
171
|
-
}, xe = /* @__PURE__ */ B(
|
|
171
|
+
}, xe = /* @__PURE__ */ B(we, [["__cssModules", ye]]);
|
|
172
172
|
var y = /* @__PURE__ */ ((p) => (p.Radio = "radio", p.Button = "button", p.Chip = "chip", p.Tile = "tile", p))(y || {});
|
|
173
173
|
const ke = /* @__PURE__ */ x({
|
|
174
174
|
__name: "RadioGroup",
|
|
@@ -188,6 +188,7 @@ const ke = /* @__PURE__ */ x({
|
|
|
188
188
|
isRequired: { type: Boolean },
|
|
189
189
|
label: {},
|
|
190
190
|
showOptionalInLabel: { type: Boolean },
|
|
191
|
+
isLabelSrOnly: { type: Boolean },
|
|
191
192
|
fieldset: { type: Boolean },
|
|
192
193
|
isDisabled: { type: Boolean },
|
|
193
194
|
disabled: { type: Boolean }
|
|
@@ -196,12 +197,12 @@ const ke = /* @__PURE__ */ x({
|
|
|
196
197
|
setup(p, { emit: i }) {
|
|
197
198
|
const o = {
|
|
198
199
|
[y.Button]: Z,
|
|
199
|
-
[y.Chip]:
|
|
200
|
+
[y.Chip]: se,
|
|
200
201
|
[y.Radio]: pe,
|
|
201
202
|
[y.Tile]: xe
|
|
202
|
-
}, a = p,
|
|
203
|
+
}, a = p, b = i;
|
|
203
204
|
function d(r) {
|
|
204
|
-
|
|
205
|
+
b("update:modelValue", r.target.value);
|
|
205
206
|
}
|
|
206
207
|
const f = U("radio-group-field-error-");
|
|
207
208
|
S(k.key, {
|
|
@@ -211,38 +212,38 @@ const ke = /* @__PURE__ */ x({
|
|
|
211
212
|
modelValue: m(() => a.modelValue),
|
|
212
213
|
options: m(() => a.options),
|
|
213
214
|
variant: m(() => a.variant),
|
|
214
|
-
orientation: m(() =>
|
|
215
|
+
orientation: m(() => l.value),
|
|
215
216
|
update: d
|
|
216
217
|
});
|
|
217
|
-
const
|
|
218
|
+
const l = C(a.orientation), _ = m(() => ({
|
|
218
219
|
"tw-flex-wrap": a.variant !== "button",
|
|
219
|
-
"tw-gap-x-1.5 tw-gap-y-3": a.variant === "chip" &&
|
|
220
|
-
"tw-gap-6": a.variant === "radio" || a.variant === "tile" || a.variant === "chip" &&
|
|
221
|
-
"tw-flex-col":
|
|
220
|
+
"tw-gap-x-1.5 tw-gap-y-3": a.variant === "chip" && l.value === "horizontal",
|
|
221
|
+
"tw-gap-6": a.variant === "radio" || a.variant === "tile" || a.variant === "chip" && l.value === "vertical",
|
|
222
|
+
"tw-flex-col": l.value === "vertical"
|
|
222
223
|
})), h = C(null), n = j("radioGroup"), t = m(() => {
|
|
223
224
|
var r;
|
|
224
225
|
return (r = n.value) == null ? void 0 : r.$el.parentElement;
|
|
225
|
-
}),
|
|
226
|
+
}), w = m(() => {
|
|
226
227
|
var r;
|
|
227
228
|
return a.variant !== "button" ? [] : Array.from((r = n.value) == null ? void 0 : r.$el.querySelectorAll("[data-variant-button]")) || [];
|
|
228
229
|
});
|
|
229
230
|
function E() {
|
|
230
|
-
return
|
|
231
|
-
const
|
|
232
|
-
return r +
|
|
231
|
+
return w.value.reduce((r, T) => {
|
|
232
|
+
const z = T.getBoundingClientRect().width;
|
|
233
|
+
return r + z;
|
|
233
234
|
}, 0);
|
|
234
235
|
}
|
|
235
|
-
const G = C(0),
|
|
236
|
-
|
|
236
|
+
const G = C(0), O = (r) => {
|
|
237
|
+
l.value = G.value > r.contentBoxSize[0].inlineSize ? "vertical" : a.orientation;
|
|
237
238
|
};
|
|
238
239
|
return D(() => {
|
|
239
|
-
a.variant === "button" && !a.fullWidth && (G.value = E(), h.value = new ResizeObserver((r) =>
|
|
240
|
+
a.variant === "button" && !a.fullWidth && (G.value = E(), h.value = new ResizeObserver((r) => O(r[0])), h.value.observe(t.value));
|
|
240
241
|
}), q(() => {
|
|
241
242
|
var r;
|
|
242
243
|
a.variant === "button" && h.value && ((r = h.value) == null || r.disconnect());
|
|
243
244
|
}), A(() => {
|
|
244
|
-
|
|
245
|
-
}), (r, T) => (
|
|
245
|
+
l.value = a.orientation;
|
|
246
|
+
}), (r, T) => (s(), M(F, L(a, {
|
|
246
247
|
ref: "radioGroup",
|
|
247
248
|
class: "stash-radio-group",
|
|
248
249
|
"data-test": "stash-radio-group",
|
|
@@ -252,10 +253,10 @@ const ke = /* @__PURE__ */ x({
|
|
|
252
253
|
role: "radiogroup",
|
|
253
254
|
fieldset: ""
|
|
254
255
|
}), {
|
|
255
|
-
default:
|
|
256
|
+
default: N(() => [
|
|
256
257
|
a.options ? W(r.$slots, "default", { key: 0 }, () => [
|
|
257
|
-
(
|
|
258
|
-
], !0) : (
|
|
258
|
+
(s(), M(P(o[a.variant])))
|
|
259
|
+
], !0) : (s(), c("div", {
|
|
259
260
|
key: 1,
|
|
260
261
|
class: v(["tw-flex", _.value]),
|
|
261
262
|
"data-test": "stash-radio-group|default-slot"
|
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, 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 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 classes = 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 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=\"classes\">\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: 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","resizeObserver","radioGroupRef","useTemplateRef","radioGroupParent","_a","radioGroupButtons","getButtonsWidth","acc","button","buttonWidth","initialTotalButtonsWidth","handleResize","entry","onMounted","entries","onUnmounted","watchEffect"],"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,MAAWR,GAC7DS,IAAUC,EAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACPvB,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,MAAWR,GAC7DS,IAAUC,EAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC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qB,EAAyB,QAAQJ,EAAgB,GAClCN,EAAA,QAAQ,IAAI,eAAe,CAACc,MAAYH,EAAaG,EAAQ,CAAC,CAAC,CAAC,GAEhEd,EAAA,MAAM,QAAQG,EAAiB,KAAK;AAAA,IACrD,CACD,GAEDY,EAAY,MAAM;;AAChB,MAAI1B,EAAM,YAAY,YAAYW,EAAe,WAC/CI,IAAAJ,EAAe,UAAf,QAAAI,EAAsB;AAAA,IACxB,CACD,GAEDY,EAAY,MAAM;AAChB,MAAAlB,EAAoB,QAAQT,EAAM;AAAA,IAAA,CACnC;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
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, 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 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 classes = 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 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=\"classes\">\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: 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","resizeObserver","radioGroupRef","useTemplateRef","radioGroupParent","_a","radioGroupButtons","getButtonsWidth","acc","button","buttonWidth","initialTotalButtonsWidth","handleResize","entry","onMounted","entries","onUnmounted","watchEffect"],"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,MAAWR,GAC7DS,IAAUC,EAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACPvB,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,G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AC7F;AAEA,WAAAwB,EAAU,MAAM;AAGd,MAAIxB,EAAM,YAAY,YAAY,CAACA,EAAM,cACvCqB,EAAyB,QAAQJ,EAAgB,GAClCN,EAAA,QAAQ,IAAI,eAAe,CAACc,MAAYH,EAAaG,EAAQ,CAAC,CAAC,CAAC,GAEhEd,EAAA,MAAM,QAAQG,EAAiB,KAAK;AAAA,IACrD,CACD,GAEDY,EAAY,MAAM;;AAChB,MAAI1B,EAAM,YAAY,YAAYW,EAAe,WAC/CI,IAAAJ,EAAe,UAAf,QAAAI,EAAsB;AAAA,IACxB,CACD,GAEDY,EAAY,MAAM;AAChB,MAAAlB,EAAoB,QAAQT,EAAM;AAAA,IAAA,CACnC;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/RadioGroup.vue.d.ts
CHANGED
|
@@ -101,6 +101,10 @@ declare interface FieldProps {
|
|
|
101
101
|
* Show "(optional)" to the right of the label text
|
|
102
102
|
*/
|
|
103
103
|
showOptionalInLabel?: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Indicates whether the label should be visually hidden (screen reader only).
|
|
106
|
+
*/
|
|
107
|
+
isLabelSrOnly?: boolean;
|
|
104
108
|
/**
|
|
105
109
|
* Indicates wheter the field is a fieldset or not
|
|
106
110
|
*/
|
package/dist/Select.js
CHANGED
|
@@ -12,7 +12,7 @@ import Qe from "./directives/clickoutside.js";
|
|
|
12
12
|
import { D as Ze } from "./MenusPlugin-Bk6UW6o9.js";
|
|
13
13
|
import ce from "./Chip.js";
|
|
14
14
|
import z from "./Icon.js";
|
|
15
|
-
import { _ as et } from "./Field.vue_vue_type_script_setup_true_lang-
|
|
15
|
+
import { _ as et } from "./Field.vue_vue_type_script_setup_true_lang-DI6z3AE9.js";
|
|
16
16
|
import { _ as tt } from "./_plugin-vue_export-helper-CHgC5LLL.js";
|
|
17
17
|
const lt = { class: "tw-flex tw-h-input tw-items-center tw-text-sm" }, at = ["id", "aria-labelledby"], st = ["id", "aria-errormessage", "aria-invalid", "disabled", "multiple", "name"], nt = ["selected", "value", "disabled"], ot = ["aria-controls", "aria-expanded", "aria-label", "aria-disabled"], rt = ["id"], it = ["onKeypress", "onMousedown"], ct = {
|
|
18
18
|
key: 0,
|
|
@@ -66,6 +66,7 @@ const lt = { class: "tw-flex tw-h-input tw-items-center tw-text-sm" }, at = ["id
|
|
|
66
66
|
isRequired: { type: Boolean },
|
|
67
67
|
label: {},
|
|
68
68
|
showOptionalInLabel: { type: Boolean },
|
|
69
|
+
isLabelSrOnly: { type: Boolean },
|
|
69
70
|
fieldset: { type: Boolean },
|
|
70
71
|
isDisabled: { type: Boolean },
|
|
71
72
|
disabled: { type: Boolean }
|