vueless 0.0.189 → 0.0.190
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
CHANGED
|
@@ -6,10 +6,9 @@ import defaultConfig from "../configs/default.config";
|
|
|
6
6
|
const componentKeys = ["icon", "divider"];
|
|
7
7
|
|
|
8
8
|
export function useAttrs(props, { isOpened }) {
|
|
9
|
-
const { config, getAttrs } = useUI(defaultConfig, () => props.config);
|
|
9
|
+
const { config, getAttrs, hasSlotContent } = useUI(defaultConfig, () => props.config);
|
|
10
10
|
const attrs = {};
|
|
11
11
|
|
|
12
|
-
// New approach of defining attrs dynamically (need to test).
|
|
13
12
|
for (const key in defaultConfig) {
|
|
14
13
|
if (isSystemKey(key)) continue;
|
|
15
14
|
|
|
@@ -33,5 +32,6 @@ export function useAttrs(props, { isOpened }) {
|
|
|
33
32
|
return {
|
|
34
33
|
...attrs,
|
|
35
34
|
config,
|
|
35
|
+
hasSlotContent,
|
|
36
36
|
};
|
|
37
37
|
}
|
|
@@ -1,184 +1,116 @@
|
|
|
1
|
+
import { computed } from "vue";
|
|
1
2
|
import useUI from "../../composable.ui";
|
|
2
|
-
import { cva, cx } from "../../service.ui";
|
|
3
|
-
|
|
3
|
+
import { cva, cx, isSystemKey } from "../../service.ui";
|
|
4
4
|
import defaultConfig from "../configs/default.config";
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
const componentKeys = ["dropdownList", "toggleIcon", "clearIcon", "removeItemIcon", "label"];
|
|
6
7
|
|
|
7
8
|
export default function useAttrs(props, { isTop, isOpen, selectedLabel: selectedLabelValue }) {
|
|
8
9
|
const { config, getAttrs, hasSlotContent } = useUI(defaultConfig, () => props.config);
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
const cvaWrapper = cva({
|
|
12
|
-
base: wrapper.base,
|
|
13
|
-
variants: wrapper.variants,
|
|
14
|
-
compoundVariants: wrapper.compoundVariants,
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
const cvaInnerWrapper = cva({
|
|
18
|
-
base: innerWrapper.base,
|
|
19
|
-
variants: innerWrapper.variants,
|
|
20
|
-
compoundVariants: innerWrapper.compoundVariants,
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
const cvaSearchInput = cva({
|
|
24
|
-
base: searchInput.base,
|
|
25
|
-
variants: searchInput.variants,
|
|
26
|
-
compoundVariants: searchInput.compoundVariants,
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
const cvaSelectedLabel = cva({
|
|
30
|
-
base: selectedLabel.base,
|
|
31
|
-
variants: selectedLabel.variants,
|
|
32
|
-
compoundVariants: selectedLabel.compoundVariants,
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
const cvaCaret = cva({
|
|
36
|
-
base: caret.base,
|
|
37
|
-
variants: caret.variants,
|
|
38
|
-
compoundVariants: caret.compoundVariants,
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
const cvaCaretClearText = cva({
|
|
42
|
-
base: caretClearText.base,
|
|
43
|
-
variants: caretClearText.variants,
|
|
44
|
-
compoundVariants: caretClearText.compoundVariants,
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
const wrapperClasses = computed(() =>
|
|
48
|
-
cvaWrapper({
|
|
49
|
-
size: props.size,
|
|
50
|
-
error: Boolean(props.error),
|
|
51
|
-
disabled: props.disabled,
|
|
52
|
-
labelAlign: props.labelAlign,
|
|
53
|
-
label: Boolean(props.label),
|
|
54
|
-
}),
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
const innerWrapperClasses = computed(() =>
|
|
58
|
-
cvaInnerWrapper({
|
|
59
|
-
multiple: props.multiple,
|
|
60
|
-
size: props.size,
|
|
61
|
-
}),
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
const searchInputClasses = computed(() =>
|
|
65
|
-
cvaSearchInput({
|
|
66
|
-
size: props.size,
|
|
67
|
-
}),
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
const selectedLabelClasses = computed(() =>
|
|
71
|
-
cvaSelectedLabel({
|
|
72
|
-
size: props.size,
|
|
73
|
-
disabled: props.disabled,
|
|
74
|
-
multiple: props.multiple,
|
|
75
|
-
}),
|
|
76
|
-
);
|
|
10
|
+
const attrs = {};
|
|
77
11
|
|
|
78
12
|
const caretClasses = computed(() =>
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
13
|
+
cva(config.value.caret)({
|
|
14
|
+
...props,
|
|
15
|
+
error: Boolean(props.error),
|
|
82
16
|
label: Boolean(props.label),
|
|
83
17
|
}),
|
|
84
18
|
);
|
|
85
19
|
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
20
|
+
for (const key in defaultConfig) {
|
|
21
|
+
if (isSystemKey(key)) continue;
|
|
22
|
+
|
|
23
|
+
let classes = "";
|
|
24
|
+
let value = config.value[key];
|
|
25
|
+
|
|
26
|
+
if (value.variants || value.compoundVariants) {
|
|
27
|
+
const getCVA = cva(value);
|
|
28
|
+
|
|
29
|
+
classes = computed(() =>
|
|
30
|
+
getCVA({
|
|
31
|
+
...props,
|
|
32
|
+
error: Boolean(props.error),
|
|
33
|
+
label: Boolean(props.label),
|
|
34
|
+
}),
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
attrs[`${key}Attrs`] = getAttrs(key, { classes, isComponent: componentKeys.includes(key) });
|
|
39
|
+
|
|
40
|
+
if (key === "wrapper") {
|
|
41
|
+
const wrapperAttrs = attrs[`${key}Attrs`];
|
|
42
|
+
|
|
43
|
+
attrs[`${key}Attrs`] = computed(() => ({
|
|
44
|
+
...wrapperAttrs.value,
|
|
45
|
+
class: cx([wrapperAttrs.value.class, isOpen.value && config.value.wrapperActive]),
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (key === "label") {
|
|
50
|
+
const labelAttrs = attrs[`${key}Attrs`];
|
|
51
|
+
|
|
52
|
+
attrs[`${key}Attrs`] = computed(() => ({
|
|
53
|
+
...labelAttrs.value,
|
|
54
|
+
class: cx([
|
|
55
|
+
labelAttrs.value.class,
|
|
56
|
+
isOpen.value && config.value.labelWrapperActive,
|
|
57
|
+
isTop.value && config.value.labelWrapperTop,
|
|
58
|
+
]),
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (key === "caretToggle") {
|
|
63
|
+
const caretToggleAttrs = attrs[`${key}Attrs`];
|
|
64
|
+
|
|
65
|
+
attrs[`${key}Attrs`] = computed(() => ({
|
|
66
|
+
...caretToggleAttrs.value,
|
|
67
|
+
class: cx([caretToggleAttrs.value.class, caretClasses.value]),
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (key === "caretClear") {
|
|
72
|
+
const caretClearAttrs = attrs[`${key}Attrs`];
|
|
73
|
+
|
|
74
|
+
attrs[`${key}Attrs`] = computed(() => ({
|
|
75
|
+
...caretClearAttrs.value,
|
|
76
|
+
class: cx([caretClearAttrs.value.class, caretClasses.value]),
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (key === "beforeCaretSlot") {
|
|
81
|
+
const beforeCaretSlotAttrs = attrs[`${key}Attrs`];
|
|
82
|
+
|
|
83
|
+
attrs[`${key}Attrs`] = computed(() => ({
|
|
84
|
+
...beforeCaretSlotAttrs.value,
|
|
85
|
+
class: cx([beforeCaretSlotAttrs.value.class, caretClasses.value]),
|
|
86
|
+
}));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (key === "afterCaretSlot") {
|
|
90
|
+
const afterCaretSlotAttrs = attrs[`${key}Attrs`];
|
|
91
|
+
|
|
92
|
+
attrs[`${key}Attrs`] = computed(() => ({
|
|
93
|
+
...afterCaretSlotAttrs.value,
|
|
94
|
+
class: cx([afterCaretSlotAttrs.value.class, caretClasses.value]),
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (key === "search") {
|
|
99
|
+
const searchAttrs = attrs[`${key}Attrs`];
|
|
100
|
+
|
|
101
|
+
attrs[`${key}Attrs`] = computed(() => ({
|
|
102
|
+
...searchAttrs.value,
|
|
103
|
+
class: cx([
|
|
104
|
+
searchAttrs.value.class,
|
|
105
|
+
Boolean(selectedLabelValue.value) && !isOpen.value && "w-0", // this is not configurable
|
|
106
|
+
]),
|
|
107
|
+
}));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
160
110
|
|
|
161
111
|
return {
|
|
112
|
+
...attrs,
|
|
162
113
|
config,
|
|
163
114
|
hasSlotContent,
|
|
164
|
-
labelAttrs,
|
|
165
|
-
wrapperAttrs,
|
|
166
|
-
innerWrapperAttrs,
|
|
167
|
-
wrapperTopAttrs,
|
|
168
|
-
leftSlotAttrs,
|
|
169
|
-
beforeCaretSlotAttrs,
|
|
170
|
-
afterCaretSlotAttrs,
|
|
171
|
-
caretToggleAttrs,
|
|
172
|
-
caretClearAttrs,
|
|
173
|
-
caretClearTextAttrs,
|
|
174
|
-
caretRemoveItemAttrs,
|
|
175
|
-
searchAttrs,
|
|
176
|
-
searchInputAttrs,
|
|
177
|
-
selectedLabelsAttrs,
|
|
178
|
-
selectedLabelAttrs,
|
|
179
|
-
dropdownListAttrs,
|
|
180
|
-
toggleIconAttrs,
|
|
181
|
-
clearIconAttrs,
|
|
182
|
-
removeItemIconAttrs,
|
|
183
115
|
};
|
|
184
116
|
}
|
|
@@ -62,7 +62,9 @@ export default /*tw*/ {
|
|
|
62
62
|
removeItemIcon: "",
|
|
63
63
|
removeItemIconName: "close_small",
|
|
64
64
|
caretRemoveItem: "flex items-center",
|
|
65
|
+
caretClear: "",
|
|
65
66
|
caretClearText: {
|
|
67
|
+
// TODO: caretClearMultiple is better
|
|
66
68
|
base: "cursor-pointer flex items-center text-sm font-normal text-gray-400 hover:text-gray-500 transition",
|
|
67
69
|
compoundVariants: [
|
|
68
70
|
{ size: "sm", class: "text-sm" },
|