@dataloop-ai/components 0.18.128 → 0.18.130

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.18.128",
3
+ "version": "0.18.130",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./models": "./models.ts",
@@ -1,6 +1,18 @@
1
1
  <template>
2
- <div class="dl-ellipsis">
2
+ <div
3
+ class="dl-ellipsis"
4
+ :class="multiline ? 'dl-ellipsis__multiline' : ''"
5
+ :style="cssVars"
6
+ >
7
+ <p
8
+ v-if="multiline"
9
+ ref="dlEllipsisRef"
10
+ class="dl-ellipsis__multiline-text"
11
+ >
12
+ {{ fullText }}
13
+ </p>
3
14
  <span
15
+ v-if="!multiline"
4
16
  ref="dlEllipsisRef"
5
17
  class="dl-ellipsis__left"
6
18
  >
@@ -11,14 +23,14 @@
11
23
  <span v-else>{{ leftText }}</span>
12
24
  </span>
13
25
  <span
14
- v-if="rightText"
26
+ v-if="!multiline && rightText"
15
27
  class="dl-ellipsis__right"
16
28
  >
17
29
  {{ rightText }}
18
30
  </span>
19
31
  <dl-tooltip
20
32
  v-if="shouldShowTooltip"
21
- :max-width="'max-content'"
33
+ :max-width="'30vw'"
22
34
  :self="tooltipPosition"
23
35
  :anchor="tooltipPosition"
24
36
  :offset="tooltipOffset"
@@ -33,7 +45,13 @@
33
45
  </template>
34
46
 
35
47
  <script lang="ts">
36
- import { defineComponent, ref, computed } from 'vue-demi'
48
+ import {
49
+ defineComponent,
50
+ ref,
51
+ computed,
52
+ onMounted,
53
+ getCurrentInstance
54
+ } from 'vue-demi'
37
55
  import { DlTooltip } from '../../shared'
38
56
  import { useSizeObserver } from '../../../hooks/use-size-observer'
39
57
 
@@ -79,6 +97,21 @@ export default defineComponent({
79
97
  tooltipOffset: {
80
98
  type: Array,
81
99
  default: () => [0, 25]
100
+ },
101
+ /**
102
+ * Allows to display multiline text
103
+ */
104
+ multiline: {
105
+ type: Boolean,
106
+ default: false
107
+ },
108
+ /**
109
+ * Number of lines to display
110
+ * must be used with multiline
111
+ */
112
+ maxLines: {
113
+ type: Number,
114
+ default: 3
82
115
  }
83
116
  },
84
117
  // TODO: fix type issue here
@@ -110,13 +143,27 @@ export default defineComponent({
110
143
  )
111
144
  const fullText = computed(() => props.text)
112
145
 
146
+ const cssVars = computed<Record<string, string | number>>(() => {
147
+ return {
148
+ '--max-lines': props.maxLines
149
+ }
150
+ })
151
+
152
+ onMounted(() => {
153
+ const vm = getCurrentInstance()
154
+ // @ts-ignore
155
+ window.vm = vm
156
+ })
157
+
113
158
  return {
114
159
  hasDefaultSlot,
115
160
  leftText,
116
161
  rightText,
117
162
  shouldShowTooltip,
118
163
  fullText,
119
- dlEllipsisRef
164
+ dlEllipsisRef,
165
+ hasEllipsis,
166
+ cssVars
120
167
  }
121
168
  }
122
169
  })
@@ -137,5 +184,32 @@ export default defineComponent({
137
184
  flex: 1 0 auto;
138
185
  overflow: hidden;
139
186
  }
187
+
188
+ &__multiline {
189
+ /* Set the number of lines to display */
190
+ display: -webkit-box;
191
+ /* Enable text ellipsis */
192
+ overflow: hidden;
193
+ /* Allow text to break into multiple lines */
194
+ -webkit-box-orient: vertical;
195
+ /* Enable vertical scrolling if necessary */
196
+ overflow-y: auto;
197
+ /* Hide the horizontal scrollbar */
198
+ overflow-x: hidden;
199
+
200
+ &-text {
201
+ /* Set the number of lines to display */
202
+ display: -webkit-box;
203
+ -webkit-line-clamp: var(
204
+ --max-lines,
205
+ 3
206
+ ); /* Adjust this value as needed */
207
+ /* Enable text ellipsis */
208
+ overflow: hidden;
209
+ /* Allow text to break into multiple lines */
210
+ -webkit-box-orient: vertical;
211
+ white-space: normal;
212
+ }
213
+ }
140
214
  }
141
215
  </style>
@@ -27,6 +27,19 @@
27
27
  :split-position="0.2"
28
28
  />
29
29
  </div>
30
+ <div style="white-space: nowrap; width: 350px; max-height: 600px">
31
+ <p style="font-weight: bold">
32
+ Ellipsis with paragraph
33
+ </p>
34
+ <dl-ellipsis
35
+ :text="`Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. \
36
+ Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. \
37
+ Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. \
38
+ Excepteur sint occaecat cupidatat non proident, \
39
+ sunt in culpa qui officia deserunt mollit anim id est laborum.`"
40
+ multiline
41
+ />
42
+ </div>
30
43
  </div>
31
44
  </template>
32
45
 
@@ -1,3 +1,6 @@
1
1
  export const isEllipsisActive = (e: Element) => {
2
- return (e as HTMLElement).offsetWidth < e.scrollWidth
2
+ return (
3
+ (e as HTMLElement).offsetWidth < e.scrollWidth ||
4
+ (e as HTMLElement).offsetHeight < e.scrollHeight
5
+ )
3
6
  }