@dataloop-ai/components 0.13.0

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 (294) hide show
  1. package/.eslintrc.js +154 -0
  2. package/.prettierrc.json +7 -0
  3. package/Dockerfile +12 -0
  4. package/LICENSE +201 -0
  5. package/README.md +43 -0
  6. package/favicon.ico +0 -0
  7. package/index.html +13 -0
  8. package/index.ts +1 -0
  9. package/jest.config.js +16 -0
  10. package/jest.setup.js +59 -0
  11. package/models.ts +1 -0
  12. package/package.json +109 -0
  13. package/src/App.vue +201 -0
  14. package/src/assets/globals.scss +253 -0
  15. package/src/assets/globalsKeys.ts +28 -0
  16. package/src/components/DlAccordion/AccordionHeader.vue +148 -0
  17. package/src/components/DlAccordion/DlAccordion.vue +108 -0
  18. package/src/components/DlAccordion/index.ts +2 -0
  19. package/src/components/DlAlert.vue +227 -0
  20. package/src/components/DlAvatar.vue +99 -0
  21. package/src/components/DlBadge.vue +127 -0
  22. package/src/components/DlButton/DlButton.vue +370 -0
  23. package/src/components/DlButton/index.ts +4 -0
  24. package/src/components/DlButton/utils.ts +169 -0
  25. package/src/components/DlButtonGroup.vue +122 -0
  26. package/src/components/DlCheckbox.vue +298 -0
  27. package/src/components/DlChip/DlChip.vue +244 -0
  28. package/src/components/DlChip/index.ts +4 -0
  29. package/src/components/DlChip/utils.ts +100 -0
  30. package/src/components/DlColorPicker/DlAlpha.vue +142 -0
  31. package/src/components/DlColorPicker/DlBox.vue +75 -0
  32. package/src/components/DlColorPicker/DlColorPicker.vue +306 -0
  33. package/src/components/DlColorPicker/DlColors.vue +139 -0
  34. package/src/components/DlColorPicker/DlHue.vue +135 -0
  35. package/src/components/DlColorPicker/DlPreview.vue +61 -0
  36. package/src/components/DlColorPicker/DlSaturation.vue +152 -0
  37. package/src/components/DlColorPicker/constants.ts +16 -0
  38. package/src/components/DlColorPicker/index.ts +20 -0
  39. package/src/components/DlColorPicker/types.ts +11 -0
  40. package/src/components/DlColorPicker/utils.ts +128 -0
  41. package/src/components/DlCounters.vue +173 -0
  42. package/src/components/DlDatePicker/DlCalendar.vue +332 -0
  43. package/src/components/DlDatePicker/DlDatePicker.vue +315 -0
  44. package/src/components/DlDatePicker/DlMonthCalendar.vue +282 -0
  45. package/src/components/DlDatePicker/classes/Calendar.ts +110 -0
  46. package/src/components/DlDatePicker/classes/CalendarDate.ts +12 -0
  47. package/src/components/DlDatePicker/classes/CustomDate.ts +218 -0
  48. package/src/components/DlDatePicker/index.ts +3 -0
  49. package/src/components/DlDatePicker/isInRange.ts +44 -0
  50. package/src/components/DlDatePicker/types.ts +4 -0
  51. package/src/components/DlDatePicker/utils.ts +39 -0
  52. package/src/components/DlDateTimeRange/DlCardSidebar.vue +109 -0
  53. package/src/components/DlDateTimeRange/DlDateInput.vue +105 -0
  54. package/src/components/DlDateTimeRange/DlDateTimeRange.vue +468 -0
  55. package/src/components/DlDateTimeRange/index.ts +3 -0
  56. package/src/components/DlDateTimeRange/types.ts +42 -0
  57. package/src/components/DlDialogBox/DlDialogBox.vue +196 -0
  58. package/src/components/DlDialogBox/DlDialogBoxFooter.vue +22 -0
  59. package/src/components/DlDialogBox/DlDialogBoxHeader.vue +75 -0
  60. package/src/components/DlDialogBox/index.ts +5 -0
  61. package/src/components/DlDropdownButton.vue +463 -0
  62. package/src/components/DlIcon.vue +147 -0
  63. package/src/components/DlInfoErrorMessage.vue +91 -0
  64. package/src/components/DlItem/DlItem.vue +35 -0
  65. package/src/components/DlItem/index.ts +2 -0
  66. package/src/components/DlItemSection.vue +88 -0
  67. package/src/components/DlLink/DlLink.vue +76 -0
  68. package/src/components/DlLink/index.ts +4 -0
  69. package/src/components/DlLink/utils.ts +4 -0
  70. package/src/components/DlList.vue +61 -0
  71. package/src/components/DlListItem/DlListItem.vue +205 -0
  72. package/src/components/DlListItem/index.ts +3 -0
  73. package/src/components/DlListItem/utils.ts +14 -0
  74. package/src/components/DlMenu/DlMenu.vue +438 -0
  75. package/src/components/DlMenu/index.ts +3 -0
  76. package/src/components/DlMenu/utils.ts +138 -0
  77. package/src/components/DlOptionGroup/DlOptionGroup.vue +201 -0
  78. package/src/components/DlOptionGroup/MenuItemWrapper.vue +48 -0
  79. package/src/components/DlOptionGroup/OptionGroup.types.ts +36 -0
  80. package/src/components/DlOptionGroup/SimpleWrapper.vue +28 -0
  81. package/src/components/DlOptionGroup/index.ts +4 -0
  82. package/src/components/DlOptionGroup/utils.ts +40 -0
  83. package/src/components/DlPagination/DlPagination.vue +184 -0
  84. package/src/components/DlPagination/PageNavigation.vue +350 -0
  85. package/src/components/DlPagination/PaginationLegend.vue +41 -0
  86. package/src/components/DlPagination/QuickNavigation.vue +146 -0
  87. package/src/components/DlPagination/RowsSelector.vue +74 -0
  88. package/src/components/DlPagination/index.ts +3 -0
  89. package/src/components/DlPanelContainer/DlPanel.vue +213 -0
  90. package/src/components/DlPanelContainer/DlPanelContainer.vue +527 -0
  91. package/src/components/DlPanelContainer/index.ts +4 -0
  92. package/src/components/DlPopup/DlPopup.vue +478 -0
  93. package/src/components/DlPopup/DraggableUpper.vue +64 -0
  94. package/src/components/DlPopup/PopupHeader.vue +129 -0
  95. package/src/components/DlPopup/index.ts +1 -0
  96. package/src/components/DlProgressBar.vue +159 -0
  97. package/src/components/DlProgressChart.vue +299 -0
  98. package/src/components/DlRadio.vue +218 -0
  99. package/src/components/DlRange/DlRange.vue +439 -0
  100. package/src/components/DlRange/utils.ts +209 -0
  101. package/src/components/DlSearch.vue +155 -0
  102. package/src/components/DlSelect/DlSelect.vue +992 -0
  103. package/src/components/DlSelect/SelectOption.vue +261 -0
  104. package/src/components/DlSelect/index.ts +4 -0
  105. package/src/components/DlSelect/utils.ts +43 -0
  106. package/src/components/DlSkeleton.vue +72 -0
  107. package/src/components/DlSlider/DlSlider.vue +243 -0
  108. package/src/components/DlSlider/components/DlSliderBase.vue +380 -0
  109. package/src/components/DlSlider/components/DlSliderInput.vue +123 -0
  110. package/src/components/DlSlider/components/index.ts +4 -0
  111. package/src/components/DlSlider/index.ts +3 -0
  112. package/src/components/DlSlider/sliderStyles.scss +109 -0
  113. package/src/components/DlSlider/useSlider.ts +277 -0
  114. package/src/components/DlSlider/utils.ts +7 -0
  115. package/src/components/DlSmartSearch/DlJsonEditor.vue +309 -0
  116. package/src/components/DlSmartSearch/DlSmartSearch.vue +333 -0
  117. package/src/components/DlSmartSearch/DlSmartSearchInput.vue +741 -0
  118. package/src/components/DlSmartSearch/DlSuggestionsDropdown.vue +73 -0
  119. package/src/components/DlSmartSearch/highlightSyntax.ts +169 -0
  120. package/src/components/DlSmartSearch/index.ts +4 -0
  121. package/src/components/DlSmartSearch/types.ts +36 -0
  122. package/src/components/DlSmartSearch/utils.ts +45 -0
  123. package/src/components/DlStepper/DlStepper.vue +196 -0
  124. package/src/components/DlStepper/DlStepperContainer.vue +55 -0
  125. package/src/components/DlStepper/DlStepperContent.vue +101 -0
  126. package/src/components/DlStepper/DlStepperFooter.vue +133 -0
  127. package/src/components/DlStepper/DlStepperHeader.vue +49 -0
  128. package/src/components/DlStepper/DlStepperSidebar.vue +167 -0
  129. package/src/components/DlStepper/Step.ts +101 -0
  130. package/src/components/DlStepper/Stepper.ts +107 -0
  131. package/src/components/DlStepper/index.ts +7 -0
  132. package/src/components/DlStepper/interfaces.ts +11 -0
  133. package/src/components/DlSwitch.vue +280 -0
  134. package/src/components/DlTabPanels/DlTabPanel.vue +22 -0
  135. package/src/components/DlTabPanels/DlTabPanels.vue +41 -0
  136. package/src/components/DlTabPanels/index.ts +4 -0
  137. package/src/components/DlTabPanels/utils.ts +19 -0
  138. package/src/components/DlTable/DlTable.vue +1264 -0
  139. package/src/components/DlTable/DlTd.vue +109 -0
  140. package/src/components/DlTable/DlTh.vue +126 -0
  141. package/src/components/DlTable/DlTr.vue +44 -0
  142. package/src/components/DlTable/ResizableManager.ts +233 -0
  143. package/src/components/DlTable/dl-table-styles.scss +466 -0
  144. package/src/components/DlTable/hooks/tableActions.ts +64 -0
  145. package/src/components/DlTable/hooks/tableColumnSelection.ts +112 -0
  146. package/src/components/DlTable/hooks/tableFilter.ts +42 -0
  147. package/src/components/DlTable/hooks/tablePagination.ts +197 -0
  148. package/src/components/DlTable/hooks/tableRowExpand.ts +55 -0
  149. package/src/components/DlTable/hooks/tableRowSelection.ts +106 -0
  150. package/src/components/DlTable/hooks/tableSort.ts +125 -0
  151. package/src/components/DlTable/index.ts +6 -0
  152. package/src/components/DlTable/types.ts +96 -0
  153. package/src/components/DlTabs/DlTab.vue +146 -0
  154. package/src/components/DlTabs/DlTabs.vue +192 -0
  155. package/src/components/DlTabs/TabsWrapper.vue +104 -0
  156. package/src/components/DlTabs/index.ts +4 -0
  157. package/src/components/DlTabs/types.ts +8 -0
  158. package/src/components/DlTextArea.vue +151 -0
  159. package/src/components/DlTextHolder.vue +65 -0
  160. package/src/components/DlTextInput.vue +753 -0
  161. package/src/components/DlThemeProvider.vue +41 -0
  162. package/src/components/DlTimePicker/DlTimeCounter.vue +81 -0
  163. package/src/components/DlTimePicker/DlTimePicker.vue +151 -0
  164. package/src/components/DlTimePicker/DlTimePickerInput.vue +311 -0
  165. package/src/components/DlTimePicker/index.ts +3 -0
  166. package/src/components/DlTimePicker/types.ts +4 -0
  167. package/src/components/DlTooltip.vue +456 -0
  168. package/src/components/DlTrend.vue +97 -0
  169. package/src/components/DlTypography.vue +87 -0
  170. package/src/components/DlVirtualScroll/DlVirtualScroll.vue +290 -0
  171. package/src/components/DlVirtualScroll/index.ts +3 -0
  172. package/src/components/DlVirtualScroll/useVirtualScroll.ts +833 -0
  173. package/src/components/DlWidget/DlWidget.vue +50 -0
  174. package/src/components/DlWidget/DlWidgetGrid.vue +360 -0
  175. package/src/components/DlWidget/index.ts +4 -0
  176. package/src/components/DlWidget/types.ts +6 -0
  177. package/src/components/DlWidget/utils.ts +30 -0
  178. package/src/components/index.ts +118 -0
  179. package/src/demo/DlAccordionDemo.vue +60 -0
  180. package/src/demo/DlAlertDemo.vue +54 -0
  181. package/src/demo/DlAvatarDemo.vue +43 -0
  182. package/src/demo/DlBadgeDemo.vue +65 -0
  183. package/src/demo/DlButtonDemo.vue +266 -0
  184. package/src/demo/DlCheckboxDemo.vue +50 -0
  185. package/src/demo/DlChipDemo.vue +181 -0
  186. package/src/demo/DlColorPickerDemo.vue +43 -0
  187. package/src/demo/DlCounterDemo.vue +53 -0
  188. package/src/demo/DlDateTimeRangeDemo.vue +217 -0
  189. package/src/demo/DlDialogBoxDemo.vue +175 -0
  190. package/src/demo/DlDropdownButtonDemo.vue +260 -0
  191. package/src/demo/DlIconDemo.vue +47 -0
  192. package/src/demo/DlLinkDemo.vue +23 -0
  193. package/src/demo/DlListDemo.vue +177 -0
  194. package/src/demo/DlMenuDemo.vue +524 -0
  195. package/src/demo/DlOptionGroupDemo.vue +79 -0
  196. package/src/demo/DlPaginationDemo.vue +44 -0
  197. package/src/demo/DlPanelContainerDemo.vue +221 -0
  198. package/src/demo/DlPopupDemo.vue +58 -0
  199. package/src/demo/DlProgressBarDemo.vue +22 -0
  200. package/src/demo/DlProgressChartDemo.vue +71 -0
  201. package/src/demo/DlRadioDemo.vue +35 -0
  202. package/src/demo/DlRangeDemo.vue +44 -0
  203. package/src/demo/DlSearchDemo.vue +27 -0
  204. package/src/demo/DlSelectDemo.vue +355 -0
  205. package/src/demo/DlSkeletonDemo.vue +20 -0
  206. package/src/demo/DlSliderDemo.vue +47 -0
  207. package/src/demo/DlStepperDemo/CenteredStepperInDialogBox.vue +260 -0
  208. package/src/demo/DlStepperDemo/SimpleStepper.vue +202 -0
  209. package/src/demo/DlStepperDemo/StepperInDialogBox.vue +261 -0
  210. package/src/demo/DlStepperDemo/index.ts +5 -0
  211. package/src/demo/DlStepperDemo/steps/AssignmentsStep.vue +97 -0
  212. package/src/demo/DlStepperDemo/steps/DataStep.vue +158 -0
  213. package/src/demo/DlStepperDemo/steps/GeneralStep.vue +106 -0
  214. package/src/demo/DlStepperDemo/steps/InstructionStep.vue +176 -0
  215. package/src/demo/DlStepperDemo/steps/QualityStep.vue +65 -0
  216. package/src/demo/DlSwitchDemo.vue +49 -0
  217. package/src/demo/DlTableDemo.vue +475 -0
  218. package/src/demo/DlTabsDemo.vue +67 -0
  219. package/src/demo/DlTdDemo.vue +19 -0
  220. package/src/demo/DlTextAreaDemo.vue +37 -0
  221. package/src/demo/DlTextHolderDemo.vue +42 -0
  222. package/src/demo/DlTextInputDemo.vue +89 -0
  223. package/src/demo/DlThDemo.vue +32 -0
  224. package/src/demo/DlTooltipDemo.vue +60 -0
  225. package/src/demo/DlTrDemo.vue +18 -0
  226. package/src/demo/DlTrendDemo.vue +25 -0
  227. package/src/demo/DlTypographyDemo.vue +93 -0
  228. package/src/demo/DlWidgetDemo.vue +157 -0
  229. package/src/demo/SmartSearchDemo/DlSmartSearchDemo.vue +202 -0
  230. package/src/demo/SmartSearchDemo/schema.ts +44 -0
  231. package/src/demo/index.ts +141 -0
  232. package/src/directives/TouchPan.ts +525 -0
  233. package/src/env.d.ts +8 -0
  234. package/src/hooks/use-anchor.ts +223 -0
  235. package/src/hooks/use-model-toggle.ts +181 -0
  236. package/src/hooks/use-portal.ts +104 -0
  237. package/src/hooks/use-scroll-target.ts +53 -0
  238. package/src/hooks/use-size-observer.ts +24 -0
  239. package/src/hooks/use-suggestions.ts +355 -0
  240. package/src/hooks/use-tick.ts +32 -0
  241. package/src/hooks/use-timeout.ts +20 -0
  242. package/src/hooks/use-transition.ts +32 -0
  243. package/src/hooks/use-window-size.ts +25 -0
  244. package/src/hooks/useForm.ts +12 -0
  245. package/src/index.ts +7 -0
  246. package/src/main.ts +4 -0
  247. package/src/models.ts +4 -0
  248. package/src/types.ts +6 -0
  249. package/src/utils/calcs.ts +18 -0
  250. package/src/utils/click-outside.ts +108 -0
  251. package/src/utils/component-name-parser.ts +1 -0
  252. package/src/utils/css-color-names.ts +150 -0
  253. package/src/utils/dom.ts +55 -0
  254. package/src/utils/draggable-table.ts +416 -0
  255. package/src/utils/escape-key.ts +54 -0
  256. package/src/utils/events.ts +67 -0
  257. package/src/utils/focus-manager.ts +33 -0
  258. package/src/utils/focusout.ts +29 -0
  259. package/src/utils/format.ts +3 -0
  260. package/src/utils/getColor.ts +17 -0
  261. package/src/utils/getLighterGradient.ts +36 -0
  262. package/src/utils/getRootStyles.ts +52 -0
  263. package/src/utils/global-config.ts +6 -0
  264. package/src/utils/global-nodes.ts +42 -0
  265. package/src/utils/includes.ts +3 -0
  266. package/src/utils/index.ts +29 -0
  267. package/src/utils/inject-object-prop.ts +21 -0
  268. package/src/utils/input-sizes.ts +7 -0
  269. package/src/utils/is-ellipsis-active.ts +3 -0
  270. package/src/utils/is-in-viewport.ts +13 -0
  271. package/src/utils/is.ts +15 -0
  272. package/src/utils/key-composition.ts +17 -0
  273. package/src/utils/keyCodes.ts +12 -0
  274. package/src/utils/logger/ConsoleLogger.ts +65 -0
  275. package/src/utils/logger/ILogger.ts +8 -0
  276. package/src/utils/logger/index.ts +8 -0
  277. package/src/utils/nav-keys-constants.ts +1 -0
  278. package/src/utils/portal.ts +55 -0
  279. package/src/utils/position-engine.ts +381 -0
  280. package/src/utils/render.ts +36 -0
  281. package/src/utils/ripple.ts +7 -0
  282. package/src/utils/scroll.ts +73 -0
  283. package/src/utils/selection.ts +15 -0
  284. package/src/utils/sort.ts +7 -0
  285. package/src/utils/splitByQuotes.ts +32 -0
  286. package/src/utils/string.ts +6 -0
  287. package/src/utils/teleport.ts +14 -0
  288. package/src/utils/theme.ts +2 -0
  289. package/src/utils/vm.ts +16 -0
  290. package/storybook.js +8 -0
  291. package/tsconfig.json +44 -0
  292. package/tsconfig.node.json +8 -0
  293. package/types.ts +1 -0
  294. package/vite.config.ts +13 -0
@@ -0,0 +1,753 @@
1
+ <template>
2
+ <div
3
+ :id="uuid"
4
+ :class="rootContainerClasses"
5
+ >
6
+ <div
7
+ v-show="!!title.length || !!tooltip.length"
8
+ :class="{
9
+ 'dl-text-input__title-container': true,
10
+ 'dl-text-input__title-container--s': isSmall
11
+ }"
12
+ >
13
+ <label
14
+ v-show="!!title.length"
15
+ class="dl-text-input__title"
16
+ >
17
+ {{ title
18
+ }}<span
19
+ v-show="required"
20
+ :class="asteriskClasses"
21
+ > *</span>
22
+ {{ !required && optional ? ' (Optional)' : null }}
23
+ </label>
24
+ <span v-show="!!tooltip.length">
25
+ <dl-icon
26
+ class="dl-text-input__tooltip-icon"
27
+ icon="icon-dl-info"
28
+ size="12px"
29
+ />
30
+ <dl-tooltip>
31
+ {{ tooltip }}
32
+ </dl-tooltip>
33
+ </span>
34
+ </div>
35
+ <div
36
+ v-show="!!topMessage.length && !isSmall"
37
+ class="dl-text-input__top-message-container"
38
+ >
39
+ <dl-info-error-message
40
+ v-show="!!topMessage.length"
41
+ position="above"
42
+ :value="topMessage"
43
+ />
44
+ </div>
45
+ <div class="dl-text-input__input-wrapper">
46
+ <input
47
+ ref="input"
48
+ :value="modelValue"
49
+ :class="inputClasses"
50
+ :placeholder="placeholder"
51
+ :maxlength="maxLength"
52
+ :type="showPass ? 'text' : type"
53
+ :disabled="disabled"
54
+ @input="onChange"
55
+ @focus="onFocus"
56
+ @blur="debouncedBlur()"
57
+ @keyup.enter="onKeyPress"
58
+ >
59
+ <div
60
+ v-show="hasPrepend"
61
+ :class="[
62
+ ...adornmentClasses,
63
+ 'dl-text-input__adornment-container--pos-left'
64
+ ]"
65
+ >
66
+ <slot name="prepend" />
67
+ </div>
68
+ <div
69
+ v-show="hasAppend"
70
+ :class="[
71
+ ...adornmentClasses,
72
+ 'dl-text-input__adornment-container--pos-right'
73
+ ]"
74
+ >
75
+ <slot name="append" />
76
+ <span v-show="showClearBtn">
77
+ <dl-button
78
+ ref="input-clear-button"
79
+ icon="icon-dl-close"
80
+ size="s"
81
+ text-color="dl-color-darker"
82
+ flat
83
+ fluid
84
+ @click="onClear"
85
+ />
86
+ <dl-tooltip v-if="clearButtonTooltip">
87
+ Remove text
88
+ </dl-tooltip>
89
+ </span>
90
+ <span v-show="showShowPassBtn">
91
+ <dl-button
92
+ ref="input-show-pass-button"
93
+ :icon="passShowIcon"
94
+ size="s"
95
+ text-color="dl-color-darker"
96
+ flat
97
+ fluid
98
+ @click="onPassShowClick"
99
+ />
100
+ <dl-tooltip>
101
+ {{ showPass ? 'Hide' : 'Show' }}
102
+ </dl-tooltip>
103
+ </span>
104
+ </div>
105
+ <dl-menu
106
+ v-if="showSuggestItems"
107
+ v-model="isMenuOpen"
108
+ auto-close
109
+ no-focus
110
+ :offset="[0, 3]"
111
+ fit
112
+ @click="onMenuShow"
113
+ >
114
+ <dl-list
115
+ bordered
116
+ :style="{ maxWidth: suggestMenuWidth }"
117
+ >
118
+ <dl-list-item
119
+ v-for="item in suggestItems"
120
+ :key="item"
121
+ clickable
122
+ style="font-size: 12px"
123
+ @click="onClick($event, item)"
124
+ >
125
+ <span
126
+ v-for="(word, index) in getSuggestWords(
127
+ item,
128
+ modelValue
129
+ )"
130
+ :key="JSON.stringify(word) + index"
131
+ :class="{
132
+ 'dl-text-input__suggestion--highlighted':
133
+ word.highlighted
134
+ }"
135
+ >
136
+ <span v-show="word.value[0] === ' '">&nbsp;</span>
137
+ {{ word.value }}
138
+ <span
139
+ v-show="
140
+ word.value[word.value.length - 1] === ' '
141
+ "
142
+ >&nbsp;</span>
143
+ </span>
144
+ </dl-list-item>
145
+ </dl-list>
146
+ </dl-menu>
147
+ </div>
148
+ <div
149
+ v-if="!isSmall && bottomMessage"
150
+ class="dl-text-input__bottom-message-container"
151
+ >
152
+ <dl-info-error-message
153
+ v-if="!!infoMessage.length && !error && !warning"
154
+ position="below"
155
+ :value="infoMessage"
156
+ />
157
+ <dl-info-error-message
158
+ v-if="error && !!errorMessage && !!errorMessage.length"
159
+ position="below"
160
+ error
161
+ :value="errorMessage"
162
+ />
163
+ <dl-info-error-message
164
+ v-if="
165
+ warning &&
166
+ !!warningMessage &&
167
+ !!warningMessage.length &&
168
+ !error
169
+ "
170
+ position="below"
171
+ warning
172
+ :value="warningMessage"
173
+ />
174
+ <span
175
+ v-if="showCounter && maxLength && maxLength > 0"
176
+ class="dl-text-input__counter"
177
+ >
178
+ {{ characterCounter }}
179
+ </span>
180
+ </div>
181
+ </div>
182
+ </template>
183
+
184
+ <script lang="ts">
185
+ import { debounce } from 'lodash'
186
+ import { defineComponent, PropType } from 'vue-demi'
187
+ import { DlButton } from './DlButton'
188
+ import DlIcon from './DlIcon.vue'
189
+ import DlInfoErrorMessage from './DlInfoErrorMessage.vue'
190
+ import DlList from './DlList.vue'
191
+ import { DlListItem } from './DlListItem'
192
+ import { DlMenu } from './DlMenu'
193
+ import DlTooltip from './DlTooltip.vue'
194
+ import { InputSizes, TInputSizes } from '../utils/input-sizes'
195
+ import { v4 } from 'uuid'
196
+
197
+ export default defineComponent({
198
+ name: 'DlTextInput',
199
+ components: {
200
+ DlButton,
201
+ DlIcon,
202
+ DlTooltip,
203
+ DlInfoErrorMessage,
204
+ DlMenu,
205
+ DlList,
206
+ DlListItem
207
+ },
208
+ model: {
209
+ prop: 'modelValue',
210
+ event: 'update:model-value'
211
+ },
212
+ props: {
213
+ modelValue: {
214
+ type: [String, Number],
215
+ default: null
216
+ },
217
+ size: {
218
+ type: String as PropType<TInputSizes>,
219
+ default: InputSizes.l
220
+ },
221
+ placeholder: {
222
+ type: String,
223
+ default: ''
224
+ },
225
+ title: {
226
+ type: String,
227
+ default: ''
228
+ },
229
+ required: {
230
+ type: Boolean,
231
+ default: false
232
+ },
233
+ optional: {
234
+ type: Boolean,
235
+ default: false
236
+ },
237
+ tooltip: {
238
+ type: String,
239
+ default: ''
240
+ },
241
+ type: {
242
+ type: String,
243
+ default: 'text'
244
+ },
245
+ topMessage: {
246
+ type: String,
247
+ default: ''
248
+ },
249
+ redAsterisk: {
250
+ type: Boolean,
251
+ default: false
252
+ },
253
+ infoMessage: {
254
+ type: String,
255
+ default: ''
256
+ },
257
+ errorMessage: {
258
+ type: String,
259
+ default: ''
260
+ },
261
+ error: {
262
+ type: Boolean,
263
+ default: false
264
+ },
265
+ warningMessage: {
266
+ type: String,
267
+ default: ''
268
+ },
269
+ warning: {
270
+ type: Boolean,
271
+ default: false
272
+ },
273
+ disabled: {
274
+ type: Boolean,
275
+ default: false
276
+ },
277
+ maxLength: {
278
+ type: Number,
279
+ default: null
280
+ },
281
+ showCounter: {
282
+ type: Boolean,
283
+ default: false
284
+ },
285
+ withoutRootPadding: {
286
+ type: Boolean,
287
+ default: false
288
+ },
289
+ disableClearBtn: {
290
+ type: Boolean,
291
+ default: false
292
+ },
293
+ counterReverse: {
294
+ type: Boolean,
295
+ default: false
296
+ },
297
+ autoSuggestItems: {
298
+ type: Array as PropType<string[]>,
299
+ default: (): string[] => []
300
+ },
301
+ highlightMatches: {
302
+ type: Boolean,
303
+ default: false
304
+ },
305
+ suggestMenuWidth: {
306
+ type: String,
307
+ default: 'auto'
308
+ },
309
+ clearButtonTooltip: {
310
+ type: Boolean,
311
+ default: false
312
+ }
313
+ },
314
+ emits: ['input', 'focus', 'blur', 'clear', 'enter', 'update:model-value'],
315
+ data() {
316
+ return {
317
+ uuid: `dl-text-input-${v4()}`,
318
+ showPass: false,
319
+ focused: false,
320
+ isMenuOpen: false
321
+ }
322
+ },
323
+ computed: {
324
+ bottomMessage(): boolean {
325
+ return (
326
+ !!this.infoMessage.length ||
327
+ !!this.errorMessage.length ||
328
+ !!this.warningMessage.length ||
329
+ this.showCounter
330
+ )
331
+ },
332
+ rootContainerClasses(): string[] {
333
+ const classes = ['dl-text-input']
334
+ if (this.isSmall) {
335
+ classes.push('dl-text-input--s')
336
+ }
337
+ if (this.withoutRootPadding) {
338
+ classes.push('dl-text-input--without-root-padding')
339
+ }
340
+ return classes
341
+ },
342
+ inputClasses(): string[] {
343
+ const classes = [
344
+ 'dl-text-input__input',
345
+ `dl-text-input__input--${this.size}`
346
+ ]
347
+
348
+ if (this.hasPrepend) {
349
+ classes.push('dl-text-input__input--prepend')
350
+ }
351
+ if (this.hasAppend) {
352
+ classes.push('dl-text-input__input--append')
353
+ }
354
+ if (this.hasPrepend && this.hasAppend) {
355
+ classes.push('dl-text-input__input--both-adornments')
356
+ }
357
+ if (this.error) {
358
+ classes.push('dl-text-input__input--error')
359
+ } else if (this.warning) {
360
+ classes.push('dl-text-input__input--warning')
361
+ }
362
+
363
+ return classes
364
+ },
365
+ asteriskClasses(): string[] {
366
+ const classes = ['dl-text-input__asterisk']
367
+
368
+ if (this.redAsterisk) {
369
+ classes.push('dl-text-input__asterisk--red')
370
+ }
371
+
372
+ return classes
373
+ },
374
+ adornmentClasses(): string[] {
375
+ return [
376
+ 'dl-text-input__adornment-container',
377
+ `dl-text-input__adornment-container--${this.size}`
378
+ ]
379
+ },
380
+ isSmall(): boolean {
381
+ return this.size === InputSizes.s
382
+ },
383
+ hasPrepend(): boolean {
384
+ return !!this.$slots.prepend && !this.isSmall
385
+ },
386
+ hasAppend(): boolean {
387
+ return (
388
+ (!!this.$slots.append ||
389
+ !this.disableClearBtn ||
390
+ this.type === 'password') &&
391
+ !this.isSmall
392
+ )
393
+ },
394
+ passShowIcon(): string {
395
+ return this.showPass ? 'icon-dl-hide' : 'icon-dl-show'
396
+ },
397
+ showClearBtn(): boolean {
398
+ return (
399
+ !this.$slots.append &&
400
+ !this.disableClearBtn &&
401
+ this.type !== 'password' &&
402
+ !this.disabled &&
403
+ !!this.modelValue
404
+ // this.focused
405
+ )
406
+ },
407
+ showShowPassBtn(): boolean {
408
+ return !this.$slots.append && this.type === 'password'
409
+ },
410
+ showSuggestItems(): boolean {
411
+ return !!this.suggestItems.length && !!this.modelValue
412
+ },
413
+ suggestItems(): string[] {
414
+ return this.autoSuggestItems.filter((item) =>
415
+ item.includes(`${this.modelValue}`)
416
+ )
417
+ },
418
+ debouncedBlur(): any {
419
+ const debounced = debounce(this.onBlur.bind(this), 50)
420
+ return debounced
421
+ },
422
+ inputLength(): number {
423
+ return `${this.modelValue}`.length
424
+ },
425
+ characterCounter(): string {
426
+ if (!this.maxLength) {
427
+ return ''
428
+ }
429
+
430
+ const chars = this.counterReverse
431
+ ? this.maxLength - this.inputLength
432
+ : this.inputLength
433
+
434
+ return `${chars}/${this.maxLength}`
435
+ }
436
+ },
437
+ methods: {
438
+ onClick(e: Event, item: string) {
439
+ this.onAutoSuggestClick(e, item)
440
+ },
441
+ onChange(e: any): void {
442
+ this.isMenuOpen = true
443
+ this.$emit('input', e.target.value, e)
444
+ this.$emit('update:model-value', e.target.value)
445
+ },
446
+ onFocus(e: InputEvent): void {
447
+ this.focused = true
448
+ this.$emit('focus', e)
449
+ },
450
+ onBlur(e: InputEvent): void {
451
+ this.focused = false
452
+ this.$emit('blur', e)
453
+ },
454
+ onKeyPress(e: any): void {
455
+ this.$emit('enter', e.target.value, e)
456
+ },
457
+ onClear(e: any): void {
458
+ this.$emit('clear', this.modelValue)
459
+ this.$emit('input', '', e)
460
+ this.$emit('update:model-value', '')
461
+
462
+ const inputRef = this.$refs.input as HTMLInputElement
463
+ inputRef.value = ''
464
+ },
465
+ onPassShowClick(): void {
466
+ this.showPass = !this.showPass
467
+ },
468
+ onAutoSuggestClick(e: Event, item: string): void {
469
+ this.$emit('input', item, e)
470
+ this.$emit('update:model-value', item)
471
+
472
+ const inputRef = this.$refs.input as HTMLInputElement
473
+ inputRef.value = item
474
+ },
475
+ onMenuShow(): void {
476
+ const inputRef = this.$refs.input as HTMLInputElement
477
+ inputRef.focus()
478
+ },
479
+ getSuggestWords(
480
+ item: string,
481
+ keyword: string
482
+ ): { value: string; highlighted: boolean }[] {
483
+ const words: { value: string; highlighted: boolean }[] = []
484
+
485
+ if (!keyword.length || !this.highlightMatches) {
486
+ return [
487
+ {
488
+ value: item,
489
+ highlighted: false
490
+ }
491
+ ]
492
+ }
493
+
494
+ const regex = new RegExp(keyword, 'g')
495
+
496
+ const matches = [...item.matchAll(regex)]
497
+
498
+ if (!matches.length) {
499
+ return [
500
+ {
501
+ value: item,
502
+ highlighted: false
503
+ }
504
+ ]
505
+ }
506
+
507
+ if (matches[0].index !== 0) {
508
+ words.push({
509
+ value: item.split('').slice(0, matches[0].index).join(''),
510
+ highlighted: false
511
+ })
512
+ }
513
+
514
+ matches.forEach(
515
+ (match: RegExpMatchArray, iterationIndex: number) => {
516
+ const matchIndex = match.index ?? 0
517
+ const wordEndIndex = matchIndex + keyword.length
518
+
519
+ words.push({
520
+ value: item
521
+ .split('')
522
+ .slice(matchIndex, keyword.length + matchIndex)
523
+ .join(''),
524
+ highlighted: true
525
+ })
526
+
527
+ if (iterationIndex + 1 === matches.length) {
528
+ words.push({
529
+ value: item
530
+ .split('')
531
+ .slice(wordEndIndex, item.length)
532
+ .join(''),
533
+ highlighted: false
534
+ })
535
+ }
536
+
537
+ if (iterationIndex + 1 < matches.length) {
538
+ words.push({
539
+ value: item
540
+ .split('')
541
+ .slice(
542
+ wordEndIndex,
543
+ matches[iterationIndex + 1].index
544
+ )
545
+ .join(''),
546
+ highlighted: false
547
+ })
548
+ }
549
+ }
550
+ )
551
+
552
+ return words
553
+ }
554
+ }
555
+ })
556
+ </script>
557
+
558
+ <style scoped lang="scss">
559
+ .dl-text-input {
560
+ padding: 20px 20px 20px 0px;
561
+
562
+ /* Chrome, Safari, Edge, Opera */
563
+ input::-webkit-outer-spin-button,
564
+ input::-webkit-inner-spin-button {
565
+ -webkit-appearance: none;
566
+ margin: 0;
567
+ }
568
+
569
+ /* Firefox */
570
+ input[type='number'] {
571
+ -moz-appearance: textfield;
572
+ }
573
+
574
+ &--without-root-padding {
575
+ padding: 0;
576
+ }
577
+
578
+ &--s {
579
+ display: flex;
580
+ align-items: center;
581
+ }
582
+
583
+ &__title-container {
584
+ margin-bottom: 6px;
585
+ display: flex;
586
+ align-items: center;
587
+
588
+ &--s {
589
+ margin-right: 5px;
590
+ margin-bottom: 0px;
591
+ }
592
+ }
593
+
594
+ &__title {
595
+ color: var(--dl-color-medium);
596
+ font-size: var(--dl-font-size-body);
597
+ text-align: left;
598
+ margin-right: 5px;
599
+ white-space: nowrap;
600
+ }
601
+
602
+ &__asterisk {
603
+ color: var(--dl-color-medium);
604
+ font-size: var(--dl-font-size-body);
605
+ user-select: none;
606
+
607
+ &--red {
608
+ color: var(--dl-color-negative);
609
+ }
610
+ }
611
+
612
+ &__tooltip-icon {
613
+ color: var(--dl-color-medium);
614
+ }
615
+
616
+ &__top-message-container {
617
+ display: flex;
618
+ margin-bottom: 10px;
619
+ text-align: start;
620
+ }
621
+
622
+ &__input-wrapper {
623
+ position: relative;
624
+ width: 100%;
625
+ }
626
+
627
+ &__input {
628
+ border: 1px solid var(--dl-color-separator);
629
+ border-radius: 2px;
630
+ color: var(--dl-color-darker);
631
+ width: calc(100% - 20px);
632
+ box-sizing: content-box;
633
+ height: 12px;
634
+ padding: 10px;
635
+ outline: none;
636
+ background: none;
637
+ transition: border 0.3s;
638
+ font-size: var(--dl-font-size-body);
639
+ position: relative;
640
+
641
+ &--prepend {
642
+ padding-left: 28px;
643
+ width: calc(100% - 10px - 28px);
644
+ }
645
+
646
+ &--append {
647
+ padding-right: 28px;
648
+ width: calc(100% - 10px - 28px);
649
+ }
650
+
651
+ &--both-adornments {
652
+ width: calc(100% - 28px - 28px);
653
+ }
654
+
655
+ &--m {
656
+ padding-top: 7px;
657
+ padding-bottom: 7px;
658
+ }
659
+
660
+ &--s {
661
+ padding-top: 3px;
662
+ padding-bottom: 3px;
663
+ padding-left: 5px;
664
+ padding-right: 5px;
665
+ width: 100%;
666
+ }
667
+
668
+ &--error {
669
+ border-color: var(--dl-color-negative);
670
+ &:hover {
671
+ border-color: var(--dl-color-separator) !important;
672
+ }
673
+ }
674
+
675
+ &--warning {
676
+ border-color: var(--dl-color-warning);
677
+ &:hover {
678
+ border-color: var(--dl-color-separator) !important;
679
+ }
680
+ }
681
+
682
+ &::placeholder {
683
+ color: var(--dl-color-lighter);
684
+ opacity: 1;
685
+ }
686
+
687
+ &:hover {
688
+ border-color: var(--dl-color-secondary);
689
+ }
690
+
691
+ &:focus {
692
+ border-color: var(--dl-color-secondary);
693
+ }
694
+
695
+ &:disabled {
696
+ border-color: var(--dl-color-separator);
697
+ color: var(--dl-color-disabled);
698
+ cursor: not-allowed;
699
+ }
700
+ }
701
+
702
+ &__adornment-container {
703
+ display: flex;
704
+ justify-content: center;
705
+ align-items: center;
706
+ position: absolute;
707
+ width: 28px;
708
+
709
+ &--l {
710
+ height: 34px;
711
+ }
712
+
713
+ &--m {
714
+ height: 28px;
715
+ }
716
+
717
+ &--s {
718
+ height: 20px;
719
+ }
720
+
721
+ &--pos-left {
722
+ top: 0;
723
+ left: 0;
724
+ }
725
+
726
+ &--pos-right {
727
+ top: 0;
728
+ right: 0px;
729
+ }
730
+ }
731
+
732
+ &__bottom-message-container {
733
+ display: flex;
734
+ justify-content: space-between;
735
+ text-align: left;
736
+ padding-top: 3px;
737
+ }
738
+
739
+ &__counter {
740
+ margin-left: 10px;
741
+ font-size: var(--dl-font-size-body);
742
+ color: var(--dl-color-darker);
743
+ }
744
+
745
+ &__suggestion {
746
+ &--highlighted {
747
+ background-color: var(--dl-color-warning);
748
+ border-radius: 2px;
749
+ color: var(--dl-color-text-darker-buttons);
750
+ }
751
+ }
752
+ }
753
+ </style>