vueless 0.0.380 → 0.0.382

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.
@@ -72,6 +72,10 @@ export default function useUI(defaultConfig = {}, propsConfigGetter = null, topL
72
72
  ...toValue(mutatedProps),
73
73
  color: color ? getColor(color) : null,
74
74
  });
75
+ } else if (value.component) {
76
+ // If the value of the key contains keys related to the nested component, it should be skipped.
77
+ // Probably this should be fixed later to be possible to extend key with nested component keys.
78
+ return "";
75
79
  }
76
80
 
77
81
  return color ? setColor(value, color) : value;
@@ -120,6 +124,7 @@ export default function useUI(defaultConfig = {}, propsConfigGetter = null, topL
120
124
  const { base, extend } = keysToExtendConfig[key];
121
125
  const keyAttrs = keysAttrs[`${key}Attrs`];
122
126
 
127
+ // TODO: if value of the key contains keys related to the nested nested component it should be skipped
123
128
  keysAttrs[`${key}Attrs`] = computed(() => ({
124
129
  ...keyAttrs.value,
125
130
  class: cx([
@@ -150,10 +155,11 @@ export default function useUI(defaultConfig = {}, propsConfigGetter = null, topL
150
155
 
151
156
  const commonAttrs = {
152
157
  ...(isTopLevelKey ? attrs : {}),
153
- component: isDev ? attrs.component || componentName || null : null,
154
- "config-key": isDev ? attrs["config-key"] || configKey || null : null,
155
- "child-component": isDev && attrs.component ? nestedComponent || componentName : null,
156
- "child-config-key": isDev && attrs.component ? configKey : null,
158
+ "vl-component": isDev ? attrs["vl-component"] || componentName || null : null,
159
+ "vl-key": isDev ? attrs["vl-config-key"] || configKey || null : null,
160
+ "vl-child-component":
161
+ isDev && attrs["vl-component"] ? nestedComponent || componentName : null,
162
+ "vl-child-key": isDev && attrs["vl-component"] ? configKey : null,
157
163
  };
158
164
 
159
165
  // Delete value key to prevent v-model overwrite
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vueless",
3
- "version": "0.0.380",
3
+ "version": "0.0.382",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless Component Framework.",
6
6
  "homepage": "https://vueless.com",
@@ -1,50 +1,28 @@
1
+ import { computed } from "vue";
1
2
  import useUI from "../composables/useUI.js";
2
- import { cva } from "../utils/utilUI.js";
3
+
3
4
  import defaultConfig from "./config.js";
4
- import { computed } from "vue";
5
5
 
6
6
  export default function useAttrs(props, { selected }) {
7
- const { config, getAttrs, isSystemKey, hasSlotContent, isCVA } = useUI(
8
- defaultConfig,
9
- () => props.config,
10
- );
11
- const attrs = {};
12
-
13
- for (const key in defaultConfig) {
14
- if (isSystemKey(key)) continue;
15
-
16
- const classes = computed(() => {
17
- let value = config.value[key];
7
+ const { config, getKeysAttrs, hasSlotContent } = useUI(defaultConfig, () => props.config);
18
8
 
19
- if (isCVA(value)) {
20
- value = cva(value)({
21
- ...props,
22
- });
23
- }
9
+ const keysAttrs = getKeysAttrs();
24
10
 
25
- return value;
26
- });
11
+ const { checkboxAttrs } = keysAttrs;
27
12
 
28
- attrs[`${key}Attrs`] = getAttrs(key, { classes });
29
-
30
- if (key === "checkbox") {
31
- const checkboxAttrs = attrs[`${key}Attrs`];
32
-
33
- attrs[`${key}Attrs`] = computed(() => {
34
- if (selected.value.icon) {
35
- checkboxAttrs.value.config = checkboxAttrs.value.config || {};
36
- checkboxAttrs.value.config.defaults = checkboxAttrs.value.config.defaults || {};
37
- checkboxAttrs.value.config.defaults.checkedIcon = selected.value.icon;
38
- }
39
-
40
- return checkboxAttrs.value;
41
- });
13
+ keysAttrs.checkboxAttrs = computed(() => {
14
+ if (selected.value.icon) {
15
+ checkboxAttrs.value.config = checkboxAttrs.value.config || {};
16
+ checkboxAttrs.value.config.defaults = checkboxAttrs.value.config.defaults || {};
17
+ checkboxAttrs.value.config.defaults.checkedIcon = selected.value.icon;
42
18
  }
43
- }
19
+
20
+ return checkboxAttrs.value;
21
+ });
44
22
 
45
23
  return {
46
- ...attrs,
47
24
  config,
25
+ ...keysAttrs,
48
26
  hasSlotContent,
49
27
  };
50
28
  }
@@ -1,7 +1,6 @@
1
1
  <template>
2
2
  <UInput
3
3
  :id="elementId"
4
- ref="searchInput"
5
4
  :model-value="localValue"
6
5
  :size="size"
7
6
  :disabled="disabled"
@@ -15,7 +14,7 @@
15
14
  :left-icon="leftIcon"
16
15
  v-bind="inputAttrs"
17
16
  :data-test="dataTest"
18
- @update:model-value="onUpdateModelValue"
17
+ @update:model-value="onUpdateValue"
19
18
  @keyup.enter="onKeyupEnter"
20
19
  >
21
20
  <template #left>
@@ -79,13 +78,13 @@
79
78
  </template>
80
79
 
81
80
  <script setup>
82
- import { computed, ref, useId } from "vue";
81
+ import { computed, useId, ref, watchEffect } from "vue";
83
82
 
84
83
  import UIcon from "../ui.image-icon/UIcon.vue";
85
84
  import UInput from "../ui.form-input/UInput.vue";
86
85
  import UButton from "../ui.button/UButton.vue";
87
86
  import { getDefault } from "../utils/utilUI.js";
88
- import { debounce as setDebounce } from "../utils/utilHelper.js";
87
+ import { createDebounce } from "../utils/utilHelper.js";
89
88
 
90
89
  import { UInputSearch } from "./constants.js";
91
90
  import defaultConfig from "./config.js";
@@ -172,7 +171,7 @@ const props = defineProps({
172
171
  * Minimum character length for search.
173
172
  */
174
173
  minLength: {
175
- type: [String, Number],
174
+ type: [Number, String],
176
175
  default: getDefault(defaultConfig, UInputSearch).minLength,
177
176
  },
178
177
 
@@ -209,7 +208,7 @@ const props = defineProps({
209
208
  },
210
209
 
211
210
  debounce: {
212
- type: [String, Number],
211
+ type: [Number, String],
213
212
  default: getDefault(defaultConfig, UInputSearch).debounce,
214
213
  },
215
214
 
@@ -249,6 +248,10 @@ const emit = defineEmits([
249
248
  "search",
250
249
  ]);
251
250
 
251
+ let updateValueWithDebounce = createDebounce((value) => {
252
+ emit("update:modelValue", value);
253
+ }, Number(props.debounce));
254
+
252
255
  const localValue = ref("");
253
256
 
254
257
  const elementId = props.id || useId();
@@ -275,17 +278,23 @@ const buttonSize = computed(() => {
275
278
  return sizes[props.size];
276
279
  });
277
280
 
278
- function onUpdateModelValue(value) {
281
+ watchEffect(() => {
282
+ updateValueWithDebounce = createDebounce((value) => {
283
+ emit("update:modelValue", value);
284
+ }, Number(props.debounce));
285
+ });
286
+
287
+ function onUpdateValue(value) {
279
288
  localValue.value = value;
280
289
 
281
290
  if (!value) {
282
- emit("update:modelValue", localValue.value);
291
+ updateValueWithDebounce(value);
292
+
293
+ return;
283
294
  }
284
295
 
285
296
  if (value.length >= Number(props.minLength)) {
286
- Number(props.minLength)
287
- ? setDebounce(() => emit("update:modelValue", localValue.value), Number(props.debounce))()
288
- : value && emit("update:modelValue", localValue.value);
297
+ updateValueWithDebounce(value);
289
298
  }
290
299
  }
291
300
 
@@ -305,7 +314,8 @@ function onClickSearch() {
305
314
 
306
315
  function onClickClear() {
307
316
  localValue.value = "";
308
- emit("update:modelValue", localValue.value);
317
+
318
+ emit("update:modelValue", "");
309
319
  emit("clear");
310
320
  }
311
321
  </script>
@@ -310,11 +310,13 @@
310
310
 
311
311
  <script setup>
312
312
  import { ref, computed, nextTick, watch, useSlots, onMounted, useId } from "vue";
313
- import { debounce, merge } from "lodash-es";
313
+ import { merge } from "lodash-es";
314
314
 
315
315
  import UIcon from "../ui.image-icon/UIcon.vue";
316
316
  import ULabel from "../ui.form-label/ULabel.vue";
317
317
  import UDropdownList from "../ui.dropdown-list/UDropdownList.vue";
318
+
319
+ import { createDebounce } from "../utils/utilHelper.js";
318
320
  import { getDefault } from "../utils/utilUI.js";
319
321
  import { isMac } from "../utils/utilPlatform.js";
320
322
 
@@ -729,7 +731,7 @@ const isLocalValue = computed(() => {
729
731
  : Boolean(String(localValue.value));
730
732
  });
731
733
 
732
- const onSearchChange = debounce(function (query) {
734
+ const onSearchChange = createDebounce(function (query) {
733
735
  emit("searchChange", query);
734
736
  }, 300);
735
737
 
@@ -38,20 +38,18 @@ export function cloneDeep(entity, cache = new WeakMap()) {
38
38
  }
39
39
 
40
40
  /**
41
- Invoke function with delay (same as lodash.debounce).
41
+ Creates a debounced function with delay (same as lodash.debounce).
42
42
  @param {Function} func
43
- @param {Number} wait
43
+ @param {Number} ms
44
44
 
45
45
  @returns {Function}
46
46
  */
47
- export function debounce(func, wait) {
47
+ export function createDebounce(func, ms) {
48
48
  let timeout;
49
49
 
50
- return function (...args) {
51
- const context = this;
52
-
50
+ return function () {
53
51
  clearTimeout(timeout);
54
- timeout = setTimeout(() => func.apply(context, args), wait);
52
+ timeout = setTimeout(() => func.apply(this, arguments), ms);
55
53
  };
56
54
  }
57
55
 
package/web-types.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "framework": "vue",
3
3
  "name": "vueless",
4
- "version": "0.0.380",
4
+ "version": "0.0.382",
5
5
  "contributions": {
6
6
  "html": {
7
7
  "description-markup": "markdown",
@@ -5383,7 +5383,7 @@
5383
5383
  "description": "Minimum character length for search.",
5384
5384
  "value": {
5385
5385
  "kind": "expression",
5386
- "type": "string|number"
5386
+ "type": "number|string"
5387
5387
  },
5388
5388
  "default": "0"
5389
5389
  },
@@ -5427,7 +5427,7 @@
5427
5427
  "name": "debounce",
5428
5428
  "value": {
5429
5429
  "kind": "expression",
5430
- "type": "string|number"
5430
+ "type": "number|string"
5431
5431
  },
5432
5432
  "default": "300"
5433
5433
  },