wave-ui 3.0.5 → 3.1.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.0.5",
3
+ "version": "3.1.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",
@@ -119,7 +119,9 @@ component(
119
119
 
120
120
  <script>
121
121
  /**
122
- * @todo Share the common parts between w-input, w-textarea & w-select.
122
+ * @todo
123
+ * - Share the common parts between w-input, w-textarea & w-select.
124
+ * - option to fit to the content using contenteditable div
123
125
  **/
124
126
 
125
127
  import FormElementMixin from '../mixins/form-elements'
@@ -581,6 +583,7 @@ $inactive-color: #777;
581
583
  top: 50%;
582
584
  left: 0;
583
585
  padding-left: 2 * $base-increment;
586
+ white-space: nowrap;
584
587
  transform: translateY(-50%);
585
588
  pointer-events: none;
586
589
 
@@ -40,21 +40,19 @@ component(
40
40
  .w-select__selection-slot(v-if="$slots.selection")
41
41
  //- inputValue is always an array.
42
42
  slot(name="selection" :item="multiple ? inputValue : inputValue[0]")
43
- input.w-select__selection(
43
+ .w-select__selection(
44
44
  ref="selection-input"
45
- type="text"
46
- :value="$slots.selection ? '' : selectionString"
45
+ :contenteditable="isDisabled || isReadonly ? 'false' : 'true'"
47
46
  @focus="!isDisabled && !isReadonly && onFocus($event)"
48
47
  @blur="onBlur"
49
48
  @keydown="!isDisabled && !isReadonly && onKeydown($event)"
50
49
  :id="`w-select--${_.uid}`"
51
- :placeholder="(!$slots.selection && placeholder) || null"
50
+ :class="{ 'w-select__selection--placeholder': !$slots.selection && !selectionString && placeholder }"
52
51
  :disabled="isDisabled || null"
53
52
  readonly
54
53
  aria-readonly="true"
55
- :required="required || null"
56
54
  :tabindex="tabindex || null"
57
- autocomplete="off")
55
+ v-html="$slots.selection ? '' : selectionString || placeholder")
58
56
  //- For standard HTML form submission.
59
57
  input(
60
58
  v-for="(val, i) in (inputValue.length ? inputValue : [{}])"
@@ -149,7 +147,8 @@ export default {
149
147
  noUnselect: { type: Boolean },
150
148
  menuProps: { type: Object }, // Allow passing down an object of props to the w-menu component.
151
149
  dark: { type: Boolean },
152
- light: { type: Boolean }
150
+ light: { type: Boolean },
151
+ fitToContent: { type: Boolean }
153
152
  // Props from mixin: name, disabled, readonly, required, tabindex, validators.
154
153
  // Computed from mixin: inputName, isDisabled & isReadonly.
155
154
  },
@@ -200,6 +199,7 @@ export default {
200
199
  'w-select--dark': this.dark,
201
200
  'w-select--light': this.light,
202
201
  'w-select--disabled': this.isDisabled,
202
+ 'w-select--fit-to-content': this.fitToContent,
203
203
  'w-select--readonly': this.isReadonly,
204
204
  [`w-select--${this.hasValue ? 'filled' : 'empty'}`]: true,
205
205
  'w-select--focused': (this.isFocused || this.showMenu) && !this.isReadonly,
@@ -230,6 +230,7 @@ export default {
230
230
  onFocus (e) {
231
231
  this.isFocused = true
232
232
  this.$emit('focus', e)
233
+ return false
233
234
  },
234
235
 
235
236
  onBlur (e) {
@@ -238,6 +239,11 @@ export default {
238
239
  },
239
240
 
240
241
  onKeydown (e) {
242
+ // Forbid typing in contenteditable element.
243
+ // Note: using contenteditable rather than input in order to be able to fit the select list
244
+ // to its content with CSS. Only contenteditable divs/non-interactive elements can react to focus/blur ).
245
+ e.preventDefault()
246
+
241
247
  if ([13, 27, 38, 40].includes(e.keyCode)) e.preventDefault()
242
248
 
243
249
  if (e.keyCode === 27) this.closeMenu() // Escape.
@@ -300,7 +306,6 @@ export default {
300
306
  // Also accept objects if returnObject is true.
301
307
  // In any case, always end up with an array.
302
308
  checkSelection (items) {
303
- console.log(items)
304
309
  items = Array.isArray(items) ? items : (items !== undefined ? [items] : [])
305
310
  // `selectItems` items always have a value.
306
311
  const allValues = this.selectItems.map(item => item.value)
@@ -368,6 +373,11 @@ export default {
368
373
  -webkit-tap-highlight-color: transparent;
369
374
  }
370
375
 
376
+ &--fit-to-content {
377
+ display: inline-flex;
378
+ flex-grow: 0;
379
+ }
380
+
371
381
  // Selection wrapper.
372
382
  // ------------------------------------------------------
373
383
  &__selection-wrap {
@@ -423,21 +433,21 @@ export default {
423
433
  }
424
434
  }
425
435
 
426
- // selection (input) field.
436
+ // Selection (contenteditable) field.
437
+ // Using contenteditable instead of readonly input in order to be able to fit to content.
438
+ // Then disable typing and hide caret.
427
439
  // ------------------------------------------------------
428
440
  &__selection {
429
441
  width: 100%;
430
442
  height: 100%;
431
443
  min-height: inherit;
432
- font: inherit;
433
- color: inherit;
434
- text-align: inherit;
435
- background: none;
436
- border: none;
437
444
  outline: none;
438
445
  padding-left: 2 * $base-increment;
439
446
  padding-right: 2 * $base-increment;
447
+ display: flex;
448
+ align-items: center;
440
449
  cursor: pointer;
450
+ caret-color: transparent;
441
451
 
442
452
  .w-select__selection-slot + & {
443
453
  position: absolute;
@@ -463,9 +473,9 @@ export default {
463
473
  -webkit-tap-highlight-color: transparent;
464
474
  }
465
475
 
466
- .w-select--disabled input::placeholder {color: inherit;}
467
-
468
476
  .w-select--readonly & {cursor: auto;}
477
+
478
+ &--placeholder {color: #888;}
469
479
  }
470
480
 
471
481
  &__selection-slot {
@@ -529,6 +539,7 @@ export default {
529
539
  top: 50%;
530
540
  left: 0;
531
541
  right: 0;
542
+ white-space: nowrap;
532
543
  // Use margin instead of padding as the scale transformation below decreases the real padding
533
544
  // size and misaligns the label.
534
545
  margin-left: 2 * $base-increment;
@@ -355,6 +355,7 @@ $inactive-color: #777;
355
355
  top: $base-increment;
356
356
  left: 0;
357
357
  padding-left: 2 * $base-increment;
358
+ white-space: nowrap;
358
359
  transform: translateY(0%);
359
360
  pointer-events: none;
360
361