athena-ui-js 1.3.0 → 2.0.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 (124) hide show
  1. package/README.md +100 -54
  2. package/docs/migration-2.0.md +83 -0
  3. package/docs/styling.md +86 -0
  4. package/package.json +108 -25
  5. package/src/athena-ui.js +54 -97
  6. package/src/chart.js +6 -0
  7. package/src/classic.js +11 -0
  8. package/src/components.js +6 -0
  9. package/src/controls.js +8 -0
  10. package/src/csv.js +6 -0
  11. package/src/dialog.js +7 -0
  12. package/src/dom.js +6 -0
  13. package/src/feedback.js +6 -0
  14. package/src/format.js +6 -0
  15. package/src/forms.js +7 -0
  16. package/src/i18n.js +6 -0
  17. package/src/inputs.js +9 -0
  18. package/src/libs/config/config.js +1 -9
  19. package/src/libs/core/controls.js +6 -14
  20. package/src/libs/core/cookies.js +55 -0
  21. package/src/libs/core/i18n.js +40 -6
  22. package/src/libs/core/validation.js +2 -2
  23. package/src/libs/hephaestus/LayoutGenerator/basicLayoutGenerator.js +9 -1
  24. package/src/libs/hephaestus/MenuGenerator/menuGenerator.js +16 -4
  25. package/src/libs/hephaestus/auth/session.js +1 -1
  26. package/src/libs/hephaestus/dialogGenerator/dialogGenerator.js +25 -17
  27. package/src/libs/hephaestus/formGenerator/changePasswordFormGenerator.js +4 -4
  28. package/src/libs/hephaestus/formGenerator/formUtils.js +0 -4
  29. package/src/libs/hephaestus/formGenerator/loginFormGenerator.js +2 -3
  30. package/src/libs/hephaestus/formGenerator/registrationFormGenerator.js +3 -3
  31. package/src/libs/hephaestus/hephaestus.js +0 -10
  32. package/src/libs/hephaestus/inputGenerator/dropZoneGenerator.js +1 -1
  33. package/src/libs/hephaestus/modalGenerator/modalGenerator.js +13 -6
  34. package/src/libs/hephaestus/navigationGenerator/navigationGenerator.js +20 -24
  35. package/src/menu.js +6 -0
  36. package/src/navigation.js +6 -0
  37. package/src/res/themes/default/style.css +97 -100
  38. package/src/res/themes/tokens.css +96 -0
  39. package/src/router.js +6 -0
  40. package/src/sanitize.js +6 -0
  41. package/src/session.js +8 -0
  42. package/src/table.js +6 -0
  43. package/src/testing.js +11 -1
  44. package/src/theme.js +7 -0
  45. package/src/validation.js +6 -0
  46. package/types/athena-ui.d.ts +96 -0
  47. package/types/chart.d.ts +1 -0
  48. package/types/classic.d.ts +1 -0
  49. package/types/components.d.ts +1 -0
  50. package/types/controls.d.ts +3 -0
  51. package/types/csv.d.ts +1 -0
  52. package/types/dialog.d.ts +2 -0
  53. package/types/dom.d.ts +1 -0
  54. package/types/feedback.d.ts +1 -0
  55. package/types/format.d.ts +1 -0
  56. package/types/forms.d.ts +2 -0
  57. package/types/i18n.d.ts +1 -0
  58. package/types/inputs.d.ts +4 -0
  59. package/types/libs/config/config.d.ts +96 -0
  60. package/types/libs/config/hooks.d.ts +8 -0
  61. package/types/libs/core/combobox.d.ts +10 -0
  62. package/types/libs/core/controls.d.ts +28 -0
  63. package/types/libs/core/cookies.d.ts +27 -0
  64. package/types/libs/core/csv.d.ts +12 -0
  65. package/types/libs/core/dateRange.d.ts +72 -0
  66. package/types/libs/core/dom.d.ts +65 -0
  67. package/types/libs/core/elementGenerator.d.ts +30 -0
  68. package/types/libs/core/errors.d.ts +29 -0
  69. package/types/libs/core/focus.d.ts +6 -0
  70. package/types/libs/core/format.d.ts +21 -0
  71. package/types/libs/core/hungarianControls.d.ts +2 -0
  72. package/types/libs/core/i18n.d.ts +17 -0
  73. package/types/libs/core/pagination.d.ts +5 -0
  74. package/types/libs/core/sanitize.d.ts +6 -0
  75. package/types/libs/core/tableMath.d.ts +26 -0
  76. package/types/libs/core/theme.d.ts +39 -0
  77. package/types/libs/core/validation.d.ts +56 -0
  78. package/types/libs/hephaestus/LayoutGenerator/basicLayoutGenerator.d.ts +10 -0
  79. package/types/libs/hephaestus/LayoutGenerator/footerContentGenerator.d.ts +4 -0
  80. package/types/libs/hephaestus/LayoutGenerator/headerContentGenerator.d.ts +20 -0
  81. package/types/libs/hephaestus/LayoutGenerator/wrapperContentGenerator.d.ts +1 -0
  82. package/types/libs/hephaestus/MenuGenerator/basicMenuGenerator.d.ts +14 -0
  83. package/types/libs/hephaestus/MenuGenerator/menuGenerator.d.ts +65 -0
  84. package/types/libs/hephaestus/auth/authState.d.ts +26 -0
  85. package/types/libs/hephaestus/auth/session.d.ts +26 -0
  86. package/types/libs/hephaestus/chartGenerator/chartGenerator.d.ts +91 -0
  87. package/types/libs/hephaestus/componentGenerator/componentGenerator.d.ts +222 -0
  88. package/types/libs/hephaestus/componentGenerator/themePicker.d.ts +24 -0
  89. package/types/libs/hephaestus/dialogGenerator/dialogGenerator.d.ts +120 -0
  90. package/types/libs/hephaestus/feedbackGenerator/feedbackGenerator.d.ts +86 -0
  91. package/types/libs/hephaestus/formGenerator/authForms.d.ts +122 -0
  92. package/types/libs/hephaestus/formGenerator/changePasswordFormGenerator.d.ts +6 -0
  93. package/types/libs/hephaestus/formGenerator/formBuilder.d.ts +113 -0
  94. package/types/libs/hephaestus/formGenerator/formUtils.d.ts +8 -0
  95. package/types/libs/hephaestus/formGenerator/loginFormGenerator.d.ts +11 -0
  96. package/types/libs/hephaestus/formGenerator/lostPasswordFormGenerator.d.ts +4 -0
  97. package/types/libs/hephaestus/formGenerator/registrationFormGenerator.d.ts +7 -0
  98. package/types/libs/hephaestus/hephaestus.d.ts +3 -0
  99. package/types/libs/hephaestus/inputGenerator/dropZoneGenerator.d.ts +48 -0
  100. package/types/libs/hephaestus/inputGenerator/inputGenerator.d.ts +185 -0
  101. package/types/libs/hephaestus/inputGenerator/richTextGenerator.d.ts +49 -0
  102. package/types/libs/hephaestus/modalGenerator/modalGenerator.d.ts +2 -0
  103. package/types/libs/hephaestus/navigationGenerator/navigationGenerator.d.ts +150 -0
  104. package/types/libs/hephaestus/router/matchRoute.d.ts +12 -0
  105. package/types/libs/hephaestus/router/router.d.ts +67 -0
  106. package/types/libs/hephaestus/tableGenerator/tableGenerator.d.ts +120 -0
  107. package/types/menu.d.ts +1 -0
  108. package/types/navigation.d.ts +1 -0
  109. package/types/res/themes/themes.d.ts +7 -0
  110. package/types/router.d.ts +1 -0
  111. package/types/sanitize.d.ts +1 -0
  112. package/types/session.d.ts +3 -0
  113. package/types/table.d.ts +1 -0
  114. package/types/testing.d.ts +27 -0
  115. package/types/theme-boot.d.ts +0 -0
  116. package/types/theme.d.ts +2 -0
  117. package/types/validation.d.ts +1 -0
  118. package/src/libs/crypto-js/LICENSE +0 -24
  119. package/src/libs/crypto-js/crypto-js.js +0 -6657
  120. package/src/libs/js-cookie/LICENSE +0 -21
  121. package/src/libs/js-cookie/src/api.mjs +0 -103
  122. package/src/libs/js-cookie/src/assign.mjs +0 -10
  123. package/src/libs/js-cookie/src/converter.mjs +0 -14
  124. package/src/libs/libs.js +0 -13
@@ -0,0 +1,185 @@
1
+ /**
2
+ * Generates an input with suggestions. `options` is an array of strings / { value, text }, or a function
3
+ * (query) => options | Promise<options> for remote data.
4
+ *
5
+ * @param {object} options
6
+ * @param {string|Element} [options.parent]
7
+ * @param {string} [options.label]
8
+ * @param {Array|Function} options.options
9
+ * @param {number} [options.minChars=1] characters needed before suggestions show
10
+ * @param {boolean} [options.strict=false] only a value chosen from the list is accepted
11
+ * @param {(item: {value, text}) => void} [options.onSelect]
12
+ * @param {(value) => void} [options.onChange]
13
+ * @returns {{element: HTMLElement, input: HTMLInputElement, getValue: Function, setValue: Function}}
14
+ */
15
+ export function generateAutocomplete(options?: {
16
+ parent?: string | Element;
17
+ label?: string;
18
+ options: any[] | Function;
19
+ minChars?: number;
20
+ strict?: boolean;
21
+ onSelect?: (item: {
22
+ value: any;
23
+ text: any;
24
+ }) => void;
25
+ onChange?: (value: any) => void;
26
+ }): {
27
+ element: HTMLElement;
28
+ input: HTMLInputElement;
29
+ getValue: Function;
30
+ setValue: Function;
31
+ };
32
+ /**
33
+ * Generates a multiple selection with chips. Same options as generateAutocomplete; getValue returns an array.
34
+ */
35
+ export function generateMultiSelect(options?: {}): any;
36
+ /**
37
+ * Generates a from / to date picker (the native pickers of the browser). The end date cannot be picked before
38
+ * the start date, and validate() reports a reversed range typed by hand.
39
+ *
40
+ * @param {object} options
41
+ * @param {string|Element} [options.parent]
42
+ * @param {string} [options.label]
43
+ * @param {string} [options.from] initial start, "2026-01-31"
44
+ * @param {string} [options.to] initial end
45
+ * @param {string} [options.min] earliest date
46
+ * @param {string} [options.max] latest date
47
+ * @param {(value: {from: string, to: string}) => void} [options.onChange]
48
+ * @returns {{element: HTMLElement, getValue: () => {from: string, to: string}, setValue: Function, validate: () => string}}
49
+ */
50
+ export function generateDateRange(options?: {
51
+ parent?: string | Element;
52
+ label?: string;
53
+ from?: string;
54
+ to?: string;
55
+ min?: string;
56
+ max?: string;
57
+ onChange?: (value: {
58
+ from: string;
59
+ to: string;
60
+ }) => void;
61
+ }): {
62
+ element: HTMLElement;
63
+ getValue: () => {
64
+ from: string;
65
+ to: string;
66
+ };
67
+ setValue: Function;
68
+ validate: () => string;
69
+ };
70
+ /**
71
+ * Generates a from / to range with date AND time (datetime-local inputs), and a list of presets: last 15 minutes, hour,
72
+ * 24 hours, 7 days, 30 days, or "Custom". For log filters, charts and reports that need times, not whole days.
73
+ * A preset moves with the clock: getRange() measures it from now when it is called.
74
+ *
75
+ * @param {object} options
76
+ * @param {string|Element} [options.parent]
77
+ * @param {string} [options.label]
78
+ * @param {string} [options.from] initial start, "2026-01-31T08:00"
79
+ * @param {string} [options.to] initial end
80
+ * @param {string} [options.preset] id of the preset to start with ("15m", "1h", "24h", "7d", "30d")
81
+ * @param {{id: string, label?: string, labelKey?: string, minutes: number}[]} [options.presets] your own list
82
+ * @param {boolean} [options.seconds=false]
83
+ * @param {string} [options.min]
84
+ * @param {string} [options.max]
85
+ * @param {(value: {from: string, to: string, preset: string}) => void} [options.onChange]
86
+ * @returns {{element: HTMLElement, getValue: Function, getRange: () => ({from: Date|null, to: Date|null}), setValue: Function, validate: () => string}}
87
+ */
88
+ export function generateDateTimeRange(options?: {
89
+ parent?: string | Element;
90
+ label?: string;
91
+ from?: string;
92
+ to?: string;
93
+ preset?: string;
94
+ presets?: {
95
+ id: string;
96
+ label?: string;
97
+ labelKey?: string;
98
+ minutes: number;
99
+ }[];
100
+ seconds?: boolean;
101
+ min?: string;
102
+ max?: string;
103
+ onChange?: (value: {
104
+ from: string;
105
+ to: string;
106
+ preset: string;
107
+ }) => void;
108
+ }): {
109
+ element: HTMLElement;
110
+ getValue: Function;
111
+ getRange: () => ({
112
+ from: Date | null;
113
+ to: Date | null;
114
+ });
115
+ setValue: Function;
116
+ validate: () => string;
117
+ };
118
+ /**
119
+ * Generates a drop zone with a file list and upload progress.
120
+ *
121
+ * @param {object} options
122
+ * @param {string|Element} [options.parent]
123
+ * @param {string} [options.accept] ".png,image/*"
124
+ * @param {boolean} [options.multiple=true]
125
+ * @param {number} [options.maxSize] bytes per file
126
+ * @param {string} [options.url] upload endpoint (multipart POST). Without it the files are only collected.
127
+ * @param {string} [options.fieldName="file"] name of the form field the file is sent as
128
+ * @param {Object<string,string>} [options.headers]
129
+ * @param {boolean} [options.autoUpload=true] upload as soon as files are added
130
+ * @param {(files: File[]) => void} [options.onSelect]
131
+ * @param {(file: File, percent: number) => void} [options.onProgress]
132
+ * @param {(file: File, response: string) => void} [options.onComplete]
133
+ * @param {(file: File, error: Error) => void} [options.onError]
134
+ * @returns {{element: HTMLElement, getFiles: () => File[], upload: () => Promise<void>, clear: Function}}
135
+ */
136
+ export function generateFileUpload(options?: {
137
+ parent?: string | Element;
138
+ accept?: string;
139
+ multiple?: boolean;
140
+ maxSize?: number;
141
+ url?: string;
142
+ fieldName?: string;
143
+ headers?: {
144
+ [x: string]: string;
145
+ };
146
+ autoUpload?: boolean;
147
+ onSelect?: (files: File[]) => void;
148
+ onProgress?: (file: File, percent: number) => void;
149
+ onComplete?: (file: File, response: string) => void;
150
+ onError?: (file: File, error: Error) => void;
151
+ }): {
152
+ element: HTMLElement;
153
+ getFiles: () => File[];
154
+ upload: () => Promise<void>;
155
+ clear: Function;
156
+ };
157
+ /**
158
+ * Generates a multi step form (wizard).
159
+ *
160
+ * @param {object} options
161
+ * @param {string|Element} [options.parent]
162
+ * @param {{id?: string, title: string, content: *, validate?: () => (boolean|string|Promise<boolean|string>)}[]} options.steps
163
+ * content is text, a Node, an array, or a function called once when the step is first shown.
164
+ * `validate` runs before leaving the step forwards: false or an error text blocks it.
165
+ * @param {() => void} [options.onFinish] called when Finish is pressed on the last step
166
+ * @param {(index: number) => void} [options.onChange]
167
+ * @returns {{element: HTMLElement, next: Function, back: Function, goTo: Function, getCurrent: Function}}
168
+ */
169
+ export function generateStepper(options?: {
170
+ parent?: string | Element;
171
+ steps: {
172
+ id?: string;
173
+ title: string;
174
+ content: any;
175
+ validate?: () => (boolean | string | Promise<boolean | string>);
176
+ }[];
177
+ onFinish?: () => void;
178
+ onChange?: (index: number) => void;
179
+ }): {
180
+ element: HTMLElement;
181
+ next: Function;
182
+ back: Function;
183
+ goTo: Function;
184
+ getCurrent: Function;
185
+ };
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Generates a rich text editor. The content is HTML restricted to a safe set of tags (paragraphs, headings,
3
+ * bold / italic / underline / strike, lists, quotes, code, links); everything else, including scripts, styles,
4
+ * event attributes and `javascript:` links, is removed when the content is set, pasted and read.
5
+ *
6
+ * @param {object} options
7
+ * @param {string|Element} [options.parent]
8
+ * @param {string} [options.id]
9
+ * @param {string} [options.label]
10
+ * @param {string} [options.value] initial HTML
11
+ * @param {string} [options.placeholder]
12
+ * @param {string[]} [options.toolbar] button names (bold, italic, underline, strike, h2, h3, quote, ul, ol, link,
13
+ * unlink, clear, undo, redo, source) and "|" separators. `source` switches between the visual editor and
14
+ * the sanitized HTML source.
15
+ * @param {number} [options.minHeight=140] px
16
+ * @param {boolean} [options.disabled]
17
+ * @param {(html: string) => void} [options.onChange]
18
+ * @returns {{element: HTMLElement, editor: HTMLElement, getValue: () => string, setValue: (html: string) => void,
19
+ * getText: () => string, focus: Function}}
20
+ */
21
+ export function createRichText(options?: {
22
+ parent?: string | Element;
23
+ id?: string;
24
+ label?: string;
25
+ value?: string;
26
+ placeholder?: string;
27
+ toolbar?: string[];
28
+ minHeight?: number;
29
+ disabled?: boolean;
30
+ onChange?: (html: string) => void;
31
+ }): {
32
+ element: HTMLElement;
33
+ editor: HTMLElement;
34
+ getValue: () => string;
35
+ setValue: (html: string) => void;
36
+ getText: () => string;
37
+ focus: Function;
38
+ };
39
+ /** Generates a labelled rich text editor, see createRichText. */
40
+ export function generateRichText(options?: {}): any;
41
+ export function createWysiwyg(options?: {}): {
42
+ element: HTMLElement;
43
+ editor: HTMLElement;
44
+ getValue: () => string;
45
+ setValue: (html: string) => void;
46
+ getText: () => string;
47
+ focus: Function;
48
+ };
49
+ export function generateWysiwyg(options?: {}): any;
@@ -0,0 +1,2 @@
1
+ export function openModal(id?: string): void;
2
+ export function closeModal(id?: string): void;
@@ -0,0 +1,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.
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
+ };
@@ -0,0 +1,12 @@
1
+ export function normalizePath(path: any): string;
2
+ export function parseQuery(search: any): {
3
+ [k: string]: string;
4
+ };
5
+ /**
6
+ * Matches a path against a pattern. `:name` segments capture a value, a trailing `*` matches the rest.
7
+ *
8
+ * @returns {Object<string, string>|null} the captured params, or null when the path does not match
9
+ */
10
+ export function matchRoute(pattern: any, path: any): {
11
+ [x: string]: string;
12
+ } | null;
@@ -0,0 +1,67 @@
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 {object} [options.auth] sign-in rules for routes, see the route options below
21
+ * @param {() => boolean} [options.auth.isSignedIn]
22
+ * @param {(role: string) => boolean} [options.auth.hasRole]
23
+ * @param {string} [options.auth.loginPath="/login"] where `auth: true` routes send a visitor who is not signed in (with `?next=<path>`)
24
+ * @param {string} [options.auth.homePath="/"] where `guestOnly` routes send a signed-in person
25
+ * @param {string} [options.auth.forbiddenPath] where a person without the role goes (default: homePath)
26
+ * @param {string} [options.titlePrefix] document title is `${titlePrefix}${route.title}`
27
+ *
28
+ * A route is a page function, or an object: `{ handler, title, auth: true, guestOnly: true, roles: ["admin"], guard(context) }`.
29
+ * `auth`, `guestOnly` and `roles` are checked with options.auth; `guard` is a function that gets the same context and returns
30
+ * false (stay where you are), a path (redirect) or anything else (go on); it runs after the rules.
31
+ * @returns {{start: Function, stop: Function, navigate: Function, current: Function, href: Function,
32
+ * onChange: (listener: (context) => void) => Function}}
33
+ * `onChange(listener)` is called with the context after every page that is shown (menus and breadcrumbs follow the router
34
+ * with it) and returns a function that stops it.
35
+ */
36
+ export function createRouter(options?: {
37
+ routes: {
38
+ [x: string]: Function | {
39
+ handler: Function;
40
+ title?: string;
41
+ };
42
+ };
43
+ outlet?: string;
44
+ mode?: "hash" | "history";
45
+ notFound?: (context: any) => void;
46
+ beforeEach?: (context: any) => (boolean | string | void | Promise<any>);
47
+ afterEach?: (context: any) => void;
48
+ onRender?: (context: any, route: any) => void;
49
+ onShown?: (context: any, route: any) => void;
50
+ focusContent?: boolean;
51
+ scrollTop?: boolean;
52
+ auth?: {
53
+ isSignedIn?: () => boolean;
54
+ hasRole?: (role: string) => boolean;
55
+ loginPath?: string;
56
+ homePath?: string;
57
+ forbiddenPath?: string;
58
+ };
59
+ titlePrefix?: string;
60
+ }): {
61
+ start: Function;
62
+ stop: Function;
63
+ navigate: Function;
64
+ current: Function;
65
+ href: Function;
66
+ onChange: (listener: (context: any) => void) => Function;
67
+ };
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Generates a table (optional filter box, sortable headers, pagination, row selection, inline
3
+ * editing, resizable columns, virtual scrolling, CSV export) and appends it to its parent.
4
+ *
5
+ * @param {object} options
6
+ * @param {string|Element} [options.parent] id or element, defaults to "wrapper"
7
+ * @param {string} [options.id] id of the table wrapper (default: "table")
8
+ * @param {string} [options.class] extra CSS class of the table
9
+ * @param {string} [options.caption]
10
+ * @param {{key: string, label?: string, width?: number, sortable?: boolean, editable?: boolean, format?: (value, row) => string}[]} options.columns
11
+ * @param {object[]} [options.rows] row objects, read by column key
12
+ * @param {boolean} [options.sortable=true] click on a header sorts by it
13
+ * @param {boolean} [options.filter=false] show a text filter above the table
14
+ * @param {number} [options.pageSize=0] rows per page, 0 disables pagination
15
+ * @param {boolean} [options.selectable=false] checkbox column; the header checkbox selects every filtered row
16
+ * @param {boolean} [options.resizableColumns=false] drag the edge of a header (or use the arrow keys on it) to resize;
17
+ * double click resets the width
18
+ * @param {{height?: number, rowHeight?: number, overscan?: number}|boolean} [options.virtual] render only the rows
19
+ * in view, for lists of thousands of rows. Rows have a fixed height (default 36 px) and the table scrolls
20
+ * inside `height` (default 400 px). Replaces pagination.
21
+ * @param {(key: string, width: number) => void} [options.onColumnResize]
22
+ * @param {(rows: object[]) => void} [options.onSelectionChange]
23
+ * @param {(row: object, key: string, value, oldValue) => (boolean|void)} [options.onEdit] called after an edit
24
+ * of an `editable` column (double click, or Enter / F2 on the focused cell). Return false to reject it.
25
+ * @param {(row: object) => void} [options.onRowClick]
26
+ * @param {string} [options.emptyText]
27
+ * @param {(row: object, column: object) => (string|string[]|null|undefined)} [options.cellClass] CSS class(es) for a cell
28
+ * @param {(row: object) => (string|string[]|null|undefined)} [options.rowClass] CSS class(es) for a row
29
+ * @param {boolean} [options.focusableRows=false] rows are reachable with Tab and, with `onRowClick`, opened with Enter and Space
30
+ * @param {(row: object) => string} [options.rowLabel] aria-label of a focusable row
31
+ * @param {"normal"|"compact"} [options.density="normal"]
32
+ * @param {boolean} [options.wrap] true lets long text wrap, false keeps one line with an ellipsis (default: wrap, except in virtual tables)
33
+ * @param {(query: {page: number, pageSize: number, cursor: *, sort: ({key: string, descending: boolean}|null), filter: string}) =>
34
+ * Promise<{rows: object[], total?: number, nextCursor?: *}>} [options.dataSource] load the rows from a server instead of
35
+ * keeping them all in the browser. Sorting, the filter box and the pager call it again. Answer with `total` for numbered pages
36
+ * (`page` is 0-based), or with `nextCursor` for a "Load more" button (`cursor` is what the last answer gave, undefined for the
37
+ * first request; the rows are appended). A failed request shows the error with a Retry button.
38
+ * Together with `virtual` the list scrolls like one of `total` rows (every answer must carry `total`): the rows in view are asked for
39
+ * in chunks of `chunkSize` (`page` is the chunk number), rows that have not arrived yet show a placeholder, and sorting or the filter
40
+ * start again from the top.
41
+ * @param {number} [options.chunkSize=50] rows per request of a data source with `virtual`
42
+ * @param {number} [options.filterDelay=300] ms to wait after typing before the data source is asked
43
+ * @param {{label: string, onclick: (row: object) => void, danger?: boolean, hidden?: (row: object) => boolean, ariaLabel?: (row: object) => string}[]} [options.rowActions]
44
+ * a column of buttons at the end of every row
45
+ * Column extras: `render(row, value)` returns text or a Node (built by the caller, so safe by construction), `align`
46
+ * ("left" | "center" | "right"), `title` (false switches the tooltip with the full text off).
47
+ * @returns {{element: HTMLElement, update: Function, destroy: Function, setRows: Function, getSelected: () => object[], clearSelection: Function,
48
+ * getColumnWidths: () => Object<string, number>, toCsv: () => string, exportCsv: (filename?: string) => void}}
49
+ */
50
+ export function generateTable(options?: {
51
+ parent?: string | Element;
52
+ id?: string;
53
+ class?: string;
54
+ caption?: string;
55
+ columns: {
56
+ key: string;
57
+ label?: string;
58
+ width?: number;
59
+ sortable?: boolean;
60
+ editable?: boolean;
61
+ format?: (value: any, row: any) => string;
62
+ }[];
63
+ rows?: object[];
64
+ sortable?: boolean;
65
+ filter?: boolean;
66
+ pageSize?: number;
67
+ selectable?: boolean;
68
+ resizableColumns?: boolean;
69
+ virtual?: {
70
+ height?: number;
71
+ rowHeight?: number;
72
+ overscan?: number;
73
+ } | boolean;
74
+ onColumnResize?: (key: string, width: number) => void;
75
+ onSelectionChange?: (rows: object[]) => void;
76
+ onEdit?: (row: object, key: string, value: any, oldValue: any) => (boolean | void);
77
+ onRowClick?: (row: object) => void;
78
+ emptyText?: string;
79
+ cellClass?: (row: object, column: object) => (string | string[] | null | undefined);
80
+ rowClass?: (row: object) => (string | string[] | null | undefined);
81
+ focusableRows?: boolean;
82
+ rowLabel?: (row: object) => string;
83
+ density?: "normal" | "compact";
84
+ wrap?: boolean;
85
+ dataSource?: (query: {
86
+ page: number;
87
+ pageSize: number;
88
+ cursor: any;
89
+ sort: ({
90
+ key: string;
91
+ descending: boolean;
92
+ } | null);
93
+ filter: string;
94
+ }) => Promise<{
95
+ rows: object[];
96
+ total?: number;
97
+ nextCursor?: any;
98
+ }>;
99
+ chunkSize?: number;
100
+ filterDelay?: number;
101
+ rowActions?: {
102
+ label: string;
103
+ onclick: (row: object) => void;
104
+ danger?: boolean;
105
+ hidden?: (row: object) => boolean;
106
+ ariaLabel?: (row: object) => string;
107
+ }[];
108
+ }): {
109
+ element: HTMLElement;
110
+ update: Function;
111
+ destroy: Function;
112
+ setRows: Function;
113
+ getSelected: () => object[];
114
+ clearSelection: Function;
115
+ getColumnWidths: () => {
116
+ [x: string]: number;
117
+ };
118
+ toCsv: () => string;
119
+ exportCsv: (filename?: string) => void;
120
+ };
@@ -0,0 +1 @@
1
+ export * from "./libs/hephaestus/MenuGenerator/menuGenerator.js";
@@ -0,0 +1 @@
1
+ export * from "./libs/hephaestus/navigationGenerator/navigationGenerator.js";
@@ -0,0 +1,7 @@
1
+ declare const _default: {
2
+ id: number;
3
+ name: string;
4
+ href: string;
5
+ description: string;
6
+ }[];
7
+ export default _default;
@@ -0,0 +1 @@
1
+ export * from "./libs/hephaestus/router/router.js";
@@ -0,0 +1 @@
1
+ export * from "./libs/core/sanitize.js";
@@ -0,0 +1,3 @@
1
+ export * from "./libs/hephaestus/auth/session.js";
2
+ export * from "./libs/hephaestus/auth/authState.js";
3
+ export * from "./libs/core/cookies.js";
@@ -0,0 +1 @@
1
+ export * from "./libs/hephaestus/tableGenerator/tableGenerator.js";
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Makes a jsdom window the global one, so Athena components can run in Node.
3
+ * The components create their events from the element's own window, so no global Event is needed for them,
4
+ * but code written without that care (and tests) can still use `new Event(...)`.
5
+ *
6
+ * @param {new (html?: string, options?: object) => {window: object}} JSDOM the JSDOM class of jsdom
7
+ * @param {string} [html] page to start with
8
+ * @param {object} [options] passed to JSDOM (default: url "http://localhost/", pretendToBeVisual so animation frames work)
9
+ * @returns {{window: object, document: Document, uninstall: () => void}}
10
+ */
11
+ export function installDom(JSDOM: new (html?: string, options?: object) => {
12
+ window: object;
13
+ }, html?: string, options?: object): {
14
+ window: object;
15
+ document: Document;
16
+ uninstall: () => void;
17
+ };
18
+ /**
19
+ * Waits until `condition()` returns something truthy, and returns that value.
20
+ * Throws after `timeout` ms, naming `message`, so a test fails with a reason instead of hanging.
21
+ */
22
+ export function until(condition: any, { timeout, interval, message }?: {
23
+ timeout?: number;
24
+ interval?: number;
25
+ message?: string;
26
+ }): Promise<any>;
27
+ export function tick(ms?: number): Promise<any>;
File without changes
@@ -0,0 +1,2 @@
1
+ export * from "./libs/core/theme.js";
2
+ export * from "./libs/hephaestus/componentGenerator/themePicker.js";
@@ -0,0 +1 @@
1
+ export * from "./libs/core/validation.js";