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.
@@ -1,150 +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.
93
- *
94
- * @param {object} options
95
- * @param {string|Element} [options.parent]
96
- * @param {string} [options.label] button text (leave it out for an icon-only button, and give `ariaLabel`)
97
- * @param {string|Node} [options.icon] shown before the label, text or a Node (e.g. an SVG); hidden from screen readers
98
- * @param {string} [options.ariaLabel] accessible name, needed when there is no label
99
- * @param {boolean} [options.caret=false] show a small arrow after the label
100
- * @param {string} [options.toggleClass] extra CSS class(es) of the toggle button
101
- * @param {{label?: string, onclick?: Function, href?: string, disabled?: boolean, divider?: boolean}[]} options.items
102
- * @param {"left"|"right"} [options.align="left"]
103
- * @returns {{element: HTMLElement, open: Function, close: Function}}
104
- */
105
- export function generateDropdown(options?: {
106
- parent?: string | Element;
107
- label?: string;
108
- icon?: string | Node;
109
- ariaLabel?: string;
110
- caret?: boolean;
111
- toggleClass?: string;
112
- items: {
113
- label?: string;
114
- onclick?: Function;
115
- href?: string;
116
- disabled?: boolean;
117
- divider?: boolean;
118
- }[];
119
- align?: "left" | "right";
120
- }): {
121
- element: HTMLElement;
122
- open: Function;
123
- close: Function;
124
- };
125
- /**
126
- * Generates a vertical navigation with nested items. On small screens it collapses behind a toggle button.
127
- *
128
- * @param {object} options
129
- * @param {string|Element} [options.parent]
130
- * @param {{id: string, label: string, icon?: string, href?: string, children?: object[]}[]} options.items
131
- * @param {(item: object) => void} [options.onSelect]
132
- * @param {string} [options.active] id of the initially selected item
133
- * @returns {{element: HTMLElement, select: (id: string) => void, toggle: Function}}
134
- */
135
- export function generateSidebar(options?: {
136
- parent?: string | Element;
137
- items: {
138
- id: string;
139
- label: string;
140
- icon?: string;
141
- href?: string;
142
- children?: object[];
143
- }[];
144
- onSelect?: (item: object) => void;
145
- active?: string;
146
- }): {
147
- element: HTMLElement;
148
- select: (id: string) => void;
149
- toggle: Function;
150
- };
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
+ };