@ngbase/adk 0.1.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 (355) hide show
  1. package/README.md +57 -0
  2. package/a11y/accessibility-group.d.ts +49 -0
  3. package/a11y/accessibility-item.d.ts +49 -0
  4. package/a11y/accessibility.service.d.ts +17 -0
  5. package/a11y/autofocus.d.ts +12 -0
  6. package/a11y/focus-trap.d.ts +15 -0
  7. package/a11y/index.d.ts +5 -0
  8. package/a11y/public-api.d.ts +4 -0
  9. package/accordion/accordion-content.d.ts +8 -0
  10. package/accordion/accordion-group.d.ts +10 -0
  11. package/accordion/accordion-header.d.ts +7 -0
  12. package/accordion/accordion-item.d.ts +10 -0
  13. package/accordion/index.d.ts +5 -0
  14. package/accordion/public-api.d.ts +4 -0
  15. package/autocomplete/autocomplete-input.d.ts +21 -0
  16. package/autocomplete/autocomplete.d.ts +25 -0
  17. package/autocomplete/index.d.ts +5 -0
  18. package/autocomplete/public-api.d.ts +2 -0
  19. package/avatar/avatar.d.ts +22 -0
  20. package/avatar/index.d.ts +5 -0
  21. package/avatar/public-api.d.ts +1 -0
  22. package/bidi/direction.service.d.ts +14 -0
  23. package/bidi/index.d.ts +5 -0
  24. package/bidi/public-api.d.ts +1 -0
  25. package/breadcrumb/breadcrumb-link.d.ts +7 -0
  26. package/breadcrumb/breadcrumb-separator.d.ts +10 -0
  27. package/breadcrumb/breadcrumb.d.ts +12 -0
  28. package/breadcrumb/breadcrumbs.d.ts +7 -0
  29. package/breadcrumb/index.d.ts +5 -0
  30. package/breadcrumb/public-api.d.ts +4 -0
  31. package/cache/cache-config.d.ts +22 -0
  32. package/cache/cache.d.ts +17 -0
  33. package/cache/cache.interecptor.d.ts +2 -0
  34. package/cache/index.d.ts +5 -0
  35. package/cache/public-api.d.ts +3 -0
  36. package/carousel/carousel-item.d.ts +7 -0
  37. package/carousel/carousel-next.d.ts +8 -0
  38. package/carousel/carousel.d.ts +61 -0
  39. package/carousel/index.d.ts +5 -0
  40. package/carousel/public-api.d.ts +3 -0
  41. package/checkbox/checkbox.d.ts +22 -0
  42. package/checkbox/index.d.ts +5 -0
  43. package/checkbox/public-api.d.ts +1 -0
  44. package/chip/chip-group.d.ts +7 -0
  45. package/chip/chip.d.ts +19 -0
  46. package/chip/index.d.ts +5 -0
  47. package/chip/public-api.d.ts +2 -0
  48. package/clipboard/clipboard.d.ts +7 -0
  49. package/clipboard/index.d.ts +5 -0
  50. package/clipboard/public-api.d.ts +1 -0
  51. package/collections/SelectionModel.d.ts +14 -0
  52. package/collections/index.d.ts +5 -0
  53. package/collections/public-api.d.ts +1 -0
  54. package/color-picker/color-input.d.ts +16 -0
  55. package/color-picker/color-picker-trigger.d.ts +30 -0
  56. package/color-picker/color-picker.d.ts +72 -0
  57. package/color-picker/index.d.ts +5 -0
  58. package/color-picker/public-api.d.ts +3 -0
  59. package/color-picker/utils.d.ts +21 -0
  60. package/cookies/cookie.service.d.ts +32 -0
  61. package/cookies/index.d.ts +5 -0
  62. package/cookies/public-api.d.ts +1 -0
  63. package/datepicker/calendar.d.ts +121 -0
  64. package/datepicker/datepicker-trigger.d.ts +49 -0
  65. package/datepicker/datepicker.d.ts +54 -0
  66. package/datepicker/index.d.ts +5 -0
  67. package/datepicker/native-date-adapter.d.ts +33 -0
  68. package/datepicker/public-api.d.ts +5 -0
  69. package/datepicker/time.d.ts +42 -0
  70. package/dialog/dialog.animation.d.ts +3 -0
  71. package/dialog/dialog.d.ts +49 -0
  72. package/dialog/dialog.service.d.ts +7 -0
  73. package/dialog/index.d.ts +5 -0
  74. package/dialog/public-api.d.ts +3 -0
  75. package/drag/drag-drop.d.ts +37 -0
  76. package/drag/drag-move.d.ts +17 -0
  77. package/drag/drag.d.ts +53 -0
  78. package/drag/index.d.ts +5 -0
  79. package/drag/public-api.d.ts +3 -0
  80. package/fesm2022/ngbase-adk-a11y.mjs +617 -0
  81. package/fesm2022/ngbase-adk-a11y.mjs.map +1 -0
  82. package/fesm2022/ngbase-adk-accordion.mjs +117 -0
  83. package/fesm2022/ngbase-adk-accordion.mjs.map +1 -0
  84. package/fesm2022/ngbase-adk-autocomplete.mjs +150 -0
  85. package/fesm2022/ngbase-adk-autocomplete.mjs.map +1 -0
  86. package/fesm2022/ngbase-adk-avatar.mjs +69 -0
  87. package/fesm2022/ngbase-adk-avatar.mjs.map +1 -0
  88. package/fesm2022/ngbase-adk-bidi.mjs +42 -0
  89. package/fesm2022/ngbase-adk-bidi.mjs.map +1 -0
  90. package/fesm2022/ngbase-adk-breadcrumb.mjs +103 -0
  91. package/fesm2022/ngbase-adk-breadcrumb.mjs.map +1 -0
  92. package/fesm2022/ngbase-adk-cache.mjs +127 -0
  93. package/fesm2022/ngbase-adk-cache.mjs.map +1 -0
  94. package/fesm2022/ngbase-adk-carousel.mjs +337 -0
  95. package/fesm2022/ngbase-adk-carousel.mjs.map +1 -0
  96. package/fesm2022/ngbase-adk-checkbox.mjs +78 -0
  97. package/fesm2022/ngbase-adk-checkbox.mjs.map +1 -0
  98. package/fesm2022/ngbase-adk-chip.mjs +60 -0
  99. package/fesm2022/ngbase-adk-chip.mjs.map +1 -0
  100. package/fesm2022/ngbase-adk-clipboard.mjs +41 -0
  101. package/fesm2022/ngbase-adk-clipboard.mjs.map +1 -0
  102. package/fesm2022/ngbase-adk-collections.mjs +39 -0
  103. package/fesm2022/ngbase-adk-collections.mjs.map +1 -0
  104. package/fesm2022/ngbase-adk-color-picker.mjs +580 -0
  105. package/fesm2022/ngbase-adk-color-picker.mjs.map +1 -0
  106. package/fesm2022/ngbase-adk-cookies.mjs +81 -0
  107. package/fesm2022/ngbase-adk-cookies.mjs.map +1 -0
  108. package/fesm2022/ngbase-adk-datepicker.mjs +1130 -0
  109. package/fesm2022/ngbase-adk-datepicker.mjs.map +1 -0
  110. package/fesm2022/ngbase-adk-dialog.mjs +223 -0
  111. package/fesm2022/ngbase-adk-dialog.mjs.map +1 -0
  112. package/fesm2022/ngbase-adk-drag.mjs +406 -0
  113. package/fesm2022/ngbase-adk-drag.mjs.map +1 -0
  114. package/fesm2022/ngbase-adk-form-field.mjs +364 -0
  115. package/fesm2022/ngbase-adk-form-field.mjs.map +1 -0
  116. package/fesm2022/ngbase-adk-hover-card.mjs +79 -0
  117. package/fesm2022/ngbase-adk-hover-card.mjs.map +1 -0
  118. package/fesm2022/ngbase-adk-icon.mjs +90 -0
  119. package/fesm2022/ngbase-adk-icon.mjs.map +1 -0
  120. package/fesm2022/ngbase-adk-inline-edit.mjs +127 -0
  121. package/fesm2022/ngbase-adk-inline-edit.mjs.map +1 -0
  122. package/fesm2022/ngbase-adk-jwt.mjs +90 -0
  123. package/fesm2022/ngbase-adk-jwt.mjs.map +1 -0
  124. package/fesm2022/ngbase-adk-keys.mjs +219 -0
  125. package/fesm2022/ngbase-adk-keys.mjs.map +1 -0
  126. package/fesm2022/ngbase-adk-layout.mjs +100 -0
  127. package/fesm2022/ngbase-adk-layout.mjs.map +1 -0
  128. package/fesm2022/ngbase-adk-list.mjs +110 -0
  129. package/fesm2022/ngbase-adk-list.mjs.map +1 -0
  130. package/fesm2022/ngbase-adk-mask.mjs +234 -0
  131. package/fesm2022/ngbase-adk-mask.mjs.map +1 -0
  132. package/fesm2022/ngbase-adk-menu.mjs +546 -0
  133. package/fesm2022/ngbase-adk-menu.mjs.map +1 -0
  134. package/fesm2022/ngbase-adk-network.mjs +90 -0
  135. package/fesm2022/ngbase-adk-network.mjs.map +1 -0
  136. package/fesm2022/ngbase-adk-pagination.mjs +187 -0
  137. package/fesm2022/ngbase-adk-pagination.mjs.map +1 -0
  138. package/fesm2022/ngbase-adk-popover.mjs +953 -0
  139. package/fesm2022/ngbase-adk-popover.mjs.map +1 -0
  140. package/fesm2022/ngbase-adk-portal.mjs +279 -0
  141. package/fesm2022/ngbase-adk-portal.mjs.map +1 -0
  142. package/fesm2022/ngbase-adk-progress.mjs +57 -0
  143. package/fesm2022/ngbase-adk-progress.mjs.map +1 -0
  144. package/fesm2022/ngbase-adk-radio.mjs +129 -0
  145. package/fesm2022/ngbase-adk-radio.mjs.map +1 -0
  146. package/fesm2022/ngbase-adk-resizable.mjs +367 -0
  147. package/fesm2022/ngbase-adk-resizable.mjs.map +1 -0
  148. package/fesm2022/ngbase-adk-scroll-area.mjs +232 -0
  149. package/fesm2022/ngbase-adk-scroll-area.mjs.map +1 -0
  150. package/fesm2022/ngbase-adk-select.mjs +599 -0
  151. package/fesm2022/ngbase-adk-select.mjs.map +1 -0
  152. package/fesm2022/ngbase-adk-selectable.mjs +79 -0
  153. package/fesm2022/ngbase-adk-selectable.mjs.map +1 -0
  154. package/fesm2022/ngbase-adk-sidenav.mjs +209 -0
  155. package/fesm2022/ngbase-adk-sidenav.mjs.map +1 -0
  156. package/fesm2022/ngbase-adk-slider.mjs +337 -0
  157. package/fesm2022/ngbase-adk-slider.mjs.map +1 -0
  158. package/fesm2022/ngbase-adk-sonner.mjs +176 -0
  159. package/fesm2022/ngbase-adk-sonner.mjs.map +1 -0
  160. package/fesm2022/ngbase-adk-stepper.mjs +211 -0
  161. package/fesm2022/ngbase-adk-stepper.mjs.map +1 -0
  162. package/fesm2022/ngbase-adk-switch.mjs +115 -0
  163. package/fesm2022/ngbase-adk-switch.mjs.map +1 -0
  164. package/fesm2022/ngbase-adk-table.mjs +348 -0
  165. package/fesm2022/ngbase-adk-table.mjs.map +1 -0
  166. package/fesm2022/ngbase-adk-tabs.mjs +386 -0
  167. package/fesm2022/ngbase-adk-tabs.mjs.map +1 -0
  168. package/fesm2022/ngbase-adk-test.mjs +267 -0
  169. package/fesm2022/ngbase-adk-test.mjs.map +1 -0
  170. package/fesm2022/ngbase-adk-toggle-group.mjs +114 -0
  171. package/fesm2022/ngbase-adk-toggle-group.mjs.map +1 -0
  172. package/fesm2022/ngbase-adk-toggle.mjs +48 -0
  173. package/fesm2022/ngbase-adk-toggle.mjs.map +1 -0
  174. package/fesm2022/ngbase-adk-tooltip.mjs +237 -0
  175. package/fesm2022/ngbase-adk-tooltip.mjs.map +1 -0
  176. package/fesm2022/ngbase-adk-tour.mjs +312 -0
  177. package/fesm2022/ngbase-adk-tour.mjs.map +1 -0
  178. package/fesm2022/ngbase-adk-translate.mjs +162 -0
  179. package/fesm2022/ngbase-adk-translate.mjs.map +1 -0
  180. package/fesm2022/ngbase-adk-tree.mjs +301 -0
  181. package/fesm2022/ngbase-adk-tree.mjs.map +1 -0
  182. package/fesm2022/ngbase-adk-utils.mjs +228 -0
  183. package/fesm2022/ngbase-adk-utils.mjs.map +1 -0
  184. package/fesm2022/ngbase-adk-virtualizer.mjs +198 -0
  185. package/fesm2022/ngbase-adk-virtualizer.mjs.map +1 -0
  186. package/fesm2022/ngbase-adk.mjs +6 -0
  187. package/fesm2022/ngbase-adk.mjs.map +1 -0
  188. package/form-field/auto-height.d.ts +9 -0
  189. package/form-field/error.d.ts +18 -0
  190. package/form-field/form-field.d.ts +14 -0
  191. package/form-field/index.d.ts +5 -0
  192. package/form-field/input.d.ts +16 -0
  193. package/form-field/label.d.ts +7 -0
  194. package/form-field/otp.d.ts +48 -0
  195. package/form-field/public-api.d.ts +6 -0
  196. package/hover-card/hover-card.d.ts +18 -0
  197. package/hover-card/index.d.ts +5 -0
  198. package/hover-card/public-api.d.ts +1 -0
  199. package/icon/icon.d.ts +12 -0
  200. package/icon/icon.service.d.ts +12 -0
  201. package/icon/index.d.ts +5 -0
  202. package/icon/public-api.d.ts +2 -0
  203. package/index.d.ts +5 -0
  204. package/inline-edit/index.d.ts +5 -0
  205. package/inline-edit/inline-edit.d.ts +47 -0
  206. package/inline-edit/public-api.d.ts +1 -0
  207. package/jwt/index.d.ts +5 -0
  208. package/jwt/jwt.service.d.ts +27 -0
  209. package/jwt/public-api.d.ts +1 -0
  210. package/keys/index.d.ts +5 -0
  211. package/keys/keys.service.d.ts +13 -0
  212. package/keys/public-api.d.ts +2 -0
  213. package/keys/shortcuts.service.d.ts +38 -0
  214. package/layout/index.d.ts +5 -0
  215. package/layout/layout.d.ts +16 -0
  216. package/layout/public-api.d.ts +1 -0
  217. package/list/index.d.ts +5 -0
  218. package/list/list.d.ts +20 -0
  219. package/list/list.directive.d.ts +12 -0
  220. package/list/public-api.d.ts +2 -0
  221. package/mask/index.d.ts +5 -0
  222. package/mask/mask-pipe.d.ts +7 -0
  223. package/mask/mask.d.ts +25 -0
  224. package/mask/public-api.d.ts +2 -0
  225. package/menu/context-menu.d.ts +21 -0
  226. package/menu/index.d.ts +5 -0
  227. package/menu/mention.d.ts +18 -0
  228. package/menu/menu-trigger.d.ts +34 -0
  229. package/menu/menu.d.ts +52 -0
  230. package/menu/navigation-menu.d.ts +19 -0
  231. package/menu/public-api.d.ts +5 -0
  232. package/network/index.d.ts +5 -0
  233. package/network/network.interceptor.d.ts +6 -0
  234. package/network/network.service.d.ts +18 -0
  235. package/network/public-api.d.ts +2 -0
  236. package/package.json +247 -0
  237. package/pagination/index.d.ts +5 -0
  238. package/pagination/pagination.d.ts +28 -0
  239. package/pagination/public-api.d.ts +1 -0
  240. package/popover/base-popover.service.d.ts +16 -0
  241. package/popover/index.d.ts +5 -0
  242. package/popover/popover-trigger.d.ts +21 -0
  243. package/popover/popover.d.ts +50 -0
  244. package/popover/popover.service.d.ts +42 -0
  245. package/popover/public-api.d.ts +5 -0
  246. package/popover/utils.d.ts +85 -0
  247. package/portal/dialog-ref.d.ts +71 -0
  248. package/portal/index.d.ts +5 -0
  249. package/portal/portal-base.service.d.ts +19 -0
  250. package/portal/portal-close.directive.d.ts +8 -0
  251. package/portal/portal.component.d.ts +7 -0
  252. package/portal/portal.service.d.ts +16 -0
  253. package/portal/public-api.d.ts +5 -0
  254. package/progress/index.d.ts +5 -0
  255. package/progress/progress.d.ts +13 -0
  256. package/progress/public-api.d.ts +1 -0
  257. package/public-api.d.ts +2 -0
  258. package/radio/index.d.ts +5 -0
  259. package/radio/public-api.d.ts +2 -0
  260. package/radio/radio-group.d.ts +19 -0
  261. package/radio/radio.d.ts +22 -0
  262. package/resizable/index.d.ts +5 -0
  263. package/resizable/public-api.d.ts +2 -0
  264. package/resizable/resizable-group.d.ts +22 -0
  265. package/resizable/resizable.d.ts +50 -0
  266. package/scroll-area/index.d.ts +5 -0
  267. package/scroll-area/public-api.d.ts +1 -0
  268. package/scroll-area/scroll-area.d.ts +56 -0
  269. package/select/index.d.ts +5 -0
  270. package/select/list-selection.d.ts +7 -0
  271. package/select/option-group.d.ts +7 -0
  272. package/select/option.d.ts +25 -0
  273. package/select/public-api.d.ts +6 -0
  274. package/select/select-base.d.ts +64 -0
  275. package/select/select-input.d.ts +23 -0
  276. package/select/select.d.ts +50 -0
  277. package/selectable/index.d.ts +5 -0
  278. package/selectable/public-api.d.ts +2 -0
  279. package/selectable/selectable-item.d.ts +12 -0
  280. package/selectable/selectable.d.ts +19 -0
  281. package/sidenav/index.d.ts +5 -0
  282. package/sidenav/public-api.d.ts +3 -0
  283. package/sidenav/sidenav-header.d.ts +31 -0
  284. package/sidenav/sidenav.d.ts +23 -0
  285. package/sidenav/sidenav.service.d.ts +18 -0
  286. package/slider/index.d.ts +5 -0
  287. package/slider/public-api.d.ts +1 -0
  288. package/slider/slider.d.ts +73 -0
  289. package/sonner/index.d.ts +5 -0
  290. package/sonner/public-api.d.ts +2 -0
  291. package/sonner/sonner.d.ts +24 -0
  292. package/sonner/sonner.service.d.ts +21 -0
  293. package/stepper/animation.d.ts +1 -0
  294. package/stepper/index.d.ts +5 -0
  295. package/stepper/public-api.d.ts +3 -0
  296. package/stepper/step.d.ts +24 -0
  297. package/stepper/stepper.d.ts +26 -0
  298. package/switch/index.d.ts +5 -0
  299. package/switch/public-api.d.ts +1 -0
  300. package/switch/switch.d.ts +44 -0
  301. package/table/body-cell.d.ts +11 -0
  302. package/table/body-row.d.ts +21 -0
  303. package/table/column.d.ts +10 -0
  304. package/table/head-cell.d.ts +12 -0
  305. package/table/head-row.d.ts +21 -0
  306. package/table/index.d.ts +5 -0
  307. package/table/public-api.d.ts +8 -0
  308. package/table/table.d.ts +32 -0
  309. package/tabs/index.d.ts +5 -0
  310. package/tabs/public-api.d.ts +2 -0
  311. package/tabs/tab-group.d.ts +52 -0
  312. package/tabs/tab.d.ts +31 -0
  313. package/test/index.d.ts +5 -0
  314. package/test/public-api.d.ts +1 -0
  315. package/test/utils.d.ts +62 -0
  316. package/toggle/index.d.ts +5 -0
  317. package/toggle/public-api.d.ts +1 -0
  318. package/toggle/toggle.d.ts +13 -0
  319. package/toggle-group/index.d.ts +5 -0
  320. package/toggle-group/public-api.d.ts +2 -0
  321. package/toggle-group/toggle-group.d.ts +25 -0
  322. package/toggle-group/toggle-item.d.ts +14 -0
  323. package/tooltip/index.d.ts +5 -0
  324. package/tooltip/public-api.d.ts +2 -0
  325. package/tooltip/tooltip.d.ts +20 -0
  326. package/tooltip/tooltip.directive.d.ts +34 -0
  327. package/tooltip/tooltip.service.d.ts +26 -0
  328. package/tour/animation.d.ts +2 -0
  329. package/tour/index.d.ts +5 -0
  330. package/tour/public-api.d.ts +5 -0
  331. package/tour/tour-base.d.ts +21 -0
  332. package/tour/tour-step.d.ts +11 -0
  333. package/tour/tour.d.ts +9 -0
  334. package/tour/tour.service.d.ts +30 -0
  335. package/translate/config.d.ts +16 -0
  336. package/translate/index.d.ts +5 -0
  337. package/translate/public-api.d.ts +3 -0
  338. package/translate/translate.d.ts +11 -0
  339. package/translate/translate.service.d.ts +31 -0
  340. package/tree/index.d.ts +5 -0
  341. package/tree/public-api.d.ts +3 -0
  342. package/tree/tree-node.d.ts +28 -0
  343. package/tree/tree-toggle.d.ts +16 -0
  344. package/tree/tree.d.ts +55 -0
  345. package/utils/animation.d.ts +3 -0
  346. package/utils/disposals.d.ts +7 -0
  347. package/utils/index.d.ts +5 -0
  348. package/utils/number-only.d.ts +22 -0
  349. package/utils/public-api.d.ts +6 -0
  350. package/utils/range.pipe.d.ts +7 -0
  351. package/utils/ssr.d.ts +2 -0
  352. package/utils/utils.d.ts +27 -0
  353. package/virtualizer/index.d.ts +5 -0
  354. package/virtualizer/public-api.d.ts +1 -0
  355. package/virtualizer/virtualizer.d.ts +42 -0
@@ -0,0 +1,580 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Directive, Component, inject, ElementRef, viewChild, output, input, afterNextRender, InjectionToken, Injector, model, effect, untracked } from '@angular/core';
3
+ import * as i1 from '@ngbase/adk/drag';
4
+ import { Drag } from '@ngbase/adk/drag';
5
+ import { DialogRef } from '@ngbase/adk/portal';
6
+ import { ngbPopoverPortal } from '@ngbase/adk/popover';
7
+ import { provideValueAccessor } from '@ngbase/adk/utils';
8
+
9
+ const MAX_RGB = 255;
10
+ const MAX_HUE = 360;
11
+ const MAX_PERCENTAGE = 100;
12
+ function hexToRgb(hex) {
13
+ // Remove the hash at the start if it's there
14
+ hex = hex.replace(/^#/, '');
15
+ // Check for valid hex formats
16
+ if (!/^([0-9A-Fa-f]{3}|[0-9A-Fa-f]{4}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/.test(hex)) {
17
+ throw new Error('Invalid hex color format');
18
+ }
19
+ let r, g, b, a = 1;
20
+ if (hex.length === 3 || hex.length === 4) {
21
+ r = parseInt(hex[0] + hex[0], 16);
22
+ g = parseInt(hex[1] + hex[1], 16);
23
+ b = parseInt(hex[2] + hex[2], 16);
24
+ if (hex.length === 4) {
25
+ a = parseInt(hex[3] + hex[3], 16) / 255;
26
+ }
27
+ }
28
+ else if (hex.length === 6 || hex.length === 8) {
29
+ r = parseInt(hex.slice(0, 2), 16);
30
+ g = parseInt(hex.slice(2, 4), 16);
31
+ b = parseInt(hex.slice(4, 6), 16);
32
+ if (hex.length === 8) {
33
+ a = parseInt(hex.slice(6, 8), 16) / 255;
34
+ }
35
+ }
36
+ else {
37
+ throw new Error('Invalid hex color format');
38
+ }
39
+ return [r, g, b, roundTo2Decimals(a)];
40
+ }
41
+ function rgbaToHsb(r, g, b, a = 1) {
42
+ validateRgba(r, g, b, a);
43
+ r /= 255;
44
+ g /= 255;
45
+ b /= 255;
46
+ const max = Math.max(r, g, b);
47
+ const min = Math.min(r, g, b);
48
+ let h = 0;
49
+ const d = max - min;
50
+ const s = max === 0 ? 0 : d / max;
51
+ const v = max;
52
+ if (max !== min) {
53
+ switch (max) {
54
+ case r:
55
+ h = (g - b) / d + (g < b ? 6 : 0);
56
+ break;
57
+ case g:
58
+ h = (b - r) / d + 2;
59
+ break;
60
+ case b:
61
+ h = (r - g) / d + 4;
62
+ break;
63
+ }
64
+ h /= 6;
65
+ }
66
+ return {
67
+ h: roundNum(h * 360),
68
+ s: roundNum(s * 100),
69
+ b: roundNum(v * 100),
70
+ a: roundTo2Decimals(a),
71
+ };
72
+ }
73
+ function hexToHsb(hex) {
74
+ const [r, g, b, a] = hexToRgb(hex);
75
+ const { h, s, b: brightness, a: alpha } = rgbaToHsb(r, g, b, a);
76
+ return [roundNum(h), roundNum(s), roundNum(brightness), roundTo2Decimals(alpha)];
77
+ }
78
+ function rgbToHsl(r, g, b) {
79
+ validateRgb(r, g, b);
80
+ r /= MAX_RGB;
81
+ g /= MAX_RGB;
82
+ b /= MAX_RGB;
83
+ const max = Math.max(r, g, b);
84
+ const min = Math.min(r, g, b);
85
+ let h = 0;
86
+ let s = 0;
87
+ const l = (max + min) / 2;
88
+ const d = max - min;
89
+ if (d) {
90
+ s = d / (1 - Math.abs(2 * l - 1));
91
+ switch (max) {
92
+ case r:
93
+ h = ((g - b) / d + (g < b ? 6 : 0)) / 6;
94
+ break;
95
+ case g:
96
+ h = ((b - r) / d + 2) / 6;
97
+ break;
98
+ case b:
99
+ h = ((r - g) / d + 4) / 6;
100
+ break;
101
+ }
102
+ }
103
+ return {
104
+ h: roundNum(h * MAX_HUE),
105
+ s: roundNum(s * MAX_PERCENTAGE),
106
+ l: roundNum(l * MAX_PERCENTAGE),
107
+ };
108
+ }
109
+ function parseRgba(rgba) {
110
+ const matches = rgba.match(/^rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)$/);
111
+ if (!matches) {
112
+ throw new Error('Invalid RGBA string format');
113
+ }
114
+ const [, r, g, b, a] = matches;
115
+ return [parseInt(r, 10), parseInt(g, 10), parseInt(b, 10), a ? parseFloat(a) : 1];
116
+ }
117
+ function parseHsba(hsb) {
118
+ const matches = hsb.match(/^hsba?\((\d+),\s*(\d+)%,\s*(\d+)%(?:,\s*(\d+(?:\.\d+)?))?\)$/);
119
+ if (!matches) {
120
+ throw new Error('Invalid HSBA string format');
121
+ }
122
+ const [, h, s, b, a] = matches;
123
+ return [parseInt(h, 10), parseInt(s, 10), parseInt(b, 10), a ? parseFloat(a) : 1];
124
+ }
125
+ function hsbToHsl(h, s, b) {
126
+ validateHsb(h, s, b);
127
+ s /= MAX_PERCENTAGE;
128
+ b /= MAX_PERCENTAGE;
129
+ const l = b * (1 - s / 2);
130
+ const saturation = l === 0 || l === 1 ? 0 : (b - l) / Math.min(l, 1 - l);
131
+ return [roundNum(h), roundNum(saturation * MAX_PERCENTAGE), roundNum(l * MAX_PERCENTAGE)];
132
+ }
133
+ function hslaToHsba(h, s, l, a = 1) {
134
+ validateHsl(h, s, l);
135
+ validateAlpha(a);
136
+ s /= MAX_PERCENTAGE;
137
+ l /= MAX_PERCENTAGE;
138
+ const brightness = l + s * Math.min(l, 1 - l);
139
+ const saturation = brightness === 0 ? 0 : 2 * (1 - l / brightness);
140
+ return [
141
+ roundNum(h),
142
+ roundNum(saturation * MAX_PERCENTAGE),
143
+ roundNum(brightness * MAX_PERCENTAGE),
144
+ roundTo2Decimals(a),
145
+ ];
146
+ }
147
+ function hsbaToRgba(h, s, b, a = 1) {
148
+ validateHsb(h, s, b);
149
+ validateAlpha(a);
150
+ s /= MAX_PERCENTAGE;
151
+ b /= MAX_PERCENTAGE;
152
+ const k = (n) => (n + h / 60) % 6;
153
+ const f = (n) => b * (1 - s * Math.max(0, Math.min(k(n), 4 - k(n), 1)));
154
+ return [
155
+ roundNum(f(5) * MAX_RGB),
156
+ roundNum(f(3) * MAX_RGB),
157
+ roundNum(f(1) * MAX_RGB),
158
+ roundTo2Decimals(a),
159
+ ];
160
+ }
161
+ function rgbToHsba(r, g, b, a = 1) {
162
+ const { h, s, b: br, a: alpha } = rgbaToHsb(r, g, b, a);
163
+ return [h, s, br, alpha];
164
+ }
165
+ function hsbaToHex(h, s, b, a = 1) {
166
+ const [r, g, b_, a_] = hsbaToRgba(h, s, b, a);
167
+ return rgbToHex(r, g, b_, a_);
168
+ }
169
+ function rgbToHex(r, g, b, a = 1) {
170
+ validateRgb(r, g, b);
171
+ validateAlpha(a);
172
+ let rgba = [r, g, b];
173
+ if (a < 1) {
174
+ rgba.push(Math.round(a * 255));
175
+ }
176
+ return ('#' +
177
+ rgba
178
+ .map(x => Math.round(x).toString(16).padStart(2, '0'))
179
+ .join('')
180
+ .toUpperCase());
181
+ }
182
+ function validateRgb(r, g, b) {
183
+ if (r < 0 || r > MAX_RGB || g < 0 || g > MAX_RGB || b < 0 || b > MAX_RGB) {
184
+ throw new Error('Invalid RGB values');
185
+ }
186
+ }
187
+ function validateRgba(r, g, b, a) {
188
+ validateRgb(r, g, b);
189
+ validateAlpha(a);
190
+ }
191
+ function validateHsb(h, s, b) {
192
+ if (h < 0 || h > MAX_HUE || s < 0 || s > MAX_PERCENTAGE || b < 0 || b > MAX_PERCENTAGE) {
193
+ throw new Error('Invalid HSB values');
194
+ }
195
+ }
196
+ function validateHsl(h, s, l) {
197
+ if (h < 0 || h >= MAX_HUE || s < 0 || s > MAX_PERCENTAGE || l < 0 || l > MAX_PERCENTAGE) {
198
+ throw new Error('Invalid HSL values');
199
+ }
200
+ }
201
+ function validateAlpha(a) {
202
+ if (a < 0 || a > 1) {
203
+ throw new Error('Invalid alpha value');
204
+ }
205
+ }
206
+ function roundNum(num) {
207
+ return Math.round(num);
208
+ }
209
+ function roundTo2Decimals(num) {
210
+ return Math.round(num * 100) / 100;
211
+ }
212
+
213
+ class ColorSpectrum {
214
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: ColorSpectrum, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
215
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.0", type: ColorSpectrum, isStandalone: true, selector: "[ngbColorSpectrum]", host: { styleAttribute: "background-image: linear-gradient(0deg, rgb(0, 0, 0), transparent), linear-gradient(90deg, rgb(255, 255, 255), rgba(255, 255, 255, 0)); background-color: var(--hue-color);" }, hostDirectives: [{ directive: i1.Drag }], ngImport: i0 }); }
216
+ }
217
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: ColorSpectrum, decorators: [{
218
+ type: Directive,
219
+ args: [{
220
+ selector: '[ngbColorSpectrum]',
221
+ hostDirectives: [Drag],
222
+ host: {
223
+ style: 'background-image: linear-gradient(0deg, rgb(0, 0, 0), transparent), linear-gradient(90deg, rgb(255, 255, 255), rgba(255, 255, 255, 0)); background-color: var(--hue-color);',
224
+ },
225
+ }]
226
+ }] });
227
+ class ColorSpectrumSelector {
228
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: ColorSpectrumSelector, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
229
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.0", type: ColorSpectrumSelector, isStandalone: true, selector: "[ngbColorSpectrumSelector]", host: { attributes: { "type": "button" } }, ngImport: i0 }); }
230
+ }
231
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: ColorSpectrumSelector, decorators: [{
232
+ type: Directive,
233
+ args: [{
234
+ selector: '[ngbColorSpectrumSelector]',
235
+ host: {
236
+ type: 'button',
237
+ },
238
+ }]
239
+ }] });
240
+ class ColorSelected {
241
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: ColorSelected, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
242
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.0", type: ColorSelected, isStandalone: true, selector: "[ngbColorSelected]", ngImport: i0 }); }
243
+ }
244
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: ColorSelected, decorators: [{
245
+ type: Directive,
246
+ args: [{ selector: '[ngbColorSelected]' }]
247
+ }] });
248
+ class ColorHue {
249
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: ColorHue, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
250
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.0", type: ColorHue, isStandalone: true, selector: "[ngbColorHue]", host: { styleAttribute: "inset: 0px; background: linear-gradient(to right, rgb(255, 0, 0), rgb(255, 255, 0), rgb(0, 255, 0), rgb(0, 255, 255), rgb(0, 0, 255), rgb(255, 0, 255), rgb(255, 0, 0));" }, hostDirectives: [{ directive: i1.Drag }], ngImport: i0 }); }
251
+ }
252
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: ColorHue, decorators: [{
253
+ type: Directive,
254
+ args: [{
255
+ selector: '[ngbColorHue]',
256
+ hostDirectives: [Drag],
257
+ host: {
258
+ style: 'inset: 0px; background: linear-gradient(to right, rgb(255, 0, 0), rgb(255, 255, 0), rgb(0, 255, 0), rgb(0, 255, 255), rgb(0, 0, 255), rgb(255, 0, 255), rgb(255, 0, 0));',
259
+ },
260
+ }]
261
+ }] });
262
+ class ColorHueThumb {
263
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: ColorHueThumb, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
264
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.0", type: ColorHueThumb, isStandalone: true, selector: "[ngbColorHueThumb]", host: { attributes: { "type": "button" } }, ngImport: i0 }); }
265
+ }
266
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: ColorHueThumb, decorators: [{
267
+ type: Directive,
268
+ args: [{
269
+ selector: '[ngbColorHueThumb]',
270
+ host: {
271
+ type: 'button',
272
+ },
273
+ }]
274
+ }] });
275
+ class ColorAlpha {
276
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: ColorAlpha, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
277
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.0.0", type: ColorAlpha, isStandalone: true, selector: "[ngbColorAlpha]", host: { styleAttribute: "\n background-image: conic-gradient(\n rgba(0, 0, 0, 0.06) 0 25%,\n transparent 0 50%,\n rgba(0, 0, 0, 0.06) 0 75%,\n transparent 0\n );\n background-size: 8px 8px;\n " }, hostDirectives: [{ directive: i1.Drag }], ngImport: i0, template: ` <div
278
+ style="height: 100%; inset: 0px; background: linear-gradient(to right, rgba(255, 0, 4, 0), var(--hue-color));"
279
+ >
280
+ <ng-content />
281
+ </div>`, isInline: true }); }
282
+ }
283
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: ColorAlpha, decorators: [{
284
+ type: Component,
285
+ args: [{
286
+ selector: '[ngbColorAlpha]',
287
+ hostDirectives: [Drag],
288
+ template: ` <div
289
+ style="height: 100%; inset: 0px; background: linear-gradient(to right, rgba(255, 0, 4, 0), var(--hue-color));"
290
+ >
291
+ <ng-content />
292
+ </div>`,
293
+ host: {
294
+ style: `
295
+ background-image: conic-gradient(
296
+ rgba(0, 0, 0, 0.06) 0 25%,
297
+ transparent 0 50%,
298
+ rgba(0, 0, 0, 0.06) 0 75%,
299
+ transparent 0
300
+ );
301
+ background-size: 8px 8px;
302
+ `,
303
+ },
304
+ }]
305
+ }] });
306
+ class ColorAlphaThumb {
307
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: ColorAlphaThumb, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
308
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.0", type: ColorAlphaThumb, isStandalone: true, selector: "[ngbColorAlphaThumb]", host: { attributes: { "type": "button" } }, ngImport: i0 }); }
309
+ }
310
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: ColorAlphaThumb, decorators: [{
311
+ type: Directive,
312
+ args: [{
313
+ selector: '[ngbColorAlphaThumb]',
314
+ host: {
315
+ type: 'button',
316
+ },
317
+ }]
318
+ }] });
319
+ class NgbColorPicker {
320
+ constructor() {
321
+ this.el = inject(ElementRef);
322
+ this.dialogRef = inject(DialogRef, { optional: true });
323
+ this.hueDiv = viewChild.required(ColorHue, { read: Drag });
324
+ this.hueSelector = viewChild.required(ColorHueThumb, { read: ElementRef });
325
+ this.spectrumDiv = viewChild.required(ColorSpectrum, {
326
+ read: Drag,
327
+ });
328
+ this.spectrumSelector = viewChild.required(ColorSpectrumSelector, { read: ElementRef });
329
+ this.selectedColor = viewChild.required(ColorSelected, { read: ElementRef });
330
+ this.alpha = 100; // 0-100
331
+ this.alphaDiv = viewChild.required(ColorAlpha, { read: Drag });
332
+ this.alphaSelector = viewChild.required(ColorAlphaThumb, { read: ElementRef });
333
+ this.valueChange = output();
334
+ this.format = input(this.dialogRef?.data.format || 'hex');
335
+ this.presetColors = input(this.dialogRef?.data.presetColors || []);
336
+ this.hue = 0;
337
+ this.saturation = 0;
338
+ this.brightness = 0;
339
+ this.localValue = '';
340
+ this.colorParsers = new Map([
341
+ ['hsb', parseHsba],
342
+ ['hex', hexToHsb],
343
+ ['rgb', (value) => rgbToHsba(...parseRgba(value))],
344
+ ['hsl', (value) => hslaToHsba(...parseHsba(value))],
345
+ ]);
346
+ afterNextRender(() => {
347
+ this.setupEventListeners();
348
+ });
349
+ }
350
+ calculateCoordinates(e, el) {
351
+ const rect = el.nativeElement.getBoundingClientRect();
352
+ let x = Math.round(e.clientX - rect.left);
353
+ let y = Math.round(e.clientY - rect.top);
354
+ // Constrain x and y within the bounds of the spectrum box
355
+ x = Math.max(0, Math.min(x, rect.width));
356
+ y = Math.max(0, Math.min(y, rect.height));
357
+ return { x, y, rect };
358
+ }
359
+ setupEventListeners() {
360
+ this.setupDragListener(this.hueDiv(), (x, y, w, h) => this.updateHue(x, 0, w, h));
361
+ this.setupDragListener(this.spectrumDiv(), this.updateSpectrum.bind(this));
362
+ this.setupDragListener(this.alphaDiv(), (x, y, w) => this.updateAlpha(x, 0, w));
363
+ }
364
+ setupDragListener(dragElement, updateFunction) {
365
+ dragElement.events.subscribe(event => {
366
+ if (event.type === 'start' || event.type === 'move') {
367
+ this.handleColorEvent(event.event, dragElement.el, updateFunction);
368
+ // If we want to avoid emitting the value on every move,
369
+ // we can add a flag to emit only when the event is 'end'
370
+ this.valueChange.emit(this.localValue);
371
+ }
372
+ });
373
+ }
374
+ handleColorEvent(event, element, updateFunction) {
375
+ const { x, y, rect } = this.calculateCoordinates(event, element);
376
+ updateFunction(x, y, rect.width, rect.height);
377
+ this.updateValue();
378
+ }
379
+ updateHue(x, y, width, height) {
380
+ this.hue = Math.round((x / width) * 360);
381
+ this.el.nativeElement.style.setProperty('--hue-color', `hsl(${this.hue}, 100%, 50%)`);
382
+ const hueSelector = this.hueSelector().nativeElement;
383
+ hueSelector.style.left = `${x}px`;
384
+ if (this.lastSpectrumEvent)
385
+ this.updateValue();
386
+ }
387
+ updateSpectrum(x, y, width, height) {
388
+ const { s, b } = this.calculateSaturationAndLuminous(x, y, width, height);
389
+ this.saturation = s;
390
+ this.brightness = b;
391
+ this.lastSpectrumEvent = { clientX: x, clientY: y };
392
+ const spectrumSelector = this.spectrumSelector().nativeElement;
393
+ spectrumSelector.style.left = `${x - spectrumSelector.offsetWidth / 2}px`;
394
+ spectrumSelector.style.top = `${y - spectrumSelector.offsetHeight / 2}px`;
395
+ }
396
+ updateAlpha(x, y, width) {
397
+ this.alpha = Math.round((x / width) * 100);
398
+ const alphaSelector = this.alphaSelector().nativeElement;
399
+ alphaSelector.style.left = `${x}px`;
400
+ }
401
+ setValue(value, emit = false) {
402
+ if (!value)
403
+ return;
404
+ this.parse(value);
405
+ this.updateValue(emit);
406
+ this.el.nativeElement.style.setProperty('--hue-color', this.getColor(this.hue, 100, 100, 100));
407
+ this.updateSelectorPositions();
408
+ }
409
+ updateSelectorPositions() {
410
+ this.updateSelectorPosition(this.hueDiv().el, this.hueSelector(), this.hue / 360);
411
+ this.updateSelectorPosition(this.alphaDiv().el, this.alphaSelector(), this.alpha / 100);
412
+ this.updateSpectrumSelectorPosition();
413
+ }
414
+ updateSelectorPosition(containerEl, selectorEl, ratio) {
415
+ selectorEl.nativeElement.style.left = ratio * containerEl.nativeElement.clientWidth + 'px';
416
+ }
417
+ updateSpectrumSelectorPosition() {
418
+ const spectrumRect = this.spectrumDiv().el.nativeElement.getBoundingClientRect();
419
+ const spectrumSelector = this.spectrumSelector().nativeElement;
420
+ const { x, y } = this.calculateSpectrumPosition(this.saturation, this.brightness, spectrumRect.width, spectrumRect.height);
421
+ spectrumSelector.style.left = `${x}px`;
422
+ spectrumSelector.style.top = `${y}px`;
423
+ }
424
+ // Simplified function to calculate the x and y based on the saturation and lightness
425
+ calculateSpectrumPosition(s, l, spectrumWidth, spectrumHeight) {
426
+ const handlerSize = 16;
427
+ const half = handlerSize / 2;
428
+ const x = (spectrumWidth * s) / 100 - half;
429
+ const y = (spectrumHeight * (100 - l)) / 100 - half;
430
+ return { x, y };
431
+ }
432
+ calculateSaturationAndLuminous(x, y, sw, sh) {
433
+ const s = Math.round((x / sw) * 100);
434
+ const b = Math.round(100 - (y / sh) * 100);
435
+ return { s, b };
436
+ }
437
+ updateValue(emit = false) {
438
+ this.localValue = this.toString();
439
+ const hsla = this.getColor(this.hue, this.saturation, this.brightness, this.alpha);
440
+ this.el.nativeElement.style.setProperty('--spectrum-color', hsla);
441
+ this.selectedColor().nativeElement.style.backgroundColor = hsla;
442
+ this.spectrumSelector().nativeElement.style.backgroundColor = hsla;
443
+ if (emit)
444
+ this.valueChange.emit(this.localValue);
445
+ }
446
+ getColor(h, s, b, a) {
447
+ const [hh, ss, l] = hsbToHsl(h, s, b);
448
+ return `hsla(${hh}, ${ss}%, ${l}%, ${a / 100})`;
449
+ }
450
+ parse(value) {
451
+ const parser = this.colorParsers.get(this.format());
452
+ if (parser) {
453
+ [this.hue, this.saturation, this.brightness, this.alpha] = parser(value);
454
+ this.alpha = Math.round(this.alpha * 100);
455
+ }
456
+ }
457
+ toString() {
458
+ const alpha = this.alpha / 100;
459
+ const formatters = {
460
+ hsb: () => `hsba(${this.hue}, ${this.saturation}%, ${this.brightness}%, ${alpha})`,
461
+ hex: () => hsbaToHex(this.hue, this.saturation, this.brightness, alpha),
462
+ rgb: () => {
463
+ const [r, g, b, a] = hsbaToRgba(this.hue, this.saturation, this.brightness, alpha);
464
+ return a === 1 ? `rgb(${r}, ${g}, ${b})` : `rgba(${r}, ${g}, ${b}, ${a})`;
465
+ },
466
+ hsl: () => {
467
+ const [h, s, l] = hsbToHsl(this.hue, this.saturation, this.brightness);
468
+ return `hsla(${h}, ${s}%, ${l}%, ${alpha})`;
469
+ },
470
+ };
471
+ return formatters[this.format()]?.() || '';
472
+ }
473
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgbColorPicker, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
474
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "19.0.0", type: NgbColorPicker, isStandalone: true, selector: "ngb-color-picker-container", inputs: { format: { classPropertyName: "format", publicName: "format", isSignal: true, isRequired: false, transformFunction: null }, presetColors: { classPropertyName: "presetColors", publicName: "presetColors", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { valueChange: "valueChange" }, host: { styleAttribute: "\n --hue-color: rgb(255, 0, 0);\n --spectrum-color: rgb(0, 0, 0);\n " }, viewQueries: [{ propertyName: "hueDiv", first: true, predicate: ColorHue, descendants: true, read: Drag, isSignal: true }, { propertyName: "hueSelector", first: true, predicate: ColorHueThumb, descendants: true, read: ElementRef, isSignal: true }, { propertyName: "spectrumDiv", first: true, predicate: ColorSpectrum, descendants: true, read: Drag, isSignal: true }, { propertyName: "spectrumSelector", first: true, predicate: ColorSpectrumSelector, descendants: true, read: ElementRef, isSignal: true }, { propertyName: "selectedColor", first: true, predicate: ColorSelected, descendants: true, read: ElementRef, isSignal: true }, { propertyName: "alphaDiv", first: true, predicate: ColorAlpha, descendants: true, read: Drag, isSignal: true }, { propertyName: "alphaSelector", first: true, predicate: ColorAlphaThumb, descendants: true, read: ElementRef, isSignal: true }], ngImport: i0 }); }
475
+ }
476
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgbColorPicker, decorators: [{
477
+ type: Directive,
478
+ args: [{
479
+ selector: 'ngb-color-picker-container',
480
+ host: {
481
+ style: `
482
+ --hue-color: rgb(255, 0, 0);
483
+ --spectrum-color: rgb(0, 0, 0);
484
+ `,
485
+ },
486
+ }]
487
+ }], ctorParameters: () => [] });
488
+
489
+ const ColorPicker = new InjectionToken('ColorPicker');
490
+ const registerColorPicker = ({ picker, accessor }) => [
491
+ { provide: ColorPicker, useValue: picker },
492
+ provideValueAccessor(accessor),
493
+ ];
494
+ class ColorPickerTrigger {
495
+ constructor() {
496
+ this.el = inject(ElementRef);
497
+ this.colorPicker = inject(ColorPicker, { optional: true }) ?? NgbColorPicker;
498
+ this.popover = ngbPopoverPortal();
499
+ this.injector = inject(Injector);
500
+ this.format = input('hex');
501
+ this.presetColors = input();
502
+ this.value = model();
503
+ }
504
+ open() {
505
+ const { childSignal } = this.popover.open(this.colorPicker, {
506
+ target: this.el.nativeElement,
507
+ position: 'bl',
508
+ offset: 0,
509
+ data: { format: this.format(), presetColors: this.presetColors() },
510
+ width: '255px',
511
+ });
512
+ this.effectRef?.destroy();
513
+ this.effectRef = effect(() => {
514
+ const colorPicker = childSignal()?.instance;
515
+ if (colorPicker) {
516
+ untracked(() => {
517
+ colorPicker.setValue(this.value() || '#000000');
518
+ colorPicker.valueChange.subscribe(res => {
519
+ this.value.set(res);
520
+ });
521
+ });
522
+ }
523
+ }, { injector: this.injector });
524
+ }
525
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: ColorPickerTrigger, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
526
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.0.0", type: ColorPickerTrigger, isStandalone: true, selector: "[ngbColorPickerTrigger]", inputs: { format: { classPropertyName: "format", publicName: "format", isSignal: true, isRequired: false, transformFunction: null }, presetColors: { classPropertyName: "presetColors", publicName: "presetColors", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange" }, host: { listeners: { "click": "open()" } }, ngImport: i0 }); }
527
+ }
528
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: ColorPickerTrigger, decorators: [{
529
+ type: Directive,
530
+ args: [{
531
+ selector: '[ngbColorPickerTrigger]',
532
+ host: {
533
+ '(click)': 'open()',
534
+ },
535
+ }]
536
+ }] });
537
+
538
+ class NgbColorInput {
539
+ constructor() {
540
+ this.format = input('hex');
541
+ this.presetColors = input();
542
+ this.value = model('');
543
+ this.onChange = (_) => { };
544
+ this.onTouched = () => { };
545
+ }
546
+ updateValue(value = '') {
547
+ this.value.set(value);
548
+ this.onChange(value);
549
+ this.onTouched();
550
+ }
551
+ writeValue(value) {
552
+ this.value.set(value);
553
+ }
554
+ registerOnChange(fn) {
555
+ this.onChange = fn;
556
+ }
557
+ registerOnTouched(fn) {
558
+ this.onTouched = fn;
559
+ }
560
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgbColorInput, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
561
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.0.0", type: NgbColorInput, isStandalone: true, selector: "[ngbColorInput]", inputs: { format: { classPropertyName: "format", publicName: "format", isSignal: true, isRequired: false, transformFunction: null }, presetColors: { classPropertyName: "presetColors", publicName: "presetColors", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange" }, providers: [provideValueAccessor(NgbColorInput)], ngImport: i0 }); }
562
+ }
563
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.0", ngImport: i0, type: NgbColorInput, decorators: [{
564
+ type: Directive,
565
+ args: [{
566
+ selector: '[ngbColorInput]',
567
+ providers: [provideValueAccessor(NgbColorInput)],
568
+ }]
569
+ }] });
570
+
571
+ /*
572
+ * Public API Surface of color-picker
573
+ */
574
+
575
+ /**
576
+ * Generated bundle index. Do not edit.
577
+ */
578
+
579
+ export { ColorAlpha, ColorAlphaThumb, ColorHue, ColorHueThumb, ColorPickerTrigger, ColorSelected, ColorSpectrum, ColorSpectrumSelector, NgbColorInput, NgbColorPicker, registerColorPicker };
580
+ //# sourceMappingURL=ngbase-adk-color-picker.mjs.map