@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,73 @@
1
+ <template>
2
+ <div
3
+ v-if="suggestions.length > 0"
4
+ class="dl-suggestions-dropdown"
5
+ >
6
+ <dl-menu
7
+ :target="defaultTarget"
8
+ :offset="offset"
9
+ :disabled="disabled"
10
+ fit
11
+ :model-value="modelValue"
12
+ @update:modelValue="$emit('update:modelValue', $event)"
13
+ >
14
+ <dl-list>
15
+ <dl-list-item
16
+ v-for="item in suggestions"
17
+ :key="item"
18
+ :clickable="true"
19
+ @click="$emit('set-input-value', item)"
20
+ >
21
+ {{ item }}
22
+ </dl-list-item>
23
+ </dl-list>
24
+ </dl-menu>
25
+ </div>
26
+ </template>
27
+ <script lang="ts">
28
+ import { defineComponent, PropType } from 'vue-demi'
29
+ import { DlMenu } from '../DlMenu'
30
+ import DlList from '../DlList.vue'
31
+ import { DlListItem } from '../DlListItem'
32
+
33
+ export default defineComponent({
34
+ components: {
35
+ DlMenu,
36
+ DlList,
37
+ DlListItem
38
+ },
39
+ model: {
40
+ prop: 'modelValue',
41
+ event: 'update:modelValue'
42
+ },
43
+ props: {
44
+ expanded: {
45
+ type: Boolean,
46
+ default: false
47
+ },
48
+ disabled: {
49
+ type: Boolean,
50
+ default: false
51
+ },
52
+ modelValue: {
53
+ type: Boolean,
54
+ default: false
55
+ },
56
+ suggestions: {
57
+ type: Array as PropType<string[]>,
58
+ default: () => [] as string[]
59
+ },
60
+ offset: {
61
+ type: Array as PropType<number[]>,
62
+ default: () => [0, 0]
63
+ }
64
+ },
65
+ emits: ['set-input-value', 'update:modelValue'],
66
+ computed: {
67
+ defaultTarget() {
68
+ return '.dl-smart-search-input__textarea'
69
+ }
70
+ }
71
+ })
72
+ </script>
73
+ <style lang="scss" scoped></style>
@@ -0,0 +1,169 @@
1
+ import { operators } from '../../hooks/use-suggestions'
2
+ import { ColorSchema } from './types'
3
+ import { Alias } from '../../hooks/use-suggestions'
4
+ import { SyntaxColorSchema } from './types'
5
+
6
+ let editor = document.getElementById('editor')
7
+ let styleModel: SyntaxColorSchema
8
+
9
+ function getTextSegments(element: HTMLElement) {
10
+ if (!element) return
11
+ const textSegments: { text: string; node: Node }[] = []
12
+ Array.from(element.childNodes).forEach((node: Node) => {
13
+ switch (node.nodeType) {
14
+ case Node.TEXT_NODE:
15
+ textSegments.push({ text: node.nodeValue, node })
16
+ break
17
+
18
+ case Node.ELEMENT_NODE:
19
+ textSegments.splice(
20
+ textSegments.length,
21
+ 0,
22
+ ...getTextSegments(node as HTMLElement)
23
+ )
24
+ break
25
+
26
+ default:
27
+ throw new Error(`Unexpected node type: ${node.nodeType}`)
28
+ }
29
+ })
30
+ return textSegments
31
+ }
32
+
33
+ export function updateEditor(model: SyntaxColorSchema) {
34
+ styleModel = model
35
+ editor = document.getElementById('editor')
36
+ if (!editor) return
37
+ const sel = window.getSelection()
38
+ const textSegments = getTextSegments(editor)
39
+ const textContent = textSegments?.map(({ text }) => text).join('')
40
+ let anchorIndex = null
41
+ let focusIndex = null
42
+ let currentIndex = 0
43
+ textSegments?.forEach(({ text, node }) => {
44
+ if (node === sel.anchorNode) {
45
+ anchorIndex = currentIndex + sel.anchorOffset
46
+ }
47
+ if (node === sel.focusNode) {
48
+ focusIndex = currentIndex + sel.focusOffset
49
+ }
50
+ currentIndex += text.length
51
+ })
52
+
53
+ editor.innerHTML = renderText(textContent)
54
+
55
+ restoreSelection(anchorIndex, focusIndex)
56
+ }
57
+
58
+ function restoreSelection(
59
+ absoluteAnchorIndex: number,
60
+ absoluteFocusIndex: number
61
+ ) {
62
+ const sel = window.getSelection()
63
+ const textSegments = getTextSegments(editor)
64
+ let anchorNode: Node = editor
65
+ let anchorIndex = 0
66
+ let focusNode: Node = editor
67
+ let focusIndex = 0
68
+ let currentIndex = 0
69
+ textSegments.forEach(({ text, node }) => {
70
+ const startIndexOfNode = currentIndex
71
+ const endIndexOfNode = startIndexOfNode + text.length
72
+ if (
73
+ startIndexOfNode <= absoluteAnchorIndex &&
74
+ absoluteAnchorIndex <= endIndexOfNode
75
+ ) {
76
+ anchorNode = node
77
+ anchorIndex = absoluteAnchorIndex - startIndexOfNode
78
+ }
79
+ if (
80
+ startIndexOfNode <= absoluteFocusIndex &&
81
+ absoluteFocusIndex <= endIndexOfNode
82
+ ) {
83
+ focusNode = node
84
+ focusIndex = absoluteFocusIndex - startIndexOfNode
85
+ }
86
+ currentIndex += text.length
87
+ })
88
+
89
+ sel.setBaseAndExtent(anchorNode, anchorIndex, focusNode, focusIndex)
90
+ }
91
+
92
+ function renderText(text: string) {
93
+ const words = text?.split(/(\s+)/)
94
+ const output = words?.map((word) => {
95
+ if (styleModel.keywords.values.includes(word)) {
96
+ return `<strong>${word}</strong>`
97
+ } else if (styleModel.fields.values.includes(word)) {
98
+ return `<span style='color:${styleModel.fields.color}'>${word}</span>`
99
+ } else if (styleModel.operators.values.includes(word)) {
100
+ return `<span style='color:${styleModel.operators.color}'>${word}</span>`
101
+ } else {
102
+ return `<span>${word}</span>`
103
+ }
104
+ })
105
+ return output?.join('')
106
+ }
107
+
108
+ export function setCaret(target: HTMLElement) {
109
+ const range = document.createRange()
110
+ const sel = window.getSelection()
111
+ range.selectNodeContents(target)
112
+ range.collapse(false)
113
+ sel.removeAllRanges()
114
+ sel.addRange(range)
115
+ target.focus()
116
+ }
117
+
118
+ export const isEligibleToChange = (target: HTMLElement, expanded: boolean) => {
119
+ let childOffsetRight = 0
120
+ let childOffsetBottom = 20
121
+
122
+ if (target?.lastChild) {
123
+ const range = document.createRange()
124
+ range.selectNode(target?.lastChild)
125
+ childOffsetRight =
126
+ range.getBoundingClientRect().right -
127
+ target.getBoundingClientRect().left
128
+ childOffsetBottom =
129
+ range.getBoundingClientRect().bottom -
130
+ target.getBoundingClientRect().top +
131
+ 5
132
+ }
133
+
134
+ if (childOffsetRight <= target.clientWidth) {
135
+ return [-childOffsetRight, 5]
136
+ } else {
137
+ return [-target.clientWidth, 5]
138
+ }
139
+ }
140
+
141
+ export function createColorSchema(
142
+ colorSchema: ColorSchema,
143
+ aliases: Alias[]
144
+ ): SyntaxColorSchema {
145
+ const thisFields = []
146
+ for (const key in aliases) {
147
+ thisFields.push(aliases[key].alias)
148
+ }
149
+
150
+ const thisOperators = []
151
+ for (const key in operators) {
152
+ thisOperators.push(operators[key])
153
+ }
154
+
155
+ return {
156
+ fields: {
157
+ values: thisFields,
158
+ color: colorSchema.fields
159
+ },
160
+ operators: {
161
+ values: thisOperators,
162
+ color: colorSchema.operators
163
+ },
164
+ keywords: {
165
+ values: ['OR', 'AND'],
166
+ color: colorSchema.keywords
167
+ }
168
+ }
169
+ }
@@ -0,0 +1,4 @@
1
+ import DlSmartSearch from './DlSmartSearch.vue'
2
+ import DlJsonEditor from './DlJsonEditor.vue'
3
+
4
+ export { DlSmartSearch, DlJsonEditor }
@@ -0,0 +1,36 @@
1
+ export interface Query {
2
+ name: string
3
+ query: string | null
4
+ }
5
+
6
+ export interface Filter {
7
+ name: string
8
+ label: string
9
+ queries: Query[]
10
+ }
11
+
12
+ export interface ColorSchema {
13
+ fields: string
14
+ operators: string
15
+ keywords: string
16
+ }
17
+
18
+ export interface SearchStatus {
19
+ type: string
20
+ message: string
21
+ }
22
+
23
+ export type SyntaxColorSchema = {
24
+ fields: {
25
+ values: string[]
26
+ color: string
27
+ }
28
+ operators: {
29
+ values: string[]
30
+ color: string
31
+ }
32
+ keywords: {
33
+ values: string[]
34
+ color: string
35
+ }
36
+ }
@@ -0,0 +1,45 @@
1
+ import { dateIntervalPattern } from '../../hooks/use-suggestions'
2
+ import { DateInterval } from '../DlDatePicker/types'
3
+
4
+ export const isEndOfString = (str: string, pattern: RegExp): boolean => {
5
+ const trimmed = str.trim()
6
+ const matches = trimmed.match(pattern)
7
+
8
+ if (!matches || !matches.length) return false
9
+
10
+ const lastMatch = matches[matches.length - 1]
11
+ return trimmed.lastIndexOf(lastMatch) + lastMatch.length === trimmed.length
12
+ }
13
+
14
+ export const isEndingWithDateIntervalPattern = (str: string) =>
15
+ isEndOfString(str, dateIntervalPattern)
16
+
17
+ export const replaceDateInterval = (
18
+ str: string,
19
+ dateInterval: DateInterval
20
+ ) => {
21
+ const dateFrom = new Date(dateInterval.from)
22
+ const dateTo = new Date(dateInterval.to)
23
+
24
+ const newStr = `(From ${formatDate(dateFrom)} To ${formatDate(dateTo)})`
25
+
26
+ return replaceLastOccurrence(str, newStr)
27
+ }
28
+
29
+ const formatDate = (date: Date): string => {
30
+ return `(${addZero(date.getDate())}/${addZero(
31
+ date.getMonth() + 1
32
+ )}/${date.getFullYear()})`
33
+ }
34
+
35
+ const addZero = (value: number): string => {
36
+ return value < 10 ? `0${value}` : value.toString()
37
+ }
38
+
39
+ const replaceLastOccurrence = (string: string, replaceValue: string) => {
40
+ const matches = string.match(dateIntervalPattern)
41
+
42
+ return matches && matches.length
43
+ ? string.replace(matches[matches.length - 1], replaceValue)
44
+ : string
45
+ }
@@ -0,0 +1,196 @@
1
+ <template>
2
+ <dl-stepper-container
3
+ v-if="isOpen"
4
+ :id="uuid"
5
+ class="dl-stepper-container"
6
+ :style="cssVars"
7
+ :transition="withTransition"
8
+ :duration="transitionDuration"
9
+ >
10
+ <dl-stepper-header
11
+ :header-title="headerTitle"
12
+ :hide-close-btn="hideCloseBtn"
13
+ @close="closeStepper"
14
+ />
15
+ <div class="dl-stepper-content">
16
+ <dl-stepper-sidebar
17
+ :steps="steps"
18
+ :bg-color="bgColor"
19
+ :sidebar-navigation="sidebarNavigation"
20
+ @step-click="$emit('set-step', $event)"
21
+ />
22
+ <div class="dl-stepper-content dl-stepper-content--slot">
23
+ <dl-stepper-content
24
+ v-if="state"
25
+ :title="contentTitle"
26
+ :error="state.error"
27
+ :completed="state.completed"
28
+ >
29
+ <template #header>
30
+ <slot
31
+ name="content-header"
32
+ :state="state"
33
+ />
34
+ </template>
35
+ <slot
36
+ :name="state.value"
37
+ :state="state"
38
+ />
39
+ </dl-stepper-content>
40
+ <dl-stepper-footer
41
+ :finished="isDone"
42
+ :done-button-label="doneButtonLabel"
43
+ :next-button-label="nextButtonLabel"
44
+ :prev-button-label="prevButtonLabel"
45
+ :disabled-next-step="disabledNextStep"
46
+ :disabled-prev-step="disabledPrevStep"
47
+ @next="$emit('next')"
48
+ @prev="$emit('prev')"
49
+ @done="$emit('done')"
50
+ @close="closeStepper"
51
+ />
52
+ </div>
53
+ </div>
54
+ </dl-stepper-container>
55
+ </template>
56
+ <script lang="ts">
57
+ import { defineComponent, PropType } from 'vue-demi'
58
+ import DlStepperContainer from './DlStepperContainer.vue'
59
+ import DlStepperHeader from '../../components/DlStepper/DlStepperHeader.vue'
60
+ import DlStepperFooter from '../../components/DlStepper/DlStepperFooter.vue'
61
+ import DlStepperSidebar from '../../components/DlStepper/DlStepperSidebar.vue'
62
+ import DlStepperContent from '../../components/DlStepper/DlStepperContent.vue'
63
+ import { StepState } from './interfaces'
64
+ import { Step } from './Step'
65
+ import { getColor } from '../../utils'
66
+ import { v4 } from 'uuid'
67
+
68
+ export default defineComponent({
69
+ components: {
70
+ DlStepperHeader,
71
+ DlStepperFooter,
72
+ DlStepperSidebar,
73
+ DlStepperContent,
74
+ DlStepperContainer
75
+ },
76
+ model: {
77
+ prop: 'modelValue',
78
+ event: 'update:modelValue'
79
+ },
80
+ props: {
81
+ steps: {
82
+ type: Array as PropType<Step[]>,
83
+ default: () => [] as Step[]
84
+ },
85
+ nextStep: {
86
+ type: Object as PropType<StepState | null>,
87
+ default: () => null as StepState | null
88
+ },
89
+ prevStep: {
90
+ type: Object as PropType<StepState | null>,
91
+ default: () => null as StepState | null
92
+ },
93
+ state: {
94
+ type: Object as PropType<StepState>,
95
+ default: () => {}
96
+ },
97
+ modelValue: {
98
+ type: Boolean,
99
+ default: false
100
+ },
101
+ headerTitle: {
102
+ type: String,
103
+ required: false,
104
+ default: ''
105
+ },
106
+ contentTitle: {
107
+ type: String,
108
+ default: ''
109
+ },
110
+ doneButtonLabel: {
111
+ type: String,
112
+ required: false,
113
+ default: 'Done'
114
+ },
115
+ width: {
116
+ type: String,
117
+ required: false,
118
+ default: '700px'
119
+ },
120
+ bgColor: {
121
+ type: String,
122
+ required: false,
123
+ default: 'dl-color-fill-third'
124
+ },
125
+ withTransition: Boolean,
126
+ transitionDuration: {
127
+ type: Number,
128
+ required: false,
129
+ default: 0.3
130
+ },
131
+ disabledNextStep: Boolean,
132
+ disabledPrevStep: Boolean,
133
+ isDone: Boolean,
134
+ hideCloseBtn: Boolean,
135
+ sidebarNavigation: { type: Boolean, default: true }
136
+ },
137
+ emits: ['update:modelValue', 'done', 'next', 'prev', 'set-step', 'close'],
138
+ data() {
139
+ return {
140
+ uuid: `dl-stepper-${v4()}`,
141
+ isOpen: this.modelValue
142
+ }
143
+ },
144
+ computed: {
145
+ nextButtonLabel(): string {
146
+ return this.nextStep?.title ?? null
147
+ },
148
+ prevButtonLabel(): string {
149
+ return this.prevStep?.title ?? null
150
+ },
151
+ cssVars(): Record<string, string | number> {
152
+ return {
153
+ '--dl-stepper-width': this.width,
154
+ '--dl-stepper-bg': getColor(this.bgColor, 'dl-color-fill-third')
155
+ }
156
+ }
157
+ },
158
+ watch: {
159
+ modelValue(newVal: boolean) {
160
+ this.isOpen = newVal
161
+ if (newVal) document.documentElement.style.overflow = 'hidden'
162
+ else document.documentElement.style.overflow = 'auto'
163
+ }
164
+ },
165
+ methods: {
166
+ closeStepper() {
167
+ this.$emit('close')
168
+ this.$emit('update:modelValue', false)
169
+ }
170
+ }
171
+ })
172
+ </script>
173
+ <style lang="scss" scoped>
174
+ .dl-stepper-container {
175
+ height: 100%;
176
+ overflow: auto;
177
+ width: var(--dl-stepper-width);
178
+ display: flex;
179
+ flex-direction: column;
180
+ background-color: var(--dl-color-panel-background);
181
+ border: 1px solid var(--dl-color-separator);
182
+ border-radius: 2px;
183
+ }
184
+
185
+ .dl-stepper-content {
186
+ display: flex;
187
+ flex-grow: 1;
188
+ position: relative;
189
+
190
+ &--slot {
191
+ display: flex;
192
+ flex-direction: column;
193
+ overflow: auto;
194
+ }
195
+ }
196
+ </style>
@@ -0,0 +1,55 @@
1
+ <template>
2
+ <transition
3
+ name="fade"
4
+ appear
5
+ :style="cssVars"
6
+ >
7
+ <div>
8
+ <slot />
9
+ </div>
10
+ </transition>
11
+ </template>
12
+
13
+ <script lang="ts">
14
+ import { defineComponent } from 'vue-demi'
15
+
16
+ export default defineComponent({
17
+ name: 'DlStepperContainer',
18
+ props: {
19
+ duration: {
20
+ type: Number,
21
+ default: 0.3
22
+ },
23
+ transition: Boolean
24
+ },
25
+ computed: {
26
+ cssVars(): Record<string, string> {
27
+ return {
28
+ '--dl-transition-duration':
29
+ (this.transition ? this.duration : 0) + 's'
30
+ }
31
+ }
32
+ }
33
+ })
34
+ </script>
35
+
36
+ <style lang="scss" scoped>
37
+ .fade-enter,
38
+ .fade-enter-active {
39
+ animation: fade-in var(--dl-transition-duration);
40
+ }
41
+
42
+ .fade-leave-active,
43
+ .fade-leave-to {
44
+ animation: fade-in var(--dl-transition-duration) reverse;
45
+ }
46
+
47
+ @keyframes fade-in {
48
+ 0% {
49
+ opacity: 0;
50
+ }
51
+ 100% {
52
+ opacity: 1;
53
+ }
54
+ }
55
+ </style>
@@ -0,0 +1,101 @@
1
+ <template>
2
+ <div class="stepper-content">
3
+ <slot name="header">
4
+ <div class="stepper-content--header">
5
+ <dl-typography
6
+ size="h3"
7
+ variant="h3"
8
+ style="text-transform: capitalize"
9
+ >
10
+ {{ title }}
11
+ </dl-typography>
12
+ <div class="flex justify-end">
13
+ <dl-chip
14
+ v-if="error"
15
+ text-color="dl-color-text-darker-buttons"
16
+ color="dl-color-negative-background"
17
+ >
18
+ {{ error }}
19
+ </dl-chip>
20
+ <dl-chip
21
+ v-else-if="completed"
22
+ text-color="dl-color-text-darker-buttons"
23
+ color="dl-color-positive-background"
24
+ >
25
+ completed
26
+ </dl-chip>
27
+ </div>
28
+ </div>
29
+ </slot>
30
+ <div class="stepper-content--content">
31
+ <slot />
32
+ </div>
33
+ </div>
34
+ </template>
35
+
36
+ <script lang="ts">
37
+ import { defineComponent } from 'vue-demi'
38
+ import DlChip from '../DlChip'
39
+ import DlTypography from '../DlTypography.vue'
40
+
41
+ export default defineComponent({
42
+ name: 'DlStepperContent',
43
+ components: {
44
+ DlChip,
45
+ DlTypography
46
+ },
47
+ props: {
48
+ title: {
49
+ type: String,
50
+ default: ''
51
+ },
52
+ error: {
53
+ type: String,
54
+ default: ''
55
+ },
56
+ completed: Boolean
57
+ },
58
+ emits: ['next', 'prev']
59
+ })
60
+ </script>
61
+ <style scoped lang="scss">
62
+ .stepper-content {
63
+ padding: 20px 50px;
64
+ // max-height: calc(100vh - 175px);
65
+
66
+ display: flex;
67
+ flex-direction: column;
68
+ position: absolute;
69
+ top: 0;
70
+ left: 0;
71
+ right: 0;
72
+ bottom: 0;
73
+ padding-bottom: 70px;
74
+
75
+ overflow: auto;
76
+ &::-webkit-scrollbar {
77
+ width: 1px;
78
+ height: 1px;
79
+ }
80
+
81
+ &--header {
82
+ display: flex;
83
+ height: 20px;
84
+ }
85
+
86
+ &--content {
87
+ &::-webkit-scrollbar {
88
+ width: 1px;
89
+ height: 1px;
90
+ }
91
+ }
92
+
93
+ &--content {
94
+ margin-top: 20px;
95
+ }
96
+
97
+ .justify-end {
98
+ margin-left: auto;
99
+ }
100
+ }
101
+ </style>