vueless 0.0.254 → 0.0.256
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/composable.ui/index.js +21 -4
- package/package.json +1 -1
- package/ui.button/composables/attrs.composable.js +11 -14
- package/ui.button/index.stories.js +1 -1
- package/ui.button-link/composables/attrs.composable.js +8 -11
- package/ui.button-link/index.stories.js +1 -1
- package/ui.button-toggle/composables/attrs.composable.js +5 -5
- package/ui.button-toggle/index.stories.js +2 -2
- package/ui.button-toggle-item/composables/attrs.composable.js +5 -5
- package/ui.button-toggle-item/index.stories.js +6 -2
- package/ui.container-card/index.stories.js +1 -1
- package/ui.dropdown-button/index.stories.js +3 -6
- package/ui.form-checkbox/index.stories.js +13 -26
- package/ui.form-checkbox-group/index.stories.js +28 -74
- package/ui.form-checkbox-multi-state/index.stories.js +17 -13
- package/ui.form-color-picker/index.stories.js +3 -3
- package/ui.form-date-picker/index.stories.js +11 -15
- package/ui.form-input/index.stories.js +1 -1
- package/ui.form-input-file/index.stories.js +1 -1
- package/ui.form-input-money/index.stories.js +1 -1
- package/ui.form-input-number/index.stories.js +3 -3
- package/ui.form-input-search/index.stories.js +1 -1
- package/ui.form-label/index.stories.js +28 -51
- package/ui.form-radio-group/index.stories.js +6 -14
- package/ui.form-select/index.stories.js +62 -159
- package/ui.form-switch/index.stories.js +17 -33
- package/ui.form-textarea/index.stories.js +1 -3
- package/ui.image-icon/index.stories.js +1 -1
- package/ui.navigation-progress/index.stories.js +1 -1
- package/ui.navigation-tabs/index.stories.js +3 -3
- package/ui.text-badge/index.stories.js +2 -2
- package/ui.text-block/index.stories.js +2 -2
- package/ui.text-empty/index.stories.js +1 -1
- package/web-types.json +1 -1
package/composable.ui/index.js
CHANGED
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
} from "../service.ui";
|
|
21
21
|
|
|
22
22
|
import { cloneDeep } from "../service.helper";
|
|
23
|
-
import { STRATEGY_TYPE, SYSTEM_CONFIG_KEY } from "../constants";
|
|
23
|
+
import { STRATEGY_TYPE, CVA_CONFIG_KEY, SYSTEM_CONFIG_KEY } from "../constants";
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
Merging component configs in a given sequence (bigger number = bigger priority):
|
|
@@ -88,12 +88,15 @@ export default function useUI(defaultConfig = {}, propsConfigGetter = null, topL
|
|
|
88
88
|
|
|
89
89
|
const isTopLevelClassKey = configKey === (topLevelClassKey || firstClassKey);
|
|
90
90
|
const attrClass = isTopLevelClassKey && !nestedComponent ? attrs.class : "";
|
|
91
|
-
// TODO: Uncomment and add into `cx` when getAttrs as a function will be resolved.
|
|
92
|
-
// const classes = toValue(options?.classes) || getBaseClasses(configKeyValue);
|
|
93
91
|
|
|
92
|
+
// TODO: remove `getBaseClasses(configKeyValue)` after migration to `setDynamicVars`
|
|
94
93
|
vuelessAttrs.value = {
|
|
95
94
|
...commonAttrs,
|
|
96
|
-
class: cx([
|
|
95
|
+
class: cx([
|
|
96
|
+
getBaseClasses(configKeyValue),
|
|
97
|
+
getBaseClasses(toValue(options?.classes)),
|
|
98
|
+
attrClass,
|
|
99
|
+
]),
|
|
97
100
|
...((isObject && configAttrs) || {}),
|
|
98
101
|
};
|
|
99
102
|
}
|
|
@@ -106,6 +109,7 @@ export default function useUI(defaultConfig = {}, propsConfigGetter = null, topL
|
|
|
106
109
|
getAttrs,
|
|
107
110
|
getColor,
|
|
108
111
|
setColor,
|
|
112
|
+
isCVA,
|
|
109
113
|
isSystemKey,
|
|
110
114
|
hasSlotContent,
|
|
111
115
|
};
|
|
@@ -404,6 +408,19 @@ function isSystemKey(key) {
|
|
|
404
408
|
);
|
|
405
409
|
}
|
|
406
410
|
|
|
411
|
+
/**
|
|
412
|
+
Check is config contains default CVA keys.
|
|
413
|
+
@param { Object | String } config
|
|
414
|
+
@returns { Boolean }
|
|
415
|
+
*/
|
|
416
|
+
function isCVA(config) {
|
|
417
|
+
if (typeof config !== "object") return false;
|
|
418
|
+
|
|
419
|
+
return Object.values(CVA_CONFIG_KEY).some((value) =>
|
|
420
|
+
Object.keys(config).some((key) => key === value),
|
|
421
|
+
);
|
|
422
|
+
}
|
|
423
|
+
|
|
407
424
|
/**
|
|
408
425
|
Check if slot defined, and have a content.
|
|
409
426
|
@param slot
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@ import defaultConfig from "../configs/default.config";
|
|
|
5
5
|
|
|
6
6
|
export default function useAttrs(props) {
|
|
7
7
|
const slots = useSlots();
|
|
8
|
-
const { config, getAttrs, getColor, setColor, hasSlotContent, isSystemKey } = useUI(
|
|
8
|
+
const { config, getAttrs, getColor, setColor, hasSlotContent, isSystemKey, isCVA } = useUI(
|
|
9
9
|
defaultConfig,
|
|
10
10
|
() => props.config,
|
|
11
11
|
);
|
|
@@ -15,22 +15,19 @@ export default function useAttrs(props) {
|
|
|
15
15
|
if (isSystemKey(key)) continue;
|
|
16
16
|
|
|
17
17
|
const classes = computed(() => {
|
|
18
|
-
|
|
18
|
+
let value = config.value[key];
|
|
19
19
|
|
|
20
|
-
if (value
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}),
|
|
29
|
-
props.color,
|
|
30
|
-
);
|
|
20
|
+
if (isCVA(value)) {
|
|
21
|
+
value = cva(value)({
|
|
22
|
+
...props,
|
|
23
|
+
color: getColor(props.color),
|
|
24
|
+
square: props.loading || props.square,
|
|
25
|
+
iconLeft: Boolean(props.iconLeft) || hasSlotContent(slots["icon-left"]),
|
|
26
|
+
iconRight: Boolean(props.iconRight) || hasSlotContent(slots["icon-right"]),
|
|
27
|
+
});
|
|
31
28
|
}
|
|
32
29
|
|
|
33
|
-
return
|
|
30
|
+
return setColor(value, props.color);
|
|
34
31
|
});
|
|
35
32
|
|
|
36
33
|
attrs[`${key}Attrs`] = getAttrs(key, { classes });
|
|
@@ -6,7 +6,7 @@ import defaultConfig from "../configs/default.config";
|
|
|
6
6
|
export default function useAttrs(props, { isActive, isExactActive }) {
|
|
7
7
|
const slots = useSlots();
|
|
8
8
|
|
|
9
|
-
const { config, getAttrs, hasSlotContent, getColor, setColor, isSystemKey } = useUI(
|
|
9
|
+
const { config, getAttrs, hasSlotContent, getColor, setColor, isSystemKey, isCVA } = useUI(
|
|
10
10
|
defaultConfig,
|
|
11
11
|
() => props.config,
|
|
12
12
|
);
|
|
@@ -16,19 +16,16 @@ export default function useAttrs(props, { isActive, isExactActive }) {
|
|
|
16
16
|
if (isSystemKey(key)) continue;
|
|
17
17
|
|
|
18
18
|
const classes = computed(() => {
|
|
19
|
-
|
|
19
|
+
let value = config.value[key];
|
|
20
20
|
|
|
21
|
-
if (value
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}),
|
|
27
|
-
props.color,
|
|
28
|
-
);
|
|
21
|
+
if (isCVA(value)) {
|
|
22
|
+
value = cva(value)({
|
|
23
|
+
...props,
|
|
24
|
+
color: getColor(props.color),
|
|
25
|
+
});
|
|
29
26
|
}
|
|
30
27
|
|
|
31
|
-
return
|
|
28
|
+
return setColor(value, props.color);
|
|
32
29
|
});
|
|
33
30
|
|
|
34
31
|
attrs[`${key}Attrs`] = getAttrs(key, { classes });
|
|
@@ -53,10 +53,10 @@ const EnumVariantTemplate = (args, { argTypes } = {}) => ({
|
|
|
53
53
|
<URow>
|
|
54
54
|
<ULink
|
|
55
55
|
v-for="(option, index) in options"
|
|
56
|
+
:key="index"
|
|
56
57
|
v-bind="args"
|
|
57
58
|
:[args.enum]="option"
|
|
58
59
|
:label="prefixedOptions[index]"
|
|
59
|
-
:key="index"
|
|
60
60
|
/>
|
|
61
61
|
</URow>
|
|
62
62
|
`,
|
|
@@ -4,7 +4,7 @@ import { cva } from "../../service.ui";
|
|
|
4
4
|
import defaultConfig from "../configs/default.config";
|
|
5
5
|
|
|
6
6
|
export default function useAttrs(props) {
|
|
7
|
-
const { config, getAttrs, hasSlotContent, isSystemKey } = useUI(
|
|
7
|
+
const { config, getAttrs, hasSlotContent, isSystemKey, isCVA } = useUI(
|
|
8
8
|
defaultConfig,
|
|
9
9
|
() => props.config,
|
|
10
10
|
);
|
|
@@ -14,15 +14,15 @@ export default function useAttrs(props) {
|
|
|
14
14
|
if (isSystemKey(key)) continue;
|
|
15
15
|
|
|
16
16
|
const classes = computed(() => {
|
|
17
|
-
|
|
17
|
+
let value = config.value[key];
|
|
18
18
|
|
|
19
|
-
if (value
|
|
20
|
-
|
|
19
|
+
if (isCVA(value)) {
|
|
20
|
+
value = cva(value)({
|
|
21
21
|
...props,
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
return
|
|
25
|
+
return value;
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
attrs[`${key}Attrs`] = getAttrs(key, { classes });
|
|
@@ -37,8 +37,8 @@ const DefaultTemplate = (args) => ({
|
|
|
37
37
|
},
|
|
38
38
|
template: `
|
|
39
39
|
<UToggle
|
|
40
|
-
v-model="value"
|
|
41
40
|
v-bind="args"
|
|
41
|
+
v-model="value"
|
|
42
42
|
:options="OPTIONS"
|
|
43
43
|
>
|
|
44
44
|
${args.slotTemplate || getSlotsFragment()}
|
|
@@ -62,8 +62,8 @@ const EnumVariantTemplate = (args, { argTypes } = {}) => ({
|
|
|
62
62
|
<UToggle
|
|
63
63
|
v-for="(option, index) in options"
|
|
64
64
|
:key="index"
|
|
65
|
-
v-model="value"
|
|
66
65
|
v-bind="args"
|
|
66
|
+
v-model="value"
|
|
67
67
|
:[args.enum]="option"
|
|
68
68
|
:label="option"
|
|
69
69
|
:options="[
|
|
@@ -4,7 +4,7 @@ import { cva } from "../../service.ui";
|
|
|
4
4
|
import defaultConfig from "../configs/default.config";
|
|
5
5
|
|
|
6
6
|
export default function useAttrs(props, { isSelected, separated, variant }) {
|
|
7
|
-
const { config, getAttrs, isSystemKey, hasSlotContent } = useUI(
|
|
7
|
+
const { config, getAttrs, isSystemKey, hasSlotContent, isCVA } = useUI(
|
|
8
8
|
defaultConfig,
|
|
9
9
|
() => props.config,
|
|
10
10
|
);
|
|
@@ -15,10 +15,10 @@ export default function useAttrs(props, { isSelected, separated, variant }) {
|
|
|
15
15
|
if (isSystemKey(key)) continue;
|
|
16
16
|
|
|
17
17
|
const classes = computed(() => {
|
|
18
|
-
|
|
18
|
+
let value = config.value[key];
|
|
19
19
|
|
|
20
|
-
if (value
|
|
21
|
-
|
|
20
|
+
if (isCVA(value)) {
|
|
21
|
+
value = cva(value)({
|
|
22
22
|
...props,
|
|
23
23
|
variant: toValue(variant),
|
|
24
24
|
separated: toValue(separated),
|
|
@@ -26,7 +26,7 @@ export default function useAttrs(props, { isSelected, separated, variant }) {
|
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
return
|
|
29
|
+
return value;
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
attrs[`${key}Attrs`] = getAttrs(key, { classes });
|
|
@@ -28,8 +28,12 @@ const DefaultTemplate = (args) => ({
|
|
|
28
28
|
return { args, slots };
|
|
29
29
|
},
|
|
30
30
|
template: `
|
|
31
|
-
<UToggleItem
|
|
32
|
-
|
|
31
|
+
<UToggleItem
|
|
32
|
+
v-bind="args"
|
|
33
|
+
v-model="args.modelValue"
|
|
34
|
+
name="toggle"
|
|
35
|
+
>
|
|
36
|
+
${args.slotTemplate || getSlotsFragment()}
|
|
33
37
|
</UToggleItem>
|
|
34
38
|
`,
|
|
35
39
|
});
|
|
@@ -40,10 +40,7 @@ const DefaultTemplate = (args) => ({
|
|
|
40
40
|
return { args, slots };
|
|
41
41
|
},
|
|
42
42
|
template: `
|
|
43
|
-
<UDropdownButton
|
|
44
|
-
v-bind="args"
|
|
45
|
-
v-model="args.modelValue"
|
|
46
|
-
>
|
|
43
|
+
<UDropdownButton v-bind="args">
|
|
47
44
|
${args.slotTemplate || getSlotsFragment()}
|
|
48
45
|
</UDropdownButton>
|
|
49
46
|
`,
|
|
@@ -83,12 +80,12 @@ const VariantColorsTemplate = (args, { argTypes } = {}) => ({
|
|
|
83
80
|
<UCol>
|
|
84
81
|
<URow v-for="(variant, index) in variants" :key="index">
|
|
85
82
|
<UDropdownButton
|
|
86
|
-
v-for="(color,
|
|
83
|
+
v-for="(color, index) in colors"
|
|
84
|
+
:key="index"
|
|
87
85
|
v-bind="args"
|
|
88
86
|
:color="color"
|
|
89
87
|
:variant="variant"
|
|
90
88
|
:label="color"
|
|
91
|
-
:key="idx"
|
|
92
89
|
/>
|
|
93
90
|
</URow>
|
|
94
91
|
</UCol>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getArgTypes, getSlotNames,
|
|
1
|
+
import { getArgTypes, getSlotNames, getSlotsFragment } from "../service.storybook";
|
|
2
2
|
|
|
3
3
|
import UCheckbox from "../ui.form-checkbox";
|
|
4
4
|
import UCheckboxGroup from "../ui.form-checkbox-group";
|
|
@@ -14,23 +14,23 @@ export default {
|
|
|
14
14
|
component: UCheckbox,
|
|
15
15
|
args: {
|
|
16
16
|
label: "Label",
|
|
17
|
-
value: {},
|
|
18
17
|
},
|
|
19
18
|
argTypes: {
|
|
20
19
|
...getArgTypes(UCheckbox.name),
|
|
20
|
+
modelValue: { control: { type: "boolean" } },
|
|
21
21
|
},
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
const DefaultTemplate = (args) => ({
|
|
25
|
-
components: { UCheckbox },
|
|
25
|
+
components: { UCheckbox, UBadge },
|
|
26
26
|
setup() {
|
|
27
27
|
const slots = getSlotNames(UCheckbox.name);
|
|
28
28
|
|
|
29
29
|
return { args, slots };
|
|
30
30
|
},
|
|
31
31
|
template: `
|
|
32
|
-
<UCheckbox v-bind="args" v-model="args.
|
|
33
|
-
${
|
|
32
|
+
<UCheckbox v-bind="args" v-model="args.modelValue">
|
|
33
|
+
${args.slotTemplate || getSlotsFragment()}
|
|
34
34
|
</UCheckbox>
|
|
35
35
|
`,
|
|
36
36
|
});
|
|
@@ -89,48 +89,35 @@ const ValueTypesTemplate = (args) => ({
|
|
|
89
89
|
`,
|
|
90
90
|
});
|
|
91
91
|
|
|
92
|
-
const
|
|
92
|
+
const EnumVariantTemplate = (args, { argTypes } = {}) => ({
|
|
93
93
|
components: { UCheckbox, UCol },
|
|
94
94
|
setup() {
|
|
95
95
|
return {
|
|
96
96
|
args,
|
|
97
|
-
|
|
97
|
+
options: argTypes[args.enum].options,
|
|
98
98
|
};
|
|
99
99
|
},
|
|
100
100
|
template: `
|
|
101
101
|
<UCol gap="xl">
|
|
102
102
|
<UCheckbox
|
|
103
|
-
v-for="(
|
|
103
|
+
v-for="(option, index) in options"
|
|
104
104
|
:key="index"
|
|
105
105
|
v-bind="args"
|
|
106
|
-
|
|
107
|
-
:
|
|
108
|
-
:label="size"
|
|
106
|
+
:[args.enum]="option"
|
|
107
|
+
:label="option"
|
|
109
108
|
/>
|
|
110
109
|
</UCol>
|
|
111
110
|
`,
|
|
112
111
|
});
|
|
113
112
|
|
|
114
|
-
const SlotTemplate = (args) => ({
|
|
115
|
-
components: { UCheckbox, UBadge },
|
|
116
|
-
setup() {
|
|
117
|
-
return { args };
|
|
118
|
-
},
|
|
119
|
-
template: `
|
|
120
|
-
<UCheckbox v-bind="args" v-model="args.value" description="hello">
|
|
121
|
-
${args.slotTemplate}
|
|
122
|
-
</UCheckbox>
|
|
123
|
-
`,
|
|
124
|
-
});
|
|
125
|
-
|
|
126
113
|
export const Default = DefaultTemplate.bind({});
|
|
127
114
|
Default.args = {};
|
|
128
115
|
|
|
129
116
|
export const CustomValues = ValueTypesTemplate.bind({});
|
|
130
117
|
CustomValues.args = {};
|
|
131
118
|
|
|
132
|
-
export const Sizes =
|
|
133
|
-
Sizes.args = {};
|
|
119
|
+
export const Sizes = EnumVariantTemplate.bind({});
|
|
120
|
+
Sizes.args = { enum: "size" };
|
|
134
121
|
|
|
135
122
|
export const Disabled = DefaultTemplate.bind({});
|
|
136
123
|
Disabled.args = { disabled: true };
|
|
@@ -138,7 +125,7 @@ Disabled.args = { disabled: true };
|
|
|
138
125
|
export const Description = DefaultTemplate.bind({});
|
|
139
126
|
Description.args = { description: "Some description" };
|
|
140
127
|
|
|
141
|
-
export const slotFooter =
|
|
128
|
+
export const slotFooter = DefaultTemplate.bind({});
|
|
142
129
|
slotFooter.args = {
|
|
143
130
|
slotTemplate: `
|
|
144
131
|
<template #footer>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getArgTypes } from "../service.storybook";
|
|
1
|
+
import { getArgTypes, getSlotNames, getSlotsFragment } from "../service.storybook";
|
|
2
2
|
|
|
3
3
|
import UCheckboxGroup from "../ui.form-checkbox-group";
|
|
4
4
|
import UCheckbox from "../ui.form-checkbox";
|
|
@@ -29,7 +29,9 @@ export default {
|
|
|
29
29
|
const DefaultTemplate = (args) => ({
|
|
30
30
|
components: { UCheckboxGroup, UCheckbox, UAlert, URow },
|
|
31
31
|
setup() {
|
|
32
|
-
|
|
32
|
+
const slots = getSlotNames(UCheckboxGroup.name);
|
|
33
|
+
|
|
34
|
+
return { args, slots };
|
|
33
35
|
},
|
|
34
36
|
data() {
|
|
35
37
|
return {
|
|
@@ -39,9 +41,7 @@ const DefaultTemplate = (args) => ({
|
|
|
39
41
|
template: `
|
|
40
42
|
<URow class="!flex-col">
|
|
41
43
|
<UCheckboxGroup v-bind="args" v-model="value">
|
|
42
|
-
|
|
43
|
-
<UCheckbox v-bind="radio"/>
|
|
44
|
-
</template>
|
|
44
|
+
${args.slotTemplate || getSlotsFragment()}
|
|
45
45
|
</UCheckboxGroup>
|
|
46
46
|
|
|
47
47
|
<URow>
|
|
@@ -53,25 +53,29 @@ const DefaultTemplate = (args) => ({
|
|
|
53
53
|
`,
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
-
const
|
|
57
|
-
components: { UCheckboxGroup,
|
|
56
|
+
const EnumVariantTemplate = (args, { argTypes } = {}) => ({
|
|
57
|
+
components: { UCheckboxGroup, URow },
|
|
58
58
|
setup() {
|
|
59
59
|
return { args };
|
|
60
60
|
},
|
|
61
61
|
data() {
|
|
62
62
|
return {
|
|
63
63
|
value: args.value,
|
|
64
|
+
options: argTypes[args.enum].options,
|
|
64
65
|
};
|
|
65
66
|
},
|
|
66
67
|
template: `
|
|
67
68
|
<URow class="!flex-col">
|
|
68
|
-
<UCheckboxGroup
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
69
|
+
<UCheckboxGroup
|
|
70
|
+
v-for="(option, index) in options"
|
|
71
|
+
:key="option"
|
|
72
|
+
v-bind="args"
|
|
73
|
+
v-model="value"
|
|
74
|
+
:label="option"
|
|
75
|
+
:[args.enum]="option"
|
|
76
|
+
:options="args.options"
|
|
77
|
+
name="option"
|
|
78
|
+
/>
|
|
75
79
|
</URow>
|
|
76
80
|
`,
|
|
77
81
|
});
|
|
@@ -79,7 +83,11 @@ const OptionsTemplate = (args) => ({
|
|
|
79
83
|
export const Default = DefaultTemplate.bind({});
|
|
80
84
|
Default.args = {
|
|
81
85
|
name: "Default",
|
|
82
|
-
|
|
86
|
+
slotTemplate: `
|
|
87
|
+
<template v-for="(radio, index) in args.options" :key="index">
|
|
88
|
+
<UCheckbox v-bind="radio"/>
|
|
89
|
+
</template>
|
|
90
|
+
`,
|
|
83
91
|
options: [
|
|
84
92
|
{ name: "Default", label: "String", value: "One" },
|
|
85
93
|
{ name: "Default", label: "Boolean", value: false },
|
|
@@ -97,7 +105,7 @@ Default.args = {
|
|
|
97
105
|
],
|
|
98
106
|
};
|
|
99
107
|
|
|
100
|
-
export const Options =
|
|
108
|
+
export const Options = DefaultTemplate.bind({});
|
|
101
109
|
Options.args = {
|
|
102
110
|
name: "Options",
|
|
103
111
|
options: [
|
|
@@ -109,68 +117,14 @@ Options.args = {
|
|
|
109
117
|
],
|
|
110
118
|
};
|
|
111
119
|
|
|
112
|
-
const ColorsTemplate = (args, { argTypes } = {}) => ({
|
|
113
|
-
components: { UCheckboxGroup, URow },
|
|
114
|
-
setup() {
|
|
115
|
-
return { args };
|
|
116
|
-
},
|
|
117
|
-
data() {
|
|
118
|
-
return {
|
|
119
|
-
value: args.value,
|
|
120
|
-
colors: argTypes.color.options,
|
|
121
|
-
};
|
|
122
|
-
},
|
|
123
|
-
template: `
|
|
124
|
-
<URow class="!flex-col">
|
|
125
|
-
<UCheckboxGroup
|
|
126
|
-
v-bind="args"
|
|
127
|
-
v-for="color in colors"
|
|
128
|
-
:key="color"
|
|
129
|
-
:label="color"
|
|
130
|
-
:color="color"
|
|
131
|
-
:options="args.options"
|
|
132
|
-
name="color"
|
|
133
|
-
v-model="value"
|
|
134
|
-
/>
|
|
135
|
-
</URow>
|
|
136
|
-
`,
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
const SizesTemplate = (args, { argTypes } = {}) => ({
|
|
140
|
-
components: { UCheckboxGroup, URow },
|
|
141
|
-
setup() {
|
|
142
|
-
return { args };
|
|
143
|
-
},
|
|
144
|
-
data() {
|
|
145
|
-
return {
|
|
146
|
-
value: args.value,
|
|
147
|
-
sizes: argTypes.size.options,
|
|
148
|
-
};
|
|
149
|
-
},
|
|
150
|
-
template: `
|
|
151
|
-
<URow class="!flex-col">
|
|
152
|
-
<UCheckboxGroup
|
|
153
|
-
v-bind="args"
|
|
154
|
-
v-for="size in sizes"
|
|
155
|
-
:key="size"
|
|
156
|
-
:label="size"
|
|
157
|
-
:size="size"
|
|
158
|
-
:options="args.options"
|
|
159
|
-
name="size"
|
|
160
|
-
v-model="value"
|
|
161
|
-
/>
|
|
162
|
-
</URow>
|
|
163
|
-
`,
|
|
164
|
-
});
|
|
165
|
-
|
|
166
120
|
export const disabled = DefaultTemplate.bind({});
|
|
167
121
|
disabled.args = { name: "Disabled", disabled: true };
|
|
168
122
|
|
|
169
123
|
export const error = DefaultTemplate.bind({});
|
|
170
124
|
error.args = { name: "Error", error: "some error" };
|
|
171
125
|
|
|
172
|
-
export const Colors =
|
|
173
|
-
Colors.args = { name: "Colors" };
|
|
126
|
+
export const Colors = EnumVariantTemplate.bind({});
|
|
127
|
+
Colors.args = { enum: "color", name: "Colors" };
|
|
174
128
|
|
|
175
|
-
export const Sizes =
|
|
176
|
-
Sizes.args = { name: "Sizes" };
|
|
129
|
+
export const Sizes = EnumVariantTemplate.bind({});
|
|
130
|
+
Sizes.args = { enum: "size", name: "Sizes" };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getArgTypes } from "../service.storybook";
|
|
1
|
+
import { getArgTypes, getSlotNames, getSlotsFragment } from "../service.storybook";
|
|
2
2
|
|
|
3
3
|
import UCheckboxMultiState from "../ui.form-checkbox-multi-state";
|
|
4
4
|
import URow from "../ui.container-row";
|
|
@@ -11,7 +11,6 @@ export default {
|
|
|
11
11
|
title: "Form Inputs & Controls / Checkbox Multistate",
|
|
12
12
|
component: UCheckboxMultiState,
|
|
13
13
|
args: {
|
|
14
|
-
modelValue: false,
|
|
15
14
|
options: [
|
|
16
15
|
{ value: false, label: "empty", icon: "", description: "checkbox empty" },
|
|
17
16
|
{ value: true, label: "selected", icon: "check", description: "checkbox selected" },
|
|
@@ -20,36 +19,41 @@ export default {
|
|
|
20
19
|
},
|
|
21
20
|
argTypes: {
|
|
22
21
|
...getArgTypes(UCheckboxMultiState.name),
|
|
22
|
+
modelValue: { control: { type: "boolean" } },
|
|
23
23
|
},
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
const DefaultTemplate = (args) => ({
|
|
27
27
|
components: { UCheckboxMultiState },
|
|
28
28
|
setup() {
|
|
29
|
-
|
|
29
|
+
const slots = getSlotNames(UCheckboxMultiState.name);
|
|
30
|
+
|
|
31
|
+
return { args, slots };
|
|
30
32
|
},
|
|
31
33
|
template: `
|
|
32
|
-
<UCheckboxMultiState v-bind="args" v-model="args.
|
|
34
|
+
<UCheckboxMultiState v-bind="args" v-model="args.modelValue">
|
|
35
|
+
${args.slotTemplate || getSlotsFragment()}
|
|
36
|
+
</UCheckboxMultiState>
|
|
33
37
|
`,
|
|
34
38
|
});
|
|
35
39
|
|
|
36
|
-
const
|
|
40
|
+
const EnumVariantTemplate = (args, { argTypes } = {}) => ({
|
|
37
41
|
components: { UCheckboxMultiState, URow },
|
|
38
42
|
setup() {
|
|
39
43
|
return {
|
|
40
44
|
args,
|
|
41
|
-
|
|
45
|
+
options: argTypes[args.enum].options,
|
|
42
46
|
};
|
|
43
47
|
},
|
|
44
48
|
template: `
|
|
45
49
|
<URow>
|
|
46
50
|
<UCheckboxMultiState
|
|
47
|
-
v-for="(
|
|
48
|
-
v-bind="args"
|
|
49
|
-
:size="size"
|
|
50
|
-
v-model="args.value"
|
|
51
|
-
:label="size"
|
|
51
|
+
v-for="(option, index) in options"
|
|
52
52
|
:key="index"
|
|
53
|
+
v-bind="args"
|
|
54
|
+
v-model="args.modelValue"
|
|
55
|
+
:[args.enum]="option"
|
|
56
|
+
:label="option"
|
|
53
57
|
/>
|
|
54
58
|
</URow>
|
|
55
59
|
`,
|
|
@@ -58,5 +62,5 @@ const SizesTemplate = (args, { argTypes } = {}) => ({
|
|
|
58
62
|
export const Default = DefaultTemplate.bind({});
|
|
59
63
|
Default.args = {};
|
|
60
64
|
|
|
61
|
-
export const sizes =
|
|
62
|
-
sizes.args = {};
|
|
65
|
+
export const sizes = EnumVariantTemplate.bind({});
|
|
66
|
+
sizes.args = { enum: "size" };
|
|
@@ -11,7 +11,7 @@ export default {
|
|
|
11
11
|
component: UColorPicker,
|
|
12
12
|
args: {
|
|
13
13
|
label: "Label",
|
|
14
|
-
|
|
14
|
+
modelValue: "",
|
|
15
15
|
},
|
|
16
16
|
argTypes: {
|
|
17
17
|
...getArgTypes(UColorPicker.name),
|
|
@@ -26,7 +26,7 @@ const DefaultTemplate = (args) => ({
|
|
|
26
26
|
return { args, slots };
|
|
27
27
|
},
|
|
28
28
|
template: `
|
|
29
|
-
<UColorPicker v-bind="args" v-model="args.
|
|
29
|
+
<UColorPicker v-bind="args" v-model="args.modelValue">
|
|
30
30
|
${args.slotTemplate || getSlotsFragment()}
|
|
31
31
|
</UColorPicker>
|
|
32
32
|
`,
|
|
@@ -46,7 +46,7 @@ const EnumVariantTemplate = (args, { argTypes } = {}) => ({
|
|
|
46
46
|
v-for="(option, index) in options"
|
|
47
47
|
:key="index"
|
|
48
48
|
v-bind="args"
|
|
49
|
-
v-model="args.
|
|
49
|
+
v-model="args.modelValue"
|
|
50
50
|
:[args.enum]="option"
|
|
51
51
|
:name="option"
|
|
52
52
|
/>
|