goodteditor-ui 1.0.77 → 1.0.79
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) {
|
|
@@ -19,16 +19,20 @@
|
|
|
19
19
|
option,
|
|
20
20
|
index,
|
|
21
21
|
cursorIndex,
|
|
22
|
-
setCursorIndex
|
|
23
|
-
}"
|
|
24
|
-
|
|
25
|
-
<li
|
|
26
|
-
:class="{ active: index == cursorIndex }"
|
|
27
|
-
:key="index"
|
|
28
|
-
@click="onOptionClick(option, index)"
|
|
29
|
-
>
|
|
22
|
+
setCursorIndex
|
|
23
|
+
}">
|
|
24
|
+
<li :class="{ active: index == cursorIndex }" :key="index" @click="onOptionClick(option, index)">
|
|
30
25
|
<div class="text-truncate" style="min-height: calc(var(--line-height) * 1rem)">
|
|
31
|
-
|
|
26
|
+
<slot
|
|
27
|
+
name="option-label"
|
|
28
|
+
v-bind="{
|
|
29
|
+
option,
|
|
30
|
+
index,
|
|
31
|
+
cursorIndex,
|
|
32
|
+
setCursorIndex
|
|
33
|
+
}">
|
|
34
|
+
{{ option }}
|
|
35
|
+
</slot>
|
|
32
36
|
</div>
|
|
33
37
|
</li>
|
|
34
38
|
</slot>
|
|
@@ -42,9 +46,11 @@
|
|
|
42
46
|
<style lang="less" scoped>
|
|
43
47
|
.dropdown {
|
|
44
48
|
outline: none;
|
|
49
|
+
|
|
45
50
|
ul {
|
|
46
51
|
scroll-behavior: smooth;
|
|
47
52
|
}
|
|
53
|
+
|
|
48
54
|
&.no-scroll-animation {
|
|
49
55
|
ul {
|
|
50
56
|
scroll-behavior: auto;
|
|
@@ -64,7 +70,7 @@ export default {
|
|
|
64
70
|
type: Array,
|
|
65
71
|
default() {
|
|
66
72
|
return [];
|
|
67
|
-
}
|
|
73
|
+
}
|
|
68
74
|
},
|
|
69
75
|
/**
|
|
70
76
|
* Defines the size of the component
|
|
@@ -75,22 +81,22 @@ export default {
|
|
|
75
81
|
default: '',
|
|
76
82
|
validator: function (value) {
|
|
77
83
|
return ['', 'small', 'large'].indexOf(value) >= 0;
|
|
78
|
-
}
|
|
84
|
+
}
|
|
79
85
|
},
|
|
80
86
|
/**
|
|
81
87
|
* Defines the max-height of the dropdown list (value may be any css unit/expression)
|
|
82
88
|
*/
|
|
83
89
|
maxHeight: {
|
|
84
90
|
type: String,
|
|
85
|
-
default: ''
|
|
91
|
+
default: ''
|
|
86
92
|
},
|
|
87
93
|
/**
|
|
88
94
|
* The current cursor index position (.sync)
|
|
89
95
|
*/
|
|
90
96
|
cursorIndex: {
|
|
91
97
|
type: Number,
|
|
92
|
-
default: -1
|
|
93
|
-
}
|
|
98
|
+
default: -1
|
|
99
|
+
}
|
|
94
100
|
},
|
|
95
101
|
data() {
|
|
96
102
|
return { useScrollAnimation: true };
|
|
@@ -102,7 +108,7 @@ export default {
|
|
|
102
108
|
size && o.push(`dropdown-${this.size}`);
|
|
103
109
|
!useScrollAnimation && o.push('no-scroll-animation');
|
|
104
110
|
return o;
|
|
105
|
-
}
|
|
111
|
+
}
|
|
106
112
|
},
|
|
107
113
|
watch: {
|
|
108
114
|
cursorIndex: {
|
|
@@ -114,8 +120,8 @@ export default {
|
|
|
114
120
|
this.useScrollAnimation = true;
|
|
115
121
|
});
|
|
116
122
|
},
|
|
117
|
-
immediate: true
|
|
118
|
-
}
|
|
123
|
+
immediate: true
|
|
124
|
+
}
|
|
119
125
|
},
|
|
120
126
|
methods: {
|
|
121
127
|
onOptionClick(option, index) {
|
|
@@ -158,7 +164,7 @@ export default {
|
|
|
158
164
|
*/
|
|
159
165
|
this.$emit('select-option', { option, index: this.cursorIndex });
|
|
160
166
|
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
163
169
|
};
|
|
164
170
|
</script>
|
|
@@ -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 style="flex: 1 0 0">
|
|
10
9
|
<!--
|
|
11
10
|
@slot Custom input slot
|
|
@@ -21,8 +20,7 @@
|
|
|
21
20
|
type="text"
|
|
22
21
|
:value="value"
|
|
23
22
|
v-bind="inputBinds"
|
|
24
|
-
v-on="inputEvents"
|
|
25
|
-
/>
|
|
23
|
+
v-on="inputEvents" />
|
|
26
24
|
</slot>
|
|
27
25
|
</div>
|
|
28
26
|
<!--
|
|
@@ -39,8 +37,7 @@
|
|
|
39
37
|
@select-option="onDatalistSelectOption"
|
|
40
38
|
v-bind="{ size, maxHeight: dropdownMaxHeight, options: suggestedOptions }"
|
|
41
39
|
:cursorIndex.sync="dataListCursorIndex"
|
|
42
|
-
ref="datalist"
|
|
43
|
-
>
|
|
40
|
+
ref="datalist">
|
|
44
41
|
<template #header>
|
|
45
42
|
<!--
|
|
46
43
|
@slot Dropdown header content
|
|
@@ -71,9 +68,31 @@
|
|
|
71
68
|
valueLocal: delimitedValue,
|
|
72
69
|
cursorIndex,
|
|
73
70
|
selectOption,
|
|
74
|
-
setCursorIndex
|
|
75
|
-
}"
|
|
76
|
-
|
|
71
|
+
setCursorIndex
|
|
72
|
+
}"></slot>
|
|
73
|
+
</template>
|
|
74
|
+
<template #option-label="{ option, index, cursorIndex, setCursorIndex }">
|
|
75
|
+
<!--
|
|
76
|
+
@slot Dropdown option label
|
|
77
|
+
@binding {String} option option label
|
|
78
|
+
@binding {Number} optionIndex option index
|
|
79
|
+
@binding {String} value current value
|
|
80
|
+
@binding {String} valueLocal current delimited value
|
|
81
|
+
@binding {Number} cursorIndex current dropdown selection index
|
|
82
|
+
@binding {Function} selectOption function that select's the option
|
|
83
|
+
@binding {Function} setCursorIndex function that sets the cursor index
|
|
84
|
+
-->
|
|
85
|
+
<slot
|
|
86
|
+
name="option-label"
|
|
87
|
+
v-bind="{
|
|
88
|
+
option: option,
|
|
89
|
+
optionIndex: index,
|
|
90
|
+
value,
|
|
91
|
+
valueLocal: delimitedValue,
|
|
92
|
+
cursorIndex,
|
|
93
|
+
selectOption,
|
|
94
|
+
setCursorIndex
|
|
95
|
+
}"></slot>
|
|
77
96
|
</template>
|
|
78
97
|
<template #footer>
|
|
79
98
|
<slot name="dropdown-footer"></slot>
|
|
@@ -84,11 +103,7 @@
|
|
|
84
103
|
@slot Custom clear btn slot
|
|
85
104
|
@binding {Function} clear function that clears the value
|
|
86
105
|
-->
|
|
87
|
-
<slot
|
|
88
|
-
name="clear-btn"
|
|
89
|
-
v-if="useClearBtn && value.length > 0"
|
|
90
|
-
v-bind="{ clear: clearValue }"
|
|
91
|
-
>
|
|
106
|
+
<slot name="clear-btn" v-if="useClearBtn && value.length > 0" v-bind="{ clear: clearValue }">
|
|
92
107
|
<i class="mdi mdi-close cursor-pointer" @click="clearValue"></i>
|
|
93
108
|
</slot>
|
|
94
109
|
</div>
|
|
@@ -97,6 +112,7 @@
|
|
|
97
112
|
.ui-input-autocomplete {
|
|
98
113
|
display: inline-flex;
|
|
99
114
|
align-items: center;
|
|
115
|
+
|
|
100
116
|
&-input {
|
|
101
117
|
border: none;
|
|
102
118
|
line-height: 1.5;
|
|
@@ -126,63 +142,63 @@ export default {
|
|
|
126
142
|
type: Array,
|
|
127
143
|
default() {
|
|
128
144
|
return [];
|
|
129
|
-
}
|
|
145
|
+
}
|
|
130
146
|
},
|
|
131
147
|
/**
|
|
132
148
|
* Function which filters suggestions function(val, options):Promise<Array>
|
|
133
149
|
*/
|
|
134
150
|
filter: {
|
|
135
151
|
type: Function,
|
|
136
|
-
default: null
|
|
152
|
+
default: null
|
|
137
153
|
},
|
|
138
154
|
/**
|
|
139
155
|
* Filter debounce delay in ms
|
|
140
156
|
*/
|
|
141
157
|
filterDebounce: {
|
|
142
158
|
type: Number,
|
|
143
|
-
default: 0
|
|
159
|
+
default: 0
|
|
144
160
|
},
|
|
145
161
|
/**
|
|
146
162
|
* Value delimiter for multiple autocomplete suggestions
|
|
147
163
|
*/
|
|
148
164
|
delimiter: {
|
|
149
165
|
type: String,
|
|
150
|
-
default: ','
|
|
166
|
+
default: ','
|
|
151
167
|
},
|
|
152
168
|
/**
|
|
153
169
|
* Show suggestions on focus event
|
|
154
170
|
*/
|
|
155
171
|
suggestOnFocus: {
|
|
156
172
|
type: Boolean,
|
|
157
|
-
default: true
|
|
173
|
+
default: true
|
|
158
174
|
},
|
|
159
175
|
/**
|
|
160
176
|
* Min length to show suggestions
|
|
161
177
|
*/
|
|
162
178
|
minLength: {
|
|
163
179
|
type: Number,
|
|
164
|
-
default: 0
|
|
180
|
+
default: 0
|
|
165
181
|
},
|
|
166
182
|
/**
|
|
167
183
|
* Defines the dropdown's max-height
|
|
168
184
|
*/
|
|
169
185
|
dropdownMaxHeight: {
|
|
170
|
-
default: ''
|
|
186
|
+
default: ''
|
|
171
187
|
},
|
|
172
188
|
/**
|
|
173
189
|
* Auto width
|
|
174
190
|
*/
|
|
175
191
|
autoWidth: {
|
|
176
192
|
type: Boolean,
|
|
177
|
-
default: true
|
|
193
|
+
default: true
|
|
178
194
|
},
|
|
179
195
|
/**
|
|
180
196
|
* Clear data btn
|
|
181
197
|
*/
|
|
182
198
|
useClearBtn: {
|
|
183
199
|
type: Boolean,
|
|
184
|
-
default: false
|
|
185
|
-
}
|
|
200
|
+
default: false
|
|
201
|
+
}
|
|
186
202
|
},
|
|
187
203
|
data() {
|
|
188
204
|
return {
|
|
@@ -193,16 +209,16 @@ export default {
|
|
|
193
209
|
filterTID: null,
|
|
194
210
|
inputBinds: {
|
|
195
211
|
placeholder: this.placeholder,
|
|
196
|
-
readonly: this.readonly
|
|
212
|
+
readonly: this.readonly
|
|
197
213
|
},
|
|
198
214
|
inputEvents: {
|
|
199
215
|
change: this.onInputChange,
|
|
200
216
|
input: this.onInputInput,
|
|
201
217
|
keydown: this.onInputKeyDown,
|
|
202
218
|
focus: this.onInputFocus,
|
|
203
|
-
blur: this.onInputBlur
|
|
219
|
+
blur: this.onInputBlur
|
|
204
220
|
},
|
|
205
|
-
delimitedValuePrev: null
|
|
221
|
+
delimitedValuePrev: null
|
|
206
222
|
};
|
|
207
223
|
},
|
|
208
224
|
computed: {
|
|
@@ -220,7 +236,7 @@ export default {
|
|
|
220
236
|
return this.value.split(this.delimiter)[this.delimitedIndex];
|
|
221
237
|
}
|
|
222
238
|
return this.value;
|
|
223
|
-
}
|
|
239
|
+
}
|
|
224
240
|
},
|
|
225
241
|
methods: {
|
|
226
242
|
clearValue() {
|
|
@@ -231,8 +247,8 @@ export default {
|
|
|
231
247
|
this.suggestedOptions = [];
|
|
232
248
|
},
|
|
233
249
|
defaultFilter(val, options) {
|
|
234
|
-
return new Promise(resolve => {
|
|
235
|
-
let arr = options.filter(opt => opt.toLowerCase().indexOf(val.toLowerCase()) === 0);
|
|
250
|
+
return new Promise((resolve) => {
|
|
251
|
+
let arr = options.filter((opt) => opt.toLowerCase().indexOf(val.toLowerCase()) === 0);
|
|
236
252
|
resolve(arr);
|
|
237
253
|
});
|
|
238
254
|
},
|
|
@@ -250,7 +266,7 @@ export default {
|
|
|
250
266
|
this.loading = true;
|
|
251
267
|
let h = this.filter ? this.filter : this.defaultFilter;
|
|
252
268
|
h(val, this.options)
|
|
253
|
-
.then(arr => {
|
|
269
|
+
.then((arr) => {
|
|
254
270
|
this.suggestedOptions = arr;
|
|
255
271
|
this.dataListCursorIndex = -1;
|
|
256
272
|
})
|
|
@@ -368,7 +384,7 @@ export default {
|
|
|
368
384
|
},
|
|
369
385
|
onDatalistSelectOption({ option }) {
|
|
370
386
|
this.selectOption(option);
|
|
371
|
-
}
|
|
372
|
-
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
373
389
|
};
|
|
374
390
|
</script>
|
|
@@ -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();
|