create-react-admin-template 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -2
- package/bin/create.mjs +5 -0
- package/package.json +22 -4
- package/template/.dockerignore +12 -0
- package/template/.editorconfig +12 -0
- package/template/.env +14 -0
- package/template/.env.development +5 -0
- package/template/.env.production +2 -0
- package/template/.env.test +5 -0
- package/template/.github/workflows/ci.yml +40 -0
- package/template/.gitlab-ci.yml +208 -0
- package/template/.husky/commit-msg +1 -0
- package/template/.husky/pre-commit +1 -0
- package/template/.nvmrc +1 -0
- package/template/.prettierignore +11 -0
- package/template/.prettierrc +47 -0
- package/template/Dockerfile +16 -0
- package/template/README.md +372 -0
- package/template/build/advancedTable.ts +103 -0
- package/template/build/environment.ts +150 -0
- package/template/commitlint.config.js +32 -0
- package/template/components.json +21 -0
- package/template/deploy/README.md +132 -0
- package/template/deploy/host-nginx/react-admin-api.conf +14 -0
- package/template/deploy/host-nginx/react-admin-web.conf +8 -0
- package/template/deploy/nginx.conf +38 -0
- package/template/docs/activity-status.md +217 -0
- package/template/docs/audit-logs.md +158 -0
- package/template/docs/authentication-adapters.md +219 -0
- package/template/docs/browser-security.md +58 -0
- package/template/docs/bundle-budgets.md +65 -0
- package/template/docs/component-source-governance.md +99 -0
- package/template/docs/data-masking.md +169 -0
- package/template/docs/enterprise-scaffold.md +208 -0
- package/template/docs/feature-data-template.md +227 -0
- package/template/docs/feature-flags.md +169 -0
- package/template/docs/file-capabilities.md +196 -0
- package/template/docs/locale-and-i18n.md +132 -0
- package/template/docs/mutation-idempotency.md +24 -0
- package/template/docs/optional-editors.md +203 -0
- package/template/docs/page-feedback.md +83 -0
- package/template/docs/query-data-conventions.md +178 -0
- package/template/docs/realtime-collaboration.md +140 -0
- package/template/docs/reporting-printing-templates.md +156 -0
- package/template/docs/scaffold-capability-roadmap.md +226 -0
- package/template/docs/scaffold-guide.md +443 -0
- package/template/docs/template-changelog.md +30 -0
- package/template/docs/template-versioning.md +26 -0
- package/template/docs/tenant-workspace-context.md +147 -0
- package/template/docs/unsaved-changes.md +58 -0
- package/template/docs/white-label.md +102 -0
- package/template/eslint.config.js +697 -0
- package/template/gitignore +39 -0
- package/template/index.html +26 -0
- package/template/knip.config.ts +42 -0
- package/template/lint-staged.config.js +8 -0
- package/template/package.json +133 -0
- package/template/pnpm-lock.yaml +8694 -0
- package/template/public/favicon.ico +0 -0
- package/template/public/logo.svg +1 -0
- package/template/public/runtime-config.json +49 -0
- package/template/scaffold.template.json +5 -0
- package/template/src/Application.tsx +114 -0
- package/template/src/api/ApiError.ts +33 -0
- package/template/src/api/activity/ActivityProvider.tsx +167 -0
- package/template/src/api/activity/access.ts +13 -0
- package/template/src/api/activity/errors.ts +17 -0
- package/template/src/api/activity/index.ts +67 -0
- package/template/src/api/activity/model.ts +227 -0
- package/template/src/api/activity/query.ts +163 -0
- package/template/src/api/activity/source.ts +16 -0
- package/template/src/api/activity/subscription.ts +292 -0
- package/template/src/api/activity/transports.ts +271 -0
- package/template/src/api/activity/types.ts +402 -0
- package/template/src/api/authClient.ts +134 -0
- package/template/src/api/authSession.ts +307 -0
- package/template/src/api/clients/configureApiClient.ts +62 -0
- package/template/src/api/clients/httpStatus.ts +4 -0
- package/template/src/api/config/services.json +7 -0
- package/template/src/api/demoAuthClient.ts +46 -0
- package/template/src/api/enums/EnumCatalogProvider.tsx +169 -0
- package/template/src/api/enums/EnumDictionary.ts +55 -0
- package/template/src/api/enums/access.ts +130 -0
- package/template/src/api/enums/catalog.ts +216 -0
- package/template/src/api/enums/errors.ts +21 -0
- package/template/src/api/enums/index.ts +48 -0
- package/template/src/api/enums/query.ts +82 -0
- package/template/src/api/enums/scope.ts +58 -0
- package/template/src/api/enums/types.ts +251 -0
- package/template/src/api/hooks/error.ts +198 -0
- package/template/src/api/hooks/index.ts +4 -0
- package/template/src/api/hooks/request.ts +99 -0
- package/template/src/api/hooks/requestId.ts +65 -0
- package/template/src/api/hooks/response.ts +22 -0
- package/template/src/api/hooks/types.ts +20 -0
- package/template/src/api/idempotency/index.ts +1 -0
- package/template/src/api/idempotency/key.ts +23 -0
- package/template/src/api/index.ts +14 -0
- package/template/src/api/metadata/MetadataProvider.tsx +37 -0
- package/template/src/api/metadata/index.ts +2 -0
- package/template/src/api/metadata/types.ts +30 -0
- package/template/src/api/parameters/GlobalParameterProvider.tsx +210 -0
- package/template/src/api/parameters/access.ts +117 -0
- package/template/src/api/parameters/catalog.ts +170 -0
- package/template/src/api/parameters/errors.ts +21 -0
- package/template/src/api/parameters/index.ts +53 -0
- package/template/src/api/parameters/query.ts +84 -0
- package/template/src/api/parameters/scope.ts +58 -0
- package/template/src/api/parameters/types.ts +214 -0
- package/template/src/api/query/index.ts +13 -0
- package/template/src/api/query/keys.ts +155 -0
- package/template/src/api/query/mutation.ts +48 -0
- package/template/src/api/query/react.ts +36 -0
- package/template/src/api/query/scope.ts +38 -0
- package/template/src/api/query/types.ts +147 -0
- package/template/src/api/types.ts +144 -0
- package/template/src/application/types.ts +52 -0
- package/template/src/auditLogs/errors.ts +17 -0
- package/template/src/auditLogs/export.ts +85 -0
- package/template/src/auditLogs/index.ts +54 -0
- package/template/src/auditLogs/model.ts +526 -0
- package/template/src/auditLogs/query.ts +113 -0
- package/template/src/auditLogs/react.ts +36 -0
- package/template/src/auditLogs/source.ts +51 -0
- package/template/src/auditLogs/types.ts +357 -0
- package/template/src/authentication/controller.ts +351 -0
- package/template/src/authentication/index.ts +8 -0
- package/template/src/authentication/redirect.ts +72 -0
- package/template/src/authentication/types.ts +300 -0
- package/template/src/bootstrap.tsx +96 -0
- package/template/src/components/AppDataTable/AppDataTable.tsx +74 -0
- package/template/src/components/AppDataTable/index.ts +2 -0
- package/template/src/components/AppDataTable/types.ts +27 -0
- package/template/src/components/AppDialog/AppConfirmDialog.tsx +44 -0
- package/template/src/components/AppDialog/AppDialog.tsx +113 -0
- package/template/src/components/AppDialog/index.ts +3 -0
- package/template/src/components/AppDialog/messages.tsx +22 -0
- package/template/src/components/AppDialog/types.ts +53 -0
- package/template/src/components/AppPageForm/AppPageForm.tsx +21 -0
- package/template/src/components/AppPageForm/PageForm.tsx +765 -0
- package/template/src/components/AppPageForm/SOURCE.md +26 -0
- package/template/src/components/AppPageForm/config.ts +253 -0
- package/template/src/components/AppPageForm/controller.ts +580 -0
- package/template/src/components/AppPageForm/index.ts +2 -0
- package/template/src/components/AppPageForm/messages.ts +90 -0
- package/template/src/components/AppPageForm/optionUtils.ts +91 -0
- package/template/src/components/AppPageForm/options.ts +397 -0
- package/template/src/components/AppPageForm/query.ts +44 -0
- package/template/src/components/AppPageForm/style.css +119 -0
- package/template/src/components/AppPageForm/types.ts +632 -0
- package/template/src/components/AppPageForm/validation.ts +233 -0
- package/template/src/components/AppTable/AppTable.tsx +26 -0
- package/template/src/components/AppTable/SOURCE.md +72 -0
- package/template/src/components/AppTable/cell/customCell/TableCellLayer.tsx +73 -0
- package/template/src/components/AppTable/cell/customCell/actions/ActionDropdownCell.tsx +104 -0
- package/template/src/components/AppTable/cell/customCell/cellLayer.ts +358 -0
- package/template/src/components/AppTable/cell/customCell/componentProps.ts +30 -0
- package/template/src/components/AppTable/cell/customCell/date/TemporalPickerEditor.tsx +54 -0
- package/template/src/components/AppTable/cell/customCell/index.ts +2 -0
- package/template/src/components/AppTable/cell/customCell/select/SelectCellEditor.tsx +225 -0
- package/template/src/components/AppTable/cell/customCell/tableCellLayer.css +20 -0
- package/template/src/components/AppTable/cell/customCell/tooltip/TooltipCell.tsx +45 -0
- package/template/src/components/AppTable/cell/customCell/types.ts +63 -0
- package/template/src/components/AppTable/cell/customCell/useCellLayerLifecycle.ts +111 -0
- package/template/src/components/AppTable/cell/frameworkCell/TableCellComponentLayer.tsx +40 -0
- package/template/src/components/AppTable/cell/frameworkCell/cellComponentSession.ts +203 -0
- package/template/src/components/AppTable/cell/frameworkCell/index.ts +3 -0
- package/template/src/components/AppTable/cell/index.ts +2 -0
- package/template/src/components/AppTable/columns/TableColumnEditor.tsx +257 -0
- package/template/src/components/AppTable/columns/index.ts +1 -0
- package/template/src/components/AppTable/columns/useTableColumnPreferenceActions.ts +85 -0
- package/template/src/components/AppTable/config/defaults.ts +46 -0
- package/template/src/components/AppTable/config/index.ts +2 -0
- package/template/src/components/AppTable/config/license.ts +39 -0
- package/template/src/components/AppTable/config/resolver.ts +25 -0
- package/template/src/components/AppTable/config/types.ts +377 -0
- package/template/src/components/AppTable/engine/bottom/index.ts +1 -0
- package/template/src/components/AppTable/engine/bottom/types.ts +14 -0
- package/template/src/components/AppTable/engine/cell/constants.ts +32 -0
- package/template/src/components/AppTable/engine/cell/customCell/actions/index.ts +1 -0
- package/template/src/components/AppTable/engine/cell/customCell/actions/renderer.ts +162 -0
- package/template/src/components/AppTable/engine/cell/customCell/date/index.ts +1 -0
- package/template/src/components/AppTable/engine/cell/customCell/date/renderer.ts +116 -0
- package/template/src/components/AppTable/engine/cell/customCell/editors/editorBounds.ts +57 -0
- package/template/src/components/AppTable/engine/cell/customCell/editors/editorTrigger.ts +46 -0
- package/template/src/components/AppTable/engine/cell/customCell/editors/index.ts +3 -0
- package/template/src/components/AppTable/engine/cell/customCell/editors/layerEditor.ts +244 -0
- package/template/src/components/AppTable/engine/cell/customCell/index.ts +7 -0
- package/template/src/components/AppTable/engine/cell/customCell/renderers/columnRenderer.ts +245 -0
- package/template/src/components/AppTable/engine/cell/customCell/renderers/confirmInput.ts +57 -0
- package/template/src/components/AppTable/engine/cell/customCell/renderers/display.ts +78 -0
- package/template/src/components/AppTable/engine/cell/customCell/renderers/index.ts +3 -0
- package/template/src/components/AppTable/engine/cell/customCell/renderers/itemList.ts +60 -0
- package/template/src/components/AppTable/engine/cell/customCell/renderers/links.ts +131 -0
- package/template/src/components/AppTable/engine/cell/customCell/renderers/selection.ts +41 -0
- package/template/src/components/AppTable/engine/cell/customCell/renderers/shared.ts +71 -0
- package/template/src/components/AppTable/engine/cell/customCell/renderers/step.ts +37 -0
- package/template/src/components/AppTable/engine/cell/customCell/renderers/switch.ts +45 -0
- package/template/src/components/AppTable/engine/cell/customCell/select/index.ts +1 -0
- package/template/src/components/AppTable/engine/cell/customCell/select/renderer.ts +33 -0
- package/template/src/components/AppTable/engine/cell/customCell/tooltip/index.ts +1 -0
- package/template/src/components/AppTable/engine/cell/customCell/tooltip/tooltip.ts +94 -0
- package/template/src/components/AppTable/engine/cell/customCell/types.ts +82 -0
- package/template/src/components/AppTable/engine/cell/formatting.ts +355 -0
- package/template/src/components/AppTable/engine/cell/formula.ts +145 -0
- package/template/src/components/AppTable/engine/cell/index.ts +7 -0
- package/template/src/components/AppTable/engine/cell/multiSelect.ts +96 -0
- package/template/src/components/AppTable/engine/cell/options.ts +339 -0
- package/template/src/components/AppTable/engine/cell/types.ts +53 -0
- package/template/src/components/AppTable/engine/columns/column.ts +430 -0
- package/template/src/components/AppTable/engine/columns/config/columns.ts +33 -0
- package/template/src/components/AppTable/engine/columns/config/index.ts +4 -0
- package/template/src/components/AppTable/engine/columns/config/mutation.ts +138 -0
- package/template/src/components/AppTable/engine/columns/config/temporal.ts +11 -0
- package/template/src/components/AppTable/engine/columns/config/validation.ts +106 -0
- package/template/src/components/AppTable/engine/columns/constants.ts +6 -0
- package/template/src/components/AppTable/engine/columns/gridColumns.ts +332 -0
- package/template/src/components/AppTable/engine/columns/index.ts +4 -0
- package/template/src/components/AppTable/engine/columns/rendererPolicies.ts +129 -0
- package/template/src/components/AppTable/engine/component/resolver.ts +272 -0
- package/template/src/components/AppTable/engine/component/types.ts +384 -0
- package/template/src/components/AppTable/engine/config/constants.ts +33 -0
- package/template/src/components/AppTable/engine/config/grid/compiler.ts +65 -0
- package/template/src/components/AppTable/engine/config/grid/defaults.ts +82 -0
- package/template/src/components/AppTable/engine/config/grid/ownership.ts +35 -0
- package/template/src/components/AppTable/engine/config/grid/runtimeDelta.ts +34 -0
- package/template/src/components/AppTable/engine/config/grid/types.ts +30 -0
- package/template/src/components/AppTable/engine/pagination/config.ts +75 -0
- package/template/src/components/AppTable/engine/pagination/constants.ts +5 -0
- package/template/src/components/AppTable/engine/pagination/index.ts +3 -0
- package/template/src/components/AppTable/engine/pagination/types.ts +70 -0
- package/template/src/components/AppTable/engine/preference/index.ts +2 -0
- package/template/src/components/AppTable/engine/preference/preference.ts +535 -0
- package/template/src/components/AppTable/engine/preference/types.ts +28 -0
- package/template/src/components/AppTable/engine/right/index.ts +1 -0
- package/template/src/components/AppTable/engine/right/types.ts +18 -0
- package/template/src/components/AppTable/engine/search/config.ts +64 -0
- package/template/src/components/AppTable/engine/search/constants.ts +8 -0
- package/template/src/components/AppTable/engine/search/index.ts +7 -0
- package/template/src/components/AppTable/engine/search/localQuery.ts +145 -0
- package/template/src/components/AppTable/engine/search/query.ts +203 -0
- package/template/src/components/AppTable/engine/search/remoteQuery.ts +99 -0
- package/template/src/components/AppTable/engine/search/searchInteraction.ts +46 -0
- package/template/src/components/AppTable/engine/search/types.ts +155 -0
- package/template/src/components/AppTable/engine/selection/config.ts +13 -0
- package/template/src/components/AppTable/engine/selection/index.ts +4 -0
- package/template/src/components/AppTable/engine/selection/selection.ts +357 -0
- package/template/src/components/AppTable/engine/selection/selectionHeader.ts +88 -0
- package/template/src/components/AppTable/engine/selection/types.ts +66 -0
- package/template/src/components/AppTable/engine/shared/action.ts +11 -0
- package/template/src/components/AppTable/engine/shared/constants.ts +2 -0
- package/template/src/components/AppTable/engine/shared/decimal.ts +114 -0
- package/template/src/components/AppTable/engine/shared/feedback.ts +62 -0
- package/template/src/components/AppTable/engine/shared/index.ts +13 -0
- package/template/src/components/AppTable/engine/shared/interaction.ts +55 -0
- package/template/src/components/AppTable/engine/shared/messages.ts +161 -0
- package/template/src/components/AppTable/engine/shared/row.ts +32 -0
- package/template/src/components/AppTable/engine/shared/scheduler.ts +17 -0
- package/template/src/components/AppTable/engine/shared/tableKey.ts +31 -0
- package/template/src/components/AppTable/engine/shared/theme.ts +196 -0
- package/template/src/components/AppTable/engine/shared/treeRows.ts +155 -0
- package/template/src/components/AppTable/engine/shared/types.ts +58 -0
- package/template/src/components/AppTable/engine/shared/valueSnapshot.ts +46 -0
- package/template/src/components/AppTable/engine/summary/config/export.ts +117 -0
- package/template/src/components/AppTable/engine/summary/config/index.ts +3 -0
- package/template/src/components/AppTable/engine/summary/config/summary.ts +62 -0
- package/template/src/components/AppTable/engine/summary/config/types.ts +93 -0
- package/template/src/components/AppTable/engine/summary/constants.ts +13 -0
- package/template/src/components/AppTable/engine/summary/excelJs.ts +133 -0
- package/template/src/components/AppTable/engine/summary/export.ts +311 -0
- package/template/src/components/AppTable/engine/summary/index.ts +6 -0
- package/template/src/components/AppTable/engine/summary/selectionSum.ts +92 -0
- package/template/src/components/AppTable/engine/summary/summary.ts +457 -0
- package/template/src/components/AppTable/engine/table/clipboard/index.ts +1 -0
- package/template/src/components/AppTable/engine/table/clipboard/transfer.ts +9 -0
- package/template/src/components/AppTable/engine/table/controller/TableController.ts +802 -0
- package/template/src/components/AppTable/engine/table/controller/errors.ts +106 -0
- package/template/src/components/AppTable/engine/table/controller/index.ts +4 -0
- package/template/src/components/AppTable/engine/table/controller/latestAbortableTask.ts +33 -0
- package/template/src/components/AppTable/engine/table/controller/tableDataReplacement.ts +60 -0
- package/template/src/components/AppTable/engine/table/controller/tableDomainConfiguration.ts +94 -0
- package/template/src/components/AppTable/engine/table/controller/tableEditingCommands.ts +163 -0
- package/template/src/components/AppTable/engine/table/controller/tableGridHost.ts +324 -0
- package/template/src/components/AppTable/engine/table/controller/tableIdentity.ts +68 -0
- package/template/src/components/AppTable/engine/table/controller/tableMutationPipeline.ts +79 -0
- package/template/src/components/AppTable/engine/table/controller/tableQueryCoordinator.ts +187 -0
- package/template/src/components/AppTable/engine/table/controller/tableReportingCoordinator.ts +143 -0
- package/template/src/components/AppTable/engine/table/controller/tableSaveCoordinator.ts +227 -0
- package/template/src/components/AppTable/engine/table/controller/tableSaveValidation.ts +29 -0
- package/template/src/components/AppTable/engine/table/controller/tableSnapshot.ts +58 -0
- package/template/src/components/AppTable/engine/table/controller/types.ts +202 -0
- package/template/src/components/AppTable/engine/table/editing/baselineStore.ts +134 -0
- package/template/src/components/AppTable/engine/table/editing/changeSet.ts +492 -0
- package/template/src/components/AppTable/engine/table/editing/changeSetSettlement.ts +633 -0
- package/template/src/components/AppTable/engine/table/editing/commitResultIndex.ts +75 -0
- package/template/src/components/AppTable/engine/table/editing/constants.ts +15 -0
- package/template/src/components/AppTable/engine/table/editing/dirtyCellIndex.ts +96 -0
- package/template/src/components/AppTable/engine/table/editing/index.ts +6 -0
- package/template/src/components/AppTable/engine/table/editing/mutation.ts +173 -0
- package/template/src/components/AppTable/engine/table/editing/rowKey.ts +10 -0
- package/template/src/components/AppTable/engine/table/editing/types.ts +404 -0
- package/template/src/components/AppTable/engine/table/editing/validation.ts +452 -0
- package/template/src/components/AppTable/engine/table/grid/cellMeta.ts +90 -0
- package/template/src/components/AppTable/engine/table/grid/handsontable.ts +25 -0
- package/template/src/components/AppTable/engine/table/grid/handsontableExtensions.d.ts +26 -0
- package/template/src/components/AppTable/engine/table/grid/index.ts +5 -0
- package/template/src/components/AppTable/engine/table/grid/moduleRegistry.ts +39 -0
- package/template/src/components/AppTable/engine/table/grid/runtime.ts +31 -0
- package/template/src/components/AppTable/engine/table/grid/types.ts +25 -0
- package/template/src/components/AppTable/engine/table/hooks/fixedEndHooks.ts +44 -0
- package/template/src/components/AppTable/engine/table/hooks/gridHooks.ts +108 -0
- package/template/src/components/AppTable/engine/table/hooks/headerHooks.ts +103 -0
- package/template/src/components/AppTable/engine/table/hooks/index.ts +3 -0
- package/template/src/components/AppTable/engine/table/index.ts +6 -0
- package/template/src/components/AppTable/engine/table/layout/constants.ts +2 -0
- package/template/src/components/AppTable/engine/table/layout/dropdownMenu.ts +89 -0
- package/template/src/components/AppTable/engine/table/layout/fixedColumns.ts +44 -0
- package/template/src/components/AppTable/engine/table/layout/fixedEndOverlay.ts +90 -0
- package/template/src/components/AppTable/engine/table/layout/fixedEndOverlayAccessibility.ts +104 -0
- package/template/src/components/AppTable/engine/table/layout/fixedEndOverlayRenderer.ts +690 -0
- package/template/src/components/AppTable/engine/table/layout/fixedEndOverlaySignature.ts +58 -0
- package/template/src/components/AppTable/engine/table/layout/fixedEndRuntime.ts +137 -0
- package/template/src/components/AppTable/engine/table/layout/handsontableDomAdapter.ts +40 -0
- package/template/src/components/AppTable/engine/table/layout/height.ts +72 -0
- package/template/src/components/AppTable/engine/table/layout/index.ts +14 -0
- package/template/src/components/AppTable/engine/table/layout/layoutScheduler.ts +60 -0
- package/template/src/components/AppTable/engine/table/layout/mergeCells.ts +146 -0
- package/template/src/components/AppTable/engine/table/layout/nestedHeaders.ts +271 -0
- package/template/src/components/AppTable/engine/table/layout/types.ts +10 -0
- package/template/src/components/AppTable/engine/toolbar/index.ts +1 -0
- package/template/src/components/AppTable/engine/toolbar/types.ts +56 -0
- package/template/src/components/AppTable/index.ts +11 -0
- package/template/src/components/AppTable/messages.ts +256 -0
- package/template/src/components/AppTable/pagination/TablePaginationBar.tsx +193 -0
- package/template/src/components/AppTable/pagination/index.ts +1 -0
- package/template/src/components/AppTable/pagination/paginationItems.ts +56 -0
- package/template/src/components/AppTable/preference/index.ts +1 -0
- package/template/src/components/AppTable/preference/useTablePreference.ts +208 -0
- package/template/src/components/AppTable/reporting/index.ts +1 -0
- package/template/src/components/AppTable/reporting/useTableReporting.ts +342 -0
- package/template/src/components/AppTable/search/TableSearchBar.tsx +301 -0
- package/template/src/components/AppTable/search/TableSearchConditionEditor.tsx +254 -0
- package/template/src/components/AppTable/search/TableSearchField.tsx +338 -0
- package/template/src/components/AppTable/search/TableSearchFields.tsx +65 -0
- package/template/src/components/AppTable/search/constants.ts +9 -0
- package/template/src/components/AppTable/search/index.ts +3 -0
- package/template/src/components/AppTable/search/tableSearchBar.css +164 -0
- package/template/src/components/AppTable/search/types.ts +7 -0
- package/template/src/components/AppTable/search/useTableQuery.ts +373 -0
- package/template/src/components/AppTable/selection/index.ts +1 -0
- package/template/src/components/AppTable/selection/useTableSelection.ts +188 -0
- package/template/src/components/AppTable/sensitiveData.tsx +41 -0
- package/template/src/components/AppTable/shared/styles.ts +2 -0
- package/template/src/components/AppTable/styles/index.css +6 -0
- package/template/src/components/AppTable/styles/tableComponent.css +297 -0
- package/template/src/components/AppTable/styles/theme.css +133 -0
- package/template/src/components/AppTable/table/components/TableComponent.tsx +567 -0
- package/template/src/components/AppTable/table/components/TableErrorFeedback.tsx +36 -0
- package/template/src/components/AppTable/table/components/TableGridViewport.tsx +85 -0
- package/template/src/components/AppTable/table/components/index.ts +2 -0
- package/template/src/components/AppTable/table/components/types.ts +90 -0
- package/template/src/components/AppTable/table/controller/configuration.ts +89 -0
- package/template/src/components/AppTable/table/controller/index.ts +2 -0
- package/template/src/components/AppTable/table/controller/useTableController.ts +155 -0
- package/template/src/components/AppTable/table/controller/useTableLifecycle.ts +97 -0
- package/template/src/components/AppTable/table/grid/index.ts +1 -0
- package/template/src/components/AppTable/table/grid/useTableGrid.ts +857 -0
- package/template/src/components/AppTable/table/grid/useTableGridRuntimeSettings.ts +49 -0
- package/template/src/components/AppTable/table/index.ts +4 -0
- package/template/src/components/AppTable/table/layout/TablePanels.tsx +389 -0
- package/template/src/components/AppTable/table/layout/index.ts +7 -0
- package/template/src/components/AppTable/table/layout/types.ts +3 -0
- package/template/src/components/AppTable/table/layout/useResizablePanel.ts +213 -0
- package/template/src/components/AppTable/table/layout/useTableAdaptiveHeight.ts +238 -0
- package/template/src/components/AppTable/table/layout/useTablePanels.ts +329 -0
- package/template/src/components/AppTable/table/layout/useTableTheme.ts +123 -0
- package/template/src/components/AppTable/toolbar/TableToolbar.tsx +336 -0
- package/template/src/components/AppTable/toolbar/index.ts +1 -0
- package/template/src/components/BrandLogo/BrandLogo.tsx +41 -0
- package/template/src/components/BrandLogo/index.ts +1 -0
- package/template/src/components/Can/Can.tsx +19 -0
- package/template/src/components/Can/index.ts +7 -0
- package/template/src/components/Can/types.ts +41 -0
- package/template/src/components/EnumBadge/EnumBadge.tsx +44 -0
- package/template/src/components/EnumBadge/index.ts +2 -0
- package/template/src/components/EnumBadge/types.ts +16 -0
- package/template/src/components/EnumText/EnumText.tsx +33 -0
- package/template/src/components/EnumText/index.ts +2 -0
- package/template/src/components/EnumText/types.ts +13 -0
- package/template/src/components/FilePreview/FilePreview.tsx +120 -0
- package/template/src/components/FilePreview/index.ts +11 -0
- package/template/src/components/FilePreview/preview.ts +88 -0
- package/template/src/components/FilePreview/types.ts +91 -0
- package/template/src/components/FileUpload/FileUpload.tsx +172 -0
- package/template/src/components/FileUpload/index.ts +2 -0
- package/template/src/components/FileUpload/types.ts +32 -0
- package/template/src/components/JsonEditor/JsonEditor.tsx +103 -0
- package/template/src/components/JsonEditor/index.ts +1 -0
- package/template/src/components/JsonEditor/types.ts +14 -0
- package/template/src/components/PageFeedback/PageFeedback.tsx +194 -0
- package/template/src/components/PageFeedback/index.ts +10 -0
- package/template/src/components/PageFeedback/types.ts +31 -0
- package/template/src/components/PasswordInput/PasswordInput.tsx +50 -0
- package/template/src/components/PasswordInput/index.ts +1 -0
- package/template/src/components/RouteDialog/RouteDialog.tsx +20 -0
- package/template/src/components/RouteDialog/index.ts +2 -0
- package/template/src/components/RouteDialog/types.ts +8 -0
- package/template/src/components/RouteDialog/useRouteDialogNavigation.ts +30 -0
- package/template/src/components/SensitiveData/SensitiveData.tsx +337 -0
- package/template/src/components/SensitiveData/index.ts +2 -0
- package/template/src/components/SensitiveData/types.ts +31 -0
- package/template/src/components/StatusBadge/StatusBadge.tsx +28 -0
- package/template/src/components/StatusBadge/index.ts +2 -0
- package/template/src/components/StatusBadge/statusBadgeStyles.ts +30 -0
- package/template/src/components/StatusBadge/types.ts +7 -0
- package/template/src/components/layout/AppHeader/AppHeader.tsx +57 -0
- package/template/src/components/layout/AppHeader/HeaderSearch.tsx +160 -0
- package/template/src/components/layout/AppHeader/HeaderUserMenu.tsx +59 -0
- package/template/src/components/layout/AppHeader/ThemeControls.tsx +44 -0
- package/template/src/components/layout/AppHeader/index.ts +1 -0
- package/template/src/components/layout/AppHeader/themeOptions.ts +13 -0
- package/template/src/components/layout/AppSidebar.tsx +268 -0
- package/template/src/components/layout/PageContainer.tsx +16 -0
- package/template/src/components/ui/avatar.tsx +108 -0
- package/template/src/components/ui/badge.tsx +47 -0
- package/template/src/components/ui/button.tsx +63 -0
- package/template/src/components/ui/card.tsx +60 -0
- package/template/src/components/ui/checkbox.tsx +31 -0
- package/template/src/components/ui/collapsible.tsx +33 -0
- package/template/src/components/ui/command.tsx +181 -0
- package/template/src/components/ui/dialog.tsx +157 -0
- package/template/src/components/ui/dropdown-menu.tsx +254 -0
- package/template/src/components/ui/form.tsx +141 -0
- package/template/src/components/ui/input.tsx +20 -0
- package/template/src/components/ui/label.tsx +23 -0
- package/template/src/components/ui/pagination.tsx +127 -0
- package/template/src/components/ui/popover.tsx +41 -0
- package/template/src/components/ui/select.tsx +187 -0
- package/template/src/components/ui/separator.tsx +25 -0
- package/template/src/components/ui/sheet.tsx +142 -0
- package/template/src/components/ui/sidebar.tsx +878 -0
- package/template/src/components/ui/skeleton.tsx +13 -0
- package/template/src/components/ui/sonner.tsx +33 -0
- package/template/src/components/ui/tooltip.tsx +54 -0
- package/template/src/config/RuntimeConfigErrorPage.tsx +48 -0
- package/template/src/config/appConfig.ts +126 -0
- package/template/src/config/buildInfo.ts +8 -0
- package/template/src/config/observabilityAdapter.ts +8 -0
- package/template/src/config/runtimeConfig.ts +360 -0
- package/template/src/config/types.ts +195 -0
- package/template/src/context/ThemeProvider.tsx +84 -0
- package/template/src/context/UnsavedChangesProvider.tsx +123 -0
- package/template/src/context/applicationScope.ts +39 -0
- package/template/src/context/types.ts +41 -0
- package/template/src/dataMasking/index.ts +14 -0
- package/template/src/dataMasking/masking.ts +139 -0
- package/template/src/dataMasking/types.ts +144 -0
- package/template/src/featureFlags/FeatureFlagProvider.tsx +143 -0
- package/template/src/featureFlags/FeatureGate.tsx +12 -0
- package/template/src/featureFlags/catalog.ts +140 -0
- package/template/src/featureFlags/errors.ts +17 -0
- package/template/src/featureFlags/index.ts +43 -0
- package/template/src/featureFlags/query.ts +103 -0
- package/template/src/featureFlags/registry.ts +149 -0
- package/template/src/featureFlags/scope.ts +27 -0
- package/template/src/featureFlags/types.ts +241 -0
- package/template/src/features/auth/AuthLayout.tsx +17 -0
- package/template/src/features/auth/index.ts +2 -0
- package/template/src/features/auth/signIn/components/UserAuthForm.tsx +121 -0
- package/template/src/features/auth/signIn/index.tsx +71 -0
- package/template/src/features/auth/signIn/messages.ts +37 -0
- package/template/src/features/auth/signIn/types.ts +4 -0
- package/template/src/features/errors/ForbiddenError.tsx +34 -0
- package/template/src/features/errors/GeneralError.tsx +46 -0
- package/template/src/features/errors/MaintenanceError.tsx +31 -0
- package/template/src/features/errors/NotFoundError.tsx +34 -0
- package/template/src/features/errors/RouteError.tsx +72 -0
- package/template/src/features/errors/UnauthorizedError.tsx +34 -0
- package/template/src/features/errors/index.ts +6 -0
- package/template/src/features/errors/messages.ts +56 -0
- package/template/src/features/home/index.tsx +107 -0
- package/template/src/features/home/messages.ts +59 -0
- package/template/src/features/showcase/AccessShowcasePage.tsx +284 -0
- package/template/src/features/showcase/AdvancedTableDemo.tsx +120 -0
- package/template/src/features/showcase/FeedbackShowcasePage.tsx +142 -0
- package/template/src/features/showcase/FileShowcasePage.tsx +110 -0
- package/template/src/features/showcase/FormShowcasePage.tsx +156 -0
- package/template/src/features/showcase/MetadataShowcasePage.tsx +241 -0
- package/template/src/features/showcase/ShowcasePageHeader.tsx +24 -0
- package/template/src/features/showcase/TableShowcasePage.tsx +436 -0
- package/template/src/features/showcase/accessMessages.ts +67 -0
- package/template/src/features/showcase/index.ts +6 -0
- package/template/src/features/showcase/messages.ts +192 -0
- package/template/src/files/download.ts +82 -0
- package/template/src/files/errors.ts +15 -0
- package/template/src/files/filename.ts +61 -0
- package/template/src/files/index.ts +38 -0
- package/template/src/files/types.ts +299 -0
- package/template/src/files/useFileTask.ts +153 -0
- package/template/src/files/useFileUpload.ts +117 -0
- package/template/src/files/validation.ts +109 -0
- package/template/src/layouts/AppLayout.tsx +37 -0
- package/template/src/lib/accessControl.ts +42 -0
- package/template/src/lib/navigationRedirect.ts +26 -0
- package/template/src/lib/utils.ts +6 -0
- package/template/src/locale/LocaleProvider.tsx +37 -0
- package/template/src/locale/context.ts +15 -0
- package/template/src/locale/formatters.ts +123 -0
- package/template/src/locale/hooks.ts +35 -0
- package/template/src/locale/index.ts +17 -0
- package/template/src/locale/messages.ts +151 -0
- package/template/src/locale/types.ts +167 -0
- package/template/src/main.tsx +5 -0
- package/template/src/observability/browser.ts +37 -0
- package/template/src/observability/consoleAdapter.ts +18 -0
- package/template/src/observability/index.ts +26 -0
- package/template/src/observability/observer.ts +118 -0
- package/template/src/observability/redaction.ts +85 -0
- package/template/src/observability/types.ts +119 -0
- package/template/src/optionalEditors/controller.ts +327 -0
- package/template/src/optionalEditors/errors.ts +21 -0
- package/template/src/optionalEditors/index.ts +35 -0
- package/template/src/optionalEditors/model.ts +253 -0
- package/template/src/optionalEditors/react.ts +89 -0
- package/template/src/optionalEditors/types.ts +254 -0
- package/template/src/permissions/index.ts +3 -0
- package/template/src/permissions/types.ts +5 -0
- package/template/src/permissions/usePermission.ts +16 -0
- package/template/src/realtimeCollaboration/controller.ts +355 -0
- package/template/src/realtimeCollaboration/errors.ts +20 -0
- package/template/src/realtimeCollaboration/index.ts +39 -0
- package/template/src/realtimeCollaboration/model.ts +212 -0
- package/template/src/realtimeCollaboration/react.ts +72 -0
- package/template/src/realtimeCollaboration/types.ts +251 -0
- package/template/src/reporting/errors.ts +21 -0
- package/template/src/reporting/generation.ts +87 -0
- package/template/src/reporting/index.ts +42 -0
- package/template/src/reporting/model.ts +373 -0
- package/template/src/reporting/print.ts +16 -0
- package/template/src/reporting/query.ts +50 -0
- package/template/src/reporting/react.ts +17 -0
- package/template/src/reporting/source.ts +13 -0
- package/template/src/reporting/types.ts +219 -0
- package/template/src/router/RootRouteLayout.tsx +11 -0
- package/template/src/router/authLifecycle.ts +39 -0
- package/template/src/router/config.ts +293 -0
- package/template/src/router/interceptors.ts +48 -0
- package/template/src/router/lazyRouteComponents.ts +78 -0
- package/template/src/router/messages.ts +48 -0
- package/template/src/router/navigation.ts +167 -0
- package/template/src/router/router.ts +66 -0
- package/template/src/router/searchSchemas.ts +9 -0
- package/template/src/router/types.ts +76 -0
- package/template/src/stores/authSessionStorage.ts +27 -0
- package/template/src/stores/authStore.ts +165 -0
- package/template/src/stores/types.ts +36 -0
- package/template/src/stores/uiPreferenceStore.ts +34 -0
- package/template/src/styles/index.css +141 -0
- package/template/src/styles/theme.css +213 -0
- package/template/src/tenantWorkspace/TenantWorkspaceProvider.tsx +102 -0
- package/template/src/tenantWorkspace/index.ts +33 -0
- package/template/src/tenantWorkspace/store.ts +184 -0
- package/template/src/tenantWorkspace/switch.ts +206 -0
- package/template/src/tenantWorkspace/types.ts +155 -0
- package/template/src/vite-env.d.ts +20 -0
- package/template/stylelint.config.js +28 -0
- package/template/tests/integration/Application.test.tsx +269 -0
- package/template/tests/integration/layout/AppHeader.test.tsx +182 -0
- package/template/tests/integration/layout/AppSidebar.test.tsx +121 -0
- package/template/tests/integration/layout/__screenshots__/AppHeader.test.tsx/AppHeader-command-search-hides-the-duplicate-header-trigger-when-the-desktop-sidebar-collapses-1.png +0 -0
- package/template/tests/integration/router/__screenshots__/config.test.ts/route-tree-authentication-boundaries-exposes-only-scaffold-navigation-metadata-1.png +0 -0
- package/template/tests/integration/router/config.test.ts +123 -0
- package/template/tests/integration/router/interceptors.test.ts +100 -0
- package/template/tests/setup/accessibility.ts +25 -0
- package/template/tests/setup/runtimeConfig.ts +3 -0
- package/template/tests/unit/api/ApiError.test.ts +25 -0
- package/template/tests/unit/api/__screenshots__/authSession.test.ts/administrator-authentication-clears-the-session-if-a-refresh-identity-loses-administrator-access-1.png +0 -0
- package/template/tests/unit/api/__screenshots__/authSession.test.ts/administrator-authentication-creates-a-session-from-the-generated-login-response-for-an-admin-1.png +0 -0
- package/template/tests/unit/api/__screenshots__/authSession.test.ts/administrator-authentication-rejects-and-revokes-the-generated-login-result-for-an-ordinary-user-1.png +0 -0
- package/template/tests/unit/api/activity/ActivityProvider.test.tsx +131 -0
- package/template/tests/unit/api/activity/__screenshots__/transports.test.ts/activity-transport-adapters-polls-sequentially-and-advances-the-last-event-ID-1.png +0 -0
- package/template/tests/unit/api/activity/modelAndQuery.test.ts +144 -0
- package/template/tests/unit/api/activity/subscription.test.ts +103 -0
- package/template/tests/unit/api/activity/transports.test.ts +145 -0
- package/template/tests/unit/api/authClient.test.ts +110 -0
- package/template/tests/unit/api/authSession.test.ts +289 -0
- package/template/tests/unit/api/clients/configureApiClient.test.ts +198 -0
- package/template/tests/unit/api/demoAuthClient.test.ts +47 -0
- package/template/tests/unit/api/enums/access.test.ts +107 -0
- package/template/tests/unit/api/enums/catalog.test.ts +200 -0
- package/template/tests/unit/api/enums/query.test.ts +110 -0
- package/template/tests/unit/api/enums/useEnum.test.tsx +98 -0
- package/template/tests/unit/api/enums/useEnumCatalog.test.tsx +68 -0
- package/template/tests/unit/api/hooks/error.test.ts +168 -0
- package/template/tests/unit/api/hooks/request.test.ts +170 -0
- package/template/tests/unit/api/hooks/response.test.ts +46 -0
- package/template/tests/unit/api/metadata/MetadataProvider.test.tsx +102 -0
- package/template/tests/unit/api/parameters/catalog.test.ts +147 -0
- package/template/tests/unit/api/parameters/query.test.ts +78 -0
- package/template/tests/unit/api/parameters/useGlobalParameter.test.tsx +89 -0
- package/template/tests/unit/api/query/queryPolicy.test.ts +245 -0
- package/template/tests/unit/api/query/useAppQueryScope.test.tsx +74 -0
- package/template/tests/unit/auditLogs/auditLogHooks.test.tsx +194 -0
- package/template/tests/unit/auditLogs/auditLogs.test.ts +199 -0
- package/template/tests/unit/authentication/__screenshots__/authentication.test.ts/authentication-controller-completes-Step-up-callbacks-without-creating-a-second-login-result-1.png +0 -0
- package/template/tests/unit/authentication/__screenshots__/authentication.test.ts/authentication-controller-moves-from-challenge-to-completion-without-retaining-tokens-in-snapshot-1.png +0 -0
- package/template/tests/unit/authentication/authentication.test.ts +376 -0
- package/template/tests/unit/components/AppDialog.test.tsx +225 -0
- package/template/tests/unit/components/AppTable.test.tsx +129 -0
- package/template/tests/unit/components/AppTableLayoutTransition.test.ts +118 -0
- package/template/tests/unit/components/AppTableLocalization.test.ts +58 -0
- package/template/tests/unit/components/AppTableSensitiveData.test.ts +35 -0
- package/template/tests/unit/components/AppTableUpgrade.test.tsx +179 -0
- package/template/tests/unit/components/AppTableUpgradeCore.test.ts +258 -0
- package/template/tests/unit/components/BrandLogo.test.tsx +24 -0
- package/template/tests/unit/components/Can.test.tsx +80 -0
- package/template/tests/unit/components/Dialog.test.tsx +56 -0
- package/template/tests/unit/components/EnumPresentation.test.tsx +64 -0
- package/template/tests/unit/components/FilePreviewEngine.test.ts +51 -0
- package/template/tests/unit/components/JsonEditor.test.tsx +47 -0
- package/template/tests/unit/components/LocalizedSharedComponents.test.tsx +36 -0
- package/template/tests/unit/components/OverlayLayer.test.tsx +151 -0
- package/template/tests/unit/components/PageFeedback.test.tsx +143 -0
- package/template/tests/unit/components/PageForm.test.tsx +272 -0
- package/template/tests/unit/components/PageFormCore.test.ts +74 -0
- package/template/tests/unit/components/PasswordInput.test.tsx +105 -0
- package/template/tests/unit/components/ScaffoldComponents.test.tsx +64 -0
- package/template/tests/unit/components/SensitiveData.test.tsx +151 -0
- package/template/tests/unit/components/StatusBadge.test.tsx +36 -0
- package/template/tests/unit/components/TableComponent.test.tsx +644 -0
- package/template/tests/unit/components/TableCore.test.ts +145 -0
- package/template/tests/unit/components/ThemeAccessibility.test.tsx +27 -0
- package/template/tests/unit/components/__screenshots__/BatchOperationDialog.test.tsx/confirms-a-batch-action-and-presents-partial-failure-details-1.png +0 -0
- package/template/tests/unit/components/__screenshots__/PageForm.test.tsx/PageForm-writes-uploaded-values-through-the-public-file-field-and-resets-dirty-state-1.png +0 -0
- package/template/tests/unit/components/__screenshots__/PasswordInput.test.tsx/PasswordInput-toggles-the-password-visibility-when-the-show-password-button-is-clicked-1.png +0 -0
- package/template/tests/unit/components/__screenshots__/TableComponent.test.tsx/TableComponent-pins-trailing-action-columns-and-removes-their-header-menu-by-default-1.png +0 -0
- package/template/tests/unit/components/__screenshots__/TableComponent.test.tsx/TableComponent-renders-shadcn-components-through-cellComponent-1.png +0 -0
- package/template/tests/unit/components/__screenshots__/TableComponent.test.tsx/TableComponent-renders-the-toolbar-without-a-bottom-divider-1.png +0 -0
- package/template/tests/unit/components/__screenshots__/TableComponent.test.tsx/TableComponent-resyncs-adaptive-height-after-a-column-resize-changes-wrapped-row-height-1.png +0 -0
- package/template/tests/unit/config/RuntimeConfigErrorPage.test.tsx +23 -0
- package/template/tests/unit/config/appConfig.test.ts +98 -0
- package/template/tests/unit/config/appTableContracts.test.mjs +120 -0
- package/template/tests/unit/config/bundleBudget.test.mjs +190 -0
- package/template/tests/unit/config/componentGovernance.test.mjs +156 -0
- package/template/tests/unit/config/deployConfig.test.mjs +211 -0
- package/template/tests/unit/config/eslintConfig.test.mjs +101 -0
- package/template/tests/unit/config/featureBoundaries.test.mjs +126 -0
- package/template/tests/unit/config/npmPackage.test.mjs +37 -0
- package/template/tests/unit/config/releaseArtifact.test.mjs +105 -0
- package/template/tests/unit/config/runtimeConfig.test.ts +225 -0
- package/template/tests/unit/config/scaffoldCheck.test.mjs +53 -0
- package/template/tests/unit/config/scaffoldFeature.test.mjs +177 -0
- package/template/tests/unit/config/scaffoldInit.test.mjs +218 -0
- package/template/tests/unit/config/scaffoldProject.test.mjs +378 -0
- package/template/tests/unit/config/scaffoldTransaction.test.mjs +77 -0
- package/template/tests/unit/config/viteConfig.test.mjs +371 -0
- package/template/tests/unit/context/ThemeProvider.test.tsx +108 -0
- package/template/tests/unit/context/UnsavedChangesProvider.test.tsx +94 -0
- package/template/tests/unit/context/__screenshots__/ThemeProvider.test.tsx/ThemeProvider-uses-the-neutral-black-palette-for-the-app-and-scoped-table-theme-1.png +0 -0
- package/template/tests/unit/context/applicationScope.test.ts +62 -0
- package/template/tests/unit/dataMasking/dataMasking.test.ts +95 -0
- package/template/tests/unit/featureFlags/featureFlags.test.ts +169 -0
- package/template/tests/unit/featureFlags/useFeatureFlag.test.tsx +108 -0
- package/template/tests/unit/features/FeatureLocalization.test.tsx +54 -0
- package/template/tests/unit/features/RouteError.test.tsx +40 -0
- package/template/tests/unit/features/auth/signIn/UserAuthForm.test.tsx +79 -0
- package/template/tests/unit/features/auth/signIn/__screenshots__/UserAuthForm.test.tsx/UserAuthForm-passes-validated-values-to-onSubmit-1.png +0 -0
- package/template/tests/unit/features/auth/signIn/__screenshots__/UserAuthForm.test.tsx/UserAuthForm-shows-validation-messages-when-submitting-an-empty-form-1.png +0 -0
- package/template/tests/unit/files/fileHooks.test.tsx +130 -0
- package/template/tests/unit/files/files.test.ts +112 -0
- package/template/tests/unit/lib/accessControl.test.ts +69 -0
- package/template/tests/unit/locale/locale.test.tsx +90 -0
- package/template/tests/unit/observability/browser.test.ts +48 -0
- package/template/tests/unit/observability/observer.test.ts +115 -0
- package/template/tests/unit/optionalEditors/__screenshots__/useOptionalEditor.test.tsx/useOptionalEditor-fails-permission-precheck-before-loading-the-project-SDK-1.png +0 -0
- package/template/tests/unit/optionalEditors/__screenshots__/useOptionalEditor.test.tsx/useOptionalEditor-mounts-a-route-scoped-SDK-into-the-dedicated-host-with-permission-1.png +0 -0
- package/template/tests/unit/optionalEditors/optionalEditors.test.ts +313 -0
- package/template/tests/unit/optionalEditors/useOptionalEditor.test.tsx +141 -0
- package/template/tests/unit/realtimeCollaboration/collaboration.test.ts +240 -0
- package/template/tests/unit/realtimeCollaboration/useRealtimeCollaboration.test.tsx +115 -0
- package/template/tests/unit/reporting/reporting.test.ts +195 -0
- package/template/tests/unit/reporting/reportingHooks.test.tsx +203 -0
- package/template/tests/unit/router/authLifecycle.test.ts +55 -0
- package/template/tests/unit/router/navigation.test.ts +55 -0
- package/template/tests/unit/router/redirects.test.ts +22 -0
- package/template/tests/unit/scaffoldFeatureTemplate/featureTemplate.test.ts +42 -0
- package/template/tests/unit/scaffoldFeatureTemplate/publicContract.test.ts +28 -0
- package/template/tests/unit/scaffoldFeatureTemplate/queries.test.tsx +289 -0
- package/template/tests/unit/stores/authStore.test.ts +128 -0
- package/template/tests/unit/stores/uiPreferenceStore.test.ts +56 -0
- package/template/tests/unit/tenantWorkspace/tenantWorkspace.test.tsx +261 -0
- package/template/tools/bundle/budgets.json +48 -0
- package/template/tools/bundle/check.mjs +307 -0
- package/template/tools/component-governance/check.mjs +703 -0
- package/template/tools/component-governance/manifest.json +112 -0
- package/template/tools/deployment/browser-smoke.mjs +76 -0
- package/template/tools/deployment/browser-smoke.sh +141 -0
- package/template/tools/openapi/generate.mjs +268 -0
- package/template/tools/openapi/templates/README.md +14 -0
- package/template/tools/openapi/templates/base/README.md +7 -0
- package/template/tools/openapi/templates/base/data-contracts.eta +44 -0
- package/template/tools/openapi/templates/base/http-client.eta +3 -0
- package/template/tools/openapi/templates/base/http-clients/axios-http-client.eta +132 -0
- package/template/tools/openapi/templates/base/http-clients/fetch-http-client.eta +220 -0
- package/template/tools/openapi/templates/base/route-docs.eta +31 -0
- package/template/tools/openapi/templates/base/route-name.eta +43 -0
- package/template/tools/openapi/templates/base/route-type.eta +22 -0
- package/template/tools/openapi/templates/default/README.md +7 -0
- package/template/tools/openapi/templates/default/api.eta +67 -0
- package/template/tools/openapi/templates/default/http-client.eta +137 -0
- package/template/tools/openapi/templates/default/procedure-call.eta +99 -0
- package/template/tools/openapi/templates/default/route-docs.eta +40 -0
- package/template/tools/openapi/templates/default/route-types.eta +28 -0
- package/template/tools/openapi/templates/modular/README.md +7 -0
- package/template/tools/openapi/templates/modular/api.eta +28 -0
- package/template/tools/openapi/templates/modular/procedure-call.eta +99 -0
- package/template/tools/openapi/templates/modular/route-types.eta +18 -0
- package/template/tools/release/artifact.mjs +258 -0
- package/template/tools/scaffold/add-capability.mjs +409 -0
- package/template/tools/scaffold/capability-catalog.json +163 -0
- package/template/tools/scaffold/check.mjs +326 -0
- package/template/tools/scaffold/create-feature.mjs +444 -0
- package/template/tools/scaffold/create-project.mjs +482 -0
- package/template/tools/scaffold/init.example.json +64 -0
- package/template/tools/scaffold/init.mjs +419 -0
- package/template/tools/scaffold/lockfile.mjs +193 -0
- package/template/tools/scaffold/templates/feature/index.ts +19 -0
- package/template/tools/scaffold/templates/feature/model.ts +142 -0
- package/template/tools/scaffold/templates/feature/queries.ts +154 -0
- package/template/tools/scaffold/templates/feature/repository.ts +206 -0
- package/template/tools/scaffold/templates/feature/types.ts +168 -0
- package/template/tools/scaffold/workspace-transaction.mjs +111 -0
- package/template/tsconfig.app.json +31 -0
- package/template/tsconfig.json +12 -0
- package/template/tsconfig.node.json +24 -0
- package/template/vite.config.ts +121 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { TableColumn } from '../../../columns/column'
|
|
2
|
+
import type { TableRow } from '../../../shared/types'
|
|
3
|
+
import type { TableCellContext } from '../../types'
|
|
4
|
+
import { setTableElementTooltip } from '../tooltip'
|
|
5
|
+
import { resolveTableStepLabels } from './display'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 渲染 step 单元格,把业务步骤排列为带方向分隔符的紧凑流程;单个步骤文本
|
|
9
|
+
* 被截断时通过共享浮层显示完整内容。
|
|
10
|
+
*/
|
|
11
|
+
export const renderTableSteps = <T extends TableRow>(
|
|
12
|
+
td: HTMLTableCellElement,
|
|
13
|
+
column: TableColumn<T>,
|
|
14
|
+
context: TableCellContext<T>
|
|
15
|
+
) => {
|
|
16
|
+
td.replaceChildren()
|
|
17
|
+
const container = document.createElement('div')
|
|
18
|
+
container.className = 'table-component__steps'
|
|
19
|
+
const groups = column.step?.resolve(context) ?? []
|
|
20
|
+
resolveTableStepLabels(groups, column.step?.labelKey).forEach(
|
|
21
|
+
(label, index, labels) => {
|
|
22
|
+
const item = document.createElement('span')
|
|
23
|
+
item.className = 'table-component__step'
|
|
24
|
+
item.textContent = label
|
|
25
|
+
setTableElementTooltip(item, label)
|
|
26
|
+
container.append(item)
|
|
27
|
+
if (index < labels.length - 1) {
|
|
28
|
+
const separator = document.createElement('span')
|
|
29
|
+
separator.className = 'table-component__step-separator'
|
|
30
|
+
separator.textContent = '→'
|
|
31
|
+
separator.setAttribute('aria-hidden', 'true')
|
|
32
|
+
container.append(separator)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
)
|
|
36
|
+
td.append(container)
|
|
37
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { TableColumn } from '../../../columns/column'
|
|
2
|
+
import type { TableRow } from '../../../shared/types'
|
|
3
|
+
import type { TableCellContext } from '../../types'
|
|
4
|
+
import type { TableRendererOptions } from '../types'
|
|
5
|
+
import { resolveTableSwitchChecked, toggleTableSwitchValue } from './display'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 渲染 switch 单元格,使用具备 ARIA switch 语义的原生按钮展示布尔状态,
|
|
9
|
+
* 点击后通过表格事务更新值并触发列级 onChange。
|
|
10
|
+
*/
|
|
11
|
+
export const renderTableSwitchCell = <T extends TableRow>(options: {
|
|
12
|
+
td: HTMLTableCellElement
|
|
13
|
+
column: TableColumn<T>
|
|
14
|
+
context: TableCellContext<T>
|
|
15
|
+
cellProperties: { readOnly?: boolean }
|
|
16
|
+
rendererOptions: TableRendererOptions
|
|
17
|
+
}) => {
|
|
18
|
+
const { td, column, context, cellProperties, rendererOptions } = options
|
|
19
|
+
td.replaceChildren()
|
|
20
|
+
td.classList.add('htCenter')
|
|
21
|
+
const control = document.createElement('button')
|
|
22
|
+
const checked = resolveTableSwitchChecked(context.value)
|
|
23
|
+
control.type = 'button'
|
|
24
|
+
control.className = 'table-component__switch'
|
|
25
|
+
control.setAttribute('role', 'switch')
|
|
26
|
+
control.setAttribute('aria-checked', String(checked))
|
|
27
|
+
control.setAttribute(
|
|
28
|
+
'aria-label',
|
|
29
|
+
rendererOptions.messages.fnSwitchAriaLabel(column.label, checked)
|
|
30
|
+
)
|
|
31
|
+
control.disabled = Boolean(cellProperties.readOnly)
|
|
32
|
+
if (checked) control.classList.add('is-checked')
|
|
33
|
+
const thumb = document.createElement('span')
|
|
34
|
+
thumb.className = 'table-component__switch-thumb'
|
|
35
|
+
thumb.setAttribute('aria-hidden', 'true')
|
|
36
|
+
control.append(thumb)
|
|
37
|
+
control.onmousedown = (event) => event.stopPropagation()
|
|
38
|
+
control.onclick = (event) => {
|
|
39
|
+
event.stopPropagation()
|
|
40
|
+
const nextValue = toggleTableSwitchValue(context.value)
|
|
41
|
+
rendererOptions.updateCell(context.visualRow, String(column.key), nextValue)
|
|
42
|
+
column.onChange?.(nextValue, { ...context, value: nextValue })
|
|
43
|
+
}
|
|
44
|
+
td.append(control)
|
|
45
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './renderer'
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { TableColumn } from '../../../columns/column'
|
|
2
|
+
import type { TableRow } from '../../../shared/types'
|
|
3
|
+
import type { TableCellContext } from '../../types'
|
|
4
|
+
import {
|
|
5
|
+
beginTableCellEditing,
|
|
6
|
+
bindTableCellEditorTrigger,
|
|
7
|
+
} from '../editors/editorTrigger'
|
|
8
|
+
import type { TableRendererOptions } from '../types'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* 渲染 select 和 multiSelect 的选项标签,并为可编辑单元格绑定打开选择浮层的
|
|
12
|
+
* 触发器;远程选项加载和实际选择器 UI 由框架适配层负责。
|
|
13
|
+
*/
|
|
14
|
+
export const renderTableSelectCell = <T extends TableRow>(options: {
|
|
15
|
+
td: HTMLTableCellElement
|
|
16
|
+
column: TableColumn<T>
|
|
17
|
+
displayValue: unknown
|
|
18
|
+
context: TableCellContext<T>
|
|
19
|
+
cellProperties: { readOnly?: boolean }
|
|
20
|
+
rendererOptions: TableRendererOptions
|
|
21
|
+
}) => {
|
|
22
|
+
const { td, column, displayValue, context, cellProperties, rendererOptions } =
|
|
23
|
+
options
|
|
24
|
+
td.textContent = String(displayValue ?? '')
|
|
25
|
+
if (cellProperties.readOnly) return
|
|
26
|
+
const open = (event: MouseEvent) => beginTableCellEditing(context, event)
|
|
27
|
+
bindTableCellEditorTrigger(
|
|
28
|
+
td,
|
|
29
|
+
column.editorTrigger ?? 'doubleClick',
|
|
30
|
+
open,
|
|
31
|
+
rendererOptions.messages
|
|
32
|
+
)
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './tooltip'
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { TableCellLayerAdapter } from '../types'
|
|
2
|
+
|
|
3
|
+
const tableCellTooltipValues = new WeakMap<HTMLTableCellElement, string>()
|
|
4
|
+
const TABLE_ELEMENT_TOOLTIP_ATTRIBUTE = 'data-table-cell-tooltip'
|
|
5
|
+
|
|
6
|
+
/** 交互 renderer 可把提示绑定到真正发生截断的子元素,而不是整个 TD。 */
|
|
7
|
+
export const setTableElementTooltip = (
|
|
8
|
+
element: HTMLElement,
|
|
9
|
+
displayValue: unknown
|
|
10
|
+
) => {
|
|
11
|
+
if (displayValue === undefined) {
|
|
12
|
+
element.removeAttribute(TABLE_ELEMENT_TOOLTIP_ATTRIBUTE)
|
|
13
|
+
} else {
|
|
14
|
+
element.setAttribute(
|
|
15
|
+
TABLE_ELEMENT_TOOLTIP_ATTRIBUTE,
|
|
16
|
+
String(displayValue ?? '')
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const setTableCellTooltip = (
|
|
22
|
+
td: HTMLTableCellElement,
|
|
23
|
+
displayValue: unknown
|
|
24
|
+
) => {
|
|
25
|
+
if (!td.classList.contains('table-component__cell')) {
|
|
26
|
+
td.classList.add('table-component__cell')
|
|
27
|
+
}
|
|
28
|
+
if (displayValue === undefined) tableCellTooltipValues.delete(td)
|
|
29
|
+
else tableCellTooltipValues.set(td, String(displayValue ?? ''))
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** 一张表只注册一组冒泡事件,仅在文字实际截断时展示 tooltip。 */
|
|
33
|
+
export const attachTableCellTooltip = (
|
|
34
|
+
host: HTMLElement,
|
|
35
|
+
layer: TableCellLayerAdapter
|
|
36
|
+
) => {
|
|
37
|
+
let activeTarget: HTMLElement | undefined
|
|
38
|
+
const resolveCell = (target: EventTarget | null) =>
|
|
39
|
+
target instanceof Element
|
|
40
|
+
? target.closest<HTMLTableCellElement>('td.table-component__cell')
|
|
41
|
+
: null
|
|
42
|
+
const resolveTarget = (target: EventTarget | null) => {
|
|
43
|
+
const cell = resolveCell(target)
|
|
44
|
+
if (!cell || !host.contains(cell)) return
|
|
45
|
+
const elementTarget =
|
|
46
|
+
target instanceof Element
|
|
47
|
+
? target.closest<HTMLElement>(`[${TABLE_ELEMENT_TOOLTIP_ATTRIBUTE}]`)
|
|
48
|
+
: null
|
|
49
|
+
if (elementTarget && cell.contains(elementTarget)) {
|
|
50
|
+
return {
|
|
51
|
+
element: elementTarget,
|
|
52
|
+
value: elementTarget.getAttribute(TABLE_ELEMENT_TOOLTIP_ATTRIBUTE),
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return { element: cell, value: tableCellTooltipValues.get(cell) }
|
|
56
|
+
}
|
|
57
|
+
const showForTarget = (eventTarget: EventTarget | null) => {
|
|
58
|
+
const target = resolveTarget(eventTarget)
|
|
59
|
+
if (!target || target.element === activeTarget) return
|
|
60
|
+
if (activeTarget) layer.hideTooltip()
|
|
61
|
+
activeTarget = target.element
|
|
62
|
+
if (
|
|
63
|
+
target.value !== undefined &&
|
|
64
|
+
target.value !== null &&
|
|
65
|
+
target.element.scrollWidth > target.element.clientWidth
|
|
66
|
+
) {
|
|
67
|
+
layer.showTooltip(target.value, target.element)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const hideForTarget = (relatedTarget: EventTarget | null) => {
|
|
71
|
+
if (!activeTarget) return
|
|
72
|
+
const next = resolveTarget(relatedTarget)
|
|
73
|
+
if (next?.element === activeTarget) return
|
|
74
|
+
activeTarget = undefined
|
|
75
|
+
layer.hideTooltip()
|
|
76
|
+
}
|
|
77
|
+
const onPointerOver = (event: PointerEvent) => showForTarget(event.target)
|
|
78
|
+
const onPointerOut = (event: PointerEvent) =>
|
|
79
|
+
hideForTarget(event.relatedTarget)
|
|
80
|
+
const onFocusIn = (event: FocusEvent) => showForTarget(event.target)
|
|
81
|
+
const onFocusOut = (event: FocusEvent) => hideForTarget(event.relatedTarget)
|
|
82
|
+
host.addEventListener('pointerover', onPointerOver)
|
|
83
|
+
host.addEventListener('pointerout', onPointerOut)
|
|
84
|
+
host.addEventListener('focusin', onFocusIn)
|
|
85
|
+
host.addEventListener('focusout', onFocusOut)
|
|
86
|
+
return () => {
|
|
87
|
+
host.removeEventListener('pointerover', onPointerOver)
|
|
88
|
+
host.removeEventListener('pointerout', onPointerOut)
|
|
89
|
+
host.removeEventListener('focusin', onFocusIn)
|
|
90
|
+
host.removeEventListener('focusout', onFocusOut)
|
|
91
|
+
if (activeTarget) layer.hideTooltip()
|
|
92
|
+
activeTarget = undefined
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { TableEngineMessages } from '../../shared/messages'
|
|
2
|
+
import type { TableOption, TableRow } from '../../shared/types'
|
|
3
|
+
import type { TableValueFormat } from '../formatting'
|
|
4
|
+
import type { TableOptionCachePolicy, TableOptionSource } from '../options'
|
|
5
|
+
import type { TableAction, TableCellContext } from '../types'
|
|
6
|
+
|
|
7
|
+
/** 框架适配层可原样交给第三方编辑组件的属性与原生 attrs。 */
|
|
8
|
+
export type TableCellComponentProps = Readonly<Record<string, unknown>>
|
|
9
|
+
|
|
10
|
+
/** 日期、时间和日期时间 renderer 共享的稳定类型。 */
|
|
11
|
+
export type TableTemporalType = 'date' | 'time' | 'datetime'
|
|
12
|
+
|
|
13
|
+
/** 日期、时间和日期时间 renderer 的单一运行时判定入口。 */
|
|
14
|
+
export const isTableTemporalType = (
|
|
15
|
+
value: unknown
|
|
16
|
+
): value is TableTemporalType =>
|
|
17
|
+
value === 'date' || value === 'time' || value === 'datetime'
|
|
18
|
+
|
|
19
|
+
/** engine 自定义单元格调用 React 浮层的最小运行时端口。 */
|
|
20
|
+
export interface TableCellLayerAdapter {
|
|
21
|
+
openSelect<T extends TableRow>(options: {
|
|
22
|
+
rect: DOMRect
|
|
23
|
+
value: unknown
|
|
24
|
+
componentProps?: TableCellComponentProps
|
|
25
|
+
multiple?: boolean
|
|
26
|
+
clearable?: boolean
|
|
27
|
+
multipleLimit?: number
|
|
28
|
+
searchable?: boolean
|
|
29
|
+
collapseTags?: boolean
|
|
30
|
+
maxCollapseTags?: number
|
|
31
|
+
row: T
|
|
32
|
+
columnKey: string
|
|
33
|
+
source?: TableOptionSource<T>
|
|
34
|
+
cache?: TableOptionCachePolicy<T>
|
|
35
|
+
debounceMs?: number
|
|
36
|
+
placeholder?: string
|
|
37
|
+
onOptionsLoaded?: (options: readonly TableOption[]) => void
|
|
38
|
+
preview?: (
|
|
39
|
+
value: unknown,
|
|
40
|
+
option?: TableOption | readonly TableOption[]
|
|
41
|
+
) => void
|
|
42
|
+
commit: (
|
|
43
|
+
value: unknown,
|
|
44
|
+
option?: TableOption | readonly TableOption[]
|
|
45
|
+
) => void
|
|
46
|
+
cancel?: (options?: { restoreFocus?: boolean }) => void
|
|
47
|
+
}): void | Promise<void>
|
|
48
|
+
searchSelect(query: string): void | Promise<void>
|
|
49
|
+
getOptionLabel(columnKey: string, value: unknown): string | undefined
|
|
50
|
+
clearOptionCache(columnKey?: string): void
|
|
51
|
+
openDate(options: {
|
|
52
|
+
rect: DOMRect
|
|
53
|
+
value: unknown
|
|
54
|
+
componentProps?: TableCellComponentProps
|
|
55
|
+
type?: TableTemporalType
|
|
56
|
+
commit: (value: unknown) => void
|
|
57
|
+
cancel?: (options?: { restoreFocus?: boolean }) => void
|
|
58
|
+
}): void
|
|
59
|
+
openActionMenu<T extends TableRow>(options: {
|
|
60
|
+
anchor: HTMLElement
|
|
61
|
+
actions: TableAction<T>[]
|
|
62
|
+
context: TableCellContext<T>
|
|
63
|
+
}): void
|
|
64
|
+
/** 将单元格业务动作的同步异常和 Promise 拒绝交给框架错误边界。 */
|
|
65
|
+
reportActionError(error: unknown): void
|
|
66
|
+
showTooltip(content: string, anchor: HTMLElement): void
|
|
67
|
+
hideTooltip(): void
|
|
68
|
+
close(options?: { cancel?: boolean; restoreFocus?: boolean }): void
|
|
69
|
+
destroy(): void
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** 自定义 renderer 从网格组合器获得的稳定运行时依赖。 */
|
|
73
|
+
export interface TableRendererOptions {
|
|
74
|
+
/** 通过控制器事务更新指定行列值。 */
|
|
75
|
+
updateCell: (rowIndex: number, key: string, value: unknown) => void
|
|
76
|
+
/** 框架提供的浮层适配器。 */
|
|
77
|
+
layer: TableCellLayerAdapter
|
|
78
|
+
/** 使用统一 locale、时区和格式声明转换显示值。 */
|
|
79
|
+
formatValue: (value: unknown, format?: TableValueFormat) => unknown
|
|
80
|
+
/** 纯 DOM renderer 使用的可见文案与无障碍名称。 */
|
|
81
|
+
messages: TableEngineMessages
|
|
82
|
+
}
|
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
import { TABLE_CELL_DEFAULTS } from './constants'
|
|
2
|
+
|
|
3
|
+
type TableLocale = string | string[]
|
|
4
|
+
|
|
5
|
+
export interface TableFormatBase {
|
|
6
|
+
/** null、undefined 和空字符串的展示值,默认为空字符串。 */
|
|
7
|
+
emptyText?: string
|
|
8
|
+
/** 无效数字或日期的展示值,默认保留原值。 */
|
|
9
|
+
invalidText?: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface TableNumberFormat extends TableFormatBase {
|
|
13
|
+
/** 使用 Intl.NumberFormat 的普通数字格式。 */
|
|
14
|
+
type: 'number'
|
|
15
|
+
/** 透传给 Intl.NumberFormat 的数字选项。 */
|
|
16
|
+
options?: Intl.NumberFormatOptions
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface TableCurrencyFormat extends TableFormatBase {
|
|
20
|
+
/** 使用 Intl.NumberFormat 的货币格式。 */
|
|
21
|
+
type: 'currency'
|
|
22
|
+
/** ISO 4217 货币代码,例如 CNY、USD。 */
|
|
23
|
+
currency: string
|
|
24
|
+
/** 除 style/currency 外透传给 Intl.NumberFormat 的选项。 */
|
|
25
|
+
options?: Omit<Intl.NumberFormatOptions, 'style' | 'currency'>
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface TablePercentFormat extends TableFormatBase {
|
|
29
|
+
/** 使用 Intl.NumberFormat 的百分比格式。 */
|
|
30
|
+
type: 'percent'
|
|
31
|
+
/** Intl 要求传入比例值(0.12 表示 12%);数值为 12 时应启用 percentage。 */
|
|
32
|
+
valueScale?: 'ratio' | 'percentage'
|
|
33
|
+
/** 除 style 外透传给 Intl.NumberFormat 的选项。 */
|
|
34
|
+
options?: Omit<Intl.NumberFormatOptions, 'style'>
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface TableDateTimeFormat extends TableFormatBase {
|
|
38
|
+
/** 日期、时间或日期时间展示类型。 */
|
|
39
|
+
type: 'date' | 'time' | 'datetime'
|
|
40
|
+
/** 透传给 Intl.DateTimeFormat 的展示选项。 */
|
|
41
|
+
options?: Intl.DateTimeFormatOptions
|
|
42
|
+
/** 为时间戳值覆盖表格级时区。 */
|
|
43
|
+
timeZone?: string
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export type TableValueFormat =
|
|
47
|
+
| TableNumberFormat
|
|
48
|
+
| TableCurrencyFormat
|
|
49
|
+
| TablePercentFormat
|
|
50
|
+
| TableDateTimeFormat
|
|
51
|
+
|
|
52
|
+
interface TableIntlFormatterOptions {
|
|
53
|
+
/** BCP 47 区域语言或优先级列表。 */
|
|
54
|
+
locale?: TableLocale
|
|
55
|
+
/** 默认 IANA 时区。 */
|
|
56
|
+
timeZone?: string
|
|
57
|
+
/** 数字和日期格式化器的实例级 LRU 最大条目数,默认 100。 */
|
|
58
|
+
maxCacheEntries?: number
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
interface TemporalValue {
|
|
62
|
+
date: Date
|
|
63
|
+
/** 纯日期、纯时间和不含偏移量的日期时间字符串均视为墙上时间。 */
|
|
64
|
+
wallClock: boolean
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const ISO_DATE = /^(\d{4})-(\d{2})-(\d{2})$/
|
|
68
|
+
const ISO_TIME = /^(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?$/
|
|
69
|
+
const ISO_FLOATING_DATETIME =
|
|
70
|
+
/^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?$/
|
|
71
|
+
|
|
72
|
+
const isValidDateParts = (
|
|
73
|
+
date: Date,
|
|
74
|
+
year: number,
|
|
75
|
+
month: number,
|
|
76
|
+
day: number,
|
|
77
|
+
hour = 0,
|
|
78
|
+
minute = 0,
|
|
79
|
+
second = 0
|
|
80
|
+
) =>
|
|
81
|
+
date.getUTCFullYear() === year &&
|
|
82
|
+
date.getUTCMonth() === month - 1 &&
|
|
83
|
+
date.getUTCDate() === day &&
|
|
84
|
+
date.getUTCHours() === hour &&
|
|
85
|
+
date.getUTCMinutes() === minute &&
|
|
86
|
+
date.getUTCSeconds() === second
|
|
87
|
+
|
|
88
|
+
const parseMilliseconds = (value?: string) =>
|
|
89
|
+
Number((value ?? '').padEnd(3, '0'))
|
|
90
|
+
|
|
91
|
+
const parseTemporalValue = (value: unknown): TemporalValue | undefined => {
|
|
92
|
+
if (value instanceof Date) {
|
|
93
|
+
return Number.isNaN(value.getTime())
|
|
94
|
+
? undefined
|
|
95
|
+
: { date: new Date(value.getTime()), wallClock: false }
|
|
96
|
+
}
|
|
97
|
+
if (typeof value === 'number') {
|
|
98
|
+
const date = new Date(value)
|
|
99
|
+
return Number.isNaN(date.getTime()) ? undefined : { date, wallClock: false }
|
|
100
|
+
}
|
|
101
|
+
if (typeof value !== 'string') return
|
|
102
|
+
const text = value.trim()
|
|
103
|
+
let match = text.match(ISO_DATE)
|
|
104
|
+
if (match) {
|
|
105
|
+
const [, yearText, monthText, dayText] = match
|
|
106
|
+
const [year, month, day] = [yearText, monthText, dayText].map(Number)
|
|
107
|
+
const date = new Date(Date.UTC(year, month - 1, day))
|
|
108
|
+
return isValidDateParts(date, year, month, day)
|
|
109
|
+
? { date, wallClock: true }
|
|
110
|
+
: undefined
|
|
111
|
+
}
|
|
112
|
+
match = text.match(ISO_TIME)
|
|
113
|
+
if (match) {
|
|
114
|
+
const [, hourText, minuteText, secondText, millisecondText] = match
|
|
115
|
+
const [hour, minute, second] = [
|
|
116
|
+
hourText,
|
|
117
|
+
minuteText,
|
|
118
|
+
secondText ?? '0',
|
|
119
|
+
].map(Number)
|
|
120
|
+
const millisecond = parseMilliseconds(millisecondText)
|
|
121
|
+
const date = new Date(
|
|
122
|
+
Date.UTC(1970, 0, 1, hour, minute, second, millisecond)
|
|
123
|
+
)
|
|
124
|
+
return isValidDateParts(date, 1970, 1, 1, hour, minute, second)
|
|
125
|
+
? { date, wallClock: true }
|
|
126
|
+
: undefined
|
|
127
|
+
}
|
|
128
|
+
match = text.match(ISO_FLOATING_DATETIME)
|
|
129
|
+
if (match) {
|
|
130
|
+
const [
|
|
131
|
+
,
|
|
132
|
+
yearText,
|
|
133
|
+
monthText,
|
|
134
|
+
dayText,
|
|
135
|
+
hourText,
|
|
136
|
+
minuteText,
|
|
137
|
+
secondText,
|
|
138
|
+
millisecondText,
|
|
139
|
+
] = match
|
|
140
|
+
const [year, month, day, hour, minute, second] = [
|
|
141
|
+
yearText,
|
|
142
|
+
monthText,
|
|
143
|
+
dayText,
|
|
144
|
+
hourText,
|
|
145
|
+
minuteText,
|
|
146
|
+
secondText ?? '0',
|
|
147
|
+
].map(Number)
|
|
148
|
+
const date = new Date(
|
|
149
|
+
Date.UTC(
|
|
150
|
+
year,
|
|
151
|
+
month - 1,
|
|
152
|
+
day,
|
|
153
|
+
hour,
|
|
154
|
+
minute,
|
|
155
|
+
second,
|
|
156
|
+
parseMilliseconds(millisecondText)
|
|
157
|
+
)
|
|
158
|
+
)
|
|
159
|
+
return isValidDateParts(date, year, month, day, hour, minute, second)
|
|
160
|
+
? { date, wallClock: true }
|
|
161
|
+
: undefined
|
|
162
|
+
}
|
|
163
|
+
const timestamp = Date.parse(text)
|
|
164
|
+
return Number.isNaN(timestamp)
|
|
165
|
+
? undefined
|
|
166
|
+
: { date: new Date(timestamp), wallClock: false }
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
type IntlNumericValue = number | bigint | string
|
|
170
|
+
|
|
171
|
+
const DECIMAL_NUMBER = /^([+-]?)(\d+)(?:\.(\d*))?(?:e([+-]?\d+))?$/i
|
|
172
|
+
|
|
173
|
+
const numberValue = (value: unknown): IntlNumericValue | null => {
|
|
174
|
+
if (typeof value === 'number') return Number.isFinite(value) ? value : null
|
|
175
|
+
if (typeof value === 'bigint') return value
|
|
176
|
+
if (typeof value !== 'string' || !DECIMAL_NUMBER.test(value.trim())) {
|
|
177
|
+
return null
|
|
178
|
+
}
|
|
179
|
+
return value.trim()
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const decimalPercentageToRatio = (value: bigint | string) => {
|
|
183
|
+
const text = String(value)
|
|
184
|
+
const match = text.match(DECIMAL_NUMBER)!
|
|
185
|
+
const sign = match[1]
|
|
186
|
+
const integer = match[2]
|
|
187
|
+
const fraction = match[3] ?? ''
|
|
188
|
+
const exponent = Number(match[4] ?? 0)
|
|
189
|
+
const digits = `${integer}${fraction}`
|
|
190
|
+
const decimalPosition = integer.length + exponent - 2
|
|
191
|
+
if (decimalPosition <= 0) {
|
|
192
|
+
return `${sign}0.${'0'.repeat(-decimalPosition)}${digits}`
|
|
193
|
+
}
|
|
194
|
+
if (decimalPosition >= digits.length) {
|
|
195
|
+
return `${sign}${digits}${'0'.repeat(decimalPosition - digits.length)}`
|
|
196
|
+
}
|
|
197
|
+
return `${sign}${digits.slice(0, decimalPosition)}.${digits.slice(decimalPosition)}`
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const formatNumeric = (formatter: Intl.NumberFormat, value: IntlNumericValue) =>
|
|
201
|
+
// 当前 Intl 可直接接受十进制字符串,无需先转成 Number 而损失精度;
|
|
202
|
+
// TypeScript 的标准库类型声明可能落后于运行时规范。
|
|
203
|
+
formatter.format(value as number)
|
|
204
|
+
|
|
205
|
+
const fallbackValue = (value: unknown, invalidText?: string) =>
|
|
206
|
+
invalidText ?? String(value ?? '')
|
|
207
|
+
|
|
208
|
+
/** 表格实例级、框架无关的 Intl 格式化器,并限制格式化器缓存大小。 */
|
|
209
|
+
export class TableIntlFormatter {
|
|
210
|
+
private readonly numberCache = new Map<string, Intl.NumberFormat>()
|
|
211
|
+
private readonly dateTimeCache = new Map<string, Intl.DateTimeFormat>()
|
|
212
|
+
private readonly locale?: TableLocale
|
|
213
|
+
private readonly timeZone?: string
|
|
214
|
+
private readonly maxCacheEntries: number
|
|
215
|
+
|
|
216
|
+
constructor(options: TableIntlFormatterOptions = {}) {
|
|
217
|
+
if (
|
|
218
|
+
options.maxCacheEntries !== undefined &&
|
|
219
|
+
(!Number.isInteger(options.maxCacheEntries) ||
|
|
220
|
+
options.maxCacheEntries < 1)
|
|
221
|
+
) {
|
|
222
|
+
throw new Error(
|
|
223
|
+
'[TableComponent] Intl formatter maxCacheEntries must be a positive integer.'
|
|
224
|
+
)
|
|
225
|
+
}
|
|
226
|
+
this.locale = options.locale
|
|
227
|
+
this.timeZone = options.timeZone
|
|
228
|
+
this.maxCacheEntries =
|
|
229
|
+
options.maxCacheEntries ?? TABLE_CELL_DEFAULTS.cacheEntries
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
private cached<T>(cache: Map<string, T>, key: string, create: () => T) {
|
|
233
|
+
const existing = cache.get(key)
|
|
234
|
+
if (existing) {
|
|
235
|
+
cache.delete(key)
|
|
236
|
+
cache.set(key, existing)
|
|
237
|
+
return existing
|
|
238
|
+
}
|
|
239
|
+
const value = create()
|
|
240
|
+
cache.set(key, value)
|
|
241
|
+
while (cache.size > this.maxCacheEntries) {
|
|
242
|
+
cache.delete(cache.keys().next().value!)
|
|
243
|
+
}
|
|
244
|
+
return value
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
private numberFormatter(options: Intl.NumberFormatOptions) {
|
|
248
|
+
const key = JSON.stringify([this.locale, options])
|
|
249
|
+
return this.cached(
|
|
250
|
+
this.numberCache,
|
|
251
|
+
key,
|
|
252
|
+
() => new Intl.NumberFormat(this.locale, options)
|
|
253
|
+
)
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
private dateTimeFormatter(
|
|
257
|
+
options: Intl.DateTimeFormatOptions,
|
|
258
|
+
timeZone?: string
|
|
259
|
+
) {
|
|
260
|
+
const resolvedOptions = { ...options, timeZone }
|
|
261
|
+
const key = JSON.stringify([this.locale, resolvedOptions])
|
|
262
|
+
return this.cached(
|
|
263
|
+
this.dateTimeCache,
|
|
264
|
+
key,
|
|
265
|
+
() => new Intl.DateTimeFormat(this.locale, resolvedOptions)
|
|
266
|
+
)
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
format(value: unknown, format?: TableValueFormat): unknown {
|
|
270
|
+
if (!format) return value
|
|
271
|
+
if (value === null || value === undefined || value === '') {
|
|
272
|
+
return format.emptyText ?? ''
|
|
273
|
+
}
|
|
274
|
+
if (
|
|
275
|
+
format.type === 'number' ||
|
|
276
|
+
format.type === 'currency' ||
|
|
277
|
+
format.type === 'percent'
|
|
278
|
+
) {
|
|
279
|
+
const parsed = numberValue(value)
|
|
280
|
+
if (parsed === null) return fallbackValue(value, format.invalidText)
|
|
281
|
+
if (format.type === 'number') {
|
|
282
|
+
return formatNumeric(
|
|
283
|
+
this.numberFormatter({
|
|
284
|
+
...format.options,
|
|
285
|
+
style: 'decimal',
|
|
286
|
+
}),
|
|
287
|
+
parsed
|
|
288
|
+
)
|
|
289
|
+
}
|
|
290
|
+
if (format.type === 'currency') {
|
|
291
|
+
return formatNumeric(
|
|
292
|
+
this.numberFormatter({
|
|
293
|
+
...format.options,
|
|
294
|
+
style: 'currency',
|
|
295
|
+
currency: format.currency,
|
|
296
|
+
}),
|
|
297
|
+
parsed
|
|
298
|
+
)
|
|
299
|
+
}
|
|
300
|
+
const percentValue =
|
|
301
|
+
format.valueScale === 'percentage'
|
|
302
|
+
? typeof parsed === 'number'
|
|
303
|
+
? parsed / 100
|
|
304
|
+
: decimalPercentageToRatio(parsed)
|
|
305
|
+
: parsed
|
|
306
|
+
return formatNumeric(
|
|
307
|
+
this.numberFormatter({
|
|
308
|
+
...format.options,
|
|
309
|
+
style: 'percent',
|
|
310
|
+
}),
|
|
311
|
+
percentValue
|
|
312
|
+
)
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
const temporal = parseTemporalValue(value)
|
|
316
|
+
if (!temporal) return fallbackValue(value, format.invalidText)
|
|
317
|
+
const defaults: Record<
|
|
318
|
+
TableDateTimeFormat['type'],
|
|
319
|
+
Intl.DateTimeFormatOptions
|
|
320
|
+
> = {
|
|
321
|
+
date: { year: 'numeric', month: '2-digit', day: '2-digit' },
|
|
322
|
+
time: {
|
|
323
|
+
hour: '2-digit',
|
|
324
|
+
minute: '2-digit',
|
|
325
|
+
second: '2-digit',
|
|
326
|
+
hour12: false,
|
|
327
|
+
},
|
|
328
|
+
datetime: {
|
|
329
|
+
year: 'numeric',
|
|
330
|
+
month: '2-digit',
|
|
331
|
+
day: '2-digit',
|
|
332
|
+
hour: '2-digit',
|
|
333
|
+
minute: '2-digit',
|
|
334
|
+
second: '2-digit',
|
|
335
|
+
hour12: false,
|
|
336
|
+
},
|
|
337
|
+
}
|
|
338
|
+
const dateTimeOptions =
|
|
339
|
+
format.options?.dateStyle || format.options?.timeStyle
|
|
340
|
+
? format.options
|
|
341
|
+
: { ...defaults[format.type], ...format.options }
|
|
342
|
+
return this.dateTimeFormatter(
|
|
343
|
+
dateTimeOptions,
|
|
344
|
+
temporal.wallClock ? 'UTC' : (format.timeZone ?? this.timeZone)
|
|
345
|
+
).format(temporal.date)
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
clear() {
|
|
349
|
+
this.numberCache.clear()
|
|
350
|
+
this.dateTimeCache.clear()
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
export const createTableIntlFormatter = (options?: TableIntlFormatterOptions) =>
|
|
355
|
+
new TableIntlFormatter(options)
|