vueless 0.0.350 → 0.0.352

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.
@@ -3,8 +3,6 @@ import { unref } from "vue";
3
3
  function clickOutside(target, handler, options) {
4
4
  const { capture = true, ignore = [] } = options;
5
5
 
6
- let shouldListen = true;
7
-
8
6
  const ignoreList = unref(ignore).map((item) => unref(item));
9
7
  const el = unref(target);
10
8
 
@@ -18,25 +16,15 @@ function clickOutside(target, handler, options) {
18
16
  return;
19
17
  }
20
18
 
21
- if (!shouldListen) {
22
- shouldListen = true;
23
-
24
- return;
25
- }
26
-
27
19
  handler(event);
28
20
  }
29
21
 
30
- function onPointerdown(event) {
31
- shouldListen = !!(el && !event.composedPath().includes(el));
32
- }
33
-
34
22
  window.addEventListener("click", onClick, { passive: true, capture });
35
- window.addEventListener("pointerdown", onPointerdown, { passive: true });
23
+ window.addEventListener("pointerdown", onClick, { passive: true });
36
24
 
37
25
  function removeEvents() {
38
26
  window.removeEventListener("click", onClick, { capture, passive: true });
39
- window.removeEventListener("pointerdown", onPointerdown, { passive: true });
27
+ window.removeEventListener("pointerdown", onClick, { passive: true });
40
28
  }
41
29
 
42
30
  return removeEvents;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "0.0.350",
3
+ "version": "0.0.352",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless Component Framework.",
6
6
  "homepage": "https://vueless.com",
@@ -1,5 +1,5 @@
1
1
  import forms from "@tailwindcss/forms";
2
- import defaultTheme from "tailwindcss/defaultTheme.js";
2
+ import colors from "tailwindcss/colors.js";
3
3
  import {
4
4
  COLOR_SHADES,
5
5
  BRAND_COLOR,
@@ -8,7 +8,6 @@ import {
8
8
  DARK_MODE_SELECTOR,
9
9
  } from "./constants.js";
10
10
 
11
- const safelist = getSafelist();
12
11
  const isStrategyOverride = process.env.VUELESS_STRATEGY === "override";
13
12
 
14
13
  /**
@@ -38,46 +37,62 @@ export const vuelessContentNuxt = [
38
37
  "./layouts/**/*.vue",
39
38
  "./pages/**/*.vue",
40
39
  "./plugins/**/*.{js,ts}",
41
- "./app.vue",
42
- "./error.vue",
40
+ "./utils/**/*.{js,ts}",
41
+ "./App.{js,ts,vue}",
42
+ "./app.{js,ts,vue}",
43
+ "./Error.{js,ts,vue}",
44
+ "./error.{js,ts,vue}",
45
+ "./app.config.{js,ts}",
43
46
  ];
44
47
 
48
+ /**
49
+ * Vueless tailwind static config.
50
+ * Exported to use in `@vueless/module-nuxt`.
51
+ */
52
+ const safelist = getSafelist();
53
+ const brandColors = getPalette(BRAND_COLOR);
54
+ const grayColors = getPalette(GRAY_COLOR);
55
+
56
+ export const vuelessTailwindConfig = {
57
+ darkMode: DARK_MODE_SELECTOR,
58
+ content: [...vuelessContent, ...vuelessContentVue, ...vuelessContentNuxt],
59
+ safelist,
60
+ theme: {
61
+ extend: {
62
+ colors: {
63
+ [BRAND_COLOR]: brandColors || {},
64
+ [GRAY_COLOR]: grayColors || {},
65
+ [COOL_COLOR]: { ...(colors[GRAY_COLOR] || {}) },
66
+ },
67
+ spacing: {
68
+ "safe-top": "env(safe-area-inset-top)",
69
+ "safe-bottom": "env(safe-area-inset-bottom)",
70
+ "safe-left": "env(safe-area-inset-left)",
71
+ "safe-right": "env(safe-area-inset-right)",
72
+ },
73
+ fontSize: {
74
+ "2xs": ["0.625rem", "0.875rem"] /* 10px / 14px */,
75
+ },
76
+ ringWidth: {
77
+ dynamic: "var(--vl-ring)",
78
+ },
79
+ ringOffsetWidth: {
80
+ dynamic: "var(--vl-ring-offset)",
81
+ },
82
+ borderRadius: {
83
+ dynamic: "var(--vl-rounding)",
84
+ },
85
+ },
86
+ },
87
+ };
88
+
45
89
  /**
46
90
  * Generates preset for TailwindCSS base on Vueless config.
47
91
  * @returns {Object}
48
92
  */
49
93
  export function vuelessPreset() {
50
94
  return {
51
- darkMode: DARK_MODE_SELECTOR,
52
- content: [...vuelessContent, ...vuelessContentVue, ...vuelessContentNuxt],
53
- safelist,
54
- theme: {
55
- extend: {
56
- colors: {
57
- [BRAND_COLOR]: getPalette(BRAND_COLOR),
58
- [GRAY_COLOR]: getPalette(GRAY_COLOR),
59
- [COOL_COLOR]: { ...defaultTheme.colors[GRAY_COLOR] },
60
- },
61
- spacing: {
62
- "safe-top": "env(safe-area-inset-top)",
63
- "safe-bottom": "env(safe-area-inset-bottom)",
64
- "safe-left": "env(safe-area-inset-left)",
65
- "safe-right": "env(safe-area-inset-right)",
66
- },
67
- fontSize: {
68
- "2xs": ["0.625rem", "0.875rem"] /* 10px / 14px */,
69
- },
70
- ringWidth: {
71
- dynamic: "var(--vl-ring)",
72
- },
73
- ringOffsetWidth: {
74
- dynamic: "var(--vl-ring-offset)",
75
- },
76
- borderRadius: {
77
- dynamic: "var(--vl-rounding)",
78
- },
79
- },
80
- },
95
+ ...vuelessTailwindConfig,
81
96
  plugins: [forms],
82
97
  };
83
98
  }
@@ -88,11 +103,7 @@ export function vuelessPreset() {
88
103
  * @returns {Function}
89
104
  */
90
105
  function twColorWithOpacity(variableName) {
91
- return ({ opacityValue }) => {
92
- return opacityValue !== undefined
93
- ? `rgba(var(${variableName}), ${opacityValue})`
94
- : `rgb(var(${variableName}))`;
95
- };
106
+ return `rgba(var(${variableName}))`;
96
107
  }
97
108
 
98
109
  /**
@@ -1,7 +1,7 @@
1
1
  export default /*tw*/ {
2
2
  wrapper: "relative inline-block",
3
- dropdownBadge: "{UBadge}",
4
- dropdownBadgeActive: "group ring-dynamic ring-offset-dynamic ring-brand-700/15 border-brand-500 hover:border-brand-500",
3
+ dropdownBadge: "{UBadge} transition",
4
+ dropdownBadgeActive: "group ring-dynamic ring-offset-dynamic ring-{color}-700/15",
5
5
  dropdownIcon: "{UIcon} transition duration-300 group-[]:rotate-180",
6
6
  dropdownList: {
7
7
  component: "{UDropdownList}",
@@ -30,4 +30,5 @@ export default /*tw*/ {
30
30
  /* icons */
31
31
  dropdownIcon: "keyboard_arrow_down",
32
32
  },
33
+ safelist: (colors) => [{ pattern: `ring-(${colors})-700` }],
33
34
  };
@@ -5,7 +5,7 @@ import defaultConfig from "./config.js";
5
5
  import { computed } from "vue";
6
6
 
7
7
  export default function useAttrs(props, { isShownOptions }) {
8
- const { config, getAttrs, hasSlotContent, isSystemKey, isCVA } = useUI(
8
+ const { config, getColor, setColor, getAttrs, hasSlotContent, isSystemKey, isCVA } = useUI(
9
9
  defaultConfig,
10
10
  () => props.config,
11
11
  );
@@ -20,10 +20,11 @@ export default function useAttrs(props, { isShownOptions }) {
20
20
  if (isCVA(value)) {
21
21
  value = cva(value)({
22
22
  ...props,
23
+ color: getColor(props.color),
23
24
  });
24
25
  }
25
26
 
26
- return value;
27
+ return setColor(value, props.color);
27
28
  });
28
29
 
29
30
  attrs[`${key}Attrs`] = getAttrs(key, { classes });
@@ -35,7 +36,7 @@ export default function useAttrs(props, { isShownOptions }) {
35
36
  ...badgeAttrs.value,
36
37
  class: cx([
37
38
  badgeAttrs.value.class,
38
- isShownOptions.value && config.value.dropdownBadgeActive,
39
+ isShownOptions.value && setColor(config.value.dropdownBadgeActive, props.color),
39
40
  ]),
40
41
  }));
41
42
  }
@@ -1,7 +1,7 @@
1
1
  export default /*tw*/ {
2
2
  wrapper: "relative inline-block",
3
3
  dropdownButton: "{UButton}",
4
- dropdownButtonActive: "group ring-dynamic ring-offset-dynamic ring-brand-700/15 border-brand-500 hover:border-brand-500",
4
+ dropdownButtonActive: "group ring-dynamic ring-offset-dynamic ring-{color}-700/15",
5
5
  dropdownIcon: "{UIcon} transition duration-300 group-[]:rotate-180",
6
6
  dropdownList: {
7
7
  base: "{UDropdownList} w-fit",
@@ -32,4 +32,5 @@ export default /*tw*/ {
32
32
  /* icons */
33
33
  dropdownIcon: "keyboard_arrow_down",
34
34
  },
35
+ safelist: (colors) => [{ pattern: `ring-(${colors})-700` }],
35
36
  };
@@ -5,7 +5,7 @@ import defaultConfig from "./config.js";
5
5
  import { computed } from "vue";
6
6
 
7
7
  export default function useAttrs(props, { isShownOptions }) {
8
- const { config, getAttrs, hasSlotContent, isSystemKey, isCVA } = useUI(
8
+ const { config, getColor, setColor, getAttrs, hasSlotContent, isSystemKey, isCVA } = useUI(
9
9
  defaultConfig,
10
10
  () => props.config,
11
11
  );
@@ -20,10 +20,11 @@ export default function useAttrs(props, { isShownOptions }) {
20
20
  if (isCVA(value)) {
21
21
  value = cva(value)({
22
22
  ...props,
23
+ color: getColor(props.color),
23
24
  });
24
25
  }
25
26
 
26
- return value;
27
+ return setColor(value, props.color);
27
28
  });
28
29
 
29
30
  attrs[`${key}Attrs`] = getAttrs(key, { classes });
@@ -35,7 +36,7 @@ export default function useAttrs(props, { isShownOptions }) {
35
36
  ...dropdownButton.value,
36
37
  class: cx([
37
38
  dropdownButton.value.class,
38
- isShownOptions.value && config.value.dropdownButtonActive,
39
+ isShownOptions.value && setColor(config.value.dropdownButtonActive, props.color),
39
40
  ]),
40
41
  }));
41
42
  }
@@ -5,7 +5,7 @@ import defaultConfig from "./config.js";
5
5
  import { computed } from "vue";
6
6
 
7
7
  export default function useAttrs(props, { isShownOptions }) {
8
- const { config, getAttrs, hasSlotContent, isSystemKey, isCVA } = useUI(
8
+ const { config, getColor, setColor, getAttrs, hasSlotContent, isSystemKey, isCVA } = useUI(
9
9
  defaultConfig,
10
10
  () => props.config,
11
11
  );
@@ -18,12 +18,13 @@ export default function useAttrs(props, { isShownOptions }) {
18
18
  let value = config.value[key];
19
19
 
20
20
  if (isCVA(value)) {
21
- return cva(value)({
21
+ value = cva(value)({
22
22
  ...props,
23
+ color: getColor(props.color),
23
24
  });
24
25
  }
25
26
 
26
- return value;
27
+ return setColor(value, props.color);
27
28
  });
28
29
 
29
30
  attrs[`${key}Attrs`] = getAttrs(key, { classes });
@@ -33,7 +34,10 @@ export default function useAttrs(props, { isShownOptions }) {
33
34
 
34
35
  attrs[`${key}Attrs`] = computed(() => ({
35
36
  ...linkAttrs.value,
36
- class: cx([linkAttrs.value.class, isShownOptions.value && config.value.dropdownLinkActive]),
37
+ class: cx([
38
+ linkAttrs.value.class,
39
+ isShownOptions.value && setColor(config.value.dropdownLinkActive, props.color),
40
+ ]),
37
41
  }));
38
42
  }
39
43
  }
@@ -1,6 +1,7 @@
1
1
  import colors from "tailwindcss/colors.js";
2
2
 
3
3
  import { vuelessConfig } from "./utilUI.js";
4
+ import { isSSR, isCSR } from "./utilHelper.js";
4
5
  import {
5
6
  GRAY_COLOR,
6
7
  COOL_COLOR,
@@ -15,12 +16,11 @@ import {
15
16
  GRAY_COLORS,
16
17
  PX_IN_REM,
17
18
  } from "../constants.js";
18
- import { isSSR } from "./utilHelper.js";
19
19
 
20
20
  export function themeInit() {
21
21
  if (isSSR) return;
22
22
 
23
- const prefersColorSchemeDark = window && window.matchMedia("(prefers-color-scheme: dark)");
23
+ const prefersColorSchemeDark = window.matchMedia("(prefers-color-scheme: dark)");
24
24
 
25
25
  setTheme({ systemDarkMode: prefersColorSchemeDark.matches });
26
26
 
@@ -30,8 +30,6 @@ export function themeInit() {
30
30
  }
31
31
 
32
32
  export function setTheme(config = {}) {
33
- if (isSSR) return;
34
-
35
33
  const isDarkMode = setDarkMode(config);
36
34
  const ring = config?.ring ?? vuelessConfig?.ring ?? DEFAULT_RING;
37
35
  const ringOffset = config?.ringOffset ?? vuelessConfig?.ringOffset ?? DEFAULT_RING_OFFSET;
@@ -79,22 +77,28 @@ export function setTheme(config = {}) {
79
77
  variables[`--vl-color-brand-${key}`] = convertHexInRgb(colors[brand][key]);
80
78
  }
81
79
 
82
- const style = document.createElement("style");
83
80
  const stringVariables = Object.entries(variables)
84
81
  .map(([key, value]) => `${key}: ${value};`)
85
82
  .join(" ");
86
83
 
87
- style.innerHTML = `:root {${stringVariables}`;
84
+ const rootVariables = `:root {${stringVariables}`;
85
+
86
+ if (isCSR) {
87
+ const style = document.createElement("style");
88
+
89
+ style.innerHTML = rootVariables;
90
+ document.head.appendChild(style);
91
+ }
88
92
 
89
- document.head.appendChild(style);
93
+ return rootVariables;
90
94
  }
91
95
 
92
96
  function setDarkMode(config) {
93
97
  config?.darkMode === undefined
94
- ? localStorage.removeItem(DARK_MODE_SELECTOR)
95
- : localStorage.setItem(DARK_MODE_SELECTOR, Number(!!config?.darkMode));
98
+ ? isCSR && localStorage.removeItem(DARK_MODE_SELECTOR)
99
+ : isCSR && localStorage.setItem(DARK_MODE_SELECTOR, Number(!!config?.darkMode));
96
100
 
97
- const storedDarkMode = localStorage.getItem(DARK_MODE_SELECTOR);
101
+ const storedDarkMode = isCSR ? localStorage.getItem(DARK_MODE_SELECTOR) : null;
98
102
 
99
103
  let isDarkMode =
100
104
  storedDarkMode !== null
@@ -102,8 +106,8 @@ function setDarkMode(config) {
102
106
  : !!(config?.darkMode ?? vuelessConfig?.darkMode ?? config?.systemDarkMode);
103
107
 
104
108
  isDarkMode
105
- ? document.documentElement.classList.add(DARK_MODE_SELECTOR)
106
- : document.documentElement.classList.remove(DARK_MODE_SELECTOR);
109
+ ? isCSR && document.documentElement.classList.add(DARK_MODE_SELECTOR)
110
+ : isCSR && document.documentElement.classList.remove(DARK_MODE_SELECTOR);
107
111
 
108
112
  return isDarkMode;
109
113
  }
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "framework": "vue",
3
3
  "name": "vueless",
4
- "version": "0.0.350",
4
+ "version": "0.0.352",
5
5
  "contributions": {
6
6
  "html": {
7
7
  "description-markup": "markdown",