plotboilerplate 1.24.0 → 1.25.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 (141) hide show
  1. package/README.md +13 -1
  2. package/dist/index.esm.js +294 -129
  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 +12084 -11919
  9. package/dist/plotboilerplate.min.js +1 -1
  10. package/package.json +9 -5
  11. package/src/cjs/PlotBoilerplate.d.ts +37 -6
  12. package/src/cjs/PlotBoilerplate.js +222 -116
  13. package/src/cjs/PlotBoilerplate.js.map +1 -1
  14. package/src/cjs/Polygon.d.ts +26 -7
  15. package/src/cjs/Polygon.js +56 -10
  16. package/src/cjs/Polygon.js.map +1 -1
  17. package/src/cjs/Triangle.js +2 -2
  18. package/src/cjs/Triangle.js.map +1 -1
  19. package/src/cjs/Vertex.d.ts +15 -3
  20. package/src/cjs/Vertex.js +18 -1
  21. package/src/cjs/Vertex.js.map +1 -1
  22. package/src/cjs/interfaces/core.d.ts +28 -0
  23. package/src/cjs/interfaces/core.js +2 -0
  24. package/src/cjs/interfaces/core.js.map +1 -1
  25. package/src/cjs/utils/datastructures/Color.d.ts +147 -1
  26. package/src/cjs/utils/datastructures/Color.js +385 -41
  27. package/src/cjs/utils/datastructures/Color.js.map +1 -1
  28. package/src/cjs/utils/datastructures/ColorGradient.d.ts +79 -0
  29. package/src/cjs/utils/datastructures/ColorGradient.js +171 -0
  30. package/src/cjs/utils/datastructures/ColorGradient.js.map +1 -0
  31. package/src/cjs/utils/dom/components/ColorGradientPicker.d.ts +245 -0
  32. package/src/cjs/utils/dom/components/ColorGradientPicker.js +667 -0
  33. package/src/cjs/utils/dom/components/ColorGradientPicker.js.map +1 -0
  34. package/src/cjs/utils/dom/components/ColorGradientPickerJSX.d.ts +129 -0
  35. package/src/cjs/utils/dom/components/ColorGradientPickerJSX.js +520 -0
  36. package/src/cjs/utils/dom/components/ColorGradientPickerJSX.js.map +1 -0
  37. package/src/cjs/utils/dom/components/ColorGradientSelector.d.ts +117 -0
  38. package/src/cjs/utils/dom/components/ColorGradientSelector.js +325 -0
  39. package/src/cjs/utils/dom/components/ColorGradientSelector.js.map +1 -0
  40. package/src/cjs/utils/dom/components/Test.d.ts +7 -0
  41. package/src/cjs/utils/dom/components/Test.js +30 -0
  42. package/src/cjs/utils/dom/components/Test.js.map +1 -0
  43. package/src/cjs/utils/dom/guiSizeToggler.js +1 -1
  44. package/src/cjs/utils/dom/guiSizeToggler.js.map +1 -1
  45. package/src/cjs/utils/helpers/BezierPathInteractionHelper.d.ts +9 -3
  46. package/src/cjs/utils/helpers/BezierPathInteractionHelper.js +20 -13
  47. package/src/cjs/utils/helpers/BezierPathInteractionHelper.js.map +1 -1
  48. package/src/cjs/utils/helpers/CircleHelper.d.ts +10 -1
  49. package/src/cjs/utils/helpers/CircleHelper.js +13 -2
  50. package/src/cjs/utils/helpers/CircleHelper.js.map +1 -1
  51. package/src/cjs/utils/helpers/CircleSectorHelper.d.ts +2 -2
  52. package/src/cjs/utils/helpers/CircleSectorHelper.js +1 -0
  53. package/src/cjs/utils/helpers/CircleSectorHelper.js.map +1 -1
  54. package/src/cjs/utils/helpers/TriangleHelper.d.ts +57 -0
  55. package/src/cjs/utils/helpers/TriangleHelper.js +83 -0
  56. package/src/cjs/utils/helpers/TriangleHelper.js.map +1 -0
  57. package/src/cjs/utils/helpers/VEllipseHelper.d.ts +6 -4
  58. package/src/cjs/utils/helpers/VEllipseHelper.js +4 -2
  59. package/src/cjs/utils/helpers/VEllipseHelper.js.map +1 -1
  60. package/src/cjs/utils/helpers/VEllipseSectorHelper.d.ts +3 -2
  61. package/src/cjs/utils/helpers/VEllipseSectorHelper.js +1 -0
  62. package/src/cjs/utils/helpers/VEllipseSectorHelper.js.map +1 -1
  63. package/src/cjs/utils/parsers/LinearColorGradientParser.d.ts +78 -0
  64. package/src/cjs/utils/parsers/LinearColorGradientParser.js +224 -0
  65. package/src/cjs/utils/parsers/LinearColorGradientParser.js.map +1 -0
  66. package/src/createDemoDrawables.js +1 -0
  67. package/src/esm/PlotBoilerplate.d.ts +37 -6
  68. package/src/esm/PlotBoilerplate.js +222 -116
  69. package/src/esm/PlotBoilerplate.js.map +1 -1
  70. package/src/esm/Polygon.d.ts +26 -7
  71. package/src/esm/Polygon.js +53 -10
  72. package/src/esm/Polygon.js.map +1 -1
  73. package/src/esm/Triangle.js +2 -2
  74. package/src/esm/Triangle.js.map +1 -1
  75. package/src/esm/Vertex.d.ts +15 -3
  76. package/src/esm/Vertex.js +18 -1
  77. package/src/esm/Vertex.js.map +1 -1
  78. package/src/esm/interfaces/core.d.ts +28 -0
  79. package/src/esm/interfaces/core.js +2 -0
  80. package/src/esm/interfaces/core.js.map +1 -1
  81. package/src/esm/utils/datastructures/Color.d.ts +147 -1
  82. package/src/esm/utils/datastructures/Color.js +386 -42
  83. package/src/esm/utils/datastructures/Color.js.map +1 -1
  84. package/src/esm/utils/datastructures/ColorGradient.d.ts +79 -0
  85. package/src/esm/utils/datastructures/ColorGradient.js +166 -0
  86. package/src/esm/utils/datastructures/ColorGradient.js.map +1 -0
  87. package/src/esm/utils/dom/components/ColorGradientPicker.d.ts +245 -0
  88. package/src/esm/utils/dom/components/ColorGradientPicker.js +732 -0
  89. package/src/esm/utils/dom/components/ColorGradientPicker.js.map +1 -0
  90. package/src/esm/utils/dom/components/ColorGradientPickerJSX.d.ts +129 -0
  91. package/src/esm/utils/dom/components/ColorGradientPickerJSX.js +582 -0
  92. package/src/esm/utils/dom/components/ColorGradientPickerJSX.js.map +1 -0
  93. package/src/esm/utils/dom/components/ColorGradientSelector.d.ts +117 -0
  94. package/src/esm/utils/dom/components/ColorGradientSelector.js +332 -0
  95. package/src/esm/utils/dom/components/ColorGradientSelector.js.map +1 -0
  96. package/src/esm/utils/dom/components/Test.d.ts +7 -0
  97. package/src/esm/utils/dom/components/Test.js +26 -0
  98. package/src/esm/utils/dom/components/Test.js.map +1 -0
  99. package/src/esm/utils/dom/guiSizeToggler.js +1 -1
  100. package/src/esm/utils/dom/guiSizeToggler.js.map +1 -1
  101. package/src/esm/utils/helpers/BezierPathInteractionHelper.d.ts +9 -3
  102. package/src/esm/utils/helpers/BezierPathInteractionHelper.js +20 -13
  103. package/src/esm/utils/helpers/BezierPathInteractionHelper.js.map +1 -1
  104. package/src/esm/utils/helpers/CircleHelper.d.ts +10 -1
  105. package/src/esm/utils/helpers/CircleHelper.js +13 -2
  106. package/src/esm/utils/helpers/CircleHelper.js.map +1 -1
  107. package/src/esm/utils/helpers/CircleSectorHelper.d.ts +2 -2
  108. package/src/esm/utils/helpers/CircleSectorHelper.js +1 -0
  109. package/src/esm/utils/helpers/CircleSectorHelper.js.map +1 -1
  110. package/src/esm/utils/helpers/TriangleHelper.d.ts +57 -0
  111. package/src/esm/utils/helpers/TriangleHelper.js +78 -0
  112. package/src/esm/utils/helpers/TriangleHelper.js.map +1 -0
  113. package/src/esm/utils/helpers/VEllipseHelper.d.ts +6 -4
  114. package/src/esm/utils/helpers/VEllipseHelper.js +4 -2
  115. package/src/esm/utils/helpers/VEllipseHelper.js.map +1 -1
  116. package/src/esm/utils/helpers/VEllipseSectorHelper.d.ts +3 -2
  117. package/src/esm/utils/helpers/VEllipseSectorHelper.js +1 -0
  118. package/src/esm/utils/helpers/VEllipseSectorHelper.js.map +1 -1
  119. package/src/esm/utils/parsers/LinearColorGradientParser.d.ts +78 -0
  120. package/src/esm/utils/parsers/LinearColorGradientParser.js +217 -0
  121. package/src/esm/utils/parsers/LinearColorGradientParser.js.map +1 -0
  122. package/src/external.d.ts +9 -0
  123. package/src/ts/PlotBoilerplate.ts +233 -105
  124. package/src/ts/Polygon.ts +68 -14
  125. package/src/ts/Triangle.ts +2 -2
  126. package/src/ts/Vertex.ts +21 -3
  127. package/src/ts/interfaces/core.ts +31 -0
  128. package/src/ts/utils/datastructures/Color.ts +423 -44
  129. package/src/ts/utils/datastructures/ColorGradient.ts +196 -0
  130. package/src/ts/utils/dom/components/ColorGradientPicker.tsx +877 -0
  131. package/src/ts/utils/dom/components/ColorGradientSelector.tsx +445 -0
  132. package/src/ts/utils/dom/components/Test.tsx +44 -0
  133. package/src/ts/utils/dom/components/_ColorGradientPicker_raw.ts_ +392 -0
  134. package/src/ts/utils/dom/guiSizeToggler.ts +1 -1
  135. package/src/ts/utils/helpers/BezierPathInteractionHelper.ts +25 -15
  136. package/src/ts/utils/helpers/CircleHelper.ts +17 -3
  137. package/src/ts/utils/helpers/CircleSectorHelper.ts +4 -2
  138. package/src/ts/utils/helpers/TriangleHelper.ts +102 -0
  139. package/src/ts/utils/helpers/VEllipseHelper.ts +6 -4
  140. package/src/ts/utils/helpers/VEllipseSectorHelper.ts +3 -2
  141. package/src/ts/utils/parsers/LinearColorGradientParser.ts +297 -0
@@ -0,0 +1,117 @@
1
+ /**
2
+ * A simple class for rendering color gradient dropdowns.
3
+ *
4
+ * As native dropdown do not support custom stylings in the way we need, we will implement
5
+ * our own dropdown class.
6
+ *
7
+ * @author Ikaros Kappler
8
+ * @date 2025-08-19
9
+ * @version 1.0.0
10
+ */
11
+ import { ColorGradient } from "../../datastructures/ColorGradient";
12
+ export type ColorGradientSelectorChangeListener = (colorGradient: ColorGradient, gradientIndex: number, source: ColorGradientSelector) => void;
13
+ /**
14
+ * The initial properties to use.
15
+ */
16
+ export interface ColorGradientSelectorProps {
17
+ containerID?: string;
18
+ initialGradients?: Array<ColorGradient>;
19
+ selectedGradientIndex?: number;
20
+ isMobileMode?: boolean;
21
+ }
22
+ export declare class ColorGradientSelector {
23
+ private readonly baseID;
24
+ private readonly elementID;
25
+ private container;
26
+ private containerRef;
27
+ private mainButtonContainerRef;
28
+ private positioningContainerRef;
29
+ private isMobileMode;
30
+ private isDropdownOpen;
31
+ private css_buttonWidth;
32
+ private css_buttonHeight;
33
+ private css_buttonFontSize;
34
+ private colorGradients;
35
+ private colorGradientOptionRefs;
36
+ private selectedGradientIndex;
37
+ private readonly installedChangeListeners;
38
+ static readonly DEFAULT_COLOR_GRADIENTS: Array<ColorGradient>;
39
+ /**
40
+ * The constructor: creates a new color gradient picker in the given container.
41
+ * If no container or ID is given then a new unbound `container` will be created (DIV).
42
+ *
43
+ * Pass a container ID or nothing – in the latter case the constructor will create
44
+ * a new DIV element.
45
+ *
46
+ * @param {string?} containerID - (optional) If you want to use an existing container (should be a DIV).
47
+ */
48
+ constructor(options?: ColorGradientSelectorProps);
49
+ setGradients(gradients: Array<ColorGradient>, selectedIndex: number): void;
50
+ addGradient(gradient: ColorGradient): void;
51
+ private __removeAllChildNodes;
52
+ /**
53
+ * Adds a new color gradient change listener to this ColorGradientPicker.
54
+ *
55
+ * @param {ColorGradientChangeListener} listener - The listener to add.
56
+ * @returns {boolean} True, if the listener was added and did not exist before.
57
+ */
58
+ addChangeListener(listener: ColorGradientSelectorChangeListener): boolean;
59
+ /**
60
+ *
61
+ * @param {ColorGradientChangeListener} listener The listener to remove.
62
+ * @returns {boolean} True, if the listener existed and has been removed.
63
+ */
64
+ removeChangeListener(listener: ColorGradientSelectorChangeListener): boolean;
65
+ getSelectedColorGradient(): ColorGradient;
66
+ private __fireChangeEvent;
67
+ /**
68
+ * Creates a handler for click events on the main button.
69
+ *
70
+ * @returns
71
+ */
72
+ private __mainButtonClickHandler;
73
+ /**
74
+ * Creates a handler for click events on one of the option button in the dropdown.
75
+ *
76
+ * @returns
77
+ */
78
+ private __optionButtonClickHandler;
79
+ private __optionButtonDeleteHandler;
80
+ /**
81
+ * Once a slider element was added or removed then the following indices must be updated.
82
+ *
83
+ * @param {number} startIndex - The slider index to start updating at.
84
+ */
85
+ __updateOptionDataSetIndices(startIndex: number): void;
86
+ private __setSelectedIndex;
87
+ /**
88
+ * Sets the backround color of the main button (of this dropdown) element.
89
+ *
90
+ * @param {ColorGradient} gradient - The gradient color to display. Must not be null.
91
+ */
92
+ private __setMainButtonGradient;
93
+ /**
94
+ * Renders a new option button for the dropdown menu.
95
+ *
96
+ * @param {ColorGradient} gradient
97
+ * @returns {JsxElement}
98
+ */
99
+ private __renderOptionButton;
100
+ /**
101
+ * Creates a new array of option buttons (refs).
102
+ * @returns
103
+ */
104
+ private _renderAllOptionButtons;
105
+ /**
106
+ * Init the container contents.
107
+ *
108
+ * @private
109
+ */
110
+ private _render;
111
+ /**
112
+ * Adds custom styles (global STYLE tag).
113
+ *
114
+ * @private
115
+ */
116
+ private __createCustomStylesElement;
117
+ }
@@ -0,0 +1,332 @@
1
+ /**
2
+ * A simple class for rendering color gradient dropdowns.
3
+ *
4
+ * As native dropdown do not support custom stylings in the way we need, we will implement
5
+ * our own dropdown class.
6
+ *
7
+ * @author Ikaros Kappler
8
+ * @date 2025-08-19
9
+ * @version 1.0.0
10
+ */
11
+ import * as NoReact from "noreact";
12
+ import { Color } from "../../datastructures/Color";
13
+ import { ColorGradient } from "../../datastructures/ColorGradient";
14
+ export class ColorGradientSelector {
15
+ /**
16
+ * The constructor: creates a new color gradient picker in the given container.
17
+ * If no container or ID is given then a new unbound `container` will be created (DIV).
18
+ *
19
+ * Pass a container ID or nothing – in the latter case the constructor will create
20
+ * a new DIV element.
21
+ *
22
+ * @param {string?} containerID - (optional) If you want to use an existing container (should be a DIV).
23
+ */
24
+ constructor(options) {
25
+ this.isDropdownOpen = false;
26
+ this.css_buttonWidth = "100px";
27
+ this.css_buttonHeight = "1.8em";
28
+ this.css_buttonFontSize = "0.725em";
29
+ this.colorGradients = [];
30
+ // TODO: this does not really need to be a pair, does it?
31
+ this.colorGradientOptionRefs = [];
32
+ this.selectedGradientIndex = -1;
33
+ this.installedChangeListeners = [];
34
+ /**
35
+ * Adds custom styles (global STYLE tag).
36
+ *
37
+ * @private
38
+ */
39
+ this.__createCustomStylesElement = () => {
40
+ // Thanks to Ana Tudor
41
+ // https://css-tricks.com/multi-thumb-sliders-particular-two-thumb-case/
42
+ return (NoReact.createElement("style", null, `
43
+
44
+ #${this.elementID} button {
45
+ border: 0px solid lightgray;
46
+ padding: 0.25em;
47
+ background-color: rgba(255,255,255,0.9);
48
+ }
49
+
50
+ #${this.elementID} .main-button:hover {
51
+ background-color: rgba(216,216,216,0.9);
52
+ }
53
+
54
+ #${this.elementID} .option-gradient-button:hover, #${this.elementID} .option-delete-button:hover {
55
+ background-color: rgba(216,216,216,0.9);
56
+ }
57
+
58
+ `));
59
+ };
60
+ options = options || {};
61
+ if (options.containerID) {
62
+ const cont = document.getElementById(options.containerID);
63
+ if (!cont) {
64
+ throw "Cannot create ColorGradientPicker. Component ID does not exist.";
65
+ }
66
+ this.container = cont;
67
+ }
68
+ else {
69
+ this.container = document.createElement("div");
70
+ }
71
+ this.isMobileMode = Boolean(options.isMobileMode);
72
+ if (this.isMobileMode) {
73
+ this.css_buttonWidth = "200px";
74
+ this.css_buttonHeight = "2.5em";
75
+ this.css_buttonFontSize = "1.25em";
76
+ }
77
+ this.baseID = Math.floor(Math.random() * 65535);
78
+ this.elementID = `color-gradient-selector-${this.baseID}`;
79
+ this.colorGradients =
80
+ typeof options.initialGradients === "undefined" ? ColorGradientSelector.DEFAULT_COLOR_GRADIENTS : options.initialGradients;
81
+ this.selectedGradientIndex = typeof options.selectedGradientIndex === "undefined" ? 0 : options.selectedGradientIndex;
82
+ document.head.appendChild(this.__createCustomStylesElement());
83
+ this.container.append(this._render());
84
+ } // END constructor
85
+ // TODO: implement this?
86
+ setGradients(gradients, selectedIndex) {
87
+ // First empty the container
88
+ this.__removeAllChildNodes(this.positioningContainerRef.current);
89
+ this.colorGradients = [];
90
+ this.colorGradientOptionRefs = [];
91
+ this.selectedGradientIndex = selectedIndex;
92
+ // Re-render button array
93
+ gradients.map((grad) => {
94
+ this.addGradient(grad);
95
+ });
96
+ }
97
+ addGradient(gradient) {
98
+ // Render a new button
99
+ const index = this.colorGradients.length;
100
+ const refMainContainer = NoReact.useRef();
101
+ const refActionButton = NoReact.useRef();
102
+ const refDeleteButton = NoReact.useRef();
103
+ this.__renderOptionButton(gradient, index, refMainContainer, refActionButton, refDeleteButton);
104
+ this.colorGradients.push(gradient);
105
+ this.colorGradientOptionRefs.push({ mainButton: refActionButton, deleteButton: refDeleteButton });
106
+ // Add to container
107
+ this.positioningContainerRef.current.appendChild(refMainContainer.current);
108
+ }
109
+ // +---------------------------------------------------------------------------------
110
+ // | A helper function to remove all child nodes.
111
+ // +-------------------------------
112
+ __removeAllChildNodes(node) {
113
+ while (node.lastChild) {
114
+ node.removeChild(node.lastChild);
115
+ }
116
+ }
117
+ /**
118
+ * Adds a new color gradient change listener to this ColorGradientPicker.
119
+ *
120
+ * @param {ColorGradientChangeListener} listener - The listener to add.
121
+ * @returns {boolean} True, if the listener was added and did not exist before.
122
+ */
123
+ addChangeListener(listener) {
124
+ for (var i = 0; i < this.installedChangeListeners.length; i++) {
125
+ if (this.installedChangeListeners[i] === listener) {
126
+ return false;
127
+ }
128
+ }
129
+ this.installedChangeListeners.push(listener);
130
+ return true;
131
+ }
132
+ /**
133
+ *
134
+ * @param {ColorGradientChangeListener} listener The listener to remove.
135
+ * @returns {boolean} True, if the listener existed and has been removed.
136
+ */
137
+ removeChangeListener(listener) {
138
+ for (var i = 0; i < this.installedChangeListeners.length; i++) {
139
+ if (this.installedChangeListeners[i] === listener) {
140
+ this.installedChangeListeners.splice(i, 1);
141
+ return true;
142
+ }
143
+ }
144
+ return false;
145
+ }
146
+ getSelectedColorGradient() {
147
+ return this.colorGradients[this.selectedGradientIndex];
148
+ }
149
+ __fireChangeEvent() {
150
+ const newColorGradient = this.getSelectedColorGradient();
151
+ for (var i = 0; i < this.installedChangeListeners.length; i++) {
152
+ this.installedChangeListeners[i](newColorGradient, this.selectedGradientIndex, this);
153
+ }
154
+ }
155
+ /**
156
+ * Creates a handler for click events on the main button.
157
+ *
158
+ * @returns
159
+ */
160
+ __mainButtonClickHandler() {
161
+ const _self = this;
162
+ return (_evt) => {
163
+ // _self.mainButtonContainerRef.current.style.visibility = "hidden";
164
+ _self.positioningContainerRef.current.style.visibility = _self.isDropdownOpen ? "hidden" : "visible";
165
+ _self.isDropdownOpen = !_self.isDropdownOpen;
166
+ };
167
+ }
168
+ /**
169
+ * Creates a handler for click events on one of the option button in the dropdown.
170
+ *
171
+ * @returns
172
+ */
173
+ __optionButtonClickHandler() {
174
+ const _self = this;
175
+ return (evt) => {
176
+ _self.positioningContainerRef.current.style.visibility = "hidden";
177
+ _self.isDropdownOpen = false;
178
+ const targetButton = evt.currentTarget;
179
+ const clickedIndex_raw = targetButton.dataset["gradientIndex"];
180
+ const clickedIndex = Number.parseInt(clickedIndex_raw);
181
+ console.log("clickedIndex", clickedIndex, clickedIndex_raw, targetButton.dataset, targetButton);
182
+ if (Number.isNaN(clickedIndex)) {
183
+ // Stop here. This is not what we want.
184
+ return;
185
+ }
186
+ // Find child: and set selected.
187
+ _self.__setSelectedIndex(clickedIndex);
188
+ _self.__fireChangeEvent();
189
+ };
190
+ }
191
+ __optionButtonDeleteHandler() {
192
+ const _self = this;
193
+ return (evt) => {
194
+ if (this.colorGradientOptionRefs.length === 1) {
195
+ // Keep the last record
196
+ return;
197
+ }
198
+ const targetButton = evt.currentTarget;
199
+ const clickedIndex_raw = targetButton.dataset["gradientIndex"];
200
+ const clickedIndex = Number.parseInt(clickedIndex_raw);
201
+ console.log("clickedIndex", clickedIndex, clickedIndex_raw, targetButton.dataset, targetButton);
202
+ if (Number.isNaN(clickedIndex)) {
203
+ // Stop here. This is not what we want.
204
+ return;
205
+ }
206
+ // Find child: and remove from DOM
207
+ console.log("this.colorGradientOptionRefs", this.colorGradientOptionRefs, "clickedIndex", clickedIndex);
208
+ const refPair = this.colorGradientOptionRefs[clickedIndex];
209
+ refPair.mainButton.current.parentElement.remove();
210
+ // Remove from logic
211
+ // Remove 1 element at the given index
212
+ this.colorGradients.splice(clickedIndex, 1);
213
+ this.colorGradientOptionRefs.splice(clickedIndex, 1);
214
+ // Update all following elements in the list.
215
+ this.__updateOptionDataSetIndices(clickedIndex);
216
+ if (this.selectedGradientIndex >= clickedIndex) {
217
+ // this.selectedGradientIndex--;
218
+ this.__setSelectedIndex(this.selectedGradientIndex);
219
+ }
220
+ console.log("All refs", this.colorGradientOptionRefs);
221
+ };
222
+ }
223
+ /**
224
+ * Once a slider element was added or removed then the following indices must be updated.
225
+ *
226
+ * @param {number} startIndex - The slider index to start updating at.
227
+ */
228
+ __updateOptionDataSetIndices(startIndex) {
229
+ // Update all elements to the right of the new elelemt
230
+ for (var i = startIndex; i < this.colorGradientOptionRefs.length; i++) {
231
+ this.colorGradientOptionRefs[i].mainButton.current.dataset["gradientIndex"] = `${i}`;
232
+ this.colorGradientOptionRefs[i].deleteButton.current.dataset["gradientIndex"] = `${i}`;
233
+ }
234
+ }
235
+ __setSelectedIndex(newSelectedIndex) {
236
+ for (var i = 0; i < this.colorGradientOptionRefs.length; i++) {
237
+ const ref = this.colorGradientOptionRefs[i].mainButton;
238
+ // Find child: and set selected.
239
+ ref.current.querySelectorAll(".option-gradient-radio-circle")[0].innerHTML = newSelectedIndex === i ? "🞊" : "🞅";
240
+ }
241
+ this.selectedGradientIndex = newSelectedIndex;
242
+ const selectedGradient = this.colorGradients[this.selectedGradientIndex];
243
+ // Display new gradient in the main button
244
+ this.__setMainButtonGradient(selectedGradient);
245
+ }
246
+ /**
247
+ * Sets the backround color of the main button (of this dropdown) element.
248
+ *
249
+ * @param {ColorGradient} gradient - The gradient color to display. Must not be null.
250
+ */
251
+ __setMainButtonGradient(gradient) {
252
+ const colorDisplay = this.mainButtonContainerRef.current.querySelectorAll(".main-button-gradient-display")[0];
253
+ colorDisplay.style["background"] = gradient.toColorGradientString();
254
+ }
255
+ /**
256
+ * Renders a new option button for the dropdown menu.
257
+ *
258
+ * @param {ColorGradient} gradient
259
+ * @returns {JsxElement}
260
+ */
261
+ __renderOptionButton(gradient, index, refMainContainer, refActionButton, refDelButton) {
262
+ return (NoReact.createElement("div", { sx: { d: "flex", flexDirection: "row" }, ref: refMainContainer },
263
+ NoReact.createElement("button", { className: "option-gradient-button", onClick: this.__optionButtonClickHandler(), style: {
264
+ d: "flex",
265
+ w: "100%",
266
+ fontSize: this.css_buttonFontSize,
267
+ minHeight: this.css_buttonHeight,
268
+ maxHeight: this.css_buttonHeight
269
+ }, ref: refActionButton, "data-gradientIndex": `${index}` },
270
+ NoReact.createElement("div", { className: "option-gradient-radio-circle", sx: { w: "2em", flexShrink: 2, alignContent: "center" } }, index === 0 ? "🞊" : "🞅"),
271
+ NoReact.createElement("div", { sx: { w: "calc( 100% - 2em )", mr: "1em", background: gradient.toColorGradientString() } }, "\u00A0")),
272
+ NoReact.createElement("button", { classname: "option-delete-button", sx: { fontSize: this.css_buttonFontSize, minHeight: this.css_buttonHeight, maxHeight: this.css_buttonHeight }, onClick: this.__optionButtonDeleteHandler(), "data-gradientIndex": `${index}`, ref: refDelButton },
273
+ NoReact.createElement("div", { sx: { w: "2em", flexShrink: 2, alignContent: "center" } }, "\uD83D\uDDD1"))));
274
+ }
275
+ /**
276
+ * Creates a new array of option buttons (refs).
277
+ * @returns
278
+ */
279
+ _renderAllOptionButtons() {
280
+ const _self = this;
281
+ // First clear all references
282
+ _self.colorGradientOptionRefs = [];
283
+ return this.colorGradients.map((colorGradient, index) => {
284
+ // console.log("num", num, index);
285
+ const refMainContainer = NoReact.useRef();
286
+ const refActionButton = NoReact.useRef();
287
+ const refDelButton = NoReact.useRef();
288
+ _self.colorGradientOptionRefs.push({ mainButton: refActionButton, deleteButton: refDelButton });
289
+ return this.__renderOptionButton(colorGradient, index, refMainContainer, refActionButton, refDelButton);
290
+ });
291
+ }
292
+ /**
293
+ * Init the container contents.
294
+ *
295
+ * @private
296
+ */
297
+ _render() {
298
+ const _self = this;
299
+ // console.log("Rendering ...", NoReact);
300
+ this.containerRef = NoReact.useRef();
301
+ this.mainButtonContainerRef = NoReact.useRef();
302
+ this.positioningContainerRef = NoReact.useRef();
303
+ const selectedGradient = this.colorGradients[this.selectedGradientIndex];
304
+ return (NoReact.createElement("div", { id: this.elementID, className: "color-gradient-selector", style: { minWidth: this.css_buttonWidth, maxWidth: this.css_buttonWidth, pos: "relative" }, ref: this.containerRef },
305
+ NoReact.createElement("button", { className: "main-button", ref: this.mainButtonContainerRef, style: {
306
+ d: "flex",
307
+ minWidth: this.css_buttonWidth,
308
+ maxWidth: this.css_buttonWidth,
309
+ minHeight: this.css_buttonHeight,
310
+ maxHeight: this.css_buttonHeight
311
+ }, onClick: this.__mainButtonClickHandler() },
312
+ NoReact.createElement("div", { className: "main-button-gradient-display", sx: { w: `calc( 100% - ${this.css_buttonFontSize} )`, background: selectedGradient.toColorGradientString() } }, "\u00A0"),
313
+ NoReact.createElement("div", { sx: { w: this.css_buttonHeight, flexShrink: 2, fontSize: this.css_buttonFontSize } }, "\u25BE")),
314
+ NoReact.createElement("div", { className: "positioning-container", ref: this.positioningContainerRef, style: {
315
+ minWidth: this.css_buttonWidth,
316
+ maxHeight: "25vh",
317
+ overflowY: "auto",
318
+ v: "hidden",
319
+ d: "flex",
320
+ fd: "column",
321
+ pos: "absolute",
322
+ l: 0,
323
+ zIndex: 999
324
+ } }, _self._renderAllOptionButtons())));
325
+ } // END function render()
326
+ }
327
+ ColorGradientSelector.DEFAULT_COLOR_GRADIENTS = [
328
+ ColorGradient.createDefault(),
329
+ ColorGradient.createFrom(Color.Red, Color.Green),
330
+ ColorGradient.createFrom(Color.Blue, Color.Gold)
331
+ ];
332
+ //# sourceMappingURL=ColorGradientSelector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ColorGradientSelector.js","sourceRoot":"","sources":["../../../../ts/utils/dom/components/ColorGradientSelector.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAGnC,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAkBnE,MAAM,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,8BAA8B,EACxC,EAAE,EAAE,EAAE,CAAC,EAAE,gBAAgB,IAAI,CAAC,kBAAkB,IAAI,EAAE,UAAU,EAAE,gBAAgB,CAAC,qBAAqB,EAAE,EAAE,aAGxG;gBACN,+BAAK,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,UAAU,EAAE,CAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,kBAAkB,EAAE,aAAS,CACzF;YACT,+BACE,SAAS,EAAC,uBAAuB,EACjC,GAAG,EAAE,IAAI,CAAC,uBAAuB,EACjC,KAAK,EAAE;oBACL,QAAQ,EAAE,IAAI,CAAC,eAAe;oBAC9B,SAAS,EAAE,MAAM;oBACjB,SAAS,EAAE,MAAM;oBACjB,CAAC,EAAE,QAAQ;oBACX,CAAC,EAAE,MAAM;oBACT,EAAE,EAAE,QAAQ;oBACZ,GAAG,EAAE,UAAU;oBACf,CAAC,EAAE,CAAC;oBACJ,MAAM,EAAE,GAAG;iBACZ,IAEA,KAAK,CAAC,uBAAuB,EAAE,CAC5B,CACF,CACP,CAAC;IACJ,CAAC,CAAC,wBAAwB;;AAnWH,6CAAuB,GAAyB;IACrE,aAAa,CAAC,aAAa,EAAE;IAC7B,aAAa,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC;IAChD,aAAa,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC;CACjD,AAJ6C,CAI5C"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @author Ikaros Kappler
3
+ * @date 2025-06-25
4
+ * @version 1.0.0
5
+ */
6
+ import { JsxElement } from "typescript";
7
+ export declare const Test: (name: string) => JsxElement;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @author Ikaros Kappler
3
+ * @date 2025-06-25
4
+ * @version 1.0.0
5
+ */
6
+ import * as NoReact from "noreact";
7
+ export const Test = (name) => {
8
+ const click1 = () => {
9
+ console.log("First clicked");
10
+ };
11
+ const click2 = () => {
12
+ console.log("Second clicked");
13
+ };
14
+ const mouseEnter = (event) => {
15
+ event.target.style["background-color"] = "grey";
16
+ };
17
+ const mouseOut = (event) => {
18
+ event.target.style["background-color"] = "DeepSkyBlue";
19
+ };
20
+ return (NoReact.createElement("div", { className: "NoReact-main" },
21
+ "Hello ",
22
+ name,
23
+ NoReact.createElement("div", { className: "NoReact-child-1", onClick: click1 }, "Hello Nested"),
24
+ NoReact.createElement("div", { className: "NoReact-child-2", onClick: click2, onMouseEnter: mouseEnter, onMouseOut: mouseOut, style: { backgroundColor: "yellow" } }, "Hello Nested 2")));
25
+ };
26
+ //# sourceMappingURL=Test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Test.js","sourceRoot":"","sources":["../../../../ts/utils/dom/components/Test.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAGnC,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,IAAY,EAAc,EAAE;IAC/C,MAAM,MAAM,GAAG,GAAG,EAAE;QAClB,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAC/B,CAAC,CAAC;IAEF,MAAM,MAAM,GAAG,GAAG,EAAE;QAClB,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAChC,CAAC,CAAC;IAEF,MAAM,UAAU,GAAG,CAAC,KAAY,EAAE,EAAE;QACjC,KAAK,CAAC,MAAyB,CAAC,KAAK,CAAC,kBAAkB,CAAC,GAAG,MAAM,CAAC;IACtE,CAAC,CAAC;IAEF,MAAM,QAAQ,GAAG,CAAC,KAAY,EAAE,EAAE;QAC/B,KAAK,CAAC,MAAyB,CAAC,KAAK,CAAC,kBAAkB,CAAC,GAAG,aAAa,CAAC;IAC7E,CAAC,CAAC;IAEF,OAAO,CACL,+BAAK,SAAS,EAAC,cAAc;;QACpB,IAAI;QACX,+BAAK,SAAS,EAAC,iBAAiB,EAAC,OAAO,EAAE,MAAM,mBAE1C;QACN,+BACE,SAAS,EAAC,iBAAiB,EAC3B,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,UAAU,EACxB,UAAU,EAAE,QAAQ,EACpB,KAAK,EAAE,EAAE,eAAe,EAAE,QAAQ,EAAE,qBAGhC,CACF,CACP,CAAC;AACJ,CAAC,CAAC"}
@@ -21,7 +21,7 @@ const applyGuiSize = (gui, guiDoubleSize, cssProps) => {
21
21
  gui.domElement.style["transform-origin"] = "100% 0%";
22
22
  }
23
23
  const transform = cssProps && cssProps.hasOwnProperty("transform") ? cssProps["transform"] + " " : "";
24
- console.log("transform", transform);
24
+ // console.log("transform", transform);
25
25
  if (guiDoubleSize) {
26
26
  gui.domElement.style["transform"] = transform + "scale(2.0)";
27
27
  }
@@ -1 +1 @@
1
- {"version":3,"file":"guiSizeToggler.js","sourceRoot":"","sources":["../../../ts/utils/dom/guiSizeToggler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAQH;;;;GAIG;AACH,MAAM,YAAY,GAAG,CAAC,GAAQ,EAAE,aAAsB,EAAE,QAAgC,EAAE,EAAE;IAC1F,IAAI,QAAQ,IAAI,QAAQ,CAAC,cAAc,CAAC,iBAAiB,CAAC,EAAE,CAAC;QAC3D,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,kBAAkB,CAAC,GAAG,QAAQ,CAAC,iBAAiB,CAAC,CAAC;IACzE,CAAC;SAAM,CAAC;QACN,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,kBAAkB,CAAC,GAAG,SAAS,CAAC;IACvD,CAAC;IAED,MAAM,SAAS,GAAG,QAAQ,IAAI,QAAQ,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAEtG,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IACpC,IAAI,aAAa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,aAAa,EAAE,CAAC;QAClB,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,SAAS,GAAG,YAAY,CAAC;IAC/D,CAAC;SAAM,CAAC;QACN,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,SAAS,GAAG,YAAY,CAAC;IAC/D,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,GAAQ,EAAE,MAAsB,EAAE,QAAgC,EAAE,EAAE;IACnG,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,YAAY,CAAC,GAAG,gBAAgB,CAAC;IACtD,OAAO;QACL,MAAM,EAAE;YACN,YAAY,CAAC,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,QAAQ,CAAC,CAAC;QAC7D,CAAC;KACF,CAAC;AACJ,CAAC,CAAC"}
@@ -25,7 +25,10 @@
25
25
  * @modified 2025-04-14 Added the `BezierPathInteractionHelper.drawHandleLines` method.
26
26
  * @modified 2025-04-14 Fixing correct event types for touch events in `BezierPathInteractionHelper`.
27
27
  * @modified 2025-04-14 BezierPathInteractionHelper: Changed default value of `HelperOptions.autoAdjustPaths` from `true` to `false`.
28
- * @version 1.2.0
28
+ * @modified 2025-05-05 Added optional params `draw` and `fill` to BezierPathInteractionHelper.drawHandleLines` method.
29
+ * @modified 2025-05-05 Class `BezierPathInteractionHelper` now implementing `IShapeInteractionHelper`.
30
+ * @modified 2025-05-07 Tweaking performance of `BezierPathInteractionHelper`: only triggering redraw now when mouse move within given detect range.
31
+ * @version 1.2.1
29
32
  *
30
33
  * @file BezierPathInteractionHelper
31
34
  * @public
@@ -34,6 +37,7 @@ import { BezierPath } from "../../BezierPath";
34
37
  import { PlotBoilerplate } from "../../PlotBoilerplate";
35
38
  import { VertListener } from "../../VertexListeners";
36
39
  import { Vertex } from "../../Vertex";
40
+ import { DrawLib, IShapeInteractionHelper } from "../../interfaces";
37
41
  /**
38
42
  * Handler type for mouse-pointer-moved listeners.
39
43
  */
@@ -73,7 +77,7 @@ interface HelperOptions {
73
77
  *
74
78
  * @public
75
79
  **/
76
- export declare class BezierPathInteractionHelper {
80
+ export declare class BezierPathInteractionHelper implements IShapeInteractionHelper {
77
81
  /**
78
82
  * @member {PlotBoilerplate} pb
79
83
  * @memberof BezierPathInteractionHelper
@@ -170,8 +174,10 @@ export declare class BezierPathInteractionHelper {
170
174
  /**
171
175
  * Draw grey handle lines.
172
176
  *
177
+ * @param {DrawLib<any>} draw - (optional) The draw library to use. If not provided then `pb.draw` will be used.
178
+ * @param {DrawLib<any>} fill - (optional) The fill library to use. If not provided then `pb.fill` will be used.
173
179
  */
174
- drawHandleLines(): void;
180
+ drawHandleLines(draw?: DrawLib<any>, fill?: DrawLib<any>): void;
175
181
  /**
176
182
  * This function should invalidate any installed listeners and invalidate this object.
177
183
  * After calling this function the object might not hold valid data any more and
@@ -25,7 +25,10 @@
25
25
  * @modified 2025-04-14 Added the `BezierPathInteractionHelper.drawHandleLines` method.
26
26
  * @modified 2025-04-14 Fixing correct event types for touch events in `BezierPathInteractionHelper`.
27
27
  * @modified 2025-04-14 BezierPathInteractionHelper: Changed default value of `HelperOptions.autoAdjustPaths` from `true` to `false`.
28
- * @version 1.2.0
28
+ * @modified 2025-05-05 Added optional params `draw` and `fill` to BezierPathInteractionHelper.drawHandleLines` method.
29
+ * @modified 2025-05-05 Class `BezierPathInteractionHelper` now implementing `IShapeInteractionHelper`.
30
+ * @modified 2025-05-07 Tweaking performance of `BezierPathInteractionHelper`: only triggering redraw now when mouse move within given detect range.
31
+ * @version 1.2.1
29
32
  *
30
33
  * @file BezierPathInteractionHelper
31
34
  * @public
@@ -187,8 +190,12 @@ export class BezierPathInteractionHelper {
187
190
  /**
188
191
  * Draw grey handle lines.
189
192
  *
193
+ * @param {DrawLib<any>} draw - (optional) The draw library to use. If not provided then `pb.draw` will be used.
194
+ * @param {DrawLib<any>} fill - (optional) The fill library to use. If not provided then `pb.fill` will be used.
190
195
  */
191
- drawHandleLines() {
196
+ drawHandleLines(draw, fill) {
197
+ draw = draw || this.pb.draw;
198
+ fill = fill || this.pb.fill;
192
199
  this.paths.forEach((path) => {
193
200
  path.bezierCurves.forEach((curve) => {
194
201
  this.pb.draw.line(curve.startPoint, curve.startControlPoint, "rgba(64,192,128,0.333)", 1.0, {
@@ -342,6 +349,9 @@ export class BezierPathInteractionHelper {
342
349
  // | Touch and mouse events should call this fuction when the pointer was moved.
343
350
  // +-------------------------------
344
351
  _handleMoveEvent(posX, posY) {
352
+ const oldA = this.currentA.clone();
353
+ const oldB = this.currentB.clone();
354
+ const oldDistance = this.currentDistance;
345
355
  const point = this.pb.transformMousePosition(posX, posY);
346
356
  this.currentB.set(point);
347
357
  this._updateMinDistance();
@@ -352,8 +362,12 @@ export class BezierPathInteractionHelper {
352
362
  else {
353
363
  this.onPointerMoved(-1, null, null, 0.0);
354
364
  }
355
- // Always redraw even when moving outside the detection distance?
356
- this.pb.redraw();
365
+ // Only redraw when moving inside the detection distance
366
+ if ((this.currentDistance <= this.maxDetectDistance ||
367
+ (this.currentDistance > this.maxDetectDistance && oldDistance <= this.maxDetectDistance)) &&
368
+ (!oldA.equals(this.currentA) || !oldB.equals(this.currentB))) {
369
+ this.pb.redraw();
370
+ }
357
371
  }
358
372
  // +---------------------------------------------------------------------------------
359
373
  // | This is called when the mouse pointer leaves the canvas or
@@ -369,23 +383,15 @@ export class BezierPathInteractionHelper {
369
383
  _installTouchListener() {
370
384
  var _self = this;
371
385
  const afProps = {
372
- // Todo: which event types does AlloyFinger use?
373
- // touchStart: function (_event: TouchEvent) {
374
- // _self.mouseIsOver = true;
375
- // },
376
- // /* TouchMoveEvent , AFTouchEvent<"touchStart"> */
377
386
  touchStart: function (_event) {
378
387
  _self.mouseIsOver = true;
379
388
  },
380
389
  touchMove: function (event) {
381
- // TouchEvent) {
382
390
  if (_self.pb.getDraggedElementCount() == 0 && event.touches.length > 0) {
383
- // console.log('touchmove');
384
391
  _self._handleMoveEvent(event.touches[0].clientX, event.touches[0].clientY);
385
392
  }
386
393
  },
387
394
  touchEnd: function (_event) {
388
- // TouchEvent) {
389
395
  _self.mouseIsOver = false;
390
396
  _self._clearMoveEvent();
391
397
  }
@@ -472,8 +478,9 @@ export class BezierPathInteractionHelper {
472
478
  // | Update the min distance from point `line.b` to the curve. And redraw.
473
479
  // +-------------------------------
474
480
  _updateMinDistance() {
475
- if (this.paths.length == 0)
481
+ if (this.paths.length == 0) {
476
482
  return;
483
+ }
477
484
  let pathIndex = -1;
478
485
  let minDist = Number.MAX_VALUE;
479
486
  let closestPoint = null;