wave-ui 1.45.13 → 1.47.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,
@@ -2678,6 +2698,8 @@ const __vue2_script$u = {
2678
2698
  return file;
2679
2699
  }));
2680
2700
  this.$emit("update:modelValue", this.inputFiles);
2701
+ this.$emit("input", this.inputFiles);
2702
+ this.$emit("change", this.inputFiles);
2681
2703
  },
2682
2704
  filePreview(original, file) {
2683
2705
  const reader = new FileReader();
@@ -2696,7 +2718,7 @@ const __vue2_script$u = {
2696
2718
  },
2697
2719
  mounted() {
2698
2720
  setTimeout(() => {
2699
- if (this.$refs.input.matches(":-webkit-autofill"))
2721
+ if (this.$refs.input && this.$refs.input.matches(":-webkit-autofill"))
2700
2722
  this.isAutofilled = true;
2701
2723
  }, 400);
2702
2724
  },
@@ -3012,34 +3034,154 @@ function __vue2_injectStyles$t(context) {
3012
3034
  var wList = /* @__PURE__ */ function() {
3013
3035
  return __component__$t.exports;
3014
3036
  }();
3037
+ var DetachableMixin = {
3038
+ computed: {
3039
+ appendToTarget() {
3040
+ const defaultTarget = ".w-app";
3041
+ if (this.detachTo && !this.appendTo) {
3042
+ consoleWarn(`The ${this.$options.name} prop \`detach-to\` is deprecated. You can replace it with \`append-to\`.`);
3043
+ }
3044
+ let target = this.appendTo || this.detachTo || defaultTarget;
3045
+ if (target === true)
3046
+ target = defaultTarget;
3047
+ else if (this.appendTo === "activator")
3048
+ target = this.$el.previousElementSibling;
3049
+ else if (target && !["object", "string"].includes(typeof target))
3050
+ target = defaultTarget;
3051
+ else if (typeof target === "object" && !target.nodeType) {
3052
+ target = defaultTarget;
3053
+ consoleWarn(`Invalid node provided in ${this.$options.name} \`append-to\`. Falling back to .w-app.`);
3054
+ }
3055
+ if (typeof target === "string")
3056
+ target = document.querySelector(target);
3057
+ if (!target) {
3058
+ consoleWarn(`Unable to locate ${this.appendTo ? `target ${this.appendTo}` : defaultTarget}`);
3059
+ target = document.querySelector(defaultTarget);
3060
+ }
3061
+ return target;
3062
+ },
3063
+ detachableParentEl() {
3064
+ return this.appendToTarget;
3065
+ }
3066
+ },
3067
+ methods: {
3068
+ getActivatorCoordinates(e) {
3069
+ const { top, left, width, height } = (e ? e.target : this.activatorEl).getBoundingClientRect();
3070
+ let coords = { top, left, width, height };
3071
+ if (!this.fixed) {
3072
+ const { top: targetTop, left: targetLeft } = this.detachableParentEl.getBoundingClientRect();
3073
+ const computedStyles2 = window.getComputedStyle(this.detachableParentEl, null);
3074
+ coords = __spreadProps(__spreadValues({}, coords), {
3075
+ top: top - targetTop + this.detachableParentEl.scrollTop - parseInt(computedStyles2.getPropertyValue("border-top-width")),
3076
+ left: left - targetLeft + this.detachableParentEl.scrollLeft - parseInt(computedStyles2.getPropertyValue("border-left-width"))
3077
+ });
3078
+ }
3079
+ return coords;
3080
+ },
3081
+ computeDetachableCoords(e) {
3082
+ let { top, left, width, height } = this.getActivatorCoordinates(e);
3083
+ this.detachableEl.style.visibility = "hidden";
3084
+ this.detachableEl.style.display = "flex";
3085
+ const computedStyles2 = window.getComputedStyle(this.detachableEl, null);
3086
+ switch (this.position) {
3087
+ case "top": {
3088
+ top -= this.detachableEl.offsetHeight;
3089
+ if (this.alignRight) {
3090
+ left += width - this.detachableEl.offsetWidth + parseInt(computedStyles2.getPropertyValue("border-right-width"));
3091
+ } else if (!this.alignLeft)
3092
+ left += (width - this.detachableEl.offsetWidth) / 2;
3093
+ break;
3094
+ }
3095
+ case "bottom": {
3096
+ top += height;
3097
+ if (this.alignRight) {
3098
+ left += width - this.detachableEl.offsetWidth + parseInt(computedStyles2.getPropertyValue("border-right-width"));
3099
+ } else if (!this.alignLeft)
3100
+ left += (width - this.detachableEl.offsetWidth) / 2;
3101
+ break;
3102
+ }
3103
+ case "left": {
3104
+ left -= this.detachableEl.offsetWidth;
3105
+ if (this.alignBottom)
3106
+ top += height - this.detachableEl.offsetHeight;
3107
+ else if (!this.alignTop)
3108
+ top += (height - this.detachableEl.offsetHeight) / 2;
3109
+ break;
3110
+ }
3111
+ case "right": {
3112
+ left += width;
3113
+ if (this.alignBottom) {
3114
+ top += height - this.detachableEl.offsetHeight + parseInt(computedStyles2.getPropertyValue("margin-top"));
3115
+ } else if (!this.alignTop) {
3116
+ top += (height - this.detachableEl.offsetHeight) / 2 + parseInt(computedStyles2.getPropertyValue("margin-top"));
3117
+ }
3118
+ break;
3119
+ }
3120
+ }
3121
+ this.detachableEl.style.visibility = null;
3122
+ if (!this.detachableVisible)
3123
+ this.detachableEl.style.display = "none";
3124
+ this.detachableCoords = { top, left };
3125
+ },
3126
+ onResize() {
3127
+ if (this.minWidth === "activator")
3128
+ this.activatorWidth = this.activatorEl.offsetWidth;
3129
+ this.computeDetachableCoords();
3130
+ },
3131
+ onOutsideMousedown(e) {
3132
+ if (!this.detachableEl.contains(e.target) && !this.activatorEl.contains(e.target)) {
3133
+ this.$emit("update:modelValue", this.detachableVisible = false);
3134
+ this.$emit("input", false);
3135
+ this.$emit("close");
3136
+ document.removeEventListener("mousedown", this.onOutsideMousedown);
3137
+ window.removeEventListener("resize", this.onResize);
3138
+ }
3139
+ },
3140
+ insertInDOM() {
3141
+ return new Promise((resolve) => {
3142
+ this.$nextTick(() => {
3143
+ var _a;
3144
+ this.detachableEl = ((_a = this.$refs.detachable) == null ? void 0 : _a.$el) || this.$refs.detachable;
3145
+ this.appendToTarget.appendChild(this.detachableEl);
3146
+ resolve();
3147
+ });
3148
+ });
3149
+ },
3150
+ removeFromDOM() {
3151
+ if (this.detachableEl && this.detachableEl.parentNode)
3152
+ this.detachableEl.remove();
3153
+ }
3154
+ }
3155
+ };
3015
3156
  var render$s = function() {
3016
3157
  var _vm = this;
3017
3158
  var _h = _vm.$createElement;
3018
3159
  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);
3160
+ 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) {
3161
+ _vm.hideOnMenuClick && _vm.close(true);
3021
3162
  }, "mouseenter": function($event) {
3022
3163
  _vm.showOnHover && (_vm.hoveringMenu = true);
3023
3164
  }, "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);
3165
+ _vm.showOnHover && (_vm.hoveringMenu = false, _vm.close());
3166
+ } } }, [_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) {
3167
+ _vm.hideOnMenuClick && _vm.close(true);
3027
3168
  }, "mouseenter": function($event) {
3028
3169
  _vm.showOnHover && (_vm.hoveringMenu = true);
3029
3170
  }, "mouseleave": function($event) {
3030
- _vm.showOnHover && (_vm.hoveringMenu = false, _vm.closeMenu());
3171
+ _vm.showOnHover && (_vm.hoveringMenu = false, _vm.close());
3031
3172
  } }, scopedSlots: _vm._u([_vm.$slots.title ? { key: "title", fn: function() {
3032
3173
  return [_vm._t("title")];
3033
3174
  }, proxy: true } : null, _vm.$slots.actions ? { key: "actions", fn: function() {
3034
3175
  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;
3176
+ }, 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) {
3177
+ _vm.detachableVisible = false;
3037
3178
  } } }, "w-overlay", _vm.overlayProps, false)) : _vm._e()], 2);
3038
3179
  };
3039
3180
  var staticRenderFns$s = [];
3040
3181
  var wMenu_vue_vue_type_style_index_0_lang = "";
3041
3182
  const __vue2_script$s = {
3042
3183
  name: "w-menu",
3184
+ mixins: [DetachableMixin],
3043
3185
  props: {
3044
3186
  value: {},
3045
3187
  showOnHover: { type: Boolean },
@@ -3056,7 +3198,8 @@ const __vue2_script$s = {
3056
3198
  titleClass: { type: [String, Object, Array] },
3057
3199
  contentClass: { type: [String, Object, Array] },
3058
3200
  arrow: { type: Boolean },
3059
- detachTo: { type: [String, Boolean, Object] },
3201
+ detachTo: { type: [String, Boolean, Object], deprecated: true },
3202
+ appendTo: { type: [String, Boolean, Object] },
3060
3203
  fixed: { type: Boolean },
3061
3204
  top: { type: Boolean },
3062
3205
  bottom: { type: Boolean },
@@ -3076,55 +3219,34 @@ const __vue2_script$s = {
3076
3219
  },
3077
3220
  emits: ["input", "update:modelValue", "open", "close"],
3078
3221
  data: () => ({
3079
- menuVisible: false,
3222
+ detachableVisible: false,
3080
3223
  hoveringActivator: false,
3081
3224
  hoveringMenu: false,
3082
- menuCoordinates: {
3225
+ detachableCoords: {
3083
3226
  top: 0,
3084
3227
  left: 0
3085
3228
  },
3086
3229
  activatorEl: null,
3087
3230
  activatorWidth: 0,
3088
- menuEl: null,
3231
+ detachableEl: null,
3089
3232
  timeoutId: null
3090
3233
  }),
3091
3234
  computed: {
3092
3235
  transitionName() {
3093
3236
  return this.transition || "scale-fade";
3094
3237
  },
3095
- detachToTarget() {
3096
- let target = this.detachTo || ".w-app";
3097
- if (target === true)
3098
- target = ".w-app";
3099
- else if (target && !["object", "string"].includes(typeof target))
3100
- target = ".w-app";
3101
- else if (typeof target === "object" && !target.nodeType) {
3102
- target = ".w-app";
3103
- consoleWarn("Invalid node provided in w-menu `detach-to`. Falling back to .w-app.");
3104
- }
3105
- if (typeof target === "string")
3106
- target = document.querySelector(target);
3107
- if (!target) {
3108
- consoleWarn(`Unable to locate ${this.detachTo ? `target ${this.detachTo}` : ".w-app"}`);
3109
- target = document.querySelector(".w-app");
3110
- }
3111
- return target;
3112
- },
3113
- menuParentEl() {
3114
- return this.detachToTarget;
3115
- },
3116
3238
  position() {
3117
3239
  return this.top && "top" || this.bottom && "bottom" || this.left && "left" || this.right && "right" || "bottom";
3118
3240
  },
3241
+ alignment() {
3242
+ 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" || "";
3243
+ },
3119
3244
  menuMinWidth() {
3120
3245
  if (this.minWidth === "activator")
3121
3246
  return this.activatorWidth ? `${this.activatorWidth}px` : 0;
3122
3247
  else
3123
3248
  return isNaN(this.minWidth) ? this.minWidth : this.minWidth ? `${this.minWidth}px` : 0;
3124
3249
  },
3125
- alignment() {
3126
- 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" || "";
3127
- },
3128
3250
  menuClasses() {
3129
3251
  return objectifyClasses(this.menuClass);
3130
3252
  },
@@ -3155,8 +3277,8 @@ const __vue2_script$s = {
3155
3277
  styles() {
3156
3278
  return {
3157
3279
  zIndex: this.zIndex || this.zIndex === 0 || this.overlay && !this.zIndex && 200 || null,
3158
- top: this.menuCoordinates.top && `${~~this.menuCoordinates.top}px` || null,
3159
- left: this.menuCoordinates.left && `${~~this.menuCoordinates.left}px` || null,
3280
+ top: this.detachableCoords.top && `${~~this.detachableCoords.top}px` || null,
3281
+ left: this.detachableCoords.left && `${~~this.detachableCoords.left}px` || null,
3160
3282
  minWidth: this.minWidth && this.menuMinWidth || null,
3161
3283
  "--w-menu-bg-color": this.arrow && this.$waveui.colors[this.bgColor || "white"]
3162
3284
  };
@@ -3169,18 +3291,19 @@ const __vue2_script$s = {
3169
3291
  blur: this.toggleMenu,
3170
3292
  mouseenter: (e) => {
3171
3293
  this.hoveringActivator = true;
3172
- this.openMenu(e);
3294
+ this.open(e);
3173
3295
  },
3174
3296
  mouseleave: (e) => {
3175
3297
  this.hoveringActivator = false;
3176
3298
  setTimeout(() => {
3177
3299
  if (!this.hoveringMenu)
3178
- this.closeMenu();
3300
+ this.close();
3179
3301
  }, 10);
3180
3302
  }
3181
3303
  };
3182
- if ("ontouchstart" in window)
3304
+ if (typeof window !== "undefined" && "ontouchstart" in window) {
3183
3305
  handlers.click = this.toggleMenu;
3306
+ }
3184
3307
  } else
3185
3308
  handlers = { click: this.toggleMenu };
3186
3309
  return handlers;
@@ -3188,7 +3311,7 @@ const __vue2_script$s = {
3188
3311
  },
3189
3312
  methods: {
3190
3313
  toggleMenu(e) {
3191
- let shouldShowMenu = this.menuVisible;
3314
+ let shouldShowMenu = this.detachableVisible;
3192
3315
  if ("ontouchstart" in window && this.showOnHover && e.type === "click") {
3193
3316
  shouldShowMenu = !shouldShowMenu;
3194
3317
  } else if (e.type === "click" && !this.showOnHover)
@@ -3202,20 +3325,20 @@ const __vue2_script$s = {
3202
3325
  }
3203
3326
  this.timeoutId = clearTimeout(this.timeoutId);
3204
3327
  if (shouldShowMenu) {
3205
- this.$emit("update:modelValue", this.menuVisible = true);
3328
+ this.$emit("update:modelValue", this.detachableVisible = true);
3206
3329
  this.$emit("input", true);
3207
3330
  this.$emit("open");
3208
- this.openMenu(e);
3331
+ this.open(e);
3209
3332
  } else
3210
- this.closeMenu();
3333
+ this.close();
3211
3334
  },
3212
- async openMenu(e) {
3213
- this.menuVisible = true;
3214
- await this.insertMenu();
3335
+ async open(e) {
3336
+ this.detachableVisible = true;
3337
+ await this.insertInDOM();
3215
3338
  if (this.minWidth === "activator")
3216
3339
  this.activatorWidth = this.activatorEl.offsetWidth;
3217
3340
  if (!this.noPosition)
3218
- this.computeMenuPosition(e);
3341
+ this.computeDetachableCoords(e);
3219
3342
  this.timeoutId = setTimeout(() => {
3220
3343
  this.$emit("update:modelValue", true);
3221
3344
  this.$emit("input", true);
@@ -3226,105 +3349,19 @@ const __vue2_script$s = {
3226
3349
  if (!this.noPosition)
3227
3350
  window.addEventListener("resize", this.onResize);
3228
3351
  },
3229
- async closeMenu(force = false) {
3230
- if (!this.menuVisible)
3352
+ async close(force = false) {
3353
+ if (!this.detachableVisible)
3231
3354
  return;
3232
3355
  if (this.showOnHover && !force) {
3233
3356
  await new Promise((resolve) => setTimeout(resolve, 10));
3234
3357
  if (this.showOnHover && (this.hoveringMenu || this.hoveringActivator))
3235
3358
  return;
3236
3359
  }
3237
- this.$emit("update:modelValue", this.menuVisible = false);
3360
+ this.$emit("update:modelValue", this.detachableVisible = false);
3238
3361
  this.$emit("input", false);
3239
3362
  this.$emit("close");
3240
3363
  document.removeEventListener("mousedown", this.onOutsideMousedown);
3241
3364
  window.removeEventListener("resize", this.onResize);
3242
- },
3243
- onOutsideMousedown(e) {
3244
- if (!this.menuEl.contains(e.target) && !this.activatorEl.contains(e.target)) {
3245
- this.$emit("update:modelValue", this.menuVisible = false);
3246
- this.$emit("input", false);
3247
- this.$emit("close");
3248
- document.removeEventListener("mousedown", this.onOutsideMousedown);
3249
- window.removeEventListener("resize", this.onResize);
3250
- }
3251
- },
3252
- onResize() {
3253
- if (this.minWidth === "activator")
3254
- this.activatorWidth = this.activatorEl.offsetWidth;
3255
- this.computeMenuPosition();
3256
- },
3257
- getCoordinates(e) {
3258
- const { top, left, width, height } = (e ? e.target : this.activatorEl).getBoundingClientRect();
3259
- let coords = { top, left, width, height };
3260
- if (!this.fixed) {
3261
- const { top: targetTop, left: targetLeft } = this.menuParentEl.getBoundingClientRect();
3262
- const computedStyles2 = window.getComputedStyle(this.menuParentEl, null);
3263
- coords = __spreadProps(__spreadValues({}, coords), {
3264
- top: top - targetTop + this.menuParentEl.scrollTop - parseInt(computedStyles2.getPropertyValue("border-top-width")),
3265
- left: left - targetLeft + this.menuParentEl.scrollLeft - parseInt(computedStyles2.getPropertyValue("border-left-width"))
3266
- });
3267
- }
3268
- return coords;
3269
- },
3270
- computeMenuPosition(e) {
3271
- let { top, left, width, height } = this.getCoordinates(e);
3272
- this.menuEl.style.visibility = "hidden";
3273
- this.menuEl.style.display = "flex";
3274
- const computedStyles2 = window.getComputedStyle(this.menuEl, null);
3275
- switch (this.position) {
3276
- case "top": {
3277
- top -= this.menuEl.offsetHeight;
3278
- if (this.alignRight) {
3279
- left += width - this.menuEl.offsetWidth + parseInt(computedStyles2.getPropertyValue("border-right-width"));
3280
- } else if (!this.alignLeft)
3281
- left += (width - this.menuEl.offsetWidth) / 2;
3282
- break;
3283
- }
3284
- case "bottom": {
3285
- top += height;
3286
- if (this.alignRight) {
3287
- left += width - this.menuEl.offsetWidth + parseInt(computedStyles2.getPropertyValue("border-right-width"));
3288
- } else if (!this.alignLeft)
3289
- left += (width - this.menuEl.offsetWidth) / 2;
3290
- break;
3291
- }
3292
- case "left": {
3293
- left -= this.menuEl.offsetWidth;
3294
- if (this.alignBottom)
3295
- top += height - this.menuEl.offsetHeight;
3296
- else if (!this.alignTop)
3297
- top += (height - this.menuEl.offsetHeight) / 2;
3298
- break;
3299
- }
3300
- case "right": {
3301
- left += width;
3302
- if (this.alignBottom) {
3303
- top += height - this.menuEl.offsetHeight + parseInt(computedStyles2.getPropertyValue("margin-top"));
3304
- } else if (!this.alignTop) {
3305
- top += (height - this.menuEl.offsetHeight) / 2 + parseInt(computedStyles2.getPropertyValue("margin-top"));
3306
- }
3307
- break;
3308
- }
3309
- }
3310
- this.menuEl.style.visibility = null;
3311
- if (!this.menuVisible)
3312
- this.menuEl.style.display = "none";
3313
- this.menuCoordinates = { top, left };
3314
- },
3315
- insertMenu() {
3316
- return new Promise((resolve) => {
3317
- this.$nextTick(() => {
3318
- var _a;
3319
- this.menuEl = ((_a = this.$refs.menu) == null ? void 0 : _a.$el) || this.$refs.menu;
3320
- this.detachToTarget.appendChild(this.menuEl);
3321
- resolve();
3322
- });
3323
- });
3324
- },
3325
- removeMenu() {
3326
- if (this.menuEl && this.menuEl.parentNode)
3327
- this.menuEl.remove();
3328
3365
  }
3329
3366
  },
3330
3367
  mounted() {
@@ -3340,7 +3377,7 @@ const __vue2_script$s = {
3340
3377
  this.toggleMenu({ type: "click", target: this.activatorEl });
3341
3378
  },
3342
3379
  beforeDestroy() {
3343
- this.removeMenu();
3380
+ this.removeFromDOM();
3344
3381
  if (this.overlay && this.overlayEl.parentNode)
3345
3382
  this.overlayEl.remove();
3346
3383
  if (this.activatorEl && this.activatorEl.parentNode)
@@ -3348,12 +3385,16 @@ const __vue2_script$s = {
3348
3385
  },
3349
3386
  watch: {
3350
3387
  value(bool) {
3351
- if (!!bool !== this.menuVisible)
3388
+ if (!!bool !== this.detachableVisible)
3352
3389
  this.toggleMenu({ type: "click", target: this.activatorEl });
3353
3390
  },
3354
3391
  detachTo() {
3355
- this.removeMenu();
3356
- this.insertMenu();
3392
+ this.removeFromDOM();
3393
+ this.insertInDOM();
3394
+ },
3395
+ appendTo() {
3396
+ this.removeFromDOM();
3397
+ this.insertInDOM();
3357
3398
  }
3358
3399
  }
3359
3400
  };
@@ -4018,7 +4059,7 @@ var render$k = function() {
4018
4059
  var _c = _vm._self._c || _h;
4019
4060
  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) {
4020
4061
  _vm.valid = $event;
4021
- }, "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) {
4062
+ }, "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) {
4022
4063
  var _obj, _obj$1;
4023
4064
  ref.on;
4024
4065
  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) {
@@ -5491,13 +5532,13 @@ var render$8 = function() {
5491
5532
  var _vm = this;
5492
5533
  var _h = _vm.$createElement;
5493
5534
  var _c = _vm._self._c || _h;
5494
- 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);
5535
+ 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);
5495
5536
  };
5496
5537
  var staticRenderFns$8 = [];
5497
5538
  var wTooltip_vue_vue_type_style_index_0_lang = "";
5498
- const marginFromWindowSide = 4;
5499
5539
  const __vue2_script$8 = {
5500
5540
  name: "w-tooltip",
5541
+ mixins: [DetachableMixin],
5501
5542
  props: {
5502
5543
  value: {},
5503
5544
  showOnClick: { type: Boolean },
@@ -5509,25 +5550,31 @@ const __vue2_script$8 = {
5509
5550
  round: { type: Boolean },
5510
5551
  transition: { type: String },
5511
5552
  tooltipClass: { type: [String, Object, Array] },
5512
- detachTo: {},
5553
+ detachTo: { type: [String, Boolean, Object], deprecated: true },
5554
+ appendTo: { type: [String, Boolean, Object] },
5513
5555
  fixed: { type: Boolean },
5514
5556
  top: { type: Boolean },
5515
5557
  bottom: { type: Boolean },
5516
5558
  left: { type: Boolean },
5517
5559
  right: { type: Boolean },
5518
- zIndex: { type: [Number, String, Boolean] }
5560
+ alignTop: { type: Boolean },
5561
+ alignBottom: { type: Boolean },
5562
+ alignLeft: { type: Boolean },
5563
+ alignRight: { type: Boolean },
5564
+ zIndex: { type: [Number, String, Boolean] },
5565
+ persistent: { type: Boolean },
5566
+ noPosition: { type: Boolean }
5519
5567
  },
5520
5568
  emits: ["input", "update:modelValue", "open", "close"],
5521
5569
  data: () => ({
5522
- showTooltip: false,
5523
- coordinates: {
5570
+ detachableVisible: false,
5571
+ hoveringActivator: false,
5572
+ detachableCoords: {
5524
5573
  top: 0,
5525
- left: 0,
5526
- width: 0,
5527
- height: 0
5574
+ left: 0
5528
5575
  },
5529
5576
  activatorEl: null,
5530
- tooltipEl: null,
5577
+ detachableEl: null,
5531
5578
  timeoutId: null
5532
5579
  }),
5533
5580
  computed: {
@@ -5538,68 +5585,23 @@ const __vue2_script$8 = {
5538
5585
  const direction = this.position.replace(/top|bottom/, (m) => ({ top: "up", bottom: "down" })[m]);
5539
5586
  return this.transition || `w-tooltip-slide-fade-${direction}`;
5540
5587
  },
5541
- detachToTarget() {
5542
- let target = this.detachTo || ".w-app";
5543
- if (target === true)
5544
- target = ".w-app";
5545
- else if (target && !["object", "string"].includes(typeof target))
5546
- target = ".w-app";
5547
- else if (typeof target === "object" && !target.nodeType) {
5548
- target = ".w-app";
5549
- consoleWarn("Invalid node provided in w-tooltip `attach-to`. Falling back to .w-app.");
5550
- }
5551
- if (typeof target === "string")
5552
- target = document.querySelector(target);
5553
- if (!target) {
5554
- consoleWarn(`Unable to locate ${this.detachTo ? `target ${this.detachTo}` : ".w-app"}`);
5555
- target = document.querySelector(".w-app");
5556
- }
5557
- return target;
5558
- },
5559
- tooltipParentEl() {
5560
- return this.detachTo ? this.detachToTarget : this.$el;
5561
- },
5562
5588
  position() {
5563
5589
  return this.top && "top" || this.bottom && "bottom" || this.left && "left" || this.right && "right" || "bottom";
5564
5590
  },
5565
- tooltipCoordinates() {
5566
- const coords = {};
5567
- const { top, left, width, height } = this.coordinates;
5568
- switch (this.position) {
5569
- case "top": {
5570
- coords.top = top;
5571
- coords.left = left + width / 2;
5572
- break;
5573
- }
5574
- case "bottom": {
5575
- coords.top = top + height;
5576
- coords.left = left + width / 2;
5577
- break;
5578
- }
5579
- case "left": {
5580
- coords.top = top + height / 2;
5581
- coords.left = left;
5582
- break;
5583
- }
5584
- case "right": {
5585
- coords.top = top + height / 2;
5586
- coords.left = left + width;
5587
- break;
5588
- }
5589
- }
5590
- return coords;
5591
+ alignment() {
5592
+ 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" || "";
5591
5593
  },
5592
5594
  classes() {
5593
5595
  return __spreadProps(__spreadValues({
5594
5596
  [this.color]: this.color,
5595
5597
  [`${this.bgColor}--bg`]: this.bgColor
5596
5598
  }, this.tooltipClasses), {
5597
- [`w-tooltip--${this.position}`]: true,
5599
+ [`w-tooltip--${this.position}`]: !this.noPosition,
5600
+ [`w-tooltip--align-${this.alignment}`]: !this.noPosition && this.alignment,
5598
5601
  "w-tooltip--tile": this.tile,
5599
5602
  "w-tooltip--round": this.round,
5600
5603
  "w-tooltip--shadow": this.shadow,
5601
5604
  "w-tooltip--fixed": this.fixed,
5602
- "w-tooltip--active": this.showTooltip,
5603
5605
  "w-tooltip--no-border": this.noBorder || this.bgColor,
5604
5606
  "w-tooltip--custom-transition": this.transition
5605
5607
  });
@@ -5607,8 +5609,8 @@ const __vue2_script$8 = {
5607
5609
  styles() {
5608
5610
  return {
5609
5611
  zIndex: this.zIndex || this.zIndex === 0 || null,
5610
- top: this.tooltipCoordinates.top && `${~~this.tooltipCoordinates.top}px` || null,
5611
- left: this.tooltipCoordinates.left && `${~~this.tooltipCoordinates.left}px` || null,
5612
+ top: this.detachableCoords.top && `${~~this.detachableCoords.top}px` || null,
5613
+ left: this.detachableCoords.left && `${~~this.detachableCoords.left}px` || null,
5612
5614
  "--w-tooltip-bg-color": this.$waveui.colors[this.bgColor || "white"]
5613
5615
  };
5614
5616
  },
@@ -5620,10 +5622,16 @@ const __vue2_script$8 = {
5620
5622
  handlers = {
5621
5623
  focus: this.toggle,
5622
5624
  blur: this.toggle,
5623
- mouseenter: this.toggle,
5624
- mouseleave: this.toggle
5625
+ mouseenter: (e) => {
5626
+ this.hoveringActivator = true;
5627
+ this.open(e);
5628
+ },
5629
+ mouseleave: (e) => {
5630
+ this.hoveringActivator = false;
5631
+ this.close();
5632
+ }
5625
5633
  };
5626
- if ("ontouchstart" in window)
5634
+ if (typeof window !== "undefined" && "ontouchstart" in window)
5627
5635
  handlers.click = this.toggle;
5628
5636
  }
5629
5637
  return handlers;
@@ -5631,8 +5639,8 @@ const __vue2_script$8 = {
5631
5639
  },
5632
5640
  methods: {
5633
5641
  toggle(e) {
5634
- let shouldShowTooltip = this.showTooltip;
5635
- if ("ontouchstart" in window) {
5642
+ let shouldShowTooltip = this.detachableVisible;
5643
+ if (typeof window !== "undefined" && "ontouchstart" in window) {
5636
5644
  if (e.type === "click")
5637
5645
  shouldShowTooltip = !shouldShowTooltip;
5638
5646
  } else if (e.type === "click" && this.showOnClick)
@@ -5643,89 +5651,69 @@ const __vue2_script$8 = {
5643
5651
  shouldShowTooltip = false;
5644
5652
  this.timeoutId = clearTimeout(this.timeoutId);
5645
5653
  if (shouldShowTooltip) {
5646
- this.coordinates = this.getCoordinates(e);
5647
- this.timeoutId = setTimeout(() => {
5648
- this.showTooltip = true;
5649
- this.$emit("update:modelValue", true);
5650
- this.$emit("input", true);
5651
- this.$emit("open");
5652
- }, 10);
5653
- } else {
5654
- this.showTooltip = false;
5655
- this.$emit("update:modelValue", false);
5656
- this.$emit("input", false);
5657
- this.$emit("close");
5658
- }
5659
- },
5660
- getCoordinates() {
5661
- const { top, left, width, height } = this.activatorEl.getBoundingClientRect();
5662
- let coords = { top, left, width, height };
5663
- if (!this.fixed) {
5664
- const { top: targetTop, left: targetLeft } = this.tooltipParentEl.getBoundingClientRect();
5665
- coords = __spreadProps(__spreadValues({}, coords), { top: top - targetTop, left: left - targetLeft });
5666
- }
5667
- const tooltipEl = this.$refs.tooltip;
5668
- tooltipEl.style.visibility = "hidden";
5669
- tooltipEl.style.display = "table";
5670
- const computedStyles2 = window.getComputedStyle(tooltipEl, null);
5671
- if (this.position === "top" && top - tooltipEl.offsetHeight < 0) {
5672
- const margin = -parseInt(computedStyles2.getPropertyValue("margin-top"));
5673
- coords.top -= top - tooltipEl.offsetHeight - margin - marginFromWindowSide;
5674
- } else if (this.position === "left" && left - tooltipEl.offsetWidth < 0) {
5675
- const margin = -parseInt(computedStyles2.getPropertyValue("margin-left"));
5676
- coords.left -= left - tooltipEl.offsetWidth - margin - marginFromWindowSide;
5677
- } else if (this.position === "right" && left + width + tooltipEl.offsetWidth > window.innerWidth) {
5678
- const margin = parseInt(computedStyles2.getPropertyValue("margin-left"));
5679
- coords.left -= left + width + tooltipEl.offsetWidth - window.innerWidth + margin + marginFromWindowSide;
5680
- } else if (this.position === "bottom" && top + height + tooltipEl.offsetHeight > window.innerHeight) {
5681
- const margin = parseInt(computedStyles2.getPropertyValue("margin-top"));
5682
- coords.top -= top + height + tooltipEl.offsetHeight - window.innerHeight + margin + marginFromWindowSide;
5683
- }
5684
- if (this.transition) {
5685
- if (["top", "bottom"].includes(this.position))
5686
- coords.left -= tooltipEl.offsetWidth / 2;
5687
- if (["left", "right"].includes(this.position))
5688
- coords.top -= tooltipEl.offsetHeight / 2;
5689
- if (this.position === "left")
5690
- coords.left -= tooltipEl.offsetWidth;
5691
- if (this.position === "top")
5692
- coords.top -= tooltipEl.offsetHeight;
5693
- }
5694
- tooltipEl.style.visibility = null;
5695
- tooltipEl.style.display = "none";
5696
- return coords;
5654
+ this.$emit("update:modelValue", this.detachableVisible = true);
5655
+ this.$emit("input", true);
5656
+ this.$emit("open");
5657
+ this.open(e);
5658
+ } else
5659
+ this.close();
5697
5660
  },
5698
- insertTooltip() {
5699
- const wrapper = this.$el;
5700
- this.tooltipEl = this.$refs.tooltip.$el || this.$refs.tooltip;
5701
- wrapper.parentNode.insertBefore(this.activatorEl, wrapper);
5702
- this.detachToTarget.appendChild(this.$refs.tooltip);
5661
+ async open(e) {
5662
+ this.detachableVisible = true;
5663
+ await this.insertInDOM();
5664
+ if (this.minWidth === "activator")
5665
+ this.activatorWidth = this.activatorEl.offsetWidth;
5666
+ if (!this.noPosition)
5667
+ this.computeDetachableCoords(e);
5668
+ this.timeoutId = setTimeout(() => {
5669
+ this.$emit("update:modelValue", true);
5670
+ this.$emit("input", true);
5671
+ this.$emit("open");
5672
+ }, 0);
5673
+ if (!this.persistent)
5674
+ document.addEventListener("mousedown", this.onOutsideMousedown);
5675
+ if (!this.noPosition)
5676
+ window.addEventListener("resize", this.onResize);
5703
5677
  },
5704
- removeTooltip() {
5705
- if (this.tooltipEl && this.tooltipEl.parentNode)
5706
- this.tooltipEl.remove();
5678
+ async close(force = false) {
5679
+ if (!this.detachableVisible)
5680
+ return;
5681
+ if (this.showOnHover && !force) {
5682
+ await new Promise((resolve) => setTimeout(resolve, 10));
5683
+ if (this.showOnHover && this.hoveringActivator)
5684
+ return;
5685
+ }
5686
+ this.$emit("update:modelValue", this.detachableVisible = false);
5687
+ this.$emit("input", false);
5688
+ this.$emit("close");
5689
+ document.removeEventListener("mousedown", this.onOutsideMousedown);
5690
+ window.removeEventListener("resize", this.onResize);
5707
5691
  }
5708
5692
  },
5709
5693
  mounted() {
5710
- this.activatorEl = this.$el.firstElementChild;
5711
- if (this.detachTo)
5712
- this.insertTooltip();
5694
+ const wrapper = this.$el;
5695
+ this.activatorEl = wrapper.firstElementChild;
5696
+ wrapper.parentNode.insertBefore(this.activatorEl, wrapper);
5713
5697
  if (this.value)
5714
5698
  this.toggle({ type: "click", target: this.activatorEl });
5715
5699
  },
5716
5700
  beforeDestroy() {
5717
- this.removeTooltip();
5701
+ this.removeFromDOM();
5718
5702
  if (this.activatorEl && this.activatorEl.parentNode)
5719
5703
  this.activatorEl.remove();
5720
5704
  },
5721
5705
  watch: {
5722
5706
  value(bool) {
5723
- if (bool !== this.showTooltip)
5707
+ if (bool !== this.detachableVisible)
5724
5708
  this.toggle({ type: "click", target: this.activatorEl });
5725
5709
  },
5726
5710
  detachTo() {
5727
- this.removeTooltip();
5728
- this.insertTooltip();
5711
+ this.removeFromDOM();
5712
+ this.insertInDOM();
5713
+ },
5714
+ appendTo() {
5715
+ this.removeFromDOM();
5716
+ this.insertInDOM();
5729
5717
  }
5730
5718
  }
5731
5719
  };