@chocbite/ts-lib-ui 1.1.5 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/AGENTS.md +547 -9
  2. package/README.md +3 -0
  3. package/SOURCE.md +10313 -7355
  4. package/base/index.d.mts +2 -2
  5. package/base/index.mjs +68 -5
  6. package/base/index.mjs.map +1 -1
  7. package/canvas/index.d.mts +1 -1
  8. package/canvas/index.mjs +1 -1
  9. package/composition/index.d.mts +283 -0
  10. package/composition/index.mjs +2 -0
  11. package/composition-BlntkKR0.mjs +869 -0
  12. package/composition-BlntkKR0.mjs.map +1 -0
  13. package/context-menu/index.d.mts +1 -1
  14. package/context-menu/index.mjs +1 -1
  15. package/{context-menu-CZxEGjBi.mjs → context-menu-C0KTV5zC.mjs} +2 -2
  16. package/{context-menu-CZxEGjBi.mjs.map → context-menu-C0KTV5zC.mjs.map} +1 -1
  17. package/depot_ui/index.d.mts +60 -0
  18. package/depot_ui/index.mjs +280 -0
  19. package/depot_ui/index.mjs.map +1 -0
  20. package/form/index.d.mts +2 -758
  21. package/form/index.mjs +1 -2953
  22. package/form-CJA3s46n.mjs +2961 -0
  23. package/form-CJA3s46n.mjs.map +1 -0
  24. package/icons/index.d.mts +1 -1
  25. package/{index-YNZjMIO7.d.mts → index-CApVOEcI.d.mts} +2 -2
  26. package/{index-BDWg5GX2.d.mts → index-Czy8O3me.d.mts} +6 -2
  27. package/index-DD09-bGe.d.mts +761 -0
  28. package/{index-DlBJdGaQ.d.mts → index-U3pqQjLg.d.mts} +4 -4
  29. package/{index-CvzH3M_5.d.mts → index-_y7vmunA.d.mts} +72 -8
  30. package/keyboard/index.d.mts +1 -1
  31. package/keyboard/index.mjs +1 -1
  32. package/list/index.d.mts +1 -1
  33. package/list/index.mjs +1 -1
  34. package/{list-C52-ExFw.mjs → list-CVrn4y2k.mjs} +3 -3
  35. package/{list-C52-ExFw.mjs.map → list-CVrn4y2k.mjs.map} +1 -1
  36. package/package.json +2 -2
  37. package/prompts/index.d.mts +48 -0
  38. package/prompts/index.mjs +107 -0
  39. package/prompts/index.mjs.map +1 -0
  40. package/spinner/index.d.mts +1 -1
  41. package/spinner/index.mjs +1 -1
  42. package/style.css +2049 -1640
  43. package/svg/index.d.mts +1 -1
  44. package/svg-Yz7elqnU.mjs.map +1 -1
  45. package/theme/index.d.mts +1 -1
  46. package/theme/index.mjs +1 -1
  47. package/{theme-D3YluyYr.mjs → theme-D0pRMLyT.mjs} +2 -2
  48. package/{theme-D3YluyYr.mjs.map → theme-D0pRMLyT.mjs.map} +1 -1
  49. package/form/index.mjs.map +0 -1
  50. package/test/index.d.mts +0 -98
  51. package/test/index.mjs +0 -193
  52. package/test/index.mjs.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"composition-BlntkKR0.mjs","names":[],"sources":["../../package-ui/composition/shared.ts","../../package-ui/composition/content.ts","../../package-ui/composition/panel.ts","../../package-ui/composition/container.ts","../../package-ui/composition/customization.ts","../../package-ui/composition/topbar.ts","../../package-ui/composition/index.ts"],"sourcesContent":["import { GREY, ORANGE, RED } from \"@chocbite/ts-lib/colors\";\nimport { px_to_rem, theme_init_variable_root } from \"#theme\";\n\n/** Type to store a position related to composition\n * position is always in rem*/\nexport interface CompPosition {\n x: number;\n y: number;\n}\n\n/**A point of a box, like the corner of a panel that its position places*/\nexport const CompAnchor = {\n TOP_RIGHT: \"top_right\",\n TOP_LEFT: \"top_left\",\n BOT_RIGHT: \"bot_right\",\n BOT_LEFT: \"bot_left\",\n CENTER: \"center\",\n} as const;\nexport type CompAnchor = (typeof CompAnchor)[keyof typeof CompAnchor];\n\n/**Where the anchor is in a box, as parts of its width and height from the top left*/\nexport function anchor_fraction(anchor: CompAnchor): [number, number] {\n if (anchor === CompAnchor.CENTER) return [0.5, 0.5];\n const [f, l] = anchor.split(\"_\");\n return [l === \"left\" ? 0 : 1, f === \"top\" ? 0 : 1];\n}\n\n/**Position in rem of the anchor point of the element, from the top left of the page*/\nexport function get_element_anchor_position(\n element: Element,\n anchor: CompAnchor,\n): CompPosition {\n const rect = element.getBoundingClientRect();\n const [ax, ay] = anchor_fraction(anchor);\n return {\n x: px_to_rem(rect.left + rect.width * ax),\n y: px_to_rem(rect.top + rect.height * ay),\n };\n}\n\nconst theme_root = theme_init_variable_root(\n \"composition\",\n \"Composition\",\n \"Theme variables for page composition, panels and top bar\",\n);\n\n// _____ ____ _ ____ _____ _____\n// / ____/ __ \\| | / __ \\| __ \\ / ____|\n// | | | | | | | | | | | |__) | (___\n// | | | | | | | | | | | _ / \\___ \\\n// | |___| |__| | |___| |__| | | \\ \\ ____) |\n// \\_____\\____/|______\\____/|_| \\_\\_____/\nconst colors = theme_root.make_sub_group(\n \"colors\",\n \"Colors\",\n \"Colors used in all form elements\",\n);\n\ncolors.make_variable(\n \"titlebar\",\n \"Title Bar Background\",\n \"Background color for the title bar of UI panels\",\n GREY[500],\n GREY[800],\n \"Color\",\n undefined,\n);\n\ncolors.make_variable(\n \"titlebarHover\",\n \"Title Bar Hover Background\",\n \"Background color for the title bar of UI panels when hovered\",\n GREY[400],\n GREY[700],\n \"Color\",\n undefined,\n);\n\ncolors.make_variable(\n \"titlebarCloseHover\",\n \"Title Bar Close Hover Background\",\n \"Background color for the title bar close button of UI panels when hovered\",\n RED[400],\n RED[700],\n \"Color\",\n undefined,\n);\n\ncolors.make_variable(\n \"titlebarText\",\n \"Title Bar Text\",\n \"Text color for the title bar of UI panels\",\n GREY[900],\n GREY[50],\n \"Color\",\n undefined,\n);\n\ncolors.make_variable(\n \"background\",\n \"Content Background\",\n \"Default background color for content areas\",\n GREY[100],\n \"#000000\",\n \"Color\",\n undefined,\n);\n\ncolors.make_variable(\n \"icons\",\n \"Icons Color\",\n \"Default color for icons\",\n GREY[900],\n GREY[100],\n \"Color\",\n undefined,\n);\n\ncolors.make_variable(\n \"sizers\",\n \"Sizers\",\n \"Background color of the sizers of panels, shown in touch mode\",\n GREY[300],\n GREY[900],\n \"Color\",\n undefined,\n);\n\ncolors.make_variable(\n \"shadow\",\n \"Border Shadow\",\n \"Shadow color for borders and outlines\",\n \"#000000\",\n GREY[50],\n \"Color\",\n undefined,\n);\n\ncolors.make_variable(\n \"shadowFocus\",\n \"Border Shadow In Focus\",\n \"Shadow color for borders and outlines when in focus\",\n ORANGE[500],\n ORANGE[500],\n \"Color\",\n undefined,\n);\n","import {\n Base,\n CREATE,\n define_element,\n input_key,\n type InputOf,\n type InputOptions,\n} from \"#base\";\nimport ctm, { type ContextMenuGroup } from \"#context-menu\";\nimport type { SVGFunc } from \"#svg\";\nimport type { StateOrVal } from \"@chocbite/ts-lib/state\";\nimport \"./content.scss\";\nimport \"./shared\";\n\n/**Inputs of content that can be set again*/\nconst CONTENT = {\n /**Context menu of the content, also shown by its container, like on the title bar of a panel\n * Lines, a menu, or a function giving them, which is called every time the menu opens*/\n context_menu: input_key<ContextMenuGroup>(),\n};\nexport type ContentOptions = InputOptions<typeof CONTENT>;\n\n/**Inputs of content given at creation, the container showing the content follows them\n * Exported for the containers of this module, not from the module*/\nexport const CONTENT_CREATE = {\n /**Title the container shows, like on the title bar of a panel*/\n title: input_key<StateOrVal<string>>(),\n /**Icon the container shows in front of the title*/\n icon: input_key<StateOrVal<SVGFunc | undefined>>(),\n /**Whether the container lets the user close the content*/\n closable: input_key<StateOrVal<boolean>>(),\n /**Smallest width in rem the container gives the content*/\n min_width: input_key<StateOrVal<number>>(),\n /**Smallest height in rem the container gives the content*/\n min_height: input_key<StateOrVal<number>>(),\n};\nexport type ContentCreateOptions = ContentOptions &\n InputOptions<typeof CONTENT_CREATE>;\n\n/**Called by the container when it closes the content, internal to this module*/\nexport const CONTENT_CLOSED = Symbol(\"content_closed\");\n\n/**The context menu of content as it is right now, for ctm.combine, internal to this module*/\nexport function content_context_lines(content: ContentBase) {\n const group = content.content_context_menu;\n return typeof group === \"function\" ? group() : (group ?? []);\n}\n\n/**Base for anything shown in a container of this module, like a panel\n *\n * Library users extend it for their own content, and create it with MyContent.create(options),\n * the title, icon, closable and minimum size are given at creation, as the container follows them\n * To follow its own size, content attaches to the resize observer of Base and overrides on_resize*/\nexport abstract class ContentBase extends Base {\n static element_name() {\n return \"@abstract@\";\n }\n static element_name_space() {\n return \"@abstract@\";\n }\n\n #title: InputOf<typeof CONTENT_CREATE.title> = \"\";\n #icon: InputOf<typeof CONTENT_CREATE.icon> = undefined;\n #closable: InputOf<typeof CONTENT_CREATE.closable> = false;\n #min_width: InputOf<typeof CONTENT_CREATE.min_width> = 0;\n #min_height: InputOf<typeof CONTENT_CREATE.min_height> = 0;\n #context_menu: ContextMenuGroup = undefined;\n #on_close: (() => void)[] = [];\n\n constructor() {\n super();\n this.tabIndex = -1;\n this.classList.add(\"content\");\n ctm.attach(\n this,\n ctm.combine(() => content_context_lines(this)),\n );\n }\n\n /**Title the container shows, given at creation and never replaced*/\n get content_title(): InputOf<typeof CONTENT_CREATE.title> {\n return this.#title;\n }\n /**Icon the container shows, given at creation and never replaced*/\n get content_icon(): InputOf<typeof CONTENT_CREATE.icon> {\n return this.#icon;\n }\n /**Whether the container lets the user close the content, given at creation and never replaced*/\n get content_closable(): InputOf<typeof CONTENT_CREATE.closable> {\n return this.#closable;\n }\n /**Smallest width in rem, given at creation and never replaced*/\n get content_min_width(): InputOf<typeof CONTENT_CREATE.min_width> {\n return this.#min_width;\n }\n /**Smallest height in rem, given at creation and never replaced*/\n get content_min_height(): InputOf<typeof CONTENT_CREATE.min_height> {\n return this.#min_height;\n }\n /**Context menu of the content, read by the container every time its menu opens*/\n get content_context_menu(): ContextMenuGroup {\n return this.#context_menu;\n }\n\n [CREATE](options: ContentCreateOptions): void {\n super[CREATE](options);\n if (options.title !== undefined) this.#title = options.title;\n if (options.icon !== undefined) this.#icon = options.icon;\n if (options.closable !== undefined) this.#closable = options.closable;\n if (options.min_width !== undefined) this.#min_width = options.min_width;\n if (options.min_height !== undefined) this.#min_height = options.min_height;\n }\n\n set(options: ContentOptions): this {\n this.set_input(CONTENT.context_menu, options.context_menu, (menu) => {\n this.#context_menu = menu.value;\n });\n return this;\n }\n\n /**Resolves when the content is closed, by itself or by its container*/\n content_on_close(): Promise<void> {\n return new Promise<void>((resolve) => this.#on_close.push(resolve));\n }\n\n /**Closes the content, its container closes with it*/\n content_close(): void {\n this[CONTENT_CLOSED]();\n this.dispatchEvent(new CustomEvent(\"content_closed\", { bubbles: true }));\n }\n\n /**Resolves the waiting content_on_close promises, called by the container that closes the content*/\n [CONTENT_CLOSED](): void {\n for (const resolve of this.#on_close.splice(0)) resolve();\n }\n}\n\n/**Content without behavior of its own, filled with children by the user*/\nclass Content extends ContentBase {\n static element_name() {\n return \"content\";\n }\n static element_name_space() {\n return \"composition\";\n }\n}\ndefine_element(Content);\n\nexport type { Content };\n\n/**Content to fill with children, the title, icon, closable and minimum size are given here, the container follows them*/\nexport function content(options: ContentCreateOptions = {}): Content {\n return Content.create(options);\n}\n","import {\n Base,\n CREATE,\n define_element,\n input_key,\n type InputOf,\n type InputOptions,\n} from \"#base\";\nimport ctm from \"#context-menu\";\nimport type { SVGFunc } from \"#svg\";\nimport { px_to_rem } from \"#theme\";\nimport type { StateOrVal, StateOrValROSW } from \"@chocbite/ts-lib/state\";\nimport {\n CONTENT_CLOSED,\n CONTENT_CREATE,\n content_context_lines,\n type ContentBase,\n} from \"./content\";\nimport \"./panel.scss\";\nimport { anchor_fraction, CompAnchor } from \"./shared\";\n\n/**Inputs of the panel*/\nconst PANEL = {\n /**Layer of the panel, panels in a higher layer are always above panels in a lower one*/\n layer: input_key<StateOrVal<number>>(),\n /**Horizontal position in rem from the left of the page, of the anchor point of the panel\n * Not given the panel starts centered, a fixed value can not be moved by the user, a writable state is written when the user moves the panel*/\n x: input_key<StateOrValROSW<number>>(),\n /**Vertical position in rem from the top of the page, of the anchor point of the panel, works like x*/\n y: input_key<StateOrValROSW<number>>(),\n /**Point of the panel that x and y place, top_left by default*/\n anchor: input_key<StateOrVal<CompAnchor>>(),\n /**Width in rem, not given the panel fits its content\n * A fixed value can not be sized by the user, a writable state is written when the user sizes the panel*/\n width: input_key<StateOrValROSW<number>>(),\n /**Height in rem, works like width*/\n height: input_key<StateOrValROSW<number>>(),\n /**Whether the user can size the panel, at the sides where width and height can be written, true by default*/\n sizeable: input_key<StateOrVal<boolean>>(),\n /**Whether the panel is hidden, auto_hide writes it, so give a writable state to show the panel again*/\n hidden: input_key<StateOrValROSW<boolean>>(),\n /**Hides the panel when the user presses outside it*/\n auto_hide: input_key<StateOrVal<boolean>>(),\n /**Closes the panel when the user presses outside it*/\n auto_close: input_key<StateOrVal<boolean>>(),\n /**Darkens the page behind the panel and keeps the focus in it*/\n modal: input_key<StateOrVal<boolean>>(),\n /**Whether the title bar is shown, true by default*/\n titlebar: input_key<StateOrVal<boolean>>(),\n};\nexport type PanelOptions = InputOptions<typeof PANEL>;\n\n/**Inputs of the content the panel follows, inner inputs that are not options*/\nconst PANEL_CONTENT = {\n title: input_key<InputOf<typeof CONTENT_CREATE.title>>(),\n icon: input_key<InputOf<typeof CONTENT_CREATE.icon>>(),\n closable: input_key<InputOf<typeof CONTENT_CREATE.closable>>(),\n min_width: input_key<InputOf<typeof CONTENT_CREATE.min_width>>(),\n min_height: input_key<InputOf<typeof CONTENT_CREATE.min_height>>(),\n};\n\n/**Smallest size of a panel in rem*/\nconst MIN_SIZE = 4;\n/**How much of the panel is kept inside the container, at the top in rem, at the sides as part of its width*/\nconst KEEP_TOP = 2;\nconst KEEP_SIDE = 0.5;\n\n//Internal to this module, between the panel and its container\nexport const PANEL_ADDED = Symbol(\"panel_added\");\nexport const PANEL_LAYOUT = Symbol(\"panel_layout\");\nexport const HOST_LAYER = Symbol(\"host_layer\");\nexport const HOST_RAISE = Symbol(\"host_raise\");\nexport const HOST_REMOVE = Symbol(\"host_remove\");\n\n/**The container of a panel, as the panel sees it*/\nexport interface PanelHost {\n /**Width in rem*/\n readonly width: number;\n /**Height in rem*/\n readonly height: number;\n /**Moves the panel into the given layer*/\n [HOST_LAYER](panel: Panel, layer: number): void;\n /**Puts the panel above the others in its layer*/\n [HOST_RAISE](panel: Panel): void;\n /**Forgets the panel, it is closed*/\n [HOST_REMOVE](panel: Panel): void;\n}\n\n/**Values of the inputs the user can change by moving, sizing or hiding the panel*/\ninterface ChangeableValues {\n x?: number;\n y?: number;\n width?: number;\n height?: number;\n hidden: boolean;\n}\ntype Changeable = keyof ChangeableValues;\n\nconst clamp = (value: number, min: number, max: number) =>\n Math.max(min, Math.min(value, max));\n\nclass Panel extends Base {\n static element_name() {\n return \"panel\";\n }\n static element_name_space() {\n return \"composition\";\n }\n\n #host?: PanelHost;\n #content!: ContentBase;\n\n #sizer = this.appendChild(document.createElement(\"div\"));\n #titlebar = this.appendChild(document.createElement(\"div\"));\n #icon?: HTMLDivElement;\n #title = this.#titlebar.appendChild(document.createElement(\"div\"));\n #close_button?: HTMLSpanElement;\n #content_box = this.appendChild(document.createElement(\"div\"));\n #focus_catcher?: HTMLDivElement;\n\n #layer = 0;\n #anchor: CompAnchor = CompAnchor.TOP_LEFT;\n #sizeable = true;\n #auto_hide = false;\n #auto_close = false;\n #min_width = 0;\n #min_height = 0;\n /**Values of the changeable inputs, the panel owns them until they are given*/\n #values: ChangeableValues = { hidden: false };\n #given = new Set<Changeable>();\n /**Position shown last, in rem, the start of moving and sizing*/\n #left = 0;\n #top = 0;\n #moving = false;\n #on_close: (() => void)[] = [];\n\n constructor() {\n super();\n this.tabIndex = 0;\n this.attach_to_resize_observer();\n this.addEventListener(\"focus\", () => this.#content.focus());\n this.addEventListener(\"focusin\", () => this.#host?.[HOST_RAISE](this));\n this.addEventListener(\"content_closed\", (e) => {\n e.stopPropagation();\n this.close();\n });\n\n this.#titlebar.tabIndex = 0;\n this.#title.classList.add(\"title\");\n ctm.attach(\n this.#titlebar,\n ctm.combine(() => content_context_lines(this.#content)),\n () => this.#moving,\n );\n this.#titlebar.onpointerdown = (e) => this.#move_start(e);\n this.#titlebar.onkeydown = (e) => this.#move_key(e);\n\n for (const side of [\"n\", \"s\", \"e\", \"w\", \"ne\", \"nw\", \"se\", \"sw\"]) {\n const handle = this.#sizer.appendChild(document.createElement(\"div\"));\n handle.classList.add(side);\n if (side.length === 1)\n handle.appendChild(document.createElement(\"div\")).textContent =\n \"\\ue25d\";\n handle.onpointerdown = (e) => this.#size_start(e, handle, side);\n }\n }\n\n [CREATE](options: { content: ContentBase }): void {\n super[CREATE](options);\n const content = (this.#content = options.content);\n this.#content_box.appendChild(content);\n this.set_input(PANEL_CONTENT.icon, content.content_icon, (icon) =>\n this.#set_icon(icon.ok ? icon.value : undefined),\n );\n this.set_input(PANEL_CONTENT.title, content.content_title, (title) => {\n this.#title.textContent = title.ok ? title.value : \"⚠ \" + title.error;\n });\n this.set_input(PANEL_CONTENT.closable, content.content_closable, (c) =>\n this.#set_closable(c.ok && c.value),\n );\n this.set_input(PANEL_CONTENT.min_width, content.content_min_width, (w) => {\n this.#min_width = w.ok ? w.value : 0;\n this.#layout();\n });\n this.set_input(\n PANEL_CONTENT.min_height,\n content.content_min_height,\n (h) => {\n this.#min_height = h.ok ? h.value : 0;\n this.#layout();\n },\n );\n }\n\n set(options: PanelOptions): this {\n this.set_input(PANEL.layer, options.layer, (layer) => {\n this.#layer = layer.ok ? layer.value : 0;\n this.#host?.[HOST_LAYER](this, this.#layer);\n });\n this.set_input(PANEL.anchor, options.anchor, (anchor) => {\n this.#anchor = anchor.ok ? anchor.value : CompAnchor.TOP_LEFT;\n this.#layout();\n });\n for (const name of [\"x\", \"y\", \"width\", \"height\"] as const) {\n if (options[name] !== undefined) this.#given.add(name);\n this.set_input(PANEL[name], options[name], (value) => {\n this.#values[name] = value.value;\n this.#layout();\n });\n }\n if (options.hidden !== undefined) this.#given.add(\"hidden\");\n this.set_input(PANEL.hidden, options.hidden, (hidden) => {\n this.#values.hidden = hidden.value;\n this.classList.toggle(\"hidden\", hidden.value);\n this.#layout();\n });\n this.set_input(PANEL.sizeable, options.sizeable, (sizeable) => {\n this.#sizeable = sizeable.ok && sizeable.value;\n this.#layout();\n });\n this.set_input(PANEL.auto_hide, options.auto_hide, (auto_hide) => {\n this.#auto_hide = auto_hide.ok && auto_hide.value;\n });\n this.set_input(PANEL.auto_close, options.auto_close, (auto_close) => {\n this.#auto_close = auto_close.ok && auto_close.value;\n });\n this.set_input(PANEL.modal, options.modal, (modal) =>\n this.#set_modal(modal.ok && modal.value),\n );\n this.set_input(PANEL.titlebar, options.titlebar, (titlebar) => {\n this.classList.toggle(\"no-titlebar\", !(titlebar.ok && titlebar.value));\n this.#layout();\n });\n return this;\n }\n\n /**Content the panel shows, given when the panel is created*/\n get content(): ContentBase {\n return this.#content;\n }\n\n /**Resolves when the panel is closed*/\n on_close(): Promise<void> {\n return new Promise<void>((resolve) => this.#on_close.push(resolve));\n }\n\n /**Closes the panel and its content*/\n close(): void {\n this.ownerDocument.removeEventListener(\"pointerdown\", this.#outside, {\n capture: true,\n });\n this.#host?.[HOST_REMOVE](this);\n this.#host = undefined;\n this.remove();\n this.#content[CONTENT_CLOSED]();\n for (const resolve of this.#on_close.splice(0)) resolve();\n }\n\n /**Called by the container that shows the panel, once, after creating it*/\n [PANEL_ADDED](host: PanelHost): void {\n this.#host = host;\n host[HOST_LAYER](this, this.#layer);\n host[HOST_RAISE](this);\n this.ownerDocument.addEventListener(\"pointerdown\", this.#outside, {\n capture: true,\n passive: true,\n });\n this.#layout();\n }\n\n /**Called by the container when its size changes*/\n [PANEL_LAYOUT](): void {\n this.#layout();\n }\n\n protected on_resize(): void {\n this.#layout();\n }\n\n // _____ _ _ _ _ _____ ______\n // / ____| | | | /\\ | \\ | |/ ____| ____|\n // | | | |__| | / \\ | \\| | | __| |__\n // | | | __ | / /\\ \\ | . ` | | |_ | __|\n // | |____| | | |/ ____ \\| |\\ | |__| | |____\n // \\_____|_| |_/_/ \\_\\_| \\_|\\_____|______|\n /**Whether the user can change the input, when the panel owns it or it is a writable state*/\n #can_change(name: Changeable): boolean {\n return !this.#given.has(name) || this.#state_of(name) !== undefined;\n }\n\n /**The writable state the input has, undefined for a fixed value or one never given*/\n #state_of(name: Changeable) {\n return this.input_state<StateOrValROSW<number | boolean>>(PANEL[name]);\n }\n\n /**Writes a change by the user, to the state of the input, or to the panel when it owns the input*/\n #change<N extends Changeable>(\n name: N,\n value: NonNullable<ChangeableValues[N]>,\n ): void {\n const state = this.#state_of(name);\n if (state) void state.write(value);\n else if (!this.#given.has(name)) {\n this.#values[name] = value;\n if (name === \"hidden\") this.classList.toggle(\"hidden\", value === true);\n this.#layout();\n }\n }\n\n #outside = (e: Event) => {\n if (this.#values.hidden) return;\n if (this.contains(e.target as Node) && e.target !== this) return;\n if (this.#auto_close) this.close();\n else if (this.#auto_hide) this.#change(\"hidden\", true);\n };\n\n // _ __ ______ _ _ _______\n // | | /\\\\ \\ / / __ \\| | | |__ __|\n // | | / \\\\ \\_/ / | | | | | | | |\n // | | / /\\ \\\\ /| | | | | | | | |\n // | |____ / ____ \\| | | |__| | |__| | | |\n // |______/_/ \\_\\_| \\____/ \\____/ |_|\n /**Left edge shown for the given one, keeping part of the panel inside the container*/\n #clamp_left(left: number, width: number): number {\n const keep = width * KEEP_SIDE;\n return clamp(left, -keep, this.#host!.width - keep);\n }\n /**Top edge shown for the given one, keeping the title bar inside the container*/\n #clamp_top(top: number): number {\n return clamp(top, 0, Math.max(0, this.#host!.height - KEEP_TOP));\n }\n\n /**Applies size and position, the position is only clamped for showing, the inputs keep their values*/\n #layout(): void {\n if (!this.#host || !this.isConnected) return;\n const { width, height } = this.#values;\n this.style.width = width === undefined ? \"\" : width + \"rem\";\n this.style.height = height === undefined ? \"\" : height + \"rem\";\n this.style.minWidth = Math.max(MIN_SIZE, this.#min_width) + \"rem\";\n this.style.minHeight = `calc(${Math.max(MIN_SIZE, this.#min_height)}rem + var(--titlebar-height))`;\n this.#sizer.classList.toggle(\n \"x\",\n this.#sizeable && this.#can_change(\"width\"),\n );\n this.#sizer.classList.toggle(\n \"y\",\n this.#sizeable && this.#can_change(\"height\"),\n );\n this.classList.toggle(\"size-x\", this.#sizer.classList.contains(\"x\"));\n this.classList.toggle(\"size-y\", this.#sizer.classList.contains(\"y\"));\n if (this.#values.hidden) return;\n\n const rect = this.getBoundingClientRect();\n const w = px_to_rem(rect.width);\n const h = px_to_rem(rect.height);\n const [ax, ay] = anchor_fraction(this.#anchor);\n const { x, y } = this.#values;\n this.#left = this.#clamp_left(\n x === undefined ? (this.#host.width - w) / 2 : x - w * ax,\n w,\n );\n this.#top = this.#clamp_top(\n y === undefined ? (this.#host.height - h) / 2 : y - h * ay,\n );\n this.style.left = this.#left + \"rem\";\n this.style.top = this.#top + \"rem\";\n }\n\n // __ __ ______ _______ _ _ _____\n // | \\/ |/ __ \\ \\ / /_ _| \\ | |/ ____|\n // | \\ / | | | \\ \\ / / | | | \\| | | __\n // | |\\/| | | | |\\ \\/ / | | | . ` | | |_ |\n // | | | | |__| | \\ / _| |_| |\\ | |__| |\n // |_| |_|\\____/ \\/ |_____|_| \\_|\\_____|\n /**Moves the panel so its top left corner is at the given position, clamped, on the axes the user can change*/\n #move_to(left: number, top: number): void {\n const rect = this.getBoundingClientRect();\n const w = px_to_rem(rect.width);\n const h = px_to_rem(rect.height);\n const [ax, ay] = anchor_fraction(this.#anchor);\n if (this.#can_change(\"x\"))\n this.#change(\"x\", this.#clamp_left(left, w) + w * ax);\n if (this.#can_change(\"y\")) this.#change(\"y\", this.#clamp_top(top) + h * ay);\n }\n\n #move_start(e: PointerEvent): void {\n if (e.button !== 0) return;\n if (!this.#can_change(\"x\") && !this.#can_change(\"y\")) return;\n const titlebar = this.#titlebar;\n titlebar.setPointerCapture(e.pointerId);\n titlebar.classList.add(\"moving\");\n this.#moving = true;\n const left = this.#left;\n const top = this.#top;\n titlebar.onpointermove = (ev) =>\n this.#move_to(\n left + px_to_rem(ev.clientX - e.clientX),\n top + px_to_rem(ev.clientY - e.clientY),\n );\n titlebar.onpointerup = (ev) => {\n titlebar.releasePointerCapture(ev.pointerId);\n titlebar.classList.remove(\"moving\");\n this.#moving = false;\n titlebar.onpointermove = null;\n titlebar.onpointerup = null;\n };\n }\n\n #move_key(e: KeyboardEvent): void {\n const step = e.shiftKey ? 5 : e.ctrlKey ? 0.1 : 1;\n const [dx, dy] =\n {\n ArrowLeft: [-step, 0],\n ArrowRight: [step, 0],\n ArrowUp: [0, -step],\n ArrowDown: [0, step],\n }[e.key] ?? [];\n if (dx === undefined || dy === undefined) return;\n e.preventDefault();\n e.stopPropagation();\n this.#move_to(this.#left + dx, this.#top + dy);\n }\n\n // _____ _____ ___________ _ _ _____\n // / ____|_ _|___ /_ _| \\ | |/ ____|\n // | (___ | | / / | | | \\| | | __\n // \\___ \\ | | / / | | | . ` | | |_ |\n // ____) |_| |_ / /__ _| |_| |\\ | |__| |\n // |_____/|_____/_____|_____|_| \\_|\\_____|\n /**Sizes the panel from one side or corner, the opposite side stays where it is when x and y can be written*/\n #size_start(e: PointerEvent, handle: HTMLDivElement, side: string): void {\n if (e.button !== 0) return;\n e.stopPropagation();\n const host = this.#host;\n if (!host) return;\n handle.setPointerCapture(e.pointerId);\n const rect = this.getBoundingClientRect();\n const w0 = px_to_rem(rect.width);\n const h0 = px_to_rem(rect.height);\n const left0 = this.#left;\n const top0 = this.#top;\n const [ax, ay] = anchor_fraction(this.#anchor);\n const min_w = Math.max(MIN_SIZE, this.#min_width);\n const min_h =\n Math.max(MIN_SIZE, this.#min_height) +\n px_to_rem(this.#titlebar.getBoundingClientRect().height);\n const horizontal = this.#sizer.classList.contains(\"x\");\n const vertical = this.#sizer.classList.contains(\"y\");\n handle.onpointermove = (ev) => {\n const dx = px_to_rem(ev.clientX - e.clientX);\n const dy = px_to_rem(ev.clientY - e.clientY);\n if (horizontal && (side.includes(\"e\") || side.includes(\"w\"))) {\n const east = side.includes(\"e\");\n const w = clamp(east ? w0 + dx : w0 - dx, min_w, host.width);\n this.#change(\"width\", w);\n if (this.#can_change(\"x\"))\n this.#change(\"x\", (east ? left0 : left0 + w0 - w) + w * ax);\n }\n if (vertical && (side.includes(\"n\") || side.includes(\"s\"))) {\n const south = side.includes(\"s\");\n const h = clamp(south ? h0 + dy : h0 - dy, min_h, host.height);\n this.#change(\"height\", h);\n if (this.#can_change(\"y\"))\n this.#change(\"y\", (south ? top0 : top0 + h0 - h) + h * ay);\n }\n };\n handle.onpointerup = (ev) => {\n handle.releasePointerCapture(ev.pointerId);\n handle.onpointermove = null;\n handle.onpointerup = null;\n this.#titlebar.focus();\n };\n }\n\n // _____ _____ ______ _____ _____ ____ _____ _____ ______ _____\n // /\\ / ____/ ____| ____|/ ____/ ____|/ __ \\| __ \\|_ _| ____|/ ____|\n // / \\ | | | | | |__ | (___| (___ | | | | |__) | | | | |__ | (___\n // / /\\ \\| | | | | __| \\___ \\\\___ \\| | | | _ / | | | __| \\___ \\\n // / ____ \\ |___| |____| |____ ____) |___) | |__| | | \\ \\ _| |_| |____ ____) |\n // /_/ \\_\\_____\\_____|______|_____/_____/ \\____/|_| \\_\\_____|______|_____/\n #set_icon(icon?: SVGFunc): void {\n if (icon) {\n this.#icon ??= this.#titlebar.insertBefore(\n document.createElement(\"div\"),\n this.#title,\n );\n this.#icon.classList.add(\"icon\");\n this.#icon.replaceChildren(icon());\n } else {\n this.#icon?.remove();\n this.#icon = undefined;\n }\n }\n\n #set_closable(closable: boolean): void {\n if (closable && !this.#close_button) {\n const button = (this.#close_button = this.#titlebar.appendChild(\n document.createElement(\"span\"),\n ));\n button.classList.add(\"close-button\");\n button.textContent = \"×\";\n button.onpointerdown = (e) => {\n e.preventDefault();\n e.stopPropagation();\n button.setPointerCapture(e.pointerId);\n button.onpointerup = (e) => {\n button.releasePointerCapture(e.pointerId);\n button.onpointerup = null;\n const rect = button.getBoundingClientRect();\n if (\n e.clientX >= rect.left &&\n e.clientX <= rect.right &&\n e.clientY >= rect.top &&\n e.clientY <= rect.bottom\n )\n this.close();\n };\n };\n button.oncontextmenu = (e) => {\n e.preventDefault();\n e.stopPropagation();\n };\n button.ontouchend = (e) => {\n if (e.cancelable) e.preventDefault();\n e.stopPropagation();\n };\n } else if (!closable && this.#close_button) {\n this.#close_button.remove();\n this.#close_button = undefined;\n }\n }\n\n #set_modal(modal: boolean): void {\n this.classList.toggle(\"modal\", modal);\n if (modal && !this.#focus_catcher) {\n //Tabbing past the end of the panel comes back to its content\n this.#focus_catcher = this.appendChild(document.createElement(\"div\"));\n this.#focus_catcher.tabIndex = 0;\n this.#focus_catcher.onfocus = () => this.#content.focus();\n } else if (!modal && this.#focus_catcher) {\n this.#focus_catcher.remove();\n this.#focus_catcher = undefined;\n }\n }\n}\ndefine_element(Panel);\n\nexport { Panel };\n","import { Base, define_element, input_key } from \"#base\";\nimport { DOCUMENT_HANDLER } from \"#document\";\nimport { px_to_rem, SCALE } from \"#theme\";\nimport type { StateOrValROS } from \"@chocbite/ts-lib/state\";\nimport type { ContentBase } from \"./content\";\nimport \"./container.scss\";\nimport {\n HOST_LAYER,\n HOST_RAISE,\n HOST_REMOVE,\n Panel,\n PANEL_ADDED,\n PANEL_LAYOUT,\n type PanelHost,\n type PanelOptions,\n} from \"./panel\";\n\n/**Internal input, the scale changes the size of the container in rem*/\nconst SCALE_KEY = input_key<StateOrValROS<number>>();\n\n/**Layer over the whole page that panels float in, one per document*/\nclass PanelContainer extends Base implements PanelHost {\n static element_name() {\n return \"panelcontainer\";\n }\n static element_name_space() {\n return \"composition\";\n }\n\n #layers = new Map<number, HTMLDivElement>();\n #panels = new Set<Panel>();\n #raised = 0;\n #active?: Panel;\n\n constructor() {\n super();\n this.attach_to_resize_observer();\n this.set_input(SCALE_KEY, SCALE, () => this.#layout());\n }\n\n /**Width in rem*/\n get width(): number {\n return px_to_rem(this.actual_size.width);\n }\n /**Height in rem*/\n get height(): number {\n return px_to_rem(this.actual_size.height);\n }\n /**Panel the user worked in last*/\n get active_panel(): Panel | undefined {\n return this.#active;\n }\n\n /**Creates a panel showing the content in this container\n * The title, icon, close button and minimum size come from the content, see content*/\n panel(content: ContentBase, options: PanelOptions = {}): Panel {\n const panel = Panel.create({ ...options, content });\n this.#panels.add(panel);\n panel[PANEL_ADDED](this);\n return panel;\n }\n\n protected on_resize(): void {\n this.#layout();\n }\n\n #layout(): void {\n for (const panel of this.#panels) panel[PANEL_LAYOUT]();\n }\n\n [HOST_LAYER](panel: Panel, layer: number): void {\n let box = this.#layers.get(layer);\n if (!box) {\n box = document.createElement(\"div\");\n box.style.zIndex = String(layer);\n this.#layers.set(layer, box);\n //Layers in order, so the DOM order matches what is shown\n const above = [...this.#layers].filter(([l]) => l > layer);\n const next = above.sort(([a], [b]) => a - b)[0]?.[1];\n this.insertBefore(box, next ?? null);\n }\n //Moving an element reconnects it, which applies its states again\n if (panel.parentElement !== box) box.appendChild(panel);\n }\n\n [HOST_RAISE](panel: Panel): void {\n this.#active = panel;\n panel.style.zIndex = String(++this.#raised);\n }\n\n [HOST_REMOVE](panel: Panel): void {\n this.#panels.delete(panel);\n if (this.#active === panel) this.#active = undefined;\n }\n}\ndefine_element(PanelContainer);\n\nexport type { PanelContainer };\n\nconst CONTAINERS = new WeakMap<Document, PanelContainer>();\nDOCUMENT_HANDLER.events.on(\"removed\", (e) => {\n CONTAINERS.get(e.data)?.remove();\n CONTAINERS.delete(e.data);\n});\n\n/**The panel container of the document the given node is in, the main document by default\n * The container is made the first time it is asked for*/\nexport function panel_container(\n owner: Node = DOCUMENT_HANDLER.main,\n): PanelContainer {\n const doc = owner.ownerDocument ?? (owner as Document);\n let container = CONTAINERS.get(doc);\n if (!container) {\n container = PanelContainer.create();\n doc.documentElement.appendChild(container);\n CONTAINERS.set(doc, container);\n }\n return container;\n}\n\n/**Creates a panel showing the content, in the main document\n * Use panel_container(element).panel for another document*/\nexport function panel(content: ContentBase, options: PanelOptions = {}): Panel {\n return panel_container().panel(content, options);\n}\n","import { define_element, input_key, type InputOptions } from \"#base\";\nimport { DOCUMENT_HANDLER } from \"#document\";\nimport form, { type FormElement } from \"#form\";\nimport { material_brightness_medium_rounded } from \"#icons\";\nimport {\n ANIMATION_LEVEL,\n ANIMATION_SPEED,\n INPUT_MODE,\n SCALE,\n THEME,\n} from \"#theme\";\nimport state, { type StateOrVal, type StateROSW } from \"@chocbite/ts-lib/state\";\nimport { panel_container } from \"./container\";\nimport {\n ContentBase,\n type ContentCreateOptions,\n type ContentOptions,\n} from \"./content\";\nimport type { Panel } from \"./panel\";\nimport { get_element_anchor_position, type CompAnchor } from \"./shared\";\n\n/**Inputs of the customization*/\nconst CUSTOMIZATION = {\n /**Settings of the app, shown under the theme*/\n main: input_key<StateOrVal<readonly FormElement[]>>(),\n /**Advanced settings of the app, shown last in the advanced section*/\n advanced: input_key<StateOrVal<readonly FormElement[]>>(),\n};\nexport type CustomizationOptions = ContentOptions &\n InputOptions<typeof CUSTOMIZATION>;\nexport type CustomizationCreateOptions = ContentCreateOptions &\n CustomizationOptions;\n\n/**Content with the settings of the library, theme, scale, input mode and animations, and settings of the app*/\nclass Customization extends ContentBase {\n static element_name() {\n return \"customization\";\n }\n static element_name_space() {\n return \"composition\";\n }\n\n #main = form.group({ embed: true });\n #advanced = form.group({ embed: true });\n\n constructor() {\n super();\n this.appendChild(\n form.group({\n elements: [\n form.toggle_button().bind({ value: THEME }),\n this.#main,\n form.group_collapser(\n form.group({\n embed: true,\n elements: [\n form.text({ text: \"UI Scale\" }),\n form.stepper().bind({ value: SCALE }),\n form.text({ text: \"Input Mode\" }),\n form.toggle_button().bind({ value: INPUT_MODE }),\n form.text({ text: \"Animation Level\" }),\n form.toggle_button().bind({ value: ANIMATION_LEVEL }),\n form.text({ text: \"Animation Speed\" }),\n form.slider({ live: true }).bind({ value: ANIMATION_SPEED }),\n this.#advanced,\n ],\n }),\n { closed_text: \"Advanced\", collapsed: true },\n ),\n ],\n }),\n );\n }\n\n set(options: CustomizationOptions): this {\n super.set(options);\n this.set_input(CUSTOMIZATION.main, options.main, (elements) => {\n this.#main = replace_group(this.#main, elements.ok ? elements.value : []);\n });\n this.set_input(CUSTOMIZATION.advanced, options.advanced, (elements) => {\n this.#advanced = replace_group(\n this.#advanced,\n elements.ok ? elements.value : [],\n );\n });\n return this;\n }\n}\ndefine_element(Customization);\n\n/**A form group only takes elements once, so a new list gets a new group*/\nconst replace_group = (old: HTMLElement, elements: readonly FormElement[]) => {\n const group = form.group({ embed: true, elements: [...elements] });\n old.replaceWith(group);\n return group;\n};\n\nexport type { Customization };\n\n/**Content with the settings of the library, and of the app given as main and advanced\n * The title, icon and minimum size have defaults, give them to change them*/\nexport function customization(\n options: CustomizationCreateOptions = {},\n): Customization {\n return Customization.create({\n title: \"Customization\",\n icon: material_brightness_medium_rounded,\n closable: true,\n min_width: 10,\n min_height: 6,\n ...options,\n });\n}\n\n/**The customization in a hidden modal panel*/\nexport interface CustomizationPanel {\n readonly panel: Panel;\n readonly content: Customization;\n /**Whether the panel is hidden, write false to show it, the panel writes true when the user presses outside it*/\n readonly hidden: StateROSW<boolean>;\n}\n\n/**Creates the customization in a modal panel, hidden, it hides again when the user presses outside it\n * Change the panel with panel.set, like its position\n * @param owner the panel is made in the document of the owner, the main document by default*/\nexport function customization_panel(\n options: CustomizationCreateOptions = {},\n owner: Node = DOCUMENT_HANDLER.main,\n): CustomizationPanel {\n const content = customization(options);\n const hidden = state.ok_w(true);\n const panel = panel_container(owner).panel(content, {\n sizeable: false,\n titlebar: false,\n width: 20,\n hidden,\n auto_hide: true,\n modal: true,\n layer: 9999,\n });\n return { panel, content, hidden };\n}\n\n/**Shows the customization panel when the element is clicked, with the anchor of the panel at the anchor of the element\n * @param c_panel the panel to show, a new one in the document of the element by default*/\nexport function attach_customization_panel_to_element(\n element: Element,\n element_anchor: CompAnchor,\n panel_anchor: CompAnchor,\n c_panel: CustomizationPanel = customization_panel({}, element),\n): CustomizationPanel {\n element.addEventListener(\"click\", () => {\n const { x, y } = get_element_anchor_position(element, element_anchor);\n c_panel.panel.set({ x, y, anchor: panel_anchor });\n void c_panel.hidden.write(false);\n c_panel.panel.focus();\n });\n return c_panel;\n}\n","import { Base, define_element, input_key, type InputOptions } from \"#base\";\nimport type { SVGFunc } from \"#svg\";\nimport type { StateOrVal } from \"@chocbite/ts-lib/state\";\nimport \"./shared\";\nimport \"./topbar.scss\";\n\n/**Shared base of the top bar elements, only sets the namespace*/\nabstract class TopbarBase extends Base {\n static element_name() {\n return \"@abstract@\";\n }\n static element_name_space() {\n return \"composition\";\n }\n}\n\n// _______ ____ _____ ____ _____\n// |__ __/ __ \\| __ \\| _ \\ /\\ | __ \\\n// | | | | | | |__) | |_) | / \\ | |__) |\n// | | | | | | ___/| _ < / /\\ \\ | _ /\n// | | | |__| | | | |_) / ____ \\| | \\ \\\n// |_| \\____/|_| |____/_/ \\_\\_| \\_\\\n/**Inputs of the top bar*/\nconst TOPBAR = {\n /**Items at the left side, the side is empty on errors*/\n left: input_key<StateOrVal<readonly Element[]>>(),\n /**Items in the middle, the middle is empty on errors*/\n mid: input_key<StateOrVal<readonly Element[]>>(),\n /**Items at the right side, the side is empty on errors*/\n right: input_key<StateOrVal<readonly Element[]>>(),\n};\nexport type TopbarOptions = InputOptions<typeof TOPBAR>;\n\n/**Bar along the top of a page, with items at the left, in the middle and at the right*/\nclass Topbar extends TopbarBase {\n static element_name() {\n return \"topbar\";\n }\n\n #left = this.appendChild(document.createElement(\"div\"));\n #mid = this.appendChild(document.createElement(\"div\"));\n #right = this.appendChild(document.createElement(\"div\"));\n\n set(options: TopbarOptions): this {\n this.set_input(TOPBAR.left, options.left, (items) => {\n this.#left.replaceChildren(...(items.ok ? items.value : []));\n });\n this.set_input(TOPBAR.mid, options.mid, (items) => {\n this.#mid.replaceChildren(...(items.ok ? items.value : []));\n });\n this.set_input(TOPBAR.right, options.right, (items) => {\n this.#right.replaceChildren(...(items.ok ? items.value : []));\n });\n return this;\n }\n}\ndefine_element(Topbar);\n\n// ____ _ _ _______ _______ ____ _ _\n// | _ \\| | | |__ __|__ __/ __ \\| \\ | |\n// | |_) | | | | | | | | | | | | \\| |\n// | _ <| | | | | | | | | | | | . ` |\n// | |_) | |__| | | | | | | |__| | |\\ |\n// |____/ \\____/ |_| |_| \\____/|_| \\_|\n/**Inputs of a top bar button*/\nconst BUTTON = {\n /**Text of the button, shows the error on errors*/\n text: input_key<StateOrVal<string>>(),\n /**Icon in front of the text, no icon on errors*/\n icon: input_key<StateOrVal<SVGFunc | undefined>>(),\n /**Called when the button is clicked, a plain value as it is not shown*/\n on_click: input_key<() => void>(),\n};\nexport type TopbarButtonOptions = InputOptions<typeof BUTTON>;\n\n/**Button for the top bar, with an icon, a text or both*/\nclass TopbarButton extends TopbarBase {\n static element_name() {\n return \"topbar-button\";\n }\n\n #icon?: SVGSVGElement;\n #text = this.appendChild(document.createElement(\"span\"));\n #on_click?: () => void;\n\n constructor() {\n super();\n this.onclick = () => this.#on_click?.();\n }\n\n set(options: TopbarButtonOptions): this {\n this.set_input(BUTTON.on_click, options.on_click, (on_click) => {\n this.#on_click = on_click.value;\n });\n this.set_input(BUTTON.text, options.text, (text) => {\n this.#text.textContent = text.ok ? text.value : \"⚠ \" + text.error;\n });\n this.set_input(BUTTON.icon, options.icon, (icon) => {\n this.#icon?.remove();\n this.#icon = icon.ok && icon.value ? icon.value() : undefined;\n if (this.#icon) this.prepend(this.#icon);\n });\n return this;\n }\n}\ndefine_element(TopbarButton);\n\n// _ ____ ______ _\n// | | /\\ | _ \\| ____| |\n// | | / \\ | |_) | |__ | |\n// | | / /\\ \\ | _ <| __| | |\n// | |____ / ____ \\| |_) | |____| |____\n// |______/_/ \\_\\____/|______|______|\n/**Inputs of a top bar label*/\nconst LABEL = {\n /**Text of the label, shows the error on errors*/\n text: input_key<StateOrVal<string>>(),\n};\nexport type TopbarLabelOptions = InputOptions<typeof LABEL>;\n\n/**Text for the top bar*/\nclass TopbarLabel extends TopbarBase {\n static element_name() {\n return \"topbar-label\";\n }\n\n set(options: TopbarLabelOptions): this {\n this.set_input(LABEL.text, options.text, (text) => {\n this.textContent = text.ok ? text.value : \"⚠ \" + text.error;\n });\n return this;\n }\n}\ndefine_element(TopbarLabel);\n\n// ______ _____ _______ ____ _____ _____ ______ _____\n// | ____/\\ / ____|__ __/ __ \\| __ \\|_ _| ____|/ ____|\n// | |__ / \\ | | | | | | | | |__) | | | | |__ | (___\n// | __/ /\\ \\| | | | | | | | _ / | | | __| \\___ \\\n// | | / ____ \\ |____ | | | |__| | | \\ \\ _| |_| |____ ____) |\n// |_|/_/ \\_\\_____| |_| \\____/|_| \\_\\_____|______|_____/\nexport type { Topbar, TopbarButton, TopbarLabel };\n\n/**Bar along the top of a page, items are given as arrays for the left, middle and right*/\nexport function topbar(options: TopbarOptions = {}): Topbar {\n return Topbar.create(options);\n}\n\n/**Button for the top bar, with an icon, a text or both*/\nexport function topbar_button(options: TopbarButtonOptions = {}): TopbarButton {\n return TopbarButton.create(options);\n}\n\n/**Text for the top bar*/\nexport function topbar_label(options: TopbarLabelOptions = {}): TopbarLabel {\n return TopbarLabel.create(options);\n}\n","export type { PanelContainer } from \"./container\";\nexport type { Panel, PanelOptions } from \"./panel\";\nexport { CompAnchor, type CompPosition } from \"./shared\";\nimport {\n attach_customization_panel_to_element,\n customization,\n customization_panel,\n} from \"./customization\";\nimport { panel, panel_container } from \"./container\";\nimport { content } from \"./content\";\nimport { get_element_anchor_position } from \"./shared\";\nimport { topbar, topbar_button, topbar_label } from \"./topbar\";\n\nexport const comp = {\n content,\n panel,\n panel_container,\n topbar,\n topbar_button,\n topbar_label,\n customization,\n customization_panel,\n attach_customization_panel_to_element,\n get_element_anchor_position,\n};\n\nexport {\n ContentBase,\n type Content,\n type ContentCreateOptions,\n type ContentOptions,\n} from \"./content\";\nexport type {\n Customization,\n CustomizationCreateOptions,\n CustomizationOptions,\n CustomizationPanel,\n} from \"./customization\";\nexport type {\n Topbar,\n TopbarButton,\n TopbarButtonOptions,\n TopbarLabel,\n TopbarLabelOptions,\n TopbarOptions,\n} from \"./topbar\";\n"],"mappings":";;;;;;;;;;;AAWA,MAAa,aAAa;CACxB,WAAW;CACX,UAAU;CACV,WAAW;CACX,U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,MAAM,QAAQ,OAAO,SAAS;GAClD,KAAK,OAAO,OAAO;GACnB,KAAK,QAAQ,KAAK,MAAM,KAAK,QAAQ,KAAK,MAAM,IAAI,KAAA;GACpD,IAAI,KAAK,OAAO,KAAK,QAAQ,KAAK,KAAK;EACzC,CAAC;EACD,OAAO;CACT;AACF;AACA,eAAe,YAAY;;AAS3B,MAAM,QAAQ;;AAEZ,MAAM,UAA8B,EACtC;;AAIA,IAAM,cAAN,cAA0B,WAAW;CACnC,OAAO,eAAe;EACpB,OAAO;CACT;CAEA,IAAI,SAAmC;EACrC,KAAK,UAAU,MAAM,MAAM,QAAQ,OAAO,SAAS;GACjD,KAAK,cAAc,KAAK,KAAK,KAAK,QAAQ,OAAO,KAAK;EACxD,CAAC;EACD,OAAO;CACT;AACF;AACA,eAAe,WAAW;;AAW1B,SAAgB,OAAO,UAAyB,CAAC,GAAW;CAC1D,OAAO,OAAO,OAAO,OAAO;AAC9B;;AAGA,SAAgB,cAAc,UAA+B,CAAC,GAAiB;CAC7E,OAAO,aAAa,OAAO,OAAO;AACpC;;AAGA,SAAgB,aAAa,UAA8B,CAAC,GAAgB;CAC1E,OAAO,YAAY,OAAO,OAAO;AACnC;;AC/IA,MAAa,OAAO;CAClB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF"}
@@ -1,3 +1,3 @@
1
1
  import '../style.css';
2
- import { i as ContextMenuLines, n as ContextMenuGroup, r as ContextMenu, t as ctm } from "../index-YNZjMIO7.mjs";
2
+ import { i as ContextMenuLines, n as ContextMenuGroup, r as ContextMenu, t as ctm } from "../index-CApVOEcI.mjs";
3
3
  export { type ContextMenu, type ContextMenuGroup, type ContextMenuLines, ctm, ctm as default };
@@ -1,2 +1,2 @@
1
1
  import "../style.css";
2
- export { t as ctm, t as default } from "../context-menu-CZxEGjBi.mjs";
2
+ export { t as ctm, t as default } from "../context-menu-C0KTV5zC.mjs";
@@ -1,6 +1,6 @@
1
1
  import "./style.css";
2
2
  import { Base, define_element } from "./base/index.mjs";
3
- import { i as theme_init_variable_root } from "./theme-D3YluyYr.mjs";
3
+ import { i as theme_init_variable_root } from "./theme-D0pRMLyT.mjs";
4
4
  import { Fm as material_chevron_right_rounded, xh as material_close_rounded } from "./icons-B88i-7MC.mjs";
5
5
  import { Spinner } from "./spinner/index.mjs";
6
6
  import { DOCUMENT_HANDLER } from "./document/index.mjs";
@@ -596,4 +596,4 @@ const ctm = {
596
596
  };
597
597
  export { ctm as t };
598
598
 
599
- //# sourceMappingURL=context-menu-CZxEGjBi.mjs.map
599
+ //# sourceMappingURL=context-menu-C0KTV5zC.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"context-menu-CZxEGjBi.mjs","names":[],"sources":["../../package-ui/context-menu/shared.ts","../../package-ui/context-menu/line.ts","../../package-ui/context-menu/devider.ts","../../package-ui/context-menu/buffer.ts","../../package-ui/context-menu/container.ts","../../package-ui/context-menu/option.ts","../../package-ui/context-menu/submenu.ts","../../package-ui/context-menu/menu.ts","../../package-ui/context-menu/combine.ts","../../package-ui/context-menu/engine.ts","../../package-ui/context-menu/index.ts"],"sourcesContent":["import { BLUE, GREY } from \"@chocbite/ts-lib/colors\";\nimport { theme_init_variable_root } from \"#theme\";\n\nconst variables = theme_init_variable_root(\n \"contextmenu\",\n \"Context Menu\",\n \"Right click or touch and hold context menu appearance\",\n);\nvariables.make_variable(\n \"background\",\n \"Background Color\",\n \"Color of background\",\n GREY[\"50\"],\n GREY[\"900\"],\n \"Color\",\n undefined,\n);\nvariables.make_variable(\n \"text\",\n \"Text Color\",\n \"Color of text\",\n GREY[\"600\"],\n GREY[\"400\"],\n \"Color\",\n undefined,\n);\nvariables.make_variable(\n \"hover\",\n \"Hover Color\",\n \"Background color of line when hovering over it\",\n BLUE[\"200\"],\n BLUE[\"900\"],\n \"Color\",\n undefined,\n);\nvariables.make_variable(\n \"hoverText\",\n \"Text Color\",\n \"Standard text color\",\n GREY[\"900\"],\n GREY[\"50\"],\n \"Color\",\n undefined,\n);\nvariables.make_variable(\n \"border\",\n \"Border Color\",\n \"Color of border and deviders\",\n GREY[\"300\"],\n GREY[\"800\"],\n \"Color\",\n undefined,\n);\n","import { Base } from \"#base\";\nimport \"./option.scss\";\nimport \"./shared\";\n\nexport interface ContextMenuLine {}\n\nexport abstract class MenuLine extends Base implements ContextMenuLine {\n /**Returns the name used to define the element */\n static element_name() {\n return \"@abstract@\";\n }\n /**Returns the namespace override for the element*/\n static element_name_space() {\n return \"contextmenu\";\n }\n\n abstract do_focus(dir?: boolean): void;\n\n /**True for lines that can not take focus, like dividers, focus moves past them*/\n get skips_focus() {\n return false;\n }\n\n /**Changes focus to the next line, wrapping around and skipping lines that can not take focus\n * @param direction false is next sibling, true is previous */\n focus_next(direction?: boolean) {\n const parent = this.parentElement;\n if (!parent) return;\n let line = direction\n ? this.previousElementSibling\n : this.nextElementSibling;\n for (;;) {\n line ??= direction ? parent.lastElementChild : parent.firstElementChild;\n //Back at the start, there is no other line to focus\n if (!line || line === this) return;\n if (!(line as MenuLine).skips_focus)\n return (line as MenuLine).do_focus(direction);\n line = direction ? line.previousElementSibling : line.nextElementSibling;\n }\n }\n}\n","import { define_element } from \"#base\";\nimport \"./devider.scss\";\nimport { ContextMenuLine, MenuLine } from \"./line\";\n\nexport interface ContextMenuDevider extends ContextMenuLine {}\n\nexport class Devider extends MenuLine implements ContextMenuDevider {\n /**Returns the name used to define the element */\n static element_name() {\n return \"devider\";\n }\n\n get skips_focus() {\n return true;\n }\n\n do_focus(dir?: boolean) {\n this.focus_next(dir);\n }\n}\ndefine_element(Devider);\n\nexport function context_devider(): ContextMenuDevider {\n return new Devider();\n}\n","import { define_element } from \"#base\";\nimport { Spinner } from \"#spinner\";\nimport \"./buffer.scss\";\nimport { MenuLine } from \"./line\";\n\nexport class Buffer extends MenuLine {\n /**Returns the name used to define the element */\n static element_name() {\n return \"buffer\";\n }\n\n constructor() {\n super();\n this.appendChild(new Spinner());\n }\n\n get skips_focus() {\n return true;\n }\n\n do_focus(dir: boolean) {\n this.focus_next(dir);\n }\n}\ndefine_element(Buffer);\n","import { Base, define_element } from \"#base\";\nimport \"./container.scss\";\nimport { ContextMenu } from \"./menu\";\n\nexport class Container extends Base {\n #active_element_buffer: HTMLOrSVGElement | null | undefined;\n #replacing = false;\n\n /**Returns the name used to define the element */\n static element_name() {\n return \"container\";\n }\n /**Returns the namespace override for the element*/\n static element_name_space() {\n return \"contextmenu\";\n }\n\n constructor() {\n super();\n this.tabIndex = -1;\n const preventer = (e: Event) => {\n e.preventDefault();\n e.stopPropagation();\n };\n this.oncontextmenu = preventer;\n this.onpointerdown = preventer;\n this.onpointerup = preventer;\n this.onpointercancel = preventer;\n this.onpointerenter = preventer;\n this.onpointerleave = preventer;\n this.onpointermove = preventer;\n this.onpointerout = preventer;\n this.onpointerout = preventer;\n this.onclick = preventer;\n }\n\n /**Attaches a menu to the container */\n attach_menu(menu: ContextMenu) {\n menu.container = this;\n const old = this.firstElementChild as ContextMenu | null;\n if (old) {\n //Closed before replacing, the browser closes it from a focusout while it is being removed otherwise,\n //focus still returns to the element from before the old menu\n this.#replacing = true;\n old.close_down();\n old.close_up();\n this.#replacing = false;\n } else\n this.#active_element_buffer = this.ownerDocument\n .activeElement as HTMLOrSVGElement | null;\n this.replaceChildren(menu);\n return menu;\n }\n\n /**Closes open context menu */\n close_up() {\n if (this.#replacing) return;\n if (this.#active_element_buffer) {\n this.#active_element_buffer.focus();\n if (\n (this.ownerDocument.activeElement as any) !==\n this.#active_element_buffer\n ) {\n this.focus();\n }\n this.#active_element_buffer = undefined;\n } else {\n this.focus();\n }\n }\n}\ndefine_element(Container);\n","import { define_element } from \"#base\";\nimport { ContextMenuLine, MenuLine } from \"./line\";\nimport { ContextMenu } from \"./menu\";\nimport \"./option.scss\";\n\nexport interface ContextMenuOption extends ContextMenuLine {}\n\nexport class MenuOption extends MenuLine implements ContextMenuOption {\n readonly func: () => void;\n\n /**Returns the name used to define the element */\n static element_name() {\n return \"option\";\n }\n\n constructor(\n text: string,\n func: () => void,\n icon?: SVGSVGElement,\n shortcut?: string,\n checkmark?: boolean,\n ) {\n super();\n this.func = func;\n this.tabIndex = 0;\n const icon_box = this.appendChild(document.createElement(\"div\"));\n icon_box.className = \"icon\";\n if (icon) icon_box.appendChild(icon);\n const text_box = this.appendChild(document.createElement(\"div\"));\n text_box.textContent = text;\n text_box.className = \"text\";\n const shortcut_box = this.appendChild(document.createElement(\"div\"));\n if (shortcut) shortcut_box.textContent = shortcut;\n shortcut_box.className = \"shortcut\";\n const check_mark_box = this.appendChild(document.createElement(\"div\"));\n if (checkmark) check_mark_box.textContent = \"✓\";\n check_mark_box.className = \"checkmark\";\n\n this.onclick = (e) => {\n e.stopPropagation();\n this.func();\n navigator.vibrate?.(25);\n (this.parentElement as ContextMenu).close_up();\n };\n\n this.onkeydown = (e) => {\n switch (e.code) {\n case \"Tab\":\n case \"ArrowUp\":\n case \"ArrowDown\":\n this.focus_next(e.shiftKey || e.code === \"ArrowUp\");\n break;\n case \"Enter\":\n case \"Space\":\n this.func();\n (this.parentElement as ContextMenu).close_up();\n break;\n case \"ArrowLeft\":\n case \"Escape\":\n return;\n }\n e.preventDefault();\n e.stopPropagation();\n };\n }\n\n do_focus(): void {\n this.focus();\n }\n}\ndefine_element(MenuOption);\n\nexport function context_line(\n text: string,\n func: () => void,\n icon?: SVGSVGElement,\n shortcut?: string,\n checkmark?: boolean,\n): ContextMenuOption {\n return new MenuOption(text, func, icon, shortcut, checkmark);\n}\n","import { define_element } from \"#base\";\nimport { material_chevron_right_rounded } from \"#icons\";\nimport { ContextMenuLine, MenuLine } from \"./line\";\nimport { ContextMenu } from \"./menu\";\nimport \"./submenu.scss\";\n\nexport interface ContextMenuSub extends ContextMenuLine {}\n\ntype Mutable<T> = {\n -readonly [P in keyof T]: T[P];\n};\nexport class MenuSub extends MenuLine implements ContextMenuSub {\n #menu: ContextMenu;\n #is_open?: boolean;\n #hover_time?: number;\n #block_time?: number;\n\n /**Returns the name used to define the element */\n static element_name() {\n return \"submenu\";\n }\n\n constructor(text: string, menu: ContextMenu, icon?: SVGSVGElement) {\n super();\n this.#menu = menu;\n this.tabIndex = 0;\n const icon_box = this.appendChild(document.createElement(\"div\"));\n icon_box.className = \"icon\";\n if (icon) icon_box.appendChild(icon);\n const text_box = this.appendChild(document.createElement(\"div\"));\n text_box.textContent = text;\n text_box.className = \"text\";\n const shortcut_box = this.appendChild(document.createElement(\"div\"));\n shortcut_box.className = \"shortcut\";\n const chevron_box = this.appendChild(document.createElement(\"div\"));\n chevron_box.appendChild(material_chevron_right_rounded());\n chevron_box.className = \"chevron\";\n\n this.onclick = (e) => {\n e.stopPropagation();\n if (!this.#block_time) {\n navigator.vibrate?.(25);\n if (this.#is_open) {\n this.close_down();\n } else {\n this.open();\n }\n }\n };\n\n this.onpointerenter = (e) => {\n if (e.pointerType !== \"touch\" && !this.#is_open) {\n this.#hover_time = window.setTimeout(() => {\n this.open();\n this.#block_time = window.setTimeout(() => {\n this.#block_time = 0;\n }, 500);\n }, 300);\n }\n };\n this.onpointerleave = () => {\n clearTimeout(this.#hover_time);\n };\n this.onkeydown = (e) => {\n switch (e.code) {\n case \"Tab\":\n case \"ArrowUp\":\n case \"ArrowDown\":\n this.focus_next(e.shiftKey || e.code === \"ArrowUp\");\n break;\n case \"ArrowRight\":\n case \"Enter\":\n case \"Space\":\n this.open();\n this.#menu.focus_next(false);\n break;\n case \"ArrowLeft\":\n case \"Escape\":\n return;\n }\n e.preventDefault();\n e.stopPropagation();\n };\n }\n\n /**Opens the sub menu */\n open() {\n const sub = this.parentElement as Mutable<ContextMenu>;\n if (sub) sub.close_down();\n (this.parentElement as Mutable<ContextMenu>).submenu = this;\n this.appendChild(this.#menu);\n this.#menu.set_position(0, 0, this);\n this.#is_open = true;\n }\n\n do_focus(): void {\n this.focus();\n }\n\n /**Closes menu by calling parent*/\n close() {\n this.focus();\n (this.parentElement as Mutable<ContextMenu>).submenu = undefined;\n this.removeChild(this.#menu);\n this.#is_open = false;\n }\n\n /**Closes the context menu down the tree*/\n close_down() {\n this.#menu.close_down();\n this.close();\n }\n\n /**Closes the context menu up the tree to the root*/\n close_up() {\n this.close();\n (this.parentElement as ContextMenu).close_up();\n }\n}\ndefine_element(MenuSub);\n\nexport function context_sub(\n text: string,\n menu: ContextMenu,\n icon?: SVGSVGElement,\n): ContextMenuSub {\n return new MenuSub(text, menu, icon);\n}\n","import { Base, define_element } from \"#base\";\nimport { material_close_rounded } from \"#icons\";\nimport { Buffer } from \"./buffer\";\nimport { Container } from \"./container\";\nimport { ContextMenuLine, MenuLine } from \"./line\";\nimport \"./menu.scss\";\nimport { MenuOption } from \"./option\";\nimport \"./shared\";\nimport { MenuSub } from \"./submenu\";\n\nexport type ContextMenuLines = ContextMenuLine[];\n\nexport class ContextMenu extends Base {\n /**Returns the name used to define the element */\n static element_name() {\n return \"menu\";\n }\n /**Returns the namespace override for the element*/\n static element_name_space() {\n return \"contextmenu\";\n }\n\n container: Container | undefined;\n readonly submenu: MenuSub | undefined;\n #closer: MenuOption | undefined;\n #x: number | undefined;\n #y: number | undefined;\n #element: Element | undefined;\n /**Spinner shown while promised lines load, cleared when the menu closes*/\n #loading: Buffer | undefined;\n #focus_out_handler = (e: FocusEvent) => {\n e.preventDefault();\n e.stopPropagation();\n if (!e.relatedTarget || !this.contains(e.relatedTarget as Node)) {\n this.close_up();\n this.close_down();\n }\n };\n #window_resize_handler = () => {\n this.set_position(this.#x, this.#y, this.#element);\n };\n\n #lines:\n | (\n | (ContextMenuLine | undefined)[]\n | Promise<(ContextMenuLine | undefined)[]>\n )\n | (() =>\n | (ContextMenuLine | undefined)[]\n | Promise<(ContextMenuLine | undefined)[]>);\n\n constructor(\n lines:\n | (\n | (ContextMenuLine | undefined)[]\n | Promise<(ContextMenuLine | undefined)[]>\n )\n | (() =>\n | (ContextMenuLine | undefined)[]\n | Promise<(ContextMenuLine | undefined)[]>),\n ) {\n super();\n this.#lines = lines;\n this.tabIndex = 0;\n this.onscroll = () => {\n this.close_down();\n };\n this.onkeydown = (e) => {\n if (e.code === \"Tab\" || e.code === \"ArrowUp\" || e.code === \"ArrowDown\")\n this.focus_next(e.shiftKey || e.code === \"ArrowUp\");\n else if (e.code === \"ArrowLeft\") {\n const parent = this.parentElement as MenuSub | Container;\n if (!(parent instanceof Container)) {\n parent.focus();\n parent.close_down();\n }\n } else if (e.code === \"Escape\") this.close_up();\n e.preventDefault();\n e.stopPropagation();\n };\n }\n\n protected connectedCallback(): void {\n super.connectedCallback();\n const lines = this.read_lines();\n this.#loading?.remove();\n if (lines instanceof Promise) {\n const buffer = (this.#loading = this.appendChild(new Buffer()));\n lines.then((line) => {\n //Closed or opened again before the lines arrived\n if (this.#loading !== buffer) return;\n this.#loading = undefined;\n buffer.remove();\n this.lines = line;\n this.set_position(this.#x, this.#y, this.#element);\n });\n } else {\n this.#loading = undefined;\n this.lines = lines;\n }\n this.addEventListener(\"focusout\", this.#focus_out_handler, {\n capture: true,\n });\n this.ownerDocument.defaultView?.addEventListener(\n \"resize\",\n this.#window_resize_handler,\n { passive: true },\n );\n }\n\n protected disconnectedCallback(): void {\n super.disconnectedCallback();\n //Lines arriving after the menu closed are not shown\n this.#loading?.remove();\n this.#loading = undefined;\n this.ownerDocument.defaultView?.removeEventListener(\n \"resize\",\n this.#window_resize_handler,\n );\n }\n\n /**Gives the lines the menu shows when it opens, a lines function is called\n * The lines are elements in one menu at a time, ctm.combine moves them into its menu, this menu takes them back when it opens */\n read_lines():\n (ContextMenuLine | undefined)[] | Promise<(ContextMenuLine | undefined)[]> {\n return typeof this.#lines === \"function\" ? this.#lines() : this.#lines;\n }\n\n /**Sets the lines of the context menu */\n set lines(lines: (ContextMenuLine | undefined)[]) {\n this.replaceChildren();\n if (this.#closer) this.appendChild(this.#closer);\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n if (line) this.appendChild(line as MenuLine);\n }\n }\n\n /**Changes focus to the next line\n * @param direction false is first child, true is last child */\n focus_next(direction: boolean) {\n //The direction is passed on, so a divider skips to the line after it, toward the middle\n if (direction) (this.lastChild as MenuLine)?.do_focus(true);\n else (this.firstChild as MenuLine)?.do_focus(false);\n }\n\n set closer(closer: boolean) {\n if (closer && !this.#closer) {\n this.classList.add(\"closer\");\n this.#closer = new MenuOption(\n \"Close\",\n () => {},\n material_close_rounded(),\n );\n this.#closer.onclick = (e) => {\n e.stopPropagation();\n if (this.parentElement instanceof MenuSub) {\n this.parentElement.close_down();\n } else {\n this.close_up();\n }\n };\n this.prepend(this.#closer);\n } else if (!closer && this.#closer) {\n this.classList.remove(\"closer\");\n this.#closer.remove();\n this.#closer = undefined;\n }\n }\n\n /**Sets the context menu to fullscreen mode in x directino */\n set fullscreenx(full: boolean) {\n if (full) this.classList.add(\"fullscreen-x\");\n else this.classList.remove(\"fullscreen-x\");\n }\n\n /**Sets the context menu to fullscreen mode in y direction */\n set fullscreeny(full: boolean) {\n if (full) this.classList.add(\"fullscreen-y\");\n else this.classList.remove(\"fullscreen-y\");\n }\n\n /**Closes the context menu down the tree*/\n close_down() {\n if (this.submenu) this.submenu.close_down();\n //@ts-expect-error Writing to readonly property, from inside class itself\n this.submenu = undefined;\n }\n\n /**Closes the context menu up the tree to the root*/\n close_up() {\n this.removeEventListener(\"focusout\", this.#focus_out_handler, {\n capture: true,\n });\n (this.parentElement as Container)?.close_up();\n this.remove();\n }\n\n /**Updates the position of the menu\n * @param x x coordinate for menu, this will be ignored if needed for contextmenu to fit\n * @param y y coordinate for menu, this will be ignored if needed for contextmenu to fit\n * @param element element to use instead of coordinates, the contextemenu will avoid covering the element if possible*/\n set_position(x: number = 0, y: number = 0, element?: Element) {\n this.#x = x;\n this.#y = y;\n this.#element = element;\n const box = this.getBoundingClientRect();\n const box_area = box.width * box.height;\n const window = this.ownerDocument.defaultView!;\n const html_area = window.innerWidth * window.innerHeight;\n this.closer = box_area > html_area * 0.5;\n let top = NaN;\n let bottom = NaN;\n let left = NaN;\n let right = NaN;\n if (element) {\n const sub_box = element.getBoundingClientRect();\n\n if (sub_box.x + sub_box.width + box.width > window.innerWidth) {\n x = sub_box.x;\n if (box.width < x) right = window.innerWidth - x;\n else right = window.innerWidth - (sub_box.x + sub_box.width);\n } else left = sub_box.x + sub_box.width;\n\n y = sub_box.y + sub_box.height;\n\n //Below the element, else above it, else as low as the window allows\n if (y + box.height < window.innerHeight) top = y;\n else if (sub_box.y >= box.height) bottom = window.innerHeight - sub_box.y;\n else top = Math.max(0, window.innerHeight - box.height);\n } else {\n if (y + box.height >= window.innerHeight) {\n if (y >= box.height) bottom = window.innerHeight - y;\n else top = window.innerHeight - box.height;\n } else top = y;\n\n if (box.width >= window.innerWidth) {\n right = 0;\n } else if (x + box.width >= window.innerWidth) {\n if (x >= box.width) right = window.innerWidth - x;\n else left = window.innerWidth - box.width;\n } else left = x;\n }\n this.fullscreenx = box.width === window.innerWidth;\n this.fullscreeny = box.height >= window.innerHeight;\n\n this.style.top = top === top ? top + \"px\" : \"\";\n this.style.bottom = bottom === bottom ? bottom + \"px\" : \"\";\n this.style.left = left === left ? left + \"px\" : \"\";\n this.style.right = right === right ? right + \"px\" : \"\";\n this.focus();\n }\n}\ndefine_element(ContextMenu);\n\nexport function context_menu(\n lines:\n | (\n | (ContextMenuLine | undefined)[]\n | Promise<(ContextMenuLine | undefined)[]>\n )\n | (() => (ContextMenuLine | undefined)[])\n | (() => Promise<(ContextMenuLine | undefined)[]>),\n): ContextMenu {\n return new ContextMenu(lines);\n}\n","import result, { none, some, type Option } from \"@chocbite/ts-lib/result\";\nimport { context_devider } from \"./devider\";\nimport type { ContextMenuLine } from \"./line\";\nimport { context_menu, ContextMenu } from \"./menu\";\n\ntype Lines = (ContextMenuLine | undefined)[];\n\n/**A group for ctm.combine, undefined for no group\n * - lines, undefined lines are skipped like in ctm.menu\n * - a menu, its lines are taken when the combined menu opens\n * - a function called every time the combined menu opens, giving lines, a menu, or an option of a menu like ctm.attach takes*/\nexport type ContextMenuGroup =\n | Lines\n | ContextMenu\n | (() => Lines | ContextMenu | Option<ContextMenu>)\n | undefined;\n\nfunction group_lines(group: ContextMenuGroup): Lines | Promise<Lines> {\n let value = typeof group === \"function\" ? group() : group;\n if (result.is_option(value)) value = value.unwrap_or(undefined);\n if (value instanceof ContextMenu) return value.read_lines();\n return value ?? [];\n}\n\n/**Joins groups with a devider between those with lines */\nfunction join(groups: Lines[]): ContextMenuLine[] {\n const lines: ContextMenuLine[] = [];\n for (const group of groups) {\n const group_lines = group.filter((line) => line !== undefined);\n if (group_lines.length === 0) continue;\n if (lines.length) lines.push(context_devider());\n lines.push(...group_lines);\n }\n return lines;\n}\n\n/**Combines groups of lines and menus into one menu with a devider between groups, built every time the menu opens\n * Empty groups are left out with their devider, and when all groups are empty there is no menu\n * A group with promised lines makes the combined menu wait for all groups, showing a spinner, it then always opens\n * Give the result to ctm.attach, or anything else taking a menu factory\n * @param groups groups in menu order, see ContextMenuGroup*/\nexport function context_combine(\n ...groups: ContextMenuGroup[]\n): () => Option<ContextMenu> {\n return () => {\n const parts = groups.map(group_lines);\n if (parts.some((part) => part instanceof Promise))\n return some(\n context_menu(\n Promise.all(parts.map((part) => Promise.resolve(part))).then(join),\n ),\n );\n const lines = join(parts as Lines[]);\n return lines.length ? some(context_menu(lines)) : none();\n };\n}\n","import { DOCUMENT_HANDLER } from \"#document\";\nimport type { Option } from \"@chocbite/ts-lib/result\";\nimport { Container } from \"./container\";\nimport \"./engine.scss\";\nimport { ContextMenu } from \"./menu\";\n\nexport const CONTEXT_MENY_SYMBOL = Symbol(\"context_menu\");\n\ndeclare global {\n interface Document {\n [CONTEXT_MENY_SYMBOL]: Container | undefined;\n }\n interface Element {\n [CONTEXT_MENY_SYMBOL]: EventListenerOrEventListenerObject | undefined;\n }\n}\n\n/**Default context menu, false blocks the operating system context menu, undefined leaves it*/\nlet default_menu: ContextMenu | (() => Option<ContextMenu>) | false | undefined;\n\n/**Blocks the operating system context menu when the default is false*/\nconst block_os_menu = (e: Event) => e.preventDefault();\n\nDOCUMENT_HANDLER.events.on(\"added\", (e) => {\n apply_to_doc(e.data);\n});\nDOCUMENT_HANDLER.for_documents((doc) => {\n apply_to_doc(doc);\n});\n\nfunction apply_to_doc(doc: Document) {\n const container = new Container();\n doc[CONTEXT_MENY_SYMBOL] = container;\n doc.documentElement.appendChild(container);\n apply_default_to_doc(doc);\n}\n\n/**Applies the current default context menu to a document*/\nfunction apply_default_to_doc(doc: Document) {\n const root = doc.documentElement;\n context_menu_detach(root);\n root.removeEventListener(\"contextmenu\", block_os_menu);\n if (default_menu) context_menu_attach(root, default_menu);\n else if (default_menu === false)\n root.addEventListener(\"contextmenu\", block_os_menu);\n}\n\n/**Attaches a context menu to the given element\n * @param element the element to attach the context menu to\n * @param lines the context menu to attach, if a function is given it will be called when the context menu is summoned\n * @param block a function that returns true if the context menu should not be summoned, if undefined the context menu will always be summoned*/\nexport function context_menu_attach(\n element: Element,\n lines: ContextMenu | (() => Option<ContextMenu>),\n block?: () => boolean,\n) {\n if (element[CONTEXT_MENY_SYMBOL]) context_menu_detach(element);\n const listener = (e: Event) => {\n e.preventDefault();\n e.stopPropagation();\n if (block && block()) return;\n const lineses =\n typeof lines === \"function\" ? lines().unwrap_or(undefined) : lines;\n if (!lineses) return;\n context_menu_summon(\n lineses,\n element,\n (e as MouseEvent).clientX,\n (e as MouseEvent).clientY,\n );\n };\n element.addEventListener(\"contextmenu\", listener);\n element[CONTEXT_MENY_SYMBOL] = listener;\n}\n\n/**Dettaches the context menu from the given element */\nexport function context_menu_detach(element: Element) {\n if (element[CONTEXT_MENY_SYMBOL]) {\n element.removeEventListener(\"contextmenu\", element[CONTEXT_MENY_SYMBOL]);\n delete element[CONTEXT_MENY_SYMBOL];\n }\n}\n\n/**Summons a context menu at a given location\n * @param menu the context menu to summon\n * @param element the element the context menu is referenced to, if undefined the context menu will appear in the main document\n * @param x x position for context menu, if undefined, will use element middle, if element undefined, will put context menu in the top left corner of the screen\n * @param y y position for context menu, if undefined, will use element middle, if element undefined, will put context menu in the top left corner of the screen\n * @param dont_cover when set true */\nexport function context_menu_summon(\n menu: ContextMenu,\n element?: Element,\n x?: number,\n y?: number,\n dont_cover?: boolean,\n) {\n const container = element\n ? element.ownerDocument[CONTEXT_MENY_SYMBOL]\n : DOCUMENT_HANDLER.main[CONTEXT_MENY_SYMBOL];\n if (container) {\n if (typeof x !== \"number\" || typeof y !== \"number\") {\n if (element) {\n const box = element.getBoundingClientRect();\n x = box.left + box.width / 2;\n y = box.top + box.height / 2;\n } else {\n x = 0;\n y = 0;\n }\n }\n container\n .attach_menu(menu)\n .set_position(x, y, dont_cover ? element : undefined);\n } else console.error(\"No context menu container available\");\n}\n\n/**Sets the default context menu for the page, the one used if no other context menu has been attached to the element\n * If set to false the operating system context menu is disabled and nothing will appear\n * If set undefined the operating systems context menu will be used*/\nexport function context_menu_default(\n lines: ContextMenu | (() => Option<ContextMenu>) | false | undefined,\n) {\n default_menu = lines;\n DOCUMENT_HANDLER.for_documents(apply_default_to_doc);\n}\n","import { context_combine } from \"./combine\";\nimport { context_devider } from \"./devider\";\nimport {\n context_menu_attach,\n context_menu_default,\n context_menu_detach,\n context_menu_summon,\n CONTEXT_MENY_SYMBOL,\n} from \"./engine\";\nimport { context_menu } from \"./menu\";\nimport { context_line } from \"./option\";\nimport { context_sub } from \"./submenu\";\n\nexport const ctm = {\n attach: context_menu_attach,\n default: context_menu_default,\n detach: context_menu_detach,\n summon: context_menu_summon,\n has(element: Element) {\n return Boolean(element[CONTEXT_MENY_SYMBOL]);\n },\n menu: context_menu,\n line: context_line,\n sub: context_sub,\n devider: context_devider,\n combine: context_combine,\n};\nexport default ctm;\n\nexport type { ContextMenuGroup } from \"./combine\";\nexport type { ContextMenu, ContextMenuLines } from \"./menu\";\n"],"mappings":";;;;;;;;;AAGA,MAAM,YAAY,yBAChB,eACA,gBACA,uDACF;AACA,UAAU,cACR,cACA,oBACA,uBACA,KAAK,OACL,KAAK,QACL,SACA,KAAA,CACF;AACA,UAAU,cACR,QACA,cACA,iBACA,KAAK,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EAC/D,IAAI,CAAC,SAAS;EACd,oBACE,SACA,SACC,EAAiB,SACjB,EAAiB,OACpB;CACF;CACA,QAAQ,iBAAiB,eAAe,QAAQ;CAChD,QAAQ,uBAAuB;AACjC;;AAGA,SAAgB,oBAAoB,SAAkB;CACpD,IAAI,QAAQ,sBAAsB;EAChC,QAAQ,oBAAoB,eAAe,QAAQ,oBAAoB;EACvE,OAAO,QAAQ;CACjB;AACF;;;;;;;AAQA,SAAgB,oBACd,MACA,SACA,GACA,GACA,YACA;CACA,MAAM,YAAY,UACd,QAAQ,cAAc,uBACtB,iBAAiB,KAAK;CAC1B,IAAI,WAAW;EACb,IAAI,OAAO,MAAM,YAAY,OAAO,MAAM,UAAU;GAClD,IAAI,SAAS;IACX,MAAM,MAAM,QAAQ,sBAAsB;IAC1C,IAAI,IAAI,OAAO,IAAI,QAAQ;IAC3B,IAAI,IAAI,MAAM,IAAI,SAAS;GAC7B,OAAO;IACL,IAAI;IACJ,IAAI;GACN;EACF;EACA,UACG,YAAY,IAAI,CAAC,CACjB,aAAa,GAAG,GAAG,aAAa,UAAU,KAAA,CAAS;CACxD,OAAO,QAAQ,MAAM,qCAAqC;AAC5D;;;;AAKA,SAAgB,qBACd,OACA;CACA,eAAe;CACf,iBAAiB,cAAc,oBAAoB;AACrD;;AC/GA,MAAa,MAAM;CACjB,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,QAAQ;CACR,IAAI,SAAkB;EACpB,OAAO,QAAQ,QAAQ,oBAAoB;CAC7C;CACA,MAAM;CACN,MAAM;CACN,KAAK;CACL,SAAS;CACT,SAAS;AACX"}
1
+ {"version":3,"file":"context-menu-C0KTV5zC.mjs","names":[],"sources":["../../package-ui/context-menu/shared.ts","../../package-ui/context-menu/line.ts","../../package-ui/context-menu/devider.ts","../../package-ui/context-menu/buffer.ts","../../package-ui/context-menu/container.ts","../../package-ui/context-menu/option.ts","../../package-ui/context-menu/submenu.ts","../../package-ui/context-menu/menu.ts","../../package-ui/context-menu/combine.ts","../../package-ui/context-menu/engine.ts","../../package-ui/context-menu/index.ts"],"sourcesContent":["import { BLUE, GREY } from \"@chocbite/ts-lib/colors\";\nimport { theme_init_variable_root } from \"#theme\";\n\nconst variables = theme_init_variable_root(\n \"contextmenu\",\n \"Context Menu\",\n \"Right click or touch and hold context menu appearance\",\n);\nvariables.make_variable(\n \"background\",\n \"Background Color\",\n \"Color of background\",\n GREY[\"50\"],\n GREY[\"900\"],\n \"Color\",\n undefined,\n);\nvariables.make_variable(\n \"text\",\n \"Text Color\",\n \"Color of text\",\n GREY[\"600\"],\n GREY[\"400\"],\n \"Color\",\n undefined,\n);\nvariables.make_variable(\n \"hover\",\n \"Hover Color\",\n \"Background color of line when hovering over it\",\n BLUE[\"200\"],\n BLUE[\"900\"],\n \"Color\",\n undefined,\n);\nvariables.make_variable(\n \"hoverText\",\n \"Text Color\",\n \"Standard text color\",\n GREY[\"900\"],\n GREY[\"50\"],\n \"Color\",\n undefined,\n);\nvariables.make_variable(\n \"border\",\n \"Border Color\",\n \"Color of border and deviders\",\n GREY[\"300\"],\n GREY[\"800\"],\n \"Color\",\n undefined,\n);\n","import { Base } from \"#base\";\nimport \"./option.scss\";\nimport \"./shared\";\n\nexport interface ContextMenuLine {}\n\nexport abstract class MenuLine extends Base implements ContextMenuLine {\n /**Returns the name used to define the element */\n static element_name() {\n return \"@abstract@\";\n }\n /**Returns the namespace override for the element*/\n static element_name_space() {\n return \"contextmenu\";\n }\n\n abstract do_focus(dir?: boolean): void;\n\n /**True for lines that can not take focus, like dividers, focus moves past them*/\n get skips_focus() {\n return false;\n }\n\n /**Changes focus to the next line, wrapping around and skipping lines that can not take focus\n * @param direction false is next sibling, true is previous */\n focus_next(direction?: boolean) {\n const parent = this.parentElement;\n if (!parent) return;\n let line = direction\n ? this.previousElementSibling\n : this.nextElementSibling;\n for (;;) {\n line ??= direction ? parent.lastElementChild : parent.firstElementChild;\n //Back at the start, there is no other line to focus\n if (!line || line === this) return;\n if (!(line as MenuLine).skips_focus)\n return (line as MenuLine).do_focus(direction);\n line = direction ? line.previousElementSibling : line.nextElementSibling;\n }\n }\n}\n","import { define_element } from \"#base\";\nimport \"./devider.scss\";\nimport { ContextMenuLine, MenuLine } from \"./line\";\n\nexport interface ContextMenuDevider extends ContextMenuLine {}\n\nexport class Devider extends MenuLine implements ContextMenuDevider {\n /**Returns the name used to define the element */\n static element_name() {\n return \"devider\";\n }\n\n get skips_focus() {\n return true;\n }\n\n do_focus(dir?: boolean) {\n this.focus_next(dir);\n }\n}\ndefine_element(Devider);\n\nexport function context_devider(): ContextMenuDevider {\n return new Devider();\n}\n","import { define_element } from \"#base\";\nimport { Spinner } from \"#spinner\";\nimport \"./buffer.scss\";\nimport { MenuLine } from \"./line\";\n\nexport class Buffer extends MenuLine {\n /**Returns the name used to define the element */\n static element_name() {\n return \"buffer\";\n }\n\n constructor() {\n super();\n this.appendChild(new Spinner());\n }\n\n get skips_focus() {\n return true;\n }\n\n do_focus(dir: boolean) {\n this.focus_next(dir);\n }\n}\ndefine_element(Buffer);\n","import { Base, define_element } from \"#base\";\nimport \"./container.scss\";\nimport { ContextMenu } from \"./menu\";\n\nexport class Container extends Base {\n #active_element_buffer: HTMLOrSVGElement | null | undefined;\n #replacing = false;\n\n /**Returns the name used to define the element */\n static element_name() {\n return \"container\";\n }\n /**Returns the namespace override for the element*/\n static element_name_space() {\n return \"contextmenu\";\n }\n\n constructor() {\n super();\n this.tabIndex = -1;\n const preventer = (e: Event) => {\n e.preventDefault();\n e.stopPropagation();\n };\n this.oncontextmenu = preventer;\n this.onpointerdown = preventer;\n this.onpointerup = preventer;\n this.onpointercancel = preventer;\n this.onpointerenter = preventer;\n this.onpointerleave = preventer;\n this.onpointermove = preventer;\n this.onpointerout = preventer;\n this.onpointerout = preventer;\n this.onclick = preventer;\n }\n\n /**Attaches a menu to the container */\n attach_menu(menu: ContextMenu) {\n menu.container = this;\n const old = this.firstElementChild as ContextMenu | null;\n if (old) {\n //Closed before replacing, the browser closes it from a focusout while it is being removed otherwise,\n //focus still returns to the element from before the old menu\n this.#replacing = true;\n old.close_down();\n old.close_up();\n this.#replacing = false;\n } else\n this.#active_element_buffer = this.ownerDocument\n .activeElement as HTMLOrSVGElement | null;\n this.replaceChildren(menu);\n return menu;\n }\n\n /**Closes open context menu */\n close_up() {\n if (this.#replacing) return;\n if (this.#active_element_buffer) {\n this.#active_element_buffer.focus();\n if (\n (this.ownerDocument.activeElement as any) !==\n this.#active_element_buffer\n ) {\n this.focus();\n }\n this.#active_element_buffer = undefined;\n } else {\n this.focus();\n }\n }\n}\ndefine_element(Container);\n","import { define_element } from \"#base\";\nimport { ContextMenuLine, MenuLine } from \"./line\";\nimport { ContextMenu } from \"./menu\";\nimport \"./option.scss\";\n\nexport interface ContextMenuOption extends ContextMenuLine {}\n\nexport class MenuOption extends MenuLine implements ContextMenuOption {\n readonly func: () => void;\n\n /**Returns the name used to define the element */\n static element_name() {\n return \"option\";\n }\n\n constructor(\n text: string,\n func: () => void,\n icon?: SVGSVGElement,\n shortcut?: string,\n checkmark?: boolean,\n ) {\n super();\n this.func = func;\n this.tabIndex = 0;\n const icon_box = this.appendChild(document.createElement(\"div\"));\n icon_box.className = \"icon\";\n if (icon) icon_box.appendChild(icon);\n const text_box = this.appendChild(document.createElement(\"div\"));\n text_box.textContent = text;\n text_box.className = \"text\";\n const shortcut_box = this.appendChild(document.createElement(\"div\"));\n if (shortcut) shortcut_box.textContent = shortcut;\n shortcut_box.className = \"shortcut\";\n const check_mark_box = this.appendChild(document.createElement(\"div\"));\n if (checkmark) check_mark_box.textContent = \"✓\";\n check_mark_box.className = \"checkmark\";\n\n this.onclick = (e) => {\n e.stopPropagation();\n this.func();\n navigator.vibrate?.(25);\n (this.parentElement as ContextMenu).close_up();\n };\n\n this.onkeydown = (e) => {\n switch (e.code) {\n case \"Tab\":\n case \"ArrowUp\":\n case \"ArrowDown\":\n this.focus_next(e.shiftKey || e.code === \"ArrowUp\");\n break;\n case \"Enter\":\n case \"Space\":\n this.func();\n (this.parentElement as ContextMenu).close_up();\n break;\n case \"ArrowLeft\":\n case \"Escape\":\n return;\n }\n e.preventDefault();\n e.stopPropagation();\n };\n }\n\n do_focus(): void {\n this.focus();\n }\n}\ndefine_element(MenuOption);\n\nexport function context_line(\n text: string,\n func: () => void,\n icon?: SVGSVGElement,\n shortcut?: string,\n checkmark?: boolean,\n): ContextMenuOption {\n return new MenuOption(text, func, icon, shortcut, checkmark);\n}\n","import { define_element } from \"#base\";\nimport { material_chevron_right_rounded } from \"#icons\";\nimport { ContextMenuLine, MenuLine } from \"./line\";\nimport { ContextMenu } from \"./menu\";\nimport \"./submenu.scss\";\n\nexport interface ContextMenuSub extends ContextMenuLine {}\n\ntype Mutable<T> = {\n -readonly [P in keyof T]: T[P];\n};\nexport class MenuSub extends MenuLine implements ContextMenuSub {\n #menu: ContextMenu;\n #is_open?: boolean;\n #hover_time?: number;\n #block_time?: number;\n\n /**Returns the name used to define the element */\n static element_name() {\n return \"submenu\";\n }\n\n constructor(text: string, menu: ContextMenu, icon?: SVGSVGElement) {\n super();\n this.#menu = menu;\n this.tabIndex = 0;\n const icon_box = this.appendChild(document.createElement(\"div\"));\n icon_box.className = \"icon\";\n if (icon) icon_box.appendChild(icon);\n const text_box = this.appendChild(document.createElement(\"div\"));\n text_box.textContent = text;\n text_box.className = \"text\";\n const shortcut_box = this.appendChild(document.createElement(\"div\"));\n shortcut_box.className = \"shortcut\";\n const chevron_box = this.appendChild(document.createElement(\"div\"));\n chevron_box.appendChild(material_chevron_right_rounded());\n chevron_box.className = \"chevron\";\n\n this.onclick = (e) => {\n e.stopPropagation();\n if (!this.#block_time) {\n navigator.vibrate?.(25);\n if (this.#is_open) {\n this.close_down();\n } else {\n this.open();\n }\n }\n };\n\n this.onpointerenter = (e) => {\n if (e.pointerType !== \"touch\" && !this.#is_open) {\n this.#hover_time = window.setTimeout(() => {\n this.open();\n this.#block_time = window.setTimeout(() => {\n this.#block_time = 0;\n }, 500);\n }, 300);\n }\n };\n this.onpointerleave = () => {\n clearTimeout(this.#hover_time);\n };\n this.onkeydown = (e) => {\n switch (e.code) {\n case \"Tab\":\n case \"ArrowUp\":\n case \"ArrowDown\":\n this.focus_next(e.shiftKey || e.code === \"ArrowUp\");\n break;\n case \"ArrowRight\":\n case \"Enter\":\n case \"Space\":\n this.open();\n this.#menu.focus_next(false);\n break;\n case \"ArrowLeft\":\n case \"Escape\":\n return;\n }\n e.preventDefault();\n e.stopPropagation();\n };\n }\n\n /**Opens the sub menu */\n open() {\n const sub = this.parentElement as Mutable<ContextMenu>;\n if (sub) sub.close_down();\n (this.parentElement as Mutable<ContextMenu>).submenu = this;\n this.appendChild(this.#menu);\n this.#menu.set_position(0, 0, this);\n this.#is_open = true;\n }\n\n do_focus(): void {\n this.focus();\n }\n\n /**Closes menu by calling parent*/\n close() {\n this.focus();\n (this.parentElement as Mutable<ContextMenu>).submenu = undefined;\n this.removeChild(this.#menu);\n this.#is_open = false;\n }\n\n /**Closes the context menu down the tree*/\n close_down() {\n this.#menu.close_down();\n this.close();\n }\n\n /**Closes the context menu up the tree to the root*/\n close_up() {\n this.close();\n (this.parentElement as ContextMenu).close_up();\n }\n}\ndefine_element(MenuSub);\n\nexport function context_sub(\n text: string,\n menu: ContextMenu,\n icon?: SVGSVGElement,\n): ContextMenuSub {\n return new MenuSub(text, menu, icon);\n}\n","import { Base, define_element } from \"#base\";\nimport { material_close_rounded } from \"#icons\";\nimport { Buffer } from \"./buffer\";\nimport { Container } from \"./container\";\nimport { ContextMenuLine, MenuLine } from \"./line\";\nimport \"./menu.scss\";\nimport { MenuOption } from \"./option\";\nimport \"./shared\";\nimport { MenuSub } from \"./submenu\";\n\nexport type ContextMenuLines = ContextMenuLine[];\n\nexport class ContextMenu extends Base {\n /**Returns the name used to define the element */\n static element_name() {\n return \"menu\";\n }\n /**Returns the namespace override for the element*/\n static element_name_space() {\n return \"contextmenu\";\n }\n\n container: Container | undefined;\n readonly submenu: MenuSub | undefined;\n #closer: MenuOption | undefined;\n #x: number | undefined;\n #y: number | undefined;\n #element: Element | undefined;\n /**Spinner shown while promised lines load, cleared when the menu closes*/\n #loading: Buffer | undefined;\n #focus_out_handler = (e: FocusEvent) => {\n e.preventDefault();\n e.stopPropagation();\n if (!e.relatedTarget || !this.contains(e.relatedTarget as Node)) {\n this.close_up();\n this.close_down();\n }\n };\n #window_resize_handler = () => {\n this.set_position(this.#x, this.#y, this.#element);\n };\n\n #lines:\n | (\n | (ContextMenuLine | undefined)[]\n | Promise<(ContextMenuLine | undefined)[]>\n )\n | (() =>\n | (ContextMenuLine | undefined)[]\n | Promise<(ContextMenuLine | undefined)[]>);\n\n constructor(\n lines:\n | (\n | (ContextMenuLine | undefined)[]\n | Promise<(ContextMenuLine | undefined)[]>\n )\n | (() =>\n | (ContextMenuLine | undefined)[]\n | Promise<(ContextMenuLine | undefined)[]>),\n ) {\n super();\n this.#lines = lines;\n this.tabIndex = 0;\n this.onscroll = () => {\n this.close_down();\n };\n this.onkeydown = (e) => {\n if (e.code === \"Tab\" || e.code === \"ArrowUp\" || e.code === \"ArrowDown\")\n this.focus_next(e.shiftKey || e.code === \"ArrowUp\");\n else if (e.code === \"ArrowLeft\") {\n const parent = this.parentElement as MenuSub | Container;\n if (!(parent instanceof Container)) {\n parent.focus();\n parent.close_down();\n }\n } else if (e.code === \"Escape\") this.close_up();\n e.preventDefault();\n e.stopPropagation();\n };\n }\n\n protected connectedCallback(): void {\n super.connectedCallback();\n const lines = this.read_lines();\n this.#loading?.remove();\n if (lines instanceof Promise) {\n const buffer = (this.#loading = this.appendChild(new Buffer()));\n lines.then((line) => {\n //Closed or opened again before the lines arrived\n if (this.#loading !== buffer) return;\n this.#loading = undefined;\n buffer.remove();\n this.lines = line;\n this.set_position(this.#x, this.#y, this.#element);\n });\n } else {\n this.#loading = undefined;\n this.lines = lines;\n }\n this.addEventListener(\"focusout\", this.#focus_out_handler, {\n capture: true,\n });\n this.ownerDocument.defaultView?.addEventListener(\n \"resize\",\n this.#window_resize_handler,\n { passive: true },\n );\n }\n\n protected disconnectedCallback(): void {\n super.disconnectedCallback();\n //Lines arriving after the menu closed are not shown\n this.#loading?.remove();\n this.#loading = undefined;\n this.ownerDocument.defaultView?.removeEventListener(\n \"resize\",\n this.#window_resize_handler,\n );\n }\n\n /**Gives the lines the menu shows when it opens, a lines function is called\n * The lines are elements in one menu at a time, ctm.combine moves them into its menu, this menu takes them back when it opens */\n read_lines():\n (ContextMenuLine | undefined)[] | Promise<(ContextMenuLine | undefined)[]> {\n return typeof this.#lines === \"function\" ? this.#lines() : this.#lines;\n }\n\n /**Sets the lines of the context menu */\n set lines(lines: (ContextMenuLine | undefined)[]) {\n this.replaceChildren();\n if (this.#closer) this.appendChild(this.#closer);\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n if (line) this.appendChild(line as MenuLine);\n }\n }\n\n /**Changes focus to the next line\n * @param direction false is first child, true is last child */\n focus_next(direction: boolean) {\n //The direction is passed on, so a divider skips to the line after it, toward the middle\n if (direction) (this.lastChild as MenuLine)?.do_focus(true);\n else (this.firstChild as MenuLine)?.do_focus(false);\n }\n\n set closer(closer: boolean) {\n if (closer && !this.#closer) {\n this.classList.add(\"closer\");\n this.#closer = new MenuOption(\n \"Close\",\n () => {},\n material_close_rounded(),\n );\n this.#closer.onclick = (e) => {\n e.stopPropagation();\n if (this.parentElement instanceof MenuSub) {\n this.parentElement.close_down();\n } else {\n this.close_up();\n }\n };\n this.prepend(this.#closer);\n } else if (!closer && this.#closer) {\n this.classList.remove(\"closer\");\n this.#closer.remove();\n this.#closer = undefined;\n }\n }\n\n /**Sets the context menu to fullscreen mode in x directino */\n set fullscreenx(full: boolean) {\n if (full) this.classList.add(\"fullscreen-x\");\n else this.classList.remove(\"fullscreen-x\");\n }\n\n /**Sets the context menu to fullscreen mode in y direction */\n set fullscreeny(full: boolean) {\n if (full) this.classList.add(\"fullscreen-y\");\n else this.classList.remove(\"fullscreen-y\");\n }\n\n /**Closes the context menu down the tree*/\n close_down() {\n if (this.submenu) this.submenu.close_down();\n //@ts-expect-error Writing to readonly property, from inside class itself\n this.submenu = undefined;\n }\n\n /**Closes the context menu up the tree to the root*/\n close_up() {\n this.removeEventListener(\"focusout\", this.#focus_out_handler, {\n capture: true,\n });\n (this.parentElement as Container)?.close_up();\n this.remove();\n }\n\n /**Updates the position of the menu\n * @param x x coordinate for menu, this will be ignored if needed for contextmenu to fit\n * @param y y coordinate for menu, this will be ignored if needed for contextmenu to fit\n * @param element element to use instead of coordinates, the contextemenu will avoid covering the element if possible*/\n set_position(x: number = 0, y: number = 0, element?: Element) {\n this.#x = x;\n this.#y = y;\n this.#element = element;\n const box = this.getBoundingClientRect();\n const box_area = box.width * box.height;\n const window = this.ownerDocument.defaultView!;\n const html_area = window.innerWidth * window.innerHeight;\n this.closer = box_area > html_area * 0.5;\n let top = NaN;\n let bottom = NaN;\n let left = NaN;\n let right = NaN;\n if (element) {\n const sub_box = element.getBoundingClientRect();\n\n if (sub_box.x + sub_box.width + box.width > window.innerWidth) {\n x = sub_box.x;\n if (box.width < x) right = window.innerWidth - x;\n else right = window.innerWidth - (sub_box.x + sub_box.width);\n } else left = sub_box.x + sub_box.width;\n\n y = sub_box.y + sub_box.height;\n\n //Below the element, else above it, else as low as the window allows\n if (y + box.height < window.innerHeight) top = y;\n else if (sub_box.y >= box.height) bottom = window.innerHeight - sub_box.y;\n else top = Math.max(0, window.innerHeight - box.height);\n } else {\n if (y + box.height >= window.innerHeight) {\n if (y >= box.height) bottom = window.innerHeight - y;\n else top = window.innerHeight - box.height;\n } else top = y;\n\n if (box.width >= window.innerWidth) {\n right = 0;\n } else if (x + box.width >= window.innerWidth) {\n if (x >= box.width) right = window.innerWidth - x;\n else left = window.innerWidth - box.width;\n } else left = x;\n }\n this.fullscreenx = box.width === window.innerWidth;\n this.fullscreeny = box.height >= window.innerHeight;\n\n this.style.top = top === top ? top + \"px\" : \"\";\n this.style.bottom = bottom === bottom ? bottom + \"px\" : \"\";\n this.style.left = left === left ? left + \"px\" : \"\";\n this.style.right = right === right ? right + \"px\" : \"\";\n this.focus();\n }\n}\ndefine_element(ContextMenu);\n\nexport function context_menu(\n lines:\n | (\n | (ContextMenuLine | undefined)[]\n | Promise<(ContextMenuLine | undefined)[]>\n )\n | (() => (ContextMenuLine | undefined)[])\n | (() => Promise<(ContextMenuLine | undefined)[]>),\n): ContextMenu {\n return new ContextMenu(lines);\n}\n","import result, { none, some, type Option } from \"@chocbite/ts-lib/result\";\nimport { context_devider } from \"./devider\";\nimport type { ContextMenuLine } from \"./line\";\nimport { context_menu, ContextMenu } from \"./menu\";\n\ntype Lines = (ContextMenuLine | undefined)[];\n\n/**A group for ctm.combine, undefined for no group\n * - lines, undefined lines are skipped like in ctm.menu\n * - a menu, its lines are taken when the combined menu opens\n * - a function called every time the combined menu opens, giving lines, a menu, or an option of a menu like ctm.attach takes*/\nexport type ContextMenuGroup =\n | Lines\n | ContextMenu\n | (() => Lines | ContextMenu | Option<ContextMenu>)\n | undefined;\n\nfunction group_lines(group: ContextMenuGroup): Lines | Promise<Lines> {\n let value = typeof group === \"function\" ? group() : group;\n if (result.is_option(value)) value = value.unwrap_or(undefined);\n if (value instanceof ContextMenu) return value.read_lines();\n return value ?? [];\n}\n\n/**Joins groups with a devider between those with lines */\nfunction join(groups: Lines[]): ContextMenuLine[] {\n const lines: ContextMenuLine[] = [];\n for (const group of groups) {\n const group_lines = group.filter((line) => line !== undefined);\n if (group_lines.length === 0) continue;\n if (lines.length) lines.push(context_devider());\n lines.push(...group_lines);\n }\n return lines;\n}\n\n/**Combines groups of lines and menus into one menu with a devider between groups, built every time the menu opens\n * Empty groups are left out with their devider, and when all groups are empty there is no menu\n * A group with promised lines makes the combined menu wait for all groups, showing a spinner, it then always opens\n * Give the result to ctm.attach, or anything else taking a menu factory\n * @param groups groups in menu order, see ContextMenuGroup*/\nexport function context_combine(\n ...groups: ContextMenuGroup[]\n): () => Option<ContextMenu> {\n return () => {\n const parts = groups.map(group_lines);\n if (parts.some((part) => part instanceof Promise))\n return some(\n context_menu(\n Promise.all(parts.map((part) => Promise.resolve(part))).then(join),\n ),\n );\n const lines = join(parts as Lines[]);\n return lines.length ? some(context_menu(lines)) : none();\n };\n}\n","import { DOCUMENT_HANDLER } from \"#document\";\nimport type { Option } from \"@chocbite/ts-lib/result\";\nimport { Container } from \"./container\";\nimport \"./engine.scss\";\nimport { ContextMenu } from \"./menu\";\n\nexport const CONTEXT_MENY_SYMBOL = Symbol(\"context_menu\");\n\ndeclare global {\n interface Document {\n [CONTEXT_MENY_SYMBOL]: Container | undefined;\n }\n interface Element {\n [CONTEXT_MENY_SYMBOL]: EventListenerOrEventListenerObject | undefined;\n }\n}\n\n/**Default context menu, false blocks the operating system context menu, undefined leaves it*/\nlet default_menu: ContextMenu | (() => Option<ContextMenu>) | false | undefined;\n\n/**Blocks the operating system context menu when the default is false*/\nconst block_os_menu = (e: Event) => e.preventDefault();\n\nDOCUMENT_HANDLER.events.on(\"added\", (e) => {\n apply_to_doc(e.data);\n});\nDOCUMENT_HANDLER.for_documents((doc) => {\n apply_to_doc(doc);\n});\n\nfunction apply_to_doc(doc: Document) {\n const container = new Container();\n doc[CONTEXT_MENY_SYMBOL] = container;\n doc.documentElement.appendChild(container);\n apply_default_to_doc(doc);\n}\n\n/**Applies the current default context menu to a document*/\nfunction apply_default_to_doc(doc: Document) {\n const root = doc.documentElement;\n context_menu_detach(root);\n root.removeEventListener(\"contextmenu\", block_os_menu);\n if (default_menu) context_menu_attach(root, default_menu);\n else if (default_menu === false)\n root.addEventListener(\"contextmenu\", block_os_menu);\n}\n\n/**Attaches a context menu to the given element\n * @param element the element to attach the context menu to\n * @param lines the context menu to attach, if a function is given it will be called when the context menu is summoned\n * @param block a function that returns true if the context menu should not be summoned, if undefined the context menu will always be summoned*/\nexport function context_menu_attach(\n element: Element,\n lines: ContextMenu | (() => Option<ContextMenu>),\n block?: () => boolean,\n) {\n if (element[CONTEXT_MENY_SYMBOL]) context_menu_detach(element);\n const listener = (e: Event) => {\n e.preventDefault();\n e.stopPropagation();\n if (block && block()) return;\n const lineses =\n typeof lines === \"function\" ? lines().unwrap_or(undefined) : lines;\n if (!lineses) return;\n context_menu_summon(\n lineses,\n element,\n (e as MouseEvent).clientX,\n (e as MouseEvent).clientY,\n );\n };\n element.addEventListener(\"contextmenu\", listener);\n element[CONTEXT_MENY_SYMBOL] = listener;\n}\n\n/**Dettaches the context menu from the given element */\nexport function context_menu_detach(element: Element) {\n if (element[CONTEXT_MENY_SYMBOL]) {\n element.removeEventListener(\"contextmenu\", element[CONTEXT_MENY_SYMBOL]);\n delete element[CONTEXT_MENY_SYMBOL];\n }\n}\n\n/**Summons a context menu at a given location\n * @param menu the context menu to summon\n * @param element the element the context menu is referenced to, if undefined the context menu will appear in the main document\n * @param x x position for context menu, if undefined, will use element middle, if element undefined, will put context menu in the top left corner of the screen\n * @param y y position for context menu, if undefined, will use element middle, if element undefined, will put context menu in the top left corner of the screen\n * @param dont_cover when set true */\nexport function context_menu_summon(\n menu: ContextMenu,\n element?: Element,\n x?: number,\n y?: number,\n dont_cover?: boolean,\n) {\n const container = element\n ? element.ownerDocument[CONTEXT_MENY_SYMBOL]\n : DOCUMENT_HANDLER.main[CONTEXT_MENY_SYMBOL];\n if (container) {\n if (typeof x !== \"number\" || typeof y !== \"number\") {\n if (element) {\n const box = element.getBoundingClientRect();\n x = box.left + box.width / 2;\n y = box.top + box.height / 2;\n } else {\n x = 0;\n y = 0;\n }\n }\n container\n .attach_menu(menu)\n .set_position(x, y, dont_cover ? element : undefined);\n } else console.error(\"No context menu container available\");\n}\n\n/**Sets the default context menu for the page, the one used if no other context menu has been attached to the element\n * If set to false the operating system context menu is disabled and nothing will appear\n * If set undefined the operating systems context menu will be used*/\nexport function context_menu_default(\n lines: ContextMenu | (() => Option<ContextMenu>) | false | undefined,\n) {\n default_menu = lines;\n DOCUMENT_HANDLER.for_documents(apply_default_to_doc);\n}\n","import { context_combine } from \"./combine\";\nimport { context_devider } from \"./devider\";\nimport {\n context_menu_attach,\n context_menu_default,\n context_menu_detach,\n context_menu_summon,\n CONTEXT_MENY_SYMBOL,\n} from \"./engine\";\nimport { context_menu } from \"./menu\";\nimport { context_line } from \"./option\";\nimport { context_sub } from \"./submenu\";\n\nexport const ctm = {\n attach: context_menu_attach,\n default: context_menu_default,\n detach: context_menu_detach,\n summon: context_menu_summon,\n has(element: Element) {\n return Boolean(element[CONTEXT_MENY_SYMBOL]);\n },\n menu: context_menu,\n line: context_line,\n sub: context_sub,\n devider: context_devider,\n combine: context_combine,\n};\nexport default ctm;\n\nexport type { ContextMenuGroup } from \"./combine\";\nexport type { ContextMenu, ContextMenuLines } from \"./menu\";\n"],"mappings":";;;;;;;;;AAGA,MAAM,YAAY,yBAChB,eACA,gBACA,uDACF;AACA,UAAU,cACR,cACA,oBACA,uBACA,KAAK,OACL,KAAK,QACL,SACA,KAAA,CACF;AACA,UAAU,cACR,QACA,cACA,iBACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AACA,UAAU,cACR,SACA,eACA,kDACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AACA,UAAU,cACR,aACA,cACA,uBACA,KAAK,QACL,KAAK,OACL,SACA,KAAA,CACF;AACA,UAAU,cACR,UACA,gBACA,gCACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;;AC9CA,IAAsB,WAAtB,cAAuC,KAAgC;;CAErE,OAAO,eAAe;EACpB,OAAO;CACT;;CAEA,OAAO,qBAAqB;EAC1B,OAAO;CACT;;CAKA,IAAI,cAAc;EAChB,OAAO;CACT;;;CAIA,WAAW,WAAqB;EAC9B,MAAM,SAAS,KAAK;EACpB,IAAI,CAAC,QAAQ;EACb,IAAI,OAAO,YACP,KAAK,yBACL,KAAK;EACT,SAAS;GACP,SAAS,YAAY,OAAO,mBAAmB,OAAO;GAEtD,IAAI,CAAC,QAAQ,SAAS,MAAM;GAC5B,IAAI,CAAE,KAAkB,aACtB,OAAQ,KAAkB,SAAS,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AC,CACjB,aAAa,GAAG,GAAG,aAAa,UAAU,KAAA,CAAS;CACxD,OAAO,QAAQ,MAAM,qCAAqC;AAC5D;;;;AAKA,SAAgB,qBACd,OACA;CACA,eAAe;CACf,iBAAiB,cAAc,oBAAoB;AACrD;;AC/GA,MAAa,MAAM;CACjB,QAAQ;CACR,SAAS;CACT,QAAQ;CACR,QAAQ;CACR,IAAI,SAAkB;EACpB,OAAO,QAAQ,QAAQ,oBAAoB;CAC7C;CACA,MAAM;CACN,MAAM;CACN,KAAK;CACL,SAAS;CACT,SAAS;AACX"}
@@ -0,0 +1,60 @@
1
+ import '../style.css';
2
+ import { State, StateROS } from "@chocbite/ts-lib/state";
3
+ import { DepotChild, DepotEntry, DepotGroup } from "@chocbite/ts-lib/depot";
4
+ interface DepotSelectOptions<T> {
5
+ /**Single selects one entry, multi any number, single when undefined*/
6
+ mode?: "single" | "multi";
7
+ /**Only entries passing the filter are shown and can be selected, like only writable states.
8
+ * Groups with no shown entries below them are hidden*/
9
+ filter?: (entry: DepotEntry<T>) => boolean;
10
+ /**Entries selected when the selector opens*/
11
+ selected?: readonly DepotEntry<T>[];
12
+ /**Title of the selector, the name of the group when undefined*/
13
+ title?: string;
14
+ }
15
+ /**Opens a selector for the entries of a type or group, the promise gives the selected entries, none when cancelled.
16
+ * The selector follows the depot while it is open*/
17
+ declare function depot_select<T>(from: DepotGroup<T>, options?: DepotSelectOptions<T>): Promise<DepotEntry<T>[]>;
18
+ /**Kind of value a state holds, as far as it can be known at runtime*/
19
+ type DepotStateKind = "number" | "string" | "boolean" | "enum";
20
+ interface DepotStateSelectOptions {
21
+ /**Group of the states type to select from, all states when undefined*/
22
+ from?: DepotGroup<unknown>;
23
+ /**Single selects one state, multi any number, single when undefined*/
24
+ mode?: "single" | "multi";
25
+ /**Only writable states can be selected*/
26
+ writable?: boolean;
27
+ /**Only states of these kinds can be selected, states of unknown kind are hidden then*/
28
+ kind?: DepotStateKind | readonly DepotStateKind[];
29
+ /**Further filter on the entries, after writable and kind*/
30
+ filter?: (entry: DepotEntry<unknown>) => boolean;
31
+ /**States selected when the selector opens*/
32
+ selected?: readonly DepotEntry<unknown>[];
33
+ /**Title of the selector, the name of the group when undefined*/
34
+ title?: string;
35
+ }
36
+ /**Opens a selector for the states of the depot with their live values, the promise gives the selected entries, none when cancelled.
37
+ * The state of an entry is its value, entry.value*/
38
+ declare function depot_select_state(options?: DepotStateSelectOptions): Promise<DepotEntry<unknown>[]>;
39
+ /**A filtered view of a group and everything below it, following the children states of the depot.
40
+ * Entries are shown when they pass the filter and the search, groups when something below them is shown*/
41
+ export declare class DepotTree<T> {
42
+ #private;
43
+ constructor(root: DepotGroup<T>, filter?: (entry: DepotEntry<T>) => boolean);
44
+ /**Rows shown for a group, the root rows when no group is given*/
45
+ rows(group?: DepotGroup<T>): StateROS<DepotChild<T>[]>;
46
+ /**True while a search text is set, rows of groups should be open then*/
47
+ get searching(): boolean;
48
+ /**Text matched against the names and paths of entries, case insensitive*/
49
+ set search(text: string);
50
+ /**Drops the subscriptions to the depot*/
51
+ dispose(): void;
52
+ }
53
+ export declare const depot_ui: {
54
+ /**Opens a selector for the entries of a type or group, the promise gives the selected entries, none when cancelled*/
55
+ select: typeof depot_select;
56
+ /**Opens a selector for the states of the depot with their live values, the promise gives the selected entries, none when cancelled*/
57
+ select_state: typeof depot_select_state;
58
+ };
59
+ export { type DepotSelectOptions, type DepotStateKind, type DepotStateSelectOptions, depot_ui as default };
60
+ //# sourceMappingURL=index.d.mts.map