@volverjs/ui-vue 0.0.10-beta.71 → 0.0.10-beta.73

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.
Files changed (37) hide show
  1. package/dist/components/VvAlert/VvAlert.es.js +4 -4
  2. package/dist/components/VvAlert/VvAlert.umd.js +1 -1
  3. package/dist/components/VvAlertGroup/VvAlertGroup.es.js +4 -4
  4. package/dist/components/VvAlertGroup/VvAlertGroup.umd.js +1 -1
  5. package/dist/components/VvButton/VvButton.es.js +4 -4
  6. package/dist/components/VvButton/VvButton.umd.js +1 -1
  7. package/dist/components/VvCombobox/VvCombobox.es.js +141 -71
  8. package/dist/components/VvCombobox/VvCombobox.umd.js +1 -1
  9. package/dist/components/VvCombobox/VvCombobox.vue.d.ts +10 -3
  10. package/dist/components/VvCombobox/index.d.ts +35 -19
  11. package/dist/components/VvDropdown/VvDropdown.es.js +41 -22
  12. package/dist/components/VvDropdown/VvDropdown.umd.js +1 -1
  13. package/dist/components/VvDropdown/VvDropdown.vue.d.ts +4 -0
  14. package/dist/components/VvInputFile/VvInputFile.es.js +9 -9
  15. package/dist/components/VvInputFile/VvInputFile.umd.js +1 -1
  16. package/dist/components/VvInputText/VvInputText.es.js +54 -35
  17. package/dist/components/VvInputText/VvInputText.umd.js +1 -1
  18. package/dist/components/VvNav/VvNav.es.js +3 -1
  19. package/dist/components/VvNav/VvNav.umd.js +1 -1
  20. package/dist/components/VvNav/VvNavItem.vue.d.ts +4 -0
  21. package/dist/components/VvNavItem/VvNavItem.es.js +3 -1
  22. package/dist/components/VvNavItem/VvNavItem.umd.js +1 -1
  23. package/dist/components/VvSelect/VvSelect.es.js +34 -24
  24. package/dist/components/VvSelect/VvSelect.umd.js +1 -1
  25. package/dist/components/VvSelect/VvSelect.vue.d.ts +3 -1
  26. package/dist/components/VvSelect/index.d.ts +12 -19
  27. package/dist/components/VvTab/VvTab.es.js +3 -1
  28. package/dist/components/VvTab/VvTab.umd.js +1 -1
  29. package/dist/components/VvTextarea/VvTextarea.es.js +48 -29
  30. package/dist/components/VvTextarea/VvTextarea.umd.js +1 -1
  31. package/dist/components/index.es.js +153 -81
  32. package/dist/components/index.umd.js +1 -1
  33. package/dist/icons.es.js +3 -3
  34. package/dist/icons.umd.js +1 -1
  35. package/dist/props/index.d.ts +24 -0
  36. package/dist/stories/Combobox/Combobox.stories.d.ts +1 -0
  37. package/package.json +11 -11
@@ -1,4 +1,4 @@
1
- import { inject, computed, toRef, unref, defineComponent, useAttrs, useId, toRefs, ref, watch, onBeforeUnmount, createElementBlock, openBlock, normalizeClass, createElementVNode, withModifiers, renderSlot, normalizeProps, guardReactiveProps, createTextVNode, toDisplayString, onMounted, isRef, provide, watchEffect, reactive, nextTick, Fragment, renderList, createBlock, mergeProps, createSlots, withCtx, getCurrentInstance, resolveComponent, resolveDynamicComponent, mergeDefaults, createCommentVNode, createVNode, TransitionGroup, toHandlers, useSlots, h, withDirectives, vModelCheckbox, Transition, normalizeStyle, vShow, vModelSelect, vModelText, vModelRadio } from "vue";
1
+ import { inject, computed, toRef, unref, defineComponent, useAttrs, useId, toRefs, ref, watch, onBeforeUnmount, createElementBlock, openBlock, normalizeClass, createElementVNode, withModifiers, renderSlot, normalizeProps, guardReactiveProps, createTextVNode, toDisplayString, onMounted, isRef, provide, watchEffect, reactive, nextTick, Fragment, renderList, createBlock, mergeProps, createSlots, withCtx, getCurrentInstance, resolveComponent, resolveDynamicComponent, mergeDefaults, createCommentVNode, createVNode, TransitionGroup, toHandlers, useSlots, h, withDirectives, vModelCheckbox, Transition, normalizeStyle, vShow, vModelSelect, withKeys, vModelText, vModelRadio } from "vue";
2
2
  import { useVModel, useStorage, useMutationObserver, onClickOutside, useFocusWithin, useElementHover, onKeyStroke, useFocus, useElementVisibility, refDebounced, computedAsync } from "@vueuse/core";
3
3
  import mitt from "mitt";
4
4
  import { iconLoaded, Icon, addIcon } from "@iconify/vue";
@@ -6,6 +6,22 @@ import { get } from "ts-dot-prop";
6
6
  import { autoPlacement, flip, shift, size, offset, arrow, useFloating, autoUpdate } from "@floating-ui/vue";
7
7
  import Sortable from "vuedraggable";
8
8
  import { useIMask } from "vue-imask";
9
+ const ACTION_ICONS = {
10
+ showPassword: "eye-on",
11
+ hidePassword: "eye-off",
12
+ showDatePicker: "calendar",
13
+ showTimePicker: "time",
14
+ showColorPicker: "color",
15
+ clear: "close",
16
+ add: "add",
17
+ remove: "trash",
18
+ edit: "edit",
19
+ download: "download"
20
+ };
21
+ const VvIconPropsDefaults = {
22
+ prefix: "normal"
23
+ /* normal */
24
+ };
9
25
  var StorageType = /* @__PURE__ */ ((StorageType2) => {
10
26
  StorageType2["local"] = "local";
11
27
  StorageType2["session"] = "session";
@@ -206,6 +222,30 @@ const CurrentProps = {
206
222
  default: false
207
223
  }
208
224
  };
225
+ const ClearProps = {
226
+ /**
227
+ * If true, the clear button will be shown
228
+ */
229
+ showClearAction: {
230
+ type: Boolean,
231
+ default: false
232
+ },
233
+ /**
234
+ * VvIcon name for clear button
235
+ * @see VvIcon
236
+ */
237
+ iconClear: {
238
+ type: [String, Object],
239
+ default: ACTION_ICONS.clear
240
+ },
241
+ /**
242
+ * Label for clear button
243
+ */
244
+ labelClear: {
245
+ type: String,
246
+ default: "Clear"
247
+ }
248
+ };
209
249
  const PressedProps = {
210
250
  /**
211
251
  * Whether the item is pressed
@@ -1552,22 +1592,6 @@ function useVvAlert(props, emit) {
1552
1592
  }))
1553
1593
  };
1554
1594
  }
1555
- const ACTION_ICONS = {
1556
- showPassword: "eye-on",
1557
- hidePassword: "eye-off",
1558
- showDatePicker: "calendar",
1559
- showTimePicker: "time",
1560
- showColorPicker: "color",
1561
- clear: "close",
1562
- add: "add",
1563
- remove: "trash",
1564
- edit: "edit",
1565
- download: "download"
1566
- };
1567
- const VvIconPropsDefaults = {
1568
- prefix: "normal"
1569
- /* normal */
1570
- };
1571
1595
  const __default__$s = {
1572
1596
  name: "VvIcon"
1573
1597
  };
@@ -3336,6 +3360,7 @@ const VvComboboxProps = {
3336
3360
  ...DropdownProps,
3337
3361
  ...LabelProps,
3338
3362
  ...RequiredProps,
3363
+ ...ClearProps,
3339
3364
  /**
3340
3365
  * Dropdown show / hide transition name
3341
3366
  */
@@ -3374,6 +3399,10 @@ const VvComboboxProps = {
3374
3399
  * Label for deselected option hint
3375
3400
  */
3376
3401
  deselectHintLabel: { type: String, default: "Press enter to remove" },
3402
+ /**
3403
+ * Label for add new option hint
3404
+ */
3405
+ addOptionHintLabel: { type: String, default: "Press enter to add" },
3377
3406
  /**
3378
3407
  * Label close button
3379
3408
  */
@@ -3382,6 +3411,10 @@ const VvComboboxProps = {
3382
3411
  * Select input placeholder
3383
3412
  */
3384
3413
  placeholder: String,
3414
+ /**
3415
+ * The options to add new options
3416
+ */
3417
+ addable: Boolean,
3385
3418
  /**
3386
3419
  * Use input text to search on options
3387
3420
  */
@@ -3487,21 +3520,6 @@ const VvComboboxProps = {
3487
3520
  focusOnHover: {
3488
3521
  type: Boolean,
3489
3522
  default: true
3490
- },
3491
- /**
3492
- * VvIcon name for clear button
3493
- * @see VvIcon
3494
- */
3495
- iconClear: {
3496
- type: [String, Object],
3497
- default: ACTION_ICONS.clear
3498
- },
3499
- /**
3500
- * Label for clear button
3501
- */
3502
- labelClear: {
3503
- type: String,
3504
- default: "Clear"
3505
3523
  }
3506
3524
  };
3507
3525
  function useVvComboboxProps() {
@@ -3866,27 +3884,6 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
3866
3884
  function init(el) {
3867
3885
  referenceEl.value = el;
3868
3886
  }
3869
- __expose({
3870
- toggle,
3871
- show,
3872
- hide,
3873
- init,
3874
- customPosition: hasCustomPosition
3875
- });
3876
- watch(expanded, (newValue) => {
3877
- if (newValue && props.autofocusFirst) {
3878
- nextTick(() => {
3879
- const focusableElements = getKeyboardFocusableElements(
3880
- floatingEl.value
3881
- );
3882
- if (focusableElements.length > 0) {
3883
- focusableElements[0].focus({
3884
- preventScroll: true
3885
- });
3886
- }
3887
- });
3888
- }
3889
- });
3890
3887
  onClickOutside(
3891
3888
  floatingEl,
3892
3889
  () => {
@@ -3933,6 +3930,30 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
3933
3930
  (el) => !el.hasAttribute("disabled") && !el.getAttribute("aria-hidden")
3934
3931
  );
3935
3932
  }
3933
+ function focusFirst() {
3934
+ nextTick(() => {
3935
+ const focusableElements = getKeyboardFocusableElements(
3936
+ floatingEl.value
3937
+ );
3938
+ if (focusableElements.length > 0) {
3939
+ focusableElements[0].focus({
3940
+ preventScroll: true
3941
+ });
3942
+ }
3943
+ });
3944
+ }
3945
+ function focusFirstListElement() {
3946
+ nextTick(() => {
3947
+ const focusableElements = getKeyboardFocusableElements(
3948
+ listEl.value
3949
+ );
3950
+ if (focusableElements.length > 0) {
3951
+ focusableElements[0].focus({
3952
+ preventScroll: true
3953
+ });
3954
+ }
3955
+ });
3956
+ }
3936
3957
  function focusNext() {
3937
3958
  nextTick(() => {
3938
3959
  if (focused.value) {
@@ -3981,6 +4002,22 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
3981
4002
  }
3982
4003
  });
3983
4004
  }
4005
+ watch(expanded, (newValue) => {
4006
+ if (newValue && props.autofocusFirst) {
4007
+ focusFirst();
4008
+ }
4009
+ });
4010
+ __expose({
4011
+ toggle,
4012
+ show,
4013
+ hide,
4014
+ init,
4015
+ focusFirst,
4016
+ focusFirstListElement,
4017
+ focusNext,
4018
+ focusPrev,
4019
+ customPosition: hasCustomPosition
4020
+ });
3984
4021
  const hovered = useElementHover(floatingEl);
3985
4022
  const { itemRole } = useDropdownProvideItem({
3986
4023
  role,
@@ -4244,6 +4281,7 @@ const VvSelectProps = {
4244
4281
  ...FloatingLabelProps,
4245
4282
  ...UnselectableProps,
4246
4283
  ...LabelProps,
4284
+ ...ClearProps,
4247
4285
  /**
4248
4286
  * This Boolean attribute indicates that multiple options can be selected in the list.
4249
4287
  * If it is not specified, then only one option can be selected at a time.
@@ -4280,22 +4318,7 @@ const VvSelectProps = {
4280
4318
  /**
4281
4319
  * Select placeholder
4282
4320
  */
4283
- placeholder: String,
4284
- /**
4285
- * VvIcon name for clear button
4286
- * @see VvIcon
4287
- */
4288
- iconClear: {
4289
- type: [String, Object],
4290
- default: ACTION_ICONS.clear
4291
- },
4292
- /**
4293
- * Label for clear button
4294
- */
4295
- labelClear: {
4296
- type: String,
4297
- default: "Clear"
4298
- }
4321
+ placeholder: String
4299
4322
  };
4300
4323
  function useVvSelectProps() {
4301
4324
  return {
@@ -4572,7 +4595,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
4572
4595
  /* FULL_PROPS */
4573
4596
  )) : createCommentVNode("v-if", true)
4574
4597
  ]),
4575
- unref(isUnselectable) ? (openBlock(), createBlock(unref(VvInputClearAction), {
4598
+ unref(isUnselectable) && unref(propsDefaults).showClearAction ? (openBlock(), createBlock(unref(VvInputClearAction), {
4576
4599
  key: 1,
4577
4600
  "input-type": "select",
4578
4601
  label: _ctx.labelClear,
@@ -4657,7 +4680,7 @@ const __default__$b = {
4657
4680
  const _sfc_main$d = /* @__PURE__ */ defineComponent({
4658
4681
  ...__default__$b,
4659
4682
  props: useVvComboboxProps(),
4660
- emits: ["update:modelValue", "update:search", "focus", "blur", "clear", "change:search"],
4683
+ emits: ["update:modelValue", "update:search", "update:options", "focus", "blur", "clear", "change:search"],
4661
4684
  setup(__props, { emit: __emit }) {
4662
4685
  const props = __props;
4663
4686
  const emit = __emit;
@@ -4826,12 +4849,33 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
4826
4849
  "badges": props.badges
4827
4850
  }))
4828
4851
  );
4852
+ const addedOptions = ref(/* @__PURE__ */ new Set());
4829
4853
  const {
4830
4854
  getOptionLabel,
4831
4855
  getOptionValue,
4832
4856
  getOptionGrouped,
4833
4857
  isOptionDisabled
4834
4858
  } = useOptions(props);
4859
+ const hasOptions = computed(() => {
4860
+ const toReturn = [...props.options, ...addedOptions.value];
4861
+ for (const localModelValueItem of localModelValue.value) {
4862
+ if (!toReturn.some((option) => {
4863
+ const optionValue = getOptionValue(option);
4864
+ if (typeof optionValue === "object") {
4865
+ return JSON.stringify(optionValue) === JSON.stringify(localModelValueItem);
4866
+ }
4867
+ return optionValue === localModelValueItem;
4868
+ })) {
4869
+ toReturn.push(localModelValueItem);
4870
+ }
4871
+ }
4872
+ return toReturn;
4873
+ });
4874
+ watch(addedOptions, (newValue) => {
4875
+ if (newValue.size > 0) {
4876
+ emit("update:options", hasOptions.value);
4877
+ }
4878
+ });
4835
4879
  function isOptionDisabledOrNotSelectable(option) {
4836
4880
  return isOptionDisabled(option) || !isSelectable.value && !isOptionSelected(option);
4837
4881
  }
@@ -4842,13 +4886,13 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
4842
4886
  const toReturn = await Promise.resolve(
4843
4887
  propsDefaults.value.searchFunction(
4844
4888
  debouncedSearchText.value,
4845
- props.options
4889
+ hasOptions.value
4846
4890
  )
4847
4891
  );
4848
4892
  localLoading.value = false;
4849
4893
  return toReturn;
4850
4894
  }
4851
- return (_a = props.options) == null ? void 0 : _a.filter((option) => {
4895
+ return (_a = hasOptions.value) == null ? void 0 : _a.filter((option) => {
4852
4896
  return getOptionLabel(option).toLowerCase().includes(debouncedSearchText.value.toLowerCase().trim());
4853
4897
  });
4854
4898
  });
@@ -4865,7 +4909,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
4865
4909
  return localModelValue.value.includes(optionValue);
4866
4910
  }
4867
4911
  const selectedOptions = computed(() => {
4868
- const options = props.options.reduce(
4912
+ const toReturn = hasOptions.value.reduce(
4869
4913
  (acc, value) => {
4870
4914
  if (isGroup(value)) {
4871
4915
  return [...acc, ...getOptionGrouped(value)];
@@ -4874,7 +4918,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
4874
4918
  },
4875
4919
  []
4876
4920
  );
4877
- return options.filter((option) => {
4921
+ return toReturn.filter((option) => {
4878
4922
  return isOptionSelected(option);
4879
4923
  });
4880
4924
  });
@@ -4911,7 +4955,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
4911
4955
  emit("clear");
4912
4956
  }
4913
4957
  watch(
4914
- () => props.options,
4958
+ hasOptions,
4915
4959
  (newValue) => {
4916
4960
  if ((newValue == null ? void 0 : newValue.length) && props.autoselectFirst && !isDirty.value) {
4917
4961
  onInput(newValue[0]);
@@ -4980,6 +5024,31 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
4980
5024
  },
4981
5025
  { target: inputEl }
4982
5026
  );
5027
+ function onKeyupEnterInputSearch() {
5028
+ var _a, _b;
5029
+ if ((_a = filteredOptions.value) == null ? void 0 : _a.length) {
5030
+ if (filteredOptions.value.length === 1) {
5031
+ onInput(filteredOptions.value[0]);
5032
+ return;
5033
+ }
5034
+ (_b = dropdownEl.value) == null ? void 0 : _b.focusFirstListElement();
5035
+ return;
5036
+ }
5037
+ if (propsDefaults.value.addable) {
5038
+ const trimmedSearch = searchText.value.trim();
5039
+ if (!trimmedSearch) {
5040
+ return;
5041
+ }
5042
+ const exists = hasOptions.value.some(
5043
+ (opt) => getOptionLabel(opt).toLowerCase() === trimmedSearch.toLowerCase()
5044
+ );
5045
+ if (exists) {
5046
+ return;
5047
+ }
5048
+ addedOptions.value.add(trimmedSearch);
5049
+ onInput(trimmedSearch);
5050
+ }
5051
+ }
4983
5052
  return (_ctx, _cache) => {
4984
5053
  return !_ctx.native ? (openBlock(), createElementBlock("div", {
4985
5054
  key: 0,
@@ -5103,7 +5172,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
5103
5172
  /* FULL_PROPS */
5104
5173
  )) : createCommentVNode("v-if", true)
5105
5174
  ]),
5106
- unref(isUnselectable) ? (openBlock(), createBlock(unref(VvInputClearAction), {
5175
+ unref(isUnselectable) && unref(propsDefaults).showClearAction ? (openBlock(), createBlock(unref(VvInputClearAction), {
5107
5176
  key: 1,
5108
5177
  "input-type": "select",
5109
5178
  label: _ctx.labelClear,
@@ -5237,7 +5306,7 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
5237
5306
  default: withCtx(() => [
5238
5307
  renderSlot(_ctx.$slots, "no-results", {}, () => [
5239
5308
  createTextVNode(
5240
- toDisplayString(unref(propsDefaults).noResultsLabel),
5309
+ toDisplayString(unref(propsDefaults).addable ? unref(propsDefaults).addOptionHintLabel : unref(propsDefaults).noResultsLabel),
5241
5310
  1
5242
5311
  /* TEXT */
5243
5312
  )
@@ -5280,8 +5349,9 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
5280
5349
  spellcheck: "false",
5281
5350
  type: "search",
5282
5351
  class: "vv-dropdown__search",
5283
- placeholder: unref(propsDefaults).searchPlaceholder
5284
- }, null, 8, _hoisted_3$4)), [
5352
+ placeholder: unref(propsDefaults).searchPlaceholder,
5353
+ onKeyup: withKeys(onKeyupEnterInputSearch, ["enter"])
5354
+ }, null, 40, _hoisted_3$4)), [
5285
5355
  [vModelText, unref(searchText)]
5286
5356
  ]) : createCommentVNode("v-if", true)
5287
5357
  ]),
@@ -7429,6 +7499,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
7429
7499
  setup(__props) {
7430
7500
  return (_ctx, _cache) => {
7431
7501
  return openBlock(), createElementBlock("li", _hoisted_1$4, [
7502
+ renderSlot(_ctx.$slots, "before"),
7432
7503
  createVNode(
7433
7504
  _sfc_main$v,
7434
7505
  mergeProps(_ctx.$attrs, {
@@ -7444,7 +7515,8 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
7444
7515
  },
7445
7516
  16
7446
7517
  /* FULL_PROPS */
7447
- )
7518
+ ),
7519
+ renderSlot(_ctx.$slots, "after")
7448
7520
  ]);
7449
7521
  };
7450
7522
  }