@dataloop-ai/components 0.17.18 → 0.17.19

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.17.18",
3
+ "version": "0.17.19",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./models": "./models.ts",
@@ -464,7 +464,7 @@ export default defineComponent({
464
464
  .dl-popup {
465
465
  z-index: calc(var(--dl-z-index-menu) - 1);
466
466
  position: fixed !important;
467
- padding: 10px 0 16px 0;
467
+ padding: var(--dl-popup-padding, 10px 0 16px 0);
468
468
  border: 1px solid var(--dl-color-separator);
469
469
  display: flex;
470
470
  background-color: var(--dl-color-panel-background);
@@ -186,8 +186,63 @@
186
186
  {{ computedAllItemsLabel }}
187
187
  </template>
188
188
  </dl-select-option>
189
+ <!-- Virtual scroll -->
190
+ <dl-virtual-scroll
191
+ v-if="optionsCount > MAX_ITEMS_PER_LIST"
192
+ v-slot="{ item }"
193
+ :items="options"
194
+ :virtual-scroll-item-size="28"
195
+ :virtual-scroll-sticky-size-start="28"
196
+ :virtual-scroll-sticky-size-end="20"
197
+ separator
198
+ >
199
+ <dl-select-option
200
+ :key="getKeyForOption(item)"
201
+ clickable
202
+ :multiselect="multiselect"
203
+ :class="{
204
+ selected:
205
+ option === selectedOption &&
206
+ highlightSelected
207
+ }"
208
+ :style="
209
+ optionIndex === highlightedIndex
210
+ ? 'background-color: var(--dl-color-fill)'
211
+ : ''
212
+ "
213
+ :with-wave="withWave"
214
+ :model-value="modelValue"
215
+ :value="getOptionValue(item)"
216
+ :highlight-selected="highlightSelected"
217
+ :count="getOptionCount(item)"
218
+ :children="getOptionChildren(item)"
219
+ :capitalized="capitalizedOptions"
220
+ @update:model-value="handleModelValueUpdate"
221
+ @click="selectOption(item)"
222
+ @selected="handleSelected"
223
+ @deselected="handleDeselected"
224
+ >
225
+ <slot
226
+ v-if="hasOptionSlot"
227
+ :opt="item"
228
+ name="option"
229
+ />
230
+ <template v-else>
231
+ {{
232
+ capitalizedOptions
233
+ ? typeof getOptionLabel(item) ===
234
+ 'string' &&
235
+ getOptionLabel(item).toLowerCase()
236
+ : getOptionLabel(item)
237
+ }}
238
+ </template>
239
+ </dl-select-option>
240
+ </dl-virtual-scroll>
241
+
242
+ <!-- Else normal list -->
189
243
  <dl-select-option
190
244
  v-for="(option, optionIndex) in options"
245
+ v-else
191
246
  :key="getKeyForOption(option)"
192
247
  clickable
193
248
  :multiselect="multiselect"
@@ -259,7 +314,11 @@
259
314
  import { InputSizes, TInputSizes } from '../../../utils/input-sizes'
260
315
  import { DlListItem } from '../../basic'
261
316
  import { DlTooltip, DlList, DlIcon, DlMenu } from '../../essential'
262
- import { DlInfoErrorMessage, DlItemSection } from '../../shared'
317
+ import {
318
+ DlInfoErrorMessage,
319
+ DlItemSection,
320
+ DlVirtualScroll
321
+ } from '../../shared'
263
322
  import { defineComponent, isVue2, PropType, ref } from 'vue-demi'
264
323
  import {
265
324
  getLabel,
@@ -282,7 +341,8 @@ export default defineComponent({
282
341
  DlListItem,
283
342
  DlMenu,
284
343
  DlTooltip,
285
- DlSelectOption
344
+ DlSelectOption,
345
+ DlVirtualScroll
286
346
  },
287
347
  model: {
288
348
  prop: 'modelValue',
@@ -349,6 +409,8 @@ export default defineComponent({
349
409
  const isExpanded = ref(false)
350
410
  const selectedIndex = ref(-1)
351
411
  const highlightedIndex = ref(-1)
412
+ const isEmpty = ref(true)
413
+ const MAX_ITEMS_PER_LIST = 100 // HARDCODED - max items per list before virtual scroll
352
414
 
353
415
  const setHighlightedIndex = (value: any) => {
354
416
  highlightedIndex.value = value
@@ -367,6 +429,9 @@ export default defineComponent({
367
429
  }
368
430
 
369
431
  return {
432
+ uuid: `dl-select-${v4()}`,
433
+ MAX_ITEMS_PER_LIST,
434
+ isEmpty,
370
435
  isExpanded,
371
436
  highlightedIndex,
372
437
  selectedIndex,
@@ -375,13 +440,10 @@ export default defineComponent({
375
440
  handleModelValueUpdate
376
441
  }
377
442
  },
378
- data() {
379
- return {
380
- uuid: `dl-select-${v4()}`,
381
- isEmpty: true
382
- }
383
- },
384
443
  computed: {
444
+ optionsCount(): number {
445
+ return this.options?.length ?? 0
446
+ },
385
447
  identifierClass(): string {
386
448
  return `dl-select-${this.title}-${
387
449
  this.placeholder ?? ''
@@ -346,12 +346,27 @@
346
346
  </div>
347
347
  </template>
348
348
  </dl-select>
349
+
350
+ Select with virtual scrolling
351
+ <dl-select
352
+ v-model="selectedOption"
353
+ :options="alotOfOptions ? alotOfOptions : []"
354
+ style="margin-bottom: 150px"
355
+ >
356
+ <template #option="scope">
357
+ <div style="padding: 5px 0px">
358
+ <div>{{ scope.opt.label }}</div>
359
+ <div>{{ scope.opt.subLabel }}</div>
360
+ </div>
361
+ </template>
362
+ </dl-select>
349
363
  </div>
350
364
  </template>
351
365
 
352
366
  <script lang="ts">
353
367
  import { defineComponent } from 'vue-demi'
354
368
  import { DlChip, DlSelect, DlIcon, DlBadge } from '../components'
369
+ import { DlSelectOptionType } from '../components/compound/DlSelect/utils'
355
370
 
356
371
  const defaultOptions = [
357
372
  { label: 'Contributor 1', value: 'c1' },
@@ -480,6 +495,21 @@ export default defineComponent({
480
495
  isNotSelected() {
481
496
  // @ts-ignore
482
497
  return defaultOptions.includes(this.selectedBySearch as any)
498
+ },
499
+ alotOfOptions(): DlSelectOptionType {
500
+ const arr = [] as any[]
501
+
502
+ for (let i = 0; i < 1000; ++i) {
503
+ arr.push({
504
+ key: i,
505
+ subLabel: 'not so high',
506
+ label: 'High ' + i,
507
+ value: 'high',
508
+ bgColor: 'dl-color-negative'
509
+ })
510
+ }
511
+
512
+ return arr
483
513
  }
484
514
  },
485
515
  methods: {