@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,108 @@
1
+ <template>
2
+ <div
3
+ :id="uuid"
4
+ :class="identifierClass"
5
+ class="accordion"
6
+ >
7
+ <accordion-header
8
+ :additional-info="additionalInfo"
9
+ :default-opened="defaultOpened"
10
+ :title="title"
11
+ :font-size="fontSize"
12
+ :title-color="titleColor"
13
+ :right-side="rightSide"
14
+ :is-open="isOpen"
15
+ data-test-id="accordion-header"
16
+ @click="handleClick"
17
+ >
18
+ <template
19
+ v-if="hasHeaderSlot"
20
+ #header
21
+ >
22
+ <slot name="header" />
23
+ </template>
24
+ </accordion-header>
25
+ <div
26
+ ref="dlAccordionContent"
27
+ class="accordion-content"
28
+ :class="{ closed: !isOpen, 'right-side': rightSide }"
29
+ >
30
+ <slot v-if="isOpen" />
31
+ </div>
32
+ </div>
33
+ </template>
34
+
35
+ <script lang="ts">
36
+ import AccordionHeader from './AccordionHeader.vue'
37
+ import { defineComponent } from 'vue-demi'
38
+ import { v4 } from 'uuid'
39
+
40
+ export default defineComponent({
41
+ name: 'DlAccordion',
42
+ components: {
43
+ AccordionHeader
44
+ },
45
+ model: {
46
+ prop: 'modelValue',
47
+ event: 'update:model-value'
48
+ },
49
+ props: {
50
+ additionalInfo: { type: String!, default: '' },
51
+ defaultOpened: { type: Boolean, default: false },
52
+ title: { type: String, default: null },
53
+ fontSize: { type: String, default: '12px' },
54
+ titleColor: { type: String, default: 'dl-color-medium' },
55
+ modelValue: { type: Boolean, default: null },
56
+ rightSide: { type: Boolean, default: false }
57
+ },
58
+ emits: ['update:model-value', 'hide', 'show'],
59
+ data() {
60
+ return {
61
+ uuid: `dl-accordion-${v4()}`,
62
+ isOpen:
63
+ this.modelValue === null ? this.defaultOpened : this.modelValue
64
+ }
65
+ },
66
+ computed: {
67
+ identifierClass(): string {
68
+ return `dl-accordion-${this.title ?? ''}`.replaceAll(' ', '-')
69
+ },
70
+ hasHeaderSlot(): boolean {
71
+ return this.$slots.header !== undefined
72
+ }
73
+ },
74
+ methods: {
75
+ handleClick() {
76
+ if (this.modelValue !== null) {
77
+ this.$emit('update:model-value', !this.isOpen)
78
+ }
79
+ this.$emit(this.isOpen === true ? 'hide' : 'show')
80
+ this.isOpen = !this.isOpen
81
+ }
82
+ }
83
+ })
84
+ </script>
85
+
86
+ <style scoped lang="scss">
87
+ .accordion {
88
+ max-width: 100%;
89
+ }
90
+ .accordion-content {
91
+ text-align: left;
92
+ font-size: var(--dl-font-size-body);
93
+ transition: all 300ms;
94
+ line-height: 16px;
95
+ padding: 0 16px 15px 38px;
96
+ color: var(--dl-color-darker);
97
+ border-bottom: 1px solid var(--dl-color-separator);
98
+ max-height: fit-content;
99
+ overflow: hidden;
100
+ &.right-side {
101
+ padding: 0 38px 16px 16px;
102
+ }
103
+ &.closed {
104
+ border-color: transparent;
105
+ padding-bottom: 0;
106
+ }
107
+ }
108
+ </style>
@@ -0,0 +1,2 @@
1
+ import DlAccordion from './DlAccordion.vue'
2
+ export { DlAccordion }
@@ -0,0 +1,227 @@
1
+ <template>
2
+ <div
3
+ v-if="show"
4
+ :id="uuid"
5
+ ref="rootRef"
6
+ class="root"
7
+ :style="rootStyle"
8
+ data-test="root"
9
+ >
10
+ <div>
11
+ <div
12
+ :style="iconStyle"
13
+ data-test="icon"
14
+ >
15
+ <dl-icon
16
+ :icon="icon"
17
+ :color="iconColor"
18
+ size="16px"
19
+ />
20
+ </div>
21
+ <span
22
+ class="text"
23
+ :style="textStyle"
24
+ ><slot v-if="!text" /> <span v-else> {{ text }}</span></span>
25
+ </div>
26
+ <div
27
+ v-if="closable"
28
+ class="close-btn"
29
+ data-test="close-btn"
30
+ >
31
+ <dl-icon
32
+ class="close-btn-icon"
33
+ data-test="close-btn-icon"
34
+ icon="icon-dl-close"
35
+ :color="iconColor"
36
+ size="8px"
37
+ @click="handleClose"
38
+ />
39
+ </div>
40
+ </div>
41
+ </template>
42
+
43
+ <script lang="ts">
44
+ import { v4 } from 'uuid'
45
+ import { computed, defineComponent, onMounted, Ref, ref, watch } from 'vue-demi'
46
+ import { getColor, includes } from '../utils'
47
+ import { DlIcon } from './'
48
+
49
+ type AlertType = 'info' | 'success' | 'warning' | 'error'
50
+
51
+ const typeToIconMap: Record<AlertType, string> = {
52
+ info: 'icon-dl-info-filled',
53
+ success: 'icon-dl-approve-filled',
54
+ warning: 'icon-dl-alert-filled',
55
+ error: 'icon-dl-alert-filled'
56
+ }
57
+
58
+ const typeToIconColorMap: Record<AlertType, string> = {
59
+ info: 'dl-color-info',
60
+ success: 'dl-color-positive',
61
+ warning: 'dl-color-warning',
62
+ error: 'dl-color-negative'
63
+ }
64
+
65
+ const typeToBackgroundMap: Record<AlertType, string> = {
66
+ info: 'dl-color-info-background',
67
+ success: 'dl-color-positive-background',
68
+ warning: 'dl-color-warning-background',
69
+ error: 'dl-color-negative-background'
70
+ }
71
+
72
+ export default defineComponent({
73
+ name: 'DlAlert',
74
+ components: {
75
+ DlIcon
76
+ },
77
+ model: {
78
+ prop: 'modelValue',
79
+ event: 'update:model-value'
80
+ },
81
+ props: {
82
+ modelValue: {
83
+ type: Boolean,
84
+ default: true
85
+ },
86
+ type: {
87
+ type: String,
88
+ default: 'success',
89
+ validator: (value: string) =>
90
+ includes(['info', 'success', 'warning', 'error'], value)
91
+ },
92
+ textColor: {
93
+ type: String,
94
+ default: 'dl-color-darker'
95
+ },
96
+ fluid: {
97
+ type: Boolean,
98
+ default: false
99
+ },
100
+ closable: {
101
+ type: Boolean,
102
+ default: false
103
+ },
104
+ text: {
105
+ type: String,
106
+ default: null
107
+ }
108
+ },
109
+ emits: ['update:model-value'],
110
+ setup(props, { emit }) {
111
+ const show = ref(props.modelValue)
112
+ const type = props.type as AlertType
113
+ const icon = computed(() => typeToIconMap[type])
114
+ const iconColor = computed(() => typeToIconColorMap[type])
115
+ const textStyle = computed(() => ({
116
+ color: getColor(props.textColor, 'dl-color-darker')
117
+ }))
118
+
119
+ const rootRef = ref(null)
120
+ const rootStyle = ref()
121
+ const iconStyle = ref()
122
+
123
+ onMounted(() => {
124
+ normalizeStyles(props.fluid)
125
+ })
126
+
127
+ watch(
128
+ () => props.modelValue,
129
+ (val) => {
130
+ show.value = val
131
+ }
132
+ )
133
+
134
+ watch(
135
+ [() => props.fluid, () => props.text, () => props.closable],
136
+ ([fluid]) => {
137
+ normalizeStyles(fluid)
138
+ }
139
+ )
140
+
141
+ function normalizeStyles(fluid?: boolean) {
142
+ const { height } = (
143
+ rootRef as Ref<HTMLElement | null>
144
+ ).value!.getBoundingClientRect()
145
+
146
+ const iconS: Record<string, any> = {
147
+ display: 'flex'
148
+ }
149
+
150
+ const rootS: Record<string, any> = {
151
+ backgroundColor: getColor(typeToBackgroundMap[type])
152
+ }
153
+
154
+ if (height > 36) {
155
+ iconS.alignSelf = 'flex-start'
156
+ } else {
157
+ iconS.alignSelf = 'center'
158
+ }
159
+
160
+ if (fluid === true) {
161
+ rootS.width = '100%'
162
+ } else {
163
+ rootS.width = 'fit-content'
164
+ }
165
+
166
+ iconStyle.value = iconS
167
+ rootStyle.value = rootS
168
+ }
169
+
170
+ function handleClose() {
171
+ show.value = false
172
+ emit('update:model-value', false)
173
+ }
174
+
175
+ return {
176
+ uuid: `dl-alert-${v4()}`,
177
+ rootRef,
178
+ show,
179
+ icon,
180
+ iconColor,
181
+ rootStyle,
182
+ iconStyle,
183
+ textStyle,
184
+ handleClose
185
+ }
186
+ },
187
+ template: 'dl-alert'
188
+ })
189
+ </script>
190
+
191
+ <style scoped lang="scss">
192
+ .root {
193
+ display: inline-flex;
194
+ flex-direction: row;
195
+ justify-content: space-between;
196
+ min-height: 36px;
197
+ border-radius: 2px;
198
+ box-sizing: border-box;
199
+
200
+ > div {
201
+ display: flex;
202
+ flex-direction: row;
203
+ padding: 10px;
204
+ }
205
+
206
+ .text {
207
+ display: flex;
208
+ text-align: left;
209
+ padding-left: 10px;
210
+ font-size: var(--dl-font-size-body);
211
+ align-self: center;
212
+ word-break: break-word;
213
+ }
214
+
215
+ .close-btn {
216
+ padding: 5px 5px 0 0;
217
+ }
218
+
219
+ .icon-dl-close:hover {
220
+ cursor: pointer;
221
+ }
222
+
223
+ .close-btn-icon:hover {
224
+ cursor: pointer;
225
+ }
226
+ }
227
+ </style>
@@ -0,0 +1,99 @@
1
+ <template>
2
+ <div
3
+ :id="uuid"
4
+ class="avatar"
5
+ :style="cssVars"
6
+ @click="handleClick"
7
+ >
8
+ <span class="avatar-content">
9
+ <span v-if="name">
10
+ {{ computedLetters }}
11
+ </span>
12
+ <slot v-else />
13
+ <dl-tooltip v-if="tooltip">
14
+ {{ tooltip }}
15
+ </dl-tooltip>
16
+ </span>
17
+ </div>
18
+ </template>
19
+
20
+ <script lang="ts">
21
+ import { defineComponent } from 'vue-demi'
22
+ import DlTooltip from './DlTooltip.vue'
23
+ import { getColor } from '../utils'
24
+ import { v4 } from 'uuid'
25
+
26
+ export default defineComponent({
27
+ components: {
28
+ DlTooltip
29
+ },
30
+ props: {
31
+ textColor: { type: String, default: 'dl-color-white' },
32
+ color: { type: String, default: 'dl-color-secondary' },
33
+ size: { type: String, default: '20px' },
34
+ name: { type: String, default: null },
35
+ tooltip: { type: String, default: null }
36
+ },
37
+ data() {
38
+ return {
39
+ uuid: `dl-avatar-${v4()}`
40
+ }
41
+ },
42
+ computed: {
43
+ computedLetters(): string {
44
+ const firstLetters = this.name
45
+ .split(' ')
46
+ .map((w) => w[0])
47
+ .join('')
48
+ if (firstLetters.length === 1) {
49
+ return firstLetters[0]
50
+ }
51
+ return `${firstLetters[0]}${firstLetters[firstLetters.length - 1]}`
52
+ },
53
+ cssVars(): Record<string, string> {
54
+ return {
55
+ '--dl-avatar-bg-color': getColor(
56
+ this.color,
57
+ 'dl-color-secondary'
58
+ ),
59
+ '--dl-avatar-text-color': getColor(
60
+ this.textColor,
61
+ 'dl-color-white'
62
+ ),
63
+ '--dl-avatar-size': this.size
64
+ }
65
+ }
66
+ },
67
+ methods: {
68
+ handleClick(e: MouseEvent) {
69
+ this.$emit('click', e)
70
+ }
71
+ }
72
+ })
73
+ </script>
74
+
75
+ <style lang="scss" scoped>
76
+ .avatar {
77
+ width: var(--dl-avatar-size);
78
+ height: var(--dl-avatar-size);
79
+ border-radius: 50%;
80
+ user-select: none;
81
+ overflow: hidden;
82
+ color: var(--dl-avatar-text-color);
83
+ background-color: var(--dl-avatar-bg-color);
84
+ &::v-deep img {
85
+ height: var(--dl-avatar-size);
86
+ width: var(--dl-avatar-size);
87
+ }
88
+ }
89
+
90
+ .avatar-content {
91
+ width: 100%;
92
+ height: 100%;
93
+ display: flex;
94
+ justify-content: center;
95
+ align-items: center;
96
+ font-size: calc(var(--dl-avatar-size) / 10 * 6);
97
+ line-height: 1;
98
+ }
99
+ </style>
@@ -0,0 +1,127 @@
1
+ <template>
2
+ <div
3
+ :id="uuid"
4
+ :class="classes"
5
+ :style="style"
6
+ role="status"
7
+ >
8
+ <slot v-if="hasSlot" />
9
+ <span v-else>{{ label }}</span>
10
+ </div>
11
+ </template>
12
+
13
+ <script lang="ts">
14
+ import { v4 } from 'uuid'
15
+ import { computed } from 'vue-demi'
16
+ import { defineComponent } from 'vue-demi'
17
+
18
+ const alignValues = ['top', 'middle', 'bottom']
19
+
20
+ export default defineComponent({
21
+ props: {
22
+ color: { type: String, default: 'var(--dl-color-negative)' },
23
+ textColor: { type: String, default: 'var(--dl-color-text-buttons)' },
24
+
25
+ floating: { type: Boolean, default: false },
26
+ transparent: { type: Boolean, default: false },
27
+ multiline: { type: Boolean, default: false },
28
+ outline: { type: Boolean, default: false },
29
+ rounded: { type: Boolean, default: true },
30
+
31
+ label: { type: String, default: null },
32
+
33
+ align: {
34
+ type: String,
35
+ default: null,
36
+ validator: (v: string) => alignValues.includes(v)
37
+ }
38
+ },
39
+
40
+ setup(props, { slots }) {
41
+ const hasSlot = computed(() => slots.default)
42
+
43
+ const style = computed(() => {
44
+ return {
45
+ verticalAlign: props.align !== void 0 ? props.align : null,
46
+ aspectRatio: hasSlot.value || props.label ? '' : '1/1',
47
+ padding:
48
+ hasSlot.value || props.label
49
+ ? `3px ${props.multiline ? '8px' : ''}`
50
+ : '',
51
+ '--dl-color-badge': props.color,
52
+ '--dl-color-badge-text': props.textColor
53
+ }
54
+ })
55
+
56
+ const classes = computed(() => {
57
+ const text =
58
+ props.outline === true
59
+ ? props.color || props.textColor
60
+ : props.textColor
61
+
62
+ return (
63
+ 'dl-badge flex inline items-center no-wrap' +
64
+ ` dl-badge--${
65
+ props.multiline === true ? 'multi' : 'single'
66
+ }-line` +
67
+ (props.outline === true
68
+ ? ' dl-badge--outline'
69
+ : props.color !== void 0
70
+ ? ` bg-${props.color}`
71
+ : '') +
72
+ (text !== void 0 ? ` text-${text}` : '') +
73
+ (props.floating === true ? ' dl-badge--floating' : '') +
74
+ (props.rounded === true ? ' dl-badge--rounded' : '') +
75
+ (props.transparent === true ? ' dl-badge--transparent' : '')
76
+ )
77
+ })
78
+
79
+ return {
80
+ uuid: `dl-badge-${v4()}`,
81
+ classes,
82
+ style,
83
+ hasSlot
84
+ }
85
+ }
86
+ })
87
+ </script>
88
+
89
+ <style scoped lang="scss">
90
+ .dl-badge {
91
+ background-color: var(--dl-color-badge);
92
+ color: var(--dl-color-badge-text);
93
+ border-radius: 2px;
94
+ font-size: 12px;
95
+ line-height: 12px;
96
+ min-height: 12px;
97
+ font-weight: normal;
98
+ vertical-align: baseline;
99
+
100
+ &--single-line {
101
+ white-space: nowrap;
102
+ display: inline-block;
103
+ overflow: hidden;
104
+ text-overflow: ellipsis;
105
+ }
106
+ &--multi-line {
107
+ word-break: break-all;
108
+ word-wrap: break-word;
109
+ }
110
+ &--floating {
111
+ position: absolute;
112
+ top: -4px;
113
+ right: -3px;
114
+ cursor: inherit;
115
+ }
116
+ &--transparent {
117
+ opacity: 0.8;
118
+ }
119
+ &--outline {
120
+ background-color: transparent;
121
+ border: 1px solid var(--dl-color-badge);
122
+ }
123
+ &--rounded {
124
+ border-radius: 1em;
125
+ }
126
+ }
127
+ </style>