vueless 0.0.691 → 0.0.693
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/bin/constants.js +2 -2
- package/composables/useUI.ts +1 -1
- package/constants.js +294 -0
- package/directives/tooltip/vTooltip.ts +1 -1
- package/package.json +1 -1
- package/plugin-vite.js +1 -1
- package/preset-tailwind.js +6 -6
- package/types.ts +2 -2
- package/ui.button/storybook/stories.ts +3 -3
- package/ui.form-input/config.ts +1 -4
- package/ui.navigation-progress/UStepperProgress.vue +9 -7
- package/ui.text-notify/UNotify.vue +1 -1
- package/ui.text-notify/utilNotify.ts +1 -1
- package/utils/node/dynamicProps.js +2 -2
- package/utils/node/dynamicStories.js +1 -1
- package/utils/node/loaderIcon.js +2 -2
- package/utils/node/tailwindSafelist.js +4 -4
- package/utils/theme.ts +39 -24
- package/utils/ui.ts +1 -1
package/bin/constants.js
CHANGED
package/composables/useUI.ts
CHANGED
|
@@ -45,7 +45,7 @@ export default function useUI<T>(
|
|
|
45
45
|
? (parent?.type.__name as ComponentNames)
|
|
46
46
|
: (type.__name as ComponentNames);
|
|
47
47
|
|
|
48
|
-
const globalConfig = (vuelessConfig.
|
|
48
|
+
const globalConfig = (vuelessConfig.components?.[componentName] || {}) as ComponentConfigFull<T>;
|
|
49
49
|
|
|
50
50
|
const vuelessStrategy = Object.values(STRATEGY_TYPE).includes(vuelessConfig.strategy || "")
|
|
51
51
|
? (vuelessConfig.strategy as Strategies)
|
package/constants.js
CHANGED
|
@@ -22,6 +22,8 @@ export const DEFAULT_RING_OFFSET = 0; /* pixels */
|
|
|
22
22
|
export const DEFAULT_RING_OFFSET_COLOR_LIGHT = "#ffffff"; // white
|
|
23
23
|
export const DEFAULT_RING_OFFSET_COLOR_DARK = "#111827"; // gray-900
|
|
24
24
|
export const DEFAULT_ROUNDING = 8; /* pixels */
|
|
25
|
+
export const ROUNDING_DECREMENT = 4; /* pixels */
|
|
26
|
+
export const ROUNDING_INCREMENT = 6; /* pixels */
|
|
25
27
|
|
|
26
28
|
/* Vueless supported colors and shades */
|
|
27
29
|
export const COLOR_SHADES = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
|
|
@@ -237,3 +239,295 @@ export const TAILWIND_VARIANT_DELIMITER = ":";
|
|
|
237
239
|
export const TAILWIND_VARIANT_DELIMITER_REG_EXP = /:(?![^[]*])/;
|
|
238
240
|
export const JAVASCRIPT_EXT = ".js";
|
|
239
241
|
export const TYPESCRIPT_EXT = ".ts";
|
|
242
|
+
|
|
243
|
+
/* Default tailwind colors */
|
|
244
|
+
export const TAILWIND_COLORS = {
|
|
245
|
+
white: "#ffffff",
|
|
246
|
+
slate: {
|
|
247
|
+
50: "#f8fafc",
|
|
248
|
+
100: "#f1f5f9",
|
|
249
|
+
200: "#e2e8f0",
|
|
250
|
+
300: "#cbd5e1",
|
|
251
|
+
400: "#94a3b8",
|
|
252
|
+
500: "#64748b",
|
|
253
|
+
600: "#475569",
|
|
254
|
+
700: "#334155",
|
|
255
|
+
800: "#1e293b",
|
|
256
|
+
900: "#0f172a",
|
|
257
|
+
950: "#020617",
|
|
258
|
+
},
|
|
259
|
+
/* ex. `gray` color */
|
|
260
|
+
cool: {
|
|
261
|
+
50: "#f9fafb",
|
|
262
|
+
100: "#f3f4f6",
|
|
263
|
+
200: "#e5e7eb",
|
|
264
|
+
300: "#d1d5db",
|
|
265
|
+
400: "#9ca3af",
|
|
266
|
+
500: "#6b7280",
|
|
267
|
+
600: "#4b5563",
|
|
268
|
+
700: "#374151",
|
|
269
|
+
800: "#1f2937",
|
|
270
|
+
900: "#111827",
|
|
271
|
+
950: "#030712",
|
|
272
|
+
},
|
|
273
|
+
zinc: {
|
|
274
|
+
50: "#fafafa",
|
|
275
|
+
100: "#f4f4f5",
|
|
276
|
+
200: "#e4e4e7",
|
|
277
|
+
300: "#d4d4d8",
|
|
278
|
+
400: "#a1a1aa",
|
|
279
|
+
500: "#71717a",
|
|
280
|
+
600: "#52525b",
|
|
281
|
+
700: "#3f3f46",
|
|
282
|
+
800: "#27272a",
|
|
283
|
+
900: "#18181b",
|
|
284
|
+
950: "#09090b",
|
|
285
|
+
},
|
|
286
|
+
neutral: {
|
|
287
|
+
50: "#fafafa",
|
|
288
|
+
100: "#f5f5f5",
|
|
289
|
+
200: "#e5e5e5",
|
|
290
|
+
300: "#d4d4d4",
|
|
291
|
+
400: "#a3a3a3",
|
|
292
|
+
500: "#737373",
|
|
293
|
+
600: "#525252",
|
|
294
|
+
700: "#404040",
|
|
295
|
+
800: "#262626",
|
|
296
|
+
900: "#171717",
|
|
297
|
+
950: "#0a0a0a",
|
|
298
|
+
},
|
|
299
|
+
stone: {
|
|
300
|
+
50: "#fafaf9",
|
|
301
|
+
100: "#f5f5f4",
|
|
302
|
+
200: "#e7e5e4",
|
|
303
|
+
300: "#d6d3d1",
|
|
304
|
+
400: "#a8a29e",
|
|
305
|
+
500: "#78716c",
|
|
306
|
+
600: "#57534e",
|
|
307
|
+
700: "#44403c",
|
|
308
|
+
800: "#292524",
|
|
309
|
+
900: "#1c1917",
|
|
310
|
+
950: "#0c0a09",
|
|
311
|
+
},
|
|
312
|
+
red: {
|
|
313
|
+
50: "#fef2f2",
|
|
314
|
+
100: "#fee2e2",
|
|
315
|
+
200: "#fecaca",
|
|
316
|
+
300: "#fca5a5",
|
|
317
|
+
400: "#f87171",
|
|
318
|
+
500: "#ef4444",
|
|
319
|
+
600: "#dc2626",
|
|
320
|
+
700: "#b91c1c",
|
|
321
|
+
800: "#991b1b",
|
|
322
|
+
900: "#7f1d1d",
|
|
323
|
+
950: "#450a0a",
|
|
324
|
+
},
|
|
325
|
+
orange: {
|
|
326
|
+
50: "#fff7ed",
|
|
327
|
+
100: "#ffedd5",
|
|
328
|
+
200: "#fed7aa",
|
|
329
|
+
300: "#fdba74",
|
|
330
|
+
400: "#fb923c",
|
|
331
|
+
500: "#f97316",
|
|
332
|
+
600: "#ea580c",
|
|
333
|
+
700: "#c2410c",
|
|
334
|
+
800: "#9a3412",
|
|
335
|
+
900: "#7c2d12",
|
|
336
|
+
950: "#431407",
|
|
337
|
+
},
|
|
338
|
+
amber: {
|
|
339
|
+
50: "#fffbeb",
|
|
340
|
+
100: "#fef3c7",
|
|
341
|
+
200: "#fde68a",
|
|
342
|
+
300: "#fcd34d",
|
|
343
|
+
400: "#fbbf24",
|
|
344
|
+
500: "#f59e0b",
|
|
345
|
+
600: "#d97706",
|
|
346
|
+
700: "#b45309",
|
|
347
|
+
800: "#92400e",
|
|
348
|
+
900: "#78350f",
|
|
349
|
+
950: "#451a03",
|
|
350
|
+
},
|
|
351
|
+
yellow: {
|
|
352
|
+
50: "#fefce8",
|
|
353
|
+
100: "#fef9c3",
|
|
354
|
+
200: "#fef08a",
|
|
355
|
+
300: "#fde047",
|
|
356
|
+
400: "#facc15",
|
|
357
|
+
500: "#eab308",
|
|
358
|
+
600: "#ca8a04",
|
|
359
|
+
700: "#a16207",
|
|
360
|
+
800: "#854d0e",
|
|
361
|
+
900: "#713f12",
|
|
362
|
+
950: "#422006",
|
|
363
|
+
},
|
|
364
|
+
lime: {
|
|
365
|
+
50: "#f7fee7",
|
|
366
|
+
100: "#ecfccb",
|
|
367
|
+
200: "#d9f99d",
|
|
368
|
+
300: "#bef264",
|
|
369
|
+
400: "#a3e635",
|
|
370
|
+
500: "#84cc16",
|
|
371
|
+
600: "#65a30d",
|
|
372
|
+
700: "#4d7c0f",
|
|
373
|
+
800: "#3f6212",
|
|
374
|
+
900: "#365314",
|
|
375
|
+
950: "#1a2e05",
|
|
376
|
+
},
|
|
377
|
+
green: {
|
|
378
|
+
50: "#f0fdf4",
|
|
379
|
+
100: "#dcfce7",
|
|
380
|
+
200: "#bbf7d0",
|
|
381
|
+
300: "#86efac",
|
|
382
|
+
400: "#4ade80",
|
|
383
|
+
500: "#22c55e",
|
|
384
|
+
600: "#16a34a",
|
|
385
|
+
700: "#15803d",
|
|
386
|
+
800: "#166534",
|
|
387
|
+
900: "#14532d",
|
|
388
|
+
950: "#052e16",
|
|
389
|
+
},
|
|
390
|
+
emerald: {
|
|
391
|
+
50: "#ecfdf5",
|
|
392
|
+
100: "#d1fae5",
|
|
393
|
+
200: "#a7f3d0",
|
|
394
|
+
300: "#6ee7b7",
|
|
395
|
+
400: "#34d399",
|
|
396
|
+
500: "#10b981",
|
|
397
|
+
600: "#059669",
|
|
398
|
+
700: "#047857",
|
|
399
|
+
800: "#065f46",
|
|
400
|
+
900: "#064e3b",
|
|
401
|
+
950: "#022c22",
|
|
402
|
+
},
|
|
403
|
+
teal: {
|
|
404
|
+
50: "#f0fdfa",
|
|
405
|
+
100: "#ccfbf1",
|
|
406
|
+
200: "#99f6e4",
|
|
407
|
+
300: "#5eead4",
|
|
408
|
+
400: "#2dd4bf",
|
|
409
|
+
500: "#14b8a6",
|
|
410
|
+
600: "#0d9488",
|
|
411
|
+
700: "#0f766e",
|
|
412
|
+
800: "#115e59",
|
|
413
|
+
900: "#134e4a",
|
|
414
|
+
950: "#042f2e",
|
|
415
|
+
},
|
|
416
|
+
cyan: {
|
|
417
|
+
50: "#ecfeff",
|
|
418
|
+
100: "#cffafe",
|
|
419
|
+
200: "#a5f3fc",
|
|
420
|
+
300: "#67e8f9",
|
|
421
|
+
400: "#22d3ee",
|
|
422
|
+
500: "#06b6d4",
|
|
423
|
+
600: "#0891b2",
|
|
424
|
+
700: "#0e7490",
|
|
425
|
+
800: "#155e75",
|
|
426
|
+
900: "#164e63",
|
|
427
|
+
950: "#083344",
|
|
428
|
+
},
|
|
429
|
+
sky: {
|
|
430
|
+
50: "#f0f9ff",
|
|
431
|
+
100: "#e0f2fe",
|
|
432
|
+
200: "#bae6fd",
|
|
433
|
+
300: "#7dd3fc",
|
|
434
|
+
400: "#38bdf8",
|
|
435
|
+
500: "#0ea5e9",
|
|
436
|
+
600: "#0284c7",
|
|
437
|
+
700: "#0369a1",
|
|
438
|
+
800: "#075985",
|
|
439
|
+
900: "#0c4a6e",
|
|
440
|
+
950: "#082f49",
|
|
441
|
+
},
|
|
442
|
+
blue: {
|
|
443
|
+
50: "#eff6ff",
|
|
444
|
+
100: "#dbeafe",
|
|
445
|
+
200: "#bfdbfe",
|
|
446
|
+
300: "#93c5fd",
|
|
447
|
+
400: "#60a5fa",
|
|
448
|
+
500: "#3b82f6",
|
|
449
|
+
600: "#2563eb",
|
|
450
|
+
700: "#1d4ed8",
|
|
451
|
+
800: "#1e40af",
|
|
452
|
+
900: "#1e3a8a",
|
|
453
|
+
950: "#172554",
|
|
454
|
+
},
|
|
455
|
+
indigo: {
|
|
456
|
+
50: "#eef2ff",
|
|
457
|
+
100: "#e0e7ff",
|
|
458
|
+
200: "#c7d2fe",
|
|
459
|
+
300: "#a5b4fc",
|
|
460
|
+
400: "#818cf8",
|
|
461
|
+
500: "#6366f1",
|
|
462
|
+
600: "#4f46e5",
|
|
463
|
+
700: "#4338ca",
|
|
464
|
+
800: "#3730a3",
|
|
465
|
+
900: "#312e81",
|
|
466
|
+
950: "#1e1b4b",
|
|
467
|
+
},
|
|
468
|
+
violet: {
|
|
469
|
+
50: "#f5f3ff",
|
|
470
|
+
100: "#ede9fe",
|
|
471
|
+
200: "#ddd6fe",
|
|
472
|
+
300: "#c4b5fd",
|
|
473
|
+
400: "#a78bfa",
|
|
474
|
+
500: "#8b5cf6",
|
|
475
|
+
600: "#7c3aed",
|
|
476
|
+
700: "#6d28d9",
|
|
477
|
+
800: "#5b21b6",
|
|
478
|
+
900: "#4c1d95",
|
|
479
|
+
950: "#2e1065",
|
|
480
|
+
},
|
|
481
|
+
purple: {
|
|
482
|
+
50: "#faf5ff",
|
|
483
|
+
100: "#f3e8ff",
|
|
484
|
+
200: "#e9d5ff",
|
|
485
|
+
300: "#d8b4fe",
|
|
486
|
+
400: "#c084fc",
|
|
487
|
+
500: "#a855f7",
|
|
488
|
+
600: "#9333ea",
|
|
489
|
+
700: "#7e22ce",
|
|
490
|
+
800: "#6b21a8",
|
|
491
|
+
900: "#581c87",
|
|
492
|
+
950: "#3b0764",
|
|
493
|
+
},
|
|
494
|
+
fuchsia: {
|
|
495
|
+
50: "#fdf4ff",
|
|
496
|
+
100: "#fae8ff",
|
|
497
|
+
200: "#f5d0fe",
|
|
498
|
+
300: "#f0abfc",
|
|
499
|
+
400: "#e879f9",
|
|
500
|
+
500: "#d946ef",
|
|
501
|
+
600: "#c026d3",
|
|
502
|
+
700: "#a21caf",
|
|
503
|
+
800: "#86198f",
|
|
504
|
+
900: "#701a75",
|
|
505
|
+
950: "#4a044e",
|
|
506
|
+
},
|
|
507
|
+
pink: {
|
|
508
|
+
50: "#fdf2f8",
|
|
509
|
+
100: "#fce7f3",
|
|
510
|
+
200: "#fbcfe8",
|
|
511
|
+
300: "#f9a8d4",
|
|
512
|
+
400: "#f472b6",
|
|
513
|
+
500: "#ec4899",
|
|
514
|
+
600: "#db2777",
|
|
515
|
+
700: "#be185d",
|
|
516
|
+
800: "#9d174d",
|
|
517
|
+
900: "#831843",
|
|
518
|
+
950: "#500724",
|
|
519
|
+
},
|
|
520
|
+
rose: {
|
|
521
|
+
50: "#fff1f2",
|
|
522
|
+
100: "#ffe4e6",
|
|
523
|
+
200: "#fecdd3",
|
|
524
|
+
300: "#fda4af",
|
|
525
|
+
400: "#fb7185",
|
|
526
|
+
500: "#f43f5e",
|
|
527
|
+
600: "#e11d48",
|
|
528
|
+
700: "#be123c",
|
|
529
|
+
800: "#9f1239",
|
|
530
|
+
900: "#881337",
|
|
531
|
+
950: "#4c0519",
|
|
532
|
+
},
|
|
533
|
+
};
|
|
@@ -24,7 +24,7 @@ if (isCSR) {
|
|
|
24
24
|
animation: "shift-away",
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
settings = merge(defaultSettings, vuelessConfig.
|
|
27
|
+
settings = merge(defaultSettings, vuelessConfig.directives?.tooltip || {}) as DefaultProps;
|
|
28
28
|
tippy.setDefaultProps(settings);
|
|
29
29
|
}
|
|
30
30
|
|
package/package.json
CHANGED
package/plugin-vite.js
CHANGED
|
@@ -62,7 +62,7 @@ export const Vueless = function (options = {}) {
|
|
|
62
62
|
"process.env": {},
|
|
63
63
|
},
|
|
64
64
|
optimizeDeps: {
|
|
65
|
-
include: [
|
|
65
|
+
include: [...(!isVuelessEnv ? ["vueless/preset-tailwind"] : [])],
|
|
66
66
|
},
|
|
67
67
|
}),
|
|
68
68
|
|
package/preset-tailwind.js
CHANGED
|
@@ -4,13 +4,13 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { merge } from "lodash-es";
|
|
6
6
|
import forms from "@tailwindcss/forms";
|
|
7
|
-
import colors from "tailwindcss/colors.js";
|
|
8
7
|
import {
|
|
9
8
|
COLOR_SHADES,
|
|
10
9
|
BRAND_COLOR,
|
|
11
10
|
GRAY_COLOR,
|
|
12
11
|
COOL_COLOR,
|
|
13
12
|
DARK_MODE_SELECTOR,
|
|
13
|
+
TAILWIND_COLORS,
|
|
14
14
|
DEFAULT_ROUNDING,
|
|
15
15
|
DEFAULT_RING,
|
|
16
16
|
DEFAULT_RING_OFFSET,
|
|
@@ -74,7 +74,6 @@ export const vuelessTailwindConfig = {
|
|
|
74
74
|
colors: {
|
|
75
75
|
[BRAND_COLOR]: brandColors || {},
|
|
76
76
|
[GRAY_COLOR]: grayColors || {},
|
|
77
|
-
[COOL_COLOR]: { ...(colors[GRAY_COLOR] || {}) },
|
|
78
77
|
},
|
|
79
78
|
spacing: {
|
|
80
79
|
"safe-top": "env(safe-area-inset-top)",
|
|
@@ -176,16 +175,17 @@ function getPalette(color) {
|
|
|
176
175
|
* @returns { Object } - `tailwind-config-viewer` color replacement object.
|
|
177
176
|
*/
|
|
178
177
|
function getReplacementColors(color, tailwindColor) {
|
|
179
|
-
if (tailwindColor === GRAYSCALE_COLOR
|
|
180
|
-
tailwindColor =
|
|
178
|
+
if (tailwindColor === GRAYSCALE_COLOR) {
|
|
179
|
+
tailwindColor = COOL_COLOR;
|
|
181
180
|
}
|
|
182
181
|
|
|
183
182
|
const varsPalette = {
|
|
184
|
-
[twColorWithOpacity(`--vl-color-${color}-default`)]:
|
|
183
|
+
[twColorWithOpacity(`--vl-color-${color}-default`)]: TAILWIND_COLORS[tailwindColor][600],
|
|
185
184
|
};
|
|
186
185
|
|
|
187
186
|
COLOR_SHADES.forEach((shade) => {
|
|
188
|
-
varsPalette[twColorWithOpacity(`--vl-color-${color}-${shade}`)] =
|
|
187
|
+
varsPalette[twColorWithOpacity(`--vl-color-${color}-${shade}`)] =
|
|
188
|
+
TAILWIND_COLORS[tailwindColor][shade];
|
|
189
189
|
});
|
|
190
190
|
|
|
191
191
|
return varsPalette;
|
package/types.ts
CHANGED
|
@@ -133,12 +133,12 @@ export interface Config extends ThemeConfig {
|
|
|
133
133
|
/**
|
|
134
134
|
* Component configs.
|
|
135
135
|
*/
|
|
136
|
-
|
|
136
|
+
components?: Partial<Components>;
|
|
137
137
|
|
|
138
138
|
/**
|
|
139
139
|
* Directive configs.
|
|
140
140
|
*/
|
|
141
|
-
|
|
141
|
+
directives?: Partial<Directives>;
|
|
142
142
|
|
|
143
143
|
/**
|
|
144
144
|
* Tailwind CSS theme config.
|
|
@@ -199,7 +199,7 @@ export const Slots: StoryFn<UButtonArgs> = (args) => ({
|
|
|
199
199
|
<UIcon
|
|
200
200
|
name="heart_plus"
|
|
201
201
|
size="sm"
|
|
202
|
-
color="
|
|
202
|
+
color="inherit"
|
|
203
203
|
:variant="isDarkMode ? 'dark' : 'default'"
|
|
204
204
|
/>
|
|
205
205
|
</template>
|
|
@@ -210,7 +210,7 @@ export const Slots: StoryFn<UButtonArgs> = (args) => ({
|
|
|
210
210
|
<UIcon
|
|
211
211
|
name="settings"
|
|
212
212
|
size="sm"
|
|
213
|
-
color="
|
|
213
|
+
color="inherit"
|
|
214
214
|
:variant="isDarkMode ? 'dark' : 'default'"
|
|
215
215
|
/>
|
|
216
216
|
</template>
|
|
@@ -221,7 +221,7 @@ export const Slots: StoryFn<UButtonArgs> = (args) => ({
|
|
|
221
221
|
<UIcon
|
|
222
222
|
name="delete"
|
|
223
223
|
size="sm"
|
|
224
|
-
color="
|
|
224
|
+
color="inherit"
|
|
225
225
|
:variant="isDarkMode ? 'dark' : 'default'"
|
|
226
226
|
/>
|
|
227
227
|
</template>
|
package/ui.form-input/config.ts
CHANGED
|
@@ -2,14 +2,11 @@ export default /*tw*/ {
|
|
|
2
2
|
inputLabel: "{ULabel}",
|
|
3
3
|
wrapper: {
|
|
4
4
|
base: `
|
|
5
|
-
w-full bg-white relative flex border border-gray-300 rounded-dynamic
|
|
5
|
+
w-full bg-white relative flex border border-gray-300 rounded-dynamic transition
|
|
6
6
|
hover:border-gray-400 hover:focus-within:border-brand-500 focus-within:border-brand-500
|
|
7
7
|
focus-within:ring-dynamic focus-within:ring-offset-dynamic focus-within:ring-brand-700/15
|
|
8
8
|
`,
|
|
9
9
|
variants: {
|
|
10
|
-
labelAlign: {
|
|
11
|
-
topInside: "rounded-dynamic",
|
|
12
|
-
},
|
|
13
10
|
error: {
|
|
14
11
|
true: `
|
|
15
12
|
border-red-300 bg-red-50
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import { computed } from "vue";
|
|
3
|
-
import colors from "tailwindcss/colors.js";
|
|
4
3
|
|
|
5
4
|
import useUI from "../composables/useUI.ts";
|
|
6
5
|
|
|
7
6
|
import defaultConfig from "./config.ts";
|
|
8
|
-
import { GRAY_COLORS } from "../constants.js";
|
|
7
|
+
import { GRAY_COLORS, TAILWIND_COLORS } from "../constants.js";
|
|
9
8
|
|
|
10
9
|
import type { StepperProgressProps, Config } from "./types.ts";
|
|
11
10
|
|
|
@@ -16,18 +15,21 @@ const props = withDefaults(defineProps<StepperProgressProps>(), {
|
|
|
16
15
|
});
|
|
17
16
|
|
|
18
17
|
const stepperColor = computed(() => {
|
|
19
|
-
const isValidColor = (color: string): color is keyof typeof
|
|
20
|
-
|
|
18
|
+
const isValidColor = (color: string): color is keyof typeof TAILWIND_COLORS =>
|
|
19
|
+
color in TAILWIND_COLORS;
|
|
20
|
+
|
|
21
|
+
const isGrayColor = (color: string): color is keyof typeof TAILWIND_COLORS =>
|
|
22
|
+
GRAY_COLORS.includes(color);
|
|
21
23
|
|
|
22
24
|
if (isValidColor(props.color)) {
|
|
23
|
-
return
|
|
25
|
+
return TAILWIND_COLORS[props.color][500];
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
if (isGrayColor(props.color)) {
|
|
27
|
-
return
|
|
29
|
+
return TAILWIND_COLORS[props.color][900];
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
return
|
|
32
|
+
return TAILWIND_COLORS.cool[900];
|
|
31
33
|
});
|
|
32
34
|
|
|
33
35
|
/**
|
|
@@ -72,7 +72,7 @@ function getOffsetWidth(selector: string): number {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
function setPosition() {
|
|
75
|
-
const positionClasses = vuelessConfig.
|
|
75
|
+
const positionClasses = vuelessConfig.components?.UNotify?.positionClasses;
|
|
76
76
|
const pageClass = positionClasses?.page || config.value?.positionClasses?.page;
|
|
77
77
|
const asideClass = positionClasses?.aside || config.value?.positionClasses?.aside;
|
|
78
78
|
const pageWidth = getOffsetWidth(`${pageClass}`);
|
|
@@ -31,7 +31,7 @@ interface VuelessNotifyConfig {
|
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
const globalNotifyDuration = (vuelessConfig.
|
|
34
|
+
const globalNotifyDuration = (vuelessConfig.components?.UNotify as VuelessNotifyConfig)?.duration;
|
|
35
35
|
const notifyClearAllEvent: Event = new Event("notifyClearAll");
|
|
36
36
|
|
|
37
37
|
let lastMessageTime: Date | undefined = undefined;
|
|
@@ -19,7 +19,7 @@ export async function setCustomPropTypes(isVuelessEnv) {
|
|
|
19
19
|
const srcDir = isVuelessEnv ? VUELESS_LOCAL_DIR : VUELESS_DIR;
|
|
20
20
|
|
|
21
21
|
for await (const [componentName, componentDir] of Object.entries(COMPONENTS)) {
|
|
22
|
-
const componentGlobalConfig = vuelessConfig.
|
|
22
|
+
const componentGlobalConfig = vuelessConfig.components?.[componentName];
|
|
23
23
|
const customProps = componentGlobalConfig && componentGlobalConfig.props;
|
|
24
24
|
const isHiddenStories = componentGlobalConfig && componentGlobalConfig.storybook === false;
|
|
25
25
|
|
|
@@ -27,7 +27,7 @@ export async function setCustomPropTypes(isVuelessEnv) {
|
|
|
27
27
|
await cacheComponentTypes(path.join(srcDir, componentDir));
|
|
28
28
|
await modifyComponentTypes(
|
|
29
29
|
path.join(srcDir, componentDir),
|
|
30
|
-
vuelessConfig.
|
|
30
|
+
vuelessConfig.components?.[componentName]?.props,
|
|
31
31
|
);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -47,7 +47,7 @@ export async function hideHiddenStories(isVuelessEnv) {
|
|
|
47
47
|
const srcDir = isVuelessEnv ? VUELESS_LOCAL_DIR : VUELESS_DIR;
|
|
48
48
|
|
|
49
49
|
for await (const [componentName, componentDir] of Object.entries(COMPONENTS)) {
|
|
50
|
-
const componentGlobalConfig = vuelessConfig.
|
|
50
|
+
const componentGlobalConfig = vuelessConfig.components?.[componentName];
|
|
51
51
|
const isHiddenStories = componentGlobalConfig && componentGlobalConfig.storybook === false;
|
|
52
52
|
|
|
53
53
|
if (isHiddenStories) {
|
package/utils/node/loaderIcon.js
CHANGED
|
@@ -146,7 +146,7 @@ async function copyCachedVuelessIcons(isVuelessEnv) {
|
|
|
146
146
|
*/
|
|
147
147
|
async function findAndCopyIcons(files) {
|
|
148
148
|
const defaults = await getDefaults();
|
|
149
|
-
const safelistIcons = vuelessConfig.
|
|
149
|
+
const safelistIcons = vuelessConfig.components?.[U_ICON]?.safelistIcons;
|
|
150
150
|
|
|
151
151
|
safelistIcons?.forEach((iconName) => {
|
|
152
152
|
copyIcon(iconName, defaults);
|
|
@@ -312,5 +312,5 @@ async function getDefaults() {
|
|
|
312
312
|
const defaultConfigPath = path.join(cwd(), defaultIconsDir, COMPONENTS[U_ICON], "config.ts");
|
|
313
313
|
const uIconDefaultConfig = await getComponentDefaultConfig(U_ICON, defaultConfigPath);
|
|
314
314
|
|
|
315
|
-
return merge({}, uIconDefaultConfig?.defaults, vuelessConfig.
|
|
315
|
+
return merge({}, uIconDefaultConfig?.defaults, vuelessConfig.components?.[U_ICON]?.defaults);
|
|
316
316
|
}
|
|
@@ -107,8 +107,8 @@ export async function createTailwindSafelist({ mode, env, debug, targetFiles = [
|
|
|
107
107
|
|
|
108
108
|
const globalSettings = cloneDeep(vuelessConfig);
|
|
109
109
|
|
|
110
|
-
delete globalSettings.
|
|
111
|
-
delete globalSettings.
|
|
110
|
+
delete globalSettings.components;
|
|
111
|
+
delete globalSettings.directives;
|
|
112
112
|
delete globalSettings.tailwindMerge;
|
|
113
113
|
|
|
114
114
|
process.env.VUELESS_GLOBAL_SETTINGS = globalSettings;
|
|
@@ -176,7 +176,7 @@ async function getMergedComponentConfig(componentName, vuelessConfigFiles) {
|
|
|
176
176
|
|
|
177
177
|
return getMergedConfig({
|
|
178
178
|
defaultConfig: await retrieveComponentDefaultConfig(componentName, vuelessConfigFiles),
|
|
179
|
-
globalConfig: vuelessConfig.
|
|
179
|
+
globalConfig: vuelessConfig.components?.[componentName] || {},
|
|
180
180
|
vuelessStrategy: isStrategyValid ? vuelessConfig.strategy : STRATEGY_TYPE.merge,
|
|
181
181
|
});
|
|
182
182
|
}
|
|
@@ -271,7 +271,7 @@ function isDefaultComponentConfig(filePath, componentName) {
|
|
|
271
271
|
|
|
272
272
|
function getSafelistColorsFromConfig(componentName) {
|
|
273
273
|
const globalSafelistColors = vuelessConfig.safelistColors || [];
|
|
274
|
-
const componentSafelistColors = vuelessConfig.
|
|
274
|
+
const componentSafelistColors = vuelessConfig.components?.[componentName]?.safelistColors || [];
|
|
275
275
|
|
|
276
276
|
return [...globalSafelistColors, ...componentSafelistColors];
|
|
277
277
|
}
|
package/utils/theme.ts
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import { merge } from "lodash-es";
|
|
2
|
-
import tailwindColors from "tailwindcss/colors.js";
|
|
3
2
|
|
|
4
3
|
import { tailwindConfig } from "./tailwindConfig.ts";
|
|
5
4
|
import { vuelessConfig } from "./ui.ts";
|
|
6
5
|
import { isSSR, isCSR } from "./helper.ts";
|
|
7
6
|
import {
|
|
8
7
|
PX_IN_REM,
|
|
9
|
-
COOL_COLOR,
|
|
10
|
-
GRAY_COLOR,
|
|
11
8
|
COLOR_MODE_KEY,
|
|
12
9
|
LIGHT_MODE_SELECTOR,
|
|
13
10
|
DARK_MODE_SELECTOR,
|
|
14
11
|
GRAYSCALE_COLOR,
|
|
12
|
+
TAILWIND_COLORS,
|
|
15
13
|
DEFAULT_RING,
|
|
16
14
|
DEFAULT_RING_OFFSET,
|
|
17
15
|
DEFAULT_ROUNDING,
|
|
@@ -19,6 +17,8 @@ import {
|
|
|
19
17
|
DEFAULT_GRAY_COLOR,
|
|
20
18
|
DEFAULT_RING_OFFSET_COLOR_LIGHT,
|
|
21
19
|
DEFAULT_RING_OFFSET_COLOR_DARK,
|
|
20
|
+
ROUNDING_DECREMENT,
|
|
21
|
+
ROUNDING_INCREMENT,
|
|
22
22
|
} from "../constants.js";
|
|
23
23
|
|
|
24
24
|
import type {
|
|
@@ -31,7 +31,7 @@ import type {
|
|
|
31
31
|
|
|
32
32
|
import { ColorMode } from "../types.ts";
|
|
33
33
|
|
|
34
|
-
type DefaultColors = typeof
|
|
34
|
+
type DefaultColors = typeof TAILWIND_COLORS;
|
|
35
35
|
|
|
36
36
|
interface Colors extends DefaultColors {
|
|
37
37
|
[key: string]: Partial<TailwindColorShades> | string;
|
|
@@ -110,15 +110,16 @@ export function getSelectedGrayColor() {
|
|
|
110
110
|
export function setTheme(config: Config = {}) {
|
|
111
111
|
setColorMode(vuelessConfig.colorMode || config.colorMode || ColorMode.Light);
|
|
112
112
|
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
113
|
+
const { roundingSm, rounding, roundingLg } = getRoundings(
|
|
114
|
+
config.roundingSm ?? vuelessConfig.roundingSm,
|
|
115
|
+
config.rounding ?? vuelessConfig.rounding,
|
|
116
|
+
config.roundingLg ?? vuelessConfig.roundingLg,
|
|
117
|
+
);
|
|
117
118
|
|
|
118
119
|
let brand: BrandColors =
|
|
119
120
|
config.brand ?? getSelectedBrandColor() ?? vuelessConfig.brand ?? DEFAULT_BRAND_COLOR;
|
|
120
121
|
|
|
121
|
-
|
|
122
|
+
const gray: GrayColors =
|
|
122
123
|
config.gray ?? getSelectedGrayColor() ?? vuelessConfig.gray ?? DEFAULT_GRAY_COLOR;
|
|
123
124
|
|
|
124
125
|
const ring = config.ring ?? vuelessConfig.ring ?? DEFAULT_RING;
|
|
@@ -134,30 +135,20 @@ export function setTheme(config: Config = {}) {
|
|
|
134
135
|
vuelessConfig.ringOffsetColorLight ??
|
|
135
136
|
DEFAULT_RING_OFFSET_COLOR_LIGHT;
|
|
136
137
|
|
|
138
|
+
const isDarkMode = isCSR && document.documentElement.classList.contains(DARK_MODE_SELECTOR);
|
|
139
|
+
const defaultRingOffsetColor = isDarkMode ? ringOffsetColorDark : ringOffsetColorLight;
|
|
137
140
|
const defaultBrandShade = isDarkMode ? 400 : 600;
|
|
138
141
|
const defaultGrayShade = isDarkMode ? 400 : 600;
|
|
139
|
-
const defaultRingOffsetColor = isDarkMode ? ringOffsetColorDark : ringOffsetColorLight;
|
|
140
142
|
|
|
141
143
|
isCSR && localStorage.setItem("brand", brand);
|
|
142
144
|
isCSR && localStorage.setItem("gray", gray);
|
|
143
145
|
|
|
144
|
-
if (gray === COOL_COLOR) {
|
|
145
|
-
gray = GRAY_COLOR;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
146
|
if (brand === GRAYSCALE_COLOR) {
|
|
149
147
|
brand = gray;
|
|
150
148
|
}
|
|
151
149
|
|
|
152
|
-
/* Remove deprecated color aliases. */
|
|
153
|
-
delete (tailwindColors as Partial<DefaultColors>).lightBlue;
|
|
154
|
-
delete (tailwindColors as Partial<DefaultColors>).warmGray;
|
|
155
|
-
delete (tailwindColors as Partial<DefaultColors>).trueGray;
|
|
156
|
-
delete (tailwindColors as Partial<DefaultColors>).coolGray;
|
|
157
|
-
delete (tailwindColors as Partial<DefaultColors>).blueGray;
|
|
158
|
-
|
|
159
150
|
const colors: Colors = merge(
|
|
160
|
-
|
|
151
|
+
TAILWIND_COLORS as Colors,
|
|
161
152
|
tailwindConfig?.theme?.extend?.colors || {},
|
|
162
153
|
vuelessConfig.tailwindTheme?.extend?.colors || {},
|
|
163
154
|
);
|
|
@@ -180,8 +171,8 @@ export function setTheme(config: Config = {}) {
|
|
|
180
171
|
"--vl-rounding-sm": `${Number(roundingSm) / PX_IN_REM}rem`,
|
|
181
172
|
"--vl-rounding": `${Number(rounding) / PX_IN_REM}rem`,
|
|
182
173
|
"--vl-rounding-lg": `${Number(roundingLg) / PX_IN_REM}rem`,
|
|
183
|
-
"--vl-ring": `${ring}px`,
|
|
184
|
-
"--vl-ring-offset": `${ringOffset}px`,
|
|
174
|
+
"--vl-ring": `${Math.max(0, ring)}px`,
|
|
175
|
+
"--vl-ring-offset": `${Math.max(0, ringOffset)}px`,
|
|
185
176
|
"--vl-ring-offset-color": convertHexInRgb(defaultRingOffsetColor),
|
|
186
177
|
"--vl-color-gray-default": convertHexInRgb(colors[gray]?.[defaultBrandShade]),
|
|
187
178
|
"--vl-color-brand-default": convertHexInRgb(colors[brand]?.[defaultGrayShade]),
|
|
@@ -240,3 +231,27 @@ export function convertHexInRgb(hex?: string) {
|
|
|
240
231
|
|
|
241
232
|
return color.length === 6 || color.length === 3 ? `${r}, ${g}, ${b}` : "";
|
|
242
233
|
}
|
|
234
|
+
|
|
235
|
+
function getRoundings(sm?: number, md?: number, lg?: number) {
|
|
236
|
+
const rounding = Math.max(0, md ?? DEFAULT_ROUNDING);
|
|
237
|
+
let roundingSm = Math.max(0, rounding - ROUNDING_DECREMENT);
|
|
238
|
+
let roundingLg = Math.max(0, rounding + ROUNDING_INCREMENT);
|
|
239
|
+
|
|
240
|
+
if (rounding === ROUNDING_INCREMENT) {
|
|
241
|
+
roundingSm = ROUNDING_DECREMENT;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (rounding === ROUNDING_DECREMENT) {
|
|
245
|
+
roundingSm = ROUNDING_INCREMENT - ROUNDING_DECREMENT;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if (rounding === 0) {
|
|
249
|
+
roundingLg = ROUNDING_INCREMENT - ROUNDING_DECREMENT;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
return {
|
|
253
|
+
rounding,
|
|
254
|
+
roundingSm: sm === undefined ? roundingSm : Math.max(0, sm),
|
|
255
|
+
roundingLg: lg === undefined ? roundingLg : Math.max(0, lg),
|
|
256
|
+
};
|
|
257
|
+
}
|
package/utils/ui.ts
CHANGED
|
@@ -99,7 +99,7 @@ export const cva = ({ base = "", variants = {}, compoundVariants = [], defaultVa
|
|
|
99
99
|
*/
|
|
100
100
|
export function getDefaults<Props, Config>(defaultConfig: Config, name: ComponentNames) {
|
|
101
101
|
const componentDefaults = (defaultConfig as UnknownObject).defaults || {};
|
|
102
|
-
const globalDefaults = vuelessConfig.
|
|
102
|
+
const globalDefaults = vuelessConfig.components?.[name]?.defaults || {};
|
|
103
103
|
|
|
104
104
|
const defaults = merge({}, componentDefaults, globalDefaults) as Props & Defaults;
|
|
105
105
|
|