shared-lib-web 0.0.0-stage → 0.0.3
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/CODING_RULES.md +118 -0
- package/LICENSE +21 -0
- package/README.md +884 -2
- package/dist/components/app-brand.d.ts +9 -0
- package/dist/components/app-brand.d.ts.map +1 -0
- package/dist/components/app-brand.js +27 -0
- package/dist/components/app-brand.js.map +1 -0
- package/dist/components/branch-switcher.d.ts +7 -0
- package/dist/components/branch-switcher.d.ts.map +1 -0
- package/dist/components/branch-switcher.js +37 -0
- package/dist/components/branch-switcher.js.map +1 -0
- package/dist/components/coming-soon.d.ts +6 -0
- package/dist/components/coming-soon.d.ts.map +1 -0
- package/dist/components/coming-soon.js +20 -0
- package/dist/components/coming-soon.js.map +1 -0
- package/dist/components/empty-state.d.ts +15 -0
- package/dist/components/empty-state.d.ts.map +1 -0
- package/dist/components/empty-state.js +14 -0
- package/dist/components/empty-state.js.map +1 -0
- package/dist/components/language-switcher.d.ts +12 -0
- package/dist/components/language-switcher.d.ts.map +1 -0
- package/dist/components/language-switcher.js +61 -0
- package/dist/components/language-switcher.js.map +1 -0
- package/dist/components/page-loader.d.ts +2 -0
- package/dist/components/page-loader.d.ts.map +1 -0
- package/dist/components/page-loader.js +8 -0
- package/dist/components/page-loader.js.map +1 -0
- package/dist/components/page-not-found.d.ts +2 -0
- package/dist/components/page-not-found.d.ts.map +1 -0
- package/dist/components/page-not-found.js +18 -0
- package/dist/components/page-not-found.js.map +1 -0
- package/dist/components/permission-denied.d.ts +2 -0
- package/dist/components/permission-denied.d.ts.map +1 -0
- package/dist/components/permission-denied.js +12 -0
- package/dist/components/permission-denied.js.map +1 -0
- package/dist/components/require-access.d.ts +11 -0
- package/dist/components/require-access.d.ts.map +1 -0
- package/dist/components/require-access.js +15 -0
- package/dist/components/require-access.js.map +1 -0
- package/dist/components/scroll-to-top.d.ts +12 -0
- package/dist/components/scroll-to-top.d.ts.map +1 -0
- package/dist/components/scroll-to-top.js +42 -0
- package/dist/components/scroll-to-top.js.map +1 -0
- package/dist/components/settings-menu.d.ts +21 -0
- package/dist/components/settings-menu.d.ts.map +1 -0
- package/dist/components/settings-menu.js +115 -0
- package/dist/components/settings-menu.js.map +1 -0
- package/dist/components/theme-switcher.d.ts +5 -0
- package/dist/components/theme-switcher.d.ts.map +1 -0
- package/dist/components/theme-switcher.js +33 -0
- package/dist/components/theme-switcher.js.map +1 -0
- package/dist/components/toast-container.d.ts +5 -0
- package/dist/components/toast-container.d.ts.map +1 -0
- package/dist/components/toast-container.js +51 -0
- package/dist/components/toast-container.js.map +1 -0
- package/dist/components/top-progress.d.ts +2 -0
- package/dist/components/top-progress.d.ts.map +1 -0
- package/dist/components/top-progress.js +14 -0
- package/dist/components/top-progress.js.map +1 -0
- package/dist/components/user-menu.d.ts +26 -0
- package/dist/components/user-menu.d.ts.map +1 -0
- package/dist/components/user-menu.js +85 -0
- package/dist/components/user-menu.js.map +1 -0
- package/dist/context/ui-context.d.ts +5 -0
- package/dist/context/ui-context.d.ts.map +1 -0
- package/dist/context/ui-context.js +16 -0
- package/dist/context/ui-context.js.map +1 -0
- package/dist/context/use-ui.d.ts +3 -0
- package/dist/context/use-ui.d.ts.map +1 -0
- package/dist/context/use-ui.js +40 -0
- package/dist/context/use-ui.js.map +1 -0
- 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 +5 -0
- package/dist/i18n/default-messages.d.ts.map +1 -0
- package/dist/i18n/default-messages.js +67 -0
- package/dist/i18n/default-messages.js.map +1 -0
- package/dist/i18n/direction.d.ts +10 -0
- package/dist/i18n/direction.d.ts.map +1 -0
- package/dist/i18n/direction.js +35 -0
- package/dist/i18n/direction.js.map +1 -0
- 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 +54 -0
- package/dist/i18n/locale-service.d.ts.map +1 -0
- package/dist/i18n/locale-service.js +231 -0
- package/dist/i18n/locale-service.js.map +1 -0
- 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 +21 -0
- package/dist/i18n/translator.d.ts.map +1 -0
- package/dist/i18n/translator.js +105 -0
- package/dist/i18n/translator.js.map +1 -0
- package/dist/index.d.ts +117 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +130 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/app-types.d.ts +143 -0
- package/dist/interfaces/app-types.d.ts.map +1 -0
- package/dist/interfaces/app-types.js +5 -0
- package/dist/interfaces/app-types.js.map +1 -0
- package/dist/interfaces/toast.d.ts +9 -0
- package/dist/interfaces/toast.d.ts.map +1 -0
- package/dist/interfaces/toast.js +4 -0
- package/dist/interfaces/toast.js.map +1 -0
- package/dist/interfaces/ui-config.d.ts +319 -0
- package/dist/interfaces/ui-config.d.ts.map +1 -0
- package/dist/interfaces/ui-config.js +6 -0
- package/dist/interfaces/ui-config.js.map +1 -0
- package/dist/interfaces/ui-context.d.ts +37 -0
- package/dist/interfaces/ui-context.d.ts.map +1 -0
- package/dist/interfaces/ui-context.js +4 -0
- package/dist/interfaces/ui-context.js.map +1 -0
- package/dist/layout.d.ts +10 -0
- package/dist/layout.d.ts.map +1 -0
- package/dist/layout.js +22 -0
- package/dist/layout.js.map +1 -0
- package/dist/layouts/app-layout.d.ts +23 -0
- package/dist/layouts/app-layout.d.ts.map +1 -0
- package/dist/layouts/app-layout.js +52 -0
- package/dist/layouts/app-layout.js.map +1 -0
- package/dist/layouts/article-layout.d.ts +7 -0
- package/dist/layouts/article-layout.d.ts.map +1 -0
- package/dist/layouts/article-layout.js +8 -0
- package/dist/layouts/article-layout.js.map +1 -0
- package/dist/layouts/aside-layout.d.ts +27 -0
- package/dist/layouts/aside-layout.d.ts.map +1 -0
- package/dist/layouts/aside-layout.js +70 -0
- package/dist/layouts/aside-layout.js.map +1 -0
- package/dist/layouts/auth-layout.d.ts +7 -0
- package/dist/layouts/auth-layout.d.ts.map +1 -0
- package/dist/layouts/auth-layout.js +20 -0
- package/dist/layouts/auth-layout.js.map +1 -0
- package/dist/layouts/content-layout.d.ts +3 -0
- package/dist/layouts/content-layout.d.ts.map +1 -0
- package/dist/layouts/content-layout.js +10 -0
- package/dist/layouts/content-layout.js.map +1 -0
- package/dist/layouts/float-layout.d.ts +3 -0
- package/dist/layouts/float-layout.d.ts.map +1 -0
- package/dist/layouts/float-layout.js +10 -0
- package/dist/layouts/float-layout.js.map +1 -0
- package/dist/layouts/grid-layout.d.ts +3 -0
- package/dist/layouts/grid-layout.d.ts.map +1 -0
- package/dist/layouts/grid-layout.js +10 -0
- package/dist/layouts/grid-layout.js.map +1 -0
- package/dist/layouts/head-layout.d.ts +16 -0
- package/dist/layouts/head-layout.d.ts.map +1 -0
- package/dist/layouts/head-layout.js +36 -0
- package/dist/layouts/head-layout.js.map +1 -0
- package/dist/layouts/header.d.ts +18 -0
- package/dist/layouts/header.d.ts.map +1 -0
- package/dist/layouts/header.js +26 -0
- package/dist/layouts/header.js.map +1 -0
- package/dist/layouts/layout-constants.d.ts +3 -0
- package/dist/layouts/layout-constants.d.ts.map +1 -0
- package/dist/layouts/layout-constants.js +5 -0
- package/dist/layouts/layout-constants.js.map +1 -0
- package/dist/layouts/mega-menu.d.ts +3 -0
- package/dist/layouts/mega-menu.d.ts.map +1 -0
- package/dist/layouts/mega-menu.js +104 -0
- package/dist/layouts/mega-menu.js.map +1 -0
- package/dist/layouts/navigation.d.ts +11 -0
- package/dist/layouts/navigation.d.ts.map +1 -0
- package/dist/layouts/navigation.js +41 -0
- package/dist/layouts/navigation.js.map +1 -0
- package/dist/layouts/rail-flyout.d.ts +5 -0
- package/dist/layouts/rail-flyout.d.ts.map +1 -0
- package/dist/layouts/rail-flyout.js +49 -0
- package/dist/layouts/rail-flyout.js.map +1 -0
- package/dist/layouts/rail-tooltip.d.ts +8 -0
- package/dist/layouts/rail-tooltip.d.ts.map +1 -0
- package/dist/layouts/rail-tooltip.js +60 -0
- package/dist/layouts/rail-tooltip.js.map +1 -0
- package/dist/layouts/sidebar.d.ts +38 -0
- package/dist/layouts/sidebar.d.ts.map +1 -0
- package/dist/layouts/sidebar.js +137 -0
- package/dist/layouts/sidebar.js.map +1 -0
- package/dist/markdown.d.ts +4 -0
- package/dist/markdown.d.ts.map +1 -0
- package/dist/markdown.js +12 -0
- package/dist/markdown.js.map +1 -0
- package/dist/providers/provider-effects.d.ts +9 -0
- package/dist/providers/provider-effects.d.ts.map +1 -0
- package/dist/providers/provider-effects.js +29 -0
- package/dist/providers/provider-effects.js.map +1 -0
- package/dist/providers/register-config.d.ts +4 -0
- package/dist/providers/register-config.d.ts.map +1 -0
- package/dist/providers/register-config.js +30 -0
- package/dist/providers/register-config.js.map +1 -0
- package/dist/providers/shared-web-ui-provider.d.ts +19 -0
- package/dist/providers/shared-web-ui-provider.d.ts.map +1 -0
- package/dist/providers/shared-web-ui-provider.js +53 -0
- package/dist/providers/shared-web-ui-provider.js.map +1 -0
- package/dist/providers/theme-provider.d.ts +6 -0
- package/dist/providers/theme-provider.d.ts.map +1 -0
- package/dist/providers/theme-provider.js +11 -0
- package/dist/providers/theme-provider.js.map +1 -0
- package/dist/providers/translation-provider.d.ts +8 -0
- package/dist/providers/translation-provider.d.ts.map +1 -0
- package/dist/providers/translation-provider.js +21 -0
- package/dist/providers/translation-provider.js.map +1 -0
- package/dist/query/page-link.d.ts +20 -0
- package/dist/query/page-link.d.ts.map +1 -0
- package/dist/query/page-link.js +53 -0
- package/dist/query/page-link.js.map +1 -0
- package/dist/query/page-path.d.ts +5 -0
- package/dist/query/page-path.d.ts.map +1 -0
- package/dist/query/page-path.js +24 -0
- package/dist/query/page-path.js.map +1 -0
- package/dist/query/query-param.d.ts +66 -0
- package/dist/query/query-param.d.ts.map +1 -0
- package/dist/query/query-param.js +218 -0
- package/dist/query/query-param.js.map +1 -0
- package/dist/query/use-query-param.d.ts +5 -0
- package/dist/query/use-query-param.d.ts.map +1 -0
- package/dist/query/use-query-param.js +21 -0
- package/dist/query/use-query-param.js.map +1 -0
- package/dist/skeleton/skeleton-article.d.ts +2 -0
- package/dist/skeleton/skeleton-article.d.ts.map +1 -0
- package/dist/skeleton/skeleton-article.js +7 -0
- package/dist/skeleton/skeleton-article.js.map +1 -0
- package/dist/skeleton/skeleton-auth-form.d.ts +6 -0
- package/dist/skeleton/skeleton-auth-form.d.ts.map +1 -0
- package/dist/skeleton/skeleton-auth-form.js +9 -0
- package/dist/skeleton/skeleton-auth-form.js.map +1 -0
- package/dist/skeleton/skeleton-cards.d.ts +6 -0
- package/dist/skeleton/skeleton-cards.d.ts.map +1 -0
- package/dist/skeleton/skeleton-cards.js +16 -0
- package/dist/skeleton/skeleton-cards.js.map +1 -0
- package/dist/skeleton/skeleton-chat.d.ts +2 -0
- package/dist/skeleton/skeleton-chat.d.ts.map +1 -0
- package/dist/skeleton/skeleton-chat.js +17 -0
- package/dist/skeleton/skeleton-chat.js.map +1 -0
- package/dist/skeleton/skeleton-dashboard.d.ts +2 -0
- package/dist/skeleton/skeleton-dashboard.d.ts.map +1 -0
- package/dist/skeleton/skeleton-dashboard.js +16 -0
- package/dist/skeleton/skeleton-dashboard.js.map +1 -0
- package/dist/skeleton/skeleton-float.d.ts +2 -0
- package/dist/skeleton/skeleton-float.d.ts.map +1 -0
- package/dist/skeleton/skeleton-float.js +7 -0
- package/dist/skeleton/skeleton-float.js.map +1 -0
- package/dist/skeleton/skeleton-form.d.ts +10 -0
- package/dist/skeleton/skeleton-form.d.ts.map +1 -0
- package/dist/skeleton/skeleton-form.js +16 -0
- package/dist/skeleton/skeleton-form.js.map +1 -0
- package/dist/skeleton/skeleton-menu.d.ts +2 -0
- package/dist/skeleton/skeleton-menu.d.ts.map +1 -0
- package/dist/skeleton/skeleton-menu.js +16 -0
- package/dist/skeleton/skeleton-menu.js.map +1 -0
- package/dist/skeleton/skeleton-page.d.ts +2 -0
- package/dist/skeleton/skeleton-page.d.ts.map +1 -0
- package/dist/skeleton/skeleton-page.js +9 -0
- package/dist/skeleton/skeleton-page.js.map +1 -0
- package/dist/skeleton/skeleton-table.d.ts +2 -0
- package/dist/skeleton/skeleton-table.d.ts.map +1 -0
- package/dist/skeleton/skeleton-table.js +16 -0
- package/dist/skeleton/skeleton-table.js.map +1 -0
- 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 +32 -0
- package/dist/state/auth-service.d.ts.map +1 -0
- package/dist/state/auth-service.js +136 -0
- package/dist/state/auth-service.js.map +1 -0
- package/dist/state/branch-service.d.ts +42 -0
- package/dist/state/branch-service.d.ts.map +1 -0
- package/dist/state/branch-service.js +193 -0
- package/dist/state/branch-service.js.map +1 -0
- 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/document-sync.d.ts +7 -0
- package/dist/state/document-sync.d.ts.map +1 -0
- package/dist/state/document-sync.js +39 -0
- package/dist/state/document-sync.js.map +1 -0
- package/dist/state/language-service.d.ts +19 -0
- package/dist/state/language-service.d.ts.map +1 -0
- package/dist/state/language-service.js +78 -0
- package/dist/state/language-service.js.map +1 -0
- 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 +20 -0
- package/dist/state/menu-service.d.ts.map +1 -0
- package/dist/state/menu-service.js +59 -0
- package/dist/state/menu-service.js.map +1 -0
- package/dist/state/navigation-service.d.ts +37 -0
- package/dist/state/navigation-service.d.ts.map +1 -0
- package/dist/state/navigation-service.js +131 -0
- package/dist/state/navigation-service.js.map +1 -0
- package/dist/state/preference-sync.d.ts +15 -0
- package/dist/state/preference-sync.d.ts.map +1 -0
- package/dist/state/preference-sync.js +93 -0
- package/dist/state/preference-sync.js.map +1 -0
- package/dist/state/progress-service.d.ts +3 -0
- package/dist/state/progress-service.d.ts.map +1 -0
- package/dist/state/progress-service.js +17 -0
- package/dist/state/progress-service.js.map +1 -0
- package/dist/state/screen-access.d.ts +15 -0
- package/dist/state/screen-access.d.ts.map +1 -0
- package/dist/state/screen-access.js +60 -0
- package/dist/state/screen-access.js.map +1 -0
- package/dist/state/sidebar-service.d.ts +8 -0
- package/dist/state/sidebar-service.d.ts.map +1 -0
- package/dist/state/sidebar-service.js +18 -0
- package/dist/state/sidebar-service.js.map +1 -0
- package/dist/state/signals.d.ts +92 -0
- package/dist/state/signals.d.ts.map +1 -0
- package/dist/state/signals.js +161 -0
- package/dist/state/signals.js.map +1 -0
- package/dist/state/toast-service.d.ts +9 -0
- package/dist/state/toast-service.d.ts.map +1 -0
- package/dist/state/toast-service.js +36 -0
- package/dist/state/toast-service.js.map +1 -0
- package/dist/styles.css +15 -0
- 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 +10 -0
- package/dist/theme/dark-themes.d.ts.map +1 -0
- package/dist/theme/dark-themes.js +92 -0
- package/dist/theme/dark-themes.js.map +1 -0
- package/dist/theme/logo.d.ts +7 -0
- package/dist/theme/logo.d.ts.map +1 -0
- package/dist/theme/logo.js +24 -0
- package/dist/theme/logo.js.map +1 -0
- package/dist/theme/theme-service.d.ts +32 -0
- package/dist/theme/theme-service.d.ts.map +1 -0
- package/dist/theme/theme-service.js +123 -0
- package/dist/theme/theme-service.js.map +1 -0
- package/dist/types/class-names.d.ts +9 -0
- package/dist/types/class-names.d.ts.map +1 -0
- package/dist/types/class-names.js +45 -0
- package/dist/types/class-names.js.map +1 -0
- package/dist/types/field-error.d.ts +5 -0
- package/dist/types/field-error.d.ts.map +1 -0
- package/dist/types/field-error.js +16 -0
- package/dist/types/field-error.js.map +1 -0
- package/dist/types/field-props.d.ts +20 -0
- package/dist/types/field-props.d.ts.map +1 -0
- package/dist/types/field-props.js +4 -0
- package/dist/types/field-props.js.map +1 -0
- package/dist/types/field-registry.d.ts +11 -0
- package/dist/types/field-registry.d.ts.map +1 -0
- package/dist/types/field-registry.js +18 -0
- package/dist/types/field-registry.js.map +1 -0
- package/dist/types/field-wrapper.d.ts +13 -0
- package/dist/types/field-wrapper.d.ts.map +1 -0
- package/dist/types/field-wrapper.js +16 -0
- package/dist/types/field-wrapper.js.map +1 -0
- package/dist/types/lang-field.d.ts +15 -0
- package/dist/types/lang-field.d.ts.map +1 -0
- package/dist/types/lang-field.js +68 -0
- package/dist/types/lang-field.js.map +1 -0
- package/dist/types/markdown-color-mode.d.ts +7 -0
- package/dist/types/markdown-color-mode.d.ts.map +1 -0
- package/dist/types/markdown-color-mode.js +11 -0
- package/dist/types/markdown-color-mode.js.map +1 -0
- package/dist/types/media-service.d.ts +24 -0
- package/dist/types/media-service.d.ts.map +1 -0
- package/dist/types/media-service.js +41 -0
- package/dist/types/media-service.js.map +1 -0
- package/dist/types/media-viewer.d.ts +2 -0
- package/dist/types/media-viewer.d.ts.map +1 -0
- package/dist/types/media-viewer.js +23 -0
- package/dist/types/media-viewer.js.map +1 -0
- package/dist/types/type.button.d.ts +36 -0
- package/dist/types/type.button.d.ts.map +1 -0
- package/dist/types/type.button.js +27 -0
- package/dist/types/type.button.js.map +1 -0
- package/dist/types/type.checkbox.d.ts +5 -0
- package/dist/types/type.checkbox.d.ts.map +1 -0
- package/dist/types/type.checkbox.js +26 -0
- package/dist/types/type.checkbox.js.map +1 -0
- package/dist/types/type.confirm.d.ts +19 -0
- package/dist/types/type.confirm.d.ts.map +1 -0
- package/dist/types/type.confirm.js +15 -0
- package/dist/types/type.confirm.js.map +1 -0
- package/dist/types/type.date.d.ts +16 -0
- package/dist/types/type.date.d.ts.map +1 -0
- package/dist/types/type.date.js +65 -0
- package/dist/types/type.date.js.map +1 -0
- package/dist/types/type.drawer.d.ts +20 -0
- package/dist/types/type.drawer.d.ts.map +1 -0
- package/dist/types/type.drawer.js +31 -0
- package/dist/types/type.drawer.js.map +1 -0
- package/dist/types/type.dropdown.d.ts +23 -0
- package/dist/types/type.dropdown.d.ts.map +1 -0
- package/dist/types/type.dropdown.js +34 -0
- package/dist/types/type.dropdown.js.map +1 -0
- package/dist/types/type.filter.d.ts +17 -0
- package/dist/types/type.filter.d.ts.map +1 -0
- package/dist/types/type.filter.js +28 -0
- package/dist/types/type.filter.js.map +1 -0
- package/dist/types/type.icon.d.ts +21 -0
- package/dist/types/type.icon.d.ts.map +1 -0
- package/dist/types/type.icon.js +24 -0
- package/dist/types/type.icon.js.map +1 -0
- package/dist/types/type.image.d.ts +34 -0
- package/dist/types/type.image.d.ts.map +1 -0
- package/dist/types/type.image.js +46 -0
- package/dist/types/type.image.js.map +1 -0
- package/dist/types/type.input.d.ts +13 -0
- package/dist/types/type.input.d.ts.map +1 -0
- package/dist/types/type.input.js +29 -0
- package/dist/types/type.input.js.map +1 -0
- package/dist/types/type.lang-md.d.ts +10 -0
- package/dist/types/type.lang-md.d.ts.map +1 -0
- package/dist/types/type.lang-md.js +56 -0
- package/dist/types/type.lang-md.js.map +1 -0
- package/dist/types/type.lang.d.ts +11 -0
- package/dist/types/type.lang.d.ts.map +1 -0
- package/dist/types/type.lang.js +56 -0
- package/dist/types/type.lang.js.map +1 -0
- package/dist/types/type.list.d.ts +13 -0
- package/dist/types/type.list.d.ts.map +1 -0
- package/dist/types/type.list.js +42 -0
- package/dist/types/type.list.js.map +1 -0
- package/dist/types/type.mdv.d.ts +10 -0
- package/dist/types/type.mdv.d.ts.map +1 -0
- package/dist/types/type.mdv.js +22 -0
- package/dist/types/type.mdv.js.map +1 -0
- package/dist/types/type.mdx.d.ts +10 -0
- package/dist/types/type.mdx.d.ts.map +1 -0
- package/dist/types/type.mdx.js +30 -0
- package/dist/types/type.mdx.js.map +1 -0
- package/dist/types/type.modal.d.ts +18 -0
- package/dist/types/type.modal.d.ts.map +1 -0
- package/dist/types/type.modal.js +30 -0
- package/dist/types/type.modal.js.map +1 -0
- package/dist/types/type.otp.d.ts +8 -0
- package/dist/types/type.otp.d.ts.map +1 -0
- package/dist/types/type.otp.js +48 -0
- package/dist/types/type.otp.js.map +1 -0
- package/dist/types/type.search.d.ts +16 -0
- package/dist/types/type.search.d.ts.map +1 -0
- package/dist/types/type.search.js +48 -0
- package/dist/types/type.search.js.map +1 -0
- package/dist/types/type.select.d.ts +14 -0
- package/dist/types/type.select.d.ts.map +1 -0
- package/dist/types/type.select.js +53 -0
- package/dist/types/type.select.js.map +1 -0
- package/dist/types/type.switch.d.ts +8 -0
- package/dist/types/type.switch.d.ts.map +1 -0
- package/dist/types/type.switch.js +26 -0
- package/dist/types/type.switch.js.map +1 -0
- package/dist/types/type.table.d.ts +28 -0
- package/dist/types/type.table.d.ts.map +1 -0
- package/dist/types/type.table.js +72 -0
- package/dist/types/type.table.js.map +1 -0
- package/dist/types/type.text-area.d.ts +9 -0
- package/dist/types/type.text-area.d.ts.map +1 -0
- package/dist/types/type.text-area.js +26 -0
- package/dist/types/type.text-area.js.map +1 -0
- package/dist/types/type.time.d.ts +9 -0
- package/dist/types/type.time.d.ts.map +1 -0
- package/dist/types/type.time.js +34 -0
- package/dist/types/type.time.js.map +1 -0
- package/dist/types/type.upload.d.ts +45 -0
- package/dist/types/type.upload.d.ts.map +1 -0
- package/dist/types/type.upload.js +90 -0
- package/dist/types/type.upload.js.map +1 -0
- package/dist/types/type.video.d.ts +19 -0
- package/dist/types/type.video.d.ts.map +1 -0
- package/dist/types/type.video.js +33 -0
- package/dist/types/type.video.js.map +1 -0
- package/dist/types/upload-service.d.ts +47 -0
- package/dist/types/upload-service.d.ts.map +1 -0
- package/dist/types/upload-service.js +191 -0
- package/dist/types/upload-service.js.map +1 -0
- package/dist/utils/app-config.d.ts +6 -0
- package/dist/utils/app-config.d.ts.map +1 -0
- package/dist/utils/app-config.js +17 -0
- package/dist/utils/app-config.js.map +1 -0
- package/dist/utils/app-http.d.ts +77 -0
- package/dist/utils/app-http.d.ts.map +1 -0
- package/dist/utils/app-http.js +331 -0
- package/dist/utils/app-http.js.map +1 -0
- package/dist/utils/app-storage.d.ts +56 -0
- package/dist/utils/app-storage.d.ts.map +1 -0
- package/dist/utils/app-storage.js +236 -0
- package/dist/utils/app-storage.js.map +1 -0
- 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/crypto-util.d.ts +15 -0
- package/dist/utils/crypto-util.d.ts.map +1 -0
- package/dist/utils/crypto-util.js +76 -0
- package/dist/utils/crypto-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/event-util.d.ts +16 -0
- package/dist/utils/event-util.d.ts.map +1 -0
- package/dist/utils/event-util.js +51 -0
- package/dist/utils/event-util.js.map +1 -0
- package/dist/utils/file-util.d.ts +30 -0
- package/dist/utils/file-util.d.ts.map +1 -0
- package/dist/utils/file-util.js +165 -0
- package/dist/utils/file-util.js.map +1 -0
- package/dist/utils/lang-util.d.ts +12 -0
- package/dist/utils/lang-util.d.ts.map +1 -0
- package/dist/utils/lang-util.js +53 -0
- package/dist/utils/lang-util.js.map +1 -0
- package/dist/utils/language-util.d.ts +21 -0
- package/dist/utils/language-util.d.ts.map +1 -0
- package/dist/utils/language-util.js +96 -0
- package/dist/utils/language-util.js.map +1 -0
- package/dist/utils/leave-guard.d.ts +5 -0
- package/dist/utils/leave-guard.d.ts.map +1 -0
- package/dist/utils/leave-guard.js +24 -0
- package/dist/utils/leave-guard.js.map +1 -0
- package/dist/utils/lucide-icon.d.ts +10 -0
- package/dist/utils/lucide-icon.d.ts.map +1 -0
- package/dist/utils/lucide-icon.js +48 -0
- package/dist/utils/lucide-icon.js.map +1 -0
- package/dist/utils/menu-util.d.ts +33 -0
- package/dist/utils/menu-util.d.ts.map +1 -0
- package/dist/utils/menu-util.js +151 -0
- package/dist/utils/menu-util.js.map +1 -0
- package/dist/utils/option-util.d.ts +21 -0
- package/dist/utils/option-util.d.ts.map +1 -0
- package/dist/utils/option-util.js +101 -0
- package/dist/utils/option-util.js.map +1 -0
- package/dist/utils/session-id.d.ts +5 -0
- package/dist/utils/session-id.d.ts.map +1 -0
- package/dist/utils/session-id.js +44 -0
- package/dist/utils/session-id.js.map +1 -0
- package/dist/utils/shared-regexp.d.ts +31 -0
- package/dist/utils/shared-regexp.d.ts.map +1 -0
- package/dist/utils/shared-regexp.js +17 -0
- package/dist/utils/shared-regexp.js.map +1 -0
- 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 +73 -0
- package/dist/utils/storage-keys.d.ts.map +1 -0
- package/dist/utils/storage-keys.js +80 -0
- package/dist/utils/storage-keys.js.map +1 -0
- package/package.json +101 -4
- package/src/components/app-brand.tsx +41 -0
- package/src/components/branch-switcher.tsx +74 -0
- package/src/components/coming-soon.tsx +36 -0
- package/src/components/empty-state.tsx +42 -0
- package/src/components/language-switcher.tsx +96 -0
- package/src/components/page-loader.tsx +11 -0
- package/src/components/page-not-found.tsx +42 -0
- package/src/components/permission-denied.tsx +21 -0
- package/src/components/require-access.tsx +30 -0
- package/src/components/scroll-to-top.tsx +62 -0
- package/src/components/settings-menu.tsx +250 -0
- package/src/components/theme-switcher.tsx +72 -0
- package/src/components/toast-container.tsx +73 -0
- package/src/components/top-progress.tsx +14 -0
- package/src/components/user-menu.tsx +179 -0
- package/src/context/ui-context.ts +20 -0
- package/src/context/use-ui.ts +43 -0
- package/src/i18n/browser-language.ts +98 -0
- package/src/i18n/default-messages.ts +70 -0
- package/src/i18n/direction.ts +43 -0
- package/src/i18n/locale-groups.ts +87 -0
- package/src/i18n/locale-service.ts +259 -0
- package/src/i18n/locale-signal.ts +173 -0
- package/src/i18n/translator.ts +114 -0
- package/src/index.ts +409 -0
- package/src/interfaces/app-types.ts +160 -0
- package/src/interfaces/toast.ts +12 -0
- package/src/interfaces/ui-config.ts +342 -0
- package/src/interfaces/ui-context.ts +43 -0
- package/src/layout.ts +29 -0
- package/src/layouts/app-layout.tsx +103 -0
- package/src/layouts/article-layout.tsx +16 -0
- package/src/layouts/aside-layout.tsx +118 -0
- package/src/layouts/auth-layout.tsx +41 -0
- package/src/layouts/content-layout.tsx +11 -0
- package/src/layouts/float-layout.tsx +11 -0
- package/src/layouts/grid-layout.tsx +11 -0
- package/src/layouts/head-layout.tsx +61 -0
- package/src/layouts/header.tsx +74 -0
- package/src/layouts/layout-constants.ts +5 -0
- package/src/layouts/mega-menu.tsx +203 -0
- package/src/layouts/navigation.ts +45 -0
- package/src/layouts/rail-flyout.tsx +77 -0
- package/src/layouts/rail-tooltip.tsx +77 -0
- package/src/layouts/sidebar.tsx +296 -0
- package/src/markdown.ts +12 -0
- package/src/providers/provider-effects.ts +33 -0
- package/src/providers/register-config.ts +32 -0
- package/src/providers/shared-web-ui-provider.tsx +81 -0
- package/src/providers/theme-provider.tsx +15 -0
- package/src/providers/translation-provider.tsx +28 -0
- package/src/query/page-link.tsx +84 -0
- package/src/query/page-path.ts +26 -0
- package/src/query/query-param.ts +267 -0
- package/src/query/use-query-param.ts +23 -0
- package/src/skeleton/skeleton-article.tsx +11 -0
- package/src/skeleton/skeleton-auth-form.tsx +20 -0
- package/src/skeleton/skeleton-cards.tsx +35 -0
- package/src/skeleton/skeleton-chat.tsx +34 -0
- package/src/skeleton/skeleton-dashboard.tsx +34 -0
- package/src/skeleton/skeleton-float.tsx +10 -0
- package/src/skeleton/skeleton-form.tsx +45 -0
- package/src/skeleton/skeleton-menu.tsx +30 -0
- package/src/skeleton/skeleton-page.tsx +18 -0
- package/src/skeleton/skeleton-table.tsx +25 -0
- package/src/state/api-loader.ts +205 -0
- package/src/state/auth-service.ts +159 -0
- package/src/state/branch-service.ts +217 -0
- package/src/state/company-service.ts +107 -0
- package/src/state/document-sync.ts +43 -0
- package/src/state/language-service.ts +85 -0
- package/src/state/layout-choice-service.ts +40 -0
- package/src/state/menu-service.ts +67 -0
- package/src/state/navigation-service.ts +160 -0
- package/src/state/preference-sync.ts +101 -0
- package/src/state/progress-service.ts +18 -0
- package/src/state/screen-access.ts +70 -0
- package/src/state/sidebar-service.ts +22 -0
- package/src/state/signals.ts +215 -0
- package/src/state/toast-service.ts +45 -0
- package/src/styles.css +15 -0
- package/src/theme/custom-themes.ts +236 -0
- package/src/theme/dark-themes.ts +97 -0
- package/src/theme/logo.ts +27 -0
- package/src/theme/org-themes.json +70 -0
- package/src/theme/theme-service.ts +142 -0
- package/src/types/class-names.ts +53 -0
- package/src/types/field-error.ts +19 -0
- package/src/types/field-props.ts +23 -0
- package/src/types/field-registry.ts +27 -0
- package/src/types/field-wrapper.tsx +42 -0
- package/src/types/lang-field.ts +71 -0
- package/src/types/markdown-color-mode.ts +13 -0
- package/src/types/media-service.ts +61 -0
- package/src/types/media-viewer.tsx +57 -0
- package/src/types/type.button.tsx +108 -0
- package/src/types/type.checkbox.tsx +49 -0
- package/src/types/type.confirm.tsx +50 -0
- package/src/types/type.date.tsx +97 -0
- package/src/types/type.drawer.tsx +86 -0
- package/src/types/type.dropdown.tsx +81 -0
- package/src/types/type.filter.tsx +64 -0
- package/src/types/type.icon.ts +53 -0
- package/src/types/type.image.tsx +115 -0
- package/src/types/type.input.tsx +57 -0
- package/src/types/type.lang-md.tsx +129 -0
- package/src/types/type.lang.tsx +156 -0
- package/src/types/type.list.tsx +97 -0
- package/src/types/type.mdv.tsx +35 -0
- package/src/types/type.mdx.tsx +54 -0
- package/src/types/type.modal.tsx +77 -0
- package/src/types/type.otp.tsx +82 -0
- package/src/types/type.search.tsx +87 -0
- package/src/types/type.select.tsx +87 -0
- package/src/types/type.switch.tsx +52 -0
- package/src/types/type.table.tsx +152 -0
- package/src/types/type.text-area.tsx +51 -0
- package/src/types/type.time.tsx +61 -0
- package/src/types/type.upload.tsx +294 -0
- package/src/types/type.video.tsx +119 -0
- package/src/types/upload-service.ts +229 -0
- package/src/utils/app-config.ts +21 -0
- package/src/utils/app-http.ts +369 -0
- package/src/utils/app-storage.ts +259 -0
- package/src/utils/content-util.ts +49 -0
- package/src/utils/crypto-util.ts +88 -0
- package/src/utils/error-util.ts +64 -0
- package/src/utils/event-util.ts +58 -0
- package/src/utils/file-util.ts +186 -0
- package/src/utils/lang-util.ts +60 -0
- package/src/utils/language-util.ts +107 -0
- package/src/utils/leave-guard.ts +26 -0
- package/src/utils/lucide-icon.ts +55 -0
- package/src/utils/menu-util.ts +165 -0
- package/src/utils/option-util.ts +108 -0
- package/src/utils/session-id.ts +48 -0
- package/src/utils/shared-regexp.ts +18 -0
- package/src/utils/signal-source.ts +15 -0
- package/src/utils/storage-keys.ts +86 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// auth-service.ts
|
|
2
|
+
// Signed-in user and access token, shared by AppHttp and the app.
|
|
3
|
+
//
|
|
4
|
+
// startSession(token, user); // after login (token saved in AppStorage, sessionStorage)
|
|
5
|
+
// startSession(token, user, true); // also saves REMEMBER_ME = true (localStorage); the token stays in sessionStorage
|
|
6
|
+
// isAuthenticatedSignal.value // true / false
|
|
7
|
+
// endSession(); // log out (LANG, THEME ... are kept)
|
|
8
|
+
// endSession([BRANCH_ID]); // log out, also keeps the listed AppStorage keys
|
|
9
|
+
//
|
|
10
|
+
// Microfrontends: each one bundles its own copy of the library. startSession / endSession fire SESSION_EVENT, and
|
|
11
|
+
// every other copy (startSessionSync, started by the provider) applies it: an auth MFE signs in -> the shell is signed in.
|
|
12
|
+
import { computed, signal } from "@preact/signals-react";
|
|
13
|
+
import { ConstValue } from "dff-util";
|
|
14
|
+
import { AppStorage } from "../utils/app-storage.js";
|
|
15
|
+
import { resetSessionId } from "../utils/session-id.js";
|
|
16
|
+
import { AUTH_USER, BRANCH_ID, REMEMBER_ME, SESSION_EVENT, TOKEN } from "../utils/storage-keys.js";
|
|
17
|
+
import { clearBranch, forgetAppliedBranches, restoreBranch } from "./branch-service.js";
|
|
18
|
+
import { uiConfigSignal } from "./signals.js";
|
|
19
|
+
export const DEFAULT_TOKEN_KEY = TOKEN;
|
|
20
|
+
export const AUTH_USER_KEY = AUTH_USER;
|
|
21
|
+
/** The signed-in user, or null. */
|
|
22
|
+
export const authUserSignal = signal(null);
|
|
23
|
+
/** The access token, or "". */
|
|
24
|
+
export const sessionTokenSignal = signal(ConstValue.EMPTY);
|
|
25
|
+
function readIsAuthenticated() {
|
|
26
|
+
const token = sessionTokenSignal.value;
|
|
27
|
+
return token.length > 0;
|
|
28
|
+
}
|
|
29
|
+
/** true when a token is present. */
|
|
30
|
+
export const isAuthenticatedSignal = computed(readIsAuthenticated);
|
|
31
|
+
/** Id of this copy of the library: its own session events are not applied again. */
|
|
32
|
+
const randomNumber = Math.random();
|
|
33
|
+
const LIBRARY_COPY_ID = String(randomNumber);
|
|
34
|
+
let isSessionSyncStarted = false;
|
|
35
|
+
/** Tells every other library copy on the page that the session started or ended. */
|
|
36
|
+
function notifySessionChanged(isSignedIn) {
|
|
37
|
+
if (typeof window === "undefined") {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const detail = { isSignedIn: isSignedIn, copyId: LIBRARY_COPY_ID };
|
|
41
|
+
const eventInit = { detail: detail };
|
|
42
|
+
const sessionEvent = new CustomEvent(SESSION_EVENT, eventInit);
|
|
43
|
+
window.dispatchEvent(sessionEvent);
|
|
44
|
+
}
|
|
45
|
+
/** AppStorage key of the token (config.http.tokenKey, default "TOKEN"). */
|
|
46
|
+
export function readTokenKey() {
|
|
47
|
+
const config = uiConfigSignal.value;
|
|
48
|
+
return config?.http?.tokenKey ?? DEFAULT_TOKEN_KEY;
|
|
49
|
+
}
|
|
50
|
+
/** Token without a "Bearer " prefix; "" when missing. */
|
|
51
|
+
export function readAccessToken() {
|
|
52
|
+
const token = sessionTokenSignal.value;
|
|
53
|
+
const plainToken = token.replace(/^Bearer\s+/i, ConstValue.EMPTY);
|
|
54
|
+
return plainToken.trim();
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Saves token and user after login (sessionStorage). isRemembered only saves the REMEMBER_ME preference
|
|
58
|
+
* (localStorage), for example to pre-tick the box on the login form next time.
|
|
59
|
+
*/
|
|
60
|
+
export function startSession(token, user, isRemembered = false) {
|
|
61
|
+
const tokenKey = readTokenKey();
|
|
62
|
+
AppStorage.setData(tokenKey, token);
|
|
63
|
+
AppStorage.setData(AUTH_USER_KEY, user);
|
|
64
|
+
AppStorage.setData(REMEMBER_ME, isRemembered);
|
|
65
|
+
// The user first: whatever runs on sign in (branches, menu) already reads the user.
|
|
66
|
+
authUserSignal.value = user;
|
|
67
|
+
sessionTokenSignal.value = token;
|
|
68
|
+
notifySessionChanged(true);
|
|
69
|
+
}
|
|
70
|
+
/** Reads a saved session (sessionStorage). Called by SharedWebUiProvider. */
|
|
71
|
+
export function restoreSession() {
|
|
72
|
+
restoreBranch();
|
|
73
|
+
const tokenKey = readTokenKey();
|
|
74
|
+
const token = AppStorage.getData(tokenKey);
|
|
75
|
+
if (typeof token !== "string" || token.length === 0) {
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
const storedUser = AppStorage.getData(AUTH_USER_KEY);
|
|
79
|
+
authUserSignal.value = storedUser && typeof storedUser === "object" ? storedUser : null;
|
|
80
|
+
sessionTokenSignal.value = token;
|
|
81
|
+
}
|
|
82
|
+
/** Sends the browser to config.http.logoutUrl (replace: Back does not return to the signed-in page). */
|
|
83
|
+
export function redirectToLogoutUrl() {
|
|
84
|
+
const config = uiConfigSignal.peek();
|
|
85
|
+
const logoutUrl = config?.http?.logoutUrl;
|
|
86
|
+
const hasWindow = typeof window !== "undefined";
|
|
87
|
+
if (!logoutUrl || !hasWindow) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
window.location.replace(logoutUrl);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Logs out: clears token, user and app storage (except keepKeys), starts a new session id
|
|
94
|
+
* and goes to config.http.logoutUrl when it is set (isRedirect = false stays on the page).
|
|
95
|
+
*/
|
|
96
|
+
export function endSession(keepKeys = [], isRedirect = true) {
|
|
97
|
+
AppStorage.clearData(keepKeys);
|
|
98
|
+
const isBranchKept = keepKeys.includes(BRANCH_ID);
|
|
99
|
+
if (!isBranchKept) {
|
|
100
|
+
clearBranch();
|
|
101
|
+
}
|
|
102
|
+
// The next sign-in selects a branch again, even when the app passes the same branch list.
|
|
103
|
+
forgetAppliedBranches();
|
|
104
|
+
sessionTokenSignal.value = ConstValue.EMPTY;
|
|
105
|
+
authUserSignal.value = null;
|
|
106
|
+
resetSessionId();
|
|
107
|
+
notifySessionChanged(false);
|
|
108
|
+
if (isRedirect) {
|
|
109
|
+
redirectToLogoutUrl();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/** Another library copy started or ended the session: read it from AppStorage (sign in) or clear it here (sign out). */
|
|
113
|
+
export function handleSessionEvent(event) {
|
|
114
|
+
const detail = event.detail;
|
|
115
|
+
const isOwnEvent = detail?.copyId === LIBRARY_COPY_ID;
|
|
116
|
+
if (!detail || isOwnEvent) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (detail.isSignedIn) {
|
|
120
|
+
restoreSession();
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
forgetAppliedBranches();
|
|
124
|
+
sessionTokenSignal.value = ConstValue.EMPTY;
|
|
125
|
+
authUserSignal.value = null;
|
|
126
|
+
}
|
|
127
|
+
/** Starts following the session events of the other library copies (once; called by SharedWebUiProvider). */
|
|
128
|
+
export function startSessionSync() {
|
|
129
|
+
const hasWindow = typeof window !== "undefined";
|
|
130
|
+
if (!hasWindow || isSessionSyncStarted) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
isSessionSyncStarted = true;
|
|
134
|
+
window.addEventListener(SESSION_EVENT, handleSessionEvent);
|
|
135
|
+
}
|
|
136
|
+
//# sourceMappingURL=auth-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-service.js","sourceRoot":"","sources":["../../src/state/auth-service.ts"],"names":[],"mappings":"AAAA,kBAAkB;AAClB,kEAAkE;AAClE,EAAE;AACF,uGAAuG;AACvG,+HAA+H;AAC/H,4DAA4D;AAC5D,kFAAkF;AAClF,8FAA8F;AAC9F,EAAE;AACF,kHAAkH;AAClH,2HAA2H;AAE3H,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAEtC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACnG,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,CAAC;AACvC,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAC;AAEvC,mCAAmC;AACnC,M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CAAC;AAED,6GAA6G;AAC7G,MAAM,UAAU,gBAAgB;IAC9B,MAAM,SAAS,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC;IAChD,IAAI,CAAC,SAAS,IAAI,oBAAoB,EAAE,CAAC;QACvC,OAAO;IACT,CAAC;IACD,oBAAoB,GAAG,IAAI,CAAC;IAC5B,MAAM,CAAC,gBAAgB,CAAC,aAAa,EAAE,kBAAkB,CAAC,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { MouseEvent } from "react";
|
|
2
|
+
import type { BranchOption, BranchRowType, BranchSource } from "../interfaces/app-types.js";
|
|
3
|
+
/** Selected branch id, or "". */
|
|
4
|
+
export declare const branchIdSignal: import("@preact/signals-core").Signal<string>;
|
|
5
|
+
/** Selected branch name, or "". */
|
|
6
|
+
export declare const branchNameSignal: import("@preact/signals-core").Signal<string>;
|
|
7
|
+
/** Selects a branch: saved in AppStorage and sent as x-branch-id from the next request on. */
|
|
8
|
+
export declare function setBranch(branchId: string, branchName?: string): void;
|
|
9
|
+
/** The selected branch id from AppStorage ("" when none). */
|
|
10
|
+
export declare function readBranchId(): string;
|
|
11
|
+
/** Removes the selected branch. */
|
|
12
|
+
export declare function clearBranch(): void;
|
|
13
|
+
/** Reads the saved branch into the signals (after a refresh). Called with restoreSession(). */
|
|
14
|
+
export declare function restoreBranch(): void;
|
|
15
|
+
/** Branches offered by the switcher ([] = no switcher). */
|
|
16
|
+
export declare const branchesSignal: import("@preact/signals-core").Signal<BranchOption[]>;
|
|
17
|
+
/** Reads the branch list from the backend reply ({ data: [...] }) or returns the list itself. */
|
|
18
|
+
export declare function readBranchRows(source: BranchSource | null | undefined): BranchRowType[];
|
|
19
|
+
/** Sort compare: lower priority first. Same priority keeps the backend order. */
|
|
20
|
+
export declare function compareBranchPriority(first: BranchRowType, second: BranchRowType): number;
|
|
21
|
+
/** One row as a switcher option, or null when it has no id. */
|
|
22
|
+
export declare function toBranchOption(row: BranchRowType): BranchOption | null;
|
|
23
|
+
/** Backend branches -> switcher options (active ones, sorted by priority). */
|
|
24
|
+
export declare function toBranchOptions(source: BranchSource | null | undefined): BranchOption[];
|
|
25
|
+
/** The branch with this id that can be selected (not disabled), or undefined. */
|
|
26
|
+
export declare function findSelectableBranch(branches: BranchOption[], branchId: string | undefined): BranchOption | undefined;
|
|
27
|
+
/** The branch with this id, or undefined. */
|
|
28
|
+
export declare function findBranch(branches: BranchOption[], branchId: string | undefined): BranchOption | undefined;
|
|
29
|
+
/** Which branch to select for a new list: saved -> isDefault -> first (disabled branches are skipped). */
|
|
30
|
+
export declare function pickBranch(branches: BranchOption[], savedBranchId: string): BranchOption | undefined;
|
|
31
|
+
/** Shows the branches in the switcher and selects one (see the order above). */
|
|
32
|
+
export declare function setBranches(source: BranchSource | null | undefined): void;
|
|
33
|
+
/**
|
|
34
|
+
* Used by the config loaders (and tests). Applies the value only when it changed.
|
|
35
|
+
* undefined leaves the branches alone; null or [] hides the switcher.
|
|
36
|
+
*/
|
|
37
|
+
export declare function registerBranches(source: BranchSource | null | undefined): void;
|
|
38
|
+
/** Forgets the applied list so the next registerBranches() applies it again (after log out / config change). */
|
|
39
|
+
export declare function forgetAppliedBranches(): void;
|
|
40
|
+
/** Switcher buttons carry the branch id in data-value. A disabled branch is ignored. */
|
|
41
|
+
export declare function handleBranchSelect(event: MouseEvent<HTMLElement>): void;
|
|
42
|
+
//# sourceMappingURL=branch-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"branch-service.d.ts","sourceRoot":"","sources":["../../src/state/branch-service.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACxC,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAK5F,iCAAiC;AACjC,eAAO,MAAM,cAAc,+CAAmC,CAAC;AAE/D,mCAAmC;AACnC,eAAO,MAAM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GAAG,IAAI,CAiBzE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,YAAY,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,CAK9E;AAED,gHAAgH;AAChH,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C;AAED,wFAAwF;AACxF,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,IAAI,CAWvE"}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
// branch-service.ts
|
|
2
|
+
// The selected branch (store). AppHttp sends its id as the "x-branch-id" header on every request.
|
|
3
|
+
//
|
|
4
|
+
// setBranch(branch.id, branch.name); // after the user picks a branch (saved in AppStorage BRANCH_ID / BRANCH_NAME)
|
|
5
|
+
// branchIdSignal.value // current id, "" when none (re-renders components)
|
|
6
|
+
// clearBranch(); // no branch (endSession() clears it too)
|
|
7
|
+
// config.loadBranches: "/app-api/branches" // the provider calls it after sign in
|
|
8
|
+
import { signal } from "@preact/signals-react";
|
|
9
|
+
import { ConstValue } from "dff-util";
|
|
10
|
+
import { AppStorage } from "../utils/app-storage.js";
|
|
11
|
+
import { readDataValue } from "../utils/event-util.js";
|
|
12
|
+
import { BRANCH_ID, BRANCH_NAME } from "../utils/storage-keys.js";
|
|
13
|
+
/** Selected branch id, or "". */
|
|
14
|
+
export const branchIdSignal = signal(ConstValue.EMPTY);
|
|
15
|
+
/** Selected branch name, or "". */
|
|
16
|
+
export const branchNameSignal = signal(ConstValue.EMPTY);
|
|
17
|
+
/** Selects a branch: saved in AppStorage and sent as x-branch-id from the next request on. */
|
|
18
|
+
export function setBranch(branchId, branchName = ConstValue.EMPTY) {
|
|
19
|
+
AppStorage.setData(BRANCH_ID, branchId);
|
|
20
|
+
AppStorage.setData(BRANCH_NAME, branchName);
|
|
21
|
+
branchIdSignal.value = branchId;
|
|
22
|
+
branchNameSignal.value = branchName;
|
|
23
|
+
}
|
|
24
|
+
/** The selected branch id from AppStorage ("" when none). */
|
|
25
|
+
export function readBranchId() {
|
|
26
|
+
return AppStorage.getText(BRANCH_ID);
|
|
27
|
+
}
|
|
28
|
+
/** Removes the selected branch. */
|
|
29
|
+
export function clearBranch() {
|
|
30
|
+
AppStorage.removeData(BRANCH_ID);
|
|
31
|
+
AppStorage.removeData(BRANCH_NAME);
|
|
32
|
+
branchIdSignal.value = ConstValue.EMPTY;
|
|
33
|
+
branchNameSignal.value = ConstValue.EMPTY;
|
|
34
|
+
}
|
|
35
|
+
/** Reads the saved branch into the signals (after a refresh). Called with restoreSession(). */
|
|
36
|
+
export function restoreBranch() {
|
|
37
|
+
branchIdSignal.value = AppStorage.getText(BRANCH_ID);
|
|
38
|
+
branchNameSignal.value = AppStorage.getText(BRANCH_NAME);
|
|
39
|
+
}
|
|
40
|
+
// ---- Branch list (the switcher) ----
|
|
41
|
+
//
|
|
42
|
+
// config.loadBranches (the provider calls it after sign in)
|
|
43
|
+
// setBranches(branchReply); // the same without the provider (for example before the menu request)
|
|
44
|
+
//
|
|
45
|
+
// Which branch is selected when the list arrives (disabled branches are never selected):
|
|
46
|
+
// 1. the saved branch (BRANCH_ID), if it is in the list
|
|
47
|
+
// 2. the row marked isDefault / default
|
|
48
|
+
// 3. the first branch
|
|
49
|
+
// Rows with disabled: true are shown greyed out and can not be picked. An empty list or null shows no switcher.
|
|
50
|
+
/** Branches offered by the switcher ([] = no switcher). */
|
|
51
|
+
export const branchesSignal = signal([]);
|
|
52
|
+
let appliedBranchSource = undefined;
|
|
53
|
+
/** Reads the branch list from the backend reply ({ data: [...] }) or returns the list itself. */
|
|
54
|
+
export function readBranchRows(source) {
|
|
55
|
+
if (!source) {
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
58
|
+
const isList = Array.isArray(source);
|
|
59
|
+
if (isList) {
|
|
60
|
+
return source;
|
|
61
|
+
}
|
|
62
|
+
return source.data ?? [];
|
|
63
|
+
}
|
|
64
|
+
/** Sort compare: lower priority first. Same priority keeps the backend order. */
|
|
65
|
+
export function compareBranchPriority(first, second) {
|
|
66
|
+
const firstPriority = first.priority ?? Number.MAX_SAFE_INTEGER;
|
|
67
|
+
const secondPriority = second.priority ?? Number.MAX_SAFE_INTEGER;
|
|
68
|
+
return firstPriority - secondPriority;
|
|
69
|
+
}
|
|
70
|
+
/** One row as a switcher option, or null when it has no id. */
|
|
71
|
+
export function toBranchOption(row) {
|
|
72
|
+
const id = row.id ?? row.branchId ?? row.code ?? ConstValue.EMPTY;
|
|
73
|
+
if (!id) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
const name = row.name ?? row.branchName ?? row.label ?? id;
|
|
77
|
+
const isDefault = Boolean(row.isDefault ?? row.default);
|
|
78
|
+
const isDisabled = Boolean(row.disabled ?? row.isDisabled);
|
|
79
|
+
return { id: id, name: name, nameLang: row.nameLang, isDefault: isDefault, isDisabled: isDisabled };
|
|
80
|
+
}
|
|
81
|
+
/** Backend branches -> switcher options (active ones, sorted by priority). */
|
|
82
|
+
export function toBranchOptions(source) {
|
|
83
|
+
const rows = readBranchRows(source);
|
|
84
|
+
const activeRows = [];
|
|
85
|
+
for (const row of rows) {
|
|
86
|
+
if (row.active !== false) {
|
|
87
|
+
activeRows.push(row);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
activeRows.sort(compareBranchPriority);
|
|
91
|
+
const options = [];
|
|
92
|
+
for (const row of activeRows) {
|
|
93
|
+
const option = toBranchOption(row);
|
|
94
|
+
if (option) {
|
|
95
|
+
options.push(option);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return options;
|
|
99
|
+
}
|
|
100
|
+
/** The branch with this id that can be selected (not disabled), or undefined. */
|
|
101
|
+
export function findSelectableBranch(branches, branchId) {
|
|
102
|
+
const branch = findBranch(branches, branchId);
|
|
103
|
+
return branch && !branch.isDisabled ? branch : undefined;
|
|
104
|
+
}
|
|
105
|
+
/** The branch with this id, or undefined. */
|
|
106
|
+
export function findBranch(branches, branchId) {
|
|
107
|
+
if (!branchId) {
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
for (const branch of branches) {
|
|
111
|
+
if (branch.id === branchId) {
|
|
112
|
+
return branch;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
117
|
+
/** The first selectable branch marked isDefault, or undefined. */
|
|
118
|
+
function findMarkedDefaultBranch(branches) {
|
|
119
|
+
for (const branch of branches) {
|
|
120
|
+
if (branch.isDefault && !branch.isDisabled) {
|
|
121
|
+
return branch;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
126
|
+
/** The first branch that is not disabled, or undefined. */
|
|
127
|
+
function findFirstSelectableBranch(branches) {
|
|
128
|
+
for (const branch of branches) {
|
|
129
|
+
if (!branch.isDisabled) {
|
|
130
|
+
return branch;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
/** Which branch to select for a new list: saved -> isDefault -> first (disabled branches are skipped). */
|
|
136
|
+
export function pickBranch(branches, savedBranchId) {
|
|
137
|
+
const savedBranch = findSelectableBranch(branches, savedBranchId);
|
|
138
|
+
if (savedBranch) {
|
|
139
|
+
return savedBranch;
|
|
140
|
+
}
|
|
141
|
+
const markedDefault = findMarkedDefaultBranch(branches);
|
|
142
|
+
if (markedDefault) {
|
|
143
|
+
return markedDefault;
|
|
144
|
+
}
|
|
145
|
+
return findFirstSelectableBranch(branches);
|
|
146
|
+
}
|
|
147
|
+
/** Shows the branches in the switcher and selects one (see the order above). */
|
|
148
|
+
export function setBranches(source) {
|
|
149
|
+
appliedBranchSource = source;
|
|
150
|
+
const branches = toBranchOptions(source);
|
|
151
|
+
branchesSignal.value = branches;
|
|
152
|
+
if (branches.length === 0) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const savedBranchId = readBranchId();
|
|
156
|
+
const branch = pickBranch(branches, savedBranchId);
|
|
157
|
+
if (!branch) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
const savedBranchName = branchNameSignal.peek();
|
|
161
|
+
const isAlreadySelected = branch.id === savedBranchId && branch.name === savedBranchName;
|
|
162
|
+
if (!isAlreadySelected) {
|
|
163
|
+
setBranch(branch.id, branch.name);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Used by the config loaders (and tests). Applies the value only when it changed.
|
|
168
|
+
* undefined leaves the branches alone; null or [] hides the switcher.
|
|
169
|
+
*/
|
|
170
|
+
export function registerBranches(source) {
|
|
171
|
+
if (source === undefined || source === appliedBranchSource) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
setBranches(source);
|
|
175
|
+
}
|
|
176
|
+
/** Forgets the applied list so the next registerBranches() applies it again (after log out / config change). */
|
|
177
|
+
export function forgetAppliedBranches() {
|
|
178
|
+
appliedBranchSource = undefined;
|
|
179
|
+
}
|
|
180
|
+
/** Switcher buttons carry the branch id in data-value. A disabled branch is ignored. */
|
|
181
|
+
export function handleBranchSelect(event) {
|
|
182
|
+
const branchId = readDataValue(event);
|
|
183
|
+
const branch = findSelectableBranch(branchesSignal.value, branchId);
|
|
184
|
+
if (!branch) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
setBranch(branch.id, branch.name);
|
|
188
|
+
const activeElement = document.activeElement;
|
|
189
|
+
if (activeElement instanceof HTMLElement) {
|
|
190
|
+
activeElement.blur();
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
//# sourceMappingURL=branch-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"branch-service.js","sourceRoot":"","sources":["../../src/state/branch-service.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,kGAAkG;AAClG,EAAE;AACF,wHAAwH;AACxH,6FAA6F;AAC7F,mFAAmF;AACnF,qFAAqF;AAErF,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CA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SAAS,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IAClC,MAAM,aAAa,GAAG,QAAQ,CAAC,aAAa,CAAC;IAC7C,IAAI,aAAa,YAAY,WAAW,EAAE,CAAC;QACzC,aAAa,CAAC,IAAI,EAAE,CAAC;IACvB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CompanyDetails, CompanySource, UiConfig } from "../interfaces/ui-config.js";
|
|
2
|
+
/** Reads the company details from a reply ({...} or { data: {...} }); empty or unknown values are left out. */
|
|
3
|
+
export declare function readCompanyDetails(reply: unknown): CompanyDetails | null;
|
|
4
|
+
/**
|
|
5
|
+
* Sets the company details (the backend reply as it is: {...} or { data: {...} }); null = none (config values).
|
|
6
|
+
* The brand (logo, app name) updates at once; faviconUrl and appName also go to the browser tab.
|
|
7
|
+
*/
|
|
8
|
+
export declare function setCompanyDetails(reply: CompanySource | unknown): void;
|
|
9
|
+
/** true while config.loadCompanyDetails has not answered yet (no reply, and no config.appName to show meanwhile). */
|
|
10
|
+
export declare function isCompanyPending(config: UiConfig, details: CompanyDetails | null): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* The app label: company appName, else config.appName, else config.appNameKey (shown with t()).
|
|
13
|
+
* "" while the company details are still loading (so the app key does not flash before the real name).
|
|
14
|
+
*/
|
|
15
|
+
export declare function readAppNameLabel(config: UiConfig, details: CompanyDetails | null): string;
|
|
16
|
+
//# sourceMappingURL=company-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"company-service.d.ts","sourceRoot":"","sources":["../../src/state/company-service.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAqB1F,+GAA+G;AAC/G,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,GAAG,IAAI,CAcxE;AA2BD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,GAAG,IAAI,CAItE;AAED,qHAAqH;AACrH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,cAAc,GAAG,IAAI,GAAG,OAAO,CAG1F;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,cAAc,GAAG,IAAI,GAAG,MAAM,CASzF"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// company-service.ts
|
|
2
|
+
// Company / brand details from the backend (config.loadCompanyDetails, or setCompanyDetails by hand):
|
|
3
|
+
//
|
|
4
|
+
// { "appName": "YourAppName", "companyName": "YourBrandName",
|
|
5
|
+
// "faviconUrl": "https://www.w3.org/favicon.ico", "logoUrl": "https://www.w3.org/Icons/w3c_home.png",
|
|
6
|
+
// "logoDarkUrl": "https://www.w3.org/Icons/w3c_home.png" }
|
|
7
|
+
//
|
|
8
|
+
// appName header / sidebar / login label and the browser tab title (wins over config.appName)
|
|
9
|
+
// companyName alt text of the logo; read companyDetailsSignal to show it anywhere (a footer, the login page)
|
|
10
|
+
// faviconUrl <link rel="icon" href="...">
|
|
11
|
+
// logoUrl the logo on light themes, and on dark themes without logoDarkUrl (wins over config.logoUrl / logoDarkUrl)
|
|
12
|
+
// logoDarkUrl the logo on dark themes (wins over config.logoDarkUrl)
|
|
13
|
+
// A reply may also be { data: {...} }. A missing field keeps the config value.
|
|
14
|
+
import { companyDetailsSignal } from "./signals.js";
|
|
15
|
+
/** The fields of CompanyDetails (only text values are kept). */
|
|
16
|
+
const COMPANY_FIELDS = ["appName", "companyName", "faviconUrl", "logoUrl", "logoDarkUrl"];
|
|
17
|
+
/** true for a plain object (not null, not a list). */
|
|
18
|
+
function isPlainObject(value) {
|
|
19
|
+
const isObject = typeof value === "object" && value !== null;
|
|
20
|
+
return isObject && !Array.isArray(value);
|
|
21
|
+
}
|
|
22
|
+
/** The details inside a reply: the object itself, or its "data" object. */
|
|
23
|
+
function unwrapCompanyReply(reply) {
|
|
24
|
+
if (!isPlainObject(reply)) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
const data = reply.data;
|
|
28
|
+
return isPlainObject(data) ? data : reply;
|
|
29
|
+
}
|
|
30
|
+
/** Reads the company details from a reply ({...} or { data: {...} }); empty or unknown values are left out. */
|
|
31
|
+
export function readCompanyDetails(reply) {
|
|
32
|
+
const source = unwrapCompanyReply(reply);
|
|
33
|
+
if (!source) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
const details = {};
|
|
37
|
+
for (const field of COMPANY_FIELDS) {
|
|
38
|
+
const value = source[field];
|
|
39
|
+
const isText = typeof value === "string" && value !== "";
|
|
40
|
+
if (isText) {
|
|
41
|
+
details[field] = value;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return details;
|
|
45
|
+
}
|
|
46
|
+
/** Points <link rel="icon"> at the favicon URL (created when the page has none). */
|
|
47
|
+
function writeFavicon(faviconUrl) {
|
|
48
|
+
let iconElement = document.querySelector('link[rel~="icon"]');
|
|
49
|
+
if (!iconElement) {
|
|
50
|
+
iconElement = document.createElement("link");
|
|
51
|
+
iconElement.rel = "icon";
|
|
52
|
+
document.head.append(iconElement);
|
|
53
|
+
}
|
|
54
|
+
iconElement.href = faviconUrl;
|
|
55
|
+
}
|
|
56
|
+
/** Writes the favicon and the tab title of the company details (fields that are missing are left alone). */
|
|
57
|
+
function applyCompanyToDocument(details) {
|
|
58
|
+
const hasDocument = typeof document !== "undefined";
|
|
59
|
+
if (!hasDocument || !details) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (details.faviconUrl) {
|
|
63
|
+
writeFavicon(details.faviconUrl);
|
|
64
|
+
}
|
|
65
|
+
if (details.appName) {
|
|
66
|
+
document.title = details.appName;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Sets the company details (the backend reply as it is: {...} or { data: {...} }); null = none (config values).
|
|
71
|
+
* The brand (logo, app name) updates at once; faviconUrl and appName also go to the browser tab.
|
|
72
|
+
*/
|
|
73
|
+
export function setCompanyDetails(reply) {
|
|
74
|
+
const details = readCompanyDetails(reply);
|
|
75
|
+
companyDetailsSignal.value = details;
|
|
76
|
+
applyCompanyToDocument(details);
|
|
77
|
+
}
|
|
78
|
+
/** true while config.loadCompanyDetails has not answered yet (no reply, and no config.appName to show meanwhile). */
|
|
79
|
+
export function isCompanyPending(config, details) {
|
|
80
|
+
const hasCompanySource = Boolean(config.loadCompanyDetails);
|
|
81
|
+
return hasCompanySource && !details && !config.appName;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The app label: company appName, else config.appName, else config.appNameKey (shown with t()).
|
|
85
|
+
* "" while the company details are still loading (so the app key does not flash before the real name).
|
|
86
|
+
*/
|
|
87
|
+
export function readAppNameLabel(config, details) {
|
|
88
|
+
if (details?.appName) {
|
|
89
|
+
return details.appName;
|
|
90
|
+
}
|
|
91
|
+
const isPending = isCompanyPending(config, details);
|
|
92
|
+
if (isPending) {
|
|
93
|
+
return "";
|
|
94
|
+
}
|
|
95
|
+
return config.appName ?? config.appNameKey;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=company-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"company-service.js","sourceRoot":"","sources":["../../src/state/company-service.ts"],"names":[],"mappings":"AAAA,qBAAqB;AACrB,sGAAsG;AACtG,EAAE;AACF,gEAAgE;AAChE,0GAA0G;AAC1G,+DAA+D;AAC/D,EAAE;AACF,qGAAqG;AACrG,gHAAgH;AAChH,8CAA8C;AAC9C,2HAA2H;AAC3H,wEAAwE;AACxE,+EAA+E;AAG/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD,gEAAgE;AAChE,MAAM,cAAc,GAAgC,CAAC,SAAS,EAAE,aAAa,EAAE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M,SAAS,GAAG,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpD,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,OAAO,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,UAAU,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Writes the current theme, language and direction to <html>. */
|
|
2
|
+
export declare function applyDocumentAttributes(): void;
|
|
3
|
+
/** Starts the automatic sync. Safe to call many times: it only starts once. */
|
|
4
|
+
export declare function startDocumentSync(): void;
|
|
5
|
+
/** Stops the automatic sync (used by tests). */
|
|
6
|
+
export declare function stopDocumentSyncForTests(): void;
|
|
7
|
+
//# sourceMappingURL=document-sync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-sync.d.ts","sourceRoot":"","sources":["../../src/state/document-sync.ts"],"names":[],"mappings":"AAUA,kEAAkE;AAClE,wBAAgB,uBAAuB,IAAI,IAAI,CAc9C;AAED,+EAA+E;AAC/E,wBAAgB,iBAAiB,IAAI,IAAI,CAKxC;AAED,gDAAgD;AAChD,wBAAgB,wBAAwB,IAAI,IAAI,CAM/C"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// document-sync.ts
|
|
2
|
+
// Keeps the <html> element in sync with the signals:
|
|
3
|
+
// <html lang="ar" dir="rtl" data-theme="dark">
|
|
4
|
+
// Uses a signals effect, so it updates automatically whenever a signal changes.
|
|
5
|
+
import { effect } from "@preact/signals-react";
|
|
6
|
+
import { directionSignal, localeSignal, themeSignal } from "./signals.js";
|
|
7
|
+
let stopDocumentSync = null;
|
|
8
|
+
/** Writes the current theme, language and direction to <html>. */
|
|
9
|
+
export function applyDocumentAttributes() {
|
|
10
|
+
const theme = themeSignal.value;
|
|
11
|
+
const languageCode = localeSignal.value;
|
|
12
|
+
const direction = directionSignal.value;
|
|
13
|
+
const hasDocument = typeof document !== "undefined";
|
|
14
|
+
if (!hasDocument) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const htmlElement = document.documentElement;
|
|
18
|
+
htmlElement.setAttribute("data-theme", theme);
|
|
19
|
+
htmlElement.setAttribute("dir", direction);
|
|
20
|
+
if (languageCode) {
|
|
21
|
+
htmlElement.lang = languageCode;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/** Starts the automatic sync. Safe to call many times: it only starts once. */
|
|
25
|
+
export function startDocumentSync() {
|
|
26
|
+
if (stopDocumentSync) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
stopDocumentSync = effect(applyDocumentAttributes);
|
|
30
|
+
}
|
|
31
|
+
/** Stops the automatic sync (used by tests). */
|
|
32
|
+
export function stopDocumentSyncForTests() {
|
|
33
|
+
if (!stopDocumentSync) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
stopDocumentSync();
|
|
37
|
+
stopDocumentSync = null;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=document-sync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document-sync.js","sourceRoot":"","sources":["../../src/state/document-sync.ts"],"names":[],"mappings":"AAAA,mBAAmB;AACnB,qDAAqD;AACrD,iDAAiD;AACjD,gFAAgF;AAEhF,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE1E,IAAI,gBAAgB,GAAwB,IAAI,CAAC;AAEjD,kEAAkE;AAClE,MAAM,UAAU,uBAAuB;IACrC,MAAM,KAAK,GAAG,WAAW,CAAC,KAAK,CAAC;IAChC,MAAM,YAAY,GAAG,YAAY,CAAC,KAAK,CAAC;IACxC,MAAM,SAAS,GAAG,eAAe,CAAC,KAAK,CAAC;IACxC,MAAM,WAAW,GAAG,OAAO,QAAQ,KAAK,WAAW,CAAC;IACpD,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO;IACT,CAAC;IACD,MAAM,WAAW,GAAG,QAAQ,CAAC,eAAe,CAAC;IAC7C,WAAW,CAAC,YAAY,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;IAC9C,WAAW,CAAC,YAAY,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAC3C,IAAI,YAAY,EAAE,CAAC;QACjB,WAAW,CAAC,IAAI,GAAG,YAAY,CAAC;IAClC,CAAC;AACH,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,iBAAiB;IAC/B,IAAI,gBAAgB,EAAE,CAAC;QACrB,OAAO;IACT,CAAC;IACD,gBAAgB,GAAG,MAAM,CAAC,uBAAuB,CAAC,CAAC;AACrD,CAAC;AAED,gDAAgD;AAChD,MAAM,UAAU,wBAAwB;IACtC,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,OAAO;IACT,CAAC;IACD,gBAAgB,EAAE,CAAC;IACnB,gBAAgB,GAAG,IAAI,CAAC;AAC1B,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { LangSource } from "../interfaces/app-types.js";
|
|
2
|
+
/** true when the code is in the current language list. */
|
|
3
|
+
export declare function isLanguageListed(languageCode: string | undefined): boolean;
|
|
4
|
+
/**
|
|
5
|
+
* The language to switch to after a new list (when the user did not pick one): the backend isDefault,
|
|
6
|
+
* config.defaultLanguage, the browser / system language, "en-US", or the first one.
|
|
7
|
+
*/
|
|
8
|
+
export declare function readLanguageAfterUpdate(source: LangSource): string | undefined;
|
|
9
|
+
/** Shows the backend languages in the switchers and TypeLang, and switches language when needed. */
|
|
10
|
+
export declare function setLanguages(source: LangSource): void;
|
|
11
|
+
/**
|
|
12
|
+
* Used by the config loaders (and tests). Applies the value only when it changed.
|
|
13
|
+
* undefined / null -> keep config.languages (or no list yet); texts of config.defaultLanguage still load
|
|
14
|
+
* reply / list -> show it (a new reply replaces the list)
|
|
15
|
+
*/
|
|
16
|
+
export declare function registerLanguages(source: LangSource | null | undefined): void;
|
|
17
|
+
/** Forgets the applied reply so the next registerLanguages() applies it again (used when the config changes). */
|
|
18
|
+
export declare function forgetAppliedLanguages(): void;
|
|
19
|
+
//# sourceMappingURL=language-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"language-service.d.ts","sourceRoot":"","sources":["../../src/state/language-service.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAQ7D,0DAA0D;AAC1D,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAO1E;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,CAqB9E;AAED,oGAAoG;AACpG,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,CAQrD;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,CAK7E;AAED,iHAAiH;AACjH,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C"}
|