athena-ui-js 2.1.0 → 2.2.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.
@@ -1,93 +1,95 @@
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.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)
37
+ * @param {boolean} [options.interactive=true] line and area charts: false leaves out the pointer layer (tooltip that follows the pointer, zoom)
38
+ * @returns {(SVGElement & {element: SVGElement, update: (options?: object) => SVGElement, destroy: () => void,
39
+ * zoom: (from: number, to: number) => void, resetZoom: () => void, getZoom: () => ({from: number, to: number}|null),
40
+ * push: (point: {x?: (number|Date|string), label?: string, values: (number|number[])}, config?: {maxPoints?: number}) => void,
41
+ * dataTable: (HTMLElement|null)})|null}
42
+ * the SVG element, which also carries the handle ({ element, update(options), destroy() }) of the other
43
+ * components; null when the options are invalid. `parent` is an element, an id or a selector.
44
+ * `push` adds a point to every series (a number for the first series, or one value per series; `x` is the time with
45
+ * `times`, `label` the category) and draws the chart again at most once per frame, however often it is called.
46
+ */
47
+ export function generateChart(options?: {
48
+ type?: "bar" | "line" | "area" | "sparkline" | "pie" | "donut";
49
+ parent?: string | Element;
50
+ id?: string;
51
+ title?: string;
52
+ labels?: string[];
53
+ times?: (number | Date | string)[];
54
+ series: {
55
+ name?: string;
56
+ data: number[];
57
+ color?: string;
58
+ }[];
59
+ width?: number;
60
+ height?: number;
61
+ legend?: boolean;
62
+ table?: boolean;
63
+ zero?: boolean;
64
+ zoom?: boolean;
65
+ zoomRange?: {
66
+ from: number;
67
+ to: number;
68
+ } | null;
69
+ onZoom?: (range: ({
70
+ from: number;
71
+ to: number;
72
+ } | null)) => void;
73
+ maxPoints?: number;
74
+ hiddenSeries?: number[];
75
+ animate?: boolean;
76
+ interactive?: boolean;
77
+ }): (SVGElement & {
78
+ element: SVGElement;
79
+ update: (options?: object) => SVGElement;
80
+ destroy: () => void;
81
+ zoom: (from: number, to: number) => void;
82
+ resetZoom: () => void;
83
+ getZoom: () => ({
84
+ from: number;
85
+ to: number;
86
+ } | null);
87
+ push: (point: {
88
+ x?: (number | Date | string);
89
+ label?: string;
90
+ values: (number | number[]);
91
+ }, config?: {
92
+ maxPoints?: number;
93
+ }) => void;
94
+ dataTable: (HTMLElement | null);
95
+ }) | null;
@@ -211,6 +211,20 @@ export function generateEmptyState(options?: {
211
211
  variant?: string;
212
212
  };
213
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;
214
228
  /**
215
229
  * A placeholder while something loads: a spinner and a text (a live region, so a screen reader says it).
216
230
  *
@@ -1,153 +1,153 @@
1
- /**
2
- * Generates tabs. Arrow keys, Home and End move between the tabs.
3
- *
4
- * @param {object} options
5
- * @param {string|Element} [options.parent]
6
- * @param {string} [options.id]
7
- * @param {{id: string, label: string, content: *, disabled?: boolean}[]} options.tabs content is text, a Node,
8
- * an array, or a function called once when the tab is first shown (lazy content)
9
- * @param {string} [options.active] id of the initially active tab (default: the first)
10
- * @param {(id: string) => void} [options.onChange]
11
- * @returns {{element: HTMLElement, select: (id: string) => void, getActive: () => string}}
12
- */
13
- export function generateTabs(options?: {
14
- parent?: string | Element;
15
- id?: string;
16
- tabs: {
17
- id: string;
18
- label: string;
19
- content: any;
20
- disabled?: boolean;
21
- }[];
22
- active?: string;
23
- onChange?: (id: string) => void;
24
- }): {
25
- element: HTMLElement;
26
- select: (id: string) => void;
27
- getActive: () => string;
28
- };
29
- /**
30
- * Generates breadcrumbs. The last item is the current page.
31
- *
32
- * @param {object} options
33
- * @param {string|Element} [options.parent]
34
- * @param {{label: string, href?: string, onclick?: Function}[]} options.items
35
- */
36
- export function generateBreadcrumbs(options?: {
37
- parent?: string | Element;
38
- items: {
39
- label: string;
40
- href?: string;
41
- onclick?: Function;
42
- }[];
43
- }): any;
44
- /**
45
- * Generates a page selector.
46
- *
47
- * @param {object} options
48
- * @param {string|Element} [options.parent]
49
- * @param {number} options.total number of items
50
- * @param {number} [options.pageSize=10]
51
- * @param {number} [options.page=1]
52
- * @param {number} [options.siblings=1] page buttons shown next to the current page
53
- * @param {(page: number) => void} [options.onChange]
54
- * @returns {{element: HTMLElement, setPage: Function, setTotal: Function, getPage: Function}}
55
- */
56
- export function generatePagination(options?: {
57
- parent?: string | Element;
58
- total: number;
59
- pageSize?: number;
60
- page?: number;
61
- siblings?: number;
62
- onChange?: (page: number) => void;
63
- }): {
64
- element: HTMLElement;
65
- setPage: Function;
66
- setTotal: Function;
67
- getPage: Function;
68
- };
69
- /**
70
- * Generates collapsible panels.
71
- *
72
- * @param {object} options
73
- * @param {string|Element} [options.parent]
74
- * @param {{id?: string, title: string, content: *, open?: boolean}[]} options.items
75
- * @param {boolean} [options.multiple=false] allow several panels to be open at once
76
- * @returns {{element: HTMLElement, toggle: (index: number, open?: boolean) => void}}
77
- */
78
- export function generateAccordion(options?: {
79
- parent?: string | Element;
80
- items: {
81
- id?: string;
82
- title: string;
83
- content: any;
84
- open?: boolean;
85
- }[];
86
- multiple?: boolean;
87
- }): {
88
- element: HTMLElement;
89
- toggle: (index: number, open?: boolean) => void;
90
- };
91
- /**
92
- * Generates a button that opens a menu. Arrow keys move through the items, Esc closes it, and so does a click outside.
93
- * The menu is a native popover (the `popover` attribute): it is drawn above everything, so no parent can cut it off, and the browser takes care of the
94
- * light dismiss and of the focus. It is placed next to the button, below it, or above it when there is no room below. Browsers without the popover API
95
- * get a plain menu that is shown and hidden with `hidden`.
96
- *
97
- * @param {object} options
98
- * @param {string|Element} [options.parent]
99
- * @param {string} [options.label] button text (leave it out for an icon-only button, and give `ariaLabel`)
100
- * @param {string|Node} [options.icon] shown before the label, text or a Node (e.g. an SVG); hidden from screen readers
101
- * @param {string} [options.ariaLabel] accessible name, needed when there is no label
102
- * @param {boolean} [options.caret=false] show a small arrow after the label
103
- * @param {string} [options.toggleClass] extra CSS class(es) of the toggle button
104
- * @param {{label?: string, onclick?: Function, href?: string, disabled?: boolean, divider?: boolean}[]} options.items
105
- * @param {"left"|"right"} [options.align="left"]
106
- * @returns {{element: HTMLElement, open: Function, close: Function}}
107
- */
108
- export function generateDropdown(options?: {
109
- parent?: string | Element;
110
- label?: string;
111
- icon?: string | Node;
112
- ariaLabel?: string;
113
- caret?: boolean;
114
- toggleClass?: string;
115
- items: {
116
- label?: string;
117
- onclick?: Function;
118
- href?: string;
119
- disabled?: boolean;
120
- divider?: boolean;
121
- }[];
122
- align?: "left" | "right";
123
- }): {
124
- element: HTMLElement;
125
- open: Function;
126
- close: Function;
127
- };
128
- /**
129
- * Generates a vertical navigation with nested items. On small screens it collapses behind a toggle button.
130
- *
131
- * @param {object} options
132
- * @param {string|Element} [options.parent]
133
- * @param {{id: string, label: string, icon?: string, href?: string, children?: object[]}[]} options.items
134
- * @param {(item: object) => void} [options.onSelect]
135
- * @param {string} [options.active] id of the initially selected item
136
- * @returns {{element: HTMLElement, select: (id: string) => void, toggle: Function}}
137
- */
138
- export function generateSidebar(options?: {
139
- parent?: string | Element;
140
- items: {
141
- id: string;
142
- label: string;
143
- icon?: string;
144
- href?: string;
145
- children?: object[];
146
- }[];
147
- onSelect?: (item: object) => void;
148
- active?: string;
149
- }): {
150
- element: HTMLElement;
151
- select: (id: string) => void;
152
- toggle: Function;
153
- };
1
+ /**
2
+ * Generates tabs. Arrow keys, Home and End move between the tabs.
3
+ *
4
+ * @param {object} options
5
+ * @param {string|Element} [options.parent]
6
+ * @param {string} [options.id]
7
+ * @param {{id: string, label: string, content: *, disabled?: boolean}[]} options.tabs content is text, a Node,
8
+ * an array, or a function called once when the tab is first shown (lazy content)
9
+ * @param {string} [options.active] id of the initially active tab (default: the first)
10
+ * @param {(id: string) => void} [options.onChange]
11
+ * @returns {{element: HTMLElement, select: (id: string) => void, getActive: () => string}}
12
+ */
13
+ export function generateTabs(options?: {
14
+ parent?: string | Element;
15
+ id?: string;
16
+ tabs: {
17
+ id: string;
18
+ label: string;
19
+ content: any;
20
+ disabled?: boolean;
21
+ }[];
22
+ active?: string;
23
+ onChange?: (id: string) => void;
24
+ }): {
25
+ element: HTMLElement;
26
+ select: (id: string) => void;
27
+ getActive: () => string;
28
+ };
29
+ /**
30
+ * Generates breadcrumbs. The last item is the current page.
31
+ *
32
+ * @param {object} options
33
+ * @param {string|Element} [options.parent]
34
+ * @param {{label: string, href?: string, onclick?: Function}[]} options.items
35
+ */
36
+ export function generateBreadcrumbs(options?: {
37
+ parent?: string | Element;
38
+ items: {
39
+ label: string;
40
+ href?: string;
41
+ onclick?: Function;
42
+ }[];
43
+ }): any;
44
+ /**
45
+ * Generates a page selector.
46
+ *
47
+ * @param {object} options
48
+ * @param {string|Element} [options.parent]
49
+ * @param {number} options.total number of items
50
+ * @param {number} [options.pageSize=10]
51
+ * @param {number} [options.page=1]
52
+ * @param {number} [options.siblings=1] page buttons shown next to the current page
53
+ * @param {(page: number) => void} [options.onChange]
54
+ * @returns {{element: HTMLElement, setPage: Function, setTotal: Function, getPage: Function}}
55
+ */
56
+ export function generatePagination(options?: {
57
+ parent?: string | Element;
58
+ total: number;
59
+ pageSize?: number;
60
+ page?: number;
61
+ siblings?: number;
62
+ onChange?: (page: number) => void;
63
+ }): {
64
+ element: HTMLElement;
65
+ setPage: Function;
66
+ setTotal: Function;
67
+ getPage: Function;
68
+ };
69
+ /**
70
+ * Generates collapsible panels.
71
+ *
72
+ * @param {object} options
73
+ * @param {string|Element} [options.parent]
74
+ * @param {{id?: string, title: string, content: *, open?: boolean}[]} options.items
75
+ * @param {boolean} [options.multiple=false] allow several panels to be open at once
76
+ * @returns {{element: HTMLElement, toggle: (index: number, open?: boolean) => void}}
77
+ */
78
+ export function generateAccordion(options?: {
79
+ parent?: string | Element;
80
+ items: {
81
+ id?: string;
82
+ title: string;
83
+ content: any;
84
+ open?: boolean;
85
+ }[];
86
+ multiple?: boolean;
87
+ }): {
88
+ element: HTMLElement;
89
+ toggle: (index: number, open?: boolean) => void;
90
+ };
91
+ /**
92
+ * Generates a button that opens a menu. Arrow keys move through the items, Esc closes it, and so does a click outside.
93
+ * The menu is a native popover (the `popover` attribute): it is drawn above everything, so no parent can cut it off, and the browser takes care of the
94
+ * light dismiss and of the focus. It is placed next to the button, below it, or above it when there is no room below. Browsers without the popover API
95
+ * get a plain menu that is shown and hidden with `hidden`.
96
+ *
97
+ * @param {object} options
98
+ * @param {string|Element} [options.parent]
99
+ * @param {string} [options.label] button text (leave it out for an icon-only button, and give `ariaLabel`)
100
+ * @param {string|Node} [options.icon] shown before the label, text or a Node (e.g. an SVG); hidden from screen readers
101
+ * @param {string} [options.ariaLabel] accessible name, needed when there is no label
102
+ * @param {boolean} [options.caret=false] show a small arrow after the label
103
+ * @param {string} [options.toggleClass] extra CSS class(es) of the toggle button
104
+ * @param {{label?: string, onclick?: Function, href?: string, disabled?: boolean, divider?: boolean}[]} options.items
105
+ * @param {"left"|"right"} [options.align="left"]
106
+ * @returns {{element: HTMLElement, open: Function, close: Function}}
107
+ */
108
+ export function generateDropdown(options?: {
109
+ parent?: string | Element;
110
+ label?: string;
111
+ icon?: string | Node;
112
+ ariaLabel?: string;
113
+ caret?: boolean;
114
+ toggleClass?: string;
115
+ items: {
116
+ label?: string;
117
+ onclick?: Function;
118
+ href?: string;
119
+ disabled?: boolean;
120
+ divider?: boolean;
121
+ }[];
122
+ align?: "left" | "right";
123
+ }): {
124
+ element: HTMLElement;
125
+ open: Function;
126
+ close: Function;
127
+ };
128
+ /**
129
+ * Generates a vertical navigation with nested items. On small screens it collapses behind a toggle button.
130
+ *
131
+ * @param {object} options
132
+ * @param {string|Element} [options.parent]
133
+ * @param {{id: string, label: string, icon?: string, href?: string, children?: object[]}[]} options.items
134
+ * @param {(item: object) => void} [options.onSelect]
135
+ * @param {string} [options.active] id of the initially selected item
136
+ * @returns {{element: HTMLElement, select: (id: string) => void, toggle: Function}}
137
+ */
138
+ export function generateSidebar(options?: {
139
+ parent?: string | Element;
140
+ items: {
141
+ id: string;
142
+ label: string;
143
+ icon?: string;
144
+ href?: string;
145
+ children?: object[];
146
+ }[];
147
+ onSelect?: (item: object) => void;
148
+ active?: string;
149
+ }): {
150
+ element: HTMLElement;
151
+ select: (id: string) => void;
152
+ toggle: Function;
153
+ };