@luzmo/lucero 1.0.1-alpha.18 → 1.0.1-alpha.19

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 (275) hide show
  1. package/components/NumberFormatter-DewVDY5w.cjs +18 -0
  2. package/components/NumberFormatter-DgOUVrge.js +136 -0
  3. package/components/NumberParser-Dik4a0h-.cjs +18 -0
  4. package/components/NumberParser-ci9J5EKv.js +173 -0
  5. package/components/accordion/index.cjs +6 -183
  6. package/components/accordion/index.js +88 -136
  7. package/components/action-bar/index.cjs +4 -85
  8. package/components/action-bar/index.js +50 -72
  9. package/components/action-button/index.cjs +3 -205
  10. package/components/action-button/index.js +93 -167
  11. package/components/action-group/index.cjs +1 -7
  12. package/components/action-group/index.js +8 -12
  13. package/components/action-group-C54IxNZk.cjs +20 -0
  14. package/components/action-group-C9dsPJg-.js +258 -0
  15. package/components/action-menu/index.cjs +11 -91
  16. package/components/action-menu/index.js +47 -66
  17. package/components/async-directive-BwIAw5tB.js +82 -0
  18. package/components/async-directive-DLz6JB0v.cjs +22 -0
  19. package/components/avatar/index.cjs +3 -63
  20. package/components/avatar/index.js +42 -54
  21. package/components/{focusable-selectors-D0t_5P7C.cjs → base-BjTwmyRF.cjs} +5 -16
  22. package/components/base-CFWO09N1.js +684 -0
  23. package/components/base-Cy0MQrPT.cjs +40 -0
  24. package/components/base-D76d76ww.js +26 -0
  25. package/components/button/index.cjs +2 -134
  26. package/components/button/index.js +72 -106
  27. package/components/button-base-B8bWcklV.js +144 -0
  28. package/components/button-base-tf95Lyl4.cjs +25 -0
  29. package/components/button-group/index.cjs +1 -45
  30. package/components/button-group/index.js +25 -37
  31. package/components/calendar/index.cjs +1 -632
  32. package/components/calendar/index.js +7 -637
  33. package/components/checkbox/index.cjs +4 -111
  34. package/components/checkbox/index.js +53 -98
  35. package/components/checkbox-mixin-BOTvuPEu.js +70 -0
  36. package/components/checkbox-mixin-BVPpXtsq.cjs +27 -0
  37. package/components/class-map-CGfNk3Ee.js +51 -0
  38. package/components/class-map-D-Y-hsN5.cjs +22 -0
  39. package/components/clear-button-CuPbWwZY.cjs +18 -0
  40. package/components/clear-button-DzZ5ulBW.js +53 -0
  41. package/components/close-button-BTo4yrFR.cjs +18 -0
  42. package/components/close-button-CuQdsez5.js +51 -0
  43. package/components/color-area/index.cjs +13 -440
  44. package/components/color-area/index.js +187 -322
  45. package/components/color-controller-B0uX6Zso.js +3230 -0
  46. package/components/color-controller-CoUL5f9K.cjs +18 -0
  47. package/components/color-field/index.cjs +2 -95
  48. package/components/color-field/index.js +41 -77
  49. package/components/color-handle/index.cjs +3 -64
  50. package/components/color-handle/index.js +37 -58
  51. package/components/color-loupe/index.cjs +1 -7
  52. package/components/color-loupe/index.js +8 -12
  53. package/components/color-loupe-CrM2DVY3.cjs +56 -0
  54. package/components/color-loupe-DmQe3SpP.js +81 -0
  55. package/components/color-menu/index.cjs +12 -217
  56. package/components/color-menu/index.js +93 -187
  57. package/components/color-palette/index.cjs +1 -89
  58. package/components/color-palette/index.js +51 -78
  59. package/components/color-palette-group/index.cjs +3 -259
  60. package/components/color-palette-group/index.js +105 -193
  61. package/components/color-picker/index.cjs +6 -114
  62. package/components/color-picker/index.js +72 -92
  63. package/components/color-slider/index.cjs +1 -585
  64. package/components/color-slider/index.js +7 -590
  65. package/components/condition-attribute-with-id-DrQYZzFS.cjs +18 -0
  66. package/components/condition-attribute-with-id-Dv4lSRbe.js +31 -0
  67. package/components/date-time-picker/index.cjs +31 -1357
  68. package/components/date-time-picker/index.js +637 -951
  69. package/components/{dependency-manger-XHpQjFgK.js → dependency-manger-CO-VPlqq.js} +14 -24
  70. package/components/dependency-manger-uthev62E.cjs +18 -0
  71. package/components/directive-C7oCP5Bh.cjs +22 -0
  72. package/components/directive-helpers-D4KMv2dC.js +62 -0
  73. package/components/directive-helpers-t-TVum7J.cjs +22 -0
  74. package/components/{slottable-request-event-CANixJnR.cjs → directive-oAbCiebi.js} +25 -14
  75. package/components/divider/index.cjs +1 -54
  76. package/components/divider/index.js +30 -49
  77. package/components/divider.module-DDvBo9zo.cjs +18 -0
  78. package/components/divider.module-DoQWQEIJ.js +21 -0
  79. package/components/element-resolution-BvRLGqIU.cjs +18 -0
  80. package/components/element-resolution-FCUT-wql.js +91 -0
  81. package/components/field-group/index.cjs +1 -7
  82. package/components/field-group/index.js +8 -12
  83. package/components/field-group-5WQMBOk4.cjs +23 -0
  84. package/components/field-group-D4B0IOdA.js +66 -0
  85. package/components/field-label/index.cjs +1 -7
  86. package/components/field-label/index.js +8 -12
  87. package/components/field-label-DxmPiC5p.js +106 -0
  88. package/components/field-label-Dz9kisdW.cjs +25 -0
  89. package/components/flow-D-0MTYCm.js +527 -0
  90. package/components/flow-DM3dNAKs.cjs +30 -0
  91. package/components/focus-group-DHeTq18L.js +218 -0
  92. package/components/focus-group-DnxZUBhQ.cjs +18 -0
  93. package/components/focus-visible-BvScGDCE.js +74 -0
  94. package/components/focus-visible-D4BXb5RB.cjs +18 -0
  95. package/components/focusable-B_KwfEec.cjs +18 -0
  96. package/components/focusable-C5JjRZmT.js +153 -0
  97. package/components/{focusable-selectors-IltOAOd9.js → focusable-selectors-B4YgbghQ.js} +4 -7
  98. package/components/focusable-selectors-BgFlyFcY.cjs +18 -0
  99. package/components/icon/index.cjs +1 -90
  100. package/components/icon/index.js +46 -74
  101. package/components/if-defined-DULpqYwi.js +27 -0
  102. package/components/if-defined-DaXWqfzc.cjs +22 -0
  103. package/components/index-CNK8wHXu.cjs +57 -0
  104. package/components/index-Cf6G4q52.js +1490 -0
  105. package/components/index-D3ICqC7S.js +1174 -0
  106. package/components/index-hqVbNKYy.cjs +113 -0
  107. package/components/index.cjs +1 -174
  108. package/components/index.js +172 -174
  109. package/components/infield-button/index.cjs +2 -46
  110. package/components/infield-button/index.js +30 -41
  111. package/components/label/index.cjs +1 -37
  112. package/components/label/index.js +24 -36
  113. package/components/{language-resolution-BSGJAWiQ.js → language-resolution-B-wjV5bb.js} +17 -21
  114. package/components/language-resolution-EUER43cg.cjs +18 -0
  115. package/components/like-anchor-Bu3pXbjT.cjs +32 -0
  116. package/components/like-anchor-DCFJN0LV.js +69 -0
  117. package/components/luzmo-icons-CiSek5iM.js +229 -0
  118. package/components/luzmo-icons-CtA-TJPd.cjs +29 -0
  119. package/components/manage-help-text-CHfMLzSa.js +92 -0
  120. package/components/manage-help-text-DNqdEkTA.cjs +30 -0
  121. package/components/menu/index.cjs +29 -1297
  122. package/components/menu/index.js +499 -954
  123. package/components/multi-language-field/index.cjs +2 -132
  124. package/components/multi-language-field/index.js +88 -118
  125. package/components/mutation-controller-DH7YOCyj.js +52 -0
  126. package/components/mutation-controller-DkOMCW-c.cjs +22 -0
  127. package/components/number-field/index.cjs +10 -613
  128. package/components/number-field/index.js +243 -442
  129. package/components/observe-slot-presence-CmVi0zTc.js +68 -0
  130. package/components/observe-slot-presence-bc9chhsi.cjs +18 -0
  131. package/components/observe-slot-text-C3moTjwy.js +87 -0
  132. package/components/observe-slot-text-D2VAEFSd.cjs +18 -0
  133. package/components/options/index.cjs +60 -693
  134. package/components/options/index.js +953 -519
  135. package/components/overlay/index.cjs +21 -367
  136. package/components/overlay/index.js +189 -273
  137. package/components/overlay-B3ajDLLq.cjs +47 -0
  138. package/components/overlay-CUKs69yr.js +2745 -0
  139. package/components/{pending-state-CXbe-Xul.js → pending-state-B2wWssTo.js} +13 -28
  140. package/components/pending-state-bJr-nEJl.cjs +26 -0
  141. package/components/picker/index.cjs +1 -9
  142. package/components/picker/index.js +11 -15
  143. package/components/picker-C0LvseZe.cjs +123 -0
  144. package/components/picker-W1qNmtsh.js +461 -0
  145. package/components/picker-button/index.cjs +4 -56
  146. package/components/picker-button/index.js +34 -45
  147. package/components/{condition-attribute-with-id-Cn815e9W.js → platform-BM-uMWpX.js} +49 -24
  148. package/components/platform-BiXhwqk3.cjs +18 -0
  149. package/components/popover/index.cjs +1 -7
  150. package/components/popover/index.js +8 -12
  151. package/components/popover-fwJeZHMQ.cjs +30 -0
  152. package/components/popover-iD8f5Jkp.js +67 -0
  153. package/components/progress-circle/index.cjs +1 -7
  154. package/components/progress-circle/index.js +8 -12
  155. package/components/progress-circle-DZxaMe8L.cjs +33 -0
  156. package/components/progress-circle-USIIU1up.js +97 -0
  157. package/components/query-BL-TJj7K.cjs +22 -0
  158. package/components/query-D_KR_GUc.js +51 -0
  159. package/components/query-assigned-elements-DjfhL1cl.js +36 -0
  160. package/components/query-assigned-elements-DsKsfk7G.cjs +22 -0
  161. package/components/query-assigned-nodes-BcKWmGzy.cjs +22 -0
  162. package/components/query-assigned-nodes-C76XVPWY.js +36 -0
  163. package/components/radio/index.cjs +2 -244
  164. package/components/radio/index.js +110 -192
  165. package/components/{random-id-BEc6QIUL.js → random-id-ByCz1xaq.js} +3 -3
  166. package/components/random-id-CqvckpWe.cjs +18 -0
  167. package/components/roving-tabindex-By_fCy_e.cjs +18 -0
  168. package/components/roving-tabindex-DOg4z6ZU.js +66 -0
  169. package/components/search/index.cjs +8 -115
  170. package/components/search/index.js +66 -96
  171. package/components/select/index.cjs +51 -720
  172. package/components/select/index.js +347 -563
  173. package/components/sized-mixin-CJbBHWRQ.js +63 -0
  174. package/components/sized-mixin-WPHH0a_D.cjs +18 -0
  175. package/components/slider/index.cjs +1 -119
  176. package/components/slider/index.js +1113 -100
  177. package/components/slottable-request-event-BfUUt1Mh.cjs +18 -0
  178. package/components/{slottable-request-event-D9WzrdWv.js → slottable-request-event-DggLA4Rx.js} +9 -12
  179. package/components/state-DwIwYPvt.js +29 -0
  180. package/components/state-vf0PJN3_.cjs +22 -0
  181. package/components/strategies-C6HsQpU2.cjs +18 -0
  182. package/components/strategies-CUMLHtQI.js +195 -0
  183. package/components/streaming-listener-BQ68fKMa.js +91 -0
  184. package/components/streaming-listener-DeGQYM-9.cjs +18 -0
  185. package/components/style-map-Bnhf_mVZ.js +53 -0
  186. package/components/style-map-DuMd5xlY.cjs +22 -0
  187. package/components/swatch/index.cjs +7 -436
  188. package/components/swatch/index.js +205 -350
  189. package/components/switch/index.cjs +2 -61
  190. package/components/switch/index.js +34 -51
  191. package/components/tabs/index.cjs +26 -693
  192. package/components/tabs/index.js +388 -521
  193. package/components/tags/index.cjs +4 -201
  194. package/components/tags/index.js +87 -152
  195. package/components/text-field/index.cjs +3 -49
  196. package/components/text-field/index.js +30 -44
  197. package/components/text-field-BkFPYo7S.cjs +85 -0
  198. package/components/text-field-C2n3rzCK.js +314 -0
  199. package/components/text-field.module-C2KVUJcX.js +21 -0
  200. package/components/text-field.module-DXhFA9G-.cjs +18 -0
  201. package/components/toast/index.cjs +12 -177
  202. package/components/toast/index.js +73 -145
  203. package/components/tooltip/index.cjs +6 -250
  204. package/components/tooltip/index.js +124 -177
  205. package/components/unit-input/index.cjs +8 -232
  206. package/components/unit-input/index.js +108 -201
  207. package/components/utils.cjs +1 -25
  208. package/components/utils.js +22 -22
  209. package/components/{random-id-BE6HA503.cjs → when-CDK1Tt5Y.js} +10 -7
  210. package/components/when-CDZyJPvd.cjs +22 -0
  211. package/package.json +1 -1
  212. package/components/action-group-DHp8RHDf.js +0 -392
  213. package/components/action-group-MPf19RPV.cjs +0 -391
  214. package/components/base-COw9n7UR.cjs +0 -119
  215. package/components/base-DmeVy0cq.js +0 -120
  216. package/components/button-base-7Ak55xFd.cjs +0 -206
  217. package/components/button-base-C3kf6BTK.js +0 -207
  218. package/components/checkbox-mixin-8cL-vfDy.js +0 -84
  219. package/components/checkbox-mixin-CE7dJj3J.cjs +0 -83
  220. package/components/clear-button-Co6oKSgl.js +0 -59
  221. package/components/clear-button-X_HDY2eH.cjs +0 -58
  222. package/components/close-button-DPBK6Kpu.cjs +0 -59
  223. package/components/close-button-Miw9ZjoJ.js +0 -60
  224. package/components/color-controller-BjDZaxhX.js +0 -491
  225. package/components/color-controller-C3c_vb2P.cjs +0 -490
  226. package/components/color-loupe-BQqNR8YD.cjs +0 -88
  227. package/components/color-loupe-B_DDFv8l.js +0 -89
  228. package/components/condition-attribute-with-id-DEc2Yjne.cjs +0 -43
  229. package/components/dependency-manger-CcIE1uvQ.cjs +0 -63
  230. package/components/divider.module-Cm5LcDRV.cjs +0 -20
  231. package/components/divider.module-DauH6k2_.js +0 -21
  232. package/components/element-resolution-DCsrhGZO.cjs +0 -112
  233. package/components/element-resolution-nMlmW4Jy.js +0 -113
  234. package/components/field-group-DNmY8W9v.cjs +0 -86
  235. package/components/field-group-DVdAWCQF.js +0 -87
  236. package/components/field-label-CKH9EXpR.cjs +0 -156
  237. package/components/field-label-Dpsecoc6.js +0 -157
  238. package/components/focus-group-BqDAk9Is.js +0 -337
  239. package/components/focus-group-DFzOlalL.cjs +0 -336
  240. package/components/focus-visible-B-B8-P9R.cjs +0 -104
  241. package/components/focus-visible-BUPRWlsh.js +0 -105
  242. package/components/focusable-BPrTcZPd.cjs +0 -262
  243. package/components/focusable-ChCLg1k4.js +0 -263
  244. package/components/language-resolution-iN9EImbb.cjs +0 -57
  245. package/components/like-anchor-D62faRNG.cjs +0 -79
  246. package/components/like-anchor-v3cJ9RWM.js +0 -80
  247. package/components/manage-help-text-BYx84zZR.cjs +0 -125
  248. package/components/manage-help-text-DOuMTGht.js +0 -126
  249. package/components/observe-slot-presence-9AwLGUQ_.cjs +0 -78
  250. package/components/observe-slot-presence-DcMdoumP.js +0 -79
  251. package/components/observe-slot-text-CSofZeeF.cjs +0 -104
  252. package/components/observe-slot-text-CjnkkBPn.js +0 -105
  253. package/components/overlay-CN8ISP1F.js +0 -2485
  254. package/components/overlay-LViy9VWM.cjs +0 -2484
  255. package/components/pending-state-e4RbXe9u.cjs +0 -75
  256. package/components/picker-DNde3awt.cjs +0 -672
  257. package/components/picker-PfUAF05y.js +0 -673
  258. package/components/platform-CxDar3Dn.cjs +0 -68
  259. package/components/platform-Cxn0WbyT.js +0 -69
  260. package/components/popover-BkbYhl3i.js +0 -74
  261. package/components/popover-BkgUf0kL.cjs +0 -74
  262. package/components/progress-circle-Hu_ivPHf.js +0 -133
  263. package/components/progress-circle-_Etqsj9f.cjs +0 -132
  264. package/components/roving-tabindex-AsmAh2In.cjs +0 -95
  265. package/components/roving-tabindex-DPF9NmrH.js +0 -96
  266. package/components/sized-mixin-DmkrNdWB.js +0 -80
  267. package/components/sized-mixin-UaTVa-AE.cjs +0 -79
  268. package/components/strategies-DlMlaSJR.cjs +0 -317
  269. package/components/strategies-DlPQoTFE.js +0 -318
  270. package/components/streaming-listener-D4sHaMub.cjs +0 -145
  271. package/components/streaming-listener-cAz5zJyk.js +0 -146
  272. package/components/text-field-11tcnftU.cjs +0 -338
  273. package/components/text-field-Chi9J2Cz.js +0 -339
  274. package/components/text-field.module-CMBS0jSL.js +0 -21
  275. package/components/text-field.module-DIJdV_sA.cjs +0 -20
@@ -1,491 +0,0 @@
1
- /*! * Lucero - The design system for Luzmo.
2
- *
3
- * Copyright © 2025 Luzmo
4
- * All rights reserved.
5
- * Lucero (“Luzmo Design System”) must be used according to the Luzmo Terms of Service.
6
- * This license allows users with a current active Luzmo account to use Lucero.
7
- * This license terminates automatically if a user no longer has an active Luzmo account.
8
- * Please view the Luzmo Terms of Service at: https://www.luzmo.com/information-pages/terms-of-use.
9
- *
10
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
11
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
12
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
13
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
14
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
15
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
16
- * SOFTWARE.
17
- * */
18
- import Color from "colorjs.io";
19
- class ColorController {
20
- /**
21
- * Creates an instance of ColorController.
22
- *
23
- * @param host - The ReactiveElement that this controller is associated with.
24
- * @param options - An object containing optional parameters.
25
- * @param options.manageAs - A string to manage the controller as a specific type.
26
- */
27
- constructor(host, {
28
- manageAs
29
- } = {}) {
30
- this._color = new Color("hsv", [0, 100, 100], 1);
31
- this.host = host;
32
- this.manageAs = manageAs;
33
- }
34
- get color() {
35
- return this._color;
36
- }
37
- /**
38
- * Validates a color string and returns a result indicating the color space,
39
- * coordinates, alpha value, and whether the color is valid.
40
- *
41
- * @param color - The color string to validate. Supported formats include:
42
- * - RGB: `rgb(r, g, b)`, `rgba(r, g, b, a)`, `rgb r g b`, `rgba r g b a`
43
- * - HSL: `hsl(h, s, l)`, `hsla(h, s, l, a)`, `hsl h s l`, `hsla h s l a`
44
- * - HSV: `hsv(h, s, v)`, `hsva(h, s, v, a)`, `hsv h s v`, `hsva h s v a`
45
- * - HEX: `#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`
46
- *
47
- * @returns An object containing the following properties:
48
- * - `spaceId`: The color space identifier (`'srgb'`, `'hsl'`, or `'hsv'`).
49
- * - `coords`: An array of numeric values representing the color coordinates.
50
- * - `alpha`: The alpha value of the color (0 to 1).
51
- * - `isValid`: A boolean indicating whether the color string is valid.
52
- */
53
- validateColorString(color) {
54
- var _a, _b, _c, _d;
55
- const result = {
56
- spaceId: null,
57
- coords: [0, 0, 0],
58
- isValid: false,
59
- alpha: 1
60
- };
61
- const rgbRegExpArray = [
62
- // With commas
63
- /rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d*\.?\d+)\s*\)/i,
64
- // rgba(r, g, b, a)
65
- /rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)/i,
66
- // rgb(r, g, b)
67
- // With spaces
68
- /^rgba\s+(\d{1,3})\s+(\d{1,3})\s+(\d{1,3})\s+(0|0?\.\d+|1)\s*$/i,
69
- // rgba r g b a
70
- /^rgb\s+(\d{1,3})\s+(\d{1,3})\s+(\d{1,3})\s*$/i,
71
- // rgb r g b
72
- // Spaces inside parentheses
73
- /^rgba\(\s*(\d{1,3})\s+(\d{1,3})\s+(\d{1,3})\s+(\d*\.?\d+)\s*\)$/i,
74
- // rgba(r g b a)
75
- /^rgb\(\s*(\d{1,3})\s+(\d{1,3})\s+(\d{1,3})\s*\)$/i,
76
- // rgb(r g b)
77
- // Percentage values
78
- /rgb\(\s*(100|[0-9]{1,2}%)\s*,\s*(100|[0-9]{1,2}%)\s*,\s*(100|[0-9]{1,2}%)\s*\)/i,
79
- // rgb(r%, g%, b%)
80
- /rgba\(\s*(100|[0-9]{1,2})%\s*,\s*(100|[0-9]{1,2})%\s*,\s*(100|[0-9]{1,2})%\s*,\s*(\d*\.?\d+)\s*\)/i
81
- // rgba(r%, g%, b%, a)
82
- ];
83
- const hslRegExpArray = [
84
- // With commas
85
- /hsla\(\s*(\d{1,3})\s*,\s*(\d{1,3}%?)\s*,\s*(\d{1,3}%?)\s*,\s*(\d*\.?\d+)\s*\)/i,
86
- // hsla(h, s, l, a)
87
- /hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3}%?)\s*,\s*(\d{1,3}%?)\s*\)/i,
88
- // hsl(h, s, l)
89
- // With spaces
90
- /^hsla\s+(\d{1,3})\s+(\d{1,3}%?)\s+(\d{1,3}%?)\s+(\d*\.?\d+)\s*$/i,
91
- // hsla h s l a
92
- /^hsl\s+(\d{1,3})\s+(\d{1,3}%?)\s+(\d{1,3}%?)\s*$/i,
93
- // hsl h s l
94
- // Spaces inside parentheses
95
- /^hsla\(\s*(\d{1,3})\s+(\d{1,3}%?)\s+(\d{1,3}%?)\s+(\d*\.?\d+)\s*\)$/i,
96
- // hsla(h s l a)
97
- /^hsl\(\s*(\d{1,3})\s+(\d{1,3}%?)\s+(\d{1,3}%?)\s*\)$/i
98
- // hsl(h s l)
99
- ];
100
- const hsvRegExpArray = [
101
- // With commas
102
- /hsva\(\s*(\d{1,3})\s*,\s*(\d{1,3}%?)\s*,\s*(\d{1,3}%?)\s*,\s*(\d*\.?\d+)\s*\)/i,
103
- // hsva(h, s, v, a)
104
- /hsv\(\s*(\d{1,3})\s*,\s*(\d{1,3}%?)\s*,\s*(\d{1,3}%?)\s*\)/i,
105
- // hsv(h, s, v)
106
- // With spaces
107
- /^hsva\s+(\d{1,3})\s+(\d{1,3}%?)\s+(\d{1,3}%?)\s+(\d*\.?\d+)\s*$/i,
108
- // hsva h s v a
109
- /^hsv\s+(\d{1,3})\s+(\d{1,3}%?)\s+(\d{1,3}%?)\s*$/i,
110
- // hsv h s v
111
- // Spaces inside parentheses
112
- /^hsva\(\s*(\d{1,3})\s+(\d{1,3}%?)\s+(\d{1,3}%?)\s+(\d*\.?\d+)\s*\)$/i,
113
- // hsva(h s v a)
114
- /^hsv\(\s*(\d{1,3})\s+(\d{1,3}%?)\s+(\d{1,3}%?)\s*\)$/i
115
- // hsv(h s v)
116
- ];
117
- const hexRegExpArray = [
118
- /^#([A-Fa-f0-9]{6})([A-Fa-f0-9]{2})?$/,
119
- // 6-digit hex with optional hex alpha
120
- /^#([A-Fa-f0-9]{3})([A-Fa-f0-9]{1})?$/
121
- // 3-digit hex with optional hex alpha
122
- ];
123
- const rgbaMatch = (_a = rgbRegExpArray.find((regex) => regex.test(color))) == null ? void 0 : _a.exec(color);
124
- const hslaMatch = (_b = hslRegExpArray.find((regex) => regex.test(color))) == null ? void 0 : _b.exec(color);
125
- const hsvaMatch = (_c = hsvRegExpArray.find((regex) => regex.test(color))) == null ? void 0 : _c.exec(color);
126
- const hexMatch = (_d = hexRegExpArray.find((regex) => regex.test(color))) == null ? void 0 : _d.exec(color);
127
- if (rgbaMatch) {
128
- const [, r, g, b, a] = rgbaMatch.filter(
129
- (element) => typeof element === "string"
130
- );
131
- const alpha = a === void 0 ? 1 : Number(a);
132
- const processValue = (value) => {
133
- if (value.includes("%")) {
134
- return Number(value.replace("%", "")) / 100;
135
- }
136
- return Number(value) / 255;
137
- };
138
- const numericR = processValue(r);
139
- const numericG = processValue(g);
140
- const numericB = processValue(b);
141
- result.spaceId = "srgb";
142
- result.coords = [numericR, numericG, numericB];
143
- result.alpha = alpha;
144
- result.isValid = numericR >= 0 && numericR <= 1 && numericG >= 0 && numericG <= 1 && numericB >= 0 && numericB <= 1 && alpha >= 0 && alpha <= 1;
145
- } else if (hslaMatch) {
146
- const [, h, s, l, a] = hslaMatch;
147
- const values = [h, s, l, a === void 0 ? "1" : a].map(
148
- (value) => Number(value.replaceAll(/[^\d.]/g, ""))
149
- );
150
- const [numericH, numericS, numericL, numericA] = values;
151
- result.spaceId = "hsl";
152
- result.coords = [numericH, numericS, numericL];
153
- result.alpha = numericA;
154
- result.isValid = numericH >= 0 && numericH <= 360 && numericS >= 0 && numericS <= 100 && numericL >= 0 && numericL <= 100 && numericA >= 0 && numericA <= 1;
155
- } else if (hsvaMatch) {
156
- const [, h, s, v, a] = hsvaMatch;
157
- const values = [h, s, v, a === void 0 ? "1" : a].map(
158
- (value) => Number(value.replaceAll(/[^\d.]/g, ""))
159
- );
160
- const [numericH, numericS, numericV, numericA] = values;
161
- result.spaceId = "hsv";
162
- result.coords = [numericH, numericS, numericV];
163
- result.alpha = numericA;
164
- result.isValid = numericH >= 0 && numericH <= 360 && numericS >= 0 && numericS <= 100 && numericV >= 0 && numericV <= 100 && numericA >= 0 && numericA <= 1;
165
- } else if (hexMatch) {
166
- const [, hex, alphaHex] = hexMatch;
167
- const processHex = (hexVal) => {
168
- if (hexVal.length === 1) {
169
- hexVal = hexVal + hexVal;
170
- }
171
- return Number.parseInt(hexVal, 16) / 255;
172
- };
173
- let numericR;
174
- let numericG;
175
- let numericB;
176
- if (hex.length === 3) {
177
- numericR = processHex(hex.slice(0, 1));
178
- numericG = processHex(hex.slice(1, 2));
179
- numericB = processHex(hex.slice(2, 3));
180
- } else {
181
- numericR = processHex(hex.slice(0, 2));
182
- numericG = processHex(hex.slice(2, 4));
183
- numericB = processHex(hex.slice(4, 6));
184
- }
185
- const numericA = alphaHex ? processHex(alphaHex) : 1;
186
- result.spaceId = "srgb";
187
- result.coords = [numericR, numericG, numericB];
188
- result.alpha = numericA;
189
- result.isValid = numericR >= 0 && numericR <= 1 && numericG >= 0 && numericG <= 1 && numericB >= 0 && numericB <= 1 && numericA >= 0 && numericA <= 1;
190
- }
191
- return result;
192
- }
193
- /**
194
- * Gets the original color value provided by the user.
195
- *
196
- * @returns The original color value.
197
- */
198
- get colorOrigin() {
199
- return this._colorOrigin;
200
- }
201
- /**
202
- * Sets the original color value provided by the user.
203
- *
204
- * @param colorOrigin - The original color value to set.
205
- */
206
- set colorOrigin(colorOrigin) {
207
- this._colorOrigin = colorOrigin;
208
- }
209
- /**
210
- * Sets the color value for the controller. The color can be provided in various formats:
211
- * - A string representing a color name, hex code, or other color format.
212
- * - An instance of the `Color` class.
213
- * - An object containing color properties such as `h`, `s`, `l`, `v`, `r`, `g`, `b`, and optionally `a`.
214
- *
215
- * The method validates and parses the input color, converting it to a `Color` instance.
216
- * If the color is invalid, it attempts to parse it as a hex code or returns without setting a new color.
217
- *
218
- * @param color - The color value to set. It can be a string, an instance of `Color`, or an object with color properties.
219
- */
220
- set color(color) {
221
- this._colorOrigin = color;
222
- let newColor;
223
- if (typeof color === "string") {
224
- const colorValidationResult = this.validateColorString(color);
225
- if (colorValidationResult.isValid) {
226
- const [coord1, coord2, coord3] = colorValidationResult.coords;
227
- newColor = new Color(
228
- `${colorValidationResult.spaceId}`,
229
- [coord1, coord2, coord3],
230
- colorValidationResult.alpha
231
- );
232
- } else {
233
- try {
234
- Color.parse(color);
235
- } catch {
236
- try {
237
- newColor = new Color(`#${color}`);
238
- } catch {
239
- return;
240
- }
241
- }
242
- }
243
- } else if (color instanceof Color) {
244
- newColor = color;
245
- } else if (!Array.isArray(color)) {
246
- const { h, s, l, v, r, g, b, a } = color;
247
- if (h !== void 0 && s !== void 0) {
248
- const lv = l ?? v;
249
- newColor = new Color(
250
- l === void 0 ? "hsv" : "hsl",
251
- [
252
- Number.parseFloat(h),
253
- typeof s === "string" ? Number.parseFloat(s) : s * 100,
254
- typeof lv === "string" ? Number.parseFloat(lv) : lv * 100
255
- ],
256
- Number.parseFloat(a || "1")
257
- );
258
- } else if (r !== void 0 && g !== void 0 && b !== void 0) {
259
- newColor = new Color(
260
- "srgb",
261
- [
262
- Number.parseFloat(r) / 255,
263
- Number.parseFloat(g) / 255,
264
- Number.parseFloat(b) / 255
265
- ],
266
- Number.parseFloat(a || "1")
267
- );
268
- }
269
- }
270
- if (!newColor) {
271
- newColor = new Color(color);
272
- }
273
- this._color = this.manageAs ? newColor.to(this.manageAs) : newColor;
274
- this.host.requestUpdate();
275
- }
276
- /**
277
- * Gets the color value in various formats based on the original color input.
278
- *
279
- * The method determines the color space of the original color input and converts
280
- * the color to the appropriate format. The supported color spaces are:
281
- * - HSV (Hue, Saturation, Value)
282
- * - HSL (Hue, Saturation, Lightness)
283
- * - Hexadecimal (with or without alpha)
284
- * - RGB (Red, Green, Blue) with optional alpha
285
- *
286
- * @returns The color value in the appropriate format.
287
- *
288
- * The method handles the following cases:
289
- * - If the original color input is a string, it checks the prefix to determine the color space.
290
- * - If the original color input is an object, it checks the properties to determine the color space.
291
- * - If the original color input is not provided, it defaults to the current color space of the color object.
292
- *
293
- * The returned color value can be in one of the following formats:
294
- * - `hsv(h, s%, v%)` or `hsva(h, s%, v%, a)`
295
- * - `hsl(h, s%, l%)` or `hsla(h, s%, l%, a)`
296
- * - `#rrggbb` or `#rrggbbaa`
297
- * - `rgb(r, g, b)` or `rgba(r, g, b, a)`
298
- * - `{ h, s, v, a }` for HSV object
299
- * - `{ h, s, l, a }` for HSL object
300
- * - `{ r, g, b, a }` for RGB object
301
- */
302
- get colorValue() {
303
- let spaceId;
304
- if (typeof this._colorOrigin === "string") {
305
- if (this._colorOrigin.startsWith("#")) {
306
- spaceId = "hex string";
307
- } else if (this._colorOrigin.startsWith("rgb")) {
308
- spaceId = "rgb";
309
- } else if (this._colorOrigin.startsWith("hsl")) {
310
- spaceId = "hsl";
311
- } else if (this._colorOrigin.startsWith("hsv")) {
312
- spaceId = "hsv";
313
- } else {
314
- spaceId = "hex";
315
- }
316
- switch (spaceId) {
317
- case "hsv": {
318
- const hadAlpha = this._colorOrigin[3] === "a";
319
- const { h, s, v } = this._color.to("hsv").hsv;
320
- const a = this._color.alpha;
321
- return `hsv${hadAlpha ? `a` : ""}(${Math.round(
322
- h
323
- )}, ${Math.round(s)}%, ${Math.round(v)}%${hadAlpha ? `, ${a}` : ""})`;
324
- }
325
- case "hsl": {
326
- const hadAlpha = this._colorOrigin[3] === "a";
327
- const { h, s, l } = this._color.to("hsl").hsl;
328
- const a = this._color.alpha;
329
- return `hsl${hadAlpha ? `a` : ""}(${Math.round(
330
- h
331
- )}, ${Math.round(s)}%, ${Math.round(l)}%${hadAlpha ? `, ${a}` : ""})`;
332
- }
333
- case "hex string": {
334
- const { r, g, b } = this._color.to("srgb").srgb;
335
- const hadAlpha = this._colorOrigin.length === 5 || this._colorOrigin.length === 9;
336
- const a = this._color.alpha;
337
- const rHex = Math.round(r * 255).toString(16);
338
- const gHex = Math.round(g * 255).toString(16);
339
- const bHex = Math.round(b * 255).toString(16);
340
- const aHex = Math.round(a * 255).toString(16);
341
- return `#${rHex.padStart(2, "0")}${gHex.padStart(
342
- 2,
343
- "0"
344
- )}${bHex.padStart(2, "0")}${hadAlpha ? aHex.padStart(2, "0") : ""}`;
345
- }
346
- case "hex": {
347
- const { r, g, b } = this._color.to("srgb").srgb;
348
- const hadAlpha = this._colorOrigin.length === 4 || this._colorOrigin.length === 8;
349
- const a = this._color.alpha;
350
- const rHex = Math.round(r * 255).toString(16);
351
- const gHex = Math.round(g * 255).toString(16);
352
- const bHex = Math.round(b * 255).toString(16);
353
- const aHex = Math.round(a * 255).toString(16);
354
- return `${rHex.padStart(2, "0")}${gHex.padStart(
355
- 2,
356
- "0"
357
- )}${bHex.padStart(2, "0")}${hadAlpha ? aHex.padStart(2, "0") : ""}`;
358
- }
359
- // rgb
360
- default: {
361
- const { r, g, b } = this._color.to("srgb").srgb;
362
- const hadAlpha = this._colorOrigin[3] === "a";
363
- const a = this._color.alpha;
364
- if (this._colorOrigin.search("%") > -1) {
365
- return `rgb${hadAlpha ? `a` : ""}(${Math.round(r * 100)}%, ${Math.round(
366
- g * 100
367
- )}%, ${Math.round(b * 100)}%${hadAlpha ? `,${Math.round(a * 100)}%` : ""})`;
368
- }
369
- return `rgb${hadAlpha ? `a` : ""}(${Math.round(r * 255)}, ${Math.round(
370
- g * 255
371
- )}, ${Math.round(b * 255)}${hadAlpha ? `, ${a}` : ""})`;
372
- }
373
- }
374
- }
375
- if (this._colorOrigin) {
376
- try {
377
- ({ spaceId } = new Color(this._colorOrigin));
378
- } catch {
379
- const { h, s, l, v, r, g, b } = this._colorOrigin;
380
- if (h !== void 0 && s !== void 0 && l !== void 0) {
381
- spaceId = "hsl";
382
- } else if (h !== void 0 && s !== void 0 && v !== void 0) {
383
- spaceId = "hsv";
384
- } else if (r !== void 0 && g !== void 0 && b !== void 0) {
385
- spaceId = "srgb";
386
- }
387
- }
388
- } else {
389
- ({ spaceId } = this.color);
390
- }
391
- switch (spaceId) {
392
- case "hsv": {
393
- const { h, s, v } = this._color.to("hsv").hsv;
394
- return {
395
- h,
396
- s: s / 100,
397
- v: v / 100,
398
- a: this._color.alpha
399
- };
400
- }
401
- case "hsl": {
402
- const { h, s, l } = this._color.to("hsl").hsl;
403
- return {
404
- h,
405
- s: s / 100,
406
- l: l / 100,
407
- a: this._color.alpha
408
- };
409
- }
410
- case "srgb": {
411
- const { r, g, b } = this._color.to("srgb").srgb;
412
- if (this._colorOrigin && typeof this._colorOrigin.r === "string" && this._colorOrigin.r.search("%")) {
413
- return {
414
- r: `${Math.round(r * 255)}%`,
415
- g: `${Math.round(g * 255)}%`,
416
- b: `${Math.round(b * 255)}%`,
417
- a: this._color.alpha
418
- };
419
- }
420
- return {
421
- r: Math.round(r * 255),
422
- g: Math.round(g * 255),
423
- b: Math.round(b * 255),
424
- a: this._color.alpha
425
- };
426
- }
427
- }
428
- return this._color;
429
- }
430
- /**
431
- * Gets the hue value of the current color in HSL format.
432
- *
433
- * @returns The hue value as a number.
434
- */
435
- get hue() {
436
- return Number(this._color.to("hsl").hsl.h);
437
- }
438
- /**
439
- * Sets the hue value of the color and requests an update from the host.
440
- *
441
- * @param hue - The hue value to set, represented as a number.
442
- */
443
- set hue(hue) {
444
- this._color.set("h", hue);
445
- this.host.requestUpdate();
446
- }
447
- /**
448
- * Converts the current color to the specified format.
449
- *
450
- * @param format - The desired color format. It can be a string representing one of the valid formats
451
- * ('srgb', 'hsva', 'hsv', 'hsl', 'hsla') or a ColorSpace object.
452
- * @returns The color object in the specified format.
453
- * @throws Will throw an error if the provided format is not a valid string format.
454
- */
455
- getColor(format) {
456
- const validFormats = ["srgb", "hsva", "hsv", "hsl", "hsla"];
457
- if (typeof format === "string" && !validFormats.includes(format)) {
458
- throw new Error("not a valid format");
459
- }
460
- return this._color.to(format);
461
- }
462
- /**
463
- * Converts the current color to an HSL string representation.
464
- *
465
- * @returns The HSL string representation of the current color.
466
- */
467
- getHslString() {
468
- return this._color.to("hsl").toString();
469
- }
470
- /**
471
- * Saves the current color state by cloning the current color and storing it
472
- * as the previous color. This allows for the ability to revert to the previous
473
- * color state if needed.
474
- *
475
- * @returns
476
- */
477
- savePreviousColor() {
478
- this._previousColor = this._color.clone();
479
- }
480
- /**
481
- * Restores the color to the previously saved color value.
482
- *
483
- * This method sets the current color (`_color`) to the previously stored color (`_previousColor`).
484
- */
485
- restorePreviousColor() {
486
- this._color = this._previousColor;
487
- }
488
- }
489
- export {
490
- ColorController as C
491
- };