@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,146 @@
1
+ <template>
2
+ <div
3
+ :id="uuid"
4
+ role="tab"
5
+ :tabindex="disabled ? -1 : tabindex"
6
+ flat
7
+ :class="classNames"
8
+ :style="cssFontSize"
9
+ @click="onClick"
10
+ @keydown="onKeydown"
11
+ @keyup="onKeyup"
12
+ >
13
+ {{ label }}
14
+ <span>
15
+ <dl-icon
16
+ v-if="showTooltip"
17
+ size="12px"
18
+ icon="icon-dl-info"
19
+ class="info-icon"
20
+ />
21
+ <dl-tooltip v-if="showTooltip === true">
22
+ {{ tooltip }}
23
+ </dl-tooltip>
24
+ </span>
25
+ </div>
26
+ </template>
27
+ <script lang="ts">
28
+ import DlTooltip from '../DlTooltip.vue'
29
+ import DlIcon from '../DlIcon.vue'
30
+ import { defineComponent } from 'vue-demi'
31
+ import { stopAndPrevent } from '../../utils'
32
+ import { v4 } from 'uuid'
33
+
34
+ export default defineComponent({
35
+ name: 'DlTab',
36
+ components: {
37
+ DlTooltip,
38
+ DlIcon
39
+ },
40
+ props: {
41
+ label: { type: String, required: true },
42
+ name: { type: String, required: true },
43
+ isActive: { type: Boolean, default: false },
44
+ noCaps: { type: Boolean, default: false },
45
+ disabled: { type: Boolean, default: false },
46
+ vertical: { type: Boolean, default: false },
47
+ showTooltip: { type: Boolean, default: false },
48
+ tooltip: { type: String, default: null },
49
+ tabindex: { type: String, default: '0' },
50
+ fontSize: { type: String, default: '12px' }
51
+ },
52
+ emits: ['click'],
53
+ data() {
54
+ return {
55
+ uuid: `dl-tab-${v4()}`
56
+ }
57
+ },
58
+ computed: {
59
+ cssFontSize(): Record<string, string> {
60
+ return {
61
+ '--dl-tab-font-size': this.fontSize
62
+ }
63
+ },
64
+ classNames(): string {
65
+ let classes = 'dl-tab'
66
+
67
+ if (this.vertical) {
68
+ classes = classes + ' dl-tab--vertical'
69
+ } else {
70
+ classes = classes + ' dl-tab--simple'
71
+ }
72
+
73
+ if (this.isActive) {
74
+ classes = classes + ' dl-tab--active'
75
+ }
76
+
77
+ if (this.disabled) {
78
+ classes = classes + ' dl-tab--disabled'
79
+ }
80
+ return classes
81
+ }
82
+ },
83
+ methods: {
84
+ onClick(e: Event) {
85
+ if (!this.disabled) {
86
+ this.$emit('click', this.name, e)
87
+ }
88
+ },
89
+ onKeydown(e: KeyboardEvent) {
90
+ if (e.key === 'Enter' || e.key === ' ') {
91
+ stopAndPrevent(e)
92
+ }
93
+ },
94
+ onKeyup(e: KeyboardEvent) {
95
+ if (e.key === 'Enter' || e.key === ' ') {
96
+ this.onClick(e as Event)
97
+ }
98
+ }
99
+ }
100
+ })
101
+ </script>
102
+ <style scoped lang="scss">
103
+ .dl-tab {
104
+ padding: 12px 16px;
105
+ color: var(--dl-color-lighter);
106
+ transition: all 200ms;
107
+ display: flex;
108
+ align-items: center;
109
+ justify-content: center;
110
+ gap: 5px;
111
+ &--active {
112
+ color: var(--dl-color-secondary);
113
+ border-color: var(--dl-color-secondary) !important;
114
+ cursor: default;
115
+ }
116
+ &--simple {
117
+ font-size: var(--dl-tab-font-size);
118
+ border-bottom: 1px solid var(--dl-color-separator);
119
+ &.active {
120
+ border-color: var(--dl-color-secondary);
121
+ }
122
+ }
123
+ &--vertical {
124
+ padding: 5px 10px;
125
+ font-size: var(--dl-tab-font-size);
126
+ line-height: 14px;
127
+ &:not(:last-child) {
128
+ border-right: 1px solid var(--dl-color-separator);
129
+ }
130
+ }
131
+ &--disabled {
132
+ cursor: not-allowed;
133
+ color: var(--dl-color-disabled);
134
+ border-color: var(--dl-color-separator) !important;
135
+ &:hover {
136
+ color: var(--dl-color-disabled) !important;
137
+ }
138
+ }
139
+ &:hover {
140
+ color: var(--dl-color-hover);
141
+ border-color: var(--dl-color-hover);
142
+ }
143
+ cursor: pointer;
144
+ flex-grow: 1;
145
+ }
146
+ </style>
@@ -0,0 +1,192 @@
1
+ <template>
2
+ <tabs-wrapper
3
+ :id="uuid"
4
+ :is-scrollable="isOverflowing"
5
+ :is-at-end="isAtEnd"
6
+ :is-at-start="isAtStart"
7
+ :is-vertical="vertical"
8
+ @left-arrow-click="handleLeft"
9
+ @right-arrow-click="handleRight"
10
+ >
11
+ <div
12
+ ref="dlTabsRef"
13
+ class="dl-tabs-container"
14
+ :class="{ 'full-width': fullWidth }"
15
+ role="tablist"
16
+ >
17
+ <dl-tab
18
+ v-for="(item, index) in items"
19
+ :key="index"
20
+ :name="item.name"
21
+ :vertical="vertical"
22
+ :label="item.label"
23
+ :show-tooltip="item.showTooltip"
24
+ :tooltip="item.tooltip"
25
+ :disabled="disabled || item.disabled"
26
+ :no-caps="item.noCaps"
27
+ :is-active="modelValue === item.name"
28
+ :font-size="fontSize"
29
+ @click="handleTabClick"
30
+ />
31
+ </div>
32
+ </tabs-wrapper>
33
+ </template>
34
+
35
+ <script lang="ts">
36
+ import { v4 } from 'uuid'
37
+ import { defineComponent, PropType } from 'vue-demi'
38
+ import { hasOverflowing } from '../../utils'
39
+ import { DlTab } from './'
40
+ import TabsWrapper from './TabsWrapper.vue'
41
+ import type { TabDetails } from './types'
42
+
43
+ export default defineComponent({
44
+ name: 'DlTabs',
45
+ components: {
46
+ TabsWrapper,
47
+ DlTab
48
+ },
49
+ model: {
50
+ prop: 'modelValue',
51
+ event: 'update:model-value'
52
+ },
53
+ props: {
54
+ items: { type: Array as PropType<TabDetails[]>, required: true },
55
+ vertical: { type: Boolean, default: false },
56
+ fullWidth: { type: Boolean, default: false },
57
+ disabled: { type: Boolean, default: false },
58
+ modelValue: { type: String, required: true },
59
+ fontSize: { type: String, default: '12px' }
60
+ },
61
+ emits: ['update:model-value'],
62
+ data() {
63
+ return {
64
+ uuid: `dl-tabs-${v4()}`,
65
+ isOverflowing: false,
66
+ isAtStart: true,
67
+ isAtEnd: false,
68
+ children: [] as HTMLElement[],
69
+ invisibleLeftIndex: 0,
70
+ invisibleRightIndex: 0
71
+ }
72
+ },
73
+ computed: {
74
+ // @ts-ignore
75
+ resizeObserver(): ResizeObserver | undefined {
76
+ // @ts-ignore
77
+ if (typeof ResizeObserver !== 'undefined') {
78
+ // @ts-ignore
79
+ return new ResizeObserver((entries) => {
80
+ for (const entry of entries) {
81
+ if (entry.contentBoxSize) {
82
+ this.isOverflowing = hasOverflowing(
83
+ this.$refs.dlTabsRef as HTMLElement
84
+ )
85
+ this.updatePosition()
86
+ this.initTabs()
87
+ }
88
+ }
89
+ })
90
+ }
91
+
92
+ return undefined
93
+ }
94
+ },
95
+ mounted() {
96
+ const element = this.$refs.dlTabsRef as HTMLElement
97
+ this.resizeObserver?.observe(element)
98
+ element?.addEventListener('scroll', this.updatePosition)
99
+ },
100
+ unmounted() {
101
+ this.unsubscribeListeners()
102
+ },
103
+ methods: {
104
+ handleTabClick(newSelectedTab: string, e: Event) {
105
+ this.$emit('update:model-value', newSelectedTab, e)
106
+ },
107
+ handleScroll(e: Event | undefined) {
108
+ this.updatePosition()
109
+ },
110
+ unsubscribeListeners() {
111
+ (this.$refs.dlTabsRef as HTMLElement)?.removeEventListener(
112
+ 'scroll',
113
+ this.handleScroll
114
+ )
115
+ this.resizeObserver?.disconnect()
116
+ },
117
+ initTabs() {
118
+ const element = this.$refs.dlTabsRef as HTMLElement
119
+
120
+ Array.from(element.children).forEach((children: Element) => {
121
+ this.children.push(children as HTMLElement)
122
+ })
123
+
124
+ this.invisibleLeftIndex = 0
125
+ },
126
+ handleLeft() {
127
+ this.children[this.invisibleLeftIndex].scrollIntoView({
128
+ block: 'nearest',
129
+ inline: 'start'
130
+ })
131
+ this.updatePosition()
132
+ },
133
+ handleRight() {
134
+ this.children[this.invisibleRightIndex].scrollIntoView({
135
+ block: 'nearest',
136
+ inline: 'end'
137
+ })
138
+ this.updatePosition()
139
+ },
140
+ updatePosition() {
141
+ const element = this.$refs.dlTabsRef as HTMLElement
142
+
143
+ const lastLeft = this.children.findIndex((child, index) => {
144
+ return child.offsetLeft >= element.scrollLeft
145
+ })
146
+ this.invisibleLeftIndex = lastLeft === -1 ? 0 : lastLeft - 1
147
+
148
+ const lastRight = this.children.findIndex(
149
+ (child) =>
150
+ child.offsetLeft >
151
+ element.scrollLeft + element.clientWidth + 1
152
+ )
153
+ this.invisibleRightIndex =
154
+ lastRight === -1 ? this.children.length - 1 : lastRight - 1
155
+
156
+ if (element.scrollLeft < 1) {
157
+ this.isAtStart = true
158
+ } else {
159
+ this.isAtStart = false
160
+ }
161
+ if (
162
+ element.offsetWidth + element.scrollLeft ===
163
+ element.scrollWidth
164
+ ) {
165
+ this.isAtEnd = true
166
+ } else {
167
+ this.isAtEnd = false
168
+ }
169
+ }
170
+ }
171
+ })
172
+ </script>
173
+
174
+ <style scoped lang="scss">
175
+ .dl-tabs-container {
176
+ position: relative;
177
+ text-align: center;
178
+ display: flex;
179
+ overflow: -moz-hidden-unscrollable;
180
+ justify-content: stretch;
181
+ overflow-x: scroll;
182
+ scroll-behavior: smooth;
183
+ -ms-overflow-style: none;
184
+ scrollbar-width: none;
185
+ &::-webkit-scrollbar {
186
+ display: none;
187
+ }
188
+ }
189
+ .full-width {
190
+ width: 100%;
191
+ }
192
+ </style>
@@ -0,0 +1,104 @@
1
+ <template>
2
+ <div
3
+ :class="['tabs-wrapper', { scrollable: isScrollable }]"
4
+ :style="cssVars"
5
+ >
6
+ <dl-button
7
+ v-if="isScrollable"
8
+ size="l"
9
+ flat
10
+ :disabled="isAtStart"
11
+ data-qa="left-arrow-button"
12
+ class="arrow-button"
13
+ text-color="dl-color-darker"
14
+ @click="handleLeftArrowClick"
15
+ >
16
+ <dl-icon
17
+ icon="icon-dl-left-chevron"
18
+ size="16px"
19
+ />
20
+ </dl-button>
21
+ <slot class="tabs" />
22
+ <dl-button
23
+ v-if="isScrollable"
24
+ size="l"
25
+ data-qa="right-arrow-button"
26
+ text-color="dl-color-darker"
27
+ flat
28
+ :disabled="isAtEnd"
29
+ class="arrow-button"
30
+ @click="handleRightArrowClick"
31
+ >
32
+ <dl-icon
33
+ icon="icon-dl-right-chevron"
34
+ size="16px"
35
+ />
36
+ </dl-button>
37
+ </div>
38
+ </template>
39
+ <script lang="ts">
40
+ import { defineComponent } from 'vue-demi'
41
+ import { DlButton } from '../DlButton'
42
+ import DlIcon from '../DlIcon.vue'
43
+
44
+ export default defineComponent({
45
+ components: {
46
+ DlButton,
47
+ DlIcon
48
+ },
49
+ props: {
50
+ isScrollable: { type: Boolean, default: false },
51
+ isVertical: { type: Boolean, default: false },
52
+ isAtStart: { type: Boolean, default: true },
53
+ isAtEnd: { type: Boolean, default: false }
54
+ },
55
+ emits: ['left-arrow-click', 'right-arrow-click'],
56
+ computed: {
57
+ cssVars(): string {
58
+ return `
59
+ --dl-tabs-arrows-size: ${this.isVertical ? '24px' : '40px'}
60
+ `
61
+ }
62
+ },
63
+ methods: {
64
+ handleLeftArrowClick(e: Event) {
65
+ if (this.isAtStart === false) {
66
+ this.$emit('left-arrow-click', e)
67
+ }
68
+ },
69
+ handleRightArrowClick(e: Event) {
70
+ if (this.isAtEnd === false) {
71
+ this.$emit('right-arrow-click', e)
72
+ }
73
+ }
74
+ }
75
+ })
76
+ </script>
77
+ <style scoped lang="scss">
78
+ .tabs-wrapper {
79
+ max-width: 100%;
80
+ display: flex;
81
+ align-items: center;
82
+ }
83
+
84
+ .tabs {
85
+ flex-grow: 1;
86
+ }
87
+
88
+ ::v-deep .dl-button {
89
+ padding: 0px;
90
+
91
+ &:disabled {
92
+ pointer-events: none;
93
+ }
94
+ }
95
+
96
+ ::v-deep .dl-btn-content {
97
+ padding-top: 1px;
98
+ min-height: var(--dl-tabs-arrows-size);
99
+ width: var(--dl-tabs-arrows-size);
100
+ display: flex;
101
+ align-items: center;
102
+ justify-content: center;
103
+ }
104
+ </style>
@@ -0,0 +1,4 @@
1
+ import DlTab from './DlTab.vue'
2
+ import DlTabs from './DlTabs.vue'
3
+
4
+ export { DlTab, DlTabs }
@@ -0,0 +1,8 @@
1
+ export interface TabDetails {
2
+ label: string
3
+ name: string
4
+ noCaps?: boolean
5
+ disabled?: boolean
6
+ showTooltip?: boolean
7
+ tooltip?: string
8
+ }
@@ -0,0 +1,151 @@
1
+ <template>
2
+ <div
3
+ :id="uuid"
4
+ class="container"
5
+ :style="cssVars"
6
+ >
7
+ <textarea
8
+ :value="modelValue"
9
+ class="textarea"
10
+ :placeholder="placeholder"
11
+ :maxlength="maxLength"
12
+ :disabled="disabled"
13
+ :class="!enableResize ? 'textarea-disable-resize' : ''"
14
+ @input="onChange"
15
+ @focus="onFocus"
16
+ @blur="onBlur"
17
+ />
18
+ <span v-show="showCounter">
19
+ {{ modelValue.length
20
+ }}{{ maxLength && maxLength > 0 ? `/${maxLength}` : null }}
21
+ </span>
22
+ </div>
23
+ </template>
24
+
25
+ <script lang="ts">
26
+ import { v4 } from 'uuid'
27
+ import { defineComponent } from 'vue-demi'
28
+
29
+ export default defineComponent({
30
+ name: 'DlTextArea',
31
+ model: {
32
+ prop: 'modelValue',
33
+ event: 'update:model-value'
34
+ },
35
+ props: {
36
+ modelValue: {
37
+ type: String,
38
+ default: ''
39
+ },
40
+ maxLength: {
41
+ type: Number,
42
+ default: null
43
+ },
44
+ width: {
45
+ type: String,
46
+ default: 'auto'
47
+ },
48
+ disabled: {
49
+ type: Boolean,
50
+ default: false
51
+ },
52
+ placeholder: {
53
+ type: String,
54
+ default: ''
55
+ },
56
+ showCounter: {
57
+ type: Boolean,
58
+ default: false
59
+ },
60
+ enableResize: {
61
+ type: Boolean,
62
+ default: false
63
+ }
64
+ },
65
+ emits: ['input', 'focus', 'blur', 'update:model-value'],
66
+ data() {
67
+ return {
68
+ uuid: `dl-text-area-${v4()}`
69
+ }
70
+ },
71
+ computed: {
72
+ cssVars(): Record<string, string> {
73
+ return {
74
+ '--dl-textarea-width': this.width || 'auto'
75
+ }
76
+ }
77
+ },
78
+ methods: {
79
+ onChange(e: any) {
80
+ this.$emit('input', e.target.value, e)
81
+ this.$emit('update:model-value', e.target.value)
82
+ },
83
+ onFocus(e: InputEvent) {
84
+ this.$emit('focus', e)
85
+ },
86
+ onBlur(e: InputEvent) {
87
+ this.$emit('blur', e)
88
+ }
89
+ }
90
+ })
91
+ </script>
92
+
93
+ <style scoped lang="scss">
94
+ .container {
95
+ display: flex;
96
+ flex-direction: column;
97
+ align-items: flex-end;
98
+ width: max-content;
99
+ max-width: 100%;
100
+ }
101
+
102
+ .textarea {
103
+ background: none;
104
+ border: 1px solid var(--dl-color-separator);
105
+ border-radius: 2px;
106
+ padding: 10px;
107
+ font-family: 'Roboto', sans-serif;
108
+ font-size: var(--dl-font-size-body);
109
+ width: var(--dl-textarea-width);
110
+ min-width: 100px;
111
+ max-width: 100%;
112
+ min-height: 80px;
113
+ max-height: 120px;
114
+ outline: none;
115
+ color: var(--dl-color-darker);
116
+
117
+ &:hover {
118
+ border-color: var(--dl-color-hover);
119
+ }
120
+
121
+ &:focus {
122
+ border-color: var(--dl-color-secondary);
123
+ }
124
+
125
+ &:disabled {
126
+ border-color: var(--dl-color-disabled);
127
+ color: var(--dl-color-disabled);
128
+ cursor: not-allowed;
129
+ user-select: none;
130
+ }
131
+
132
+ &::placeholder {
133
+ color: var(--dl-color-lighter);
134
+ opacity: 1;
135
+ }
136
+
137
+ &:disabled::placeholder {
138
+ color: rgba(0, 0, 0, 0);
139
+ }
140
+
141
+ &-disable-resize {
142
+ resize: none;
143
+ }
144
+ }
145
+
146
+ span {
147
+ margin-top: 3px;
148
+ font-size: var(--dl-font-size-body);
149
+ color: var(--dl-color-darker);
150
+ }
151
+ </style>
@@ -0,0 +1,65 @@
1
+ <template>
2
+ <span
3
+ :id="uuid"
4
+ class="dl-text-holder"
5
+ >
6
+ <span v-if="prefix">{{ prefixPreview }}</span>
7
+ <span class="dl-text-holder--value">
8
+ <slot> {{ textPreview }} </slot>
9
+ </span>
10
+ <span v-if="suffix"> {{ suffixPreview }}</span>
11
+ </span>
12
+ </template>
13
+
14
+ <script lang="ts">
15
+ import { v4 } from 'uuid'
16
+ import { defineComponent } from 'vue-demi'
17
+
18
+ export default defineComponent({
19
+ name: 'DlTextHolder',
20
+ props: {
21
+ prefix: {
22
+ type: String,
23
+ default: null
24
+ },
25
+ suffix: {
26
+ type: String,
27
+ default: null
28
+ },
29
+ text: {
30
+ type: String,
31
+ required: true
32
+ }
33
+ },
34
+ data() {
35
+ return {
36
+ uuid: `dl-text-holder-${v4()}`
37
+ }
38
+ },
39
+ computed: {
40
+ prefixPreview(): string {
41
+ return this.prefix?.trim() ?? ''
42
+ },
43
+ suffixPreview(): string {
44
+ return this.suffix?.trim() ?? ''
45
+ },
46
+ textPreview(): string {
47
+ return this.text
48
+ }
49
+ }
50
+ })
51
+ </script>
52
+
53
+ <style scoped lang="scss">
54
+ .dl-text-holder {
55
+ display: flex;
56
+ flex-wrap: nowrap;
57
+ width: 100%;
58
+
59
+ &--value {
60
+ white-space: nowrap;
61
+ overflow: hidden;
62
+ text-overflow: ellipsis;
63
+ }
64
+ }
65
+ </style>