vueless 0.0.201 → 0.0.202
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 +3 -2
- package/package.json +2 -2
- package/ui.button-link/composables/attrs.composable.js +64 -130
- package/ui.button-link/index.stories.js +2 -4
- package/ui.button-link/index.vue +29 -4
- package/ui.button-toggle/composables/attrs.composable.js +21 -33
- package/ui.button-toggle/configs/default.config.js +2 -2
- package/ui.button-toggle/index.vue +8 -2
- package/ui.button-toggle-item/composables/attrs.composable.js +50 -40
- package/ui.button-toggle-item/configs/default.config.js +1 -1
- package/ui.button-toggle-item/index.stories.js +2 -4
- package/ui.button-toggle-item/index.vue +11 -3
- package/ui.dropdown-badge/composables/attrs.composable.js +45 -45
- package/ui.dropdown-badge/configs/default.config.js +3 -3
- package/ui.dropdown-badge/index.stories.js +2 -4
- package/ui.dropdown-badge/index.vue +8 -2
- package/ui.dropdown-button/composables/attrs.composable.js +45 -45
- package/ui.dropdown-button/configs/default.config.js +3 -3
- package/ui.dropdown-button/index.stories.js +2 -4
- package/ui.dropdown-button/index.vue +8 -2
- package/ui.dropdown-item/index.vue +7 -1
- package/ui.dropdown-link/composables/attrs.composable.js +43 -45
- package/ui.dropdown-link/configs/default.config.js +3 -3
- package/ui.dropdown-link/index.stories.js +2 -4
- package/ui.dropdown-link/index.vue +8 -2
- package/ui.dropdown-list/composables/attrs.composable.js +43 -67
- package/ui.dropdown-list/configs/default.config.js +2 -2
- package/ui.dropdown-list/index.vue +19 -3
- package/ui.form-calendar/components/DayView.vue +4 -4
- package/ui.form-calendar/composables/attrs.composable.js +5 -4
- package/ui.navigation-progress/components/StepperProgress.vue +87 -0
- package/ui.navigation-progress/composables/attrs.composable.js +33 -56
- package/ui.navigation-progress/configs/default.config.js +34 -1
- package/ui.navigation-progress/constants/index.js +5 -0
- package/ui.navigation-progress/index.stories.js +3 -0
- package/ui.navigation-progress/index.vue +55 -9
- package/ui.text-alert/composables/attrs.composable.js +23 -39
- package/ui.text-alert/configs/default.config.js +3 -3
- package/ui.text-alert/index.vue +19 -8
- package/ui.text-badge/composables/attrs.composable.js +25 -36
- package/ui.text-badge/index.stories.js +2 -4
- package/ui.text-badge/index.vue +22 -2
- package/ui.text-block/composables/attrs.composable.js +24 -20
- package/ui.text-block/index.vue +1 -1
- package/ui.text-empty/composables/attrs.composable.js +17 -27
- package/ui.text-empty/configs/default.config.js +1 -1
- package/ui.text-empty/index.stories.js +2 -4
- package/ui.text-empty/index.vue +1 -1
- package/ui.text-header/composables/attrs.composable.js +28 -22
- package/ui.text-header/index.stories.js +1 -1
- package/ui.text-header/index.vue +1 -1
- package/ui.text-money/composables/attrs.composable.js +21 -48
- package/ui.text-money/index.stories.js +2 -4
- package/web-types.json +181 -97
- package/ui.navigation-stepper/Docs.mdx +0 -16
- package/ui.navigation-stepper/composables/attrs.composable.js +0 -25
- package/ui.navigation-stepper/configs/default.config.js +0 -13
- package/ui.navigation-stepper/constants/index.js +0 -5
- package/ui.navigation-stepper/index.stories.js +0 -33
- package/ui.navigation-stepper/index.vue +0 -126
package/composable.ui/index.js
CHANGED
|
@@ -102,11 +102,12 @@ export default function useUI(defaultConfig = {}, propsConfigGetter = null, topL
|
|
|
102
102
|
|
|
103
103
|
const isTopLevelClassKey = configKey === (topLevelClassKey || firstClassKey);
|
|
104
104
|
const attrClass = isTopLevelClassKey && !nestedComponent ? attrs.class : "";
|
|
105
|
-
|
|
105
|
+
// TODO: Uncomment and add into `cx` when getAttrs as a function will be resolved.
|
|
106
|
+
// const classes = toValue(options?.classes) || getBaseClasses(configKeyValue);
|
|
106
107
|
|
|
107
108
|
vuelessAttrs.value = {
|
|
108
109
|
...commonAttrs,
|
|
109
|
-
class: cx([classes, attrClass]),
|
|
110
|
+
class: cx([getBaseClasses(configKeyValue), toValue(options?.classes), attrClass]),
|
|
110
111
|
...((isObject && configAttrs) || {}),
|
|
111
112
|
};
|
|
112
113
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vueless",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.202",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Vue Styleless Component Framework.",
|
|
6
6
|
"homepage": "https://vueless.com",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@release-it/bumper": "^6.0.1",
|
|
38
38
|
"@vitejs/plugin-vue": "^5.0.5",
|
|
39
39
|
"@vue/eslint-config-prettier": "^9.0.0",
|
|
40
|
-
"@vueless/plugin-vite": "^0.0.
|
|
40
|
+
"@vueless/plugin-vite": "^0.0.36",
|
|
41
41
|
"@vueless/storybook": "^0.0.33",
|
|
42
42
|
"@vueless/web-types": "^0.0.13",
|
|
43
43
|
"autoprefixer": "^10.4.19",
|
|
@@ -1,146 +1,80 @@
|
|
|
1
1
|
import { computed, useSlots } from "vue";
|
|
2
|
-
|
|
3
2
|
import useUI from "../../composable.ui";
|
|
4
3
|
import { cva, cx } from "../../service.ui";
|
|
5
|
-
|
|
6
4
|
import defaultConfig from "../configs/default.config";
|
|
7
5
|
|
|
8
|
-
export function useAttrs(props, { isActive, isExactActive }) {
|
|
6
|
+
export default function useAttrs(props, { isActive, isExactActive }) {
|
|
9
7
|
const slots = useSlots();
|
|
10
8
|
|
|
11
|
-
const { config, getAttrs, hasSlotContent, getColor, setColor } = useUI(
|
|
9
|
+
const { config, getAttrs, hasSlotContent, getColor, setColor, isSystemKey } = useUI(
|
|
12
10
|
defaultConfig,
|
|
13
11
|
() => props.config,
|
|
14
12
|
);
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}),
|
|
77
|
-
props.color,
|
|
78
|
-
),
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
const rightSlotClasses = computed(() =>
|
|
82
|
-
setColor(
|
|
83
|
-
cvaRightSlot({
|
|
84
|
-
color: getColor(props.color),
|
|
85
|
-
}),
|
|
86
|
-
props.color,
|
|
87
|
-
),
|
|
88
|
-
);
|
|
89
|
-
|
|
90
|
-
const leftSlotClasses = computed(() =>
|
|
91
|
-
setColor(
|
|
92
|
-
cvaLeftSlot({
|
|
93
|
-
color: getColor(props.color),
|
|
94
|
-
}),
|
|
95
|
-
props.color,
|
|
96
|
-
),
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
const wrapperAttrsRaw = getAttrs("wrapper", { classes: wrapperClasses });
|
|
100
|
-
|
|
101
|
-
const wrapperAttrs = computed(() => {
|
|
102
|
-
const hasDefaultSlot = hasSlotContent(slots["default"]);
|
|
103
|
-
const hasRightSlot = hasSlotContent(slots["right"]);
|
|
104
|
-
const hasLeftSlot = hasSlotContent(slots["left"]);
|
|
105
|
-
|
|
106
|
-
return {
|
|
107
|
-
...wrapperAttrsRaw.value,
|
|
108
|
-
class: cx([
|
|
109
|
-
wrapperAttrsRaw.value.class,
|
|
110
|
-
(hasDefaultSlot || hasLeftSlot || hasRightSlot) && config.value.withSlots,
|
|
111
|
-
isActive.value && props.wrapperActiveClass,
|
|
112
|
-
isExactActive.value && props.wrapperExactActiveClass,
|
|
113
|
-
]),
|
|
114
|
-
};
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
const linkAttrsRaw = getAttrs("link", { classes: linkClasses });
|
|
118
|
-
|
|
119
|
-
const linkAttrs = computed(() => {
|
|
120
|
-
const hasDefaultSlot = hasSlotContent(slots["default"]);
|
|
121
|
-
|
|
122
|
-
return {
|
|
123
|
-
...linkAttrsRaw.value,
|
|
124
|
-
class: cx([
|
|
125
|
-
linkAttrsRaw.value.class,
|
|
126
|
-
hasDefaultSlot && config.value.withSlots,
|
|
127
|
-
isActive.value && props.activeClass,
|
|
128
|
-
isExactActive.value && props.exactActiveClass,
|
|
129
|
-
]),
|
|
130
|
-
};
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
const rightSlotAttrs = getAttrs("rightSlot", { classes: rightSlotClasses });
|
|
134
|
-
const leftSlotAttrs = getAttrs("leftSlot", { classes: leftSlotClasses });
|
|
135
|
-
const textAttrs = getAttrs("text", { classes: textClasses });
|
|
13
|
+
const attrs = {};
|
|
14
|
+
|
|
15
|
+
for (const key in defaultConfig) {
|
|
16
|
+
if (isSystemKey(key)) continue;
|
|
17
|
+
|
|
18
|
+
const classes = computed(() => {
|
|
19
|
+
const value = config.value[key];
|
|
20
|
+
|
|
21
|
+
if (value.variants || value.compoundVariants) {
|
|
22
|
+
return setColor(
|
|
23
|
+
cva(value)({
|
|
24
|
+
...props,
|
|
25
|
+
color: getColor(props.color),
|
|
26
|
+
}),
|
|
27
|
+
props.color,
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return "";
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
attrs[`${key}Attrs`] = getAttrs(key, { classes });
|
|
35
|
+
|
|
36
|
+
if (key === "wrapper") {
|
|
37
|
+
const wrapperAttrs = attrs[`${key}Attrs`];
|
|
38
|
+
|
|
39
|
+
attrs[`${key}Attrs`] = computed(() => {
|
|
40
|
+
const hasDefaultSlot = hasSlotContent(slots["default"]);
|
|
41
|
+
const hasRightSlot = hasSlotContent(slots["right"]);
|
|
42
|
+
const hasLeftSlot = hasSlotContent(slots["left"]);
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
...wrapperAttrs.value,
|
|
46
|
+
class: cx([
|
|
47
|
+
wrapperAttrs.value.class,
|
|
48
|
+
(hasDefaultSlot || hasLeftSlot || hasRightSlot) && config.value.withSlots,
|
|
49
|
+
isActive.value && props.wrapperActiveClass,
|
|
50
|
+
isExactActive.value && props.wrapperExactActiveClass,
|
|
51
|
+
]),
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (key === "link") {
|
|
57
|
+
const linkAttrs = attrs[`${key}Attrs`];
|
|
58
|
+
|
|
59
|
+
attrs[`${key}Attrs`] = computed(() => {
|
|
60
|
+
const hasDefaultSlot = hasSlotContent(slots["default"]);
|
|
61
|
+
|
|
62
|
+
return {
|
|
63
|
+
...linkAttrs.value,
|
|
64
|
+
class: cx([
|
|
65
|
+
linkAttrs.value.class,
|
|
66
|
+
hasDefaultSlot && config.value.withSlots,
|
|
67
|
+
isActive.value && props.activeClass,
|
|
68
|
+
isExactActive.value && props.exactActiveClass,
|
|
69
|
+
]),
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
136
74
|
|
|
137
75
|
return {
|
|
76
|
+
...attrs,
|
|
138
77
|
config,
|
|
139
78
|
hasSlotContent,
|
|
140
|
-
wrapperAttrs,
|
|
141
|
-
linkAttrs,
|
|
142
|
-
rightSlotAttrs,
|
|
143
|
-
leftSlotAttrs,
|
|
144
|
-
textAttrs,
|
|
145
79
|
};
|
|
146
80
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getArgTypes, getSlotNames } from "../service.storybook";
|
|
1
|
+
import { getArgTypes, getSlotNames, allSlotsFragment } from "../service.storybook";
|
|
2
2
|
|
|
3
3
|
import ULink from "../ui.button-link";
|
|
4
4
|
import UButton from "../ui.button";
|
|
@@ -29,9 +29,7 @@ const DefaultTemplate = (args) => ({
|
|
|
29
29
|
},
|
|
30
30
|
template: `
|
|
31
31
|
<ULink v-bind="args">
|
|
32
|
-
|
|
33
|
-
<template v-if="args[slot]">{{ args[slot] }}</template>
|
|
34
|
-
</template>
|
|
32
|
+
${allSlotsFragment}
|
|
35
33
|
</ULink>
|
|
36
34
|
`,
|
|
37
35
|
});
|
package/ui.button-link/index.vue
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div v-bind="wrapperAttrs" ref="wrapperRef" tabindex="-1">
|
|
3
3
|
<div v-if="hasSlotContent($slots['left'])" v-bind="leftSlotAttrs">
|
|
4
|
-
<!-- @slot Use it to add something before text. -->
|
|
4
|
+
<!-- @slot Use it to add something before the text. -->
|
|
5
5
|
<slot name="left" />
|
|
6
6
|
</div>
|
|
7
7
|
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
</a>
|
|
43
43
|
|
|
44
44
|
<div v-if="hasSlotContent($slots['right'])" v-bind="rightSlotAttrs">
|
|
45
|
-
<!-- @slot Use it to add something after text. -->
|
|
45
|
+
<!-- @slot Use it to add something after the text. -->
|
|
46
46
|
<slot name="right" />
|
|
47
47
|
</div>
|
|
48
48
|
</div>
|
|
@@ -53,14 +53,39 @@ import { computed, ref } from "vue";
|
|
|
53
53
|
import { RouterLink, useLink } from "vue-router";
|
|
54
54
|
import UIService from "../service.ui";
|
|
55
55
|
|
|
56
|
-
import
|
|
56
|
+
import useAttrs from "./composables/attrs.composable";
|
|
57
57
|
import defaultConfig from "./configs/default.config";
|
|
58
58
|
import { ULink } from "./constants";
|
|
59
59
|
|
|
60
60
|
/* Should be a string for correct web-types gen */
|
|
61
61
|
defineOptions({ name: "ULink", inheritAttrs: false });
|
|
62
62
|
|
|
63
|
-
const emit = defineEmits([
|
|
63
|
+
const emit = defineEmits([
|
|
64
|
+
/**
|
|
65
|
+
* Triggers when link is clicked.
|
|
66
|
+
*/
|
|
67
|
+
"click",
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Triggers when cursor is on the link.
|
|
71
|
+
*/
|
|
72
|
+
"mouseover",
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Triggers when link is focused.
|
|
76
|
+
*/
|
|
77
|
+
"focus",
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Triggers when link loses focus.
|
|
81
|
+
*/
|
|
82
|
+
"blur",
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Triggers when link is clicked.
|
|
86
|
+
*/
|
|
87
|
+
"keydown",
|
|
88
|
+
]);
|
|
64
89
|
|
|
65
90
|
const props = defineProps({
|
|
66
91
|
/**
|
|
@@ -1,48 +1,36 @@
|
|
|
1
1
|
import { computed } from "vue";
|
|
2
2
|
import useUI from "../../composable.ui";
|
|
3
3
|
import { cva } from "../../service.ui";
|
|
4
|
-
|
|
5
4
|
import defaultConfig from "../configs/default.config";
|
|
6
5
|
|
|
7
|
-
export function useAttrs(props) {
|
|
8
|
-
const { config, getAttrs } = useUI(
|
|
9
|
-
|
|
6
|
+
export default function useAttrs(props) {
|
|
7
|
+
const { config, getAttrs, hasSlotContent, isSystemKey } = useUI(
|
|
8
|
+
defaultConfig,
|
|
9
|
+
() => props.config,
|
|
10
|
+
);
|
|
11
|
+
const attrs = {};
|
|
10
12
|
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
variants: items.variants,
|
|
14
|
-
compoundVariants: items.compoundVariants,
|
|
15
|
-
});
|
|
13
|
+
for (const key in defaultConfig) {
|
|
14
|
+
if (isSystemKey(key)) continue;
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
variants: label.variants,
|
|
20
|
-
compoundVariants: label.compoundVariants,
|
|
21
|
-
});
|
|
16
|
+
const classes = computed(() => {
|
|
17
|
+
const value = config.value[key];
|
|
22
18
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
separated: props.separated,
|
|
29
|
-
}),
|
|
30
|
-
);
|
|
19
|
+
if (value.variants || value.compoundVariants) {
|
|
20
|
+
return cva(value)({
|
|
21
|
+
...props,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
31
24
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
block: props.block,
|
|
35
|
-
}),
|
|
36
|
-
);
|
|
25
|
+
return "";
|
|
26
|
+
});
|
|
37
27
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const itemAttrs = getAttrs("item", { isComponent: true });
|
|
28
|
+
attrs[`${key}Attrs`] = getAttrs(key, { classes });
|
|
29
|
+
}
|
|
41
30
|
|
|
42
31
|
return {
|
|
32
|
+
...attrs,
|
|
43
33
|
config,
|
|
44
|
-
|
|
45
|
-
itemsAttrs,
|
|
46
|
-
itemAttrs,
|
|
34
|
+
hasSlotContent,
|
|
47
35
|
};
|
|
48
36
|
}
|
|
@@ -24,14 +24,14 @@ export default /*tw*/ {
|
|
|
24
24
|
],
|
|
25
25
|
},
|
|
26
26
|
label: {
|
|
27
|
-
base: "flex flex-wrap",
|
|
27
|
+
base: "{ULabel} flex flex-wrap",
|
|
28
28
|
variants: {
|
|
29
29
|
block: {
|
|
30
30
|
true: "w-full",
|
|
31
31
|
},
|
|
32
32
|
},
|
|
33
33
|
},
|
|
34
|
-
item: "",
|
|
34
|
+
item: "{UToggleItem}",
|
|
35
35
|
defaultVariants: {
|
|
36
36
|
variant: "primary",
|
|
37
37
|
labelAlign: "top",
|
|
@@ -36,7 +36,7 @@ import UIService from "../service.ui";
|
|
|
36
36
|
|
|
37
37
|
import defaultConfig from "./configs/default.config";
|
|
38
38
|
import { UToggle, TYPE_RADIO, TYPE_CHECKBOX } from "./constants";
|
|
39
|
-
import
|
|
39
|
+
import useAttrs from "./composables/attrs.composable";
|
|
40
40
|
|
|
41
41
|
/* Should be a string for correct web-types gen */
|
|
42
42
|
defineOptions({ name: "UToggle", inheritAttrs: false });
|
|
@@ -174,7 +174,13 @@ const props = defineProps({
|
|
|
174
174
|
},
|
|
175
175
|
});
|
|
176
176
|
|
|
177
|
-
const emit = defineEmits([
|
|
177
|
+
const emit = defineEmits([
|
|
178
|
+
/**
|
|
179
|
+
* Triggers when toggle item is selected.
|
|
180
|
+
* @property {string} modelValue
|
|
181
|
+
*/
|
|
182
|
+
"update:modelValue",
|
|
183
|
+
]);
|
|
178
184
|
|
|
179
185
|
const { labelAttrs, itemsAttrs, itemAttrs } = useAttrs(props);
|
|
180
186
|
|
|
@@ -1,54 +1,64 @@
|
|
|
1
1
|
import { computed, toValue } from "vue";
|
|
2
|
-
import { cx, cva } from "../../service.ui";
|
|
3
2
|
import useUI from "../../composable.ui";
|
|
4
|
-
|
|
3
|
+
import { cx, cva } from "../../service.ui";
|
|
5
4
|
import defaultConfig from "../configs/default.config";
|
|
6
5
|
|
|
7
|
-
export function useAttrs(props, { selectedValue, separated, variant }) {
|
|
8
|
-
const { config, getAttrs } = useUI(
|
|
9
|
-
|
|
6
|
+
export default function useAttrs(props, { selectedValue, separated, variant }) {
|
|
7
|
+
const { config, getAttrs, isSystemKey, hasSlotContent } = useUI(
|
|
8
|
+
defaultConfig,
|
|
9
|
+
() => props.config,
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
const skipKeys = ["selected"];
|
|
13
|
+
|
|
14
|
+
const attrs = {};
|
|
10
15
|
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
variants: button.variants,
|
|
14
|
-
compoundVariants: button.compoundVariants,
|
|
15
|
-
});
|
|
16
|
+
for (const key in defaultConfig) {
|
|
17
|
+
if (isSystemKey(key) || skipKeys.includes(key)) continue;
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const classes = computed(() => {
|
|
20
|
+
const value = config.value[key];
|
|
21
|
+
|
|
22
|
+
if (value.variants || value.compoundVariants) {
|
|
23
|
+
return cva(value)({
|
|
24
|
+
...props,
|
|
25
|
+
variant: toValue(variant),
|
|
26
|
+
separated: toValue(separated),
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return "";
|
|
21
31
|
});
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
const cvaSelected = cva({
|
|
25
|
-
base: selected.base,
|
|
26
|
-
variants: selected.variants,
|
|
27
|
-
compoundVariants: selected.compoundVariants,
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
const selectedClasses = computed(() =>
|
|
31
|
-
cvaSelected({
|
|
32
|
-
variant: toValue(variant),
|
|
33
|
-
}),
|
|
34
|
-
);
|
|
35
32
|
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
attrs[`${key}Attrs`] = getAttrs(key, { classes });
|
|
34
|
+
|
|
35
|
+
if (key === "button") {
|
|
36
|
+
const selectedClasses = computed(() =>
|
|
37
|
+
cva(config.value.selected)({
|
|
38
|
+
...props,
|
|
39
|
+
variant: toValue(variant),
|
|
40
|
+
separated: toValue(separated),
|
|
41
|
+
}),
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
const buttonAttrs = attrs[`${key}Attrs`];
|
|
38
45
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
46
|
+
attrs[`${key}Attrs`] = computed(() => {
|
|
47
|
+
const isSelected = Array.isArray(selectedValue?.value)
|
|
48
|
+
? selectedValue?.value?.includes(props.value)
|
|
49
|
+
: selectedValue?.value === props.value;
|
|
43
50
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
51
|
+
return {
|
|
52
|
+
...buttonAttrs.value,
|
|
53
|
+
class: cx([buttonAttrs.value.class, isSelected && selectedClasses.value]),
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
49
58
|
|
|
50
59
|
return {
|
|
51
|
-
|
|
52
|
-
|
|
60
|
+
...attrs,
|
|
61
|
+
config,
|
|
62
|
+
hasSlotContent,
|
|
53
63
|
};
|
|
54
64
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export default /*tw*/ {
|
|
2
2
|
button: {
|
|
3
3
|
base: `
|
|
4
|
-
border-gray-300 font-normal
|
|
4
|
+
{UButton} border-gray-300 font-normal
|
|
5
5
|
hover:text-brand-600 hover:border-brand-600 hover:relative hover:z-10
|
|
6
6
|
focus:text-brand-600 focus:border-brand-600 focus:relative focus:z-10 focus:ring-brand-600 focus-within:ring-brand-600
|
|
7
7
|
active:text-brand-700 active:border-brand-700 active:relative active:z-10
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getArgTypes, getSlotNames } from "../service.storybook";
|
|
1
|
+
import { getArgTypes, getSlotNames, allSlotsFragment } from "../service.storybook";
|
|
2
2
|
|
|
3
3
|
import UToggleItem from "../ui.button-toggle-item";
|
|
4
4
|
import UIcon from "../ui.image-icon";
|
|
@@ -29,9 +29,7 @@ const DefaultTemplate = (args) => ({
|
|
|
29
29
|
},
|
|
30
30
|
template: `
|
|
31
31
|
<UToggleItem v-bind="args" name="toggle">
|
|
32
|
-
|
|
33
|
-
<template v-if="args[slot]">{{ args[slot] }}</template>
|
|
34
|
-
</template>
|
|
32
|
+
${allSlotsFragment}
|
|
35
33
|
</UToggleItem>
|
|
36
34
|
`,
|
|
37
35
|
});
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
@click.stop="onClickSetValue"
|
|
15
15
|
>
|
|
16
16
|
<template #left>
|
|
17
|
+
<!-- @slot Use it to add something before the text. -->
|
|
17
18
|
<slot name="left" />
|
|
18
19
|
</template>
|
|
19
20
|
|
|
@@ -28,11 +29,12 @@
|
|
|
28
29
|
v-bind="inputAttrs"
|
|
29
30
|
@click.stop
|
|
30
31
|
/>
|
|
31
|
-
|
|
32
|
+
<!-- @slot Use it to add something instead of the text. -->
|
|
32
33
|
<slot name="default" />
|
|
33
34
|
</template>
|
|
34
35
|
|
|
35
36
|
<template #right>
|
|
37
|
+
<!-- @slot Use it to add something after the text. -->
|
|
36
38
|
<slot name="right" />
|
|
37
39
|
</template>
|
|
38
40
|
</UButton>
|
|
@@ -46,7 +48,7 @@ import UIService, { getRandomId } from "../service.ui";
|
|
|
46
48
|
|
|
47
49
|
import { TYPE_RADIO } from "../ui.button-toggle/constants";
|
|
48
50
|
|
|
49
|
-
import
|
|
51
|
+
import useAttrs from "./composables/attrs.composable";
|
|
50
52
|
import defaultConfig from "./configs/default.config";
|
|
51
53
|
import { UToggleItem } from "./constants";
|
|
52
54
|
|
|
@@ -112,7 +114,13 @@ const props = defineProps({
|
|
|
112
114
|
},
|
|
113
115
|
});
|
|
114
116
|
|
|
115
|
-
const emit = defineEmits([
|
|
117
|
+
const emit = defineEmits([
|
|
118
|
+
/**
|
|
119
|
+
* Triggers when new value is set.
|
|
120
|
+
* @property {string} modelValue
|
|
121
|
+
*/
|
|
122
|
+
"update:modelValue",
|
|
123
|
+
]);
|
|
116
124
|
|
|
117
125
|
const name = inject("toggleName", () => "toggle");
|
|
118
126
|
const type = inject("toggleType", UIService.get(defaultConfig, UToggleItem).default.type);
|