goodteditor-ui 1.0.76 → 1.0.78
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
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
:color="previewRgbaString"
|
|
32
32
|
:width="previewWidth"
|
|
33
33
|
:height="previewHeight" />
|
|
34
|
-
<div class="d-flex mar-top-2">
|
|
34
|
+
<div class="footer d-flex mar-top-2">
|
|
35
35
|
<input
|
|
36
36
|
class="input input-small text-xsmall flex-grow"
|
|
37
37
|
type="text"
|
|
@@ -44,12 +44,12 @@
|
|
|
44
44
|
:value="modelHex"
|
|
45
45
|
@input="({ target }) => inputHex(target.value)"
|
|
46
46
|
v-else />
|
|
47
|
-
<
|
|
48
|
-
<span class="text-xsmall text-upper">{{ nextModelMode }}</span>
|
|
49
|
-
</
|
|
50
|
-
<
|
|
47
|
+
<button class="btn btn-outline btn-small" :title="nextModelMode" @click="toggleModelMode">
|
|
48
|
+
<span class="text-xsmall text-upper">{{ nextModelMode[0] }}</span>
|
|
49
|
+
</button>
|
|
50
|
+
<button class="btn btn-outline btn-small" @click="submit" v-if="showSubmit">
|
|
51
51
|
<i class="mdi mdi-check"></i>
|
|
52
|
-
</
|
|
52
|
+
</button>
|
|
53
53
|
</div>
|
|
54
54
|
<cp-colors
|
|
55
55
|
class="mar-top-2"
|
|
@@ -72,6 +72,10 @@
|
|
|
72
72
|
min-width: 0;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
.footer {
|
|
76
|
+
gap: var(--spacer2);
|
|
77
|
+
}
|
|
78
|
+
|
|
75
79
|
.btn {
|
|
76
80
|
min-height: 0;
|
|
77
81
|
width: 2.25em;
|
|
@@ -153,16 +157,28 @@ export default {
|
|
|
153
157
|
};
|
|
154
158
|
},
|
|
155
159
|
computed: {
|
|
160
|
+
/**
|
|
161
|
+
* @return {string}
|
|
162
|
+
*/
|
|
156
163
|
nextModelMode() {
|
|
157
164
|
let { HEX, RGBA } = MODEL_MODE;
|
|
158
|
-
return
|
|
165
|
+
return this.modelMode === HEX ? RGBA : HEX;
|
|
159
166
|
},
|
|
167
|
+
/**
|
|
168
|
+
* @return {number}
|
|
169
|
+
*/
|
|
160
170
|
totalWidth() {
|
|
161
171
|
return this.hueHeight + (this.hueWidth + 4) * 2;
|
|
162
172
|
},
|
|
173
|
+
/**
|
|
174
|
+
* @return {number}
|
|
175
|
+
*/
|
|
163
176
|
previewWidth() {
|
|
164
177
|
return this.totalWidth;
|
|
165
178
|
},
|
|
179
|
+
/**
|
|
180
|
+
* @return {{a: number, r: number, b: number, g: number}}
|
|
181
|
+
*/
|
|
166
182
|
rgba() {
|
|
167
183
|
return {
|
|
168
184
|
r: this.r,
|
|
@@ -171,6 +187,9 @@ export default {
|
|
|
171
187
|
a: this.a
|
|
172
188
|
};
|
|
173
189
|
},
|
|
190
|
+
/**
|
|
191
|
+
* @return {{s: number, v: number, h: number}}
|
|
192
|
+
*/
|
|
174
193
|
hsv() {
|
|
175
194
|
return {
|
|
176
195
|
h: this.h,
|
|
@@ -178,20 +197,43 @@ export default {
|
|
|
178
197
|
v: this.v
|
|
179
198
|
};
|
|
180
199
|
},
|
|
200
|
+
/**
|
|
201
|
+
* @return {string}
|
|
202
|
+
*/
|
|
181
203
|
rgbString() {
|
|
182
204
|
return `rgb(${this.r}, ${this.g}, ${this.b})`;
|
|
183
205
|
},
|
|
206
|
+
/**
|
|
207
|
+
* @return {string}
|
|
208
|
+
*/
|
|
184
209
|
rgbaStringShort() {
|
|
185
210
|
return `${this.r}, ${this.g}, ${this.b}, ${this.a}`;
|
|
186
211
|
},
|
|
212
|
+
/**
|
|
213
|
+
* @return {string}
|
|
214
|
+
*/
|
|
187
215
|
rgbaString() {
|
|
188
216
|
return `rgba(${this.rgbaStringShort})`;
|
|
189
217
|
},
|
|
218
|
+
/**
|
|
219
|
+
* @return {string}
|
|
220
|
+
*/
|
|
190
221
|
hexString() {
|
|
191
222
|
return rgb2hex(this.rgba, true);
|
|
192
223
|
},
|
|
224
|
+
/**
|
|
225
|
+
* @return {string}
|
|
226
|
+
*/
|
|
193
227
|
previewRgbaString() {
|
|
194
228
|
return this.rgbaString;
|
|
229
|
+
},
|
|
230
|
+
/**
|
|
231
|
+
* @return {string}
|
|
232
|
+
*/
|
|
233
|
+
modelModeValue() {
|
|
234
|
+
const { modelMode, modelHex, rgbaString } = this;
|
|
235
|
+
const { RGBA } = MODEL_MODE;
|
|
236
|
+
return modelMode === RGBA ? rgbaString : modelHex;
|
|
195
237
|
}
|
|
196
238
|
},
|
|
197
239
|
watch: {
|
|
@@ -206,21 +248,13 @@ export default {
|
|
|
206
248
|
},
|
|
207
249
|
immediate: true
|
|
208
250
|
},
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
* Triggers when the color changes
|
|
212
|
-
* @property {Object} color color object
|
|
213
|
-
*/
|
|
214
|
-
this.$emit('changeColor', {
|
|
215
|
-
rgba: this.rgba,
|
|
216
|
-
hsv: this.hsv,
|
|
217
|
-
hex: this.modelHex
|
|
218
|
-
});
|
|
251
|
+
modelModeValue() {
|
|
252
|
+
this.emitDetails('changeColor');
|
|
219
253
|
/**
|
|
220
254
|
* Triggers when the color changes
|
|
221
255
|
* @property {Number} rgbaString color rgba string
|
|
222
256
|
*/
|
|
223
|
-
this.$emit('input', this.
|
|
257
|
+
this.$emit('input', this.modelModeValue);
|
|
224
258
|
}
|
|
225
259
|
},
|
|
226
260
|
created() {
|
|
@@ -230,20 +264,29 @@ export default {
|
|
|
230
264
|
document.removeEventListener('keydown', this.onDocKeydown);
|
|
231
265
|
},
|
|
232
266
|
methods: {
|
|
233
|
-
|
|
267
|
+
/**
|
|
268
|
+
* Triggers when the color changes
|
|
269
|
+
* @property {Object} color color object
|
|
270
|
+
*/
|
|
271
|
+
emitDetails(eventName) {
|
|
272
|
+
const { modelMode, modelModeValue, modelHex, rgba, hsv } = this;
|
|
234
273
|
/**
|
|
235
274
|
* Triggers when the color changes
|
|
236
275
|
* @property {Object} color color object
|
|
237
276
|
*/
|
|
238
|
-
this.$emit(
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
277
|
+
this.$emit(eventName, {
|
|
278
|
+
value: modelModeValue,
|
|
279
|
+
rgba,
|
|
280
|
+
hsv,
|
|
281
|
+
hex: modelHex,
|
|
282
|
+
mode: modelMode
|
|
243
283
|
});
|
|
244
284
|
},
|
|
285
|
+
submit() {
|
|
286
|
+
this.emitDetails('submit');
|
|
287
|
+
},
|
|
245
288
|
toggleModelMode() {
|
|
246
|
-
|
|
289
|
+
const { HEX, RGBA } = MODEL_MODE;
|
|
247
290
|
this.modelMode = this.modelMode === HEX ? RGBA : HEX;
|
|
248
291
|
},
|
|
249
292
|
selectSaturation(color) {
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
}
|
|
95
95
|
</style>
|
|
96
96
|
<script>
|
|
97
|
-
import {
|
|
97
|
+
import { isValidColorString } from './ColorPicker/utils';
|
|
98
98
|
import ColorPicker from './ColorPicker.vue';
|
|
99
99
|
import UiPopover from './Popover.vue';
|
|
100
100
|
import { Key } from './utils/Helpers';
|
|
@@ -192,19 +192,10 @@ export default {
|
|
|
192
192
|
onInputBlur(e) {
|
|
193
193
|
this.rootHasFocus = false;
|
|
194
194
|
},
|
|
195
|
-
onColorPickerSubmit({
|
|
195
|
+
onColorPickerSubmit({ value: colorString }) {
|
|
196
196
|
if (this.readonly || this.disabled) {
|
|
197
197
|
return;
|
|
198
198
|
}
|
|
199
|
-
const value = profiles[mode];
|
|
200
|
-
let colorString;
|
|
201
|
-
if (mode === MODEL_MODE.RGBA) {
|
|
202
|
-
let { r, g, b, a } = value;
|
|
203
|
-
colorString = `rgba(${r}, ${g}, ${b}, ${a})`;
|
|
204
|
-
}
|
|
205
|
-
if (mode === MODEL_MODE.HEX) {
|
|
206
|
-
colorString = value;
|
|
207
|
-
}
|
|
208
199
|
this.inputColor(colorString);
|
|
209
200
|
this.changeColor(colorString);
|
|
210
201
|
this.onColorPickerClose();
|
|
@@ -108,7 +108,32 @@
|
|
|
108
108
|
</template>
|
|
109
109
|
<template #option="{ option, index, cursorIndex }">
|
|
110
110
|
<!--
|
|
111
|
-
@slot
|
|
111
|
+
@slot before option slot
|
|
112
|
+
@binding {Object} option option
|
|
113
|
+
@binding {any} value option's value
|
|
114
|
+
@binding {String} label option's label
|
|
115
|
+
@binding {Number} index option's index
|
|
116
|
+
@binding {Boolean} isSelected option selection status
|
|
117
|
+
@binding {Number} cursorIndex current cursor index
|
|
118
|
+
@binding {Function} selectOption function that selects option
|
|
119
|
+
@binding {Function} deselectOption function that deselects option
|
|
120
|
+
@binding {Function} toggleOption function that toggles option selection
|
|
121
|
+
-->
|
|
122
|
+
<slot
|
|
123
|
+
name="option:before"
|
|
124
|
+
v-bind="{
|
|
125
|
+
option,
|
|
126
|
+
value: getOptionValue(option),
|
|
127
|
+
label: getOptionLabel(option),
|
|
128
|
+
index,
|
|
129
|
+
cursorIndex,
|
|
130
|
+
isSelected: isOptionSelected(option),
|
|
131
|
+
selectOption,
|
|
132
|
+
deselectOption,
|
|
133
|
+
toggleOption
|
|
134
|
+
}"></slot>
|
|
135
|
+
<!--
|
|
136
|
+
@slot option slot mode
|
|
112
137
|
@binding {Object} option option
|
|
113
138
|
@binding {any} value option's value
|
|
114
139
|
@binding {String} label option's label
|
|
@@ -168,7 +193,7 @@
|
|
|
168
193
|
</div>
|
|
169
194
|
<div class="text-truncate" style="min-height: calc(var(--line-height) * 1rem)" v-else>
|
|
170
195
|
<!--
|
|
171
|
-
@slot
|
|
196
|
+
@slot option content slot
|
|
172
197
|
-->
|
|
173
198
|
<slot
|
|
174
199
|
name="option-label"
|
|
@@ -185,6 +210,31 @@
|
|
|
185
210
|
</div>
|
|
186
211
|
</li>
|
|
187
212
|
</slot>
|
|
213
|
+
<!--
|
|
214
|
+
@slot after option slot
|
|
215
|
+
@binding {Object} option option
|
|
216
|
+
@binding {any} value option's value
|
|
217
|
+
@binding {String} label option's label
|
|
218
|
+
@binding {Number} index option's index
|
|
219
|
+
@binding {Boolean} isSelected option selection status
|
|
220
|
+
@binding {Number} cursorIndex current cursor index
|
|
221
|
+
@binding {Function} selectOption function that selects option
|
|
222
|
+
@binding {Function} deselectOption function that deselects option
|
|
223
|
+
@binding {Function} toggleOption function that toggles option selection
|
|
224
|
+
-->
|
|
225
|
+
<slot
|
|
226
|
+
name="option:after"
|
|
227
|
+
v-bind="{
|
|
228
|
+
option,
|
|
229
|
+
value: getOptionValue(option),
|
|
230
|
+
label: getOptionLabel(option),
|
|
231
|
+
index,
|
|
232
|
+
isSelected: isOptionSelected(option),
|
|
233
|
+
cursorIndex,
|
|
234
|
+
selectOption,
|
|
235
|
+
deselectOption,
|
|
236
|
+
toggleOption
|
|
237
|
+
}"></slot>
|
|
188
238
|
</template>
|
|
189
239
|
<template #footer>
|
|
190
240
|
<!--
|
|
@@ -348,7 +398,9 @@ export default {
|
|
|
348
398
|
importModel(model) {
|
|
349
399
|
const { options, isValueOfOption } = this;
|
|
350
400
|
const models = [model].flat();
|
|
351
|
-
const optionsSelected = options.filter((option) =>
|
|
401
|
+
const optionsSelected = options.filter((option) =>
|
|
402
|
+
models.some((modelItem) => isValueOfOption(option, modelItem))
|
|
403
|
+
);
|
|
352
404
|
if (optionsSelected.length > 0) {
|
|
353
405
|
this.dataListCursorIndex = this.getOptionIndex(optionsSelected[0]);
|
|
354
406
|
this.optionsSelected = this.multiple ? optionsSelected : [optionsSelected[0]];
|