@dataloop-ai/components 0.19.128 → 0.19.129

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.19.128",
3
+ "version": "0.19.129",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./models": "./models.ts",
@@ -84,6 +84,18 @@
84
84
  :single-selection="true"
85
85
  @change="onDateSelection"
86
86
  />
87
+ <div class="dl-smart-search-input__date-picker-buttons">
88
+ <dl-button
89
+ label="Cancel"
90
+ outlined
91
+ @mousedown="onDateSelectionCancel"
92
+ />
93
+ <dl-button
94
+ label="Apply"
95
+ :disabled="!datePickerSelection"
96
+ @mousedown="onDateSelectionApply"
97
+ />
98
+ </div>
87
99
  </div>
88
100
  </dl-menu>
89
101
  </div>
@@ -118,6 +130,7 @@ import { DateInterval } from '../../../DlDateTime/types'
118
130
  import {
119
131
  isEndingWithDateIntervalPattern,
120
132
  replaceDateInterval,
133
+ removeDateInterval,
121
134
  updateEditor,
122
135
  isEligibleToChange,
123
136
  createColorSchema,
@@ -538,8 +551,27 @@ export default defineComponent({
538
551
 
539
552
  const onDateSelection = (value: DateInterval) => {
540
553
  datePickerSelection.value = value
541
- searchQuery.value = replaceDateInterval(searchQuery.value, value)
542
- input.value.innerHTML = searchQuery.value
554
+ }
555
+
556
+ const onDateSelectionCancel = () => {
557
+ searchQuery.value = removeDateInterval(searchQuery.value)
558
+ showDatePicker.value = false
559
+ showSuggestions.value = true
560
+ datePickerSelection.value = null
561
+ setInputValue(searchQuery.value + ' ', { noEmit: true })
562
+ setCaretAtTheEnd(input.value)
563
+ }
564
+
565
+ const onDateSelectionApply = () => {
566
+ searchQuery.value = replaceDateInterval(
567
+ searchQuery.value,
568
+ datePickerSelection.value
569
+ )
570
+ showDatePicker.value = false
571
+ showSuggestions.value = true
572
+ datePickerSelection.value = null
573
+ setInputValue(searchQuery.value + ' ', { noEmit: true })
574
+ setCaretAtTheEnd(input.value)
543
575
  }
544
576
 
545
577
  const readModelValue = (val: { [key: string]: any }) => {
@@ -628,15 +660,6 @@ export default defineComponent({
628
660
  return
629
661
  }
630
662
 
631
- if (showDatePicker.value) {
632
- showDatePicker.value = false
633
- showSuggestions.value = true
634
- datePickerSelection.value = null
635
- setInputValue(searchQuery.value + ' ', { noEmit: true })
636
- setCaretAtTheEnd(input.value)
637
- return
638
- }
639
-
640
663
  if (showSuggestions.value) {
641
664
  showSuggestions.value = false
642
665
  return
@@ -897,6 +920,8 @@ export default defineComponent({
897
920
  onKeyPress,
898
921
  onInput,
899
922
  onDateSelection,
923
+ onDateSelectionCancel,
924
+ onDateSelectionApply,
900
925
  computedStatus,
901
926
  setInputFromSuggestion,
902
927
  inputPlaceholder,
@@ -1129,6 +1154,14 @@ export default defineComponent({
1129
1154
  &__date-picker-wrapper {
1130
1155
  width: 562px;
1131
1156
  }
1157
+
1158
+ &__date-picker-buttons {
1159
+ padding: 0 16px 16px;
1160
+ text-align: right;
1161
+ > * {
1162
+ margin-left: 16px;
1163
+ }
1164
+ }
1132
1165
  }
1133
1166
  .focus {
1134
1167
  word-break: break-all;
@@ -47,6 +47,10 @@ export const replaceDateInterval = (str: string, date: DateInterval) => {
47
47
  return replaced
48
48
  }
49
49
 
50
+ export const removeDateInterval = (str: string) => {
51
+ return replaceFirstOrLastOccurrence(str, '', datePattern)
52
+ }
53
+
50
54
  const formatDate = (date: Date | string | number): string => {
51
55
  return moment(date).format('DD/MM/YYYY')
52
56
  }