vueless 0.0.200 → 0.0.202
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/composable.ui/index.js +3 -2
- package/package.json +2 -2
- package/service.storybook/index.js +1 -1
- package/ui.button/composables/attrs.composable.js +6 -2
- package/ui.button/configs/default.config.js +14 -2
- package/ui.button/index.stories.js +27 -3
- package/ui.button/index.vue +70 -27
- package/ui.button-link/composables/attrs.composable.js +64 -130
- package/ui.button-link/index.stories.js +2 -4
- package/ui.button-link/index.vue +29 -4
- package/ui.button-toggle/composables/attrs.composable.js +21 -33
- package/ui.button-toggle/configs/default.config.js +2 -2
- package/ui.button-toggle/index.vue +8 -2
- package/ui.button-toggle-item/composables/attrs.composable.js +50 -40
- package/ui.button-toggle-item/configs/default.config.js +1 -1
- package/ui.button-toggle-item/index.stories.js +2 -4
- package/ui.button-toggle-item/index.vue +11 -3
- package/ui.dropdown-badge/composables/attrs.composable.js +45 -45
- package/ui.dropdown-badge/configs/default.config.js +3 -3
- package/ui.dropdown-badge/index.stories.js +2 -4
- package/ui.dropdown-badge/index.vue +8 -2
- package/ui.dropdown-button/composables/attrs.composable.js +45 -45
- package/ui.dropdown-button/configs/default.config.js +3 -3
- package/ui.dropdown-button/index.stories.js +2 -4
- package/ui.dropdown-button/index.vue +8 -2
- package/ui.dropdown-item/index.vue +7 -1
- package/ui.dropdown-link/composables/attrs.composable.js +43 -45
- package/ui.dropdown-link/configs/default.config.js +3 -3
- package/ui.dropdown-link/index.stories.js +2 -4
- package/ui.dropdown-link/index.vue +8 -2
- package/ui.dropdown-list/composables/attrs.composable.js +43 -67
- package/ui.dropdown-list/configs/default.config.js +2 -2
- package/ui.dropdown-list/index.vue +19 -3
- package/ui.form-calendar/components/DayView.vue +4 -4
- package/ui.form-calendar/composables/attrs.composable.js +5 -4
- package/ui.form-input/composables/attrs.composable.js +31 -48
- package/ui.form-input/configs/default.config.js +3 -3
- package/ui.form-input/index.stories.js +32 -9
- package/ui.form-input/index.vue +92 -41
- package/ui.navigation-progress/components/StepperProgress.vue +87 -0
- package/ui.navigation-progress/composables/attrs.composable.js +33 -56
- package/ui.navigation-progress/configs/default.config.js +34 -1
- package/ui.navigation-progress/constants/index.js +5 -0
- package/ui.navigation-progress/index.stories.js +3 -0
- package/ui.navigation-progress/index.vue +55 -9
- package/ui.text-alert/composables/attrs.composable.js +23 -39
- package/ui.text-alert/configs/default.config.js +3 -3
- package/ui.text-alert/index.vue +19 -8
- package/ui.text-badge/composables/attrs.composable.js +25 -36
- package/ui.text-badge/index.stories.js +2 -4
- package/ui.text-badge/index.vue +22 -2
- package/ui.text-block/composables/attrs.composable.js +24 -20
- package/ui.text-block/index.vue +1 -1
- package/ui.text-empty/composables/attrs.composable.js +17 -27
- package/ui.text-empty/configs/default.config.js +1 -1
- package/ui.text-empty/index.stories.js +2 -4
- package/ui.text-empty/index.vue +1 -1
- package/ui.text-header/composables/attrs.composable.js +28 -22
- package/ui.text-header/index.stories.js +1 -1
- package/ui.text-header/index.vue +1 -1
- package/ui.text-money/composables/attrs.composable.js +21 -48
- package/ui.text-money/index.stories.js +2 -4
- package/web-types.json +326 -145
- package/ui.navigation-stepper/Docs.mdx +0 -16
- package/ui.navigation-stepper/composables/attrs.composable.js +0 -25
- package/ui.navigation-stepper/configs/default.config.js +0 -13
- package/ui.navigation-stepper/constants/index.js +0 -5
- package/ui.navigation-stepper/index.stories.js +0 -33
- package/ui.navigation-stepper/index.vue +0 -126
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getArgTypes, getSlotNames } from "../service.storybook";
|
|
1
|
+
import { getArgTypes, getSlotNames, allSlotsFragment } from "../service.storybook";
|
|
2
2
|
|
|
3
3
|
import UDropdownLink from "../ui.dropdown-link";
|
|
4
4
|
import UDropdownItem from "../ui.dropdown-item";
|
|
@@ -42,9 +42,7 @@ const DefaultTemplate = (args) => ({
|
|
|
42
42
|
<UDropdownLink
|
|
43
43
|
v-bind="args"
|
|
44
44
|
>
|
|
45
|
-
|
|
46
|
-
<template v-if="args[slot]">{{ args[slot] }}</template>
|
|
47
|
-
</template>
|
|
45
|
+
${allSlotsFragment}
|
|
48
46
|
</UDropdownLink>
|
|
49
47
|
`,
|
|
50
48
|
});
|
|
@@ -67,7 +67,7 @@ import vClickOutside from "../directive.clickOutside";
|
|
|
67
67
|
|
|
68
68
|
import { UDropdownLink } from "./constants";
|
|
69
69
|
import defaultConfig from "./configs/default.config";
|
|
70
|
-
import
|
|
70
|
+
import useAttrs from "./composables/attrs.composable";
|
|
71
71
|
import { UDropdownButton } from "../ui.dropdown-button/constants/index.js";
|
|
72
72
|
|
|
73
73
|
/* Should be a string for correct web-types gen */
|
|
@@ -208,7 +208,13 @@ const props = defineProps({
|
|
|
208
208
|
},
|
|
209
209
|
});
|
|
210
210
|
|
|
211
|
-
const emit = defineEmits([
|
|
211
|
+
const emit = defineEmits([
|
|
212
|
+
/**
|
|
213
|
+
* Triggers when dropdown option is selected.
|
|
214
|
+
* @property {string} value
|
|
215
|
+
*/
|
|
216
|
+
"select",
|
|
217
|
+
]);
|
|
212
218
|
|
|
213
219
|
provide("hideDropdownOptions", hideOptions);
|
|
214
220
|
|
|
@@ -5,65 +5,53 @@ import defaultConfig from "../configs/default.config";
|
|
|
5
5
|
import { computed } from "vue";
|
|
6
6
|
|
|
7
7
|
export default function useAttrs(props) {
|
|
8
|
-
const { config, getAttrs, hasSlotContent } = useUI(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
variants: subGroupLabel.variants,
|
|
14
|
-
compoundVariants: subGroupLabel.compoundVariants,
|
|
15
|
-
});
|
|
16
|
-
const cvaGroupLabel = cva({
|
|
17
|
-
base: groupLabel.base,
|
|
18
|
-
variants: groupLabel.variants,
|
|
19
|
-
compoundVariants: groupLabel.compoundVariants,
|
|
20
|
-
});
|
|
21
|
-
const cvaOption = cva({
|
|
22
|
-
base: option.base,
|
|
23
|
-
variants: option.variants,
|
|
24
|
-
compoundVariants: option.compoundVariants,
|
|
25
|
-
});
|
|
8
|
+
const { config, getAttrs, hasSlotContent, isSystemKey } = useUI(
|
|
9
|
+
defaultConfig,
|
|
10
|
+
() => props.config,
|
|
11
|
+
);
|
|
12
|
+
const attrs = {};
|
|
26
13
|
|
|
27
14
|
const optionClasses = computed(() =>
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
size: props.size,
|
|
31
|
-
}),
|
|
32
|
-
);
|
|
33
|
-
const subGroupLabelClasses = computed(() =>
|
|
34
|
-
cvaSubGroupLabel({
|
|
35
|
-
size: props.size,
|
|
36
|
-
}),
|
|
37
|
-
);
|
|
38
|
-
const groupLabelClasses = computed(() =>
|
|
39
|
-
cvaGroupLabel({
|
|
40
|
-
size: props.size,
|
|
15
|
+
cva(config.value.option)({
|
|
16
|
+
...props,
|
|
41
17
|
}),
|
|
42
18
|
);
|
|
43
19
|
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
20
|
+
for (const key in defaultConfig) {
|
|
21
|
+
if (isSystemKey(key)) continue;
|
|
22
|
+
|
|
23
|
+
const classes = computed(() => {
|
|
24
|
+
const value = config.value[key];
|
|
25
|
+
|
|
26
|
+
if (value.variants || value.compoundVariants) {
|
|
27
|
+
return cva(value)({
|
|
28
|
+
...props,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
55
31
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
...subGroupLabelAttrsRaw.value,
|
|
59
|
-
class: cx([optionClasses.value, subGroupLabelAttrsRaw.value.class]),
|
|
60
|
-
}));
|
|
32
|
+
return "";
|
|
33
|
+
});
|
|
61
34
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
35
|
+
attrs[`${key}Attrs`] = getAttrs(key, { classes });
|
|
36
|
+
|
|
37
|
+
if (key === "subGroupLabel") {
|
|
38
|
+
const subGroupLabelAttrs = attrs[`${key}Attrs`];
|
|
39
|
+
|
|
40
|
+
attrs[`${key}Attrs`] = computed(() => ({
|
|
41
|
+
...subGroupLabelAttrs.value,
|
|
42
|
+
class: cx([subGroupLabelAttrs.value.class, optionClasses.value]),
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (key === "groupLabel") {
|
|
47
|
+
const groupLabelAttrs = attrs[`${key}Attrs`];
|
|
48
|
+
|
|
49
|
+
attrs[`${key}Attrs`] = computed(() => ({
|
|
50
|
+
...groupLabelAttrs.value,
|
|
51
|
+
class: cx([groupLabelAttrs.value.class, optionClasses.value]),
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
67
55
|
|
|
68
56
|
const optionAttrs = (classes = []) => {
|
|
69
57
|
const mergedClasses = cx([optionClasses.value, ...classes]);
|
|
@@ -72,22 +60,10 @@ export default function useAttrs(props) {
|
|
|
72
60
|
};
|
|
73
61
|
|
|
74
62
|
return {
|
|
75
|
-
|
|
76
|
-
config,
|
|
77
|
-
wrapperAttrs,
|
|
78
|
-
listAttrs,
|
|
79
|
-
optionHighlightAttrs,
|
|
80
|
-
optionSelectedAttrs,
|
|
81
|
-
optionItemAttrs,
|
|
82
|
-
addTitleWrapperAttrs,
|
|
83
|
-
addTitleAttrs,
|
|
84
|
-
addTitleHotkeyAttrs,
|
|
85
|
-
buttonAddAttrs,
|
|
86
|
-
addIconAttrs,
|
|
63
|
+
...attrs,
|
|
87
64
|
optionAttrs,
|
|
88
|
-
subGroupLabelAttrs,
|
|
89
|
-
groupLabelAttrs,
|
|
90
65
|
optionClasses,
|
|
91
|
-
|
|
66
|
+
hasSlotContent,
|
|
67
|
+
config,
|
|
92
68
|
};
|
|
93
69
|
}
|
|
@@ -54,9 +54,9 @@ export default /*tw*/ {
|
|
|
54
54
|
`,
|
|
55
55
|
addTitle: "text-sm font-medium text-gray-900",
|
|
56
56
|
addTitleHotkey: "text-gray-500",
|
|
57
|
-
buttonAdd: "sticky left-[calc(100%-2.3rem)] bottom-2.5 p-1",
|
|
57
|
+
buttonAdd: "{UButton} sticky left-[calc(100%-2.3rem)] bottom-2.5 p-1",
|
|
58
58
|
addIconName: "add",
|
|
59
|
-
addIcon: "bg-transparent",
|
|
59
|
+
addIcon: "{UIcon} bg-transparent",
|
|
60
60
|
i18n: {
|
|
61
61
|
noDataToShow: "No data to show.",
|
|
62
62
|
add: "Add",
|
|
@@ -25,9 +25,17 @@
|
|
|
25
25
|
@click.stop="select(option)"
|
|
26
26
|
@mouseenter.self="pointerSet(index)"
|
|
27
27
|
>
|
|
28
|
-
<!--
|
|
28
|
+
<!--
|
|
29
|
+
@slot Use it to add something before the option.
|
|
30
|
+
@binding {other} option
|
|
31
|
+
-->
|
|
29
32
|
<slot :option="option" name="before-option" />
|
|
30
33
|
|
|
34
|
+
<!--
|
|
35
|
+
@slot Use it to add something instead of the option.
|
|
36
|
+
@binding {other} option
|
|
37
|
+
@binding {number} index
|
|
38
|
+
-->
|
|
31
39
|
<slot name="option" :option="option" :index="index">
|
|
32
40
|
<span
|
|
33
41
|
:style="getMarginForSubCategory(option.level)"
|
|
@@ -36,7 +44,10 @@
|
|
|
36
44
|
/>
|
|
37
45
|
</slot>
|
|
38
46
|
|
|
39
|
-
<!--
|
|
47
|
+
<!--
|
|
48
|
+
@slot Use it to add something after the option.
|
|
49
|
+
@binding {other} option
|
|
50
|
+
-->
|
|
40
51
|
<slot :option="option" name="after-option" />
|
|
41
52
|
</span>
|
|
42
53
|
|
|
@@ -198,7 +209,12 @@ const props = defineProps({
|
|
|
198
209
|
},
|
|
199
210
|
});
|
|
200
211
|
|
|
201
|
-
const emit = defineEmits([
|
|
212
|
+
const emit = defineEmits([
|
|
213
|
+
/**
|
|
214
|
+
* Triggers when option is added.
|
|
215
|
+
*/
|
|
216
|
+
"addOption",
|
|
217
|
+
]);
|
|
202
218
|
|
|
203
219
|
const wrapperRef = ref(null);
|
|
204
220
|
const optionsRef = ref([]);
|
|
@@ -245,19 +245,19 @@ function getDayClasses(day) {
|
|
|
245
245
|
}
|
|
246
246
|
|
|
247
247
|
if (isDayInRange) {
|
|
248
|
-
return
|
|
248
|
+
return inRangeDayAttrs.value.class;
|
|
249
249
|
}
|
|
250
250
|
|
|
251
251
|
if (isSelectedDay(day)) {
|
|
252
|
-
return
|
|
252
|
+
return selectedDayAttrs.value.class;
|
|
253
253
|
}
|
|
254
254
|
|
|
255
255
|
if (isSameDay(props.activeDate, day)) {
|
|
256
|
-
return
|
|
256
|
+
return activeDayAttrs.value.class;
|
|
257
257
|
}
|
|
258
258
|
|
|
259
259
|
if (isAnotherMothDay(day, activeMonthDate.value)) {
|
|
260
|
-
return
|
|
260
|
+
return anotherMonthDayAttrs.value.class;
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
263
|
|
|
@@ -55,17 +55,18 @@ export default function useAttrs(props) {
|
|
|
55
55
|
});
|
|
56
56
|
const timepickerSubmitButtonAttrs = getAttrs("timepickerSubmitButton");
|
|
57
57
|
|
|
58
|
-
const nextPrevWrapperAttrs = getAttrs("nextPrevWrapper", { classes: optionClasses
|
|
58
|
+
const nextPrevWrapperAttrs = getAttrs("nextPrevWrapper", { classes: optionClasses });
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
// TODO: Need to find other solution
|
|
61
|
+
const dayAttrs = (classes) => {
|
|
61
62
|
return getAttrs("day", { classes }).value;
|
|
62
63
|
};
|
|
63
64
|
|
|
64
|
-
const monthAttrs = (classes
|
|
65
|
+
const monthAttrs = (classes) => {
|
|
65
66
|
return getAttrs("month", { classes, isComponent: true }).value;
|
|
66
67
|
};
|
|
67
68
|
|
|
68
|
-
const yearAttrs = (classes
|
|
69
|
+
const yearAttrs = (classes) => {
|
|
69
70
|
return getAttrs("year", { classes, isComponent: true }).value;
|
|
70
71
|
};
|
|
71
72
|
|
|
@@ -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>
|