@processfocus/runtime-local 0.1.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +28 -0
- package/README.md +290 -0
- package/dist/authentication-server.mjs +188 -0
- package/dist/chunk-2sb4v2sx.js +70 -0
- package/dist/chunk-9weqs8n8.js +56031 -0
- package/dist/chunk-mvkr77wp.js +54113 -0
- package/dist/chunk-tkn4cnc8.js +453 -0
- package/dist/chunk-vpsm84e8.js +85 -0
- package/dist/dashboard-source/apps/frontend/app/%5Fpf/app-icons/[...path]/route.ts +63 -0
- package/dist/dashboard-source/apps/frontend/app/%5Fpf/health/page.tsx +19 -0
- package/dist/dashboard-source/apps/frontend/app/%5Fpf/public-form-branding/[...path]/route.ts +95 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/act-on-behalf/actions.ts +248 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/act-on-behalf/delegations-client.tsx +751 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/act-on-behalf/page.tsx +46 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/client-index.tsx +375 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/client.tsx +14 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/(.)[executionId]/client.tsx +73 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/(.)[executionId]/page.tsx +20 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/(.)[executionId]/process-state/page.tsx +22 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/default.tsx +3 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/[executionId]/page.tsx +11 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/[executionId]/process-state/page.tsx +23 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/abandon-execution-dialog.tsx +137 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/execution-card-menu.tsx +233 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/layout.tsx +19 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/page.tsx +1549 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/process-state-dialog.tsx +91 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/process-state-modal-client.tsx +33 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/process-state-page-client.tsx +31 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/process-state-route-fallback.tsx +18 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/restart-execution-feedback.tsx +40 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/layout.tsx +129 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/@modal/(.)item/[id]/client.tsx +215 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/@modal/(.)item/[id]/page.tsx +23 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/@modal/default.tsx +3 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/[...listPath]/list-page-client.tsx +678 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/[...listPath]/loading.tsx +10 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/[...listPath]/page.tsx +228 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-create-form.tsx +147 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-item-edit-form.tsx +246 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/hooks/metric-control-url-state.ts +71 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/hooks/use-list-deleted-callback.ts +22 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/hooks/use-list-item-detail.ts +315 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/item/[id]/client.tsx +259 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/item/[id]/page.tsx +46 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/layout.tsx +14 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/lib/list-detail-title.ts +20 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/lib/list-refresh.ts +26 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/utils.ts +20 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/loading.tsx +5 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/org-chart/org-chart-client.tsx +74 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/org-chart/page.tsx +120 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/page.tsx +13 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/passkeys/actions.ts +188 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/passkeys/page.tsx +33 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/passkeys/passkeys-client.tsx +320 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/@modal/(.)start/[...startStepPath]/client.tsx +152 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/@modal/(.)start/[...startStepPath]/page.tsx +41 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/@modal/default.tsx +3 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/client.tsx +33 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/components/process-form-actions.tsx +105 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/components/process-submit-button.tsx +81 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/components/start-process-form.tsx +282 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/layout.tsx +21 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/lib/mobile-process-catalog.ts +28 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/lib/start-process-actions.ts +13 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/loading.tsx +10 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/page.tsx +5 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/processes-client.tsx +504 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/start/[...startStepPath]/client.tsx +153 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/start/[...startStepPath]/page.tsx +39 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/loading.tsx +20 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/page.tsx +131 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/process-documentation.tsx +209 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/use-workflow-auto-refresh.ts +120 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/workflow-flow.tsx +319 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/workflow-form-preview-sheet.tsx +98 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/[[...tab]]/loading.tsx +1 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/[[...tab]]/page.tsx +100 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/access-handbook.tsx +110 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/authorization-loading.tsx +25 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/authorization-tabs.tsx +47 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/cedar-authorize.ts +261 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/cedar-helpers.ts +17 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/cedar-source.tsx +34 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/cedar-types.ts +79 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/evaluate-cedar.ts +43 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/explorer.tsx +526 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/layout.tsx +23 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/load-cedar.ts +174 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/load-handbook.ts +390 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/org-data.ts +70 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/[invitationId]/page.tsx +22 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/invitation-detail-client.tsx +594 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/invitation-detail-skeleton.tsx +48 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/new/page.tsx +5 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations-table.tsx +186 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/page.tsx +69 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/providers-table.tsx +48 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/roles-table.tsx +62 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/settings-client.tsx +244 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/[userId]/client.tsx +329 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/[userId]/page.tsx +21 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/[userId]/tokens/page.tsx +39 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users-table.tsx +82 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/stats/[...statsPath]/error.tsx +34 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/stats/[...statsPath]/not-found.tsx +13 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/stats/[...statsPath]/page.tsx +84 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/stats/[...statsPath]/stats-data-fetcher.tsx +93 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/@modal/(.)complete/[...stepPath]/client.tsx +143 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/@modal/(.)complete/[...stepPath]/page.tsx +50 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/@modal/default.tsx +3 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/complete/[...stepPath]/client.tsx +131 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/complete/[...stepPath]/page.tsx +50 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/components/complete-todo-form.tsx +172 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/components/public-completion-correction-form.tsx +233 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/components/todo-form-actions.tsx +26 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/correct/[...stepPath]/page.tsx +58 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/layout.tsx +14 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/lib/mobile-todo-list.ts +154 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/page.tsx +1317 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/callback/route.ts +259 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/delegation/route.ts +127 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/login/route.ts +49 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/logout/route.ts +33 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/passkey/auth-options/route.ts +79 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/passkey/auth-verify/route.ts +142 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/passkey/register/route.ts +103 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/passkey/register-verify/route.ts +136 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/passkey/registration-session/route.ts +129 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/passkey/start/route.ts +153 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/refresh/route.ts +122 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/switch-role/route.ts +177 -0
- package/dist/dashboard-source/apps/frontend/app/api/dev/import-completed/route.ts +22 -0
- package/dist/dashboard-source/apps/frontend/app/api/dev/import-events/route.ts +38 -0
- package/dist/dashboard-source/apps/frontend/app/api/embed/lookup/route.ts +266 -0
- package/dist/dashboard-source/apps/frontend/app/api/embed/submit/route.ts +118 -0
- package/dist/dashboard-source/apps/frontend/app/api/embed/test-host/route.ts +125 -0
- package/dist/dashboard-source/apps/frontend/app/api/public/to-dos/calendar-slots/route.ts +44 -0
- package/dist/dashboard-source/apps/frontend/app/api/public/to-dos/complete/route.ts +56 -0
- package/dist/dashboard-source/apps/frontend/app/api/public/to-dos/lookup/route.ts +61 -0
- package/dist/dashboard-source/apps/frontend/app/api/public/to-dos/request-fresh-link/route.ts +41 -0
- package/dist/dashboard-source/apps/frontend/app/api/revalidate/route.ts +61 -0
- package/dist/dashboard-source/apps/frontend/app/app-shell.tsx +100 -0
- package/dist/dashboard-source/apps/frontend/app/cli-auth/route.ts +261 -0
- package/dist/dashboard-source/apps/frontend/app/embed/[...startStepPath]/embed-client.tsx +393 -0
- package/dist/dashboard-source/apps/frontend/app/embed/[...startStepPath]/loading.tsx +13 -0
- package/dist/dashboard-source/apps/frontend/app/embed/[...startStepPath]/page.tsx +51 -0
- package/dist/dashboard-source/apps/frontend/app/embed/embedded.css +48 -0
- package/dist/dashboard-source/apps/frontend/app/embed/layout.tsx +15 -0
- package/dist/dashboard-source/apps/frontend/app/global.css +13 -0
- package/dist/dashboard-source/apps/frontend/app/layout.tsx +102 -0
- package/dist/dashboard-source/apps/frontend/app/login/layout.tsx +9 -0
- package/dist/dashboard-source/apps/frontend/app/login/login-button.tsx +35 -0
- package/dist/dashboard-source/apps/frontend/app/login/login-form-content.tsx +117 -0
- package/dist/dashboard-source/apps/frontend/app/login/login-form.tsx +30 -0
- package/dist/dashboard-source/apps/frontend/app/login/page.tsx +52 -0
- package/dist/dashboard-source/apps/frontend/app/login/passkey-button.tsx +226 -0
- package/dist/dashboard-source/apps/frontend/app/login/secret-login-form.tsx +91 -0
- package/dist/dashboard-source/apps/frontend/app/manifest.ts +7 -0
- package/dist/dashboard-source/apps/frontend/app/public/form/[token]/error.tsx +63 -0
- package/dist/dashboard-source/apps/frontend/app/public/form/[token]/layout.tsx +34 -0
- package/dist/dashboard-source/apps/frontend/app/public/form/[token]/page.tsx +129 -0
- package/dist/dashboard-source/apps/frontend/app/public/form/[token]/public-form-branding-card.tsx +42 -0
- package/dist/dashboard-source/apps/frontend/app/public/form/[token]/public-form-branding-context.tsx +27 -0
- package/dist/dashboard-source/apps/frontend/app/public/form/[token]/public-form-branding-html.tsx +40 -0
- package/dist/dashboard-source/apps/frontend/app/public/form/[token]/public-todo-client.tsx +553 -0
- package/dist/dashboard-source/apps/frontend/app/public/form/[token]/public-todo-state-content.tsx +27 -0
- package/dist/dashboard-source/apps/frontend/app/public.css +33 -0
- package/dist/dashboard-source/apps/frontend/app/register/passkey/layout.tsx +49 -0
- package/dist/dashboard-source/apps/frontend/app/register/passkey/page.tsx +36 -0
- package/dist/dashboard-source/apps/frontend/app/register/passkey/register-passkey-client.tsx +292 -0
- package/dist/dashboard-source/apps/frontend/app/theme.css +117 -0
- package/dist/dashboard-source/apps/frontend/components/DashboardSection.tsx +693 -0
- package/dist/dashboard-source/apps/frontend/components/Header.tsx +481 -0
- package/dist/dashboard-source/apps/frontend/components/OrgUnitNode.tsx +41 -0
- package/dist/dashboard-source/apps/frontend/components/app-sidebar.tsx +245 -0
- package/dist/dashboard-source/apps/frontend/components/auth-provider.tsx +158 -0
- package/dist/dashboard-source/apps/frontend/components/collections/collection-table-card.tsx +218 -0
- package/dist/dashboard-source/apps/frontend/components/collections/collection-table-header-row.tsx +97 -0
- package/dist/dashboard-source/apps/frontend/components/config-provider.tsx +27 -0
- package/dist/dashboard-source/apps/frontend/components/copy-button.tsx +40 -0
- package/dist/dashboard-source/apps/frontend/components/dashboard-activity.tsx +35 -0
- package/dist/dashboard-source/apps/frontend/components/dashboard-skeleton.tsx +17 -0
- package/dist/dashboard-source/apps/frontend/components/delegation-expiry.tsx +21 -0
- package/dist/dashboard-source/apps/frontend/components/feature-permissions-provider.tsx +28 -0
- package/dist/dashboard-source/apps/frontend/components/form-dialog-content.tsx +66 -0
- package/dist/dashboard-source/apps/frontend/components/frontend-client-plugin-host.tsx +27 -0
- package/dist/dashboard-source/apps/frontend/components/frontend-client-plugin-identify.tsx +33 -0
- package/dist/dashboard-source/apps/frontend/components/frontend-client-plugin-provider.tsx +55 -0
- package/dist/dashboard-source/apps/frontend/components/journey-timeline.tsx +378 -0
- package/dist/dashboard-source/apps/frontend/components/mobile-home-switchboard.tsx +98 -0
- package/dist/dashboard-source/apps/frontend/components/mocks-provider.tsx +27 -0
- package/dist/dashboard-source/apps/frontend/components/notification-bell.tsx +137 -0
- package/dist/dashboard-source/apps/frontend/components/org-settings-provider.tsx +26 -0
- package/dist/dashboard-source/apps/frontend/components/process-workflow-link.tsx +36 -0
- package/dist/dashboard-source/apps/frontend/components/session-reissue.tsx +48 -0
- package/dist/dashboard-source/apps/frontend/components/sidebar-lists.tsx +89 -0
- package/dist/dashboard-source/apps/frontend/components/sidebar-stats-views.tsx +65 -0
- package/dist/dashboard-source/apps/frontend/components/theme-provider.tsx +132 -0
- package/dist/dashboard-source/apps/frontend/components/todo-count-badge.tsx +59 -0
- package/dist/dashboard-source/apps/frontend/components/token-refresh-scheduler.tsx +304 -0
- package/dist/dashboard-source/apps/frontend/components/ui/checkbox.tsx +31 -0
- package/dist/dashboard-source/apps/frontend/components/ui/dialog.tsx +142 -0
- package/dist/dashboard-source/apps/frontend/components/ui/dropdown-menu.tsx +256 -0
- package/dist/dashboard-source/apps/frontend/components/ui/input.tsx +20 -0
- package/dist/dashboard-source/apps/frontend/components/ui/pagination.tsx +59 -0
- package/dist/dashboard-source/apps/frontend/components/ui/sheet.tsx +138 -0
- package/dist/dashboard-source/apps/frontend/components/ui/sidebar.tsx +741 -0
- package/dist/dashboard-source/apps/frontend/components/ui/skeleton.tsx +13 -0
- package/dist/dashboard-source/apps/frontend/components/ui/tab-pill.tsx +30 -0
- package/dist/dashboard-source/apps/frontend/components/ui/table.tsx +115 -0
- package/dist/dashboard-source/apps/frontend/components/ui/tooltip.tsx +60 -0
- package/dist/dashboard-source/apps/frontend/components/without-waiting-badge.tsx +24 -0
- package/dist/dashboard-source/apps/frontend/components/workflow/step-node.tsx +116 -0
- package/dist/dashboard-source/apps/frontend/components/workflow/swimlane-node.tsx +46 -0
- package/dist/dashboard-source/apps/frontend/components/workflow/workflow-edge.tsx +172 -0
- package/dist/dashboard-source/apps/frontend/hooks/use-draft-process-save.ts +189 -0
- package/dist/dashboard-source/apps/frontend/hooks/use-draft-state.ts +79 -0
- package/dist/dashboard-source/apps/frontend/hooks/use-form-metadata.ts +74 -0
- package/dist/dashboard-source/apps/frontend/hooks/use-mobile.ts +27 -0
- package/dist/dashboard-source/apps/frontend/hooks/use-notification-preference.ts +246 -0
- package/dist/dashboard-source/apps/frontend/hooks/use-processes-query.ts +56 -0
- package/dist/dashboard-source/apps/frontend/hooks/use-weekly-execution-stats.ts +101 -0
- package/dist/dashboard-source/apps/frontend/index.d.ts +12 -0
- package/dist/dashboard-source/apps/frontend/instrumentation.node.ts +25 -0
- package/dist/dashboard-source/apps/frontend/instrumentation.ts +19 -0
- package/dist/dashboard-source/apps/frontend/lib/app-icons-metadata.ts +66 -0
- package/dist/dashboard-source/apps/frontend/lib/appsync-events/adapter.ts +128 -0
- package/dist/dashboard-source/apps/frontend/lib/appsync-events/client.ts +355 -0
- package/dist/dashboard-source/apps/frontend/lib/appsync-events/config.ts +18 -0
- package/dist/dashboard-source/apps/frontend/lib/appsync-events/reconnect-registry.ts +34 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/act-on-behalf-menu.ts +9 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/callback-error.ts +26 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/client-session.ts +32 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/client.ts +46 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/config.ts +48 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/delegations.ts +62 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/issuer.ts +164 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/jwt.ts +17 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/logout.ts +35 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/passkeys-menu.ts +9 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/passkeys.ts +117 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/providers.ts +52 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/realtime-session-token.ts +62 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/reauthentication-state.ts +16 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/redirect.ts +105 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/secret-login-presentation.ts +33 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/session-cache-scope.ts +1 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/session-role.ts +6 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/session.ts +277 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/ssr-session.ts +76 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/verify-passkey.ts +95 -0
- package/dist/dashboard-source/apps/frontend/lib/authorization-tabs.ts +19 -0
- package/dist/dashboard-source/apps/frontend/lib/cedar-highlight.ts +116 -0
- package/dist/dashboard-source/apps/frontend/lib/client-plugin-error-reporting.ts +28 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/collection-provider-factory.tsx +1119 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/collection-provider-scope.ts +48 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/database-error-ui.tsx +61 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/draft-process-execution-collection-provider.tsx +32 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/draft-process-execution.ts +161 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/execution-collection-provider.tsx +42 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/execution.ts +215 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/graphql-stream.ts +123 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/process-collection-provider.tsx +30 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/process.ts +123 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/replication-factory.ts +394 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/replication-registry.ts +196 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/rxdb-database-name.ts +19 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/rxdb-lifecycle.ts +368 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/rxdb-provider.tsx +577 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/todo-collection-provider.tsx +30 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/todo.ts +133 -0
- package/dist/dashboard-source/apps/frontend/lib/current-provider-user.ts +30 -0
- package/dist/dashboard-source/apps/frontend/lib/dev/frontend-port-file.ts +41 -0
- package/dist/dashboard-source/apps/frontend/lib/dev/import-completed-events.ts +21 -0
- package/dist/dashboard-source/apps/frontend/lib/dev/import-completed-query-invalidation.tsx +62 -0
- package/dist/dashboard-source/apps/frontend/lib/dev/import-completed-refresh.ts +40 -0
- package/dist/dashboard-source/apps/frontend/lib/effect/error-boundary.tsx +84 -0
- package/dist/dashboard-source/apps/frontend/lib/effect/index.ts +31 -0
- package/dist/dashboard-source/apps/frontend/lib/effect/params.ts +57 -0
- package/dist/dashboard-source/apps/frontend/lib/effect/run-effect.ts +17 -0
- package/dist/dashboard-source/apps/frontend/lib/effect/runtime.ts +168 -0
- package/dist/dashboard-source/apps/frontend/lib/effect/services/access-token.ts +48 -0
- package/dist/dashboard-source/apps/frontend/lib/effect/services/authorization.ts +206 -0
- package/dist/dashboard-source/apps/frontend/lib/effect/services/form-validation.ts +36 -0
- package/dist/dashboard-source/apps/frontend/lib/effect/services/graphql.ts +94 -0
- package/dist/dashboard-source/apps/frontend/lib/effect/services/index.ts +21 -0
- package/dist/dashboard-source/apps/frontend/lib/embed-manifest-store.ts +20 -0
- package/dist/dashboard-source/apps/frontend/lib/embed-manifest.ts +152 -0
- package/dist/dashboard-source/apps/frontend/lib/embed-request-origin.ts +39 -0
- package/dist/dashboard-source/apps/frontend/lib/errors/get-display-error-message.ts +22 -0
- package/dist/dashboard-source/apps/frontend/lib/execution-menu-actions-registry.ts +26 -0
- package/dist/dashboard-source/apps/frontend/lib/feature-permissions.ts +13 -0
- package/dist/dashboard-source/apps/frontend/lib/frontend-boot-health.tsx +161 -0
- package/dist/dashboard-source/apps/frontend/lib/frontend-client-plugin-registry.ts +45 -0
- package/dist/dashboard-source/apps/frontend/lib/frontend-manifest-store.ts +214 -0
- package/dist/dashboard-source/apps/frontend/lib/frontend-manifest.ts +74 -0
- package/dist/dashboard-source/apps/frontend/lib/frontend-plugin-loaders.ts +191 -0
- package/dist/dashboard-source/apps/frontend/lib/generated/gql/fragment-masking.ts +87 -0
- package/dist/dashboard-source/apps/frontend/lib/generated/gql/gql.ts +292 -0
- package/dist/dashboard-source/apps/frontend/lib/generated/gql/graphql.ts +443 -0
- package/dist/dashboard-source/apps/frontend/lib/generated/gql/index.ts +2 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/client-consumer.tsx +23 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/client-error-reporting.ts +268 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/client-provider.tsx +59 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/dashboard-activity.ts +7 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/dependent-lookup-query.ts +78 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/endpoint.ts +26 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/execution-queries.ts +70 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/file-upload-provider.tsx +82 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/graphql-identifiers.ts +10 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/list-queries.ts +327 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/lookup-provider.tsx +81 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/org-chart-operations.ts +63 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/org-chart-queries.ts +67 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/provider-user-queries.ts +65 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/queries.ts +80 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/server-client.ts +15 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/settings-queries.ts +634 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/stats-views-server.ts +16 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/stats-views.ts +33 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/user-queries.ts +138 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/workflow-operations.ts +54 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/workflow-queries.ts +50 -0
- package/dist/dashboard-source/apps/frontend/lib/mobile-home-view-model.ts +74 -0
- package/dist/dashboard-source/apps/frontend/lib/mobile-shell-policy.ts +124 -0
- package/dist/dashboard-source/apps/frontend/lib/mock-data.ts +364 -0
- package/dist/dashboard-source/apps/frontend/lib/notifications/notification-preference.ts +251 -0
- package/dist/dashboard-source/apps/frontend/lib/notifications/todo-notification-observer.ts +178 -0
- package/dist/dashboard-source/apps/frontend/lib/notifications/todo-notifications-runtime.tsx +14 -0
- package/dist/dashboard-source/apps/frontend/lib/notifications/use-todo-notifications.tsx +103 -0
- package/dist/dashboard-source/apps/frontend/lib/org-chart-data.ts +50 -0
- package/dist/dashboard-source/apps/frontend/lib/org-chart-depth-config.ts +71 -0
- package/dist/dashboard-source/apps/frontend/lib/org-chart-layout.ts +149 -0
- package/dist/dashboard-source/apps/frontend/lib/org-chart-types.ts +17 -0
- package/dist/dashboard-source/apps/frontend/lib/org-identity.ts +57 -0
- package/dist/dashboard-source/apps/frontend/lib/organisation-plugin-loaders.ts +13 -0
- package/dist/dashboard-source/apps/frontend/lib/organisation-plugin-preparation.ts +2 -0
- package/dist/dashboard-source/apps/frontend/lib/plugins-client.tsx +99 -0
- package/dist/dashboard-source/apps/frontend/lib/plugins.ts +1 -0
- package/dist/dashboard-source/apps/frontend/lib/public-todo-form-runtime.ts +9 -0
- package/dist/dashboard-source/apps/frontend/lib/public-todo-graphql-errors.ts +45 -0
- package/dist/dashboard-source/apps/frontend/lib/public-todo-model.ts +200 -0
- package/dist/dashboard-source/apps/frontend/lib/public-todo-server.ts +209 -0
- package/dist/dashboard-source/apps/frontend/lib/query-client.ts +41 -0
- package/dist/dashboard-source/apps/frontend/lib/restart-execution-action.ts +76 -0
- package/dist/dashboard-source/apps/frontend/lib/runtime-config.ts +23 -0
- package/dist/dashboard-source/apps/frontend/lib/telemetry/constants.ts +5 -0
- package/dist/dashboard-source/apps/frontend/lib/telemetry/otlp-config.ts +16 -0
- package/dist/dashboard-source/apps/frontend/lib/telemetry/register-otel.ts +308 -0
- package/dist/dashboard-source/apps/frontend/lib/theme.ts +9 -0
- package/dist/dashboard-source/apps/frontend/lib/todo-types.ts +64 -0
- package/dist/dashboard-source/apps/frontend/lib/todo-utils.ts +144 -0
- package/dist/dashboard-source/apps/frontend/lib/types/org-identity.ts +7 -0
- package/dist/dashboard-source/apps/frontend/lib/utils.ts +16 -0
- package/dist/dashboard-source/apps/frontend/lib/workflow/constants.ts +118 -0
- package/dist/dashboard-source/apps/frontend/lib/workflow/edge-routing.ts +195 -0
- package/dist/dashboard-source/apps/frontend/lib/workflow/form-preview.ts +8 -0
- package/dist/dashboard-source/apps/frontend/lib/workflow/layout.ts +878 -0
- package/dist/dashboard-source/apps/frontend/lib/workflow/types.ts +63 -0
- package/dist/dashboard-source/apps/frontend/next.config.ts +238 -0
- package/dist/dashboard-source/apps/frontend/package.json +71 -0
- package/dist/dashboard-source/apps/frontend/postcss.config.mjs +5 -0
- package/dist/dashboard-source/apps/frontend/proxy.ts +293 -0
- package/dist/dashboard-source/apps/frontend/public/.gitkeep +0 -0
- package/dist/dashboard-source/apps/frontend/public/favicon.ico +0 -0
- package/dist/dashboard-source/apps/frontend/public/processfocus-embed.js +553 -0
- package/dist/dashboard-source/apps/frontend/tsconfig.json +35 -0
- package/dist/dashboard-source/modules/auth-local-cedar/src/index.ts +7 -0
- package/dist/dashboard-source/modules/auth-local-cedar/src/lib/auth-local-cedar.ts +1397 -0
- package/dist/dashboard-source/modules/auth-local-cedar/src/lib/cedar-reload-notifier.ts +18 -0
- package/dist/dashboard-source/modules/auth-local-cedar/src/lib/config-base.ts +346 -0
- package/dist/dashboard-source/modules/auth-local-cedar/src/lib/policy-watcher.ts +172 -0
- package/dist/dashboard-source/modules/auth-policy/src/index.ts +4 -0
- package/dist/dashboard-source/modules/auth-policy/src/lib/auth-policy.ts +263 -0
- package/dist/dashboard-source/modules/auth-policy/src/lib/current-principal.ts +34 -0
- package/dist/dashboard-source/modules/auth-policy/src/lib/errors.ts +47 -0
- package/dist/dashboard-source/modules/auth-policy/src/lib/types.ts +595 -0
- package/dist/dashboard-source/modules/auth-session/src/index.ts +22 -0
- package/dist/dashboard-source/modules/auth-session/src/lib/issuer-url.ts +192 -0
- package/dist/dashboard-source/modules/auth-session/src/lib/realtime-recipient.ts +76 -0
- package/dist/dashboard-source/modules/auth-session/src/lib/session-cache-scope.ts +24 -0
- package/dist/dashboard-source/modules/auth-session/src/lib/subjects.ts +54 -0
- package/dist/dashboard-source/modules/auth-session/src/lib/url.ts +2 -0
- package/dist/dashboard-source/modules/aws-common/src/index.ts +3 -0
- package/dist/dashboard-source/modules/aws-common/src/lib/acm.ts +50 -0
- package/dist/dashboard-source/modules/aws-common/src/lib/otlp-config.ts +66 -0
- package/dist/dashboard-source/modules/aws-common/src/lib/runtime-ssm.ts +28 -0
- package/dist/dashboard-source/modules/effect-json-logger/src/index.ts +1 -0
- package/dist/dashboard-source/modules/effect-json-logger/src/lib/effect-json-logger.ts +65 -0
- package/dist/dashboard-source/modules/form/src/hooks/use-local-storage.ts +78 -0
- package/dist/dashboard-source/modules/form/src/index.ts +20 -0
- package/dist/dashboard-source/modules/form/src/lib/ajv-standard-schema.ts +152 -0
- package/dist/dashboard-source/modules/form/src/lib/client-components-to-form.tsx +1421 -0
- package/dist/dashboard-source/modules/form/src/lib/friendly-validation-message.ts +85 -0
- package/dist/dashboard-source/modules/form/src/lib/lookup-context.tsx +58 -0
- package/dist/dashboard-source/modules/form/src/lib/plugin-registry.ts +34 -0
- package/dist/dashboard-source/modules/form/src/lib/walker.tsx +1554 -0
- package/dist/dashboard-source/modules/form-client-representation/src/lib/client-form-definition.ts +440 -0
- package/dist/dashboard-source/modules/form-client-representation/src/lib/plugin-registry.ts +13 -0
- package/dist/dashboard-source/modules/form-client-representation/src/lib/types.ts +336 -0
- package/dist/dashboard-source/modules/form-rule/src/index.ts +21 -0
- package/dist/dashboard-source/modules/form-rule/src/lib/evaluator.ts +531 -0
- package/dist/dashboard-source/modules/form-rule/src/lib/paths.ts +102 -0
- package/dist/dashboard-source/modules/form-rule/src/lib/types.ts +121 -0
- package/dist/dashboard-source/modules/form-schema/src/index.ts +8 -0
- package/dist/dashboard-source/modules/form-schema/src/lib/annotation-helpers.ts +44 -0
- package/dist/dashboard-source/modules/form-schema/src/lib/deferred-value.ts +21 -0
- package/dist/dashboard-source/modules/form-schema/src/lib/email.ts +50 -0
- package/dist/dashboard-source/modules/form-schema/src/lib/field-count.ts +82 -0
- package/dist/dashboard-source/modules/form-schema/src/lib/form-annotations.ts +58 -0
- package/dist/dashboard-source/modules/form-schema/src/lib/form-schema.ts +975 -0
- package/dist/dashboard-source/modules/form-schema/src/lib/phone.ts +60 -0
- package/dist/dashboard-source/modules/form-schema/src/lib/property-signature.ts +45 -0
- package/dist/dashboard-source/modules/frontend-endpoints/src/endpoint.ts +137 -0
- package/dist/dashboard-source/modules/frontend-endpoints/src/index.ts +11 -0
- package/dist/dashboard-source/modules/frontend-endpoints/src/port-files.ts +219 -0
- package/dist/dashboard-source/modules/frontend-manifest/src/index.ts +2 -0
- package/dist/dashboard-source/modules/frontend-manifest/src/lib/browser-plugin-artifact.ts +201 -0
- package/dist/dashboard-source/modules/frontend-manifest/src/lib/frontend-manifest.ts +408 -0
- package/dist/dashboard-source/modules/frontend-plugin-host/src/index.ts +29 -0
- package/dist/dashboard-source/modules/frontend-plugin-host/src/lib/frontend-plugin-host.ts +288 -0
- package/dist/dashboard-source/modules/openauth/src/client.ts +1045 -0
- package/dist/dashboard-source/modules/openauth/src/error.ts +140 -0
- package/dist/dashboard-source/modules/openauth/src/pkce.ts +40 -0
- package/dist/dashboard-source/modules/openauth/src/random.ts +24 -0
- package/dist/dashboard-source/modules/openauth/src/subject.ts +132 -0
- package/dist/dashboard-source/modules/openauth/src/util.ts +13 -0
- package/dist/dashboard-source/modules/request-time/src/index.ts +1 -0
- package/dist/dashboard-source/modules/request-time/src/lib/request-time.ts +30 -0
- package/dist/dashboard-source/modules/rxdb-collections/generated/draft-process-execution-schema.json +45 -0
- package/dist/dashboard-source/modules/rxdb-collections/generated/execution-schema.json +217 -0
- package/dist/dashboard-source/modules/rxdb-collections/generated/process-schema.json +77 -0
- package/dist/dashboard-source/modules/rxdb-collections/generated/todo-schema.json +94 -0
- package/dist/dashboard-source/modules/rxdb-collections/src/index.ts +2 -0
- package/dist/dashboard-source/modules/rxdb-collections/src/lib/rxdb-collections.ts +181 -0
- package/dist/dashboard-source/modules/rxdb-collections/src/lib/to-rxdb-schema.ts +166 -0
- package/dist/dashboard-source/modules/shadcn-components/src/index.ts +60 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/boolean-field.tsx +73 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/calendar-slot-field.tsx +808 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/date-field.tsx +127 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/field-set.tsx +14 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/file-field.tsx +321 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/file-upload-context.tsx +45 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/form-context.tsx +19 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/lookup-field.tsx +394 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/radio-field.tsx +96 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/select-field.tsx +106 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/text-field.tsx +245 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/ui/button.tsx +63 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/ui/checkbox.tsx +31 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/ui/command.tsx +101 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/ui/field.tsx +275 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/ui/input.tsx +29 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/ui/label.tsx +23 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/ui/popover.tsx +31 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/ui/separator.tsx +27 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/ui/textarea.tsx +19 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/utils/utils.ts +4 -0
- package/dist/dashboard-source.json +70 -0
- package/dist/graphql-server.mjs +1319 -0
- package/dist/job-worker.mjs +989 -0
- package/dist/main.mjs +495 -0
- package/dist/prepare-dashboard.mjs +35 -0
- package/dist/resources/cedar/policies.cedar +315 -0
- package/dist/resources/cedar/schema.cedarschema +276 -0
- package/dist/resources/graphql-schema/rxdb.graphql +401 -0
- package/dist/resources/graphql-schema/system.graphql +1200 -0
- package/package.json +98 -0
|
@@ -0,0 +1,808 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import type { StandardSchemaV1Issue } from "@tanstack/react-form"
|
|
4
|
+
import { useEffect, useMemo, useRef, useState } from "react"
|
|
5
|
+
import type {
|
|
6
|
+
CalendarSlotCalendarMetadata,
|
|
7
|
+
CalendarSlotWeekday,
|
|
8
|
+
} from "../../../form-schema/src/index.ts"
|
|
9
|
+
import { useFieldContext, useFormContext } from "./form-context.tsx"
|
|
10
|
+
import { Field, FieldDescription, FieldError, FieldLabel } from "./ui/field.tsx"
|
|
11
|
+
import { cn } from "./utils/utils.ts"
|
|
12
|
+
|
|
13
|
+
export interface CalendarSlotFieldItem {
|
|
14
|
+
readonly value: string
|
|
15
|
+
readonly startsAt: string
|
|
16
|
+
readonly endsAt: string
|
|
17
|
+
readonly label?: string | undefined
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface CalendarSlotFieldProps {
|
|
21
|
+
readonly label: string
|
|
22
|
+
readonly descriptionHtml?: string | undefined | null
|
|
23
|
+
readonly emptyMessageHtml?: string | undefined | null
|
|
24
|
+
readonly loadErrorMessageHtml?: string | undefined | null
|
|
25
|
+
readonly slots: CalendarSlotFieldItem[]
|
|
26
|
+
readonly loading: boolean
|
|
27
|
+
readonly error?: boolean | undefined
|
|
28
|
+
readonly readOnly?: boolean
|
|
29
|
+
readonly autoFocus?: boolean
|
|
30
|
+
readonly timeZone: string
|
|
31
|
+
readonly locale: string
|
|
32
|
+
readonly calendar?: CalendarSlotCalendarMetadata | undefined
|
|
33
|
+
readonly onRetry?: (() => void) | undefined
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
type CalendarSlotMonthCell =
|
|
37
|
+
| { readonly _tag: "blank"; readonly key: string }
|
|
38
|
+
| {
|
|
39
|
+
readonly _tag: "day"
|
|
40
|
+
readonly key: string
|
|
41
|
+
readonly dateKey: string
|
|
42
|
+
readonly day: number
|
|
43
|
+
readonly inVisibleMonth: boolean
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const DAY_NUMBER_FONT_FAMILY =
|
|
47
|
+
'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'
|
|
48
|
+
// 2026-01-04 is a known Sunday; offset from it for locale-specific weekday labels.
|
|
49
|
+
const WEEKDAY_REFERENCE_SUNDAY = Date.UTC(2026, 0, 4)
|
|
50
|
+
|
|
51
|
+
const dateKeyFormatter = (timeZone: string) =>
|
|
52
|
+
new Intl.DateTimeFormat("en-CA", {
|
|
53
|
+
timeZone,
|
|
54
|
+
year: "numeric",
|
|
55
|
+
month: "2-digit",
|
|
56
|
+
day: "2-digit",
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
const dateKeyFromDate = (date: Date, timeZone: string): string => {
|
|
60
|
+
const parts = dateKeyFormatter(timeZone).formatToParts(date)
|
|
61
|
+
const year = parts.find((part) => part.type === "year")?.value
|
|
62
|
+
const month = parts.find((part) => part.type === "month")?.value
|
|
63
|
+
const day = parts.find((part) => part.type === "day")?.value
|
|
64
|
+
|
|
65
|
+
return year && month && day ? `${year}-${month}-${day}` : ""
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const parseDateKey = (key: string) => {
|
|
69
|
+
const [year = 0, month = 1, day = 1] = key
|
|
70
|
+
.split("-")
|
|
71
|
+
.map((part) => Number(part))
|
|
72
|
+
return { day, month, year }
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const parseMonthKey = (key: string) => {
|
|
76
|
+
const [year = 0, month = 1] = key.split("-").map((part) => Number(part))
|
|
77
|
+
return { month, year }
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const padded = (value: number) => value.toString().padStart(2, "0")
|
|
81
|
+
|
|
82
|
+
const dateKeyFromParts = (year: number, month: number, day: number): string =>
|
|
83
|
+
`${year}-${padded(month)}-${padded(day)}`
|
|
84
|
+
|
|
85
|
+
const monthKeyFromParts = (year: number, month: number): string =>
|
|
86
|
+
`${year}-${padded(month)}`
|
|
87
|
+
|
|
88
|
+
const monthKeyFromDateKey = (key: string): string => key.slice(0, 7)
|
|
89
|
+
|
|
90
|
+
const monthIndex = (key: string): number => {
|
|
91
|
+
const { year, month } = parseMonthKey(key)
|
|
92
|
+
return year * 12 + month - 1
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const compareMonthKeys = (left: string, right: string): number =>
|
|
96
|
+
monthIndex(left) - monthIndex(right)
|
|
97
|
+
|
|
98
|
+
const addMonthsToMonthKey = (key: string, offset: number): string => {
|
|
99
|
+
const { year, month } = parseMonthKey(key)
|
|
100
|
+
const date = new Date(Date.UTC(year, month - 1 + offset, 1))
|
|
101
|
+
return monthKeyFromParts(date.getUTCFullYear(), date.getUTCMonth() + 1)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const addDaysToDateKey = (key: string, offset: number): string => {
|
|
105
|
+
const { year, month, day } = parseDateKey(key)
|
|
106
|
+
const date = new Date(Date.UTC(year, month - 1, day + offset))
|
|
107
|
+
return dateKeyFromParts(
|
|
108
|
+
date.getUTCFullYear(),
|
|
109
|
+
date.getUTCMonth() + 1,
|
|
110
|
+
date.getUTCDate(),
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const monthDateFromKey = (key: string): Date => {
|
|
115
|
+
const { year, month } = parseMonthKey(key)
|
|
116
|
+
return new Date(Date.UTC(year, month - 1, 1))
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const dayOfWeekFromKey = (key: string): CalendarSlotWeekday => {
|
|
120
|
+
const { year, month, day } = parseDateKey(key)
|
|
121
|
+
return new Date(
|
|
122
|
+
Date.UTC(year, month - 1, day),
|
|
123
|
+
).getUTCDay() as CalendarSlotWeekday
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
const formatMonthTitle = (key: string, locale: string): string =>
|
|
127
|
+
new Intl.DateTimeFormat(locale, {
|
|
128
|
+
timeZone: "UTC",
|
|
129
|
+
month: "long",
|
|
130
|
+
year: "numeric",
|
|
131
|
+
})
|
|
132
|
+
.format(monthDateFromKey(key))
|
|
133
|
+
.toUpperCase()
|
|
134
|
+
|
|
135
|
+
const formatDateHeading = (key: string, locale: string): string => {
|
|
136
|
+
const { year, month, day } = parseDateKey(key)
|
|
137
|
+
return new Intl.DateTimeFormat(locale, {
|
|
138
|
+
timeZone: "UTC",
|
|
139
|
+
weekday: "short",
|
|
140
|
+
day: "numeric",
|
|
141
|
+
month: "short",
|
|
142
|
+
}).format(new Date(Date.UTC(year, month - 1, day)))
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const formatStartTime = (
|
|
146
|
+
slot: CalendarSlotFieldItem,
|
|
147
|
+
timeZone: string,
|
|
148
|
+
locale: string,
|
|
149
|
+
): string => {
|
|
150
|
+
const parts = new Intl.DateTimeFormat(locale, {
|
|
151
|
+
timeZone,
|
|
152
|
+
hour: "numeric",
|
|
153
|
+
minute: "2-digit",
|
|
154
|
+
}).formatToParts(new Date(slot.startsAt))
|
|
155
|
+
const hour = parts.find((part) => part.type === "hour")?.value
|
|
156
|
+
const minute = parts.find((part) => part.type === "minute")?.value ?? "00"
|
|
157
|
+
const dayPeriod =
|
|
158
|
+
parts.find((part) => part.type === "dayPeriod")?.value.toLowerCase() ?? ""
|
|
159
|
+
|
|
160
|
+
if (!hour) {
|
|
161
|
+
return ""
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return minute === "00"
|
|
165
|
+
? `${hour}${dayPeriod}`
|
|
166
|
+
: `${hour}:${minute}${dayPeriod}`
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const weekDayLabels = (
|
|
170
|
+
weekStartsOn: CalendarSlotWeekday,
|
|
171
|
+
locale: string,
|
|
172
|
+
): Array<{ readonly day: CalendarSlotWeekday; readonly label: string }> =>
|
|
173
|
+
Array.from({ length: 7 }, (_value, index) => {
|
|
174
|
+
const day = ((weekStartsOn + index) % 7) as CalendarSlotWeekday
|
|
175
|
+
const label = new Intl.DateTimeFormat(locale, {
|
|
176
|
+
timeZone: "UTC",
|
|
177
|
+
weekday: "short",
|
|
178
|
+
})
|
|
179
|
+
.format(new Date(WEEKDAY_REFERENCE_SUNDAY + day * 86_400_000))
|
|
180
|
+
.toUpperCase()
|
|
181
|
+
|
|
182
|
+
return { day, label }
|
|
183
|
+
})
|
|
184
|
+
|
|
185
|
+
const buildMonthCells = (
|
|
186
|
+
monthKey: string,
|
|
187
|
+
weekStartsOn: CalendarSlotWeekday,
|
|
188
|
+
): CalendarSlotMonthCell[] => {
|
|
189
|
+
const { year, month } = parseMonthKey(monthKey)
|
|
190
|
+
const daysInMonth = new Date(Date.UTC(year, month, 0)).getUTCDate()
|
|
191
|
+
const firstDayOfWeek = new Date(Date.UTC(year, month - 1, 1)).getUTCDay()
|
|
192
|
+
const leadingBlankCount = (firstDayOfWeek - weekStartsOn + 7) % 7
|
|
193
|
+
const totalCells = Math.ceil((leadingBlankCount + daysInMonth) / 7) * 7
|
|
194
|
+
|
|
195
|
+
return Array.from({ length: totalCells }, (_value, index) => {
|
|
196
|
+
const dayOffset = index - leadingBlankCount + 1
|
|
197
|
+
if (dayOffset < 1) {
|
|
198
|
+
return { _tag: "blank", key: `blank-${index}` }
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const dateKey =
|
|
202
|
+
dayOffset <= daysInMonth
|
|
203
|
+
? dateKeyFromParts(year, month, dayOffset)
|
|
204
|
+
: addDaysToDateKey(
|
|
205
|
+
dateKeyFromParts(year, month, daysInMonth),
|
|
206
|
+
dayOffset - daysInMonth,
|
|
207
|
+
)
|
|
208
|
+
const { day } = parseDateKey(dateKey)
|
|
209
|
+
return {
|
|
210
|
+
_tag: "day",
|
|
211
|
+
key: dateKey,
|
|
212
|
+
dateKey,
|
|
213
|
+
day,
|
|
214
|
+
inVisibleMonth: monthKeyFromDateKey(dateKey) === monthKey,
|
|
215
|
+
}
|
|
216
|
+
})
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const monthRows = (cells: CalendarSlotMonthCell[]): CalendarSlotMonthCell[][] =>
|
|
220
|
+
Array.from({ length: Math.ceil(cells.length / 7) }, (_value, index) =>
|
|
221
|
+
cells.slice(index * 7, index * 7 + 7),
|
|
222
|
+
)
|
|
223
|
+
|
|
224
|
+
const isBusinessDay = (
|
|
225
|
+
key: string,
|
|
226
|
+
businessDays: readonly CalendarSlotWeekday[] | undefined,
|
|
227
|
+
): boolean => !businessDays || businessDays.includes(dayOfWeekFromKey(key))
|
|
228
|
+
|
|
229
|
+
const isBusinessDayOfWeek = (
|
|
230
|
+
day: CalendarSlotWeekday,
|
|
231
|
+
businessDays: readonly CalendarSlotWeekday[] | undefined,
|
|
232
|
+
): boolean => !businessDays || businessDays.includes(day)
|
|
233
|
+
|
|
234
|
+
function CalendarSlotArrow({
|
|
235
|
+
direction,
|
|
236
|
+
}: {
|
|
237
|
+
readonly direction: "next" | "previous"
|
|
238
|
+
}) {
|
|
239
|
+
return (
|
|
240
|
+
<svg
|
|
241
|
+
aria-hidden="true"
|
|
242
|
+
className="h-5 w-5 fill-current"
|
|
243
|
+
viewBox="0 0 16 16"
|
|
244
|
+
>
|
|
245
|
+
<path
|
|
246
|
+
d={
|
|
247
|
+
direction === "previous"
|
|
248
|
+
? "M11.5 2 4.5 8l7 6z"
|
|
249
|
+
: "M4.5 2 11.5 8l-7 6z"
|
|
250
|
+
}
|
|
251
|
+
/>
|
|
252
|
+
</svg>
|
|
253
|
+
)
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function CalendarSlotMonthCalendar({
|
|
257
|
+
autoFocus,
|
|
258
|
+
autoFocusDayKey,
|
|
259
|
+
businessDays,
|
|
260
|
+
canGoNext,
|
|
261
|
+
canGoPrevious,
|
|
262
|
+
firstSlotByDay,
|
|
263
|
+
label,
|
|
264
|
+
locale,
|
|
265
|
+
loading,
|
|
266
|
+
onNextMonth,
|
|
267
|
+
onPreviousMonth,
|
|
268
|
+
onSelectDay,
|
|
269
|
+
readOnly,
|
|
270
|
+
selectedSlotDayKey,
|
|
271
|
+
timeZone,
|
|
272
|
+
todayKey,
|
|
273
|
+
visibleMonthKey,
|
|
274
|
+
weekStartsOn,
|
|
275
|
+
}: {
|
|
276
|
+
readonly autoFocus?: boolean | undefined
|
|
277
|
+
readonly autoFocusDayKey?: string | undefined
|
|
278
|
+
readonly businessDays?: readonly CalendarSlotWeekday[] | undefined
|
|
279
|
+
readonly canGoNext: boolean
|
|
280
|
+
readonly canGoPrevious: boolean
|
|
281
|
+
readonly firstSlotByDay: ReadonlyMap<string, CalendarSlotFieldItem>
|
|
282
|
+
readonly label: string
|
|
283
|
+
readonly locale: string
|
|
284
|
+
readonly loading?: boolean | undefined
|
|
285
|
+
readonly onNextMonth?: (() => void) | undefined
|
|
286
|
+
readonly onPreviousMonth?: (() => void) | undefined
|
|
287
|
+
readonly onSelectDay?:
|
|
288
|
+
| ((dayKey: string, slot: CalendarSlotFieldItem) => void)
|
|
289
|
+
| undefined
|
|
290
|
+
readonly readOnly?: boolean | undefined
|
|
291
|
+
readonly selectedSlotDayKey?: string | undefined
|
|
292
|
+
readonly timeZone: string
|
|
293
|
+
readonly todayKey: string
|
|
294
|
+
readonly visibleMonthKey: string
|
|
295
|
+
readonly weekStartsOn: CalendarSlotWeekday
|
|
296
|
+
}) {
|
|
297
|
+
const autoFocusButtonRef = useRef<HTMLButtonElement | null>(null)
|
|
298
|
+
const monthTitle = formatMonthTitle(visibleMonthKey, locale)
|
|
299
|
+
const cells = buildMonthCells(visibleMonthKey, weekStartsOn)
|
|
300
|
+
const labels = weekDayLabels(weekStartsOn, locale)
|
|
301
|
+
|
|
302
|
+
useEffect(() => {
|
|
303
|
+
if (autoFocus !== true) {
|
|
304
|
+
return
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
autoFocusButtonRef.current?.focus()
|
|
308
|
+
}, [autoFocus])
|
|
309
|
+
|
|
310
|
+
return (
|
|
311
|
+
<>
|
|
312
|
+
<style>{`
|
|
313
|
+
[data-calendar-slot-calendar] [data-calendar-slot-day] {
|
|
314
|
+
min-height: var(--calendar-slot-cell-height);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
[data-calendar-slot-calendar] [data-calendar-slot-blank] {
|
|
318
|
+
height: var(--calendar-slot-cell-height);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
[data-calendar-slot-calendar] {
|
|
322
|
+
--calendar-slot-cell-height: 4.75rem;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
@media (max-width: 639px) {
|
|
326
|
+
[data-calendar-slot-calendar] {
|
|
327
|
+
margin-left: calc(-1.5rem - 1px);
|
|
328
|
+
margin-right: calc(-1.5rem - 1px);
|
|
329
|
+
width: calc(100% + 3rem + 2px);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
@media (min-width: 640px) {
|
|
334
|
+
[data-calendar-slot-calendar] {
|
|
335
|
+
--calendar-slot-cell-height: 6rem;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
`}</style>
|
|
339
|
+
<div
|
|
340
|
+
data-calendar-slot-calendar=""
|
|
341
|
+
className={cn(
|
|
342
|
+
"overflow-hidden rounded-lg border bg-background",
|
|
343
|
+
loading && "animate-pulse bg-muted/10",
|
|
344
|
+
)}
|
|
345
|
+
>
|
|
346
|
+
<div className="flex items-center gap-2 px-2 py-3 sm:px-4 sm:py-4">
|
|
347
|
+
<div className="flex h-10 w-10 shrink-0 items-center justify-start">
|
|
348
|
+
{canGoPrevious && onPreviousMonth ? (
|
|
349
|
+
<button
|
|
350
|
+
type="button"
|
|
351
|
+
aria-label="Show previous month"
|
|
352
|
+
className="inline-flex h-10 w-10 items-center justify-center rounded-md hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
353
|
+
onClick={onPreviousMonth}
|
|
354
|
+
>
|
|
355
|
+
<CalendarSlotArrow direction="previous" />
|
|
356
|
+
</button>
|
|
357
|
+
) : null}
|
|
358
|
+
</div>
|
|
359
|
+
|
|
360
|
+
<p
|
|
361
|
+
className="min-w-0 flex-1 whitespace-nowrap text-center text-xl font-medium tracking-[0.2em] text-foreground/90 sm:text-4xl"
|
|
362
|
+
style={{ fontFamily: DAY_NUMBER_FONT_FAMILY }}
|
|
363
|
+
>
|
|
364
|
+
{monthTitle}
|
|
365
|
+
</p>
|
|
366
|
+
|
|
367
|
+
<div className="flex h-10 w-10 shrink-0 items-center justify-end">
|
|
368
|
+
{canGoNext && onNextMonth ? (
|
|
369
|
+
<button
|
|
370
|
+
type="button"
|
|
371
|
+
aria-label="Show next month"
|
|
372
|
+
className="inline-flex h-10 w-10 items-center justify-center rounded-md hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
373
|
+
onClick={onNextMonth}
|
|
374
|
+
>
|
|
375
|
+
<CalendarSlotArrow direction="next" />
|
|
376
|
+
</button>
|
|
377
|
+
) : null}
|
|
378
|
+
</div>
|
|
379
|
+
</div>
|
|
380
|
+
|
|
381
|
+
<table className="w-full table-fixed border-collapse border-t">
|
|
382
|
+
<caption className="sr-only">
|
|
383
|
+
{label} for {monthTitle}
|
|
384
|
+
</caption>
|
|
385
|
+
<thead>
|
|
386
|
+
<tr>
|
|
387
|
+
{labels.map(({ day, label }) => (
|
|
388
|
+
<th
|
|
389
|
+
key={String(day)}
|
|
390
|
+
scope="col"
|
|
391
|
+
className={cn(
|
|
392
|
+
"border px-1 py-2 text-center font-mono text-xs font-medium tracking-[0.18em] text-foreground sm:text-sm",
|
|
393
|
+
!isBusinessDayOfWeek(day, businessDays) &&
|
|
394
|
+
"text-muted-foreground",
|
|
395
|
+
)}
|
|
396
|
+
>
|
|
397
|
+
{label}
|
|
398
|
+
</th>
|
|
399
|
+
))}
|
|
400
|
+
</tr>
|
|
401
|
+
</thead>
|
|
402
|
+
<tbody>
|
|
403
|
+
{monthRows(cells).map((row) => (
|
|
404
|
+
<tr key={row.map((cell) => cell.key).join(":")}>
|
|
405
|
+
{row.map((cell) => {
|
|
406
|
+
if (cell._tag === "blank") {
|
|
407
|
+
return (
|
|
408
|
+
<td
|
|
409
|
+
key={cell.key}
|
|
410
|
+
data-calendar-slot-blank=""
|
|
411
|
+
className="border bg-muted/10 p-0 align-top"
|
|
412
|
+
/>
|
|
413
|
+
)
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
if (loading) {
|
|
417
|
+
return (
|
|
418
|
+
<td key={cell.key} className="border p-0 align-top">
|
|
419
|
+
<div
|
|
420
|
+
data-calendar-slot-day=""
|
|
421
|
+
className="flex w-full flex-col items-start p-2 sm:p-3"
|
|
422
|
+
>
|
|
423
|
+
<div className="h-6 w-8 rounded-md bg-muted sm:h-9 sm:w-10" />
|
|
424
|
+
<div className="mt-3 h-3 w-11 rounded bg-muted sm:mt-4" />
|
|
425
|
+
</div>
|
|
426
|
+
</td>
|
|
427
|
+
)
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
const slot = firstSlotByDay.get(cell.dateKey)
|
|
431
|
+
const available =
|
|
432
|
+
slot !== undefined && cell.dateKey >= todayKey
|
|
433
|
+
const nonBusiness = !isBusinessDay(cell.dateKey, businessDays)
|
|
434
|
+
const selected = selectedSlotDayKey === cell.dateKey
|
|
435
|
+
const contentClassName = cn(
|
|
436
|
+
"flex w-full flex-col items-start p-2 text-left transition-colors sm:p-3",
|
|
437
|
+
!available && "text-muted-foreground",
|
|
438
|
+
available &&
|
|
439
|
+
"cursor-pointer text-foreground hover:bg-primary/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",
|
|
440
|
+
nonBusiness &&
|
|
441
|
+
"bg-muted/40 text-muted-foreground hover:bg-muted/60",
|
|
442
|
+
!cell.inVisibleMonth &&
|
|
443
|
+
!available &&
|
|
444
|
+
"bg-muted/10 text-muted-foreground/35",
|
|
445
|
+
selected &&
|
|
446
|
+
"bg-primary text-primary-foreground shadow-inner hover:bg-primary",
|
|
447
|
+
readOnly &&
|
|
448
|
+
available &&
|
|
449
|
+
"cursor-default hover:bg-transparent",
|
|
450
|
+
readOnly && selected && "hover:bg-primary",
|
|
451
|
+
)
|
|
452
|
+
const dayNumberClassName = cn(
|
|
453
|
+
"text-2xl font-medium leading-none tracking-wide text-foreground/90 sm:text-4xl",
|
|
454
|
+
nonBusiness && !selected && "text-muted-foreground/65",
|
|
455
|
+
selected && "text-primary-foreground",
|
|
456
|
+
)
|
|
457
|
+
const timeClassName = cn(
|
|
458
|
+
"mt-2 text-sm font-medium sm:mt-2.5 sm:text-base",
|
|
459
|
+
!selected && nonBusiness && "text-muted-foreground",
|
|
460
|
+
selected && "text-primary-foreground",
|
|
461
|
+
)
|
|
462
|
+
const unavailableStyle = !available
|
|
463
|
+
? {
|
|
464
|
+
backgroundColor:
|
|
465
|
+
"color-mix(in oklch, var(--muted-foreground) 8%, var(--background))",
|
|
466
|
+
}
|
|
467
|
+
: undefined
|
|
468
|
+
const dayNumberStyle = {
|
|
469
|
+
fontFamily: DAY_NUMBER_FONT_FAMILY,
|
|
470
|
+
...(available || selected
|
|
471
|
+
? {}
|
|
472
|
+
: {
|
|
473
|
+
color:
|
|
474
|
+
"color-mix(in oklch, var(--muted-foreground) 55%, var(--background))",
|
|
475
|
+
}),
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
return (
|
|
479
|
+
<td key={cell.key} className="border p-0 align-top">
|
|
480
|
+
{available && slot ? (
|
|
481
|
+
<button
|
|
482
|
+
type="button"
|
|
483
|
+
aria-label={`${formatDateHeading(
|
|
484
|
+
cell.dateKey,
|
|
485
|
+
locale,
|
|
486
|
+
)}, ${formatStartTime(slot, timeZone, locale)}`}
|
|
487
|
+
aria-pressed={selected}
|
|
488
|
+
data-calendar-slot-day=""
|
|
489
|
+
className={contentClassName}
|
|
490
|
+
disabled={readOnly === true}
|
|
491
|
+
onClick={() => onSelectDay?.(cell.dateKey, slot)}
|
|
492
|
+
ref={
|
|
493
|
+
autoFocus === true &&
|
|
494
|
+
cell.dateKey === autoFocusDayKey
|
|
495
|
+
? autoFocusButtonRef
|
|
496
|
+
: undefined
|
|
497
|
+
}
|
|
498
|
+
>
|
|
499
|
+
<span
|
|
500
|
+
className={dayNumberClassName}
|
|
501
|
+
style={dayNumberStyle}
|
|
502
|
+
>
|
|
503
|
+
{cell.day}
|
|
504
|
+
</span>
|
|
505
|
+
<span className={timeClassName}>
|
|
506
|
+
{formatStartTime(slot, timeZone, locale)}
|
|
507
|
+
</span>
|
|
508
|
+
</button>
|
|
509
|
+
) : (
|
|
510
|
+
<div
|
|
511
|
+
data-calendar-slot-day=""
|
|
512
|
+
className={contentClassName}
|
|
513
|
+
style={unavailableStyle}
|
|
514
|
+
>
|
|
515
|
+
<span
|
|
516
|
+
className={dayNumberClassName}
|
|
517
|
+
style={dayNumberStyle}
|
|
518
|
+
>
|
|
519
|
+
{cell.day}
|
|
520
|
+
</span>
|
|
521
|
+
</div>
|
|
522
|
+
)}
|
|
523
|
+
</td>
|
|
524
|
+
)
|
|
525
|
+
})}
|
|
526
|
+
</tr>
|
|
527
|
+
))}
|
|
528
|
+
</tbody>
|
|
529
|
+
</table>
|
|
530
|
+
</div>
|
|
531
|
+
</>
|
|
532
|
+
)
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
const CalendarSlotSkeletonCalendar = ({
|
|
536
|
+
calendar,
|
|
537
|
+
locale,
|
|
538
|
+
timeZone,
|
|
539
|
+
}: {
|
|
540
|
+
readonly calendar?: CalendarSlotCalendarMetadata | undefined
|
|
541
|
+
readonly locale: string
|
|
542
|
+
readonly timeZone: string
|
|
543
|
+
}) => {
|
|
544
|
+
const todayKey = dateKeyFromDate(new Date(), timeZone)
|
|
545
|
+
const visibleMonthKey = monthKeyFromDateKey(todayKey)
|
|
546
|
+
|
|
547
|
+
return (
|
|
548
|
+
<div aria-busy="true" aria-live="polite" className="space-y-3">
|
|
549
|
+
<CalendarSlotMonthCalendar
|
|
550
|
+
canGoNext={false}
|
|
551
|
+
canGoPrevious={false}
|
|
552
|
+
firstSlotByDay={new Map<string, CalendarSlotFieldItem>()}
|
|
553
|
+
label="Available times"
|
|
554
|
+
locale={locale}
|
|
555
|
+
loading
|
|
556
|
+
timeZone={timeZone}
|
|
557
|
+
todayKey={todayKey}
|
|
558
|
+
visibleMonthKey={visibleMonthKey}
|
|
559
|
+
weekStartsOn={calendar?.weekStartsOn ?? 0}
|
|
560
|
+
/>
|
|
561
|
+
<p className="text-sm text-muted-foreground">
|
|
562
|
+
Loading available times...
|
|
563
|
+
</p>
|
|
564
|
+
</div>
|
|
565
|
+
)
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
const useStringFieldState = () => {
|
|
569
|
+
const field = useFieldContext<string>()
|
|
570
|
+
const form = useFormContext()
|
|
571
|
+
const validationErrors = field.state.meta
|
|
572
|
+
.errors as unknown as StandardSchemaV1Issue[]
|
|
573
|
+
const serverError = field.state.meta.errorMap?.onSubmit
|
|
574
|
+
const allErrors: Array<{ message?: string }> = [
|
|
575
|
+
...validationErrors,
|
|
576
|
+
...(serverError ? [{ message: serverError as string }] : []),
|
|
577
|
+
]
|
|
578
|
+
const { isTouched, isDefaultValue } = field.state.meta
|
|
579
|
+
const afterSubmission = form.state.submissionAttempts > 0
|
|
580
|
+
const isInvalid =
|
|
581
|
+
(afterSubmission && allErrors.length > 0) ||
|
|
582
|
+
(isTouched && !isDefaultValue && allErrors.length > 0)
|
|
583
|
+
|
|
584
|
+
return {
|
|
585
|
+
field,
|
|
586
|
+
isInvalid,
|
|
587
|
+
allErrors,
|
|
588
|
+
errorId: `${field.name}-error`,
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
export function CalendarSlotField({
|
|
593
|
+
label,
|
|
594
|
+
descriptionHtml,
|
|
595
|
+
emptyMessageHtml,
|
|
596
|
+
loadErrorMessageHtml,
|
|
597
|
+
slots,
|
|
598
|
+
loading,
|
|
599
|
+
error,
|
|
600
|
+
readOnly,
|
|
601
|
+
autoFocus,
|
|
602
|
+
timeZone,
|
|
603
|
+
locale,
|
|
604
|
+
calendar,
|
|
605
|
+
onRetry,
|
|
606
|
+
}: CalendarSlotFieldProps) {
|
|
607
|
+
const { field, isInvalid, allErrors, errorId } = useStringFieldState()
|
|
608
|
+
// Slot lists are collapsed to one selectable time per day; the first
|
|
609
|
+
// chronological slot for that date is presented.
|
|
610
|
+
// This value intentionally updates on remount rather than ticking at midnight;
|
|
611
|
+
// the server remains responsible for filtering out stale slot data.
|
|
612
|
+
const todayKey = useMemo(
|
|
613
|
+
() => dateKeyFromDate(new Date(), timeZone),
|
|
614
|
+
[timeZone],
|
|
615
|
+
)
|
|
616
|
+
const [visibleMonthKey, setVisibleMonthKey] = useState<string>(() =>
|
|
617
|
+
monthKeyFromDateKey(todayKey),
|
|
618
|
+
)
|
|
619
|
+
const initializedMonthRef = useRef(false)
|
|
620
|
+
|
|
621
|
+
const { firstSlotByDay, sortedSlots } = useMemo(() => {
|
|
622
|
+
const sorted = [...slots].sort(
|
|
623
|
+
(left, right) =>
|
|
624
|
+
new Date(left.startsAt).getTime() - new Date(right.startsAt).getTime(),
|
|
625
|
+
)
|
|
626
|
+
const firstByDay = new Map<string, CalendarSlotFieldItem>()
|
|
627
|
+
for (const slot of sorted) {
|
|
628
|
+
const key = dateKeyFromDate(new Date(slot.startsAt), timeZone)
|
|
629
|
+
if (key < todayKey || firstByDay.has(key)) {
|
|
630
|
+
continue
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
firstByDay.set(key, slot)
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
return { firstSlotByDay: firstByDay, sortedSlots: sorted }
|
|
637
|
+
}, [slots, timeZone, todayKey])
|
|
638
|
+
|
|
639
|
+
const availableDayKeys = useMemo(
|
|
640
|
+
() => [...firstSlotByDay.keys()].sort(),
|
|
641
|
+
[firstSlotByDay],
|
|
642
|
+
)
|
|
643
|
+
const firstAvailableDayKey = availableDayKeys[0]
|
|
644
|
+
const lastAvailableDayKey = availableDayKeys.at(-1)
|
|
645
|
+
const selectedSlot = sortedSlots.find(
|
|
646
|
+
(slot) => slot.value === field.state.value,
|
|
647
|
+
)
|
|
648
|
+
const selectedSlotDayKey = selectedSlot
|
|
649
|
+
? dateKeyFromDate(new Date(selectedSlot.startsAt), timeZone)
|
|
650
|
+
: undefined
|
|
651
|
+
const startMonthKey = firstAvailableDayKey
|
|
652
|
+
? monthKeyFromDateKey(firstAvailableDayKey)
|
|
653
|
+
: monthKeyFromDateKey(todayKey)
|
|
654
|
+
const endMonthKey = lastAvailableDayKey
|
|
655
|
+
? monthKeyFromDateKey(lastAvailableDayKey)
|
|
656
|
+
: startMonthKey
|
|
657
|
+
const autoFocusDayKey = selectedSlotDayKey ?? firstAvailableDayKey
|
|
658
|
+
|
|
659
|
+
useEffect(() => {
|
|
660
|
+
const currentValue = field.state.value
|
|
661
|
+
if (
|
|
662
|
+
readOnly ||
|
|
663
|
+
field.state.meta.isTouched ||
|
|
664
|
+
!currentValue ||
|
|
665
|
+
sortedSlots.length === 0
|
|
666
|
+
) {
|
|
667
|
+
return
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
const currentSlot = sortedSlots.find((slot) => slot.value === currentValue)
|
|
671
|
+
if (!currentSlot) {
|
|
672
|
+
field.handleChange("")
|
|
673
|
+
return
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
const currentDayKey = dateKeyFromDate(
|
|
677
|
+
new Date(currentSlot.startsAt),
|
|
678
|
+
timeZone,
|
|
679
|
+
)
|
|
680
|
+
const visibleSlot = firstSlotByDay.get(currentDayKey)
|
|
681
|
+
// currentSlot can exist in sortedSlots but be hidden because its day is now
|
|
682
|
+
// in the past and therefore excluded from firstSlotByDay.
|
|
683
|
+
if (!visibleSlot) {
|
|
684
|
+
field.handleChange("")
|
|
685
|
+
return
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
if (visibleSlot.value !== currentValue) {
|
|
689
|
+
field.handleChange(visibleSlot.value)
|
|
690
|
+
}
|
|
691
|
+
}, [
|
|
692
|
+
field,
|
|
693
|
+
field.state.meta.isTouched,
|
|
694
|
+
field.state.value,
|
|
695
|
+
firstSlotByDay,
|
|
696
|
+
readOnly,
|
|
697
|
+
sortedSlots,
|
|
698
|
+
timeZone,
|
|
699
|
+
])
|
|
700
|
+
|
|
701
|
+
useEffect(() => {
|
|
702
|
+
const initialDayKey = selectedSlotDayKey ?? firstAvailableDayKey
|
|
703
|
+
if (!initialDayKey) {
|
|
704
|
+
return
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
const initialMonthKey = monthKeyFromDateKey(initialDayKey)
|
|
708
|
+
const visibleMonthIsOutsideSlotRange =
|
|
709
|
+
compareMonthKeys(visibleMonthKey, startMonthKey) < 0 ||
|
|
710
|
+
compareMonthKeys(visibleMonthKey, endMonthKey) > 0
|
|
711
|
+
|
|
712
|
+
if (!initializedMonthRef.current || visibleMonthIsOutsideSlotRange) {
|
|
713
|
+
setVisibleMonthKey(initialMonthKey)
|
|
714
|
+
initializedMonthRef.current = true
|
|
715
|
+
}
|
|
716
|
+
}, [
|
|
717
|
+
endMonthKey,
|
|
718
|
+
firstAvailableDayKey,
|
|
719
|
+
selectedSlotDayKey,
|
|
720
|
+
startMonthKey,
|
|
721
|
+
visibleMonthKey,
|
|
722
|
+
])
|
|
723
|
+
|
|
724
|
+
const canGoPrevious = compareMonthKeys(visibleMonthKey, startMonthKey) > 0
|
|
725
|
+
const canGoNext = compareMonthKeys(visibleMonthKey, endMonthKey) < 0
|
|
726
|
+
|
|
727
|
+
return (
|
|
728
|
+
<Field>
|
|
729
|
+
<FieldLabel>{label}</FieldLabel>
|
|
730
|
+
{loading ? (
|
|
731
|
+
<CalendarSlotSkeletonCalendar
|
|
732
|
+
calendar={calendar}
|
|
733
|
+
locale={locale}
|
|
734
|
+
timeZone={timeZone}
|
|
735
|
+
/>
|
|
736
|
+
) : error ? (
|
|
737
|
+
<div className="rounded-lg border border-destructive/30 bg-destructive/10 p-4 text-sm text-destructive">
|
|
738
|
+
<div className="space-y-3">
|
|
739
|
+
<FieldDescription
|
|
740
|
+
className="text-destructive"
|
|
741
|
+
trustedHtml={
|
|
742
|
+
loadErrorMessageHtml ??
|
|
743
|
+
"Available times could not be loaded. Please try again."
|
|
744
|
+
}
|
|
745
|
+
/>
|
|
746
|
+
{onRetry ? (
|
|
747
|
+
<button
|
|
748
|
+
type="button"
|
|
749
|
+
className="rounded-md border border-destructive/40 bg-background px-3 py-2 text-sm font-medium text-destructive transition hover:bg-destructive/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
750
|
+
onClick={onRetry}
|
|
751
|
+
>
|
|
752
|
+
Try again
|
|
753
|
+
</button>
|
|
754
|
+
) : null}
|
|
755
|
+
</div>
|
|
756
|
+
</div>
|
|
757
|
+
) : sortedSlots.length === 0 ? (
|
|
758
|
+
<div className="rounded-lg border bg-muted/30 p-4 text-sm text-muted-foreground">
|
|
759
|
+
<FieldDescription
|
|
760
|
+
trustedHtml={emptyMessageHtml ?? "No available times."}
|
|
761
|
+
/>
|
|
762
|
+
</div>
|
|
763
|
+
) : (
|
|
764
|
+
<div
|
|
765
|
+
aria-describedby={isInvalid ? errorId : undefined}
|
|
766
|
+
aria-invalid={isInvalid}
|
|
767
|
+
className="space-y-4"
|
|
768
|
+
>
|
|
769
|
+
<CalendarSlotMonthCalendar
|
|
770
|
+
autoFocus={autoFocus}
|
|
771
|
+
autoFocusDayKey={autoFocusDayKey}
|
|
772
|
+
businessDays={calendar?.businessDays}
|
|
773
|
+
canGoNext={canGoNext}
|
|
774
|
+
canGoPrevious={canGoPrevious}
|
|
775
|
+
firstSlotByDay={firstSlotByDay}
|
|
776
|
+
label={label}
|
|
777
|
+
locale={locale}
|
|
778
|
+
onNextMonth={() =>
|
|
779
|
+
setVisibleMonthKey(addMonthsToMonthKey(visibleMonthKey, 1))
|
|
780
|
+
}
|
|
781
|
+
onPreviousMonth={() =>
|
|
782
|
+
setVisibleMonthKey(addMonthsToMonthKey(visibleMonthKey, -1))
|
|
783
|
+
}
|
|
784
|
+
onSelectDay={(dayKey, slot) => {
|
|
785
|
+
if (readOnly) {
|
|
786
|
+
return
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
field.handleChange(slot.value)
|
|
790
|
+
field.handleBlur()
|
|
791
|
+
setVisibleMonthKey(monthKeyFromDateKey(dayKey))
|
|
792
|
+
}}
|
|
793
|
+
readOnly={readOnly}
|
|
794
|
+
selectedSlotDayKey={selectedSlotDayKey}
|
|
795
|
+
timeZone={timeZone}
|
|
796
|
+
todayKey={todayKey}
|
|
797
|
+
visibleMonthKey={visibleMonthKey}
|
|
798
|
+
weekStartsOn={calendar?.weekStartsOn ?? 0}
|
|
799
|
+
/>
|
|
800
|
+
</div>
|
|
801
|
+
)}
|
|
802
|
+
{isInvalid && allErrors.length > 0 && (
|
|
803
|
+
<FieldError errors={allErrors} id={errorId} />
|
|
804
|
+
)}
|
|
805
|
+
{descriptionHtml && <FieldDescription trustedHtml={descriptionHtml} />}
|
|
806
|
+
</Field>
|
|
807
|
+
)
|
|
808
|
+
}
|