athena-ui-js 1.3.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/README.md +100 -54
  2. package/docs/migration-2.0.md +83 -0
  3. package/docs/styling.md +86 -0
  4. package/package.json +108 -25
  5. package/src/athena-ui.js +54 -97
  6. package/src/chart.js +6 -0
  7. package/src/classic.js +11 -0
  8. package/src/components.js +6 -0
  9. package/src/controls.js +8 -0
  10. package/src/csv.js +6 -0
  11. package/src/dialog.js +7 -0
  12. package/src/dom.js +6 -0
  13. package/src/feedback.js +6 -0
  14. package/src/format.js +6 -0
  15. package/src/forms.js +7 -0
  16. package/src/i18n.js +6 -0
  17. package/src/inputs.js +9 -0
  18. package/src/libs/config/config.js +1 -9
  19. package/src/libs/core/controls.js +6 -14
  20. package/src/libs/core/cookies.js +55 -0
  21. package/src/libs/core/i18n.js +40 -6
  22. package/src/libs/core/validation.js +2 -2
  23. package/src/libs/hephaestus/LayoutGenerator/basicLayoutGenerator.js +9 -1
  24. package/src/libs/hephaestus/MenuGenerator/menuGenerator.js +16 -4
  25. package/src/libs/hephaestus/auth/session.js +1 -1
  26. package/src/libs/hephaestus/dialogGenerator/dialogGenerator.js +25 -17
  27. package/src/libs/hephaestus/formGenerator/changePasswordFormGenerator.js +4 -4
  28. package/src/libs/hephaestus/formGenerator/formUtils.js +0 -4
  29. package/src/libs/hephaestus/formGenerator/loginFormGenerator.js +2 -3
  30. package/src/libs/hephaestus/formGenerator/registrationFormGenerator.js +3 -3
  31. package/src/libs/hephaestus/hephaestus.js +0 -10
  32. package/src/libs/hephaestus/inputGenerator/dropZoneGenerator.js +1 -1
  33. package/src/libs/hephaestus/modalGenerator/modalGenerator.js +13 -6
  34. package/src/libs/hephaestus/navigationGenerator/navigationGenerator.js +20 -24
  35. package/src/menu.js +6 -0
  36. package/src/navigation.js +6 -0
  37. package/src/res/themes/default/style.css +97 -100
  38. package/src/res/themes/tokens.css +96 -0
  39. package/src/router.js +6 -0
  40. package/src/sanitize.js +6 -0
  41. package/src/session.js +8 -0
  42. package/src/table.js +6 -0
  43. package/src/testing.js +11 -1
  44. package/src/theme.js +7 -0
  45. package/src/validation.js +6 -0
  46. package/types/athena-ui.d.ts +96 -0
  47. package/types/chart.d.ts +1 -0
  48. package/types/classic.d.ts +1 -0
  49. package/types/components.d.ts +1 -0
  50. package/types/controls.d.ts +3 -0
  51. package/types/csv.d.ts +1 -0
  52. package/types/dialog.d.ts +2 -0
  53. package/types/dom.d.ts +1 -0
  54. package/types/feedback.d.ts +1 -0
  55. package/types/format.d.ts +1 -0
  56. package/types/forms.d.ts +2 -0
  57. package/types/i18n.d.ts +1 -0
  58. package/types/inputs.d.ts +4 -0
  59. package/types/libs/config/config.d.ts +96 -0
  60. package/types/libs/config/hooks.d.ts +8 -0
  61. package/types/libs/core/combobox.d.ts +10 -0
  62. package/types/libs/core/controls.d.ts +28 -0
  63. package/types/libs/core/cookies.d.ts +27 -0
  64. package/types/libs/core/csv.d.ts +12 -0
  65. package/types/libs/core/dateRange.d.ts +72 -0
  66. package/types/libs/core/dom.d.ts +65 -0
  67. package/types/libs/core/elementGenerator.d.ts +30 -0
  68. package/types/libs/core/errors.d.ts +29 -0
  69. package/types/libs/core/focus.d.ts +6 -0
  70. package/types/libs/core/format.d.ts +21 -0
  71. package/types/libs/core/hungarianControls.d.ts +2 -0
  72. package/types/libs/core/i18n.d.ts +17 -0
  73. package/types/libs/core/pagination.d.ts +5 -0
  74. package/types/libs/core/sanitize.d.ts +6 -0
  75. package/types/libs/core/tableMath.d.ts +26 -0
  76. package/types/libs/core/theme.d.ts +39 -0
  77. package/types/libs/core/validation.d.ts +56 -0
  78. package/types/libs/hephaestus/LayoutGenerator/basicLayoutGenerator.d.ts +10 -0
  79. package/types/libs/hephaestus/LayoutGenerator/footerContentGenerator.d.ts +4 -0
  80. package/types/libs/hephaestus/LayoutGenerator/headerContentGenerator.d.ts +20 -0
  81. package/types/libs/hephaestus/LayoutGenerator/wrapperContentGenerator.d.ts +1 -0
  82. package/types/libs/hephaestus/MenuGenerator/basicMenuGenerator.d.ts +14 -0
  83. package/types/libs/hephaestus/MenuGenerator/menuGenerator.d.ts +65 -0
  84. package/types/libs/hephaestus/auth/authState.d.ts +26 -0
  85. package/types/libs/hephaestus/auth/session.d.ts +26 -0
  86. package/types/libs/hephaestus/chartGenerator/chartGenerator.d.ts +91 -0
  87. package/types/libs/hephaestus/componentGenerator/componentGenerator.d.ts +222 -0
  88. package/types/libs/hephaestus/componentGenerator/themePicker.d.ts +24 -0
  89. package/types/libs/hephaestus/dialogGenerator/dialogGenerator.d.ts +120 -0
  90. package/types/libs/hephaestus/feedbackGenerator/feedbackGenerator.d.ts +86 -0
  91. package/types/libs/hephaestus/formGenerator/authForms.d.ts +122 -0
  92. package/types/libs/hephaestus/formGenerator/changePasswordFormGenerator.d.ts +6 -0
  93. package/types/libs/hephaestus/formGenerator/formBuilder.d.ts +113 -0
  94. package/types/libs/hephaestus/formGenerator/formUtils.d.ts +8 -0
  95. package/types/libs/hephaestus/formGenerator/loginFormGenerator.d.ts +11 -0
  96. package/types/libs/hephaestus/formGenerator/lostPasswordFormGenerator.d.ts +4 -0
  97. package/types/libs/hephaestus/formGenerator/registrationFormGenerator.d.ts +7 -0
  98. package/types/libs/hephaestus/hephaestus.d.ts +3 -0
  99. package/types/libs/hephaestus/inputGenerator/dropZoneGenerator.d.ts +48 -0
  100. package/types/libs/hephaestus/inputGenerator/inputGenerator.d.ts +185 -0
  101. package/types/libs/hephaestus/inputGenerator/richTextGenerator.d.ts +49 -0
  102. package/types/libs/hephaestus/modalGenerator/modalGenerator.d.ts +2 -0
  103. package/types/libs/hephaestus/navigationGenerator/navigationGenerator.d.ts +150 -0
  104. package/types/libs/hephaestus/router/matchRoute.d.ts +12 -0
  105. package/types/libs/hephaestus/router/router.d.ts +67 -0
  106. package/types/libs/hephaestus/tableGenerator/tableGenerator.d.ts +120 -0
  107. package/types/menu.d.ts +1 -0
  108. package/types/navigation.d.ts +1 -0
  109. package/types/res/themes/themes.d.ts +7 -0
  110. package/types/router.d.ts +1 -0
  111. package/types/sanitize.d.ts +1 -0
  112. package/types/session.d.ts +3 -0
  113. package/types/table.d.ts +1 -0
  114. package/types/testing.d.ts +27 -0
  115. package/types/theme-boot.d.ts +0 -0
  116. package/types/theme.d.ts +2 -0
  117. package/types/validation.d.ts +1 -0
  118. package/src/libs/crypto-js/LICENSE +0 -24
  119. package/src/libs/crypto-js/crypto-js.js +0 -6657
  120. package/src/libs/js-cookie/LICENSE +0 -21
  121. package/src/libs/js-cookie/src/api.mjs +0 -103
  122. package/src/libs/js-cookie/src/assign.mjs +0 -10
  123. package/src/libs/js-cookie/src/converter.mjs +0 -14
  124. package/src/libs/libs.js +0 -13
package/package.json CHANGED
@@ -1,25 +1,109 @@
1
1
  {
2
2
  "name": "athena-ui-js",
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.",
3
+ "version": "2.0.0",
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",
7
7
  "scripts": {
8
8
  "test": "node --test tests/*.test.js",
9
- "test:browser": "node tests/browser/run.mjs"
9
+ "test:browser": "node tests/browser/run.mjs",
10
+ "docs": "node scripts/styling-docs.mjs",
11
+ "types": "tsc -p tsconfig.types.json"
10
12
  },
11
13
  "exports": {
12
- ".": "./src/athena-ui.js",
13
- "./testing": "./src/testing.js",
14
+ ".": {
15
+ "types": "./types/athena-ui.d.ts",
16
+ "default": "./src/athena-ui.js"
17
+ },
18
+ "./classic": {
19
+ "types": "./types/classic.d.ts",
20
+ "default": "./src/classic.js"
21
+ },
22
+ "./testing": {
23
+ "types": "./types/testing.d.ts",
24
+ "default": "./src/testing.js"
25
+ },
14
26
  "./theme-boot.js": "./src/theme-boot.js",
27
+ "./table": {
28
+ "types": "./types/table.d.ts",
29
+ "default": "./src/table.js"
30
+ },
31
+ "./chart": {
32
+ "types": "./types/chart.d.ts",
33
+ "default": "./src/chart.js"
34
+ },
35
+ "./dialog": {
36
+ "types": "./types/dialog.d.ts",
37
+ "default": "./src/dialog.js"
38
+ },
39
+ "./menu": {
40
+ "types": "./types/menu.d.ts",
41
+ "default": "./src/menu.js"
42
+ },
43
+ "./navigation": {
44
+ "types": "./types/navigation.d.ts",
45
+ "default": "./src/navigation.js"
46
+ },
47
+ "./forms": {
48
+ "types": "./types/forms.d.ts",
49
+ "default": "./src/forms.js"
50
+ },
51
+ "./feedback": {
52
+ "types": "./types/feedback.d.ts",
53
+ "default": "./src/feedback.js"
54
+ },
55
+ "./components": {
56
+ "types": "./types/components.d.ts",
57
+ "default": "./src/components.js"
58
+ },
59
+ "./inputs": {
60
+ "types": "./types/inputs.d.ts",
61
+ "default": "./src/inputs.js"
62
+ },
63
+ "./router": {
64
+ "types": "./types/router.d.ts",
65
+ "default": "./src/router.js"
66
+ },
67
+ "./session": {
68
+ "types": "./types/session.d.ts",
69
+ "default": "./src/session.js"
70
+ },
71
+ "./theme": {
72
+ "types": "./types/theme.d.ts",
73
+ "default": "./src/theme.js"
74
+ },
75
+ "./i18n": {
76
+ "types": "./types/i18n.d.ts",
77
+ "default": "./src/i18n.js"
78
+ },
79
+ "./format": {
80
+ "types": "./types/format.d.ts",
81
+ "default": "./src/format.js"
82
+ },
83
+ "./validation": {
84
+ "types": "./types/validation.d.ts",
85
+ "default": "./src/validation.js"
86
+ },
87
+ "./sanitize": {
88
+ "types": "./types/sanitize.d.ts",
89
+ "default": "./src/sanitize.js"
90
+ },
91
+ "./csv": {
92
+ "types": "./types/csv.d.ts",
93
+ "default": "./src/csv.js"
94
+ },
95
+ "./dom": {
96
+ "types": "./types/dom.d.ts",
97
+ "default": "./src/dom.js"
98
+ },
99
+ "./controls": {
100
+ "types": "./types/controls.d.ts",
101
+ "default": "./src/controls.js"
102
+ },
15
103
  "./themes/*": "./src/res/themes/*",
16
104
  "./package.json": "./package.json"
17
105
  },
18
106
  "files": [
19
- "src/athena-ui.js",
20
- "src/testing.js",
21
- "src/theme-boot.js",
22
- "src/libs/libs.js",
23
107
  "src/libs/config",
24
108
  "src/libs/hephaestus/hephaestus.js",
25
109
  "src/libs/hephaestus/LayoutGenerator",
@@ -36,17 +120,20 @@
36
120
  "src/libs/hephaestus/chartGenerator",
37
121
  "src/libs/hephaestus/tableGenerator",
38
122
  "src/libs/hephaestus/modalGenerator",
39
- "src/libs/crypto-js/LICENSE",
40
- "src/libs/crypto-js/crypto-js.js",
41
- "src/libs/js-cookie/LICENSE",
42
- "src/libs/js-cookie/src",
43
- "src/res"
123
+ "src/res",
124
+ "src/*.js",
125
+ "!src/example.js",
126
+ "types",
127
+ "docs"
128
+ ],
129
+ "sideEffects": [
130
+ "./src/classic.js",
131
+ "./src/theme-boot.js",
132
+ "*.css"
44
133
  ],
45
- "sideEffects": true,
46
134
  "keywords": [
47
135
  "ui",
48
136
  "framework",
49
- "jquery",
50
137
  "layout",
51
138
  "menu",
52
139
  "login-form",
@@ -64,14 +151,6 @@
64
151
  "themes",
65
152
  "es-modules"
66
153
  ],
67
- "peerDependencies": {
68
- "jquery": "^4.0.0"
69
- },
70
- "peerDependenciesMeta": {
71
- "jquery": {
72
- "optional": true
73
- }
74
- },
75
154
  "publishConfig": {
76
155
  "access": "public"
77
156
  },
@@ -84,5 +163,9 @@
84
163
  "url": "https://github.com/csabatibortoth/athena-ui/issues"
85
164
  },
86
165
  "author": "Csaba Tóth (https://github.com/csabatibortoth)",
87
- "license": "MIT"
166
+ "license": "MIT",
167
+ "devDependencies": {
168
+ "typescript": "^5.9.3"
169
+ },
170
+ "types": "./types/athena-ui.d.ts"
88
171
  }
package/src/athena-ui.js CHANGED
@@ -2,52 +2,21 @@
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.3.0
5
+ //Version: 2.0.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`, ...).
6
10
 
7
11
  import config, { applyConfig } from "./libs/config/config.js";
8
12
  import { getAppConfig, setHooks } from "./libs/config/hooks.js";
9
- import { loadLibs, loadScript, loadTheme } from "./libs/hephaestus/hephaestus.js";
10
- import * as layout from "./libs/hephaestus/LayoutGenerator/basicLayoutGenerator.js";
11
- import * as header from "./libs/hephaestus/LayoutGenerator/headerContentGenerator.js";
12
- import * as wrapper from "./libs/hephaestus/LayoutGenerator/wrapperContentGenerator.js";
13
- import * as footer from "./libs/hephaestus/LayoutGenerator/footerContentGenerator.js";
14
- import * as menu from "./libs/hephaestus/MenuGenerator/basicMenuGenerator.js";
15
- import * as menuGenerator from "./libs/hephaestus/MenuGenerator/menuGenerator.js";
16
- import * as loginForm from "./libs/hephaestus/formGenerator/loginFormGenerator.js";
17
- import * as registrationForm from "./libs/hephaestus/formGenerator/registrationFormGenerator.js";
18
- import * as lostPasswordForm from "./libs/hephaestus/formGenerator/lostPasswordFormGenerator.js";
19
- import * as chart from "./libs/hephaestus/chartGenerator/chartGenerator.js";
20
- import * as table from "./libs/hephaestus/tableGenerator/tableGenerator.js";
21
- import * as changePasswordForm from "./libs/hephaestus/formGenerator/changePasswordFormGenerator.js";
22
- import * as formBuilder from "./libs/hephaestus/formGenerator/formBuilder.js";
23
- import * as feedback from "./libs/hephaestus/feedbackGenerator/feedbackGenerator.js";
24
- import * as dialog from "./libs/hephaestus/dialogGenerator/dialogGenerator.js";
25
- import * as navigation from "./libs/hephaestus/navigationGenerator/navigationGenerator.js";
26
- import * as components from "./libs/hephaestus/componentGenerator/componentGenerator.js";
27
- import * as inputs from "./libs/hephaestus/inputGenerator/inputGenerator.js";
28
- import * as dropZone from "./libs/hephaestus/inputGenerator/dropZoneGenerator.js";
29
- import * as richText from "./libs/hephaestus/inputGenerator/richTextGenerator.js";
30
- import * as sanitize from "./libs/core/sanitize.js";
31
- import * as router from "./libs/hephaestus/router/router.js";
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";
35
- import * as i18n from "./libs/core/i18n.js";
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";
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";
42
- import * as modal from "./libs/hephaestus/modalGenerator/modalGenerator.js";
43
- import Cookies from "./libs/js-cookie/src/api.mjs";
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";
47
-
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";
48
17
 
49
18
  /**
50
- * Loads the libraries and the theme in parallel, then generates the layout.
19
+ * Loads the theme, waits for the page and generates the layout.
51
20
  *
52
21
  * @param {object} [options]
53
22
  * @param {{id?: number, href?: string}} [options.theme] registered theme id or custom stylesheet
@@ -62,19 +31,54 @@ import { registerHungarianInputControls } from "./libs/core/hungarianControls.js
62
31
  */
63
32
  export async function init(options = {}) {
64
33
  applyConfig(getAppConfig(), options.config);
65
- i18n.setLocale(config.locale);
34
+ setLocale(config.locale);
66
35
  setHooks(options);
67
36
 
68
37
  await Promise.all([
69
- loadLibs(config.customLoader ? [config.customLoader] : [], { crypto: config.enable_encrypt_password }),
38
+ config.customLoader ? loadScript(config.customLoader) : undefined,
70
39
  loadTheme(options.theme ?? options.themes),
71
40
  new Promise(resolve => (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", resolve, { once: true }) : resolve()))
72
41
  ]);
73
42
 
74
- layout.generateBasicLayout();
43
+ generateBasicLayout();
75
44
  return config;
76
45
  }
77
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
+
78
82
  /**
79
83
  * Switches the theme at runtime: { id } of a registered theme or { href } of a stylesheet.
80
84
  * @returns {Promise<object>} the applied theme
@@ -83,57 +87,11 @@ export function setTheme(selected) {
83
87
  return loadTheme(selected);
84
88
  }
85
89
 
86
- const AthenaUI = {
87
- init,
88
- config,
89
- loadScript,
90
- Cookies,
91
- HTMLElementGenerator,
92
- HTMLControlGenerator,
93
- registerControl,
94
- generateControl,
95
- registerHungarianInputControls,
96
- ...layout,
97
- ...header,
98
- ...wrapper,
99
- ...footer,
100
- ...menu,
101
- ...menuGenerator,
102
- ...loginForm,
103
- ...registrationForm,
104
- ...lostPasswordForm,
105
- ...changePasswordForm,
106
- ...formBuilder,
107
- ...feedback,
108
- ...dialog,
109
- ...navigation,
110
- ...components,
111
- ...inputs,
112
- ...dropZone,
113
- ...richText,
114
- ...sanitize,
115
- ...router,
116
- ...session,
117
- ...authState,
118
- ...authForms,
119
- ...i18n,
120
- ...validation,
121
- ...csv,
122
- ...dateRange,
123
- ...format,
124
- setTheme,
125
- ...chart,
126
- ...table,
127
- ...theme,
128
- ...themePicker,
129
- ...modal
130
- };
131
-
132
- // Classic scripts (the customLoader, inline handlers) keep working: the whole API
133
- // stays reachable as globals, like in the pre-module versions.
134
- Object.assign(globalThis, AthenaUI, { AthenaUI });
135
-
136
- export { config, loadScript, Cookies, HTMLElementGenerator, HTMLControlGenerator, registerControl, generateControl, registerHungarianInputControls };
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";
137
95
  export * from "./libs/hephaestus/LayoutGenerator/basicLayoutGenerator.js";
138
96
  export * from "./libs/hephaestus/LayoutGenerator/headerContentGenerator.js";
139
97
  export * from "./libs/hephaestus/LayoutGenerator/wrapperContentGenerator.js";
@@ -147,6 +105,7 @@ export * from "./libs/hephaestus/chartGenerator/chartGenerator.js";
147
105
  export * from "./libs/hephaestus/tableGenerator/tableGenerator.js";
148
106
  export * from "./libs/hephaestus/formGenerator/changePasswordFormGenerator.js";
149
107
  export * from "./libs/hephaestus/formGenerator/formBuilder.js";
108
+ export * from "./libs/hephaestus/formGenerator/authForms.js";
150
109
  export * from "./libs/hephaestus/feedbackGenerator/feedbackGenerator.js";
151
110
  export * from "./libs/hephaestus/dialogGenerator/dialogGenerator.js";
152
111
  export * from "./libs/hephaestus/navigationGenerator/navigationGenerator.js";
@@ -159,7 +118,6 @@ export * from "./libs/core/sanitize.js";
159
118
  export * from "./libs/hephaestus/router/router.js";
160
119
  export * from "./libs/hephaestus/auth/session.js";
161
120
  export * from "./libs/hephaestus/auth/authState.js";
162
- export * from "./libs/hephaestus/formGenerator/authForms.js";
163
121
  export * from "./libs/core/i18n.js";
164
122
  export * from "./libs/core/validation.js";
165
123
  export * from "./libs/core/csv.js";
@@ -168,4 +126,3 @@ export * from "./libs/core/format.js";
168
126
  export * from "./libs/hephaestus/modalGenerator/modalGenerator.js";
169
127
  export * from "./libs/core/theme.js";
170
128
  export * from "./libs/hephaestus/componentGenerator/themePicker.js";
171
- export default AthenaUI;
package/src/chart.js ADDED
@@ -0,0 +1,6 @@
1
+ //chart entry of Athena UI: generateChart
2
+ //Import only what you use: `import { generateTable } from "athena-ui-js/chart"`.
3
+ //LICENCE: MIT
4
+ //Repository: https://github.com/csabatibortoth/athena-ui
5
+
6
+ export * from "./libs/hephaestus/chartGenerator/chartGenerator.js";
package/src/classic.js ADDED
@@ -0,0 +1,11 @@
1
+ //classic build of Athena UI: puts the whole API on globalThis (as window.generateTable, window.AthenaUI, ...)
2
+ //LICENCE: MIT
3
+ //Repository: https://github.com/csabatibortoth/athena-ui
4
+ //
5
+ // The ES module entry points have no side effects. This file is the opt-in for pages that use inline handlers or classic scripts:
6
+ //
7
+ // <script type="module" src="athena-ui/src/classic.js"></script>
8
+
9
+ import * as AthenaUI from "./athena-ui.js";
10
+
11
+ Object.assign(globalThis, AthenaUI, { AthenaUI });
@@ -0,0 +1,6 @@
1
+ //components entry of Athena UI: card, section, grid, badge, avatar, stat, link, tooltip, page header, facts, empty state, loading
2
+ //Import only what you use: `import { generateTable } from "athena-ui-js/components"`.
3
+ //LICENCE: MIT
4
+ //Repository: https://github.com/csabatibortoth/athena-ui
5
+
6
+ export * from "./libs/hephaestus/componentGenerator/componentGenerator.js";
@@ -0,0 +1,8 @@
1
+ //controls entry of Athena UI: HTMLElementGenerator, HTMLControlGenerator, generateControl, registerHungarianInputControls
2
+ //Import only what you use: `import { generateTable } from "athena-ui-js/controls"`.
3
+ //LICENCE: MIT
4
+ //Repository: https://github.com/csabatibortoth/athena-ui
5
+
6
+ export * from "./libs/core/elementGenerator.js";
7
+ export * from "./libs/core/controls.js";
8
+ export * from "./libs/core/hungarianControls.js";
package/src/csv.js ADDED
@@ -0,0 +1,6 @@
1
+ //csv entry of Athena UI: toCsv, downloadFile
2
+ //Import only what you use: `import { generateTable } from "athena-ui-js/csv"`.
3
+ //LICENCE: MIT
4
+ //Repository: https://github.com/csabatibortoth/athena-ui
5
+
6
+ export * from "./libs/core/csv.js";
package/src/dialog.js ADDED
@@ -0,0 +1,7 @@
1
+ //dialog entry of Athena UI: showDialog, showConfirm, showFormDialog, alert / confirm / prompt, openModal, closeModal
2
+ //Import only what you use: `import { generateTable } from "athena-ui-js/dialog"`.
3
+ //LICENCE: MIT
4
+ //Repository: https://github.com/csabatibortoth/athena-ui
5
+
6
+ export * from "./libs/hephaestus/dialogGenerator/dialogGenerator.js";
7
+ export * from "./libs/hephaestus/modalGenerator/modalGenerator.js";
package/src/dom.js ADDED
@@ -0,0 +1,6 @@
1
+ //dom entry of Athena UI: el, setContent, resolveElement, asHandle, createSafeBuilder
2
+ //Import only what you use: `import { generateTable } from "athena-ui-js/dom"`.
3
+ //LICENCE: MIT
4
+ //Repository: https://github.com/csabatibortoth/athena-ui
5
+
6
+ export { el, setContent, resolveElement, asHandle, createSafeBuilder } from "./libs/core/dom.js";
@@ -0,0 +1,6 @@
1
+ //feedback entry of Athena UI: toasts, alerts, spinner, progress, copyToClipboard
2
+ //Import only what you use: `import { generateTable } from "athena-ui-js/feedback"`.
3
+ //LICENCE: MIT
4
+ //Repository: https://github.com/csabatibortoth/athena-ui
5
+
6
+ export * from "./libs/hephaestus/feedbackGenerator/feedbackGenerator.js";
package/src/format.js ADDED
@@ -0,0 +1,6 @@
1
+ //format entry of Athena UI: formatBytes, formatNumber, formatDuration, formatRelativeTime, formatDate
2
+ //Import only what you use: `import { generateTable } from "athena-ui-js/format"`.
3
+ //LICENCE: MIT
4
+ //Repository: https://github.com/csabatibortoth/athena-ui
5
+
6
+ export * from "./libs/core/format.js";
package/src/forms.js ADDED
@@ -0,0 +1,7 @@
1
+ //forms entry of Athena UI: generateForm, generateField, generateButton, the sign in / sign up / password forms
2
+ //Import only what you use: `import { generateTable } from "athena-ui-js/forms"`.
3
+ //LICENCE: MIT
4
+ //Repository: https://github.com/csabatibortoth/athena-ui
5
+
6
+ export * from "./libs/hephaestus/formGenerator/formBuilder.js";
7
+ export * from "./libs/hephaestus/formGenerator/authForms.js";
package/src/i18n.js ADDED
@@ -0,0 +1,6 @@
1
+ //i18n entry of Athena UI: translate, setLocale, addMessages
2
+ //Import only what you use: `import { generateTable } from "athena-ui-js/i18n"`.
3
+ //LICENCE: MIT
4
+ //Repository: https://github.com/csabatibortoth/athena-ui
5
+
6
+ export * from "./libs/core/i18n.js";
package/src/inputs.js ADDED
@@ -0,0 +1,9 @@
1
+ //inputs entry of Athena UI: autocomplete, multi select, file upload, drop zone, stepper, date and time ranges, rich text, WYSIWYG
2
+ //Import only what you use: `import { generateTable } from "athena-ui-js/inputs"`.
3
+ //LICENCE: MIT
4
+ //Repository: https://github.com/csabatibortoth/athena-ui
5
+
6
+ export * from "./libs/hephaestus/inputGenerator/inputGenerator.js";
7
+ export * from "./libs/hephaestus/inputGenerator/dropZoneGenerator.js";
8
+ export * from "./libs/hephaestus/inputGenerator/richTextGenerator.js";
9
+ export * from "./libs/core/dateRange.js";
@@ -6,7 +6,7 @@
6
6
  export const BORDERED_CLASS = "default-cointainer-bordered";
7
7
 
8
8
  export const defaults = Object.freeze({
9
- version: "1.3.0",
9
+ version: "2.0.0",
10
10
  container_class: "container",
11
11
  header_class: "header-container",
12
12
  header_menu_class: "header-menu menu",
@@ -29,7 +29,6 @@ export const defaults = Object.freeze({
29
29
  lost_password_enabled: false,
30
30
  change_password_enabled: false,
31
31
  login_remember_me: false,
32
- enable_encrypt_password: false,
33
32
 
34
33
  header_title_text: "Athena UI",
35
34
  header_img_url: undefined,
@@ -50,8 +49,6 @@ const config = { ...defaults };
50
49
 
51
50
  export default config;
52
51
 
53
- let warnedEncrypt = false;
54
-
55
52
  // Copies every known setting that is defined in the given sources onto the live config.
56
53
  export function applyConfig(...sources) {
57
54
  for (const source of sources) {
@@ -60,11 +57,6 @@ export function applyConfig(...sources) {
60
57
  if (source[key] !== undefined) config[key] = source[key];
61
58
  }
62
59
  }
63
- if (config.enable_encrypt_password && !warnedEncrypt) {
64
- warnedEncrypt = true;
65
- console.warn("Athena UI: enable_encrypt_password is deprecated and will be removed in 2.0. Hashing a password in the browser only turns the hash "
66
- + "into the password. Send it over HTTPS and hash it on the server. generateSignInForm / generateSignUpForm do not hash.");
67
- }
68
60
  return config;
69
61
  }
70
62
 
@@ -3,7 +3,7 @@
3
3
  //LICENCE: MIT
4
4
  //Repository: https://github.com/csabatibortoth/athena-ui
5
5
  //Moved here from HTMLControlGenerator 0.4.1 (https://github.com/csabatibortoth/HTMLControlGenerator), which is no longer developed.
6
- //The calls are the same; jQuery is not needed any more (see HTMLControlGenerator.create for what it returns).
6
+ //The calls are the same; there is no jQuery in it any more (since 2.0 `create` returns the element, not a jQuery object).
7
7
 
8
8
  import { el, resolveElement } from "./dom.js";
9
9
  import { noBodyOrParentError, reportError, undefinedError, wrongInputTypeError } from "./errors.js";
@@ -83,19 +83,16 @@ function list(options) {
83
83
 
84
84
  const factories = new Map([...INPUT_TYPES.map(type => [type, input]), ["select", select], ["ul", list], ["ol", list]]);
85
85
 
86
- // A factory registered by an addon may return an element or a jQuery object.
87
- const unwrap = made => (made && made.jquery ? made[0] : made);
88
-
89
86
  /** Builds the control described by `options` without appending it. Returns the element, or null (an error is reported). */
90
87
  export function buildControl(options) {
91
88
  if (options === undefined) return reportError(undefinedError("options", "HTMLControlGenerator"));
92
89
  const factory = factories.get(options.inputType);
93
90
  if (!factory) return reportError(wrongInputTypeError("options", "HTMLControlGenerator", options));
94
- return unwrap(factory(options));
91
+ return factory(options);
95
92
  }
96
93
 
97
94
  /**
98
- * Registers a new input type. `factory(options)` returns the element to append (a jQuery object is accepted too).
95
+ * Registers a new input type. `factory(options)` returns the element to append.
99
96
  * Addons use this to plug in their controls, see registerHungarianInputControls.
100
97
  */
101
98
  export function registerControl(inputType, factory) {
@@ -140,14 +137,9 @@ export function HTMLControlGenerator(options) {
140
137
  }
141
138
 
142
139
  /**
143
- * Builds the control without appending it. Like the standalone project it returns a jQuery object when jQuery is on the page
144
- * (Odin NS Manager relies on that), and the plain element when it is not. Undefined when the options are not valid.
140
+ * Builds the control without appending it and returns the element (the standalone project returned a jQuery object: wrap it yourself with
141
+ * `$(HTMLControlGenerator.create(options))` if you still need one). Undefined when the options are not valid.
145
142
  */
146
- HTMLControlGenerator.create = options => {
147
- const control = buildControl(options);
148
- if (!control) return undefined;
149
- const jquery = globalThis.jQuery;
150
- return typeof jquery === "function" ? jquery(control) : control;
151
- };
143
+ HTMLControlGenerator.create = options => buildControl(options) ?? undefined;
152
144
 
153
145
  HTMLControlGenerator.register = registerControl;
@@ -0,0 +1,55 @@
1
+ //cookies 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
+ // A small cookie helper (it replaces js-cookie, which Athena UI used to bundle). Same calls for what Athena needs:
7
+ // Cookies.get(name), Cookies.set(name, value, attributes), Cookies.remove(name, attributes).
8
+
9
+ const encode = value => encodeURIComponent(String(value)).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g, decodeURIComponent);
10
+ const decode = value => value.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
11
+
12
+ /**
13
+ * @param {string} name
14
+ * @param {string} value
15
+ * @param {object} [attributes]
16
+ * @param {number|Date} [attributes.expires] days from now, or a Date. Without it the cookie ends with the browser session.
17
+ * @param {string} [attributes.path="/"]
18
+ * @param {string} [attributes.domain]
19
+ * @param {"strict"|"lax"|"none"} [attributes.sameSite]
20
+ * @param {boolean} [attributes.secure]
21
+ */
22
+ function set(name, value, attributes = {}) {
23
+ const { expires, path = "/", domain, sameSite, secure } = attributes;
24
+ let text = `${encode(name)}=${encode(value)}`;
25
+ if (expires != null) {
26
+ const date = expires instanceof Date ? expires : new Date(Date.now() + expires * 864e5);
27
+ text += `; expires=${date.toUTCString()}`;
28
+ }
29
+ if (path) text += `; path=${path}`;
30
+ if (domain) text += `; domain=${domain}`;
31
+ if (sameSite) text += `; samesite=${sameSite}`;
32
+ if (secure) text += "; secure";
33
+ document.cookie = text;
34
+ }
35
+
36
+ /** The value of a cookie, or undefined. Without a name: all cookies as an object. */
37
+ function get(name) {
38
+ const all = {};
39
+ for (const part of document.cookie ? document.cookie.split("; ") : []) {
40
+ const at = part.indexOf("=");
41
+ const key = decode(part.slice(0, at));
42
+ if (name === undefined || key === name) all[key] = decode(part.slice(at + 1));
43
+ if (key === name) break;
44
+ }
45
+ return name === undefined ? all : all[name];
46
+ }
47
+
48
+ /** Removes a cookie. Give the same path, domain and sameSite it was set with. */
49
+ function remove(name, attributes = {}) {
50
+ set(name, "", { ...attributes, expires: -1 });
51
+ }
52
+
53
+ const Cookies = { get, set, remove };
54
+ export default Cookies;
55
+ export { Cookies };