@dataloop-ai/components 0.16.60 → 0.16.62
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
package/src/assets/globals.scss
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
</template>
|
|
20
20
|
|
|
21
21
|
<script lang="ts">
|
|
22
|
-
import { defineComponent, ref, computed } from 'vue-demi'
|
|
22
|
+
import { defineComponent, ref, computed, toRef } from 'vue-demi'
|
|
23
23
|
import DlTooltip from '../../essential/DlTooltip/DlTooltip.vue'
|
|
24
24
|
import { useSizeObserver } from '../../../hooks/use-size-observer'
|
|
25
25
|
|
|
@@ -29,15 +29,33 @@ export default defineComponent({
|
|
|
29
29
|
DlTooltip
|
|
30
30
|
},
|
|
31
31
|
props: {
|
|
32
|
+
/**
|
|
33
|
+
* Text to be displayed
|
|
34
|
+
*/
|
|
32
35
|
text: {
|
|
33
36
|
type: String,
|
|
34
37
|
required: true
|
|
35
38
|
},
|
|
36
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Allows to split the text in two parts
|
|
41
|
+
*/
|
|
42
|
+
split: {
|
|
37
43
|
type: Boolean,
|
|
38
44
|
default: false,
|
|
39
45
|
required: false
|
|
40
46
|
},
|
|
47
|
+
/**
|
|
48
|
+
* Position of the split in the text, % of the text length
|
|
49
|
+
*/
|
|
50
|
+
splitPosition: {
|
|
51
|
+
type: Number,
|
|
52
|
+
required: false,
|
|
53
|
+
default: 0.5,
|
|
54
|
+
validator: (value: number) => value >= 0 && value <= 1
|
|
55
|
+
},
|
|
56
|
+
/**
|
|
57
|
+
* Tooltip to be displayed when the text is truncated
|
|
58
|
+
*/
|
|
41
59
|
tooltip: {
|
|
42
60
|
type: Boolean,
|
|
43
61
|
default: true,
|
|
@@ -45,20 +63,26 @@ export default defineComponent({
|
|
|
45
63
|
}
|
|
46
64
|
},
|
|
47
65
|
setup(props) {
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
|
|
66
|
+
const { text, split } = props
|
|
67
|
+
|
|
68
|
+
const splitPositionsRef = toRef(props, 'splitPosition')
|
|
69
|
+
splitPositionsRef.value = Math.min(
|
|
70
|
+
Math.max(splitPositionsRef.value, 1),
|
|
71
|
+
0
|
|
72
|
+
)
|
|
52
73
|
|
|
74
|
+
const dlEllipsisRef = ref(null)
|
|
53
75
|
const splitIndex = computed(() =>
|
|
54
|
-
|
|
55
|
-
? Math.round(
|
|
56
|
-
:
|
|
76
|
+
split
|
|
77
|
+
? Math.round(text.length * splitPositionsRef.value)
|
|
78
|
+
: text.length
|
|
57
79
|
)
|
|
58
80
|
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
81
|
+
const leftText = computed(() => text.slice(0, splitIndex.value))
|
|
82
|
+
const rightText = computed(() => text.slice(splitIndex.value))
|
|
83
|
+
|
|
84
|
+
const { hasEllipsis } = useSizeObserver(dlEllipsisRef)
|
|
85
|
+
const fullText = computed(() => text)
|
|
62
86
|
|
|
63
87
|
return {
|
|
64
88
|
leftText,
|
|
@@ -14,7 +14,17 @@
|
|
|
14
14
|
</p>
|
|
15
15
|
<dl-ellipsis
|
|
16
16
|
text="Lorem ipsum dolor sit amet consectetur adipisicing elit. "
|
|
17
|
-
|
|
17
|
+
split
|
|
18
|
+
/>
|
|
19
|
+
</div>
|
|
20
|
+
<div style="white-space: nowrap; width: 350px">
|
|
21
|
+
<p style="font-weight: bold">
|
|
22
|
+
Ellipsis at the 20%
|
|
23
|
+
</p>
|
|
24
|
+
<dl-ellipsis
|
|
25
|
+
text="Lorem ipsum dolor sit amet consectetur adipisicing elit. "
|
|
26
|
+
split
|
|
27
|
+
:split-position="0.2"
|
|
18
28
|
/>
|
|
19
29
|
</div>
|
|
20
30
|
</div>
|