@eightshift/ui-components 4.0.0 → 5.0.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 (144) hide show
  1. package/package.json +101 -101
  2. package/dist/Button-CvzGKGCo.js +0 -185
  3. package/dist/Collection-ddre1L5v.js +0 -2332
  4. package/dist/Color-MV5kBVXr.js +0 -2452
  5. package/dist/ColorSwatch-BqQfVu4L.js +0 -64
  6. package/dist/ComboBox-jQ-dk95U.js +0 -1906
  7. package/dist/Dialog-DX1aiYyE.js +0 -2300
  8. package/dist/FieldError-52GVSGgC.js +0 -42
  9. package/dist/FocusScope-Cri5BFRz.js +0 -831
  10. package/dist/Form-Cq3fu75_.js +0 -5
  11. package/dist/Group-_emcIVxI.js +0 -48
  12. package/dist/Heading-B2153VXe.js +0 -16
  13. package/dist/Hidden-rE6uR-lr.js +0 -41
  14. package/dist/Input-BxpFEIXV.js +0 -133
  15. package/dist/Label-icmbmNdI.js +0 -17
  16. package/dist/List-BYNHbol3.js +0 -593
  17. package/dist/ListBox-mJ4nQaL7.js +0 -581
  18. package/dist/NumberFormatter-DA8u1Ot7.js +0 -140
  19. package/dist/OverlayArrow-BB0CWwdq.js +0 -629
  20. package/dist/RSPContexts-2lR5GG9p.js +0 -14
  21. package/dist/Select-aab027f3.esm--EmXjiL3.js +0 -2469
  22. package/dist/Separator-D9moUgP8.js +0 -322
  23. package/dist/Slider-rz2XRMGm.js +0 -853
  24. package/dist/Text-DVSAPY-K.js +0 -16
  25. package/dist/VisuallyHidden-f9zX67a_.js +0 -48
  26. package/dist/_commonjsHelpers-CUmg6egw.js +0 -6
  27. package/dist/assets/index.css +0 -37
  28. package/dist/assets/style-admin.css +0 -5255
  29. package/dist/assets/style-editor.css +0 -5255
  30. package/dist/assets/style.css +0 -5261
  31. package/dist/assets/wp-font-enhancements.css +0 -8
  32. package/dist/assets/wp-ui-enhancements.css +0 -299
  33. package/dist/components/animated-visibility/animated-visibility.js +0 -105
  34. package/dist/components/base-control/base-control.js +0 -86
  35. package/dist/components/breakpoint-preview/breakpoint-preview.js +0 -161
  36. package/dist/components/button/button.js +0 -387
  37. package/dist/components/checkbox/checkbox.js +0 -320
  38. package/dist/components/color-pickers/color-picker.js +0 -272
  39. package/dist/components/color-pickers/color-swatch.js +0 -58
  40. package/dist/components/color-pickers/gradient-editor.js +0 -534
  41. package/dist/components/color-pickers/solid-color-picker.js +0 -1567
  42. package/dist/components/component-toggle/component-toggle.js +0 -158
  43. package/dist/components/container-panel/container-panel.js +0 -131
  44. package/dist/components/draggable/draggable-context.js +0 -5
  45. package/dist/components/draggable/draggable-handle.js +0 -46
  46. package/dist/components/draggable/draggable.js +0 -6207
  47. package/dist/components/draggable-list/draggable-list-context.js +0 -5
  48. package/dist/components/draggable-list/draggable-list-item.js +0 -77
  49. package/dist/components/draggable-list/draggable-list.js +0 -151
  50. package/dist/components/expandable/expandable.js +0 -342
  51. package/dist/components/index.js +0 -137
  52. package/dist/components/input-field/input-field.js +0 -231
  53. package/dist/components/item-collection/item-collection.js +0 -59
  54. package/dist/components/layout/hstack.js +0 -30
  55. package/dist/components/layout/vstack.js +0 -30
  56. package/dist/components/link-input/link-input.js +0 -293
  57. package/dist/components/matrix-align/matrix-align.js +0 -134
  58. package/dist/components/menu/menu.js +0 -285
  59. package/dist/components/modal/modal.js +0 -305
  60. package/dist/components/notice/notice.js +0 -123
  61. package/dist/components/number-picker/number-picker.js +0 -292
  62. package/dist/components/option-select/option-select.js +0 -264
  63. package/dist/components/options-panel/options-panel.js +0 -158
  64. package/dist/components/placeholders/file-placeholder.js +0 -42
  65. package/dist/components/placeholders/image-placeholder.js +0 -88
  66. package/dist/components/placeholders/media-placeholder.js +0 -63
  67. package/dist/components/popover/popover.js +0 -207
  68. package/dist/components/radio/radio.js +0 -579
  69. package/dist/components/repeater/repeater-context.js +0 -5
  70. package/dist/components/repeater/repeater-item.js +0 -119
  71. package/dist/components/repeater/repeater.js +0 -280
  72. package/dist/components/responsive/mini-responsive.js +0 -498
  73. package/dist/components/responsive/responsive-legacy.js +0 -343
  74. package/dist/components/responsive/responsive.js +0 -580
  75. package/dist/components/responsive-preview/responsive-preview.js +0 -123
  76. package/dist/components/rich-label/rich-label.js +0 -66
  77. package/dist/components/select/async-multi-select.js +0 -157
  78. package/dist/components/select/async-single-select.js +0 -137
  79. package/dist/components/select/custom-select-default-components.js +0 -38
  80. package/dist/components/select/multi-select-components.js +0 -8
  81. package/dist/components/select/multi-select.js +0 -151
  82. package/dist/components/select/react-select-component-wrappers.js +0 -90
  83. package/dist/components/select/shared.js +0 -26
  84. package/dist/components/select/single-select.js +0 -131
  85. package/dist/components/select/styles.js +0 -49
  86. package/dist/components/select/v2/async-select.js +0 -297
  87. package/dist/components/select/v2/shared.js +0 -24
  88. package/dist/components/select/v2/single-select.js +0 -990
  89. package/dist/components/slider/column-config-slider.js +0 -210
  90. package/dist/components/slider/slider.js +0 -343
  91. package/dist/components/slider/utils.js +0 -84
  92. package/dist/components/spacer/spacer.js +0 -97
  93. package/dist/components/tabs/tabs.js +0 -702
  94. package/dist/components/toggle/switch.js +0 -155
  95. package/dist/components/toggle/toggle.js +0 -64
  96. package/dist/components/toggle-button/toggle-button.js +0 -324
  97. package/dist/components/tooltip/tooltip.js +0 -525
  98. package/dist/context-D2KUdwNL.js +0 -92
  99. package/dist/default-i18n-CT_oS1Fy.js +0 -922
  100. package/dist/filterDOMProps-EDDcM64A.js +0 -28
  101. package/dist/icons/block-icon.js +0 -42
  102. package/dist/icons/generic-color-swatch.js +0 -113
  103. package/dist/icons/icons.js +0 -30371
  104. package/dist/icons/index.js +0 -11
  105. package/dist/icons/jsx-svg.js +0 -50
  106. package/dist/index-641ee5b8.esm-BPz6U6sJ.js +0 -3137
  107. package/dist/index-BKGQ6jGS.js +0 -44
  108. package/dist/index-BYHhzLf-.js +0 -444
  109. package/dist/index.js +0 -139
  110. package/dist/lite-DVmmD_-j.js +0 -7
  111. package/dist/modifiers.esm-BuJQPI1X.js +0 -31
  112. package/dist/multi-select-components-BlZZoNXC.js +0 -3744
  113. package/dist/number-GajL10e1.js +0 -36
  114. package/dist/react-jsx-parser.min-DZCiis5V.js +0 -11753
  115. package/dist/react-select-async.esm-CwUoej5h.js +0 -107
  116. package/dist/react-select.esm-DcwYxadV.js +0 -15
  117. package/dist/style-admin.js +0 -1
  118. package/dist/style-editor.js +0 -1
  119. package/dist/style.js +0 -1
  120. package/dist/textSelection-0UUS8Yfg.js +0 -46
  121. package/dist/useButton-BpOKDWEN.js +0 -71
  122. package/dist/useEvent-B0b-6KBr.js +0 -23
  123. package/dist/useFocusRing-CV5l3lf6.js +0 -107
  124. package/dist/useFormReset-C5OggHsw.js +0 -22
  125. package/dist/useFormValidation-DhDNSjws.js +0 -224
  126. package/dist/useHover-DwDr6ozG.js +0 -900
  127. package/dist/useLabel-D7HkNEHT.js +0 -27
  128. package/dist/useLabels-D8cxd1Z8.js +0 -23
  129. package/dist/useListState-UGlN5-7P.js +0 -161
  130. package/dist/useLocalizedStringFormatter-CFP1YZWQ.js +0 -121
  131. package/dist/useNumberField-CEAj7Mrj.js +0 -1204
  132. package/dist/useNumberFormatter-321rAb4J.js +0 -13
  133. package/dist/usePress-DNW8qpY6.js +0 -664
  134. package/dist/useSingleSelectListState-DC0wWTUM.js +0 -38
  135. package/dist/useToggle-BrpmSOB-.js +0 -59
  136. package/dist/useToggleState-CmQX3SoX.js +0 -19
  137. package/dist/utilities/array-helpers.js +0 -56
  138. package/dist/utilities/debounce-throttle.js +0 -123
  139. package/dist/utilities/es-dash.js +0 -376
  140. package/dist/utilities/index.js +0 -27
  141. package/dist/utilities/text-helpers.js +0 -136
  142. package/dist/utils-DkCSC521.js +0 -370
  143. package/dist/wp/wp-font-enhancements.js +0 -1
  144. package/dist/wp/wp-ui-enhancements.js +0 -1
@@ -1,1567 +0,0 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import React__default, { useMemo, useRef, useState, useCallback, forwardRef, createContext, useContext } from "react";
3
- import { b as $4e85f108e88277b8$export$ebe63fadcdce34ed, c as $4e85f108e88277b8$export$44644b8a16031b5b, d as $4e85f108e88277b8$export$717b2c0a523a0b53 } from "../../RSPContexts-2lR5GG9p.js";
4
- import { d as $3ef42575df84b30b$export$9d1611c77c2fe928, e as $bdb11010cef70236$export$f680877a34711e37, b as $64fa3d84918910a7$export$4d86445c2cf5e3, a as $64fa3d84918910a7$export$29f1550f4b0d4415, i as $64fa3d84918910a7$export$2881499e37b75b9a, g as $64fa3d84918910a7$export$9d4c57ee4c6ffdd8, h as $64fa3d84918910a7$export$ef03459518577ad4 } from "../../utils-DkCSC521.js";
5
- import { $ as $65484d02dcb7eb3e$export$457c3d6518dd4c6f } from "../../filterDOMProps-EDDcM64A.js";
6
- import { a as $9ab94262bd0047c7$export$420e68273165f4ec, $ as $f7dceffc5ad7768b$export$4e328f61c538687f } from "../../useFocusRing-CV5l3lf6.js";
7
- import { b as $458b0a5536c1a7cf$export$40bfa8c7b0832715, g as $03deb23ff14920c4$export$4eaf04e54aa8eed6, y as $7215afc6de606d6b$export$de79e2c695e052f3, z as $46d819fcbaf35654$export$8f71654801c2f7cd, o as $a1ea59d68270f0dd$export$f8168d8dd8fd66e6, c as $c87311424ea30a05$export$fedb369cb70207f1, u as $c87311424ea30a05$export$a11b0059900ceec8, $ as $6179b936705e76d3$export$ae780daf29e6d456 } from "../../useHover-DwDr6ozG.js";
8
- import { $ as $799cddbef784668f$export$6e865ea70d7724f, b as $799cddbef784668f$export$4cde5df63f53f473, a as $3493a52097159720$exports } from "../../Color-MV5kBVXr.js";
9
- import { $ as $9446cca9a3875146$export$cb6e0bb50bc19463, a as $9446cca9a3875146$export$7d15b64cf5a3a4c4 } from "../../number-GajL10e1.js";
10
- import { $ as $313b98861ee5dd6c$export$d6875122194c7b44 } from "../../useLabels-D8cxd1Z8.js";
11
- import { $ as $99facab73266f662$export$5add1d006293d136 } from "../../useFormReset-C5OggHsw.js";
12
- import { e as $28f99e3e86e6ec45$export$e5fda3247f5d67f9, f as $e8a7022cf87cba2a$export$36da96379f79f245, g as $bcca50147b47f54d$export$56b2c08e277f365, h as $47b897dc8cdb026b$export$8d15029008292ae, d as $6f909507e6374d18$export$1e7083018727fa60, i as $6f909507e6374d18$export$f1fce0420cc6d8ee, j as $6f909507e6374d18$export$6189c2744041d8f8, a as $6f909507e6374d18$export$105594979f116971 } from "../../Slider-rz2XRMGm.js";
13
- import { $ as $18f2051aff69b9bf$export$43bb16f9c6d9e3f7 } from "../../context-D2KUdwNL.js";
14
- import { $ as $fca6afa0e843324b$export$f12b703ca79dfbb1 } from "../../useLocalizedStringFormatter-CFP1YZWQ.js";
15
- import { a as $5c3e21d68f1c4674$export$a966af930f325cab } from "../../VisuallyHidden-f9zX67a_.js";
16
- import { $ as $ee014567cb39d3f0$export$ff05c3ac10437e03 } from "../../FieldError-52GVSGgC.js";
17
- import { a as $3985021b0ad6602f$export$37fb8590cf2c088c, $ as $3985021b0ad6602f$export$f5b8910cec6cf069 } from "../../Input-BxpFEIXV.js";
18
- import { a as $01b77f81d0f07f68$export$75b6ee27786ba447, $ as $01b77f81d0f07f68$export$b04be29aa201d4f5 } from "../../Label-icmbmNdI.js";
19
- import { a as $514c0188e459b4c0$export$9afb8bc826b033ea } from "../../Text-DVSAPY-K.js";
20
- import { $ as $de67e98908f0c6ee$export$7f629e9dc1ecf37c, b as $d2e8511e6f209edf$export$e908e06f4b8e3402, c as $7d0a636d7a4dcefd$export$2123ff2b87c81ca, d as $d841c8010a73d545$export$4f384c9210e583c3, a as $81397a9303501bda$export$23f548e970bdf099 } from "../../useNumberField-CEAj7Mrj.js";
21
- import { $ as $e5be200c675c3b3a$export$fc1a364ae1f3ff10, b as $e5be200c675c3b3a$export$a763b9476acd3eb } from "../../useFormValidation-DhDNSjws.js";
22
- import { c as clsx } from "../../lite-DVmmD_-j.js";
23
- import { BaseControl } from "../base-control/base-control.js";
24
- import { _ as __ } from "../../default-i18n-CT_oS1Fy.js";
25
- import { TriggeredPopover } from "../popover/popover.js";
26
- import { icons } from "../../icons/icons.js";
27
- import { Tabs, TabList, Tab, TabPanel } from "../tabs/tabs.js";
28
- const $6e14a98a7f67141d$var$DEFAULT_COLOR = $799cddbef784668f$export$6e865ea70d7724f("#ffffff");
29
- function $6e14a98a7f67141d$export$6df7f0e2cabc7eef(props) {
30
- let { value, defaultValue, colorSpace, xChannel, yChannel, onChange, onChangeEnd } = props;
31
- if (!value && !defaultValue) defaultValue = $6e14a98a7f67141d$var$DEFAULT_COLOR;
32
- if (value) value = $799cddbef784668f$export$4cde5df63f53f473(value);
33
- if (defaultValue) defaultValue = $799cddbef784668f$export$4cde5df63f53f473(defaultValue);
34
- let [colorValue, setColorState] = $458b0a5536c1a7cf$export$40bfa8c7b0832715(value, defaultValue, onChange);
35
- let color = useMemo(() => colorSpace && colorValue ? colorValue.toFormat(colorSpace) : colorValue, [
36
- colorValue,
37
- colorSpace
38
- ]);
39
- let valueRef = useRef(color);
40
- let setColor = (color2) => {
41
- valueRef.current = color2;
42
- setColorState(color2);
43
- };
44
- let channels = useMemo(() => color.getColorSpaceAxes({
45
- xChannel,
46
- yChannel
47
- }), [
48
- color,
49
- xChannel,
50
- yChannel
51
- ]);
52
- let xChannelRange = color.getChannelRange(channels.xChannel);
53
- let yChannelRange = color.getChannelRange(channels.yChannel);
54
- let { minValue: minValueX, maxValue: maxValueX, step: stepX, pageSize: pageSizeX } = xChannelRange;
55
- let { minValue: minValueY, maxValue: maxValueY, step: stepY, pageSize: pageSizeY } = yChannelRange;
56
- let [isDragging, setDragging] = useState(false);
57
- let isDraggingRef = useRef(false);
58
- let xValue = color.getChannelValue(channels.xChannel);
59
- let yValue = color.getChannelValue(channels.yChannel);
60
- let setXValue = (v) => {
61
- if (v === xValue) return;
62
- let newColor = color.withChannelValue(channels.xChannel, v);
63
- setColor(newColor);
64
- };
65
- let setYValue = (v) => {
66
- if (v === yValue) return;
67
- let newColor = color.withChannelValue(channels.yChannel, v);
68
- setColor(newColor);
69
- };
70
- return {
71
- channels,
72
- xChannelStep: stepX,
73
- yChannelStep: stepY,
74
- xChannelPageStep: pageSizeX,
75
- yChannelPageStep: pageSizeY,
76
- value: color,
77
- setValue(value2) {
78
- setColor($799cddbef784668f$export$4cde5df63f53f473(value2));
79
- },
80
- xValue,
81
- setXValue,
82
- yValue,
83
- setYValue,
84
- setColorFromPoint(x, y) {
85
- let newXValue = minValueX + $9446cca9a3875146$export$7d15b64cf5a3a4c4(x, 0, 1) * (maxValueX - minValueX);
86
- let newYValue = minValueY + (1 - $9446cca9a3875146$export$7d15b64cf5a3a4c4(y, 0, 1)) * (maxValueY - minValueY);
87
- let newColor;
88
- if (newXValue !== xValue) {
89
- newXValue = $9446cca9a3875146$export$cb6e0bb50bc19463(newXValue, minValueX, maxValueX, stepX);
90
- newColor = color.withChannelValue(channels.xChannel, newXValue);
91
- }
92
- if (newYValue !== yValue) {
93
- newYValue = $9446cca9a3875146$export$cb6e0bb50bc19463(newYValue, minValueY, maxValueY, stepY);
94
- newColor = (newColor || color).withChannelValue(channels.yChannel, newYValue);
95
- }
96
- if (newColor) setColor(newColor);
97
- },
98
- getThumbPosition() {
99
- let x = (xValue - minValueX) / (maxValueX - minValueX);
100
- let y = 1 - (yValue - minValueY) / (maxValueY - minValueY);
101
- return {
102
- x,
103
- y
104
- };
105
- },
106
- incrementX(stepSize = 1) {
107
- setXValue(xValue + stepSize > maxValueX ? maxValueX : $9446cca9a3875146$export$cb6e0bb50bc19463(xValue + stepSize, minValueX, maxValueX, stepX));
108
- },
109
- incrementY(stepSize = 1) {
110
- setYValue(yValue + stepSize > maxValueY ? maxValueY : $9446cca9a3875146$export$cb6e0bb50bc19463(yValue + stepSize, minValueY, maxValueY, stepY));
111
- },
112
- decrementX(stepSize = 1) {
113
- setXValue($9446cca9a3875146$export$cb6e0bb50bc19463(xValue - stepSize, minValueX, maxValueX, stepX));
114
- },
115
- decrementY(stepSize = 1) {
116
- setYValue($9446cca9a3875146$export$cb6e0bb50bc19463(yValue - stepSize, minValueY, maxValueY, stepY));
117
- },
118
- setDragging(isDragging2) {
119
- let wasDragging = isDraggingRef.current;
120
- isDraggingRef.current = isDragging2;
121
- if (onChangeEnd && !isDragging2 && wasDragging) onChangeEnd(valueRef.current);
122
- setDragging(isDragging2);
123
- },
124
- isDragging,
125
- getDisplayColor() {
126
- return color.withChannelValue("alpha", 1);
127
- }
128
- };
129
- }
130
- function $25a25ac0d1624665$export$57bc203e1c9c6d44(props) {
131
- let { channel, colorSpace, value, defaultValue, onChange, locale, ...otherProps } = props;
132
- if (value == null && defaultValue == null) throw new Error("useColorSliderState requires a value or defaultValue");
133
- if (value) value = $799cddbef784668f$export$4cde5df63f53f473(value);
134
- if (defaultValue) defaultValue = $799cddbef784668f$export$4cde5df63f53f473(defaultValue);
135
- let [colorValue, setColor] = $458b0a5536c1a7cf$export$40bfa8c7b0832715(value, defaultValue, onChange);
136
- let color = useMemo(() => colorSpace && colorValue ? colorValue.toFormat(colorSpace) : colorValue, [
137
- colorValue,
138
- colorSpace
139
- ]);
140
- let sliderState = $28f99e3e86e6ec45$export$e5fda3247f5d67f9({
141
- ...color.getChannelRange(channel),
142
- ...otherProps,
143
- // Unused except in getThumbValueLabel, which is overridden below. null to localize the TypeScript error for ignoring.
144
- // @ts-ignore
145
- numberFormatter: null,
146
- value: color.getChannelValue(channel),
147
- onChange(v) {
148
- setColor(color.withChannelValue(channel, v));
149
- },
150
- onChangeEnd(v) {
151
- if (props.onChangeEnd) props.onChangeEnd(color.withChannelValue(channel, v));
152
- }
153
- });
154
- let { step, pageSize } = color.getChannelRange(channel);
155
- return {
156
- ...sliderState,
157
- value: color,
158
- setValue(value2) {
159
- setColor($799cddbef784668f$export$4cde5df63f53f473(value2));
160
- },
161
- getDisplayColor() {
162
- switch (channel) {
163
- case "hue":
164
- return $799cddbef784668f$export$6e865ea70d7724f(`hsl(${color.getChannelValue("hue")}, 100%, 50%)`);
165
- case "lightness":
166
- case "brightness":
167
- case "saturation":
168
- case "red":
169
- case "green":
170
- case "blue":
171
- return color.withChannelValue("alpha", 1);
172
- case "alpha":
173
- return color;
174
- default:
175
- throw new Error("Unknown color channel: " + channel);
176
- }
177
- },
178
- getThumbValueLabel() {
179
- return color.formatChannelValue(channel, locale);
180
- },
181
- step,
182
- pageSize,
183
- isDragging: sliderState.isThumbDragging(0)
184
- };
185
- }
186
- function $aa90ad8b2b1d015f$export$5aadd9c0606af5c2(value) {
187
- return useMemo(() => {
188
- if (typeof value === "string") try {
189
- return (0, $799cddbef784668f$export$6e865ea70d7724f)(value);
190
- } catch {
191
- return void 0;
192
- }
193
- return value;
194
- }, [
195
- value
196
- ]);
197
- }
198
- const $b335ada08155d9c0$var$MIN_COLOR = $799cddbef784668f$export$6e865ea70d7724f("#000000");
199
- const $b335ada08155d9c0$var$MAX_COLOR = $799cddbef784668f$export$6e865ea70d7724f("#FFFFFF");
200
- const $b335ada08155d9c0$var$MIN_COLOR_INT = $b335ada08155d9c0$var$MIN_COLOR.toHexInt();
201
- const $b335ada08155d9c0$var$MAX_COLOR_INT = $b335ada08155d9c0$var$MAX_COLOR.toHexInt();
202
- function $b335ada08155d9c0$export$d52a01683abdfcd6(props) {
203
- let { value, defaultValue, onChange } = props;
204
- let { step } = $b335ada08155d9c0$var$MIN_COLOR.getChannelRange("red");
205
- let initialValue = $aa90ad8b2b1d015f$export$5aadd9c0606af5c2(value);
206
- let initialDefaultValue = $aa90ad8b2b1d015f$export$5aadd9c0606af5c2(defaultValue);
207
- let [colorValue, setColorValue] = $458b0a5536c1a7cf$export$40bfa8c7b0832715(initialValue, initialDefaultValue, onChange);
208
- let [inputValue, setInputValue] = useState(() => (value || defaultValue) && colorValue ? colorValue.toString("hex") : "");
209
- let validation = $e5be200c675c3b3a$export$fc1a364ae1f3ff10({
210
- ...props,
211
- value: colorValue
212
- });
213
- let safelySetColorValue = (newColor) => {
214
- if (!colorValue || !newColor) {
215
- setColorValue(newColor);
216
- return;
217
- }
218
- if (newColor.toHexInt() !== colorValue.toHexInt()) {
219
- setColorValue(newColor);
220
- return;
221
- }
222
- };
223
- let [prevValue, setPrevValue] = useState(colorValue);
224
- if (prevValue !== colorValue) {
225
- setInputValue(colorValue ? colorValue.toString("hex") : "");
226
- setPrevValue(colorValue);
227
- }
228
- let parsedValue = useMemo(() => {
229
- let color;
230
- try {
231
- color = (0, $799cddbef784668f$export$6e865ea70d7724f)(inputValue.startsWith("#") ? inputValue : `#${inputValue}`);
232
- } catch {
233
- color = null;
234
- }
235
- return color;
236
- }, [
237
- inputValue
238
- ]);
239
- let commit = () => {
240
- if (!inputValue.length) {
241
- safelySetColorValue(null);
242
- if (value === void 0 || colorValue === null) setInputValue("");
243
- else setInputValue(colorValue.toString("hex"));
244
- return;
245
- }
246
- if (parsedValue == null) {
247
- setInputValue(colorValue ? colorValue.toString("hex") : "");
248
- return;
249
- }
250
- safelySetColorValue(parsedValue);
251
- let newColorValue = "";
252
- if (colorValue) newColorValue = colorValue.toString("hex");
253
- setInputValue(newColorValue);
254
- };
255
- let increment = () => {
256
- let newValue = $b335ada08155d9c0$var$addColorValue(parsedValue, step);
257
- if (newValue === colorValue) setInputValue(newValue.toString("hex"));
258
- safelySetColorValue(newValue);
259
- validation.commitValidation();
260
- };
261
- let decrement = () => {
262
- let newValue = $b335ada08155d9c0$var$addColorValue(parsedValue, -step);
263
- if (newValue === colorValue) setInputValue(newValue.toString("hex"));
264
- safelySetColorValue(newValue);
265
- validation.commitValidation();
266
- };
267
- let incrementToMax = () => safelySetColorValue($b335ada08155d9c0$var$MAX_COLOR);
268
- let decrementToMin = () => safelySetColorValue($b335ada08155d9c0$var$MIN_COLOR);
269
- let validate = (value2) => {
270
- var _value_match;
271
- return value2 === "" || !!((_value_match = value2.match(/^#?[0-9a-f]{0,6}$/i)) === null || _value_match === void 0 ? void 0 : _value_match[0]);
272
- };
273
- return {
274
- ...validation,
275
- validate,
276
- colorValue,
277
- inputValue,
278
- setInputValue,
279
- commit,
280
- increment,
281
- incrementToMax,
282
- decrement,
283
- decrementToMin
284
- };
285
- }
286
- function $b335ada08155d9c0$var$addColorValue(color, step) {
287
- let newColor = color ? color : $b335ada08155d9c0$var$MIN_COLOR;
288
- let colorInt = newColor.toHexInt();
289
- let clampInt = Math.min(Math.max(colorInt + step, $b335ada08155d9c0$var$MIN_COLOR_INT), $b335ada08155d9c0$var$MAX_COLOR_INT);
290
- if (clampInt !== colorInt) {
291
- let newColorString = `#${clampInt.toString(16).padStart(6, "0").toUpperCase()}`;
292
- newColor = $799cddbef784668f$export$6e865ea70d7724f(newColorString);
293
- }
294
- return newColor;
295
- }
296
- function $31a863bb88e75dd6$export$b9fc0d69c9190c4a(props) {
297
- let { channel, colorSpace, locale } = props;
298
- let black = $aa90ad8b2b1d015f$export$5aadd9c0606af5c2("#000");
299
- let initialValue = $aa90ad8b2b1d015f$export$5aadd9c0606af5c2(props.value);
300
- let initialDefaultValue = $aa90ad8b2b1d015f$export$5aadd9c0606af5c2(props.defaultValue);
301
- let [colorValue, setColor] = $458b0a5536c1a7cf$export$40bfa8c7b0832715(initialValue, initialDefaultValue !== null && initialDefaultValue !== void 0 ? initialDefaultValue : null, props.onChange);
302
- let color = useMemo(() => {
303
- let nonNullColorValue = colorValue || black;
304
- return colorSpace && nonNullColorValue ? nonNullColorValue.toFormat(colorSpace) : nonNullColorValue;
305
- }, [
306
- black,
307
- colorValue,
308
- colorSpace
309
- ]);
310
- let value = color.getChannelValue(channel);
311
- let range = color.getChannelRange(channel);
312
- let formatOptions = useMemo(() => color.getChannelFormatOptions(channel), [
313
- color,
314
- channel
315
- ]);
316
- let multiplier = formatOptions.style === "percent" && range.maxValue === 100 ? 100 : 1;
317
- let numberFieldState = $de67e98908f0c6ee$export$7f629e9dc1ecf37c({
318
- locale,
319
- value: colorValue === null ? NaN : value / multiplier,
320
- onChange: (v) => {
321
- if (!Number.isNaN(v)) setColor(color.withChannelValue(channel, v * multiplier));
322
- else setColor(null);
323
- },
324
- minValue: range.minValue / multiplier,
325
- maxValue: range.maxValue / multiplier,
326
- step: range.step / multiplier,
327
- formatOptions
328
- });
329
- return {
330
- ...numberFieldState,
331
- colorValue: color
332
- };
333
- }
334
- const $40297c24c53588e6$var$hue = (color) => [
335
- 0,
336
- 60,
337
- 120,
338
- 180,
339
- 240,
340
- 300,
341
- 360
342
- ].map((hue) => color.withChannelValue("hue", hue).toString("css")).join(", ");
343
- const $40297c24c53588e6$var$saturation = (color) => `${color.withChannelValue("saturation", 0)}, transparent`;
344
- const $40297c24c53588e6$var$hslChannels = {
345
- hue: $40297c24c53588e6$var$hue,
346
- saturation: $40297c24c53588e6$var$saturation,
347
- lightness: () => "black, transparent, white"
348
- };
349
- const $40297c24c53588e6$var$hsbChannels = {
350
- hue: $40297c24c53588e6$var$hue,
351
- saturation: $40297c24c53588e6$var$saturation,
352
- brightness: () => "black, transparent"
353
- };
354
- function $40297c24c53588e6$export$dd62420467d245ca({ direction, state, zChannel, xChannel, yChannel }) {
355
- let returnVal = useMemo(() => {
356
- let end = direction === "rtl" ? "left" : "right";
357
- let colorAreaStyles = {};
358
- let zValue = state.value.getChannelValue(zChannel);
359
- switch (state.value.getColorSpace()) {
360
- case "rgb": {
361
- let rgb = $799cddbef784668f$export$6e865ea70d7724f("rgb(0, 0, 0)");
362
- colorAreaStyles = {
363
- background: [
364
- // The screen blend mode multiplies the inverse of each channel, e.g. 1 - (1 - a) * (1 - b).
365
- // Create a layer for each channel, with the other channels as 0. After blending, this should
366
- // result in the gradients being combined channel by channel.
367
- `linear-gradient(to ${end}, ${rgb.withChannelValue(xChannel, 0)}, ${rgb.withChannelValue(xChannel, 255)})`,
368
- `linear-gradient(to top, ${rgb.withChannelValue(yChannel, 0)}, ${rgb.withChannelValue(yChannel, 255)})`,
369
- rgb.withChannelValue(zChannel, zValue)
370
- ].join(","),
371
- backgroundBlendMode: "screen"
372
- };
373
- break;
374
- }
375
- case "hsl": {
376
- let channels = state.value.getColorChannels();
377
- let value = $799cddbef784668f$export$6e865ea70d7724f("hsl(0, 100%, 50%)").withChannelValue(zChannel, zValue);
378
- let bg = channels.filter((c) => c !== zChannel).map((c) => `linear-gradient(to ${c === xChannel ? end : "top"}, ${$40297c24c53588e6$var$hslChannels[c](value)})`).reverse();
379
- if (zChannel === "hue") bg.push(value.toString("css"));
380
- colorAreaStyles = {
381
- background: bg.join(", ")
382
- };
383
- break;
384
- }
385
- case "hsb": {
386
- let channels = state.value.getColorChannels();
387
- let value = $799cddbef784668f$export$6e865ea70d7724f("hsb(0, 100%, 100%)").withChannelValue(zChannel, zValue);
388
- let bg = channels.filter((c) => c !== zChannel).map((c) => `linear-gradient(to ${c === xChannel ? end : "top"}, ${$40297c24c53588e6$var$hsbChannels[c](value)})`).reverse();
389
- if (zChannel === "hue") bg.push(value.toString("css"));
390
- colorAreaStyles = {
391
- background: bg.join(", ")
392
- };
393
- break;
394
- }
395
- }
396
- let { x, y } = state.getThumbPosition();
397
- if (direction === "rtl") x = 1 - x;
398
- let forcedColorAdjustNoneStyle = {
399
- forcedColorAdjust: "none"
400
- };
401
- return {
402
- colorAreaStyleProps: {
403
- style: {
404
- position: "relative",
405
- touchAction: "none",
406
- ...forcedColorAdjustNoneStyle,
407
- ...colorAreaStyles
408
- }
409
- },
410
- thumbStyleProps: {
411
- style: {
412
- position: "absolute",
413
- left: `${x * 100}%`,
414
- top: `${y * 100}%`,
415
- transform: "translate(-50%, -50%)",
416
- touchAction: "none",
417
- ...forcedColorAdjustNoneStyle
418
- }
419
- }
420
- };
421
- }, [
422
- direction,
423
- state,
424
- zChannel,
425
- xChannel,
426
- yChannel
427
- ]);
428
- return returnVal;
429
- }
430
- function $parcel$interopDefault(a) {
431
- return a && a.__esModule ? a.default : a;
432
- }
433
- function $60bd7d6e45dcddfa$export$2f92a7a615a014f6(props, state) {
434
- let { isDisabled, inputXRef, inputYRef, containerRef, "aria-label": ariaLabel, xName, yName } = props;
435
- let stringFormatter = $fca6afa0e843324b$export$f12b703ca79dfbb1($parcel$interopDefault($3493a52097159720$exports), "@react-aria/color");
436
- let { addGlobalListener, removeGlobalListener } = $03deb23ff14920c4$export$4eaf04e54aa8eed6();
437
- let { direction, locale } = $18f2051aff69b9bf$export$43bb16f9c6d9e3f7();
438
- let [focusedInput, setFocusedInput] = useState(null);
439
- let focusInput = useCallback((inputRef = inputXRef) => {
440
- if (inputRef.current) $7215afc6de606d6b$export$de79e2c695e052f3(inputRef.current);
441
- }, [
442
- inputXRef
443
- ]);
444
- $99facab73266f662$export$5add1d006293d136(inputXRef, [
445
- state.xValue,
446
- state.yValue
447
- ], ([x, y]) => {
448
- let newColor = state.value.withChannelValue(state.channels.xChannel, x).withChannelValue(state.channels.yChannel, y);
449
- state.setValue(newColor);
450
- });
451
- let [valueChangedViaKeyboard, setValueChangedViaKeyboard] = useState(false);
452
- let [valueChangedViaInputChangeEvent, setValueChangedViaInputChangeEvent] = useState(false);
453
- let { xChannel, yChannel, zChannel } = state.channels;
454
- let xChannelStep = state.xChannelStep;
455
- let yChannelStep = state.yChannelStep;
456
- let currentPosition = useRef(null);
457
- let { keyboardProps } = $46d819fcbaf35654$export$8f71654801c2f7cd({
458
- onKeyDown(e) {
459
- if (!/^(PageUp|PageDown|Home|End)$/.test(e.key)) {
460
- e.continuePropagation();
461
- return;
462
- }
463
- e.preventDefault();
464
- state.setDragging(true);
465
- setValueChangedViaKeyboard(true);
466
- let dir;
467
- switch (e.key) {
468
- case "PageUp":
469
- state.incrementY(state.yChannelPageStep);
470
- dir = "y";
471
- break;
472
- case "PageDown":
473
- state.decrementY(state.yChannelPageStep);
474
- dir = "y";
475
- break;
476
- case "Home":
477
- direction === "rtl" ? state.incrementX(state.xChannelPageStep) : state.decrementX(state.xChannelPageStep);
478
- dir = "x";
479
- break;
480
- case "End":
481
- direction === "rtl" ? state.decrementX(state.xChannelPageStep) : state.incrementX(state.xChannelPageStep);
482
- dir = "x";
483
- break;
484
- }
485
- state.setDragging(false);
486
- if (dir) {
487
- let input = dir === "x" ? inputXRef : inputYRef;
488
- focusInput(input);
489
- setFocusedInput(dir);
490
- }
491
- }
492
- });
493
- let moveHandler = {
494
- onMoveStart() {
495
- currentPosition.current = null;
496
- state.setDragging(true);
497
- },
498
- onMove({ deltaX, deltaY, pointerType, shiftKey }) {
499
- var _containerRef_current;
500
- let { incrementX, decrementX, incrementY, decrementY, xChannelPageStep, xChannelStep: xChannelStep2, yChannelPageStep, yChannelStep: yChannelStep2, getThumbPosition, setColorFromPoint } = state;
501
- if (currentPosition.current == null) currentPosition.current = getThumbPosition();
502
- let { width, height } = ((_containerRef_current = containerRef.current) === null || _containerRef_current === void 0 ? void 0 : _containerRef_current.getBoundingClientRect()) || {
503
- width: 0,
504
- height: 0
505
- };
506
- let valueChanged = deltaX !== 0 || deltaY !== 0;
507
- if (pointerType === "keyboard") {
508
- let deltaXValue = shiftKey && xChannelPageStep > xChannelStep2 ? xChannelPageStep : xChannelStep2;
509
- let deltaYValue = shiftKey && yChannelPageStep > yChannelStep2 ? yChannelPageStep : yChannelStep2;
510
- if (deltaX > 0 && direction === "ltr" || deltaX < 0 && direction === "rtl") incrementX(deltaXValue);
511
- else if (deltaX < 0 && direction === "ltr" || deltaX > 0 && direction === "rtl") decrementX(deltaXValue);
512
- else if (deltaY > 0) decrementY(deltaYValue);
513
- else if (deltaY < 0) incrementY(deltaYValue);
514
- setValueChangedViaKeyboard(valueChanged);
515
- focusedInput = valueChanged && Math.abs(deltaY) > Math.abs(deltaX) ? "y" : "x";
516
- setFocusedInput(focusedInput);
517
- } else {
518
- currentPosition.current.x += (direction === "rtl" ? -1 : 1) * deltaX / width;
519
- currentPosition.current.y += deltaY / height;
520
- setColorFromPoint(currentPosition.current.x, currentPosition.current.y);
521
- }
522
- },
523
- onMoveEnd() {
524
- isOnColorArea.current = false;
525
- state.setDragging(false);
526
- let input = focusedInput === "x" ? inputXRef : inputYRef;
527
- focusInput(input);
528
- }
529
- };
530
- let { moveProps: movePropsThumb } = $e8a7022cf87cba2a$export$36da96379f79f245(moveHandler);
531
- let { focusWithinProps } = $9ab94262bd0047c7$export$420e68273165f4ec({
532
- onFocusWithinChange: (focusWithin) => {
533
- if (!focusWithin) {
534
- setValueChangedViaKeyboard(false);
535
- setValueChangedViaInputChangeEvent(false);
536
- }
537
- }
538
- });
539
- let currentPointer = useRef(void 0);
540
- let isOnColorArea = useRef(false);
541
- let { moveProps: movePropsContainer } = $e8a7022cf87cba2a$export$36da96379f79f245({
542
- onMoveStart() {
543
- if (isOnColorArea.current) moveHandler.onMoveStart();
544
- },
545
- onMove(e) {
546
- if (isOnColorArea.current) moveHandler.onMove(e);
547
- },
548
- onMoveEnd() {
549
- if (isOnColorArea.current) moveHandler.onMoveEnd();
550
- }
551
- });
552
- let onThumbDown = (id) => {
553
- if (!state.isDragging) {
554
- currentPointer.current = id;
555
- setValueChangedViaKeyboard(false);
556
- focusInput();
557
- state.setDragging(true);
558
- if (typeof PointerEvent !== "undefined") addGlobalListener(window, "pointerup", onThumbUp, false);
559
- else {
560
- addGlobalListener(window, "mouseup", onThumbUp, false);
561
- addGlobalListener(window, "touchend", onThumbUp, false);
562
- }
563
- }
564
- };
565
- let onThumbUp = (e) => {
566
- var _e_changedTouches;
567
- var _e_pointerId;
568
- let id = (_e_pointerId = e.pointerId) !== null && _e_pointerId !== void 0 ? _e_pointerId : (_e_changedTouches = e.changedTouches) === null || _e_changedTouches === void 0 ? void 0 : _e_changedTouches[0].identifier;
569
- if (id === currentPointer.current) {
570
- setValueChangedViaKeyboard(false);
571
- focusInput();
572
- state.setDragging(false);
573
- currentPointer.current = void 0;
574
- isOnColorArea.current = false;
575
- if (typeof PointerEvent !== "undefined") removeGlobalListener(window, "pointerup", onThumbUp, false);
576
- else {
577
- removeGlobalListener(window, "mouseup", onThumbUp, false);
578
- removeGlobalListener(window, "touchend", onThumbUp, false);
579
- }
580
- }
581
- };
582
- let onColorAreaDown = (colorArea, id, clientX, clientY) => {
583
- let rect = colorArea.getBoundingClientRect();
584
- let { width, height } = rect;
585
- let x = (clientX - rect.x) / width;
586
- let y = (clientY - rect.y) / height;
587
- if (direction === "rtl") x = 1 - x;
588
- if (x >= 0 && x <= 1 && y >= 0 && y <= 1 && !state.isDragging && currentPointer.current === void 0) {
589
- isOnColorArea.current = true;
590
- setValueChangedViaKeyboard(false);
591
- currentPointer.current = id;
592
- state.setColorFromPoint(x, y);
593
- focusInput();
594
- state.setDragging(true);
595
- if (typeof PointerEvent !== "undefined") addGlobalListener(window, "pointerup", onColorAreaUp, false);
596
- else {
597
- addGlobalListener(window, "mouseup", onColorAreaUp, false);
598
- addGlobalListener(window, "touchend", onColorAreaUp, false);
599
- }
600
- }
601
- };
602
- let onColorAreaUp = (e) => {
603
- var _e_changedTouches;
604
- var _e_pointerId;
605
- let id = (_e_pointerId = e.pointerId) !== null && _e_pointerId !== void 0 ? _e_pointerId : (_e_changedTouches = e.changedTouches) === null || _e_changedTouches === void 0 ? void 0 : _e_changedTouches[0].identifier;
606
- if (isOnColorArea.current && id === currentPointer.current) {
607
- isOnColorArea.current = false;
608
- setValueChangedViaKeyboard(false);
609
- currentPointer.current = void 0;
610
- state.setDragging(false);
611
- focusInput();
612
- if (typeof PointerEvent !== "undefined") removeGlobalListener(window, "pointerup", onColorAreaUp, false);
613
- else {
614
- removeGlobalListener(window, "mouseup", onColorAreaUp, false);
615
- removeGlobalListener(window, "touchend", onColorAreaUp, false);
616
- }
617
- }
618
- };
619
- let colorAreaInteractions = isDisabled ? {} : $3ef42575df84b30b$export$9d1611c77c2fe928({
620
- ...typeof PointerEvent !== "undefined" ? {
621
- onPointerDown: (e) => {
622
- if (e.pointerType === "mouse" && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) return;
623
- onColorAreaDown(e.currentTarget, e.pointerId, e.clientX, e.clientY);
624
- }
625
- } : {
626
- onMouseDown: (e) => {
627
- if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
628
- onColorAreaDown(e.currentTarget, void 0, e.clientX, e.clientY);
629
- },
630
- onTouchStart: (e) => {
631
- onColorAreaDown(e.currentTarget, e.changedTouches[0].identifier, e.changedTouches[0].clientX, e.changedTouches[0].clientY);
632
- }
633
- }
634
- }, movePropsContainer);
635
- let thumbInteractions = isDisabled ? {} : $3ef42575df84b30b$export$9d1611c77c2fe928({
636
- ...typeof PointerEvent !== "undefined" ? {
637
- onPointerDown: (e) => {
638
- if (e.pointerType === "mouse" && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) return;
639
- onThumbDown(e.pointerId);
640
- }
641
- } : {
642
- onMouseDown: (e) => {
643
- if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
644
- onThumbDown(void 0);
645
- },
646
- onTouchStart: (e) => {
647
- onThumbDown(e.changedTouches[0].identifier);
648
- }
649
- }
650
- }, focusWithinProps, keyboardProps, movePropsThumb);
651
- let { focusProps: xInputFocusProps } = $a1ea59d68270f0dd$export$f8168d8dd8fd66e6({
652
- onFocus: () => {
653
- setFocusedInput("x");
654
- }
655
- });
656
- let { focusProps: yInputFocusProps } = $a1ea59d68270f0dd$export$f8168d8dd8fd66e6({
657
- onFocus: () => {
658
- setFocusedInput("y");
659
- }
660
- });
661
- const onChange = (e) => {
662
- const { target } = e;
663
- setValueChangedViaInputChangeEvent(true);
664
- if (target === inputXRef.current) state.setXValue(parseFloat(target.value));
665
- else if (target === inputYRef.current) state.setYValue(parseFloat(target.value));
666
- };
667
- let isMobile = $c87311424ea30a05$export$fedb369cb70207f1() || $c87311424ea30a05$export$a11b0059900ceec8();
668
- let value = state.getDisplayColor();
669
- const getAriaValueTextForChannel = useCallback((channel) => {
670
- const isAfterInput = valueChangedViaInputChangeEvent || valueChangedViaKeyboard;
671
- return `${isAfterInput ? stringFormatter.format("colorNameAndValue", {
672
- name: value.getChannelName(channel, locale),
673
- value: value.formatChannelValue(channel, locale)
674
- }) : [
675
- stringFormatter.format("colorNameAndValue", {
676
- name: value.getChannelName(channel, locale),
677
- value: value.formatChannelValue(channel, locale)
678
- }),
679
- stringFormatter.format("colorNameAndValue", {
680
- name: value.getChannelName(channel === yChannel ? xChannel : yChannel, locale),
681
- value: value.formatChannelValue(channel === yChannel ? xChannel : yChannel, locale)
682
- }),
683
- stringFormatter.format("colorNameAndValue", {
684
- name: value.getChannelName(zChannel, locale),
685
- value: value.formatChannelValue(zChannel, locale)
686
- })
687
- ].join(", ")}, ${value.getColorName(locale)}`;
688
- }, [
689
- locale,
690
- value,
691
- stringFormatter,
692
- valueChangedViaInputChangeEvent,
693
- valueChangedViaKeyboard,
694
- xChannel,
695
- yChannel,
696
- zChannel
697
- ]);
698
- let colorPickerLabel = stringFormatter.format("colorPicker");
699
- let xInputLabellingProps = $313b98861ee5dd6c$export$d6875122194c7b44({
700
- ...props,
701
- "aria-label": ariaLabel ? stringFormatter.format("colorInputLabel", {
702
- label: ariaLabel,
703
- channelLabel: colorPickerLabel
704
- }) : colorPickerLabel
705
- });
706
- let yInputLabellingProps = $313b98861ee5dd6c$export$d6875122194c7b44({
707
- ...props,
708
- "aria-label": ariaLabel ? stringFormatter.format("colorInputLabel", {
709
- label: ariaLabel,
710
- channelLabel: colorPickerLabel
711
- }) : colorPickerLabel
712
- });
713
- let colorAreaLabellingProps = $313b98861ee5dd6c$export$d6875122194c7b44({
714
- ...props,
715
- "aria-label": ariaLabel ? `${ariaLabel}, ${colorPickerLabel}` : void 0
716
- }, isMobile ? colorPickerLabel : void 0);
717
- let ariaRoleDescription = stringFormatter.format("twoDimensionalSlider");
718
- let { visuallyHiddenProps } = $5c3e21d68f1c4674$export$a966af930f325cab({
719
- style: {
720
- opacity: "0.0001",
721
- width: "100%",
722
- height: "100%",
723
- pointerEvents: "none"
724
- }
725
- });
726
- let { colorAreaStyleProps, thumbStyleProps } = $40297c24c53588e6$export$dd62420467d245ca({
727
- direction,
728
- state,
729
- xChannel,
730
- yChannel,
731
- zChannel
732
- });
733
- return {
734
- colorAreaProps: {
735
- ...colorAreaLabellingProps,
736
- ...colorAreaInteractions,
737
- ...colorAreaStyleProps,
738
- role: "group"
739
- },
740
- thumbProps: {
741
- ...thumbInteractions,
742
- ...thumbStyleProps,
743
- role: "presentation"
744
- },
745
- xInputProps: {
746
- ...xInputLabellingProps,
747
- ...visuallyHiddenProps,
748
- ...xInputFocusProps,
749
- type: "range",
750
- min: state.value.getChannelRange(xChannel).minValue,
751
- max: state.value.getChannelRange(xChannel).maxValue,
752
- step: xChannelStep,
753
- "aria-roledescription": ariaRoleDescription,
754
- "aria-valuetext": getAriaValueTextForChannel(xChannel),
755
- "aria-orientation": "horizontal",
756
- "aria-describedby": props["aria-describedby"],
757
- "aria-details": props["aria-details"],
758
- disabled: isDisabled,
759
- value: state.value.getChannelValue(xChannel),
760
- name: xName,
761
- tabIndex: isMobile || !focusedInput || focusedInput === "x" ? void 0 : -1,
762
- /*
763
- So that only a single "2d slider" control shows up when listing form elements for screen readers,
764
- add aria-hidden="true" to the unfocused control when the value has not changed via the keyboard,
765
- but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.
766
- */
767
- "aria-hidden": isMobile || !focusedInput || focusedInput === "x" || valueChangedViaKeyboard ? void 0 : "true",
768
- onChange
769
- },
770
- yInputProps: {
771
- ...yInputLabellingProps,
772
- ...visuallyHiddenProps,
773
- ...yInputFocusProps,
774
- type: "range",
775
- min: state.value.getChannelRange(yChannel).minValue,
776
- max: state.value.getChannelRange(yChannel).maxValue,
777
- step: yChannelStep,
778
- "aria-roledescription": ariaRoleDescription,
779
- "aria-valuetext": getAriaValueTextForChannel(yChannel),
780
- "aria-orientation": "vertical",
781
- "aria-describedby": props["aria-describedby"],
782
- "aria-details": props["aria-details"],
783
- disabled: isDisabled,
784
- value: state.value.getChannelValue(yChannel),
785
- name: yName,
786
- tabIndex: isMobile || focusedInput === "y" ? void 0 : -1,
787
- /*
788
- So that only a single "2d slider" control shows up when listing form elements for screen readers,
789
- add aria-hidden="true" to the unfocused input when the value has not changed via the keyboard,
790
- but remove aria-hidden to reveal the input for each channel when the value has changed with the keyboard.
791
- */
792
- "aria-hidden": isMobile || focusedInput === "y" || valueChangedViaKeyboard ? void 0 : "true",
793
- onChange
794
- }
795
- };
796
- }
797
- function $40af666d6c251e36$export$106b7a4e66508f66(props, state) {
798
- let { trackRef, inputRef, orientation, channel, "aria-label": ariaLabel, name } = props;
799
- let { locale, direction } = $18f2051aff69b9bf$export$43bb16f9c6d9e3f7();
800
- if (!props.label && !ariaLabel && !props["aria-labelledby"]) ariaLabel = state.value.getChannelName(channel, locale);
801
- let { groupProps, trackProps, labelProps, outputProps } = $bcca50147b47f54d$export$56b2c08e277f365({
802
- ...props,
803
- "aria-label": ariaLabel
804
- }, state, trackRef);
805
- let { inputProps, thumbProps } = $47b897dc8cdb026b$export$8d15029008292ae({
806
- index: 0,
807
- orientation,
808
- isDisabled: props.isDisabled,
809
- name,
810
- trackRef,
811
- inputRef
812
- }, state);
813
- let value = state.getDisplayColor();
814
- let generateBackground = () => {
815
- let to;
816
- if (orientation === "vertical") to = "top";
817
- else if (direction === "ltr") to = "right";
818
- else to = "left";
819
- switch (channel) {
820
- case "hue": {
821
- let stops = [
822
- 0,
823
- 60,
824
- 120,
825
- 180,
826
- 240,
827
- 300,
828
- 360
829
- ].map((hue) => value.withChannelValue("hue", hue).toString("css")).join(", ");
830
- return `linear-gradient(to ${to}, ${stops})`;
831
- }
832
- case "lightness": {
833
- let min = state.getThumbMinValue(0);
834
- let max = state.getThumbMaxValue(0);
835
- let start = value.withChannelValue(channel, min).toString("css");
836
- let middle = value.withChannelValue(channel, (max - min) / 2).toString("css");
837
- let end = value.withChannelValue(channel, max).toString("css");
838
- return `linear-gradient(to ${to}, ${start}, ${middle}, ${end})`;
839
- }
840
- case "saturation":
841
- case "brightness":
842
- case "red":
843
- case "green":
844
- case "blue":
845
- case "alpha": {
846
- let start = value.withChannelValue(channel, state.getThumbMinValue(0)).toString("css");
847
- let end = value.withChannelValue(channel, state.getThumbMaxValue(0)).toString("css");
848
- return `linear-gradient(to ${to}, ${start}, ${end})`;
849
- }
850
- default:
851
- throw new Error("Unknown color channel: " + channel);
852
- }
853
- };
854
- let forcedColorAdjustNoneStyle = {
855
- forcedColorAdjust: "none"
856
- };
857
- if (channel === "hue") inputProps["aria-valuetext"] += `, ${value.getHueName(locale)}`;
858
- else if (channel !== "alpha") inputProps["aria-valuetext"] += `, ${value.getColorName(locale)}`;
859
- let { visuallyHiddenProps } = $5c3e21d68f1c4674$export$a966af930f325cab({
860
- style: {
861
- opacity: "0.0001",
862
- width: "100%",
863
- height: "100%",
864
- pointerEvents: "none"
865
- }
866
- });
867
- return {
868
- trackProps: {
869
- ...$3ef42575df84b30b$export$9d1611c77c2fe928(groupProps, trackProps),
870
- style: {
871
- ...trackProps.style,
872
- ...forcedColorAdjustNoneStyle,
873
- background: generateBackground()
874
- }
875
- },
876
- inputProps: {
877
- ...inputProps,
878
- style: {
879
- ...inputProps.style,
880
- ...visuallyHiddenProps.style
881
- }
882
- },
883
- thumbProps: {
884
- ...thumbProps,
885
- style: {
886
- ...thumbProps.style,
887
- ...forcedColorAdjustNoneStyle
888
- }
889
- },
890
- labelProps,
891
- outputProps
892
- };
893
- }
894
- function $f6896b05b2ecad12$export$77e32ca575a28fdf(props, state, ref) {
895
- let { isDisabled, isReadOnly, isRequired, isWheelDisabled, validationBehavior = "aria" } = props;
896
- let { colorValue, inputValue, increment, decrement, incrementToMax, decrementToMin, commit } = state;
897
- let inputId = $bdb11010cef70236$export$f680877a34711e37();
898
- let { spinButtonProps } = $d2e8511e6f209edf$export$e908e06f4b8e3402({
899
- isDisabled,
900
- isReadOnly,
901
- isRequired,
902
- maxValue: 16777215,
903
- minValue: 0,
904
- onIncrement: increment,
905
- onIncrementToMax: incrementToMax,
906
- onDecrement: decrement,
907
- onDecrementToMin: decrementToMin,
908
- value: colorValue ? colorValue.toHexInt() : void 0,
909
- textValue: colorValue ? colorValue.toString("hex") : void 0
910
- });
911
- let [focusWithin, setFocusWithin] = useState(false);
912
- let { focusWithinProps } = $9ab94262bd0047c7$export$420e68273165f4ec({
913
- isDisabled,
914
- onFocusWithinChange: setFocusWithin
915
- });
916
- let onWheel = useCallback((e) => {
917
- if (Math.abs(e.deltaY) <= Math.abs(e.deltaX)) return;
918
- if (e.deltaY > 0) increment();
919
- else if (e.deltaY < 0) decrement();
920
- }, [
921
- decrement,
922
- increment
923
- ]);
924
- let scrollingDisabled = isWheelDisabled || isDisabled || isReadOnly || !focusWithin;
925
- $7d0a636d7a4dcefd$export$2123ff2b87c81ca({
926
- onScroll: onWheel,
927
- isDisabled: scrollingDisabled
928
- }, ref);
929
- let onChange = (value) => {
930
- if (state.validate(value)) state.setInputValue(value);
931
- };
932
- let { inputProps, ...otherProps } = $d841c8010a73d545$export$4f384c9210e583c3({
933
- ...props,
934
- id: inputId,
935
- value: inputValue,
936
- defaultValue: void 0,
937
- validate: void 0,
938
- [$e5be200c675c3b3a$export$a763b9476acd3eb]: state,
939
- type: "text",
940
- autoComplete: "off",
941
- onChange
942
- }, state, ref);
943
- inputProps = $3ef42575df84b30b$export$9d1611c77c2fe928(inputProps, spinButtonProps, focusWithinProps, {
944
- role: "textbox",
945
- "aria-valuemax": null,
946
- "aria-valuemin": null,
947
- "aria-valuenow": null,
948
- "aria-valuetext": null,
949
- autoCorrect: "off",
950
- spellCheck: "false",
951
- onBlur: commit
952
- });
953
- if (validationBehavior === "native") inputProps["aria-required"] = void 0;
954
- return {
955
- inputProps,
956
- ...otherProps
957
- };
958
- }
959
- function $5e632d1ff0188f00$export$e55dd820142d3131(props, state, inputRef) {
960
- let { locale } = $18f2051aff69b9bf$export$43bb16f9c6d9e3f7();
961
- return $81397a9303501bda$export$23f548e970bdf099({
962
- ...props,
963
- value: void 0,
964
- defaultValue: void 0,
965
- onChange: void 0,
966
- validate: void 0,
967
- // Provide a default aria-label if no other label is provided.
968
- "aria-label": props["aria-label"] || (props.label || props["aria-labelledby"] ? void 0 : state.colorValue.getChannelName(props.channel, locale))
969
- }, state, inputRef);
970
- }
971
- const $e2b71ec1d6016406$export$c80c0ea2ca5cb846 = /* @__PURE__ */ createContext(null);
972
- const $e2b71ec1d6016406$export$a3cc47cee1c1ccc = /* @__PURE__ */ forwardRef(function ColorThumb(props, ref) {
973
- let { state, thumbProps, inputXRef, inputYRef, xInputProps, yInputProps, isDisabled = false } = useContext($e2b71ec1d6016406$export$c80c0ea2ca5cb846);
974
- let { focusProps, isFocused, isFocusVisible } = $f7dceffc5ad7768b$export$4e328f61c538687f();
975
- let { hoverProps, isHovered } = $6179b936705e76d3$export$ae780daf29e6d456(props);
976
- let renderProps = $64fa3d84918910a7$export$4d86445c2cf5e3({
977
- ...props,
978
- defaultClassName: "react-aria-ColorThumb",
979
- defaultStyle: {
980
- ...thumbProps.style,
981
- backgroundColor: state.getDisplayColor().toString()
982
- },
983
- values: {
984
- color: state.getDisplayColor(),
985
- isHovered,
986
- isDragging: state.isDragging,
987
- isFocused,
988
- isFocusVisible,
989
- isDisabled
990
- }
991
- });
992
- let DOMProps = $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props);
993
- delete DOMProps.id;
994
- return /* @__PURE__ */ React__default.createElement("div", {
995
- ...$3ef42575df84b30b$export$9d1611c77c2fe928(thumbProps, hoverProps, DOMProps),
996
- ...renderProps,
997
- ref,
998
- "data-hovered": isHovered || void 0,
999
- "data-dragging": state.isDragging || void 0,
1000
- "data-focused": isFocused || void 0,
1001
- "data-focus-visible": isFocusVisible || void 0,
1002
- "data-disabled": isDisabled || void 0
1003
- }, /* @__PURE__ */ React__default.createElement("input", {
1004
- ref: inputXRef,
1005
- ...xInputProps,
1006
- ...focusProps
1007
- }), yInputProps && /* @__PURE__ */ React__default.createElement("input", {
1008
- ref: inputYRef,
1009
- ...yInputProps,
1010
- ...focusProps
1011
- }), renderProps.children);
1012
- });
1013
- const $0de070065d44825d$export$6b32221de49982e = /* @__PURE__ */ createContext(null);
1014
- const $0de070065d44825d$export$b2103f68a961418e = /* @__PURE__ */ forwardRef(function ColorArea(props, ref) {
1015
- [props, ref] = $64fa3d84918910a7$export$29f1550f4b0d4415(props, ref, $4e85f108e88277b8$export$ebe63fadcdce34ed);
1016
- let inputXRef = useRef(null);
1017
- let inputYRef = useRef(null);
1018
- let state = $6e14a98a7f67141d$export$6df7f0e2cabc7eef(props);
1019
- let { colorAreaProps, xInputProps, yInputProps, thumbProps } = $60bd7d6e45dcddfa$export$2f92a7a615a014f6({
1020
- ...props,
1021
- inputXRef,
1022
- inputYRef,
1023
- containerRef: ref
1024
- }, state);
1025
- let renderProps = $64fa3d84918910a7$export$4d86445c2cf5e3({
1026
- ...props,
1027
- defaultClassName: "react-aria-ColorArea",
1028
- defaultStyle: colorAreaProps.style,
1029
- values: {
1030
- state,
1031
- isDisabled: props.isDisabled || false
1032
- }
1033
- });
1034
- let DOMProps = $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props);
1035
- delete DOMProps.id;
1036
- return /* @__PURE__ */ React__default.createElement("div", {
1037
- ref,
1038
- ...colorAreaProps,
1039
- ...DOMProps,
1040
- ...renderProps,
1041
- slot: props.slot || void 0,
1042
- "data-disabled": props.isDisabled || void 0
1043
- }, /* @__PURE__ */ React__default.createElement($64fa3d84918910a7$export$2881499e37b75b9a, {
1044
- values: [
1045
- [
1046
- $0de070065d44825d$export$6b32221de49982e,
1047
- state
1048
- ],
1049
- [
1050
- $e2b71ec1d6016406$export$c80c0ea2ca5cb846,
1051
- {
1052
- state,
1053
- thumbProps,
1054
- inputXRef,
1055
- xInputProps,
1056
- inputYRef,
1057
- yInputProps,
1058
- isDisabled: props.isDisabled
1059
- }
1060
- ]
1061
- ]
1062
- }, renderProps.children));
1063
- });
1064
- const $3ada01a82feafb94$export$96b6d32b05a1a8ed = /* @__PURE__ */ createContext(null);
1065
- const $3ada01a82feafb94$export$b865d4358897bb17 = /* @__PURE__ */ forwardRef(function ColorField(props, ref) {
1066
- [props, ref] = $64fa3d84918910a7$export$29f1550f4b0d4415(props, ref, $4e85f108e88277b8$export$44644b8a16031b5b);
1067
- if (props.channel) return /* @__PURE__ */ React__default.createElement($3ada01a82feafb94$var$ColorChannelField, {
1068
- ...props,
1069
- channel: props.channel,
1070
- forwardedRef: ref
1071
- });
1072
- else return /* @__PURE__ */ React__default.createElement($3ada01a82feafb94$var$HexColorField, {
1073
- ...props,
1074
- forwardedRef: ref
1075
- });
1076
- });
1077
- function $3ada01a82feafb94$var$ColorChannelField(props) {
1078
- let { locale } = $18f2051aff69b9bf$export$43bb16f9c6d9e3f7();
1079
- let state = $31a863bb88e75dd6$export$b9fc0d69c9190c4a({
1080
- ...props,
1081
- locale
1082
- });
1083
- let inputRef = useRef(null);
1084
- let [labelRef, label] = $64fa3d84918910a7$export$9d4c57ee4c6ffdd8(!props["aria-label"] && !props["aria-labelledby"]);
1085
- var _props_validationBehavior;
1086
- let { labelProps, inputProps, descriptionProps, errorMessageProps, ...validation } = $5e632d1ff0188f00$export$e55dd820142d3131({
1087
- ...$64fa3d84918910a7$export$ef03459518577ad4(props),
1088
- label,
1089
- validationBehavior: (_props_validationBehavior = props.validationBehavior) !== null && _props_validationBehavior !== void 0 ? _props_validationBehavior : "native"
1090
- }, state, inputRef);
1091
- return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, $3ada01a82feafb94$var$useChildren(props, state, props.forwardedRef, inputProps, inputRef, labelProps, labelRef, descriptionProps, errorMessageProps, validation), props.name && /* @__PURE__ */ React__default.createElement("input", {
1092
- type: "hidden",
1093
- name: props.name,
1094
- value: isNaN(state.numberValue) ? "" : state.numberValue
1095
- }));
1096
- }
1097
- function $3ada01a82feafb94$var$HexColorField(props) {
1098
- var _props_validationBehavior;
1099
- let state = $b335ada08155d9c0$export$d52a01683abdfcd6({
1100
- ...props,
1101
- validationBehavior: (_props_validationBehavior = props.validationBehavior) !== null && _props_validationBehavior !== void 0 ? _props_validationBehavior : "native"
1102
- });
1103
- let inputRef = useRef(null);
1104
- let [labelRef, label] = $64fa3d84918910a7$export$9d4c57ee4c6ffdd8(!props["aria-label"] && !props["aria-labelledby"]);
1105
- var _props_validationBehavior1;
1106
- let { labelProps, inputProps, descriptionProps, errorMessageProps, ...validation } = $f6896b05b2ecad12$export$77e32ca575a28fdf({
1107
- ...$64fa3d84918910a7$export$ef03459518577ad4(props),
1108
- label,
1109
- validationBehavior: (_props_validationBehavior1 = props.validationBehavior) !== null && _props_validationBehavior1 !== void 0 ? _props_validationBehavior1 : "native"
1110
- }, state, inputRef);
1111
- return $3ada01a82feafb94$var$useChildren(props, state, props.forwardedRef, inputProps, inputRef, labelProps, labelRef, descriptionProps, errorMessageProps, validation);
1112
- }
1113
- function $3ada01a82feafb94$var$useChildren(props, state, ref, inputProps, inputRef, labelProps, labelRef, descriptionProps, errorMessageProps, validation) {
1114
- let renderProps = $64fa3d84918910a7$export$4d86445c2cf5e3({
1115
- ...props,
1116
- values: {
1117
- state,
1118
- channel: props.channel || "hex",
1119
- isDisabled: props.isDisabled || false,
1120
- isInvalid: validation.isInvalid || false
1121
- },
1122
- defaultClassName: "react-aria-ColorField"
1123
- });
1124
- let DOMProps = $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props);
1125
- delete DOMProps.id;
1126
- return /* @__PURE__ */ React__default.createElement($64fa3d84918910a7$export$2881499e37b75b9a, {
1127
- values: [
1128
- [
1129
- $3ada01a82feafb94$export$96b6d32b05a1a8ed,
1130
- state
1131
- ],
1132
- [
1133
- $3985021b0ad6602f$export$37fb8590cf2c088c,
1134
- {
1135
- ...inputProps,
1136
- ref: inputRef
1137
- }
1138
- ],
1139
- [
1140
- $01b77f81d0f07f68$export$75b6ee27786ba447,
1141
- {
1142
- ...labelProps,
1143
- ref: labelRef
1144
- }
1145
- ],
1146
- [
1147
- $514c0188e459b4c0$export$9afb8bc826b033ea,
1148
- {
1149
- slots: {
1150
- description: descriptionProps,
1151
- errorMessage: errorMessageProps
1152
- }
1153
- }
1154
- ],
1155
- [
1156
- $ee014567cb39d3f0$export$ff05c3ac10437e03,
1157
- validation
1158
- ]
1159
- ]
1160
- }, /* @__PURE__ */ React__default.createElement("div", {
1161
- ...DOMProps,
1162
- ...renderProps,
1163
- ref,
1164
- slot: props.slot || void 0,
1165
- "data-channel": props.channel || "hex",
1166
- "data-disabled": props.isDisabled || void 0,
1167
- "data-invalid": validation.isInvalid || void 0
1168
- }));
1169
- }
1170
- const $1cca5300a3c2e7f9$export$c7fad7ea00194428 = /* @__PURE__ */ createContext(null);
1171
- const $1cca5300a3c2e7f9$export$44fd664bcca5b6fb = /* @__PURE__ */ forwardRef(function ColorSlider(props, ref) {
1172
- [props, ref] = $64fa3d84918910a7$export$29f1550f4b0d4415(props, ref, $4e85f108e88277b8$export$717b2c0a523a0b53);
1173
- let { locale } = $18f2051aff69b9bf$export$43bb16f9c6d9e3f7();
1174
- let state = $25a25ac0d1624665$export$57bc203e1c9c6d44({
1175
- ...props,
1176
- locale
1177
- });
1178
- let trackRef = React__default.useRef(null);
1179
- let inputRef = React__default.useRef(null);
1180
- let [labelRef, label] = $64fa3d84918910a7$export$9d4c57ee4c6ffdd8(!props["aria-label"] && !props["aria-labelledby"]);
1181
- let { trackProps, thumbProps, inputProps, labelProps, outputProps } = $40af666d6c251e36$export$106b7a4e66508f66({
1182
- ...props,
1183
- label,
1184
- trackRef,
1185
- inputRef
1186
- }, state);
1187
- let renderProps = $64fa3d84918910a7$export$4d86445c2cf5e3({
1188
- ...props,
1189
- values: {
1190
- orientation: state.orientation,
1191
- isDisabled: state.isDisabled,
1192
- state
1193
- },
1194
- defaultClassName: "react-aria-ColorSlider"
1195
- });
1196
- let DOMProps = $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props);
1197
- delete DOMProps.id;
1198
- return /* @__PURE__ */ React__default.createElement($64fa3d84918910a7$export$2881499e37b75b9a, {
1199
- values: [
1200
- [
1201
- $1cca5300a3c2e7f9$export$c7fad7ea00194428,
1202
- state
1203
- ],
1204
- [
1205
- $6f909507e6374d18$export$1e7083018727fa60,
1206
- state
1207
- ],
1208
- [
1209
- $6f909507e6374d18$export$f1fce0420cc6d8ee,
1210
- {
1211
- ...trackProps,
1212
- ref: trackRef
1213
- }
1214
- ],
1215
- [
1216
- $6f909507e6374d18$export$6189c2744041d8f8,
1217
- outputProps
1218
- ],
1219
- [
1220
- $01b77f81d0f07f68$export$75b6ee27786ba447,
1221
- {
1222
- ...labelProps,
1223
- ref: labelRef,
1224
- children: state.value.getChannelName(props.channel, locale)
1225
- }
1226
- ],
1227
- [
1228
- $e2b71ec1d6016406$export$c80c0ea2ca5cb846,
1229
- {
1230
- state,
1231
- thumbProps,
1232
- inputXRef: inputRef,
1233
- xInputProps: inputProps,
1234
- isDisabled: props.isDisabled
1235
- }
1236
- ]
1237
- ]
1238
- }, /* @__PURE__ */ React__default.createElement("div", {
1239
- ...DOMProps,
1240
- ...renderProps,
1241
- ref,
1242
- slot: props.slot || void 0,
1243
- "data-orientation": state.orientation,
1244
- "data-disabled": state.isDisabled || void 0
1245
- }));
1246
- });
1247
- /**
1248
- * A solid color picker.
1249
- *
1250
- * @component
1251
- * @param {Object} props - Component props.
1252
- * @param {import('react-aria-components').Color} props.value - The color value. Hex format is preferred, but HSL, HSB, and RGB are also supported.
1253
- * @param {Function} props.onChange - The change handler.
1254
- * @param {boolean} [props.disabled] - Whether the color picker is disabled.
1255
- * @param {Function} [props.onChangeEnd] - The change end handler.
1256
- * @param {boolean} [props.allowTransparency=false] - Whether the color picker allows transparency.
1257
- * @param {OutputColorFormat} [props.outputFormat] - The output format. Default is 'hex' (or 'hexa' if `allowTransparency` is true).
1258
- * @param {boolean} [props.noAdvancedOptions] - If `true`, the advanced options are hidden.
1259
- * @param {boolean} [props.hidden] - If `true`, the component is not rendered.
1260
- *
1261
- * @typedef {'hex' | 'hexa' | 'rgb' | 'rgba' | 'hsl' | 'hsla' | 'hsb' | 'hsba'} OutputColorFormat
1262
- *
1263
- * @returns {JSX.Element} The ButtonGroup component.
1264
- *
1265
- * @example
1266
- * <ButtonGroup
1267
- *
1268
- * @preserve
1269
- */
1270
- const SolidColorPicker = (props) => {
1271
- const { value: rawValue, onChange, disabled, onChangeEnd, allowTransparency = false, outputFormat, hidden, noAdvancedOptions } = props;
1272
- const value = rawValue == null ? void 0 : rawValue.replace("transparent", "rgba(0, 0, 0, 0)");
1273
- const defaultColor = $799cddbef784668f$export$6e865ea70d7724f("#00000000").toFormat(allowTransparency ? "hsla" : "hsl");
1274
- const modifiedValue = value && (value == null ? void 0 : value.length) > 1 ? $799cddbef784668f$export$6e865ea70d7724f(value) : defaultColor;
1275
- const [color, setColor] = useState(modifiedValue.toFormat(allowTransparency ? "hsla" : "hsl"));
1276
- if (hidden) {
1277
- return null;
1278
- }
1279
- let handleChangeEnd;
1280
- if (onChangeEnd) {
1281
- handleChangeEnd = (color2) => {
1282
- setColor(color2 ?? defaultColor);
1283
- onChange(color2 == null ? void 0 : color2.toString(outputFormat ?? (allowTransparency ? "hexa" : "hex")));
1284
- };
1285
- }
1286
- let handleChange = (color2) => {
1287
- setColor(color2 ?? defaultColor);
1288
- onChange(color2 == null ? void 0 : color2.toString(outputFormat ?? (allowTransparency ? "hexa" : "hex")));
1289
- };
1290
- const valueInputClassName = clsx(
1291
- "es:h-8 es:w-12",
1292
- "es:tabular-nums es:font-mono",
1293
- "es:border es:rounded-lg es:border-secondary-300 es:p-2 es:text-sm es:shadow-xs es:transition es:selection:bg-accent-500/20 es:selection:text-accent-950",
1294
- "es:any-focus:outline-hidden",
1295
- "es:focus-visible:ring-2 es:focus-visible:ring-accent-500/50 es:focus-visible:z-10",
1296
- "es:focus-visible:border-accent-500",
1297
- "es:inset-ring es:inset-ring-secondary-100"
1298
- );
1299
- return /* @__PURE__ */ jsxs("div", { className: "es:flex es:flex-col es:items-center es:gap-2", children: [
1300
- /* @__PURE__ */ jsx(
1301
- $0de070065d44825d$export$b2103f68a961418e,
1302
- {
1303
- value: color,
1304
- xChannel: "saturation",
1305
- yChannel: "lightness",
1306
- className: clsx(
1307
- "es:size-48 es:rounded-md es:border es:border-secondary-300 es:shadow-sm es:transition",
1308
- 'es:[&:has(>_[data-focus-visible="true"])]:ring-2 es:[&:has(>_[data-focus-visible="true"])]:ring-accent-500/50',
1309
- "es:disabled:bg-linear-to-r! es:disabled:from-white es:disabled:to-secondary-100"
1310
- ),
1311
- onChange: handleChange,
1312
- onChangeEnd: handleChangeEnd,
1313
- isDisabled: disabled,
1314
- children: /* @__PURE__ */ jsx($e2b71ec1d6016406$export$a3cc47cee1c1ccc, { className: "es:size-5 es:rounded-full es:transition es:dragging:scale-110! es:border es:border-white es:shadow-[0_0_0_1px_black] es:disabled:invisible" })
1315
- }
1316
- ),
1317
- /* @__PURE__ */ jsx(
1318
- $1cca5300a3c2e7f9$export$44fd664bcca5b6fb,
1319
- {
1320
- channel: "hue",
1321
- value: color,
1322
- onChange: handleChange,
1323
- isDisabled: disabled,
1324
- children: /* @__PURE__ */ jsx(
1325
- $6f909507e6374d18$export$105594979f116971,
1326
- {
1327
- className: clsx(
1328
- "es:h-7 es:w-48 es:rounded-md es:border es:border-secondary-300 es:shadow-sm",
1329
- 'es:[&:has(>_[data-focus-visible="true"])]:ring-2 es:[&:has(>_[data-focus-visible="true"])]:ring-accent-500/50',
1330
- "es:disabled:bg-linear-to-r! es:disabled:from-white es:disabled:to-secondary-100"
1331
- ),
1332
- children: /* @__PURE__ */ jsx($e2b71ec1d6016406$export$a3cc47cee1c1ccc, { className: "es:top-3.25 es:size-5 es:rounded-full es:border es:border-white es:shadow-[0_0_0_1px_black] es:transition es:dragging:scale-110! es:disabled:invisible" })
1333
- }
1334
- )
1335
- }
1336
- ),
1337
- allowTransparency && /* @__PURE__ */ jsx(
1338
- $1cca5300a3c2e7f9$export$44fd664bcca5b6fb,
1339
- {
1340
- channel: "alpha",
1341
- value: color,
1342
- onChange: handleChange,
1343
- isDisabled: disabled,
1344
- children: /* @__PURE__ */ jsx(
1345
- $6f909507e6374d18$export$105594979f116971,
1346
- {
1347
- className: clsx(
1348
- "es:h-7 es:w-48 es:rounded-md es:border es:border-secondary-300 es:shadow-sm",
1349
- 'es:[&:has(>_[data-focus-visible="true"])]:ring-2 es:[&:has(>_[data-focus-visible="true"])]:ring-accent-500/50',
1350
- "es:disabled:bg-linear-to-r! es:disabled:from-white es:disabled:to-secondary-100"
1351
- ),
1352
- style: () => {
1353
- const startColor = color.clone().withChannelValue("alpha", 0).toString("hsla");
1354
- const endColor = color.clone().withChannelValue("alpha", 1).toString("hsla");
1355
- return {
1356
- background: `linear-gradient(to right, ${startColor}, ${endColor}), repeating-conic-gradient(rgb(204, 204, 204) 0%, rgb(204, 204, 204) 25%, white 0%, white 50%) 50% center / 14px 14px`
1357
- };
1358
- },
1359
- children: /* @__PURE__ */ jsx($e2b71ec1d6016406$export$a3cc47cee1c1ccc, { className: "es:top-3.25 es:size-5 es:rounded-full es:border es:border-white es:shadow-[0_0_0_1px_black] es:transition es:disabled:invisible" })
1360
- }
1361
- )
1362
- }
1363
- ),
1364
- /* @__PURE__ */ jsxs("div", { className: "es:flex es:items-center es:justify-center", children: [
1365
- /* @__PURE__ */ jsx(
1366
- $3ada01a82feafb94$export$b865d4358897bb17,
1367
- {
1368
- value: color,
1369
- onChange: (color2) => handleChange(color2 == null ? void 0 : color2.toFormat("hsl")),
1370
- "aria-label": __("Hex color value", "eightshift-ui-components"),
1371
- isDisabled: disabled,
1372
- children: /* @__PURE__ */ jsx(
1373
- $3985021b0ad6602f$export$f5b8910cec6cf069,
1374
- {
1375
- className: clsx(
1376
- "es:h-9 es:w-20",
1377
- "es:tabular-nums es:font-mono",
1378
- "es:border es:border-secondary-300 es:p-2 es:text-sm es:shadow-xs es:transition es:selection:bg-accent-500/20 es:selection:text-accent-950",
1379
- "es:any-focus:outline-hidden",
1380
- "es:focus-visible:ring-2 es:focus-visible:ring-accent-500/50 es:focus-visible:z-10",
1381
- "es:focus-visible:border-accent-500",
1382
- "es:inset-ring es:inset-ring-secondary-100",
1383
- noAdvancedOptions ? "es:rounded-lg" : "es:rounded-l-lg"
1384
- )
1385
- }
1386
- )
1387
- }
1388
- ),
1389
- /* @__PURE__ */ jsxs(
1390
- TriggeredPopover,
1391
- {
1392
- triggerButtonIcon: icons.dropdownCaretAlt,
1393
- className: "es:w-52 es:p-3",
1394
- triggerButtonProps: {
1395
- disabled,
1396
- tooltip: __("Advanced color options", "eightshift-ui-components"),
1397
- className: "es:rounded-l-none es:rounded-r-l es:-ml-px es:w-6 es:icon:size-4.5!"
1398
- },
1399
- hidden: noAdvancedOptions,
1400
- children: [
1401
- /* @__PURE__ */ jsx($01b77f81d0f07f68$export$b04be29aa201d4f5, { className: "es:text-sm es:tracking-tight es:mb-2 es:inline-block", children: __("Advanced color options", "eightshift-ui-components") }),
1402
- /* @__PURE__ */ jsxs(Tabs, { type: "pillCompactInverse", children: [
1403
- /* @__PURE__ */ jsxs(TabList, { children: [
1404
- /* @__PURE__ */ jsx(Tab, { children: "RGB" }),
1405
- /* @__PURE__ */ jsx(Tab, { children: "HSL" }),
1406
- /* @__PURE__ */ jsx(Tab, { children: "HSB" })
1407
- ] }),
1408
- /* @__PURE__ */ jsxs(TabPanel, { children: [
1409
- /* @__PURE__ */ jsx(
1410
- $3ada01a82feafb94$export$b865d4358897bb17,
1411
- {
1412
- value: color == null ? void 0 : color.toFormat(allowTransparency ? "rgba" : "rgb"),
1413
- onChange: (color2) => handleChange(color2 == null ? void 0 : color2.toFormat("hsl")),
1414
- channel: "red",
1415
- children: /* @__PURE__ */ jsx(
1416
- BaseControl,
1417
- {
1418
- label: __("Red", "eightshift-ui-components"),
1419
- inline: true,
1420
- children: /* @__PURE__ */ jsx($3985021b0ad6602f$export$f5b8910cec6cf069, { className: valueInputClassName })
1421
- }
1422
- )
1423
- }
1424
- ),
1425
- /* @__PURE__ */ jsx(
1426
- $3ada01a82feafb94$export$b865d4358897bb17,
1427
- {
1428
- value: color == null ? void 0 : color.toFormat(allowTransparency ? "rgba" : "rgb"),
1429
- onChange: (color2) => handleChange(color2 == null ? void 0 : color2.toFormat("hsl")),
1430
- channel: "green",
1431
- children: /* @__PURE__ */ jsx(
1432
- BaseControl,
1433
- {
1434
- label: __("Green", "eightshift-ui-components"),
1435
- inline: true,
1436
- children: /* @__PURE__ */ jsx($3985021b0ad6602f$export$f5b8910cec6cf069, { className: valueInputClassName })
1437
- }
1438
- )
1439
- }
1440
- ),
1441
- /* @__PURE__ */ jsx(
1442
- $3ada01a82feafb94$export$b865d4358897bb17,
1443
- {
1444
- value: color == null ? void 0 : color.toFormat(allowTransparency ? "rgba" : "rgb"),
1445
- onChange: (color2) => handleChange(color2 == null ? void 0 : color2.toFormat("hsl")),
1446
- channel: "blue",
1447
- children: /* @__PURE__ */ jsx(
1448
- BaseControl,
1449
- {
1450
- label: __("Blue", "eightshift-ui-components"),
1451
- inline: true,
1452
- children: /* @__PURE__ */ jsx($3985021b0ad6602f$export$f5b8910cec6cf069, { className: valueInputClassName })
1453
- }
1454
- )
1455
- }
1456
- )
1457
- ] }),
1458
- /* @__PURE__ */ jsxs(TabPanel, { children: [
1459
- /* @__PURE__ */ jsx(
1460
- $3ada01a82feafb94$export$b865d4358897bb17,
1461
- {
1462
- value: color == null ? void 0 : color.toFormat(allowTransparency ? "hsla" : "hsl"),
1463
- onChange: (color2) => handleChange(color2 == null ? void 0 : color2.toFormat("hsl")),
1464
- channel: "hue",
1465
- children: /* @__PURE__ */ jsx(
1466
- BaseControl,
1467
- {
1468
- label: __("Hue", "eightshift-ui-components"),
1469
- inline: true,
1470
- children: /* @__PURE__ */ jsx($3985021b0ad6602f$export$f5b8910cec6cf069, { className: valueInputClassName })
1471
- }
1472
- )
1473
- }
1474
- ),
1475
- /* @__PURE__ */ jsx(
1476
- $3ada01a82feafb94$export$b865d4358897bb17,
1477
- {
1478
- value: color == null ? void 0 : color.toFormat(allowTransparency ? "hsla" : "hsl"),
1479
- onChange: (color2) => handleChange(color2 == null ? void 0 : color2.toFormat("hsl")),
1480
- channel: "saturation",
1481
- children: /* @__PURE__ */ jsx(
1482
- BaseControl,
1483
- {
1484
- label: __("Saturation", "eightshift-ui-components"),
1485
- inline: true,
1486
- children: /* @__PURE__ */ jsx($3985021b0ad6602f$export$f5b8910cec6cf069, { className: valueInputClassName })
1487
- }
1488
- )
1489
- }
1490
- ),
1491
- /* @__PURE__ */ jsx(
1492
- $3ada01a82feafb94$export$b865d4358897bb17,
1493
- {
1494
- value: color == null ? void 0 : color.toFormat(allowTransparency ? "hsla" : "hsl"),
1495
- onChange: (color2) => handleChange(color2 == null ? void 0 : color2.toFormat("hsl")),
1496
- channel: "lightness",
1497
- children: /* @__PURE__ */ jsx(
1498
- BaseControl,
1499
- {
1500
- label: __("Lightness", "eightshift-ui-components"),
1501
- inline: true,
1502
- children: /* @__PURE__ */ jsx($3985021b0ad6602f$export$f5b8910cec6cf069, { className: valueInputClassName })
1503
- }
1504
- )
1505
- }
1506
- )
1507
- ] }),
1508
- /* @__PURE__ */ jsxs(TabPanel, { children: [
1509
- /* @__PURE__ */ jsx(
1510
- $3ada01a82feafb94$export$b865d4358897bb17,
1511
- {
1512
- value: color == null ? void 0 : color.toFormat(allowTransparency ? "hsba" : "hsb"),
1513
- onChange: (color2) => handleChange(color2 == null ? void 0 : color2.toFormat("hsl")),
1514
- channel: "hue",
1515
- children: /* @__PURE__ */ jsx(
1516
- BaseControl,
1517
- {
1518
- label: __("Hue", "eightshift-ui-components"),
1519
- inline: true,
1520
- children: /* @__PURE__ */ jsx($3985021b0ad6602f$export$f5b8910cec6cf069, { className: valueInputClassName })
1521
- }
1522
- )
1523
- }
1524
- ),
1525
- /* @__PURE__ */ jsx(
1526
- $3ada01a82feafb94$export$b865d4358897bb17,
1527
- {
1528
- value: color == null ? void 0 : color.toFormat(allowTransparency ? "hsba" : "hsb"),
1529
- onChange: (color2) => handleChange(color2 == null ? void 0 : color2.toFormat("hsl")),
1530
- channel: "saturation",
1531
- children: /* @__PURE__ */ jsx(
1532
- BaseControl,
1533
- {
1534
- label: __("Saturation", "eightshift-ui-components"),
1535
- inline: true,
1536
- children: /* @__PURE__ */ jsx($3985021b0ad6602f$export$f5b8910cec6cf069, { className: valueInputClassName })
1537
- }
1538
- )
1539
- }
1540
- ),
1541
- /* @__PURE__ */ jsx(
1542
- $3ada01a82feafb94$export$b865d4358897bb17,
1543
- {
1544
- value: color == null ? void 0 : color.toFormat(allowTransparency ? "hsba" : "hsb"),
1545
- onChange: (color2) => handleChange(color2 == null ? void 0 : color2.toFormat("hsl")),
1546
- channel: "brightness",
1547
- children: /* @__PURE__ */ jsx(
1548
- BaseControl,
1549
- {
1550
- label: __("Brightness", "eightshift-ui-components"),
1551
- inline: true,
1552
- children: /* @__PURE__ */ jsx($3985021b0ad6602f$export$f5b8910cec6cf069, { className: valueInputClassName })
1553
- }
1554
- )
1555
- }
1556
- )
1557
- ] })
1558
- ] })
1559
- ]
1560
- }
1561
- )
1562
- ] })
1563
- ] });
1564
- };
1565
- export {
1566
- SolidColorPicker
1567
- };