vueless 0.0.380 → 0.0.381
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/composables/useUI.js +10 -4
- package/package.json +1 -1
- package/ui.form-input-search/UInputSearch.vue +22 -12
- package/ui.form-select/USelect.vue +4 -2
- package/utils/utilHelper.js +5 -7
- package/web-types.json +3 -3
package/composables/useUI.js
CHANGED
|
@@ -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
|
|
154
|
-
"
|
|
155
|
-
"child-component":
|
|
156
|
-
|
|
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,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="
|
|
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,
|
|
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 {
|
|
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: [
|
|
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: [
|
|
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
|
-
|
|
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
|
-
|
|
291
|
+
updateValueWithDebounce(value);
|
|
292
|
+
|
|
293
|
+
return;
|
|
283
294
|
}
|
|
284
295
|
|
|
285
296
|
if (value.length >= Number(props.minLength)) {
|
|
286
|
-
|
|
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
|
-
|
|
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 {
|
|
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 =
|
|
734
|
+
const onSearchChange = createDebounce(function (query) {
|
|
733
735
|
emit("searchChange", query);
|
|
734
736
|
}, 300);
|
|
735
737
|
|
package/utils/utilHelper.js
CHANGED
|
@@ -38,20 +38,18 @@ export function cloneDeep(entity, cache = new WeakMap()) {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
|
-
|
|
41
|
+
Creates a debounced function with delay (same as lodash.debounce).
|
|
42
42
|
@param {Function} func
|
|
43
|
-
@param {Number}
|
|
43
|
+
@param {Number} ms
|
|
44
44
|
|
|
45
45
|
@returns {Function}
|
|
46
46
|
*/
|
|
47
|
-
export function
|
|
47
|
+
export function createDebounce(func, ms) {
|
|
48
48
|
let timeout;
|
|
49
49
|
|
|
50
|
-
return function (
|
|
51
|
-
const context = this;
|
|
52
|
-
|
|
50
|
+
return function () {
|
|
53
51
|
clearTimeout(timeout);
|
|
54
|
-
timeout = setTimeout(() => func.apply(
|
|
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.
|
|
4
|
+
"version": "0.0.381",
|
|
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
|
|
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
|
|
5430
|
+
"type": "number|string"
|
|
5431
5431
|
},
|
|
5432
5432
|
"default": "300"
|
|
5433
5433
|
},
|