@dataloop-ai/components 0.18.99 → 0.18.101
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 +1 -1
- package/src/components/basic/DlButton/DlButton.vue +8 -0
- package/src/components/basic/DlChip/DlChip.vue +20 -6
- package/src/components/basic/DlChip/utils.ts +13 -5
- package/src/components/essential/DlTextArea/DlTextArea.vue +6 -1
- package/src/hooks/use-size-observer.ts +23 -9
- package/src/utils/is-ellipsis-active.ts +1 -4
package/package.json
CHANGED
|
@@ -191,6 +191,9 @@ export default defineComponent({
|
|
|
191
191
|
if (active.value) {
|
|
192
192
|
classes.push('active-class')
|
|
193
193
|
}
|
|
194
|
+
if (props.dense) {
|
|
195
|
+
classes.push('dl-button--dense')
|
|
196
|
+
}
|
|
194
197
|
return classes
|
|
195
198
|
})
|
|
196
199
|
|
|
@@ -462,6 +465,11 @@ export default defineComponent({
|
|
|
462
465
|
}
|
|
463
466
|
}
|
|
464
467
|
|
|
468
|
+
&--dense {
|
|
469
|
+
border: none;
|
|
470
|
+
padding: 0;
|
|
471
|
+
}
|
|
472
|
+
|
|
465
473
|
&:hover:enabled:not(:active) {
|
|
466
474
|
transition: var(--dl-button-transition-duration);
|
|
467
475
|
color: var(--dl-button-text-color-hover);
|
|
@@ -27,14 +27,17 @@
|
|
|
27
27
|
>
|
|
28
28
|
<div
|
|
29
29
|
ref="dlChipRef"
|
|
30
|
-
class="
|
|
30
|
+
:class="{
|
|
31
|
+
'dl-chip--ellipsis': overflow,
|
|
32
|
+
'dl-chip--no-overflow': !overflow
|
|
33
|
+
}"
|
|
31
34
|
>
|
|
32
35
|
<slot>
|
|
33
36
|
{{ hasLabel ? label : null }}
|
|
34
37
|
</slot>
|
|
35
38
|
</div>
|
|
36
39
|
</div>
|
|
37
|
-
|
|
40
|
+
<slot name="suffix" />
|
|
38
41
|
<span
|
|
39
42
|
v-if="removable"
|
|
40
43
|
class="dl-chip-remove-icon-container"
|
|
@@ -49,7 +52,7 @@
|
|
|
49
52
|
</template>
|
|
50
53
|
|
|
51
54
|
<script lang="ts">
|
|
52
|
-
import { PropType, defineComponent, ref } from 'vue-demi'
|
|
55
|
+
import { PropType, defineComponent, ref, watch } from 'vue-demi'
|
|
53
56
|
import { DlTooltip } from '../../shared'
|
|
54
57
|
import { DlIcon } from '../../essential'
|
|
55
58
|
import { useSizeObserver } from '../../../hooks/use-size-observer'
|
|
@@ -74,6 +77,7 @@ export default defineComponent({
|
|
|
74
77
|
props: {
|
|
75
78
|
disabled: Boolean,
|
|
76
79
|
filled: { type: Boolean, default: true },
|
|
80
|
+
noBorder: { type: Boolean, default: false },
|
|
77
81
|
outlined: Boolean,
|
|
78
82
|
color: { type: String, default: 'dl-color-secondary' },
|
|
79
83
|
textColor: { type: String, default: '' },
|
|
@@ -92,11 +96,16 @@ export default defineComponent({
|
|
|
92
96
|
overflow: { type: Boolean, default: false },
|
|
93
97
|
fit: { type: Boolean, default: false }
|
|
94
98
|
},
|
|
95
|
-
emits: ['remove'],
|
|
96
|
-
setup() {
|
|
99
|
+
emits: ['remove', 'ellipsis'],
|
|
100
|
+
setup(props, ctx) {
|
|
97
101
|
const isVisible = ref(true)
|
|
98
102
|
const dlChipRef = ref(null)
|
|
99
|
-
const
|
|
103
|
+
const label = ref(props.label)
|
|
104
|
+
const { hasEllipsis } = useSizeObserver(dlChipRef, label)
|
|
105
|
+
|
|
106
|
+
watch(hasEllipsis, () => {
|
|
107
|
+
ctx.emit('ellipsis', hasEllipsis.value)
|
|
108
|
+
})
|
|
100
109
|
|
|
101
110
|
return {
|
|
102
111
|
isVisible,
|
|
@@ -151,6 +160,7 @@ export default defineComponent({
|
|
|
151
160
|
color: this.color
|
|
152
161
|
}),
|
|
153
162
|
'--dl-chip-border': setBorder({
|
|
163
|
+
noBorder: this.noBorder,
|
|
154
164
|
disabled: this.disabled,
|
|
155
165
|
color: this.color
|
|
156
166
|
}),
|
|
@@ -211,6 +221,10 @@ export default defineComponent({
|
|
|
211
221
|
white-space: nowrap;
|
|
212
222
|
overflow: hidden;
|
|
213
223
|
}
|
|
224
|
+
|
|
225
|
+
&--no-overflow {
|
|
226
|
+
overflow-wrap: break-word;
|
|
227
|
+
}
|
|
214
228
|
}
|
|
215
229
|
|
|
216
230
|
.dl-chip-remove-icon-container {
|
|
@@ -9,6 +9,7 @@ export interface DlChipProps {
|
|
|
9
9
|
filled: boolean
|
|
10
10
|
color: string
|
|
11
11
|
textColor: string
|
|
12
|
+
noBorder: boolean
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
export const setTextColor = ({
|
|
@@ -42,7 +43,14 @@ export const setBgColor = ({
|
|
|
42
43
|
return getColor(color, 'dl-color-secondary')
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
export const setBorder = ({
|
|
46
|
+
export const setBorder = ({
|
|
47
|
+
noBorder,
|
|
48
|
+
disabled,
|
|
49
|
+
color = ''
|
|
50
|
+
}: Partial<DlChipProps>) => {
|
|
51
|
+
if (noBorder) {
|
|
52
|
+
return 'none'
|
|
53
|
+
}
|
|
46
54
|
if (disabled) {
|
|
47
55
|
return `1px solid var(--dl-color-disabled)`
|
|
48
56
|
}
|
|
@@ -59,17 +67,17 @@ export const setPadding = ({
|
|
|
59
67
|
const right = removable ? 20 : 5
|
|
60
68
|
|
|
61
69
|
if (hasLabel && (removable || hasIcon)) {
|
|
62
|
-
return `
|
|
70
|
+
return `3px ${right}px 3px ${left}px`
|
|
63
71
|
}
|
|
64
72
|
|
|
65
73
|
if (!hasLabel && hasIcon && removable) {
|
|
66
|
-
return `
|
|
74
|
+
return `3px ${right}px 3px 0`
|
|
67
75
|
}
|
|
68
76
|
if (removable || hasIcon) {
|
|
69
|
-
return '
|
|
77
|
+
return '3px 0'
|
|
70
78
|
}
|
|
71
79
|
|
|
72
|
-
return '5px'
|
|
80
|
+
return '3px 5px'
|
|
73
81
|
}
|
|
74
82
|
|
|
75
83
|
export const setRemoveIconWidth = ({
|
|
@@ -222,6 +222,10 @@ export default defineComponent({
|
|
|
222
222
|
maxHeight: {
|
|
223
223
|
type: String,
|
|
224
224
|
default: '120px'
|
|
225
|
+
},
|
|
226
|
+
minHeight: {
|
|
227
|
+
type: String,
|
|
228
|
+
default: '80px'
|
|
225
229
|
}
|
|
226
230
|
},
|
|
227
231
|
emits: ['input', 'focus', 'blur', 'clear', 'update:model-value', 'keydown'],
|
|
@@ -235,6 +239,7 @@ export default defineComponent({
|
|
|
235
239
|
return {
|
|
236
240
|
'--dl-textarea-max-width': props.width || 'auto',
|
|
237
241
|
'--dl-textarea-max-height': props.maxHeight,
|
|
242
|
+
'--dl-textarea-min-height': props.minHeight,
|
|
238
243
|
'--dl-textarea-width':
|
|
239
244
|
borderBoxSize.value?.[0].inlineSize + 'px' || '100%'
|
|
240
245
|
}
|
|
@@ -365,7 +370,7 @@ export default defineComponent({
|
|
|
365
370
|
width: 100%;
|
|
366
371
|
min-width: 100px;
|
|
367
372
|
max-width: 100%;
|
|
368
|
-
min-height:
|
|
373
|
+
min-height: var(--dl-textarea-min-height);
|
|
369
374
|
max-height: var(--dl-textarea-max-height);
|
|
370
375
|
outline: none;
|
|
371
376
|
color: var(--dl-color-darker);
|
|
@@ -1,22 +1,36 @@
|
|
|
1
|
-
import { onBeforeUnmount, onMounted, ref, Ref } from 'vue-demi'
|
|
1
|
+
import { onBeforeUnmount, onMounted, ref, Ref, watch } from 'vue-demi'
|
|
2
2
|
import { isEllipsisActive } from '../utils/is-ellipsis-active'
|
|
3
3
|
import { get } from 'lodash'
|
|
4
4
|
|
|
5
|
-
export function useSizeObserver(elRef: Ref,
|
|
5
|
+
export function useSizeObserver(elRef: Ref, ...refsToWatch: any[]) {
|
|
6
|
+
const entryLevel = 'target'
|
|
6
7
|
const widthRef = ref(0)
|
|
7
8
|
const heightRef = ref(0)
|
|
8
9
|
const hasEllipsis = ref(false)
|
|
9
10
|
const borderBoxSize = ref(null)
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
const calcEllipsis = (el: HTMLElement) => {
|
|
12
|
+
hasEllipsis.value = isEllipsisActive(el)
|
|
13
|
+
}
|
|
14
|
+
const resizeObserver = new ResizeObserver(
|
|
15
|
+
(entries: ResizeObserverEntry[]) => {
|
|
16
|
+
for (const entry of entries) {
|
|
17
|
+
hasEllipsis.value = isEllipsisActive(get(entry, entryLevel))
|
|
18
|
+
widthRef.value = entry.contentRect.width
|
|
19
|
+
heightRef.value = entry.contentRect.height
|
|
20
|
+
borderBoxSize.value = entry.borderBoxSize
|
|
21
|
+
}
|
|
16
22
|
}
|
|
17
|
-
|
|
23
|
+
)
|
|
18
24
|
|
|
19
25
|
onMounted(() => elRef.value && resizeObserver.observe(elRef.value))
|
|
26
|
+
watch(elRef, () => {
|
|
27
|
+
elRef.value && calcEllipsis(elRef.value)
|
|
28
|
+
})
|
|
29
|
+
for (const ref of refsToWatch) {
|
|
30
|
+
watch(ref, () => {
|
|
31
|
+
elRef.value && calcEllipsis(elRef.value)
|
|
32
|
+
})
|
|
33
|
+
}
|
|
20
34
|
onBeforeUnmount(() => elRef.value && resizeObserver.unobserve(elRef.value))
|
|
21
35
|
|
|
22
36
|
return {
|