vueless 0.0.200 → 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/web-types.json +146 -49
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>
|
package/web-types.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"framework": "vue",
|
|
3
3
|
"name": "vueless",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.201",
|
|
5
5
|
"contributions": {
|
|
6
6
|
"html": {
|
|
7
7
|
"description-markup": "markdown",
|
|
@@ -732,6 +732,24 @@
|
|
|
732
732
|
},
|
|
733
733
|
"default": "md"
|
|
734
734
|
},
|
|
735
|
+
{
|
|
736
|
+
"name": "iconLeft",
|
|
737
|
+
"description": "Left side icon name.",
|
|
738
|
+
"value": {
|
|
739
|
+
"kind": "expression",
|
|
740
|
+
"type": "string"
|
|
741
|
+
},
|
|
742
|
+
"default": "\"\""
|
|
743
|
+
},
|
|
744
|
+
{
|
|
745
|
+
"name": "iconRight",
|
|
746
|
+
"description": "Right side icon name.",
|
|
747
|
+
"value": {
|
|
748
|
+
"kind": "expression",
|
|
749
|
+
"type": "string"
|
|
750
|
+
},
|
|
751
|
+
"default": "\"\""
|
|
752
|
+
},
|
|
735
753
|
{
|
|
736
754
|
"name": "label",
|
|
737
755
|
"description": "Button label.",
|
|
@@ -830,38 +848,58 @@
|
|
|
830
848
|
"type": "string"
|
|
831
849
|
},
|
|
832
850
|
"default": "\"\""
|
|
833
|
-
},
|
|
834
|
-
{
|
|
835
|
-
"name": "iconLeft",
|
|
836
|
-
"description": "Left side icon name.",
|
|
837
|
-
"value": {
|
|
838
|
-
"kind": "expression",
|
|
839
|
-
"type": "string"
|
|
840
|
-
},
|
|
841
|
-
"default": "\"\""
|
|
842
|
-
},
|
|
843
|
-
{
|
|
844
|
-
"name": "iconRight",
|
|
845
|
-
"description": "Right side icon name.",
|
|
846
|
-
"value": {
|
|
847
|
-
"kind": "expression",
|
|
848
|
-
"type": "string"
|
|
849
|
-
},
|
|
850
|
-
"default": "\"\""
|
|
851
851
|
}
|
|
852
852
|
],
|
|
853
853
|
"slots": [
|
|
854
|
+
{
|
|
855
|
+
"name": "icon-left",
|
|
856
|
+
"scoped": true,
|
|
857
|
+
"description": "Use it to add icon before the text.",
|
|
858
|
+
"bindings": [
|
|
859
|
+
{
|
|
860
|
+
"type": "string",
|
|
861
|
+
"name": "icon-name"
|
|
862
|
+
},
|
|
863
|
+
{
|
|
864
|
+
"type": "string",
|
|
865
|
+
"name": "icon-size"
|
|
866
|
+
},
|
|
867
|
+
{
|
|
868
|
+
"type": "string",
|
|
869
|
+
"name": "icon-color"
|
|
870
|
+
}
|
|
871
|
+
]
|
|
872
|
+
},
|
|
854
873
|
{
|
|
855
874
|
"name": "left",
|
|
856
|
-
"description": "Use it to add
|
|
875
|
+
"description": "Use it to add something before the text."
|
|
857
876
|
},
|
|
858
877
|
{
|
|
859
878
|
"name": "default",
|
|
860
|
-
"description": "Use it to add something instead of text."
|
|
879
|
+
"description": "Use it to add something instead of the text."
|
|
861
880
|
},
|
|
862
881
|
{
|
|
863
882
|
"name": "right",
|
|
864
|
-
"description": "Use it to add
|
|
883
|
+
"description": "Use it to add something after the text."
|
|
884
|
+
},
|
|
885
|
+
{
|
|
886
|
+
"name": "icon-right",
|
|
887
|
+
"scoped": true,
|
|
888
|
+
"description": "Use it to add icon after the text.",
|
|
889
|
+
"bindings": [
|
|
890
|
+
{
|
|
891
|
+
"type": "string",
|
|
892
|
+
"name": "icon-name"
|
|
893
|
+
},
|
|
894
|
+
{
|
|
895
|
+
"type": "string",
|
|
896
|
+
"name": "icon-size"
|
|
897
|
+
},
|
|
898
|
+
{
|
|
899
|
+
"type": "string",
|
|
900
|
+
"name": "icon-color"
|
|
901
|
+
}
|
|
902
|
+
]
|
|
865
903
|
}
|
|
866
904
|
],
|
|
867
905
|
"source": {
|
|
@@ -3639,6 +3677,24 @@
|
|
|
3639
3677
|
},
|
|
3640
3678
|
"default": "md"
|
|
3641
3679
|
},
|
|
3680
|
+
{
|
|
3681
|
+
"name": "iconLeft",
|
|
3682
|
+
"description": "Left side icon name.",
|
|
3683
|
+
"value": {
|
|
3684
|
+
"kind": "expression",
|
|
3685
|
+
"type": "string"
|
|
3686
|
+
},
|
|
3687
|
+
"default": "\"\""
|
|
3688
|
+
},
|
|
3689
|
+
{
|
|
3690
|
+
"name": "iconRight",
|
|
3691
|
+
"description": "Right side icon name.",
|
|
3692
|
+
"value": {
|
|
3693
|
+
"kind": "expression",
|
|
3694
|
+
"type": "string"
|
|
3695
|
+
},
|
|
3696
|
+
"default": "\"\""
|
|
3697
|
+
},
|
|
3642
3698
|
{
|
|
3643
3699
|
"name": "maxLength",
|
|
3644
3700
|
"description": "Maximum character length.",
|
|
@@ -3728,57 +3784,98 @@
|
|
|
3728
3784
|
"type": "string"
|
|
3729
3785
|
},
|
|
3730
3786
|
"default": "\"\""
|
|
3731
|
-
},
|
|
3732
|
-
{
|
|
3733
|
-
"name": "iconLeft",
|
|
3734
|
-
"description": "Left side icon name.",
|
|
3735
|
-
"value": {
|
|
3736
|
-
"kind": "expression",
|
|
3737
|
-
"type": "string"
|
|
3738
|
-
},
|
|
3739
|
-
"default": "\"\""
|
|
3740
|
-
},
|
|
3741
|
-
{
|
|
3742
|
-
"name": "iconRight",
|
|
3743
|
-
"description": "Right side icon name.",
|
|
3744
|
-
"value": {
|
|
3745
|
-
"kind": "expression",
|
|
3746
|
-
"type": "string"
|
|
3747
|
-
},
|
|
3748
|
-
"default": "\"\""
|
|
3749
3787
|
}
|
|
3750
3788
|
],
|
|
3751
3789
|
"events": [
|
|
3752
3790
|
{
|
|
3753
|
-
"name": "update:modelValue"
|
|
3791
|
+
"name": "update:modelValue",
|
|
3792
|
+
"description": "Triggers when the input value is updated.",
|
|
3793
|
+
"properties": [
|
|
3794
|
+
{
|
|
3795
|
+
"type": [
|
|
3796
|
+
"string"
|
|
3797
|
+
],
|
|
3798
|
+
"name": "modelValue"
|
|
3799
|
+
},
|
|
3800
|
+
{
|
|
3801
|
+
"type": [
|
|
3802
|
+
"number"
|
|
3803
|
+
],
|
|
3804
|
+
"name": "modelValue"
|
|
3805
|
+
}
|
|
3806
|
+
]
|
|
3754
3807
|
},
|
|
3755
3808
|
{
|
|
3756
|
-
"name": "change"
|
|
3809
|
+
"name": "change",
|
|
3810
|
+
"description": "Triggers when the input value changes."
|
|
3757
3811
|
},
|
|
3758
3812
|
{
|
|
3759
|
-
"name": "click"
|
|
3813
|
+
"name": "click",
|
|
3814
|
+
"description": "Triggers when the input is clicked."
|
|
3760
3815
|
},
|
|
3761
3816
|
{
|
|
3762
|
-
"name": "focus"
|
|
3817
|
+
"name": "focus",
|
|
3818
|
+
"description": "Triggers when the input gains focus."
|
|
3763
3819
|
},
|
|
3764
3820
|
{
|
|
3765
|
-
"name": "mousedown"
|
|
3821
|
+
"name": "mousedown",
|
|
3822
|
+
"description": "Triggers when the mouse is pressed down on the input."
|
|
3766
3823
|
},
|
|
3767
3824
|
{
|
|
3768
|
-
"name": "blur"
|
|
3825
|
+
"name": "blur",
|
|
3826
|
+
"description": "Triggers when the input loses focus."
|
|
3769
3827
|
},
|
|
3770
3828
|
{
|
|
3771
|
-
"name": "input"
|
|
3829
|
+
"name": "input",
|
|
3830
|
+
"description": "Triggers when any validation rules are applied to input value.",
|
|
3831
|
+
"properties": [
|
|
3832
|
+
{
|
|
3833
|
+
"type": [
|
|
3834
|
+
"string"
|
|
3835
|
+
],
|
|
3836
|
+
"name": "value"
|
|
3837
|
+
}
|
|
3838
|
+
]
|
|
3772
3839
|
}
|
|
3773
3840
|
],
|
|
3774
3841
|
"slots": [
|
|
3842
|
+
{
|
|
3843
|
+
"name": "icon-left",
|
|
3844
|
+
"scoped": true,
|
|
3845
|
+
"description": "Use it to add icon before the text.",
|
|
3846
|
+
"bindings": [
|
|
3847
|
+
{
|
|
3848
|
+
"type": "string",
|
|
3849
|
+
"name": "icon-name"
|
|
3850
|
+
},
|
|
3851
|
+
{
|
|
3852
|
+
"type": "string",
|
|
3853
|
+
"name": "icon-size"
|
|
3854
|
+
}
|
|
3855
|
+
]
|
|
3856
|
+
},
|
|
3775
3857
|
{
|
|
3776
3858
|
"name": "left",
|
|
3777
|
-
"description": "Use it to add
|
|
3859
|
+
"description": "Use it to add something before the text."
|
|
3778
3860
|
},
|
|
3779
3861
|
{
|
|
3780
3862
|
"name": "right",
|
|
3781
|
-
"description": "Use it to add
|
|
3863
|
+
"description": "Use it to add something after the text."
|
|
3864
|
+
},
|
|
3865
|
+
{
|
|
3866
|
+
"name": "icon-right",
|
|
3867
|
+
"scoped": true,
|
|
3868
|
+
"description": "Use it to add icon after the text.",
|
|
3869
|
+
"bindings": [
|
|
3870
|
+
{
|
|
3871
|
+
"type": "string",
|
|
3872
|
+
"name": "icon-name"
|
|
3873
|
+
},
|
|
3874
|
+
{
|
|
3875
|
+
"type": "string",
|
|
3876
|
+
"name": "icon-size"
|
|
3877
|
+
}
|
|
3878
|
+
]
|
|
3782
3879
|
}
|
|
3783
3880
|
],
|
|
3784
3881
|
"source": {
|