@chocbite/ts-lib-ui 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -1
- package/base/index.d.mts +2 -2
- package/base/index.mjs +69 -77
- package/base/index.mjs.map +1 -1
- package/canvas/index.d.mts +117 -60
- package/canvas/index.mjs +652 -584
- package/canvas/index.mjs.map +1 -1
- package/context-menu/index.d.mts +1 -1
- package/context-menu/index.mjs +1 -1
- package/{context-menu-CiNcuP-a.mjs → context-menu-Cz9rqUaM.mjs} +71 -37
- package/context-menu-Cz9rqUaM.mjs.map +1 -0
- package/document/index.mjs +3 -1
- package/document/index.mjs.map +1 -1
- package/form/index.d.mts +16 -5
- package/form/index.mjs +412 -153
- package/form/index.mjs.map +1 -1
- package/icons/index.d.mts +1 -1
- package/icons/index.mjs +1 -1
- package/icons-e2J_Ojic.mjs +4124 -0
- package/{index-BcidwqIy.d.mts → index-BDWg5GX2.d.mts} +7 -18
- package/{index-BND79jZp.d.mts → index-CvzH3M_5.d.mts} +16 -9
- package/{index-CugtUzv_.d.mts → index-DCn7acFY.d.mts} +30 -12
- package/{index-CB3-qP6l.d.mts → index-DhRb2iA8.d.mts} +7 -5
- package/keyboard/index.d.mts +1 -1
- package/keyboard/index.mjs +121 -50
- package/keyboard/index.mjs.map +1 -1
- package/list/index.d.mts +1 -1
- package/list/index.mjs +1 -1
- package/{list-CQDnxsLV.mjs → list-DXkEJKjx.mjs} +218 -117
- package/list-DXkEJKjx.mjs.map +1 -0
- package/package.json +7 -7
- package/selection/index.mjs +9 -11
- package/selection/index.mjs.map +1 -1
- package/settings/index.d.mts +23 -5
- package/settings/index.mjs +17 -10
- package/settings/index.mjs.map +1 -1
- package/spinner/index.d.mts +1 -1
- package/spinner/index.mjs +2 -2
- package/state/index.d.mts +36 -0
- package/state/index.mjs +2 -0
- package/state-OCzEmq3j.mjs +87 -0
- package/state-OCzEmq3j.mjs.map +1 -0
- package/style.css +423 -142
- package/svg/index.d.mts +1 -1
- package/svg/index.mjs +1 -1
- package/{svg-golJPaR4.mjs → svg-1bp-yIPC.mjs} +20 -17
- package/svg-1bp-yIPC.mjs.map +1 -0
- package/theme/index.d.mts +21 -2
- package/theme/index.mjs +1 -1
- package/{theme-9ib89_3b.mjs → theme-CFeGnUuF.mjs} +125 -44
- package/theme-CFeGnUuF.mjs.map +1 -0
- package/context-menu-CiNcuP-a.mjs.map +0 -1
- package/icons-CY4BLQ2F.mjs +0 -4123
- package/list-CQDnxsLV.mjs.map +0 -1
- package/svg-golJPaR4.mjs.map +0 -1
- package/theme-9ib89_3b.mjs.map +0 -1
- package/viewport/index.d.mts +0 -1
- package/viewport/index.mjs +0 -2
package/svg/index.d.mts
CHANGED
package/svg/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import "../style.css";
|
|
2
|
-
export { n as SVGAnchorPoint, t as svg } from "../svg-
|
|
2
|
+
export { n as SVGAnchorPoint, t as svg } from "../svg-1bp-yIPC.mjs";
|
|
@@ -118,18 +118,20 @@ function ellipse(center_x, center_y, radius_x, radius_y) {
|
|
|
118
118
|
* @param center_y the center point on the y axis
|
|
119
119
|
* @param radius_x radius in x axis
|
|
120
120
|
* @param radius_y radius in y axis
|
|
121
|
-
* @param start_angle start angle in
|
|
122
|
-
* @param end_angle end
|
|
121
|
+
* @param start_angle start angle in degrees
|
|
122
|
+
* @param end_angle end angle in degrees, a sweep of 360 degrees or more draws the whole ellipse*/
|
|
123
123
|
function ellipse_arc(center_x, center_y, radius_x, radius_y, start_angle, end_angle) {
|
|
124
124
|
const start_radian = degrees_to_radians(start_angle);
|
|
125
|
-
|
|
126
|
-
const
|
|
127
|
-
const
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
125
|
+
const sweep = degrees_to_radians(end_angle - start_angle);
|
|
126
|
+
const point = (radian) => `${radius_x * Math.cos(radian) + center_x} ${radius_y * Math.sin(radian) + center_y}`;
|
|
127
|
+
const f_s = sweep > 0 ? 1 : 0;
|
|
128
|
+
const arc = `A ${radius_x} ${radius_y} 0`;
|
|
129
|
+
if (Math.abs(sweep) >= 2 * Math.PI) {
|
|
130
|
+
const half = start_radian + (sweep > 0 ? Math.PI : -Math.PI);
|
|
131
|
+
return create_svg_element("path").a("d", `M ${point(start_radian)} ${arc} 0 ${f_s} ${point(half)} ${arc} 0 ${f_s} ${point(start_radian)}`);
|
|
132
|
+
}
|
|
133
|
+
const f_a = Math.abs(sweep) > Math.PI ? 1 : 0;
|
|
134
|
+
return create_svg_element("path").a("d", `M ${point(start_radian)} ${arc} ${f_a} ${f_s} ${point(start_radian + sweep)}`);
|
|
133
135
|
}
|
|
134
136
|
// src/svg/primitives/circle.ts
|
|
135
137
|
/**This creates a svg circle
|
|
@@ -147,8 +149,8 @@ function circle(center_x, center_y, radius) {
|
|
|
147
149
|
* @param center_x the center point on the x axis
|
|
148
150
|
* @param center_y the center point on the y axis
|
|
149
151
|
* @param radius radius in x axis
|
|
150
|
-
* @param start_angle start angle in
|
|
151
|
-
* @param end_angle end
|
|
152
|
+
* @param start_angle start angle in degrees
|
|
153
|
+
* @param end_angle end angle in degrees, a sweep of 360 degrees or more draws the whole circle*/
|
|
152
154
|
function circle_arc(center_x, center_y, radius, start_angle, end_angle) {
|
|
153
155
|
return ellipse_arc(center_x, center_y, radius, radius, start_angle, end_angle);
|
|
154
156
|
}
|
|
@@ -219,7 +221,7 @@ const SVGAnchorPoint = {
|
|
|
219
221
|
* @param anchor anchor point of text*/
|
|
220
222
|
function text(x, y, text, size, anchor) {
|
|
221
223
|
const text_elem = create_svg_element("text").a("x", String(x)).a("y", String(y)).a("font-size", String(size));
|
|
222
|
-
text_elem.elem.
|
|
224
|
+
text_elem.elem.textContent = text;
|
|
223
225
|
switch (anchor) {
|
|
224
226
|
case SVGAnchorPoint.bottomLeft:
|
|
225
227
|
case SVGAnchorPoint.middleLeft:
|
|
@@ -271,7 +273,7 @@ function multi_line_text(x, y, width, height, text, size, anchor) {
|
|
|
271
273
|
text_div.style.width = "100%";
|
|
272
274
|
text_div.style.height = "100%";
|
|
273
275
|
text_div.style.display = "flex";
|
|
274
|
-
text_div.
|
|
276
|
+
text_div.textContent = text;
|
|
275
277
|
switch (anchor) {
|
|
276
278
|
case SVGAnchorPoint.bottomLeft:
|
|
277
279
|
case SVGAnchorPoint.middleLeft:
|
|
@@ -321,9 +323,10 @@ function isosceles_triangle(center_x, center_y, width, height) {
|
|
|
321
323
|
}
|
|
322
324
|
// src/svg/util/angleToAnchorPoint.ts
|
|
323
325
|
/**Converts an angle to an anchor point
|
|
324
|
-
* @param angle angle in radians*/
|
|
326
|
+
* @param angle angle in radians, any angle outside 0 to 2PI is wrapped around*/
|
|
325
327
|
const angle_to_anchor_point = (angle) => {
|
|
326
|
-
const
|
|
328
|
+
const full = 6.283185307179586;
|
|
329
|
+
const sec = (angle % full + full) % full;
|
|
327
330
|
if (sec > 5.93411945678072) return SVGAnchorPoint.middleRight;
|
|
328
331
|
else if (sec > 4.974188368183839) return SVGAnchorPoint.topRight;
|
|
329
332
|
else if (sec > 4.45058959258554) return SVGAnchorPoint.topCenter;
|
|
@@ -355,4 +358,4 @@ const svg = {
|
|
|
355
358
|
};
|
|
356
359
|
export { SVGAnchorPoint as n, svg as t };
|
|
357
360
|
|
|
358
|
-
//# sourceMappingURL=svg-
|
|
361
|
+
//# sourceMappingURL=svg-1bp-yIPC.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svg-1bp-yIPC.mjs","names":["svg","svgsvg"],"sources":["../src/svg/attributes.ts","../src/svg/shared.ts","../src/svg/primitives/shared.ts","../src/svg/primitives/ellipse.ts","../src/svg/primitives/circle.ts","../src/svg/primitives/group.ts","../src/svg/primitives/line.ts","../src/svg/primitives/path.ts","../src/svg/primitives/rectangle.ts","../src/svg/primitives/svg.ts","../src/svg/util/anchorPoint.ts","../src/svg/primitives/text.ts","../src/svg/primitives/triangle.ts","../src/svg/util/angleToAnchorPoint.ts","../src/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;EAC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} from "../index-
|
|
2
|
+
import { t as SVGFunc } from "../index-BDWg5GX2.mjs";
|
|
3
3
|
export declare const BUILT_IN = 0;
|
|
4
4
|
export declare const Themes: {
|
|
5
5
|
readonly Light: "light";
|
|
6
6
|
readonly Dark: "dark";
|
|
7
|
+
/**Follows the light or dark mode of the operating system, only offered when theme_init enables system*/
|
|
8
|
+
readonly System: "system";
|
|
7
9
|
};
|
|
8
10
|
export type Themes = (typeof Themes)[keyof typeof Themes];
|
|
11
|
+
/**Themes that can be applied to the page, System is resolved to one of these*/
|
|
12
|
+
type AppliedThemes = typeof Themes.Light | typeof Themes.Dark;
|
|
9
13
|
export declare const THEME: import("@chocbite/ts-lib/state").StateROSW<Themes, import("@chocbite/ts-lib/result").OptionSome<import("@chocbite/ts-lib/state").StateEnumRelated<{
|
|
10
14
|
light: {
|
|
11
15
|
name: string;
|
|
@@ -17,6 +21,11 @@ export declare const THEME: import("@chocbite/ts-lib/state").StateROSW<Themes, i
|
|
|
17
21
|
description?: string;
|
|
18
22
|
icon?: SVGFunc;
|
|
19
23
|
};
|
|
24
|
+
system: {
|
|
25
|
+
name: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
icon?: SVGFunc;
|
|
28
|
+
};
|
|
20
29
|
}>>, Themes>;
|
|
21
30
|
export declare const SCALE: import("@chocbite/ts-lib/state").StateROSW<number, import("@chocbite/ts-lib/result").OptionSome<import("@chocbite/ts-lib/state").StateNumberRelated>, number>;
|
|
22
31
|
export declare const ScrollbarModes: {
|
|
@@ -93,6 +102,16 @@ export declare const ANIMATION_SPEED: import("@chocbite/ts-lib/state").StateROSW
|
|
|
93
102
|
export declare function rem_to_px(rem: number): number;
|
|
94
103
|
/**Converts the given pixels to rems */
|
|
95
104
|
export declare function px_to_rem(px: number): number;
|
|
105
|
+
interface ThemeInitOptions {
|
|
106
|
+
/**Offers a System theme that follows the light or dark mode of the operating system,
|
|
107
|
+
* leave it off on devices without that feature*/
|
|
108
|
+
system?: boolean;
|
|
109
|
+
/**Theme used until the user chooses one, defaults to System when system is on, otherwise Light*/
|
|
110
|
+
default?: Themes;
|
|
111
|
+
}
|
|
112
|
+
/**Starts the theme, the app must call it once, nothing of the theme is applied to the page before.
|
|
113
|
+
* This is the only place the operating system dark mode is read, and only when system is on*/
|
|
114
|
+
export declare function theme_init(options?: ThemeInitOptions): void;
|
|
96
115
|
/**Initialises the settings for the package
|
|
97
116
|
* @param package_name use import {name} from "../package.json"
|
|
98
117
|
* @param name name of group formatted for user reading
|
|
@@ -175,5 +194,5 @@ interface VariableType {
|
|
|
175
194
|
};
|
|
176
195
|
} | number;
|
|
177
196
|
}
|
|
178
|
-
export {};
|
|
197
|
+
export type { AppliedThemes, ThemeInitOptions };
|
|
179
198
|
//# sourceMappingURL=index.d.mts.map
|
package/theme/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import "../style.css";
|
|
2
|
-
export {
|
|
2
|
+
export { s as ANIMATION_LEVEL, c as ANIMATION_SPEED, l as AnimationLevels, n as BUILT_IN, u as INPUT_MODE, d as InputModes, f as SCALE, p as SCROLLBAR_MODE, m as ScrollbarModes, h as THEME, r as ThemeVariableGroup, g as Themes, a as px_to_rem, o as rem_to_px, t as theme_init, i as theme_init_variable_root } from "../theme-CFeGnUuF.mjs";
|
|
@@ -1,38 +1,71 @@
|
|
|
1
1
|
import "./style.css";
|
|
2
2
|
import { DOCUMENT_HANDLER } from "./document/index.mjs";
|
|
3
|
-
import { RS as material_edit_rounded, nW as material_mouse_rounded, oR as material_light_mode_rounded, vat as material_touch_app_rounded, vv as material_dark_mode_rounded } from "./icons-
|
|
3
|
+
import { RS as material_edit_rounded, nW as material_mouse_rounded, oR as material_light_mode_rounded, vat as material_touch_app_rounded, vv as material_dark_mode_rounded } from "./icons-e2J_Ojic.mjs";
|
|
4
4
|
import { settings_init } from "./settings/index.mjs";
|
|
5
5
|
import { state as state$1 } from "@chocbite/ts-lib/state";
|
|
6
|
+
import { none, ok, some } from "@chocbite/ts-lib/result";
|
|
6
7
|
import { GREY } from "@chocbite/ts-lib/colors";
|
|
7
|
-
// package.json
|
|
8
|
-
var version = "1.0.
|
|
8
|
+
// ../package.json
|
|
9
|
+
var version = "1.0.4";
|
|
9
10
|
// src/theme/settings.ts
|
|
10
11
|
const SETTINGS = settings_init("@chocbite/ts-lib-theme", version, "Theme/UI", "Settings for UI elements and color themes");
|
|
12
|
+
/**Accepts a stored setting only when it is one of the given values, otherwise the default is used*/
|
|
13
|
+
const one_of = (values) => (stored) => Object.values(values).includes(stored) ? some(stored) : none();
|
|
14
|
+
/**Accepts a stored setting only when it is a number within the range, otherwise the default is used*/
|
|
15
|
+
const in_range = (min, max) => (stored) => typeof stored === "number" && stored >= min && stored <= max ? some(stored) : none();
|
|
11
16
|
const Themes = {
|
|
12
17
|
Light: "light",
|
|
13
|
-
Dark: "dark"
|
|
18
|
+
Dark: "dark",
|
|
19
|
+
/**Follows the light or dark mode of the operating system, only offered when theme_init enables system*/
|
|
20
|
+
System: "system"
|
|
14
21
|
};
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
const LIGHT = {
|
|
23
|
+
name: "Light",
|
|
24
|
+
description: "Theme optimized for daylight",
|
|
25
|
+
icon: material_light_mode_rounded
|
|
26
|
+
};
|
|
27
|
+
const DARK = {
|
|
28
|
+
name: "Dark",
|
|
29
|
+
description: "Theme optimized for night time",
|
|
30
|
+
icon: material_dark_mode_rounded
|
|
31
|
+
};
|
|
32
|
+
/**Theme choices, the System choice shows the theme the operating system currently uses
|
|
33
|
+
* @param system theme of the operating system, undefined when the System choice is not offered*/
|
|
34
|
+
const theme_list = (system) => {
|
|
35
|
+
const list = {
|
|
36
|
+
[Themes.Light]: LIGHT,
|
|
37
|
+
[Themes.Dark]: DARK
|
|
38
|
+
};
|
|
39
|
+
if (system) {
|
|
40
|
+
const active = system === Themes.Dark ? DARK : LIGHT;
|
|
41
|
+
list[Themes.System] = {
|
|
42
|
+
name: "System (" + active.name + ")",
|
|
43
|
+
description: "Follows the light or dark mode of the operating system",
|
|
44
|
+
icon: active.icon
|
|
45
|
+
};
|
|
25
46
|
}
|
|
26
|
-
|
|
47
|
+
return list;
|
|
48
|
+
};
|
|
49
|
+
const THEMES = state$1.ok_w(theme_list());
|
|
27
50
|
const THEME_ID = "theme";
|
|
28
|
-
|
|
29
|
-
SETTINGS.
|
|
51
|
+
/**Theme the user chose, undefined when nothing has been chosen yet*/
|
|
52
|
+
const STORED_THEME = SETTINGS.get(THEME_ID, void 0, one_of(Themes)).value;
|
|
53
|
+
const PRIVATE_THEME = state$1.rosw(state$1.e.help(ok(STORED_THEME ?? Themes.Light), { list: THEMES }), true);
|
|
30
54
|
const THEME = PRIVATE_THEME.read_write;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
55
|
+
/**Sets up the theme setting, called once by theme_init
|
|
56
|
+
* @param system theme of the operating system, undefined when the System choice is not offered
|
|
57
|
+
* @param default_theme theme used when the user has not chosen one*/
|
|
58
|
+
function theme_setting_init(system, default_theme) {
|
|
59
|
+
if (system) THEMES.set_ok(theme_list(system));
|
|
60
|
+
if (STORED_THEME === void 0 || STORED_THEME === Themes.System && !system) PRIVATE_THEME.set_ok(default_theme);
|
|
61
|
+
SETTINGS.register(THEME_ID, "Theme", "Theme to use for the UI", PRIVATE_THEME);
|
|
62
|
+
}
|
|
63
|
+
/**Updates the System choice to show the theme the operating system uses*/
|
|
64
|
+
function theme_setting_system(system) {
|
|
65
|
+
THEMES.set_ok(theme_list(system));
|
|
66
|
+
}
|
|
34
67
|
const SCALE_ID = "scale";
|
|
35
|
-
const PRIVATE_SCALE = state$1.rosw(state$1.n.help(SETTINGS.get(SCALE_ID, 100), {
|
|
68
|
+
const PRIVATE_SCALE = state$1.rosw(state$1.n.help(SETTINGS.get(SCALE_ID, 100, in_range(50, 400)), {
|
|
36
69
|
min: state$1.ok(50),
|
|
37
70
|
max: state$1.ok(400),
|
|
38
71
|
unit: state$1.ok("%"),
|
|
@@ -60,7 +93,7 @@ const SCROLLBAR_MODES = state$1.ok(state$1.e.list({
|
|
|
60
93
|
description: "Large touch friendly scrollbar"
|
|
61
94
|
}
|
|
62
95
|
}));
|
|
63
|
-
const PRIVATE_SCROLLBAR_MODE = state$1.rosw(state$1.e.help(SETTINGS.get("scrollbar", ScrollbarModes.Thin), { list: SCROLLBAR_MODES }), true);
|
|
96
|
+
const PRIVATE_SCROLLBAR_MODE = state$1.rosw(state$1.e.help(SETTINGS.get("scrollbar", ScrollbarModes.Thin, one_of(ScrollbarModes)), { list: SCROLLBAR_MODES }), true);
|
|
64
97
|
SETTINGS.register("scrollbar", "Scrollbar Mode", "Size of the scrollbar to use", PRIVATE_SCROLLBAR_MODE);
|
|
65
98
|
const SCROLLBAR_MODE = PRIVATE_SCROLLBAR_MODE.read_write;
|
|
66
99
|
const InputModes = {
|
|
@@ -86,7 +119,7 @@ const INPUT_MODES = state$1.ok(state$1.e.list({
|
|
|
86
119
|
}
|
|
87
120
|
}));
|
|
88
121
|
const INPUT_MODE_ID = "input_mode";
|
|
89
|
-
const PRIVATE_INPUT_MODE = state$1.rosw(state$1.e.help(SETTINGS.get(INPUT_MODE_ID, matchMedia("(pointer: coarse)").matches ? InputModes.Touch : InputModes.Mouse), { list: INPUT_MODES }), true);
|
|
122
|
+
const PRIVATE_INPUT_MODE = state$1.rosw(state$1.e.help(SETTINGS.get(INPUT_MODE_ID, matchMedia("(pointer: coarse)").matches ? InputModes.Touch : InputModes.Mouse, one_of(InputModes)), { list: INPUT_MODES }), true);
|
|
90
123
|
SETTINGS.register(INPUT_MODE_ID, "Input Mode", "Setting for preffered input mode, changes UI elements to be more optimized for the selected input mode", PRIVATE_INPUT_MODE);
|
|
91
124
|
const INPUT_MODE = PRIVATE_INPUT_MODE.read_write;
|
|
92
125
|
const AnimationLevels = {
|
|
@@ -109,11 +142,11 @@ const ANIMATION_LEVELS = state$1.ok(state$1.e.list({
|
|
|
109
142
|
}
|
|
110
143
|
}));
|
|
111
144
|
const ANIMATION_LEVEL_ID = "animation_level";
|
|
112
|
-
const PRIVATE_ANIMATION_LEVEL = state$1.rosw(state$1.e.help(SETTINGS.get(ANIMATION_LEVEL_ID, AnimationLevels.None), { list: ANIMATION_LEVELS }), true);
|
|
145
|
+
const PRIVATE_ANIMATION_LEVEL = state$1.rosw(state$1.e.help(SETTINGS.get(ANIMATION_LEVEL_ID, AnimationLevels.None, one_of(AnimationLevels)), { list: ANIMATION_LEVELS }), true);
|
|
113
146
|
SETTINGS.register(ANIMATION_LEVEL_ID, "Animation Level", "Setting for animation level, changes the amount of animations used in the UI", PRIVATE_ANIMATION_LEVEL);
|
|
114
147
|
const ANIMATION_LEVEL = PRIVATE_ANIMATION_LEVEL.read_write;
|
|
115
148
|
const ANIMATION_SPEED_ID = "animation_speed";
|
|
116
|
-
const PRIVATE_ANIMATION_SPEED = state$1.rosw(state$1.n.help(SETTINGS.get(ANIMATION_SPEED_ID, 200), {
|
|
149
|
+
const PRIVATE_ANIMATION_SPEED = state$1.rosw(state$1.n.help(SETTINGS.get(ANIMATION_SPEED_ID, 200, in_range(50, 1e3)), {
|
|
117
150
|
min: state$1.ok(50),
|
|
118
151
|
max: state$1.ok(1e3),
|
|
119
152
|
unit: state$1.ok("ms"),
|
|
@@ -126,14 +159,32 @@ const ANIMATION_SPEED = PRIVATE_ANIMATION_SPEED.read_write;
|
|
|
126
159
|
const BOTTOM_GROUPS = {};
|
|
127
160
|
// src/theme/engine.ts
|
|
128
161
|
var ThemeEngine = class {
|
|
129
|
-
|
|
162
|
+
#started = false;
|
|
163
|
+
/**Theme of the operating system, used for the System theme*/
|
|
164
|
+
#os_theme = Themes.Light;
|
|
165
|
+
/**Starts applying the theme to all documents, called once by theme_init*/
|
|
166
|
+
start() {
|
|
167
|
+
this.#started = true;
|
|
130
168
|
DOCUMENT_HANDLER.events.on("added", (e) => {
|
|
131
169
|
this.#apply_all_to_doc(e.data);
|
|
132
170
|
});
|
|
133
|
-
|
|
171
|
+
this.#for_documents((doc) => {
|
|
134
172
|
this.#apply_all_to_doc(doc);
|
|
135
173
|
});
|
|
136
174
|
}
|
|
175
|
+
/**Runs for every document, nothing is applied before the engine is started*/
|
|
176
|
+
#for_documents(func) {
|
|
177
|
+
if (this.#started) DOCUMENT_HANDLER.for_documents(func);
|
|
178
|
+
}
|
|
179
|
+
/**Sets the theme of the operating system, reapplying the theme when System is used*/
|
|
180
|
+
set_os_theme(theme) {
|
|
181
|
+
this.#os_theme = theme;
|
|
182
|
+
if (THEME.ok() === Themes.System) this.apply_theme(Themes.System);
|
|
183
|
+
}
|
|
184
|
+
/**Resolves the System theme to the theme of the operating system*/
|
|
185
|
+
#applied(theme) {
|
|
186
|
+
return theme === Themes.System ? this.#os_theme : theme;
|
|
187
|
+
}
|
|
137
188
|
/**This applies the current theme to a document*/
|
|
138
189
|
#apply_all_to_doc(doc) {
|
|
139
190
|
this.#apply_scrollbar_to_doc(doc, SCROLLBAR_MODE.ok());
|
|
@@ -145,7 +196,7 @@ var ThemeEngine = class {
|
|
|
145
196
|
}
|
|
146
197
|
/**This applies the current theme to a document*/
|
|
147
198
|
apply_scrollbar(scroll) {
|
|
148
|
-
|
|
199
|
+
this.#for_documents((doc) => {
|
|
149
200
|
this.#apply_scrollbar_to_doc(doc, scroll);
|
|
150
201
|
});
|
|
151
202
|
}
|
|
@@ -158,7 +209,7 @@ var ThemeEngine = class {
|
|
|
158
209
|
}
|
|
159
210
|
/**This applies the current theme to a document*/
|
|
160
211
|
apply_animation_level(anim) {
|
|
161
|
-
|
|
212
|
+
this.#for_documents((doc) => {
|
|
162
213
|
this.#apply_animation_level_to_doc(doc, anim);
|
|
163
214
|
});
|
|
164
215
|
}
|
|
@@ -174,7 +225,7 @@ var ThemeEngine = class {
|
|
|
174
225
|
}
|
|
175
226
|
/**This applies the current theme to a document*/
|
|
176
227
|
apply_animation_speed(speed) {
|
|
177
|
-
|
|
228
|
+
this.#for_documents((doc) => {
|
|
178
229
|
this.#apply_animation_speed_to_doc(doc, speed);
|
|
179
230
|
});
|
|
180
231
|
}
|
|
@@ -183,16 +234,17 @@ var ThemeEngine = class {
|
|
|
183
234
|
}
|
|
184
235
|
/**This applies the current theme to a document*/
|
|
185
236
|
apply_theme(theme) {
|
|
186
|
-
|
|
237
|
+
this.#for_documents((doc) => {
|
|
187
238
|
this.#apply_theme_to_doc(doc, theme);
|
|
188
239
|
});
|
|
189
240
|
}
|
|
190
241
|
#apply_theme_to_doc(doc, theme) {
|
|
191
|
-
|
|
242
|
+
const applied = this.#applied(theme);
|
|
243
|
+
for (const key in BOTTOM_GROUPS) BOTTOM_GROUPS[key].apply_themes(doc.documentElement.style, applied);
|
|
192
244
|
}
|
|
193
245
|
/**This applies the current scale to a document*/
|
|
194
246
|
apply_scale(scale) {
|
|
195
|
-
|
|
247
|
+
this.#for_documents((doc) => {
|
|
196
248
|
this.#apply_scale_to_doc(doc, scale);
|
|
197
249
|
});
|
|
198
250
|
}
|
|
@@ -201,7 +253,7 @@ var ThemeEngine = class {
|
|
|
201
253
|
}
|
|
202
254
|
/**Auto Input Mode */
|
|
203
255
|
apply_input(mode) {
|
|
204
|
-
|
|
256
|
+
this.#for_documents((doc) => {
|
|
205
257
|
this.#apply_input_to_doc(doc, mode);
|
|
206
258
|
});
|
|
207
259
|
}
|
|
@@ -226,8 +278,8 @@ var ThemeEngine = class {
|
|
|
226
278
|
}
|
|
227
279
|
}
|
|
228
280
|
apply_single_property(key, variable) {
|
|
229
|
-
const theme_buff = THEME.ok();
|
|
230
|
-
|
|
281
|
+
const theme_buff = this.#applied(THEME.ok());
|
|
282
|
+
this.#for_documents((doc) => {
|
|
231
283
|
doc.documentElement.style.setProperty(key, variable[theme_buff]);
|
|
232
284
|
});
|
|
233
285
|
}
|
|
@@ -236,13 +288,13 @@ const theme_engine = new ThemeEngine();
|
|
|
236
288
|
THEME.sub((val) => {
|
|
237
289
|
theme_engine.apply_theme(val.value);
|
|
238
290
|
});
|
|
239
|
-
|
|
291
|
+
/**Size of a rem in pixels at the current scale, set right away from the stored scale*/
|
|
240
292
|
let scale_rem = 16;
|
|
241
293
|
SCALE.sub((val) => {
|
|
242
|
-
scale_value = val.value / 100;
|
|
294
|
+
const scale_value = val.value / 100;
|
|
243
295
|
scale_rem = scale_value * 16;
|
|
244
296
|
theme_engine.apply_scale(scale_value);
|
|
245
|
-
});
|
|
297
|
+
}, true);
|
|
246
298
|
/**Converts the given rems to pixels */
|
|
247
299
|
function rem_to_px(rem) {
|
|
248
300
|
return rem * scale_rem;
|
|
@@ -260,12 +312,17 @@ INPUT_MODE.sub((val) => {
|
|
|
260
312
|
ANIMATION_LEVEL.sub((val) => {
|
|
261
313
|
theme_engine.apply_animation_level(val.value);
|
|
262
314
|
});
|
|
315
|
+
ANIMATION_SPEED.sub((val) => {
|
|
316
|
+
theme_engine.apply_animation_speed(val.value);
|
|
317
|
+
});
|
|
318
|
+
// src/theme/variables.ts
|
|
263
319
|
/**Initialises the settings for the package
|
|
264
320
|
* @param package_name use import {name} from "../package.json"
|
|
265
321
|
* @param name name of group formatted for user reading
|
|
266
322
|
* @param description a description of what the setting group is about*/
|
|
267
323
|
const theme_init_variable_root = (package_name, name, description) => {
|
|
268
324
|
if (package_name.includes("-")) throw new Error("Dash not permitted in package name " + package_name);
|
|
325
|
+
if (package_name in BOTTOM_GROUPS) throw new Error("Theme variable group already registered " + package_name + ", by another package or by this library being loaded twice");
|
|
269
326
|
BOTTOM_GROUPS[package_name] = new ThemeVariableGroup(package_name, name, description);
|
|
270
327
|
return BOTTOM_GROUPS[package_name];
|
|
271
328
|
};
|
|
@@ -328,11 +385,35 @@ var ThemeVariableGroup = class ThemeVariableGroup {
|
|
|
328
385
|
const BUILT_IN = 0;
|
|
329
386
|
const root = theme_init_variable_root("common", "Shared Variables", "Shared variables across features");
|
|
330
387
|
const scroll_bar_thumb = root.make_sub_group("scrollbar", "Scrollbar", "Scrollbar variables").make_sub_group("thumb", "Thumb", "Scrollbar Thumb variables");
|
|
331
|
-
scroll_bar_thumb.make_variable("color", "Thumb Color", "Color of the scrollbar thumb in normal state", GREY["400"], GREY["800"], "
|
|
332
|
-
scroll_bar_thumb.make_variable("hoverColor", "Thumb Hover Color", "Color of the scrollbar thumb when hovered", GREY["600"], GREY["600"], "
|
|
333
|
-
scroll_bar_thumb.make_variable("activeColor", "Thumb Color", "Color of the scrollbar thumb
|
|
388
|
+
scroll_bar_thumb.make_variable("color", "Thumb Color", "Color of the scrollbar thumb in normal state", GREY["400"], GREY["800"], "Color", void 0);
|
|
389
|
+
scroll_bar_thumb.make_variable("hoverColor", "Thumb Hover Color", "Color of the scrollbar thumb when hovered", GREY["600"], GREY["600"], "Color", void 0);
|
|
390
|
+
scroll_bar_thumb.make_variable("activeColor", "Thumb Active Color", "Color of the scrollbar thumb when pressed", GREY["500"], GREY["700"], "Color", void 0);
|
|
334
391
|
root.make_sub_group("fonts", "Fonts", "Font variables").make_variable("base", "UI Base Font", "The base font for the UI", "\"Roboto\", Arial, Helvetica, sans-serif", "\"Roboto\", Arial, Helvetica, sans-serif", "Font", void 0);
|
|
335
392
|
root.make_sub_group("colors", "Colors", "Color variables").make_variable("layer1", "UI Layer 1", "Color of the first layer of the UI", GREY[50], "#111111", "Color", void 0);
|
|
336
|
-
|
|
393
|
+
// src/theme/init.ts
|
|
394
|
+
let initialized = false;
|
|
395
|
+
/**Starts the theme, the app must call it once, nothing of the theme is applied to the page before.
|
|
396
|
+
* This is the only place the operating system dark mode is read, and only when system is on*/
|
|
397
|
+
function theme_init(options = {}) {
|
|
398
|
+
const default_theme = options.default ?? (options.system ? Themes.System : Themes.Light);
|
|
399
|
+
if (default_theme === Themes.System && !options.system) throw new Error("The System theme can only be the default with system on");
|
|
400
|
+
if (initialized) throw new Error("theme_init has already been called");
|
|
401
|
+
initialized = true;
|
|
402
|
+
let os_theme;
|
|
403
|
+
if (options.system) {
|
|
404
|
+
const query = window.matchMedia("(prefers-color-scheme: dark)");
|
|
405
|
+
const theme_of = (dark) => dark ? Themes.Dark : Themes.Light;
|
|
406
|
+
os_theme = theme_of(query.matches);
|
|
407
|
+
theme_engine.set_os_theme(os_theme);
|
|
408
|
+
query.addEventListener("change", (e) => {
|
|
409
|
+
const changed = theme_of(e.matches);
|
|
410
|
+
theme_setting_system(changed);
|
|
411
|
+
theme_engine.set_os_theme(changed);
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
theme_setting_init(os_theme, default_theme);
|
|
415
|
+
theme_engine.start();
|
|
416
|
+
}
|
|
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 };
|
|
337
418
|
|
|
338
|
-
//# sourceMappingURL=theme-
|
|
419
|
+
//# sourceMappingURL=theme-CFeGnUuF.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-CFeGnUuF.mjs","names":["st"],"sources":["../../package.json","../src/theme/settings.ts","../src/theme/shared.ts","../src/theme/engine.ts","../src/theme/variables.ts","../src/theme/builtIn.ts","../src/theme/init.ts"],"sourcesContent":["","import {\n material_dark_mode_rounded,\n material_edit_rounded,\n material_light_mode_rounded,\n material_mouse_rounded,\n material_touch_app_rounded,\n} from \"#icons\";\nimport { settings_init } from \"#settings\";\nimport { none, ok, some, type Option } from \"@chocbite/ts-lib/result\";\nimport { state as st } from \"@chocbite/ts-lib/state\";\nimport { version } from \"../../../package.json\";\n\nconst SETTINGS = settings_init(\n \"@chocbite/ts-lib-theme\",\n version,\n \"Theme/UI\",\n \"Settings for UI elements and color themes\",\n);\n\n/**Accepts a stored setting only when it is one of the given values, otherwise the default is used*/\nconst one_of =\n <T>(values: { [key: string]: T }) =>\n (stored: unknown): Option<T> =>\n Object.values(values).includes(stored as T) ? some(stored as T) : none();\n\n/**Accepts a stored setting only when it is a number within the range, otherwise the default is used*/\nconst in_range =\n (min: number, max: number) =>\n (stored: unknown): Option<number> =>\n typeof stored === \"number\" && stored >= min && stored <= max\n ? some(stored)\n : none();\n\n// _______ _ _ ______ __ __ ______\n// |__ __| | | | ____| \\/ | ____|\n// | | | |__| | |__ | \\ / | |__\n// | | | __ | __| | |\\/| | __|\n// | | | | | | |____| | | | |____\n// |_| |_| |_|______|_| |_|______|\nexport const Themes = {\n Light: \"light\",\n Dark: \"dark\",\n /**Follows the light or dark mode of the operating system, only offered when theme_init enables system*/\n System: \"system\",\n} as const;\nexport type Themes = (typeof Themes)[keyof typeof Themes];\n/**Themes that can be applied to the page, System is resolved to one of these*/\nexport type AppliedThemes = typeof Themes.Light | typeof Themes.Dark;\n\ntype ThemeList = Parameters<typeof st.e.list<Themes>>[0];\nconst LIGHT = {\n name: \"Light\",\n description: \"Theme optimized for daylight\",\n icon: material_light_mode_rounded,\n};\nconst DARK = {\n name: \"Dark\",\n description: \"Theme optimized for night time\",\n icon: material_dark_mode_rounded,\n};\n/**Theme choices, the System choice shows the theme the operating system currently uses\n * @param system theme of the operating system, undefined when the System choice is not offered*/\nconst theme_list = (system?: AppliedThemes): ThemeList => {\n const list: Partial<ThemeList> = {\n [Themes.Light]: LIGHT,\n [Themes.Dark]: DARK,\n };\n if (system) {\n const active = system === Themes.Dark ? DARK : LIGHT;\n list[Themes.System] = {\n name: \"System (\" + active.name + \")\",\n description: \"Follows the light or dark mode of the operating system\",\n icon: active.icon,\n };\n }\n return list as ThemeList;\n};\nconst THEMES = st.ok_w(theme_list());\n\nconst THEME_ID = \"theme\";\n/**Theme the user chose, undefined when nothing has been chosen yet*/\nconst STORED_THEME = SETTINGS.get<Themes | undefined>(\n THEME_ID,\n undefined,\n one_of(Themes),\n).value;\nconst PRIVATE_THEME = st.rosw(\n st.e.help(ok(STORED_THEME ?? (Themes.Light as Themes)), { list: THEMES }),\n true,\n);\n\nexport const THEME = PRIVATE_THEME.read_write;\n\n/**Sets up the theme setting, called once by theme_init\n * @param system theme of the operating system, undefined when the System choice is not offered\n * @param default_theme theme used when the user has not chosen one*/\nexport function theme_setting_init(\n system: AppliedThemes | undefined,\n default_theme: Themes,\n) {\n if (system) THEMES.set_ok(theme_list(system));\n //Set before registering, so the default is not stored as if the user chose it\n if (STORED_THEME === undefined || (STORED_THEME === Themes.System && !system))\n PRIVATE_THEME.set_ok(default_theme);\n SETTINGS.register(\n THEME_ID,\n \"Theme\",\n \"Theme to use for the UI\",\n PRIVATE_THEME,\n );\n}\n\n/**Updates the System choice to show the theme the operating system uses*/\nexport function theme_setting_system(system: AppliedThemes) {\n THEMES.set_ok(theme_list(system));\n}\n\n// _____ _____ _ ______\n// / ____|/ ____| /\\ | | | ____|\n// | (___ | | / \\ | | | |__\n// \\___ \\| | / /\\ \\ | | | __|\n// ____) | |____ / ____ \\| |____| |____\n// |_____/ \\_____/_/ \\_\\______|______|\nconst SCALE_ID = \"scale\";\nconst PRIVATE_SCALE = st.rosw(\n st.n.help(SETTINGS.get(SCALE_ID, 100, in_range(50, 400)), {\n min: st.ok(50),\n max: st.ok(400),\n unit: st.ok(\"%\"),\n start: st.ok(0),\n step: st.ok(1),\n }),\n true,\n);\nSETTINGS.register(SCALE_ID, \"Scale\", \"UI scale\", PRIVATE_SCALE);\nexport const SCALE = PRIVATE_SCALE.read_write;\n\n// _____ _____ _____ ____ _ _ ____ _____\n// / ____|/ ____| __ \\ / __ \\| | | | | _ \\ /\\ | __ \\\n// | (___ | | | |__) | | | | | | | | |_) | / \\ | |__) |\n// \\___ \\| | | _ /| | | | | | | | _ < / /\\ \\ | _ /\n// ____) | |____| | \\ \\| |__| | |____| |____| |_) / ____ \\| | \\ \\\n// |_____/ \\_____|_| \\_\\\\____/|______|______|____/_/ \\_\\_| \\_\\\nexport const ScrollbarModes = {\n Thin: \"thin\",\n Medium: \"medium\",\n Wide: \"wide\",\n} as const;\nexport type ScrollbarModes =\n (typeof ScrollbarModes)[keyof typeof ScrollbarModes];\n\nconst SCROLLBAR_MODES = st.ok(\n st.e.list<ScrollbarModes>({\n [ScrollbarModes.Thin]: {\n name: \"Thin\",\n description: \"Thin modern scrollbar\",\n },\n [ScrollbarModes.Medium]: {\n name: \"Medium\",\n description: \"Normal scrollbar\",\n },\n [ScrollbarModes.Wide]: {\n name: \"Wide\",\n description: \"Large touch friendly scrollbar\",\n },\n }),\n);\n\nconst SCROLLBAR_ID = \"scrollbar\";\nconst PRIVATE_SCROLLBAR_MODE = st.rosw(\n st.e.help(\n SETTINGS.get(\n SCROLLBAR_ID,\n ScrollbarModes.Thin as ScrollbarModes,\n one_of(ScrollbarModes),\n ),\n { list: SCROLLBAR_MODES },\n ),\n true,\n);\nSETTINGS.register(\n \"scrollbar\",\n \"Scrollbar Mode\",\n \"Size of the scrollbar to use\",\n PRIVATE_SCROLLBAR_MODE,\n);\n\nexport const SCROLLBAR_MODE = PRIVATE_SCROLLBAR_MODE.read_write;\n\n// _____ _ _ _____ _ _ _______ __ __ ____ _____ ______\n// |_ _| \\ | | __ \\| | | |__ __| | \\/ |/ __ \\| __ \\| ____|\n// | | | \\| | |__) | | | | | | | \\ / | | | | | | | |__\n// | | | . ` | ___/| | | | | | | |\\/| | | | | | | | __|\n// _| |_| |\\ | | | |__| | | | | | | | |__| | |__| | |____\n// |_____|_| \\_|_| \\____/ |_| |_| |_|\\____/|_____/|______|\nexport const InputModes = {\n Mouse: \"mouse\",\n Pen: \"pen\",\n Touch: \"touch\",\n} as const;\nexport type InputModes = (typeof InputModes)[keyof typeof InputModes];\n\nconst INPUT_MODES = st.ok(\n st.e.list<InputModes>({\n [InputModes.Mouse]: {\n name: \"Mouse\",\n description: \"Mouse input\",\n icon: material_mouse_rounded,\n },\n [InputModes.Pen]: {\n name: \"Pen\",\n description: \"Pen input\",\n icon: material_edit_rounded,\n },\n [InputModes.Touch]: {\n name: \"Touch\",\n description: \"Touch input\",\n icon: material_touch_app_rounded,\n },\n }),\n);\n\nconst INPUT_MODE_ID = \"input_mode\";\nconst PRIVATE_INPUT_MODE = st.rosw(\n st.e.help(\n SETTINGS.get(\n INPUT_MODE_ID,\n matchMedia(\"(pointer: coarse)\").matches\n ? InputModes.Touch\n : (InputModes.Mouse as InputModes),\n one_of(InputModes),\n ),\n { list: INPUT_MODES },\n ),\n true,\n);\nSETTINGS.register(\n INPUT_MODE_ID,\n \"Input Mode\",\n \"Setting for preffered input mode, changes UI elements to be more optimized for the selected input mode\",\n PRIVATE_INPUT_MODE,\n);\n\nexport const INPUT_MODE = PRIVATE_INPUT_MODE.read_write;\n\n// _ _ _____ __ __ _______ _____ ____ _ _ _ ________ ________ _\n// /\\ | \\ | |_ _| \\/ | /\\|__ __|_ _/ __ \\| \\ | | | | | ____\\ \\ / / ____| |\n// / \\ | \\| | | | | \\ / | / \\ | | | || | | | \\| | | | | |__ \\ \\ / /| |__ | |\n// / /\\ \\ | . ` | | | | |\\/| | / /\\ \\ | | | || | | | . ` | | | | __| \\ \\/ / | __| | |\n// / ____ \\| |\\ |_| |_| | | |/ ____ \\| | _| || |__| | |\\ | | |____| |____ \\ / | |____| |____\n// /_/ \\_\\_| \\_|_____|_| |_/_/ \\_\\_| |_____\\____/|_| \\_| |______|______| \\/ |______|______|\nexport const AnimationLevels = {\n All: \"all\",\n Some: \"some\",\n None: \"none\",\n} as const;\nexport type AnimationLevels =\n (typeof AnimationLevels)[keyof typeof AnimationLevels];\n\nconst ANIMATION_LEVELS = st.ok(\n st.e.list<AnimationLevels>({\n [AnimationLevels.All]: { name: \"All\", description: \"All animations\" },\n [AnimationLevels.Some]: {\n name: \"Functional\",\n description: \"Only functional animations that improve usability\",\n },\n [AnimationLevels.None]: { name: \"None\", description: \"No animations\" },\n }),\n);\n\nconst ANIMATION_LEVEL_ID = \"animation_level\";\nconst PRIVATE_ANIMATION_LEVEL = st.rosw(\n st.e.help(\n SETTINGS.get(\n ANIMATION_LEVEL_ID,\n AnimationLevels.None as AnimationLevels,\n one_of(AnimationLevels),\n ),\n { list: ANIMATION_LEVELS },\n ),\n true,\n);\nSETTINGS.register(\n ANIMATION_LEVEL_ID,\n \"Animation Level\",\n \"Setting for animation level, changes the amount of animations used in the UI\",\n PRIVATE_ANIMATION_LEVEL,\n);\n\nexport const ANIMATION_LEVEL = PRIVATE_ANIMATION_LEVEL.read_write;\n\n// _ _ _____ __ __ _______ _____ ____ _ _ _____ _____ ______ ______ _____\n// /\\ | \\ | |_ _| \\/ | /\\|__ __|_ _/ __ \\| \\ | | / ____| __ \\| ____| ____| __ \\\n// / \\ | \\| | | | | \\ / | / \\ | | | || | | | \\| | | (___ | |__) | |__ | |__ | | | |\n// / /\\ \\ | . ` | | | | |\\/| | / /\\ \\ | | | || | | | . ` | \\___ \\| ___/| __| | __| | | | |\n// / ____ \\| |\\ |_| |_| | | |/ ____ \\| | _| || |__| | |\\ | ____) | | | |____| |____| |__| |\n// /_/ \\_\\_| \\_|_____|_| |_/_/ \\_\\_| |_____\\____/|_| \\_| |_____/|_| |______|______|_____/\nconst ANIMATION_SPEED_ID = \"animation_speed\";\nconst PRIVATE_ANIMATION_SPEED = st.rosw(\n st.n.help(SETTINGS.get(ANIMATION_SPEED_ID, 200, in_range(50, 1000)), {\n min: st.ok(50),\n max: st.ok(1000),\n unit: st.ok(\"ms\"),\n start: st.ok(0),\n step: st.ok(50),\n }),\n true,\n);\nSETTINGS.register(\n ANIMATION_SPEED_ID,\n \"Animation Speed\",\n \"Setting for animation speed, changes the speed of animations in the UI\",\n PRIVATE_ANIMATION_SPEED,\n);\n\nexport const ANIMATION_SPEED = PRIVATE_ANIMATION_SPEED.read_write;\n","import type { ThemeVariableGroup } from \"./variables\";\n\nexport const BOTTOM_GROUPS: { [key: string]: ThemeVariableGroup } = {};\n","import { DOCUMENT_HANDLER } from \"#document\";\nimport {\n ANIMATION_LEVEL,\n ANIMATION_SPEED,\n AnimationLevels,\n INPUT_MODE,\n InputModes,\n SCALE,\n SCROLLBAR_MODE,\n ScrollbarModes,\n THEME,\n Themes,\n type AppliedThemes,\n} from \"./settings\";\nimport { BOTTOM_GROUPS } from \"./shared\";\n\nclass ThemeEngine {\n #started = false;\n /**Theme of the operating system, used for the System theme*/\n #os_theme: AppliedThemes = Themes.Light;\n\n /**Starts applying the theme to all documents, called once by theme_init*/\n start() {\n this.#started = true;\n DOCUMENT_HANDLER.events.on(\"added\", (e) => {\n this.#apply_all_to_doc(e.data);\n });\n this.#for_documents((doc) => {\n this.#apply_all_to_doc(doc);\n });\n }\n\n /**Runs for every document, nothing is applied before the engine is started*/\n #for_documents(func: (doc: Document) => void) {\n if (this.#started) DOCUMENT_HANDLER.for_documents(func);\n }\n\n /**Sets the theme of the operating system, reapplying the theme when System is used*/\n set_os_theme(theme: AppliedThemes) {\n this.#os_theme = theme;\n if (THEME.ok() === Themes.System) this.apply_theme(Themes.System);\n }\n\n /**Resolves the System theme to the theme of the operating system*/\n #applied(theme: Themes): AppliedThemes {\n return theme === Themes.System ? this.#os_theme : theme;\n }\n\n /**This applies the current theme to a document*/\n #apply_all_to_doc(doc: Document) {\n this.#apply_scrollbar_to_doc(doc, SCROLLBAR_MODE.ok());\n this.#apply_theme_to_doc(doc, THEME.ok());\n this.#apply_input_to_doc(doc, INPUT_MODE.ok());\n this.#apply_scale_to_doc(doc, SCALE.ok() / 100);\n this.#apply_animation_level_to_doc(doc, ANIMATION_LEVEL.ok());\n this.#apply_animation_speed_to_doc(doc, ANIMATION_SPEED.ok());\n }\n\n /**This applies the current theme to a document*/\n apply_scrollbar(scroll: ScrollbarModes) {\n this.#for_documents((doc) => {\n this.#apply_scrollbar_to_doc(doc, scroll);\n });\n }\n #apply_scrollbar_to_doc(doc: Document, scroll: ScrollbarModes) {\n doc.documentElement.style.setProperty(\n \"--scrollbar\",\n {\n [ScrollbarModes.Thin]: \"0.6rem\",\n [ScrollbarModes.Medium]: \"1rem\",\n [ScrollbarModes.Wide]: \"2.6rem\",\n }[scroll],\n );\n }\n\n /**This applies the current theme to a document*/\n apply_animation_level(anim: AnimationLevels) {\n this.#for_documents((doc) => {\n this.#apply_animation_level_to_doc(doc, anim);\n });\n }\n #apply_animation_level_to_doc(doc: Document, anim: AnimationLevels) {\n doc.documentElement.classList.remove(\"anim-all\", \"anim-some\");\n switch (anim) {\n case AnimationLevels.All:\n doc.documentElement.classList.add(\"anim-all\");\n doc.documentElement.classList.add(\"anim-some\");\n break;\n case AnimationLevels.Some:\n doc.documentElement.classList.add(\"anim-some\");\n break;\n }\n }\n\n /**This applies the current theme to a document*/\n apply_animation_speed(speed: number) {\n this.#for_documents((doc) => {\n this.#apply_animation_speed_to_doc(doc, speed);\n });\n }\n #apply_animation_speed_to_doc(doc: Document, speed: number) {\n const style = doc.documentElement.style;\n style.setProperty(\"--animation-speed\", speed.toString() + \"ms\");\n }\n\n /**This applies the current theme to a document*/\n apply_theme(theme: Themes) {\n this.#for_documents((doc) => {\n this.#apply_theme_to_doc(doc, theme);\n });\n }\n #apply_theme_to_doc(doc: Document, theme: Themes) {\n const applied = this.#applied(theme);\n for (const key in BOTTOM_GROUPS)\n BOTTOM_GROUPS[key].apply_themes(doc.documentElement.style, applied);\n }\n\n /**This applies the current scale to a document*/\n apply_scale(scale: number) {\n this.#for_documents((doc) => {\n this.#apply_scale_to_doc(doc, scale);\n });\n }\n #apply_scale_to_doc(doc: Document, scale: number) {\n doc.documentElement.style.fontSize = scale * 16 + \"px\";\n }\n\n /**Auto Input Mode */\n apply_input(mode: InputModes) {\n this.#for_documents((doc) => {\n this.#apply_input_to_doc(doc, mode);\n });\n }\n #apply_input_to_doc(doc: Document, mode: InputModes) {\n const style = doc.documentElement.style;\n style.setProperty(\"--mouse\", \"0\");\n style.setProperty(\"--pen\", \"0\");\n style.setProperty(\"--touch\", \"0\");\n doc.documentElement.classList.remove(\"mouse\", \"pen\", \"touch\");\n switch (mode) {\n case InputModes.Mouse:\n style.setProperty(\"--mouse\", \"1\");\n doc.documentElement.classList.add(\"mouse\");\n break;\n case InputModes.Pen:\n style.setProperty(\"--pen\", \"1\");\n doc.documentElement.classList.add(\"pen\");\n break;\n case InputModes.Touch:\n style.setProperty(\"--touch\", \"1\");\n doc.documentElement.classList.add(\"touch\");\n break;\n }\n }\n\n apply_single_property(key: string, variable: { [s: string]: string }) {\n const theme_buff = this.#applied(THEME.ok());\n this.#for_documents((doc) => {\n doc.documentElement.style.setProperty(key, variable[theme_buff]);\n });\n }\n}\n\nexport const theme_engine = new ThemeEngine();\n\nTHEME.sub((val) => {\n theme_engine.apply_theme(val.value);\n});\n/**Size of a rem in pixels at the current scale, set right away from the stored scale*/\nlet scale_rem = 16;\nSCALE.sub((val) => {\n const scale_value = val.value / 100;\n scale_rem = scale_value * 16;\n theme_engine.apply_scale(scale_value);\n}, true);\n/**Converts the given rems to pixels */\nexport function rem_to_px(rem: number) {\n return rem * scale_rem;\n}\n/**Converts the given pixels to rems */\nexport function px_to_rem(px: number) {\n return px / scale_rem;\n}\nSCROLLBAR_MODE.sub((val) => {\n theme_engine.apply_scrollbar(val.value);\n});\nINPUT_MODE.sub((val) => {\n theme_engine.apply_input(val.value);\n});\nANIMATION_LEVEL.sub((val) => {\n theme_engine.apply_animation_level(val.value);\n});\nANIMATION_SPEED.sub((val) => {\n theme_engine.apply_animation_speed(val.value);\n});\n","import { theme_engine } from \"./engine\";\nimport { Themes } from \"./settings\";\nimport { BOTTOM_GROUPS } from \"./shared\";\n\n/**Initialises the settings for the package\n * @param package_name use import {name} from \"../package.json\"\n * @param name name of group formatted for user reading\n * @param description a description of what the setting group is about*/\nexport const theme_init_variable_root = (\n package_name: string,\n name: string,\n description: string\n) => {\n if (package_name.includes(\"-\"))\n throw new Error(\"Dash not permitted in package name \" + package_name);\n if (package_name in BOTTOM_GROUPS)\n throw new Error(\n \"Theme variable group already registered \" +\n package_name +\n \", by another package or by this library being loaded twice\",\n );\n BOTTOM_GROUPS[package_name] = new ThemeVariableGroup(\n package_name,\n name,\n description\n );\n return BOTTOM_GROUPS[package_name];\n};\n\n/**Group of settings should never be instantiated manually use initSettings*/\nexport class ThemeVariableGroup {\n private path_id: string;\n private variables: {\n [key: string]: {\n name: string;\n desc: string;\n vars: { [key: string]: string };\n type: keyof VariableType;\n typeParams: VariableType[keyof VariableType];\n example?: () => Element;\n };\n } = {};\n private sub_groups: { [key: string]: ThemeVariableGroup } = {};\n readonly name: string;\n readonly description: string;\n\n constructor(path: string, name: string, description: string) {\n this.path_id = path;\n this.name = name;\n this.description = description;\n }\n\n /**Makes a variable subgroup for this group\n * @param id unique identifier for this subgroup in the parent group\n * @param name name of group formatted for user reading\n * @param description a description of what the setting group is about formatted for user reading*/\n make_sub_group(id: string, name: string, description: string) {\n if (id.includes(\"-\"))\n throw new Error(\"Dash not permitted in variable id \" + id);\n if (id in this.sub_groups)\n throw new Error(\"Sub group already registered \" + id);\n return (this.sub_groups[id] = new ThemeVariableGroup(\n this.path_id + \"-\" + id,\n name,\n description\n ));\n }\n\n /**Makes a variable\n * @param id unique identifier for this variable in the group\n * @param name name of variable formatted for user reading\n * @param description a description of what the variable is about formatted for user reading\n * @param light value for light mode\n * @param dark value for dark mode\n * @param type type of variable for editing\n * @param type_params */\n make_variable<K extends keyof VariableType>(\n id: string,\n name: string,\n description: string,\n light: string,\n dark: string,\n type: K,\n type_params: VariableType[K],\n example?: () => Element\n ): string {\n if (id.includes(\"-\"))\n throw new Error(\"Dash not permitted in variable id \" + id);\n const key = \"--\" + this.path_id + \"-\" + id;\n if (key in this.variables)\n throw new Error(\"Settings already registered \" + id);\n const variable = (this.variables[key] = {\n name,\n desc: description,\n vars: { [Themes.Light]: light, [Themes.Dark]: dark },\n type,\n typeParams: type_params,\n example,\n });\n theme_engine.apply_single_property(key, variable.vars);\n return key;\n }\n\n /**Applies the groups\n * @param style unique identifier for this variable in the group\n * @param theme name of variable formatted for user reading*/\n apply_themes(style: CSSStyleDeclaration, theme: string) {\n for (const key in this.variables)\n style.setProperty(key, this.variables[key].vars[theme]);\n for (const key in this.sub_groups)\n this.sub_groups[key].apply_themes(style, theme);\n }\n}\n\n/**Defines the parameters for a variable type */\ninterface VariableType {\n /**Font variable, */\n Font: undefined;\n /**Text variable, */\n String: undefined;\n /**Color variable */\n Color: undefined;\n /**Transition type */\n TransitionType: undefined;\n /**Percent type */\n Percent: undefined;\n /**Filter type */\n Filter: undefined;\n /**Radius type */\n Radius: undefined;\n /**Time variable */\n Time: {\n /**Minimum time in milliseconds */\n min: number;\n /**Maximum time in milliseconds */\n max: number;\n };\n /**Angle variable */\n Angle: { min: number; max: number };\n /**Length variable*/\n Length: { min: number; max: number };\n /**Number variable*/\n Number: { min: number; max: number };\n /**Ratio*/\n Ratio:\n | {\n width: { min: number; max: number };\n height: { min: number; max: number };\n }\n | number;\n}\n","import { GREY } from \"@chocbite/ts-lib/colors\";\nimport { theme_init_variable_root } from \"./variables\";\n\nexport const BUILT_IN = 0;\n\nconst root = theme_init_variable_root(\n \"common\",\n \"Shared Variables\",\n \"Shared variables across features\",\n);\n\nconst scroll_bar = root.make_sub_group(\n \"scrollbar\",\n \"Scrollbar\",\n \"Scrollbar variables\",\n);\nconst scroll_bar_thumb = scroll_bar.make_sub_group(\n \"thumb\",\n \"Thumb\",\n \"Scrollbar Thumb variables\",\n);\nscroll_bar_thumb.make_variable(\n \"color\",\n \"Thumb Color\",\n \"Color of the scrollbar thumb in normal state\",\n GREY[\"400\"],\n GREY[\"800\"],\n \"Color\",\n undefined,\n);\nscroll_bar_thumb.make_variable(\n \"hoverColor\",\n \"Thumb Hover Color\",\n \"Color of the scrollbar thumb when hovered\",\n GREY[\"600\"],\n GREY[\"600\"],\n \"Color\",\n undefined,\n);\nscroll_bar_thumb.make_variable(\n \"activeColor\",\n \"Thumb Active Color\",\n \"Color of the scrollbar thumb when pressed\",\n GREY[\"500\"],\n GREY[\"700\"],\n \"Color\",\n undefined,\n);\n\nconst fonts = root.make_sub_group(\"fonts\", \"Fonts\", \"Font variables\");\nfonts.make_variable(\n \"base\",\n \"UI Base Font\",\n \"The base font for the UI\",\n '\"Roboto\", Arial, Helvetica, sans-serif',\n '\"Roboto\", Arial, Helvetica, sans-serif',\n \"Font\",\n undefined,\n);\n\n// _____ ____ _ ____ _____ _____\n// / ____/ __ \\| | / __ \\| __ \\ / ____|\n// | | | | | | | | | | | |__) | (___\n// | | | | | | | | | | | _ / \\___ \\\n// | |___| |__| | |___| |__| | | \\ \\ ____) |\n// \\_____\\____/|______\\____/|_| \\_\\_____/\n\nconst colors = root.make_sub_group(\"colors\", \"Colors\", \"Color variables\");\ncolors.make_variable(\n \"layer1\",\n \"UI Layer 1\",\n \"Color of the first layer of the UI\",\n GREY[50],\n \"#111111\",\n \"Color\",\n undefined,\n);\n","import { theme_engine } from \"./engine\";\nimport {\n theme_setting_init,\n theme_setting_system,\n Themes,\n type AppliedThemes,\n} from \"./settings\";\n\nexport interface ThemeInitOptions {\n /**Offers a System theme that follows the light or dark mode of the operating system,\n * leave it off on devices without that feature*/\n system?: boolean;\n /**Theme used until the user chooses one, defaults to System when system is on, otherwise Light*/\n default?: Themes;\n}\n\nlet initialized = false;\n\n/**Starts the theme, the app must call it once, nothing of the theme is applied to the page before.\n * This is the only place the operating system dark mode is read, and only when system is on*/\nexport function theme_init(options: ThemeInitOptions = {}) {\n const default_theme =\n options.default ?? (options.system ? Themes.System : Themes.Light);\n if (default_theme === Themes.System && !options.system)\n throw new Error(\"The System theme can only be the default with system on\");\n if (initialized) throw new Error(\"theme_init has already been called\");\n initialized = true;\n let os_theme: AppliedThemes | undefined;\n if (options.system) {\n const query = window.matchMedia(\"(prefers-color-scheme: dark)\");\n const theme_of = (dark: boolean) => (dark ? Themes.Dark : Themes.Light);\n os_theme = theme_of(query.matches);\n theme_engine.set_os_theme(os_theme);\n query.addEventListener(\"change\", (e) => {\n const changed = theme_of(e.matches);\n theme_setting_system(changed);\n theme_engine.set_os_theme(changed);\n });\n }\n theme_setting_init(os_theme, default_theme);\n theme_engine.start();\n}\n"],"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