@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,298 @@
1
+ <template>
2
+ <div
3
+ :id="uuid"
4
+ :class="identifierClass"
5
+ class="container-wrapper"
6
+ >
7
+ <label
8
+ ref="container"
9
+ :for="computedId"
10
+ class="container"
11
+ :class="{ disabled: disabled }"
12
+ :tabindex="tabindex"
13
+ :style="cssContainerVars"
14
+ @click="onClick"
15
+ @keydown="onKeydown"
16
+ @keyup="onKeyup"
17
+ >
18
+ <span
19
+ class="checkbox-wrapper"
20
+ :style="cssSvgVars"
21
+ >
22
+ <input
23
+ :id="computedId"
24
+ :value="value"
25
+ :checked="isTrue"
26
+ type="checkbox"
27
+ tabindex="-1"
28
+ :disabled="disabled"
29
+ :style="cssSvgVars"
30
+ >
31
+ <svg
32
+ class="check"
33
+ :class="{ active: isTrue }"
34
+ width="12"
35
+ height="12"
36
+ viewBox="0 0 12 12"
37
+ :style="cssSvgVars"
38
+ >
39
+ <path
40
+ d="M10.2 0H1.8C1.32261 0 0.864773 0.189642 0.527208 0.527208C0.189642 0.864773 0 1.32261 0 1.8V10.2C0 10.4364 0.0465583 10.6704 0.137017 10.8888C0.227475 11.1072 0.360062 11.3056 0.527208 11.4728C0.694353 11.6399 0.892784 11.7725 1.11117 11.863C1.32956 11.9534 1.56362 12 1.8 12H10.2C10.4364 12 10.6704 11.9534 10.8888 11.863C11.1072 11.7725 11.3056 11.6399 11.4728 11.4728C11.6399 11.3056 11.7725 11.1072 11.863 10.8888C11.9534 10.6704 12 10.4364 12 10.2V1.8C12 1.56362 11.9534 1.32956 11.863 1.11117C11.7725 0.892784 11.6399 0.694353 11.4728 0.527208C11.3056 0.360062 11.1072 0.227475 10.8888 0.137017C10.6704 0.0465583 10.4364 0 10.2 0ZM9.426 4.014L4.95 8.778C4.8932 8.83679 4.82515 8.88355 4.7499 8.91548C4.67465 8.94742 4.59375 8.96387 4.512 8.96387C4.43025 8.96387 4.34935 8.94742 4.2741 8.91548C4.19885 8.88355 4.1308 8.83679 4.074 8.778L2.586 7.2C2.52524 7.14431 2.47661 7.07669 2.44314 7.00138C2.40966 6.92606 2.39207 6.84465 2.39145 6.76223C2.39082 6.67981 2.40719 6.59815 2.43952 6.52234C2.47185 6.44652 2.51946 6.37818 2.57937 6.32158C2.63928 6.26497 2.71021 6.22132 2.78773 6.19334C2.86526 6.16536 2.94772 6.15365 3.02997 6.15894C3.11222 6.16424 3.1925 6.18642 3.26579 6.22411C3.33909 6.2618 3.40384 6.31418 3.456 6.378L4.512 7.5L8.55 3.2C8.66154 3.10272 8.8051 3.0501 8.95309 3.05225C9.10107 3.05441 9.24304 3.11118 9.35171 3.21166C9.46037 3.31214 9.52807 3.44923 9.54178 3.5966C9.5555 3.74396 9.51426 3.8912 9.426 4.01V4.014Z"
41
+ />
42
+ </svg>
43
+ <svg
44
+ v-if="hasIndeterminateValue"
45
+ class="check"
46
+ :class="{ active: isIndeterminate }"
47
+ width="12"
48
+ height="12"
49
+ viewBox="0 0 12 12"
50
+ :style="cssSvgVars"
51
+ >
52
+ <path
53
+ fill-rule="evenodd"
54
+ clip-rule="evenodd"
55
+ d="M2 0C0.895431 0 0 0.895431 0 2V10C0 11.1046 0.895431 12 2 12H10C11.1046 12 12 11.1046 12 10V2C12 0.895431 11.1046 0 10 0H2ZM3.75 5C3.33579 5 3 5.33579 3 5.75C3 6.16421 3.33579 6.5 3.75 6.5H8.25C8.66421 6.5 9 6.16421 9 5.75C9 5.33579 8.66421 5 8.25 5H3.75Z"
56
+ />
57
+ </svg>
58
+ </span>
59
+ <span
60
+ v-if="hasLabel"
61
+ class="checkbox-label"
62
+ :for="computedId"
63
+ >
64
+ <slot>
65
+ {{ label }}
66
+ </slot>
67
+ </span>
68
+ </label>
69
+ <div
70
+ v-if="subLabel"
71
+ :style="subLabelStyle"
72
+ class="sub-text"
73
+ >
74
+ <span>{{ subLabel }}</span>
75
+ </div>
76
+ </div>
77
+ </template>
78
+
79
+ <script lang="ts">
80
+ import { defineComponent, toRaw } from 'vue-demi'
81
+ import { getColor } from '../utils'
82
+ import { v4 } from 'uuid'
83
+ import { stopAndPrevent } from '../utils'
84
+
85
+ const ValueTypes = [Array, Boolean, String, Number, Object, Function]
86
+
87
+ export default defineComponent({
88
+ name: 'DlCheckbox',
89
+ model: {
90
+ prop: 'modelValue',
91
+ event: 'update:model-value'
92
+ },
93
+ props: {
94
+ color: { type: String, default: 'dl-color-secondary' },
95
+ disabled: { type: Boolean, default: false },
96
+ id: { type: [String, Number], default: null },
97
+ modelValue: { type: ValueTypes, required: true },
98
+ label: { default: null, type: String },
99
+ subLabel: { type: String, default: '' },
100
+ toggleIndeterminate: { type: Boolean, default: false },
101
+ indeterminateValue: { type: ValueTypes, default: null },
102
+ value: { type: ValueTypes, default: null },
103
+ falseValue: { type: ValueTypes, default: false },
104
+ padding: { type: String, default: '5px' },
105
+ trueValue: { type: ValueTypes, default: true },
106
+ tabindex: { type: String, default: '0' },
107
+ subLabelSize: { type: String, default: '10px' }
108
+ },
109
+ emits: ['update:model-value', 'input', 'checked', 'unchecked'],
110
+ data() {
111
+ return {
112
+ uuid: `dl-checkbox-${v4()}`
113
+ }
114
+ },
115
+ computed: {
116
+ identifierClass(): string {
117
+ return `dl-checkbox-${this.label ?? ''}`.replaceAll(' ', '-')
118
+ },
119
+ computedId(): string {
120
+ return `${this.id || v4()}`
121
+ },
122
+ modelIsArray(): boolean {
123
+ return this.value !== null && Array.isArray(this.modelValue)
124
+ },
125
+ index(): number {
126
+ const value = toRaw(this.value)
127
+ return this.modelIsArray
128
+ ? (this.modelValue as any[]).findIndex(
129
+ (opt) => toRaw(opt) === value
130
+ )
131
+ : -1
132
+ },
133
+ isTrue(): boolean {
134
+ return this.modelIsArray
135
+ ? this.index > -1
136
+ : toRaw(this.modelValue) === toRaw(this.trueValue)
137
+ },
138
+ isFalse(): boolean {
139
+ return this.modelIsArray
140
+ ? this.index === -1
141
+ : toRaw(this.modelValue) === toRaw(this.falseValue)
142
+ },
143
+ hasIndeterminateValue(): boolean {
144
+ return this.indeterminateValue !== null
145
+ },
146
+ isIndeterminate(): boolean {
147
+ return !this.isTrue && !this.isFalse
148
+ },
149
+ cssContainerVars(): Record<string, string> {
150
+ return {
151
+ '--dl-checkbox-padding': this.padding
152
+ }
153
+ },
154
+ cssSvgVars(): Record<string, string> {
155
+ return {
156
+ '--dl-active-color': this.getCurrentColor()
157
+ }
158
+ },
159
+ hasLabel(): boolean {
160
+ return !!this.label || !!this.$slots.default
161
+ },
162
+ subLabelStyle(): Record<string, string> {
163
+ return {
164
+ 'font-size': this.subLabelSize
165
+ }
166
+ }
167
+ },
168
+ methods: {
169
+ getCurrentColor() {
170
+ if (this.disabled) {
171
+ return 'var(--dl-color-disabled)'
172
+ }
173
+ return getColor(this.color, 'dl-color-secondary')
174
+ },
175
+ onClick(e: Event) {
176
+ if (e) {
177
+ stopAndPrevent(e)
178
+ }
179
+
180
+ if (!this.disabled) {
181
+ let newValue: any | any[]
182
+ if (Array.isArray(this.modelValue)) {
183
+ newValue = this.isFalse
184
+ ? [...this.modelValue, this.value]
185
+ : this.modelValue.filter(
186
+ (element) => element !== this.value
187
+ )
188
+ } else {
189
+ newValue = this.modelValue
190
+ if (this.isIndeterminate) {
191
+ newValue = this.trueValue
192
+ }
193
+ if (this.isTrue) {
194
+ newValue = this.falseValue
195
+ }
196
+ if (this.isFalse) {
197
+ newValue = this.toggleIndeterminate
198
+ ? this.indeterminateValue
199
+ : this.trueValue
200
+ }
201
+ }
202
+
203
+ // checking the opposites to predict the next value
204
+ if (this.isTrue) {
205
+ this.$emit('unchecked', this.value)
206
+ }
207
+ if (this.isFalse) {
208
+ this.$emit('checked', this.value)
209
+ }
210
+
211
+ this.$emit('update:model-value', newValue, e)
212
+ this.$emit('input', newValue)
213
+ }
214
+ },
215
+ onKeydown(e: KeyboardEvent) {
216
+ if (e.key === 'Enter' || e.key === ' ') {
217
+ stopAndPrevent(e)
218
+ }
219
+ },
220
+ onKeyup(e: KeyboardEvent) {
221
+ if (e.key === 'Enter' || e.key === ' ') {
222
+ this.onClick(e as Event)
223
+ }
224
+ }
225
+ }
226
+ })
227
+ </script>
228
+
229
+ <style scoped lang="scss">
230
+ .container-wrapper {
231
+ display: flex;
232
+ flex-direction: column;
233
+ }
234
+
235
+ .container {
236
+ cursor: pointer;
237
+ display: inline-flex;
238
+ max-width: max-content;
239
+ align-items: center;
240
+ gap: 10px;
241
+ padding: var(--dl-checkbox-padding);
242
+ user-select: none;
243
+ }
244
+ .container.disabled {
245
+ cursor: not-allowed;
246
+ color: var(--dl-color-disabled);
247
+ & * {
248
+ pointer-events: none;
249
+ color: var(--dl-color-disabled);
250
+ }
251
+ }
252
+ .checkbox-wrapper {
253
+ display: flex;
254
+ position: relative;
255
+ width: 12px;
256
+ height: 12px;
257
+ border: 1px solid var(--dl-color-separator);
258
+ border-radius: 2px;
259
+ & svg {
260
+ transition: fill 100ms cubic-bezier(0, 0, 0.2, 1) 0ms;
261
+ overflow: visible;
262
+ fill: transparent;
263
+ }
264
+ & .active {
265
+ fill: var(--dl-active-color);
266
+ }
267
+ }
268
+ input {
269
+ appearance: none;
270
+ margin: 0;
271
+ position: absolute;
272
+ width: 100%;
273
+ height: 100%;
274
+ }
275
+
276
+ .sub-text {
277
+ margin-left: 6%;
278
+ width: 80%;
279
+ color: var(--dl-color-medium);
280
+ word-break: break-all;
281
+ }
282
+
283
+ .label-wrapper {
284
+ display: flex;
285
+ flex-direction: column;
286
+ }
287
+
288
+ .checkbox-label {
289
+ font-size: var(--dl-font-size-body);
290
+ color: var(--dl-color-darker);
291
+ }
292
+ .check {
293
+ position: absolute;
294
+ margin: -1px 0 0 -1px;
295
+ width: 120%;
296
+ height: 120%;
297
+ }
298
+ </style>
@@ -0,0 +1,244 @@
1
+ <template>
2
+ <div
3
+ :id="uuid"
4
+ ref="dlChipRef"
5
+ :tabindex="tabIndex"
6
+ class="dl-chip"
7
+ :style="cssChipVars"
8
+ >
9
+ <slot name="prefix" />
10
+ <span
11
+ v-if="hasIcon"
12
+ class="dl-chip-left-icon-container"
13
+ >
14
+ <dl-icon
15
+ class="dl-chip-left-icon"
16
+ size="12px"
17
+ :icon="icon"
18
+ />
19
+ </span>
20
+ <slot>
21
+ {{ hasLabel ? label : null }}
22
+ </slot>
23
+ <dl-tooltip v-if="overflow && isOverflowing">
24
+ {{ label }}
25
+ </dl-tooltip>
26
+ <span
27
+ v-if="removable"
28
+ class="dl-chip-remove-icon-container"
29
+ @click="onRemove"
30
+ >
31
+ <dl-icon
32
+ class="dl-chip-remove-icon"
33
+ size="7px"
34
+ icon="icon-dl-close"
35
+ /></span>
36
+ </div>
37
+ </template>
38
+
39
+ <script lang="ts">
40
+ import { defineComponent, ref } from 'vue-demi'
41
+ import DlTooltip from '../../components/DlTooltip.vue'
42
+ import DLIcon from '../../components/DlIcon.vue'
43
+ import { useSizeObserver } from '../../hooks/use-size-observer'
44
+ import {
45
+ setTextColor,
46
+ setBgColor,
47
+ setBorder,
48
+ setPadding,
49
+ setLeftIconColor,
50
+ setMaxWidth,
51
+ setRemoveIconWidth
52
+ } from './utils'
53
+ import { v4 } from 'uuid'
54
+
55
+ const transformOptions: string[] = [
56
+ 'none',
57
+ 'capitalize',
58
+ 'uppercase',
59
+ 'lowercase',
60
+ 'full-width',
61
+ 'full-size-kana',
62
+ 'inherit',
63
+ 'initial',
64
+ 'revert',
65
+ 'revert-layer',
66
+ 'unset'
67
+ ]
68
+
69
+ export default defineComponent({
70
+ name: 'DlChip',
71
+ components: {
72
+ 'dl-tooltip': DlTooltip,
73
+ 'dl-icon': DLIcon
74
+ },
75
+ props: {
76
+ disabled: Boolean,
77
+ filled: { type: Boolean, default: true },
78
+ outlined: Boolean,
79
+ color: { type: String, default: 'dl-color-secondary' },
80
+ textColor: { type: String, default: '' },
81
+ icon: { type: String, default: '' },
82
+ iconColor: { type: String, default: '' },
83
+ label: { type: [String, Number], default: '' },
84
+ maxWidth: { type: [String, Number], default: '' },
85
+ removable: Boolean,
86
+ tabIndex: { type: [String, Number], default: '' },
87
+ transform: {
88
+ type: String,
89
+ default: 'lowercase',
90
+ validator: (value: string): boolean =>
91
+ transformOptions.includes(value)
92
+ },
93
+ overflow: { type: Boolean, default: false }
94
+ },
95
+ emits: ['remove'],
96
+ setup() {
97
+ const dlChipRef = ref(null)
98
+ const { hasEllipsis } = useSizeObserver(dlChipRef)
99
+
100
+ return {
101
+ uuid: `dl-chip-${v4()}`,
102
+ dlChipRef,
103
+ isOverflowing: hasEllipsis
104
+ }
105
+ },
106
+ computed: {
107
+ hasLabel(): boolean {
108
+ return (
109
+ this.label !== void 0 &&
110
+ this.label !== null &&
111
+ this.label !== ''
112
+ )
113
+ },
114
+ hasIcon(): boolean {
115
+ return typeof this.icon === 'string' && this.icon !== ''
116
+ },
117
+ computedIconColor(): string {
118
+ if (this.outlined && !this.iconColor) {
119
+ return 'dl-color-secondary'
120
+ }
121
+
122
+ if (this.filled && !this.iconColor) {
123
+ return 'dl-color-white'
124
+ }
125
+
126
+ return this.iconColor
127
+ },
128
+ cssChipVars(): Record<string, string | number> {
129
+ return {
130
+ '--dl-chip-max-width': setMaxWidth(this.maxWidth),
131
+ '--dl-chip-remove-icon-width': setRemoveIconWidth({
132
+ hasLabel: this.hasLabel,
133
+ removable: this.removable,
134
+ hasIcon: this.hasIcon
135
+ }),
136
+ '--dl-chip-text-color': setTextColor({
137
+ outlined: this.outlined,
138
+ filled: this.filled,
139
+ disabled: this.disabled,
140
+ textColor: this.textColor
141
+ }),
142
+ '--dl-chip-bg-color': setBgColor({
143
+ outlined: this.outlined,
144
+ disabled: this.disabled,
145
+ color: this.color
146
+ }),
147
+ '--dl-chip-border': setBorder({
148
+ disabled: this.disabled,
149
+ color: this.color
150
+ }),
151
+ '--dl-chip-padding': setPadding({
152
+ hasLabel: this.hasLabel,
153
+ removable: this.removable,
154
+ hasIcon: this.hasIcon
155
+ }),
156
+ '--dl-chip-left-icon-color': setLeftIconColor({
157
+ color: this.computedIconColor,
158
+ disabled: this.disabled
159
+ }),
160
+ '--dl-chip-left-icon-active-opacity': this.disabled ? 1 : 0.5,
161
+ '--dl-chip-left-icon-hover-opacity': this.disabled ? 1 : 0.8,
162
+ '--dl-chip-left-icon-cursor': this.disabled
163
+ ? 'not-allowed'
164
+ : 'pointer',
165
+ '--dl-chip-text-transform': this.transform
166
+ }
167
+ }
168
+ },
169
+ methods: {
170
+ onRemove(e: Event) {
171
+ if (!this.disabled) {
172
+ this.$emit('remove', this.label)
173
+ }
174
+ }
175
+ }
176
+ })
177
+ </script>
178
+
179
+ <style scoped lang="scss">
180
+ .dl-chip {
181
+ position: relative;
182
+ vertical-align: middle;
183
+ text-transform: var(--dl-chip-text-transform);
184
+ font-size: var(--dl-font-size-body);
185
+ line-height: 12px;
186
+ border-radius: 2px;
187
+ padding: var(--dl-chip-padding);
188
+ outline: 0;
189
+ min-width: 18px; // +2px from borders
190
+ max-height: 18px; // +2px from borders
191
+ min-height: 12px;
192
+ height: fit-content;
193
+ max-width: var(--dl-chip-max-width);
194
+ width: fit-content;
195
+ color: var(--dl-chip-text-color);
196
+ background-color: var(--dl-chip-bg-color);
197
+ white-space: nowrap;
198
+ overflow: hidden;
199
+ text-overflow: ellipsis;
200
+ border: var(--dl-chip-border);
201
+ &::first-letter,
202
+ & > *::first-letter {
203
+ text-transform: capitalize;
204
+ }
205
+ }
206
+ .dl-chip-remove-icon-container {
207
+ cursor: var(--dl-chip-left-icon-cursor);
208
+ position: absolute;
209
+ display: flex;
210
+ justify-content: center;
211
+ align-items: center;
212
+ width: var(--dl-chip-remove-icon-width); // +2px from borders
213
+ top: 0;
214
+ bottom: 0;
215
+ right: 0;
216
+ &:active {
217
+ opacity: var(--dl-chip-left-icon-active-opacity);
218
+ }
219
+ &:hover:not(:disabled) {
220
+ opacity: var(--dl-chip-left-icon-hover-opacity);
221
+ }
222
+ }
223
+
224
+ .dl-chip-left-icon-container {
225
+ @extend .dl-chip-remove-icon-container;
226
+ cursor: text;
227
+ left: 0;
228
+ width: 18px;
229
+ &:active {
230
+ opacity: 1;
231
+ }
232
+ &:hover:not(:active) {
233
+ opacity: 1;
234
+ }
235
+ }
236
+
237
+ .dl-chip-left-icon {
238
+ color: var(--dl-chip-left-icon-color);
239
+ }
240
+
241
+ .dl-chip-remove-icon {
242
+ color: var(--dl-chip-text-color);
243
+ }
244
+ </style>
@@ -0,0 +1,4 @@
1
+ import DlChip from './DlChip.vue'
2
+
3
+ export default DlChip
4
+ export * from './utils'
@@ -0,0 +1,100 @@
1
+ import { getColor } from '../../utils'
2
+
3
+ interface ChipProps {
4
+ hasIcon: boolean
5
+ hasLabel: boolean
6
+ removable: boolean
7
+ disabled: boolean
8
+ outlined: boolean
9
+ filled: boolean
10
+ color: string
11
+ textColor: string
12
+ }
13
+
14
+ export const setTextColor = ({
15
+ disabled,
16
+ outlined,
17
+ filled,
18
+ textColor = ''
19
+ }: Partial<ChipProps>): string => {
20
+ if (disabled) {
21
+ return getColor('', 'dl-color-disabled')
22
+ }
23
+ if (outlined) {
24
+ return getColor(textColor, 'dl-color-secondary')
25
+ }
26
+ if (filled) {
27
+ return getColor(textColor, 'dl-color-text-buttons')
28
+ }
29
+
30
+ return getColor(textColor, 'dl-color-text-buttons')
31
+ }
32
+
33
+ export const setBgColor = ({
34
+ disabled,
35
+ outlined,
36
+ color = ''
37
+ }: Partial<ChipProps>) => {
38
+ if (disabled || outlined) {
39
+ return 'transparent'
40
+ }
41
+
42
+ return getColor(color, 'dl-color-secondary')
43
+ }
44
+
45
+ export const setBorder = ({ disabled, color = '' }: Partial<ChipProps>) => {
46
+ if (disabled) {
47
+ return `1px solid var(--dl-color-disabled)`
48
+ }
49
+
50
+ return `1px solid ${getColor(color, 'dl-color-secondary')}`
51
+ }
52
+
53
+ export const setPadding = ({
54
+ hasLabel,
55
+ removable,
56
+ hasIcon
57
+ }: Partial<ChipProps>) => {
58
+ const left = hasIcon ? 20 : 5
59
+ const right = removable ? 20 : 5
60
+
61
+ if (hasLabel && (removable || hasIcon)) {
62
+ return `3px ${right}px 3px ${left}px`
63
+ }
64
+
65
+ if (!hasLabel && hasIcon && removable) {
66
+ return `3px ${right}px 3px 0`
67
+ }
68
+ if (removable || hasIcon) {
69
+ return '3px 0'
70
+ }
71
+
72
+ return '3px 5px'
73
+ }
74
+
75
+ export const setRemoveIconWidth = ({
76
+ hasLabel,
77
+ removable,
78
+ hasIcon
79
+ }: Partial<ChipProps>) => {
80
+ const iconWidth = (hasLabel || hasIcon) && removable ? 14 : 18
81
+
82
+ return `${iconWidth}px`
83
+ }
84
+
85
+ export const setMaxWidth = (maxWidth: string | number) => {
86
+ if (maxWidth) {
87
+ if (typeof maxWidth === 'string') {
88
+ return maxWidth
89
+ }
90
+ return `${maxWidth}px`
91
+ }
92
+
93
+ return '100px'
94
+ }
95
+
96
+ export const setLeftIconColor = ({
97
+ color = '',
98
+ disabled
99
+ }: Partial<ChipProps>) =>
100
+ getColor(disabled ? 'dl-color-disabled' : color, 'dl-color-secondary')