goodteditor-ui 1.0.93 → 1.0.95

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": "goodteditor-ui",
3
- "version": "1.0.93",
3
+ "version": "1.0.95",
4
4
  "main": "index.js",
5
5
  "homepage": "https://goodt-ui.netlify.app/",
6
6
  "scripts": {
@@ -4,8 +4,7 @@
4
4
  :class="cssClass"
5
5
  @focus="onRootFocus"
6
6
  tabindex="0"
7
- :data-popover="popoverTargetId"
8
- >
7
+ :data-popover="popoverTargetId">
9
8
  <div class="ui-input-color-picker-wrapper d-flex flex-v-center w-100">
10
9
  <div style="flex: 1 0 0">
11
10
  <!--
@@ -22,8 +21,7 @@
22
21
  type="text"
23
22
  :value="value"
24
23
  v-bind="inputBinds"
25
- v-on="inputEvents"
26
- />
24
+ v-on="inputEvents" />
27
25
  </slot>
28
26
  </div>
29
27
  <!--
@@ -34,10 +32,9 @@
34
32
  <slot name="icon" v-bind="{ value, toggle: togglePopover }">
35
33
  <div
36
34
  class="ui-input-color-picker-icon-preview mar-left-2"
37
- :class="[ readonly ? 'events-none': 'cursor-pointer' ]"
35
+ :class="[readonly ? 'events-none' : 'cursor-pointer']"
38
36
  :style="{ ...(isValid && { background: value }) }"
39
- @click="togglePopover"
40
- ></div>
37
+ @click="togglePopover"></div>
41
38
  </slot>
42
39
  </div>
43
40
  <ui-popover v-if="popoverShow" :show.sync="popoverShow" v-bind="popoverOptions">
@@ -46,12 +43,11 @@
46
43
  v-bind="{
47
44
  value,
48
45
  colorsDefault,
49
- showSubmit: true,
46
+ showSubmit: true
50
47
  }"
51
48
  @close="onColorPickerClose"
52
49
  @submit="onColorPickerSubmit"
53
- @valid="emitValid"
54
- ></color-picker>
50
+ @valid="emitValid"></color-picker>
55
51
  </ui-popover>
56
52
  </div>
57
53
  </template>
@@ -124,7 +120,6 @@ export default {
124
120
  },
125
121
  data() {
126
122
  return {
127
- isValid: false,
128
123
  inputBinds: {
129
124
  placeholder: this.placeholder,
130
125
  readonly: this.readonly || !this.editable,
@@ -139,8 +134,21 @@ export default {
139
134
  }
140
135
  };
141
136
  },
142
- created() {
143
- this.validateInput(this.value);
137
+ computed: {
138
+ /**
139
+ * @return {boolean}
140
+ */
141
+ isValid() {
142
+ return this.value === '' ? true : isValidColorString(this.value);
143
+ }
144
+ },
145
+ watch: {
146
+ isValid: {
147
+ handler() {
148
+ this.emitValid(this.isValid);
149
+ },
150
+ immediate: true
151
+ }
144
152
  },
145
153
  methods: {
146
154
  inputColor(val) {
@@ -160,11 +168,6 @@ export default {
160
168
  emitValid(isValid) {
161
169
  this.$emit('valid', isValid);
162
170
  },
163
- validateInput(value) {
164
- const isValid = value === '' ? true : isValidColorString(value);
165
- this.isValid = isValid;
166
- this.emitValid(isValid);
167
- },
168
171
  // EVENT HANDLERS
169
172
  onRootFocus(e) {
170
173
  if (this.disabled) {
@@ -175,13 +178,11 @@ export default {
175
178
  },
176
179
  onInputChange(e) {
177
180
  const { value } = e.target;
178
- this.validateInput(value);
179
181
  this.changeColor(value);
180
182
  },
181
183
  onInputInput(e) {
182
184
  const { value } = e.target;
183
- this.validateInput(value);
184
- this.inputColor(e.target.value);
185
+ this.inputColor(value);
185
186
  },
186
187
  onInputFocus(e) {
187
188
  if (this.disabled) {
@@ -27,10 +27,10 @@
27
27
  }">
28
28
  <ui-badge
29
29
  class="mar-none mar-right-2"
30
- theme="primary"
30
+ :theme="selectedBadgeTheme"
31
31
  size="small"
32
32
  :key="index"
33
- removable
33
+ :removable="isSelectedRemovable"
34
34
  @click.native.stop
35
35
  @remove="deselectOption(option)">
36
36
  <span>{{ getOptionLabel(option) }}</span>
@@ -79,20 +79,23 @@
79
79
  @slot Open state icon slot
80
80
  -->
81
81
  <slot name="icon-open" v-if="popoverShow">
82
- <i class="icon mdi mdi-chevron-up" :class="{
83
- 'mdi-18px': size === '',
84
- 'h-auto w-auto': size === 'small'
85
- }">
86
- </i>
82
+ <i
83
+ class="icon mdi mdi-chevron-up"
84
+ :class="{
85
+ 'mdi-18px': size === '',
86
+ 'h-auto w-auto': size === 'small'
87
+ }"></i>
87
88
  </slot>
88
89
  <!--
89
90
  @slot Close state icon slot
90
91
  -->
91
92
  <slot name="icon-close" v-else>
92
- <i class="icon mdi mdi-chevron-down" :class="{
93
- 'mdi-18px': size === '',
94
- 'h-auto w-auto': size === 'small'
95
- }"></i>
93
+ <i
94
+ class="icon mdi mdi-chevron-down"
95
+ :class="{
96
+ 'mdi-18px': size === '',
97
+ 'h-auto w-auto': size === 'small'
98
+ }"></i>
96
99
  </slot>
97
100
 
98
101
  <ui-popover :show.sync="popoverShow" v-bind="popoverOptions">
@@ -375,7 +378,7 @@ export default {
375
378
  itemHeight: {
376
379
  type: String,
377
380
  default: null
378
- },
381
+ }
379
382
  },
380
383
  data() {
381
384
  return {
@@ -388,8 +391,17 @@ export default {
388
391
  * @return {object}
389
392
  */
390
393
  cssClassExt() {
391
- let obj = { 'u-select-none': this.readonly };
392
- return { ...this.cssClass, ...obj };
394
+ if (this.readonly) {
395
+ const { ['events-none']: eventsNone, ...cssClass } = this.cssClass;
396
+ return cssClass;
397
+ }
398
+ return this.cssClass;
399
+ },
400
+ selectedBadgeTheme() {
401
+ return this.disabled ? '' : 'primary';
402
+ },
403
+ isSelectedRemovable() {
404
+ return this.readonly === false && this.disabled === false;
393
405
  }
394
406
  },
395
407
  watch: {
@@ -487,6 +499,9 @@ export default {
487
499
  };
488
500
  },
489
501
  selectOption(option) {
502
+ if (this.readonly) {
503
+ return;
504
+ }
490
505
  if (this.isOptionSelected(option)) {
491
506
  return;
492
507
  }
@@ -502,6 +517,9 @@ export default {
502
517
  this.triggerModelChange(rollback);
503
518
  },
504
519
  deselectOption(option) {
520
+ if (this.readonly) {
521
+ return;
522
+ }
505
523
  if (!this.multiple) {
506
524
  this.popoverShow = false;
507
525
  return;
@@ -67,7 +67,8 @@ export default {
67
67
  },
68
68
  readonly: {
69
69
  handler(val) {
70
- this.$set(this.cssClass, 'readonly events-none', val);
70
+ this.$set(this.cssClass, 'readonly', val);
71
+ this.$set(this.cssClass, 'events-none', val);
71
72
  },
72
73
  immediate: true,
73
74
  },