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,325 @@
1
+ "use strict";
2
+ /**
3
+ * A simple class for rendering color gradient dropdowns.
4
+ *
5
+ * As native dropdown do not support custom stylings in the way we need, we will implement
6
+ * our own dropdown class.
7
+ *
8
+ * @author Ikaros Kappler
9
+ * @date 2025-08-19
10
+ * @version 1.0.0
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.ColorGradientSelector = void 0;
14
+ var NoReact = require("noreact");
15
+ var Color_1 = require("../../datastructures/Color");
16
+ var ColorGradient_1 = require("../../datastructures/ColorGradient");
17
+ var ColorGradientSelector = /** @class */ (function () {
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
+ */
27
+ function ColorGradientSelector(options) {
28
+ var _this = this;
29
+ this.isDropdownOpen = false;
30
+ this.css_buttonWidth = "100px";
31
+ this.css_buttonHeight = "1.8em";
32
+ this.css_buttonFontSize = "0.725em";
33
+ this.colorGradients = [];
34
+ // TODO: this does not really need to be a pair, does it?
35
+ this.colorGradientOptionRefs = [];
36
+ this.selectedGradientIndex = -1;
37
+ this.installedChangeListeners = [];
38
+ /**
39
+ * Adds custom styles (global STYLE tag).
40
+ *
41
+ * @private
42
+ */
43
+ this.__createCustomStylesElement = function () {
44
+ // Thanks to Ana Tudor
45
+ // https://css-tricks.com/multi-thumb-sliders-particular-two-thumb-case/
46
+ return (NoReact.createElement("style", null, "\n\n #".concat(_this.elementID, " button {\n border: 0px solid lightgray;\n padding: 0.25em;\n background-color: rgba(255,255,255,0.9);\n }\n\n #").concat(_this.elementID, " .main-button:hover {\n background-color: rgba(216,216,216,0.9);\n }\n\n #").concat(_this.elementID, " .option-gradient-button:hover, #").concat(_this.elementID, " .option-delete-button:hover {\n background-color: rgba(216,216,216,0.9);\n }\n\n ")));
47
+ };
48
+ options = options || {};
49
+ if (options.containerID) {
50
+ var cont = document.getElementById(options.containerID);
51
+ if (!cont) {
52
+ throw "Cannot create ColorGradientPicker. Component ID does not exist.";
53
+ }
54
+ this.container = cont;
55
+ }
56
+ else {
57
+ this.container = document.createElement("div");
58
+ }
59
+ this.isMobileMode = Boolean(options.isMobileMode);
60
+ if (this.isMobileMode) {
61
+ this.css_buttonWidth = "200px";
62
+ this.css_buttonHeight = "2.5em";
63
+ this.css_buttonFontSize = "1.25em";
64
+ }
65
+ this.baseID = Math.floor(Math.random() * 65535);
66
+ this.elementID = "color-gradient-selector-".concat(this.baseID);
67
+ this.colorGradients =
68
+ typeof options.initialGradients === "undefined" ? ColorGradientSelector.DEFAULT_COLOR_GRADIENTS : options.initialGradients;
69
+ this.selectedGradientIndex = typeof options.selectedGradientIndex === "undefined" ? 0 : options.selectedGradientIndex;
70
+ document.head.appendChild(this.__createCustomStylesElement());
71
+ this.container.append(this._render());
72
+ } // END constructor
73
+ // TODO: implement this?
74
+ ColorGradientSelector.prototype.setGradients = function (gradients, selectedIndex) {
75
+ var _this = this;
76
+ // First empty the container
77
+ this.__removeAllChildNodes(this.positioningContainerRef.current);
78
+ this.colorGradients = [];
79
+ this.colorGradientOptionRefs = [];
80
+ this.selectedGradientIndex = selectedIndex;
81
+ // Re-render button array
82
+ gradients.map(function (grad) {
83
+ _this.addGradient(grad);
84
+ });
85
+ };
86
+ ColorGradientSelector.prototype.addGradient = function (gradient) {
87
+ // Render a new button
88
+ var index = this.colorGradients.length;
89
+ var refMainContainer = NoReact.useRef();
90
+ var refActionButton = NoReact.useRef();
91
+ var refDeleteButton = NoReact.useRef();
92
+ this.__renderOptionButton(gradient, index, refMainContainer, refActionButton, refDeleteButton);
93
+ this.colorGradients.push(gradient);
94
+ this.colorGradientOptionRefs.push({ mainButton: refActionButton, deleteButton: refDeleteButton });
95
+ // Add to container
96
+ this.positioningContainerRef.current.appendChild(refMainContainer.current);
97
+ };
98
+ // +---------------------------------------------------------------------------------
99
+ // | A helper function to remove all child nodes.
100
+ // +-------------------------------
101
+ ColorGradientSelector.prototype.__removeAllChildNodes = function (node) {
102
+ while (node.lastChild) {
103
+ node.removeChild(node.lastChild);
104
+ }
105
+ };
106
+ /**
107
+ * Adds a new color gradient change listener to this ColorGradientPicker.
108
+ *
109
+ * @param {ColorGradientChangeListener} listener - The listener to add.
110
+ * @returns {boolean} True, if the listener was added and did not exist before.
111
+ */
112
+ ColorGradientSelector.prototype.addChangeListener = function (listener) {
113
+ for (var i = 0; i < this.installedChangeListeners.length; i++) {
114
+ if (this.installedChangeListeners[i] === listener) {
115
+ return false;
116
+ }
117
+ }
118
+ this.installedChangeListeners.push(listener);
119
+ return true;
120
+ };
121
+ /**
122
+ *
123
+ * @param {ColorGradientChangeListener} listener The listener to remove.
124
+ * @returns {boolean} True, if the listener existed and has been removed.
125
+ */
126
+ ColorGradientSelector.prototype.removeChangeListener = function (listener) {
127
+ for (var i = 0; i < this.installedChangeListeners.length; i++) {
128
+ if (this.installedChangeListeners[i] === listener) {
129
+ this.installedChangeListeners.splice(i, 1);
130
+ return true;
131
+ }
132
+ }
133
+ return false;
134
+ };
135
+ ColorGradientSelector.prototype.getSelectedColorGradient = function () {
136
+ return this.colorGradients[this.selectedGradientIndex];
137
+ };
138
+ ColorGradientSelector.prototype.__fireChangeEvent = function () {
139
+ var newColorGradient = this.getSelectedColorGradient();
140
+ for (var i = 0; i < this.installedChangeListeners.length; i++) {
141
+ this.installedChangeListeners[i](newColorGradient, this.selectedGradientIndex, this);
142
+ }
143
+ };
144
+ /**
145
+ * Creates a handler for click events on the main button.
146
+ *
147
+ * @returns
148
+ */
149
+ ColorGradientSelector.prototype.__mainButtonClickHandler = function () {
150
+ var _self = this;
151
+ return function (_evt) {
152
+ // _self.mainButtonContainerRef.current.style.visibility = "hidden";
153
+ _self.positioningContainerRef.current.style.visibility = _self.isDropdownOpen ? "hidden" : "visible";
154
+ _self.isDropdownOpen = !_self.isDropdownOpen;
155
+ };
156
+ };
157
+ /**
158
+ * Creates a handler for click events on one of the option button in the dropdown.
159
+ *
160
+ * @returns
161
+ */
162
+ ColorGradientSelector.prototype.__optionButtonClickHandler = function () {
163
+ var _self = this;
164
+ return function (evt) {
165
+ _self.positioningContainerRef.current.style.visibility = "hidden";
166
+ _self.isDropdownOpen = false;
167
+ var targetButton = evt.currentTarget;
168
+ var clickedIndex_raw = targetButton.dataset["gradientIndex"];
169
+ var clickedIndex = Number.parseInt(clickedIndex_raw);
170
+ console.log("clickedIndex", clickedIndex, clickedIndex_raw, targetButton.dataset, targetButton);
171
+ if (Number.isNaN(clickedIndex)) {
172
+ // Stop here. This is not what we want.
173
+ return;
174
+ }
175
+ // Find child: and set selected.
176
+ _self.__setSelectedIndex(clickedIndex);
177
+ _self.__fireChangeEvent();
178
+ };
179
+ };
180
+ ColorGradientSelector.prototype.__optionButtonDeleteHandler = function () {
181
+ var _this = this;
182
+ var _self = this;
183
+ return function (evt) {
184
+ if (_this.colorGradientOptionRefs.length === 1) {
185
+ // Keep the last record
186
+ return;
187
+ }
188
+ var targetButton = evt.currentTarget;
189
+ var clickedIndex_raw = targetButton.dataset["gradientIndex"];
190
+ var clickedIndex = Number.parseInt(clickedIndex_raw);
191
+ console.log("clickedIndex", clickedIndex, clickedIndex_raw, targetButton.dataset, targetButton);
192
+ if (Number.isNaN(clickedIndex)) {
193
+ // Stop here. This is not what we want.
194
+ return;
195
+ }
196
+ // Find child: and remove from DOM
197
+ console.log("this.colorGradientOptionRefs", _this.colorGradientOptionRefs, "clickedIndex", clickedIndex);
198
+ var refPair = _this.colorGradientOptionRefs[clickedIndex];
199
+ refPair.mainButton.current.parentElement.remove();
200
+ // Remove from logic
201
+ // Remove 1 element at the given index
202
+ _this.colorGradients.splice(clickedIndex, 1);
203
+ _this.colorGradientOptionRefs.splice(clickedIndex, 1);
204
+ // Update all following elements in the list.
205
+ _this.__updateOptionDataSetIndices(clickedIndex);
206
+ if (_this.selectedGradientIndex >= clickedIndex) {
207
+ // this.selectedGradientIndex--;
208
+ _this.__setSelectedIndex(_this.selectedGradientIndex);
209
+ }
210
+ console.log("All refs", _this.colorGradientOptionRefs);
211
+ };
212
+ };
213
+ /**
214
+ * Once a slider element was added or removed then the following indices must be updated.
215
+ *
216
+ * @param {number} startIndex - The slider index to start updating at.
217
+ */
218
+ ColorGradientSelector.prototype.__updateOptionDataSetIndices = function (startIndex) {
219
+ // Update all elements to the right of the new elelemt
220
+ for (var i = startIndex; i < this.colorGradientOptionRefs.length; i++) {
221
+ this.colorGradientOptionRefs[i].mainButton.current.dataset["gradientIndex"] = "".concat(i);
222
+ this.colorGradientOptionRefs[i].deleteButton.current.dataset["gradientIndex"] = "".concat(i);
223
+ }
224
+ };
225
+ ColorGradientSelector.prototype.__setSelectedIndex = function (newSelectedIndex) {
226
+ for (var i = 0; i < this.colorGradientOptionRefs.length; i++) {
227
+ var ref = this.colorGradientOptionRefs[i].mainButton;
228
+ // Find child: and set selected.
229
+ ref.current.querySelectorAll(".option-gradient-radio-circle")[0].innerHTML = newSelectedIndex === i ? "🞊" : "🞅";
230
+ }
231
+ this.selectedGradientIndex = newSelectedIndex;
232
+ var selectedGradient = this.colorGradients[this.selectedGradientIndex];
233
+ // Display new gradient in the main button
234
+ this.__setMainButtonGradient(selectedGradient);
235
+ };
236
+ /**
237
+ * Sets the backround color of the main button (of this dropdown) element.
238
+ *
239
+ * @param {ColorGradient} gradient - The gradient color to display. Must not be null.
240
+ */
241
+ ColorGradientSelector.prototype.__setMainButtonGradient = function (gradient) {
242
+ var colorDisplay = this.mainButtonContainerRef.current.querySelectorAll(".main-button-gradient-display")[0];
243
+ colorDisplay.style["background"] = gradient.toColorGradientString();
244
+ };
245
+ /**
246
+ * Renders a new option button for the dropdown menu.
247
+ *
248
+ * @param {ColorGradient} gradient
249
+ * @returns {JsxElement}
250
+ */
251
+ ColorGradientSelector.prototype.__renderOptionButton = function (gradient, index, refMainContainer, refActionButton, refDelButton) {
252
+ return (NoReact.createElement("div", { sx: { d: "flex", flexDirection: "row" }, ref: refMainContainer },
253
+ NoReact.createElement("button", { className: "option-gradient-button", onClick: this.__optionButtonClickHandler(), style: {
254
+ d: "flex",
255
+ w: "100%",
256
+ fontSize: this.css_buttonFontSize,
257
+ minHeight: this.css_buttonHeight,
258
+ maxHeight: this.css_buttonHeight
259
+ }, ref: refActionButton, "data-gradientIndex": "".concat(index) },
260
+ NoReact.createElement("div", { className: "option-gradient-radio-circle", sx: { w: "2em", flexShrink: 2, alignContent: "center" } }, index === 0 ? "🞊" : "🞅"),
261
+ NoReact.createElement("div", { sx: { w: "calc( 100% - 2em )", mr: "1em", background: gradient.toColorGradientString() } }, "\u00A0")),
262
+ 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": "".concat(index), ref: refDelButton },
263
+ NoReact.createElement("div", { sx: { w: "2em", flexShrink: 2, alignContent: "center" } }, "\uD83D\uDDD1"))));
264
+ };
265
+ /**
266
+ * Creates a new array of option buttons (refs).
267
+ * @returns
268
+ */
269
+ ColorGradientSelector.prototype._renderAllOptionButtons = function () {
270
+ var _this = this;
271
+ var _self = this;
272
+ // First clear all references
273
+ _self.colorGradientOptionRefs = [];
274
+ return this.colorGradients.map(function (colorGradient, index) {
275
+ // console.log("num", num, index);
276
+ var refMainContainer = NoReact.useRef();
277
+ var refActionButton = NoReact.useRef();
278
+ var refDelButton = NoReact.useRef();
279
+ _self.colorGradientOptionRefs.push({ mainButton: refActionButton, deleteButton: refDelButton });
280
+ return _this.__renderOptionButton(colorGradient, index, refMainContainer, refActionButton, refDelButton);
281
+ });
282
+ };
283
+ /**
284
+ * Init the container contents.
285
+ *
286
+ * @private
287
+ */
288
+ ColorGradientSelector.prototype._render = function () {
289
+ var _self = this;
290
+ // console.log("Rendering ...", NoReact);
291
+ this.containerRef = NoReact.useRef();
292
+ this.mainButtonContainerRef = NoReact.useRef();
293
+ this.positioningContainerRef = NoReact.useRef();
294
+ var selectedGradient = this.colorGradients[this.selectedGradientIndex];
295
+ 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 },
296
+ NoReact.createElement("button", { className: "main-button", ref: this.mainButtonContainerRef, style: {
297
+ d: "flex",
298
+ minWidth: this.css_buttonWidth,
299
+ maxWidth: this.css_buttonWidth,
300
+ minHeight: this.css_buttonHeight,
301
+ maxHeight: this.css_buttonHeight
302
+ }, onClick: this.__mainButtonClickHandler() },
303
+ NoReact.createElement("div", { className: "main-button-gradient-display", sx: { w: "calc( 100% - ".concat(this.css_buttonFontSize, " )"), background: selectedGradient.toColorGradientString() } }, "\u00A0"),
304
+ NoReact.createElement("div", { sx: { w: this.css_buttonHeight, flexShrink: 2, fontSize: this.css_buttonFontSize } }, "\u25BE")),
305
+ NoReact.createElement("div", { className: "positioning-container", ref: this.positioningContainerRef, style: {
306
+ minWidth: this.css_buttonWidth,
307
+ maxHeight: "25vh",
308
+ overflowY: "auto",
309
+ v: "hidden",
310
+ d: "flex",
311
+ fd: "column",
312
+ pos: "absolute",
313
+ l: 0,
314
+ zIndex: 999
315
+ } }, _self._renderAllOptionButtons())));
316
+ }; // END function render()
317
+ ColorGradientSelector.DEFAULT_COLOR_GRADIENTS = [
318
+ ColorGradient_1.ColorGradient.createDefault(),
319
+ ColorGradient_1.ColorGradient.createFrom(Color_1.Color.Red, Color_1.Color.Green),
320
+ ColorGradient_1.ColorGradient.createFrom(Color_1.Color.Blue, Color_1.Color.Gold)
321
+ ];
322
+ return ColorGradientSelector;
323
+ }());
324
+ exports.ColorGradientSelector = ColorGradientSelector;
325
+ //# 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,iCAAmC;AAGnC,oDAAmD;AACnD,oEAAmE;AAkBnE;IAgCE;;;;;;;;OAQG;IACH,+BAAY,OAAoC;QAAhD,iBA0BC;QAzDO,mBAAc,GAAY,KAAK,CAAC;QAEhC,oBAAe,GAAG,OAAO,CAAC;QAC1B,qBAAgB,GAAG,OAAO,CAAC;QAC3B,uBAAkB,GAAG,SAAS,CAAC;QAE/B,mBAAc,GAAyB,EAAE,CAAC;QAClD,yDAAyD;QACjD,4BAAuB,GAG1B,EAAE,CAAC;QACA,0BAAqB,GAAW,CAAC,CAAC,CAAC;QAE1B,6BAAwB,GAA+C,EAAE,CAAC;QAuW3F;;;;WAIG;QACK,gCAA2B,GAAG;YACpC,sBAAsB;YACtB,2EAA2E;YAC3E,OAAO,CACL,qCAAQ,mBAEP,KAAI,CAAC,SAAS,kJAMd,KAAI,CAAC,SAAS,kGAId,KAAI,CAAC,SAAS,8CAAoC,KAAI,CAAC,SAAS,kGAIlE,CAAS,CACT,CAAC;QACJ,CAAC,CAAC;QAhXA,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;QACxB,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;YACxB,IAAM,IAAI,GAAG,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YAC1D,IAAI,CAAC,IAAI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wB;IAnWH,6CAAuB,GAAyB;QACrE,6BAAa,CAAC,aAAa,EAAE;QAC7B,6BAAa,CAAC,UAAU,CAAC,aAAK,CAAC,GAAG,EAAE,aAAK,CAAC,KAAK,CAAC;QAChD,6BAAa,CAAC,UAAU,CAAC,aAAK,CAAC,IAAI,EAAE,aAAK,CAAC,IAAI,CAAC;KACjD,AAJ6C,CAI5C;IA6XJ,4BAAC;CAAA,AA3ZD,IA2ZC;AA3ZY,sDAAqB"}
@@ -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,30 @@
1
+ "use strict";
2
+ /**
3
+ * @author Ikaros Kappler
4
+ * @date 2025-06-25
5
+ * @version 1.0.0
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.Test = void 0;
9
+ var NoReact = require("noreact");
10
+ var Test = function (name) {
11
+ var click1 = function () {
12
+ console.log("First clicked");
13
+ };
14
+ var click2 = function () {
15
+ console.log("Second clicked");
16
+ };
17
+ var mouseEnter = function (event) {
18
+ event.target.style["background-color"] = "grey";
19
+ };
20
+ var mouseOut = function (event) {
21
+ event.target.style["background-color"] = "DeepSkyBlue";
22
+ };
23
+ return (NoReact.createElement("div", { className: "NoReact-main" },
24
+ "Hello ",
25
+ name,
26
+ NoReact.createElement("div", { className: "NoReact-child-1", onClick: click1 }, "Hello Nested"),
27
+ NoReact.createElement("div", { className: "NoReact-child-2", onClick: click2, onMouseEnter: mouseEnter, onMouseOut: mouseOut, style: { backgroundColor: "yellow" } }, "Hello Nested 2")));
28
+ };
29
+ exports.Test = Test;
30
+ //# 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,iCAAmC;AAG5B,IAAM,IAAI,GAAG,UAAC,IAAY;IAC/B,IAAM,MAAM,GAAG;QACb,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAC/B,CAAC,CAAC;IAEF,IAAM,MAAM,GAAG;QACb,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAChC,CAAC,CAAC;IAEF,IAAM,UAAU,GAAG,UAAC,KAAY;QAC7B,KAAK,CAAC,MAAyB,CAAC,KAAK,CAAC,kBAAkB,CAAC,GAAG,MAAM,CAAC;IACtE,CAAC,CAAC;IAEF,IAAM,QAAQ,GAAG,UAAC,KAAY;QAC3B,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;AAlCW,QAAA,IAAI,QAkCf"}
@@ -24,7 +24,7 @@ var applyGuiSize = function (gui, guiDoubleSize, cssProps) {
24
24
  gui.domElement.style["transform-origin"] = "100% 0%";
25
25
  }
26
26
  var transform = cssProps && cssProps.hasOwnProperty("transform") ? cssProps["transform"] + " " : "";
27
- console.log("transform", transform);
27
+ // console.log("transform", transform);
28
28
  if (guiDoubleSize) {
29
29
  gui.domElement.style["transform"] = transform + "scale(2.0)";
30
30
  }
@@ -1 +1 @@
1
- {"version":3,"file":"guiSizeToggler.js","sourceRoot":"","sources":["../../../ts/utils/dom/guiSizeToggler.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAQH;;;;GAI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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
@@ -26,7 +26,10 @@
26
26
  * @modified 2025-04-14 Added the `BezierPathInteractionHelper.drawHandleLines` method.
27
27
  * @modified 2025-04-14 Fixing correct event types for touch events in `BezierPathInteractionHelper`.
28
28
  * @modified 2025-04-14 BezierPathInteractionHelper: Changed default value of `HelperOptions.autoAdjustPaths` from `true` to `false`.
29
- * @version 1.2.0
29
+ * @modified 2025-05-05 Added optional params `draw` and `fill` to BezierPathInteractionHelper.drawHandleLines` method.
30
+ * @modified 2025-05-05 Class `BezierPathInteractionHelper` now implementing `IShapeInteractionHelper`.
31
+ * @modified 2025-05-07 Tweaking performance of `BezierPathInteractionHelper`: only triggering redraw now when mouse move within given detect range.
32
+ * @version 1.2.1
30
33
  *
31
34
  * @file BezierPathInteractionHelper
32
35
  * @public
@@ -191,9 +194,13 @@ var BezierPathInteractionHelper = /** @class */ (function () {
191
194
  /**
192
195
  * Draw grey handle lines.
193
196
  *
197
+ * @param {DrawLib<any>} draw - (optional) The draw library to use. If not provided then `pb.draw` will be used.
198
+ * @param {DrawLib<any>} fill - (optional) The fill library to use. If not provided then `pb.fill` will be used.
194
199
  */
195
- BezierPathInteractionHelper.prototype.drawHandleLines = function () {
200
+ BezierPathInteractionHelper.prototype.drawHandleLines = function (draw, fill) {
196
201
  var _this = this;
202
+ draw = draw || this.pb.draw;
203
+ fill = fill || this.pb.fill;
197
204
  this.paths.forEach(function (path) {
198
205
  path.bezierCurves.forEach(function (curve) {
199
206
  _this.pb.draw.line(curve.startPoint, curve.startControlPoint, "rgba(64,192,128,0.333)", 1.0, {
@@ -347,6 +354,9 @@ var BezierPathInteractionHelper = /** @class */ (function () {
347
354
  // | Touch and mouse events should call this fuction when the pointer was moved.
348
355
  // +-------------------------------
349
356
  BezierPathInteractionHelper.prototype._handleMoveEvent = function (posX, posY) {
357
+ var oldA = this.currentA.clone();
358
+ var oldB = this.currentB.clone();
359
+ var oldDistance = this.currentDistance;
350
360
  var point = this.pb.transformMousePosition(posX, posY);
351
361
  this.currentB.set(point);
352
362
  this._updateMinDistance();
@@ -357,8 +367,12 @@ var BezierPathInteractionHelper = /** @class */ (function () {
357
367
  else {
358
368
  this.onPointerMoved(-1, null, null, 0.0);
359
369
  }
360
- // Always redraw even when moving outside the detection distance?
361
- this.pb.redraw();
370
+ // Only redraw when moving inside the detection distance
371
+ if ((this.currentDistance <= this.maxDetectDistance ||
372
+ (this.currentDistance > this.maxDetectDistance && oldDistance <= this.maxDetectDistance)) &&
373
+ (!oldA.equals(this.currentA) || !oldB.equals(this.currentB))) {
374
+ this.pb.redraw();
375
+ }
362
376
  };
363
377
  // +---------------------------------------------------------------------------------
364
378
  // | This is called when the mouse pointer leaves the canvas or
@@ -374,23 +388,15 @@ var BezierPathInteractionHelper = /** @class */ (function () {
374
388
  BezierPathInteractionHelper.prototype._installTouchListener = function () {
375
389
  var _self = this;
376
390
  var afProps = {
377
- // Todo: which event types does AlloyFinger use?
378
- // touchStart: function (_event: TouchEvent) {
379
- // _self.mouseIsOver = true;
380
- // },
381
- // /* TouchMoveEvent , AFTouchEvent<"touchStart"> */
382
391
  touchStart: function (_event) {
383
392
  _self.mouseIsOver = true;
384
393
  },
385
394
  touchMove: function (event) {
386
- // TouchEvent) {
387
395
  if (_self.pb.getDraggedElementCount() == 0 && event.touches.length > 0) {
388
- // console.log('touchmove');
389
396
  _self._handleMoveEvent(event.touches[0].clientX, event.touches[0].clientY);
390
397
  }
391
398
  },
392
399
  touchEnd: function (_event) {
393
- // TouchEvent) {
394
400
  _self.mouseIsOver = false;
395
401
  _self._clearMoveEvent();
396
402
  }
@@ -477,8 +483,9 @@ var BezierPathInteractionHelper = /** @class */ (function () {
477
483
  // | Update the min distance from point `line.b` to the curve. And redraw.
478
484
  // +-------------------------------
479
485
  BezierPathInteractionHelper.prototype._updateMinDistance = function () {
480
- if (this.paths.length == 0)
486
+ if (this.paths.length == 0) {
481
487
  return;
488
+ }
482
489
  var pathIndex = -1;
483
490
  var minDist = Number.MAX_VALUE;
484
491
  var closestPoint = null;