shared-lib-web 0.0.2 → 0.0.4
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 +192 -528
- package/dist/components/app-brand.d.ts.map +1 -1
- package/dist/components/app-brand.js +9 -5
- package/dist/components/app-brand.js.map +1 -1
- package/dist/components/coming-soon.d.ts.map +1 -1
- package/dist/components/coming-soon.js +3 -2
- package/dist/components/coming-soon.js.map +1 -1
- package/dist/components/language-switcher.d.ts +5 -1
- package/dist/components/language-switcher.d.ts.map +1 -1
- package/dist/components/language-switcher.js +20 -7
- package/dist/components/language-switcher.js.map +1 -1
- package/dist/components/otp-modal.d.ts +5 -0
- package/dist/components/otp-modal.d.ts.map +1 -0
- package/dist/components/otp-modal.js +77 -0
- package/dist/components/otp-modal.js.map +1 -0
- package/dist/components/settings-menu.d.ts +4 -0
- package/dist/components/settings-menu.d.ts.map +1 -1
- package/dist/components/settings-menu.js +15 -2
- package/dist/components/settings-menu.js.map +1 -1
- package/dist/context/use-ui.d.ts.map +1 -1
- package/dist/context/use-ui.js +4 -3
- package/dist/context/use-ui.js.map +1 -1
- package/dist/i18n/browser-language.d.ts +9 -0
- package/dist/i18n/browser-language.d.ts.map +1 -0
- package/dist/i18n/browser-language.js +89 -0
- package/dist/i18n/browser-language.js.map +1 -0
- package/dist/i18n/default-messages.d.ts.map +1 -1
- package/dist/i18n/default-messages.js +15 -0
- package/dist/i18n/default-messages.js.map +1 -1
- package/dist/i18n/locale-groups.d.ts +18 -0
- package/dist/i18n/locale-groups.d.ts.map +1 -0
- package/dist/i18n/locale-groups.js +74 -0
- package/dist/i18n/locale-groups.js.map +1 -0
- package/dist/i18n/locale-service.d.ts +22 -4
- package/dist/i18n/locale-service.d.ts.map +1 -1
- package/dist/i18n/locale-service.js +95 -27
- package/dist/i18n/locale-service.js.map +1 -1
- package/dist/i18n/locale-signal.d.ts +18 -0
- package/dist/i18n/locale-signal.d.ts.map +1 -0
- package/dist/i18n/locale-signal.js +142 -0
- package/dist/i18n/locale-signal.js.map +1 -0
- package/dist/i18n/translator.d.ts +8 -1
- package/dist/i18n/translator.d.ts.map +1 -1
- package/dist/i18n/translator.js +36 -12
- package/dist/i18n/translator.js.map +1 -1
- package/dist/index.d.ts +24 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -8
- package/dist/index.js.map +1 -1
- package/dist/interfaces/app-types.d.ts +6 -0
- package/dist/interfaces/app-types.d.ts.map +1 -1
- package/dist/interfaces/ui-config.d.ts +184 -15
- package/dist/interfaces/ui-config.d.ts.map +1 -1
- package/dist/interfaces/ui-context.d.ts +1 -1
- package/dist/interfaces/ui-context.d.ts.map +1 -1
- package/dist/layouts/auth-layout.js +1 -1
- package/dist/layouts/auth-layout.js.map +1 -1
- package/dist/providers/provider-effects.d.ts +2 -2
- package/dist/providers/provider-effects.d.ts.map +1 -1
- package/dist/providers/provider-effects.js +4 -1
- package/dist/providers/provider-effects.js.map +1 -1
- package/dist/providers/register-config.d.ts.map +1 -1
- package/dist/providers/register-config.js +2 -0
- package/dist/providers/register-config.js.map +1 -1
- package/dist/providers/shared-web-ui-provider.d.ts +7 -19
- package/dist/providers/shared-web-ui-provider.d.ts.map +1 -1
- package/dist/providers/shared-web-ui-provider.js +21 -22
- package/dist/providers/shared-web-ui-provider.js.map +1 -1
- package/dist/query/query-param.d.ts +4 -1
- package/dist/query/query-param.d.ts.map +1 -1
- package/dist/query/query-param.js +6 -3
- package/dist/query/query-param.js.map +1 -1
- package/dist/state/api-loader.d.ts +19 -0
- package/dist/state/api-loader.d.ts.map +1 -0
- package/dist/state/api-loader.js +187 -0
- package/dist/state/api-loader.js.map +1 -0
- package/dist/state/auth-service.d.ts +9 -0
- package/dist/state/auth-service.d.ts.map +1 -1
- package/dist/state/auth-service.js +70 -3
- package/dist/state/auth-service.js.map +1 -1
- package/dist/state/branch-service.d.ts +1 -1
- package/dist/state/branch-service.js +3 -3
- package/dist/state/branch-service.js.map +1 -1
- package/dist/state/company-service.d.ts +16 -0
- package/dist/state/company-service.d.ts.map +1 -0
- package/dist/state/company-service.js +97 -0
- package/dist/state/company-service.js.map +1 -0
- package/dist/state/language-service.d.ts +5 -2
- package/dist/state/language-service.d.ts.map +1 -1
- package/dist/state/language-service.js +12 -7
- package/dist/state/language-service.js.map +1 -1
- package/dist/state/layout-choice-service.d.ts +10 -0
- package/dist/state/layout-choice-service.d.ts.map +1 -0
- package/dist/state/layout-choice-service.js +34 -0
- package/dist/state/layout-choice-service.js.map +1 -0
- package/dist/state/menu-service.d.ts +1 -1
- package/dist/state/menu-service.js +2 -2
- package/dist/state/menu-service.js.map +1 -1
- package/dist/state/otp-service.d.ts +69 -0
- package/dist/state/otp-service.d.ts.map +1 -0
- package/dist/state/otp-service.js +212 -0
- package/dist/state/otp-service.js.map +1 -0
- package/dist/state/preference-sync.d.ts +1 -1
- package/dist/state/preference-sync.d.ts.map +1 -1
- package/dist/state/preference-sync.js +11 -3
- package/dist/state/preference-sync.js.map +1 -1
- package/dist/state/signals.d.ts +9 -1
- package/dist/state/signals.d.ts.map +1 -1
- package/dist/state/signals.js +28 -4
- package/dist/state/signals.js.map +1 -1
- package/dist/theme/custom-themes.d.ts +28 -0
- package/dist/theme/custom-themes.d.ts.map +1 -0
- package/dist/theme/custom-themes.js +218 -0
- package/dist/theme/custom-themes.js.map +1 -0
- package/dist/theme/dark-themes.d.ts +9 -1
- package/dist/theme/dark-themes.d.ts.map +1 -1
- package/dist/theme/dark-themes.js +74 -2
- package/dist/theme/dark-themes.js.map +1 -1
- package/dist/theme/logo.d.ts +6 -3
- package/dist/theme/logo.d.ts.map +1 -1
- package/dist/theme/logo.js +17 -3
- package/dist/theme/logo.js.map +1 -1
- package/dist/theme/theme-service.d.ts +14 -3
- package/dist/theme/theme-service.d.ts.map +1 -1
- package/dist/theme/theme-service.js +64 -10
- package/dist/theme/theme-service.js.map +1 -1
- package/dist/types/field-wrapper.d.ts +2 -0
- package/dist/types/field-wrapper.d.ts.map +1 -1
- package/dist/types/field-wrapper.js +3 -2
- package/dist/types/field-wrapper.js.map +1 -1
- package/dist/types/type.otp.d.ts +2 -0
- package/dist/types/type.otp.d.ts.map +1 -1
- package/dist/types/type.otp.js +2 -2
- package/dist/types/type.otp.js.map +1 -1
- package/dist/utils/app-http.d.ts +41 -1
- package/dist/utils/app-http.d.ts.map +1 -1
- package/dist/utils/app-http.js +188 -12
- package/dist/utils/app-http.js.map +1 -1
- package/dist/utils/content-util.d.ts +6 -0
- package/dist/utils/content-util.d.ts.map +1 -0
- package/dist/utils/content-util.js +45 -0
- package/dist/utils/content-util.js.map +1 -0
- package/dist/utils/error-util.d.ts +3 -0
- package/dist/utils/error-util.d.ts.map +1 -0
- package/dist/utils/error-util.js +58 -0
- package/dist/utils/error-util.js.map +1 -0
- package/dist/utils/language-util.d.ts +3 -3
- package/dist/utils/language-util.d.ts.map +1 -1
- package/dist/utils/language-util.js +7 -7
- package/dist/utils/language-util.js.map +1 -1
- package/dist/utils/menu-util.js +1 -1
- package/dist/utils/menu-util.js.map +1 -1
- package/dist/utils/signal-source.d.ts +4 -0
- package/dist/utils/signal-source.d.ts.map +1 -0
- package/dist/utils/signal-source.js +13 -0
- package/dist/utils/signal-source.js.map +1 -0
- package/dist/utils/storage-keys.d.ts +5 -0
- package/dist/utils/storage-keys.d.ts.map +1 -1
- package/dist/utils/storage-keys.js +5 -0
- package/dist/utils/storage-keys.js.map +1 -1
- package/package.json +3 -3
- package/src/components/app-brand.tsx +9 -5
- package/src/components/coming-soon.tsx +3 -2
- package/src/components/language-switcher.tsx +26 -7
- package/src/components/otp-modal.tsx +154 -0
- package/src/components/settings-menu.tsx +28 -2
- package/src/context/use-ui.ts +4 -3
- package/src/i18n/browser-language.ts +98 -0
- package/src/i18n/default-messages.ts +15 -0
- package/src/i18n/locale-groups.ts +87 -0
- package/src/i18n/locale-service.ts +99 -27
- package/src/i18n/locale-signal.ts +173 -0
- package/src/i18n/translator.ts +38 -12
- package/src/index.ts +102 -4
- package/src/interfaces/app-types.ts +6 -0
- package/src/interfaces/ui-config.ts +191 -15
- package/src/interfaces/ui-context.ts +1 -1
- package/src/layouts/auth-layout.tsx +1 -1
- package/src/providers/provider-effects.ts +5 -2
- package/src/providers/register-config.ts +2 -0
- package/src/providers/shared-web-ui-provider.tsx +26 -43
- package/src/query/query-param.ts +6 -2
- package/src/state/api-loader.ts +205 -0
- package/src/state/auth-service.ts +84 -3
- package/src/state/branch-service.ts +3 -3
- package/src/state/company-service.ts +107 -0
- package/src/state/language-service.ts +12 -7
- package/src/state/layout-choice-service.ts +40 -0
- package/src/state/menu-service.ts +2 -2
- package/src/state/otp-service.ts +283 -0
- package/src/state/preference-sync.ts +11 -3
- package/src/state/signals.ts +36 -4
- package/src/theme/custom-themes.ts +236 -0
- package/src/theme/dark-themes.ts +80 -3
- package/src/theme/logo.ts +19 -4
- package/src/theme/org-themes.json +70 -0
- package/src/theme/theme-service.ts +70 -10
- package/src/types/field-wrapper.tsx +5 -2
- package/src/types/type.otp.tsx +11 -2
- package/src/utils/app-http.ts +205 -12
- package/src/utils/content-util.ts +49 -0
- package/src/utils/error-util.ts +64 -0
- package/src/utils/language-util.ts +7 -7
- package/src/utils/menu-util.ts +1 -1
- package/src/utils/signal-source.ts +15 -0
- package/src/utils/storage-keys.ts +6 -0
package/README.md
CHANGED
|
@@ -1,631 +1,295 @@
|
|
|
1
1
|
# shared-lib-web
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
React 19 component library for DesignForFeature apps: provider, Type* form controls, layouts, i18n (RTL/LTR),
|
|
4
|
+
DaisyUI themes, Signals state, AppHttp / AppStorage. Built on `dff-util`. MIT license.
|
|
5
5
|
|
|
6
|
-
| Entry |
|
|
7
|
-
| --- | --- |
|
|
8
|
-
| `shared-lib-web` |
|
|
9
|
-
| `shared-lib-web/layout` | optional
|
|
10
|
-
| `shared-lib-web/markdown` | optional
|
|
11
|
-
|
|
12
|
-
The project decides the layout: use `AppLayout` as it is, turn off / replace its parts, build an own layout from the
|
|
13
|
-
single parts, or skip `shared-lib-web/layout` completely and write the whole layout itself.
|
|
14
|
-
|
|
15
|
-
An app keeps **only**:
|
|
16
|
-
|
|
17
|
-
1. `config.ts` – app name, default language + locale loader, themes, logos, layout and http
|
|
18
|
-
(no menu, no language list)
|
|
19
|
-
2. two backend inputs passed to the provider, `null` first and the reply later:
|
|
20
|
-
`nav` (the menu) and `lang` (the languages)
|
|
21
|
-
3. `locales/{code}.json` – its texts (`en-US.json`, `ar-SA.json` …)
|
|
22
|
-
4. its pages / modules
|
|
23
|
-
|
|
24
|
-
Everything else lives in the library: components and (optionally) layouts, header, sidebar (with icon rail),
|
|
25
|
-
full-width mega menu, pages by query parameter (no router), DaisyUI light/dark themes, lightweight i18n, RTL/LTR, permissions,
|
|
26
|
-
localStorage persistence, toasts, skeletons, overlays and `react-hook-form` controls.
|
|
27
|
-
|
|
28
|
-
Stack: React 19 · TypeScript (strict) · Vite · Tailwind CSS 4 · DaisyUI 5 · `@preact/signals-react` ·
|
|
29
|
-
`lucide-react` (through `TypeIcon`) · `react-hook-form` · `dff-util`.
|
|
30
|
-
**No router (no react-router-dom), no AG Grid.** Markdown fields are an optional extra entry (`shared-lib-web/markdown`).
|
|
31
|
-
|
|
32
|
-
The source follows strict readability rules (no nested functions, no `abcd(xyz())`, no chained calls,
|
|
33
|
-
lowercase file names) – see [CODING_RULES.md](./CODING_RULES.md). AI agents: read `.agent/skills/` in the repository.
|
|
34
|
-
|
|
35
|
-
---
|
|
6
|
+
| Entry | What |
|
|
7
|
+
| --- | --- |
|
|
8
|
+
| `shared-lib-web` | provider, controls, components, signals, services, AppHttp, AppStorage |
|
|
9
|
+
| `shared-lib-web/layout` | optional app shell: `AppLayout`, `AsideLayout`, `AuthLayout` and parts |
|
|
10
|
+
| `shared-lib-web/markdown` | optional markdown controls (needs `@uiw/react-md-editor`) |
|
|
11
|
+
| `shared-lib-web/styles.css` | Tailwind source hint for the library classes |
|
|
36
12
|
|
|
37
13
|
## Install
|
|
38
14
|
|
|
39
15
|
```bash
|
|
40
16
|
npm install shared-lib-web dff-util react react-dom @preact/signals-react lucide-react react-hook-form
|
|
41
|
-
npm install -D tailwindcss daisyui
|
|
42
|
-
#
|
|
43
|
-
npm install @uiw/react-md-editor
|
|
17
|
+
npm install -D tailwindcss daisyui @tailwindcss/vite
|
|
18
|
+
npm install @uiw/react-md-editor # only for shared-lib-web/markdown
|
|
44
19
|
```
|
|
45
20
|
|
|
46
|
-
## CSS
|
|
47
|
-
|
|
48
21
|
```css
|
|
49
22
|
/* src/index.css */
|
|
50
23
|
@import "tailwindcss";
|
|
51
|
-
@import "shared-lib-web/styles.css";
|
|
52
|
-
@plugin "daisyui" {
|
|
53
|
-
themes: light --default, dark --prefersdark, corporate, dracula;
|
|
54
|
-
}
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
Every theme in `config.themes` must also be enabled in `@plugin "daisyui"` (or defined as a custom theme), and the
|
|
58
|
-
dark ones listed in `config.darkThemes` (dark logo, dark markdown editor). Use `themes: all` or list the ones you need.
|
|
59
|
-
|
|
60
|
-
Custom themes use DaisyUI's theme plugin, one file per theme in a `theme/` folder (the example has
|
|
61
|
-
`example/src/theme/org-light.css` and `org-dark.css`, and the theme names in `example/src/theme/themes.ts`):
|
|
62
|
-
|
|
63
|
-
```css
|
|
64
|
-
/* src/index.css */
|
|
65
|
-
@import "tailwindcss";
|
|
66
|
-
@import "./theme/org-light.css";
|
|
67
|
-
@import "./theme/org-dark.css";
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
```css
|
|
71
|
-
/* src/theme/org-dark.css */
|
|
72
|
-
@plugin "daisyui/theme" {
|
|
73
|
-
name: "org-dark";
|
|
74
|
-
default: false;
|
|
75
|
-
color-scheme: dark;
|
|
76
|
-
--color-base-100: oklch(22% 0.03 264);
|
|
77
|
-
--color-base-content: oklch(92% 0.015 264);
|
|
78
|
-
--color-primary: oklch(70% 0.16 277);
|
|
79
|
-
/* ... all --color-*, --radius-*, --size-*, --border, --depth, --noise variables */
|
|
80
|
-
}
|
|
24
|
+
@import "shared-lib-web/styles.css";
|
|
25
|
+
@plugin "daisyui" { themes: all; }
|
|
81
26
|
```
|
|
82
27
|
|
|
83
28
|
```ts
|
|
84
|
-
//
|
|
85
|
-
export
|
|
86
|
-
export const DARK_THEMES: Theme[] = ["org-dark", "dark", /* ... */];
|
|
29
|
+
// vite.config.ts — dff-util needs Node's global
|
|
30
|
+
export default defineConfig({ plugins: [react(), tailwindcss()], define: { global: "globalThis" } });
|
|
87
31
|
```
|
|
88
32
|
|
|
89
|
-
|
|
90
|
-
as two groups (split by `config.darkThemes`). In your own UI: `const { lightThemes, darkThemes } = useUi();`
|
|
91
|
-
or `splitThemesByMode(themes)`, `isDarkThemeName(theme)`. Texts: `ui.lightThemes`, `ui.darkThemes`.
|
|
92
|
-
|
|
93
|
-
## App bundler (Vite example)
|
|
94
|
-
|
|
95
|
-
The library itself has no bundler. Your **app** uses its own (Vite, Next.js, webpack …).
|
|
96
|
-
`dff-util` uses packages that expect Node's `global`, so define it — with Vite:
|
|
33
|
+
## config.ts
|
|
97
34
|
|
|
98
35
|
```ts
|
|
99
|
-
|
|
100
|
-
plugins: [reactPlugin, tailwindPlugin],
|
|
101
|
-
define: { global: "globalThis" },
|
|
102
|
-
});
|
|
103
|
-
```
|
|
36
|
+
import { loadLocaleGroups, type UiConfig } from "shared-lib-web";
|
|
104
37
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
## 1. config.ts
|
|
108
|
-
|
|
109
|
-
```ts
|
|
110
|
-
import { readEnvData, toAbsoluteUrl, type LocaleModule, type UiConfig } from "shared-lib-web";
|
|
111
|
-
|
|
112
|
-
const APP_NAME_KEY = "ORG";
|
|
113
|
-
|
|
114
|
-
// window.env.REACT_APP_ORG_API_BASE_URL (env.js), else the default
|
|
115
|
-
const envBaseUrl = readEnvData(APP_NAME_KEY, "API_BASE_URL");
|
|
116
|
-
const API_BASE_URL = toAbsoluteUrl(envBaseUrl ?? "https://api.example.com/api");
|
|
117
|
-
|
|
118
|
-
// Service URLs are PROJECT level (not part of AppHttp)
|
|
119
|
-
export const MsUrl = {
|
|
120
|
-
api: `${API_BASE_URL}/xxx-api`,
|
|
121
|
-
main: `${API_BASE_URL}/xxx-api`,
|
|
122
|
-
sor: `${API_BASE_URL}/xxx-sor`,
|
|
123
|
-
events: `${API_BASE_URL}/xxx-events`,
|
|
124
|
-
tms: `${API_BASE_URL}/xxx-tms`,
|
|
125
|
-
utils: `${API_BASE_URL}/xxx-util`,
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
/** locales/{code}.json, loaded only when that language is used: "en-US" -> locales/en-US.json */
|
|
129
|
-
function loadLocale(languageCode: string): Promise<LocaleModule> {
|
|
130
|
-
return import(`./locales/${languageCode}.json`);
|
|
131
|
-
}
|
|
38
|
+
export const MsUrl = { main: "/org-api", sor: "/org-sor", utils: "/org-util" };
|
|
39
|
+
const localeFiles = import.meta.glob("./locales/*/*.json");
|
|
132
40
|
|
|
133
41
|
export const config: UiConfig = {
|
|
134
|
-
appNameKey:
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
defaultTheme: "light",
|
|
141
|
-
themes: ["light", "dark", "corporate", "dracula"],
|
|
142
|
-
darkThemes: ["dark", "dracula"],
|
|
42
|
+
appNameKey: "ORG", // storage ORG-TOKEN, env REACT_APP_ORG_API_BASE_URL
|
|
43
|
+
loadLocale: loadLocaleGroups.bind(null, localeFiles),
|
|
44
|
+
loadSupportLanguages: `${MsUrl.sor}/load/LANG`,
|
|
45
|
+
loadCompanyDetails: `${MsUrl.sor}/company-details`,
|
|
46
|
+
loadBranches: `${MsUrl.main}/branches`,
|
|
47
|
+
loadMenuNavigation: `${MsUrl.utils}/menu-access`,
|
|
143
48
|
layout: { menuMode: "sidebar", isSidebarCollapsible: true },
|
|
144
|
-
http: {
|
|
49
|
+
http: {
|
|
50
|
+
baseUrl: "https://api.example.com/api",
|
|
51
|
+
logoutUrl: "/login",
|
|
52
|
+
regenerateUrl: `${MsUrl.utils}/jwt-regenerate`, // optional: auto JWT regenerate
|
|
53
|
+
},
|
|
145
54
|
};
|
|
146
55
|
```
|
|
147
56
|
|
|
148
|
-
|
|
149
|
-
| --- | --- |
|
|
150
|
-
| `defaultLanguage`, `fallbackLanguage` | Optional language codes like `en-US` (default `"en-US"`). The default is shown before the `lang` list arrives (and when a file is missing). Without `defaultLanguage`, `languages`, `loadLocale` and `lang` the app runs in en-US with the library's built-in English texts and no language switcher. |
|
|
151
|
-
| `loadLocale(code)` | Loads `locales/{code}.json` lazily for any language code. |
|
|
152
|
-
| `languages` | Not needed: the list comes from `lang` (below). Only for apps with a fixed list (`{ code, label, flag?, direction?, load? }`). |
|
|
153
|
-
| `themes`, `darkThemes` | Listed by the theme switcher. Dark themes switch to `logoDarkUrl` and dark markdown. |
|
|
154
|
-
| `layout.headerSettings` | `"inline"` (language + theme switchers in the header) or `"menu"` (one ⚙ button opening a settings dialog with language, theme and navigation style). |
|
|
155
|
-
| `layout.toastPosition`, `layout.showScrollToTop` | Toast corner (`top-end` …) and the scroll-to-top button. |
|
|
156
|
-
| `layout.showMenu` | Menu shown at start (default `true`); switch at runtime with `setMenuVisible()` / `toggleMenuVisible()`. |
|
|
157
|
-
| `layout.menuMode` | `"sidebar"` (drawer + collapsible icon rail) or `"megamenu"` (top bar + full-width panels). Users can switch with `changeNavigationMode()`; the choice is saved. |
|
|
158
|
-
| `homePath`, `layout.pageParam` | The page shown when `?page` is missing (default `/`) and the name of the page parameter (default `page`). |
|
|
159
|
-
| `http.baseUrl` | API base URL of `AppHttp` (`window.env.REACT_APP_<APPNAMEKEY>_API_BASE_URL` wins when set; a relative `/api` becomes absolute). |
|
|
160
|
-
| `http.logoutUrl` | Where the browser goes after `endSession()` (log out), for example `/login` or an SSO logout URL. `endSession(keepKeys, false)` stays on the page. |
|
|
161
|
-
| `http.tokenKey`, `http.headers`, `http.loadUrl`, `http.showProgress` | Optional: AppStorage key of the token (default `TOKEN`), extra headers, `AppHttp.Load` URL (default base + `/load`), progress bar (default `true`). |
|
|
162
|
-
| `appNameKey` | Key of the app (`ENV_BASE_NAME`): prefix of every AppStorage key (`ORG-TOKEN`, `ORG-LANG`) and of the `window.env` names (`REACT_APP_ORG_…`). The key names are fixed constants — no `storage` / `languageKey` / `themeKey` settings. |
|
|
163
|
-
| `appName` | Label shown in header, sidebar and login: `t(config.appName)` (plain text or a translation key). Default: `appNameKey`. |
|
|
164
|
-
|
|
165
|
-
| `navigation` | Not needed: the menu comes from `nav` (below). Only for apps with a fixed menu and no backend (`NavItem[]`). |
|
|
166
|
-
| `navOptions` | How the backend menu is converted: `rootMenuIds` (default: groups named "Root" or ids ending in `_ROOT`), `isRootFlattened` (default `true`). |
|
|
167
|
-
|
|
168
|
-
### Second config: `nav` (menu from the backend)
|
|
169
|
-
|
|
170
|
-
The menu is passed separately from `config` and can change at any time (login, persona switch, refresh).
|
|
171
|
-
Pass the backend reply as it is — `{ data: [...], meta }` or only the list:
|
|
172
|
-
|
|
173
|
-
```tsx
|
|
174
|
-
const menuResponse = await AppHttp.Get(menuUrl); // { data: [...], meta: {...} }
|
|
175
|
-
|
|
176
|
-
<SharedWebUiProvider config={config} nav={menuResponse}> // null = skeleton, then the reply
|
|
177
|
-
<App />
|
|
178
|
-
</SharedWebUiProvider>
|
|
179
|
-
```
|
|
57
|
+
## App types
|
|
180
58
|
|
|
181
|
-
|
|
59
|
+
### spa — single app (pages in `?page=...`)
|
|
182
60
|
|
|
183
61
|
```tsx
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
export async function loadNav(): Promise<void> {
|
|
188
|
-
navSignal.value = null;
|
|
189
|
-
const reply = await AppHttp.Get(menuUrl);
|
|
190
|
-
navSignal.value = reply; // menu appears; a new reply replaces it
|
|
191
|
-
}
|
|
62
|
+
import { SharedWebUiProvider, useCurrentPage, PageNotFound } from "shared-lib-web";
|
|
63
|
+
import { AppLayout, AuthLayout } from "shared-lib-web/layout";
|
|
192
64
|
|
|
193
|
-
// root.tsx
|
|
194
65
|
export function Root() {
|
|
195
|
-
useSignals();
|
|
196
|
-
const nav = navSignal.value;
|
|
197
66
|
return (
|
|
198
|
-
<SharedWebUiProvider config={config}
|
|
67
|
+
<SharedWebUiProvider type="spa" config={config}>
|
|
199
68
|
<App />
|
|
200
69
|
</SharedWebUiProvider>
|
|
201
70
|
);
|
|
202
71
|
}
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
On an API error set `[]` (empty menu), otherwise the skeleton stays. On logout set `null` again.
|
|
206
|
-
Without the prop: `setMenuLoading()` → `setMenu(menuResponse)`; `clearMenu()` on logout.
|
|
207
|
-
|
|
208
|
-
What happens to the reply (`MenuAccessType`: `id`, `name`, `nameLang`, `href`, `icon`, `type`, `priority`,
|
|
209
|
-
`read/create/update/delete` or `permissions`, `active`, `children`):
|
|
210
|
-
|
|
211
|
-
- the children of the **Root** group (`ADMIN_ROOT`) move to the top level, in the place of the group;
|
|
212
|
-
- sorted by `priority`; the same priority keeps the backend order; `active: false` is removed;
|
|
213
|
-
- icons like `layout-dashboard`, `users`, `User-Round-Key` become lucide names (unknown → `Circle`);
|
|
214
|
-
- `nameLang` `{ "en-US": "..." }` is used for `en`, `en-US`, … (`trans()`), else `name`;
|
|
215
|
-
- `read: false` hides the item and blocks the page; `create/update/delete` feed `canAccess()`.
|
|
216
|
-
|
|
217
|
-
`toNavigation(menuResponse, options)` does the conversion if you need the `NavItem[]` yourself.
|
|
218
|
-
|
|
219
|
-
### Third input: `lang` (languages from the backend)
|
|
220
|
-
|
|
221
|
-
Passed the same way as `nav`: `null` first, the reply later. Texts come from `locales/{code}.json` via `loadLocale`.
|
|
222
|
-
|
|
223
|
-
```tsx
|
|
224
|
-
// lang.service.ts
|
|
225
|
-
export const langSignal = signal<LangSource | null>(null);
|
|
226
72
|
|
|
227
|
-
export
|
|
228
|
-
const
|
|
229
|
-
|
|
73
|
+
export function App() {
|
|
74
|
+
const page = useCurrentPage();
|
|
75
|
+
if (!isAuthenticatedSignal.value) { // import { isAuthenticatedSignal, RequireAccess } from "shared-lib-web"
|
|
76
|
+
return <AuthLayout><LoginPage /></AuthLayout>;
|
|
77
|
+
}
|
|
78
|
+
const pageElement = PAGES[page] ?? <PageNotFound />;
|
|
79
|
+
return <AppLayout><RequireAccess key={page}>{pageElement}</RequireAccess></AppLayout>;
|
|
230
80
|
}
|
|
231
|
-
|
|
232
|
-
// root.tsx
|
|
233
|
-
<SharedWebUiProvider config={config} nav={navSignal.value} lang={langSignal.value}>
|
|
234
81
|
```
|
|
235
82
|
|
|
236
|
-
|
|
237
|
-
`isDefault` (or `default`), `active` (false hides it), `priority`. RTL is automatic for `ar`, `he`, `fa`, `ur`.
|
|
238
|
-
- While `lang` is `null`: `defaultLanguage` (or the language the user saved) is shown; the switchers have no list yet.
|
|
239
|
-
- When the list arrives: the user's saved language stays if it is listed; otherwise the row with `isDefault`
|
|
240
|
-
(else `defaultLanguage`, else the first) is loaded. Only a language the user picks is saved to localStorage.
|
|
241
|
-
- `TypeLang` / `TypeLangMd` fields get one entry per listed language: `{ "en-US": "...", "ar-SA": "..." }`;
|
|
242
|
-
backend `nameLang` with the same codes is shown by `trans()` and the menu.
|
|
243
|
-
- Without the prop: `setLanguages(reply)`. Conversion only: `toLanguageOptions(reply)`, `readDefaultLanguageCode(reply)`.
|
|
244
|
-
|
|
245
|
-
### AppStorage and AppHttp
|
|
246
|
-
|
|
247
|
-
The same helpers the apps had in `utils/services/app.storage.ts` and `app.http.ts`, now in the library:
|
|
248
|
-
|
|
249
|
-
```ts
|
|
250
|
-
import { AppHttp, AppStorage, BRANCH_ID, LANG, THEME, TOKEN } from "shared-lib-web";
|
|
251
|
-
|
|
252
|
-
AppStorage.setData(BRANCH_ID, branchId); // sessionStorage "ORG-BRANCH_ID"
|
|
253
|
-
const token = AppStorage.getData(TOKEN); // objects come back parsed
|
|
254
|
-
AppStorage.getText(THEME); // localStorage "ORG-THEME"
|
|
255
|
-
AppStorage.removeData(BRANCH_ID); // from both storages
|
|
256
|
-
AppStorage.clearData(); // log out: keeps the localStorage preferences
|
|
257
|
-
AppStorage.envData("API_BASE_URL"); // window.env.REACT_APP_ORG_API_BASE_URL (env.js of the deployed app)
|
|
258
|
-
|
|
259
|
-
// MsUrl comes from the project's config.ts (see section 1)
|
|
260
|
-
const rows = await AppHttp.Get(`${MsUrl.main}/profile/search`, params);
|
|
261
|
-
```
|
|
262
|
-
|
|
263
|
-
**Which storage:** decided only by the key (no argument).
|
|
264
|
-
|
|
265
|
-
| localStorage (preferences, kept on log out) | sessionStorage (everything else) |
|
|
266
|
-
| --- | --- |
|
|
267
|
-
| `LANG`, `THEME`, `LAYOUT_CHOICE`, `MENU_MODE`, `SIDEBAR_COLLAPSED`, `REMEMBER_ME` + `config.localStorageKeys` | `TOKEN`, `ACTIVE_SESSION_ID` (tab id, sent as `x-session-id`), `AUTH_USER`, `SESSION_INFO`, `SCREEN_ACCESS`, `SCREEN_ACTION`, `NAV`, `TRANS`, `DIR`, `OTP_ID`, `BRANCH_ID`, `BRANCH_NAME`, `REGEN_EXPIRES_AT`, project keys |
|
|
268
|
-
|
|
269
|
-
`startSession(token, user, isRemembered)` keeps the token in sessionStorage; `isRemembered` only saves `REMEMBER_ME`.
|
|
270
|
-
On start the provider removes old app values from localStorage that are not preferences (`AppStorage.cleanLocalStorage()`).
|
|
271
|
-
Saving a preference (`THEME`, `LANG` …) also fires the window event `PREFERENCE_EVENT`; every copy of the library on the
|
|
272
|
-
page (microfrontends) and every other tab applies the new theme / language at once.
|
|
273
|
-
|
|
274
|
-
Key constants (also as `StorageKeys.*`): `TOKEN`, `AUTH_USER`, `SESSION_INFO`, `SCREEN_ACCESS`, `SCREEN_ACTION`, `NAV`,
|
|
275
|
-
`REMEMBER_ME`, `TRANS`, `DIR`, `LANG`, `THEME`, `LAYOUT_CHOICE`, `MENU_MODE`, `SIDEBAR_COLLAPSED`, `OTP_ID`, `BRANCH_ID`, `BRANCH_NAME`,
|
|
276
|
-
`REGEN_EXPIRES_AT`. The library saves the chosen language in `LANG`, the theme in `THEME`, the navigation style in
|
|
277
|
-
`MENU_MODE` and the rail state in `SIDEBAR_COLLAPSED`.
|
|
278
|
-
|
|
279
|
-
AppHttp headers on every request: `Content-Type`, `Authorization: Bearer <TOKEN>`, `x-session-id` (per-tab id, saved as `ORG-ACTIVE_SESSION_ID`),
|
|
280
|
-
`x-branch-id` (AppStorage `BRANCH_ID`, `""` when no branch), `http.headers` and `AppHttp.setHeader(name, value)`.
|
|
281
|
-
Pick the branch with `setBranch(branch.id, branch.name)` (saved as `BRANCH_ID` / `BRANCH_NAME`, read back with
|
|
282
|
-
`readBranchId()` or `branchIdSignal`); `clearBranch()` removes it and `endSession()` clears it too.
|
|
283
|
-
|
|
284
|
-
**Branch switcher** – pass the user's branches like `lang` (null first, the reply later); the default and disabled
|
|
285
|
-
branches come with the rows:
|
|
83
|
+
### shell — hosts microfrontends (pages are paths: `/settings`)
|
|
286
84
|
|
|
287
85
|
```tsx
|
|
288
|
-
<SharedWebUiProvider
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
- Rows: `{ id | branchId | code, name | branchName | label, nameLang?, isDefault?, disabled?, active?, priority? }`, as `{ data: [...] }` or the list.
|
|
293
|
-
- `disabled: true` shows the branch greyed out; it can not be selected. `active: false` hides it.
|
|
294
|
-
- Selected when the list arrives: the saved `BRANCH_ID` (if listed and not disabled) → the row with `isDefault` → the first one that is not disabled.
|
|
295
|
-
- Shown as a dropdown in the `Header` and as the first section of the settings dialog. `null` or `[]` = no switcher.
|
|
296
|
-
- `setBranches(reply)` does the same without the provider (call it before the menu request so it already
|
|
297
|
-
sends `x-branch-id`). Own layouts: `<BranchSwitcher />`. Helpers: `toBranchOptions`, `pickBranch`, `branchesSignal`.
|
|
298
|
-
The token is read from AppStorage (`TOKEN`, sessionStorage then localStorage).
|
|
299
|
-
|
|
300
|
-
`AppHttp` and `AppStorage` use no signals: they read the config saved by `<SharedWebUiProvider>`.
|
|
301
|
-
Code that runs before the provider (for example at module load) calls `setAppConfig(config)` first, in `main.tsx`.
|
|
302
|
-
|
|
303
|
-
## 2. locales/en-US.json
|
|
304
|
-
|
|
305
|
-
```json
|
|
306
|
-
{
|
|
307
|
-
"app": { "name": "My App" },
|
|
308
|
-
"nav": { "dashboard": "Dashboard", "users": "Users", "usersText": "Everyone who uses the app" },
|
|
309
|
-
"greeting": "Hello {{name}}",
|
|
310
|
-
"REQUIRED": "This field is required"
|
|
311
|
-
}
|
|
86
|
+
<SharedWebUiProvider type="shell" config={shellConfig}>
|
|
87
|
+
<ShellLayout /> {/* AppLayout or AsideLayout (layoutChoiceSignal) + the MFE mount point */}
|
|
88
|
+
</SharedWebUiProvider>
|
|
312
89
|
```
|
|
313
90
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
selectOption, search, navigation, account, logout, confirm, cancel, translate, permissionDenied,
|
|
317
|
-
permissionDeniedText, pageNotFound, pageNotFoundText, backToHome, goBack, reloadPage, comingSoon, comingSoonText,
|
|
318
|
-
openPreview, playVideo, mediaError`.
|
|
91
|
+
The shell owns login, menu, branches and brand. `startSession` / `endSession` and the token regenerate are shared
|
|
92
|
+
with every MFE on the page.
|
|
319
93
|
|
|
320
|
-
|
|
94
|
+
### mfe — microfrontend inside a shell (page layouts only)
|
|
321
95
|
|
|
322
96
|
```tsx
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
const nav = navSignal.value;
|
|
327
|
-
const lang = langSignal.value;
|
|
328
|
-
return (
|
|
329
|
-
<SharedWebUiProvider config={config} nav={nav} lang={lang}>
|
|
330
|
-
<App />
|
|
331
|
-
</SharedWebUiProvider>
|
|
332
|
-
);
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
// main.tsx
|
|
336
|
-
const root = createRoot(rootElement);
|
|
337
|
-
root.render(<Root />);
|
|
97
|
+
<SharedWebUiProvider type="mfe" config={mfeConfig}>
|
|
98
|
+
<RequireAccess><FormsPage /></RequireAccess>
|
|
99
|
+
</SharedWebUiProvider>
|
|
338
100
|
```
|
|
339
101
|
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
import { AppLayout, AuthLayout } from "shared-lib-web/layout"; // optional, see "Layout" below
|
|
102
|
+
No menu, no `loadBranches` / `loadMenuNavigation`. Theme, language, session and token come from the shell.
|
|
103
|
+
See `example-mfe/`.
|
|
343
104
|
|
|
344
|
-
|
|
345
|
-
"/": <DashboardPage />,
|
|
346
|
-
"/profiles": <UserPage />, // keys = the menu hrefs
|
|
347
|
-
"/app-settings": <SettingsPage />,
|
|
348
|
-
};
|
|
105
|
+
## HTTP — `AppHttp`
|
|
349
106
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
const pageElement = readPageElement(page);
|
|
364
|
-
return (
|
|
365
|
-
<AppLayout headerEnd={<UserMenu name={userName} email={email} onLogout={handleLogout} />}>
|
|
366
|
-
<RequireAccess key={page}>{pageElement}</RequireAccess>
|
|
367
|
-
</AppLayout>
|
|
368
|
-
);
|
|
369
|
-
}
|
|
107
|
+
```ts
|
|
108
|
+
const rows = await AppHttp.Get(`${MsUrl.main}/profile/search`, { page: 1 });
|
|
109
|
+
const saved = await AppHttp.Post(`${MsUrl.main}/profile`, body);
|
|
110
|
+
await AppHttp.Put(`${MsUrl.main}/profile`, id, body);
|
|
111
|
+
await AppHttp.Delete(`${MsUrl.main}/profile`, id);
|
|
112
|
+
await AppHttp.Patch(`${MsUrl.main}/profile`, body);
|
|
113
|
+
const langs = await AppHttp.GetShared(`${MsUrl.sor}/load/LANG`); // once per page (shell + MFEs)
|
|
114
|
+
const options = await AppHttp.Load("COUNTRY"); // GET `${http.loadUrl}/COUNTRY`
|
|
115
|
+
const blob = await AppHttp.Media(`${MsUrl.utils}/files/${id}`);
|
|
116
|
+
await AppHttp.DownloadFile(`${MsUrl.utils}/report`, {}, "report.pdf");
|
|
117
|
+
await AppHttp.CloudUpload(signedUrl, file);
|
|
118
|
+
const file = await uploadToSignedUrl(file, uploadUrl, downloadUrl);
|
|
119
|
+
AppHttp.setHeader("x-custom", "value");
|
|
370
120
|
```
|
|
371
121
|
|
|
372
|
-
|
|
122
|
+
| Member | Use |
|
|
123
|
+
| --- | --- |
|
|
124
|
+
| `Get / Post / Put / Delete / Patch` | JSON requests with token, `x-session-id`, `x-branch-id` |
|
|
125
|
+
| `GetShared(url, params)` | GET once per page (shell + MFEs) |
|
|
126
|
+
| `Load(id, params)` | option lists |
|
|
127
|
+
| `Media / DownloadFile / CloudUpload / uploadFile` | files |
|
|
128
|
+
| `BaseUrl() / FullUrl(url)` | base URL / resolved URL |
|
|
129
|
+
| `Headers() / RawHeaders() / setHeader(name, value)` | headers |
|
|
130
|
+
| `withProgress(promise)` | shows the top progress bar |
|
|
373
131
|
|
|
374
|
-
|
|
375
|
-
import { AppLayout, AsideLayout, AuthLayout, Header, Sidebar, SidebarNav } from "shared-lib-web/layout";
|
|
376
|
-
|
|
377
|
-
// 1. Single layout – everything ready-made
|
|
378
|
-
<AppLayout headerEnd={<UserMenu ... />} sidebarFooter="v1.0">{page}</AppLayout>
|
|
379
|
-
|
|
380
|
-
// 2. Single layout with options
|
|
381
|
-
<AppLayout showSidebar={false}>{page}</AppLayout> // header + page only
|
|
382
|
-
<AppLayout showHeader={false}>{page}</AppLayout> // sidebar + page only
|
|
383
|
-
<AppLayout header={<MyHeader />} sidebar={<MySidebar />} footer={<MyFooter />}>{page}</AppLayout>
|
|
384
|
-
|
|
385
|
-
// 2b. AsideLayout – no top header, only the side menu and the page
|
|
386
|
-
<AsideLayout sidebarUser={<UserMenu isInSidebar ... />}>{page}</AsideLayout>
|
|
387
|
-
// desktop: collapsible to an icon rail (button at the bottom, tooltips on the rail)
|
|
388
|
-
// small screens: always the icon rail (no drawer, no menu button)
|
|
389
|
-
// no mega menu: menuMode is ignored and hidden in the settings dialog
|
|
390
|
-
// the user at the bottom of the sidebar; HeadLayout sticks at top-0
|
|
391
|
-
// options: sidebarFooter, showSettings (settings button at the bottom, default false), showSidebar, sidebar, footer
|
|
392
|
-
// signals: isAsideLayoutSignal, isSmallScreenSignal, isRailEverywhereSignal
|
|
393
|
-
|
|
394
|
-
// 3. MainLayout: the project's own layout from the individual parts (any markup around them)
|
|
395
|
-
<div className="flex min-h-screen flex-col">
|
|
396
|
-
<Header endContent={<UserMenu ... />} isStandalone /> {/* brand always shown on desktop */}
|
|
397
|
-
<div className="flex flex-1">
|
|
398
|
-
<aside className="w-64"><SidebarNav isAlwaysExpanded /></aside> {/* only the menu */}
|
|
399
|
-
<main>{page}</main>
|
|
400
|
-
</div>
|
|
401
|
-
</div>
|
|
402
|
-
|
|
403
|
-
// 4. No layout entry at all – the project writes everything with the main entry:
|
|
404
|
-
// AppBrand, UserMenu, LanguageSwitcher, ThemeSwitcher, SettingsMenu, PageLink, toggleSidebar ...
|
|
405
|
-
```
|
|
132
|
+
### JWT regenerate
|
|
406
133
|
|
|
407
|
-
|
|
134
|
+
With `http.regenerateUrl` set, before every request: `JwtValid(token)` (dff-util) is false → one GET to
|
|
135
|
+
`regenerateUrl` (kept in the shared page cache, so all waiting requests and MFEs share it) → the new token
|
|
136
|
+
(`token` or `data.token`) is saved in sessionStorage. An error → `endSession()` (log out, goes to `http.logoutUrl`).
|
|
137
|
+
An invalid token with an empty `regenerateUrl` throws an error at the time of the call.
|
|
408
138
|
|
|
409
139
|
```ts
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
isMenuVisibleSignal.value // current state (re-renders components)
|
|
414
|
-
// start value: config.layout.showMenu (default true)
|
|
140
|
+
await ensureFreshToken(); // what every AppHttp request does first
|
|
141
|
+
const token = await jwtRegenerateCall(); // the regenerate call itself (throws when no token)
|
|
142
|
+
readRegenerateUrl(); readJwtToken();
|
|
415
143
|
```
|
|
416
144
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
| `AppLayout` | `headerEnd`, `sidebarFooter`, `showHeader`, `showSidebar` (default: `isMenuVisibleSignal`), `header`, `sidebar`, `footer` |
|
|
420
|
-
| `Header` | `endContent`, `startContent`, `showMenuButtons`, `showSwitchers`, `isStandalone` |
|
|
421
|
-
| `Sidebar` | `footer`, `showBrand` |
|
|
422
|
-
| `SidebarNav` | `className`, `isAlwaysExpanded`, `isAlwaysShown` (menu list only, follows permissions and the menu on/off switch, skeleton while `nav` is `null`) |
|
|
423
|
-
|
|
424
|
-
The example app shows both: Settings → *App layout* switches between `AppLayout` and
|
|
425
|
-
`MainLayout` in `example/src/layout/main-layout.tsx`.
|
|
426
|
-
|
|
427
|
-
### No router: query parameters
|
|
428
|
-
|
|
429
|
-
There is no router and nothing redirects. A menu click only sets `?page=<menu href>` with the History API
|
|
430
|
-
(no reload); the app shows the component for that value. Back / forward work.
|
|
145
|
+
HTTP helpers: `API_BASE_URL_ENV`, `toAbsoluteUrl`, `isHttpUrl`, `joinUrl`, `clearSharedGetCache`, `setAppConfig`, `readAppConfig`.
|
|
146
|
+
Types: `HttpParams`, `HttpHeaders`, `HttpConfig`.
|
|
431
147
|
|
|
432
|
-
|
|
433
|
-
`http://host/?page=profiles`. Menu links, `openPage`, `PageLink`, `useCurrentPage` and back / forward all follow it;
|
|
434
|
-
other query parameters still work (`/profiles?userId=7`). The server must answer every path with `index.html`
|
|
435
|
-
(Vite dev does). For code outside React (for example single-spa `activeWhen`) use `readPageFromLocation(location)`,
|
|
436
|
-
which reads the page in either mode.
|
|
148
|
+
## Session
|
|
437
149
|
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
| `readQueryParam("userId")`, `readQueryParams()` | Read values (outside components or in handlers). |
|
|
445
|
-
| `useQueryParam("userId")`, `useCurrentPage()` | Read values in a component and re-render when they change. |
|
|
446
|
-
| `<PageLink page="/profiles">` | A link that calls `openPage` (Ctrl/Cmd-click opens a new tab). |
|
|
150
|
+
```ts
|
|
151
|
+
startSession(token, user, isRemembered); // after login
|
|
152
|
+
endSession(keepKeys?, isRedirect?); // logout
|
|
153
|
+
refreshSessionToken(token); // new token, user stays
|
|
154
|
+
isAuthenticatedSignal.value; authUserSignal.value; readAccessToken();
|
|
155
|
+
```
|
|
447
156
|
|
|
448
|
-
|
|
449
|
-
`
|
|
157
|
+
Also: `restoreSession`, `startSessionSync`, `handleSessionEvent`, `redirectToLogoutUrl`, `readTokenKey`,
|
|
158
|
+
`sessionTokenSignal`, `AUTH_USER_KEY`.
|
|
450
159
|
|
|
451
|
-
##
|
|
160
|
+
## Storage — `AppStorage`
|
|
452
161
|
|
|
453
|
-
```
|
|
454
|
-
|
|
162
|
+
```ts
|
|
163
|
+
AppStorage.setData(BRANCH_ID, id); AppStorage.getData(TOKEN); AppStorage.getText(THEME);
|
|
164
|
+
AppStorage.removeData(KEY); AppStorage.clearData(keepKeys); AppStorage.envData("API_BASE_URL");
|
|
455
165
|
```
|
|
456
166
|
|
|
457
|
-
|
|
458
|
-
`
|
|
167
|
+
Helpers: `readAppStoragePrefix`, `readPrefixedKey`, `readEnvData`, `readEnvPrefix`, `buildEnvPrefix`,
|
|
168
|
+
`isLocalStorageKey`, `readLocalStorageKeys`. Type: `StoredValue`.
|
|
169
|
+
Keys: `TOKEN`, `AUTH_USER`, `SESSION_INFO`, `SCREEN_ACCESS`, `SCREEN_ACTION`, `NAV`, `TRANS`, `DIR`, `LANG`, `THEME`,
|
|
170
|
+
`LAYOUT_CHOICE`, `MENU_MODE`, `SIDEBAR_COLLAPSED`, `REMEMBER_ME`, `OTP_ID`, `BRANCH_ID`, `BRANCH_NAME`,
|
|
171
|
+
`REGEN_EXPIRES_AT`, `ACTIVE_SESSION_ID`, `SESSION_EVENT`, `PREFERENCE_EVENT`, `StorageKeys`, `LOCAL_STORAGE_KEYS`.
|
|
459
172
|
|
|
460
|
-
##
|
|
173
|
+
## Provider and hooks
|
|
461
174
|
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
175
|
+
| Export | Use |
|
|
176
|
+
| --- | --- |
|
|
177
|
+
| `SharedWebUiProvider` | `<SharedWebUiProvider type config>` root of every app |
|
|
178
|
+
| `useUi()` | `{ locale, theme, direction, t, changeLanguage, changeTheme }` |
|
|
179
|
+
| `useCurrentPage()`, `useQueryParam(name)` | current page / query param (re-render on change) |
|
|
180
|
+
| `ThemeProvider`, `TranslationProvider`, `UiContext` | lower-level providers |
|
|
466
181
|
|
|
467
|
-
|
|
182
|
+
## Signals
|
|
468
183
|
|
|
469
|
-
|
|
184
|
+
`uiConfigSignal`, `appTypeSignal`, `localeSignal`, `languagesSignal`, `directionSignal`, `translationSignal`,
|
|
185
|
+
`fallbackTranslationSignal`, `isTranslationReadySignal`, `themeSignal`, `isDarkThemeSignal`, `customThemesSignal`,
|
|
186
|
+
`companyDetailsSignal`, `navigationSignal`, `navigationLoadingSignal`, `navigationModeSignal`, `isMenuVisibleSignal`,
|
|
187
|
+
`isSidebarOpenSignal`, `isSidebarCollapsedSignal`, `isDesktopSidebarSignal`, `isRailEverywhereSignal`,
|
|
188
|
+
`isAsideLayoutSignal`, `isSmallScreenSignal`, `isSettingsOpenSignal`, `pathnameSignal`, `currentPageSignal`,
|
|
189
|
+
`queryParamsSignal`, `progressSignal`, `toastsSignal`, `branchesSignal`, `branchIdSignal`, `branchNameSignal`,
|
|
190
|
+
`layoutChoiceSignal`, `screenAccessSignal`, `mediaPreviewSignal`, `requestedLocalesSignal`.
|
|
470
191
|
|
|
471
|
-
|
|
472
|
-
(use dff-util `ConstKeys` as messages and `RegExp` as patterns).
|
|
192
|
+
## Services
|
|
473
193
|
|
|
474
|
-
|
|
|
194
|
+
| Area | Exports |
|
|
475
195
|
| --- | --- |
|
|
476
|
-
| `
|
|
477
|
-
| `
|
|
478
|
-
| `
|
|
479
|
-
| `
|
|
480
|
-
| `
|
|
481
|
-
| `
|
|
482
|
-
|
|
|
483
|
-
|
|
|
484
|
-
|
|
|
485
|
-
|
|
|
486
|
-
|
|
487
|
-
|
|
196
|
+
| Pages (no router) | `openPage`, `PageLink`, `isPageActive`, `buildPageHref`, `buildPagePath`, `buildQueryHref`, `buildQueryString`, `readCurrentPage`, `readPageParam`, `readQueryParam`, `readQueryParams`, `setQueryParam`, `setQueryParams`, `removeQueryParam`, `readPageFromLocation`, `isPathPageMode`, `toPagePath`, `toPageParamValue` |
|
|
197
|
+
| Language / i18n | `changeLanguage`, `translate`, `interpolate`, `lookupMessage`, `trans`, `readNavLabel`, `loadLocaleMessages`, `loadLocaleGroups`, `readLocaleFilePath`, `fillLocaleBundle`, `setLanguages`, `toLanguageOptions`, `toLanguageOption`, `readLanguageRows`, `readDefaultLanguageCode`, `resolveDirection`, `findLanguageOption`, `matchLanguageCode`, `readBrowserLanguage`, `readBrowserLanguageCodes`, `readDefaultLanguage`, `readFallbackLanguage`, `readStartLanguageCandidates`, `unwrapLocaleModule`, `findDeepLocaleKeys`, `DEFAULT_LANGUAGE`, `DEFAULT_UI_MESSAGES`, `RTL_LANGUAGE_CODES`, `ROOT_LOCALE_GROUP`, `LOCALE_WAIT_MS`, `MAX_KEY_PARTS` |
|
|
198
|
+
| Theme | `changeTheme`, `isDarkThemeName`, `readThemeNames`, `readDarkThemeNames`, `splitThemesByMode`, `setCustomThemes`, `mergeCustomThemes`, `loadConfigThemes`, `followConfigThemes`, `buildCustomThemeCss`, `isValidCustomTheme`, `toCustomThemeList`, `unwrapThemesModule`, `readLogoUrl`, `DAISYUI_THEMES`, `DEFAULT_DARK_THEMES` |
|
|
199
|
+
| Menu / navigation | `setMenu`, `setMenuLoading`, `clearMenu`, `setNavigation`, `setNavigationLoading`, `changeNavigationMode`, `setMenuVisible`, `toggleMenuVisible`, `toggleSidebar`, `closeSidebar`, `toggleSidebarCollapsed`, `closeAllMenus`, `filterVisibleNavigation`, `toNavigation`, `toNavItem`, `toNavItems`, `flattenRootMenus`, `sortActiveMenus`, `compareMenuPriority`, `isRootMenu`, `unwrapRootMenu`, `readMenuRows`, `readMenuPermissions`, `findNavTrail`, `isNavItemActive`, `isPathMatch` |
|
|
200
|
+
| Access | `canAccess`, `canAccessPath`, `findNavItemByPath`, `FULL_ACCESS` |
|
|
201
|
+
| Branch | `setBranch`, `setBranches`, `clearBranch`, `readBranchId`, `findBranch`, `pickBranch`, `toBranchOptions`, `handleBranchSelect`, `readBranchName`, `DEFAULT_BRANCH_LABEL` |
|
|
202
|
+
| Company | `setCompanyDetails`, `readCompanyDetails`, `isCompanyPending`, `readAppNameLabel` |
|
|
203
|
+
| Layout choice / prefs | `changeLayoutChoice`, `applySavedLayoutChoice`, `toLayoutChoice`, `applySavedPreference`, `startPreferenceSync` |
|
|
204
|
+
| Backend loaders | `callApiSource`, `loadSessionData`, `clearSessionData`, `loadConfigLanguages`, `loadConfigCompany`, `isSignalSource` |
|
|
205
|
+
| Feedback | `ShowToast`, `removeToast`, `clearToasts`, `ShowProgress`, `openSettings`, `closeSettings`, `openMediaPreview`, `closeMediaPreview`, `scrollToTop` |
|
|
206
|
+
| Utils | `readErrorMessage`, `readContent`, `readResponseRows`, `toOptionTypes`, `readCountryOptions`, `readLanguageOptions`, `readTelCode`, `readTelCodeOptions`, `formatBytes`, `parseSizeToBytes`, `sumFileSizes`, `isFileTypeAllowed`, `normalizeFileTypes`, `readFileExtension`, `readFileIconName`, `readUploadFiles`, `resolveLucideIcon`, `isLucideIcon`, `toLucideName`, `FALLBACK_ICON`, `readSessionId`, `resetSessionId`, `setLeaveGuard`, `encryptPayload`, `decryptResponse`, `isEncryptedEnvelope`, `SharedRegExp`, `readDataValue`, `readRowKey`, `readSearchText`, `readOptionLabel`, `formatDateInputValue`, `buildMediaStyle`, `readInitials`, `goBackInHistory`, `handleDocumentEscape`, `reloadPage`, `joinClassNames` |
|
|
207
|
+
|
|
208
|
+
## Components
|
|
209
|
+
|
|
210
|
+
| Group | Exports |
|
|
211
|
+
| --- | --- |
|
|
212
|
+
| Form controls (react-hook-form) | `TypeInput`, `TypeTextArea`, `TypeSelect`, `TypeSwitch`, `TypeCheckbox`, `TypeDate`, `TypeTime`, `TypeOtp`, `TypeList`, `TypeLang`, `TypeSearch`, `TypeFilter`, `TypeUpload`, `TypeUploadBox` |
|
|
213
|
+
| Actions / overlays | `TypeButton`, `TypeDropdown`, `TypeModal`, `TypeDrawer`, `TypeConfirm`, `OtpModal`, `TypeTable`, `TypeIcon`, `TypeImage`, `TypeVideo`, `MediaViewer` |
|
|
214
|
+
| App parts | `AppBrand`, `UserMenu`, `LanguageSwitcher`, `ThemeSwitcher`, `BranchSwitcher`, `SettingsMenu`, `ToastContainer`, `TopProgress`, `ScrollToTop`, `PageLoader` |
|
|
215
|
+
| Pages / states | `RequireAccess`, `PermissionDenied`, `PageNotFound`, `ComingSoon`, `EmptyState` |
|
|
216
|
+
| Page blocks | `HeadLayout`, `ArticleLayout`, `ContentLayout`, `GridLayout`, `FloatLayout` |
|
|
217
|
+
| Skeletons | `SkeletonPage`, `SkeletonArticle`, `SkeletonTable`, `SkeletonForm`, `SkeletonCards`, `SkeletonDashboard`, `SkeletonChat`, `SkeletonMenu`, `SkeletonFloat`, `SkeletonAuthForm` |
|
|
218
|
+
| `shared-lib-web/layout` | `AppLayout`, `AsideLayout`, `AuthLayout`, `Header`, `Sidebar`, `SidebarNav`, `SidebarCollapseButton`, `MegaMenuBar`, `MegaMenuPanel`, `RailFlyout`, `RailTooltip`, `DRAWER_ID` |
|
|
219
|
+
| `shared-lib-web/markdown` | `TypeMdx` (editor), `TypeMdv` (viewer), `TypeLangMd` (editor per language) |
|
|
488
220
|
|
|
489
221
|
```tsx
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
<
|
|
493
|
-
<TypeLangMd control={control} name="body" label={t("page.body")} height={250} />
|
|
494
|
-
<TypeMdv textByLanguage={page.body} />
|
|
222
|
+
<TypeInput control={control} name="email" label={t("user.email")} type="email" rules={rules.email} />
|
|
223
|
+
<TypeButton action="primary" label={t("save")} icon="Save" type="submit" />
|
|
224
|
+
<TypeIcon name="users" />
|
|
495
225
|
```
|
|
496
226
|
|
|
497
|
-
### File upload – TypeUpload
|
|
498
227
|
|
|
499
|
-
|
|
500
|
-
<TypeUpload control={control} name="csvFile" label={t("product.csv")} fileType="csv" maxSize="10MB" rules={rules.csvFile} />
|
|
501
|
-
<TypeUpload control={control} name="photos" label={t("product.photos")} fileType={["png", "jpg"]} maxSize="5MB" isMultiple totalSize="20MB" />
|
|
502
|
-
<TypeUploadBox name="import" fileType="csv" maxSize={10} value={importFile.value} onChange={handleImportFileChange} />
|
|
503
|
-
```
|
|
228
|
+
### OTP modal — `OtpModal`
|
|
504
229
|
|
|
505
|
-
|
|
506
|
-
Value: `File` (single) or `File[]` (`isMultiple`). Then upload with:
|
|
230
|
+
1. Set the send / verify URLs in `config.ts`:
|
|
507
231
|
|
|
508
232
|
```ts
|
|
509
|
-
|
|
510
|
-
|
|
233
|
+
http: {
|
|
234
|
+
baseUrl: API_BASE_URL,
|
|
235
|
+
otp: {
|
|
236
|
+
sendUrl: `${MsUrl.sor}/otp-send`, // POST { userid } -> { data: { message, oid, uid } }
|
|
237
|
+
verifyUrl: `${MsUrl.sor}/otp-verify`, // POST { otp, oid, uid } -> { data: { message, oid, uid } }
|
|
238
|
+
resendSeconds: 180, // optional, default 180
|
|
239
|
+
length: 6, // optional, default 6
|
|
240
|
+
},
|
|
241
|
+
},
|
|
511
242
|
```
|
|
512
243
|
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
Option lists from dff-util data: `readCountryOptions()`, `readTelCodeOptions()` (+ `readTelCode("IN")` → `"+91"`), `readLanguageOptions()`.
|
|
516
|
-
|
|
517
|
-
## 7. Other components
|
|
518
|
-
|
|
519
|
-
### Sticky page header (HeadLayout)
|
|
244
|
+
2. Render `<OtpModal />` once (page or layout) and open it. The code is sent on open:
|
|
520
245
|
|
|
521
246
|
```tsx
|
|
522
|
-
|
|
523
|
-
<>
|
|
524
|
-
<TypeButton action="ghost" icon="X" label={t("user.cancel")} onPress={handleUserCancel} />
|
|
525
|
-
<TypeButton type="submit" form="user-form" icon="Save" label={t("user.save")} />
|
|
526
|
-
</>
|
|
527
|
-
);
|
|
528
|
-
|
|
529
|
-
<HeadLayout title={t("user.editTitle")} actions={headActions} />
|
|
530
|
-
<form id="user-form" onSubmit={onSubmit}>...</form>
|
|
531
|
-
```
|
|
247
|
+
import { OtpModal, openOtpModal, type OtpVerifiedResult } from "shared-lib-web";
|
|
532
248
|
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
- Optional `children` add a row under the title (filters, tabs).
|
|
249
|
+
export function handleEmailVerified(result: OtpVerifiedResult): void {
|
|
250
|
+
// result = { oid, uid, otp }
|
|
251
|
+
}
|
|
537
252
|
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
| `TypeImage`, `TypeVideo` | Media thumbnails: skeleton while loading, error icon if the file fails; a click opens one shared popup (`MediaViewer`, rendered by the provider) with the full image, or the video playing with controls. `<TypeImage src alt previewSrc? fit? className? width? height? isPreviewable? />`, `<TypeVideo src title poster? className? width? height? isPreviewable? />` (optional `width` / `height`: number = px, string = any CSS size such as `"12rem"` or `"100%"`; only a height keeps the 16:9 shape) (no poster = first frame; `isPreviewable={false}` plays inline). `openMediaPreview({ type, src, title, poster })` / `closeMediaPreview()` open it from code |
|
|
548
|
-
| `TypeModal`, `TypeDrawer`, `TypeConfirm` | Overlays (Escape, backdrop and ✕ close them) |
|
|
549
|
-
| `UserMenu`, `LanguageSwitcher`, `ThemeSwitcher`, `SettingsMenu` | Header menus |
|
|
550
|
-
| `ShowProgress(true/false)`, `TopProgress`, `ScrollToTop` | Request progress bar and scroll-to-top button |
|
|
551
|
-
| `EmptyState`, `PermissionDenied`, `RequireAccess`, `PageNotFound`, `ComingSoon`, `PageLoader` | States and pages |
|
|
552
|
-
| `SkeletonArticle`, `SkeletonTable`, `SkeletonForm`, `SkeletonCards`, `SkeletonDashboard`, `SkeletonChat`, `SkeletonMenu`, `SkeletonAuthForm`, `SkeletonPage`, `SkeletonFloat` | Loading placeholders |
|
|
553
|
-
| `ShowToast(message, type)` | Toasts |
|
|
554
|
-
| `trans(textByLanguage, defaultText)` | Pick a backend translation for the current language |
|
|
555
|
-
| `AppStorage.getData / getText / setData / removeData / clearData / envData`, `TOKEN`, `LANG`, `THEME`, `BRANCH_ID` … `StorageKeys` | Prefixed session/local storage, shared key constants, `window.env` settings |
|
|
556
|
-
| `openPage`, `setQueryParam(s)`, `removeQueryParam`, `readQueryParam(s)`, `useQueryParam`, `useCurrentPage`, `PageLink`, `currentPageSignal`, `queryParamsSignal` | Pages and query parameters (no router) |
|
|
557
|
-
| `setLanguages(reply)`, `toLanguageOptions(reply)`, `languagesSignal`, `LangSource`, `LanguageRowType`, `setMenu(reply)`, `setMenuLoading()`, `clearMenu()`, `toNavigation(reply)`, `toNavItems(menus)`, `unwrapRootMenu(menus, "ADMIN_ROOT")`, `MenuAccessType`, `MenuResponseType`, `MenuSource`, `MenuOptions`, `ScreenAccessType`, `TranslationType`, `AuthUser` | Backend menus and shared app types (menu icons are fixed with `resolveLucideIcon`) |
|
|
558
|
-
| `AppHttp.Get / Post / Put / Patch / Delete / Load / CloudUpload (uploadFile) / DownloadFile`, `AppHttp.BaseUrl()`, `AppHttp.setHeader`, `readEnvData(appNameKey, key)`, `uploadToSignedUrl`, `setAppConfig` / `readAppConfig` | HTTP client on dff-util `Http`: bearer token, session id, branch, extra headers, progress bar |
|
|
559
|
-
| `setBranch(id, name)`, `readBranchId()`, `clearBranch()`, `branchIdSignal`, `branchNameSignal` | Selected branch, sent as `x-branch-id` |
|
|
560
|
-
| `startSession(token, user, isRemembered)`, `restoreSession()`, `endSession(keepKeys)`, `authUserSignal`, `isAuthenticatedSignal` | Login state (restored on reload) |
|
|
561
|
-
| `toOptionTypes(rows)`, `readResponseRows(response)` | Backend option rows → `OptionType[]` |
|
|
562
|
-
| `resolveLucideIcon("user-round-key")` | Backend icon names → lucide names |
|
|
563
|
-
| `encryptPayload`, `decryptResponse` | AES-GCM payload encryption (key passed in) |
|
|
564
|
-
| `SharedRegExp` | dff-util `RegExp` + `MOBILE_10`, `PERSON_NAME`, `ADDRESS_TEXT`, `UPPER_ALPHA_NUMERIC` |
|
|
565
|
-
| `canAccessPath(action, path)` | Permission check for any path |
|
|
566
|
-
| Signals | `localeSignal`, `themeSignal`, `directionSignal`, `translationSignal`, `isDarkThemeSignal`, `navigationSignal`, `navigationModeSignal`, `pathnameSignal`, `screenAccessSignal` … |
|
|
567
|
-
|
|
568
|
-
Every component uses DaisyUI theme colours (`base-*`, `primary` …), so all themes – light and dark – work.
|
|
569
|
-
|
|
570
|
-
---
|
|
571
|
-
|
|
572
|
-
## Example apps
|
|
573
|
-
|
|
574
|
-
There are two examples, each its own small Vite app that uses the library source directly:
|
|
575
|
-
|
|
576
|
-
| Folder | Port | Shows |
|
|
577
|
-
| --- | --- | --- |
|
|
578
|
-
| `example-basic/` | 5174 | **One language** (en-US, `defaultLanguage` + `loadLocale`, no `lang`) and **no branches** (no `branch`): login, dashboard, users CRUD, settings (theme, menu mode, menu on/off). The smallest real setup to copy. |
|
|
579
|
-
| `example-mfe/` | 5175 | **Microfrontends**: 4 separate Vite projects — `shell` (the only `AppLayout`, login, single-spa routing from `env.mfe.js`, event-based menu after a session) and 3 MFEs `settings`, `forms`, `profile` (page layouts only; theme and language from localStorage, kept in sync between bundles). See `example-mfe/README.md`. |
|
|
580
|
-
| `example/` | 5173 | **11 languages** (`lang` from the backend, 4 RTL) and **stores** (`branch` from the backend, `isDefault` / `disabled`), plus every component, 3 layouts and all themes. |
|
|
253
|
+
export function verifyEmail(): void {
|
|
254
|
+
openOtpModal({
|
|
255
|
+
userId: email, // sent as "userid" and shown in the dialog
|
|
256
|
+
title: t("login.otpTitle"), // optional, default t("ui.otpTitle")
|
|
257
|
+
message: t("login.otpMessage"), // optional, default t("ui.otpText")
|
|
258
|
+
onVerified: handleEmailVerified, // optional, called after a successful verify
|
|
259
|
+
onCancel: handleOtpCancel, // optional
|
|
260
|
+
});
|
|
261
|
+
}
|
|
581
262
|
|
|
582
|
-
|
|
583
|
-
npm run example-basic:install
|
|
584
|
-
npm run example-basic:dev # http://localhost:5174
|
|
263
|
+
<OtpModal />
|
|
585
264
|
```
|
|
586
265
|
|
|
587
|
-
|
|
266
|
+
Every component exports its `*Props` type (`TypeInputProps`, `AppLayoutProps` …).
|
|
588
267
|
|
|
589
|
-
|
|
590
|
-
It shows login, dashboard, users CRUD (drawer + confirm + permissions), a **Components** section with every control,
|
|
591
|
-
upload, overlay, skeleton and state, and settings for language (11, including 4 RTL and Telugu, Kannada, Tamil), theme (all 35 DaisyUI themes + custom `org-light` / `org-dark`) and navigation style.
|
|
592
|
-
All pages live in one `App` component (`example/src/app.tsx`) and are picked by `?page`; the menu (`nav`) and the
|
|
593
|
-
languages (`lang`) come from fake backend replies. It uses the library source directly, so changes show up without a build.
|
|
268
|
+
## Types
|
|
594
269
|
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
270
|
+
`UiConfig`, `HttpConfig`, `AppType` (`"spa" | "shell" | "mfe"`), `PageMode`, `LayoutConfig`, `NavItem`,
|
|
271
|
+
`NavigationMode`, `ScreenPermissions`, `ScreenAction`, `ApiSource`, `ValueSignal`, `Direction`, `LanguageOption`,
|
|
272
|
+
`LocaleLoader`, `LocaleCodeLoader`, `LocaleMessages`, `LocaleModule`, `LocaleBundle`, `LocaleFileLoader`,
|
|
273
|
+
`LocaleGroupFiles`, `Theme`, `ThemesLoader`, `ThemeGroups`, `CustomTheme`, `CustomThemeEntry`, `CustomThemeMap`,
|
|
274
|
+
`CustomThemes`, `CustomThemesModule`, `CompanyDetails`, `CompanySource`, `ToastPosition`, `ToastItem`, `ToastType`,
|
|
275
|
+
`AuthUser`, `BranchOption`, `BranchRowType`, `BranchResponseType`, `BranchSource`, `LangResponseType`, `LangSource`,
|
|
276
|
+
`LanguageRowType`, `MenuAccessType`, `MenuOptions`, `MenuResponseType`, `MenuSource`, `ScreenAccessType`,
|
|
277
|
+
`TranslationType`, `TranslationRecord`, `TranslateFunction`, `TranslateParams`, `UiContextState`, `UiContextValue`,
|
|
278
|
+
`OpenPageOptions`, `QueryParamOptions`, `QueryParamValues`, `LayoutChoice`, `FileTypeRules`, `UploadValue`,
|
|
279
|
+
`UploadOptions`, `MediaPreview`, `MediaType`, `MediaFit`, `MediaSize`, `IconName`, `TableColumn`, `ModalSize`,
|
|
280
|
+
`DrawerSide`, `DrawerSize`, `ListSelectionMode`, `LangInputType`, `TimeGranularity`, `ButtonAction`, `ControlSize`,
|
|
281
|
+
`TypeFieldProps`, `EncryptedEnvelope`, `WritableLocaleBundleSignal`, `StoredValue`, `HttpParams`, `HttpHeaders`.
|
|
599
282
|
|
|
600
|
-
## Development
|
|
601
283
|
|
|
602
|
-
|
|
603
|
-
and the tests run on Node's built-in test runner (`node:test` + `jsdom`, setup in `scripts/test-setup.mjs`).
|
|
284
|
+
## Development
|
|
604
285
|
|
|
605
286
|
```bash
|
|
606
287
|
npm install
|
|
607
|
-
npm run verify
|
|
608
|
-
npm run build # tsc -> dist/, fix .d.ts import paths, copy styles.css
|
|
609
|
-
npm run check:style # readability rules only
|
|
610
|
-
npm test # tsc -> build-test/, then Node's built-in test runner (node --test) with jsdom
|
|
288
|
+
npm run verify # typecheck + code style + tests + build
|
|
611
289
|
```
|
|
612
290
|
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
## Publishing
|
|
616
|
-
|
|
617
|
-
```bash
|
|
618
|
-
npm login
|
|
619
|
-
npm version minor
|
|
620
|
-
npm publish
|
|
621
|
-
```
|
|
622
|
-
|
|
623
|
-
Or use `github-workflows/publish.yml` (move it to `.github/workflows/` and add the `NPM_TOKEN` secret).
|
|
291
|
+
Code rules: [CODING_RULES.md](./CODING_RULES.md). Examples: `example-basic/`, `example/`, `example-mfe/`.
|
|
624
292
|
|
|
625
293
|
## License
|
|
626
294
|
|
|
627
|
-
[MIT](./LICENSE)
|
|
628
|
-
|
|
629
|
-
Anybody can use this library for free, in personal or commercial projects: use it, copy it, change it, merge it,
|
|
630
|
-
publish it, share it and sell software built with it. The only condition is to keep the copyright and license notice
|
|
631
|
-
(the `LICENSE` file) with copies of the library. It comes "as is", without warranty.
|
|
295
|
+
[MIT](./LICENSE)
|