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,224 +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 placeholder while something loads: a spinner and a text (a live region, so a screen reader says it).
216
- *
217
- * @param {object} [options]
218
- * @param {string|Element} [options.parent]
219
- * @param {string} [options.text] default: the translated "Loading..."
220
- */
221
- export function generateLoading(options?: {
222
- parent?: string | Element;
223
- text?: string;
224
- }): 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;