plotboilerplate 1.24.0 → 1.26.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 (222) hide show
  1. package/README.md +14 -1
  2. package/dist/index.esm.js +433 -162
  3. package/dist/index.esm.js.map +1 -1
  4. package/dist/index.esm.min.js +1 -1
  5. package/dist/index.esm.min.js.map +1 -1
  6. package/dist/plotboilerplate.browser.min.js +1 -1
  7. package/dist/plotboilerplate.browser.min.js.map +1 -1
  8. package/dist/plotboilerplate.js +12312 -12041
  9. package/dist/plotboilerplate.min.js +1 -1
  10. package/package.json +9 -5
  11. package/src/cjs/Bounds.d.ts +79 -25
  12. package/src/cjs/Bounds.js +102 -29
  13. package/src/cjs/Bounds.js.map +1 -1
  14. package/src/cjs/CircleSector.d.ts +3 -0
  15. package/src/cjs/CircleSector.js +28 -1
  16. package/src/cjs/CircleSector.js.map +1 -1
  17. package/src/cjs/PlotBoilerplate.d.ts +37 -6
  18. package/src/cjs/PlotBoilerplate.js +222 -116
  19. package/src/cjs/PlotBoilerplate.js.map +1 -1
  20. package/src/cjs/Polygon.d.ts +26 -7
  21. package/src/cjs/Polygon.js +56 -10
  22. package/src/cjs/Polygon.js.map +1 -1
  23. package/src/cjs/Triangle.js +2 -2
  24. package/src/cjs/Triangle.js.map +1 -1
  25. package/src/cjs/Vertex.d.ts +15 -3
  26. package/src/cjs/Vertex.js +18 -1
  27. package/src/cjs/Vertex.js.map +1 -1
  28. package/src/cjs/drawutilssvg.d.ts +2 -1
  29. package/src/cjs/drawutilssvg.js +9 -3
  30. package/src/cjs/drawutilssvg.js.map +1 -1
  31. package/src/cjs/interfaces/core.d.ts +28 -0
  32. package/src/cjs/interfaces/core.js +2 -0
  33. package/src/cjs/interfaces/core.js.map +1 -1
  34. package/src/cjs/utils/LissajousFigure.d.ts +34 -0
  35. package/src/cjs/utils/LissajousFigure.js +100 -0
  36. package/src/cjs/utils/LissajousFigure.js.map +1 -0
  37. package/src/cjs/utils/PerlinNoise.d.ts +19 -0
  38. package/src/cjs/utils/PerlinNoise.js +352 -0
  39. package/src/cjs/utils/PerlinNoise.js.map +1 -0
  40. package/src/cjs/utils/SVGPathUtils.d.ts +22 -0
  41. package/src/cjs/utils/SVGPathUtils.js +45 -0
  42. package/src/cjs/utils/SVGPathUtils.js.map +1 -0
  43. package/src/cjs/utils/algorithms/pixelCornersToRoundPaths.d.ts +23 -0
  44. package/src/cjs/utils/algorithms/pixelCornersToRoundPaths.js +270 -0
  45. package/src/cjs/utils/algorithms/pixelCornersToRoundPaths.js.map +1 -0
  46. package/src/cjs/utils/datastructures/Color.d.ts +147 -1
  47. package/src/cjs/utils/datastructures/Color.js +385 -41
  48. package/src/cjs/utils/datastructures/Color.js.map +1 -1
  49. package/src/cjs/utils/datastructures/ColorGradient.d.ts +79 -0
  50. package/src/cjs/utils/datastructures/ColorGradient.js +171 -0
  51. package/src/cjs/utils/datastructures/ColorGradient.js.map +1 -0
  52. package/src/cjs/utils/datastructures/DataGrid2d.d.ts +6 -0
  53. package/src/cjs/utils/datastructures/DataGrid2dArrayMatrix.d.ts +88 -0
  54. package/src/cjs/utils/datastructures/DataGrid2dArrayMatrix.js +155 -0
  55. package/src/cjs/utils/datastructures/DataGrid2dArrayMatrix.js.map +1 -0
  56. package/src/cjs/utils/datastructures/DataGrid2dListAdapter.d.ts +1 -7
  57. package/src/cjs/utils/datastructures/DataGrid2dListAdapter.js +3 -3
  58. package/src/cjs/utils/datastructures/DataGrid2dListAdapter.js.map +1 -1
  59. package/src/cjs/utils/datastructures/GeometryMesh.d.ts +49 -0
  60. package/src/cjs/utils/datastructures/GeometryMesh.js +58 -0
  61. package/src/cjs/utils/datastructures/GeometryMesh.js.map +1 -0
  62. package/src/cjs/utils/detectDarkMode.js +16 -7
  63. package/src/cjs/utils/detectDarkMode.js.map +1 -1
  64. package/src/cjs/utils/dom/components/ColorGradientPicker.d.ts +246 -0
  65. package/src/cjs/utils/dom/components/ColorGradientPicker.js +667 -0
  66. package/src/cjs/utils/dom/components/ColorGradientPicker.js.map +1 -0
  67. package/src/cjs/utils/dom/components/ColorGradientPickerJSX.d.ts +129 -0
  68. package/src/cjs/utils/dom/components/ColorGradientPickerJSX.js +520 -0
  69. package/src/cjs/utils/dom/components/ColorGradientPickerJSX.js.map +1 -0
  70. package/src/cjs/utils/dom/components/ColorGradientSelector.d.ts +118 -0
  71. package/src/cjs/utils/dom/components/ColorGradientSelector.js +327 -0
  72. package/src/cjs/utils/dom/components/ColorGradientSelector.js.map +1 -0
  73. package/src/cjs/utils/dom/components/Test.d.ts +7 -0
  74. package/src/cjs/utils/dom/components/Test.js +30 -0
  75. package/src/cjs/utils/dom/components/Test.js.map +1 -0
  76. package/src/cjs/utils/dom/guiSizeToggler.js +1 -1
  77. package/src/cjs/utils/dom/guiSizeToggler.js.map +1 -1
  78. package/src/cjs/utils/helpers/BezierPathInteractionHelper.d.ts +9 -3
  79. package/src/cjs/utils/helpers/BezierPathInteractionHelper.js +20 -13
  80. package/src/cjs/utils/helpers/BezierPathInteractionHelper.js.map +1 -1
  81. package/src/cjs/utils/helpers/CircleHelper.d.ts +10 -1
  82. package/src/cjs/utils/helpers/CircleHelper.js +13 -2
  83. package/src/cjs/utils/helpers/CircleHelper.js.map +1 -1
  84. package/src/cjs/utils/helpers/CircleSectorHelper.d.ts +2 -2
  85. package/src/cjs/utils/helpers/CircleSectorHelper.js +1 -0
  86. package/src/cjs/utils/helpers/CircleSectorHelper.js.map +1 -1
  87. package/src/cjs/utils/helpers/TriangleHelper.d.ts +57 -0
  88. package/src/cjs/utils/helpers/TriangleHelper.js +83 -0
  89. package/src/cjs/utils/helpers/TriangleHelper.js.map +1 -0
  90. package/src/cjs/utils/helpers/VEllipseHelper.d.ts +6 -4
  91. package/src/cjs/utils/helpers/VEllipseHelper.js +4 -2
  92. package/src/cjs/utils/helpers/VEllipseHelper.js.map +1 -1
  93. package/src/cjs/utils/helpers/VEllipseSectorHelper.d.ts +3 -2
  94. package/src/cjs/utils/helpers/VEllipseSectorHelper.js +1 -0
  95. package/src/cjs/utils/helpers/VEllipseSectorHelper.js.map +1 -1
  96. package/src/cjs/utils/parsers/LinearColorGradientParser.d.ts +78 -0
  97. package/src/cjs/utils/parsers/LinearColorGradientParser.js +224 -0
  98. package/src/cjs/utils/parsers/LinearColorGradientParser.js.map +1 -0
  99. package/src/cjs/utils/parsers/svg/types.d.ts +8 -8
  100. package/src/createDemoDrawables.js +1 -0
  101. package/src/esm/Bounds.d.ts +79 -25
  102. package/src/esm/Bounds.js +102 -29
  103. package/src/esm/Bounds.js.map +1 -1
  104. package/src/esm/CircleSector.d.ts +3 -0
  105. package/src/esm/CircleSector.js +28 -1
  106. package/src/esm/CircleSector.js.map +1 -1
  107. package/src/esm/PlotBoilerplate.d.ts +37 -6
  108. package/src/esm/PlotBoilerplate.js +222 -116
  109. package/src/esm/PlotBoilerplate.js.map +1 -1
  110. package/src/esm/Polygon.d.ts +26 -7
  111. package/src/esm/Polygon.js +53 -10
  112. package/src/esm/Polygon.js.map +1 -1
  113. package/src/esm/Triangle.js +2 -2
  114. package/src/esm/Triangle.js.map +1 -1
  115. package/src/esm/Vertex.d.ts +15 -3
  116. package/src/esm/Vertex.js +18 -1
  117. package/src/esm/Vertex.js.map +1 -1
  118. package/src/esm/drawutilssvg.d.ts +2 -1
  119. package/src/esm/drawutilssvg.js +9 -3
  120. package/src/esm/drawutilssvg.js.map +1 -1
  121. package/src/esm/interfaces/core.d.ts +28 -0
  122. package/src/esm/interfaces/core.js +2 -0
  123. package/src/esm/interfaces/core.js.map +1 -1
  124. package/src/esm/utils/LissajousFigure.d.ts +34 -0
  125. package/src/esm/utils/LissajousFigure.js +95 -0
  126. package/src/esm/utils/LissajousFigure.js.map +1 -0
  127. package/src/esm/utils/PerlinNoise.d.ts +19 -0
  128. package/src/esm/utils/PerlinNoise.js +346 -0
  129. package/src/esm/utils/PerlinNoise.js.map +1 -0
  130. package/src/esm/utils/SVGPathUtils.d.ts +22 -0
  131. package/src/esm/utils/SVGPathUtils.js +42 -0
  132. package/src/esm/utils/SVGPathUtils.js.map +1 -0
  133. package/src/esm/utils/algorithms/pixelCornersToRoundPaths.d.ts +23 -0
  134. package/src/esm/utils/algorithms/pixelCornersToRoundPaths.js +266 -0
  135. package/src/esm/utils/algorithms/pixelCornersToRoundPaths.js.map +1 -0
  136. package/src/esm/utils/datastructures/Color.d.ts +147 -1
  137. package/src/esm/utils/datastructures/Color.js +386 -42
  138. package/src/esm/utils/datastructures/Color.js.map +1 -1
  139. package/src/esm/utils/datastructures/ColorGradient.d.ts +79 -0
  140. package/src/esm/utils/datastructures/ColorGradient.js +166 -0
  141. package/src/esm/utils/datastructures/ColorGradient.js.map +1 -0
  142. package/src/esm/utils/datastructures/DataGrid2d.d.ts +6 -0
  143. package/src/esm/utils/datastructures/DataGrid2dArrayMatrix.d.ts +88 -0
  144. package/src/esm/utils/datastructures/DataGrid2dArrayMatrix.js +150 -0
  145. package/src/esm/utils/datastructures/DataGrid2dArrayMatrix.js.map +1 -0
  146. package/src/esm/utils/datastructures/DataGrid2dListAdapter.d.ts +1 -7
  147. package/src/esm/utils/datastructures/DataGrid2dListAdapter.js +3 -3
  148. package/src/esm/utils/datastructures/DataGrid2dListAdapter.js.map +1 -1
  149. package/src/esm/utils/datastructures/GeometryMesh.d.ts +49 -0
  150. package/src/esm/utils/datastructures/GeometryMesh.js +53 -0
  151. package/src/esm/utils/datastructures/GeometryMesh.js.map +1 -0
  152. package/src/esm/utils/detectDarkMode.js +16 -7
  153. package/src/esm/utils/detectDarkMode.js.map +1 -1
  154. package/src/esm/utils/dom/components/ColorGradientPicker.d.ts +246 -0
  155. package/src/esm/utils/dom/components/ColorGradientPicker.js +743 -0
  156. package/src/esm/utils/dom/components/ColorGradientPicker.js.map +1 -0
  157. package/src/esm/utils/dom/components/ColorGradientPickerJSX.d.ts +129 -0
  158. package/src/esm/utils/dom/components/ColorGradientPickerJSX.js +582 -0
  159. package/src/esm/utils/dom/components/ColorGradientPickerJSX.js.map +1 -0
  160. package/src/esm/utils/dom/components/ColorGradientSelector.d.ts +118 -0
  161. package/src/esm/utils/dom/components/ColorGradientSelector.js +339 -0
  162. package/src/esm/utils/dom/components/ColorGradientSelector.js.map +1 -0
  163. package/src/esm/utils/dom/components/Test.d.ts +7 -0
  164. package/src/esm/utils/dom/components/Test.js +26 -0
  165. package/src/esm/utils/dom/components/Test.js.map +1 -0
  166. package/src/esm/utils/dom/guiSizeToggler.js +1 -1
  167. package/src/esm/utils/dom/guiSizeToggler.js.map +1 -1
  168. package/src/esm/utils/helpers/BezierPathInteractionHelper.d.ts +9 -3
  169. package/src/esm/utils/helpers/BezierPathInteractionHelper.js +20 -13
  170. package/src/esm/utils/helpers/BezierPathInteractionHelper.js.map +1 -1
  171. package/src/esm/utils/helpers/CircleHelper.d.ts +10 -1
  172. package/src/esm/utils/helpers/CircleHelper.js +13 -2
  173. package/src/esm/utils/helpers/CircleHelper.js.map +1 -1
  174. package/src/esm/utils/helpers/CircleSectorHelper.d.ts +2 -2
  175. package/src/esm/utils/helpers/CircleSectorHelper.js +1 -0
  176. package/src/esm/utils/helpers/CircleSectorHelper.js.map +1 -1
  177. package/src/esm/utils/helpers/TriangleHelper.d.ts +57 -0
  178. package/src/esm/utils/helpers/TriangleHelper.js +78 -0
  179. package/src/esm/utils/helpers/TriangleHelper.js.map +1 -0
  180. package/src/esm/utils/helpers/VEllipseHelper.d.ts +6 -4
  181. package/src/esm/utils/helpers/VEllipseHelper.js +4 -2
  182. package/src/esm/utils/helpers/VEllipseHelper.js.map +1 -1
  183. package/src/esm/utils/helpers/VEllipseSectorHelper.d.ts +3 -2
  184. package/src/esm/utils/helpers/VEllipseSectorHelper.js +1 -0
  185. package/src/esm/utils/helpers/VEllipseSectorHelper.js.map +1 -1
  186. package/src/esm/utils/parsers/LinearColorGradientParser.d.ts +78 -0
  187. package/src/esm/utils/parsers/LinearColorGradientParser.js +217 -0
  188. package/src/esm/utils/parsers/LinearColorGradientParser.js.map +1 -0
  189. package/src/esm/utils/parsers/svg/types.d.ts +8 -8
  190. package/src/external.d.ts +9 -0
  191. package/src/ts/Bounds.ts +107 -22
  192. package/src/ts/CircleSector.ts +39 -6
  193. package/src/ts/PlotBoilerplate.ts +233 -105
  194. package/src/ts/Polygon.ts +68 -14
  195. package/src/ts/Triangle.ts +2 -2
  196. package/src/ts/Vertex.ts +21 -3
  197. package/src/ts/drawutilssvg.ts +8 -3
  198. package/src/ts/interfaces/core.ts +31 -0
  199. package/src/ts/utils/LissajousFigure.ts +110 -0
  200. package/src/ts/utils/PerlinNoise.ts +368 -0
  201. package/src/ts/utils/SVGPathUtils.ts +55 -0
  202. package/src/ts/utils/algorithms/pixelCornersToRoundPaths.ts +379 -0
  203. package/src/ts/utils/datastructures/Color.ts +423 -44
  204. package/src/ts/utils/datastructures/ColorGradient.ts +196 -0
  205. package/src/ts/utils/datastructures/DataGrid2d.ts +7 -0
  206. package/src/ts/utils/datastructures/DataGrid2dArrayMatrix.ts +182 -0
  207. package/src/ts/utils/datastructures/DataGrid2dListAdapter.ts +4 -11
  208. package/src/ts/utils/datastructures/GeometryMesh.ts +79 -0
  209. package/src/ts/utils/detectDarkMode.ts +17 -8
  210. package/src/ts/utils/dom/components/ColorGradientPicker.tsx +889 -0
  211. package/src/ts/utils/dom/components/ColorGradientSelector.tsx +452 -0
  212. package/src/ts/utils/dom/components/Test.tsx +44 -0
  213. package/src/ts/utils/dom/components/_ColorGradientPicker_raw.ts_ +392 -0
  214. package/src/ts/utils/dom/guiSizeToggler.ts +1 -1
  215. package/src/ts/utils/helpers/BezierPathInteractionHelper.ts +25 -15
  216. package/src/ts/utils/helpers/CircleHelper.ts +17 -3
  217. package/src/ts/utils/helpers/CircleSectorHelper.ts +4 -2
  218. package/src/ts/utils/helpers/TriangleHelper.ts +102 -0
  219. package/src/ts/utils/helpers/VEllipseHelper.ts +6 -4
  220. package/src/ts/utils/helpers/VEllipseSectorHelper.ts +3 -2
  221. package/src/ts/utils/parsers/LinearColorGradientParser.ts +297 -0
  222. package/src/ts/utils/parsers/svg/types.ts +8 -8
@@ -0,0 +1,743 @@
1
+ /**
2
+ * Approach for a 'simple' color gradient picker for my PlotBoilerplate library.
3
+ *
4
+ * As it turned out a bit more complex in the end – due to the fact that color gradient
5
+ * picking is not a super simple task – so I used JSX here. Thus a JSX library is required
6
+ * to get this running: NoReact.
7
+ *
8
+ *
9
+ * @author Ikaros Kappler
10
+ * @date 2025-06-27
11
+ * @modified 2025-09-10 Fixing a color select bug on MacOS.
12
+ * @version 1.0.0
13
+ */
14
+ import * as NoReact from "noreact";
15
+ import { Color } from "../../datastructures/Color";
16
+ import { ColorGradient } from "../../datastructures/ColorGradient";
17
+ export class ColorGradientPicker {
18
+ /**
19
+ * The constructor: creates a new color gradient picker in the given container.
20
+ * If no container or ID is given then a new unbound `container` will be created (DIV).
21
+ *
22
+ * Pass a container ID or nothing – in the latter case the constructor will create
23
+ * a new DIV element.
24
+ *
25
+ * @param {string?} containerID - (optional) If you want to use an existing container (should be a DIV).
26
+ * @param {boolean?} isMobileMode - (optional) If `true` then the elements are rendered in double size.
27
+ */
28
+ constructor(containerID, isMobileMode) {
29
+ this._sliderElementRefs = [];
30
+ this.sliderMin = 0;
31
+ this.sliderMax = 100;
32
+ // Only used during initialization!
33
+ this.isMobileMode = false;
34
+ this.css_indicatorWidth_num = 1.0;
35
+ this.css_indicatorWidth = "1em";
36
+ this.css_indicatorHeight = "1em";
37
+ this.css_thumbWidth = "0.5em";
38
+ this.css_thumbHeight = "1.333em";
39
+ this.css_containerHeight = "20px";
40
+ this.installedChangeListeners = [];
41
+ this.__mouseDownPosition = null;
42
+ /**
43
+ * Creates a callback function for range slider.
44
+ *
45
+ * @returns
46
+ */
47
+ this.__createSliderChangeHandler = () => {
48
+ const _self = this;
49
+ return (e) => {
50
+ const targetSlider = e.target;
51
+ // console.log("Clicked", targetSlider ? targetSlider.getAttribute("id") : null);
52
+ if (!targetSlider) {
53
+ return false;
54
+ }
55
+ const currentSliderValue = Number.parseFloat(targetSlider.value);
56
+ const rangeSliderIndexRaw = targetSlider.dataset["rangeSliderIndex"];
57
+ // console.log("rangeSliderIndexRaw", rangeSliderIndexRaw);
58
+ if (!rangeSliderIndexRaw) {
59
+ return false;
60
+ }
61
+ const rangeSliderIndex = Number.parseInt(rangeSliderIndexRaw);
62
+ var leftSliderValue = this.__getSliderValue(rangeSliderIndex - 1, _self.sliderMin);
63
+ var rightSliderValue = this.__getSliderValue(rangeSliderIndex + 1, _self.sliderMax);
64
+ if (leftSliderValue >= currentSliderValue) {
65
+ targetSlider.value = `${leftSliderValue}`;
66
+ _self.__updateBackgroundGradient();
67
+ _self.__updateColorIndicator(rangeSliderIndex);
68
+ return false;
69
+ }
70
+ else if (rightSliderValue <= currentSliderValue) {
71
+ targetSlider.value = `${rightSliderValue}`;
72
+ _self.__updateBackgroundGradient();
73
+ _self.__updateColorIndicator(rangeSliderIndex);
74
+ return false;
75
+ }
76
+ else {
77
+ _self.__updateBackgroundGradient();
78
+ _self.__updateColorIndicator(rangeSliderIndex);
79
+ return true;
80
+ }
81
+ };
82
+ };
83
+ /**
84
+ * Adds custom styles (global STYLE tag).
85
+ *
86
+ * @private
87
+ */
88
+ this.__createCustomStylesElement = () => {
89
+ // Thanks to Ana Tudor
90
+ // https://css-tricks.com/multi-thumb-sliders-particular-two-thumb-case/
91
+ return (NoReact.createElement("style", null, `
92
+ #${this.elementID} {
93
+ margin-top: 1em;
94
+ }
95
+
96
+ #${this.elementID} input[type='range'] {
97
+
98
+ -webkit-appearance: none;
99
+
100
+ grid-column: 1;
101
+ grid-row: 2;
102
+
103
+ /* same as before */
104
+ background: none; /* get rid of white Chrome background */
105
+ color: #000;
106
+ font: inherit; /* fix too small font-size in both Chrome & Firefox */
107
+ margin: 0;
108
+ pointer-events: none; /* let clicks pass through */
109
+ }
110
+
111
+ #${this.elementID} input[type='range']::-webkit-slider-runnable-track {
112
+ -webkit-appearance: none;
113
+
114
+ background: none; /* get rid of Firefox track background */
115
+ height: 100%;
116
+ width: 100%;
117
+
118
+ pointer-events: none;
119
+ }
120
+
121
+ #${this.elementID} input[type='range']::-webkit-slider-thumb {
122
+ -webkit-appearance: none;
123
+ background: currentcolor;
124
+ border: none; /* get rid of Firefox thumb border */
125
+ border-radius: 6px; /* get rid of Firefox corner rounding */
126
+ pointer-events: auto; /* catch clicks */
127
+ width: ${this.css_thumbWidth};
128
+ height: ${this.css_thumbHeight};
129
+ }
130
+
131
+ #${this.elementID} input[type='range']:focus::-webkit-slider-thumb {
132
+ border: 2px solid white;
133
+ }
134
+
135
+ #${this.elementID} input[type='range']::-moz-range-track {
136
+ -webkit-appearance: none;
137
+ background: none; /* get rid of Firefox track background */
138
+ height: 100%;
139
+ width: 100%;
140
+ pointer-events: none;
141
+ }
142
+
143
+ #${this.elementID} input[type='range']::-moz-range-thumb {
144
+ /* -webkit-appearance: none; */
145
+ background: currentcolor;
146
+ border: none; /* get rid of Firefox thumb border */
147
+ border-radius: 6px; /* get rid of Firefox corner rounding */
148
+ pointer-events: auto; /* catch clicks */
149
+ width: ${this.css_thumbWidth};
150
+ height: ${this.css_thumbHeight};
151
+ }
152
+
153
+ #${this.elementID} input[type='range']:focus::-moz-range-thumb {
154
+ border: 2px solid white;
155
+ }
156
+
157
+ #${this.elementID} input[type='range'] {
158
+ /* same as before */
159
+ z-index: 1;
160
+ }
161
+
162
+ #${this.elementID} input[type='range']:focus {
163
+ z-index: 2;
164
+ /* outline: dotted 1px orange; */
165
+ color: darkorange;
166
+ }
167
+
168
+ body.darkmode #${this.elementID} .color-remove-button {
169
+ background-color: #1e2937;
170
+ color: grey;
171
+ }
172
+
173
+ body.darkmode #${this.elementID} .color-remove-button:hover,
174
+ body.darkmode #${this.elementID} .color-remove-button:active {
175
+ background-color: rgba(216,216,216,0.9);
176
+ }
177
+
178
+ `));
179
+ };
180
+ if (containerID) {
181
+ const cont = document.getElementById(containerID);
182
+ if (!cont) {
183
+ throw "Cannot create ColorGradientPicker. Component ID does not exist.";
184
+ }
185
+ this.container = cont;
186
+ }
187
+ else {
188
+ this.container = document.createElement("div");
189
+ }
190
+ this.baseID = Math.floor(Math.random() * 65535);
191
+ this.elementID = `color-gradient-picker-${this.baseID}`;
192
+ this.colorGradient = ColorGradient.createDefault();
193
+ this.isMobileMode = Boolean(isMobileMode);
194
+ if (isMobileMode) {
195
+ // Double size :)
196
+ this.css_indicatorWidth_num = 2.0;
197
+ this.css_indicatorWidth = "2em";
198
+ this.css_indicatorHeight = "2em";
199
+ this.css_thumbWidth = "1.0em";
200
+ this.css_thumbHeight = "2.666em";
201
+ this.css_containerHeight = "40px";
202
+ }
203
+ document.head.appendChild(this.__createCustomStylesElement());
204
+ this.container.append(this._render());
205
+ this.__initializeDataSets();
206
+ this.__updateColorIndicator(0);
207
+ this.__updateBackgroundGradient();
208
+ } // END constructor
209
+ setGradient(gradient, fireChangeEvent) {
210
+ // We are lazy: just throw away everything and rebuild all.
211
+ this.__removeAllChildNodes(this.container);
212
+ this.colorGradient = gradient;
213
+ this.container.append(this._render());
214
+ this.__initializeDataSets();
215
+ this.__updateColorIndicator(0);
216
+ this.__updateBackgroundGradient();
217
+ if (fireChangeEvent) {
218
+ this.__fireChangeEvent();
219
+ }
220
+ }
221
+ // +---------------------------------------------------------------------------------
222
+ // | A helper function to remove all child nodes.
223
+ // +-------------------------------
224
+ __removeAllChildNodes(node) {
225
+ while (node.lastChild) {
226
+ node.removeChild(node.lastChild);
227
+ }
228
+ }
229
+ // +---------------------------------------------------------------------------------
230
+ // | Used during initialization: define dataset values for each slider.
231
+ // +-------------------------------
232
+ __initializeDataSets() {
233
+ for (var i = 0; i < this._sliderElementRefs.length; i++) {
234
+ const sliderColor = this.colorGradient.values[i].color;
235
+ // console.log("Setting up slider color data set", i, sliderColor, sliderColor.cssRGB(), sliderColor.cssHEX());
236
+ this._sliderElementRefs[i].current.dataset.colorValue = sliderColor.cssRGB();
237
+ this._sliderElementRefs[i].current.dataset.colorValueHEX = sliderColor.cssHEX();
238
+ }
239
+ }
240
+ /**
241
+ * Adds a new color gradient change listener to this ColorGradientPicker.
242
+ *
243
+ * @param {ColorGradientChangeListener} listener - The listener to add.
244
+ * @returns {boolean} True, if the listener was added and did not exist before.
245
+ */
246
+ addChangeListener(listener) {
247
+ for (var i = 0; i < this.installedChangeListeners.length; i++) {
248
+ if (this.installedChangeListeners[i] === listener) {
249
+ return false;
250
+ }
251
+ }
252
+ this.installedChangeListeners.push(listener);
253
+ return true;
254
+ }
255
+ /**
256
+ *
257
+ * @param {ColorGradientChangeListener} listener The listener to remove.
258
+ * @returns {boolean} True, if the listener existed and has been removed.
259
+ */
260
+ removeChangeListener(listener) {
261
+ for (var i = 0; i < this.installedChangeListeners.length; i++) {
262
+ if (this.installedChangeListeners[i] === listener) {
263
+ this.installedChangeListeners.splice(i, 1);
264
+ return true;
265
+ }
266
+ }
267
+ return false;
268
+ }
269
+ /**
270
+ * Fires a change event to all installed listeners.
271
+ */
272
+ __fireChangeEvent() {
273
+ const newColorGradient = this.getColorGradient();
274
+ for (var i = 0; i < this.installedChangeListeners.length; i++) {
275
+ this.installedChangeListeners[i](newColorGradient, this);
276
+ }
277
+ }
278
+ /**
279
+ * Creates a new color range input element.
280
+ *
281
+ * @private
282
+ * @param {number} baseID
283
+ * @param index
284
+ * @param sliderMin
285
+ * @param sliderMax
286
+ * @param initialValue
287
+ * @param initialColor
288
+ * @returns
289
+ */
290
+ __createColorRangeInput(index, sliderMin, sliderMax, initialValue, initialColor) {
291
+ const sliderHandler = this.__createSliderChangeHandler();
292
+ const ref = NoReact.useRef();
293
+ // this._sliderElementRefs.push(ref);
294
+ this._sliderElementRefs.splice(index, 0, ref);
295
+ // console.log("new _sliderElementRefs", this._sliderElementRefs);
296
+ // Update all elements to the right of the new elelemt
297
+ this.__updateSliderDataSetIndices(index + 1);
298
+ return (NoReact.createElement("input", { id: `rage-slider-${this.baseID}-${index}`, type: "range", min: sliderMin, max: sliderMax, value: initialValue, style: { pos: "absolute", l: "0px", t: "0px", w: "100%", h: "60%" }, "data-range-slider-index": `${index}`, "data-colorValue": initialColor.cssRGB(), "data-colorValueHEX": initialColor.cssHEX(), onChange: sliderHandler, onClick: sliderHandler, ref: ref }));
299
+ }
300
+ /**
301
+ * Get the absolute length of this range, in slider units.
302
+ * @returns
303
+ */
304
+ getRangeLength() {
305
+ return this.sliderMax - this.sliderMin;
306
+ }
307
+ /**
308
+ * Handles color value changes.
309
+ *
310
+ * @returns
311
+ */
312
+ __colorChangeHandler() {
313
+ const _self = this;
314
+ return (_evt) => {
315
+ // console.log("__colorChangeHandler");
316
+ const activeSliderIndex_raw = this.colorInputRef.current.dataset.activeSliderIndex;
317
+ if (!activeSliderIndex_raw) {
318
+ console.warn("Cannot update color indicator; no active range slider set. This is likely a program error and should not happen.");
319
+ return false;
320
+ }
321
+ const activeSliderIndex = Number.parseInt(activeSliderIndex_raw);
322
+ if (Number.isNaN(activeSliderIndex) || activeSliderIndex < 0 || activeSliderIndex >= _self._sliderElementRefs.length) {
323
+ console.warn("Cannot update color indicator; active index invalid or out of bounds. This is likely a program error and should not happen.", activeSliderIndex);
324
+ return false;
325
+ }
326
+ const newColor = _self.colorInputRef.current.value;
327
+ const rangeSlider = _self._sliderElementRefs[activeSliderIndex].current;
328
+ rangeSlider.dataset.colorValue = newColor;
329
+ // rangeSlider.dataset["colorValue"] = newColor;
330
+ this.colorIndicatorColorButtonRef.current.style["background-color"] = newColor;
331
+ _self.__updateBackgroundGradient();
332
+ _self.__fireChangeEvent();
333
+ return true;
334
+ };
335
+ }
336
+ /**
337
+ * Removed the current color slider from the DOM and highlights the left neighbour.
338
+ *
339
+ * @returns {boolean} True if the element could be successfully removed.
340
+ */
341
+ __handleRemoveColor() {
342
+ // const colorInput : HTMLInputElement | null = evt.target;
343
+ // console.log("__colorChangeHandler");
344
+ const activeSliderIndex_raw = this.colorInputRef.current.dataset.activeSliderIndex;
345
+ if (!activeSliderIndex_raw) {
346
+ console.warn("Cannot remove color indicator; no active range slider set.");
347
+ return false;
348
+ }
349
+ const activeSliderIndex = Number.parseInt(activeSliderIndex_raw);
350
+ if (Number.isNaN(activeSliderIndex) || activeSliderIndex < 0 || activeSliderIndex >= this._sliderElementRefs.length) {
351
+ console.warn("Cannot remove color indicator; active index invalid or out of bounds.", activeSliderIndex);
352
+ return false;
353
+ }
354
+ if (activeSliderIndex === 0 || activeSliderIndex + 1 === this.getRangeLength()) {
355
+ console.warn("Cannot remove color indicator; leftmost and rightmost slider must not be removed.", activeSliderIndex);
356
+ return false;
357
+ }
358
+ const sliderElementRef = this._sliderElementRefs[activeSliderIndex];
359
+ sliderElementRef.current.remove();
360
+ this._sliderElementRefs.splice(activeSliderIndex, 1);
361
+ // Update all elements to the right of the removed elelemt
362
+ this.__updateSliderDataSetIndices(activeSliderIndex);
363
+ // Set left element active
364
+ this.__updateColorIndicator(activeSliderIndex - 1);
365
+ this.__updateBackgroundGradient();
366
+ this.__fireChangeEvent();
367
+ return true;
368
+ }
369
+ /**
370
+ * Once a slider element was added or removed then the following indices must be updated.
371
+ *
372
+ * @param {number} startIndex - The slider index to start updating at.
373
+ */
374
+ __updateSliderDataSetIndices(startIndex) {
375
+ // Update all elements to the right of the new elelemt
376
+ for (var i = startIndex; i < this._sliderElementRefs.length; i++) {
377
+ this._sliderElementRefs[i].current.setAttribute("data-range-slider-index", `${i}`);
378
+ this._sliderElementRefs[i].current.setAttribute("id", `rage-slider-${this.baseID}-${i}`);
379
+ }
380
+ }
381
+ /**
382
+ * To avoid too many sliders added on each click, check if the mouse was moved in the meantime (detect drag event).
383
+ *
384
+ * @returns
385
+ */
386
+ __containerMouseDownHandler() {
387
+ const _self = this;
388
+ return (event) => {
389
+ _self.__mouseDownPosition = { x: event.clientX, y: event.clientY };
390
+ // console.log("__containerMouseDownHandler _self.__mouseDownPosition", _self.__mouseDownPosition);
391
+ };
392
+ }
393
+ /**
394
+ * Creates a handler for click events on the container. If the click event is far
395
+ * enough from existing sliders, then it can be added.
396
+ *
397
+ * @returns
398
+ */
399
+ __containerClickHandler() {
400
+ const _self = this;
401
+ const maxDifference = _self.getRangeLength() * 0.03;
402
+ return (evt) => {
403
+ // console.log("Container click handler");
404
+ const relativeValue = _self.__clickEventToRelativeValue(evt);
405
+ if (relativeValue < 0 || relativeValue > 1.0) {
406
+ // Clicked somewhere outside the range
407
+ return;
408
+ }
409
+ // Check if element was moved in the meantime
410
+ if (_self.__mouseDownPosition && Math.abs(_self.__mouseDownPosition.x - evt.clientX) >= 10.0) {
411
+ // Ignore event if mouse was moved more than 10 pixels between down- and up-event
412
+ // console.log("Mouse was moved more than 10 px. Cancelling.");
413
+ _self.__mouseDownPosition = null;
414
+ return;
415
+ }
416
+ const absoluteValue = this.__relativeToAbsolute(relativeValue);
417
+ // console.log("click", "relativeValue", relativeValue, "absoluteValue", absoluteValue);
418
+ // Check if click position (ratio) is far enough away from any slider
419
+ const [leftSliderIndex, closestSliderValue] = _self.__locateClosestSliderValue(absoluteValue);
420
+ const diff = Math.abs(closestSliderValue - absoluteValue);
421
+ if (diff >= maxDifference) {
422
+ // console.log("Add slider here");
423
+ _self.__addSliderAt(absoluteValue, leftSliderIndex);
424
+ }
425
+ else {
426
+ // console.debug("Don't add slider here.");
427
+ }
428
+ // Finally clear mousedown-position
429
+ _self.__mouseDownPosition = null;
430
+ };
431
+ }
432
+ /**
433
+ * Find that slider (index) that's value is closest to the given absolute value. The function will return
434
+ * the closest value and the left index, indicating the containing interval index.
435
+ *
436
+ * @param {number} absoluteValue - The value to look for.
437
+ * @returns {[number,number]} A pair of left slider index and closest value.
438
+ */
439
+ __locateClosestSliderValue(absoluteValue) {
440
+ // As the colorGradient always reflects the slider values we can just ust the color gradient itself to search.
441
+ const relativeValue = this.__absoluteToRelative(absoluteValue);
442
+ const colorGradientEntry = this.colorGradient.locateClosestRatio(relativeValue);
443
+ return [colorGradientEntry[0], this.__relativeToAbsolute(colorGradientEntry[1].ratio)];
444
+ }
445
+ /**
446
+ * Convert the click event to the relative x value in [0..1].
447
+ *
448
+ * @param {MouseEvent} evt - The mouse event.
449
+ * @returns {number} The relative x value.
450
+ */
451
+ __clickEventToRelativeValue(evt) {
452
+ const target = evt.target;
453
+ const rect = target.getBoundingClientRect();
454
+ const x = evt.clientX - rect.left; //x position within the element.
455
+ const width = rect.width; // target.clientWidth;
456
+ const relativeValue = x / width;
457
+ // console.log("width", width, "x", x, "relativeValue", relativeValue);
458
+ return relativeValue;
459
+ }
460
+ /**
461
+ * Adds a slider at the given interval index.
462
+ *
463
+ * @param {number} absoluteValue - The absolute new slider value.
464
+ * @param {number} leftSliderIndex - The new slider's position (interval index).
465
+ */
466
+ __addSliderAt(absoluteValue, leftSliderIndex) {
467
+ // console.log("__addSliderAt", "absoluteValue", absoluteValue, "leftSliderIndex", leftSliderIndex);
468
+ const leftSlider = this._sliderElementRefs[leftSliderIndex].current;
469
+ // const colorAtPosition = this.__getSliderColorAt(relativeValue);
470
+ const newColor = this.__getSliderColorAt(absoluteValue);
471
+ const newSliderIndex = leftSliderIndex + 1;
472
+ const _newSlider = this.__createColorRangeInput(newSliderIndex, this.sliderMin, this.sliderMax, absoluteValue, newColor // initialColor: string
473
+ );
474
+ const sliderRef = this._sliderElementRefs[newSliderIndex];
475
+ leftSlider.after(sliderRef.current);
476
+ sliderRef.current.dataset.colorValue = newColor.cssRGB();
477
+ sliderRef.current.dataset.colorValueHEX = newColor.cssHEX();
478
+ // No visible change, but let's reflect this in the output gradient anyway
479
+ this.__updateBackgroundGradient();
480
+ // Highlight the newly added range slider
481
+ this.__updateColorIndicator(newSliderIndex);
482
+ this.__fireChangeEvent();
483
+ }
484
+ /**
485
+ * Get the slider color at the given absolute value. That value must be inside the [MIN_VALUE, MAX_VALUE] interval.
486
+ * @param absoluteValue
487
+ * @returns
488
+ */
489
+ __getSliderColorAt(absoluteValue) {
490
+ // console.log("__getSliderColorAt", "absoluteValue", absoluteValue);
491
+ // Locate interval
492
+ const leftIndex = this.__locateIntervalAt(absoluteValue);
493
+ const leftSliderValue = this.__getSliderValue(leftIndex, NaN);
494
+ const rightSliderValue = this.__getSliderValue(leftIndex + 1, NaN);
495
+ if (Number.isNaN(leftSliderValue) || Number.isNaN(rightSliderValue)) {
496
+ console.warn(`[Warn] Failed to determine left/right slider values at indices ${leftIndex} or ${rightSliderValue}. Cannot proceed for absolute value ${absoluteValue}.`);
497
+ return null;
498
+ }
499
+ const leftColorString = this.__getSliderColorString(leftIndex, null);
500
+ const rightColorString = this.__getSliderColorString(leftIndex + 1, null);
501
+ if (!leftColorString || !rightColorString) {
502
+ console.warn(`[Warn] Failed to determine left/right color string values at indices ${leftIndex} or ${rightSliderValue}. Cannot proceed for absolute value ${absoluteValue}.`);
503
+ return null;
504
+ }
505
+ const positionInsideInterval = (absoluteValue - leftSliderValue) / (rightSliderValue - leftSliderValue);
506
+ // console.log("leftColorString", leftColorString, "rightColorString", rightColorString);
507
+ const leftColorObject = Color.parse(leftColorString);
508
+ const rightColorObject = Color.parse(rightColorString);
509
+ const newColor = leftColorObject.interpolate(rightColorObject, positionInsideInterval);
510
+ return newColor;
511
+ }
512
+ /**
513
+ * Locate the slider interval that contains the given (absolute) slider value. The given value must be
514
+ * somewhere between MIN_VALUE and MAX_VALUE (usually between 0 and 100 in the default configuraion.).
515
+ *
516
+ * @param {number} absoluteValue - The absolute value to search for.
517
+ * @returns {number} The left slider inder the containing interval is starting with – or -1 if out of bounds.
518
+ */
519
+ __locateIntervalAt(absoluteValue) {
520
+ for (var i = 0; i + 1 < this._sliderElementRefs.length; i++) {
521
+ if (this.__getSliderValue(i, this.sliderMin) <= absoluteValue &&
522
+ absoluteValue < this.__getSliderValue(i + 1, this.sliderMax)) {
523
+ return i;
524
+ }
525
+ }
526
+ return -1;
527
+ }
528
+ /**
529
+ * Converts a relative value in [0..1] to [min..max].
530
+ * @param relativeValue
531
+ */
532
+ __relativeToAbsolute(relativeValue) {
533
+ return this.sliderMin + (this.sliderMax - this.sliderMin) * relativeValue;
534
+ }
535
+ /**
536
+ * Converts a relative value in [0..1] to [min..max].
537
+ * @param relativeValue
538
+ */
539
+ __absoluteToRelative(absolute) {
540
+ return (absolute - this.sliderMin) / (this.sliderMax - this.sliderMin);
541
+ }
542
+ /**
543
+ * Get the value of the n-th rangel slider.
544
+ *
545
+ * @param {number} sliderIndex
546
+ * @param {number} fallback
547
+ * @returns
548
+ */
549
+ __getSliderValue(sliderIndex, fallback) {
550
+ if (sliderIndex < 0 || sliderIndex >= this._sliderElementRefs.length) {
551
+ return fallback;
552
+ }
553
+ return Number.parseFloat(this._sliderElementRefs[sliderIndex].current.value);
554
+ }
555
+ /**
556
+ * Get all current slider values as an array.
557
+ * @returns
558
+ */
559
+ __getAllSliderValues() {
560
+ return this._sliderElementRefs.map((ref, index) => this.__getSliderValue(index, NaN));
561
+ }
562
+ /**
563
+ * Updates the container's background to display the configured color gradient.
564
+ *
565
+ * @private
566
+ */
567
+ __updateBackgroundGradient() {
568
+ // const colorGradient = this.getColorGradient();
569
+ this.colorGradient = new ColorGradient(this.__getAllSliderValues().map((sliderValue, sliderIndex) => ({
570
+ color: this.__getSliderColor(sliderIndex, null),
571
+ ratio: this.__absoluteToRelative(sliderValue)
572
+ })), this.colorGradient.angle);
573
+ this.containerRef.current.style["background"] = this.colorGradient.toColorGradientString();
574
+ }
575
+ /**
576
+ * After changes this function updates the color indicator button.
577
+ *
578
+ * @param {number} rangeSliderIndex - The new active slider index.
579
+ */
580
+ __updateColorIndicator(rangeSliderIndex) {
581
+ const colorValue = this.__getSliderColorHEXString(rangeSliderIndex, "#808080");
582
+ const ratio = this.__getSliderPercentage(rangeSliderIndex);
583
+ // Set left offset of color input container
584
+ this.colorInputContainerRef.current.style["left"] = `calc( ${ratio * 100}% + ${(1.0 - ratio) * this.css_indicatorWidth_num * 0.5}em - ${ratio * this.css_indicatorWidth_num * 0.5}em)`;
585
+ // Also set offset of colot input element (safari will open the native color dialog at this position)
586
+ this.colorInputRef.current.style["left"] = `calc( ${ratio * 100}% + ${(1.0 - ratio) * this.css_indicatorWidth_num * 0.5}em - ${ratio * this.css_indicatorWidth_num * 0.5}em)`;
587
+ this.colorIndicatorColorButtonRef.current.style["background-color"] = colorValue;
588
+ this.colorInputRef.current.value = colorValue;
589
+ // console.log("Setting new color value", this.colorInputRef.current.value, colorValue);
590
+ this.colorInputRef.current.dataset.activeSliderIndex = `${rangeSliderIndex}`;
591
+ if (rangeSliderIndex <= 0 || rangeSliderIndex + 1 >= this._sliderElementRefs.length) {
592
+ this.colorIndicatorRemoveButtonRef.current.style["visibility"] = "hidden";
593
+ }
594
+ else {
595
+ this.colorIndicatorRemoveButtonRef.current.style["visibility"] = "visible";
596
+ }
597
+ }
598
+ /**
599
+ * Get a color gradient CSS value string from the current editor settings.
600
+ *
601
+ * @instance
602
+ * @memberof ColorGradientPicker
603
+ * @returns {ColorGradient}
604
+ */
605
+ getColorGradient() {
606
+ return this.colorGradient;
607
+ }
608
+ /**
609
+ * Get the configured color value of the n-th rangel slider.
610
+ *
611
+ * @param {number} sliderIndex
612
+ * @param {string} fallback
613
+ * @returns
614
+ */
615
+ __getSliderColorString(sliderIndex, fallback) {
616
+ if (sliderIndex < 0 || sliderIndex >= this._sliderElementRefs.length) {
617
+ return fallback;
618
+ }
619
+ const colorValue = this._sliderElementRefs[sliderIndex].current.dataset.colorValue;
620
+ return colorValue ? colorValue : fallback;
621
+ }
622
+ /**
623
+ * Get the configured color value of the n-th rangel slider.
624
+ *
625
+ * @param {number} sliderIndex
626
+ * @param {string} fallback
627
+ * @returns
628
+ */
629
+ __getSliderColorHEXString(sliderIndex, fallback) {
630
+ if (sliderIndex < 0 || sliderIndex >= this._sliderElementRefs.length) {
631
+ return fallback;
632
+ }
633
+ const colorValue = this._sliderElementRefs[sliderIndex].current.dataset.colorValueHEX;
634
+ return colorValue ? colorValue : fallback;
635
+ }
636
+ /**
637
+ * Get get color of this gradient picker at the given slider index.
638
+ *
639
+ * @param {number} sliderIndex - The index to get the slider color from. Something between 0 and _sliderElementRefs.length.
640
+ * @param {Color} fallback
641
+ * @returns
642
+ */
643
+ __getSliderColor(sliderIndex, fallback) {
644
+ if (sliderIndex < 0 || sliderIndex >= this._sliderElementRefs.length) {
645
+ return fallback;
646
+ }
647
+ const colorValueString = this._sliderElementRefs[sliderIndex].current.dataset["colorValue"];
648
+ const colorValue = Color.parse(colorValueString);
649
+ return colorValue ? colorValue : fallback;
650
+ }
651
+ /**
652
+ * Get the slider's value in a mapped range of 0.0 ... 1.0.
653
+ *
654
+ * @param sliderIndex
655
+ * @returns
656
+ */
657
+ __getSliderPercentage(sliderIndex) {
658
+ const sliderValue = this.__getSliderValue(sliderIndex, 0.0);
659
+ const percentage = (this.sliderMin + sliderValue) / (this.sliderMax - this.sliderMin);
660
+ return percentage;
661
+ }
662
+ /**
663
+ * Init the container contents.
664
+ *
665
+ * @private
666
+ */
667
+ _render() {
668
+ const _self = this;
669
+ // console.log("Rendering ...", NoReact);
670
+ this._sliderElementRefs = [];
671
+ this.colorIndicatorColorButtonRef = NoReact.useRef();
672
+ this.colorIndicatorRemoveButtonRef = NoReact.useRef();
673
+ this.colorInputRef = NoReact.useRef();
674
+ this.colorInputContainerRef = NoReact.useRef();
675
+ this.containerRef = NoReact.useRef();
676
+ /**
677
+ * This helper method is called when the tiny color button below the active slider is clicked. The method
678
+ * triggers the colorInput dialog to be triggered.
679
+ *
680
+ * @param {Event} evt
681
+ */
682
+ const handleIndicatorButtonClick = (evt) => {
683
+ evt.preventDefault(); // Prevent other inputs to react to this event.
684
+ evt.stopPropagation();
685
+ // But fake a click on the input element
686
+ // console.log("Current selected color: " + _self.colorInputRef.current.value);
687
+ _self.colorInputRef.current.click();
688
+ };
689
+ /**
690
+ * This helper method is called when the remove-color button is clicked. It removes the
691
+ * currently active color slider – if possible (leftmost and rightmost slider cannot be removed).
692
+ * @param evt
693
+ */
694
+ const handleRemoveColorButtonClick = (evt) => {
695
+ evt.preventDefault(); // Prevent other inputs to react to this event.
696
+ evt.stopPropagation();
697
+ _self.__handleRemoveColor();
698
+ };
699
+ return (NoReact.createElement("div", { id: this.elementID, style: {
700
+ d: "flex",
701
+ fd: "column",
702
+ w: "100%",
703
+ h: this.css_containerHeight,
704
+ pos: "relative",
705
+ mb: this.isMobileMode ? "5em" : "3em"
706
+ }, ref: this.containerRef, onMouseDown: this.__containerMouseDownHandler(), onClick: this.__containerClickHandler() },
707
+ this.colorGradient.values.map((colorGradientItem, index) => {
708
+ const initialValue = _self.__relativeToAbsolute(colorGradientItem.ratio);
709
+ return this.__createColorRangeInput(index, this.sliderMin, this.sliderMax, initialValue, colorGradientItem.color);
710
+ }),
711
+ NoReact.createElement("div", { style: { w: "100%" } },
712
+ NoReact.createElement("input", { id: `color-indicator-input-${this.baseID}`, type: "color", style: { v: "hidden", pos: "absolute", l: 0 },
713
+ // data-active-slider-index=""
714
+ ref: this.colorInputRef, onInput: this.__colorChangeHandler() }),
715
+ NoReact.createElement("div", { ref: this.colorInputContainerRef, style: {
716
+ pos: "absolute",
717
+ b: "0px",
718
+ l: "0%",
719
+ d: "flex",
720
+ fd: "column",
721
+ transform: "translate(0%, 100%)"
722
+ } },
723
+ NoReact.createElement("button", { id: `color-indicator-button-${this.baseID}`, className: "color-indicator-button", style: {
724
+ backgroundColor: "grey",
725
+ borderRadius: "50%",
726
+ border: "1px solid grey",
727
+ w: this.css_indicatorWidth, // "1em",
728
+ h: this.css_indicatorHeight, // "1em",
729
+ transform: "translate(-50%, 0%)"
730
+ }, onClick: handleIndicatorButtonClick, ref: this.colorIndicatorColorButtonRef }),
731
+ NoReact.createElement("button", { id: `color-remove-button-${this.baseID}`, className: "color-remove-button", style: {
732
+ borderRadius: "10%",
733
+ border: "1px solid grey",
734
+ w: this.css_indicatorWidth, // "1em",
735
+ h: this.css_indicatorHeight, // "1em",
736
+ transform: "translate(-50%, 50%)",
737
+ lineHeight: "0.5em",
738
+ p: 0
739
+ }, onClick: handleRemoveColorButtonClick, ref: this.colorIndicatorRemoveButtonRef },
740
+ NoReact.createElement("span", { style: { fontSize: this.isMobileMode ? "1.0em" : "0.5em" } }, "\uD83D\uDDD1"))))));
741
+ } // END function render()
742
+ }
743
+ //# sourceMappingURL=ColorGradientPicker.js.map