athena-ui-js 2.2.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.
- package/README.md +45 -3
- package/docs/styling.md +1 -1
- package/package.json +5 -1
- package/src/athena-ui.js +3 -1
- package/src/libs/config/config.js +1 -1
- package/src/libs/core/gridLayout.js +102 -0
- package/src/libs/core/i18n.js +32 -0
- package/src/res/themes/default/style.css +185 -0
- package/src/widgets.js +7 -0
- package/types/athena-ui.d.ts +2 -0
- package/types/libs/config/config.d.ts +3 -3
- package/types/libs/core/gridLayout.d.ts +45 -0
- package/types/libs/core/motion.d.ts +123 -123
- package/types/libs/core/theme.d.ts +41 -41
- package/types/libs/hephaestus/chartGenerator/chartGenerator.d.ts +95 -95
- package/types/libs/hephaestus/componentGenerator/componentGenerator.d.ts +238 -238
- package/types/libs/hephaestus/router/router.d.ts +71 -71
- package/types/libs/hephaestus/tableGenerator/tableGenerator.d.ts +123 -123
- package/types/libs/hephaestus/widgetGrid/widgetGrid.d.ts +117 -0
- package/types/motion.d.ts +1 -1
- package/types/widgets.d.ts +2 -0
|
@@ -1,238 +1,238 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generates a link. External links open in a new tab and get `rel="noopener noreferrer"`.
|
|
3
|
-
* With `onclick` and no `href` it behaves as an in-page action.
|
|
4
|
-
*
|
|
5
|
-
* @param {object} options
|
|
6
|
-
* @param {string|Element} [options.parent]
|
|
7
|
-
* @param {string} options.text
|
|
8
|
-
* @param {string} [options.href]
|
|
9
|
-
* @param {boolean} [options.external]
|
|
10
|
-
* @param {(event: Event) => void} [options.onclick]
|
|
11
|
-
* @returns {HTMLAnchorElement}
|
|
12
|
-
*/
|
|
13
|
-
export function generateLink(options?: {
|
|
14
|
-
parent?: string | Element;
|
|
15
|
-
text: string;
|
|
16
|
-
href?: string;
|
|
17
|
-
external?: boolean;
|
|
18
|
-
onclick?: (event: Event) => void;
|
|
19
|
-
}): HTMLAnchorElement;
|
|
20
|
-
/**
|
|
21
|
-
* Generates a section with an optional heading. Returns the section, fill it through `content`
|
|
22
|
-
* or append to it.
|
|
23
|
-
*
|
|
24
|
-
* @param {object} options
|
|
25
|
-
* @param {string|Element} [options.parent]
|
|
26
|
-
* @param {string} [options.title]
|
|
27
|
-
* @param {number} [options.level=2] heading level 1..6
|
|
28
|
-
* @param {string|Node|Array|Function} [options.content]
|
|
29
|
-
* @returns {HTMLElement}
|
|
30
|
-
*/
|
|
31
|
-
export function generateSection(options?: {
|
|
32
|
-
parent?: string | Element;
|
|
33
|
-
title?: string;
|
|
34
|
-
level?: number;
|
|
35
|
-
content?: string | Node | any[] | Function;
|
|
36
|
-
}): HTMLElement;
|
|
37
|
-
/**
|
|
38
|
-
* Generates a card.
|
|
39
|
-
*
|
|
40
|
-
* @param {object} options
|
|
41
|
-
* @param {string|Element} [options.parent]
|
|
42
|
-
* @param {string} [options.title]
|
|
43
|
-
* @param {string} [options.image] image URL shown on top
|
|
44
|
-
* @param {string} [options.imageAlt]
|
|
45
|
-
* @param {string|Node|Array|Function} [options.content]
|
|
46
|
-
* @param {string|Node|Array|Function} [options.footer]
|
|
47
|
-
* @returns {{element: HTMLElement, body: HTMLElement}} append to `body` to add more content
|
|
48
|
-
*/
|
|
49
|
-
export function generateCard(options?: {
|
|
50
|
-
parent?: string | Element;
|
|
51
|
-
title?: string;
|
|
52
|
-
image?: string;
|
|
53
|
-
imageAlt?: string;
|
|
54
|
-
content?: string | Node | any[] | Function;
|
|
55
|
-
footer?: string | Node | any[] | Function;
|
|
56
|
-
}): {
|
|
57
|
-
element: HTMLElement;
|
|
58
|
-
body: HTMLElement;
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* Generates a small label.
|
|
62
|
-
*
|
|
63
|
-
* @param {object} options
|
|
64
|
-
* @param {string|Element} [options.parent]
|
|
65
|
-
* @param {string} options.text
|
|
66
|
-
* @param {"neutral"|"info"|"success"|"warning"|"error"} [options.variant="neutral"]
|
|
67
|
-
* @param {boolean} [options.pill]
|
|
68
|
-
* @returns {HTMLElement}
|
|
69
|
-
*/
|
|
70
|
-
export function generateBadge(options?: {
|
|
71
|
-
parent?: string | Element;
|
|
72
|
-
text: string;
|
|
73
|
-
variant?: "neutral" | "info" | "success" | "warning" | "error";
|
|
74
|
-
pill?: boolean;
|
|
75
|
-
}): HTMLElement;
|
|
76
|
-
export function initialsOf(name?: string): string;
|
|
77
|
-
/**
|
|
78
|
-
* Generates an avatar: the image, or the initials of the name when there is no (working) image.
|
|
79
|
-
*
|
|
80
|
-
* @param {object} options
|
|
81
|
-
* @param {string|Element} [options.parent]
|
|
82
|
-
* @param {string} [options.name]
|
|
83
|
-
* @param {string} [options.src]
|
|
84
|
-
* @param {"small"|"large"} [options.size]
|
|
85
|
-
* @returns {HTMLElement}
|
|
86
|
-
*/
|
|
87
|
-
export function generateAvatar(options?: {
|
|
88
|
-
parent?: string | Element;
|
|
89
|
-
name?: string;
|
|
90
|
-
src?: string;
|
|
91
|
-
size?: "small" | "large";
|
|
92
|
-
}): HTMLElement;
|
|
93
|
-
/**
|
|
94
|
-
* Generates a KPI tile: a label, a big value and an optional change.
|
|
95
|
-
*
|
|
96
|
-
* @param {object} options
|
|
97
|
-
* @param {string|Element} [options.parent]
|
|
98
|
-
* @param {string} options.label
|
|
99
|
-
* @param {string|number} options.value
|
|
100
|
-
* @param {number} [options.delta] change in percent, shown with an arrow
|
|
101
|
-
* @param {boolean} [options.invertDelta] a falling value is good news (costs, errors)
|
|
102
|
-
* @param {"ok"|"warn"|"bad"} [options.tone] colours the tile (the class is-ok / is-warn / is-bad) and adds the word to the screen reader text
|
|
103
|
-
* @param {string} [options.note] small text under the value ("of 120 hosts", "updated 2 min ago")
|
|
104
|
-
* @returns {{element: HTMLElement, setValue: Function, setNote: Function, setTone: Function}}
|
|
105
|
-
*/
|
|
106
|
-
export function generateStat(options?: {
|
|
107
|
-
parent?: string | Element;
|
|
108
|
-
label: string;
|
|
109
|
-
value: string | number;
|
|
110
|
-
delta?: number;
|
|
111
|
-
invertDelta?: boolean;
|
|
112
|
-
tone?: "ok" | "warn" | "bad";
|
|
113
|
-
note?: string;
|
|
114
|
-
}): {
|
|
115
|
-
element: HTMLElement;
|
|
116
|
-
setValue: Function;
|
|
117
|
-
setNote: Function;
|
|
118
|
-
setTone: Function;
|
|
119
|
-
};
|
|
120
|
-
/**
|
|
121
|
-
* Generates a responsive grid. The columns collapse to one on small screens.
|
|
122
|
-
*
|
|
123
|
-
* @param {object} options
|
|
124
|
-
* @param {string|Element} [options.parent]
|
|
125
|
-
* @param {number} [options.columns=3]
|
|
126
|
-
* @param {string} [options.gap] any CSS length
|
|
127
|
-
* @returns {HTMLElement} append the cells to it
|
|
128
|
-
*/
|
|
129
|
-
export function generateGrid(options?: {
|
|
130
|
-
parent?: string | Element;
|
|
131
|
-
columns?: number;
|
|
132
|
-
gap?: string;
|
|
133
|
-
}): HTMLElement;
|
|
134
|
-
/**
|
|
135
|
-
* Adds a tooltip to an element. It shows on hover and on keyboard focus, and Esc hides it.
|
|
136
|
-
* It is a native popover (`popover="manual"`), so it is drawn above everything and never cut off by a parent with `overflow: hidden`. A touch
|
|
137
|
-
* does not show it (a tap would hide the thing it describes). Browsers without the popover API show it with CSS, as before.
|
|
138
|
-
*
|
|
139
|
-
* @param {Element|string} target element or id
|
|
140
|
-
* @param {string} text
|
|
141
|
-
*/
|
|
142
|
-
export function generateTooltip(target: Element | string, text: string): HTMLElement;
|
|
143
|
-
/**
|
|
144
|
-
* The top of a page: breadcrumbs, the title (a heading), a description and the actions of the page.
|
|
145
|
-
*
|
|
146
|
-
* @param {object} options
|
|
147
|
-
* @param {string|Element} [options.parent]
|
|
148
|
-
* @param {string} options.title
|
|
149
|
-
* @param {string} [options.description]
|
|
150
|
-
* @param {{label: string, href?: string, onclick?: Function}[]} [options.breadcrumbs] see generateBreadcrumbs
|
|
151
|
-
* @param {(Node|string)[]|Node} [options.actions] buttons, shown at the end of the header
|
|
152
|
-
* @param {1|2|3} [options.level=1] heading level
|
|
153
|
-
* @returns {{element: HTMLElement, setTitle: Function, setDescription: Function, actions: HTMLElement}}
|
|
154
|
-
*/
|
|
155
|
-
export function generatePageHeader(options?: {
|
|
156
|
-
parent?: string | Element;
|
|
157
|
-
title: string;
|
|
158
|
-
description?: string;
|
|
159
|
-
breadcrumbs?: {
|
|
160
|
-
label: string;
|
|
161
|
-
href?: string;
|
|
162
|
-
onclick?: Function;
|
|
163
|
-
}[];
|
|
164
|
-
actions?: (Node | string)[] | Node;
|
|
165
|
-
level?: 1 | 2 | 3;
|
|
166
|
-
}): {
|
|
167
|
-
element: HTMLElement;
|
|
168
|
-
setTitle: Function;
|
|
169
|
-
setDescription: Function;
|
|
170
|
-
actions: HTMLElement;
|
|
171
|
-
};
|
|
172
|
-
/**
|
|
173
|
-
* A list of facts: a term and its description, in pairs (a <dl>).
|
|
174
|
-
*
|
|
175
|
-
* @param {object} options
|
|
176
|
-
* @param {string|Element} [options.parent]
|
|
177
|
-
* @param {{term: string, description: (string|number|Node|Array), title?: string}[]} options.items text is inserted as text
|
|
178
|
-
* @param {boolean} [options.inline=false] terms and descriptions side by side
|
|
179
|
-
* @returns {{element: HTMLElement, setItems: Function}}
|
|
180
|
-
*/
|
|
181
|
-
export function generateFacts(options?: {
|
|
182
|
-
parent?: string | Element;
|
|
183
|
-
items: {
|
|
184
|
-
term: string;
|
|
185
|
-
description: (string | number | Node | any[]);
|
|
186
|
-
title?: string;
|
|
187
|
-
}[];
|
|
188
|
-
inline?: boolean;
|
|
189
|
-
}): {
|
|
190
|
-
element: HTMLElement;
|
|
191
|
-
setItems: Function;
|
|
192
|
-
};
|
|
193
|
-
/**
|
|
194
|
-
* What a list shows when there is nothing in it: a title, a short explanation and what to do about it.
|
|
195
|
-
*
|
|
196
|
-
* @param {object} options
|
|
197
|
-
* @param {string|Element} [options.parent]
|
|
198
|
-
* @param {string} options.title
|
|
199
|
-
* @param {string} [options.message]
|
|
200
|
-
* @param {string|Node} [options.icon] decorative
|
|
201
|
-
* @param {{text: string, onclick: Function, variant?: string}} [options.action] a button
|
|
202
|
-
*/
|
|
203
|
-
export function generateEmptyState(options?: {
|
|
204
|
-
parent?: string | Element;
|
|
205
|
-
title: string;
|
|
206
|
-
message?: string;
|
|
207
|
-
icon?: string | Node;
|
|
208
|
-
action?: {
|
|
209
|
-
text: string;
|
|
210
|
-
onclick: Function;
|
|
211
|
-
variant?: string;
|
|
212
|
-
};
|
|
213
|
-
}): any;
|
|
214
|
-
/**
|
|
215
|
-
* A skeleton: grey lines with a shimmer where text or a card will be, so the page does not jump when it arrives. It is a live region that says
|
|
216
|
-
* "Loading..." to a screen reader; the shimmer stops under reduced motion.
|
|
217
|
-
*
|
|
218
|
-
* @param {object} [options]
|
|
219
|
-
* @param {string|Element} [options.parent]
|
|
220
|
-
* @param {number} [options.lines=3] the last of several lines is shorter
|
|
221
|
-
* @param {string} [options.class] e.g. "skeleton-card" in your own CSS gives the box a height
|
|
222
|
-
*/
|
|
223
|
-
export function generateSkeleton(options?: {
|
|
224
|
-
parent?: string | Element;
|
|
225
|
-
lines?: number;
|
|
226
|
-
class?: string;
|
|
227
|
-
}): any;
|
|
228
|
-
/**
|
|
229
|
-
* A placeholder while something loads: a spinner and a text (a live region, so a screen reader says it).
|
|
230
|
-
*
|
|
231
|
-
* @param {object} [options]
|
|
232
|
-
* @param {string|Element} [options.parent]
|
|
233
|
-
* @param {string} [options.text] default: the translated "Loading..."
|
|
234
|
-
*/
|
|
235
|
-
export function generateLoading(options?: {
|
|
236
|
-
parent?: string | Element;
|
|
237
|
-
text?: string;
|
|
238
|
-
}): any;
|
|
1
|
+
/**
|
|
2
|
+
* Generates a link. External links open in a new tab and get `rel="noopener noreferrer"`.
|
|
3
|
+
* With `onclick` and no `href` it behaves as an in-page action.
|
|
4
|
+
*
|
|
5
|
+
* @param {object} options
|
|
6
|
+
* @param {string|Element} [options.parent]
|
|
7
|
+
* @param {string} options.text
|
|
8
|
+
* @param {string} [options.href]
|
|
9
|
+
* @param {boolean} [options.external]
|
|
10
|
+
* @param {(event: Event) => void} [options.onclick]
|
|
11
|
+
* @returns {HTMLAnchorElement}
|
|
12
|
+
*/
|
|
13
|
+
export function generateLink(options?: {
|
|
14
|
+
parent?: string | Element;
|
|
15
|
+
text: string;
|
|
16
|
+
href?: string;
|
|
17
|
+
external?: boolean;
|
|
18
|
+
onclick?: (event: Event) => void;
|
|
19
|
+
}): HTMLAnchorElement;
|
|
20
|
+
/**
|
|
21
|
+
* Generates a section with an optional heading. Returns the section, fill it through `content`
|
|
22
|
+
* or append to it.
|
|
23
|
+
*
|
|
24
|
+
* @param {object} options
|
|
25
|
+
* @param {string|Element} [options.parent]
|
|
26
|
+
* @param {string} [options.title]
|
|
27
|
+
* @param {number} [options.level=2] heading level 1..6
|
|
28
|
+
* @param {string|Node|Array|Function} [options.content]
|
|
29
|
+
* @returns {HTMLElement}
|
|
30
|
+
*/
|
|
31
|
+
export function generateSection(options?: {
|
|
32
|
+
parent?: string | Element;
|
|
33
|
+
title?: string;
|
|
34
|
+
level?: number;
|
|
35
|
+
content?: string | Node | any[] | Function;
|
|
36
|
+
}): HTMLElement;
|
|
37
|
+
/**
|
|
38
|
+
* Generates a card.
|
|
39
|
+
*
|
|
40
|
+
* @param {object} options
|
|
41
|
+
* @param {string|Element} [options.parent]
|
|
42
|
+
* @param {string} [options.title]
|
|
43
|
+
* @param {string} [options.image] image URL shown on top
|
|
44
|
+
* @param {string} [options.imageAlt]
|
|
45
|
+
* @param {string|Node|Array|Function} [options.content]
|
|
46
|
+
* @param {string|Node|Array|Function} [options.footer]
|
|
47
|
+
* @returns {{element: HTMLElement, body: HTMLElement}} append to `body` to add more content
|
|
48
|
+
*/
|
|
49
|
+
export function generateCard(options?: {
|
|
50
|
+
parent?: string | Element;
|
|
51
|
+
title?: string;
|
|
52
|
+
image?: string;
|
|
53
|
+
imageAlt?: string;
|
|
54
|
+
content?: string | Node | any[] | Function;
|
|
55
|
+
footer?: string | Node | any[] | Function;
|
|
56
|
+
}): {
|
|
57
|
+
element: HTMLElement;
|
|
58
|
+
body: HTMLElement;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Generates a small label.
|
|
62
|
+
*
|
|
63
|
+
* @param {object} options
|
|
64
|
+
* @param {string|Element} [options.parent]
|
|
65
|
+
* @param {string} options.text
|
|
66
|
+
* @param {"neutral"|"info"|"success"|"warning"|"error"} [options.variant="neutral"]
|
|
67
|
+
* @param {boolean} [options.pill]
|
|
68
|
+
* @returns {HTMLElement}
|
|
69
|
+
*/
|
|
70
|
+
export function generateBadge(options?: {
|
|
71
|
+
parent?: string | Element;
|
|
72
|
+
text: string;
|
|
73
|
+
variant?: "neutral" | "info" | "success" | "warning" | "error";
|
|
74
|
+
pill?: boolean;
|
|
75
|
+
}): HTMLElement;
|
|
76
|
+
export function initialsOf(name?: string): string;
|
|
77
|
+
/**
|
|
78
|
+
* Generates an avatar: the image, or the initials of the name when there is no (working) image.
|
|
79
|
+
*
|
|
80
|
+
* @param {object} options
|
|
81
|
+
* @param {string|Element} [options.parent]
|
|
82
|
+
* @param {string} [options.name]
|
|
83
|
+
* @param {string} [options.src]
|
|
84
|
+
* @param {"small"|"large"} [options.size]
|
|
85
|
+
* @returns {HTMLElement}
|
|
86
|
+
*/
|
|
87
|
+
export function generateAvatar(options?: {
|
|
88
|
+
parent?: string | Element;
|
|
89
|
+
name?: string;
|
|
90
|
+
src?: string;
|
|
91
|
+
size?: "small" | "large";
|
|
92
|
+
}): HTMLElement;
|
|
93
|
+
/**
|
|
94
|
+
* Generates a KPI tile: a label, a big value and an optional change.
|
|
95
|
+
*
|
|
96
|
+
* @param {object} options
|
|
97
|
+
* @param {string|Element} [options.parent]
|
|
98
|
+
* @param {string} options.label
|
|
99
|
+
* @param {string|number} options.value
|
|
100
|
+
* @param {number} [options.delta] change in percent, shown with an arrow
|
|
101
|
+
* @param {boolean} [options.invertDelta] a falling value is good news (costs, errors)
|
|
102
|
+
* @param {"ok"|"warn"|"bad"} [options.tone] colours the tile (the class is-ok / is-warn / is-bad) and adds the word to the screen reader text
|
|
103
|
+
* @param {string} [options.note] small text under the value ("of 120 hosts", "updated 2 min ago")
|
|
104
|
+
* @returns {{element: HTMLElement, setValue: Function, setNote: Function, setTone: Function}}
|
|
105
|
+
*/
|
|
106
|
+
export function generateStat(options?: {
|
|
107
|
+
parent?: string | Element;
|
|
108
|
+
label: string;
|
|
109
|
+
value: string | number;
|
|
110
|
+
delta?: number;
|
|
111
|
+
invertDelta?: boolean;
|
|
112
|
+
tone?: "ok" | "warn" | "bad";
|
|
113
|
+
note?: string;
|
|
114
|
+
}): {
|
|
115
|
+
element: HTMLElement;
|
|
116
|
+
setValue: Function;
|
|
117
|
+
setNote: Function;
|
|
118
|
+
setTone: Function;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* Generates a responsive grid. The columns collapse to one on small screens.
|
|
122
|
+
*
|
|
123
|
+
* @param {object} options
|
|
124
|
+
* @param {string|Element} [options.parent]
|
|
125
|
+
* @param {number} [options.columns=3]
|
|
126
|
+
* @param {string} [options.gap] any CSS length
|
|
127
|
+
* @returns {HTMLElement} append the cells to it
|
|
128
|
+
*/
|
|
129
|
+
export function generateGrid(options?: {
|
|
130
|
+
parent?: string | Element;
|
|
131
|
+
columns?: number;
|
|
132
|
+
gap?: string;
|
|
133
|
+
}): HTMLElement;
|
|
134
|
+
/**
|
|
135
|
+
* Adds a tooltip to an element. It shows on hover and on keyboard focus, and Esc hides it.
|
|
136
|
+
* It is a native popover (`popover="manual"`), so it is drawn above everything and never cut off by a parent with `overflow: hidden`. A touch
|
|
137
|
+
* does not show it (a tap would hide the thing it describes). Browsers without the popover API show it with CSS, as before.
|
|
138
|
+
*
|
|
139
|
+
* @param {Element|string} target element or id
|
|
140
|
+
* @param {string} text
|
|
141
|
+
*/
|
|
142
|
+
export function generateTooltip(target: Element | string, text: string): HTMLElement;
|
|
143
|
+
/**
|
|
144
|
+
* The top of a page: breadcrumbs, the title (a heading), a description and the actions of the page.
|
|
145
|
+
*
|
|
146
|
+
* @param {object} options
|
|
147
|
+
* @param {string|Element} [options.parent]
|
|
148
|
+
* @param {string} options.title
|
|
149
|
+
* @param {string} [options.description]
|
|
150
|
+
* @param {{label: string, href?: string, onclick?: Function}[]} [options.breadcrumbs] see generateBreadcrumbs
|
|
151
|
+
* @param {(Node|string)[]|Node} [options.actions] buttons, shown at the end of the header
|
|
152
|
+
* @param {1|2|3} [options.level=1] heading level
|
|
153
|
+
* @returns {{element: HTMLElement, setTitle: Function, setDescription: Function, actions: HTMLElement}}
|
|
154
|
+
*/
|
|
155
|
+
export function generatePageHeader(options?: {
|
|
156
|
+
parent?: string | Element;
|
|
157
|
+
title: string;
|
|
158
|
+
description?: string;
|
|
159
|
+
breadcrumbs?: {
|
|
160
|
+
label: string;
|
|
161
|
+
href?: string;
|
|
162
|
+
onclick?: Function;
|
|
163
|
+
}[];
|
|
164
|
+
actions?: (Node | string)[] | Node;
|
|
165
|
+
level?: 1 | 2 | 3;
|
|
166
|
+
}): {
|
|
167
|
+
element: HTMLElement;
|
|
168
|
+
setTitle: Function;
|
|
169
|
+
setDescription: Function;
|
|
170
|
+
actions: HTMLElement;
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* A list of facts: a term and its description, in pairs (a <dl>).
|
|
174
|
+
*
|
|
175
|
+
* @param {object} options
|
|
176
|
+
* @param {string|Element} [options.parent]
|
|
177
|
+
* @param {{term: string, description: (string|number|Node|Array), title?: string}[]} options.items text is inserted as text
|
|
178
|
+
* @param {boolean} [options.inline=false] terms and descriptions side by side
|
|
179
|
+
* @returns {{element: HTMLElement, setItems: Function}}
|
|
180
|
+
*/
|
|
181
|
+
export function generateFacts(options?: {
|
|
182
|
+
parent?: string | Element;
|
|
183
|
+
items: {
|
|
184
|
+
term: string;
|
|
185
|
+
description: (string | number | Node | any[]);
|
|
186
|
+
title?: string;
|
|
187
|
+
}[];
|
|
188
|
+
inline?: boolean;
|
|
189
|
+
}): {
|
|
190
|
+
element: HTMLElement;
|
|
191
|
+
setItems: Function;
|
|
192
|
+
};
|
|
193
|
+
/**
|
|
194
|
+
* What a list shows when there is nothing in it: a title, a short explanation and what to do about it.
|
|
195
|
+
*
|
|
196
|
+
* @param {object} options
|
|
197
|
+
* @param {string|Element} [options.parent]
|
|
198
|
+
* @param {string} options.title
|
|
199
|
+
* @param {string} [options.message]
|
|
200
|
+
* @param {string|Node} [options.icon] decorative
|
|
201
|
+
* @param {{text: string, onclick: Function, variant?: string}} [options.action] a button
|
|
202
|
+
*/
|
|
203
|
+
export function generateEmptyState(options?: {
|
|
204
|
+
parent?: string | Element;
|
|
205
|
+
title: string;
|
|
206
|
+
message?: string;
|
|
207
|
+
icon?: string | Node;
|
|
208
|
+
action?: {
|
|
209
|
+
text: string;
|
|
210
|
+
onclick: Function;
|
|
211
|
+
variant?: string;
|
|
212
|
+
};
|
|
213
|
+
}): any;
|
|
214
|
+
/**
|
|
215
|
+
* A skeleton: grey lines with a shimmer where text or a card will be, so the page does not jump when it arrives. It is a live region that says
|
|
216
|
+
* "Loading..." to a screen reader; the shimmer stops under reduced motion.
|
|
217
|
+
*
|
|
218
|
+
* @param {object} [options]
|
|
219
|
+
* @param {string|Element} [options.parent]
|
|
220
|
+
* @param {number} [options.lines=3] the last of several lines is shorter
|
|
221
|
+
* @param {string} [options.class] e.g. "skeleton-card" in your own CSS gives the box a height
|
|
222
|
+
*/
|
|
223
|
+
export function generateSkeleton(options?: {
|
|
224
|
+
parent?: string | Element;
|
|
225
|
+
lines?: number;
|
|
226
|
+
class?: string;
|
|
227
|
+
}): any;
|
|
228
|
+
/**
|
|
229
|
+
* A placeholder while something loads: a spinner and a text (a live region, so a screen reader says it).
|
|
230
|
+
*
|
|
231
|
+
* @param {object} [options]
|
|
232
|
+
* @param {string|Element} [options.parent]
|
|
233
|
+
* @param {string} [options.text] default: the translated "Loading..."
|
|
234
|
+
*/
|
|
235
|
+
export function generateLoading(options?: {
|
|
236
|
+
parent?: string | Element;
|
|
237
|
+
text?: string;
|
|
238
|
+
}): any;
|
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates a router that renders a page function into an outlet element.
|
|
3
|
-
*
|
|
4
|
-
* @param {object} options
|
|
5
|
-
* @param {Object<string, Function|{handler: Function, title?: string}>} options.routes path pattern -> page
|
|
6
|
-
* function. Patterns support `:param` segments and a trailing `*`. A page function is called with
|
|
7
|
-
* `{ path, params, query }` after the outlet was emptied, and may return a promise.
|
|
8
|
-
* @param {string} [options.outlet="wrapper"] id of the element the pages are rendered into
|
|
9
|
-
* @param {"hash"|"history"} [options.mode="hash"] "history" needs the server to answer every path with the page
|
|
10
|
-
* @param {(context) => void} [options.notFound] called when no route matches
|
|
11
|
-
* @param {(context) => (boolean|string|void|Promise)} [options.beforeEach] guard: return false to cancel,
|
|
12
|
-
* or a path to redirect to (login redirect)
|
|
13
|
-
* @param {(context) => void} [options.afterEach] same as onShown
|
|
14
|
-
* @param {(context, route) => void} [options.onRender] called after the outlet was emptied, before the page function runs
|
|
15
|
-
* @param {(context, route) => void} [options.onShown] called after the page function finished (and it was not replaced by a newer
|
|
16
|
-
* navigation): the place to set the title, move the focus to the content, scroll to the top
|
|
17
|
-
* @param {boolean} [options.focusContent=false] after a page is shown the outlet gets the focus (it is made focusable for that), so a
|
|
18
|
-
* screen reader starts reading the new page and the keyboard continues there
|
|
19
|
-
* @param {boolean} [options.scrollTop=false] scroll to the top after a page is shown
|
|
20
|
-
* @param {boolean} [options.transition=false] a page change is a view transition (document.startViewTransition): the old page cross-fades into the new one,
|
|
21
|
-
* and elements with a `view-transition-name` move from one page to the next. Without the API, or under reduced motion, nothing changes. The old page
|
|
22
|
-
* stays on the screen until the page function of the new one is done, so pages that need long to build should draw something quickly.
|
|
23
|
-
* @param {object} [options.auth] sign-in rules for routes, see the route options below
|
|
24
|
-
* @param {() => boolean} [options.auth.isSignedIn]
|
|
25
|
-
* @param {(role: string) => boolean} [options.auth.hasRole]
|
|
26
|
-
* @param {string} [options.auth.loginPath="/login"] where `auth: true` routes send a visitor who is not signed in (with `?next=<path>`)
|
|
27
|
-
* @param {string} [options.auth.homePath="/"] where `guestOnly` routes send a signed-in person
|
|
28
|
-
* @param {string} [options.auth.forbiddenPath] where a person without the role goes (default: homePath)
|
|
29
|
-
* @param {string} [options.titlePrefix] document title is `${titlePrefix}${route.title}`
|
|
30
|
-
*
|
|
31
|
-
* A route is a page function, or an object: `{ handler, title, auth: true, guestOnly: true, roles: ["admin"], guard(context) }`.
|
|
32
|
-
* `auth`, `guestOnly` and `roles` are checked with options.auth; `guard` is a function that gets the same context and returns
|
|
33
|
-
* false (stay where you are), a path (redirect) or anything else (go on); it runs after the rules.
|
|
34
|
-
* @returns {{start: Function, stop: Function, navigate: Function, current: Function, href: Function,
|
|
35
|
-
* onChange: (listener: (context) => void) => Function}}
|
|
36
|
-
* `onChange(listener)` is called with the context after every page that is shown (menus and breadcrumbs follow the router
|
|
37
|
-
* with it) and returns a function that stops it.
|
|
38
|
-
*/
|
|
39
|
-
export function createRouter(options?: {
|
|
40
|
-
routes: {
|
|
41
|
-
[x: string]: Function | {
|
|
42
|
-
handler: Function;
|
|
43
|
-
title?: string;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
outlet?: string;
|
|
47
|
-
mode?: "hash" | "history";
|
|
48
|
-
notFound?: (context: any) => void;
|
|
49
|
-
beforeEach?: (context: any) => (boolean | string | void | Promise<any>);
|
|
50
|
-
afterEach?: (context: any) => void;
|
|
51
|
-
onRender?: (context: any, route: any) => void;
|
|
52
|
-
onShown?: (context: any, route: any) => void;
|
|
53
|
-
focusContent?: boolean;
|
|
54
|
-
scrollTop?: boolean;
|
|
55
|
-
transition?: boolean;
|
|
56
|
-
auth?: {
|
|
57
|
-
isSignedIn?: () => boolean;
|
|
58
|
-
hasRole?: (role: string) => boolean;
|
|
59
|
-
loginPath?: string;
|
|
60
|
-
homePath?: string;
|
|
61
|
-
forbiddenPath?: string;
|
|
62
|
-
};
|
|
63
|
-
titlePrefix?: string;
|
|
64
|
-
}): {
|
|
65
|
-
start: Function;
|
|
66
|
-
stop: Function;
|
|
67
|
-
navigate: Function;
|
|
68
|
-
current: Function;
|
|
69
|
-
href: Function;
|
|
70
|
-
onChange: (listener: (context: any) => void) => Function;
|
|
71
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Creates a router that renders a page function into an outlet element.
|
|
3
|
+
*
|
|
4
|
+
* @param {object} options
|
|
5
|
+
* @param {Object<string, Function|{handler: Function, title?: string}>} options.routes path pattern -> page
|
|
6
|
+
* function. Patterns support `:param` segments and a trailing `*`. A page function is called with
|
|
7
|
+
* `{ path, params, query }` after the outlet was emptied, and may return a promise.
|
|
8
|
+
* @param {string} [options.outlet="wrapper"] id of the element the pages are rendered into
|
|
9
|
+
* @param {"hash"|"history"} [options.mode="hash"] "history" needs the server to answer every path with the page
|
|
10
|
+
* @param {(context) => void} [options.notFound] called when no route matches
|
|
11
|
+
* @param {(context) => (boolean|string|void|Promise)} [options.beforeEach] guard: return false to cancel,
|
|
12
|
+
* or a path to redirect to (login redirect)
|
|
13
|
+
* @param {(context) => void} [options.afterEach] same as onShown
|
|
14
|
+
* @param {(context, route) => void} [options.onRender] called after the outlet was emptied, before the page function runs
|
|
15
|
+
* @param {(context, route) => void} [options.onShown] called after the page function finished (and it was not replaced by a newer
|
|
16
|
+
* navigation): the place to set the title, move the focus to the content, scroll to the top
|
|
17
|
+
* @param {boolean} [options.focusContent=false] after a page is shown the outlet gets the focus (it is made focusable for that), so a
|
|
18
|
+
* screen reader starts reading the new page and the keyboard continues there
|
|
19
|
+
* @param {boolean} [options.scrollTop=false] scroll to the top after a page is shown
|
|
20
|
+
* @param {boolean} [options.transition=false] a page change is a view transition (document.startViewTransition): the old page cross-fades into the new one,
|
|
21
|
+
* and elements with a `view-transition-name` move from one page to the next. Without the API, or under reduced motion, nothing changes. The old page
|
|
22
|
+
* stays on the screen until the page function of the new one is done, so pages that need long to build should draw something quickly.
|
|
23
|
+
* @param {object} [options.auth] sign-in rules for routes, see the route options below
|
|
24
|
+
* @param {() => boolean} [options.auth.isSignedIn]
|
|
25
|
+
* @param {(role: string) => boolean} [options.auth.hasRole]
|
|
26
|
+
* @param {string} [options.auth.loginPath="/login"] where `auth: true` routes send a visitor who is not signed in (with `?next=<path>`)
|
|
27
|
+
* @param {string} [options.auth.homePath="/"] where `guestOnly` routes send a signed-in person
|
|
28
|
+
* @param {string} [options.auth.forbiddenPath] where a person without the role goes (default: homePath)
|
|
29
|
+
* @param {string} [options.titlePrefix] document title is `${titlePrefix}${route.title}`
|
|
30
|
+
*
|
|
31
|
+
* A route is a page function, or an object: `{ handler, title, auth: true, guestOnly: true, roles: ["admin"], guard(context) }`.
|
|
32
|
+
* `auth`, `guestOnly` and `roles` are checked with options.auth; `guard` is a function that gets the same context and returns
|
|
33
|
+
* false (stay where you are), a path (redirect) or anything else (go on); it runs after the rules.
|
|
34
|
+
* @returns {{start: Function, stop: Function, navigate: Function, current: Function, href: Function,
|
|
35
|
+
* onChange: (listener: (context) => void) => Function}}
|
|
36
|
+
* `onChange(listener)` is called with the context after every page that is shown (menus and breadcrumbs follow the router
|
|
37
|
+
* with it) and returns a function that stops it.
|
|
38
|
+
*/
|
|
39
|
+
export function createRouter(options?: {
|
|
40
|
+
routes: {
|
|
41
|
+
[x: string]: Function | {
|
|
42
|
+
handler: Function;
|
|
43
|
+
title?: string;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
outlet?: string;
|
|
47
|
+
mode?: "hash" | "history";
|
|
48
|
+
notFound?: (context: any) => void;
|
|
49
|
+
beforeEach?: (context: any) => (boolean | string | void | Promise<any>);
|
|
50
|
+
afterEach?: (context: any) => void;
|
|
51
|
+
onRender?: (context: any, route: any) => void;
|
|
52
|
+
onShown?: (context: any, route: any) => void;
|
|
53
|
+
focusContent?: boolean;
|
|
54
|
+
scrollTop?: boolean;
|
|
55
|
+
transition?: boolean;
|
|
56
|
+
auth?: {
|
|
57
|
+
isSignedIn?: () => boolean;
|
|
58
|
+
hasRole?: (role: string) => boolean;
|
|
59
|
+
loginPath?: string;
|
|
60
|
+
homePath?: string;
|
|
61
|
+
forbiddenPath?: string;
|
|
62
|
+
};
|
|
63
|
+
titlePrefix?: string;
|
|
64
|
+
}): {
|
|
65
|
+
start: Function;
|
|
66
|
+
stop: Function;
|
|
67
|
+
navigate: Function;
|
|
68
|
+
current: Function;
|
|
69
|
+
href: Function;
|
|
70
|
+
onChange: (listener: (context: any) => void) => Function;
|
|
71
|
+
};
|