vueless 1.2.8-beta.14 → 1.2.8-beta.16
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/index.d.ts +1 -1
- package/index.ts +1 -1
- package/package.json +1 -1
- package/ui.dropdown-badge/UDropdownBadge.vue +17 -1
- package/ui.dropdown-button/UDropdownButton.vue +18 -4
- package/ui.dropdown-link/UDropdownLink.vue +18 -4
- package/ui.form-listbox/UListbox.vue +1 -5
- package/ui.form-select/USelect.vue +1 -0
- package/utils/theme.ts +12 -24
package/index.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export {
|
|
|
17
17
|
} from "./utils/helper";
|
|
18
18
|
export { isMac, isPWA, isIOS, isAndroid, isMobileApp, isWindows } from "./utils/platform";
|
|
19
19
|
export { cx, cva, compose, getDefaults, setVuelessConfig, setColor, vuelessConfig } from "./utils/ui";
|
|
20
|
-
export { getTheme, setTheme, resetTheme, normalizeThemeConfig, cssVar } from "./utils/theme";
|
|
20
|
+
export { getTheme, setTheme, resetTheme, normalizeThemeConfig, cssVar, setRootCSSVariables } from "./utils/theme";
|
|
21
21
|
export { getArgs, getArgTypes, getSlotNames, getSlotsFragment, getSource, getDocsDescription } from "./utils/storybook";
|
|
22
22
|
/* adapters */
|
|
23
23
|
export { default as defaultEnLocale } from "./adapter.locale/locales/en";
|
package/index.ts
CHANGED
|
@@ -23,7 +23,7 @@ export {
|
|
|
23
23
|
} from "./utils/helper";
|
|
24
24
|
export { isMac, isPWA, isIOS, isAndroid, isMobileApp, isWindows } from "./utils/platform";
|
|
25
25
|
export { cx, cva, compose, getDefaults, setVuelessConfig, setColor, vuelessConfig } from "./utils/ui";
|
|
26
|
-
export { getTheme, setTheme, resetTheme, normalizeThemeConfig, cssVar } from "./utils/theme";
|
|
26
|
+
export { getTheme, setTheme, resetTheme, normalizeThemeConfig, cssVar, setRootCSSVariables } from "./utils/theme";
|
|
27
27
|
export { getArgs, getArgTypes, getSlotNames, getSlotsFragment, getSource, getDocsDescription } from "./utils/storybook";
|
|
28
28
|
/* adapters */
|
|
29
29
|
export { default as defaultEnLocale } from "./adapter.locale/locales/en";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vueless",
|
|
3
|
-
"version": "1.2.8-beta.
|
|
3
|
+
"version": "1.2.8-beta.16",
|
|
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",
|
|
@@ -66,6 +66,7 @@ const emit = defineEmits([
|
|
|
66
66
|
type UListboxRef = InstanceType<typeof UListbox>;
|
|
67
67
|
|
|
68
68
|
const isShownOptions = ref(false);
|
|
69
|
+
const isClickingOption = ref(false);
|
|
69
70
|
const listboxRef = useTemplateRef<UListboxRef>("dropdown-list");
|
|
70
71
|
const wrapperRef = useTemplateRef<HTMLDivElement>("wrapper");
|
|
71
72
|
|
|
@@ -157,14 +158,29 @@ function onClickBadge() {
|
|
|
157
158
|
|
|
158
159
|
function hideOptions() {
|
|
159
160
|
isShownOptions.value = false;
|
|
161
|
+
dropdownSearch.value = "";
|
|
160
162
|
|
|
161
163
|
emit("close");
|
|
162
164
|
}
|
|
163
165
|
|
|
164
166
|
function onClickOption(option: Option) {
|
|
167
|
+
isClickingOption.value = true;
|
|
168
|
+
|
|
165
169
|
emit("clickOption", option);
|
|
166
170
|
|
|
167
171
|
if (!props.multiple && props.closeOnSelect) hideOptions();
|
|
172
|
+
|
|
173
|
+
nextTick(() => {
|
|
174
|
+
setTimeout(() => {
|
|
175
|
+
isClickingOption.value = false;
|
|
176
|
+
}, 10);
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
function handleClickOutside() {
|
|
181
|
+
if (isClickingOption.value) return;
|
|
182
|
+
|
|
183
|
+
hideOptions();
|
|
168
184
|
}
|
|
169
185
|
|
|
170
186
|
defineExpose({
|
|
@@ -197,7 +213,7 @@ const { getDataTest, config, wrapperAttrs, dropdownBadgeAttrs, listboxAttrs, tog
|
|
|
197
213
|
<template>
|
|
198
214
|
<div
|
|
199
215
|
ref="wrapper"
|
|
200
|
-
v-click-outside="
|
|
216
|
+
v-click-outside="handleClickOutside"
|
|
201
217
|
v-bind="wrapperAttrs"
|
|
202
218
|
:data-test="getDataTest('wrapper')"
|
|
203
219
|
>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { nextTick, computed,
|
|
2
|
+
import { nextTick, computed, ref, useId, useTemplateRef } from "vue";
|
|
3
3
|
import { isEqual } from "lodash-es";
|
|
4
4
|
|
|
5
5
|
import useUI from "../composables/useUI";
|
|
@@ -63,11 +63,10 @@ const emit = defineEmits([
|
|
|
63
63
|
"update:search",
|
|
64
64
|
]);
|
|
65
65
|
|
|
66
|
-
provide("hideDropdownOptions", hideOptions);
|
|
67
|
-
|
|
68
66
|
type UListboxRef = InstanceType<typeof UListbox>;
|
|
69
67
|
|
|
70
68
|
const isShownOptions = ref(false);
|
|
69
|
+
const isClickingOption = ref(false);
|
|
71
70
|
const listboxRef = useTemplateRef<UListboxRef>("dropdown-list");
|
|
72
71
|
const wrapperRef = useTemplateRef<HTMLDivElement>("wrapper");
|
|
73
72
|
|
|
@@ -148,9 +147,23 @@ function getFullOptionLabels(value: Option | Option[]) {
|
|
|
148
147
|
}
|
|
149
148
|
|
|
150
149
|
function onClickOption(option: Option) {
|
|
150
|
+
isClickingOption.value = true;
|
|
151
|
+
|
|
151
152
|
emit("clickOption", option);
|
|
152
153
|
|
|
153
154
|
if (!props.multiple && props.closeOnSelect) hideOptions();
|
|
155
|
+
|
|
156
|
+
nextTick(() => {
|
|
157
|
+
setTimeout(() => {
|
|
158
|
+
isClickingOption.value = false;
|
|
159
|
+
}, 10);
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function handleClickOutside() {
|
|
164
|
+
if (isClickingOption.value) return;
|
|
165
|
+
|
|
166
|
+
hideOptions();
|
|
154
167
|
}
|
|
155
168
|
|
|
156
169
|
function onClickButton() {
|
|
@@ -165,6 +178,7 @@ function onClickButton() {
|
|
|
165
178
|
|
|
166
179
|
function hideOptions() {
|
|
167
180
|
isShownOptions.value = false;
|
|
181
|
+
dropdownSearch.value = "";
|
|
168
182
|
|
|
169
183
|
emit("close");
|
|
170
184
|
}
|
|
@@ -199,7 +213,7 @@ const { getDataTest, config, dropdownButtonAttrs, listboxAttrs, toggleIconAttrs,
|
|
|
199
213
|
<template>
|
|
200
214
|
<div
|
|
201
215
|
ref="wrapper"
|
|
202
|
-
v-click-outside="
|
|
216
|
+
v-click-outside="handleClickOutside"
|
|
203
217
|
v-bind="wrapperAttrs"
|
|
204
218
|
:data-test="getDataTest('wrapper')"
|
|
205
219
|
>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import { nextTick, computed,
|
|
2
|
+
import { nextTick, computed, ref, useId, useTemplateRef } from "vue";
|
|
3
3
|
import { isEqual } from "lodash-es";
|
|
4
4
|
|
|
5
5
|
import useUI from "../composables/useUI";
|
|
@@ -63,11 +63,10 @@ const emit = defineEmits([
|
|
|
63
63
|
"update:search",
|
|
64
64
|
]);
|
|
65
65
|
|
|
66
|
-
provide("hideDropdownOptions", hideOptions);
|
|
67
|
-
|
|
68
66
|
type ULisboxRef = InstanceType<typeof ULisbox>;
|
|
69
67
|
|
|
70
68
|
const isShownOptions = ref(false);
|
|
69
|
+
const isClickingOption = ref(false);
|
|
71
70
|
const listboxRef = useTemplateRef<ULisboxRef>("dropdown-list");
|
|
72
71
|
const wrapperRef = useTemplateRef<HTMLDivElement>("wrapper");
|
|
73
72
|
|
|
@@ -161,14 +160,29 @@ function onClickLink() {
|
|
|
161
160
|
|
|
162
161
|
function hideOptions() {
|
|
163
162
|
isShownOptions.value = false;
|
|
163
|
+
dropdownSearch.value = "";
|
|
164
164
|
|
|
165
165
|
emit("close");
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
function onClickOption(option: Option) {
|
|
169
|
+
isClickingOption.value = true;
|
|
170
|
+
|
|
169
171
|
emit("clickOption", option);
|
|
170
172
|
|
|
171
173
|
if (!props.multiple && props.closeOnSelect) hideOptions();
|
|
174
|
+
|
|
175
|
+
nextTick(() => {
|
|
176
|
+
setTimeout(() => {
|
|
177
|
+
isClickingOption.value = false;
|
|
178
|
+
}, 10);
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function handleClickOutside() {
|
|
183
|
+
if (isClickingOption.value) return;
|
|
184
|
+
|
|
185
|
+
hideOptions();
|
|
172
186
|
}
|
|
173
187
|
|
|
174
188
|
defineExpose({
|
|
@@ -201,7 +215,7 @@ const { config, getDataTest, wrapperAttrs, dropdownLinkAttrs, listboxAttrs, togg
|
|
|
201
215
|
<template>
|
|
202
216
|
<div
|
|
203
217
|
ref="wrapper"
|
|
204
|
-
v-click-outside="
|
|
218
|
+
v-click-outside="handleClickOutside"
|
|
205
219
|
tabindex="1"
|
|
206
220
|
v-bind="wrapperAttrs"
|
|
207
221
|
:data-test="getDataTest('wrapper')"
|
|
@@ -103,11 +103,7 @@ const selectedValue = computed({
|
|
|
103
103
|
|
|
104
104
|
return props.modelValue;
|
|
105
105
|
},
|
|
106
|
-
set: (value) =>
|
|
107
|
-
if (searchModel.value) searchModel.value = "";
|
|
108
|
-
|
|
109
|
-
emit("update:modelValue", value);
|
|
110
|
-
},
|
|
106
|
+
set: (value) => emit("update:modelValue", value),
|
|
111
107
|
});
|
|
112
108
|
|
|
113
109
|
const addOptionKeyCombination = computed(() => {
|
package/utils/theme.ts
CHANGED
|
@@ -51,18 +51,6 @@ import type {
|
|
|
51
51
|
} from "../types";
|
|
52
52
|
import { ColorMode } from "../types";
|
|
53
53
|
|
|
54
|
-
declare interface RootCSSVariableOptions {
|
|
55
|
-
primary: PrimaryColors | string;
|
|
56
|
-
neutral: NeutralColors | string;
|
|
57
|
-
text: ThemeConfigText;
|
|
58
|
-
rounding: ThemeConfigRounding;
|
|
59
|
-
outline: ThemeConfigOutline;
|
|
60
|
-
letterSpacing: number;
|
|
61
|
-
disabledOpacity: number;
|
|
62
|
-
lightTheme: Partial<VuelessCssVariables>;
|
|
63
|
-
darkTheme: Partial<VuelessCssVariables>;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
54
|
declare interface SetColorMode {
|
|
67
55
|
colorMode: `${ColorMode}`;
|
|
68
56
|
isColorModeAuto: boolean;
|
|
@@ -334,10 +322,10 @@ export function setTheme(config: ThemeConfig = {}) {
|
|
|
334
322
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
335
323
|
export function normalizeThemeConfig(theme: any): MergedThemeConfig {
|
|
336
324
|
return {
|
|
337
|
-
colorMode: String(theme.colorMode) as ColorMode,
|
|
325
|
+
colorMode: String(theme.colorMode ?? "") as ColorMode,
|
|
338
326
|
isColorModeAuto: !!toNumber(theme.isColorModeAuto),
|
|
339
|
-
primary: String(theme.primary),
|
|
340
|
-
neutral: String(theme.neutral),
|
|
327
|
+
primary: String(theme.primary ?? ""),
|
|
328
|
+
neutral: String(theme.neutral ?? ""),
|
|
341
329
|
text: {
|
|
342
330
|
xs: toNumber(theme.text?.xs),
|
|
343
331
|
sm: toNumber(theme.text?.sm),
|
|
@@ -696,20 +684,20 @@ function getDarkTheme(darkTheme?: Partial<VuelessCssVariables>) {
|
|
|
696
684
|
* Generate and apply Vueless CSS variables.
|
|
697
685
|
* @return string - Vueless CSS variables string.
|
|
698
686
|
*/
|
|
699
|
-
function setRootCSSVariables(vars:
|
|
687
|
+
export function setRootCSSVariables(vars: MergedThemeConfig) {
|
|
700
688
|
let darkVariables: Partial<VuelessCssVariables> = {};
|
|
701
689
|
|
|
702
690
|
let variables: Partial<VuelessCssVariables> = {
|
|
703
|
-
"--vl-text-xs": `${vars.text
|
|
704
|
-
"--vl-text-sm": `${vars.text
|
|
705
|
-
"--vl-text-md": `${vars.text
|
|
706
|
-
"--vl-text-lg": `${vars.text
|
|
691
|
+
"--vl-text-xs": `${Number(vars.text?.xs ?? 0) / PX_IN_REM}rem`,
|
|
692
|
+
"--vl-text-sm": `${Number(vars.text?.sm ?? 0) / PX_IN_REM}rem`,
|
|
693
|
+
"--vl-text-md": `${Number(vars.text?.md ?? 0) / PX_IN_REM}rem`,
|
|
694
|
+
"--vl-text-lg": `${Number(vars.text?.lg ?? 0) / PX_IN_REM}rem`,
|
|
707
695
|
"--vl-outline-sm": `${vars.outline.sm}px`,
|
|
708
696
|
"--vl-outline-md": `${vars.outline.md}px`,
|
|
709
697
|
"--vl-outline-lg": `${vars.outline.lg}px`,
|
|
710
|
-
"--vl-rounding-sm": `${vars.rounding.sm / PX_IN_REM}rem`,
|
|
711
|
-
"--vl-rounding-md": `${vars.rounding.md / PX_IN_REM}rem`,
|
|
712
|
-
"--vl-rounding-lg": `${vars.rounding.lg / PX_IN_REM}rem`,
|
|
698
|
+
"--vl-rounding-sm": `${Number(vars.rounding.sm ?? 0) / PX_IN_REM}rem`,
|
|
699
|
+
"--vl-rounding-md": `${Number(vars.rounding.md ?? 0) / PX_IN_REM}rem`,
|
|
700
|
+
"--vl-rounding-lg": `${Number(vars.rounding.lg ?? 0) / PX_IN_REM}rem`,
|
|
713
701
|
"--vl-letter-spacing": `${vars.letterSpacing}em`,
|
|
714
702
|
"--vl-disabled-opacity": `${vars.disabledOpacity}%`,
|
|
715
703
|
};
|
|
@@ -724,7 +712,7 @@ function setRootCSSVariables(vars: RootCSSVariableOptions) {
|
|
|
724
712
|
`var(--color-${vars.neutral}-${shade})`;
|
|
725
713
|
}
|
|
726
714
|
|
|
727
|
-
const [light, dark] = generateCSSColorVariables(vars.lightTheme, vars.darkTheme);
|
|
715
|
+
const [light, dark] = generateCSSColorVariables(vars.lightTheme ?? {}, vars.darkTheme ?? {});
|
|
728
716
|
|
|
729
717
|
variables = { ...variables, ...light };
|
|
730
718
|
darkVariables = { ...darkVariables, ...dark };
|