wave-ui 3.5.2 → 3.6.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wave-ui",
3
- "version": "3.5.2",
3
+ "version": "3.6.0",
4
4
  "description": "An emerging UI framework for Vue.js (2 & 3) with only the bright side. :sunny:",
5
5
  "author": "Antoni Andre <antoniandre.web@gmail.com>",
6
6
  "homepage": "https://antoniandre.github.io/wave-ui",
@@ -282,7 +282,10 @@ $spinner-size: 40;
282
282
 
283
283
  // Active state.
284
284
  &:active {transform: scale(1.02);}
285
- &:active:before {opacity: 0.3;}
285
+ &:active:before {
286
+ opacity: 0.3;
287
+ @include default-transition($fast-transition-duration);
288
+ }
286
289
  &--dark:active:before, &.primary--bg:active:before {opacity: 0.35;}
287
290
 
288
291
  // Disable visual feedback on loading and disabled buttons.
@@ -571,6 +571,7 @@ $inactive-color: #777;
571
571
  &__label {
572
572
  transition: color $transition-duration;
573
573
  cursor: pointer;
574
+ user-select: none;
574
575
 
575
576
  &--left {margin-right: 2 * $base-increment;}
576
577
  &--right {margin-left: 2 * $base-increment;}
@@ -168,7 +168,7 @@ export default {
168
168
  top: (this.detachableCoords.top && `${~~this.detachableCoords.top}px`) || null,
169
169
  left: (this.detachableCoords.left && `${~~this.detachableCoords.left}px`) || null,
170
170
  minWidth: (this.minWidth && this.menuMinWidth) || null,
171
- '--w-menu-bg-color': this.arrow && this.$waveui.colors[this.bgColor || 'white']
171
+ '--w-menu-bg-color': this.arrow && (this.$waveui.colors[this.bgColor] || 'rgb(var(--w-base-bg-color-rgb))')
172
172
  }
173
173
  },
174
174
 
@@ -300,7 +300,7 @@ export default {
300
300
  &.w-menu--left {margin-left: -4 * $base-increment;}
301
301
  &.w-menu--right {margin-left: 4 * $base-increment;}
302
302
 
303
- @include triangle($menu-bg-color, '.w-menu', 9px);
303
+ @include triangle(var(--w-menu-bg-color), '.w-menu', 9px);
304
304
  }
305
305
  }
306
306
  </style>
@@ -529,6 +529,7 @@ export default {
529
529
  align-items: center;
530
530
  transition: color $transition-duration;
531
531
  cursor: pointer;
532
+ user-select: none;
532
533
 
533
534
  &--left {margin-right: 2 * $base-increment;}
534
535
  &--right {margin-left: 2 * $base-increment;}
@@ -330,6 +330,7 @@ $inactive-color: #777;
330
330
  transition: color $transition-duration;
331
331
  cursor: pointer;
332
332
  align-self: flex-start;
333
+ user-select: none;
333
334
 
334
335
  &--left {
335
336
  margin-top: $base-increment;
@@ -34,7 +34,14 @@ export default {
34
34
  persistent: { type: Boolean },
35
35
  delay: { type: Number },
36
36
  dark: { type: Boolean },
37
- light: { type: Boolean }
37
+ light: { type: Boolean },
38
+ caption: { type: Boolean }, // Apply the caption class and style (grey, italic, small).
39
+ xs: { type: Boolean },
40
+ sm: { type: Boolean },
41
+ md: { type: Boolean },
42
+ lg: { type: Boolean },
43
+ xl: { type: Boolean },
44
+ enableTouch: { type: Boolean }
38
45
  // Other props in the detachable mixin:
39
46
  // detachTo, appendTo, fixed, top, bottom, left, right, alignTop, alignBottom, alignLeft,
40
47
  // alignRight, noPosition, zIndex, activator.
@@ -73,6 +80,17 @@ export default {
73
80
  return this.transition || `w-tooltip-slide-fade-${direction}`
74
81
  },
75
82
 
83
+ size () {
84
+ return (
85
+ (this.xs && 'xs') ||
86
+ (this.sm && 'sm') ||
87
+ (this.sm && 'md') ||
88
+ (this.lg && 'lg') ||
89
+ (this.xl && 'xl') ||
90
+ (this.caption ? 'sm' : 'md') // if no size is set put md by default, or sm if caption is on.
91
+ )
92
+ },
93
+
76
94
  classes () {
77
95
  return {
78
96
  [this.color]: this.color,
@@ -84,6 +102,8 @@ export default {
84
102
  'w-tooltip--light': this.light,
85
103
  'w-tooltip--tile': this.tile,
86
104
  'w-tooltip--round': this.round,
105
+ caption: this.caption,
106
+ [`size--${this.size}`]: true,
87
107
  'w-tooltip--shadow': this.shadow,
88
108
  'w-tooltip--fixed': this.fixed,
89
109
  'w-tooltip--no-border': this.noBorder || this.bgColor,
@@ -97,17 +117,21 @@ export default {
97
117
  zIndex: this.zIndex || this.zIndex === 0 || null,
98
118
  top: (this.detachableCoords.top && `${~~this.detachableCoords.top}px`) || null,
99
119
  left: (this.detachableCoords.left && `${~~this.detachableCoords.left}px`) || null,
100
- '--w-tooltip-bg-color': this.$waveui.colors[this.bgColor || 'white']
120
+ '--w-tooltip-bg-color': this.$waveui.colors[this.bgColor] || 'rgb(var(--w-base-bg-color-rgb))'
101
121
  }
102
122
  },
103
123
 
104
124
  activatorEventHandlers () {
105
125
  let handlers = {}
106
- if (this.showOnClick) handlers = { click: this.toggle }
107
- else {
126
+
127
+ // Check the window exists: SSR-proof.
128
+ const isTouchDevice = typeof window !== 'undefined' && 'ontouchstart' in window
129
+
130
+ // Toggling tooltip on mouseenter/mouseout (by default), and also show on focus, hide on blur.
131
+ if (!this.showOnClick && !isTouchDevice) {
108
132
  handlers = {
109
- focus: this.toggle,
110
- blur: this.toggle,
133
+ focus: this.open,
134
+ blur: this.close,
111
135
  mouseenter: e => {
112
136
  this.hoveringActivator = true
113
137
  this.open(e)
@@ -117,10 +141,10 @@ export default {
117
141
  this.close()
118
142
  }
119
143
  }
120
-
121
- // Check the window exists: SSR-proof.
122
- if (typeof window !== 'undefined' && 'ontouchstart' in window) handlers.click = this.toggle
123
144
  }
145
+ // Only bind a click event on mobile, or if showOnClick is set.
146
+ else if (this.enableTouch || this.showOnClick) handlers = { click: this.toggle }
147
+
124
148
  return handlers
125
149
  }
126
150
  },
@@ -140,8 +164,12 @@ export default {
140
164
  // ! \ This function uses the DOM - NO SSR (only trigger from beforeMount and later).
141
165
  toggle (e) {
142
166
  let shouldShowTooltip = this.detachableVisible
167
+
168
+ // For touch devices.
143
169
  if (typeof window !== 'undefined' && 'ontouchstart' in window) {
144
- if (e.type === 'click') shouldShowTooltip = !shouldShowTooltip
170
+ // disable tooltip opening for mouseenter activation.
171
+ if (!this.enableTouch && !this.showOnClick) shouldShowTooltip = false
172
+ else shouldShowTooltip = !shouldShowTooltip
145
173
  }
146
174
  else if (e.type === 'click' && this.showOnClick) shouldShowTooltip = !shouldShowTooltip
147
175
  else if (['mouseenter', 'focus'].includes(e.type) && !this.showOnClick) shouldShowTooltip = true
@@ -220,16 +248,22 @@ export default {
220
248
  &--left {margin-left: -3 * $base-increment;}
221
249
  &--right {margin-left: 3 * $base-increment;}
222
250
 
251
+ &.size--xs {font-size: 0.75rem;}
252
+ &.size--sm {font-size: 0.83rem;}
253
+ &.size--md {font-size: 0.9rem;}
254
+ &.size--lg {font-size: 1rem;}
255
+ &.size--xl {font-size: 1.1rem;}
256
+
223
257
  &--custom-transition {transform: none;}
224
258
 
225
259
  // Tooltip without border.
226
260
  &--no-border {
227
- @include triangle($tooltip-bg-color, '.w-tooltip', 7px, 0);
261
+ @include triangle(var(--w-tooltip-bg-color), '.w-tooltip', 7px, 0);
228
262
  }
229
263
 
230
264
  // Tooltip with border.
231
265
  &:not(&--no-border) {
232
- @include triangle($tooltip-bg-color, '.w-tooltip', 7px);
266
+ @include triangle(var(--w-tooltip-bg-color), '.w-tooltip', 7px);
233
267
  }
234
268
  }
235
269
 
@@ -331,14 +331,17 @@ export default {
331
331
  else {
332
332
  this.$nextTick(() => {
333
333
  if (this.activator) this.bindActivatorEvents()
334
- if (this.modelValue) this.toggle({ type: 'click', target: this.activatorEl })
334
+ if (this.modelValue) this.open({ target: this.activatorEl })
335
335
  })
336
336
  }
337
337
 
338
338
  // Unwrap the overlay if any.
339
339
  if (this.overlay) this.overlayEl = this.$refs.overlay?.$el
340
340
 
341
- if (this.modelValue && this.activator) this.toggle({ type: 'click', target: this.activatorEl })
341
+ if (this.modelValue && this.activator) {
342
+ this.toggle({ type: this.showOnClick ? 'click' : 'mouseenter', target: this.activatorEl })
343
+ }
344
+ else if (this.modelValue) this.open({ target: this.activatorEl })
342
345
  },
343
346
 
344
347
  unmounted () {
@@ -357,7 +360,7 @@ export default {
357
360
 
358
361
  watch: {
359
362
  modelValue (bool) {
360
- if (!!bool !== this.detachableVisible) this.toggle({ type: 'click', target: this.activatorEl })
363
+ if (!!bool !== this.detachableVisible) this.toggle({ type: this.showOnClick ? 'click' : 'mouseenter', target: this.activatorEl })
361
364
  },
362
365
  appendTo () {
363
366
  this.removeFromDOM()