vueless 1.2.8-beta.0 → 1.2.8-beta.10
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/constants.d.ts +3 -0
- package/constants.js +3 -0
- package/icons/storybook/rocket_launch.svg +1 -0
- package/package.json +1 -1
- package/ui.container-accordion/UAccordion.vue +0 -1
- package/ui.container-accordion/config.ts +1 -1
- package/ui.container-accordion/storybook/stories.ts +13 -1
- package/ui.container-accordion-item/UAccordionItem.vue +17 -4
- package/ui.container-accordion-item/config.ts +1 -1
- package/ui.container-accordion-item/storybook/stories.ts +26 -1
- package/ui.container-accordion-item/tests/UAccordionItem.test.ts +186 -0
- package/ui.dropdown-badge/UDropdownBadge.vue +51 -2
- package/ui.dropdown-badge/config.ts +5 -1
- package/ui.dropdown-badge/storybook/stories.ts +280 -4
- package/ui.dropdown-badge/tests/UDropdownBadge.test.ts +194 -0
- package/ui.dropdown-badge/types.ts +30 -0
- package/ui.dropdown-button/UDropdownButton.vue +51 -2
- package/ui.dropdown-button/config.ts +5 -1
- package/ui.dropdown-button/storybook/stories.ts +288 -3
- package/ui.dropdown-button/tests/UDropdownButton.test.ts +190 -0
- package/ui.dropdown-button/types.ts +30 -0
- package/ui.dropdown-link/UDropdownLink.vue +51 -2
- package/ui.dropdown-link/config.ts +5 -1
- package/ui.dropdown-link/storybook/stories.ts +281 -4
- package/ui.dropdown-link/tests/UDropdownLink.test.ts +194 -0
- package/ui.dropdown-link/types.ts +30 -0
- package/ui.form-checkbox/tests/UCheckbox.test.ts +2 -2
- package/ui.form-checkbox-group/tests/UCheckboxGroup.test.ts +2 -2
- package/ui.form-input/UInput.vue +4 -2
- package/ui.form-input/tests/UInput.test.ts +2 -2
- package/ui.form-input-counter/UInputCounter.vue +25 -1
- package/ui.form-input-counter/config.ts +7 -2
- package/ui.form-input-counter/tests/UInputCounter.test.ts +85 -1
- package/ui.form-input-counter/types.ts +25 -0
- package/ui.form-input-file/tests/UInputFile.test.ts +2 -2
- package/ui.form-input-number/UInputNumber.vue +15 -3
- package/ui.form-input-number/utilFormat.ts +17 -7
- package/ui.form-input-password/UInputPassword.vue +23 -1
- package/ui.form-label/ULabel.vue +10 -4
- package/ui.form-label/tests/ULabel.test.ts +29 -12
- package/ui.form-listbox/UListbox.vue +21 -5
- package/ui.form-listbox/storybook/stories.ts +188 -1
- package/ui.form-listbox/tests/UListbox.test.ts +36 -0
- package/ui.form-listbox/types.ts +5 -0
- package/ui.form-radio/tests/URadio.test.ts +2 -2
- package/ui.form-radio-group/tests/URadioGroup.test.ts +2 -2
- package/ui.form-select/USelect.vue +19 -2
- package/ui.form-select/config.ts +1 -0
- package/ui.form-select/storybook/stories.ts +31 -4
- package/ui.form-select/tests/USelect.test.ts +143 -0
- package/ui.form-select/types.ts +10 -0
- package/ui.form-textarea/tests/UTextarea.test.ts +2 -2
- package/utils/theme.ts +61 -5
package/utils/theme.ts
CHANGED
|
@@ -35,6 +35,8 @@ import {
|
|
|
35
35
|
DEFAULT_DISABLED_OPACITY,
|
|
36
36
|
LETTER_SPACING,
|
|
37
37
|
DEFAULT_LETTER_SPACING,
|
|
38
|
+
LIGHT_THEME,
|
|
39
|
+
DARK_THEME,
|
|
38
40
|
} from "../constants";
|
|
39
41
|
|
|
40
42
|
import type {
|
|
@@ -191,6 +193,8 @@ export function resetTheme() {
|
|
|
191
193
|
`vl-${ROUNDING}-lg`,
|
|
192
194
|
`vl-${LETTER_SPACING}`,
|
|
193
195
|
`vl-${DISABLED_OPACITY}`,
|
|
196
|
+
`vl-${LIGHT_THEME}`,
|
|
197
|
+
`vl-${DARK_THEME}`,
|
|
194
198
|
];
|
|
195
199
|
|
|
196
200
|
themeKeys.forEach((key) => {
|
|
@@ -217,8 +221,8 @@ export function getTheme(config?: ThemeConfig): MergedThemeConfig {
|
|
|
217
221
|
const letterSpacing = getLetterSpacing(config?.letterSpacing);
|
|
218
222
|
const disabledOpacity = getDisabledOpacity(config?.disabledOpacity);
|
|
219
223
|
|
|
220
|
-
const lightTheme =
|
|
221
|
-
const darkTheme =
|
|
224
|
+
const lightTheme = getLightTheme(config?.lightTheme);
|
|
225
|
+
const darkTheme = getDarkTheme(config?.darkTheme);
|
|
222
226
|
|
|
223
227
|
return {
|
|
224
228
|
colorMode,
|
|
@@ -254,8 +258,8 @@ export function setTheme(config: ThemeConfig = {}) {
|
|
|
254
258
|
let primary = getPrimaryColor(config.primary);
|
|
255
259
|
const neutral = getNeutralColor(config.neutral);
|
|
256
260
|
|
|
257
|
-
const lightTheme =
|
|
258
|
-
const darkTheme =
|
|
261
|
+
const lightTheme = getLightTheme(config.lightTheme);
|
|
262
|
+
const darkTheme = getDarkTheme(config.darkTheme);
|
|
259
263
|
|
|
260
264
|
/* Redeclare primary color if grayscale color set as default */
|
|
261
265
|
if (primary === GRAYSCALE_COLOR) {
|
|
@@ -608,7 +612,7 @@ function getLetterSpacing(letterSpacing?: ThemeConfig["letterSpacing"]) {
|
|
|
608
612
|
const storageKey = `vl-${LETTER_SPACING}`;
|
|
609
613
|
|
|
610
614
|
const spacing = letterSpacing ?? getStored(storageKey) ?? vuelessConfig.letterSpacing;
|
|
611
|
-
const mergedSpacing =
|
|
615
|
+
const mergedSpacing = Number(spacing ?? DEFAULT_LETTER_SPACING);
|
|
612
616
|
|
|
613
617
|
if (isCSR && letterSpacing !== undefined) {
|
|
614
618
|
setCookie(storageKey, String(mergedSpacing));
|
|
@@ -636,6 +640,58 @@ function getDisabledOpacity(disabledOpacity?: ThemeConfig["disabledOpacity"]) {
|
|
|
636
640
|
return mergedOpacity;
|
|
637
641
|
}
|
|
638
642
|
|
|
643
|
+
/**
|
|
644
|
+
* Retrieve light theme configuration and save them to cookie and localStorage.
|
|
645
|
+
* @return Partial<VuelessCssVariables> - light theme configuration.
|
|
646
|
+
*/
|
|
647
|
+
function getLightTheme(lightTheme?: Partial<VuelessCssVariables>) {
|
|
648
|
+
const storageKey = `vl-${LIGHT_THEME}`;
|
|
649
|
+
|
|
650
|
+
const storedLightTheme: Partial<VuelessCssVariables> = JSON.parse(getStored(storageKey) ?? "{}");
|
|
651
|
+
|
|
652
|
+
const mergedLightTheme = merge(
|
|
653
|
+
{},
|
|
654
|
+
DEFAULT_LIGHT_THEME,
|
|
655
|
+
vuelessConfig.lightTheme,
|
|
656
|
+
storedLightTheme,
|
|
657
|
+
lightTheme,
|
|
658
|
+
);
|
|
659
|
+
|
|
660
|
+
if (isCSR && lightTheme !== undefined) {
|
|
661
|
+
const themeString = JSON.stringify(mergedLightTheme);
|
|
662
|
+
|
|
663
|
+
localStorage.setItem(storageKey, themeString);
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
return mergedLightTheme;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
* Retrieve dark theme configuration and save them to cookie and localStorage.
|
|
671
|
+
* @return Partial<VuelessCssVariables> - dark theme configuration.
|
|
672
|
+
*/
|
|
673
|
+
function getDarkTheme(darkTheme?: Partial<VuelessCssVariables>) {
|
|
674
|
+
const storageKey = `vl-${DARK_THEME}`;
|
|
675
|
+
|
|
676
|
+
const storedDarkTheme: Partial<VuelessCssVariables> = JSON.parse(getStored(storageKey) ?? "{}");
|
|
677
|
+
|
|
678
|
+
const mergedDarkTheme = merge(
|
|
679
|
+
{},
|
|
680
|
+
DEFAULT_DARK_THEME,
|
|
681
|
+
vuelessConfig.darkTheme,
|
|
682
|
+
storedDarkTheme,
|
|
683
|
+
darkTheme,
|
|
684
|
+
);
|
|
685
|
+
|
|
686
|
+
if (isCSR && darkTheme !== undefined) {
|
|
687
|
+
const themeString = JSON.stringify(mergedDarkTheme);
|
|
688
|
+
|
|
689
|
+
localStorage.setItem(storageKey, themeString);
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
return mergedDarkTheme;
|
|
693
|
+
}
|
|
694
|
+
|
|
639
695
|
/**
|
|
640
696
|
* Generate and apply Vueless CSS variables.
|
|
641
697
|
* @return string - Vueless CSS variables string.
|