athena-ui-js 2.0.1 → 2.1.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 +21 -3
- package/docs/migration-2.0.md +1 -1
- package/docs/styling.md +3 -1
- package/package.json +1 -1
- package/src/athena-ui.js +1 -1
- package/src/libs/config/config.js +1 -1
- package/src/libs/core/popover.js +96 -0
- package/src/libs/hephaestus/componentGenerator/componentGenerator.js +26 -2
- package/src/libs/hephaestus/navigationGenerator/navigationGenerator.js +45 -9
- package/src/res/themes/default/style.css +32 -0
- package/types/libs/config/config.d.ts +3 -3
- package/types/libs/core/popover.d.ts +36 -0
- package/types/libs/hephaestus/chartGenerator/chartGenerator.d.ts +93 -93
- package/types/libs/hephaestus/componentGenerator/componentGenerator.d.ts +224 -222
- package/types/libs/hephaestus/navigationGenerator/navigationGenerator.d.ts +153 -150
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
/** Tick positions (ms) at round times between `from` and `to`, about `count` of them. */
|
|
2
|
-
export function timeTicks(from: any, to: any, count?: number): {
|
|
3
|
-
ticks: number[];
|
|
4
|
-
step: number;
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* Keeps about `buckets` x positions of a long series: of every bucket the lowest and the highest value stay (in their order),
|
|
8
|
-
* so peaks are not lost. Returns the kept indices.
|
|
9
|
-
*/
|
|
10
|
-
export function decimate(indices: any, values: any, buckets: any): any;
|
|
11
|
-
/**
|
|
12
|
-
* Draws a chart as inline SVG and appends it to its parent.
|
|
13
|
-
*
|
|
14
|
-
* @param {object} options
|
|
15
|
-
* @param {"bar"|"line"|"area"|"sparkline"|"pie"|"donut"} [options.type="bar"]
|
|
16
|
-
* @param {string|Element} [options.parent] element, id or selector, defaults to "wrapper"
|
|
17
|
-
* @param {string} [options.id] id of the svg element
|
|
18
|
-
* @param {string} [options.title] drawn above the chart, and its accessible name
|
|
19
|
-
* @param {string[]} [options.labels] category labels
|
|
20
|
-
* @param {(number|Date|string)[]} [options.times] line and area charts: the time of every value (Date, ms or a date string).
|
|
21
|
-
* The x axis becomes a time axis with ticks at round times, and the points sit at their real distance.
|
|
22
|
-
* @param {{name?: string, data: number[], color?: string}[]} options.series pie / donut / sparkline use the first series only.
|
|
23
|
-
* Colours come from the theme (--series-1 ... --series-8); `color` is an override for one series.
|
|
24
|
-
* @param {number} [options.width=600] (a sparkline: 120)
|
|
25
|
-
* @param {number} [options.height=360] (a sparkline: 32)
|
|
26
|
-
* @param {boolean} [options.legend] default: shown for several series, and for pie / donut. Clicking an entry hides / shows its series.
|
|
27
|
-
* @param {boolean} [options.table=false] adds a "Show as table" section with the values below the chart
|
|
28
|
-
* @param {boolean} [options.zero=true] line charts: false lets the value axis start near the smallest value
|
|
29
|
-
* @param {boolean} [options.zoom=false] line and area charts: drag over the plot to zoom into that range, double click (or the
|
|
30
|
-
* reset button, or 0 / Esc) to zoom out; with the keyboard on the plot: + and - zoom, the arrow keys pan
|
|
31
|
-
* @param {{from: number, to: number}|null} [options.zoomRange] the range in view, in the units of the x axis: milliseconds with
|
|
32
|
-
* `times`, otherwise the index of the point (-0.5 is the left edge of the first point)
|
|
33
|
-
* @param {(range: ({from: number, to: number}|null)) => void} [options.onZoom] called when a person zooms or resets
|
|
34
|
-
* @param {number} [options.maxPoints] `push` keeps at most this many points per series (the oldest are dropped)
|
|
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.interactive=true] line and area charts: false leaves out the pointer layer (tooltip that follows the pointer, zoom)
|
|
37
|
-
* @returns {(SVGElement & {element: SVGElement, update: (options?: object) => SVGElement, destroy: () => void,
|
|
38
|
-
* zoom: (from: number, to: number) => void, resetZoom: () => void, getZoom: () => ({from: number, to: number}|null),
|
|
39
|
-
* push: (point: {x?: (number|Date|string), label?: string, values: (number|number[])}, config?: {maxPoints?: number}) => void,
|
|
40
|
-
* dataTable: (HTMLElement|null)})|null}
|
|
41
|
-
* the SVG element, which also carries the handle ({ element, update(options), destroy() }) of the other
|
|
42
|
-
* components; null when the options are invalid. `parent` is an element, an id or a selector.
|
|
43
|
-
* `push` adds a point to every series (a number for the first series, or one value per series; `x` is the time with
|
|
44
|
-
* `times`, `label` the category) and draws the chart again at most once per frame, however often it is called.
|
|
45
|
-
*/
|
|
46
|
-
export function generateChart(options?: {
|
|
47
|
-
type?: "bar" | "line" | "area" | "sparkline" | "pie" | "donut";
|
|
48
|
-
parent?: string | Element;
|
|
49
|
-
id?: string;
|
|
50
|
-
title?: string;
|
|
51
|
-
labels?: string[];
|
|
52
|
-
times?: (number | Date | string)[];
|
|
53
|
-
series: {
|
|
54
|
-
name?: string;
|
|
55
|
-
data: number[];
|
|
56
|
-
color?: string;
|
|
57
|
-
}[];
|
|
58
|
-
width?: number;
|
|
59
|
-
height?: number;
|
|
60
|
-
legend?: boolean;
|
|
61
|
-
table?: boolean;
|
|
62
|
-
zero?: boolean;
|
|
63
|
-
zoom?: boolean;
|
|
64
|
-
zoomRange?: {
|
|
65
|
-
from: number;
|
|
66
|
-
to: number;
|
|
67
|
-
} | null;
|
|
68
|
-
onZoom?: (range: ({
|
|
69
|
-
from: number;
|
|
70
|
-
to: number;
|
|
71
|
-
} | null)) => void;
|
|
72
|
-
maxPoints?: number;
|
|
73
|
-
hiddenSeries?: number[];
|
|
74
|
-
interactive?: boolean;
|
|
75
|
-
}): (SVGElement & {
|
|
76
|
-
element: SVGElement;
|
|
77
|
-
update: (options?: object) => SVGElement;
|
|
78
|
-
destroy: () => void;
|
|
79
|
-
zoom: (from: number, to: number) => void;
|
|
80
|
-
resetZoom: () => void;
|
|
81
|
-
getZoom: () => ({
|
|
82
|
-
from: number;
|
|
83
|
-
to: number;
|
|
84
|
-
} | null);
|
|
85
|
-
push: (point: {
|
|
86
|
-
x?: (number | Date | string);
|
|
87
|
-
label?: string;
|
|
88
|
-
values: (number | number[]);
|
|
89
|
-
}, config?: {
|
|
90
|
-
maxPoints?: number;
|
|
91
|
-
}) => void;
|
|
92
|
-
dataTable: (HTMLElement | null);
|
|
93
|
-
}) | null;
|
|
1
|
+
/** Tick positions (ms) at round times between `from` and `to`, about `count` of them. */
|
|
2
|
+
export function timeTicks(from: any, to: any, count?: number): {
|
|
3
|
+
ticks: number[];
|
|
4
|
+
step: number;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Keeps about `buckets` x positions of a long series: of every bucket the lowest and the highest value stay (in their order),
|
|
8
|
+
* so peaks are not lost. Returns the kept indices.
|
|
9
|
+
*/
|
|
10
|
+
export function decimate(indices: any, values: any, buckets: any): any;
|
|
11
|
+
/**
|
|
12
|
+
* Draws a chart as inline SVG and appends it to its parent.
|
|
13
|
+
*
|
|
14
|
+
* @param {object} options
|
|
15
|
+
* @param {"bar"|"line"|"area"|"sparkline"|"pie"|"donut"} [options.type="bar"]
|
|
16
|
+
* @param {string|Element} [options.parent] element, id or selector, defaults to "wrapper"
|
|
17
|
+
* @param {string} [options.id] id of the svg element
|
|
18
|
+
* @param {string} [options.title] drawn above the chart, and its accessible name
|
|
19
|
+
* @param {string[]} [options.labels] category labels
|
|
20
|
+
* @param {(number|Date|string)[]} [options.times] line and area charts: the time of every value (Date, ms or a date string).
|
|
21
|
+
* The x axis becomes a time axis with ticks at round times, and the points sit at their real distance.
|
|
22
|
+
* @param {{name?: string, data: number[], color?: string}[]} options.series pie / donut / sparkline use the first series only.
|
|
23
|
+
* Colours come from the theme (--series-1 ... --series-8); `color` is an override for one series.
|
|
24
|
+
* @param {number} [options.width=600] (a sparkline: 120)
|
|
25
|
+
* @param {number} [options.height=360] (a sparkline: 32)
|
|
26
|
+
* @param {boolean} [options.legend] default: shown for several series, and for pie / donut. Clicking an entry hides / shows its series.
|
|
27
|
+
* @param {boolean} [options.table=false] adds a "Show as table" section with the values below the chart
|
|
28
|
+
* @param {boolean} [options.zero=true] line charts: false lets the value axis start near the smallest value
|
|
29
|
+
* @param {boolean} [options.zoom=false] line and area charts: drag over the plot to zoom into that range, double click (or the
|
|
30
|
+
* reset button, or 0 / Esc) to zoom out; with the keyboard on the plot: + and - zoom, the arrow keys pan
|
|
31
|
+
* @param {{from: number, to: number}|null} [options.zoomRange] the range in view, in the units of the x axis: milliseconds with
|
|
32
|
+
* `times`, otherwise the index of the point (-0.5 is the left edge of the first point)
|
|
33
|
+
* @param {(range: ({from: number, to: number}|null)) => void} [options.onZoom] called when a person zooms or resets
|
|
34
|
+
* @param {number} [options.maxPoints] `push` keeps at most this many points per series (the oldest are dropped)
|
|
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.interactive=true] line and area charts: false leaves out the pointer layer (tooltip that follows the pointer, zoom)
|
|
37
|
+
* @returns {(SVGElement & {element: SVGElement, update: (options?: object) => SVGElement, destroy: () => void,
|
|
38
|
+
* zoom: (from: number, to: number) => void, resetZoom: () => void, getZoom: () => ({from: number, to: number}|null),
|
|
39
|
+
* push: (point: {x?: (number|Date|string), label?: string, values: (number|number[])}, config?: {maxPoints?: number}) => void,
|
|
40
|
+
* dataTable: (HTMLElement|null)})|null}
|
|
41
|
+
* the SVG element, which also carries the handle ({ element, update(options), destroy() }) of the other
|
|
42
|
+
* components; null when the options are invalid. `parent` is an element, an id or a selector.
|
|
43
|
+
* `push` adds a point to every series (a number for the first series, or one value per series; `x` is the time with
|
|
44
|
+
* `times`, `label` the category) and draws the chart again at most once per frame, however often it is called.
|
|
45
|
+
*/
|
|
46
|
+
export function generateChart(options?: {
|
|
47
|
+
type?: "bar" | "line" | "area" | "sparkline" | "pie" | "donut";
|
|
48
|
+
parent?: string | Element;
|
|
49
|
+
id?: string;
|
|
50
|
+
title?: string;
|
|
51
|
+
labels?: string[];
|
|
52
|
+
times?: (number | Date | string)[];
|
|
53
|
+
series: {
|
|
54
|
+
name?: string;
|
|
55
|
+
data: number[];
|
|
56
|
+
color?: string;
|
|
57
|
+
}[];
|
|
58
|
+
width?: number;
|
|
59
|
+
height?: number;
|
|
60
|
+
legend?: boolean;
|
|
61
|
+
table?: boolean;
|
|
62
|
+
zero?: boolean;
|
|
63
|
+
zoom?: boolean;
|
|
64
|
+
zoomRange?: {
|
|
65
|
+
from: number;
|
|
66
|
+
to: number;
|
|
67
|
+
} | null;
|
|
68
|
+
onZoom?: (range: ({
|
|
69
|
+
from: number;
|
|
70
|
+
to: number;
|
|
71
|
+
} | null)) => void;
|
|
72
|
+
maxPoints?: number;
|
|
73
|
+
hiddenSeries?: number[];
|
|
74
|
+
interactive?: boolean;
|
|
75
|
+
}): (SVGElement & {
|
|
76
|
+
element: SVGElement;
|
|
77
|
+
update: (options?: object) => SVGElement;
|
|
78
|
+
destroy: () => void;
|
|
79
|
+
zoom: (from: number, to: number) => void;
|
|
80
|
+
resetZoom: () => void;
|
|
81
|
+
getZoom: () => ({
|
|
82
|
+
from: number;
|
|
83
|
+
to: number;
|
|
84
|
+
} | null);
|
|
85
|
+
push: (point: {
|
|
86
|
+
x?: (number | Date | string);
|
|
87
|
+
label?: string;
|
|
88
|
+
values: (number | number[]);
|
|
89
|
+
}, config?: {
|
|
90
|
+
maxPoints?: number;
|
|
91
|
+
}) => void;
|
|
92
|
+
dataTable: (HTMLElement | null);
|
|
93
|
+
}) | null;
|
|
@@ -1,222 +1,224 @@
|
|
|
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.
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
* @param {
|
|
147
|
-
* @param {string} [options.
|
|
148
|
-
* @param {
|
|
149
|
-
* @param {
|
|
150
|
-
* @param {
|
|
151
|
-
* @
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
*
|
|
174
|
-
*
|
|
175
|
-
* @param {
|
|
176
|
-
* @param {
|
|
177
|
-
* @
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
* @param {
|
|
197
|
-
* @param {string} [options.
|
|
198
|
-
* @param {string
|
|
199
|
-
* @param {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
* @param {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
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;
|