@chocbite/ts-lib-ui 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +609 -0
- package/README.md +0 -1
- package/SOURCE.md +17135 -0
- package/base/index.mjs +1 -1
- package/base/index.mjs.map +1 -1
- package/canvas/index.d.mts +114 -59
- package/canvas/index.mjs +661 -575
- package/canvas/index.mjs.map +1 -1
- package/context-menu/index.mjs +1 -1
- package/{context-menu-_9dMpC-H.mjs → context-menu-CA4o4fXx.mjs} +2 -2
- package/{context-menu-_9dMpC-H.mjs.map → context-menu-CA4o4fXx.mjs.map} +1 -1
- package/form/index.d.mts +1 -1
- package/form/index.mjs +4 -4
- package/{index-CzpbJoAj.d.mts → index-DCn7acFY.d.mts} +13 -4
- package/keyboard/index.mjs +1 -1
- package/list/index.d.mts +1 -1
- package/list/index.mjs +1 -1
- package/{list-Bkm9Ailw.mjs → list-CNYJ3sm-.mjs} +131 -21
- package/list-CNYJ3sm-.mjs.map +1 -0
- package/package.json +7 -7
- package/spinner/index.mjs +1 -1
- package/state_ui/index.mjs +2 -0
- package/{state-OCzEmq3j.mjs → state_ui-Bm3TeKNL.mjs} +3 -3
- package/state_ui-Bm3TeKNL.mjs.map +1 -0
- package/style.css +409 -135
- package/test/index.d.mts +98 -0
- package/test/index.mjs +193 -0
- package/test/index.mjs.map +1 -0
- package/theme/index.mjs +1 -1
- package/{theme-DlD5P5tY.mjs → theme-ChmpRObz.mjs} +2 -2
- package/{theme-DlD5P5tY.mjs.map → theme-ChmpRObz.mjs.map} +1 -1
- package/list-Bkm9Ailw.mjs.map +0 -1
- package/state/index.mjs +0 -2
- package/state-OCzEmq3j.mjs.map +0 -1
- package/viewport/index.d.mts +0 -1
- package/viewport/index.mjs +0 -2
- /package/{state → state_ui}/index.d.mts +0 -0
package/canvas/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["state"],"sources":["../../src/canvas/viewport_mover.ts","../../src/canvas/viewport.ts","../../src/canvas/viewport_element.ts","../../src/canvas/index.ts"],"sourcesContent":["import { node_clone } from \"#dom\";\nimport { material_autorenew_rounded } from \"#icons\";\nimport type { StateROS } from \"@chocbite/ts-lib/state\";\nimport { svg } from \"#svg\";\nimport { ViewportElement } from \"./viewport_element\";\nimport \"./viewport_mover.scss\";\n\nconst nw = svg.svg(32, 32, \"0 0 32 32\").cl(\"nw\").elem;\nnw.appendChild(svg.create(\"circle\").elem);\nnw.appendChild(svg.line(-8, -8, 8, 8).elem);\nnw.appendChild(svg.isosceles_triangle(-7, -7, 8, 6).rotate(-45, -7, -7).elem);\nnw.appendChild(svg.isosceles_triangle(7, 7, 8, 6).rotate(135, 7, 7).elem);\nconst ne = svg.svg(32, 32, \"0 0 32 32\").cl(\"ne\").elem;\nne.appendChild(svg.create(\"circle\").elem);\nne.appendChild(svg.line(-8, 8, 8, -8).elem);\nne.appendChild(svg.isosceles_triangle(-7, 7, 8, 6).rotate(-135, -7, 7).elem);\nne.appendChild(svg.isosceles_triangle(7, -7, 8, 6).rotate(45, 7, -7).elem);\nconst se = svg.svg(32, 32, \"0 0 32 32\").cl(\"se\").elem;\nse.appendChild(svg.create(\"circle\").elem);\nse.appendChild(svg.line(-8, -8, 8, 8).elem);\nse.appendChild(svg.isosceles_triangle(-7, -7, 8, 6).rotate(-45, -7, -7).elem);\nse.appendChild(svg.isosceles_triangle(7, 7, 8, 6).rotate(135, 7, 7).elem);\nconst sw = svg.svg(32, 32, \"0 0 32 32\").cl(\"sw\").elem;\nsw.appendChild(svg.create(\"circle\").elem);\nsw.appendChild(svg.line(-8, 8, 8, -8).elem);\nsw.appendChild(svg.isosceles_triangle(-7, 7, 8, 6).rotate(-135, -7, 7).elem);\nsw.appendChild(svg.isosceles_triangle(7, -7, 8, 6).rotate(45, 7, -7).elem);\nconst move = svg.svg(32, 32, \"0 0 32 32\").cl(\"move\").elem;\nmove.appendChild(svg.create(\"circle\").elem);\nmove.appendChild(svg.line(0, 8, 0, -8).elem);\nmove.appendChild(svg.isosceles_triangle(0, 10, 8, 6).rotate(180, 0, 10).elem);\nmove.appendChild(svg.isosceles_triangle(0, -10, 8, 6).rotate(0, 0, -10).elem);\nmove.appendChild(svg.line(-10, 0, 10, 0).elem);\nmove.appendChild(svg.isosceles_triangle(-10, 0, 8, 6).rotate(270, -10, 0).elem);\nmove.appendChild(svg.isosceles_triangle(10, 0, 8, 6).rotate(90, 10, 0).elem);\nconst rotate_sym = svg.svg(32, 32, \"0 0 32 32\").a(\"y\", \"-30\").cl(\"rotate\").elem;\nrotate_sym.appendChild(svg.create(\"circle\").elem);\nrotate_sym.appendChild(\n svg.attr(material_autorenew_rounded()).a(\"x\", \"-12\").a(\"y\", \"-12\")\n .elem,\n);\nconst rotation_center_indicator = svg\n .svg(16, 16, \"0 0 16 16\")\n .cl(\"rotation-center\").elem;\nrotation_center_indicator.appendChild(svg.create(\"circle\").elem);\nrotation_center_indicator.appendChild(svg.line(-6, 0, 6, 0).elem);\nrotation_center_indicator.appendChild(svg.line(0, -6, 0, 6).elem);\n\nconst DEG_TO_RAD = Math.PI / 180;\n\n/**Rounds the value to the grid, a grid of 0 does not snap*/\nconst snap = (value: number, grid: number) =>\n grid ? Math.round(value / grid) * grid : value;\n\n/**Stops a handle following the pointer, for pointerup and pointercancel*/\nconst handle_release = (ev: PointerEvent) => {\n const handle = ev.currentTarget as SVGSVGElement;\n if (handle.hasPointerCapture(ev.pointerId))\n handle.releasePointerCapture(ev.pointerId);\n handle.onpointermove = null;\n};\n\nexport class ViewportMover {\n #canvas: SVGSVGElement = svg.create(\"svg\").cl(\"viewport-mover\").elem;\n #outline = this.#canvas.appendChild(\n svg.rectangle_from_corner(-1, -1, 1, 1, 0).elem,\n );\n #nw_corner = this.#canvas.appendChild(node_clone(nw));\n #ne_corner = this.#canvas.appendChild(node_clone(ne));\n #sw_corner = this.#canvas.appendChild(node_clone(sw));\n #se_corner = this.#canvas.appendChild(node_clone(se));\n #move = this.#canvas.appendChild(node_clone(move));\n #rotate = this.#canvas.appendChild(node_clone(rotate_sym));\n #rc_indicator = this.#canvas.appendChild(\n node_clone(rotation_center_indicator),\n );\n #scale_buffer = 1;\n #grid_x_buffer = 1;\n #grid_y_buffer = 1;\n #grid_rotate_buffer = 0;\n\n constructor(\n scale: StateROS<number>,\n grid_x: StateROS<number>,\n grid_y: StateROS<number>,\n grid_rotate: StateROS<number>,\n ) {\n scale.sub((val) => {\n this.#scale_buffer = val.value;\n const s = `scale(${1 / val.value})`;\n this.#nw_corner.setAttribute(\"transform\", s);\n this.#ne_corner.setAttribute(\"transform\", s);\n this.#sw_corner.setAttribute(\"transform\", s);\n this.#se_corner.setAttribute(\"transform\", s);\n this.#move.setAttribute(\"transform\", s);\n this.#rotate.setAttribute(\"transform\", s);\n this.#rc_indicator.setAttribute(\"transform\", s);\n }, true);\n grid_x.sub((val) => {\n this.#grid_x_buffer = val.value;\n }, true);\n grid_y.sub((val) => {\n this.#grid_y_buffer = val.value;\n }, true);\n grid_rotate.sub((val) => {\n this.#grid_rotate_buffer = val.value;\n }, true);\n this.#setup_position();\n this.#setup_corner(this.#nw_corner, -1, -1);\n this.#setup_corner(this.#ne_corner, 1, -1);\n this.#setup_corner(this.#sw_corner, -1, 1);\n this.#setup_corner(this.#se_corner, 1, 1);\n this.#setup_rotation();\n }\n #update_mover_transform() {\n if (this.#rotation === 0) {\n this.#canvas.removeAttribute(\"transform\");\n } else {\n const cx = this.#position_x + this.#rotation_center_x;\n const cy = this.#position_y + this.#rotation_center_y;\n this.#canvas.setAttribute(\n \"transform\",\n `rotate(${this.#rotation} ${cx} ${cy})`,\n );\n }\n }\n\n #element?: ViewportElement;\n /**Element the mover is attached to*/\n get element(): ViewportElement | undefined {\n return this.#element;\n }\n attach_to_element(element: ViewportElement, canvas: SVGSVGElement) {\n // Clear the old element reference first so the property setters below\n // don't propagate the new element's values back to the previous element.\n this.#element = undefined;\n this.#canvas.setAttribute(\"x\", element.position_x.toString());\n this.#canvas.setAttribute(\"y\", element.position_y.toString());\n this.width = element.width;\n this.height = element.height;\n this.position_x = element.position_x;\n this.position_y = element.position_y;\n this.#rotation = element.rotation;\n this.#rotation_center_x = element.rotation_center_x;\n this.#rotation_center_y = element.rotation_center_y;\n this.#update_rc_indicator();\n this.#element = element;\n this.#update_mover_transform();\n canvas.appendChild(this.#canvas);\n }\n\n detach_from_element() {\n this.#element = undefined;\n this.#canvas.remove();\n }\n // _____ ____ _____ _____ _______ _____ ____ _ _\n // | __ \\ / __ \\ / ____|_ _|__ __|_ _/ __ \\| \\ | |\n // | |__) | | | | (___ | | | | | || | | | \\| |\n // | ___/| | | |\\___ \\ | | | | | || | | | . ` |\n // | | | |__| |____) |_| |_ | | _| || |__| | |\\ |\n // |_| \\____/|_____/|_____| |_| |_____\\____/|_| \\_|\n #setup_position() {\n this.#move.onpointerdown = (e) => {\n e.preventDefault();\n e.stopPropagation();\n if (!this.#element) return;\n this.#move.setPointerCapture(e.pointerId);\n const x = this.#position_x;\n const y = this.#position_y;\n const offset_x = e.offsetX;\n const offset_y = e.offsetY;\n this.#move.onpointermove = (ev) => {\n if (this.#element) {\n const pos_x = (ev.offsetX - offset_x) / this.#scale_buffer + x;\n this.position_x = ev.shiftKey\n ? pos_x\n : snap(pos_x, this.#grid_x_buffer);\n const pos_y = (ev.offsetY - offset_y) / this.#scale_buffer + y;\n this.position_y = ev.shiftKey\n ? pos_y\n : snap(pos_y, this.#grid_y_buffer);\n }\n };\n };\n this.#move.onpointerup = handle_release;\n this.#move.onpointercancel = handle_release;\n }\n\n #position_x = 0;\n set position_x(value: number) {\n this.#canvas.setAttribute(\"x\", String(value));\n this.#position_x = value;\n if (this.#element) this.#element.position_x = value;\n this.#update_mover_transform();\n }\n\n #position_y = 0;\n set position_y(value: number) {\n this.#canvas.setAttribute(\"y\", String(value));\n this.#position_y = value;\n if (this.#element) this.#element.position_y = value;\n this.#update_mover_transform();\n }\n\n // _____ ____ _______ _______ _____ ____ _ _\n // | __ \\ / __ \\__ __|/\\|__ __|_ _/ __ \\| \\ | |\n // | |__) | | | | | | / \\ | | | || | | | \\| |\n // | _ /| | | | | | / /\\ \\ | | | || | | | . ` |\n // | | \\ \\| |__| | | |/ ____ \\| | _| || |__| | |\\ |\n // |_| \\_\\\\____/ |_/_/ \\_\\_| |_____\\____/|_| \\_|\n #setup_rotation() {\n this.#rotate.onpointerdown = (e) => {\n e.preventDefault();\n e.stopPropagation();\n if (!this.#element) return;\n this.#rotate.setPointerCapture(e.pointerId);\n const ctm = this.#canvas.getScreenCTM();\n if (!ctm) return;\n // Use the rotation center as the angle reference so the mover and\n // element both rotate around the same point without position shifts.\n const center = new DOMPoint(\n this.#rotation_center_x,\n this.#rotation_center_y,\n ).matrixTransform(ctm);\n const initial_angle = Math.atan2(\n e.clientY - center.y,\n e.clientX - center.x,\n );\n const initial_rotation = this.#rotation;\n this.#rotate.onpointermove = (ev) => {\n if (!this.#element) return;\n const current_angle = Math.atan2(\n ev.clientY - center.y,\n ev.clientX - center.x,\n );\n const raw_rotation =\n initial_rotation + (current_angle - initial_angle) / DEG_TO_RAD;\n this.rotation = ev.shiftKey\n ? raw_rotation\n : snap(raw_rotation, this.#grid_rotate_buffer);\n };\n };\n this.#rotate.onpointerup = handle_release;\n this.#rotate.onpointercancel = handle_release;\n }\n #update_rc_indicator() {\n this.#rc_indicator.setAttribute(\"x\", String(this.#rotation_center_x));\n this.#rc_indicator.setAttribute(\"y\", String(this.#rotation_center_y));\n this.#rc_indicator.setAttribute(\n \"transform-origin\",\n `${this.#rotation_center_x} ${this.#rotation_center_y}`,\n );\n }\n\n #rotation = 0;\n set rotation(value: number) {\n this.#rotation = value;\n if (this.#element) this.#element.rotation = value;\n this.#update_mover_transform();\n }\n\n #rotation_center_x = 0;\n #rotation_center_y = 0;\n\n // _____ _____ ____________\n // / ____|_ _|___ / ____|\n // | (___ | | / /| |__\n // \\___ \\ | | / / | __|\n // ____) |_| |_ / /__| |____\n // |_____/|_____/_____|______|\n #setup_corner(handle: SVGSVGElement, sx: number, sy: number) {\n handle.onpointerdown = (e) => {\n e.preventDefault();\n e.stopPropagation();\n if (!this.#element) return;\n handle.setPointerCapture(e.pointerId);\n const initial_x = e.clientX;\n const initial_y = e.clientY;\n const initial_w = this.#width;\n const initial_h = this.#height;\n const initial_px = this.#position_x;\n const initial_py = this.#position_y;\n const initial_rcx = this.#rotation_center_x;\n const initial_rcy = this.#rotation_center_y;\n const rad = this.#rotation * DEG_TO_RAD;\n const cos_r = Math.cos(rad);\n const sin_r = Math.sin(rad);\n handle.onpointermove = (ev) => {\n if (!this.#element) return;\n const canvas_dx = (ev.clientX - initial_x) / this.#scale_buffer;\n const canvas_dy = (ev.clientY - initial_y) / this.#scale_buffer;\n const local_dx = cos_r * canvas_dx + sin_r * canvas_dy;\n const local_dy = -sin_r * canvas_dx + cos_r * canvas_dy;\n let new_w = Math.max(1, initial_w + sx * local_dx);\n let new_h = Math.max(1, initial_h + sy * local_dy);\n if (!ev.shiftKey) {\n new_w = Math.round(new_w);\n new_h = Math.round(new_h);\n }\n const new_rcx =\n initial_w > 0 ? initial_rcx * (new_w / initial_w) : initial_rcx;\n const new_rcy =\n initial_h > 0 ? initial_rcy * (new_h / initial_h) : initial_rcy;\n const drc_x = initial_rcx - new_rcx;\n const drc_y = initial_rcy - new_rcy;\n const delta_w = new_w - initial_w;\n const delta_h = new_h - initial_h;\n let new_px = initial_px;\n let new_py = initial_py;\n if (sx < 0) {\n new_px -= delta_w * cos_r;\n new_py -= delta_w * sin_r;\n }\n if (sy < 0) {\n new_px += delta_h * sin_r;\n new_py -= delta_h * cos_r;\n }\n // Compensate position for the rotation pivot change so the\n // anchor corner stays visually fixed on a rotated element.\n new_px += drc_x * (1 - cos_r) + drc_y * sin_r;\n new_py += -drc_x * sin_r + drc_y * (1 - cos_r);\n this.#rotation_center_x = new_rcx;\n this.#rotation_center_y = new_rcy;\n if (this.#element) {\n this.#element.rotation_center_x = new_rcx;\n this.#element.rotation_center_y = new_rcy;\n }\n this.#update_rc_indicator();\n this.width = new_w;\n this.height = new_h;\n this.position_x = new_px;\n this.position_y = new_py;\n };\n };\n handle.onpointerup = handle_release;\n handle.onpointercancel = handle_release;\n }\n\n #width = 0;\n set width(value: number) {\n this.#outline.setAttribute(\"width\", (value + 2).toString());\n this.#ne_corner.setAttribute(\"x\", String(value));\n this.#ne_corner.setAttribute(\"transform-origin\", `${value} 0`);\n this.#se_corner.setAttribute(\"x\", String(value));\n this.#se_corner.setAttribute(\n \"transform-origin\",\n `${value} ${this.#height}`,\n );\n this.#move.setAttribute(\"x\", String(value / 2));\n this.#move.setAttribute(\n \"transform-origin\",\n `${value / 2} ${this.#height / 2}`,\n );\n this.#rotate.setAttribute(\"x\", String(value / 2));\n this.#rotate.setAttribute(\"transform-origin\", `${value / 2} 0`);\n this.#width = value;\n if (this.#element) this.#element.width = value;\n }\n #height = 0;\n set height(value: number) {\n this.#outline.setAttribute(\"height\", (value + 2).toString());\n this.#sw_corner.setAttribute(\"y\", String(value));\n this.#sw_corner.setAttribute(\"transform-origin\", `0 ${value}`);\n this.#se_corner.setAttribute(\"y\", String(value));\n this.#se_corner.setAttribute(\"transform-origin\", `${this.#width} ${value}`);\n this.#move.setAttribute(\"y\", String(value / 2));\n this.#move.setAttribute(\n \"transform-origin\",\n `${this.#width / 2} ${value / 2}`,\n );\n this.#height = value;\n if (this.#element) this.#element.height = value;\n }\n}\n","import { Base, define_element } from \"#base\";\nimport { sync_resolve } from \"@chocbite/ts-lib/common\";\nimport { ok } from \"@chocbite/ts-lib/result\";\nimport type { State, StateInferSub } from \"@chocbite/ts-lib/state\";\nimport { state } from \"@chocbite/ts-lib/state\";\nimport state_ui from \"#state\";\nimport { svg } from \"#svg\";\nimport \"./viewport.scss\";\nimport type { ViewportElement } from \"./viewport_element\";\nimport { ViewportMover } from \"./viewport_mover\";\n\nexport class Viewport extends Base {\n static element_name(): string {\n return \"viewport\";\n }\n static element_name_space(): string {\n return \"editor\";\n }\n\n #viewport_width: number = 0;\n #viewport_width_half: number = 0;\n #viewport_height: number = 0;\n #viewport_height_half: number = 0;\n #resize_observer = new ResizeObserver((a) => {\n this.#viewport_width = a[0].contentRect.width;\n this.#viewport_width_half = this.#viewport_width / 2;\n this.#viewport_height = a[0].contentRect.height;\n this.#viewport_height_half = this.#viewport_height / 2;\n //The pan is relative to the center, so the canvas stays centered\n this.#pan_coordinates(this.#pan_x.ok(), this.#pan_y.ok());\n this.#root.setAttribute(\n \"viewBox\",\n `0 0 ${this.#viewport_width} ${this.#viewport_height}`,\n );\n });\n #root = this.appendChild(svg.create(\"svg\").elem);\n #panner;\n #zoomer;\n\n /**Detaches the mover when clicking outside the viewport*/\n #outside_pointerdown = (e: PointerEvent) => {\n if (!this.contains(e.target as Node)) this.#detach_mover();\n };\n /**Detaches the mover when the browser window loses focus*/\n #window_blur = () => this.#detach_mover();\n /**Document the listeners are attached to, while connected*/\n #listening_document?: Document;\n\n protected connectedCallback() {\n super.connectedCallback();\n this.#listening_document = this.ownerDocument;\n this.#listening_document.addEventListener(\n \"pointerdown\",\n this.#outside_pointerdown,\n );\n this.#listening_document.defaultView?.addEventListener(\n \"blur\",\n this.#window_blur,\n );\n }\n\n protected disconnectedCallback() {\n super.disconnectedCallback();\n this.#listening_document?.removeEventListener(\n \"pointerdown\",\n this.#outside_pointerdown,\n );\n this.#listening_document?.defaultView?.removeEventListener(\n \"blur\",\n this.#window_blur,\n );\n this.#listening_document = undefined;\n }\n\n constructor(\n canvas_width: number,\n canvas_height: number,\n infinite_canvas: boolean = false,\n ) {\n super();\n this.#resize_observer.observe(this);\n this.#canvas_width = canvas_width;\n this.#canvas_height = canvas_height;\n //Panning\n this.#panner = this.#root.appendChild(\n svg\n .create(\"svg\")\n .a(\"width\", canvas_width.toString())\n .a(\"height\", canvas_height.toString()).elem,\n );\n //Zoomer\n this.#zoomer = this.#panner.appendChild(\n svg\n .create(\"svg\")\n .a(\"x\", \"-50%\")\n .a(\"y\", \"-50%\")\n .a(\"width\", canvas_width.toString())\n .a(\"height\", canvas_height.toString()).elem,\n );\n //Background\n (infinite_canvas ? this.#root : this.#zoomer).prepend(\n svg\n .create(\"rect\")\n .attribute(\"x\", \"0\")\n .attribute(\"y\", \"0\")\n .attribute(\"width\", \"100%\")\n .attribute(\"height\", \"100%\")\n .fill(\"white\").elem,\n );\n //Canvas\n this.#canvas = this.#zoomer.appendChild(\n svg.svg(\n canvas_width,\n canvas_height,\n `0 0 ${canvas_width} ${canvas_height}`,\n ).elem,\n );\n this.#canvas_elements = this.#canvas.appendChild(svg.create(\"g\").elem);\n\n // _____ _ _ _______ ______ _____ _____ _______ _____ ____ _ _\n // |_ _| \\ | |__ __| ____| __ \\ /\\ / ____|__ __|_ _/ __ \\| \\ | |\n // | | | \\| | | | | |__ | |__) | / \\ | | | | | || | | | \\| |\n // | | | . ` | | | | __| | _ / / /\\ \\| | | | | || | | | . ` |\n // _| |_| |\\ | | | | |____| | \\ \\ / ____ \\ |____ | | _| || |__| | |\\ |\n // |_____|_| \\_| |_| |______|_| \\_\\/_/ \\_\\_____| |_| |_____\\____/|_| \\_|\n\n let count = 0;\n let mover_x = 0;\n let mover_y = 0;\n let initial_x = 0;\n let initial_y = 0;\n let initial_id = 0;\n // let second_initial_x = 0;\n // let second_initial_y = 0;\n let second_initial_id = 0;\n\n //Middle Mouse\n let double_click = 0;\n this.addEventListener(\"pointerdown\", (e) => {\n if (e.pointerType === \"mouse\" || e.pointerType === \"touch\") {\n e.preventDefault();\n e.stopPropagation();\n\n // Element selection: detect clicks on the mover or viewport elements\n const target = e.target as Element;\n if (target.closest(\".viewport-mover\")) return;\n const elementCanvas = target.closest(\".viewport-element\");\n if (elementCanvas) {\n const element = this.#elements.find(\n (el) => el.canvas === elementCanvas,\n );\n if (element) {\n this.attach_mover(element);\n return;\n }\n }\n this.#detach_mover();\n\n //Double Click Reset Position\n const now = performance.now();\n if (now - double_click < 300) {\n this.#pan_coordinates(0, 0);\n this.#zoom_coordinates(\n Math.min(\n this.#viewport_height / this.#canvas_height,\n this.#viewport_width / this.#canvas_width,\n ),\n 0,\n 0,\n );\n return;\n }\n double_click = now;\n //Dragging\n this.setPointerCapture(e.pointerId);\n if (count === 0) {\n mover_x = this.#pan_x.ok();\n mover_y = this.#pan_y.ok();\n initial_x = e.offsetX;\n initial_y = e.offsetY;\n initial_id = e.pointerId;\n } else if (count === 1) {\n // second_initial_x = e.offsetX;\n // second_initial_y = e.offsetY;\n second_initial_id = e.pointerId;\n }\n count++;\n }\n });\n this.onpointermove = (ev) => {\n if (count === 0) return;\n if (ev.pointerId === initial_id) {\n this.#pan_coordinates(\n mover_x + (ev.offsetX - initial_x) / count,\n mover_y + (ev.offsetY - initial_y) / count,\n );\n } else if (ev.pointerId === second_initial_id) {\n if (count < 2) return;\n this.#pan_coordinates(\n mover_x + (ev.offsetX - initial_x) / count,\n mover_y + (ev.offsetY - initial_y) / count,\n );\n }\n };\n this.onpointerup = (ev) => {\n if (this.hasPointerCapture(ev.pointerId)) {\n this.releasePointerCapture(ev.pointerId);\n count--;\n }\n };\n //The browser can take over a touch, for example for a system gesture, which ends it without pointerup\n this.onpointercancel = this.onpointerup;\n //Wheel\n this.addEventListener(\n \"wheel\",\n (e) => {\n e.preventDefault();\n e.stopPropagation();\n const move_scale = e.shiftKey\n ? e.altKey\n ? 0.01\n : 0.05\n : e.altKey\n ? 2\n : 0.5;\n if (e.ctrlKey) {\n this.#pan_coordinates(\n undefined,\n this.#pan_y.ok() - e.deltaY * move_scale,\n );\n } else {\n const scale_scale = e.shiftKey\n ? e.altKey\n ? 0.00005\n : 0.0001\n : e.altKey\n ? 0.005\n : 0.001;\n const scale = this.#zoom.ok() * (1 - e.deltaY * scale_scale);\n this.#zoom_coordinates(\n scale,\n e.offsetX - this.#viewport_width / 2,\n e.offsetY - this.#viewport_height / 2,\n );\n }\n this.#pan_coordinates(\n this.#pan_x.ok() - e.deltaX * move_scale,\n undefined,\n );\n },\n { capture: true },\n );\n }\n\n #pan_coordinates(x?: number, y?: number) {\n if (x !== undefined) {\n this.#panner.setAttribute(\n \"x\",\n (this.#viewport_width_half + x).toFixed(0),\n );\n this.#pan_x.set_ok(x);\n }\n if (y !== undefined) {\n this.#panner.setAttribute(\n \"y\",\n (this.#viewport_height_half + y).toFixed(0),\n );\n this.#pan_y.set_ok(y);\n }\n }\n\n /**Zooms coordinate aware to offset canvas position so hover position stays\n * coordinates are relative to the center */\n #zoom_coordinates(scale: number, x: number, y: number) {\n scale = Math.max(0.001, Math.min(10000, scale));\n const zoom_factor = scale / this.#zoom.ok();\n this.#pan_coordinates(\n this.#pan_x.ok() * zoom_factor + x * (1 - zoom_factor),\n this.#pan_y.ok() * zoom_factor + y * (1 - zoom_factor),\n );\n this.#zoomer.style.scale = scale.toString();\n this.#zoom.set_ok(scale);\n }\n\n // _____ _ ___ __ _____\n // / ____| /\\ | \\ | \\ \\ / /\\ / ____|\n // | | / \\ | \\| |\\ \\ / / \\ | (___\n // | | / /\\ \\ | . ` | \\ \\/ / /\\ \\ \\___ \\\n // | |____ / ____ \\| |\\ | \\ / ____ \\ ____) |\n // \\_____/_/ \\_\\_| \\_| \\/_/ \\_\\_____/\n #canvas;\n #canvas_width;\n #canvas_height;\n #canvas_elements;\n\n set canvas_width(value: number) {\n this.#canvas.setAttribute(\"width\", value.toString());\n this.#canvas.setAttribute(\"viewBox\", `0 0 ${value} ${this.#canvas_height}`);\n this.#zoomer.setAttribute(\"width\", value.toString());\n this.#canvas_width = value;\n }\n get canvas_width(): number {\n return this.#canvas_width;\n }\n set canvas_height(value: number) {\n this.#canvas.setAttribute(\"height\", value.toString());\n this.#canvas.setAttribute(\"viewBox\", `0 0 ${this.#canvas_width} ${value}`);\n this.#zoomer.setAttribute(\"height\", value.toString());\n this.#canvas_height = value;\n }\n get canvas_height(): number {\n return this.#canvas_height;\n }\n\n #pan_x = state.rosw(ok(0), (value) => {\n return sync_resolve(ok(this.#pan_coordinates(value, undefined)));\n });\n readonly pan_x = this.#pan_x.read_write;\n\n #pan_y = state.rosw(ok(0), (value) => {\n return sync_resolve(ok(this.#pan_coordinates(undefined, value)));\n });\n readonly pan_y = this.#pan_y.read_write;\n\n #zoom = state.rosw(ok(1), (value) =>\n sync_resolve(ok(this.#zoom_coordinates(value, 0, 0))),\n );\n readonly zoom = this.#zoom.read_write;\n\n // _____ _____ _____ _____\n // / ____| __ \\|_ _| __ \\\n // | | __| |__) | | | | | | |\n // | | |_ | _ / | | | | | |\n // | |__| | | \\ \\ _| |_| |__| |\n // \\_____|_| \\_\\_____|_____/\n #grid_x = state.rosw(ok(10), (value) => {\n this.#grid_x.set_ok(value);\n return sync_resolve(ok(undefined));\n });\n readonly grid_x = this.#grid_x.read_write;\n\n #grid_y = state.rosw(ok(10), (value) => {\n this.#grid_y.set_ok(value);\n return sync_resolve(ok(undefined));\n });\n readonly grid_y = this.#grid_y.read_write;\n\n #grid_rotate = state.rosw(ok(15), (value) => {\n this.#grid_rotate.set_ok(value);\n return sync_resolve(ok(undefined));\n });\n readonly grid_rotate = this.#grid_rotate.read_write;\n\n // ______ _ ______ __ __ ______ _ _ _______ _____\n // | ____| | | ____| \\/ | ____| \\ | |__ __/ ____|\n // | |__ | | | |__ | \\ / | |__ | \\| | | | | (___\n // | __| | | | __| | |\\/| | __| | . ` | | | \\___ \\\n // | |____| |____| |____| | | | |____| |\\ | | | ____) |\n // |______|______|______|_| |_|______|_| \\_| |_| |_____/\n #elements: readonly ViewportElement[] = [];\n #state_sub?: StateInferSub<State<ViewportElement[]>>;\n\n set elements(elements: ViewportElement[] | State<ViewportElement[]>) {\n if (this.#state_sub) {\n this.detach_state(this.#state_sub);\n this.#state_sub = undefined;\n }\n if (state.is.state(elements)) {\n this.#state_sub = this.attach_state(elements, (r) =>\n this.#update_rows(r.ok ? r.value : []),\n );\n } else this.#update_rows(elements);\n }\n\n #update_rows(rows: readonly ViewportElement[]) {\n this.#elements = rows;\n //Each element owns its canvas node, so changed elements replace their node\n state_ui.a.apply(this.#canvas_elements, rows, {\n create: (element) => element.canvas,\n });\n const moved = this.#mover?.element;\n if (moved && !rows.includes(moved)) this.#detach_mover();\n }\n\n // __ __ ______ ________ _____\n // | \\/ |/ __ \\ \\ / / ____| __ \\\n // | \\ / | | | \\ \\ / /| |__ | |__) |\n // | |\\/| | | | |\\ \\/ / | __| | _ /\n // | | | | |__| | \\ / | |____| | \\ \\\n // |_| |_|\\____/ \\/ |______|_| \\_\\\n #mover?: ViewportMover;\n\n attach_mover(move: ViewportElement) {\n (this.#mover ??= new ViewportMover(\n this.#zoom,\n this.#grid_x,\n this.#grid_y,\n this.#grid_rotate,\n )).attach_to_element(move, this.#canvas);\n }\n\n #detach_mover() {\n this.#mover?.detach_from_element();\n }\n}\ndefine_element(Viewport);\n\nexport function create_viewport(\n canvas_width: number,\n canvas_height: number,\n infinite_canvas: boolean = false,\n): Viewport {\n return new Viewport(canvas_width, canvas_height, infinite_canvas);\n}\n","import { some, type Option } from \"@chocbite/ts-lib/result\";\nimport { svg } from \"#svg\";\n\nexport abstract class ViewportElement {\n protected abstract element_name(): string;\n protected abstract element_name_space(): string;\n\n /**Default width of element when created */\n abstract default_width(): number;\n /**Default height of element when created */\n abstract default_height(): number;\n /**Element optimal ratio, returns the ratio where the element has no distortion.\n * If the element can dynamically change based on ratio, return none. */\n optimal_ratio(): Option<number> {\n const w = this.default_width();\n const h = this.default_height();\n if (w === 0 || h === 0) return some(0);\n return some(w / h);\n }\n\n /**Called when the element has no optimal ratio and its dimensions change.\n * Descendants can override this to re-layout their content in the new\n * coordinate space defined by the updated viewBox. */\n protected on_resize(_width: number, _height: number): void {}\n\n readonly canvas: SVGSVGElement = svg\n .svg(\n this.default_width(),\n this.default_height(),\n `0 0 ${this.default_width()} ${this.default_height()}`,\n )\n .cl(\n \"viewport-element\",\n `${this.element_name_space()}-${this.element_name()}`,\n ).elem;\n\n constructor() {\n // When the element has an optimal ratio, set preserveAspectRatio to \"none\"\n // so that non-uniform scaling (stretching) is applied when the display\n // dimensions deviate from the optimal ratio.\n if (this.optimal_ratio().some) {\n this.canvas.setAttribute(\"preserveAspectRatio\", \"none\");\n }\n }\n\n // _____ ____ _____ _____ _______ _____ ____ _ _\n // | __ \\ / __ \\ / ____|_ _|__ __|_ _/ __ \\| \\ | |\n // | |__) | | | | (___ | | | | | || | | | \\| |\n // | ___/| | | |\\___ \\ | | | | | || | | | . ` |\n // | | | |__| |____) |_| |_ | | _| || |__| | |\\ |\n // |_| \\____/|_____/|_____| |_| |_____\\____/|_| \\_|\n #position_x = 0;\n #position_y = 0;\n\n set position_x(value: number) {\n this.#position_x = value;\n this.canvas.setAttribute(\"x\", value.toString());\n this.#update_transform();\n }\n get position_x(): number {\n return this.#position_x;\n }\n\n set position_y(value: number) {\n this.#position_y = value;\n this.canvas.setAttribute(\"y\", value.toString());\n this.#update_transform();\n }\n get position_y(): number {\n return this.#position_y;\n }\n\n // _____ ____ _______ _______ _____ ____ _ _\n // | __ \\ / __ \\__ __|/\\|__ __|_ _/ __ \\| \\ | |\n // | |__) | | | | | | / \\ | | | || | | | \\| |\n // | _ /| | | | | | / /\\ \\ | | | || | | | . ` |\n // | | \\ \\| |__| | | |/ ____ \\| | _| || |__| | |\\ |\n // |_| \\_\\\\____/ |_/_/ \\_\\_| |_____\\____/|_| \\_|\n #rotation = 0;\n #rotation_center_x = this.default_width() / 2;\n #rotation_center_y = this.default_height() / 2;\n\n set rotation(value: number) {\n this.#rotation = value;\n this.#update_transform();\n }\n get rotation(): number {\n return this.#rotation;\n }\n\n /**Rotation center x coordinate, relative to the element's display area.\n * Defaults to half of default_width (center of element). */\n set rotation_center_x(value: number) {\n this.#rotation_center_x = value;\n this.#update_transform();\n }\n get rotation_center_x(): number {\n return this.#rotation_center_x;\n }\n\n /**Rotation center y coordinate, relative to the element's display area.\n * Defaults to half of default_height (center of element). */\n set rotation_center_y(value: number) {\n this.#rotation_center_y = value;\n this.#update_transform();\n }\n get rotation_center_y(): number {\n return this.#rotation_center_y;\n }\n\n #update_transform() {\n if (this.#rotation === 0) {\n this.canvas.removeAttribute(\"transform\");\n } else {\n const cx = this.#position_x + this.#rotation_center_x;\n const cy = this.#position_y + this.#rotation_center_y;\n this.canvas.setAttribute(\n \"transform\",\n `rotate(${this.#rotation} ${cx} ${cy})`,\n );\n }\n }\n\n // _____ _____ ____________\n // / ____|_ _|___ / ____|\n // | (___ | | / /| |__\n // \\___ \\ | | / / | __|\n // ____) |_| |_ / /__| |____\n // |_____/|_____/_____|______|\n #width = this.default_width();\n #height = this.default_height();\n\n /**Display width of the element. Changing this scales the element.\n * - If the element has an optimal_ratio, the viewBox stays at default\n * dimensions and the SVG content is stretched/scaled to fill the new size.\n * - If the element has no optimal_ratio, the viewBox is updated to match\n * the new dimensions and on_resize is called. */\n set width(value: number) {\n this.#width = value;\n this.#apply_size();\n }\n get width(): number {\n return this.#width;\n }\n\n /**Display height of the element. Changing this scales the element.\n * - If the element has an optimal_ratio, the viewBox stays at default\n * dimensions and the SVG content is stretched/scaled to fill the new size.\n * - If the element has no optimal_ratio, the viewBox is updated to match\n * the new dimensions and on_resize is called. */\n set height(value: number) {\n this.#height = value;\n this.#apply_size();\n }\n get height(): number {\n return this.#height;\n }\n\n #apply_size() {\n this.canvas.setAttribute(\"width\", this.#width.toString());\n this.canvas.setAttribute(\"height\", this.#height.toString());\n\n if (this.optimal_ratio().none) {\n // No optimal ratio: update the coordinate system to match the new\n // display size and notify the descendant so it can re-layout.\n this.canvas.setAttribute(\"viewBox\", `0 0 ${this.#width} ${this.#height}`);\n this.on_resize(this.#width, this.#height);\n }\n // When an optimal ratio exists the viewBox stays at the default\n // dimensions. preserveAspectRatio=\"none\" ensures the content is\n // stretched/scaled to fill the (possibly non-uniform) display size.\n }\n}\n","import { create_viewport } from \"./viewport\";\nexport { ViewportElement } from \"./viewport_element\";\n\nexport const viewport = {\n create_viewport,\n};\n"],"mappings":";;;;;;;;;;AAOA,MAAM,KAAK,IAAI,IAAI,IAAI,IAAI,WAAW,CAA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,cAAc,GACrB,KAAK,OAAO,gBAAgB,WAAW;OAClC;GACL,MAAM,KAAK,KAAK,cAAc,KAAK;GACnC,MAAM,KAAK,KAAK,cAAc,KAAK;GACnC,KAAK,OAAO,aACV,aACA,UAAU,KAAK,UAAU,GAAG,GAAG,GAAG,GAAG,EACvC;EACF;CACF;CAQA,SAAS,KAAK,cAAc;CAC5B,UAAU,KAAK,eAAe;;;;;;CAO9B,IAAI,MAAM,OAAe;EACvB,KAAK,SAAS;EACd,KAAK,YAAY;CACnB;CACA,IAAI,QAAgB;EAClB,OAAO,KAAK;CACd;;;;;;CAOA,IAAI,OAAO,OAAe;EACxB,KAAK,UAAU;EACf,KAAK,YAAY;CACnB;CACA,IAAI,SAAiB;EACnB,OAAO,KAAK;CACd;CAEA,cAAc;EACZ,KAAK,OAAO,aAAa,SAAS,KAAK,OAAO,SAAS,CAAC;EACxD,KAAK,OAAO,aAAa,UAAU,KAAK,QAAQ,SAAS,CAAC;EAE1D,IAAI,KAAK,cAAc,CAAC,CAAC,MAAM;GAG7B,KAAK,OAAO,aAAa,WAAW,OAAO,KAAK,OAAO,GAAG,KAAK,SAAS;GACxE,KAAK,UAAU,KAAK,QAAQ,KAAK,OAAO;EAC1C;CAIF;AACF;;ACzKA,MAAa,WAAW,EACtB,gBACF"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/canvas/shared.ts","../../src/canvas/page.ts","../../src/canvas/widget.ts","../../src/canvas/transformer.ts","../../src/canvas/viewport.ts","../../src/canvas/index.ts"],"sourcesContent":["import { BLUE, GREY } from \"@chocbite/ts-lib/colors\";\nimport { theme_init_variable_root } from \"#theme\";\n\nconst theme_root = theme_init_variable_root(\n \"canvas\",\n \"Canvas\",\n \"Theme variables for canvas viewports and pages\",\n);\n\n// _____ ____ _ ____ _____ _____\n// / ____/ __ \\| | / __ \\| __ \\ / ____|\n// | | | | | | | | | | | |__) | (___\n// | | | | | | | | | | | _ / \\___ \\\n// | |___| |__| | |___| |__| | | \\ \\ ____) |\n// \\_____\\____/|______\\____/|_| \\_\\_____/\nconst colors = theme_root.make_sub_group(\n \"colors\",\n \"Colors\",\n \"Colors used in viewports\",\n);\ncolors.make_variable(\n \"background\",\n \"Background Color\",\n \"Color of the viewport around the page\",\n GREY[\"300\"],\n GREY[\"900\"],\n \"Color\",\n undefined,\n);\ncolors.make_variable(\n \"pageBackground\",\n \"Page Background Color\",\n \"Color of the page behind the widgets\",\n GREY[\"50\"],\n GREY[\"800\"],\n \"Color\",\n undefined,\n);\n\n// ______ _____ _____ _______\n// | ____| __ \\_ _|__ __|\n// | |__ | | | || | | |\n// | __| | | | || | | |\n// | |____| |__| || |_ | |\n// |______|_____/_____| |_|\nconst edit = theme_root.make_sub_group(\n \"edit\",\n \"Edit\",\n \"Settings for viewports in edit mode\",\n);\nedit.make_variable(\n \"checker1\",\n \"Checkerboard First Color\",\n \"First color of the checkerboard shown behind the page in edit mode\",\n GREY[\"300\"],\n GREY[\"600\"],\n \"Color\",\n undefined,\n);\nedit.make_variable(\n \"checker2\",\n \"Checkerboard Second Color\",\n \"Second color of the checkerboard shown behind the page in edit mode\",\n GREY[\"200\"],\n GREY[\"700\"],\n \"Color\",\n undefined,\n);\nedit.make_variable(\n \"checkerSize\",\n \"Checkerboard Square Size\",\n \"Size of one square of the checkerboard shown behind the page in edit mode\",\n \"0.625rem\",\n \"0.625rem\",\n \"Length\",\n { min: 0.1, max: 10 },\n);\n\n// _______ _____ _ _ _____ ______ ____ _____ __ __ ______ _____\n// |__ __| __ \\ /\\ | \\ | |/ ____| ____/ __ \\| __ \\| \\/ | ____| __ \\\n// | | | |__) | / \\ | \\| | (___ | |__ | | | | |__) | \\ / | |__ | |__) |\n// | | | _ / / /\\ \\ | . ` |\\___ \\| __|| | | | _ /| |\\/| | __| | _ /\n// | | | | \\ \\ / ____ \\| |\\ |____) | | | |__| | | \\ \\| | | | |____| | \\ \\\n// |_| |_| \\_\\/_/ \\_\\_| \\_|_____/|_| \\____/|_| \\_\\_| |_|______|_| \\_\\\nconst transformer = theme_root.make_sub_group(\n \"transformer\",\n \"Transformer\",\n \"Settings for the transformer used to move, resize and rotate widgets in edit mode\",\n);\ntransformer.make_variable(\n \"color\",\n \"Transformer Color\",\n \"Color of the transformer outline and handle borders\",\n BLUE[\"600\"],\n BLUE[\"300\"],\n \"Color\",\n undefined,\n);\ntransformer.make_variable(\n \"handleBackground\",\n \"Handle Background Color\",\n \"Background color of the transformer handles\",\n GREY[\"50\"],\n GREY[\"900\"],\n \"Color\",\n undefined,\n);\n","import { Base, define_element } from \"#base\";\nimport \"./page.scss\";\nimport \"./shared\";\nimport type { WidgetBase } from \"./widget\";\n\n/**Page of widgets with a fixed size\n * Width and height are the size of the page in page units (px before any viewport scaling)*/\nexport class Page extends Base {\n /**Returns the name used to define the element */\n static element_name() {\n return \"page\";\n }\n /**Returns the namespace override for the element*/\n static element_name_space() {\n return \"canvas\";\n }\n\n #width: number = 1920;\n #height: number = 1080;\n #widgets: readonly WidgetBase[] = [];\n\n constructor() {\n super();\n this.style.width = this.#width + \"px\";\n this.style.height = this.#height + \"px\";\n }\n\n /**Sets the width of the page */\n set width(width: number) {\n this.#width = width;\n this.style.width = width + \"px\";\n }\n /**Returns the width of the page */\n get width(): number {\n return this.#width;\n }\n\n /**Sets the height of the page */\n set height(height: number) {\n this.#height = height;\n this.style.height = height + \"px\";\n }\n /**Returns the height of the page */\n get height(): number {\n return this.#height;\n }\n\n /**Sets the widgets on the page, the array order is the drawing order with the last widget on top\n * Widgets already on the page are kept in place, so they are only reconnected if their order changes */\n set widgets(widgets: readonly WidgetBase[]) {\n const keep = new Set(widgets);\n for (const widget of this.#widgets)\n if (!keep.has(widget) && widget.parentElement === this) widget.remove();\n for (let i = 0; i < widgets.length; i++) {\n const current = this.children[i];\n if (current !== widgets[i])\n this.insertBefore(widgets[i], current ?? null);\n }\n this.#widgets = widgets;\n }\n /**Returns the widgets on the page */\n get widgets(): readonly WidgetBase[] {\n return this.#widgets;\n }\n}\ndefine_element(Page);\n\nexport interface CanvasPageOptions {\n /**Width of the page in page units, defaults to 1920 */\n width?: number;\n /**Height of the page in page units, defaults to 1080 */\n height?: number;\n /**Widgets on the page, the last widget is drawn on top */\n widgets?: readonly WidgetBase[];\n}\n\n/**Creates a page of widgets with a fixed size */\nexport const canvas_page = (options?: CanvasPageOptions): Page =>\n options ? new Page().opts(options) : new Page();\n","import { Base } from \"#base\";\n\n/**Event dispatched on a widget when its position, size or rotation changes */\nexport const WIDGET_TRANSFORM_EVENT = \"widget_transform\";\n\n/**Shared class for widgets placed at a fixed position in a viewport\n * Position and size are in viewport units (px before any viewport scaling)\n * Rotation is in degrees clockwise around the center of the widget\n *\n * Width and height must always be set, they default to 0\n *\n * Widgets declare their original size, which is the size their content is laid out at\n * The content is then scaled from the original size to the width and height of the widget\n * Widgets that should not stretch, like text, return width and height as their original size\n *\n * WIDGET_TRANSFORM_EVENT is dispatched whenever position, size or rotation changes*/\nexport abstract class WidgetBase extends Base {\n /**Returns the name used to define the element, Abstract classes should return @abstract@ */\n static element_name() {\n return \"@abstract@\";\n }\n /**Returns the namespace override for the element*/\n static element_name_space() {\n return \"canvas\";\n }\n\n #x: number = 0;\n #y: number = 0;\n #width: number = 0;\n #height: number = 0;\n #rotation: number = 0;\n\n constructor() {\n super();\n this.style.position = \"absolute\";\n this.style.boxSizing = \"border-box\";\n this.style.transformOrigin = \"0 0\";\n }\n\n protected connectedCallback(): void {\n super.connectedCallback();\n this.#update();\n }\n\n /**Returns the width the content of the widget is laid out at, return this.width to not stretch */\n abstract get original_width(): number;\n /**Returns the height the content of the widget is laid out at, return this.height to not stretch */\n abstract get original_height(): number;\n\n /**Sets the x position of the left edge of the widget */\n set x(x: number) {\n this.#x = x;\n this.#update();\n }\n /**Returns the x position of the left edge of the widget */\n get x(): number {\n return this.#x;\n }\n\n /**Sets the y position of the top edge of the widget */\n set y(y: number) {\n this.#y = y;\n this.#update();\n }\n /**Returns the y position of the top edge of the widget */\n get y(): number {\n return this.#y;\n }\n\n /**Sets the width of the widget */\n set width(width: number) {\n this.#width = width;\n this.#update();\n }\n /**Returns the width of the widget */\n get width(): number {\n return this.#width;\n }\n\n /**Sets the height of the widget */\n set height(height: number) {\n this.#height = height;\n this.#update();\n }\n /**Returns the height of the widget */\n get height(): number {\n return this.#height;\n }\n\n /**Sets the rotation of the widget in degrees, rotating clockwise around the center of the widget */\n set rotation(rotation: number) {\n this.#rotation = rotation;\n this.#update();\n }\n /**Returns the rotation of the widget in degrees */\n get rotation(): number {\n return this.#rotation;\n }\n\n #update() {\n const width = this.#width;\n const height = this.#height;\n const layout_width = this.original_width;\n const layout_height = this.original_height;\n const scale_x = layout_width > 0 ? width / layout_width : 1;\n const scale_y = layout_height > 0 ? height / layout_height : 1;\n this.style.left = this.#x + \"px\";\n this.style.top = this.#y + \"px\";\n this.style.width = layout_width + \"px\";\n this.style.height = layout_height + \"px\";\n //Scale the layout box to the widget size, then rotate around the center of the widget size\n this.style.transform = `translate(${width / 2}px, ${height / 2}px) rotate(${this.#rotation}deg) translate(${-width / 2}px, ${-height / 2}px) scale(${scale_x}, ${scale_y})`;\n this.dispatchEvent(new Event(WIDGET_TRANSFORM_EVENT));\n }\n}\n","import { Base, define_element } from \"#base\";\nimport {\n material_arrow_range_rounded,\n material_open_with_rounded,\n material_rotate_right_rounded,\n} from \"#icons\";\nimport type { SVGFunc } from \"#svg\";\nimport \"./shared\";\nimport \"./transformer.scss\";\nimport { WIDGET_TRANSFORM_EVENT, type WidgetBase } from \"./widget\";\n\n/**Smallest width and height a widget can be resized to */\nconst MIN_SIZE = 1;\n/**Grid positions and sizes snap to, and the finer grid used while alt is held */\nconst SNAP_GRID = 5;\nconst SNAP_GRID_FINE = 1;\n/**Angle in degrees rotation snaps to, and the finer angle used while alt is held */\nconst SNAP_ANGLE = 15;\nconst SNAP_ANGLE_FINE = 5;\n\n/**Rounds the value to the nearest multiple of step, a step of 0 returns the value unchanged */\nfunction snap(value: number, step: number): number {\n if (step <= 0) return value;\n return Math.round(value / step) * step;\n}\n\n/**Resize handles, x and y is the edge they move, -1 is the left or top edge, 1 the right or bottom edge, 0 none */\nconst RESIZE_HANDLES = [\n { name: \"nw\", x: -1, y: -1 },\n { name: \"n\", x: 0, y: -1 },\n { name: \"ne\", x: 1, y: -1 },\n { name: \"e\", x: 1, y: 0 },\n { name: \"se\", x: 1, y: 1 },\n { name: \"s\", x: 0, y: 1 },\n { name: \"sw\", x: -1, y: 1 },\n { name: \"w\", x: -1, y: 0 },\n];\n\ntype Action =\n | { type: \"move\" }\n | { type: \"resize\"; x: number; y: number }\n | { type: \"rotate\" };\n\n/**State of the widget and pointer when a drag started */\ninterface Drag {\n action: Action;\n pointer_id: number;\n /**Client position of the origin of the view, which is what offset is relative to */\n origin_x: number;\n origin_y: number;\n /**Point on the page that was pressed */\n page_x: number;\n page_y: number;\n /**Angle from the center of the widget to the point that was pressed, used for rotation */\n angle: number;\n /**Latest pointer event of the drag, undefined until the pointer has moved */\n last: PointerEvent | undefined;\n x: number;\n y: number;\n width: number;\n height: number;\n rotation: number;\n}\n\n/**Dashed outline with handles, attached to a widget to move, resize and rotate it\n * Corner handles resize both axes and side handles one axis, keeping the opposite corner or side in place\n * The handle above the outline rotates the widget around its center\n * The center handle and the outline itself move the widget, the inside of the outline is left to the widgets below\n *\n * Position and size snap to a 5px grid and rotation to 15 degrees\n * Holding alt snaps to a 1px grid and 5 degrees instead, holding shift disables snapping\n *\n * Resize and rotate cursors follow the rotation of the widget in 45 degree steps\n *\n * The transformer is drawn in viewport pixels, so it keeps its size when the page is zoomed*/\nexport class Transformer extends Base {\n /**Returns the name used to define the element */\n static element_name() {\n return \"transformer\";\n }\n /**Returns the namespace override for the element*/\n static element_name_space() {\n return \"canvas\";\n }\n\n #widget: WidgetBase | undefined;\n #offset_x: number = 0;\n #offset_y: number = 0;\n #scale: number = 1;\n #actions = new Map<Element, Action>();\n #drag: Drag | undefined;\n\n constructor() {\n super();\n this.hidden = true;\n for (const side of [\"top\", \"right\", \"bottom\", \"left\"])\n this.#add(\"side \" + side, { type: \"move\" });\n this.#add(\"line\", undefined);\n for (const handle of RESIZE_HANDLES)\n this.#add(\n \"handle \" + handle.name,\n { type: \"resize\", x: handle.x, y: handle.y },\n material_arrow_range_rounded,\n );\n this.#add(\n \"handle rotate\",\n { type: \"rotate\" },\n material_rotate_right_rounded,\n );\n //Added last so it is drawn on top of the other handles on small widgets\n this.#add(\"handle move\", { type: \"move\" }, material_open_with_rounded);\n this.addEventListener(\"pointerdown\", this.#on_pointer_down);\n }\n\n protected disconnectedCallback(): void {\n super.disconnectedCallback();\n this.#stop_drag();\n }\n\n /**Sets the widget the transformer is attached to, undefined hides the transformer */\n set widget(widget: WidgetBase | undefined) {\n if (this.#widget === widget) return;\n this.#stop_drag();\n this.#widget?.removeEventListener(\n WIDGET_TRANSFORM_EVENT,\n this.#on_widget_transform,\n );\n this.#widget = widget;\n widget?.addEventListener(WIDGET_TRANSFORM_EVENT, this.#on_widget_transform);\n this.#update();\n }\n /**Returns the widget the transformer is attached to */\n get widget(): WidgetBase | undefined {\n return this.#widget;\n }\n\n /**Returns whether a handle is being dragged */\n get dragging(): boolean {\n return this.#drag !== undefined;\n }\n\n /**Sets how page units map to viewport pixels, viewport = offset + page * scale\n * During a drag the widget is moved so the grabbed point stays under the pointer */\n view(offset_x: number, offset_y: number, scale: number) {\n this.#offset_x = offset_x;\n this.#offset_y = offset_y;\n this.#scale = scale;\n this.#update();\n if (this.#drag?.last) this.#apply_drag(this.#drag, this.#drag.last);\n }\n\n #add(class_name: string, action: Action | undefined, icon?: SVGFunc) {\n const element = this.appendChild(document.createElement(\"div\"));\n element.className = class_name;\n if (icon) element.appendChild(icon());\n if (action) this.#actions.set(element, action);\n }\n\n #update() {\n const widget = this.#widget;\n this.hidden = !widget;\n if (!widget) return;\n const scale = this.#scale;\n this.style.left = this.#offset_x + widget.x * scale + \"px\";\n this.style.top = this.#offset_y + widget.y * scale + \"px\";\n this.style.width = widget.width * scale + \"px\";\n this.style.height = widget.height * scale + \"px\";\n this.style.transform = `rotate(${widget.rotation}deg)`;\n //Cursors only exist in 45 degree steps repeating every 180 degrees, the stylesheet picks the cursors from the closest step\n const half_turn = ((widget.rotation % 180) + 180) % 180;\n this.setAttribute(\"cursor-step\", String(Math.round(half_turn / 45) % 4));\n }\n\n #start(action: Action, e: PointerEvent) {\n const widget = this.#widget;\n if (!widget || this.#drag) return;\n e.preventDefault();\n e.stopPropagation();\n //The bounding box of the rotated outline is centered on the widget center\n const rect = this.getBoundingClientRect();\n const center_x = rect.left + rect.width / 2;\n const center_y = rect.top + rect.height / 2;\n const scale = this.#scale;\n const origin_x =\n center_x - this.#offset_x - (widget.x + widget.width / 2) * scale;\n const origin_y =\n center_y - this.#offset_y - (widget.y + widget.height / 2) * scale;\n this.#drag = {\n action,\n pointer_id: e.pointerId,\n origin_x,\n origin_y,\n page_x: (e.clientX - origin_x - this.#offset_x) / scale,\n page_y: (e.clientY - origin_y - this.#offset_y) / scale,\n angle: Math.atan2(e.clientY - center_y, e.clientX - center_x),\n last: undefined,\n x: widget.x,\n y: widget.y,\n width: widget.width,\n height: widget.height,\n rotation: widget.rotation,\n };\n window.addEventListener(\"pointermove\", this.#on_pointer_move);\n window.addEventListener(\"pointerup\", this.#on_pointer_up);\n window.addEventListener(\"pointercancel\", this.#on_pointer_up);\n }\n\n #stop_drag() {\n if (!this.#drag) return;\n this.#drag = undefined;\n window.removeEventListener(\"pointermove\", this.#on_pointer_move);\n window.removeEventListener(\"pointerup\", this.#on_pointer_up);\n window.removeEventListener(\"pointercancel\", this.#on_pointer_up);\n }\n\n #on_widget_transform = () => {\n this.#update();\n };\n\n #on_pointer_down = (e: PointerEvent) => {\n const action =\n e.target instanceof Element ? this.#actions.get(e.target) : undefined;\n //Other buttons are left to the viewport, so middle mouse still pans\n if (!action || e.button !== 0) return;\n this.#start(action, e);\n };\n\n #on_pointer_move = (e: PointerEvent) => {\n const drag = this.#drag;\n if (!drag || e.pointerId !== drag.pointer_id) return;\n drag.last = e;\n this.#apply_drag(drag, e);\n };\n\n #on_pointer_up = (e: PointerEvent) => {\n if (e.pointerId === this.#drag?.pointer_id) this.#stop_drag();\n };\n\n /**Updates the widget from the pointer event and the current view */\n #apply_drag(drag: Drag, e: PointerEvent) {\n const widget = this.#widget;\n const scale = this.#scale;\n //A viewport without a size has a scale of 0, which has no page position\n if (!widget || scale <= 0) return;\n const view_x = drag.origin_x + this.#offset_x;\n const view_y = drag.origin_y + this.#offset_y;\n //Pointer movement in page units\n const delta_x = (e.clientX - view_x) / scale - drag.page_x;\n const delta_y = (e.clientY - view_y) / scale - drag.page_y;\n const grid = e.shiftKey ? 0 : e.altKey ? SNAP_GRID_FINE : SNAP_GRID;\n const action = drag.action;\n switch (action.type) {\n case \"move\":\n widget.x = snap(drag.x + delta_x, grid);\n widget.y = snap(drag.y + delta_y, grid);\n break;\n case \"resize\": {\n const radians = (drag.rotation * Math.PI) / 180;\n const cos = Math.cos(radians);\n const sin = Math.sin(radians);\n //Pointer movement in the unrotated frame of the widget\n const local_x = delta_x * cos + delta_y * sin;\n const local_y = delta_y * cos - delta_x * sin;\n const width = action.x\n ? Math.max(MIN_SIZE, snap(drag.width + action.x * local_x, grid))\n : drag.width;\n const height = action.y\n ? Math.max(MIN_SIZE, snap(drag.height + action.y * local_y, grid))\n : drag.height;\n //Move the center by half the size change, so the opposite corner or side stays in place\n const shift_x = (action.x * (width - drag.width)) / 2;\n const shift_y = (action.y * (height - drag.height)) / 2;\n const center_x =\n drag.x + drag.width / 2 + shift_x * cos - shift_y * sin;\n const center_y =\n drag.y + drag.height / 2 + shift_x * sin + shift_y * cos;\n widget.x = center_x - width / 2;\n widget.y = center_y - height / 2;\n widget.width = width;\n widget.height = height;\n break;\n }\n case \"rotate\": {\n const now = Math.atan2(\n e.clientY - (view_y + (drag.y + drag.height / 2) * scale),\n e.clientX - (view_x + (drag.x + drag.width / 2) * scale),\n );\n const rotation = snap(\n drag.rotation + ((now - drag.angle) * 180) / Math.PI,\n e.shiftKey ? 0 : e.altKey ? SNAP_ANGLE_FINE : SNAP_ANGLE,\n );\n widget.rotation = ((rotation % 360) + 360) % 360;\n break;\n }\n }\n }\n}\ndefine_element(Transformer);\n","import { Base, define_element } from \"#base\";\nimport type { Page } from \"./page\";\nimport \"./shared\";\nimport { Transformer } from \"./transformer\";\nimport \"./viewport.scss\";\nimport type { WidgetBase } from \"./widget\";\n\nconst ZOOM_MIN = 0.1;\nconst ZOOM_MAX = 20;\n/**Zoom factor per wheel pixel */\nconst WHEEL_ZOOM_SPEED = 0.002;\n/**Zoom factor per wheel pixel for touchpad pinch, which reports much smaller deltas than a mouse wheel */\nconst PINCH_ZOOM_SPEED = 0.01;\n/**Screen pixels panned per wheel pixel */\nconst WHEEL_PAN_SPEED = 0.5;\n/**Pixels per line, for wheel events reported in lines */\nconst WHEEL_LINE_HEIGHT = 16;\n/**Speed multiplier for wheel zoom and pan while alt is held */\nconst WHEEL_SLOW = 0.1;\n\n/**Viewport showing a page of widgets\n * The page is scaled to fit inside the viewport element while keeping its aspect ratio, and centered\n *\n * When edit is true the page can be zoomed and panned, and a checkerboard is shown behind it\n * Wheel and touchpad two finger swipe pans, ctrl + wheel or swipe zooms toward the cursor\n * Shift + vertical wheel pans horizontally\n * Touchpad pinch zooms toward the cursor\n * Holding alt makes wheel zoom and pan 10 times slower\n * Two finger touch pinch zooms and pans, middle or right mouse drag pans\n *\n * Pressing a widget in edit mode selects it and attaches a transformer to move, resize and rotate it\n * Pressing outside any widget clears the selection*/\nexport class Viewport extends Base {\n /**Returns the name used to define the element */\n static element_name() {\n return \"viewport\";\n }\n /**Returns the namespace override for the element*/\n static element_name_space() {\n return \"canvas\";\n }\n\n #background: HTMLDivElement = this.appendChild(\n document.createElement(\"div\"),\n );\n #container: HTMLDivElement = this.appendChild(document.createElement(\"div\"));\n #transformer: Transformer = this.appendChild(new Transformer());\n #page: Page | undefined;\n #page_observer = new ResizeObserver(() => {\n this.#update_view();\n });\n #scale: number = 1;\n #fit_x: number = 0;\n #fit_y: number = 0;\n #edit: boolean = false;\n #zoom: number = 1;\n #pan_x: number = 0;\n #pan_y: number = 0;\n #touches = new Map<number, { x: number; y: number }>();\n #pan_pointer_id: number | undefined;\n #pan_pointer_last = { x: 0, y: 0 };\n /**Whether the ctrl key is physically held, to tell touchpad pinch from ctrl + wheel */\n #ctrl_held: boolean = false;\n\n constructor() {\n super();\n this.#background.className = \"checkerboard\";\n this.#container.className = \"container\";\n this.attach_to_resize_observer();\n }\n\n /**Sets the page shown in the viewport */\n set page(page: Page | undefined) {\n if (this.#page === page) return;\n this.selected = undefined;\n if (this.#page) {\n this.#page_observer.unobserve(this.#page);\n if (this.#page.parentElement === this.#container) this.#page.remove();\n }\n this.#page = page;\n if (page) {\n this.#container.appendChild(page);\n this.#page_observer.observe(page);\n }\n this.#update_view();\n }\n /**Returns the page shown in the viewport */\n get page(): Page | undefined {\n return this.#page;\n }\n\n /**Sets edit mode, which enables zooming and panning and shows a checkerboard background\n * Leaving edit mode resets the view to fit the page */\n set edit(edit: boolean) {\n if (this.#edit === edit) return;\n this.#edit = edit;\n this.toggleAttribute(\"edit\", edit);\n this.#listen_keys(edit && this.isConnected);\n if (edit) {\n this.addEventListener(\"wheel\", this.#on_wheel, { passive: false });\n this.addEventListener(\"pointerdown\", this.#on_pointer_down);\n this.addEventListener(\"pointermove\", this.#on_pointer_move);\n this.addEventListener(\"pointerup\", this.#on_pointer_up);\n this.addEventListener(\"pointercancel\", this.#on_pointer_up);\n this.addEventListener(\"mousedown\", this.#on_mouse_down);\n this.addEventListener(\"contextmenu\", this.#on_context_menu);\n } else {\n this.removeEventListener(\"wheel\", this.#on_wheel);\n this.removeEventListener(\"pointerdown\", this.#on_pointer_down);\n this.removeEventListener(\"pointermove\", this.#on_pointer_move);\n this.removeEventListener(\"pointerup\", this.#on_pointer_up);\n this.removeEventListener(\"pointercancel\", this.#on_pointer_up);\n this.removeEventListener(\"mousedown\", this.#on_mouse_down);\n this.removeEventListener(\"contextmenu\", this.#on_context_menu);\n this.#touches.clear();\n this.#pan_pointer_id = undefined;\n this.selected = undefined;\n this.#zoom = 1;\n this.#pan_x = 0;\n this.#pan_y = 0;\n this.#update_view();\n }\n }\n /**Returns whether edit mode is enabled */\n get edit(): boolean {\n return this.#edit;\n }\n\n /**Sets the selected widget, which the transformer is attached to, selection is cleared when leaving edit mode */\n set selected(widget: WidgetBase | undefined) {\n this.#transformer.widget = widget;\n }\n /**Returns the selected widget */\n get selected(): WidgetBase | undefined {\n return this.#transformer.widget;\n }\n\n /**Returns the current scale from page units to screen pixels */\n get scale(): number {\n return this.#scale;\n }\n\n protected on_resize(): void {\n this.#update_view();\n }\n\n protected connectedCallback(): void {\n super.connectedCallback();\n if (this.#edit) this.#listen_keys(true);\n }\n\n protected disconnectedCallback(): void {\n super.disconnectedCallback();\n this.#listen_keys(false);\n }\n\n /**Adds or removes the window listeners tracking the ctrl key */\n #listen_keys(listen: boolean) {\n if (listen) {\n window.addEventListener(\"keydown\", this.#on_key);\n window.addEventListener(\"keyup\", this.#on_key);\n window.addEventListener(\"blur\", this.#on_blur);\n } else {\n window.removeEventListener(\"keydown\", this.#on_key);\n window.removeEventListener(\"keyup\", this.#on_key);\n window.removeEventListener(\"blur\", this.#on_blur);\n this.#ctrl_held = false;\n }\n }\n\n #update_view() {\n if (!this.#page) return;\n const width = this.#page.width;\n const height = this.#page.height;\n if (width <= 0 || height <= 0) return;\n const rect = this.actual_size;\n const fit = Math.min(rect.width / width, rect.height / height);\n this.#fit_x = (rect.width - width * fit) / 2;\n this.#fit_y = (rect.height - height * fit) / 2;\n this.#scale = fit * this.#zoom;\n this.#container.style.transform = `translate(${this.#fit_x + this.#pan_x}px, ${this.#fit_y + this.#pan_y}px) scale(${this.#scale})`;\n this.#transformer.view(\n this.#fit_x + this.#pan_x,\n this.#fit_y + this.#pan_y,\n this.#scale,\n );\n }\n\n /**Zooms by the factor, keeping the given point in viewport coordinates in place */\n #zoom_at(x: number, y: number, factor: number) {\n const zoom = Math.min(ZOOM_MAX, Math.max(ZOOM_MIN, this.#zoom * factor));\n const ratio = zoom / this.#zoom;\n this.#pan_x += (x - this.#fit_x - this.#pan_x) * (1 - ratio);\n this.#pan_y += (y - this.#fit_y - this.#pan_y) * (1 - ratio);\n this.#zoom = zoom;\n }\n\n /**Returns the position of the event in viewport coordinates */\n #local(e: MouseEvent): { x: number; y: number } {\n const rect = this.getBoundingClientRect();\n return { x: e.clientX - rect.left, y: e.clientY - rect.top };\n }\n\n /**Selects the widget under the pointer, or clears the selection if there is none */\n #select_at(e: PointerEvent) {\n const page = this.#page;\n let element = e.target instanceof Element ? e.target : null;\n while (element && element.parentElement !== page)\n element = element.parentElement;\n this.selected = page?.widgets.find((widget) => widget === element);\n }\n\n /**Returns center and distance of the first two touches */\n #pinch(): { x: number; y: number; distance: number } | undefined {\n if (this.#touches.size < 2) return undefined;\n const [a, b] = this.#touches.values();\n return {\n x: (a.x + b.x) / 2,\n y: (a.y + b.y) / 2,\n distance: Math.hypot(a.x - b.x, a.y - b.y),\n };\n }\n\n #on_wheel = (e: WheelEvent) => {\n e.preventDefault();\n const unit =\n e.deltaMode === WheelEvent.DOM_DELTA_LINE\n ? WHEEL_LINE_HEIGHT\n : e.deltaMode === WheelEvent.DOM_DELTA_PAGE\n ? this.actual_size.height\n : 1;\n const delta_x = e.deltaX * unit;\n const delta_y = e.deltaY * unit;\n const speed = e.altKey ? WHEEL_SLOW : 1;\n if (e.ctrlKey) {\n //Browsers report touchpad pinch as ctrl + wheel, without the ctrl key being held\n const zoom_speed = this.#ctrl_held ? WHEEL_ZOOM_SPEED : PINCH_ZOOM_SPEED;\n const point = this.#local(e);\n this.#zoom_at(point.x, point.y, Math.exp(-delta_y * zoom_speed * speed));\n } else {\n //Shift makes the vertical wheel pan horizontally, some browsers already swap the deltas themselves\n const swap = e.shiftKey && delta_x === 0;\n this.#pan_x -= (swap ? delta_y : delta_x) * speed * WHEEL_PAN_SPEED;\n this.#pan_y -= (swap ? 0 : delta_y) * speed * WHEEL_PAN_SPEED;\n }\n this.#update_view();\n };\n\n #on_pointer_down = (e: PointerEvent) => {\n if (e.pointerType === \"touch\") {\n //Only the first touch selects, so a second finger can pinch without changing the selection\n if (this.#touches.size === 0 && !this.#transformer.dragging)\n this.#select_at(e);\n this.#touches.set(e.pointerId, this.#local(e));\n this.setPointerCapture(e.pointerId);\n } else if (e.button === 0) {\n this.#select_at(e);\n } else if (e.button === 1 || e.button === 2) {\n e.preventDefault();\n this.#pan_pointer_id = e.pointerId;\n this.#pan_pointer_last = this.#local(e);\n this.setPointerCapture(e.pointerId);\n }\n };\n\n #on_pointer_move = (e: PointerEvent) => {\n this.#ctrl_held = e.ctrlKey;\n if (this.#touches.has(e.pointerId)) {\n const before = this.#pinch();\n this.#touches.set(e.pointerId, this.#local(e));\n const after = this.#pinch();\n if (!before || !after || before.distance <= 0) return;\n this.#pan_x += after.x - before.x;\n this.#pan_y += after.y - before.y;\n this.#zoom_at(after.x, after.y, after.distance / before.distance);\n this.#update_view();\n } else if (e.pointerId === this.#pan_pointer_id) {\n const point = this.#local(e);\n this.#pan_x += point.x - this.#pan_pointer_last.x;\n this.#pan_y += point.y - this.#pan_pointer_last.y;\n this.#pan_pointer_last = point;\n this.#update_view();\n }\n };\n\n #on_pointer_up = (e: PointerEvent) => {\n this.#touches.delete(e.pointerId);\n if (e.pointerId === this.#pan_pointer_id) this.#pan_pointer_id = undefined;\n };\n\n /**Prevents the browser autoscroll on middle mouse button */\n #on_mouse_down = (e: MouseEvent) => {\n if (e.button === 1) e.preventDefault();\n };\n\n /**Prevents the context menu, as the right mouse button pans in edit mode */\n #on_context_menu = (e: MouseEvent) => {\n e.preventDefault();\n };\n\n #on_key = (e: KeyboardEvent) => {\n this.#ctrl_held = e.ctrlKey;\n };\n\n #on_blur = () => {\n this.#ctrl_held = false;\n };\n}\ndefine_element(Viewport);\n\nexport interface CanvasViewportOptions {\n /**Page shown in the viewport */\n page?: Page;\n /**Enables zooming, panning and selecting widgets */\n edit?: boolean;\n}\n\n/**Creates a viewport showing a page of widgets */\nexport const canvas_viewport = (options?: CanvasViewportOptions): Viewport =>\n options ? new Viewport().opts(options) : new Viewport();\n","import { canvas_page, Page, type CanvasPageOptions } from \"./page\";\nimport {\n canvas_viewport,\n Viewport,\n type CanvasViewportOptions,\n} from \"./viewport\";\nimport { WIDGET_TRANSFORM_EVENT } from \"./widget\";\n\n/**Displaying and editing graphics with a fixed position and size */\nexport const canvas = {\n page: canvas_page,\n viewport: canvas_viewport,\n WIDGET_TRANSFORM_EVENT,\n};\nexport default canvas;\n\nexport type { CanvasPageOptions, CanvasViewportOptions, Page, Viewport };\n\nexport { WIDGET_TRANSFORM_EVENT, WidgetBase } from \"./widget\";\n"],"mappings":";;;;;;AAGA,MAAM,aAAa,yBACjB,UACA,UACA,gDACF;AAQA,MAAM,SAAS,WAAW,eACxB,UACA,UACA,0BACF;AACA,OAAO,cACL,cACA,oBACA,yCACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AACA,OAAO,cACL,kBACA,yBACA,wCACA,KAAK,OACL,KAAK,QACL,SACA,KAAA,CACF;AAQA,MAAM,OAAO,WAAW,eACtB,QACA,QACA,qCACF;AACA,KAAK,cACH,YACA,4BACA,sEACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AACA,KAAK,cACH,YACA,6BACA,uEACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AACA,KAAK,cACH,eACA,4BACA,6EACA,YACA,YACA,UACA;CAAE,KAAK;CAAK,KAAK;AAAG,CACtB;AAQA,MAAM,cAAc,WAAW,eAC7B,eACA,eACA,mFACF;AACA,YAAY,cACV,SACA,qBACA,uDACA,KAAK,QACL,KAAK,QACL,SACA,KAAA,CACF;AACA,YAAY,cACV,oBACA,2BACA,+CACA,KAAK,OACL,KAAK,QACL,SACA,KAAA,CACF;;;;ACnGA,IAAa,OAAb,cAA0B,KAAK;;CAE7B,OAAO,eAAe;EACpB,OA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AC1B,IAAI,CAAC,UAAU,CAAC,SAAS,OAAO,YAAY,GAAG;GAC/C,KAAK,UAAU,MAAM,IAAI,OAAO;GAChC,KAAK,UAAU,MAAM,IAAI,OAAO;GAChC,KAAK,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,WAAW,OAAO,QAAQ;GAChE,KAAK,aAAa;EACpB,OAAO,IAAI,EAAE,cAAc,KAAK,iBAAiB;GAC/C,MAAM,QAAQ,KAAK,OAAO,CAAC;GAC3B,KAAK,UAAU,MAAM,IAAI,KAAK,kBAAkB;GAChD,KAAK,UAAU,MAAM,IAAI,KAAK,kBAAkB;GAChD,KAAK,oBAAoB;GACzB,KAAK,aAAa;EACpB;CACF;CAEA,kBAAkB,MAAoB;EACpC,KAAK,SAAS,OAAO,EAAE,SAAS;EAChC,IAAI,EAAE,cAAc,KAAK,iBAAiB,KAAK,kBAAkB,KAAA;CACnE;;CAGA,kBAAkB,MAAkB;EAClC,IAAI,EAAE,WAAW,GAAG,EAAE,eAAe;CACvC;;CAGA,oBAAoB,MAAkB;EACpC,EAAE,eAAe;CACnB;CAEA,WAAW,MAAqB;EAC9B,KAAK,aAAa,EAAE;CACtB;CAEA,iBAAiB;EACf,KAAK,aAAa;CACpB;AACF;AACA,eAAe,QAAQ;;AAUvB,MAAa,mBAAmB,YAC9B,UAAU,IAAI,SAAS,CAAC,CAAC,KAAK,OAAO,IAAI,IAAI,SAAS;;;ACtTxD,MAAa,SAAS;CACpB,MAAM;CACN,UAAU;CACV;AACF"}
|
package/context-menu/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import "../style.css";
|
|
2
|
-
export { t as ctm, t as default } from "../context-menu-
|
|
2
|
+
export { t as ctm, t as default } from "../context-menu-CA4o4fXx.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-
|
|
3
|
+
import { i as theme_init_variable_root } from "./theme-ChmpRObz.mjs";
|
|
4
4
|
import { DOCUMENT_HANDLER } from "./document/index.mjs";
|
|
5
5
|
import { Fm as material_chevron_right_rounded, xh as material_close_rounded } from "./icons-e2J_Ojic.mjs";
|
|
6
6
|
import { Spinner } from "./spinner/index.mjs";
|
|
@@ -558,4 +558,4 @@ const ctm = {
|
|
|
558
558
|
};
|
|
559
559
|
export { ctm as t };
|
|
560
560
|
|
|
561
|
-
//# sourceMappingURL=context-menu-
|
|
561
|
+
//# sourceMappingURL=context-menu-CA4o4fXx.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-menu-_9dMpC-H.mjs","names":[],"sources":["../src/context-menu/shared.ts","../src/context-menu/line.ts","../src/context-menu/devider.ts","../src/context-menu/container.ts","../src/context-menu/engine.ts","../src/context-menu/buffer.ts","../src/context-menu/option.ts","../src/context-menu/submenu.ts","../src/context-menu/menu.ts","../src/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 { 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 { 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 { 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 { 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 =\n typeof this.#lines === \"function\" ? this.#lines() : this.#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 /**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 { 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};\nexport default ctm;\n\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,cAC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ider.ts","../src/context-menu/container.ts","../src/context-menu/engine.ts","../src/context-menu/buffer.ts","../src/context-menu/option.ts","../src/context-menu/submenu.ts","../src/context-menu/menu.ts","../src/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 { 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 { 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 { 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 { 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 =\n typeof this.#lines === \"function\" ? this.#lines() : this.#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 /**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 { 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};\nexport default ctm;\n\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,SAAS;GAC9C,OAAO,YAA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AAI,KAAK,IAAI,OAAO,QAAQ,OAAO,aAAa;SAC3C,OAAO,OAAO,aAAa,IAAI;GACtC,OAAO,OAAO;EAChB;EACA,KAAK,cAAc,IAAI,UAAU,OAAO;EACxC,KAAK,cAAc,IAAI,UAAU,OAAO;EAExC,KAAK,MAAM,MAAM,QAAQ,MAAM,MAAM,OAAO;EAC5C,KAAK,MAAM,SAAS,WAAW,SAAS,SAAS,OAAO;EACxD,KAAK,MAAM,OAAO,SAAS,OAAO,OAAO,OAAO;EAChD,KAAK,MAAM,QAAQ,UAAU,QAAQ,QAAQ,OAAO;EACpD,KAAK,MAAM;CACb;AACF;AACA,eAAe,WAAW;AAE1B,SAAgB,aACd,OAOa;CACb,OAAO,IAAI,YAAY,KAAK;AAC9B;;ACvPA,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;AACX"}
|
package/form/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import '../style.css';
|
|
2
2
|
import { l as Base, p as AccessTypes } from "../index-CvzH3M_5.mjs";
|
|
3
3
|
import { t as SVGFunc } from "../index-BDWg5GX2.mjs";
|
|
4
|
-
import { n as ListField } from "../index-
|
|
4
|
+
import { n as ListField } from "../index-DCn7acFY.mjs";
|
|
5
5
|
import { State, StateEnumRelated, StateNumberRelated, StateREAW, StateStringRelated } from "@chocbite/ts-lib/state";
|
|
6
6
|
import { Option, Result } from "@chocbite/ts-lib/result";
|
|
7
7
|
import { IPAddress, IPVersion, Prettify } from "@chocbite/ts-lib/common";
|
package/form/index.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import "../style.css";
|
|
2
2
|
import { AccessTypes, Base, define_element } from "../base/index.mjs";
|
|
3
|
-
import { c as ANIMATION_SPEED, i as theme_init_variable_root, l as AnimationLevels, s as ANIMATION_LEVEL } from "../theme-
|
|
3
|
+
import { c as ANIMATION_SPEED, i as theme_init_variable_root, l as AnimationLevels, s as ANIMATION_LEVEL } from "../theme-ChmpRObz.mjs";
|
|
4
4
|
import { node_clone } from "../dom/index.mjs";
|
|
5
5
|
import { B1 as material_remove_rounded, Fx as material_drag_handle_rounded, Qot as material_unfold_less_rounded, U2 as material_schedule_rounded, dn as material_add_rounded, est as material_unfold_more_rounded, if as material_calendar_month_rounded, xI as material_keyboard_arrow_down_rounded, xh as material_close_rounded } from "../icons-e2J_Ojic.mjs";
|
|
6
|
-
import { n as ListField } from "../list-
|
|
6
|
+
import { n as ListField } from "../list-CNYJ3sm-.mjs";
|
|
7
7
|
import { get_cursor_position, set_cursor_end, set_cursor_position, set_selection_all } from "../selection/index.mjs";
|
|
8
8
|
import { DOCUMENT_HANDLER } from "../document/index.mjs";
|
|
9
9
|
import state from "@chocbite/ts-lib/state";
|
|
10
10
|
import { err, none, ok, some } from "@chocbite/ts-lib/result";
|
|
11
|
-
import { IPAddress, IPVersion, sleep, sync_resolve } from "@chocbite/ts-lib/common";
|
|
12
|
-
import { number_step_start_decimal } from "@chocbite/ts-lib/math";
|
|
13
11
|
import { BLUE, GREEN, GREY, ORANGE, RED, YELLOW } from "@chocbite/ts-lib/colors";
|
|
12
|
+
import { number_step_start_decimal } from "@chocbite/ts-lib/math";
|
|
13
|
+
import { IPAddress, IPVersion, sleep, sync_resolve } from "@chocbite/ts-lib/common";
|
|
14
14
|
import { string_byte_length, string_byte_limit } from "@chocbite/ts-lib/string";
|
|
15
15
|
// src/form/shared.ts
|
|
16
16
|
const theme_root = theme_init_variable_root("form", "UI Form Elements", "Theme variables for UI form Elements");
|
|
@@ -3,7 +3,7 @@ import { l as Base, u as BaseIntersectObserver } from "./index-CvzH3M_5.mjs";
|
|
|
3
3
|
import { t as SVGFunc } from "./index-BDWg5GX2.mjs";
|
|
4
4
|
import { n as ContextMenu } from "./index-DhRb2iA8.mjs";
|
|
5
5
|
import { State } from "@chocbite/ts-lib/state";
|
|
6
|
-
import { Option } from "@chocbite/ts-lib/result";
|
|
6
|
+
import { Option, Result } from "@chocbite/ts-lib/result";
|
|
7
7
|
declare abstract class ListField extends Base {
|
|
8
8
|
static element_name(): string;
|
|
9
9
|
static element_name_space(): string;
|
|
@@ -69,6 +69,7 @@ declare const ListDataType: {
|
|
|
69
69
|
readonly bool: "bool";
|
|
70
70
|
};
|
|
71
71
|
type ListDataType = (typeof ListDataType)[keyof typeof ListDataType];
|
|
72
|
+
type ListColumnAlign = "left" | "center" | "right";
|
|
72
73
|
interface ListColumnOptions<V, C extends ListField> {
|
|
73
74
|
/**Initial width of the column in rem, auto when undefined*/
|
|
74
75
|
init_width?: number;
|
|
@@ -81,6 +82,9 @@ interface ListColumnOptions<V, C extends ListField> {
|
|
|
81
82
|
reorderable?: boolean;
|
|
82
83
|
/**Data type of the column, used for sorting, will attempt auto detect if undefined*/
|
|
83
84
|
type?: ListDataType;
|
|
85
|
+
/**Horizontal alignment of the title and the fields, center when undefined
|
|
86
|
+
* Text, number and node fields follow it, more complex fields like form fields do not */
|
|
87
|
+
align?: ListColumnAlign;
|
|
84
88
|
/**Column title*/
|
|
85
89
|
title: string;
|
|
86
90
|
/**Generates the field element, only called during row or column creation */
|
|
@@ -93,14 +97,19 @@ declare function column<V, C extends ListField>(options: ListColumnOptions<V, C>
|
|
|
93
97
|
/**Special helper to create a string value column */
|
|
94
98
|
declare function column_string(
|
|
95
99
|
/**Column title*/
|
|
96
|
-
title: string
|
|
100
|
+
title: string, options?: {
|
|
101
|
+
align?: ListColumnAlign;
|
|
102
|
+
}): ListColumnOptions<string, ListTextField>;
|
|
103
|
+
/**Transforms the data of a row into row options
|
|
104
|
+
* Returning an error makes the row invalid, the error text then replaces the fields of the row
|
|
105
|
+
* An invalid row is for failures with no other options, so it has no sub rows, add row or context menu */
|
|
97
106
|
type ListRowTransformer<R, T extends {}, A extends ListType<any>, S extends boolean> = (
|
|
98
107
|
/**Data of the row */
|
|
99
108
|
data: R,
|
|
100
109
|
/**The row the options are for */
|
|
101
110
|
row: ListRow<R, T, A, S>,
|
|
102
111
|
/**Rows the data is from, sub rows can come from an array or a state regardless of the top level rows */
|
|
103
|
-
state: S extends true ? A | ListType<R> : A) => ListRowOptions<R, T, S>;
|
|
112
|
+
state: S extends true ? A | ListType<R> : A) => Result<ListRowOptions<R, T, S>, string>;
|
|
104
113
|
interface ListRoot<R, T extends {}, A extends ListType<any>, S extends boolean> {
|
|
105
114
|
/**Sub rows */
|
|
106
115
|
readonly sub_rows: S;
|
|
@@ -161,4 +170,4 @@ declare const list: {
|
|
|
161
170
|
node_field: typeof node_field;
|
|
162
171
|
};
|
|
163
172
|
export { ListField as n, list as t };
|
|
164
|
-
//# sourceMappingURL=index-
|
|
173
|
+
//# sourceMappingURL=index-DCn7acFY.d.mts.map
|
package/keyboard/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import "../style.css";
|
|
|
2
2
|
import { DOCUMENT_HANDLER } from "../document/index.mjs";
|
|
3
3
|
import { Base, define_element } from "../base/index.mjs";
|
|
4
4
|
import { get_cursor_position, set_cursor_position } from "../selection/index.mjs";
|
|
5
|
-
import { _ as version, i as theme_init_variable_root } from "../theme-
|
|
5
|
+
import { _ as version, i as theme_init_variable_root } from "../theme-ChmpRObz.mjs";
|
|
6
6
|
import { settings_init } from "../settings/index.mjs";
|
|
7
7
|
import state, { state as state$1 } from "@chocbite/ts-lib/state";
|
|
8
8
|
import { some } from "@chocbite/ts-lib/result";
|
package/list/index.d.mts
CHANGED
package/list/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import "../style.css";
|
|
2
|
-
export { n as ListField, t as default, t as list } from "../list-
|
|
2
|
+
export { n as ListField, t as default, t as list } from "../list-CNYJ3sm-.mjs";
|