@jini-ai/user-management 0.7.3-next.2 → 0.7.4
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/CHANGELOG.md +7 -0
- package/README.md +55 -2
- package/dist/admin/adapters/memory.js +4 -4
- package/dist/admin-http/auth/auth-request.d.ts +112 -0
- package/dist/admin-http/auth/auth-request.js +32 -0
- package/dist/admin-http/auth/boot-redemption.d.ts +9 -0
- package/dist/admin-http/auth/boot-redemption.js +17 -0
- package/dist/admin-http/auth/boot-session.d.ts +30 -0
- package/dist/admin-http/auth/boot-session.js +40 -0
- package/dist/admin-http/auth/current-user.d.ts +28 -0
- package/dist/admin-http/auth/current-user.js +34 -0
- package/dist/admin-http/auth/index.d.ts +17 -0
- package/dist/admin-http/auth/index.js +9 -0
- package/dist/admin-http/auth/local-boot-session.d.ts +9 -0
- package/dist/admin-http/auth/local-boot-session.js +30 -0
- package/dist/admin-http/auth/logout.d.ts +10 -0
- package/dist/admin-http/auth/logout.js +17 -0
- package/dist/admin-http/auth/mfa-login.d.ts +30 -0
- package/dist/admin-http/auth/mfa-login.js +43 -0
- package/dist/admin-http/auth/password-login.d.ts +35 -0
- package/dist/admin-http/auth/password-login.js +52 -0
- package/dist/admin-http/auth/password-status.d.ts +34 -0
- package/dist/admin-http/auth/password-status.js +42 -0
- package/dist/admin-http/http/api-keys.d.ts +45 -0
- package/dist/admin-http/http/api-keys.js +28 -0
- package/dist/admin-http/http/users.d.ts +71 -0
- package/dist/admin-http/http/users.js +42 -0
- package/dist/admin-http/owner/mfa-deps.d.ts +41 -0
- package/dist/admin-http/owner/mfa-deps.js +26 -0
- package/dist/admin-http/owner/mfa-routes.d.ts +72 -0
- package/dist/admin-http/owner/mfa-routes.js +105 -0
- package/dist/admin-http/owner/passkey-admission.d.ts +46 -0
- package/dist/admin-http/owner/passkey-admission.js +23 -0
- package/dist/admin-http/owner/passkey-route-deps.d.ts +53 -0
- package/dist/admin-http/owner/passkey-route-deps.js +33 -0
- package/dist/admin-http/owner/passkey-routes.d.ts +146 -0
- package/dist/admin-http/owner/passkey-routes.js +98 -0
- package/dist/admin-http/owner/recovery-routes.d.ts +71 -0
- package/dist/admin-http/owner/recovery-routes.js +112 -0
- package/dist/admin-http/routes/api-keys/create-principal.d.ts +26 -0
- package/dist/admin-http/routes/api-keys/create-principal.js +37 -0
- package/dist/admin-http/routes/api-keys/issue.d.ts +32 -0
- package/dist/admin-http/routes/api-keys/issue.js +38 -0
- package/dist/admin-http/routes/api-keys/revoke.d.ts +26 -0
- package/dist/admin-http/routes/api-keys/revoke.js +31 -0
- package/dist/admin-http/routes/api-keys/shared.d.ts +46 -0
- package/dist/admin-http/routes/api-keys/shared.js +38 -0
- package/dist/admin-http/routes/users/access-shared.d.ts +103 -0
- package/dist/admin-http/routes/users/access-shared.js +85 -0
- package/dist/admin-http/routes/users/assign-role.d.ts +24 -0
- package/dist/admin-http/routes/users/assign-role.js +30 -0
- package/dist/admin-http/routes/users/attach-policy.d.ts +25 -0
- package/dist/admin-http/routes/users/attach-policy.js +31 -0
- package/dist/admin-http/routes/users/create-policy.d.ts +19 -0
- package/dist/admin-http/routes/users/create-policy.js +28 -0
- package/dist/admin-http/routes/users/create-role.d.ts +15 -0
- package/dist/admin-http/routes/users/create-role.js +21 -0
- package/dist/admin-http/routes/users/create.d.ts +32 -0
- package/dist/admin-http/routes/users/create.js +67 -0
- package/dist/admin-http/routes/users/delete-policy.d.ts +16 -0
- package/dist/admin-http/routes/users/delete-policy.js +24 -0
- package/dist/admin-http/routes/users/delete-role.d.ts +16 -0
- package/dist/admin-http/routes/users/delete-role.js +24 -0
- package/dist/admin-http/routes/users/delete.d.ts +35 -0
- package/dist/admin-http/routes/users/delete.js +35 -0
- package/dist/admin-http/routes/users/disable.d.ts +31 -0
- package/dist/admin-http/routes/users/disable.js +38 -0
- package/dist/admin-http/routes/users/enable.d.ts +32 -0
- package/dist/admin-http/routes/users/enable.js +45 -0
- package/dist/admin-http/routes/users/list-policies.d.ts +18 -0
- package/dist/admin-http/routes/users/list-policies.js +20 -0
- package/dist/admin-http/routes/users/list-policy-permissions.d.ts +28 -0
- package/dist/admin-http/routes/users/list-policy-permissions.js +30 -0
- package/dist/admin-http/routes/users/list-roles.d.ts +18 -0
- package/dist/admin-http/routes/users/list-roles.js +20 -0
- package/dist/admin-http/routes/users/list.d.ts +40 -0
- package/dist/admin-http/routes/users/list.js +82 -0
- package/dist/admin-http/routes/users/remove-policy-permission.d.ts +48 -0
- package/dist/admin-http/routes/users/remove-policy-permission.js +62 -0
- package/dist/admin-http/routes/users/reset-password.d.ts +33 -0
- package/dist/admin-http/routes/users/reset-password.js +52 -0
- package/dist/admin-http/routes/users/shared.d.ts +124 -0
- package/dist/admin-http/routes/users/shared.js +93 -0
- package/dist/admin-http/routes/users/update-policy.d.ts +25 -0
- package/dist/admin-http/routes/users/update-policy.js +30 -0
- package/dist/admin-http/routes/users/update-role.d.ts +23 -0
- package/dist/admin-http/routes/users/update-role.js +29 -0
- package/dist/admin-http/routes/users/update.d.ts +35 -0
- package/dist/admin-http/routes/users/update.js +78 -0
- package/dist/admin-http/routes/users/write-policy-permission.d.ts +31 -0
- package/dist/admin-http/routes/users/write-policy-permission.js +45 -0
- package/dist/core/ports.d.ts +22 -3
- package/dist/core/types.d.ts +17 -5
- package/dist/core/types.js +12 -0
- package/dist/identity/api-key-secret.d.ts +68 -0
- package/dist/identity/api-key-secret.js +229 -0
- package/dist/identity/api-key-service.d.ts +144 -0
- package/dist/identity/api-key-service.js +389 -0
- package/dist/identity/api-key-types.d.ts +79 -0
- package/dist/identity/api-key-types.js +2 -0
- package/dist/identity/boot-session-token.d.ts +18 -0
- package/dist/identity/boot-session-token.js +92 -0
- package/dist/identity/builtin-role-grants.d.ts +120 -0
- package/dist/identity/builtin-role-grants.js +88 -0
- package/dist/identity/delete-user-service.d.ts +195 -0
- package/dist/identity/delete-user-service.js +275 -0
- package/dist/identity/owner-reset-env.d.ts +37 -0
- package/dist/identity/owner-reset-env.js +38 -0
- package/dist/identity/permission-grants.d.ts +31 -0
- package/dist/identity/permission-grants.js +12 -0
- package/dist/identity/permission-list-tool.d.ts +35 -0
- package/dist/identity/permission-list-tool.js +47 -0
- package/dist/identity/repo.authentication.d.ts +57 -0
- package/dist/identity/repo.authentication.js +153 -0
- package/dist/identity/repo.authorization.d.ts +82 -0
- package/dist/identity/repo.authorization.js +203 -0
- package/dist/identity/repo.d.ts +87 -0
- package/dist/identity/repo.js +167 -0
- package/dist/identity/repo.memory.d.ts +31 -0
- package/dist/identity/repo.memory.js +37 -0
- package/dist/identity/role-manage-permission.d.ts +34 -0
- package/dist/identity/role-manage-permission.js +39 -0
- package/dist/identity/site-key-permission.d.ts +66 -0
- package/dist/identity/site-key-permission.js +92 -0
- package/dist/identity/sql/kernel-user-purge.d.ts +19 -0
- package/dist/identity/sql/kernel-user-purge.js +34 -0
- package/dist/identity/sql/kernel-user-trash-store.d.ts +15 -0
- package/dist/identity/sql/kernel-user-trash-store.js +41 -0
- package/dist/identity/sql/user-trash-adapter.d.ts +87 -0
- package/dist/identity/sql/user-trash-adapter.js +124 -0
- package/dist/identity/tool-registrations.d.ts +100 -0
- package/dist/identity/tool-registrations.js +257 -0
- package/dist/identity/user-manage-permission.d.ts +8 -0
- package/dist/identity/user-manage-permission.js +8 -0
- package/dist/identity/user-purge-types.d.ts +85 -0
- package/dist/identity/user-purge-types.js +17 -0
- package/dist/identity/user-purge.d.ts +69 -0
- package/dist/identity/user-purge.js +46 -0
- package/dist/identity/username-change-ports.d.ts +15 -0
- package/dist/identity/username-change-ports.js +22 -0
- package/dist/mail/site/capture-clear.d.ts +58 -0
- package/dist/mail/site/capture-clear.js +21 -0
- package/dist/mail/status/agent-tools.d.ts +65 -0
- package/dist/mail/status/agent-tools.js +22 -0
- package/dist/mail/status/delivery-agent-tools.d.ts +206 -0
- package/dist/mail/status/delivery-agent-tools.js +63 -0
- package/dist/mail/status/delivery-tool-registrations.d.ts +216 -0
- package/dist/mail/status/delivery-tool-registrations.js +110 -0
- package/dist/mail/status/domain-deps.d.ts +25 -0
- package/dist/mail/status/domain-deps.js +23 -0
- package/dist/mail/status/permissions.d.ts +43 -0
- package/dist/mail/status/permissions.js +45 -0
- package/dist/mail/status/provider-agent-tools.d.ts +38 -0
- package/dist/mail/status/provider-agent-tools.js +17 -0
- package/dist/mail/status/provider-operations.d.ts +166 -0
- package/dist/mail/status/provider-operations.js +121 -0
- package/dist/mail/status/provider-tool-registrations.d.ts +65 -0
- package/dist/mail/status/provider-tool-registrations.js +106 -0
- package/dist/mail/status/tool-registrations.d.ts +152 -0
- package/dist/mail/status/tool-registrations.js +112 -0
- package/dist/member-login/credentials.d.ts +40 -0
- package/dist/member-login/credentials.js +26 -0
- package/dist/member-login/link-service.d.ts +66 -0
- package/dist/member-login/link-service.js +141 -0
- package/dist/member-login/oidc-login.d.ts +132 -0
- package/dist/member-login/oidc-login.js +206 -0
- package/dist/member-login/oidc-request.d.ts +80 -0
- package/dist/member-login/oidc-request.js +86 -0
- package/dist/member-login/providers.d.ts +79 -0
- package/dist/member-login/providers.js +41 -0
- package/dist/member-login/ready-providers.d.ts +17 -0
- package/dist/member-login/ready-providers.js +11 -0
- package/dist/member-login/unlink-identity.d.ts +26 -0
- package/dist/member-login/unlink-identity.js +59 -0
- package/dist/members/access-resolver.d.ts +107 -0
- package/dist/members/access-resolver.js +231 -0
- package/dist/members/agent-tools.d.ts +14 -0
- package/dist/members/agent-tools.js +139 -0
- package/dist/members/auth-mail.d.ts +27 -0
- package/dist/members/auth-mail.js +21 -0
- package/dist/members/capability-card.d.ts +18 -0
- package/dist/members/capability-card.js +27 -0
- package/dist/members/consent-service.d.ts +115 -0
- package/dist/members/consent-service.js +179 -0
- package/dist/members/member-admin-writes.d.ts +73 -0
- package/dist/members/member-admin-writes.js +149 -0
- package/dist/members/member-challenge-request.d.ts +59 -0
- package/dist/members/member-challenge-request.js +145 -0
- package/dist/members/member-challenge.d.ts +37 -0
- package/dist/members/member-challenge.js +84 -0
- package/dist/members/member-credentials.d.ts +35 -0
- package/dist/members/member-credentials.js +57 -0
- package/dist/members/member-sign-in.d.ts +44 -0
- package/dist/members/member-sign-in.js +130 -0
- package/dist/members/member-validation.d.ts +5 -0
- package/dist/members/member-validation.js +13 -0
- package/dist/members/password-auth.d.ts +55 -0
- package/dist/members/password-auth.js +177 -0
- package/dist/members/ports.d.ts +455 -0
- package/dist/members/ports.js +21 -0
- package/dist/members/public-member-auth-response.d.ts +68 -0
- package/dist/members/public-member-auth-response.js +45 -0
- package/dist/members/public-member-response.d.ts +25 -0
- package/dist/members/public-member-response.js +15 -0
- package/dist/members/repo.d.ts +199 -0
- package/dist/members/repo.js +324 -0
- package/dist/members/repo.memory.d.ts +276 -0
- package/dist/members/repo.memory.js +395 -0
- package/dist/members/repo.rows.d.ts +153 -0
- package/dist/members/repo.rows.js +250 -0
- package/dist/members/repo.sessions.d.ts +80 -0
- package/dist/members/repo.sessions.js +166 -0
- package/dist/members/repo.sql.d.ts +9 -0
- package/dist/members/repo.sql.js +11 -0
- package/dist/members/subscriber-directory.d.ts +85 -0
- package/dist/members/subscriber-directory.js +70 -0
- package/dist/members/tool-registrations.d.ts +143 -0
- package/dist/members/tool-registrations.js +247 -0
- package/dist/members/trash-member.d.ts +24 -0
- package/dist/members/trash-member.js +24 -0
- package/dist/members/types.d.ts +321 -0
- package/dist/members/types.js +34 -0
- package/dist/members/write-service.d.ts +17 -0
- package/dist/members/write-service.js +15 -0
- package/dist/newsletter/agent-tools.d.ts +20 -0
- package/dist/newsletter/agent-tools.js +236 -0
- package/dist/newsletter/campaign-write-service.d.ts +92 -0
- package/dist/newsletter/campaign-write-service.js +190 -0
- package/dist/newsletter/campaign.d.ts +53 -0
- package/dist/newsletter/campaign.js +95 -0
- package/dist/newsletter/confirmation.d.ts +75 -0
- package/dist/newsletter/confirmation.js +142 -0
- package/dist/newsletter/data-module-manifest.d.ts +68 -0
- package/dist/newsletter/data-module-manifest.js +126 -0
- package/dist/newsletter/delivery/tool-registrations.d.ts +67 -0
- package/dist/newsletter/delivery/tool-registrations.js +229 -0
- package/dist/newsletter/errors.d.ts +93 -0
- package/dist/newsletter/errors.js +93 -0
- package/dist/newsletter/hooks.d.ts +59 -0
- package/dist/newsletter/hooks.js +49 -0
- package/dist/newsletter/http-error-responses.d.ts +17 -0
- package/dist/newsletter/http-error-responses.js +96 -0
- package/dist/newsletter/launch-gate.d.ts +62 -0
- package/dist/newsletter/launch-gate.js +29 -0
- package/dist/newsletter/lists.d.ts +60 -0
- package/dist/newsletter/lists.js +83 -0
- package/dist/newsletter/ports.d.ts +283 -0
- package/dist/newsletter/ports.js +2 -0
- package/dist/newsletter/repo-sends.d.ts +82 -0
- package/dist/newsletter/repo-sends.js +178 -0
- package/dist/newsletter/repo-subscribers.d.ts +83 -0
- package/dist/newsletter/repo-subscribers.js +215 -0
- package/dist/newsletter/repo.d.ts +61 -0
- package/dist/newsletter/repo.js +147 -0
- package/dist/newsletter/repo.memory.d.ts +202 -0
- package/dist/newsletter/repo.memory.js +260 -0
- package/dist/newsletter/repo.rows.d.ts +221 -0
- package/dist/newsletter/repo.rows.js +260 -0
- package/dist/newsletter/save-guard.d.ts +32 -0
- package/dist/newsletter/save-guard.js +27 -0
- package/dist/newsletter/send-pipeline.d.ts +240 -0
- package/dist/newsletter/send-pipeline.js +514 -0
- package/dist/newsletter/subscriptions.d.ts +87 -0
- package/dist/newsletter/subscriptions.js +119 -0
- package/dist/newsletter/tool-registrations.d.ts +89 -0
- package/dist/newsletter/tool-registrations.deps.d.ts +9 -0
- package/dist/newsletter/tool-registrations.deps.js +9 -0
- package/dist/newsletter/tool-registrations.js +133 -0
- package/dist/newsletter/tool-registrations.read.d.ts +76 -0
- package/dist/newsletter/tool-registrations.read.js +140 -0
- package/dist/newsletter/tool-registrations.write.d.ts +54 -0
- package/dist/newsletter/tool-registrations.write.js +229 -0
- package/dist/newsletter/types.d.ts +279 -0
- package/dist/newsletter/types.js +23 -0
- package/dist/newsletter/unsubscribe.d.ts +41 -0
- package/dist/newsletter/unsubscribe.js +100 -0
- package/dist/project-keys/attached-vault.d.ts +23 -0
- package/dist/project-keys/attached-vault.js +65 -0
- package/dist/project-keys/create-vault.d.ts +17 -0
- package/dist/project-keys/create-vault.js +29 -0
- package/dist/project-keys/service.d.ts +133 -0
- package/dist/project-keys/service.js +128 -0
- package/dist/project-keys/site-references.d.ts +30 -0
- package/dist/project-keys/site-references.js +63 -0
- package/dist/project-keys/site-sealer.d.ts +28 -0
- package/dist/project-keys/site-sealer.js +64 -0
- package/dist/project-keys/sql/attachments.d.ts +33 -0
- package/dist/project-keys/sql/attachments.js +55 -0
- package/dist/project-keys/tools.d.ts +86 -0
- package/dist/project-keys/tools.js +66 -0
- package/dist/public-http/routes/mail/feedback.d.ts +44 -0
- package/dist/public-http/routes/mail/feedback.js +17 -0
- package/dist/public-http/routes/newsletter/confirm.d.ts +38 -0
- package/dist/public-http/routes/newsletter/confirm.js +33 -0
- package/dist/public-http/routes/newsletter/page.d.ts +29 -0
- package/dist/public-http/routes/newsletter/page.js +34 -0
- package/dist/public-http/routes/newsletter/unsubscribe.d.ts +33 -0
- package/dist/public-http/routes/newsletter/unsubscribe.js +35 -0
- package/dist/react/auth/Passkeys.d.ts +2 -34
- package/dist/react/auth/RecoveryCodesCard.d.ts +27 -0
- package/dist/react/auth/RecoveryCodesCard.hooks.d.ts +67 -0
- package/dist/react/auth/RecoveryCodesCard.hooks.js +38 -0
- package/dist/react/auth/RecoveryCodesCard.js +56 -0
- package/dist/react/auth/TotpSettings.d.ts +2 -23
- package/dist/react/auth/local-owner-signin.d.ts +40 -0
- package/dist/react/auth/local-owner-signin.js +25 -0
- package/dist/react/auth/owner-mfa-api.d.ts +10 -0
- package/dist/react/auth/owner-mfa-api.js +17 -0
- package/dist/react/auth/owner-passkey-api.d.ts +11 -0
- package/dist/react/auth/owner-passkey-api.js +17 -0
- package/dist/react/auth/owner-recovery-api.d.ts +51 -0
- package/dist/react/auth/owner-recovery-api.js +29 -0
- package/dist/react/auth/owner-request.d.ts +7 -0
- package/dist/react/auth/owner-request.js +2 -0
- package/dist/react/index.d.ts +10 -0
- package/dist/react/index.js +6 -0
- package/dist/react/mail/Email.d.ts +20 -0
- package/dist/react/mail/Email.js +143 -0
- package/dist/react/mail/EmailProviderTab.d.ts +34 -0
- package/dist/react/mail/EmailProviderTab.js +132 -0
- package/dist/react/mail/EmailSegments.d.ts +24 -0
- package/dist/react/mail/EmailSegments.js +15 -0
- package/dist/react/mail/EmailTemplateEditor.d.ts +146 -0
- package/dist/react/mail/EmailTemplateEditor.js +116 -0
- package/dist/react/mail/email-view.types.d.ts +236 -0
- package/dist/react/mail/email-view.types.js +2 -0
- package/dist/react/members/Members.d.ts +5 -3
- package/dist/react/members/Members.js +3 -3
- package/dist/react/members/api/members-api.d.ts +37 -0
- package/dist/react/members/api/members-api.js +16 -0
- package/dist/react/members/hooks/use-members.hooks.js +2 -1
- package/dist/react/members/members-i18n.d.ts +23 -0
- package/dist/react/members/members-i18n.js +25 -0
- package/dist/react/members/members-i18n.locales-a.d.ts +4 -0
- package/dist/react/members/members-i18n.locales-a.js +294 -0
- package/dist/react/members/members-i18n.locales-b.d.ts +4 -0
- package/dist/react/members/members-i18n.locales-b.js +265 -0
- package/dist/react/models.d.ts +1 -49
- package/dist/react/ports.d.ts +3 -143
- package/dist/react/roles/api/roles-api.d.ts +74 -0
- package/dist/react/roles/api/roles-api.js +22 -0
- package/dist/react/testing.js +18 -9
- package/dist/react/users/UsersPanel.d.ts +30 -0
- package/dist/react/users/UsersPanel.hooks.d.ts +8 -0
- package/dist/react/users/UsersPanel.hooks.js +9 -0
- package/dist/react/users/UsersPanel.js +9 -0
- package/dist/react/users/api/users-api.d.ts +65 -0
- package/dist/react/users/api/users-api.js +46 -0
- package/dist/react/users/hooks/use-localized-users.hooks.d.ts +43 -0
- package/dist/react/users/hooks/use-localized-users.hooks.js +15 -0
- package/dist/react/users/hooks/use-users-state.hooks.d.ts +18 -18
- package/dist/react/users/password-reset-notice.d.ts +8 -0
- package/dist/react/users/password-reset-notice.js +36 -0
- package/dist/server/admin-crud-service.d.ts +4 -10
- package/dist/server/admin-crud-service.js +20 -6
- package/dist/server/agent-tool-registrations.js +26 -7
- package/dist/server/agent-tools.js +22 -7
- package/dist/server/auth-challenge.d.ts +1 -1
- package/dist/server/auth-service.js +2 -1
- package/dist/server/grant-service.d.ts +1 -0
- package/dist/server/grant-service.js +7 -4
- package/dist/server/mfa/passkey-service.d.ts +2 -2
- package/dist/server/mfa/passkey-service.js +1 -1
- package/dist/server/mfa/service.js +6 -4
- package/dist/server/repo.memory.d.ts +30 -2
- package/dist/server/repo.memory.js +58 -4
- package/dist/server/seed.js +3 -3
- package/dist/server/sql/assignments.d.ts +90 -0
- package/dist/server/sql/assignments.js +128 -0
- package/dist/server/sql/index.d.ts +6 -0
- package/dist/server/sql/index.js +5 -0
- package/dist/server/sql/kernel.d.ts +9 -0
- package/dist/server/sql/kernel.js +2 -0
- package/dist/server/sql/mfa.d.ts +36 -0
- package/dist/server/sql/mfa.js +51 -0
- package/dist/server/sql/passkeys.d.ts +25 -0
- package/dist/server/sql/passkeys.js +33 -0
- package/dist/server/sql/recovery-codes.d.ts +22 -0
- package/dist/server/sql/recovery-codes.js +32 -0
- package/package.json +909 -11
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { agentHandle } from '@jini-ai/core/agent-handles';
|
|
3
|
+
import { resolveActiveTabId } from '@jini-ai/core/text';
|
|
4
|
+
import { EmailProviderTab } from './EmailProviderTab.js';
|
|
5
|
+
import { Segments } from './EmailSegments.js';
|
|
6
|
+
/**
|
|
7
|
+
* @file The mail screen — markup only; every tab's state comes from the host's hooks.
|
|
8
|
+
*
|
|
9
|
+
* Each tab's state is its own hook (`tabHooks`), mounted only while that tab shows so the page does
|
|
10
|
+
* not fire every read at once. No provider-name branches: everything shown comes from the server's
|
|
11
|
+
* data. A template's editor is its own page (`EmailTemplateEditor.tsx`).
|
|
12
|
+
*
|
|
13
|
+
* Tabs (overview | provider | sender | templates | activity) render through the host's `TabBar`; the
|
|
14
|
+
* host's URL owns the selection (`tabId`), so a reload or a link lands on that tab. The host owns the
|
|
15
|
+
* URL shape: this screen only calls `navigate({ tabId, part })`.
|
|
16
|
+
*
|
|
17
|
+
* Inside Overview, Provider, Sender & DNS and Activity, a segmented pill shows one section at a time
|
|
18
|
+
* (owner, 2026-10-22: the stacked cards were too much to take in). The host's URL owns that choice
|
|
19
|
+
* too, as `part`: an Overview section, a provider id, `sender`/`dns`, or an Activity section. A
|
|
20
|
+
* missing or unknown `part` falls back to the first section (Provider: the active provider — see
|
|
21
|
+
* `EmailProviderTab.tsx`).
|
|
22
|
+
*/
|
|
23
|
+
const TAB_IDS = ['overview', 'provider', 'sender', 'templates', 'activity'];
|
|
24
|
+
const TAB_LABELS = {
|
|
25
|
+
overview: 'Overview',
|
|
26
|
+
provider: 'Provider',
|
|
27
|
+
sender: 'Sender & DNS',
|
|
28
|
+
templates: 'Templates',
|
|
29
|
+
activity: 'Activity',
|
|
30
|
+
};
|
|
31
|
+
const OVERVIEW_PARTS = ['status', 'uses', 'test'];
|
|
32
|
+
const OVERVIEW_PART_LABELS = { status: 'Status', uses: 'What uses email', test: 'Send test email' };
|
|
33
|
+
const SENDER_PARTS = ['sender', 'dns'];
|
|
34
|
+
const SENDER_PART_LABELS = { sender: 'Sender', dns: 'DNS' };
|
|
35
|
+
const ACTIVITY_PARTS = ['sends', 'blocked', 'reports'];
|
|
36
|
+
const ACTIVITY_PART_LABELS = { sends: 'Recent sends', blocked: 'Blocked addresses', reports: 'Bounce and spam reports' };
|
|
37
|
+
/** `p` when it names one of `parts`, else the first. Pure. */
|
|
38
|
+
function pickPart({ parts, part }, _options = {}) {
|
|
39
|
+
return parts.find((id) => id === part) ?? parts[0];
|
|
40
|
+
}
|
|
41
|
+
/** A segmented pill over fixed parts, labelled through the dictionary. */
|
|
42
|
+
function PartSegments(props) {
|
|
43
|
+
const items = Object.keys(props.labels).map((key) => ({ key, label: props.copy.t({ locale: props.locale, key: props.labels[key] }) }));
|
|
44
|
+
return _jsx(Segments, { name: props.name, label: props.label, items: items, active: props.active, onSelect: props.onSelect, Segmented: props.kit.Segmented });
|
|
45
|
+
}
|
|
46
|
+
const SUMMARY = {
|
|
47
|
+
not_set_up: {
|
|
48
|
+
tone: 'warning',
|
|
49
|
+
chip: 'Not set up',
|
|
50
|
+
line: 'No mail provider is selected, so sign-in links, confirmations and form notifications are not sent.',
|
|
51
|
+
},
|
|
52
|
+
no_external_delivery: {
|
|
53
|
+
tone: 'neutral',
|
|
54
|
+
chip: 'No external delivery',
|
|
55
|
+
line: 'Mail is only written to the server log. Nothing is sent.',
|
|
56
|
+
},
|
|
57
|
+
needs_attention: { tone: 'warning', chip: 'Needs attention', line: 'Some mail cannot be sent. Check the Provider and Sender & DNS tabs.' },
|
|
58
|
+
configured: { tone: 'ok', chip: 'Configured', line: 'A provider is selected and its key is saved.' },
|
|
59
|
+
};
|
|
60
|
+
function StatusBody(props) {
|
|
61
|
+
const { view, locale, kit, copy } = props;
|
|
62
|
+
if (view.kind === 'loading')
|
|
63
|
+
return _jsx("p", { className: "jini-field-hint", role: "status", children: copy.t({ locale, key: 'Loading email status…' }) });
|
|
64
|
+
if (view.kind === 'forbidden')
|
|
65
|
+
return _jsx("p", { className: "jini-field-hint", children: copy.t({ locale, key: "You don't have permission to view email status." }) });
|
|
66
|
+
if (view.kind === 'error') {
|
|
67
|
+
return (_jsxs("div", { className: "email-row", role: "alert", children: [_jsx(kit.Chip, { tone: "warning", children: copy.t({ locale, key: 'Status unavailable' }) }), _jsx("button", { type: "button", className: "btn-secondary", onClick: props.retry, ...agentHandle({ handle: 'email-status-retry' }, { role: 'button', label: 'Retry the email status read' }), children: copy.t({ locale, key: 'Retry' }) })] }));
|
|
68
|
+
}
|
|
69
|
+
const summary = SUMMARY[props.rules.summarize({ status: view.status })];
|
|
70
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: "email-row", children: [_jsx(kit.Chip, { tone: summary.tone, children: copy.t({ locale, key: summary.chip }) }), _jsx("span", { className: "jini-field-hint", children: copy.t({ locale, key: summary.line }) })] }), _jsx(kit.StatusFacts, { status: view.status, locale: locale }), _jsx("p", { className: "jini-field-hint", children: copy.t({ locale, key: 'This checks configuration only. It does not prove that mail arrives.' }) })] }));
|
|
71
|
+
}
|
|
72
|
+
/** Overview's hook stays mounted across its segments, so the uses read and a typed test address survive a switch. */
|
|
73
|
+
function OverviewTab(props) {
|
|
74
|
+
const controller = props.hooks.overview();
|
|
75
|
+
const part = pickPart({ parts: OVERVIEW_PARTS, part: props.part });
|
|
76
|
+
const { Overview } = props.parts;
|
|
77
|
+
return (_jsxs(_Fragment, { children: [_jsx(PartSegments, { name: "email-overview-part", label: props.label, labels: OVERVIEW_PART_LABELS, active: part, locale: props.locale, onSelect: (next) => props.onPart({ next }), kit: props.kit, copy: props.copy }), part === 'status' ? props.status : _jsx(Overview, { controller: controller, locale: props.locale, part: part })] }));
|
|
78
|
+
}
|
|
79
|
+
function ProviderTab(props) {
|
|
80
|
+
const controller = props.hooks.provider({ onChanged: props.status.retry });
|
|
81
|
+
return (_jsx(EmailProviderTab, { controller: controller, status: props.status.view.kind === 'loaded' ? props.status.view.status : null, locale: props.locale, selectedId: props.part, onSelect: (next) => props.onPart({ next }), kit: props.kit, copy: props.copy, rules: props.rules }));
|
|
82
|
+
}
|
|
83
|
+
function SenderTab(props) {
|
|
84
|
+
const controller = props.hooks.sender({ onChanged: props.status.retry });
|
|
85
|
+
const part = pickPart({ parts: SENDER_PARTS, part: props.part });
|
|
86
|
+
const { Sender } = props.parts;
|
|
87
|
+
return (_jsxs(_Fragment, { children: [_jsx(PartSegments, { name: "email-sender-part", label: props.label, labels: SENDER_PART_LABELS, active: part, locale: props.locale, onSelect: (next) => props.onPart({ next }), kit: props.kit, copy: props.copy }), _jsx(Sender, { controller: controller, warnings: props.status.view.kind === 'loaded' ? props.status.view.status.warnings ?? [] : [], locale: props.locale, part: part })] }));
|
|
88
|
+
}
|
|
89
|
+
function TemplatesTab(props) {
|
|
90
|
+
const { Templates } = props.parts;
|
|
91
|
+
return _jsx(Templates, { controller: props.hooks.templates({ newName: props.copy.t({ locale: props.locale, key: 'Untitled email' }) }), locale: props.locale });
|
|
92
|
+
}
|
|
93
|
+
/** Activity's hook stays mounted across its segments, so filters, searches and loaded pages survive a switch. */
|
|
94
|
+
function ActivityTab(props) {
|
|
95
|
+
const controller = props.hooks.activity();
|
|
96
|
+
const part = pickPart({ parts: ACTIVITY_PARTS, part: props.part });
|
|
97
|
+
const { Activity } = props.parts;
|
|
98
|
+
return (_jsxs(_Fragment, { children: [_jsx(PartSegments, { name: "email-activity-part", label: props.label, labels: ACTIVITY_PART_LABELS, active: part, locale: props.locale, onSelect: (next) => props.onPart({ next }), kit: props.kit, copy: props.copy }), _jsx(Activity, { controller: controller, locale: props.locale, part: part })] }));
|
|
99
|
+
}
|
|
100
|
+
/** The tab whose id is `next`, or undefined for an id this screen does not know. Pure. */
|
|
101
|
+
function knownTabId({ next }, _options = {}) {
|
|
102
|
+
return TAB_IDS.find((id) => id === next);
|
|
103
|
+
}
|
|
104
|
+
/** The active tab's body. Only that tab's hook mounts. */
|
|
105
|
+
function ActiveTab(props) {
|
|
106
|
+
const { activeId, partProps, controller } = props;
|
|
107
|
+
const { locale, copy, kit } = partProps;
|
|
108
|
+
const tabLabel = (id) => copy.t({ locale, key: TAB_LABELS[id] });
|
|
109
|
+
if (activeId === 'provider')
|
|
110
|
+
return _jsx(ProviderTab, { ...partProps, status: controller, rules: props.rules });
|
|
111
|
+
if (activeId === 'sender')
|
|
112
|
+
return _jsx(SenderTab, { ...partProps, label: tabLabel('sender'), status: controller });
|
|
113
|
+
if (activeId === 'templates')
|
|
114
|
+
return _jsx(TemplatesTab, { ...partProps });
|
|
115
|
+
if (activeId === 'activity')
|
|
116
|
+
return _jsx(ActivityTab, { ...partProps, label: tabLabel('activity') });
|
|
117
|
+
return (_jsx(OverviewTab, { ...partProps, label: tabLabel('overview'), status: (_jsx(kit.Section, { id: "status", title: copy.t({ locale, key: 'Status' }), hideTitle: true, children: _jsx(StatusBody, { view: controller.view, locale: locale, retry: controller.retry, kit: kit, copy: copy, rules: props.rules }) })) }));
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* The mail screen. `tabId` is the host's tab selection and `part` the section shown inside that tab;
|
|
121
|
+
* every hook, component, dictionary and rule is the host's, injected through props.
|
|
122
|
+
*/
|
|
123
|
+
export function Email(props) {
|
|
124
|
+
const controller = props.useEmailHook();
|
|
125
|
+
const { locale } = controller;
|
|
126
|
+
const { kit, copy } = props;
|
|
127
|
+
const themeBoundary = props.useAdminThemeBoundaryHook({}, {});
|
|
128
|
+
const activeId = resolveActiveTabId({ tabId: props.tabId, validIds: TAB_IDS, defaultId: 'overview' });
|
|
129
|
+
const tabs = TAB_IDS.map((id) => ({
|
|
130
|
+
id, label: copy.t({ locale, key: TAB_LABELS[id] }), handle: `email-tab-${id}`, handleLabel: `Switch to the ${TAB_LABELS[id]} tab of Email`,
|
|
131
|
+
}));
|
|
132
|
+
const partProps = {
|
|
133
|
+
hooks: props.tabHooks, locale, part: props.part, kit, copy, parts: props.parts,
|
|
134
|
+
onPart: ({ next }, _options = {}) => props.navigate({ tabId: activeId, part: next }),
|
|
135
|
+
};
|
|
136
|
+
const onTab = (next) => {
|
|
137
|
+
const tabId = knownTabId({ next });
|
|
138
|
+
if (tabId !== undefined)
|
|
139
|
+
props.navigate({ tabId, part: null });
|
|
140
|
+
};
|
|
141
|
+
return (_jsxs("div", { className: "page email-page", children: [_jsx("div", { className: "page-header", children: _jsxs("div", { className: "page-header-text", children: [_jsx("p", { className: "page-kicker", children: copy.navLabel({ locale, key: 'Administration' }) }), _jsx("h1", { className: "page-title", children: copy.navLabel({ locale, key: 'Email' }) }), _jsx("p", { className: "page-description", children: copy.t({ locale, key: 'Sign-in links, confirmations and form notifications depend on email.' }) })] }) }), _jsx(kit.TabBar, { ariaLabel: copy.navLabel({ locale, key: 'Email' }), tabs: tabs, activeId: activeId, onChange: onTab, containerHandle: "email-tab-bar" }), _jsx("div", { className: "settings-ui-section settings-ui-section--page-flow email-sections", ...themeBoundary, children: _jsx(ActiveTab, { activeId: activeId, partProps: partProps, controller: controller, rules: props.rules }) })] }));
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=Email.js.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { EmailCopy, EmailKit, EmailProviderChoice, EmailProviderControl, EmailProviderView, EmailRules, EmailStatusShape } from './email-view.types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The card to show: `selectedId` when installed, else the provider sending all mail, else one
|
|
4
|
+
* sending some, else the first. Pure. `isFullyActive` is the host's rule, passed in.
|
|
5
|
+
*/
|
|
6
|
+
export declare function shownProviderId<P extends Pick<EmailProviderView, 'id' | 'lanes'>>({ providers, selectedId, isFullyActive }: {
|
|
7
|
+
providers: readonly P[];
|
|
8
|
+
selectedId: string | null | undefined;
|
|
9
|
+
isFullyActive: (required: {
|
|
10
|
+
provider: Pick<P, 'lanes'>;
|
|
11
|
+
}) => boolean;
|
|
12
|
+
}, _options?: Record<string, never>): string | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* A segment's name: the provider's label without a trailing "(…)" aside — "Console (local
|
|
15
|
+
* development, sends nothing)" reads as "Console"; the card keeps the full label. Pure.
|
|
16
|
+
*/
|
|
17
|
+
export declare function segmentLabel({ label }: {
|
|
18
|
+
label: string;
|
|
19
|
+
}, _options?: Record<string, never>): string;
|
|
20
|
+
export declare const ADD_PROVIDER_PART = "_add-provider";
|
|
21
|
+
export declare const CAPABILITIES_PART = "_capabilities";
|
|
22
|
+
export interface EmailProviderTabProps<P extends EmailProviderView, Ch extends EmailProviderChoice, S extends EmailStatusShape> {
|
|
23
|
+
readonly controller: EmailProviderControl<P, Ch>;
|
|
24
|
+
readonly status: S | null;
|
|
25
|
+
readonly locale: string;
|
|
26
|
+
readonly selectedId?: string | null | undefined;
|
|
27
|
+
readonly onSelect?: ((id: string) => void) | undefined;
|
|
28
|
+
readonly kit: EmailKit<S>;
|
|
29
|
+
readonly copy: EmailCopy;
|
|
30
|
+
readonly rules: EmailRules<S, P, Ch>;
|
|
31
|
+
}
|
|
32
|
+
/** The Provider tab: one provider card per segment, Add provider, Capabilities, and the switch confirmation. */
|
|
33
|
+
export declare function EmailProviderTab<P extends EmailProviderView, Ch extends EmailProviderChoice, S extends EmailStatusShape>(props: EmailProviderTabProps<P, Ch, S>): import("react").JSX.Element;
|
|
34
|
+
//# sourceMappingURL=EmailProviderTab.d.ts.map
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { agentHandle, agentHandleSegment } from '@jini-ai/core/agent-handles';
|
|
3
|
+
import { ConfirmDialog, SecretInput } from '../kit.js';
|
|
4
|
+
import { Segments } from './EmailSegments.js';
|
|
5
|
+
const LANE_STATE = {
|
|
6
|
+
ready: { tone: 'ok', label: 'Ready' },
|
|
7
|
+
unconfigured: { tone: 'warning', label: 'Not set' },
|
|
8
|
+
unknown_provider: { tone: 'warning', label: 'Not set' },
|
|
9
|
+
missing_credential: { tone: 'warning', label: 'Key not saved' },
|
|
10
|
+
local_only: { tone: 'neutral', label: 'No external delivery' },
|
|
11
|
+
};
|
|
12
|
+
const LANE_LABEL = { transactional: 'Transactional mail', bulk: 'Bulk mail' };
|
|
13
|
+
function Lanes(props) {
|
|
14
|
+
const { status, locale, kit, copy } = props;
|
|
15
|
+
const lanes = status?.lanes ?? [];
|
|
16
|
+
if (lanes.length === 0)
|
|
17
|
+
return null;
|
|
18
|
+
const label = props.rules.providerLabel({ locale, providers: props.providers });
|
|
19
|
+
return (_jsx("dl", { className: "email-facts", children: lanes.map((lane) => {
|
|
20
|
+
const state = LANE_STATE[lane.state] ?? { tone: 'neutral', label: lane.state };
|
|
21
|
+
return (_jsxs("div", { className: "email-fact", children: [_jsx("dt", { className: "jini-field-label", children: copy.t({ locale, key: LANE_LABEL[lane.lane] }) }), _jsxs("dd", { children: [_jsx("span", { className: "jini-field-hint", children: label(lane.providerId) }), _jsx(kit.Chip, { tone: state.tone, children: copy.t({ locale, key: state.label }) })] })] }, lane.lane));
|
|
22
|
+
}) }));
|
|
23
|
+
}
|
|
24
|
+
/** The input type for a declared non-secret field. Pure. */
|
|
25
|
+
function inputType(field) {
|
|
26
|
+
return field.type === 'text' ? 'text' : field.type;
|
|
27
|
+
}
|
|
28
|
+
function KeyField(props) {
|
|
29
|
+
const { provider, field, controller, locale, copy } = props;
|
|
30
|
+
const key = field.key;
|
|
31
|
+
const id = `email-provider-${provider.id}-${field.key}`;
|
|
32
|
+
const secret = field.type === 'secret';
|
|
33
|
+
const replacing = secret && provider.credential.saved;
|
|
34
|
+
const placeholder = replacing ? copy.t({ locale, key: 'Saved — enter a new key to replace it' }) : field.placeholder ?? field.defaultValue;
|
|
35
|
+
const inputProps = {
|
|
36
|
+
id,
|
|
37
|
+
className: 'jini-input',
|
|
38
|
+
spellCheck: false,
|
|
39
|
+
value: controller.drafts[provider.id]?.[key] ?? '',
|
|
40
|
+
placeholder,
|
|
41
|
+
onChange: (event) => controller.setDraftField(provider.id, key, event.target.value),
|
|
42
|
+
...agentHandle({ handle: `email-provider-${provider.id}-${agentHandleSegment({ value: field.key })}` }, { role: 'field', label: `${provider.label} ${field.label}` }),
|
|
43
|
+
};
|
|
44
|
+
return (_jsxs("div", { className: "jini-field email-field", children: [_jsx("label", { className: "jini-field-label", htmlFor: id, children: field.label }), _jsx("div", { className: "email-input-row", children: secret ? (
|
|
45
|
+
// `new-password`, not `off`, on the key: Chrome ignores `off` and silently filled the admin
|
|
46
|
+
// sign-in into these fields (the same reason as the host's access-token input).
|
|
47
|
+
_jsx(SecretInput, { label: field.label, autoComplete: "new-password", ...inputProps })) : (_jsx("input", { type: inputType(field), autoComplete: "off", ...inputProps })) }), field.help ? _jsx("span", { className: "jini-field-hint", children: field.help }) : null] }));
|
|
48
|
+
}
|
|
49
|
+
function ProviderChips({ provider, locale, kit, copy, rules }) {
|
|
50
|
+
const active = provider.lanes.length > 0;
|
|
51
|
+
const saved = provider.credential.saved;
|
|
52
|
+
return (_jsxs("div", { className: "email-row", children: [_jsx("strong", { className: "email-provider-name", children: provider.label }), active ? _jsx(kit.Chip, { tone: "ok", children: copy.t({ locale, key: rules.isFullyActive({ provider }) ? 'Active' : 'Active for one lane' }) }) : null, provider.credential.required ? _jsx(kit.Chip, { tone: saved ? 'ok' : 'warning', children: copy.t({ locale, key: saved ? 'Key saved' : 'Key not saved' }) }) : null, provider.hosted ? null : _jsx(kit.Chip, { tone: "neutral", children: copy.t({ locale, key: 'Local only' }) })] }));
|
|
53
|
+
}
|
|
54
|
+
function ProviderKeyForm(props) {
|
|
55
|
+
const { provider, controller, locale, copy, rules } = props;
|
|
56
|
+
const fields = provider.credential.required ? provider.setup.fields : [];
|
|
57
|
+
if (fields.length === 0)
|
|
58
|
+
return null;
|
|
59
|
+
const updatedAt = provider.credential.saved ? provider.credential.updatedAt : undefined;
|
|
60
|
+
return (_jsxs("form", { className: "email-provider-form", onSubmit: (event) => { event.preventDefault(); void controller.saveKey(provider); }, children: [updatedAt ? _jsx("span", { className: "jini-field-hint", children: copy.t({ locale, key: 'Key updated {when}' }).replace('{when}', () => rules.when({ iso: updatedAt, locale })) }) : null, fields.map((field) => _jsx(KeyField, { ...props, field: field }, field.key)), _jsxs("div", { className: "email-row", children: [_jsx("button", { type: "submit", className: "btn-secondary", disabled: controller.busyId === provider.id, ...agentHandle({ handle: `email-provider-${provider.id}-save` }, { role: 'button', label: `Save the ${provider.label} key` }), children: copy.t({ locale, key: provider.credential.saved ? 'Replace key' : 'Save key' }) }), provider.setup.helpUrl ? _jsx("a", { href: provider.setup.helpUrl, target: "_blank", rel: "noreferrer", children: copy.t({ locale, key: 'Where do I get a key?' }) }) : null] })] }));
|
|
61
|
+
}
|
|
62
|
+
function ProviderSwitch({ provider, controller, locale, copy, rules }) {
|
|
63
|
+
if (rules.isFullyActive({ provider }))
|
|
64
|
+
return null;
|
|
65
|
+
return (_jsxs(_Fragment, { children: [provider.selectable || !provider.refusal ? null : _jsx("span", { className: "jini-field-hint", children: copy.t({ locale, key: provider.credential.required && !provider.credential.saved ? "Add this provider's key first." : 'Not set up' }) }), _jsx("div", { className: "email-row", children: _jsx("button", { type: "button", disabled: controller.busyId === provider.id || !provider.selectable, onClick: () => controller.askSwitch(provider), ...agentHandle({ handle: `email-provider-${provider.id}-use` }, { role: 'button', label: `Send all mail with ${provider.label}` }), children: copy.t({ locale, key: 'Use this provider' }) }) })] }));
|
|
66
|
+
}
|
|
67
|
+
function ProviderNoticeLine({ provider, controller, locale, copy }) {
|
|
68
|
+
const notice = controller.notice;
|
|
69
|
+
if (notice?.providerId !== provider.id)
|
|
70
|
+
return null;
|
|
71
|
+
const error = notice.tone === 'error';
|
|
72
|
+
return _jsx("p", { className: error ? 'jini-field-error' : 'jini-field-hint', role: error ? 'alert' : 'status', children: copy.t({ locale, key: notice.text }) });
|
|
73
|
+
}
|
|
74
|
+
function ProviderCard(props) {
|
|
75
|
+
return (_jsxs("li", { className: "email-provider", ...agentHandle({ handle: `email-provider-${props.provider.id}` }, { role: 'region', label: `Mail provider ${props.provider.label}` }), children: [_jsx(ProviderChips, { ...props }), _jsx(ProviderKeyForm, { ...props }), _jsx(ProviderSwitch, { ...props }), _jsx(ProviderNoticeLine, { ...props })] }));
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The card to show: `selectedId` when installed, else the provider sending all mail, else one
|
|
79
|
+
* sending some, else the first. Pure. `isFullyActive` is the host's rule, passed in.
|
|
80
|
+
*/
|
|
81
|
+
export function shownProviderId({ providers, selectedId, isFullyActive }, _options = {}) {
|
|
82
|
+
const pick = providers.find((p) => p.id === selectedId) ?? providers.find((p) => isFullyActive({ provider: p })) ?? providers.find((p) => p.lanes.length > 0) ?? providers[0];
|
|
83
|
+
return pick?.id;
|
|
84
|
+
}
|
|
85
|
+
/** `label` minus one trailing `(…)` group (no nested parentheses) and the whitespace around it;
|
|
86
|
+
* `label` unchanged when it does not end in one. Same result as
|
|
87
|
+
* `label.replace(/\s*\([^()]*\)\s*$/, "")`, in one linear pass. */
|
|
88
|
+
function withoutTrailingParenthetical({ label }, _options = {}) {
|
|
89
|
+
const body = label.trimEnd();
|
|
90
|
+
if (!body.endsWith(')'))
|
|
91
|
+
return label;
|
|
92
|
+
const open = body.lastIndexOf('(');
|
|
93
|
+
if (open === -1 || body.slice(open + 1, -1).includes(')'))
|
|
94
|
+
return label;
|
|
95
|
+
return body.slice(0, open).trimEnd();
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* A segment's name: the provider's label without a trailing "(…)" aside — "Console (local
|
|
99
|
+
* development, sends nothing)" reads as "Console"; the card keeps the full label. Pure.
|
|
100
|
+
*/
|
|
101
|
+
export function segmentLabel({ label }, _options = {}) {
|
|
102
|
+
return withoutTrailingParenthetical({ label }) || label;
|
|
103
|
+
}
|
|
104
|
+
export const ADD_PROVIDER_PART = '_add-provider';
|
|
105
|
+
export const CAPABILITIES_PART = '_capabilities';
|
|
106
|
+
function AddProvider(props) {
|
|
107
|
+
const { controller, locale, copy, rules } = props;
|
|
108
|
+
const selectAdded = (id) => { if (id)
|
|
109
|
+
props.onSelect?.(id); };
|
|
110
|
+
return (_jsxs(_Fragment, { children: [controller.addError ? _jsxs("div", { className: "email-row", role: "alert", children: [_jsx("span", { className: "jini-field-error", children: copy.t({ locale, key: controller.addError }) }), _jsx("button", { type: "button", className: "btn-secondary", disabled: controller.adding !== null, onClick: () => void controller.retryAdd().then(selectAdded), ...agentHandle({ handle: 'email-add-provider-retry' }, { role: 'button', label: 'Retry adding an email provider' }), children: copy.t({ locale, key: 'Retry' }) })] }) : null, controller.choices === null && !controller.addError ? _jsx("p", { className: "jini-field-hint", role: "status", children: copy.t({ locale, key: 'Loading…' }) }) : (_jsxs("ul", { className: "email-list", children: [controller.choices?.map((plugin) => _jsxs("li", { className: "email-row", children: [_jsx("span", { className: "email-provider-name", children: rules.displayName(plugin) }), _jsx("span", { className: "jini-field-hint", children: plugin.summary ?? plugin.description }), _jsx("button", { type: "button", disabled: controller.adding !== null, onClick: () => void controller.addProvider({ pluginId: plugin.pluginId }).then(selectAdded), ...agentHandle({ handle: `email-add-provider-${plugin.pluginId}` }, { role: 'button', label: `Add ${rules.displayName(plugin)} as an email provider` }), children: copy.t({ locale, key: controller.adding === plugin.pluginId ? 'Adding…' : 'Add' }) })] }, plugin.pluginId)), controller.choices?.length === 0 && !controller.addError ? _jsx("li", { className: "jini-field-hint", children: copy.t({ locale, key: 'No more email providers to add.' }) }) : null] }))] }));
|
|
111
|
+
}
|
|
112
|
+
/** The segment to show: one of the two fixed parts when named, else a provider card, else Add provider. Pure. */
|
|
113
|
+
function shownPart({ providers, selectedId, isFullyActive }) {
|
|
114
|
+
if (selectedId === ADD_PROVIDER_PART || selectedId === CAPABILITIES_PART)
|
|
115
|
+
return selectedId;
|
|
116
|
+
return shownProviderId({ providers, selectedId, isFullyActive }) ?? ADD_PROVIDER_PART;
|
|
117
|
+
}
|
|
118
|
+
function ProviderCards(props) {
|
|
119
|
+
const { providers, controller, locale, kit, copy, rules } = props;
|
|
120
|
+
const deps = { kit, copy, rules };
|
|
121
|
+
const shownId = shownPart({ providers, selectedId: props.selectedId, isFullyActive: rules.isFullyActive });
|
|
122
|
+
const items = [...providers.map((p) => ({ key: p.id, label: segmentLabel({ label: p.label }) })),
|
|
123
|
+
{ key: ADD_PROVIDER_PART, label: copy.t({ locale, key: '+ Add provider' }) }, { key: CAPABILITIES_PART, label: copy.t({ locale, key: 'Capabilities' }) }];
|
|
124
|
+
return (_jsxs(_Fragment, { children: [_jsx(Segments, { name: "email-provider-pick", label: copy.t({ locale, key: 'Provider' }), active: shownId, onSelect: (id) => props.onSelect?.(id), items: items, Segmented: kit.Segmented }), shownId === CAPABILITIES_PART ? _jsx(Lanes, { ...deps, status: props.status, providers: providers, locale: locale }) : null, shownId === ADD_PROVIDER_PART ? _jsx(AddProvider, { ...deps, controller: controller, locale: locale, onSelect: props.onSelect }) : null, _jsx("ul", { className: "email-list email-providers", children: providers.filter((p) => p.id === shownId).map((provider) => _jsx(ProviderCard, { ...deps, provider: provider, controller: controller, locale: locale }, provider.id)) })] }));
|
|
125
|
+
}
|
|
126
|
+
/** The Provider tab: one provider card per segment, Add provider, Capabilities, and the switch confirmation. */
|
|
127
|
+
export function EmailProviderTab(props) {
|
|
128
|
+
const { controller, locale, kit, copy, rules } = props;
|
|
129
|
+
const pending = controller.pendingSwitch;
|
|
130
|
+
return (_jsxs(kit.Section, { id: "provider", title: copy.t({ locale, key: 'Provider' }), hideTitle: true, children: [controller.addWarning ? _jsx("p", { className: "jini-field-hint", role: "status", children: controller.addWarning }) : null, _jsx(kit.Loaded, { view: controller.view, locale: locale, retry: controller.reload, children: (report) => (_jsxs(_Fragment, { children: [_jsx(ProviderCards, { kit: kit, copy: copy, rules: rules, providers: report.providers, controller: controller, status: props.status, locale: locale, selectedId: props.selectedId, onSelect: props.onSelect }), report.refusals.length > 0 ? (_jsxs(_Fragment, { children: [_jsx("h3", { className: "jini-field-label email-subhead", children: copy.t({ locale, key: 'Not loaded' }) }), _jsx("ul", { className: "email-list", children: report.refusals.map((reason) => _jsx("li", { className: "jini-field-hint", children: reason }, reason)) })] })) : null] })) }), _jsx(ConfirmDialog, { open: pending !== null, agentHandle: "email-provider-switch", title: copy.t({ locale, key: 'Switch email provider?' }), body: _jsx("p", { children: copy.t({ locale, key: 'All email — sign-in links, confirmations, notifications and newsletters — will send with {provider}.' }).replace('{provider}', () => pending?.label ?? '') }), confirmLabel: copy.t({ locale, key: 'Switch' }), pending: pending !== null && controller.busyId === pending.id, onConfirm: () => void controller.confirmSwitch(), onCancel: () => controller.askSwitch(null) })] }));
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=EmailProviderTab.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ComponentType } from 'react';
|
|
2
|
+
import type { EmailSegmentedProps } from './email-view.types.js';
|
|
3
|
+
/**
|
|
4
|
+
* @file The mail screen's segmented pill: the host's segmented control (injected as `Segmented`) wrapped
|
|
5
|
+
* in the radiogroup the mail tabs share. Internal to `react/mail`; no package leaf.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* One section of a tab at a time, picked with a segmented pill (owner, 2026-10-22: "reduce the
|
|
9
|
+
* cognitive load" — stacked cards were too much). The injected `Segmented` renders real radios sharing
|
|
10
|
+
* `name`, so arrow keys move between segments; the `radiogroup` wrapper names the group. The caller owns
|
|
11
|
+
* the choice (the host keeps it in its URL).
|
|
12
|
+
*/
|
|
13
|
+
export declare function Segments(props: {
|
|
14
|
+
name: string;
|
|
15
|
+
label: string;
|
|
16
|
+
items: readonly {
|
|
17
|
+
key: string;
|
|
18
|
+
label: string;
|
|
19
|
+
}[];
|
|
20
|
+
active: string;
|
|
21
|
+
onSelect: (key: string) => void;
|
|
22
|
+
Segmented: ComponentType<EmailSegmentedProps>;
|
|
23
|
+
}): import("react").JSX.Element;
|
|
24
|
+
//# sourceMappingURL=EmailSegments.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* @file The mail screen's segmented pill: the host's segmented control (injected as `Segmented`) wrapped
|
|
4
|
+
* in the radiogroup the mail tabs share. Internal to `react/mail`; no package leaf.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* One section of a tab at a time, picked with a segmented pill (owner, 2026-10-22: "reduce the
|
|
8
|
+
* cognitive load" — stacked cards were too much). The injected `Segmented` renders real radios sharing
|
|
9
|
+
* `name`, so arrow keys move between segments; the `radiogroup` wrapper names the group. The caller owns
|
|
10
|
+
* the choice (the host keeps it in its URL).
|
|
11
|
+
*/
|
|
12
|
+
export function Segments(props) {
|
|
13
|
+
return (_jsx("div", { className: "email-segments", role: "radiogroup", "aria-label": props.label, children: _jsx(props.Segmented, { name: props.name, items: props.items.map((item) => ({ key: item.key, label: item.label, checked: item.key === props.active, change: () => props.onSelect(item.key) })) }) }));
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=EmailSegments.js.map
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import type { ComponentType, KeyboardEvent as ReactKeyboardEvent, ReactNode } from 'react';
|
|
2
|
+
import type { EmailKit, EmailLoadView, EmailStatusShape, EmailTranslate } from './email-view.types.js';
|
|
3
|
+
/**
|
|
4
|
+
* @file One email template's editor page, laid out like the host's page editor (owner, 2026-10-22):
|
|
5
|
+
* back arrow + name, an HTML | Preview tab bar with the device-width buttons, Save below it, then the
|
|
6
|
+
* full-width pane. Same chrome classes as the page editor (`content-editor-*`, `page-editor-toolbar`,
|
|
7
|
+
* `.segmented`, `page-html-source`) and the host's injected device-preview components; the page
|
|
8
|
+
* editor's translator (`copy.pageEditorT`) supplies the shared control words.
|
|
9
|
+
*
|
|
10
|
+
* No Interactive tab on purpose: a visual editor rewrites the HTML on save and can drop the
|
|
11
|
+
* template's field declarations in `<head>`.
|
|
12
|
+
*
|
|
13
|
+
* The preview uses the host's page-preview sandbox (`kit.previewSandbox`: scripts run, but with no
|
|
14
|
+
* same-origin access to the admin). "As sent" shows what a mail client gets — scripts stripped by
|
|
15
|
+
* the server, static HTML.
|
|
16
|
+
*/
|
|
17
|
+
export type EmailTemplateTab = 'html' | 'preview';
|
|
18
|
+
export type EmailPreviewMode = 'admin' | 'sent';
|
|
19
|
+
/** Members of the host's template editor controller that this page reads. */
|
|
20
|
+
export interface EmailTemplateEditorControl {
|
|
21
|
+
readonly view: EmailLoadView<{
|
|
22
|
+
readonly subject: string;
|
|
23
|
+
}>;
|
|
24
|
+
readonly html: string;
|
|
25
|
+
readonly setHtml: (html: string) => void;
|
|
26
|
+
readonly dirty: boolean;
|
|
27
|
+
readonly values: Readonly<Record<string, string>>;
|
|
28
|
+
readonly setValue: (field: string, value: string) => void;
|
|
29
|
+
readonly fieldNames: readonly string[];
|
|
30
|
+
readonly mode: EmailPreviewMode;
|
|
31
|
+
readonly setMode: (mode: EmailPreviewMode) => void;
|
|
32
|
+
readonly preview: {
|
|
33
|
+
readonly data: {
|
|
34
|
+
readonly subject: string;
|
|
35
|
+
readonly html: string;
|
|
36
|
+
readonly missingFields: readonly string[];
|
|
37
|
+
readonly undeclaredFields: readonly string[];
|
|
38
|
+
} | null;
|
|
39
|
+
readonly error: string | null;
|
|
40
|
+
readonly pending: boolean;
|
|
41
|
+
};
|
|
42
|
+
readonly saving: boolean;
|
|
43
|
+
readonly saveError: string | null;
|
|
44
|
+
readonly savedAt: string | null;
|
|
45
|
+
readonly save: () => Promise<void>;
|
|
46
|
+
readonly name: string;
|
|
47
|
+
readonly setName: (name: string) => void;
|
|
48
|
+
readonly commitName: () => Promise<void>;
|
|
49
|
+
readonly renameError: string | null;
|
|
50
|
+
}
|
|
51
|
+
/** Members of the host's editor view state (tab, device width, measured pane) that this page reads. */
|
|
52
|
+
export interface EmailTemplateViewControl<D extends string> {
|
|
53
|
+
readonly tab: EmailTemplateTab;
|
|
54
|
+
readonly setTab: (tab: EmailTemplateTab) => void;
|
|
55
|
+
readonly device: D;
|
|
56
|
+
readonly setDevice: (device: D) => void;
|
|
57
|
+
readonly frameRef: (node: HTMLDivElement | null) => void;
|
|
58
|
+
readonly paneWidth: number;
|
|
59
|
+
}
|
|
60
|
+
type EditorTab = {
|
|
61
|
+
id: EmailTemplateTab;
|
|
62
|
+
label: string;
|
|
63
|
+
};
|
|
64
|
+
export interface EmailTemplateEditorKit<D extends string> {
|
|
65
|
+
readonly Icon: ComponentType<{
|
|
66
|
+
name: 'arrow-left';
|
|
67
|
+
size: number;
|
|
68
|
+
'aria-hidden': 'true';
|
|
69
|
+
}>;
|
|
70
|
+
readonly Chip: EmailKit<EmailStatusShape>['Chip'];
|
|
71
|
+
readonly Loaded: EmailKit<EmailStatusShape>['Loaded'];
|
|
72
|
+
readonly DevicePreviewFrame: ComponentType<{
|
|
73
|
+
width: number;
|
|
74
|
+
frameRef: (node: HTMLDivElement | null) => void;
|
|
75
|
+
paneWidth: number;
|
|
76
|
+
children: ReactNode;
|
|
77
|
+
}>;
|
|
78
|
+
readonly DevicePreviewToggle: ComponentType<{
|
|
79
|
+
device: D;
|
|
80
|
+
setDevice: (device: D) => void;
|
|
81
|
+
t: (key: string) => string;
|
|
82
|
+
handlePrefix: string;
|
|
83
|
+
}>;
|
|
84
|
+
readonly devicePreviewWidths: Readonly<Record<D, number>>;
|
|
85
|
+
/** The host's page-preview iframe sandbox tokens. */
|
|
86
|
+
readonly previewSandbox: string;
|
|
87
|
+
readonly adminBase: string;
|
|
88
|
+
readonly adminHref: (required: {
|
|
89
|
+
routePath: string;
|
|
90
|
+
}) => string;
|
|
91
|
+
}
|
|
92
|
+
export interface EmailTemplateEditorHooks<C, V> {
|
|
93
|
+
readonly useEditorHook: (required: {
|
|
94
|
+
id: string;
|
|
95
|
+
}) => C;
|
|
96
|
+
readonly useAdminLocaleHook: () => string;
|
|
97
|
+
readonly useEmailTemplateViewHook: () => V;
|
|
98
|
+
readonly useTabBarKeyboardHook: (required: {
|
|
99
|
+
tabs: readonly EditorTab[];
|
|
100
|
+
activeId: string;
|
|
101
|
+
onChange: (id: string) => void;
|
|
102
|
+
}) => {
|
|
103
|
+
onKeyDown: (event: ReactKeyboardEvent<HTMLDivElement>) => void;
|
|
104
|
+
};
|
|
105
|
+
readonly useDirtyGuardHook: (required: {
|
|
106
|
+
current: boolean;
|
|
107
|
+
original: boolean | null;
|
|
108
|
+
}, optional: {
|
|
109
|
+
host: Window;
|
|
110
|
+
translate: (key: string) => string;
|
|
111
|
+
}) => {
|
|
112
|
+
confirmLeave: () => boolean;
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
export interface EmailTemplateEditorCopy {
|
|
116
|
+
readonly t: EmailTranslate;
|
|
117
|
+
readonly pageEditorT: EmailTranslate;
|
|
118
|
+
}
|
|
119
|
+
/** What the editor's key/leave guard reads. */
|
|
120
|
+
export type EmailTemplateEditorKeysArgs = {
|
|
121
|
+
controller: EmailTemplateEditorControl;
|
|
122
|
+
locale: string;
|
|
123
|
+
t: EmailTranslate;
|
|
124
|
+
adminBase: string;
|
|
125
|
+
useDirtyGuardHook: EmailTemplateEditorHooks<unknown, unknown>['useDirtyGuardHook'];
|
|
126
|
+
};
|
|
127
|
+
/** The save-state word beside the Save button, or null before any edit. Pure. */
|
|
128
|
+
export declare function editorStatus(controller: Pick<EmailTemplateEditorControl, 'saving' | 'dirty' | 'savedAt'>): string | null;
|
|
129
|
+
export interface EmailTemplateEditorProps<D extends string, C extends EmailTemplateEditorControl, V extends EmailTemplateViewControl<D>> {
|
|
130
|
+
readonly id: string;
|
|
131
|
+
readonly locale?: string | undefined;
|
|
132
|
+
readonly hooks: EmailTemplateEditorHooks<C, V>;
|
|
133
|
+
readonly kit: EmailTemplateEditorKit<D>;
|
|
134
|
+
readonly copy: EmailTemplateEditorCopy;
|
|
135
|
+
readonly resolveTabIndex: (required: {
|
|
136
|
+
tabs: readonly EditorTab[];
|
|
137
|
+
activeId: string;
|
|
138
|
+
tab: EditorTab;
|
|
139
|
+
}) => number;
|
|
140
|
+
/** The Ctrl/Cmd+S and leave-guard listeners; a test swaps them, the page defaults to this module's own. */
|
|
141
|
+
readonly useEditorKeysHook?: ((required: EmailTemplateEditorKeysArgs) => void) | undefined;
|
|
142
|
+
}
|
|
143
|
+
/** The editor page. Every hook, component and dictionary is the host's, injected through props. */
|
|
144
|
+
export declare function EmailTemplateEditor<D extends string, C extends EmailTemplateEditorControl, V extends EmailTemplateViewControl<D>>(props: EmailTemplateEditorProps<D, C, V>): import("react").JSX.Element;
|
|
145
|
+
export {};
|
|
146
|
+
//# sourceMappingURL=EmailTemplateEditor.d.ts.map
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import { agentHandle } from '@jini-ai/core/agent-handles';
|
|
4
|
+
const TABS = [
|
|
5
|
+
{ id: 'html', label: 'HTML' },
|
|
6
|
+
{ id: 'preview', label: 'Preview' },
|
|
7
|
+
];
|
|
8
|
+
function Fields(props) {
|
|
9
|
+
const { controller, locale, t, Chip } = props;
|
|
10
|
+
const missing = new Set(controller.preview.data?.missingFields ?? []);
|
|
11
|
+
const undeclared = new Set(controller.preview.data?.undeclaredFields ?? []);
|
|
12
|
+
return (_jsxs("details", { className: "email-template-fields", open: true, children: [_jsx("summary", { className: "jini-field-label", children: t({ locale, key: 'Fill-in fields (preview values)' }) }), controller.fieldNames.length === 0 ? (_jsx("p", { className: "jini-field-hint", children: t({ locale, key: 'No fill-in fields. Add {{name}} to the HTML to make one.' }) })) : (_jsx("div", { className: "email-template-field-list", children: controller.fieldNames.map((name) => (_jsxs("div", { className: "jini-field email-field", children: [_jsxs("label", { className: "jini-field-label", htmlFor: `email-template-field-${name}`, children: [_jsx("code", { children: `{{${name}}}` }), undeclared.has(name) ? _jsx(Chip, { tone: "warning", children: t({ locale, key: 'Not declared' }) }) : null] }), _jsx("input", { id: `email-template-field-${name}`, className: "jini-input", value: controller.values[name] ?? '', "aria-invalid": missing.has(name), onChange: (e) => controller.setValue(name, e.target.value), ...agentHandle({ handle: `email-template-field-${name}` }, { role: 'field', label: `Preview value for ${name}` }) })] }, name))) }))] }));
|
|
13
|
+
}
|
|
14
|
+
/** "As sent" sits beside the device buttons as one pressed/unpressed pill (Preview is the tab). */
|
|
15
|
+
function AsSentToggle(props) {
|
|
16
|
+
const { controller, locale, t } = props;
|
|
17
|
+
const sent = controller.mode === 'sent';
|
|
18
|
+
return (_jsx("div", { className: "segmented email-template-as-sent", role: "group", "aria-label": t({ locale, key: 'Preview mode' }), children: _jsx("button", { type: "button", "aria-pressed": sent, className: sent ? 'is-active' : undefined, onClick: () => controller.setMode(sent ? 'admin' : 'sent'), ...agentHandle({ handle: 'email-template-mode-sent' }, { role: 'button', label: 'Toggle the As sent preview (scripts stripped, what a mail client gets)' }), children: t({ locale, key: 'As sent' }) }) }));
|
|
19
|
+
}
|
|
20
|
+
function Preview(props) {
|
|
21
|
+
const { controller, view, locale, t, kit } = props;
|
|
22
|
+
const { data, error, pending } = controller.preview;
|
|
23
|
+
return (_jsxs("div", { className: "email-template-preview", children: [_jsx(Fields, { controller: controller, locale: locale, t: t, Chip: kit.Chip }), error ? _jsx("p", { className: "jini-field-error", role: "alert", children: t({ locale, key: error }) }) : null, controller.mode === 'sent' ? _jsx("p", { className: "jini-field-hint", children: t({ locale, key: "Mail apps don't run scripts, so they are removed when it sends." }) }) : null, _jsx(kit.DevicePreviewFrame, { width: kit.devicePreviewWidths[view.device], frameRef: view.frameRef, paneWidth: view.paneWidth, children: data ? (_jsx("iframe", { className: "page-preview-iframe", title: t({ locale, key: 'Email preview' }), sandbox: kit.previewSandbox, srcDoc: data.html, ...agentHandle({ handle: 'email-template-preview' }, { role: 'region', label: 'Live preview of this email' }) })) : (_jsx("p", { className: "jini-field-hint email-template-empty", children: t({ locale, key: pending ? 'Loading…' : 'Write some HTML to see it here.' }) })) })] }));
|
|
24
|
+
}
|
|
25
|
+
/** Back arrow, the template name as the title, and its subject where the page editor shows the slug. */
|
|
26
|
+
function Header(props) {
|
|
27
|
+
const { controller, locale, t, kit } = props;
|
|
28
|
+
const subject = controller.preview.data?.subject ?? (controller.view.kind === 'loaded' ? controller.view.data.subject : '');
|
|
29
|
+
return (_jsxs("div", { className: "content-editor-header", ...agentHandle({ handle: 'email-template-header' }, { role: 'region', label: "Editor header — the back link, the template's name and its subject" }), children: [_jsx("h1", { className: "visually-hidden", children: t({ locale, key: 'Templates' }) }), _jsx("a", { className: "content-editor-back", href: kit.adminHref({ routePath: '/email?tab=templates' }), "aria-label": `${props.pageT('Back')}: ${t({ locale, key: 'Templates' })}`, ...agentHandle({ handle: 'email-template-back' }, { role: 'link', label: 'Back to the email templates list' }), children: _jsx(kit.Icon, { name: "arrow-left", size: 22, "aria-hidden": "true" }) }), _jsx("label", { className: "visually-hidden", htmlFor: "email-template-name", children: t({ locale, key: 'Template name' }) }), _jsx("input", { id: "email-template-name", className: "editor-title content-editor-title email-template-name", value: controller.name, maxLength: 200, disabled: controller.view.kind !== 'loaded', onChange: (e) => controller.setName(e.target.value), onBlur: () => void controller.commitName(), onKeyDown: (e) => { if (e.key === 'Enter')
|
|
30
|
+
e.currentTarget.blur(); }, ...agentHandle({ handle: 'email-template-name' }, { role: 'field', label: 'Template name' }) }), subject ? (_jsxs("div", { className: "editor-slug email-template-subject", children: [_jsx("span", { children: t({ locale, key: 'Subject' }) }), _jsx("span", { className: "email-template-subject-text", title: subject, children: subject })] })) : null] }));
|
|
31
|
+
}
|
|
32
|
+
/** HTML | Preview tabs (the page editor's segmented tablist and keyboard contract), device widths, As sent. */
|
|
33
|
+
function Toolbar(props) {
|
|
34
|
+
const { controller, view, locale, t, kit, pageT } = props;
|
|
35
|
+
const { onKeyDown } = props.useTabBarKeyboardHook({ tabs: TABS, activeId: view.tab, onChange: (id) => view.setTab(id) });
|
|
36
|
+
return (_jsxs("div", { className: "page-editor-toolbar", children: [_jsxs("div", { className: "content-editor-toolbar-start", children: [_jsx("div", { className: "segmented", role: "tablist", "aria-label": pageT('Editor view'), onKeyDown: onKeyDown, children: TABS.map((entry) => (_jsx("button", { type: "button", role: "tab", "aria-selected": view.tab === entry.id, className: view.tab === entry.id ? 'is-active' : undefined, tabIndex: props.resolveTabIndex({ tabs: TABS, activeId: view.tab, tab: entry }), onClick: () => view.setTab(entry.id), ...agentHandle({ handle: `email-template-view-${entry.id}` }, { role: 'button', label: `Switch to the ${entry.label} view` }), children: pageT(entry.label) }, entry.id))) }), view.tab === 'preview' ? (_jsxs(_Fragment, { children: [_jsx(kit.DevicePreviewToggle, { device: view.device, setDevice: view.setDevice, t: pageT, handlePrefix: "email-template-preview-width" }), _jsx(AsSentToggle, { controller: controller, locale: locale, t: t })] })) : null] }), controller.preview.pending && view.tab === 'preview' ? _jsx("span", { className: "jini-field-hint", role: "status", children: t({ locale, key: 'Updating…' }) }) : null] }));
|
|
37
|
+
}
|
|
38
|
+
/** Save and its state word, in the row under the toolbar like the page editor's action row. */
|
|
39
|
+
function Actions(props) {
|
|
40
|
+
const { controller, locale, t } = props;
|
|
41
|
+
const status = editorStatus(controller);
|
|
42
|
+
return (_jsxs("div", { className: "editor-action-row content-action-row", ...agentHandle({ handle: 'email-template-actions' }, { role: 'region', label: 'Save and its status' }), children: [_jsx("div", { className: "content-action-group", children: _jsx("button", { type: "button", onClick: () => void controller.save(), disabled: !controller.dirty || controller.saving, ...agentHandle({ handle: 'email-template-save' }, { role: 'button', label: "Save this template's HTML" }), children: t({ locale, key: 'Save' }) }) }), status ? _jsx("span", { className: status === 'Saved' ? 'save-ok' : 'jini-field-hint', role: "status", children: t({ locale, key: status }) }) : null] }));
|
|
43
|
+
}
|
|
44
|
+
/** Whether an anchor replaces this editor through the host's SPA. Pure; other windows stay usable. */
|
|
45
|
+
function leavesEditor({ anchor, location, adminBase }, _options = {}) {
|
|
46
|
+
if (!replacesCurrentWindow(anchor))
|
|
47
|
+
return false;
|
|
48
|
+
const url = new URL(anchor.href, location.href);
|
|
49
|
+
const adminPath = url.pathname === adminBase || url.pathname.startsWith(`${adminBase}/`);
|
|
50
|
+
const routeChanged = url.pathname !== location.pathname || url.search !== location.search;
|
|
51
|
+
return url.origin === location.origin && adminPath && routeChanged;
|
|
52
|
+
}
|
|
53
|
+
/** Downloads and explicitly separate browsing contexts leave the working copy open. */
|
|
54
|
+
function replacesCurrentWindow(anchor) {
|
|
55
|
+
if (!anchor || anchor.hasAttribute('download'))
|
|
56
|
+
return false;
|
|
57
|
+
return !anchor.target || anchor.target === '_self';
|
|
58
|
+
}
|
|
59
|
+
/** Only a plain click replaces this tab; modified clicks leave its working copy alive. */
|
|
60
|
+
function isPlainNavigationClick({ event }, _options = {}) {
|
|
61
|
+
const modified = event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;
|
|
62
|
+
return event.button === 0 && !event.defaultPrevented && !modified;
|
|
63
|
+
}
|
|
64
|
+
/** Reuse the host's dirty guard for unload and in-app links; also save on Cmd/Ctrl+S. Removes all listeners. */
|
|
65
|
+
function useEditorKeys({ controller, locale, t, adminBase, useDirtyGuardHook }, { host = window, documentHost = document } = {}) {
|
|
66
|
+
const { dirty, save } = controller;
|
|
67
|
+
const { confirmLeave } = useDirtyGuardHook({ current: dirty, original: controller.view.kind === 'loaded' ? false : null }, { host, translate: (key) => t({ locale, key }) });
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
const onKey = (event) => {
|
|
70
|
+
if ((event.metaKey || event.ctrlKey) && event.key.toLowerCase() === 's') {
|
|
71
|
+
event.preventDefault();
|
|
72
|
+
void save();
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
host.addEventListener('keydown', onKey);
|
|
76
|
+
return () => host.removeEventListener('keydown', onKey);
|
|
77
|
+
}, [host, save]);
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
const onNavigate = (event) => {
|
|
80
|
+
if (!isPlainNavigationClick({ event }))
|
|
81
|
+
return;
|
|
82
|
+
const anchor = event.target?.closest?.('a[href]');
|
|
83
|
+
if (!leavesEditor({ anchor, location: host.location, adminBase }))
|
|
84
|
+
return;
|
|
85
|
+
if (confirmLeave())
|
|
86
|
+
return;
|
|
87
|
+
event.preventDefault();
|
|
88
|
+
event.stopPropagation();
|
|
89
|
+
};
|
|
90
|
+
// MOVE: Capture covers sidebar anchors outside this page before the shared SPA interceptor.
|
|
91
|
+
documentHost.addEventListener('click', onNavigate, true);
|
|
92
|
+
return () => documentHost.removeEventListener('click', onNavigate, true);
|
|
93
|
+
}, [confirmLeave, host, documentHost, adminBase]);
|
|
94
|
+
}
|
|
95
|
+
/** The save-state word beside the Save button, or null before any edit. Pure. */
|
|
96
|
+
export function editorStatus(controller) {
|
|
97
|
+
if (controller.saving)
|
|
98
|
+
return 'Saving…';
|
|
99
|
+
if (controller.dirty)
|
|
100
|
+
return 'Unsaved changes';
|
|
101
|
+
return controller.savedAt ? 'Saved' : null;
|
|
102
|
+
}
|
|
103
|
+
/** The editor page. Every hook, component and dictionary is the host's, injected through props. */
|
|
104
|
+
export function EmailTemplateEditor(props) {
|
|
105
|
+
const { hooks, kit, copy, useEditorKeysHook = useEditorKeys } = props;
|
|
106
|
+
const controller = hooks.useEditorHook({ id: props.id });
|
|
107
|
+
const adminLocale = hooks.useAdminLocaleHook();
|
|
108
|
+
const locale = props.locale ?? adminLocale;
|
|
109
|
+
const view = hooks.useEmailTemplateViewHook();
|
|
110
|
+
const t = copy.t;
|
|
111
|
+
useEditorKeysHook({ controller, locale, t, adminBase: kit.adminBase, useDirtyGuardHook: hooks.useDirtyGuardHook });
|
|
112
|
+
const pageT = (key) => copy.pageEditorT({ locale, key });
|
|
113
|
+
const base = { controller, locale, t };
|
|
114
|
+
return (_jsxs("div", { className: "page content-editor-page email-template-page", children: [_jsx(Header, { ...base, kit: kit, pageT: pageT }), controller.renameError ? _jsx("p", { className: "jini-field-error", role: "alert", children: t({ locale, key: controller.renameError }) }) : null, controller.saveError ? _jsx("div", { className: "notice error", role: "alert", children: t({ locale, key: controller.saveError }) }) : null, _jsx(kit.Loaded, { view: controller.view, locale: locale, children: () => (_jsxs(_Fragment, { children: [_jsx(Toolbar, { ...base, view: view, kit: kit, pageT: pageT, useTabBarKeyboardHook: hooks.useTabBarKeyboardHook, resolveTabIndex: props.resolveTabIndex }), _jsx(Actions, { ...base }), view.tab === 'html' ? (_jsx("textarea", { className: "page-html-source email-template-source", value: controller.html, onChange: (e) => controller.setHtml(e.target.value), spellCheck: false, "aria-label": t({ locale, key: 'Template HTML' }), placeholder: t({ locale, key: "Write the email's HTML, or ask the assistant to." }), ...agentHandle({ handle: 'email-template-html' }, { role: 'field', label: "This email template's raw HTML" }) })) : (_jsx(Preview, { ...base, view: view, kit: kit }))] })) })] }));
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=EmailTemplateEditor.js.map
|