athena-ui-js 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +273 -23
- package/package.json +11 -7
- package/src/athena-ui.js +33 -10
- package/src/libs/config/config.js +8 -1
- package/src/libs/core/combobox.js +1 -1
- package/src/libs/core/controls.js +153 -0
- package/src/libs/core/dateRange.js +121 -0
- package/src/libs/core/dom.js +88 -11
- package/src/libs/{hephaestus/HTMLElementGenerator/src/HTMLElementGenerator.js → core/elementGenerator.js} +23 -21
- package/src/libs/{hephaestus/HTMLElementGenerator/src → core}/errors.js +7 -5
- package/src/libs/core/format.js +51 -0
- package/src/libs/core/hungarianControls.js +41 -0
- package/src/libs/core/i18n.js +64 -0
- package/src/libs/core/theme.js +131 -0
- package/src/libs/hephaestus/LayoutGenerator/basicLayoutGenerator.js +4 -6
- package/src/libs/hephaestus/LayoutGenerator/footerContentGenerator.js +2 -4
- package/src/libs/hephaestus/LayoutGenerator/headerContentGenerator.js +12 -5
- package/src/libs/hephaestus/MenuGenerator/basicMenuGenerator.js +3 -3
- package/src/libs/hephaestus/MenuGenerator/menuGenerator.js +253 -0
- package/src/libs/hephaestus/auth/authState.js +58 -0
- package/src/libs/hephaestus/chartGenerator/chartGenerator.js +530 -65
- package/src/libs/hephaestus/componentGenerator/componentGenerator.js +124 -6
- package/src/libs/hephaestus/componentGenerator/themePicker.js +73 -0
- package/src/libs/hephaestus/dialogGenerator/dialogGenerator.js +100 -13
- package/src/libs/hephaestus/feedbackGenerator/feedbackGenerator.js +23 -2
- package/src/libs/hephaestus/formGenerator/authForms.js +130 -0
- package/src/libs/hephaestus/formGenerator/formBuilder.js +5 -5
- package/src/libs/hephaestus/formGenerator/formUtils.js +10 -9
- package/src/libs/hephaestus/formGenerator/loginFormGenerator.js +9 -9
- package/src/libs/hephaestus/hephaestus.js +7 -2
- package/src/libs/hephaestus/inputGenerator/dropZoneGenerator.js +2 -2
- package/src/libs/hephaestus/inputGenerator/inputGenerator.js +37 -8
- package/src/libs/hephaestus/inputGenerator/richTextGenerator.js +2 -2
- package/src/libs/hephaestus/modalGenerator/modalGenerator.js +17 -11
- package/src/libs/hephaestus/navigationGenerator/navigationGenerator.js +20 -11
- package/src/libs/hephaestus/router/router.js +56 -6
- package/src/libs/hephaestus/tableGenerator/tableGenerator.js +368 -29
- package/src/libs/libs.js +3 -3
- package/src/res/themes/appearance.css +154 -0
- package/src/res/themes/default/style.css +649 -2
- package/src/testing.js +71 -0
- package/src/theme-boot.js +25 -0
- package/src/libs/hephaestus/HTMLControlGenerator/LICENSE +0 -21
- package/src/libs/hephaestus/HTMLControlGenerator/src/HTMLControlGenerator.min.js +0 -5
- package/src/libs/hephaestus/HTMLElementGenerator/LICENSE +0 -21
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# Athena UI
|
|
2
2
|
|
|
3
|
-
A small
|
|
3
|
+
A small UI framework for development and education purposes (jQuery is optional). It generates a page
|
|
4
4
|
layout (header, menu, content wrapper, footer) from a single `init()` call, loads its own libraries
|
|
5
5
|
and theme, and ships the building blocks of a multipurpose application: forms, tables, charts,
|
|
6
6
|
feedback, navigation, a router and more.
|
|
7
7
|
|
|
8
|
-
Current version: **1.
|
|
8
|
+
Current version: **1.3.0**
|
|
9
9
|
|
|
10
10
|
[Quick start](#usage) · [API](#api) · [Components](#charts) · [Themes](#themes) · [Tests](#tests) · [Release notes](#releases)
|
|
11
11
|
|
|
@@ -17,16 +17,23 @@ Known limits are listed below, so you can judge whether it fits your project:
|
|
|
17
17
|
|
|
18
18
|
- Rich text uses the deprecated `document.execCommand`. Content is sanitized in the browser, but sanitize it on the server too.
|
|
19
19
|
- The session cookie is readable from JavaScript. It is a UI state, not a security boundary: authenticate on the server.
|
|
20
|
-
- Virtual table rows have to be a fixed height, one line per cell.
|
|
20
|
+
- Virtual table rows have to be a fixed height, one line per cell (set it with `virtual.rowHeight`; the CSS variable `--row-height` follows).
|
|
21
21
|
- Translations: English and Hungarian.
|
|
22
|
+
- jQuery is optional since 1.3.0. The older generators (`generateLoginForm`, the layout and the header / footer menu built from `menuItems`) still work, and
|
|
23
|
+
they no longer need it. Everything new (`generateMenu`, the sign in forms, dialogs, charts, tables, ...) is plain DOM.
|
|
22
24
|
|
|
23
25
|
## Features
|
|
24
26
|
|
|
25
27
|
- Generated page layout: container, header (logo, title, menu), wrapper, footer (menu, copyright text)
|
|
26
28
|
- Menus built from your own item lists, with a navigation callback
|
|
27
29
|
- Login, registration and lost password forms with optional SHA-256 password hashing
|
|
28
|
-
- SVG charts (bar, line, pie, donut) without extra dependencies
|
|
29
|
-
- Tables with sortable columns, filter box, pagination, row selection, inline editing, resizable columns, virtual scrolling for thousands of rows and CSV export
|
|
30
|
+
- SVG charts (bar, line, area, sparkline, pie, donut) with a time axis, tooltips, zoom, a clickable legend, a table of values and streaming, without extra dependencies
|
|
31
|
+
- Tables with sortable columns, filter box, pagination, row selection, inline editing, resizable columns, virtual scrolling for thousands of rows, rows loaded from a server (pages, "Load more", or scrolling through a data source), row actions and CSV export
|
|
32
|
+
- Navigation menu (`generateMenu`): real links and buttons, groups of any depth, badges, a user menu with an avatar, tabs at the bottom on a phone
|
|
33
|
+
- Sign in, sign up and password forms that password managers understand, and a signed-in state that lives in memory only
|
|
34
|
+
- Themes and modes (light / dark / like the system) with a theme manager, a picker and a no-flash boot script
|
|
35
|
+
- Form dialogs, confirmations (also "type the name to confirm"), date and time ranges with presets, page header, facts list, empty and loading states
|
|
36
|
+
- Safe DOM building (`el`, `createSafeBuilder`): text stays text, no event attributes, no inline style
|
|
30
37
|
- Form builder: text, number, date, textarea, select, radio / checkbox groups, switch, autocomplete, multi select, with validation
|
|
31
38
|
- Buttons, toasts, alerts, spinner, progress bar, alert / confirm / prompt dialogs
|
|
32
39
|
- Tabs, accordion, dropdown, sidebar, breadcrumbs, pagination and a hash / history router
|
|
@@ -41,16 +48,14 @@ Known limits are listed below, so you can judge whether it fits your project:
|
|
|
41
48
|
|
|
42
49
|
## Requirements
|
|
43
50
|
|
|
44
|
-
-
|
|
51
|
+
- jQuery is optional (v4.0.0, only if your own code or an older application uses it). Athena UI itself does not need it.
|
|
45
52
|
- A browser with ES module support
|
|
46
53
|
- The page has to be served over HTTP(S). Modules do not load from `file://`.
|
|
47
54
|
|
|
48
|
-
Bundled as git submodules:
|
|
55
|
+
Bundled as git submodules (third party):
|
|
49
56
|
|
|
50
57
|
| Library | Version | Used for |
|
|
51
58
|
| --- | --- | --- |
|
|
52
|
-
| [HTMLControlGenerator](https://github.com/csabatibortoth/HTMLControlGenerator) | 0.4.0 | inputs, lists |
|
|
53
|
-
| [HTMLElementGenerator](https://github.com/csabatibortoth/HTMLElementGenerator) | 0.3.0 | divs, headings, images |
|
|
54
59
|
| [crypto-js](https://github.com/brix/crypto-js) | 4.2.0 | password hashing |
|
|
55
60
|
| [js-cookie](https://github.com/js-cookie/js-cookie) | 3.0.8 | cookie handling |
|
|
56
61
|
|
|
@@ -71,8 +76,7 @@ Serve the `src` folder with any static web server and open `index.html` to see t
|
|
|
71
76
|
## Usage
|
|
72
77
|
|
|
73
78
|
```html
|
|
74
|
-
|
|
75
|
-
integrity="sha256-OaVG6prZf4v69dPg6PhVattBXkcOWQB62pdZ3ORyrao=" crossorigin="anonymous"></script>
|
|
79
|
+
<!-- jQuery is not needed -->
|
|
76
80
|
<script type="module">
|
|
77
81
|
import { init, clearWrapper, generateLoginForm } from "./athena-ui.js";
|
|
78
82
|
|
|
@@ -120,7 +124,7 @@ the theme are loaded and the layout is generated.
|
|
|
120
124
|
| `header_title_text` | `"Athena UI"` | Title in the header |
|
|
121
125
|
| `header_img_url` | | Header logo URL |
|
|
122
126
|
| `copyright` | placeholder text | Footer text, the version is appended |
|
|
123
|
-
| `version` | `"1.
|
|
127
|
+
| `version` | `"1.3.0"` | Version shown in the footer |
|
|
124
128
|
| `bordered` | `true` | Draw a border around the layout blocks |
|
|
125
129
|
| `generateHeader`, `generateFooter` | `true` | Generate the header / footer block |
|
|
126
130
|
| `generateHeadercontent`, `generateFooterContent`, `generateWrappercontent` | `true` | Generate the content of the block |
|
|
@@ -158,6 +162,14 @@ Everything is exported from `athena-ui.js`:
|
|
|
158
162
|
| `showDialog`, `alertDialog`, `confirmDialog`, `promptDialog` | See [Dialogs](#dialogs) |
|
|
159
163
|
| `generateTabs`, `generateBreadcrumbs`, `generatePagination`, `generateAccordion`, `generateDropdown`, `generateSidebar` | See [Navigation](#navigation) |
|
|
160
164
|
| `createRouter(options)` | See [Router](#router) |
|
|
165
|
+
| `generateMenu(options)`, `generateHeaderMenu({ items })` | See [Menu component](#menu-component) |
|
|
166
|
+
| `generateSignInForm`, `generateSignUpForm`, `generatePasswordResetForm`, `generatePasswordChangeForm`, `createAuthState` | See [Signing in](#signing-in-recommended) |
|
|
167
|
+
| `showFormDialog`, `showConfirm` | See [Dialogs](#dialogs) |
|
|
168
|
+
| `createThemeManager`, `generateThemePicker` | See [Themes and modes](#themes-and-modes-light--dark--like-the-system) |
|
|
169
|
+
| `generateDateTimeRange`, `toLocalInput`, `fromLocalInput` | See [Date and time range](#date-and-time-range) |
|
|
170
|
+
| `generatePageHeader`, `generateFacts`, `generateEmptyState`, `generateLoading`, `copyToClipboard` | See [Page parts and formatting](#page-parts-and-formatting) |
|
|
171
|
+
| `formatBytes`, `formatNumber`, `formatDuration`, `formatRelativeTime`, `formatDate` | Format helpers on top of `Intl`, in the current language |
|
|
172
|
+
| `el`, `setContent`, `resolveElement`, `asHandle`, `createSafeBuilder` | See [Safe DOM building](#safe-dom-building) |
|
|
161
173
|
| `generateCard`, `generateSection`, `generateGrid`, `generateBadge`, `generateAvatar`, `generateStat`, `generateLink`, `generateTooltip` | See [Components](#components) |
|
|
162
174
|
| `generateAutocomplete`, `generateMultiSelect`, `generateFileUpload`, `generateDropZone`, `generateStepper`, `generateDateRange`, `generateRichText`, `generateWysiwyg` | See [Inputs](#inputs) |
|
|
163
175
|
| `sanitizeHtml(html)`, `htmlToText(html)`, `isSafeUrl(url)` | The allow-list sanitizer behind the rich text editor |
|
|
@@ -169,26 +181,42 @@ Everything is exported from `athena-ui.js`:
|
|
|
169
181
|
| `openModal(id)`, `closeModal(id)` | Show / hide a `.modal` element (default id: `myModal`). Elements with the `close` class close their modal. |
|
|
170
182
|
| `loadScript(src)` | Load a classic script once, returns a Promise |
|
|
171
183
|
| `Cookies` | The [js-cookie](https://github.com/js-cookie/js-cookie) API |
|
|
172
|
-
| `HTMLElementGenerator(options)` |
|
|
184
|
+
| `HTMLElementGenerator(options)` | Generates a div, span, p, heading or img and appends it to the element with the id `parent` |
|
|
185
|
+
| `HTMLControlGenerator(options)`, `HTMLControlGenerator.create(options)`, `HTMLControlGenerator.register(type, factory)` | Generates inputs, selects and lists from an options object. `create` builds without appending and returns the element (a jQuery object when the page has jQuery). `registerHungarianInputControls()` adds the types `hunPIN`, `hunCRID` and `hunTID` |
|
|
186
|
+
|
|
187
|
+
HTMLElementGenerator and HTMLControlGenerator used to be projects of their own. They are part of Athena UI now (the calls and options are the
|
|
188
|
+
same, and HTMLControlGenerator no longer needs jQuery); the old repositories are no longer developed.
|
|
173
189
|
|
|
174
190
|
### Charts
|
|
175
191
|
|
|
176
192
|
```js
|
|
177
|
-
generateChart({
|
|
178
|
-
type: "
|
|
179
|
-
parent: "wrapper", // id
|
|
193
|
+
const chart = generateChart({
|
|
194
|
+
type: "line", // "bar" | "line" | "area" | "sparkline" | "pie" | "donut"
|
|
195
|
+
parent: "wrapper", // element, id or selector (default "wrapper")
|
|
180
196
|
title: "Revenue",
|
|
181
197
|
labels: ["Q1", "Q2", "Q3"],
|
|
182
198
|
series: [
|
|
183
199
|
{ name: "2025", data: [12, 19, 8] },
|
|
184
200
|
{ name: "2026", data: [14, 17, 12], color: "#e15759" }
|
|
185
|
-
]
|
|
201
|
+
],
|
|
202
|
+
table: true // adds "Show as table" with the values
|
|
186
203
|
});
|
|
187
204
|
```
|
|
188
205
|
|
|
189
|
-
Charts are inline SVG
|
|
190
|
-
|
|
191
|
-
|
|
206
|
+
Charts are inline SVG, nothing is styled inline (a strict Content-Security-Policy works), negative values are supported. `pie` and `donut` use the
|
|
207
|
+
first series, one slice per label. `sparkline` is a small line without axes (120 x 32 by default) for a table cell or a tile.
|
|
208
|
+
Other options: `id`, `width` (600), `height` (360), `legend`, `zero: false` (a line chart's value axis may start near the smallest value).
|
|
209
|
+
|
|
210
|
+
- **Colours** come from the theme: `--series-1` ... `--series-8` (see `appearance.css`), so every chart follows light / dark. `color` overrides one series.
|
|
211
|
+
- **Tooltips** show on hover and on keyboard focus (every point and bar is focusable and named). In a long line chart the tooltip follows the pointer.
|
|
212
|
+
- **Legend**: click (or Enter / Space) on an entry hides and shows that series.
|
|
213
|
+
- **Time axis**: `times: [Date | ms | "2026-11-19T10:00"]` (line and area). Ticks fall on round times, points sit at their real distance.
|
|
214
|
+
- **Zoom** (`zoom: true`, line and area): drag over the plot, double click or the reset button zoom out. On the plot, + and - zoom, the arrow keys pan,
|
|
215
|
+
0 resets. `chart.zoom(from, to)`, `chart.resetZoom()`, `chart.getZoom()`, `onZoom(range)` and `zoomRange` (ms with `times`, otherwise the point index).
|
|
216
|
+
- **Long series** are thinned to the width of the plot (the lowest and the highest value of every slice stay, so peaks are not lost), and dots are only drawn up to 80 points in view.
|
|
217
|
+
- **Streaming**: `chart.push({ x: Date.now(), values: [12, 3] }, { maxPoints: 500 })` adds a point to every series, drops the oldest ones and redraws at most once per frame.
|
|
218
|
+
- `chart.update({ series })` redraws with changes, `chart.destroy()` removes the chart and its table. `generateChart` returns the `<svg>` element that carries these
|
|
219
|
+
methods, or `null` when the options are invalid.
|
|
192
220
|
|
|
193
221
|
### Tables
|
|
194
222
|
|
|
@@ -211,6 +239,16 @@ Click a header to sort (disable with `sortable: false`, or per column). Other op
|
|
|
211
239
|
- A column with `editable: true` can be edited with a double click, or Enter / F2 on the focused cell. `onEdit(row, key, value, oldValue)` is called after the edit; return `false` to reject it. Numeric cells stay numbers.
|
|
212
240
|
- `resizableColumns: true` puts a drag handle on every header edge. The handle is focusable too: Left / Right resize by 10 px, Shift by 50 px, double click resets the column to its configured `width`. Columns take `width`, `minWidth` and `maxWidth`; `onColumnResize(key, width)` and `getColumnWidths()` let you persist the layout.
|
|
213
241
|
- `virtual: { height: 400, rowHeight: 36, overscan: 5 }` (or `virtual: true`) renders only the rows in view and keeps the scroll bar the size of the whole list, so 10 000+ rows stay fast. Rows have a fixed height (the theme enforces it, one line per cell), the table scrolls inside `height` and its header stays visible. It replaces pagination; filtering, sorting, selection, editing and CSV export work as usual.
|
|
242
|
+
- Hooks and looks: `cellClass(row, column)` and `rowClass(row)` return a class name (or a list) for a cell or a row. `focusableRows: true` makes rows reachable with Tab (`rowLabel(row)` is their aria-label); together with `onRowClick` they open with Enter and Space. `density: "compact"`, and `wrap: true | false` (long text wraps, or stays on one line with an ellipsis). The pager is hidden when there is only one page.
|
|
243
|
+
- Column extras: `render(row, value)` returns text or a Node (built by you, so it is safe by construction), `align: "left" | "center" | "right"`. Text longer than 24 characters gets its full text as a tooltip (`title: false` switches it off).
|
|
244
|
+
- A virtual table that starts empty draws a full window as soon as it gets rows, and measures again when the scroll area changes size.
|
|
245
|
+
- **Rows from a server**: `dataSource: async ({ page, pageSize, cursor, sort, filter }) => ({ rows, total })`. Sorting, the (debounced) filter box and the pager ask it again,
|
|
246
|
+
a slow request shows a loading state, a failed one an error with a Retry button, and an answer that comes too late is ignored. Answer with `total` for numbered pages
|
|
247
|
+
(`page` is 0-based), or with `nextCursor` for a "Load more" button (`cursor` is what the last answer gave). `table.reload()` asks again.
|
|
248
|
+
- **Rows from a server and virtual scrolling**: `dataSource` together with `virtual` (every answer needs `total`) scrolls through `total` rows. The rows in view are asked for in chunks of
|
|
249
|
+
`chunkSize` (default 50, `page` is the chunk number), chunks you scroll past are skipped, rows that have not arrived yet show a placeholder, and a failed chunk can be retried.
|
|
250
|
+
The select-all checkbox only selects the rows that have arrived.
|
|
251
|
+
- `rowActions: [{ label: "Delete", danger: true, onclick: row => remove(row), hidden: row => row.locked, ariaLabel: row => "Delete " + row.name }]` adds a column of buttons.
|
|
214
252
|
- `exportCsv()` downloads the filtered and sorted rows. Cells that start with `=`, `+`, `-` or `@` are prefixed with `'` so a spreadsheet does not run them as formulas.
|
|
215
253
|
|
|
216
254
|
### Forms
|
|
@@ -266,6 +304,25 @@ const name = await promptDialog("Your name", { validate: v => v ? "" : "Required
|
|
|
266
304
|
const choice = await showDialog({ title: "Custom", content: "Pick one", buttons: [{ text: "A", value: "a" }, { text: "B", value: "b" }] });
|
|
267
305
|
```
|
|
268
306
|
|
|
307
|
+
Options: `size` ("small" 360 px, "medium" 480 px, "large" 720 px, "full") and `class` (extra class on the dialog).
|
|
308
|
+
`showDialog` returns a promise that also carries the open dialog: `const dialog = showDialog({ size: "large", ... }); dialog.element; dialog.close(value);`.
|
|
309
|
+
The dialog is shown by a CSS class, not by an inline style, so a strict Content-Security-Policy works.
|
|
310
|
+
|
|
311
|
+
**Form dialog** and **confirmation**:
|
|
312
|
+
|
|
313
|
+
```js
|
|
314
|
+
const saved = await showFormDialog({
|
|
315
|
+
title: "Add host", intro: "The agent connects with this name.", size: "small", submitText: "Add",
|
|
316
|
+
fields: [{ name: "name", label: "Name", required: true }],
|
|
317
|
+
onSubmit: async (values, form) => {
|
|
318
|
+
const answer = await api.addHost(values); // when this throws, the message shows in the dialog and it stays open
|
|
319
|
+
if (answer.errors) throw Object.assign(new Error("Check the fields"), { fields: answer.errors }); // or form.setErrors({ name: "Already taken" })
|
|
320
|
+
}
|
|
321
|
+
}); // true when saved, false when dismissed
|
|
322
|
+
|
|
323
|
+
if (await showConfirm({ title: "Delete host", message: "This cannot be undone.", confirmText: "Delete", danger: true, typeToConfirm: host.name })) { /* ... */ }
|
|
324
|
+
```
|
|
325
|
+
|
|
269
326
|
Dialogs trap the focus, close with Esc (resolving `null` / `false`) and restore the focus. Text content is
|
|
270
327
|
never parsed as HTML. `openModal` / `closeModal` got the same focus handling.
|
|
271
328
|
|
|
@@ -275,6 +332,7 @@ never parsed as HTML. `openModal` / `closeModal` got the same focus handling.
|
|
|
275
332
|
generateTabs({ parent: "wrapper", tabs: [{ id: "a", label: "A", content: "First" }, { id: "b", label: "B", content: () => lazyNode() }] });
|
|
276
333
|
generateAccordion({ parent: "wrapper", items: [{ title: "Q", content: "A", open: true }], multiple: false });
|
|
277
334
|
generateDropdown({ parent: "wrapper", label: "Actions", items: [{ label: "Edit", onclick }, { divider: true }, { label: "Delete", onclick }] });
|
|
335
|
+
generateDropdown({ parent: "wrapper", icon: "⋮", ariaLabel: "More actions", items: [{ label: "Edit", onclick }] }); // icon only; also caret: true, toggleClass
|
|
278
336
|
generatePagination({ parent: "wrapper", total: 200, pageSize: 10, onChange: page => load(page) });
|
|
279
337
|
generateBreadcrumbs({ parent: "wrapper", items: [{ label: "Home", href: "#/" }, { label: "Users" }] });
|
|
280
338
|
generateSidebar({ parent: "wrapper", active: "home", onSelect: item => go(item.id),
|
|
@@ -302,6 +360,33 @@ init({
|
|
|
302
360
|
A submenu opens with a click, Enter, Space or the Down arrow, closes with Esc, a click outside or by choosing an entry,
|
|
303
361
|
and supports the arrow keys, Home and End. The same works in the footer menu.
|
|
304
362
|
|
|
363
|
+
### Menu component
|
|
364
|
+
|
|
365
|
+
`generateMenu` is a navigation menu that does not use globals. Items are real links (`href`) or buttons, so Tab, Enter and Space work, and screen readers hear what they are.
|
|
366
|
+
|
|
367
|
+
```js
|
|
368
|
+
const menu = generateMenu({
|
|
369
|
+
parent: "header", // an element, an id or a selector
|
|
370
|
+
layout: "responsive", // "bar" | "bottom-tabs" | "responsive" (tabs at the bottom under 700px, groups open as sheets)
|
|
371
|
+
followHash: true, // the item whose href equals location.hash is the active one
|
|
372
|
+
onNavigate: (item, event) => console.log(item.id), // only when a person uses an item, never from select() or while building
|
|
373
|
+
items: [
|
|
374
|
+
{ id: "home", label: "Home", icon: "⌂", href: "#/" },
|
|
375
|
+
{ id: "inbox", label: "Inbox", href: "#/inbox", badge: 3, badgeLabel: "3 unread" },
|
|
376
|
+
{ id: "tools", label: "Tools", children: [
|
|
377
|
+
{ id: "export", label: "Export" },
|
|
378
|
+
{ id: "more", label: "More", children: [{ id: "csv", label: "CSV" }, { id: "json", label: "JSON" }] }
|
|
379
|
+
] },
|
|
380
|
+
{ id: "user", label: "Anna Kiss", avatar: { name: "Anna Kiss" }, align: "end", children: [{ id: "out", label: "Sign out" }] }
|
|
381
|
+
]
|
|
382
|
+
});
|
|
383
|
+
menu.select("inbox"); // marks the current page (class is-active, aria-current="page", has-active on the groups around it)
|
|
384
|
+
menu.setBadge("inbox", { text: 12, tone: "bad" }); // a count, text, or { text, tone: "info" | "ok" | "warn" | "bad" }; 0 / null removes it
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
Groups nest to any depth: ArrowDown / ArrowUp open the first level, ArrowRight opens a deeper group and ArrowLeft closes it, Esc closes the innermost group
|
|
388
|
+
first, Home / End jump, a click outside closes everything. A badge above 99 shows "99+". `generateHeaderMenu({ items, onNavigate })` puts the same menu into the header.
|
|
389
|
+
|
|
305
390
|
### Router
|
|
306
391
|
|
|
307
392
|
```js
|
|
@@ -319,6 +404,22 @@ router.start();
|
|
|
319
404
|
router.navigate("/users/5?tab=info");
|
|
320
405
|
```
|
|
321
406
|
|
|
407
|
+
Routes can carry the sign-in rules, so a page does not check them itself:
|
|
408
|
+
|
|
409
|
+
```js
|
|
410
|
+
const router = createRouter({
|
|
411
|
+
auth: auth.routerRules({ loginPath: "/login", homePath: "/", forbiddenPath: "/denied" }), // { isSignedIn, hasRole, ... }
|
|
412
|
+
focusContent: true, scrollTop: true, // after a page is shown: focus the outlet, scroll to the top
|
|
413
|
+
onShown: ctx => menu.select(ctx.path), // also onRender (before the page function) and router.onChange(listener)
|
|
414
|
+
routes: {
|
|
415
|
+
"/login": { handler: renderLogin, guestOnly: true }, // a signed-in person goes home
|
|
416
|
+
"/account": { handler: renderAccount, auth: true }, // not signed in: /login?next=%2Faccount
|
|
417
|
+
"/admin": { handler: renderAdmin, auth: true, roles: ["admin"] },
|
|
418
|
+
"/report": { handler: renderReport, guard: ctx => ctx.query.id ? undefined : "/reports" } // false stays, a path redirects
|
|
419
|
+
}
|
|
420
|
+
});
|
|
421
|
+
```
|
|
422
|
+
|
|
322
423
|
`mode: "history"` uses real paths instead of the hash, the server then has to answer every path with the page.
|
|
323
424
|
Pass `router.navigate` from your `nav` callback to route the menu clicks.
|
|
324
425
|
|
|
@@ -427,6 +528,30 @@ The global `appConfig`, `menuItems`, `nav`, `login`, `register` and `lostPasswor
|
|
|
427
528
|
not given. `appConfig.athenaUIFolder` is not needed anymore, paths are resolved relative to
|
|
428
529
|
`athena-ui.js`.
|
|
429
530
|
|
|
531
|
+
### Signing in (recommended)
|
|
532
|
+
|
|
533
|
+
`generateSignInForm`, `generateSignUpForm`, `generatePasswordResetForm` and `generatePasswordChangeForm` are real `<form>` elements with the autocomplete tokens
|
|
534
|
+
that password managers look for (`username`, `current-password`, `new-password`, `email`), so Enter submits and the browser can save and fill passwords.
|
|
535
|
+
|
|
536
|
+
```js
|
|
537
|
+
const auth = createAuthState({ restore: () => fetch("/api/me", { credentials: "same-origin" }).then(r => (r.ok ? r.json() : null)) });
|
|
538
|
+
await auth.restore(); // after a reload: ask the server who is signed in
|
|
539
|
+
|
|
540
|
+
generateSignInForm({
|
|
541
|
+
parent: "wrapper", remember: true,
|
|
542
|
+
onSubmit: async ({ username, password, remember }) => {
|
|
543
|
+
const response = await fetch("/api/login", { method: "POST", body: JSON.stringify({ username, password, remember }), credentials: "same-origin" });
|
|
544
|
+
if (!response.ok) throw new Error("Wrong user name or password"); // shown in the form, which stays usable
|
|
545
|
+
auth.signIn(await response.json()); // { name, roles: [...] }
|
|
546
|
+
}
|
|
547
|
+
});
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
An error with a `fields` object (`{ username: "Already taken" }`) marks those fields as well. The password is sent as typed, over HTTPS: hash it on the server.
|
|
551
|
+
Hashing it in the browser (`enable_encrypt_password`) only turns the hash into the password, so that setting is **deprecated** and will be removed in 2.0.
|
|
552
|
+
`createAuthState` keeps who is signed in **in memory only**: nothing readable is written to a cookie or the storage, the session itself is a server set `HttpOnly` cookie,
|
|
553
|
+
and the server decides what a person may do. `auth.hasRole(role)`, `auth.onChange(listener)` and `auth.routerRules()` connect it to menus and the router.
|
|
554
|
+
|
|
430
555
|
## Themes
|
|
431
556
|
|
|
432
557
|
A theme is a single stylesheet. Register it in `src/res/themes/themes.js` and select it with
|
|
@@ -441,6 +566,95 @@ The default theme is in `src/res/themes/default/style.css`; `{ id: 1 }` is a dar
|
|
|
441
566
|
|
|
442
567
|
Switch themes at runtime with `setTheme({ id: 1 })`.
|
|
443
568
|
|
|
569
|
+
### Themes and modes (light / dark / like the system)
|
|
570
|
+
|
|
571
|
+
A second system lets people choose a theme **and** a mode. It is just two attributes on `<html>` that `src/res/themes/appearance.css` reads:
|
|
572
|
+
|
|
573
|
+
```html
|
|
574
|
+
<link rel="stylesheet" href="athena-ui/src/res/themes/default/style.css">
|
|
575
|
+
<link rel="stylesheet" href="athena-ui/src/res/themes/appearance.css">
|
|
576
|
+
<script src="athena-ui/src/theme-boot.js" data-key="myapp.appearance" data-theme="athena"></script> <!-- before the page is drawn: no flash of the wrong colours -->
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
```js
|
|
580
|
+
const manager = createThemeManager({ themes: [{ id: "athena", name: "Athena" }, { id: "contrast", name: "High contrast" }], storageKey: "myapp.appearance",
|
|
581
|
+
themeColorVariable: "--athena-bg" }); // <meta name="theme-color"> follows this variable
|
|
582
|
+
manager.setTheme("contrast"); manager.setMode("dark"); // "system" | "light" | "dark"; saved in localStorage, other tabs follow
|
|
583
|
+
manager.onChange(({ theme, mode, dark }) => redrawChartsOrWhatever());
|
|
584
|
+
generateThemePicker({ parent: "account-page", manager }); // radio groups with a small preview of every theme
|
|
585
|
+
```
|
|
586
|
+
|
|
587
|
+
**The contract of a theme** (also at the top of `appearance.css`): a theme is a pair of CSS blocks that set the tokens
|
|
588
|
+
`--athena-bg`, `-fg`, `-muted`, `-line`, `-border`, `-surface`, `-surface-alt`, `-hover`, `-overlay`, `-accent`, `-accent-fg`, `-focus`, `-danger`, `-success`, `-warning`, `-info`, `-shadow` and `--series-1` ... `--series-8`:
|
|
589
|
+
|
|
590
|
+
```css
|
|
591
|
+
[data-theme="ocean"][data-mode="light"] { --athena-bg: #f4f9fb; /* ... */ }
|
|
592
|
+
[data-theme="ocean"][data-mode="dark"] { --athena-bg: #0b1c24; /* ... */ }
|
|
593
|
+
```
|
|
594
|
+
|
|
595
|
+
The selectors match any element with the two attributes, so a preview or a dark panel on a light page is just an element with `data-theme` and `data-mode`.
|
|
596
|
+
Athena and High contrast (light and dark) are included; without the script the page follows the system.
|
|
597
|
+
|
|
598
|
+
### Date and time range
|
|
599
|
+
|
|
600
|
+
```js
|
|
601
|
+
const range = generateDateTimeRange({ parent: "wrapper", label: "Time", preset: "24h", onChange: ({ from, to, preset }) => reload() });
|
|
602
|
+
range.getRange(); // { from: Date, to: Date }. A preset ("15m", "1h", "24h", "7d", "30d") is measured from NOW when this is called
|
|
603
|
+
range.getValue(); // { from: "2026-11-19T08:00", to: "...", preset: "24h" }, the values of the inputs
|
|
604
|
+
```
|
|
605
|
+
|
|
606
|
+
Two `datetime-local` inputs and a list of presets (your own with `presets: [{ id, label, minutes }]`). Typing in an input makes it a custom range.
|
|
607
|
+
`toLocalInput(date)` and `fromLocalInput(value)` convert between a Date and the value of such an input.
|
|
608
|
+
|
|
609
|
+
### Page parts and formatting
|
|
610
|
+
|
|
611
|
+
```js
|
|
612
|
+
generatePageHeader({ parent: "wrapper", title: "Hosts", description: "All monitored machines", breadcrumbs: [{ label: "Home", href: "#/" }, { label: "Hosts" }], actions: [addButton] });
|
|
613
|
+
generateFacts({ parent: "wrapper", items: [{ term: "System", description: "Linux" }, { term: "Seen", description: formatRelativeTime(host.lastSeen) }] });
|
|
614
|
+
generateEmptyState({ parent: "wrapper", title: "No hosts yet", message: "Install the agent.", action: { text: "Add host", onclick: add } });
|
|
615
|
+
generateLoading({ parent: "wrapper" }); // spinner + text, a live region
|
|
616
|
+
generateStat({ parent: "wrapper", label: "CPU", value: "91 %", tone: "bad", note: "of 4 cores" }); // tone: "ok" | "warn" | "bad" (colour + a word for screen readers)
|
|
617
|
+
await copyToClipboard(token); // and says "Copied" in a toast
|
|
618
|
+
formatBytes(1536); formatNumber(1234567.891); formatDuration(7500000); formatRelativeTime(date); formatDate(date, { time: true }); // Intl, in the current language
|
|
619
|
+
```
|
|
620
|
+
|
|
621
|
+
### Safe DOM building
|
|
622
|
+
|
|
623
|
+
`el(tag, { class, id, text, attrs, on, prop }, ...children)` is the way Athena builds its own pages, and it is exported. Strings are only ever inserted as **text**, children can be
|
|
624
|
+
nested lists, listeners have to be functions, and `on*` attributes, `style` and `srcdoc`, unsafe addresses (`javascript:`, `data:`) in `href` / `src` / `action`, and properties that
|
|
625
|
+
parse HTML (`innerHTML`) are refused. `createSafeBuilder({ tags: [...], attributes: [...] })` returns an `el` that only allows what is on your lists, for pages built from data you
|
|
626
|
+
do not control (a plugin API).
|
|
627
|
+
|
|
628
|
+
### Moved into Athena: HTMLElementGenerator and HTMLControlGenerator
|
|
629
|
+
|
|
630
|
+
Both used to be projects of their own and are part of Athena UI since 1.3.0 (same calls and options, MIT, same author). `HTMLElementGenerator(options)` is in
|
|
631
|
+
`src/libs/core/elementGenerator.js`, `HTMLControlGenerator(options)` / `.create()` / `.register()` in `src/libs/core/controls.js`; both are exported and global as before.
|
|
632
|
+
`HTMLControlGenerator` no longer needs jQuery (`create` returns a jQuery object when the page has jQuery, otherwise the element).
|
|
633
|
+
`registerHungarianInputControls()` adds the `hunPIN`, `hunCRID` and `hunTID` input types of its old addon. The old repositories are no longer developed.
|
|
634
|
+
|
|
635
|
+
### Parents and handles
|
|
636
|
+
|
|
637
|
+
Every `parent` option takes an element, an id or a CSS selector (`"wrapper"`, `"#list"`, `".panel > ul"`; an id wins over a selector).
|
|
638
|
+
The components return the same kind of handle: `{ element, update(), destroy() }`, plus their own methods. `destroy()` removes the
|
|
639
|
+
component. `update()` redraws it where that makes sense (`table.update({ rows })`, `chart.update({ series })`, `stat.update({ value })`,
|
|
640
|
+
`progress.update({ value })`) and otherwise just returns the handle. `generateChart` still returns the SVG element, which also carries
|
|
641
|
+
`element`, `update(options)` and `destroy()`.
|
|
642
|
+
|
|
643
|
+
### Testing your application
|
|
644
|
+
|
|
645
|
+
```js
|
|
646
|
+
import { JSDOM } from "jsdom";
|
|
647
|
+
import { installDom, until, tick } from "athena-ui-js/testing";
|
|
648
|
+
|
|
649
|
+
const dom = installDom(JSDOM); // window, document, Node, Event, ... become global
|
|
650
|
+
generateDropdown({ parent: "#wrapper", icon: "x", ariaLabel: "More", items: [] });
|
|
651
|
+
await until(() => document.querySelector(".dropdown"), { message: "the dropdown" });
|
|
652
|
+
dom.uninstall();
|
|
653
|
+
```
|
|
654
|
+
|
|
655
|
+
`installDom` takes your own `JSDOM` class, so Athena UI has no dependency on jsdom. Athena creates its events from the element's own
|
|
656
|
+
window, so they work in jsdom without a global `Event`.
|
|
657
|
+
|
|
444
658
|
## Tests
|
|
445
659
|
|
|
446
660
|
```sh
|
|
@@ -454,6 +668,8 @@ component: forms, dialogs, navigation, submenus, inputs, rich text (sanitizing,
|
|
|
454
668
|
session, themes. Set `CHROME_PATH` if the browser is not found, and `JQUERY_URL` to load jQuery from somewhere else than the CDN
|
|
455
669
|
(the machine needs internet access otherwise). `DEBUG=1` prints the browser log when the page does not report results.
|
|
456
670
|
|
|
671
|
+
A test run without jQuery is the default; `WITH_JQUERY=1 npm run test:browser` loads jQuery from its CDN to check that an application that still has it works too.
|
|
672
|
+
|
|
457
673
|
## Project structure
|
|
458
674
|
|
|
459
675
|
```
|
|
@@ -465,9 +681,11 @@ src/
|
|
|
465
681
|
core/ DOM / focus helpers, validation, translations, CSV, formatting, sanitizer, table math
|
|
466
682
|
hephaestus/ script and theme loader, generators (layout, menu, forms, charts, tables, feedback,
|
|
467
683
|
dialogs, navigation, components, inputs), router, session
|
|
468
|
-
crypto-js/, js-cookie/ submodules
|
|
469
|
-
libs.js classic scripts loaded at runtime
|
|
470
|
-
res/themes/ default and dark theme
|
|
684
|
+
crypto-js/, js-cookie/ submodules (third party)
|
|
685
|
+
libs.js classic scripts loaded at runtime (only crypto-js, and only with the deprecated enable_encrypt_password)
|
|
686
|
+
res/themes/ default and dark theme, appearance.css (themes and modes)
|
|
687
|
+
theme-boot.js classic script that sets the saved theme and mode before the page is drawn
|
|
688
|
+
testing.js installDom, until, tick for the tests of an application
|
|
471
689
|
tests/ unit tests (Node) and browser tests (headless Chrome)
|
|
472
690
|
```
|
|
473
691
|
|
|
@@ -481,6 +699,38 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
|
|
|
481
699
|
|
|
482
700
|
## Releases
|
|
483
701
|
|
|
702
|
+
### 1.3.0
|
|
703
|
+
#### Added:
|
|
704
|
+
1. Dialogs: `showFormDialog` (async save, errors stay in the dialog, `form.setErrors`) and `showConfirm` (`danger`, `typeToConfirm`)
|
|
705
|
+
2. Themes: `createThemeManager`, `generateThemePicker`, `theme-boot.js` and `appearance.css` (the contract: `data-theme` + `data-mode`, the tokens, Athena and High contrast in light and dark)
|
|
706
|
+
3. `generateMenu`: real links and buttons, groups of any depth, badges, avatar user menu, active item, bar / bottom tabs / responsive; `generateHeaderMenu({ items })`
|
|
707
|
+
4. Tables: `dataSource` (pages, cursor "Load more", loading / empty / error with Retry), `dataSource` together with `virtual`, `rowActions`, `reload()`
|
|
708
|
+
5. Charts: `area` and `sparkline`, time axis, tooltips, clickable legend, table of values, theme colours, zoom, long series thinning, `push()` for streaming
|
|
709
|
+
6. Router: `auth`, `guestOnly`, `roles`, `guard`, `onRender` / `onShown`, `focusContent`, `scrollTop`, `router.onChange`
|
|
710
|
+
7. `generateSignInForm`, `generateSignUpForm`, `generatePasswordResetForm`, `generatePasswordChangeForm`, `createAuthState`
|
|
711
|
+
8. `generateDateTimeRange` with presets, `generatePageHeader`, `generateFacts`, `generateEmptyState`, `generateLoading`, stat `tone` and `note`, `copyToClipboard`, format helpers
|
|
712
|
+
9. `el`, `setContent`, `resolveElement`, `asHandle` and `createSafeBuilder` are exported
|
|
713
|
+
10. HTMLElementGenerator and HTMLControlGenerator (and the Hungarian input addon) are part of Athena UI; no more submodules for them
|
|
714
|
+
#### Changed:
|
|
715
|
+
1. jQuery is optional: init() does not need it, the layout, modal, forms and menus use plain DOM, the browser tests run without it
|
|
716
|
+
2. Only crypto-js can still be loaded as a classic script, and only with `enable_encrypt_password`
|
|
717
|
+
3. `el()` refuses code attributes and unsafe addresses
|
|
718
|
+
#### Deprecated:
|
|
719
|
+
1. `enable_encrypt_password` and the hashing of the old login forms (removed in 2.0): send the password over HTTPS and hash it on the server
|
|
720
|
+
|
|
721
|
+
### 1.2.0
|
|
722
|
+
#### Added:
|
|
723
|
+
1. Dialogs: `size` and `class` options, and the open dialog (`element`, `backdrop`, `close()`) on the returned promise
|
|
724
|
+
2. Tables: `cellClass`, `rowClass`, `focusableRows` / `rowLabel`, `density`, `wrap`, column `render` (text or Node), `align`, tooltip for cut text
|
|
725
|
+
3. Dropdown: `icon`, `ariaLabel`, `caret`, `toggleClass`; the label is optional
|
|
726
|
+
4. Every `parent` option takes an element, an id or a CSS selector; the components share the handle `{ element, update(), destroy() }`
|
|
727
|
+
5. `athena-ui-js/testing`: `installDom`, `until`, `tick`
|
|
728
|
+
#### Changed:
|
|
729
|
+
1. The dialog backdrop is shown by a CSS class, not by an inline style (works with a strict Content-Security-Policy)
|
|
730
|
+
2. Virtual tables: a list that starts empty draws a full window, the window is measured again when the scroll area changes size, and the cell padding no longer loses against the application's `td` padding
|
|
731
|
+
3. The combobox creates its events from the element's own window (no more jsdom errors)
|
|
732
|
+
4. The pager of a table with one page is hidden
|
|
733
|
+
|
|
484
734
|
### 1.1.0
|
|
485
735
|
#### Added:
|
|
486
736
|
1. `generateDropZone` / `createDropZone`: drag-and-drop area with file type, size and count checks
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "athena-ui-js",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "A small jQuery
|
|
3
|
+
"version": "1.3.0",
|
|
4
|
+
"description": "A small UI framework (jQuery is optional): generated page layout, menus, login / registration / lost password forms, charts, tables, modals and themes, written as ES modules.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/athena-ui.js",
|
|
7
7
|
"scripts": {
|
|
@@ -10,11 +10,15 @@
|
|
|
10
10
|
},
|
|
11
11
|
"exports": {
|
|
12
12
|
".": "./src/athena-ui.js",
|
|
13
|
+
"./testing": "./src/testing.js",
|
|
14
|
+
"./theme-boot.js": "./src/theme-boot.js",
|
|
13
15
|
"./themes/*": "./src/res/themes/*",
|
|
14
16
|
"./package.json": "./package.json"
|
|
15
17
|
},
|
|
16
18
|
"files": [
|
|
17
19
|
"src/athena-ui.js",
|
|
20
|
+
"src/testing.js",
|
|
21
|
+
"src/theme-boot.js",
|
|
18
22
|
"src/libs/libs.js",
|
|
19
23
|
"src/libs/config",
|
|
20
24
|
"src/libs/hephaestus/hephaestus.js",
|
|
@@ -32,11 +36,6 @@
|
|
|
32
36
|
"src/libs/hephaestus/chartGenerator",
|
|
33
37
|
"src/libs/hephaestus/tableGenerator",
|
|
34
38
|
"src/libs/hephaestus/modalGenerator",
|
|
35
|
-
"src/libs/hephaestus/HTMLControlGenerator/LICENSE",
|
|
36
|
-
"src/libs/hephaestus/HTMLControlGenerator/src/HTMLControlGenerator.min.js",
|
|
37
|
-
"src/libs/hephaestus/HTMLElementGenerator/LICENSE",
|
|
38
|
-
"src/libs/hephaestus/HTMLElementGenerator/src/HTMLElementGenerator.js",
|
|
39
|
-
"src/libs/hephaestus/HTMLElementGenerator/src/errors.js",
|
|
40
39
|
"src/libs/crypto-js/LICENSE",
|
|
41
40
|
"src/libs/crypto-js/crypto-js.js",
|
|
42
41
|
"src/libs/js-cookie/LICENSE",
|
|
@@ -68,6 +67,11 @@
|
|
|
68
67
|
"peerDependencies": {
|
|
69
68
|
"jquery": "^4.0.0"
|
|
70
69
|
},
|
|
70
|
+
"peerDependenciesMeta": {
|
|
71
|
+
"jquery": {
|
|
72
|
+
"optional": true
|
|
73
|
+
}
|
|
74
|
+
},
|
|
71
75
|
"publishConfig": {
|
|
72
76
|
"access": "public"
|
|
73
77
|
},
|
package/src/athena-ui.js
CHANGED
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
//Author: Csaba Tóth https://github.com/csabatibortoth/
|
|
3
3
|
//LICENCE: MIT
|
|
4
4
|
//Repository: https://github.com/csabatibortoth/athena-ui
|
|
5
|
-
//Version: 1.
|
|
6
|
-
|
|
7
|
-
/* global $ */
|
|
5
|
+
//Version: 1.3.0
|
|
8
6
|
|
|
9
7
|
import config, { applyConfig } from "./libs/config/config.js";
|
|
10
8
|
import { getAppConfig, setHooks } from "./libs/config/hooks.js";
|
|
@@ -14,6 +12,7 @@ import * as header from "./libs/hephaestus/LayoutGenerator/headerContentGenerato
|
|
|
14
12
|
import * as wrapper from "./libs/hephaestus/LayoutGenerator/wrapperContentGenerator.js";
|
|
15
13
|
import * as footer from "./libs/hephaestus/LayoutGenerator/footerContentGenerator.js";
|
|
16
14
|
import * as menu from "./libs/hephaestus/MenuGenerator/basicMenuGenerator.js";
|
|
15
|
+
import * as menuGenerator from "./libs/hephaestus/MenuGenerator/menuGenerator.js";
|
|
17
16
|
import * as loginForm from "./libs/hephaestus/formGenerator/loginFormGenerator.js";
|
|
18
17
|
import * as registrationForm from "./libs/hephaestus/formGenerator/registrationFormGenerator.js";
|
|
19
18
|
import * as lostPasswordForm from "./libs/hephaestus/formGenerator/lostPasswordFormGenerator.js";
|
|
@@ -31,16 +30,21 @@ import * as richText from "./libs/hephaestus/inputGenerator/richTextGenerator.js
|
|
|
31
30
|
import * as sanitize from "./libs/core/sanitize.js";
|
|
32
31
|
import * as router from "./libs/hephaestus/router/router.js";
|
|
33
32
|
import * as session from "./libs/hephaestus/auth/session.js";
|
|
33
|
+
import * as authState from "./libs/hephaestus/auth/authState.js";
|
|
34
|
+
import * as authForms from "./libs/hephaestus/formGenerator/authForms.js";
|
|
34
35
|
import * as i18n from "./libs/core/i18n.js";
|
|
35
36
|
import * as validation from "./libs/core/validation.js";
|
|
37
|
+
import * as format from "./libs/core/format.js";
|
|
38
|
+
import * as dateRange from "./libs/core/dateRange.js";
|
|
36
39
|
import * as csv from "./libs/core/csv.js";
|
|
40
|
+
import * as theme from "./libs/core/theme.js";
|
|
41
|
+
import * as themePicker from "./libs/hephaestus/componentGenerator/themePicker.js";
|
|
37
42
|
import * as modal from "./libs/hephaestus/modalGenerator/modalGenerator.js";
|
|
38
43
|
import Cookies from "./libs/js-cookie/src/api.mjs";
|
|
39
|
-
import { HTMLElementGenerator } from "./libs/
|
|
44
|
+
import { HTMLElementGenerator } from "./libs/core/elementGenerator.js";
|
|
45
|
+
import { HTMLControlGenerator, registerControl, generateControl } from "./libs/core/controls.js";
|
|
46
|
+
import { registerHungarianInputControls } from "./libs/core/hungarianControls.js";
|
|
40
47
|
|
|
41
|
-
if (typeof $ !== "function") {
|
|
42
|
-
throw new Error("Athena UI: jQuery has to be loaded before athena-ui.js");
|
|
43
|
-
}
|
|
44
48
|
|
|
45
49
|
/**
|
|
46
50
|
* Loads the libraries and the theme in parallel, then generates the layout.
|
|
@@ -62,9 +66,9 @@ export async function init(options = {}) {
|
|
|
62
66
|
setHooks(options);
|
|
63
67
|
|
|
64
68
|
await Promise.all([
|
|
65
|
-
loadLibs(config.customLoader ? [config.customLoader] : []),
|
|
69
|
+
loadLibs(config.customLoader ? [config.customLoader] : [], { crypto: config.enable_encrypt_password }),
|
|
66
70
|
loadTheme(options.theme ?? options.themes),
|
|
67
|
-
new Promise(resolve =>
|
|
71
|
+
new Promise(resolve => (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", resolve, { once: true }) : resolve()))
|
|
68
72
|
]);
|
|
69
73
|
|
|
70
74
|
layout.generateBasicLayout();
|
|
@@ -85,11 +89,16 @@ const AthenaUI = {
|
|
|
85
89
|
loadScript,
|
|
86
90
|
Cookies,
|
|
87
91
|
HTMLElementGenerator,
|
|
92
|
+
HTMLControlGenerator,
|
|
93
|
+
registerControl,
|
|
94
|
+
generateControl,
|
|
95
|
+
registerHungarianInputControls,
|
|
88
96
|
...layout,
|
|
89
97
|
...header,
|
|
90
98
|
...wrapper,
|
|
91
99
|
...footer,
|
|
92
100
|
...menu,
|
|
101
|
+
...menuGenerator,
|
|
93
102
|
...loginForm,
|
|
94
103
|
...registrationForm,
|
|
95
104
|
...lostPasswordForm,
|
|
@@ -105,12 +114,18 @@ const AthenaUI = {
|
|
|
105
114
|
...sanitize,
|
|
106
115
|
...router,
|
|
107
116
|
...session,
|
|
117
|
+
...authState,
|
|
118
|
+
...authForms,
|
|
108
119
|
...i18n,
|
|
109
120
|
...validation,
|
|
110
121
|
...csv,
|
|
122
|
+
...dateRange,
|
|
123
|
+
...format,
|
|
111
124
|
setTheme,
|
|
112
125
|
...chart,
|
|
113
126
|
...table,
|
|
127
|
+
...theme,
|
|
128
|
+
...themePicker,
|
|
114
129
|
...modal
|
|
115
130
|
};
|
|
116
131
|
|
|
@@ -118,12 +133,13 @@ const AthenaUI = {
|
|
|
118
133
|
// stays reachable as globals, like in the pre-module versions.
|
|
119
134
|
Object.assign(globalThis, AthenaUI, { AthenaUI });
|
|
120
135
|
|
|
121
|
-
export { config, loadScript, Cookies, HTMLElementGenerator };
|
|
136
|
+
export { config, loadScript, Cookies, HTMLElementGenerator, HTMLControlGenerator, registerControl, generateControl, registerHungarianInputControls };
|
|
122
137
|
export * from "./libs/hephaestus/LayoutGenerator/basicLayoutGenerator.js";
|
|
123
138
|
export * from "./libs/hephaestus/LayoutGenerator/headerContentGenerator.js";
|
|
124
139
|
export * from "./libs/hephaestus/LayoutGenerator/wrapperContentGenerator.js";
|
|
125
140
|
export * from "./libs/hephaestus/LayoutGenerator/footerContentGenerator.js";
|
|
126
141
|
export * from "./libs/hephaestus/MenuGenerator/basicMenuGenerator.js";
|
|
142
|
+
export * from "./libs/hephaestus/MenuGenerator/menuGenerator.js";
|
|
127
143
|
export * from "./libs/hephaestus/formGenerator/loginFormGenerator.js";
|
|
128
144
|
export * from "./libs/hephaestus/formGenerator/registrationFormGenerator.js";
|
|
129
145
|
export * from "./libs/hephaestus/formGenerator/lostPasswordFormGenerator.js";
|
|
@@ -138,11 +154,18 @@ export * from "./libs/hephaestus/componentGenerator/componentGenerator.js";
|
|
|
138
154
|
export * from "./libs/hephaestus/inputGenerator/inputGenerator.js";
|
|
139
155
|
export * from "./libs/hephaestus/inputGenerator/dropZoneGenerator.js";
|
|
140
156
|
export * from "./libs/hephaestus/inputGenerator/richTextGenerator.js";
|
|
157
|
+
export { el, setContent, resolveElement, asHandle, createSafeBuilder } from "./libs/core/dom.js";
|
|
141
158
|
export * from "./libs/core/sanitize.js";
|
|
142
159
|
export * from "./libs/hephaestus/router/router.js";
|
|
143
160
|
export * from "./libs/hephaestus/auth/session.js";
|
|
161
|
+
export * from "./libs/hephaestus/auth/authState.js";
|
|
162
|
+
export * from "./libs/hephaestus/formGenerator/authForms.js";
|
|
144
163
|
export * from "./libs/core/i18n.js";
|
|
145
164
|
export * from "./libs/core/validation.js";
|
|
146
165
|
export * from "./libs/core/csv.js";
|
|
166
|
+
export * from "./libs/core/dateRange.js";
|
|
167
|
+
export * from "./libs/core/format.js";
|
|
147
168
|
export * from "./libs/hephaestus/modalGenerator/modalGenerator.js";
|
|
169
|
+
export * from "./libs/core/theme.js";
|
|
170
|
+
export * from "./libs/hephaestus/componentGenerator/themePicker.js";
|
|
148
171
|
export default AthenaUI;
|