vueless 0.0.188 → 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "0.0.188",
3
+ "version": "0.0.190",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless Component Framework.",
6
6
  "homepage": "https://vueless.com",
@@ -212,6 +212,23 @@ export default class UIService {
212
212
  setColor(classes, color) {
213
213
  return classes?.replaceAll("{color}", color);
214
214
  }
215
+
216
+ /**
217
+ Check is config key not contains classes or CVA config object.
218
+ @param { String } key
219
+ @returns { Boolean }
220
+ */
221
+ isSystemKey(key) {
222
+ return (
223
+ key === "i18n" ||
224
+ key === "strategy" ||
225
+ key === "safelist" ||
226
+ key === "safelistColors" ||
227
+ key === "defaultVariants" ||
228
+ key.includes("iconName") ||
229
+ key.includes("IconName")
230
+ );
231
+ }
215
232
  }
216
233
 
217
234
  export const {
@@ -222,6 +239,7 @@ export const {
222
239
  setFavicon,
223
240
  setBrandColor,
224
241
  convertHexInRgb,
242
+ isSystemKey,
225
243
  isMac,
226
244
  isPWA,
227
245
  isIOS,
@@ -1,60 +1,37 @@
1
1
  import { computed } from "vue";
2
2
  import useUI from "../../composable.ui";
3
- import { cva } from "../../service.ui";
4
-
3
+ import { cva, isSystemKey } from "../../service.ui";
5
4
  import defaultConfig from "../configs/default.config";
6
5
 
6
+ const componentKeys = ["icon", "divider"];
7
+
7
8
  export function useAttrs(props, { isOpened }) {
8
- const { config, getAttrs } = useUI(defaultConfig, () => props.config);
9
- const { wrapper, title, description } = config.value;
10
-
11
- const cvaWrapper = cva({
12
- base: wrapper.base,
13
- variants: wrapper.variants,
14
- compoundVariants: wrapper.compoundVariants,
15
- });
16
-
17
- const cvaTitle = cva({
18
- base: title.base,
19
- variants: title.variants,
20
- compoundVariants: title.compoundVariants,
21
- });
22
-
23
- const cvaDescription = cva({
24
- base: description.base,
25
- variants: description.variants,
26
- compoundVariants: description.compoundVariants,
27
- });
28
-
29
- const wrapperClasses = computed(() => cvaWrapper({ size: props.size }));
30
-
31
- const titleClasses = computed(() =>
32
- cvaTitle({
33
- size: props.size,
34
- }),
35
- );
36
-
37
- const descriptionClasses = computed(() =>
38
- cvaDescription({
39
- size: props.size,
40
- isOpened: isOpened.value,
41
- }),
42
- );
43
-
44
- const wrapperAttrs = getAttrs("wrapper", { classes: wrapperClasses });
45
- const bodyAttrs = getAttrs("body");
46
- const titleAttrs = getAttrs("title", { classes: titleClasses });
47
- const descriptionAttrs = getAttrs("description", { classes: descriptionClasses });
48
- const iconAttrs = getAttrs("icon", { isComponent: true });
49
- const dividerAttrs = getAttrs("divider", { isComponent: true });
9
+ const { config, getAttrs, hasSlotContent } = useUI(defaultConfig, () => props.config);
10
+ const attrs = {};
11
+
12
+ for (const key in defaultConfig) {
13
+ if (isSystemKey(key)) continue;
14
+
15
+ let classes = "";
16
+ let value = config.value[key];
17
+
18
+ if (value.variants || value.compoundVariants) {
19
+ const getCVA = cva(value);
20
+
21
+ classes = computed(() =>
22
+ getCVA({
23
+ ...props,
24
+ isOpened: isOpened.value,
25
+ }),
26
+ );
27
+ }
28
+
29
+ attrs[`${key}Attrs`] = getAttrs(key, { classes, isComponent: componentKeys.includes(key) });
30
+ }
50
31
 
51
32
  return {
33
+ ...attrs,
52
34
  config,
53
- wrapperAttrs,
54
- descriptionAttrs,
55
- bodyAttrs,
56
- titleAttrs,
57
- iconAttrs,
58
- dividerAttrs,
35
+ hasSlotContent,
59
36
  };
60
37
  }
@@ -21,11 +21,11 @@ const DefaultTemplate = (args) => ({
21
21
  },
22
22
  template: `
23
23
  <UAccordion
24
- v-bind="args"
25
24
  name="Excellence"
26
25
  title="Excellence by necessity"
27
26
  description="As creators and maintainers of the technologies you are using,
28
27
  our services are here to showcase the full power of our softwares."
28
+ v-bind="args"
29
29
  />
30
30
  <UAccordion
31
31
  v-bind="args"
@@ -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
- import { computed } from "vue";
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 { wrapper, innerWrapper, searchInput, selectedLabel, caret, caretClearText } = config.value;
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
- cvaCaret({
80
- size: props.size,
81
- labelAlign: props.labelAlign,
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 caretClearTextClasses = computed(() =>
87
- cvaCaretClearText({
88
- size: props.size,
89
- }),
90
- );
91
-
92
- const innerWrapperAttrs = getAttrs("innerWrapper", { classes: innerWrapperClasses });
93
- const wrapperTopAttrs = getAttrs("wrapperTop");
94
- const leftSlotAttrs = getAttrs("leftSlot");
95
- const searchInputAttrs = getAttrs("searchInput", { classes: searchInputClasses });
96
- const selectedLabelsAttrs = getAttrs("selectedLabels");
97
- const selectedLabelAttrs = getAttrs("selectedLabel", { classes: selectedLabelClasses });
98
- const dropdownListAttrs = getAttrs("dropdownList", { isComponent: true });
99
- const caretClearTextAttrs = getAttrs("caretClearText", { classes: caretClearTextClasses });
100
- const caretRemoveItemAttrs = getAttrs("caretRemoveItem");
101
- const toggleIconAttrs = getAttrs("toggleIcon", { isComponent: true });
102
- const clearIconAttrs = getAttrs("clearIcon", { isComponent: true });
103
- const removeItemIconAttrs = getAttrs("removeItemIcon", { isComponent: true });
104
-
105
- const wrapperAttrsRaw = getAttrs("wrapper", { classes: wrapperClasses });
106
-
107
- const wrapperAttrs = computed(() => ({
108
- ...wrapperAttrsRaw.value,
109
- class: cx([wrapperAttrsRaw.value.class, isOpen.value && config.value.wrapperActive]),
110
- }));
111
-
112
- const labelAttrsRaw = getAttrs("label", { isComponent: true });
113
-
114
- const labelAttrs = computed(() => ({
115
- ...labelAttrsRaw.value,
116
- class: cx([
117
- labelAttrsRaw.value.class,
118
- isOpen.value && config.value.labelWrapperActive,
119
- isTop.value && config.value.labelWrapperTop,
120
- ]),
121
- }));
122
-
123
- const caretToggleAttrsRaw = getAttrs("caretToggle");
124
-
125
- const caretToggleAttrs = computed(() => ({
126
- ...caretToggleAttrsRaw.value,
127
- class: cx([caretToggleAttrsRaw.value.class, caretClasses.value]),
128
- }));
129
-
130
- const caretClearAttrsRaw = getAttrs("caretClear");
131
-
132
- const caretClearAttrs = computed(() => ({
133
- ...caretClearAttrsRaw.value,
134
- class: cx([caretClearAttrsRaw.value.class, caretClasses.value]),
135
- }));
136
-
137
- const beforeCaretSlotAttrsRaw = getAttrs("beforeCaretSlot");
138
-
139
- const beforeCaretSlotAttrs = computed(() => ({
140
- ...beforeCaretSlotAttrsRaw.value,
141
- class: cx([beforeCaretSlotAttrsRaw.value.class, caretClasses.value]),
142
- }));
143
-
144
- const afterCaretSlotAttrsRaw = getAttrs("afterCaretSlot");
145
-
146
- const afterCaretSlotAttrs = computed(() => ({
147
- ...afterCaretSlotAttrsRaw.value,
148
- class: cx([afterCaretSlotAttrsRaw.value.class, caretClasses.value]),
149
- }));
150
-
151
- const searchAttrsRaw = getAttrs("search");
152
-
153
- const searchAttrs = computed(() => ({
154
- ...searchAttrsRaw.value,
155
- class: cx([
156
- searchAttrsRaw.value.class,
157
- Boolean(selectedLabelValue.value) && !isOpen.value && "w-0", // this is not configurable
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" },
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "framework": "vue",
3
3
  "name": "vueless",
4
- "version": "0.0.188",
4
+ "version": "0.0.190",
5
5
  "contributions": {
6
6
  "html": {
7
7
  "description-markup": "markdown",