@chocbite/ts-lib-ui 1.1.5 → 1.2.1

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 (52) hide show
  1. package/AGENTS.md +547 -9
  2. package/README.md +3 -0
  3. package/SOURCE.md +10313 -7355
  4. package/base/index.d.mts +2 -2
  5. package/base/index.mjs +68 -5
  6. package/base/index.mjs.map +1 -1
  7. package/canvas/index.d.mts +1 -1
  8. package/canvas/index.mjs +1 -1
  9. package/composition/index.d.mts +283 -0
  10. package/composition/index.mjs +2 -0
  11. package/composition-7xlf0UjB.mjs +869 -0
  12. package/composition-7xlf0UjB.mjs.map +1 -0
  13. package/context-menu/index.d.mts +1 -1
  14. package/context-menu/index.mjs +1 -1
  15. package/{context-menu-CZxEGjBi.mjs → context-menu-DSVerkvr.mjs} +2 -2
  16. package/{context-menu-CZxEGjBi.mjs.map → context-menu-DSVerkvr.mjs.map} +1 -1
  17. package/depot_ui/index.d.mts +60 -0
  18. package/depot_ui/index.mjs +280 -0
  19. package/depot_ui/index.mjs.map +1 -0
  20. package/form/index.d.mts +2 -758
  21. package/form/index.mjs +1 -2953
  22. package/form-CnIHz2Bp.mjs +2961 -0
  23. package/form-CnIHz2Bp.mjs.map +1 -0
  24. package/icons/index.d.mts +1 -1
  25. package/{index-YNZjMIO7.d.mts → index-CApVOEcI.d.mts} +2 -2
  26. package/{index-BDWg5GX2.d.mts → index-Czy8O3me.d.mts} +6 -2
  27. package/index-DD09-bGe.d.mts +761 -0
  28. package/{index-DlBJdGaQ.d.mts → index-U3pqQjLg.d.mts} +4 -4
  29. package/{index-CvzH3M_5.d.mts → index-_y7vmunA.d.mts} +72 -8
  30. package/keyboard/index.d.mts +1 -1
  31. package/keyboard/index.mjs +1 -1
  32. package/list/index.d.mts +1 -1
  33. package/list/index.mjs +1 -1
  34. package/{list-C52-ExFw.mjs → list-ByNP3ZG2.mjs} +3 -3
  35. package/{list-C52-ExFw.mjs.map → list-ByNP3ZG2.mjs.map} +1 -1
  36. package/package.json +2 -2
  37. package/prompts/index.d.mts +48 -0
  38. package/prompts/index.mjs +107 -0
  39. package/prompts/index.mjs.map +1 -0
  40. package/spinner/index.d.mts +1 -1
  41. package/spinner/index.mjs +1 -1
  42. package/style.css +2049 -1640
  43. package/svg/index.d.mts +1 -1
  44. package/svg-Yz7elqnU.mjs.map +1 -1
  45. package/theme/index.d.mts +1 -1
  46. package/theme/index.mjs +1 -1
  47. package/{theme-D3YluyYr.mjs → theme-ycsugrdT.mjs} +2 -2
  48. package/{theme-D3YluyYr.mjs.map → theme-ycsugrdT.mjs.map} +1 -1
  49. package/form/index.mjs.map +0 -1
  50. package/test/index.d.mts +0 -98
  51. package/test/index.mjs +0 -193
  52. package/test/index.mjs.map +0 -1
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 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 };
2
+ import { _ as InputState, a as validate_element_name, b as ACCESSTYPESINFO, c as base_loop, d as BaseIntersectObserverOptions, f as CREATE, g as InputResult, h as InputOptions, i as set_base_element_global_namespace, l as Base, m as InputOf, n as base_element_name, o as BaseSVG, p as InputKey, r as define_element, s as Loop, t as ELEMENT_LIST, u as BaseIntersectObserver, v as InputValue, x as AccessTypes, y as input_key } from "../index-_y7vmunA.mjs";
3
+ export { ACCESSTYPESINFO, AccessTypes, Base, BaseIntersectObserver, BaseIntersectObserverOptions, BaseSVG, CREATE, ELEMENT_LIST, InputKey, InputOf, InputOptions, InputResult, InputState, InputValue, Loop, base_element_name, base_loop, define_element, input_key, set_base_element_global_namespace, validate_element_name };
package/base/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import "../style.css";
2
2
  import { t as state_ui } from "../state_ui-Dtm2y5RU.mjs";
3
3
  import { state as state$1 } from "@chocbite/ts-lib/state";
4
- import { some } from "@chocbite/ts-lib/result";
4
+ import { ok, some } from "@chocbite/ts-lib/result";
5
5
  // base/access.ts
6
6
  /**Enum of possible access types for base element*/
7
7
  const AccessTypes = {
@@ -24,6 +24,20 @@ const ACCESSTYPESINFO = state$1.e.list({
24
24
  description: "No access to element"
25
25
  }
26
26
  });
27
+ // base/input.ts
28
+ /**Key of the method applying the creation inputs of an element, see Base.create
29
+ * Elements with inputs given at creation override [CREATE] like set, and call super[CREATE] with the options*/
30
+ const CREATE = Symbol("create");
31
+ /**Makes a key for an input, one per input, as a property of a module constant object of the keys of an element
32
+ * @example
33
+ * const SLIDER = {
34
+ * value: input_key<StateOrValROSW<number>>(),
35
+ * step: input_key<number>(),
36
+ * };
37
+ * export type SliderOptions = InputOptions<typeof SLIDER>;*/
38
+ function input_key() {
39
+ return Symbol();
40
+ }
27
41
  // base/intersect_observer.ts
28
42
  var BaseIntersectObserver = class extends IntersectionObserver {
29
43
  #deffered_visible_time;
@@ -90,6 +104,15 @@ const base_resize_observer = new ResizeObserver((e) => {
90
104
  * Elements are only created in code, with new or a factory function, HTML is not supported,
91
105
  * constructors add children and attributes, which document.createElement and the HTML parser do not allow
92
106
  *
107
+ * New elements, and elements being reworked, follow the element pattern in package-ui/PATTERN.md:
108
+ * The class is only exported as a type, a factory function taking optional options creates it with create
109
+ * The constructor takes no arguments, it builds the children and sets the defaults
110
+ * The inputs are an object of keys made with input_key, the options type is InputOptions of it
111
+ * set takes the options, each a fixed value or a state (StateOrVal), and applies them with set_input
112
+ * Inputs handed out to other elements are given once, at creation, and applied by overriding [CREATE]
113
+ * so element_factory({ width: 100, label: label_state }).set({ width: 120 })
114
+ * A fixed value never changes, anything that changes must be a state
115
+ *
93
116
  * All none abstracts classes must override the static method element_name to return the name of the element
94
117
  * Abstract classes should return @abstract@
95
118
  *
@@ -133,7 +156,8 @@ var Base = class extends HTMLElement {
133
156
  if (this.#attached_int_observer) this.#attached_int_observer.unobserve(this);
134
157
  this.internal_set_visible(false);
135
158
  }
136
- /**Sets any attribute on the base element, to either a fixed value or a state value */
159
+ /**Sets any attribute on the base element, to either a fixed value or a state value
160
+ * Older style, new elements take their inputs with set and set_input, see package-ui/PATTERN.md*/
137
161
  opts(opts) {
138
162
  for (const key in opts) {
139
163
  const opt = opts[key];
@@ -142,10 +166,49 @@ var Base = class extends HTMLElement {
142
166
  }
143
167
  return this;
144
168
  }
145
- /**Elements that can attach to a writable state can declare them in binds*/
146
- bind(_opts) {
169
+ /**Applies the given options, options that are not given are left unchanged
170
+ * Can be called any number of times, like when a list reuses an element for other data
171
+ * Elements override it with their own options type and call super.set with the options,
172
+ * each option is applied with set_input, so setting an option again replaces the state set before
173
+ * It runs after every constructor has finished, so overrides called from it can use all fields of the subclass*/
174
+ set(_options) {
147
175
  return this;
148
176
  }
177
+ /**Creates the element, applies the creation inputs with [CREATE] and then the rest with set
178
+ * Factories call it, and called on a subclass it creates the subclass, so a user subclass is made with MyElement.create(options)
179
+ * The options are those of [CREATE] and set together, both run after every constructor has finished
180
+ * The constructor must take no arguments, abstract classes can not be created*/
181
+ static create(options = {}) {
182
+ const element = new this();
183
+ element[CREATE](options);
184
+ return element.set(options);
185
+ }
186
+ /**Applies the inputs given at creation, called once by create before set
187
+ * Inputs other elements follow are given here, and left out of the options of set, so they can never be replaced
188
+ * Elements override it with their own options type and call super[CREATE] with the options, like set*/
189
+ [CREATE](_options) {}
190
+ /**Sets an input that is either a fixed value or a state, see set
191
+ * undefined leaves the input unchanged
192
+ * A fixed value is applied right away as an ok result, and detaches any state the key had
193
+ * A state replaces any state the key had, and is applied while the element is connected
194
+ * The key decides the type of the input, and the result apply gets:
195
+ * inputs that can not be errors give ok results, others results the element must handle
196
+ * @param key the key of the input, made with input_key*/
197
+ set_input(key, input, apply) {
198
+ if (input === void 0) return;
199
+ if (state$1.is.state_of(input)) this.attach_state_to_symbol(key, input, apply);
200
+ else {
201
+ this.detach_state_from_symbol(key);
202
+ apply(ok(input));
203
+ }
204
+ }
205
+ /**The state an input has now, undefined when it has a fixed value or was never set
206
+ * Typed by the key, so a writable input gives a writable state to write to,
207
+ * the element keeps no reference of its own to the state*/
208
+ input_state(key) {
209
+ const func = this.#props.get(key);
210
+ return func && this.#states.get(func)?.[0];
211
+ }
149
212
  /**Executes a function with the element as an argument and returns the element
150
213
  * Useful when declaring multiple elements in a single statement, without easy access to a scope to execute code in*/
151
214
  scope(fn) {
@@ -508,6 +571,6 @@ var BaseSVG = class extends Base {
508
571
  this.canvas.appendChild(this);
509
572
  }
510
573
  };
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 };
574
+ export { ACCESSTYPESINFO, AccessTypes, Base, BaseIntersectObserver, BaseSVG, CREATE, ELEMENT_LIST, Loop, base_element_name, base_loop, define_element, input_key, set_base_element_global_namespace, validate_element_name };
512
575
 
513
576
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["state","state"],"sources":["../../../package-ui/base/access.ts","../../../package-ui/base/intersect_observer.ts","../../../package-ui/base/base.ts","../../../package-ui/base/define_element.ts","../../../package-ui/base/base_loop.ts","../../../package-ui/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_ui\";\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;EAA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AAsB,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":["../../../package-ui/base/access.ts","../../../package-ui/base/input.ts","../../../package-ui/base/intersect_observer.ts","../../../package-ui/base/base.ts","../../../package-ui/base/define_element.ts","../../../package-ui/base/base_loop.ts","../../../package-ui/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 { ResultOk } from \"@chocbite/ts-lib/result\";\nimport type { State, StateResult, StateROA } from \"@chocbite/ts-lib/state\";\n\ndeclare const INPUT_TYPE: unique symbol;\n\n/**Key of the method applying the creation inputs of an element, see Base.create\n * Elements with inputs given at creation override [CREATE] like set, and call super[CREATE] with the options*/\nexport const CREATE: unique symbol = Symbol(\"create\");\n\n/**Key identifying an input of an element, carrying the type of the input, a StateOrVal variant or a plain value type\n * Made with input_key, the type property only exists for the types, so a plain symbol is not a key*/\nexport type InputKey<S> = symbol & { readonly [INPUT_TYPE]: S };\n\n/**Makes a key for an input, one per input, as a property of a module constant object of the keys of an element\n * @example\n * const SLIDER = {\n * value: input_key<StateOrValROSW<number>>(),\n * step: input_key<number>(),\n * };\n * export type SliderOptions = InputOptions<typeof SLIDER>;*/\nexport function input_key<S>(): InputKey<S> {\n return Symbol() as InputKey<S>;\n}\n\n/**Input type of a key, the StateOrVal variant or plain value type it was made with\n * For building an options interface by hand, like options passed on to a child: scale?: InputOf<typeof VIEW.scale>*/\nexport type InputOf<K> = K extends InputKey<infer S> ? S : never;\n\n/**Options of an element from an object of its keys, every option is optional, see Base.set\n * The doc comments of the keys show on the options*/\nexport type InputOptions<K extends Record<string, InputKey<any>>> = {\n [P in keyof K]?: InputOf<K[P]>;\n};\n\n/**State part of an input type, never for plain values*/\nexport type InputState<S> = Extract<S, State<any, any, any>>;\n\n/**Value part of an input type*/\nexport type InputValue<S> = Exclude<S, State<any, any, any>>;\n\n/**Result an input gives, ok results when the input can not be an error*/\nexport type InputResult<S> = [InputState<S>] extends [never]\n ? ResultOk<InputValue<S>>\n : [InputState<S>] extends [StateROA<any, any, any>]\n ? ResultOk<InputValue<S>>\n : StateResult<InputValue<S>>;\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((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 }, options);\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 { ok, 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 CREATE,\n type InputKey,\n type InputResult,\n type InputState,\n type InputValue,\n} from \"./input\";\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 * New elements, and elements being reworked, follow the element pattern in package-ui/PATTERN.md:\n * The class is only exported as a type, a factory function taking optional options creates it with create\n * The constructor takes no arguments, it builds the children and sets the defaults\n * The inputs are an object of keys made with input_key, the options type is InputOptions of it\n * set takes the options, each a fixed value or a state (StateOrVal), and applies them with set_input\n * Inputs handed out to other elements are given once, at creation, and applied by overriding [CREATE]\n * so element_factory({ width: 100, label: label_state }).set({ width: 120 })\n * A fixed value never changes, anything that changes must be a state\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)\n 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 * Older style, new elements take their inputs with set and set_input, see package-ui/PATTERN.md*/\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 /**Applies the given options, options that are not given are left unchanged\n * Can be called any number of times, like when a list reuses an element for other data\n * Elements override it with their own options type and call super.set with the options,\n * each option is applied with set_input, so setting an option again replaces the state set before\n * It runs after every constructor has finished, so overrides called from it can use all fields of the subclass*/\n set(_options: object): this {\n return this;\n }\n\n /**Creates the element, applies the creation inputs with [CREATE] and then the rest with set\n * Factories call it, and called on a subclass it creates the subclass, so a user subclass is made with MyElement.create(options)\n * The options are those of [CREATE] and set together, both run after every constructor has finished\n * The constructor must take no arguments, abstract classes can not be created*/\n static create<T extends Base>(\n this: new () => T,\n options: Parameters<T[typeof CREATE]>[0] & Parameters<T[\"set\"]>[0] = {},\n ): T {\n const element = new this();\n element[CREATE](options);\n return element.set(options);\n }\n\n /**Applies the inputs given at creation, called once by create before set\n * Inputs other elements follow are given here, and left out of the options of set, so they can never be replaced\n * Elements override it with their own options type and call super[CREATE] with the options, like set*/\n [CREATE](_options: object): void {}\n\n /**Sets an input that is either a fixed value or a state, see set\n * undefined leaves the input unchanged\n * A fixed value is applied right away as an ok result, and detaches any state the key had\n * A state replaces any state the key had, and is applied while the element is connected\n * The key decides the type of the input, and the result apply gets:\n * inputs that can not be errors give ok results, others results the element must handle\n * @param key the key of the input, made with input_key*/\n protected set_input<S>(\n key: InputKey<S>,\n input: NoInfer<S> | undefined,\n apply: (value: InputResult<S>) => void,\n ): void {\n if (input === undefined) return;\n if (state.is.state_of(input))\n this.attach_state_to_symbol(key, input, apply as StateSub<any>);\n else {\n this.detach_state_from_symbol(key);\n apply(ok(input as InputValue<S>) as InputResult<S>);\n }\n }\n\n /**The state an input has now, undefined when it has a fixed value or was never set\n * Typed by the key, so a writable input gives a writable state to write to,\n * the element keeps no reference of its own to the state*/\n protected input_state<S>(key: InputKey<S>): InputState<S> | undefined {\n const func = this.#props.get(key);\n return (func && this.#states.get(func)?.[0]) as InputState<S> | undefined;\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_ui\";\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;;;;ACXD,MAAa,SAAwB,OAAO,QAAQ;;;;;;;;AAapD,SAAgB,YAA4B;CAC1C,OAAO,OAAO;AAChB;;ACXA,IAAa,wBAAb,cAA2C,qBAAqB;CAC9D;CACA,4BAA2C;CAC3C,0CAAqC,IAAI,IAAI;CAC7C;CACA,2BAA0C;;CAE1C,yCAA4C,IAAI,IAAI;CAEpD,YAAY,SAAuC;EACjD,OAAO,MAAM;GACX,IACE,KAAK,0BAA0B,KAC/B,KAAK,2BAA2B,GAChC;IACA,KAAK,IAAI,IAAI,GAAG,IAAI,EAAE,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K;GACb,SAAS,KAAK;EAChB,CAAC;CACH;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;;;;AC7CA,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,5 +1,5 @@
1
1
  import '../style.css';
2
- import { l as Base } from "../index-CvzH3M_5.mjs";
2
+ import { l as Base } from "../index-_y7vmunA.mjs";
3
3
  /**Event dispatched on a widget when its position, size or rotation changes */
4
4
  export declare const WIDGET_TRANSFORM_EVENT = "widget_transform";
5
5
  /**Shared class for widgets placed at a fixed position in a viewport
package/canvas/index.mjs CHANGED
@@ -1,6 +1,6 @@
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-D3YluyYr.mjs";
3
+ import { i as theme_init_variable_root } from "../theme-ycsugrdT.mjs";
4
4
  import { $q as material_open_with_rounded, ha as material_arrow_range_rounded, r2 as material_rotate_right_rounded } from "../icons-B88i-7MC.mjs";
5
5
  import { BLUE, GREY } from "@chocbite/ts-lib/colors";
6
6
  // canvas/shared.ts