vueless 0.0.200 → 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/service.storybook/index.js +1 -1
- package/ui.button/composables/attrs.composable.js +6 -2
- package/ui.button/configs/default.config.js +14 -2
- package/ui.button/index.stories.js +27 -3
- package/ui.button/index.vue +70 -27
- 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.form-input/composables/attrs.composable.js +31 -48
- package/ui.form-input/configs/default.config.js +3 -3
- package/ui.form-input/index.stories.js +32 -9
- package/ui.form-input/index.vue +92 -41
- 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 +326 -145
- 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",
|
|
@@ -108,7 +108,7 @@ export function getArgTypes(componentName) {
|
|
|
108
108
|
});
|
|
109
109
|
|
|
110
110
|
types[event.name] = {
|
|
111
|
-
type: event.properties ?
|
|
111
|
+
type: event.properties ? properties.join(", ") : null,
|
|
112
112
|
name: event.name,
|
|
113
113
|
description: event.description,
|
|
114
114
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { computed } from "vue";
|
|
1
|
+
import { computed, useSlots } from "vue";
|
|
2
2
|
import useUI from "../../composable.ui";
|
|
3
3
|
import { cva } from "../../service.ui";
|
|
4
4
|
import defaultConfig from "../configs/default.config";
|
|
5
5
|
|
|
6
6
|
export default function useAttrs(props) {
|
|
7
|
-
const
|
|
7
|
+
const slots = useSlots();
|
|
8
|
+
const { config, getAttrs, getColor, setColor, hasSlotContent, isSystemKey } = useUI(
|
|
8
9
|
defaultConfig,
|
|
9
10
|
() => props.config,
|
|
10
11
|
);
|
|
@@ -21,6 +22,9 @@ export default function useAttrs(props) {
|
|
|
21
22
|
cva(value)({
|
|
22
23
|
...props,
|
|
23
24
|
color: getColor(props.color),
|
|
25
|
+
square: props.loading || props.square,
|
|
26
|
+
iconLeft: Boolean(props.iconLeft) || hasSlotContent(slots["icon-left"]),
|
|
27
|
+
iconRight: Boolean(props.iconRight) || hasSlotContent(slots["icon-right"]),
|
|
24
28
|
}),
|
|
25
29
|
props.color,
|
|
26
30
|
);
|
|
@@ -130,12 +130,24 @@ export default /*tw*/ {
|
|
|
130
130
|
class: "bg-gray-800 bg-opacity-10 hover:bg-opacity-15 focus:bg-opacity-15 active:bg-opacity-20",
|
|
131
131
|
},
|
|
132
132
|
{ filled: true, variant: "thirdary", color: "white", class: "bg-gray-50" },
|
|
133
|
-
{ square: true, size: "
|
|
133
|
+
{ square: true, size: "2xs", class: "p-1" },
|
|
134
134
|
{ square: true, size: "xs", class: "p-1.5" },
|
|
135
135
|
{ square: true, size: "sm", class: "p-2.5" },
|
|
136
136
|
{ square: true, size: "md", class: "p-3.5" },
|
|
137
137
|
{ square: true, size: "lg", class: "p-4" },
|
|
138
|
-
{ square: true, size: "
|
|
138
|
+
{ square: true, size: "xl", class: "p-5" },
|
|
139
|
+
{ iconLeft: true, size: "2xs", class: "pl-1" },
|
|
140
|
+
{ iconLeft: true, size: "xs", class: "pl-1.5" },
|
|
141
|
+
{ iconLeft: true, size: "sm", class: "pl-2.5" },
|
|
142
|
+
{ iconLeft: true, size: "md", class: "pl-3.5" },
|
|
143
|
+
{ iconLeft: true, size: "lg", class: "pl-4" },
|
|
144
|
+
{ iconLeft: true, size: "xl", class: "pl-5" },
|
|
145
|
+
{ iconRight: true, size: "2xs", class: "pr-1" },
|
|
146
|
+
{ iconRight: true, size: "xs", class: "pr-1.5" },
|
|
147
|
+
{ iconRight: true, size: "sm", class: "pr-2.5" },
|
|
148
|
+
{ iconRight: true, size: "md", class: "pr-3.5" },
|
|
149
|
+
{ iconRight: true, size: "lg", class: "pr-4" },
|
|
150
|
+
{ iconRight: true, size: "xl", class: "pr-5" },
|
|
139
151
|
],
|
|
140
152
|
},
|
|
141
153
|
text: "whitespace-nowrap focus-visible:outline-none",
|
|
@@ -41,7 +41,7 @@ const SlotTemplate = (args) => ({
|
|
|
41
41
|
},
|
|
42
42
|
template: `
|
|
43
43
|
<UButton v-bind="args">
|
|
44
|
-
${args.slotTemplate
|
|
44
|
+
${args.slotTemplate}
|
|
45
45
|
</UButton>
|
|
46
46
|
`,
|
|
47
47
|
});
|
|
@@ -153,7 +153,7 @@ slotDefault.args = {
|
|
|
153
153
|
export const iconLeftSlot = SlotTemplate.bind({});
|
|
154
154
|
iconLeftSlot.args = {
|
|
155
155
|
slotTemplate: `
|
|
156
|
-
<template #left>
|
|
156
|
+
<template #icon-left>
|
|
157
157
|
<UIcon
|
|
158
158
|
name="star"
|
|
159
159
|
color="green"
|
|
@@ -165,7 +165,7 @@ iconLeftSlot.args = {
|
|
|
165
165
|
export const iconRightSlot = SlotTemplate.bind({});
|
|
166
166
|
iconRightSlot.args = {
|
|
167
167
|
slotTemplate: `
|
|
168
|
-
<template #right>
|
|
168
|
+
<template #icon-right>
|
|
169
169
|
<UIcon
|
|
170
170
|
name="star"
|
|
171
171
|
color="green"
|
|
@@ -173,3 +173,27 @@ iconRightSlot.args = {
|
|
|
173
173
|
</template>
|
|
174
174
|
`,
|
|
175
175
|
};
|
|
176
|
+
|
|
177
|
+
export const leftSlot = SlotTemplate.bind({});
|
|
178
|
+
leftSlot.args = {
|
|
179
|
+
slotTemplate: `
|
|
180
|
+
<template #left>
|
|
181
|
+
<UIcon
|
|
182
|
+
name="archive"
|
|
183
|
+
color="red"
|
|
184
|
+
/>
|
|
185
|
+
</template>
|
|
186
|
+
`,
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
export const rightSlot = SlotTemplate.bind({});
|
|
190
|
+
rightSlot.args = {
|
|
191
|
+
slotTemplate: `
|
|
192
|
+
<template #right>
|
|
193
|
+
<UIcon
|
|
194
|
+
name="archive"
|
|
195
|
+
color="red"
|
|
196
|
+
/>
|
|
197
|
+
</template>
|
|
198
|
+
`,
|
|
199
|
+
};
|
package/ui.button/index.vue
CHANGED
|
@@ -14,19 +14,49 @@
|
|
|
14
14
|
</template>
|
|
15
15
|
|
|
16
16
|
<template v-else>
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
<div v-if="hasSlotContent($slots['icon-left']) || iconLeft">
|
|
18
|
+
<!--
|
|
19
|
+
@slot Use it to add icon before the text.
|
|
20
|
+
@binding {string} icon-name
|
|
21
|
+
@binding {string} icon-size
|
|
22
|
+
@binding {string} icon-color
|
|
23
|
+
-->
|
|
24
|
+
<slot
|
|
25
|
+
name="icon-left"
|
|
26
|
+
:icon-name="iconLeft"
|
|
27
|
+
:icon-size="iconSize"
|
|
28
|
+
:icon-color="componentColor"
|
|
29
|
+
>
|
|
30
|
+
<UIcon v-if="iconLeft" :name="iconLeft" :size="iconSize" :color="componentColor" />
|
|
31
|
+
</slot>
|
|
32
|
+
</div>
|
|
33
|
+
|
|
34
|
+
<!-- @slot Use it to add something before the text. -->
|
|
35
|
+
<slot name="left" />
|
|
36
|
+
|
|
37
|
+
<!-- @slot Use it to add something instead of the text. -->
|
|
23
38
|
<slot />
|
|
24
39
|
<div v-if="label" v-bind="textAttrs" tabindex="-1" v-text="label" />
|
|
25
40
|
|
|
26
|
-
<!-- @slot Use it to add
|
|
27
|
-
<slot name="right"
|
|
28
|
-
|
|
29
|
-
|
|
41
|
+
<!-- @slot Use it to add something after the text. -->
|
|
42
|
+
<slot name="right" />
|
|
43
|
+
|
|
44
|
+
<div v-if="hasSlotContent($slots['icon-right']) || iconRight">
|
|
45
|
+
<!--
|
|
46
|
+
@slot Use it to add icon after the text.
|
|
47
|
+
@binding {string} icon-name
|
|
48
|
+
@binding {string} icon-size
|
|
49
|
+
@binding {string} icon-color
|
|
50
|
+
-->
|
|
51
|
+
<slot
|
|
52
|
+
name="icon-right"
|
|
53
|
+
:icon-name="iconRight"
|
|
54
|
+
:icon-size="iconSize"
|
|
55
|
+
:icon-color="componentColor"
|
|
56
|
+
>
|
|
57
|
+
<UIcon v-if="iconRight" :name="iconRight" :size="iconSize" :color="componentColor" />
|
|
58
|
+
</slot>
|
|
59
|
+
</div>
|
|
30
60
|
</template>
|
|
31
61
|
</component>
|
|
32
62
|
</template>
|
|
@@ -73,6 +103,22 @@ const props = defineProps({
|
|
|
73
103
|
default: UIService.get(defaultConfig, UButton).default.size,
|
|
74
104
|
},
|
|
75
105
|
|
|
106
|
+
/**
|
|
107
|
+
* Left side icon name.
|
|
108
|
+
*/
|
|
109
|
+
iconLeft: {
|
|
110
|
+
type: String,
|
|
111
|
+
default: "",
|
|
112
|
+
},
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Right side icon name.
|
|
116
|
+
*/
|
|
117
|
+
iconRight: {
|
|
118
|
+
type: String,
|
|
119
|
+
default: "",
|
|
120
|
+
},
|
|
121
|
+
|
|
76
122
|
/**
|
|
77
123
|
* Button label.
|
|
78
124
|
*/
|
|
@@ -161,25 +207,9 @@ const props = defineProps({
|
|
|
161
207
|
type: String,
|
|
162
208
|
default: "",
|
|
163
209
|
},
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Left side icon name.
|
|
167
|
-
*/
|
|
168
|
-
iconLeft: {
|
|
169
|
-
type: String,
|
|
170
|
-
default: "",
|
|
171
|
-
},
|
|
172
|
-
|
|
173
|
-
/**
|
|
174
|
-
* Right side icon name.
|
|
175
|
-
*/
|
|
176
|
-
iconRight: {
|
|
177
|
-
type: String,
|
|
178
|
-
default: "",
|
|
179
|
-
},
|
|
180
210
|
});
|
|
181
211
|
|
|
182
|
-
const { buttonAttrs, loaderAttrs, textAttrs } = useAttrs(props);
|
|
212
|
+
const { buttonAttrs, loaderAttrs, textAttrs, hasSlotContent } = useAttrs(props);
|
|
183
213
|
|
|
184
214
|
const buttonRef = ref(null);
|
|
185
215
|
|
|
@@ -198,6 +228,19 @@ const loaderSize = computed(() => {
|
|
|
198
228
|
return sizes[props.size];
|
|
199
229
|
});
|
|
200
230
|
|
|
231
|
+
const iconSize = computed(() => {
|
|
232
|
+
const sizes = {
|
|
233
|
+
"2xs": "sm",
|
|
234
|
+
xs: "sm",
|
|
235
|
+
sm: "md",
|
|
236
|
+
md: "md",
|
|
237
|
+
lg: "lg",
|
|
238
|
+
xl: "lg",
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
return sizes[props.size];
|
|
242
|
+
});
|
|
243
|
+
|
|
201
244
|
const componentColor = computed(() => {
|
|
202
245
|
return props.variant === "primary" ? "white" : props.color;
|
|
203
246
|
});
|
|
@@ -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
|
|