vueless 1.2.1-beta.2 → 1.2.1
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/modules.d.ts +0 -6
- package/package.json +1 -2
- package/plugin-vite.js +6 -6
- package/utils/node/dynamicProps.d.ts +1 -1
- package/utils/node/dynamicProps.js +4 -8
- package/utils/node/loaderIcon.d.ts +1 -1
- package/utils/node/loaderIcon.js +6 -10
- package/utils/node/storybook.d.ts +1 -0
- package/utils/node/storybook.js +10 -3
- package/utils/node/tailwindSafelist.d.ts +1 -1
- package/utils/node/tailwindSafelist.js +10 -20
- package/utils/node/webTypes.d.ts +1 -1
- package/utils/node/webTypes.js +3 -4
- package/utils/theme.ts +0 -1
package/modules.d.ts
CHANGED
|
@@ -20,12 +20,6 @@ declare module "*.svg?skipsvgo" {
|
|
|
20
20
|
export default component;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
declare module "vueless/storybook" {
|
|
24
|
-
import type { Config, UnknownObject } from "./types";
|
|
25
|
-
export function defineConfigWithVueless(config: Config): Promise<UnknownObject>;
|
|
26
|
-
export function getVuelessStoriesGlob(vuelessEnv: string): Promise<string[]>;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
23
|
declare module "virtual:vueless/icons" {
|
|
30
24
|
import type { UnknownArray } from "./types";
|
|
31
25
|
export const cachedIcons: UnknownArray;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vueless",
|
|
3
|
-
"version": "1.2.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Vue Styleless UI Component Library, powered by Tailwind CSS.",
|
|
5
5
|
"author": "Johnny Grid <hello@vueless.com> (https://vueless.com)",
|
|
6
6
|
"homepage": "https://vueless.com",
|
|
@@ -90,7 +90,6 @@
|
|
|
90
90
|
"./constants.js": "./constants.js",
|
|
91
91
|
"./plugin-vite": "./plugin-vite.js",
|
|
92
92
|
"./plugin-vite.js": "./plugin-vite.js",
|
|
93
|
-
"./storybook": "./utils/node/storybook.js",
|
|
94
93
|
"./tailwind.css": "./tailwind.css",
|
|
95
94
|
"./types": "./types.ts",
|
|
96
95
|
"./modules": {
|
package/plugin-vite.js
CHANGED
|
@@ -120,21 +120,21 @@ export const Vueless = function (options = {}) {
|
|
|
120
120
|
configResolved: async (config) => {
|
|
121
121
|
if (!isNuxtModuleEnv) {
|
|
122
122
|
/* auto import user configs */
|
|
123
|
-
await autoImportUserConfigs(
|
|
123
|
+
await autoImportUserConfigs();
|
|
124
124
|
|
|
125
125
|
/* merge and cache component configs. */
|
|
126
126
|
await cacheMergedConfigs(vuelessSrcDir);
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
await buildWebTypes(
|
|
130
|
-
await setCustomPropTypes(
|
|
129
|
+
await buildWebTypes(vuelessSrcDir);
|
|
130
|
+
await setCustomPropTypes(vuelessSrcDir);
|
|
131
131
|
|
|
132
132
|
/* collect used in project colors for tailwind safelist */
|
|
133
|
-
await createTailwindSafelist({ env, srcDir: vuelessSrcDir, targetFiles,
|
|
133
|
+
await createTailwindSafelist({ env, srcDir: vuelessSrcDir, targetFiles, debug });
|
|
134
134
|
|
|
135
135
|
/* cache vueless built-in and project icons */
|
|
136
136
|
await removeIconsCache(basePath);
|
|
137
|
-
await createIconsCache({ env,
|
|
137
|
+
await createIconsCache({ env, debug, targetFiles });
|
|
138
138
|
|
|
139
139
|
if (isNuxtModuleEnv) {
|
|
140
140
|
await copyIconsCache(basePath);
|
|
@@ -170,7 +170,7 @@ export const Vueless = function (options = {}) {
|
|
|
170
170
|
|
|
171
171
|
if (hasIconChanges && currentIconLines.length) {
|
|
172
172
|
/* cache vueless built-in and project icons */
|
|
173
|
-
await createIconsCache({ env, targetFiles: [file]
|
|
173
|
+
await createIconsCache({ env, debug, targetFiles: [file] });
|
|
174
174
|
|
|
175
175
|
if (isNuxtModuleEnv) {
|
|
176
176
|
await copyIconsCache(basePath);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export function setCustomPropTypes(
|
|
1
|
+
export function setCustomPropTypes(srcDir: any): Promise<void>;
|
|
2
2
|
export function removeCustomPropTypes(srcDir: any): Promise<void>;
|
|
@@ -3,7 +3,7 @@ import { existsSync } from "node:fs";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
|
|
5
5
|
import { removeFolderIfEmpty } from "./helper.js";
|
|
6
|
-
import {
|
|
6
|
+
import { vuelessConfig } from "./vuelessConfig.js";
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
9
|
CACHE_DIR,
|
|
@@ -25,9 +25,7 @@ const WORD_IN_QUOTE_REG_EXP = /"([^"]+)"/g;
|
|
|
25
25
|
|
|
26
26
|
const DEFAULT_SAFE_COLORS = [PRIMARY_COLOR, GRAYSCALE_COLOR, INHERIT_COLOR, TEXT_COLOR];
|
|
27
27
|
|
|
28
|
-
export async function setCustomPropTypes(
|
|
29
|
-
const vuelessConfig = await getVuelessConfig(basePath);
|
|
30
|
-
|
|
28
|
+
export async function setCustomPropTypes(srcDir) {
|
|
31
29
|
for await (const [componentName, componentDir] of Object.entries(COMPONENTS)) {
|
|
32
30
|
let componentGlobalConfig = vuelessConfig.components?.[componentName];
|
|
33
31
|
|
|
@@ -80,10 +78,8 @@ export async function setCustomPropTypes({ vuelessSrcDir, basePath } = {}) {
|
|
|
80
78
|
const isCustomProps = componentGlobalConfig && componentGlobalConfig.props;
|
|
81
79
|
|
|
82
80
|
if (isCustomProps) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
await cacheComponentTypes(cachePath);
|
|
86
|
-
await modifyComponentTypes(cachePath, componentGlobalConfig.props);
|
|
81
|
+
await cacheComponentTypes(path.join(srcDir, componentDir));
|
|
82
|
+
await modifyComponentTypes(path.join(srcDir, componentDir), componentGlobalConfig.props);
|
|
87
83
|
}
|
|
88
84
|
}
|
|
89
85
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function createIconsCache({ env, debug, targetFiles
|
|
1
|
+
export function createIconsCache({ env, debug, targetFiles }?: string): Promise<void>;
|
|
2
2
|
export function removeIconsCache(basePath: string, isVuelessEnv?: boolean): Promise<void>;
|
|
3
3
|
export function copyIconsCache(basePath: string, isVuelessEnv?: boolean): Promise<void>;
|
|
4
4
|
export function generateIconExports(): string;
|
package/utils/node/loaderIcon.js
CHANGED
|
@@ -11,7 +11,7 @@ import { cwd } from "node:process";
|
|
|
11
11
|
import { rm, cp } from "node:fs/promises";
|
|
12
12
|
import { createRequire } from "module";
|
|
13
13
|
|
|
14
|
-
import {
|
|
14
|
+
import { vuelessConfig } from "./vuelessConfig.js";
|
|
15
15
|
import { getDirFiles, getMergedComponentConfig } from "./helper.js";
|
|
16
16
|
import {
|
|
17
17
|
ICONS_DIR,
|
|
@@ -34,9 +34,8 @@ let uIconDefaults = {};
|
|
|
34
34
|
* @param {string} env
|
|
35
35
|
* @param {boolean} debug
|
|
36
36
|
* @param {Array} targetFiles
|
|
37
|
-
* @param {string} basePath
|
|
38
37
|
*/
|
|
39
|
-
export async function createIconsCache({ env, debug = false, targetFiles = []
|
|
38
|
+
export async function createIconsCache({ env, debug = false, targetFiles = [] } = {}) {
|
|
40
39
|
const isInternalEnv = env === INTERNAL_ENV;
|
|
41
40
|
const isStorybookEnv = env === STORYBOOK_ENV;
|
|
42
41
|
|
|
@@ -56,8 +55,6 @@ export async function createIconsCache({ env, debug = false, targetFiles = [], b
|
|
|
56
55
|
...vuelessMergedConfigFiles,
|
|
57
56
|
];
|
|
58
57
|
|
|
59
|
-
const vuelessConfig = await getVuelessConfig(basePath);
|
|
60
|
-
|
|
61
58
|
if (isInternalEnv) {
|
|
62
59
|
const storybookFiles = [];
|
|
63
60
|
const internalFiles = [];
|
|
@@ -68,13 +65,13 @@ export async function createIconsCache({ env, debug = false, targetFiles = [], b
|
|
|
68
65
|
: internalFiles.push(file);
|
|
69
66
|
}
|
|
70
67
|
|
|
71
|
-
await findAndCopyIcons(storybookFiles, STORYBOOK_ICONS_LIBRARY,
|
|
72
|
-
await findAndCopyIcons(internalFiles, INTERNAL_ICONS_LIBRARY,
|
|
68
|
+
await findAndCopyIcons(storybookFiles, STORYBOOK_ICONS_LIBRARY, debug);
|
|
69
|
+
await findAndCopyIcons(internalFiles, INTERNAL_ICONS_LIBRARY, debug);
|
|
73
70
|
}
|
|
74
71
|
|
|
75
72
|
if (!isInternalEnv) {
|
|
76
73
|
await cachePackageIcons(isStorybookEnv);
|
|
77
|
-
await findAndCopyIcons(files, uIconDefaults.library,
|
|
74
|
+
await findAndCopyIcons(files, uIconDefaults.library, debug);
|
|
78
75
|
}
|
|
79
76
|
}
|
|
80
77
|
|
|
@@ -183,10 +180,9 @@ async function cachePackageIcons(isStorybookEnv) {
|
|
|
183
180
|
* Scan the project for icon names and copy found icons to the cache.
|
|
184
181
|
* @param {Array} files
|
|
185
182
|
* @param {string} library
|
|
186
|
-
* @param {object} vuelessConfig
|
|
187
183
|
* @param {boolean} debug
|
|
188
184
|
*/
|
|
189
|
-
async function findAndCopyIcons(files, library,
|
|
185
|
+
async function findAndCopyIcons(files, library, debug) {
|
|
190
186
|
const safelistIcons = vuelessConfig.components?.["UIcon"]?.safelistIcons;
|
|
191
187
|
|
|
192
188
|
const validIconNamesRegex = /^(?!icon$|name$)[a-z0-9_-]+$/;
|
package/utils/node/storybook.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getVuelessConfig } from "./vuelessConfig.js";
|
|
2
|
+
import { autoImportUserConfigs } from "./helper.js";
|
|
2
3
|
import {
|
|
3
4
|
COMPONENTS,
|
|
4
5
|
DIRECTIVES,
|
|
@@ -16,7 +17,10 @@ import {
|
|
|
16
17
|
export function defineConfigWithVueless(config) {
|
|
17
18
|
return (async () => ({
|
|
18
19
|
...config,
|
|
19
|
-
stories: [
|
|
20
|
+
stories: [
|
|
21
|
+
...config.stories,
|
|
22
|
+
...(await getVuelessStoriesGlob(config?.vuelessEnv, config?.basePath)),
|
|
23
|
+
],
|
|
20
24
|
addons: [
|
|
21
25
|
...new Set([
|
|
22
26
|
...(config.addons || []),
|
|
@@ -26,7 +30,6 @@ export function defineConfigWithVueless(config) {
|
|
|
26
30
|
"@storybook/addon-themes",
|
|
27
31
|
]),
|
|
28
32
|
],
|
|
29
|
-
staticDirs: ["public"],
|
|
30
33
|
framework: {
|
|
31
34
|
...config.framework,
|
|
32
35
|
name: "@storybook/vue3-vite",
|
|
@@ -49,9 +52,13 @@ export function defineConfigWithVueless(config) {
|
|
|
49
52
|
* Retrieves the glob pattern for Vueless stories based on the provided Vueless environment.
|
|
50
53
|
*
|
|
51
54
|
* @param {string} vuelessEnv - The Vueless environment.
|
|
55
|
+
* @param {string} basePath - The Project base path.
|
|
52
56
|
* @return {Promise<string[]>} A promise that resolves to an array of glob patterns for Vueless stories.
|
|
53
57
|
*/
|
|
54
|
-
async function getVuelessStoriesGlob(vuelessEnv) {
|
|
58
|
+
export async function getVuelessStoriesGlob(vuelessEnv, basePath) {
|
|
59
|
+
/* Auto import user configs. */
|
|
60
|
+
await autoImportUserConfigs(basePath);
|
|
61
|
+
|
|
55
62
|
const vuelessSrcDir = vuelessEnv === INTERNAL_ENV ? VUELESS_LOCAL_DIR : VUELESS_PACKAGE_DIR;
|
|
56
63
|
const vuelessConfig = await getVuelessConfig();
|
|
57
64
|
const storiesGlob = [];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export function clearTailwindSafelist(): Promise<void>;
|
|
2
|
-
export function createTailwindSafelist({ env, srcDir, targetFiles
|
|
2
|
+
export function createTailwindSafelist({ env, srcDir, targetFiles }?: {
|
|
3
3
|
env: string;
|
|
4
4
|
srcDir: string;
|
|
5
5
|
targetFiles?: string[] | undefined;
|
|
@@ -5,7 +5,7 @@ import { readFile, unlink, writeFile, mkdir } from "node:fs/promises";
|
|
|
5
5
|
import { merge } from "lodash-es";
|
|
6
6
|
|
|
7
7
|
import { getDefaultComponentConfig, getMergedComponentConfig, getDirFiles } from "./helper.js";
|
|
8
|
-
import {
|
|
8
|
+
import { vuelessConfig } from "./vuelessConfig.js";
|
|
9
9
|
import {
|
|
10
10
|
COMPONENTS,
|
|
11
11
|
INTERNAL_ENV,
|
|
@@ -50,31 +50,25 @@ export async function clearTailwindSafelist() {
|
|
|
50
50
|
* @param {string[]} [options.targetFiles=[]] - Optional array of target file paths to include in the safelist generation.
|
|
51
51
|
* @return {Promise<void>} A promise that resolves when the safelist file is successfully created and written to disk.
|
|
52
52
|
*/
|
|
53
|
-
export async function createTailwindSafelist({ env, srcDir, targetFiles
|
|
53
|
+
export async function createTailwindSafelist({ env, srcDir, targetFiles = [] } = {}) {
|
|
54
54
|
const isStorybookEnv = env === STORYBOOK_ENV;
|
|
55
55
|
const isInternalEnv = env === INTERNAL_ENV;
|
|
56
56
|
|
|
57
|
-
const vuelessConfig = await getVuelessConfig(basePath);
|
|
58
|
-
|
|
59
57
|
/* Safelist dynamic color classes in components. */
|
|
60
|
-
const classes = await getComponentsSafelistClasses(
|
|
58
|
+
const classes = await getComponentsSafelistClasses({
|
|
61
59
|
env: { isStorybookEnv, isInternalEnv },
|
|
62
60
|
targetFiles,
|
|
63
61
|
srcDir,
|
|
64
62
|
});
|
|
65
63
|
|
|
66
64
|
/* Safelist all color shades to allow runtime color switching feature. */
|
|
67
|
-
const runtimeColorCSSVariables = getRuntimeColorCSSVariables(
|
|
68
|
-
vuelessConfig,
|
|
69
|
-
isStorybookEnv,
|
|
70
|
-
isInternalEnv,
|
|
71
|
-
);
|
|
65
|
+
const runtimeColorCSSVariables = getRuntimeColorCSSVariables(isStorybookEnv, isInternalEnv);
|
|
72
66
|
|
|
73
67
|
/* Safelist primary and neutral color variables. */
|
|
74
|
-
let brandColorCSSVariables = getBrandColorCSSVariables(
|
|
68
|
+
let brandColorCSSVariables = getBrandColorCSSVariables(isInternalEnv);
|
|
75
69
|
|
|
76
70
|
/* Safelist all color variables to allow runtime color switching feature. */
|
|
77
|
-
const themeCSSVariables = getThemeCSSVariables(
|
|
71
|
+
const themeCSSVariables = getThemeCSSVariables();
|
|
78
72
|
|
|
79
73
|
const safelist = [
|
|
80
74
|
...new Set([
|
|
@@ -97,12 +91,11 @@ export async function createTailwindSafelist({ env, srcDir, targetFiles, basePat
|
|
|
97
91
|
* Generates a list of runtime CSS color variables based on the environment
|
|
98
92
|
* and available configuration.
|
|
99
93
|
*
|
|
100
|
-
* @param {object} vuelessConfig - The Vueless config object.
|
|
101
94
|
* @param {boolean} isStorybookEnv - Indicates if the method is executed in a Storybook environment.
|
|
102
95
|
* @param {boolean} isInternalEnv - Indicates if the method is executed in an Internal environment.
|
|
103
96
|
* @return {string[]} An array of strings, each representing CSS variable definitions for colors and shades.
|
|
104
97
|
*/
|
|
105
|
-
function getRuntimeColorCSSVariables(
|
|
98
|
+
function getRuntimeColorCSSVariables(isStorybookEnv, isInternalEnv) {
|
|
106
99
|
if (!isStorybookEnv && !isInternalEnv && !vuelessConfig.runtimeColors) return [];
|
|
107
100
|
|
|
108
101
|
const colors = vuelessConfig.runtimeColors?.length
|
|
@@ -117,11 +110,10 @@ function getRuntimeColorCSSVariables(vuelessConfig, isStorybookEnv, isInternalEn
|
|
|
117
110
|
/**
|
|
118
111
|
* Generates an array of CSS variable strings for `primary` and `neutral` colors based on environment settings.
|
|
119
112
|
*
|
|
120
|
-
* @param {object} vuelessConfig - The Vueless config object.
|
|
121
113
|
* @param {boolean} isInternalEnv - Indicates whether the current environment is internal.
|
|
122
114
|
* @return {string[]} An array of CSS variable strings representing brand colors and their shades.
|
|
123
115
|
*/
|
|
124
|
-
function getBrandColorCSSVariables(
|
|
116
|
+
function getBrandColorCSSVariables(isInternalEnv) {
|
|
125
117
|
if (isInternalEnv) return [];
|
|
126
118
|
|
|
127
119
|
const colors = [
|
|
@@ -140,10 +132,9 @@ function getBrandColorCSSVariables(vuelessConfig, isInternalEnv) {
|
|
|
140
132
|
* This method combines theme settings from default and custom configurations and
|
|
141
133
|
* returns an array of variable values for each theme.
|
|
142
134
|
*
|
|
143
|
-
* @param {object} vuelessConfig - The Vueless config object.
|
|
144
135
|
* @return {Array} An array containing CSS variable values from the light and dark themes.
|
|
145
136
|
*/
|
|
146
|
-
function getThemeCSSVariables(
|
|
137
|
+
function getThemeCSSVariables() {
|
|
147
138
|
const lightThemeConfig = merge({}, DEFAULT_LIGHT_THEME, vuelessConfig.lightTheme);
|
|
148
139
|
const darkThemeConfig = merge({}, DEFAULT_DARK_THEME, vuelessConfig.darkTheme);
|
|
149
140
|
|
|
@@ -159,7 +150,6 @@ function getThemeCSSVariables(vuelessConfig) {
|
|
|
159
150
|
* CSS classes based on component usage, environment conditions, and configured colors.
|
|
160
151
|
*
|
|
161
152
|
* @param {Object} params - The parameters for the function.
|
|
162
|
-
* @param {object} vuelessConfig - The Vueless config object.
|
|
163
153
|
* @param {Array<string>} params.targetFiles - List of file paths to check for component usage.
|
|
164
154
|
* @param {Object} params.env - Environment variables for distinguishing between different environments.
|
|
165
155
|
* @param {boolean} params.env.isStorybookEnv - Indicates whether the function is running in a Storybook environment.
|
|
@@ -169,7 +159,7 @@ function getThemeCSSVariables(vuelessConfig) {
|
|
|
169
159
|
* @return {Promise<Array<string>>} A promise that resolves to an array of safelisted CSS class names
|
|
170
160
|
* for all matched components and nested components.
|
|
171
161
|
*/
|
|
172
|
-
async function getComponentsSafelistClasses(
|
|
162
|
+
async function getComponentsSafelistClasses({ targetFiles, env, srcDir }) {
|
|
173
163
|
const { isStorybookEnv, isInternalEnv } = env;
|
|
174
164
|
|
|
175
165
|
let srcVueFiles = [];
|
package/utils/node/webTypes.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export function buildWebTypes(
|
|
1
|
+
export function buildWebTypes(srcDir: any): Promise<void>;
|
package/utils/node/webTypes.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { vuelessConfig } from "./vuelessConfig.js";
|
|
2
2
|
|
|
3
|
-
export async function buildWebTypes(
|
|
3
|
+
export async function buildWebTypes(srcDir) {
|
|
4
4
|
try {
|
|
5
|
-
const vuelessConfig = await getVuelessConfig(basePath);
|
|
6
5
|
const { default: build } = await import("@vueless/storybook/webTypes/index.js");
|
|
7
6
|
|
|
8
|
-
await build(vuelessConfig,
|
|
7
|
+
await build(vuelessConfig, srcDir);
|
|
9
8
|
} catch (error) {
|
|
10
9
|
if (error.code !== "ERR_MODULE_NOT_FOUND") {
|
|
11
10
|
// eslint-disable-next-line no-console
|
package/utils/theme.ts
CHANGED
|
@@ -81,7 +81,6 @@ function toggleColorModeClass() {
|
|
|
81
81
|
function setColorMode(mode: `${ColorMode}`, isCachedAutoMode?: boolean): string {
|
|
82
82
|
const colorMode = mode || getStored(COLOR_MODE_KEY) || vuelessConfig.colorMode || ColorMode.Light;
|
|
83
83
|
|
|
84
|
-
// TODO: This always true `!!Number(getStored(AUTO_MODE_KEY))` > `!!Number(undefined) = true`
|
|
85
84
|
isCachedAutoMode = isCachedAutoMode ?? !!Number(getStored(AUTO_MODE_KEY));
|
|
86
85
|
|
|
87
86
|
const isAutoMode = colorMode === ColorMode.Auto;
|