athena-ui-js 2.1.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/README.md +81 -3
  2. package/docs/styling.md +21 -6
  3. package/package.json +9 -1
  4. package/src/athena-ui.js +4 -1
  5. package/src/libs/config/config.js +1 -1
  6. package/src/libs/core/gridLayout.js +102 -0
  7. package/src/libs/core/i18n.js +32 -0
  8. package/src/libs/core/motion.js +358 -0
  9. package/src/libs/core/theme.js +12 -0
  10. package/src/libs/hephaestus/chartGenerator/chartGenerator.js +9 -5
  11. package/src/libs/hephaestus/componentGenerator/componentGenerator.js +17 -0
  12. package/src/libs/hephaestus/dialogGenerator/dialogGenerator.js +2 -1
  13. package/src/libs/hephaestus/feedbackGenerator/feedbackGenerator.js +3 -1
  14. package/src/libs/hephaestus/router/router.js +18 -9
  15. package/src/libs/hephaestus/tableGenerator/tableGenerator.js +25 -0
  16. package/src/motion.js +6 -0
  17. package/src/res/themes/default/style.css +413 -10
  18. package/src/res/themes/tokens.css +25 -0
  19. package/src/widgets.js +7 -0
  20. package/types/athena-ui.d.ts +99 -96
  21. package/types/libs/config/config.d.ts +3 -3
  22. package/types/libs/core/gridLayout.d.ts +45 -0
  23. package/types/libs/core/motion.d.ts +123 -0
  24. package/types/libs/core/popover.d.ts +36 -36
  25. package/types/libs/core/theme.d.ts +2 -0
  26. package/types/libs/hephaestus/chartGenerator/chartGenerator.d.ts +2 -0
  27. package/types/libs/hephaestus/componentGenerator/componentGenerator.d.ts +238 -224
  28. package/types/libs/hephaestus/navigationGenerator/navigationGenerator.d.ts +153 -153
  29. package/types/libs/hephaestus/router/router.d.ts +4 -0
  30. package/types/libs/hephaestus/tableGenerator/tableGenerator.d.ts +3 -0
  31. package/types/libs/hephaestus/widgetGrid/widgetGrid.d.ts +117 -0
  32. package/types/motion.d.ts +1 -0
  33. package/types/widgets.d.ts +2 -0
@@ -1,96 +1,99 @@
1
- /**
2
- * Loads the theme, waits for the page and generates the layout.
3
- *
4
- * @param {object} [options]
5
- * @param {{id?: number, href?: string}} [options.theme] registered theme id or custom stylesheet
6
- * @param {object} [options.config] settings overriding the defaults (and the global appConfig)
7
- * @param {Function} [options.nav] navigation callback (falls back to the global nav)
8
- * @param {Function} [options.login] login callback (falls back to the global login)
9
- * @param {Function} [options.register] registration callback (falls back to the global register)
10
- * @param {Function} [options.lostPassword] lost password callback (falls back to the global lostPassword)
11
- * @param {Function} [options.changePassword] change password callback (falls back to the global changePassword)
12
- * @param {object} [options.menuItems] { headerMenu, footerMenu } (falls back to the global menuItems)
13
- * @returns {Promise<object>} the effective configuration
14
- */
15
- export function init(options?: {
16
- theme?: {
17
- id?: number;
18
- href?: string;
19
- };
20
- config?: object;
21
- nav?: Function;
22
- login?: Function;
23
- register?: Function;
24
- lostPassword?: Function;
25
- changePassword?: Function;
26
- menuItems?: object;
27
- }): Promise<object>;
28
- /**
29
- * Starts Athena UI inside an element of your page instead of the body, so it can be one part of a larger page (or of several apps).
30
- * It does what init() does (settings, language, theme, hooks), and the layout (container, header, wrapper, footer) is generated into
31
- * `root`. The parts follow the settings: `config: { generateHeader: false, generateFooter: false }` leaves only the wrapper, which is where
32
- * the components go by default (the element with the id "wrapper"). One app per page: the parts have fixed ids.
33
- *
34
- * @param {object} options the options of init(), and
35
- * @param {string|Element} options.root the element to build into (an element, an id or a selector)
36
- * @returns {Promise<{element: HTMLElement, container: HTMLElement, header: HTMLElement|null, wrapper: HTMLElement|null, footer: HTMLElement|null,
37
- * config: object, update: Function, destroy: Function}>}
38
- */
39
- export function createApp(options?: {
40
- root: string | Element;
41
- }): Promise<{
42
- element: HTMLElement;
43
- container: HTMLElement;
44
- header: HTMLElement | null;
45
- wrapper: HTMLElement | null;
46
- footer: HTMLElement | null;
47
- config: object;
48
- update: Function;
49
- destroy: Function;
50
- }>;
51
- /**
52
- * Switches the theme at runtime: { id } of a registered theme or { href } of a stylesheet.
53
- * @returns {Promise<object>} the applied theme
54
- */
55
- export function setTheme(selected: any): Promise<object>;
56
- export { default as Cookies } from "./libs/core/cookies.js";
57
- export * from "./libs/core/elementGenerator.js";
58
- export * from "./libs/core/controls.js";
59
- export * from "./libs/core/hungarianControls.js";
60
- export * from "./libs/hephaestus/LayoutGenerator/basicLayoutGenerator.js";
61
- export * from "./libs/hephaestus/LayoutGenerator/headerContentGenerator.js";
62
- export * from "./libs/hephaestus/LayoutGenerator/wrapperContentGenerator.js";
63
- export * from "./libs/hephaestus/LayoutGenerator/footerContentGenerator.js";
64
- export * from "./libs/hephaestus/MenuGenerator/basicMenuGenerator.js";
65
- export * from "./libs/hephaestus/MenuGenerator/menuGenerator.js";
66
- export * from "./libs/hephaestus/formGenerator/loginFormGenerator.js";
67
- export * from "./libs/hephaestus/formGenerator/registrationFormGenerator.js";
68
- export * from "./libs/hephaestus/formGenerator/lostPasswordFormGenerator.js";
69
- export * from "./libs/hephaestus/chartGenerator/chartGenerator.js";
70
- export * from "./libs/hephaestus/tableGenerator/tableGenerator.js";
71
- export * from "./libs/hephaestus/formGenerator/changePasswordFormGenerator.js";
72
- export * from "./libs/hephaestus/formGenerator/formBuilder.js";
73
- export * from "./libs/hephaestus/formGenerator/authForms.js";
74
- export * from "./libs/hephaestus/feedbackGenerator/feedbackGenerator.js";
75
- export * from "./libs/hephaestus/dialogGenerator/dialogGenerator.js";
76
- export * from "./libs/hephaestus/navigationGenerator/navigationGenerator.js";
77
- export * from "./libs/hephaestus/componentGenerator/componentGenerator.js";
78
- export * from "./libs/hephaestus/inputGenerator/inputGenerator.js";
79
- export * from "./libs/hephaestus/inputGenerator/dropZoneGenerator.js";
80
- export * from "./libs/hephaestus/inputGenerator/richTextGenerator.js";
81
- export * from "./libs/core/sanitize.js";
82
- export * from "./libs/hephaestus/router/router.js";
83
- export * from "./libs/hephaestus/auth/session.js";
84
- export * from "./libs/hephaestus/auth/authState.js";
85
- export * from "./libs/core/i18n.js";
86
- export * from "./libs/core/validation.js";
87
- export * from "./libs/core/csv.js";
88
- export * from "./libs/core/dateRange.js";
89
- export * from "./libs/core/format.js";
90
- export * from "./libs/hephaestus/modalGenerator/modalGenerator.js";
91
- export * from "./libs/core/theme.js";
92
- export * from "./libs/hephaestus/componentGenerator/themePicker.js";
93
- import config from "./libs/config/config.js";
94
- import { loadScript } from "./libs/hephaestus/hephaestus.js";
95
- export { config, loadScript };
96
- export { el, setContent, resolveElement, asHandle, createSafeBuilder } from "./libs/core/dom.js";
1
+ /**
2
+ * Loads the theme, waits for the page and generates the layout.
3
+ *
4
+ * @param {object} [options]
5
+ * @param {{id?: number, href?: string}} [options.theme] registered theme id or custom stylesheet
6
+ * @param {object} [options.config] settings overriding the defaults (and the global appConfig)
7
+ * @param {Function} [options.nav] navigation callback (falls back to the global nav)
8
+ * @param {Function} [options.login] login callback (falls back to the global login)
9
+ * @param {Function} [options.register] registration callback (falls back to the global register)
10
+ * @param {Function} [options.lostPassword] lost password callback (falls back to the global lostPassword)
11
+ * @param {Function} [options.changePassword] change password callback (falls back to the global changePassword)
12
+ * @param {object} [options.menuItems] { headerMenu, footerMenu } (falls back to the global menuItems)
13
+ * @returns {Promise<object>} the effective configuration
14
+ */
15
+ export function init(options?: {
16
+ theme?: {
17
+ id?: number;
18
+ href?: string;
19
+ };
20
+ config?: object;
21
+ nav?: Function;
22
+ login?: Function;
23
+ register?: Function;
24
+ lostPassword?: Function;
25
+ changePassword?: Function;
26
+ menuItems?: object;
27
+ }): Promise<object>;
28
+ /**
29
+ * Starts Athena UI inside an element of your page instead of the body, so it can be one part of a larger page (or of several apps).
30
+ * It does what init() does (settings, language, theme, hooks), and the layout (container, header, wrapper, footer) is generated into
31
+ * `root`. The parts follow the settings: `config: { generateHeader: false, generateFooter: false }` leaves only the wrapper, which is where
32
+ * the components go by default (the element with the id "wrapper"). One app per page: the parts have fixed ids.
33
+ *
34
+ * @param {object} options the options of init(), and
35
+ * @param {string|Element} options.root the element to build into (an element, an id or a selector)
36
+ * @returns {Promise<{element: HTMLElement, container: HTMLElement, header: HTMLElement|null, wrapper: HTMLElement|null, footer: HTMLElement|null,
37
+ * config: object, update: Function, destroy: Function}>}
38
+ */
39
+ export function createApp(options?: {
40
+ root: string | Element;
41
+ }): Promise<{
42
+ element: HTMLElement;
43
+ container: HTMLElement;
44
+ header: HTMLElement | null;
45
+ wrapper: HTMLElement | null;
46
+ footer: HTMLElement | null;
47
+ config: object;
48
+ update: Function;
49
+ destroy: Function;
50
+ }>;
51
+ /**
52
+ * Switches the theme at runtime: { id } of a registered theme or { href } of a stylesheet.
53
+ * @returns {Promise<object>} the applied theme
54
+ */
55
+ export function setTheme(selected: any): Promise<object>;
56
+ export { default as Cookies } from "./libs/core/cookies.js";
57
+ export * from "./libs/core/elementGenerator.js";
58
+ export * from "./libs/core/controls.js";
59
+ export * from "./libs/core/hungarianControls.js";
60
+ export * from "./libs/hephaestus/LayoutGenerator/basicLayoutGenerator.js";
61
+ export * from "./libs/hephaestus/LayoutGenerator/headerContentGenerator.js";
62
+ export * from "./libs/hephaestus/LayoutGenerator/wrapperContentGenerator.js";
63
+ export * from "./libs/hephaestus/LayoutGenerator/footerContentGenerator.js";
64
+ export * from "./libs/hephaestus/MenuGenerator/basicMenuGenerator.js";
65
+ export * from "./libs/hephaestus/MenuGenerator/menuGenerator.js";
66
+ export * from "./libs/hephaestus/formGenerator/loginFormGenerator.js";
67
+ export * from "./libs/hephaestus/formGenerator/registrationFormGenerator.js";
68
+ export * from "./libs/hephaestus/formGenerator/lostPasswordFormGenerator.js";
69
+ export * from "./libs/hephaestus/chartGenerator/chartGenerator.js";
70
+ export * from "./libs/hephaestus/tableGenerator/tableGenerator.js";
71
+ export * from "./libs/hephaestus/formGenerator/changePasswordFormGenerator.js";
72
+ export * from "./libs/hephaestus/formGenerator/formBuilder.js";
73
+ export * from "./libs/hephaestus/formGenerator/authForms.js";
74
+ export * from "./libs/hephaestus/feedbackGenerator/feedbackGenerator.js";
75
+ export * from "./libs/hephaestus/dialogGenerator/dialogGenerator.js";
76
+ export * from "./libs/hephaestus/navigationGenerator/navigationGenerator.js";
77
+ export * from "./libs/hephaestus/componentGenerator/componentGenerator.js";
78
+ export * from "./libs/hephaestus/inputGenerator/inputGenerator.js";
79
+ export * from "./libs/hephaestus/inputGenerator/dropZoneGenerator.js";
80
+ export * from "./libs/hephaestus/inputGenerator/richTextGenerator.js";
81
+ export * from "./libs/core/sanitize.js";
82
+ export * from "./libs/hephaestus/router/router.js";
83
+ export * from "./libs/hephaestus/auth/session.js";
84
+ export * from "./libs/hephaestus/auth/authState.js";
85
+ export * from "./libs/core/i18n.js";
86
+ export * from "./libs/core/validation.js";
87
+ export * from "./libs/core/csv.js";
88
+ export * from "./libs/core/dateRange.js";
89
+ export * from "./libs/core/format.js";
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/modalGenerator/modalGenerator.js";
94
+ export * from "./libs/core/theme.js";
95
+ export * from "./libs/hephaestus/componentGenerator/themePicker.js";
96
+ import config from "./libs/config/config.js";
97
+ import { loadScript } from "./libs/hephaestus/hephaestus.js";
98
+ export { config, loadScript };
99
+ export { el, setContent, resolveElement, asHandle, createSafeBuilder } from "./libs/core/dom.js";
@@ -1,5 +1,5 @@
1
1
  export function applyConfig(...sources: any[]): {
2
- version: "2.1.0";
2
+ version: "2.3.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.1.0";
35
+ version: "2.3.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.1.0";
67
+ let version: "2.3.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,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;
@@ -0,0 +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,36 +1,36 @@
1
- /** Opens it: showPopover(), or without the API: the element is no longer hidden. Does nothing when it is open already. */
2
- export function openPopover(element: any): void;
3
- /** Closes it. Does nothing when it is closed already. */
4
- export function closePopover(element: any): void;
5
- /**
6
- * Where a popover goes, next to the element it belongs to, before it is shown (so there is no frame at the wrong place). Only the side and the alignment
7
- * are chosen here, from the position of the anchor in the window: the popover is moved with CSS (translate) by its own size. Once it is shown,
8
- * `settlePopover` measures it and keeps it inside the window.
9
- *
10
- * @param {Element} anchor the button or the target of the tooltip
11
- * @param {HTMLElement} popover
12
- * @param {object} [options]
13
- * @param {"bottom"|"top"|"auto"} [options.side="auto"] "bottom": below. "top": above, unless there is less than `room` px above. "auto": below,
14
- * unless there is less than `room` px below and more room above
15
- * @param {"start"|"end"|"center"} [options.align="start"] which edge of the anchor the popover lines up with
16
- * @param {number} [options.gap=4] px between the anchor and the popover
17
- * @param {number} [options.room=240] how much room a side needs, in px (a tooltip needs about 40)
18
- */
19
- export function placePopover(anchor: Element, popover: HTMLElement, { side, align, gap, room }?: {
20
- side?: "bottom" | "top" | "auto";
21
- align?: "start" | "end" | "center";
22
- gap?: number;
23
- room?: number;
24
- }): void;
25
- /**
26
- * After the popover is shown: measures it and moves it back inside the window when it sticks out to the left, the right or the bottom (a popover that
27
- * is taller than the room is left where it is: it scrolls).
28
- */
29
- export function settlePopover(popover: any): void;
30
- /**
31
- * Keeps an open popover next to its anchor while the page scrolls or the window changes size. Returns a function that stops it.
32
- * (A popover in the top layer does not move with its anchor by itself.)
33
- */
34
- export function followAnchor(anchor: any, popover: any, options: any): () => void;
35
- export function supportsPopover(): boolean;
36
- export function isOpen(element: any): any;
1
+ /** Opens it: showPopover(), or without the API: the element is no longer hidden. Does nothing when it is open already. */
2
+ export function openPopover(element: any): void;
3
+ /** Closes it. Does nothing when it is closed already. */
4
+ export function closePopover(element: any): void;
5
+ /**
6
+ * Where a popover goes, next to the element it belongs to, before it is shown (so there is no frame at the wrong place). Only the side and the alignment
7
+ * are chosen here, from the position of the anchor in the window: the popover is moved with CSS (translate) by its own size. Once it is shown,
8
+ * `settlePopover` measures it and keeps it inside the window.
9
+ *
10
+ * @param {Element} anchor the button or the target of the tooltip
11
+ * @param {HTMLElement} popover
12
+ * @param {object} [options]
13
+ * @param {"bottom"|"top"|"auto"} [options.side="auto"] "bottom": below. "top": above, unless there is less than `room` px above. "auto": below,
14
+ * unless there is less than `room` px below and more room above
15
+ * @param {"start"|"end"|"center"} [options.align="start"] which edge of the anchor the popover lines up with
16
+ * @param {number} [options.gap=4] px between the anchor and the popover
17
+ * @param {number} [options.room=240] how much room a side needs, in px (a tooltip needs about 40)
18
+ */
19
+ export function placePopover(anchor: Element, popover: HTMLElement, { side, align, gap, room }?: {
20
+ side?: "bottom" | "top" | "auto";
21
+ align?: "start" | "end" | "center";
22
+ gap?: number;
23
+ room?: number;
24
+ }): void;
25
+ /**
26
+ * After the popover is shown: measures it and moves it back inside the window when it sticks out to the left, the right or the bottom (a popover that
27
+ * is taller than the room is left where it is: it scrolls).
28
+ */
29
+ export function settlePopover(popover: any): void;
30
+ /**
31
+ * Keeps an open popover next to its anchor while the page scrolls or the window changes size. Returns a function that stops it.
32
+ * (A popover in the top layer does not move with its anchor by itself.)
33
+ */
34
+ export function followAnchor(anchor: any, popover: any, options: any): () => void;
35
+ export function supportsPopover(): boolean;
36
+ export function isOpen(element: any): any;
@@ -6,6 +6,7 @@
6
6
  * @param {string} [options.themeColorVariable] CSS variable whose value becomes <meta name="theme-color"> (the bar of a phone browser)
7
7
  * @param {HTMLElement} [options.root] element that gets the attributes (default: <html>)
8
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)
9
10
  * @returns {{themes, modes, appearance: () => object, setTheme: (id) => boolean, setMode: (id) => boolean,
10
11
  * onChange: (listener) => Function, refresh: Function, destroy: Function}}
11
12
  */
@@ -23,6 +24,7 @@ export function createThemeManager(options?: {
23
24
  themeColorVariable?: string;
24
25
  root?: HTMLElement;
25
26
  storage?: Storage;
27
+ transition?: boolean;
26
28
  }): {
27
29
  themes: any;
28
30
  modes: any;
@@ -33,6 +33,7 @@ export function decimate(indices: any, values: any, buckets: any): any;
33
33
  * @param {(range: ({from: number, to: number}|null)) => void} [options.onZoom] called when a person zooms or resets
34
34
  * @param {number} [options.maxPoints] `push` keeps at most this many points per series (the oldest are dropped)
35
35
  * @param {number[]} [options.hiddenSeries] the series (or slices) that are hidden at the start; a person hides and shows them with the legend, and a redraw keeps that
36
+ * @param {boolean} [options.animate=true] the first drawing animates: bars grow, a line is drawn, slices pop in (not when it is redrawn, and not under reduced motion)
36
37
  * @param {boolean} [options.interactive=true] line and area charts: false leaves out the pointer layer (tooltip that follows the pointer, zoom)
37
38
  * @returns {(SVGElement & {element: SVGElement, update: (options?: object) => SVGElement, destroy: () => void,
38
39
  * zoom: (from: number, to: number) => void, resetZoom: () => void, getZoom: () => ({from: number, to: number}|null),
@@ -71,6 +72,7 @@ export function generateChart(options?: {
71
72
  } | null)) => void;
72
73
  maxPoints?: number;
73
74
  hiddenSeries?: number[];
75
+ animate?: boolean;
74
76
  interactive?: boolean;
75
77
  }): (SVGElement & {
76
78
  element: SVGElement;