wave-ui 1.45.14 → 1.48.0

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.
@@ -1600,15 +1600,15 @@ var render$E = function() {
1600
1600
  var _c = _vm._self._c || _h;
1601
1601
  return _c("div", { staticClass: "w-confirm" }, [_c("w-menu", _vm._b({ scopedSlots: _vm._u([{ key: "activator", fn: function(ref) {
1602
1602
  var on = ref.on;
1603
- return [_c("w-button", _vm._g(_vm._b({ staticClass: "w-confirm__button" }, "w-button", _vm.buttonProps, false), on), [_vm._t("default")], 2)];
1603
+ return [_c("w-button", _vm._g(_vm._b({ staticClass: "w-confirm__button" }, "w-button", _vm.buttonProps, false), Object.assign({}, _vm.$listeners, on)), [_vm._t("default")], 2)];
1604
1604
  } }], null, true), model: { value: _vm.showPopup, callback: function($$v) {
1605
1605
  _vm.showPopup = $$v;
1606
1606
  }, expression: "showPopup" } }, "w-menu", _vm.wMenuProps, false), [_c("w-flex", { attrs: { "column": !_vm.inline, "align-center": "" } }, [_c("div", [_vm._t("question", function() {
1607
- return [_vm._v("Are you sure?")];
1608
- })], 2), _c("div", { staticClass: "w-flex justify-end", class: _vm.inline ? "ml2" : "mt2" }, [!_vm.noCancel ? _c("w-button", _vm._b({ staticClass: "mr2", attrs: { "bg-color": (_vm.cancelButton || {}).bgColor || "error" }, on: { "click": _vm.onCancel } }, "w-button", _vm.cancelButton, false), [_vm._t("cancel", function() {
1609
- return [_vm._v("Cancel")];
1610
- })], 2) : _vm._e(), _c("w-button", _vm._b({ attrs: { "bg-color": (_vm.confirmButton || {}).bgColor || "success" }, on: { "click": _vm.onConfirm } }, "w-button", _vm.confirmButton, false), [_vm._t("confirm", function() {
1611
- return [_vm._v("Confirm")];
1607
+ return [_vm._v(_vm._s(_vm.question))];
1608
+ })], 2), _c("div", { staticClass: "w-flex justify-end", class: _vm.inline ? "ml2" : "mt2" }, [_vm.cancel !== false ? _c("w-button", _vm._b({ staticClass: "mr2", attrs: { "bg-color": (_vm.cancelButton || {}).bgColor || "error" }, on: { "click": _vm.onCancel } }, "w-button", _vm.cancelButtonProps, false), [_vm._t("cancel", function() {
1609
+ return [_vm._v(_vm._s(_vm.cancelButton.label))];
1610
+ })], 2) : _vm._e(), _c("w-button", _vm._b({ attrs: { "bg-color": (_vm.confirmButton || {}).bgColor || "success" }, on: { "click": _vm.onConfirm } }, "w-button", _vm.confirmButtonProps, false), [_vm._t("confirm", function() {
1611
+ return [_vm._v(_vm._s(_vm.confirmButton.label))];
1612
1612
  })], 2)], 1)])], 1)], 1);
1613
1613
  };
1614
1614
  var staticRenderFns$E = [];
@@ -1619,9 +1619,9 @@ const __vue2_script$E = {
1619
1619
  color: { type: String },
1620
1620
  icon: { type: String },
1621
1621
  mainButton: { type: Object },
1622
- noCancel: { type: Boolean },
1623
- cancelButton: { type: [Boolean, Object] },
1624
- confirmButton: { type: Object },
1622
+ question: { type: String, default: "Are you sure?" },
1623
+ cancel: { type: [Boolean, Object, String], default: void 0 },
1624
+ confirm: { type: [Object, String] },
1625
1625
  inline: { type: Boolean },
1626
1626
  menu: { type: Object },
1627
1627
  noArrow: { type: Boolean },
@@ -1642,6 +1642,26 @@ const __vue2_script$E = {
1642
1642
  props: []
1643
1643
  }),
1644
1644
  computed: {
1645
+ cancelButton() {
1646
+ let button = { label: typeof this.cancel === "string" ? this.cancel : "Cancel" };
1647
+ if (typeof this.cancel === "object")
1648
+ button = Object.assign({}, button, this.cancel);
1649
+ return button;
1650
+ },
1651
+ cancelButtonProps() {
1652
+ const _a = this.cancelButton, { label } = _a, props = __objRest(_a, ["label"]);
1653
+ return props;
1654
+ },
1655
+ confirmButton() {
1656
+ let button = { label: typeof this.confirm === "string" ? this.confirm : "Confirm" };
1657
+ if (typeof this.confirm === "object")
1658
+ button = Object.assign({}, button, this.confirm);
1659
+ return button;
1660
+ },
1661
+ confirmButtonProps() {
1662
+ const _a = this.confirmButton, { label } = _a, props = __objRest(_a, ["label"]);
1663
+ return props;
1664
+ },
1645
1665
  wMenuProps() {
1646
1666
  return __spreadValues({
1647
1667
  top: this.top,
@@ -2511,7 +2531,6 @@ var wImage = /* @__PURE__ */ function() {
2511
2531
  return __component__$v.exports;
2512
2532
  }();
2513
2533
  var render$u = function() {
2514
- var _obj, _obj$1;
2515
2534
  var _vm = this;
2516
2535
  var _h = _vm.$createElement;
2517
2536
  var _c = _vm._self._c || _h;
@@ -2525,7 +2544,7 @@ var render$u = function() {
2525
2544
  return;
2526
2545
  }
2527
2546
  _vm.inputValue = $event.target.value;
2528
- } } }) : [_vm.labelPosition === "left" ? [_vm.$slots.default ? _c("label", { staticClass: "w-input__label w-input__label--left w-form-el-shakable", attrs: { "for": "w-input--" + _vm._uid } }, [_vm._t("default")], 2) : _vm.label ? _c("label", { staticClass: "w-input__label w-input__label--left w-form-el-shakable", attrs: { "for": "w-input--" + _vm._uid }, domProps: { "innerHTML": _vm._s(_vm.label) } }) : _vm._e()] : _vm._e(), _c("div", { staticClass: "w-input__input-wrap", class: _vm.inputWrapClasses }, [_vm.innerIconLeft ? _c("w-icon", { staticClass: "w-input__icon w-input__icon--inner-left", attrs: { "tag": "label", "for": "w-input--" + _vm._uid }, on: { "click": function($event) {
2547
+ } } }) : [_vm.labelPosition === "left" ? [_vm.$slots.default ? _c("label", { staticClass: "w-input__label w-input__label--left w-form-el-shakable", class: _vm.validationClasses, attrs: { "for": "w-input--" + _vm._uid } }, [_vm._t("default")], 2) : _vm.label ? _c("label", { staticClass: "w-input__label w-input__label--left w-form-el-shakable", class: _vm.validationClasses, attrs: { "for": "w-input--" + _vm._uid }, domProps: { "innerHTML": _vm._s(_vm.label) } }) : _vm._e()] : _vm._e(), _c("div", { staticClass: "w-input__input-wrap", class: _vm.inputWrapClasses }, [_vm.innerIconLeft ? _c("w-icon", { staticClass: "w-input__icon w-input__icon--inner-left", attrs: { "tag": "label", "for": "w-input--" + _vm._uid }, on: { "click": function($event) {
2529
2548
  return _vm.$emit("click:inner-icon-left", $event);
2530
2549
  } } }, [_vm._v(_vm._s(_vm.innerIconLeft))]) : _vm._e(), _vm.type === "checkbox" && _vm.type !== "file" ? _c("input", _vm._g(_vm._b({ directives: [{ name: "model", rawName: "v-model", value: _vm.inputValue, expression: "inputValue" }], ref: "input", staticClass: "w-input__input", attrs: { "id": "w-input--" + _vm._uid, "name": _vm.inputName, "placeholder": _vm.placeholder || null, "step": _vm.step || null, "min": _vm.min || null, "max": _vm.max || null, "minlength": _vm.minlength || null, "maxlength": _vm.maxlength || null, "readonly": _vm.isReadonly || null, "aria-readonly": _vm.isReadonly ? "true" : "false", "disabled": _vm.isDisabled || null, "required": _vm.required || null, "tabindex": _vm.tabindex || null, "type": "checkbox" }, domProps: { "checked": Array.isArray(_vm.inputValue) ? _vm._i(_vm.inputValue, null) > -1 : _vm.inputValue }, on: { "input": _vm.onInput, "focus": _vm.onFocus, "blur": _vm.onBlur, "change": function($event) {
2531
2550
  var $$a = _vm.inputValue, $$el = $event.target, $$c = $$el.checked ? true : false;
@@ -2546,15 +2565,15 @@ var render$u = function() {
2546
2565
  return;
2547
2566
  }
2548
2567
  _vm.inputValue = $event.target.value;
2549
- }, _vm.onInput], "focus": _vm.onFocus, "blur": _vm.onBlur } }, "input", _vm.attrs, false), _vm.listeners)) : [_c("input", _vm._b({ ref: "input", attrs: { "id": "w-input--" + _vm._uid, "type": "file", "name": _vm.name || null, "multiple": _vm.multiple || null }, on: { "focus": _vm.onFocus, "blur": _vm.onBlur, "change": _vm.onFileChange } }, "input", _vm.attrs, false)), _c("transition-group", { staticClass: "w-input__input w-input__input--file", attrs: { "tag": "label", "name": "fade", "for": "w-input--" + _vm._uid } }, [!_vm.inputFiles.length && _vm.isFocused ? _c("span", { key: "no-file", staticClass: "w-input__no-file" }, [_vm._t("no-file", function() {
2568
+ }, _vm.onInput], "focus": _vm.onFocus, "blur": _vm.onBlur } }, "input", _vm.attrs, false), _vm.listeners)) : [_c("input", _vm._b({ ref: "input", attrs: { "id": "w-input--" + _vm._uid, "type": "file", "name": _vm.name || null, "multiple": _vm.multiple || null, "data-progress": _vm.overallFilesProgress }, on: { "focus": _vm.onFocus, "blur": _vm.onBlur, "change": _vm.onFileChange } }, "input", _vm.attrs, false)), _c("transition-group", { staticClass: "w-input__input w-input__input--file", attrs: { "tag": "label", "name": "fade", "for": "w-input--" + _vm._uid } }, [!_vm.inputFiles.length && _vm.isFocused ? _c("span", { key: "no-file", staticClass: "w-input__no-file" }, [_vm._t("no-file", function() {
2550
2569
  return [_vm.$slots["no-file"] === void 0 ? [_vm._v("No file")] : _vm._e()];
2551
2570
  })], 2) : _vm._e(), _vm._l(_vm.inputFiles, function(file, i) {
2552
- return _c("span", { key: file.lastModified }, [_vm._v(_vm._s(i ? ", " : "")), _c("span", { key: i + "b", staticClass: "filename" }, [_vm._v(_vm._s(file.base))]), _vm._v(_vm._s(file.extension))]);
2553
- })], 2)], _vm.labelPosition === "inside" && _vm.showLabelInside ? [_vm.$slots.default ? _c("label", { staticClass: "w-input__label w-input__label--inside w-form-el-shakable", class: _vm.isFocused && (_obj = {}, _obj[_vm.valid === false ? "error" : _vm.color] = _vm.color || _vm.valid === false, _obj), attrs: { "for": "w-input--" + _vm._uid } }, [_vm._t("default")], 2) : _vm.label ? _c("label", { staticClass: "w-input__label w-input__label--inside w-form-el-shakable", class: _vm.isFocused && (_obj$1 = {}, _obj$1[_vm.valid === false ? "error" : _vm.color] = _vm.color || _vm.valid === false, _obj$1), attrs: { "for": "w-input--" + _vm._uid }, domProps: { "innerHTML": _vm._s(_vm.label) } }) : _vm._e()] : _vm._e(), _vm.innerIconRight ? _c("w-icon", { staticClass: "w-input__icon w-input__icon--inner-right", attrs: { "tag": "label", "for": "w-input--" + _vm._uid }, on: { "click": function($event) {
2571
+ return _c("span", { key: file.lastModified }, [_vm._v(_vm._s(i ? ", " : "")), _c("span", { key: i + "b", staticClass: "filename" }, [_vm._v(_vm._s(file.base))]), _vm._v(_vm._s(file.extension ? "." + file.extension : ""))]);
2572
+ })], 2)], _vm.labelPosition === "inside" && _vm.showLabelInside ? [_vm.$slots.default ? _c("label", { staticClass: "w-input__label w-input__label--inside w-form-el-shakable", class: _vm.validationClasses, attrs: { "for": "w-input--" + _vm._uid } }, [_vm._t("default")], 2) : _vm.label ? _c("label", { staticClass: "w-input__label w-input__label--inside w-form-el-shakable", class: _vm.validationClasses, attrs: { "for": "w-input--" + _vm._uid }, domProps: { "innerHTML": _vm._s(_vm.label) } }) : _vm._e()] : _vm._e(), _vm.innerIconRight ? _c("w-icon", { staticClass: "w-input__icon w-input__icon--inner-right", attrs: { "tag": "label", "for": "w-input--" + _vm._uid }, on: { "click": function($event) {
2554
2573
  return _vm.$emit("click:inner-icon-right", $event);
2555
- } } }, [_vm._v(_vm._s(_vm.innerIconRight))]) : _vm._e()], 2), _vm.type === "file" && _vm.inputFiles.length ? _c("label", { staticClass: "d-flex", attrs: { "for": "w-input--" + _vm._uid } }, [_vm._l(_vm.inputFiles, function(file, i) {
2556
- return [file.progress < 100 ? _c("i", { key: i, staticClass: "w-icon wi-spinner w-icon--spin size--sm w-input__file-preview primary" }) : file.preview ? _c("img", { key: i, staticClass: "w-input__file-preview", attrs: { "src": file.preview, "alt": "" } }) : _c("i", { key: i, staticClass: "w-icon wi-file w-input__file-preview primary" })];
2557
- })], 2) : _vm._e(), _vm.labelPosition === "right" ? [_vm.$slots.default ? _c("label", { staticClass: "w-input__label w-input__label--right w-form-el-shakable", attrs: { "for": "w-input--" + _vm._uid } }, [_vm._t("default")], 2) : _vm.label ? _c("label", { staticClass: "w-input__label w-input__label--right w-form-el-shakable", attrs: { "for": "w-input--" + _vm._uid }, domProps: { "innerHTML": _vm._s(_vm.label) } }) : _vm._e()] : _vm._e(), _vm.loading ? _c("w-progress", { staticClass: "fill-width", attrs: { "size": "2", "color": _vm.progressColor || _vm.color } }) : _vm._e()]], 2);
2574
+ } } }, [_vm._v(_vm._s(_vm.innerIconRight))]) : _vm._e(), _vm.hasLoading || _vm.showProgress && (_vm.uploadInProgress || _vm.uploadComplete) ? _c("w-progress", { staticClass: "fill-width", attrs: { "size": "2", "color": _vm.progressColor || _vm.color, "value": _vm.showProgress ? (_vm.uploadInProgress || _vm.uploadComplete) && _vm.overallFilesProgress : _vm.loadingValue } }) : _vm._e()], 2), _vm.type === "file" && _vm.preview && _vm.inputFiles.length ? _c("label", { staticClass: "d-flex", attrs: { "for": "w-input--" + _vm._uid } }, [_vm._l(_vm.inputFiles, function(file, i) {
2575
+ return [file.progress < 100 ? _c("i", { key: i, staticClass: "w-icon wi-spinner w-icon--spin size--sm w-input__file-preview primary" }) : file.preview ? _c("img", { key: i, staticClass: "w-input__file-preview", attrs: { "src": file.preview, "alt": "" } }) : _c("i", { key: i, staticClass: "w-icon w-input__file-preview primary size--md", class: _vm.preview && typeof _vm.preview === "string" ? _vm.preview : "wi-file" })];
2576
+ })], 2) : _vm._e(), _vm.labelPosition === "right" ? [_vm.$slots.default ? _c("label", { staticClass: "w-input__label w-input__label--right w-form-el-shakable", class: _vm.validationClasses, attrs: { "for": "w-input--" + _vm._uid } }, [_vm._t("default")], 2) : _vm.label ? _c("label", { staticClass: "w-input__label w-input__label--right w-form-el-shakable", class: _vm.validationClasses, attrs: { "for": "w-input--" + _vm._uid }, domProps: { "innerHTML": _vm._s(_vm.label) } }) : _vm._e()] : _vm._e()]], 2);
2558
2577
  };
2559
2578
  var staticRenderFns$u = [];
2560
2579
  var wInput_vue_vue_type_style_index_0_lang = "";
@@ -2584,10 +2603,12 @@ const __vue2_script$u = {
2584
2603
  shadow: { type: Boolean },
2585
2604
  tile: { type: Boolean },
2586
2605
  multiple: { type: Boolean },
2587
- preview: { type: Boolean },
2588
- loading: { type: Boolean }
2606
+ preview: { type: [Boolean, String], default: true },
2607
+ loading: { type: [Boolean, Number], default: false },
2608
+ showProgress: { type: [Boolean] },
2609
+ files: { type: Array }
2589
2610
  },
2590
- emits: ["input", "update:modelValue", "focus", "blur", "click:inner-icon-left", "click:inner-icon-right"],
2611
+ emits: ["input", "update:modelValue", "focus", "blur", "click:inner-icon-left", "click:inner-icon-right", "update:overallProgress"],
2591
2612
  data() {
2592
2613
  return {
2593
2614
  inputValue: this.value,
@@ -2608,14 +2629,48 @@ const __vue2_script$u = {
2608
2629
  return listeners;
2609
2630
  },
2610
2631
  hasValue() {
2611
- return this.inputValue || this.inputValue === 0 || ["date", "time"].includes(this.type) || this.type === "number" && this.inputNumberError || this.type === "file" && this.inputFiles.length;
2632
+ switch (this.type) {
2633
+ case "file":
2634
+ return !!this.inputFiles.length;
2635
+ case "number":
2636
+ return this.inputNumberError;
2637
+ case "date":
2638
+ case "time":
2639
+ return true;
2640
+ default:
2641
+ return this.inputValue || this.inputValue === 0;
2642
+ }
2612
2643
  },
2613
2644
  hasLabel() {
2614
2645
  return this.label || this.$slots.default;
2615
2646
  },
2647
+ hasLoading() {
2648
+ return ![void 0, false].includes(this.loading);
2649
+ },
2650
+ loadingValue() {
2651
+ let value;
2652
+ if (typeof this.loading === "number")
2653
+ value = this.loading;
2654
+ else if (this.loading) {
2655
+ value = this.type === "file" && this.overallFilesProgress ? this.overallFilesProgress : void 0;
2656
+ }
2657
+ return value;
2658
+ },
2616
2659
  showLabelInside() {
2617
2660
  return !this.staticLabel || !this.hasValue && !this.placeholder;
2618
2661
  },
2662
+ overallFilesProgress() {
2663
+ const progress = this.inputFiles.reduce((total2, file) => total2 + file.progress, 0);
2664
+ const total = progress / this.inputFiles.length;
2665
+ this.$emit("update:overallProgress", this.inputFiles.length ? total : void 0);
2666
+ return total;
2667
+ },
2668
+ uploadInProgress() {
2669
+ return this.overallFilesProgress > 0 && this.overallFilesProgress < 100;
2670
+ },
2671
+ uploadComplete() {
2672
+ return this.overallFilesProgress === 100;
2673
+ },
2619
2674
  classes() {
2620
2675
  return {
2621
2676
  "w-input": true,
@@ -2632,6 +2687,11 @@ const __vue2_script$u = {
2632
2687
  "w-input--inner-icon-right": this.innerIconRight
2633
2688
  };
2634
2689
  },
2690
+ validationClasses() {
2691
+ return this.isFocused && {
2692
+ [this.valid === false ? "error" : this.color]: this.color || this.valid === false
2693
+ };
2694
+ },
2635
2695
  inputWrapClasses() {
2636
2696
  return {
2637
2697
  [this.valid === false ? "error" : this.color]: this.color || this.valid === false,
@@ -2643,7 +2703,8 @@ const __vue2_script$u = {
2643
2703
  "w-input__input-wrap--underline": !this.outline,
2644
2704
  "w-input__input-wrap--shadow": this.shadow,
2645
2705
  "w-input__input-wrap--no-padding": !this.outline && !this.bgColor && !this.shadow && !this.round,
2646
- "w-input__input-wrap--loading": this.loading
2706
+ "w-input__input-wrap--loading": this.loading || this.showProgress && this.uploadInProgress,
2707
+ "w-input__input-wrap--upload-complete": this.uploadComplete
2647
2708
  };
2648
2709
  }
2649
2710
  },
@@ -2663,29 +2724,34 @@ const __vue2_script$u = {
2663
2724
  },
2664
2725
  onFileChange(e) {
2665
2726
  this.$set(this, "inputFiles", [...e.target.files].map((original) => {
2666
- const [, base, extension] = original.name.match(/^(.*)(\..*?)$/);
2727
+ const [, base = "", extension = "", full = ""] = original.name.match(/^(.*?)\.([^.]*)$|(.*)/);
2667
2728
  const file = Object.assign({}, {
2668
2729
  name: original.name,
2669
- base,
2730
+ base: base || full,
2670
2731
  extension,
2671
2732
  type: original.type,
2672
2733
  size: original.size,
2673
2734
  lastModified: original.lastModified,
2674
2735
  preview: null,
2675
- progress: 0
2736
+ progress: 0,
2737
+ file: original
2676
2738
  });
2677
- this.filePreview(original, file);
2739
+ this.readFile(original, file);
2678
2740
  return file;
2679
2741
  }));
2680
2742
  this.$emit("update:modelValue", this.inputFiles);
2743
+ this.$emit("input", this.inputFiles);
2681
2744
  },
2682
- filePreview(original, file) {
2745
+ readFile(original, file) {
2683
2746
  const reader = new FileReader();
2684
- if (original.type && original.type.startsWith("image/")) {
2747
+ const isPreviewAnIcon = typeof this.preview === "string";
2748
+ const isFileAnImage = original.type && original.type.startsWith("image/");
2749
+ if (this.preview && !isPreviewAnIcon && isFileAnImage) {
2685
2750
  reader.addEventListener("load", (e) => {
2686
2751
  this.$set(file, "preview", e.target.result);
2687
2752
  });
2688
- }
2753
+ } else
2754
+ delete file.preview;
2689
2755
  reader.addEventListener("progress", (event) => {
2690
2756
  if (event.loaded && event.total) {
2691
2757
  this.$set(file, "progress", event.loaded * 100 / event.total);
@@ -2696,7 +2762,7 @@ const __vue2_script$u = {
2696
2762
  },
2697
2763
  mounted() {
2698
2764
  setTimeout(() => {
2699
- if (this.$refs.input.matches(":-webkit-autofill"))
2765
+ if (this.$refs.input && this.$refs.input.matches(":-webkit-autofill"))
2700
2766
  this.isAutofilled = true;
2701
2767
  }, 400);
2702
2768
  },
@@ -3012,34 +3078,154 @@ function __vue2_injectStyles$t(context) {
3012
3078
  var wList = /* @__PURE__ */ function() {
3013
3079
  return __component__$t.exports;
3014
3080
  }();
3081
+ var DetachableMixin = {
3082
+ computed: {
3083
+ appendToTarget() {
3084
+ const defaultTarget = ".w-app";
3085
+ if (this.detachTo && !this.appendTo) {
3086
+ consoleWarn(`The ${this.$options.name} prop \`detach-to\` is deprecated. You can replace it with \`append-to\`.`);
3087
+ }
3088
+ let target = this.appendTo || this.detachTo || defaultTarget;
3089
+ if (target === true)
3090
+ target = defaultTarget;
3091
+ else if (this.appendTo === "activator")
3092
+ target = this.$el.previousElementSibling;
3093
+ else if (target && !["object", "string"].includes(typeof target))
3094
+ target = defaultTarget;
3095
+ else if (typeof target === "object" && !target.nodeType) {
3096
+ target = defaultTarget;
3097
+ consoleWarn(`Invalid node provided in ${this.$options.name} \`append-to\`. Falling back to .w-app.`);
3098
+ }
3099
+ if (typeof target === "string")
3100
+ target = document.querySelector(target);
3101
+ if (!target) {
3102
+ consoleWarn(`Unable to locate ${this.appendTo ? `target ${this.appendTo}` : defaultTarget}`);
3103
+ target = document.querySelector(defaultTarget);
3104
+ }
3105
+ return target;
3106
+ },
3107
+ detachableParentEl() {
3108
+ return this.appendToTarget;
3109
+ }
3110
+ },
3111
+ methods: {
3112
+ getActivatorCoordinates(e) {
3113
+ const { top, left, width, height } = (e ? e.target : this.activatorEl).getBoundingClientRect();
3114
+ let coords = { top, left, width, height };
3115
+ if (!this.fixed) {
3116
+ const { top: targetTop, left: targetLeft } = this.detachableParentEl.getBoundingClientRect();
3117
+ const computedStyles2 = window.getComputedStyle(this.detachableParentEl, null);
3118
+ coords = __spreadProps(__spreadValues({}, coords), {
3119
+ top: top - targetTop + this.detachableParentEl.scrollTop - parseInt(computedStyles2.getPropertyValue("border-top-width")),
3120
+ left: left - targetLeft + this.detachableParentEl.scrollLeft - parseInt(computedStyles2.getPropertyValue("border-left-width"))
3121
+ });
3122
+ }
3123
+ return coords;
3124
+ },
3125
+ computeDetachableCoords(e) {
3126
+ let { top, left, width, height } = this.getActivatorCoordinates(e);
3127
+ this.detachableEl.style.visibility = "hidden";
3128
+ this.detachableEl.style.display = "flex";
3129
+ const computedStyles2 = window.getComputedStyle(this.detachableEl, null);
3130
+ switch (this.position) {
3131
+ case "top": {
3132
+ top -= this.detachableEl.offsetHeight;
3133
+ if (this.alignRight) {
3134
+ left += width - this.detachableEl.offsetWidth + parseInt(computedStyles2.getPropertyValue("border-right-width"));
3135
+ } else if (!this.alignLeft)
3136
+ left += (width - this.detachableEl.offsetWidth) / 2;
3137
+ break;
3138
+ }
3139
+ case "bottom": {
3140
+ top += height;
3141
+ if (this.alignRight) {
3142
+ left += width - this.detachableEl.offsetWidth + parseInt(computedStyles2.getPropertyValue("border-right-width"));
3143
+ } else if (!this.alignLeft)
3144
+ left += (width - this.detachableEl.offsetWidth) / 2;
3145
+ break;
3146
+ }
3147
+ case "left": {
3148
+ left -= this.detachableEl.offsetWidth;
3149
+ if (this.alignBottom)
3150
+ top += height - this.detachableEl.offsetHeight;
3151
+ else if (!this.alignTop)
3152
+ top += (height - this.detachableEl.offsetHeight) / 2;
3153
+ break;
3154
+ }
3155
+ case "right": {
3156
+ left += width;
3157
+ if (this.alignBottom) {
3158
+ top += height - this.detachableEl.offsetHeight + parseInt(computedStyles2.getPropertyValue("margin-top"));
3159
+ } else if (!this.alignTop) {
3160
+ top += (height - this.detachableEl.offsetHeight) / 2 + parseInt(computedStyles2.getPropertyValue("margin-top"));
3161
+ }
3162
+ break;
3163
+ }
3164
+ }
3165
+ this.detachableEl.style.visibility = null;
3166
+ if (!this.detachableVisible)
3167
+ this.detachableEl.style.display = "none";
3168
+ this.detachableCoords = { top, left };
3169
+ },
3170
+ onResize() {
3171
+ if (this.minWidth === "activator")
3172
+ this.activatorWidth = this.activatorEl.offsetWidth;
3173
+ this.computeDetachableCoords();
3174
+ },
3175
+ onOutsideMousedown(e) {
3176
+ if (!this.detachableEl.contains(e.target) && !this.activatorEl.contains(e.target)) {
3177
+ this.$emit("update:modelValue", this.detachableVisible = false);
3178
+ this.$emit("input", false);
3179
+ this.$emit("close");
3180
+ document.removeEventListener("mousedown", this.onOutsideMousedown);
3181
+ window.removeEventListener("resize", this.onResize);
3182
+ }
3183
+ },
3184
+ insertInDOM() {
3185
+ return new Promise((resolve) => {
3186
+ this.$nextTick(() => {
3187
+ var _a;
3188
+ this.detachableEl = ((_a = this.$refs.detachable) == null ? void 0 : _a.$el) || this.$refs.detachable;
3189
+ this.appendToTarget.appendChild(this.detachableEl);
3190
+ resolve();
3191
+ });
3192
+ });
3193
+ },
3194
+ removeFromDOM() {
3195
+ if (this.detachableEl && this.detachableEl.parentNode)
3196
+ this.detachableEl.remove();
3197
+ }
3198
+ }
3199
+ };
3015
3200
  var render$s = function() {
3016
3201
  var _vm = this;
3017
3202
  var _h = _vm.$createElement;
3018
3203
  var _c = _vm._self._c || _h;
3019
- return _c("div", { staticClass: "w-menu-wrap" }, [_vm._t("activator", null, { "on": _vm.activatorEventHandlers }), _c("transition", { attrs: { "name": _vm.transitionName, "appear": "" } }, [_vm.custom && _vm.menuVisible ? _c("div", { ref: "menu", staticClass: "w-menu", class: _vm.classes, style: _vm.styles, on: { "click": function($event) {
3020
- _vm.hideOnMenuClick && _vm.closeMenu(true);
3204
+ return _c("div", { staticClass: "w-menu-wrap" }, [_vm._t("activator", null, { "on": _vm.activatorEventHandlers }), _c("transition", { attrs: { "name": _vm.transitionName, "appear": "" } }, [_vm.custom && _vm.detachableVisible ? _c("div", { ref: "detachable", staticClass: "w-menu", class: _vm.classes, style: _vm.styles, on: { "click": function($event) {
3205
+ _vm.hideOnMenuClick && _vm.close(true);
3021
3206
  }, "mouseenter": function($event) {
3022
3207
  _vm.showOnHover && (_vm.hoveringMenu = true);
3023
3208
  }, "mouseleave": function($event) {
3024
- _vm.showOnHover && (_vm.hoveringMenu = false, _vm.closeMenu());
3025
- } } }, [_vm._t("default")], 2) : _vm.menuVisible ? _c("w-card", { ref: "menu", staticClass: "w-menu", class: _vm.classes, style: _vm.styles, attrs: { "tile": _vm.tile, "title-class": _vm.titleClasses, "content-class": _vm.contentClasses, "shadow": _vm.shadow, "no-border": _vm.noBorder }, nativeOn: { "click": function($event) {
3026
- _vm.hideOnMenuClick && _vm.closeMenu(true);
3209
+ _vm.showOnHover && (_vm.hoveringMenu = false, _vm.close());
3210
+ } } }, [_vm._t("default")], 2) : _vm.detachableVisible ? _c("w-card", { ref: "detachable", staticClass: "w-menu", class: _vm.classes, style: _vm.styles, attrs: { "tile": _vm.tile, "title-class": _vm.titleClasses, "content-class": _vm.contentClasses, "shadow": _vm.shadow, "no-border": _vm.noBorder }, nativeOn: { "click": function($event) {
3211
+ _vm.hideOnMenuClick && _vm.close(true);
3027
3212
  }, "mouseenter": function($event) {
3028
3213
  _vm.showOnHover && (_vm.hoveringMenu = true);
3029
3214
  }, "mouseleave": function($event) {
3030
- _vm.showOnHover && (_vm.hoveringMenu = false, _vm.closeMenu());
3215
+ _vm.showOnHover && (_vm.hoveringMenu = false, _vm.close());
3031
3216
  } }, scopedSlots: _vm._u([_vm.$slots.title ? { key: "title", fn: function() {
3032
3217
  return [_vm._t("title")];
3033
3218
  }, proxy: true } : null, _vm.$slots.actions ? { key: "actions", fn: function() {
3034
3219
  return [_vm._t("actions")];
3035
- }, proxy: true } : null], null, true) }, [_vm._t("default")], 2) : _vm._e()], 1), _vm.overlay ? _c("w-overlay", _vm._b({ ref: "overlay", class: _vm.overlayClasses, attrs: { "value": _vm.menuVisible, "persistent": _vm.persistent, "z-index": (_vm.zIndex || 200) - 1 }, on: { "input": function($event) {
3036
- _vm.menuVisible = false;
3220
+ }, proxy: true } : null], null, true) }, [_vm._t("default")], 2) : _vm._e()], 1), _vm.overlay ? _c("w-overlay", _vm._b({ ref: "overlay", class: _vm.overlayClasses, attrs: { "value": _vm.detachableVisible, "persistent": _vm.persistent, "z-index": (_vm.zIndex || 200) - 1 }, on: { "input": function($event) {
3221
+ _vm.detachableVisible = false;
3037
3222
  } } }, "w-overlay", _vm.overlayProps, false)) : _vm._e()], 2);
3038
3223
  };
3039
3224
  var staticRenderFns$s = [];
3040
3225
  var wMenu_vue_vue_type_style_index_0_lang = "";
3041
3226
  const __vue2_script$s = {
3042
3227
  name: "w-menu",
3228
+ mixins: [DetachableMixin],
3043
3229
  props: {
3044
3230
  value: {},
3045
3231
  showOnHover: { type: Boolean },
@@ -3056,7 +3242,8 @@ const __vue2_script$s = {
3056
3242
  titleClass: { type: [String, Object, Array] },
3057
3243
  contentClass: { type: [String, Object, Array] },
3058
3244
  arrow: { type: Boolean },
3059
- detachTo: { type: [String, Boolean, Object] },
3245
+ detachTo: { type: [String, Boolean, Object], deprecated: true },
3246
+ appendTo: { type: [String, Boolean, Object] },
3060
3247
  fixed: { type: Boolean },
3061
3248
  top: { type: Boolean },
3062
3249
  bottom: { type: Boolean },
@@ -3076,56 +3263,34 @@ const __vue2_script$s = {
3076
3263
  },
3077
3264
  emits: ["input", "update:modelValue", "open", "close"],
3078
3265
  data: () => ({
3079
- menuVisible: false,
3266
+ detachableVisible: false,
3080
3267
  hoveringActivator: false,
3081
3268
  hoveringMenu: false,
3082
- menuCoordinates: {
3269
+ detachableCoords: {
3083
3270
  top: 0,
3084
3271
  left: 0
3085
3272
  },
3086
3273
  activatorEl: null,
3087
3274
  activatorWidth: 0,
3088
- menuEl: null,
3275
+ detachableEl: null,
3089
3276
  timeoutId: null
3090
3277
  }),
3091
3278
  computed: {
3092
3279
  transitionName() {
3093
3280
  return this.transition || "scale-fade";
3094
3281
  },
3095
- detachToTarget() {
3096
- const defaultTarget = ".w-app";
3097
- let target = this.detachTo || defaultTarget;
3098
- if (target === true)
3099
- target = defaultTarget;
3100
- else if (target && !["object", "string"].includes(typeof target))
3101
- target = defaultTarget;
3102
- else if (typeof target === "object" && !target.nodeType) {
3103
- target = defaultTarget;
3104
- consoleWarn("Invalid node provided in w-menu `detach-to`. Falling back to .w-app.");
3105
- }
3106
- if (typeof target === "string")
3107
- target = document.querySelector(target);
3108
- if (!target) {
3109
- consoleWarn(`Unable to locate ${this.detachTo ? `target ${this.detachTo}` : defaultTarget}`);
3110
- target = document.querySelector(defaultTarget);
3111
- }
3112
- return target;
3113
- },
3114
- menuParentEl() {
3115
- return this.detachToTarget;
3116
- },
3117
3282
  position() {
3118
3283
  return this.top && "top" || this.bottom && "bottom" || this.left && "left" || this.right && "right" || "bottom";
3119
3284
  },
3285
+ alignment() {
3286
+ return ["top", "bottom"].includes(this.position) && this.alignLeft && "left" || ["top", "bottom"].includes(this.position) && this.alignRight && "right" || ["left", "right"].includes(this.position) && this.alignTop && "top" || ["left", "right"].includes(this.position) && this.alignBottom && "bottom" || "";
3287
+ },
3120
3288
  menuMinWidth() {
3121
3289
  if (this.minWidth === "activator")
3122
3290
  return this.activatorWidth ? `${this.activatorWidth}px` : 0;
3123
3291
  else
3124
3292
  return isNaN(this.minWidth) ? this.minWidth : this.minWidth ? `${this.minWidth}px` : 0;
3125
3293
  },
3126
- alignment() {
3127
- return (this.top || this.bottom) && this.alignLeft && "left" || (this.top || this.bottom) && this.alignRight && "right" || (this.left || this.right) && this.alignTop && "top" || (this.left || this.right) && this.alignBottom && "bottom" || "";
3128
- },
3129
3294
  menuClasses() {
3130
3295
  return objectifyClasses(this.menuClass);
3131
3296
  },
@@ -3156,8 +3321,8 @@ const __vue2_script$s = {
3156
3321
  styles() {
3157
3322
  return {
3158
3323
  zIndex: this.zIndex || this.zIndex === 0 || this.overlay && !this.zIndex && 200 || null,
3159
- top: this.menuCoordinates.top && `${~~this.menuCoordinates.top}px` || null,
3160
- left: this.menuCoordinates.left && `${~~this.menuCoordinates.left}px` || null,
3324
+ top: this.detachableCoords.top && `${~~this.detachableCoords.top}px` || null,
3325
+ left: this.detachableCoords.left && `${~~this.detachableCoords.left}px` || null,
3161
3326
  minWidth: this.minWidth && this.menuMinWidth || null,
3162
3327
  "--w-menu-bg-color": this.arrow && this.$waveui.colors[this.bgColor || "white"]
3163
3328
  };
@@ -3170,13 +3335,13 @@ const __vue2_script$s = {
3170
3335
  blur: this.toggleMenu,
3171
3336
  mouseenter: (e) => {
3172
3337
  this.hoveringActivator = true;
3173
- this.openMenu(e);
3338
+ this.open(e);
3174
3339
  },
3175
3340
  mouseleave: (e) => {
3176
3341
  this.hoveringActivator = false;
3177
3342
  setTimeout(() => {
3178
3343
  if (!this.hoveringMenu)
3179
- this.closeMenu();
3344
+ this.close();
3180
3345
  }, 10);
3181
3346
  }
3182
3347
  };
@@ -3190,7 +3355,7 @@ const __vue2_script$s = {
3190
3355
  },
3191
3356
  methods: {
3192
3357
  toggleMenu(e) {
3193
- let shouldShowMenu = this.menuVisible;
3358
+ let shouldShowMenu = this.detachableVisible;
3194
3359
  if ("ontouchstart" in window && this.showOnHover && e.type === "click") {
3195
3360
  shouldShowMenu = !shouldShowMenu;
3196
3361
  } else if (e.type === "click" && !this.showOnHover)
@@ -3204,20 +3369,20 @@ const __vue2_script$s = {
3204
3369
  }
3205
3370
  this.timeoutId = clearTimeout(this.timeoutId);
3206
3371
  if (shouldShowMenu) {
3207
- this.$emit("update:modelValue", this.menuVisible = true);
3372
+ this.$emit("update:modelValue", this.detachableVisible = true);
3208
3373
  this.$emit("input", true);
3209
3374
  this.$emit("open");
3210
- this.openMenu(e);
3375
+ this.open(e);
3211
3376
  } else
3212
- this.closeMenu();
3377
+ this.close();
3213
3378
  },
3214
- async openMenu(e) {
3215
- this.menuVisible = true;
3216
- await this.insertMenu();
3379
+ async open(e) {
3380
+ this.detachableVisible = true;
3381
+ await this.insertInDOM();
3217
3382
  if (this.minWidth === "activator")
3218
3383
  this.activatorWidth = this.activatorEl.offsetWidth;
3219
3384
  if (!this.noPosition)
3220
- this.computeMenuPosition(e);
3385
+ this.computeDetachableCoords(e);
3221
3386
  this.timeoutId = setTimeout(() => {
3222
3387
  this.$emit("update:modelValue", true);
3223
3388
  this.$emit("input", true);
@@ -3228,105 +3393,19 @@ const __vue2_script$s = {
3228
3393
  if (!this.noPosition)
3229
3394
  window.addEventListener("resize", this.onResize);
3230
3395
  },
3231
- async closeMenu(force = false) {
3232
- if (!this.menuVisible)
3396
+ async close(force = false) {
3397
+ if (!this.detachableVisible)
3233
3398
  return;
3234
3399
  if (this.showOnHover && !force) {
3235
3400
  await new Promise((resolve) => setTimeout(resolve, 10));
3236
3401
  if (this.showOnHover && (this.hoveringMenu || this.hoveringActivator))
3237
3402
  return;
3238
3403
  }
3239
- this.$emit("update:modelValue", this.menuVisible = false);
3404
+ this.$emit("update:modelValue", this.detachableVisible = false);
3240
3405
  this.$emit("input", false);
3241
3406
  this.$emit("close");
3242
3407
  document.removeEventListener("mousedown", this.onOutsideMousedown);
3243
3408
  window.removeEventListener("resize", this.onResize);
3244
- },
3245
- onOutsideMousedown(e) {
3246
- if (!this.menuEl.contains(e.target) && !this.activatorEl.contains(e.target)) {
3247
- this.$emit("update:modelValue", this.menuVisible = false);
3248
- this.$emit("input", false);
3249
- this.$emit("close");
3250
- document.removeEventListener("mousedown", this.onOutsideMousedown);
3251
- window.removeEventListener("resize", this.onResize);
3252
- }
3253
- },
3254
- onResize() {
3255
- if (this.minWidth === "activator")
3256
- this.activatorWidth = this.activatorEl.offsetWidth;
3257
- this.computeMenuPosition();
3258
- },
3259
- getCoordinates(e) {
3260
- const { top, left, width, height } = (e ? e.target : this.activatorEl).getBoundingClientRect();
3261
- let coords = { top, left, width, height };
3262
- if (!this.fixed) {
3263
- const { top: targetTop, left: targetLeft } = this.menuParentEl.getBoundingClientRect();
3264
- const computedStyles2 = window.getComputedStyle(this.menuParentEl, null);
3265
- coords = __spreadProps(__spreadValues({}, coords), {
3266
- top: top - targetTop + this.menuParentEl.scrollTop - parseInt(computedStyles2.getPropertyValue("border-top-width")),
3267
- left: left - targetLeft + this.menuParentEl.scrollLeft - parseInt(computedStyles2.getPropertyValue("border-left-width"))
3268
- });
3269
- }
3270
- return coords;
3271
- },
3272
- computeMenuPosition(e) {
3273
- let { top, left, width, height } = this.getCoordinates(e);
3274
- this.menuEl.style.visibility = "hidden";
3275
- this.menuEl.style.display = "flex";
3276
- const computedStyles2 = window.getComputedStyle(this.menuEl, null);
3277
- switch (this.position) {
3278
- case "top": {
3279
- top -= this.menuEl.offsetHeight;
3280
- if (this.alignRight) {
3281
- left += width - this.menuEl.offsetWidth + parseInt(computedStyles2.getPropertyValue("border-right-width"));
3282
- } else if (!this.alignLeft)
3283
- left += (width - this.menuEl.offsetWidth) / 2;
3284
- break;
3285
- }
3286
- case "bottom": {
3287
- top += height;
3288
- if (this.alignRight) {
3289
- left += width - this.menuEl.offsetWidth + parseInt(computedStyles2.getPropertyValue("border-right-width"));
3290
- } else if (!this.alignLeft)
3291
- left += (width - this.menuEl.offsetWidth) / 2;
3292
- break;
3293
- }
3294
- case "left": {
3295
- left -= this.menuEl.offsetWidth;
3296
- if (this.alignBottom)
3297
- top += height - this.menuEl.offsetHeight;
3298
- else if (!this.alignTop)
3299
- top += (height - this.menuEl.offsetHeight) / 2;
3300
- break;
3301
- }
3302
- case "right": {
3303
- left += width;
3304
- if (this.alignBottom) {
3305
- top += height - this.menuEl.offsetHeight + parseInt(computedStyles2.getPropertyValue("margin-top"));
3306
- } else if (!this.alignTop) {
3307
- top += (height - this.menuEl.offsetHeight) / 2 + parseInt(computedStyles2.getPropertyValue("margin-top"));
3308
- }
3309
- break;
3310
- }
3311
- }
3312
- this.menuEl.style.visibility = null;
3313
- if (!this.menuVisible)
3314
- this.menuEl.style.display = "none";
3315
- this.menuCoordinates = { top, left };
3316
- },
3317
- insertMenu() {
3318
- return new Promise((resolve) => {
3319
- this.$nextTick(() => {
3320
- var _a;
3321
- this.menuEl = ((_a = this.$refs.menu) == null ? void 0 : _a.$el) || this.$refs.menu;
3322
- this.detachToTarget.appendChild(this.menuEl);
3323
- resolve();
3324
- });
3325
- });
3326
- },
3327
- removeMenu() {
3328
- if (this.menuEl && this.menuEl.parentNode)
3329
- this.menuEl.remove();
3330
3409
  }
3331
3410
  },
3332
3411
  mounted() {
@@ -3342,7 +3421,7 @@ const __vue2_script$s = {
3342
3421
  this.toggleMenu({ type: "click", target: this.activatorEl });
3343
3422
  },
3344
3423
  beforeDestroy() {
3345
- this.removeMenu();
3424
+ this.removeFromDOM();
3346
3425
  if (this.overlay && this.overlayEl.parentNode)
3347
3426
  this.overlayEl.remove();
3348
3427
  if (this.activatorEl && this.activatorEl.parentNode)
@@ -3350,12 +3429,16 @@ const __vue2_script$s = {
3350
3429
  },
3351
3430
  watch: {
3352
3431
  value(bool) {
3353
- if (!!bool !== this.menuVisible)
3432
+ if (!!bool !== this.detachableVisible)
3354
3433
  this.toggleMenu({ type: "click", target: this.activatorEl });
3355
3434
  },
3356
3435
  detachTo() {
3357
- this.removeMenu();
3358
- this.insertMenu();
3436
+ this.removeFromDOM();
3437
+ this.insertInDOM();
3438
+ },
3439
+ appendTo() {
3440
+ this.removeFromDOM();
3441
+ this.insertInDOM();
3359
3442
  }
3360
3443
  }
3361
3444
  };
@@ -4020,7 +4103,7 @@ var render$k = function() {
4020
4103
  var _c = _vm._self._c || _h;
4021
4104
  return _c(_vm.formRegister ? "w-form-element" : "div", _vm._b({ ref: "formEl", tag: "component", class: _vm.classes, attrs: { "valid": _vm.valid, "wrap": _vm.hasLabel && _vm.labelPosition !== "inside" }, on: { "update:valid": function($event) {
4022
4105
  _vm.valid = $event;
4023
- }, "reset": _vm.onReset } }, "component", _vm.formRegister && { validators: _vm.validators, inputValue: _vm.selectionString, disabled: _vm.isDisabled, readonly: _vm.isReadonly }, false), [_vm.labelPosition === "left" ? [_vm.$slots.default ? _c("label", { staticClass: "w-select__label w-select__label--left w-form-el-shakable", attrs: { "for": "w-select--" + _vm._uid } }, [_vm._t("default")], 2) : _vm.label ? _c("label", { staticClass: "w-select__label w-select__label--left w-form-el-shakable", attrs: { "for": "w-select--" + _vm._uid }, domProps: { "innerHTML": _vm._s(_vm.label) } }) : _vm._e()] : _vm._e(), _c("w-menu", _vm._b({ attrs: { "menu-class": "w-select__menu " + (_vm.menuClass || ""), "transition": "slide-fade-down", "detach-to": (_vm.menuProps || {}).detachTo !== void 0 ? (_vm.menuProps || {}).detachTo : ".w-app", "align-left": "", "custom": "", "min-width": "activator" }, scopedSlots: _vm._u([{ key: "activator", fn: function(ref) {
4106
+ }, "reset": _vm.onReset } }, "component", _vm.formRegister && { validators: _vm.validators, inputValue: _vm.selectionString, disabled: _vm.isDisabled, readonly: _vm.isReadonly }, false), [_vm.labelPosition === "left" ? [_vm.$slots.default ? _c("label", { staticClass: "w-select__label w-select__label--left w-form-el-shakable", attrs: { "for": "w-select--" + _vm._uid } }, [_vm._t("default")], 2) : _vm.label ? _c("label", { staticClass: "w-select__label w-select__label--left w-form-el-shakable", attrs: { "for": "w-select--" + _vm._uid }, domProps: { "innerHTML": _vm._s(_vm.label) } }) : _vm._e()] : _vm._e(), _c("w-menu", _vm._b({ attrs: { "menu-class": "w-select__menu " + (_vm.menuClass || ""), "transition": "slide-fade-down", "append-to": (_vm.menuProps || {}).appendTo !== void 0 ? (_vm.menuProps || {}).appendTo : ".w-app", "align-left": "", "custom": "", "min-width": "activator" }, scopedSlots: _vm._u([{ key: "activator", fn: function(ref) {
4024
4107
  var _obj, _obj$1;
4025
4108
  ref.on;
4026
4109
  return [_c("div", { ref: "selection-wrap", staticClass: "w-select__selection-wrap", class: _vm.inputWrapClasses, attrs: { "role": "button", "aria-haspopup": "listbox", "aria-expanded": _vm.showMenu ? "true" : "false", "aria-owns": "w-select-menu--" + _vm._uid, "aria-activedescendant": "w-select-menu--" + _vm._uid + "_item-1" }, on: { "click": function($event) {
@@ -5493,13 +5576,13 @@ var render$8 = function() {
5493
5576
  var _vm = this;
5494
5577
  var _h = _vm.$createElement;
5495
5578
  var _c = _vm._self._c || _h;
5496
- return _c("div", { staticClass: "w-tooltip-wrap", class: { "w-tooltip-wrap--attached": !_vm.detachTo } }, [_vm._t("activator", null, { "on": _vm.eventHandlers }), _c("transition", { attrs: { "name": _vm.transitionName, "appear": "" } }, [_c("div", { directives: [{ name: "show", rawName: "v-show", value: _vm.showTooltip, expression: "showTooltip" }], ref: "tooltip", staticClass: "w-tooltip", class: _vm.classes, style: _vm.styles }, [_vm._t("default")], 2)])], 2);
5579
+ return _c("div", { staticClass: "w-tooltip-wrap" }, [_vm._t("activator", null, { "on": _vm.eventHandlers }), _c("transition", { attrs: { "name": _vm.transitionName, "appear": "" } }, [_vm.detachableVisible ? _c("div", { ref: "detachable", staticClass: "w-tooltip", class: _vm.classes, style: _vm.styles }, [_vm._t("default")], 2) : _vm._e()])], 2);
5497
5580
  };
5498
5581
  var staticRenderFns$8 = [];
5499
5582
  var wTooltip_vue_vue_type_style_index_0_lang = "";
5500
- const marginFromWindowSide = 4;
5501
5583
  const __vue2_script$8 = {
5502
5584
  name: "w-tooltip",
5585
+ mixins: [DetachableMixin],
5503
5586
  props: {
5504
5587
  value: {},
5505
5588
  showOnClick: { type: Boolean },
@@ -5511,25 +5594,31 @@ const __vue2_script$8 = {
5511
5594
  round: { type: Boolean },
5512
5595
  transition: { type: String },
5513
5596
  tooltipClass: { type: [String, Object, Array] },
5514
- detachTo: {},
5597
+ detachTo: { type: [String, Boolean, Object], deprecated: true },
5598
+ appendTo: { type: [String, Boolean, Object] },
5515
5599
  fixed: { type: Boolean },
5516
5600
  top: { type: Boolean },
5517
5601
  bottom: { type: Boolean },
5518
5602
  left: { type: Boolean },
5519
5603
  right: { type: Boolean },
5520
- zIndex: { type: [Number, String, Boolean] }
5604
+ alignTop: { type: Boolean },
5605
+ alignBottom: { type: Boolean },
5606
+ alignLeft: { type: Boolean },
5607
+ alignRight: { type: Boolean },
5608
+ zIndex: { type: [Number, String, Boolean] },
5609
+ persistent: { type: Boolean },
5610
+ noPosition: { type: Boolean }
5521
5611
  },
5522
5612
  emits: ["input", "update:modelValue", "open", "close"],
5523
5613
  data: () => ({
5524
- showTooltip: false,
5525
- coordinates: {
5614
+ detachableVisible: false,
5615
+ hoveringActivator: false,
5616
+ detachableCoords: {
5526
5617
  top: 0,
5527
- left: 0,
5528
- width: 0,
5529
- height: 0
5618
+ left: 0
5530
5619
  },
5531
5620
  activatorEl: null,
5532
- tooltipEl: null,
5621
+ detachableEl: null,
5533
5622
  timeoutId: null
5534
5623
  }),
5535
5624
  computed: {
@@ -5540,69 +5629,23 @@ const __vue2_script$8 = {
5540
5629
  const direction = this.position.replace(/top|bottom/, (m) => ({ top: "up", bottom: "down" })[m]);
5541
5630
  return this.transition || `w-tooltip-slide-fade-${direction}`;
5542
5631
  },
5543
- detachToTarget() {
5544
- const defaultTarget = ".w-app";
5545
- let target = this.detachTo || defaultTarget;
5546
- if (target === true)
5547
- target = defaultTarget;
5548
- else if (target && !["object", "string"].includes(typeof target))
5549
- target = defaultTarget;
5550
- else if (typeof target === "object" && !target.nodeType) {
5551
- target = defaultTarget;
5552
- consoleWarn("Invalid node provided in w-tooltip `attach-to`. Falling back to .w-app.");
5553
- }
5554
- if (typeof target === "string")
5555
- target = document.querySelector(target);
5556
- if (!target) {
5557
- consoleWarn(`Unable to locate ${this.detachTo ? `target ${this.detachTo}` : defaultTarget}`);
5558
- target = document.querySelector(defaultTarget);
5559
- }
5560
- return target;
5561
- },
5562
- tooltipParentEl() {
5563
- return this.detachTo ? this.detachToTarget : this.$el;
5564
- },
5565
5632
  position() {
5566
5633
  return this.top && "top" || this.bottom && "bottom" || this.left && "left" || this.right && "right" || "bottom";
5567
5634
  },
5568
- tooltipCoordinates() {
5569
- const coords = {};
5570
- const { top, left, width, height } = this.coordinates;
5571
- switch (this.position) {
5572
- case "top": {
5573
- coords.top = top;
5574
- coords.left = left + width / 2;
5575
- break;
5576
- }
5577
- case "bottom": {
5578
- coords.top = top + height;
5579
- coords.left = left + width / 2;
5580
- break;
5581
- }
5582
- case "left": {
5583
- coords.top = top + height / 2;
5584
- coords.left = left;
5585
- break;
5586
- }
5587
- case "right": {
5588
- coords.top = top + height / 2;
5589
- coords.left = left + width;
5590
- break;
5591
- }
5592
- }
5593
- return coords;
5635
+ alignment() {
5636
+ return ["top", "bottom"].includes(this.position) && this.alignLeft && "left" || ["top", "bottom"].includes(this.position) && this.alignRight && "right" || ["left", "right"].includes(this.position) && this.alignTop && "top" || ["left", "right"].includes(this.position) && this.alignBottom && "bottom" || "";
5594
5637
  },
5595
5638
  classes() {
5596
5639
  return __spreadProps(__spreadValues({
5597
5640
  [this.color]: this.color,
5598
5641
  [`${this.bgColor}--bg`]: this.bgColor
5599
5642
  }, this.tooltipClasses), {
5600
- [`w-tooltip--${this.position}`]: true,
5643
+ [`w-tooltip--${this.position}`]: !this.noPosition,
5644
+ [`w-tooltip--align-${this.alignment}`]: !this.noPosition && this.alignment,
5601
5645
  "w-tooltip--tile": this.tile,
5602
5646
  "w-tooltip--round": this.round,
5603
5647
  "w-tooltip--shadow": this.shadow,
5604
5648
  "w-tooltip--fixed": this.fixed,
5605
- "w-tooltip--active": this.showTooltip,
5606
5649
  "w-tooltip--no-border": this.noBorder || this.bgColor,
5607
5650
  "w-tooltip--custom-transition": this.transition
5608
5651
  });
@@ -5610,8 +5653,8 @@ const __vue2_script$8 = {
5610
5653
  styles() {
5611
5654
  return {
5612
5655
  zIndex: this.zIndex || this.zIndex === 0 || null,
5613
- top: this.tooltipCoordinates.top && `${~~this.tooltipCoordinates.top}px` || null,
5614
- left: this.tooltipCoordinates.left && `${~~this.tooltipCoordinates.left}px` || null,
5656
+ top: this.detachableCoords.top && `${~~this.detachableCoords.top}px` || null,
5657
+ left: this.detachableCoords.left && `${~~this.detachableCoords.left}px` || null,
5615
5658
  "--w-tooltip-bg-color": this.$waveui.colors[this.bgColor || "white"]
5616
5659
  };
5617
5660
  },
@@ -5623,8 +5666,14 @@ const __vue2_script$8 = {
5623
5666
  handlers = {
5624
5667
  focus: this.toggle,
5625
5668
  blur: this.toggle,
5626
- mouseenter: this.toggle,
5627
- mouseleave: this.toggle
5669
+ mouseenter: (e) => {
5670
+ this.hoveringActivator = true;
5671
+ this.open(e);
5672
+ },
5673
+ mouseleave: (e) => {
5674
+ this.hoveringActivator = false;
5675
+ this.close();
5676
+ }
5628
5677
  };
5629
5678
  if (typeof window !== "undefined" && "ontouchstart" in window)
5630
5679
  handlers.click = this.toggle;
@@ -5634,7 +5683,7 @@ const __vue2_script$8 = {
5634
5683
  },
5635
5684
  methods: {
5636
5685
  toggle(e) {
5637
- let shouldShowTooltip = this.showTooltip;
5686
+ let shouldShowTooltip = this.detachableVisible;
5638
5687
  if (typeof window !== "undefined" && "ontouchstart" in window) {
5639
5688
  if (e.type === "click")
5640
5689
  shouldShowTooltip = !shouldShowTooltip;
@@ -5646,89 +5695,69 @@ const __vue2_script$8 = {
5646
5695
  shouldShowTooltip = false;
5647
5696
  this.timeoutId = clearTimeout(this.timeoutId);
5648
5697
  if (shouldShowTooltip) {
5649
- this.coordinates = this.getCoordinates(e);
5650
- this.timeoutId = setTimeout(() => {
5651
- this.showTooltip = true;
5652
- this.$emit("update:modelValue", true);
5653
- this.$emit("input", true);
5654
- this.$emit("open");
5655
- }, 10);
5656
- } else {
5657
- this.showTooltip = false;
5658
- this.$emit("update:modelValue", false);
5659
- this.$emit("input", false);
5660
- this.$emit("close");
5661
- }
5662
- },
5663
- getCoordinates() {
5664
- const { top, left, width, height } = this.activatorEl.getBoundingClientRect();
5665
- let coords = { top, left, width, height };
5666
- if (!this.fixed) {
5667
- const { top: targetTop, left: targetLeft } = this.tooltipParentEl.getBoundingClientRect();
5668
- coords = __spreadProps(__spreadValues({}, coords), { top: top - targetTop, left: left - targetLeft });
5669
- }
5670
- const tooltipEl = this.$refs.tooltip;
5671
- tooltipEl.style.visibility = "hidden";
5672
- tooltipEl.style.display = "table";
5673
- const computedStyles2 = window.getComputedStyle(tooltipEl, null);
5674
- if (this.position === "top" && top - tooltipEl.offsetHeight < 0) {
5675
- const margin = -parseInt(computedStyles2.getPropertyValue("margin-top"));
5676
- coords.top -= top - tooltipEl.offsetHeight - margin - marginFromWindowSide;
5677
- } else if (this.position === "left" && left - tooltipEl.offsetWidth < 0) {
5678
- const margin = -parseInt(computedStyles2.getPropertyValue("margin-left"));
5679
- coords.left -= left - tooltipEl.offsetWidth - margin - marginFromWindowSide;
5680
- } else if (this.position === "right" && left + width + tooltipEl.offsetWidth > window.innerWidth) {
5681
- const margin = parseInt(computedStyles2.getPropertyValue("margin-left"));
5682
- coords.left -= left + width + tooltipEl.offsetWidth - window.innerWidth + margin + marginFromWindowSide;
5683
- } else if (this.position === "bottom" && top + height + tooltipEl.offsetHeight > window.innerHeight) {
5684
- const margin = parseInt(computedStyles2.getPropertyValue("margin-top"));
5685
- coords.top -= top + height + tooltipEl.offsetHeight - window.innerHeight + margin + marginFromWindowSide;
5686
- }
5687
- if (this.transition) {
5688
- if (["top", "bottom"].includes(this.position))
5689
- coords.left -= tooltipEl.offsetWidth / 2;
5690
- if (["left", "right"].includes(this.position))
5691
- coords.top -= tooltipEl.offsetHeight / 2;
5692
- if (this.position === "left")
5693
- coords.left -= tooltipEl.offsetWidth;
5694
- if (this.position === "top")
5695
- coords.top -= tooltipEl.offsetHeight;
5696
- }
5697
- tooltipEl.style.visibility = null;
5698
- tooltipEl.style.display = "none";
5699
- return coords;
5698
+ this.$emit("update:modelValue", this.detachableVisible = true);
5699
+ this.$emit("input", true);
5700
+ this.$emit("open");
5701
+ this.open(e);
5702
+ } else
5703
+ this.close();
5700
5704
  },
5701
- insertTooltip() {
5702
- const wrapper = this.$el;
5703
- this.tooltipEl = this.$refs.tooltip.$el || this.$refs.tooltip;
5704
- wrapper.parentNode.insertBefore(this.activatorEl, wrapper);
5705
- this.detachToTarget.appendChild(this.$refs.tooltip);
5705
+ async open(e) {
5706
+ this.detachableVisible = true;
5707
+ await this.insertInDOM();
5708
+ if (this.minWidth === "activator")
5709
+ this.activatorWidth = this.activatorEl.offsetWidth;
5710
+ if (!this.noPosition)
5711
+ this.computeDetachableCoords(e);
5712
+ this.timeoutId = setTimeout(() => {
5713
+ this.$emit("update:modelValue", true);
5714
+ this.$emit("input", true);
5715
+ this.$emit("open");
5716
+ }, 0);
5717
+ if (!this.persistent)
5718
+ document.addEventListener("mousedown", this.onOutsideMousedown);
5719
+ if (!this.noPosition)
5720
+ window.addEventListener("resize", this.onResize);
5706
5721
  },
5707
- removeTooltip() {
5708
- if (this.tooltipEl && this.tooltipEl.parentNode)
5709
- this.tooltipEl.remove();
5722
+ async close(force = false) {
5723
+ if (!this.detachableVisible)
5724
+ return;
5725
+ if (this.showOnHover && !force) {
5726
+ await new Promise((resolve) => setTimeout(resolve, 10));
5727
+ if (this.showOnHover && this.hoveringActivator)
5728
+ return;
5729
+ }
5730
+ this.$emit("update:modelValue", this.detachableVisible = false);
5731
+ this.$emit("input", false);
5732
+ this.$emit("close");
5733
+ document.removeEventListener("mousedown", this.onOutsideMousedown);
5734
+ window.removeEventListener("resize", this.onResize);
5710
5735
  }
5711
5736
  },
5712
5737
  mounted() {
5713
- this.activatorEl = this.$el.firstElementChild;
5714
- if (this.detachTo)
5715
- this.insertTooltip();
5738
+ const wrapper = this.$el;
5739
+ this.activatorEl = wrapper.firstElementChild;
5740
+ wrapper.parentNode.insertBefore(this.activatorEl, wrapper);
5716
5741
  if (this.value)
5717
5742
  this.toggle({ type: "click", target: this.activatorEl });
5718
5743
  },
5719
5744
  beforeDestroy() {
5720
- this.removeTooltip();
5745
+ this.removeFromDOM();
5721
5746
  if (this.activatorEl && this.activatorEl.parentNode)
5722
5747
  this.activatorEl.remove();
5723
5748
  },
5724
5749
  watch: {
5725
5750
  value(bool) {
5726
- if (bool !== this.showTooltip)
5751
+ if (bool !== this.detachableVisible)
5727
5752
  this.toggle({ type: "click", target: this.activatorEl });
5728
5753
  },
5729
5754
  detachTo() {
5730
- this.removeTooltip();
5731
- this.insertTooltip();
5755
+ this.removeFromDOM();
5756
+ this.insertInDOM();
5757
+ },
5758
+ appendTo() {
5759
+ this.removeFromDOM();
5760
+ this.insertInDOM();
5732
5761
  }
5733
5762
  }
5734
5763
  };