vueless 0.0.636 → 0.0.638
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
package/preset-tailwind.js
CHANGED
|
@@ -22,9 +22,8 @@ import {
|
|
|
22
22
|
GRAYSCALE_COLOR,
|
|
23
23
|
} from "./constants.js";
|
|
24
24
|
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const grayColor = process.env.VUELESS_GRAY || DEFAULT_GRAY_COLOR;
|
|
25
|
+
const globalSettings = process.env.VUELESS_GLOBAL_SETTINGS || {};
|
|
26
|
+
const isStrategyOverride = globalSettings.strategy === "override";
|
|
28
27
|
|
|
29
28
|
/**
|
|
30
29
|
* Vueless Tailwind CSS `content` config.
|
|
@@ -106,15 +105,16 @@ export const vuelessTailwindConfig = {
|
|
|
106
105
|
},
|
|
107
106
|
configViewer: {
|
|
108
107
|
themeReplacements: {
|
|
109
|
-
|
|
110
|
-
"var(--vl-ring)": DEFAULT_RING,
|
|
111
|
-
"var(--vl-ring-offset)": DEFAULT_RING_OFFSET,
|
|
112
|
-
"var(--vl-ring-offset-color)": DEFAULT_RING_OFFSET_COLOR_LIGHT,
|
|
113
|
-
"var(--vl-rounding-sm)": DEFAULT_ROUNDING_SM,
|
|
114
|
-
"var(--vl-rounding)": DEFAULT_ROUNDING,
|
|
115
|
-
"var(--vl-rounding-lg)": DEFAULT_ROUNDING_LG,
|
|
116
|
-
...getReplacementColors(GRAY_COLOR,
|
|
117
|
-
...getReplacementColors(BRAND_COLOR,
|
|
108
|
+
/* eslint-disable prettier/prettier */
|
|
109
|
+
"var(--vl-ring)": globalSettings.ring || DEFAULT_RING,
|
|
110
|
+
"var(--vl-ring-offset)": globalSettings.ringOffset || DEFAULT_RING_OFFSET,
|
|
111
|
+
"var(--vl-ring-offset-color)": globalSettings.ringOffsetColorLight || DEFAULT_RING_OFFSET_COLOR_LIGHT,
|
|
112
|
+
"var(--vl-rounding-sm)": globalSettings.roundingSm || DEFAULT_ROUNDING_SM,
|
|
113
|
+
"var(--vl-rounding)": globalSettings.ring || DEFAULT_ROUNDING,
|
|
114
|
+
"var(--vl-rounding-lg)": globalSettings.roundingLg || DEFAULT_ROUNDING_LG,
|
|
115
|
+
...getReplacementColors(GRAY_COLOR, globalSettings.gray || DEFAULT_GRAY_COLOR),
|
|
116
|
+
...getReplacementColors(BRAND_COLOR, globalSettings.brand || DEFAULT_BRAND_COLOR),
|
|
117
|
+
/* eslint-enable prettier/prettier */
|
|
118
118
|
},
|
|
119
119
|
},
|
|
120
120
|
},
|
|
@@ -43,11 +43,13 @@ export interface UDatePickerProps<TModelValue> {
|
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
45
|
* Datepicker open direction on x-axis.
|
|
46
|
+
* @extendOnly
|
|
46
47
|
*/
|
|
47
48
|
openDirectionX?: "auto" | "left" | "right";
|
|
48
49
|
|
|
49
50
|
/**
|
|
50
51
|
* Datepicker open direction on y-axis.
|
|
52
|
+
* @extendOnly
|
|
51
53
|
*/
|
|
52
54
|
openDirectionY?: "auto" | "top" | "bottom";
|
|
53
55
|
|
|
@@ -96,11 +96,13 @@ export interface UDatePickerRangeProps<TModelValue> {
|
|
|
96
96
|
|
|
97
97
|
/**
|
|
98
98
|
* Datepicker open direction on x-axis.
|
|
99
|
+
* @extendOnly
|
|
99
100
|
*/
|
|
100
101
|
openDirectionX?: "auto" | "left" | "right";
|
|
101
102
|
|
|
102
103
|
/**
|
|
103
104
|
* Datepicker open direction on y-axis.
|
|
105
|
+
* @extendOnly
|
|
104
106
|
*/
|
|
105
107
|
openDirectionY?: "auto" | "top" | "bottom";
|
|
106
108
|
|
package/ui.form-select/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import { merge } from "lodash-es";
|
|
2
|
+
import { merge, cloneDeep } from "lodash-es";
|
|
3
3
|
import { existsSync } from "node:fs";
|
|
4
4
|
import { readFile } from "node:fs/promises";
|
|
5
5
|
import { extendTailwindMerge } from "tailwind-merge";
|
|
@@ -11,19 +11,20 @@ import { createGetMergedConfig } from "./mergeConfigs.js";
|
|
|
11
11
|
import { getComponentDefaultConfig, getDirFiles } from "./helper.js";
|
|
12
12
|
import {
|
|
13
13
|
COMPONENTS,
|
|
14
|
-
BRAND_COLORS,
|
|
15
|
-
BRAND_COLOR,
|
|
16
14
|
GRAY_COLOR,
|
|
15
|
+
BRAND_COLOR,
|
|
16
|
+
BRAND_COLORS,
|
|
17
|
+
STRATEGY_TYPE,
|
|
18
|
+
SYSTEM_CONFIG_KEY,
|
|
17
19
|
DYNAMIC_COLOR_PATTERN,
|
|
18
|
-
TAILWIND_VARIANT_DELIMITER,
|
|
19
20
|
TAILWIND_MERGE_EXTENSION,
|
|
20
|
-
|
|
21
|
+
TAILWIND_VARIANT_DELIMITER,
|
|
21
22
|
TAILWIND_COLOR_OPACITY_DELIMITER,
|
|
23
|
+
NESTED_COMPONENT_PATTERN_REG_EXP,
|
|
22
24
|
TAILWIND_VARIANT_DELIMITER_REG_EXP,
|
|
23
|
-
STRATEGY_TYPE,
|
|
24
|
-
SYSTEM_CONFIG_KEY,
|
|
25
25
|
} from "../../constants.js";
|
|
26
26
|
|
|
27
|
+
const cwd = process.cwd();
|
|
27
28
|
const twMerge = extendTailwindMerge(merge(TAILWIND_MERGE_EXTENSION, vuelessConfig.tailwindMerge));
|
|
28
29
|
|
|
29
30
|
export const { cx } = defineConfig({
|
|
@@ -60,46 +61,38 @@ export async function createTailwindSafelist({ mode, env, debug, targetFiles = [
|
|
|
60
61
|
|
|
61
62
|
const vuelessFiles = [...srcVueFiles, ...vuelessVueFiles, ...vuelessConfigFiles];
|
|
62
63
|
|
|
64
|
+
const safelist = [];
|
|
65
|
+
|
|
63
66
|
const storybookColors = {
|
|
64
67
|
colors: [...BRAND_COLORS, BRAND_COLOR, GRAY_COLOR],
|
|
65
68
|
isComponentExists: true,
|
|
66
69
|
};
|
|
67
|
-
const safelist = [];
|
|
68
70
|
|
|
69
71
|
const componentNames = Object.keys(COMPONENTS);
|
|
70
72
|
|
|
71
|
-
for await (const
|
|
72
|
-
const defaultConfigPath = vuelessConfigFiles.find((file) =>
|
|
73
|
-
isDefaultComponentConfig(file, component),
|
|
74
|
-
);
|
|
75
|
-
const defaultConfig = await readFile(path.join(process.cwd(), defaultConfigPath), {
|
|
76
|
-
encoding: "utf-8",
|
|
77
|
-
});
|
|
78
|
-
const nestedComponents = (defaultConfig.match(/\{U\w+\}/g) || []).map(
|
|
79
|
-
(nestedComponentPattern) => nestedComponentPattern.replaceAll(/[{}]/g, ""),
|
|
80
|
-
);
|
|
81
|
-
|
|
73
|
+
for await (const componentName of componentNames) {
|
|
82
74
|
const { colors, isComponentExists } = isStorybookMode
|
|
83
75
|
? storybookColors
|
|
84
|
-
: await findComponentColors(vuelessFiles,
|
|
76
|
+
: await findComponentColors(componentName, vuelessFiles, vuelessConfigFiles);
|
|
77
|
+
|
|
78
|
+
const defaultConfig = await retrieveComponentDefaultConfig(componentName, vuelessConfigFiles);
|
|
79
|
+
const match = JSON.stringify(defaultConfig).match(/\{U\w+\}/g) || [];
|
|
80
|
+
|
|
81
|
+
const nestedComponents = match.map((nestedComponentPattern) =>
|
|
82
|
+
nestedComponentPattern.replaceAll(/[{}]/g, ""),
|
|
83
|
+
);
|
|
85
84
|
|
|
86
85
|
if (isComponentExists && colors.length) {
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
vuelessConfigFiles,
|
|
90
|
-
isVuelessEnv,
|
|
91
|
-
});
|
|
86
|
+
const mergedConfig = await getMergedComponentConfig(componentName, vuelessConfigFiles);
|
|
87
|
+
const componentSafelist = await getComponentSafelist(mergedConfig, colors);
|
|
92
88
|
|
|
93
89
|
safelist.push(...componentSafelist);
|
|
94
90
|
}
|
|
95
91
|
|
|
96
92
|
if (isComponentExists && colors.length && nestedComponents.length) {
|
|
97
93
|
for await (const nestedComponent of nestedComponents) {
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
vuelessConfigFiles,
|
|
101
|
-
isVuelessEnv,
|
|
102
|
-
});
|
|
94
|
+
const mergedConfig = await getMergedComponentConfig(nestedComponent, vuelessConfigFiles);
|
|
95
|
+
const nestedComponentSafelist = await getComponentSafelist(mergedConfig, colors);
|
|
103
96
|
|
|
104
97
|
safelist.push(...nestedComponentSafelist);
|
|
105
98
|
}
|
|
@@ -113,19 +106,25 @@ export async function createTailwindSafelist({ mode, env, debug, targetFiles = [
|
|
|
113
106
|
console.log("VUELESS_SAFELIST", mergedSafelist);
|
|
114
107
|
}
|
|
115
108
|
|
|
109
|
+
const globalSettings = cloneDeep(vuelessConfig);
|
|
110
|
+
|
|
111
|
+
delete globalSettings.component;
|
|
112
|
+
delete globalSettings.directive;
|
|
113
|
+
delete globalSettings.tailwindMerge;
|
|
114
|
+
|
|
115
|
+
process.env.VUELESS_GLOBAL_SETTINGS = globalSettings;
|
|
116
116
|
process.env.VUELESS_SAFELIST = JSON.stringify(mergedSafelist);
|
|
117
|
-
process.env.VUELESS_STRATEGY = vuelessConfig.strategy || "";
|
|
118
117
|
}
|
|
119
118
|
|
|
120
119
|
function getSafelistClasses(config) {
|
|
121
120
|
const safelistItems = [];
|
|
122
121
|
|
|
123
122
|
for (const key in config) {
|
|
123
|
+
if (key === SYSTEM_CONFIG_KEY.defaults) continue;
|
|
124
|
+
|
|
124
125
|
if (Object.prototype.hasOwnProperty.call(config, key)) {
|
|
125
126
|
const classes = config[key];
|
|
126
127
|
|
|
127
|
-
if (key === SYSTEM_CONFIG_KEY.defaults) continue;
|
|
128
|
-
|
|
129
128
|
if (typeof classes === "object" && Array.isArray(classes)) {
|
|
130
129
|
safelistItems.push(...classes.map(getSafelistClasses));
|
|
131
130
|
}
|
|
@@ -164,47 +163,46 @@ function getSafelistItem(safelistClass, colorString) {
|
|
|
164
163
|
}
|
|
165
164
|
}
|
|
166
165
|
|
|
167
|
-
async function getComponentSafelist(
|
|
168
|
-
|
|
169
|
-
isDefaultComponentConfig(file, componentName),
|
|
170
|
-
);
|
|
171
|
-
const customConfig = vuelessConfig.component?.[componentName] || {};
|
|
172
|
-
let defaultConfig = {};
|
|
173
|
-
|
|
174
|
-
if (defaultConfigPath) {
|
|
175
|
-
const configPath = path.join(process.cwd(), defaultConfigPath);
|
|
166
|
+
async function getComponentSafelist(mergedConfig, colors) {
|
|
167
|
+
const colorString = `(${colors.join("|")})`;
|
|
176
168
|
|
|
177
|
-
|
|
178
|
-
|
|
169
|
+
return getSafelistClasses(mergedConfig).map((safelistClass) =>
|
|
170
|
+
getSafelistItem(safelistClass, colorString),
|
|
171
|
+
);
|
|
172
|
+
}
|
|
179
173
|
|
|
174
|
+
async function getMergedComponentConfig(componentName, vuelessConfigFiles) {
|
|
180
175
|
const isStrategyValid =
|
|
181
176
|
vuelessConfig.strategy && Object.values(STRATEGY_TYPE).includes(vuelessConfig.strategy);
|
|
182
177
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
globalConfig: customConfig,
|
|
188
|
-
vuelessStrategy,
|
|
178
|
+
return getMergedConfig({
|
|
179
|
+
defaultConfig: await retrieveComponentDefaultConfig(componentName, vuelessConfigFiles),
|
|
180
|
+
globalConfig: vuelessConfig.component?.[componentName] || {},
|
|
181
|
+
vuelessStrategy: isStrategyValid ? vuelessConfig.strategy : STRATEGY_TYPE.merge,
|
|
189
182
|
});
|
|
183
|
+
}
|
|
190
184
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
getSafelistItem(safelistClass, colorString),
|
|
185
|
+
async function retrieveComponentDefaultConfig(componentName, vuelessConfigFiles) {
|
|
186
|
+
const componentDefaultConfigPath = vuelessConfigFiles.find((file) =>
|
|
187
|
+
isDefaultComponentConfig(file, componentName),
|
|
195
188
|
);
|
|
189
|
+
|
|
190
|
+
return componentDefaultConfigPath
|
|
191
|
+
? await getComponentDefaultConfig(componentName, path.join(cwd, componentDefaultConfigPath))
|
|
192
|
+
: {};
|
|
196
193
|
}
|
|
197
194
|
|
|
198
|
-
async function findComponentColors(files,
|
|
195
|
+
async function findComponentColors(componentName, files, vuelessConfigFiles) {
|
|
199
196
|
const objectColorRegExp = new RegExp(/\bcolor\s*:\s*["']([^"'\s]+)["']/, "g");
|
|
200
197
|
const singleColorRegExp = new RegExp(/\bcolor\s*=\s*["']([^"'\s]+)["']/);
|
|
201
198
|
const ternaryColorRegExp = new RegExp(/\bcolor="[^']*'([^']*)'\s*:\s*'([^']*)'/);
|
|
202
199
|
|
|
203
|
-
const
|
|
200
|
+
const mergedComponentConfig = await getMergedComponentConfig(componentName, vuelessConfigFiles);
|
|
201
|
+
const defaultColor = mergedComponentConfig.defaults?.color || vuelessConfig.brand || "";
|
|
204
202
|
const colors = new Set();
|
|
205
203
|
|
|
206
|
-
if (
|
|
207
|
-
colors.add(
|
|
204
|
+
if (defaultColor && defaultColor !== "grayscale") {
|
|
205
|
+
colors.add(defaultColor);
|
|
208
206
|
}
|
|
209
207
|
|
|
210
208
|
getSafelistColorsFromConfig().forEach((color) => colors.add(color));
|
|
@@ -253,13 +251,6 @@ async function findComponentColors(files, componentName) {
|
|
|
253
251
|
};
|
|
254
252
|
}
|
|
255
253
|
|
|
256
|
-
function getComponentBrandColor(componentName) {
|
|
257
|
-
const globalBrandColor = vuelessConfig.brand || "";
|
|
258
|
-
const globalComponentConfig = vuelessConfig.component?.[componentName] || {};
|
|
259
|
-
|
|
260
|
-
return vuelessConfig.component ? globalComponentConfig.defaults?.color : globalBrandColor;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
254
|
function isDefaultComponentConfig(filePath, componentName) {
|
|
264
255
|
const componentDirName = filePath.split(path.sep).at(-2);
|
|
265
256
|
|