vueless 0.0.513 → 0.0.515
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 +26 -0
- package/ui.button-link/types.ts +3 -1
- package/ui.button-link/useAttrs.ts +2 -2
- package/ui.container-accordion/UAccordion.vue +33 -69
- package/ui.container-accordion/storybook/Docs.mdx +2 -2
- package/ui.container-accordion/storybook/{stories.js → stories.ts} +10 -3
- package/ui.container-accordion/types.ts +35 -0
- package/ui.container-accordion/{useAttrs.js → useAttrs.ts} +14 -3
- package/ui.container-card/UCard.vue +43 -71
- package/ui.container-card/storybook/Docs.mdx +2 -2
- package/ui.container-card/storybook/{stories.js → stories.ts} +9 -2
- package/ui.container-card/types.ts +25 -0
- package/ui.container-card/useAttrs.ts +18 -0
- package/ui.container-col/UCol.vue +21 -79
- package/ui.container-col/storybook/Docs.mdx +2 -2
- package/ui.container-col/storybook/{stories.js → stories.ts} +9 -2
- package/ui.container-col/types.ts +54 -0
- package/ui.container-col/useAttrs.ts +18 -0
- package/ui.container-divider/UDivider.vue +22 -94
- package/ui.container-divider/storybook/Docs.mdx +2 -2
- package/ui.container-divider/storybook/{stories.js → stories.ts} +13 -5
- package/ui.container-divider/types.ts +55 -0
- package/ui.container-divider/useAttrs.ts +23 -0
- package/ui.container-group/UGroup.vue +31 -73
- package/ui.container-group/storybook/Docs.mdx +2 -2
- package/ui.container-group/storybook/{stories.js → stories.ts} +9 -2
- package/ui.container-group/types.ts +36 -0
- package/ui.container-group/useAttrs.ts +18 -0
- package/ui.container-modal/UModal.vue +122 -232
- package/ui.container-modal/storybook/Docs.mdx +2 -2
- package/ui.container-modal/storybook/{stories.js → stories.ts} +16 -6
- package/ui.container-modal/types.ts +82 -0
- package/ui.container-modal/useAttrs.ts +22 -0
- package/ui.container-modal-confirm/UModalConfirm.vue +82 -199
- package/ui.container-modal-confirm/storybook/Docs.mdx +2 -2
- package/ui.container-modal-confirm/storybook/{stories.js → stories.ts} +14 -3
- package/ui.container-modal-confirm/types.ts +106 -0
- package/ui.container-modal-confirm/useAttrs.ts +18 -0
- package/ui.container-page/UPage.vue +79 -153
- package/ui.container-page/storybook/Docs.mdx +2 -2
- package/ui.container-page/storybook/{stories.js → stories.ts} +9 -2
- package/ui.container-page/types.ts +57 -0
- package/ui.container-page/{useAttrs.js → useAttrs.ts} +14 -3
- package/ui.container-row/URow.vue +22 -87
- package/ui.container-row/storybook/Docs.mdx +2 -2
- package/ui.container-row/storybook/{stories.js → stories.ts} +11 -3
- package/ui.container-row/types.ts +59 -0
- package/ui.container-row/useAttrs.ts +18 -0
- package/ui.dropdown-badge/UDropdownBadge.vue +70 -167
- package/ui.dropdown-badge/storybook/Docs.mdx +2 -2
- package/ui.dropdown-badge/storybook/{stories.js → stories.ts} +16 -5
- package/ui.dropdown-badge/types.ts +93 -0
- package/ui.dropdown-badge/{useAttrs.js → useAttrs.ts} +13 -2
- package/ui.dropdown-button/UDropdownButton.vue +85 -203
- package/ui.dropdown-button/storybook/Docs.mdx +2 -2
- package/ui.dropdown-button/storybook/{stories.js → stories.ts} +25 -11
- package/ui.dropdown-button/types.ts +108 -0
- package/ui.dropdown-button/{useAttrs.js → useAttrs.ts} +14 -3
- package/ui.dropdown-link/UDropdownLink.vue +84 -194
- package/ui.dropdown-link/storybook/Docs.mdx +2 -2
- package/ui.dropdown-link/storybook/{stories.js → stories.ts} +20 -9
- package/ui.dropdown-link/types.ts +103 -0
- package/ui.dropdown-link/{useAttrs.js → useAttrs.ts} +14 -3
- package/ui.dropdown-list/UDropdownList.vue +112 -177
- package/ui.dropdown-list/storybook/Docs.mdx +2 -2
- package/ui.dropdown-list/storybook/{stories.js → stories.ts} +23 -7
- package/ui.dropdown-list/types.ts +52 -0
- package/ui.dropdown-list/{useAttrs.js → useAttrs.ts} +6 -3
- package/ui.dropdown-list/usePointer.ts +111 -0
- package/web-types.json +298 -146
- package/ui.container-card/useAttrs.js +0 -15
- package/ui.container-col/useAttrs.js +0 -15
- package/ui.container-divider/useAttrs.js +0 -20
- package/ui.container-group/useAttrs.js +0 -15
- package/ui.container-modal/useAttrs.js +0 -19
- package/ui.container-modal-confirm/useAttrs.js +0 -15
- package/ui.container-row/useAttrs.js +0 -15
- package/ui.dropdown-list/usePointer.js +0 -86
- /package/ui.container-accordion/{config.js → config.ts} +0 -0
- /package/ui.container-accordion/{constants.js → constants.ts} +0 -0
- /package/ui.container-card/{config.js → config.ts} +0 -0
- /package/ui.container-card/{constants.js → constants.ts} +0 -0
- /package/ui.container-col/{config.js → config.ts} +0 -0
- /package/ui.container-col/{constants.js → constants.ts} +0 -0
- /package/ui.container-divider/{config.js → config.ts} +0 -0
- /package/ui.container-divider/{constants.js → constants.ts} +0 -0
- /package/ui.container-group/{config.js → config.ts} +0 -0
- /package/ui.container-group/{constants.js → constants.ts} +0 -0
- /package/ui.container-modal/{config.js → config.ts} +0 -0
- /package/ui.container-modal/{constants.js → constants.ts} +0 -0
- /package/ui.container-modal-confirm/{config.js → config.ts} +0 -0
- /package/ui.container-modal-confirm/{constants.js → constants.ts} +0 -0
- /package/ui.container-page/{config.js → config.ts} +0 -0
- /package/ui.container-page/{constants.js → constants.ts} +0 -0
- /package/ui.container-row/{config.js → config.ts} +0 -0
- /package/ui.container-row/{constants.js → constants.ts} +0 -0
- /package/ui.dropdown-badge/{config.js → config.ts} +0 -0
- /package/ui.dropdown-badge/{constants.js → constants.ts} +0 -0
- /package/ui.dropdown-button/{config.js → config.ts} +0 -0
- /package/ui.dropdown-button/{constants.js → constants.ts} +0 -0
- /package/ui.dropdown-link/{config.js → config.ts} +0 -0
- /package/ui.dropdown-link/{constants.js → constants.ts} +0 -0
- /package/ui.dropdown-list/{config.js → config.ts} +0 -0
- /package/ui.dropdown-list/{constants.js → constants.ts} +0 -0
|
@@ -1,3 +1,87 @@
|
|
|
1
|
+
<script lang="ts" setup>
|
|
2
|
+
import { nextTick, computed, provide, ref, useId } from "vue";
|
|
3
|
+
|
|
4
|
+
import UIcon from "../ui.image-icon/UIcon.vue";
|
|
5
|
+
import ULink from "../ui.button-link/ULink.vue";
|
|
6
|
+
import UDropdownList from "../ui.dropdown-list/UDropdownList.vue";
|
|
7
|
+
|
|
8
|
+
import { getDefault } from "../utils/ui.ts";
|
|
9
|
+
|
|
10
|
+
import { vClickOutside } from "../directives";
|
|
11
|
+
|
|
12
|
+
import { UDropdownLink } from "./constants.ts";
|
|
13
|
+
import defaultConfig from "./config.ts";
|
|
14
|
+
import useAttrs from "./useAttrs.ts";
|
|
15
|
+
|
|
16
|
+
import type { UDropdownLinkProps } from "./types.ts";
|
|
17
|
+
|
|
18
|
+
defineOptions({ inheritAttrs: false });
|
|
19
|
+
|
|
20
|
+
const props = withDefaults(defineProps<UDropdownLinkProps>(), {
|
|
21
|
+
labelKey: getDefault<UDropdownLinkProps>(defaultConfig, UDropdownLink).labelKey,
|
|
22
|
+
color: getDefault<UDropdownLinkProps>(defaultConfig, UDropdownLink).color,
|
|
23
|
+
size: getDefault<UDropdownLinkProps>(defaultConfig, UDropdownLink).size,
|
|
24
|
+
underlined: getDefault<UDropdownLinkProps>(defaultConfig, UDropdownLink).underlined,
|
|
25
|
+
dashed: getDefault<UDropdownLinkProps>(defaultConfig, UDropdownLink).dashed,
|
|
26
|
+
disabled: getDefault<UDropdownLinkProps>(defaultConfig, UDropdownLink).disabled,
|
|
27
|
+
noRing: getDefault<UDropdownLinkProps>(defaultConfig, UDropdownLink).noRing,
|
|
28
|
+
noIcon: getDefault<UDropdownLinkProps>(defaultConfig, UDropdownLink).noIcon,
|
|
29
|
+
yPosition: getDefault<UDropdownLinkProps>(defaultConfig, UDropdownLink).yPosition,
|
|
30
|
+
xPosition: getDefault<UDropdownLinkProps>(defaultConfig, UDropdownLink).xPosition,
|
|
31
|
+
dataTest: "",
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const emit = defineEmits([
|
|
35
|
+
/**
|
|
36
|
+
* Triggers on dropdown option click.
|
|
37
|
+
* @property {string} value
|
|
38
|
+
*/
|
|
39
|
+
"clickOption",
|
|
40
|
+
]);
|
|
41
|
+
|
|
42
|
+
provide("hideDropdownOptions", hideOptions);
|
|
43
|
+
|
|
44
|
+
const isShownOptions = ref(false);
|
|
45
|
+
const dropdownListRef = ref(null);
|
|
46
|
+
|
|
47
|
+
const elementId = props.id || useId();
|
|
48
|
+
|
|
49
|
+
const { config, wrapperAttrs, dropdownLinkAttrs, dropdownListAttrs, dropdownIconAttrs } = useAttrs(
|
|
50
|
+
props,
|
|
51
|
+
{ isShownOptions },
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
const iconSize = computed(() => {
|
|
55
|
+
const sizes = {
|
|
56
|
+
sm: "2xs",
|
|
57
|
+
md: "xs",
|
|
58
|
+
lg: "sm",
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
return sizes[props.size];
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
function onClickLink() {
|
|
65
|
+
isShownOptions.value = !isShownOptions.value;
|
|
66
|
+
|
|
67
|
+
if (isShownOptions.value) {
|
|
68
|
+
nextTick(() => dropdownListRef.value.wrapperRef.focus());
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function hideOptions() {
|
|
73
|
+
isShownOptions.value = false;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function onClickList() {
|
|
77
|
+
hideOptions();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function onClickOption(option) {
|
|
81
|
+
emit("clickOption", option);
|
|
82
|
+
}
|
|
83
|
+
</script>
|
|
84
|
+
|
|
1
85
|
<template>
|
|
2
86
|
<div v-click-outside="hideOptions" v-bind="wrapperAttrs">
|
|
3
87
|
<ULink
|
|
@@ -66,197 +150,3 @@
|
|
|
66
150
|
/>
|
|
67
151
|
</div>
|
|
68
152
|
</template>
|
|
69
|
-
|
|
70
|
-
<script setup>
|
|
71
|
-
import { nextTick, computed, provide, ref, useId } from "vue";
|
|
72
|
-
|
|
73
|
-
import UIcon from "../ui.image-icon/UIcon.vue";
|
|
74
|
-
import ULink from "../ui.button-link/ULink.vue";
|
|
75
|
-
import UDropdownList from "../ui.dropdown-list/UDropdownList.vue";
|
|
76
|
-
|
|
77
|
-
import { getDefault } from "../utils/ui.ts";
|
|
78
|
-
|
|
79
|
-
import { vClickOutside } from "../directives";
|
|
80
|
-
|
|
81
|
-
import { UDropdownLink } from "./constants.js";
|
|
82
|
-
import defaultConfig from "./config.js";
|
|
83
|
-
import useAttrs from "./useAttrs.js";
|
|
84
|
-
|
|
85
|
-
defineOptions({ inheritAttrs: false });
|
|
86
|
-
|
|
87
|
-
const props = defineProps({
|
|
88
|
-
/**
|
|
89
|
-
* Link label.
|
|
90
|
-
*/
|
|
91
|
-
label: {
|
|
92
|
-
type: String,
|
|
93
|
-
default: "",
|
|
94
|
-
},
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Options list.
|
|
98
|
-
*/
|
|
99
|
-
options: {
|
|
100
|
-
type: Array,
|
|
101
|
-
default: () => [],
|
|
102
|
-
},
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Label key in the item object of options.
|
|
106
|
-
*/
|
|
107
|
-
labelKey: {
|
|
108
|
-
type: String,
|
|
109
|
-
default: getDefault(defaultConfig, UDropdownLink).labelKey,
|
|
110
|
-
},
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Link color.
|
|
114
|
-
* @values brand, grayscale, gray, red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose, white
|
|
115
|
-
*/
|
|
116
|
-
color: {
|
|
117
|
-
type: String,
|
|
118
|
-
default: getDefault(defaultConfig, UDropdownLink).color,
|
|
119
|
-
},
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Link size.
|
|
123
|
-
* @values sm, md, lg
|
|
124
|
-
*/
|
|
125
|
-
size: {
|
|
126
|
-
type: String,
|
|
127
|
-
default: getDefault(defaultConfig, UDropdownLink).size,
|
|
128
|
-
},
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Add underline.
|
|
132
|
-
*/
|
|
133
|
-
underlined: {
|
|
134
|
-
type: Boolean,
|
|
135
|
-
default: getDefault(defaultConfig, UDropdownLink).underlined,
|
|
136
|
-
},
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Set dashed underline style.
|
|
140
|
-
*/
|
|
141
|
-
dashed: {
|
|
142
|
-
type: Boolean,
|
|
143
|
-
default: getDefault(defaultConfig, UDropdownLink).dashed,
|
|
144
|
-
},
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Disable the link.
|
|
148
|
-
*/
|
|
149
|
-
disabled: {
|
|
150
|
-
type: Boolean,
|
|
151
|
-
default: getDefault(defaultConfig, UDropdownLink).disabled,
|
|
152
|
-
},
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Hide focus ring.
|
|
156
|
-
*/
|
|
157
|
-
noRing: {
|
|
158
|
-
type: Boolean,
|
|
159
|
-
default: getDefault(defaultConfig, UDropdownLink).noRing,
|
|
160
|
-
},
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Hide dropdown icon.
|
|
164
|
-
*/
|
|
165
|
-
noIcon: {
|
|
166
|
-
type: Boolean,
|
|
167
|
-
default: getDefault(defaultConfig, UDropdownLink).noIcon,
|
|
168
|
-
},
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* The position of dropdown list on the y-axis.
|
|
172
|
-
* @values top, bottom
|
|
173
|
-
*/
|
|
174
|
-
yPosition: {
|
|
175
|
-
type: String,
|
|
176
|
-
default: getDefault(defaultConfig, UDropdownLink).yPosition,
|
|
177
|
-
},
|
|
178
|
-
|
|
179
|
-
/**
|
|
180
|
-
* The position of dropdown list on the x-axis.
|
|
181
|
-
* @values left, right
|
|
182
|
-
*/
|
|
183
|
-
xPosition: {
|
|
184
|
-
type: String,
|
|
185
|
-
default: getDefault(defaultConfig, UDropdownLink).xPosition,
|
|
186
|
-
},
|
|
187
|
-
|
|
188
|
-
/**
|
|
189
|
-
* Unique element id.
|
|
190
|
-
*/
|
|
191
|
-
id: {
|
|
192
|
-
type: String,
|
|
193
|
-
default: "",
|
|
194
|
-
},
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* Component config object.
|
|
198
|
-
*/
|
|
199
|
-
config: {
|
|
200
|
-
type: Object,
|
|
201
|
-
default: () => ({}),
|
|
202
|
-
},
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
* Data-test attribute for automated testing.
|
|
206
|
-
*/
|
|
207
|
-
dataTest: {
|
|
208
|
-
type: String,
|
|
209
|
-
default: "",
|
|
210
|
-
},
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
const emit = defineEmits([
|
|
214
|
-
/**
|
|
215
|
-
* Triggers on dropdown option click.
|
|
216
|
-
* @property {string} value
|
|
217
|
-
*/
|
|
218
|
-
"clickOption",
|
|
219
|
-
]);
|
|
220
|
-
|
|
221
|
-
provide("hideDropdownOptions", hideOptions);
|
|
222
|
-
|
|
223
|
-
const isShownOptions = ref(false);
|
|
224
|
-
const dropdownListRef = ref(null);
|
|
225
|
-
|
|
226
|
-
const elementId = props.id || useId();
|
|
227
|
-
|
|
228
|
-
const { config, wrapperAttrs, dropdownLinkAttrs, dropdownListAttrs, dropdownIconAttrs } = useAttrs(
|
|
229
|
-
props,
|
|
230
|
-
{ isShownOptions },
|
|
231
|
-
);
|
|
232
|
-
|
|
233
|
-
const iconSize = computed(() => {
|
|
234
|
-
const sizes = {
|
|
235
|
-
sm: "2xs",
|
|
236
|
-
md: "xs",
|
|
237
|
-
lg: "sm",
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
return sizes[props.size];
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
function onClickLink() {
|
|
244
|
-
isShownOptions.value = !isShownOptions.value;
|
|
245
|
-
|
|
246
|
-
if (isShownOptions.value) {
|
|
247
|
-
nextTick(() => dropdownListRef.value.wrapperRef.focus());
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
function hideOptions() {
|
|
252
|
-
isShownOptions.value = false;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
function onClickList() {
|
|
256
|
-
hideOptions();
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
function onClickOption(option) {
|
|
260
|
-
emit("clickOption", option);
|
|
261
|
-
}
|
|
262
|
-
</script>
|
|
@@ -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} />
|
|
@@ -4,6 +4,14 @@ import UDropdownLink from "../../ui.dropdown-link/UDropdownLink.vue";
|
|
|
4
4
|
import URow from "../../ui.container-row/URow.vue";
|
|
5
5
|
import UIcon from "../../ui.image-icon/UIcon.vue";
|
|
6
6
|
|
|
7
|
+
import type { Meta, StoryFn } from "@storybook/vue3";
|
|
8
|
+
import type { UDropdownLinkProps } from "../types.ts";
|
|
9
|
+
|
|
10
|
+
interface UDropdownLinkArgs extends UDropdownLinkProps {
|
|
11
|
+
slotTemplate?: string;
|
|
12
|
+
enum: "color" | "size";
|
|
13
|
+
}
|
|
14
|
+
|
|
7
15
|
/**
|
|
8
16
|
* The `UDropdownLink` component. | [View on GitHub](https://github.com/vuelessjs/vueless/tree/main/src/ui.dropdown-link)
|
|
9
17
|
*/
|
|
@@ -29,9 +37,9 @@ export default {
|
|
|
29
37
|
},
|
|
30
38
|
},
|
|
31
39
|
},
|
|
32
|
-
};
|
|
40
|
+
} as Meta;
|
|
33
41
|
|
|
34
|
-
const DefaultTemplate = (args) => ({
|
|
42
|
+
const DefaultTemplate: StoryFn<UDropdownLinkArgs> = (args: UDropdownLinkArgs) => ({
|
|
35
43
|
components: { UDropdownLink, UIcon },
|
|
36
44
|
setup() {
|
|
37
45
|
const slots = getSlotNames(UDropdownLink.__name);
|
|
@@ -40,25 +48,28 @@ const DefaultTemplate = (args) => ({
|
|
|
40
48
|
},
|
|
41
49
|
template: `
|
|
42
50
|
<UDropdownLink v-bind="args">
|
|
43
|
-
${args.slotTemplate || getSlotsFragment()}
|
|
51
|
+
${args.slotTemplate || getSlotsFragment("")}
|
|
44
52
|
</UDropdownLink>
|
|
45
53
|
`,
|
|
46
54
|
});
|
|
47
55
|
|
|
48
|
-
const EnumVariantTemplate = (
|
|
56
|
+
const EnumVariantTemplate: StoryFn<UDropdownLinkArgs> = (
|
|
57
|
+
args: UDropdownLinkArgs,
|
|
58
|
+
{ argTypes },
|
|
59
|
+
) => ({
|
|
49
60
|
components: { UDropdownLink, URow },
|
|
50
61
|
setup() {
|
|
51
|
-
function getText(value) {
|
|
62
|
+
function getText(value: string) {
|
|
52
63
|
return `Dropdown ${value}`;
|
|
53
64
|
}
|
|
54
65
|
|
|
55
|
-
let prefixedOptions = argTypes[args.enum]
|
|
66
|
+
let prefixedOptions = argTypes?.[args.enum]?.options;
|
|
56
67
|
|
|
57
|
-
if (argTypes[args.enum]
|
|
58
|
-
prefixedOptions = prefixedOptions
|
|
68
|
+
if (argTypes?.[args.enum]?.name === "size") {
|
|
69
|
+
prefixedOptions = prefixedOptions?.map((option) => getText(option));
|
|
59
70
|
}
|
|
60
71
|
|
|
61
|
-
return { args, options: argTypes[args.enum]
|
|
72
|
+
return { args, options: argTypes?.[args.enum]?.options, prefixedOptions };
|
|
62
73
|
},
|
|
63
74
|
template: `
|
|
64
75
|
<URow>
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import defaultConfig from "./config.ts";
|
|
2
|
+
|
|
3
|
+
import type { UnknownObject } from "../types.ts";
|
|
4
|
+
|
|
5
|
+
export type Config = Partial<typeof defaultConfig>;
|
|
6
|
+
|
|
7
|
+
export interface UDropdownLinkProps {
|
|
8
|
+
/**
|
|
9
|
+
* Link label.
|
|
10
|
+
*/
|
|
11
|
+
label?: string;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Options list.
|
|
15
|
+
*/
|
|
16
|
+
options?: UnknownObject[];
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Label key in the item object of options.
|
|
20
|
+
*/
|
|
21
|
+
labelKey?: string;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Link color.
|
|
25
|
+
*/
|
|
26
|
+
color?:
|
|
27
|
+
| "brand"
|
|
28
|
+
| "grayscale"
|
|
29
|
+
| "gray"
|
|
30
|
+
| "red"
|
|
31
|
+
| "orange"
|
|
32
|
+
| "amber"
|
|
33
|
+
| "yellow"
|
|
34
|
+
| "lime"
|
|
35
|
+
| "green"
|
|
36
|
+
| "emerald"
|
|
37
|
+
| "teal"
|
|
38
|
+
| "cyan"
|
|
39
|
+
| "sky"
|
|
40
|
+
| "blue"
|
|
41
|
+
| "indigo"
|
|
42
|
+
| "violet"
|
|
43
|
+
| "purple"
|
|
44
|
+
| "fuchsia"
|
|
45
|
+
| "pink"
|
|
46
|
+
| "rose"
|
|
47
|
+
| "white";
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Link size.
|
|
51
|
+
*/
|
|
52
|
+
size?: "sm" | "md" | "lg";
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Add underline.
|
|
56
|
+
*/
|
|
57
|
+
underlined?: boolean;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Set dashed underline style.
|
|
61
|
+
*/
|
|
62
|
+
dashed?: boolean;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Disable the link.
|
|
66
|
+
*/
|
|
67
|
+
disabled?: boolean;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Hide focus ring.
|
|
71
|
+
*/
|
|
72
|
+
noRing?: boolean;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Hide dropdown icon.
|
|
76
|
+
*/
|
|
77
|
+
noIcon?: boolean;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The position of dropdown list on the y-axis.
|
|
81
|
+
*/
|
|
82
|
+
yPosition?: "top" | "bottom";
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The position of dropdown list on the x-axis.
|
|
86
|
+
*/
|
|
87
|
+
xPosition?: "left" | "right";
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Unique element id.
|
|
91
|
+
*/
|
|
92
|
+
id?: string;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Component config object.
|
|
96
|
+
*/
|
|
97
|
+
config?: Partial<typeof defaultConfig>;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Data-test attribute for automated testing.
|
|
101
|
+
*/
|
|
102
|
+
dataTest?: string;
|
|
103
|
+
}
|
|
@@ -1,10 +1,21 @@
|
|
|
1
1
|
import { 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 { Ref } from "vue";
|
|
7
|
+
import type { UseAttrs } from "../types.ts";
|
|
8
|
+
import type { UDropdownLinkProps, Config } from "./types.ts";
|
|
9
|
+
|
|
10
|
+
type ComponentState = {
|
|
11
|
+
isShownOptions: Ref<boolean>;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default function useAttrs(
|
|
15
|
+
props: UDropdownLinkProps,
|
|
16
|
+
{ isShownOptions }: ComponentState,
|
|
17
|
+
): UseAttrs<Config> {
|
|
18
|
+
const { config, getKeysAttrs, hasSlotContent, getExtendingKeysClasses } = useUI<Config>(
|
|
8
19
|
defaultConfig,
|
|
9
20
|
() => props.config,
|
|
10
21
|
);
|