vueless 0.0.412 → 0.0.414

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.
@@ -26,12 +26,12 @@
26
26
  @keydown.enter.tab.stop.self="dropdownListRef.addPointerElement"
27
27
  @keyup.esc="deactivate"
28
28
  >
29
- <!-- @slot Use it to add something after input. -->
29
+ <!-- @slot Use it to add something right. -->
30
30
  <slot name="right" />
31
31
 
32
32
  <div v-if="hasSlotContent($slots['right-icon']) || rightIcon" v-bind="rightIconWrapperAttrs">
33
33
  <!--
34
- @slot Use it to add icon after option.
34
+ @slot Use it to add icon right.
35
35
  @binding {string} icon-name
36
36
  @binding {string} icon-size
37
37
  -->
@@ -68,6 +68,7 @@
68
68
  @slot Use it to add something instead of the toggle icon.
69
69
  @binding {string} icon-name
70
70
  @binding {string} icon-size
71
+ @binding {boolean} opened
71
72
  -->
72
73
  <slot
73
74
  name="toggle"
@@ -88,7 +89,7 @@
88
89
  </div>
89
90
 
90
91
  <div
91
- v-if="isLocalValue && !noClear && !disabled && !multiple"
92
+ v-if="isLocalValue && !clearable && !disabled && !multiple"
92
93
  v-bind="clearAttrs"
93
94
  @mousedown="removeElement"
94
95
  >
@@ -127,7 +128,7 @@
127
128
  v-bind="leftIconWrapperAttrs"
128
129
  >
129
130
  <!--
130
- @slot Use it to add icon before option.
131
+ @slot Use it to add icon left.
131
132
  @binding {string} icon-name
132
133
  @binding {string} icon-size
133
134
  -->
@@ -143,14 +144,14 @@
143
144
  </span>
144
145
 
145
146
  <span v-if="hasSlotContent($slots['left'])" ref="leftSlotWrapperRef">
146
- <!-- @slot Use it to add something before input. -->
147
+ <!-- @slot Use it to add something left. -->
147
148
  <slot name="left" />
148
149
  </span>
149
150
 
150
151
  <div v-if="multiple && localValue.length" v-bind="selectedLabelsAttrs">
151
152
  <span v-for="item in localValue" :key="item[valueKey]" v-bind="selectedLabelAttrs">
152
153
  <!--
153
- @slot Use it to add selected value label.
154
+ @slot Use it to customise selected value label.
154
155
  @binding {string} selected-label
155
156
  -->
156
157
  <slot
@@ -243,8 +244,8 @@
243
244
  </span>
244
245
 
245
246
  <div
246
- v-if="isLocalValue && !noClear && !disabled && multiple"
247
- v-bind="clearMultipleTextAllAttrs"
247
+ v-if="isLocalValue && !clearable && !disabled && multiple"
248
+ v-bind="clearMultipleTextAttrs"
248
249
  @mousedown.prevent.capture="removeElement(localValue)"
249
250
  @click.prevent.capture
250
251
  v-text="currentLocale.clear"
@@ -264,23 +265,24 @@
264
265
  :add-option="addOption"
265
266
  tabindex="-1"
266
267
  v-bind="dropdownListAttrs"
268
+ @add="onAddOption"
267
269
  @focus="activate"
268
- @add-option="onAddOption"
269
270
  @mousedown.prevent.capture
270
271
  @click.prevent.capture
271
272
  >
272
273
  <template #before-option="{ option, index }">
273
274
  <!--
274
275
  @slot Use it to add something before option.
275
- @binding {other} option
276
+ @binding {object} option
277
+ @binding {number} index
276
278
  -->
277
279
  <slot name="before-option" :option="option" :index="index" />
278
280
  </template>
279
281
 
280
282
  <template #option="{ option, index }">
281
283
  <!--
282
- @slot Use it to add something instead of option.
283
- @binding {other} option
284
+ @slot Use it to customise the option.
285
+ @binding {object} option
284
286
  @binding {number} index
285
287
  -->
286
288
  <slot name="option" :option="option" :index="index" />
@@ -289,7 +291,8 @@
289
291
  <template #after-option="{ option, index }">
290
292
  <!--
291
293
  @slot Use it to add something after option.
292
- @binding {other} option
294
+ @binding {object} option
295
+ @binding {number} index
293
296
  -->
294
297
  <slot name="after-option" :option="option" :index="index" />
295
298
  </template>
@@ -472,9 +475,9 @@ const props = defineProps({
472
475
  /**
473
476
  * Allow clearing selected value.
474
477
  */
475
- noClear: {
478
+ clearable: {
476
479
  type: Boolean,
477
- default: getDefault(defaultConfig, USelect).noClear,
480
+ default: getDefault(defaultConfig, USelect).clearable,
478
481
  },
479
482
 
480
483
  /**
@@ -536,19 +539,19 @@ const props = defineProps({
536
539
 
537
540
  const emit = defineEmits([
538
541
  /**
539
- * Triggers when dropdown list is opened.
542
+ * Triggers when a dropdown list is opened.
540
543
  * @property {string} propsId
541
544
  */
542
545
  "open",
543
546
 
544
547
  /**
545
- * Triggers when dropdown list is closed.
548
+ * Triggers when a dropdown list is closed.
546
549
  * @property {string} propsId
547
550
  */
548
551
  "close",
549
552
 
550
553
  /**
551
- * Triggers when the input value is changed.
554
+ * Triggers when the search value is changed.
552
555
  */
553
556
  "searchChange",
554
557
 
@@ -566,9 +569,9 @@ const emit = defineEmits([
566
569
  "update:modelValue",
567
570
 
568
571
  /**
569
- * Triggers when dropdown options list is updated.
572
+ * Triggers on click on add new option button in the dropdown.
570
573
  */
571
- "addOption",
574
+ "add",
572
575
 
573
576
  /**
574
577
  * Triggers when the user commits the change to options or selected value explicitly.
@@ -626,7 +629,7 @@ const {
626
629
  afterCaretAttrs,
627
630
  toggleAttrs,
628
631
  clearAttrs,
629
- clearMultipleTextAllAttrs,
632
+ clearMultipleTextAttrs,
630
633
  clearMultipleAttrs,
631
634
  searchAttrs,
632
635
  searchInputAttrs,
@@ -754,18 +757,18 @@ function onKeydownAddOption(event) {
754
757
  const isMeta = event.metaKey;
755
758
 
756
759
  if (isMeta && isEnter && isMac) {
757
- emit("addOption");
760
+ emit("add");
758
761
  emit("change", { value: dropdownValue.value, options: props.options });
759
762
  }
760
763
 
761
764
  if (isEnter && isCtrl && !isMac) {
762
- emit("addOption");
765
+ emit("add");
763
766
  emit("change", { value: dropdownValue.value, options: props.options });
764
767
  }
765
768
  }
766
769
 
767
770
  function onAddOption() {
768
- emit("addOption");
771
+ emit("add");
769
772
  }
770
773
 
771
774
  function filterAndFlat(options, search, label) {
@@ -831,7 +834,7 @@ function adjustPosition() {
831
834
  function removeElement(option, shouldClose = true) {
832
835
  if (props.disabled) return;
833
836
 
834
- if (props.noClear && !props.multiple) {
837
+ if (props.clearable && !props.multiple) {
835
838
  deactivate();
836
839
 
837
840
  return;
@@ -1,7 +1,7 @@
1
1
  export default /*tw*/ {
2
2
  selectLabel: "{ULabel}",
3
- labelWrapperTop: "group/top", // applies when an open direction is top
4
- labelWrapperActive: "group/active",
3
+ selectLabelActive: "group/active",
4
+ selectLabelOpenDirectionTop: "group/top",
5
5
  wrapper: {
6
6
  base: `
7
7
  py-2 flex flex-row-reverse justify-between w-full min-h-full box-border relative
@@ -27,7 +27,7 @@ export default /*tw*/ {
27
27
  { labelAlign: "topInside", label: true, size: "lg", class: "pt-7" },
28
28
  ],
29
29
  },
30
- wrapperActive: "z-[inherit]", // applies when select active
30
+ wrapperActive: "z-[inherit]",
31
31
  innerWrapper: {
32
32
  base: "px-3 flex min-h-full w-full overflow-hidden justify-between",
33
33
  variants: {
@@ -81,7 +81,7 @@ export default /*tw*/ {
81
81
  clearIcon: "{UIcon}",
82
82
  clearMultiple: "flex items-center",
83
83
  clearMultipleIcon: "{UIcon}",
84
- clearMultipleTextAll: {
84
+ clearMultipleText: {
85
85
  base: "cursor-pointer flex items-center text-sm font-normal text-gray-400 hover:text-gray-500 transition",
86
86
  compoundVariants: [
87
87
  { size: "sm", class: "text-xs" },
@@ -89,7 +89,8 @@ export default /*tw*/ {
89
89
  { size: "lg", class: "text-base" },
90
90
  ],
91
91
  },
92
- search: "flex w-full",
92
+ search: "flex w-0",
93
+ searchActive: "w-full",
93
94
  searchInput: {
94
95
  base: `
95
96
  p-0 font-normal leading-none text-gray-900 relative w-full border-none bg-transparent
@@ -122,7 +123,7 @@ export default /*tw*/ {
122
123
  multiple: false,
123
124
  disabled: false,
124
125
  searchable: true,
125
- noClear: false,
126
+ clearable: true,
126
127
  addOption: false,
127
128
  /* icons */
128
129
  dropdownIcon: "expand_more",
@@ -15,7 +15,7 @@ export default {
15
15
  component: USelect,
16
16
  args: {
17
17
  label: "Label",
18
- modelValue: "",
18
+ modelValue: null,
19
19
  options: [
20
20
  { id: 1, label: "value 1", badge: "10%" },
21
21
  { id: 2, label: "value 2", badge: "20%" },
@@ -25,7 +25,7 @@ export default {
25
25
  },
26
26
  argTypes: {
27
27
  ...getArgTypes(USelect.__name),
28
- modelValue: { control: { type: "text" } },
28
+ modelValue: { control: { type: "number" } },
29
29
  },
30
30
  parameters: {
31
31
  docs: {
@@ -14,19 +14,25 @@ export default function useAttrs(props, { isTop, isOpen, selectedLabel: selected
14
14
  label: Boolean(props.label),
15
15
  }));
16
16
 
17
- const extendingKeys = ["caret", "wrapperActive", "labelWrapperActive", "labelWrapperTop"];
17
+ const extendingKeys = [
18
+ "caret",
19
+ "searchActive",
20
+ "wrapperActive",
21
+ "selectLabelActive",
22
+ "selectLabelOpenDirectionTop",
23
+ ];
18
24
  const extendingKeysClasses = getExtendingKeysClasses(extendingKeys, mutatedProps);
19
25
 
20
26
  const keysAttrs = getKeysAttrs(mutatedProps, extendingKeys, {
21
- wrapper: {
22
- extend: computed(() => [isOpen.value && extendingKeysClasses.wrapperActive.value]),
23
- },
24
- label: {
27
+ selectLabel: {
25
28
  extend: computed(() => [
26
- isOpen.value && extendingKeysClasses.labelWrapperActive.value,
27
- isTop.value && extendingKeysClasses.labelWrapperTop.value,
29
+ isOpen.value && extendingKeysClasses.selectLabelActive.value,
30
+ isTop.value && extendingKeysClasses.selectLabelOpenDirectionTop.value,
28
31
  ]),
29
32
  },
33
+ wrapper: {
34
+ extend: computed(() => [isOpen.value && extendingKeysClasses.wrapperActive.value]),
35
+ },
30
36
  toggle: {
31
37
  base: computed(() => [extendingKeysClasses.caret.value]),
32
38
  },
@@ -43,7 +49,9 @@ export default function useAttrs(props, { isTop, isOpen, selectedLabel: selected
43
49
  base: computed(() => [extendingKeysClasses.caret.value]),
44
50
  },
45
51
  search: {
46
- extend: computed(() => [Boolean(selectedLabelValue.value) && !isOpen.value && "w-0"]),
52
+ extend: computed(() => [
53
+ (!selectedLabelValue.value || isOpen.value) && extendingKeysClasses.searchActive.value,
54
+ ]),
47
55
  },
48
56
  });
49
57