athena-ui-js 0.4.1 → 1.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 (39) hide show
  1. package/README.md +352 -11
  2. package/package.json +84 -60
  3. package/src/athena-ui.js +68 -1
  4. package/src/libs/config/config.js +15 -1
  5. package/src/libs/config/hooks.js +15 -3
  6. package/src/libs/core/combobox.js +179 -0
  7. package/src/libs/core/csv.js +37 -0
  8. package/src/libs/core/dateRange.js +50 -0
  9. package/src/libs/core/dom.js +57 -0
  10. package/src/libs/core/focus.js +49 -0
  11. package/src/libs/core/format.js +31 -0
  12. package/src/libs/core/i18n.js +160 -0
  13. package/src/libs/core/pagination.js +24 -0
  14. package/src/libs/core/sanitize.js +65 -0
  15. package/src/libs/core/tableMath.js +31 -0
  16. package/src/libs/core/validation.js +79 -0
  17. package/src/libs/hephaestus/MenuGenerator/basicMenuGenerator.js +81 -0
  18. package/src/libs/hephaestus/auth/session.js +68 -0
  19. package/src/libs/hephaestus/chartGenerator/chartGenerator.js +187 -0
  20. package/src/libs/hephaestus/componentGenerator/componentGenerator.js +201 -0
  21. package/src/libs/hephaestus/dialogGenerator/dialogGenerator.js +126 -0
  22. package/src/libs/hephaestus/feedbackGenerator/feedbackGenerator.js +138 -0
  23. package/src/libs/hephaestus/formGenerator/changePasswordFormGenerator.js +50 -0
  24. package/src/libs/hephaestus/formGenerator/formBuilder.js +379 -0
  25. package/src/libs/hephaestus/formGenerator/formUtils.js +66 -0
  26. package/src/libs/hephaestus/formGenerator/loginFormGenerator.js +20 -6
  27. package/src/libs/hephaestus/formGenerator/lostPasswordFormGenerator.js +30 -0
  28. package/src/libs/hephaestus/formGenerator/registrationFormGenerator.js +54 -0
  29. package/src/libs/hephaestus/hephaestus.js +8 -1
  30. package/src/libs/hephaestus/inputGenerator/inputGenerator.js +299 -0
  31. package/src/libs/hephaestus/inputGenerator/richTextGenerator.js +222 -0
  32. package/src/libs/hephaestus/modalGenerator/modalGenerator.js +13 -2
  33. package/src/libs/hephaestus/navigationGenerator/navigationGenerator.js +388 -0
  34. package/src/libs/hephaestus/router/matchRoute.js +42 -0
  35. package/src/libs/hephaestus/router/router.js +102 -0
  36. package/src/libs/hephaestus/tableGenerator/tableGenerator.js +457 -0
  37. package/src/res/themes/dark/style.css +31 -0
  38. package/src/res/themes/default/style.css +1388 -7
  39. package/src/res/themes/themes.js +6 -0
package/README.md CHANGED
@@ -1,16 +1,40 @@
1
1
  # Athena UI
2
2
 
3
3
  A small jQuery based UI framework for development and education purposes. It generates a page
4
- layout (header, menu, content wrapper, footer), a login form and modal support from a single
5
- `init()` call, and loads its own libraries and theme.
4
+ layout (header, menu, content wrapper, footer) from a single `init()` call, loads its own libraries
5
+ and theme, and ships the building blocks of a multipurpose application: forms, tables, charts,
6
+ feedback, navigation, a router and more.
6
7
 
7
- Current version: **0.4.1**
8
+ Current version: **1.0.0** (first stable release)
9
+
10
+ [Quick start](#usage) · [API](#api) · [Components](#charts) · [Themes](#themes) · [Tests](#tests) · [Release notes](#releases)
11
+
12
+ ## Status
13
+
14
+ 1.0.0 is the first stable release. From here on the exported API of `src/athena-ui.js` follows
15
+ [semantic versioning](https://semver.org/): breaking changes only come with a new major version.
16
+ Known limits are listed below, so you can judge whether it fits your project:
17
+
18
+ - Rich text uses the deprecated `document.execCommand`. Content is sanitized in the browser, but sanitize it on the server too.
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.
21
+ - Translations: English and Hungarian.
8
22
 
9
23
  ## Features
10
24
 
11
25
  - Generated page layout: container, header (logo, title, menu), wrapper, footer (menu, copyright text)
12
26
  - Menus built from your own item lists, with a navigation callback
13
- - Login form with optional SHA-256 password hashing
27
+ - 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
+ - Form builder: text, number, date, textarea, select, radio / checkbox groups, switch, autocomplete, multi select, with validation
31
+ - Buttons, toasts, alerts, spinner, progress bar, alert / confirm / prompt dialogs
32
+ - Tabs, accordion, dropdown, sidebar, breadcrumbs, pagination and a hash / history router
33
+ - Cards, grid, badges, avatars, KPI tiles, tooltips, links, sections
34
+ - File upload with progress, stepper (wizard), date range picker, rich text editor
35
+ - Menus with submenus
36
+ - Session handling (login state in a cookie), change password form
37
+ - Default and dark theme (switchable at runtime), responsive, translations (English, Hungarian), keyboard and ARIA support
14
38
  - Modal open / close helpers
15
39
  - Themes loaded at runtime, custom stylesheets supported
16
40
  - Written as ES modules, no build step
@@ -85,6 +109,9 @@ the theme are loaded and the layout is generated.
85
109
  | `menuItems` | `{ headerMenu, footerMenu }`, arrays of `{ id, class, text, inner_text }`. Placeholder items are generated without it. |
86
110
  | `nav` | Called without arguments when the wrapper is generated, and with the `inner_text` of the item on menu clicks. |
87
111
  | `login` | Called with `{ username, password }` when the login button is clicked and `login_enabled` is set. |
112
+ | `register` | Called with `{ username, email, password }` when a valid registration form is submitted and `registration_enabled` is set. |
113
+ | `lostPassword` | Called with `{ email }` when a valid lost password form is submitted and `lost_password_enabled` is set. |
114
+ | `changePassword` | Called with `{ currentPassword, newPassword }` when a valid change password form is submitted and `change_password_enabled` is set. |
88
115
 
89
116
  ### Configuration
90
117
 
@@ -93,14 +120,21 @@ the theme are loaded and the layout is generated.
93
120
  | `header_title_text` | `"Athena UI"` | Title in the header |
94
121
  | `header_img_url` | | Header logo URL |
95
122
  | `copyright` | placeholder text | Footer text, the version is appended |
96
- | `version` | `"0.4.1"` | Version shown in the footer |
123
+ | `version` | `"1.0.0"` | Version shown in the footer |
97
124
  | `bordered` | `true` | Draw a border around the layout blocks |
98
125
  | `generateHeader`, `generateFooter` | `true` | Generate the header / footer block |
99
126
  | `generateHeadercontent`, `generateFooterContent`, `generateWrappercontent` | `true` | Generate the content of the block |
100
127
  | `login_enabled` | `false` | Call the `login` callback from the login form |
101
- | `enable_encrypt_password` | `false` | SHA-256 hash the password before it is passed to `login` |
128
+ | `registration_enabled` | `false` | Call the `register` callback from the registration form |
129
+ | `lost_password_enabled` | `false` | Call the `lostPassword` callback from the lost password form |
130
+ | `change_password_enabled` | `false` | Call the `changePassword` callback from the change password form |
131
+ | `login_remember_me` | `false` | Show a "Remember me" checkbox in the login form, passed to `login` as `remember` |
132
+ | `locale` | `"en"` | Language of the generated texts (`en`, `hu`, or your own, see [Translations](#translations)) |
133
+ | `session_cookie` | `"athena_session"` | Name of the session cookie |
134
+ | `session_days` | `7` | Lifetime of a remembered session in days |
135
+ | `enable_encrypt_password` | `false` | SHA-256 hash the password before it is passed to `login` / `register` |
102
136
  | `customLoader` | | URL of an extra classic script, loaded before the layout is generated |
103
- | `container_class`, `header_class`, `header_menu_class`, `wrapper_class`, `footer_class`, `footer_menu_class`, `loginForm_class` | | CSS classes of the generated blocks |
137
+ | `container_class`, `header_class`, `header_menu_class`, `wrapper_class`, `footer_class`, `footer_menu_class`, `loginForm_class`, `registrationForm_class`, `lostPasswordForm_class`, `changePasswordForm_class` | | CSS classes of the generated blocks |
104
138
 
105
139
  ### API
106
140
 
@@ -114,11 +148,253 @@ Everything is exported from `athena-ui.js`:
114
148
  | `clearHeader()`, `clearWrapper()`, `clearFooter()`, `clearHeaderMenu()`, `clearFooterMenu()` | Empty a block |
115
149
  | `generateBasicMenu(options)` | Generate a menu into any parent |
116
150
  | `generateLoginForm()`, `getLoginFormData()` | Login form into the wrapper, and its current values |
151
+ | `generateRegistrationForm(parent)`, `getRegistrationFormData()`, `validateRegistrationForm()` | Registration form (username, email, password, confirmation) into `parent` (default `wrapper`). Validated before the callback is called. |
152
+ | `generateLostPasswordForm(parent)`, `getLostPasswordFormData()` | Lost password form (email) |
153
+ | `generateChart(options)` | Draw a chart, see [Charts](#charts) |
154
+ | `generateTable(options)` | Draw a table, see [Tables](#tables) |
155
+ | `generateChangePasswordForm(parent)`, `getChangePasswordFormData()`, `validateChangePasswordForm()` | Change password form |
156
+ | `generateForm`, `generateField`, `generateButton` | Form builder, see [Forms](#forms) |
157
+ | `showToast`, `generateAlert`, `generateSpinner`, `generateProgress` | See [Feedback](#feedback) |
158
+ | `showDialog`, `alertDialog`, `confirmDialog`, `promptDialog` | See [Dialogs](#dialogs) |
159
+ | `generateTabs`, `generateBreadcrumbs`, `generatePagination`, `generateAccordion`, `generateDropdown`, `generateSidebar` | See [Navigation](#navigation) |
160
+ | `createRouter(options)` | See [Router](#router) |
161
+ | `generateCard`, `generateSection`, `generateGrid`, `generateBadge`, `generateAvatar`, `generateStat`, `generateLink`, `generateTooltip` | See [Components](#components) |
162
+ | `generateAutocomplete`, `generateMultiSelect`, `generateFileUpload`, `generateStepper`, `generateDateRange`, `generateRichText` | See [Inputs](#inputs) |
163
+ | `sanitizeHtml(html)`, `htmlToText(html)`, `isSafeUrl(url)` | The allow-list sanitizer behind the rich text editor |
164
+ | `setSession`, `getSession`, `isLoggedIn`, `logout`, `onSessionChange` | See [Session](#session) |
165
+ | `translate`, `setLocale`, `getLocale`, `addMessages` | See [Translations](#translations) |
166
+ | `validateValue`, `validateAll` | The validator behind the form builder |
167
+ | `toCsv(columns, rows)`, `downloadFile(name, text)` | CSV helpers |
168
+ | `setTheme({ id })` | Switch the theme at runtime |
117
169
  | `openModal(id)`, `closeModal(id)` | Show / hide a `.modal` element (default id: `myModal`). Elements with the `close` class close their modal. |
118
170
  | `loadScript(src)` | Load a classic script once, returns a Promise |
119
171
  | `Cookies` | The [js-cookie](https://github.com/js-cookie/js-cookie) API |
120
172
  | `HTMLElementGenerator(options)` | The [HTMLElementGenerator](https://github.com/csabatibortoth/HTMLElementGenerator) function |
121
173
 
174
+ ### Charts
175
+
176
+ ```js
177
+ generateChart({
178
+ type: "bar", // "bar" | "line" | "pie" | "donut"
179
+ parent: "wrapper", // id of the parent element (default)
180
+ title: "Revenue",
181
+ labels: ["Q1", "Q2", "Q3"],
182
+ series: [
183
+ { name: "2025", data: [12, 19, 8] },
184
+ { name: "2026", data: [14, 17, 12], color: "#e15759" }
185
+ ]
186
+ });
187
+ ```
188
+
189
+ Charts are inline SVG and support negative values. `pie` and `donut` use the first series, one slice per
190
+ label. Other options: `id`, `width` (600), `height` (360), `legend` (shown for several series and for
191
+ pie / donut). Returns the `<svg>` element, or `null` when the options are invalid.
192
+
193
+ ### Tables
194
+
195
+ ```js
196
+ const { setRows } = generateTable({
197
+ parent: "wrapper",
198
+ caption: "Users",
199
+ columns: [{ key: "name", label: "Name" }, { key: "age", label: "Age", format: v => `${v} y` }],
200
+ rows: [{ name: "Anna", age: 31 }, { name: "Béla", age: 27 }],
201
+ filter: true, // text filter box
202
+ pageSize: 10, // 0 = no pagination
203
+ onRowClick: row => console.log(row)
204
+ });
205
+ ```
206
+
207
+ Click a header to sort (disable with `sortable: false`, or per column). Other options: `id`, `class`,
208
+ `emptyText`. Returns `{ element, setRows(rows), getSelected(), clearSelection(), toCsv(), exportCsv(filename) }`.
209
+
210
+ - `selectable: true` adds a checkbox column (the header checkbox selects every filtered row), `onSelectionChange(rows)` reports changes.
211
+ - 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
+ - `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
+ - `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.
214
+ - `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
+
216
+ ### Forms
217
+
218
+ ```js
219
+ const form = generateForm({
220
+ parent: "wrapper",
221
+ submitText: "Save",
222
+ fields: [
223
+ { name: "name", label: "Name", required: true, minLength: 2, help: "At least 2 characters" },
224
+ { name: "email", label: "Email", type: "email", required: true },
225
+ { name: "password", label: "Password", type: "password", required: true },
226
+ { name: "password2", label: "Repeat", type: "password", match: "password" },
227
+ { name: "country", label: "Country", type: "select", placeholder: "Choose...", options: ["Hungary", "Italy"] },
228
+ { name: "plan", type: "radio", label: "Plan", options: ["Free", "Pro"], value: "Free" },
229
+ { name: "news", type: "switch", label: "Newsletter" }
230
+ ],
231
+ onSubmit: async values => { await save(values); } // called when every field is valid
232
+ });
233
+ ```
234
+
235
+ Field types: `text`, `password`, `email`, `number`, `date`, `datetime-local`, `time`, `month`, `week`, `url`, `tel`,
236
+ `search`, `color`, `range`, `file`, `hidden`, `textarea`, `select` (`multiple`), `checkbox`, `switch`, `radio`,
237
+ `checkboxes`, `autocomplete`, `multiselect`, `daterange` (value `{ from, to }`), `richtext` (value: safe HTML).
238
+ The date, time and color types use the native pickers of the browser.
239
+
240
+ Rules (`required`, `email`, `minLength`, `maxLength`, `pattern`, `min`, `max`, `match`, `validate(value, values)`) can be
241
+ given on the field or in `rules`. A field is validated when it loses focus, then on every change. A rejected
242
+ `onSubmit` promise is shown as form message and the submit button shows a spinner while it runs.
243
+
244
+ The returned form has `getValues()`, `setValues()`, `setErrors({ name: "Taken" })` (server side errors),
245
+ `validate()`, `reset()`, `setMessage(text)`, `fields` and `submitButton`. `generateField(options)` builds a single field.
246
+
247
+ `generateButton({ text, variant, loading, disabled, onclick })` has the variants `primary`, `secondary`, `danger` and
248
+ `link`, and returns `{ element, setLoading, setDisabled, setText }`.
249
+
250
+ ### Feedback
251
+
252
+ ```js
253
+ showToast({ title: "Saved", message: "All good", type: "success", duration: 4000 }); // info | success | warning | error
254
+ generateAlert({ parent: "wrapper", type: "error", message: "Failed", dismissible: true });
255
+ generateSpinner({ parent: "wrapper", size: "large" });
256
+ const progress = generateProgress({ parent: "wrapper", label: "Upload", value: 20 }); // no value: indeterminate
257
+ progress.setValue(60);
258
+ ```
259
+
260
+ ### Dialogs
261
+
262
+ ```js
263
+ await alertDialog("Saved");
264
+ if (await confirmDialog("Delete the item?", { title: "Delete", confirmText: "Delete", danger: true })) { /* ... */ }
265
+ const name = await promptDialog("Your name", { validate: v => v ? "" : "Required" }); // null when cancelled
266
+ const choice = await showDialog({ title: "Custom", content: "Pick one", buttons: [{ text: "A", value: "a" }, { text: "B", value: "b" }] });
267
+ ```
268
+
269
+ Dialogs trap the focus, close with Esc (resolving `null` / `false`) and restore the focus. Text content is
270
+ never parsed as HTML. `openModal` / `closeModal` got the same focus handling.
271
+
272
+ ### Navigation
273
+
274
+ ```js
275
+ generateTabs({ parent: "wrapper", tabs: [{ id: "a", label: "A", content: "First" }, { id: "b", label: "B", content: () => lazyNode() }] });
276
+ generateAccordion({ parent: "wrapper", items: [{ title: "Q", content: "A", open: true }], multiple: false });
277
+ generateDropdown({ parent: "wrapper", label: "Actions", items: [{ label: "Edit", onclick }, { divider: true }, { label: "Delete", onclick }] });
278
+ generatePagination({ parent: "wrapper", total: 200, pageSize: 10, onChange: page => load(page) });
279
+ generateBreadcrumbs({ parent: "wrapper", items: [{ label: "Home", href: "#/" }, { label: "Users" }] });
280
+ generateSidebar({ parent: "wrapper", active: "home", onSelect: item => go(item.id),
281
+ items: [{ id: "home", label: "Home" }, { id: "reports", label: "Reports", children: [{ id: "daily", label: "Daily" }] }] });
282
+ ```
283
+
284
+ Tabs, dropdown and the combobox inputs follow the WAI-ARIA keyboard patterns (arrow keys, Home / End, Esc).
285
+ The sidebar collapses behind a toggle button on small screens.
286
+
287
+ ### Menus with submenus
288
+
289
+ ```js
290
+ init({
291
+ menuItems: {
292
+ headerMenu: [
293
+ { id: "menu-home", class: "menu-item", text: "", inner_text: "Home" },
294
+ { id: "menu-more", class: "menu-item", text: "", inner_text: "More", children: [{ inner_text: "Reports" }, { inner_text: "Archive", disabled: true }] }
295
+ ],
296
+ footerMenu: []
297
+ },
298
+ nav: name => router.navigate(`/${name.toLowerCase()}`) // called with the entry's inner_text
299
+ });
300
+ ```
301
+
302
+ A submenu opens with a click, Enter, Space or the Down arrow, closes with Esc, a click outside or by choosing an entry,
303
+ and supports the arrow keys, Home and End. The same works in the footer menu.
304
+
305
+ ### Router
306
+
307
+ ```js
308
+ const router = createRouter({
309
+ routes: {
310
+ "/": () => renderHome(),
311
+ "/users/:id": ({ params, query }) => renderUser(params.id),
312
+ "/admin": { handler: renderAdmin, title: "Admin" }
313
+ },
314
+ outlet: "wrapper", // emptied before every page
315
+ beforeEach: ({ path }) => path === "/admin" && !isLoggedIn() ? "/login" : undefined, // false cancels, a path redirects
316
+ notFound: () => renderNotFound()
317
+ });
318
+ router.start();
319
+ router.navigate("/users/5?tab=info");
320
+ ```
321
+
322
+ `mode: "history"` uses real paths instead of the hash, the server then has to answer every path with the page.
323
+ Pass `router.navigate` from your `nav` callback to route the menu clicks.
324
+
325
+ ### Components
326
+
327
+ ```js
328
+ const grid = generateGrid({ parent: "wrapper", columns: 3 }); // one column on small screens
329
+ generateStat({ parent: grid, label: "Revenue", value: "$12k", delta: 8.2 });
330
+ generateCard({ parent: grid, title: "Title", content: "Text or a Node", footer: "Footer", image: "a.jpg" });
331
+ generateBadge({ parent: "wrapper", text: "new", variant: "success", pill: true });
332
+ generateAvatar({ parent: "wrapper", name: "Ada Lovelace", src: "ada.png" }); // initials without a working image
333
+ generateTooltip(buttonElement, "Saves the form");
334
+ generateLink({ parent: "wrapper", text: "Docs", href: "https://example.com", external: true });
335
+ generateSection({ parent: "wrapper", title: "Section", level: 2, content: "..." });
336
+ ```
337
+
338
+ `parent` is the id of an element or the element itself. String content is always inserted as text.
339
+
340
+ ### Inputs
341
+
342
+ ```js
343
+ generateAutocomplete({ parent: "wrapper", label: "Country", options: ["Hungary", "Italy"] });
344
+ generateAutocomplete({ parent: "wrapper", options: async query => fetchSuggestions(query), minChars: 2 }); // remote data
345
+ generateMultiSelect({ parent: "wrapper", options: [{ value: "h", text: "Hungary" }], value: ["h"] }); // getValue(): array
346
+ generateFileUpload({ parent: "wrapper", accept: ".png,.pdf", maxSize: 2 * 1024 * 1024, url: "/upload",
347
+ onProgress: (file, percent) => {}, onComplete: (file, response) => {}, onError: (file, error) => {} });
348
+ generateStepper({ parent: "wrapper", onFinish: () => {}, steps: [
349
+ { title: "Account", content: () => buildStep1(), validate: () => valid || "Fix the errors" },
350
+ { title: "Done", content: "Finished" }
351
+ ] });
352
+ ```
353
+
354
+ ```js
355
+ generateDateRange({ parent: "wrapper", label: "Stay", from: "2026-06-01", min: "2026-01-01", onChange: ({ from, to }) => {} });
356
+ const editor = generateRichText({ parent: "wrapper", label: "Description", placeholder: "Write...", value: "<p>Hello</p>",
357
+ toolbar: ["bold", "italic", "|", "ul", "ol", "link"], onChange: html => {} });
358
+ editor.getValue(); // safe HTML, "" when empty
359
+ ```
360
+
361
+ The date range uses the native date pickers; the end picker starts at the chosen start date and a reversed range typed by
362
+ hand is reported. The rich text editor produces a restricted set of HTML (paragraphs, headings, bold / italic / underline /
363
+ strike, lists, quotes, code, links). Everything else (scripts, styles, iframes, images, event attributes, `javascript:` and
364
+ `data:` links) is removed when the content is set, pasted, dropped and read, so the value is safe to store and show with
365
+ `innerHTML`; links get `rel="noopener noreferrer"`. Toolbar buttons: `bold`, `italic`, `underline`, `strike`, `h2`, `h3`,
366
+ `quote`, `ul`, `ol`, `link`, `unlink`, `clear`, `undo`, `redo`. The editor is built on `contenteditable` and
367
+ `document.execCommand`, which every browser still supports; sanitize on the server as well, as with any HTML you accept.
368
+
369
+ Files are sent as a multipart POST (`fieldName`, `headers` are configurable). Without `url` the files are only collected,
370
+ read them with `getFiles()`.
371
+
372
+ ### Session
373
+
374
+ ```js
375
+ login: async ({ username, password, remember }) => {
376
+ const user = await api.login(username, password);
377
+ setSession({ user, token: user.token, remember }); // a session cookie, or `session_days` days when remembered
378
+ router.navigate("/");
379
+ }
380
+ isLoggedIn(); getSession(); logout();
381
+ onSessionChange(session => updateMenu(session));
382
+ ```
383
+
384
+ The session lives in a cookie written from script, so any script of the page can read it. Keep only what the UI needs in it
385
+ and let the server enforce authorization; a server set `HttpOnly` cookie is the safer place for real credentials.
386
+
387
+ ### Translations
388
+
389
+ ```js
390
+ init({ config: { locale: "hu" } }); // English and Hungarian are included
391
+ setLocale("en"); // switch at runtime, texts of new components follow
392
+ addMessages("de", { login: "Anmelden", "validation.required": "Pflichtfeld" });
393
+ translate("login");
394
+ ```
395
+
396
+ Missing texts fall back to English. See `src/libs/core/i18n.js` for all keys.
397
+
122
398
  ### Usage from classic scripts
123
399
 
124
400
  The same API is available as globals (and as `AthenaUI`), so scripts written for earlier versions
@@ -136,7 +412,7 @@ keep working. Load `athena-ui.js` with `type="module"` and call the globals afte
136
412
  </script>
137
413
  ```
138
414
 
139
- The global `appConfig`, `menuItems`, `nav` and `login` are used when the matching `init` option is
415
+ The global `appConfig`, `menuItems`, `nav`, `login`, `register` and `lostPassword` are used when the matching `init` option is
140
416
  not given. `appConfig.athenaUIFolder` is not needed anymore, paths are resolved relative to
141
417
  `athena-ui.js`.
142
418
 
@@ -144,7 +420,28 @@ not given. `appConfig.athenaUIFolder` is not needed anymore, paths are resolved
144
420
 
145
421
  A theme is a single stylesheet. Register it in `src/res/themes/themes.js` and select it with
146
422
  `theme: { id }`, or pass any stylesheet directly with `theme: { href: "css/my-theme.css" }`.
147
- The default theme is in `src/res/themes/default/style.css`.
423
+ The default theme is in `src/res/themes/default/style.css`; `{ id: 1 }` is a dark theme. All colors are CSS variables
424
+ (`--athena-bg`, `--athena-fg`, `--athena-accent`, ...), so a custom theme can import the default one and override them:
425
+
426
+ ```css
427
+ @import url("athena-ui/src/res/themes/default/style.css");
428
+ :root { --athena-accent: #8e44ad; }
429
+ ```
430
+
431
+ Switch themes at runtime with `setTheme({ id: 1 })`.
432
+
433
+ ## Tests
434
+
435
+ ```sh
436
+ npm test # unit tests of the pure modules, run in Node
437
+ npm run test:browser # the components in headless Chrome
438
+ ```
439
+
440
+ The unit tests cover validation, translations, router matching, CSV, pagination, formatting, virtual scrolling math, date ranges and the URL check.
441
+ The browser tests start a small static server, open `tests/browser/index.html` in headless Chrome, Chromium or Edge and run every
442
+ component: forms, dialogs, navigation, submenus, inputs, rich text (sanitizing, toolbar, paste), tables (resizing, virtual scrolling), router,
443
+ session, themes. Set `CHROME_PATH` if the browser is not found, and `JQUERY_URL` to load jQuery from somewhere else than the CDN
444
+ (the machine needs internet access otherwise). `DEBUG=1` prints the browser log when the page does not report results.
148
445
 
149
446
  ## Project structure
150
447
 
@@ -154,10 +451,13 @@ src/
154
451
  index.html, example.js example page
155
452
  libs/
156
453
  config/ default configuration, application hooks
157
- hephaestus/ script and theme loader, layout / menu / form / modal generators
454
+ core/ DOM / focus helpers, validation, translations, CSV, formatting, sanitizer, table math
455
+ hephaestus/ script and theme loader, generators (layout, menu, forms, charts, tables, feedback,
456
+ dialogs, navigation, components, inputs), router, session
158
457
  crypto-js/, js-cookie/ submodules
159
458
  libs.js classic scripts loaded at runtime
160
- res/themes/ themes
459
+ res/themes/ default and dark theme
460
+ tests/ unit tests (Node) and browser tests (headless Chrome)
161
461
  ```
162
462
 
163
463
  ## Authors
@@ -170,6 +470,47 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
170
470
 
171
471
  ## Releases
172
472
 
473
+ ### 1.0.0
474
+ #### Added:
475
+ 1. Stable public API (semantic versioning from this release on)
476
+ 2. README: status, known limits and quick links
477
+ #### Changed:
478
+ 1. Version bumped to 1.0.0, no breaking changes since 0.7.0
479
+
480
+ ### 0.7.0
481
+ #### Added:
482
+ 1. Menus with submenus: `children` on a menu item, with keyboard support
483
+ 2. Tables: resizable columns (mouse and keyboard) and virtual scrolling (`virtual`) for thousands of rows
484
+ 3. `generateDateRange` and the `daterange` form field
485
+ 4. `generateRichText` / `createRichText` and the `richtext` form field, with an allow-list sanitizer (`sanitizeHtml`, `isSafeUrl`)
486
+ 5. Browser tests in headless Chrome (`npm run test:browser`), more unit tests
487
+ #### Changed:
488
+ 1. English and Hungarian texts for the new components
489
+
490
+ ### 0.6.0
491
+ #### Added:
492
+ 1. Form builder (`generateForm`, `generateField`, `generateButton`) with validation, textarea, select, radio / checkbox groups, switch, autocomplete and multi select
493
+ 2. Feedback: `showToast`, `generateAlert`, `generateSpinner`, `generateProgress`; dialogs: `alertDialog`, `confirmDialog`, `promptDialog`, `showDialog`
494
+ 3. Navigation: tabs, accordion, dropdown, sidebar, breadcrumbs, pagination; `createRouter`
495
+ 4. Components: card, grid, section, badge, avatar, stat, tooltip, link
496
+ 5. `generateFileUpload` with progress, `generateStepper`
497
+ 6. Tables: row selection, inline editing, CSV export
498
+ 7. Session handling, change password form, "Remember me" in the login form
499
+ 8. Dark theme, `setTheme`, CSS variables, responsive styles
500
+ 9. Translations (English, Hungarian), `translate`, `setLocale`, `addMessages`
501
+ 10. Unit tests (`npm test`)
502
+ #### Changed:
503
+ 1. Modals trap the focus, close with Esc and restore the focus
504
+ 2. The texts of the forms and of the table go through `translate`; the registration form checks its fields with the shared validator
505
+ 3. `init` accepts the `changePassword` callback
506
+
507
+ ### 0.5.0
508
+ #### Added:
509
+ 1. `generateChart`: bar, line, pie and donut charts as inline SVG
510
+ 2. `generateTable`: sortable, filterable, paginated tables
511
+ 3. `generateRegistrationForm` and `generateLostPasswordForm`, with the `register` / `lostPassword` callbacks and the `registration_enabled` / `lost_password_enabled` settings
512
+ 4. Example page shows all of them
513
+
173
514
  ### 0.4.1
174
515
  #### Changed:
175
516
  1. HTMLControlGenerator v0.4.0, HTMLElementGenerator v0.3.0, js-cookie updated to the latest master
package/package.json CHANGED
@@ -1,60 +1,84 @@
1
- {
2
- "name": "athena-ui-js",
3
- "version": "0.4.1",
4
- "description": "A small jQuery based UI framework: generated page layout, menus, login form, modals and themes, written as ES modules.",
5
- "type": "module",
6
- "main": "./src/athena-ui.js",
7
- "exports": {
8
- ".": "./src/athena-ui.js",
9
- "./themes/*": "./src/res/themes/*",
10
- "./package.json": "./package.json"
11
- },
12
- "files": [
13
- "src/athena-ui.js",
14
- "src/libs/libs.js",
15
- "src/libs/config",
16
- "src/libs/hephaestus/hephaestus.js",
17
- "src/libs/hephaestus/LayoutGenerator",
18
- "src/libs/hephaestus/MenuGenerator",
19
- "src/libs/hephaestus/formGenerator",
20
- "src/libs/hephaestus/modalGenerator",
21
- "src/libs/hephaestus/HTMLControlGenerator/LICENSE",
22
- "src/libs/hephaestus/HTMLControlGenerator/src/HTMLControlGenerator.min.js",
23
- "src/libs/hephaestus/HTMLElementGenerator/LICENSE",
24
- "src/libs/hephaestus/HTMLElementGenerator/src/HTMLElementGenerator.js",
25
- "src/libs/hephaestus/HTMLElementGenerator/src/errors.js",
26
- "src/libs/crypto-js/LICENSE",
27
- "src/libs/crypto-js/crypto-js.js",
28
- "src/libs/js-cookie/LICENSE",
29
- "src/libs/js-cookie/src",
30
- "src/res"
31
- ],
32
- "sideEffects": true,
33
- "keywords": [
34
- "ui",
35
- "framework",
36
- "jquery",
37
- "layout",
38
- "menu",
39
- "login-form",
40
- "modal",
41
- "themes",
42
- "es-modules"
43
- ],
44
- "peerDependencies": {
45
- "jquery": "^4.0.0"
46
- },
47
- "publishConfig": {
48
- "access": "public"
49
- },
50
- "repository": {
51
- "type": "git",
52
- "url": "git+https://github.com/csabatibortoth/athena-ui.git"
53
- },
54
- "homepage": "https://github.com/csabatibortoth/athena-ui#readme",
55
- "bugs": {
56
- "url": "https://github.com/csabatibortoth/athena-ui/issues"
57
- },
58
- "author": "Csaba Tóth (https://github.com/csabatibortoth)",
59
- "license": "MIT"
60
- }
1
+ {
2
+ "name": "athena-ui-js",
3
+ "version": "1.0.0",
4
+ "description": "A small jQuery based UI framework: generated page layout, menus, login / registration / lost password forms, charts, tables, modals and themes, written as ES modules.",
5
+ "type": "module",
6
+ "main": "./src/athena-ui.js",
7
+ "scripts": {
8
+ "test": "node --test tests/*.test.js",
9
+ "test:browser": "node tests/browser/run.mjs"
10
+ },
11
+ "exports": {
12
+ ".": "./src/athena-ui.js",
13
+ "./themes/*": "./src/res/themes/*",
14
+ "./package.json": "./package.json"
15
+ },
16
+ "files": [
17
+ "src/athena-ui.js",
18
+ "src/libs/libs.js",
19
+ "src/libs/config",
20
+ "src/libs/hephaestus/hephaestus.js",
21
+ "src/libs/hephaestus/LayoutGenerator",
22
+ "src/libs/hephaestus/MenuGenerator",
23
+ "src/libs/hephaestus/formGenerator",
24
+ "src/libs/core",
25
+ "src/libs/hephaestus/auth",
26
+ "src/libs/hephaestus/router",
27
+ "src/libs/hephaestus/feedbackGenerator",
28
+ "src/libs/hephaestus/dialogGenerator",
29
+ "src/libs/hephaestus/navigationGenerator",
30
+ "src/libs/hephaestus/componentGenerator",
31
+ "src/libs/hephaestus/inputGenerator",
32
+ "src/libs/hephaestus/chartGenerator",
33
+ "src/libs/hephaestus/tableGenerator",
34
+ "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
+ "src/libs/crypto-js/LICENSE",
41
+ "src/libs/crypto-js/crypto-js.js",
42
+ "src/libs/js-cookie/LICENSE",
43
+ "src/libs/js-cookie/src",
44
+ "src/res"
45
+ ],
46
+ "sideEffects": true,
47
+ "keywords": [
48
+ "ui",
49
+ "framework",
50
+ "jquery",
51
+ "layout",
52
+ "menu",
53
+ "login-form",
54
+ "registration-form",
55
+ "chart",
56
+ "table",
57
+ "form-builder",
58
+ "dialog",
59
+ "router",
60
+ "dark-theme",
61
+ "i18n",
62
+ "rich-text",
63
+ "virtual-scroll",
64
+ "modal",
65
+ "themes",
66
+ "es-modules"
67
+ ],
68
+ "peerDependencies": {
69
+ "jquery": "^4.0.0"
70
+ },
71
+ "publishConfig": {
72
+ "access": "public"
73
+ },
74
+ "repository": {
75
+ "type": "git",
76
+ "url": "git+https://github.com/csabatibortoth/athena-ui.git"
77
+ },
78
+ "homepage": "https://github.com/csabatibortoth/athena-ui#readme",
79
+ "bugs": {
80
+ "url": "https://github.com/csabatibortoth/athena-ui/issues"
81
+ },
82
+ "author": "Csaba Tóth (https://github.com/csabatibortoth)",
83
+ "license": "MIT"
84
+ }