athena-ui-js 2.5.1 → 2.6.1
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 +36 -2
- package/docs/migration-2.0.md +99 -83
- package/docs/styling.md +124 -123
- package/package.json +5 -1
- package/src/app.js +85 -0
- package/src/athena-ui.js +4 -79
- package/src/libs/config/config.js +1 -1
- package/src/libs/core/i18n.js +354 -352
- package/src/libs/hephaestus/MenuGenerator/menuGenerator.js +278 -265
- package/src/libs/hephaestus/chartGenerator/chartGenerator.js +772 -722
- package/src/libs/hephaestus/feedbackGenerator/feedbackGenerator.js +171 -161
- package/src/libs/hephaestus/formGenerator/formBuilder.js +473 -460
- package/src/libs/hephaestus/tableGenerator/tableGenerator.js +837 -825
- package/src/res/themes/default/style.css +3128 -3037
- package/types/app.d.ts +58 -0
- package/types/athena-ui.d.ts +1 -55
- package/types/libs/config/config.d.ts +96 -96
- package/types/libs/hephaestus/MenuGenerator/menuGenerator.d.ts +5 -0
- package/types/libs/hephaestus/chartGenerator/chartGenerator.d.ts +123 -117
- package/types/libs/hephaestus/dialogGenerator/dialogGenerator.d.ts +122 -122
- package/types/libs/hephaestus/feedbackGenerator/feedbackGenerator.d.ts +3 -0
- package/types/libs/hephaestus/formGenerator/authForms.d.ts +130 -130
- package/types/libs/hephaestus/formGenerator/formBuilder.d.ts +128 -128
- package/types/libs/hephaestus/tableGenerator/tableGenerator.d.ts +133 -129
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "athena-ui-js",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.6.1",
|
|
4
4
|
"description": "A small, dependency-free UI framework: forms, tables, charts, menus, dialogs, themes and a router, written as ES modules.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/athena-ui.js",
|
|
@@ -20,6 +20,10 @@
|
|
|
20
20
|
"types": "./types/athena-ui.d.ts",
|
|
21
21
|
"default": "./src/athena-ui.js"
|
|
22
22
|
},
|
|
23
|
+
"./app": {
|
|
24
|
+
"types": "./types/app.d.ts",
|
|
25
|
+
"default": "./src/app.js"
|
|
26
|
+
},
|
|
23
27
|
"./classic": {
|
|
24
28
|
"types": "./types/classic.d.ts",
|
|
25
29
|
"default": "./src/classic.js"
|
package/src/app.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
//app entry of Athena UI: init, createApp and setTheme, the start of a page, without the components
|
|
2
|
+
//Import only what you use: `import { init } from "athena-ui-js/app"`. The root file loads every component, this one only the layout and the theme.
|
|
3
|
+
//LICENCE: MIT
|
|
4
|
+
//Repository: https://github.com/csabatibortoth/athena-ui
|
|
5
|
+
|
|
6
|
+
import config, { applyConfig } from "./libs/config/config.js";
|
|
7
|
+
import { getAppConfig, setHooks } from "./libs/config/hooks.js";
|
|
8
|
+
import { loadScript, loadTheme } from "./libs/hephaestus/hephaestus.js";
|
|
9
|
+
import { generateBasicLayout, setLayoutRoot } from "./libs/hephaestus/LayoutGenerator/basicLayoutGenerator.js";
|
|
10
|
+
import { asHandle, resolveElement, uid } from "./libs/core/dom.js";
|
|
11
|
+
import { setLocale } from "./libs/core/i18n.js";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Loads the theme, waits for the page and generates the layout.
|
|
15
|
+
*
|
|
16
|
+
* @param {object} [options]
|
|
17
|
+
* @param {{id?: number, href?: string}} [options.theme] registered theme id or custom stylesheet
|
|
18
|
+
* @param {object} [options.config] settings overriding the defaults (and the global appConfig)
|
|
19
|
+
* @param {Function} [options.nav] navigation callback (falls back to the global nav)
|
|
20
|
+
* @param {Function} [options.login] login callback (falls back to the global login)
|
|
21
|
+
* @param {Function} [options.register] registration callback (falls back to the global register)
|
|
22
|
+
* @param {Function} [options.lostPassword] lost password callback (falls back to the global lostPassword)
|
|
23
|
+
* @param {Function} [options.changePassword] change password callback (falls back to the global changePassword)
|
|
24
|
+
* @param {object} [options.menuItems] { headerMenu, footerMenu } (falls back to the global menuItems)
|
|
25
|
+
* @returns {Promise<object>} the effective configuration
|
|
26
|
+
*/
|
|
27
|
+
export async function init(options = {}) {
|
|
28
|
+
applyConfig(getAppConfig(), options.config);
|
|
29
|
+
setLocale(config.locale);
|
|
30
|
+
setHooks(options);
|
|
31
|
+
|
|
32
|
+
await Promise.all([
|
|
33
|
+
config.customLoader ? loadScript(config.customLoader) : undefined,
|
|
34
|
+
loadTheme(options.theme ?? options.themes),
|
|
35
|
+
new Promise(resolve => (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", resolve, { once: true }) : resolve()))
|
|
36
|
+
]);
|
|
37
|
+
|
|
38
|
+
generateBasicLayout();
|
|
39
|
+
return config;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Starts Athena UI inside an element of your page instead of the body, so it can be one part of a larger page (or of several apps).
|
|
44
|
+
* It does what init() does (settings, language, theme, hooks), and the layout (container, header, wrapper, footer) is generated into
|
|
45
|
+
* `root`. The parts follow the settings: `config: { generateHeader: false, generateFooter: false }` leaves only the wrapper, which is where
|
|
46
|
+
* the components go by default (the element with the id "wrapper"). One app per page: the parts have fixed ids.
|
|
47
|
+
*
|
|
48
|
+
* @param {object} options the options of init(), and
|
|
49
|
+
* @param {string|Element} options.root the element to build into (an element, an id or a selector)
|
|
50
|
+
* @returns {Promise<{element: HTMLElement, container: HTMLElement, header: HTMLElement|null, wrapper: HTMLElement|null, footer: HTMLElement|null,
|
|
51
|
+
* config: object, update: Function, destroy: Function}>}
|
|
52
|
+
*/
|
|
53
|
+
export async function createApp(options = {}) {
|
|
54
|
+
const root = resolveElement(options.root);
|
|
55
|
+
if (!root) throw new Error("Athena UI: createApp needs a root element (an element, an id or a selector)");
|
|
56
|
+
if (!root.id) root.id = uid("athena-app");
|
|
57
|
+
setLayoutRoot(root.id);
|
|
58
|
+
let effective;
|
|
59
|
+
try {
|
|
60
|
+
effective = await init(options);
|
|
61
|
+
} finally {
|
|
62
|
+
setLayoutRoot("");
|
|
63
|
+
}
|
|
64
|
+
return asHandle({
|
|
65
|
+
element: root,
|
|
66
|
+
container: document.getElementById("container"),
|
|
67
|
+
header: document.getElementById("header"),
|
|
68
|
+
wrapper: document.getElementById("wrapper"),
|
|
69
|
+
footer: document.getElementById("footer"),
|
|
70
|
+
config: effective,
|
|
71
|
+
destroy() {
|
|
72
|
+
document.getElementById("container")?.remove();
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Switches the theme at runtime: { id } of a registered theme or { href } of a stylesheet.
|
|
79
|
+
* @returns {Promise<object>} the applied theme
|
|
80
|
+
*/
|
|
81
|
+
export function setTheme(selected) {
|
|
82
|
+
return loadTheme(selected);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export { config, loadScript };
|
package/src/athena-ui.js
CHANGED
|
@@ -2,91 +2,16 @@
|
|
|
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: 2.
|
|
5
|
+
//Version: 2.6.1
|
|
6
6
|
|
|
7
7
|
// The whole API as ES module exports. There are no side effects: importing this file does not touch the page, does not load a script and does not
|
|
8
8
|
// put anything on globalThis. For pages that need globals use `athena-ui-js/classic`, and to download only what you use import from the entry points
|
|
9
9
|
// (`athena-ui-js/table`, `athena-ui-js/dialog`, ...).
|
|
10
10
|
|
|
11
|
-
import config
|
|
12
|
-
import {
|
|
13
|
-
import { loadScript, loadTheme } from "./libs/hephaestus/hephaestus.js";
|
|
14
|
-
import { generateBasicLayout, setLayoutRoot } from "./libs/hephaestus/LayoutGenerator/basicLayoutGenerator.js";
|
|
15
|
-
import { asHandle, resolveElement, uid } from "./libs/core/dom.js";
|
|
16
|
-
import { setLocale } from "./libs/core/i18n.js";
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Loads the theme, waits for the page and generates the layout.
|
|
20
|
-
*
|
|
21
|
-
* @param {object} [options]
|
|
22
|
-
* @param {{id?: number, href?: string}} [options.theme] registered theme id or custom stylesheet
|
|
23
|
-
* @param {object} [options.config] settings overriding the defaults (and the global appConfig)
|
|
24
|
-
* @param {Function} [options.nav] navigation callback (falls back to the global nav)
|
|
25
|
-
* @param {Function} [options.login] login callback (falls back to the global login)
|
|
26
|
-
* @param {Function} [options.register] registration callback (falls back to the global register)
|
|
27
|
-
* @param {Function} [options.lostPassword] lost password callback (falls back to the global lostPassword)
|
|
28
|
-
* @param {Function} [options.changePassword] change password callback (falls back to the global changePassword)
|
|
29
|
-
* @param {object} [options.menuItems] { headerMenu, footerMenu } (falls back to the global menuItems)
|
|
30
|
-
* @returns {Promise<object>} the effective configuration
|
|
31
|
-
*/
|
|
32
|
-
export async function init(options = {}) {
|
|
33
|
-
applyConfig(getAppConfig(), options.config);
|
|
34
|
-
setLocale(config.locale);
|
|
35
|
-
setHooks(options);
|
|
36
|
-
|
|
37
|
-
await Promise.all([
|
|
38
|
-
config.customLoader ? loadScript(config.customLoader) : undefined,
|
|
39
|
-
loadTheme(options.theme ?? options.themes),
|
|
40
|
-
new Promise(resolve => (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", resolve, { once: true }) : resolve()))
|
|
41
|
-
]);
|
|
42
|
-
|
|
43
|
-
generateBasicLayout();
|
|
44
|
-
return config;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Starts Athena UI inside an element of your page instead of the body, so it can be one part of a larger page (or of several apps).
|
|
49
|
-
* It does what init() does (settings, language, theme, hooks), and the layout (container, header, wrapper, footer) is generated into
|
|
50
|
-
* `root`. The parts follow the settings: `config: { generateHeader: false, generateFooter: false }` leaves only the wrapper, which is where
|
|
51
|
-
* the components go by default (the element with the id "wrapper"). One app per page: the parts have fixed ids.
|
|
52
|
-
*
|
|
53
|
-
* @param {object} options the options of init(), and
|
|
54
|
-
* @param {string|Element} options.root the element to build into (an element, an id or a selector)
|
|
55
|
-
* @returns {Promise<{element: HTMLElement, container: HTMLElement, header: HTMLElement|null, wrapper: HTMLElement|null, footer: HTMLElement|null,
|
|
56
|
-
* config: object, update: Function, destroy: Function}>}
|
|
57
|
-
*/
|
|
58
|
-
export async function createApp(options = {}) {
|
|
59
|
-
const root = resolveElement(options.root);
|
|
60
|
-
if (!root) throw new Error("Athena UI: createApp needs a root element (an element, an id or a selector)");
|
|
61
|
-
if (!root.id) root.id = uid("athena-app");
|
|
62
|
-
setLayoutRoot(root.id);
|
|
63
|
-
let effective;
|
|
64
|
-
try {
|
|
65
|
-
effective = await init(options);
|
|
66
|
-
} finally {
|
|
67
|
-
setLayoutRoot("");
|
|
68
|
-
}
|
|
69
|
-
return asHandle({
|
|
70
|
-
element: root,
|
|
71
|
-
container: document.getElementById("container"),
|
|
72
|
-
header: document.getElementById("header"),
|
|
73
|
-
wrapper: document.getElementById("wrapper"),
|
|
74
|
-
footer: document.getElementById("footer"),
|
|
75
|
-
config: effective,
|
|
76
|
-
destroy() {
|
|
77
|
-
document.getElementById("container")?.remove();
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Switches the theme at runtime: { id } of a registered theme or { href } of a stylesheet.
|
|
84
|
-
* @returns {Promise<object>} the applied theme
|
|
85
|
-
*/
|
|
86
|
-
export function setTheme(selected) {
|
|
87
|
-
return loadTheme(selected);
|
|
88
|
-
}
|
|
11
|
+
import config from "./libs/config/config.js";
|
|
12
|
+
import { loadScript } from "./libs/hephaestus/hephaestus.js";
|
|
89
13
|
|
|
14
|
+
export { init, createApp, setTheme } from "./app.js";
|
|
90
15
|
export { config, loadScript };
|
|
91
16
|
export { default as Cookies } from "./libs/core/cookies.js";
|
|
92
17
|
export * from "./libs/core/elementGenerator.js";
|