@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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dataloop-ai/components",
3
- "version": "0.16.60",
3
+ "version": "0.16.62",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./models": "./models.ts",
@@ -221,6 +221,7 @@ body {
221
221
  --dl-color-warning-background: #7B7241;
222
222
  --dl-color-positive-background: #3A644E;
223
223
  --dl-color-info-background: #4B5A6B;
224
+ --dl-color-info: #92CDF2;
224
225
 
225
226
  --dl-color-chart-brush: #475077;
226
227
 
@@ -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
- middleEllipsis: {
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 dlEllipsisRef = ref(null)
49
- const leftText = ref('')
50
- const rightText = ref('')
51
- const { hasEllipsis } = useSizeObserver(dlEllipsisRef)
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
- props.middleEllipsis
55
- ? Math.round(props.text.length * 0.75)
56
- : props.text.length
76
+ split
77
+ ? Math.round(text.length * splitPositionsRef.value)
78
+ : text.length
57
79
  )
58
80
 
59
- const fullText = computed(() => props.text)
60
- leftText.value = props.text.slice(0, splitIndex.value)
61
- rightText.value = props.text.slice(splitIndex.value)
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
- middle-ellipsis="true"
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>