@dataloop-ai/components 0.19.274 → 0.19.276

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.
@@ -1,2 +1,3 @@
1
1
  import DlInput from './DlInput.vue'
2
- export { DlInput }
2
+ import DlTextInput from './DlTextInput.vue'
3
+ export { DlInput, DlTextInput }
@@ -105,8 +105,9 @@
105
105
  @escapekey="onEscapeKey"
106
106
  >
107
107
  <div class="dl-smart-search-input__date-picker-wrapper">
108
- <dl-date-picker
109
- :single-selection="true"
108
+ <dl-date-time-card
109
+ :model-value="datePickerSelection"
110
+ show-time
110
111
  @change="onDateSelection"
111
112
  />
112
113
  <div class="dl-smart-search-input__date-picker-buttons">
@@ -138,7 +139,7 @@ import {
138
139
  onBeforeUnmount
139
140
  } from 'vue-demi'
140
141
  import { DlButton } from '../../../../basic'
141
- import { DlDatePicker } from '../../../DlDateTime'
142
+ import { DlDateTimeCard } from '../../../DlDateTime'
142
143
  import { DlMenu, DlIcon, DlLabel } from '../../../../essential'
143
144
  import { isEllipsisActive } from '../../../../../utils/is-ellipsis-active'
144
145
  import { useSizeObserver } from '../../../../../hooks/use-size-observer'
@@ -173,7 +174,8 @@ import {
173
174
  Data,
174
175
  useSuggestions,
175
176
  removeBrackets,
176
- removeLeadingExpression
177
+ removeLeadingExpression,
178
+ dateSuggestionPattern
177
179
  } from '../../../../../hooks/use-suggestions'
178
180
  import { parseSmartQuery, stringifySmartQuery } from '../../../../../utils'
179
181
  import { StateManager, stateManager } from '../../../../../StateManager'
@@ -184,7 +186,7 @@ export default defineComponent({
184
186
  DlButton,
185
187
  SuggestionsDropdown,
186
188
  DlTooltip,
187
- DlDatePicker,
189
+ DlDateTimeCard,
188
190
  DlMenu,
189
191
  DlLabel
190
192
  },
@@ -300,7 +302,7 @@ export default defineComponent({
300
302
  const menuOffset = ref([0, 5])
301
303
  const cancelBlur = ref(0)
302
304
  const expanded = ref(true)
303
- const datePickerSelection = ref(null)
305
+ const datePickerSelection = ref<Date>(null)
304
306
  const showDatePicker = ref(false)
305
307
  const suggestionsDropdown = ref(null)
306
308
  //#endregion
@@ -333,7 +335,7 @@ export default defineComponent({
333
335
  }
334
336
 
335
337
  // to handle date suggestion modal to open automatically.
336
- if (value.includes('(dd/mm/yyyy)')) {
338
+ if (value.includes(dateSuggestionPattern)) {
337
339
  value = value.trimEnd()
338
340
  }
339
341
 
@@ -676,7 +678,7 @@ export default defineComponent({
676
678
  debouncedSetInputValue.value(text)
677
679
  }
678
680
 
679
- const onDateSelection = (value: DateInterval) => {
681
+ const onDateSelection = (value: Date) => {
680
682
  datePickerSelection.value = value
681
683
  }
682
684
 
@@ -1333,10 +1335,6 @@ export default defineComponent({
1333
1335
  max-width: 100%;
1334
1336
  }
1335
1337
 
1336
- &__date-picker-wrapper {
1337
- width: 562px;
1338
- }
1339
-
1340
1338
  &__date-picker-buttons {
1341
1339
  padding: 0 16px 16px;
1342
1340
  text-align: right;
@@ -8,7 +8,8 @@ import {
8
8
  Data,
9
9
  datePattern,
10
10
  datePatternNoBrackets,
11
- removeBrackets
11
+ removeBrackets,
12
+ pureDateSuggestionPattern
12
13
  } from '../../../../../hooks/use-suggestions'
13
14
  import moment from 'moment'
14
15
  import { cloneDeep, get } from 'lodash'
@@ -37,8 +38,8 @@ export const isEndingWithDateIntervalPattern = (str: string) => {
37
38
  return isEndOfString(str, datePattern, { checkWhiteSpace: true })
38
39
  }
39
40
 
40
- export const replaceDateInterval = (str: string, date: DateInterval) => {
41
- const newStr = `${formatDate(date.from)}`
41
+ export const replaceDateInterval = (str: string, date: Date) => {
42
+ const newStr = `${formatDate(date)}`
42
43
  const replaced = replaceFirstOrLastOccurrence(
43
44
  str,
44
45
  newStr,
@@ -52,7 +53,7 @@ export const removeDateInterval = (str: string) => {
52
53
  }
53
54
 
54
55
  const formatDate = (date: Date | string | number): string => {
55
- return moment(date).format('DD/MM/YYYY')
56
+ return moment(date).format(pureDateSuggestionPattern)
56
57
  }
57
58
 
58
59
  const replaceFirstOrLastOccurrence = (
@@ -67,7 +68,7 @@ const replaceFirstOrLastOccurrence = (
67
68
  let match
68
69
 
69
70
  while ((match = regex.exec(string))) {
70
- if (match[0] === 'dd/mm/yyyy' && !firstMatch) {
71
+ if (match[0] === pureDateSuggestionPattern && !firstMatch) {
71
72
  firstMatch = match
72
73
  }
73
74
  lastMatch = match
@@ -120,7 +121,7 @@ export function replaceStringifiedDatesWithJSDates(str: string) {
120
121
 
121
122
  export function formatToNumericDate(str: string) {
122
123
  const dateString = str.replace(/['"\(\)]+/g, '')
123
- const newDate = moment(dateString, 'DD/MM/YYYY')
124
+ const newDate = moment(dateString, pureDateSuggestionPattern)
124
125
  const ms = newDate.toDate().getTime()
125
126
  return ms
126
127
  }
@@ -8,7 +8,12 @@
8
8
  :end-icon="endIcon(step)"
9
9
  :start-icon="
10
10
  step.icon
11
- ? { icon: step.icon, color: 'secondary' }
11
+ ? {
12
+ icon: step.icon,
13
+ color: step.active
14
+ ? 'secondary'
15
+ : 'dl-color-lighter'
16
+ }
12
17
  : undefined
13
18
  "
14
19
  :clickable="!disabled"
@@ -0,0 +1,183 @@
1
+ <template>
2
+ <div>
3
+ <dl-input
4
+ v-model="textInputValue"
5
+ style="width: 920px"
6
+ placeholder="Select option"
7
+ size="l"
8
+ margin="20px"
9
+ title="Input Title"
10
+ required
11
+ tooltip="Quis fugiat et non eu proident sit et amet."
12
+ top-message="Pariatur consequat non sit aliqua labore ad reprehenderit deserunt ullamco incididunt non irure laborum deserunt."
13
+ info-message="Ipsum amet quis velit amet. Anim consectetur nostrud sunt eu non non consequat sint eu amet."
14
+ :auto-suggest-items="[
15
+ 'foo',
16
+ 'bar',
17
+ 'foobar',
18
+ 'barfoo',
19
+ 'foo bar foobarv'
20
+ ]"
21
+ show-counter
22
+ :max-length="20"
23
+ />
24
+ <dl-input
25
+ v-model="saveInputValue"
26
+ style="width: 220px"
27
+ placeholder="Input with icon"
28
+ size="l"
29
+ has-append
30
+ >
31
+ <template #append>
32
+ <dl-icon icon="icon-dl-save" size="12px" />
33
+ </template>
34
+ </dl-input>
35
+ <dl-input
36
+ v-model="passFieldValue"
37
+ title="Password"
38
+ style="width: 220px"
39
+ placeholder="Select option"
40
+ size="m"
41
+ type="password"
42
+ error
43
+ error-message="The password entered is incorrect."
44
+ info-message="This won't show, error is true"
45
+ />
46
+ <dl-input
47
+ v-model="warningFieldValue"
48
+ title="Warning Example"
49
+ style="width: 220px"
50
+ placeholder="Select option"
51
+ size="m"
52
+ warning
53
+ warning-message="Something isn't right."
54
+ info-message="This won't show, error is true"
55
+ optional
56
+ />
57
+
58
+ <p>size S with long text</p>
59
+ <dl-input
60
+ v-model="warningFieldValue"
61
+ title="Warning Example"
62
+ style="width: 220px"
63
+ placeholder="Select option"
64
+ size="s"
65
+ warning
66
+ warning-message="Something isn't right."
67
+ info-message="This won't show, error is true"
68
+ optional
69
+ />
70
+ <dl-input
71
+ v-model="errorFieldValue"
72
+ title="Error Example"
73
+ style="width: 220px"
74
+ placeholder="Select option"
75
+ size="m"
76
+ error
77
+ error-message="Error message is the strongest."
78
+ warning
79
+ warning-message="This won't show, error is true"
80
+ info-message="This won't show, error is true"
81
+ />
82
+ <dl-input
83
+ style="width: 220px"
84
+ placeholder="Select option"
85
+ title="Min"
86
+ required
87
+ size="s"
88
+ error
89
+ error-message="Error message is the strongest."
90
+ />
91
+ <dl-input
92
+ style="width: 440px"
93
+ placeholder="Select option"
94
+ title="Min"
95
+ size="s"
96
+ error
97
+ error-message="Error message is the strongest."
98
+ />
99
+ <p>input in a row with button</p>
100
+ <div class="row" style="align-items: center">
101
+ <dl-input
102
+ class="input-parts"
103
+ style="width: 440px"
104
+ placeholder="Select option"
105
+ title="Min"
106
+ dense
107
+ size="s"
108
+ />
109
+ <dl-button dense flat icon="icon-dl-add" size="m" />
110
+ </div>
111
+ <dl-input
112
+ title="Readonly"
113
+ style="width: 220px"
114
+ placeholder="Readonly state"
115
+ size="m"
116
+ readonly
117
+ />
118
+
119
+ <p>input in a limited size and action slot size m</p>
120
+ <div style="align-items: center; width: 250px; overflow: hidden">
121
+ <dl-input class="input-parts" placeholder="Select option">
122
+ <template #action>
123
+ <dl-button dense flat icon="icon-dl-add" size="m" />
124
+ </template>
125
+ </dl-input>
126
+ </div>
127
+
128
+ <p>input with tooltip and no title</p>
129
+ <div>
130
+ <dl-input
131
+ class="input-parts"
132
+ placeholder="Select option"
133
+ tooltip="test me tooltip"
134
+ >
135
+ <template #action>
136
+ <dl-button dense flat icon="icon-dl-add" size="m" />
137
+ </template>
138
+ </dl-input>
139
+ </div>
140
+
141
+ <p>input with tooltip and no title size small</p>
142
+ <div>
143
+ <dl-input
144
+ class="input-parts"
145
+ placeholder="Select option"
146
+ tooltip="test me tooltip"
147
+ size="small"
148
+ >
149
+ <template #action>
150
+ <dl-button dense flat icon="icon-dl-add" size="m" />
151
+ </template>
152
+ </dl-input>
153
+ </div>
154
+ </div>
155
+ </template>
156
+ <script lang="ts">
157
+ import { defineComponent, ref } from 'vue-demi'
158
+ import { DlInput, DlIcon, DlButton } from '../components'
159
+ export default defineComponent({
160
+ name: 'DlInputDemo',
161
+ components: {
162
+ DlInput,
163
+ DlIcon,
164
+ DlButton
165
+ },
166
+ setup() {
167
+ const textInputValue = ref<string>('')
168
+ const passFieldValue = ref<string>('')
169
+ const warningFieldValue = ref<string>('')
170
+ const errorFieldValue = ref<string>('')
171
+ const saveInputValue = ref<string>('')
172
+
173
+ return {
174
+ textInputValue,
175
+ passFieldValue,
176
+ warningFieldValue,
177
+ errorFieldValue,
178
+ saveInputValue
179
+ }
180
+ }
181
+ })
182
+ </script>
183
+ <style></style>
@@ -70,6 +70,7 @@ import { DlCodeEditorDemo } from './DlCodeEditor'
70
70
  import DlLabelPickerDemo from './DlLabelPickerDemo.vue'
71
71
  import DlInfiniteScrollDemo from './DlInfiniteScrollDemo.vue'
72
72
  import DlMarkdownDemo from './DlMarkdownDemo.vue'
73
+ import DlTextInputDemo from './DlTextInputDemo.vue'
73
74
 
74
75
  export default {
75
76
  AvatarDemo,
@@ -140,5 +141,6 @@ export default {
140
141
  DlLayoutDemo,
141
142
  DlLabelPickerDemo,
142
143
  DlInfiniteScrollDemo,
143
- DlMarkdownDemo
144
+ DlMarkdownDemo,
145
+ DlTextInputDemo
144
146
  }
@@ -79,16 +79,17 @@ type Expression = {
79
79
  }
80
80
 
81
81
  const space = ' '
82
- const dateSuggestionPattern = '(dd/mm/yyyy)'
82
+ export const pureDateSuggestionPattern = 'DD/MM/YYYY HH:mm:ss'
83
+ export const dateSuggestionPattern = `(${pureDateSuggestionPattern})`
83
84
 
84
85
  let localSuggestions: Suggestion[] = []
85
86
 
86
87
  export const datePattern = new RegExp(
87
- /([\(']?\d{2}\/\d{2}\/\d{4}[\)']?\s?|\s?\(dd\/mm\/yyyy\)\s?)/,
88
+ /[\(']?(\d{2}\/\d{2}\/\d{4}[\)']?\s?|\s?DD\/MM\/YYYY)\s?(\d{2}:\d{2}:\d{2}|\s?HH:mm:ss)[\)']?/,
88
89
  'gi'
89
90
  )
90
91
  export const datePatternNoBrackets =
91
- /(\d{2}\/\d{2}\/\d{4}\s?|\s?dd\/mm\/yyyy\s?)/
92
+ /(\d{2}\/\d{2}\/\d{4}[\)']?\s?|\s?DD\/MM\/YYYY)\s?(\d{2}:\d{2}:\d{2}|\s?HH:mm:ss)/
92
93
 
93
94
  const existsValuePlaceholder = 'existsValuePlaceholder'
94
95
 
@@ -261,32 +261,42 @@ export const stringifySmartQuery = (query: { [key: string]: any }): string => {
261
261
  [key: string]: string | number | string[] | number[]
262
262
  }
263
263
  )[operator]
264
+
265
+ let stringValue = ''
266
+ if (
267
+ ['$eq', '$ne', '$gt', '$gte', '$lt', '$lte'].includes(
268
+ operator
269
+ )
270
+ ) {
271
+ if (isNumber(operatorValue)) {
272
+ stringValue = `${operatorValue}`
273
+ } else if (isBoolean(operatorValue)) {
274
+ stringValue = `${operatorValue}`
275
+ } else if (isDatePattern(`${operatorValue}`)) {
276
+ stringValue = `(${operatorValue})`
277
+ } else {
278
+ stringValue = `'${operatorValue}'`
279
+ }
280
+ }
281
+
264
282
  switch (operator) {
265
283
  case '$eq':
266
- result += `${key} = ${
267
- isString(operatorValue)
268
- ? `'${operatorValue}'`
269
- : operatorValue
270
- }`
284
+ result += `${key} = ${stringValue}`
271
285
  break
272
286
  case '$ne':
273
- result += `${key} != ${
274
- isString(operatorValue)
275
- ? `'${operatorValue}'`
276
- : operatorValue
277
- }`
287
+ result += `${key} != ${stringValue}`
278
288
  break
279
289
  case '$gt':
280
- result += `${key} > ${operatorValue}`
290
+ result += `${key} > ${stringValue}`
281
291
  break
282
292
  case '$gte':
283
- result += `${key} >= ${operatorValue}`
293
+ result += `${key} >= ${stringValue}`
284
294
  break
285
295
  case '$lt':
286
- result += `${key} < ${operatorValue}`
296
+ result += `${key} < ${stringValue}`
287
297
  break
288
298
  case '$lte':
289
- result += `${key} <= ${operatorValue}`
299
+ result += `${key} <= ${stringValue}`
290
300
  break
291
301
  case '$exists':
292
302
  result += `${key} ${