@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.
Files changed (56) hide show
  1. package/README.md +16 -0
  2. package/base/index.d.mts +2 -2
  3. package/base/index.mjs +69 -77
  4. package/base/index.mjs.map +1 -1
  5. package/canvas/index.d.mts +3 -1
  6. package/canvas/index.mjs +51 -53
  7. package/canvas/index.mjs.map +1 -1
  8. package/context-menu/index.d.mts +1 -1
  9. package/context-menu/index.mjs +1 -1
  10. package/{context-menu-CiNcuP-a.mjs → context-menu-_9dMpC-H.mjs} +71 -37
  11. package/context-menu-_9dMpC-H.mjs.map +1 -0
  12. package/document/index.mjs +3 -1
  13. package/document/index.mjs.map +1 -1
  14. package/form/index.d.mts +16 -5
  15. package/form/index.mjs +410 -151
  16. package/form/index.mjs.map +1 -1
  17. package/icons/index.d.mts +1 -1
  18. package/icons/index.mjs +1 -1
  19. package/icons-e2J_Ojic.mjs +4124 -0
  20. package/{index-BcidwqIy.d.mts → index-BDWg5GX2.d.mts} +7 -18
  21. package/{index-BND79jZp.d.mts → index-CvzH3M_5.d.mts} +16 -9
  22. package/{index-CugtUzv_.d.mts → index-CzpbJoAj.d.mts} +19 -10
  23. package/{index-CB3-qP6l.d.mts → index-DhRb2iA8.d.mts} +7 -5
  24. package/keyboard/index.d.mts +1 -1
  25. package/keyboard/index.mjs +121 -50
  26. package/keyboard/index.mjs.map +1 -1
  27. package/list/index.d.mts +1 -1
  28. package/list/index.mjs +1 -1
  29. package/{list-CQDnxsLV.mjs → list-Bkm9Ailw.mjs} +97 -106
  30. package/list-Bkm9Ailw.mjs.map +1 -0
  31. package/package.json +7 -2
  32. package/selection/index.mjs +9 -11
  33. package/selection/index.mjs.map +1 -1
  34. package/settings/index.d.mts +23 -5
  35. package/settings/index.mjs +17 -10
  36. package/settings/index.mjs.map +1 -1
  37. package/spinner/index.d.mts +1 -1
  38. package/spinner/index.mjs +2 -2
  39. package/state/index.d.mts +36 -0
  40. package/state/index.mjs +2 -0
  41. package/state-OCzEmq3j.mjs +87 -0
  42. package/state-OCzEmq3j.mjs.map +1 -0
  43. package/style.css +14 -7
  44. package/svg/index.d.mts +1 -1
  45. package/svg/index.mjs +1 -1
  46. package/{svg-golJPaR4.mjs → svg-1bp-yIPC.mjs} +20 -17
  47. package/svg-1bp-yIPC.mjs.map +1 -0
  48. package/theme/index.d.mts +21 -2
  49. package/theme/index.mjs +1 -1
  50. package/{theme-9ib89_3b.mjs → theme-DlD5P5tY.mjs} +125 -44
  51. package/theme-DlD5P5tY.mjs.map +1 -0
  52. package/context-menu-CiNcuP-a.mjs.map +0 -1
  53. package/icons-CY4BLQ2F.mjs +0 -4123
  54. package/list-CQDnxsLV.mjs.map +0 -1
  55. package/svg-golJPaR4.mjs.map +0 -1
  56. package/theme-9ib89_3b.mjs.map +0 -1
package/README.md CHANGED
@@ -19,6 +19,22 @@ import ctm from "@chocbite/ts-lib-ui/context-menu";
19
19
  import { svg } from "@chocbite/ts-lib-ui/svg";
20
20
  ```
21
21
 
22
+ ### Creating elements
23
+
24
+ Elements are created in code, with their factory functions (e.g. `form_button()`) or `new`. HTML is not supported: `document.createElement`, elements written in HTML, `innerHTML` and `cloneNode` do not work. Elements build their children in their constructor, which the browser only allows for `new`, and many constructors need arguments.
25
+
26
+ ### Names of stored settings
27
+
28
+ Settings like the theme are stored in the local storage under the name of their package, e.g. `@chocbite/ts-lib-theme/theme`. `settings_set_name_transform` renames them for every package. The settings are read when their module is imported, so it must be called in a module that is imported before any other module of this library:
29
+
30
+ ```ts
31
+ //setup.ts, the first import of main.ts
32
+ import { settings_set_name_transform } from "@chocbite/ts-lib-ui/settings";
33
+ settings_set_name_transform((name) => name.replace("@chocbite/ts-lib", "myapp"));
34
+ ```
35
+
36
+ Called later, it reports the settings that already use their name with `console.error`. Renaming starts from empty settings, values stored under the old names are not moved.
37
+
22
38
  ## CSS
23
39
 
24
40
  All styles are in one `style.css`, which every module imports itself. A bundler that handles CSS imports (e.g. Vite) picks it up automatically, nothing needs to be imported by hand.
package/base/index.d.mts CHANGED
@@ -1,3 +1,3 @@
1
1
  import '../style.css';
2
- import { a as validate_element_name, c as base_loop, d as BaseIntersectObserver, f as BaseIntersectObserverOptions, i as set_base_element_global_namespace, l as base_loop_state, m as AccessTypes, n as base_element_name, o as BaseSVG, p as ACCESSTYPESINFO, r as define_element, s as Loop, t as ELEMENT_LIST, u as Base } from "../index-BND79jZp.mjs";
3
- export { ACCESSTYPESINFO, AccessTypes, Base, BaseIntersectObserver, BaseIntersectObserverOptions, BaseSVG, ELEMENT_LIST, Loop, base_element_name, base_loop, base_loop_state, define_element, set_base_element_global_namespace, validate_element_name };
2
+ import { a as validate_element_name, c as base_loop, d as BaseIntersectObserverOptions, f as ACCESSTYPESINFO, i as set_base_element_global_namespace, l as Base, n as base_element_name, o as BaseSVG, p as AccessTypes, r as define_element, s as Loop, t as ELEMENT_LIST, u as BaseIntersectObserver } from "../index-CvzH3M_5.mjs";
3
+ export { ACCESSTYPESINFO, AccessTypes, Base, BaseIntersectObserver, BaseIntersectObserverOptions, BaseSVG, ELEMENT_LIST, Loop, base_element_name, base_loop, define_element, set_base_element_global_namespace, validate_element_name };
package/base/index.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import "../style.css";
2
- import state, { state as state$1 } from "@chocbite/ts-lib/state";
2
+ import { t as state_ui } from "../state-OCzEmq3j.mjs";
3
+ import { state as state$1 } from "@chocbite/ts-lib/state";
3
4
  import { some } from "@chocbite/ts-lib/result";
4
5
  // src/base/access.ts
5
6
  /**Enum of possible access types for base element*/
@@ -24,50 +25,59 @@ const ACCESSTYPESINFO = state$1.e.list({
24
25
  }
25
26
  });
26
27
  // src/base/intersect_observer.ts
27
- const V2 = "delay" in new IntersectionObserver(() => {});
28
28
  var BaseIntersectObserver = class extends IntersectionObserver {
29
29
  #deffered_visible_time;
30
30
  #deffered_visible_timeout = null;
31
- #deffered_visible_queue = [];
31
+ #deffered_visible_queue = /* @__PURE__ */ new Set();
32
32
  #deffered_hidden_time;
33
33
  #deffered_hidden_timeout = null;
34
- #deffered_hidden_queue = [];
34
+ /**Elements with the time they hide, in order of that time as the deferral is the same for all*/
35
+ #deffered_hidden_queue = /* @__PURE__ */ new Map();
35
36
  constructor(options) {
36
37
  super((e) => {
37
38
  if (this.#deffered_hidden_time === 0 && this.#deffered_visible_time === 0) {
38
39
  for (let i = 0; i < e.length; i++) e[i].target.internal_set_visible(e[i].isIntersecting);
39
40
  return;
40
41
  }
41
- for (let i = 0; i < e.length; i++) if (e[i].isIntersecting) {
42
- this.#deffered_visible_queue.push(e[i].target);
43
- const index = this.#deffered_hidden_queue.indexOf(e[i].target);
44
- if (index !== -1) this.#deffered_hidden_queue.splice(index, 1);
45
- } else {
46
- this.#deffered_hidden_queue.push(e[i].target);
47
- const index = this.#deffered_visible_queue.indexOf(e[i].target);
48
- if (index !== -1) this.#deffered_visible_queue.splice(index, 1);
42
+ const now = performance.now();
43
+ for (let i = 0; i < e.length; i++) {
44
+ const target = e[i].target;
45
+ if (e[i].isIntersecting) {
46
+ this.#deffered_visible_queue.add(target);
47
+ this.#deffered_hidden_queue.delete(target);
48
+ } else {
49
+ this.#deffered_hidden_queue.delete(target);
50
+ this.#deffered_hidden_queue.set(target, now + this.#deffered_hidden_time);
51
+ this.#deffered_visible_queue.delete(target);
52
+ }
49
53
  }
50
- if (!this.#deffered_visible_timeout) this.#deffered_visible_timeout = window.setTimeout(() => {
51
- for (let i = 0; i < this.#deffered_visible_queue.length; i++) this.#deffered_visible_queue[i].internal_set_visible(true);
52
- this.#deffered_visible_queue = [];
54
+ if (!this.#deffered_visible_timeout && this.#deffered_visible_queue.size) this.#deffered_visible_timeout = window.setTimeout(() => {
55
+ for (const element of this.#deffered_visible_queue) element.internal_set_visible(true);
56
+ this.#deffered_visible_queue.clear();
53
57
  this.#deffered_visible_timeout = null;
54
58
  }, this.#deffered_visible_time);
55
- if (!this.#deffered_hidden_timeout) this.#deffered_hidden_timeout = window.setTimeout(() => {
56
- for (let i = 0; i < this.#deffered_hidden_queue.length; i++) this.#deffered_hidden_queue[i].internal_set_visible(false);
57
- this.#deffered_hidden_queue = [];
58
- this.#deffered_hidden_timeout = null;
59
- }, this.#deffered_hidden_time);
60
- }, V2 && options.deffered_visible === options.deffered_hidden ? {
61
- delay: options.deffered_visible,
62
- ...options
63
- } : options);
64
- if (V2 && options.deffered_visible === options.deffered_hidden) {
65
- this.#deffered_visible_time = 0;
66
- this.#deffered_hidden_time = 0;
67
- } else {
68
- this.#deffered_visible_time = options.deffered_visible ?? 250;
69
- this.#deffered_hidden_time = options.deffered_hidden ?? 250;
70
- }
59
+ if (!this.#deffered_hidden_timeout && this.#deffered_hidden_queue.size) this.#hide_after(this.#deffered_hidden_time);
60
+ }, options);
61
+ this.#deffered_visible_time = options.deffered_visible ?? 250;
62
+ this.#deffered_hidden_time = options.deffered_hidden ?? 250;
63
+ }
64
+ /**Hides the elements whose time has come, then waits for the next*/
65
+ #hide_after(time) {
66
+ this.#deffered_hidden_timeout = window.setTimeout(() => {
67
+ this.#deffered_hidden_timeout = null;
68
+ const now = performance.now();
69
+ for (const [element, at] of this.#deffered_hidden_queue) {
70
+ if (at > now) return this.#hide_after(at - now);
71
+ this.#deffered_hidden_queue.delete(element);
72
+ element.internal_set_visible(false);
73
+ }
74
+ }, time);
75
+ }
76
+ /**Also drops the element from pending deferred updates, so it does not change visibility after it is unobserved*/
77
+ unobserve(target) {
78
+ super.unobserve(target);
79
+ this.#deffered_visible_queue.delete(target);
80
+ this.#deffered_hidden_queue.delete(target);
71
81
  }
72
82
  };
73
83
  // src/base/base.ts
@@ -77,6 +87,9 @@ const base_resize_observer = new ResizeObserver((e) => {
77
87
  /**Shared class for elements to extend
78
88
  * All none abstract elements must use the define_element function to declare itself
79
89
  *
90
+ * Elements are only created in code, with new or a factory function, HTML is not supported,
91
+ * constructors add children and attributes, which document.createElement and the HTML parser do not allow
92
+ *
80
93
  * All none abstracts classes must override the static method element_name to return the name of the element
81
94
  * Abstract classes should return @abstract@
82
95
  *
@@ -109,25 +122,23 @@ var Base = class extends HTMLElement {
109
122
  /**Runs when element is attached to document*/
110
123
  connectedCallback() {
111
124
  for (const [f, [s, v]] of this.#states) if (!v) s.sub(f, true);
125
+ this.is_connected = true;
112
126
  if (this.#attached_int_observer) this.#attached_int_observer.observe(this);
113
127
  else this.internal_set_visible(true);
114
- this.is_connected = true;
115
128
  }
116
129
  /**Runs when element is dettached from document*/
117
130
  disconnectedCallback() {
118
- for (const [f, [s, v]] of this.#states) if (!v) s.unsub(f);
119
- if (this.#attached_int_observer) {
120
- this.#attached_int_observer.unobserve(this);
121
- this.internal_set_visible(false);
122
- }
123
131
  this.is_connected = false;
132
+ for (const [f, [s, v]] of this.#states) if (!v) s.unsub(f);
133
+ if (this.#attached_int_observer) this.#attached_int_observer.unobserve(this);
134
+ this.internal_set_visible(false);
124
135
  }
125
136
  /**Sets any attribute on the base element, to either a fixed value or a state value */
126
137
  opts(opts) {
127
138
  for (const key in opts) {
128
139
  const opt = opts[key];
129
140
  if (state$1.is.roa(opt)) this.attach_state_ROA_to_prop(key, opt);
130
- else this[key] = opt;
141
+ else this.detach_state_from_prop(key)[key] = opt;
131
142
  }
132
143
  return this;
133
144
  }
@@ -161,8 +172,10 @@ var Base = class extends HTMLElement {
161
172
  }
162
173
  this.#attached_int_observer = observer;
163
174
  } else if (this.#attached_int_observer) {
164
- if (this.is_connected) this.#attached_int_observer.unobserve(this);
165
- if (!this.is_visible) this.internal_set_visible(true);
175
+ if (this.is_connected) {
176
+ this.#attached_int_observer.unobserve(this);
177
+ this.internal_set_visible(true);
178
+ }
166
179
  this.#attached_int_observer = void 0;
167
180
  }
168
181
  return this;
@@ -367,7 +380,10 @@ var Base = class extends HTMLElement {
367
380
  /**Detaches the state from the property */
368
381
  detach_state_from_attribute(qualified_name) {
369
382
  const pro = this.#attr.get(qualified_name);
370
- if (pro) this.detach_state(pro);
383
+ if (pro) {
384
+ this.detach_state(pro);
385
+ this.#attr.delete(qualified_name);
386
+ }
371
387
  return this;
372
388
  }
373
389
  };
@@ -430,15 +446,18 @@ const define_element = (element) => {
430
446
  if (name !== "@abstract@") define_name = "-" + name + define_name;
431
447
  }
432
448
  define_name = base_element_global_namespace + namespace + define_name;
449
+ if (customElements.get(define_name)) throw new Error("Failed to define element \"" + define_name + "\" the name has already been defined, by another element or by this library being loaded twice");
450
+ const defined_as = "getName" in customElements ? customElements.getName(element) : null;
451
+ if (defined_as) throw new Error("Failed to define element \"" + define_name + "\" the class is already defined as \"" + defined_as + "\"");
433
452
  try {
434
453
  customElements.define(define_name, element);
435
454
  ELEMENT_LIST.add(define_name);
436
- } catch (e) {
437
- if (e instanceof Error && e.message.includes("has already been used with this registry")) throw e;
438
- else throw new Error("Failed to define element \"" + define_name + "\" " + validate_element_name(define_name));
455
+ } catch {
456
+ throw new Error("Failed to define element \"" + define_name + "\" " + validate_element_name(define_name));
439
457
  }
440
458
  };
441
459
  // src/base/base_loop.ts
460
+ /**Element with one child node per value of an array, follows the changes of array states*/
442
461
  var Loop = class extends Base {
443
462
  static element_name() {
444
463
  return "loop";
@@ -456,37 +475,11 @@ var Loop = class extends Base {
456
475
  this.#change = options?.change;
457
476
  }
458
477
  set array(array) {
459
- const read = state.a.read(array);
460
- for (let i = 0; i < read.length; i++) {
461
- const element = read[i];
462
- if (element.type === "fresh") this.replaceChildren(...array.map(this.#generator));
463
- else if (element.type === "added") {
464
- const child_nodes = this.childNodes;
465
- if (element.index === child_nodes.length) this.append(...array.slice(element.index).map(this.#generator));
466
- else for (let i = element.items.length; i > 0; i--) this.insertBefore(this.#generator(element.items[i - 1]), child_nodes[element.index]);
467
- } else if (element.type === "removed") for (let i = 0; i < element.items.length; i++) {
468
- this.#destructor?.(this.childNodes[element.index]);
469
- this.childNodes[element.index].remove();
470
- }
471
- else if (element.type === "changed") for (let i = 0; i < element.items.length; i++) if (this.#change) this.#change(this.childNodes[i + element.index], element.items[i]);
472
- else {
473
- this.#destructor?.(this.childNodes[i + element.index]);
474
- this.childNodes[i + element.index].replaceWith(this.#generator(element.items[i]));
475
- }
476
- else if (element.type === "moved") {
477
- const extracted_nodes = [];
478
- for (let i = 0; i < element.items.length; i++) {
479
- const node = this.childNodes[element.from_index + i];
480
- extracted_nodes.push(node);
481
- node.remove();
482
- }
483
- for (let i = 0; i < element.items.length; i++) {
484
- const node = extracted_nodes[i];
485
- if (element.to_index + i === this.childNodes.length) this.append(node);
486
- else this.insertBefore(node, this.childNodes[element.to_index + i]);
487
- }
488
- }
489
- }
478
+ state_ui.a.apply(this, array, {
479
+ create: this.#generator,
480
+ update: this.#change,
481
+ destroy: this.#destructor
482
+ });
490
483
  }
491
484
  set error(err) {
492
485
  this.replaceChildren(err);
@@ -496,7 +489,6 @@ define_element(Loop);
496
489
  function base_loop(generator, options) {
497
490
  return new Loop(generator, options);
498
491
  }
499
- function base_loop_state() {}
500
492
  // src/base/base_svg.ts
501
493
  /**Shared svg class for elements to extend
502
494
  * See Base for more information on how to define elements, and the element lifecycle */
@@ -516,6 +508,6 @@ var BaseSVG = class extends Base {
516
508
  this.canvas.appendChild(this);
517
509
  }
518
510
  };
519
- export { ACCESSTYPESINFO, AccessTypes, Base, BaseIntersectObserver, BaseSVG, ELEMENT_LIST, Loop, base_element_name, base_loop, base_loop_state, define_element, set_base_element_global_namespace, validate_element_name };
511
+ export { ACCESSTYPESINFO, AccessTypes, Base, BaseIntersectObserver, BaseSVG, ELEMENT_LIST, Loop, base_element_name, base_loop, define_element, set_base_element_global_namespace, validate_element_name };
520
512
 
521
513
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["state","state"],"sources":["../../src/base/access.ts","../../src/base/intersect_observer.ts","../../src/base/base.ts","../../src/base/define_element.ts","../../src/base/base_loop.ts","../../src/base/base_svg.ts"],"sourcesContent":["import { state } from \"@chocbite/ts-lib/state\";\n\n/**Enum of possible access types for base element*/\nexport const AccessTypes = {\n Write: \"w\",\n Read: \"r\",\n None: \"n\",\n} as const;\nexport type AccessTypes = (typeof AccessTypes)[keyof typeof AccessTypes];\n\n/**List for access type*/\nexport const ACCESSTYPESINFO = state.e.list<AccessTypes>({\n [AccessTypes.Write]: {\n name: \"Write\",\n description: \"Write access to element\",\n },\n [AccessTypes.Read]: { name: \"Read\", description: \"Read access to element\" },\n [AccessTypes.None]: { name: \"None\", description: \"No access to element\" },\n});\n","import type { Base } from \"./base\";\n\nexport type BaseIntersectObserverOptions = {\n /**Deffers updating visible state for so many milliseconds\n * this will also batch updates if they are constantly coming*/\n deffered_visible?: number;\n /**Deffers updating visible state for so many milliseconds\n * this will also batch updates if they are constantly coming*/\n deffered_hidden?: number;\n} & IntersectionObserverInit;\n\nconst V2 = \"delay\" in new IntersectionObserver(() => {});\nexport class BaseIntersectObserver extends IntersectionObserver {\n #deffered_visible_time: number;\n #deffered_visible_timeout: number | null = null;\n #deffered_visible_queue: Base[] = [];\n #deffered_hidden_time: number;\n #deffered_hidden_timeout: number | null = null;\n #deffered_hidden_queue: Base[] = [];\n\n constructor(options: BaseIntersectObserverOptions) {\n super(\n (e) => {\n if (\n this.#deffered_hidden_time === 0 &&\n this.#deffered_visible_time === 0\n ) {\n for (let i = 0; i < e.length; i++) {\n //@ts-expect-error Call of private method, is private to prevent external usage\n (<Base>e[i].target).internal_set_visible(e[i].isIntersecting);\n }\n return;\n }\n for (let i = 0; i < e.length; i++) {\n if (e[i].isIntersecting) {\n this.#deffered_visible_queue.push(e[i].target as Base);\n const index = this.#deffered_hidden_queue.indexOf(\n e[i].target as Base,\n );\n if (index !== -1) this.#deffered_hidden_queue.splice(index, 1);\n } else {\n this.#deffered_hidden_queue.push(e[i].target as Base);\n const index = this.#deffered_visible_queue.indexOf(\n e[i].target as Base,\n );\n if (index !== -1) this.#deffered_visible_queue.splice(index, 1);\n }\n }\n if (!this.#deffered_visible_timeout) {\n this.#deffered_visible_timeout = window.setTimeout(() => {\n for (let i = 0; i < this.#deffered_visible_queue.length; i++) {\n //@ts-expect-error Call of private method, is private to prevent external usage\n this.#deffered_visible_queue[i].internal_set_visible(true);\n }\n this.#deffered_visible_queue = [];\n this.#deffered_visible_timeout = null;\n }, this.#deffered_visible_time);\n }\n if (!this.#deffered_hidden_timeout) {\n this.#deffered_hidden_timeout = window.setTimeout(() => {\n for (let i = 0; i < this.#deffered_hidden_queue.length; i++) {\n //@ts-expect-error Call of private method, is private to prevent external usage\n this.#deffered_hidden_queue[i].internal_set_visible(false);\n }\n this.#deffered_hidden_queue = [];\n this.#deffered_hidden_timeout = null;\n }, this.#deffered_hidden_time);\n }\n },\n V2 && options.deffered_visible === options.deffered_hidden\n ? ({ delay: options.deffered_visible, ...options } as object)\n : options,\n );\n if (V2 && options.deffered_visible === options.deffered_hidden) {\n this.#deffered_visible_time = 0;\n this.#deffered_hidden_time = 0;\n } else {\n this.#deffered_visible_time = options.deffered_visible ?? 250;\n this.#deffered_hidden_time = options.deffered_hidden ?? 250;\n }\n }\n}\n","import { some, type Option } from \"@chocbite/ts-lib/result\";\nimport {\n state,\n type State,\n type StateInferSub,\n type StateREA,\n type StateROA,\n type StateSub,\n} from \"@chocbite/ts-lib/state\";\nimport { AccessTypes } from \"./access\";\nimport {\n BaseIntersectObserver,\n type BaseIntersectObserverOptions,\n} from \"./intersect_observer\";\n\n// Helpers for opts\ntype DataProps<T> = {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n [K in keyof T as T[K] extends Function ? never : K]: T[K];\n};\ntype WithStateROA<T> = {\n [K in keyof T]?: T[K] | StateROA<T[K]>;\n};\n\nconst base_resize_observer = new ResizeObserver((e) => {\n for (let i = 0; i < e.length; i++) {\n //@ts-expect-error Call of private method, is private to prevent external usage\n (<Base>e[i].target).internal_set_size_pos(e[i].contentRect);\n }\n});\n\n/**Shared class for elements to extend\n * All none abstract elements must use the define_element function to declare itself\n *\n * All none abstracts classes must override the static method element_name to return the name of the element\n * Abstract classes should return @abstract@\n *\n * If another library defines an abstract base class, it is recommended to change the static element_name_space method to the name of the library\n * example for this library '@chocolatelibui/core' becomes 'chocolatelibui-core'\n * static element_name_space() { return 'chocolatelibui-core' }\n * This resets the nametree to the library name and prevents too long element names\n *\n * Elements have an access propery, which builds on the html inert property\n * Access has the following three states\n * write = normal interaction and look\n * read = inert attribute is added making the element uninteractable, and add opacity 0.5 to make the element look inaccessible\n * none = adds display:none to element to make it */\nexport abstract class Base extends HTMLElement {\n /**Returns the name used to define the element, Abstract classes should return @abstract@ */\n static element_name() {\n return \"@abstract@\";\n }\n /**Returns the namespace override for the element*/\n static element_name_space() {\n return \"lib\";\n }\n\n #states: Map<StateSub<any>, [State<any>, boolean]> = new Map();\n\n readonly is_connected: boolean = false;\n\n /**Works when element is connected to observer, otherwise it is an alias for isConnected*/\n readonly is_visible: boolean = false;\n\n #access?: AccessTypes;\n\n #props: Map<any, StateSub<any>> = new Map();\n #attr: Map<string, StateSub<any>> = new Map();\n\n /**Runs when element is attached to document*/\n protected connectedCallback() {\n for (const [f, [s, v]] of this.#states) if (!v) s.sub(f, true);\n if (this.#attached_int_observer) this.#attached_int_observer.observe(this);\n else this.internal_set_visible(true);\n //@ts-expect-error Change readonly, in same class, why is there no way to do this without ts-ignore?\n this.is_connected = true;\n }\n\n /**Runs when element is dettached from document*/\n protected disconnectedCallback() {\n for (const [f, [s, v]] of this.#states) if (!v) s.unsub(f);\n if (this.#attached_int_observer) {\n this.#attached_int_observer.unobserve(this);\n this.internal_set_visible(false);\n }\n //@ts-expect-error Change readonly, in same class\n this.is_connected = false;\n }\n\n /**Sets any attribute on the base element, to either a fixed value or a state value */\n opts(opts: WithStateROA<DataProps<this>>): this {\n for (const key in opts) {\n const opt = opts[key] as this[typeof key] | StateROA<this[typeof key]>;\n if (state.is.roa(opt)) this.attach_state_ROA_to_prop(key, opt);\n else this[key] = opt;\n }\n return this;\n }\n\n /**Elements that can attach to a writable state can declare them in binds*/\n bind(_opts: never): this {\n return this;\n }\n\n /**Executes a function with the element as an argument and returns the element\n * Useful when declaring multiple elements in a single statement, without easy access to a scope to execute code in*/\n scope(fn: (elem: this) => void): this {\n fn(this);\n return this;\n }\n\n // ____ ____ _____ ______ _______ ________ _____\n // / __ \\| _ \\ / ____| ____| __ \\ \\ / / ____| __ \\\n // | | | | |_) | (___ | |__ | |__) \\ \\ / /| |__ | |__) |\n // | | | | _ < \\___ \\| __| | _ / \\ \\/ / | __| | _ /\n // | |__| | |_) |____) | |____| | \\ \\ \\ / | |____| | \\ \\\n // \\____/|____/|_____/|______|_| \\_\\ \\/ |______|_| \\_\\\n /**Observer for children of this element */\n #intersect_observer?: BaseIntersectObserver;\n #attached_int_observer?: BaseIntersectObserver;\n\n /**Returns an observer for the element */\n intersect_observer(\n options: BaseIntersectObserverOptions = {\n root: this,\n threshold: 0,\n deffered_hidden: 1000,\n },\n ): BaseIntersectObserver {\n return (this.#intersect_observer ??= new BaseIntersectObserver(options));\n }\n\n /**Attaches the component to an observer, which is needed for the isVisible state and event to work and for the state system to work on visible*/\n attach_to_intersect_observer(observer?: BaseIntersectObserver): this {\n if (observer) {\n if (this.is_connected) {\n if (this.#attached_int_observer)\n this.#attached_int_observer.unobserve(this);\n observer.observe(this);\n }\n this.#attached_int_observer = observer;\n } else if (this.#attached_int_observer) {\n if (this.is_connected) this.#attached_int_observer.unobserve(this);\n if (!this.is_visible) this.internal_set_visible(true);\n this.#attached_int_observer = undefined;\n }\n return this;\n }\n\n private internal_set_visible(is: boolean) {\n if (this.is_visible !== is) {\n //@ts-expect-error Change readonly, in same class\n this.is_visible = is;\n if (is) {\n for (const [f, [s, v]] of this.#states) if (v) s.sub(f, true);\n if (this.#resize_observe) base_resize_observer.observe(this);\n } else {\n for (const [f, [s, v]] of this.#states) if (v) s.unsub(f);\n if (this.#resize_observe) base_resize_observer.unobserve(this);\n }\n this.on_visible(is);\n }\n }\n /**Overrideable function called when the element becomes visible or hidden\n * If intersection observer is not attached it is based on connectedCallback, which is less accurate*/\n protected on_visible(_is: boolean) {}\n\n #resize_observe = false;\n #actual_size?: { width: number; height: number };\n /**Returns actual size and position of the element\n * if a resize observer is attached to the element, it will return the result of that, otherwise it will return the result of getBoundingClientRect()*/\n get actual_size(): { width: number; height: number } {\n return this.#actual_size ?? this.getBoundingClientRect();\n }\n\n /**Attaches the component to the global resize observer */\n attach_to_resize_observer(): this {\n if (this.is_visible) base_resize_observer.observe(this);\n this.#resize_observe = true;\n return this;\n }\n\n /**Dettaches the component from the global resize observer */\n detach_from_resize_observer(): this {\n if (this.is_visible) base_resize_observer.unobserve(this);\n this.#resize_observe = false;\n this.#actual_size = undefined;\n return this;\n }\n\n private internal_set_size_pos(rect: DOMRectReadOnly) {\n this.#actual_size = rect;\n this.on_resize(rect);\n }\n\n /**Overrideable function called when the element is resized\n * Only triggers when a resize observer is attached to the element, otherwise it will not trigger*/\n protected on_resize(_rect: { width: number; height: number }) {}\n\n // _____ _____ ______ _____ _____\n // /\\ / ____/ ____| ____|/ ____/ ____|\n // / \\ | | | | | |__ | (___| (___\n // / /\\ \\| | | | | __| \\___ \\\\___ \\\n // / ____ \\ |___| |____| |____ ____) |___) |\n // /_/ \\_\\_____\\_____|______|_____/_____/\n /**Sets the access of the element, passing undefined is the same as passing write access*/\n set access(access: AccessTypes) {\n if (this.#access === access) return;\n this.#access = access;\n switch (access) {\n case AccessTypes.Write:\n this.inert = false;\n break;\n case AccessTypes.Read:\n this.inert = true;\n break;\n case AccessTypes.None:\n this.setAttribute(\"inert\", \"none\");\n break;\n }\n this.on_access(access);\n }\n\n /**Overrideable function called when access is changed */\n protected on_access(_access: AccessTypes) {}\n\n /**Returns the current access of the element */\n get access(): AccessTypes {\n return this.#access ?? AccessTypes.Write;\n }\n // _____ _______ _______ ______\n // / ____|__ __|/\\|__ __| ____|\n // | (___ | | / \\ | | | |__\n // \\___ \\ | | / /\\ \\ | | | __|\n // ____) | | |/ ____ \\| | | |____\n // |_____/ |_/_/ \\_\\_| |______|\n /**Attaches a state to a function, so that the function is subscribed to the state when the component is connected\n * @param visible when set true the function is only subscribed when the element is visible, this requires an observer to be attached to the element*/\n attach_state<S extends State<any>>(\n state: S,\n func: StateInferSub<S>,\n visible?: boolean,\n ): typeof func {\n if (this.#states.has(func))\n console.error(\"Function already registered with element\", func, this);\n else {\n this.#states.set(func, [state, Boolean(visible)]);\n if (visible ? this.is_visible : this.is_connected)\n state.sub(func as StateSub<any>, true);\n }\n return func;\n }\n\n /**Detaches the function from the state/component */\n detach_state(func: StateSub<any>): typeof func {\n const state = this.#states.get(func);\n if (state) {\n if (state[1] ? this.is_visible : this.is_connected) state[0].unsub(func);\n this.#states.delete(func);\n } else console.error(\"Function not registered with element\", func, this);\n return func;\n }\n\n /**Attaches a state to a function, so that the function is subscribed to the state when the component is connected\n * @param visible when set true the function is only subscribed when the element is visible, this requires an observer to be attached to the element*/\n attach_state_to_symbol<S extends State<any>>(\n symbol: symbol,\n state: S,\n func: StateInferSub<S>,\n visible?: boolean,\n ): this {\n this.detach_state_from_symbol(symbol).#props.set(\n symbol,\n this.attach_state(state, func, visible),\n );\n return this;\n }\n\n /**Detaches the function from the state/component */\n detach_state_from_symbol(symbol: symbol): this {\n const pro = this.#props.get(symbol);\n if (pro) {\n this.detach_state(pro);\n this.#props.delete(symbol);\n }\n return this;\n }\n\n // _____ _______ _______ ______ _____ _____ ____ _____\n // / ____|__ __|/\\|__ __| ____| | __ \\| __ \\ / __ \\| __ \\\n // | (___ | | / \\ | | | |__ | |__) | |__) | | | | |__) |\n // \\___ \\ | | / /\\ \\ | | | __| | ___/| _ /| | | | ___/\n // ____) | | |/ ____ \\| | | |____ | | | | \\ \\| |__| | |\n // |_____/ |_/_/ \\_\\_| |______| |_| |_| \\_\\\\____/|_|\n /**Attaches a state to a property, so that the property is updated when the state changes\n * @param prop the property to attach the state to\n * @param state the state to attach to the property\n * @param visible when set true the property is only updated when the element is visible, this requires an observer to be attached to the element*/\n attach_state_ROA_to_prop<K extends keyof this>(\n prop: K,\n state: StateROA<this[K], any, any>,\n visible?: boolean,\n ): this {\n this.detach_state_from_prop(prop).#props.set(\n prop,\n this.attach_state(state, (val) => (this[prop] = val.value), visible),\n );\n return this;\n }\n\n /**Attaches a state to a property, so that the property is updated when the state changes\n * @param prop the property to attach the state to\n * @param state the state to attach to the property\n * @param visible when set true the property is only updated when the element is visible, this requires an observer to be attached to the element\n * @param fallback the fallback value for the property when the state is not ok, if undefined the property is not updated when the state is not ok*/\n attach_state_ROA_to_prop_map<K extends keyof this, T = this[K]>(\n prop: K,\n state: StateROA<T, any, any>,\n map: (val: T) => Option<this[K]>,\n visible?: boolean,\n ): this {\n this.detach_state_from_prop(prop).#props.set(\n prop,\n this.attach_state(\n state,\n (val) => {\n const o = map(val.value);\n if (o.some) this[prop] = o.value;\n },\n visible,\n ),\n );\n return this;\n }\n\n /**Attaches a state to a property, so that the property is updated when the state changes\n * @param prop the property to attach the state to\n * @param state the state to attach to the property\n * @param map_err function called when state gives a ResultErr,\n * @param visible when set true the property is only updated when the element is visible, this requires an observer to be attached to the element*/\n attach_state_to_prop<K extends keyof this>(\n prop: K,\n state: StateREA<this[K], any, any>,\n map_err: (error: string) => Option<this[K]>,\n visible?: boolean,\n ): this {\n this.detach_state_from_prop(prop).#props.set(\n prop,\n this.attach_state(\n state,\n (v) => {\n const o = v.ok ? some(v.value) : map_err(v.error);\n if (o.some) this[prop] = o.value;\n },\n visible,\n ),\n );\n return this;\n }\n /**Attaches a state to a property, so that the property is updated when the state changes\n * @param prop the property to attach the state to\n * @param state the state to attach to the property\n * @param map_err function called when state gives a ResultErr,\n * @param map function called when state gives a ResultOk,\n * @param visible when set true the property is only updated when the element is visible, this requires an observer to be attached to the element*/\n attach_state_to_prop_map<K extends keyof this, T = this[K]>(\n prop: K,\n state: StateREA<T, any, any>,\n map_err: (error: string) => Option<this[K]>,\n map: (val: T) => Option<this[K]>,\n visible?: boolean,\n ): this {\n this.detach_state_from_prop(prop).#props.set(\n prop,\n this.attach_state(\n state,\n (v) => {\n const o = v.ok ? map(v.value) : map_err(v.error);\n if (o.some) this[prop] = o.value;\n },\n visible,\n ),\n );\n return this;\n }\n\n /**Detaches the state from the property */\n detach_state_from_prop<T extends keyof this>(prop: T): this {\n const pro = this.#props.get(prop);\n if (pro) {\n this.detach_state(pro);\n this.#props.delete(prop);\n }\n return this;\n }\n\n // _____ _______ _______ ______ _______ _______ _____ _____ ____ _ _ _______ ______\n // / ____|__ __|/\\|__ __| ____| /\\|__ __|__ __| __ \\|_ _| _ \\| | | |__ __| ____|\n // | (___ | | / \\ | | | |__ / \\ | | | | | |__) | | | | |_) | | | | | | | |__\n // \\___ \\ | | / /\\ \\ | | | __| / /\\ \\ | | | | | _ / | | | _ <| | | | | | | __|\n // ____) | | |/ ____ \\| | | |____ / ____ \\| | | | | | \\ \\ _| |_| |_) | |__| | | | | |____\n // |_____/ |_/_/ \\_\\_| |______| /_/ \\_\\_| |_| |_| \\_\\_____|____/ \\____/ |_| |______|\n /**Attaches a state to an element attribute, so that the attribute is updated when the state changes\n * @param qualified_name the qualified name of the attribute to attach the state to\n * @param state the state to attach to the attribute\n * @param visible when set true the attribute is only updated when the element is visible, this requires an observer to be attached to the element*/\n attach_state_ROA_to_attribute(\n qualified_name: string,\n state: StateROA<string, any, any>,\n visible?: boolean,\n ): this {\n this.detach_state_from_attribute(qualified_name).#attr.set(\n qualified_name,\n this.attach_state(\n state,\n (val) => this.setAttribute(qualified_name, val.value),\n visible,\n ),\n );\n return this;\n }\n\n /**Attaches a state to an element attribute, so that the attribute is updated when the state changes\n * @param qualified_name the qualified name of the attribute to attach the state to\n * @param state the state to attach to the attribute\n * @param visible when set true the attribute is only updated when the element is visible, this requires an observer to be attached to the element\n * @param fallback the fallback value for the attribute when the state is not ok, if undefined the attribute is not updated when the state is not ok*/\n attach_state_ROA_to_attribute_map<U>(\n qualified_name: string,\n state: StateROA<U, any, any>,\n map: (val: U) => Option<string>,\n visible?: boolean,\n ): this {\n this.detach_state_from_attribute(qualified_name).#attr.set(\n qualified_name,\n this.attach_state(\n state,\n (val) => {\n const o = map(val.value);\n if (o.some) this.setAttribute(qualified_name, o.value);\n },\n visible,\n ),\n );\n return this;\n }\n\n /**Attaches a state to an element attribute, so that the attribute is updated when the state changes\n * @param qualified_name the qualified name of the attribute to attach the state to\n * @param state the state to attach to the attribute\n * @param map_err function called when state gives a ResultErr,\n * @param visible when set true the attribute is only updated when the element is visible, this requires an observer to be attached to the element*/\n attach_state_to_attribute(\n qualified_name: string,\n state: StateREA<string, any, any>,\n map_err: (error: string) => Option<string>,\n visible?: boolean,\n ): this {\n this.detach_state_from_attribute(qualified_name).#attr.set(\n qualified_name,\n this.attach_state(\n state,\n (v) => {\n const o = v.ok ? some(v.value) : map_err(v.error);\n if (o.some) this.setAttribute(qualified_name, o.value);\n },\n visible,\n ),\n );\n return this;\n }\n\n /**Attaches a state to an element attribute, so that the attribute is updated when the state changes\n * @param qualified_name the qualified name of the attribute to attach the state to\n * @param state the state to attach to the attribute\n * @param map_err function called when state gives a ResultErr,\n * @param map function called when state gives a ResultOk,\n * @param visible when set true the attribute is only updated when the element is visible, this requires an observer to be attached to the element*/\n attach_state_to_attribute_map<U>(\n qualified_name: string,\n state: StateREA<U, any, any>,\n map_err: (error: string) => Option<string>,\n map: (val: U) => Option<string>,\n visible?: boolean,\n ): this {\n this.detach_state_from_attribute(qualified_name).#attr.set(\n qualified_name,\n this.attach_state(\n state,\n (v) => {\n const o = v.ok ? map(v.value) : map_err(v.error);\n if (o.some) this.setAttribute(qualified_name, o.value);\n },\n visible,\n ),\n );\n return this;\n }\n\n /**Detaches the state from the property */\n detach_state_from_attribute(qualified_name: string): this {\n const pro = this.#attr.get(qualified_name);\n if (pro) this.detach_state(pro);\n return this;\n }\n}\n","const RESERVED_NAMES = new Set([\n \"annotation-xml\",\n \"color-profile\",\n \"font-face\",\n \"font-face-src\",\n \"font-face-uri\",\n \"font-face-format\",\n \"font-face-name\",\n \"missing-glyph\",\n]);\n\nconst regex =\n /^[a-z](?:[\\.0-9_a-z\\xB7\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u037D\\u037F-\\u1FFF\\u200C\\u200D\\u203F\\u2040\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD]|[\\uD800-\\uDB7F][\\uDC00-\\uDFFF])*-(?:[\\x2D\\.0-9_a-z\\xB7\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u037D\\u037F-\\u1FFF\\u200C\\u200D\\u203F\\u2040\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD]|[\\uD800-\\uDB7F][\\uDC00-\\uDFFF])*$/;\n\n/**Gives more information about whats wrong with the given element name */\nexport const validate_element_name = (name: string) => {\n if (!name) return \"Missing element name.\";\n if (/[A-Z]/.test(name))\n return \"Custom element names must not contain uppercase ASCII characters.\";\n if (!name.includes(\"-\"))\n return \"Custom element names must contain a hyphen. Example: unicorn-cake\";\n if (/^\\d/i.test(name))\n return \"Custom element names must not start with a digit.\";\n if (/^-/i.test(name))\n return \"Custom element names must not start with a hyphen.\";\n // https://html.spec.whatwg.org/multipage/scripting.html#prod-potentialcustomelementname\n if (!regex.test(name)) return \"Invalid element name.\";\n if (RESERVED_NAMES.has(name))\n return \"The supplied element name is reserved and can't be used.\\nSee: https://html.spec.whatwg.org/multipage/scripting.html#valid-custom-element-name\";\n return \"Unknown fault\";\n};\n\nlet base_element_global_namespace = \"\";\n\nexport const set_base_element_global_namespace = (namespace: string) => {\n base_element_global_namespace = namespace + (namespace.length ? \"-\" : \"\");\n};\n\ninterface ElementConstructor {\n element_name: () => string;\n element_name_space: () => string;\n}\n\n/**Generates the base name for a custom element */\nexport const base_element_name = (element: ElementConstructor): string => {\n const namespace = element.element_name_space();\n const check = element.element_name;\n let define_name = \"\";\n let runner = element;\n // @ts-expect-error Very dynamic stuff\n while (runner !== HTMLElement) {\n if (namespace !== runner.element_name_space()) break;\n const name = runner.element_name();\n runner = Object.getPrototypeOf(runner) as ElementConstructor;\n if (check === runner.element_name)\n throw new Error(\n \"Element uses same name as ancestor, abstract classes should return '@abstract@'\",\n );\n if (!name.length) throw new Error(\"Element doesn't define element name\");\n if (name !== \"@abstract@\") define_name = \"-\" + name + define_name;\n }\n return base_element_global_namespace + namespace + define_name;\n};\n\nexport const ELEMENT_LIST: Set<string> = new Set();\n\n/**Defines elements inheriting from the base*/\nexport const define_element = (element: ElementConstructor) => {\n const namespace = element.element_name_space();\n const check = element.element_name;\n let define_name = \"\";\n let runner = element;\n // @ts-expect-error Very dynamic stuff\n while (runner !== HTMLElement) {\n if (namespace !== runner.element_name_space()) break;\n\n const name = runner.element_name();\n runner = Object.getPrototypeOf(runner) as ElementConstructor;\n if (check === runner.element_name)\n throw new Error(\n 'Failed to define element \"' +\n namespace +\n \"-\" +\n name +\n define_name +\n '\" ' +\n \"Element uses same name as ancestor, abstract classes should return '@abstract@'\",\n );\n if (!name.length) throw new Error(\"Element doesn't define element name\");\n if (name !== \"@abstract@\") define_name = \"-\" + name + define_name;\n }\n define_name = base_element_global_namespace + namespace + define_name;\n try {\n // @ts-expect-error Dynamic custom element definition\n customElements.define(define_name, element);\n ELEMENT_LIST.add(define_name);\n } catch (e) {\n if (\n e instanceof Error &&\n e.message.includes(\"has already been used with this registry\")\n ) {\n throw e;\n } else {\n throw new Error(\n 'Failed to define element \"' +\n define_name +\n '\" ' +\n validate_element_name(define_name),\n );\n }\n }\n};\n","import state from \"@chocbite/ts-lib/state\";\nimport { Base } from \"./base\";\nimport { define_element } from \"./define_element\";\n\ninterface LoopOptions<T, N extends Node> {\n change?: (element: N, new_value: T) => void;\n destructor?: (element: N) => void;\n}\n\nexport class Loop<T, N extends Node> extends Base {\n static element_name(): string {\n return \"loop\";\n }\n static element_name_space(): string {\n return \"base\";\n }\n\n #generator: (val: T) => N;\n #destructor?: (element: N) => void;\n #change?: (element: N, new_value: T) => void;\n\n constructor(generator: (val: T) => N, options?: LoopOptions<T, N>) {\n super();\n this.#generator = generator;\n this.#destructor = options?.destructor;\n this.#change = options?.change;\n }\n\n set array(array: readonly T[]) {\n const read = state.a.read(array);\n for (let i = 0; i < read.length; i++) {\n const element = read[i];\n if (element.type === \"fresh\")\n this.replaceChildren(...array.map(this.#generator));\n else if (element.type === \"added\") {\n const child_nodes = this.childNodes;\n if (element.index === child_nodes.length)\n this.append(...array.slice(element.index).map(this.#generator));\n else {\n for (let i = element.items.length; i > 0; i--) {\n this.insertBefore(\n this.#generator(element.items[i - 1]),\n child_nodes[element.index],\n );\n }\n }\n } else if (element.type === \"removed\")\n for (let i = 0; i < element.items.length; i++) {\n this.#destructor?.(this.childNodes[element.index] as unknown as N);\n this.childNodes[element.index].remove();\n }\n else if (element.type === \"changed\")\n for (let i = 0; i < element.items.length; i++)\n if (this.#change)\n this.#change(\n this.childNodes[i + element.index] as unknown as N,\n element.items[i],\n );\n else {\n this.#destructor?.(\n this.childNodes[i + element.index] as unknown as N,\n );\n this.childNodes[i + element.index].replaceWith(\n this.#generator(element.items[i]),\n );\n }\n else if (element.type === \"moved\") {\n const extracted_nodes: Node[] = [];\n for (let i = 0; i < element.items.length; i++) {\n const node = this.childNodes[element.from_index + i];\n extracted_nodes.push(node);\n node.remove();\n }\n for (let i = 0; i < element.items.length; i++) {\n const node = extracted_nodes[i];\n if (element.to_index + i === this.childNodes.length)\n this.append(node);\n else this.insertBefore(node, this.childNodes[element.to_index + i]);\n }\n }\n }\n }\n\n set error(err: Node) {\n this.replaceChildren(err);\n }\n}\ndefine_element(Loop);\n\nexport function base_loop<T, N extends Node>(\n generator: (val: T) => N,\n options?: LoopOptions<T, N>,\n) {\n return new Loop<T, N>(generator, options);\n}\n\nexport function base_loop_state() {}\n","import { Base } from \"./base\";\nimport { base_element_name } from \"./define_element\";\n\n/**Shared svg class for elements to extend\n * See Base for more information on how to define elements, and the element lifecycle */\nexport abstract class BaseSVG extends Base {\n /**Returns the name used to define the element, Abstract classes should return @abstract@ */\n static element_name() {\n return \"@abstract@\";\n }\n /**Returns the namespace override for the element*/\n static element_name_space() {\n return \"lib\";\n }\n\n protected abstract default_canvas(): SVGSVGElement;\n\n readonly canvas: SVGSVGElement = this.default_canvas();\n\n constructor() {\n super();\n this.canvas.classList.add(\n base_element_name(this.constructor as typeof BaseSVG),\n );\n this.canvas.appendChild(this);\n }\n}\n"],"mappings":";;;;;AAGA,MAAa,cAAc;CACzB,OAAO;CACP,MAAM;CACN,MAAM;AACR;;AAIA,MAAa,kBAAkBA,QAAM,EAAE,KAAkB;EACtD,YAAY,QAAQ;EACnB,MAAM;EACN,aAAa;CACf;EACC,YAAY,OAAO;EAAE,MAAM;EAAQ,aAAa;CAAyB;EACzE,YAAY,OAAO;EAAE,MAAM;EAAQ,aAAa;CAAuB;AAC1E,CAAC;;ACPD,MAAM,KAAK,WAAW,IAAI,2BAA2B,CAAC,CAAC;AACvD,IAAa,wBAAb,cAA2C,qBAAqB;CAC9D;CACA,4BAA2C;CAC3C,0BAAkC,CAAC;CACnC;CACA,2BAA0C;CAC1C,yBAAiC,CAAC;CAElC,YAAY,SAAuC;EACjD,OACG,MAAM;GACL,IACE,KAAK,0BAA0B,KAC/B,KAAK,2BAA2B,GAChC;IACA,KAAK,IAAI,IAAI,GAAG,IAAI,EAAE,QAAQ,KAE5B,EAAS,EAAE,CAAC,OAAQ,qBAAqB,EAAE,EAAE,CAAC,cAAc;IAE9D;GACF;GACA,KAAK,IAAI,IAAI,GAAG,IAAI,EAAE,QAAQ,KAC5B,IAAI,EAAE,EAAE,CAAC,gBAAgB;IACvB,KAAK,wBAAwB,KAAK,EAAE,EAAE,CAAC,MAAc;IACrD,MAAM,QAAQ,KAAK,uBAAuB,QACxC,EAAE,EAAE,CAAC,MACP;IACA,IAAI,UAAU,IAAI,KAAK,uBAAuB,OAAO,OAAO,CAAC;GAC/D,OAAO;IACL,KAAK,uBAAuB,KAAK,EAAE,EAAE,CAAC,MAAc;IACpD,MAAM,QAAQ,KAAK,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QAAQ,aAAa;KAClD,gBAAgB,KAAK,IAAI;KACzB,KAAK,OAAO;IACd;IACA,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,MAAM,QAAQ,KAAK;KAC7C,MAAM,OAAO,gBAAgB;KAC7B,IAAI,QAAQ,WAAW,MAAM,KAAK,WAAW,QAC3C,KAAK,OAAO,IAAI;UACb,KAAK,aAAa,MAAM,KAAK,WAAW,QAAQ,WAAW,EAAE;IACpE;GACF;EACF;CACF;CAEA,IAAI,MAAM,KAAW;EACnB,KAAK,gBAAgB,GAAG;CAC1B;AACF;AACA,eAAe,IAAI;AAEnB,SAAgB,UACd,WACA,SACA;CACA,OAAO,IAAI,KAAW,WAAW,OAAO;AAC1C;AAEA,SAAgB,kBAAkB,CAAC;;;;AC3FnC,IAAsB,UAAtB,cAAsC,KAAK;;CAEzC,OAAO,eAAe;EACpB,OAAO;CACT;;CAEA,OAAO,qBAAqB;EAC1B,OAAO;CACT;CAIA,SAAiC,KAAK,eAAe;CAErD,cAAc;EACZ,MAAM;EACN,KAAK,OAAO,UAAU,IACpB,kBAAkB,KAAK,WAA6B,CACtD;EACA,KAAK,OAAO,YAAY,IAAI;CAC9B;AACF"}
1
+ {"version":3,"file":"index.mjs","names":["state","state"],"sources":["../../src/base/access.ts","../../src/base/intersect_observer.ts","../../src/base/base.ts","../../src/base/define_element.ts","../../src/base/base_loop.ts","../../src/base/base_svg.ts"],"sourcesContent":["import { state } from \"@chocbite/ts-lib/state\";\n\n/**Enum of possible access types for base element*/\nexport const AccessTypes = {\n Write: \"w\",\n Read: \"r\",\n None: \"n\",\n} as const;\nexport type AccessTypes = (typeof AccessTypes)[keyof typeof AccessTypes];\n\n/**List for access type*/\nexport const ACCESSTYPESINFO = state.e.list<AccessTypes>({\n [AccessTypes.Write]: {\n name: \"Write\",\n description: \"Write access to element\",\n },\n [AccessTypes.Read]: { name: \"Read\", description: \"Read access to element\" },\n [AccessTypes.None]: { name: \"None\", description: \"No access to element\" },\n});\n","import type { Base } from \"./base\";\n\nexport type BaseIntersectObserverOptions = {\n /**Deffers updating visible state for so many milliseconds, defaults to 250\n * this will also batch updates if they are constantly coming*/\n deffered_visible?: number;\n /**Deffers updating visible state for so many milliseconds, defaults to 250\n * this will also batch updates if they are constantly coming*/\n deffered_hidden?: number;\n} & IntersectionObserverInit;\n\nexport class BaseIntersectObserver extends IntersectionObserver {\n #deffered_visible_time: number;\n #deffered_visible_timeout: number | null = null;\n #deffered_visible_queue: Set<Base> = new Set();\n #deffered_hidden_time: number;\n #deffered_hidden_timeout: number | null = null;\n /**Elements with the time they hide, in order of that time as the deferral is the same for all*/\n #deffered_hidden_queue: Map<Base, number> = new Map();\n\n constructor(options: BaseIntersectObserverOptions) {\n super(\n (e) => {\n if (\n this.#deffered_hidden_time === 0 &&\n this.#deffered_visible_time === 0\n ) {\n for (let i = 0; i < e.length; i++) {\n //@ts-expect-error Call of private method, is private to prevent external usage\n (<Base>e[i].target).internal_set_visible(e[i].isIntersecting);\n }\n return;\n }\n const now = performance.now();\n for (let i = 0; i < e.length; i++) {\n const target = e[i].target as Base;\n if (e[i].isIntersecting) {\n this.#deffered_visible_queue.add(target);\n this.#deffered_hidden_queue.delete(target);\n } else {\n this.#deffered_hidden_queue.delete(target);\n this.#deffered_hidden_queue.set(\n target,\n now + this.#deffered_hidden_time,\n );\n this.#deffered_visible_queue.delete(target);\n }\n }\n if (!this.#deffered_visible_timeout && this.#deffered_visible_queue.size)\n this.#deffered_visible_timeout = window.setTimeout(() => {\n for (const element of this.#deffered_visible_queue)\n //@ts-expect-error Call of private method, is private to prevent external usage\n element.internal_set_visible(true);\n this.#deffered_visible_queue.clear();\n this.#deffered_visible_timeout = null;\n }, this.#deffered_visible_time);\n if (!this.#deffered_hidden_timeout && this.#deffered_hidden_queue.size)\n this.#hide_after(this.#deffered_hidden_time);\n },\n options,\n );\n this.#deffered_visible_time = options.deffered_visible ?? 250;\n this.#deffered_hidden_time = options.deffered_hidden ?? 250;\n }\n\n /**Hides the elements whose time has come, then waits for the next*/\n #hide_after(time: number): void {\n this.#deffered_hidden_timeout = window.setTimeout(() => {\n this.#deffered_hidden_timeout = null;\n const now = performance.now();\n for (const [element, at] of this.#deffered_hidden_queue) {\n if (at > now) return this.#hide_after(at - now);\n this.#deffered_hidden_queue.delete(element);\n //@ts-expect-error Call of private method, is private to prevent external usage\n element.internal_set_visible(false);\n }\n }, time);\n }\n\n /**Also drops the element from pending deferred updates, so it does not change visibility after it is unobserved*/\n unobserve(target: Element): void {\n super.unobserve(target);\n this.#deffered_visible_queue.delete(target as Base);\n this.#deffered_hidden_queue.delete(target as Base);\n }\n}\n","import { some, type Option } from \"@chocbite/ts-lib/result\";\nimport {\n state,\n type State,\n type StateInferSub,\n type StateREA,\n type StateROA,\n type StateSub,\n} from \"@chocbite/ts-lib/state\";\nimport { AccessTypes } from \"./access\";\nimport {\n BaseIntersectObserver,\n type BaseIntersectObserverOptions,\n} from \"./intersect_observer\";\n\n// Helpers for opts\ntype DataProps<T> = {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n [K in keyof T as T[K] extends Function ? never : K]: T[K];\n};\ntype WithStateROA<T> = {\n [K in keyof T]?: T[K] | StateROA<T[K]>;\n};\n\nconst base_resize_observer = new ResizeObserver((e) => {\n for (let i = 0; i < e.length; i++) {\n //@ts-expect-error Call of private method, is private to prevent external usage\n (<Base>e[i].target).internal_set_size_pos(e[i].contentRect);\n }\n});\n\n/**Shared class for elements to extend\n * All none abstract elements must use the define_element function to declare itself\n *\n * Elements are only created in code, with new or a factory function, HTML is not supported,\n * constructors add children and attributes, which document.createElement and the HTML parser do not allow\n *\n * All none abstracts classes must override the static method element_name to return the name of the element\n * Abstract classes should return @abstract@\n *\n * If another library defines an abstract base class, it is recommended to change the static element_name_space method to the name of the library\n * example for this library '@chocolatelibui/core' becomes 'chocolatelibui-core'\n * static element_name_space() { return 'chocolatelibui-core' }\n * This resets the nametree to the library name and prevents too long element names\n *\n * Elements have an access propery, which builds on the html inert property\n * Access has the following three states\n * write = normal interaction and look\n * read = inert attribute is added making the element uninteractable, and add opacity 0.5 to make the element look inaccessible\n * none = adds display:none to element to make it */\nexport abstract class Base extends HTMLElement {\n /**Returns the name used to define the element, Abstract classes should return @abstract@ */\n static element_name() {\n return \"@abstract@\";\n }\n /**Returns the namespace override for the element*/\n static element_name_space() {\n return \"lib\";\n }\n\n #states: Map<StateSub<any>, [State<any>, boolean]> = new Map();\n\n readonly is_connected: boolean = false;\n\n /**Works when element is connected to observer, otherwise it is an alias for isConnected*/\n readonly is_visible: boolean = false;\n\n #access?: AccessTypes;\n\n #props: Map<any, StateSub<any>> = new Map();\n #attr: Map<string, StateSub<any>> = new Map();\n\n /**Runs when element is attached to document*/\n protected connectedCallback() {\n for (const [f, [s, v]] of this.#states) if (!v) s.sub(f, true);\n //Set after subscribing, so states attached by the subscribers are not subscribed twice,\n //but before visibility, so states attached from on_visible are subscribed\n //@ts-expect-error Change readonly, in same class, why is there no way to do this without ts-ignore?\n this.is_connected = true;\n if (this.#attached_int_observer) this.#attached_int_observer.observe(this);\n else this.internal_set_visible(true);\n }\n\n /**Runs when element is dettached from document*/\n protected disconnectedCallback() {\n //@ts-expect-error Change readonly, in same class\n this.is_connected = false;\n for (const [f, [s, v]] of this.#states) if (!v) s.unsub(f);\n if (this.#attached_int_observer) this.#attached_int_observer.unobserve(this);\n this.internal_set_visible(false);\n }\n\n /**Sets any attribute on the base element, to either a fixed value or a state value */\n opts(opts: WithStateROA<DataProps<this>>): this {\n for (const key in opts) {\n const opt = opts[key] as this[typeof key] | StateROA<this[typeof key]>;\n if (state.is.roa(opt)) this.attach_state_ROA_to_prop(key, opt);\n else this.detach_state_from_prop(key)[key] = opt;\n }\n return this;\n }\n\n /**Elements that can attach to a writable state can declare them in binds*/\n bind(_opts: never): this {\n return this;\n }\n\n /**Executes a function with the element as an argument and returns the element\n * Useful when declaring multiple elements in a single statement, without easy access to a scope to execute code in*/\n scope(fn: (elem: this) => void): this {\n fn(this);\n return this;\n }\n\n // ____ ____ _____ ______ _______ ________ _____\n // / __ \\| _ \\ / ____| ____| __ \\ \\ / / ____| __ \\\n // | | | | |_) | (___ | |__ | |__) \\ \\ / /| |__ | |__) |\n // | | | | _ < \\___ \\| __| | _ / \\ \\/ / | __| | _ /\n // | |__| | |_) |____) | |____| | \\ \\ \\ / | |____| | \\ \\\n // \\____/|____/|_____/|______|_| \\_\\ \\/ |______|_| \\_\\\n /**Observer for children of this element */\n #intersect_observer?: BaseIntersectObserver;\n #attached_int_observer?: BaseIntersectObserver;\n\n /**Returns an observer for the element */\n intersect_observer(\n options: BaseIntersectObserverOptions = {\n root: this,\n threshold: 0,\n deffered_hidden: 1000,\n },\n ): BaseIntersectObserver {\n return (this.#intersect_observer ??= new BaseIntersectObserver(options));\n }\n\n /**Attaches the component to an observer, which is needed for the isVisible state and event to work and for the state system to work on visible*/\n attach_to_intersect_observer(observer?: BaseIntersectObserver): this {\n if (observer) {\n if (this.is_connected) {\n if (this.#attached_int_observer)\n this.#attached_int_observer.unobserve(this);\n observer.observe(this);\n }\n this.#attached_int_observer = observer;\n } else if (this.#attached_int_observer) {\n //Without an observer a connected element counts as visible\n if (this.is_connected) {\n this.#attached_int_observer.unobserve(this);\n this.internal_set_visible(true);\n }\n this.#attached_int_observer = undefined;\n }\n return this;\n }\n\n private internal_set_visible(is: boolean) {\n if (this.is_visible !== is) {\n //@ts-expect-error Change readonly, in same class\n this.is_visible = is;\n if (is) {\n for (const [f, [s, v]] of this.#states) if (v) s.sub(f, true);\n if (this.#resize_observe) base_resize_observer.observe(this);\n } else {\n for (const [f, [s, v]] of this.#states) if (v) s.unsub(f);\n if (this.#resize_observe) base_resize_observer.unobserve(this);\n }\n this.on_visible(is);\n }\n }\n /**Overrideable function called when the element becomes visible or hidden\n * If intersection observer is not attached it is based on connectedCallback, which is less accurate*/\n protected on_visible(_is: boolean) {}\n\n #resize_observe = false;\n #actual_size?: { width: number; height: number };\n /**Returns actual size and position of the element\n * if a resize observer is attached to the element, it will return the result of that, otherwise it will return the result of getBoundingClientRect()*/\n get actual_size(): { width: number; height: number } {\n return this.#actual_size ?? this.getBoundingClientRect();\n }\n\n /**Attaches the component to the global resize observer */\n attach_to_resize_observer(): this {\n if (this.is_visible) base_resize_observer.observe(this);\n this.#resize_observe = true;\n return this;\n }\n\n /**Dettaches the component from the global resize observer */\n detach_from_resize_observer(): this {\n if (this.is_visible) base_resize_observer.unobserve(this);\n this.#resize_observe = false;\n this.#actual_size = undefined;\n return this;\n }\n\n private internal_set_size_pos(rect: DOMRectReadOnly) {\n this.#actual_size = rect;\n this.on_resize(rect);\n }\n\n /**Overrideable function called when the element is resized\n * Only triggers when a resize observer is attached to the element, otherwise it will not trigger*/\n protected on_resize(_rect: { width: number; height: number }) {}\n\n // _____ _____ ______ _____ _____\n // /\\ / ____/ ____| ____|/ ____/ ____|\n // / \\ | | | | | |__ | (___| (___\n // / /\\ \\| | | | | __| \\___ \\\\___ \\\n // / ____ \\ |___| |____| |____ ____) |___) |\n // /_/ \\_\\_____\\_____|______|_____/_____/\n /**Sets the access of the element, passing undefined is the same as passing write access*/\n set access(access: AccessTypes) {\n if (this.#access === access) return;\n this.#access = access;\n switch (access) {\n case AccessTypes.Write:\n this.inert = false;\n break;\n case AccessTypes.Read:\n this.inert = true;\n break;\n case AccessTypes.None:\n this.setAttribute(\"inert\", \"none\");\n break;\n }\n this.on_access(access);\n }\n\n /**Overrideable function called when access is changed */\n protected on_access(_access: AccessTypes) {}\n\n /**Returns the current access of the element */\n get access(): AccessTypes {\n return this.#access ?? AccessTypes.Write;\n }\n // _____ _______ _______ ______\n // / ____|__ __|/\\|__ __| ____|\n // | (___ | | / \\ | | | |__\n // \\___ \\ | | / /\\ \\ | | | __|\n // ____) | | |/ ____ \\| | | |____\n // |_____/ |_/_/ \\_\\_| |______|\n /**Attaches a state to a function, so that the function is subscribed to the state when the component is connected\n * @param visible when set true the function is only subscribed when the element is visible, this requires an observer to be attached to the element*/\n attach_state<S extends State<any>>(\n state: S,\n func: StateInferSub<S>,\n visible?: boolean,\n ): typeof func {\n if (this.#states.has(func))\n console.error(\"Function already registered with element\", func, this);\n else {\n this.#states.set(func, [state, Boolean(visible)]);\n if (visible ? this.is_visible : this.is_connected)\n state.sub(func as StateSub<any>, true);\n }\n return func;\n }\n\n /**Detaches the function from the state/component */\n detach_state(func: StateSub<any>): typeof func {\n const state = this.#states.get(func);\n if (state) {\n if (state[1] ? this.is_visible : this.is_connected) state[0].unsub(func);\n this.#states.delete(func);\n } else console.error(\"Function not registered with element\", func, this);\n return func;\n }\n\n /**Attaches a state to a function, so that the function is subscribed to the state when the component is connected\n * @param visible when set true the function is only subscribed when the element is visible, this requires an observer to be attached to the element*/\n attach_state_to_symbol<S extends State<any>>(\n symbol: symbol,\n state: S,\n func: StateInferSub<S>,\n visible?: boolean,\n ): this {\n this.detach_state_from_symbol(symbol).#props.set(\n symbol,\n this.attach_state(state, func, visible),\n );\n return this;\n }\n\n /**Detaches the function from the state/component */\n detach_state_from_symbol(symbol: symbol): this {\n const pro = this.#props.get(symbol);\n if (pro) {\n this.detach_state(pro);\n this.#props.delete(symbol);\n }\n return this;\n }\n\n // _____ _______ _______ ______ _____ _____ ____ _____\n // / ____|__ __|/\\|__ __| ____| | __ \\| __ \\ / __ \\| __ \\\n // | (___ | | / \\ | | | |__ | |__) | |__) | | | | |__) |\n // \\___ \\ | | / /\\ \\ | | | __| | ___/| _ /| | | | ___/\n // ____) | | |/ ____ \\| | | |____ | | | | \\ \\| |__| | |\n // |_____/ |_/_/ \\_\\_| |______| |_| |_| \\_\\\\____/|_|\n /**Attaches a state to a property, so that the property is updated when the state changes\n * @param prop the property to attach the state to\n * @param state the state to attach to the property\n * @param visible when set true the property is only updated when the element is visible, this requires an observer to be attached to the element*/\n attach_state_ROA_to_prop<K extends keyof this>(\n prop: K,\n state: StateROA<this[K], any, any>,\n visible?: boolean,\n ): this {\n this.detach_state_from_prop(prop).#props.set(\n prop,\n this.attach_state(state, (val) => (this[prop] = val.value), visible),\n );\n return this;\n }\n\n /**Attaches a state to a property, so that the property is updated when the state changes\n * @param prop the property to attach the state to\n * @param state the state to attach to the property\n * @param visible when set true the property is only updated when the element is visible, this requires an observer to be attached to the element\n * @param fallback the fallback value for the property when the state is not ok, if undefined the property is not updated when the state is not ok*/\n attach_state_ROA_to_prop_map<K extends keyof this, T = this[K]>(\n prop: K,\n state: StateROA<T, any, any>,\n map: (val: T) => Option<this[K]>,\n visible?: boolean,\n ): this {\n this.detach_state_from_prop(prop).#props.set(\n prop,\n this.attach_state(\n state,\n (val) => {\n const o = map(val.value);\n if (o.some) this[prop] = o.value;\n },\n visible,\n ),\n );\n return this;\n }\n\n /**Attaches a state to a property, so that the property is updated when the state changes\n * @param prop the property to attach the state to\n * @param state the state to attach to the property\n * @param map_err function called when state gives a ResultErr,\n * @param visible when set true the property is only updated when the element is visible, this requires an observer to be attached to the element*/\n attach_state_to_prop<K extends keyof this>(\n prop: K,\n state: StateREA<this[K], any, any>,\n map_err: (error: string) => Option<this[K]>,\n visible?: boolean,\n ): this {\n this.detach_state_from_prop(prop).#props.set(\n prop,\n this.attach_state(\n state,\n (v) => {\n const o = v.ok ? some(v.value) : map_err(v.error);\n if (o.some) this[prop] = o.value;\n },\n visible,\n ),\n );\n return this;\n }\n /**Attaches a state to a property, so that the property is updated when the state changes\n * @param prop the property to attach the state to\n * @param state the state to attach to the property\n * @param map_err function called when state gives a ResultErr,\n * @param map function called when state gives a ResultOk,\n * @param visible when set true the property is only updated when the element is visible, this requires an observer to be attached to the element*/\n attach_state_to_prop_map<K extends keyof this, T = this[K]>(\n prop: K,\n state: StateREA<T, any, any>,\n map_err: (error: string) => Option<this[K]>,\n map: (val: T) => Option<this[K]>,\n visible?: boolean,\n ): this {\n this.detach_state_from_prop(prop).#props.set(\n prop,\n this.attach_state(\n state,\n (v) => {\n const o = v.ok ? map(v.value) : map_err(v.error);\n if (o.some) this[prop] = o.value;\n },\n visible,\n ),\n );\n return this;\n }\n\n /**Detaches the state from the property */\n detach_state_from_prop<T extends keyof this>(prop: T): this {\n const pro = this.#props.get(prop);\n if (pro) {\n this.detach_state(pro);\n this.#props.delete(prop);\n }\n return this;\n }\n\n // _____ _______ _______ ______ _______ _______ _____ _____ ____ _ _ _______ ______\n // / ____|__ __|/\\|__ __| ____| /\\|__ __|__ __| __ \\|_ _| _ \\| | | |__ __| ____|\n // | (___ | | / \\ | | | |__ / \\ | | | | | |__) | | | | |_) | | | | | | | |__\n // \\___ \\ | | / /\\ \\ | | | __| / /\\ \\ | | | | | _ / | | | _ <| | | | | | | __|\n // ____) | | |/ ____ \\| | | |____ / ____ \\| | | | | | \\ \\ _| |_| |_) | |__| | | | | |____\n // |_____/ |_/_/ \\_\\_| |______| /_/ \\_\\_| |_| |_| \\_\\_____|____/ \\____/ |_| |______|\n /**Attaches a state to an element attribute, so that the attribute is updated when the state changes\n * @param qualified_name the qualified name of the attribute to attach the state to\n * @param state the state to attach to the attribute\n * @param visible when set true the attribute is only updated when the element is visible, this requires an observer to be attached to the element*/\n attach_state_ROA_to_attribute(\n qualified_name: string,\n state: StateROA<string, any, any>,\n visible?: boolean,\n ): this {\n this.detach_state_from_attribute(qualified_name).#attr.set(\n qualified_name,\n this.attach_state(\n state,\n (val) => this.setAttribute(qualified_name, val.value),\n visible,\n ),\n );\n return this;\n }\n\n /**Attaches a state to an element attribute, so that the attribute is updated when the state changes\n * @param qualified_name the qualified name of the attribute to attach the state to\n * @param state the state to attach to the attribute\n * @param visible when set true the attribute is only updated when the element is visible, this requires an observer to be attached to the element\n * @param fallback the fallback value for the attribute when the state is not ok, if undefined the attribute is not updated when the state is not ok*/\n attach_state_ROA_to_attribute_map<U>(\n qualified_name: string,\n state: StateROA<U, any, any>,\n map: (val: U) => Option<string>,\n visible?: boolean,\n ): this {\n this.detach_state_from_attribute(qualified_name).#attr.set(\n qualified_name,\n this.attach_state(\n state,\n (val) => {\n const o = map(val.value);\n if (o.some) this.setAttribute(qualified_name, o.value);\n },\n visible,\n ),\n );\n return this;\n }\n\n /**Attaches a state to an element attribute, so that the attribute is updated when the state changes\n * @param qualified_name the qualified name of the attribute to attach the state to\n * @param state the state to attach to the attribute\n * @param map_err function called when state gives a ResultErr,\n * @param visible when set true the attribute is only updated when the element is visible, this requires an observer to be attached to the element*/\n attach_state_to_attribute(\n qualified_name: string,\n state: StateREA<string, any, any>,\n map_err: (error: string) => Option<string>,\n visible?: boolean,\n ): this {\n this.detach_state_from_attribute(qualified_name).#attr.set(\n qualified_name,\n this.attach_state(\n state,\n (v) => {\n const o = v.ok ? some(v.value) : map_err(v.error);\n if (o.some) this.setAttribute(qualified_name, o.value);\n },\n visible,\n ),\n );\n return this;\n }\n\n /**Attaches a state to an element attribute, so that the attribute is updated when the state changes\n * @param qualified_name the qualified name of the attribute to attach the state to\n * @param state the state to attach to the attribute\n * @param map_err function called when state gives a ResultErr,\n * @param map function called when state gives a ResultOk,\n * @param visible when set true the attribute is only updated when the element is visible, this requires an observer to be attached to the element*/\n attach_state_to_attribute_map<U>(\n qualified_name: string,\n state: StateREA<U, any, any>,\n map_err: (error: string) => Option<string>,\n map: (val: U) => Option<string>,\n visible?: boolean,\n ): this {\n this.detach_state_from_attribute(qualified_name).#attr.set(\n qualified_name,\n this.attach_state(\n state,\n (v) => {\n const o = v.ok ? map(v.value) : map_err(v.error);\n if (o.some) this.setAttribute(qualified_name, o.value);\n },\n visible,\n ),\n );\n return this;\n }\n\n /**Detaches the state from the property */\n detach_state_from_attribute(qualified_name: string): this {\n const pro = this.#attr.get(qualified_name);\n if (pro) {\n this.detach_state(pro);\n this.#attr.delete(qualified_name);\n }\n return this;\n }\n}\n","const RESERVED_NAMES = new Set([\n \"annotation-xml\",\n \"color-profile\",\n \"font-face\",\n \"font-face-src\",\n \"font-face-uri\",\n \"font-face-format\",\n \"font-face-name\",\n \"missing-glyph\",\n]);\n\nconst regex =\n /^[a-z](?:[\\.0-9_a-z\\xB7\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u037D\\u037F-\\u1FFF\\u200C\\u200D\\u203F\\u2040\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD]|[\\uD800-\\uDB7F][\\uDC00-\\uDFFF])*-(?:[\\x2D\\.0-9_a-z\\xB7\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u037D\\u037F-\\u1FFF\\u200C\\u200D\\u203F\\u2040\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD]|[\\uD800-\\uDB7F][\\uDC00-\\uDFFF])*$/;\n\n/**Gives more information about whats wrong with the given element name */\nexport const validate_element_name = (name: string) => {\n if (!name) return \"Missing element name.\";\n if (/[A-Z]/.test(name))\n return \"Custom element names must not contain uppercase ASCII characters.\";\n if (!name.includes(\"-\"))\n return \"Custom element names must contain a hyphen. Example: unicorn-cake\";\n if (/^\\d/i.test(name))\n return \"Custom element names must not start with a digit.\";\n if (/^-/i.test(name))\n return \"Custom element names must not start with a hyphen.\";\n // https://html.spec.whatwg.org/multipage/scripting.html#prod-potentialcustomelementname\n if (!regex.test(name)) return \"Invalid element name.\";\n if (RESERVED_NAMES.has(name))\n return \"The supplied element name is reserved and can't be used.\\nSee: https://html.spec.whatwg.org/multipage/scripting.html#valid-custom-element-name\";\n return \"Unknown fault\";\n};\n\nlet base_element_global_namespace = \"\";\n\nexport const set_base_element_global_namespace = (namespace: string) => {\n base_element_global_namespace = namespace + (namespace.length ? \"-\" : \"\");\n};\n\ninterface ElementConstructor {\n element_name: () => string;\n element_name_space: () => string;\n}\n\n/**Generates the base name for a custom element */\nexport const base_element_name = (element: ElementConstructor): string => {\n const namespace = element.element_name_space();\n const check = element.element_name;\n let define_name = \"\";\n let runner = element;\n // @ts-expect-error Very dynamic stuff\n while (runner !== HTMLElement) {\n if (namespace !== runner.element_name_space()) break;\n const name = runner.element_name();\n runner = Object.getPrototypeOf(runner) as ElementConstructor;\n if (check === runner.element_name)\n throw new Error(\n \"Element uses same name as ancestor, abstract classes should return '@abstract@'\",\n );\n if (!name.length) throw new Error(\"Element doesn't define element name\");\n if (name !== \"@abstract@\") define_name = \"-\" + name + define_name;\n }\n return base_element_global_namespace + namespace + define_name;\n};\n\nexport const ELEMENT_LIST: Set<string> = new Set();\n\n/**Defines elements inheriting from the base*/\nexport const define_element = (element: ElementConstructor) => {\n const namespace = element.element_name_space();\n const check = element.element_name;\n let define_name = \"\";\n let runner = element;\n // @ts-expect-error Very dynamic stuff\n while (runner !== HTMLElement) {\n if (namespace !== runner.element_name_space()) break;\n\n const name = runner.element_name();\n runner = Object.getPrototypeOf(runner) as ElementConstructor;\n if (check === runner.element_name)\n throw new Error(\n 'Failed to define element \"' +\n namespace +\n \"-\" +\n name +\n define_name +\n '\" ' +\n \"Element uses same name as ancestor, abstract classes should return '@abstract@'\",\n );\n if (!name.length) throw new Error(\"Element doesn't define element name\");\n if (name !== \"@abstract@\") define_name = \"-\" + name + define_name;\n }\n define_name = base_element_global_namespace + namespace + define_name;\n //Checked first, browsers word the error for a name or class used twice differently\n if (customElements.get(define_name))\n throw new Error(\n 'Failed to define element \"' +\n define_name +\n '\" the name has already been defined, by another element or by this library being loaded twice',\n );\n //getName is missing in older browsers\n const defined_as =\n \"getName\" in customElements\n ? customElements.getName(element as unknown as CustomElementConstructor)\n : null;\n if (defined_as)\n throw new Error(\n 'Failed to define element \"' +\n define_name +\n '\" the class is already defined as \"' +\n defined_as +\n '\"',\n );\n try {\n // @ts-expect-error Dynamic custom element definition\n customElements.define(define_name, element);\n ELEMENT_LIST.add(define_name);\n } catch {\n throw new Error(\n 'Failed to define element \"' +\n define_name +\n '\" ' +\n validate_element_name(define_name),\n );\n }\n};\n","import state_ui from \"#state\";\nimport { Base } from \"./base\";\nimport { define_element } from \"./define_element\";\n\ninterface LoopOptions<T, N extends ChildNode> {\n /**Updates a node to a new value, when given nodes are reused instead of replaced*/\n change?: (element: N, new_value: T) => void;\n /**Called for every node that is removed or replaced*/\n destructor?: (element: N) => void;\n}\n\n/**Element with one child node per value of an array, follows the changes of array states*/\nexport class Loop<T, N extends ChildNode> extends Base {\n static element_name(): string {\n return \"loop\";\n }\n static element_name_space(): string {\n return \"base\";\n }\n\n #generator: (val: T) => N;\n #destructor?: (element: N) => void;\n #change?: (element: N, new_value: T) => void;\n\n constructor(generator: (val: T) => N, options?: LoopOptions<T, N>) {\n super();\n this.#generator = generator;\n this.#destructor = options?.destructor;\n this.#change = options?.change;\n }\n\n set array(array: readonly T[]) {\n state_ui.a.apply(this, array, {\n create: this.#generator,\n update: this.#change,\n destroy: this.#destructor,\n });\n }\n\n set error(err: Node) {\n this.replaceChildren(err);\n }\n}\ndefine_element(Loop);\n\nexport function base_loop<T, N extends ChildNode>(\n generator: (val: T) => N,\n options?: LoopOptions<T, N>,\n) {\n return new Loop<T, N>(generator, options);\n}\n","import { Base } from \"./base\";\nimport { base_element_name } from \"./define_element\";\n\n/**Shared svg class for elements to extend\n * See Base for more information on how to define elements, and the element lifecycle */\nexport abstract class BaseSVG extends Base {\n /**Returns the name used to define the element, Abstract classes should return @abstract@ */\n static element_name() {\n return \"@abstract@\";\n }\n /**Returns the namespace override for the element*/\n static element_name_space() {\n return \"lib\";\n }\n\n protected abstract default_canvas(): SVGSVGElement;\n\n readonly canvas: SVGSVGElement = this.default_canvas();\n\n constructor() {\n super();\n this.canvas.classList.add(\n base_element_name(this.constructor as typeof BaseSVG),\n );\n this.canvas.appendChild(this);\n }\n}\n"],"mappings":";;;;;;AAGA,MAAa,cAAc;CACzB,OAAO;CACP,MAAM;CACN,MAAM;AACR;;AAIA,MAAa,kBAAkBA,QAAM,EAAE,KAAkB;EACtD,YAAY,QAAQ;EACnB,MAAM;EACN,aAAa;CACf;EACC,YAAY,OAAO;EAAE,MAAM;EAAQ,aAAa;CAAyB;EACzE,YAAY,OAAO;EAAE,MAAM;EAAQ,aAAa;CAAuB;AAC1E,CAAC;;ACPD,IAAa,wBAAb,cAA2C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A,SAAiC,KAAK,eAAe;CAErD,cAAc;EACZ,MAAM;EACN,KAAK,OAAO,UAAU,IACpB,kBAAkB,KAAK,WAA6B,CACtD;EACA,KAAK,OAAO,YAAY,IAAI;CAC9B;AACF"}
@@ -1,5 +1,5 @@
1
1
  import '../style.css';
2
- import { u as Base } from "../index-BND79jZp.mjs";
2
+ import { l as Base } from "../index-CvzH3M_5.mjs";
3
3
  import { State } from "@chocbite/ts-lib/state";
4
4
  import { Option } from "@chocbite/ts-lib/result";
5
5
  export declare abstract class ViewportElement {
@@ -52,6 +52,8 @@ declare class Viewport extends Base {
52
52
  #private;
53
53
  static element_name(): string;
54
54
  static element_name_space(): string;
55
+ protected connectedCallback(): void;
56
+ protected disconnectedCallback(): void;
55
57
  constructor(canvas_width: number, canvas_height: number, infinite_canvas?: boolean);
56
58
  set canvas_width(value: number);
57
59
  get canvas_width(): number;