vueless 0.0.199 → 0.0.201
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/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.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.form-select/configs/default.config.js +3 -2
- package/ui.form-select/index.stories.js +44 -8
- package/ui.form-select/index.vue +129 -20
- package/web-types.json +264 -63
package/package.json
CHANGED
|
@@ -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,64 +1,47 @@
|
|
|
1
|
+
import { computed } from "vue";
|
|
1
2
|
import useUI from "../../composable.ui";
|
|
2
3
|
import { cva, cx } from "../../service.ui";
|
|
3
|
-
|
|
4
4
|
import defaultConfig from "../configs/default.config";
|
|
5
|
-
import { computed } from "vue";
|
|
6
5
|
|
|
7
|
-
export function useAttrs(props, { inputPasswordClasses }) {
|
|
8
|
-
const { config, getAttrs, hasSlotContent } = useUI(
|
|
9
|
-
|
|
6
|
+
export default function useAttrs(props, { inputPasswordClasses }) {
|
|
7
|
+
const { config, getAttrs, hasSlotContent, isSystemKey } = useUI(
|
|
8
|
+
defaultConfig,
|
|
9
|
+
() => props.config,
|
|
10
|
+
);
|
|
11
|
+
const attrs = {};
|
|
10
12
|
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
variants: input.variants,
|
|
14
|
-
compoundVariants: input.compoundVariants,
|
|
15
|
-
});
|
|
13
|
+
for (const key in defaultConfig) {
|
|
14
|
+
if (isSystemKey(key)) continue;
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
variants: block.variants,
|
|
20
|
-
compoundVariants: block.compoundVariants,
|
|
21
|
-
});
|
|
16
|
+
const classes = computed(() => {
|
|
17
|
+
const value = config.value[key];
|
|
22
18
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
if (value.variants || value.compoundVariants) {
|
|
20
|
+
return cva(value)({
|
|
21
|
+
...props,
|
|
22
|
+
error: Boolean(props.error),
|
|
23
|
+
label: Boolean(props.label),
|
|
24
|
+
});
|
|
25
|
+
}
|
|
29
26
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
labelAlign: props.labelAlign,
|
|
35
|
-
label: Boolean(props.label),
|
|
36
|
-
error: Boolean(props.error),
|
|
37
|
-
}),
|
|
38
|
-
);
|
|
27
|
+
return "";
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
attrs[`${key}Attrs`] = getAttrs(key, { classes });
|
|
39
31
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const leftSlotAttrs = getAttrs("leftSlot");
|
|
43
|
-
const passwordIconAttrs = getAttrs("passwordIcon");
|
|
44
|
-
const blockAttrs = getAttrs("block", { classes: blockClasses });
|
|
45
|
-
const labelAttrs = getAttrs("label", { isComponent: true });
|
|
46
|
-
const inputAttrsRaw = getAttrs("input", { classes: inputClasses });
|
|
32
|
+
if (key === "input") {
|
|
33
|
+
const inputAttrs = attrs[`${key}Attrs`];
|
|
47
34
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
35
|
+
attrs[`${key}Attrs`] = computed(() => ({
|
|
36
|
+
...inputAttrs.value,
|
|
37
|
+
class: cx([inputAttrs.value.class, inputPasswordClasses.value]),
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
}
|
|
52
41
|
|
|
53
42
|
return {
|
|
43
|
+
...attrs,
|
|
54
44
|
config,
|
|
55
|
-
inputAttrs,
|
|
56
|
-
blockAttrs,
|
|
57
|
-
labelAttrs,
|
|
58
|
-
passwordIconAttrs,
|
|
59
|
-
leftSlotAttrs,
|
|
60
|
-
inputWrapperAttrs,
|
|
61
|
-
rightSlotAttrs,
|
|
62
45
|
hasSlotContent,
|
|
63
46
|
};
|
|
64
47
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export default /*tw*/ {
|
|
2
|
-
label: "relative w-full",
|
|
2
|
+
label: "{ULabel} relative w-full",
|
|
3
3
|
inputWrapper: "flex relative w-full",
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
rightIconSlot: "flex items-center justify-end whitespace-nowrap pr-3 rounded-r-lg rounded-l-none",
|
|
5
|
+
leftIconSlot: "flex items-center justify-end whitespace-nowrap pl-3 rounded-l-lg rounded-r-none",
|
|
6
6
|
passwordIcon: "",
|
|
7
7
|
passwordVisibleIconName: "visibility-fill",
|
|
8
8
|
passwordHiddenIconName: "visibility_off-fill",
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { getArgTypes, getSlotNames } from "../service.storybook";
|
|
1
|
+
import { getArgTypes, getSlotNames, allSlotsFragment } from "../service.storybook";
|
|
2
2
|
|
|
3
3
|
import UInput from "../ui.form-input";
|
|
4
4
|
import UIcon from "../ui.image-icon";
|
|
5
|
+
import UButton from "../ui.button";
|
|
5
6
|
import UGroup from "../ui.container-group";
|
|
6
7
|
import URow from "../ui.container-row";
|
|
7
8
|
|
|
@@ -32,22 +33,20 @@ const DefaultTemplate = (args) => ({
|
|
|
32
33
|
<UInput
|
|
33
34
|
v-bind="args"
|
|
34
35
|
>
|
|
35
|
-
|
|
36
|
-
<template v-if="args[slot]">{{ args[slot] }}</template>
|
|
37
|
-
</template>
|
|
36
|
+
${allSlotsFragment}
|
|
38
37
|
</UInput>
|
|
39
38
|
`,
|
|
40
39
|
});
|
|
41
40
|
|
|
42
41
|
const SlotTemplate = (args) => ({
|
|
43
|
-
components: { UInput, UIcon },
|
|
42
|
+
components: { UInput, UIcon, UButton },
|
|
44
43
|
setup() {
|
|
45
44
|
return { args };
|
|
46
45
|
},
|
|
47
46
|
template: `
|
|
48
47
|
<UInput v-bind="args"
|
|
49
48
|
>
|
|
50
|
-
${args.slotTemplate
|
|
49
|
+
${args.slotTemplate}
|
|
51
50
|
</UInput>
|
|
52
51
|
`,
|
|
53
52
|
});
|
|
@@ -163,17 +162,41 @@ iconRight.args = {
|
|
|
163
162
|
export const iconLeftSlot = SlotTemplate.bind({});
|
|
164
163
|
iconLeftSlot.args = {
|
|
165
164
|
slotTemplate: `
|
|
166
|
-
<template #left>
|
|
167
|
-
|
|
165
|
+
<template #icon-left>
|
|
166
|
+
<UIcon
|
|
167
|
+
name="star"
|
|
168
|
+
color="green"
|
|
169
|
+
/>
|
|
168
170
|
</template>
|
|
169
171
|
`,
|
|
170
172
|
};
|
|
171
173
|
|
|
172
174
|
export const iconRightSlot = SlotTemplate.bind({});
|
|
173
175
|
iconRightSlot.args = {
|
|
176
|
+
slotTemplate: `
|
|
177
|
+
<template #icon-right>
|
|
178
|
+
<UIcon
|
|
179
|
+
name="star"
|
|
180
|
+
color="green"
|
|
181
|
+
/>
|
|
182
|
+
</template>
|
|
183
|
+
`,
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
export const leftSlot = SlotTemplate.bind({});
|
|
187
|
+
leftSlot.args = {
|
|
188
|
+
slotTemplate: `
|
|
189
|
+
<template #left>
|
|
190
|
+
<UButton variant="thirdary" filled square label="Filter" class="rounded-r-none h-full" />
|
|
191
|
+
</template>
|
|
192
|
+
`,
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
export const rightSlot = SlotTemplate.bind({});
|
|
196
|
+
rightSlot.args = {
|
|
174
197
|
slotTemplate: `
|
|
175
198
|
<template #right>
|
|
176
|
-
|
|
199
|
+
<UButton variant="thirdary" filled square label="Filter" class="rounded-l-none" />
|
|
177
200
|
</template>
|
|
178
201
|
`,
|
|
179
202
|
};
|
package/ui.form-input/index.vue
CHANGED
|
@@ -12,16 +12,25 @@
|
|
|
12
12
|
>
|
|
13
13
|
<label :for="id" v-bind="blockAttrs">
|
|
14
14
|
<span
|
|
15
|
-
v-if="hasSlotContent($slots['left']) || iconLeft"
|
|
15
|
+
v-if="hasSlotContent($slots['icon-left']) || iconLeft"
|
|
16
16
|
ref="leftSlotWrapper"
|
|
17
|
-
v-bind="
|
|
17
|
+
v-bind="leftIconSlotAttrs"
|
|
18
18
|
>
|
|
19
|
-
<!--
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
<!--
|
|
20
|
+
@slot Use it to add icon before the text.
|
|
21
|
+
@binding {string} icon-name
|
|
22
|
+
@binding {string} icon-size
|
|
23
|
+
-->
|
|
24
|
+
<slot name="icon-left" :icon-name="iconLeft" :icon-size="iconSize">
|
|
25
|
+
<UIcon v-if="iconLeft" :name="iconLeft" :size="iconSize" />
|
|
22
26
|
</slot>
|
|
23
27
|
</span>
|
|
24
28
|
|
|
29
|
+
<span v-if="hasSlotContent($slots['left'])" ref="leftSlotWrapper">
|
|
30
|
+
<!-- @slot Use it to add something before the text. -->
|
|
31
|
+
<slot name="left" />
|
|
32
|
+
</span>
|
|
33
|
+
|
|
25
34
|
<span v-bind="inputWrapperAttrs">
|
|
26
35
|
<input
|
|
27
36
|
:id="id"
|
|
@@ -44,7 +53,7 @@
|
|
|
44
53
|
/>
|
|
45
54
|
</span>
|
|
46
55
|
|
|
47
|
-
<label v-if="isTypePassword" v-bind="
|
|
56
|
+
<label v-if="isTypePassword" v-bind="rightIconSlotAttrs" :for="id">
|
|
48
57
|
<UIcon
|
|
49
58
|
v-if="isTypePassword"
|
|
50
59
|
:name="isShownPassword ? config.passwordVisibleIconName : config.passwordHiddenIconName"
|
|
@@ -57,10 +66,17 @@
|
|
|
57
66
|
/>
|
|
58
67
|
</label>
|
|
59
68
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
69
|
+
<!-- @slot Use it to add something after the text. -->
|
|
70
|
+
<slot name="right" />
|
|
71
|
+
|
|
72
|
+
<span v-if="hasSlotContent($slots['icon-right']) || iconRight" v-bind="rightIconSlotAttrs">
|
|
73
|
+
<!--
|
|
74
|
+
@slot Use it to add icon after the text.
|
|
75
|
+
@binding {string} icon-name
|
|
76
|
+
@binding {string} icon-size
|
|
77
|
+
-->
|
|
78
|
+
<slot name="icon-right" :icon-name="iconLeft" :icon-size="iconSize">
|
|
79
|
+
<UIcon v-if="iconRight" :name="iconRight" :size="iconSize" />
|
|
64
80
|
</slot>
|
|
65
81
|
</span>
|
|
66
82
|
</label>
|
|
@@ -88,18 +104,48 @@ import UIService from "../service.ui";
|
|
|
88
104
|
|
|
89
105
|
import defaultConfig from "./configs/default.config";
|
|
90
106
|
import { UInput } from "./constants";
|
|
91
|
-
import
|
|
107
|
+
import useAttrs from "./composables/attrs.composable";
|
|
92
108
|
|
|
93
109
|
/* Should be a string for correct web-types gen */
|
|
94
110
|
defineOptions({ name: "UInput", inheritAttrs: false });
|
|
95
111
|
|
|
96
112
|
const emit = defineEmits([
|
|
113
|
+
/**
|
|
114
|
+
* Triggers when the input value is updated.
|
|
115
|
+
* @property {string} modelValue
|
|
116
|
+
* @property {number} modelValue
|
|
117
|
+
*/
|
|
97
118
|
"update:modelValue",
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* Triggers when the input value changes.
|
|
122
|
+
*/
|
|
98
123
|
"change",
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Triggers when the input is clicked.
|
|
127
|
+
*/
|
|
99
128
|
"click",
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Triggers when the input gains focus.
|
|
132
|
+
*/
|
|
100
133
|
"focus",
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Triggers when the mouse is pressed down on the input.
|
|
137
|
+
*/
|
|
101
138
|
"mousedown",
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Triggers when the input loses focus.
|
|
142
|
+
*/
|
|
102
143
|
"blur",
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Triggers when any validation rules are applied to input value.
|
|
147
|
+
* @property {string} value
|
|
148
|
+
*/
|
|
103
149
|
"input",
|
|
104
150
|
]);
|
|
105
151
|
|
|
@@ -162,6 +208,22 @@ const props = defineProps({
|
|
|
162
208
|
default: UIService.get(defaultConfig, UInput).default.size,
|
|
163
209
|
},
|
|
164
210
|
|
|
211
|
+
/**
|
|
212
|
+
* Left side icon name.
|
|
213
|
+
*/
|
|
214
|
+
iconLeft: {
|
|
215
|
+
type: String,
|
|
216
|
+
default: "",
|
|
217
|
+
},
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Right side icon name.
|
|
221
|
+
*/
|
|
222
|
+
iconRight: {
|
|
223
|
+
type: String,
|
|
224
|
+
default: "",
|
|
225
|
+
},
|
|
226
|
+
|
|
165
227
|
/**
|
|
166
228
|
* Maximum character length.
|
|
167
229
|
*/
|
|
@@ -247,22 +309,6 @@ const props = defineProps({
|
|
|
247
309
|
type: String,
|
|
248
310
|
default: "",
|
|
249
311
|
},
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* Left side icon name.
|
|
253
|
-
*/
|
|
254
|
-
iconLeft: {
|
|
255
|
-
type: String,
|
|
256
|
-
default: "",
|
|
257
|
-
},
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Right side icon name.
|
|
261
|
-
*/
|
|
262
|
-
iconRight: {
|
|
263
|
-
type: String,
|
|
264
|
-
default: "",
|
|
265
|
-
},
|
|
266
312
|
});
|
|
267
313
|
|
|
268
314
|
const slots = useSlots();
|
|
@@ -293,12 +339,22 @@ const {
|
|
|
293
339
|
blockAttrs,
|
|
294
340
|
labelAttrs,
|
|
295
341
|
passwordIconAttrs,
|
|
296
|
-
|
|
342
|
+
leftIconSlotAttrs,
|
|
297
343
|
inputWrapperAttrs,
|
|
298
|
-
|
|
344
|
+
rightIconSlotAttrs,
|
|
299
345
|
hasSlotContent,
|
|
300
346
|
} = useAttrs(props, { isTypePassword, inputPasswordClasses });
|
|
301
347
|
|
|
348
|
+
const iconSize = computed(() => {
|
|
349
|
+
const sizes = {
|
|
350
|
+
sm: "sm",
|
|
351
|
+
md: "md",
|
|
352
|
+
lg: "lg",
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
return sizes[props.size];
|
|
356
|
+
});
|
|
357
|
+
|
|
302
358
|
const inputType = computed(() => {
|
|
303
359
|
return isShownPassword.value || props.noAutocomplete ? "text" : props.type;
|
|
304
360
|
});
|
|
@@ -376,24 +432,19 @@ function transformValue(value, exp) {
|
|
|
376
432
|
}
|
|
377
433
|
|
|
378
434
|
function setLabelPosition() {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
let leftSlotOrIconWidth = 0;
|
|
435
|
+
const shouldAlignLabelOnTop =
|
|
436
|
+
!hasSlotContent(slots["icon-left"]) && !hasSlotContent(slots["left"]) && !props.iconLeft;
|
|
382
437
|
|
|
383
|
-
if (
|
|
384
|
-
|
|
438
|
+
if (props.labelAlign === "top" || shouldAlignLabelOnTop) {
|
|
439
|
+
return;
|
|
385
440
|
}
|
|
386
441
|
|
|
387
|
-
|
|
388
|
-
const iconLeftElement = document.querySelector(`#${props.id} ~ .ui-icon`);
|
|
442
|
+
let leftSlotOrIconWidth = leftSlotWrapper.value.getBoundingClientRect().width;
|
|
389
443
|
|
|
390
|
-
|
|
391
|
-
leftSlotOrIconWidth = iconLeftElement.getBoundingClientRect().width;
|
|
392
|
-
}
|
|
393
|
-
}
|
|
444
|
+
const leftPaddingValue = parseFloat(getComputedStyle(input.value).paddingLeft);
|
|
394
445
|
|
|
395
446
|
if (labelComponent.value.labelElement) {
|
|
396
|
-
labelComponent.value.labelElement.style.left = `${leftSlotOrIconWidth}px`;
|
|
447
|
+
labelComponent.value.labelElement.style.left = `${leftSlotOrIconWidth + leftPaddingValue}px`;
|
|
397
448
|
}
|
|
398
449
|
}
|
|
399
450
|
</script>
|
|
@@ -33,7 +33,7 @@ export default /*tw*/ {
|
|
|
33
33
|
],
|
|
34
34
|
},
|
|
35
35
|
innerWrapper: {
|
|
36
|
-
base: "flex px-4 min-h-full w-full overflow-hidden",
|
|
36
|
+
base: "flex px-4 min-h-full w-full overflow-hidden justify-between",
|
|
37
37
|
variants: {
|
|
38
38
|
multiple: {
|
|
39
39
|
true: "grid grid-cols-1 grid-rows-[minmax(0, 1fr)_min-content]",
|
|
@@ -43,7 +43,8 @@ export default /*tw*/ {
|
|
|
43
43
|
wrapperActive: "z-[inherit]", // applies when select active
|
|
44
44
|
labelWrapperTop: "group/top", // applies when an open direction is top
|
|
45
45
|
labelWrapperActive: "group/active",
|
|
46
|
-
|
|
46
|
+
leftIconSlot: "pr-3 flex items-center",
|
|
47
|
+
rightIconSlot: "pl-3 flex items-center",
|
|
47
48
|
caret: {
|
|
48
49
|
base: "flex items-center mt-0",
|
|
49
50
|
compoundVariants: [
|