vueless 0.0.478-beta.16 → 0.0.478-beta.17

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.
@@ -6,7 +6,7 @@ import type { InjectionKey } from "vue";
6
6
 
7
7
  export const LocaleSymbol: InjectionKey<LocaleInstance> = Symbol.for("vueless:locale");
8
8
 
9
- export function createLocale(options: LocaleOptions) {
9
+ export function createLocale(options?: LocaleOptions) {
10
10
  const i18n =
11
11
  options?.adapter && options?.adapter?.name ? options?.adapter : createVuelessAdapter(options);
12
12
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "0.0.478-beta.16",
3
+ "version": "0.0.478-beta.17",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless UI Component Library, powered by Tailwind CSS.",
6
6
  "keywords": [
@@ -27,12 +27,12 @@
27
27
  "access": "public"
28
28
  },
29
29
  "scripts": {
30
- "dev:docs": "npx @vueless/web-types && node .prepare/icons && storybook dev -p 6006 --docs --no-open",
31
- "dev": "npx @vueless/web-types && node .prepare/icons && STORYBOOK_FULL=1 storybook dev -p 6006 --no-open",
32
- "build": "npx @vueless/web-types && node .prepare/icons && storybook build --docs",
30
+ "dev:docs": "npx @vueless/web-types && node .scripts/icons && storybook dev -p 6006 --docs --no-open",
31
+ "dev": "npx @vueless/web-types && node .scripts/icons && STORYBOOK_FULL=1 storybook dev -p 6006 --no-open",
32
+ "build": "npx @vueless/web-types && node .scripts/icons && storybook build --docs",
33
33
  "preview": "vite preview --host --outDir=storybook-static",
34
34
  "ts:check": "vue-tsc --build --force",
35
- "release:prepare": "node .prepare/icons && rm -rf dist && mkdir -p dist && cp -r src/. package.json LICENSE README.md dist/ && node .prepare/package",
35
+ "release:prepare": "node .scripts/icons && rm -rf dist && mkdir -p dist && cp -r src/. package.json LICENSE README.md dist/ && node .scripts/package",
36
36
  "release:beta": "release-it --ci --npm.publish --preRelease=beta --increment=prerelease",
37
37
  "release:patch": "release-it patch --ci --npm.publish",
38
38
  "release:minor": "release-it minor --ci --npm.publish --git.tag --github.release",
package/types.ts CHANGED
@@ -7,6 +7,7 @@ import UBadgeDefaultConfig from "./ui.text-badge/config.ts";
7
7
 
8
8
  import type { ComputedRef, MaybeRef } from "vue";
9
9
  import type { Props } from "tippy.js";
10
+ import type { LocaleOptions } from "./adatper.locale/vueless.ts";
10
11
 
11
12
  export type TemplateRefElement = MaybeRef<HTMLElement | HTMLElement[] | null>;
12
13
 
@@ -181,7 +182,7 @@ export interface KeysToExtend {
181
182
  }
182
183
 
183
184
  export interface CreateVuelessOptions {
184
- i18n?: Record<string, string | object>;
185
+ i18n?: LocaleOptions;
185
186
  }
186
187
 
187
188
  export interface TailwindSafelist {
@@ -13,25 +13,9 @@ import path from "node:path";
13
13
  import { createRequire } from "module";
14
14
  import { rm, cp } from "node:fs/promises";
15
15
 
16
+ import { vuelessConfig } from "./vuelessConfig.js";
16
17
  import { getDirFiles, getDefaultConfigJson } from "./helper.js";
17
18
 
18
- let vuelessConfig = {};
19
-
20
- /* Load Vueless config from the project root in IIFE (no top-level await). */
21
- (async () => {
22
- try {
23
- const filePath = `${process.cwd()}/vueless.config`;
24
-
25
- vuelessConfig = (await import(`${filePath}.js`)).default;
26
-
27
- if (!vuelessConfig) {
28
- vuelessConfig = (await import(`${filePath}.ts`)).default;
29
- }
30
- } catch {
31
- vuelessConfig = {};
32
- }
33
- })();
34
-
35
19
  const DEFAULT_ICONS_DIR = "./src/assets/icons";
36
20
  const VUELESS_ICONS_DIR = "./src/assets/icons/cache";
37
21
  const PROJECT_ICONS_DIR = path.join(process.cwd(), "/node_modules/vueless/assets/icons/cache");
@@ -6,6 +6,7 @@ import { extendTailwindMerge } from "tailwind-merge";
6
6
  import { isEqual, omit } from "lodash-es";
7
7
  import { defineConfig } from "cva";
8
8
 
9
+ import { vuelessConfig } from "./vuelessConfig.js";
9
10
  import { createMergeConfigsFunction } from "./mergeConfigs.js";
10
11
  import { getDefaultConfigJson, getDirFiles } from "./helper.js";
11
12
  import {
@@ -18,23 +19,6 @@ import {
18
19
  NESTED_COMPONENT_REG_EXP,
19
20
  } from "../../constants.js";
20
21
 
21
- let vuelessConfig = {};
22
-
23
- /* Load Vueless config from the project root in IIFE (no top-level await). */
24
- (async () => {
25
- try {
26
- const filePath = `${process.cwd()}/vueless.config`;
27
-
28
- vuelessConfig = (await import(`${filePath}.js`)).default;
29
-
30
- if (!vuelessConfig) {
31
- vuelessConfig = (await import(`${filePath}.ts`)).default;
32
- }
33
- } catch {
34
- vuelessConfig = {};
35
- }
36
- })();
37
-
38
22
  const twMerge = extendTailwindMerge(merge(TAILWIND_MERGE_EXTENSION, vuelessConfig.tailwindMerge));
39
23
 
40
24
  export const { cx } = defineConfig({
@@ -164,10 +148,7 @@ function getSafelistItem(safelistClass, colorString) {
164
148
  return classes.length === 1 ? { pattern } : { pattern, variants: [variants].flat() };
165
149
  }
166
150
 
167
- async function getComponentSafelist(
168
- componentName,
169
- { colors, vuelessConfigFiles, isVuelessEnv = false },
170
- ) {
151
+ async function getComponentSafelist(componentName, { colors, vuelessConfigFiles }) {
171
152
  let defaultConfigPath = vuelessConfigFiles.find((file) =>
172
153
  isDefaultComponentConfig(file, componentName),
173
154
  );
@@ -175,9 +156,6 @@ async function getComponentSafelist(
175
156
  let defaultConfig = {};
176
157
 
177
158
  if (defaultConfigPath) {
178
- // disable file caching on vueless env (for the dev purpose)
179
- defaultConfigPath = isVuelessEnv ? `${defaultConfigPath}?${Date.now()}` : defaultConfigPath;
180
-
181
159
  const configPath = path.join(process.cwd(), defaultConfigPath);
182
160
  const defaultConfigContent = await readFile(configPath, { encoding: "utf-8" });
183
161
 
@@ -0,0 +1,38 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import esbuild from "esbuild";
4
+
5
+ /**
6
+ * Load Vueless config from the project root.
7
+ * IIFE is used to prevent top level await issue.
8
+ */
9
+ export let vuelessConfig = {};
10
+
11
+ (async () => {
12
+ const configPathJs = path.join(process.cwd(), "/vueless.config.js");
13
+ const configPathTs = path.join(process.cwd(), "/vueless.config.ts");
14
+ const configOutPath = path.join(process.cwd(), "node_modules/.cache/vueless/vueless.config.mjs");
15
+
16
+ if (!fs.existsSync(configPathJs) && !fs.existsSync(configPathTs)) {
17
+ vuelessConfig = {};
18
+
19
+ return;
20
+ }
21
+
22
+ fs.existsSync(configPathJs) && (await buildConfig(configPathJs, configOutPath));
23
+ fs.existsSync(configPathTs) && (await buildConfig(configPathTs, configOutPath));
24
+
25
+ vuelessConfig = (await import(configOutPath)).default;
26
+ })();
27
+
28
+ async function buildConfig(entryPath, configOutFile) {
29
+ await esbuild.build({
30
+ entryPoints: [entryPath],
31
+ outfile: configOutFile,
32
+ bundle: true,
33
+ platform: "node",
34
+ format: "esm",
35
+ target: "ESNext",
36
+ loader: { ".ts": "ts" },
37
+ });
38
+ }
@@ -20,7 +20,9 @@ if (isSSR) {
20
20
  if (!tailwindConfig) {
21
21
  tailwindConfig = (await import(/* @vite-ignore */ `${filePath}.ts`)).default;
22
22
  }
23
- } catch {}
23
+ } catch {
24
+ tailwindConfig = {} as Config;
25
+ }
24
26
  })();
25
27
  }
26
28
 
package/utils/theme.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { merge } from "lodash-es";
2
2
  import tailwindColors from "tailwindcss/colors.js";
3
3
 
4
- import { tailwindConfig } from "./tailwind.ts";
4
+ import { tailwindConfig } from "./tailwindConfig.ts";
5
5
  import { vuelessConfig } from "./ui.ts";
6
6
  import { isSSR, isCSR } from "./helper.ts";
7
7
  import {
@@ -70,7 +70,7 @@ export function setTheme(config: InternalThemeConfig = {}) {
70
70
  vuelessConfig.ringOffsetColorLight ??
71
71
  DEFAULT_RING_OFFSET_COLOR_LIGHT;
72
72
 
73
- const isBrandColor = BRAND_COLORS.some((color) => color === brand);
73
+ const isBrandColor = [...BRAND_COLORS, GRAYSCALE_COLOR].some((color) => color === brand);
74
74
  const isGrayColor = GRAY_COLORS.some((color) => color === gray);
75
75
 
76
76
  if (!isBrandColor) {