@chocbite/ts-lib-ui 1.0.6 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/AGENTS.md +164 -3
  2. package/SOURCE.md +2000 -268
  3. package/base/index.d.mts +1 -1
  4. package/base/index.mjs +7 -7
  5. package/base/index.mjs.map +1 -1
  6. package/canvas/index.d.mts +1 -1
  7. package/canvas/index.mjs +8 -8
  8. package/canvas/index.mjs.map +1 -1
  9. package/context-menu/index.d.mts +2 -2
  10. package/context-menu/index.mjs +1 -1
  11. package/{context-menu-Bo8R6DmK.mjs → context-menu-DE3EUtY8.mjs} +149 -111
  12. package/context-menu-DE3EUtY8.mjs.map +1 -0
  13. package/document/index.mjs +1 -1
  14. package/document/index.mjs.map +1 -1
  15. package/dom/index.mjs +1 -1
  16. package/dom/index.mjs.map +1 -1
  17. package/form/index.d.mts +6 -5
  18. package/form/index.mjs +30 -29
  19. package/form/index.mjs.map +1 -1
  20. package/icons/index.d.mts +1 -1
  21. package/icons/index.mjs +1 -1
  22. package/{icons-e2J_Ojic.mjs → icons-B88i-7MC.mjs} +2 -2
  23. package/{index-ClIBfrHy.d.mts → index-BDWg5GX2.d.mts} +2 -2
  24. package/{index-ClfL2SQR.d.mts → index-CvzH3M_5.d.mts} +2 -2
  25. package/index-Cw4AcuUl.d.mts +371 -0
  26. package/{index-Pr2sLv9e.d.mts → index-YNZjMIO7.d.mts} +33 -17
  27. package/keyboard/index.d.mts +1 -1
  28. package/keyboard/index.mjs +12 -12
  29. package/keyboard/index.mjs.map +1 -1
  30. package/list/index.d.mts +2 -2
  31. package/list/index.mjs +1 -1
  32. package/list-D08epOjk.mjs +1566 -0
  33. package/list-D08epOjk.mjs.map +1 -0
  34. package/package.json +5 -80
  35. package/selection/index.mjs +1 -1
  36. package/selection/index.mjs.map +1 -1
  37. package/settings/index.mjs +1 -1
  38. package/settings/index.mjs.map +1 -1
  39. package/spinner/index.d.mts +1 -1
  40. package/spinner/index.mjs +3 -3
  41. package/spinner/index.mjs.map +1 -1
  42. package/state_ui/index.mjs +1 -1
  43. package/{state_ui-Bm3TeKNL.mjs → state_ui-Dtm2y5RU.mjs} +3 -3
  44. package/state_ui-Dtm2y5RU.mjs.map +1 -0
  45. package/style.css +307 -63
  46. package/svg/index.d.mts +1 -1
  47. package/svg/index.mjs +1 -1
  48. package/{svg-1bp-yIPC.mjs → svg-Yz7elqnU.mjs} +16 -16
  49. package/svg-Yz7elqnU.mjs.map +1 -0
  50. package/test/index.d.mts +1 -1
  51. package/test/index.mjs +1 -1
  52. package/test/index.mjs.map +1 -1
  53. package/theme/index.d.mts +1 -1
  54. package/theme/index.mjs +1 -1
  55. package/{theme-DgVtLDzP.mjs → theme-BJS5z1iW.mjs} +9 -9
  56. package/theme-BJS5z1iW.mjs.map +1 -0
  57. package/context-menu-Bo8R6DmK.mjs.map +0 -1
  58. package/index-BTUFkF9s.d.mts +0 -173
  59. package/list-DOXIQOEY.mjs +0 -715
  60. package/list-DOXIQOEY.mjs.map +0 -1
  61. package/state_ui-Bm3TeKNL.mjs.map +0 -1
  62. package/svg-1bp-yIPC.mjs.map +0 -1
  63. package/theme-DgVtLDzP.mjs.map +0 -1
@@ -1,18 +1,19 @@
1
1
  import "./style.css";
2
2
  import { Base, define_element } from "./base/index.mjs";
3
- import { i as theme_init_variable_root } from "./theme-DgVtLDzP.mjs";
4
- import { DOCUMENT_HANDLER } from "./document/index.mjs";
5
- import { Fm as material_chevron_right_rounded, xh as material_close_rounded } from "./icons-e2J_Ojic.mjs";
3
+ import { i as theme_init_variable_root } from "./theme-BJS5z1iW.mjs";
4
+ import { Fm as material_chevron_right_rounded, xh as material_close_rounded } from "./icons-B88i-7MC.mjs";
6
5
  import { Spinner } from "./spinner/index.mjs";
6
+ import { DOCUMENT_HANDLER } from "./document/index.mjs";
7
+ import result, { none, some } from "@chocbite/ts-lib/result";
7
8
  import { BLUE, GREY } from "@chocbite/ts-lib/colors";
8
- // src/context-menu/shared.ts
9
+ // context-menu/shared.ts
9
10
  const variables = theme_init_variable_root("contextmenu", "Context Menu", "Right click or touch and hold context menu appearance");
10
11
  variables.make_variable("background", "Background Color", "Color of background", GREY["50"], GREY["900"], "Color", void 0);
11
12
  variables.make_variable("text", "Text Color", "Color of text", GREY["600"], GREY["400"], "Color", void 0);
12
13
  variables.make_variable("hover", "Hover Color", "Background color of line when hovering over it", BLUE["200"], BLUE["900"], "Color", void 0);
13
14
  variables.make_variable("hoverText", "Text Color", "Standard text color", GREY["900"], GREY["50"], "Color", void 0);
14
15
  variables.make_variable("border", "Border Color", "Color of border and deviders", GREY["300"], GREY["800"], "Color", void 0);
15
- // src/context-menu/line.ts
16
+ // context-menu/line.ts
16
17
  var MenuLine = class extends Base {
17
18
  /**Returns the name used to define the element */
18
19
  static element_name() {
@@ -40,7 +41,7 @@ var MenuLine = class extends Base {
40
41
  }
41
42
  }
42
43
  };
43
- // src/context-menu/devider.ts
44
+ // context-menu/devider.ts
44
45
  var Devider = class extends MenuLine {
45
46
  /**Returns the name used to define the element */
46
47
  static element_name() {
@@ -57,7 +58,25 @@ define_element(Devider);
57
58
  function context_devider() {
58
59
  return new Devider();
59
60
  }
60
- // src/context-menu/container.ts
61
+ // context-menu/buffer.ts
62
+ var Buffer = class extends MenuLine {
63
+ /**Returns the name used to define the element */
64
+ static element_name() {
65
+ return "buffer";
66
+ }
67
+ constructor() {
68
+ super();
69
+ this.appendChild(new Spinner());
70
+ }
71
+ get skips_focus() {
72
+ return true;
73
+ }
74
+ do_focus(dir) {
75
+ this.focus_next(dir);
76
+ }
77
+ };
78
+ define_element(Buffer);
79
+ // context-menu/container.ts
61
80
  var Container = class extends Base {
62
81
  #active_element_buffer;
63
82
  #replacing = false;
@@ -111,104 +130,7 @@ var Container = class extends Base {
111
130
  }
112
131
  };
113
132
  define_element(Container);
114
- // src/context-menu/engine.ts
115
- const CONTEXT_MENY_SYMBOL = Symbol("context_menu");
116
- /**Default context menu, false blocks the operating system context menu, undefined leaves it*/
117
- let default_menu;
118
- /**Blocks the operating system context menu when the default is false*/
119
- const block_os_menu = (e) => e.preventDefault();
120
- DOCUMENT_HANDLER.events.on("added", (e) => {
121
- apply_to_doc(e.data);
122
- });
123
- DOCUMENT_HANDLER.for_documents((doc) => {
124
- apply_to_doc(doc);
125
- });
126
- function apply_to_doc(doc) {
127
- const container = new Container();
128
- doc[CONTEXT_MENY_SYMBOL] = container;
129
- doc.documentElement.appendChild(container);
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);
139
- }
140
- /**Attaches a context menu to the given element
141
- * @param element the element to attach the context menu to
142
- * @param lines the context menu to attach, if a function is given it will be called when the context menu is summoned
143
- * @param block a function that returns true if the context menu should not be summoned, if undefined the context menu will always be summoned*/
144
- function context_menu_attach(element, lines, block) {
145
- if (element[CONTEXT_MENY_SYMBOL]) context_menu_detach(element);
146
- const listener = (e) => {
147
- e.preventDefault();
148
- e.stopPropagation();
149
- if (block && block()) return;
150
- const lineses = typeof lines === "function" ? lines().unwrap_or(void 0) : lines;
151
- if (!lineses) return;
152
- context_menu_summon(lineses, element, e.clientX, e.clientY);
153
- };
154
- element.addEventListener("contextmenu", listener);
155
- element[CONTEXT_MENY_SYMBOL] = listener;
156
- }
157
- /**Dettaches the context menu from the given element */
158
- function context_menu_detach(element) {
159
- if (element[CONTEXT_MENY_SYMBOL]) {
160
- element.removeEventListener("contextmenu", element[CONTEXT_MENY_SYMBOL]);
161
- delete element[CONTEXT_MENY_SYMBOL];
162
- }
163
- }
164
- /**Summons a context menu at a given location
165
- * @param menu the context menu to summon
166
- * @param element the element the context menu is referenced to, if undefined the context menu will appear in the main document
167
- * @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
168
- * @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
169
- * @param dont_cover when set true */
170
- function context_menu_summon(menu, element, x, y, dont_cover) {
171
- const container = element ? element.ownerDocument[CONTEXT_MENY_SYMBOL] : DOCUMENT_HANDLER.main[CONTEXT_MENY_SYMBOL];
172
- if (container) {
173
- if (typeof x !== "number" || typeof y !== "number") {
174
- if (element) {
175
- const box = element.getBoundingClientRect();
176
- x = box.left + box.width / 2;
177
- y = box.top + box.height / 2;
178
- } else {
179
- x = 0;
180
- y = 0;
181
- }
182
- }
183
- container.attach_menu(menu).set_position(x, y, dont_cover ? element : void 0);
184
- } else console.error("No context menu container available");
185
- }
186
- /**Sets the default context menu for the page, the one used if no other context menu has been attached to the element
187
- * If set to false the operating system context menu is disabled and nothing will appear
188
- * If set undefined the operating systems context menu will be used*/
189
- function context_menu_default(lines) {
190
- default_menu = lines;
191
- DOCUMENT_HANDLER.for_documents(apply_default_to_doc);
192
- }
193
- // src/context-menu/buffer.ts
194
- var Buffer = class extends MenuLine {
195
- /**Returns the name used to define the element */
196
- static element_name() {
197
- return "buffer";
198
- }
199
- constructor() {
200
- super();
201
- this.appendChild(new Spinner());
202
- }
203
- get skips_focus() {
204
- return true;
205
- }
206
- do_focus(dir) {
207
- this.focus_next(dir);
208
- }
209
- };
210
- define_element(Buffer);
211
- // src/context-menu/option.ts
133
+ // context-menu/option.ts
212
134
  var MenuOption = class extends MenuLine {
213
135
  func;
214
136
  /**Returns the name used to define the element */
@@ -264,7 +186,7 @@ define_element(MenuOption);
264
186
  function context_line(text, func, icon, shortcut, checkmark) {
265
187
  return new MenuOption(text, func, icon, shortcut, checkmark);
266
188
  }
267
- // src/context-menu/submenu.ts
189
+ // context-menu/submenu.ts
268
190
  var MenuSub = class extends MenuLine {
269
191
  #menu;
270
192
  #is_open;
@@ -362,7 +284,7 @@ define_element(MenuSub);
362
284
  function context_sub(text, menu, icon) {
363
285
  return new MenuSub(text, menu, icon);
364
286
  }
365
- // src/context-menu/menu.ts
287
+ // context-menu/menu.ts
366
288
  var ContextMenu = class extends Base {
367
289
  /**Returns the name used to define the element */
368
290
  static element_name() {
@@ -414,7 +336,7 @@ var ContextMenu = class extends Base {
414
336
  }
415
337
  connectedCallback() {
416
338
  super.connectedCallback();
417
- const lines = typeof this.#lines === "function" ? this.#lines() : this.#lines;
339
+ const lines = this.read_lines();
418
340
  this.#loading?.remove();
419
341
  if (lines instanceof Promise) {
420
342
  const buffer = this.#loading = this.appendChild(new Buffer());
@@ -438,6 +360,11 @@ var ContextMenu = class extends Base {
438
360
  this.#loading = void 0;
439
361
  this.ownerDocument.defaultView?.removeEventListener("resize", this.#window_resize_handler);
440
362
  }
363
+ /**Gives the lines the menu shows when it opens, a lines function is called
364
+ * The lines are elements in one menu at a time, ctm.combine moves them into its menu, this menu takes them back when it opens */
365
+ read_lines() {
366
+ return typeof this.#lines === "function" ? this.#lines() : this.#lines;
367
+ }
441
368
  /**Sets the lines of the context menu */
442
369
  set lines(lines) {
443
370
  this.replaceChildren();
@@ -542,7 +469,117 @@ define_element(ContextMenu);
542
469
  function context_menu(lines) {
543
470
  return new ContextMenu(lines);
544
471
  }
545
- // src/context-menu/index.ts
472
+ // context-menu/combine.ts
473
+ function group_lines(group) {
474
+ let value = typeof group === "function" ? group() : group;
475
+ if (result.is_option(value)) value = value.unwrap_or(void 0);
476
+ if (value instanceof ContextMenu) return value.read_lines();
477
+ return value ?? [];
478
+ }
479
+ /**Joins groups with a devider between those with lines */
480
+ function join(groups) {
481
+ const lines = [];
482
+ for (const group of groups) {
483
+ const group_lines = group.filter((line) => line !== void 0);
484
+ if (group_lines.length === 0) continue;
485
+ if (lines.length) lines.push(context_devider());
486
+ lines.push(...group_lines);
487
+ }
488
+ return lines;
489
+ }
490
+ /**Combines groups of lines and menus into one menu with a devider between groups, built every time the menu opens
491
+ * Empty groups are left out with their devider, and when all groups are empty there is no menu
492
+ * A group with promised lines makes the combined menu wait for all groups, showing a spinner, it then always opens
493
+ * Give the result to ctm.attach, or anything else taking a menu factory
494
+ * @param groups groups in menu order, see ContextMenuGroup*/
495
+ function context_combine(...groups) {
496
+ return () => {
497
+ const parts = groups.map(group_lines);
498
+ if (parts.some((part) => part instanceof Promise)) return some(context_menu(Promise.all(parts.map((part) => Promise.resolve(part))).then(join)));
499
+ const lines = join(parts);
500
+ return lines.length ? some(context_menu(lines)) : none();
501
+ };
502
+ }
503
+ // context-menu/engine.ts
504
+ const CONTEXT_MENY_SYMBOL = Symbol("context_menu");
505
+ /**Default context menu, false blocks the operating system context menu, undefined leaves it*/
506
+ let default_menu;
507
+ /**Blocks the operating system context menu when the default is false*/
508
+ const block_os_menu = (e) => e.preventDefault();
509
+ DOCUMENT_HANDLER.events.on("added", (e) => {
510
+ apply_to_doc(e.data);
511
+ });
512
+ DOCUMENT_HANDLER.for_documents((doc) => {
513
+ apply_to_doc(doc);
514
+ });
515
+ function apply_to_doc(doc) {
516
+ const container = new Container();
517
+ doc[CONTEXT_MENY_SYMBOL] = container;
518
+ doc.documentElement.appendChild(container);
519
+ apply_default_to_doc(doc);
520
+ }
521
+ /**Applies the current default context menu to a document*/
522
+ function apply_default_to_doc(doc) {
523
+ const root = doc.documentElement;
524
+ context_menu_detach(root);
525
+ root.removeEventListener("contextmenu", block_os_menu);
526
+ if (default_menu) context_menu_attach(root, default_menu);
527
+ else if (default_menu === false) root.addEventListener("contextmenu", block_os_menu);
528
+ }
529
+ /**Attaches a context menu to the given element
530
+ * @param element the element to attach the context menu to
531
+ * @param lines the context menu to attach, if a function is given it will be called when the context menu is summoned
532
+ * @param block a function that returns true if the context menu should not be summoned, if undefined the context menu will always be summoned*/
533
+ function context_menu_attach(element, lines, block) {
534
+ if (element[CONTEXT_MENY_SYMBOL]) context_menu_detach(element);
535
+ const listener = (e) => {
536
+ e.preventDefault();
537
+ e.stopPropagation();
538
+ if (block && block()) return;
539
+ const lineses = typeof lines === "function" ? lines().unwrap_or(void 0) : lines;
540
+ if (!lineses) return;
541
+ context_menu_summon(lineses, element, e.clientX, e.clientY);
542
+ };
543
+ element.addEventListener("contextmenu", listener);
544
+ element[CONTEXT_MENY_SYMBOL] = listener;
545
+ }
546
+ /**Dettaches the context menu from the given element */
547
+ function context_menu_detach(element) {
548
+ if (element[CONTEXT_MENY_SYMBOL]) {
549
+ element.removeEventListener("contextmenu", element[CONTEXT_MENY_SYMBOL]);
550
+ delete element[CONTEXT_MENY_SYMBOL];
551
+ }
552
+ }
553
+ /**Summons a context menu at a given location
554
+ * @param menu the context menu to summon
555
+ * @param element the element the context menu is referenced to, if undefined the context menu will appear in the main document
556
+ * @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
557
+ * @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
558
+ * @param dont_cover when set true */
559
+ function context_menu_summon(menu, element, x, y, dont_cover) {
560
+ const container = element ? element.ownerDocument[CONTEXT_MENY_SYMBOL] : DOCUMENT_HANDLER.main[CONTEXT_MENY_SYMBOL];
561
+ if (container) {
562
+ if (typeof x !== "number" || typeof y !== "number") {
563
+ if (element) {
564
+ const box = element.getBoundingClientRect();
565
+ x = box.left + box.width / 2;
566
+ y = box.top + box.height / 2;
567
+ } else {
568
+ x = 0;
569
+ y = 0;
570
+ }
571
+ }
572
+ container.attach_menu(menu).set_position(x, y, dont_cover ? element : void 0);
573
+ } else console.error("No context menu container available");
574
+ }
575
+ /**Sets the default context menu for the page, the one used if no other context menu has been attached to the element
576
+ * If set to false the operating system context menu is disabled and nothing will appear
577
+ * If set undefined the operating systems context menu will be used*/
578
+ function context_menu_default(lines) {
579
+ default_menu = lines;
580
+ DOCUMENT_HANDLER.for_documents(apply_default_to_doc);
581
+ }
582
+ // context-menu/index.ts
546
583
  const ctm = {
547
584
  attach: context_menu_attach,
548
585
  default: context_menu_default,
@@ -554,8 +591,9 @@ const ctm = {
554
591
  menu: context_menu,
555
592
  line: context_line,
556
593
  sub: context_sub,
557
- devider: context_devider
594
+ devider: context_devider,
595
+ combine: context_combine
558
596
  };
559
597
  export { ctm as t };
560
598
 
561
- //# sourceMappingURL=context-menu-Bo8R6DmK.mjs.map
599
+ //# sourceMappingURL=context-menu-DE3EUtY8.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-menu-DE3EUtY8.mjs","names":[],"sources":["../../package-ui/context-menu/shared.ts","../../package-ui/context-menu/line.ts","../../package-ui/context-menu/devider.ts","../../package-ui/context-menu/buffer.ts","../../package-ui/context-menu/container.ts","../../package-ui/context-menu/option.ts","../../package-ui/context-menu/submenu.ts","../../package-ui/context-menu/menu.ts","../../package-ui/context-menu/combine.ts","../../package-ui/context-menu/engine.ts","../../package-ui/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 { 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 { 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 { 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 = this.read_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 /**Gives the lines the menu shows when it opens, a lines function is called\n * The lines are elements in one menu at a time, ctm.combine moves them into its menu, this menu takes them back when it opens */\n read_lines():\n (ContextMenuLine | undefined)[] | Promise<(ContextMenuLine | undefined)[]> {\n return typeof this.#lines === \"function\" ? this.#lines() : this.#lines;\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 result, { none, some, type Option } from \"@chocbite/ts-lib/result\";\nimport { context_devider } from \"./devider\";\nimport type { ContextMenuLine } from \"./line\";\nimport { context_menu, ContextMenu } from \"./menu\";\n\ntype Lines = (ContextMenuLine | undefined)[];\n\n/**A group for ctm.combine, undefined for no group\n * - lines, undefined lines are skipped like in ctm.menu\n * - a menu, its lines are taken when the combined menu opens\n * - a function called every time the combined menu opens, giving lines, a menu, or an option of a menu like ctm.attach takes*/\nexport type ContextMenuGroup =\n | Lines\n | ContextMenu\n | (() => Lines | ContextMenu | Option<ContextMenu>)\n | undefined;\n\nfunction group_lines(group: ContextMenuGroup): Lines | Promise<Lines> {\n let value = typeof group === \"function\" ? group() : group;\n if (result.is_option(value)) value = value.unwrap_or(undefined);\n if (value instanceof ContextMenu) return value.read_lines();\n return value ?? [];\n}\n\n/**Joins groups with a devider between those with lines */\nfunction join(groups: Lines[]): ContextMenuLine[] {\n const lines: ContextMenuLine[] = [];\n for (const group of groups) {\n const group_lines = group.filter((line) => line !== undefined);\n if (group_lines.length === 0) continue;\n if (lines.length) lines.push(context_devider());\n lines.push(...group_lines);\n }\n return lines;\n}\n\n/**Combines groups of lines and menus into one menu with a devider between groups, built every time the menu opens\n * Empty groups are left out with their devider, and when all groups are empty there is no menu\n * A group with promised lines makes the combined menu wait for all groups, showing a spinner, it then always opens\n * Give the result to ctm.attach, or anything else taking a menu factory\n * @param groups groups in menu order, see ContextMenuGroup*/\nexport function context_combine(\n ...groups: ContextMenuGroup[]\n): () => Option<ContextMenu> {\n return () => {\n const parts = groups.map(group_lines);\n if (parts.some((part) => part instanceof Promise))\n return some(\n context_menu(\n Promise.all(parts.map((part) => Promise.resolve(part))).then(join),\n ),\n );\n const lines = join(parts as Lines[]);\n return lines.length ? some(context_menu(lines)) : none();\n };\n}\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 { context_combine } from \"./combine\";\nimport { 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 combine: context_combine,\n};\nexport default ctm;\n\nexport type { ContextMenuGroup } from \"./combine\";\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,QAC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oBAAoB,eAAe,QAAQ,oBAAoB;EACvE,OAAO,QAAQ;CACjB;AACF;;;;;;;AAQA,SAAgB,oBACd,MACA,SACA,GACA,GACA,YACA;CACA,MAAM,YAAY,UACd,QAAQ,cAAc,uBACtB,iBAAiB,KAAK;CAC1B,IAAI,WAAW;EACb,IAAI,OAAO,MAAM,YAAY,OAAO,MAAM,UAAU;GAClD,IAAI,SAAS;IACX,MAAM,MAAM,QAAQ,sBAAsB;IAC1C,IAAI,IAAI,OAAO,IAAI,QAAQ;IAC3B,IAAI,IAAI,MAAM,IAAI,SAAS;GAC7B,OAAO;IACL,IAAI;IACJ,IAAI;GACN;EACF;EACA,UACG,YAAY,IAAI,CAAC,CACjB,aAAa,GAAG,GAAG,aAAa,UAAU,KAAA,CAAS;CACxD,OAAO,QAAQ,MAAM,qCAAqC;AAC5D;;;;AAKA,SAAgB,qBACd,OACA;CACA,eAAe;CACf,iBAAiB,cAAc,oBAAoB;AACrD;;AC/GA,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;CACT,SAAS;AACX"}
@@ -1,6 +1,6 @@
1
1
  import "../style.css";
2
2
  import { EventHandler } from "@chocbite/ts-lib/event";
3
- // src/document/document.ts
3
+ // document/document.ts
4
4
  var DocumentHandler = class {
5
5
  /**Stores all managed documents */
6
6
  #documents = /* @__PURE__ */ new Set();
@@ -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 //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"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../package-ui/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/dom/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import "../style.css";
2
- // src/dom/index.ts
2
+ // dom/index.ts
3
3
  function node_clone(node) {
4
4
  return node.cloneNode(true);
5
5
  }
package/dom/index.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../src/dom/index.ts"],"sourcesContent":["export function node_clone<T extends Node>(node: T): T {\n return node.cloneNode(true) as T;\n}\n"],"mappings":";;AAAA,SAAgB,WAA2B,MAAY;CACrD,OAAO,KAAK,UAAU,IAAI;AAC5B"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../package-ui/dom/index.ts"],"sourcesContent":["export function node_clone<T extends Node>(node: T): T {\n return node.cloneNode(true) as T;\n}\n"],"mappings":";;AAAA,SAAgB,WAA2B,MAAY;CACrD,OAAO,KAAK,UAAU,IAAI;AAC5B"}
package/form/index.d.mts CHANGED
@@ -1,8 +1,8 @@
1
1
  import '../style.css';
2
- import { l as Base, p as AccessTypes } from "../index-ClfL2SQR.mjs";
3
- import { t as SVGFunc } from "../index-ClIBfrHy.mjs";
4
- import { n as ListField } from "../index-BTUFkF9s.mjs";
5
- import { State, StateEnumRelated, StateNumberRelated, StateREAW, StateStringRelated } from "@chocbite/ts-lib/state";
2
+ import { l as Base, p as AccessTypes } from "../index-CvzH3M_5.mjs";
3
+ import { t as SVGFunc } from "../index-BDWg5GX2.mjs";
4
+ import { a as ListField } from "../index-Cw4AcuUl.mjs";
5
+ import { State, StateEnumRelated, StateNumberRelated, StateREA, 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";
8
8
  interface FormOptions {}
@@ -44,8 +44,9 @@ export declare abstract class FormValue<RT, ID extends string | undefined> exten
44
44
  protected _buffer?: RT;
45
45
  get buffer(): RT | undefined;
46
46
  protected _state?: State<RT, Option<{}>, RT>;
47
+ /**Binds the element to a state, a read only state is shown and changes to the element are refused with a warning*/
47
48
  bind(opts: {
48
- value: StateREAW<RT, Option<{}>, RT>;
49
+ value: StateREA<RT, Option<{}>, RT>;
49
50
  }): this;
50
51
  /**This sets the value of the component*/
51
52
  set value(val: RT);