@dataloop-ai/components 0.16.48 → 0.16.50

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.48",
3
+ "version": "0.16.50",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./models": "./models.ts",
@@ -10,7 +10,7 @@
10
10
  :tabindex="tabIndex"
11
11
  :aria-disabled="disabled ? 'true' : 'false'"
12
12
  :disabled="disabled"
13
- :style="[cssButtonVars, styles]"
13
+ :style="[cssButtonVars, computedStyles]"
14
14
  style="pointer-events: auto"
15
15
  class="dl-button"
16
16
  @click="onClick"
@@ -73,6 +73,8 @@ import { colorNames } from '../../../utils/css-color-names'
73
73
  import { useSizeObserver } from '../../../hooks/use-size-observer'
74
74
  import { v4 } from 'uuid'
75
75
  import { ButtonColors } from './types'
76
+ import { stringStyleToRecord } from '../../../utils'
77
+ import { isString } from 'lodash'
76
78
 
77
79
  export default defineComponent({
78
80
  name: 'DlButton',
@@ -108,7 +110,7 @@ export default defineComponent({
108
110
  icon: { type: String, default: '' },
109
111
  overflow: { type: Boolean, default: false, required: false },
110
112
  tooltip: { type: String, default: null, required: false },
111
- styles: { type: [Object, String, Array], default: null }
113
+ styles: { type: [Object, String], default: null }
112
114
  },
113
115
  emits: ['click', 'mousedown'],
114
116
  setup() {
@@ -122,6 +124,11 @@ export default defineComponent({
122
124
  }
123
125
  },
124
126
  computed: {
127
+ computedStyles(): Record<string, string> {
128
+ return isString(this.styles)
129
+ ? stringStyleToRecord(this.styles)
130
+ : this.styles
131
+ },
125
132
  isActionable(): boolean {
126
133
  return this.disabled !== true
127
134
  },
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <div
3
3
  class="card"
4
- :style="[{ width, height }, styles]"
4
+ :style="[{ width, height }, computedStyles]"
5
5
  >
6
6
  <div
7
7
  v-if="icon"
@@ -84,7 +84,9 @@
84
84
  </template>
85
85
 
86
86
  <script lang="ts">
87
+ import { isString } from 'lodash'
87
88
  import { defineComponent, PropType } from 'vue-demi'
89
+ import { stringStyleToRecord } from '../../../utils'
88
90
  import { DlIcon } from '../../essential/DlIcon'
89
91
  import { DlLink } from '../../essential/DlLink'
90
92
  import { IconItem, ImageItem, LinkItem } from './types'
@@ -126,11 +128,16 @@ export default defineComponent({
126
128
  default: '200px'
127
129
  },
128
130
  styles: {
129
- type: [Object, String, Array],
131
+ type: [Object, String],
130
132
  default: null
131
133
  }
132
134
  },
133
135
  computed: {
136
+ computedStyles(): Record<string, string> {
137
+ return isString(this.styles)
138
+ ? stringStyleToRecord(this.styles)
139
+ : this.styles
140
+ },
134
141
  iconStyles(): string {
135
142
  return this.icon?.styles ?? ''
136
143
  },
@@ -112,6 +112,8 @@ import {
112
112
  import DraggableUpper from './components/DraggableUpper.vue'
113
113
  import PopupHeader from './components/PopupHeader.vue'
114
114
  import { v4 } from 'uuid'
115
+ import { isString } from 'lodash'
116
+ import { stringStyleToRecord } from '../../../utils'
115
117
 
116
118
  export default defineComponent({
117
119
  name: 'DlPopup',
@@ -446,7 +448,9 @@ export default defineComponent({
446
448
  portalIsActive,
447
449
  classes: 'dl-popup dl-position-engine scroll',
448
450
  styles: [
449
- attrs.style,
451
+ isString(attrs.style)
452
+ ? stringStyleToRecord(attrs.style)
453
+ : attrs.style,
450
454
  transitionStyle.value,
451
455
  stylesFromProps.value
452
456
  ] as any
@@ -78,18 +78,21 @@ export function flattenConfusionMatrix(
78
78
 
79
79
  for (const [rowIndex, row] of matrix.entries()) {
80
80
  for (const [cellIndex, cell] of row.entries()) {
81
- const value = isObject(cell)
81
+ const cellIsObject = isObject(cell)
82
+ const value: number = cellIsObject
82
83
  ? (cell as DlConfusionMatrixCell).value
83
- : cell
84
- toNormalize.push({
84
+ : (cell as number)
85
+
86
+ const object: DlConfusionMatrixCell = {
85
87
  value,
86
88
  unnormalizedValue: value,
87
89
  xLabel: labelStrings[rowIndex],
88
90
  yLabel: labelStrings[cellIndex],
89
91
  x: rowIndex,
90
92
  y: cellIndex,
91
- link: isObject ? (cell as DlConfusionMatrixCell).link : ''
92
- })
93
+ link: cellIsObject ? (cell as DlConfusionMatrixCell).link : ''
94
+ }
95
+ toNormalize.push(object)
93
96
  }
94
97
  }
95
98
  return normalizeMatrix(toNormalize)
@@ -121,6 +121,7 @@ export default defineComponent({
121
121
  },
122
122
  props: {
123
123
  withWave: Boolean,
124
+ // todo: clean this up; rename the prop to something better
124
125
  defaultStyles: { type: Boolean, default: true },
125
126
  multiselect: { type: Boolean, default: false },
126
127
  value: { type: ValueTypes, default: null },
@@ -415,15 +415,18 @@
415
415
  v-if="!hideBottom"
416
416
  :class="bottomClasses"
417
417
  >
418
- <div class="dl-table__control">
419
- <slot
420
- v-if="nothingToDisplay && !hideNoData"
421
- name="no-data"
422
- >
423
- {{ bottomMessage }}
418
+ <div
419
+ v-if="nothingToDisplay && !hideNoData"
420
+ class="dl-table__control"
421
+ >
422
+ <slot name="no-data">
423
+ {{ noDataMessage }}
424
424
  </slot>
425
425
  </div>
426
- <div class="dl-table__control">
426
+ <div
427
+ v-else
428
+ class="dl-table__control"
429
+ >
427
430
  <slot
428
431
  name="bottom"
429
432
  v-bind="marginalsScope"
@@ -438,12 +441,13 @@
438
441
  </div>
439
442
 
440
443
  <slot
441
- v-bind="marginalsScope"
442
444
  name="pagination"
445
+ v-bind="marginalsScope"
443
446
  >
444
447
  <dl-pagination
445
448
  v-if="displayPagination"
446
449
  v-bind="marginalsScope.pagination"
450
+ total-items="rows.length"
447
451
  @update:rowsPerPage="
448
452
  (v) => setPagination({ rowsPerPage: v })
449
453
  "
@@ -699,7 +703,7 @@ export default defineComponent({
699
703
  })
700
704
  //
701
705
 
702
- const bottomMessage = computed(() => {
706
+ const noDataMessage = computed(() => {
703
707
  if (props.loading) {
704
708
  return props.loadingLabel
705
709
  }
@@ -1257,7 +1261,7 @@ export default defineComponent({
1257
1261
  bottomClasses,
1258
1262
  hasTopSlots,
1259
1263
  nothingToDisplay,
1260
- bottomMessage,
1264
+ noDataMessage,
1261
1265
  paginationState,
1262
1266
  hasTopSelectionMode,
1263
1267
  hasBotomSelectionBanner,
@@ -2,7 +2,7 @@
2
2
  <div
3
3
  v-if="!svg"
4
4
  :id="uuid"
5
- :style="[inlineStyles, styles]"
5
+ :style="[inlineStyles, computedStyles]"
6
6
  @click="$emit('click', $event)"
7
7
  @mousedown="$emit('mousedown', $event)"
8
8
  @mouseup="$emit('mouseup', $event)"
@@ -35,9 +35,10 @@
35
35
  </template>
36
36
 
37
37
  <script lang="ts">
38
+ import { isString } from 'lodash'
38
39
  import { v4 } from 'uuid'
39
40
  import { defineComponent } from 'vue-demi'
40
- import { getColor, loggerFactory } from '../../../utils'
41
+ import { getColor, loggerFactory, stringStyleToRecord } from '../../../utils'
41
42
 
42
43
  export default defineComponent({
43
44
  name: 'DlIcon',
@@ -55,7 +56,7 @@ export default defineComponent({
55
56
  default: '12px'
56
57
  },
57
58
  styles: {
58
- type: [Array, String, Object],
59
+ type: [String, Object],
59
60
  default: null
60
61
  },
61
62
  svg: {
@@ -80,6 +81,11 @@ export default defineComponent({
80
81
  }
81
82
  },
82
83
  computed: {
84
+ computedStyles(): Record<string, string> {
85
+ return isString(this.styles)
86
+ ? stringStyleToRecord(this.styles)
87
+ : this.styles
88
+ },
83
89
  cssIconVars(): Record<string, string> {
84
90
  return {
85
91
  '--dl-icon-font-size': `${this.size}`,
@@ -94,8 +100,8 @@ export default defineComponent({
94
100
  : 'inherit'
95
101
  }
96
102
  },
97
- inlineStyles(): string {
98
- return this.inline ? 'display: inline' : 'display: flex;'
103
+ inlineStyles(): Record<string, string> {
104
+ return { display: this.inline ? 'inline' : 'flex;' }
99
105
  },
100
106
  // needed to allow external source of icons that do not use class based
101
107
  externalIcon(): boolean {
@@ -48,7 +48,8 @@ import {
48
48
  cleanEvt,
49
49
  clearSelection,
50
50
  getColor,
51
- isMobileOrTablet
51
+ isMobileOrTablet,
52
+ stringStyleToRecord
52
53
  } from '../../../utils'
53
54
  import {
54
55
  parsePosition,
@@ -65,6 +66,7 @@ import {
65
66
  } from '../../../utils/click-outside'
66
67
  import DlTeleport from '../../../utils/teleport'
67
68
  import { v4 } from 'uuid'
69
+ import { isString } from 'lodash'
68
70
 
69
71
  export default defineComponent({
70
72
  name: 'DlTooltip',
@@ -391,7 +393,9 @@ export default defineComponent({
391
393
  innerRef,
392
394
  portalEl: isVue2 ? 'body' : portalEl,
393
395
  styles: [
394
- attrs.style,
396
+ isString(attrs.style)
397
+ ? stringStyleToRecord(attrs.style)
398
+ : attrs.style,
395
399
  transitionStyle.value,
396
400
  {
397
401
  '--dl-tooltip-color': getColor(
@@ -1,6 +1,7 @@
1
1
  <template>
2
2
  <div>
3
3
  <DlAlert
4
+ type="info"
4
5
  :closable="true"
5
6
  fluid
6
7
  >
@@ -241,7 +241,48 @@
241
241
  </div>
242
242
  </div>
243
243
  <div>
244
- <p>#no-data & #pagination declare together</p>
244
+ <h3>slots #no-data & #pagination declare together</h3>
245
+ <h4>case 1: table with data</h4>
246
+ <p>
247
+ rows should appear with slot#pagination, slot#no-data should
248
+ not
249
+ </p>
250
+ <DlTable
251
+ :rows="tableRows"
252
+ :selected="selected"
253
+ :separator="separator"
254
+ :columns="columns"
255
+ :bordered="bordered"
256
+ :draggable="draggable"
257
+ :dense="dense"
258
+ class="sticky-header"
259
+ :filter="filter"
260
+ :selection="selection"
261
+ :loading="loading"
262
+ :resizable="resizable"
263
+ row-key="name"
264
+ color="dl-color-secondary"
265
+ title="Table Title"
266
+ :virtual-scroll="vScroll"
267
+ style="height: 200px"
268
+ :rows-per-page-options="rowsPerPageOptions"
269
+ @row-click="log"
270
+ @update:selected="updateSeleted"
271
+ >
272
+ <template #pagination>
273
+ <div style="background-color: #4db1d3">
274
+ &lt slot#pagination >
275
+ </div>
276
+ </template>
277
+ <template #no-data>
278
+ <div style="background-color: #734145">
279
+ &lt slot#no-data > should not be visible
280
+ </div>
281
+ </template>
282
+ </DlTable>
283
+ <h4>case 2: table with no data</h4>
284
+ <p>slot#no-data should appear, slot#pagination not</p>
285
+
245
286
  <DlTable
246
287
  :selected="selected"
247
288
  :separator="separator"
@@ -264,10 +305,14 @@
264
305
  @update:selected="updateSeleted"
265
306
  >
266
307
  <template #pagination>
267
- pagination slot, no-data slot should be visible too
308
+ <div style="background-color: #734145">
309
+ &lt slot#pagination > should not be visible
310
+ </div>
268
311
  </template>
269
312
  <template #no-data>
270
- no-data slot, pagination slot should be visible too
313
+ <div style="background-color: #2f3c4b">
314
+ &lt slot#no-data >
315
+ </div>
271
316
  </template>
272
317
  </DlTable>
273
318
  </div>
@@ -374,5 +374,5 @@ const matchStringEnd = (input: string, str: string) =>
374
374
  input.lastIndexOf(str + '" ') > -1 || input.lastIndexOf(str + "' ") > -1
375
375
 
376
376
  export const removeBrackets = (str: string) => {
377
- return str.replaceAll('(', '').replaceAll(')', '')
377
+ return str.replace(/\(/g, '').replace(/\)/g, '')
378
378
  }
@@ -13,6 +13,7 @@ export * from './component-name-parser'
13
13
  export * from './colors'
14
14
  export * from './teleport'
15
15
  export * from './parse-smart-query'
16
+ export * from './stringStyleToRecord'
16
17
 
17
18
  export const isMobileOrTablet = () => {
18
19
  let check = false
@@ -0,0 +1,17 @@
1
+ export const stringStyleToRecord = (input: string): Record<string, string> => {
2
+ const style = input.split(';')
3
+ const output: Record<string, string> = {}
4
+ style.forEach((item) => {
5
+ const [key, value] = item.split(':')
6
+ if (key && value) {
7
+ output[snakeToCamel(key.trim())] = value.trim()
8
+ }
9
+ })
10
+ return output
11
+ }
12
+
13
+ export const snakeToCamel = (str: string): string => {
14
+ return str.replace(/([-_][a-z])/g, (group) =>
15
+ group.toUpperCase().replace('-', '').replace('_', '')
16
+ )
17
+ }