@chocbite/ts-lib-ui 1.0.2 → 1.0.3
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/README.md +16 -0
- package/base/index.d.mts +2 -2
- package/base/index.mjs +69 -77
- package/base/index.mjs.map +1 -1
- package/canvas/index.d.mts +3 -1
- package/canvas/index.mjs +51 -53
- package/canvas/index.mjs.map +1 -1
- package/context-menu/index.d.mts +1 -1
- package/context-menu/index.mjs +1 -1
- package/{context-menu-CiNcuP-a.mjs → context-menu-_9dMpC-H.mjs} +71 -37
- package/context-menu-_9dMpC-H.mjs.map +1 -0
- package/document/index.mjs +3 -1
- package/document/index.mjs.map +1 -1
- package/form/index.d.mts +16 -5
- package/form/index.mjs +410 -151
- package/form/index.mjs.map +1 -1
- package/icons/index.d.mts +1 -1
- package/icons/index.mjs +1 -1
- package/icons-e2J_Ojic.mjs +4124 -0
- package/{index-BcidwqIy.d.mts → index-BDWg5GX2.d.mts} +7 -18
- package/{index-BND79jZp.d.mts → index-CvzH3M_5.d.mts} +16 -9
- package/{index-CugtUzv_.d.mts → index-CzpbJoAj.d.mts} +19 -10
- package/{index-CB3-qP6l.d.mts → index-DhRb2iA8.d.mts} +7 -5
- package/keyboard/index.d.mts +1 -1
- package/keyboard/index.mjs +121 -50
- package/keyboard/index.mjs.map +1 -1
- package/list/index.d.mts +1 -1
- package/list/index.mjs +1 -1
- package/{list-CQDnxsLV.mjs → list-Bkm9Ailw.mjs} +97 -106
- package/list-Bkm9Ailw.mjs.map +1 -0
- package/package.json +7 -2
- package/selection/index.mjs +9 -11
- package/selection/index.mjs.map +1 -1
- package/settings/index.d.mts +23 -5
- package/settings/index.mjs +17 -10
- package/settings/index.mjs.map +1 -1
- package/spinner/index.d.mts +1 -1
- package/spinner/index.mjs +2 -2
- package/state/index.d.mts +36 -0
- package/state/index.mjs +2 -0
- package/state-OCzEmq3j.mjs +87 -0
- package/state-OCzEmq3j.mjs.map +1 -0
- package/style.css +14 -7
- package/svg/index.d.mts +1 -1
- package/svg/index.mjs +1 -1
- package/{svg-golJPaR4.mjs → svg-1bp-yIPC.mjs} +20 -17
- package/svg-1bp-yIPC.mjs.map +1 -0
- package/theme/index.d.mts +21 -2
- package/theme/index.mjs +1 -1
- package/{theme-9ib89_3b.mjs → theme-DlD5P5tY.mjs} +125 -44
- package/theme-DlD5P5tY.mjs.map +1 -0
- package/context-menu-CiNcuP-a.mjs.map +0 -1
- package/icons-CY4BLQ2F.mjs +0 -4123
- package/list-CQDnxsLV.mjs.map +0 -1
- package/svg-golJPaR4.mjs.map +0 -1
- package/theme-9ib89_3b.mjs.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "./style.css";
|
|
2
2
|
import { Base, define_element } from "./base/index.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { i as theme_init_variable_root } from "./theme-DlD5P5tY.mjs";
|
|
4
4
|
import { DOCUMENT_HANDLER } from "./document/index.mjs";
|
|
5
|
-
import { Fm as material_chevron_right_rounded, xh as material_close_rounded } from "./icons-
|
|
5
|
+
import { Fm as material_chevron_right_rounded, xh as material_close_rounded } from "./icons-e2J_Ojic.mjs";
|
|
6
6
|
import { Spinner } from "./spinner/index.mjs";
|
|
7
7
|
import { BLUE, GREY } from "@chocbite/ts-lib/colors";
|
|
8
8
|
// src/context-menu/shared.ts
|
|
@@ -22,14 +22,22 @@ var MenuLine = class extends Base {
|
|
|
22
22
|
static element_name_space() {
|
|
23
23
|
return "contextmenu";
|
|
24
24
|
}
|
|
25
|
-
/**
|
|
25
|
+
/**True for lines that can not take focus, like dividers, focus moves past them*/
|
|
26
|
+
get skips_focus() {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
/**Changes focus to the next line, wrapping around and skipping lines that can not take focus
|
|
26
30
|
* @param direction false is next sibling, true is previous */
|
|
27
31
|
focus_next(direction) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
const parent = this.parentElement;
|
|
33
|
+
if (!parent) return;
|
|
34
|
+
let line = direction ? this.previousElementSibling : this.nextElementSibling;
|
|
35
|
+
for (;;) {
|
|
36
|
+
line ??= direction ? parent.lastElementChild : parent.firstElementChild;
|
|
37
|
+
if (!line || line === this) return;
|
|
38
|
+
if (!line.skips_focus) return line.do_focus(direction);
|
|
39
|
+
line = direction ? line.previousElementSibling : line.nextElementSibling;
|
|
40
|
+
}
|
|
33
41
|
}
|
|
34
42
|
};
|
|
35
43
|
// src/context-menu/devider.ts
|
|
@@ -38,6 +46,9 @@ var Devider = class extends MenuLine {
|
|
|
38
46
|
static element_name() {
|
|
39
47
|
return "devider";
|
|
40
48
|
}
|
|
49
|
+
get skips_focus() {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
41
52
|
do_focus(dir) {
|
|
42
53
|
this.focus_next(dir);
|
|
43
54
|
}
|
|
@@ -49,6 +60,7 @@ function context_devider() {
|
|
|
49
60
|
// src/context-menu/container.ts
|
|
50
61
|
var Container = class extends Base {
|
|
51
62
|
#active_element_buffer;
|
|
63
|
+
#replacing = false;
|
|
52
64
|
/**Returns the name used to define the element */
|
|
53
65
|
static element_name() {
|
|
54
66
|
return "container";
|
|
@@ -78,12 +90,19 @@ var Container = class extends Base {
|
|
|
78
90
|
/**Attaches a menu to the container */
|
|
79
91
|
attach_menu(menu) {
|
|
80
92
|
menu.container = this;
|
|
81
|
-
|
|
93
|
+
const old = this.firstElementChild;
|
|
94
|
+
if (old) {
|
|
95
|
+
this.#replacing = true;
|
|
96
|
+
old.close_down();
|
|
97
|
+
old.close_up();
|
|
98
|
+
this.#replacing = false;
|
|
99
|
+
} else this.#active_element_buffer = this.ownerDocument.activeElement;
|
|
82
100
|
this.replaceChildren(menu);
|
|
83
101
|
return menu;
|
|
84
102
|
}
|
|
85
103
|
/**Closes open context menu */
|
|
86
104
|
close_up() {
|
|
105
|
+
if (this.#replacing) return;
|
|
87
106
|
if (this.#active_element_buffer) {
|
|
88
107
|
this.#active_element_buffer.focus();
|
|
89
108
|
if (this.ownerDocument.activeElement !== this.#active_element_buffer) this.focus();
|
|
@@ -94,8 +113,10 @@ var Container = class extends Base {
|
|
|
94
113
|
define_element(Container);
|
|
95
114
|
// src/context-menu/engine.ts
|
|
96
115
|
const CONTEXT_MENY_SYMBOL = Symbol("context_menu");
|
|
97
|
-
/**
|
|
116
|
+
/**Default context menu, false blocks the operating system context menu, undefined leaves it*/
|
|
98
117
|
let default_menu;
|
|
118
|
+
/**Blocks the operating system context menu when the default is false*/
|
|
119
|
+
const block_os_menu = (e) => e.preventDefault();
|
|
99
120
|
DOCUMENT_HANDLER.events.on("added", (e) => {
|
|
100
121
|
apply_to_doc(e.data);
|
|
101
122
|
});
|
|
@@ -106,7 +127,15 @@ function apply_to_doc(doc) {
|
|
|
106
127
|
const container = new Container();
|
|
107
128
|
doc[CONTEXT_MENY_SYMBOL] = container;
|
|
108
129
|
doc.documentElement.appendChild(container);
|
|
109
|
-
|
|
130
|
+
apply_default_to_doc(doc);
|
|
131
|
+
}
|
|
132
|
+
/**Applies the current default context menu to a document*/
|
|
133
|
+
function apply_default_to_doc(doc) {
|
|
134
|
+
const root = doc.documentElement;
|
|
135
|
+
context_menu_detach(root);
|
|
136
|
+
root.removeEventListener("contextmenu", block_os_menu);
|
|
137
|
+
if (default_menu) context_menu_attach(root, default_menu);
|
|
138
|
+
else if (default_menu === false) root.addEventListener("contextmenu", block_os_menu);
|
|
110
139
|
}
|
|
111
140
|
/**Attaches a context menu to the given element
|
|
112
141
|
* @param element the element to attach the context menu to
|
|
@@ -155,18 +184,11 @@ function context_menu_summon(menu, element, x, y, dont_cover) {
|
|
|
155
184
|
} else console.error("No context menu container available");
|
|
156
185
|
}
|
|
157
186
|
/**Sets the default context menu for the page, the one used if no other context menu has been attached to the element
|
|
158
|
-
* If set to
|
|
187
|
+
* If set to false the operating system context menu is disabled and nothing will appear
|
|
159
188
|
* If set undefined the operating systems context menu will be used*/
|
|
160
189
|
function context_menu_default(lines) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
});
|
|
164
|
-
if (lines) {
|
|
165
|
-
default_menu = lines;
|
|
166
|
-
DOCUMENT_HANDLER.for_documents((doc) => {
|
|
167
|
-
context_menu_attach(doc.documentElement, lines);
|
|
168
|
-
});
|
|
169
|
-
}
|
|
190
|
+
default_menu = lines;
|
|
191
|
+
DOCUMENT_HANDLER.for_documents(apply_default_to_doc);
|
|
170
192
|
}
|
|
171
193
|
// src/context-menu/buffer.ts
|
|
172
194
|
var Buffer = class extends MenuLine {
|
|
@@ -178,6 +200,9 @@ var Buffer = class extends MenuLine {
|
|
|
178
200
|
super();
|
|
179
201
|
this.appendChild(new Spinner());
|
|
180
202
|
}
|
|
203
|
+
get skips_focus() {
|
|
204
|
+
return true;
|
|
205
|
+
}
|
|
181
206
|
do_focus(dir) {
|
|
182
207
|
this.focus_next(dir);
|
|
183
208
|
}
|
|
@@ -198,18 +223,18 @@ var MenuOption = class extends MenuLine {
|
|
|
198
223
|
icon_box.className = "icon";
|
|
199
224
|
if (icon) icon_box.appendChild(icon);
|
|
200
225
|
const text_box = this.appendChild(document.createElement("div"));
|
|
201
|
-
text_box.
|
|
226
|
+
text_box.textContent = text;
|
|
202
227
|
text_box.className = "text";
|
|
203
228
|
const shortcut_box = this.appendChild(document.createElement("div"));
|
|
204
|
-
if (shortcut) shortcut_box.
|
|
229
|
+
if (shortcut) shortcut_box.textContent = shortcut;
|
|
205
230
|
shortcut_box.className = "shortcut";
|
|
206
231
|
const check_mark_box = this.appendChild(document.createElement("div"));
|
|
207
|
-
if (checkmark) check_mark_box.
|
|
232
|
+
if (checkmark) check_mark_box.textContent = "✓";
|
|
208
233
|
check_mark_box.className = "checkmark";
|
|
209
234
|
this.onclick = (e) => {
|
|
210
235
|
e.stopPropagation();
|
|
211
236
|
this.func();
|
|
212
|
-
navigator?.
|
|
237
|
+
navigator.vibrate?.(25);
|
|
213
238
|
this.parentElement.close_up();
|
|
214
239
|
};
|
|
215
240
|
this.onkeydown = (e) => {
|
|
@@ -257,7 +282,7 @@ var MenuSub = class extends MenuLine {
|
|
|
257
282
|
icon_box.className = "icon";
|
|
258
283
|
if (icon) icon_box.appendChild(icon);
|
|
259
284
|
const text_box = this.appendChild(document.createElement("div"));
|
|
260
|
-
text_box.
|
|
285
|
+
text_box.textContent = text;
|
|
261
286
|
text_box.className = "text";
|
|
262
287
|
const shortcut_box = this.appendChild(document.createElement("div"));
|
|
263
288
|
shortcut_box.className = "shortcut";
|
|
@@ -267,7 +292,7 @@ var MenuSub = class extends MenuLine {
|
|
|
267
292
|
this.onclick = (e) => {
|
|
268
293
|
e.stopPropagation();
|
|
269
294
|
if (!this.#block_time) {
|
|
270
|
-
navigator?.
|
|
295
|
+
navigator.vibrate?.(25);
|
|
271
296
|
if (this.#is_open) this.close_down();
|
|
272
297
|
else this.open();
|
|
273
298
|
}
|
|
@@ -353,6 +378,8 @@ var ContextMenu = class extends Base {
|
|
|
353
378
|
#x;
|
|
354
379
|
#y;
|
|
355
380
|
#element;
|
|
381
|
+
/**Spinner shown while promised lines load, cleared when the menu closes*/
|
|
382
|
+
#loading;
|
|
356
383
|
#focus_out_handler = (e) => {
|
|
357
384
|
e.preventDefault();
|
|
358
385
|
e.stopPropagation();
|
|
@@ -388,19 +415,27 @@ var ContextMenu = class extends Base {
|
|
|
388
415
|
connectedCallback() {
|
|
389
416
|
super.connectedCallback();
|
|
390
417
|
const lines = typeof this.#lines === "function" ? this.#lines() : this.#lines;
|
|
418
|
+
this.#loading?.remove();
|
|
391
419
|
if (lines instanceof Promise) {
|
|
392
|
-
const buffer = this.appendChild(new Buffer());
|
|
420
|
+
const buffer = this.#loading = this.appendChild(new Buffer());
|
|
393
421
|
lines.then((line) => {
|
|
422
|
+
if (this.#loading !== buffer) return;
|
|
423
|
+
this.#loading = void 0;
|
|
394
424
|
buffer.remove();
|
|
395
425
|
this.lines = line;
|
|
396
426
|
this.set_position(this.#x, this.#y, this.#element);
|
|
397
427
|
});
|
|
398
|
-
} else
|
|
428
|
+
} else {
|
|
429
|
+
this.#loading = void 0;
|
|
430
|
+
this.lines = lines;
|
|
431
|
+
}
|
|
399
432
|
this.addEventListener("focusout", this.#focus_out_handler, { capture: true });
|
|
400
433
|
this.ownerDocument.defaultView?.addEventListener("resize", this.#window_resize_handler, { passive: true });
|
|
401
434
|
}
|
|
402
435
|
disconnectedCallback() {
|
|
403
436
|
super.disconnectedCallback();
|
|
437
|
+
this.#loading?.remove();
|
|
438
|
+
this.#loading = void 0;
|
|
404
439
|
this.ownerDocument.defaultView?.removeEventListener("resize", this.#window_resize_handler);
|
|
405
440
|
}
|
|
406
441
|
/**Sets the lines of the context menu */
|
|
@@ -415,8 +450,8 @@ var ContextMenu = class extends Base {
|
|
|
415
450
|
/**Changes focus to the next line
|
|
416
451
|
* @param direction false is first child, true is last child */
|
|
417
452
|
focus_next(direction) {
|
|
418
|
-
if (direction) this.lastChild?.do_focus();
|
|
419
|
-
else this.firstChild?.do_focus(
|
|
453
|
+
if (direction) this.lastChild?.do_focus(true);
|
|
454
|
+
else this.firstChild?.do_focus(false);
|
|
420
455
|
}
|
|
421
456
|
set closer(closer) {
|
|
422
457
|
if (closer && !this.#closer) {
|
|
@@ -478,12 +513,11 @@ var ContextMenu = class extends Base {
|
|
|
478
513
|
x = sub_box.x;
|
|
479
514
|
if (box.width < x) right = window.innerWidth - x;
|
|
480
515
|
else right = window.innerWidth - (sub_box.x + sub_box.width);
|
|
481
|
-
} else
|
|
516
|
+
} else left = sub_box.x + sub_box.width;
|
|
482
517
|
y = sub_box.y + sub_box.height;
|
|
483
|
-
if (y + box.height
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
} else top = y;
|
|
518
|
+
if (y + box.height < window.innerHeight) top = y;
|
|
519
|
+
else if (sub_box.y >= box.height) bottom = window.innerHeight - sub_box.y;
|
|
520
|
+
else top = Math.max(0, window.innerHeight - box.height);
|
|
487
521
|
} else {
|
|
488
522
|
if (y + box.height >= window.innerHeight) {
|
|
489
523
|
if (y >= box.height) bottom = window.innerHeight - y;
|
|
@@ -524,4 +558,4 @@ const ctm = {
|
|
|
524
558
|
};
|
|
525
559
|
export { ctm as t };
|
|
526
560
|
|
|
527
|
-
//# sourceMappingURL=context-menu-
|
|
561
|
+
//# sourceMappingURL=context-menu-_9dMpC-H.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-menu-_9dMpC-H.mjs","names":[],"sources":["../src/context-menu/shared.ts","../src/context-menu/line.ts","../src/context-menu/devider.ts","../src/context-menu/container.ts","../src/context-menu/engine.ts","../src/context-menu/buffer.ts","../src/context-menu/option.ts","../src/context-menu/submenu.ts","../src/context-menu/menu.ts","../src/context-menu/index.ts"],"sourcesContent":["import { BLUE, GREY } from \"@chocbite/ts-lib/colors\";\nimport { theme_init_variable_root } from \"#theme\";\n\nconst variables = theme_init_variable_root(\n \"contextmenu\",\n \"Context Menu\",\n \"Right click or touch and hold context menu appearance\",\n);\nvariables.make_variable(\n \"background\",\n \"Background Color\",\n \"Color of background\",\n GREY[\"50\"],\n GREY[\"900\"],\n \"Color\",\n undefined,\n);\nvariables.make_variable(\n \"text\",\n \"Text Color\",\n \"Color of text\",\n GREY[\"600\"],\n GREY[\"400\"],\n \"Color\",\n undefined,\n);\nvariables.make_variable(\n \"hover\",\n \"Hover Color\",\n \"Background color of line when hovering over it\",\n BLUE[\"200\"],\n BLUE[\"900\"],\n \"Color\",\n undefined,\n);\nvariables.make_variable(\n \"hoverText\",\n \"Text Color\",\n \"Standard text color\",\n GREY[\"900\"],\n GREY[\"50\"],\n \"Color\",\n undefined,\n);\nvariables.make_variable(\n \"border\",\n \"Border Color\",\n \"Color of border and deviders\",\n GREY[\"300\"],\n GREY[\"800\"],\n \"Color\",\n undefined,\n);\n","import { Base } from \"#base\";\nimport \"./option.scss\";\nimport \"./shared\";\n\nexport interface ContextMenuLine {}\n\nexport abstract class MenuLine extends Base implements ContextMenuLine {\n /**Returns the name used to define the element */\n static element_name() {\n return \"@abstract@\";\n }\n /**Returns the namespace override for the element*/\n static element_name_space() {\n return \"contextmenu\";\n }\n\n abstract do_focus(dir?: boolean): void;\n\n /**True for lines that can not take focus, like dividers, focus moves past them*/\n get skips_focus() {\n return false;\n }\n\n /**Changes focus to the next line, wrapping around and skipping lines that can not take focus\n * @param direction false is next sibling, true is previous */\n focus_next(direction?: boolean) {\n const parent = this.parentElement;\n if (!parent) return;\n let line = direction\n ? this.previousElementSibling\n : this.nextElementSibling;\n for (;;) {\n line ??= direction ? parent.lastElementChild : parent.firstElementChild;\n //Back at the start, there is no other line to focus\n if (!line || line === this) return;\n if (!(line as MenuLine).skips_focus)\n return (line as MenuLine).do_focus(direction);\n line = direction ? line.previousElementSibling : line.nextElementSibling;\n }\n }\n}\n","import { define_element } from \"#base\";\nimport \"./devider.scss\";\nimport { ContextMenuLine, MenuLine } from \"./line\";\n\nexport interface ContextMenuDevider extends ContextMenuLine {}\n\nexport class Devider extends MenuLine implements ContextMenuDevider {\n /**Returns the name used to define the element */\n static element_name() {\n return \"devider\";\n }\n\n get skips_focus() {\n return true;\n }\n\n do_focus(dir?: boolean) {\n this.focus_next(dir);\n }\n}\ndefine_element(Devider);\n\nexport function context_devider(): ContextMenuDevider {\n return new Devider();\n}\n","import { Base, define_element } from \"#base\";\nimport \"./container.scss\";\nimport { ContextMenu } from \"./menu\";\n\nexport class Container extends Base {\n #active_element_buffer: HTMLOrSVGElement | null | undefined;\n #replacing = false;\n\n /**Returns the name used to define the element */\n static element_name() {\n return \"container\";\n }\n /**Returns the namespace override for the element*/\n static element_name_space() {\n return \"contextmenu\";\n }\n\n constructor() {\n super();\n this.tabIndex = -1;\n const preventer = (e: Event) => {\n e.preventDefault();\n e.stopPropagation();\n };\n this.oncontextmenu = preventer;\n this.onpointerdown = preventer;\n this.onpointerup = preventer;\n this.onpointercancel = preventer;\n this.onpointerenter = preventer;\n this.onpointerleave = preventer;\n this.onpointermove = preventer;\n this.onpointerout = preventer;\n this.onpointerout = preventer;\n this.onclick = preventer;\n }\n\n /**Attaches a menu to the container */\n attach_menu(menu: ContextMenu) {\n menu.container = this;\n const old = this.firstElementChild as ContextMenu | null;\n if (old) {\n //Closed before replacing, the browser closes it from a focusout while it is being removed otherwise,\n //focus still returns to the element from before the old menu\n this.#replacing = true;\n old.close_down();\n old.close_up();\n this.#replacing = false;\n } else\n this.#active_element_buffer = this.ownerDocument\n .activeElement as HTMLOrSVGElement | null;\n this.replaceChildren(menu);\n return menu;\n }\n\n /**Closes open context menu */\n close_up() {\n if (this.#replacing) return;\n if (this.#active_element_buffer) {\n this.#active_element_buffer.focus();\n if (\n (this.ownerDocument.activeElement as any) !==\n this.#active_element_buffer\n ) {\n this.focus();\n }\n this.#active_element_buffer = undefined;\n } else {\n this.focus();\n }\n }\n}\ndefine_element(Container);\n","import { DOCUMENT_HANDLER } from \"#document\";\nimport type { Option } from \"@chocbite/ts-lib/result\";\nimport { Container } from \"./container\";\nimport \"./engine.scss\";\nimport { ContextMenu } from \"./menu\";\n\nexport const CONTEXT_MENY_SYMBOL = Symbol(\"context_menu\");\n\ndeclare global {\n interface Document {\n [CONTEXT_MENY_SYMBOL]: Container | undefined;\n }\n interface Element {\n [CONTEXT_MENY_SYMBOL]: EventListenerOrEventListenerObject | undefined;\n }\n}\n\n/**Default context menu, false blocks the operating system context menu, undefined leaves it*/\nlet default_menu: ContextMenu | (() => Option<ContextMenu>) | false | undefined;\n\n/**Blocks the operating system context menu when the default is false*/\nconst block_os_menu = (e: Event) => e.preventDefault();\n\nDOCUMENT_HANDLER.events.on(\"added\", (e) => {\n apply_to_doc(e.data);\n});\nDOCUMENT_HANDLER.for_documents((doc) => {\n apply_to_doc(doc);\n});\n\nfunction apply_to_doc(doc: Document) {\n const container = new Container();\n doc[CONTEXT_MENY_SYMBOL] = container;\n doc.documentElement.appendChild(container);\n apply_default_to_doc(doc);\n}\n\n/**Applies the current default context menu to a document*/\nfunction apply_default_to_doc(doc: Document) {\n const root = doc.documentElement;\n context_menu_detach(root);\n root.removeEventListener(\"contextmenu\", block_os_menu);\n if (default_menu) context_menu_attach(root, default_menu);\n else if (default_menu === false)\n root.addEventListener(\"contextmenu\", block_os_menu);\n}\n\n/**Attaches a context menu to the given element\n * @param element the element to attach the context menu to\n * @param lines the context menu to attach, if a function is given it will be called when the context menu is summoned\n * @param block a function that returns true if the context menu should not be summoned, if undefined the context menu will always be summoned*/\nexport function context_menu_attach(\n element: Element,\n lines: ContextMenu | (() => Option<ContextMenu>),\n block?: () => boolean,\n) {\n if (element[CONTEXT_MENY_SYMBOL]) context_menu_detach(element);\n const listener = (e: Event) => {\n e.preventDefault();\n e.stopPropagation();\n if (block && block()) return;\n const lineses =\n typeof lines === \"function\" ? lines().unwrap_or(undefined) : lines;\n if (!lineses) return;\n context_menu_summon(\n lineses,\n element,\n (e as MouseEvent).clientX,\n (e as MouseEvent).clientY,\n );\n };\n element.addEventListener(\"contextmenu\", listener);\n element[CONTEXT_MENY_SYMBOL] = listener;\n}\n\n/**Dettaches the context menu from the given element */\nexport function context_menu_detach(element: Element) {\n if (element[CONTEXT_MENY_SYMBOL]) {\n element.removeEventListener(\"contextmenu\", element[CONTEXT_MENY_SYMBOL]);\n delete element[CONTEXT_MENY_SYMBOL];\n }\n}\n\n/**Summons a context menu at a given location\n * @param menu the context menu to summon\n * @param element the element the context menu is referenced to, if undefined the context menu will appear in the main document\n * @param x x position for context menu, if undefined, will use element middle, if element undefined, will put context menu in the top left corner of the screen\n * @param y y position for context menu, if undefined, will use element middle, if element undefined, will put context menu in the top left corner of the screen\n * @param dont_cover when set true */\nexport function context_menu_summon(\n menu: ContextMenu,\n element?: Element,\n x?: number,\n y?: number,\n dont_cover?: boolean,\n) {\n const container = element\n ? element.ownerDocument[CONTEXT_MENY_SYMBOL]\n : DOCUMENT_HANDLER.main[CONTEXT_MENY_SYMBOL];\n if (container) {\n if (typeof x !== \"number\" || typeof y !== \"number\") {\n if (element) {\n const box = element.getBoundingClientRect();\n x = box.left + box.width / 2;\n y = box.top + box.height / 2;\n } else {\n x = 0;\n y = 0;\n }\n }\n container\n .attach_menu(menu)\n .set_position(x, y, dont_cover ? element : undefined);\n } else console.error(\"No context menu container available\");\n}\n\n/**Sets the default context menu for the page, the one used if no other context menu has been attached to the element\n * If set to false the operating system context menu is disabled and nothing will appear\n * If set undefined the operating systems context menu will be used*/\nexport function context_menu_default(\n lines: ContextMenu | (() => Option<ContextMenu>) | false | undefined,\n) {\n default_menu = lines;\n DOCUMENT_HANDLER.for_documents(apply_default_to_doc);\n}\n","import { define_element } from \"#base\";\nimport { Spinner } from \"#spinner\";\nimport \"./buffer.scss\";\nimport { MenuLine } from \"./line\";\n\nexport class Buffer extends MenuLine {\n /**Returns the name used to define the element */\n static element_name() {\n return \"buffer\";\n }\n\n constructor() {\n super();\n this.appendChild(new Spinner());\n }\n\n get skips_focus() {\n return true;\n }\n\n do_focus(dir: boolean) {\n this.focus_next(dir);\n }\n}\ndefine_element(Buffer);\n","import { define_element } from \"#base\";\nimport { ContextMenuLine, MenuLine } from \"./line\";\nimport { ContextMenu } from \"./menu\";\nimport \"./option.scss\";\n\nexport interface ContextMenuOption extends ContextMenuLine {}\n\nexport class MenuOption extends MenuLine implements ContextMenuOption {\n readonly func: () => void;\n\n /**Returns the name used to define the element */\n static element_name() {\n return \"option\";\n }\n\n constructor(\n text: string,\n func: () => void,\n icon?: SVGSVGElement,\n shortcut?: string,\n checkmark?: boolean,\n ) {\n super();\n this.func = func;\n this.tabIndex = 0;\n const icon_box = this.appendChild(document.createElement(\"div\"));\n icon_box.className = \"icon\";\n if (icon) icon_box.appendChild(icon);\n const text_box = this.appendChild(document.createElement(\"div\"));\n text_box.textContent = text;\n text_box.className = \"text\";\n const shortcut_box = this.appendChild(document.createElement(\"div\"));\n if (shortcut) shortcut_box.textContent = shortcut;\n shortcut_box.className = \"shortcut\";\n const check_mark_box = this.appendChild(document.createElement(\"div\"));\n if (checkmark) check_mark_box.textContent = \"✓\";\n check_mark_box.className = \"checkmark\";\n\n this.onclick = (e) => {\n e.stopPropagation();\n this.func();\n navigator.vibrate?.(25);\n (this.parentElement as ContextMenu).close_up();\n };\n\n this.onkeydown = (e) => {\n switch (e.code) {\n case \"Tab\":\n case \"ArrowUp\":\n case \"ArrowDown\":\n this.focus_next(e.shiftKey || e.code === \"ArrowUp\");\n break;\n case \"Enter\":\n case \"Space\":\n this.func();\n (this.parentElement as ContextMenu).close_up();\n break;\n case \"ArrowLeft\":\n case \"Escape\":\n return;\n }\n e.preventDefault();\n e.stopPropagation();\n };\n }\n\n do_focus(): void {\n this.focus();\n }\n}\ndefine_element(MenuOption);\n\nexport function context_line(\n text: string,\n func: () => void,\n icon?: SVGSVGElement,\n shortcut?: string,\n checkmark?: boolean,\n): ContextMenuOption {\n return new MenuOption(text, func, icon, shortcut, checkmark);\n}\n","import { define_element } from \"#base\";\nimport { material_chevron_right_rounded } from \"#icons\";\nimport { ContextMenuLine, MenuLine } from \"./line\";\nimport { ContextMenu } from \"./menu\";\nimport \"./submenu.scss\";\n\nexport interface ContextMenuSub extends ContextMenuLine {}\n\ntype Mutable<T> = {\n -readonly [P in keyof T]: T[P];\n};\nexport class MenuSub extends MenuLine implements ContextMenuSub {\n #menu: ContextMenu;\n #is_open?: boolean;\n #hover_time?: number;\n #block_time?: number;\n\n /**Returns the name used to define the element */\n static element_name() {\n return \"submenu\";\n }\n\n constructor(text: string, menu: ContextMenu, icon?: SVGSVGElement) {\n super();\n this.#menu = menu;\n this.tabIndex = 0;\n const icon_box = this.appendChild(document.createElement(\"div\"));\n icon_box.className = \"icon\";\n if (icon) icon_box.appendChild(icon);\n const text_box = this.appendChild(document.createElement(\"div\"));\n text_box.textContent = text;\n text_box.className = \"text\";\n const shortcut_box = this.appendChild(document.createElement(\"div\"));\n shortcut_box.className = \"shortcut\";\n const chevron_box = this.appendChild(document.createElement(\"div\"));\n chevron_box.appendChild(material_chevron_right_rounded());\n chevron_box.className = \"chevron\";\n\n this.onclick = (e) => {\n e.stopPropagation();\n if (!this.#block_time) {\n navigator.vibrate?.(25);\n if (this.#is_open) {\n this.close_down();\n } else {\n this.open();\n }\n }\n };\n\n this.onpointerenter = (e) => {\n if (e.pointerType !== \"touch\" && !this.#is_open) {\n this.#hover_time = window.setTimeout(() => {\n this.open();\n this.#block_time = window.setTimeout(() => {\n this.#block_time = 0;\n }, 500);\n }, 300);\n }\n };\n this.onpointerleave = () => {\n clearTimeout(this.#hover_time);\n };\n this.onkeydown = (e) => {\n switch (e.code) {\n case \"Tab\":\n case \"ArrowUp\":\n case \"ArrowDown\":\n this.focus_next(e.shiftKey || e.code === \"ArrowUp\");\n break;\n case \"ArrowRight\":\n case \"Enter\":\n case \"Space\":\n this.open();\n this.#menu.focus_next(false);\n break;\n case \"ArrowLeft\":\n case \"Escape\":\n return;\n }\n e.preventDefault();\n e.stopPropagation();\n };\n }\n\n /**Opens the sub menu */\n open() {\n const sub = this.parentElement as Mutable<ContextMenu>;\n if (sub) sub.close_down();\n (this.parentElement as Mutable<ContextMenu>).submenu = this;\n this.appendChild(this.#menu);\n this.#menu.set_position(0, 0, this);\n this.#is_open = true;\n }\n\n do_focus(): void {\n this.focus();\n }\n\n /**Closes menu by calling parent*/\n close() {\n this.focus();\n (this.parentElement as Mutable<ContextMenu>).submenu = undefined;\n this.removeChild(this.#menu);\n this.#is_open = false;\n }\n\n /**Closes the context menu down the tree*/\n close_down() {\n this.#menu.close_down();\n this.close();\n }\n\n /**Closes the context menu up the tree to the root*/\n close_up() {\n this.close();\n (this.parentElement as ContextMenu).close_up();\n }\n}\ndefine_element(MenuSub);\n\nexport function context_sub(\n text: string,\n menu: ContextMenu,\n icon?: SVGSVGElement,\n): ContextMenuSub {\n return new MenuSub(text, menu, icon);\n}\n","import { Base, define_element } from \"#base\";\nimport { material_close_rounded } from \"#icons\";\nimport { Buffer } from \"./buffer\";\nimport { Container } from \"./container\";\nimport { ContextMenuLine, MenuLine } from \"./line\";\nimport \"./menu.scss\";\nimport { MenuOption } from \"./option\";\nimport \"./shared\";\nimport { MenuSub } from \"./submenu\";\n\nexport type ContextMenuLines = ContextMenuLine[];\n\nexport class ContextMenu extends Base {\n /**Returns the name used to define the element */\n static element_name() {\n return \"menu\";\n }\n /**Returns the namespace override for the element*/\n static element_name_space() {\n return \"contextmenu\";\n }\n\n container: Container | undefined;\n readonly submenu: MenuSub | undefined;\n #closer: MenuOption | undefined;\n #x: number | undefined;\n #y: number | undefined;\n #element: Element | undefined;\n /**Spinner shown while promised lines load, cleared when the menu closes*/\n #loading: Buffer | undefined;\n #focus_out_handler = (e: FocusEvent) => {\n e.preventDefault();\n e.stopPropagation();\n if (!e.relatedTarget || !this.contains(e.relatedTarget as Node)) {\n this.close_up();\n this.close_down();\n }\n };\n #window_resize_handler = () => {\n this.set_position(this.#x, this.#y, this.#element);\n };\n\n #lines:\n | (\n | (ContextMenuLine | undefined)[]\n | Promise<(ContextMenuLine | undefined)[]>\n )\n | (() =>\n | (ContextMenuLine | undefined)[]\n | Promise<(ContextMenuLine | undefined)[]>);\n\n constructor(\n lines:\n | (\n | (ContextMenuLine | undefined)[]\n | Promise<(ContextMenuLine | undefined)[]>\n )\n | (() =>\n | (ContextMenuLine | undefined)[]\n | Promise<(ContextMenuLine | undefined)[]>),\n ) {\n super();\n this.#lines = lines;\n this.tabIndex = 0;\n this.onscroll = () => {\n this.close_down();\n };\n this.onkeydown = (e) => {\n if (e.code === \"Tab\" || e.code === \"ArrowUp\" || e.code === \"ArrowDown\")\n this.focus_next(e.shiftKey || e.code === \"ArrowUp\");\n else if (e.code === \"ArrowLeft\") {\n const parent = this.parentElement as MenuSub | Container;\n if (!(parent instanceof Container)) {\n parent.focus();\n parent.close_down();\n }\n } else if (e.code === \"Escape\") this.close_up();\n e.preventDefault();\n e.stopPropagation();\n };\n }\n\n protected connectedCallback(): void {\n super.connectedCallback();\n const lines =\n typeof this.#lines === \"function\" ? this.#lines() : this.#lines;\n this.#loading?.remove();\n if (lines instanceof Promise) {\n const buffer = (this.#loading = this.appendChild(new Buffer()));\n lines.then((line) => {\n //Closed or opened again before the lines arrived\n if (this.#loading !== buffer) return;\n this.#loading = undefined;\n buffer.remove();\n this.lines = line;\n this.set_position(this.#x, this.#y, this.#element);\n });\n } else {\n this.#loading = undefined;\n this.lines = lines;\n }\n this.addEventListener(\"focusout\", this.#focus_out_handler, {\n capture: true,\n });\n this.ownerDocument.defaultView?.addEventListener(\n \"resize\",\n this.#window_resize_handler,\n { passive: true },\n );\n }\n\n protected disconnectedCallback(): void {\n super.disconnectedCallback();\n //Lines arriving after the menu closed are not shown\n this.#loading?.remove();\n this.#loading = undefined;\n this.ownerDocument.defaultView?.removeEventListener(\n \"resize\",\n this.#window_resize_handler,\n );\n }\n\n /**Sets the lines of the context menu */\n set lines(lines: (ContextMenuLine | undefined)[]) {\n this.replaceChildren();\n if (this.#closer) this.appendChild(this.#closer);\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n if (line) this.appendChild(line as MenuLine);\n }\n }\n\n /**Changes focus to the next line\n * @param direction false is first child, true is last child */\n focus_next(direction: boolean) {\n //The direction is passed on, so a divider skips to the line after it, toward the middle\n if (direction) (this.lastChild as MenuLine)?.do_focus(true);\n else (this.firstChild as MenuLine)?.do_focus(false);\n }\n\n set closer(closer: boolean) {\n if (closer && !this.#closer) {\n this.classList.add(\"closer\");\n this.#closer = new MenuOption(\n \"Close\",\n () => {},\n material_close_rounded(),\n );\n this.#closer.onclick = (e) => {\n e.stopPropagation();\n if (this.parentElement instanceof MenuSub) {\n this.parentElement.close_down();\n } else {\n this.close_up();\n }\n };\n this.prepend(this.#closer);\n } else if (!closer && this.#closer) {\n this.classList.remove(\"closer\");\n this.#closer.remove();\n this.#closer = undefined;\n }\n }\n\n /**Sets the context menu to fullscreen mode in x directino */\n set fullscreenx(full: boolean) {\n if (full) this.classList.add(\"fullscreen-x\");\n else this.classList.remove(\"fullscreen-x\");\n }\n\n /**Sets the context menu to fullscreen mode in y direction */\n set fullscreeny(full: boolean) {\n if (full) this.classList.add(\"fullscreen-y\");\n else this.classList.remove(\"fullscreen-y\");\n }\n\n /**Closes the context menu down the tree*/\n close_down() {\n if (this.submenu) this.submenu.close_down();\n //@ts-expect-error Writing to readonly property, from inside class itself\n this.submenu = undefined;\n }\n\n /**Closes the context menu up the tree to the root*/\n close_up() {\n this.removeEventListener(\"focusout\", this.#focus_out_handler, {\n capture: true,\n });\n (this.parentElement as Container)?.close_up();\n this.remove();\n }\n\n /**Updates the position of the menu\n * @param x x coordinate for menu, this will be ignored if needed for contextmenu to fit\n * @param y y coordinate for menu, this will be ignored if needed for contextmenu to fit\n * @param element element to use instead of coordinates, the contextemenu will avoid covering the element if possible*/\n set_position(x: number = 0, y: number = 0, element?: Element) {\n this.#x = x;\n this.#y = y;\n this.#element = element;\n const box = this.getBoundingClientRect();\n const box_area = box.width * box.height;\n const window = this.ownerDocument.defaultView!;\n const html_area = window.innerWidth * window.innerHeight;\n this.closer = box_area > html_area * 0.5;\n let top = NaN;\n let bottom = NaN;\n let left = NaN;\n let right = NaN;\n if (element) {\n const sub_box = element.getBoundingClientRect();\n\n if (sub_box.x + sub_box.width + box.width > window.innerWidth) {\n x = sub_box.x;\n if (box.width < x) right = window.innerWidth - x;\n else right = window.innerWidth - (sub_box.x + sub_box.width);\n } else left = sub_box.x + sub_box.width;\n\n y = sub_box.y + sub_box.height;\n\n //Below the element, else above it, else as low as the window allows\n if (y + box.height < window.innerHeight) top = y;\n else if (sub_box.y >= box.height) bottom = window.innerHeight - sub_box.y;\n else top = Math.max(0, window.innerHeight - box.height);\n } else {\n if (y + box.height >= window.innerHeight) {\n if (y >= box.height) bottom = window.innerHeight - y;\n else top = window.innerHeight - box.height;\n } else top = y;\n\n if (box.width >= window.innerWidth) {\n right = 0;\n } else if (x + box.width >= window.innerWidth) {\n if (x >= box.width) right = window.innerWidth - x;\n else left = window.innerWidth - box.width;\n } else left = x;\n }\n this.fullscreenx = box.width === window.innerWidth;\n this.fullscreeny = box.height >= window.innerHeight;\n\n this.style.top = top === top ? top + \"px\" : \"\";\n this.style.bottom = bottom === bottom ? bottom + \"px\" : \"\";\n this.style.left = left === left ? left + \"px\" : \"\";\n this.style.right = right === right ? right + \"px\" : \"\";\n this.focus();\n }\n}\ndefine_element(ContextMenu);\n\nexport function context_menu(\n lines:\n | (\n | (ContextMenuLine | undefined)[]\n | Promise<(ContextMenuLine | undefined)[]>\n )\n | (() => (ContextMenuLine | undefined)[])\n | (() => Promise<(ContextMenuLine | undefined)[]>),\n): ContextMenu {\n return new ContextMenu(lines);\n}\n","import { context_devider } from \"./devider\";\nimport {\n context_menu_attach,\n context_menu_default,\n context_menu_detach,\n context_menu_summon,\n CONTEXT_MENY_SYMBOL,\n} from \"./engine\";\nimport { context_menu } from \"./menu\";\nimport { context_line } from \"./option\";\nimport { context_sub } from \"./submenu\";\n\nexport const ctm = {\n attach: context_menu_attach,\n default: context_menu_default,\n detach: context_menu_detach,\n summon: context_menu_summon,\n has(element: Element) {\n return Boolean(element[CONTEXT_MENY_SYMBOL]);\n },\n menu: context_menu,\n line: context_line,\n sub: context_sub,\n devider: context_devider,\n};\nexport default ctm;\n\nexport type { ContextMenu, ContextMenuLines } from \"./menu\";\n"],"mappings":";;;;;;;;AAGA,MAAM,YAAY,yBAChB,eACA,gBACA,uDACF;AACA,UAAU,cACR,cACA,oBACA,uBACA,KAAK,OACL,KAAK,QACL,SACA,KAAA,CACF;AACA,UAAU,cACR,QACA,cACA,iBACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AACA,UAAU,cACR,SACA,eACA,kDACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AACA,UAAU,cACR,aACA,cACA,uBACA,KAAK,QACL,KAAK,OACL,SACA,KAAA,CACF;AACA,UAAU,cACR,UACA,gBACA,gCACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;;AC9CA,IAAsB,WAAtB,cAAuC,KAAgC;;CAErE,OAAO,eAAe;EACpB,OAAO;CACT;;CAEA,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KAAK,IAAI,QAAQ,SAAS,OAAO,cAAc,QAAQ;QACnE,MAAM,KAAK,IAAI,GAAG,OAAO,cAAc,IAAI,MAAM;EACxD,OAAO;GACL,IAAI,IAAI,IAAI,UAAU,OAAO,aAAa;IACxC,IAAI,KAAK,IAAI,QAAQ,SAAS,OAAO,cAAc;SAC9C,MAAM,OAAO,cAAc,IAAI;GACtC,OAAO,MAAM;GAEb,IAAI,IAAI,SAAS,OAAO,YACtB,QAAQ;QACH,IAAI,IAAI,IAAI,SAAS,OAAO,YAAY;IAC7C,IAAI,KAAK,IAAI,OAAO,QAAQ,OAAO,aAAa;SAC3C,OAAO,OAAO,aAAa,IAAI;GACtC,OAAO,OAAO;EAChB;EACA,KAAK,cAAc,IAAI,UAAU,OAAO;EACxC,KAAK,cAAc,IAAI,UAAU,OAAO;EAExC,KAAK,MAAM,MAAM,QAAQ,MAAM,MAAM,OAAO;EAC5C,KAAK,MAAM,SAAS,WAAW,SAAS,SAAS,OAAO;EACxD,KAAK,MAAM,OAAO,SAAS,OAAO,OAAO,OAAO;EAChD,KAAK,MAAM,QAAQ,UAAU,QAAQ,QAAQ,OAAO;EACpD,KAAK,MAAM;CACb;AACF;AACA,eAAe,WAAW;AAE1B,SAAgB,aACd,OAOa;CACb,OAAO,IAAI,YAAY,KAAK;AAC9B;;ACvPA,MAAa,MAAM;CACjB,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,QAAQ;CACR,IAAI,SAAkB;EACpB,OAAO,QAAQ,QAAQ,oBAAoB;CAC7C;CACA,MAAM;CACN,MAAM;CACN,KAAK;CACL,SAAS;AACX"}
|
package/document/index.mjs
CHANGED
|
@@ -30,7 +30,9 @@ var DocumentHandler = class {
|
|
|
30
30
|
if (styles) {
|
|
31
31
|
const head_elements = this.main.head.children;
|
|
32
32
|
for (let i = 0; i < head_elements.length; i++) switch (head_elements[i].nodeName) {
|
|
33
|
-
case "LINK":
|
|
33
|
+
case "LINK":
|
|
34
|
+
if (head_elements[i].rel === "stylesheet") document.head.appendChild(head_elements[i].cloneNode(true));
|
|
35
|
+
break;
|
|
34
36
|
case "STYLE": document.head.appendChild(head_elements[i].cloneNode(true));
|
|
35
37
|
}
|
|
36
38
|
}
|
package/document/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/document/document.ts"],"sourcesContent":["import { EventHandler } from \"@chocbite/ts-lib/event\";\n\ninterface DocumentHandlerEvents {\n /**Fired when document is added*/\n added: Document;\n /**Fired when document is removed*/\n removed: Document;\n}\n\nclass DocumentHandler {\n /**Stores all managed documents */\n #documents: Set<Document> = new Set();\n /**Stores the main docuement of the manager */\n readonly main: Document;\n /**Event handler */\n #events: EventHandler<DocumentHandlerEvents, this> = new EventHandler(this);\n /**Manager events */\n readonly events = this.#events.consumer;\n\n constructor(main_document: Document) {\n this.main = main_document;\n this.#documents.add(main_document);\n }\n\n /**Itterates a function over all existing documents */\n for_documents(func: (document: Document) => void) {\n for (const doc of this.#documents) {\n func(doc);\n }\n }\n\n get documents() {\n return [...this.#documents];\n }\n\n /**Registers a document with the theme engine, which will be updated with\n * @param document document to register\n * @param styles copies all style from main document if set true */\n register_document(document: Document, styles?: boolean) {\n if (this.#documents.has(document))\n return console.error(\"Document already registered\");\n this.#documents.add(document);\n if (styles) {\n const head_elements = this.main.head.children;\n for (let i = 0; i < head_elements.length; i++) {\n switch (head_elements[i].nodeName) {\n case \"LINK\":\n break;\n case \"STYLE\":\n document.head.appendChild(head_elements[i].cloneNode(true));\n break;\n }\n }\n }\n this.#events.emit(\"added\", document);\n }\n\n /**Registers a document with the theme engine, which will be updated with */\n deregister_document(document: Document) {\n if (!this.#documents.has(document))\n return console.error(\"Document not registered\");\n if (document === this.main)\n return console.error(\"Main document cannot be removed\");\n this.#documents.delete(document);\n this.#events.emit(\"removed\", document);\n }\n}\n\nexport const DOCUMENT_HANDLER = new DocumentHandler(document);\n"],"mappings":";;;AASA,IAAM,kBAAN,MAAsB;;CAEpB,6BAA4B,IAAI,IAAI;;CAEpC;;CAEA,UAAqD,IAAI,aAAa,IAAI;;CAE1E,SAAkB,KAAK,QAAQ;CAE/B,YAAY,eAAyB;EACnC,KAAK,OAAO;EACZ,KAAK,WAAW,IAAI,aAAa;CACnC;;CAGA,cAAc,MAAoC;EAChD,KAAK,MAAM,OAAO,KAAK,YACrB,KAAK,GAAG;CAEZ;CAEA,IAAI,YAAY;EACd,OAAO,CAAC,GAAG,KAAK,UAAU;CAC5B;;;;CAKA,kBAAkB,UAAoB,QAAkB;EACtD,IAAI,KAAK,WAAW,IAAI,QAAQ,GAC9B,OAAO,QAAQ,MAAM,6BAA6B;EACpD,KAAK,WAAW,IAAI,QAAQ;EAC5B,IAAI,QAAQ;GACV,MAAM,gBAAgB,KAAK,KAAK,KAAK;GACrC,KAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,KACxC,QAAQ,cAAc,EAAE,CAAC,UAAzB;IACE,KAAK,
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/document/document.ts"],"sourcesContent":["import { EventHandler } from \"@chocbite/ts-lib/event\";\n\ninterface DocumentHandlerEvents {\n /**Fired when document is added*/\n added: Document;\n /**Fired when document is removed*/\n removed: Document;\n}\n\nclass DocumentHandler {\n /**Stores all managed documents */\n #documents: Set<Document> = new Set();\n /**Stores the main docuement of the manager */\n readonly main: Document;\n /**Event handler */\n #events: EventHandler<DocumentHandlerEvents, this> = new EventHandler(this);\n /**Manager events */\n readonly events = this.#events.consumer;\n\n constructor(main_document: Document) {\n this.main = main_document;\n this.#documents.add(main_document);\n }\n\n /**Itterates a function over all existing documents */\n for_documents(func: (document: Document) => void) {\n for (const doc of this.#documents) {\n func(doc);\n }\n }\n\n get documents() {\n return [...this.#documents];\n }\n\n /**Registers a document with the theme engine, which will be updated with\n * @param document document to register\n * @param styles copies all style from main document if set true */\n register_document(document: Document, styles?: boolean) {\n if (this.#documents.has(document))\n return console.error(\"Document already registered\");\n this.#documents.add(document);\n if (styles) {\n const head_elements = this.main.head.children;\n for (let i = 0; i < head_elements.length; i++) {\n switch (head_elements[i].nodeName) {\n case \"LINK\":\n //Built apps load their css through a stylesheet link\n if ((head_elements[i] as HTMLLinkElement).rel === \"stylesheet\")\n document.head.appendChild(head_elements[i].cloneNode(true));\n break;\n case \"STYLE\":\n document.head.appendChild(head_elements[i].cloneNode(true));\n break;\n }\n }\n }\n this.#events.emit(\"added\", document);\n }\n\n /**Registers a document with the theme engine, which will be updated with */\n deregister_document(document: Document) {\n if (!this.#documents.has(document))\n return console.error(\"Document not registered\");\n if (document === this.main)\n return console.error(\"Main document cannot be removed\");\n this.#documents.delete(document);\n this.#events.emit(\"removed\", document);\n }\n}\n\nexport const DOCUMENT_HANDLER = new DocumentHandler(document);\n"],"mappings":";;;AASA,IAAM,kBAAN,MAAsB;;CAEpB,6BAA4B,IAAI,IAAI;;CAEpC;;CAEA,UAAqD,IAAI,aAAa,IAAI;;CAE1E,SAAkB,KAAK,QAAQ;CAE/B,YAAY,eAAyB;EACnC,KAAK,OAAO;EACZ,KAAK,WAAW,IAAI,aAAa;CACnC;;CAGA,cAAc,MAAoC;EAChD,KAAK,MAAM,OAAO,KAAK,YACrB,KAAK,GAAG;CAEZ;CAEA,IAAI,YAAY;EACd,OAAO,CAAC,GAAG,KAAK,UAAU;CAC5B;;;;CAKA,kBAAkB,UAAoB,QAAkB;EACtD,IAAI,KAAK,WAAW,IAAI,QAAQ,GAC9B,OAAO,QAAQ,MAAM,6BAA6B;EACpD,KAAK,WAAW,IAAI,QAAQ;EAC5B,IAAI,QAAQ;GACV,MAAM,gBAAgB,KAAK,KAAK,KAAK;GACrC,KAAK,IAAI,IAAI,GAAG,IAAI,cAAc,QAAQ,KACxC,QAAQ,cAAc,EAAE,CAAC,UAAzB;IACE,KAAK;KAEH,IAAK,cAAc,EAAE,CAAqB,QAAQ,cAChD,SAAS,KAAK,YAAY,cAAc,EAAE,CAAC,UAAU,IAAI,CAAC;KAC5D;IACF,KAAK,SACH,SAAS,KAAK,YAAY,cAAc,EAAE,CAAC,UAAU,IAAI,CAAC;GAE9D;EAEJ;EACA,KAAK,QAAQ,KAAK,SAAS,QAAQ;CACrC;;CAGA,oBAAoB,UAAoB;EACtC,IAAI,CAAC,KAAK,WAAW,IAAI,QAAQ,GAC/B,OAAO,QAAQ,MAAM,yBAAyB;EAChD,IAAI,aAAa,KAAK,MACpB,OAAO,QAAQ,MAAM,iCAAiC;EACxD,KAAK,WAAW,OAAO,QAAQ;EAC/B,KAAK,QAAQ,KAAK,WAAW,QAAQ;CACvC;AACF;AAEA,MAAa,mBAAmB,IAAI,gBAAgB,QAAQ"}
|
package/form/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import '../style.css';
|
|
2
|
-
import {
|
|
3
|
-
import { t as SVGFunc } from "../index-
|
|
4
|
-
import { n as ListField } from "../index-
|
|
2
|
+
import { l as Base, p as AccessTypes } from "../index-CvzH3M_5.mjs";
|
|
3
|
+
import { t as SVGFunc } from "../index-BDWg5GX2.mjs";
|
|
4
|
+
import { n as ListField } from "../index-CzpbJoAj.mjs";
|
|
5
5
|
import { State, StateEnumRelated, StateNumberRelated, StateREAW, StateStringRelated } from "@chocbite/ts-lib/state";
|
|
6
6
|
import { Option, Result } from "@chocbite/ts-lib/result";
|
|
7
7
|
import { IPAddress, IPVersion, Prettify } from "@chocbite/ts-lib/common";
|
|
@@ -38,7 +38,7 @@ export declare abstract class FormValue<RT, ID extends string | undefined> exten
|
|
|
38
38
|
readonly form_id: ID;
|
|
39
39
|
constructor(id?: ID);
|
|
40
40
|
protected _description?: string;
|
|
41
|
-
/**Sets the
|
|
41
|
+
/**Sets the description of the element, shown as a tooltip*/
|
|
42
42
|
set description(text: string);
|
|
43
43
|
get description(): string;
|
|
44
44
|
protected _buffer?: RT;
|
|
@@ -86,12 +86,16 @@ export declare abstract class FormValueWrite<RT, ID extends string | undefined>
|
|
|
86
86
|
warn(message: string): void;
|
|
87
87
|
/**Function to limit value entered */
|
|
88
88
|
protected limit_value(val: RT): PromiseLike<Result<RT, string>>;
|
|
89
|
-
/**Function to check value */
|
|
89
|
+
/**Function to check value, a state checks the value itself when it is written, so it is not checked here*/
|
|
90
90
|
protected check_value(val: RT): PromiseLike<Result<RT, string>>;
|
|
91
91
|
/**Function to update value*/
|
|
92
92
|
protected set_value_limit(val: RT): Promise<Result<RT, string>>;
|
|
93
93
|
/**Function to update value*/
|
|
94
94
|
protected set_value_check(val: RT): Promise<Result<RT, string>>;
|
|
95
|
+
/**Calls the change listener with a value the user changed, and lets a parent group know*/
|
|
96
|
+
protected call_change(val: RT): void;
|
|
97
|
+
/**Called when a child value element with a form id was changed by the user*/
|
|
98
|
+
protected child_changed(_child: FormValueWrite<any, any>): void;
|
|
95
99
|
}
|
|
96
100
|
interface FormButtonOptions<ID extends string | undefined> extends FormValueWriteOptions<boolean, ID> {
|
|
97
101
|
/**Buttons text */
|
|
@@ -208,6 +212,7 @@ type GroupExtractVals<Arr extends any[]> = Arr extends [infer Head, ...infer Tai
|
|
|
208
212
|
type GroupToKeyVal<Arr extends FormValue<any, any>[]> = { [K in Arr[number] as K extends FormValue<any, infer ID> ? [ID] extends [string] ? ID : never : never]: K extends FormValue<infer T, any> ? T : never; };
|
|
209
213
|
type GroupValueElements<Elements extends FormElement[]> = { [Element in Elements[number] as Element extends FormValueWrite<any, infer ID> ? [ID] extends [string] ? ID : never : never]: Element; };
|
|
210
214
|
declare abstract class FormGroupBase<RT extends object, ID extends string | undefined, Elements extends FormElement[] = FormElement[]> extends FormValueWrite<Partial<RT>, ID> {
|
|
215
|
+
#private;
|
|
211
216
|
static element_name(): string;
|
|
212
217
|
static element_name_space(): string;
|
|
213
218
|
protected _value_elements: Map<string, FormValueWrite<any, any>>;
|
|
@@ -222,6 +227,8 @@ declare abstract class FormGroupBase<RT extends object, ID extends string | unde
|
|
|
222
227
|
get get_value(): Result<RT, string>;
|
|
223
228
|
/**Returns partial value of the group, containing all values of components that have values*/
|
|
224
229
|
get value_partial(): Result<Partial<RT>, string>;
|
|
230
|
+
/**The change listener of the group gets the values of all components that have values*/
|
|
231
|
+
protected child_changed(child: FormValueWrite<any, any>): void;
|
|
225
232
|
/**Returns partial value of the group, only containing values of components where value has changed*/
|
|
226
233
|
get value_changed(): Result<Partial<RT>, string>;
|
|
227
234
|
protected new_value(val: RT): void;
|
|
@@ -247,12 +254,14 @@ interface FormGroupOptions<L extends FormElement[], ID extends string | undefine
|
|
|
247
254
|
}
|
|
248
255
|
/**Component group class which allows to add elements and controls the flow of the elements*/
|
|
249
256
|
declare class FormGroup<RT extends object, ID extends string | undefined, Elements extends FormElement[] = FormValueWrite<any, string>[]> extends FormGroupBase<RT, ID, Elements> {
|
|
257
|
+
#private;
|
|
250
258
|
static element_name(): string;
|
|
251
259
|
static element_name_space(): string;
|
|
252
260
|
constructor(id?: ID);
|
|
253
261
|
set column(column: true | string | string[]);
|
|
254
262
|
set row(row: true | string | string[]);
|
|
255
263
|
set elements(elements: FormElement[]);
|
|
264
|
+
/**All elements added to the group, also those without a form id*/
|
|
256
265
|
get elements(): FormElement[];
|
|
257
266
|
}
|
|
258
267
|
/**Creates a form group with elements */
|
|
@@ -312,6 +321,7 @@ interface FormStepperBaseOptions<ID extends string | undefined, RT = number> ext
|
|
|
312
321
|
icon_increase?: SVGFunc;
|
|
313
322
|
}
|
|
314
323
|
declare abstract class FormNumberWrite<ID extends string | undefined, RT = number> extends FormValueWrite<RT, ID> {
|
|
324
|
+
#private;
|
|
315
325
|
static apply_options<RT, ID extends string | undefined>(element: FormNumberWrite<ID, RT>, options: FormNumberWriteOptions<ID, RT>): void;
|
|
316
326
|
/**Set the minimum value*/
|
|
317
327
|
abstract set min(min: number | undefined);
|
|
@@ -436,6 +446,7 @@ interface FormSelectorBaseOptions<T, ID extends string | undefined> extends Form
|
|
|
436
446
|
}
|
|
437
447
|
/**Base for number elements elements*/
|
|
438
448
|
declare abstract class FormSelectorBase<RT, ID extends string | undefined> extends FormValueWrite<RT, ID> {
|
|
449
|
+
#private;
|
|
439
450
|
/**Sets the selection options for the selector */
|
|
440
451
|
abstract set selections(selections: FormSelections<RT> | undefined);
|
|
441
452
|
static apply_options<RT, ID extends string | undefined>(element: FormSelectorBase<RT, ID>, options: FormSelectorBaseOptions<RT, ID>): void;
|