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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "0.0.189",
3
+ "version": "0.0.190",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless Component Framework.",
6
6
  "homepage": "https://vueless.com",
@@ -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
- 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.189",
4
+ "version": "0.0.190",
5
5
  "contributions": {
6
6
  "html": {
7
7
  "description-markup": "markdown",