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