@chocbite/ts-lib-ui 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/canvas/index.d.mts +114 -59
- package/canvas/index.mjs +645 -575
- package/canvas/index.mjs.map +1 -1
- package/context-menu/index.mjs +1 -1
- package/{context-menu-_9dMpC-H.mjs → context-menu-Cz9rqUaM.mjs} +2 -2
- package/{context-menu-_9dMpC-H.mjs.map → context-menu-Cz9rqUaM.mjs.map} +1 -1
- package/form/index.d.mts +1 -1
- package/form/index.mjs +4 -4
- package/{index-CzpbJoAj.d.mts → index-DCn7acFY.d.mts} +13 -4
- package/keyboard/index.mjs +1 -1
- package/list/index.d.mts +1 -1
- package/list/index.mjs +1 -1
- package/{list-Bkm9Ailw.mjs → list-DXkEJKjx.mjs} +130 -20
- package/list-DXkEJKjx.mjs.map +1 -0
- package/package.json +2 -7
- package/spinner/index.mjs +1 -1
- package/style.css +409 -135
- package/theme/index.mjs +1 -1
- package/{theme-DlD5P5tY.mjs → theme-CFeGnUuF.mjs} +2 -2
- package/{theme-DlD5P5tY.mjs.map → theme-CFeGnUuF.mjs.map} +1 -1
- package/list-Bkm9Ailw.mjs.map +0 -1
- package/viewport/index.d.mts +0 -1
- package/viewport/index.mjs +0 -2
package/theme/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import "../style.css";
|
|
2
|
-
export { s as ANIMATION_LEVEL, c as ANIMATION_SPEED, l as AnimationLevels, n as BUILT_IN, u as INPUT_MODE, d as InputModes, f as SCALE, p as SCROLLBAR_MODE, m as ScrollbarModes, h as THEME, r as ThemeVariableGroup, g as Themes, a as px_to_rem, o as rem_to_px, t as theme_init, i as theme_init_variable_root } from "../theme-
|
|
2
|
+
export { s as ANIMATION_LEVEL, c as ANIMATION_SPEED, l as AnimationLevels, n as BUILT_IN, u as INPUT_MODE, d as InputModes, f as SCALE, p as SCROLLBAR_MODE, m as ScrollbarModes, h as THEME, r as ThemeVariableGroup, g as Themes, a as px_to_rem, o as rem_to_px, t as theme_init, i as theme_init_variable_root } from "../theme-CFeGnUuF.mjs";
|
|
@@ -6,7 +6,7 @@ import { state as state$1 } from "@chocbite/ts-lib/state";
|
|
|
6
6
|
import { none, ok, some } from "@chocbite/ts-lib/result";
|
|
7
7
|
import { GREY } from "@chocbite/ts-lib/colors";
|
|
8
8
|
// ../package.json
|
|
9
|
-
var version = "1.0.
|
|
9
|
+
var version = "1.0.4";
|
|
10
10
|
// src/theme/settings.ts
|
|
11
11
|
const SETTINGS = settings_init("@chocbite/ts-lib-theme", version, "Theme/UI", "Settings for UI elements and color themes");
|
|
12
12
|
/**Accepts a stored setting only when it is one of the given values, otherwise the default is used*/
|
|
@@ -416,4 +416,4 @@ function theme_init(options = {}) {
|
|
|
416
416
|
}
|
|
417
417
|
export { version as _, px_to_rem as a, ANIMATION_SPEED as c, InputModes as d, SCALE as f, Themes as g, THEME as h, theme_init_variable_root as i, AnimationLevels as l, ScrollbarModes as m, BUILT_IN as n, rem_to_px as o, SCROLLBAR_MODE as p, ThemeVariableGroup as r, ANIMATION_LEVEL as s, theme_init as t, INPUT_MODE as u };
|
|
418
418
|
|
|
419
|
-
//# sourceMappingURL=theme-
|
|
419
|
+
//# sourceMappingURL=theme-CFeGnUuF.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-DlD5P5tY.mjs","names":["st"],"sources":["../../package.json","../src/theme/settings.ts","../src/theme/shared.ts","../src/theme/engine.ts","../src/theme/variables.ts","../src/theme/builtIn.ts","../src/theme/init.ts"],"sourcesContent":["","import {\n material_dark_mode_rounded,\n material_edit_rounded,\n material_light_mode_rounded,\n material_mouse_rounded,\n material_touch_app_rounded,\n} from \"#icons\";\nimport { settings_init } from \"#settings\";\nimport { none, ok, some, type Option } from \"@chocbite/ts-lib/result\";\nimport { state as st } from \"@chocbite/ts-lib/state\";\nimport { version } from \"../../../package.json\";\n\nconst SETTINGS = settings_init(\n \"@chocbite/ts-lib-theme\",\n version,\n \"Theme/UI\",\n \"Settings for UI elements and color themes\",\n);\n\n/**Accepts a stored setting only when it is one of the given values, otherwise the default is used*/\nconst one_of =\n <T>(values: { [key: string]: T }) =>\n (stored: unknown): Option<T> =>\n Object.values(values).includes(stored as T) ? some(stored as T) : none();\n\n/**Accepts a stored setting only when it is a number within the range, otherwise the default is used*/\nconst in_range =\n (min: number, max: number) =>\n (stored: unknown): Option<number> =>\n typeof stored === \"number\" && stored >= min && stored <= max\n ? some(stored)\n : none();\n\n// _______ _ _ ______ __ __ ______\n// |__ __| | | | ____| \\/ | ____|\n// | | | |__| | |__ | \\ / | |__\n// | | | __ | __| | |\\/| | __|\n// | | | | | | |____| | | | |____\n// |_| |_| |_|______|_| |_|______|\nexport const Themes = {\n Light: \"light\",\n Dark: \"dark\",\n /**Follows the light or dark mode of the operating system, only offered when theme_init enables system*/\n System: \"system\",\n} as const;\nexport type Themes = (typeof Themes)[keyof typeof Themes];\n/**Themes that can be applied to the page, System is resolved to one of these*/\nexport type AppliedThemes = typeof Themes.Light | typeof Themes.Dark;\n\ntype ThemeList = Parameters<typeof st.e.list<Themes>>[0];\nconst LIGHT = {\n name: \"Light\",\n description: \"Theme optimized for daylight\",\n icon: material_light_mode_rounded,\n};\nconst DARK = {\n name: \"Dark\",\n description: \"Theme optimized for night time\",\n icon: material_dark_mode_rounded,\n};\n/**Theme choices, the System choice shows the theme the operating system currently uses\n * @param system theme of the operating system, undefined when the System choice is not offered*/\nconst theme_list = (system?: AppliedThemes): ThemeList => {\n const list: Partial<ThemeList> = {\n [Themes.Light]: LIGHT,\n [Themes.Dark]: DARK,\n };\n if (system) {\n const active = system === Themes.Dark ? DARK : LIGHT;\n list[Themes.System] = {\n name: \"System (\" + active.name + \")\",\n description: \"Follows the light or dark mode of the operating system\",\n icon: active.icon,\n };\n }\n return list as ThemeList;\n};\nconst THEMES = st.ok_w(theme_list());\n\nconst THEME_ID = \"theme\";\n/**Theme the user chose, undefined when nothing has been chosen yet*/\nconst STORED_THEME = SETTINGS.get<Themes | undefined>(\n THEME_ID,\n undefined,\n one_of(Themes),\n).value;\nconst PRIVATE_THEME = st.rosw(\n st.e.help(ok(STORED_THEME ?? (Themes.Light as Themes)), { list: THEMES }),\n true,\n);\n\nexport const THEME = PRIVATE_THEME.read_write;\n\n/**Sets up the theme setting, called once by theme_init\n * @param system theme of the operating system, undefined when the System choice is not offered\n * @param default_theme theme used when the user has not chosen one*/\nexport function theme_setting_init(\n system: AppliedThemes | undefined,\n default_theme: Themes,\n) {\n if (system) THEMES.set_ok(theme_list(system));\n //Set before registering, so the default is not stored as if the user chose it\n if (STORED_THEME === undefined || (STORED_THEME === Themes.System && !system))\n PRIVATE_THEME.set_ok(default_theme);\n SETTINGS.register(\n THEME_ID,\n \"Theme\",\n \"Theme to use for the UI\",\n PRIVATE_THEME,\n );\n}\n\n/**Updates the System choice to show the theme the operating system uses*/\nexport function theme_setting_system(system: AppliedThemes) {\n THEMES.set_ok(theme_list(system));\n}\n\n// _____ _____ _ ______\n// / ____|/ ____| /\\ | | | ____|\n// | (___ | | / \\ | | | |__\n// \\___ \\| | / /\\ \\ | | | __|\n// ____) | |____ / ____ \\| |____| |____\n// |_____/ \\_____/_/ \\_\\______|______|\nconst SCALE_ID = \"scale\";\nconst PRIVATE_SCALE = st.rosw(\n st.n.help(SETTINGS.get(SCALE_ID, 100, in_range(50, 400)), {\n min: st.ok(50),\n max: st.ok(400),\n unit: st.ok(\"%\"),\n start: st.ok(0),\n step: st.ok(1),\n }),\n true,\n);\nSETTINGS.register(SCALE_ID, \"Scale\", \"UI scale\", PRIVATE_SCALE);\nexport const SCALE = PRIVATE_SCALE.read_write;\n\n// _____ _____ _____ ____ _ _ ____ _____\n// / ____|/ ____| __ \\ / __ \\| | | | | _ \\ /\\ | __ \\\n// | (___ | | | |__) | | | | | | | | |_) | / \\ | |__) |\n// \\___ \\| | | _ /| | | | | | | | _ < / /\\ \\ | _ /\n// ____) | |____| | \\ \\| |__| | |____| |____| |_) / ____ \\| | \\ \\\n// |_____/ \\_____|_| \\_\\\\____/|______|______|____/_/ \\_\\_| \\_\\\nexport const ScrollbarModes = {\n Thin: \"thin\",\n Medium: \"medium\",\n Wide: \"wide\",\n} as const;\nexport type ScrollbarModes =\n (typeof ScrollbarModes)[keyof typeof ScrollbarModes];\n\nconst SCROLLBAR_MODES = st.ok(\n st.e.list<ScrollbarModes>({\n [ScrollbarModes.Thin]: {\n name: \"Thin\",\n description: \"Thin modern scrollbar\",\n },\n [ScrollbarModes.Medium]: {\n name: \"Medium\",\n description: \"Normal scrollbar\",\n },\n [ScrollbarModes.Wide]: {\n name: \"Wide\",\n description: \"Large touch friendly scrollbar\",\n },\n }),\n);\n\nconst SCROLLBAR_ID = \"scrollbar\";\nconst PRIVATE_SCROLLBAR_MODE = st.rosw(\n st.e.help(\n SETTINGS.get(\n SCROLLBAR_ID,\n ScrollbarModes.Thin as ScrollbarModes,\n one_of(ScrollbarModes),\n ),\n { list: SCROLLBAR_MODES },\n ),\n true,\n);\nSETTINGS.register(\n \"scrollbar\",\n \"Scrollbar Mode\",\n \"Size of the scrollbar to use\",\n PRIVATE_SCROLLBAR_MODE,\n);\n\nexport const SCROLLBAR_MODE = PRIVATE_SCROLLBAR_MODE.read_write;\n\n// _____ _ _ _____ _ _ _______ __ __ ____ _____ ______\n// |_ _| \\ | | __ \\| | | |__ __| | \\/ |/ __ \\| __ \\| ____|\n// | | | \\| | |__) | | | | | | | \\ / | | | | | | | |__\n// | | | . ` | ___/| | | | | | | |\\/| | | | | | | | __|\n// _| |_| |\\ | | | |__| | | | | | | | |__| | |__| | |____\n// |_____|_| \\_|_| \\____/ |_| |_| |_|\\____/|_____/|______|\nexport const InputModes = {\n Mouse: \"mouse\",\n Pen: \"pen\",\n Touch: \"touch\",\n} as const;\nexport type InputModes = (typeof InputModes)[keyof typeof InputModes];\n\nconst INPUT_MODES = st.ok(\n st.e.list<InputModes>({\n [InputModes.Mouse]: {\n name: \"Mouse\",\n description: \"Mouse input\",\n icon: material_mouse_rounded,\n },\n [InputModes.Pen]: {\n name: \"Pen\",\n description: \"Pen input\",\n icon: material_edit_rounded,\n },\n [InputModes.Touch]: {\n name: \"Touch\",\n description: \"Touch input\",\n icon: material_touch_app_rounded,\n },\n }),\n);\n\nconst INPUT_MODE_ID = \"input_mode\";\nconst PRIVATE_INPUT_MODE = st.rosw(\n st.e.help(\n SETTINGS.get(\n INPUT_MODE_ID,\n matchMedia(\"(pointer: coarse)\").matches\n ? InputModes.Touch\n : (InputModes.Mouse as InputModes),\n one_of(InputModes),\n ),\n { list: INPUT_MODES },\n ),\n true,\n);\nSETTINGS.register(\n INPUT_MODE_ID,\n \"Input Mode\",\n \"Setting for preffered input mode, changes UI elements to be more optimized for the selected input mode\",\n PRIVATE_INPUT_MODE,\n);\n\nexport const INPUT_MODE = PRIVATE_INPUT_MODE.read_write;\n\n// _ _ _____ __ __ _______ _____ ____ _ _ _ ________ ________ _\n// /\\ | \\ | |_ _| \\/ | /\\|__ __|_ _/ __ \\| \\ | | | | | ____\\ \\ / / ____| |\n// / \\ | \\| | | | | \\ / | / \\ | | | || | | | \\| | | | | |__ \\ \\ / /| |__ | |\n// / /\\ \\ | . ` | | | | |\\/| | / /\\ \\ | | | || | | | . ` | | | | __| \\ \\/ / | __| | |\n// / ____ \\| |\\ |_| |_| | | |/ ____ \\| | _| || |__| | |\\ | | |____| |____ \\ / | |____| |____\n// /_/ \\_\\_| \\_|_____|_| |_/_/ \\_\\_| |_____\\____/|_| \\_| |______|______| \\/ |______|______|\nexport const AnimationLevels = {\n All: \"all\",\n Some: \"some\",\n None: \"none\",\n} as const;\nexport type AnimationLevels =\n (typeof AnimationLevels)[keyof typeof AnimationLevels];\n\nconst ANIMATION_LEVELS = st.ok(\n st.e.list<AnimationLevels>({\n [AnimationLevels.All]: { name: \"All\", description: \"All animations\" },\n [AnimationLevels.Some]: {\n name: \"Functional\",\n description: \"Only functional animations that improve usability\",\n },\n [AnimationLevels.None]: { name: \"None\", description: \"No animations\" },\n }),\n);\n\nconst ANIMATION_LEVEL_ID = \"animation_level\";\nconst PRIVATE_ANIMATION_LEVEL = st.rosw(\n st.e.help(\n SETTINGS.get(\n ANIMATION_LEVEL_ID,\n AnimationLevels.None as AnimationLevels,\n one_of(AnimationLevels),\n ),\n { list: ANIMATION_LEVELS },\n ),\n true,\n);\nSETTINGS.register(\n ANIMATION_LEVEL_ID,\n \"Animation Level\",\n \"Setting for animation level, changes the amount of animations used in the UI\",\n PRIVATE_ANIMATION_LEVEL,\n);\n\nexport const ANIMATION_LEVEL = PRIVATE_ANIMATION_LEVEL.read_write;\n\n// _ _ _____ __ __ _______ _____ ____ _ _ _____ _____ ______ ______ _____\n// /\\ | \\ | |_ _| \\/ | /\\|__ __|_ _/ __ \\| \\ | | / ____| __ \\| ____| ____| __ \\\n// / \\ | \\| | | | | \\ / | / \\ | | | || | | | \\| | | (___ | |__) | |__ | |__ | | | |\n// / /\\ \\ | . ` | | | | |\\/| | / /\\ \\ | | | || | | | . ` | \\___ \\| ___/| __| | __| | | | |\n// / ____ \\| |\\ |_| |_| | | |/ ____ \\| | _| || |__| | |\\ | ____) | | | |____| |____| |__| |\n// /_/ \\_\\_| \\_|_____|_| |_/_/ \\_\\_| |_____\\____/|_| \\_| |_____/|_| |______|______|_____/\nconst ANIMATION_SPEED_ID = \"animation_speed\";\nconst PRIVATE_ANIMATION_SPEED = st.rosw(\n st.n.help(SETTINGS.get(ANIMATION_SPEED_ID, 200, in_range(50, 1000)), {\n min: st.ok(50),\n max: st.ok(1000),\n unit: st.ok(\"ms\"),\n start: st.ok(0),\n step: st.ok(50),\n }),\n true,\n);\nSETTINGS.register(\n ANIMATION_SPEED_ID,\n \"Animation Speed\",\n \"Setting for animation speed, changes the speed of animations in the UI\",\n PRIVATE_ANIMATION_SPEED,\n);\n\nexport const ANIMATION_SPEED = PRIVATE_ANIMATION_SPEED.read_write;\n","import type { ThemeVariableGroup } from \"./variables\";\n\nexport const BOTTOM_GROUPS: { [key: string]: ThemeVariableGroup } = {};\n","import { DOCUMENT_HANDLER } from \"#document\";\nimport {\n ANIMATION_LEVEL,\n ANIMATION_SPEED,\n AnimationLevels,\n INPUT_MODE,\n InputModes,\n SCALE,\n SCROLLBAR_MODE,\n ScrollbarModes,\n THEME,\n Themes,\n type AppliedThemes,\n} from \"./settings\";\nimport { BOTTOM_GROUPS } from \"./shared\";\n\nclass ThemeEngine {\n #started = false;\n /**Theme of the operating system, used for the System theme*/\n #os_theme: AppliedThemes = Themes.Light;\n\n /**Starts applying the theme to all documents, called once by theme_init*/\n start() {\n this.#started = true;\n DOCUMENT_HANDLER.events.on(\"added\", (e) => {\n this.#apply_all_to_doc(e.data);\n });\n this.#for_documents((doc) => {\n this.#apply_all_to_doc(doc);\n });\n }\n\n /**Runs for every document, nothing is applied before the engine is started*/\n #for_documents(func: (doc: Document) => void) {\n if (this.#started) DOCUMENT_HANDLER.for_documents(func);\n }\n\n /**Sets the theme of the operating system, reapplying the theme when System is used*/\n set_os_theme(theme: AppliedThemes) {\n this.#os_theme = theme;\n if (THEME.ok() === Themes.System) this.apply_theme(Themes.System);\n }\n\n /**Resolves the System theme to the theme of the operating system*/\n #applied(theme: Themes): AppliedThemes {\n return theme === Themes.System ? this.#os_theme : theme;\n }\n\n /**This applies the current theme to a document*/\n #apply_all_to_doc(doc: Document) {\n this.#apply_scrollbar_to_doc(doc, SCROLLBAR_MODE.ok());\n this.#apply_theme_to_doc(doc, THEME.ok());\n this.#apply_input_to_doc(doc, INPUT_MODE.ok());\n this.#apply_scale_to_doc(doc, SCALE.ok() / 100);\n this.#apply_animation_level_to_doc(doc, ANIMATION_LEVEL.ok());\n this.#apply_animation_speed_to_doc(doc, ANIMATION_SPEED.ok());\n }\n\n /**This applies the current theme to a document*/\n apply_scrollbar(scroll: ScrollbarModes) {\n this.#for_documents((doc) => {\n this.#apply_scrollbar_to_doc(doc, scroll);\n });\n }\n #apply_scrollbar_to_doc(doc: Document, scroll: ScrollbarModes) {\n doc.documentElement.style.setProperty(\n \"--scrollbar\",\n {\n [ScrollbarModes.Thin]: \"0.6rem\",\n [ScrollbarModes.Medium]: \"1rem\",\n [ScrollbarModes.Wide]: \"2.6rem\",\n }[scroll],\n );\n }\n\n /**This applies the current theme to a document*/\n apply_animation_level(anim: AnimationLevels) {\n this.#for_documents((doc) => {\n this.#apply_animation_level_to_doc(doc, anim);\n });\n }\n #apply_animation_level_to_doc(doc: Document, anim: AnimationLevels) {\n doc.documentElement.classList.remove(\"anim-all\", \"anim-some\");\n switch (anim) {\n case AnimationLevels.All:\n doc.documentElement.classList.add(\"anim-all\");\n doc.documentElement.classList.add(\"anim-some\");\n break;\n case AnimationLevels.Some:\n doc.documentElement.classList.add(\"anim-some\");\n break;\n }\n }\n\n /**This applies the current theme to a document*/\n apply_animation_speed(speed: number) {\n this.#for_documents((doc) => {\n this.#apply_animation_speed_to_doc(doc, speed);\n });\n }\n #apply_animation_speed_to_doc(doc: Document, speed: number) {\n const style = doc.documentElement.style;\n style.setProperty(\"--animation-speed\", speed.toString() + \"ms\");\n }\n\n /**This applies the current theme to a document*/\n apply_theme(theme: Themes) {\n this.#for_documents((doc) => {\n this.#apply_theme_to_doc(doc, theme);\n });\n }\n #apply_theme_to_doc(doc: Document, theme: Themes) {\n const applied = this.#applied(theme);\n for (const key in BOTTOM_GROUPS)\n BOTTOM_GROUPS[key].apply_themes(doc.documentElement.style, applied);\n }\n\n /**This applies the current scale to a document*/\n apply_scale(scale: number) {\n this.#for_documents((doc) => {\n this.#apply_scale_to_doc(doc, scale);\n });\n }\n #apply_scale_to_doc(doc: Document, scale: number) {\n doc.documentElement.style.fontSize = scale * 16 + \"px\";\n }\n\n /**Auto Input Mode */\n apply_input(mode: InputModes) {\n this.#for_documents((doc) => {\n this.#apply_input_to_doc(doc, mode);\n });\n }\n #apply_input_to_doc(doc: Document, mode: InputModes) {\n const style = doc.documentElement.style;\n style.setProperty(\"--mouse\", \"0\");\n style.setProperty(\"--pen\", \"0\");\n style.setProperty(\"--touch\", \"0\");\n doc.documentElement.classList.remove(\"mouse\", \"pen\", \"touch\");\n switch (mode) {\n case InputModes.Mouse:\n style.setProperty(\"--mouse\", \"1\");\n doc.documentElement.classList.add(\"mouse\");\n break;\n case InputModes.Pen:\n style.setProperty(\"--pen\", \"1\");\n doc.documentElement.classList.add(\"pen\");\n break;\n case InputModes.Touch:\n style.setProperty(\"--touch\", \"1\");\n doc.documentElement.classList.add(\"touch\");\n break;\n }\n }\n\n apply_single_property(key: string, variable: { [s: string]: string }) {\n const theme_buff = this.#applied(THEME.ok());\n this.#for_documents((doc) => {\n doc.documentElement.style.setProperty(key, variable[theme_buff]);\n });\n }\n}\n\nexport const theme_engine = new ThemeEngine();\n\nTHEME.sub((val) => {\n theme_engine.apply_theme(val.value);\n});\n/**Size of a rem in pixels at the current scale, set right away from the stored scale*/\nlet scale_rem = 16;\nSCALE.sub((val) => {\n const scale_value = val.value / 100;\n scale_rem = scale_value * 16;\n theme_engine.apply_scale(scale_value);\n}, true);\n/**Converts the given rems to pixels */\nexport function rem_to_px(rem: number) {\n return rem * scale_rem;\n}\n/**Converts the given pixels to rems */\nexport function px_to_rem(px: number) {\n return px / scale_rem;\n}\nSCROLLBAR_MODE.sub((val) => {\n theme_engine.apply_scrollbar(val.value);\n});\nINPUT_MODE.sub((val) => {\n theme_engine.apply_input(val.value);\n});\nANIMATION_LEVEL.sub((val) => {\n theme_engine.apply_animation_level(val.value);\n});\nANIMATION_SPEED.sub((val) => {\n theme_engine.apply_animation_speed(val.value);\n});\n","import { theme_engine } from \"./engine\";\nimport { Themes } from \"./settings\";\nimport { BOTTOM_GROUPS } from \"./shared\";\n\n/**Initialises the settings for the package\n * @param package_name use import {name} from \"../package.json\"\n * @param name name of group formatted for user reading\n * @param description a description of what the setting group is about*/\nexport const theme_init_variable_root = (\n package_name: string,\n name: string,\n description: string\n) => {\n if (package_name.includes(\"-\"))\n throw new Error(\"Dash not permitted in package name \" + package_name);\n if (package_name in BOTTOM_GROUPS)\n throw new Error(\n \"Theme variable group already registered \" +\n package_name +\n \", by another package or by this library being loaded twice\",\n );\n BOTTOM_GROUPS[package_name] = new ThemeVariableGroup(\n package_name,\n name,\n description\n );\n return BOTTOM_GROUPS[package_name];\n};\n\n/**Group of settings should never be instantiated manually use initSettings*/\nexport class ThemeVariableGroup {\n private path_id: string;\n private variables: {\n [key: string]: {\n name: string;\n desc: string;\n vars: { [key: string]: string };\n type: keyof VariableType;\n typeParams: VariableType[keyof VariableType];\n example?: () => Element;\n };\n } = {};\n private sub_groups: { [key: string]: ThemeVariableGroup } = {};\n readonly name: string;\n readonly description: string;\n\n constructor(path: string, name: string, description: string) {\n this.path_id = path;\n this.name = name;\n this.description = description;\n }\n\n /**Makes a variable subgroup for this group\n * @param id unique identifier for this subgroup in the parent group\n * @param name name of group formatted for user reading\n * @param description a description of what the setting group is about formatted for user reading*/\n make_sub_group(id: string, name: string, description: string) {\n if (id.includes(\"-\"))\n throw new Error(\"Dash not permitted in variable id \" + id);\n if (id in this.sub_groups)\n throw new Error(\"Sub group already registered \" + id);\n return (this.sub_groups[id] = new ThemeVariableGroup(\n this.path_id + \"-\" + id,\n name,\n description\n ));\n }\n\n /**Makes a variable\n * @param id unique identifier for this variable in the group\n * @param name name of variable formatted for user reading\n * @param description a description of what the variable is about formatted for user reading\n * @param light value for light mode\n * @param dark value for dark mode\n * @param type type of variable for editing\n * @param type_params */\n make_variable<K extends keyof VariableType>(\n id: string,\n name: string,\n description: string,\n light: string,\n dark: string,\n type: K,\n type_params: VariableType[K],\n example?: () => Element\n ): string {\n if (id.includes(\"-\"))\n throw new Error(\"Dash not permitted in variable id \" + id);\n const key = \"--\" + this.path_id + \"-\" + id;\n if (key in this.variables)\n throw new Error(\"Settings already registered \" + id);\n const variable = (this.variables[key] = {\n name,\n desc: description,\n vars: { [Themes.Light]: light, [Themes.Dark]: dark },\n type,\n typeParams: type_params,\n example,\n });\n theme_engine.apply_single_property(key, variable.vars);\n return key;\n }\n\n /**Applies the groups\n * @param style unique identifier for this variable in the group\n * @param theme name of variable formatted for user reading*/\n apply_themes(style: CSSStyleDeclaration, theme: string) {\n for (const key in this.variables)\n style.setProperty(key, this.variables[key].vars[theme]);\n for (const key in this.sub_groups)\n this.sub_groups[key].apply_themes(style, theme);\n }\n}\n\n/**Defines the parameters for a variable type */\ninterface VariableType {\n /**Font variable, */\n Font: undefined;\n /**Text variable, */\n String: undefined;\n /**Color variable */\n Color: undefined;\n /**Transition type */\n TransitionType: undefined;\n /**Percent type */\n Percent: undefined;\n /**Filter type */\n Filter: undefined;\n /**Radius type */\n Radius: undefined;\n /**Time variable */\n Time: {\n /**Minimum time in milliseconds */\n min: number;\n /**Maximum time in milliseconds */\n max: number;\n };\n /**Angle variable */\n Angle: { min: number; max: number };\n /**Length variable*/\n Length: { min: number; max: number };\n /**Number variable*/\n Number: { min: number; max: number };\n /**Ratio*/\n Ratio:\n | {\n width: { min: number; max: number };\n height: { min: number; max: number };\n }\n | number;\n}\n","import { GREY } from \"@chocbite/ts-lib/colors\";\nimport { theme_init_variable_root } from \"./variables\";\n\nexport const BUILT_IN = 0;\n\nconst root = theme_init_variable_root(\n \"common\",\n \"Shared Variables\",\n \"Shared variables across features\",\n);\n\nconst scroll_bar = root.make_sub_group(\n \"scrollbar\",\n \"Scrollbar\",\n \"Scrollbar variables\",\n);\nconst scroll_bar_thumb = scroll_bar.make_sub_group(\n \"thumb\",\n \"Thumb\",\n \"Scrollbar Thumb variables\",\n);\nscroll_bar_thumb.make_variable(\n \"color\",\n \"Thumb Color\",\n \"Color of the scrollbar thumb in normal state\",\n GREY[\"400\"],\n GREY[\"800\"],\n \"Color\",\n undefined,\n);\nscroll_bar_thumb.make_variable(\n \"hoverColor\",\n \"Thumb Hover Color\",\n \"Color of the scrollbar thumb when hovered\",\n GREY[\"600\"],\n GREY[\"600\"],\n \"Color\",\n undefined,\n);\nscroll_bar_thumb.make_variable(\n \"activeColor\",\n \"Thumb Active Color\",\n \"Color of the scrollbar thumb when pressed\",\n GREY[\"500\"],\n GREY[\"700\"],\n \"Color\",\n undefined,\n);\n\nconst fonts = root.make_sub_group(\"fonts\", \"Fonts\", \"Font variables\");\nfonts.make_variable(\n \"base\",\n \"UI Base Font\",\n \"The base font for the UI\",\n '\"Roboto\", Arial, Helvetica, sans-serif',\n '\"Roboto\", Arial, Helvetica, sans-serif',\n \"Font\",\n undefined,\n);\n\n// _____ ____ _ ____ _____ _____\n// / ____/ __ \\| | / __ \\| __ \\ / ____|\n// | | | | | | | | | | | |__) | (___\n// | | | | | | | | | | | _ / \\___ \\\n// | |___| |__| | |___| |__| | | \\ \\ ____) |\n// \\_____\\____/|______\\____/|_| \\_\\_____/\n\nconst colors = root.make_sub_group(\"colors\", \"Colors\", \"Color variables\");\ncolors.make_variable(\n \"layer1\",\n \"UI Layer 1\",\n \"Color of the first layer of the UI\",\n GREY[50],\n \"#111111\",\n \"Color\",\n undefined,\n);\n","import { theme_engine } from \"./engine\";\nimport {\n theme_setting_init,\n theme_setting_system,\n Themes,\n type AppliedThemes,\n} from \"./settings\";\n\nexport interface ThemeInitOptions {\n /**Offers a System theme that follows the light or dark mode of the operating system,\n * leave it off on devices without that feature*/\n system?: boolean;\n /**Theme used until the user chooses one, defaults to System when system is on, otherwise Light*/\n default?: Themes;\n}\n\nlet initialized = false;\n\n/**Starts the theme, the app must call it once, nothing of the theme is applied to the page before.\n * This is the only place the operating system dark mode is read, and only when system is on*/\nexport function theme_init(options: ThemeInitOptions = {}) {\n const default_theme =\n options.default ?? (options.system ? Themes.System : Themes.Light);\n if (default_theme === Themes.System && !options.system)\n throw new Error(\"The System theme can only be the default with system on\");\n if (initialized) throw new Error(\"theme_init has already been called\");\n initialized = true;\n let os_theme: AppliedThemes | undefined;\n if (options.system) {\n const query = window.matchMedia(\"(prefers-color-scheme: dark)\");\n const theme_of = (dark: boolean) => (dark ? Themes.Dark : Themes.Light);\n os_theme = theme_of(query.matches);\n theme_engine.set_os_theme(os_theme);\n query.addEventListener(\"change\", (e) => {\n const changed = theme_of(e.matches);\n theme_setting_system(changed);\n theme_engine.set_os_theme(changed);\n });\n }\n theme_setting_init(os_theme, default_theme);\n theme_engine.start();\n}\n"],"mappings":";;;;;;;;;;ACYA,MAAM,WAAW,cACf,0BACA,SACA,YACA,2CACF;;AAGA,MAAM,UACA,YACH,WACC,OAAO,OAAO,MAAM,CAAC,CAAC,SAAS,MAAW,IAAI,KAAK,MAAW,IAAI,KAAK;;AAG3E,MAAM,YACH,KAAa,SACb,WACC,OAAO,WAAW,YAAY,UAAU,OAAO,UAAU,MACrD,KAAK,MAAM,IACX,KAAK;AAQb,MAAa,SAAS;CACpB,OAAO;CACP,MAAM;;CAEN,QAAQ;AACV;AAMA,MAAM,QAAQ;CACZ,MAAM;CACN,aAAa;CACb,MAAM;AACR;AACA,MAAM,OAAO;CACX,MAAM;CACN,aAAa;CACb,MAAM;AACR;;;AAGA,MAAM,cAAc,WAAsC;CACxD,MAAM,OAA2B;GAC9B,OAAO,QAAQ;GACf,OAAO,OAAO;CACjB;CACA,IAAI,QAAQ;EACV,MAAM,SAAS,WAAW,OAAO,OAAO,OAAO;EAC/C,KAAK,OAAO,UAAU;GACpB,MAAM,aAAa,OAAO,OAAO;GACjC,aAAa;GACb,MAAM,OAAO;EACf;CACF;CACA,OAAO;AACT;AACA,MAAM,SAASA,QAAG,KAAK,WAAW,CAAC;AAEnC,MAAM,WAAW;;AAEjB,MAAM,eAAe,SAAS,IAC5B,UACA,KAAA,GACA,OAAO,MAAM,CACf,CAAC,CAAC;AACF,MAAM,gBAAgBA,QAAG,KACvBA,QAAG,EAAE,KAAK,GAAG,gBAAiB,OAAO,KAAgB,GAAG,EAAE,MAAM,OAAO,CAAC,GACxE,IACF;AAEA,MAAa,QAAQ,cAAc;;;;AAKnC,SAAgB,mBACd,QACA,eACA;CACA,IAAI,QAAQ,OAAO,OAAO,WAAW,MAAM,CAAC;CAE5C,IAAI,iBAA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A,iBAAiB,cACf,SACA,eACA,gDACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AACA,iBAAiB,cACf,cACA,qBACA,6CACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AACA,iBAAiB,cACf,eACA,sBACA,6CACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AAEc,KAAK,eAAe,SAAS,SAAS,gBAChD,CAAC,CAAC,cACJ,QACA,gBACA,4BACA,4CACA,4CACA,QACA,KAAA,CACF;AASe,KAAK,eAAe,UAAU,UAAU,iBAClD,CAAC,CAAC,cACL,UACA,cACA,sCACA,KAAK,KACL,WACA,SACA,KAAA,CACF;;AC5DA,IAAI,cAAc;;;AAIlB,SAAgB,WAAW,UAA4B,CAAC,GAAG;CACzD,MAAM,gBACJ,QAAQ,YAAY,QAAQ,SAAS,OAAO,SAAS,OAAO;CAC9D,IAAI,kBAAkB,OAAO,UAAU,CAAC,QAAQ,QAC9C,MAAM,IAAI,MAAM,yDAAyD;CAC3E,IAAI,aAAa,MAAM,IAAI,MAAM,oCAAoC;CACrE,cAAc;CACd,IAAI;CACJ,IAAI,QAAQ,QAAQ;EAClB,MAAM,QAAQ,OAAO,WAAW,8BAA8B;EAC9D,MAAM,YAAY,SAAmB,OAAO,OAAO,OAAO,OAAO;EACjE,WAAW,SAAS,MAAM,OAAO;EACjC,aAAa,aAAa,QAAQ;EAClC,MAAM,iBAAiB,WAAW,MAAM;GACtC,MAAM,UAAU,SAAS,EAAE,OAAO;GAClC,qBAAqB,OAAO;GAC5B,aAAa,aAAa,OAAO;EACnC,CAAC;CACH;CACA,mBAAmB,UAAU,aAAa;CAC1C,aAAa,MAAM;AACrB"}
|
|
1
|
+
{"version":3,"file":"theme-CFeGnUuF.mjs","names":["st"],"sources":["../../package.json","../src/theme/settings.ts","../src/theme/shared.ts","../src/theme/engine.ts","../src/theme/variables.ts","../src/theme/builtIn.ts","../src/theme/init.ts"],"sourcesContent":["","import {\n material_dark_mode_rounded,\n material_edit_rounded,\n material_light_mode_rounded,\n material_mouse_rounded,\n material_touch_app_rounded,\n} from \"#icons\";\nimport { settings_init } from \"#settings\";\nimport { none, ok, some, type Option } from \"@chocbite/ts-lib/result\";\nimport { state as st } from \"@chocbite/ts-lib/state\";\nimport { version } from \"../../../package.json\";\n\nconst SETTINGS = settings_init(\n \"@chocbite/ts-lib-theme\",\n version,\n \"Theme/UI\",\n \"Settings for UI elements and color themes\",\n);\n\n/**Accepts a stored setting only when it is one of the given values, otherwise the default is used*/\nconst one_of =\n <T>(values: { [key: string]: T }) =>\n (stored: unknown): Option<T> =>\n Object.values(values).includes(stored as T) ? some(stored as T) : none();\n\n/**Accepts a stored setting only when it is a number within the range, otherwise the default is used*/\nconst in_range =\n (min: number, max: number) =>\n (stored: unknown): Option<number> =>\n typeof stored === \"number\" && stored >= min && stored <= max\n ? some(stored)\n : none();\n\n// _______ _ _ ______ __ __ ______\n// |__ __| | | | ____| \\/ | ____|\n// | | | |__| | |__ | \\ / | |__\n// | | | __ | __| | |\\/| | __|\n// | | | | | | |____| | | | |____\n// |_| |_| |_|______|_| |_|______|\nexport const Themes = {\n Light: \"light\",\n Dark: \"dark\",\n /**Follows the light or dark mode of the operating system, only offered when theme_init enables system*/\n System: \"system\",\n} as const;\nexport type Themes = (typeof Themes)[keyof typeof Themes];\n/**Themes that can be applied to the page, System is resolved to one of these*/\nexport type AppliedThemes = typeof Themes.Light | typeof Themes.Dark;\n\ntype ThemeList = Parameters<typeof st.e.list<Themes>>[0];\nconst LIGHT = {\n name: \"Light\",\n description: \"Theme optimized for daylight\",\n icon: material_light_mode_rounded,\n};\nconst DARK = {\n name: \"Dark\",\n description: \"Theme optimized for night time\",\n icon: material_dark_mode_rounded,\n};\n/**Theme choices, the System choice shows the theme the operating system currently uses\n * @param system theme of the operating system, undefined when the System choice is not offered*/\nconst theme_list = (system?: AppliedThemes): ThemeList => {\n const list: Partial<ThemeList> = {\n [Themes.Light]: LIGHT,\n [Themes.Dark]: DARK,\n };\n if (system) {\n const active = system === Themes.Dark ? DARK : LIGHT;\n list[Themes.System] = {\n name: \"System (\" + active.name + \")\",\n description: \"Follows the light or dark mode of the operating system\",\n icon: active.icon,\n };\n }\n return list as ThemeList;\n};\nconst THEMES = st.ok_w(theme_list());\n\nconst THEME_ID = \"theme\";\n/**Theme the user chose, undefined when nothing has been chosen yet*/\nconst STORED_THEME = SETTINGS.get<Themes | undefined>(\n THEME_ID,\n undefined,\n one_of(Themes),\n).value;\nconst PRIVATE_THEME = st.rosw(\n st.e.help(ok(STORED_THEME ?? (Themes.Light as Themes)), { list: THEMES }),\n true,\n);\n\nexport const THEME = PRIVATE_THEME.read_write;\n\n/**Sets up the theme setting, called once by theme_init\n * @param system theme of the operating system, undefined when the System choice is not offered\n * @param default_theme theme used when the user has not chosen one*/\nexport function theme_setting_init(\n system: AppliedThemes | undefined,\n default_theme: Themes,\n) {\n if (system) THEMES.set_ok(theme_list(system));\n //Set before registering, so the default is not stored as if the user chose it\n if (STORED_THEME === undefined || (STORED_THEME === Themes.System && !system))\n PRIVATE_THEME.set_ok(default_theme);\n SETTINGS.register(\n THEME_ID,\n \"Theme\",\n \"Theme to use for the UI\",\n PRIVATE_THEME,\n );\n}\n\n/**Updates the System choice to show the theme the operating system uses*/\nexport function theme_setting_system(system: AppliedThemes) {\n THEMES.set_ok(theme_list(system));\n}\n\n// _____ _____ _ ______\n// / ____|/ ____| /\\ | | | ____|\n// | (___ | | / \\ | | | |__\n// \\___ \\| | / /\\ \\ | | | __|\n// ____) | |____ / ____ \\| |____| |____\n// |_____/ \\_____/_/ \\_\\______|______|\nconst SCALE_ID = \"scale\";\nconst PRIVATE_SCALE = st.rosw(\n st.n.help(SETTINGS.get(SCALE_ID, 100, in_range(50, 400)), {\n min: st.ok(50),\n max: st.ok(400),\n unit: st.ok(\"%\"),\n start: st.ok(0),\n step: st.ok(1),\n }),\n true,\n);\nSETTINGS.register(SCALE_ID, \"Scale\", \"UI scale\", PRIVATE_SCALE);\nexport const SCALE = PRIVATE_SCALE.read_write;\n\n// _____ _____ _____ ____ _ _ ____ _____\n// / ____|/ ____| __ \\ / __ \\| | | | | _ \\ /\\ | __ \\\n// | (___ | | | |__) | | | | | | | | |_) | / \\ | |__) |\n// \\___ \\| | | _ /| | | | | | | | _ < / /\\ \\ | _ /\n// ____) | |____| | \\ \\| |__| | |____| |____| |_) / ____ \\| | \\ \\\n// |_____/ \\_____|_| \\_\\\\____/|______|______|____/_/ \\_\\_| \\_\\\nexport const ScrollbarModes = {\n Thin: \"thin\",\n Medium: \"medium\",\n Wide: \"wide\",\n} as const;\nexport type ScrollbarModes =\n (typeof ScrollbarModes)[keyof typeof ScrollbarModes];\n\nconst SCROLLBAR_MODES = st.ok(\n st.e.list<ScrollbarModes>({\n [ScrollbarModes.Thin]: {\n name: \"Thin\",\n description: \"Thin modern scrollbar\",\n },\n [ScrollbarModes.Medium]: {\n name: \"Medium\",\n description: \"Normal scrollbar\",\n },\n [ScrollbarModes.Wide]: {\n name: \"Wide\",\n description: \"Large touch friendly scrollbar\",\n },\n }),\n);\n\nconst SCROLLBAR_ID = \"scrollbar\";\nconst PRIVATE_SCROLLBAR_MODE = st.rosw(\n st.e.help(\n SETTINGS.get(\n SCROLLBAR_ID,\n ScrollbarModes.Thin as ScrollbarModes,\n one_of(ScrollbarModes),\n ),\n { list: SCROLLBAR_MODES },\n ),\n true,\n);\nSETTINGS.register(\n \"scrollbar\",\n \"Scrollbar Mode\",\n \"Size of the scrollbar to use\",\n PRIVATE_SCROLLBAR_MODE,\n);\n\nexport const SCROLLBAR_MODE = PRIVATE_SCROLLBAR_MODE.read_write;\n\n// _____ _ _ _____ _ _ _______ __ __ ____ _____ ______\n// |_ _| \\ | | __ \\| | | |__ __| | \\/ |/ __ \\| __ \\| ____|\n// | | | \\| | |__) | | | | | | | \\ / | | | | | | | |__\n// | | | . ` | ___/| | | | | | | |\\/| | | | | | | | __|\n// _| |_| |\\ | | | |__| | | | | | | | |__| | |__| | |____\n// |_____|_| \\_|_| \\____/ |_| |_| |_|\\____/|_____/|______|\nexport const InputModes = {\n Mouse: \"mouse\",\n Pen: \"pen\",\n Touch: \"touch\",\n} as const;\nexport type InputModes = (typeof InputModes)[keyof typeof InputModes];\n\nconst INPUT_MODES = st.ok(\n st.e.list<InputModes>({\n [InputModes.Mouse]: {\n name: \"Mouse\",\n description: \"Mouse input\",\n icon: material_mouse_rounded,\n },\n [InputModes.Pen]: {\n name: \"Pen\",\n description: \"Pen input\",\n icon: material_edit_rounded,\n },\n [InputModes.Touch]: {\n name: \"Touch\",\n description: \"Touch input\",\n icon: material_touch_app_rounded,\n },\n }),\n);\n\nconst INPUT_MODE_ID = \"input_mode\";\nconst PRIVATE_INPUT_MODE = st.rosw(\n st.e.help(\n SETTINGS.get(\n INPUT_MODE_ID,\n matchMedia(\"(pointer: coarse)\").matches\n ? InputModes.Touch\n : (InputModes.Mouse as InputModes),\n one_of(InputModes),\n ),\n { list: INPUT_MODES },\n ),\n true,\n);\nSETTINGS.register(\n INPUT_MODE_ID,\n \"Input Mode\",\n \"Setting for preffered input mode, changes UI elements to be more optimized for the selected input mode\",\n PRIVATE_INPUT_MODE,\n);\n\nexport const INPUT_MODE = PRIVATE_INPUT_MODE.read_write;\n\n// _ _ _____ __ __ _______ _____ ____ _ _ _ ________ ________ _\n// /\\ | \\ | |_ _| \\/ | /\\|__ __|_ _/ __ \\| \\ | | | | | ____\\ \\ / / ____| |\n// / \\ | \\| | | | | \\ / | / \\ | | | || | | | \\| | | | | |__ \\ \\ / /| |__ | |\n// / /\\ \\ | . ` | | | | |\\/| | / /\\ \\ | | | || | | | . ` | | | | __| \\ \\/ / | __| | |\n// / ____ \\| |\\ |_| |_| | | |/ ____ \\| | _| || |__| | |\\ | | |____| |____ \\ / | |____| |____\n// /_/ \\_\\_| \\_|_____|_| |_/_/ \\_\\_| |_____\\____/|_| \\_| |______|______| \\/ |______|______|\nexport const AnimationLevels = {\n All: \"all\",\n Some: \"some\",\n None: \"none\",\n} as const;\nexport type AnimationLevels =\n (typeof AnimationLevels)[keyof typeof AnimationLevels];\n\nconst ANIMATION_LEVELS = st.ok(\n st.e.list<AnimationLevels>({\n [AnimationLevels.All]: { name: \"All\", description: \"All animations\" },\n [AnimationLevels.Some]: {\n name: \"Functional\",\n description: \"Only functional animations that improve usability\",\n },\n [AnimationLevels.None]: { name: \"None\", description: \"No animations\" },\n }),\n);\n\nconst ANIMATION_LEVEL_ID = \"animation_level\";\nconst PRIVATE_ANIMATION_LEVEL = st.rosw(\n st.e.help(\n SETTINGS.get(\n ANIMATION_LEVEL_ID,\n AnimationLevels.None as AnimationLevels,\n one_of(AnimationLevels),\n ),\n { list: ANIMATION_LEVELS },\n ),\n true,\n);\nSETTINGS.register(\n ANIMATION_LEVEL_ID,\n \"Animation Level\",\n \"Setting for animation level, changes the amount of animations used in the UI\",\n PRIVATE_ANIMATION_LEVEL,\n);\n\nexport const ANIMATION_LEVEL = PRIVATE_ANIMATION_LEVEL.read_write;\n\n// _ _ _____ __ __ _______ _____ ____ _ _ _____ _____ ______ ______ _____\n// /\\ | \\ | |_ _| \\/ | /\\|__ __|_ _/ __ \\| \\ | | / ____| __ \\| ____| ____| __ \\\n// / \\ | \\| | | | | \\ / | / \\ | | | || | | | \\| | | (___ | |__) | |__ | |__ | | | |\n// / /\\ \\ | . ` | | | | |\\/| | / /\\ \\ | | | || | | | . ` | \\___ \\| ___/| __| | __| | | | |\n// / ____ \\| |\\ |_| |_| | | |/ ____ \\| | _| || |__| | |\\ | ____) | | | |____| |____| |__| |\n// /_/ \\_\\_| \\_|_____|_| |_/_/ \\_\\_| |_____\\____/|_| \\_| |_____/|_| |______|______|_____/\nconst ANIMATION_SPEED_ID = \"animation_speed\";\nconst PRIVATE_ANIMATION_SPEED = st.rosw(\n st.n.help(SETTINGS.get(ANIMATION_SPEED_ID, 200, in_range(50, 1000)), {\n min: st.ok(50),\n max: st.ok(1000),\n unit: st.ok(\"ms\"),\n start: st.ok(0),\n step: st.ok(50),\n }),\n true,\n);\nSETTINGS.register(\n ANIMATION_SPEED_ID,\n \"Animation Speed\",\n \"Setting for animation speed, changes the speed of animations in the UI\",\n PRIVATE_ANIMATION_SPEED,\n);\n\nexport const ANIMATION_SPEED = PRIVATE_ANIMATION_SPEED.read_write;\n","import type { ThemeVariableGroup } from \"./variables\";\n\nexport const BOTTOM_GROUPS: { [key: string]: ThemeVariableGroup } = {};\n","import { DOCUMENT_HANDLER } from \"#document\";\nimport {\n ANIMATION_LEVEL,\n ANIMATION_SPEED,\n AnimationLevels,\n INPUT_MODE,\n InputModes,\n SCALE,\n SCROLLBAR_MODE,\n ScrollbarModes,\n THEME,\n Themes,\n type AppliedThemes,\n} from \"./settings\";\nimport { BOTTOM_GROUPS } from \"./shared\";\n\nclass ThemeEngine {\n #started = false;\n /**Theme of the operating system, used for the System theme*/\n #os_theme: AppliedThemes = Themes.Light;\n\n /**Starts applying the theme to all documents, called once by theme_init*/\n start() {\n this.#started = true;\n DOCUMENT_HANDLER.events.on(\"added\", (e) => {\n this.#apply_all_to_doc(e.data);\n });\n this.#for_documents((doc) => {\n this.#apply_all_to_doc(doc);\n });\n }\n\n /**Runs for every document, nothing is applied before the engine is started*/\n #for_documents(func: (doc: Document) => void) {\n if (this.#started) DOCUMENT_HANDLER.for_documents(func);\n }\n\n /**Sets the theme of the operating system, reapplying the theme when System is used*/\n set_os_theme(theme: AppliedThemes) {\n this.#os_theme = theme;\n if (THEME.ok() === Themes.System) this.apply_theme(Themes.System);\n }\n\n /**Resolves the System theme to the theme of the operating system*/\n #applied(theme: Themes): AppliedThemes {\n return theme === Themes.System ? this.#os_theme : theme;\n }\n\n /**This applies the current theme to a document*/\n #apply_all_to_doc(doc: Document) {\n this.#apply_scrollbar_to_doc(doc, SCROLLBAR_MODE.ok());\n this.#apply_theme_to_doc(doc, THEME.ok());\n this.#apply_input_to_doc(doc, INPUT_MODE.ok());\n this.#apply_scale_to_doc(doc, SCALE.ok() / 100);\n this.#apply_animation_level_to_doc(doc, ANIMATION_LEVEL.ok());\n this.#apply_animation_speed_to_doc(doc, ANIMATION_SPEED.ok());\n }\n\n /**This applies the current theme to a document*/\n apply_scrollbar(scroll: ScrollbarModes) {\n this.#for_documents((doc) => {\n this.#apply_scrollbar_to_doc(doc, scroll);\n });\n }\n #apply_scrollbar_to_doc(doc: Document, scroll: ScrollbarModes) {\n doc.documentElement.style.setProperty(\n \"--scrollbar\",\n {\n [ScrollbarModes.Thin]: \"0.6rem\",\n [ScrollbarModes.Medium]: \"1rem\",\n [ScrollbarModes.Wide]: \"2.6rem\",\n }[scroll],\n );\n }\n\n /**This applies the current theme to a document*/\n apply_animation_level(anim: AnimationLevels) {\n this.#for_documents((doc) => {\n this.#apply_animation_level_to_doc(doc, anim);\n });\n }\n #apply_animation_level_to_doc(doc: Document, anim: AnimationLevels) {\n doc.documentElement.classList.remove(\"anim-all\", \"anim-some\");\n switch (anim) {\n case AnimationLevels.All:\n doc.documentElement.classList.add(\"anim-all\");\n doc.documentElement.classList.add(\"anim-some\");\n break;\n case AnimationLevels.Some:\n doc.documentElement.classList.add(\"anim-some\");\n break;\n }\n }\n\n /**This applies the current theme to a document*/\n apply_animation_speed(speed: number) {\n this.#for_documents((doc) => {\n this.#apply_animation_speed_to_doc(doc, speed);\n });\n }\n #apply_animation_speed_to_doc(doc: Document, speed: number) {\n const style = doc.documentElement.style;\n style.setProperty(\"--animation-speed\", speed.toString() + \"ms\");\n }\n\n /**This applies the current theme to a document*/\n apply_theme(theme: Themes) {\n this.#for_documents((doc) => {\n this.#apply_theme_to_doc(doc, theme);\n });\n }\n #apply_theme_to_doc(doc: Document, theme: Themes) {\n const applied = this.#applied(theme);\n for (const key in BOTTOM_GROUPS)\n BOTTOM_GROUPS[key].apply_themes(doc.documentElement.style, applied);\n }\n\n /**This applies the current scale to a document*/\n apply_scale(scale: number) {\n this.#for_documents((doc) => {\n this.#apply_scale_to_doc(doc, scale);\n });\n }\n #apply_scale_to_doc(doc: Document, scale: number) {\n doc.documentElement.style.fontSize = scale * 16 + \"px\";\n }\n\n /**Auto Input Mode */\n apply_input(mode: InputModes) {\n this.#for_documents((doc) => {\n this.#apply_input_to_doc(doc, mode);\n });\n }\n #apply_input_to_doc(doc: Document, mode: InputModes) {\n const style = doc.documentElement.style;\n style.setProperty(\"--mouse\", \"0\");\n style.setProperty(\"--pen\", \"0\");\n style.setProperty(\"--touch\", \"0\");\n doc.documentElement.classList.remove(\"mouse\", \"pen\", \"touch\");\n switch (mode) {\n case InputModes.Mouse:\n style.setProperty(\"--mouse\", \"1\");\n doc.documentElement.classList.add(\"mouse\");\n break;\n case InputModes.Pen:\n style.setProperty(\"--pen\", \"1\");\n doc.documentElement.classList.add(\"pen\");\n break;\n case InputModes.Touch:\n style.setProperty(\"--touch\", \"1\");\n doc.documentElement.classList.add(\"touch\");\n break;\n }\n }\n\n apply_single_property(key: string, variable: { [s: string]: string }) {\n const theme_buff = this.#applied(THEME.ok());\n this.#for_documents((doc) => {\n doc.documentElement.style.setProperty(key, variable[theme_buff]);\n });\n }\n}\n\nexport const theme_engine = new ThemeEngine();\n\nTHEME.sub((val) => {\n theme_engine.apply_theme(val.value);\n});\n/**Size of a rem in pixels at the current scale, set right away from the stored scale*/\nlet scale_rem = 16;\nSCALE.sub((val) => {\n const scale_value = val.value / 100;\n scale_rem = scale_value * 16;\n theme_engine.apply_scale(scale_value);\n}, true);\n/**Converts the given rems to pixels */\nexport function rem_to_px(rem: number) {\n return rem * scale_rem;\n}\n/**Converts the given pixels to rems */\nexport function px_to_rem(px: number) {\n return px / scale_rem;\n}\nSCROLLBAR_MODE.sub((val) => {\n theme_engine.apply_scrollbar(val.value);\n});\nINPUT_MODE.sub((val) => {\n theme_engine.apply_input(val.value);\n});\nANIMATION_LEVEL.sub((val) => {\n theme_engine.apply_animation_level(val.value);\n});\nANIMATION_SPEED.sub((val) => {\n theme_engine.apply_animation_speed(val.value);\n});\n","import { theme_engine } from \"./engine\";\nimport { Themes } from \"./settings\";\nimport { BOTTOM_GROUPS } from \"./shared\";\n\n/**Initialises the settings for the package\n * @param package_name use import {name} from \"../package.json\"\n * @param name name of group formatted for user reading\n * @param description a description of what the setting group is about*/\nexport const theme_init_variable_root = (\n package_name: string,\n name: string,\n description: string\n) => {\n if (package_name.includes(\"-\"))\n throw new Error(\"Dash not permitted in package name \" + package_name);\n if (package_name in BOTTOM_GROUPS)\n throw new Error(\n \"Theme variable group already registered \" +\n package_name +\n \", by another package or by this library being loaded twice\",\n );\n BOTTOM_GROUPS[package_name] = new ThemeVariableGroup(\n package_name,\n name,\n description\n );\n return BOTTOM_GROUPS[package_name];\n};\n\n/**Group of settings should never be instantiated manually use initSettings*/\nexport class ThemeVariableGroup {\n private path_id: string;\n private variables: {\n [key: string]: {\n name: string;\n desc: string;\n vars: { [key: string]: string };\n type: keyof VariableType;\n typeParams: VariableType[keyof VariableType];\n example?: () => Element;\n };\n } = {};\n private sub_groups: { [key: string]: ThemeVariableGroup } = {};\n readonly name: string;\n readonly description: string;\n\n constructor(path: string, name: string, description: string) {\n this.path_id = path;\n this.name = name;\n this.description = description;\n }\n\n /**Makes a variable subgroup for this group\n * @param id unique identifier for this subgroup in the parent group\n * @param name name of group formatted for user reading\n * @param description a description of what the setting group is about formatted for user reading*/\n make_sub_group(id: string, name: string, description: string) {\n if (id.includes(\"-\"))\n throw new Error(\"Dash not permitted in variable id \" + id);\n if (id in this.sub_groups)\n throw new Error(\"Sub group already registered \" + id);\n return (this.sub_groups[id] = new ThemeVariableGroup(\n this.path_id + \"-\" + id,\n name,\n description\n ));\n }\n\n /**Makes a variable\n * @param id unique identifier for this variable in the group\n * @param name name of variable formatted for user reading\n * @param description a description of what the variable is about formatted for user reading\n * @param light value for light mode\n * @param dark value for dark mode\n * @param type type of variable for editing\n * @param type_params */\n make_variable<K extends keyof VariableType>(\n id: string,\n name: string,\n description: string,\n light: string,\n dark: string,\n type: K,\n type_params: VariableType[K],\n example?: () => Element\n ): string {\n if (id.includes(\"-\"))\n throw new Error(\"Dash not permitted in variable id \" + id);\n const key = \"--\" + this.path_id + \"-\" + id;\n if (key in this.variables)\n throw new Error(\"Settings already registered \" + id);\n const variable = (this.variables[key] = {\n name,\n desc: description,\n vars: { [Themes.Light]: light, [Themes.Dark]: dark },\n type,\n typeParams: type_params,\n example,\n });\n theme_engine.apply_single_property(key, variable.vars);\n return key;\n }\n\n /**Applies the groups\n * @param style unique identifier for this variable in the group\n * @param theme name of variable formatted for user reading*/\n apply_themes(style: CSSStyleDeclaration, theme: string) {\n for (const key in this.variables)\n style.setProperty(key, this.variables[key].vars[theme]);\n for (const key in this.sub_groups)\n this.sub_groups[key].apply_themes(style, theme);\n }\n}\n\n/**Defines the parameters for a variable type */\ninterface VariableType {\n /**Font variable, */\n Font: undefined;\n /**Text variable, */\n String: undefined;\n /**Color variable */\n Color: undefined;\n /**Transition type */\n TransitionType: undefined;\n /**Percent type */\n Percent: undefined;\n /**Filter type */\n Filter: undefined;\n /**Radius type */\n Radius: undefined;\n /**Time variable */\n Time: {\n /**Minimum time in milliseconds */\n min: number;\n /**Maximum time in milliseconds */\n max: number;\n };\n /**Angle variable */\n Angle: { min: number; max: number };\n /**Length variable*/\n Length: { min: number; max: number };\n /**Number variable*/\n Number: { min: number; max: number };\n /**Ratio*/\n Ratio:\n | {\n width: { min: number; max: number };\n height: { min: number; max: number };\n }\n | number;\n}\n","import { GREY } from \"@chocbite/ts-lib/colors\";\nimport { theme_init_variable_root } from \"./variables\";\n\nexport const BUILT_IN = 0;\n\nconst root = theme_init_variable_root(\n \"common\",\n \"Shared Variables\",\n \"Shared variables across features\",\n);\n\nconst scroll_bar = root.make_sub_group(\n \"scrollbar\",\n \"Scrollbar\",\n \"Scrollbar variables\",\n);\nconst scroll_bar_thumb = scroll_bar.make_sub_group(\n \"thumb\",\n \"Thumb\",\n \"Scrollbar Thumb variables\",\n);\nscroll_bar_thumb.make_variable(\n \"color\",\n \"Thumb Color\",\n \"Color of the scrollbar thumb in normal state\",\n GREY[\"400\"],\n GREY[\"800\"],\n \"Color\",\n undefined,\n);\nscroll_bar_thumb.make_variable(\n \"hoverColor\",\n \"Thumb Hover Color\",\n \"Color of the scrollbar thumb when hovered\",\n GREY[\"600\"],\n GREY[\"600\"],\n \"Color\",\n undefined,\n);\nscroll_bar_thumb.make_variable(\n \"activeColor\",\n \"Thumb Active Color\",\n \"Color of the scrollbar thumb when pressed\",\n GREY[\"500\"],\n GREY[\"700\"],\n \"Color\",\n undefined,\n);\n\nconst fonts = root.make_sub_group(\"fonts\", \"Fonts\", \"Font variables\");\nfonts.make_variable(\n \"base\",\n \"UI Base Font\",\n \"The base font for the UI\",\n '\"Roboto\", Arial, Helvetica, sans-serif',\n '\"Roboto\", Arial, Helvetica, sans-serif',\n \"Font\",\n undefined,\n);\n\n// _____ ____ _ ____ _____ _____\n// / ____/ __ \\| | / __ \\| __ \\ / ____|\n// | | | | | | | | | | | |__) | (___\n// | | | | | | | | | | | _ / \\___ \\\n// | |___| |__| | |___| |__| | | \\ \\ ____) |\n// \\_____\\____/|______\\____/|_| \\_\\_____/\n\nconst colors = root.make_sub_group(\"colors\", \"Colors\", \"Color variables\");\ncolors.make_variable(\n \"layer1\",\n \"UI Layer 1\",\n \"Color of the first layer of the UI\",\n GREY[50],\n \"#111111\",\n \"Color\",\n undefined,\n);\n","import { theme_engine } from \"./engine\";\nimport {\n theme_setting_init,\n theme_setting_system,\n Themes,\n type AppliedThemes,\n} from \"./settings\";\n\nexport interface ThemeInitOptions {\n /**Offers a System theme that follows the light or dark mode of the operating system,\n * leave it off on devices without that feature*/\n system?: boolean;\n /**Theme used until the user chooses one, defaults to System when system is on, otherwise Light*/\n default?: Themes;\n}\n\nlet initialized = false;\n\n/**Starts the theme, the app must call it once, nothing of the theme is applied to the page before.\n * This is the only place the operating system dark mode is read, and only when system is on*/\nexport function theme_init(options: ThemeInitOptions = {}) {\n const default_theme =\n options.default ?? (options.system ? Themes.System : Themes.Light);\n if (default_theme === Themes.System && !options.system)\n throw new Error(\"The System theme can only be the default with system on\");\n if (initialized) throw new Error(\"theme_init has already been called\");\n initialized = true;\n let os_theme: AppliedThemes | undefined;\n if (options.system) {\n const query = window.matchMedia(\"(prefers-color-scheme: dark)\");\n const theme_of = (dark: boolean) => (dark ? Themes.Dark : Themes.Light);\n os_theme = theme_of(query.matches);\n theme_engine.set_os_theme(os_theme);\n query.addEventListener(\"change\", (e) => {\n const changed = theme_of(e.matches);\n theme_setting_system(changed);\n theme_engine.set_os_theme(changed);\n });\n }\n theme_setting_init(os_theme, default_theme);\n theme_engine.start();\n}\n"],"mappings":";;;;;;;;;;ACYA,MAAM,WAAW,cACf,0BACA,SACA,YACA,2CACF;;AAGA,MAAM,UACA,YACH,WACC,OAAO,OAAO,MAAM,CAAC,CAAC,SAAS,MAAW,IAAI,KAAK,MAAW,IAAI,KAAK;;AAG3E,MAAM,YACH,KAAa,SACb,WACC,OAAO,WAAW,YAAY,UAAU,OAAO,UAAU,MACrD,KAAK,MAAM,IACX,KAAK;AAQb,MAAa,SAAS;CACpB,OAAO;CACP,MAAM;;CAEN,QAAQ;AACV;AAMA,MAAM,QAAQ;CACZ,MAAM;CACN,aAAa;CACb,MAAM;AACR;AACA,MAAM,OAAO;CACX,MAAM;CACN,aAAa;CACb,MAAM;AACR;;;AAGA,MAAM,cAAc,WAAsC;CACxD,MAAM,OAA2B;GAC9B,OAAO,QAAQ;GACf,OAAO,OAAO;CACjB;CACA,IAAI,QAAQ;EACV,MAAM,SAAS,WAAW,OAAO,OAAO,OAAO;EAC/C,KAAK,OAAO,UAAU;GACpB,MAAM,aAAa,OAAO,OAAO;GACjC,aAAa;GACb,MAAM,OAAO;EACf;CACF;CACA,OAAO;AACT;AACA,MAAM,SAASA,QAAG,KAAK,WAAW,CAAC;AAEnC,MAAM,WAAW;;AAEjB,MAAM,eAAe,SAAS,IAC5B,UACA,KAAA,GACA,OAAO,MAAM,CACf,CAAC,CAAC;AACF,MAAM,gBAAgBA,QAAG,KACvBA,QAAG,EAAE,KAAK,GAAG,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|
package/list-Bkm9Ailw.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"list-Bkm9Ailw.mjs","names":["state","state","state","state"],"sources":["../src/list/key_field.ts","../src/list/add_row.ts","../src/list/field.ts","../src/list/row.ts","../src/list/shared.ts","../src/list/container.ts","../src/list/types.ts","../src/list/index.ts"],"sourcesContent":["import { Base, define_element } from \"#base\";\nimport { array_from_length } from \"@chocbite/ts-lib/common\";\nimport { none, some } from \"@chocbite/ts-lib/result\";\nimport { state, type State } from \"@chocbite/ts-lib/state\";\nimport type { SVGFunc } from \"#svg\";\nimport \"./key_field.scss\";\nimport type { ListRowParent, ListType } from \"./types\";\n\nexport interface ListKeyFieldOptions {\n icon?: SVGFunc | State<SVGFunc>;\n}\n\nexport class ListKeyField<A extends ListType<any>> extends Base {\n static element_name() {\n return \"keyfield\";\n }\n static element_name_space() {\n return \"list\";\n }\n\n #opener: HTMLDivElement;\n #text_box?: HTMLSpanElement;\n #icon?: SVGSVGElement;\n\n constructor(parent: ListRowParent<A>) {\n super();\n this.tabIndex = 0;\n this.onkeydown = (e) => {\n if (e.key === \"Enter\" || e.key === \" \") parent.open = !parent.open;\n else if (e.key === \"ArrowRight\") parent.open = true;\n else if (e.key === \"ArrowLeft\") parent.open = false;\n else if (e.key === \"ArrowDown\") parent.select_adjacent(\"next\", none());\n else if (e.key === \"ArrowUp\") parent.select_adjacent(\"previous\", none());\n else return;\n e.preventDefault();\n };\n\n const opener_box = document.createElement(\"span\");\n this.#opener = opener_box.appendChild(document.createElement(\"div\"));\n this.replaceChildren(\n ...array_from_length(parent.depth, (i) => {\n const div = document.createElement(\"div\");\n div.style.borderColor = \"var(--i-\" + i + \")\";\n return div;\n }),\n opener_box,\n );\n\n this.#opener.addEventListener(\"click\", (e) => {\n e.stopPropagation();\n e.preventDefault();\n parent.open = !parent.open;\n });\n }\n\n set options(options: ListKeyFieldOptions | undefined) {\n if (state.is.state(options?.icon)) {\n this.attach_state_to_prop(\"icon\", options.icon, () => some(undefined));\n } else this.detach_state_from_prop(\"icon\").icon = options?.icon;\n }\n\n set icon(value: SVGFunc | undefined) {\n if (this.#icon) this.#icon.remove();\n this.#icon = undefined;\n if (!value) return;\n this.#icon = value();\n if (this.#text_box) this.insertBefore(this.#icon, this.#text_box);\n else this.appendChild(this.#icon);\n }\n\n // ____ _____ ______ _ _ _____ _ _ _____\n // / __ \\| __ \\| ____| \\ | |_ _| \\ | |/ ____|\n // | | | | |__) | |__ | \\| | | | | \\| | | __\n // | | | | ___/| __| | . ` | | | | . ` | | |_ |\n // | |__| | | | |____| |\\ |_| |_| |\\ | |__| |\n // \\____/|_| |______|_| \\_|_____|_| \\_|\\_____|\n\n set openable(value: boolean) {\n if (value) this.classList.add(\"openable\");\n else this.classList.remove(\"openable\");\n }\n get openable(): boolean {\n return this.classList.contains(\"openable\");\n }\n}\ndefine_element(ListKeyField);\n","import { Base, define_element } from \"#base\";\nimport { some } from \"@chocbite/ts-lib/result\";\nimport { state, type State } from \"@chocbite/ts-lib/state\";\nimport type { SVGFunc } from \"#svg\";\nimport \"./add_row.scss\";\nimport { ListKeyField } from \"./key_field\";\nimport type {\n ListParentRows,\n ListRoot,\n ListRowParent,\n ListType,\n} from \"./types\";\n\nexport interface ListAddRowOptions {\n text: string | State<string>;\n disabled?: boolean | State<boolean>;\n icon?: SVGFunc | State<SVGFunc>;\n on_add: () => void;\n}\n\nexport class ListAddRow<\n R,\n T extends {},\n A extends ListType<any>,\n S extends boolean,\n>\n extends Base\n implements ListRowParent<A>\n{\n static element_name() {\n return \"addrow\";\n }\n static element_name_space(): string {\n return \"list\";\n }\n\n #button: HTMLSpanElement;\n #text: Text;\n #icon?: SVGSVGElement;\n #parent: ListRowParent<A>;\n readonly depth: number;\n\n constructor(root: ListRoot<R, T, A, S>, parent: ListRowParent<A>) {\n super();\n this.#parent = parent;\n this.depth = parent.depth + 1;\n if (root.sub_rows) this.appendChild(new ListKeyField(this));\n this.#button = this.appendChild(document.createElement(\"span\"));\n this.#button.tabIndex = 0;\n this.#text = this.#button.appendChild(document.createTextNode(\"\"));\n }\n\n set options(options: ListAddRowOptions) {\n this.#button.onclick = options.on_add;\n\n if (state.is.state(options.text))\n this.attach_state_to_prop(\"text\", options.text, (e) => some(e));\n else this.detach_state_from_prop(\"text\").text = options.text;\n if (state.is.state(options.disabled))\n this.attach_state_to_prop(\"disabled\", options.disabled, () =>\n some(false),\n );\n else this.detach_state_from_prop(\"disabled\").disabled = Boolean(\n options.disabled,\n );\n if (state.is.state(options.icon))\n this.attach_state_to_prop(\"icon\", options.icon, () => some(undefined));\n else this.detach_state_from_prop(\"icon\").icon = options.icon;\n }\n\n set text(value: string) {\n this.#text.data = value;\n }\n\n set icon(value: SVGFunc | undefined) {\n this.#icon?.remove();\n this.#icon = value ? this.#button.insertBefore(value(), this.#text) : undefined;\n }\n\n set disabled(value: boolean) {\n if (value) this.inert = true;\n else this.inert = false;\n }\n\n set open(_value: boolean) {}\n get open(): boolean {\n return false;\n }\n\n set global_index(_value: number) {}\n get global_index(): number {\n return 0;\n }\n\n /**Rows the add row adds to, the state of its parent */\n set state(_value: ListParentRows<A>) {}\n get state(): ListParentRows<A> {\n return this.#parent.state;\n }\n\n get global_amount(): number {\n return 0;\n }\n\n select_adjacent(): void {}\n}\ndefine_element(ListAddRow);\n","import { Base, define_element } from \"#base\";\nimport \"./field.scss\";\n\nexport abstract class ListField extends Base {\n static element_name() {\n return \"@abstract@\";\n }\n static element_name_space() {\n return \"list\";\n }\n\n constructor() {\n super();\n }\n}\n\nexport class ListTextField extends ListField {\n static element_name() {\n return \"textfield\";\n }\n\n set text(value: string) {\n this.textContent = value;\n }\n}\ndefine_element(ListTextField);\n\nexport function text_field() {\n return new ListTextField();\n}\n\nexport class ListNumberField extends ListField {\n static element_name() {\n return \"numberfield\";\n }\n\n set number(value: number) {\n this.textContent = value.toString();\n }\n}\ndefine_element(ListNumberField);\n\nexport function number_field() {\n return new ListNumberField();\n}\n\nexport class ListNodeField<T extends Node> extends ListField {\n static element_name() {\n return \"nodefield\";\n }\n\n constructor(node: T) {\n super();\n this.appendChild(node);\n }\n\n set node(node: T) {\n this.replaceChildren(node);\n }\n\n get node() {\n return this.firstChild! as unknown as T;\n }\n}\ndefine_element(ListNodeField);\n\nexport function node_field<T extends Node>(node: T) {\n return new ListNodeField<T>(node);\n}\n","import { Base, define_element } from \"#base\";\nimport ctm, { ContextMenu } from \"#context-menu\";\nimport { some, type Option } from \"@chocbite/ts-lib/result\";\nimport { state, type State, type StateInferSub } from \"@chocbite/ts-lib/state\";\nimport state_ui from \"#state\";\nimport { ListAddRow, type ListAddRowOptions } from \"./add_row\";\nimport type { ListField } from \"./field\";\nimport { ListKeyField, type ListKeyFieldOptions } from \"./key_field\";\nimport \"./row.scss\";\nimport type {\n ListParentRows,\n ListRoot,\n ListRowParent,\n ListRowTransformer,\n ListType,\n} from \"./types\";\n\nexport type ListSubRows<R> = () => R[] | State<R[]>;\n\nexport interface ListRowOptions<R, T extends {}, S extends boolean> {\n opened?: boolean;\n openable?: boolean | State<boolean>;\n key_field?: ListKeyFieldOptions;\n sub_rows?: S extends true ? ListSubRows<R> : never;\n add_row?: ListAddRowOptions;\n context_menu?: ContextMenu | (() => Option<ContextMenu>);\n values: T;\n}\n\nexport class ListRow<R, T extends {}, A extends ListType<R>, S extends boolean>\n extends Base\n implements ListRowParent<A>\n{\n static element_name() {\n return \"row\";\n }\n static element_name_space(): string {\n return \"list\";\n }\n #root: ListRoot<R, T, A, S>;\n #parent: ListRowParent<A>;\n #sub_rows?: ListSubRows<R>;\n readonly depth: number;\n #key_field?: ListKeyField<A>;\n #field_box: HTMLDivElement;\n #child_box: HTMLSpanElement;\n #add_row?: ListAddRow<R, T, A, S>;\n #fields: ListField[];\n #values!: T;\n #open_pending = false;\n #sub_row_menu = false;\n #state_sub?: StateInferSub<State<R[]>>;\n state!: ListParentRows<A>;\n\n constructor(root: ListRoot<R, T, A, S>, parent: ListRowParent<A>, data: R) {\n super();\n this.#root = root;\n this.#parent = parent;\n this.depth = parent.depth + 1;\n this.style.setProperty(\"--i-\" + this.depth, \"var(--c)\");\n if (this.#root.sub_rows) {\n this.#key_field = new ListKeyField(this);\n if (this.#root.observer)\n this.#key_field.attach_to_intersect_observer(this.#root.observer);\n }\n this.#field_box = this.appendChild(document.createElement(\"div\"));\n this.#child_box = this.appendChild(document.createElement(\"span\"));\n //A right click on a sub row without its own menu reaches the child box before this row\n if (this.#root.sub_rows)\n this.#child_box.oncontextmenu = () => {\n this.#sub_row_menu = true;\n };\n this.#fields = this.#generate_fields();\n\n //Updates row data\n this.data = data;\n }\n\n #generate_fields(): ListField[] {\n const fields = this.#root.columns_visible.map((key) => {\n const field = this.#root.columns.get(key)!.field_gen();\n if (this.#root.observer)\n field.attach_to_intersect_observer(this.#root.observer);\n return field;\n });\n if (this.#key_field)\n this.#field_box.replaceChildren(this.#key_field, ...fields);\n else this.#field_box.replaceChildren(...fields);\n return fields;\n }\n\n #apply_values() {\n this.#root.columns_visible.forEach((key, index) => {\n this.#root.columns\n .get(key)!\n .field_apply(this.#fields[index], this.#values[key]);\n });\n }\n\n /**Regenerates the fields of the row and its sub rows after the columns changed */\n columns_changed() {\n this.#fields = this.#generate_fields();\n this.#apply_values();\n for (let i = 0; i < this.#child_box.childElementCount; i++)\n (this.#child_box.children[i] as ListRow<R, T, A, S>).columns_changed();\n }\n\n // _____ _____ ______ _ _ _______\n // | __ \\ /\\ | __ \\| ____| \\ | |__ __|\n // | |__) / \\ | |__) | |__ | \\| | | |\n // | ___/ /\\ \\ | _ /| __| | . ` | | |\n // | | / ____ \\| | \\ \\| |____| |\\ | | |\n // |_| /_/ \\_\\_| \\_\\______|_| \\_| |_|\n\n select_adjacent(\n direction: \"next\" | \"previous\" | \"p_next\" | \"p_previous\" | \"last\",\n field: Option<number>,\n ) {\n if (!this.#key_field) return;\n if (direction === \"next\" || direction === \"p_next\") {\n if (direction === \"next\" && this.open)\n (\n this.#child_box.firstElementChild! as ListRow<R, T, A, false>\n ).#key_field!.focus();\n else {\n const sibling = this.nextElementSibling;\n if (sibling instanceof ListRow) sibling.#key_field!.focus();\n else this.#parent.select_adjacent(\"p_next\", field);\n }\n } else if (direction === \"previous\") {\n const sibling = this.previousElementSibling;\n if (sibling instanceof ListRow) {\n if (sibling.open) sibling.select_adjacent(\"last\", field);\n else sibling.#key_field!.focus();\n } else this.#parent.select_adjacent(\"p_previous\", field);\n } else if (direction === \"p_previous\") this.#key_field.focus();\n else if (direction === \"last\") {\n if (this.open) {\n (\n this.#child_box.lastElementChild as ListRow<R, T, A, S>\n ).select_adjacent(\"last\", field);\n } else this.#key_field.focus();\n }\n }\n\n // _____ _______\n // | __ \\ /\\|__ __|/\\\n // | | | | / \\ | | / \\\n // | | | |/ /\\ \\ | | / /\\ \\\n // | |__| / ____ \\| |/ ____ \\\n // |_____/_/ \\_\\_/_/ \\_\\\n\n set data(data: R) {\n const row_options = this.#root.transform(\n data,\n this,\n //Only the container gives top level rows, rows are only parents of sub rows\n this.#parent.state as Parameters<ListRowTransformer<R, T, A, S>>[2],\n );\n if (this.#key_field) this.#key_field.options = row_options.key_field;\n this.#sub_rows = row_options.sub_rows;\n\n this.add_row = row_options.add_row;\n\n this.#values = row_options.values;\n this.#apply_values();\n\n //Setup openable\n const was_open = this.open;\n if (state.is.state(row_options.openable)) {\n //Opening waits for the first value of the state, which is immediate when connected\n this.#open_pending = !was_open && Boolean(row_options.opened);\n this.attach_state_to_prop(\"openable\", row_options.openable, () =>\n some(false),\n );\n } else {\n this.#open_pending = false;\n this.detach_state_from_prop(\"openable\");\n this.openable = Boolean(row_options.openable);\n if (!was_open && row_options.opened) this.open = true;\n }\n\n //Refresh the sub rows of an open row\n if (was_open && this.open) {\n if (this.#sub_rows) this.rows = this.#sub_rows();\n else if (!row_options.opened) this.open = false;\n }\n\n //Setup context menu, blocked for right clicks bubbling up from sub rows\n ctm.detach(this);\n this.#sub_row_menu = false;\n if (row_options.context_menu)\n ctm.attach(this, row_options.context_menu, () => {\n const from_sub_row = this.#sub_row_menu;\n this.#sub_row_menu = false;\n return from_sub_row;\n });\n }\n\n set add_row(options: ListAddRowOptions | undefined) {\n if (!options && this.#add_row) {\n this.#add_row.remove();\n this.classList.remove(\"addrow\");\n this.#add_row = undefined;\n } else if (options) {\n if (!this.#add_row) {\n this.classList.add(\"addrow\");\n this.#add_row = this.appendChild(\n new ListAddRow<R, T, A, S>(this.#root, this),\n );\n }\n this.#add_row.options = options;\n }\n }\n\n // ____ _____ ______ _ _ _____ _ _ _____\n // / __ \\| __ \\| ____| \\ | |_ _| \\ | |/ ____|\n // | | | | |__) | |__ | \\| | | | | \\| | | __\n // | | | | ___/| __| | . ` | | | | . ` | | |_ |\n // | |__| | | | |____| |\\ |_| |_| |\\ | |__| |\n // \\____/|_| |______|_| \\_|_____|_| \\_|\\_____|\n\n set openable(value: boolean) {\n if (!value) this.open = false;\n if (this.#key_field) this.#key_field.openable = value;\n if (this.#open_pending) {\n this.#open_pending = false;\n if (value) this.open = true;\n }\n }\n get openable(): boolean {\n return this.#key_field?.openable ?? false;\n }\n\n set open(open: boolean) {\n if (!this.openable) return;\n if (open && this.#child_box.childElementCount === 0) {\n if (this.#sub_rows) this.rows = this.#sub_rows?.();\n } else if (!open && this.open) this.rows = [];\n }\n get open(): boolean {\n return this.classList.contains(\"open\");\n }\n\n // _____ ______ _______\n // | __ \\ / __ \\ \\ / / ____|\n // | |__) | | | \\ \\ /\\ / / (___\n // | _ /| | | |\\ \\/ \\/ / \\___ \\\n // | | \\ \\| |__| | \\ /\\ / ____) |\n // |_| \\_\\\\____/ \\/ \\/ |_____/\n\n get index(): number {\n return Array.prototype.indexOf.call(this.parentElement!.children, this);\n }\n\n amount_rows(rec: boolean = false): number {\n let count = this.#child_box.childElementCount;\n if (rec)\n for (let i = 0; i < this.#child_box.childElementCount; i++)\n count += (\n this.#child_box.children[i] as ListRow<R, T, A, S>\n ).amount_rows(true);\n return count;\n }\n\n set rows(rows: R[] | State<R[]>) {\n if (this.#state_sub) this.detach_state(this.#state_sub);\n this.#state_sub = undefined;\n //R is the item type of A\n this.state = rows as ListParentRows<A>;\n if (state.is.state(rows))\n this.#state_sub = this.attach_state(rows, (r) =>\n this.#update_rows(r.ok ? r.value : []),\n );\n else this.#update_rows(rows);\n }\n\n #update_rows(rows: readonly R[]) {\n this.classList.toggle(\"open\", rows.length > 0);\n state_ui.a.apply(this.#child_box, rows, {\n create: (row) => new ListRow<R, T, A, S>(this.#root, this, row),\n update: (element, row) => (element.data = row),\n });\n }\n}\ndefine_element(ListRow);\n","import { GREY, ORANGE } from \"@chocbite/ts-lib/colors\";\nimport { theme_init_variable_root } from \"#theme\";\n\nconst theme_root = theme_init_variable_root(\n \"list\",\n \"UI List Elements\",\n \"Theme variables for UI list elements\",\n);\n\n// _____ ______ _____ ____ _ _ _ __ __\n// | __ \\| ____| /\\ | __ \\ / __ \\| \\ | | | \\ \\ / /\n// | |__) | |__ / \\ | | | | | | | | \\| | | \\ \\_/ /\n// | _ /| __| / /\\ \\ | | | | | | | | . ` | | \\ /\n// | | \\ \\| |____ / ____ \\| |__| | | |__| | |\\ | |____| |\n// |_| \\_\\______/_/ \\_\\_____/ \\____/|_| \\_|______|_|\nconst read_only = theme_root.make_sub_group(\n \"read\",\n \"Read Only\",\n \"Settings for list elements in read only mode\",\n);\nread_only.make_variable(\n \"filter\",\n \"Read Only Filter\",\n \"Filter applied to list elements in read only mode\",\n \"opacity(0.6)\",\n \"opacity(0.6)\",\n \"Filter\",\n undefined,\n);\n\n//#################################################################################3\n//#################################################################################3\n// _____ ____ _ ____ _____ _____\n// / ____/ __ \\| | / __ \\| __ \\ / ____|\n// | | | | | | | | | | | |__) | (___\n// | | | | | | | | | | | _ / \\___ \\\n// | |___| |__| | |___| |__| | | \\ \\ ____) |\n// \\_____\\____/|______\\____/|_| \\_\\_____/\nconst colors = theme_root.make_sub_group(\n \"colors\",\n \"Colors\",\n \"Colors used in all list elements\",\n);\n\n// _______ ________ _________ _____ ____ _ ____ _____ _____\n// |__ __| ____\\ \\ / /__ __| / ____/ __ \\| | / __ \\| __ \\ / ____|\n// | | | |__ \\ V / | | | | | | | | | | | | | |__) | (___\n// | | | __| > < | | | | | | | | | | | | | _ / \\___ \\\n// | | | |____ / . \\ | | | |___| |__| | |___| |__| | | \\ \\ ____) |\n// |_| |______/_/ \\_\\ |_| \\_____\\____/|______\\____/|_| \\_\\_____/\nconst colors_text = colors.make_sub_group(\n \"text\",\n \"Text Colors\",\n \"Text colors used in all list elements\",\n);\ncolors_text.make_variable(\n \"header\",\n \"Header Text Color\",\n \"Header text color in list elements\",\n GREY[\"900\"],\n GREY[\"50\"],\n \"Color\",\n undefined,\n);\ncolors_text.make_variable(\n \"field\",\n \"Field Text Color\",\n \"Text color of list field elements\",\n GREY[\"800\"],\n GREY[\"100\"],\n \"Color\",\n undefined,\n);\ncolors_text.make_variable(\n \"key_field\",\n \"Special Column Text Color\",\n \"Text color of special first column elements\",\n GREY[\"900\"],\n GREY[\"50\"],\n \"Color\",\n undefined,\n);\ncolors_text.make_variable(\n \"add\",\n \"Row Adder Text Color\",\n \"Text color of row adder button\",\n GREY[\"900\"],\n GREY[\"50\"],\n \"Color\",\n undefined,\n);\n\n// _____ _____ ____ _ _ _____ ____ _ ____ _____ _____\n// |_ _/ ____/ __ \\| \\ | | / ____/ __ \\| | / __ \\| __ \\ / ____|\n// | || | | | | | \\| | | | | | | | | | | | | |__) | (___\n// | || | | | | | . ` | | | | | | | | | | | | _ / \\___ \\\n// _| || |___| |__| | |\\ | | |___| |__| | |___| |__| | | \\ \\ ____) |\n// |_____\\_____\\____/|_| \\_| \\_____\\____/|______\\____/|_| \\_\\_____/\nconst colors_icon = colors.make_sub_group(\n \"icon\",\n \"Icon Colors\",\n \"Icon colors used in all form elements\",\n);\ncolors_icon.make_variable(\n \"sub_opener\",\n \"Sub Row Opener Icon Color\",\n \"Color of the sub row opener icon\",\n GREY[\"800\"],\n GREY[\"200\"],\n \"Color\",\n undefined,\n);\ncolors_icon.make_variable(\n \"key_icon\",\n \"Key Field Icon Color\",\n \"Color of the key field icon\",\n GREY[\"800\"],\n GREY[\"200\"],\n \"Color\",\n undefined,\n);\ncolors_icon.make_variable(\n \"add_icon\",\n \"Add Row Icon Color\",\n \"Color of the add row icon\",\n GREY[\"800\"],\n GREY[\"200\"],\n \"Color\",\n undefined,\n);\n\n// ____ _____ _ _______ _____ ____ _ _ _ _ _____ _____ ____ _ ____ _____ _____\n// | _ \\ /\\ / ____| |/ / ____| __ \\ / __ \\| | | | \\ | | __ \\ / ____/ __ \\| | / __ \\| __ \\ / ____|\n// | |_) | / \\ | | | ' / | __| |__) | | | | | | | \\| | | | | | | | | | | | | | | | |__) | (___\n// | _ < / /\\ \\| | | <| | |_ | _ /| | | | | | | . ` | | | | | | | | | | | | | | | _ / \\___ \\\n// | |_) / ____ \\ |____| . \\ |__| | | \\ \\| |__| | |__| | |\\ | |__| | | |___| |__| | |___| |__| | | \\ \\ ____) |\n// |____/_/ \\_\\_____|_|\\_\\_____|_| \\_\\\\____/ \\____/|_| \\_|_____/ \\_____\\____/|______\\____/|_| \\_\\_____/\nconst colors_background = colors.make_sub_group(\n \"background\",\n \"Background Colors\",\n \"Background colors used in all list elements\",\n);\ncolors_background.make_variable(\n \"row_even\",\n \"Even Row Background Color\",\n \"Color of even row element backgrounds\",\n GREY[\"100\"],\n GREY[\"800\"],\n \"Color\",\n undefined,\n);\ncolors_background.make_variable(\n \"row_odd\",\n \"Odd Row Background Color\",\n \"Color of odd row element backgrounds\",\n GREY[\"50\"],\n GREY[\"900\"],\n \"Color\",\n undefined,\n);\ncolors_background.make_variable(\n \"row_hover\",\n \"Hover Row Background Color\",\n \"Color of row element backgrounds when hovering\",\n GREY[\"300\"],\n GREY[\"700\"],\n \"Color\",\n undefined,\n);\n\n// ____ ____ _____ _____ ______ _____ _____ ____ _ ____ _____ _____\n// | _ \\ / __ \\| __ \\| __ \\| ____| __ \\ / ____/ __ \\| | / __ \\| __ \\ / ____|\n// | |_) | | | | |__) | | | | |__ | |__) | | | | | | | | | | | | |__) | (___\n// | _ <| | | | _ /| | | | __| | _ / | | | | | | | | | | | _ / \\___ \\\n// | |_) | |__| | | \\ \\| |__| | |____| | \\ \\ | |___| |__| | |___| |__| | | \\ \\ ____) |\n// |____/ \\____/|_| \\_\\_____/|______|_| \\_\\ \\_____\\____/|______\\____/|_| \\_\\_____/\nconst colors_border = colors.make_sub_group(\n \"border\",\n \"Border Colors\",\n \"Border colors used in all list elements\",\n);\ncolors_border.make_variable(\n \"header\",\n \"Header Border Color\",\n \"Color of borders under header\",\n GREY[\"600\"],\n GREY[\"400\"],\n \"Color\",\n undefined,\n);\ncolors_border.make_variable(\n \"row\",\n \"Row Border Color\",\n \"Color of borders between rows\",\n GREY[\"400\"],\n GREY[\"600\"],\n \"Color\",\n undefined,\n);\ncolors_border.make_variable(\n \"column\",\n \"Column Border Color\",\n \"Color of border between columns\",\n GREY[\"500\"],\n GREY[\"500\"],\n \"Color\",\n undefined,\n);\n\n// ______ ____ _____ _ _ _____\n// | ____/ __ \\ / ____| | | |/ ____|\n// | |__ | | | | | | | | | (___\n// | __|| | | | | | | | |\\___ \\\n// | | | |__| | |____| |__| |____) |\n// |_| \\____/ \\_____|\\____/|_____/\nconst colors_focus = colors.make_sub_group(\n \"focus\",\n \"Focus Colors\",\n \"Focus colors used in all list elements\",\n);\ncolors_focus.make_variable(\n \"normal\",\n \"Focus Color\",\n \"Color of focussed list element\",\n ORANGE[\"600\"],\n ORANGE[\"300\"],\n \"Color\",\n undefined,\n);\n\n//#################################################################################3\n//#################################################################################3\n// _____ _____ ____________ _____\n// / ____|_ _|___ / ____|/ ____|\n// | (___ | | / /| |__ | (___\n// \\___ \\ | | / / | __| \\___ \\\n// ____) |_| |_ / /__| |____ ____) |\n// |_____/|_____/_____|______|_____/\nconst sizes = theme_root.make_sub_group(\n \"size\",\n \"Size\",\n \"Sizes used in all list elements\",\n);\n\nsizes.make_variable(\n \"row_min\",\n \"Row Minimum Height\",\n \"Minimum height for list rows\",\n \"1.4rem\",\n \"1.4rem\",\n \"Length\",\n { min: 0.1, max: 10 },\n);\n\nsizes.make_variable(\n \"touch_row_min\",\n \"Touch Row Minimum Height\",\n \"Minimum height for list rows on touch devices\",\n \"2.6rem\",\n \"2.6rem\",\n \"Length\",\n { min: 0.1, max: 10 },\n);\n\nsizes.make_variable(\n \"add_min\",\n \"Add Row Minimum Height\",\n \"Minimum height for add row button\",\n \"1rem\",\n \"1rem\",\n \"Length\",\n { min: 0.1, max: 10 },\n);\n\nsizes.make_variable(\n \"touch_add_min\",\n \"Touch Add Row Minimum Height\",\n \"Minimum height for add row button on touch devices\",\n \"2rem\",\n \"2rem\",\n \"Length\",\n { min: 0.1, max: 10 },\n);\n\n//#################################################################################3\n//#################################################################################3\n// _ _ _____ __ __ _______ _____ ____ _ _\n// /\\ | \\ | |_ _| \\/ | /\\|__ __|_ _/ __ \\| \\ | |\n// / \\ | \\| | | | | \\ / | / \\ | | | || | | | \\| |\n// / /\\ \\ | . ` | | | | |\\/| | / /\\ \\ | | | || | | | . ` |\n// / ____ \\| |\\ |_| |_| | | |/ ____ \\| | _| || |__| | |\\ |\n// /_/ \\_\\_| \\_|_____|_| |_/_/ \\_\\_| |_____\\____/|_| \\_|\nconst animation = theme_root.make_sub_group(\n \"animation\",\n \"Animation\",\n \"Animation settings used in all list elements\",\n);\n\nanimation.make_variable(\n \"transitionType\",\n \"Transition Type\",\n \"Type of transition used in list element animations\",\n \"ease-in-out\",\n \"ease-in-out\",\n \"TransitionType\",\n undefined,\n);\n\nanimation.make_variable(\n \"transitionDuration\",\n \"Transition Duration\",\n \"Duration of transitions used in list element animations\",\n \"200ms\",\n \"200ms\",\n \"Time\",\n { min: 0, max: 5000 },\n);\n\n//#################################################################################3\n//#################################################################################3\n// ______ ____ _ _ _______\n// | ____/ __ \\| \\ | |__ __|\n// | |__ | | | | \\| | | |\n// | __|| | | | . ` | | |\n// | | | |__| | |\\ | | |\n// |_| \\____/|_| \\_| |_|\nconst font = theme_root.make_sub_group(\n \"font\",\n \"Font\",\n \"Font settings used in all list elements\",\n);\n\nfont.make_variable(\n \"size\",\n \"Font Size\",\n \"Default font size used in all list elements\",\n \"1rem\",\n \"1rem\",\n \"Length\",\n { min: 0.1, max: 10 },\n);\n\nfont.make_variable(\n \"touchSize\",\n \"Touch Font Size\",\n \"Font size used in all list elements for touch devices\",\n \"1.2rem\",\n \"1.2rem\",\n \"Length\",\n { min: 0.1, max: 10 },\n);\n","import {\n Base,\n define_element,\n type BaseIntersectObserver,\n} from \"#base\";\nimport { state, type State, type StateInferSub } from \"@chocbite/ts-lib/state\";\nimport state_ui from \"#state\";\nimport { px_to_rem } from \"#theme\";\nimport { ListAddRow, type ListAddRowOptions } from \"./add_row\";\nimport \"./container.scss\";\nimport { text_field } from \"./field\";\nimport { ListRow } from \"./row\";\nimport \"./shared\";\nimport type {\n ListColumnOptions,\n ListRoot,\n ListRowParent,\n ListRowTransformer,\n ListType,\n ListTypeExtract,\n} from \"./types.ts\";\n\nclass HeaderField extends Base {\n static element_name() {\n return \"headerfield\";\n }\n static element_name_space(): string {\n return \"list\";\n }\n\n #box = this.appendChild(document.createElement(\"div\"));\n #text = this.#box.appendChild(document.createElement(\"span\"));\n #sizer?: HTMLDivElement;\n\n constructor(text?: string) {\n super();\n if (text) this.text = text;\n }\n\n set text(value: string) {\n this.#text.textContent = value;\n }\n\n sizable(sizeable: boolean, sizer: (width: number | undefined) => void) {\n if (sizeable) {\n this.#sizer = this.#box.appendChild(document.createElement(\"div\"));\n let double_timeout: number;\n this.#sizer.onpointerdown = (e) => {\n e.preventDefault();\n if (double_timeout) {\n sizer(undefined);\n return;\n }\n double_timeout = window.setTimeout(() => {\n double_timeout = 0;\n }, 300);\n this.setPointerCapture(e.pointerId);\n const start_x = e.pageX;\n const start_width = this.#box.offsetWidth;\n this.onpointermove = (ev: PointerEvent) => {\n sizer(px_to_rem(start_width + (ev.pageX - start_x)));\n };\n this.onpointerup = () => {\n this.releasePointerCapture(e.pointerId);\n this.onpointermove = null;\n this.onpointerup = null;\n };\n };\n } else if (this.#sizer) {\n this.#sizer.remove();\n this.#sizer = undefined;\n }\n }\n}\ndefine_element(HeaderField);\n\nclass HeaderRow<\n R,\n T extends {},\n A extends ListType<R>,\n S extends boolean,\n> extends Base {\n static element_name() {\n return \"headerrow\";\n }\n static element_name_space(): string {\n return \"list\";\n }\n\n set fields(fields: HeaderField[]) {\n if (this.#root.sub_rows) this.replaceChildren(text_field(), ...fields);\n else this.replaceChildren(...fields);\n }\n\n #root: ListRoot<R, T, A, S>;\n\n constructor(root: ListRoot<R, T, A, S>) {\n super();\n this.#root = root;\n }\n}\ndefine_element(HeaderRow);\n\ninterface ContainerOptions<S extends boolean = false> {\n /**Should header row be omitted */\n headless?: boolean;\n /**Can rows have sub rows */\n sub_rows?: S;\n /**Options for an add row button */\n add_row?: ListAddRowOptions;\n /**If list should use a container to give fields the option of attach/detach to states when visible */\n observer?: BaseIntersectObserver;\n}\n\nclass Container<\n A extends ListType<any>,\n T extends { [key: string]: ListColumnOptions<any, any> },\n S extends boolean = false,\n R = ListTypeExtract<A>,\n> extends Base {\n static element_name() {\n return \"container\";\n }\n static element_name_space() {\n return \"list\";\n }\n\n #root: ListRoot<R, T, A, S>;\n #parent: ListRowParent<A>;\n #box = this.appendChild(document.createElement(\"div\"));\n #header?: HeaderRow<R, T, A, S>;\n #child_box: HTMLDivElement;\n #add_row?: ListAddRow<R, T, A, S>;\n #state_sub?: StateInferSub<State<R[]>>;\n\n constructor(\n columns: { [K in keyof T]: ListColumnOptions<T[K], any> },\n transform: ListRowTransformer<R, T, A, S>,\n rows: A,\n options?: ContainerOptions<S>,\n ) {\n super();\n this.#root = {\n sub_rows: options?.sub_rows ?? (false as S),\n columns: new Map(),\n columns_visible: [],\n transform,\n observer: options?.observer,\n };\n this.#parent = {\n depth: -1,\n open: false,\n select_adjacent() {},\n state: rows,\n };\n\n if (!options?.headless)\n this.#header = this.#box.appendChild(new HeaderRow(this.#root));\n this.#child_box = this.#box.appendChild(document.createElement(\"div\"));\n if (options?.sub_rows) this.#box.classList.add(\"sub-rows\");\n this.add_row = options?.add_row;\n\n this.columns = columns;\n this.rows = rows;\n }\n\n set columns(columns: { [K in keyof T]: ListColumnOptions<T[K], any> }) {\n this.#root.columns.clear();\n const order = new Map<keyof T, number>();\n let index = 0;\n for (const key in columns) {\n //Copied, so resizing does not write into the callers options\n this.#root.columns.set(key, { ...columns[key as keyof T] });\n order.set(key, columns[key].order ?? index);\n index++;\n }\n this.#root.columns_visible = [...order.keys()].sort(\n (a, b) => order.get(a)! - order.get(b)!,\n );\n\n if (this.#header)\n this.#header.fields = this.#root.columns_visible.map((key) => {\n const column = this.#root.columns.get(key)!;\n const header = new HeaderField(column.title);\n header.sizable(typeof column.fixed_width === \"undefined\", (width) => {\n column.init_width = width;\n this.#update_column_widths();\n });\n return header;\n });\n this.#update_column_widths();\n\n for (let i = 0; i < this.#child_box.childElementCount; i++)\n (this.#child_box.children[i] as ListRow<R, T, A, S>).columns_changed();\n }\n\n #update_column_widths() {\n const widths: string[] = this.#root.columns_visible.map((key) => {\n const col = this.#root.columns.get(key)!;\n const width = col.fixed_width ?? col.init_width;\n if (width) {\n if (width === \"min\") return \"min-content\";\n else if (width === \"max\") return \"max-content\";\n return `${Math.max(width, 1)}rem`;\n }\n return \"auto\";\n });\n if (this.#root.sub_rows) widths.unshift(\"min-content\");\n this.#box.style.gridTemplateColumns = widths.join(\" \");\n }\n\n set add_row(options: ListAddRowOptions | undefined) {\n if (!options && this.#add_row) {\n this.#add_row.remove();\n this.#box.classList.remove(\"addrow\");\n this.#add_row = undefined;\n } else if (options) {\n if (!this.#add_row) {\n this.#box.classList.add(\"addrow\");\n this.#add_row = this.#box.appendChild(\n new ListAddRow<R, T, A, S>(this.#root, this.#parent),\n );\n }\n this.#add_row.options = options;\n }\n }\n\n // _____ ______ _______\n // | __ \\ / __ \\ \\ / / ____|\n // | |__) | | | \\ \\ /\\ / / (___\n // | _ /| | | |\\ \\/ \\/ / \\___ \\\n // | | \\ \\| |__| | \\ /\\ / ____) |\n // |_| \\_\\\\____/ \\/ \\/ |_____/\n\n amount_rows(rec: boolean = false): number {\n let count = this.#child_box.childElementCount;\n if (rec)\n for (let i = 0; i < this.#child_box.childElementCount; i++)\n count += (\n this.#child_box.children[i] as ListRow<R, T, A, S>\n ).amount_rows(true);\n return count;\n }\n\n set rows(rows: R[] | State<R[]>) {\n if (this.#state_sub) this.detach_state(this.#state_sub);\n this.#state_sub = undefined;\n this.#parent.state = rows as A;\n if (state.is.state(rows))\n this.#state_sub = this.attach_state(rows, (r) =>\n this.#update_rows(r.ok ? r.value : []),\n );\n else this.#update_rows(rows);\n }\n\n #update_rows(rows: readonly R[]) {\n state_ui.a.apply(this.#child_box, rows, {\n create: (row) => new ListRow<R, T, A, S>(this.#root, this.#parent, row),\n update: (element, row) => (element.data = row),\n });\n }\n}\ndefine_element(Container);\n\nexport function container<\n A extends ListType<any>,\n T extends {},\n S extends boolean = false,\n R = ListTypeExtract<A>,\n>(\n columns: { [K in keyof T]: ListColumnOptions<T[K], any> },\n transform: ListRowTransformer<R, NoInfer<T>, A, S>,\n rows: A,\n options?: ContainerOptions<S>,\n) {\n return new Container<A, T, S, R>(columns, transform, rows, options);\n}\n","import type { BaseIntersectObserver } from \"#base\";\nimport { type Option } from \"@chocbite/ts-lib/result\";\nimport type { State } from \"@chocbite/ts-lib/state\";\nimport list from \".\";\nimport type { ListField, ListTextField } from \"./field\";\nimport type { ListRow, ListRowOptions } from \"./row\";\n\nexport type ListType<R> = R[] | State<R[]>;\n\nexport type ListTypeExtract<A extends ListType<any>> = A extends (infer U)[]\n ? U\n : A extends State<(infer U)[]>\n ? U\n : never;\n\n/**Rows of a row parent, the top level rows or sub rows, which can be an array or a state regardless of the top level rows */\nexport type ListParentRows<A extends ListType<any>> =\n | A\n | ListType<ListTypeExtract<A>>;\n\nexport const ListDataType = {\n number: \"number\",\n string: \"string\",\n bool: \"bool\",\n} as const;\nexport type ListDataType = (typeof ListDataType)[keyof typeof ListDataType];\n\nexport interface ListColumnOptions<V, C extends ListField> {\n /**Initial width of the column in rem, auto when undefined*/\n init_width?: number;\n /**If the column has a fixed width in rem, overrides init_width and disables resizing*/\n fixed_width?: number | \"min\" | \"max\";\n /**Initial order of the column, lower numbers appear first, will order by column object if undefined\n * A column without order uses its position in the column object as order*/\n order?: number;\n /**Whether the column is reorderable by the user*/\n reorderable?: boolean;\n /**Data type of the column, used for sorting, will attempt auto detect if undefined*/\n type?: ListDataType;\n /**Column title*/\n title: string;\n /**Generates the field element, only called during row or column creation */\n field_gen(): C;\n /**Applies the value to the field */\n field_apply(field: C, value: V): void;\n}\n\n/**Helper to create a column object */\nexport function column<V, C extends ListField>(\n options: ListColumnOptions<V, C>,\n): ListColumnOptions<V, C> {\n return options;\n}\n\n/**Special helper to create a string value column */\nexport function column_string(\n /**Column title*/\n title: string,\n): ListColumnOptions<string, ListTextField> {\n return {\n title,\n field_gen: () => list.text_field(),\n field_apply: (field, value) => (field.text = value),\n };\n}\n\nexport type ListRowTransformer<\n R,\n T extends {},\n A extends ListType<any>,\n S extends boolean,\n> = (\n /**Data of the row */\n data: R,\n /**The row the options are for */\n row: ListRow<R, T, A, S>,\n /**Rows the data is from, sub rows can come from an array or a state regardless of the top level rows */\n state: S extends true ? A | ListType<R> : A,\n) => ListRowOptions<R, T, S>;\n\nexport interface ListRoot<\n R,\n T extends {},\n A extends ListType<any>,\n S extends boolean,\n> {\n /**Sub rows */\n readonly sub_rows: S;\n /**Columns options mapped by column key */\n readonly columns: Map<keyof T, ListColumnOptions<T[keyof T], ListField>>;\n /**Order of visible columns by column key */\n columns_visible: (keyof T)[];\n /**Function to transform a row data into row options */\n transform: ListRowTransformer<R, T, A, S>;\n /**Observer for the container if observer is active */\n observer?: BaseIntersectObserver;\n}\n\nexport interface ListRowParent<A extends ListType<any>> {\n /**Sub row depth */\n readonly depth: number;\n /**Whether the row is open to show sub rows */\n open: boolean;\n /**Selects the adjacent row in the given direction */\n select_adjacent(\n direction: \"next\" | \"previous\" | \"p_next\" | \"p_previous\" | \"last\",\n field: Option<number>,\n ): void;\n /**Rows of the parent, the rows of the container or the sub rows of a row */\n state: ListParentRows<A>;\n}\n","import { container } from \"./container\";\nimport { node_field, number_field, text_field } from \"./field\";\nimport { column, column_string } from \"./types\";\n\nexport const list = {\n column,\n column_string,\n container,\n text_field,\n number_field,\n node_field,\n};\n\nexport { ListField } from \"./field\";\n\nexport default list;\n"],"mappings":";;;;;;;;;;AAYA,IAAa,eAAb,cAA2D,KAAK;CAC9D,OAAO,eAAe;EACpB,OAAO;CACT;CACA,OAAO,qBAAqB;EAC1B,OAAO;CACT;CAEA;CACA;CACA;CAEA,YAAY,QAA0B;EACpC,MAAM;EACN,KAAK,WAAW;EAChB,KAAK,aAAa,MAAM;GACtB,IAAI,EAAE,QAAQ,WAAW,EAAE,QAAQ,KAAK,OAAO,OAAO,CAAC,OAAO;QACzD,IAAI,EAAE,QAAQ,cAAc,OAAO,OAAO;QAC1C,IAAI,EAAE,QAAQ,aAAa,OAAO,OAAO;QACzC,IAAI,EAAE,QAAQ,aAAa,OAAO,gBAAgB,QAAQ,KAAK,CAAC;QAChE,IAAI,EAAE,QAAQ,WAAW,OAAO,gBAAgB,YAAY,KAAK,CAAC;QAClE;GACL,EAAE,eAAe;EACnB;EAEA,MAAM,aAAa,SAAS,cAAc,MAAM;EAChD,KAAK,UAAU,WAAW,YAAY,SAAS,cAAc,KAAK,CAAC;EACnE,KAAK,gBACH,GAAG,kBAAkB,OAAO,QAAQ,MAAM;GACxC,MAAM,MAAM,SAAS,cAAc,KAAK;GACxC,IAAI,MAAM,cAAc,aAAa,IAAI;GACzC,OAAO;EACT,CAAC,GACD,UACF;EAEA,KAAK,QAAQ,iBAAiB,UAAU,MAAM;GAC5C,EAAE,gBAAgB;GAClB,EAAE,eAAe;GACjB,OAAO,OAAO,CAAC,OAAO;EACxB,CAAC;CACH;CA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7B;CAEA,aAAa,MAAoB;EAC/B,KAAK,UAAU,OAAO,QAAQ,KAAK,SAAS,CAAC;EAC7C,SAAS,EAAE,MAAM,KAAK,YAAY,MAAM;GACtC,SAAS,QAAQ,IAAI,QAAoB,KAAK,OAAO,MAAM,GAAG;GAC9D,SAAS,SAAS,QAAS,QAAQ,OAAO;EAC5C,CAAC;CACH;AACF;AACA,eAAe,OAAO;;AC1RtB,MAAM,aAAa,yBACjB,QACA,oBACA,sCACF;AAQkB,WAAW,eAC3B,QACA,aACA,8CAEM,CAAC,CAAC,cACR,UACA,oBACA,qDACA,gBACA,gBACA,UACA,KAAA,CACF;AAUA,MAAM,SAAS,WAAW,eACxB,UACA,UACA,kCACF;AAQA,MAAM,cAAc,OAAO,eACzB,QACA,eACA,uCACF;AACA,YAAY,cACV,UACA,qBACA,sCACA,KAAK,QACL,KAAK,OACL,SACA,KAAA,CACF;AACA,YAAY,cACV,SACA,oBACA,qCACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AACA,YAAY,cACV,aACA,6BACA,+CACA,KAAK,QACL,KAAK,OACL,SACA,KAAA,CACF;AACA,YAAY,cACV,OACA,wBACA,kCACA,KAAK,QACL,KAAK,OACL,SACA,KAAA,CACF;AAQA,MAAM,cAAc,OAAO,eACzB,QACA,eACA,uCACF;AACA,YAAY,cACV,cACA,6BACA,oCACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AACA,YAAY,cACV,YACA,wBACA,+BACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AACA,YAAY,cACV,YACA,sBACA,6BACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AAQA,MAAM,oBAAoB,OAAO,eAC/B,cACA,qBACA,6CACF;AACA,kBAAkB,cAChB,YACA,6BACA,yCACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AACA,kBAAkB,cAChB,WACA,4BACA,wCACA,KAAK,OACL,KAAK,QACL,SACA,KAAA,CACF;AACA,kBAAkB,cAChB,aACA,8BACA,kDACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AAQA,MAAM,gBAAgB,OAAO,eAC3B,UACA,iBACA,yCACF;AACA,cAAc,cACZ,UACA,uBACA,iCACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AACA,cAAc,cACZ,OACA,oBACA,iCACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AACA,cAAc,cACZ,UACA,uBACA,mCACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AAQqB,OAAO,eAC1B,SACA,gBACA,wCAES,CAAC,CAAC,cACX,UACA,eACA,kCACA,OAAO,QACP,OAAO,QACP,SACA,KAAA,CACF;AAUA,MAAM,QAAQ,WAAW,eACvB,QACA,QACA,iCACF;AAEA,MAAM,cACJ,WACA,sBACA,gCACA,UACA,UACA,UACA;CAAE,KAAK;CAAK,KAAK;AAAG,CACtB;AAEA,MAAM,cACJ,iBACA,4BACA,iDACA,UACA,UACA,UACA;CAAE,KAAK;CAAK,KAAK;AAAG,CACtB;AAEA,MAAM,cACJ,WACA,0BACA,qCACA,QACA,QACA,UACA;CAAE,KAAK;CAAK,KAAK;AAAG,CACtB;AAEA,MAAM,cACJ,iBACA,gCACA,sDACA,QACA,QACA,UACA;CAAE,KAAK;CAAK,KAAK;AAAG,CACtB;AAUA,MAAM,YAAY,WAAW,eAC3B,aACA,aACA,8CACF;AAEA,UAAU,cACR,kBACA,mBACA,sDACA,eACA,eACA,kBACA,KAAA,CACF;AAEA,UAAU,cACR,sBACA,uBACA,2DACA,SACA,SACA,QACA;CAAE,KAAK;CAAG,KAAK;AAAK,CACtB;AAUA,MAAM,OAAO,WAAW,eACtB,QACA,QACA,yCACF;AAEA,KAAK,cACH,QACA,aACA,+CACA,QACA,QACA,UACA;CAAE,KAAK;CAAK,KAAK;AAAG,CACtB;AAEA,KAAK,cACH,aACA,mBACA,yDACA,UACA,UACA,UACA;CAAE,KAAK;CAAK,KAAK;AAAG,CACtB;;AC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