athena-ui-js 2.2.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/widgets.js ADDED
@@ -0,0 +1,7 @@
1
+ //widgets entry of Athena UI: a dashboard of widgets (registerWidget, createWidgetGrid) and the grid maths
2
+ //Import only what you use: `import { registerWidget, createWidgetGrid } from "athena-ui-js/widgets"`.
3
+ //LICENCE: MIT
4
+ //Repository: https://github.com/csabatibortoth/athena-ui
5
+
6
+ export * from "./libs/hephaestus/widgetGrid/widgetGrid.js";
7
+ export * from "./libs/core/gridLayout.js";
@@ -88,6 +88,12 @@ export * from "./libs/core/csv.js";
88
88
  export * from "./libs/core/dateRange.js";
89
89
  export * from "./libs/core/format.js";
90
90
  export * from "./libs/core/motion.js";
91
+ export * from "./libs/hephaestus/widgetGrid/widgetGrid.js";
92
+ export * from "./libs/core/gridLayout.js";
93
+ export * from "./libs/hephaestus/codeGenerator/codeGenerator.js";
94
+ export * from "./libs/hephaestus/codeGenerator/codeEditor.js";
95
+ export * from "./libs/core/codeLanguages.js";
96
+ export * from "./libs/core/codeDiff.js";
91
97
  export * from "./libs/hephaestus/modalGenerator/modalGenerator.js";
92
98
  export * from "./libs/core/theme.js";
93
99
  export * from "./libs/hephaestus/componentGenerator/themePicker.js";
@@ -0,0 +1,4 @@
1
+ export * from "./libs/hephaestus/codeGenerator/codeGenerator.js";
2
+ export * from "./libs/hephaestus/codeGenerator/codeEditor.js";
3
+ export * from "./libs/core/codeLanguages.js";
4
+ export * from "./libs/core/codeDiff.js";
@@ -1,5 +1,5 @@
1
1
  export function applyConfig(...sources: any[]): {
2
- version: "2.2.0";
2
+ version: "2.4.0";
3
3
  container_class: "container";
4
4
  header_class: "header-container";
5
5
  header_menu_class: "header-menu menu";
@@ -32,7 +32,7 @@ export function applyConfig(...sources: any[]): {
32
32
  export function withBorder(className: any): any;
33
33
  export const BORDERED_CLASS: "default-cointainer-bordered";
34
34
  export const defaults: Readonly<{
35
- version: "2.2.0";
35
+ version: "2.4.0";
36
36
  container_class: "container";
37
37
  header_class: "header-container";
38
38
  header_menu_class: "header-menu menu";
@@ -64,7 +64,7 @@ export const defaults: Readonly<{
64
64
  }>;
65
65
  export default config;
66
66
  declare namespace config {
67
- let version: "2.2.0";
67
+ let version: "2.4.0";
68
68
  let container_class: "container";
69
69
  let header_class: "header-container";
70
70
  let header_menu_class: "header-menu menu";
@@ -0,0 +1,32 @@
1
+ /**
2
+ * The difference between two lists of lines, as operations in order. `a` and `b` are indexes into the two lists.
3
+ * When the two lists differ by more than `maxEdits` lines the result is coarse (everything removed, then everything added) instead of slow.
4
+ *
5
+ * @param {string[]} oldLines
6
+ * @param {string[]} newLines
7
+ * @param {{maxEdits?: number}} [options]
8
+ * @returns {DiffOp[]}
9
+ */
10
+ export function diffLines(oldLines: string[], newLines: string[], { maxEdits }?: {
11
+ maxEdits?: number;
12
+ }): DiffOp[];
13
+ /**
14
+ * Groups the operations into hunks that show `context` unchanged lines around each change (Infinity: everything is one hunk).
15
+ * @returns {{ops: DiffOp[], skippedBefore: number}[]} `skippedBefore` is the number of unchanged lines left out before the hunk
16
+ */
17
+ export function hunksOf(ops: any, context?: number): {
18
+ ops: DiffOp[];
19
+ skippedBefore: number;
20
+ }[];
21
+ export function splitLines(text: any): string[];
22
+ export type DiffOp = {
23
+ type: "equal";
24
+ a: number;
25
+ b: number;
26
+ } | {
27
+ type: "remove";
28
+ a: number;
29
+ } | {
30
+ type: "add";
31
+ b: number;
32
+ };
@@ -0,0 +1,58 @@
1
+ /** Registers a language (and its aliases). */
2
+ export function registerLanguage(language: any): void;
3
+ /**
4
+ * Splits text into tokens: [{ type, text }]. `type` is null for plain text. Concatenating the texts gives the input back.
5
+ * An unknown language, or a text that is too long, gives one plain token.
6
+ */
7
+ export function tokenize(text: any, language: any): any[];
8
+ export function getLanguage(name: any): any;
9
+ export function getLanguages(): any[];
10
+ /** The token types the default theme gives a colour to: the classes are `tok-<type>`. */
11
+ export const TOKEN_TYPES: string[];
12
+ /**
13
+ * A language: an ordered list of rules. The text is scanned once; at every position the first rule that matches wins.
14
+ */
15
+ export type CodeLanguage = {
16
+ name: string;
17
+ /**
18
+ * shown in the label of a code block (default: the name)
19
+ */
20
+ label?: string;
21
+ /**
22
+ * other names ("js" for "javascript")
23
+ */
24
+ aliases?: string[];
25
+ /**
26
+ * `type` becomes the class `tok-<type>`;
27
+ * the pattern must use non-capturing groups only; `inner` splits a match into smaller tokens (a tag into name and attributes)
28
+ */
29
+ rules: {
30
+ type: string;
31
+ pattern: RegExp;
32
+ inner?: (text: string) => {
33
+ type: string | null;
34
+ text: string;
35
+ }[];
36
+ }[];
37
+ /**
38
+ * the rules are case-insensitive (SQL)
39
+ */
40
+ ignoreCase?: boolean;
41
+ /**
42
+ * ^ and $ match at every line (YAML, C# preprocessor lines)
43
+ */
44
+ multiline?: boolean;
45
+ /**
46
+ * used by the editor to comment lines ("//")
47
+ */
48
+ lineComment?: string;
49
+ blockComment?: [string, string];
50
+ /**
51
+ * characters the editor closes: ["()", "[]", "{}", "\"\"", "''"]
52
+ */
53
+ pairs?: string[];
54
+ /**
55
+ * a line that matches this makes the next line one level deeper (/[{(\[:]\s*$/)
56
+ */
57
+ indentAfter?: RegExp;
58
+ };
@@ -0,0 +1,45 @@
1
+ /** Puts an item inside the columns and inside its size limits ({ min: {w, h}, max: {w, h} }). */
2
+ export function clampItem(item: any, columns: any, { min, max }?: {
3
+ min?: {};
4
+ max?: {};
5
+ }): any;
6
+ /**
7
+ * Gravity: every item that is not locked moves up as far as it can (locked items stay where they are).
8
+ * @returns {object[]} new items, in the order of the argument
9
+ */
10
+ export function compact(items: any): object[];
11
+ /**
12
+ * Sets the place of one item (clamped), pushes the others out of its way and, unless `compactItems` is false, lets everything fall upwards.
13
+ * @param {object[]} items
14
+ * @param {string} id
15
+ * @param {{x?: number, y?: number, w?: number, h?: number}} place the new place; missing values stay as they are
16
+ * @param {number} columns
17
+ * @param {object} [options]
18
+ * @param {{min?: object, max?: object}} [options.limits] size limits of this item
19
+ * @param {boolean} [options.compactItems=true]
20
+ * @returns {object[]|null} the new layout, or null when it is not possible (a locked item is in the way, or the item is locked)
21
+ */
22
+ export function placeItem(items: object[], id: string, place: {
23
+ x?: number;
24
+ y?: number;
25
+ w?: number;
26
+ h?: number;
27
+ }, columns: number, { limits, compactItems }?: {
28
+ limits?: {
29
+ min?: object;
30
+ max?: object;
31
+ };
32
+ compactItems?: boolean;
33
+ }): object[] | null;
34
+ /** The first free place of the size w x h (rows grow without end). */
35
+ export function findFreeSpot(items: any, w: any, h: any, columns: any): {
36
+ x: number;
37
+ y: number;
38
+ };
39
+ /**
40
+ * Makes any list of items a valid layout for `columns`: inside the columns, without overlaps, compact. Items keep their order of reading
41
+ * (top to bottom, left to right). Used for loaded layouts and for a breakpoint that has no layout of its own.
42
+ */
43
+ export function normalize(items: any, columns: any, limitsOf?: () => {}): any[];
44
+ export function collides(a: any, b: any): boolean;
45
+ export function rowsOf(items: any): any;
@@ -1,123 +1,123 @@
1
- /** Does the person want less motion? The choice made with setMotion wins over the setting of the system. */
2
- export function prefersReducedMotion(): boolean;
3
- /**
4
- * Chooses how much motion there is: "system", "reduce" (none) or "full". It is put on <html> as data-motion, which the CSS tokens read (the durations
5
- * become 0), and the functions of this module read it too.
6
- */
7
- export function setMotion(value: any): boolean;
8
- /** Called with { preference, reduced } when setMotion changes it, and when the system setting changes. Returns a function that stops it. */
9
- export function onMotionChange(listener: any): () => boolean;
10
- /** A duration token as milliseconds: readDuration("--athena-duration-base") -> 200. 0 under reduced motion. */
11
- export function readDuration(token?: string, element?: HTMLElement): number;
12
- /** How long an element takes to finish its CSS transitions, delays included, in ms (0 when it has none, or under reduced motion). */
13
- export function transitionTime(element: any): number;
14
- /** Removes an element when its exit transition is over (at once when it has none, which is also what reduced motion gives). */
15
- export function removeAfterTransition(element: any): void;
16
- /**
17
- * A spring as a CSS easing: simulates a damped spring and returns the points as a `linear()` easing (which can overshoot) and how long it takes.
18
- * `element.animate(keyframes, { duration, easing })` then moves like a spring. Settles when it stays within `precision` of 1.
19
- *
20
- * @param {{stiffness?: number, damping?: number, mass?: number, precision?: number}} [options]
21
- * @returns {{easing: string, duration: number}} duration in ms
22
- */
23
- export function spring({ stiffness, damping, mass, precision }?: {
24
- stiffness?: number;
25
- damping?: number;
26
- mass?: number;
27
- precision?: number;
28
- }): {
29
- easing: string;
30
- duration: number;
31
- };
32
- /**
33
- * Animates an element with the Web Animations API and resolves when it is over. Under reduced motion it does nothing and resolves at once.
34
- * It resolves (never rejects) when the animation is cancelled, and `null` when there was none.
35
- *
36
- * @param {Element} element
37
- * @param {Keyframe[]|PropertyIndexedKeyframes} keyframes e.g. [{ opacity: 0 }, { opacity: 1 }]
38
- * @param {object} [options] the options of element.animate (duration, easing, delay, fill, ...), and
39
- * @param {boolean} [options.commit=false] write the end state to the element's style when it is over (CSSOM: allowed by a strict policy)
40
- * @param {AbortSignal} [options.signal] cancels the animation when aborted
41
- * @returns {Promise<Animation|null>}
42
- */
43
- export function animate(element: Element, keyframes: Keyframe[] | PropertyIndexedKeyframes, options?: {
44
- commit?: boolean;
45
- signal?: AbortSignal;
46
- }): Promise<Animation | null>;
47
- /** Fades an element out and removes it. Under reduced motion it is removed at once. */
48
- export function fadeOut(element: any, options: any): Promise<void>;
49
- /**
50
- * A change that is done with CSS (a class, an attribute) and has a CSS transition: runs `change()` and resolves when the element's transition is over.
51
- * It waits at most the length of the transition (plus a little), so a transition that never ends does not hang anything.
52
- */
53
- export function transition(element: any, change: any): Promise<any>;
54
- /** Runs the functions one after the other, each when the one before is over. Resolves with their results. */
55
- export function sequence(steps: any): Promise<any[]>;
56
- /**
57
- * The delays of a staggered animation: `count` items, `step` ms apart, starting from "start", "end" or "center".
58
- * @returns {number[]}
59
- */
60
- export function staggerDelays(count: any, step?: number, from?: string): number[];
61
- /**
62
- * Calls `run(item, index, delay)` for every item with its delay, and resolves when all are over: `stagger(rows, (row, i, delay) => fadeIn(row, { delay }))`.
63
- * No more than `limit` items are staggered (the rest run with the last delay), so a long list does not take long.
64
- */
65
- export function stagger(items: any, run: any, { step, from, limit }?: {
66
- step?: number;
67
- from?: string;
68
- limit?: number;
69
- }): Promise<any[]>;
70
- /**
71
- * Lets the children of a container move smoothly when `change()` rearranges them (sorting, filtering, inserting, removing): First (measure), Last (do the change,
72
- * measure), Invert and Play (each child that moved starts at its old place and slides to the new one). New children fade in. Under reduced motion `change()` is
73
- * just done.
74
- *
75
- * @param {Element} container its children are what moves
76
- * @param {() => void} change rearranges the children (synchronously)
77
- * @param {object} [options]
78
- * @param {(element: Element) => *} [options.key] what makes a child "the same" before and after, default: the element itself
79
- * @param {number} [options.limit=60] at most this many children are animated (a long list does not need it, and costs time)
80
- * @param {number} [options.duration] ms, default the token --athena-duration-base
81
- * @returns {Promise<void>} resolves when the animations are over
82
- */
83
- export function flip(container: Element, change: () => void, { key, limit, duration }?: {
84
- key?: (element: Element) => any;
85
- limit?: number;
86
- duration?: number;
87
- }): Promise<void>;
88
- /**
89
- * Changes numbers over time with requestAnimationFrame: tween({ from: 0, to: 100, duration: 500, easing: easings.easeOutCubic, onUpdate: v => ... }).
90
- * `from` and `to` can be numbers, or objects with the same keys ({ x: 0, y: 0 } to { x: 10, y: 5 }); onUpdate then gets an object.
91
- * Under reduced motion it jumps to the end (one onUpdate call). It runs on animation frames; in a page that is not drawn a timer keeps it going slowly, so it still ends.
92
- *
93
- * @returns {Promise<void> & {cancel: () => void}} resolves when it is over (also when cancelled)
94
- */
95
- export function tween({ from, to, duration, easing, onUpdate, delay }?: {
96
- from?: number;
97
- to?: number;
98
- duration?: number;
99
- easing?: (t: any) => number;
100
- delay?: number;
101
- }): Promise<void> & {
102
- cancel: () => void;
103
- };
104
- /**
105
- * Runs `update()` (which changes the DOM) as a view transition when the browser can and motion is wanted: the old and the new state cross-fade
106
- * (or whatever the CSS ::view-transition-* rules say). Elements with a `view-transition-name` move from one place to the other. Without the API,
107
- * or under reduced motion, `update()` is just run. Resolves when it is over.
108
- */
109
- export function viewTransition(update: any): Promise<void>;
110
- export function getMotion(): "reduce" | "full" | "system";
111
- export namespace easings {
112
- function linear(t: any): any;
113
- function easeInQuad(t: any): number;
114
- function easeOutQuad(t: any): number;
115
- function easeInOutQuad(t: any): number;
116
- function easeInCubic(t: any): number;
117
- function easeOutCubic(t: any): number;
118
- function easeInOutCubic(t: any): number;
119
- function easeOutBack(t: any): number;
120
- function easeOutElastic(t: any): any;
121
- }
122
- export function fadeIn(element: any, options: any): Promise<Animation>;
123
- export function parallel(steps: any): Promise<any[]>;
1
+ /** Does the person want less motion? The choice made with setMotion wins over the setting of the system. */
2
+ export function prefersReducedMotion(): boolean;
3
+ /**
4
+ * Chooses how much motion there is: "system", "reduce" (none) or "full". It is put on <html> as data-motion, which the CSS tokens read (the durations
5
+ * become 0), and the functions of this module read it too.
6
+ */
7
+ export function setMotion(value: any): boolean;
8
+ /** Called with { preference, reduced } when setMotion changes it, and when the system setting changes. Returns a function that stops it. */
9
+ export function onMotionChange(listener: any): () => boolean;
10
+ /** A duration token as milliseconds: readDuration("--athena-duration-base") -> 200. 0 under reduced motion. */
11
+ export function readDuration(token?: string, element?: HTMLElement): number;
12
+ /** How long an element takes to finish its CSS transitions, delays included, in ms (0 when it has none, or under reduced motion). */
13
+ export function transitionTime(element: any): number;
14
+ /** Removes an element when its exit transition is over (at once when it has none, which is also what reduced motion gives). */
15
+ export function removeAfterTransition(element: any): void;
16
+ /**
17
+ * A spring as a CSS easing: simulates a damped spring and returns the points as a `linear()` easing (which can overshoot) and how long it takes.
18
+ * `element.animate(keyframes, { duration, easing })` then moves like a spring. Settles when it stays within `precision` of 1.
19
+ *
20
+ * @param {{stiffness?: number, damping?: number, mass?: number, precision?: number}} [options]
21
+ * @returns {{easing: string, duration: number}} duration in ms
22
+ */
23
+ export function spring({ stiffness, damping, mass, precision }?: {
24
+ stiffness?: number;
25
+ damping?: number;
26
+ mass?: number;
27
+ precision?: number;
28
+ }): {
29
+ easing: string;
30
+ duration: number;
31
+ };
32
+ /**
33
+ * Animates an element with the Web Animations API and resolves when it is over. Under reduced motion it does nothing and resolves at once.
34
+ * It resolves (never rejects) when the animation is cancelled, and `null` when there was none.
35
+ *
36
+ * @param {Element} element
37
+ * @param {Keyframe[]|PropertyIndexedKeyframes} keyframes e.g. [{ opacity: 0 }, { opacity: 1 }]
38
+ * @param {object} [options] the options of element.animate (duration, easing, delay, fill, ...), and
39
+ * @param {boolean} [options.commit=false] write the end state to the element's style when it is over (CSSOM: allowed by a strict policy)
40
+ * @param {AbortSignal} [options.signal] cancels the animation when aborted
41
+ * @returns {Promise<Animation|null>}
42
+ */
43
+ export function animate(element: Element, keyframes: Keyframe[] | PropertyIndexedKeyframes, options?: {
44
+ commit?: boolean;
45
+ signal?: AbortSignal;
46
+ }): Promise<Animation | null>;
47
+ /** Fades an element out and removes it. Under reduced motion it is removed at once. */
48
+ export function fadeOut(element: any, options: any): Promise<void>;
49
+ /**
50
+ * A change that is done with CSS (a class, an attribute) and has a CSS transition: runs `change()` and resolves when the element's transition is over.
51
+ * It waits at most the length of the transition (plus a little), so a transition that never ends does not hang anything.
52
+ */
53
+ export function transition(element: any, change: any): Promise<any>;
54
+ /** Runs the functions one after the other, each when the one before is over. Resolves with their results. */
55
+ export function sequence(steps: any): Promise<any[]>;
56
+ /**
57
+ * The delays of a staggered animation: `count` items, `step` ms apart, starting from "start", "end" or "center".
58
+ * @returns {number[]}
59
+ */
60
+ export function staggerDelays(count: any, step?: number, from?: string): number[];
61
+ /**
62
+ * Calls `run(item, index, delay)` for every item with its delay, and resolves when all are over: `stagger(rows, (row, i, delay) => fadeIn(row, { delay }))`.
63
+ * No more than `limit` items are staggered (the rest run with the last delay), so a long list does not take long.
64
+ */
65
+ export function stagger(items: any, run: any, { step, from, limit }?: {
66
+ step?: number;
67
+ from?: string;
68
+ limit?: number;
69
+ }): Promise<any[]>;
70
+ /**
71
+ * Lets the children of a container move smoothly when `change()` rearranges them (sorting, filtering, inserting, removing): First (measure), Last (do the change,
72
+ * measure), Invert and Play (each child that moved starts at its old place and slides to the new one). New children fade in. Under reduced motion `change()` is
73
+ * just done.
74
+ *
75
+ * @param {Element} container its children are what moves
76
+ * @param {() => void} change rearranges the children (synchronously)
77
+ * @param {object} [options]
78
+ * @param {(element: Element) => *} [options.key] what makes a child "the same" before and after, default: the element itself
79
+ * @param {number} [options.limit=60] at most this many children are animated (a long list does not need it, and costs time)
80
+ * @param {number} [options.duration] ms, default the token --athena-duration-base
81
+ * @returns {Promise<void>} resolves when the animations are over
82
+ */
83
+ export function flip(container: Element, change: () => void, { key, limit, duration }?: {
84
+ key?: (element: Element) => any;
85
+ limit?: number;
86
+ duration?: number;
87
+ }): Promise<void>;
88
+ /**
89
+ * Changes numbers over time with requestAnimationFrame: tween({ from: 0, to: 100, duration: 500, easing: easings.easeOutCubic, onUpdate: v => ... }).
90
+ * `from` and `to` can be numbers, or objects with the same keys ({ x: 0, y: 0 } to { x: 10, y: 5 }); onUpdate then gets an object.
91
+ * Under reduced motion it jumps to the end (one onUpdate call). It runs on animation frames; in a page that is not drawn a timer keeps it going slowly, so it still ends.
92
+ *
93
+ * @returns {Promise<void> & {cancel: () => void}} resolves when it is over (also when cancelled)
94
+ */
95
+ export function tween({ from, to, duration, easing, onUpdate, delay }?: {
96
+ from?: number;
97
+ to?: number;
98
+ duration?: number;
99
+ easing?: (t: any) => number;
100
+ delay?: number;
101
+ }): Promise<void> & {
102
+ cancel: () => void;
103
+ };
104
+ /**
105
+ * Runs `update()` (which changes the DOM) as a view transition when the browser can and motion is wanted: the old and the new state cross-fade
106
+ * (or whatever the CSS ::view-transition-* rules say). Elements with a `view-transition-name` move from one place to the other. Without the API,
107
+ * or under reduced motion, `update()` is just run. Resolves when it is over.
108
+ */
109
+ export function viewTransition(update: any): Promise<void>;
110
+ export function getMotion(): "reduce" | "full" | "system";
111
+ export namespace easings {
112
+ function linear(t: any): any;
113
+ function easeInQuad(t: any): number;
114
+ function easeOutQuad(t: any): number;
115
+ function easeInOutQuad(t: any): number;
116
+ function easeInCubic(t: any): number;
117
+ function easeOutCubic(t: any): number;
118
+ function easeInOutCubic(t: any): number;
119
+ function easeOutBack(t: any): number;
120
+ function easeOutElastic(t: any): any;
121
+ }
122
+ export function fadeIn(element: any, options: any): Promise<Animation>;
123
+ export function parallel(steps: any): Promise<any[]>;
@@ -1,41 +1,41 @@
1
- /**
2
- * @param {object} options
3
- * @param {{id: string, name?: string, description?: string}[]} options.themes the first one is the default
4
- * @param {{id: string, name?: string}[]} [options.modes] default: system, light, dark. Ids "light" and "dark" are the ones that can be resolved
5
- * @param {string} [options.storageKey="athena.appearance"] localStorage key (also give it to theme-boot.js)
6
- * @param {string} [options.themeColorVariable] CSS variable whose value becomes <meta name="theme-color"> (the bar of a phone browser)
7
- * @param {HTMLElement} [options.root] element that gets the attributes (default: <html>)
8
- * @param {Storage} [options.storage] default: localStorage
9
- * @param {boolean} [options.transition=true] colours cross-fade when the theme or the mode changes (not under reduced motion)
10
- * @returns {{themes, modes, appearance: () => object, setTheme: (id) => boolean, setMode: (id) => boolean,
11
- * onChange: (listener) => Function, refresh: Function, destroy: Function}}
12
- */
13
- export function createThemeManager(options?: {
14
- themes: {
15
- id: string;
16
- name?: string;
17
- description?: string;
18
- }[];
19
- modes?: {
20
- id: string;
21
- name?: string;
22
- }[];
23
- storageKey?: string;
24
- themeColorVariable?: string;
25
- root?: HTMLElement;
26
- storage?: Storage;
27
- transition?: boolean;
28
- }): {
29
- themes: any;
30
- modes: any;
31
- appearance: () => object;
32
- setTheme: (id: any) => boolean;
33
- setMode: (id: any) => boolean;
34
- onChange: (listener: any) => Function;
35
- refresh: Function;
36
- destroy: Function;
37
- };
38
- export const DEFAULT_MODES: {
39
- id: string;
40
- name: string;
41
- }[];
1
+ /**
2
+ * @param {object} options
3
+ * @param {{id: string, name?: string, description?: string}[]} options.themes the first one is the default
4
+ * @param {{id: string, name?: string}[]} [options.modes] default: system, light, dark. Ids "light" and "dark" are the ones that can be resolved
5
+ * @param {string} [options.storageKey="athena.appearance"] localStorage key (also give it to theme-boot.js)
6
+ * @param {string} [options.themeColorVariable] CSS variable whose value becomes <meta name="theme-color"> (the bar of a phone browser)
7
+ * @param {HTMLElement} [options.root] element that gets the attributes (default: <html>)
8
+ * @param {Storage} [options.storage] default: localStorage
9
+ * @param {boolean} [options.transition=true] colours cross-fade when the theme or the mode changes (not under reduced motion)
10
+ * @returns {{themes, modes, appearance: () => object, setTheme: (id) => boolean, setMode: (id) => boolean,
11
+ * onChange: (listener) => Function, refresh: Function, destroy: Function}}
12
+ */
13
+ export function createThemeManager(options?: {
14
+ themes: {
15
+ id: string;
16
+ name?: string;
17
+ description?: string;
18
+ }[];
19
+ modes?: {
20
+ id: string;
21
+ name?: string;
22
+ }[];
23
+ storageKey?: string;
24
+ themeColorVariable?: string;
25
+ root?: HTMLElement;
26
+ storage?: Storage;
27
+ transition?: boolean;
28
+ }): {
29
+ themes: any;
30
+ modes: any;
31
+ appearance: () => object;
32
+ setTheme: (id: any) => boolean;
33
+ setMode: (id: any) => boolean;
34
+ onChange: (listener: any) => Function;
35
+ refresh: Function;
36
+ destroy: Function;
37
+ };
38
+ export const DEFAULT_MODES: {
39
+ id: string;
40
+ name: string;
41
+ }[];