athena-ui-js 2.5.0 → 2.6.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/src/athena-ui.js CHANGED
@@ -1,135 +1,60 @@
1
- //Athena UI
2
- //Author: Csaba Tóth https://github.com/csabatibortoth/
3
- //LICENCE: MIT
4
- //Repository: https://github.com/csabatibortoth/athena-ui
5
- //Version: 2.5.0
6
-
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
- // 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
- // (`athena-ui-js/table`, `athena-ui-js/dialog`, ...).
10
-
11
- import config, { applyConfig } from "./libs/config/config.js";
12
- import { getAppConfig, setHooks } from "./libs/config/hooks.js";
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
- }
89
-
90
- export { config, loadScript };
91
- export { default as Cookies } from "./libs/core/cookies.js";
92
- export * from "./libs/core/elementGenerator.js";
93
- export * from "./libs/core/controls.js";
94
- export * from "./libs/core/hungarianControls.js";
95
- export * from "./libs/hephaestus/LayoutGenerator/basicLayoutGenerator.js";
96
- export * from "./libs/hephaestus/LayoutGenerator/headerContentGenerator.js";
97
- export * from "./libs/hephaestus/LayoutGenerator/wrapperContentGenerator.js";
98
- export * from "./libs/hephaestus/LayoutGenerator/footerContentGenerator.js";
99
- export * from "./libs/hephaestus/MenuGenerator/basicMenuGenerator.js";
100
- export * from "./libs/hephaestus/MenuGenerator/menuGenerator.js";
101
- export * from "./libs/hephaestus/formGenerator/loginFormGenerator.js";
102
- export * from "./libs/hephaestus/formGenerator/registrationFormGenerator.js";
103
- export * from "./libs/hephaestus/formGenerator/lostPasswordFormGenerator.js";
104
- export * from "./libs/hephaestus/chartGenerator/chartGenerator.js";
105
- export * from "./libs/hephaestus/tableGenerator/tableGenerator.js";
106
- export * from "./libs/hephaestus/formGenerator/changePasswordFormGenerator.js";
107
- export * from "./libs/hephaestus/formGenerator/formBuilder.js";
108
- export * from "./libs/hephaestus/formGenerator/authForms.js";
109
- export * from "./libs/hephaestus/feedbackGenerator/feedbackGenerator.js";
110
- export * from "./libs/hephaestus/dialogGenerator/dialogGenerator.js";
111
- export * from "./libs/hephaestus/navigationGenerator/navigationGenerator.js";
112
- export * from "./libs/hephaestus/componentGenerator/componentGenerator.js";
113
- export * from "./libs/hephaestus/inputGenerator/inputGenerator.js";
114
- export * from "./libs/hephaestus/inputGenerator/dropZoneGenerator.js";
115
- export * from "./libs/hephaestus/inputGenerator/richTextGenerator.js";
116
- export { el, setContent, resolveElement, asHandle, createSafeBuilder } from "./libs/core/dom.js";
117
- export * from "./libs/core/sanitize.js";
118
- export * from "./libs/hephaestus/router/router.js";
119
- export * from "./libs/hephaestus/auth/session.js";
120
- export * from "./libs/hephaestus/auth/authState.js";
121
- export * from "./libs/core/i18n.js";
122
- export * from "./libs/core/validation.js";
123
- export * from "./libs/core/csv.js";
124
- export * from "./libs/core/dateRange.js";
125
- export * from "./libs/core/format.js";
126
- export * from "./libs/core/motion.js";
127
- export * from "./libs/hephaestus/widgetGrid/widgetGrid.js";
128
- export * from "./libs/core/gridLayout.js";
129
- export * from "./libs/hephaestus/codeGenerator/codeGenerator.js";
130
- export * from "./libs/hephaestus/codeGenerator/codeEditor.js";
131
- export * from "./libs/core/codeLanguages.js";
132
- export * from "./libs/core/codeDiff.js";
133
- export * from "./libs/hephaestus/modalGenerator/modalGenerator.js";
134
- export * from "./libs/core/theme.js";
135
- export * from "./libs/hephaestus/componentGenerator/themePicker.js";
1
+ //Athena UI
2
+ //Author: Csaba Tóth https://github.com/csabatibortoth/
3
+ //LICENCE: MIT
4
+ //Repository: https://github.com/csabatibortoth/athena-ui
5
+ //Version: 2.6.0
6
+
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
+ // 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
+ // (`athena-ui-js/table`, `athena-ui-js/dialog`, ...).
10
+
11
+ import config from "./libs/config/config.js";
12
+ import { loadScript } from "./libs/hephaestus/hephaestus.js";
13
+
14
+ export { init, createApp, setTheme } from "./app.js";
15
+ export { config, loadScript };
16
+ export { default as Cookies } from "./libs/core/cookies.js";
17
+ export * from "./libs/core/elementGenerator.js";
18
+ export * from "./libs/core/controls.js";
19
+ export * from "./libs/core/hungarianControls.js";
20
+ export * from "./libs/hephaestus/LayoutGenerator/basicLayoutGenerator.js";
21
+ export * from "./libs/hephaestus/LayoutGenerator/headerContentGenerator.js";
22
+ export * from "./libs/hephaestus/LayoutGenerator/wrapperContentGenerator.js";
23
+ export * from "./libs/hephaestus/LayoutGenerator/footerContentGenerator.js";
24
+ export * from "./libs/hephaestus/MenuGenerator/basicMenuGenerator.js";
25
+ export * from "./libs/hephaestus/MenuGenerator/menuGenerator.js";
26
+ export * from "./libs/hephaestus/formGenerator/loginFormGenerator.js";
27
+ export * from "./libs/hephaestus/formGenerator/registrationFormGenerator.js";
28
+ export * from "./libs/hephaestus/formGenerator/lostPasswordFormGenerator.js";
29
+ export * from "./libs/hephaestus/chartGenerator/chartGenerator.js";
30
+ export * from "./libs/hephaestus/tableGenerator/tableGenerator.js";
31
+ export * from "./libs/hephaestus/formGenerator/changePasswordFormGenerator.js";
32
+ export * from "./libs/hephaestus/formGenerator/formBuilder.js";
33
+ export * from "./libs/hephaestus/formGenerator/authForms.js";
34
+ export * from "./libs/hephaestus/feedbackGenerator/feedbackGenerator.js";
35
+ export * from "./libs/hephaestus/dialogGenerator/dialogGenerator.js";
36
+ export * from "./libs/hephaestus/navigationGenerator/navigationGenerator.js";
37
+ export * from "./libs/hephaestus/componentGenerator/componentGenerator.js";
38
+ export * from "./libs/hephaestus/inputGenerator/inputGenerator.js";
39
+ export * from "./libs/hephaestus/inputGenerator/dropZoneGenerator.js";
40
+ export * from "./libs/hephaestus/inputGenerator/richTextGenerator.js";
41
+ export { el, setContent, resolveElement, asHandle, createSafeBuilder } from "./libs/core/dom.js";
42
+ export * from "./libs/core/sanitize.js";
43
+ export * from "./libs/hephaestus/router/router.js";
44
+ export * from "./libs/hephaestus/auth/session.js";
45
+ export * from "./libs/hephaestus/auth/authState.js";
46
+ export * from "./libs/core/i18n.js";
47
+ export * from "./libs/core/validation.js";
48
+ export * from "./libs/core/csv.js";
49
+ export * from "./libs/core/dateRange.js";
50
+ export * from "./libs/core/format.js";
51
+ export * from "./libs/core/motion.js";
52
+ export * from "./libs/hephaestus/widgetGrid/widgetGrid.js";
53
+ export * from "./libs/core/gridLayout.js";
54
+ export * from "./libs/hephaestus/codeGenerator/codeGenerator.js";
55
+ export * from "./libs/hephaestus/codeGenerator/codeEditor.js";
56
+ export * from "./libs/core/codeLanguages.js";
57
+ export * from "./libs/core/codeDiff.js";
58
+ export * from "./libs/hephaestus/modalGenerator/modalGenerator.js";
59
+ export * from "./libs/core/theme.js";
60
+ export * from "./libs/hephaestus/componentGenerator/themePicker.js";
@@ -1,66 +1,66 @@
1
- //config for Athena UI
2
- //Author: Csaba Tóth https://github.com/csabatibortoth/
3
- //LICENCE: MIT
4
- //Repository: https://github.com/csabatibortoth/athena-ui
5
-
6
- export const BORDERED_CLASS = "default-cointainer-bordered";
7
-
8
- export const defaults = Object.freeze({
9
- version: "2.5.0",
10
- container_class: "container",
11
- header_class: "header-container",
12
- header_menu_class: "header-menu menu",
13
- wrapper_class: "wrapper-container",
14
- footer_class: "footer-container",
15
- footer_menu_class: "footer-menu menu",
16
- loginForm_class: "login-form form",
17
- registrationForm_class: "registration-form form",
18
- lostPasswordForm_class: "lost-password-form form",
19
- changePasswordForm_class: "change-password-form form",
20
-
21
- bordered: true,
22
- generateHeader: true,
23
- generateFooter: true,
24
- generateHeadercontent: true,
25
- generateFooterContent: true,
26
- generateWrappercontent: true,
27
- login_enabled: false,
28
- registration_enabled: false,
29
- lost_password_enabled: false,
30
- change_password_enabled: false,
31
- login_remember_me: false,
32
-
33
- header_title_text: "Athena UI",
34
- header_img_url: undefined,
35
- copyright: "Here is the bottom Copyright Text for website",
36
-
37
- // Language of the generated texts, see core/i18n.js
38
- locale: "en",
39
-
40
- // Cookie that keeps the session, and the lifetime (days) of a remembered session
41
- session_cookie: "athena_session",
42
- session_days: 7,
43
-
44
- // URL (relative to the page) of an extra classic script, loaded before the layout is generated
45
- customLoader: undefined
46
- });
47
-
48
- const config = { ...defaults };
49
-
50
- export default config;
51
-
52
- // Copies every known setting that is defined in the given sources onto the live config.
53
- export function applyConfig(...sources) {
54
- for (const source of sources) {
55
- if (!source) continue;
56
- for (const key of Object.keys(defaults)) {
57
- if (source[key] !== undefined) config[key] = source[key];
58
- }
59
- }
60
- return config;
61
- }
62
-
63
- // Appends the border class to a class list when borders are enabled.
64
- export function withBorder(className) {
65
- return config.bordered ? `${className} ${BORDERED_CLASS}` : className;
66
- }
1
+ //config for Athena UI
2
+ //Author: Csaba Tóth https://github.com/csabatibortoth/
3
+ //LICENCE: MIT
4
+ //Repository: https://github.com/csabatibortoth/athena-ui
5
+
6
+ export const BORDERED_CLASS = "default-cointainer-bordered";
7
+
8
+ export const defaults = Object.freeze({
9
+ version: "2.6.0",
10
+ container_class: "container",
11
+ header_class: "header-container",
12
+ header_menu_class: "header-menu menu",
13
+ wrapper_class: "wrapper-container",
14
+ footer_class: "footer-container",
15
+ footer_menu_class: "footer-menu menu",
16
+ loginForm_class: "login-form form",
17
+ registrationForm_class: "registration-form form",
18
+ lostPasswordForm_class: "lost-password-form form",
19
+ changePasswordForm_class: "change-password-form form",
20
+
21
+ bordered: true,
22
+ generateHeader: true,
23
+ generateFooter: true,
24
+ generateHeadercontent: true,
25
+ generateFooterContent: true,
26
+ generateWrappercontent: true,
27
+ login_enabled: false,
28
+ registration_enabled: false,
29
+ lost_password_enabled: false,
30
+ change_password_enabled: false,
31
+ login_remember_me: false,
32
+
33
+ header_title_text: "Athena UI",
34
+ header_img_url: undefined,
35
+ copyright: "Here is the bottom Copyright Text for website",
36
+
37
+ // Language of the generated texts, see core/i18n.js
38
+ locale: "en",
39
+
40
+ // Cookie that keeps the session, and the lifetime (days) of a remembered session
41
+ session_cookie: "athena_session",
42
+ session_days: 7,
43
+
44
+ // URL (relative to the page) of an extra classic script, loaded before the layout is generated
45
+ customLoader: undefined
46
+ });
47
+
48
+ const config = { ...defaults };
49
+
50
+ export default config;
51
+
52
+ // Copies every known setting that is defined in the given sources onto the live config.
53
+ export function applyConfig(...sources) {
54
+ for (const source of sources) {
55
+ if (!source) continue;
56
+ for (const key of Object.keys(defaults)) {
57
+ if (source[key] !== undefined) config[key] = source[key];
58
+ }
59
+ }
60
+ return config;
61
+ }
62
+
63
+ // Appends the border class to a class list when borders are enabled.
64
+ export function withBorder(className) {
65
+ return config.bordered ? `${className} ${BORDERED_CLASS}` : className;
66
+ }