@postxl/generators 0.2.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/LICENSE +50 -0
- package/dist/backend-actions/actions-provider.mock.d.ts +7 -0
- package/dist/backend-actions/actions-provider.mock.js +75 -0
- package/dist/backend-actions/actions-provider.mock.js.map +1 -0
- package/dist/backend-actions/actions.generator.d.ts +130 -0
- package/dist/backend-actions/actions.generator.js +204 -0
- package/dist/backend-actions/actions.generator.js.map +1 -0
- package/dist/backend-actions/generators/action-types.generator.d.ts +2 -0
- package/dist/backend-actions/generators/action-types.generator.js +47 -0
- package/dist/backend-actions/generators/action-types.generator.js.map +1 -0
- package/dist/backend-actions/generators/actions-config-class.generator.d.ts +2 -0
- package/dist/backend-actions/generators/actions-config-class.generator.js +25 -0
- package/dist/backend-actions/generators/actions-config-class.generator.js.map +1 -0
- package/dist/backend-actions/generators/actions-module.generator.d.ts +2 -0
- package/dist/backend-actions/generators/actions-module.generator.js +47 -0
- package/dist/backend-actions/generators/actions-module.generator.js.map +1 -0
- package/dist/backend-actions/generators/authorization-service.generator.d.ts +2 -0
- package/dist/backend-actions/generators/authorization-service.generator.js +35 -0
- package/dist/backend-actions/generators/authorization-service.generator.js.map +1 -0
- package/dist/backend-actions/generators/dispatcher-service.generator.d.ts +2 -0
- package/dist/backend-actions/generators/dispatcher-service.generator.js +97 -0
- package/dist/backend-actions/generators/dispatcher-service.generator.js.map +1 -0
- package/dist/backend-actions/generators/execution-class.generator.d.ts +2 -0
- package/dist/backend-actions/generators/execution-class.generator.js +561 -0
- package/dist/backend-actions/generators/execution-class.generator.js.map +1 -0
- package/dist/backend-actions/generators/execution-interface.generator.d.ts +2 -0
- package/dist/backend-actions/generators/execution-interface.generator.js +237 -0
- package/dist/backend-actions/generators/execution-interface.generator.js.map +1 -0
- package/dist/backend-actions/index.d.ts +9 -0
- package/dist/backend-actions/index.js +43 -0
- package/dist/backend-actions/index.js.map +1 -0
- package/dist/backend-actions/template/README.md +21 -0
- package/dist/backend-actions/template/src/execution/types.ts +85 -0
- package/dist/backend-authentication/authentication.generator.d.ts +29 -0
- package/dist/backend-authentication/authentication.generator.js +145 -0
- package/dist/backend-authentication/authentication.generator.js.map +1 -0
- package/dist/backend-authentication/generators/auth-guard.generator.d.ts +2 -0
- package/dist/backend-authentication/generators/auth-guard.generator.js +121 -0
- package/dist/backend-authentication/generators/auth-guard.generator.js.map +1 -0
- package/dist/backend-authentication/generators/authentication-module.generator.d.ts +2 -0
- package/dist/backend-authentication/generators/authentication-module.generator.js +79 -0
- package/dist/backend-authentication/generators/authentication-module.generator.js.map +1 -0
- package/dist/backend-authentication/generators/authentication-service.generator.d.ts +2 -0
- package/dist/backend-authentication/generators/authentication-service.generator.js +393 -0
- package/dist/backend-authentication/generators/authentication-service.generator.js.map +1 -0
- package/dist/backend-authentication/generators/authentication-types.generator.d.ts +2 -0
- package/dist/backend-authentication/generators/authentication-types.generator.js +64 -0
- package/dist/backend-authentication/generators/authentication-types.generator.js.map +1 -0
- package/dist/backend-authentication/index.d.ts +4 -0
- package/dist/backend-authentication/index.js +40 -0
- package/dist/backend-authentication/index.js.map +1 -0
- package/dist/backend-authentication/template/README.md +35 -0
- package/dist/backend-authentication/template/assets/auth.png +0 -0
- package/dist/backend-authentication/template/assets/cookie-validation.png +0 -0
- package/dist/backend-authentication/template/assets/page-request.png +0 -0
- package/dist/backend-authentication/template/docs/auth.mmd +42 -0
- package/dist/backend-authentication/template/docs/cookie-validation.mmd +0 -0
- package/dist/backend-authentication/template/docs/page-request.mmd +42 -0
- package/dist/backend-authentication/template/src/authentication.config.ts +51 -0
- package/dist/backend-authentication/template/src/authentication.controller.ts +105 -0
- package/dist/backend-authentication/template/src/authentication.mock.service.ts +108 -0
- package/dist/backend-authentication/template/src/utils.ts +13 -0
- package/dist/backend-authentication/template/src/viewer.decorator.ts +13 -0
- package/dist/backend-core/backend.generator.d.ts +3 -0
- package/dist/backend-core/backend.generator.js +154 -0
- package/dist/backend-core/backend.generator.js.map +1 -0
- package/dist/backend-core/generators/api-config.generator.d.ts +2 -0
- package/dist/backend-core/generators/api-config.generator.js +72 -0
- package/dist/backend-core/generators/api-config.generator.js.map +1 -0
- package/dist/backend-core/generators/api-module.generator.d.ts +2 -0
- package/dist/backend-core/generators/api-module.generator.js +53 -0
- package/dist/backend-core/generators/api-module.generator.js.map +1 -0
- package/dist/backend-core/generators/dotenv-example.generator.d.ts +2 -0
- package/dist/backend-core/generators/dotenv-example.generator.js +38 -0
- package/dist/backend-core/generators/dotenv-example.generator.js.map +1 -0
- package/dist/backend-core/generators/main.generator.d.ts +2 -0
- package/dist/backend-core/generators/main.generator.js +153 -0
- package/dist/backend-core/generators/main.generator.js.map +1 -0
- package/dist/backend-core/generators/tsconfig.generator.d.ts +2 -0
- package/dist/backend-core/generators/tsconfig.generator.js +59 -0
- package/dist/backend-core/generators/tsconfig.generator.js.map +1 -0
- package/dist/backend-core/index.d.ts +3 -0
- package/dist/backend-core/index.js +20 -0
- package/dist/backend-core/index.js.map +1 -0
- package/dist/backend-core/modules/backend-module-utils.generator.d.ts +3 -0
- package/dist/backend-core/modules/backend-module-utils.generator.js +65 -0
- package/dist/backend-core/modules/backend-module-utils.generator.js.map +1 -0
- package/dist/backend-core/modules/backend-module-xlport.generator.d.ts +3 -0
- package/dist/backend-core/modules/backend-module-xlport.generator.js +80 -0
- package/dist/backend-core/modules/backend-module-xlport.generator.js.map +1 -0
- package/dist/backend-core/template/README.md +97 -0
- package/dist/backend-core/template/apps/api/README.md +3 -0
- package/dist/backend-core/template/apps/api/src/api.controller.ts +14 -0
- package/dist/backend-core/template/apps/api/src/console.logger.ts +55 -0
- package/dist/backend-core/template/apps/api/src/e2e.ts +458 -0
- package/dist/backend-core/template/apps/api/test/base.test.ts +7 -0
- package/dist/backend-core/template/apps/api/tsconfig.app.json +9 -0
- package/dist/backend-core/template/jest.config.ts +39 -0
- package/dist/backend-core/template/libs/e2e/src/e2e.controller.ts +30 -0
- package/dist/backend-core/template/libs/e2e/src/e2e.module.ts +18 -0
- package/dist/backend-core/template/libs/e2e/src/test-data.service.ts +20 -0
- package/dist/backend-core/template/libs/utils/src/pagination.test.ts +58 -0
- package/dist/backend-core/template/libs/utils/src/pagination.ts +68 -0
- package/dist/backend-core/template/libs/utils/tsconfig.lib.json +9 -0
- package/dist/backend-core/template/libs/xlport/README.md +90 -0
- package/dist/backend-core/template/libs/xlport/src/xlport.config.ts +8 -0
- package/dist/backend-core/template/libs/xlport/src/xlport.module.ts +20 -0
- package/dist/backend-core/template/libs/xlport/src/xlport.service.ts +171 -0
- package/dist/backend-core/template/libs/xlport/tsconfig.lib.json +9 -0
- package/dist/backend-core/template/nest-cli.json +22 -0
- package/dist/backend-core/template/tsconfig.build.json +4 -0
- package/dist/backend-core/types.d.ts +145 -0
- package/dist/backend-core/types.js +3 -0
- package/dist/backend-core/types.js.map +1 -0
- package/dist/backend-data-management/data-management.generator.d.ts +18 -0
- package/dist/backend-data-management/data-management.generator.js +104 -0
- package/dist/backend-data-management/data-management.generator.js.map +1 -0
- package/dist/backend-data-management/generators/data-management-service.generator.d.ts +8 -0
- package/dist/backend-data-management/generators/data-management-service.generator.js +330 -0
- package/dist/backend-data-management/generators/data-management-service.generator.js.map +1 -0
- package/dist/backend-data-management/index.d.ts +2 -0
- package/dist/backend-data-management/index.js +22 -0
- package/dist/backend-data-management/index.js.map +1 -0
- package/dist/backend-data-management/template/data-management.controller.ts +242 -0
- package/dist/backend-data-management/template/data-management.module.ts +15 -0
- package/dist/backend-database-prisma/generators/database-config.generator.d.ts +2 -0
- package/dist/backend-database-prisma/generators/database-config.generator.js +18 -0
- package/dist/backend-database-prisma/generators/database-config.generator.js.map +1 -0
- package/dist/backend-database-prisma/generators/database-module.generator.d.ts +2 -0
- package/dist/backend-database-prisma/generators/database-module.generator.js +66 -0
- package/dist/backend-database-prisma/generators/database-module.generator.js.map +1 -0
- package/dist/backend-database-prisma/generators/database-service.generator.d.ts +2 -0
- package/dist/backend-database-prisma/generators/database-service.generator.js +45 -0
- package/dist/backend-database-prisma/generators/database-service.generator.js.map +1 -0
- package/dist/backend-database-prisma/generators/index.generator.d.ts +2 -0
- package/dist/backend-database-prisma/generators/index.generator.js +12 -0
- package/dist/backend-database-prisma/generators/index.generator.js.map +1 -0
- package/dist/backend-database-prisma/generators/prisma-schema.generator.d.ts +2 -0
- package/dist/backend-database-prisma/generators/prisma-schema.generator.js +224 -0
- package/dist/backend-database-prisma/generators/prisma-schema.generator.js.map +1 -0
- package/dist/backend-database-prisma/index.d.ts +5 -0
- package/dist/backend-database-prisma/index.js +41 -0
- package/dist/backend-database-prisma/index.js.map +1 -0
- package/dist/backend-database-prisma/prisma.generator.d.ts +29 -0
- package/dist/backend-database-prisma/prisma.generator.js +123 -0
- package/dist/backend-database-prisma/prisma.generator.js.map +1 -0
- package/dist/backend-database-prisma/prisma.utils.d.ts +9 -0
- package/dist/backend-database-prisma/prisma.utils.js +27 -0
- package/dist/backend-database-prisma/prisma.utils.js.map +1 -0
- package/dist/backend-database-prisma/template/prisma.config.ts +14 -0
- package/dist/backend-e2e/backend-e2e.generator.d.ts +23 -0
- package/dist/backend-e2e/backend-e2e.generator.js +139 -0
- package/dist/backend-e2e/backend-e2e.generator.js.map +1 -0
- package/dist/backend-e2e/generators/e2e-controller.generator.d.ts +2 -0
- package/dist/backend-e2e/generators/e2e-controller.generator.js +70 -0
- package/dist/backend-e2e/generators/e2e-controller.generator.js.map +1 -0
- package/dist/backend-e2e/generators/e2e-module.generator.d.ts +2 -0
- package/dist/backend-e2e/generators/e2e-module.generator.js +64 -0
- package/dist/backend-e2e/generators/e2e-module.generator.js.map +1 -0
- package/dist/backend-e2e/generators/e2e-service.generator.d.ts +2 -0
- package/dist/backend-e2e/generators/e2e-service.generator.js +99 -0
- package/dist/backend-e2e/generators/e2e-service.generator.js.map +1 -0
- package/dist/backend-e2e/index.d.ts +4 -0
- package/dist/backend-e2e/index.js +40 -0
- package/dist/backend-e2e/index.js.map +1 -0
- package/dist/backend-import/generators/convert-functions.generator.d.ts +5 -0
- package/dist/backend-import/generators/convert-functions.generator.js +600 -0
- package/dist/backend-import/generators/convert-functions.generator.js.map +1 -0
- package/dist/backend-import/generators/detect-delta/detect-delta-all-models.generator.d.ts +2 -0
- package/dist/backend-import/generators/detect-delta/detect-delta-all-models.generator.js +128 -0
- package/dist/backend-import/generators/detect-delta/detect-delta-all-models.generator.js.map +1 -0
- package/dist/backend-import/generators/detect-delta/detect-delta-functions.generator.d.ts +2 -0
- package/dist/backend-import/generators/detect-delta/detect-delta-functions.generator.js +391 -0
- package/dist/backend-import/generators/detect-delta/detect-delta-functions.generator.js.map +1 -0
- package/dist/backend-import/generators/detect-delta/model-function.generator.d.ts +2 -0
- package/dist/backend-import/generators/detect-delta/model-function.generator.js +321 -0
- package/dist/backend-import/generators/detect-delta/model-function.generator.js.map +1 -0
- package/dist/backend-import/generators/detect-delta/types.generator.d.ts +2 -0
- package/dist/backend-import/generators/detect-delta/types.generator.js +149 -0
- package/dist/backend-import/generators/detect-delta/types.generator.js.map +1 -0
- package/dist/backend-import/generators/import-module.generator.d.ts +2 -0
- package/dist/backend-import/generators/import-module.generator.js +58 -0
- package/dist/backend-import/generators/import-module.generator.js.map +1 -0
- package/dist/backend-import/generators/import-service.generator.d.ts +2 -0
- package/dist/backend-import/generators/import-service.generator.js +304 -0
- package/dist/backend-import/generators/import-service.generator.js.map +1 -0
- package/dist/backend-import/import.generator.d.ts +228 -0
- package/dist/backend-import/import.generator.js +255 -0
- package/dist/backend-import/import.generator.js.map +1 -0
- package/dist/backend-import/index.d.ts +5 -0
- package/dist/backend-import/index.js +40 -0
- package/dist/backend-import/index.js.map +1 -0
- package/dist/backend-import/template/README.md +52 -0
- package/dist/backend-repositories/generators/bulk-mutation-types.generator.d.ts +2 -0
- package/dist/backend-repositories/generators/bulk-mutation-types.generator.js +42 -0
- package/dist/backend-repositories/generators/bulk-mutation-types.generator.js.map +1 -0
- package/dist/backend-repositories/generators/data-service.generator.d.ts +2 -0
- package/dist/backend-repositories/generators/data-service.generator.js +289 -0
- package/dist/backend-repositories/generators/data-service.generator.js.map +1 -0
- package/dist/backend-repositories/generators/model-repository.generator.d.ts +14 -0
- package/dist/backend-repositories/generators/model-repository.generator.js +1936 -0
- package/dist/backend-repositories/generators/model-repository.generator.js.map +1 -0
- package/dist/backend-repositories/generators/repository-interface.generator.d.ts +2 -0
- package/dist/backend-repositories/generators/repository-interface.generator.js +55 -0
- package/dist/backend-repositories/generators/repository-interface.generator.js.map +1 -0
- package/dist/backend-repositories/generators/repository-module.generator.d.ts +2 -0
- package/dist/backend-repositories/generators/repository-module.generator.js +143 -0
- package/dist/backend-repositories/generators/repository-module.generator.js.map +1 -0
- package/dist/backend-repositories/index.d.ts +5 -0
- package/dist/backend-repositories/index.js +40 -0
- package/dist/backend-repositories/index.js.map +1 -0
- package/dist/backend-repositories/model.types.d.ts +69 -0
- package/dist/backend-repositories/model.types.js +17 -0
- package/dist/backend-repositories/model.types.js.map +1 -0
- package/dist/backend-repositories/repositories.generator.d.ts +46 -0
- package/dist/backend-repositories/repositories.generator.js +256 -0
- package/dist/backend-repositories/repositories.generator.js.map +1 -0
- package/dist/backend-rest-api/generators/model-controller.generator.d.ts +5 -0
- package/dist/backend-rest-api/generators/model-controller.generator.js +100 -0
- package/dist/backend-rest-api/generators/model-controller.generator.js.map +1 -0
- package/dist/backend-rest-api/generators/rest-api-module.generator.d.ts +2 -0
- package/dist/backend-rest-api/generators/rest-api-module.generator.js +62 -0
- package/dist/backend-rest-api/generators/rest-api-module.generator.js.map +1 -0
- package/dist/backend-rest-api/generators/zod-exception-filter.generator.d.ts +1 -0
- package/dist/backend-rest-api/generators/zod-exception-filter.generator.js +28 -0
- package/dist/backend-rest-api/generators/zod-exception-filter.generator.js.map +1 -0
- package/dist/backend-rest-api/index.d.ts +5 -0
- package/dist/backend-rest-api/index.js +40 -0
- package/dist/backend-rest-api/index.js.map +1 -0
- package/dist/backend-rest-api/rest-api.generator.d.ts +24 -0
- package/dist/backend-rest-api/rest-api.generator.js +113 -0
- package/dist/backend-rest-api/rest-api.generator.js.map +1 -0
- package/dist/backend-rest-api/template/zod-exception.filter.ts +21 -0
- package/dist/backend-router-trpc/generators/app-routes.generator.d.ts +4 -0
- package/dist/backend-router-trpc/generators/app-routes.generator.js +74 -0
- package/dist/backend-router-trpc/generators/app-routes.generator.js.map +1 -0
- package/dist/backend-router-trpc/generators/audit-log-route.generator.d.ts +7 -0
- package/dist/backend-router-trpc/generators/audit-log-route.generator.js +611 -0
- package/dist/backend-router-trpc/generators/audit-log-route.generator.js.map +1 -0
- package/dist/backend-router-trpc/generators/middleware.generator.d.ts +2 -0
- package/dist/backend-router-trpc/generators/middleware.generator.js +100 -0
- package/dist/backend-router-trpc/generators/middleware.generator.js.map +1 -0
- package/dist/backend-router-trpc/generators/model-routes.generator.d.ts +8 -0
- package/dist/backend-router-trpc/generators/model-routes.generator.js +88 -0
- package/dist/backend-router-trpc/generators/model-routes.generator.js.map +1 -0
- package/dist/backend-router-trpc/generators/trpc-plugin.generator.d.ts +2 -0
- package/dist/backend-router-trpc/generators/trpc-plugin.generator.js +141 -0
- package/dist/backend-router-trpc/generators/trpc-plugin.generator.js.map +1 -0
- package/dist/backend-router-trpc/generators/trpc-router-module.generator.d.ts +2 -0
- package/dist/backend-router-trpc/generators/trpc-router-module.generator.js +60 -0
- package/dist/backend-router-trpc/generators/trpc-router-module.generator.js.map +1 -0
- package/dist/backend-router-trpc/generators/trpc-shared.generator.d.ts +2 -0
- package/dist/backend-router-trpc/generators/trpc-shared.generator.js +134 -0
- package/dist/backend-router-trpc/generators/trpc-shared.generator.js.map +1 -0
- package/dist/backend-router-trpc/index.d.ts +5 -0
- package/dist/backend-router-trpc/index.js +40 -0
- package/dist/backend-router-trpc/index.js.map +1 -0
- package/dist/backend-router-trpc/router-trpc.generator.d.ts +108 -0
- package/dist/backend-router-trpc/router-trpc.generator.js +189 -0
- package/dist/backend-router-trpc/router-trpc.generator.js.map +1 -0
- package/dist/backend-router-trpc/template/viewer.router.ts +25 -0
- package/dist/backend-s3/generators/s3.config.generator.d.ts +2 -0
- package/dist/backend-s3/generators/s3.config.generator.js +24 -0
- package/dist/backend-s3/generators/s3.config.generator.js.map +1 -0
- package/dist/backend-s3/generators/s3.module.generator.d.ts +2 -0
- package/dist/backend-s3/generators/s3.module.generator.js +33 -0
- package/dist/backend-s3/generators/s3.module.generator.js.map +1 -0
- package/dist/backend-s3/generators/s3.service.generator.d.ts +2 -0
- package/dist/backend-s3/generators/s3.service.generator.js +116 -0
- package/dist/backend-s3/generators/s3.service.generator.js.map +1 -0
- package/dist/backend-s3/index.d.ts +4 -0
- package/dist/backend-s3/index.js +40 -0
- package/dist/backend-s3/index.js.map +1 -0
- package/dist/backend-s3/s3.generator.d.ts +19 -0
- package/dist/backend-s3/s3.generator.js +125 -0
- package/dist/backend-s3/s3.generator.js.map +1 -0
- package/dist/backend-seed/generators/seed-module.generator.d.ts +2 -0
- package/dist/backend-seed/generators/seed-module.generator.js +60 -0
- package/dist/backend-seed/generators/seed-module.generator.js.map +1 -0
- package/dist/backend-seed/generators/seed-service.generator.d.ts +2 -0
- package/dist/backend-seed/generators/seed-service.generator.js +176 -0
- package/dist/backend-seed/generators/seed-service.generator.js.map +1 -0
- package/dist/backend-seed/index.d.ts +4 -0
- package/dist/backend-seed/index.js +40 -0
- package/dist/backend-seed/index.js.map +1 -0
- package/dist/backend-seed/seed.generator.d.ts +19 -0
- package/dist/backend-seed/seed.generator.js +95 -0
- package/dist/backend-seed/seed.generator.js.map +1 -0
- package/dist/backend-seed/template/src/actions.ts +90 -0
- package/dist/backend-seed/template/tsconfig.lib.json +9 -0
- package/dist/backend-update/bulk-service.generator.d.ts +2 -0
- package/dist/backend-update/bulk-service.generator.js +277 -0
- package/dist/backend-update/bulk-service.generator.js.map +1 -0
- package/dist/backend-update/index.d.ts +5 -0
- package/dist/backend-update/index.js +40 -0
- package/dist/backend-update/index.js.map +1 -0
- package/dist/backend-update/model-update-service.generator.d.ts +5 -0
- package/dist/backend-update/model-update-service.generator.js +757 -0
- package/dist/backend-update/model-update-service.generator.js.map +1 -0
- package/dist/backend-update/update-actions.decoders.d.ts +15 -0
- package/dist/backend-update/update-actions.decoders.js +37 -0
- package/dist/backend-update/update-actions.decoders.js.map +1 -0
- package/dist/backend-update/update-module.generator.d.ts +2 -0
- package/dist/backend-update/update-module.generator.js +69 -0
- package/dist/backend-update/update-module.generator.js.map +1 -0
- package/dist/backend-update/update-service.generator.d.ts +2 -0
- package/dist/backend-update/update-service.generator.js +94 -0
- package/dist/backend-update/update-service.generator.js.map +1 -0
- package/dist/backend-update/update.generator.d.ts +138 -0
- package/dist/backend-update/update.generator.js +302 -0
- package/dist/backend-update/update.generator.js.map +1 -0
- package/dist/backend-view/index.d.ts +5 -0
- package/dist/backend-view/index.js +40 -0
- package/dist/backend-view/index.js.map +1 -0
- package/dist/backend-view/model-view-service.generator.d.ts +11 -0
- package/dist/backend-view/model-view-service.generator.js +196 -0
- package/dist/backend-view/model-view-service.generator.js.map +1 -0
- package/dist/backend-view/view-module.generator.d.ts +2 -0
- package/dist/backend-view/view-module.generator.js +62 -0
- package/dist/backend-view/view-module.generator.js.map +1 -0
- package/dist/backend-view/view-service.generator.d.ts +2 -0
- package/dist/backend-view/view-service.generator.js +56 -0
- package/dist/backend-view/view-service.generator.js.map +1 -0
- package/dist/backend-view/view.generator.d.ts +32 -0
- package/dist/backend-view/view.generator.js +100 -0
- package/dist/backend-view/view.generator.js.map +1 -0
- package/dist/base/base.generator.d.ts +26 -0
- package/dist/base/base.generator.js +138 -0
- package/dist/base/base.generator.js.map +1 -0
- package/dist/base/index.d.ts +1 -0
- package/dist/base/index.js +18 -0
- package/dist/base/index.js.map +1 -0
- package/dist/base/template/.nvmrc +1 -0
- package/dist/base/template/.prettierignore +5 -0
- package/dist/base/template/.turboignore +1 -0
- package/dist/base/template/.vscode/extensions.json +16 -0
- package/dist/base/template/.vscode/launch.json +15 -0
- package/dist/base/template/.vscode/settings.json +73 -0
- package/dist/base/template/README.md +115 -0
- package/dist/base/template/eslint.config.mjs +194 -0
- package/dist/base/template/jest.config.ts +7 -0
- package/dist/base/template/prettier.config.js +10 -0
- package/dist/base/template/scripts/setup.sh +25 -0
- package/dist/base/template/sonar-project.properties +94 -0
- package/dist/base/template/tsconfig.json +12 -0
- package/dist/decoders/datamodel-decoder.generator.d.ts +7 -0
- package/dist/decoders/datamodel-decoder.generator.js +134 -0
- package/dist/decoders/datamodel-decoder.generator.js.map +1 -0
- package/dist/decoders/decoders.generator.d.ts +133 -0
- package/dist/decoders/decoders.generator.js +424 -0
- package/dist/decoders/decoders.generator.js.map +1 -0
- package/dist/decoders/discriminated-union.decoder.generator.d.ts +12 -0
- package/dist/decoders/discriminated-union.decoder.generator.js +205 -0
- package/dist/decoders/discriminated-union.decoder.generator.js.map +1 -0
- package/dist/decoders/enum-decoder.generator.d.ts +5 -0
- package/dist/decoders/enum-decoder.generator.js +71 -0
- package/dist/decoders/enum-decoder.generator.js.map +1 -0
- package/dist/decoders/excel-field-decoder.helper.d.ts +17 -0
- package/dist/decoders/excel-field-decoder.helper.js +178 -0
- package/dist/decoders/excel-field-decoder.helper.js.map +1 -0
- package/dist/decoders/field-decoder.helper.d.ts +50 -0
- package/dist/decoders/field-decoder.helper.js +113 -0
- package/dist/decoders/field-decoder.helper.js.map +1 -0
- package/dist/decoders/index.d.ts +4 -0
- package/dist/decoders/index.js +40 -0
- package/dist/decoders/index.js.map +1 -0
- package/dist/decoders/model-decoder.generator.d.ts +5 -0
- package/dist/decoders/model-decoder.generator.js +197 -0
- package/dist/decoders/model-decoder.generator.js.map +1 -0
- package/dist/decoders/shared.d.ts +51 -0
- package/dist/decoders/shared.js +140 -0
- package/dist/decoders/shared.js.map +1 -0
- package/dist/devops/devops.generator.d.ts +66 -0
- package/dist/devops/devops.generator.js +127 -0
- package/dist/devops/devops.generator.js.map +1 -0
- package/dist/devops/generators/backend-build-sh.generator.d.ts +2 -0
- package/dist/devops/generators/backend-build-sh.generator.js +49 -0
- package/dist/devops/generators/backend-build-sh.generator.js.map +1 -0
- package/dist/devops/generators/backend-dockerfile.generator.d.ts +2 -0
- package/dist/devops/generators/backend-dockerfile.generator.js +67 -0
- package/dist/devops/generators/backend-dockerfile.generator.js.map +1 -0
- package/dist/devops/generators/backend-start-api-sh.generator.d.ts +2 -0
- package/dist/devops/generators/backend-start-api-sh.generator.js +18 -0
- package/dist/devops/generators/backend-start-api-sh.generator.js.map +1 -0
- package/dist/devops/generators/bitbucket-pipelines-yml.generator.d.ts +2 -0
- package/dist/devops/generators/bitbucket-pipelines-yml.generator.js +105 -0
- package/dist/devops/generators/bitbucket-pipelines-yml.generator.js.map +1 -0
- package/dist/devops/generators/configure-keycloak-sh.generator.d.ts +2 -0
- package/dist/devops/generators/configure-keycloak-sh.generator.js +158 -0
- package/dist/devops/generators/configure-keycloak-sh.generator.js.map +1 -0
- package/dist/devops/generators/docker-compose-yml.generator.d.ts +2 -0
- package/dist/devops/generators/docker-compose-yml.generator.js +78 -0
- package/dist/devops/generators/docker-compose-yml.generator.js.map +1 -0
- package/dist/devops/generators/e2e-yml.generator.d.ts +2 -0
- package/dist/devops/generators/e2e-yml.generator.js +195 -0
- package/dist/devops/generators/e2e-yml.generator.js.map +1 -0
- package/dist/devops/generators/frontend-build-sh.generator.d.ts +2 -0
- package/dist/devops/generators/frontend-build-sh.generator.js +45 -0
- package/dist/devops/generators/frontend-build-sh.generator.js.map +1 -0
- package/dist/devops/generators/frontend-dockerfile.generator.d.ts +2 -0
- package/dist/devops/generators/frontend-dockerfile.generator.js +75 -0
- package/dist/devops/generators/frontend-dockerfile.generator.js.map +1 -0
- package/dist/devops/generators/jenkinsfile.generator.d.ts +2 -0
- package/dist/devops/generators/jenkinsfile.generator.js +147 -0
- package/dist/devops/generators/jenkinsfile.generator.js.map +1 -0
- package/dist/devops/generators/root-dotenv-example.generator.d.ts +2 -0
- package/dist/devops/generators/root-dotenv-example.generator.js +10 -0
- package/dist/devops/generators/root-dotenv-example.generator.js.map +1 -0
- package/dist/devops/index.d.ts +4 -0
- package/dist/devops/index.js +40 -0
- package/dist/devops/index.js.map +1 -0
- package/dist/devops/template/.github/workflows/test.yml +45 -0
- package/dist/devops/template/docker/backend/migrate.sh +10 -0
- package/dist/devops/template/docker/backend/start.api.sh +8 -0
- package/dist/devops/template/docker/frontend/entrypoint.sh +18 -0
- package/dist/devops/template/docker/frontend/frontend.conf +17 -0
- package/dist/devops/template/docker/keycloak/Dockerfile +17 -0
- package/dist/devops/template/docker/keycloak/localization.en.json +5 -0
- package/dist/devops/template/docker/keycloak/protocol-mappers.json +28 -0
- package/dist/devops/template/docker/keycloak/user-attributes.json +142 -0
- package/dist/e2e/e2e.generator.d.ts +19 -0
- package/dist/e2e/e2e.generator.js +92 -0
- package/dist/e2e/e2e.generator.js.map +1 -0
- package/dist/e2e/generators/lib/test-id-collector.d.ts +48 -0
- package/dist/e2e/generators/lib/test-id-collector.js +65 -0
- package/dist/e2e/generators/lib/test-id-collector.js.map +1 -0
- package/dist/e2e/generators/lib/test-id-generator.d.ts +5 -0
- package/dist/e2e/generators/lib/test-id-generator.js +67 -0
- package/dist/e2e/generators/lib/test-id-generator.js.map +1 -0
- package/dist/e2e/generators/model-test-id.generator.d.ts +5 -0
- package/dist/e2e/generators/model-test-id.generator.js +19 -0
- package/dist/e2e/generators/model-test-id.generator.js.map +1 -0
- package/dist/e2e/generators/package-json.generator.d.ts +2 -0
- package/dist/e2e/generators/package-json.generator.js +29 -0
- package/dist/e2e/generators/package-json.generator.js.map +1 -0
- package/dist/e2e/index.d.ts +4 -0
- package/dist/e2e/index.js +40 -0
- package/dist/e2e/index.js.map +1 -0
- package/dist/e2e/template/e2e/.env.example +11 -0
- package/dist/e2e/template/e2e/Dockerfile +8 -0
- package/dist/e2e/template/e2e/README.md +87 -0
- package/dist/e2e/template/e2e/fixtures/global-setup.ts +3 -0
- package/dist/e2e/template/e2e/fixtures/global-teardown.ts +21 -0
- package/dist/e2e/template/e2e/fixtures/handle-backend.ts +35 -0
- package/dist/e2e/template/e2e/fixtures/set-date-script.js +28 -0
- package/dist/e2e/template/e2e/fixtures/set-fixed-date.ts +12 -0
- package/dist/e2e/template/e2e/fixtures/test-fixtures.ts +132 -0
- package/dist/e2e/template/e2e/package.json +22 -0
- package/dist/e2e/template/e2e/playwright.config.ts +161 -0
- package/dist/e2e/template/e2e/specs/example-backend-isolation.spec.ts +59 -0
- package/dist/e2e/template/e2e/specs/example.spec.ts +77 -0
- package/dist/e2e/template/e2e/specs/example.spec.ts-snapshots/Navigate-to-homepage-and-take-snapshot-1-chromium-linux.png +0 -0
- package/dist/e2e/template/e2e/support/checkbox-click.ts +20 -0
- package/dist/e2e/template/e2e/support/get-backend-mode.ts +10 -0
- package/dist/e2e/template/e2e/support/map.utils.ts +98 -0
- package/dist/e2e/template/e2e/support/mask-toast.ts +20 -0
- package/dist/e2e/template/e2e/support/model-test-ids.ts +4 -0
- package/dist/e2e/template/e2e/support/mouse-annotations.ts +162 -0
- package/dist/e2e/template/e2e/support/page-stability.ts +86 -0
- package/dist/e2e/template/e2e/support/reset-data.ts +38 -0
- package/dist/e2e/template/e2e/support/set-data.ts +44 -0
- package/dist/e2e/template/e2e/support/wait-for-page-loaded.ts +28 -0
- package/dist/e2e/template/e2e/tsconfig.json +51 -0
- package/dist/e2e/template/scripts/docker.sh +17 -0
- package/dist/frontend-admin/admin.generator.d.ts +75 -0
- package/dist/frontend-admin/admin.generator.js +132 -0
- package/dist/frontend-admin/admin.generator.js.map +1 -0
- package/dist/frontend-admin/generators/admin-overview-page.generator.d.ts +7 -0
- package/dist/frontend-admin/generators/admin-overview-page.generator.js +110 -0
- package/dist/frontend-admin/generators/admin-overview-page.generator.js.map +1 -0
- package/dist/frontend-admin/generators/admin-sidebar.generator.d.ts +7 -0
- package/dist/frontend-admin/generators/admin-sidebar.generator.js +196 -0
- package/dist/frontend-admin/generators/admin-sidebar.generator.js.map +1 -0
- package/dist/frontend-admin/generators/audit-log-sidebar.generator.d.ts +8 -0
- package/dist/frontend-admin/generators/audit-log-sidebar.generator.js +629 -0
- package/dist/frontend-admin/generators/audit-log-sidebar.generator.js.map +1 -0
- package/dist/frontend-admin/generators/data-management-page.generator.d.ts +7 -0
- package/dist/frontend-admin/generators/data-management-page.generator.js +778 -0
- package/dist/frontend-admin/generators/data-management-page.generator.js.map +1 -0
- package/dist/frontend-admin/generators/model-admin-page.generator.d.ts +8 -0
- package/dist/frontend-admin/generators/model-admin-page.generator.js +231 -0
- package/dist/frontend-admin/generators/model-admin-page.generator.js.map +1 -0
- package/dist/frontend-admin/index.d.ts +5 -0
- package/dist/frontend-admin/index.js +40 -0
- package/dist/frontend-admin/index.js.map +1 -0
- package/dist/frontend-admin/utils.d.ts +24 -0
- package/dist/frontend-admin/utils.js +122 -0
- package/dist/frontend-admin/utils.js.map +1 -0
- package/dist/frontend-core/frontend.generator.d.ts +87 -0
- package/dist/frontend-core/frontend.generator.js +400 -0
- package/dist/frontend-core/frontend.generator.js.map +1 -0
- package/dist/frontend-core/generators/tsconfig.generator.d.ts +2 -0
- package/dist/frontend-core/generators/tsconfig.generator.js +55 -0
- package/dist/frontend-core/generators/tsconfig.generator.js.map +1 -0
- package/dist/frontend-core/index.d.ts +2 -0
- package/dist/frontend-core/index.js +19 -0
- package/dist/frontend-core/index.js.map +1 -0
- package/dist/frontend-core/scripts/generate-types.d.ts +1 -0
- package/dist/frontend-core/scripts/generate-types.js +59 -0
- package/dist/frontend-core/scripts/generate-types.js.map +1 -0
- package/dist/frontend-core/template/.env.example +44 -0
- package/dist/frontend-core/template/.prettierignore +4 -0
- package/dist/frontend-core/template/.storybook/main.ts +27 -0
- package/dist/frontend-core/template/.storybook/preview.ts +16 -0
- package/dist/frontend-core/template/.storybook/vitest.setup.ts +18 -0
- package/dist/frontend-core/template/README.md +488 -0
- package/dist/frontend-core/template/components.json +21 -0
- package/dist/frontend-core/template/index.html +11 -0
- package/dist/frontend-core/template/public/android-chrome-192x192.png +0 -0
- package/dist/frontend-core/template/public/android-chrome-512x512.png +0 -0
- package/dist/frontend-core/template/public/apple-touch-icon.png +0 -0
- package/dist/frontend-core/template/public/favicon-16x16.png +0 -0
- package/dist/frontend-core/template/public/favicon-32x32.png +0 -0
- package/dist/frontend-core/template/public/favicon.ico +0 -0
- package/dist/frontend-core/template/public/flags/AC.svg +39 -0
- package/dist/frontend-core/template/public/flags/AD.svg +32 -0
- package/dist/frontend-core/template/public/flags/AE.svg +7 -0
- package/dist/frontend-core/template/public/flags/AF.svg +9 -0
- package/dist/frontend-core/template/public/flags/AG.svg +13 -0
- package/dist/frontend-core/template/public/flags/AI.svg +31 -0
- package/dist/frontend-core/template/public/flags/AL.svg +22 -0
- package/dist/frontend-core/template/public/flags/AM.svg +6 -0
- package/dist/frontend-core/template/public/flags/AO.svg +24 -0
- package/dist/frontend-core/template/public/flags/AQ.svg +6 -0
- package/dist/frontend-core/template/public/flags/AR.svg +7 -0
- package/dist/frontend-core/template/public/flags/AS.svg +9 -0
- package/dist/frontend-core/template/public/flags/AT.svg +6 -0
- package/dist/frontend-core/template/public/flags/AU.svg +36 -0
- package/dist/frontend-core/template/public/flags/AW.svg +12 -0
- package/dist/frontend-core/template/public/flags/AX.svg +8 -0
- package/dist/frontend-core/template/public/flags/AZ.svg +13 -0
- package/dist/frontend-core/template/public/flags/BA.svg +23 -0
- package/dist/frontend-core/template/public/flags/BB.svg +11 -0
- package/dist/frontend-core/template/public/flags/BD.svg +5 -0
- package/dist/frontend-core/template/public/flags/BE.svg +7 -0
- package/dist/frontend-core/template/public/flags/BF.svg +7 -0
- package/dist/frontend-core/template/public/flags/BG.svg +7 -0
- package/dist/frontend-core/template/public/flags/BH.svg +8 -0
- package/dist/frontend-core/template/public/flags/BI.svg +21 -0
- package/dist/frontend-core/template/public/flags/BJ.svg +7 -0
- package/dist/frontend-core/template/public/flags/BL.svg +48 -0
- package/dist/frontend-core/template/public/flags/BM.svg +24 -0
- package/dist/frontend-core/template/public/flags/BN.svg +17 -0
- package/dist/frontend-core/template/public/flags/BO.svg +1 -0
- package/dist/frontend-core/template/public/flags/BQ.svg +9 -0
- package/dist/frontend-core/template/public/flags/BR.svg +10 -0
- package/dist/frontend-core/template/public/flags/BS.svg +10 -0
- package/dist/frontend-core/template/public/flags/BT.svg +7 -0
- package/dist/frontend-core/template/public/flags/BV.svg +10 -0
- package/dist/frontend-core/template/public/flags/BW.svg +10 -0
- package/dist/frontend-core/template/public/flags/BY.svg +19 -0
- package/dist/frontend-core/template/public/flags/BZ.svg +17 -0
- package/dist/frontend-core/template/public/flags/CA.svg +11 -0
- package/dist/frontend-core/template/public/flags/CC.svg +25 -0
- package/dist/frontend-core/template/public/flags/CD.svg +8 -0
- package/dist/frontend-core/template/public/flags/CF.svg +18 -0
- package/dist/frontend-core/template/public/flags/CG.svg +7 -0
- package/dist/frontend-core/template/public/flags/CH.svg +6 -0
- package/dist/frontend-core/template/public/flags/CI.svg +7 -0
- package/dist/frontend-core/template/public/flags/CK.svg +26 -0
- package/dist/frontend-core/template/public/flags/CL.svg +7 -0
- package/dist/frontend-core/template/public/flags/CM.svg +10 -0
- package/dist/frontend-core/template/public/flags/CN.svg +16 -0
- package/dist/frontend-core/template/public/flags/CO.svg +7 -0
- package/dist/frontend-core/template/public/flags/CR.svg +10 -0
- package/dist/frontend-core/template/public/flags/CU.svg +14 -0
- package/dist/frontend-core/template/public/flags/CV.svg +31 -0
- package/dist/frontend-core/template/public/flags/CW.svg +11 -0
- package/dist/frontend-core/template/public/flags/CX.svg +25 -0
- package/dist/frontend-core/template/public/flags/CY.svg +35 -0
- package/dist/frontend-core/template/public/flags/CZ.svg +7 -0
- package/dist/frontend-core/template/public/flags/DE.svg +7 -0
- package/dist/frontend-core/template/public/flags/DJ.svg +8 -0
- package/dist/frontend-core/template/public/flags/DK.svg +6 -0
- package/dist/frontend-core/template/public/flags/DM.svg +38 -0
- package/dist/frontend-core/template/public/flags/DO.svg +14 -0
- package/dist/frontend-core/template/public/flags/DZ.svg +12 -0
- package/dist/frontend-core/template/public/flags/EC.svg +12 -0
- package/dist/frontend-core/template/public/flags/EE.svg +7 -0
- package/dist/frontend-core/template/public/flags/EG.svg +10 -0
- package/dist/frontend-core/template/public/flags/EH.svg +13 -0
- package/dist/frontend-core/template/public/flags/ER.svg +17 -0
- package/dist/frontend-core/template/public/flags/ES.svg +13 -0
- package/dist/frontend-core/template/public/flags/ET.svg +24 -0
- package/dist/frontend-core/template/public/flags/EU.svg +1 -0
- package/dist/frontend-core/template/public/flags/FI.svg +6 -0
- package/dist/frontend-core/template/public/flags/FJ.svg +22 -0
- package/dist/frontend-core/template/public/flags/FK.svg +41 -0
- package/dist/frontend-core/template/public/flags/FM.svg +14 -0
- package/dist/frontend-core/template/public/flags/FO.svg +8 -0
- package/dist/frontend-core/template/public/flags/FR.svg +7 -0
- package/dist/frontend-core/template/public/flags/G.svg +4 -0
- package/dist/frontend-core/template/public/flags/GA.svg +7 -0
- package/dist/frontend-core/template/public/flags/GB.svg +30 -0
- package/dist/frontend-core/template/public/flags/GD.svg +32 -0
- package/dist/frontend-core/template/public/flags/GE-AB.svg +20 -0
- package/dist/frontend-core/template/public/flags/GE-OS.svg +6 -0
- package/dist/frontend-core/template/public/flags/GE.svg +9 -0
- package/dist/frontend-core/template/public/flags/GF.svg +6 -0
- package/dist/frontend-core/template/public/flags/GG.svg +6 -0
- package/dist/frontend-core/template/public/flags/GH.svg +8 -0
- package/dist/frontend-core/template/public/flags/GI.svg +19 -0
- package/dist/frontend-core/template/public/flags/GL.svg +7 -0
- package/dist/frontend-core/template/public/flags/GM.svg +7 -0
- package/dist/frontend-core/template/public/flags/GN.svg +6 -0
- package/dist/frontend-core/template/public/flags/GP.svg +7 -0
- package/dist/frontend-core/template/public/flags/GQ.svg +25 -0
- package/dist/frontend-core/template/public/flags/GR.svg +16 -0
- package/dist/frontend-core/template/public/flags/GS.svg +35 -0
- package/dist/frontend-core/template/public/flags/GT.svg +13 -0
- package/dist/frontend-core/template/public/flags/GU.svg +16 -0
- package/dist/frontend-core/template/public/flags/GW.svg +8 -0
- package/dist/frontend-core/template/public/flags/GY.svg +8 -0
- package/dist/frontend-core/template/public/flags/HK.svg +1 -0
- package/dist/frontend-core/template/public/flags/HM.svg +28 -0
- package/dist/frontend-core/template/public/flags/HN.svg +18 -0
- package/dist/frontend-core/template/public/flags/HR.svg +32 -0
- package/dist/frontend-core/template/public/flags/HT.svg +11 -0
- package/dist/frontend-core/template/public/flags/HU.svg +7 -0
- package/dist/frontend-core/template/public/flags/IC.svg +6 -0
- package/dist/frontend-core/template/public/flags/ID.svg +6 -0
- package/dist/frontend-core/template/public/flags/IE.svg +7 -0
- package/dist/frontend-core/template/public/flags/IL.svg +12 -0
- package/dist/frontend-core/template/public/flags/IM.svg +17 -0
- package/dist/frontend-core/template/public/flags/IN.svg +11 -0
- package/dist/frontend-core/template/public/flags/IO.svg +70 -0
- package/dist/frontend-core/template/public/flags/IQ.svg +13 -0
- package/dist/frontend-core/template/public/flags/IR.svg +37 -0
- package/dist/frontend-core/template/public/flags/IS.svg +7 -0
- package/dist/frontend-core/template/public/flags/IT.svg +7 -0
- package/dist/frontend-core/template/public/flags/JE.svg +9 -0
- package/dist/frontend-core/template/public/flags/JM.svg +9 -0
- package/dist/frontend-core/template/public/flags/JO.svg +9 -0
- package/dist/frontend-core/template/public/flags/JP.svg +6 -0
- package/dist/frontend-core/template/public/flags/KE.svg +18 -0
- package/dist/frontend-core/template/public/flags/KG.svg +21 -0
- package/dist/frontend-core/template/public/flags/KH.svg +10 -0
- package/dist/frontend-core/template/public/flags/KI.svg +24 -0
- package/dist/frontend-core/template/public/flags/KM.svg +16 -0
- package/dist/frontend-core/template/public/flags/KN.svg +13 -0
- package/dist/frontend-core/template/public/flags/KP.svg +13 -0
- package/dist/frontend-core/template/public/flags/KR.svg +21 -0
- package/dist/frontend-core/template/public/flags/KW.svg +8 -0
- package/dist/frontend-core/template/public/flags/KY.svg +24 -0
- package/dist/frontend-core/template/public/flags/KZ.svg +28 -0
- package/dist/frontend-core/template/public/flags/LA.svg +9 -0
- package/dist/frontend-core/template/public/flags/LB.svg +15 -0
- package/dist/frontend-core/template/public/flags/LC.svg +7 -0
- package/dist/frontend-core/template/public/flags/LI.svg +8 -0
- package/dist/frontend-core/template/public/flags/LICENSE +22 -0
- package/dist/frontend-core/template/public/flags/LK.svg +30 -0
- package/dist/frontend-core/template/public/flags/LR.svg +13 -0
- package/dist/frontend-core/template/public/flags/LS.svg +10 -0
- package/dist/frontend-core/template/public/flags/LT.svg +7 -0
- package/dist/frontend-core/template/public/flags/LU.svg +7 -0
- package/dist/frontend-core/template/public/flags/LV.svg +8 -0
- package/dist/frontend-core/template/public/flags/LY.svg +11 -0
- package/dist/frontend-core/template/public/flags/MA.svg +6 -0
- package/dist/frontend-core/template/public/flags/MC.svg +6 -0
- package/dist/frontend-core/template/public/flags/MD.svg +8 -0
- package/dist/frontend-core/template/public/flags/ME.svg +26 -0
- package/dist/frontend-core/template/public/flags/MF.svg +7 -0
- package/dist/frontend-core/template/public/flags/MG.svg +7 -0
- package/dist/frontend-core/template/public/flags/MH.svg +9 -0
- package/dist/frontend-core/template/public/flags/MK.svg +17 -0
- package/dist/frontend-core/template/public/flags/ML.svg +7 -0
- package/dist/frontend-core/template/public/flags/MM.svg +8 -0
- package/dist/frontend-core/template/public/flags/MN.svg +17 -0
- package/dist/frontend-core/template/public/flags/MO.svg +17 -0
- package/dist/frontend-core/template/public/flags/MP.svg +12 -0
- package/dist/frontend-core/template/public/flags/MQ.svg +44 -0
- package/dist/frontend-core/template/public/flags/MR.svg +9 -0
- package/dist/frontend-core/template/public/flags/MS.svg +21 -0
- package/dist/frontend-core/template/public/flags/MT.svg +7 -0
- package/dist/frontend-core/template/public/flags/MU.svg +8 -0
- package/dist/frontend-core/template/public/flags/MV.svg +7 -0
- package/dist/frontend-core/template/public/flags/MW.svg +8 -0
- package/dist/frontend-core/template/public/flags/MX.svg +11 -0
- package/dist/frontend-core/template/public/flags/MY.svg +19 -0
- package/dist/frontend-core/template/public/flags/MZ.svg +10 -0
- package/dist/frontend-core/template/public/flags/NA.svg +9 -0
- package/dist/frontend-core/template/public/flags/NC.svg +16 -0
- package/dist/frontend-core/template/public/flags/NE.svg +8 -0
- package/dist/frontend-core/template/public/flags/NF.svg +10 -0
- package/dist/frontend-core/template/public/flags/NG.svg +9 -0
- package/dist/frontend-core/template/public/flags/NI.svg +13 -0
- package/dist/frontend-core/template/public/flags/NL.svg +7 -0
- package/dist/frontend-core/template/public/flags/NO.svg +7 -0
- package/dist/frontend-core/template/public/flags/NP.svg +12 -0
- package/dist/frontend-core/template/public/flags/NR.svg +7 -0
- package/dist/frontend-core/template/public/flags/NU.svg +47 -0
- package/dist/frontend-core/template/public/flags/NZ.svg +25 -0
- package/dist/frontend-core/template/public/flags/OM.svg +12 -0
- package/dist/frontend-core/template/public/flags/PA.svg +9 -0
- package/dist/frontend-core/template/public/flags/PE.svg +9 -0
- package/dist/frontend-core/template/public/flags/PF.svg +16 -0
- package/dist/frontend-core/template/public/flags/PG.svg +14 -0
- package/dist/frontend-core/template/public/flags/PH.svg +15 -0
- package/dist/frontend-core/template/public/flags/PK.svg +13 -0
- package/dist/frontend-core/template/public/flags/PL.svg +9 -0
- package/dist/frontend-core/template/public/flags/PM.svg +7 -0
- package/dist/frontend-core/template/public/flags/PN.svg +23 -0
- package/dist/frontend-core/template/public/flags/PR.svg +12 -0
- package/dist/frontend-core/template/public/flags/PS.svg +8 -0
- package/dist/frontend-core/template/public/flags/PT.svg +9 -0
- package/dist/frontend-core/template/public/flags/PW.svg +6 -0
- package/dist/frontend-core/template/public/flags/PY.svg +9 -0
- package/dist/frontend-core/template/public/flags/QA.svg +7 -0
- package/dist/frontend-core/template/public/flags/RE.svg +7 -0
- package/dist/frontend-core/template/public/flags/README.md +1 -0
- package/dist/frontend-core/template/public/flags/RO.svg +7 -0
- package/dist/frontend-core/template/public/flags/RS.svg +13 -0
- package/dist/frontend-core/template/public/flags/RU.svg +8 -0
- package/dist/frontend-core/template/public/flags/RW.svg +8 -0
- package/dist/frontend-core/template/public/flags/SA.svg +12 -0
- package/dist/frontend-core/template/public/flags/SB.svg +14 -0
- package/dist/frontend-core/template/public/flags/SC.svg +9 -0
- package/dist/frontend-core/template/public/flags/SD.svg +8 -0
- package/dist/frontend-core/template/public/flags/SE.svg +6 -0
- package/dist/frontend-core/template/public/flags/SG.svg +14 -0
- package/dist/frontend-core/template/public/flags/SH.svg +32 -0
- package/dist/frontend-core/template/public/flags/SI.svg +10 -0
- package/dist/frontend-core/template/public/flags/SJ.svg +7 -0
- package/dist/frontend-core/template/public/flags/SK.svg +11 -0
- package/dist/frontend-core/template/public/flags/SL.svg +7 -0
- package/dist/frontend-core/template/public/flags/SM.svg +11 -0
- package/dist/frontend-core/template/public/flags/SN.svg +10 -0
- package/dist/frontend-core/template/public/flags/SO.svg +6 -0
- package/dist/frontend-core/template/public/flags/SR.svg +11 -0
- package/dist/frontend-core/template/public/flags/SS.svg +10 -0
- package/dist/frontend-core/template/public/flags/ST.svg +12 -0
- package/dist/frontend-core/template/public/flags/SV.svg +12 -0
- package/dist/frontend-core/template/public/flags/SX.svg +14 -0
- package/dist/frontend-core/template/public/flags/SY.svg +11 -0
- package/dist/frontend-core/template/public/flags/SZ.svg +12 -0
- package/dist/frontend-core/template/public/flags/TA.svg +38 -0
- package/dist/frontend-core/template/public/flags/TC.svg +24 -0
- package/dist/frontend-core/template/public/flags/TD.svg +7 -0
- package/dist/frontend-core/template/public/flags/TF.svg +14 -0
- package/dist/frontend-core/template/public/flags/TG.svg +12 -0
- package/dist/frontend-core/template/public/flags/TH.svg +10 -0
- package/dist/frontend-core/template/public/flags/TJ.svg +17 -0
- package/dist/frontend-core/template/public/flags/TK.svg +15 -0
- package/dist/frontend-core/template/public/flags/TL.svg +8 -0
- package/dist/frontend-core/template/public/flags/TM.svg +34 -0
- package/dist/frontend-core/template/public/flags/TN.svg +10 -0
- package/dist/frontend-core/template/public/flags/TO.svg +7 -0
- package/dist/frontend-core/template/public/flags/TR.svg +8 -0
- package/dist/frontend-core/template/public/flags/TT.svg +7 -0
- package/dist/frontend-core/template/public/flags/TV.svg +21 -0
- package/dist/frontend-core/template/public/flags/TW.svg +9 -0
- package/dist/frontend-core/template/public/flags/TZ.svg +8 -0
- package/dist/frontend-core/template/public/flags/UA.svg +6 -0
- package/dist/frontend-core/template/public/flags/UG.svg +15 -0
- package/dist/frontend-core/template/public/flags/UK.svg +30 -0
- package/dist/frontend-core/template/public/flags/UM.svg +40 -0
- package/dist/frontend-core/template/public/flags/US.svg +40 -0
- package/dist/frontend-core/template/public/flags/UY.svg +17 -0
- package/dist/frontend-core/template/public/flags/UZ.svg +26 -0
- package/dist/frontend-core/template/public/flags/VA.svg +8 -0
- package/dist/frontend-core/template/public/flags/VC.svg +12 -0
- package/dist/frontend-core/template/public/flags/VE.svg +21 -0
- package/dist/frontend-core/template/public/flags/VG.svg +33 -0
- package/dist/frontend-core/template/public/flags/VI.svg +31 -0
- package/dist/frontend-core/template/public/flags/VN.svg +6 -0
- package/dist/frontend-core/template/public/flags/VU.svg +14 -0
- package/dist/frontend-core/template/public/flags/WF.svg +9 -0
- package/dist/frontend-core/template/public/flags/WS.svg +13 -0
- package/dist/frontend-core/template/public/flags/XK.svg +20 -0
- package/dist/frontend-core/template/public/flags/YE.svg +7 -0
- package/dist/frontend-core/template/public/flags/YT.svg +22 -0
- package/dist/frontend-core/template/public/flags/ZA.svg +10 -0
- package/dist/frontend-core/template/public/flags/ZM.svg +9 -0
- package/dist/frontend-core/template/public/flags/ZW.svg +19 -0
- package/dist/frontend-core/template/public/silent-check-sso.html +12 -0
- package/dist/frontend-core/template/public/site.webmanifest +1 -0
- package/dist/frontend-core/template/src/components/ui/accordion/accordion.stories.tsx +47 -0
- package/dist/frontend-core/template/src/components/ui/accordion/accordion.tsx +52 -0
- package/dist/frontend-core/template/src/components/ui/admin-sidebar/admin-sidebar.tsx +195 -0
- package/dist/frontend-core/template/src/components/ui/alert/alert.stories.tsx +61 -0
- package/dist/frontend-core/template/src/components/ui/alert/alert.tsx +45 -0
- package/dist/frontend-core/template/src/components/ui/alert-dialog/alert-dialog.stories.tsx +52 -0
- package/dist/frontend-core/template/src/components/ui/alert-dialog/alert-dialog.tsx +105 -0
- package/dist/frontend-core/template/src/components/ui/avatar/avatar.stories.tsx +30 -0
- package/dist/frontend-core/template/src/components/ui/avatar/avatar.tsx +39 -0
- package/dist/frontend-core/template/src/components/ui/badge/badge.stories.tsx +78 -0
- package/dist/frontend-core/template/src/components/ui/badge/badge.tsx +48 -0
- package/dist/frontend-core/template/src/components/ui/breadcrumb/breadcrumb.stories.tsx +67 -0
- package/dist/frontend-core/template/src/components/ui/breadcrumb/breadcrumb.tsx +85 -0
- package/dist/frontend-core/template/src/components/ui/button/button.stories.tsx +150 -0
- package/dist/frontend-core/template/src/components/ui/button/button.tsx +68 -0
- package/dist/frontend-core/template/src/components/ui/calendar/calendar.stories.tsx +160 -0
- package/dist/frontend-core/template/src/components/ui/calendar/calendar.tsx +293 -0
- package/dist/frontend-core/template/src/components/ui/card/card.stories.tsx +77 -0
- package/dist/frontend-core/template/src/components/ui/card/card.tsx +45 -0
- package/dist/frontend-core/template/src/components/ui/card-hover/card-hover.stories.tsx +29 -0
- package/dist/frontend-core/template/src/components/ui/card-hover/card-hover.tsx +28 -0
- package/dist/frontend-core/template/src/components/ui/carousel/carousel.stories.tsx +154 -0
- package/dist/frontend-core/template/src/components/ui/carousel/carousel.tsx +227 -0
- package/dist/frontend-core/template/src/components/ui/chart/base.tsx +304 -0
- package/dist/frontend-core/template/src/components/ui/chart/index.ts +2 -0
- package/dist/frontend-core/template/src/components/ui/chart/line.stories.tsx +230 -0
- package/dist/frontend-core/template/src/components/ui/chart/line.tsx +121 -0
- package/dist/frontend-core/template/src/components/ui/chart/util.ts +3 -0
- package/dist/frontend-core/template/src/components/ui/checkbox/checkbox.stories.tsx +105 -0
- package/dist/frontend-core/template/src/components/ui/checkbox/checkbox.tsx +79 -0
- package/dist/frontend-core/template/src/components/ui/checkbox/shadcn-checkbox.stories.tsx +90 -0
- package/dist/frontend-core/template/src/components/ui/checkbox/shadcn-checkbox.tsx +54 -0
- package/dist/frontend-core/template/src/components/ui/collapse/collapse.stories.tsx +52 -0
- package/dist/frontend-core/template/src/components/ui/collapse/collapse.tsx +9 -0
- package/dist/frontend-core/template/src/components/ui/combobox/combobox.stories.tsx +207 -0
- package/dist/frontend-core/template/src/components/ui/combobox/combobox.tsx +79 -0
- package/dist/frontend-core/template/src/components/ui/command/command.stories.tsx +186 -0
- package/dist/frontend-core/template/src/components/ui/command/command.tsx +165 -0
- package/dist/frontend-core/template/src/components/ui/command-palette/command-palette.stories.tsx +160 -0
- package/dist/frontend-core/template/src/components/ui/command-palette/command-palette.tsx +134 -0
- package/dist/frontend-core/template/src/components/ui/content-frame/content-frame.stories.tsx +198 -0
- package/dist/frontend-core/template/src/components/ui/content-frame/content-frame.tsx +100 -0
- package/dist/frontend-core/template/src/components/ui/context-menu/context-menu.stories.tsx +78 -0
- package/dist/frontend-core/template/src/components/ui/context-menu/context-menu.tsx +179 -0
- package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/cell-variant-types.ts +11 -0
- package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/checkbox-cell.tsx +112 -0
- package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/date-cell.tsx +158 -0
- package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/gantt-cell.tsx +80 -0
- package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/long-text-cell.tsx +179 -0
- package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/multi-select-cell.tsx +284 -0
- package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/number-cell.tsx +167 -0
- package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/react-node-cell.tsx +32 -0
- package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/select-cell.tsx +175 -0
- package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/short-text-cell.tsx +137 -0
- package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/utils/gantt-timeline.tsx +91 -0
- package/dist/frontend-core/template/src/components/ui/data-grid/cell-variants/utils/gantt-timerange-picker.tsx +330 -0
- package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-cell-wrapper.tsx +212 -0
- package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-cell.tsx +156 -0
- package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-column-header.tsx +317 -0
- package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-context-menu.tsx +262 -0
- package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-row.tsx +123 -0
- package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-search.tsx +211 -0
- package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-types.ts +151 -0
- package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-utils.ts +78 -0
- package/dist/frontend-core/template/src/components/ui/data-grid/data-grid-view-menu.tsx +360 -0
- package/dist/frontend-core/template/src/components/ui/data-grid/data-grid.tsx +217 -0
- package/dist/frontend-core/template/src/components/ui/data-grid/hooks/use-callback-ref.ts +22 -0
- package/dist/frontend-core/template/src/components/ui/data-grid/hooks/use-data-grid.tsx +1888 -0
- package/dist/frontend-core/template/src/components/ui/data-grid/hooks/use-debounced-callback.ts +19 -0
- package/dist/frontend-core/template/src/components/ui/data-table/context-menu-simple.tsx +141 -0
- package/dist/frontend-core/template/src/components/ui/data-table/data-table.stories.tsx +146 -0
- package/dist/frontend-core/template/src/components/ui/data-table/data-table.tsx +448 -0
- package/dist/frontend-core/template/src/components/ui/data-table/renderers/country-array-cell-renderer.tsx +77 -0
- package/dist/frontend-core/template/src/components/ui/data-table/renderers/country-cell-renderer.tsx +56 -0
- package/dist/frontend-core/template/src/components/ui/data-table/renderers/favorite-cell-renderer.tsx +68 -0
- package/dist/frontend-core/template/src/components/ui/data-table/renderers/links-cell-renderer.tsx +205 -0
- package/dist/frontend-core/template/src/components/ui/data-table/utils/columns.ts +351 -0
- package/dist/frontend-core/template/src/components/ui/data-table/utils/data-table.utils.ts +49 -0
- package/dist/frontend-core/template/src/components/ui/date-picker/date-picker.stories.tsx +149 -0
- package/dist/frontend-core/template/src/components/ui/date-picker/date-picker.tsx +30 -0
- package/dist/frontend-core/template/src/components/ui/dialog/dialog.stories.tsx +80 -0
- package/dist/frontend-core/template/src/components/ui/dialog/dialog.tsx +134 -0
- package/dist/frontend-core/template/src/components/ui/drawer/drawer.stories.tsx +104 -0
- package/dist/frontend-core/template/src/components/ui/drawer/drawer.tsx +87 -0
- package/dist/frontend-core/template/src/components/ui/dropdown-menu/dropdown-menu.stories.tsx +168 -0
- package/dist/frontend-core/template/src/components/ui/dropdown-menu/dropdown-menu.tsx +225 -0
- package/dist/frontend-core/template/src/components/ui/input/input.stories.tsx +141 -0
- package/dist/frontend-core/template/src/components/ui/input/input.tsx +47 -0
- package/dist/frontend-core/template/src/components/ui/label/label.stories.tsx +41 -0
- package/dist/frontend-core/template/src/components/ui/label/label.tsx +20 -0
- package/dist/frontend-core/template/src/components/ui/loader/loader.stories.tsx +45 -0
- package/dist/frontend-core/template/src/components/ui/loader/loader.tsx +17 -0
- package/dist/frontend-core/template/src/components/ui/mark-value-renderer/mark-value-renderer.stories.tsx +114 -0
- package/dist/frontend-core/template/src/components/ui/mark-value-renderer/mark-value-renderer.tsx +48 -0
- package/dist/frontend-core/template/src/components/ui/menubar/menu.stories.tsx +134 -0
- package/dist/frontend-core/template/src/components/ui/menubar/menubar.tsx +208 -0
- package/dist/frontend-core/template/src/components/ui/modal/modal.stories.tsx +297 -0
- package/dist/frontend-core/template/src/components/ui/modal/modal.tsx +80 -0
- package/dist/frontend-core/template/src/components/ui/navigation-menu/navigation-menu.stories.tsx +213 -0
- package/dist/frontend-core/template/src/components/ui/navigation-menu/navigation-menu.tsx +142 -0
- package/dist/frontend-core/template/src/components/ui/pagination/pagination.stories.tsx +49 -0
- package/dist/frontend-core/template/src/components/ui/pagination/pagination.tsx +84 -0
- package/dist/frontend-core/template/src/components/ui/popover/popover.stories.tsx +82 -0
- package/dist/frontend-core/template/src/components/ui/popover/popover.tsx +55 -0
- package/dist/frontend-core/template/src/components/ui/progress/progress.stories.tsx +80 -0
- package/dist/frontend-core/template/src/components/ui/progress/progress.tsx +17 -0
- package/dist/frontend-core/template/src/components/ui/radio-group/radio-group.stories.tsx +154 -0
- package/dist/frontend-core/template/src/components/ui/radio-group/radio-group.tsx +68 -0
- package/dist/frontend-core/template/src/components/ui/resizable/resizable.stories.tsx +73 -0
- package/dist/frontend-core/template/src/components/ui/resizable/resizeable.tsx +38 -0
- package/dist/frontend-core/template/src/components/ui/scroll-area/scroll-area.stories.tsx +55 -0
- package/dist/frontend-core/template/src/components/ui/scroll-area/scroll-area.tsx +39 -0
- package/dist/frontend-core/template/src/components/ui/select/select.stories.tsx +297 -0
- package/dist/frontend-core/template/src/components/ui/select/select.tsx +227 -0
- package/dist/frontend-core/template/src/components/ui/separator/separator.tsx +21 -0
- package/dist/frontend-core/template/src/components/ui/separator/seperator.stories.tsx +25 -0
- package/dist/frontend-core/template/src/components/ui/sheet/sheet.stories.tsx +45 -0
- package/dist/frontend-core/template/src/components/ui/sheet/sheet.tsx +107 -0
- package/dist/frontend-core/template/src/components/ui/skeleton/skeleton.stories.tsx +26 -0
- package/dist/frontend-core/template/src/components/ui/skeleton/skeleton.tsx +7 -0
- package/dist/frontend-core/template/src/components/ui/slider/slider.stories.tsx +101 -0
- package/dist/frontend-core/template/src/components/ui/slider/slider.tsx +98 -0
- package/dist/frontend-core/template/src/components/ui/spinner/spinner.stories.tsx +19 -0
- package/dist/frontend-core/template/src/components/ui/spinner/spinner.tsx +21 -0
- package/dist/frontend-core/template/src/components/ui/spreadsheet/engine.ts +411 -0
- package/dist/frontend-core/template/src/components/ui/spreadsheet/format.ts +79 -0
- package/dist/frontend-core/template/src/components/ui/spreadsheet/index.tsx +201 -0
- package/dist/frontend-core/template/src/components/ui/spreadsheet/model.json +2877 -0
- package/dist/frontend-core/template/src/components/ui/spreadsheet/model.xlsm +0 -0
- package/dist/frontend-core/template/src/components/ui/spreadsheet/parser.ts +307 -0
- package/dist/frontend-core/template/src/components/ui/spreadsheet/types.ts +69 -0
- package/dist/frontend-core/template/src/components/ui/switch/switch.stories.tsx +33 -0
- package/dist/frontend-core/template/src/components/ui/switch/switch.tsx +28 -0
- package/dist/frontend-core/template/src/components/ui/tabs/tabs.stories.tsx +215 -0
- package/dist/frontend-core/template/src/components/ui/tabs/tabs.tsx +70 -0
- package/dist/frontend-core/template/src/components/ui/textarea/textarea.stories.tsx +138 -0
- package/dist/frontend-core/template/src/components/ui/textarea/textarea.tsx +40 -0
- package/dist/frontend-core/template/src/components/ui/toast/toast.mdx +31 -0
- package/dist/frontend-core/template/src/components/ui/toast/toast.stories.tsx +89 -0
- package/dist/frontend-core/template/src/components/ui/toggle/toggle.stories.tsx +65 -0
- package/dist/frontend-core/template/src/components/ui/toggle/toggle.tsx +38 -0
- package/dist/frontend-core/template/src/components/ui/toggle-group/toggle-group.stories.tsx +85 -0
- package/dist/frontend-core/template/src/components/ui/toggle-group/toggle-group.tsx +54 -0
- package/dist/frontend-core/template/src/components/ui/tooltip/tooltip.stories.tsx +29 -0
- package/dist/frontend-core/template/src/components/ui/tooltip/tooltip.tsx +29 -0
- package/dist/frontend-core/template/src/context-providers/auth-context-provider.tsx +210 -0
- package/dist/frontend-core/template/src/context-providers/theme-context-provider.tsx +107 -0
- package/dist/frontend-core/template/src/hooks/useDelay.ts +17 -0
- package/dist/frontend-core/template/src/hooks/useFontsLoaded.ts +17 -0
- package/dist/frontend-core/template/src/hooks/useMediaQuery.ts +28 -0
- package/dist/frontend-core/template/src/hooks/useScreenSize.ts +37 -0
- package/dist/frontend-core/template/src/hooks/useScrollLock.tsx +93 -0
- package/dist/frontend-core/template/src/hooks/useWindowFocus.ts +30 -0
- package/dist/frontend-core/template/src/lib/color.ts +277 -0
- package/dist/frontend-core/template/src/lib/compose-refs.ts +62 -0
- package/dist/frontend-core/template/src/lib/config.ts +77 -0
- package/dist/frontend-core/template/src/lib/query-client.ts +25 -0
- package/dist/frontend-core/template/src/lib/react.ts +25 -0
- package/dist/frontend-core/template/src/lib/router.tsx +26 -0
- package/dist/frontend-core/template/src/lib/types.ts +9 -0
- package/dist/frontend-core/template/src/lib/utils.ts +33 -0
- package/dist/frontend-core/template/src/main.tsx +48 -0
- package/dist/frontend-core/template/src/pages/dashboard/dashboard.page.tsx +97 -0
- package/dist/frontend-core/template/src/pages/error/default-error.page.tsx +20 -0
- package/dist/frontend-core/template/src/pages/error/not-found-error.page.tsx +17 -0
- package/dist/frontend-core/template/src/pages/login/login.page.tsx +50 -0
- package/dist/frontend-core/template/src/pages/root-document.tsx +62 -0
- package/dist/frontend-core/template/src/pages/unauthorized/unauthorized.page.tsx +12 -0
- package/dist/frontend-core/template/src/routes/__root.tsx +79 -0
- package/dist/frontend-core/template/src/routes/_auth-routes/dashboard.lazy.tsx +6 -0
- package/dist/frontend-core/template/src/routes/_auth-routes.tsx +19 -0
- package/dist/frontend-core/template/src/routes/index.tsx +8 -0
- package/dist/frontend-core/template/src/routes/login.tsx +6 -0
- package/dist/frontend-core/template/src/routes/unauthorized.tsx +6 -0
- package/dist/frontend-core/template/src/stories/Configure.mdx +363 -0
- package/dist/frontend-core/template/src/stories/assets/accessibility.png +0 -0
- package/dist/frontend-core/template/src/stories/assets/accessibility.svg +1 -0
- package/dist/frontend-core/template/src/stories/assets/addon-library.png +0 -0
- package/dist/frontend-core/template/src/stories/assets/assets.png +0 -0
- package/dist/frontend-core/template/src/stories/assets/avif-test-image.avif +0 -0
- package/dist/frontend-core/template/src/stories/assets/context.png +0 -0
- package/dist/frontend-core/template/src/stories/assets/discord.svg +1 -0
- package/dist/frontend-core/template/src/stories/assets/docs.png +0 -0
- package/dist/frontend-core/template/src/stories/assets/figma-plugin.png +0 -0
- package/dist/frontend-core/template/src/stories/assets/github.svg +1 -0
- package/dist/frontend-core/template/src/stories/assets/share.png +0 -0
- package/dist/frontend-core/template/src/stories/assets/styling.png +0 -0
- package/dist/frontend-core/template/src/stories/assets/testing.png +0 -0
- package/dist/frontend-core/template/src/stories/assets/theming.png +0 -0
- package/dist/frontend-core/template/src/stories/assets/tutorials.svg +1 -0
- package/dist/frontend-core/template/src/stories/assets/youtube.svg +1 -0
- package/dist/frontend-core/template/src/styles/styles.css +33 -0
- package/dist/frontend-core/template/src/styles/theme-default.css +183 -0
- package/dist/frontend-core/template/src/vite-env.d.ts +2 -0
- package/dist/frontend-core/template/tsconfig.json +103 -0
- package/dist/frontend-core/template/vite.config.ts +167 -0
- package/dist/frontend-core/template/vitest.shims.d.ts +1 -0
- package/dist/frontend-core/types/component.d.ts +1 -0
- package/dist/frontend-core/types/component.js +3 -0
- package/dist/frontend-core/types/component.js.map +1 -0
- package/dist/frontend-core/types/contextprovider.d.ts +1 -0
- package/dist/frontend-core/types/contextprovider.js +3 -0
- package/dist/frontend-core/types/contextprovider.js.map +1 -0
- package/dist/frontend-core/types/hook.d.ts +1 -0
- package/dist/frontend-core/types/hook.js +3 -0
- package/dist/frontend-core/types/hook.js.map +1 -0
- package/dist/frontend-core/types.d.ts +35 -0
- package/dist/frontend-core/types.js +3 -0
- package/dist/frontend-core/types.js.map +1 -0
- package/dist/frontend-forms/forms.generator.d.ts +54 -0
- package/dist/frontend-forms/forms.generator.js +190 -0
- package/dist/frontend-forms/forms.generator.js.map +1 -0
- package/dist/frontend-forms/generators/discriminated-union/fields.generator.d.ts +11 -0
- package/dist/frontend-forms/generators/discriminated-union/fields.generator.js +310 -0
- package/dist/frontend-forms/generators/discriminated-union/fields.generator.js.map +1 -0
- package/dist/frontend-forms/generators/discriminated-union/inputs.generator.d.ts +7 -0
- package/dist/frontend-forms/generators/discriminated-union/inputs.generator.js +69 -0
- package/dist/frontend-forms/generators/discriminated-union/inputs.generator.js.map +1 -0
- package/dist/frontend-forms/generators/enum/inputs.generator.d.ts +5 -0
- package/dist/frontend-forms/generators/enum/inputs.generator.js +69 -0
- package/dist/frontend-forms/generators/enum/inputs.generator.js.map +1 -0
- package/dist/frontend-forms/generators/model/forms.generator.d.ts +11 -0
- package/dist/frontend-forms/generators/model/forms.generator.js +549 -0
- package/dist/frontend-forms/generators/model/forms.generator.js.map +1 -0
- package/dist/frontend-forms/generators/model/inputs.generator.d.ts +5 -0
- package/dist/frontend-forms/generators/model/inputs.generator.js +148 -0
- package/dist/frontend-forms/generators/model/inputs.generator.js.map +1 -0
- package/dist/frontend-forms/index.d.ts +5 -0
- package/dist/frontend-forms/index.js +40 -0
- package/dist/frontend-forms/index.js.map +1 -0
- package/dist/frontend-forms/template/src/components/ui/field/field.tsx +226 -0
- package/dist/frontend-tables/generators/model-context.generator.d.ts +5 -0
- package/dist/frontend-tables/generators/model-context.generator.js +72 -0
- package/dist/frontend-tables/generators/model-context.generator.js.map +1 -0
- package/dist/frontend-tables/generators/model-table.generator.d.ts +5 -0
- package/dist/frontend-tables/generators/model-table.generator.js +339 -0
- package/dist/frontend-tables/generators/model-table.generator.js.map +1 -0
- package/dist/frontend-tables/index.d.ts +5 -0
- package/dist/frontend-tables/index.js +40 -0
- package/dist/frontend-tables/index.js.map +1 -0
- package/dist/frontend-tables/tables.generator.d.ts +49 -0
- package/dist/frontend-tables/tables.generator.js +104 -0
- package/dist/frontend-tables/tables.generator.js.map +1 -0
- package/dist/frontend-trpc-client/generators/model-hook.generator.d.ts +5 -0
- package/dist/frontend-trpc-client/generators/model-hook.generator.js +107 -0
- package/dist/frontend-trpc-client/generators/model-hook.generator.js.map +1 -0
- package/dist/frontend-trpc-client/generators/trpc-client.generator.d.ts +5 -0
- package/dist/frontend-trpc-client/generators/trpc-client.generator.js +64 -0
- package/dist/frontend-trpc-client/generators/trpc-client.generator.js.map +1 -0
- package/dist/frontend-trpc-client/index.d.ts +4 -0
- package/dist/frontend-trpc-client/index.js +40 -0
- package/dist/frontend-trpc-client/index.js.map +1 -0
- package/dist/frontend-trpc-client/trpc-client.generator.d.ts +82 -0
- package/dist/frontend-trpc-client/trpc-client.generator.js +125 -0
- package/dist/frontend-trpc-client/trpc-client.generator.js.map +1 -0
- package/dist/generators.d.ts +2 -0
- package/dist/generators.js +59 -0
- package/dist/generators.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +125 -0
- package/dist/index.js.map +1 -0
- package/dist/mock-data/generators/data-mocker.generator.d.ts +2 -0
- package/dist/mock-data/generators/data-mocker.generator.js +235 -0
- package/dist/mock-data/generators/data-mocker.generator.js.map +1 -0
- package/dist/mock-data/generators/id-tracker.generator.d.ts +2 -0
- package/dist/mock-data/generators/id-tracker.generator.js +101 -0
- package/dist/mock-data/generators/id-tracker.generator.js.map +1 -0
- package/dist/mock-data/generators/model-stub.generator.d.ts +10 -0
- package/dist/mock-data/generators/model-stub.generator.js +179 -0
- package/dist/mock-data/generators/model-stub.generator.js.map +1 -0
- package/dist/mock-data/index.d.ts +4 -0
- package/dist/mock-data/index.js +40 -0
- package/dist/mock-data/index.js.map +1 -0
- package/dist/mock-data/mock-data.generator.d.ts +34 -0
- package/dist/mock-data/mock-data.generator.js +121 -0
- package/dist/mock-data/mock-data.generator.js.map +1 -0
- package/dist/seed-data/generator/excel-template.generator.d.ts +8 -0
- package/dist/seed-data/generator/excel-template.generator.js +221 -0
- package/dist/seed-data/generator/excel-template.generator.js.map +1 -0
- package/dist/seed-data/generator/model-seed-data.generator.d.ts +15 -0
- package/dist/seed-data/generator/model-seed-data.generator.js +231 -0
- package/dist/seed-data/generator/model-seed-data.generator.js.map +1 -0
- package/dist/seed-data/generator/seed-migration-types.generator.d.ts +2 -0
- package/dist/seed-data/generator/seed-migration-types.generator.js +44 -0
- package/dist/seed-data/generator/seed-migration-types.generator.js.map +1 -0
- package/dist/seed-data/generator/seed-migrations.generator.d.ts +2 -0
- package/dist/seed-data/generator/seed-migrations.generator.js +57 -0
- package/dist/seed-data/generator/seed-migrations.generator.js.map +1 -0
- package/dist/seed-data/index.d.ts +5 -0
- package/dist/seed-data/index.js +40 -0
- package/dist/seed-data/index.js.map +1 -0
- package/dist/seed-data/seed-data.generator.d.ts +74 -0
- package/dist/seed-data/seed-data.generator.js +131 -0
- package/dist/seed-data/seed-data.generator.js.map +1 -0
- package/dist/types/generators/discriminated-union.generator.d.ts +6 -0
- package/dist/types/generators/discriminated-union.generator.js +86 -0
- package/dist/types/generators/discriminated-union.generator.js.map +1 -0
- package/dist/types/generators/dto-types.generator.d.ts +2 -0
- package/dist/types/generators/dto-types.generator.js +32 -0
- package/dist/types/generators/dto-types.generator.js.map +1 -0
- package/dist/types/generators/enum-type.generator.d.ts +2 -0
- package/dist/types/generators/enum-type.generator.js +65 -0
- package/dist/types/generators/enum-type.generator.js.map +1 -0
- package/dist/types/generators/model-type.generator.d.ts +13 -0
- package/dist/types/generators/model-type.generator.js +171 -0
- package/dist/types/generators/model-type.generator.js.map +1 -0
- package/dist/types/generators/models.generator.d.ts +2 -0
- package/dist/types/generators/models.generator.js +9 -0
- package/dist/types/generators/models.generator.js.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.js +10 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/types.generator.d.ts +179 -0
- package/dist/types/types.generator.js +220 -0
- package/dist/types/types.generator.js.map +1 -0
- package/dist/types/types.generator.mock.d.ts +2 -0
- package/dist/types/types.generator.mock.js +16 -0
- package/dist/types/types.generator.mock.js.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,1888 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ColumnDef,
|
|
3
|
+
getCoreRowModel,
|
|
4
|
+
getSortedRowModel,
|
|
5
|
+
type RowSelectionState,
|
|
6
|
+
type SortingState,
|
|
7
|
+
type TableOptions,
|
|
8
|
+
type Updater,
|
|
9
|
+
useReactTable,
|
|
10
|
+
} from '@tanstack/react-table'
|
|
11
|
+
import { useVirtualizer, type Virtualizer } from '@tanstack/react-virtual'
|
|
12
|
+
|
|
13
|
+
import * as React from 'react'
|
|
14
|
+
|
|
15
|
+
import { DataGridCell } from '@components/ui/data-grid/data-grid-cell'
|
|
16
|
+
import type {
|
|
17
|
+
CellPosition,
|
|
18
|
+
ContextMenuState,
|
|
19
|
+
NavigationDirection,
|
|
20
|
+
RowHeightValue,
|
|
21
|
+
SearchState,
|
|
22
|
+
SelectionState,
|
|
23
|
+
UpdateCell,
|
|
24
|
+
} from '@components/ui/data-grid/data-grid-types'
|
|
25
|
+
import { getCellKey, getRowHeightValue, parseCellKey } from '@components/ui/data-grid/data-grid-utils'
|
|
26
|
+
|
|
27
|
+
const DEFAULT_ROW_HEIGHT = 'short'
|
|
28
|
+
const OVERSCAN = 3
|
|
29
|
+
const VIEWPORT_OFFSET = 1
|
|
30
|
+
const MIN_COLUMN_SIZE = 60
|
|
31
|
+
const MAX_COLUMN_SIZE = 800
|
|
32
|
+
const SEARCH_SHORTCUT_KEY = 'f'
|
|
33
|
+
const NON_NAVIGABLE_COLUMN_IDS = ['select', 'actions']
|
|
34
|
+
|
|
35
|
+
const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect
|
|
36
|
+
|
|
37
|
+
function useLazyRef<T>(fn: () => T): React.RefObject<T> {
|
|
38
|
+
const ref = React.useRef<T | null>(null)
|
|
39
|
+
if (ref.current === null) {
|
|
40
|
+
ref.current = fn()
|
|
41
|
+
}
|
|
42
|
+
return ref as React.RefObject<T>
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function useAsRef<T>(data: T) {
|
|
46
|
+
const ref = React.useRef<T>(data)
|
|
47
|
+
|
|
48
|
+
useIsomorphicLayoutEffect(() => {
|
|
49
|
+
ref.current = data
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
return ref
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
type DataGridState = {
|
|
56
|
+
sorting: SortingState
|
|
57
|
+
rowHeight: RowHeightValue
|
|
58
|
+
rowSelection: RowSelectionState
|
|
59
|
+
selectionState: SelectionState
|
|
60
|
+
focusedCell: CellPosition | null
|
|
61
|
+
editingCell: CellPosition | null
|
|
62
|
+
contextMenu: ContextMenuState
|
|
63
|
+
searchQuery: string
|
|
64
|
+
searchMatches: CellPosition[]
|
|
65
|
+
matchIndex: number
|
|
66
|
+
searchOpen: boolean
|
|
67
|
+
lastClickedRowIndex: number | null
|
|
68
|
+
isScrolling: boolean
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
type DataGridStore = {
|
|
72
|
+
subscribe: (callback: () => void) => () => void
|
|
73
|
+
getState: () => DataGridState
|
|
74
|
+
setState: <K extends keyof DataGridState>(key: K, value: DataGridState[K]) => void
|
|
75
|
+
notify: () => void
|
|
76
|
+
batch: (fn: () => void) => void
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function useStore<T>(store: DataGridStore, selector: (state: DataGridState) => T): T {
|
|
80
|
+
const getSnapshot = React.useCallback(() => selector(store.getState()), [store, selector])
|
|
81
|
+
|
|
82
|
+
return React.useSyncExternalStore(store.subscribe, getSnapshot, getSnapshot)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
type UseDataGridProps<TData> = {
|
|
86
|
+
onDataChange?: (data: TData[]) => void
|
|
87
|
+
onRowAdd?: (event?: React.MouseEvent<HTMLDivElement>) =>
|
|
88
|
+
| Partial<CellPosition>
|
|
89
|
+
| Promise<Partial<CellPosition>>
|
|
90
|
+
| null
|
|
91
|
+
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type
|
|
92
|
+
| void // void is needed here to allow functions without explicit return
|
|
93
|
+
onRowsDelete?: (rows: TData[], rowIndices: number[]) => void | Promise<void>
|
|
94
|
+
onCellFocus?: (args: { rowIndex: number; columnId: string }) => void
|
|
95
|
+
rowHeight?: RowHeightValue
|
|
96
|
+
overscan?: number
|
|
97
|
+
autoFocus?: boolean | Partial<CellPosition>
|
|
98
|
+
enableColumnSelection?: boolean
|
|
99
|
+
enableSearch?: boolean
|
|
100
|
+
} & Omit<TableOptions<TData>, 'pageCount' | 'getCoreRowModel'>
|
|
101
|
+
|
|
102
|
+
function useDataGrid<TData>({
|
|
103
|
+
columns,
|
|
104
|
+
data,
|
|
105
|
+
onDataChange,
|
|
106
|
+
onRowAdd: onRowAddProp,
|
|
107
|
+
onRowsDelete: onRowsDeleteProp,
|
|
108
|
+
onCellFocus: onCellFocusProp,
|
|
109
|
+
rowHeight: rowHeightProp = DEFAULT_ROW_HEIGHT,
|
|
110
|
+
overscan = OVERSCAN,
|
|
111
|
+
initialState,
|
|
112
|
+
autoFocus = false,
|
|
113
|
+
enableColumnSelection = false,
|
|
114
|
+
enableSearch = false,
|
|
115
|
+
...dataGridProps
|
|
116
|
+
}: UseDataGridProps<TData>) {
|
|
117
|
+
const dataGridRef = React.useRef<HTMLDivElement>(null)
|
|
118
|
+
const tableRef = React.useRef<ReturnType<typeof useReactTable<TData>>>(null)
|
|
119
|
+
const rowVirtualizerRef = React.useRef<Virtualizer<HTMLDivElement, Element>>(null)
|
|
120
|
+
const headerRef = React.useRef<HTMLDivElement>(null)
|
|
121
|
+
const rowMapRef = React.useRef<Map<number, HTMLDivElement>>(new Map())
|
|
122
|
+
const footerRef = React.useRef<HTMLDivElement>(null)
|
|
123
|
+
|
|
124
|
+
const dataGridPropsRef = useAsRef(dataGridProps)
|
|
125
|
+
const listenersRef = useLazyRef(() => new Set<() => void>())
|
|
126
|
+
|
|
127
|
+
const stateRef = useLazyRef<DataGridState>(() => {
|
|
128
|
+
return {
|
|
129
|
+
sorting: initialState?.sorting ?? [],
|
|
130
|
+
rowHeight: rowHeightProp,
|
|
131
|
+
rowSelection: initialState?.rowSelection ?? {},
|
|
132
|
+
selectionState: {
|
|
133
|
+
selectedCells: new Set(),
|
|
134
|
+
selectionRange: null,
|
|
135
|
+
isSelecting: false,
|
|
136
|
+
},
|
|
137
|
+
focusedCell: null,
|
|
138
|
+
editingCell: null,
|
|
139
|
+
contextMenu: {
|
|
140
|
+
open: false,
|
|
141
|
+
x: 0,
|
|
142
|
+
y: 0,
|
|
143
|
+
},
|
|
144
|
+
searchQuery: '',
|
|
145
|
+
searchMatches: [],
|
|
146
|
+
matchIndex: -1,
|
|
147
|
+
searchOpen: false,
|
|
148
|
+
lastClickedRowIndex: null,
|
|
149
|
+
isScrolling: false,
|
|
150
|
+
}
|
|
151
|
+
})
|
|
152
|
+
|
|
153
|
+
const store = React.useMemo<DataGridStore>(() => {
|
|
154
|
+
let isBatching = false
|
|
155
|
+
let pendingNotification = false
|
|
156
|
+
|
|
157
|
+
return {
|
|
158
|
+
subscribe: (callback) => {
|
|
159
|
+
listenersRef.current.add(callback)
|
|
160
|
+
return () => listenersRef.current.delete(callback)
|
|
161
|
+
},
|
|
162
|
+
getState: () => stateRef.current,
|
|
163
|
+
setState: (key, value) => {
|
|
164
|
+
if (Object.is(stateRef.current[key], value)) {
|
|
165
|
+
return
|
|
166
|
+
}
|
|
167
|
+
stateRef.current[key] = value
|
|
168
|
+
|
|
169
|
+
if (isBatching) {
|
|
170
|
+
pendingNotification = true
|
|
171
|
+
} else {
|
|
172
|
+
if (!pendingNotification) {
|
|
173
|
+
pendingNotification = true
|
|
174
|
+
queueMicrotask(() => {
|
|
175
|
+
pendingNotification = false
|
|
176
|
+
store.notify()
|
|
177
|
+
})
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
notify: () => {
|
|
182
|
+
for (const listener of listenersRef.current) {
|
|
183
|
+
listener()
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
batch: (fn) => {
|
|
187
|
+
if (isBatching) {
|
|
188
|
+
fn()
|
|
189
|
+
return
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
isBatching = true
|
|
193
|
+
const wasPending = pendingNotification
|
|
194
|
+
pendingNotification = false
|
|
195
|
+
|
|
196
|
+
try {
|
|
197
|
+
fn()
|
|
198
|
+
} finally {
|
|
199
|
+
isBatching = false
|
|
200
|
+
if (pendingNotification || wasPending) {
|
|
201
|
+
pendingNotification = false
|
|
202
|
+
store.notify()
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
}
|
|
207
|
+
}, [listenersRef, stateRef])
|
|
208
|
+
|
|
209
|
+
const focusedCell = useStore(store, (state) => state.focusedCell)
|
|
210
|
+
const editingCell = useStore(store, (state) => state.editingCell)
|
|
211
|
+
const selectionState = useStore(store, (state) => state.selectionState)
|
|
212
|
+
const searchQuery = useStore(store, (state) => state.searchQuery)
|
|
213
|
+
const searchMatches = useStore(store, (state) => state.searchMatches)
|
|
214
|
+
const matchIndex = useStore(store, (state) => state.matchIndex)
|
|
215
|
+
const searchOpen = useStore(store, (state) => state.searchOpen)
|
|
216
|
+
const sorting = useStore(store, (state) => state.sorting)
|
|
217
|
+
const rowSelection = useStore(store, (state) => state.rowSelection)
|
|
218
|
+
const contextMenu = useStore(store, (state) => state.contextMenu)
|
|
219
|
+
const rowHeight = useStore(store, (state) => state.rowHeight)
|
|
220
|
+
const isScrolling = useStore(store, (state) => state.isScrolling)
|
|
221
|
+
|
|
222
|
+
const rowHeightValue = getRowHeightValue(rowHeight)
|
|
223
|
+
|
|
224
|
+
const columnIds = React.useMemo(() => {
|
|
225
|
+
return columns
|
|
226
|
+
.map((c) => {
|
|
227
|
+
if (c.id) {
|
|
228
|
+
return c.id
|
|
229
|
+
}
|
|
230
|
+
if ('accessorKey' in c) {
|
|
231
|
+
return c.accessorKey as string
|
|
232
|
+
}
|
|
233
|
+
return undefined
|
|
234
|
+
})
|
|
235
|
+
.filter((id): id is string => Boolean(id))
|
|
236
|
+
}, [columns])
|
|
237
|
+
|
|
238
|
+
// Build a storage key for this table. We use the current pathname plus the column ids so different tables/pages get separate storage slots
|
|
239
|
+
const storageKey = React.useMemo(() => {
|
|
240
|
+
if (typeof window === 'undefined') {
|
|
241
|
+
return undefined
|
|
242
|
+
}
|
|
243
|
+
const path = window.location.pathname || 'unknown'
|
|
244
|
+
const cols = columnIds.join('|')
|
|
245
|
+
return `pxl.dataGrid:${path}:${cols}`
|
|
246
|
+
}, [columnIds])
|
|
247
|
+
|
|
248
|
+
// Try to load persisted table state (order/visibility/pinning) from localStorage and merge it into the initial state the table will be created with.
|
|
249
|
+
const persistedState = React.useMemo(() => {
|
|
250
|
+
if (!storageKey) {
|
|
251
|
+
return undefined
|
|
252
|
+
}
|
|
253
|
+
try {
|
|
254
|
+
const raw = localStorage.getItem(storageKey)
|
|
255
|
+
if (!raw) {
|
|
256
|
+
return undefined
|
|
257
|
+
}
|
|
258
|
+
const parsed = JSON.parse(raw)
|
|
259
|
+
return parsed
|
|
260
|
+
} catch (_) {
|
|
261
|
+
return undefined
|
|
262
|
+
}
|
|
263
|
+
}, [storageKey])
|
|
264
|
+
|
|
265
|
+
// Merge persisted state (if any) into the table initial state so stored column order / visibility / pinning get reapplied on load.
|
|
266
|
+
const mergedInitialState = React.useMemo(() => {
|
|
267
|
+
const base = { ...(initialState ?? {}) } as Record<string, unknown>
|
|
268
|
+
|
|
269
|
+
if (persistedState) {
|
|
270
|
+
try {
|
|
271
|
+
if (persistedState.columnOrder) {
|
|
272
|
+
base.columnOrder = persistedState.columnOrder
|
|
273
|
+
}
|
|
274
|
+
if (persistedState.columnVisibility) {
|
|
275
|
+
base.columnVisibility = persistedState.columnVisibility
|
|
276
|
+
}
|
|
277
|
+
if (persistedState.columnPinning) {
|
|
278
|
+
base.columnPinning = persistedState.columnPinning
|
|
279
|
+
}
|
|
280
|
+
} catch (_) {
|
|
281
|
+
// ignore malformed persisted state
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
return base as typeof initialState
|
|
286
|
+
}, [initialState, persistedState])
|
|
287
|
+
|
|
288
|
+
// Derive the current visible, ordered column ids from the table when available.
|
|
289
|
+
// This respects `table.setColumnOrder(...)` and column visibility.
|
|
290
|
+
const getNavigableColumnIds = React.useCallback(() => {
|
|
291
|
+
const t = tableRef.current
|
|
292
|
+
if (t) {
|
|
293
|
+
return t
|
|
294
|
+
.getVisibleLeafColumns()
|
|
295
|
+
.map((c) => c.id)
|
|
296
|
+
.filter((c) => !NON_NAVIGABLE_COLUMN_IDS.includes(c))
|
|
297
|
+
}
|
|
298
|
+
return columnIds.filter((c) => !NON_NAVIGABLE_COLUMN_IDS.includes(c))
|
|
299
|
+
}, [columnIds])
|
|
300
|
+
|
|
301
|
+
const onDataUpdate = React.useCallback(
|
|
302
|
+
(updates: UpdateCell | UpdateCell[]) => {
|
|
303
|
+
const updateArray = Array.isArray(updates) ? updates : [updates]
|
|
304
|
+
|
|
305
|
+
if (updateArray.length === 0) {
|
|
306
|
+
return
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
const currentTable = tableRef.current
|
|
310
|
+
const rows = currentTable?.getRowModel().rows
|
|
311
|
+
|
|
312
|
+
const rowUpdatesMap = new Map<number, Omit<UpdateCell, 'rowIndex'>[]>()
|
|
313
|
+
|
|
314
|
+
for (const update of updateArray) {
|
|
315
|
+
if (!rows || !currentTable) {
|
|
316
|
+
const existingUpdates = rowUpdatesMap.get(update.rowIndex) ?? []
|
|
317
|
+
existingUpdates.push({
|
|
318
|
+
columnId: update.columnId,
|
|
319
|
+
value: update.value,
|
|
320
|
+
})
|
|
321
|
+
rowUpdatesMap.set(update.rowIndex, existingUpdates)
|
|
322
|
+
} else {
|
|
323
|
+
const row = rows[update.rowIndex]
|
|
324
|
+
if (!row) {
|
|
325
|
+
continue
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
const originalData = row.original
|
|
329
|
+
const originalRowIndex = data.indexOf(originalData)
|
|
330
|
+
if (originalRowIndex === -1) {
|
|
331
|
+
continue
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
const existingUpdates = rowUpdatesMap.get(originalRowIndex) ?? []
|
|
335
|
+
existingUpdates.push({
|
|
336
|
+
columnId: update.columnId,
|
|
337
|
+
value: update.value,
|
|
338
|
+
})
|
|
339
|
+
rowUpdatesMap.set(originalRowIndex, existingUpdates)
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
// Also notify any per-cell change handler if present on the table meta.
|
|
343
|
+
const currentMeta = tableRef.current?.options.meta
|
|
344
|
+
if (currentMeta?.onCellChange) {
|
|
345
|
+
for (const u of updateArray) {
|
|
346
|
+
try {
|
|
347
|
+
currentMeta.onCellChange(u)
|
|
348
|
+
} catch (_) {
|
|
349
|
+
// Ignore handler errors here to avoid breaking the grid behavior
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
const newData = data.map((row, index) => {
|
|
355
|
+
const updates = rowUpdatesMap.get(index)
|
|
356
|
+
if (!updates) {
|
|
357
|
+
return row
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
const updatedRow = { ...row } as Record<string, unknown>
|
|
361
|
+
for (const { columnId, value } of updates) {
|
|
362
|
+
updatedRow[columnId] = value
|
|
363
|
+
}
|
|
364
|
+
return updatedRow as TData
|
|
365
|
+
})
|
|
366
|
+
|
|
367
|
+
onDataChange?.(newData)
|
|
368
|
+
},
|
|
369
|
+
[data, onDataChange],
|
|
370
|
+
)
|
|
371
|
+
|
|
372
|
+
const getIsCellSelected = React.useCallback(
|
|
373
|
+
(rowIndex: number, columnId: string) => {
|
|
374
|
+
return selectionState.selectedCells.has(getCellKey(rowIndex, columnId))
|
|
375
|
+
},
|
|
376
|
+
[selectionState.selectedCells],
|
|
377
|
+
)
|
|
378
|
+
|
|
379
|
+
const clearSelection = React.useCallback(() => {
|
|
380
|
+
store.batch(() => {
|
|
381
|
+
store.setState('selectionState', {
|
|
382
|
+
selectedCells: new Set(),
|
|
383
|
+
selectionRange: null,
|
|
384
|
+
isSelecting: false,
|
|
385
|
+
})
|
|
386
|
+
store.setState('rowSelection', {})
|
|
387
|
+
})
|
|
388
|
+
}, [store])
|
|
389
|
+
|
|
390
|
+
const selectAll = React.useCallback(() => {
|
|
391
|
+
const allCells = new Set<string>()
|
|
392
|
+
const currentTable = tableRef.current
|
|
393
|
+
const rows = currentTable?.getRowModel().rows ?? []
|
|
394
|
+
const rowCount = rows.length ?? data.length
|
|
395
|
+
|
|
396
|
+
for (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {
|
|
397
|
+
for (const columnId of columnIds) {
|
|
398
|
+
allCells.add(getCellKey(rowIndex, columnId))
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
const firstColumnId = columnIds[0]
|
|
403
|
+
const lastColumnId = columnIds[columnIds.length - 1]
|
|
404
|
+
|
|
405
|
+
store.setState('selectionState', {
|
|
406
|
+
selectedCells: allCells,
|
|
407
|
+
selectionRange:
|
|
408
|
+
columnIds.length > 0 && rowCount > 0 && firstColumnId && lastColumnId
|
|
409
|
+
? {
|
|
410
|
+
start: { rowIndex: 0, columnId: firstColumnId },
|
|
411
|
+
end: { rowIndex: rowCount - 1, columnId: lastColumnId },
|
|
412
|
+
}
|
|
413
|
+
: null,
|
|
414
|
+
isSelecting: false,
|
|
415
|
+
})
|
|
416
|
+
}, [columnIds, data.length, store])
|
|
417
|
+
|
|
418
|
+
const selectColumn = React.useCallback(
|
|
419
|
+
(columnId: string) => {
|
|
420
|
+
const currentTable = tableRef.current
|
|
421
|
+
const rows = currentTable?.getRowModel().rows ?? []
|
|
422
|
+
const rowCount = rows.length ?? data.length
|
|
423
|
+
|
|
424
|
+
if (rowCount === 0) {
|
|
425
|
+
return
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
const selectedCells = new Set<string>()
|
|
429
|
+
|
|
430
|
+
for (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {
|
|
431
|
+
selectedCells.add(getCellKey(rowIndex, columnId))
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
store.setState('selectionState', {
|
|
435
|
+
selectedCells,
|
|
436
|
+
selectionRange: {
|
|
437
|
+
start: { rowIndex: 0, columnId },
|
|
438
|
+
end: { rowIndex: rowCount - 1, columnId },
|
|
439
|
+
},
|
|
440
|
+
isSelecting: false,
|
|
441
|
+
})
|
|
442
|
+
},
|
|
443
|
+
[data.length, store],
|
|
444
|
+
)
|
|
445
|
+
|
|
446
|
+
const selectRange = React.useCallback(
|
|
447
|
+
(start: CellPosition, end: CellPosition, isSelecting = false) => {
|
|
448
|
+
// Use the current visible/displayed column order so drag selection
|
|
449
|
+
// follows the UI when users reorder columns.
|
|
450
|
+
const visibleCols = getNavigableColumnIds()
|
|
451
|
+
const startColIndex = visibleCols.indexOf(start.columnId)
|
|
452
|
+
const endColIndex = visibleCols.indexOf(end.columnId)
|
|
453
|
+
|
|
454
|
+
const minRow = Math.min(start.rowIndex, end.rowIndex)
|
|
455
|
+
const maxRow = Math.max(start.rowIndex, end.rowIndex)
|
|
456
|
+
const minCol = Math.min(startColIndex, endColIndex)
|
|
457
|
+
const maxCol = Math.max(startColIndex, endColIndex)
|
|
458
|
+
|
|
459
|
+
const selectedCells = new Set<string>()
|
|
460
|
+
|
|
461
|
+
for (let rowIndex = minRow; rowIndex <= maxRow; rowIndex++) {
|
|
462
|
+
for (let colIndex = minCol; colIndex <= maxCol; colIndex++) {
|
|
463
|
+
const columnId = visibleCols[colIndex]
|
|
464
|
+
if (columnId) {
|
|
465
|
+
selectedCells.add(getCellKey(rowIndex, columnId))
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
store.setState('selectionState', {
|
|
471
|
+
selectedCells,
|
|
472
|
+
selectionRange: { start, end },
|
|
473
|
+
isSelecting,
|
|
474
|
+
})
|
|
475
|
+
},
|
|
476
|
+
[getNavigableColumnIds, store],
|
|
477
|
+
)
|
|
478
|
+
|
|
479
|
+
const focusCell = React.useCallback(
|
|
480
|
+
(rowIndex: number, columnId: string) => {
|
|
481
|
+
store.batch(() => {
|
|
482
|
+
store.setState('focusedCell', { rowIndex, columnId })
|
|
483
|
+
store.setState('editingCell', null)
|
|
484
|
+
})
|
|
485
|
+
|
|
486
|
+
// Notify parent component about cell focus change
|
|
487
|
+
onCellFocusProp?.({ rowIndex, columnId })
|
|
488
|
+
|
|
489
|
+
const currentState = store.getState()
|
|
490
|
+
|
|
491
|
+
if (currentState.searchOpen) {
|
|
492
|
+
return
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
if (dataGridRef.current && document.activeElement !== dataGridRef.current) {
|
|
496
|
+
dataGridRef.current.focus()
|
|
497
|
+
}
|
|
498
|
+
},
|
|
499
|
+
[store, onCellFocusProp],
|
|
500
|
+
)
|
|
501
|
+
|
|
502
|
+
const onRowsDelete = React.useCallback(
|
|
503
|
+
async (rowIndices: number[]) => {
|
|
504
|
+
if (!onRowsDeleteProp || rowIndices.length === 0) {
|
|
505
|
+
return
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
const currentTable = tableRef.current
|
|
509
|
+
const rows = currentTable?.getRowModel().rows
|
|
510
|
+
|
|
511
|
+
if (!rows || rows.length === 0) {
|
|
512
|
+
return
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
const currentState = store.getState()
|
|
516
|
+
const currentFocusedColumn = currentState.focusedCell?.columnId ?? getNavigableColumnIds()[0]
|
|
517
|
+
|
|
518
|
+
const minDeletedRowIndex = Math.min(...rowIndices)
|
|
519
|
+
|
|
520
|
+
const rowsToDelete: TData[] = []
|
|
521
|
+
for (const rowIndex of rowIndices) {
|
|
522
|
+
const row = rows[rowIndex]
|
|
523
|
+
if (row) {
|
|
524
|
+
rowsToDelete.push(row.original)
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
await onRowsDeleteProp(rowsToDelete, rowIndices)
|
|
529
|
+
|
|
530
|
+
store.batch(() => {
|
|
531
|
+
store.setState('selectionState', {
|
|
532
|
+
selectedCells: new Set(),
|
|
533
|
+
selectionRange: null,
|
|
534
|
+
isSelecting: false,
|
|
535
|
+
})
|
|
536
|
+
store.setState('rowSelection', {})
|
|
537
|
+
store.setState('editingCell', null)
|
|
538
|
+
})
|
|
539
|
+
|
|
540
|
+
requestAnimationFrame(() => {
|
|
541
|
+
const currentTable = tableRef.current
|
|
542
|
+
const currentRows = currentTable?.getRowModel().rows ?? []
|
|
543
|
+
const newRowCount = currentRows.length ?? data.length
|
|
544
|
+
|
|
545
|
+
if (newRowCount > 0 && currentFocusedColumn) {
|
|
546
|
+
const targetRowIndex = Math.min(minDeletedRowIndex, newRowCount - 1)
|
|
547
|
+
focusCell(targetRowIndex, currentFocusedColumn)
|
|
548
|
+
}
|
|
549
|
+
})
|
|
550
|
+
},
|
|
551
|
+
[onRowsDeleteProp, data.length, store, getNavigableColumnIds, focusCell],
|
|
552
|
+
)
|
|
553
|
+
|
|
554
|
+
const navigateCell = React.useCallback(
|
|
555
|
+
(direction: NavigationDirection) => {
|
|
556
|
+
const currentState = store.getState()
|
|
557
|
+
if (!currentState.focusedCell) {
|
|
558
|
+
return
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
const { rowIndex, columnId } = currentState.focusedCell
|
|
562
|
+
const _navCols = getNavigableColumnIds()
|
|
563
|
+
const currentColIndex = _navCols.indexOf(columnId)
|
|
564
|
+
const rowVirtualizer = rowVirtualizerRef.current
|
|
565
|
+
const currentTable = tableRef.current
|
|
566
|
+
const rows = currentTable?.getRowModel().rows ?? []
|
|
567
|
+
const rowCount = rows.length ?? data.length
|
|
568
|
+
|
|
569
|
+
let newRowIndex = rowIndex
|
|
570
|
+
let newColumnId = columnId
|
|
571
|
+
|
|
572
|
+
switch (direction) {
|
|
573
|
+
case 'up':
|
|
574
|
+
newRowIndex = Math.max(0, rowIndex - 1)
|
|
575
|
+
break
|
|
576
|
+
case 'down':
|
|
577
|
+
newRowIndex = Math.min(rowCount - 1, rowIndex + 1)
|
|
578
|
+
break
|
|
579
|
+
case 'left':
|
|
580
|
+
if (currentColIndex > 0) {
|
|
581
|
+
const prevColumnId = _navCols[currentColIndex - 1]
|
|
582
|
+
if (prevColumnId) {
|
|
583
|
+
newColumnId = prevColumnId
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
break
|
|
587
|
+
case 'right':
|
|
588
|
+
if (currentColIndex < _navCols.length - 1) {
|
|
589
|
+
const nextColumnId = _navCols[currentColIndex + 1]
|
|
590
|
+
if (nextColumnId) {
|
|
591
|
+
newColumnId = nextColumnId
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
break
|
|
595
|
+
case 'home': {
|
|
596
|
+
const _navCols2 = getNavigableColumnIds()
|
|
597
|
+
if (_navCols2.length > 0) {
|
|
598
|
+
newColumnId = _navCols2[0] ?? columnId
|
|
599
|
+
}
|
|
600
|
+
break
|
|
601
|
+
}
|
|
602
|
+
case 'end': {
|
|
603
|
+
const _navCols3 = getNavigableColumnIds()
|
|
604
|
+
if (_navCols3.length > 0) {
|
|
605
|
+
newColumnId = _navCols3[_navCols3.length - 1] ?? columnId
|
|
606
|
+
}
|
|
607
|
+
break
|
|
608
|
+
}
|
|
609
|
+
case 'ctrl+home': {
|
|
610
|
+
newRowIndex = 0
|
|
611
|
+
const _navCols4 = getNavigableColumnIds()
|
|
612
|
+
if (_navCols4.length > 0) {
|
|
613
|
+
newColumnId = _navCols4[0] ?? columnId
|
|
614
|
+
}
|
|
615
|
+
break
|
|
616
|
+
}
|
|
617
|
+
case 'ctrl+end': {
|
|
618
|
+
newRowIndex = Math.max(0, rowCount - 1)
|
|
619
|
+
const _navCols5 = getNavigableColumnIds()
|
|
620
|
+
if (_navCols5.length > 0) {
|
|
621
|
+
newColumnId = _navCols5[_navCols5.length - 1] ?? columnId
|
|
622
|
+
}
|
|
623
|
+
break
|
|
624
|
+
}
|
|
625
|
+
case 'pageup':
|
|
626
|
+
if (rowVirtualizer) {
|
|
627
|
+
const visibleRange = rowVirtualizer.getVirtualItems()
|
|
628
|
+
const pageSize = visibleRange.length ?? 10
|
|
629
|
+
newRowIndex = Math.max(0, rowIndex - pageSize)
|
|
630
|
+
} else {
|
|
631
|
+
newRowIndex = Math.max(0, rowIndex - 10)
|
|
632
|
+
}
|
|
633
|
+
break
|
|
634
|
+
case 'pagedown':
|
|
635
|
+
if (rowVirtualizer) {
|
|
636
|
+
const visibleRange = rowVirtualizer.getVirtualItems()
|
|
637
|
+
const pageSize = visibleRange.length ?? 10
|
|
638
|
+
newRowIndex = Math.min(rowCount - 1, rowIndex + pageSize)
|
|
639
|
+
} else {
|
|
640
|
+
newRowIndex = Math.min(rowCount - 1, rowIndex + 10)
|
|
641
|
+
}
|
|
642
|
+
break
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
if (newRowIndex !== rowIndex || newColumnId !== columnId) {
|
|
646
|
+
const rowDiff = newRowIndex - rowIndex
|
|
647
|
+
|
|
648
|
+
// For single-row vertical navigation (up/down arrows)
|
|
649
|
+
if (Math.abs(rowDiff) === 1 && (direction === 'up' || direction === 'down')) {
|
|
650
|
+
const container = dataGridRef.current
|
|
651
|
+
const currentRow = rowMapRef.current.get(rowIndex)
|
|
652
|
+
const targetRow = rowMapRef.current.get(newRowIndex)
|
|
653
|
+
|
|
654
|
+
if (!container || !currentRow) {
|
|
655
|
+
// Fallback to simple focus if we can't find elements
|
|
656
|
+
focusCell(newRowIndex, newColumnId)
|
|
657
|
+
return
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
// Check viewport boundaries
|
|
661
|
+
const containerRect = container.getBoundingClientRect()
|
|
662
|
+
const headerHeight = headerRef.current?.getBoundingClientRect().height ?? 0
|
|
663
|
+
const footerHeight = footerRef.current?.getBoundingClientRect().height ?? 0
|
|
664
|
+
|
|
665
|
+
const viewportTop = containerRect.top + headerHeight + VIEWPORT_OFFSET
|
|
666
|
+
const viewportBottom = containerRect.bottom - footerHeight - VIEWPORT_OFFSET
|
|
667
|
+
|
|
668
|
+
// If target row already exists, check if it's visible
|
|
669
|
+
if (targetRow) {
|
|
670
|
+
const rowRect = targetRow.getBoundingClientRect()
|
|
671
|
+
const isFullyVisible = rowRect.top >= viewportTop && rowRect.bottom <= viewportBottom
|
|
672
|
+
|
|
673
|
+
if (isFullyVisible) {
|
|
674
|
+
// Row is fully visible, just focus it
|
|
675
|
+
focusCell(newRowIndex, newColumnId)
|
|
676
|
+
return
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
// Row exists but not fully visible, scroll it into view
|
|
680
|
+
focusCell(newRowIndex, newColumnId)
|
|
681
|
+
|
|
682
|
+
if (direction === 'down') {
|
|
683
|
+
// Scroll just enough to show the row at the bottom
|
|
684
|
+
const scrollNeeded = rowRect.bottom - viewportBottom
|
|
685
|
+
container.scrollTop += scrollNeeded
|
|
686
|
+
} else {
|
|
687
|
+
// Scroll just enough to show the row at the top
|
|
688
|
+
const scrollNeeded = viewportTop - rowRect.top
|
|
689
|
+
container.scrollTop -= scrollNeeded
|
|
690
|
+
}
|
|
691
|
+
return
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
// Target row is not rendered yet
|
|
695
|
+
// Focus immediately so the ring appears as the row is revealed
|
|
696
|
+
focusCell(newRowIndex, newColumnId)
|
|
697
|
+
|
|
698
|
+
// Scroll by exactly one row height to reveal it smoothly
|
|
699
|
+
if (direction === 'down') {
|
|
700
|
+
container.scrollTop += rowHeightValue
|
|
701
|
+
} else {
|
|
702
|
+
// For arrow up, ensure we don't go below 0
|
|
703
|
+
const currentScrollTop = container.scrollTop
|
|
704
|
+
const targetScrollTop = Math.max(0, currentScrollTop - rowHeightValue)
|
|
705
|
+
container.scrollTop = targetScrollTop
|
|
706
|
+
}
|
|
707
|
+
return
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
// For larger jumps (page up/down, ctrl+home/end, etc.)
|
|
711
|
+
if (rowVirtualizer && Math.abs(rowDiff) > 1) {
|
|
712
|
+
const align =
|
|
713
|
+
direction === 'pageup' || direction === 'ctrl+home'
|
|
714
|
+
? 'start'
|
|
715
|
+
: direction === 'pagedown' || direction === 'ctrl+end'
|
|
716
|
+
? 'end'
|
|
717
|
+
: 'center'
|
|
718
|
+
rowVirtualizer.scrollToIndex(newRowIndex, { align })
|
|
719
|
+
requestAnimationFrame(() => {
|
|
720
|
+
focusCell(newRowIndex, newColumnId)
|
|
721
|
+
})
|
|
722
|
+
return
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
// For horizontal navigation or when row is already visible
|
|
726
|
+
focusCell(newRowIndex, newColumnId)
|
|
727
|
+
}
|
|
728
|
+
},
|
|
729
|
+
[store, getNavigableColumnIds, focusCell, data.length, rowHeightValue],
|
|
730
|
+
)
|
|
731
|
+
|
|
732
|
+
const onCellEditingStart = React.useCallback(
|
|
733
|
+
(rowIndex: number, columnId: string) => {
|
|
734
|
+
store.batch(() => {
|
|
735
|
+
store.setState('focusedCell', { rowIndex, columnId })
|
|
736
|
+
store.setState('editingCell', { rowIndex, columnId })
|
|
737
|
+
})
|
|
738
|
+
},
|
|
739
|
+
[store],
|
|
740
|
+
)
|
|
741
|
+
|
|
742
|
+
const onCellEditingStop = React.useCallback(
|
|
743
|
+
(opts?: { moveToNextRow?: boolean; direction?: NavigationDirection }) => {
|
|
744
|
+
const currentState = store.getState()
|
|
745
|
+
const currentEditing = currentState.editingCell
|
|
746
|
+
|
|
747
|
+
store.setState('editingCell', null)
|
|
748
|
+
|
|
749
|
+
if (opts?.moveToNextRow && currentEditing) {
|
|
750
|
+
const { rowIndex, columnId } = currentEditing
|
|
751
|
+
const currentTable = tableRef.current
|
|
752
|
+
const rows = currentTable?.getRowModel().rows ?? []
|
|
753
|
+
const rowCount = rows.length ?? data.length
|
|
754
|
+
|
|
755
|
+
const nextRowIndex = rowIndex + 1
|
|
756
|
+
if (nextRowIndex < rowCount) {
|
|
757
|
+
requestAnimationFrame(() => {
|
|
758
|
+
focusCell(nextRowIndex, columnId)
|
|
759
|
+
})
|
|
760
|
+
}
|
|
761
|
+
} else if (opts?.direction && currentEditing) {
|
|
762
|
+
// Focus the current editing cell first, then navigate
|
|
763
|
+
const { rowIndex, columnId } = currentEditing
|
|
764
|
+
focusCell(rowIndex, columnId)
|
|
765
|
+
requestAnimationFrame(() => {
|
|
766
|
+
navigateCell(opts.direction ?? 'right')
|
|
767
|
+
})
|
|
768
|
+
}
|
|
769
|
+
},
|
|
770
|
+
[store, data.length, focusCell, navigateCell],
|
|
771
|
+
)
|
|
772
|
+
|
|
773
|
+
const onSearchOpenChange = React.useCallback(
|
|
774
|
+
(open: boolean) => {
|
|
775
|
+
if (open) {
|
|
776
|
+
store.setState('searchOpen', true)
|
|
777
|
+
return
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
const currentState = store.getState()
|
|
781
|
+
const currentMatch = currentState.matchIndex >= 0 && currentState.searchMatches[currentState.matchIndex]
|
|
782
|
+
|
|
783
|
+
store.batch(() => {
|
|
784
|
+
store.setState('searchOpen', false)
|
|
785
|
+
store.setState('searchQuery', '')
|
|
786
|
+
store.setState('searchMatches', [])
|
|
787
|
+
store.setState('matchIndex', -1)
|
|
788
|
+
|
|
789
|
+
if (currentMatch) {
|
|
790
|
+
store.setState('focusedCell', {
|
|
791
|
+
rowIndex: currentMatch.rowIndex,
|
|
792
|
+
columnId: currentMatch.columnId,
|
|
793
|
+
})
|
|
794
|
+
}
|
|
795
|
+
})
|
|
796
|
+
|
|
797
|
+
if (dataGridRef.current && document.activeElement !== dataGridRef.current) {
|
|
798
|
+
dataGridRef.current.focus()
|
|
799
|
+
}
|
|
800
|
+
},
|
|
801
|
+
[store],
|
|
802
|
+
)
|
|
803
|
+
|
|
804
|
+
const onSearch = React.useCallback(
|
|
805
|
+
(query: string) => {
|
|
806
|
+
if (!query.trim()) {
|
|
807
|
+
store.batch(() => {
|
|
808
|
+
store.setState('searchMatches', [])
|
|
809
|
+
store.setState('matchIndex', -1)
|
|
810
|
+
})
|
|
811
|
+
return
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
const matches: CellPosition[] = []
|
|
815
|
+
const currentTable = tableRef.current
|
|
816
|
+
const rows = currentTable?.getRowModel().rows ?? []
|
|
817
|
+
|
|
818
|
+
const lowerQuery = query.toLowerCase()
|
|
819
|
+
|
|
820
|
+
for (let rowIndex = 0; rowIndex < rows.length; rowIndex++) {
|
|
821
|
+
const row = rows[rowIndex]
|
|
822
|
+
if (!row) {
|
|
823
|
+
continue
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
for (const columnId of columnIds) {
|
|
827
|
+
const cell = row.getVisibleCells().find((c) => c.column.id === columnId)
|
|
828
|
+
if (!cell) {
|
|
829
|
+
continue
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
const value = cell.getValue()
|
|
833
|
+
const stringValue = String(value ?? '').toLowerCase()
|
|
834
|
+
|
|
835
|
+
if (stringValue.includes(lowerQuery)) {
|
|
836
|
+
matches.push({ rowIndex, columnId })
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
store.batch(() => {
|
|
842
|
+
store.setState('searchMatches', matches)
|
|
843
|
+
store.setState('matchIndex', matches.length > 0 ? 0 : -1)
|
|
844
|
+
})
|
|
845
|
+
|
|
846
|
+
// Scroll to first match but don't focus it (to keep focus in search input)
|
|
847
|
+
if (matches.length > 0 && matches[0]) {
|
|
848
|
+
const firstMatch = matches[0]
|
|
849
|
+
rowVirtualizerRef.current?.scrollToIndex(firstMatch.rowIndex, {
|
|
850
|
+
align: 'center',
|
|
851
|
+
})
|
|
852
|
+
}
|
|
853
|
+
},
|
|
854
|
+
[columnIds, store],
|
|
855
|
+
)
|
|
856
|
+
|
|
857
|
+
const onSearchQueryChange = React.useCallback((query: string) => store.setState('searchQuery', query), [store])
|
|
858
|
+
|
|
859
|
+
const onNavigateToPrevMatch = React.useCallback(() => {
|
|
860
|
+
const currentState = store.getState()
|
|
861
|
+
if (currentState.searchMatches.length === 0) {
|
|
862
|
+
return
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
const prevIndex =
|
|
866
|
+
currentState.matchIndex - 1 < 0 ? currentState.searchMatches.length - 1 : currentState.matchIndex - 1
|
|
867
|
+
const match = currentState.searchMatches[prevIndex]
|
|
868
|
+
|
|
869
|
+
if (match) {
|
|
870
|
+
rowVirtualizerRef.current?.scrollToIndex(match.rowIndex, {
|
|
871
|
+
align: 'center',
|
|
872
|
+
})
|
|
873
|
+
|
|
874
|
+
requestAnimationFrame(() => {
|
|
875
|
+
store.setState('matchIndex', prevIndex)
|
|
876
|
+
requestAnimationFrame(() => {
|
|
877
|
+
focusCell(match.rowIndex, match.columnId)
|
|
878
|
+
})
|
|
879
|
+
})
|
|
880
|
+
}
|
|
881
|
+
}, [store, focusCell])
|
|
882
|
+
|
|
883
|
+
const onNavigateToNextMatch = React.useCallback(() => {
|
|
884
|
+
const currentState = store.getState()
|
|
885
|
+
if (currentState.searchMatches.length === 0) {
|
|
886
|
+
return
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
const nextIndex = (currentState.matchIndex + 1) % currentState.searchMatches.length
|
|
890
|
+
const match = currentState.searchMatches[nextIndex]
|
|
891
|
+
|
|
892
|
+
if (match) {
|
|
893
|
+
rowVirtualizerRef.current?.scrollToIndex(match.rowIndex, {
|
|
894
|
+
align: 'center',
|
|
895
|
+
})
|
|
896
|
+
|
|
897
|
+
requestAnimationFrame(() => {
|
|
898
|
+
store.setState('matchIndex', nextIndex)
|
|
899
|
+
requestAnimationFrame(() => {
|
|
900
|
+
focusCell(match.rowIndex, match.columnId)
|
|
901
|
+
})
|
|
902
|
+
})
|
|
903
|
+
}
|
|
904
|
+
}, [store, focusCell])
|
|
905
|
+
|
|
906
|
+
const getIsSearchMatch = React.useCallback(
|
|
907
|
+
(rowIndex: number, columnId: string) => {
|
|
908
|
+
return searchMatches.some((match) => match.rowIndex === rowIndex && match.columnId === columnId)
|
|
909
|
+
},
|
|
910
|
+
[searchMatches],
|
|
911
|
+
)
|
|
912
|
+
|
|
913
|
+
const getIsActiveSearchMatch = React.useCallback(
|
|
914
|
+
(rowIndex: number, columnId: string) => {
|
|
915
|
+
if (matchIndex < 0) {
|
|
916
|
+
return false
|
|
917
|
+
}
|
|
918
|
+
const currentMatch = searchMatches[matchIndex]
|
|
919
|
+
return currentMatch?.rowIndex === rowIndex && currentMatch?.columnId === columnId
|
|
920
|
+
},
|
|
921
|
+
[searchMatches, matchIndex],
|
|
922
|
+
)
|
|
923
|
+
|
|
924
|
+
const blurCell = React.useCallback(() => {
|
|
925
|
+
const currentState = store.getState()
|
|
926
|
+
if (currentState.editingCell && document.activeElement instanceof HTMLElement) {
|
|
927
|
+
document.activeElement.blur()
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
store.batch(() => {
|
|
931
|
+
store.setState('focusedCell', null)
|
|
932
|
+
store.setState('editingCell', null)
|
|
933
|
+
})
|
|
934
|
+
}, [store])
|
|
935
|
+
|
|
936
|
+
const onCellClick = React.useCallback(
|
|
937
|
+
(rowIndex: number, columnId: string, event?: React.MouseEvent) => {
|
|
938
|
+
// Ignore right-click (button 2) - let onCellContextMenu handle it
|
|
939
|
+
if (event?.button === 2) {
|
|
940
|
+
return
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
const currentState = store.getState()
|
|
944
|
+
const currentFocused = currentState.focusedCell
|
|
945
|
+
|
|
946
|
+
if (event) {
|
|
947
|
+
if (event.ctrlKey || event.metaKey) {
|
|
948
|
+
event.preventDefault()
|
|
949
|
+
const cellKey = getCellKey(rowIndex, columnId)
|
|
950
|
+
const newSelectedCells = new Set(currentState.selectionState.selectedCells)
|
|
951
|
+
|
|
952
|
+
if (newSelectedCells.has(cellKey)) {
|
|
953
|
+
newSelectedCells.delete(cellKey)
|
|
954
|
+
} else {
|
|
955
|
+
newSelectedCells.add(cellKey)
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
store.setState('selectionState', {
|
|
959
|
+
selectedCells: newSelectedCells,
|
|
960
|
+
selectionRange: null,
|
|
961
|
+
isSelecting: false,
|
|
962
|
+
})
|
|
963
|
+
focusCell(rowIndex, columnId)
|
|
964
|
+
return
|
|
965
|
+
}
|
|
966
|
+
|
|
967
|
+
if (event.shiftKey && currentState.focusedCell) {
|
|
968
|
+
event.preventDefault()
|
|
969
|
+
selectRange(currentState.focusedCell, { rowIndex, columnId })
|
|
970
|
+
return
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
// Clear selection if there are selected cells or rows
|
|
975
|
+
const hasSelectedCells = currentState.selectionState.selectedCells.size > 0
|
|
976
|
+
const hasSelectedRows = Object.keys(currentState.rowSelection).length > 0
|
|
977
|
+
|
|
978
|
+
if (hasSelectedCells && !currentState.selectionState.isSelecting) {
|
|
979
|
+
// If there's a cell selection but we're not actively selecting (drag just finished),
|
|
980
|
+
// don't clear it - keep the selection
|
|
981
|
+
// Only clear if clicking elsewhere
|
|
982
|
+
const cellKey = getCellKey(rowIndex, columnId)
|
|
983
|
+
const isClickingSelectedCell = currentState.selectionState.selectedCells.has(cellKey)
|
|
984
|
+
|
|
985
|
+
if (!isClickingSelectedCell) {
|
|
986
|
+
clearSelection()
|
|
987
|
+
} else {
|
|
988
|
+
// Clicking on an already selected cell - just focus it
|
|
989
|
+
focusCell(rowIndex, columnId)
|
|
990
|
+
return
|
|
991
|
+
}
|
|
992
|
+
} else if (hasSelectedRows && columnId !== 'select') {
|
|
993
|
+
// If there are selected rows but we're clicking on a non-checkbox cell, clear selections
|
|
994
|
+
clearSelection()
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
if (currentFocused?.rowIndex === rowIndex && currentFocused?.columnId === columnId) {
|
|
998
|
+
onCellEditingStart(rowIndex, columnId)
|
|
999
|
+
} else {
|
|
1000
|
+
focusCell(rowIndex, columnId)
|
|
1001
|
+
}
|
|
1002
|
+
},
|
|
1003
|
+
[store, focusCell, onCellEditingStart, selectRange, clearSelection],
|
|
1004
|
+
)
|
|
1005
|
+
|
|
1006
|
+
const onCellDoubleClick = React.useCallback(
|
|
1007
|
+
(rowIndex: number, columnId: string, event?: React.MouseEvent) => {
|
|
1008
|
+
if (event?.defaultPrevented) {
|
|
1009
|
+
return
|
|
1010
|
+
}
|
|
1011
|
+
|
|
1012
|
+
onCellEditingStart(rowIndex, columnId)
|
|
1013
|
+
},
|
|
1014
|
+
[onCellEditingStart],
|
|
1015
|
+
)
|
|
1016
|
+
|
|
1017
|
+
const onCellMouseDown = React.useCallback(
|
|
1018
|
+
(rowIndex: number, columnId: string, event: React.MouseEvent) => {
|
|
1019
|
+
// Ignore right-click (button 2) - let onCellContextMenu handle it
|
|
1020
|
+
if (event.button === 2) {
|
|
1021
|
+
return
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
event.preventDefault()
|
|
1025
|
+
|
|
1026
|
+
// Only start drag selection if no modifier keys are pressed
|
|
1027
|
+
// Clear any existing selection and prepare for potential drag
|
|
1028
|
+
if (!event.ctrlKey && !event.metaKey && !event.shiftKey) {
|
|
1029
|
+
store.batch(() => {
|
|
1030
|
+
store.setState('selectionState', {
|
|
1031
|
+
selectedCells: new Set(),
|
|
1032
|
+
selectionRange: {
|
|
1033
|
+
start: { rowIndex, columnId },
|
|
1034
|
+
end: { rowIndex, columnId },
|
|
1035
|
+
},
|
|
1036
|
+
isSelecting: true,
|
|
1037
|
+
})
|
|
1038
|
+
store.setState('rowSelection', {})
|
|
1039
|
+
})
|
|
1040
|
+
}
|
|
1041
|
+
},
|
|
1042
|
+
[store],
|
|
1043
|
+
)
|
|
1044
|
+
|
|
1045
|
+
const onCellMouseEnter = React.useCallback(
|
|
1046
|
+
(rowIndex: number, columnId: string, _event: React.MouseEvent) => {
|
|
1047
|
+
const currentState = store.getState()
|
|
1048
|
+
if (currentState.selectionState.isSelecting && currentState.selectionState.selectionRange) {
|
|
1049
|
+
const start = currentState.selectionState.selectionRange.start
|
|
1050
|
+
const end = { rowIndex, columnId }
|
|
1051
|
+
|
|
1052
|
+
if (
|
|
1053
|
+
currentState.focusedCell?.rowIndex !== start.rowIndex ||
|
|
1054
|
+
currentState.focusedCell?.columnId !== start.columnId
|
|
1055
|
+
) {
|
|
1056
|
+
focusCell(start.rowIndex, start.columnId)
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
selectRange(start, end, true)
|
|
1060
|
+
}
|
|
1061
|
+
},
|
|
1062
|
+
[store, selectRange, focusCell],
|
|
1063
|
+
)
|
|
1064
|
+
|
|
1065
|
+
const onCellMouseUp = React.useCallback(() => {
|
|
1066
|
+
const currentState = store.getState()
|
|
1067
|
+
store.setState('selectionState', {
|
|
1068
|
+
...currentState.selectionState,
|
|
1069
|
+
isSelecting: false,
|
|
1070
|
+
})
|
|
1071
|
+
}, [store])
|
|
1072
|
+
|
|
1073
|
+
const onCellContextMenu = React.useCallback(
|
|
1074
|
+
(rowIndex: number, columnId: string, event: React.MouseEvent) => {
|
|
1075
|
+
event.preventDefault()
|
|
1076
|
+
event.stopPropagation()
|
|
1077
|
+
|
|
1078
|
+
const currentState = store.getState()
|
|
1079
|
+
const cellKey = getCellKey(rowIndex, columnId)
|
|
1080
|
+
const isTargetCellSelected = currentState.selectionState.selectedCells.has(cellKey)
|
|
1081
|
+
|
|
1082
|
+
// If right-clicking on a non-selected cell, select only that cell
|
|
1083
|
+
if (!isTargetCellSelected) {
|
|
1084
|
+
store.batch(() => {
|
|
1085
|
+
store.setState('selectionState', {
|
|
1086
|
+
selectedCells: new Set([cellKey]),
|
|
1087
|
+
selectionRange: {
|
|
1088
|
+
start: { rowIndex, columnId },
|
|
1089
|
+
end: { rowIndex, columnId },
|
|
1090
|
+
},
|
|
1091
|
+
isSelecting: false,
|
|
1092
|
+
})
|
|
1093
|
+
store.setState('focusedCell', { rowIndex, columnId })
|
|
1094
|
+
})
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
// Open context menu at cursor position
|
|
1098
|
+
store.setState('contextMenu', {
|
|
1099
|
+
open: true,
|
|
1100
|
+
x: event.clientX,
|
|
1101
|
+
y: event.clientY,
|
|
1102
|
+
})
|
|
1103
|
+
},
|
|
1104
|
+
[store],
|
|
1105
|
+
)
|
|
1106
|
+
|
|
1107
|
+
const onContextMenuOpenChange = React.useCallback(
|
|
1108
|
+
(open: boolean) => {
|
|
1109
|
+
if (!open) {
|
|
1110
|
+
const currentMenu = store.getState().contextMenu
|
|
1111
|
+
store.setState('contextMenu', {
|
|
1112
|
+
open: false,
|
|
1113
|
+
x: currentMenu.x,
|
|
1114
|
+
y: currentMenu.y,
|
|
1115
|
+
})
|
|
1116
|
+
}
|
|
1117
|
+
},
|
|
1118
|
+
[store],
|
|
1119
|
+
)
|
|
1120
|
+
|
|
1121
|
+
const onDataGridKeyDown = React.useCallback(
|
|
1122
|
+
(event: KeyboardEvent) => {
|
|
1123
|
+
const currentState = store.getState()
|
|
1124
|
+
const { key, ctrlKey, metaKey, shiftKey } = event
|
|
1125
|
+
const isCtrlPressed = ctrlKey || metaKey
|
|
1126
|
+
|
|
1127
|
+
// Handle Cmd+F / Ctrl+F to open search (highest priority, works even when editing)
|
|
1128
|
+
if (enableSearch && isCtrlPressed && key === SEARCH_SHORTCUT_KEY) {
|
|
1129
|
+
event.preventDefault()
|
|
1130
|
+
onSearchOpenChange(true)
|
|
1131
|
+
return
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
// Handle search navigation when search is open
|
|
1135
|
+
if (enableSearch && currentState.searchOpen && !currentState.editingCell) {
|
|
1136
|
+
if (key === 'Enter') {
|
|
1137
|
+
event.preventDefault()
|
|
1138
|
+
if (shiftKey) {
|
|
1139
|
+
onNavigateToPrevMatch()
|
|
1140
|
+
} else {
|
|
1141
|
+
onNavigateToNextMatch()
|
|
1142
|
+
}
|
|
1143
|
+
return
|
|
1144
|
+
}
|
|
1145
|
+
if (key === 'Escape') {
|
|
1146
|
+
event.preventDefault()
|
|
1147
|
+
onSearchOpenChange(false)
|
|
1148
|
+
return
|
|
1149
|
+
}
|
|
1150
|
+
// When search is open, don't let data grid handle any other keys
|
|
1151
|
+
// (they should only affect the search input)
|
|
1152
|
+
return
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
if (currentState.editingCell) {
|
|
1156
|
+
return
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
if (!currentState.focusedCell) {
|
|
1160
|
+
return
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
let direction: NavigationDirection | null = null
|
|
1164
|
+
|
|
1165
|
+
if (isCtrlPressed && key === 'a') {
|
|
1166
|
+
event.preventDefault()
|
|
1167
|
+
selectAll()
|
|
1168
|
+
return
|
|
1169
|
+
}
|
|
1170
|
+
|
|
1171
|
+
if (key === 'Delete' || key === 'Backspace') {
|
|
1172
|
+
if (currentState.selectionState.selectedCells.size > 0) {
|
|
1173
|
+
event.preventDefault()
|
|
1174
|
+
// If any selected cell is not editable, do nothing (mirror context-menu Clear behavior)
|
|
1175
|
+
const currentTable = tableRef.current
|
|
1176
|
+
const visibleCols = currentTable?.getVisibleLeafColumns() ?? []
|
|
1177
|
+
let canClear = true
|
|
1178
|
+
for (const cellKey of currentState.selectionState.selectedCells) {
|
|
1179
|
+
if (!canClear) {
|
|
1180
|
+
break
|
|
1181
|
+
}
|
|
1182
|
+
const { columnId } = parseCellKey(cellKey)
|
|
1183
|
+
const col = visibleCols.find((c) => c.id === columnId)
|
|
1184
|
+
const editable = (col?.columnDef as any)?.meta?.cell?.editable
|
|
1185
|
+
if (editable === false) {
|
|
1186
|
+
canClear = false
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
if (!canClear) {
|
|
1191
|
+
return
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1194
|
+
const updates: {
|
|
1195
|
+
rowIndex: number
|
|
1196
|
+
columnId: string
|
|
1197
|
+
value: unknown
|
|
1198
|
+
}[] = []
|
|
1199
|
+
|
|
1200
|
+
currentState.selectionState.selectedCells.forEach((cellKey) => {
|
|
1201
|
+
const { rowIndex, columnId } = parseCellKey(cellKey)
|
|
1202
|
+
updates.push({ rowIndex, columnId, value: '' })
|
|
1203
|
+
})
|
|
1204
|
+
|
|
1205
|
+
onDataUpdate(updates)
|
|
1206
|
+
clearSelection()
|
|
1207
|
+
}
|
|
1208
|
+
return
|
|
1209
|
+
}
|
|
1210
|
+
|
|
1211
|
+
switch (key) {
|
|
1212
|
+
case 'ArrowUp':
|
|
1213
|
+
direction = 'up'
|
|
1214
|
+
break
|
|
1215
|
+
case 'ArrowDown':
|
|
1216
|
+
direction = 'down'
|
|
1217
|
+
break
|
|
1218
|
+
case 'ArrowLeft':
|
|
1219
|
+
direction = 'left'
|
|
1220
|
+
break
|
|
1221
|
+
case 'ArrowRight':
|
|
1222
|
+
direction = 'right'
|
|
1223
|
+
break
|
|
1224
|
+
case 'Home':
|
|
1225
|
+
direction = isCtrlPressed ? 'ctrl+home' : 'home'
|
|
1226
|
+
break
|
|
1227
|
+
case 'End':
|
|
1228
|
+
direction = isCtrlPressed ? 'ctrl+end' : 'end'
|
|
1229
|
+
break
|
|
1230
|
+
case 'PageUp':
|
|
1231
|
+
direction = 'pageup'
|
|
1232
|
+
break
|
|
1233
|
+
case 'PageDown':
|
|
1234
|
+
direction = 'pagedown'
|
|
1235
|
+
break
|
|
1236
|
+
case 'Escape':
|
|
1237
|
+
event.preventDefault()
|
|
1238
|
+
if (currentState.selectionState.selectedCells.size > 0 || Object.keys(currentState.rowSelection).length > 0) {
|
|
1239
|
+
clearSelection()
|
|
1240
|
+
} else {
|
|
1241
|
+
blurCell()
|
|
1242
|
+
}
|
|
1243
|
+
return
|
|
1244
|
+
case 'Tab':
|
|
1245
|
+
event.preventDefault()
|
|
1246
|
+
direction = event.shiftKey ? 'left' : 'right'
|
|
1247
|
+
break
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
if (direction) {
|
|
1251
|
+
event.preventDefault()
|
|
1252
|
+
|
|
1253
|
+
// Tab navigation should not trigger selection, even with Shift
|
|
1254
|
+
if (shiftKey && key !== 'Tab' && currentState.focusedCell) {
|
|
1255
|
+
const _navCols = getNavigableColumnIds()
|
|
1256
|
+
const currentColIndex = _navCols.indexOf(currentState.focusedCell.columnId)
|
|
1257
|
+
let newRowIndex = currentState.focusedCell.rowIndex
|
|
1258
|
+
let newColumnId = currentState.focusedCell.columnId
|
|
1259
|
+
|
|
1260
|
+
switch (direction) {
|
|
1261
|
+
case 'up':
|
|
1262
|
+
newRowIndex = Math.max(0, currentState.focusedCell.rowIndex - 1)
|
|
1263
|
+
break
|
|
1264
|
+
case 'down':
|
|
1265
|
+
newRowIndex = Math.min(
|
|
1266
|
+
(tableRef.current?.getRowModel().rows.length || data.length) - 1,
|
|
1267
|
+
currentState.focusedCell.rowIndex + 1,
|
|
1268
|
+
)
|
|
1269
|
+
break
|
|
1270
|
+
case 'left':
|
|
1271
|
+
if (currentColIndex > 0) {
|
|
1272
|
+
const prevColumnId = _navCols[currentColIndex - 1]
|
|
1273
|
+
if (prevColumnId) {
|
|
1274
|
+
newColumnId = prevColumnId
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
break
|
|
1278
|
+
case 'right':
|
|
1279
|
+
if (currentColIndex < _navCols.length - 1) {
|
|
1280
|
+
const nextColumnId = _navCols[currentColIndex + 1]
|
|
1281
|
+
if (nextColumnId) {
|
|
1282
|
+
newColumnId = nextColumnId
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
break
|
|
1286
|
+
}
|
|
1287
|
+
|
|
1288
|
+
const selectionStart = currentState.selectionState.selectionRange?.start || currentState.focusedCell
|
|
1289
|
+
selectRange(selectionStart, {
|
|
1290
|
+
rowIndex: newRowIndex,
|
|
1291
|
+
columnId: newColumnId,
|
|
1292
|
+
})
|
|
1293
|
+
focusCell(newRowIndex, newColumnId)
|
|
1294
|
+
} else {
|
|
1295
|
+
if (currentState.selectionState.selectedCells.size > 0) {
|
|
1296
|
+
clearSelection()
|
|
1297
|
+
}
|
|
1298
|
+
navigateCell(direction)
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
},
|
|
1302
|
+
[
|
|
1303
|
+
store,
|
|
1304
|
+
blurCell,
|
|
1305
|
+
navigateCell,
|
|
1306
|
+
selectAll,
|
|
1307
|
+
onDataUpdate,
|
|
1308
|
+
clearSelection,
|
|
1309
|
+
getNavigableColumnIds,
|
|
1310
|
+
data.length,
|
|
1311
|
+
selectRange,
|
|
1312
|
+
focusCell,
|
|
1313
|
+
onSearchOpenChange,
|
|
1314
|
+
onNavigateToNextMatch,
|
|
1315
|
+
onNavigateToPrevMatch,
|
|
1316
|
+
enableSearch,
|
|
1317
|
+
],
|
|
1318
|
+
)
|
|
1319
|
+
|
|
1320
|
+
const onSortingChange = React.useCallback(
|
|
1321
|
+
(updater: Updater<SortingState>) => {
|
|
1322
|
+
const currentState = store.getState()
|
|
1323
|
+
const newSorting = typeof updater === 'function' ? updater(currentState.sorting) : updater
|
|
1324
|
+
store.setState('sorting', newSorting)
|
|
1325
|
+
},
|
|
1326
|
+
[store],
|
|
1327
|
+
)
|
|
1328
|
+
|
|
1329
|
+
const onRowSelectionChange = React.useCallback(
|
|
1330
|
+
(updater: Updater<RowSelectionState>) => {
|
|
1331
|
+
const currentState = store.getState()
|
|
1332
|
+
const newRowSelection = typeof updater === 'function' ? updater(currentState.rowSelection) : updater
|
|
1333
|
+
|
|
1334
|
+
const selectedRows = Object.keys(newRowSelection).filter((key) => newRowSelection[key])
|
|
1335
|
+
|
|
1336
|
+
const selectedCells = new Set<string>()
|
|
1337
|
+
const rows = tableRef.current?.getRowModel().rows ?? []
|
|
1338
|
+
|
|
1339
|
+
for (const rowId of selectedRows) {
|
|
1340
|
+
const rowIndex = rows.findIndex((r) => r.id === rowId)
|
|
1341
|
+
if (rowIndex === -1) {
|
|
1342
|
+
continue
|
|
1343
|
+
}
|
|
1344
|
+
|
|
1345
|
+
for (const columnId of columnIds) {
|
|
1346
|
+
selectedCells.add(getCellKey(rowIndex, columnId))
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
|
|
1350
|
+
store.batch(() => {
|
|
1351
|
+
store.setState('rowSelection', newRowSelection)
|
|
1352
|
+
store.setState('selectionState', {
|
|
1353
|
+
selectedCells,
|
|
1354
|
+
selectionRange: null,
|
|
1355
|
+
isSelecting: false,
|
|
1356
|
+
})
|
|
1357
|
+
store.setState('focusedCell', null)
|
|
1358
|
+
store.setState('editingCell', null)
|
|
1359
|
+
})
|
|
1360
|
+
},
|
|
1361
|
+
[store, columnIds],
|
|
1362
|
+
)
|
|
1363
|
+
|
|
1364
|
+
const onRowSelect = React.useCallback(
|
|
1365
|
+
(rowIndex: number, selected: boolean, shiftKey: boolean) => {
|
|
1366
|
+
const currentState = store.getState()
|
|
1367
|
+
const rows = tableRef.current?.getRowModel().rows ?? []
|
|
1368
|
+
const currentRow = rows[rowIndex]
|
|
1369
|
+
if (!currentRow) {
|
|
1370
|
+
return
|
|
1371
|
+
}
|
|
1372
|
+
|
|
1373
|
+
if (shiftKey && currentState.lastClickedRowIndex !== null) {
|
|
1374
|
+
const startIndex = Math.min(currentState.lastClickedRowIndex, rowIndex)
|
|
1375
|
+
const endIndex = Math.max(currentState.lastClickedRowIndex, rowIndex)
|
|
1376
|
+
|
|
1377
|
+
const newRowSelection: RowSelectionState = {
|
|
1378
|
+
...currentState.rowSelection,
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
for (let i = startIndex; i <= endIndex; i++) {
|
|
1382
|
+
const row = rows[i]
|
|
1383
|
+
if (row) {
|
|
1384
|
+
newRowSelection[row.id] = selected
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
onRowSelectionChange(newRowSelection)
|
|
1389
|
+
} else {
|
|
1390
|
+
onRowSelectionChange({
|
|
1391
|
+
...currentState.rowSelection,
|
|
1392
|
+
[currentRow.id]: selected,
|
|
1393
|
+
})
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
store.setState('lastClickedRowIndex', rowIndex)
|
|
1397
|
+
},
|
|
1398
|
+
[store, onRowSelectionChange],
|
|
1399
|
+
)
|
|
1400
|
+
|
|
1401
|
+
const onRowHeightChange = React.useCallback(
|
|
1402
|
+
(updater: Updater<RowHeightValue>) => {
|
|
1403
|
+
const currentState = store.getState()
|
|
1404
|
+
const newRowHeight = typeof updater === 'function' ? updater(currentState.rowHeight) : updater
|
|
1405
|
+
store.setState('rowHeight', newRowHeight)
|
|
1406
|
+
},
|
|
1407
|
+
[store],
|
|
1408
|
+
)
|
|
1409
|
+
|
|
1410
|
+
const onColumnClick = React.useCallback(
|
|
1411
|
+
(columnId: string) => {
|
|
1412
|
+
if (!enableColumnSelection) {
|
|
1413
|
+
clearSelection()
|
|
1414
|
+
return
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
selectColumn(columnId)
|
|
1418
|
+
},
|
|
1419
|
+
[enableColumnSelection, selectColumn, clearSelection],
|
|
1420
|
+
)
|
|
1421
|
+
|
|
1422
|
+
const defaultColumn: Partial<ColumnDef<TData>> = React.useMemo(
|
|
1423
|
+
() => ({
|
|
1424
|
+
cell: DataGridCell,
|
|
1425
|
+
minSize: MIN_COLUMN_SIZE,
|
|
1426
|
+
maxSize: MAX_COLUMN_SIZE,
|
|
1427
|
+
}),
|
|
1428
|
+
[],
|
|
1429
|
+
)
|
|
1430
|
+
|
|
1431
|
+
const tableOptions = React.useMemo<TableOptions<TData>>(
|
|
1432
|
+
() => ({
|
|
1433
|
+
...dataGridPropsRef.current,
|
|
1434
|
+
data,
|
|
1435
|
+
columns,
|
|
1436
|
+
defaultColumn,
|
|
1437
|
+
initialState: mergedInitialState,
|
|
1438
|
+
state: {
|
|
1439
|
+
...dataGridPropsRef.current.state,
|
|
1440
|
+
sorting,
|
|
1441
|
+
rowSelection,
|
|
1442
|
+
},
|
|
1443
|
+
onRowSelectionChange,
|
|
1444
|
+
onSortingChange,
|
|
1445
|
+
columnResizeMode: 'onChange',
|
|
1446
|
+
getCoreRowModel: getCoreRowModel(),
|
|
1447
|
+
getSortedRowModel: getSortedRowModel(),
|
|
1448
|
+
meta: {
|
|
1449
|
+
...dataGridPropsRef.current.meta,
|
|
1450
|
+
dataGridRef,
|
|
1451
|
+
focusedCell,
|
|
1452
|
+
editingCell,
|
|
1453
|
+
selectionState,
|
|
1454
|
+
searchOpen,
|
|
1455
|
+
rowHeight,
|
|
1456
|
+
isScrolling,
|
|
1457
|
+
getIsCellSelected,
|
|
1458
|
+
getIsSearchMatch,
|
|
1459
|
+
getIsActiveSearchMatch,
|
|
1460
|
+
onRowHeightChange,
|
|
1461
|
+
onRowSelect,
|
|
1462
|
+
onRowsDelete: onRowsDeleteProp ? onRowsDelete : undefined,
|
|
1463
|
+
onDataUpdate,
|
|
1464
|
+
onColumnClick,
|
|
1465
|
+
onCellClick,
|
|
1466
|
+
onCellDoubleClick,
|
|
1467
|
+
onCellMouseDown,
|
|
1468
|
+
onCellMouseEnter,
|
|
1469
|
+
onCellMouseUp,
|
|
1470
|
+
onCellContextMenu,
|
|
1471
|
+
onCellEditingStart,
|
|
1472
|
+
onCellEditingStop,
|
|
1473
|
+
contextMenu,
|
|
1474
|
+
onContextMenuOpenChange,
|
|
1475
|
+
},
|
|
1476
|
+
}),
|
|
1477
|
+
[
|
|
1478
|
+
dataGridPropsRef,
|
|
1479
|
+
data,
|
|
1480
|
+
columns,
|
|
1481
|
+
defaultColumn,
|
|
1482
|
+
mergedInitialState,
|
|
1483
|
+
sorting,
|
|
1484
|
+
rowSelection,
|
|
1485
|
+
onRowSelectionChange,
|
|
1486
|
+
onSortingChange,
|
|
1487
|
+
focusedCell,
|
|
1488
|
+
editingCell,
|
|
1489
|
+
selectionState,
|
|
1490
|
+
searchOpen,
|
|
1491
|
+
isScrolling,
|
|
1492
|
+
getIsCellSelected,
|
|
1493
|
+
getIsSearchMatch,
|
|
1494
|
+
getIsActiveSearchMatch,
|
|
1495
|
+
onDataUpdate,
|
|
1496
|
+
onRowsDeleteProp,
|
|
1497
|
+
onRowsDelete,
|
|
1498
|
+
onColumnClick,
|
|
1499
|
+
onCellClick,
|
|
1500
|
+
onCellDoubleClick,
|
|
1501
|
+
onCellMouseDown,
|
|
1502
|
+
onCellMouseEnter,
|
|
1503
|
+
onCellMouseUp,
|
|
1504
|
+
onCellContextMenu,
|
|
1505
|
+
onCellEditingStart,
|
|
1506
|
+
onCellEditingStop,
|
|
1507
|
+
contextMenu,
|
|
1508
|
+
onContextMenuOpenChange,
|
|
1509
|
+
rowHeight,
|
|
1510
|
+
onRowHeightChange,
|
|
1511
|
+
onRowSelect,
|
|
1512
|
+
],
|
|
1513
|
+
)
|
|
1514
|
+
|
|
1515
|
+
const table = useReactTable(tableOptions)
|
|
1516
|
+
|
|
1517
|
+
if (!tableRef.current) {
|
|
1518
|
+
tableRef.current = table
|
|
1519
|
+
}
|
|
1520
|
+
|
|
1521
|
+
// Extract columnSizing once so it can be used in hook dependency arrays
|
|
1522
|
+
const columnSizing = table.getState().columnSizing
|
|
1523
|
+
|
|
1524
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: we need to memoize the column size vars
|
|
1525
|
+
const columnSizeVars = React.useMemo(() => {
|
|
1526
|
+
// reference columnSizing so it is a used dependency (recomputes when column sizing changes)
|
|
1527
|
+
void columnSizing
|
|
1528
|
+
const headers = table.getFlatHeaders()
|
|
1529
|
+
const colSizes: Record<string, number> = {}
|
|
1530
|
+
for (const header of headers) {
|
|
1531
|
+
// Prefer the current header size, but fall back to the columnDef `size`
|
|
1532
|
+
// or the MIN_COLUMN_SIZE so the CSS variables exist on first render.
|
|
1533
|
+
const headerSize =
|
|
1534
|
+
(typeof header.getSize === 'function' ? header.getSize() : undefined) ??
|
|
1535
|
+
(header.column.columnDef as any)?.size ??
|
|
1536
|
+
MIN_COLUMN_SIZE
|
|
1537
|
+
const colSize =
|
|
1538
|
+
(typeof header.column.getSize === 'function' ? header.column.getSize() : undefined) ??
|
|
1539
|
+
(header.column.columnDef as any)?.size ??
|
|
1540
|
+
MIN_COLUMN_SIZE
|
|
1541
|
+
|
|
1542
|
+
colSizes[`--header-${header.id}-size`] = headerSize
|
|
1543
|
+
colSizes[`--col-${header.column.id}-size`] = colSize
|
|
1544
|
+
}
|
|
1545
|
+
return colSizes
|
|
1546
|
+
// Recompute whenever the table's column sizing state changes so CSS vars reflect new sizes
|
|
1547
|
+
}, [table, columnSizing])
|
|
1548
|
+
|
|
1549
|
+
const rowVirtualizer = useVirtualizer({
|
|
1550
|
+
count: table.getRowModel().rows.length,
|
|
1551
|
+
getScrollElement: () => dataGridRef.current,
|
|
1552
|
+
estimateSize: () => rowHeightValue,
|
|
1553
|
+
overscan,
|
|
1554
|
+
measureElement:
|
|
1555
|
+
typeof window !== 'undefined' && navigator.userAgent.indexOf('Firefox') === -1
|
|
1556
|
+
? (element) => element?.getBoundingClientRect().height
|
|
1557
|
+
: undefined,
|
|
1558
|
+
onChange: (instance) => {
|
|
1559
|
+
// Sync virtualizer's isScrolling state to our store
|
|
1560
|
+
const virtualizerIsScrolling = instance.isScrolling
|
|
1561
|
+
const currentIsScrolling = store.getState().isScrolling
|
|
1562
|
+
|
|
1563
|
+
if (virtualizerIsScrolling !== currentIsScrolling) {
|
|
1564
|
+
store.setState('isScrolling', virtualizerIsScrolling)
|
|
1565
|
+
}
|
|
1566
|
+
|
|
1567
|
+
// Batch DOM updates in a single animation frame
|
|
1568
|
+
const virtualItems = instance.getVirtualItems()
|
|
1569
|
+
if (virtualItems.length === 0) {
|
|
1570
|
+
return
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1573
|
+
requestAnimationFrame(() => {
|
|
1574
|
+
for (const virtualRow of virtualItems) {
|
|
1575
|
+
if (!virtualRow) {
|
|
1576
|
+
continue
|
|
1577
|
+
}
|
|
1578
|
+
const rowRef = rowMapRef.current.get(virtualRow.index)
|
|
1579
|
+
if (rowRef) {
|
|
1580
|
+
rowRef.style.transform = `translateY(${virtualRow.start}px)`
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
})
|
|
1584
|
+
},
|
|
1585
|
+
})
|
|
1586
|
+
|
|
1587
|
+
if (!rowVirtualizerRef.current) {
|
|
1588
|
+
rowVirtualizerRef.current = rowVirtualizer
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
const onScrollToRow = React.useCallback(
|
|
1592
|
+
(opts: Partial<CellPosition>) => {
|
|
1593
|
+
const rowIndex = opts?.rowIndex ?? 0
|
|
1594
|
+
const columnId = opts?.columnId
|
|
1595
|
+
|
|
1596
|
+
rowVirtualizer.scrollToIndex(rowIndex, {
|
|
1597
|
+
align: 'center',
|
|
1598
|
+
})
|
|
1599
|
+
|
|
1600
|
+
const targetColumnId = columnId ?? getNavigableColumnIds()[0]
|
|
1601
|
+
|
|
1602
|
+
if (!targetColumnId) {
|
|
1603
|
+
return
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
queueMicrotask(() => {
|
|
1607
|
+
requestAnimationFrame(() => {
|
|
1608
|
+
requestAnimationFrame(() => {
|
|
1609
|
+
store.batch(() => {
|
|
1610
|
+
store.setState('focusedCell', {
|
|
1611
|
+
rowIndex,
|
|
1612
|
+
columnId: targetColumnId,
|
|
1613
|
+
})
|
|
1614
|
+
store.setState('editingCell', null)
|
|
1615
|
+
})
|
|
1616
|
+
})
|
|
1617
|
+
})
|
|
1618
|
+
})
|
|
1619
|
+
},
|
|
1620
|
+
[rowVirtualizer, getNavigableColumnIds, store],
|
|
1621
|
+
)
|
|
1622
|
+
|
|
1623
|
+
const onRowAdd = React.useCallback(
|
|
1624
|
+
async (event?: React.MouseEvent<HTMLDivElement>) => {
|
|
1625
|
+
if (!onRowAddProp) {
|
|
1626
|
+
return
|
|
1627
|
+
}
|
|
1628
|
+
|
|
1629
|
+
const result = await onRowAddProp(event)
|
|
1630
|
+
|
|
1631
|
+
if (event?.defaultPrevented || result === null) {
|
|
1632
|
+
return
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1635
|
+
const currentTable = tableRef.current
|
|
1636
|
+
const rows = currentTable?.getRowModel().rows ?? []
|
|
1637
|
+
|
|
1638
|
+
if (result) {
|
|
1639
|
+
const adjustedRowIndex = (result.rowIndex ?? 0) >= rows.length ? rows.length : result.rowIndex
|
|
1640
|
+
|
|
1641
|
+
onScrollToRow({
|
|
1642
|
+
rowIndex: adjustedRowIndex,
|
|
1643
|
+
columnId: result.columnId,
|
|
1644
|
+
})
|
|
1645
|
+
return
|
|
1646
|
+
}
|
|
1647
|
+
|
|
1648
|
+
onScrollToRow({ rowIndex: rows.length })
|
|
1649
|
+
},
|
|
1650
|
+
[onRowAddProp, onScrollToRow],
|
|
1651
|
+
)
|
|
1652
|
+
|
|
1653
|
+
// Persist table column state (order, visibility, pinning) whenever it changes.
|
|
1654
|
+
// Use a layout effect so persistence stays in sync with table layout updates.
|
|
1655
|
+
useIsomorphicLayoutEffect(() => {
|
|
1656
|
+
if (!storageKey) {
|
|
1657
|
+
return
|
|
1658
|
+
}
|
|
1659
|
+
|
|
1660
|
+
try {
|
|
1661
|
+
const state = table.getState()
|
|
1662
|
+
const payload = {
|
|
1663
|
+
columnOrder: state.columnOrder,
|
|
1664
|
+
columnVisibility: state.columnVisibility,
|
|
1665
|
+
columnPinning: state.columnPinning,
|
|
1666
|
+
}
|
|
1667
|
+
localStorage.setItem(storageKey, JSON.stringify(payload))
|
|
1668
|
+
} catch (_) {
|
|
1669
|
+
// ignore storage errors
|
|
1670
|
+
}
|
|
1671
|
+
}, [storageKey, table.getState().columnOrder, table.getState().columnVisibility, table.getState().columnPinning])
|
|
1672
|
+
|
|
1673
|
+
const searchState = React.useMemo<SearchState | undefined>(() => {
|
|
1674
|
+
if (!enableSearch) {
|
|
1675
|
+
return undefined
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
return {
|
|
1679
|
+
searchMatches,
|
|
1680
|
+
matchIndex,
|
|
1681
|
+
searchOpen,
|
|
1682
|
+
onSearchOpenChange,
|
|
1683
|
+
searchQuery,
|
|
1684
|
+
onSearchQueryChange,
|
|
1685
|
+
onSearch,
|
|
1686
|
+
onNavigateToNextMatch,
|
|
1687
|
+
onNavigateToPrevMatch,
|
|
1688
|
+
}
|
|
1689
|
+
}, [
|
|
1690
|
+
enableSearch,
|
|
1691
|
+
searchMatches,
|
|
1692
|
+
matchIndex,
|
|
1693
|
+
searchOpen,
|
|
1694
|
+
onSearchOpenChange,
|
|
1695
|
+
searchQuery,
|
|
1696
|
+
onSearchQueryChange,
|
|
1697
|
+
onSearch,
|
|
1698
|
+
onNavigateToNextMatch,
|
|
1699
|
+
onNavigateToPrevMatch,
|
|
1700
|
+
])
|
|
1701
|
+
|
|
1702
|
+
React.useEffect(() => {
|
|
1703
|
+
const dataGridElement = dataGridRef.current
|
|
1704
|
+
if (!dataGridElement) {
|
|
1705
|
+
return
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1708
|
+
dataGridElement.addEventListener('keydown', onDataGridKeyDown)
|
|
1709
|
+
return () => {
|
|
1710
|
+
dataGridElement.removeEventListener('keydown', onDataGridKeyDown)
|
|
1711
|
+
}
|
|
1712
|
+
}, [onDataGridKeyDown])
|
|
1713
|
+
|
|
1714
|
+
React.useEffect(() => {
|
|
1715
|
+
function onGlobalKeyDown(event: KeyboardEvent) {
|
|
1716
|
+
const dataGridElement = dataGridRef.current
|
|
1717
|
+
if (!dataGridElement) {
|
|
1718
|
+
return
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1721
|
+
const target = event.target
|
|
1722
|
+
if (!(target instanceof HTMLElement)) {
|
|
1723
|
+
return
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1726
|
+
const { key, ctrlKey, metaKey } = event
|
|
1727
|
+
const isCtrlPressed = ctrlKey || metaKey
|
|
1728
|
+
|
|
1729
|
+
if (enableSearch && isCtrlPressed && key === SEARCH_SHORTCUT_KEY) {
|
|
1730
|
+
const isInInput = target.tagName === 'INPUT' || target.tagName === 'TEXTAREA'
|
|
1731
|
+
const isInDataGrid = dataGridElement.contains(target)
|
|
1732
|
+
const isInSearchInput = target.closest('[role=search]') !== null
|
|
1733
|
+
|
|
1734
|
+
if (isInDataGrid || isInSearchInput || !isInInput) {
|
|
1735
|
+
event.preventDefault()
|
|
1736
|
+
event.stopPropagation()
|
|
1737
|
+
onSearchOpenChange(true)
|
|
1738
|
+
|
|
1739
|
+
if (!isInDataGrid && !isInSearchInput) {
|
|
1740
|
+
requestAnimationFrame(() => {
|
|
1741
|
+
dataGridElement.focus()
|
|
1742
|
+
})
|
|
1743
|
+
}
|
|
1744
|
+
return
|
|
1745
|
+
}
|
|
1746
|
+
}
|
|
1747
|
+
|
|
1748
|
+
const isInDataGrid = dataGridElement.contains(target)
|
|
1749
|
+
if (!isInDataGrid) {
|
|
1750
|
+
return
|
|
1751
|
+
}
|
|
1752
|
+
|
|
1753
|
+
if (key === 'Escape') {
|
|
1754
|
+
const currentState = store.getState()
|
|
1755
|
+
const hasSelections =
|
|
1756
|
+
currentState.selectionState.selectedCells.size > 0 || Object.keys(currentState.rowSelection).length > 0
|
|
1757
|
+
|
|
1758
|
+
if (hasSelections) {
|
|
1759
|
+
event.preventDefault()
|
|
1760
|
+
event.stopPropagation()
|
|
1761
|
+
clearSelection()
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
|
|
1766
|
+
window.addEventListener('keydown', onGlobalKeyDown, true)
|
|
1767
|
+
return () => {
|
|
1768
|
+
window.removeEventListener('keydown', onGlobalKeyDown, true)
|
|
1769
|
+
}
|
|
1770
|
+
}, [enableSearch, onSearchOpenChange, store, clearSelection])
|
|
1771
|
+
|
|
1772
|
+
React.useEffect(() => {
|
|
1773
|
+
const currentState = store.getState()
|
|
1774
|
+
if (autoFocus && data.length > 0 && columns.length > 0 && !currentState.focusedCell) {
|
|
1775
|
+
const _nav = getNavigableColumnIds()
|
|
1776
|
+
if (_nav.length > 0) {
|
|
1777
|
+
const rafId = requestAnimationFrame(() => {
|
|
1778
|
+
if (typeof autoFocus === 'object') {
|
|
1779
|
+
const { rowIndex, columnId } = autoFocus
|
|
1780
|
+
if (columnId) {
|
|
1781
|
+
focusCell(rowIndex ?? 0, columnId)
|
|
1782
|
+
}
|
|
1783
|
+
return
|
|
1784
|
+
}
|
|
1785
|
+
|
|
1786
|
+
const firstColumnId = _nav[0]
|
|
1787
|
+
if (firstColumnId) {
|
|
1788
|
+
focusCell(0, firstColumnId)
|
|
1789
|
+
}
|
|
1790
|
+
})
|
|
1791
|
+
return () => cancelAnimationFrame(rafId)
|
|
1792
|
+
}
|
|
1793
|
+
}
|
|
1794
|
+
}, [autoFocus, data.length, columns.length, store, getNavigableColumnIds, focusCell])
|
|
1795
|
+
|
|
1796
|
+
React.useEffect(() => {
|
|
1797
|
+
function onOutsideClick(event: MouseEvent) {
|
|
1798
|
+
if (event.button === 2) {
|
|
1799
|
+
return
|
|
1800
|
+
}
|
|
1801
|
+
|
|
1802
|
+
if (dataGridRef.current && !dataGridRef.current.contains(event.target as Node)) {
|
|
1803
|
+
const target = event.target
|
|
1804
|
+
const isInsidePopover =
|
|
1805
|
+
target instanceof HTMLElement &&
|
|
1806
|
+
(target.closest('[data-grid-cell-editor]') || target.closest('[data-grid-popover]'))
|
|
1807
|
+
|
|
1808
|
+
if (!isInsidePopover) {
|
|
1809
|
+
blurCell()
|
|
1810
|
+
const currentState = store.getState()
|
|
1811
|
+
if (currentState.selectionState.selectedCells.size > 0 || Object.keys(currentState.rowSelection).length > 0) {
|
|
1812
|
+
clearSelection()
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1816
|
+
}
|
|
1817
|
+
|
|
1818
|
+
document.addEventListener('mousedown', onOutsideClick)
|
|
1819
|
+
return () => {
|
|
1820
|
+
document.removeEventListener('mousedown', onOutsideClick)
|
|
1821
|
+
}
|
|
1822
|
+
}, [store, blurCell, clearSelection])
|
|
1823
|
+
|
|
1824
|
+
React.useEffect(() => {
|
|
1825
|
+
function onCleanup() {
|
|
1826
|
+
document.removeEventListener('selectstart', preventSelection)
|
|
1827
|
+
document.removeEventListener('contextmenu', preventContextMenu)
|
|
1828
|
+
document.body.style.userSelect = ''
|
|
1829
|
+
}
|
|
1830
|
+
|
|
1831
|
+
function preventSelection(event: Event) {
|
|
1832
|
+
event.preventDefault()
|
|
1833
|
+
}
|
|
1834
|
+
function preventContextMenu(event: Event) {
|
|
1835
|
+
event.preventDefault()
|
|
1836
|
+
}
|
|
1837
|
+
|
|
1838
|
+
const onUnsubscribe = store.subscribe(() => {
|
|
1839
|
+
const currentState = store.getState()
|
|
1840
|
+
if (currentState.selectionState.isSelecting) {
|
|
1841
|
+
document.addEventListener('selectstart', preventSelection)
|
|
1842
|
+
document.addEventListener('contextmenu', preventContextMenu)
|
|
1843
|
+
document.body.style.userSelect = 'none'
|
|
1844
|
+
} else {
|
|
1845
|
+
onCleanup()
|
|
1846
|
+
}
|
|
1847
|
+
})
|
|
1848
|
+
|
|
1849
|
+
return () => {
|
|
1850
|
+
onCleanup()
|
|
1851
|
+
onUnsubscribe()
|
|
1852
|
+
}
|
|
1853
|
+
}, [store])
|
|
1854
|
+
|
|
1855
|
+
useIsomorphicLayoutEffect(() => {
|
|
1856
|
+
const rafId = requestAnimationFrame(() => {
|
|
1857
|
+
rowVirtualizer.measure()
|
|
1858
|
+
})
|
|
1859
|
+
return () => cancelAnimationFrame(rafId)
|
|
1860
|
+
}, [
|
|
1861
|
+
data,
|
|
1862
|
+
table.getState().columnFilters,
|
|
1863
|
+
table.getState().columnOrder,
|
|
1864
|
+
table.getState().columnPinning,
|
|
1865
|
+
table.getState().columnSizing,
|
|
1866
|
+
table.getState().columnVisibility,
|
|
1867
|
+
table.getState().expanded,
|
|
1868
|
+
table.getState().globalFilter,
|
|
1869
|
+
table.getState().grouping,
|
|
1870
|
+
table.getState().rowSelection,
|
|
1871
|
+
table.getState().sorting,
|
|
1872
|
+
rowHeight,
|
|
1873
|
+
])
|
|
1874
|
+
|
|
1875
|
+
return {
|
|
1876
|
+
dataGridRef,
|
|
1877
|
+
headerRef,
|
|
1878
|
+
rowMapRef,
|
|
1879
|
+
footerRef,
|
|
1880
|
+
table,
|
|
1881
|
+
rowVirtualizer,
|
|
1882
|
+
searchState,
|
|
1883
|
+
columnSizeVars,
|
|
1884
|
+
onRowAdd: onRowAddProp ? onRowAdd : undefined,
|
|
1885
|
+
}
|
|
1886
|
+
}
|
|
1887
|
+
|
|
1888
|
+
export { useDataGrid, type UseDataGridProps }
|