@chocbite/ts-lib-ui 1.1.5 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/AGENTS.md +547 -9
  2. package/README.md +3 -0
  3. package/SOURCE.md +10313 -7355
  4. package/base/index.d.mts +2 -2
  5. package/base/index.mjs +68 -5
  6. package/base/index.mjs.map +1 -1
  7. package/canvas/index.d.mts +1 -1
  8. package/canvas/index.mjs +1 -1
  9. package/composition/index.d.mts +283 -0
  10. package/composition/index.mjs +2 -0
  11. package/composition-7xlf0UjB.mjs +869 -0
  12. package/composition-7xlf0UjB.mjs.map +1 -0
  13. package/context-menu/index.d.mts +1 -1
  14. package/context-menu/index.mjs +1 -1
  15. package/{context-menu-CZxEGjBi.mjs → context-menu-DSVerkvr.mjs} +2 -2
  16. package/{context-menu-CZxEGjBi.mjs.map → context-menu-DSVerkvr.mjs.map} +1 -1
  17. package/depot_ui/index.d.mts +60 -0
  18. package/depot_ui/index.mjs +280 -0
  19. package/depot_ui/index.mjs.map +1 -0
  20. package/form/index.d.mts +2 -758
  21. package/form/index.mjs +1 -2953
  22. package/form-CnIHz2Bp.mjs +2961 -0
  23. package/form-CnIHz2Bp.mjs.map +1 -0
  24. package/icons/index.d.mts +1 -1
  25. package/{index-YNZjMIO7.d.mts → index-CApVOEcI.d.mts} +2 -2
  26. package/{index-BDWg5GX2.d.mts → index-Czy8O3me.d.mts} +6 -2
  27. package/index-DD09-bGe.d.mts +761 -0
  28. package/{index-DlBJdGaQ.d.mts → index-U3pqQjLg.d.mts} +4 -4
  29. package/{index-CvzH3M_5.d.mts → index-_y7vmunA.d.mts} +72 -8
  30. package/keyboard/index.d.mts +1 -1
  31. package/keyboard/index.mjs +1 -1
  32. package/list/index.d.mts +1 -1
  33. package/list/index.mjs +1 -1
  34. package/{list-C52-ExFw.mjs → list-ByNP3ZG2.mjs} +3 -3
  35. package/{list-C52-ExFw.mjs.map → list-ByNP3ZG2.mjs.map} +1 -1
  36. package/package.json +2 -2
  37. package/prompts/index.d.mts +48 -0
  38. package/prompts/index.mjs +107 -0
  39. package/prompts/index.mjs.map +1 -0
  40. package/spinner/index.d.mts +1 -1
  41. package/spinner/index.mjs +1 -1
  42. package/style.css +2049 -1640
  43. package/svg/index.d.mts +1 -1
  44. package/svg-Yz7elqnU.mjs.map +1 -1
  45. package/theme/index.d.mts +1 -1
  46. package/theme/index.mjs +1 -1
  47. package/{theme-D3YluyYr.mjs → theme-ycsugrdT.mjs} +2 -2
  48. package/{theme-D3YluyYr.mjs.map → theme-ycsugrdT.mjs.map} +1 -1
  49. package/form/index.mjs.map +0 -1
  50. package/test/index.d.mts +0 -98
  51. package/test/index.mjs +0 -193
  52. package/test/index.mjs.map +0 -1
package/svg/index.d.mts CHANGED
@@ -1,3 +1,3 @@
1
1
  import '../style.css';
2
- import { n as svg, r as SVGAnchorPoint, t as SVGFunc } from "../index-BDWg5GX2.mjs";
2
+ import { n as svg, r as SVGAnchorPoint, t as SVGFunc } from "../index-Czy8O3me.mjs";
3
3
  export { SVGAnchorPoint, SVGFunc, svg };
@@ -1 +1 @@
1
- {"version":3,"file":"svg-Yz7elqnU.mjs","names":["svg","svgsvg"],"sources":["../../package-ui/svg/attributes.ts","../../package-ui/svg/shared.ts","../../package-ui/svg/primitives/shared.ts","../../package-ui/svg/primitives/ellipse.ts","../../package-ui/svg/primitives/circle.ts","../../package-ui/svg/primitives/group.ts","../../package-ui/svg/primitives/line.ts","../../package-ui/svg/primitives/path.ts","../../package-ui/svg/primitives/rectangle.ts","../../package-ui/svg/primitives/svg.ts","../../package-ui/svg/util/anchorPoint.ts","../../package-ui/svg/primitives/text.ts","../../package-ui/svg/primitives/triangle.ts","../../package-ui/svg/util/angleToAnchorPoint.ts","../../package-ui/svg/index.ts"],"sourcesContent":["export class SVGAttributes<T extends SVGElement> {\n constructor(elem: T) {\n this.#elem = elem;\n }\n #elem: T;\n /**Returns the svg element */\n get elem(): T {\n this.#apply_transforms();\n return this.#elem;\n }\n\n /** Sets the stroke color of the SVG element */\n stroke(stroke: string): this {\n this.#elem.setAttribute(\"stroke\", stroke);\n return this;\n }\n /** Sets the stroke color of the SVG element */\n s(stroke: string): this {\n this.#elem.setAttribute(\"stroke\", stroke);\n return this;\n }\n\n /** Sets the fill color of the SVG element */\n fill(fill: string): this {\n this.#elem.setAttribute(\"fill\", fill);\n return this;\n }\n /** Sets the fill color of the SVG element */\n f(fill: string): this {\n this.#elem.setAttribute(\"fill\", fill);\n return this;\n }\n\n /** Sets the stroke width of the SVG element */\n stroke_width(width: number): this {\n this.#elem.setAttribute(\"stroke-width\", String(width));\n return this;\n }\n /** Sets the stroke width of the SVG element */\n sw(width: number): this {\n this.#elem.setAttribute(\"stroke-width\", String(width));\n return this;\n }\n\n /** Adds one or more class names to the SVG element */\n class_list(...class_name: string[]): this {\n this.#elem.classList.add(...class_name);\n return this;\n }\n /** Adds one or more class names to the SVG element */\n cl(...class_name: string[]): this {\n this.#elem.classList.add(...class_name);\n return this;\n }\n\n /** Sets an arbitrary attribute on the SVG element */\n attribute(name: string, value: string): this {\n this.#elem.setAttribute(name, value);\n return this;\n }\n /** Sets an arbitrary attribute on the SVG element */\n a(name: string, value: string): this {\n this.#elem.setAttribute(name, value);\n return this;\n }\n\n #transforms: string[] = [];\n #apply_transforms(): void {\n if (this.#transforms.length > 0)\n this.#elem.setAttribute(\"transform\", this.#transforms.join(\" \"));\n }\n\n /** Applies a translation transform to the SVG element */\n translate(x: number, y: number): this {\n this.#transforms.push(`translate(${x} ${y})`);\n return this;\n }\n\n /** Applies a rotation transform to the SVG element */\n rotate(angle: number, cx?: number, cy?: number): this {\n if (cx !== undefined && cy !== undefined)\n this.#transforms.push(`rotate(${angle} ${cx} ${cy})`);\n else this.#transforms.push(`rotate(${angle})`);\n return this;\n }\n\n /** Applies a scaling transform to the SVG element */\n scale(sx: number, sy?: number): this {\n if (sy !== undefined) this.#transforms.push(`scale(${sx} ${sy})`);\n else this.#transforms.push(`scale(${sx})`);\n return this;\n }\n\n /** Applies a skewX transform to the SVG element */\n skewX(angle: number): this {\n this.#transforms.push(`skewX(${angle})`);\n return this;\n }\n\n /** Applies a skewY transform to the SVG element */\n skewY(angle: number): this {\n this.#transforms.push(`skewY(${angle})`);\n return this;\n }\n\n /** Applies a custom transform to the SVG element */\n transform(transform: string): this {\n this.#transforms.push(transform);\n return this;\n }\n}\n","export const NAME_SPACE = \"http://www.w3.org/2000/svg\";\n","import { SVGAttributes } from \"../attributes\";\nimport { NAME_SPACE } from \"../shared\";\n\nexport function create_svg_element<K extends keyof SVGElementTagNameMap>(\n name: K,\n): SVGAttributes<SVGElementTagNameMap[K]> {\n return new SVGAttributes(document.createElementNS(NAME_SPACE, name));\n}\n","import { degrees_to_radians } from \"@chocbite/ts-lib/math\";\nimport { SVGAttributes } from \"../attributes\";\nimport { create_svg_element } from \"./shared\";\n\n/**This creates a svg ellipse\n * @param center_x x coordinate of center\n * @param center_y y coordinate of center\n * @param radius_x x radius of circle\n * @param radius_y y radius of circle*/\nexport function ellipse(\n center_x: number,\n center_y: number,\n radius_x: number,\n radius_y: number,\n): SVGAttributes<SVGEllipseElement> {\n return create_svg_element(\"ellipse\")\n .a(\"cx\", String(center_x))\n .a(\"cy\", String(center_y))\n .a(\"rx\", String(radius_x))\n .a(\"ry\", String(radius_y));\n}\n\n/**This draws parts of a circle/ellipse, the circle direction is reversed\n * @param center_x the center point on the x axis\n * @param center_y the center point on the y axis\n * @param radius_x radius in x axis\n * @param radius_y radius in y axis\n * @param start_angle start angle in degrees\n * @param end_angle end angle in degrees, a sweep of 360 degrees or more draws the whole ellipse*/\nexport function ellipse_arc(\n center_x: number,\n center_y: number,\n radius_x: number,\n radius_y: number,\n start_angle: number,\n end_angle: number,\n): SVGAttributes<SVGPathElement> {\n const start_radian = degrees_to_radians(start_angle);\n const sweep = degrees_to_radians(end_angle - start_angle);\n const point = (radian: number) =>\n `${radius_x * Math.cos(radian) + center_x} ${radius_y * Math.sin(radian) + center_y}`;\n const f_s = sweep > 0 ? 1 : 0;\n const arc = `A ${radius_x} ${radius_y} 0`;\n //An arc ending where it starts draws nothing, so the whole ellipse is two halves\n if (Math.abs(sweep) >= 2 * Math.PI) {\n const half = start_radian + (sweep > 0 ? Math.PI : -Math.PI);\n return create_svg_element(\"path\").a(\n \"d\",\n `M ${point(start_radian)} ${arc} 0 ${f_s} ${point(half)} ${arc} 0 ${f_s} ${point(start_radian)}`,\n );\n }\n const f_a = Math.abs(sweep) > Math.PI ? 1 : 0;\n return create_svg_element(\"path\").a(\n \"d\",\n `M ${point(start_radian)} ${arc} ${f_a} ${f_s} ${point(start_radian + sweep)}`,\n );\n}\n","import { SVGAttributes } from \"../attributes\";\nimport { ellipse_arc } from \"./ellipse\";\nimport { create_svg_element } from \"./shared\";\n\n/**This creates a svg circle\n * @param center_x x coordinate of center\n * @param center_y y coordinate of center\n * @param radius radius of circle*/\nexport function circle(\n center_x: number,\n center_y: number,\n radius: number,\n): SVGAttributes<SVGCircleElement> {\n const circle = create_svg_element(\"circle\");\n circle.a(\"cx\", String(center_x));\n circle.a(\"cy\", String(center_y));\n circle.a(\"r\", String(radius));\n return circle;\n}\n\n/**This draws parts of a circle/ellipse, the circle direction is reversed\n * @param center_x the center point on the x axis\n * @param center_y the center point on the y axis\n * @param radius radius in x axis\n * @param start_angle start angle in degrees\n * @param end_angle end angle in degrees, a sweep of 360 degrees or more draws the whole circle*/\nexport function circle_arc(\n center_x: number,\n center_y: number,\n radius: number,\n start_angle: number,\n end_angle: number,\n): SVGAttributes<SVGPathElement> {\n return ellipse_arc(\n center_x,\n center_y,\n radius,\n radius,\n start_angle,\n end_angle,\n );\n}\n","import { SVGAttributes } from \"../attributes\";\nimport { create_svg_element } from \"./shared\";\n\n/**This draws a triangle*/\nexport function group(): SVGAttributes<SVGGElement> {\n return create_svg_element(\"g\");\n}\n","import { SVGAttributes } from \"../attributes\";\nimport { create_svg_element } from \"./shared\";\n\n/**This creates a line element\n * @param start_x start point on x axis\n * @param start_y start point on y axis\n * @param end_x end point on x axis\n * @param end_y end point on y axis*/\nexport function line(\n start_x: number,\n start_y: number,\n end_x: number,\n end_y: number,\n): SVGAttributes<SVGLineElement> {\n return create_svg_element(\"line\")\n .a(\"x1\", String(start_x))\n .a(\"y1\", String(start_y))\n .a(\"x2\", String(end_x))\n .a(\"y2\", String(end_y));\n}\n","import { SVGAttributes } from \"../attributes\";\nimport { create_svg_element } from \"./shared\";\n\n/**This creates a path element*/\nexport function path(path: string): SVGAttributes<SVGPathElement> {\n return create_svg_element(\"path\").a(\"d\", path);\n}\n\n/**This creates a line with a path element\n * @param start_x start point on x axis\n * @param start_y start point on y axis\n * @param end_x end point on x axis\n * @param end_y end point on y axis*/\nexport function path_line(\n start_x: number,\n start_y: number,\n end_x: number,\n end_y: number,\n): SVGAttributes<SVGPathElement> {\n return create_svg_element(\"path\").a(\n \"d\",\n `M ${start_x} ${start_y} L ${end_x} ${end_y}`,\n );\n}\n","import { SVGAttributes } from \"../attributes\";\nimport { create_svg_element } from \"./shared\";\n\n/**This creates a rectangle with teh center as origin\n * @param center_x x coordinate of center\n * @param center_y y coordinate of center\n * @param width width\n * @param height height\n * @param corner_radius radius of corner*/\nexport function rectangle_from_center(\n center_x: number,\n center_y: number,\n width: number,\n height: number,\n corner_radius: number,\n): SVGAttributes<SVGRectElement> {\n return create_svg_element(\"rect\")\n .a(\"x\", String(center_x - width / 2))\n .a(\"y\", String(center_y - height / 2))\n .a(\"width\", String(width))\n .a(\"height\", String(height))\n .a(\"rx\", String(corner_radius));\n}\n\n/**This creates a rectangle with teh center as origin\n * @param start_x x coordinate of center\n * @param start_y y coordinate of center\n * @param width width\n * @param height height\n * @param corner_radius radius of corner*/\nexport function rectangle_from_corner(\n start_x: number,\n start_y: number,\n width: number,\n height: number,\n corner_radius: number,\n): SVGAttributes<SVGRectElement> {\n return create_svg_element(\"rect\")\n .a(\"x\", String(start_x))\n .a(\"y\", String(start_y))\n .a(\"width\", String(width))\n .a(\"height\", String(height))\n .a(\"rx\", String(corner_radius));\n}\n","import { SVGAttributes } from \"../attributes\";\nimport { create_svg_element } from \"./shared\";\n\n/** This returns an empty svg element\n * @param width width of svg\n * @param height height of svg\n * @param viewbox viewbox of svg*/\nexport function svg(\n width: number,\n height: number,\n viewbox: string = `0 0 ${width} ${height}`,\n): SVGAttributes<SVGSVGElement> {\n return create_svg_element(\"svg\")\n .a(\"width\", String(width))\n .a(\"height\", String(height))\n .a(\"viewBox\", String(viewbox));\n}\n","//Enum describing the diffrent possible anchor points\nexport const SVGAnchorPoint = {\n bottomLeft: 0,\n middleLeft: 1,\n topLeft: 2,\n topCenter: 3,\n topRight: 4,\n middleRight: 5,\n bottomRight: 6,\n bottomCenter: 7,\n middleCenter: 8,\n} as const;\nexport type SVGAnchorPoint =\n (typeof SVGAnchorPoint)[keyof typeof SVGAnchorPoint];\n","import { SVGAttributes } from \"../attributes\";\nimport { SVGAnchorPoint } from \"../util/anchorPoint\";\nimport { create_svg_element } from \"./shared\";\n\n/**Creates a text nodes for an svg\n * @param x x coordinate of text\n * @param y y coordinate of text\n * @param text text\n * @param size size of text in px\n * @param anchor anchor point of text*/\nexport function text(\n x: number,\n y: number,\n text: string,\n size: number,\n anchor: SVGAnchorPoint,\n): SVGAttributes<SVGTextElement> {\n const text_elem = create_svg_element(\"text\")\n .a(\"x\", String(x))\n .a(\"y\", String(y))\n .a(\"font-size\", String(size));\n text_elem.elem.textContent = text;\n switch (anchor) {\n case SVGAnchorPoint.bottomLeft:\n case SVGAnchorPoint.middleLeft:\n case SVGAnchorPoint.topLeft: {\n text_elem.a(\"text-anchor\", \"start\");\n break;\n }\n case SVGAnchorPoint.topCenter:\n case SVGAnchorPoint.bottomCenter:\n case SVGAnchorPoint.middleCenter: {\n text_elem.a(\"text-anchor\", \"middle\");\n break;\n }\n case SVGAnchorPoint.topRight:\n case SVGAnchorPoint.middleRight:\n case SVGAnchorPoint.bottomRight: {\n text_elem.a(\"text-anchor\", \"end\");\n break;\n }\n }\n switch (anchor) {\n case SVGAnchorPoint.bottomLeft:\n case SVGAnchorPoint.bottomRight:\n case SVGAnchorPoint.bottomCenter: {\n text_elem.a(\"dominant-baseline\", \"auto\");\n break;\n }\n case SVGAnchorPoint.middleLeft:\n case SVGAnchorPoint.middleRight:\n case SVGAnchorPoint.middleCenter: {\n text_elem.a(\"dominant-baseline\", \"central\");\n break;\n }\n case SVGAnchorPoint.topLeft:\n case SVGAnchorPoint.topCenter:\n case SVGAnchorPoint.topRight: {\n text_elem.a(\"dominant-baseline\", \"hanging\");\n break;\n }\n }\n return text_elem;\n}\n\n/**Creates a text nodes for an svg\n * @param x x coordinate of text\n * @param y y coordinate of text\n * @param width width of text\n * @param height height of text\n * @param text text\n * @param size size of text in px\n * @param anchor anchor point of */\nexport function multi_line_text(\n x: number,\n y: number,\n width: number,\n height: number,\n text: string,\n size: number,\n anchor: SVGAnchorPoint,\n): SVGAttributes<SVGForeignObjectElement> {\n const text_element = create_svg_element(\"foreignObject\");\n const text_div = text_element.elem.appendChild(document.createElement(\"div\"));\n text_element.a(\"width\", String(width));\n text_element.a(\"height\", String(height));\n text_element.a(\"x\", String(x));\n text_element.a(\"y\", String(y));\n text_div.style.fontSize = size + \"px\";\n text_div.style.width = \"100%\";\n text_div.style.height = \"100%\";\n text_div.style.display = \"flex\";\n text_div.textContent = text;\n switch (anchor) {\n case SVGAnchorPoint.bottomLeft:\n case SVGAnchorPoint.middleLeft:\n case SVGAnchorPoint.topLeft: {\n text_div.style.textAlign = \"start\";\n text_div.style.justifyContent = \"flex-start\";\n break;\n }\n case SVGAnchorPoint.topCenter:\n case SVGAnchorPoint.bottomCenter:\n case SVGAnchorPoint.middleCenter: {\n text_div.style.textAlign = \"center\";\n text_div.style.justifyContent = \"center\";\n break;\n }\n case SVGAnchorPoint.topRight:\n case SVGAnchorPoint.middleRight:\n case SVGAnchorPoint.bottomRight: {\n text_div.style.textAlign = \"end\";\n text_div.style.justifyContent = \"flex-end\";\n break;\n }\n }\n switch (anchor) {\n case SVGAnchorPoint.bottomLeft:\n case SVGAnchorPoint.bottomRight:\n case SVGAnchorPoint.bottomCenter: {\n text_div.style.alignItems = \"flex-end\";\n break;\n }\n case SVGAnchorPoint.middleLeft:\n case SVGAnchorPoint.middleRight:\n case SVGAnchorPoint.middleCenter: {\n text_div.style.alignItems = \"center\";\n break;\n }\n case SVGAnchorPoint.topLeft:\n case SVGAnchorPoint.topCenter:\n case SVGAnchorPoint.topRight: {\n text_div.style.alignItems = \"flex-start\";\n break;\n }\n }\n return text_element;\n}\n","import { SVGAttributes } from \"../attributes\";\nimport { create_svg_element } from \"./shared\";\n\n/**This draws a triangle\n * @param center_x x coordinate of center\n * @param center_y y coordinate of center\n * @param width width\n * @param height height*/\nexport function isosceles_triangle(\n center_x: number,\n center_y: number,\n width: number,\n height: number,\n): SVGAttributes<SVGPathElement> {\n const half_w = width / 2;\n const half_h = height / 2;\n return create_svg_element(\"path\").a(\n \"d\",\n \"M\" +\n (center_x - half_w) +\n \",\" +\n (center_y + half_h) +\n \" \" +\n (center_x + half_w) +\n \",\" +\n (center_y + half_h) +\n \" \" +\n center_x +\n \",\" +\n (center_y - half_h) +\n \"Z\",\n );\n}\n","import { SVGAnchorPoint } from \"./anchorPoint\";\n\n/**Converts an angle to an anchor point\n * @param angle angle in radians, any angle outside 0 to 2PI is wrapped around*/\nexport const angle_to_anchor_point = (angle: number) => {\n const full = 6.283185307179586;\n const sec = ((angle % full) + full) % full;\n if (sec > 5.93411945678072) {\n return SVGAnchorPoint.middleRight;\n } else if (sec > 4.974188368183839) {\n return SVGAnchorPoint.topRight;\n } else if (sec > 4.45058959258554) {\n return SVGAnchorPoint.topCenter;\n } else if (sec > 3.4906585039886591) {\n return SVGAnchorPoint.topLeft;\n } else if (sec > 2.792526803190927) {\n return SVGAnchorPoint.middleLeft;\n } else if (sec > 1.832595714594046) {\n return SVGAnchorPoint.bottomLeft;\n } else if (sec > 1.308996938995747) {\n return SVGAnchorPoint.bottomCenter;\n } else if (sec > 0.3490658503988659) {\n return SVGAnchorPoint.bottomRight;\n } else {\n return SVGAnchorPoint.middleRight;\n }\n};\n","import { SVGAttributes } from \"./attributes\";\nimport { circle, circle_arc } from \"./primitives/circle\";\nimport { ellipse, ellipse_arc } from \"./primitives/ellipse\";\nimport { group } from \"./primitives/group\";\nimport { line } from \"./primitives/line\";\nimport { path } from \"./primitives/path\";\nimport {\n rectangle_from_center,\n rectangle_from_corner,\n} from \"./primitives/rectangle\";\nimport { create_svg_element } from \"./primitives/shared\";\nimport { svg as svgsvg } from \"./primitives/svg\";\nimport { multi_line_text, text } from \"./primitives/text\";\nimport { isosceles_triangle } from \"./primitives/triangle\";\nimport { angle_to_anchor_point } from \"./util/angleToAnchorPoint\";\n\nexport const svg = {\n create: create_svg_element,\n attr: (elem: SVGElement) => new SVGAttributes(elem),\n //Primitives\n circle: circle,\n circle_arc: circle_arc,\n ellipse: ellipse,\n ellipse_arc: ellipse_arc,\n group: group,\n line: line,\n path: path,\n rectangle_from_center: rectangle_from_center,\n rectangle_from_corner: rectangle_from_corner,\n svg: svgsvg,\n text: text,\n multi_line_text: multi_line_text,\n isosceles_triangle: isosceles_triangle,\n //Utilities\n angle_to_anchor_point: angle_to_anchor_point,\n};\n\nexport type SVGFunc = () => SVGSVGElement;\nexport { SVGAnchorPoint } from \"./util/anchorPoint\";\n\ndeclare global {\n /**Types enum icons in @chocbite/ts-lib state as SVGFunc*/\n interface ChocbiteStateRegister {\n icon: SVGFunc;\n }\n}\n"],"mappings":";;;AAAA,IAAa,gBAAb,MAAiD;CAC/C,YAAY,MAAS;EACnB,KAAK,QAAQ;CACf;CACA;;CAEA,IAAI,OAAU;EACZ,KAAK,kBAAkB;EACvB,OAAO,KAAK;CACd;;CAGA,OAAO,QAAsB;EAC3B,KAAK,MAAM,aAAa,UAAU,MAAM;EACxC,OAAO;CACT;;CAEA,EAAE,QAAsB;EACtB,KAAK,MAAM,aAAa,UAAU,MAAM;EACxC,O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KAAK,eAAe;EACpB,KAAK,eAAe;GAClB,SAAS,MAAM,aAAa;GAC5B;EAEF,KAAK,eAAe;EACpB,KAAK,eAAe;EACpB,KAAK,eAAe,UAClB,SAAS,MAAM,aAAa;CAGhC;CACA,OAAO;AACT;;;;;;;ACjIA,SAAgB,mBACd,UACA,UACA,OACA,QAC+B;CAC/B,MAAM,SAAS,QAAQ;CACvB,MAAM,SAAS,SAAS;CACxB,OAAO,mBAAmB,MAAM,CAAC,CAAC,EAChC,KACA,OACG,WAAW,UACZ,OACC,WAAW,UACZ,OACC,WAAW,UACZ,OACC,WAAW,UACZ,MACA,WACA,OACC,WAAW,UACZ,GACJ;AACF;;;;AC5BA,MAAa,yBAAyB,UAAkB;CACtD,MAAM,OAAO;CACb,MAAM,OAAQ,QAAQ,OAAQ,QAAQ;CACtC,IAAI,MAAM,kBACR,OAAO,eAAe;MACjB,IAAI,MAAM,mBACf,OAAO,eAAe;MACjB,IAAI,MAAM,kBACf,OAAO,eAAe;MACjB,IAAI,MAAM,mBACf,OAAO,eAAe;MACjB,IAAI,MAAM,mBACf,OAAO,eAAe;MACjB,IAAI,MAAM,mBACf,OAAO,eAAe;MACjB,IAAI,MAAM,mBACf,OAAO,eAAe;MACjB,IAAI,MAAM,mBACf,OAAO,eAAe;MAEtB,OAAO,eAAe;AAE1B;;ACVA,MAAa,MAAM;CACjB,QAAQ;CACR,OAAO,SAAqB,IAAI,cAAc,IAAI;CAE1C;CACI;CACH;CACI;CACN;CACD;CACA;CACiB;CACA;CACvB,KAAKC;CACC;CACW;CACG;CAEG;AACzB"}
1
+ {"version":3,"file":"svg-Yz7elqnU.mjs","names":["svg","svgsvg"],"sources":["../../package-ui/svg/attributes.ts","../../package-ui/svg/shared.ts","../../package-ui/svg/primitives/shared.ts","../../package-ui/svg/primitives/ellipse.ts","../../package-ui/svg/primitives/circle.ts","../../package-ui/svg/primitives/group.ts","../../package-ui/svg/primitives/line.ts","../../package-ui/svg/primitives/path.ts","../../package-ui/svg/primitives/rectangle.ts","../../package-ui/svg/primitives/svg.ts","../../package-ui/svg/util/anchorPoint.ts","../../package-ui/svg/primitives/text.ts","../../package-ui/svg/primitives/triangle.ts","../../package-ui/svg/util/angleToAnchorPoint.ts","../../package-ui/svg/index.ts"],"sourcesContent":["export class SVGAttributes<T extends SVGElement> {\n constructor(elem: T) {\n this.#elem = elem;\n }\n #elem: T;\n /**Returns the svg element */\n get elem(): T {\n this.#apply_transforms();\n return this.#elem;\n }\n\n /** Sets the stroke color of the SVG element */\n stroke(stroke: string): this {\n this.#elem.setAttribute(\"stroke\", stroke);\n return this;\n }\n /** Sets the stroke color of the SVG element */\n s(stroke: string): this {\n this.#elem.setAttribute(\"stroke\", stroke);\n return this;\n }\n\n /** Sets the fill color of the SVG element */\n fill(fill: string): this {\n this.#elem.setAttribute(\"fill\", fill);\n return this;\n }\n /** Sets the fill color of the SVG element */\n f(fill: string): this {\n this.#elem.setAttribute(\"fill\", fill);\n return this;\n }\n\n /** Sets the stroke width of the SVG element */\n stroke_width(width: number): this {\n this.#elem.setAttribute(\"stroke-width\", String(width));\n return this;\n }\n /** Sets the stroke width of the SVG element */\n sw(width: number): this {\n this.#elem.setAttribute(\"stroke-width\", String(width));\n return this;\n }\n\n /** Adds one or more class names to the SVG element */\n class_list(...class_name: string[]): this {\n this.#elem.classList.add(...class_name);\n return this;\n }\n /** Adds one or more class names to the SVG element */\n cl(...class_name: string[]): this {\n this.#elem.classList.add(...class_name);\n return this;\n }\n\n /** Sets an arbitrary attribute on the SVG element */\n attribute(name: string, value: string): this {\n this.#elem.setAttribute(name, value);\n return this;\n }\n /** Sets an arbitrary attribute on the SVG element */\n a(name: string, value: string): this {\n this.#elem.setAttribute(name, value);\n return this;\n }\n\n #transforms: string[] = [];\n #apply_transforms(): void {\n if (this.#transforms.length > 0)\n this.#elem.setAttribute(\"transform\", this.#transforms.join(\" \"));\n }\n\n /** Applies a translation transform to the SVG element */\n translate(x: number, y: number): this {\n this.#transforms.push(`translate(${x} ${y})`);\n return this;\n }\n\n /** Applies a rotation transform to the SVG element */\n rotate(angle: number, cx?: number, cy?: number): this {\n if (cx !== undefined && cy !== undefined)\n this.#transforms.push(`rotate(${angle} ${cx} ${cy})`);\n else this.#transforms.push(`rotate(${angle})`);\n return this;\n }\n\n /** Applies a scaling transform to the SVG element */\n scale(sx: number, sy?: number): this {\n if (sy !== undefined) this.#transforms.push(`scale(${sx} ${sy})`);\n else this.#transforms.push(`scale(${sx})`);\n return this;\n }\n\n /** Applies a skewX transform to the SVG element */\n skewX(angle: number): this {\n this.#transforms.push(`skewX(${angle})`);\n return this;\n }\n\n /** Applies a skewY transform to the SVG element */\n skewY(angle: number): this {\n this.#transforms.push(`skewY(${angle})`);\n return this;\n }\n\n /** Applies a custom transform to the SVG element */\n transform(transform: string): this {\n this.#transforms.push(transform);\n return this;\n }\n}\n","export const NAME_SPACE = \"http://www.w3.org/2000/svg\";\n","import { SVGAttributes } from \"../attributes\";\nimport { NAME_SPACE } from \"../shared\";\n\nexport function create_svg_element<K extends keyof SVGElementTagNameMap>(\n name: K,\n): SVGAttributes<SVGElementTagNameMap[K]> {\n return new SVGAttributes(document.createElementNS(NAME_SPACE, name));\n}\n","import { degrees_to_radians } from \"@chocbite/ts-lib/math\";\nimport { SVGAttributes } from \"../attributes\";\nimport { create_svg_element } from \"./shared\";\n\n/**This creates a svg ellipse\n * @param center_x x coordinate of center\n * @param center_y y coordinate of center\n * @param radius_x x radius of circle\n * @param radius_y y radius of circle*/\nexport function ellipse(\n center_x: number,\n center_y: number,\n radius_x: number,\n radius_y: number,\n): SVGAttributes<SVGEllipseElement> {\n return create_svg_element(\"ellipse\")\n .a(\"cx\", String(center_x))\n .a(\"cy\", String(center_y))\n .a(\"rx\", String(radius_x))\n .a(\"ry\", String(radius_y));\n}\n\n/**This draws parts of a circle/ellipse, the circle direction is reversed\n * @param center_x the center point on the x axis\n * @param center_y the center point on the y axis\n * @param radius_x radius in x axis\n * @param radius_y radius in y axis\n * @param start_angle start angle in degrees\n * @param end_angle end angle in degrees, a sweep of 360 degrees or more draws the whole ellipse*/\nexport function ellipse_arc(\n center_x: number,\n center_y: number,\n radius_x: number,\n radius_y: number,\n start_angle: number,\n end_angle: number,\n): SVGAttributes<SVGPathElement> {\n const start_radian = degrees_to_radians(start_angle);\n const sweep = degrees_to_radians(end_angle - start_angle);\n const point = (radian: number) =>\n `${radius_x * Math.cos(radian) + center_x} ${radius_y * Math.sin(radian) + center_y}`;\n const f_s = sweep > 0 ? 1 : 0;\n const arc = `A ${radius_x} ${radius_y} 0`;\n //An arc ending where it starts draws nothing, so the whole ellipse is two halves\n if (Math.abs(sweep) >= 2 * Math.PI) {\n const half = start_radian + (sweep > 0 ? Math.PI : -Math.PI);\n return create_svg_element(\"path\").a(\n \"d\",\n `M ${point(start_radian)} ${arc} 0 ${f_s} ${point(half)} ${arc} 0 ${f_s} ${point(start_radian)}`,\n );\n }\n const f_a = Math.abs(sweep) > Math.PI ? 1 : 0;\n return create_svg_element(\"path\").a(\n \"d\",\n `M ${point(start_radian)} ${arc} ${f_a} ${f_s} ${point(start_radian + sweep)}`,\n );\n}\n","import { SVGAttributes } from \"../attributes\";\nimport { ellipse_arc } from \"./ellipse\";\nimport { create_svg_element } from \"./shared\";\n\n/**This creates a svg circle\n * @param center_x x coordinate of center\n * @param center_y y coordinate of center\n * @param radius radius of circle*/\nexport function circle(\n center_x: number,\n center_y: number,\n radius: number,\n): SVGAttributes<SVGCircleElement> {\n const circle = create_svg_element(\"circle\");\n circle.a(\"cx\", String(center_x));\n circle.a(\"cy\", String(center_y));\n circle.a(\"r\", String(radius));\n return circle;\n}\n\n/**This draws parts of a circle/ellipse, the circle direction is reversed\n * @param center_x the center point on the x axis\n * @param center_y the center point on the y axis\n * @param radius radius in x axis\n * @param start_angle start angle in degrees\n * @param end_angle end angle in degrees, a sweep of 360 degrees or more draws the whole circle*/\nexport function circle_arc(\n center_x: number,\n center_y: number,\n radius: number,\n start_angle: number,\n end_angle: number,\n): SVGAttributes<SVGPathElement> {\n return ellipse_arc(\n center_x,\n center_y,\n radius,\n radius,\n start_angle,\n end_angle,\n );\n}\n","import { SVGAttributes } from \"../attributes\";\nimport { create_svg_element } from \"./shared\";\n\n/**This draws a triangle*/\nexport function group(): SVGAttributes<SVGGElement> {\n return create_svg_element(\"g\");\n}\n","import { SVGAttributes } from \"../attributes\";\nimport { create_svg_element } from \"./shared\";\n\n/**This creates a line element\n * @param start_x start point on x axis\n * @param start_y start point on y axis\n * @param end_x end point on x axis\n * @param end_y end point on y axis*/\nexport function line(\n start_x: number,\n start_y: number,\n end_x: number,\n end_y: number,\n): SVGAttributes<SVGLineElement> {\n return create_svg_element(\"line\")\n .a(\"x1\", String(start_x))\n .a(\"y1\", String(start_y))\n .a(\"x2\", String(end_x))\n .a(\"y2\", String(end_y));\n}\n","import { SVGAttributes } from \"../attributes\";\nimport { create_svg_element } from \"./shared\";\n\n/**This creates a path element*/\nexport function path(path: string): SVGAttributes<SVGPathElement> {\n return create_svg_element(\"path\").a(\"d\", path);\n}\n\n/**This creates a line with a path element\n * @param start_x start point on x axis\n * @param start_y start point on y axis\n * @param end_x end point on x axis\n * @param end_y end point on y axis*/\nexport function path_line(\n start_x: number,\n start_y: number,\n end_x: number,\n end_y: number,\n): SVGAttributes<SVGPathElement> {\n return create_svg_element(\"path\").a(\n \"d\",\n `M ${start_x} ${start_y} L ${end_x} ${end_y}`,\n );\n}\n","import { SVGAttributes } from \"../attributes\";\nimport { create_svg_element } from \"./shared\";\n\n/**This creates a rectangle with teh center as origin\n * @param center_x x coordinate of center\n * @param center_y y coordinate of center\n * @param width width\n * @param height height\n * @param corner_radius radius of corner*/\nexport function rectangle_from_center(\n center_x: number,\n center_y: number,\n width: number,\n height: number,\n corner_radius: number,\n): SVGAttributes<SVGRectElement> {\n return create_svg_element(\"rect\")\n .a(\"x\", String(center_x - width / 2))\n .a(\"y\", String(center_y - height / 2))\n .a(\"width\", String(width))\n .a(\"height\", String(height))\n .a(\"rx\", String(corner_radius));\n}\n\n/**This creates a rectangle with teh center as origin\n * @param start_x x coordinate of center\n * @param start_y y coordinate of center\n * @param width width\n * @param height height\n * @param corner_radius radius of corner*/\nexport function rectangle_from_corner(\n start_x: number,\n start_y: number,\n width: number,\n height: number,\n corner_radius: number,\n): SVGAttributes<SVGRectElement> {\n return create_svg_element(\"rect\")\n .a(\"x\", String(start_x))\n .a(\"y\", String(start_y))\n .a(\"width\", String(width))\n .a(\"height\", String(height))\n .a(\"rx\", String(corner_radius));\n}\n","import { SVGAttributes } from \"../attributes\";\nimport { create_svg_element } from \"./shared\";\n\n/** This returns an empty svg element\n * @param width width of svg\n * @param height height of svg\n * @param viewbox viewbox of svg*/\nexport function svg(\n width: number,\n height: number,\n viewbox: string = `0 0 ${width} ${height}`,\n): SVGAttributes<SVGSVGElement> {\n return create_svg_element(\"svg\")\n .a(\"width\", String(width))\n .a(\"height\", String(height))\n .a(\"viewBox\", String(viewbox));\n}\n","//Enum describing the diffrent possible anchor points\nexport const SVGAnchorPoint = {\n bottomLeft: 0,\n middleLeft: 1,\n topLeft: 2,\n topCenter: 3,\n topRight: 4,\n middleRight: 5,\n bottomRight: 6,\n bottomCenter: 7,\n middleCenter: 8,\n} as const;\nexport type SVGAnchorPoint =\n (typeof SVGAnchorPoint)[keyof typeof SVGAnchorPoint];\n","import { SVGAttributes } from \"../attributes\";\nimport { SVGAnchorPoint } from \"../util/anchorPoint\";\nimport { create_svg_element } from \"./shared\";\n\n/**Creates a text nodes for an svg\n * @param x x coordinate of text\n * @param y y coordinate of text\n * @param text text\n * @param size size of text in px\n * @param anchor anchor point of text*/\nexport function text(\n x: number,\n y: number,\n text: string,\n size: number,\n anchor: SVGAnchorPoint,\n): SVGAttributes<SVGTextElement> {\n const text_elem = create_svg_element(\"text\")\n .a(\"x\", String(x))\n .a(\"y\", String(y))\n .a(\"font-size\", String(size));\n text_elem.elem.textContent = text;\n switch (anchor) {\n case SVGAnchorPoint.bottomLeft:\n case SVGAnchorPoint.middleLeft:\n case SVGAnchorPoint.topLeft: {\n text_elem.a(\"text-anchor\", \"start\");\n break;\n }\n case SVGAnchorPoint.topCenter:\n case SVGAnchorPoint.bottomCenter:\n case SVGAnchorPoint.middleCenter: {\n text_elem.a(\"text-anchor\", \"middle\");\n break;\n }\n case SVGAnchorPoint.topRight:\n case SVGAnchorPoint.middleRight:\n case SVGAnchorPoint.bottomRight: {\n text_elem.a(\"text-anchor\", \"end\");\n break;\n }\n }\n switch (anchor) {\n case SVGAnchorPoint.bottomLeft:\n case SVGAnchorPoint.bottomRight:\n case SVGAnchorPoint.bottomCenter: {\n text_elem.a(\"dominant-baseline\", \"auto\");\n break;\n }\n case SVGAnchorPoint.middleLeft:\n case SVGAnchorPoint.middleRight:\n case SVGAnchorPoint.middleCenter: {\n text_elem.a(\"dominant-baseline\", \"central\");\n break;\n }\n case SVGAnchorPoint.topLeft:\n case SVGAnchorPoint.topCenter:\n case SVGAnchorPoint.topRight: {\n text_elem.a(\"dominant-baseline\", \"hanging\");\n break;\n }\n }\n return text_elem;\n}\n\n/**Creates a text nodes for an svg\n * @param x x coordinate of text\n * @param y y coordinate of text\n * @param width width of text\n * @param height height of text\n * @param text text\n * @param size size of text in px\n * @param anchor anchor point of */\nexport function multi_line_text(\n x: number,\n y: number,\n width: number,\n height: number,\n text: string,\n size: number,\n anchor: SVGAnchorPoint,\n): SVGAttributes<SVGForeignObjectElement> {\n const text_element = create_svg_element(\"foreignObject\");\n const text_div = text_element.elem.appendChild(document.createElement(\"div\"));\n text_element.a(\"width\", String(width));\n text_element.a(\"height\", String(height));\n text_element.a(\"x\", String(x));\n text_element.a(\"y\", String(y));\n text_div.style.fontSize = size + \"px\";\n text_div.style.width = \"100%\";\n text_div.style.height = \"100%\";\n text_div.style.display = \"flex\";\n text_div.textContent = text;\n switch (anchor) {\n case SVGAnchorPoint.bottomLeft:\n case SVGAnchorPoint.middleLeft:\n case SVGAnchorPoint.topLeft: {\n text_div.style.textAlign = \"start\";\n text_div.style.justifyContent = \"flex-start\";\n break;\n }\n case SVGAnchorPoint.topCenter:\n case SVGAnchorPoint.bottomCenter:\n case SVGAnchorPoint.middleCenter: {\n text_div.style.textAlign = \"center\";\n text_div.style.justifyContent = \"center\";\n break;\n }\n case SVGAnchorPoint.topRight:\n case SVGAnchorPoint.middleRight:\n case SVGAnchorPoint.bottomRight: {\n text_div.style.textAlign = \"end\";\n text_div.style.justifyContent = \"flex-end\";\n break;\n }\n }\n switch (anchor) {\n case SVGAnchorPoint.bottomLeft:\n case SVGAnchorPoint.bottomRight:\n case SVGAnchorPoint.bottomCenter: {\n text_div.style.alignItems = \"flex-end\";\n break;\n }\n case SVGAnchorPoint.middleLeft:\n case SVGAnchorPoint.middleRight:\n case SVGAnchorPoint.middleCenter: {\n text_div.style.alignItems = \"center\";\n break;\n }\n case SVGAnchorPoint.topLeft:\n case SVGAnchorPoint.topCenter:\n case SVGAnchorPoint.topRight: {\n text_div.style.alignItems = \"flex-start\";\n break;\n }\n }\n return text_element;\n}\n","import { SVGAttributes } from \"../attributes\";\nimport { create_svg_element } from \"./shared\";\n\n/**This draws a triangle\n * @param center_x x coordinate of center\n * @param center_y y coordinate of center\n * @param width width\n * @param height height*/\nexport function isosceles_triangle(\n center_x: number,\n center_y: number,\n width: number,\n height: number,\n): SVGAttributes<SVGPathElement> {\n const half_w = width / 2;\n const half_h = height / 2;\n return create_svg_element(\"path\").a(\n \"d\",\n \"M\" +\n (center_x - half_w) +\n \",\" +\n (center_y + half_h) +\n \" \" +\n (center_x + half_w) +\n \",\" +\n (center_y + half_h) +\n \" \" +\n center_x +\n \",\" +\n (center_y - half_h) +\n \"Z\",\n );\n}\n","import { SVGAnchorPoint } from \"./anchorPoint\";\n\n/**Converts an angle to an anchor point\n * @param angle angle in radians, any angle outside 0 to 2PI is wrapped around*/\nexport const angle_to_anchor_point = (angle: number) => {\n const full = 6.283185307179586;\n const sec = ((angle % full) + full) % full;\n if (sec > 5.93411945678072) {\n return SVGAnchorPoint.middleRight;\n } else if (sec > 4.974188368183839) {\n return SVGAnchorPoint.topRight;\n } else if (sec > 4.45058959258554) {\n return SVGAnchorPoint.topCenter;\n } else if (sec > 3.4906585039886591) {\n return SVGAnchorPoint.topLeft;\n } else if (sec > 2.792526803190927) {\n return SVGAnchorPoint.middleLeft;\n } else if (sec > 1.832595714594046) {\n return SVGAnchorPoint.bottomLeft;\n } else if (sec > 1.308996938995747) {\n return SVGAnchorPoint.bottomCenter;\n } else if (sec > 0.3490658503988659) {\n return SVGAnchorPoint.bottomRight;\n } else {\n return SVGAnchorPoint.middleRight;\n }\n};\n","import { SVGAttributes } from \"./attributes\";\nimport { circle, circle_arc } from \"./primitives/circle\";\nimport { ellipse, ellipse_arc } from \"./primitives/ellipse\";\nimport { group } from \"./primitives/group\";\nimport { line } from \"./primitives/line\";\nimport { path } from \"./primitives/path\";\nimport {\n rectangle_from_center,\n rectangle_from_corner,\n} from \"./primitives/rectangle\";\nimport { create_svg_element } from \"./primitives/shared\";\nimport { svg as svgsvg } from \"./primitives/svg\";\nimport { multi_line_text, text } from \"./primitives/text\";\nimport { isosceles_triangle } from \"./primitives/triangle\";\nimport { angle_to_anchor_point } from \"./util/angleToAnchorPoint\";\n\nexport const svg = {\n create: create_svg_element,\n attr: (elem: SVGElement) => new SVGAttributes(elem),\n //Primitives\n circle: circle,\n circle_arc: circle_arc,\n ellipse: ellipse,\n ellipse_arc: ellipse_arc,\n group: group,\n line: line,\n path: path,\n rectangle_from_center: rectangle_from_center,\n rectangle_from_corner: rectangle_from_corner,\n svg: svgsvg,\n text: text,\n multi_line_text: multi_line_text,\n isosceles_triangle: isosceles_triangle,\n //Utilities\n angle_to_anchor_point: angle_to_anchor_point,\n};\n\nexport type SVGFunc = () => SVGSVGElement;\nexport { SVGAnchorPoint } from \"./util/anchorPoint\";\n\ndeclare global {\n /**Types enum icons in @chocbite/ts-lib state as SVGFunc*/\n interface ChocbiteStateRegister {\n icon: SVGFunc;\n }\n /**Types icons of nodes in the @chocbite/ts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,IAAI;CAE1C;CACI;CACH;CACI;CACN;CACD;CACA;CACiB;CACA;CACvB,KAAKC;CACC;CACW;CACG;CAEG;AACzB"}
package/theme/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import '../style.css';
2
- import { t as SVGFunc } from "../index-BDWg5GX2.mjs";
2
+ import { t as SVGFunc } from "../index-Czy8O3me.mjs";
3
3
  export declare const BUILT_IN = 0;
4
4
  export declare const Themes: {
5
5
  readonly Light: "light";
package/theme/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
  import "../style.css";
2
- export { s as ANIMATION_LEVEL, c as ANIMATION_SPEED, l as AnimationLevels, n as BUILT_IN, u as INPUT_MODE, d as InputModes, f as SCALE, p as SCROLLBAR_MODE, m as ScrollbarModes, h as THEME, r as ThemeVariableGroup, g as Themes, a as px_to_rem, o as rem_to_px, t as theme_init, i as theme_init_variable_root } from "../theme-D3YluyYr.mjs";
2
+ export { s as ANIMATION_LEVEL, c as ANIMATION_SPEED, l as AnimationLevels, n as BUILT_IN, u as INPUT_MODE, d as InputModes, f as SCALE, p as SCROLLBAR_MODE, m as ScrollbarModes, h as THEME, r as ThemeVariableGroup, g as Themes, a as px_to_rem, o as rem_to_px, t as theme_init, i as theme_init_variable_root } from "../theme-ycsugrdT.mjs";
@@ -6,7 +6,7 @@ import { state as state$1 } from "@chocbite/ts-lib/state";
6
6
  import { none, ok, some } from "@chocbite/ts-lib/result";
7
7
  import { GREY } from "@chocbite/ts-lib/colors";
8
8
  // ../package.json
9
- var version = "1.1.5";
9
+ var version = "1.2.1";
10
10
  // theme/settings.ts
11
11
  const SETTINGS = settings_init("@chocbite/ts-lib-theme", version, "Theme/UI", "Settings for UI elements and color themes");
12
12
  /**Accepts a stored setting only when it is one of the given values, otherwise the default is used*/
@@ -416,4 +416,4 @@ function theme_init(options = {}) {
416
416
  }
417
417
  export { version as _, px_to_rem as a, ANIMATION_SPEED as c, InputModes as d, SCALE as f, Themes as g, THEME as h, theme_init_variable_root as i, AnimationLevels as l, ScrollbarModes as m, BUILT_IN as n, rem_to_px as o, SCROLLBAR_MODE as p, ThemeVariableGroup as r, ANIMATION_LEVEL as s, theme_init as t, INPUT_MODE as u };
418
418
 
419
- //# sourceMappingURL=theme-D3YluyYr.mjs.map
419
+ //# sourceMappingURL=theme-ycsugrdT.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"theme-D3YluyYr.mjs","names":["st"],"sources":["../../package.json","../../package-ui/theme/settings.ts","../../package-ui/theme/shared.ts","../../package-ui/theme/engine.ts","../../package-ui/theme/variables.ts","../../package-ui/theme/builtIn.ts","../../package-ui/theme/init.ts"],"sourcesContent":["","import {\n material_dark_mode_rounded,\n material_edit_rounded,\n material_light_mode_rounded,\n material_mouse_rounded,\n material_touch_app_rounded,\n} from \"#icons\";\nimport { settings_init } from \"#settings\";\nimport { none, ok, some, type Option } from \"@chocbite/ts-lib/result\";\nimport { state as st } from \"@chocbite/ts-lib/state\";\nimport { version } from \"../../package.json\";\n\nconst SETTINGS = settings_init(\n \"@chocbite/ts-lib-theme\",\n version,\n \"Theme/UI\",\n \"Settings for UI elements and color themes\",\n);\n\n/**Accepts a stored setting only when it is one of the given values, otherwise the default is used*/\nconst one_of =\n <T>(values: { [key: string]: T }) =>\n (stored: unknown): Option<T> =>\n Object.values(values).includes(stored as T) ? some(stored as T) : none();\n\n/**Accepts a stored setting only when it is a number within the range, otherwise the default is used*/\nconst in_range =\n (min: number, max: number) =>\n (stored: unknown): Option<number> =>\n typeof stored === \"number\" && stored >= min && stored <= max\n ? some(stored)\n : none();\n\n// _______ _ _ ______ __ __ ______\n// |__ __| | | | ____| \\/ | ____|\n// | | | |__| | |__ | \\ / | |__\n// | | | __ | __| | |\\/| | __|\n// | | | | | | |____| | | | |____\n// |_| |_| |_|______|_| |_|______|\nexport const Themes = {\n Light: \"light\",\n Dark: \"dark\",\n /**Follows the light or dark mode of the operating system, only offered when theme_init enables system*/\n System: \"system\",\n} as const;\nexport type Themes = (typeof Themes)[keyof typeof Themes];\n/**Themes that can be applied to the page, System is resolved to one of these*/\nexport type AppliedThemes = typeof Themes.Light | typeof Themes.Dark;\n\ntype ThemeList = Parameters<typeof st.e.list<Themes>>[0];\nconst LIGHT = {\n name: \"Light\",\n description: \"Theme optimized for daylight\",\n icon: material_light_mode_rounded,\n};\nconst DARK = {\n name: \"Dark\",\n description: \"Theme optimized for night time\",\n icon: material_dark_mode_rounded,\n};\n/**Theme choices, the System choice shows the theme the operating system currently uses\n * @param system theme of the operating system, undefined when the System choice is not offered*/\nconst theme_list = (system?: AppliedThemes): ThemeList => {\n const list: Partial<ThemeList> = {\n [Themes.Light]: LIGHT,\n [Themes.Dark]: DARK,\n };\n if (system) {\n const active = system === Themes.Dark ? DARK : LIGHT;\n list[Themes.System] = {\n name: \"System (\" + active.name + \")\",\n description: \"Follows the light or dark mode of the operating system\",\n icon: active.icon,\n };\n }\n return list as ThemeList;\n};\nconst THEMES = st.ok_w(theme_list());\n\nconst THEME_ID = \"theme\";\n/**Theme the user chose, undefined when nothing has been chosen yet*/\nconst STORED_THEME = SETTINGS.get<Themes | undefined>(\n THEME_ID,\n undefined,\n one_of(Themes),\n).value;\nconst PRIVATE_THEME = st.rosw(\n st.e.help(ok(STORED_THEME ?? (Themes.Light as Themes)), { list: THEMES }),\n true,\n);\n\nexport const THEME = PRIVATE_THEME.read_write;\n\n/**Sets up the theme setting, called once by theme_init\n * @param system theme of the operating system, undefined when the System choice is not offered\n * @param default_theme theme used when the user has not chosen one*/\nexport function theme_setting_init(\n system: AppliedThemes | undefined,\n default_theme: Themes,\n) {\n if (system) THEMES.set_ok(theme_list(system));\n //Set before registering, so the default is not stored as if the user chose it\n if (STORED_THEME === undefined || (STORED_THEME === Themes.System && !system))\n PRIVATE_THEME.set_ok(default_theme);\n SETTINGS.register(\n THEME_ID,\n \"Theme\",\n \"Theme to use for the UI\",\n PRIVATE_THEME,\n );\n}\n\n/**Updates the System choice to show the theme the operating system uses*/\nexport function theme_setting_system(system: AppliedThemes) {\n THEMES.set_ok(theme_list(system));\n}\n\n// _____ _____ _ ______\n// / ____|/ ____| /\\ | | | ____|\n// | (___ | | / \\ | | | |__\n// \\___ \\| | / /\\ \\ | | | __|\n// ____) | |____ / ____ \\| |____| |____\n// |_____/ \\_____/_/ \\_\\______|______|\nconst SCALE_ID = \"scale\";\nconst PRIVATE_SCALE = st.rosw(\n st.n.help(SETTINGS.get(SCALE_ID, 100, in_range(50, 400)), {\n min: st.ok(50),\n max: st.ok(400),\n unit: st.ok(\"%\"),\n start: st.ok(0),\n step: st.ok(1),\n }),\n true,\n);\nSETTINGS.register(SCALE_ID, \"Scale\", \"UI scale\", PRIVATE_SCALE);\nexport const SCALE = PRIVATE_SCALE.read_write;\n\n// _____ _____ _____ ____ _ _ ____ _____\n// / ____|/ ____| __ \\ / __ \\| | | | | _ \\ /\\ | __ \\\n// | (___ | | | |__) | | | | | | | | |_) | / \\ | |__) |\n// \\___ \\| | | _ /| | | | | | | | _ < / /\\ \\ | _ /\n// ____) | |____| | \\ \\| |__| | |____| |____| |_) / ____ \\| | \\ \\\n// |_____/ \\_____|_| \\_\\\\____/|______|______|____/_/ \\_\\_| \\_\\\nexport const ScrollbarModes = {\n Thin: \"thin\",\n Medium: \"medium\",\n Wide: \"wide\",\n} as const;\nexport type ScrollbarModes =\n (typeof ScrollbarModes)[keyof typeof ScrollbarModes];\n\nconst SCROLLBAR_MODES = st.ok(\n st.e.list<ScrollbarModes>({\n [ScrollbarModes.Thin]: {\n name: \"Thin\",\n description: \"Thin modern scrollbar\",\n },\n [ScrollbarModes.Medium]: {\n name: \"Medium\",\n description: \"Normal scrollbar\",\n },\n [ScrollbarModes.Wide]: {\n name: \"Wide\",\n description: \"Large touch friendly scrollbar\",\n },\n }),\n);\n\nconst SCROLLBAR_ID = \"scrollbar\";\nconst PRIVATE_SCROLLBAR_MODE = st.rosw(\n st.e.help(\n SETTINGS.get(\n SCROLLBAR_ID,\n ScrollbarModes.Thin as ScrollbarModes,\n one_of(ScrollbarModes),\n ),\n { list: SCROLLBAR_MODES },\n ),\n true,\n);\nSETTINGS.register(\n \"scrollbar\",\n \"Scrollbar Mode\",\n \"Size of the scrollbar to use\",\n PRIVATE_SCROLLBAR_MODE,\n);\n\nexport const SCROLLBAR_MODE = PRIVATE_SCROLLBAR_MODE.read_write;\n\n// _____ _ _ _____ _ _ _______ __ __ ____ _____ ______\n// |_ _| \\ | | __ \\| | | |__ __| | \\/ |/ __ \\| __ \\| ____|\n// | | | \\| | |__) | | | | | | | \\ / | | | | | | | |__\n// | | | . ` | ___/| | | | | | | |\\/| | | | | | | | __|\n// _| |_| |\\ | | | |__| | | | | | | | |__| | |__| | |____\n// |_____|_| \\_|_| \\____/ |_| |_| |_|\\____/|_____/|______|\nexport const InputModes = {\n Mouse: \"mouse\",\n Pen: \"pen\",\n Touch: \"touch\",\n} as const;\nexport type InputModes = (typeof InputModes)[keyof typeof InputModes];\n\nconst INPUT_MODES = st.ok(\n st.e.list<InputModes>({\n [InputModes.Mouse]: {\n name: \"Mouse\",\n description: \"Mouse input\",\n icon: material_mouse_rounded,\n },\n [InputModes.Pen]: {\n name: \"Pen\",\n description: \"Pen input\",\n icon: material_edit_rounded,\n },\n [InputModes.Touch]: {\n name: \"Touch\",\n description: \"Touch input\",\n icon: material_touch_app_rounded,\n },\n }),\n);\n\nconst INPUT_MODE_ID = \"input_mode\";\nconst PRIVATE_INPUT_MODE = st.rosw(\n st.e.help(\n SETTINGS.get(\n INPUT_MODE_ID,\n matchMedia(\"(pointer: coarse)\").matches\n ? InputModes.Touch\n : (InputModes.Mouse as InputModes),\n one_of(InputModes),\n ),\n { list: INPUT_MODES },\n ),\n true,\n);\nSETTINGS.register(\n INPUT_MODE_ID,\n \"Input Mode\",\n \"Setting for preffered input mode, changes UI elements to be more optimized for the selected input mode\",\n PRIVATE_INPUT_MODE,\n);\n\nexport const INPUT_MODE = PRIVATE_INPUT_MODE.read_write;\n\n// _ _ _____ __ __ _______ _____ ____ _ _ _ ________ ________ _\n// /\\ | \\ | |_ _| \\/ | /\\|__ __|_ _/ __ \\| \\ | | | | | ____\\ \\ / / ____| |\n// / \\ | \\| | | | | \\ / | / \\ | | | || | | | \\| | | | | |__ \\ \\ / /| |__ | |\n// / /\\ \\ | . ` | | | | |\\/| | / /\\ \\ | | | || | | | . ` | | | | __| \\ \\/ / | __| | |\n// / ____ \\| |\\ |_| |_| | | |/ ____ \\| | _| || |__| | |\\ | | |____| |____ \\ / | |____| |____\n// /_/ \\_\\_| \\_|_____|_| |_/_/ \\_\\_| |_____\\____/|_| \\_| |______|______| \\/ |______|______|\nexport const AnimationLevels = {\n All: \"all\",\n Some: \"some\",\n None: \"none\",\n} as const;\nexport type AnimationLevels =\n (typeof AnimationLevels)[keyof typeof AnimationLevels];\n\nconst ANIMATION_LEVELS = st.ok(\n st.e.list<AnimationLevels>({\n [AnimationLevels.All]: { name: \"All\", description: \"All animations\" },\n [AnimationLevels.Some]: {\n name: \"Functional\",\n description: \"Only functional animations that improve usability\",\n },\n [AnimationLevels.None]: { name: \"None\", description: \"No animations\" },\n }),\n);\n\nconst ANIMATION_LEVEL_ID = \"animation_level\";\nconst PRIVATE_ANIMATION_LEVEL = st.rosw(\n st.e.help(\n SETTINGS.get(\n ANIMATION_LEVEL_ID,\n AnimationLevels.None as AnimationLevels,\n one_of(AnimationLevels),\n ),\n { list: ANIMATION_LEVELS },\n ),\n true,\n);\nSETTINGS.register(\n ANIMATION_LEVEL_ID,\n \"Animation Level\",\n \"Setting for animation level, changes the amount of animations used in the UI\",\n PRIVATE_ANIMATION_LEVEL,\n);\n\nexport const ANIMATION_LEVEL = PRIVATE_ANIMATION_LEVEL.read_write;\n\n// _ _ _____ __ __ _______ _____ ____ _ _ _____ _____ ______ ______ _____\n// /\\ | \\ | |_ _| \\/ | /\\|__ __|_ _/ __ \\| \\ | | / ____| __ \\| ____| ____| __ \\\n// / \\ | \\| | | | | \\ / | / \\ | | | || | | | \\| | | (___ | |__) | |__ | |__ | | | |\n// / /\\ \\ | . ` | | | | |\\/| | / /\\ \\ | | | || | | | . ` | \\___ \\| ___/| __| | __| | | | |\n// / ____ \\| |\\ |_| |_| | | |/ ____ \\| | _| || |__| | |\\ | ____) | | | |____| |____| |__| |\n// /_/ \\_\\_| \\_|_____|_| |_/_/ \\_\\_| |_____\\____/|_| \\_| |_____/|_| |______|______|_____/\nconst ANIMATION_SPEED_ID = \"animation_speed\";\nconst PRIVATE_ANIMATION_SPEED = st.rosw(\n st.n.help(SETTINGS.get(ANIMATION_SPEED_ID, 200, in_range(50, 1000)), {\n min: st.ok(50),\n max: st.ok(1000),\n unit: st.ok(\"ms\"),\n start: st.ok(0),\n step: st.ok(50),\n }),\n true,\n);\nSETTINGS.register(\n ANIMATION_SPEED_ID,\n \"Animation Speed\",\n \"Setting for animation speed, changes the speed of animations in the UI\",\n PRIVATE_ANIMATION_SPEED,\n);\n\nexport const ANIMATION_SPEED = PRIVATE_ANIMATION_SPEED.read_write;\n","import type { ThemeVariableGroup } from \"./variables\";\n\nexport const BOTTOM_GROUPS: { [key: string]: ThemeVariableGroup } = {};\n","import { DOCUMENT_HANDLER } from \"#document\";\nimport {\n ANIMATION_LEVEL,\n ANIMATION_SPEED,\n AnimationLevels,\n INPUT_MODE,\n InputModes,\n SCALE,\n SCROLLBAR_MODE,\n ScrollbarModes,\n THEME,\n Themes,\n type AppliedThemes,\n} from \"./settings\";\nimport { BOTTOM_GROUPS } from \"./shared\";\n\nclass ThemeEngine {\n #started = false;\n /**Theme of the operating system, used for the System theme*/\n #os_theme: AppliedThemes = Themes.Light;\n\n /**Starts applying the theme to all documents, called once by theme_init*/\n start() {\n this.#started = true;\n DOCUMENT_HANDLER.events.on(\"added\", (e) => {\n this.#apply_all_to_doc(e.data);\n });\n this.#for_documents((doc) => {\n this.#apply_all_to_doc(doc);\n });\n }\n\n /**Runs for every document, nothing is applied before the engine is started*/\n #for_documents(func: (doc: Document) => void) {\n if (this.#started) DOCUMENT_HANDLER.for_documents(func);\n }\n\n /**Sets the theme of the operating system, reapplying the theme when System is used*/\n set_os_theme(theme: AppliedThemes) {\n this.#os_theme = theme;\n if (THEME.ok() === Themes.System) this.apply_theme(Themes.System);\n }\n\n /**Resolves the System theme to the theme of the operating system*/\n #applied(theme: Themes): AppliedThemes {\n return theme === Themes.System ? this.#os_theme : theme;\n }\n\n /**This applies the current theme to a document*/\n #apply_all_to_doc(doc: Document) {\n this.#apply_scrollbar_to_doc(doc, SCROLLBAR_MODE.ok());\n this.#apply_theme_to_doc(doc, THEME.ok());\n this.#apply_input_to_doc(doc, INPUT_MODE.ok());\n this.#apply_scale_to_doc(doc, SCALE.ok() / 100);\n this.#apply_animation_level_to_doc(doc, ANIMATION_LEVEL.ok());\n this.#apply_animation_speed_to_doc(doc, ANIMATION_SPEED.ok());\n }\n\n /**This applies the current theme to a document*/\n apply_scrollbar(scroll: ScrollbarModes) {\n this.#for_documents((doc) => {\n this.#apply_scrollbar_to_doc(doc, scroll);\n });\n }\n #apply_scrollbar_to_doc(doc: Document, scroll: ScrollbarModes) {\n doc.documentElement.style.setProperty(\n \"--scrollbar\",\n {\n [ScrollbarModes.Thin]: \"0.6rem\",\n [ScrollbarModes.Medium]: \"1rem\",\n [ScrollbarModes.Wide]: \"2.6rem\",\n }[scroll],\n );\n }\n\n /**This applies the current theme to a document*/\n apply_animation_level(anim: AnimationLevels) {\n this.#for_documents((doc) => {\n this.#apply_animation_level_to_doc(doc, anim);\n });\n }\n #apply_animation_level_to_doc(doc: Document, anim: AnimationLevels) {\n doc.documentElement.classList.remove(\"anim-all\", \"anim-some\");\n switch (anim) {\n case AnimationLevels.All:\n doc.documentElement.classList.add(\"anim-all\");\n doc.documentElement.classList.add(\"anim-some\");\n break;\n case AnimationLevels.Some:\n doc.documentElement.classList.add(\"anim-some\");\n break;\n }\n }\n\n /**This applies the current theme to a document*/\n apply_animation_speed(speed: number) {\n this.#for_documents((doc) => {\n this.#apply_animation_speed_to_doc(doc, speed);\n });\n }\n #apply_animation_speed_to_doc(doc: Document, speed: number) {\n const style = doc.documentElement.style;\n style.setProperty(\"--animation-speed\", speed.toString() + \"ms\");\n }\n\n /**This applies the current theme to a document*/\n apply_theme(theme: Themes) {\n this.#for_documents((doc) => {\n this.#apply_theme_to_doc(doc, theme);\n });\n }\n #apply_theme_to_doc(doc: Document, theme: Themes) {\n const applied = this.#applied(theme);\n for (const key in BOTTOM_GROUPS)\n BOTTOM_GROUPS[key].apply_themes(doc.documentElement.style, applied);\n }\n\n /**This applies the current scale to a document*/\n apply_scale(scale: number) {\n this.#for_documents((doc) => {\n this.#apply_scale_to_doc(doc, scale);\n });\n }\n #apply_scale_to_doc(doc: Document, scale: number) {\n doc.documentElement.style.fontSize = scale * 16 + \"px\";\n }\n\n /**Auto Input Mode */\n apply_input(mode: InputModes) {\n this.#for_documents((doc) => {\n this.#apply_input_to_doc(doc, mode);\n });\n }\n #apply_input_to_doc(doc: Document, mode: InputModes) {\n const style = doc.documentElement.style;\n style.setProperty(\"--mouse\", \"0\");\n style.setProperty(\"--pen\", \"0\");\n style.setProperty(\"--touch\", \"0\");\n doc.documentElement.classList.remove(\"mouse\", \"pen\", \"touch\");\n switch (mode) {\n case InputModes.Mouse:\n style.setProperty(\"--mouse\", \"1\");\n doc.documentElement.classList.add(\"mouse\");\n break;\n case InputModes.Pen:\n style.setProperty(\"--pen\", \"1\");\n doc.documentElement.classList.add(\"pen\");\n break;\n case InputModes.Touch:\n style.setProperty(\"--touch\", \"1\");\n doc.documentElement.classList.add(\"touch\");\n break;\n }\n }\n\n apply_single_property(key: string, variable: { [s: string]: string }) {\n const theme_buff = this.#applied(THEME.ok());\n this.#for_documents((doc) => {\n doc.documentElement.style.setProperty(key, variable[theme_buff]);\n });\n }\n}\n\nexport const theme_engine = new ThemeEngine();\n\nTHEME.sub((val) => {\n theme_engine.apply_theme(val.value);\n});\n/**Size of a rem in pixels at the current scale, set right away from the stored scale*/\nlet scale_rem = 16;\nSCALE.sub((val) => {\n const scale_value = val.value / 100;\n scale_rem = scale_value * 16;\n theme_engine.apply_scale(scale_value);\n}, true);\n/**Converts the given rems to pixels */\nexport function rem_to_px(rem: number) {\n return rem * scale_rem;\n}\n/**Converts the given pixels to rems */\nexport function px_to_rem(px: number) {\n return px / scale_rem;\n}\nSCROLLBAR_MODE.sub((val) => {\n theme_engine.apply_scrollbar(val.value);\n});\nINPUT_MODE.sub((val) => {\n theme_engine.apply_input(val.value);\n});\nANIMATION_LEVEL.sub((val) => {\n theme_engine.apply_animation_level(val.value);\n});\nANIMATION_SPEED.sub((val) => {\n theme_engine.apply_animation_speed(val.value);\n});\n","import { theme_engine } from \"./engine\";\nimport { Themes } from \"./settings\";\nimport { BOTTOM_GROUPS } from \"./shared\";\n\n/**Initialises the settings for the package\n * @param package_name use import {name} from \"../package.json\"\n * @param name name of group formatted for user reading\n * @param description a description of what the setting group is about*/\nexport const theme_init_variable_root = (\n package_name: string,\n name: string,\n description: string\n) => {\n if (package_name.includes(\"-\"))\n throw new Error(\"Dash not permitted in package name \" + package_name);\n if (package_name in BOTTOM_GROUPS)\n throw new Error(\n \"Theme variable group already registered \" +\n package_name +\n \", by another package or by this library being loaded twice\",\n );\n BOTTOM_GROUPS[package_name] = new ThemeVariableGroup(\n package_name,\n name,\n description\n );\n return BOTTOM_GROUPS[package_name];\n};\n\n/**Group of settings should never be instantiated manually use initSettings*/\nexport class ThemeVariableGroup {\n private path_id: string;\n private variables: {\n [key: string]: {\n name: string;\n desc: string;\n vars: { [key: string]: string };\n type: keyof VariableType;\n typeParams: VariableType[keyof VariableType];\n example?: () => Element;\n };\n } = {};\n private sub_groups: { [key: string]: ThemeVariableGroup } = {};\n readonly name: string;\n readonly description: string;\n\n constructor(path: string, name: string, description: string) {\n this.path_id = path;\n this.name = name;\n this.description = description;\n }\n\n /**Makes a variable subgroup for this group\n * @param id unique identifier for this subgroup in the parent group\n * @param name name of group formatted for user reading\n * @param description a description of what the setting group is about formatted for user reading*/\n make_sub_group(id: string, name: string, description: string) {\n if (id.includes(\"-\"))\n throw new Error(\"Dash not permitted in variable id \" + id);\n if (id in this.sub_groups)\n throw new Error(\"Sub group already registered \" + id);\n return (this.sub_groups[id] = new ThemeVariableGroup(\n this.path_id + \"-\" + id,\n name,\n description\n ));\n }\n\n /**Makes a variable\n * @param id unique identifier for this variable in the group\n * @param name name of variable formatted for user reading\n * @param description a description of what the variable is about formatted for user reading\n * @param light value for light mode\n * @param dark value for dark mode\n * @param type type of variable for editing\n * @param type_params */\n make_variable<K extends keyof VariableType>(\n id: string,\n name: string,\n description: string,\n light: string,\n dark: string,\n type: K,\n type_params: VariableType[K],\n example?: () => Element\n ): string {\n if (id.includes(\"-\"))\n throw new Error(\"Dash not permitted in variable id \" + id);\n const key = \"--\" + this.path_id + \"-\" + id;\n if (key in this.variables)\n throw new Error(\"Settings already registered \" + id);\n const variable = (this.variables[key] = {\n name,\n desc: description,\n vars: { [Themes.Light]: light, [Themes.Dark]: dark },\n type,\n typeParams: type_params,\n example,\n });\n theme_engine.apply_single_property(key, variable.vars);\n return key;\n }\n\n /**Applies the groups\n * @param style unique identifier for this variable in the group\n * @param theme name of variable formatted for user reading*/\n apply_themes(style: CSSStyleDeclaration, theme: string) {\n for (const key in this.variables)\n style.setProperty(key, this.variables[key].vars[theme]);\n for (const key in this.sub_groups)\n this.sub_groups[key].apply_themes(style, theme);\n }\n}\n\n/**Defines the parameters for a variable type */\ninterface VariableType {\n /**Font variable, */\n Font: undefined;\n /**Text variable, */\n String: undefined;\n /**Color variable */\n Color: undefined;\n /**Transition type */\n TransitionType: undefined;\n /**Percent type */\n Percent: undefined;\n /**Filter type */\n Filter: undefined;\n /**Radius type */\n Radius: undefined;\n /**Time variable */\n Time: {\n /**Minimum time in milliseconds */\n min: number;\n /**Maximum time in milliseconds */\n max: number;\n };\n /**Angle variable */\n Angle: { min: number; max: number };\n /**Length variable*/\n Length: { min: number; max: number };\n /**Number variable*/\n Number: { min: number; max: number };\n /**Ratio*/\n Ratio:\n | {\n width: { min: number; max: number };\n height: { min: number; max: number };\n }\n | number;\n}\n","import { GREY } from \"@chocbite/ts-lib/colors\";\nimport { theme_init_variable_root } from \"./variables\";\n\nexport const BUILT_IN = 0;\n\nconst root = theme_init_variable_root(\n \"common\",\n \"Shared Variables\",\n \"Shared variables across features\",\n);\n\nconst scroll_bar = root.make_sub_group(\n \"scrollbar\",\n \"Scrollbar\",\n \"Scrollbar variables\",\n);\nconst scroll_bar_thumb = scroll_bar.make_sub_group(\n \"thumb\",\n \"Thumb\",\n \"Scrollbar Thumb variables\",\n);\nscroll_bar_thumb.make_variable(\n \"color\",\n \"Thumb Color\",\n \"Color of the scrollbar thumb in normal state\",\n GREY[\"400\"],\n GREY[\"800\"],\n \"Color\",\n undefined,\n);\nscroll_bar_thumb.make_variable(\n \"hoverColor\",\n \"Thumb Hover Color\",\n \"Color of the scrollbar thumb when hovered\",\n GREY[\"600\"],\n GREY[\"600\"],\n \"Color\",\n undefined,\n);\nscroll_bar_thumb.make_variable(\n \"activeColor\",\n \"Thumb Active Color\",\n \"Color of the scrollbar thumb when pressed\",\n GREY[\"500\"],\n GREY[\"700\"],\n \"Color\",\n undefined,\n);\n\nconst fonts = root.make_sub_group(\"fonts\", \"Fonts\", \"Font variables\");\nfonts.make_variable(\n \"base\",\n \"UI Base Font\",\n \"The base font for the UI\",\n '\"Roboto\", Arial, Helvetica, sans-serif',\n '\"Roboto\", Arial, Helvetica, sans-serif',\n \"Font\",\n undefined,\n);\n\n// _____ ____ _ ____ _____ _____\n// / ____/ __ \\| | / __ \\| __ \\ / ____|\n// | | | | | | | | | | | |__) | (___\n// | | | | | | | | | | | _ / \\___ \\\n// | |___| |__| | |___| |__| | | \\ \\ ____) |\n// \\_____\\____/|______\\____/|_| \\_\\_____/\n\nconst colors = root.make_sub_group(\"colors\", \"Colors\", \"Color variables\");\ncolors.make_variable(\n \"layer1\",\n \"UI Layer 1\",\n \"Color of the first layer of the UI\",\n GREY[50],\n \"#111111\",\n \"Color\",\n undefined,\n);\n","import { theme_engine } from \"./engine\";\nimport {\n theme_setting_init,\n theme_setting_system,\n Themes,\n type AppliedThemes,\n} from \"./settings\";\n\nexport interface ThemeInitOptions {\n /**Offers a System theme that follows the light or dark mode of the operating system,\n * leave it off on devices without that feature*/\n system?: boolean;\n /**Theme used until the user chooses one, defaults to System when system is on, otherwise Light*/\n default?: Themes;\n}\n\nlet initialized = false;\n\n/**Starts the theme, the app must call it once, nothing of the theme is applied to the page before.\n * This is the only place the operating system dark mode is read, and only when system is on*/\nexport function theme_init(options: ThemeInitOptions = {}) {\n const default_theme =\n options.default ?? (options.system ? Themes.System : Themes.Light);\n if (default_theme === Themes.System && !options.system)\n throw new Error(\"The System theme can only be the default with system on\");\n if (initialized) throw new Error(\"theme_init has already been called\");\n initialized = true;\n let os_theme: AppliedThemes | undefined;\n if (options.system) {\n const query = window.matchMedia(\"(prefers-color-scheme: dark)\");\n const theme_of = (dark: boolean) => (dark ? Themes.Dark : Themes.Light);\n os_theme = theme_of(query.matches);\n theme_engine.set_os_theme(os_theme);\n query.addEventListener(\"change\", (e) => {\n const changed = theme_of(e.matches);\n theme_setting_system(changed);\n theme_engine.set_os_theme(changed);\n });\n }\n theme_setting_init(os_theme, default_theme);\n theme_engine.start();\n}\n"],"mappings":";;;;;;;;;;ACYA,MAAM,WAAW,cACf,0BACA,SACA,YACA,2CACF;;AAGA,MAAM,UACA,YACH,WACC,OAAO,OAAO,MAAM,CAAC,CAAC,SAAS,MAAW,IAAI,KAAK,MAAW,IAAI,KAAK;;AAG3E,MAAM,YACH,KAAa,SACb,WACC,OAAO,WAAW,YAAY,UAAU,OAAO,UAAU,MACrD,KAAK,MAAM,IACX,KAAK;AAQb,MAAa,SAAS;CACpB,OAAO;CACP,MAAM;;CAEN,QAAQ;AACV;AAMA,MAAM,QAAQ;CACZ,MAAM;CACN,aAAa;CACb,MAAM;AACR;AACA,MAAM,OAAO;CACX,MAAM;CACN,aAAa;CACb,MAAM;AACR;;;AAGA,MAAM,cAAc,WAAsC;CACx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AC3E,IAAI,aAAa,MAAM,IAAI,MAAM,oCAAoC;CACrE,cAAc;CACd,IAAI;CACJ,IAAI,QAAQ,QAAQ;EAClB,MAAM,QAAQ,OAAO,WAAW,8BAA8B;EAC9D,MAAM,YAAY,SAAmB,OAAO,OAAO,OAAO,OAAO;EACjE,WAAW,SAAS,MAAM,OAAO;EACjC,aAAa,aAAa,QAAQ;EAClC,MAAM,iBAAiB,WAAW,MAAM;GACtC,MAAM,UAAU,SAAS,EAAE,OAAO;GAClC,qBAAqB,OAAO;GAC5B,aAAa,aAAa,OAAO;EACnC,CAAC;CACH;CACA,mBAAmB,UAAU,aAAa;CAC1C,aAAa,MAAM;AACrB"}
1
+ {"version":3,"file":"theme-ycsugrdT.mjs","names":["st"],"sources":["../../package.json","../../package-ui/theme/settings.ts","../../package-ui/theme/shared.ts","../../package-ui/theme/engine.ts","../../package-ui/theme/variables.ts","../../package-ui/theme/builtIn.ts","../../package-ui/theme/init.ts"],"sourcesContent":["","import {\n material_dark_mode_rounded,\n material_edit_rounded,\n material_light_mode_rounded,\n material_mouse_rounded,\n material_touch_app_rounded,\n} from \"#icons\";\nimport { settings_init } from \"#settings\";\nimport { none, ok, some, type Option } from \"@chocbite/ts-lib/result\";\nimport { state as st } from \"@chocbite/ts-lib/state\";\nimport { version } from \"../../package.json\";\n\nconst SETTINGS = settings_init(\n \"@chocbite/ts-lib-theme\",\n version,\n \"Theme/UI\",\n \"Settings for UI elements and color themes\",\n);\n\n/**Accepts a stored setting only when it is one of the given values, otherwise the default is used*/\nconst one_of =\n <T>(values: { [key: string]: T }) =>\n (stored: unknown): Option<T> =>\n Object.values(values).includes(stored as T) ? some(stored as T) : none();\n\n/**Accepts a stored setting only when it is a number within the range, otherwise the default is used*/\nconst in_range =\n (min: number, max: number) =>\n (stored: unknown): Option<number> =>\n typeof stored === \"number\" && stored >= min && stored <= max\n ? some(stored)\n : none();\n\n// _______ _ _ ______ __ __ ______\n// |__ __| | | | ____| \\/ | ____|\n// | | | |__| | |__ | \\ / | |__\n// | | | __ | __| | |\\/| | __|\n// | | | | | | |____| | | | |____\n// |_| |_| |_|______|_| |_|______|\nexport const Themes = {\n Light: \"light\",\n Dark: \"dark\",\n /**Follows the light or dark mode of the operating system, only offered when theme_init enables system*/\n System: \"system\",\n} as const;\nexport type Themes = (typeof Themes)[keyof typeof Themes];\n/**Themes that can be applied to the page, System is resolved to one of these*/\nexport type AppliedThemes = typeof Themes.Light | typeof Themes.Dark;\n\ntype ThemeList = Parameters<typeof st.e.list<Themes>>[0];\nconst LIGHT = {\n name: \"Light\",\n description: \"Theme optimized for daylight\",\n icon: material_light_mode_rounded,\n};\nconst DARK = {\n name: \"Dark\",\n description: \"Theme optimized for night time\",\n icon: material_dark_mode_rounded,\n};\n/**Theme choices, the System choice shows the theme the operating system currently uses\n * @param system theme of the operating system, undefined when the System choice is not offered*/\nconst theme_list = (system?: AppliedThemes): ThemeList => {\n const list: Partial<ThemeList> = {\n [Themes.Light]: LIGHT,\n [Themes.Dark]: DARK,\n };\n if (system) {\n const active = system === Themes.Dark ? DARK : LIGHT;\n list[Themes.System] = {\n name: \"System (\" + active.name + \")\",\n description: \"Follows the light or dark mode of the operating system\",\n icon: active.icon,\n };\n }\n return list as ThemeList;\n};\nconst THEMES = st.ok_w(theme_list());\n\nconst THEME_ID = \"theme\";\n/**Theme the user chose, undefined when nothing has been chosen yet*/\nconst STORED_THEME = SETTINGS.get<Themes | undefined>(\n THEME_ID,\n undefined,\n one_of(Themes),\n).value;\nconst PRIVATE_THEME = st.rosw(\n st.e.help(ok(STORED_THEME ?? (Themes.Light as Themes)), { list: THEMES }),\n true,\n);\n\nexport const THEME = PRIVATE_THEME.read_write;\n\n/**Sets up the theme setting, called once by theme_init\n * @param system theme of the operating system, undefined when the System choice is not offered\n * @param default_theme theme used when the user has not chosen one*/\nexport function theme_setting_init(\n system: AppliedThemes | undefined,\n default_theme: Themes,\n) {\n if (system) THEMES.set_ok(theme_list(system));\n //Set before registering, so the default is not stored as if the user chose it\n if (STORED_THEME === undefined || (STORED_THEME === Themes.System && !system))\n PRIVATE_THEME.set_ok(default_theme);\n SETTINGS.register(\n THEME_ID,\n \"Theme\",\n \"Theme to use for the UI\",\n PRIVATE_THEME,\n );\n}\n\n/**Updates the System choice to show the theme the operating system uses*/\nexport function theme_setting_system(system: AppliedThemes) {\n THEMES.set_ok(theme_list(system));\n}\n\n// _____ _____ _ ______\n// / ____|/ ____| /\\ | | | ____|\n// | (___ | | / \\ | | | |__\n// \\___ \\| | / /\\ \\ | | | __|\n// ____) | |____ / ____ \\| |____| |____\n// |_____/ \\_____/_/ \\_\\______|______|\nconst SCALE_ID = \"scale\";\nconst PRIVATE_SCALE = st.rosw(\n st.n.help(SETTINGS.get(SCALE_ID, 100, in_range(50, 400)), {\n min: st.ok(50),\n max: st.ok(400),\n unit: st.ok(\"%\"),\n start: st.ok(0),\n step: st.ok(1),\n }),\n true,\n);\nSETTINGS.register(SCALE_ID, \"Scale\", \"UI scale\", PRIVATE_SCALE);\nexport const SCALE = PRIVATE_SCALE.read_write;\n\n// _____ _____ _____ ____ _ _ ____ _____\n// / ____|/ ____| __ \\ / __ \\| | | | | _ \\ /\\ | __ \\\n// | (___ | | | |__) | | | | | | | | |_) | / \\ | |__) |\n// \\___ \\| | | _ /| | | | | | | | _ < / /\\ \\ | _ /\n// ____) | |____| | \\ \\| |__| | |____| |____| |_) / ____ \\| | \\ \\\n// |_____/ \\_____|_| \\_\\\\____/|______|______|____/_/ \\_\\_| \\_\\\nexport const ScrollbarModes = {\n Thin: \"thin\",\n Medium: \"medium\",\n Wide: \"wide\",\n} as const;\nexport type ScrollbarModes =\n (typeof ScrollbarModes)[keyof typeof ScrollbarModes];\n\nconst SCROLLBAR_MODES = st.ok(\n st.e.list<ScrollbarModes>({\n [ScrollbarModes.Thin]: {\n name: \"Thin\",\n description: \"Thin modern scrollbar\",\n },\n [ScrollbarModes.Medium]: {\n name: \"Medium\",\n description: \"Normal scrollbar\",\n },\n [ScrollbarModes.Wide]: {\n name: \"Wide\",\n description: \"Large touch friendly scrollbar\",\n },\n }),\n);\n\nconst SCROLLBAR_ID = \"scrollbar\";\nconst PRIVATE_SCROLLBAR_MODE = st.rosw(\n st.e.help(\n SETTINGS.get(\n SCROLLBAR_ID,\n ScrollbarModes.Thin as ScrollbarModes,\n one_of(ScrollbarModes),\n ),\n { list: SCROLLBAR_MODES },\n ),\n true,\n);\nSETTINGS.register(\n \"scrollbar\",\n \"Scrollbar Mode\",\n \"Size of the scrollbar to use\",\n PRIVATE_SCROLLBAR_MODE,\n);\n\nexport const SCROLLBAR_MODE = PRIVATE_SCROLLBAR_MODE.read_write;\n\n// _____ _ _ _____ _ _ _______ __ __ ____ _____ ______\n// |_ _| \\ | | __ \\| | | |__ __| | \\/ |/ __ \\| __ \\| ____|\n// | | | \\| | |__) | | | | | | | \\ / | | | | | | | |__\n// | | | . ` | ___/| | | | | | | |\\/| | | | | | | | __|\n// _| |_| |\\ | | | |__| | | | | | | | |__| | |__| | |____\n// |_____|_| \\_|_| \\____/ |_| |_| |_|\\____/|_____/|______|\nexport const InputModes = {\n Mouse: \"mouse\",\n Pen: \"pen\",\n Touch: \"touch\",\n} as const;\nexport type InputModes = (typeof InputModes)[keyof typeof InputModes];\n\nconst INPUT_MODES = st.ok(\n st.e.list<InputModes>({\n [InputModes.Mouse]: {\n name: \"Mouse\",\n description: \"Mouse input\",\n icon: material_mouse_rounded,\n },\n [InputModes.Pen]: {\n name: \"Pen\",\n description: \"Pen input\",\n icon: material_edit_rounded,\n },\n [InputModes.Touch]: {\n name: \"Touch\",\n description: \"Touch input\",\n icon: material_touch_app_rounded,\n },\n }),\n);\n\nconst INPUT_MODE_ID = \"input_mode\";\nconst PRIVATE_INPUT_MODE = st.rosw(\n st.e.help(\n SETTINGS.get(\n INPUT_MODE_ID,\n matchMedia(\"(pointer: coarse)\").matches\n ? InputModes.Touch\n : (InputModes.Mouse as InputModes),\n one_of(InputModes),\n ),\n { list: INPUT_MODES },\n ),\n true,\n);\nSETTINGS.register(\n INPUT_MODE_ID,\n \"Input Mode\",\n \"Setting for preffered input mode, changes UI elements to be more optimized for the selected input mode\",\n PRIVATE_INPUT_MODE,\n);\n\nexport const INPUT_MODE = PRIVATE_INPUT_MODE.read_write;\n\n// _ _ _____ __ __ _______ _____ ____ _ _ _ ________ ________ _\n// /\\ | \\ | |_ _| \\/ | /\\|__ __|_ _/ __ \\| \\ | | | | | ____\\ \\ / / ____| |\n// / \\ | \\| | | | | \\ / | / \\ | | | || | | | \\| | | | | |__ \\ \\ / /| |__ | |\n// / /\\ \\ | . ` | | | | |\\/| | / /\\ \\ | | | || | | | . ` | | | | __| \\ \\/ / | __| | |\n// / ____ \\| |\\ |_| |_| | | |/ ____ \\| | _| || |__| | |\\ | | |____| |____ \\ / | |____| |____\n// /_/ \\_\\_| \\_|_____|_| |_/_/ \\_\\_| |_____\\____/|_| \\_| |______|______| \\/ |______|______|\nexport const AnimationLevels = {\n All: \"all\",\n Some: \"some\",\n None: \"none\",\n} as const;\nexport type AnimationLevels =\n (typeof AnimationLevels)[keyof typeof AnimationLevels];\n\nconst ANIMATION_LEVELS = st.ok(\n st.e.list<AnimationLevels>({\n [AnimationLevels.All]: { name: \"All\", description: \"All animations\" },\n [AnimationLevels.Some]: {\n name: \"Functional\",\n description: \"Only functional animations that improve usability\",\n },\n [AnimationLevels.None]: { name: \"None\", description: \"No animations\" },\n }),\n);\n\nconst ANIMATION_LEVEL_ID = \"animation_level\";\nconst PRIVATE_ANIMATION_LEVEL = st.rosw(\n st.e.help(\n SETTINGS.get(\n ANIMATION_LEVEL_ID,\n AnimationLevels.None as AnimationLevels,\n one_of(AnimationLevels),\n ),\n { list: ANIMATION_LEVELS },\n ),\n true,\n);\nSETTINGS.register(\n ANIMATION_LEVEL_ID,\n \"Animation Level\",\n \"Setting for animation level, changes the amount of animations used in the UI\",\n PRIVATE_ANIMATION_LEVEL,\n);\n\nexport const ANIMATION_LEVEL = PRIVATE_ANIMATION_LEVEL.read_write;\n\n// _ _ _____ __ __ _______ _____ ____ _ _ _____ _____ ______ ______ _____\n// /\\ | \\ | |_ _| \\/ | /\\|__ __|_ _/ __ \\| \\ | | / ____| __ \\| ____| ____| __ \\\n// / \\ | \\| | | | | \\ / | / \\ | | | || | | | \\| | | (___ | |__) | |__ | |__ | | | |\n// / /\\ \\ | . ` | | | | |\\/| | / /\\ \\ | | | || | | | . ` | \\___ \\| ___/| __| | __| | | | |\n// / ____ \\| |\\ |_| |_| | | |/ ____ \\| | _| || |__| | |\\ | ____) | | | |____| |____| |__| |\n// /_/ \\_\\_| \\_|_____|_| |_/_/ \\_\\_| |_____\\____/|_| \\_| |_____/|_| |______|______|_____/\nconst ANIMATION_SPEED_ID = \"animation_speed\";\nconst PRIVATE_ANIMATION_SPEED = st.rosw(\n st.n.help(SETTINGS.get(ANIMATION_SPEED_ID, 200, in_range(50, 1000)), {\n min: st.ok(50),\n max: st.ok(1000),\n unit: st.ok(\"ms\"),\n start: st.ok(0),\n step: st.ok(50),\n }),\n true,\n);\nSETTINGS.register(\n ANIMATION_SPEED_ID,\n \"Animation Speed\",\n \"Setting for animation speed, changes the speed of animations in the UI\",\n PRIVATE_ANIMATION_SPEED,\n);\n\nexport const ANIMATION_SPEED = PRIVATE_ANIMATION_SPEED.read_write;\n","import type { ThemeVariableGroup } from \"./variables\";\n\nexport const BOTTOM_GROUPS: { [key: string]: ThemeVariableGroup } = {};\n","import { DOCUMENT_HANDLER } from \"#document\";\nimport {\n ANIMATION_LEVEL,\n ANIMATION_SPEED,\n AnimationLevels,\n INPUT_MODE,\n InputModes,\n SCALE,\n SCROLLBAR_MODE,\n ScrollbarModes,\n THEME,\n Themes,\n type AppliedThemes,\n} from \"./settings\";\nimport { BOTTOM_GROUPS } from \"./shared\";\n\nclass ThemeEngine {\n #started = false;\n /**Theme of the operating system, used for the System theme*/\n #os_theme: AppliedThemes = Themes.Light;\n\n /**Starts applying the theme to all documents, called once by theme_init*/\n start() {\n this.#started = true;\n DOCUMENT_HANDLER.events.on(\"added\", (e) => {\n this.#apply_all_to_doc(e.data);\n });\n this.#for_documents((doc) => {\n this.#apply_all_to_doc(doc);\n });\n }\n\n /**Runs for every document, nothing is applied before the engine is started*/\n #for_documents(func: (doc: Document) => void) {\n if (this.#started) DOCUMENT_HANDLER.for_documents(func);\n }\n\n /**Sets the theme of the operating system, reapplying the theme when System is used*/\n set_os_theme(theme: AppliedThemes) {\n this.#os_theme = theme;\n if (THEME.ok() === Themes.System) this.apply_theme(Themes.System);\n }\n\n /**Resolves the System theme to the theme of the operating system*/\n #applied(theme: Themes): AppliedThemes {\n return theme === Themes.System ? this.#os_theme : theme;\n }\n\n /**This applies the current theme to a document*/\n #apply_all_to_doc(doc: Document) {\n this.#apply_scrollbar_to_doc(doc, SCROLLBAR_MODE.ok());\n this.#apply_theme_to_doc(doc, THEME.ok());\n this.#apply_input_to_doc(doc, INPUT_MODE.ok());\n this.#apply_scale_to_doc(doc, SCALE.ok() / 100);\n this.#apply_animation_level_to_doc(doc, ANIMATION_LEVEL.ok());\n this.#apply_animation_speed_to_doc(doc, ANIMATION_SPEED.ok());\n }\n\n /**This applies the current theme to a document*/\n apply_scrollbar(scroll: ScrollbarModes) {\n this.#for_documents((doc) => {\n this.#apply_scrollbar_to_doc(doc, scroll);\n });\n }\n #apply_scrollbar_to_doc(doc: Document, scroll: ScrollbarModes) {\n doc.documentElement.style.setProperty(\n \"--scrollbar\",\n {\n [ScrollbarModes.Thin]: \"0.6rem\",\n [ScrollbarModes.Medium]: \"1rem\",\n [ScrollbarModes.Wide]: \"2.6rem\",\n }[scroll],\n );\n }\n\n /**This applies the current theme to a document*/\n apply_animation_level(anim: AnimationLevels) {\n this.#for_documents((doc) => {\n this.#apply_animation_level_to_doc(doc, anim);\n });\n }\n #apply_animation_level_to_doc(doc: Document, anim: AnimationLevels) {\n doc.documentElement.classList.remove(\"anim-all\", \"anim-some\");\n switch (anim) {\n case AnimationLevels.All:\n doc.documentElement.classList.add(\"anim-all\");\n doc.documentElement.classList.add(\"anim-some\");\n break;\n case AnimationLevels.Some:\n doc.documentElement.classList.add(\"anim-some\");\n break;\n }\n }\n\n /**This applies the current theme to a document*/\n apply_animation_speed(speed: number) {\n this.#for_documents((doc) => {\n this.#apply_animation_speed_to_doc(doc, speed);\n });\n }\n #apply_animation_speed_to_doc(doc: Document, speed: number) {\n const style = doc.documentElement.style;\n style.setProperty(\"--animation-speed\", speed.toString() + \"ms\");\n }\n\n /**This applies the current theme to a document*/\n apply_theme(theme: Themes) {\n this.#for_documents((doc) => {\n this.#apply_theme_to_doc(doc, theme);\n });\n }\n #apply_theme_to_doc(doc: Document, theme: Themes) {\n const applied = this.#applied(theme);\n for (const key in BOTTOM_GROUPS)\n BOTTOM_GROUPS[key].apply_themes(doc.documentElement.style, applied);\n }\n\n /**This applies the current scale to a document*/\n apply_scale(scale: number) {\n this.#for_documents((doc) => {\n this.#apply_scale_to_doc(doc, scale);\n });\n }\n #apply_scale_to_doc(doc: Document, scale: number) {\n doc.documentElement.style.fontSize = scale * 16 + \"px\";\n }\n\n /**Auto Input Mode */\n apply_input(mode: InputModes) {\n this.#for_documents((doc) => {\n this.#apply_input_to_doc(doc, mode);\n });\n }\n #apply_input_to_doc(doc: Document, mode: InputModes) {\n const style = doc.documentElement.style;\n style.setProperty(\"--mouse\", \"0\");\n style.setProperty(\"--pen\", \"0\");\n style.setProperty(\"--touch\", \"0\");\n doc.documentElement.classList.remove(\"mouse\", \"pen\", \"touch\");\n switch (mode) {\n case InputModes.Mouse:\n style.setProperty(\"--mouse\", \"1\");\n doc.documentElement.classList.add(\"mouse\");\n break;\n case InputModes.Pen:\n style.setProperty(\"--pen\", \"1\");\n doc.documentElement.classList.add(\"pen\");\n break;\n case InputModes.Touch:\n style.setProperty(\"--touch\", \"1\");\n doc.documentElement.classList.add(\"touch\");\n break;\n }\n }\n\n apply_single_property(key: string, variable: { [s: string]: string }) {\n const theme_buff = this.#applied(THEME.ok());\n this.#for_documents((doc) => {\n doc.documentElement.style.setProperty(key, variable[theme_buff]);\n });\n }\n}\n\nexport const theme_engine = new ThemeEngine();\n\nTHEME.sub((val) => {\n theme_engine.apply_theme(val.value);\n});\n/**Size of a rem in pixels at the current scale, set right away from the stored scale*/\nlet scale_rem = 16;\nSCALE.sub((val) => {\n const scale_value = val.value / 100;\n scale_rem = scale_value * 16;\n theme_engine.apply_scale(scale_value);\n}, true);\n/**Converts the given rems to pixels */\nexport function rem_to_px(rem: number) {\n return rem * scale_rem;\n}\n/**Converts the given pixels to rems */\nexport function px_to_rem(px: number) {\n return px / scale_rem;\n}\nSCROLLBAR_MODE.sub((val) => {\n theme_engine.apply_scrollbar(val.value);\n});\nINPUT_MODE.sub((val) => {\n theme_engine.apply_input(val.value);\n});\nANIMATION_LEVEL.sub((val) => {\n theme_engine.apply_animation_level(val.value);\n});\nANIMATION_SPEED.sub((val) => {\n theme_engine.apply_animation_speed(val.value);\n});\n","import { theme_engine } from \"./engine\";\nimport { Themes } from \"./settings\";\nimport { BOTTOM_GROUPS } from \"./shared\";\n\n/**Initialises the settings for the package\n * @param package_name use import {name} from \"../package.json\"\n * @param name name of group formatted for user reading\n * @param description a description of what the setting group is about*/\nexport const theme_init_variable_root = (\n package_name: string,\n name: string,\n description: string\n) => {\n if (package_name.includes(\"-\"))\n throw new Error(\"Dash not permitted in package name \" + package_name);\n if (package_name in BOTTOM_GROUPS)\n throw new Error(\n \"Theme variable group already registered \" +\n package_name +\n \", by another package or by this library being loaded twice\",\n );\n BOTTOM_GROUPS[package_name] = new ThemeVariableGroup(\n package_name,\n name,\n description\n );\n return BOTTOM_GROUPS[package_name];\n};\n\n/**Group of settings should never be instantiated manually use initSettings*/\nexport class ThemeVariableGroup {\n private path_id: string;\n private variables: {\n [key: string]: {\n name: string;\n desc: string;\n vars: { [key: string]: string };\n type: keyof VariableType;\n typeParams: VariableType[keyof VariableType];\n example?: () => Element;\n };\n } = {};\n private sub_groups: { [key: string]: ThemeVariableGroup } = {};\n readonly name: string;\n readonly description: string;\n\n constructor(path: string, name: string, description: string) {\n this.path_id = path;\n this.name = name;\n this.description = description;\n }\n\n /**Makes a variable subgroup for this group\n * @param id unique identifier for this subgroup in the parent group\n * @param name name of group formatted for user reading\n * @param description a description of what the setting group is about formatted for user reading*/\n make_sub_group(id: string, name: string, description: string) {\n if (id.includes(\"-\"))\n throw new Error(\"Dash not permitted in variable id \" + id);\n if (id in this.sub_groups)\n throw new Error(\"Sub group already registered \" + id);\n return (this.sub_groups[id] = new ThemeVariableGroup(\n this.path_id + \"-\" + id,\n name,\n description\n ));\n }\n\n /**Makes a variable\n * @param id unique identifier for this variable in the group\n * @param name name of variable formatted for user reading\n * @param description a description of what the variable is about formatted for user reading\n * @param light value for light mode\n * @param dark value for dark mode\n * @param type type of variable for editing\n * @param type_params */\n make_variable<K extends keyof VariableType>(\n id: string,\n name: string,\n description: string,\n light: string,\n dark: string,\n type: K,\n type_params: VariableType[K],\n example?: () => Element\n ): string {\n if (id.includes(\"-\"))\n throw new Error(\"Dash not permitted in variable id \" + id);\n const key = \"--\" + this.path_id + \"-\" + id;\n if (key in this.variables)\n throw new Error(\"Settings already registered \" + id);\n const variable = (this.variables[key] = {\n name,\n desc: description,\n vars: { [Themes.Light]: light, [Themes.Dark]: dark },\n type,\n typeParams: type_params,\n example,\n });\n theme_engine.apply_single_property(key, variable.vars);\n return key;\n }\n\n /**Applies the groups\n * @param style unique identifier for this variable in the group\n * @param theme name of variable formatted for user reading*/\n apply_themes(style: CSSStyleDeclaration, theme: string) {\n for (const key in this.variables)\n style.setProperty(key, this.variables[key].vars[theme]);\n for (const key in this.sub_groups)\n this.sub_groups[key].apply_themes(style, theme);\n }\n}\n\n/**Defines the parameters for a variable type */\ninterface VariableType {\n /**Font variable, */\n Font: undefined;\n /**Text variable, */\n String: undefined;\n /**Color variable */\n Color: undefined;\n /**Transition type */\n TransitionType: undefined;\n /**Percent type */\n Percent: undefined;\n /**Filter type */\n Filter: undefined;\n /**Radius type */\n Radius: undefined;\n /**Time variable */\n Time: {\n /**Minimum time in milliseconds */\n min: number;\n /**Maximum time in milliseconds */\n max: number;\n };\n /**Angle variable */\n Angle: { min: number; max: number };\n /**Length variable*/\n Length: { min: number; max: number };\n /**Number variable*/\n Number: { min: number; max: number };\n /**Ratio*/\n Ratio:\n | {\n width: { min: number; max: number };\n height: { min: number; max: number };\n }\n | number;\n}\n","import { GREY } from \"@chocbite/ts-lib/colors\";\nimport { theme_init_variable_root } from \"./variables\";\n\nexport const BUILT_IN = 0;\n\nconst root = theme_init_variable_root(\n \"common\",\n \"Shared Variables\",\n \"Shared variables across features\",\n);\n\nconst scroll_bar = root.make_sub_group(\n \"scrollbar\",\n \"Scrollbar\",\n \"Scrollbar variables\",\n);\nconst scroll_bar_thumb = scroll_bar.make_sub_group(\n \"thumb\",\n \"Thumb\",\n \"Scrollbar Thumb variables\",\n);\nscroll_bar_thumb.make_variable(\n \"color\",\n \"Thumb Color\",\n \"Color of the scrollbar thumb in normal state\",\n GREY[\"400\"],\n GREY[\"800\"],\n \"Color\",\n undefined,\n);\nscroll_bar_thumb.make_variable(\n \"hoverColor\",\n \"Thumb Hover Color\",\n \"Color of the scrollbar thumb when hovered\",\n GREY[\"600\"],\n GREY[\"600\"],\n \"Color\",\n undefined,\n);\nscroll_bar_thumb.make_variable(\n \"activeColor\",\n \"Thumb Active Color\",\n \"Color of the scrollbar thumb when pressed\",\n GREY[\"500\"],\n GREY[\"700\"],\n \"Color\",\n undefined,\n);\n\nconst fonts = root.make_sub_group(\"fonts\", \"Fonts\", \"Font variables\");\nfonts.make_variable(\n \"base\",\n \"UI Base Font\",\n \"The base font for the UI\",\n '\"Roboto\", Arial, Helvetica, sans-serif',\n '\"Roboto\", Arial, Helvetica, sans-serif',\n \"Font\",\n undefined,\n);\n\n// _____ ____ _ ____ _____ _____\n// / ____/ __ \\| | / __ \\| __ \\ / ____|\n// | | | | | | | | | | | |__) | (___\n// | | | | | | | | | | | _ / \\___ \\\n// | |___| |__| | |___| |__| | | \\ \\ ____) |\n// \\_____\\____/|______\\____/|_| \\_\\_____/\n\nconst colors = root.make_sub_group(\"colors\", \"Colors\", \"Color variables\");\ncolors.make_variable(\n \"layer1\",\n \"UI Layer 1\",\n \"Color of the first layer of the UI\",\n GREY[50],\n \"#111111\",\n \"Color\",\n undefined,\n);\n","import { theme_engine } from \"./engine\";\nimport {\n theme_setting_init,\n theme_setting_system,\n Themes,\n type AppliedThemes,\n} from \"./settings\";\n\nexport interface ThemeInitOptions {\n /**Offers a System theme that follows the light or dark mode of the operating system,\n * leave it off on devices without that feature*/\n system?: boolean;\n /**Theme used until the user chooses one, defaults to System when system is on, otherwise Light*/\n default?: Themes;\n}\n\nlet initialized = false;\n\n/**Starts the theme, the app must call it once, nothing of the theme is applied to the page before.\n * This is the only place the operating system dark mode is read, and only when system is on*/\nexport function theme_init(options: ThemeInitOptions = {}) {\n const default_theme =\n options.default ?? (options.system ? Themes.System : Themes.Light);\n if (default_theme === Themes.System && !options.system)\n throw new Error(\"The System theme can only be the default with system on\");\n if (initialized) throw new Error(\"theme_init has already been called\");\n initialized = true;\n let os_theme: AppliedThemes | undefined;\n if (options.system) {\n const query = window.matchMedia(\"(prefers-color-scheme: dark)\");\n const theme_of = (dark: boolean) => (dark ? Themes.Dark : Themes.Light);\n os_theme = theme_of(query.matches);\n theme_engine.set_os_theme(os_theme);\n query.addEventListener(\"change\", (e) => {\n const changed = theme_of(e.matches);\n theme_setting_system(changed);\n theme_engine.set_os_theme(changed);\n });\n }\n theme_setting_init(os_theme, default_theme);\n theme_engine.start();\n}\n"],"mappings":";;;;;;;;;;ACYA,MAAM,WAAW,cACf,0BACA,SACA,YACA,2CACF;;AAGA,MAAM,UACA,YACH,WACC,OAAO,OAAO,MAAM,CAAC,CAAC,SAAS,MAAW,IAAI,KAAK,MAAW,IAAI,KAAK;;AAG3E,MAAM,YACH,KAAa,SACb,WACC,OAAO,WAAW,YAAY,UAAU,OAAO,UAAU,MACrD,KAAK,MAAM,IACX,KA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