vueless 0.0.356 → 0.0.358

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.
@@ -30,7 +30,7 @@ import {
30
30
  export default function useUI(defaultConfig = {}, propsConfigGetter = null, topLevelClassKey) {
31
31
  const { type, props } = getCurrentInstance();
32
32
  const componentName = type.__name;
33
- const globalConfig = vuelessConfig?.component ? vuelessConfig?.component[componentName] : {};
33
+ const globalConfig = vuelessConfig.component ? vuelessConfig.component[componentName] : {};
34
34
 
35
35
  const isStrategyValid =
36
36
  vuelessConfig.strategy && Object.values(STRATEGY_TYPE).includes(vuelessConfig.strategy);
@@ -17,7 +17,7 @@ if (isCSR) {
17
17
  animation: "shift-away",
18
18
  };
19
19
 
20
- settings = merge(defaultSettings, vuelessConfig?.directive?.tooltip || {});
20
+ settings = merge(defaultSettings, vuelessConfig.directive?.tooltip || {});
21
21
  tippy.setDefaultProps(settings);
22
22
  }
23
23
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "0.0.356",
3
+ "version": "0.0.358",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless Component Framework.",
6
6
  "homepage": "https://vueless.com",
@@ -2,7 +2,7 @@
2
2
  <UInput
3
3
  :id="elementId"
4
4
  ref="searchInput"
5
- v-model="search"
5
+ :model-value="localValue"
6
6
  :size="size"
7
7
  :disabled="disabled"
8
8
  :readonly="readonly"
@@ -12,10 +12,11 @@
12
12
  :description="description"
13
13
  :placeholder="placeholder"
14
14
  inputmode="search"
15
- :data-test="dataTest"
16
15
  :left-icon="leftIcon"
17
16
  v-bind="inputAttrs"
18
- @keyup.enter="onClickSearch"
17
+ :data-test="dataTest"
18
+ @update:model-value="onUpdateModelValue"
19
+ @keyup.enter="onKeyupEnter"
19
20
  >
20
21
  <template #left>
21
22
  <!-- @slot Use it to add something before the text. -->
@@ -29,14 +30,14 @@
29
30
 
30
31
  <template #right-icon>
31
32
  <UIcon
32
- v-if="modelValue"
33
+ v-if="localValue"
33
34
  internal
34
35
  interactive
35
36
  color="gray"
36
37
  :name="config.defaults.clearIcon"
37
- :data-test="`${dataTest}-close`"
38
38
  :size="iconSize"
39
39
  v-bind="clearIconAttrs"
40
+ :data-test="`${dataTest}-clear`"
40
41
  @click="onClickClear"
41
42
  />
42
43
 
@@ -53,8 +54,8 @@
53
54
  interactive
54
55
  :size="iconSize"
55
56
  :name="rightIcon || config.defaults.searchIcon"
56
- :data-test="`${dataTest}-search`"
57
57
  v-bind="searchIconAttrs"
58
+ :data-test="`${dataTest}-search-icon`"
58
59
  @click="onClickSearch"
59
60
  />
60
61
  </slot>
@@ -69,7 +70,7 @@
69
70
  :size="buttonSize"
70
71
  no-ring
71
72
  v-bind="buttonAttrs"
72
- :data-test="`${dataTest}-right`"
73
+ :data-test="`${dataTest}-search-button`"
73
74
  @click="onClickSearch"
74
75
  />
75
76
  </slot>
@@ -84,7 +85,7 @@ import UIcon from "../ui.image-icon/UIcon.vue";
84
85
  import UInput from "../ui.form-input/UInput.vue";
85
86
  import UButton from "../ui.button/UButton.vue";
86
87
  import { getDefault } from "../utils/utilUI.js";
87
- import { debounce as debounceMethod } from "../utils/utilHelper.js";
88
+ import { debounce as setDebounce } from "../utils/utilHelper.js";
88
89
 
89
90
  import { UInputSearch } from "./constants.js";
90
91
  import defaultConfig from "./config.js";
@@ -208,7 +209,7 @@ const props = defineProps({
208
209
  },
209
210
 
210
211
  debounce: {
211
- type: Number,
212
+ type: [String, Number],
212
213
  default: getDefault(defaultConfig, UInputSearch).debounce,
213
214
  },
214
215
 
@@ -254,17 +255,6 @@ const elementId = props.id || useId();
254
255
 
255
256
  const { config, inputAttrs, searchIconAttrs, clearIconAttrs, buttonAttrs } = useAttrs(props);
256
257
 
257
- const search = computed({
258
- get: () => props.modelValue,
259
- set: debounceMethod((value) => {
260
- localValue.value = value;
261
-
262
- if (localValue.value.length >= Number(props.minLength)) {
263
- emit("update:modelValue", value);
264
- }
265
- }, props.debounce),
266
- });
267
-
268
258
  const iconSize = computed(() => {
269
259
  const sizes = {
270
260
  sm: "xs",
@@ -285,13 +275,34 @@ const buttonSize = computed(() => {
285
275
  return sizes[props.size];
286
276
  });
287
277
 
288
- function onClickClear() {
289
- search.value = "";
290
- emit("clear");
278
+ function onUpdateModelValue(value) {
279
+ localValue.value = value;
280
+
281
+ if (!value) {
282
+ emit("update:modelValue", localValue.value);
283
+ }
284
+
285
+ if (Number(props.minLength) && value.length >= Number(props.minLength)) {
286
+ setDebounce(() => emit("update:modelValue", localValue.value), Number(props.debounce))();
287
+ }
288
+ }
289
+
290
+ function search() {
291
+ if (localValue.value && localValue.value.length >= Number(props.minLength)) {
292
+ emit("search", localValue.value);
293
+ }
294
+ }
295
+
296
+ function onKeyupEnter() {
297
+ search();
291
298
  }
292
299
 
293
300
  function onClickSearch() {
294
- if (!localValue.value) return;
295
- emit("search", localValue.value);
301
+ search();
302
+ }
303
+
304
+ function onClickClear() {
305
+ localValue.value = "";
306
+ emit("clear");
296
307
  }
297
308
  </script>
@@ -1,6 +1,6 @@
1
1
  export default /*tw*/ {
2
2
  header: {
3
- base: "text-{color}-600 font-bold",
3
+ base: "text-{color}-600 font-medium",
4
4
  variants: {
5
5
  size: {
6
6
  xs: "text-lg",
@@ -31,11 +31,11 @@ export function themeInit() {
31
31
 
32
32
  export function setTheme(config = {}) {
33
33
  const isDarkMode = setDarkMode(config);
34
- const ring = config?.ring ?? vuelessConfig?.ring ?? DEFAULT_RING;
35
- const ringOffset = config?.ringOffset ?? vuelessConfig?.ringOffset ?? DEFAULT_RING_OFFSET;
36
- const rounding = config?.rounding ?? vuelessConfig?.rounding ?? DEFAULT_ROUNDING;
37
- let brand = config?.brand ?? vuelessConfig?.brand ?? DEFAULT_BRAND_COLOR;
38
- let gray = config?.gray ?? vuelessConfig?.gray ?? DEFAULT_GRAY_COLOR;
34
+ const ring = config?.ring ?? vuelessConfig.ring ?? DEFAULT_RING;
35
+ const ringOffset = config?.ringOffset ?? vuelessConfig.ringOffset ?? DEFAULT_RING_OFFSET;
36
+ const rounding = config?.rounding ?? vuelessConfig.rounding ?? DEFAULT_ROUNDING;
37
+ let brand = config?.brand ?? vuelessConfig.brand ?? DEFAULT_BRAND_COLOR;
38
+ let gray = config?.gray ?? vuelessConfig.gray ?? DEFAULT_GRAY_COLOR;
39
39
 
40
40
  const isBrandColor = BRAND_COLORS.some((color) => color === brand);
41
41
  const isGrayColor = GRAY_COLORS.some((color) => color === gray);
@@ -103,7 +103,7 @@ function setDarkMode(config) {
103
103
  let isDarkMode =
104
104
  storedDarkMode !== null
105
105
  ? !!Number(storedDarkMode)
106
- : !!(config?.darkMode ?? vuelessConfig?.darkMode ?? config?.systemDarkMode);
106
+ : !!(config?.darkMode ?? vuelessConfig.darkMode ?? config?.systemDarkMode);
107
107
 
108
108
  isDarkMode
109
109
  ? isCSR && document.documentElement.classList.add(DARK_MODE_SELECTOR)
package/utils/utilUI.js CHANGED
@@ -17,16 +17,20 @@ import {
17
17
  export let vuelessConfig = {};
18
18
 
19
19
  if (isSSR) {
20
- (async () =>
21
- (vuelessConfig = (
22
- await import(/* @vite-ignore */ `${process.cwd()}/vueless.config.js?${Date.now()}`)
23
- ).default))();
20
+ /* Load Vueless config from the project root in IIFE (no top-level await). */
21
+ (async () => {
22
+ try {
23
+ vuelessConfig = (await import(`${process.cwd()}/vueless.config.js`)).default;
24
+ } catch (error) {
25
+ vuelessConfig = {};
26
+ }
27
+ })();
24
28
  }
25
29
 
26
30
  if (isCSR) {
27
- vuelessConfig = Object.values(
28
- import.meta.glob("/vueless.config.js", { eager: true, import: "default" }),
29
- )[0];
31
+ vuelessConfig =
32
+ Object.values(import.meta.glob("/vueless.config.js", { eager: true, import: "default" }))[0] ||
33
+ {};
30
34
  }
31
35
 
32
36
  /**
@@ -49,7 +53,7 @@ const twMerge = extendTailwindMerge(
49
53
  },
50
54
  },
51
55
  },
52
- vuelessConfig?.tailwindMerge,
56
+ vuelessConfig.tailwindMerge,
53
57
  ),
54
58
  );
55
59
 
@@ -88,7 +92,7 @@ export const cva = ({ base = "", variants = {}, compoundVariants = [], defaultVa
88
92
  export function getDefault(defaultConfig, name) {
89
93
  const defaults = merge(
90
94
  cloneDeep(defaultConfig.defaults),
91
- vuelessConfig?.component ? vuelessConfig?.component[name]?.defaults : {},
95
+ vuelessConfig.component ? vuelessConfig.component[name]?.defaults : {},
92
96
  );
93
97
 
94
98
  defaults.color = getColor(defaults.color);
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "framework": "vue",
3
3
  "name": "vueless",
4
- "version": "0.0.356",
4
+ "version": "0.0.358",
5
5
  "contributions": {
6
6
  "html": {
7
7
  "description-markup": "markdown",
@@ -5560,7 +5560,7 @@
5560
5560
  "name": "debounce",
5561
5561
  "value": {
5562
5562
  "kind": "expression",
5563
- "type": "number"
5563
+ "type": "string|number"
5564
5564
  },
5565
5565
  "default": "300"
5566
5566
  },