vueless 0.0.379 → 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.
@@ -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.379",
3
+ "version": "0.0.381",
4
4
  "license": "MIT",
5
5
  "description": "Vue Styleless Component Framework.",
6
6
  "homepage": "https://vueless.com",
@@ -45,16 +45,12 @@ export default {
45
45
  const DefaultTemplate = (args) => ({
46
46
  components: { UDataList, UIcon, URow, UButton },
47
47
  setup() {
48
- function onDragSort(value) {
49
- this.list = value;
50
- }
51
-
52
48
  const slots = getSlotNames(UDataList.__name);
53
49
 
54
- return { args, slots, onDragSort };
50
+ return { args, slots };
55
51
  },
56
52
  template: `
57
- <UDataList v-bind="args" @dragSort="onDragSort">
53
+ <UDataList v-bind="args">
58
54
  ${args.slotTemplate || getSlotsFragment()}
59
55
  </UDataList>
60
56
  `,
@@ -54,7 +54,6 @@
54
54
  ref="dropdownListRef"
55
55
  :size="size"
56
56
  :options="options"
57
- :value-key="valueKey"
58
57
  :label-key="labelKey"
59
58
  v-bind="dropdownListAttrs"
60
59
  :data-test="`${dataTest}-list`"
@@ -105,14 +104,6 @@ const props = defineProps({
105
104
  default: getDefault(defaultConfig, UDropdownBadge).labelKey,
106
105
  },
107
106
 
108
- /**
109
- * Value key in the item object of options.
110
- */
111
- valueKey: {
112
- type: String,
113
- default: getDefault(defaultConfig, UDropdownBadge).valueKey,
114
- },
115
-
116
107
  /**
117
108
  * Badge variant.
118
109
  * @values primary, secondary, thirdary
@@ -13,11 +13,7 @@ export default {
13
13
  component: UDropdownBadge,
14
14
  args: {
15
15
  label: "Dropdown",
16
- options: [
17
- { label: "option 1", id: "1" },
18
- { label: "option 2", id: "2" },
19
- { label: "option 3", id: "3" },
20
- ],
16
+ options: [{ label: "option 1" }, { label: "option 2" }, { label: "option 3" }],
21
17
  },
22
18
  argTypes: {
23
19
  ...getArgTypes(UDropdownBadge.__name),
@@ -55,7 +55,6 @@
55
55
  ref="dropdownListRef"
56
56
  :size="size"
57
57
  :options="options"
58
- :value-key="valueKey"
59
58
  :label-key="labelKey"
60
59
  v-bind="dropdownListAttrs"
61
60
  :data-test="`${dataTest}-list`"
@@ -107,14 +106,6 @@ const props = defineProps({
107
106
  default: getDefault(defaultConfig, UDropdownButton).labelKey,
108
107
  },
109
108
 
110
- /**
111
- * Value key in the item object of options.
112
- */
113
- valueKey: {
114
- type: String,
115
- default: getDefault(defaultConfig, UDropdownButton).valueKey,
116
- },
117
-
118
109
  /**
119
110
  * Button variant.
120
111
  * @values primary, secondary, thirdary
@@ -14,11 +14,7 @@ export default {
14
14
  component: UDropdownButton,
15
15
  args: {
16
16
  label: "Dropdown",
17
- options: [
18
- { label: "option 1", id: "1" },
19
- { label: "option 2", id: "2" },
20
- { label: "option 3", id: "3" },
21
- ],
17
+ options: [{ label: "option 1" }, { label: "option 2" }, { label: "option 3" }],
22
18
  },
23
19
  argTypes: {
24
20
  ...getArgTypes(UDropdownButton.__name),
@@ -58,7 +58,6 @@
58
58
  ref="dropdownListRef"
59
59
  :size="size"
60
60
  :options="options"
61
- :value-key="valueKey"
62
61
  :label-key="labelKey"
63
62
  :data-test="`${dataTest}-list`"
64
63
  v-bind="dropdownListAttrs"
@@ -110,14 +109,6 @@ const props = defineProps({
110
109
  default: getDefault(defaultConfig, UDropdownLink).labelKey,
111
110
  },
112
111
 
113
- /**
114
- * Value key in the item object of options.
115
- */
116
- valueKey: {
117
- type: String,
118
- default: getDefault(defaultConfig, UDropdownLink).valueKey,
119
- },
120
-
121
112
  /**
122
113
  * Link color.
123
114
  * @values brand, grayscale, gray, red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose, white
@@ -16,7 +16,7 @@ export default /*tw*/ {
16
16
  variants: {
17
17
  error: {
18
18
  true: `
19
- border-red-300
19
+ border-red-300 bg-red-50
20
20
  hover:border-red-400 hover:focus-within:border-red-500
21
21
  focus-within:border-red-500 focus-within:ring-red-700/15
22
22
  `,
@@ -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.379",
4
+ "version": "0.0.381",
5
5
  "contributions": {
6
6
  "html": {
7
7
  "description-markup": "markdown",
@@ -3108,15 +3108,6 @@
3108
3108
  },
3109
3109
  "default": "label"
3110
3110
  },
3111
- {
3112
- "name": "valueKey",
3113
- "description": "Value key in the item object of options.",
3114
- "value": {
3115
- "kind": "expression",
3116
- "type": "string"
3117
- },
3118
- "default": "id"
3119
- },
3120
3111
  {
3121
3112
  "name": "variant",
3122
3113
  "description": "Badge variant.",
@@ -3297,15 +3288,6 @@
3297
3288
  },
3298
3289
  "default": "label"
3299
3290
  },
3300
- {
3301
- "name": "valueKey",
3302
- "description": "Value key in the item object of options.",
3303
- "value": {
3304
- "kind": "expression",
3305
- "type": "string"
3306
- },
3307
- "default": "id"
3308
- },
3309
3291
  {
3310
3292
  "name": "variant",
3311
3293
  "description": "Button variant.",
@@ -3510,15 +3492,6 @@
3510
3492
  },
3511
3493
  "default": "label"
3512
3494
  },
3513
- {
3514
- "name": "valueKey",
3515
- "description": "Value key in the item object of options.",
3516
- "value": {
3517
- "kind": "expression",
3518
- "type": "string"
3519
- },
3520
- "default": "id"
3521
- },
3522
3495
  {
3523
3496
  "name": "color",
3524
3497
  "description": "Link color.",
@@ -5410,7 +5383,7 @@
5410
5383
  "description": "Minimum character length for search.",
5411
5384
  "value": {
5412
5385
  "kind": "expression",
5413
- "type": "string|number"
5386
+ "type": "number|string"
5414
5387
  },
5415
5388
  "default": "0"
5416
5389
  },
@@ -5454,7 +5427,7 @@
5454
5427
  "name": "debounce",
5455
5428
  "value": {
5456
5429
  "kind": "expression",
5457
- "type": "string|number"
5430
+ "type": "number|string"
5458
5431
  },
5459
5432
  "default": "300"
5460
5433
  },