@volverjs/ui-vue 0.0.9-beta.10 → 0.0.9-beta.11

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.
@@ -1,6 +1,6 @@
1
1
  import { unref, inject, computed, toRef, toRefs, defineComponent, useAttrs, ref, openBlock, createElementBlock, normalizeClass, createElementVNode, withModifiers, renderSlot, normalizeProps, guardReactiveProps, createTextVNode, toDisplayString, isRef, provide, watchEffect, watch, Fragment, renderList, createBlock, mergeProps, withCtx, resolveDynamicComponent, createCommentVNode, useSlots, h, onMounted, withDirectives, vModelCheckbox, createVNode, createSlots, nextTick, Transition, toHandlers, normalizeStyle, vShow, vModelSelect, vModelText, vModelDynamic, vModelRadio } from "vue";
2
2
  import { nanoid } from "nanoid";
3
- import { useToggle, useStorage, useVModel, useMutationObserver, onClickOutside, useFocusWithin, onKeyStroke, useElementHover, useFocus, useElementVisibility, refDebounced } from "@vueuse/core";
3
+ import { useToggle, useStorage, useVModel, useMutationObserver, onClickOutside, useFocusWithin, onKeyStroke, useElementHover, useFocus, useElementVisibility, refDebounced, computedAsync } from "@vueuse/core";
4
4
  import { iconExists, Icon, addIcon } from "@iconify/vue";
5
5
  import { get } from "ts-dot-prop";
6
6
  import { autoPlacement, flip, shift, size, offset, arrow, useFloating, autoUpdate } from "@floating-ui/vue";
@@ -3669,7 +3669,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
3669
3669
  expanded.value = false;
3670
3670
  };
3671
3671
  const onAfterExpand = () => {
3672
- if (searchable.value) {
3672
+ if (propsDefaults.value.searchable) {
3673
3673
  if (inputSearchEl.value) {
3674
3674
  inputSearchEl.value.focus({
3675
3675
  preventScroll: true
@@ -3678,7 +3678,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
3678
3678
  }
3679
3679
  };
3680
3680
  const onAfterCollapse = () => {
3681
- if (searchable.value) {
3681
+ if (propsDefaults.value.searchable) {
3682
3682
  searchText.value = "";
3683
3683
  }
3684
3684
  };
@@ -3692,14 +3692,15 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
3692
3692
  loading,
3693
3693
  valid,
3694
3694
  invalid,
3695
- floating,
3696
- searchable
3695
+ floating
3697
3696
  } = toRefs(props);
3698
3697
  const hasId = useUniqueId(id);
3699
3698
  const hasHintId = computed(() => `${hasId.value}-hint`);
3700
3699
  const hasDropdownId = computed(() => `${hasId.value}-dropdown`);
3701
3700
  const hasSearchId = computed(() => `${hasId.value}-search`);
3702
3701
  const hasLabelId = computed(() => `${hasId.value}-label`);
3702
+ const localLoading = ref(false);
3703
+ const isLoading = computed(() => localLoading.value || loading.value);
3703
3704
  const dropdownEl = ref();
3704
3705
  const { hasIcon, hasIconBefore, hasIconAfter } = useComponentIcon(
3705
3706
  icon,
@@ -3714,7 +3715,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
3714
3715
  modifiers,
3715
3716
  computed(() => ({
3716
3717
  disabled: disabled.value,
3717
- loading: loading.value,
3718
+ loading: isLoading.value,
3718
3719
  readonly: readonly.value,
3719
3720
  "icon-before": Boolean(hasIconBefore.value),
3720
3721
  "icon-after": Boolean(hasIconAfter.value),
@@ -3732,13 +3733,18 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
3732
3733
  getOptionDisabled,
3733
3734
  getOptionGrouped
3734
3735
  } = useOptions(props);
3735
- const filteredOptions = computed(() => {
3736
+ const filteredOptions = computedAsync(async () => {
3736
3737
  var _a;
3737
3738
  if (propsDefaults.value.searchFunction) {
3738
- return propsDefaults.value.searchFunction(
3739
- debouncedSearchText.value,
3740
- props.options
3739
+ localLoading.value = true;
3740
+ const toReturn = await Promise.resolve(
3741
+ propsDefaults.value.searchFunction(
3742
+ debouncedSearchText.value,
3743
+ props.options
3744
+ )
3741
3745
  );
3746
+ localLoading.value = false;
3747
+ return toReturn;
3742
3748
  }
3743
3749
  return (_a = props.options) == null ? void 0 : _a.filter((option) => {
3744
3750
  return getOptionLabel(option).toLowerCase().includes(debouncedSearchText.value.toLowerCase().trim());
@@ -3816,7 +3822,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
3816
3822
  invalid: invalid.value,
3817
3823
  invalidLabel: propsDefaults.value.invalidLabel,
3818
3824
  hintLabel: propsDefaults.value.hintLabel,
3819
- loading: loading.value,
3825
+ loading: isLoading.value,
3820
3826
  loadingLabel: propsDefaults.value.loadingLabel,
3821
3827
  disabled: disabled.value,
3822
3828
  readonly: readonly.value,
@@ -3844,7 +3850,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
3844
3850
  flip: propsDefaults.value.flip,
3845
3851
  autoPlacement: propsDefaults.value.autoPlacement,
3846
3852
  arrow: propsDefaults.value.arrow,
3847
- autofocusFirst: searchable.value ? true : propsDefaults.value.autofocusFirst,
3853
+ autofocusFirst: propsDefaults.value.searchable ? true : propsDefaults.value.autofocusFirst,
3848
3854
  triggerWidth: propsDefaults.value.triggerWidth,
3849
3855
  modifiers: propsDefaults.value.dropdownModifiers
3850
3856
  }));
@@ -3876,7 +3882,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
3876
3882
  _ctx.label ? (openBlock(), createElementBlock("label", {
3877
3883
  key: 0,
3878
3884
  id: unref(hasLabelId),
3879
- for: unref(searchable) ? unref(hasSearchId) : void 0
3885
+ for: unref(propsDefaults).searchable ? unref(hasSearchId) : void 0
3880
3886
  }, toDisplayString(_ctx.label), 9, _hoisted_2$5)) : createCommentVNode("", true),
3881
3887
  createElementVNode("div", {
3882
3888
  ref_key: "wrapperEl",
@@ -3950,87 +3956,90 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
3950
3956
  renderSlot(_ctx.$slots, "after", normalizeProps(guardReactiveProps(unref(slotProps))))
3951
3957
  ])) : createCommentVNode("", true)
3952
3958
  ]),
3953
- items: withCtx(() => [
3954
- unref(filteredOptions).length ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(unref(filteredOptions), (option, index) => {
3955
- return openBlock(), createElementBlock(Fragment, { key: index }, [
3956
- isGroup(option) ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
3957
- createVNode(_sfc_main$b, {
3958
- label: unref(getOptionLabel)(option)
3959
- }, null, 8, ["label"]),
3960
- (openBlock(true), createElementBlock(Fragment, null, renderList(unref(getOptionGrouped)(
3961
- option
3962
- ), (item, i) => {
3963
- return openBlock(), createBlock(_sfc_main$c, mergeProps({
3964
- disabled: unref(getOptionDisabled)(item),
3965
- selected: getOptionSelected(item),
3966
- unselectable: _ctx.unselectable,
3967
- deselectHintLabel: unref(propsDefaults).deselectHintLabel,
3968
- selectHintLabel: unref(propsDefaults).selectHintLabel,
3969
- selectedHintLabel: unref(propsDefaults).selectedHintLabel
3970
- }, {
3971
- key: i,
3972
- class: "vv-dropdown-option",
3973
- onClickPassive: ($event) => onInput(item)
3974
- }), {
3975
- default: withCtx(() => [
3976
- renderSlot(_ctx.$slots, "option", normalizeProps(guardReactiveProps({
3977
- option,
3978
- selectedOptions: unref(selectedOptions),
3979
- selected: getOptionSelected(item),
3980
- disabled: unref(getOptionDisabled)(item)
3981
- })), () => [
3982
- createTextVNode(toDisplayString(unref(getOptionLabel)(item)), 1)
3983
- ])
3984
- ]),
3985
- _: 2
3986
- }, 1040, ["onClickPassive"]);
3987
- }), 128))
3988
- ], 64)) : (openBlock(), createBlock(_sfc_main$c, mergeProps({ key: 1 }, {
3989
- disabled: unref(getOptionDisabled)(option),
3990
- selected: getOptionSelected(option),
3991
- unselectable: _ctx.unselectable,
3992
- deselectHintLabel: unref(propsDefaults).deselectHintLabel,
3993
- selectHintLabel: unref(propsDefaults).selectHintLabel,
3994
- selectedHintLabel: unref(propsDefaults).selectedHintLabel
3995
- }, {
3996
- class: "vv-dropdown-option",
3997
- onClickPassive: ($event) => onInput(option)
3998
- }), {
3999
- default: withCtx(() => [
4000
- renderSlot(_ctx.$slots, "option", normalizeProps(guardReactiveProps({
4001
- option,
4002
- selectedOptions: unref(selectedOptions),
4003
- selected: getOptionSelected(option),
4004
- disabled: unref(getOptionDisabled)(option)
4005
- })), () => [
4006
- createTextVNode(toDisplayString(unref(getOptionLabel)(option)), 1)
4007
- ])
4008
- ]),
4009
- _: 2
4010
- }, 1040, ["onClickPassive"]))
4011
- ], 64);
4012
- }), 128)) : !_ctx.options.length ? (openBlock(), createBlock(_sfc_main$c, {
4013
- key: 1,
4014
- modifiers: "inert"
4015
- }, {
4016
- default: withCtx(() => [
4017
- renderSlot(_ctx.$slots, "no-options", {}, () => [
4018
- createTextVNode(toDisplayString(unref(propsDefaults).noOptionsLabel), 1)
4019
- ])
4020
- ]),
4021
- _: 3
4022
- })) : (openBlock(), createBlock(_sfc_main$c, {
4023
- key: 2,
4024
- modifiers: "inert"
4025
- }, {
4026
- default: withCtx(() => [
4027
- renderSlot(_ctx.$slots, "no-results", {}, () => [
4028
- createTextVNode(toDisplayString(unref(propsDefaults).noResultsLabel), 1)
4029
- ])
4030
- ]),
4031
- _: 3
4032
- }))
4033
- ]),
3959
+ items: withCtx(() => {
3960
+ var _a;
3961
+ return [
3962
+ ((_a = unref(filteredOptions)) == null ? void 0 : _a.length) ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(unref(filteredOptions), (option, index) => {
3963
+ return openBlock(), createElementBlock(Fragment, { key: index }, [
3964
+ isGroup(option) ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
3965
+ createVNode(_sfc_main$b, {
3966
+ label: unref(getOptionLabel)(option)
3967
+ }, null, 8, ["label"]),
3968
+ (openBlock(true), createElementBlock(Fragment, null, renderList(unref(getOptionGrouped)(
3969
+ option
3970
+ ), (item, i) => {
3971
+ return openBlock(), createBlock(_sfc_main$c, mergeProps({
3972
+ disabled: unref(getOptionDisabled)(item),
3973
+ selected: getOptionSelected(item),
3974
+ unselectable: _ctx.unselectable,
3975
+ deselectHintLabel: unref(propsDefaults).deselectHintLabel,
3976
+ selectHintLabel: unref(propsDefaults).selectHintLabel,
3977
+ selectedHintLabel: unref(propsDefaults).selectedHintLabel
3978
+ }, {
3979
+ key: i,
3980
+ class: "vv-dropdown-option",
3981
+ onClickPassive: ($event) => onInput(item)
3982
+ }), {
3983
+ default: withCtx(() => [
3984
+ renderSlot(_ctx.$slots, "option", normalizeProps(guardReactiveProps({
3985
+ option,
3986
+ selectedOptions: unref(selectedOptions),
3987
+ selected: getOptionSelected(item),
3988
+ disabled: unref(getOptionDisabled)(item)
3989
+ })), () => [
3990
+ createTextVNode(toDisplayString(unref(getOptionLabel)(item)), 1)
3991
+ ])
3992
+ ]),
3993
+ _: 2
3994
+ }, 1040, ["onClickPassive"]);
3995
+ }), 128))
3996
+ ], 64)) : (openBlock(), createBlock(_sfc_main$c, mergeProps({ key: 1 }, {
3997
+ disabled: unref(getOptionDisabled)(option),
3998
+ selected: getOptionSelected(option),
3999
+ unselectable: _ctx.unselectable,
4000
+ deselectHintLabel: unref(propsDefaults).deselectHintLabel,
4001
+ selectHintLabel: unref(propsDefaults).selectHintLabel,
4002
+ selectedHintLabel: unref(propsDefaults).selectedHintLabel
4003
+ }, {
4004
+ class: "vv-dropdown-option",
4005
+ onClickPassive: ($event) => onInput(option)
4006
+ }), {
4007
+ default: withCtx(() => [
4008
+ renderSlot(_ctx.$slots, "option", normalizeProps(guardReactiveProps({
4009
+ option,
4010
+ selectedOptions: unref(selectedOptions),
4011
+ selected: getOptionSelected(option),
4012
+ disabled: unref(getOptionDisabled)(option)
4013
+ })), () => [
4014
+ createTextVNode(toDisplayString(unref(getOptionLabel)(option)), 1)
4015
+ ])
4016
+ ]),
4017
+ _: 2
4018
+ }, 1040, ["onClickPassive"]))
4019
+ ], 64);
4020
+ }), 128)) : !_ctx.options.length ? (openBlock(), createBlock(_sfc_main$c, {
4021
+ key: 1,
4022
+ modifiers: "inert"
4023
+ }, {
4024
+ default: withCtx(() => [
4025
+ renderSlot(_ctx.$slots, "no-options", {}, () => [
4026
+ createTextVNode(toDisplayString(unref(propsDefaults).noOptionsLabel), 1)
4027
+ ])
4028
+ ]),
4029
+ _: 3
4030
+ })) : (openBlock(), createBlock(_sfc_main$c, {
4031
+ key: 2,
4032
+ modifiers: "inert"
4033
+ }, {
4034
+ default: withCtx(() => [
4035
+ renderSlot(_ctx.$slots, "no-results", {}, () => [
4036
+ createTextVNode(toDisplayString(unref(propsDefaults).noResultsLabel), 1)
4037
+ ])
4038
+ ]),
4039
+ _: 3
4040
+ }))
4041
+ ];
4042
+ }),
4034
4043
  after: withCtx(() => [
4035
4044
  renderSlot(_ctx.$slots, "dropdown::after", {}, () => {
4036
4045
  var _a;
@@ -4046,11 +4055,11 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
4046
4055
  ]),
4047
4056
  _: 2
4048
4057
  }, [
4049
- unref(searchable) || _ctx.$slots["dropdown::before"] ? {
4058
+ unref(propsDefaults).searchable || _ctx.$slots["dropdown::before"] ? {
4050
4059
  name: "before",
4051
4060
  fn: withCtx(() => [
4052
4061
  renderSlot(_ctx.$slots, "dropdown::before"),
4053
- unref(searchable) ? withDirectives((openBlock(), createElementBlock("input", {
4062
+ unref(propsDefaults).searchable ? withDirectives((openBlock(), createElementBlock("input", {
4054
4063
  key: 0,
4055
4064
  id: unref(hasSearchId),
4056
4065
  ref_key: "inputSearchEl",