vueless 1.2.8-beta.6 → 1.2.8-beta.8
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/package.json +1 -1
- package/ui.form-input-number/UInputNumber.vue +1 -1
- package/ui.form-listbox/UListbox.vue +10 -20
- package/utils/theme.ts +60 -4
package/constants.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ export const OUTLINE: "outline";
|
|
|
9
9
|
export const ROUNDING: "rounding";
|
|
10
10
|
export const DISABLED_OPACITY: "disabled-opacity";
|
|
11
11
|
export const LETTER_SPACING: "letter-spacing";
|
|
12
|
+
export const LIGHT_THEME: "light-theme";
|
|
13
|
+
export const DARK_THEME: "dark-theme";
|
|
12
14
|
export const COLOR_MODE_KEY: "vl-color-mode";
|
|
13
15
|
export const AUTO_MODE_KEY: "vl-auto-mode";
|
|
14
16
|
export const DARK_MODE_CLASS: "vl-dark";
|
|
@@ -28,6 +30,7 @@ export const DEFAULT_DISABLED_OPACITY: 50;
|
|
|
28
30
|
export const DEFAULT_LETTER_SPACING: 0;
|
|
29
31
|
export const PRIMARY_COLORS: string[];
|
|
30
32
|
export const STATE_COLORS: string[];
|
|
33
|
+
export const LAYOUT_COLORS: string[];
|
|
31
34
|
export const NEUTRAL_COLORS: string[];
|
|
32
35
|
export const COLOR_SHADES: number[];
|
|
33
36
|
export const DEFAULT_LIGHT_THEME: {
|
package/constants.js
CHANGED
|
@@ -17,6 +17,8 @@ export const OUTLINE = "outline";
|
|
|
17
17
|
export const ROUNDING = "rounding";
|
|
18
18
|
export const DISABLED_OPACITY = "disabled-opacity";
|
|
19
19
|
export const LETTER_SPACING = "letter-spacing";
|
|
20
|
+
export const LIGHT_THEME = "light-theme";
|
|
21
|
+
export const DARK_THEME = "dark-theme";
|
|
20
22
|
|
|
21
23
|
/* Vueless color mode keys */
|
|
22
24
|
export const COLOR_MODE_KEY = "vl-color-mode";
|
|
@@ -70,6 +72,7 @@ export const STATE_COLORS = [
|
|
|
70
72
|
NEUTRAL_COLOR,
|
|
71
73
|
GRAYSCALE_COLOR,
|
|
72
74
|
];
|
|
75
|
+
export const LAYOUT_COLORS = ["text", "border", "bg"];
|
|
73
76
|
export const NEUTRAL_COLORS = ["slate", "gray", "zinc", "neutral", "stone"];
|
|
74
77
|
export const COLOR_SHADES = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
|
|
75
78
|
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { watch, computed, useId, ref, useTemplateRef, nextTick
|
|
2
|
+
import { watch, computed, useId, ref, useTemplateRef, nextTick } from "vue";
|
|
3
3
|
import { isEqual } from "lodash-es";
|
|
4
4
|
|
|
5
5
|
import useUI from "../composables/useUI";
|
|
@@ -65,8 +65,6 @@ const emit = defineEmits([
|
|
|
65
65
|
"update:search",
|
|
66
66
|
]);
|
|
67
67
|
|
|
68
|
-
const attrs = useAttrs();
|
|
69
|
-
|
|
70
68
|
const wrapperRef = useTemplateRef<HTMLDivElement>("wrapper");
|
|
71
69
|
const listboxInputRef = useTemplateRef<{ input: HTMLInputElement }>("listbox-input");
|
|
72
70
|
const optionsRef = useTemplateRef<HTMLLIElement[]>("option");
|
|
@@ -75,7 +73,7 @@ const addOptionRef = useTemplateRef<HTMLLIElement>("add-option");
|
|
|
75
73
|
|
|
76
74
|
const wrapperMaxHeight = ref("");
|
|
77
75
|
|
|
78
|
-
const
|
|
76
|
+
const localSearch = ref(props.search ?? "");
|
|
79
77
|
|
|
80
78
|
const { pointer, pointerDirty, pointerSet, pointerBackward, pointerForward, pointerReset } =
|
|
81
79
|
usePointer(props.options, optionsRef, wrapperRef);
|
|
@@ -88,13 +86,12 @@ const { localeMessages } = useComponentLocaleMessages<typeof defaultConfig.i18n>
|
|
|
88
86
|
props?.config?.i18n,
|
|
89
87
|
);
|
|
90
88
|
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
const search = computed({
|
|
94
|
-
get: () => (isControlledSearch.value ? (props.search ?? "") : internalSearch.value),
|
|
89
|
+
const searchModel = computed({
|
|
90
|
+
get: () => localSearch.value,
|
|
95
91
|
set: (value: string) => {
|
|
96
92
|
emit("update:search", value);
|
|
97
|
-
|
|
93
|
+
|
|
94
|
+
localSearch.value = value ?? "";
|
|
98
95
|
},
|
|
99
96
|
});
|
|
100
97
|
|
|
@@ -107,7 +104,7 @@ const selectedValue = computed({
|
|
|
107
104
|
return props.modelValue;
|
|
108
105
|
},
|
|
109
106
|
set: (value) => {
|
|
110
|
-
if (
|
|
107
|
+
if (searchModel.value) searchModel.value = "";
|
|
111
108
|
|
|
112
109
|
emit("update:modelValue", value);
|
|
113
110
|
},
|
|
@@ -118,7 +115,7 @@ const addOptionKeyCombination = computed(() => {
|
|
|
118
115
|
});
|
|
119
116
|
|
|
120
117
|
const filteredOptions = computed(() => {
|
|
121
|
-
const normalizedSearch =
|
|
118
|
+
const normalizedSearch = searchModel.value.toLowerCase().trim();
|
|
122
119
|
|
|
123
120
|
let options = [...props.options];
|
|
124
121
|
|
|
@@ -136,14 +133,7 @@ const filteredOptions = computed(() => {
|
|
|
136
133
|
});
|
|
137
134
|
|
|
138
135
|
watch(
|
|
139
|
-
() => props.
|
|
140
|
-
(value) => {
|
|
141
|
-
if (isControlledSearch.value) internalSearch.value = value ?? "";
|
|
142
|
-
},
|
|
143
|
-
);
|
|
144
|
-
|
|
145
|
-
watch(
|
|
146
|
-
() => [props.options, props.size, props.visibleOptions, props.searchable, search.value],
|
|
136
|
+
() => [props.options, props.size, props.visibleOptions, props.searchable, searchModel.value],
|
|
147
137
|
() => {
|
|
148
138
|
nextTick(() => {
|
|
149
139
|
const options = [
|
|
@@ -444,7 +434,7 @@ const {
|
|
|
444
434
|
v-if="searchable"
|
|
445
435
|
:id="elementId"
|
|
446
436
|
ref="listbox-input"
|
|
447
|
-
v-model="
|
|
437
|
+
v-model="searchModel"
|
|
448
438
|
:placeholder="localeMessages.search"
|
|
449
439
|
:size="size"
|
|
450
440
|
:debounce="debounce"
|
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) {
|
|
@@ -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.
|