@dataloop-ai/components 0.18.139 → 0.18.141

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.139",
3
+ "version": "0.18.141",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./models": "./models.ts",
@@ -12,13 +12,13 @@
12
12
  >
13
13
  <div :class="computeClass('item-content')">
14
14
  <dl-kpi
15
- :counter="kpiValue(item.value)"
15
+ :counter="kpiValue(item)"
16
16
  :counter-font-size="counterFontSize"
17
17
  :title="capitalize(item.text)"
18
18
  :title-font-size="titleFontSize"
19
19
  :subtitle="item.subtext && capitalize(item.subtext)"
20
20
  :subtitle-font-size="subtitleFontSize"
21
- :info-message="null"
21
+ :info-message="kpiInfoMessage(item)"
22
22
  :progress="null"
23
23
  :small="small"
24
24
  />
@@ -89,11 +89,14 @@ export default defineComponent({
89
89
  computeClass(value: string): (string | boolean)[] {
90
90
  return [value, this.small && `${value}--small`]
91
91
  },
92
- kpiValue(value: string | number) {
92
+ kpiValue(item: DlCounterItem) {
93
93
  return {
94
- value: value ?? 0,
95
- format: DlKpiCounterFormat.long
94
+ value: item.value ?? 0,
95
+ format: item.format ?? DlKpiCounterFormat.long
96
96
  }
97
+ },
98
+ kpiInfoMessage(item: DlCounterItem) {
99
+ return item.infoMessage || null
97
100
  }
98
101
  }
99
102
  })
@@ -2,4 +2,6 @@ export interface DlCounterItem {
2
2
  value?: number
3
3
  text: string
4
4
  subtext?: string
5
+ infoMessage?: string
6
+ format?: string
5
7
  }
@@ -38,7 +38,11 @@ export const isEndingWithDateIntervalPattern = (str: string) => {
38
38
 
39
39
  export const replaceDateInterval = (str: string, date: DateInterval) => {
40
40
  const newStr = `${formatDate(date.from)}`
41
- const replaced = replaceLastOccurrence(str, newStr, datePatternNoBrackets)
41
+ const replaced = replaceFirstOrLastOccurrence(
42
+ str,
43
+ newStr,
44
+ datePatternNoBrackets
45
+ )
42
46
  return replaced
43
47
  }
44
48
 
@@ -46,16 +50,39 @@ const formatDate = (date: Date | string | number): string => {
46
50
  return moment.utc(date).format('DD/MM/YYYY')
47
51
  }
48
52
 
49
- const replaceLastOccurrence = (
53
+ const replaceFirstOrLastOccurrence = (
50
54
  string: string,
51
55
  replaceValue: string,
52
56
  pattern: RegExp
53
57
  ) => {
54
- const matches = string.match(pattern)
58
+ const regex = RegExp(pattern, 'g')
55
59
 
56
- return matches && matches.length
57
- ? string.replace(matches[matches.length - 1], replaceValue)
58
- : string
60
+ let firstMatch
61
+ let lastMatch
62
+ let match
63
+
64
+ while ((match = regex.exec(string))) {
65
+ if (match[0] === 'dd/mm/yyyy' && !firstMatch) {
66
+ firstMatch = match
67
+ }
68
+ lastMatch = match
69
+ }
70
+
71
+ if (firstMatch) {
72
+ const modifiedString =
73
+ string.slice(0, firstMatch.index) +
74
+ string.slice(firstMatch.index).replace(firstMatch[0], replaceValue)
75
+
76
+ return modifiedString
77
+ } else if (lastMatch) {
78
+ const modifiedString =
79
+ string.slice(0, lastMatch.index) +
80
+ string.slice(lastMatch.index).replace(lastMatch[0], replaceValue)
81
+
82
+ return modifiedString
83
+ }
84
+
85
+ return string
59
86
  }
60
87
 
61
88
  export function getTabItems(filters: Filters) {
@@ -38,6 +38,33 @@
38
38
  }
39
39
  ]"
40
40
  />
41
+ <dl-counters
42
+ small
43
+ :items="[
44
+ {
45
+ value: 100000000,
46
+ text: 'lorem',
47
+ format: 'short',
48
+ infoMessage:
49
+ 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.'
50
+ },
51
+ {
52
+ value: '154h:35m:20s',
53
+ text: 'ipsum lorem',
54
+ subtext:
55
+ 'Cupidatat est labore et nisi do culpa veniam reprehenderit anim consectetur dolor mollit.',
56
+ format: 'hms',
57
+ infoMessage: '154h:35m:20s'
58
+ },
59
+ {
60
+ value: 6789,
61
+ text: 'lorem lorem ipsum',
62
+ subtext: 'Minim exercitation ipsum elit cillum magna.',
63
+ format: 'short',
64
+ infoMessage: '6789'
65
+ }
66
+ ]"
67
+ />
41
68
  </div>
42
69
  </template>
43
70
 
@@ -447,11 +447,16 @@ const getOperatorByDataType = (dataType: string) => {
447
447
  return []
448
448
  }
449
449
 
450
- const operators = Object.keys(operatorToDataTypeMap).filter((key) => {
450
+ let operators = Object.keys(operatorToDataTypeMap).filter((key) => {
451
451
  const value = operatorToDataTypeMap[key]
452
452
  return value.length === 0 || value.includes(dataType)
453
453
  })
454
454
 
455
+ if (dataType === 'date' || dataType === 'datetime') {
456
+ const toExclude = ['$in', '$nin']
457
+ operators = operators.filter((s) => !toExclude.includes(s))
458
+ }
459
+
455
460
  return operators
456
461
  }
457
462