@chocbite/ts-lib-ui 1.1.5 → 1.2.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.
- package/AGENTS.md +547 -9
- package/README.md +3 -0
- package/SOURCE.md +10313 -7355
- package/base/index.d.mts +2 -2
- package/base/index.mjs +68 -5
- package/base/index.mjs.map +1 -1
- package/canvas/index.d.mts +1 -1
- package/canvas/index.mjs +1 -1
- package/composition/index.d.mts +283 -0
- package/composition/index.mjs +2 -0
- package/composition-BlntkKR0.mjs +869 -0
- package/composition-BlntkKR0.mjs.map +1 -0
- package/context-menu/index.d.mts +1 -1
- package/context-menu/index.mjs +1 -1
- package/{context-menu-CZxEGjBi.mjs → context-menu-C0KTV5zC.mjs} +2 -2
- package/{context-menu-CZxEGjBi.mjs.map → context-menu-C0KTV5zC.mjs.map} +1 -1
- package/depot_ui/index.d.mts +60 -0
- package/depot_ui/index.mjs +280 -0
- package/depot_ui/index.mjs.map +1 -0
- package/form/index.d.mts +2 -758
- package/form/index.mjs +1 -2953
- package/form-CJA3s46n.mjs +2961 -0
- package/form-CJA3s46n.mjs.map +1 -0
- package/icons/index.d.mts +1 -1
- package/{index-YNZjMIO7.d.mts → index-CApVOEcI.d.mts} +2 -2
- package/{index-BDWg5GX2.d.mts → index-Czy8O3me.d.mts} +6 -2
- package/index-DD09-bGe.d.mts +761 -0
- package/{index-DlBJdGaQ.d.mts → index-U3pqQjLg.d.mts} +4 -4
- package/{index-CvzH3M_5.d.mts → index-_y7vmunA.d.mts} +72 -8
- package/keyboard/index.d.mts +1 -1
- package/keyboard/index.mjs +1 -1
- package/list/index.d.mts +1 -1
- package/list/index.mjs +1 -1
- package/{list-C52-ExFw.mjs → list-CVrn4y2k.mjs} +3 -3
- package/{list-C52-ExFw.mjs.map → list-CVrn4y2k.mjs.map} +1 -1
- package/package.json +2 -2
- package/prompts/index.d.mts +48 -0
- package/prompts/index.mjs +107 -0
- package/prompts/index.mjs.map +1 -0
- package/spinner/index.d.mts +1 -1
- package/spinner/index.mjs +1 -1
- package/style.css +2049 -1640
- package/svg/index.d.mts +1 -1
- package/svg-Yz7elqnU.mjs.map +1 -1
- package/theme/index.d.mts +1 -1
- package/theme/index.mjs +1 -1
- package/{theme-D3YluyYr.mjs → theme-D0pRMLyT.mjs} +2 -2
- package/{theme-D3YluyYr.mjs.map → theme-D0pRMLyT.mjs.map} +1 -1
- package/form/index.mjs.map +0 -1
- package/test/index.d.mts +0 -98
- package/test/index.mjs +0 -193
- package/test/index.mjs.map +0 -1
|
@@ -0,0 +1,2961 @@
|
|
|
1
|
+
import "./style.css";
|
|
2
|
+
import { AccessTypes, Base, define_element } from "./base/index.mjs";
|
|
3
|
+
import { c as ANIMATION_SPEED, i as theme_init_variable_root, l as AnimationLevels, s as ANIMATION_LEVEL } from "./theme-D0pRMLyT.mjs";
|
|
4
|
+
import { node_clone } from "./dom/index.mjs";
|
|
5
|
+
import { B1 as material_remove_rounded, Fx as material_drag_handle_rounded, Qot as material_unfold_less_rounded, U2 as material_schedule_rounded, dn as material_add_rounded, est as material_unfold_more_rounded, if as material_calendar_month_rounded, xI as material_keyboard_arrow_down_rounded, xh as material_close_rounded } from "./icons-B88i-7MC.mjs";
|
|
6
|
+
import { n as ListField } from "./list-CVrn4y2k.mjs";
|
|
7
|
+
import { get_cursor_position, set_cursor_end, set_cursor_position, set_selection_all } from "./selection/index.mjs";
|
|
8
|
+
import { DOCUMENT_HANDLER } from "./document/index.mjs";
|
|
9
|
+
import state from "@chocbite/ts-lib/state";
|
|
10
|
+
import { err, none, ok, some } from "@chocbite/ts-lib/result";
|
|
11
|
+
import { BLUE, GREEN, GREY, ORANGE, RED, YELLOW } from "@chocbite/ts-lib/colors";
|
|
12
|
+
import { IPAddress, IPVersion, sleep, sync_resolve } from "@chocbite/ts-lib/common";
|
|
13
|
+
import { number_step_start_decimal } from "@chocbite/ts-lib/math";
|
|
14
|
+
import { string_byte_length, string_byte_limit } from "@chocbite/ts-lib/string";
|
|
15
|
+
// form/shared.ts
|
|
16
|
+
const theme_root = theme_init_variable_root("form", "UI Form Elements", "Theme variables for UI form Elements");
|
|
17
|
+
theme_root.make_sub_group("read", "Read Only", "Settings for form elements in read only mode").make_variable("filter", "Read Only Filter", "Filter applied to form elements in read only mode", "opacity(0.6)", "opacity(0.6)", "Filter", void 0);
|
|
18
|
+
const colors = theme_root.make_sub_group("colors", "Colors", "Colors used in all form elements");
|
|
19
|
+
const colors_text = colors.make_sub_group("text", "Text Colors", "Text colors used in all form elements");
|
|
20
|
+
colors_text.make_variable("label", "Label Color", "Color of form elements labels", GREY["700"], GREY["300"], "Color", void 0);
|
|
21
|
+
colors_text.make_variable("normal", "Normal Text Color", "Normal text color in form elements", GREY["800"], GREY["200"], "Color", void 0);
|
|
22
|
+
colors_text.make_variable("selected", "Selected Text Color", "Selected text color in form elements", GREY["900"], GREY["50"], "Color", void 0);
|
|
23
|
+
colors_text.make_variable("unselected", "Unselected Text Color", "Unselected text color in form elements", GREY["600"], GREY["400"], "Color", void 0);
|
|
24
|
+
const colors_text_black = colors.make_sub_group("textBlack", "Text Colors Black Background", "Text colors used for black background in all form elements");
|
|
25
|
+
colors_text_black.make_variable("normal", "Normal Text Color", "Normal text color in form elements", GREY["200"], GREY["200"], "Color", void 0);
|
|
26
|
+
colors_text_black.make_variable("selected", "Selected Text Color", "Selected text color in form elements", GREY["50"], GREY["50"], "Color", void 0);
|
|
27
|
+
colors_text_black.make_variable("unselected", "Unselected Text Color", "Unselected text color in form elements", GREY["600"], GREY["400"], "Color", void 0);
|
|
28
|
+
const colors_icon = colors.make_sub_group("icon", "Icon Colors", "Icon colors used in all form elements");
|
|
29
|
+
colors_icon.make_variable("normal", "Normal Icon Color", "Color of icons in form elements", GREY["800"], GREY["200"], "Color", void 0);
|
|
30
|
+
colors_icon.make_variable("selected", "Selected Icon Color", "Color of selected icons in form elements", GREY["900"], GREY["50"], "Color", void 0);
|
|
31
|
+
colors_icon.make_variable("unselected", "Unselected Icon Color", "Color of unselected icons in form elements", GREY["600"], GREY["400"], "Color", void 0);
|
|
32
|
+
const colors_background = colors.make_sub_group("background", "Background Colors", "Background colors used in all form elements");
|
|
33
|
+
colors_background.make_variable("normal", "Normal Background Color", "Color of normal form element backgrounds", GREY["50"], GREY["900"], "Color", void 0);
|
|
34
|
+
colors_background.make_variable("hover", "Hover Background Color", "Color of form element backgrounds when hovering", GREY["400"], GREY["700"], "Color", void 0);
|
|
35
|
+
colors_background.make_variable("unselected", "Unselected Background Color", "Color of unselected form element backgrounds", GREY["300"], GREY["800"], "Color", void 0);
|
|
36
|
+
const colors_border = colors.make_sub_group("border", "Border Colors", "Border colors used in all form elements");
|
|
37
|
+
colors_border.make_variable("normal", "Normal Border Color", "Color of normal form element borders", GREY["700"], GREY["300"], "Color", void 0);
|
|
38
|
+
colors_border.make_variable("unselected", "Unselected Border Color", "Color of unselected form element borders", GREY["700"], GREY["300"], "Color", void 0);
|
|
39
|
+
colors.make_sub_group("focus", "Focus Colors", "Focus colors used in all form elements").make_variable("normal", "Focus Color", "Color of focussed form element", ORANGE["600"], ORANGE["300"], "Color", void 0);
|
|
40
|
+
const colors_basic = colors.make_sub_group("basic", "Basic Colors", "Basic colors used in all form elements");
|
|
41
|
+
colors_basic.make_variable("black", "Basic Black Color", "Commonly used black color in form elements", GREY["900"], GREY["900"], "Color", void 0);
|
|
42
|
+
colors_basic.make_variable("white", "Basic White Color", "Commonly used white color in form elements", GREY["100"], GREY["100"], "Color", void 0);
|
|
43
|
+
colors_basic.make_variable("green", "Basic Green Color", "Commonly used green color in form elements", GREEN["300"], GREEN["900"], "Color", void 0);
|
|
44
|
+
colors_basic.make_variable("red", "Basic Red Color", "Commonly used red color in form elements", RED["300"], RED["900"], "Color", void 0);
|
|
45
|
+
colors_basic.make_variable("blue", "Basic Blue Color", "Commonly used blue color in form elements", BLUE["300"], BLUE["900"], "Color", void 0);
|
|
46
|
+
colors_basic.make_variable("yellow", "Basic Yellow Color", "Commonly used yellow color in form elements", YELLOW["300"], ORANGE["900"], "Color", void 0);
|
|
47
|
+
const sizes = theme_root.make_sub_group("size", "Size", "Sizes used in all form elements");
|
|
48
|
+
sizes.make_variable("height", "Height", "Default height used in all form elements", "1.3rem", "1.3rem", "Length", {
|
|
49
|
+
min: .1,
|
|
50
|
+
max: 10
|
|
51
|
+
});
|
|
52
|
+
sizes.make_variable("touchHeight", "Touch Height", "Minimum height for touch devices used in all form elements", "2.0rem", "2.0rem", "Length", {
|
|
53
|
+
min: .1,
|
|
54
|
+
max: 10
|
|
55
|
+
});
|
|
56
|
+
const font = theme_root.make_sub_group("font", "Font", "Font settings used in all form elements");
|
|
57
|
+
font.make_variable("size", "Font Size", "Default font size used in all form elements", "0.9rem", "0.9rem", "Length", {
|
|
58
|
+
min: .1,
|
|
59
|
+
max: 10
|
|
60
|
+
});
|
|
61
|
+
font.make_variable("touch_size", "Touch Font Size", "Font size used in all form elements for touch devices", "1.1rem", "1.1rem", "Length", {
|
|
62
|
+
min: .1,
|
|
63
|
+
max: 10
|
|
64
|
+
});
|
|
65
|
+
// form/base.ts
|
|
66
|
+
/**Colors for form elements that have selectable colors*/
|
|
67
|
+
const FormColors = {
|
|
68
|
+
None: "none",
|
|
69
|
+
Black: "black",
|
|
70
|
+
Green: "green",
|
|
71
|
+
Red: "red",
|
|
72
|
+
Blue: "blue",
|
|
73
|
+
Yellow: "yellow"
|
|
74
|
+
};
|
|
75
|
+
/**Shared component class for other components to inherit from*/
|
|
76
|
+
var FormElement = class extends Base {
|
|
77
|
+
static element_name() {
|
|
78
|
+
return "@abstract@";
|
|
79
|
+
}
|
|
80
|
+
static element_name_space() {
|
|
81
|
+
return "form";
|
|
82
|
+
}
|
|
83
|
+
static apply_options(_element, _options) {}
|
|
84
|
+
};
|
|
85
|
+
/**Shared class for all components with values*/
|
|
86
|
+
var FormValue = class extends FormElement {
|
|
87
|
+
static element_name() {
|
|
88
|
+
return "@abstract@";
|
|
89
|
+
}
|
|
90
|
+
static apply_options(element, options) {
|
|
91
|
+
if (options.description) element.description = options.description;
|
|
92
|
+
if (options.value !== void 0) element.value = options.value;
|
|
93
|
+
super.apply_options(element, options);
|
|
94
|
+
}
|
|
95
|
+
form_id;
|
|
96
|
+
constructor(id) {
|
|
97
|
+
super();
|
|
98
|
+
this.form_id = id;
|
|
99
|
+
}
|
|
100
|
+
_description;
|
|
101
|
+
/**Sets the description of the element, shown as a tooltip*/
|
|
102
|
+
set description(text) {
|
|
103
|
+
this._description = text;
|
|
104
|
+
if (text) this.title = text;
|
|
105
|
+
else this.removeAttribute("title");
|
|
106
|
+
}
|
|
107
|
+
get description() {
|
|
108
|
+
return this._description || "";
|
|
109
|
+
}
|
|
110
|
+
_buffer;
|
|
111
|
+
get buffer() {
|
|
112
|
+
return this._buffer;
|
|
113
|
+
}
|
|
114
|
+
_state;
|
|
115
|
+
#func;
|
|
116
|
+
/**Binds the element to a state, a read only state is shown and changes to the element are refused with a warning*/
|
|
117
|
+
bind(opts) {
|
|
118
|
+
if (this.#func) {
|
|
119
|
+
this.detach_state(this.#func);
|
|
120
|
+
this.#func = void 0;
|
|
121
|
+
}
|
|
122
|
+
if (opts.value) {
|
|
123
|
+
const related = opts.value.related();
|
|
124
|
+
this.state_related(related.some ? related.value : {});
|
|
125
|
+
this.#func = this.attach_state(opts.value, (val) => {
|
|
126
|
+
if (val.ok) {
|
|
127
|
+
this.value = val.value;
|
|
128
|
+
if (this.#error) this.error = void 0;
|
|
129
|
+
} else this.error = val.error;
|
|
130
|
+
});
|
|
131
|
+
} else this.state_related({});
|
|
132
|
+
this._state = opts.value;
|
|
133
|
+
return this;
|
|
134
|
+
}
|
|
135
|
+
/**This sets the value of the component*/
|
|
136
|
+
set value(val) {
|
|
137
|
+
if (typeof this._buffer !== "undefined" && this._buffer === val) return;
|
|
138
|
+
this._buffer = val;
|
|
139
|
+
this.new_value(val);
|
|
140
|
+
}
|
|
141
|
+
/**Returns value of the component*/
|
|
142
|
+
get get_value() {
|
|
143
|
+
return this._state ? err("State based component") : typeof this._buffer === "undefined" ? err("No value yet") : ok(this._buffer);
|
|
144
|
+
}
|
|
145
|
+
#error = false;
|
|
146
|
+
set error(err) {
|
|
147
|
+
if (err) {
|
|
148
|
+
this.new_error(err);
|
|
149
|
+
this.#error = true;
|
|
150
|
+
} else if (this.#error) {
|
|
151
|
+
this.clear_error();
|
|
152
|
+
this.#error = false;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
/**Clears the value and error of the component if not state based*/
|
|
156
|
+
clear() {
|
|
157
|
+
if (this._state) return;
|
|
158
|
+
this._buffer = void 0;
|
|
159
|
+
this.clear_value();
|
|
160
|
+
this.clear_error();
|
|
161
|
+
this.#error = false;
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
/**Shared class for all components with values*/
|
|
165
|
+
var FormValueWrite = class FormValueWrite extends FormValue {
|
|
166
|
+
static element_name() {
|
|
167
|
+
return "@abstract@";
|
|
168
|
+
}
|
|
169
|
+
selected = false;
|
|
170
|
+
warn_input = document.createElement("input");
|
|
171
|
+
#warn_timeout;
|
|
172
|
+
#changed = false;
|
|
173
|
+
#change;
|
|
174
|
+
static apply_options(element, options) {
|
|
175
|
+
if (options.change) element.change = options.change;
|
|
176
|
+
super.apply_options(element, options);
|
|
177
|
+
}
|
|
178
|
+
constructor(id) {
|
|
179
|
+
super(id);
|
|
180
|
+
this.warn_input.name = "val";
|
|
181
|
+
}
|
|
182
|
+
focus(options) {
|
|
183
|
+
this.warn_input.focus(options);
|
|
184
|
+
}
|
|
185
|
+
set change(func) {
|
|
186
|
+
this.#change = func;
|
|
187
|
+
}
|
|
188
|
+
get change() {
|
|
189
|
+
return this.#change;
|
|
190
|
+
}
|
|
191
|
+
/**Returns true if the value of the component has changed*/
|
|
192
|
+
get changed() {
|
|
193
|
+
return this.#changed;
|
|
194
|
+
}
|
|
195
|
+
set value(val) {
|
|
196
|
+
if (!this.selected) super.value = val;
|
|
197
|
+
else this._buffer = val;
|
|
198
|
+
}
|
|
199
|
+
warn(message) {
|
|
200
|
+
this.warn_input.setCustomValidity(message);
|
|
201
|
+
this.warn_input.reportValidity();
|
|
202
|
+
if (this.#warn_timeout) clearTimeout(this.#warn_timeout);
|
|
203
|
+
this.#warn_timeout = setTimeout(() => {
|
|
204
|
+
this.warn_input.setCustomValidity("");
|
|
205
|
+
this.warn_input.reportValidity();
|
|
206
|
+
}, 5e3);
|
|
207
|
+
}
|
|
208
|
+
/**Function to limit value entered */
|
|
209
|
+
limit_value(val) {
|
|
210
|
+
if (this._state) {
|
|
211
|
+
if (this._state.writable) return this._state.limit(val);
|
|
212
|
+
else return sync_resolve(err("Not writable"));
|
|
213
|
+
} else return sync_resolve(ok(val));
|
|
214
|
+
}
|
|
215
|
+
/**Function to check value, a state checks the value itself when it is written, so it is not checked here*/
|
|
216
|
+
check_value(val) {
|
|
217
|
+
if (this._state && !this._state.writable) return sync_resolve(err("Not writable"));
|
|
218
|
+
return sync_resolve(ok(val));
|
|
219
|
+
}
|
|
220
|
+
/**Function to update value*/
|
|
221
|
+
async set_value_limit(val) {
|
|
222
|
+
const limited = await this.limit_value(val);
|
|
223
|
+
if (limited.err) {
|
|
224
|
+
this.warn(limited.error);
|
|
225
|
+
return limited;
|
|
226
|
+
}
|
|
227
|
+
return this.#set_value(limited.value);
|
|
228
|
+
}
|
|
229
|
+
/**Function to update value*/
|
|
230
|
+
async set_value_check(val) {
|
|
231
|
+
const checked = await this.check_value(val);
|
|
232
|
+
if (checked.err) {
|
|
233
|
+
this.warn(checked.error);
|
|
234
|
+
return checked;
|
|
235
|
+
}
|
|
236
|
+
return this.#set_value(checked.value);
|
|
237
|
+
}
|
|
238
|
+
/**Shows the value and writes it to the state, a value the state rejects is reverted and warned about.
|
|
239
|
+
* The change listener is only called with accepted values*/
|
|
240
|
+
async #set_value(val) {
|
|
241
|
+
this.new_value(val);
|
|
242
|
+
if (this._buffer === val) return ok(val);
|
|
243
|
+
if (this._state) {
|
|
244
|
+
const buff = this._buffer;
|
|
245
|
+
const written = await this._state.write(val);
|
|
246
|
+
if (written.err) {
|
|
247
|
+
if (buff !== void 0) this.new_value(buff);
|
|
248
|
+
this.warn(written.error);
|
|
249
|
+
return err(written.error);
|
|
250
|
+
}
|
|
251
|
+
} else {
|
|
252
|
+
this._buffer = val;
|
|
253
|
+
this.#changed = true;
|
|
254
|
+
}
|
|
255
|
+
this.call_change(val);
|
|
256
|
+
return ok(val);
|
|
257
|
+
}
|
|
258
|
+
/**Calls the change listener with a value the user changed, and lets a parent group know*/
|
|
259
|
+
call_change(val) {
|
|
260
|
+
if (this.#change) try {
|
|
261
|
+
this.#change(val);
|
|
262
|
+
} catch (e) {
|
|
263
|
+
console.error("Failed while updating change listener", e);
|
|
264
|
+
}
|
|
265
|
+
const parent = this.parentElement;
|
|
266
|
+
if (this.form_id !== void 0 && parent instanceof FormValueWrite) parent.child_changed(this);
|
|
267
|
+
}
|
|
268
|
+
/**Called when a child value element with a form id was changed by the user*/
|
|
269
|
+
child_changed(_child) {}
|
|
270
|
+
};
|
|
271
|
+
// form/boolean/button/button.ts
|
|
272
|
+
var FormButton = class extends FormValueWrite {
|
|
273
|
+
static element_name() {
|
|
274
|
+
return "button";
|
|
275
|
+
}
|
|
276
|
+
static element_name_space() {
|
|
277
|
+
return "form";
|
|
278
|
+
}
|
|
279
|
+
#text = this.appendChild(document.createElement("span"));
|
|
280
|
+
#on_click;
|
|
281
|
+
#toggle;
|
|
282
|
+
#icon;
|
|
283
|
+
constructor(id) {
|
|
284
|
+
super(id);
|
|
285
|
+
this.appendChild(this.warn_input);
|
|
286
|
+
this.setAttribute("tabindex", "0");
|
|
287
|
+
this.onclick = () => {
|
|
288
|
+
if (this.#on_click) this.#on_click();
|
|
289
|
+
};
|
|
290
|
+
this.onpointerdown = (e) => {
|
|
291
|
+
if (e.pointerType !== "touch" && e.button === 0) {
|
|
292
|
+
e.stopPropagation();
|
|
293
|
+
this.setPointerCapture(e.pointerId);
|
|
294
|
+
if (!this.#toggle) this.set_value_check(true);
|
|
295
|
+
this.onpointerup = (ev) => {
|
|
296
|
+
ev.stopPropagation();
|
|
297
|
+
this.releasePointerCapture(ev.pointerId);
|
|
298
|
+
if (this.#toggle) this.set_value_check(!this.buffer);
|
|
299
|
+
else this.set_value_check(false);
|
|
300
|
+
this.onpointerup = null;
|
|
301
|
+
this.onpointercancel = null;
|
|
302
|
+
};
|
|
303
|
+
this.onpointercancel = (ev) => {
|
|
304
|
+
this.releasePointerCapture(ev.pointerId);
|
|
305
|
+
if (!this.#toggle) this.set_value_check(false);
|
|
306
|
+
this.onpointerup = null;
|
|
307
|
+
this.onpointercancel = null;
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
this.ontouchstart = (e) => {
|
|
312
|
+
e.stopPropagation();
|
|
313
|
+
if (!this.#toggle) this.set_value_check(true);
|
|
314
|
+
this.ontouchend = (ev) => {
|
|
315
|
+
ev.stopPropagation();
|
|
316
|
+
if (ev.targetTouches.length === 0) {
|
|
317
|
+
if (this.#toggle) this.set_value_check(!this.buffer);
|
|
318
|
+
else this.set_value_check(false);
|
|
319
|
+
this.ontouchend = null;
|
|
320
|
+
this.ontouchcancel = null;
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
this.ontouchcancel = () => {
|
|
324
|
+
if (!this.#toggle) this.set_value_check(false);
|
|
325
|
+
this.ontouchend = null;
|
|
326
|
+
this.ontouchcancel = null;
|
|
327
|
+
};
|
|
328
|
+
};
|
|
329
|
+
this.onkeydown = (e) => {
|
|
330
|
+
switch (e.key) {
|
|
331
|
+
case " ":
|
|
332
|
+
case "Enter":
|
|
333
|
+
e.stopPropagation();
|
|
334
|
+
e.preventDefault();
|
|
335
|
+
if (!this.#toggle) this.set_value_check(true);
|
|
336
|
+
this.onkeyup = (e) => {
|
|
337
|
+
switch (e.key) {
|
|
338
|
+
case "Enter":
|
|
339
|
+
case " ":
|
|
340
|
+
e.stopPropagation();
|
|
341
|
+
e.preventDefault();
|
|
342
|
+
this.onkeyup = null;
|
|
343
|
+
if (this.#toggle) this.set_value_check(!this.buffer);
|
|
344
|
+
else this.set_value_check(false);
|
|
345
|
+
if (this.#on_click) this.#on_click();
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
focus(options) {
|
|
352
|
+
HTMLElement.prototype.focus.call(this, options);
|
|
353
|
+
}
|
|
354
|
+
/**Sets the current text of the button*/
|
|
355
|
+
set text(label) {
|
|
356
|
+
this.#text.textContent = label;
|
|
357
|
+
}
|
|
358
|
+
get text() {
|
|
359
|
+
return this.#text.textContent;
|
|
360
|
+
}
|
|
361
|
+
/**Changes the icon of the button*/
|
|
362
|
+
set icon(icon) {
|
|
363
|
+
if (this.#icon) this.removeChild(this.#icon);
|
|
364
|
+
this.#icon = icon ? this.insertBefore(icon(), this.#text) : void 0;
|
|
365
|
+
}
|
|
366
|
+
/**Function to call on button click*/
|
|
367
|
+
set on_click(func) {
|
|
368
|
+
this.#on_click = func;
|
|
369
|
+
}
|
|
370
|
+
get on_click() {
|
|
371
|
+
return this.#on_click;
|
|
372
|
+
}
|
|
373
|
+
/**Changes the color of the button*/
|
|
374
|
+
set color(color) {
|
|
375
|
+
if (color === FormColors.None) this.removeAttribute("color");
|
|
376
|
+
else this.setAttribute("color", color);
|
|
377
|
+
}
|
|
378
|
+
/**Centers text and icon */
|
|
379
|
+
set center(center) {
|
|
380
|
+
if (center) this.classList.add("center");
|
|
381
|
+
else this.classList.remove("center");
|
|
382
|
+
}
|
|
383
|
+
get center() {
|
|
384
|
+
return this.classList.contains("center");
|
|
385
|
+
}
|
|
386
|
+
/**Called when value is changed */
|
|
387
|
+
new_value(value) {
|
|
388
|
+
if (value) this.classList.add("active");
|
|
389
|
+
else this.classList.remove("active");
|
|
390
|
+
}
|
|
391
|
+
clear_value() {
|
|
392
|
+
this.new_value(false);
|
|
393
|
+
}
|
|
394
|
+
new_error(err) {
|
|
395
|
+
console.error("TODO", err);
|
|
396
|
+
}
|
|
397
|
+
clear_error() {}
|
|
398
|
+
state_related(_related) {}
|
|
399
|
+
/**Changes whether the button is maintained or momentary*/
|
|
400
|
+
set toggle(toggle) {
|
|
401
|
+
this.#toggle = Boolean(toggle);
|
|
402
|
+
}
|
|
403
|
+
get toggle() {
|
|
404
|
+
return this.#toggle;
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
define_element(FormButton);
|
|
408
|
+
/**Creates a button form element */
|
|
409
|
+
function form_button(options) {
|
|
410
|
+
const butt = new FormButton(options?.id);
|
|
411
|
+
if (options) {
|
|
412
|
+
if (options.text) butt.text = options.text;
|
|
413
|
+
if (options.icon) butt.icon = options.icon;
|
|
414
|
+
if (options.on_click) butt.on_click = options.on_click;
|
|
415
|
+
if (options.toggle) butt.toggle = options.toggle;
|
|
416
|
+
if (options.color) butt.color = options.color;
|
|
417
|
+
if (options.center) butt.center = options.center;
|
|
418
|
+
FormValueWrite.apply_options(butt, options);
|
|
419
|
+
}
|
|
420
|
+
return butt;
|
|
421
|
+
}
|
|
422
|
+
// form/boolean/lamp/lamp.ts
|
|
423
|
+
var FormLamp = class extends FormValue {
|
|
424
|
+
static element_name() {
|
|
425
|
+
return "lamp";
|
|
426
|
+
}
|
|
427
|
+
static element_name_space() {
|
|
428
|
+
return "form";
|
|
429
|
+
}
|
|
430
|
+
#text = this.appendChild(document.createElement("span"));
|
|
431
|
+
#icon;
|
|
432
|
+
#colors = [];
|
|
433
|
+
/**Sets the current text of the lamp*/
|
|
434
|
+
set text(label) {
|
|
435
|
+
this.#text.textContent = label;
|
|
436
|
+
}
|
|
437
|
+
get text() {
|
|
438
|
+
return this.#text.textContent;
|
|
439
|
+
}
|
|
440
|
+
/**Changes the icon of the lamp*/
|
|
441
|
+
set icon(icon) {
|
|
442
|
+
if (this.#icon) this.removeChild(this.#icon);
|
|
443
|
+
this.#icon = icon ? this.insertBefore(icon(), this.#text) : void 0;
|
|
444
|
+
}
|
|
445
|
+
/** Sets the background color of the lamp*/
|
|
446
|
+
set colors(colors) {
|
|
447
|
+
this.#colors = colors;
|
|
448
|
+
this.new_value(this.buffer);
|
|
449
|
+
}
|
|
450
|
+
/**Centers text and icon */
|
|
451
|
+
set center(center) {
|
|
452
|
+
if (center) this.classList.add("center");
|
|
453
|
+
else this.classList.remove("center");
|
|
454
|
+
}
|
|
455
|
+
get center() {
|
|
456
|
+
return this.classList.contains("center");
|
|
457
|
+
}
|
|
458
|
+
/**Called when value is changed */
|
|
459
|
+
new_value(value) {
|
|
460
|
+
const color = this.#colors[Number(value)];
|
|
461
|
+
if (color) this.setAttribute("color", color);
|
|
462
|
+
else this.removeAttribute("color");
|
|
463
|
+
}
|
|
464
|
+
clear_value() {
|
|
465
|
+
this.removeAttribute("color");
|
|
466
|
+
}
|
|
467
|
+
new_error(err) {
|
|
468
|
+
console.error(err);
|
|
469
|
+
}
|
|
470
|
+
clear_error() {}
|
|
471
|
+
state_related(_related) {}
|
|
472
|
+
};
|
|
473
|
+
define_element(FormLamp);
|
|
474
|
+
function from(options) {
|
|
475
|
+
const lamp = new FormLamp(options?.id);
|
|
476
|
+
if (options) {
|
|
477
|
+
lamp.colors = options.colors;
|
|
478
|
+
if (options.text) lamp.text = options.text;
|
|
479
|
+
if (options.icon) lamp.icon = options.icon;
|
|
480
|
+
if (options.center) lamp.center = options.center;
|
|
481
|
+
FormValue.apply_options(lamp, options);
|
|
482
|
+
}
|
|
483
|
+
return lamp;
|
|
484
|
+
}
|
|
485
|
+
/**Creates a button form element */
|
|
486
|
+
const form_lamp = from;
|
|
487
|
+
// form/boolean/switch/switch.ts
|
|
488
|
+
var FormSwitch = class extends FormValueWrite {
|
|
489
|
+
static element_name() {
|
|
490
|
+
return "switch";
|
|
491
|
+
}
|
|
492
|
+
static element_name_space() {
|
|
493
|
+
return "form";
|
|
494
|
+
}
|
|
495
|
+
#switch = this.appendChild(document.createElement("div"));
|
|
496
|
+
#icon;
|
|
497
|
+
#prevent_click = false;
|
|
498
|
+
constructor(id) {
|
|
499
|
+
super(id);
|
|
500
|
+
this.appendChild(this.warn_input);
|
|
501
|
+
this.#switch.setAttribute("tabindex", "0");
|
|
502
|
+
this.#switch.onkeydown = (e) => {
|
|
503
|
+
if (e.key !== " ") return;
|
|
504
|
+
e.stopPropagation();
|
|
505
|
+
e.preventDefault();
|
|
506
|
+
this.onkeyup = (e) => {
|
|
507
|
+
if (e.key !== " ") return;
|
|
508
|
+
e.stopPropagation();
|
|
509
|
+
e.preventDefault();
|
|
510
|
+
this.onkeyup = null;
|
|
511
|
+
this.set_value_check(!this.buffer);
|
|
512
|
+
};
|
|
513
|
+
};
|
|
514
|
+
this.#switch.onpointerdown = (e) => {
|
|
515
|
+
if (e.button === 0) {
|
|
516
|
+
e.stopPropagation();
|
|
517
|
+
this.#switch.classList.add("active");
|
|
518
|
+
this.#switch.setPointerCapture(e.pointerId);
|
|
519
|
+
let has_moved = false;
|
|
520
|
+
this.#switch.onpointermove = (ev) => {
|
|
521
|
+
ev.stopPropagation();
|
|
522
|
+
if (has_moved) {
|
|
523
|
+
const box = this.#switch.getBoundingClientRect();
|
|
524
|
+
const mid_cord = box.x + box.width / 2;
|
|
525
|
+
if (ev.clientX > mid_cord) {
|
|
526
|
+
if (!this.buffer) this.set_value_check(true);
|
|
527
|
+
} else if (this.buffer) this.set_value_check(false);
|
|
528
|
+
} else if (Math.abs(e.clientX - ev.clientX) > 10 || Math.abs(e.clientY - ev.clientY) > 10) has_moved = true;
|
|
529
|
+
};
|
|
530
|
+
const release = () => {
|
|
531
|
+
this.#switch.classList.remove("active");
|
|
532
|
+
this.#switch.releasePointerCapture(e.pointerId);
|
|
533
|
+
this.#switch.onpointerup = null;
|
|
534
|
+
this.#switch.onpointermove = null;
|
|
535
|
+
this.#switch.onpointercancel = null;
|
|
536
|
+
};
|
|
537
|
+
this.#switch.onpointerup = (ev) => {
|
|
538
|
+
ev.stopPropagation();
|
|
539
|
+
release();
|
|
540
|
+
if (!has_moved) this.set_value_check(!this.buffer);
|
|
541
|
+
};
|
|
542
|
+
this.#switch.onpointercancel = release;
|
|
543
|
+
}
|
|
544
|
+
};
|
|
545
|
+
this.#switch.onclick = (e) => e.stopPropagation();
|
|
546
|
+
this.onclick = (e) => {
|
|
547
|
+
e.stopPropagation();
|
|
548
|
+
if (this.#prevent_click) return this.#prevent_click = false;
|
|
549
|
+
this.set_value_check(!this.buffer);
|
|
550
|
+
};
|
|
551
|
+
}
|
|
552
|
+
/**Focuses the knob, the input for warnings is hidden and can not take the focus*/
|
|
553
|
+
focus(options) {
|
|
554
|
+
this.#switch.focus(options);
|
|
555
|
+
}
|
|
556
|
+
/**Changes the icon of the switch*/
|
|
557
|
+
set icon(icon) {
|
|
558
|
+
if (this.#icon) this.removeChild(this.#icon);
|
|
559
|
+
this.#icon = icon ? this.insertBefore(icon(), this.#switch) : void 0;
|
|
560
|
+
}
|
|
561
|
+
set on_color(color) {
|
|
562
|
+
if (color === FormColors.None) this.#switch.removeAttribute("on-color");
|
|
563
|
+
else this.#switch.setAttribute("on-color", color);
|
|
564
|
+
}
|
|
565
|
+
set off_color(color) {
|
|
566
|
+
if (color === FormColors.None) this.#switch.removeAttribute("off-color");
|
|
567
|
+
else this.#switch.setAttribute("off-color", color);
|
|
568
|
+
}
|
|
569
|
+
set error_color(color) {
|
|
570
|
+
if (color === FormColors.None) this.#switch.removeAttribute("error-color");
|
|
571
|
+
else this.#switch.setAttribute("error-color", color);
|
|
572
|
+
}
|
|
573
|
+
/**Called when value is changed */
|
|
574
|
+
new_value(value) {
|
|
575
|
+
if (value) this.#switch.classList.add("on");
|
|
576
|
+
else this.#switch.classList.remove("on");
|
|
577
|
+
}
|
|
578
|
+
clear_value() {
|
|
579
|
+
this.new_value(false);
|
|
580
|
+
}
|
|
581
|
+
new_error(_err) {
|
|
582
|
+
this.#switch.classList.add("error");
|
|
583
|
+
}
|
|
584
|
+
clear_error() {
|
|
585
|
+
this.#switch.classList.remove("error");
|
|
586
|
+
}
|
|
587
|
+
state_related(_related) {}
|
|
588
|
+
};
|
|
589
|
+
define_element(FormSwitch);
|
|
590
|
+
/**Creates a switch form element */
|
|
591
|
+
function form_switch(options) {
|
|
592
|
+
const swit = new FormSwitch(options?.id);
|
|
593
|
+
if (options) {
|
|
594
|
+
if (options.icon) swit.icon = options.icon;
|
|
595
|
+
if (options.on_color) swit.on_color = options.on_color;
|
|
596
|
+
if (options.off_color) swit.off_color = options.off_color;
|
|
597
|
+
FormValueWrite.apply_options(swit, options);
|
|
598
|
+
}
|
|
599
|
+
return swit;
|
|
600
|
+
}
|
|
601
|
+
// form/group/group_base.ts
|
|
602
|
+
/**Different border styles for the component group*/
|
|
603
|
+
const FormGroupBorderStyle = {
|
|
604
|
+
None: "none",
|
|
605
|
+
Inset: "inset",
|
|
606
|
+
Outset: "outset",
|
|
607
|
+
Line: "line"
|
|
608
|
+
};
|
|
609
|
+
var FormGroupBase = class extends FormValueWrite {
|
|
610
|
+
static element_name() {
|
|
611
|
+
return "@abstract@";
|
|
612
|
+
}
|
|
613
|
+
static element_name_space() {
|
|
614
|
+
return "form";
|
|
615
|
+
}
|
|
616
|
+
_value_elements = /* @__PURE__ */ new Map();
|
|
617
|
+
/**Returns form elements indexed by their form IDs*/
|
|
618
|
+
get value_elements() {
|
|
619
|
+
return Object.fromEntries(this._value_elements);
|
|
620
|
+
}
|
|
621
|
+
/**This places the group at an absolute position in one of the corners of the container*/
|
|
622
|
+
set border(border) {
|
|
623
|
+
this.classList.remove(FormGroupBorderStyle.Inset, FormGroupBorderStyle.Outset, FormGroupBorderStyle.Line);
|
|
624
|
+
if (border && border !== FormGroupBorderStyle.None) this.classList.add(border);
|
|
625
|
+
}
|
|
626
|
+
set max_height(height) {
|
|
627
|
+
this.style.setProperty("--max_height", height ? height + "rem" : "none");
|
|
628
|
+
if (height) this.classList.add("max_height");
|
|
629
|
+
else this.classList.remove("max_height");
|
|
630
|
+
}
|
|
631
|
+
set embed(embed) {
|
|
632
|
+
if (embed) this.classList.add("embed");
|
|
633
|
+
else this.classList.remove("embed");
|
|
634
|
+
}
|
|
635
|
+
set value(val) {
|
|
636
|
+
super.value = val;
|
|
637
|
+
}
|
|
638
|
+
/**Returns value of the group, returning err if any component has no value*/
|
|
639
|
+
get get_value() {
|
|
640
|
+
if (this._state) return err("State based component");
|
|
641
|
+
const result = {};
|
|
642
|
+
for (const [key, comp] of this._value_elements) {
|
|
643
|
+
const val = comp.get_value;
|
|
644
|
+
if (val.err) return err("Component with id " + key + " has no value");
|
|
645
|
+
result[key] = val.value;
|
|
646
|
+
}
|
|
647
|
+
return ok(result);
|
|
648
|
+
}
|
|
649
|
+
/**Returns partial value of the group, containing all values of components that have values*/
|
|
650
|
+
get value_partial() {
|
|
651
|
+
if (this._state) return err("State based component");
|
|
652
|
+
return ok(this.#partial());
|
|
653
|
+
}
|
|
654
|
+
#partial() {
|
|
655
|
+
const result = {};
|
|
656
|
+
for (const [key, comp] of this._value_elements) {
|
|
657
|
+
const val = comp.get_value;
|
|
658
|
+
if (val.err) continue;
|
|
659
|
+
result[key] = val.value;
|
|
660
|
+
}
|
|
661
|
+
return result;
|
|
662
|
+
}
|
|
663
|
+
/**The change listener of the group gets the values of all components that have values*/
|
|
664
|
+
child_changed(child) {
|
|
665
|
+
if (this._value_elements.get(child.form_id) === child) this.call_change(this.#partial());
|
|
666
|
+
}
|
|
667
|
+
/**Returns partial value of the group, only containing values of components where value has changed*/
|
|
668
|
+
get value_changed() {
|
|
669
|
+
if (this._state) return err("State based component");
|
|
670
|
+
const result = {};
|
|
671
|
+
for (const [key, comp] of this._value_elements) {
|
|
672
|
+
const val = comp.get_value;
|
|
673
|
+
if (val.err) continue;
|
|
674
|
+
if (comp.changed) result[key] = val.value;
|
|
675
|
+
}
|
|
676
|
+
return ok(result);
|
|
677
|
+
}
|
|
678
|
+
new_value(val) {
|
|
679
|
+
for (const key in val) if (this._value_elements.has(key)) this._value_elements.get(key).value = val[key];
|
|
680
|
+
}
|
|
681
|
+
clear_value() {
|
|
682
|
+
for (const comp of this._value_elements.values()) comp.clear();
|
|
683
|
+
}
|
|
684
|
+
new_error(err) {
|
|
685
|
+
console.error(err);
|
|
686
|
+
}
|
|
687
|
+
clear_error() {}
|
|
688
|
+
state_related(_related) {}
|
|
689
|
+
on_access(access) {
|
|
690
|
+
switch (access) {
|
|
691
|
+
case AccessTypes.Read:
|
|
692
|
+
this.tabIndex = 0;
|
|
693
|
+
this.onfocus = () => document.body.focus();
|
|
694
|
+
break;
|
|
695
|
+
case AccessTypes.Write:
|
|
696
|
+
this.removeAttribute("tabIndex");
|
|
697
|
+
this.onfocus = null;
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
};
|
|
701
|
+
// form/group/group.ts
|
|
702
|
+
/**Component group class which allows to add elements and controls the flow of the elements*/
|
|
703
|
+
var FormGroup = class extends FormGroupBase {
|
|
704
|
+
static element_name() {
|
|
705
|
+
return "group";
|
|
706
|
+
}
|
|
707
|
+
static element_name_space() {
|
|
708
|
+
return "form";
|
|
709
|
+
}
|
|
710
|
+
constructor(id) {
|
|
711
|
+
super(id);
|
|
712
|
+
this.classList.add("flex-col");
|
|
713
|
+
}
|
|
714
|
+
set column(column) {
|
|
715
|
+
this.classList.remove("grid-row", "grid-col", "flex-row", "flex-col");
|
|
716
|
+
if (column === true) this.classList.add("flex-col");
|
|
717
|
+
else {
|
|
718
|
+
this.classList.add("grid-col");
|
|
719
|
+
if (typeof column === "string") this.style.gridTemplateColumns = "repeat(auto-fit, minmax(" + column + ", 1fr))";
|
|
720
|
+
else this.style.gridTemplateColumns = column.map((col) => "minmax(" + col + ", 1fr)").join(" ");
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
set row(row) {
|
|
724
|
+
this.classList.remove("grid-row", "grid-col", "flex-row", "flex-col");
|
|
725
|
+
if (row === true) this.classList.add("flex-row");
|
|
726
|
+
else {
|
|
727
|
+
this.classList.add("grid-row");
|
|
728
|
+
if (typeof row === "string") this.style.gridTemplateRows = "repeat(auto-fit, minmax(" + row + ", 1fr))";
|
|
729
|
+
else this.style.gridTemplateRows = row.map((col) => "minmax(" + col + ", 1fr)").join(" ");
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
#elements = [];
|
|
733
|
+
set elements(elements) {
|
|
734
|
+
for (let i = 0, n = elements.length; i < n; i++) {
|
|
735
|
+
const comp = elements[i];
|
|
736
|
+
if (comp instanceof FormValueWrite && comp.form_id) {
|
|
737
|
+
if (this._value_elements.has(comp.form_id)) {
|
|
738
|
+
console.error("Form element with form id " + comp.form_id + " already exists in group");
|
|
739
|
+
continue;
|
|
740
|
+
}
|
|
741
|
+
this._value_elements.set(comp.form_id, comp);
|
|
742
|
+
}
|
|
743
|
+
this.#elements.push(this.appendChild(comp));
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
/**All elements added to the group, also those without a form id*/
|
|
747
|
+
get elements() {
|
|
748
|
+
return [...this.#elements];
|
|
749
|
+
}
|
|
750
|
+
};
|
|
751
|
+
define_element(FormGroup);
|
|
752
|
+
/**Creates a form group with elements */
|
|
753
|
+
function form_group(options) {
|
|
754
|
+
const group = new FormGroup(options?.id);
|
|
755
|
+
if (options) {
|
|
756
|
+
if (options.border) group.border = options.border;
|
|
757
|
+
if (options.elements) group.elements = options.elements;
|
|
758
|
+
if (options.max_height) group.max_height = options.max_height;
|
|
759
|
+
if (options.embed) group.embed = options.embed;
|
|
760
|
+
if (options.column) group.column = options.column;
|
|
761
|
+
else if (options.row) group.row = options.row;
|
|
762
|
+
FormValueWrite.apply_options(group, options);
|
|
763
|
+
}
|
|
764
|
+
return group;
|
|
765
|
+
}
|
|
766
|
+
// form/group/group_collapser.ts
|
|
767
|
+
const opened_text = document.createElement("span");
|
|
768
|
+
opened_text.textContent = "Collapse";
|
|
769
|
+
const closed_text = document.createElement("span");
|
|
770
|
+
closed_text.textContent = "Expand";
|
|
771
|
+
/**Component group class which allows to add elements and controls the flow of the elements*/
|
|
772
|
+
var FormGroupCollapser = class extends FormElement {
|
|
773
|
+
static element_name() {
|
|
774
|
+
return "group-collapser";
|
|
775
|
+
}
|
|
776
|
+
static element_name_space() {
|
|
777
|
+
return "form";
|
|
778
|
+
}
|
|
779
|
+
#group;
|
|
780
|
+
#collapse_button;
|
|
781
|
+
#collapsed = false;
|
|
782
|
+
/**Running collapse or open animation, cancelled when the other one starts*/
|
|
783
|
+
#animation;
|
|
784
|
+
#open_text = node_clone(opened_text);
|
|
785
|
+
#close_text = node_clone(closed_text);
|
|
786
|
+
constructor(group, collapsed) {
|
|
787
|
+
super();
|
|
788
|
+
this.#group = this.appendChild(group);
|
|
789
|
+
if (collapsed) {
|
|
790
|
+
this.classList.add("collapsed");
|
|
791
|
+
this.#collapsed = true;
|
|
792
|
+
}
|
|
793
|
+
this.#collapse_button = this.appendChild(document.createElement("span"));
|
|
794
|
+
this.#collapse_button.tabIndex = 0;
|
|
795
|
+
this.#collapse_button.appendChild(collapsed ? this.#close_text : this.#open_text);
|
|
796
|
+
this.#collapse_button.appendChild(collapsed ? material_unfold_more_rounded() : material_unfold_less_rounded());
|
|
797
|
+
this.#collapse_button.onclick = () => this.collapsed = !this.collapsed;
|
|
798
|
+
this.#collapse_button.onkeydown = (e) => {
|
|
799
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
800
|
+
e.preventDefault();
|
|
801
|
+
this.collapsed = !this.collapsed;
|
|
802
|
+
}
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
set group(group) {
|
|
806
|
+
this.replaceChild(group, this.#group);
|
|
807
|
+
this.#group = group;
|
|
808
|
+
}
|
|
809
|
+
get group() {
|
|
810
|
+
return this.#group;
|
|
811
|
+
}
|
|
812
|
+
set collapsed(collapsed) {
|
|
813
|
+
if (collapsed && !this.#collapsed) {
|
|
814
|
+
this.#animation?.cancel();
|
|
815
|
+
this.#collapse_button.replaceChildren(this.#close_text, material_unfold_more_rounded());
|
|
816
|
+
if (ANIMATION_LEVEL.get().value === AnimationLevels.All) {
|
|
817
|
+
this.#group.style.overflowY = "auto";
|
|
818
|
+
const full_height = this.#group.getBoundingClientRect().height + "px";
|
|
819
|
+
this.#animation = this.#group.animate([{ maxHeight: full_height }, {
|
|
820
|
+
maxHeight: "0px",
|
|
821
|
+
paddingBlock: "0px"
|
|
822
|
+
}], {
|
|
823
|
+
duration: ANIMATION_SPEED.get().value,
|
|
824
|
+
easing: "ease-in-out"
|
|
825
|
+
});
|
|
826
|
+
this.#animation.onfinish = () => {
|
|
827
|
+
this.classList.add("collapsed");
|
|
828
|
+
this.#group.style.overflowY = "";
|
|
829
|
+
};
|
|
830
|
+
} else this.classList.add("collapsed");
|
|
831
|
+
} else if (!collapsed && this.#collapsed) {
|
|
832
|
+
this.#animation?.cancel();
|
|
833
|
+
this.classList.remove("collapsed");
|
|
834
|
+
this.#collapse_button.replaceChildren(this.#open_text, material_unfold_less_rounded());
|
|
835
|
+
if (ANIMATION_LEVEL.get().value === AnimationLevels.All) {
|
|
836
|
+
this.#group.style.overflowY = "auto";
|
|
837
|
+
const full_height = this.#group.getBoundingClientRect().height + "px";
|
|
838
|
+
this.#animation = this.#group.animate([{
|
|
839
|
+
maxHeight: "0px",
|
|
840
|
+
paddingBlock: "0px"
|
|
841
|
+
}, { maxHeight: full_height }], {
|
|
842
|
+
duration: ANIMATION_SPEED.get().value,
|
|
843
|
+
easing: "ease-in-out"
|
|
844
|
+
});
|
|
845
|
+
this.#animation.onfinish = () => this.#group.style.overflowY = "";
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
this.#collapsed = collapsed;
|
|
849
|
+
}
|
|
850
|
+
get collapsed() {
|
|
851
|
+
return this.#collapsed;
|
|
852
|
+
}
|
|
853
|
+
set opened_text(text) {
|
|
854
|
+
this.#open_text.textContent = text;
|
|
855
|
+
}
|
|
856
|
+
set closed_text(text) {
|
|
857
|
+
this.#close_text.textContent = text;
|
|
858
|
+
}
|
|
859
|
+
};
|
|
860
|
+
define_element(FormGroupCollapser);
|
|
861
|
+
/**Creates a dropdown form element */
|
|
862
|
+
function form_group_collapser(group, options) {
|
|
863
|
+
const slide = new FormGroupCollapser(group, options?.collapsed);
|
|
864
|
+
if (options) {
|
|
865
|
+
if (options.opened_text) slide.opened_text = options.opened_text;
|
|
866
|
+
if (options.closed_text) slide.closed_text = options.closed_text;
|
|
867
|
+
FormElement.apply_options(slide, options);
|
|
868
|
+
}
|
|
869
|
+
return slide;
|
|
870
|
+
}
|
|
871
|
+
// form/list/list_field.ts
|
|
872
|
+
var ListFormField = class extends ListField {
|
|
873
|
+
static element_name() {
|
|
874
|
+
return "listfield";
|
|
875
|
+
}
|
|
876
|
+
static element_name_space() {
|
|
877
|
+
return "form";
|
|
878
|
+
}
|
|
879
|
+
set element(component) {
|
|
880
|
+
this.replaceChildren(component);
|
|
881
|
+
}
|
|
882
|
+
get element() {
|
|
883
|
+
return this.firstElementChild;
|
|
884
|
+
}
|
|
885
|
+
};
|
|
886
|
+
define_element(ListFormField);
|
|
887
|
+
function form_list_field(element) {
|
|
888
|
+
const field = new ListFormField();
|
|
889
|
+
field.element = element;
|
|
890
|
+
return field;
|
|
891
|
+
}
|
|
892
|
+
// form/number/number_base.ts
|
|
893
|
+
var FormNumberWrite = class extends FormValueWrite {
|
|
894
|
+
static apply_options(element, options) {
|
|
895
|
+
if (options.unit) element.unit = options.unit;
|
|
896
|
+
if (options.decimals) element.decimals = options.decimals;
|
|
897
|
+
if (options.min !== void 0) element.min = options.min;
|
|
898
|
+
if (options.max !== void 0) element.max = options.max;
|
|
899
|
+
if (options.step) element.step = options.step;
|
|
900
|
+
if (options.start) element.start = options.start;
|
|
901
|
+
super.apply_options(element, options);
|
|
902
|
+
}
|
|
903
|
+
/**Related states of the last bound state, a prop is only reset when it followed one of them*/
|
|
904
|
+
#related = {};
|
|
905
|
+
state_related(related) {
|
|
906
|
+
const old = this.#related;
|
|
907
|
+
this.#related = related;
|
|
908
|
+
if (related.min) this.attach_state_to_prop("min", related.min, () => none());
|
|
909
|
+
else if (old.min) this.detach_state_from_prop("min").min = void 0;
|
|
910
|
+
if (related.max) this.attach_state_to_prop("max", related.max, () => none());
|
|
911
|
+
else if (old.max) this.detach_state_from_prop("max").max = void 0;
|
|
912
|
+
if (related.step) this.attach_state_to_prop("step", related.step, () => none());
|
|
913
|
+
else if (old.step) this.detach_state_from_prop("step").step = void 0;
|
|
914
|
+
if (related.start) this.attach_state_to_prop("start", related.start, () => none());
|
|
915
|
+
else if (old.start) this.detach_state_from_prop("start").start = void 0;
|
|
916
|
+
if (related.decimals) this.attach_state_to_prop("decimals", related.decimals, () => none());
|
|
917
|
+
else if (old.decimals) this.detach_state_from_prop("decimals").decimals = void 0;
|
|
918
|
+
if (related.unit) this.attach_state_to_prop("unit", related.unit, () => none());
|
|
919
|
+
else if (old.unit) this.detach_state_from_prop("unit").unit = void 0;
|
|
920
|
+
}
|
|
921
|
+
};
|
|
922
|
+
/**Decimals to show and round to, the given decimals, or without them enough for the step and start*/
|
|
923
|
+
function number_decimals(decimals, step, start) {
|
|
924
|
+
return decimals ?? Math.max(fraction_digits(step), fraction_digits(start));
|
|
925
|
+
}
|
|
926
|
+
/**Amount of decimals needed to show a number, at most 10*/
|
|
927
|
+
function fraction_digits(val) {
|
|
928
|
+
let dec = 0;
|
|
929
|
+
for (let scaled = val; dec < 10; dec++, scaled = val * 10 ** dec) if (Math.abs(scaled - Math.round(scaled)) < 1e-9) break;
|
|
930
|
+
return dec;
|
|
931
|
+
}
|
|
932
|
+
// form/number/number_input/number_input.ts
|
|
933
|
+
var FormNumberInput = class extends FormNumberWrite {
|
|
934
|
+
static element_name() {
|
|
935
|
+
return "numberinput";
|
|
936
|
+
}
|
|
937
|
+
static element_name_space() {
|
|
938
|
+
return "form";
|
|
939
|
+
}
|
|
940
|
+
#unit = "";
|
|
941
|
+
#min = -Infinity;
|
|
942
|
+
#max = Infinity;
|
|
943
|
+
#step = 0;
|
|
944
|
+
#start = 0;
|
|
945
|
+
#decimals_set;
|
|
946
|
+
#decimals = 0;
|
|
947
|
+
/**Text last drawn from a value, and whether the user typed since*/
|
|
948
|
+
#shown = "";
|
|
949
|
+
#edited = false;
|
|
950
|
+
#value_box = this.appendChild(document.createElement("span"));
|
|
951
|
+
#unit_box = this.appendChild(document.createElement("span"));
|
|
952
|
+
#legend = this.appendChild(document.createElement("div"));
|
|
953
|
+
#max_legend = this.#legend.appendChild(document.createElement("span"));
|
|
954
|
+
#min_legend = this.#legend.appendChild(document.createElement("span"));
|
|
955
|
+
constructor(id) {
|
|
956
|
+
super(id);
|
|
957
|
+
this.appendChild(this.warn_input);
|
|
958
|
+
this.#value_box.contentEditable = "true";
|
|
959
|
+
this.onpointerdown = (e) => {
|
|
960
|
+
this.selected = true;
|
|
961
|
+
if (e.target !== this.#value_box) {
|
|
962
|
+
e.preventDefault();
|
|
963
|
+
set_cursor_end(this.#value_box);
|
|
964
|
+
} else this.#value_box.focus();
|
|
965
|
+
};
|
|
966
|
+
this.#value_box.addEventListener("focusin", (e) => {
|
|
967
|
+
e.preventDefault();
|
|
968
|
+
if (this.selected) return;
|
|
969
|
+
set_selection_all(this.#value_box);
|
|
970
|
+
this.selected = true;
|
|
971
|
+
});
|
|
972
|
+
this.#value_box.onblur = () => {
|
|
973
|
+
this.selected = false;
|
|
974
|
+
setTimeout(() => {
|
|
975
|
+
this.#set(false);
|
|
976
|
+
}, 0);
|
|
977
|
+
};
|
|
978
|
+
this.#value_box.oninput = () => this.#edited = true;
|
|
979
|
+
this.onkeydown = (e) => {
|
|
980
|
+
if (e.key === "Enter") this.#set(true);
|
|
981
|
+
else if (e.key === "Escape") {
|
|
982
|
+
if ((this.#value_box.textContent || "") === this.#shown) return;
|
|
983
|
+
if (this.buffer !== void 0) this.new_value(this.buffer);
|
|
984
|
+
else this.clear_value();
|
|
985
|
+
} else if (e.key === "ArrowUp") this.#step_value(true);
|
|
986
|
+
else if (e.key === "ArrowDown") this.#step_value(false);
|
|
987
|
+
else return;
|
|
988
|
+
e.preventDefault();
|
|
989
|
+
e.stopPropagation();
|
|
990
|
+
};
|
|
991
|
+
this.onbeforeinput = (e) => {
|
|
992
|
+
if (e.inputType === "insertParagraph") e.preventDefault();
|
|
993
|
+
else if (e.data) {
|
|
994
|
+
if (!/[\d,.-]/g.test(e.data)) e.preventDefault();
|
|
995
|
+
else if (/[,.]/g.test(e.data) && this.#decimals === 0) e.preventDefault();
|
|
996
|
+
else if (this.#min >= 0 && /-/g.test(e.data)) e.preventDefault();
|
|
997
|
+
}
|
|
998
|
+
};
|
|
999
|
+
}
|
|
1000
|
+
async #set(cur) {
|
|
1001
|
+
const text = this.#value_box.textContent || "";
|
|
1002
|
+
if (!this.#edited && text === this.#shown) {
|
|
1003
|
+
const shown = this.buffer?.toFixed(this.#decimals);
|
|
1004
|
+
if (shown !== void 0 && shown !== text) this.new_value(this.buffer);
|
|
1005
|
+
return;
|
|
1006
|
+
}
|
|
1007
|
+
const sel = get_cursor_position(this.#value_box);
|
|
1008
|
+
const buff = this.buffer;
|
|
1009
|
+
(await this.set_value_check(parseFloat(text.replace(",", ".")) || 0)).map_err(() => {
|
|
1010
|
+
this.new_value(buff || Math.max(Math.min(0, this.#max), this.#min));
|
|
1011
|
+
set_cursor_end(this.#value_box);
|
|
1012
|
+
}).map(() => {
|
|
1013
|
+
if (!cur) return;
|
|
1014
|
+
set_cursor_position(this.#value_box, sel);
|
|
1015
|
+
});
|
|
1016
|
+
}
|
|
1017
|
+
focus(options) {
|
|
1018
|
+
this.#value_box.focus(options);
|
|
1019
|
+
}
|
|
1020
|
+
set unit(unit) {
|
|
1021
|
+
this.#unit = unit || "";
|
|
1022
|
+
this.#unit_box.textContent = this.#unit;
|
|
1023
|
+
}
|
|
1024
|
+
set decimals(dec) {
|
|
1025
|
+
this.#decimals_set = dec;
|
|
1026
|
+
this.#update_decimals();
|
|
1027
|
+
}
|
|
1028
|
+
/**Updates the decimals from the set decimals, step and start, and redraws with them*/
|
|
1029
|
+
#update_decimals() {
|
|
1030
|
+
const dec = number_decimals(this.#decimals_set, this.#step, this.#start);
|
|
1031
|
+
if (dec === this.#decimals) return;
|
|
1032
|
+
this.#decimals = dec;
|
|
1033
|
+
this.#update_min_legend();
|
|
1034
|
+
this.#update_max_lengend();
|
|
1035
|
+
if (this.buffer !== void 0 && !this.selected) this.new_value(this.buffer);
|
|
1036
|
+
}
|
|
1037
|
+
set min(min) {
|
|
1038
|
+
this.#min = min ?? -Infinity;
|
|
1039
|
+
this.#update_min_legend();
|
|
1040
|
+
}
|
|
1041
|
+
#update_min_legend() {
|
|
1042
|
+
this.#min_legend.textContent = this.#min === -Infinity ? "" : "Min:" + this.#min.toFixed(this.#decimals);
|
|
1043
|
+
}
|
|
1044
|
+
set max(max) {
|
|
1045
|
+
this.#max = max ?? Infinity;
|
|
1046
|
+
this.#update_max_lengend();
|
|
1047
|
+
}
|
|
1048
|
+
#update_max_lengend() {
|
|
1049
|
+
this.#max_legend.textContent = this.#max === Infinity ? "" : "Max:" + this.#max.toFixed(this.#decimals);
|
|
1050
|
+
}
|
|
1051
|
+
set step(step) {
|
|
1052
|
+
this.#step = step || 0;
|
|
1053
|
+
this.#update_decimals();
|
|
1054
|
+
}
|
|
1055
|
+
set start(step) {
|
|
1056
|
+
this.#start = step || 0;
|
|
1057
|
+
this.#update_decimals();
|
|
1058
|
+
}
|
|
1059
|
+
new_value(val) {
|
|
1060
|
+
this.#value_box.textContent = this.#shown = val.toFixed(this.#decimals);
|
|
1061
|
+
this.#edited = false;
|
|
1062
|
+
}
|
|
1063
|
+
clear_value() {
|
|
1064
|
+
this.#value_box.textContent = this.#shown = "";
|
|
1065
|
+
this.#edited = false;
|
|
1066
|
+
}
|
|
1067
|
+
new_error(_val) {}
|
|
1068
|
+
clear_error() {}
|
|
1069
|
+
limit_value(val) {
|
|
1070
|
+
let lim = number_step_start_decimal(Math.min(Math.max(val, this.#min), this.#max), this.#step, this.#start, this.#decimals);
|
|
1071
|
+
if (lim < this.#min) lim += this.#step;
|
|
1072
|
+
if (lim > this.#max) lim -= this.#step;
|
|
1073
|
+
return super.limit_value(lim);
|
|
1074
|
+
}
|
|
1075
|
+
check_value(val) {
|
|
1076
|
+
if (val < this.#min) return sync_resolve(err("Minimum value " + this.#min.toFixed(this.#decimals) + this.#unit));
|
|
1077
|
+
if (val > this.#max) return sync_resolve(err("Maximum value " + this.#max.toFixed(this.#decimals) + this.#unit));
|
|
1078
|
+
let lim = number_step_start_decimal(val, this.#step, this.#start, this.#decimals);
|
|
1079
|
+
if (lim < this.#min) lim += this.#step;
|
|
1080
|
+
if (lim > this.#max) lim -= this.#step;
|
|
1081
|
+
return super.check_value(lim);
|
|
1082
|
+
}
|
|
1083
|
+
#step_value(dir) {
|
|
1084
|
+
const step = this.#step || Math.max(this.#decimals ? 10 ** -this.#decimals : 1, Math.floor(Math.abs(this.buffer || 0) / 150));
|
|
1085
|
+
return this.set_value_check((this.buffer || 0) + (dir ? step : -step));
|
|
1086
|
+
}
|
|
1087
|
+
};
|
|
1088
|
+
define_element(FormNumberInput);
|
|
1089
|
+
/**Creates a number input form element */
|
|
1090
|
+
function form_number_input(options) {
|
|
1091
|
+
const input = new FormNumberInput(options?.id);
|
|
1092
|
+
if (options) FormNumberWrite.apply_options(input, options);
|
|
1093
|
+
return input;
|
|
1094
|
+
}
|
|
1095
|
+
// form/number/progress/progress.ts
|
|
1096
|
+
var FormProgress = class extends FormValue {
|
|
1097
|
+
static element_name() {
|
|
1098
|
+
return "progress";
|
|
1099
|
+
}
|
|
1100
|
+
static element_name_space() {
|
|
1101
|
+
return "form";
|
|
1102
|
+
}
|
|
1103
|
+
#min = 0;
|
|
1104
|
+
#max = 100;
|
|
1105
|
+
#span = 100;
|
|
1106
|
+
#decimals = 0;
|
|
1107
|
+
#bar = this.appendChild(document.createElement("div"));
|
|
1108
|
+
#val = this.appendChild(document.createElement("span"));
|
|
1109
|
+
#unit = this.appendChild(document.createElement("span"));
|
|
1110
|
+
/**Set the minimum value*/
|
|
1111
|
+
set min(min) {
|
|
1112
|
+
this.#min = min;
|
|
1113
|
+
this.#span = this.#max - this.#min;
|
|
1114
|
+
this.#redraw();
|
|
1115
|
+
}
|
|
1116
|
+
/**Set the minimum value*/
|
|
1117
|
+
set max(max) {
|
|
1118
|
+
this.#max = max;
|
|
1119
|
+
this.#span = this.#max - this.#min;
|
|
1120
|
+
this.#redraw();
|
|
1121
|
+
}
|
|
1122
|
+
/**Sets the amount of decimals the element can have*/
|
|
1123
|
+
set decimals(dec) {
|
|
1124
|
+
this.#decimals = Math.max(dec ?? 0, 0);
|
|
1125
|
+
this.#redraw();
|
|
1126
|
+
}
|
|
1127
|
+
/**Sets the unit of the element*/
|
|
1128
|
+
set unit(unit) {
|
|
1129
|
+
this.#unit.textContent = unit ?? "";
|
|
1130
|
+
}
|
|
1131
|
+
/**Shows the value again, after a change to how it is shown*/
|
|
1132
|
+
#redraw() {
|
|
1133
|
+
if (this._buffer !== void 0) this.new_value(this._buffer);
|
|
1134
|
+
}
|
|
1135
|
+
new_value(value) {
|
|
1136
|
+
this.#bar.style.width = Math.min(Math.max((value - this.#min) / this.#span * 100, 0), 100) + "%";
|
|
1137
|
+
this.#val.textContent = value.toFixed(this.#decimals);
|
|
1138
|
+
}
|
|
1139
|
+
clear_value() {
|
|
1140
|
+
this.#bar.style.width = "0%";
|
|
1141
|
+
this.#val.textContent = "";
|
|
1142
|
+
}
|
|
1143
|
+
new_error(err) {
|
|
1144
|
+
console.error(err);
|
|
1145
|
+
}
|
|
1146
|
+
clear_error() {}
|
|
1147
|
+
/**Related states of the last bound state, a prop is only reset when it followed one of them*/
|
|
1148
|
+
#related = {};
|
|
1149
|
+
state_related(related) {
|
|
1150
|
+
const old = this.#related;
|
|
1151
|
+
this.#related = related;
|
|
1152
|
+
if (related.min) this.attach_state_to_prop("min", related.min, () => none());
|
|
1153
|
+
else if (old.min) this.detach_state_from_prop("min").min = 0;
|
|
1154
|
+
if (related.max) this.attach_state_to_prop("max", related.max, () => none());
|
|
1155
|
+
else if (old.max) this.detach_state_from_prop("max").max = 100;
|
|
1156
|
+
if (related.decimals) this.attach_state_to_prop("decimals", related.decimals, () => none());
|
|
1157
|
+
else if (old.decimals) this.detach_state_from_prop("decimals").decimals = void 0;
|
|
1158
|
+
if (related.unit) this.attach_state_to_prop("unit", related.unit, () => none());
|
|
1159
|
+
else if (old.unit) this.detach_state_from_prop("unit").unit = void 0;
|
|
1160
|
+
}
|
|
1161
|
+
};
|
|
1162
|
+
define_element(FormProgress);
|
|
1163
|
+
/**Creates a progress form element */
|
|
1164
|
+
function form_progress(options) {
|
|
1165
|
+
const prog = new FormProgress(options?.id);
|
|
1166
|
+
if (options) {
|
|
1167
|
+
if (typeof options.min !== "undefined") prog.min = options.min;
|
|
1168
|
+
if (typeof options.max !== "undefined") prog.max = options.max;
|
|
1169
|
+
prog.decimals = options.decimals;
|
|
1170
|
+
prog.unit = options.unit;
|
|
1171
|
+
FormValue.apply_options(prog, options);
|
|
1172
|
+
}
|
|
1173
|
+
return prog;
|
|
1174
|
+
}
|
|
1175
|
+
// form/number/slider/slider.ts
|
|
1176
|
+
/**Slide Selector, displays all options in a slider*/
|
|
1177
|
+
var FormSlider = class extends FormNumberWrite {
|
|
1178
|
+
static element_name() {
|
|
1179
|
+
return "slider";
|
|
1180
|
+
}
|
|
1181
|
+
static element_name_space() {
|
|
1182
|
+
return "form";
|
|
1183
|
+
}
|
|
1184
|
+
#unit = "";
|
|
1185
|
+
#decimals_set;
|
|
1186
|
+
#decimals = 0;
|
|
1187
|
+
#min = -Infinity;
|
|
1188
|
+
#max = Infinity;
|
|
1189
|
+
#span = Infinity;
|
|
1190
|
+
#step = 0;
|
|
1191
|
+
#start = 0;
|
|
1192
|
+
#live = false;
|
|
1193
|
+
#icon_dec = this.#stepper_func(this.appendChild(material_remove_rounded()), false);
|
|
1194
|
+
#slide = this.appendChild(document.createElement("div"));
|
|
1195
|
+
#legend = this.appendChild(document.createElement("span"));
|
|
1196
|
+
#left_legend = this.#legend.appendChild(document.createElement("span"));
|
|
1197
|
+
#right_legend = this.#legend.appendChild(document.createElement("span"));
|
|
1198
|
+
#icon_inc = this.#stepper_func(this.appendChild(material_add_rounded()), true);
|
|
1199
|
+
#slider = this.#slide.appendChild(document.createElement("div"));
|
|
1200
|
+
#value_box = this.#slider.appendChild(document.createElement("span"));
|
|
1201
|
+
#unit_box = this.#slider.appendChild(document.createElement("span"));
|
|
1202
|
+
constructor(id) {
|
|
1203
|
+
super(id);
|
|
1204
|
+
this.#slider.setAttribute("tabindex", "0");
|
|
1205
|
+
this.appendChild(this.warn_input);
|
|
1206
|
+
this.onpointerdown = (e) => {
|
|
1207
|
+
if (e.button !== 0) return;
|
|
1208
|
+
if (e.pointerType !== "mouse" && !this.#slider.contains(e.target)) return;
|
|
1209
|
+
e.stopPropagation();
|
|
1210
|
+
this.#slider.classList.add("active");
|
|
1211
|
+
this.selected = true;
|
|
1212
|
+
const box = this.#slider.getBoundingClientRect();
|
|
1213
|
+
const offset = this.#slider.contains(e.target) ? e.clientX >= box.x ? e.clientX <= box.x + box.width ? box.x - e.clientX : -box.width : 0 : -box.width / 2;
|
|
1214
|
+
if (this.#min === -Infinity || this.#max === Infinity) {
|
|
1215
|
+
let value = this.buffer || 0;
|
|
1216
|
+
const interval = setInterval(async () => {
|
|
1217
|
+
const val = value += diff / 50;
|
|
1218
|
+
if (this.#live) (await this.set_value_limit(val)).map((v) => value = v);
|
|
1219
|
+
else (await this.limit_value(val)).map((v) => {
|
|
1220
|
+
this.#move_value(v);
|
|
1221
|
+
value = v;
|
|
1222
|
+
});
|
|
1223
|
+
}, 100);
|
|
1224
|
+
let diff = this.#x_to_perc(e.clientX + offset) - 50;
|
|
1225
|
+
this.#move_slide(this.#x_to_perc(e.clientX + offset));
|
|
1226
|
+
this.#slider.setPointerCapture(e.pointerId);
|
|
1227
|
+
this.#slider.onpointermove = (ev) => {
|
|
1228
|
+
ev.stopPropagation();
|
|
1229
|
+
const perc = this.#x_to_perc(ev.clientX + offset);
|
|
1230
|
+
diff = (this.#step || 1) * ((perc - 50) * 2);
|
|
1231
|
+
this.#move_slide(perc);
|
|
1232
|
+
};
|
|
1233
|
+
const reset = () => {
|
|
1234
|
+
this.#slider.classList.remove("active");
|
|
1235
|
+
this.selected = false;
|
|
1236
|
+
this.#slider.releasePointerCapture(e.pointerId);
|
|
1237
|
+
this.#slider.onpointermove = null;
|
|
1238
|
+
this.#slider.onpointerup = null;
|
|
1239
|
+
this.#slider.onpointercancel = null;
|
|
1240
|
+
this.#slider.onkeydown = null;
|
|
1241
|
+
this.#move_slide(50);
|
|
1242
|
+
clearInterval(interval);
|
|
1243
|
+
};
|
|
1244
|
+
this.#slider.onpointerup = (ev) => {
|
|
1245
|
+
ev.stopPropagation();
|
|
1246
|
+
reset();
|
|
1247
|
+
if (!this.#live) this.set_value_limit(value);
|
|
1248
|
+
};
|
|
1249
|
+
this.#slider.onpointercancel = () => {
|
|
1250
|
+
reset();
|
|
1251
|
+
if (this.buffer !== void 0) this.new_value(this.buffer);
|
|
1252
|
+
else this.clear_value();
|
|
1253
|
+
};
|
|
1254
|
+
this.#slider.onkeydown = (e) => {
|
|
1255
|
+
if (e.key === "Escape") {
|
|
1256
|
+
e.preventDefault();
|
|
1257
|
+
e.stopPropagation();
|
|
1258
|
+
reset();
|
|
1259
|
+
if (this.buffer !== void 0) this.new_value(this.buffer);
|
|
1260
|
+
else this.clear_value();
|
|
1261
|
+
}
|
|
1262
|
+
};
|
|
1263
|
+
} else {
|
|
1264
|
+
const value = this.buffer || 0;
|
|
1265
|
+
this.#move_absolute(e.clientX + offset);
|
|
1266
|
+
this.#slider.setPointerCapture(e.pointerId);
|
|
1267
|
+
this.#slider.onpointermove = (ev) => {
|
|
1268
|
+
ev.stopPropagation();
|
|
1269
|
+
this.#move_absolute(ev.clientX + offset);
|
|
1270
|
+
};
|
|
1271
|
+
const reset = () => {
|
|
1272
|
+
this.#slider.classList.remove("active");
|
|
1273
|
+
this.selected = false;
|
|
1274
|
+
this.#slider.releasePointerCapture(e.pointerId);
|
|
1275
|
+
this.#slider.onpointermove = null;
|
|
1276
|
+
this.#slider.onpointerup = null;
|
|
1277
|
+
this.#slider.onpointercancel = null;
|
|
1278
|
+
this.#slider.onkeydown = null;
|
|
1279
|
+
};
|
|
1280
|
+
this.#slider.onpointerup = (ev) => {
|
|
1281
|
+
ev.stopPropagation();
|
|
1282
|
+
reset();
|
|
1283
|
+
this.#move_absolute(ev.clientX + offset, value);
|
|
1284
|
+
};
|
|
1285
|
+
this.#slider.onpointercancel = () => {
|
|
1286
|
+
reset();
|
|
1287
|
+
if (this.buffer !== void 0) this.new_value(this.buffer);
|
|
1288
|
+
else this.clear_value();
|
|
1289
|
+
};
|
|
1290
|
+
this.#slider.onkeydown = (e) => {
|
|
1291
|
+
if (e.key === "Escape") {
|
|
1292
|
+
e.preventDefault();
|
|
1293
|
+
e.stopPropagation();
|
|
1294
|
+
reset();
|
|
1295
|
+
if (this.buffer !== void 0) this.new_value(this.buffer);
|
|
1296
|
+
else this.clear_value();
|
|
1297
|
+
}
|
|
1298
|
+
};
|
|
1299
|
+
}
|
|
1300
|
+
};
|
|
1301
|
+
this.#slide.onkeydown = (e) => {
|
|
1302
|
+
if (e.key === "ArrowRight") this.#step_value(true);
|
|
1303
|
+
else if (e.key === "ArrowLeft") this.#step_value(false);
|
|
1304
|
+
else return;
|
|
1305
|
+
e.preventDefault();
|
|
1306
|
+
e.stopPropagation();
|
|
1307
|
+
};
|
|
1308
|
+
}
|
|
1309
|
+
focus(options) {
|
|
1310
|
+
this.#slider.focus(options);
|
|
1311
|
+
}
|
|
1312
|
+
set unit(unit) {
|
|
1313
|
+
this.#unit = unit || "";
|
|
1314
|
+
this.#unit_box.textContent = this.#unit;
|
|
1315
|
+
}
|
|
1316
|
+
set min(min) {
|
|
1317
|
+
this.#min = min ?? -Infinity;
|
|
1318
|
+
this.#update_min_max();
|
|
1319
|
+
this.#update_min_legend();
|
|
1320
|
+
}
|
|
1321
|
+
#update_min_legend() {
|
|
1322
|
+
this.#left_legend.textContent = this.#min === -Infinity ? "" : "Min:" + this.#min.toFixed(this.#decimals);
|
|
1323
|
+
}
|
|
1324
|
+
set max(max) {
|
|
1325
|
+
this.#max = max ?? Infinity;
|
|
1326
|
+
this.#update_min_max();
|
|
1327
|
+
this.#update_max_legend();
|
|
1328
|
+
}
|
|
1329
|
+
#update_max_legend() {
|
|
1330
|
+
this.#right_legend.textContent = this.#max === Infinity ? "" : this.#max.toFixed(this.#decimals) + ":Max";
|
|
1331
|
+
}
|
|
1332
|
+
#update_min_max() {
|
|
1333
|
+
this.#span = this.#max - this.#min;
|
|
1334
|
+
if (this.#span === Infinity) this.#move_slide(50);
|
|
1335
|
+
else if (this.buffer !== void 0) this.new_value(this.buffer);
|
|
1336
|
+
}
|
|
1337
|
+
set decimals(dec) {
|
|
1338
|
+
this.#decimals_set = dec;
|
|
1339
|
+
this.#update_decimals();
|
|
1340
|
+
}
|
|
1341
|
+
set step(step) {
|
|
1342
|
+
this.#step = step || 0;
|
|
1343
|
+
this.#update_decimals();
|
|
1344
|
+
}
|
|
1345
|
+
set start(step) {
|
|
1346
|
+
this.#start = step || 0;
|
|
1347
|
+
this.#update_decimals();
|
|
1348
|
+
}
|
|
1349
|
+
/**Updates the decimals from the set decimals, step and start, and redraws with them*/
|
|
1350
|
+
#update_decimals() {
|
|
1351
|
+
const dec = number_decimals(this.#decimals_set, this.#step, this.#start);
|
|
1352
|
+
if (dec === this.#decimals) return;
|
|
1353
|
+
this.#decimals = dec;
|
|
1354
|
+
this.#update_min_legend();
|
|
1355
|
+
this.#update_max_legend();
|
|
1356
|
+
if (this.buffer !== void 0 && !this.selected) this.new_value(this.buffer);
|
|
1357
|
+
}
|
|
1358
|
+
/**Set wether the slider is in live mode*/
|
|
1359
|
+
set live(live) {
|
|
1360
|
+
this.#live = live || false;
|
|
1361
|
+
}
|
|
1362
|
+
set icon_decrease(icon) {
|
|
1363
|
+
const old = this.#icon_dec;
|
|
1364
|
+
this.#icon_dec = this.#stepper_func(icon ? icon() : material_remove_rounded(), false);
|
|
1365
|
+
this.replaceChild(this.#icon_dec, old);
|
|
1366
|
+
}
|
|
1367
|
+
set icon_increase(icon) {
|
|
1368
|
+
const old = this.#icon_inc;
|
|
1369
|
+
this.#icon_inc = this.#stepper_func(icon ? icon() : material_add_rounded(), true);
|
|
1370
|
+
this.replaceChild(this.#icon_inc, old);
|
|
1371
|
+
}
|
|
1372
|
+
new_value(value) {
|
|
1373
|
+
this.#move_value(value);
|
|
1374
|
+
this.#move_slide(this.#span === Infinity ? 50 : Math.min(Math.max((-this.#min + value) / this.#span * 100, 0), 100));
|
|
1375
|
+
}
|
|
1376
|
+
clear_value() {
|
|
1377
|
+
this.#value_box.textContent = "";
|
|
1378
|
+
this.#move_slide(50);
|
|
1379
|
+
}
|
|
1380
|
+
new_error(err) {
|
|
1381
|
+
console.error(err);
|
|
1382
|
+
}
|
|
1383
|
+
clear_error() {}
|
|
1384
|
+
limit_value(val) {
|
|
1385
|
+
let lim = number_step_start_decimal(Math.min(Math.max(val, this.#min), this.#max), this.#step, this.#start, this.#decimals);
|
|
1386
|
+
if (lim < this.#min) lim += this.#step;
|
|
1387
|
+
if (lim > this.#max) lim -= this.#step;
|
|
1388
|
+
return super.limit_value(lim);
|
|
1389
|
+
}
|
|
1390
|
+
check_value(val) {
|
|
1391
|
+
if (val < this.#min) return sync_resolve(err("Minimum value " + this.#min.toFixed(this.#decimals) + this.#unit));
|
|
1392
|
+
if (val > this.#max) return sync_resolve(err("Maximum value " + this.#max.toFixed(this.#decimals) + this.#unit));
|
|
1393
|
+
let lim = number_step_start_decimal(val, this.#step, this.#start, this.#decimals);
|
|
1394
|
+
if (lim < this.#min) lim += this.#step;
|
|
1395
|
+
if (lim > this.#max) lim -= this.#step;
|
|
1396
|
+
return super.check_value(lim);
|
|
1397
|
+
}
|
|
1398
|
+
async #move_absolute(x, last) {
|
|
1399
|
+
const perc = this.#x_to_perc(x);
|
|
1400
|
+
if (this.#live) this.set_value_limit(this.#perc_to_value(perc));
|
|
1401
|
+
else if (last === void 0) {
|
|
1402
|
+
const value = await this.limit_value(this.#perc_to_value(perc));
|
|
1403
|
+
if (value.ok) {
|
|
1404
|
+
this.#move_slide((-this.#min + value.value) / this.#span * 100);
|
|
1405
|
+
this.#move_value(value.value);
|
|
1406
|
+
}
|
|
1407
|
+
} else this.set_value_limit(this.#perc_to_value(perc));
|
|
1408
|
+
}
|
|
1409
|
+
#x_to_perc(x) {
|
|
1410
|
+
const box = this.#slide.getBoundingClientRect();
|
|
1411
|
+
return Math.min(100, Math.max(0, (x - box.x) / box.width * 100));
|
|
1412
|
+
}
|
|
1413
|
+
#perc_to_value(perc) {
|
|
1414
|
+
return perc / 100 * this.#span + this.#min;
|
|
1415
|
+
}
|
|
1416
|
+
/**Attaches click action to over time increase speed of stepping when holding step buttons */
|
|
1417
|
+
#stepper_func(icon, dir) {
|
|
1418
|
+
icon.onpointerdown = (e) => {
|
|
1419
|
+
if (e.button === 0) {
|
|
1420
|
+
e.stopPropagation();
|
|
1421
|
+
let interval = 0;
|
|
1422
|
+
let scaler_interval = 0;
|
|
1423
|
+
let scaler = 250;
|
|
1424
|
+
const release = () => {
|
|
1425
|
+
clearInterval(interval);
|
|
1426
|
+
clearInterval(scaler_interval);
|
|
1427
|
+
clearTimeout(timeout);
|
|
1428
|
+
icon.onpointerup = null;
|
|
1429
|
+
icon.onpointercancel = null;
|
|
1430
|
+
icon.releasePointerCapture(e.pointerId);
|
|
1431
|
+
icon.classList.remove("active");
|
|
1432
|
+
};
|
|
1433
|
+
icon.setPointerCapture(e.pointerId);
|
|
1434
|
+
icon.classList.add("active");
|
|
1435
|
+
const timeout = setTimeout(() => {
|
|
1436
|
+
this.#step_value(dir);
|
|
1437
|
+
interval = setInterval(() => this.#step_value(dir), scaler);
|
|
1438
|
+
scaler_interval = setInterval(() => {
|
|
1439
|
+
if (scaler > 20) scaler /= 1.1;
|
|
1440
|
+
clearInterval(interval);
|
|
1441
|
+
interval = setInterval(() => this.#step_value(dir), scaler);
|
|
1442
|
+
}, 1e3);
|
|
1443
|
+
}, 500);
|
|
1444
|
+
icon.onpointerup = () => {
|
|
1445
|
+
if (interval === 0) this.#step_value(dir);
|
|
1446
|
+
release();
|
|
1447
|
+
};
|
|
1448
|
+
icon.onpointercancel = release;
|
|
1449
|
+
}
|
|
1450
|
+
};
|
|
1451
|
+
return icon;
|
|
1452
|
+
}
|
|
1453
|
+
#step_value(dir) {
|
|
1454
|
+
const step = this.#step || Math.max(this.#decimals ? 10 ** -this.#decimals : 1, Math.floor(Math.abs(this.buffer || 0) / 150));
|
|
1455
|
+
return this.set_value_check((this.buffer || 0) + (dir ? step : -step));
|
|
1456
|
+
}
|
|
1457
|
+
#move_slide(perc) {
|
|
1458
|
+
this.#slider.style.left = perc + "%";
|
|
1459
|
+
}
|
|
1460
|
+
#move_value(value) {
|
|
1461
|
+
this.#value_box.textContent = value.toFixed(this.#decimals);
|
|
1462
|
+
}
|
|
1463
|
+
};
|
|
1464
|
+
define_element(FormSlider);
|
|
1465
|
+
/**Creates a dropdown form element */
|
|
1466
|
+
function form_slider(options) {
|
|
1467
|
+
const slide = new FormSlider(options?.id);
|
|
1468
|
+
if (options) {
|
|
1469
|
+
if (options.live) slide.live = options.live;
|
|
1470
|
+
if (options.icon_decrease) slide.icon_decrease = options.icon_decrease;
|
|
1471
|
+
if (options.icon_increase) slide.icon_increase = options.icon_increase;
|
|
1472
|
+
FormNumberWrite.apply_options(slide, options);
|
|
1473
|
+
}
|
|
1474
|
+
return slide;
|
|
1475
|
+
}
|
|
1476
|
+
// form/number/stepper/stepper.ts
|
|
1477
|
+
/**Slide Selector, displays all options in a slider*/
|
|
1478
|
+
var FormStepper = class extends FormNumberWrite {
|
|
1479
|
+
static element_name() {
|
|
1480
|
+
return "stepper";
|
|
1481
|
+
}
|
|
1482
|
+
static element_name_space() {
|
|
1483
|
+
return "form";
|
|
1484
|
+
}
|
|
1485
|
+
#unit = "";
|
|
1486
|
+
#decimals_set;
|
|
1487
|
+
#decimals = 0;
|
|
1488
|
+
/**Text last drawn from a value, and whether the user typed since*/
|
|
1489
|
+
#shown = "";
|
|
1490
|
+
#edited = false;
|
|
1491
|
+
#min = -Infinity;
|
|
1492
|
+
#max = Infinity;
|
|
1493
|
+
#step = 0;
|
|
1494
|
+
#start = 0;
|
|
1495
|
+
#live = false;
|
|
1496
|
+
#icon_dec = this.#stepper_func(this.appendChild(material_remove_rounded()), false);
|
|
1497
|
+
#text = this.appendChild(document.createElement("span"));
|
|
1498
|
+
#icon_inc = this.#stepper_func(this.appendChild(material_add_rounded()), true);
|
|
1499
|
+
#value_box = this.#text.appendChild(document.createElement("span"));
|
|
1500
|
+
#unit_box = this.#text.appendChild(document.createElement("span"));
|
|
1501
|
+
#legend = this.#text.appendChild(document.createElement("span"));
|
|
1502
|
+
#max_legend = this.#legend.appendChild(document.createElement("span"));
|
|
1503
|
+
#min_legend = this.#legend.appendChild(document.createElement("span"));
|
|
1504
|
+
constructor(id) {
|
|
1505
|
+
super(id);
|
|
1506
|
+
this.setAttribute("tabindex", "0");
|
|
1507
|
+
this.appendChild(this.warn_input);
|
|
1508
|
+
this.#value_box.setAttribute("tabindex", "-1");
|
|
1509
|
+
this.#value_box.contentEditable = "true";
|
|
1510
|
+
this.#value_box.onfocus = async () => {
|
|
1511
|
+
this.selected = true;
|
|
1512
|
+
};
|
|
1513
|
+
this.#value_box.onblur = async () => {
|
|
1514
|
+
this.selected = false;
|
|
1515
|
+
await sleep(0);
|
|
1516
|
+
const text = this.#value_box.textContent || "";
|
|
1517
|
+
if (!this.#edited && text === this.#shown) {
|
|
1518
|
+
if (this.buffer !== void 0) this.new_value(this.buffer);
|
|
1519
|
+
} else this.set_value_check(parseFloat(text.replace(",", ".")) || 0);
|
|
1520
|
+
};
|
|
1521
|
+
this.#value_box.oninput = () => this.#edited = true;
|
|
1522
|
+
this.#value_box.onpointerdown = () => {
|
|
1523
|
+
this.selected = true;
|
|
1524
|
+
};
|
|
1525
|
+
let pointer_id;
|
|
1526
|
+
const reset = () => {
|
|
1527
|
+
this.selected = false;
|
|
1528
|
+
this.#value_box.contentEditable = "true";
|
|
1529
|
+
if (pointer_id !== void 0) {
|
|
1530
|
+
this.#text.releasePointerCapture(pointer_id);
|
|
1531
|
+
pointer_id = void 0;
|
|
1532
|
+
}
|
|
1533
|
+
this.#text.onpointermove = null;
|
|
1534
|
+
this.#text.onpointerup = null;
|
|
1535
|
+
this.#text.onpointercancel = null;
|
|
1536
|
+
};
|
|
1537
|
+
this.#text.onpointerdown = (e) => {
|
|
1538
|
+
if (e.button === 0 && !this.selected) {
|
|
1539
|
+
e.stopPropagation();
|
|
1540
|
+
this.selected = true;
|
|
1541
|
+
const initial_val = this.buffer || 0;
|
|
1542
|
+
let moving = false;
|
|
1543
|
+
this.#text.setPointerCapture(e.pointerId);
|
|
1544
|
+
pointer_id = e.pointerId;
|
|
1545
|
+
this.#text.onpointermove = (ev) => {
|
|
1546
|
+
ev.stopPropagation();
|
|
1547
|
+
if (moving) this.#move_diff(initial_val + (ev.clientX - e.clientX) / 10 * (this.#step || 1));
|
|
1548
|
+
else if (Math.abs(e.clientX - ev.clientX) > 5) {
|
|
1549
|
+
this.#value_box.contentEditable = "false";
|
|
1550
|
+
moving = true;
|
|
1551
|
+
}
|
|
1552
|
+
};
|
|
1553
|
+
this.#text.onpointerup = (ev) => {
|
|
1554
|
+
ev.stopPropagation();
|
|
1555
|
+
reset();
|
|
1556
|
+
if (!moving && e.target !== this.#value_box) set_cursor_end(this.#value_box);
|
|
1557
|
+
else if (moving) {
|
|
1558
|
+
this.#move_diff(initial_val + (ev.clientX - e.clientX) / 10 * (this.#step || 1), true);
|
|
1559
|
+
moving = false;
|
|
1560
|
+
}
|
|
1561
|
+
};
|
|
1562
|
+
this.#text.onpointercancel = () => {
|
|
1563
|
+
reset();
|
|
1564
|
+
if (this.buffer !== void 0) this.new_value(this.buffer);
|
|
1565
|
+
else this.clear_value();
|
|
1566
|
+
};
|
|
1567
|
+
}
|
|
1568
|
+
};
|
|
1569
|
+
this.onkeydown = (e) => {
|
|
1570
|
+
if (e.key === "ArrowRight" || e.key === "ArrowLeft") {
|
|
1571
|
+
e.preventDefault();
|
|
1572
|
+
e.stopPropagation();
|
|
1573
|
+
this.#step_value(e.key === "ArrowRight");
|
|
1574
|
+
} else if (e.key === "Escape") {
|
|
1575
|
+
if (pointer_id === void 0 && this.#unchanged()) return;
|
|
1576
|
+
e.preventDefault();
|
|
1577
|
+
e.stopPropagation();
|
|
1578
|
+
reset();
|
|
1579
|
+
if (this.buffer !== void 0) this.new_value(this.buffer);
|
|
1580
|
+
else this.clear_value();
|
|
1581
|
+
} else if (this.ownerDocument.activeElement !== this.#value_box && /[\d,.-]/g.test(e.key)) {
|
|
1582
|
+
this.#value_box.textContent = "";
|
|
1583
|
+
this.#value_box.focus();
|
|
1584
|
+
}
|
|
1585
|
+
};
|
|
1586
|
+
this.#value_box.onkeydown = (e) => {
|
|
1587
|
+
if (e.key === "Enter") HTMLElement.prototype.focus.call(this);
|
|
1588
|
+
else if (e.key === "Escape") {
|
|
1589
|
+
if (this.#unchanged()) return;
|
|
1590
|
+
e.preventDefault();
|
|
1591
|
+
e.stopPropagation();
|
|
1592
|
+
if (this.buffer !== void 0) this.new_value(this.buffer);
|
|
1593
|
+
else this.clear_value();
|
|
1594
|
+
} else if (e.key === "ArrowRight" || e.key === "ArrowLeft") e.stopPropagation();
|
|
1595
|
+
};
|
|
1596
|
+
this.#value_box.onbeforeinput = (e) => {
|
|
1597
|
+
if (e.inputType === "insertParagraph") e.preventDefault();
|
|
1598
|
+
if (e.data) {
|
|
1599
|
+
if (!/[\d,.-]/g.test(e.data)) e.preventDefault();
|
|
1600
|
+
else if (/[,.]/g.test(e.data) && this.#decimals === 0) e.preventDefault();
|
|
1601
|
+
else if (/-/g.test(e.data) && (this.#min >= 0 || this.#value_box.textContent?.includes("-"))) e.preventDefault();
|
|
1602
|
+
}
|
|
1603
|
+
};
|
|
1604
|
+
}
|
|
1605
|
+
/**Whether the text is the one last drawn from the value, nothing typed to revert*/
|
|
1606
|
+
#unchanged() {
|
|
1607
|
+
return (this.#value_box.textContent || "") === this.#shown;
|
|
1608
|
+
}
|
|
1609
|
+
focus(options) {
|
|
1610
|
+
this.#value_box.focus(options);
|
|
1611
|
+
}
|
|
1612
|
+
set unit(unit) {
|
|
1613
|
+
this.#unit = unit || "";
|
|
1614
|
+
this.#unit_box.textContent = this.#unit;
|
|
1615
|
+
}
|
|
1616
|
+
set decimals(dec) {
|
|
1617
|
+
this.#decimals_set = dec;
|
|
1618
|
+
this.#update_decimals();
|
|
1619
|
+
}
|
|
1620
|
+
/**Updates the decimals from the set decimals, step and start, and redraws with them*/
|
|
1621
|
+
#update_decimals() {
|
|
1622
|
+
const dec = number_decimals(this.#decimals_set, this.#step, this.#start);
|
|
1623
|
+
if (dec === this.#decimals) return;
|
|
1624
|
+
this.#decimals = dec;
|
|
1625
|
+
this.#update_min_legend();
|
|
1626
|
+
this.#update_max_lengend();
|
|
1627
|
+
if (this.buffer !== void 0 && !this.selected) this.new_value(this.buffer);
|
|
1628
|
+
}
|
|
1629
|
+
set min(min) {
|
|
1630
|
+
this.#min = min ?? -Infinity;
|
|
1631
|
+
this.#update_min_legend();
|
|
1632
|
+
}
|
|
1633
|
+
#update_min_legend() {
|
|
1634
|
+
this.#min_legend.textContent = this.#min === -Infinity ? "" : "Min:" + this.#min.toFixed(this.#decimals);
|
|
1635
|
+
}
|
|
1636
|
+
set max(max) {
|
|
1637
|
+
this.#max = max ?? Infinity;
|
|
1638
|
+
this.#update_max_lengend();
|
|
1639
|
+
}
|
|
1640
|
+
#update_max_lengend() {
|
|
1641
|
+
this.#max_legend.textContent = this.#max === Infinity ? "" : "Max:" + this.#max.toFixed(this.#decimals);
|
|
1642
|
+
}
|
|
1643
|
+
set step(step) {
|
|
1644
|
+
this.#step = step || 0;
|
|
1645
|
+
this.#update_decimals();
|
|
1646
|
+
}
|
|
1647
|
+
set start(step) {
|
|
1648
|
+
this.#start = step || 0;
|
|
1649
|
+
this.#update_decimals();
|
|
1650
|
+
}
|
|
1651
|
+
/**Set wether the slider is in live mode*/
|
|
1652
|
+
set live(live) {
|
|
1653
|
+
this.#live = live || false;
|
|
1654
|
+
}
|
|
1655
|
+
set icon_decrease(icon) {
|
|
1656
|
+
const old = this.#icon_dec;
|
|
1657
|
+
this.#icon_dec = this.#stepper_func(icon ? icon() : material_remove_rounded(), false);
|
|
1658
|
+
this.replaceChild(this.#icon_dec, old);
|
|
1659
|
+
}
|
|
1660
|
+
set icon_increase(icon) {
|
|
1661
|
+
const old = this.#icon_inc;
|
|
1662
|
+
this.#icon_inc = this.#stepper_func(icon ? icon() : material_add_rounded(), true);
|
|
1663
|
+
this.replaceChild(this.#icon_inc, old);
|
|
1664
|
+
}
|
|
1665
|
+
new_value(value) {
|
|
1666
|
+
this.#value_box.textContent = this.#shown = value.toFixed(this.#decimals);
|
|
1667
|
+
this.#edited = false;
|
|
1668
|
+
}
|
|
1669
|
+
clear_value() {
|
|
1670
|
+
this.#value_box.textContent = this.#shown = "";
|
|
1671
|
+
this.#edited = false;
|
|
1672
|
+
}
|
|
1673
|
+
new_error(err) {
|
|
1674
|
+
console.error(err);
|
|
1675
|
+
}
|
|
1676
|
+
clear_error() {}
|
|
1677
|
+
limit_value(val) {
|
|
1678
|
+
let lim = number_step_start_decimal(Math.min(Math.max(val, this.#min), this.#max), this.#step, this.#start, this.#decimals);
|
|
1679
|
+
if (lim < this.#min) lim += this.#step;
|
|
1680
|
+
if (lim > this.#max) lim -= this.#step;
|
|
1681
|
+
return super.limit_value(lim);
|
|
1682
|
+
}
|
|
1683
|
+
check_value(val) {
|
|
1684
|
+
if (val < this.#min) return sync_resolve(err("Minimum value " + this.#min.toFixed(this.#decimals) + this.#unit));
|
|
1685
|
+
if (val > this.#max) return sync_resolve(err("Maximum value " + this.#max.toFixed(this.#decimals) + this.#unit));
|
|
1686
|
+
let lim = number_step_start_decimal(val, this.#step, this.#start, this.#decimals);
|
|
1687
|
+
if (lim < this.#min) lim += this.#step;
|
|
1688
|
+
if (lim > this.#max) lim -= this.#step;
|
|
1689
|
+
return super.check_value(lim);
|
|
1690
|
+
}
|
|
1691
|
+
/**Moves the value to a position by the mouse x coordinates*/
|
|
1692
|
+
async #move_diff(value, last = false) {
|
|
1693
|
+
if (this.#live) this.set_value_limit(value);
|
|
1694
|
+
else if (last) this.set_value_limit(value);
|
|
1695
|
+
else {
|
|
1696
|
+
const lim = await this.limit_value(value);
|
|
1697
|
+
if (lim.ok) this.#move_value(lim.value);
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1700
|
+
/**Moves the slider to the given percent position*/
|
|
1701
|
+
#move_value(value) {
|
|
1702
|
+
this.#value_box.textContent = value.toFixed(this.#decimals);
|
|
1703
|
+
}
|
|
1704
|
+
/**Attaches click action to over time increase speed of stepping when holding step buttons */
|
|
1705
|
+
#stepper_func(icon, dir) {
|
|
1706
|
+
icon.onpointerdown = (e) => {
|
|
1707
|
+
if (e.button === 0) {
|
|
1708
|
+
e.stopPropagation();
|
|
1709
|
+
let interval = 0;
|
|
1710
|
+
let scaler_interval = 0;
|
|
1711
|
+
let scaler = 250;
|
|
1712
|
+
const release = () => {
|
|
1713
|
+
clearInterval(interval);
|
|
1714
|
+
clearInterval(scaler_interval);
|
|
1715
|
+
clearTimeout(timeout);
|
|
1716
|
+
icon.onpointerup = null;
|
|
1717
|
+
icon.onpointercancel = null;
|
|
1718
|
+
icon.releasePointerCapture(e.pointerId);
|
|
1719
|
+
icon.classList.remove("active");
|
|
1720
|
+
};
|
|
1721
|
+
icon.setPointerCapture(e.pointerId);
|
|
1722
|
+
icon.classList.add("active");
|
|
1723
|
+
const timeout = setTimeout(() => {
|
|
1724
|
+
this.#step_value(dir);
|
|
1725
|
+
interval = setInterval(() => this.#step_value(dir), scaler);
|
|
1726
|
+
scaler_interval = setInterval(() => {
|
|
1727
|
+
if (scaler > 20) scaler /= 1.1;
|
|
1728
|
+
clearInterval(interval);
|
|
1729
|
+
interval = setInterval(() => this.#step_value(dir), scaler);
|
|
1730
|
+
}, 1e3);
|
|
1731
|
+
}, 500);
|
|
1732
|
+
icon.onpointerup = () => {
|
|
1733
|
+
if (interval === 0) this.#step_value(dir);
|
|
1734
|
+
release();
|
|
1735
|
+
};
|
|
1736
|
+
icon.onpointercancel = release;
|
|
1737
|
+
}
|
|
1738
|
+
};
|
|
1739
|
+
return icon;
|
|
1740
|
+
}
|
|
1741
|
+
#step_value(dir) {
|
|
1742
|
+
const step = this.#step || Math.max(this.#decimals ? 10 ** -this.#decimals : 1, Math.floor(Math.abs(this.buffer || 0) / 150));
|
|
1743
|
+
return this.set_value_check((this.buffer || 0) + (dir ? step : -step));
|
|
1744
|
+
}
|
|
1745
|
+
};
|
|
1746
|
+
define_element(FormStepper);
|
|
1747
|
+
/**Creates a dropdown form element */
|
|
1748
|
+
function form_stepper(options) {
|
|
1749
|
+
const slide = new FormStepper(options?.id);
|
|
1750
|
+
if (options) {
|
|
1751
|
+
if (options.live) slide.live = options.live;
|
|
1752
|
+
if (options.icon_decrease) slide.icon_decrease = options.icon_decrease;
|
|
1753
|
+
if (options.icon_increase) slide.icon_increase = options.icon_increase;
|
|
1754
|
+
FormNumberWrite.apply_options(slide, options);
|
|
1755
|
+
}
|
|
1756
|
+
return slide;
|
|
1757
|
+
}
|
|
1758
|
+
// form/selectors/selector_base.ts
|
|
1759
|
+
/**Base for number elements elements*/
|
|
1760
|
+
var FormSelectorBase = class extends FormValueWrite {
|
|
1761
|
+
static apply_options(element, options) {
|
|
1762
|
+
if (options.selections) element.selections = options.selections;
|
|
1763
|
+
super.apply_options(element, options);
|
|
1764
|
+
}
|
|
1765
|
+
#related_list = false;
|
|
1766
|
+
state_related(related) {
|
|
1767
|
+
if (related.list) this.attach_state_to_prop_map("selections", related.list, () => some([]), (val) => {
|
|
1768
|
+
return some(state.e.map(val, (key, val) => {
|
|
1769
|
+
return {
|
|
1770
|
+
text: val.name,
|
|
1771
|
+
value: key,
|
|
1772
|
+
icon: val.icon
|
|
1773
|
+
};
|
|
1774
|
+
}));
|
|
1775
|
+
});
|
|
1776
|
+
else if (this.#related_list) this.detach_state_from_prop("selections").selections = void 0;
|
|
1777
|
+
this.#related_list = !!related.list;
|
|
1778
|
+
}
|
|
1779
|
+
};
|
|
1780
|
+
// form/selectors/drop_down/drop_down.ts
|
|
1781
|
+
/**Dropdown box for selecting between multiple choices in a small space*/
|
|
1782
|
+
var FormDropdown = class extends FormSelectorBase {
|
|
1783
|
+
static element_name() {
|
|
1784
|
+
return "dropdown";
|
|
1785
|
+
}
|
|
1786
|
+
static element_name_space() {
|
|
1787
|
+
return "form";
|
|
1788
|
+
}
|
|
1789
|
+
#map = /* @__PURE__ */ new Map();
|
|
1790
|
+
#values = [];
|
|
1791
|
+
#selected = -1;
|
|
1792
|
+
#icon;
|
|
1793
|
+
#text = this.appendChild(document.createElement("div"));
|
|
1794
|
+
#open = this.appendChild(material_keyboard_arrow_down_rounded());
|
|
1795
|
+
#default = document.createTextNode("Select something");
|
|
1796
|
+
#default_icon;
|
|
1797
|
+
/**Popup of the document the dropdown was opened in*/
|
|
1798
|
+
#box;
|
|
1799
|
+
is_open = false;
|
|
1800
|
+
constructor(id) {
|
|
1801
|
+
super(id);
|
|
1802
|
+
this.#text.append(this.#default);
|
|
1803
|
+
this.appendChild(this.warn_input);
|
|
1804
|
+
this.tabIndex = 0;
|
|
1805
|
+
this.onclick = () => this.open = true;
|
|
1806
|
+
this.onpointerdown = (e) => {
|
|
1807
|
+
if (e.pointerType === "mouse") {
|
|
1808
|
+
this.open = true;
|
|
1809
|
+
e.preventDefault();
|
|
1810
|
+
}
|
|
1811
|
+
};
|
|
1812
|
+
this.onkeydown = (e) => {
|
|
1813
|
+
switch (e.key) {
|
|
1814
|
+
case " ":
|
|
1815
|
+
case "Enter":
|
|
1816
|
+
e.preventDefault();
|
|
1817
|
+
this.open = true;
|
|
1818
|
+
break;
|
|
1819
|
+
case "ArrowDown":
|
|
1820
|
+
case "ArrowUp":
|
|
1821
|
+
e.preventDefault();
|
|
1822
|
+
e.stopPropagation();
|
|
1823
|
+
this.#select_adjacent(e.key === "ArrowDown");
|
|
1824
|
+
}
|
|
1825
|
+
};
|
|
1826
|
+
}
|
|
1827
|
+
focus(options) {
|
|
1828
|
+
HTMLElement.prototype.focus.call(this, options);
|
|
1829
|
+
}
|
|
1830
|
+
/**Gets the default text displayed when nothing has been selected yet */
|
|
1831
|
+
get default() {
|
|
1832
|
+
return this.#default.nodeValue || "";
|
|
1833
|
+
}
|
|
1834
|
+
/**Sets the default text displayed when nothing has been selected yet */
|
|
1835
|
+
set default(def) {
|
|
1836
|
+
this.#default.nodeValue = def;
|
|
1837
|
+
}
|
|
1838
|
+
/**Sets the default text displayed when nothing has been selected yet */
|
|
1839
|
+
set default_icon(def) {
|
|
1840
|
+
this.#default_icon = def;
|
|
1841
|
+
if (def && this.#selected === -1) this.#set_icon = def;
|
|
1842
|
+
}
|
|
1843
|
+
set selections(selections) {
|
|
1844
|
+
this.open = false;
|
|
1845
|
+
if (this.#map.size > 0) {
|
|
1846
|
+
this.#map.clear();
|
|
1847
|
+
this.#values = [];
|
|
1848
|
+
this.#selected = -1;
|
|
1849
|
+
}
|
|
1850
|
+
for (let i = 0; selections && i < selections.length; i++) {
|
|
1851
|
+
const { value, text, icon } = selections[i];
|
|
1852
|
+
this.#map.set(value, {
|
|
1853
|
+
text,
|
|
1854
|
+
icon
|
|
1855
|
+
});
|
|
1856
|
+
this.#values.push(value);
|
|
1857
|
+
}
|
|
1858
|
+
if (this.buffer !== void 0) this.new_value(this.buffer);
|
|
1859
|
+
}
|
|
1860
|
+
set open(open) {
|
|
1861
|
+
if (open && !this.is_open) {
|
|
1862
|
+
const old = this.#open;
|
|
1863
|
+
this.#open = material_unfold_less_rounded();
|
|
1864
|
+
old.replaceWith(this.#open);
|
|
1865
|
+
this.#box = boxes.get(this.ownerDocument) ?? main_box;
|
|
1866
|
+
this.#box.open_menu(this.#map, this, this.buffer);
|
|
1867
|
+
} else if (!open && this.is_open) {
|
|
1868
|
+
const old = this.#open;
|
|
1869
|
+
this.#open = material_keyboard_arrow_down_rounded();
|
|
1870
|
+
old.replaceWith(this.#open);
|
|
1871
|
+
this.#box?.close_menu();
|
|
1872
|
+
}
|
|
1873
|
+
this.is_open = open;
|
|
1874
|
+
}
|
|
1875
|
+
/**Changes the icon of the button*/
|
|
1876
|
+
set #set_icon(icon) {
|
|
1877
|
+
if (icon) {
|
|
1878
|
+
const i = icon();
|
|
1879
|
+
if (this.#icon) this.replaceChild(i, this.#icon);
|
|
1880
|
+
else this.insertBefore(i, this.#text);
|
|
1881
|
+
this.#icon = i;
|
|
1882
|
+
} else if (this.#icon) {
|
|
1883
|
+
this.removeChild(this.#icon);
|
|
1884
|
+
this.#icon = void 0;
|
|
1885
|
+
}
|
|
1886
|
+
}
|
|
1887
|
+
/**Selects the previous or next selection in the element
|
|
1888
|
+
* @param dir false is next true is previous*/
|
|
1889
|
+
#select_adjacent(dir) {
|
|
1890
|
+
const y = Math.min(this.#values.length - 1, Math.max(0, dir ? this.#selected + 1 : this.#selected - 1));
|
|
1891
|
+
if (y !== this.#selected) this.set_value_check(this.#values[y]);
|
|
1892
|
+
}
|
|
1893
|
+
#clear() {
|
|
1894
|
+
this.default_icon = this.#default_icon ? this.#set_icon = this.#default_icon : this.#set_icon = void 0;
|
|
1895
|
+
this.#text.replaceChildren(this.#default);
|
|
1896
|
+
}
|
|
1897
|
+
/**Called when Value is changed */
|
|
1898
|
+
new_value(value) {
|
|
1899
|
+
if (!this.#map.has(value)) {
|
|
1900
|
+
this.#clear();
|
|
1901
|
+
this.#selected = -1;
|
|
1902
|
+
return;
|
|
1903
|
+
}
|
|
1904
|
+
const opt = this.#map.get(value);
|
|
1905
|
+
this.#text.innerText = opt.text;
|
|
1906
|
+
this.#selected = this.#values.indexOf(value);
|
|
1907
|
+
if (opt.icon) this.#set_icon = opt.icon;
|
|
1908
|
+
else this.#set_icon = void 0;
|
|
1909
|
+
}
|
|
1910
|
+
clear_value() {
|
|
1911
|
+
this.#clear();
|
|
1912
|
+
}
|
|
1913
|
+
new_error(_val) {}
|
|
1914
|
+
clear_error() {}
|
|
1915
|
+
warn(message) {
|
|
1916
|
+
setTimeout(() => {
|
|
1917
|
+
super.warn(message);
|
|
1918
|
+
}, 0);
|
|
1919
|
+
}
|
|
1920
|
+
};
|
|
1921
|
+
define_element(FormDropdown);
|
|
1922
|
+
/**Creates a dropdown form element */
|
|
1923
|
+
function form_dropdown(options) {
|
|
1924
|
+
const drop = new FormDropdown(options?.id);
|
|
1925
|
+
if (options) {
|
|
1926
|
+
if (options.default) drop.default = options.default;
|
|
1927
|
+
if (options.default_icon) drop.default_icon = options.default_icon;
|
|
1928
|
+
FormSelectorBase.apply_options(drop, options);
|
|
1929
|
+
}
|
|
1930
|
+
return drop;
|
|
1931
|
+
}
|
|
1932
|
+
var DropDownBox = class extends Base {
|
|
1933
|
+
static element_name() {
|
|
1934
|
+
return "dropdownbox";
|
|
1935
|
+
}
|
|
1936
|
+
static element_name_space() {
|
|
1937
|
+
return "form";
|
|
1938
|
+
}
|
|
1939
|
+
#closer = document.createElement("div");
|
|
1940
|
+
#container = this.appendChild(document.createElement("div"));
|
|
1941
|
+
#scroll = this.#container.appendChild(document.createElement("div"));
|
|
1942
|
+
#table = this.#scroll.appendChild(document.createElement("div"));
|
|
1943
|
+
#dropdown;
|
|
1944
|
+
#focus_out_handler = (e) => {
|
|
1945
|
+
e.preventDefault();
|
|
1946
|
+
e.stopPropagation();
|
|
1947
|
+
if (!e.relatedTarget || !this.contains(e.relatedTarget)) this.close_menu();
|
|
1948
|
+
};
|
|
1949
|
+
#window_resize_handler = () => this.close_menu();
|
|
1950
|
+
#is_open = false;
|
|
1951
|
+
constructor() {
|
|
1952
|
+
super();
|
|
1953
|
+
this.#container.tabIndex = 0;
|
|
1954
|
+
this.#container.onkeydown = (e) => {
|
|
1955
|
+
if (e.key === "Escape") this.close_menu();
|
|
1956
|
+
else if (e.key === "ArrowUp" || e.shiftKey && e.key === "Tab") {
|
|
1957
|
+
const elem = e.target === this.#container ? this.#table.lastElementChild : e.target.previousElementSibling;
|
|
1958
|
+
if (elem) elem.focus();
|
|
1959
|
+
} else if (e.key === "ArrowDown" || e.key === "Tab") {
|
|
1960
|
+
const elem = e.target === this.#container ? this.#table.firstElementChild : e.target.nextElementSibling;
|
|
1961
|
+
if (elem) elem.focus();
|
|
1962
|
+
} else return;
|
|
1963
|
+
e.stopPropagation();
|
|
1964
|
+
e.preventDefault();
|
|
1965
|
+
};
|
|
1966
|
+
this.#closer.appendChild(document.createElement("div")).appendChild(material_close_rounded());
|
|
1967
|
+
this.#closer.appendChild(document.createElement("div")).textContent = "Close";
|
|
1968
|
+
this.#closer.tabIndex = 0;
|
|
1969
|
+
this.#closer.onclick = (e) => {
|
|
1970
|
+
e.stopPropagation();
|
|
1971
|
+
e.preventDefault();
|
|
1972
|
+
this.close_menu();
|
|
1973
|
+
};
|
|
1974
|
+
this.#closer.onkeydown = (e) => {
|
|
1975
|
+
if (e.key === " " || e.key === "Enter") {
|
|
1976
|
+
e.stopPropagation();
|
|
1977
|
+
e.preventDefault();
|
|
1978
|
+
this.close_menu();
|
|
1979
|
+
}
|
|
1980
|
+
};
|
|
1981
|
+
this.addEventListener("focusout", this.#focus_out_handler, { capture: true });
|
|
1982
|
+
}
|
|
1983
|
+
#set_value(value) {
|
|
1984
|
+
if (this.#dropdown) this.#dropdown.set_value_check(value);
|
|
1985
|
+
this.close_menu();
|
|
1986
|
+
}
|
|
1987
|
+
open_menu(map, parent, value) {
|
|
1988
|
+
if (this.#is_open) this.close_menu(false);
|
|
1989
|
+
const inner_height = this.ownerDocument.defaultView?.innerHeight || 0;
|
|
1990
|
+
this.classList.add("open");
|
|
1991
|
+
const bounds = parent.getBoundingClientRect();
|
|
1992
|
+
if (bounds.y + bounds.height / 2 < inner_height / 2) {
|
|
1993
|
+
const top = bounds.y + bounds.height;
|
|
1994
|
+
this.#container.style.top = top + "px";
|
|
1995
|
+
this.#container.style.bottom = "";
|
|
1996
|
+
this.#container.style.maxHeight = inner_height - top - 10 + "px";
|
|
1997
|
+
this.#container.style.flexDirection = "column";
|
|
1998
|
+
} else {
|
|
1999
|
+
const bottom = inner_height - bounds.y;
|
|
2000
|
+
this.#container.style.top = "";
|
|
2001
|
+
this.#container.style.bottom = bottom + "px";
|
|
2002
|
+
this.#container.style.maxHeight = inner_height - bottom - 10 + "px";
|
|
2003
|
+
this.#container.style.flexDirection = "column-reverse";
|
|
2004
|
+
}
|
|
2005
|
+
this.#container.style.left = bounds.x + "px";
|
|
2006
|
+
this.#container.style.width = bounds.width + "px";
|
|
2007
|
+
this.#dropdown = parent;
|
|
2008
|
+
let focus = void 0;
|
|
2009
|
+
this.#table.replaceChildren(...Array.from(map).map(([val, opt]) => {
|
|
2010
|
+
const line = document.createElement("div");
|
|
2011
|
+
const icon = line.appendChild(document.createElement("div"));
|
|
2012
|
+
if (opt.icon) icon.appendChild(opt.icon());
|
|
2013
|
+
const text = line.appendChild(document.createElement("div"));
|
|
2014
|
+
text.textContent = opt.text;
|
|
2015
|
+
line.onpointerup = (e) => {
|
|
2016
|
+
if (e.pointerType !== "touch") this.#set_value(val);
|
|
2017
|
+
};
|
|
2018
|
+
line.onclick = () => this.#set_value(val);
|
|
2019
|
+
line.tabIndex = 0;
|
|
2020
|
+
line.onkeydown = (e) => {
|
|
2021
|
+
if (e.key === " " || e.key === "Enter") {
|
|
2022
|
+
e.preventDefault();
|
|
2023
|
+
this.#set_value(val);
|
|
2024
|
+
}
|
|
2025
|
+
};
|
|
2026
|
+
if (val === value) focus = line;
|
|
2027
|
+
return line;
|
|
2028
|
+
}));
|
|
2029
|
+
const box = this.#scroll.getBoundingClientRect();
|
|
2030
|
+
const box_area = box.width * box.height;
|
|
2031
|
+
const html = this.ownerDocument.documentElement;
|
|
2032
|
+
if (box_area > html.clientWidth * html.clientHeight * .5) this.#table.prepend(this.#closer);
|
|
2033
|
+
if (this.#scroll.scrollHeight > this.#scroll.clientHeight) this.#scroll.classList.add("scroll");
|
|
2034
|
+
else this.#scroll.classList.remove("scroll");
|
|
2035
|
+
if (focus) {
|
|
2036
|
+
focus.focus();
|
|
2037
|
+
focus.classList.add("selected");
|
|
2038
|
+
} else this.#container.focus();
|
|
2039
|
+
this.ownerDocument.defaultView?.addEventListener("resize", this.#window_resize_handler, { passive: true });
|
|
2040
|
+
this.#is_open = true;
|
|
2041
|
+
}
|
|
2042
|
+
close_menu(focus = true) {
|
|
2043
|
+
if (!this.#is_open) return;
|
|
2044
|
+
this.#is_open = false;
|
|
2045
|
+
if (this.#dropdown) this.#dropdown.open = false;
|
|
2046
|
+
this.classList.remove("open");
|
|
2047
|
+
this.#table.replaceChildren();
|
|
2048
|
+
if (this.#dropdown) {
|
|
2049
|
+
if (focus) this.#dropdown.focus();
|
|
2050
|
+
this.#dropdown.is_open = false;
|
|
2051
|
+
}
|
|
2052
|
+
this.ownerDocument.defaultView?.removeEventListener("resize", this.#window_resize_handler);
|
|
2053
|
+
}
|
|
2054
|
+
};
|
|
2055
|
+
define_element(DropDownBox);
|
|
2056
|
+
/**One popup per document, so dropdowns in popout windows open in their own window*/
|
|
2057
|
+
const boxes = /* @__PURE__ */ new Map();
|
|
2058
|
+
const add_box = (doc) => {
|
|
2059
|
+
const box = doc.documentElement.appendChild(new DropDownBox());
|
|
2060
|
+
boxes.set(doc, box);
|
|
2061
|
+
return box;
|
|
2062
|
+
};
|
|
2063
|
+
/**Used for dropdowns in documents not registered with the document handler*/
|
|
2064
|
+
const main_box = add_box(DOCUMENT_HANDLER.main);
|
|
2065
|
+
DOCUMENT_HANDLER.for_documents((doc) => {
|
|
2066
|
+
if (doc !== DOCUMENT_HANDLER.main) add_box(doc);
|
|
2067
|
+
});
|
|
2068
|
+
DOCUMENT_HANDLER.events.on("added", (e) => add_box(e.data));
|
|
2069
|
+
DOCUMENT_HANDLER.events.on("removed", (e) => boxes.delete(e.data));
|
|
2070
|
+
// form/selectors/toggle_button/toggle_button.ts
|
|
2071
|
+
/**Toggle buttons, displays all options in a multi toggler*/
|
|
2072
|
+
var FormToggleButton = class extends FormSelectorBase {
|
|
2073
|
+
/**Returns the name used to define the element*/
|
|
2074
|
+
static element_name() {
|
|
2075
|
+
return "togglebutton";
|
|
2076
|
+
}
|
|
2077
|
+
static element_name_space() {
|
|
2078
|
+
return "form";
|
|
2079
|
+
}
|
|
2080
|
+
#map = /* @__PURE__ */ new Map();
|
|
2081
|
+
#values = [];
|
|
2082
|
+
#selected = -1;
|
|
2083
|
+
focus(options) {
|
|
2084
|
+
this.firstElementChild?.focus(options);
|
|
2085
|
+
}
|
|
2086
|
+
set selections(selections) {
|
|
2087
|
+
if (this.#map.size > 0) {
|
|
2088
|
+
this.#map.clear();
|
|
2089
|
+
this.#values = [];
|
|
2090
|
+
this.#selected = -1;
|
|
2091
|
+
this.replaceChildren();
|
|
2092
|
+
}
|
|
2093
|
+
for (let i = 0; selections && i < selections.length; i++) {
|
|
2094
|
+
const { value } = selections[i];
|
|
2095
|
+
this.#map.set(value, this.#add_selection(selections[i]));
|
|
2096
|
+
this.#values.push(selections[i].value);
|
|
2097
|
+
}
|
|
2098
|
+
if (this.buffer !== void 0) this.new_value(this.buffer);
|
|
2099
|
+
}
|
|
2100
|
+
#add_selection(selection) {
|
|
2101
|
+
const top = this.appendChild(document.createElement("div"));
|
|
2102
|
+
top.tabIndex = 0;
|
|
2103
|
+
const bot = this.appendChild(document.createElement("div"));
|
|
2104
|
+
if (selection.icon) {
|
|
2105
|
+
top.appendChild(selection.icon());
|
|
2106
|
+
bot.textContent = selection.text;
|
|
2107
|
+
} else top.textContent = selection.text;
|
|
2108
|
+
const click = () => {
|
|
2109
|
+
top.appendChild(this.warn_input);
|
|
2110
|
+
this.set_value_check(selection.value);
|
|
2111
|
+
};
|
|
2112
|
+
top.onclick = click;
|
|
2113
|
+
bot.onclick = click;
|
|
2114
|
+
top.onkeydown = (e) => {
|
|
2115
|
+
if (e.key === " " || e.key === "Enter") click();
|
|
2116
|
+
else if (e.key === "ArrowRight") this.#select_adjacent(true);
|
|
2117
|
+
else if (e.key === "ArrowLeft") this.#select_adjacent(false);
|
|
2118
|
+
else return;
|
|
2119
|
+
e.preventDefault();
|
|
2120
|
+
e.stopPropagation();
|
|
2121
|
+
};
|
|
2122
|
+
return {
|
|
2123
|
+
top,
|
|
2124
|
+
bot
|
|
2125
|
+
};
|
|
2126
|
+
}
|
|
2127
|
+
/**Selects the previous or next selection in the element
|
|
2128
|
+
* @param dir false is next true is previous*/
|
|
2129
|
+
#select_adjacent(dir) {
|
|
2130
|
+
const sel = this.#map.get(this.#values[this.#selected]);
|
|
2131
|
+
if (sel) sel.top.appendChild(this.warn_input);
|
|
2132
|
+
const y = Math.min(this.#values.length - 1, Math.max(0, dir ? this.#selected + 1 : this.#selected - 1));
|
|
2133
|
+
if (y !== this.#selected) this.set_value_check(this.#values[y]);
|
|
2134
|
+
}
|
|
2135
|
+
new_value(value) {
|
|
2136
|
+
const prev = this.#map.get(this.#values[this.#selected]);
|
|
2137
|
+
if (prev) {
|
|
2138
|
+
prev.top.classList.remove("selected");
|
|
2139
|
+
prev.bot.classList.remove("selected");
|
|
2140
|
+
}
|
|
2141
|
+
const opt = this.#map.get(value);
|
|
2142
|
+
if (opt) {
|
|
2143
|
+
opt.top.classList.add("selected");
|
|
2144
|
+
opt.bot.classList.add("selected");
|
|
2145
|
+
this.#selected = this.#values.indexOf(value);
|
|
2146
|
+
if (this.contains(document.activeElement)) opt.top.focus();
|
|
2147
|
+
} else this.#selected = -1;
|
|
2148
|
+
}
|
|
2149
|
+
clear_value() {
|
|
2150
|
+
const prev = this.#map.get(this.#values[this.#selected]);
|
|
2151
|
+
if (prev) {
|
|
2152
|
+
prev.top.classList.remove("selected");
|
|
2153
|
+
prev.bot.classList.remove("selected");
|
|
2154
|
+
}
|
|
2155
|
+
this.#selected = -1;
|
|
2156
|
+
}
|
|
2157
|
+
new_error(_val) {}
|
|
2158
|
+
clear_error() {}
|
|
2159
|
+
};
|
|
2160
|
+
define_element(FormToggleButton);
|
|
2161
|
+
/**Creates a toggle button form element */
|
|
2162
|
+
function form_toggle_button(options) {
|
|
2163
|
+
const togg = new FormToggleButton(options?.id);
|
|
2164
|
+
if (options) FormSelectorBase.apply_options(togg, options);
|
|
2165
|
+
return togg;
|
|
2166
|
+
}
|
|
2167
|
+
// form/spacing/spacer.ts
|
|
2168
|
+
var FormSpacer = class extends FormElement {
|
|
2169
|
+
static element_name() {
|
|
2170
|
+
return "spacer";
|
|
2171
|
+
}
|
|
2172
|
+
static element_name_space() {
|
|
2173
|
+
return "form";
|
|
2174
|
+
}
|
|
2175
|
+
constructor() {
|
|
2176
|
+
super();
|
|
2177
|
+
}
|
|
2178
|
+
/**Sets the amount of space, in rem */
|
|
2179
|
+
set space(space) {
|
|
2180
|
+
this.style.height = `${space}rem`;
|
|
2181
|
+
}
|
|
2182
|
+
get space() {
|
|
2183
|
+
return parseFloat(this.style.height);
|
|
2184
|
+
}
|
|
2185
|
+
};
|
|
2186
|
+
define_element(FormSpacer);
|
|
2187
|
+
/**Creates a spacer form element */
|
|
2188
|
+
function form_spacer(options) {
|
|
2189
|
+
const spacer = new FormSpacer();
|
|
2190
|
+
if (options) {
|
|
2191
|
+
if (options.space) spacer.space = options.space;
|
|
2192
|
+
}
|
|
2193
|
+
return spacer;
|
|
2194
|
+
}
|
|
2195
|
+
// form/special/color/color_input.ts
|
|
2196
|
+
var FormColor = class extends FormValueWrite {
|
|
2197
|
+
static element_name() {
|
|
2198
|
+
return "colorinput";
|
|
2199
|
+
}
|
|
2200
|
+
static element_name_space() {
|
|
2201
|
+
return "form";
|
|
2202
|
+
}
|
|
2203
|
+
#live = false;
|
|
2204
|
+
constructor(id) {
|
|
2205
|
+
super(id);
|
|
2206
|
+
this.appendChild(this.warn_input);
|
|
2207
|
+
this.warn_input.type = "color";
|
|
2208
|
+
this.warn_input.oninput = () => {
|
|
2209
|
+
if (this.#live) this.set_value_check(this.warn_input.value);
|
|
2210
|
+
};
|
|
2211
|
+
this.warn_input.onchange = () => {
|
|
2212
|
+
if (!this.#live) this.set_value_check(this.warn_input.value);
|
|
2213
|
+
};
|
|
2214
|
+
}
|
|
2215
|
+
set live(val) {
|
|
2216
|
+
this.#live = val;
|
|
2217
|
+
}
|
|
2218
|
+
get live() {
|
|
2219
|
+
return this.#live;
|
|
2220
|
+
}
|
|
2221
|
+
new_value(val) {
|
|
2222
|
+
this.warn_input.value = val;
|
|
2223
|
+
}
|
|
2224
|
+
clear_value() {
|
|
2225
|
+
this.warn_input.value = "#000000";
|
|
2226
|
+
}
|
|
2227
|
+
new_error(_val) {}
|
|
2228
|
+
clear_error() {}
|
|
2229
|
+
state_related(_related) {}
|
|
2230
|
+
};
|
|
2231
|
+
define_element(FormColor);
|
|
2232
|
+
/**Creates a color input form element */
|
|
2233
|
+
function form_color(options) {
|
|
2234
|
+
const input = new FormColor(options?.id);
|
|
2235
|
+
if (options) {
|
|
2236
|
+
if (options.live) input.live = options.live;
|
|
2237
|
+
FormValueWrite.apply_options(input, options);
|
|
2238
|
+
}
|
|
2239
|
+
return input;
|
|
2240
|
+
}
|
|
2241
|
+
// form/special/date_time/date_time_input.ts
|
|
2242
|
+
const FormDateTimeType = {
|
|
2243
|
+
DATE: "date",
|
|
2244
|
+
TIME: "time",
|
|
2245
|
+
DATETIME: "datetime"
|
|
2246
|
+
};
|
|
2247
|
+
const FormDateTimeMode = {
|
|
2248
|
+
DATE: "date",
|
|
2249
|
+
STRING: "string",
|
|
2250
|
+
NUMBER: "number"
|
|
2251
|
+
};
|
|
2252
|
+
const TIME_ONLY = /^\d{2}:\d{2}/;
|
|
2253
|
+
const DATE_ONLY = /^\d{4}-\d{2}-\d{2}$/;
|
|
2254
|
+
const INPUT_FORMAT = {
|
|
2255
|
+
date: DATE_ONLY,
|
|
2256
|
+
time: /^\d{2}:\d{2}(:\d{2})?$/,
|
|
2257
|
+
datetime: /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2})?$/
|
|
2258
|
+
};
|
|
2259
|
+
/**Returns the wall clock time of a string as UTC milliseconds, like the input uses
|
|
2260
|
+
* Time only strings give the time since midnight, strings without time zone are local*/
|
|
2261
|
+
const string_wall_time = (value) => {
|
|
2262
|
+
if (TIME_ONLY.test(value)) return Date.parse("1970-01-01T" + value + "Z");
|
|
2263
|
+
if (DATE_ONLY.test(value)) return Date.parse(value);
|
|
2264
|
+
const date = new Date(value);
|
|
2265
|
+
return date.getTime() - date.getTimezoneOffset() * 6e4;
|
|
2266
|
+
};
|
|
2267
|
+
var FormDateTime = class extends FormValueWrite {
|
|
2268
|
+
static element_name() {
|
|
2269
|
+
return "datetimeinput";
|
|
2270
|
+
}
|
|
2271
|
+
static element_name_space() {
|
|
2272
|
+
return "form";
|
|
2273
|
+
}
|
|
2274
|
+
#type = FormDateTimeType.DATETIME;
|
|
2275
|
+
#mode;
|
|
2276
|
+
#milliseconds = false;
|
|
2277
|
+
constructor(mode, id) {
|
|
2278
|
+
super(id);
|
|
2279
|
+
this.#mode = mode;
|
|
2280
|
+
this.warn_input.onfocus = () => {
|
|
2281
|
+
this.selected = true;
|
|
2282
|
+
};
|
|
2283
|
+
this.warn_input.onblur = () => {
|
|
2284
|
+
this.selected = false;
|
|
2285
|
+
if (this._buffer !== void 0) this.new_value(this._buffer);
|
|
2286
|
+
};
|
|
2287
|
+
this.warn_input.type = "datetime-local";
|
|
2288
|
+
this.warn_input.lang = "da-DK";
|
|
2289
|
+
this.warn_input.step = "1";
|
|
2290
|
+
this.appendChild(this.warn_input);
|
|
2291
|
+
this.appendChild(material_calendar_month_rounded()).onclick = () => this.warn_input.showPicker();
|
|
2292
|
+
this.appendChild(material_schedule_rounded()).onclick = () => this.warn_input.showPicker();
|
|
2293
|
+
this.warn_input.onchange = () => {
|
|
2294
|
+
if (this.warn_input.value) {
|
|
2295
|
+
if (this.#mode === FormDateTimeMode.DATE) {
|
|
2296
|
+
const wall = new Date(this.warn_input.valueAsNumber);
|
|
2297
|
+
const date = /* @__PURE__ */ new Date(0);
|
|
2298
|
+
date.setFullYear(wall.getUTCFullYear(), wall.getUTCMonth(), wall.getUTCDate());
|
|
2299
|
+
date.setHours(wall.getUTCHours(), wall.getUTCMinutes(), wall.getUTCSeconds(), wall.getUTCMilliseconds());
|
|
2300
|
+
this.set_value_check(date);
|
|
2301
|
+
} else if (this.#mode === FormDateTimeMode.STRING) this.set_value_check(this.warn_input.value);
|
|
2302
|
+
else this.set_value_check(this.warn_input.valueAsNumber);
|
|
2303
|
+
}
|
|
2304
|
+
};
|
|
2305
|
+
}
|
|
2306
|
+
/**Returns the date time type*/
|
|
2307
|
+
get type() {
|
|
2308
|
+
return this.#type;
|
|
2309
|
+
}
|
|
2310
|
+
/**Sets the date time type*/
|
|
2311
|
+
set type(type) {
|
|
2312
|
+
if (type === FormDateTimeType.DATE) this.warn_input.type = "date";
|
|
2313
|
+
if (type === FormDateTimeType.TIME) this.warn_input.type = "time";
|
|
2314
|
+
if (type === FormDateTimeType.DATETIME) this.warn_input.type = "datetime-local";
|
|
2315
|
+
this.#type = type;
|
|
2316
|
+
}
|
|
2317
|
+
/**Returns true if the input is set to show milliseconds*/
|
|
2318
|
+
get milliseconds() {
|
|
2319
|
+
return this.#milliseconds;
|
|
2320
|
+
}
|
|
2321
|
+
/**Sets the input to show milliseconds*/
|
|
2322
|
+
set milliseconds(value) {
|
|
2323
|
+
this.#milliseconds = value;
|
|
2324
|
+
if (value) this.warn_input.step = "0.001";
|
|
2325
|
+
else this.warn_input.step = "1";
|
|
2326
|
+
}
|
|
2327
|
+
/**Returns the date time type*/
|
|
2328
|
+
get step() {
|
|
2329
|
+
return Number(this.warn_input.step);
|
|
2330
|
+
}
|
|
2331
|
+
/**Sets the date time type*/
|
|
2332
|
+
set step(step) {
|
|
2333
|
+
this.warn_input.step = String(step);
|
|
2334
|
+
}
|
|
2335
|
+
new_value(value) {
|
|
2336
|
+
let time;
|
|
2337
|
+
if (typeof value === "number") time = value;
|
|
2338
|
+
else if (typeof value === "string") {
|
|
2339
|
+
if (INPUT_FORMAT[this.#type].test(value)) {
|
|
2340
|
+
this.warn_input.value = value;
|
|
2341
|
+
return;
|
|
2342
|
+
}
|
|
2343
|
+
time = string_wall_time(value);
|
|
2344
|
+
} else time = value.getTime() - value.getTimezoneOffset() * 6e4;
|
|
2345
|
+
this.warn_input.valueAsNumber = this.#milliseconds ? time : time - time % 1e3;
|
|
2346
|
+
}
|
|
2347
|
+
clear_value() {
|
|
2348
|
+
this.warn_input.value = "";
|
|
2349
|
+
}
|
|
2350
|
+
new_error(_val) {}
|
|
2351
|
+
clear_error() {}
|
|
2352
|
+
state_related(_related) {}
|
|
2353
|
+
};
|
|
2354
|
+
define_element(FormDateTime);
|
|
2355
|
+
/**Creates a date time input form element
|
|
2356
|
+
* Number type is always UTC, Date and String is always local*/
|
|
2357
|
+
function form_date_time(options) {
|
|
2358
|
+
const input = new FormDateTime(options.mode, options.id);
|
|
2359
|
+
if (options.type) input.type = options.type;
|
|
2360
|
+
if (options.milliseconds !== void 0) input.milliseconds = options.milliseconds;
|
|
2361
|
+
FormValueWrite.apply_options(input, options);
|
|
2362
|
+
return input;
|
|
2363
|
+
}
|
|
2364
|
+
// form/special/ip/ip_input.ts
|
|
2365
|
+
var FormIp = class extends FormValueWrite {
|
|
2366
|
+
static element_name() {
|
|
2367
|
+
return "ipinput";
|
|
2368
|
+
}
|
|
2369
|
+
static element_name_space() {
|
|
2370
|
+
return "form";
|
|
2371
|
+
}
|
|
2372
|
+
#type;
|
|
2373
|
+
/**Amount of parts of the current type*/
|
|
2374
|
+
get #count() {
|
|
2375
|
+
return this.#type === IPVersion.V4 ? 4 : 8;
|
|
2376
|
+
}
|
|
2377
|
+
#parts = Array.from({ length: 8 }, (_, i) => {
|
|
2378
|
+
const inp = this.appendChild(document.createElement("div"));
|
|
2379
|
+
if (i < 7) this.appendChild(document.createElement("span"));
|
|
2380
|
+
inp.contentEditable = "true";
|
|
2381
|
+
inp.onbeforeinput = async (ev) => {
|
|
2382
|
+
if (ev.inputType === "insertParagraph") ev.preventDefault();
|
|
2383
|
+
else if (ev.inputType === "deleteContentBackward") {
|
|
2384
|
+
if (inp.textContent.length === 0 && i > 0) set_cursor_end(this.#parts[i - 1]);
|
|
2385
|
+
} else if (ev.inputType === "deleteContentForward") {
|
|
2386
|
+
if (inp.textContent.length === 0 && i < this.#count - 1) {
|
|
2387
|
+
await sleep(0);
|
|
2388
|
+
this.#parts[i + 1].focus();
|
|
2389
|
+
}
|
|
2390
|
+
} else if (ev.data) {
|
|
2391
|
+
if ((ev.data === "." || ev.data === ":" || ev.data === ",") && i < this.#count - 1) {
|
|
2392
|
+
set_selection_all(this.#parts[i + 1]);
|
|
2393
|
+
ev.preventDefault();
|
|
2394
|
+
} else if (!ev.data.match(this.#type === IPVersion.V4 ? /^[\d]*$/ : /^[\dA-Fa-f]*$/)) ev.preventDefault();
|
|
2395
|
+
else {
|
|
2396
|
+
const [start, end] = this.#selection_in(inp);
|
|
2397
|
+
const potential = inp.textContent.slice(0, start) + ev.data + inp.textContent.slice(end);
|
|
2398
|
+
if (potential.length > (this.#type === IPVersion.V4 ? 3 : 4)) {
|
|
2399
|
+
ev.preventDefault();
|
|
2400
|
+
return;
|
|
2401
|
+
}
|
|
2402
|
+
const num = this.#type === IPVersion.V4 ? parseInt(potential, 10) : parseInt(potential, 16);
|
|
2403
|
+
if (this.#type === IPVersion.V4 && num > 255 || this.#type === IPVersion.V6 && num > 65535) {
|
|
2404
|
+
if (i < this.#count - 1) set_selection_all(this.#parts[i + 1]);
|
|
2405
|
+
else ev.preventDefault();
|
|
2406
|
+
}
|
|
2407
|
+
}
|
|
2408
|
+
}
|
|
2409
|
+
};
|
|
2410
|
+
inp.oninput = () => {
|
|
2411
|
+
if (inp.textContent.length === (this.#type === IPVersion.V4 ? 3 : 4) && get_cursor_position(inp) === inp.textContent.length && i < this.#count - 1) set_selection_all(this.#parts[i + 1]);
|
|
2412
|
+
};
|
|
2413
|
+
inp.onkeydown = async (e) => {
|
|
2414
|
+
if (e.key === "ArrowUp") {} else if (e.key === "ArrowDown") {} else if (e.key === "ArrowLeft" && i > 0) {
|
|
2415
|
+
if (get_cursor_position(inp) === 0 || inp.textContent.length === 0) set_cursor_end(this.#parts[i - 1]);
|
|
2416
|
+
else return;
|
|
2417
|
+
} else if (e.key === "ArrowRight" && i < this.#count - 1) {
|
|
2418
|
+
if (get_cursor_position(inp) === inp.textContent.length || inp.textContent.length === 0) this.#parts[i + 1].focus();
|
|
2419
|
+
else return;
|
|
2420
|
+
} else return;
|
|
2421
|
+
e.preventDefault();
|
|
2422
|
+
e.stopPropagation();
|
|
2423
|
+
};
|
|
2424
|
+
return inp;
|
|
2425
|
+
});
|
|
2426
|
+
constructor(type, id) {
|
|
2427
|
+
super(id);
|
|
2428
|
+
this.type = type;
|
|
2429
|
+
this.#type = type;
|
|
2430
|
+
this.appendChild(this.warn_input);
|
|
2431
|
+
this.addEventListener("focusin", () => {
|
|
2432
|
+
this.selected = true;
|
|
2433
|
+
});
|
|
2434
|
+
this.addEventListener("focusout", () => {
|
|
2435
|
+
this.selected = false;
|
|
2436
|
+
});
|
|
2437
|
+
this.onpointerdown = (e) => {
|
|
2438
|
+
if (!this.#parts.includes(e.target)) {
|
|
2439
|
+
e.preventDefault();
|
|
2440
|
+
set_cursor_end(this.#parts[this.#type === IPVersion.V4 ? 3 : 7]);
|
|
2441
|
+
}
|
|
2442
|
+
};
|
|
2443
|
+
this.ondblclick = (e) => {
|
|
2444
|
+
if (e.target !== this) return;
|
|
2445
|
+
e.preventDefault();
|
|
2446
|
+
set_selection_all(this.#parts[0]);
|
|
2447
|
+
};
|
|
2448
|
+
this.addEventListener("focusin", (e) => {
|
|
2449
|
+
e.preventDefault();
|
|
2450
|
+
});
|
|
2451
|
+
this.addEventListener("focusout", (e) => {
|
|
2452
|
+
if (e.relatedTarget && this.contains(e.relatedTarget)) return;
|
|
2453
|
+
this.#commit_typed();
|
|
2454
|
+
});
|
|
2455
|
+
this.onkeydown = (e) => {
|
|
2456
|
+
if (e.key === "Enter") this.#commit_typed();
|
|
2457
|
+
else if (e.key === "Escape") {
|
|
2458
|
+
if (this.buffer) this.new_value(this.buffer);
|
|
2459
|
+
else this.clear_value();
|
|
2460
|
+
}
|
|
2461
|
+
};
|
|
2462
|
+
this.oncopy = (e) => {
|
|
2463
|
+
e.preventDefault();
|
|
2464
|
+
const typed = this.#typed();
|
|
2465
|
+
if (typed.ok) e.clipboardData?.setData("text/plain", typed.value.to_string());
|
|
2466
|
+
};
|
|
2467
|
+
this.onpaste = (e) => {
|
|
2468
|
+
e.preventDefault();
|
|
2469
|
+
const paste = e.clipboardData?.getData("text/plain") || "";
|
|
2470
|
+
let new_ip;
|
|
2471
|
+
try {
|
|
2472
|
+
new_ip = new IPAddress(paste);
|
|
2473
|
+
} catch (error) {
|
|
2474
|
+
return this.warn(error instanceof Error ? error.message : String(error));
|
|
2475
|
+
}
|
|
2476
|
+
if (new_ip.version !== this.#type) return;
|
|
2477
|
+
this.#commit(new_ip);
|
|
2478
|
+
};
|
|
2479
|
+
}
|
|
2480
|
+
/**Start and end of the selection in a part, both the cursor position when nothing is selected*/
|
|
2481
|
+
#selection_in(part) {
|
|
2482
|
+
const selection = part.ownerDocument.getSelection();
|
|
2483
|
+
if (selection?.rangeCount && part.contains(selection.anchorNode)) {
|
|
2484
|
+
const range = selection.getRangeAt(0);
|
|
2485
|
+
const before = range.cloneRange();
|
|
2486
|
+
before.selectNodeContents(part);
|
|
2487
|
+
before.setEnd(range.startContainer, range.startOffset);
|
|
2488
|
+
const start = before.toString().length;
|
|
2489
|
+
return [start, start + range.toString().length];
|
|
2490
|
+
}
|
|
2491
|
+
const position = get_cursor_position(part);
|
|
2492
|
+
return [position, position];
|
|
2493
|
+
}
|
|
2494
|
+
/**The typed address, or why the typed parts are not an address*/
|
|
2495
|
+
#typed() {
|
|
2496
|
+
if (this.#parts.slice(0, this.#count).some((part) => !part.textContent)) return err("All parts of the address must be filled in");
|
|
2497
|
+
try {
|
|
2498
|
+
return ok(this.value_as_ip);
|
|
2499
|
+
} catch (error) {
|
|
2500
|
+
return err(error instanceof Error ? error.message : String(error));
|
|
2501
|
+
}
|
|
2502
|
+
}
|
|
2503
|
+
/**Commits the typed address, or warns why it is not an address*/
|
|
2504
|
+
#commit_typed() {
|
|
2505
|
+
const typed = this.#typed();
|
|
2506
|
+
if (typed.ok) this.#commit(typed.value);
|
|
2507
|
+
else this.warn(typed.error);
|
|
2508
|
+
}
|
|
2509
|
+
/**Commits an address, unless it is the current address, a new IPAddress object is never the same object as the current one*/
|
|
2510
|
+
#commit(ip) {
|
|
2511
|
+
if (this.buffer?.equals(ip)) return;
|
|
2512
|
+
this.set_value_check(ip);
|
|
2513
|
+
}
|
|
2514
|
+
focus(options) {
|
|
2515
|
+
this.#parts[0].focus(options);
|
|
2516
|
+
}
|
|
2517
|
+
get value_as_ip() {
|
|
2518
|
+
return new IPAddress(this.#parts.slice(0, this.#type === IPVersion.V4 ? 4 : 8).reduce((acc, part, i) => {
|
|
2519
|
+
acc += part.innerText;
|
|
2520
|
+
if (i < (this.#type === IPVersion.V4 ? 4 : 8) - 1) acc += this.#type === IPVersion.V4 ? "." : ":";
|
|
2521
|
+
return acc;
|
|
2522
|
+
}, ""));
|
|
2523
|
+
}
|
|
2524
|
+
set type(val) {
|
|
2525
|
+
if (this.#type === val) return;
|
|
2526
|
+
this.#type = val;
|
|
2527
|
+
this.classList.toggle("ipv4", val === IPVersion.V4);
|
|
2528
|
+
this.classList.toggle("ipv6", val === IPVersion.V6);
|
|
2529
|
+
this.replaceChildren(...this.#parts.slice(0, this.#count).flatMap((v, i) => i < this.#count - 1 ? [v, document.createTextNode(val === IPVersion.V4 ? "." : ":")] : [v]), this.warn_input);
|
|
2530
|
+
}
|
|
2531
|
+
new_value(val) {
|
|
2532
|
+
this.type = val.version;
|
|
2533
|
+
val.as_array.forEach((part, i) => {
|
|
2534
|
+
this.#parts[i].textContent = val.version === IPVersion.V4 ? part.toString() : part.toString(16);
|
|
2535
|
+
});
|
|
2536
|
+
}
|
|
2537
|
+
clear_value() {
|
|
2538
|
+
this.#parts.forEach((part) => {
|
|
2539
|
+
part.textContent = "";
|
|
2540
|
+
});
|
|
2541
|
+
}
|
|
2542
|
+
new_error(_val) {}
|
|
2543
|
+
clear_error() {}
|
|
2544
|
+
state_related(_related) {}
|
|
2545
|
+
};
|
|
2546
|
+
define_element(FormIp);
|
|
2547
|
+
/**Creates an IP input form element */
|
|
2548
|
+
function form_ip(options) {
|
|
2549
|
+
const input = new FormIp(options.type, options?.id);
|
|
2550
|
+
if (options) FormValueWrite.apply_options(input, options);
|
|
2551
|
+
return input;
|
|
2552
|
+
}
|
|
2553
|
+
// form/special/password/password_input.ts
|
|
2554
|
+
var FormPassword = class extends FormValueWrite {
|
|
2555
|
+
static element_name() {
|
|
2556
|
+
return "passwordinput";
|
|
2557
|
+
}
|
|
2558
|
+
static element_name_space() {
|
|
2559
|
+
return "form";
|
|
2560
|
+
}
|
|
2561
|
+
#filter;
|
|
2562
|
+
constructor(id) {
|
|
2563
|
+
super(id);
|
|
2564
|
+
this.appendChild(this.warn_input);
|
|
2565
|
+
this.warn_input.type = "password";
|
|
2566
|
+
this.warn_input.onfocus = () => {
|
|
2567
|
+
this.warn_input.value = "";
|
|
2568
|
+
this.selected = true;
|
|
2569
|
+
};
|
|
2570
|
+
this.warn_input.onblur = () => {
|
|
2571
|
+
this.selected = false;
|
|
2572
|
+
if (this._buffer !== void 0 && this.warn_input.value !== this._buffer) this.new_value(this._buffer);
|
|
2573
|
+
};
|
|
2574
|
+
this.warn_input.onchange = () => {
|
|
2575
|
+
this.set_value_check(this.warn_input.value);
|
|
2576
|
+
};
|
|
2577
|
+
this.warn_input.onbeforeinput = (ev) => {
|
|
2578
|
+
if (ev.data && this.#filter) {
|
|
2579
|
+
this.#filter.lastIndex = 0;
|
|
2580
|
+
if (!this.#filter.test(ev.data)) {
|
|
2581
|
+
ev.preventDefault();
|
|
2582
|
+
this.warn("Invalid character entered");
|
|
2583
|
+
}
|
|
2584
|
+
}
|
|
2585
|
+
};
|
|
2586
|
+
}
|
|
2587
|
+
set filter(val) {
|
|
2588
|
+
this.#filter = val;
|
|
2589
|
+
}
|
|
2590
|
+
new_value(val) {
|
|
2591
|
+
this.warn_input.value = val;
|
|
2592
|
+
}
|
|
2593
|
+
clear_value() {
|
|
2594
|
+
this.warn_input.value = "";
|
|
2595
|
+
}
|
|
2596
|
+
new_error(_val) {}
|
|
2597
|
+
clear_error() {}
|
|
2598
|
+
state_related(_related) {}
|
|
2599
|
+
};
|
|
2600
|
+
define_element(FormPassword);
|
|
2601
|
+
/**Creates a password input form element */
|
|
2602
|
+
function form_password(options) {
|
|
2603
|
+
const input = new FormPassword(options?.id);
|
|
2604
|
+
if (options) {
|
|
2605
|
+
if (options.filter) input.filter = options.filter;
|
|
2606
|
+
FormValueWrite.apply_options(input, options);
|
|
2607
|
+
}
|
|
2608
|
+
return input;
|
|
2609
|
+
}
|
|
2610
|
+
// form/text/input/text_input.ts
|
|
2611
|
+
var FormTextInput = class extends FormValueWrite {
|
|
2612
|
+
static element_name() {
|
|
2613
|
+
return "textinput";
|
|
2614
|
+
}
|
|
2615
|
+
static element_name_space() {
|
|
2616
|
+
return "form";
|
|
2617
|
+
}
|
|
2618
|
+
#filter;
|
|
2619
|
+
#max_length;
|
|
2620
|
+
#max_bytes;
|
|
2621
|
+
#related_length = false;
|
|
2622
|
+
#related_bytes = false;
|
|
2623
|
+
constructor(id) {
|
|
2624
|
+
super(id);
|
|
2625
|
+
this.warn_input.onfocus = () => {
|
|
2626
|
+
this.selected = true;
|
|
2627
|
+
};
|
|
2628
|
+
this.warn_input.onblur = () => {
|
|
2629
|
+
this.selected = false;
|
|
2630
|
+
if (this._buffer !== void 0 && this.warn_input.value !== this._buffer) this.new_value(this._buffer);
|
|
2631
|
+
};
|
|
2632
|
+
this.warn_input.type = "text";
|
|
2633
|
+
this.appendChild(this.warn_input);
|
|
2634
|
+
this.warn_input.onchange = () => this.#set();
|
|
2635
|
+
this.onbeforeinput = (e) => {
|
|
2636
|
+
this.warn("");
|
|
2637
|
+
const data = e.data || e.dataTransfer?.getData("text/plain");
|
|
2638
|
+
if (data) {
|
|
2639
|
+
if (this.#filter) this.#filter.lastIndex = 0;
|
|
2640
|
+
if (this.#filter && !this.#filter.test(data)) {
|
|
2641
|
+
e.preventDefault();
|
|
2642
|
+
this.warn("Invalid character entered");
|
|
2643
|
+
} else if (this.#max_length || this.#max_bytes) {
|
|
2644
|
+
const input = this.warn_input;
|
|
2645
|
+
const value = input.value;
|
|
2646
|
+
const start = input.selectionStart ?? value.length;
|
|
2647
|
+
const end = input.selectionEnd ?? start;
|
|
2648
|
+
if (this.#max_length && value.length - (end - start) + data.length > this.#max_length) {
|
|
2649
|
+
e.preventDefault();
|
|
2650
|
+
this.warn(`A maximum of ${this.#max_length} characters is allowed`);
|
|
2651
|
+
}
|
|
2652
|
+
if (this.#max_bytes && string_byte_length(value) - string_byte_length(value.slice(start, end)) + string_byte_length(data) > this.#max_bytes) {
|
|
2653
|
+
e.preventDefault();
|
|
2654
|
+
this.warn(`A maximum of ${this.#max_bytes} bytes is allowed`);
|
|
2655
|
+
}
|
|
2656
|
+
}
|
|
2657
|
+
}
|
|
2658
|
+
};
|
|
2659
|
+
this.onkeydown = (e) => {
|
|
2660
|
+
if (e.key === "Escape") {
|
|
2661
|
+
if (this.warn_input.value === (this.buffer ?? "")) return;
|
|
2662
|
+
e.preventDefault();
|
|
2663
|
+
e.stopPropagation();
|
|
2664
|
+
if (this.buffer) this.new_value(this.buffer);
|
|
2665
|
+
else this.clear_value();
|
|
2666
|
+
}
|
|
2667
|
+
};
|
|
2668
|
+
}
|
|
2669
|
+
async #set() {
|
|
2670
|
+
const buff = this.buffer;
|
|
2671
|
+
(await this.set_value_check(this.warn_input.value || "")).map_err(() => {
|
|
2672
|
+
this.new_value(buff || "");
|
|
2673
|
+
set_cursor_end(this.warn_input);
|
|
2674
|
+
});
|
|
2675
|
+
}
|
|
2676
|
+
set filter(val) {
|
|
2677
|
+
this.#filter = val;
|
|
2678
|
+
}
|
|
2679
|
+
get filter() {
|
|
2680
|
+
return this.#filter;
|
|
2681
|
+
}
|
|
2682
|
+
set placeholder(val) {
|
|
2683
|
+
this.warn_input.placeholder = val;
|
|
2684
|
+
}
|
|
2685
|
+
get placeholder() {
|
|
2686
|
+
return this.warn_input.placeholder;
|
|
2687
|
+
}
|
|
2688
|
+
set max_length(val) {
|
|
2689
|
+
this.#max_length = val;
|
|
2690
|
+
if (val === void 0) this.warn_input.removeAttribute("maxlength");
|
|
2691
|
+
else this.warn_input.maxLength = val;
|
|
2692
|
+
}
|
|
2693
|
+
get max_length() {
|
|
2694
|
+
return this.#max_length;
|
|
2695
|
+
}
|
|
2696
|
+
set max_bytes(val) {
|
|
2697
|
+
this.#max_bytes = val;
|
|
2698
|
+
}
|
|
2699
|
+
get max_bytes() {
|
|
2700
|
+
return this.#max_bytes;
|
|
2701
|
+
}
|
|
2702
|
+
new_value(val) {
|
|
2703
|
+
this.warn_input.value = val;
|
|
2704
|
+
}
|
|
2705
|
+
clear_value() {
|
|
2706
|
+
this.warn_input.value = "";
|
|
2707
|
+
}
|
|
2708
|
+
new_error(_val) {}
|
|
2709
|
+
clear_error() {}
|
|
2710
|
+
limit_value(val) {
|
|
2711
|
+
if (this.#max_length && val.length > this.#max_length) val = val.slice(0, this.#max_length);
|
|
2712
|
+
if (this.#max_bytes) val = string_byte_limit(val, this.#max_bytes);
|
|
2713
|
+
return super.limit_value(val);
|
|
2714
|
+
}
|
|
2715
|
+
check_value(val) {
|
|
2716
|
+
if (this.#max_length && val.length > this.#max_length) return sync_resolve(err(`A maximum of ${this.#max_length} characters is allowed`));
|
|
2717
|
+
if (this.#max_bytes && string_byte_length(val) > this.#max_bytes) return sync_resolve(err(`A maximum of ${this.#max_bytes} bytes is allowed`));
|
|
2718
|
+
return super.check_value(val);
|
|
2719
|
+
}
|
|
2720
|
+
state_related(related) {
|
|
2721
|
+
if (related.max_length) this.attach_state_to_prop("max_length", related.max_length, () => none());
|
|
2722
|
+
else if (this.#related_length) this.detach_state_from_prop("max_length").max_length = void 0;
|
|
2723
|
+
this.#related_length = !!related.max_length;
|
|
2724
|
+
if (related.max_length_bytes) this.attach_state_to_prop("max_bytes", related.max_length_bytes, () => none());
|
|
2725
|
+
else if (this.#related_bytes) this.detach_state_from_prop("max_bytes").max_bytes = void 0;
|
|
2726
|
+
this.#related_bytes = !!related.max_length_bytes;
|
|
2727
|
+
}
|
|
2728
|
+
};
|
|
2729
|
+
define_element(FormTextInput);
|
|
2730
|
+
/**Creates a single line text input form element */
|
|
2731
|
+
function form_text_input(options) {
|
|
2732
|
+
const input = new FormTextInput(options?.id);
|
|
2733
|
+
if (options) {
|
|
2734
|
+
if (options.filter) input.filter = options.filter;
|
|
2735
|
+
if (options.placeholder) input.placeholder = options.placeholder;
|
|
2736
|
+
if (options.max_length) input.max_length = options.max_length;
|
|
2737
|
+
if (options.max_bytes) input.max_bytes = options.max_bytes;
|
|
2738
|
+
FormValueWrite.apply_options(input, options);
|
|
2739
|
+
}
|
|
2740
|
+
return input;
|
|
2741
|
+
}
|
|
2742
|
+
// form/text/multi_line/text_multi_line.ts
|
|
2743
|
+
var FormTextMultiline = class extends FormValueWrite {
|
|
2744
|
+
static element_name() {
|
|
2745
|
+
return "textmultiline";
|
|
2746
|
+
}
|
|
2747
|
+
static element_name_space() {
|
|
2748
|
+
return "form";
|
|
2749
|
+
}
|
|
2750
|
+
#filter;
|
|
2751
|
+
#max_length;
|
|
2752
|
+
#max_bytes;
|
|
2753
|
+
#related_length = false;
|
|
2754
|
+
#related_bytes = false;
|
|
2755
|
+
#value_box = this.appendChild(document.createElement("textarea"));
|
|
2756
|
+
#resizer = this.appendChild(document.createElement("div"));
|
|
2757
|
+
constructor(id) {
|
|
2758
|
+
super(id);
|
|
2759
|
+
this.#value_box.onfocus = () => {
|
|
2760
|
+
this.selected = true;
|
|
2761
|
+
};
|
|
2762
|
+
this.#value_box.onblur = () => {
|
|
2763
|
+
this.selected = false;
|
|
2764
|
+
if (this._buffer !== void 0 && this.#value_box.value !== this._buffer) this.new_value(this._buffer);
|
|
2765
|
+
};
|
|
2766
|
+
this.appendChild(this.warn_input);
|
|
2767
|
+
this.#resizer.appendChild(material_drag_handle_rounded());
|
|
2768
|
+
this.#resizer.onpointerdown = (e) => {
|
|
2769
|
+
e.preventDefault();
|
|
2770
|
+
const height = this.#value_box.getBoundingClientRect().height;
|
|
2771
|
+
const start_y = e.clientY;
|
|
2772
|
+
this.#resizer.setPointerCapture(e.pointerId);
|
|
2773
|
+
this.#resizer.onpointermove = (ev) => {
|
|
2774
|
+
const dy = ev.clientY - start_y;
|
|
2775
|
+
this.#value_box.style.height = `${height + dy}px`;
|
|
2776
|
+
};
|
|
2777
|
+
this.#resizer.onpointerup = (_ev) => {
|
|
2778
|
+
this.#resizer.releasePointerCapture(e.pointerId);
|
|
2779
|
+
this.#resizer.onpointermove = null;
|
|
2780
|
+
this.#resizer.onpointerup = null;
|
|
2781
|
+
};
|
|
2782
|
+
};
|
|
2783
|
+
this.#value_box.onchange = () => this.#set();
|
|
2784
|
+
this.#value_box.onbeforeinput = (e) => {
|
|
2785
|
+
this.warn("");
|
|
2786
|
+
const data = e.data || e.dataTransfer?.getData("text/plain");
|
|
2787
|
+
if (data) {
|
|
2788
|
+
if (this.#filter) this.#filter.lastIndex = 0;
|
|
2789
|
+
if (this.#filter && !this.#filter.test(data)) {
|
|
2790
|
+
e.preventDefault();
|
|
2791
|
+
this.warn("Invalid character entered");
|
|
2792
|
+
} else if (this.#max_length || this.#max_bytes) {
|
|
2793
|
+
const box = this.#value_box;
|
|
2794
|
+
const value = box.value;
|
|
2795
|
+
const start = box.selectionStart;
|
|
2796
|
+
const end = box.selectionEnd;
|
|
2797
|
+
if (this.#max_length && value.length - (end - start) + data.length > this.#max_length) {
|
|
2798
|
+
e.preventDefault();
|
|
2799
|
+
this.warn(`A maximum of ${this.#max_length} characters is allowed`);
|
|
2800
|
+
}
|
|
2801
|
+
if (this.#max_bytes && string_byte_length(value) - string_byte_length(value.slice(start, end)) + string_byte_length(data) > this.#max_bytes) {
|
|
2802
|
+
e.preventDefault();
|
|
2803
|
+
this.warn(`A maximum of ${this.#max_bytes} bytes is allowed`);
|
|
2804
|
+
}
|
|
2805
|
+
}
|
|
2806
|
+
}
|
|
2807
|
+
};
|
|
2808
|
+
this.#value_box.onkeydown = (e) => {
|
|
2809
|
+
if (e.key === "Escape") {
|
|
2810
|
+
if (this.#value_box.value === (this.buffer ?? "")) return;
|
|
2811
|
+
e.preventDefault();
|
|
2812
|
+
e.stopPropagation();
|
|
2813
|
+
if (this.buffer) this.new_value(this.buffer);
|
|
2814
|
+
else this.clear_value();
|
|
2815
|
+
} else if (e.key === "Enter") {
|
|
2816
|
+
if (!e.shiftKey) e.stopPropagation();
|
|
2817
|
+
if (e.ctrlKey) {
|
|
2818
|
+
e.preventDefault();
|
|
2819
|
+
this.#set();
|
|
2820
|
+
}
|
|
2821
|
+
}
|
|
2822
|
+
};
|
|
2823
|
+
}
|
|
2824
|
+
focus(options) {
|
|
2825
|
+
this.#value_box.focus(options);
|
|
2826
|
+
}
|
|
2827
|
+
async #set() {
|
|
2828
|
+
const buff = this.buffer;
|
|
2829
|
+
(await this.set_value_check(this.#value_box.value || "")).map_err(() => {
|
|
2830
|
+
this.new_value(buff || "");
|
|
2831
|
+
set_cursor_end(this.#value_box);
|
|
2832
|
+
});
|
|
2833
|
+
}
|
|
2834
|
+
set filter(val) {
|
|
2835
|
+
this.#filter = val;
|
|
2836
|
+
}
|
|
2837
|
+
get filter() {
|
|
2838
|
+
return this.#filter;
|
|
2839
|
+
}
|
|
2840
|
+
set placeholder(val) {
|
|
2841
|
+
this.#value_box.placeholder = val;
|
|
2842
|
+
}
|
|
2843
|
+
get placeholder() {
|
|
2844
|
+
return this.#value_box.placeholder;
|
|
2845
|
+
}
|
|
2846
|
+
set max_length(val) {
|
|
2847
|
+
this.#max_length = val;
|
|
2848
|
+
if (val === void 0) this.#value_box.removeAttribute("maxlength");
|
|
2849
|
+
else this.#value_box.maxLength = val;
|
|
2850
|
+
}
|
|
2851
|
+
get max_length() {
|
|
2852
|
+
return this.#max_length;
|
|
2853
|
+
}
|
|
2854
|
+
set max_bytes(val) {
|
|
2855
|
+
this.#max_bytes = val;
|
|
2856
|
+
}
|
|
2857
|
+
get max_bytes() {
|
|
2858
|
+
return this.#max_bytes;
|
|
2859
|
+
}
|
|
2860
|
+
new_value(val) {
|
|
2861
|
+
this.#value_box.value = val;
|
|
2862
|
+
}
|
|
2863
|
+
clear_value() {
|
|
2864
|
+
this.#value_box.value = "";
|
|
2865
|
+
}
|
|
2866
|
+
new_error(_val) {}
|
|
2867
|
+
clear_error() {}
|
|
2868
|
+
limit_value(val) {
|
|
2869
|
+
if (this.#max_length && val.length > this.#max_length) val = val.slice(0, this.#max_length);
|
|
2870
|
+
if (this.#max_bytes) val = string_byte_limit(val, this.#max_bytes);
|
|
2871
|
+
return super.limit_value(val);
|
|
2872
|
+
}
|
|
2873
|
+
check_value(val) {
|
|
2874
|
+
if (this.#max_length && val.length > this.#max_length) return sync_resolve(err(`A maximum of ${this.#max_length} characters is allowed`));
|
|
2875
|
+
if (this.#max_bytes && string_byte_length(val) > this.#max_bytes) return sync_resolve(err(`A maximum of ${this.#max_bytes} bytes is allowed`));
|
|
2876
|
+
return super.check_value(val);
|
|
2877
|
+
}
|
|
2878
|
+
state_related(related) {
|
|
2879
|
+
if (related.max_length) this.attach_state_to_prop("max_length", related.max_length, () => none());
|
|
2880
|
+
else if (this.#related_length) this.detach_state_from_prop("max_length").max_length = void 0;
|
|
2881
|
+
this.#related_length = !!related.max_length;
|
|
2882
|
+
if (related.max_length_bytes) this.attach_state_to_prop("max_bytes", related.max_length_bytes, () => none());
|
|
2883
|
+
else if (this.#related_bytes) this.detach_state_from_prop("max_bytes").max_bytes = void 0;
|
|
2884
|
+
this.#related_bytes = !!related.max_length_bytes;
|
|
2885
|
+
}
|
|
2886
|
+
};
|
|
2887
|
+
define_element(FormTextMultiline);
|
|
2888
|
+
/**Creates a multi line text input form element */
|
|
2889
|
+
function form_text_multiline(options) {
|
|
2890
|
+
const input = new FormTextMultiline(options?.id);
|
|
2891
|
+
if (options) {
|
|
2892
|
+
if (options.filter) input.filter = options.filter;
|
|
2893
|
+
if (options.placeholder) input.placeholder = options.placeholder;
|
|
2894
|
+
if (options.max_length) input.max_length = options.max_length;
|
|
2895
|
+
if (options.max_bytes) input.max_bytes = options.max_bytes;
|
|
2896
|
+
FormValueWrite.apply_options(input, options);
|
|
2897
|
+
}
|
|
2898
|
+
return input;
|
|
2899
|
+
}
|
|
2900
|
+
// form/text/text/text.ts
|
|
2901
|
+
/**Component for simple text */
|
|
2902
|
+
var FormText = class extends FormElement {
|
|
2903
|
+
static element_name() {
|
|
2904
|
+
return "text";
|
|
2905
|
+
}
|
|
2906
|
+
static element_name_space() {
|
|
2907
|
+
return "form";
|
|
2908
|
+
}
|
|
2909
|
+
constructor(options) {
|
|
2910
|
+
super();
|
|
2911
|
+
if (options.text) this.text = options.text;
|
|
2912
|
+
if (options.size) this.size = options.size;
|
|
2913
|
+
}
|
|
2914
|
+
/**Sets the current text of the element*/
|
|
2915
|
+
set text(text) {
|
|
2916
|
+
this.textContent = text;
|
|
2917
|
+
}
|
|
2918
|
+
get text() {
|
|
2919
|
+
return this.textContent;
|
|
2920
|
+
}
|
|
2921
|
+
/**Sets the current text of the element*/
|
|
2922
|
+
set size(size) {
|
|
2923
|
+
this.style.fontSize = size + "rem";
|
|
2924
|
+
this.style.lineHeight = size + "rem";
|
|
2925
|
+
}
|
|
2926
|
+
};
|
|
2927
|
+
define_element(FormText);
|
|
2928
|
+
/**Creates a button form element */
|
|
2929
|
+
function form_text(options) {
|
|
2930
|
+
return new FormText(options);
|
|
2931
|
+
}
|
|
2932
|
+
// form/index.ts
|
|
2933
|
+
/**Form elements with label */
|
|
2934
|
+
const form = {
|
|
2935
|
+
FormColors,
|
|
2936
|
+
button: form_button,
|
|
2937
|
+
switch: form_switch,
|
|
2938
|
+
lamp: form_lamp,
|
|
2939
|
+
group: form_group,
|
|
2940
|
+
group_collapser: form_group_collapser,
|
|
2941
|
+
color: form_color,
|
|
2942
|
+
date_time: form_date_time,
|
|
2943
|
+
FormDateTimeMode,
|
|
2944
|
+
FormDateTimeType,
|
|
2945
|
+
ip: form_ip,
|
|
2946
|
+
password: form_password,
|
|
2947
|
+
progress: form_progress,
|
|
2948
|
+
number_input: form_number_input,
|
|
2949
|
+
slider: form_slider,
|
|
2950
|
+
stepper: form_stepper,
|
|
2951
|
+
dropdown: form_dropdown,
|
|
2952
|
+
toggle_button: form_toggle_button,
|
|
2953
|
+
spacer: form_spacer,
|
|
2954
|
+
text: form_text,
|
|
2955
|
+
text_input: form_text_input,
|
|
2956
|
+
text_multiline: form_text_multiline,
|
|
2957
|
+
list_field: form_list_field
|
|
2958
|
+
};
|
|
2959
|
+
export { FormElement as a, FormColors as i, FormDateTimeMode as n, FormValue as o, FormDateTimeType as r, FormValueWrite as s, form as t };
|
|
2960
|
+
|
|
2961
|
+
//# sourceMappingURL=form-CJA3s46n.mjs.map
|