vueless 0.0.377 → 0.0.378

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "0.0.377",
3
+ "version": "0.0.378",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless Component Framework.",
6
6
  "homepage": "https://vueless.com",
@@ -1,375 +1,209 @@
1
- import useUI from "../composables/useUI.js";
2
- import { cva, cx } from "../utils/utilUI.js";
3
-
4
1
  import { computed } from "vue";
2
+ import useUI from "../composables/useUI.js";
5
3
 
6
4
  import defaultConfig from "./config.js";
7
5
 
8
6
  export default function useAttrs(props) {
9
- const { config, getAttrs, isSystemKey, hasSlotContent, isCVA } = useUI(
7
+ const { config, getKeysAttrs, hasSlotContent, getExtendingKeysClasses } = useUI(
10
8
  defaultConfig,
11
9
  () => props.config,
12
10
  );
13
- const attrs = {};
14
11
 
15
- const buttonVariantKeys = [
12
+ const extendingKeys = [
16
13
  "firstDateInRange",
17
14
  "lastDateInRange",
18
15
  "anotherMonthDate",
19
16
  "activeDate",
20
17
  "selectedDate",
21
18
  "currentDate",
22
- "currentDay",
23
- "currentDayInRange",
24
- "anotherMonthDay",
25
- "firstDayInRange",
26
- "anotherMonthFirstDayInRange",
27
- "lastDayInRange",
28
- "anotherMonthLastDayInRange",
29
- "selectedDay",
30
- "activeDay",
31
- "dayInRange",
32
19
  "edgeDateInRange",
33
20
  "dateInRange",
34
- "currentMonth",
35
- "currentMonthInRange",
36
- "lastMonthInRange",
37
- "firstMonthInRange",
38
- "singleMonthInRange",
39
- "monthInRange",
40
- "selectedMonth",
41
- "activeMonth",
42
- "currentYear",
43
- "currentYearInRange",
44
- "firstYearInRange",
45
- "lastYearInRange",
46
- "yearInRange",
47
- "singleYearInRange",
48
- "selectedYear",
49
- "activeYear",
50
- ];
51
-
52
- const timepickerInputKeys = [
53
- "timepickerInputHours",
54
- "timepickerInputMinutes",
55
- "timepickerInputSeconds",
21
+ "timepickerInput",
56
22
  ];
57
23
 
58
- for (const key in defaultConfig) {
59
- if (isSystemKey(key) || buttonVariantKeys.includes(key)) continue;
60
-
61
- const classes = computed(() => {
62
- let value = config.value[key];
63
-
64
- if (isCVA(value)) {
65
- value = cva(value)({
66
- ...props,
67
- });
68
- }
69
-
70
- return value;
71
- });
72
-
73
- attrs[`${key}Attrs`] = getAttrs(key, { classes });
74
-
75
- if (timepickerInputKeys.includes(key)) {
76
- const keyAttrs = attrs[`${key}Attrs`];
77
-
78
- attrs[`${key}Attrs`] = computed(() => ({
79
- ...keyAttrs.value,
80
- class: cx([config.value.timepickerInput, keyAttrs.value.class]),
81
- }));
82
- }
83
- }
84
-
85
- for (const key of buttonVariantKeys) {
86
- if (key === "dayInRange") {
87
- attrs[`${key}Attrs`] = computed(() => ({
88
- ...attrs.dayAttrs.value,
89
- class: cx([attrs.dayAttrs.value.class, config.value.dateInRange, config.value.dayInRange]),
90
- }));
91
- }
92
-
93
- if (key === "selectedDay") {
94
- attrs[`${key}Attrs`] = computed(() => ({
95
- ...attrs.dayAttrs.value,
96
- class: cx([
97
- attrs.dayAttrs.value.class,
98
- config.value.selectedDate,
99
- config.value.selectedDay,
100
- ]),
101
- }));
102
- }
103
-
104
- if (key === "activeDay") {
105
- attrs[`${key}Attrs`] = computed(() => ({
106
- ...attrs.dayAttrs.value,
107
- class: cx([attrs.dayAttrs.value.class, config.value.activeDate, config.value.activeDay]),
108
- }));
109
- }
110
-
111
- if (key === "anotherMonthDay") {
112
- attrs[`${key}Attrs`] = computed(() => ({
113
- ...attrs.dayAttrs.value,
114
- class: cx([
115
- attrs.dayAttrs.value.class,
116
- config.value.anotherMonthDate,
117
- config.value.anotherMonthDay,
118
- ]),
119
- }));
120
- }
121
-
122
- if (key === "currentDay") {
123
- attrs[`${key}Attrs`] = computed(() => ({
124
- ...attrs.dayAttrs.value,
125
- class: cx([attrs.dayAttrs.value.class, config.value.currentDate, config.value.currentDay]),
126
- }));
127
- }
128
-
129
- if (key === "currentDayInRange") {
130
- attrs[`${key}Attrs`] = computed(() => ({
131
- ...attrs.dayAttrs.value,
132
- class: cx([
133
- attrs.dayAttrs.value.class,
134
- config.value.dateInRange,
135
- config.value.currentDate,
136
- config.value.currentDayInRange,
137
- ]),
138
- }));
139
- }
140
-
141
- if (key === "firstDayInRange") {
142
- attrs[`${key}Attrs`] = computed(() => ({
143
- ...attrs.dayAttrs.value,
144
- class: cx([
145
- attrs.dayAttrs.value.class,
146
- config.value.edgeDateInRange,
147
- config.value.firstDateInRange,
148
- config.value.firstDayInRange,
149
- ]),
150
- }));
151
- }
152
-
153
- if (key === "lastDayInRange") {
154
- attrs[`${key}Attrs`] = computed(() => ({
155
- ...attrs.dayAttrs.value,
156
- class: cx([
157
- attrs.dayAttrs.value.class,
158
- config.value.edgeDateInRange,
159
- config.value.lastDateInRange,
160
- config.value.lastDayInRange,
161
- ]),
162
- }));
163
- }
164
-
165
- if (key === "anotherMonthLastDayInRange") {
166
- attrs[`${key}Attrs`] = computed(() => ({
167
- ...attrs.dayAttrs.value,
168
- class: cx([
169
- attrs.dayAttrs.value.class,
170
- config.value.anotherMonthDay,
171
- config.value.edgeDateInRange,
172
- config.value.lastDateInRange,
173
- config.value.anotherMonthLastDayInRange,
174
- ]),
175
- }));
176
- }
177
-
178
- if (key === "anotherMonthFirstDayInRange") {
179
- attrs[`${key}Attrs`] = computed(() => ({
180
- ...attrs.dayAttrs.value,
181
- class: cx([
182
- attrs.dayAttrs.value.class,
183
- config.value.anotherMonthDay,
184
- config.value.edgeDateInRange,
185
- config.value.firstDateInRange,
186
- config.value.anotherMonthFirstDayInRange,
187
- ]),
188
- }));
189
- }
190
-
191
- if (key === "currentMonth") {
192
- attrs[`${key}Attrs`] = computed(() => ({
193
- ...attrs.monthAttrs.value,
194
- class: cx([
195
- attrs.monthAttrs.value.class,
196
- config.value.currentDate,
197
- config.value.currentMonth,
198
- ]),
199
- }));
200
- }
201
-
202
- if (key === "monthInRange") {
203
- attrs[`${key}Attrs`] = computed(() => ({
204
- ...attrs.monthAttrs.value,
205
- class: cx([
206
- attrs.monthAttrs.value.class,
207
- config.value.dateInRange,
208
- config.value.monthInRange,
209
- ]),
210
- }));
211
- }
212
-
213
- if (key === "singleMonthInRange") {
214
- attrs[`${key}Attrs`] = computed(() => ({
215
- ...attrs.monthAttrs.value,
216
- class: cx([
217
- attrs.monthAttrs.value.class,
218
- config.value.dateInRange,
219
- config.value.singleMonthInRange,
220
- ]),
221
- }));
222
- }
223
-
224
- if (key === "currentMonthInRange") {
225
- attrs[`${key}Attrs`] = computed(() => ({
226
- ...attrs.monthAttrs.value,
227
- class: cx([
228
- attrs.monthAttrs.value.class,
229
- config.value.currentDate,
230
- config.value.dateInRange,
231
- config.value.currentMonthInRange,
232
- ]),
233
- }));
234
- }
235
-
236
- if (key === "lastMonthInRange") {
237
- attrs[`${key}Attrs`] = computed(() => ({
238
- ...attrs.monthAttrs.value,
239
- class: cx([
240
- attrs.monthAttrs.value.class,
241
- config.value.edgeDateInRange,
242
- config.value.lastDateInRange,
243
- config.value.lastMonthInRange,
244
- ]),
245
- }));
246
- }
247
-
248
- if (key === "firstMonthInRange") {
249
- attrs[`${key}Attrs`] = computed(() => ({
250
- ...attrs.monthAttrs.value,
251
- class: cx([
252
- attrs.monthAttrs.value.class,
253
- config.value.edgeDateInRange,
254
- config.value.firstDateInRange,
255
- config.value.firstMonthInRange,
256
- ]),
257
- }));
258
- }
259
-
260
- if (key === "selectedMonth") {
261
- attrs[`${key}Attrs`] = computed(() => ({
262
- ...attrs.monthAttrs.value,
263
- class: cx([
264
- attrs.monthAttrs.value.class,
265
- config.value.selectedDate,
266
- config.value.selectedMonth,
267
- ]),
268
- }));
269
- }
270
-
271
- if (key === "activeMonth") {
272
- attrs[`${key}Attrs`] = computed(() => ({
273
- ...attrs.monthAttrs.value,
274
- class: cx([
275
- attrs.monthAttrs.value.class,
276
- config.value.activeDate,
277
- config.value.activeMonth,
278
- ]),
279
- }));
280
- }
281
-
282
- if (key === "currentYear") {
283
- attrs[`${key}Attrs`] = computed(() => ({
284
- ...attrs.yearAttrs.value,
285
- class: cx([
286
- attrs.yearAttrs.value.class,
287
- config.value.currentDate,
288
- config.value.currentYear,
289
- ]),
290
- }));
291
- }
292
-
293
- if (key === "yearInRange") {
294
- attrs[`${key}Attrs`] = computed(() => ({
295
- ...attrs.yearAttrs.value,
296
- class: cx([
297
- attrs.yearAttrs.value.class,
298
- config.value.dateInRange,
299
- config.value.yearInRange,
300
- ]),
301
- }));
302
- }
303
-
304
- if (key === "singleYearInRange") {
305
- attrs[`${key}Attrs`] = computed(() => ({
306
- ...attrs.yearAttrs.value,
307
- class: cx([
308
- attrs.yearAttrs.value.class,
309
- config.value.dateInRange,
310
- config.value.singleYearInRange,
311
- ]),
312
- }));
313
- }
314
-
315
- if (key === "currentYearInRange") {
316
- attrs[`${key}Attrs`] = computed(() => ({
317
- ...attrs.yearAttrs.value,
318
- class: cx([
319
- attrs.yearAttrs.value.class,
320
- config.value.currentDate,
321
- config.value.dateInRange,
322
- config.value.currentYearInRange,
323
- ]),
324
- }));
325
- }
326
-
327
- if (key === "lastYearInRange") {
328
- attrs[`${key}Attrs`] = computed(() => ({
329
- ...attrs.yearAttrs.value,
330
- class: cx([
331
- attrs.yearAttrs.value.class,
332
- config.value.edgeDateInRange,
333
- config.value.lastDateInRange,
334
- config.value.lastYearInRange,
335
- ]),
336
- }));
337
- }
338
-
339
- if (key === "firstYearInRange") {
340
- attrs[`${key}Attrs`] = computed(() => ({
341
- ...attrs.yearAttrs.value,
342
- class: cx([
343
- attrs.yearAttrs.value.class,
344
- config.value.edgeDateInRange,
345
- config.value.firstDateInRange,
346
- config.value.firstYearInRange,
347
- ]),
348
- }));
349
- }
350
-
351
- if (key === "selectedYear") {
352
- attrs[`${key}Attrs`] = computed(() => ({
353
- ...attrs.yearAttrs.value,
354
- class: cx([
355
- attrs.yearAttrs.value.class,
356
- config.value.selectedDate,
357
- config.value.selectedYear,
358
- ]),
359
- }));
360
- }
361
-
362
- if (key === "activeYear") {
363
- attrs[`${key}Attrs`] = computed(() => ({
364
- ...attrs.yearAttrs.value,
365
- class: cx([attrs.yearAttrs.value.class, config.value.activeDate, config.value.activeYear]),
366
- }));
367
- }
368
- }
24
+ const extendingKeysClasses = getExtendingKeysClasses([...extendingKeys, "day", "month", "year"]);
25
+
26
+ const keysAttrs = getKeysAttrs({}, extendingKeys, {
27
+ timepickerInputHours: {
28
+ base: computed(() => [extendingKeysClasses.timepickerInput.value]),
29
+ },
30
+ timepickerInputMinutes: {
31
+ base: computed(() => [extendingKeysClasses.timepickerInput.value]),
32
+ },
33
+ timepickerInputSeconds: {
34
+ base: computed(() => [extendingKeysClasses.timepickerInput.value]),
35
+ },
36
+ dayInRange: {
37
+ base: computed(() => [
38
+ extendingKeysClasses.day.value,
39
+ extendingKeysClasses.dateInRange.value,
40
+ ]),
41
+ },
42
+ selectedDay: {
43
+ base: computed(() => [
44
+ extendingKeysClasses.day.value,
45
+ extendingKeysClasses.selectedDate.value,
46
+ ]),
47
+ },
48
+ activeDay: {
49
+ base: computed(() => [extendingKeysClasses.day.value, extendingKeysClasses.activeDate.value]),
50
+ },
51
+ anotherMonthDay: {
52
+ base: computed(() => [
53
+ extendingKeysClasses.day.value,
54
+ extendingKeysClasses.anotherMonthDate.value,
55
+ ]),
56
+ },
57
+ currentDay: {
58
+ base: computed(() => [
59
+ extendingKeysClasses.day.value,
60
+ extendingKeysClasses.currentDate.value,
61
+ ]),
62
+ },
63
+ currentDayInRange: {
64
+ base: computed(() => [
65
+ extendingKeysClasses.day.value,
66
+ extendingKeysClasses.dateInRange.value,
67
+ extendingKeysClasses.currentDate.value,
68
+ ]),
69
+ },
70
+ firstDayInRange: {
71
+ base: computed(() => [
72
+ extendingKeysClasses.day.value,
73
+ extendingKeysClasses.edgeDateInRange.value,
74
+ extendingKeysClasses.firstDateInRange.value,
75
+ ]),
76
+ },
77
+ lastDayInRange: {
78
+ base: computed(() => [
79
+ extendingKeysClasses.day.value,
80
+ extendingKeysClasses.edgeDateInRange.value,
81
+ extendingKeysClasses.lastDateInRange.value,
82
+ ]),
83
+ },
84
+ anotherMonthLastDayInRange: {
85
+ base: computed(() => [
86
+ extendingKeysClasses.day.value,
87
+ extendingKeysClasses.anotherMonthDay.value,
88
+ extendingKeysClasses.edgeDateInRange.value,
89
+ extendingKeysClasses.lastDateInRange.value,
90
+ ]),
91
+ },
92
+ anotherMonthFirstDayInRange: {
93
+ base: computed(() => [
94
+ extendingKeysClasses.day.value,
95
+ extendingKeysClasses.anotherMonthDay.value,
96
+ extendingKeysClasses.edgeDateInRange.value,
97
+ extendingKeysClasses.firstDateInRange.value,
98
+ ]),
99
+ },
100
+ currentMonth: {
101
+ base: computed(() => [
102
+ extendingKeysClasses.month.value,
103
+ extendingKeysClasses.currentDate.value,
104
+ ]),
105
+ },
106
+ monthInRange: {
107
+ base: computed(() => [
108
+ extendingKeysClasses.month.value,
109
+ extendingKeysClasses.dateInRange.value,
110
+ ]),
111
+ },
112
+ singleMonthInRange: {
113
+ base: computed(() => [
114
+ extendingKeysClasses.month.value,
115
+ extendingKeysClasses.dateInRange.value,
116
+ ]),
117
+ },
118
+ currentMonthInRange: {
119
+ base: computed(() => [
120
+ extendingKeysClasses.month.value,
121
+ extendingKeysClasses.currentDate.value,
122
+ extendingKeysClasses.dateInRange.value,
123
+ ]),
124
+ },
125
+ lastMonthInRange: {
126
+ base: computed(() => [
127
+ extendingKeysClasses.month.value,
128
+ extendingKeysClasses.edgeDateInRange.value,
129
+ extendingKeysClasses.lastDateInRange.value,
130
+ ]),
131
+ },
132
+ firstMonthInRange: {
133
+ base: computed(() => [
134
+ extendingKeysClasses.month.value,
135
+ extendingKeysClasses.edgeDateInRange.value,
136
+ extendingKeysClasses.firstDateInRange.value,
137
+ ]),
138
+ },
139
+ selectedMonth: {
140
+ base: computed(() => [
141
+ extendingKeysClasses.month.value,
142
+ extendingKeysClasses.selectedDate.value,
143
+ ]),
144
+ },
145
+ activeMonth: {
146
+ base: computed(() => [
147
+ extendingKeysClasses.month.value,
148
+ extendingKeysClasses.activeDate.value,
149
+ ]),
150
+ },
151
+ currentYear: {
152
+ base: computed(() => [
153
+ extendingKeysClasses.year.value,
154
+ extendingKeysClasses.currentDate.value,
155
+ ]),
156
+ },
157
+ yearInRange: {
158
+ base: computed(() => [
159
+ extendingKeysClasses.year.value,
160
+ extendingKeysClasses.dateInRange.value,
161
+ ]),
162
+ },
163
+ singleYearInRange: {
164
+ base: computed(() => [
165
+ extendingKeysClasses.year.value,
166
+ extendingKeysClasses.dateInRange.value,
167
+ ]),
168
+ },
169
+ currentYearInRange: {
170
+ base: computed(() => [
171
+ extendingKeysClasses.year.value,
172
+ extendingKeysClasses.currentDate.value,
173
+ extendingKeysClasses.dateInRange.value,
174
+ ]),
175
+ },
176
+ lastYearInRange: {
177
+ base: computed(() => [
178
+ extendingKeysClasses.year.value,
179
+ extendingKeysClasses.edgeDateInRange.value,
180
+ extendingKeysClasses.lastDateInRange.value,
181
+ ]),
182
+ },
183
+ firstYearInRange: {
184
+ base: computed(() => [
185
+ extendingKeysClasses.year.value,
186
+ extendingKeysClasses.edgeDateInRange.value,
187
+ extendingKeysClasses.firstDateInRange.value,
188
+ ]),
189
+ },
190
+ selectedYear: {
191
+ base: computed(() => [
192
+ extendingKeysClasses.year.value,
193
+ extendingKeysClasses.selectedDate.value,
194
+ ]),
195
+ },
196
+ activeYear: {
197
+ base: computed(() => [
198
+ extendingKeysClasses.year.value,
199
+ extendingKeysClasses.activeDate.value,
200
+ ]),
201
+ },
202
+ });
369
203
 
370
204
  return {
371
- ...attrs,
372
205
  config,
206
+ ...keysAttrs,
373
207
  hasSlotContent,
374
208
  };
375
209
  }
@@ -1,41 +1,23 @@
1
1
  import { computed } from "vue";
2
2
  import useUI from "../composables/useUI.js";
3
- import { cva } from "../utils/utilUI.js";
4
3
 
5
4
  import defaultConfig from "./config.js";
6
5
 
7
6
  export default function useAttrs(props, { checkboxColor, checkboxSize }) {
8
- const { config, getAttrs, getColor, setColor, isSystemKey, hasSlotContent, isCVA } = useUI(
9
- defaultConfig,
10
- () => props.config,
11
- );
12
- const attrs = {};
7
+ const { config, getKeysAttrs, hasSlotContent } = useUI(defaultConfig, () => props.config);
13
8
 
14
- for (const key in defaultConfig) {
15
- if (isSystemKey(key)) continue;
9
+ const mutatedProps = computed(() => ({
10
+ color: checkboxColor.value,
11
+ size: checkboxSize.value,
12
+ label: Boolean(props.label),
13
+ error: Boolean(props.error),
14
+ }));
16
15
 
17
- const classes = computed(() => {
18
- let value = config.value[key];
19
-
20
- if (isCVA(value)) {
21
- value = cva(value)({
22
- ...props,
23
- size: checkboxSize.value,
24
- label: Boolean(props.label),
25
- error: Boolean(props.error),
26
- color: getColor(checkboxColor.value),
27
- });
28
- }
29
-
30
- return setColor(value, checkboxColor.value);
31
- });
32
-
33
- attrs[`${key}Attrs`] = getAttrs(key, { classes });
34
- }
16
+ const keysAttrs = getKeysAttrs(mutatedProps);
35
17
 
36
18
  return {
37
- ...attrs,
38
19
  config,
20
+ ...keysAttrs,
39
21
  hasSlotContent,
40
22
  };
41
23
  }
@@ -1,36 +1,15 @@
1
1
  import useUI from "../composables/useUI.js";
2
- import { computed } from "vue";
3
- import { cva } from "../utils/utilUI.js";
2
+
4
3
  import defaultConfig from "./config.js";
5
4
 
6
5
  export default function useAttrs(props) {
7
- const { config, getAttrs, isSystemKey, hasSlotContent, isCVA } = useUI(
8
- defaultConfig,
9
- () => props.config,
10
- );
11
- const attrs = {};
12
-
13
- for (const key in defaultConfig) {
14
- if (isSystemKey(key)) continue;
15
-
16
- const classes = computed(() => {
17
- let value = config.value[key];
18
-
19
- if (isCVA(value)) {
20
- value = cva(value)({
21
- ...props,
22
- });
23
- }
24
-
25
- return value;
26
- });
6
+ const { config, getKeysAttrs, hasSlotContent } = useUI(defaultConfig, () => props.config);
27
7
 
28
- attrs[`${key}Attrs`] = getAttrs(key, { classes });
29
- }
8
+ const keysAttrs = getKeysAttrs();
30
9
 
31
10
  return {
32
- ...attrs,
33
11
  config,
12
+ ...keysAttrs,
34
13
  hasSlotContent,
35
14
  };
36
15
  }
@@ -1,38 +1,15 @@
1
- import { computed } from "vue";
2
1
  import useUI from "../composables/useUI.js";
3
- import { cva } from "../utils/utilUI.js";
4
2
 
5
3
  import defaultConfig from "./config.js";
6
4
 
7
5
  export default function useAttrs(props) {
8
- const { config, getAttrs, setColor, getColor, isSystemKey, hasSlotContent, isCVA } = useUI(
9
- defaultConfig,
10
- () => props.config,
11
- );
12
- const attrs = {};
6
+ const { config, getKeysAttrs, hasSlotContent } = useUI(defaultConfig, () => props.config);
13
7
 
14
- for (const key in defaultConfig) {
15
- if (isSystemKey(key)) continue;
16
-
17
- const classes = computed(() => {
18
- let value = config.value[key];
19
-
20
- if (isCVA(value)) {
21
- value = cva(value)({
22
- ...props,
23
- color: getColor(props.color),
24
- });
25
- }
26
-
27
- return setColor(value, props.color);
28
- });
29
-
30
- attrs[`${key}Attrs`] = getAttrs(key, { classes });
31
- }
8
+ const keysAttrs = getKeysAttrs();
32
9
 
33
10
  return {
34
- ...attrs,
35
11
  config,
12
+ ...keysAttrs,
36
13
  hasSlotContent,
37
14
  };
38
15
  }
@@ -1,104 +1,55 @@
1
1
  import { computed } from "vue";
2
2
  import useUI from "../composables/useUI.js";
3
- import { cva, cx } from "../utils/utilUI.js";
3
+
4
4
  import defaultConfig from "./config.js";
5
5
 
6
6
  export default function useAttrs(props, { isTop, isOpen, selectedLabel: selectedLabelValue }) {
7
- const { config, getAttrs, hasSlotContent, isSystemKey, isCVA } = useUI(
7
+ const { config, getKeysAttrs, hasSlotContent, getExtendingKeysClasses } = useUI(
8
8
  defaultConfig,
9
9
  () => props.config,
10
10
  );
11
- const attrs = {};
12
-
13
- const caretClasses = computed(() =>
14
- cva(config.value.caret)({
15
- ...props,
16
- error: Boolean(props.error),
17
- label: Boolean(props.label),
18
- }),
19
- );
20
-
21
- for (const key in defaultConfig) {
22
- if (isSystemKey(key)) continue;
23
-
24
- const classes = computed(() => {
25
- let value = config.value[key];
26
-
27
- if (isCVA(value)) {
28
- value = cva(value)({
29
- ...props,
30
- error: Boolean(props.error),
31
- label: Boolean(props.label),
32
- });
33
- }
34
-
35
- return value;
36
- });
37
-
38
- attrs[`${key}Attrs`] = getAttrs(key, { classes });
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 === "toggle") {
63
- const toggleAttrs = attrs[`${key}Attrs`];
64
-
65
- attrs[`${key}Attrs`] = computed(() => ({
66
- ...toggleAttrs.value,
67
- class: cx([toggleAttrs.value.class, caretClasses.value]),
68
- }));
69
- }
70
-
71
- if (
72
- key === "toggle" ||
73
- key === "clear" ||
74
- key === "beforeCaret" ||
75
- key === "afterCaret" ||
76
- key === "rightIconWrapper"
77
- ) {
78
- const keyAttrs = attrs[`${key}Attrs`];
79
-
80
- attrs[`${key}Attrs`] = computed(() => ({
81
- ...keyAttrs.value,
82
- class: cx([keyAttrs.value.class, caretClasses.value]),
83
- }));
84
- }
85
-
86
- if (key === "search") {
87
- const searchAttrs = attrs[`${key}Attrs`];
88
11
 
89
- attrs[`${key}Attrs`] = computed(() => ({
90
- ...searchAttrs.value,
91
- class: cx([
92
- searchAttrs.value.class,
93
- Boolean(selectedLabelValue.value) && !isOpen.value && "w-0", // this is not configurable
94
- ]),
95
- }));
96
- }
97
- }
12
+ const mutatedProps = computed(() => ({
13
+ error: Boolean(props.error),
14
+ label: Boolean(props.label),
15
+ }));
16
+
17
+ const extendingKeys = ["caret", "wrapperActive", "labelWrapperActive", "labelWrapperTop"];
18
+ const extendingKeysClasses = getExtendingKeysClasses(extendingKeys);
19
+
20
+ const keysAttrs = getKeysAttrs(mutatedProps, extendingKeys, {
21
+ wrapper: {
22
+ extend: computed(() => [isOpen.value && extendingKeysClasses.wrapperActive.value]),
23
+ },
24
+ label: {
25
+ extend: computed(() => [
26
+ isOpen.value && extendingKeysClasses.labelWrapperActive.value,
27
+ isTop.value && extendingKeysClasses.labelWrapperTop.value,
28
+ ]),
29
+ },
30
+ toggle: {
31
+ base: computed(() => [extendingKeysClasses.caret.value]),
32
+ },
33
+ clear: {
34
+ base: computed(() => [extendingKeysClasses.caret.value]),
35
+ },
36
+ beforeCaret: {
37
+ base: computed(() => [extendingKeysClasses.caret.value]),
38
+ },
39
+ afterCaret: {
40
+ base: computed(() => [extendingKeysClasses.caret.value]),
41
+ },
42
+ rightIconWrapper: {
43
+ base: computed(() => [extendingKeysClasses.caret.value]),
44
+ },
45
+ search: {
46
+ extend: computed(() => [Boolean(selectedLabelValue.value) && !isOpen.value && "w-0"]),
47
+ },
48
+ });
98
49
 
99
50
  return {
100
- ...attrs,
101
51
  config,
52
+ ...keysAttrs,
102
53
  hasSlotContent,
103
54
  };
104
55
  }
@@ -1,39 +1,20 @@
1
+ import { computed } from "vue";
1
2
  import useUI from "../composables/useUI.js";
2
- import { cva } from "../utils/utilUI.js";
3
3
 
4
4
  import defaultConfig from "./config.js";
5
- import { computed } from "vue";
6
5
 
7
6
  export default function useAttrs(props, { checked }) {
8
- const { config, getAttrs, getColor, setColor, isSystemKey, hasSlotContent, isCVA } = useUI(
9
- defaultConfig,
10
- () => props.config,
11
- );
12
- const attrs = {};
13
-
14
- for (const key in defaultConfig) {
15
- if (isSystemKey(key)) continue;
16
-
17
- const classes = computed(() => {
18
- let value = config.value[key];
19
-
20
- if (isCVA(value)) {
21
- value = cva(value)({
22
- ...props,
23
- color: getColor(props.color),
24
- checked: Boolean(checked.value),
25
- });
26
- }
7
+ const { config, getKeysAttrs, hasSlotContent } = useUI(defaultConfig, () => props.config);
27
8
 
28
- return setColor(value, props.color);
29
- });
9
+ const mutatedProps = computed(() => ({
10
+ checked: Boolean(checked.value),
11
+ }));
30
12
 
31
- attrs[`${key}Attrs`] = getAttrs(key, { classes });
32
- }
13
+ const keysAttrs = getKeysAttrs(mutatedProps);
33
14
 
34
15
  return {
35
- ...attrs,
36
16
  config,
17
+ ...keysAttrs,
37
18
  hasSlotContent,
38
19
  };
39
20
  }
@@ -1,39 +1,21 @@
1
+ import { computed } from "vue";
1
2
  import useUI from "../composables/useUI.js";
2
- import { cva } from "../utils/utilUI.js";
3
3
 
4
4
  import defaultConfig from "./config.js";
5
- import { computed } from "vue";
6
5
 
7
6
  export default function useAttrs(props) {
8
- const { config, getAttrs, hasSlotContent, isSystemKey, isCVA } = useUI(
9
- defaultConfig,
10
- () => props.config,
11
- );
12
- const attrs = {};
13
-
14
- for (const key in defaultConfig) {
15
- if (isSystemKey(key)) continue;
16
-
17
- const classes = computed(() => {
18
- let value = config.value[key];
19
-
20
- if (isCVA(value)) {
21
- value = cva(value)({
22
- ...props,
23
- error: Boolean(props.error),
24
- label: Boolean(props.label),
25
- });
26
- }
7
+ const { config, getKeysAttrs, hasSlotContent } = useUI(defaultConfig, () => props.config);
27
8
 
28
- return value;
29
- });
9
+ const mutatedProps = computed(() => ({
10
+ error: Boolean(props.error),
11
+ label: Boolean(props.label),
12
+ }));
30
13
 
31
- attrs[`${key}Attrs`] = getAttrs(key, { classes });
32
- }
14
+ const keysAttrs = getKeysAttrs(mutatedProps);
33
15
 
34
16
  return {
35
- ...attrs,
36
17
  config,
18
+ ...keysAttrs,
37
19
  hasSlotContent,
38
20
  };
39
21
  }
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "framework": "vue",
3
3
  "name": "vueless",
4
- "version": "0.0.377",
4
+ "version": "0.0.378",
5
5
  "contributions": {
6
6
  "html": {
7
7
  "description-markup": "markdown",