@dataloop-ai/components 0.13.19 → 0.14.4

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.
Files changed (94) hide show
  1. package/.nvmrc +1 -0
  2. package/README.md +3 -1
  3. package/package.json +19 -17
  4. package/src/assets/globals.scss +38 -3
  5. package/src/assets/grid.scss +9 -0
  6. package/src/components/DlAccordion/DlAccordion.vue +4 -4
  7. package/src/components/DlAlert.vue +6 -6
  8. package/src/components/DlChart/BrushThumb.vue +83 -0
  9. package/src/components/DlChart/DlBarChart.vue +545 -0
  10. package/src/components/DlChart/DlBrush.vue +475 -0
  11. package/src/components/DlChart/DlChartLabels.vue +279 -0
  12. package/src/components/DlChart/DlChartLegend.vue +141 -0
  13. package/src/components/DlChart/DlColumnChart.vue +555 -0
  14. package/src/components/DlChart/DlLineChart.vue +644 -0
  15. package/src/components/DlChart/DlScrollBar.vue +147 -0
  16. package/src/components/DlChart/Doughnut/DlDoughnutChart.vue +448 -0
  17. package/src/components/DlChart/Doughnut/DlDoughnutChartLegend.vue +281 -0
  18. package/src/components/DlChart/Doughnut/DlDoughnutChartWidget.vue +64 -0
  19. package/src/components/DlChart/Doughnut/types/TDoughnutChartAnimation.ts +4 -0
  20. package/src/components/DlChart/Doughnut/types/TDoughnutChartData.ts +16 -0
  21. package/src/components/DlChart/Doughnut/types/TDoughnutChartOptions.ts +11 -0
  22. package/src/components/DlChart/Doughnut/types/TDoughnutChartProps.ts +8 -0
  23. package/src/components/DlChart/Doughnut/types/TDoughnutWithOriginalColor.ts +13 -0
  24. package/src/components/DlChart/chart.ts +122 -0
  25. package/src/components/DlChart/index.ts +36 -0
  26. package/src/components/DlChart/props.ts +348 -0
  27. package/src/components/DlChart/typedCharts.ts +88 -0
  28. package/src/components/DlChart/types.ts +63 -0
  29. package/src/components/DlChart/utils.ts +153 -0
  30. package/src/components/DlChip/DlChip.vue +40 -13
  31. package/src/components/DlCounters.vue +31 -7
  32. package/src/components/DlDatePicker/DlCalendar.vue +22 -10
  33. package/src/components/DlDatePicker/DlDatePicker.vue +8 -5
  34. package/src/components/DlDateTimeRange/types.ts +2 -2
  35. package/src/components/DlDropdownButton.vue +5 -3
  36. package/src/components/DlMenu/DlMenu.vue +4 -2
  37. package/src/components/DlPagination/RowsSelector.vue +15 -2
  38. package/src/components/DlPopup/DlPopup.vue +0 -1
  39. package/src/components/DlRange/DlRange.vue +3 -2
  40. package/src/components/DlSearch.vue +1 -1
  41. package/src/components/DlSelect/DlSelect.vue +3 -2
  42. package/src/components/DlSlider/sliderStyles.scss +4 -0
  43. package/src/components/DlSlider/useSlider.ts +39 -12
  44. package/src/components/DlSmartSearch/DlSuggestionsDropdown.vue +1 -1
  45. package/src/components/DlSpinner.vue +259 -0
  46. package/src/components/DlTable/DlTable.vue +4 -1
  47. package/src/components/DlTable/hooks/tablePagination.ts +8 -2
  48. package/src/components/DlTextArea.vue +9 -0
  49. package/src/components/DlTextInput.vue +4 -2
  50. package/src/components/DlThemeProvider.vue +22 -13
  51. package/src/components/DlToastMessage/api/useToast.ts +23 -0
  52. package/src/components/DlToastMessage/components/ToastComponent.vue +279 -0
  53. package/src/components/DlToastMessage/index.ts +5 -0
  54. package/src/components/DlToastMessage/types.ts +4 -0
  55. package/src/components/DlToastMessage/utils/config.ts +17 -0
  56. package/src/components/DlToastMessage/utils/render.ts +56 -0
  57. package/src/components/DlTypography.vue +1 -1
  58. package/src/components/DlWidget/DlGrid.vue +33 -0
  59. package/src/components/DlWidget/DlGridRow.vue +32 -0
  60. package/src/components/DlWidget/DlWidget.vue +202 -11
  61. package/src/components/DlWidget/index.ts +2 -2
  62. package/src/components/DlWidget/utils.ts +26 -19
  63. package/src/components/index.ts +8 -3
  64. package/src/demo/BarChartDemo.vue +77 -0
  65. package/src/demo/ColumnChartDemo.vue +230 -0
  66. package/src/demo/DlButtonDemo.vue +1 -1
  67. package/src/demo/DlChartDoughnutDemo.vue +229 -0
  68. package/src/demo/DlChipDemo.vue +42 -18
  69. package/src/demo/DlDialogBoxDemo.vue +4 -4
  70. package/src/demo/DlDropdownButtonDemo.vue +1 -1
  71. package/src/demo/DlLineChartDemo.vue +375 -0
  72. package/src/demo/DlMenuDemo.vue +1 -1
  73. package/src/demo/DlOptionGroupDemo.vue +1 -1
  74. package/src/demo/DlSelectDemo.vue +1 -1
  75. package/src/demo/DlSpinnerDemo.vue +20 -0
  76. package/src/demo/DlTableDemo.vue +13 -94
  77. package/src/demo/DlToastMessageDemo.vue +143 -0
  78. package/src/demo/DlWidgetDemo.vue +105 -143
  79. package/src/demo/index.ts +20 -2
  80. package/src/hooks/use-theme.ts +19 -0
  81. package/src/utils/abbreviate-to-string.ts +14 -0
  82. package/src/utils/colors.ts +47 -0
  83. package/src/utils/getRootStyles.ts +1 -1
  84. package/src/utils/index.ts +1 -0
  85. package/src/utils/position-engine.ts +11 -2
  86. package/src/utils/swapNodes.ts +30 -0
  87. package/src/utils/update-key.ts +90 -0
  88. package/tsconfig.json +0 -1
  89. package/vite.config.ts +17 -0
  90. package/Dockerfile +0 -12
  91. package/jest.config.js +0 -16
  92. package/jest.setup.js +0 -59
  93. package/src/components/DlWidget/DlWidgetGrid.vue +0 -360
  94. package/storybook.js +0 -8
@@ -0,0 +1,475 @@
1
+ <template>
2
+ <div
3
+ ref="rootRef"
4
+ class="slider-bar"
5
+ v-bind="attributes"
6
+ :aria-valuenow="attributeDisplayValue"
7
+ data-test="slider-bar"
8
+ :style="rangeStyles"
9
+ >
10
+ <div
11
+ v-touch-pan:horizontal.prevent.stop.mouse.mouseAllDir="onTouchPan"
12
+ class="track-container"
13
+ :class="{ readonly, disabled: disabled }"
14
+ data-test="track-container"
15
+ v-on="trackContainerEvents"
16
+ >
17
+ <div
18
+ class="track"
19
+ :style="trackStyle"
20
+ >
21
+ <div
22
+ class="selection"
23
+ :style="selectionBarStyle"
24
+ />
25
+ <dl-brush-thumb
26
+ key="tmin"
27
+ ref="minThumbRef"
28
+ class="thumb"
29
+ :icon-size="iconSize"
30
+ icon="icon-dl-two-lines"
31
+ icon-color="dl-color-text-buttons"
32
+ :style="minThumbStyle"
33
+ data-test="min-thumb"
34
+ />
35
+
36
+ <dl-brush-thumb
37
+ key="tmax"
38
+ ref="maxThumbRef"
39
+ class="thumb"
40
+ :icon-size="iconSize"
41
+ icon="icon-dl-two-lines"
42
+ icon-color="dl-color-text-buttons"
43
+ :style="maxThumbStyle"
44
+ data-test="max-thumb"
45
+ />
46
+ <input
47
+ v-if="name !== null && disabled !== true"
48
+ type="hidden"
49
+ :name="name"
50
+ :value="displayValue"
51
+ >
52
+ </div>
53
+ </div>
54
+ </div>
55
+ </template>
56
+
57
+ <script lang="ts">
58
+ import { ref, computed, watch, defineComponent } from 'vue-demi'
59
+
60
+ import useSlider, {
61
+ useSliderProps,
62
+ useSliderEmits,
63
+ dragType,
64
+ Dragging
65
+ } from '../DlSlider/useSlider'
66
+
67
+ import { between, isMobileOrTablet, getColor } from '../../utils'
68
+ import DlBrushThumb from './BrushThumb.vue'
69
+ import touchPanDirective from '../../directives/TouchPan'
70
+
71
+ export default defineComponent({
72
+ name: 'DlBrushBar',
73
+ directives: {
74
+ touchPan: touchPanDirective as any // force any type cause of the vue version
75
+ },
76
+ components: {
77
+ DlBrushThumb
78
+ },
79
+ model: {
80
+ prop: 'modelValue',
81
+ event: 'update:modelValue'
82
+ },
83
+ props: {
84
+ ...useSliderProps,
85
+ modelValue: {
86
+ type: Object,
87
+ default: () =>
88
+ ({ min: null, max: null } as {
89
+ min: number | null
90
+ max: number | null
91
+ }),
92
+ validator: (v: Object) => 'min' in v && 'max' in v
93
+ },
94
+
95
+ dragRange: Boolean,
96
+ dragOnlyRange: Boolean,
97
+ trackColor: {
98
+ type: String,
99
+ default: 'dl-color-panel-background'
100
+ },
101
+ selectionColor: {
102
+ type: String,
103
+ default: 'dl-color-chart-brush'
104
+ }
105
+ },
106
+
107
+ emits: useSliderEmits,
108
+
109
+ setup(props, { emit }) {
110
+ const { state, methods } = useSlider({
111
+ updateValue,
112
+ updatePosition,
113
+ getDragging
114
+ })
115
+
116
+ const rootRef = ref(null)
117
+ const curMinRatio = ref(0)
118
+ const curMaxRatio = ref(0)
119
+ const model = ref({ min: 0, max: 0 })
120
+
121
+ function normalizeModel() {
122
+ model.value.min =
123
+ props.modelValue.min === null
124
+ ? state.innerMin.value
125
+ : between(
126
+ props.modelValue.min,
127
+ state.innerMin.value,
128
+ state.innerMax.value
129
+ )
130
+
131
+ model.value.max =
132
+ props.modelValue.max === null
133
+ ? state.innerMax.value
134
+ : between(
135
+ props.modelValue.max,
136
+ state.innerMin.value,
137
+ state.innerMax.value
138
+ )
139
+ }
140
+
141
+ const iconSize = computed(() => {
142
+ return 0.25 * parseInt(props.thumbSize) + 'px'
143
+ })
144
+
145
+ watch(
146
+ () =>
147
+ `${props.modelValue.min}|${props.modelValue.max}|${state.innerMin.value}|${state.innerMax.value}`,
148
+ normalizeModel
149
+ )
150
+
151
+ normalizeModel()
152
+
153
+ const isMobile = computed(() => isMobileOrTablet())
154
+
155
+ const modelMinRatio = computed(() =>
156
+ methods.convertModelToRatio(model.value.min)
157
+ )
158
+ const modelMaxRatio = computed(() =>
159
+ methods.convertModelToRatio(model.value.max)
160
+ )
161
+
162
+ const ratioMin = computed(() =>
163
+ state.active.value === true
164
+ ? curMinRatio.value
165
+ : modelMinRatio.value
166
+ )
167
+ const ratioMax = computed(() =>
168
+ state.active.value === true
169
+ ? curMaxRatio.value
170
+ : modelMaxRatio.value
171
+ )
172
+
173
+ const selectionBarStyle = computed(() => {
174
+ const acc = {
175
+ left: `${100 * ratioMin.value}%`,
176
+ width: `${100 * (ratioMax.value - ratioMin.value)}%`
177
+ }
178
+
179
+ return acc
180
+ })
181
+
182
+ const trackContainerEvents = computed(() => {
183
+ if (state.editable.value !== true) {
184
+ return {}
185
+ }
186
+
187
+ if (isMobile.value) {
188
+ return { onClick: methods.onMobileClick }
189
+ }
190
+
191
+ const evt = { onMousedown: methods.onActivate }
192
+
193
+ if (props.dragRange === true || props.dragOnlyRange === true) {
194
+ Object.assign(evt, {
195
+ onFocus: () => {
196
+ state.focus.value = 'both'
197
+ },
198
+ onBlur: methods.onBlur
199
+ })
200
+ }
201
+
202
+ return evt
203
+ })
204
+
205
+ const trackStyle = computed(() => ({
206
+ height: props.trackSize,
207
+ '--track-color': getColor(props.trackColor),
208
+ '--selection-color': getColor(props.selectionColor)
209
+ }))
210
+
211
+ const onTouchPan = computed(() => {
212
+ return state.editable.value ? methods.onPan : null
213
+ })
214
+
215
+ const minThumbRef = ref(null)
216
+
217
+ const attributeDisplayValue = computed<string>(() => {
218
+ return `${props.modelValue.min}|${props.modelValue.max}`
219
+ })
220
+
221
+ const displayValue = computed<string>(() => {
222
+ return `${model.value.min}|${model.value.max}`
223
+ })
224
+
225
+ const rangeStyles = computed(() => ({
226
+ '--dl-track-width': 0.25 * parseInt(props.thumbSize) + 'px',
227
+ '--text-color': getColor(props.textColor, 'dl-color-darker'),
228
+ '--width': props.width,
229
+ '--color': getColor(props.color, 'dl-color-secondary'),
230
+ width: props.width
231
+ }))
232
+
233
+ const minThumbStyle = computed(() => ({
234
+ width: 0.5 * parseInt(props.thumbSize) + 'px',
235
+ height: props.thumbSize,
236
+ left: `${100 * ratioMin.value}%`,
237
+ zIndex: state.focus.value === 'min' ? 2 : void 0
238
+ }))
239
+
240
+ const maxThumbStyle = computed(() => ({
241
+ width: 0.5 * parseInt(props.thumbSize) + 'px',
242
+ height: props.thumbSize,
243
+ left: `${100 * ratioMax.value}%`,
244
+ zIndex: state.focus.value === 'max' ? 2 : void 0
245
+ }))
246
+
247
+ function updateValue(change = false) {
248
+ if (
249
+ model.value.min !== props.modelValue.min ||
250
+ model.value.max !== props.modelValue.max
251
+ ) {
252
+ emit('update:model-value', { ...model.value })
253
+ }
254
+ if (change) {
255
+ emit('change', { ...model.value })
256
+ }
257
+ }
258
+
259
+ function getDragging(event: MouseEvent) {
260
+ const { left, top, width, height } =
261
+ rootRef.value.getBoundingClientRect()
262
+ const sensitivity =
263
+ props.dragOnlyRange === true
264
+ ? 0
265
+ : minThumbRef.value.$el.offsetWidth / (2 * width)
266
+
267
+ const dragging: Dragging = {
268
+ left,
269
+ top,
270
+ width,
271
+ height,
272
+ valueMin: model.value.min,
273
+ valueMax: model.value.max,
274
+ ratioMin: modelMinRatio.value,
275
+ ratioMax: modelMaxRatio.value
276
+ }
277
+
278
+ const ratio = methods.getDraggingRatio(event, dragging)
279
+
280
+ if (
281
+ props.dragOnlyRange !== true &&
282
+ ratio < dragging.ratioMin + sensitivity
283
+ ) {
284
+ dragging.type = dragType.MIN
285
+ } else if (
286
+ props.dragOnlyRange === true ||
287
+ ratio < dragging.ratioMax - sensitivity
288
+ ) {
289
+ if (props.dragRange === true || props.dragOnlyRange === true) {
290
+ dragging.type = dragType.RANGE
291
+ Object.assign(dragging, {
292
+ offsetRatio: ratio,
293
+ offsetModel: methods.convertRatioToModel(ratio),
294
+ rangeValue: dragging.valueMax - dragging.valueMin,
295
+ rangeRatio: dragging.ratioMax - dragging.ratioMin
296
+ })
297
+ } else {
298
+ dragging.type =
299
+ dragging.ratioMax - ratio < ratio - dragging.ratioMin
300
+ ? dragType.MAX
301
+ : dragType.MIN
302
+ }
303
+ } else {
304
+ dragging.type = dragType.MAX
305
+ }
306
+
307
+ return dragging
308
+ }
309
+
310
+ function updatePosition(
311
+ event: MouseEvent,
312
+ dragging = state.dragging.value
313
+ ) {
314
+ let pos
315
+ const ratio = methods.getDraggingRatio(event, dragging)
316
+ const localModel = methods.convertRatioToModel(ratio)
317
+
318
+ switch ((dragging as Dragging).type) {
319
+ case dragType.MIN:
320
+ if (ratio <= (dragging as Dragging).ratioMax) {
321
+ pos = {
322
+ minR: ratio,
323
+ maxR: (dragging as Dragging).ratioMax,
324
+ min: localModel,
325
+ max: (dragging as Dragging).valueMax
326
+ }
327
+ state.focus.value = 'min'
328
+ } else {
329
+ pos = {
330
+ minR: (dragging as Dragging).ratioMax,
331
+ maxR: ratio,
332
+ min: (dragging as Dragging).valueMax,
333
+ max: localModel
334
+ }
335
+ state.focus.value = 'max'
336
+ }
337
+ break
338
+
339
+ case dragType.MAX:
340
+ if (ratio >= (dragging as Dragging).ratioMin) {
341
+ pos = {
342
+ minR: (dragging as Dragging).ratioMin,
343
+ maxR: ratio,
344
+ min: (dragging as Dragging).valueMin,
345
+ max: localModel
346
+ }
347
+ state.focus.value = 'max'
348
+ } else {
349
+ pos = {
350
+ minR: ratio,
351
+ maxR: (dragging as Dragging).ratioMin,
352
+ min: localModel,
353
+ max: (dragging as Dragging).valueMin
354
+ }
355
+ state.focus.value = 'min'
356
+ }
357
+ break
358
+
359
+ case dragType.RANGE:
360
+ const ratioDelta =
361
+ ratio - (dragging as Dragging).offsetRatio
362
+ const minR = between(
363
+ (dragging as Dragging).ratioMin + ratioDelta,
364
+ 0,
365
+ 1 - (dragging as Dragging).rangeRatio
366
+ )
367
+ const modelDelta =
368
+ localModel - (dragging as Dragging).offsetModel
369
+ const min = between(
370
+ (dragging as Dragging).valueMin + modelDelta,
371
+ props.min,
372
+ props.max - (dragging as Dragging).rangeValue
373
+ )
374
+
375
+ pos = {
376
+ minR,
377
+ maxR: minR + (dragging as Dragging).rangeRatio,
378
+ min: parseFloat(min.toFixed(state.decimals.value)),
379
+ max: parseFloat(
380
+ (min + (dragging as Dragging).rangeValue).toFixed(
381
+ state.decimals.value
382
+ )
383
+ )
384
+ }
385
+
386
+ state.focus.value = 'both'
387
+ break
388
+ }
389
+
390
+ model.value =
391
+ model.value.min === null || model.value.max === null
392
+ ? { min: pos.min || props.min, max: pos.max || props.max }
393
+ : { min: pos.min, max: pos.max }
394
+
395
+ if (props.snap !== true || props.step === 0) {
396
+ curMinRatio.value = pos.minR
397
+ curMaxRatio.value = pos.maxR
398
+ } else {
399
+ curMinRatio.value = methods.convertModelToRatio(model.value.min)
400
+ curMaxRatio.value = methods.convertModelToRatio(model.value.max)
401
+ }
402
+ }
403
+
404
+ return {
405
+ attributeDisplayValue,
406
+ displayValue,
407
+ rangeStyles,
408
+ attributes: state.attributes,
409
+ minThumbStyle,
410
+ maxThumbStyle,
411
+ selectionBarStyle,
412
+ trackContainerEvents,
413
+ trackStyle,
414
+ onTouchPan,
415
+ rootRef,
416
+ minThumbRef,
417
+ iconSize
418
+ }
419
+ }
420
+ })
421
+ </script>
422
+
423
+ <style scoped lang="scss">
424
+ .slider-bar {
425
+ position: relative;
426
+ width: 100%;
427
+ cursor: grab;
428
+ display: inline-flex;
429
+ flex-wrap: nowrap;
430
+ flex-direction: column;
431
+ opacity: 1;
432
+
433
+ & .track-container {
434
+ cursor: grab;
435
+ outline: 0;
436
+ width: 100%;
437
+ max-width: var(--width);
438
+
439
+ & .track {
440
+ height: 2px;
441
+ width: inherit;
442
+ position: relative;
443
+ outline: none;
444
+ background-color: var(--track-color);
445
+ border: 1px solid var(--dl-color-separator);
446
+ border-radius: 3px;
447
+
448
+ & .selection {
449
+ background: var(--selection-color);
450
+ border-radius: inherit;
451
+ width: 100%;
452
+ height: 100%;
453
+ position: absolute;
454
+ }
455
+
456
+ & .thumb {
457
+ z-index: 1;
458
+ outline: 0;
459
+ transition: transform 0.18s ease-out, fill 0.18s ease-out,
460
+ stroke 0.18s ease-out;
461
+ top: 50%;
462
+ transform: scale(1) translate(-50%, -50%);
463
+ position: absolute;
464
+ user-select: none;
465
+ &:nth-child(odd) {
466
+ border-radius: 0px 3px 3px 0px;
467
+ }
468
+ &:nth-child(even) {
469
+ border-radius: 3px 0px 0px 3px;
470
+ }
471
+ }
472
+ }
473
+ }
474
+ }
475
+ </style>