vueless 0.0.504 → 0.0.506
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/package.json +1 -1
- package/types.ts +6 -0
- package/ui.button/UButton.vue +106 -240
- package/ui.button/config.ts +167 -0
- package/ui.button/storybook/Docs.mdx +2 -2
- package/ui.button/storybook/{stories.js → stories.ts} +36 -16
- package/ui.button/types.ts +121 -0
- package/ui.button/{useAttrs.js → useAttrs.ts} +6 -3
- package/ui.button-link/ULink.vue +72 -223
- package/ui.button-link/storybook/Docs.mdx +2 -2
- package/ui.button-link/storybook/{stories.js → stories.ts} +30 -17
- package/ui.button-link/types.ts +131 -0
- package/ui.button-link/{useAttrs.js → useAttrs.ts} +15 -3
- package/ui.button-toggle/UToggle.vue +47 -165
- package/ui.button-toggle/storybook/Docs.mdx +2 -2
- package/ui.button-toggle/storybook/{stories.js → stories.ts} +13 -5
- package/ui.button-toggle/types.ts +85 -0
- package/ui.button-toggle/useAttrs.ts +18 -0
- package/ui.button-toggle-item/UToggleItem.vue +59 -110
- package/ui.button-toggle-item/storybook/Docs.mdx +2 -2
- package/ui.button-toggle-item/storybook/{stories.js → stories.ts} +10 -3
- package/ui.button-toggle-item/types.ts +40 -0
- package/ui.button-toggle-item/{useAttrs.js → useAttrs.ts} +16 -4
- package/ui.image-icon/UIcon.vue +1 -1
- package/ui.image-icon/config.ts +5 -4
- package/ui.loader/ULoader.vue +1 -1
- package/ui.loader/config.js +2 -1
- package/ui.loader-overlay/ULoaderOverlay.vue +1 -1
- package/web-types.json +137 -59
- package/ui.button/config.js +0 -164
- package/ui.button-toggle/useAttrs.js +0 -15
- /package/ui.button/{constants.js → constants.ts} +0 -0
- /package/ui.button-link/{config.js → config.ts} +0 -0
- /package/ui.button-link/{constants.js → constants.ts} +0 -0
- /package/ui.button-toggle/{config.js → config.ts} +0 -0
- /package/ui.button-toggle/{constants.js → constants.ts} +0 -0
- /package/ui.button-toggle-item/{config.js → config.ts} +0 -0
- /package/ui.button-toggle-item/{constants.js → constants.ts} +0 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import defaultConfig from "./config.ts";
|
|
2
|
+
|
|
3
|
+
export type Config = Partial<typeof defaultConfig>;
|
|
4
|
+
|
|
5
|
+
export interface UButtonProps {
|
|
6
|
+
/**
|
|
7
|
+
* Button variant.
|
|
8
|
+
*/
|
|
9
|
+
variant?: "primary" | "secondary" | "thirdary";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Button color.
|
|
13
|
+
*/
|
|
14
|
+
color?:
|
|
15
|
+
| "brand"
|
|
16
|
+
| "grayscale"
|
|
17
|
+
| "gray"
|
|
18
|
+
| "red"
|
|
19
|
+
| "orange"
|
|
20
|
+
| "amber"
|
|
21
|
+
| "yellow"
|
|
22
|
+
| "lime"
|
|
23
|
+
| "green"
|
|
24
|
+
| "emerald"
|
|
25
|
+
| "teal"
|
|
26
|
+
| "cyan"
|
|
27
|
+
| "sky"
|
|
28
|
+
| "blue"
|
|
29
|
+
| "indigo"
|
|
30
|
+
| "violet"
|
|
31
|
+
| "purple"
|
|
32
|
+
| "fuchsia"
|
|
33
|
+
| "pink"
|
|
34
|
+
| "rose"
|
|
35
|
+
| "white";
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Button size.
|
|
39
|
+
*/
|
|
40
|
+
size?: "2xs" | "xs" | "sm" | "md" | "lg" | "xl";
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Button label.
|
|
44
|
+
*/
|
|
45
|
+
label?: string;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Allows changing button html tag.
|
|
49
|
+
*/
|
|
50
|
+
tag?: string;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Icon name (appears instead of label).
|
|
54
|
+
*/
|
|
55
|
+
icon?: string;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Left icon name.
|
|
59
|
+
*/
|
|
60
|
+
leftIcon?: string;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Right icon name.
|
|
64
|
+
*/
|
|
65
|
+
rightIcon?: string;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Controls the keyboard “Tab” focus order of elements.
|
|
69
|
+
*/
|
|
70
|
+
tabindex?: string | number;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Fill the background for thirdary variant.
|
|
74
|
+
*/
|
|
75
|
+
filled?: boolean;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Disable the button.
|
|
79
|
+
*/
|
|
80
|
+
disabled?: boolean;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Make the Button fill the width with its container.
|
|
84
|
+
*/
|
|
85
|
+
block?: boolean;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Set button corners rounded.
|
|
89
|
+
*/
|
|
90
|
+
round?: boolean;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Set the same paddings for the button.
|
|
94
|
+
*/
|
|
95
|
+
square?: boolean;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Enable loader.
|
|
99
|
+
*/
|
|
100
|
+
loading?: boolean;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Remove button ring on focus.
|
|
104
|
+
*/
|
|
105
|
+
noRing?: boolean;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Unique element id.
|
|
109
|
+
*/
|
|
110
|
+
id?: string;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Component config object.
|
|
114
|
+
*/
|
|
115
|
+
config?: Partial<typeof defaultConfig>;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Data-test attribute for automated testing.
|
|
119
|
+
*/
|
|
120
|
+
dataTest?: string;
|
|
121
|
+
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { useSlots, computed } from "vue";
|
|
2
2
|
import useUI from "../composables/useUI.ts";
|
|
3
3
|
|
|
4
|
-
import defaultConfig from "./config.
|
|
4
|
+
import defaultConfig from "./config.ts";
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
import type { UseAttrs } from "../types.ts";
|
|
7
|
+
import type { UButtonProps, Config } from "./types.ts";
|
|
8
|
+
|
|
9
|
+
export default function useAttrs(props: UButtonProps): UseAttrs<Config> {
|
|
10
|
+
const { config, getKeysAttrs, hasSlotContent } = useUI<Config>(defaultConfig, () => props.config);
|
|
8
11
|
const slots = useSlots();
|
|
9
12
|
|
|
10
13
|
const mutatedProps = computed(() => ({
|
package/ui.button-link/ULink.vue
CHANGED
|
@@ -1,60 +1,36 @@
|
|
|
1
|
-
<
|
|
2
|
-
<div v-bind="wrapperAttrs" ref="wrapperRef" tabindex="-1">
|
|
3
|
-
<!-- @slot Use it to add something before the label. -->
|
|
4
|
-
<slot name="left" />
|
|
5
|
-
|
|
6
|
-
<router-link
|
|
7
|
-
v-if="isPresentRoute"
|
|
8
|
-
:to="route"
|
|
9
|
-
:target="targetValue"
|
|
10
|
-
v-bind="linkAttrs"
|
|
11
|
-
:data-test="dataTest"
|
|
12
|
-
tabindex="0"
|
|
13
|
-
@blur="onBlur"
|
|
14
|
-
@focus="onFocus"
|
|
15
|
-
@click="onClick"
|
|
16
|
-
@keydown="onKeydown"
|
|
17
|
-
@mouseover="onMouseover"
|
|
18
|
-
>
|
|
19
|
-
<!-- @slot Use it replace the label. -->
|
|
20
|
-
<slot>
|
|
21
|
-
{{ label }}
|
|
22
|
-
</slot>
|
|
23
|
-
</router-link>
|
|
24
|
-
|
|
25
|
-
<a
|
|
26
|
-
v-else
|
|
27
|
-
:href="prefixedHref"
|
|
28
|
-
:target="targetValue"
|
|
29
|
-
v-bind="linkAttrs"
|
|
30
|
-
:data-test="dataTest"
|
|
31
|
-
tabindex="0"
|
|
32
|
-
@blur="onBlur"
|
|
33
|
-
@focus="onFocus"
|
|
34
|
-
@click="onClick"
|
|
35
|
-
@keydown="onKeydown"
|
|
36
|
-
@mouseover="onMouseover"
|
|
37
|
-
>
|
|
38
|
-
<!-- @slot Use it replace the label. -->
|
|
39
|
-
<slot>{{ label }}</slot>
|
|
40
|
-
</a>
|
|
41
|
-
|
|
42
|
-
<!-- @slot Use it to add something after the label. -->
|
|
43
|
-
<slot name="right" />
|
|
44
|
-
</div>
|
|
45
|
-
</template>
|
|
46
|
-
|
|
47
|
-
<script setup>
|
|
1
|
+
<script lang="ts" setup>
|
|
48
2
|
import { computed, ref } from "vue";
|
|
49
3
|
import { RouterLink, useLink } from "vue-router";
|
|
50
4
|
import { getDefault } from "../utils/ui.ts";
|
|
51
5
|
|
|
52
|
-
import useAttrs from "./useAttrs.
|
|
53
|
-
import defaultConfig from "./config.
|
|
54
|
-
import { ULink } from "./constants.
|
|
6
|
+
import useAttrs from "./useAttrs.ts";
|
|
7
|
+
import defaultConfig from "./config.ts";
|
|
8
|
+
import { ULink } from "./constants.ts";
|
|
9
|
+
|
|
10
|
+
import type { ULinkProps } from "./types.ts";
|
|
55
11
|
|
|
56
12
|
defineOptions({ inheritAttrs: false });
|
|
57
13
|
|
|
14
|
+
const props = withDefaults(defineProps<ULinkProps>(), {
|
|
15
|
+
size: getDefault<ULinkProps>(defaultConfig, ULink).size,
|
|
16
|
+
color: getDefault<ULinkProps>(defaultConfig, ULink).color,
|
|
17
|
+
type: getDefault<ULinkProps>(defaultConfig, ULink).type,
|
|
18
|
+
targetBlank: getDefault<ULinkProps>(defaultConfig, ULink).targetBlank,
|
|
19
|
+
ariaCurrentValue: getDefault<ULinkProps>(defaultConfig, ULink).ariaCurrentValue,
|
|
20
|
+
custom: getDefault<ULinkProps>(defaultConfig, ULink).custom,
|
|
21
|
+
replace: getDefault<ULinkProps>(defaultConfig, ULink).replace,
|
|
22
|
+
activeClass: getDefault<ULinkProps>(defaultConfig, ULink).activeClass,
|
|
23
|
+
exactActiveClass: getDefault<ULinkProps>(defaultConfig, ULink).exactActiveClass,
|
|
24
|
+
wrapperActiveClass: getDefault<ULinkProps>(defaultConfig, ULink).wrapperActiveClass,
|
|
25
|
+
wrapperExactActiveClass: getDefault<ULinkProps>(defaultConfig, ULink).wrapperExactActiveClass,
|
|
26
|
+
underlined: getDefault<ULinkProps>(defaultConfig, ULink).underlined,
|
|
27
|
+
dashed: getDefault<ULinkProps>(defaultConfig, ULink).dashed,
|
|
28
|
+
disabled: getDefault<ULinkProps>(defaultConfig, ULink).disabled,
|
|
29
|
+
block: getDefault<ULinkProps>(defaultConfig, ULink).block,
|
|
30
|
+
noRing: getDefault<ULinkProps>(defaultConfig, ULink).noRing,
|
|
31
|
+
dataTest: "",
|
|
32
|
+
});
|
|
33
|
+
|
|
58
34
|
const emit = defineEmits([
|
|
59
35
|
/**
|
|
60
36
|
* Triggers when link is clicked.
|
|
@@ -82,179 +58,6 @@ const emit = defineEmits([
|
|
|
82
58
|
"keydown",
|
|
83
59
|
]);
|
|
84
60
|
|
|
85
|
-
const props = defineProps({
|
|
86
|
-
/**
|
|
87
|
-
* Button label.
|
|
88
|
-
*/
|
|
89
|
-
label: {
|
|
90
|
-
type: String,
|
|
91
|
-
default: "",
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Link href url.
|
|
96
|
-
*/
|
|
97
|
-
href: {
|
|
98
|
-
type: String,
|
|
99
|
-
default: "",
|
|
100
|
-
},
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Vue-router route object.
|
|
104
|
-
*/
|
|
105
|
-
to: {
|
|
106
|
-
type: Object,
|
|
107
|
-
default: () => ({}),
|
|
108
|
-
},
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Link size.
|
|
112
|
-
* @values sm, md, lg
|
|
113
|
-
*/
|
|
114
|
-
size: {
|
|
115
|
-
type: String,
|
|
116
|
-
default: getDefault(defaultConfig, ULink).size,
|
|
117
|
-
},
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Link color.
|
|
121
|
-
* @values brand, grayscale, gray, red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose, white
|
|
122
|
-
*/
|
|
123
|
-
color: {
|
|
124
|
-
type: String,
|
|
125
|
-
default: getDefault(defaultConfig, ULink).color,
|
|
126
|
-
},
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Link open type behaviour.
|
|
130
|
-
* @values phone, email, link
|
|
131
|
-
*/
|
|
132
|
-
type: {
|
|
133
|
-
type: String,
|
|
134
|
-
default: getDefault(defaultConfig, ULink).type,
|
|
135
|
-
},
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Open link in the new tab.
|
|
139
|
-
*/
|
|
140
|
-
targetBlank: {
|
|
141
|
-
type: Boolean,
|
|
142
|
-
default: getDefault(defaultConfig, ULink).targetBlank,
|
|
143
|
-
},
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Pass value to the attribute aria-current when the link is exact active.
|
|
147
|
-
*/
|
|
148
|
-
ariaCurrentValue: {
|
|
149
|
-
type: String,
|
|
150
|
-
default: getDefault(defaultConfig, ULink).ariaCurrentValue,
|
|
151
|
-
},
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Whether RouterLink should not wrap its content in an a tag.
|
|
155
|
-
*/
|
|
156
|
-
custom: {
|
|
157
|
-
type: Boolean,
|
|
158
|
-
default: getDefault(defaultConfig, ULink).custom,
|
|
159
|
-
},
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Whether RouterLink should not wrap its content in an a tag.
|
|
163
|
-
*/
|
|
164
|
-
replace: {
|
|
165
|
-
type: Boolean,
|
|
166
|
-
default: getDefault(defaultConfig, ULink).replace,
|
|
167
|
-
},
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Apply classes to the link when its route is active or when it matches any parent route.
|
|
171
|
-
*/
|
|
172
|
-
activeClass: {
|
|
173
|
-
type: String,
|
|
174
|
-
default: getDefault(defaultConfig, ULink).activeClass,
|
|
175
|
-
},
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Apply classes to the link when its route is active.
|
|
179
|
-
*/
|
|
180
|
-
exactActiveClass: {
|
|
181
|
-
type: String,
|
|
182
|
-
default: getDefault(defaultConfig, ULink).exactActiveClass,
|
|
183
|
-
},
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Apply classes to the wrapper div when link route is active or when it matches any parent route.
|
|
187
|
-
*/
|
|
188
|
-
wrapperActiveClass: {
|
|
189
|
-
type: String,
|
|
190
|
-
default: getDefault(defaultConfig, ULink).wrapperActiveClass,
|
|
191
|
-
},
|
|
192
|
-
|
|
193
|
-
/**
|
|
194
|
-
* Apply classes to the wrapper div when link route is active.
|
|
195
|
-
*/
|
|
196
|
-
wrapperExactActiveClass: {
|
|
197
|
-
type: String,
|
|
198
|
-
default: getDefault(defaultConfig, ULink).wrapperExactActiveClass,
|
|
199
|
-
},
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Show underline.
|
|
203
|
-
*/
|
|
204
|
-
underlined: {
|
|
205
|
-
type: Boolean,
|
|
206
|
-
default: getDefault(defaultConfig, ULink).underlined,
|
|
207
|
-
},
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Set link underline style as dashed.
|
|
211
|
-
*/
|
|
212
|
-
dashed: {
|
|
213
|
-
type: Boolean,
|
|
214
|
-
default: getDefault(defaultConfig, ULink).dashed,
|
|
215
|
-
},
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* Disable the link.
|
|
219
|
-
*/
|
|
220
|
-
disabled: {
|
|
221
|
-
type: Boolean,
|
|
222
|
-
default: getDefault(defaultConfig, ULink).disabled,
|
|
223
|
-
},
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Make the Button fill the width with its container.
|
|
227
|
-
*/
|
|
228
|
-
block: {
|
|
229
|
-
type: Boolean,
|
|
230
|
-
default: getDefault(defaultConfig, ULink).block,
|
|
231
|
-
},
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Remove outline ring on focus.
|
|
235
|
-
*/
|
|
236
|
-
noRing: {
|
|
237
|
-
type: Boolean,
|
|
238
|
-
default: getDefault(defaultConfig, ULink).noRing,
|
|
239
|
-
},
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* Component config object.
|
|
243
|
-
*/
|
|
244
|
-
config: {
|
|
245
|
-
type: Object,
|
|
246
|
-
default: () => ({}),
|
|
247
|
-
},
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* Data-test attribute for automated testing.
|
|
251
|
-
*/
|
|
252
|
-
dataTest: {
|
|
253
|
-
type: String,
|
|
254
|
-
default: "",
|
|
255
|
-
},
|
|
256
|
-
});
|
|
257
|
-
|
|
258
61
|
const isPresentRoute = computed(() => {
|
|
259
62
|
for (const key in props.to) return true;
|
|
260
63
|
|
|
@@ -316,3 +119,49 @@ defineExpose({
|
|
|
316
119
|
wrapperRef,
|
|
317
120
|
});
|
|
318
121
|
</script>
|
|
122
|
+
|
|
123
|
+
<template>
|
|
124
|
+
<div v-bind="wrapperAttrs" ref="wrapperRef" tabindex="-1">
|
|
125
|
+
<!-- @slot Use it to add something before the label. -->
|
|
126
|
+
<slot name="left" />
|
|
127
|
+
|
|
128
|
+
<router-link
|
|
129
|
+
v-if="isPresentRoute"
|
|
130
|
+
:to="route"
|
|
131
|
+
:target="targetValue"
|
|
132
|
+
v-bind="linkAttrs"
|
|
133
|
+
:data-test="dataTest"
|
|
134
|
+
tabindex="0"
|
|
135
|
+
@blur="onBlur"
|
|
136
|
+
@focus="onFocus"
|
|
137
|
+
@click="onClick"
|
|
138
|
+
@keydown="onKeydown"
|
|
139
|
+
@mouseover="onMouseover"
|
|
140
|
+
>
|
|
141
|
+
<!-- @slot Use it replace the label. -->
|
|
142
|
+
<slot>
|
|
143
|
+
{{ label }}
|
|
144
|
+
</slot>
|
|
145
|
+
</router-link>
|
|
146
|
+
|
|
147
|
+
<a
|
|
148
|
+
v-else
|
|
149
|
+
:href="prefixedHref"
|
|
150
|
+
:target="targetValue"
|
|
151
|
+
v-bind="linkAttrs"
|
|
152
|
+
:data-test="dataTest"
|
|
153
|
+
tabindex="0"
|
|
154
|
+
@blur="onBlur"
|
|
155
|
+
@focus="onFocus"
|
|
156
|
+
@click="onClick"
|
|
157
|
+
@keydown="onKeydown"
|
|
158
|
+
@mouseover="onMouseover"
|
|
159
|
+
>
|
|
160
|
+
<!-- @slot Use it replace the label. -->
|
|
161
|
+
<slot>{{ label }}</slot>
|
|
162
|
+
</a>
|
|
163
|
+
|
|
164
|
+
<!-- @slot Use it to add something after the label. -->
|
|
165
|
+
<slot name="right" />
|
|
166
|
+
</div>
|
|
167
|
+
</template>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Meta, Title, Subtitle, Description, Primary, Controls, Stories, Source } from "@storybook/blocks";
|
|
2
2
|
import { getSource } from "../../utils/storybook.ts";
|
|
3
3
|
|
|
4
|
-
import * as stories from "./stories.
|
|
5
|
-
import defaultConfig from "../config.
|
|
4
|
+
import * as stories from "./stories.ts";
|
|
5
|
+
import defaultConfig from "../config.ts?raw"
|
|
6
6
|
|
|
7
7
|
<Meta of={stories} />
|
|
8
8
|
<Title of={stories} />
|
|
@@ -5,6 +5,14 @@ import UIcon from "../../ui.image-icon/UIcon.vue";
|
|
|
5
5
|
import UButton from "../../ui.button/UButton.vue";
|
|
6
6
|
import URow from "../../ui.container-row/URow.vue";
|
|
7
7
|
|
|
8
|
+
import type { Meta, StoryFn } from "@storybook/vue3";
|
|
9
|
+
import type { ULinkProps } from "../types.ts";
|
|
10
|
+
|
|
11
|
+
interface ULinkArgs extends ULinkProps {
|
|
12
|
+
slotTemplate?: string;
|
|
13
|
+
enum: "size" | "color";
|
|
14
|
+
}
|
|
15
|
+
|
|
8
16
|
/**
|
|
9
17
|
* The `ULink` component. | [View on GitHub](https://github.com/vuelessjs/vueless/tree/main/src/ui.button-link)
|
|
10
18
|
*/
|
|
@@ -18,9 +26,9 @@ export default {
|
|
|
18
26
|
argTypes: {
|
|
19
27
|
...getArgTypes(ULink.__name),
|
|
20
28
|
},
|
|
21
|
-
};
|
|
29
|
+
} as Meta;
|
|
22
30
|
|
|
23
|
-
const DefaultTemplate = (args) => ({
|
|
31
|
+
const DefaultTemplate: StoryFn<ULinkArgs> = (args: ULinkArgs) => ({
|
|
24
32
|
components: { ULink, UButton, UIcon },
|
|
25
33
|
setup() {
|
|
26
34
|
const slots = getSlotNames(ULink.__name);
|
|
@@ -28,26 +36,29 @@ const DefaultTemplate = (args) => ({
|
|
|
28
36
|
return { args, slots };
|
|
29
37
|
},
|
|
30
38
|
template: `
|
|
31
|
-
<ULink v-bind="args">
|
|
32
|
-
${args.slotTemplate || getSlotsFragment()}
|
|
39
|
+
<ULink v-if="args.block" v-bind="args" :config="{ wrapper: 'border-2 border-dashed border-green-500 p-2' }">
|
|
40
|
+
${args.slotTemplate || getSlotsFragment("")}
|
|
41
|
+
</ULink>
|
|
42
|
+
<ULink v-else v-bind="args">
|
|
43
|
+
${args.slotTemplate || getSlotsFragment("")}
|
|
33
44
|
</ULink>
|
|
34
45
|
`,
|
|
35
46
|
});
|
|
36
47
|
|
|
37
|
-
const EnumVariantTemplate = (args, { argTypes }) => ({
|
|
48
|
+
const EnumVariantTemplate: StoryFn<ULinkArgs> = (args: ULinkArgs, { argTypes }) => ({
|
|
38
49
|
components: { ULink, URow },
|
|
39
50
|
setup() {
|
|
40
|
-
function getText(value) {
|
|
51
|
+
function getText(value: string) {
|
|
41
52
|
return `Link ${value}`;
|
|
42
53
|
}
|
|
43
54
|
|
|
44
|
-
let prefixedOptions = argTypes[args.enum]
|
|
55
|
+
let prefixedOptions = argTypes?.[args.enum]?.options;
|
|
45
56
|
|
|
46
|
-
if (argTypes[args.enum]
|
|
47
|
-
prefixedOptions = prefixedOptions
|
|
57
|
+
if (argTypes?.[args.enum]?.name === "size") {
|
|
58
|
+
prefixedOptions = prefixedOptions?.map((option) => getText(option));
|
|
48
59
|
}
|
|
49
60
|
|
|
50
|
-
return { args, options: argTypes[args.enum]
|
|
61
|
+
return { args, options: argTypes?.[args.enum]?.options, prefixedOptions };
|
|
51
62
|
},
|
|
52
63
|
template: `
|
|
53
64
|
<URow no-mobile>
|
|
@@ -71,10 +82,10 @@ Sizes.args = { enum: "size" };
|
|
|
71
82
|
export const Colors = EnumVariantTemplate.bind({});
|
|
72
83
|
Colors.args = { enum: "color" };
|
|
73
84
|
|
|
74
|
-
export const Types = (args) => ({
|
|
85
|
+
export const Types: StoryFn<ULinkArgs> = (args: ULinkArgs) => ({
|
|
75
86
|
components: { ULink, URow },
|
|
76
87
|
setup() {
|
|
77
|
-
function getTypeLabel(type) {
|
|
88
|
+
function getTypeLabel(type: string): string {
|
|
78
89
|
switch (type) {
|
|
79
90
|
case "phone":
|
|
80
91
|
return "+1 (000) 123-4567";
|
|
@@ -82,10 +93,12 @@ export const Types = (args) => ({
|
|
|
82
93
|
return "hello@vueless.com";
|
|
83
94
|
case "link":
|
|
84
95
|
return "Vueless.com";
|
|
96
|
+
default:
|
|
97
|
+
return "Unknown";
|
|
85
98
|
}
|
|
86
99
|
}
|
|
87
100
|
|
|
88
|
-
function getTypeHref(type, label) {
|
|
101
|
+
function getTypeHref(type: string, label: string) {
|
|
89
102
|
switch (type) {
|
|
90
103
|
case "phone": {
|
|
91
104
|
const phoneNumber = label.replace(/\D/g, "");
|
|
@@ -126,7 +139,7 @@ export const Types = (args) => ({
|
|
|
126
139
|
`,
|
|
127
140
|
});
|
|
128
141
|
|
|
129
|
-
export const UnderlineVariants = (args, { argTypes }
|
|
142
|
+
export const UnderlineVariants: StoryFn<ULinkArgs> = (args: ULinkArgs, { argTypes }) => ({
|
|
130
143
|
components: { ULink, URow },
|
|
131
144
|
setup() {
|
|
132
145
|
const variants = [
|
|
@@ -135,7 +148,7 @@ export const UnderlineVariants = (args, { argTypes } = {}) => ({
|
|
|
135
148
|
{ name: "Dashed", props: { dashed: true } },
|
|
136
149
|
];
|
|
137
150
|
|
|
138
|
-
const colors = argTypes
|
|
151
|
+
const colors = argTypes?.color?.options;
|
|
139
152
|
|
|
140
153
|
return {
|
|
141
154
|
args,
|
|
@@ -166,7 +179,7 @@ export const NoRing = DefaultTemplate.bind({});
|
|
|
166
179
|
NoRing.args = { noRing: true };
|
|
167
180
|
|
|
168
181
|
export const Block = DefaultTemplate.bind({});
|
|
169
|
-
Block.args = { block: true
|
|
182
|
+
Block.args = { block: true };
|
|
170
183
|
|
|
171
184
|
export const DefaultSlot = DefaultTemplate.bind({});
|
|
172
185
|
DefaultSlot.args = {
|
|
@@ -177,7 +190,7 @@ DefaultSlot.args = {
|
|
|
177
190
|
`,
|
|
178
191
|
};
|
|
179
192
|
|
|
180
|
-
export const LeftAndRightSlots = (args) => ({
|
|
193
|
+
export const LeftAndRightSlots: StoryFn<ULinkArgs> = (args: ULinkArgs) => ({
|
|
181
194
|
components: { ULink, UIcon, URow },
|
|
182
195
|
setup() {
|
|
183
196
|
return { args };
|