@dataloop-ai/components 0.17.23 → 0.17.24
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
|
@@ -2,8 +2,62 @@
|
|
|
2
2
|
<div
|
|
3
3
|
:id="uuid"
|
|
4
4
|
class="container"
|
|
5
|
+
:class="rootContainerClasses"
|
|
5
6
|
:style="cssVars"
|
|
6
7
|
>
|
|
8
|
+
<div class="dl-textarea__header">
|
|
9
|
+
<div
|
|
10
|
+
v-show="!!title.length || !!tooltip.length"
|
|
11
|
+
class="dl-textarea__title-container"
|
|
12
|
+
>
|
|
13
|
+
<label
|
|
14
|
+
v-show="!!title.length"
|
|
15
|
+
class="dl-textarea__title"
|
|
16
|
+
>
|
|
17
|
+
{{ title }}
|
|
18
|
+
<span
|
|
19
|
+
v-show="required"
|
|
20
|
+
:class="asteriskClasses"
|
|
21
|
+
> *</span>
|
|
22
|
+
{{ !required && optional ? ' (Optional)' : null }}
|
|
23
|
+
</label>
|
|
24
|
+
<span v-show="!!tooltip.length">
|
|
25
|
+
<dl-icon
|
|
26
|
+
class="dl-textarea__tooltip-icon"
|
|
27
|
+
icon="icon-dl-info"
|
|
28
|
+
size="12px"
|
|
29
|
+
/>
|
|
30
|
+
<dl-tooltip>
|
|
31
|
+
{{ tooltip }}
|
|
32
|
+
</dl-tooltip>
|
|
33
|
+
</span>
|
|
34
|
+
</div>
|
|
35
|
+
<div
|
|
36
|
+
v-show="!!topMessage.length"
|
|
37
|
+
class="dl-textarea__top-message-container"
|
|
38
|
+
>
|
|
39
|
+
<dl-info-error-message
|
|
40
|
+
v-show="!!topMessage.length"
|
|
41
|
+
position="above"
|
|
42
|
+
:value="topMessage"
|
|
43
|
+
/>
|
|
44
|
+
</div>
|
|
45
|
+
<span
|
|
46
|
+
v-show="showClearButton"
|
|
47
|
+
class="dl-textarea__clear-button"
|
|
48
|
+
>
|
|
49
|
+
<dl-button
|
|
50
|
+
ref="input-clear-button"
|
|
51
|
+
icon="icon-dl-close"
|
|
52
|
+
size="s"
|
|
53
|
+
text-color="dl-color-darker"
|
|
54
|
+
flat
|
|
55
|
+
fluid
|
|
56
|
+
@click="onClear"
|
|
57
|
+
/>
|
|
58
|
+
<dl-tooltip v-if="clearButtonTooltip"> Remove text </dl-tooltip>
|
|
59
|
+
</span>
|
|
60
|
+
</div>
|
|
7
61
|
<textarea
|
|
8
62
|
ref="textarea"
|
|
9
63
|
:value="modelValue"
|
|
@@ -11,6 +65,7 @@
|
|
|
11
65
|
:placeholder="placeholder"
|
|
12
66
|
:maxlength="maxLength"
|
|
13
67
|
:disabled="disabled"
|
|
68
|
+
:readonly="readonly"
|
|
14
69
|
@input="onChange"
|
|
15
70
|
@keydown="onKeydown"
|
|
16
71
|
@focus="onFocus"
|
|
@@ -42,9 +97,11 @@
|
|
|
42
97
|
warning
|
|
43
98
|
:value="warningMessage"
|
|
44
99
|
/>
|
|
45
|
-
<span
|
|
46
|
-
|
|
47
|
-
|
|
100
|
+
<span
|
|
101
|
+
v-if="showCounter && maxLength && maxLength > 0"
|
|
102
|
+
class="dl-text-input__counter"
|
|
103
|
+
>
|
|
104
|
+
{{ characterCounter }}
|
|
48
105
|
</span>
|
|
49
106
|
</div>
|
|
50
107
|
</div>
|
|
@@ -55,10 +112,15 @@ import { v4 } from 'uuid'
|
|
|
55
112
|
import { DlInfoErrorMessage } from '../../shared'
|
|
56
113
|
import { defineComponent, computed, ref } from 'vue-demi'
|
|
57
114
|
import { useSizeObserver } from '../../../hooks/use-size-observer'
|
|
115
|
+
import { DlIcon, DlTooltip } from '../'
|
|
116
|
+
import DlButton from '../../basic/DlButton/DlButton.vue'
|
|
58
117
|
|
|
59
118
|
export default defineComponent({
|
|
60
119
|
name: 'DlTextArea',
|
|
61
120
|
components: {
|
|
121
|
+
DlButton,
|
|
122
|
+
DlTooltip,
|
|
123
|
+
DlIcon,
|
|
62
124
|
DlInfoErrorMessage
|
|
63
125
|
},
|
|
64
126
|
model: {
|
|
@@ -113,9 +175,50 @@ export default defineComponent({
|
|
|
113
175
|
warning: {
|
|
114
176
|
type: Boolean,
|
|
115
177
|
default: false
|
|
178
|
+
},
|
|
179
|
+
required: {
|
|
180
|
+
type: Boolean,
|
|
181
|
+
default: false
|
|
182
|
+
},
|
|
183
|
+
tooltip: {
|
|
184
|
+
type: String,
|
|
185
|
+
default: ''
|
|
186
|
+
},
|
|
187
|
+
optional: {
|
|
188
|
+
type: Boolean,
|
|
189
|
+
default: false
|
|
190
|
+
},
|
|
191
|
+
title: {
|
|
192
|
+
type: String,
|
|
193
|
+
default: ''
|
|
194
|
+
},
|
|
195
|
+
topMessage: {
|
|
196
|
+
type: String,
|
|
197
|
+
default: ''
|
|
198
|
+
},
|
|
199
|
+
hideClearButton: {
|
|
200
|
+
type: Boolean,
|
|
201
|
+
default: false
|
|
202
|
+
},
|
|
203
|
+
clearButtonTooltip: {
|
|
204
|
+
type: Boolean,
|
|
205
|
+
default: false
|
|
206
|
+
},
|
|
207
|
+
dense: Boolean,
|
|
208
|
+
redAsterisk: {
|
|
209
|
+
type: Boolean,
|
|
210
|
+
default: false
|
|
211
|
+
},
|
|
212
|
+
readonly: {
|
|
213
|
+
type: Boolean,
|
|
214
|
+
default: false
|
|
215
|
+
},
|
|
216
|
+
counterReverse: {
|
|
217
|
+
type: Boolean,
|
|
218
|
+
default: false
|
|
116
219
|
}
|
|
117
220
|
},
|
|
118
|
-
emits: ['input', 'focus', 'blur', 'update:model-value', 'keydown'],
|
|
221
|
+
emits: ['input', 'focus', 'blur', 'clear', 'update:model-value', 'keydown'],
|
|
119
222
|
setup(props) {
|
|
120
223
|
const uuid = ref(`dl-text-area-${v4()}`)
|
|
121
224
|
const textarea = ref(null)
|
|
@@ -161,7 +264,56 @@ export default defineComponent({
|
|
|
161
264
|
textarea
|
|
162
265
|
}
|
|
163
266
|
},
|
|
267
|
+
computed: {
|
|
268
|
+
showClearButton(): boolean {
|
|
269
|
+
return (
|
|
270
|
+
!this.hideClearButton &&
|
|
271
|
+
!this.disabled &&
|
|
272
|
+
!this.readonly &&
|
|
273
|
+
!!this.modelValue
|
|
274
|
+
)
|
|
275
|
+
},
|
|
276
|
+
asteriskClasses(): string[] {
|
|
277
|
+
const classes = ['dl-textarea__asterisk']
|
|
278
|
+
|
|
279
|
+
if (this.redAsterisk) {
|
|
280
|
+
classes.push('dl-textarea__asterisk--red')
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
return classes
|
|
284
|
+
},
|
|
285
|
+
rootContainerClasses(): string[] {
|
|
286
|
+
const classes = []
|
|
287
|
+
if (this.dense) {
|
|
288
|
+
classes.push('dl-textarea--dense')
|
|
289
|
+
}
|
|
290
|
+
return classes
|
|
291
|
+
},
|
|
292
|
+
textareaLength(): number {
|
|
293
|
+
return `${this.modelValue}`.length
|
|
294
|
+
},
|
|
295
|
+
characterCounter(): string {
|
|
296
|
+
if (!this.maxLength) {
|
|
297
|
+
return ''
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
const chars = this.counterReverse
|
|
301
|
+
? this.maxLength - this.textareaLength
|
|
302
|
+
: this.textareaLength
|
|
303
|
+
|
|
304
|
+
return `${chars}/${this.maxLength}`
|
|
305
|
+
}
|
|
306
|
+
},
|
|
164
307
|
methods: {
|
|
308
|
+
onClear(e: any): void {
|
|
309
|
+
this.$emit('clear', this.modelValue)
|
|
310
|
+
this.$emit('input', '', e)
|
|
311
|
+
this.$emit('update:model-value', '')
|
|
312
|
+
|
|
313
|
+
const inputRef = this.$refs.textarea as HTMLInputElement
|
|
314
|
+
inputRef.value = ''
|
|
315
|
+
inputRef.focus()
|
|
316
|
+
},
|
|
165
317
|
onChange(e: any) {
|
|
166
318
|
this.$emit('input', e.target.value, e)
|
|
167
319
|
this.$emit('update:model-value', e.target.value)
|
|
@@ -211,7 +363,47 @@ export default defineComponent({
|
|
|
211
363
|
outline: none;
|
|
212
364
|
color: var(--dl-color-darker);
|
|
213
365
|
box-sizing: border-box;
|
|
214
|
-
|
|
366
|
+
&--dense {
|
|
367
|
+
padding: 0;
|
|
368
|
+
}
|
|
369
|
+
&__asterisk {
|
|
370
|
+
color: var(--dl-color-medium);
|
|
371
|
+
font-size: var(--dl-font-size-body);
|
|
372
|
+
user-select: none;
|
|
373
|
+
&--red {
|
|
374
|
+
color: var(--dl-color-negative);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
&__clear-button {
|
|
378
|
+
position: absolute;
|
|
379
|
+
bottom: -25px;
|
|
380
|
+
right: 0;
|
|
381
|
+
}
|
|
382
|
+
&__header {
|
|
383
|
+
position: relative;
|
|
384
|
+
width: var(--dl-textarea-width);
|
|
385
|
+
}
|
|
386
|
+
&__title-container {
|
|
387
|
+
margin-bottom: 6px;
|
|
388
|
+
display: flex;
|
|
389
|
+
align-items: center;
|
|
390
|
+
text-align: start;
|
|
391
|
+
}
|
|
392
|
+
&__title {
|
|
393
|
+
color: var(--dl-color-medium);
|
|
394
|
+
font-size: var(--dl-font-size-body);
|
|
395
|
+
text-align: left;
|
|
396
|
+
margin-right: 5px;
|
|
397
|
+
white-space: nowrap;
|
|
398
|
+
}
|
|
399
|
+
&__tooltip-icon {
|
|
400
|
+
color: var(--dl-color-medium);
|
|
401
|
+
}
|
|
402
|
+
&__top-message-container {
|
|
403
|
+
display: flex;
|
|
404
|
+
margin-bottom: 10px;
|
|
405
|
+
text-align: start;
|
|
406
|
+
}
|
|
215
407
|
&:hover {
|
|
216
408
|
border-color: var(--dl-color-hover);
|
|
217
409
|
}
|
|
@@ -226,7 +418,13 @@ export default defineComponent({
|
|
|
226
418
|
cursor: not-allowed;
|
|
227
419
|
user-select: none;
|
|
228
420
|
}
|
|
229
|
-
|
|
421
|
+
&:readonly {
|
|
422
|
+
border-color: var(--dl-color-separator);
|
|
423
|
+
cursor: text;
|
|
424
|
+
&:hover {
|
|
425
|
+
border-color: var(--dl-color-separator) !important;
|
|
426
|
+
}
|
|
427
|
+
}
|
|
230
428
|
&::placeholder {
|
|
231
429
|
color: var(--dl-color-lighter);
|
|
232
430
|
opacity: 1;
|
|
@@ -6,8 +6,13 @@
|
|
|
6
6
|
placeholder="Type your text..."
|
|
7
7
|
show-counter
|
|
8
8
|
:max-length="20"
|
|
9
|
+
title="Text area title"
|
|
10
|
+
required
|
|
11
|
+
tooltip="Quis fugiat et non eu proident sit et amet."
|
|
12
|
+
top-message="Pariatur consequat non sit aliqua labore ad reprehenderit deserunt ullamco incididunt non irure laborum deserunt."
|
|
9
13
|
enable-resize
|
|
10
14
|
error
|
|
15
|
+
clear-button-tooltip
|
|
11
16
|
error-message="Something went wrong!"
|
|
12
17
|
@keydown="log"
|
|
13
18
|
@focus="textAreaFocused = true"
|