shared-lib-web 0.0.0-stage → 0.0.2
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 +630 -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 +23 -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 +19 -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 +8 -0
- package/dist/components/language-switcher.d.ts.map +1 -0
- package/dist/components/language-switcher.js +48 -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 +17 -0
- package/dist/components/settings-menu.d.ts.map +1 -0
- package/dist/components/settings-menu.js +102 -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 +39 -0
- package/dist/context/use-ui.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 +64 -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-service.d.ts +36 -0
- package/dist/i18n/locale-service.d.ts.map +1 -0
- package/dist/i18n/locale-service.js +163 -0
- package/dist/i18n/locale-service.js.map +1 -0
- package/dist/i18n/translator.d.ts +14 -0
- package/dist/i18n/translator.d.ts.map +1 -0
- package/dist/i18n/translator.js +81 -0
- package/dist/i18n/translator.js.map +1 -0
- package/dist/index.d.ts +106 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +119 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/app-types.d.ts +137 -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 +172 -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 +26 -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 +28 -0
- package/dist/providers/register-config.js.map +1 -0
- package/dist/providers/shared-web-ui-provider.d.ts +31 -0
- package/dist/providers/shared-web-ui-provider.d.ts.map +1 -0
- package/dist/providers/shared-web-ui-provider.js +54 -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 +63 -0
- package/dist/query/query-param.d.ts.map +1 -0
- package/dist/query/query-param.js +215 -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/auth-service.d.ts +28 -0
- package/dist/state/auth-service.d.ts.map +1 -0
- package/dist/state/auth-service.js +92 -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/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 +16 -0
- package/dist/state/language-service.d.ts.map +1 -0
- package/dist/state/language-service.js +73 -0
- package/dist/state/language-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 +85 -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 +84 -0
- package/dist/state/signals.d.ts.map +1 -0
- package/dist/state/signals.js +137 -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/dark-themes.d.ts +2 -0
- package/dist/theme/dark-themes.d.ts.map +1 -0
- package/dist/theme/dark-themes.js +20 -0
- package/dist/theme/dark-themes.js.map +1 -0
- package/dist/theme/logo.d.ts +4 -0
- package/dist/theme/logo.d.ts.map +1 -0
- package/dist/theme/logo.js +10 -0
- package/dist/theme/logo.js.map +1 -0
- package/dist/theme/theme-service.d.ts +21 -0
- package/dist/theme/theme-service.d.ts.map +1 -0
- package/dist/theme/theme-service.js +69 -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 +49 -0
- package/dist/utils/app-http.d.ts.map +1 -0
- package/dist/utils/app-http.js +229 -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/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/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/storage-keys.d.ts +68 -0
- package/dist/utils/storage-keys.d.ts.map +1 -0
- package/dist/utils/storage-keys.js +75 -0
- package/dist/utils/storage-keys.js.map +1 -0
- package/package.json +101 -4
- package/src/components/app-brand.tsx +37 -0
- package/src/components/branch-switcher.tsx +74 -0
- package/src/components/coming-soon.tsx +35 -0
- package/src/components/empty-state.tsx +42 -0
- package/src/components/language-switcher.tsx +77 -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 +224 -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 +42 -0
- package/src/i18n/default-messages.ts +67 -0
- package/src/i18n/direction.ts +43 -0
- package/src/i18n/locale-service.ts +187 -0
- package/src/i18n/translator.ts +88 -0
- package/src/index.ts +341 -0
- package/src/interfaces/app-types.ts +154 -0
- package/src/interfaces/toast.ts +12 -0
- package/src/interfaces/ui-config.ts +189 -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 +30 -0
- package/src/providers/register-config.ts +30 -0
- package/src/providers/shared-web-ui-provider.tsx +98 -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 +263 -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/auth-service.ts +104 -0
- package/src/state/branch-service.ts +217 -0
- package/src/state/document-sync.ts +43 -0
- package/src/state/language-service.ts +80 -0
- package/src/state/menu-service.ts +67 -0
- package/src/state/navigation-service.ts +160 -0
- package/src/state/preference-sync.ts +93 -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 +183 -0
- package/src/state/toast-service.ts +45 -0
- package/src/styles.css +15 -0
- package/src/theme/dark-themes.ts +20 -0
- package/src/theme/logo.ts +12 -0
- package/src/theme/theme-service.ts +82 -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 +255 -0
- package/src/utils/app-storage.ts +259 -0
- package/src/utils/crypto-util.ts +88 -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/storage-keys.ts +80 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// type.mdv.tsx
|
|
2
|
+
// TypeMdv: markdown VIEWER. Shows markdown text as formatted content. Follows light/dark themes.
|
|
3
|
+
// Import from "shared-lib-web/markdown".
|
|
4
|
+
//
|
|
5
|
+
// <TypeMdv text={post.content} />
|
|
6
|
+
// <TypeMdv textByLanguage={post.contentLang} text={post.content} /> // picks the current language
|
|
7
|
+
|
|
8
|
+
import MDEditor from "@uiw/react-md-editor";
|
|
9
|
+
import { useUi } from "../context/use-ui.ts";
|
|
10
|
+
import { joinClassNames } from "./class-names.ts";
|
|
11
|
+
import { trans, type TranslationRecord } from "../utils/lang-util.ts";
|
|
12
|
+
import { MARKDOWN_SURFACE_STYLE, readMarkdownColorMode } from "./markdown-color-mode.ts";
|
|
13
|
+
|
|
14
|
+
export interface TypeMdvProps {
|
|
15
|
+
/** Markdown text (also the fallback when textByLanguage has no text for the current language). */
|
|
16
|
+
text?: string;
|
|
17
|
+
/** Markdown per language: { en: "...", fr: "..." }. */
|
|
18
|
+
textByLanguage?: TranslationRecord;
|
|
19
|
+
className?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function TypeMdv(props: TypeMdvProps) {
|
|
23
|
+
const { text = "", textByLanguage, className } = props;
|
|
24
|
+
useUi();
|
|
25
|
+
const colorMode = readMarkdownColorMode();
|
|
26
|
+
const source = trans(textByLanguage, text);
|
|
27
|
+
const classList = ["rounded-box", className];
|
|
28
|
+
const wrapperClassName = joinClassNames(classList);
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<div data-color-mode={colorMode} className={wrapperClassName}>
|
|
32
|
+
<MDEditor.Markdown source={source} style={MARKDOWN_SURFACE_STYLE} />
|
|
33
|
+
</div>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// type.mdx.tsx
|
|
2
|
+
// TypeMdx: markdown EDITOR (@uiw/react-md-editor) connected to react-hook-form. Follows light/dark themes.
|
|
3
|
+
// Import from "shared-lib-web/markdown" (needs the optional peer dependency @uiw/react-md-editor).
|
|
4
|
+
//
|
|
5
|
+
// <TypeMdx control={control} name="content" label={t("blog.content")} height={400} />
|
|
6
|
+
|
|
7
|
+
import MDEditor from "@uiw/react-md-editor";
|
|
8
|
+
import { ConstValue } from "dff-util";
|
|
9
|
+
import { useController, type FieldValues } from "react-hook-form";
|
|
10
|
+
import { useUi } from "../context/use-ui.ts";
|
|
11
|
+
import { joinClassNames } from "./class-names.ts";
|
|
12
|
+
import { readFieldErrorText } from "./field-error.ts";
|
|
13
|
+
import type { TypeFieldProps } from "./field-props.ts";
|
|
14
|
+
import { readMarkdownColorMode } from "./markdown-color-mode.ts";
|
|
15
|
+
|
|
16
|
+
export interface TypeMdxProps<TFieldValues extends FieldValues> extends TypeFieldProps<TFieldValues> {
|
|
17
|
+
/** Editor height in px. Default 300. */
|
|
18
|
+
height?: number;
|
|
19
|
+
/** "edit" (default), "live" (editor + preview) or "preview". */
|
|
20
|
+
preview?: "edit" | "live" | "preview";
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function TypeMdx<TFieldValues extends FieldValues>(props: TypeMdxProps<TFieldValues>) {
|
|
24
|
+
const { control, name, label, rules, error, hint, disabled, className, height = 300, preview = "edit" } = props;
|
|
25
|
+
const { t } = useUi();
|
|
26
|
+
const controllerOptions = { control: control, name: name, rules: rules, disabled: disabled };
|
|
27
|
+
const { field, fieldState } = useController(controllerOptions);
|
|
28
|
+
const fieldError = error ?? fieldState.error;
|
|
29
|
+
const errorText = readFieldErrorText(fieldError, t);
|
|
30
|
+
const colorMode = readMarkdownColorMode();
|
|
31
|
+
const value = field.value ?? ConstValue.EMPTY;
|
|
32
|
+
const textareaProps = { disabled: field.disabled, name: field.name, onBlur: field.onBlur };
|
|
33
|
+
const classList = ["fieldset", className];
|
|
34
|
+
const wrapperClassName = joinClassNames(classList);
|
|
35
|
+
const editorClassName = errorText ? "rounded-box ring-2 ring-error" : "rounded-box";
|
|
36
|
+
const messageText = errorText ?? hint;
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<fieldset className={wrapperClassName}>
|
|
40
|
+
<legend className="fieldset-legend">{label}</legend>
|
|
41
|
+
<div data-color-mode={colorMode} className={editorClassName}>
|
|
42
|
+
<MDEditor
|
|
43
|
+
value={value}
|
|
44
|
+
onChange={field.onChange}
|
|
45
|
+
height={height}
|
|
46
|
+
preview={preview}
|
|
47
|
+
visibleDragbar={false}
|
|
48
|
+
textareaProps={textareaProps}
|
|
49
|
+
/>
|
|
50
|
+
</div>
|
|
51
|
+
{messageText ? <p className={errorText ? "label text-error" : "label"}>{messageText}</p> : null}
|
|
52
|
+
</fieldset>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// type.modal.tsx
|
|
2
|
+
// DaisyUI modal. Closes with the ✕ button, a backdrop click or Escape.
|
|
3
|
+
//
|
|
4
|
+
// <TypeModal isOpen={isSettingsOpen.value} title={t("settings.title")} onClose={closeSettings} size="md"
|
|
5
|
+
// footer={<TypeButton label={t("save")} onPress={handleSave} />}>
|
|
6
|
+
// ...content...
|
|
7
|
+
// </TypeModal>
|
|
8
|
+
|
|
9
|
+
import type { MouseEventHandler, ReactNode } from "react";
|
|
10
|
+
import { createPortal } from "react-dom";
|
|
11
|
+
import { useUi } from "../context/use-ui.ts";
|
|
12
|
+
import { joinClassNames } from "./class-names.ts";
|
|
13
|
+
import { TypeButton } from "./type.button.tsx";
|
|
14
|
+
|
|
15
|
+
export type ModalSize = "sm" | "md" | "lg" | "xl" | "2xl" | "4xl" | "full";
|
|
16
|
+
|
|
17
|
+
export interface TypeModalProps {
|
|
18
|
+
isOpen: boolean;
|
|
19
|
+
/** Heading (already translated). */
|
|
20
|
+
title?: string;
|
|
21
|
+
onClose: MouseEventHandler<HTMLElement>;
|
|
22
|
+
children?: ReactNode;
|
|
23
|
+
/** Buttons at the bottom. */
|
|
24
|
+
footer?: ReactNode;
|
|
25
|
+
/** Width. Default "md". */
|
|
26
|
+
size?: ModalSize;
|
|
27
|
+
/** Hide the ✕ button. Escape and backdrop still close. */
|
|
28
|
+
isCloseHidden?: boolean;
|
|
29
|
+
className?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const MODAL_SIZE_CLASSES: Record<ModalSize, string> = {
|
|
33
|
+
sm: "max-w-sm",
|
|
34
|
+
md: "max-w-lg",
|
|
35
|
+
lg: "max-w-2xl",
|
|
36
|
+
xl: "max-w-4xl",
|
|
37
|
+
"2xl": "max-w-5xl",
|
|
38
|
+
"4xl": "max-w-7xl",
|
|
39
|
+
full: "max-w-[calc(100vw-2rem)] w-full",
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export function TypeModal(props: TypeModalProps) {
|
|
43
|
+
const { isOpen, title, onClose, children, footer, size = "md", isCloseHidden = false, className } = props;
|
|
44
|
+
const { t } = useUi();
|
|
45
|
+
if (!isOpen) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
const closeText = t("ui.close");
|
|
49
|
+
const sizeClass = MODAL_SIZE_CLASSES[size];
|
|
50
|
+
const boxClassList = ["modal-box outline-none", sizeClass, className];
|
|
51
|
+
const boxClassName = joinClassNames(boxClassList);
|
|
52
|
+
const closeButtonClassName = isCloseHidden ? "hidden" : "absolute end-2 top-2";
|
|
53
|
+
|
|
54
|
+
const overlay = (
|
|
55
|
+
<div className="modal modal-open" role="dialog" aria-modal="true" aria-label={title}>
|
|
56
|
+
<div className={boxClassName}>
|
|
57
|
+
<TypeButton
|
|
58
|
+
action="ghost"
|
|
59
|
+
size="sm"
|
|
60
|
+
icon="X"
|
|
61
|
+
label={closeText}
|
|
62
|
+
isIconOnly
|
|
63
|
+
isOverlayClose
|
|
64
|
+
autoFocus={!isCloseHidden}
|
|
65
|
+
className={`btn-circle ${closeButtonClassName}`}
|
|
66
|
+
onPress={onClose}
|
|
67
|
+
/>
|
|
68
|
+
{title ? <h3 className="pe-8 text-lg font-bold">{title}</h3> : null}
|
|
69
|
+
<div className="py-4">{children}</div>
|
|
70
|
+
{footer ? <div className="modal-action">{footer}</div> : null}
|
|
71
|
+
</div>
|
|
72
|
+
<button type="button" className="modal-backdrop" aria-label={closeText} onClick={onClose} />
|
|
73
|
+
</div>
|
|
74
|
+
);
|
|
75
|
+
// Rendered into <body> so a sticky or blurred parent (for example the header) can not clip it.
|
|
76
|
+
return createPortal(overlay, document.body);
|
|
77
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// type.otp.tsx
|
|
2
|
+
// One-time code input connected to react-hook-form.
|
|
3
|
+
// One real input (so paste, autofill and the keyboard work) drawn as separate boxes.
|
|
4
|
+
//
|
|
5
|
+
// <TypeOtp control={control} name="code" label={t("login.code")} length={6} rules={otpValidation} />
|
|
6
|
+
// const otpValidation = { required: { value: true, message: ConstKeys.REQUIRED },
|
|
7
|
+
// pattern: { value: RegExp.DIGITS_ONLY, message: ConstKeys.FIELD_MUST_BE_NUMERIC } };
|
|
8
|
+
|
|
9
|
+
import { ConstValue } from "dff-util";
|
|
10
|
+
import { useId, type ReactElement } from "react";
|
|
11
|
+
import { useController, type FieldValues } from "react-hook-form";
|
|
12
|
+
import { useUi } from "../context/use-ui.ts";
|
|
13
|
+
import { FieldWrapper, readMessageId } from "./field-wrapper.tsx";
|
|
14
|
+
import { joinClassNames } from "./class-names.ts";
|
|
15
|
+
import { readFieldErrorText } from "./field-error.ts";
|
|
16
|
+
import type { TypeFieldProps } from "./field-props.ts";
|
|
17
|
+
|
|
18
|
+
export interface TypeOtpProps<TFieldValues extends FieldValues> extends TypeFieldProps<TFieldValues> {
|
|
19
|
+
/** Number of characters. Default 6. */
|
|
20
|
+
length?: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Builds the boxes that show one character each. The box at the cursor is highlighted. */
|
|
24
|
+
function buildOtpBoxes(value: string, length: number, hasError: boolean): ReactElement[] {
|
|
25
|
+
const boxes: ReactElement[] = [];
|
|
26
|
+
for (let index = 0; index < length; index += 1) {
|
|
27
|
+
const character = value.charAt(index);
|
|
28
|
+
const isCurrent = index === value.length;
|
|
29
|
+
const classList = [
|
|
30
|
+
"flex size-11 items-center justify-center rounded-field border bg-base-100 text-lg font-semibold",
|
|
31
|
+
hasError ? "border-error" : "border-base-300",
|
|
32
|
+
isCurrent ? "peer-focus:border-primary peer-focus:ring-2 peer-focus:ring-primary/30" : "",
|
|
33
|
+
];
|
|
34
|
+
const boxClassName = joinClassNames(classList);
|
|
35
|
+
const box = (
|
|
36
|
+
<span key={index} className={boxClassName} aria-hidden="true">
|
|
37
|
+
{character}
|
|
38
|
+
</span>
|
|
39
|
+
);
|
|
40
|
+
boxes.push(box);
|
|
41
|
+
}
|
|
42
|
+
return boxes;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function TypeOtp<TFieldValues extends FieldValues>(props: TypeOtpProps<TFieldValues>) {
|
|
46
|
+
const { control, name, label, rules, error, hint, disabled, className, length = 6 } = props;
|
|
47
|
+
const { t } = useUi();
|
|
48
|
+
const inputId = useId();
|
|
49
|
+
const controllerOptions = { control: control, name: name, rules: rules, disabled: disabled };
|
|
50
|
+
const { field, fieldState } = useController(controllerOptions);
|
|
51
|
+
const fieldError = error ?? fieldState.error;
|
|
52
|
+
const errorText = readFieldErrorText(fieldError, t);
|
|
53
|
+
const hasError = Boolean(errorText);
|
|
54
|
+
const messageId = readMessageId(inputId);
|
|
55
|
+
const rawValue = field.value ?? ConstValue.EMPTY;
|
|
56
|
+
const value = String(rawValue);
|
|
57
|
+
const boxes = buildOtpBoxes(value, length, hasError);
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<FieldWrapper inputId={inputId} label={label} errorText={errorText} hint={hint} className={className}>
|
|
61
|
+
<div className="relative flex w-fit gap-2" dir="ltr">
|
|
62
|
+
<input
|
|
63
|
+
id={inputId}
|
|
64
|
+
ref={field.ref}
|
|
65
|
+
name={field.name}
|
|
66
|
+
type="text"
|
|
67
|
+
inputMode="numeric"
|
|
68
|
+
autoComplete="one-time-code"
|
|
69
|
+
maxLength={length}
|
|
70
|
+
value={value}
|
|
71
|
+
onChange={field.onChange}
|
|
72
|
+
onBlur={field.onBlur}
|
|
73
|
+
disabled={field.disabled}
|
|
74
|
+
className="peer absolute inset-0 z-10 w-full cursor-text opacity-0"
|
|
75
|
+
aria-invalid={hasError}
|
|
76
|
+
aria-describedby={errorText || hint ? messageId : undefined}
|
|
77
|
+
/>
|
|
78
|
+
{boxes}
|
|
79
|
+
</div>
|
|
80
|
+
</FieldWrapper>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// type.search.tsx
|
|
2
|
+
// Search box for list filters (not a form field).
|
|
3
|
+
// onChange runs on every key press (live filter)
|
|
4
|
+
// onSearch runs on Enter or the search button; read the text with readSearchText(event)
|
|
5
|
+
//
|
|
6
|
+
// <TypeSearch name="search" label={t("ui.search")} value={userSearchText.value} onChange={handleUserSearchChange} />
|
|
7
|
+
// <TypeSearch name="search" label={t("ui.search")} onSearch={handleUserSearchSubmit} />
|
|
8
|
+
// function handleUserSearchSubmit(event: FormEvent<HTMLFormElement>) { const text = readSearchText(event); ... }
|
|
9
|
+
|
|
10
|
+
import { ConstValue } from "dff-util";
|
|
11
|
+
import type { ChangeEventHandler, FormEvent, FormEventHandler } from "react";
|
|
12
|
+
import { useUi } from "../context/use-ui.ts";
|
|
13
|
+
import { joinClassNames } from "./class-names.ts";
|
|
14
|
+
import { TypeIcon } from "./type.icon.ts";
|
|
15
|
+
|
|
16
|
+
export interface TypeSearchProps {
|
|
17
|
+
name: string;
|
|
18
|
+
/** Hidden label for screen readers and the placeholder (already translated). */
|
|
19
|
+
label: string;
|
|
20
|
+
value?: string;
|
|
21
|
+
/** Live search on every key press. */
|
|
22
|
+
onChange?: ChangeEventHandler<HTMLInputElement>;
|
|
23
|
+
/** Search on Enter / button click. The page does not reload. */
|
|
24
|
+
onSearch?: FormEventHandler<HTMLFormElement>;
|
|
25
|
+
className?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Returns the text typed in the search box of a submitted TypeSearch form. */
|
|
29
|
+
export function readSearchText(event: FormEvent<HTMLFormElement>): string {
|
|
30
|
+
const form = event.currentTarget;
|
|
31
|
+
const formData = new FormData(form);
|
|
32
|
+
const searchValue = formData.get("search");
|
|
33
|
+
return typeof searchValue === "string" ? searchValue : ConstValue.EMPTY;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** Stops the page reload, then calls the app handler. */
|
|
37
|
+
function submitWithoutReload(event: FormEvent<HTMLFormElement>, onSearch: FormEventHandler<HTMLFormElement> | undefined): void {
|
|
38
|
+
event.preventDefault();
|
|
39
|
+
if (onSearch) {
|
|
40
|
+
onSearch(event);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Form submit handler; the app handler is read from the form's search-handler registry. */
|
|
45
|
+
function handleSearchFormSubmit(event: FormEvent<HTMLFormElement>): void {
|
|
46
|
+
const form = event.currentTarget;
|
|
47
|
+
const handlerId = form.dataset.searchId ?? ConstValue.EMPTY;
|
|
48
|
+
const onSearch = searchHandlers.get(handlerId);
|
|
49
|
+
submitWithoutReload(event, onSearch);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const searchHandlers = new Map<string, FormEventHandler<HTMLFormElement>>();
|
|
53
|
+
|
|
54
|
+
export function TypeSearch(props: TypeSearchProps) {
|
|
55
|
+
const { name, label, value, onChange, onSearch, className } = props;
|
|
56
|
+
const { t } = useUi();
|
|
57
|
+
const searchText = t("ui.search");
|
|
58
|
+
const classList = ["input input-sm", className];
|
|
59
|
+
const wrapperClassName = joinClassNames(classList);
|
|
60
|
+
|
|
61
|
+
if (!onSearch) {
|
|
62
|
+
return (
|
|
63
|
+
<label className={wrapperClassName}>
|
|
64
|
+
<TypeIcon name="Search" size={16} className="opacity-60" />
|
|
65
|
+
<input type="search" name={name} value={value} onChange={onChange} placeholder={label} aria-label={label} className="grow" />
|
|
66
|
+
</label>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
searchHandlers.set(name, onSearch);
|
|
71
|
+
return (
|
|
72
|
+
<form role="search" className="join" data-search-id={name} onSubmit={handleSearchFormSubmit}>
|
|
73
|
+
<input
|
|
74
|
+
type="search"
|
|
75
|
+
name="search"
|
|
76
|
+
defaultValue={value}
|
|
77
|
+
onChange={onChange}
|
|
78
|
+
placeholder={label}
|
|
79
|
+
aria-label={label}
|
|
80
|
+
className="input input-sm join-item"
|
|
81
|
+
/>
|
|
82
|
+
<button type="submit" className="btn btn-sm join-item" aria-label={searchText} title={searchText}>
|
|
83
|
+
<TypeIcon name="Search" size={16} />
|
|
84
|
+
</button>
|
|
85
|
+
</form>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// type.select.tsx
|
|
2
|
+
// Select box connected to react-hook-form. Options use dff-util OptionType.
|
|
3
|
+
// When option.lang has a text for the current language code, that text is shown.
|
|
4
|
+
//
|
|
5
|
+
// <TypeSelect control={control} name="role" label={t("user.role")} options={roleOptions.value} />
|
|
6
|
+
|
|
7
|
+
import { ConstValue, type OptionType } from "dff-util";
|
|
8
|
+
import { useId, type ReactElement } from "react";
|
|
9
|
+
import { useController, type FieldValues } from "react-hook-form";
|
|
10
|
+
import { useUi } from "../context/use-ui.ts";
|
|
11
|
+
import { FieldWrapper, readMessageId } from "./field-wrapper.tsx";
|
|
12
|
+
import { SELECT_SIZE_CLASSES, joinClassNames, type ControlSize } from "./class-names.ts";
|
|
13
|
+
import { readFieldErrorText } from "./field-error.ts";
|
|
14
|
+
import type { TypeFieldProps } from "./field-props.ts";
|
|
15
|
+
|
|
16
|
+
export interface TypeSelectProps<TFieldValues extends FieldValues> extends TypeFieldProps<TFieldValues> {
|
|
17
|
+
options: OptionType[];
|
|
18
|
+
/** First empty choice text. Default: translated "Select an option". Set false to hide it. */
|
|
19
|
+
placeholder?: string | false;
|
|
20
|
+
size?: ControlSize;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Returns the option text for the language, or the default label. */
|
|
24
|
+
export function readOptionLabel(option: OptionType, languageCode: string): string {
|
|
25
|
+
const translatedLabels = option.lang;
|
|
26
|
+
const translatedLabel = translatedLabels ? translatedLabels[languageCode] : undefined;
|
|
27
|
+
if (translatedLabel) {
|
|
28
|
+
return translatedLabel;
|
|
29
|
+
}
|
|
30
|
+
return option.label;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Builds the <option> elements. */
|
|
34
|
+
function buildOptionElements(options: OptionType[], languageCode: string): ReactElement[] {
|
|
35
|
+
const optionElements: ReactElement[] = [];
|
|
36
|
+
for (const option of options) {
|
|
37
|
+
const optionLabel = readOptionLabel(option, languageCode);
|
|
38
|
+
const iconText = option.icon ? `${option.icon} ` : ConstValue.EMPTY;
|
|
39
|
+
const optionElement = (
|
|
40
|
+
<option key={option.key} value={option.key} disabled={option.disabled}>
|
|
41
|
+
{iconText}
|
|
42
|
+
{optionLabel}
|
|
43
|
+
</option>
|
|
44
|
+
);
|
|
45
|
+
optionElements.push(optionElement);
|
|
46
|
+
}
|
|
47
|
+
return optionElements;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function TypeSelect<TFieldValues extends FieldValues>(props: TypeSelectProps<TFieldValues>) {
|
|
51
|
+
const { control, name, label, rules, error, hint, disabled, className, options, placeholder, size = "md" } = props;
|
|
52
|
+
const { t, locale } = useUi();
|
|
53
|
+
const inputId = useId();
|
|
54
|
+
const controllerOptions = { control: control, name: name, rules: rules, disabled: disabled };
|
|
55
|
+
const { field, fieldState } = useController(controllerOptions);
|
|
56
|
+
const fieldError = error ?? fieldState.error;
|
|
57
|
+
const errorText = readFieldErrorText(fieldError, t);
|
|
58
|
+
const hasError = Boolean(errorText);
|
|
59
|
+
const sizeClass = SELECT_SIZE_CLASSES[size];
|
|
60
|
+
const classList = ["select w-full", sizeClass, hasError ? "select-error" : ""];
|
|
61
|
+
const selectClassName = joinClassNames(classList);
|
|
62
|
+
const messageId = readMessageId(inputId);
|
|
63
|
+
const defaultPlaceholder = t("ui.selectOption");
|
|
64
|
+
const placeholderText = placeholder ?? defaultPlaceholder;
|
|
65
|
+
const optionElements = buildOptionElements(options, locale);
|
|
66
|
+
const value = field.value ?? ConstValue.EMPTY;
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<FieldWrapper inputId={inputId} label={label} errorText={errorText} hint={hint} className={className}>
|
|
70
|
+
<select
|
|
71
|
+
id={inputId}
|
|
72
|
+
ref={field.ref}
|
|
73
|
+
name={field.name}
|
|
74
|
+
value={value}
|
|
75
|
+
onChange={field.onChange}
|
|
76
|
+
onBlur={field.onBlur}
|
|
77
|
+
disabled={field.disabled}
|
|
78
|
+
className={selectClassName}
|
|
79
|
+
aria-invalid={hasError}
|
|
80
|
+
aria-describedby={errorText || hint ? messageId : undefined}
|
|
81
|
+
>
|
|
82
|
+
{placeholderText === false ? null : <option value="">{placeholderText}</option>}
|
|
83
|
+
{optionElements}
|
|
84
|
+
</select>
|
|
85
|
+
</FieldWrapper>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// type.switch.tsx
|
|
2
|
+
// On/off toggle (boolean) connected to react-hook-form.
|
|
3
|
+
//
|
|
4
|
+
// <TypeSwitch control={control} name="active" label={t("user.active")} />
|
|
5
|
+
|
|
6
|
+
import { useId } from "react";
|
|
7
|
+
import { useController, type FieldValues } from "react-hook-form";
|
|
8
|
+
import { useUi } from "../context/use-ui.ts";
|
|
9
|
+
import { joinClassNames } from "./class-names.ts";
|
|
10
|
+
import { readFieldErrorText } from "./field-error.ts";
|
|
11
|
+
import type { TypeFieldProps } from "./field-props.ts";
|
|
12
|
+
|
|
13
|
+
export interface TypeSwitchProps<TFieldValues extends FieldValues> extends TypeFieldProps<TFieldValues> {
|
|
14
|
+
/** Show a checkbox instead of a toggle. Default false. */
|
|
15
|
+
isCheckbox?: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function TypeSwitch<TFieldValues extends FieldValues>(props: TypeSwitchProps<TFieldValues>) {
|
|
19
|
+
const { control, name, label, rules, error, hint, disabled, className, isCheckbox = false } = props;
|
|
20
|
+
const { t } = useUi();
|
|
21
|
+
const inputId = useId();
|
|
22
|
+
const controllerOptions = { control: control, name: name, rules: rules, disabled: disabled };
|
|
23
|
+
const { field, fieldState } = useController(controllerOptions);
|
|
24
|
+
const fieldError = error ?? fieldState.error;
|
|
25
|
+
const errorText = readFieldErrorText(fieldError, t);
|
|
26
|
+
const isChecked = Boolean(field.value);
|
|
27
|
+
const controlClassName = isCheckbox ? "checkbox checkbox-primary" : "toggle toggle-primary";
|
|
28
|
+
const classList = ["fieldset", className];
|
|
29
|
+
const wrapperClassName = joinClassNames(classList);
|
|
30
|
+
const messageText = errorText ?? hint;
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<fieldset className={wrapperClassName}>
|
|
34
|
+
<label className="label cursor-pointer gap-3" htmlFor={inputId}>
|
|
35
|
+
<input
|
|
36
|
+
id={inputId}
|
|
37
|
+
ref={field.ref}
|
|
38
|
+
name={field.name}
|
|
39
|
+
type="checkbox"
|
|
40
|
+
checked={isChecked}
|
|
41
|
+
onChange={field.onChange}
|
|
42
|
+
onBlur={field.onBlur}
|
|
43
|
+
disabled={field.disabled}
|
|
44
|
+
className={controlClassName}
|
|
45
|
+
aria-invalid={Boolean(errorText)}
|
|
46
|
+
/>
|
|
47
|
+
<span className="text-base-content">{label}</span>
|
|
48
|
+
</label>
|
|
49
|
+
{messageText ? <p className={errorText ? "label text-error" : "label"}>{messageText}</p> : null}
|
|
50
|
+
</fieldset>
|
|
51
|
+
);
|
|
52
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// type.table.tsx
|
|
2
|
+
// Simple DaisyUI table for lists.
|
|
3
|
+
//
|
|
4
|
+
// const userColumns: TableColumn<UserType>[] = [
|
|
5
|
+
// { key: "name", headerKey: "user.name" },
|
|
6
|
+
// { key: "email", headerKey: "user.email" },
|
|
7
|
+
// ];
|
|
8
|
+
// <TypeTable rows={users} columns={userColumns} rowKey="id" onRowClick={handleUserRowClick} />
|
|
9
|
+
//
|
|
10
|
+
// function handleUserRowClick(event: MouseEvent<HTMLTableRowElement>) {
|
|
11
|
+
// const userId = readRowKey(event);
|
|
12
|
+
// editModeUpdate(userId);
|
|
13
|
+
// }
|
|
14
|
+
|
|
15
|
+
import type { MouseEvent, MouseEventHandler, ReactElement, ReactNode } from "react";
|
|
16
|
+
import { ConstValue } from "dff-util";
|
|
17
|
+
import { useUi } from "../context/use-ui.ts";
|
|
18
|
+
import type { TranslateFunction } from "../interfaces/ui-context.ts";
|
|
19
|
+
import { EmptyState } from "../components/empty-state.tsx";
|
|
20
|
+
import { SkeletonTable } from "../skeleton/skeleton-table.tsx";
|
|
21
|
+
import { joinClassNames } from "./class-names.ts";
|
|
22
|
+
|
|
23
|
+
export interface TableColumn<RowType> {
|
|
24
|
+
/** Field of the row shown in the column. */
|
|
25
|
+
key: keyof RowType & string;
|
|
26
|
+
/** Translation key of the heading. */
|
|
27
|
+
headerKey: string;
|
|
28
|
+
/** Optional top-level function that returns custom cell content. */
|
|
29
|
+
render?: (row: RowType) => ReactNode;
|
|
30
|
+
className?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface TypeTableProps<RowType> {
|
|
34
|
+
rows: RowType[];
|
|
35
|
+
columns: TableColumn<RowType>[];
|
|
36
|
+
/** Field that is unique per row. Its value is put in data-row-key. */
|
|
37
|
+
rowKey: keyof RowType & string;
|
|
38
|
+
isLoading?: boolean;
|
|
39
|
+
/** Text when there are no rows (translation key). Default "ui.noData". */
|
|
40
|
+
emptyKey?: string;
|
|
41
|
+
/** Row click handler. Read the clicked row id with readRowKey(event). */
|
|
42
|
+
onRowClick?: MouseEventHandler<HTMLTableRowElement>;
|
|
43
|
+
className?: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Returns the row key of the clicked row (from data-row-key). */
|
|
47
|
+
export function readRowKey(event: MouseEvent<HTMLElement>): string {
|
|
48
|
+
const element = event.currentTarget;
|
|
49
|
+
const rowKey = element.dataset.rowKey;
|
|
50
|
+
return rowKey ?? ConstValue.EMPTY;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Returns the content of one cell. */
|
|
54
|
+
export function readCellContent<RowType>(row: RowType, column: TableColumn<RowType>): ReactNode {
|
|
55
|
+
if (column.render) {
|
|
56
|
+
const customContent = column.render(row);
|
|
57
|
+
return customContent;
|
|
58
|
+
}
|
|
59
|
+
const cellValue = row[column.key];
|
|
60
|
+
if (cellValue === null || cellValue === undefined) {
|
|
61
|
+
return ConstValue.EMPTY;
|
|
62
|
+
}
|
|
63
|
+
const cellText = String(cellValue);
|
|
64
|
+
return cellText;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Builds the heading cells. */
|
|
68
|
+
function buildHeaderCells<RowType>(columns: TableColumn<RowType>[], t: TranslateFunction): ReactElement[] {
|
|
69
|
+
const headerCells: ReactElement[] = [];
|
|
70
|
+
for (const column of columns) {
|
|
71
|
+
const headerText = t(column.headerKey);
|
|
72
|
+
const headerCell = (
|
|
73
|
+
<th key={column.key} className={column.className}>
|
|
74
|
+
{headerText}
|
|
75
|
+
</th>
|
|
76
|
+
);
|
|
77
|
+
headerCells.push(headerCell);
|
|
78
|
+
}
|
|
79
|
+
return headerCells;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Builds the cells of one row. */
|
|
83
|
+
function buildRowCells<RowType>(row: RowType, columns: TableColumn<RowType>[]): ReactElement[] {
|
|
84
|
+
const cells: ReactElement[] = [];
|
|
85
|
+
for (const column of columns) {
|
|
86
|
+
const cellContent = readCellContent(row, column);
|
|
87
|
+
const cell = (
|
|
88
|
+
<td key={column.key} className={column.className}>
|
|
89
|
+
{cellContent}
|
|
90
|
+
</td>
|
|
91
|
+
);
|
|
92
|
+
cells.push(cell);
|
|
93
|
+
}
|
|
94
|
+
return cells;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** Builds all body rows. */
|
|
98
|
+
function buildBodyRows<RowType>(
|
|
99
|
+
rows: RowType[],
|
|
100
|
+
columns: TableColumn<RowType>[],
|
|
101
|
+
rowKey: keyof RowType & string,
|
|
102
|
+
onRowClick: MouseEventHandler<HTMLTableRowElement> | undefined,
|
|
103
|
+
): ReactElement[] {
|
|
104
|
+
const bodyRows: ReactElement[] = [];
|
|
105
|
+
const rowClassName = onRowClick ? "hover cursor-pointer" : undefined;
|
|
106
|
+
for (const row of rows) {
|
|
107
|
+
const cells = buildRowCells(row, columns);
|
|
108
|
+
const keyValue = row[rowKey];
|
|
109
|
+
const rowKeyText = String(keyValue);
|
|
110
|
+
const bodyRow = (
|
|
111
|
+
<tr key={rowKeyText} data-row-key={rowKeyText} className={rowClassName} onClick={onRowClick}>
|
|
112
|
+
{cells}
|
|
113
|
+
</tr>
|
|
114
|
+
);
|
|
115
|
+
bodyRows.push(bodyRow);
|
|
116
|
+
}
|
|
117
|
+
return bodyRows;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function TypeTable<RowType>(props: TypeTableProps<RowType>) {
|
|
121
|
+
const { rows, columns, rowKey, isLoading = false, emptyKey = "ui.noData", onRowClick, className } = props;
|
|
122
|
+
const { t } = useUi();
|
|
123
|
+
|
|
124
|
+
if (isLoading) {
|
|
125
|
+
return <SkeletonTable />;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const headerCells = buildHeaderCells(columns, t);
|
|
129
|
+
const bodyRows = buildBodyRows(rows, columns, rowKey, onRowClick);
|
|
130
|
+
const isEmpty = rows.length === 0;
|
|
131
|
+
const classList = ["table table-zebra", className];
|
|
132
|
+
const tableClassName = joinClassNames(classList);
|
|
133
|
+
|
|
134
|
+
return (
|
|
135
|
+
<table className={tableClassName}>
|
|
136
|
+
<thead>
|
|
137
|
+
<tr>{headerCells}</tr>
|
|
138
|
+
</thead>
|
|
139
|
+
<tbody>
|
|
140
|
+
{isEmpty ? (
|
|
141
|
+
<tr>
|
|
142
|
+
<td colSpan={columns.length}>
|
|
143
|
+
<EmptyState titleKey={emptyKey} />
|
|
144
|
+
</td>
|
|
145
|
+
</tr>
|
|
146
|
+
) : (
|
|
147
|
+
bodyRows
|
|
148
|
+
)}
|
|
149
|
+
</tbody>
|
|
150
|
+
</table>
|
|
151
|
+
);
|
|
152
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// type.text-area.tsx
|
|
2
|
+
// Multi-line text connected to react-hook-form.
|
|
3
|
+
|
|
4
|
+
import { ConstValue } from "dff-util";
|
|
5
|
+
import { useId } from "react";
|
|
6
|
+
import { useController, type FieldValues } from "react-hook-form";
|
|
7
|
+
import { useUi } from "../context/use-ui.ts";
|
|
8
|
+
import { FieldWrapper, readMessageId } from "./field-wrapper.tsx";
|
|
9
|
+
import { joinClassNames } from "./class-names.ts";
|
|
10
|
+
import { readFieldErrorText } from "./field-error.ts";
|
|
11
|
+
import type { TypeFieldProps } from "./field-props.ts";
|
|
12
|
+
|
|
13
|
+
export interface TypeTextAreaProps<TFieldValues extends FieldValues> extends TypeFieldProps<TFieldValues> {
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
/** Visible lines. Default 4. */
|
|
16
|
+
rows?: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function TypeTextArea<TFieldValues extends FieldValues>(props: TypeTextAreaProps<TFieldValues>) {
|
|
20
|
+
const { control, name, label, rules, error, hint, disabled, className, placeholder, rows = 4 } = props;
|
|
21
|
+
const { t } = useUi();
|
|
22
|
+
const inputId = useId();
|
|
23
|
+
const controllerOptions = { control: control, name: name, rules: rules, disabled: disabled };
|
|
24
|
+
const { field, fieldState } = useController(controllerOptions);
|
|
25
|
+
const fieldError = error ?? fieldState.error;
|
|
26
|
+
const errorText = readFieldErrorText(fieldError, t);
|
|
27
|
+
const hasError = Boolean(errorText);
|
|
28
|
+
const classList = ["textarea w-full", hasError ? "textarea-error" : ""];
|
|
29
|
+
const textAreaClassName = joinClassNames(classList);
|
|
30
|
+
const messageId = readMessageId(inputId);
|
|
31
|
+
const value = field.value ?? ConstValue.EMPTY;
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<FieldWrapper inputId={inputId} label={label} errorText={errorText} hint={hint} className={className}>
|
|
35
|
+
<textarea
|
|
36
|
+
id={inputId}
|
|
37
|
+
ref={field.ref}
|
|
38
|
+
name={field.name}
|
|
39
|
+
rows={rows}
|
|
40
|
+
value={value}
|
|
41
|
+
onChange={field.onChange}
|
|
42
|
+
onBlur={field.onBlur}
|
|
43
|
+
disabled={field.disabled}
|
|
44
|
+
placeholder={placeholder}
|
|
45
|
+
className={textAreaClassName}
|
|
46
|
+
aria-invalid={hasError}
|
|
47
|
+
aria-describedby={errorText || hint ? messageId : undefined}
|
|
48
|
+
/>
|
|
49
|
+
</FieldWrapper>
|
|
50
|
+
);
|
|
51
|
+
}
|