@processfocus/runtime-local 0.1.0-next.2 → 0.1.0-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -253
- package/dist/authentication-server.mjs +52 -84
- package/dist/{chunk-yhzbn4vx.js → chunk-04r0t2mb.js} +34324 -49067
- package/dist/chunk-727y6qkb.js +156 -0
- package/dist/chunk-bg5r4wpv.js +4755 -0
- package/dist/chunk-cbd36jq1.js +512 -0
- package/dist/chunk-d4ctj079.js +241 -0
- package/dist/{chunk-352j1ayk.js → chunk-r5s2v669.js} +51753 -36263
- package/dist/dashboard-source/apps/frontend/app/(protected)/act-on-behalf/actions.ts +12 -12
- package/dist/dashboard-source/apps/frontend/app/(protected)/act-on-behalf/delegations-client.tsx +31 -21
- package/dist/dashboard-source/apps/frontend/app/(protected)/act-on-behalf/page.tsx +3 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/client-index.tsx +1 -12
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/(.)[executionId]/client.tsx +1 -1
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/(.)[executionId]/page.tsx +2 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/@modal/(.)[executionId]/process-state/page.tsx +2 -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 +3 -1
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/[executionId]/process-state/page.tsx +2 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/client-layout.tsx +19 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/default.tsx +6 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/executions-client.tsx +1637 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/layout.tsx +5 -7
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/page.tsx +4 -1589
- package/dist/dashboard-source/apps/frontend/app/(protected)/executions/process-state-page-client.tsx +1 -1
- package/dist/dashboard-source/apps/frontend/app/(protected)/layout.tsx +41 -33
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/@modal/(.)item/[id]/client.tsx +11 -17
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/@modal/(.)item/[id]/page.tsx +2 -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 +145 -19
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/[...listPath]/page.tsx +10 -2
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-create-form.tsx +29 -13
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-item-edit-form.tsx +22 -28
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-item-load-error.tsx +49 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/components/list-schema-form.tsx +28 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/default.tsx +6 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/hooks/metric-control-url-state.ts +7 -16
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/hooks/use-list-deleted-callback.ts +4 -6
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/hooks/use-list-item-detail.ts +45 -142
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/item/[id]/client.tsx +10 -20
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/item/[id]/page.tsx +2 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/layout.tsx +3 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/lib/list-process-dialog.tsx +72 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/lib/list-refresh-provider.tsx +65 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/lib/list-refresh.ts +162 -16
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/utils.tsx +19 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/org-chart/page.tsx +4 -9
- package/dist/dashboard-source/apps/frontend/app/(protected)/page.tsx +4 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/passkeys/actions.ts +15 -18
- package/dist/dashboard-source/apps/frontend/app/(protected)/passkeys/page.tsx +12 -6
- package/dist/dashboard-source/apps/frontend/app/(protected)/passkeys/passkeys-client.tsx +7 -16
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/@modal/(.)start/[...startStepPath]/client.tsx +26 -48
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/@modal/(.)start/[...startStepPath]/page.tsx +4 -7
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/@modal/default.tsx +3 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/client-layout.tsx +28 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/client.tsx +1 -3
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/components/start-process-form.tsx +193 -117
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/default.tsx +6 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/layout.tsx +7 -9
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/page.tsx +3 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/processes-client.tsx +60 -204
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/start/[...startStepPath]/client.tsx +12 -51
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/start/[...startStepPath]/page.tsx +27 -4
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/page.tsx +5 -4
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/workflow-flow.tsx +0 -5
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/workflow/[...processPath]/workflow-form-preview-sheet.tsx +26 -19
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/[[...tab]]/page.tsx +5 -2
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/cedar-authorize.ts +85 -9
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/cedar-types.ts +12 -1
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/explorer.tsx +66 -4
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/layout.tsx +3 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/cedar/load-handbook.ts +41 -13
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/[invitationId]/page.tsx +2 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/invitation-detail-client.tsx +442 -365
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/new/page.tsx +8 -2
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations/page.tsx +7 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/invitations-table.tsx +61 -43
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/page.tsx +6 -67
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/providers/page.tsx +7 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/roles/page.tsx +7 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/settings-client.tsx +111 -189
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/settings-page.tsx +86 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/[userId]/client.tsx +141 -256
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/[userId]/page.tsx +2 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/[userId]/tokens/page.tsx +2 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users/page.tsx +7 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/settings/users-table.tsx +6 -4
- package/dist/dashboard-source/apps/frontend/app/(protected)/stats/[...statsPath]/page.tsx +3 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/@modal/(.)complete/[...stepPath]/client.tsx +30 -9
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/@modal/(.)complete/[...stepPath]/page.tsx +3 -1
- 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 +2 -4
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/complete/[...stepPath]/page.tsx +3 -1
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/components/complete-todo-form.tsx +47 -54
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/components/public-completion-correction-form.tsx +37 -54
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/components/todo-form-actions.tsx +1 -1
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/correct/[...stepPath]/page.tsx +3 -1
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/default.tsx +6 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/layout.tsx +3 -0
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/lib/mobile-todo-list.ts +4 -25
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/page.tsx +4 -1315
- package/dist/dashboard-source/apps/frontend/app/(protected)/to-dos/to-dos-client.tsx +1282 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/callback/route.ts +81 -65
- package/dist/dashboard-source/apps/frontend/app/api/auth/delegation/route.ts +8 -2
- package/dist/dashboard-source/apps/frontend/app/api/auth/login/route.ts +0 -1
- package/dist/dashboard-source/apps/frontend/app/api/auth/logout/route.ts +10 -5
- package/dist/dashboard-source/apps/frontend/app/api/auth/passkey/start/route.ts +1 -3
- package/dist/dashboard-source/apps/frontend/app/api/auth/refresh/route.ts +0 -1
- package/dist/dashboard-source/apps/frontend/app/api/auth/revalidate-google/route.ts +68 -0
- package/dist/dashboard-source/apps/frontend/app/api/auth/switch-role/route.ts +1 -3
- package/dist/dashboard-source/apps/frontend/app/api/embed/lookup/route.ts +25 -7
- package/dist/dashboard-source/apps/frontend/app/api/embed/submit/route.ts +1 -2
- package/dist/dashboard-source/apps/frontend/app/api/public/start/[address]/route.ts +49 -0
- package/dist/dashboard-source/apps/frontend/app/api/public/to-dos/lookup/route.ts +4 -3
- package/dist/dashboard-source/apps/frontend/app/api/revalidate/route.ts +15 -4
- package/dist/dashboard-source/apps/frontend/app/app-shell.tsx +11 -4
- package/dist/dashboard-source/apps/frontend/app/cli-auth/route.ts +2 -1
- package/dist/dashboard-source/apps/frontend/app/embed/[...startStepPath]/embed-client.tsx +31 -18
- package/dist/dashboard-source/apps/frontend/app/embed/[...startStepPath]/page.tsx +5 -1
- package/dist/dashboard-source/apps/frontend/app/login/page.tsx +4 -4
- package/dist/dashboard-source/apps/frontend/app/login/passkey-button.tsx +11 -6
- package/dist/dashboard-source/apps/frontend/app/login/passkey-help/page.tsx +67 -0
- package/dist/dashboard-source/apps/frontend/app/mcp/[[...endpoint]]/route.ts +47 -0
- package/dist/dashboard-source/apps/frontend/app/public/form/[token]/public-todo-client.tsx +44 -25
- package/dist/dashboard-source/apps/frontend/app/public/start/[address]/form/page.tsx +10 -0
- package/dist/dashboard-source/apps/frontend/app/public/start/[address]/layout.tsx +32 -0
- package/dist/dashboard-source/apps/frontend/app/public/start/[address]/page-client.tsx +319 -0
- package/dist/dashboard-source/apps/frontend/app/public/start/[address]/page-content.tsx +41 -0
- package/dist/dashboard-source/apps/frontend/app/public/start/[address]/page.tsx +10 -0
- package/dist/dashboard-source/apps/frontend/app/public.css +1 -1
- package/dist/dashboard-source/apps/frontend/app/register/passkey/register-passkey-client.tsx +17 -0
- package/dist/dashboard-source/apps/frontend/components/DashboardSection.tsx +9 -15
- package/dist/dashboard-source/apps/frontend/components/Header.tsx +4 -8
- package/dist/dashboard-source/apps/frontend/components/anonymous-page-link.tsx +57 -0
- package/dist/dashboard-source/apps/frontend/components/anonymous-start-form.tsx +24 -0
- package/dist/dashboard-source/apps/frontend/components/app-sidebar.tsx +21 -7
- package/dist/dashboard-source/apps/frontend/components/auth-provider.tsx +12 -7
- package/dist/dashboard-source/apps/frontend/components/browser-only.tsx +19 -0
- package/dist/dashboard-source/apps/frontend/components/config-provider.tsx +0 -1
- package/dist/dashboard-source/apps/frontend/components/delegation-expiry.tsx +24 -13
- package/dist/dashboard-source/apps/frontend/components/form-dialog-content.tsx +22 -2
- package/dist/dashboard-source/apps/frontend/components/journey-timeline.tsx +52 -45
- package/dist/dashboard-source/apps/frontend/components/notification-bell.tsx +0 -1
- package/dist/dashboard-source/apps/frontend/components/sidebar-lists.tsx +0 -1
- package/dist/dashboard-source/apps/frontend/components/token-refresh-scheduler.tsx +38 -11
- package/dist/dashboard-source/apps/frontend/components/ui/sidebar.tsx +0 -1
- package/dist/dashboard-source/apps/frontend/components/ui/tab-pill.tsx +26 -15
- package/dist/dashboard-source/apps/frontend/components/workflow/step-node.tsx +0 -1
- package/dist/dashboard-source/apps/frontend/components/workflow/workflow-edge.tsx +5 -0
- package/dist/dashboard-source/apps/frontend/hooks/use-form-metadata.ts +21 -10
- package/dist/dashboard-source/apps/frontend/hooks/use-process-draft.ts +173 -0
- package/dist/dashboard-source/apps/frontend/hooks/use-weekly-execution-stats.ts +1 -3
- package/dist/dashboard-source/apps/frontend/lib/anonymous-page-form-values.ts +6 -0
- package/dist/dashboard-source/apps/frontend/lib/anonymous-page-server.ts +65 -0
- package/dist/dashboard-source/apps/frontend/lib/appsync-events/adapter.ts +9 -3
- package/dist/dashboard-source/apps/frontend/lib/appsync-events/client.ts +7 -340
- package/dist/dashboard-source/apps/frontend/lib/auth/client-session.ts +2 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/delegations.ts +9 -7
- package/dist/dashboard-source/apps/frontend/lib/auth/google-revalidation.ts +111 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/logout.ts +1 -1
- package/dist/dashboard-source/apps/frontend/lib/auth/passkeys.ts +28 -30
- package/dist/dashboard-source/apps/frontend/lib/auth/providers.ts +10 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/realtime-session-token.ts +1 -0
- package/dist/dashboard-source/apps/frontend/lib/auth/reauthentication-state.ts +4 -4
- package/dist/dashboard-source/apps/frontend/lib/auth/session-admission.ts +11 -7
- package/dist/dashboard-source/apps/frontend/lib/auth/session.ts +27 -10
- package/dist/dashboard-source/apps/frontend/lib/auth/ssr-session.ts +76 -9
- package/dist/dashboard-source/apps/frontend/lib/auth/verify-passkey.ts +25 -3
- package/dist/dashboard-source/apps/frontend/lib/collections/collection-provider-factory.tsx +112 -21
- package/dist/dashboard-source/apps/frontend/lib/collections/draft-process-execution.ts +1 -8
- package/dist/dashboard-source/apps/frontend/lib/collections/execution.ts +6 -2
- package/dist/dashboard-source/apps/frontend/lib/collections/process-collection-provider.tsx +3 -0
- package/dist/dashboard-source/apps/frontend/lib/collections/process.ts +8 -2
- package/dist/dashboard-source/apps/frontend/lib/collections/replication-factory.ts +16 -4
- package/dist/dashboard-source/apps/frontend/lib/collections/todo.ts +1 -1
- package/dist/dashboard-source/apps/frontend/lib/effect/navigation.ts +4 -0
- package/dist/dashboard-source/apps/frontend/lib/effect/page-runtime.ts +29 -0
- package/dist/dashboard-source/apps/frontend/lib/effect/params.ts +18 -12
- package/dist/dashboard-source/apps/frontend/lib/effect/run-effect.ts +1 -1
- package/dist/dashboard-source/apps/frontend/lib/effect/runtime.ts +19 -23
- package/dist/dashboard-source/apps/frontend/lib/effect/services/access-token.ts +9 -12
- package/dist/dashboard-source/apps/frontend/lib/effect/services/authorization.ts +12 -12
- package/dist/dashboard-source/apps/frontend/lib/effect/services/form-validation.ts +20 -18
- package/dist/dashboard-source/apps/frontend/lib/effect/services/graphql.ts +32 -16
- package/dist/dashboard-source/apps/frontend/lib/embed-form-server.ts +35 -0
- package/dist/dashboard-source/apps/frontend/lib/embed-manifest.ts +10 -103
- package/dist/dashboard-source/apps/frontend/lib/forms/invitation.ts +43 -0
- package/dist/dashboard-source/apps/frontend/lib/forms/provider-user.ts +64 -0
- package/dist/dashboard-source/apps/frontend/lib/frontend-form-loaders.ts +40 -0
- package/dist/dashboard-source/apps/frontend/lib/frontend-manifest.ts +1 -33
- package/dist/dashboard-source/apps/frontend/lib/generated/gql/gql.ts +123 -33
- package/dist/dashboard-source/apps/frontend/lib/generated/gql/graphql.ts +169 -30
- package/dist/dashboard-source/apps/frontend/lib/generated/gql/index.ts +1 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/anonymous-page.ts +27 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/dependent-lookup-query.ts +1 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/list-queries.ts +34 -29
- package/dist/dashboard-source/apps/frontend/lib/graphql/lookup-provider.tsx +82 -10
- package/dist/dashboard-source/apps/frontend/lib/graphql/org-chart-operations.ts +2 -5
- package/dist/dashboard-source/apps/frontend/lib/graphql/queries.ts +25 -4
- package/dist/dashboard-source/apps/frontend/lib/graphql/server-client.ts +11 -0
- package/dist/dashboard-source/apps/frontend/lib/graphql/settings-queries.ts +13 -104
- package/dist/dashboard-source/apps/frontend/lib/graphql/user-queries.ts +11 -4
- package/dist/dashboard-source/apps/frontend/lib/graphql/workflow-operations.ts +1 -3
- package/dist/dashboard-source/apps/frontend/lib/graphql/workflow-queries.ts +1 -0
- package/dist/dashboard-source/apps/frontend/lib/list-detail-selection.ts +54 -0
- package/dist/dashboard-source/apps/frontend/lib/mcp/executions.ts +110 -0
- package/dist/dashboard-source/apps/frontend/lib/mcp/list-writes.ts +395 -0
- package/dist/dashboard-source/apps/frontend/lib/mcp/lists.ts +263 -0
- package/dist/dashboard-source/apps/frontend/lib/mcp/oauth.ts +900 -0
- package/dist/dashboard-source/apps/frontend/lib/mcp/origin.ts +42 -0
- package/dist/dashboard-source/apps/frontend/lib/mcp/processes.ts +436 -0
- package/dist/dashboard-source/apps/frontend/lib/mcp/read-tool.ts +72 -0
- package/dist/dashboard-source/apps/frontend/lib/mcp/result.ts +4 -0
- package/dist/dashboard-source/apps/frontend/lib/mcp/server.ts +71 -0
- package/dist/dashboard-source/apps/frontend/lib/mcp/store.ts +193 -0
- package/dist/dashboard-source/apps/frontend/lib/mcp/todos.ts +237 -0
- package/dist/dashboard-source/apps/frontend/lib/notifications/notification-preference.ts +0 -1
- package/dist/dashboard-source/apps/frontend/lib/notifications/todo-notification-observer.ts +0 -5
- package/dist/dashboard-source/apps/frontend/lib/org-chart-data.ts +0 -2
- package/dist/dashboard-source/apps/frontend/lib/org-identity.ts +6 -4
- package/dist/dashboard-source/apps/frontend/lib/organisation-form-loaders.ts +4 -0
- package/dist/dashboard-source/apps/frontend/lib/public-todo-form-runtime.ts +0 -1
- package/dist/dashboard-source/apps/frontend/lib/public-todo-model.ts +39 -139
- package/dist/dashboard-source/apps/frontend/lib/public-todo-server.ts +17 -16
- package/dist/dashboard-source/apps/frontend/lib/query-client.ts +0 -1
- package/dist/dashboard-source/apps/frontend/lib/todo-utils.ts +1 -77
- package/dist/dashboard-source/apps/frontend/lib/workflow/layout.ts +3 -7
- package/dist/dashboard-source/apps/frontend/next.config.ts +33 -13
- package/dist/dashboard-source/apps/frontend/package.json +48 -47
- package/dist/dashboard-source/apps/frontend/proxy.ts +72 -14
- package/dist/dashboard-source/modules/auth-local-cedar/src/index.ts +0 -3
- package/dist/dashboard-source/modules/auth-local-cedar/src/lib/auth-local-cedar.ts +165 -233
- package/dist/dashboard-source/modules/auth-local-cedar/src/lib/cedar-reload-notifier.ts +4 -3
- package/dist/dashboard-source/modules/auth-local-cedar/src/lib/config-base.ts +111 -75
- package/dist/dashboard-source/modules/auth-local-cedar/src/lib/policy-watcher.ts +14 -18
- package/dist/dashboard-source/modules/auth-policy/src/index.ts +1 -0
- package/dist/dashboard-source/modules/auth-policy/src/lib/auth-policy.ts +19 -37
- package/dist/dashboard-source/modules/auth-policy/src/lib/current-principal.ts +33 -29
- package/dist/dashboard-source/modules/auth-policy/src/lib/policy-revision.ts +23 -0
- package/dist/dashboard-source/modules/auth-policy/src/lib/types.ts +24 -49
- package/dist/dashboard-source/modules/auth-session/src/index.ts +4 -0
- package/dist/dashboard-source/modules/auth-session/src/lib/project-subscription.ts +13 -0
- package/dist/dashboard-source/modules/auth-session/src/lib/realtime-recipient.ts +10 -2
- package/dist/dashboard-source/modules/auth-session/src/lib/subjects.ts +82 -8
- package/dist/dashboard-source/modules/auth-session/src/lib/workload-access.ts +48 -0
- package/dist/dashboard-source/modules/auth-session/src/lib/workload-audit.ts +52 -0
- package/dist/dashboard-source/modules/aws-common/src/index.ts +0 -1
- package/dist/dashboard-source/modules/effect-json-logger/src/lib/effect-json-logger.ts +6 -9
- package/dist/dashboard-source/modules/form/src/hooks/use-local-storage.ts +5 -3
- package/dist/dashboard-source/modules/form/src/index.ts +1 -10
- package/dist/dashboard-source/modules/form/src/lib/effect-schema-form.tsx +1271 -0
- package/dist/dashboard-source/modules/form/src/lib/form-actions.ts +26 -0
- package/dist/dashboard-source/modules/form/src/lib/form-prefill.tsx +79 -0
- package/dist/dashboard-source/modules/form/src/lib/initial-focus.ts +31 -0
- package/dist/dashboard-source/modules/form/src/lib/lookup-context.tsx +18 -0
- package/dist/dashboard-source/modules/form/src/lib/plugin-registry.ts +4 -0
- package/dist/dashboard-source/modules/form/src/lib/plugin-scripts.ts +26 -0
- package/dist/dashboard-source/modules/form/src/lib/registered-plugin-field.tsx +57 -0
- package/dist/dashboard-source/modules/form/src/lib/schema-lookup.tsx +124 -0
- package/dist/dashboard-source/modules/form/src/lib/schema-typeahead.tsx +522 -0
- package/dist/dashboard-source/modules/form/src/lib/validation-logic.ts +172 -0
- package/dist/dashboard-source/modules/form-schema/src/index.ts +4 -1
- package/dist/dashboard-source/modules/form-schema/src/lib/annotation-helpers.ts +19 -14
- package/dist/dashboard-source/modules/form-schema/src/lib/email.ts +13 -11
- package/dist/dashboard-source/modules/form-schema/src/lib/field-count.ts +15 -13
- package/dist/dashboard-source/modules/form-schema/src/lib/form-annotations.ts +14 -0
- package/dist/dashboard-source/modules/form-schema/src/lib/form-presentation.ts +33 -0
- package/dist/dashboard-source/modules/form-schema/src/lib/form-schema.ts +186 -80
- package/dist/dashboard-source/modules/form-schema/src/lib/number-from-string.ts +26 -0
- package/dist/dashboard-source/modules/form-schema/src/lib/phone.ts +8 -7
- package/dist/dashboard-source/modules/form-schema/src/lib/public-completion-correction.ts +7 -0
- package/dist/dashboard-source/modules/form-schema/src/lib/search-lookup-items.ts +27 -0
- package/dist/dashboard-source/modules/form-submission-schema/src/index.ts +5 -0
- package/dist/dashboard-source/modules/form-submission-schema/src/lib/executable-rules.ts +379 -0
- package/dist/dashboard-source/modules/form-submission-schema/src/lib/form-submission-schema.ts +475 -0
- package/dist/dashboard-source/modules/form-submission-schema/src/lib/json-schema.ts +58 -0
- package/dist/dashboard-source/modules/form-submission-schema/src/lib/schema-defaults.ts +158 -0
- package/dist/dashboard-source/modules/form-submission-schema/src/lib/submission-utils.ts +75 -0
- package/dist/dashboard-source/modules/frontend-manifest/src/lib/browser-plugin-artifact.ts +46 -0
- package/dist/dashboard-source/modules/frontend-manifest/src/lib/frontend-manifest.ts +37 -30
- package/dist/dashboard-source/modules/frontend-plugin-host/src/lib/frontend-plugin-host.ts +9 -1
- package/dist/dashboard-source/modules/openauth/src/client.ts +25 -17
- package/dist/dashboard-source/modules/openauth/src/util.ts +16 -0
- package/dist/dashboard-source/modules/{aws-common/src/lib/project-balance-admission.ts → project-accounting/src/admission.ts} +4 -8
- package/dist/dashboard-source/modules/realtime-client/src/appsync-client.ts +377 -0
- package/dist/dashboard-source/modules/realtime-client/src/index.ts +5 -0
- package/dist/dashboard-source/modules/realtime-client/src/subscription-presence.ts +163 -0
- package/dist/dashboard-source/modules/request-time/src/lib/request-time.ts +6 -24
- package/dist/dashboard-source/modules/rxdb-collections/generated/execution-schema.json +28 -21
- package/dist/dashboard-source/modules/rxdb-collections/src/lib/rxdb-collections.ts +25 -18
- package/dist/dashboard-source/modules/rxdb-collections/src/lib/to-rxdb-schema.ts +60 -10
- package/dist/dashboard-source/modules/shadcn-components/src/index.ts +18 -2
- package/dist/dashboard-source/modules/shadcn-components/src/lib/date-calendar.tsx +93 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/date-field.tsx +147 -48
- package/dist/dashboard-source/modules/shadcn-components/src/lib/date-time-display.tsx +272 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/local-date-time-input.tsx +108 -0
- package/dist/dashboard-source/modules/shadcn-components/src/lib/lookup-field.tsx +237 -351
- package/dist/dashboard-source/modules/shadcn-components/src/lib/ui/popover.tsx +2 -1
- package/dist/dashboard-source.json +48 -47
- package/dist/graphql-server.mjs +245 -200
- package/dist/job-worker-supervisor.mjs +262 -0
- package/dist/job-worker.mjs +234 -133
- package/dist/main.mjs +23 -4
- package/dist/prepare-dashboard.mjs +8 -8
- package/dist/resources/cedar/policies.cedar +80 -38
- package/dist/resources/cedar/schema.cedarschema +39 -21
- package/dist/resources/graphql-schema/rxdb.graphql +2 -0
- package/dist/resources/graphql-schema/system.graphql +190 -51
- package/package.json +64 -62
- package/dist/chunk-6ntmymmx.js +0 -85
- package/dist/dashboard-source/apps/frontend/app/(protected)/lists/utils.ts +0 -20
- package/dist/dashboard-source/apps/frontend/app/(protected)/processes/components/process-form-actions.tsx +0 -105
- package/dist/dashboard-source/apps/frontend/hooks/use-draft-process-save.ts +0 -189
- package/dist/dashboard-source/apps/frontend/hooks/use-draft-state.ts +0 -79
- package/dist/dashboard-source/apps/frontend/hooks/use-processes-query.ts +0 -56
- package/dist/dashboard-source/modules/form/src/lib/ajv-standard-schema.ts +0 -152
- package/dist/dashboard-source/modules/form/src/lib/client-components-to-form.tsx +0 -1421
- package/dist/dashboard-source/modules/form/src/lib/friendly-validation-message.ts +0 -85
- package/dist/dashboard-source/modules/form/src/lib/walker.tsx +0 -1549
- package/dist/dashboard-source/modules/form-client-representation/src/lib/client-form-definition.ts +0 -440
- package/dist/dashboard-source/modules/form-client-representation/src/lib/plugin-registry.ts +0 -13
- package/dist/dashboard-source/modules/form-client-representation/src/lib/types.ts +0 -336
- package/dist/dashboard-source/modules/form-rule/src/index.ts +0 -21
- package/dist/dashboard-source/modules/form-rule/src/lib/evaluator.ts +0 -531
- package/dist/dashboard-source/modules/form-rule/src/lib/paths.ts +0 -102
- package/dist/dashboard-source/modules/form-rule/src/lib/types.ts +0 -121
- package/dist/dashboard-source/modules/form-schema/src/lib/property-signature.ts +0 -45
|
@@ -1,1549 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
Suspense,
|
|
3
|
-
use,
|
|
4
|
-
useCallback,
|
|
5
|
-
useEffect,
|
|
6
|
-
useEffectEvent,
|
|
7
|
-
useRef,
|
|
8
|
-
useState,
|
|
9
|
-
} from "react"
|
|
10
|
-
import type {
|
|
11
|
-
CalendarSlotField as CalendarSlotFieldType,
|
|
12
|
-
FormComponent,
|
|
13
|
-
ListField as ListFieldType,
|
|
14
|
-
LookupField as LookupFieldType,
|
|
15
|
-
MetricBreakdown as MetricBreakdownType,
|
|
16
|
-
PluginField,
|
|
17
|
-
ProviderUserField as ProviderUserFieldType,
|
|
18
|
-
TableField as TableFieldType,
|
|
19
|
-
} from "../../../form-client-representation/src/lib/types.ts"
|
|
20
|
-
import { FormComponentType } from "../../../form-client-representation/src/lib/types.ts"
|
|
21
|
-
import type { FrontendPluginForm } from "../../../frontend-plugin-host/src/index.ts"
|
|
22
|
-
import {
|
|
23
|
-
BooleanField,
|
|
24
|
-
Button,
|
|
25
|
-
CalendarSlotField,
|
|
26
|
-
type CalendarSlotFieldItem,
|
|
27
|
-
DateField,
|
|
28
|
-
Field,
|
|
29
|
-
FieldDescription,
|
|
30
|
-
FieldLabel,
|
|
31
|
-
FieldSetField,
|
|
32
|
-
FileField,
|
|
33
|
-
LookupField,
|
|
34
|
-
type LookupFieldItem,
|
|
35
|
-
RadioField,
|
|
36
|
-
SelectField,
|
|
37
|
-
TextAreaField,
|
|
38
|
-
TextField,
|
|
39
|
-
useFieldContext,
|
|
40
|
-
useFormContext,
|
|
41
|
-
} from "../../../shadcn-components/src/index.ts"
|
|
42
|
-
import {
|
|
43
|
-
type LookupOptions,
|
|
44
|
-
type LookupService,
|
|
45
|
-
useLookup,
|
|
46
|
-
} from "./lookup-context.tsx"
|
|
47
|
-
import { getPluginRenderer } from "./plugin-registry.ts"
|
|
48
|
-
|
|
49
|
-
type AnyAppForm = FrontendPluginForm
|
|
50
|
-
|
|
51
|
-
const effectiveReadOnly = (component: FormComponent): boolean | undefined => {
|
|
52
|
-
if (component.disabled === true) return true
|
|
53
|
-
return component.readonly
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Main walker function that processes client representation and emits React components
|
|
58
|
-
*
|
|
59
|
-
* @param form - The Tanstack form instance
|
|
60
|
-
* @param components - The client representation (output of asClientRepresentation)
|
|
61
|
-
* @param isFirstField - Whether this is the first field (for autofocus)
|
|
62
|
-
* @param stepPath - The step path for file upload authorization (required when form has file fields)
|
|
63
|
-
*/
|
|
64
|
-
export const walkClientRepresentation = (
|
|
65
|
-
form: AnyAppForm,
|
|
66
|
-
components: Record<string, FormComponent>,
|
|
67
|
-
isFirstField = true,
|
|
68
|
-
stepPath?: string,
|
|
69
|
-
enableProviderUserLookup = true,
|
|
70
|
-
lookupOptions?: LookupOptions,
|
|
71
|
-
): React.JSX.Element[] => {
|
|
72
|
-
const fields: React.JSX.Element[] = []
|
|
73
|
-
let autoFocusAssigned = false
|
|
74
|
-
|
|
75
|
-
for (const [fieldName, component] of Object.entries(components)) {
|
|
76
|
-
if (component.hidden === true) {
|
|
77
|
-
continue
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const shouldAutoFocus =
|
|
81
|
-
isFirstField &&
|
|
82
|
-
!autoFocusAssigned &&
|
|
83
|
-
!component.readonly &&
|
|
84
|
-
!component.disabled
|
|
85
|
-
if (shouldAutoFocus) {
|
|
86
|
-
autoFocusAssigned = true
|
|
87
|
-
}
|
|
88
|
-
const field = processComponent(
|
|
89
|
-
form,
|
|
90
|
-
fieldName,
|
|
91
|
-
component,
|
|
92
|
-
shouldAutoFocus,
|
|
93
|
-
stepPath,
|
|
94
|
-
enableProviderUserLookup,
|
|
95
|
-
lookupOptions,
|
|
96
|
-
)
|
|
97
|
-
fields.push(field)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return fields
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Process a single component from the client representation
|
|
105
|
-
*/
|
|
106
|
-
const processComponent = (
|
|
107
|
-
form: AnyAppForm,
|
|
108
|
-
fieldName: string,
|
|
109
|
-
component: FormComponent,
|
|
110
|
-
shouldAutoFocus: boolean,
|
|
111
|
-
stepPath?: string,
|
|
112
|
-
enableProviderUserLookup = true,
|
|
113
|
-
lookupOptions?: LookupOptions,
|
|
114
|
-
): React.JSX.Element => {
|
|
115
|
-
const readOnly = effectiveReadOnly(component)
|
|
116
|
-
// descriptionHtml opts into trusted HTML rendering. Form descriptions are
|
|
117
|
-
// admin-authored process-definition content, not end-user supplied input.
|
|
118
|
-
switch (component._tag) {
|
|
119
|
-
case FormComponentType.Text:
|
|
120
|
-
return (
|
|
121
|
-
<form.AppField key={component.field} name={component.field}>
|
|
122
|
-
{() => (
|
|
123
|
-
<TextField
|
|
124
|
-
label={component.label}
|
|
125
|
-
descriptionHtml={component.description}
|
|
126
|
-
autoFocus={shouldAutoFocus}
|
|
127
|
-
autoComplete={component.autoComplete}
|
|
128
|
-
{...(readOnly !== undefined && {
|
|
129
|
-
readOnly,
|
|
130
|
-
})}
|
|
131
|
-
/>
|
|
132
|
-
)}
|
|
133
|
-
</form.AppField>
|
|
134
|
-
)
|
|
135
|
-
|
|
136
|
-
case FormComponentType.TextArea:
|
|
137
|
-
return (
|
|
138
|
-
<form.AppField key={component.field} name={component.field}>
|
|
139
|
-
{() => (
|
|
140
|
-
<TextAreaField
|
|
141
|
-
label={component.label}
|
|
142
|
-
descriptionHtml={component.description}
|
|
143
|
-
autoFocus={shouldAutoFocus}
|
|
144
|
-
{...(readOnly !== undefined && {
|
|
145
|
-
readOnly,
|
|
146
|
-
})}
|
|
147
|
-
/>
|
|
148
|
-
)}
|
|
149
|
-
</form.AppField>
|
|
150
|
-
)
|
|
151
|
-
|
|
152
|
-
case FormComponentType.Number:
|
|
153
|
-
return (
|
|
154
|
-
<form.AppField key={component.field} name={component.field}>
|
|
155
|
-
{() => (
|
|
156
|
-
<TextField
|
|
157
|
-
inputMode="decimal"
|
|
158
|
-
label={component.label}
|
|
159
|
-
descriptionHtml={component.description}
|
|
160
|
-
autoFocus={shouldAutoFocus}
|
|
161
|
-
autoComplete={component.autoComplete}
|
|
162
|
-
{...(readOnly !== undefined && {
|
|
163
|
-
readOnly,
|
|
164
|
-
})}
|
|
165
|
-
/>
|
|
166
|
-
)}
|
|
167
|
-
</form.AppField>
|
|
168
|
-
)
|
|
169
|
-
|
|
170
|
-
case FormComponentType.Date:
|
|
171
|
-
return (
|
|
172
|
-
<form.AppField key={component.field} name={component.field}>
|
|
173
|
-
{() => (
|
|
174
|
-
<DateField
|
|
175
|
-
label={component.label}
|
|
176
|
-
descriptionHtml={component.description}
|
|
177
|
-
autoFocus={shouldAutoFocus}
|
|
178
|
-
{...(readOnly !== undefined && {
|
|
179
|
-
readOnly,
|
|
180
|
-
})}
|
|
181
|
-
/>
|
|
182
|
-
)}
|
|
183
|
-
</form.AppField>
|
|
184
|
-
)
|
|
185
|
-
|
|
186
|
-
case FormComponentType.Email:
|
|
187
|
-
return (
|
|
188
|
-
<form.AppField key={component.field} name={component.field}>
|
|
189
|
-
{() => (
|
|
190
|
-
<TextField
|
|
191
|
-
type="email"
|
|
192
|
-
inputMode="email"
|
|
193
|
-
label={component.label}
|
|
194
|
-
descriptionHtml={component.description}
|
|
195
|
-
autoFocus={shouldAutoFocus}
|
|
196
|
-
autoComplete={component.autoComplete}
|
|
197
|
-
{...(readOnly !== undefined && {
|
|
198
|
-
readOnly,
|
|
199
|
-
})}
|
|
200
|
-
/>
|
|
201
|
-
)}
|
|
202
|
-
</form.AppField>
|
|
203
|
-
)
|
|
204
|
-
|
|
205
|
-
case FormComponentType.Phone:
|
|
206
|
-
return (
|
|
207
|
-
<form.AppField key={component.field} name={component.field}>
|
|
208
|
-
{() => (
|
|
209
|
-
<TextField
|
|
210
|
-
type="tel"
|
|
211
|
-
inputMode="tel"
|
|
212
|
-
label={component.label}
|
|
213
|
-
descriptionHtml={component.description}
|
|
214
|
-
autoFocus={shouldAutoFocus}
|
|
215
|
-
autoComplete={component.autoComplete}
|
|
216
|
-
{...(readOnly !== undefined && {
|
|
217
|
-
readOnly,
|
|
218
|
-
})}
|
|
219
|
-
/>
|
|
220
|
-
)}
|
|
221
|
-
</form.AppField>
|
|
222
|
-
)
|
|
223
|
-
|
|
224
|
-
case FormComponentType.ProviderUser:
|
|
225
|
-
if (!enableProviderUserLookup) {
|
|
226
|
-
return (
|
|
227
|
-
<form.AppField key={component.field} name={component.field}>
|
|
228
|
-
{() => (
|
|
229
|
-
<TextField
|
|
230
|
-
label={component.label}
|
|
231
|
-
descriptionHtml={component.description}
|
|
232
|
-
autoFocus={shouldAutoFocus}
|
|
233
|
-
autoComplete={component.autoComplete}
|
|
234
|
-
{...(readOnly !== undefined && {
|
|
235
|
-
readOnly,
|
|
236
|
-
})}
|
|
237
|
-
/>
|
|
238
|
-
)}
|
|
239
|
-
</form.AppField>
|
|
240
|
-
)
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
if (!stepPath) {
|
|
244
|
-
throw new Error(
|
|
245
|
-
`ProviderUserField "${component.field}" requires stepPath for fetching suggestions. ` +
|
|
246
|
-
`Please provide stepPath when calling walkClientRepresentation.`,
|
|
247
|
-
)
|
|
248
|
-
}
|
|
249
|
-
return (
|
|
250
|
-
<form.AppField key={component.field} name={component.field}>
|
|
251
|
-
{() => (
|
|
252
|
-
<IndependentLookupFieldWrapper
|
|
253
|
-
component={component}
|
|
254
|
-
stepPath={stepPath}
|
|
255
|
-
lookupOptions={lookupOptions}
|
|
256
|
-
shouldAutoFocus={shouldAutoFocus}
|
|
257
|
-
/>
|
|
258
|
-
)}
|
|
259
|
-
</form.AppField>
|
|
260
|
-
)
|
|
261
|
-
|
|
262
|
-
case FormComponentType.Boolean:
|
|
263
|
-
return (
|
|
264
|
-
<form.AppField key={component.field} name={component.field}>
|
|
265
|
-
{() => (
|
|
266
|
-
<BooleanField
|
|
267
|
-
label={component.label}
|
|
268
|
-
descriptionHtml={component.description}
|
|
269
|
-
{...(readOnly !== undefined && {
|
|
270
|
-
readOnly,
|
|
271
|
-
})}
|
|
272
|
-
/>
|
|
273
|
-
)}
|
|
274
|
-
</form.AppField>
|
|
275
|
-
)
|
|
276
|
-
|
|
277
|
-
case FormComponentType.Select:
|
|
278
|
-
return (
|
|
279
|
-
<form.AppField key={component.field} name={component.field}>
|
|
280
|
-
{() => (
|
|
281
|
-
<SelectField
|
|
282
|
-
label={component.label}
|
|
283
|
-
descriptionHtml={component.description}
|
|
284
|
-
options={component.options}
|
|
285
|
-
{...(component.emptyValue !== undefined && {
|
|
286
|
-
emptyValue: component.emptyValue,
|
|
287
|
-
})}
|
|
288
|
-
autoFocus={shouldAutoFocus}
|
|
289
|
-
{...(readOnly !== undefined && {
|
|
290
|
-
readOnly,
|
|
291
|
-
})}
|
|
292
|
-
/>
|
|
293
|
-
)}
|
|
294
|
-
</form.AppField>
|
|
295
|
-
)
|
|
296
|
-
|
|
297
|
-
case FormComponentType.Radio:
|
|
298
|
-
return (
|
|
299
|
-
<form.AppField key={component.field} name={component.field}>
|
|
300
|
-
{() => (
|
|
301
|
-
<RadioField
|
|
302
|
-
label={component.label}
|
|
303
|
-
descriptionHtml={component.description}
|
|
304
|
-
options={component.options}
|
|
305
|
-
autoFocus={shouldAutoFocus}
|
|
306
|
-
{...(readOnly !== undefined && {
|
|
307
|
-
readOnly,
|
|
308
|
-
})}
|
|
309
|
-
/>
|
|
310
|
-
)}
|
|
311
|
-
</form.AppField>
|
|
312
|
-
)
|
|
313
|
-
|
|
314
|
-
case FormComponentType.Lookup:
|
|
315
|
-
if (!stepPath) {
|
|
316
|
-
throw new Error(
|
|
317
|
-
`LookupField "${component.field}" requires stepPath for fetching suggestions. ` +
|
|
318
|
-
`Please provide stepPath when calling walkClientRepresentation.`,
|
|
319
|
-
)
|
|
320
|
-
}
|
|
321
|
-
return (
|
|
322
|
-
<form.AppField key={component.field} name={component.field}>
|
|
323
|
-
{() => (
|
|
324
|
-
<LookupFieldWrapper
|
|
325
|
-
component={component}
|
|
326
|
-
stepPath={stepPath}
|
|
327
|
-
lookupOptions={lookupOptions}
|
|
328
|
-
shouldAutoFocus={shouldAutoFocus}
|
|
329
|
-
/>
|
|
330
|
-
)}
|
|
331
|
-
</form.AppField>
|
|
332
|
-
)
|
|
333
|
-
|
|
334
|
-
case FormComponentType.CalendarSlot:
|
|
335
|
-
if (!stepPath) {
|
|
336
|
-
throw new Error(
|
|
337
|
-
`CalendarSlotField "${component.field}" requires stepPath for fetching slots. ` +
|
|
338
|
-
`Please provide stepPath when calling walkClientRepresentation.`,
|
|
339
|
-
)
|
|
340
|
-
}
|
|
341
|
-
return (
|
|
342
|
-
<form.AppField key={component.field} name={component.field}>
|
|
343
|
-
{() => (
|
|
344
|
-
<CalendarSlotFieldWrapper
|
|
345
|
-
component={component}
|
|
346
|
-
stepPath={stepPath}
|
|
347
|
-
lookupOptions={lookupOptions}
|
|
348
|
-
shouldAutoFocus={shouldAutoFocus}
|
|
349
|
-
/>
|
|
350
|
-
)}
|
|
351
|
-
</form.AppField>
|
|
352
|
-
)
|
|
353
|
-
|
|
354
|
-
case FormComponentType.File:
|
|
355
|
-
if (!stepPath) {
|
|
356
|
-
throw new Error(
|
|
357
|
-
`FileField "${component.field}" requires stepPath for authorization. ` +
|
|
358
|
-
`Please provide stepPath when calling walkClientRepresentation.`,
|
|
359
|
-
)
|
|
360
|
-
}
|
|
361
|
-
return (
|
|
362
|
-
<form.AppField key={component.field} name={component.field}>
|
|
363
|
-
{() => (
|
|
364
|
-
<FileField
|
|
365
|
-
label={component.label}
|
|
366
|
-
descriptionHtml={component.description}
|
|
367
|
-
documentStore={component.documentStore}
|
|
368
|
-
stepPath={stepPath}
|
|
369
|
-
{...(component.accept != null && { accept: component.accept })}
|
|
370
|
-
{...(component.maxSize != null && { maxSize: component.maxSize })}
|
|
371
|
-
{...(readOnly !== undefined && {
|
|
372
|
-
readOnly,
|
|
373
|
-
})}
|
|
374
|
-
/>
|
|
375
|
-
)}
|
|
376
|
-
</form.AppField>
|
|
377
|
-
)
|
|
378
|
-
|
|
379
|
-
case FormComponentType.FieldSet: {
|
|
380
|
-
const children = walkClientRepresentation(
|
|
381
|
-
form,
|
|
382
|
-
component.children,
|
|
383
|
-
false,
|
|
384
|
-
stepPath,
|
|
385
|
-
enableProviderUserLookup,
|
|
386
|
-
lookupOptions,
|
|
387
|
-
)
|
|
388
|
-
return (
|
|
389
|
-
<FieldSetField key={fieldName} label={component.label}>
|
|
390
|
-
{children}
|
|
391
|
-
</FieldSetField>
|
|
392
|
-
)
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
case FormComponentType.List: {
|
|
396
|
-
return (
|
|
397
|
-
<form.AppField key={component.field} name={component.field}>
|
|
398
|
-
{() => (
|
|
399
|
-
<ListFieldRenderer
|
|
400
|
-
form={form}
|
|
401
|
-
component={component}
|
|
402
|
-
stepPath={stepPath}
|
|
403
|
-
enableProviderUserLookup={enableProviderUserLookup}
|
|
404
|
-
lookupOptions={lookupOptions}
|
|
405
|
-
/>
|
|
406
|
-
)}
|
|
407
|
-
</form.AppField>
|
|
408
|
-
)
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
case FormComponentType.Table: {
|
|
412
|
-
return (
|
|
413
|
-
<form.AppField key={component.field} name={component.field}>
|
|
414
|
-
{() => <TableFieldRenderer component={component} />}
|
|
415
|
-
</form.AppField>
|
|
416
|
-
)
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
case FormComponentType.Plugin: {
|
|
420
|
-
return (
|
|
421
|
-
<PluginFieldRenderer
|
|
422
|
-
key={fieldName}
|
|
423
|
-
form={form}
|
|
424
|
-
component={component}
|
|
425
|
-
shouldAutoFocus={shouldAutoFocus}
|
|
426
|
-
{...(stepPath !== undefined && { stepPath })}
|
|
427
|
-
{...(lookupOptions?.todoId !== undefined && {
|
|
428
|
-
todoId: lookupOptions.todoId,
|
|
429
|
-
})}
|
|
430
|
-
/>
|
|
431
|
-
)
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
case FormComponentType.Static: {
|
|
435
|
-
return (
|
|
436
|
-
<div key={fieldName} data-slot="static-field" className="space-y-2">
|
|
437
|
-
{component.label && (
|
|
438
|
-
<div
|
|
439
|
-
data-slot="static-field-label"
|
|
440
|
-
className="text-sm font-medium leading-none"
|
|
441
|
-
>
|
|
442
|
-
{component.label}
|
|
443
|
-
</div>
|
|
444
|
-
)}
|
|
445
|
-
<div
|
|
446
|
-
data-slot="static-field-content"
|
|
447
|
-
className="text-sm text-muted-foreground"
|
|
448
|
-
>
|
|
449
|
-
{component.content || component.description}
|
|
450
|
-
</div>
|
|
451
|
-
</div>
|
|
452
|
-
)
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
case FormComponentType.Link: {
|
|
456
|
-
if (component.display === "button") {
|
|
457
|
-
return (
|
|
458
|
-
<div key={fieldName} data-slot="static-link" className="space-y-2">
|
|
459
|
-
<Button
|
|
460
|
-
asChild
|
|
461
|
-
className={
|
|
462
|
-
component.color === "blue"
|
|
463
|
-
? "bg-blue-600 text-white hover:bg-blue-700"
|
|
464
|
-
: undefined
|
|
465
|
-
}
|
|
466
|
-
>
|
|
467
|
-
<a
|
|
468
|
-
data-slot="static-link-button"
|
|
469
|
-
href={component.url}
|
|
470
|
-
target="_blank"
|
|
471
|
-
rel="noopener noreferrer"
|
|
472
|
-
>
|
|
473
|
-
{component.text}
|
|
474
|
-
</a>
|
|
475
|
-
</Button>
|
|
476
|
-
</div>
|
|
477
|
-
)
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
return (
|
|
481
|
-
<div key={fieldName} data-slot="static-link" className="space-y-2">
|
|
482
|
-
{component.label && (
|
|
483
|
-
<div
|
|
484
|
-
data-slot="static-link-label"
|
|
485
|
-
className="text-sm font-medium leading-none"
|
|
486
|
-
>
|
|
487
|
-
{component.label}
|
|
488
|
-
</div>
|
|
489
|
-
)}
|
|
490
|
-
<a
|
|
491
|
-
data-slot="static-link-anchor"
|
|
492
|
-
href={component.url}
|
|
493
|
-
target="_blank"
|
|
494
|
-
rel="noopener noreferrer"
|
|
495
|
-
className="text-sm text-primary underline-offset-4 hover:underline"
|
|
496
|
-
>
|
|
497
|
-
{component.text}
|
|
498
|
-
</a>
|
|
499
|
-
</div>
|
|
500
|
-
)
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
case FormComponentType.MetricBreakdown: {
|
|
504
|
-
return (
|
|
505
|
-
<MetricBreakdownPluginRenderer
|
|
506
|
-
key={fieldName}
|
|
507
|
-
form={form}
|
|
508
|
-
component={component}
|
|
509
|
-
shouldAutoFocus={shouldAutoFocus}
|
|
510
|
-
/>
|
|
511
|
-
)
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
default: {
|
|
515
|
-
const _exhaustive: never = component
|
|
516
|
-
throw new Error(
|
|
517
|
-
`Unhandled component type: ${(_exhaustive as FormComponent)._tag}`,
|
|
518
|
-
)
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
function TableFieldRenderer({ component }: { component: TableFieldType }) {
|
|
524
|
-
const field = useFieldContext<unknown[]>()
|
|
525
|
-
const rows = Array.isArray(field.state.value) ? field.state.value : []
|
|
526
|
-
const columns = Object.entries(component.itemChildren).flatMap(
|
|
527
|
-
([key, child]) =>
|
|
528
|
-
"field" in child ? [{ key, label: child.label || key }] : [],
|
|
529
|
-
)
|
|
530
|
-
|
|
531
|
-
return (
|
|
532
|
-
<Field>
|
|
533
|
-
<FieldLabel>{component.label}</FieldLabel>
|
|
534
|
-
<div className="overflow-x-auto rounded-md border">
|
|
535
|
-
<table className="w-full min-w-max text-left text-sm">
|
|
536
|
-
<thead className="border-b bg-muted/50 text-muted-foreground">
|
|
537
|
-
<tr>
|
|
538
|
-
{columns.map((column) => (
|
|
539
|
-
<th
|
|
540
|
-
key={column.key}
|
|
541
|
-
scope="col"
|
|
542
|
-
className="px-3 py-2 font-medium"
|
|
543
|
-
>
|
|
544
|
-
{column.label}
|
|
545
|
-
</th>
|
|
546
|
-
))}
|
|
547
|
-
</tr>
|
|
548
|
-
</thead>
|
|
549
|
-
<tbody>
|
|
550
|
-
{rows.length === 0 ? (
|
|
551
|
-
<tr>
|
|
552
|
-
<td
|
|
553
|
-
className="px-3 py-3 text-muted-foreground"
|
|
554
|
-
colSpan={Math.max(columns.length, 1)}
|
|
555
|
-
>
|
|
556
|
-
No rows.
|
|
557
|
-
</td>
|
|
558
|
-
</tr>
|
|
559
|
-
) : (
|
|
560
|
-
rows.map((row, index) => (
|
|
561
|
-
<tr
|
|
562
|
-
key={getTableRowKey(row, component.field, index)}
|
|
563
|
-
className="border-b last:border-0"
|
|
564
|
-
>
|
|
565
|
-
{columns.map((column) => (
|
|
566
|
-
<td key={column.key} className="px-3 py-2 align-top">
|
|
567
|
-
{formatTableCellValue(getTableCellValue(row, column.key))}
|
|
568
|
-
</td>
|
|
569
|
-
))}
|
|
570
|
-
</tr>
|
|
571
|
-
))
|
|
572
|
-
)}
|
|
573
|
-
</tbody>
|
|
574
|
-
</table>
|
|
575
|
-
</div>
|
|
576
|
-
{component.description && (
|
|
577
|
-
<FieldDescription trustedHtml={component.description} />
|
|
578
|
-
)}
|
|
579
|
-
</Field>
|
|
580
|
-
)
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
const getTableCellValue = (row: unknown, key: string): unknown =>
|
|
584
|
-
typeof row === "object" && row !== null && !Array.isArray(row)
|
|
585
|
-
? (row as Record<string, unknown>)[key]
|
|
586
|
-
: undefined
|
|
587
|
-
|
|
588
|
-
const getTableRowKey = (row: unknown, field: string, index: number): string => {
|
|
589
|
-
if (typeof row === "object" && row !== null) {
|
|
590
|
-
const explicitKey = (row as Record<string, unknown>)["id"]
|
|
591
|
-
if (typeof explicitKey === "string" || typeof explicitKey === "number") {
|
|
592
|
-
return `${field}-id-${explicitKey}`
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
return `${field}-row-${index}`
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
const formatTableCellValue = (value: unknown): string => {
|
|
600
|
-
if (value === null || value === undefined || value === "") return "-"
|
|
601
|
-
if (typeof value === "string") return value
|
|
602
|
-
if (typeof value === "number" || typeof value === "boolean") {
|
|
603
|
-
return String(value)
|
|
604
|
-
}
|
|
605
|
-
// Keep unexpected table cell shapes visible instead of silently blanking them.
|
|
606
|
-
return JSON.stringify(value)
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
function MetricBreakdownPluginRenderer({
|
|
610
|
-
form,
|
|
611
|
-
component,
|
|
612
|
-
shouldAutoFocus,
|
|
613
|
-
}: {
|
|
614
|
-
readonly form: AnyAppForm
|
|
615
|
-
readonly component: MetricBreakdownType
|
|
616
|
-
readonly shouldAutoFocus: boolean
|
|
617
|
-
}) {
|
|
618
|
-
if (!component.rendererPluginType) {
|
|
619
|
-
return (
|
|
620
|
-
<div className="rounded-md border border-amber-300 bg-amber-50 p-3 text-sm text-amber-900">
|
|
621
|
-
No renderer plugin configured for metric breakdown "{component.title}".
|
|
622
|
-
</div>
|
|
623
|
-
)
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
const renderer = getPluginRenderer(component.rendererPluginType)
|
|
627
|
-
if (!renderer) {
|
|
628
|
-
return (
|
|
629
|
-
<div className="rounded-md border border-red-300 bg-red-50 p-3 text-sm text-red-800">
|
|
630
|
-
No renderer registered for plugin type: {component.rendererPluginType}
|
|
631
|
-
</div>
|
|
632
|
-
)
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
const pluginComponent: PluginField = {
|
|
636
|
-
_tag: FormComponentType.Plugin,
|
|
637
|
-
field: component.field,
|
|
638
|
-
label: component.label,
|
|
639
|
-
pluginType: component.rendererPluginType,
|
|
640
|
-
pluginData: component,
|
|
641
|
-
readonly: true,
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
return renderer(form, pluginComponent, shouldAutoFocus)
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
/**
|
|
648
|
-
* Wrapper component that fetches lookup suggestions and renders the LookupField UI.
|
|
649
|
-
* Uses the LookupProvider context to make GraphQL calls with debounced search.
|
|
650
|
-
*
|
|
651
|
-
* For dependent lookups (component.dependencies is set), subscribes to dependency
|
|
652
|
-
* field values and calls the typed query. Re-queries and clears invalid selections
|
|
653
|
-
* when dependencies change.
|
|
654
|
-
*/
|
|
655
|
-
function LookupFieldWrapper({
|
|
656
|
-
component,
|
|
657
|
-
stepPath,
|
|
658
|
-
lookupOptions,
|
|
659
|
-
shouldAutoFocus,
|
|
660
|
-
}: {
|
|
661
|
-
component: LookupFieldType
|
|
662
|
-
stepPath: string
|
|
663
|
-
lookupOptions: LookupOptions | undefined
|
|
664
|
-
shouldAutoFocus: boolean
|
|
665
|
-
}) {
|
|
666
|
-
const hasDeps =
|
|
667
|
-
component.dependencies &&
|
|
668
|
-
component.dependencies.length > 0 &&
|
|
669
|
-
component.queryName
|
|
670
|
-
|
|
671
|
-
return hasDeps ? (
|
|
672
|
-
<DependentLookupFieldWrapper
|
|
673
|
-
component={component}
|
|
674
|
-
shouldAutoFocus={shouldAutoFocus}
|
|
675
|
-
/>
|
|
676
|
-
) : (
|
|
677
|
-
<IndependentLookupFieldWrapper
|
|
678
|
-
component={component}
|
|
679
|
-
stepPath={stepPath}
|
|
680
|
-
lookupOptions={lookupOptions}
|
|
681
|
-
shouldAutoFocus={shouldAutoFocus}
|
|
682
|
-
/>
|
|
683
|
-
)
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
/**
|
|
687
|
-
* Independent lookup — uses the generic lookupSuggestions query.
|
|
688
|
-
*/
|
|
689
|
-
function IndependentLookupFieldWrapper({
|
|
690
|
-
component,
|
|
691
|
-
stepPath,
|
|
692
|
-
lookupOptions,
|
|
693
|
-
shouldAutoFocus,
|
|
694
|
-
}: {
|
|
695
|
-
component: LookupFieldType | ProviderUserFieldType
|
|
696
|
-
stepPath: string
|
|
697
|
-
lookupOptions: LookupOptions | undefined
|
|
698
|
-
shouldAutoFocus: boolean
|
|
699
|
-
}) {
|
|
700
|
-
const lookupService = useLookup()
|
|
701
|
-
const readOnly = effectiveReadOnly(component)
|
|
702
|
-
const [items, setItems] = useState<LookupFieldItem[]>([])
|
|
703
|
-
const [loading, setLoading] = useState(false)
|
|
704
|
-
const [error, setError] = useState<string | undefined>(undefined)
|
|
705
|
-
const debounceRef = useRef<ReturnType<typeof setTimeout> | null>(null)
|
|
706
|
-
|
|
707
|
-
// Fetch initial items on mount
|
|
708
|
-
useEffect(() => {
|
|
709
|
-
const fieldName = component.field.includes(".")
|
|
710
|
-
? (component.field.split(".").pop() ?? component.field)
|
|
711
|
-
: component.field
|
|
712
|
-
lookupService
|
|
713
|
-
.fetchSuggestions(stepPath, fieldName, "", 20, lookupOptions)
|
|
714
|
-
.then((results) => {
|
|
715
|
-
setItems(results)
|
|
716
|
-
setError(undefined)
|
|
717
|
-
})
|
|
718
|
-
.catch((err) => {
|
|
719
|
-
setItems([])
|
|
720
|
-
setError(
|
|
721
|
-
err instanceof Error ? err.message : "Failed to load suggestions",
|
|
722
|
-
)
|
|
723
|
-
})
|
|
724
|
-
}, [stepPath, component.field, lookupService, lookupOptions])
|
|
725
|
-
|
|
726
|
-
const handleSearch = useCallback(
|
|
727
|
-
(filter: string) => {
|
|
728
|
-
if (debounceRef.current) {
|
|
729
|
-
clearTimeout(debounceRef.current)
|
|
730
|
-
}
|
|
731
|
-
debounceRef.current = setTimeout(() => {
|
|
732
|
-
setLoading(true)
|
|
733
|
-
setError(undefined)
|
|
734
|
-
const fieldName = component.field.includes(".")
|
|
735
|
-
? (component.field.split(".").pop() ?? component.field)
|
|
736
|
-
: component.field
|
|
737
|
-
lookupService
|
|
738
|
-
.fetchSuggestions(stepPath, fieldName, filter, 20, lookupOptions)
|
|
739
|
-
.then((results) => {
|
|
740
|
-
setItems(results)
|
|
741
|
-
setLoading(false)
|
|
742
|
-
})
|
|
743
|
-
.catch((err) => {
|
|
744
|
-
setItems([])
|
|
745
|
-
setLoading(false)
|
|
746
|
-
setError(
|
|
747
|
-
err instanceof Error ? err.message : "Failed to load suggestions",
|
|
748
|
-
)
|
|
749
|
-
})
|
|
750
|
-
}, 300)
|
|
751
|
-
},
|
|
752
|
-
[stepPath, component.field, lookupService, lookupOptions],
|
|
753
|
-
)
|
|
754
|
-
|
|
755
|
-
return (
|
|
756
|
-
<LookupField
|
|
757
|
-
label={component.label}
|
|
758
|
-
descriptionHtml={component.description}
|
|
759
|
-
items={items}
|
|
760
|
-
onSearch={handleSearch}
|
|
761
|
-
loading={loading}
|
|
762
|
-
error={error}
|
|
763
|
-
{...(readOnly !== undefined && {
|
|
764
|
-
readOnly,
|
|
765
|
-
})}
|
|
766
|
-
autoFocus={shouldAutoFocus}
|
|
767
|
-
allowFreeText={getLookupAllowFreeText(component)}
|
|
768
|
-
/>
|
|
769
|
-
)
|
|
770
|
-
}
|
|
771
|
-
|
|
772
|
-
const getLookupAllowFreeText = (
|
|
773
|
-
component: LookupFieldType | ProviderUserFieldType,
|
|
774
|
-
): boolean | undefined =>
|
|
775
|
-
component._tag === FormComponentType.Lookup
|
|
776
|
-
? component.allowFreeText
|
|
777
|
-
: undefined
|
|
778
|
-
|
|
779
|
-
const calendarSlotResourceCache = new WeakMap<
|
|
780
|
-
LookupService,
|
|
781
|
-
Map<string, Promise<CalendarSlotFieldItem[]>>
|
|
782
|
-
>()
|
|
783
|
-
|
|
784
|
-
// Resource lifetime is tied to the lookup service. Public todo pages create a
|
|
785
|
-
// per-token service, so time-sensitive slot data is discarded on navigation.
|
|
786
|
-
|
|
787
|
-
const calendarSlotResourceKey = (
|
|
788
|
-
stepPath: string,
|
|
789
|
-
fieldName: string,
|
|
790
|
-
lookupOptions: LookupOptions | undefined,
|
|
791
|
-
) => `${stepPath}\u0000${fieldName}\u0000${lookupOptions?.todoId ?? ""}`
|
|
792
|
-
|
|
793
|
-
const getCalendarSlotResource = (
|
|
794
|
-
lookupService: LookupService,
|
|
795
|
-
stepPath: string,
|
|
796
|
-
fieldName: string,
|
|
797
|
-
lookupOptions: LookupOptions | undefined,
|
|
798
|
-
) => {
|
|
799
|
-
let serviceCache = calendarSlotResourceCache.get(lookupService)
|
|
800
|
-
if (!serviceCache) {
|
|
801
|
-
serviceCache = new Map<string, Promise<CalendarSlotFieldItem[]>>()
|
|
802
|
-
calendarSlotResourceCache.set(lookupService, serviceCache)
|
|
803
|
-
}
|
|
804
|
-
|
|
805
|
-
const key = calendarSlotResourceKey(stepPath, fieldName, lookupOptions)
|
|
806
|
-
const cached = serviceCache.get(key)
|
|
807
|
-
if (cached) {
|
|
808
|
-
return cached
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
const promise = lookupService.fetchCalendarSlots(
|
|
812
|
-
stepPath,
|
|
813
|
-
fieldName,
|
|
814
|
-
lookupOptions,
|
|
815
|
-
)
|
|
816
|
-
serviceCache.set(key, promise)
|
|
817
|
-
return promise
|
|
818
|
-
}
|
|
819
|
-
|
|
820
|
-
const clearCalendarSlotResource = (
|
|
821
|
-
lookupService: LookupService,
|
|
822
|
-
stepPath: string,
|
|
823
|
-
fieldName: string,
|
|
824
|
-
lookupOptions: LookupOptions | undefined,
|
|
825
|
-
) => {
|
|
826
|
-
calendarSlotResourceCache
|
|
827
|
-
.get(lookupService)
|
|
828
|
-
?.delete(calendarSlotResourceKey(stepPath, fieldName, lookupOptions))
|
|
829
|
-
}
|
|
830
|
-
|
|
831
|
-
interface CalendarSlotLoadErrorBoundaryProps {
|
|
832
|
-
readonly children: React.ReactNode
|
|
833
|
-
readonly onReset: () => void
|
|
834
|
-
readonly renderError: (error: unknown, reset: () => void) => React.ReactNode
|
|
835
|
-
readonly resetKey: string
|
|
836
|
-
}
|
|
837
|
-
|
|
838
|
-
interface CalendarSlotLoadErrorBoundaryState {
|
|
839
|
-
readonly error: unknown | null
|
|
840
|
-
readonly resetKey: string
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
class CalendarSlotLoadErrorBoundary extends React.Component<
|
|
844
|
-
CalendarSlotLoadErrorBoundaryProps,
|
|
845
|
-
CalendarSlotLoadErrorBoundaryState
|
|
846
|
-
> {
|
|
847
|
-
override state: CalendarSlotLoadErrorBoundaryState = {
|
|
848
|
-
error: null,
|
|
849
|
-
resetKey: this.props.resetKey,
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
static getDerivedStateFromError(
|
|
853
|
-
error: unknown,
|
|
854
|
-
): Partial<CalendarSlotLoadErrorBoundaryState> {
|
|
855
|
-
return { error }
|
|
856
|
-
}
|
|
857
|
-
|
|
858
|
-
static getDerivedStateFromProps(
|
|
859
|
-
props: CalendarSlotLoadErrorBoundaryProps,
|
|
860
|
-
state: CalendarSlotLoadErrorBoundaryState,
|
|
861
|
-
): Partial<CalendarSlotLoadErrorBoundaryState> | null {
|
|
862
|
-
if (props.resetKey !== state.resetKey) {
|
|
863
|
-
return { error: null, resetKey: props.resetKey }
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
return null
|
|
867
|
-
}
|
|
868
|
-
|
|
869
|
-
private readonly reset = () => {
|
|
870
|
-
this.props.onReset()
|
|
871
|
-
this.setState({ error: null })
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
override render() {
|
|
875
|
-
if (this.state.error) {
|
|
876
|
-
return this.props.renderError(this.state.error, this.reset)
|
|
877
|
-
}
|
|
878
|
-
|
|
879
|
-
return this.props.children
|
|
880
|
-
}
|
|
881
|
-
}
|
|
882
|
-
|
|
883
|
-
function CalendarSlotFieldView({
|
|
884
|
-
component,
|
|
885
|
-
error,
|
|
886
|
-
loading,
|
|
887
|
-
onRetry,
|
|
888
|
-
shouldAutoFocus,
|
|
889
|
-
slots,
|
|
890
|
-
}: {
|
|
891
|
-
readonly component: CalendarSlotFieldType
|
|
892
|
-
readonly error?: boolean | undefined
|
|
893
|
-
readonly loading: boolean
|
|
894
|
-
readonly onRetry?: (() => void) | undefined
|
|
895
|
-
readonly shouldAutoFocus: boolean
|
|
896
|
-
readonly slots: CalendarSlotFieldItem[]
|
|
897
|
-
}) {
|
|
898
|
-
const readOnly = effectiveReadOnly(component)
|
|
899
|
-
|
|
900
|
-
return (
|
|
901
|
-
<CalendarSlotField
|
|
902
|
-
label={component.label}
|
|
903
|
-
descriptionHtml={component.description}
|
|
904
|
-
emptyMessageHtml={component.emptyMessageHtml}
|
|
905
|
-
loadErrorMessageHtml={component.loadErrorMessageHtml}
|
|
906
|
-
slots={slots}
|
|
907
|
-
loading={loading}
|
|
908
|
-
error={error}
|
|
909
|
-
autoFocus={shouldAutoFocus}
|
|
910
|
-
timeZone={component.timeZone}
|
|
911
|
-
locale={component.locale}
|
|
912
|
-
onRetry={onRetry}
|
|
913
|
-
{...(readOnly !== undefined && {
|
|
914
|
-
readOnly,
|
|
915
|
-
})}
|
|
916
|
-
{...(component.calendar !== undefined && {
|
|
917
|
-
calendar: component.calendar,
|
|
918
|
-
})}
|
|
919
|
-
/>
|
|
920
|
-
)
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
function CalendarSlotFieldContent({
|
|
924
|
-
component,
|
|
925
|
-
fieldName,
|
|
926
|
-
lookupOptions,
|
|
927
|
-
lookupService,
|
|
928
|
-
shouldAutoFocus,
|
|
929
|
-
stepPath,
|
|
930
|
-
}: {
|
|
931
|
-
readonly component: CalendarSlotFieldType
|
|
932
|
-
readonly fieldName: string
|
|
933
|
-
readonly lookupOptions: LookupOptions | undefined
|
|
934
|
-
readonly lookupService: LookupService
|
|
935
|
-
readonly shouldAutoFocus: boolean
|
|
936
|
-
readonly stepPath: string
|
|
937
|
-
}) {
|
|
938
|
-
const slots = use(
|
|
939
|
-
getCalendarSlotResource(lookupService, stepPath, fieldName, lookupOptions),
|
|
940
|
-
)
|
|
941
|
-
|
|
942
|
-
return (
|
|
943
|
-
<CalendarSlotFieldView
|
|
944
|
-
component={component}
|
|
945
|
-
loading={false}
|
|
946
|
-
shouldAutoFocus={shouldAutoFocus}
|
|
947
|
-
slots={slots}
|
|
948
|
-
/>
|
|
949
|
-
)
|
|
950
|
-
}
|
|
951
|
-
|
|
952
|
-
function CalendarSlotFieldWrapper({
|
|
953
|
-
component,
|
|
954
|
-
stepPath,
|
|
955
|
-
lookupOptions,
|
|
956
|
-
shouldAutoFocus,
|
|
957
|
-
}: {
|
|
958
|
-
readonly component: CalendarSlotFieldType
|
|
959
|
-
readonly stepPath: string
|
|
960
|
-
readonly lookupOptions: LookupOptions | undefined
|
|
961
|
-
readonly shouldAutoFocus: boolean
|
|
962
|
-
}) {
|
|
963
|
-
const lookupService = useLookup()
|
|
964
|
-
const [clientReady, setClientReady] = useState(false)
|
|
965
|
-
const fieldName = component.field
|
|
966
|
-
const resetKey = calendarSlotResourceKey(stepPath, fieldName, lookupOptions)
|
|
967
|
-
|
|
968
|
-
useEffect(() => {
|
|
969
|
-
setClientReady(true)
|
|
970
|
-
}, [])
|
|
971
|
-
|
|
972
|
-
const fallback = (
|
|
973
|
-
<CalendarSlotFieldView
|
|
974
|
-
component={component}
|
|
975
|
-
loading
|
|
976
|
-
shouldAutoFocus={shouldAutoFocus}
|
|
977
|
-
slots={[]}
|
|
978
|
-
/>
|
|
979
|
-
)
|
|
980
|
-
|
|
981
|
-
if (!clientReady) {
|
|
982
|
-
return fallback
|
|
983
|
-
}
|
|
984
|
-
|
|
985
|
-
return (
|
|
986
|
-
<CalendarSlotLoadErrorBoundary
|
|
987
|
-
resetKey={resetKey}
|
|
988
|
-
onReset={() =>
|
|
989
|
-
clearCalendarSlotResource(
|
|
990
|
-
lookupService,
|
|
991
|
-
stepPath,
|
|
992
|
-
fieldName,
|
|
993
|
-
lookupOptions,
|
|
994
|
-
)
|
|
995
|
-
}
|
|
996
|
-
renderError={(_error, reset) => (
|
|
997
|
-
<CalendarSlotFieldView
|
|
998
|
-
component={component}
|
|
999
|
-
error
|
|
1000
|
-
loading={false}
|
|
1001
|
-
onRetry={reset}
|
|
1002
|
-
shouldAutoFocus={shouldAutoFocus}
|
|
1003
|
-
slots={[]}
|
|
1004
|
-
/>
|
|
1005
|
-
)}
|
|
1006
|
-
>
|
|
1007
|
-
<Suspense fallback={fallback}>
|
|
1008
|
-
<CalendarSlotFieldContent
|
|
1009
|
-
key={resetKey}
|
|
1010
|
-
component={component}
|
|
1011
|
-
fieldName={fieldName}
|
|
1012
|
-
lookupOptions={lookupOptions}
|
|
1013
|
-
lookupService={lookupService}
|
|
1014
|
-
shouldAutoFocus={shouldAutoFocus}
|
|
1015
|
-
stepPath={stepPath}
|
|
1016
|
-
/>
|
|
1017
|
-
</Suspense>
|
|
1018
|
-
</CalendarSlotLoadErrorBoundary>
|
|
1019
|
-
)
|
|
1020
|
-
}
|
|
1021
|
-
|
|
1022
|
-
/**
|
|
1023
|
-
* Read current dependency values from the form store.
|
|
1024
|
-
*/
|
|
1025
|
-
function readDepValues(
|
|
1026
|
-
// biome-ignore lint/suspicious/noExplicitAny: form API generic variance
|
|
1027
|
-
formCtx: any,
|
|
1028
|
-
dependencies: ReadonlyArray<string>,
|
|
1029
|
-
): Record<string, string> {
|
|
1030
|
-
const values = formCtx.state.values as Record<string, unknown>
|
|
1031
|
-
const result: Record<string, string> = {}
|
|
1032
|
-
for (const dep of dependencies) {
|
|
1033
|
-
result[dep] = (values[dep] as string) ?? ""
|
|
1034
|
-
}
|
|
1035
|
-
return result
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
|
-
/**
|
|
1039
|
-
* Dependent lookup — subscribes to dependency field values via form store,
|
|
1040
|
-
* calls the typed per-lookup query, and clears the field when deps change.
|
|
1041
|
-
*/
|
|
1042
|
-
function DependentLookupFieldWrapper({
|
|
1043
|
-
component,
|
|
1044
|
-
shouldAutoFocus,
|
|
1045
|
-
}: {
|
|
1046
|
-
component: LookupFieldType
|
|
1047
|
-
shouldAutoFocus: boolean
|
|
1048
|
-
}) {
|
|
1049
|
-
const lookupService = useLookup()
|
|
1050
|
-
const readOnly = effectiveReadOnly(component)
|
|
1051
|
-
const formCtx = useFormContext()
|
|
1052
|
-
const field = useFieldContext<string>()
|
|
1053
|
-
|
|
1054
|
-
const dependencies = component.dependencies ?? []
|
|
1055
|
-
const queryName = component.queryName ?? ""
|
|
1056
|
-
|
|
1057
|
-
const [items, setItems] = useState<LookupFieldItem[]>([])
|
|
1058
|
-
const [loading, setLoading] = useState(false)
|
|
1059
|
-
const [error, setError] = useState<string | undefined>(undefined)
|
|
1060
|
-
const debounceRef = useRef<ReturnType<typeof setTimeout> | null>(null)
|
|
1061
|
-
|
|
1062
|
-
// Reactive dependency values — updated via form store subscription
|
|
1063
|
-
const [depValues, setDepValues] = useState<Record<string, string>>(() =>
|
|
1064
|
-
readDepValues(formCtx, dependencies),
|
|
1065
|
-
)
|
|
1066
|
-
|
|
1067
|
-
// Subscribe to form store changes to track dependency values
|
|
1068
|
-
useEffect(() => {
|
|
1069
|
-
const unsub = formCtx.store.subscribe(() => {
|
|
1070
|
-
setDepValues((prev) => {
|
|
1071
|
-
const next = readDepValues(formCtx, dependencies)
|
|
1072
|
-
const changed = dependencies.some((d) => prev[d] !== next[d])
|
|
1073
|
-
return changed ? next : prev
|
|
1074
|
-
})
|
|
1075
|
-
})
|
|
1076
|
-
return () => unsub.unsubscribe()
|
|
1077
|
-
}, [formCtx, formCtx.store, dependencies])
|
|
1078
|
-
|
|
1079
|
-
const allDepsFilled = dependencies.every((d) => Boolean(depValues[d]))
|
|
1080
|
-
|
|
1081
|
-
// Stable key for dependency values — triggers re-fetch on change
|
|
1082
|
-
const depKey = dependencies.map((d) => depValues[d] ?? "").join("\0")
|
|
1083
|
-
const prevDepKeyRef = useRef<string | null>(null)
|
|
1084
|
-
const lastFilterRef = useRef("")
|
|
1085
|
-
const clearFieldValue = useEffectEvent(() => {
|
|
1086
|
-
if (field.state.value) {
|
|
1087
|
-
field.setValue("")
|
|
1088
|
-
}
|
|
1089
|
-
})
|
|
1090
|
-
const getCurrentDepValues = useEffectEvent(() =>
|
|
1091
|
-
readDepValues(formCtx, dependencies),
|
|
1092
|
-
)
|
|
1093
|
-
|
|
1094
|
-
// When dependencies change: re-fetch and clear invalid selection
|
|
1095
|
-
useEffect(() => {
|
|
1096
|
-
const isInitialMount = prevDepKeyRef.current === null
|
|
1097
|
-
prevDepKeyRef.current = depKey
|
|
1098
|
-
|
|
1099
|
-
if (!allDepsFilled) {
|
|
1100
|
-
setItems([])
|
|
1101
|
-
return
|
|
1102
|
-
}
|
|
1103
|
-
|
|
1104
|
-
// Clear field value on dep change (not initial mount)
|
|
1105
|
-
if (!isInitialMount) {
|
|
1106
|
-
clearFieldValue()
|
|
1107
|
-
}
|
|
1108
|
-
|
|
1109
|
-
// Fetch with current filter
|
|
1110
|
-
const filter = lastFilterRef.current
|
|
1111
|
-
setLoading(true)
|
|
1112
|
-
setError(undefined)
|
|
1113
|
-
|
|
1114
|
-
const currentDepValues = getCurrentDepValues()
|
|
1115
|
-
const variables: Record<string, unknown> = {
|
|
1116
|
-
input: { filter, ...currentDepValues },
|
|
1117
|
-
limit: 20,
|
|
1118
|
-
}
|
|
1119
|
-
|
|
1120
|
-
lookupService
|
|
1121
|
-
.fetchDependentSuggestions(queryName, variables)
|
|
1122
|
-
.then((results) => {
|
|
1123
|
-
setItems(results)
|
|
1124
|
-
setLoading(false)
|
|
1125
|
-
setError(undefined)
|
|
1126
|
-
})
|
|
1127
|
-
.catch((err) => {
|
|
1128
|
-
console.error("Lookup fetch failed:", err)
|
|
1129
|
-
setItems([])
|
|
1130
|
-
setLoading(false)
|
|
1131
|
-
setError(
|
|
1132
|
-
err instanceof Error ? err.message : "Failed to load suggestions",
|
|
1133
|
-
)
|
|
1134
|
-
})
|
|
1135
|
-
}, [depKey, allDepsFilled, queryName, lookupService])
|
|
1136
|
-
|
|
1137
|
-
// Cleanup debounce timer on unmount
|
|
1138
|
-
useEffect(() => {
|
|
1139
|
-
return () => {
|
|
1140
|
-
if (debounceRef.current) clearTimeout(debounceRef.current)
|
|
1141
|
-
}
|
|
1142
|
-
}, [])
|
|
1143
|
-
|
|
1144
|
-
const handleSearch = (filter: string) => {
|
|
1145
|
-
lastFilterRef.current = filter
|
|
1146
|
-
if (!allDepsFilled) return
|
|
1147
|
-
|
|
1148
|
-
if (debounceRef.current) {
|
|
1149
|
-
clearTimeout(debounceRef.current)
|
|
1150
|
-
}
|
|
1151
|
-
debounceRef.current = setTimeout(() => {
|
|
1152
|
-
setLoading(true)
|
|
1153
|
-
setError(undefined)
|
|
1154
|
-
|
|
1155
|
-
const currentDepValues = readDepValues(formCtx, dependencies)
|
|
1156
|
-
const variables: Record<string, unknown> = {
|
|
1157
|
-
input: { filter, ...currentDepValues },
|
|
1158
|
-
limit: 20,
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1161
|
-
lookupService
|
|
1162
|
-
.fetchDependentSuggestions(queryName, variables)
|
|
1163
|
-
.then((results) => {
|
|
1164
|
-
setItems(results)
|
|
1165
|
-
setLoading(false)
|
|
1166
|
-
})
|
|
1167
|
-
.catch((err) => {
|
|
1168
|
-
console.error("Lookup fetch failed:", err)
|
|
1169
|
-
setItems([])
|
|
1170
|
-
setLoading(false)
|
|
1171
|
-
setError(
|
|
1172
|
-
err instanceof Error ? err.message : "Failed to load suggestions",
|
|
1173
|
-
)
|
|
1174
|
-
})
|
|
1175
|
-
}, 300)
|
|
1176
|
-
}
|
|
1177
|
-
|
|
1178
|
-
return (
|
|
1179
|
-
<LookupField
|
|
1180
|
-
label={component.label}
|
|
1181
|
-
descriptionHtml={component.description}
|
|
1182
|
-
items={items}
|
|
1183
|
-
onSearch={handleSearch}
|
|
1184
|
-
loading={loading}
|
|
1185
|
-
error={error}
|
|
1186
|
-
readOnly={readOnly === true || !allDepsFilled}
|
|
1187
|
-
autoFocus={shouldAutoFocus}
|
|
1188
|
-
/>
|
|
1189
|
-
)
|
|
1190
|
-
}
|
|
1191
|
-
|
|
1192
|
-
/**
|
|
1193
|
-
* Create path-indexed copies of itemChildren for a specific array index.
|
|
1194
|
-
* E.g., if field is "students" and itemChildren has "first_name" at path "students",
|
|
1195
|
-
* this produces "first_name" at path "students[0].first_name" for index 0.
|
|
1196
|
-
*
|
|
1197
|
-
* If parentReadOnly is true, all child fields will be marked as readonly.
|
|
1198
|
-
*/
|
|
1199
|
-
function indexItemChildren(
|
|
1200
|
-
itemChildren: Record<string, FormComponent>,
|
|
1201
|
-
field: string,
|
|
1202
|
-
index: number,
|
|
1203
|
-
parentReadOnly?: boolean,
|
|
1204
|
-
): Record<string, FormComponent> {
|
|
1205
|
-
const result: Record<string, FormComponent> = {}
|
|
1206
|
-
for (const [key, child] of Object.entries(itemChildren)) {
|
|
1207
|
-
if ("field" in child) {
|
|
1208
|
-
// Replace the base field path with the indexed version
|
|
1209
|
-
const childFieldName = child.field.startsWith(`${field}.`)
|
|
1210
|
-
? child.field.slice(field.length + 1)
|
|
1211
|
-
: child.field === field
|
|
1212
|
-
? key
|
|
1213
|
-
: key
|
|
1214
|
-
result[key] = {
|
|
1215
|
-
...child,
|
|
1216
|
-
field: `${field}[${index}].${childFieldName}`,
|
|
1217
|
-
// Propagate parent readonly if specified
|
|
1218
|
-
...(parentReadOnly !== undefined && { readonly: parentReadOnly }),
|
|
1219
|
-
} as FormComponent
|
|
1220
|
-
} else {
|
|
1221
|
-
result[key] = child
|
|
1222
|
-
}
|
|
1223
|
-
}
|
|
1224
|
-
return result
|
|
1225
|
-
}
|
|
1226
|
-
|
|
1227
|
-
/**
|
|
1228
|
-
* Component that renders a list/array field with add/remove functionality.
|
|
1229
|
-
*
|
|
1230
|
-
* Uses TanStack Form's array field API (pushFieldValue, removeFieldValue)
|
|
1231
|
-
* and recursively renders itemChildren for each array item.
|
|
1232
|
-
*/
|
|
1233
|
-
function ListFieldRenderer({
|
|
1234
|
-
form,
|
|
1235
|
-
component,
|
|
1236
|
-
stepPath,
|
|
1237
|
-
enableProviderUserLookup,
|
|
1238
|
-
lookupOptions,
|
|
1239
|
-
}: {
|
|
1240
|
-
form: AnyAppForm
|
|
1241
|
-
component: ListFieldType
|
|
1242
|
-
stepPath?: string | undefined
|
|
1243
|
-
enableProviderUserLookup: boolean
|
|
1244
|
-
lookupOptions: LookupOptions | undefined
|
|
1245
|
-
}) {
|
|
1246
|
-
const formCtx = useFormContext()
|
|
1247
|
-
const field = useFieldContext<unknown[]>()
|
|
1248
|
-
const readOnly = effectiveReadOnly(component)
|
|
1249
|
-
|
|
1250
|
-
// Subscribe to the array field value to get the current item count
|
|
1251
|
-
const items = (field.state.value as unknown[]) ?? []
|
|
1252
|
-
|
|
1253
|
-
const [itemKeyState, setItemKeyState] = useState(() => ({
|
|
1254
|
-
keys: Array.from({ length: items.length }, (_, index) => index),
|
|
1255
|
-
nextKey: items.length,
|
|
1256
|
-
}))
|
|
1257
|
-
const warnedProviderUserLookupDisabled = useRef(false)
|
|
1258
|
-
|
|
1259
|
-
useEffect(() => {
|
|
1260
|
-
setItemKeyState((current) => {
|
|
1261
|
-
if (current.keys.length === items.length) return current
|
|
1262
|
-
if (current.keys.length > items.length) {
|
|
1263
|
-
return { ...current, keys: current.keys.slice(0, items.length) }
|
|
1264
|
-
}
|
|
1265
|
-
|
|
1266
|
-
const addedCount = items.length - current.keys.length
|
|
1267
|
-
return {
|
|
1268
|
-
keys: [
|
|
1269
|
-
...current.keys,
|
|
1270
|
-
...Array.from(
|
|
1271
|
-
{ length: addedCount },
|
|
1272
|
-
(_, index) => current.nextKey + index,
|
|
1273
|
-
),
|
|
1274
|
-
],
|
|
1275
|
-
nextKey: current.nextKey + addedCount,
|
|
1276
|
-
}
|
|
1277
|
-
})
|
|
1278
|
-
}, [items.length])
|
|
1279
|
-
|
|
1280
|
-
useEffect(() => {
|
|
1281
|
-
if (enableProviderUserLookup) {
|
|
1282
|
-
warnIfListItemProviderUserLookupDisabled(
|
|
1283
|
-
component.itemChildren,
|
|
1284
|
-
warnedProviderUserLookupDisabled,
|
|
1285
|
-
)
|
|
1286
|
-
}
|
|
1287
|
-
}, [component.itemChildren, enableProviderUserLookup])
|
|
1288
|
-
|
|
1289
|
-
// Build default item value from the itemChildren structure
|
|
1290
|
-
const buildEmptyItem = (): Record<string, unknown> => {
|
|
1291
|
-
const item: Record<string, unknown> = {}
|
|
1292
|
-
for (const [key, child] of Object.entries(component.itemChildren)) {
|
|
1293
|
-
if ("field" in child) {
|
|
1294
|
-
switch (child._tag) {
|
|
1295
|
-
case FormComponentType.Text:
|
|
1296
|
-
case FormComponentType.Email:
|
|
1297
|
-
case FormComponentType.Phone:
|
|
1298
|
-
case FormComponentType.ProviderUser:
|
|
1299
|
-
case FormComponentType.File:
|
|
1300
|
-
case FormComponentType.CalendarSlot:
|
|
1301
|
-
item[key] = ""
|
|
1302
|
-
break
|
|
1303
|
-
case FormComponentType.Number:
|
|
1304
|
-
item[key] = 0
|
|
1305
|
-
break
|
|
1306
|
-
case FormComponentType.Boolean:
|
|
1307
|
-
item[key] = false
|
|
1308
|
-
break
|
|
1309
|
-
default:
|
|
1310
|
-
item[key] = ""
|
|
1311
|
-
}
|
|
1312
|
-
}
|
|
1313
|
-
}
|
|
1314
|
-
return item
|
|
1315
|
-
}
|
|
1316
|
-
|
|
1317
|
-
const handleAdd = () => {
|
|
1318
|
-
setItemKeyState((current) => ({
|
|
1319
|
-
keys: [...current.keys, current.nextKey],
|
|
1320
|
-
nextKey: current.nextKey + 1,
|
|
1321
|
-
}))
|
|
1322
|
-
formCtx.pushFieldValue(component.field as never, buildEmptyItem() as never)
|
|
1323
|
-
}
|
|
1324
|
-
|
|
1325
|
-
const handleRemove = (index: number) => {
|
|
1326
|
-
setItemKeyState((current) => ({
|
|
1327
|
-
...current,
|
|
1328
|
-
keys: current.keys.filter((_, itemIndex) => itemIndex !== index),
|
|
1329
|
-
}))
|
|
1330
|
-
formCtx.removeFieldValue(component.field as never, index)
|
|
1331
|
-
}
|
|
1332
|
-
|
|
1333
|
-
return (
|
|
1334
|
-
<FieldSetField label={component.label}>
|
|
1335
|
-
{items.map((_, index) => {
|
|
1336
|
-
const itemKey =
|
|
1337
|
-
itemKeyState.keys[index] ??
|
|
1338
|
-
itemKeyState.nextKey + index - itemKeyState.keys.length
|
|
1339
|
-
const indexedChildren = indexItemChildren(
|
|
1340
|
-
component.itemChildren,
|
|
1341
|
-
component.field,
|
|
1342
|
-
index,
|
|
1343
|
-
readOnly,
|
|
1344
|
-
)
|
|
1345
|
-
return (
|
|
1346
|
-
<div
|
|
1347
|
-
key={`${component.field}-item-${itemKey}`}
|
|
1348
|
-
className="flex flex-col gap-4 rounded-md border p-4"
|
|
1349
|
-
>
|
|
1350
|
-
<div className="flex items-center justify-between">
|
|
1351
|
-
<span className="text-sm font-medium text-muted-foreground">
|
|
1352
|
-
{component.label} #{index + 1}
|
|
1353
|
-
</span>
|
|
1354
|
-
{readOnly !== true && (
|
|
1355
|
-
<Button
|
|
1356
|
-
type="button"
|
|
1357
|
-
variant="ghost"
|
|
1358
|
-
size="sm"
|
|
1359
|
-
onClick={() => handleRemove(index)}
|
|
1360
|
-
>
|
|
1361
|
-
Remove
|
|
1362
|
-
</Button>
|
|
1363
|
-
)}
|
|
1364
|
-
</div>
|
|
1365
|
-
{walkClientRepresentation(
|
|
1366
|
-
form,
|
|
1367
|
-
indexedChildren,
|
|
1368
|
-
false,
|
|
1369
|
-
stepPath,
|
|
1370
|
-
false,
|
|
1371
|
-
lookupOptions,
|
|
1372
|
-
)}
|
|
1373
|
-
</div>
|
|
1374
|
-
)
|
|
1375
|
-
})}
|
|
1376
|
-
{readOnly !== true && (
|
|
1377
|
-
<Button type="button" variant="outline" onClick={handleAdd}>
|
|
1378
|
-
{component.addButtonLabel ?? `Add ${component.label.toLowerCase()}`}
|
|
1379
|
-
</Button>
|
|
1380
|
-
)}
|
|
1381
|
-
</FieldSetField>
|
|
1382
|
-
)
|
|
1383
|
-
}
|
|
1384
|
-
|
|
1385
|
-
const warnIfListItemProviderUserLookupDisabled = (
|
|
1386
|
-
children: Record<string, FormComponent>,
|
|
1387
|
-
warned: { current: boolean },
|
|
1388
|
-
) => {
|
|
1389
|
-
const hasProviderUserField = Object.values(children).some(
|
|
1390
|
-
componentContainsProviderUser,
|
|
1391
|
-
)
|
|
1392
|
-
if (
|
|
1393
|
-
hasProviderUserField &&
|
|
1394
|
-
!warned.current &&
|
|
1395
|
-
process.env["NODE_ENV"] !== "production"
|
|
1396
|
-
) {
|
|
1397
|
-
warned.current = true
|
|
1398
|
-
console.warn(
|
|
1399
|
-
"ProviderUserField lookup is disabled inside ListField until nested submit-time authorization is supported.",
|
|
1400
|
-
)
|
|
1401
|
-
}
|
|
1402
|
-
}
|
|
1403
|
-
|
|
1404
|
-
const componentContainsProviderUser = (component: FormComponent): boolean => {
|
|
1405
|
-
switch (component._tag) {
|
|
1406
|
-
case FormComponentType.ProviderUser:
|
|
1407
|
-
return true
|
|
1408
|
-
case FormComponentType.FieldSet:
|
|
1409
|
-
return Object.values(component.children).some(
|
|
1410
|
-
componentContainsProviderUser,
|
|
1411
|
-
)
|
|
1412
|
-
case FormComponentType.List:
|
|
1413
|
-
case FormComponentType.Table:
|
|
1414
|
-
return Object.values(component.itemChildren).some(
|
|
1415
|
-
componentContainsProviderUser,
|
|
1416
|
-
)
|
|
1417
|
-
default:
|
|
1418
|
-
return false
|
|
1419
|
-
}
|
|
1420
|
-
}
|
|
1421
|
-
|
|
1422
|
-
// Global map of in-flight script loads keyed by src URL.
|
|
1423
|
-
// Ensures concurrent renders share a single load promise per script.
|
|
1424
|
-
const scriptLoadPromises = new Map<string, Promise<void>>()
|
|
1425
|
-
|
|
1426
|
-
function loadScript(src: string, async: boolean): Promise<void> {
|
|
1427
|
-
const existing = scriptLoadPromises.get(src)
|
|
1428
|
-
if (existing) return existing
|
|
1429
|
-
|
|
1430
|
-
const promise = new Promise<void>((resolve, reject) => {
|
|
1431
|
-
// Script may already be in the DOM from a previous page load
|
|
1432
|
-
if (document.querySelector(`script[src="${src}"]`)) {
|
|
1433
|
-
resolve()
|
|
1434
|
-
return
|
|
1435
|
-
}
|
|
1436
|
-
|
|
1437
|
-
const el = document.createElement("script")
|
|
1438
|
-
el.src = src
|
|
1439
|
-
el.async = async
|
|
1440
|
-
el.onload = () => resolve()
|
|
1441
|
-
el.onerror = () => reject(new Error(`Failed to load script: ${src}`))
|
|
1442
|
-
document.head.appendChild(el)
|
|
1443
|
-
})
|
|
1444
|
-
|
|
1445
|
-
scriptLoadPromises.set(src, promise)
|
|
1446
|
-
return promise
|
|
1447
|
-
}
|
|
1448
|
-
|
|
1449
|
-
/**
|
|
1450
|
-
* Minimal error boundary for plugin renderers.
|
|
1451
|
-
* Catches render errors from lazy-loaded plugin components.
|
|
1452
|
-
*/
|
|
1453
|
-
class PluginErrorBoundary extends React.Component<
|
|
1454
|
-
{ pluginType: string; children: React.ReactNode },
|
|
1455
|
-
{ error: string | null }
|
|
1456
|
-
> {
|
|
1457
|
-
constructor(props: { pluginType: string; children: React.ReactNode }) {
|
|
1458
|
-
super(props)
|
|
1459
|
-
this.state = { error: null }
|
|
1460
|
-
}
|
|
1461
|
-
|
|
1462
|
-
static getDerivedStateFromError(error: Error): { error: string } {
|
|
1463
|
-
return { error: error.message }
|
|
1464
|
-
}
|
|
1465
|
-
|
|
1466
|
-
override render() {
|
|
1467
|
-
if (this.state.error) {
|
|
1468
|
-
return (
|
|
1469
|
-
<div className="rounded-md border border-red-300 bg-red-50 p-3 text-sm text-red-800">
|
|
1470
|
-
Error rendering plugin "{this.props.pluginType}": {this.state.error}
|
|
1471
|
-
</div>
|
|
1472
|
-
)
|
|
1473
|
-
}
|
|
1474
|
-
return this.props.children
|
|
1475
|
-
}
|
|
1476
|
-
}
|
|
1477
|
-
|
|
1478
|
-
/**
|
|
1479
|
-
* Component that loads external scripts before rendering a plugin field.
|
|
1480
|
-
*
|
|
1481
|
-
* Scripts are loaded lazily when the field is first encountered, preventing
|
|
1482
|
-
* unnecessary network requests for plugins not used in the current form.
|
|
1483
|
-
*/
|
|
1484
|
-
function PluginFieldRenderer({
|
|
1485
|
-
form,
|
|
1486
|
-
component,
|
|
1487
|
-
shouldAutoFocus,
|
|
1488
|
-
todoId,
|
|
1489
|
-
stepPath,
|
|
1490
|
-
}: {
|
|
1491
|
-
form: AnyAppForm
|
|
1492
|
-
component: PluginField
|
|
1493
|
-
shouldAutoFocus: boolean
|
|
1494
|
-
todoId?: string
|
|
1495
|
-
stepPath?: string
|
|
1496
|
-
}) {
|
|
1497
|
-
const [scriptsLoaded, setScriptsLoaded] = useState(false)
|
|
1498
|
-
const [error, setError] = useState<string | null>(null)
|
|
1499
|
-
|
|
1500
|
-
useEffect(() => {
|
|
1501
|
-
if (!component.scripts || component.scripts.length === 0) {
|
|
1502
|
-
setScriptsLoaded(true)
|
|
1503
|
-
return
|
|
1504
|
-
}
|
|
1505
|
-
|
|
1506
|
-
Promise.all(
|
|
1507
|
-
component.scripts.map((s) => loadScript(s.src, s.async ?? true)),
|
|
1508
|
-
).then(
|
|
1509
|
-
() => setScriptsLoaded(true),
|
|
1510
|
-
(err) =>
|
|
1511
|
-
setError(err instanceof Error ? err.message : "Failed to load scripts"),
|
|
1512
|
-
)
|
|
1513
|
-
}, [component.scripts])
|
|
1514
|
-
|
|
1515
|
-
if (error) {
|
|
1516
|
-
return (
|
|
1517
|
-
<div className="rounded-md border border-red-300 bg-red-50 p-3 text-sm text-red-800">
|
|
1518
|
-
Error loading plugin: {error}
|
|
1519
|
-
</div>
|
|
1520
|
-
)
|
|
1521
|
-
}
|
|
1522
|
-
|
|
1523
|
-
if (!scriptsLoaded) {
|
|
1524
|
-
return <div>Loading plugin...</div>
|
|
1525
|
-
}
|
|
1526
|
-
|
|
1527
|
-
const renderer = getPluginRenderer(component.pluginType)
|
|
1528
|
-
if (!renderer) {
|
|
1529
|
-
return (
|
|
1530
|
-
<div>No renderer registered for plugin type: {component.pluginType}</div>
|
|
1531
|
-
)
|
|
1532
|
-
}
|
|
1533
|
-
|
|
1534
|
-
return (
|
|
1535
|
-
<PluginErrorBoundary pluginType={component.pluginType}>
|
|
1536
|
-
{renderer(
|
|
1537
|
-
form,
|
|
1538
|
-
component,
|
|
1539
|
-
shouldAutoFocus,
|
|
1540
|
-
todoId !== undefined || stepPath !== undefined
|
|
1541
|
-
? {
|
|
1542
|
-
...(todoId !== undefined && { todoId }),
|
|
1543
|
-
...(stepPath !== undefined && { stepPath }),
|
|
1544
|
-
}
|
|
1545
|
-
: undefined,
|
|
1546
|
-
)}
|
|
1547
|
-
</PluginErrorBoundary>
|
|
1548
|
-
)
|
|
1549
|
-
}
|