@revealui/auth 0.0.1-pre.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/dist/better-auth/adapter/__tests__/transform.test.js +213 -0
- package/dist/better-auth/adapter/__tests__/transform.test.js.map +1 -0
- package/dist/better-auth/adapter/generate-schema/biome.d.js +2 -0
- package/dist/better-auth/adapter/generate-schema/biome.d.js.map +1 -0
- package/dist/better-auth/adapter/generate-schema/generate-schema-builder.d.ts +5 -0
- package/dist/better-auth/adapter/generate-schema/generate-schema-builder.js +482 -0
- package/dist/better-auth/adapter/generate-schema/generate-schema-builder.js.map +1 -0
- package/dist/better-auth/adapter/generate-schema/get-payload-schema.d.ts +1 -0
- package/dist/better-auth/adapter/generate-schema/get-payload-schema.js +42 -0
- package/dist/better-auth/adapter/generate-schema/get-payload-schema.js.map +1 -0
- package/dist/better-auth/adapter/generate-schema/index.d.ts +4 -0
- package/dist/better-auth/adapter/generate-schema/index.js +19 -0
- package/dist/better-auth/adapter/generate-schema/index.js.map +1 -0
- package/dist/better-auth/adapter/generate-schema/utils.d.ts +2 -0
- package/dist/better-auth/adapter/generate-schema/utils.js +20 -0
- package/dist/better-auth/adapter/generate-schema/utils.js.map +1 -0
- package/dist/better-auth/adapter/index.d.ts +15 -0
- package/dist/better-auth/adapter/index.js +731 -0
- package/dist/better-auth/adapter/index.js.map +1 -0
- package/dist/better-auth/adapter/tests/adapter.test.js +174 -0
- package/dist/better-auth/adapter/tests/adapter.test.js.map +1 -0
- package/dist/better-auth/adapter/tests/base-collections-tests.js +575 -0
- package/dist/better-auth/adapter/tests/base-collections-tests.js.map +1 -0
- package/dist/better-auth/adapter/tests/dev/index.js +117 -0
- package/dist/better-auth/adapter/tests/dev/index.js.map +1 -0
- package/dist/better-auth/adapter/tests/dev/migrate.js +26 -0
- package/dist/better-auth/adapter/tests/dev/migrate.js.map +1 -0
- package/dist/better-auth/adapter/tests/dev/migrations/20250423_232936_init.js +218 -0
- package/dist/better-auth/adapter/tests/dev/migrations/20250423_232936_init.js.map +1 -0
- package/dist/better-auth/adapter/tests/dev/schema.js +160 -0
- package/dist/better-auth/adapter/tests/dev/schema.js.map +1 -0
- package/dist/better-auth/adapter/tests/plugins-tests.js +2 -0
- package/dist/better-auth/adapter/tests/plugins-tests.js.map +1 -0
- package/dist/better-auth/adapter/transform/index.d.ts +27 -0
- package/dist/better-auth/adapter/transform/index.js +664 -0
- package/dist/better-auth/adapter/transform/index.js.map +1 -0
- package/dist/better-auth/adapter/types.d.ts +10 -0
- package/dist/better-auth/adapter/types.js +3 -0
- package/dist/better-auth/adapter/types.js.map +1 -0
- package/dist/better-auth/generated-types.d.ts +285 -0
- package/dist/better-auth/index.d.ts +3 -0
- package/dist/better-auth/index.js +5 -0
- package/dist/better-auth/index.js.map +1 -0
- package/dist/better-auth/plugin/__tests__/plugin.test.js +162 -0
- package/dist/better-auth/plugin/__tests__/plugin.test.js.map +1 -0
- package/dist/better-auth/plugin/constants.d.ts +220 -0
- package/dist/better-auth/plugin/constants.js +249 -0
- package/dist/better-auth/plugin/constants.js.map +1 -0
- package/dist/better-auth/plugin/helpers/check-plugin-exists.d.ts +12 -0
- package/dist/better-auth/plugin/helpers/check-plugin-exists.js +14 -0
- package/dist/better-auth/plugin/helpers/check-plugin-exists.js.map +1 -0
- package/dist/better-auth/plugin/helpers/generate-verify-email-url.d.ts +29 -0
- package/dist/better-auth/plugin/helpers/generate-verify-email-url.js +46 -0
- package/dist/better-auth/plugin/helpers/generate-verify-email-url.js.map +1 -0
- package/dist/better-auth/plugin/helpers/get-admin-access.d.ts +7 -0
- package/dist/better-auth/plugin/helpers/get-admin-access.js +22 -0
- package/dist/better-auth/plugin/helpers/get-admin-access.js.map +1 -0
- package/dist/better-auth/plugin/helpers/get-all-roles.d.ts +5 -0
- package/dist/better-auth/plugin/helpers/get-all-roles.js +20 -0
- package/dist/better-auth/plugin/helpers/get-all-roles.js.map +1 -0
- package/dist/better-auth/plugin/helpers/get-better-auth-schema.d.ts +18 -0
- package/dist/better-auth/plugin/helpers/get-better-auth-schema.js +70 -0
- package/dist/better-auth/plugin/helpers/get-better-auth-schema.js.map +1 -0
- package/dist/better-auth/plugin/helpers/get-collection-slug.d.ts +5 -0
- package/dist/better-auth/plugin/helpers/get-collection-slug.js +20 -0
- package/dist/better-auth/plugin/helpers/get-collection-slug.js.map +1 -0
- package/dist/better-auth/plugin/helpers/get-collection.d.ts +15 -0
- package/dist/better-auth/plugin/helpers/get-collection.js +29 -0
- package/dist/better-auth/plugin/helpers/get-collection.js.map +1 -0
- package/dist/better-auth/plugin/helpers/get-ip.d.ts +2 -0
- package/dist/better-auth/plugin/helpers/get-ip.js +31 -0
- package/dist/better-auth/plugin/helpers/get-ip.js.map +1 -0
- package/dist/better-auth/plugin/helpers/get-signed-cookie.d.ts +2 -0
- package/dist/better-auth/plugin/helpers/get-signed-cookie.js +65 -0
- package/dist/better-auth/plugin/helpers/get-signed-cookie.js.map +1 -0
- package/dist/better-auth/plugin/helpers/index.d.ts +1 -0
- package/dist/better-auth/plugin/helpers/index.js +3 -0
- package/dist/better-auth/plugin/helpers/index.js.map +1 -0
- package/dist/better-auth/plugin/helpers/prepare-session-data.d.ts +59 -0
- package/dist/better-auth/plugin/helpers/prepare-session-data.js +49 -0
- package/dist/better-auth/plugin/helpers/prepare-session-data.js.map +1 -0
- package/dist/better-auth/plugin/helpers/sync-resolved-schema-with-collection-map.d.ts +20 -0
- package/dist/better-auth/plugin/helpers/sync-resolved-schema-with-collection-map.js +67 -0
- package/dist/better-auth/plugin/helpers/sync-resolved-schema-with-collection-map.js.map +1 -0
- package/dist/better-auth/plugin/index.d.ts +11 -0
- package/dist/better-auth/plugin/index.js +125 -0
- package/dist/better-auth/plugin/index.js.map +1 -0
- package/dist/better-auth/plugin/lib/apply-disabled-default-auth-config.d.ts +12 -0
- package/dist/better-auth/plugin/lib/apply-disabled-default-auth-config.js +87 -0
- package/dist/better-auth/plugin/lib/apply-disabled-default-auth-config.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/accounts/hooks/sync-password-to-user.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/accounts/hooks/sync-password-to-user.js +60 -0
- package/dist/better-auth/plugin/lib/build-collections/accounts/hooks/sync-password-to-user.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/accounts/index.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/accounts/index.js +154 -0
- package/dist/better-auth/plugin/lib/build-collections/accounts/index.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/hooks/get-url-after-read.d.ts +5 -0
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/hooks/get-url-after-read.js +11 -0
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/hooks/get-url-after-read.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/hooks/get-url-before-change.d.ts +2 -0
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/hooks/get-url-before-change.js +8 -0
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/hooks/get-url-before-change.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/index.d.ts +6 -0
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/index.js +119 -0
- package/dist/better-auth/plugin/lib/build-collections/admin-invitations/index.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/api-keys.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/api-keys.js +177 -0
- package/dist/better-auth/plugin/lib/build-collections/api-keys.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/device-code.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/device-code.js +50 -0
- package/dist/better-auth/plugin/lib/build-collections/device-code.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/index.d.ts +10 -0
- package/dist/better-auth/plugin/lib/build-collections/index.js +73 -0
- package/dist/better-auth/plugin/lib/build-collections/index.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/invitations.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/invitations.js +94 -0
- package/dist/better-auth/plugin/lib/build-collections/invitations.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/jwks.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/jwks.js +59 -0
- package/dist/better-auth/plugin/lib/build-collections/jwks.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/members.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/members.js +73 -0
- package/dist/better-auth/plugin/lib/build-collections/members.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/oauth-access-tokens.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/oauth-access-tokens.js +107 -0
- package/dist/better-auth/plugin/lib/build-collections/oauth-access-tokens.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/oauth-applications.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/oauth-applications.js +118 -0
- package/dist/better-auth/plugin/lib/build-collections/oauth-applications.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/oauth-consents.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/oauth-consents.js +89 -0
- package/dist/better-auth/plugin/lib/build-collections/oauth-consents.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/organizations.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/organizations.js +70 -0
- package/dist/better-auth/plugin/lib/build-collections/organizations.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/passkeys.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/passkeys.js +115 -0
- package/dist/better-auth/plugin/lib/build-collections/passkeys.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/sessions.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/sessions.js +170 -0
- package/dist/better-auth/plugin/lib/build-collections/sessions.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/sso-providers.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/sso-providers.js +81 -0
- package/dist/better-auth/plugin/lib/build-collections/sso-providers.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/subscriptions.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/subscriptions.js +111 -0
- package/dist/better-auth/plugin/lib/build-collections/subscriptions.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/team-members.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/team-members.js +57 -0
- package/dist/better-auth/plugin/lib/build-collections/team-members.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/teams.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/teams.js +76 -0
- package/dist/better-auth/plugin/lib/build-collections/teams.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/two-factors.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/two-factors.js +67 -0
- package/dist/better-auth/plugin/lib/build-collections/two-factors.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/better-auth-strategy.d.ts +7 -0
- package/dist/better-auth/plugin/lib/build-collections/users/better-auth-strategy.js +53 -0
- package/dist/better-auth/plugin/lib/build-collections/users/better-auth-strategy.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/generate-invite-url.d.ts +11 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/generate-invite-url.js +75 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/generate-invite-url.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/index.d.ts +4 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/index.js +6 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/index.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/refresh-token.d.ts +2 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/refresh-token.js +115 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/refresh-token.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/send-invite-url.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/send-invite-url.js +64 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/send-invite-url.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/set-admin-role.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/set-admin-role.js +80 -0
- package/dist/better-auth/plugin/lib/build-collections/users/endpoints/set-admin-role.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/after-login.d.ts +6 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/after-login.js +79 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/after-login.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/after-logout.d.ts +2 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/after-logout.js +82 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/after-logout.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/before-delete.d.ts +2 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/before-delete.js +54 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/before-delete.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/before-login.d.ts +6 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/before-login.js +15 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/before-login.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/index.d.ts +6 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/index.js +8 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/index.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/on-verified-change.d.ts +2 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/on-verified-change.js +17 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/on-verified-change.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/sync-account.d.ts +2 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/sync-account.js +91 -0
- package/dist/better-auth/plugin/lib/build-collections/users/hooks/sync-account.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/users/index.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/users/index.js +341 -0
- package/dist/better-auth/plugin/lib/build-collections/users/index.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/collection-schema.d.ts +15 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/collection-schema.js +24 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/collection-schema.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/filter-duplicate-fields.d.ts +10 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/filter-duplicate-fields.js +67 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/filter-duplicate-fields.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/filter-properties.d.ts +9 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/filter-properties.js +94 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/filter-properties.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/get-timestamp-fields.d.ts +7 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/get-timestamp-fields.js +35 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/get-timestamp-fields.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/model-field-transformations.d.ts +12 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/model-field-transformations.js +25 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/model-field-transformations.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/payload-access.d.ts +14 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/payload-access.js +67 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/payload-access.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/transform-schema-fields-to-payload.d.ts +20 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/transform-schema-fields-to-payload.js +98 -0
- package/dist/better-auth/plugin/lib/build-collections/utils/transform-schema-fields-to-payload.js.map +1 -0
- package/dist/better-auth/plugin/lib/build-collections/verifications.d.ts +3 -0
- package/dist/better-auth/plugin/lib/build-collections/verifications.js +87 -0
- package/dist/better-auth/plugin/lib/build-collections/verifications.js.map +1 -0
- package/dist/better-auth/plugin/lib/get-payload-auth.d.ts +5 -0
- package/dist/better-auth/plugin/lib/get-payload-auth.js +9 -0
- package/dist/better-auth/plugin/lib/get-payload-auth.js.map +1 -0
- package/dist/better-auth/plugin/lib/init-better-auth.d.ts +7 -0
- package/dist/better-auth/plugin/lib/init-better-auth.js +46 -0
- package/dist/better-auth/plugin/lib/init-better-auth.js.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/admin-plugin.d.ts +2 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/admin-plugin.js +9 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/admin-plugin.js.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/api-key-plugin.d.ts +2 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/api-key-plugin.js +10 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/api-key-plugin.js.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/device-authorization-plugin.d.ts +2 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/device-authorization-plugin.js +8 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/device-authorization-plugin.js.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/index.d.ts +10 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/index.js +156 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/index.js.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/oidc-plugin.d.ts +2 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/oidc-plugin.js +18 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/oidc-plugin.js.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/organizations-plugin.d.ts +2 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/organizations-plugin.js +34 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/organizations-plugin.js.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/passkey-plugin.d.ts +2 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/passkey-plugin.js +11 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/passkey-plugin.js.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/sso-plugin.d.ts +2 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/sso-plugin.js +10 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/sso-plugin.js.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/two-factor-plugin.d.ts +2 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/two-factor-plugin.js +11 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/two-factor-plugin.js.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/ensure-password-set-before-create.d.ts +7 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/ensure-password-set-before-create.js +23 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/ensure-password-set-before-create.js.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/password.d.ts +25 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/password.js +62 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/password.js.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/require-admin-invite-for-sign-up-middleware.d.ts +9 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/require-admin-invite-for-sign-up-middleware.js +47 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/require-admin-invite-for-sign-up-middleware.js.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/save-to-jwt-middleware.d.ts +15 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/save-to-jwt-middleware.js +42 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/save-to-jwt-middleware.js.map +1 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/use-admin-invite-after-email-sign-up-middleware.d.ts +9 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/use-admin-invite-after-email-sign-up-middleware.js +63 -0
- package/dist/better-auth/plugin/lib/sanitize-better-auth-options/utils/use-admin-invite-after-email-sign-up-middleware.js.map +1 -0
- package/dist/better-auth/plugin/lib/set-login-methods.d.ts +4 -0
- package/dist/better-auth/plugin/lib/set-login-methods.js +14 -0
- package/dist/better-auth/plugin/lib/set-login-methods.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/admin-buttons/index.d.ts +9 -0
- package/dist/better-auth/plugin/payload/components/admin-buttons/index.js +143 -0
- package/dist/better-auth/plugin/payload/components/admin-buttons/index.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/admin-invite-button/index.d.ts +10 -0
- package/dist/better-auth/plugin/payload/components/admin-invite-button/index.js +219 -0
- package/dist/better-auth/plugin/payload/components/admin-invite-button/index.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/logout-button.d.ts +4 -0
- package/dist/better-auth/plugin/payload/components/logout-button.js +24 -0
- package/dist/better-auth/plugin/payload/components/logout-button.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/passkeys/add-button.d.ts +8 -0
- package/dist/better-auth/plugin/payload/components/passkeys/add-button.js +117 -0
- package/dist/better-auth/plugin/payload/components/passkeys/add-button.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/passkeys/client.d.ts +3 -0
- package/dist/better-auth/plugin/payload/components/passkeys/client.js +66 -0
- package/dist/better-auth/plugin/payload/components/passkeys/client.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/passkeys/index.d.ts +4 -0
- package/dist/better-auth/plugin/payload/components/passkeys/index.js +52 -0
- package/dist/better-auth/plugin/payload/components/passkeys/index.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/passkeys/list.d.ts +8 -0
- package/dist/better-auth/plugin/payload/components/passkeys/list.js +57 -0
- package/dist/better-auth/plugin/payload/components/passkeys/list.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/passkeys/types.d.ts +22 -0
- package/dist/better-auth/plugin/payload/components/passkeys/types.js +3 -0
- package/dist/better-auth/plugin/payload/components/passkeys/types.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/rsc-redirect.d.ts +6 -0
- package/dist/better-auth/plugin/payload/components/rsc-redirect.js +7 -0
- package/dist/better-auth/plugin/payload/components/rsc-redirect.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/social-provider-buttons/index.d.ts +15 -0
- package/dist/better-auth/plugin/payload/components/social-provider-buttons/index.js +157 -0
- package/dist/better-auth/plugin/payload/components/social-provider-buttons/index.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/token-field.d.ts +4 -0
- package/dist/better-auth/plugin/payload/components/token-field.js +31 -0
- package/dist/better-auth/plugin/payload/components/token-field.js.map +1 -0
- package/dist/better-auth/plugin/payload/components/two-factor-auth/index.d.ts +8 -0
- package/dist/better-auth/plugin/payload/components/two-factor-auth/index.js +300 -0
- package/dist/better-auth/plugin/payload/components/two-factor-auth/index.js.map +1 -0
- package/dist/better-auth/plugin/payload/exports/client.d.ts +6 -0
- package/dist/better-auth/plugin/payload/exports/client.js +8 -0
- package/dist/better-auth/plugin/payload/exports/client.js.map +1 -0
- package/dist/better-auth/plugin/payload/exports/rsc.d.ts +8 -0
- package/dist/better-auth/plugin/payload/exports/rsc.js +10 -0
- package/dist/better-auth/plugin/payload/exports/rsc.js.map +1 -0
- package/dist/better-auth/plugin/payload/utils/generate-admin-invite-url.d.ts +2 -0
- package/dist/better-auth/plugin/payload/utils/generate-admin-invite-url.js +9 -0
- package/dist/better-auth/plugin/payload/utils/generate-admin-invite-url.js.map +1 -0
- package/dist/better-auth/plugin/payload/utils/get-safe-redirect.d.ts +1 -0
- package/dist/better-auth/plugin/payload/utils/get-safe-redirect.js +22 -0
- package/dist/better-auth/plugin/payload/utils/get-safe-redirect.js.map +1 -0
- package/dist/better-auth/plugin/payload/views/admin-login/client.d.ts +19 -0
- package/dist/better-auth/plugin/payload/views/admin-login/client.js +226 -0
- package/dist/better-auth/plugin/payload/views/admin-login/client.js.map +1 -0
- package/dist/better-auth/plugin/payload/views/admin-login/index.d.ts +10 -0
- package/dist/better-auth/plugin/payload/views/admin-login/index.js +150 -0
- package/dist/better-auth/plugin/payload/views/admin-login/index.js.map +1 -0
- package/dist/better-auth/plugin/payload/views/admin-signup/client.d.ts +16 -0
- package/dist/better-auth/plugin/payload/views/admin-signup/client.js +299 -0
- package/dist/better-auth/plugin/payload/views/admin-signup/client.js.map +1 -0
- package/dist/better-auth/plugin/payload/views/admin-signup/index.d.ts +9 -0
- package/dist/better-auth/plugin/payload/views/admin-signup/index.js +104 -0
- package/dist/better-auth/plugin/payload/views/admin-signup/index.js.map +1 -0
- package/dist/better-auth/plugin/payload/views/forgot-password/client.d.ts +7 -0
- package/dist/better-auth/plugin/payload/views/forgot-password/client.js +119 -0
- package/dist/better-auth/plugin/payload/views/forgot-password/client.js.map +1 -0
- package/dist/better-auth/plugin/payload/views/forgot-password/index.d.ts +8 -0
- package/dist/better-auth/plugin/payload/views/forgot-password/index.js +78 -0
- package/dist/better-auth/plugin/payload/views/forgot-password/index.js.map +1 -0
- package/dist/better-auth/plugin/payload/views/reset-password/client.d.ts +10 -0
- package/dist/better-auth/plugin/payload/views/reset-password/client.js +144 -0
- package/dist/better-auth/plugin/payload/views/reset-password/client.js.map +1 -0
- package/dist/better-auth/plugin/payload/views/reset-password/index.d.ts +8 -0
- package/dist/better-auth/plugin/payload/views/reset-password/index.js +96 -0
- package/dist/better-auth/plugin/payload/views/reset-password/index.js.map +1 -0
- package/dist/better-auth/plugin/payload/views/two-factor-verify/client.d.ts +6 -0
- package/dist/better-auth/plugin/payload/views/two-factor-verify/client.js +96 -0
- package/dist/better-auth/plugin/payload/views/two-factor-verify/client.js.map +1 -0
- package/dist/better-auth/plugin/payload/views/two-factor-verify/index.d.ts +9 -0
- package/dist/better-auth/plugin/payload/views/two-factor-verify/index.js +56 -0
- package/dist/better-auth/plugin/payload/views/two-factor-verify/index.js.map +1 -0
- package/dist/better-auth/plugin/types.d.ts +429 -0
- package/dist/better-auth/plugin/types.js +3 -0
- package/dist/better-auth/plugin/types.js.map +1 -0
- package/dist/better-auth/plugin/utils/set.d.ts +39 -0
- package/dist/better-auth/plugin/utils/set.js +103 -0
- package/dist/better-auth/plugin/utils/set.js.map +1 -0
- package/dist/better-auth/scripts/generate-types.d.ts +1 -0
- package/dist/better-auth/scripts/generate-types.js +234 -0
- package/dist/better-auth/scripts/generate-types.js.map +1 -0
- package/dist/better-auth/types.d.ts +2 -0
- package/dist/better-auth/types.js +4 -0
- package/dist/better-auth/types.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/shared/components/icons.d.ts +7 -0
- package/dist/shared/components/icons.js +442 -0
- package/dist/shared/components/icons.js.map +1 -0
- package/dist/shared/components/logo.d.ts +3 -0
- package/dist/shared/components/logo.js +24 -0
- package/dist/shared/components/logo.js.map +1 -0
- package/dist/shared/form/components/submit.d.ts +7 -0
- package/dist/shared/form/components/submit.js +16 -0
- package/dist/shared/form/components/submit.js.map +1 -0
- package/dist/shared/form/fields/text-field.d.ts +8 -0
- package/dist/shared/form/fields/text-field.js +37 -0
- package/dist/shared/form/fields/text-field.js.map +1 -0
- package/dist/shared/form/index.d.ts +4 -0
- package/dist/shared/form/index.js +8 -0
- package/dist/shared/form/index.js.map +1 -0
- package/dist/shared/form/ui/header/index.d.ts +8 -0
- package/dist/shared/form/ui/header/index.js +24 -0
- package/dist/shared/form/ui/header/index.js.map +1 -0
- package/dist/shared/form/ui/index.d.ts +31 -0
- package/dist/shared/form/ui/index.js +57 -0
- package/dist/shared/form/ui/index.js.map +1 -0
- package/dist/shared/form/validation.d.ts +51 -0
- package/dist/shared/form/validation.js +127 -0
- package/dist/shared/form/validation.js.map +1 -0
- package/dist/shared/index.d.ts +2 -0
- package/dist/shared/index.js +4 -0
- package/dist/shared/index.js.map +1 -0
- package/dist/shared/payload/fields/field-copy-button/index.d.ts +3 -0
- package/dist/shared/payload/fields/field-copy-button/index.js +38 -0
- package/dist/shared/payload/fields/field-copy-button/index.js.map +1 -0
- package/dist/shared/payload/fields/generate-uuid-button/index.d.ts +3 -0
- package/dist/shared/payload/fields/generate-uuid-button/index.js +26 -0
- package/dist/shared/payload/fields/generate-uuid-button/index.js.map +1 -0
- package/dist/shared/payload/fields/index.d.ts +2 -0
- package/dist/shared/payload/fields/index.js +4 -0
- package/dist/shared/payload/fields/index.js.map +1 -0
- package/dist/shared/utils/regex.d.ts +2 -0
- package/dist/shared/utils/regex.js +4 -0
- package/dist/shared/utils/regex.js.map +1 -0
- package/dist/shared/utils/try-catch.d.ts +11 -0
- package/dist/shared/utils/try-catch.js +17 -0
- package/dist/shared/utils/try-catch.js.map +1 -0
- package/dist/shared/utils/value-or-default.d.ts +9 -0
- package/dist/shared/utils/value-or-default.js +12 -0
- package/dist/shared/utils/value-or-default.js.map +1 -0
- package/package.json +122 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useFormContext } from "react-hook-form";
|
|
3
|
+
import { FieldErrors, FieldInputWrap, FormField, FormLabel } from "../ui";
|
|
4
|
+
export function TextField({ name, className, label, required = false, type = 'text', autoComplete = 'off' }) {
|
|
5
|
+
const { register, formState: { errors } } = useFormContext();
|
|
6
|
+
const fieldError = errors[name];
|
|
7
|
+
const hasError = !!fieldError;
|
|
8
|
+
return /*#__PURE__*/ _jsxs(FormField, {
|
|
9
|
+
id: name,
|
|
10
|
+
className: className,
|
|
11
|
+
hasError: hasError,
|
|
12
|
+
children: [
|
|
13
|
+
/*#__PURE__*/ _jsx(FormLabel, {
|
|
14
|
+
label: label,
|
|
15
|
+
htmlFor: name,
|
|
16
|
+
required: required
|
|
17
|
+
}),
|
|
18
|
+
/*#__PURE__*/ _jsxs(FieldInputWrap, {
|
|
19
|
+
children: [
|
|
20
|
+
/*#__PURE__*/ _jsx("input", {
|
|
21
|
+
...register(name),
|
|
22
|
+
autoComplete: autoComplete,
|
|
23
|
+
type: type,
|
|
24
|
+
id: name,
|
|
25
|
+
required: required,
|
|
26
|
+
className: "text-field"
|
|
27
|
+
}),
|
|
28
|
+
fieldError && /*#__PURE__*/ _jsx(FieldErrors, {
|
|
29
|
+
error: fieldError
|
|
30
|
+
})
|
|
31
|
+
]
|
|
32
|
+
})
|
|
33
|
+
]
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=text-field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/shared/form/fields/text-field.tsx"],"sourcesContent":["import { type FieldError, useFormContext } from 'react-hook-form';\nimport { FieldErrors, FieldInputWrap, FormField, FormLabel } from '../ui';\n\nexport function TextField({\n name,\n className,\n label,\n required = false,\n type = 'text',\n autoComplete = 'off',\n}: {\n name: string;\n className: string;\n label: string;\n required?: boolean;\n type?: string;\n autoComplete?: string;\n}) {\n const {\n register,\n formState: { errors },\n } = useFormContext();\n\n const fieldError = errors[name] as FieldError | undefined;\n const hasError = !!fieldError;\n\n return (\n <FormField id={name} className={className} hasError={hasError}>\n <FormLabel label={label} htmlFor={name} required={required} />\n <FieldInputWrap>\n <input\n {...register(name)}\n autoComplete={autoComplete}\n type={type}\n id={name}\n required={required}\n className='text-field'\n />\n {fieldError && <FieldErrors error={fieldError} />}\n </FieldInputWrap>\n </FormField>\n );\n}\n"],"names":["useFormContext","FieldErrors","FieldInputWrap","FormField","FormLabel","TextField","name","className","label","required","type","autoComplete","register","formState","errors","fieldError","hasError","id","htmlFor","input","error"],"mappings":";AAAA,SAA0BA,cAAc,QAAQ,kBAAkB;AAClE,SAASC,WAAW,EAAEC,cAAc,EAAEC,SAAS,EAAEC,SAAS,QAAQ,QAAQ;AAE1E,OAAO,SAASC,UAAU,EACxBC,IAAI,EACJC,SAAS,EACTC,KAAK,EACLC,WAAW,KAAK,EAChBC,OAAO,MAAM,EACbC,eAAe,KAAK,EAQrB;IACC,MAAM,EACJC,QAAQ,EACRC,WAAW,EAAEC,MAAM,EAAE,EACtB,GAAGd;IAEJ,MAAMe,aAAaD,MAAM,CAACR,KAAK;IAC/B,MAAMU,WAAW,CAAC,CAACD;IAEnB,qBACE,MAACZ;QAAUc,IAAIX;QAAMC,WAAWA;QAAWS,UAAUA;;0BACnD,KAACZ;gBAAUI,OAAOA;gBAAOU,SAASZ;gBAAMG,UAAUA;;0BAClD,MAACP;;kCACC,KAACiB;wBACE,GAAGP,SAASN,KAAK;wBAClBK,cAAcA;wBACdD,MAAMA;wBACNO,IAAIX;wBACJG,UAAUA;wBACVF,WAAU;;oBAEXQ,4BAAc,KAACd;wBAAYmB,OAAOL;;;;;;AAI3C"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Re-export react-hook-form utilities for use in forms
|
|
2
|
+
export { zodResolver } from "@hookform/resolvers/zod";
|
|
3
|
+
export { FormProvider, useForm, useFormContext } from "react-hook-form";
|
|
4
|
+
// Re-export form components
|
|
5
|
+
export { Submit } from "./components/submit";
|
|
6
|
+
export { TextField } from "./fields/text-field";
|
|
7
|
+
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/shared/form/index.ts"],"sourcesContent":["// Re-export react-hook-form utilities for use in forms\nexport { zodResolver } from '@hookform/resolvers/zod';\nexport { FormProvider, useForm, useFormContext } from 'react-hook-form';\n\n// Re-export form components\nexport { Submit } from './components/submit';\nexport { TextField } from './fields/text-field';\n"],"names":["zodResolver","FormProvider","useForm","useFormContext","Submit","TextField"],"mappings":"AAAA,uDAAuD;AACvD,SAASA,WAAW,QAAQ,0BAA0B;AACtD,SAASC,YAAY,EAAEC,OAAO,EAAEC,cAAc,QAAQ,kBAAkB;AAExE,4BAA4B;AAC5B,SAASC,MAAM,QAAQ,sBAAsB;AAC7C,SAASC,SAAS,QAAQ,sBAAsB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React, { type ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
import './index.scss';
|
|
3
|
+
type Props = ComponentPropsWithoutRef<'div'> & {
|
|
4
|
+
description?: React.ReactNode | string;
|
|
5
|
+
heading: string;
|
|
6
|
+
};
|
|
7
|
+
declare const FormHeader: React.FC<Props>;
|
|
8
|
+
export { FormHeader };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import "./index.scss";
|
|
4
|
+
const baseClass = 'form-header';
|
|
5
|
+
const FormHeader = ({ description, heading, ...props })=>{
|
|
6
|
+
if (!heading) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
10
|
+
className: baseClass,
|
|
11
|
+
...props,
|
|
12
|
+
children: [
|
|
13
|
+
/*#__PURE__*/ _jsx("h1", {
|
|
14
|
+
children: heading
|
|
15
|
+
}),
|
|
16
|
+
Boolean(description) && /*#__PURE__*/ _jsx("p", {
|
|
17
|
+
children: description
|
|
18
|
+
})
|
|
19
|
+
]
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
export { FormHeader };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/shared/form/ui/header/index.tsx"],"sourcesContent":["import React, { type ComponentPropsWithoutRef } from 'react';\n\nimport './index.scss';\n\nconst baseClass = 'form-header';\n\ntype Props = ComponentPropsWithoutRef<'div'> & {\n description?: React.ReactNode | string;\n heading: string;\n};\n\nconst FormHeader: React.FC<Props> = ({ description, heading, ...props }) => {\n if (!heading) {\n return null;\n }\n\n return (\n <div className={baseClass} {...props}>\n <h1>{heading}</h1>\n {Boolean(description) && <p>{description}</p>}\n </div>\n );\n};\n\nexport { FormHeader };\n"],"names":["React","baseClass","FormHeader","description","heading","props","div","className","h1","Boolean","p"],"mappings":";AAAA,OAAOA,WAA8C,QAAQ;AAE7D,OAAO,eAAe;AAEtB,MAAMC,YAAY;AAOlB,MAAMC,aAA8B,CAAC,EAAEC,WAAW,EAAEC,OAAO,EAAE,GAAGC,OAAO;IACrE,IAAI,CAACD,SAAS;QACZ,OAAO;IACT;IAEA,qBACE,MAACE;QAAIC,WAAWN;QAAY,GAAGI,KAAK;;0BAClC,KAACG;0BAAIJ;;YACJK,QAAQN,8BAAgB,KAACO;0BAAGP;;;;AAGnC;AAEA,SAASD,UAAU,GAAG"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React, { type ComponentPropsWithoutRef, type ReactNode } from 'react';
|
|
2
|
+
import type { FieldError } from 'react-hook-form';
|
|
3
|
+
import './index.scss';
|
|
4
|
+
type FormFieldProps = ComponentPropsWithoutRef<'div'> & {
|
|
5
|
+
hasError?: boolean;
|
|
6
|
+
};
|
|
7
|
+
declare const FormField: React.FC<FormFieldProps>;
|
|
8
|
+
type FormLabelProps = ComponentPropsWithoutRef<'label'> & {
|
|
9
|
+
label: ReactNode;
|
|
10
|
+
required?: boolean;
|
|
11
|
+
htmlFor?: string;
|
|
12
|
+
};
|
|
13
|
+
declare const FormLabel: React.FC<FormLabelProps>;
|
|
14
|
+
type FieldErrorsProps = {
|
|
15
|
+
error?: FieldError;
|
|
16
|
+
className?: string;
|
|
17
|
+
};
|
|
18
|
+
export declare const FieldErrors: ({ error, className }: FieldErrorsProps) => any;
|
|
19
|
+
type FormErrorProps = {
|
|
20
|
+
errors?: string[];
|
|
21
|
+
className?: string;
|
|
22
|
+
};
|
|
23
|
+
declare const FormError: React.FC<FormErrorProps>;
|
|
24
|
+
type FormProps = ComponentPropsWithoutRef<'form'>;
|
|
25
|
+
declare const Form: React.FC<FormProps>;
|
|
26
|
+
type FormInputWrapProps = ComponentPropsWithoutRef<'div'>;
|
|
27
|
+
declare const FormInputWrap: React.FC<FormInputWrapProps>;
|
|
28
|
+
type FieldInputWrapProps = ComponentPropsWithoutRef<'div'>;
|
|
29
|
+
declare const FieldInputWrap: React.FC<FieldInputWrapProps>;
|
|
30
|
+
export { FieldInputWrap, Form, FormError, FormField, FormInputWrap, FormLabel };
|
|
31
|
+
export type { FormErrorProps, FormFieldProps, FormInputWrapProps, FormLabelProps, FormProps };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Tooltip } from "@payloadcms/ui/elements/Tooltip";
|
|
3
|
+
import clsx from "clsx";
|
|
4
|
+
import React from "react";
|
|
5
|
+
import "./index.scss";
|
|
6
|
+
const FormField = ({ children, hasError, className, ...rest })=>/*#__PURE__*/ _jsx("div", {
|
|
7
|
+
className: clsx('field-type', className, {
|
|
8
|
+
error: hasError
|
|
9
|
+
}),
|
|
10
|
+
...rest,
|
|
11
|
+
children: children
|
|
12
|
+
});
|
|
13
|
+
const FormLabel = ({ label, required = false, className, htmlFor, ...rest })=>/*#__PURE__*/ _jsxs("label", {
|
|
14
|
+
className: clsx('field-label', className),
|
|
15
|
+
htmlFor: htmlFor,
|
|
16
|
+
...rest,
|
|
17
|
+
children: [
|
|
18
|
+
label,
|
|
19
|
+
required && /*#__PURE__*/ _jsx("span", {
|
|
20
|
+
className: "required",
|
|
21
|
+
children: "*"
|
|
22
|
+
})
|
|
23
|
+
]
|
|
24
|
+
});
|
|
25
|
+
export const FieldErrors = ({ error, className })=>{
|
|
26
|
+
const errorMessage = error?.message ?? null;
|
|
27
|
+
return /*#__PURE__*/ _jsx(Tooltip, {
|
|
28
|
+
alignCaret: "right",
|
|
29
|
+
className: clsx('field-error', className),
|
|
30
|
+
show: !!errorMessage,
|
|
31
|
+
delay: 0,
|
|
32
|
+
staticPositioning: true,
|
|
33
|
+
children: errorMessage
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
const FormError = ({ errors, className })=>errors ? /*#__PURE__*/ _jsx("div", {
|
|
37
|
+
className: clsx('form-error', className),
|
|
38
|
+
children: errors.join(', ')
|
|
39
|
+
}) : null;
|
|
40
|
+
const Form = ({ children, className, ...rest })=>/*#__PURE__*/ _jsx("form", {
|
|
41
|
+
className: clsx('form', className),
|
|
42
|
+
...rest,
|
|
43
|
+
children: children
|
|
44
|
+
});
|
|
45
|
+
const FormInputWrap = ({ children, className, ...rest })=>/*#__PURE__*/ _jsx("div", {
|
|
46
|
+
className: `${className}__inputWrap`,
|
|
47
|
+
...rest,
|
|
48
|
+
children: children
|
|
49
|
+
});
|
|
50
|
+
const FieldInputWrap = ({ children, className, ...rest })=>/*#__PURE__*/ _jsx("div", {
|
|
51
|
+
className: clsx('field-type__wrap', className),
|
|
52
|
+
...rest,
|
|
53
|
+
children: children
|
|
54
|
+
});
|
|
55
|
+
export { FieldInputWrap, Form, FormError, FormField, FormInputWrap, FormLabel };
|
|
56
|
+
|
|
57
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/shared/form/ui/index.tsx"],"sourcesContent":["import { Tooltip } from '@payloadcms/ui/elements/Tooltip';\nimport clsx from 'clsx';\nimport React, { type ComponentPropsWithoutRef, type ReactNode } from 'react';\nimport type { FieldError } from 'react-hook-form';\n\nimport './index.scss';\n\ntype FormFieldProps = ComponentPropsWithoutRef<'div'> & {\n hasError?: boolean;\n};\n\nconst FormField: React.FC<FormFieldProps> = ({ children, hasError, className, ...rest }) => (\n <div className={clsx('field-type', className, { error: hasError })} {...rest}>\n {children}\n </div>\n);\n\ntype FormLabelProps = ComponentPropsWithoutRef<'label'> & {\n label: ReactNode;\n required?: boolean;\n htmlFor?: string;\n};\n\nconst FormLabel: React.FC<FormLabelProps> = ({ label, required = false, className, htmlFor, ...rest }) => (\n <label className={clsx('field-label', className)} htmlFor={htmlFor} {...rest}>\n {label}\n {required && <span className='required'>*</span>}\n </label>\n);\n\ntype FieldErrorsProps = {\n error?: FieldError;\n className?: string;\n};\n\nexport const FieldErrors = ({ error, className }: FieldErrorsProps) => {\n const errorMessage = error?.message ?? null;\n\n return (\n <Tooltip\n alignCaret='right'\n className={clsx('field-error', className)}\n show={!!errorMessage}\n delay={0}\n staticPositioning\n >\n {errorMessage}\n </Tooltip>\n );\n};\n\ntype FormErrorProps = {\n errors?: string[];\n className?: string;\n};\n\nconst FormError: React.FC<FormErrorProps> = ({ errors, className }) =>\n errors ? <div className={clsx('form-error', className)}>{errors.join(', ')}</div> : null;\n\ntype FormProps = ComponentPropsWithoutRef<'form'>;\n\nconst Form: React.FC<FormProps> = ({ children, className, ...rest }) => (\n <form className={clsx('form', className)} {...rest}>\n {children}\n </form>\n);\n\ntype FormInputWrapProps = ComponentPropsWithoutRef<'div'>;\n\nconst FormInputWrap: React.FC<FormInputWrapProps> = ({ children, className, ...rest }) => (\n <div className={`${className}__inputWrap`} {...rest}>\n {children}\n </div>\n);\n\ntype FieldInputWrapProps = ComponentPropsWithoutRef<'div'>;\n\nconst FieldInputWrap: React.FC<FieldInputWrapProps> = ({ children, className, ...rest }) => (\n <div className={clsx('field-type__wrap', className)} {...rest}>\n {children}\n </div>\n);\n\nexport { FieldInputWrap, Form, FormError, FormField, FormInputWrap, FormLabel };\nexport type { FormErrorProps, FormFieldProps, FormInputWrapProps, FormLabelProps, FormProps };\n"],"names":["Tooltip","clsx","React","FormField","children","hasError","className","rest","div","error","FormLabel","label","required","htmlFor","span","FieldErrors","errorMessage","message","alignCaret","show","delay","staticPositioning","FormError","errors","join","Form","form","FormInputWrap","FieldInputWrap"],"mappings":";AAAA,SAASA,OAAO,QAAQ,kCAAkC;AAC1D,OAAOC,UAAU,OAAO;AACxB,OAAOC,WAA8D,QAAQ;AAG7E,OAAO,eAAe;AAMtB,MAAMC,YAAsC,CAAC,EAAEC,QAAQ,EAAEC,QAAQ,EAAEC,SAAS,EAAE,GAAGC,MAAM,iBACrF,KAACC;QAAIF,WAAWL,KAAK,cAAcK,WAAW;YAAEG,OAAOJ;QAAS;QAAK,GAAGE,IAAI;kBACzEH;;AAUL,MAAMM,YAAsC,CAAC,EAAEC,KAAK,EAAEC,WAAW,KAAK,EAAEN,SAAS,EAAEO,OAAO,EAAE,GAAGN,MAAM,iBACnG,MAACI;QAAML,WAAWL,KAAK,eAAeK;QAAYO,SAASA;QAAU,GAAGN,IAAI;;YACzEI;YACAC,0BAAY,KAACE;gBAAKR,WAAU;0BAAW;;;;AAS5C,OAAO,MAAMS,cAAc,CAAC,EAAEN,KAAK,EAAEH,SAAS,EAAoB;IAChE,MAAMU,eAAeP,OAAOQ,WAAW;IAEvC,qBACE,KAACjB;QACCkB,YAAW;QACXZ,WAAWL,KAAK,eAAeK;QAC/Ba,MAAM,CAAC,CAACH;QACRI,OAAO;QACPC,iBAAiB;kBAEhBL;;AAGP,EAAE;AAOF,MAAMM,YAAsC,CAAC,EAAEC,MAAM,EAAEjB,SAAS,EAAE,GAChEiB,uBAAS,KAACf;QAAIF,WAAWL,KAAK,cAAcK;kBAAaiB,OAAOC,IAAI,CAAC;SAAe;AAItF,MAAMC,OAA4B,CAAC,EAAErB,QAAQ,EAAEE,SAAS,EAAE,GAAGC,MAAM,iBACjE,KAACmB;QAAKpB,WAAWL,KAAK,QAAQK;QAAa,GAAGC,IAAI;kBAC/CH;;AAML,MAAMuB,gBAA8C,CAAC,EAAEvB,QAAQ,EAAEE,SAAS,EAAE,GAAGC,MAAM,iBACnF,KAACC;QAAIF,WAAW,GAAGA,UAAU,WAAW,CAAC;QAAG,GAAGC,IAAI;kBAChDH;;AAML,MAAMwB,iBAAgD,CAAC,EAAExB,QAAQ,EAAEE,SAAS,EAAE,GAAGC,MAAM,iBACrF,KAACC;QAAIF,WAAWL,KAAK,oBAAoBK;QAAa,GAAGC,IAAI;kBAC1DH;;AAIL,SAASwB,cAAc,EAAEH,IAAI,EAAEH,SAAS,EAAEnB,SAAS,EAAEwB,aAAa,EAAEjB,SAAS,GAAG"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal translation function type extracted from `i18next`.
|
|
3
|
+
* Accepts a key and returns the translated string.
|
|
4
|
+
*/
|
|
5
|
+
export type Translate = (...args: any[]) => string;
|
|
6
|
+
export declare const emailField: ({ t, required }: {
|
|
7
|
+
t: Translate;
|
|
8
|
+
required?: boolean;
|
|
9
|
+
}) => any;
|
|
10
|
+
export declare const usernameField: ({ t, required }: {
|
|
11
|
+
t: Translate;
|
|
12
|
+
required?: boolean;
|
|
13
|
+
}) => any;
|
|
14
|
+
export declare const passwordField: ({ t, required, minLength, }: {
|
|
15
|
+
t: Translate;
|
|
16
|
+
required?: boolean;
|
|
17
|
+
minLength?: number;
|
|
18
|
+
}) => any;
|
|
19
|
+
export declare const confirmPasswordField: ({ t, required, }: {
|
|
20
|
+
t: Translate;
|
|
21
|
+
required?: boolean;
|
|
22
|
+
}) => any;
|
|
23
|
+
/**
|
|
24
|
+
* Returns a Zod object schema with `password` and `confirmPassword` fields
|
|
25
|
+
* and a refinement that ensures they match.
|
|
26
|
+
*/
|
|
27
|
+
export declare const passwordWithConfirmation: ({ t, minLength, }: {
|
|
28
|
+
t: Translate;
|
|
29
|
+
minLength?: number;
|
|
30
|
+
}) => any;
|
|
31
|
+
export declare const isValidEmail: (val: string) => boolean;
|
|
32
|
+
export declare const isValidUsername: (val: string, { minLength, maxLength }?: {
|
|
33
|
+
minLength?: number;
|
|
34
|
+
maxLength?: number;
|
|
35
|
+
}) => boolean;
|
|
36
|
+
type UsernameSettings = {
|
|
37
|
+
minLength: number;
|
|
38
|
+
maxLength: number;
|
|
39
|
+
};
|
|
40
|
+
export declare const createLoginSchema: ({ t, loginType, canLoginWithUsername, usernameSettings, }: {
|
|
41
|
+
t: Translate;
|
|
42
|
+
loginType: "email" | "username" | "emailOrUsername";
|
|
43
|
+
canLoginWithUsername?: boolean;
|
|
44
|
+
usernameSettings?: UsernameSettings;
|
|
45
|
+
}) => any;
|
|
46
|
+
export declare const createSignupSchema: ({ t, requireUsername, requireConfirmPassword, }: {
|
|
47
|
+
t: Translate;
|
|
48
|
+
requireUsername?: boolean;
|
|
49
|
+
requireConfirmPassword?: boolean;
|
|
50
|
+
}) => any;
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
// Email regex pattern
|
|
3
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
4
|
+
// Username regex pattern: alphanumeric, underscore, hyphen, 3-20 characters
|
|
5
|
+
const usernameRegex = /^[a-zA-Z0-9_-]{3,20}$/;
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
// Field builders
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
export const emailField = ({ t, required = true })=>{
|
|
10
|
+
let schema = z.string();
|
|
11
|
+
if (required) schema = schema.min(1, t('validation:required'));
|
|
12
|
+
return schema.refine((val)=>emailRegex.test(val), {
|
|
13
|
+
message: t('authentication:emailNotValid') ?? 'Email is not valid'
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
export const usernameField = ({ t, required = true })=>{
|
|
17
|
+
let schema = z.string();
|
|
18
|
+
if (required) schema = schema.min(1, t('validation:required'));
|
|
19
|
+
return schema.refine((val)=>usernameRegex.test(val), {
|
|
20
|
+
message: t('authentication:usernameNotValid') ?? 'Username is not valid'
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
export const passwordField = ({ t, required = true, minLength = 1 })=>{
|
|
24
|
+
let schema = z.string();
|
|
25
|
+
if (required) schema = schema.min(minLength, t('validation:required') ?? 'Password is required');
|
|
26
|
+
return schema;
|
|
27
|
+
};
|
|
28
|
+
export const confirmPasswordField = ({ t, required = true })=>{
|
|
29
|
+
let schema = z.string();
|
|
30
|
+
if (required) schema = schema.min(1, t('validation:required') ?? 'Confirm password is required');
|
|
31
|
+
return schema;
|
|
32
|
+
};
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
// Composables
|
|
35
|
+
// ---------------------------------------------------------------------------
|
|
36
|
+
/**
|
|
37
|
+
* Returns a Zod object schema with `password` and `confirmPassword` fields
|
|
38
|
+
* and a refinement that ensures they match.
|
|
39
|
+
*/ export const passwordWithConfirmation = ({ t, minLength = 1 })=>z.object({
|
|
40
|
+
password: passwordField({
|
|
41
|
+
t,
|
|
42
|
+
minLength
|
|
43
|
+
}),
|
|
44
|
+
confirmPassword: confirmPasswordField({
|
|
45
|
+
t
|
|
46
|
+
})
|
|
47
|
+
}).refine((data)=>data.password === data.confirmPassword, {
|
|
48
|
+
path: [
|
|
49
|
+
'confirmPassword'
|
|
50
|
+
],
|
|
51
|
+
message: t('fields:passwordsDoNotMatch') ?? 'Passwords do not match'
|
|
52
|
+
});
|
|
53
|
+
// ---------------------------------------------------------------------------
|
|
54
|
+
// Utility validators (non‑Zod) — handy for dynamic login field checks
|
|
55
|
+
// ---------------------------------------------------------------------------
|
|
56
|
+
export const isValidEmail = (val)=>emailRegex.test(val);
|
|
57
|
+
export const isValidUsername = (val, { minLength = 5, maxLength = 128 } = {})=>usernameRegex.test(val) && val.length >= minLength && val.length <= maxLength;
|
|
58
|
+
export const createLoginSchema = ({ t, loginType, canLoginWithUsername = false, usernameSettings = {
|
|
59
|
+
minLength: 5,
|
|
60
|
+
maxLength: 128
|
|
61
|
+
} })=>z.object({
|
|
62
|
+
login: z.string().superRefine((val, ctx)=>{
|
|
63
|
+
if (!val) {
|
|
64
|
+
ctx.addIssue({
|
|
65
|
+
code: z.ZodIssueCode.custom,
|
|
66
|
+
message: t('validation:required')
|
|
67
|
+
});
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const isProbablyEmail = val.includes('@') || !canLoginWithUsername;
|
|
71
|
+
if (loginType === 'email') {
|
|
72
|
+
if (!isValidEmail(val)) {
|
|
73
|
+
ctx.addIssue({
|
|
74
|
+
code: z.ZodIssueCode.custom,
|
|
75
|
+
message: t('authentication:emailNotValid') || 'Email is not valid'
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
} else if (loginType === 'username') {
|
|
79
|
+
if (!isValidUsername(val, usernameSettings)) {
|
|
80
|
+
ctx.addIssue({
|
|
81
|
+
code: z.ZodIssueCode.custom,
|
|
82
|
+
message: t('authentication:usernameNotValid') || 'Username is not valid'
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
} else {
|
|
86
|
+
if (!isValidEmail(val) && !isValidUsername(val, usernameSettings)) {
|
|
87
|
+
ctx.addIssue({
|
|
88
|
+
code: z.ZodIssueCode.custom,
|
|
89
|
+
message: isProbablyEmail ? t('authentication:emailNotValid') || 'Email is not valid' : t('authentication:usernameNotValid') || 'Username is not valid'
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}),
|
|
94
|
+
password: passwordField({
|
|
95
|
+
t
|
|
96
|
+
})
|
|
97
|
+
});
|
|
98
|
+
export const createSignupSchema = ({ t, requireUsername = false, requireConfirmPassword = false })=>{
|
|
99
|
+
const schema = z.object({
|
|
100
|
+
name: z.string({
|
|
101
|
+
message: 'Name is required'
|
|
102
|
+
}).min(1),
|
|
103
|
+
email: emailField({
|
|
104
|
+
t
|
|
105
|
+
}),
|
|
106
|
+
username: usernameField({
|
|
107
|
+
t,
|
|
108
|
+
required: requireUsername
|
|
109
|
+
}).optional(),
|
|
110
|
+
password: passwordField({
|
|
111
|
+
t
|
|
112
|
+
}),
|
|
113
|
+
confirmPassword: confirmPasswordField({
|
|
114
|
+
t,
|
|
115
|
+
required: requireConfirmPassword
|
|
116
|
+
}).optional()
|
|
117
|
+
});
|
|
118
|
+
if (!requireConfirmPassword) return schema;
|
|
119
|
+
return schema.refine((data)=>data.password === data.confirmPassword, {
|
|
120
|
+
path: [
|
|
121
|
+
'confirmPassword'
|
|
122
|
+
],
|
|
123
|
+
message: t('fields:passwordsDoNotMatch') || 'Passwords do not match'
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
//# sourceMappingURL=validation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/shared/form/validation.ts"],"sourcesContent":["import { z } from 'zod';\n\n// Email regex pattern\nconst emailRegex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n// Username regex pattern: alphanumeric, underscore, hyphen, 3-20 characters\nconst usernameRegex = /^[a-zA-Z0-9_-]{3,20}$/;\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/**\n * Minimal translation function type extracted from `i18next`.\n * Accepts a key and returns the translated string.\n */\nexport type Translate = (...args: any[]) => string;\n\n// ---------------------------------------------------------------------------\n// Field builders\n// ---------------------------------------------------------------------------\n\nexport const emailField = ({ t, required = true }: { t: Translate; required?: boolean }) => {\n let schema = z.string();\n if (required) schema = schema.min(1, t('validation:required'));\n return schema.refine(val => emailRegex.test(val), {\n message: t('authentication:emailNotValid') ?? 'Email is not valid',\n });\n};\n\nexport const usernameField = ({ t, required = true }: { t: Translate; required?: boolean }) => {\n let schema = z.string();\n if (required) schema = schema.min(1, t('validation:required'));\n return schema.refine(val => usernameRegex.test(val), {\n message: t('authentication:usernameNotValid') ?? 'Username is not valid',\n });\n};\n\nexport const passwordField = ({\n t,\n required = true,\n minLength = 1,\n}: {\n t: Translate;\n required?: boolean;\n minLength?: number;\n}) => {\n let schema = z.string();\n if (required) schema = schema.min(minLength, t('validation:required') ?? 'Password is required');\n return schema;\n};\n\nexport const confirmPasswordField = ({\n t,\n required = true,\n}: {\n t: Translate;\n required?: boolean;\n}) => {\n let schema = z.string();\n if (required) schema = schema.min(1, t('validation:required') ?? 'Confirm password is required');\n return schema;\n};\n\n// ---------------------------------------------------------------------------\n// Composables\n// ---------------------------------------------------------------------------\n\n/**\n * Returns a Zod object schema with `password` and `confirmPassword` fields\n * and a refinement that ensures they match.\n */\nexport const passwordWithConfirmation = ({\n t,\n minLength = 1,\n}: {\n t: Translate;\n minLength?: number;\n}) =>\n z\n .object({\n password: passwordField({ t, minLength }),\n confirmPassword: confirmPasswordField({ t }),\n })\n .refine(data => data.password === data.confirmPassword, {\n path: ['confirmPassword'],\n message: t('fields:passwordsDoNotMatch') ?? 'Passwords do not match',\n });\n\n// ---------------------------------------------------------------------------\n// Utility validators (non‑Zod) — handy for dynamic login field checks\n// ---------------------------------------------------------------------------\n\nexport const isValidEmail = (val: string) => emailRegex.test(val);\nexport const isValidUsername = (\n val: string,\n { minLength = 5, maxLength = 128 }: { minLength?: number; maxLength?: number } = {}\n) => usernameRegex.test(val) && val.length >= minLength && val.length <= maxLength;\n\n// ---------------------------------------------------------------------------\n// Schema builders\n// ---------------------------------------------------------------------------\n\ntype UsernameSettings = { minLength: number; maxLength: number };\n\nexport const createLoginSchema = ({\n t,\n loginType,\n canLoginWithUsername = false,\n usernameSettings = { minLength: 5, maxLength: 128 },\n}: {\n t: Translate;\n loginType: 'email' | 'username' | 'emailOrUsername';\n canLoginWithUsername?: boolean;\n usernameSettings?: UsernameSettings;\n}) =>\n z.object({\n login: z.string().superRefine((val, ctx) => {\n if (!val) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: t('validation:required'),\n });\n return;\n }\n\n const isProbablyEmail = val.includes('@') || !canLoginWithUsername;\n\n if (loginType === 'email') {\n if (!isValidEmail(val)) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: t('authentication:emailNotValid') || 'Email is not valid',\n });\n }\n } else if (loginType === 'username') {\n if (!isValidUsername(val, usernameSettings)) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: t('authentication:usernameNotValid') || 'Username is not valid',\n });\n }\n } else {\n if (!isValidEmail(val) && !isValidUsername(val, usernameSettings)) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n message: isProbablyEmail\n ? t('authentication:emailNotValid') || 'Email is not valid'\n : t('authentication:usernameNotValid') || 'Username is not valid',\n });\n }\n }\n }),\n password: passwordField({ t }),\n });\n\nexport const createSignupSchema = ({\n t,\n requireUsername = false,\n requireConfirmPassword = false,\n}: {\n t: Translate;\n requireUsername?: boolean;\n requireConfirmPassword?: boolean;\n}) => {\n const schema = z.object({\n name: z.string({ message: 'Name is required' }).min(1),\n email: emailField({ t }),\n username: usernameField({ t, required: requireUsername }).optional(),\n password: passwordField({ t }),\n confirmPassword: confirmPasswordField({ t, required: requireConfirmPassword }).optional(),\n });\n\n if (!requireConfirmPassword) return schema;\n\n return schema.refine(data => data.password === data.confirmPassword, {\n path: ['confirmPassword'],\n message: t('fields:passwordsDoNotMatch') || 'Passwords do not match',\n });\n};\n"],"names":["z","emailRegex","usernameRegex","emailField","t","required","schema","string","min","refine","val","test","message","usernameField","passwordField","minLength","confirmPasswordField","passwordWithConfirmation","object","password","confirmPassword","data","path","isValidEmail","isValidUsername","maxLength","length","createLoginSchema","loginType","canLoginWithUsername","usernameSettings","login","superRefine","ctx","addIssue","code","ZodIssueCode","custom","isProbablyEmail","includes","createSignupSchema","requireUsername","requireConfirmPassword","name","email","username","optional"],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/shared/index.ts"],"sourcesContent":["export * from './payload/fields/field-copy-button';\nexport * from './payload/fields/generate-uuid-button';\n"],"names":[],"mappings":"AAAA,cAAc,qCAAqC;AACnD,cAAc,wCAAwC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import "./index.css";
|
|
4
|
+
import { Button, CopyIcon, useField } from "@payloadcms/ui";
|
|
5
|
+
import { useRef, useState } from "react";
|
|
6
|
+
export const FieldCopyButton = ({ path })=>{
|
|
7
|
+
const { value } = useField({
|
|
8
|
+
path
|
|
9
|
+
});
|
|
10
|
+
const [copied, setCopied] = useState(false);
|
|
11
|
+
const buttonRef = useRef(null);
|
|
12
|
+
const handleCopy = ()=>{
|
|
13
|
+
navigator.clipboard.writeText(value);
|
|
14
|
+
setCopied(true);
|
|
15
|
+
setTimeout(()=>{
|
|
16
|
+
setCopied(false);
|
|
17
|
+
}, 2000);
|
|
18
|
+
};
|
|
19
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
20
|
+
className: "field-copy-text__button-wrapper",
|
|
21
|
+
children: [
|
|
22
|
+
/*#__PURE__*/ _jsx("div", {
|
|
23
|
+
className: "field-copy-text__tooltip",
|
|
24
|
+
"data-visible": copied,
|
|
25
|
+
children: "Copied"
|
|
26
|
+
}),
|
|
27
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
28
|
+
ref: buttonRef,
|
|
29
|
+
icon: /*#__PURE__*/ _jsx(CopyIcon, {}),
|
|
30
|
+
buttonStyle: "transparent",
|
|
31
|
+
onClick: handleCopy,
|
|
32
|
+
className: "field-copy-text__button"
|
|
33
|
+
})
|
|
34
|
+
]
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/shared/payload/fields/field-copy-button/index.tsx"],"sourcesContent":["'use client';\nimport './index.css';\nimport { Button, CopyIcon, TextField, useField } from '@payloadcms/ui';\nimport { useRef, useState } from 'react';\n\nexport const FieldCopyButton: typeof TextField = ({ path }) => {\n const { value } = useField({ path });\n const [copied, setCopied] = useState(false);\n const buttonRef = useRef<HTMLButtonElement>(null);\n\n const handleCopy = () => {\n navigator.clipboard.writeText(value as string);\n setCopied(true);\n setTimeout(() => {\n setCopied(false);\n }, 2000);\n };\n return (\n <div className='field-copy-text__button-wrapper'>\n <div className='field-copy-text__tooltip' data-visible={copied}>\n Copied\n </div>\n <Button\n ref={buttonRef}\n icon={<CopyIcon />}\n buttonStyle='transparent'\n onClick={handleCopy}\n className='field-copy-text__button'\n />\n </div>\n );\n};\n"],"names":["Button","CopyIcon","useField","useRef","useState","FieldCopyButton","path","value","copied","setCopied","buttonRef","handleCopy","navigator","clipboard","writeText","setTimeout","div","className","data-visible","ref","icon","buttonStyle","onClick"],"mappings":"AAAA;;AACA,OAAO,cAAc;AACrB,SAASA,MAAM,EAAEC,QAAQ,EAAaC,QAAQ,QAAQ,iBAAiB;AACvE,SAASC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAEzC,OAAO,MAAMC,kBAAoC,CAAC,EAAEC,IAAI,EAAE;IACxD,MAAM,EAAEC,KAAK,EAAE,GAAGL,SAAS;QAAEI;IAAK;IAClC,MAAM,CAACE,QAAQC,UAAU,GAAGL,SAAS;IACrC,MAAMM,YAAYP,OAA0B;IAE5C,MAAMQ,aAAa;QACjBC,UAAUC,SAAS,CAACC,SAAS,CAACP;QAC9BE,UAAU;QACVM,WAAW;YACTN,UAAU;QACZ,GAAG;IACL;IACA,qBACE,MAACO;QAAIC,WAAU;;0BACb,KAACD;gBAAIC,WAAU;gBAA2BC,gBAAcV;0BAAQ;;0BAGhE,KAACR;gBACCmB,KAAKT;gBACLU,oBAAM,KAACnB;gBACPoB,aAAY;gBACZC,SAASX;gBACTM,WAAU;;;;AAIlB,EAAE"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import "./index.css";
|
|
4
|
+
import { Button, useField } from "@payloadcms/ui";
|
|
5
|
+
import { useRef } from "react";
|
|
6
|
+
export const GenerateUuidButton = ({ path })=>{
|
|
7
|
+
const { setValue } = useField({
|
|
8
|
+
path
|
|
9
|
+
});
|
|
10
|
+
const buttonRef = useRef(null);
|
|
11
|
+
const handleGenerate = ()=>{
|
|
12
|
+
setValue(crypto.randomUUID());
|
|
13
|
+
};
|
|
14
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
15
|
+
className: "generate-uuid-button-wrapper",
|
|
16
|
+
children: /*#__PURE__*/ _jsx(Button, {
|
|
17
|
+
ref: buttonRef,
|
|
18
|
+
buttonStyle: "primary",
|
|
19
|
+
onClick: handleGenerate,
|
|
20
|
+
className: "generate-uuid-button",
|
|
21
|
+
children: "Generate UUID"
|
|
22
|
+
})
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/shared/payload/fields/generate-uuid-button/index.tsx"],"sourcesContent":["'use client';\n\nimport './index.css';\nimport { Button, TextField, useField } from '@payloadcms/ui';\nimport { useRef } from 'react';\n\nexport const GenerateUuidButton: typeof TextField = ({ path }) => {\n const { setValue } = useField({ path });\n const buttonRef = useRef<HTMLButtonElement>(null);\n\n const handleGenerate = () => {\n setValue(crypto.randomUUID());\n };\n\n return (\n <div className='generate-uuid-button-wrapper'>\n <Button\n ref={buttonRef}\n buttonStyle='primary'\n onClick={handleGenerate}\n className='generate-uuid-button'\n >\n Generate UUID\n </Button>\n </div>\n );\n};\n"],"names":["Button","useField","useRef","GenerateUuidButton","path","setValue","buttonRef","handleGenerate","crypto","randomUUID","div","className","ref","buttonStyle","onClick"],"mappings":"AAAA;;AAEA,OAAO,cAAc;AACrB,SAASA,MAAM,EAAaC,QAAQ,QAAQ,iBAAiB;AAC7D,SAASC,MAAM,QAAQ,QAAQ;AAE/B,OAAO,MAAMC,qBAAuC,CAAC,EAAEC,IAAI,EAAE;IAC3D,MAAM,EAAEC,QAAQ,EAAE,GAAGJ,SAAS;QAAEG;IAAK;IACrC,MAAME,YAAYJ,OAA0B;IAE5C,MAAMK,iBAAiB;QACrBF,SAASG,OAAOC,UAAU;IAC5B;IAEA,qBACE,KAACC;QAAIC,WAAU;kBACb,cAAA,KAACX;YACCY,KAAKN;YACLO,aAAY;YACZC,SAASP;YACTI,WAAU;sBACX;;;AAKP,EAAE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/shared/payload/fields/index.ts"],"sourcesContent":["export * from './field-copy-button';\nexport * from './generate-uuid-button';\n"],"names":[],"mappings":"AAAA,cAAc,sBAAsB;AACpC,cAAc,yBAAyB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/shared/utils/regex.ts"],"sourcesContent":["export const emailRegex =\n /^(?!\\.)(?!.*\\.\\.)([a-z0-9_'+\\-\\.]*)[a-z0-9_'+\\-]@([a-z0-9][a-z0-9\\-]*\\.)+[a-z]{2,}$/i;\nexport const usernameRegex = /^[a-zA-Z0-9._-]+$/;\n"],"names":["emailRegex","usernameRegex"],"mappings":"AAAA,OAAO,MAAMA,aACX,uFAAuF;AACzF,OAAO,MAAMC,gBAAgB,oBAAoB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type Success<T> = {
|
|
2
|
+
data: T;
|
|
3
|
+
error: null;
|
|
4
|
+
};
|
|
5
|
+
type Failure<E> = {
|
|
6
|
+
data: null;
|
|
7
|
+
error: E;
|
|
8
|
+
};
|
|
9
|
+
type Result<T, E = Error> = Success<T> | Failure<E>;
|
|
10
|
+
export declare function tryCatch<T, E = Error>(promise: Promise<T>): Promise<Result<T, E>>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Main wrapper function
|
|
2
|
+
export async function tryCatch(promise) {
|
|
3
|
+
try {
|
|
4
|
+
const data = await promise;
|
|
5
|
+
return {
|
|
6
|
+
data,
|
|
7
|
+
error: null
|
|
8
|
+
};
|
|
9
|
+
} catch (error) {
|
|
10
|
+
return {
|
|
11
|
+
data: null,
|
|
12
|
+
error: error
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=try-catch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/shared/utils/try-catch.ts"],"sourcesContent":["type Success<T> = {\n data: T;\n error: null;\n};\n\ntype Failure<E> = {\n data: null;\n error: E;\n};\n\ntype Result<T, E = Error> = Success<T> | Failure<E>;\n\n// Main wrapper function\nexport async function tryCatch<T, E = Error>(promise: Promise<T>): Promise<Result<T, E>> {\n try {\n const data = await promise;\n return { data, error: null };\n } catch (error) {\n return { data: null, error: error as E };\n }\n}\n"],"names":["tryCatch","promise","data","error"],"mappings":"AAYA,wBAAwB;AACxB,OAAO,eAAeA,SAAuBC,OAAmB;IAC9D,IAAI;QACF,MAAMC,OAAO,MAAMD;QACnB,OAAO;YAAEC;YAAMC,OAAO;QAAK;IAC7B,EAAE,OAAOA,OAAO;QACd,OAAO;YAAED,MAAM;YAAMC,OAAOA;QAAW;IACzC;AACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the provided value if it's defined (not undefined), otherwise returns the default value.
|
|
3
|
+
* Unlike null checks, this allows empty strings to pass through.
|
|
4
|
+
*
|
|
5
|
+
* @param value - The value to check
|
|
6
|
+
* @param defaultValue - The default value to return if the provided value is undefined
|
|
7
|
+
* @returns The provided value if defined, otherwise the default value
|
|
8
|
+
*/
|
|
9
|
+
export declare function valueOrDefaultString<T extends string>(value: T | undefined, defaultValue: T): T;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the provided value if it's defined (not undefined), otherwise returns the default value.
|
|
3
|
+
* Unlike null checks, this allows empty strings to pass through.
|
|
4
|
+
*
|
|
5
|
+
* @param value - The value to check
|
|
6
|
+
* @param defaultValue - The default value to return if the provided value is undefined
|
|
7
|
+
* @returns The provided value if defined, otherwise the default value
|
|
8
|
+
*/ export function valueOrDefaultString(value, defaultValue) {
|
|
9
|
+
return value !== undefined ? value : defaultValue;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=value-or-default.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/shared/utils/value-or-default.ts"],"sourcesContent":["/**\n * Returns the provided value if it's defined (not undefined), otherwise returns the default value.\n * Unlike null checks, this allows empty strings to pass through.\n *\n * @param value - The value to check\n * @param defaultValue - The default value to return if the provided value is undefined\n * @returns The provided value if defined, otherwise the default value\n */\nexport function valueOrDefaultString<T extends string>(value: T | undefined, defaultValue: T): T {\n return value !== undefined ? value : defaultValue;\n}\n"],"names":["valueOrDefaultString","value","defaultValue","undefined"],"mappings":"AAAA;;;;;;;CAOC,GACD,OAAO,SAASA,qBAAuCC,KAAoB,EAAEC,YAAe;IAC1F,OAAOD,UAAUE,YAAYF,QAAQC;AACvC"}
|