vueless 0.0.163 → 0.0.164

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.
@@ -8,7 +8,7 @@ import {
8
8
  Text,
9
9
  Fragment,
10
10
  } from "vue";
11
- import { cx, globalComponentConfig, strategy } from "../service.ui";
11
+ import { cx, globalComponentConfig, strategy, getColor, setColor } from "../service.ui";
12
12
  import { cloneDeep } from "../service.helper";
13
13
 
14
14
  const strategyType = {
@@ -94,6 +94,7 @@ export default function useUI(defaultConfig = {}, propsConfigGetter = null, topL
94
94
  return {
95
95
  config,
96
96
  getAttrs,
97
+ getColor,
97
98
  setColor,
98
99
  hasSlotContent,
99
100
  };
@@ -350,7 +351,3 @@ function hasSlotContent(slot, props = {}) {
350
351
 
351
352
  return !isVNodeEmpty(slot?.(props));
352
353
  }
353
-
354
- function setColor(classes, color) {
355
- return classes?.replaceAll("{color}", color);
356
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "0.0.163",
3
+ "version": "0.0.164",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless Component Framework.",
6
6
  "homepage": "https://vueless.com",
@@ -37,7 +37,7 @@
37
37
  "@release-it/bumper": "^6.0.1",
38
38
  "@vitejs/plugin-vue": "^5.0.5",
39
39
  "@vue/eslint-config-prettier": "^9.0.0",
40
- "@vueless/plugin-vite": "^0.0.29",
40
+ "@vueless/plugin-vite": "^0.0.30",
41
41
  "@vueless/storybook": "^0.0.31",
42
42
  "@vueless/web-types": "^0.0.11",
43
43
  "autoprefixer": "^10.4.19",
@@ -43,7 +43,7 @@ export const cva = ({ base = "", variants = {}, compoundVariants = [], defaultVa
43
43
  */
44
44
  export const { layout, strategy, gray, brand, component: globalComponentConfig } = vuelessConfig;
45
45
 
46
- export default class UIServiceDefault {
46
+ export default class UIService {
47
47
  isMac = false;
48
48
  isPWA = false;
49
49
  isIOS = false;
@@ -137,7 +137,7 @@ export default class UIServiceDefault {
137
137
  const globalBrandColor = getBrandColor(brand, grayColor, BRAND_COLORS);
138
138
 
139
139
  const style = document.createElement("style");
140
- const rgb = UIServiceDefault.convertHexInRgb(localBrandColor || globalBrandColor || grayColor);
140
+ const rgb = UIService.convertHexInRgb(localBrandColor || globalBrandColor || grayColor);
141
141
 
142
142
  style.innerHTML = `
143
143
  :root {
@@ -187,22 +187,41 @@ export default class UIServiceDefault {
187
187
  globalComponentConfig[name]?.defaultVariants,
188
188
  );
189
189
 
190
- if (brand === GRAYSCALE_COLOR && defaultVariants.color === BRAND_COLOR) {
191
- defaultVariants.color = GRAYSCALE_COLOR;
192
- }
190
+ defaultVariants.color = getColor(defaultVariants.color);
193
191
 
194
192
  return {
195
193
  default: defaultVariants,
196
194
  };
197
195
  }
196
+
197
+ /**
198
+ Get color for props.
199
+ @param { String } color
200
+ @returns { String }
201
+ */
202
+ getColor(color) {
203
+ return brand === GRAYSCALE_COLOR && color === BRAND_COLOR ? GRAYSCALE_COLOR : color;
204
+ }
205
+
206
+ /**
207
+ Find and replace all {color} variables in class names into given color.
208
+ @param { String } classes
209
+ @param { String } color
210
+ @returns { String }
211
+ */
212
+ setColor(classes, color) {
213
+ return classes?.replaceAll("{color}", color);
214
+ }
198
215
  }
199
216
 
200
217
  export const {
201
218
  getRandomId,
202
- setBrandColor,
203
- convertHexInRgb,
219
+ getColor,
220
+ setColor,
204
221
  setTitle,
205
222
  setFavicon,
223
+ setBrandColor,
224
+ convertHexInRgb,
206
225
  isMac,
207
226
  isPWA,
208
227
  isIOS,
@@ -210,4 +229,4 @@ export const {
210
229
  isMobileApp,
211
230
  PX_IN_REM,
212
231
  HYPHEN_SYMBOL,
213
- } = new UIServiceDefault();
232
+ } = new UIService();
@@ -5,7 +5,7 @@ import { cva } from "../../service.ui";
5
5
  import defaultConfig from "../configs/default.config";
6
6
 
7
7
  export function useAttrs(props) {
8
- const { config, getAttrs, setColor } = useUI(defaultConfig, () => props.config);
8
+ const { config, getAttrs, getColor, setColor } = useUI(defaultConfig, () => props.config);
9
9
  const { button, text } = config.value;
10
10
 
11
11
  const cvaButton = cva({
@@ -24,7 +24,7 @@ export function useAttrs(props) {
24
24
  setColor(
25
25
  cvaButton({
26
26
  size: props.size,
27
- color: props.color,
27
+ color: getColor(props.color),
28
28
  variant: props.variant,
29
29
  pill: props.pill,
30
30
  block: props.block,
@@ -40,7 +40,7 @@ export function useAttrs(props) {
40
40
  const textClasses = computed(() =>
41
41
  setColor(
42
42
  cvaText({
43
- color: props.color,
43
+ color: getColor(props.color),
44
44
  }),
45
45
  props.color,
46
46
  ),
@@ -160,7 +160,6 @@ export default /*tw*/ {
160
160
  { pattern: `text-(${colors})-700`, variants: ["hover", "focus"] },
161
161
  { pattern: `text-(${colors})-800`, variants: ["active"] },
162
162
  { pattern: `text-(${colors})-300`, variants: ["disabled"] },
163
- { pattern: `ring-(${colors})-700`, variants: ["focus"] },
164
- { pattern: `ring-(${colors})-800`, variants: ["active"] },
163
+ { pattern: `ring-(${colors})-700`, variants: ["focus", "focus-within"] },
165
164
  ],
166
165
  };
@@ -8,7 +8,10 @@ import defaultConfig from "../configs/default.config";
8
8
  export function useAttrs(props, { isActive, isExactActive }) {
9
9
  const slots = useSlots();
10
10
 
11
- const { config, getAttrs, hasSlotContent, setColor } = useUI(defaultConfig, () => props.config);
11
+ const { config, getAttrs, hasSlotContent, getColor, setColor } = useUI(
12
+ defaultConfig,
13
+ () => props.config,
14
+ );
12
15
  const { wrapper, link, text, rightSlot, leftSlot } = config.value;
13
16
 
14
17
  const cvaWrapper = cva({
@@ -45,7 +48,7 @@ export function useAttrs(props, { isActive, isExactActive }) {
45
48
  setColor(
46
49
  cvaWrapper({
47
50
  size: props.size,
48
- color: props.color,
51
+ color: getColor(props.color),
49
52
  block: props.block,
50
53
  noRing: props.noRing,
51
54
  disabled: props.disabled,
@@ -58,7 +61,7 @@ export function useAttrs(props, { isActive, isExactActive }) {
58
61
  setColor(
59
62
  cvaLink({
60
63
  size: props.size,
61
- color: props.color,
64
+ color: getColor(props.color),
62
65
  dashed: props.dashed,
63
66
  underlined: props.underlined,
64
67
  }),
@@ -4,8 +4,11 @@ import { cva } from "../../service.ui/index.js";
4
4
  import { computed } from "vue";
5
5
 
6
6
  export function useAttrs(props) {
7
- const { config, getAttrs, hasSlotContent, setColor } = useUI(defaultConfig, () => props.config);
8
- const { modal, footerLeftFallback, confirmButton, cancelButton } = config.value;
7
+ const { config, getAttrs, hasSlotContent, getColor, setColor } = useUI(
8
+ defaultConfig,
9
+ () => props.config,
10
+ );
11
+ const { modal, footerLeftFallback } = config.value;
9
12
 
10
13
  const cvaModal = cva({
11
14
  base: modal.base,
@@ -19,40 +22,26 @@ export function useAttrs(props) {
19
22
  compoundVariants: footerLeftFallback.compoundVariants,
20
23
  });
21
24
 
22
- const cvaConfirmButton = cva({
23
- base: confirmButton.base,
24
- variants: confirmButton.variants,
25
- compoundVariants: confirmButton.compoundVariants,
26
- });
27
-
28
- const cvaCancelButton = cva({
29
- base: cancelButton.base,
30
- variants: cancelButton.variants,
31
- compoundVariants: cancelButton.compoundVariants,
32
- });
33
-
34
- const modalClasses = computed(() => setColor(cvaModal({ color: props.color }), props.color));
25
+ const modalClasses = computed(() =>
26
+ setColor(
27
+ cvaModal({
28
+ color: getColor(props.color),
29
+ }),
30
+ props.color,
31
+ ),
32
+ );
35
33
 
36
34
  const footerLeftFallbackClasses = computed(() =>
37
- setColor(cvaFooterLeftFallback({ color: props.color }), props.color),
35
+ setColor(cvaFooterLeftFallback({ color: getColor(props.color) }), props.color),
38
36
  );
39
37
 
40
- const confirmButtonClasses = computed(() => cvaConfirmButton({ color: props.color }));
41
-
42
- const cancelButtonClasses = computed(() => cvaCancelButton({ color: props.color }));
43
-
44
- const modalAttrsRaw = getAttrs("modal", { isComponent: true, classes: modalClasses });
45
38
  const footerLeftFallbackAttrs = getAttrs("footerLeftFallback", {
46
39
  classes: footerLeftFallbackClasses,
47
40
  });
48
- const confirmButtonAttrs = getAttrs("confirmButton", {
49
- isComponent: true,
50
- classes: confirmButtonClasses,
51
- });
52
- const cancelButtonAttrs = getAttrs("cancelButton", {
53
- isComponent: true,
54
- classes: cancelButtonClasses,
55
- });
41
+
42
+ const confirmButtonAttrs = getAttrs("confirmButton", { isComponent: true });
43
+ const cancelButtonAttrs = getAttrs("cancelButton", { isComponent: true });
44
+ const modalAttrsRaw = getAttrs("modal", { isComponent: true, classes: modalClasses });
56
45
 
57
46
  const modalAttrs = computed(() => ({
58
47
  ...modalAttrsRaw.value,
@@ -5,7 +5,7 @@ import { cva } from "../../service.ui";
5
5
  import defaultConfig from "../configs/default.config";
6
6
 
7
7
  export function useAttrs(props) {
8
- const { config, getAttrs, setColor } = useUI(defaultConfig, () => props.config);
8
+ const { config, getAttrs, getColor, setColor } = useUI(defaultConfig, () => props.config);
9
9
  const { checkbox, iconWrapper } = config.value;
10
10
 
11
11
  const cvaCheckbox = cva({
@@ -25,7 +25,7 @@ export function useAttrs(props) {
25
25
  cvaCheckbox({
26
26
  size: props.size,
27
27
  label: Boolean(props.label),
28
- color: props.color,
28
+ color: getColor(props.color),
29
29
  disabled: props.color,
30
30
  }),
31
31
  props.color,
@@ -36,7 +36,7 @@ export function useAttrs(props) {
36
36
  setColor(
37
37
  cvaIconWrapper({
38
38
  size: props.size,
39
- color: props.color,
39
+ color: getColor(props.color),
40
40
  }),
41
41
  props.color,
42
42
  ),
@@ -5,7 +5,7 @@ import { cva } from "../../service.ui";
5
5
  import defaultConfig from "../configs/default.config";
6
6
 
7
7
  export function useAttrs(props, { radioColor, radioSize }) {
8
- const { config, getAttrs, setColor } = useUI(defaultConfig, () => props.config);
8
+ const { config, getAttrs, getColor, setColor } = useUI(defaultConfig, () => props.config);
9
9
  const { radio } = config.value;
10
10
 
11
11
  const cvaRadio = cva({
@@ -17,7 +17,7 @@ export function useAttrs(props, { radioColor, radioSize }) {
17
17
  const radioClasses = computed(() =>
18
18
  setColor(
19
19
  cvaRadio({
20
- color: radioColor.value,
20
+ color: getColor(radioColor.value),
21
21
  size: radioSize.value,
22
22
  }),
23
23
  radioColor.value,
@@ -5,7 +5,7 @@ import defaultConfig from "../configs/default.config";
5
5
  import { computed } from "vue";
6
6
 
7
7
  export function useAttrs(props, { checked }) {
8
- const { config, getAttrs, setColor } = useUI(defaultConfig, () => props.config);
8
+ const { config, getAttrs, getColor, setColor } = useUI(defaultConfig, () => props.config);
9
9
  const { wrapper, circle, toggleLabel } = config.value;
10
10
 
11
11
  const cvaWrapper = cva({
@@ -30,7 +30,7 @@ export function useAttrs(props, { checked }) {
30
30
  setColor(
31
31
  cvaWrapper({
32
32
  size: props.size,
33
- color: props.color,
33
+ color: getColor(props.color),
34
34
  disabled: props.disabled,
35
35
  checked: Boolean(checked.value),
36
36
  toggleLabel: props.toggleLabel,
@@ -50,7 +50,7 @@ export function useAttrs(props, { checked }) {
50
50
  setColor(
51
51
  cvaToggleLabel({
52
52
  size: props.size,
53
- color: props.color,
53
+ color: getColor(props.color),
54
54
  toggleLabel: props.toggleLabel,
55
55
  checked: Boolean(checked.value),
56
56
  }),
@@ -5,7 +5,7 @@ import defaultConfig from "../configs/default.config";
5
5
  import { computed } from "vue";
6
6
 
7
7
  export function useAttrs(props) {
8
- const { config, getAttrs, setColor } = useUI(defaultConfig, () => props.config);
8
+ const { config, getAttrs, getColor, setColor } = useUI(defaultConfig, () => props.config);
9
9
  const { avatar } = config.value;
10
10
 
11
11
  const cvaAvatar = cva({
@@ -18,7 +18,7 @@ export function useAttrs(props) {
18
18
  setColor(
19
19
  cvaAvatar({
20
20
  size: props.size,
21
- color: props.color,
21
+ color: getColor(props.color),
22
22
  rounded: props.rounded,
23
23
  bordered: props.bordered,
24
24
  }),
@@ -5,7 +5,7 @@ import defaultConfig from "../configs/default.config";
5
5
  import { computed } from "vue";
6
6
 
7
7
  export function useAttrs(props) {
8
- const { config, getAttrs, setColor } = useUI(defaultConfig, () => props.config);
8
+ const { config, getAttrs, getColor, setColor } = useUI(defaultConfig, () => props.config);
9
9
  const { wrapper, container, icon } = config.value;
10
10
 
11
11
  const cvaWrapper = cva({
@@ -31,7 +31,7 @@ export function useAttrs(props) {
31
31
  cvaWrapper({
32
32
  pill: props.pill,
33
33
  size: props.size,
34
- color: props.color,
34
+ color: getColor(props.color),
35
35
  }),
36
36
  props.color,
37
37
  ),
@@ -42,7 +42,7 @@ export function useAttrs(props) {
42
42
  cvaContainer({
43
43
  pill: props.pill,
44
44
  size: props.size,
45
- color: props.color,
45
+ color: getColor(props.color),
46
46
  variant: props.variant,
47
47
  interactive: props.interactive,
48
48
  }),
@@ -5,7 +5,7 @@ import defaultConfig from "../configs/default.config";
5
5
  import { computed } from "vue";
6
6
 
7
7
  export function useAttrs(props) {
8
- const { config, getAttrs, setColor } = useUI(defaultConfig, () => props.config);
8
+ const { config, getAttrs, getColor, setColor } = useUI(defaultConfig, () => props.config);
9
9
  const { loader, ellipse } = config.value;
10
10
 
11
11
  const cvaLoader = cva({
@@ -30,7 +30,7 @@ export function useAttrs(props) {
30
30
  setColor(
31
31
  cvaEllipse({
32
32
  size: props.size,
33
- color: props.color,
33
+ color: getColor(props.color),
34
34
  }),
35
35
  props.color,
36
36
  ),
@@ -5,7 +5,7 @@ import { cva } from "../../service.ui";
5
5
  import defaultConfig from "../configs/default.config";
6
6
 
7
7
  export function useAttrs(props) {
8
- const { getAttrs, setColor, config } = useUI(defaultConfig, () => props.config);
8
+ const { config, getAttrs, getColor, setColor } = useUI(defaultConfig, () => props.config);
9
9
  const { wrapper } = config.value;
10
10
 
11
11
  const cvaWrapper = cva({
@@ -17,7 +17,7 @@ export function useAttrs(props) {
17
17
  const wrapperClasses = computed(() =>
18
18
  setColor(
19
19
  cvaWrapper({
20
- color: props.color,
20
+ color: getColor(props.color),
21
21
  }),
22
22
  props.color,
23
23
  ),
@@ -5,7 +5,7 @@ import defaultConfig from "../configs/default.config";
5
5
  import { computed } from "vue";
6
6
 
7
7
  export function useAttrs(props) {
8
- const { config, getAttrs, setColor } = useUI(defaultConfig, () => props.config);
8
+ const { config, getAttrs, getColor, setColor } = useUI(defaultConfig, () => props.config);
9
9
  const { progress } = config.value;
10
10
 
11
11
  const cvaProgress = cva({
@@ -15,7 +15,12 @@ export function useAttrs(props) {
15
15
  });
16
16
 
17
17
  const progressClasses = computed(() =>
18
- setColor(cvaProgress({ color: props.color }), props.color),
18
+ setColor(
19
+ cvaProgress({
20
+ color: getColor(props.color),
21
+ }),
22
+ props.color,
23
+ ),
19
24
  );
20
25
 
21
26
  const progressAttrs = getAttrs("progress", { classes: progressClasses.value });
@@ -5,7 +5,7 @@ import defaultConfig from "../configs/default.config";
5
5
  import { computed } from "vue";
6
6
 
7
7
  export function useAttrs(props) {
8
- const { config, getAttrs, setColor } = useUI(defaultConfig, () => props.config);
8
+ const { config, getAttrs, getColor, setColor } = useUI(defaultConfig, () => props.config);
9
9
  const { progress } = config.value;
10
10
 
11
11
  const cvaProgress = cva({
@@ -18,7 +18,7 @@ export function useAttrs(props) {
18
18
  setColor(
19
19
  cvaProgress({
20
20
  size: props.size,
21
- color: props.color,
21
+ color: getColor(props.color),
22
22
  }),
23
23
  props.color,
24
24
  ),
@@ -5,7 +5,7 @@ import defaultConfig from "../configs/default.config";
5
5
  import { computed } from "vue";
6
6
 
7
7
  export function useAttrs(props) {
8
- const { config, getAttrs, setColor } = useUI(defaultConfig, () => props.config);
8
+ const { config, getAttrs, getColor, setColor } = useUI(defaultConfig, () => props.config);
9
9
  const { wrapper } = config.value;
10
10
 
11
11
  const cvaWrapper = cva({
@@ -18,7 +18,7 @@ export function useAttrs(props) {
18
18
  setColor(
19
19
  cvaWrapper({
20
20
  size: props.size,
21
- color: props.color,
21
+ color: getColor(props.color),
22
22
  }),
23
23
  props.color,
24
24
  ),
@@ -5,7 +5,10 @@ import defaultConfig from "../configs/default.config";
5
5
  import { computed } from "vue";
6
6
 
7
7
  export function useAttrs(props) {
8
- const { config, getAttrs, setColor, hasSlotContent } = useUI(defaultConfig, () => props.config);
8
+ const { config, getAttrs, hasSlotContent, getColor, setColor } = useUI(
9
+ defaultConfig,
10
+ () => props.config,
11
+ );
9
12
  const { wrapper, body } = config.value;
10
13
 
11
14
  const cvaWrapper = cva({
@@ -23,7 +26,7 @@ export function useAttrs(props) {
23
26
  const wrapperClasses = computed(() =>
24
27
  setColor(
25
28
  cvaWrapper({
26
- color: props.color,
29
+ color: getColor(props.color),
27
30
  bordered: props.bordered,
28
31
  }),
29
32
  props.color,
@@ -43,5 +43,9 @@ export default /*tw*/ {
43
43
  bordered: false,
44
44
  closeIcon: false,
45
45
  },
46
- safelist: (colors) => [{ pattern: `bg-(${colors})-50` }, { pattern: `text-(${colors})-700` }, { pattern: `border-(${colors})-100` }],
46
+ safelist: (colors) => [
47
+ { pattern: `bg-(${colors})-50` },
48
+ { pattern: `text-(${colors})-700` },
49
+ { pattern: `border-(${colors})-100` },
50
+ ],
47
51
  };
@@ -5,7 +5,10 @@ import defaultConfig from "../configs/default.config";
5
5
  import { computed } from "vue";
6
6
 
7
7
  export function useAttrs(props) {
8
- const { config, getAttrs, hasSlotContent, setColor } = useUI(defaultConfig, () => props.config);
8
+ const { config, getAttrs, hasSlotContent, getColor, setColor } = useUI(
9
+ defaultConfig,
10
+ () => props.config,
11
+ );
9
12
  const { wrapper, body } = config.value;
10
13
 
11
14
  const cvaWrapper = cva({
@@ -25,7 +28,7 @@ export function useAttrs(props) {
25
28
  cvaWrapper({
26
29
  variant: props.variant,
27
30
  size: props.size,
28
- color: props.color,
31
+ color: getColor(props.color),
29
32
  weight: props.weight,
30
33
  }),
31
34
  props.color,
@@ -5,7 +5,7 @@ import defaultConfig from "../configs/default.config";
5
5
  import { computed } from "vue";
6
6
 
7
7
  export function useAttrs(props) {
8
- const { config, getAttrs, setColor } = useUI(defaultConfig, () => props.config);
8
+ const { config, getAttrs, getColor, setColor } = useUI(defaultConfig, () => props.config);
9
9
  const { wrapper } = config.value;
10
10
 
11
11
  const cvaWrapper = cva({
@@ -20,7 +20,7 @@ export function useAttrs(props) {
20
20
  size: props.size,
21
21
  weight: props.weight,
22
22
  underlined: props.underlined,
23
- color: props.color,
23
+ color: getColor(props.color),
24
24
  }),
25
25
  props.color,
26
26
  ),
@@ -5,7 +5,10 @@ import defaultConfig from "../configs/default.config";
5
5
  import { computed } from "vue";
6
6
 
7
7
  export function useAttrs(props) {
8
- const { config, hasSlotContent, getAttrs, setColor } = useUI(defaultConfig, () => props.config);
8
+ const { config, hasSlotContent, getAttrs, getColor, setColor } = useUI(
9
+ defaultConfig,
10
+ () => props.config,
11
+ );
9
12
  const { money, sum, penny } = config.value;
10
13
 
11
14
  const cvaMoney = cva({
@@ -30,7 +33,7 @@ export function useAttrs(props) {
30
33
  setColor(
31
34
  cvaMoney({
32
35
  align: props.align,
33
- color: props.color,
36
+ color: getColor(props.color),
34
37
  weight: props.weight,
35
38
  }),
36
39
  props.color,
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "framework": "vue",
3
3
  "name": "vueless",
4
- "version": "0.0.163",
4
+ "version": "0.0.164",
5
5
  "contributions": {
6
6
  "html": {
7
7
  "description-markup": "markdown",