@contember/create 2.1.0-rc.3 → 2.2.0-alpha.10
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/CLAUDE.md +22 -0
- package/dist/development/run.cjs +7 -7
- package/dist/development/run.cjs.map +1 -1
- package/dist/development/run.js +8 -8
- package/dist/development/run.js.map +1 -1
- package/dist/development/src/commands/WorkspaceCreateCommand.cjs +28 -14
- package/dist/development/src/commands/WorkspaceCreateCommand.cjs.map +1 -1
- package/dist/development/src/commands/WorkspaceCreateCommand.js +28 -14
- package/dist/development/src/commands/WorkspaceCreateCommand.js.map +1 -1
- package/dist/development/src/lib/FileSystem.cjs +1 -2
- package/dist/development/src/lib/FileSystem.cjs.map +1 -1
- package/dist/development/src/lib/FileSystem.js +1 -2
- package/dist/development/src/lib/FileSystem.js.map +1 -1
- package/dist/development/src/lib/TemplateInstaller.cjs +79 -67
- package/dist/development/src/lib/TemplateInstaller.cjs.map +1 -1
- package/dist/development/src/lib/TemplateInstaller.js +72 -60
- package/dist/development/src/lib/TemplateInstaller.js.map +1 -1
- package/dist/development/src/lib/packageManagerDetector.cjs +6 -6
- package/dist/development/src/lib/packageManagerDetector.cjs.map +1 -1
- package/dist/development/src/lib/version.cjs +2 -2
- package/dist/development/src/lib/version.cjs.map +1 -1
- package/dist/development/src/lib/version.js.map +1 -1
- package/dist/development/src/paths.cjs +3 -3
- package/dist/development/src/paths.cjs.map +1 -1
- package/dist/production/run.cjs +7 -7
- package/dist/production/run.cjs.map +1 -1
- package/dist/production/run.js +8 -8
- package/dist/production/run.js.map +1 -1
- package/dist/production/src/commands/WorkspaceCreateCommand.cjs +28 -14
- package/dist/production/src/commands/WorkspaceCreateCommand.cjs.map +1 -1
- package/dist/production/src/commands/WorkspaceCreateCommand.js +28 -14
- package/dist/production/src/commands/WorkspaceCreateCommand.js.map +1 -1
- package/dist/production/src/lib/FileSystem.cjs +1 -2
- package/dist/production/src/lib/FileSystem.cjs.map +1 -1
- package/dist/production/src/lib/FileSystem.js +1 -2
- package/dist/production/src/lib/FileSystem.js.map +1 -1
- package/dist/production/src/lib/TemplateInstaller.cjs +79 -67
- package/dist/production/src/lib/TemplateInstaller.cjs.map +1 -1
- package/dist/production/src/lib/TemplateInstaller.js +72 -60
- package/dist/production/src/lib/TemplateInstaller.js.map +1 -1
- package/dist/production/src/lib/packageManagerDetector.cjs +6 -6
- package/dist/production/src/lib/packageManagerDetector.cjs.map +1 -1
- package/dist/production/src/lib/version.cjs +2 -2
- package/dist/production/src/lib/version.cjs.map +1 -1
- package/dist/production/src/lib/version.js.map +1 -1
- package/dist/production/src/paths.cjs +3 -3
- package/dist/production/src/paths.cjs.map +1 -1
- package/dist/types/commands/WorkspaceCreateCommand.d.ts +16 -4
- package/dist/types/commands/WorkspaceCreateCommand.d.ts.map +1 -1
- package/dist/types/commands/index.d.ts +1 -1
- package/dist/types/commands/index.d.ts.map +1 -1
- package/dist/types/lib/FileSystem.d.ts +3 -2
- package/dist/types/lib/FileSystem.d.ts.map +1 -1
- package/dist/types/lib/TemplateInstaller.d.ts +10 -2
- package/dist/types/lib/TemplateInstaller.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -4
- package/resources/templates/default/README.md +3 -1
- package/resources/templates/default/admin/app/components/navigation.tsx +95 -8
- package/resources/templates/default/admin/app/pages/tenant.tsx +328 -77
- package/resources/templates/default/admin/entrypoint/components/login.tsx +1 -1
- package/resources/templates/default/admin/entrypoint/pages/magicLink.tsx +1 -1
- package/resources/templates/default/admin/entrypoint/pages/magicLinkSent.tsx +1 -1
- package/resources/templates/default/admin/entrypoint/pages/passwordReset.tsx +1 -1
- package/resources/templates/default/admin/entrypoint/pages/resetRequest.tsx +1 -1
- package/resources/templates/default/admin/entrypoint/pages/resetRequestSuccess.tsx +1 -1
- package/resources/templates/default/admin/lib/binding/binding.tsx +19 -4
- package/resources/templates/default/admin/lib/binding/delete.tsx +37 -3
- package/resources/templates/default/admin/lib/binding/hooks.tsx +65 -3
- package/resources/templates/default/admin/lib/binding/identity.tsx +17 -4
- package/resources/templates/default/admin/lib/binding/index.ts +5 -5
- package/resources/templates/default/admin/lib/binding/navigation-guard-dialog.tsx +15 -3
- package/resources/templates/default/admin/lib/binding/persist.tsx +27 -5
- package/resources/templates/default/admin/lib/block-repeater/block-repeater.tsx +15 -11
- package/resources/templates/default/admin/lib/block-repeater/index.ts +1 -1
- package/resources/templates/default/admin/lib/board/board.tsx +2 -2
- package/resources/templates/default/admin/lib/board/index.ts +1 -1
- package/resources/templates/default/admin/lib/buttons/back-button.tsx +22 -2
- package/resources/templates/default/admin/lib/buttons/index.ts +2 -2
- package/resources/templates/default/admin/lib/buttons/link-back-button.tsx +11 -2
- package/resources/templates/default/admin/lib/datagrid/cells.tsx +3 -3
- package/resources/templates/default/admin/lib/datagrid/column-header.tsx +4 -4
- package/resources/templates/default/admin/lib/datagrid/columns.tsx +28 -14
- package/resources/templates/default/admin/lib/datagrid/elements.tsx +2 -2
- package/resources/templates/default/admin/lib/datagrid/empty.tsx +1 -1
- package/resources/templates/default/admin/lib/datagrid/export.tsx +2 -2
- package/resources/templates/default/admin/lib/datagrid/filters/boolean.tsx +13 -13
- package/resources/templates/default/admin/lib/datagrid/filters/common.tsx +2 -2
- package/resources/templates/default/admin/lib/datagrid/filters/date.tsx +37 -16
- package/resources/templates/default/admin/lib/datagrid/filters/defined.tsx +13 -12
- package/resources/templates/default/admin/lib/datagrid/filters/enum.tsx +56 -22
- package/resources/templates/default/admin/lib/datagrid/filters/index.ts +7 -7
- package/resources/templates/default/admin/lib/datagrid/filters/mobile.tsx +18 -0
- package/resources/templates/default/admin/lib/datagrid/filters/number.tsx +10 -13
- package/resources/templates/default/admin/lib/datagrid/filters/relation.tsx +8 -8
- package/resources/templates/default/admin/lib/datagrid/filters/text.tsx +9 -9
- package/resources/templates/default/admin/lib/datagrid/grid.tsx +31 -23
- package/resources/templates/default/admin/lib/datagrid/index.ts +12 -12
- package/resources/templates/default/admin/lib/datagrid/labels.tsx +22 -4
- package/resources/templates/default/admin/lib/datagrid/layout-switcher.tsx +10 -4
- package/resources/templates/default/admin/lib/datagrid/loader.tsx +4 -4
- package/resources/templates/default/admin/lib/datagrid/pagination.tsx +16 -6
- package/resources/templates/default/admin/lib/datagrid/table.tsx +8 -6
- package/resources/templates/default/admin/lib/datagrid/tiles.tsx +6 -5
- package/resources/templates/default/admin/lib/datagrid/toolbar.tsx +15 -19
- package/resources/templates/default/admin/lib/datagrid/ui.tsx +3 -3
- package/resources/templates/default/admin/lib/dev/index.ts +2 -2
- package/resources/templates/default/admin/lib/dev/login-panel.tsx +12 -3
- package/resources/templates/default/admin/lib/dev/todo.tsx +12 -0
- package/resources/templates/default/admin/lib/dict.ts +0 -261
- package/resources/templates/default/admin/lib/dimensions/dimensions.tsx +85 -4
- package/resources/templates/default/admin/lib/dimensions/index.ts +1 -1
- package/resources/templates/default/admin/lib/editor/block-editor.tsx +72 -3
- package/resources/templates/default/admin/lib/editor/common/baseEditorPlugins.tsx +54 -11
- package/resources/templates/default/admin/lib/editor/common/buttons.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/editor-block-toolbar.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/elements/HeadingRenderer.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/elements/HorizontalRuleRenderer.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/elements/ListItemRenderer.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/elements/OrderedListRenderer.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/elements/TableElementRenderer.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/elements/UnorderedListRenderer.tsx +1 -1
- package/resources/templates/default/admin/lib/editor/common/index.ts +6 -6
- package/resources/templates/default/admin/lib/editor/editor-block.tsx +54 -3
- package/resources/templates/default/admin/lib/editor/index.ts +6 -6
- package/resources/templates/default/admin/lib/editor/plugins.tsx +46 -2
- package/resources/templates/default/admin/lib/editor/rich-text-view.tsx +44 -0
- package/resources/templates/default/admin/lib/editor/rich-text.tsx +31 -3
- package/resources/templates/default/admin/lib/editor/sortable-block.tsx +34 -2
- package/resources/templates/default/admin/lib/errors/index.ts +1 -1
- package/resources/templates/default/admin/lib/errors/use-error-formatter.ts +22 -1
- package/resources/templates/default/admin/lib/field/formatted-field.tsx +16 -1
- package/resources/templates/default/admin/lib/field/index.ts +2 -1
- package/resources/templates/default/admin/lib/field/list-field.tsx +56 -0
- package/resources/templates/default/admin/lib/form/container.tsx +33 -3
- package/resources/templates/default/admin/lib/form/index.ts +6 -5
- package/resources/templates/default/admin/lib/form/inputs.tsx +105 -6
- package/resources/templates/default/admin/lib/form/labels.tsx +1 -1
- package/resources/templates/default/admin/lib/form/select.tsx +162 -5
- package/resources/templates/default/admin/lib/form/ui.tsx +2 -2
- package/resources/templates/default/admin/lib/form/upload-repeaters.tsx +159 -5
- package/resources/templates/default/admin/lib/form/upload.tsx +116 -3
- package/resources/templates/default/admin/lib/formatting/formatting.ts +106 -1
- package/resources/templates/default/admin/lib/formatting/index.ts +1 -1
- package/resources/templates/default/admin/lib/images/formatImageResizeUrl.ts +19 -0
- package/resources/templates/default/admin/lib/images/index.ts +1 -1
- package/resources/templates/default/admin/lib/index.ts +54 -0
- package/resources/templates/default/admin/lib/labels/index.ts +2 -2
- package/resources/templates/default/admin/lib/layout/index.ts +3 -3
- package/resources/templates/default/admin/lib/layout/layout-boxed.tsx +5 -5
- package/resources/templates/default/admin/lib/layout/layout.tsx +3 -3
- package/resources/templates/default/admin/lib/outdated-application-dialog/index.ts +1 -1
- package/resources/templates/default/admin/lib/outdated-application-dialog/outdated-application-dialog.tsx +2 -2
- package/resources/templates/default/admin/lib/repeater/index.ts +1 -1
- package/resources/templates/default/admin/lib/repeater/repeater.tsx +26 -9
- package/resources/templates/default/admin/lib/select/create-new.tsx +19 -3
- package/resources/templates/default/admin/lib/select/filter.tsx +8 -2
- package/resources/templates/default/admin/lib/select/highlight.tsx +16 -0
- package/resources/templates/default/admin/lib/select/index.ts +6 -6
- package/resources/templates/default/admin/lib/select/list.tsx +30 -6
- package/resources/templates/default/admin/lib/select/multi-select.tsx +41 -4
- package/resources/templates/default/admin/lib/select/select.tsx +44 -6
- package/resources/templates/default/admin/lib/select/sortable-select.tsx +15 -6
- package/resources/templates/default/admin/lib/select/ui.tsx +100 -4
- package/resources/templates/default/admin/lib/tenant/config/auth-policy-list.tsx +86 -0
- package/resources/templates/default/admin/lib/tenant/config/common.tsx +71 -0
- package/resources/templates/default/admin/lib/tenant/config/identity-provider-list.tsx +113 -0
- package/resources/templates/default/admin/lib/tenant/config/index.ts +5 -0
- package/resources/templates/default/admin/lib/tenant/config/mail-template-list.tsx +108 -0
- package/resources/templates/default/admin/lib/tenant/config/tenant-config-view.tsx +182 -0
- package/resources/templates/default/admin/lib/tenant/dict.ts +770 -0
- package/resources/templates/default/admin/lib/tenant/errors.ts +10 -0
- package/resources/templates/default/admin/lib/tenant/forms/add-project-member.tsx +57 -0
- package/resources/templates/default/admin/lib/tenant/forms/change-my-password.tsx +4 -4
- package/resources/templates/default/admin/lib/tenant/forms/change-my-profile.tsx +40 -0
- package/resources/templates/default/admin/lib/tenant/forms/change-profile.tsx +55 -0
- package/resources/templates/default/admin/lib/tenant/forms/common.tsx +12 -5
- package/resources/templates/default/admin/lib/tenant/forms/confirm-email-change.tsx +38 -0
- package/resources/templates/default/admin/lib/tenant/forms/create-api-key.tsx +5 -5
- package/resources/templates/default/admin/lib/tenant/forms/create-global-api-key.tsx +69 -0
- package/resources/templates/default/admin/lib/tenant/forms/global-roles-control.tsx +113 -0
- package/resources/templates/default/admin/lib/tenant/forms/index.ts +23 -8
- package/resources/templates/default/admin/lib/tenant/forms/invite.tsx +46 -8
- package/resources/templates/default/admin/lib/tenant/forms/login.tsx +8 -14
- package/resources/templates/default/admin/lib/tenant/forms/memberships-control.tsx +7 -5
- package/resources/templates/default/admin/lib/tenant/forms/mfa-code-fields.tsx +81 -0
- package/resources/templates/default/admin/lib/tenant/forms/password-reset-request.tsx +4 -4
- package/resources/templates/default/admin/lib/tenant/forms/password-reset.tsx +4 -4
- package/resources/templates/default/admin/lib/tenant/forms/passwordless-signin-init.tsx +4 -4
- package/resources/templates/default/admin/lib/tenant/forms/passwordless-signin.tsx +8 -14
- package/resources/templates/default/admin/lib/tenant/forms/request-email-verification.tsx +35 -0
- package/resources/templates/default/admin/lib/tenant/forms/set-person-password.tsx +58 -0
- package/resources/templates/default/admin/lib/tenant/forms/set-project-secret.tsx +59 -0
- package/resources/templates/default/admin/lib/tenant/forms/sign-up.tsx +73 -0
- package/resources/templates/default/admin/lib/tenant/forms/update-project-member.tsx +14 -5
- package/resources/templates/default/admin/lib/tenant/forms/verify-email.tsx +38 -0
- package/resources/templates/default/admin/lib/tenant/hooks/index.ts +2 -0
- package/resources/templates/default/admin/lib/tenant/hooks/useInvite.ts +41 -0
- package/resources/templates/default/admin/lib/tenant/hooks/useInviteUser.tsx +32 -3
- package/resources/templates/default/admin/lib/tenant/idp/identity-provider-connections.tsx +124 -0
- package/resources/templates/default/admin/lib/tenant/idp/index.ts +1 -0
- package/resources/templates/default/admin/lib/tenant/index.ts +10 -3
- package/resources/templates/default/admin/lib/tenant/listing/api-key-list.tsx +161 -23
- package/resources/templates/default/admin/lib/tenant/listing/auth-log-list.tsx +179 -0
- package/resources/templates/default/admin/lib/tenant/listing/global-api-key-list.tsx +149 -0
- package/resources/templates/default/admin/lib/tenant/listing/index.ts +11 -4
- package/resources/templates/default/admin/lib/tenant/listing/member-delete-dialog.tsx +4 -4
- package/resources/templates/default/admin/lib/tenant/listing/member-list.tsx +28 -19
- package/resources/templates/default/admin/lib/tenant/listing/mfa.tsx +29 -0
- package/resources/templates/default/admin/lib/tenant/listing/person-actions.tsx +179 -0
- package/resources/templates/default/admin/lib/tenant/listing/person-detail.tsx +141 -0
- package/resources/templates/default/admin/lib/tenant/listing/person-list.tsx +17 -6
- package/resources/templates/default/admin/lib/tenant/listing/persons-list.tsx +128 -0
- package/resources/templates/default/admin/lib/tenant/listing/project-secret-list.tsx +82 -0
- package/resources/templates/default/admin/lib/tenant/otp/backup-codes.tsx +81 -0
- package/resources/templates/default/admin/lib/tenant/otp/email-otp-setup.tsx +133 -0
- package/resources/templates/default/admin/lib/tenant/otp/index.ts +3 -1
- package/resources/templates/default/admin/lib/tenant/otp/otp-setup.tsx +6 -6
- package/resources/templates/default/admin/lib/tenant/security/index.ts +2 -0
- package/resources/templates/default/admin/lib/tenant/security/passwordless-toggle.tsx +63 -0
- package/resources/templates/default/admin/lib/tenant/security/session-list.tsx +143 -0
- package/resources/templates/default/admin/lib/toast/index.ts +2 -2
- package/resources/templates/default/admin/lib/toast/toast.tsx +3 -3
- package/resources/templates/default/admin/lib/ui/alert-dialog.tsx +114 -3
- package/resources/templates/default/admin/lib/ui/avatar.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/button.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/card.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/collapsible.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/dialog.tsx +2 -2
- package/resources/templates/default/admin/lib/ui/dimension.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/divider.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/dropdown.tsx +3 -3
- package/resources/templates/default/admin/lib/ui/input.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/label.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/loader.tsx +2 -2
- package/resources/templates/default/admin/lib/ui/menu.tsx +2 -2
- package/resources/templates/default/admin/lib/ui/overlay.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/popover.tsx +2 -2
- package/resources/templates/default/admin/lib/ui/progress.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/property-list.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/scroll-area.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/select.tsx +44 -2
- package/resources/templates/default/admin/lib/ui/separator.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/sheet.tsx +2 -2
- package/resources/templates/default/admin/lib/ui/sidebar.tsx +8 -8
- package/resources/templates/default/admin/lib/ui/skeleton.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/sortable.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/switch.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/table.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/textarea.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/toggle-group.tsx +2 -2
- package/resources/templates/default/admin/lib/ui/toggle.tsx +1 -1
- package/resources/templates/default/admin/lib/ui/tooltip.tsx +2 -2
- package/resources/templates/default/admin/lib/upload/dropzone.tsx +20 -3
- package/resources/templates/default/admin/lib/upload/index.ts +3 -3
- package/resources/templates/default/admin/lib/upload/repeater.tsx +5 -1
- package/resources/templates/default/admin/lib/upload/ui.tsx +2 -2
- package/resources/templates/default/admin/lib/upload/upload-progress.tsx +6 -6
- package/resources/templates/default/admin/lib/upload/view.tsx +4 -4
- package/resources/templates/default/admin/lib/utils/cn.ts +18 -0
- package/resources/templates/default/admin/lib/utils/createComponentOpenHooks.tsx +33 -0
- package/resources/templates/default/admin/lib/utils/index.ts +2 -2
- package/resources/templates/default/admin/lib/utils/uic.tsx +59 -0
- package/resources/templates/default/admin/lib/utils/use-mobile.ts +19 -0
- package/resources/templates/default/admin/package.json +1 -0
- package/resources/templates/default/docker/object-storage/README.md +13 -0
- package/resources/templates/default/docker/object-storage/identities.json +13 -0
- package/resources/templates/default/docker-compose.yaml +29 -7
- package/resources/templates/default/scripts/assemble-ui-lib.mjs +132 -0
- package/resources/templates/default/scripts/update-ui-lib.sh +101 -185
- package/src/commands/WorkspaceCreateCommand.ts +45 -17
- package/src/commands/index.ts +1 -1
- package/src/lib/FileSystem.ts +2 -2
- package/src/lib/TemplateInstaller.ts +87 -69
- package/src/lib/version.ts +1 -1
- package/src/run.ts +11 -10
- package/tests/cases/unit/create-process.test.ts +66 -0
- package/tests/cases/unit/template-installer-cleanup.test.ts +150 -0
- package/tests/cases/unit/workspace-create.test.ts +81 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
import { DisableEmailOtpTrigger, EmailOtpConfirmForm, InitEmailOtpTrigger, useEmailOtpConfirmForm, useIdentity } from '@contember/interface'
|
|
3
|
+
import { Loader } from '~/lib'
|
|
4
|
+
import { Button } from '~/lib'
|
|
5
|
+
import {
|
|
6
|
+
AlertDialog,
|
|
7
|
+
AlertDialogAction,
|
|
8
|
+
AlertDialogCancel,
|
|
9
|
+
AlertDialogContent,
|
|
10
|
+
AlertDialogDescription,
|
|
11
|
+
AlertDialogFooter,
|
|
12
|
+
AlertDialogHeader,
|
|
13
|
+
AlertDialogTitle,
|
|
14
|
+
AlertDialogTrigger,
|
|
15
|
+
} from '~/lib'
|
|
16
|
+
import { TenantFormError, TenantFormField } from '../forms/common.js'
|
|
17
|
+
import { ToastContent, useShowToast } from '~/lib'
|
|
18
|
+
import { BackupCodesDisplay } from './backup-codes.js'
|
|
19
|
+
import { dict } from '../dict.js'
|
|
20
|
+
|
|
21
|
+
export const EmailOtpSetup = () => {
|
|
22
|
+
const identity = useIdentity()
|
|
23
|
+
const showToast = useShowToast()
|
|
24
|
+
const [confirming, setConfirming] = useState(false)
|
|
25
|
+
const [backupCodes, setBackupCodes] = useState<readonly string[]>()
|
|
26
|
+
|
|
27
|
+
const person = identity?.person
|
|
28
|
+
|
|
29
|
+
if (!person) {
|
|
30
|
+
return null
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const onInitSuccess = () => {
|
|
34
|
+
setConfirming(true)
|
|
35
|
+
showToast(<ToastContent>{dict.tenant.emailOtpSetup.codeSent}</ToastContent>, { type: 'success' })
|
|
36
|
+
}
|
|
37
|
+
const onInitError = () => {
|
|
38
|
+
showToast(<ToastContent>{dict.tenant.emailOtpSetup.initFailed}</ToastContent>, { type: 'error' })
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (confirming) {
|
|
42
|
+
return (
|
|
43
|
+
<EmailOtpConfirmForm
|
|
44
|
+
onSuccess={({ result: { backupCodes } }) => {
|
|
45
|
+
setConfirming(false)
|
|
46
|
+
setBackupCodes(backupCodes)
|
|
47
|
+
showToast(<ToastContent>{dict.tenant.emailOtpSetup.enabledSuccess}</ToastContent>, { type: 'success' })
|
|
48
|
+
}}
|
|
49
|
+
>
|
|
50
|
+
<form>
|
|
51
|
+
<EmailOtpConfirmFormFields />
|
|
52
|
+
</form>
|
|
53
|
+
</EmailOtpConfirmForm>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (backupCodes) {
|
|
58
|
+
return <BackupCodesDisplay codes={backupCodes} />
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (person.emailOtpEnabled) {
|
|
62
|
+
return (
|
|
63
|
+
<>
|
|
64
|
+
<p>{dict.tenant.emailOtpSetup.emailOtpEnabled}</p>
|
|
65
|
+
<AlertDialog>
|
|
66
|
+
<AlertDialogTrigger asChild>
|
|
67
|
+
<Button variant="destructive">{dict.tenant.emailOtpSetup.disableEmailOtp}</Button>
|
|
68
|
+
</AlertDialogTrigger>
|
|
69
|
+
<AlertDialogContent>
|
|
70
|
+
<AlertDialogHeader>
|
|
71
|
+
<AlertDialogTitle>{dict.tenant.emailOtpSetup.disableEmailOtp}</AlertDialogTitle>
|
|
72
|
+
<AlertDialogDescription>{dict.tenant.emailOtpSetup.disableEmailOtpConfirm}</AlertDialogDescription>
|
|
73
|
+
</AlertDialogHeader>
|
|
74
|
+
<AlertDialogFooter>
|
|
75
|
+
<AlertDialogCancel>
|
|
76
|
+
{dict.tenant.emailOtpSetup.cancel}
|
|
77
|
+
</AlertDialogCancel>
|
|
78
|
+
<DisableEmailOtpTrigger
|
|
79
|
+
onSuccess={() => {
|
|
80
|
+
showToast(<ToastContent>{dict.tenant.emailOtpSetup.disabledSuccess}</ToastContent>, { type: 'success' })
|
|
81
|
+
}}
|
|
82
|
+
onError={() => {
|
|
83
|
+
showToast(<ToastContent>{dict.tenant.emailOtpSetup.disableFailed}</ToastContent>, { type: 'error' })
|
|
84
|
+
}}
|
|
85
|
+
>
|
|
86
|
+
<AlertDialogAction variant="destructive">
|
|
87
|
+
{dict.tenant.emailOtpSetup.disable}
|
|
88
|
+
</AlertDialogAction>
|
|
89
|
+
</DisableEmailOtpTrigger>
|
|
90
|
+
</AlertDialogFooter>
|
|
91
|
+
</AlertDialogContent>
|
|
92
|
+
</AlertDialog>
|
|
93
|
+
<InitEmailOtpTrigger onSuccess={onInitSuccess} onError={onInitError}>
|
|
94
|
+
<Button>{dict.tenant.emailOtpSetup.setupAgain}</Button>
|
|
95
|
+
</InitEmailOtpTrigger>
|
|
96
|
+
</>
|
|
97
|
+
)
|
|
98
|
+
}
|
|
99
|
+
return (
|
|
100
|
+
<>
|
|
101
|
+
<p>
|
|
102
|
+
{dict.tenant.emailOtpSetup.description}
|
|
103
|
+
</p>
|
|
104
|
+
<InitEmailOtpTrigger onSuccess={onInitSuccess} onError={onInitError}>
|
|
105
|
+
<Button>{dict.tenant.emailOtpSetup.sendCode}</Button>
|
|
106
|
+
</InitEmailOtpTrigger>
|
|
107
|
+
</>
|
|
108
|
+
)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export const EmailOtpConfirmFormFields = () => {
|
|
112
|
+
const form = useEmailOtpConfirmForm()
|
|
113
|
+
return (
|
|
114
|
+
<div className="relative flex flex-col gap-2">
|
|
115
|
+
{form.state === 'success' || form.state === 'submitting' ? <Loader position="absolute" /> : null}
|
|
116
|
+
<TenantFormError form={form} messages={dict.tenant.emailOtpSetup.emailOtpConfirmFormErrorMessages} />
|
|
117
|
+
<TenantFormField
|
|
118
|
+
form={form}
|
|
119
|
+
messages={dict.tenant.emailOtpSetup.emailOtpConfirmFormErrorMessages}
|
|
120
|
+
field="otpToken"
|
|
121
|
+
type="text"
|
|
122
|
+
required
|
|
123
|
+
maxLength={6}
|
|
124
|
+
autoComplete="one-time-code"
|
|
125
|
+
>
|
|
126
|
+
{dict.tenant.emailOtpSetup.otpToken}
|
|
127
|
+
</TenantFormField>
|
|
128
|
+
<Button type="submit" className="w-full" disabled={form.state === 'submitting'}>
|
|
129
|
+
{dict.tenant.emailOtpSetup.confirm}
|
|
130
|
+
</Button>
|
|
131
|
+
</div>
|
|
132
|
+
)
|
|
133
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useMemo, useState } from 'react'
|
|
2
2
|
import qrcode from 'qrcode-generator'
|
|
3
3
|
import { DisableOtpTrigger, OtpConfirmForm, OtpPrepareForm, useIdentity, useOtpConfirmForm, useOtpPrepareForm } from '@contember/interface'
|
|
4
|
-
import { Loader } from '
|
|
5
|
-
import { Button } from '
|
|
4
|
+
import { Loader } from '~/lib'
|
|
5
|
+
import { Button } from '~/lib'
|
|
6
6
|
import {
|
|
7
7
|
AlertDialog,
|
|
8
8
|
AlertDialogAction,
|
|
@@ -13,10 +13,10 @@ import {
|
|
|
13
13
|
AlertDialogHeader,
|
|
14
14
|
AlertDialogTitle,
|
|
15
15
|
AlertDialogTrigger,
|
|
16
|
-
} from '
|
|
17
|
-
import { TenantFormError, TenantFormField } from '../forms/common'
|
|
18
|
-
import { ToastContent, useShowToast } from '
|
|
19
|
-
import { dict } from '
|
|
16
|
+
} from '~/lib'
|
|
17
|
+
import { TenantFormError, TenantFormField } from '../forms/common.js'
|
|
18
|
+
import { ToastContent, useShowToast } from '~/lib'
|
|
19
|
+
import { dict } from '../dict.js'
|
|
20
20
|
|
|
21
21
|
export const OtpSetup = () => {
|
|
22
22
|
const identity = useIdentity()
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { DisableMyPasswordlessTrigger, EnableMyPasswordlessTrigger, useIdentity } from '@contember/interface'
|
|
2
|
+
import { Button } from '~/lib'
|
|
3
|
+
import { ToastContent, useShowToast } from '~/lib'
|
|
4
|
+
import { dict } from '../dict.js'
|
|
5
|
+
import { actionErrorMessage } from '../errors.js'
|
|
6
|
+
|
|
7
|
+
export const PasswordlessToggle = () => {
|
|
8
|
+
const identity = useIdentity()
|
|
9
|
+
const showToast = useShowToast()
|
|
10
|
+
|
|
11
|
+
const onError = ({ code }: { code: string }) => {
|
|
12
|
+
showToast(<ToastContent>{actionErrorMessage(code, dict.tenant.passwordlessToggle.toggleFailed)}</ToastContent>, { type: 'error' })
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const person = identity?.person
|
|
16
|
+
if (!person) {
|
|
17
|
+
return null
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Both flags come from the server, because the decision needs the tenant policy and reading the
|
|
21
|
+
// configuration is an admin permission. `passwordlessAvailable` is the effective state — the raw
|
|
22
|
+
// opt-in says nothing under an `always`/`never` policy — and `passwordlessSelfManaged` is whether
|
|
23
|
+
// the opt-in decides anything at all, so the toggle is not offered where it would change nothing.
|
|
24
|
+
if (!person.passwordlessSelfManaged) {
|
|
25
|
+
return (
|
|
26
|
+
<p>
|
|
27
|
+
{person.passwordlessAvailable
|
|
28
|
+
? dict.tenant.passwordlessToggle.enforcedEnabled
|
|
29
|
+
: dict.tenant.passwordlessToggle.enforcedDisabled}
|
|
30
|
+
</p>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (person.passwordlessAvailable) {
|
|
35
|
+
return (
|
|
36
|
+
<>
|
|
37
|
+
<p>{dict.tenant.passwordlessToggle.descriptionEnabled}</p>
|
|
38
|
+
<DisableMyPasswordlessTrigger
|
|
39
|
+
onSuccess={() => {
|
|
40
|
+
showToast(<ToastContent>{dict.tenant.passwordlessToggle.disabledSuccess}</ToastContent>, { type: 'success' })
|
|
41
|
+
}}
|
|
42
|
+
onError={onError}
|
|
43
|
+
>
|
|
44
|
+
<Button variant="destructive">{dict.tenant.passwordlessToggle.disable}</Button>
|
|
45
|
+
</DisableMyPasswordlessTrigger>
|
|
46
|
+
</>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<>
|
|
52
|
+
<p>{dict.tenant.passwordlessToggle.descriptionDisabled}</p>
|
|
53
|
+
<EnableMyPasswordlessTrigger
|
|
54
|
+
onSuccess={() => {
|
|
55
|
+
showToast(<ToastContent>{dict.tenant.passwordlessToggle.enabledSuccess}</ToastContent>, { type: 'success' })
|
|
56
|
+
}}
|
|
57
|
+
onError={onError}
|
|
58
|
+
>
|
|
59
|
+
<Button>{dict.tenant.passwordlessToggle.enable}</Button>
|
|
60
|
+
</EnableMyPasswordlessTrigger>
|
|
61
|
+
</>
|
|
62
|
+
)
|
|
63
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { ReactNode, useCallback } from 'react'
|
|
3
|
+
import {
|
|
4
|
+
AlertDialog,
|
|
5
|
+
AlertDialogAction,
|
|
6
|
+
AlertDialogCancel,
|
|
7
|
+
AlertDialogContent,
|
|
8
|
+
AlertDialogFooter,
|
|
9
|
+
AlertDialogHeader,
|
|
10
|
+
AlertDialogTitle,
|
|
11
|
+
AlertDialogTrigger,
|
|
12
|
+
Button,
|
|
13
|
+
Loader,
|
|
14
|
+
Table,
|
|
15
|
+
TableCell,
|
|
16
|
+
TableHead,
|
|
17
|
+
TableHeader,
|
|
18
|
+
TableRow,
|
|
19
|
+
ToastContent,
|
|
20
|
+
useShowToast,
|
|
21
|
+
} from '~/lib'
|
|
22
|
+
import { BanIcon, RefreshCwIcon } from 'lucide-react'
|
|
23
|
+
import { useMySessionsQuery, usePersonSessionsQuery, useTenantQueryLoader } from '@contember/react-client-tenant'
|
|
24
|
+
import { RevokeSessionTrigger } from '@contember/interface'
|
|
25
|
+
import { dict } from '../dict.js'
|
|
26
|
+
import { actionErrorMessage } from '../errors.js'
|
|
27
|
+
|
|
28
|
+
const formatDateTime = (value?: string | null): ReactNode => {
|
|
29
|
+
if (!value) {
|
|
30
|
+
return <span className="text-gray-400 italic">{dict.tenant.sessionList.never}</span>
|
|
31
|
+
}
|
|
32
|
+
return new Date(value).toLocaleString()
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface SessionListController {
|
|
36
|
+
refresh: () => void
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface SessionListProps {
|
|
40
|
+
personId?: string
|
|
41
|
+
controller?: { current?: SessionListController }
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const SessionList = ({ personId, controller }: SessionListProps) => {
|
|
45
|
+
const mySessionsQuery = useMySessionsQuery()
|
|
46
|
+
const personSessionsQuery = usePersonSessionsQuery()
|
|
47
|
+
const fetcher = useCallback((variables: { personId?: string }) => (
|
|
48
|
+
variables.personId ? personSessionsQuery({ personId: variables.personId }) : mySessionsQuery({})
|
|
49
|
+
), [mySessionsQuery, personSessionsQuery])
|
|
50
|
+
|
|
51
|
+
const [query, { refresh }] = useTenantQueryLoader(fetcher, { personId })
|
|
52
|
+
if (controller) {
|
|
53
|
+
controller.current = { refresh }
|
|
54
|
+
}
|
|
55
|
+
const showToast = useShowToast()
|
|
56
|
+
|
|
57
|
+
const onRevoked = () => {
|
|
58
|
+
refresh()
|
|
59
|
+
showToast(<ToastContent>{dict.tenant.sessionList.revokeSuccess}</ToastContent>, { type: 'success' })
|
|
60
|
+
}
|
|
61
|
+
const onRevokeError = ({ code }: { code: string }) => {
|
|
62
|
+
showToast(<ToastContent>{actionErrorMessage(code, dict.tenant.sessionList.revokeFailed)}</ToastContent>, { type: 'error' })
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Revoking is self-service only: `revokeSession` refuses a session that is not the caller's own, so
|
|
66
|
+
// in the admin view the button would be one that always fails. `ForceSignOutPersonAction` is the
|
|
67
|
+
// admin equivalent, and `PersonDetail` already offers it.
|
|
68
|
+
const canRevoke = personId === undefined
|
|
69
|
+
|
|
70
|
+
if (query.state === 'error') {
|
|
71
|
+
return <div className="text-destructive italic">{dict.tenant.sessionList.failedToLoadData}</div>
|
|
72
|
+
}
|
|
73
|
+
return (
|
|
74
|
+
<div className="relative">
|
|
75
|
+
{query.state !== 'success' && <Loader position="absolute" />}
|
|
76
|
+
<Table>
|
|
77
|
+
<TableHeader>
|
|
78
|
+
<TableRow>
|
|
79
|
+
<TableHead>{dict.tenant.sessionList.created}</TableHead>
|
|
80
|
+
<TableHead>{dict.tenant.sessionList.lastUsed}</TableHead>
|
|
81
|
+
<TableHead>{dict.tenant.sessionList.ip}</TableHead>
|
|
82
|
+
<TableHead>{dict.tenant.sessionList.userAgent}</TableHead>
|
|
83
|
+
<TableHead>{dict.tenant.sessionList.expires}</TableHead>
|
|
84
|
+
<TableHead className="w-24">
|
|
85
|
+
<div className="flex gap-2 items-center">
|
|
86
|
+
{canRevoke && <span>{dict.tenant.sessionList.action}</span>}
|
|
87
|
+
<Button variant="outline" onClick={refresh} className="ml-auto" size="sm">
|
|
88
|
+
<RefreshCwIcon className="w-3 h-3" />
|
|
89
|
+
</Button>
|
|
90
|
+
</div>
|
|
91
|
+
</TableHead>
|
|
92
|
+
</TableRow>
|
|
93
|
+
</TableHeader>
|
|
94
|
+
{'data' in query && query.data.length === 0 && (
|
|
95
|
+
<TableRow>
|
|
96
|
+
<TableCell colSpan={6}>{dict.tenant.sessionList.noResults}</TableCell>
|
|
97
|
+
</TableRow>
|
|
98
|
+
)}
|
|
99
|
+
{'data' in query && query.data.map(session => (
|
|
100
|
+
<TableRow key={session.id}>
|
|
101
|
+
<TableCell className="whitespace-nowrap">{formatDateTime(session.createdAt)}</TableCell>
|
|
102
|
+
<TableCell className="whitespace-nowrap">{formatDateTime(session.lastUsedAt)}</TableCell>
|
|
103
|
+
<TableCell className="whitespace-nowrap">{session.lastIp ?? session.createdIp}</TableCell>
|
|
104
|
+
<TableCell className="max-w-xs truncate" title={session.lastUserAgent ?? session.createdUserAgent ?? ''}>
|
|
105
|
+
{session.lastUserAgent ?? session.createdUserAgent}
|
|
106
|
+
</TableCell>
|
|
107
|
+
<TableCell className="whitespace-nowrap">{formatDateTime(session.expiresAt)}</TableCell>
|
|
108
|
+
<TableCell className="whitespace-nowrap">
|
|
109
|
+
{canRevoke && (session.isCurrent
|
|
110
|
+
? <span className="text-gray-500 italic">{dict.tenant.sessionList.thisDevice}</span>
|
|
111
|
+
: <RevokeSessionDialog sessionId={session.id} onSuccess={onRevoked} onError={onRevokeError} />)}
|
|
112
|
+
</TableCell>
|
|
113
|
+
</TableRow>
|
|
114
|
+
))}
|
|
115
|
+
</Table>
|
|
116
|
+
</div>
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const RevokeSessionDialog = (
|
|
121
|
+
{ sessionId, onSuccess, onError }: { sessionId: string; onSuccess: () => void; onError: (args: { code: string }) => void },
|
|
122
|
+
) => {
|
|
123
|
+
return (
|
|
124
|
+
<AlertDialog>
|
|
125
|
+
<AlertDialogTrigger asChild>
|
|
126
|
+
<Button variant="destructive">
|
|
127
|
+
<BanIcon className="w-3 h-3" />
|
|
128
|
+
</Button>
|
|
129
|
+
</AlertDialogTrigger>
|
|
130
|
+
<AlertDialogContent>
|
|
131
|
+
<AlertDialogHeader>
|
|
132
|
+
<AlertDialogTitle>{dict.tenant.sessionList.revokeConfirmation}</AlertDialogTitle>
|
|
133
|
+
</AlertDialogHeader>
|
|
134
|
+
<AlertDialogFooter>
|
|
135
|
+
<AlertDialogCancel>{dict.tenant.sessionList.cancel}</AlertDialogCancel>
|
|
136
|
+
<RevokeSessionTrigger sessionId={sessionId} onSuccess={onSuccess} onError={onError}>
|
|
137
|
+
<AlertDialogAction variant="destructive">{dict.tenant.sessionList.revoke}</AlertDialogAction>
|
|
138
|
+
</RevokeSessionTrigger>
|
|
139
|
+
</AlertDialogFooter>
|
|
140
|
+
</AlertDialogContent>
|
|
141
|
+
</AlertDialog>
|
|
142
|
+
)
|
|
143
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './toaster'
|
|
2
|
-
export * from './toast'
|
|
1
|
+
export * from './toaster.js'
|
|
2
|
+
export * from './toast.js'
|
|
@@ -2,9 +2,9 @@ import * as React from 'react'
|
|
|
2
2
|
import { ReactNode } from 'react'
|
|
3
3
|
import * as ToastPrimitives from '@radix-ui/react-toast'
|
|
4
4
|
import { X } from 'lucide-react'
|
|
5
|
-
import { uic } from '../utils'
|
|
6
|
-
import { ToasterProvider, useToasts } from './toaster'
|
|
7
|
-
import { dict } from '../dict'
|
|
5
|
+
import { uic } from '../utils/index.js'
|
|
6
|
+
import { ToasterProvider, useToasts } from './toaster.js'
|
|
7
|
+
import { dict } from '../dict.js'
|
|
8
8
|
|
|
9
9
|
export const ToastContent = ({ title, children, action, details }: {
|
|
10
10
|
title?: ReactNode
|
|
@@ -1,24 +1,93 @@
|
|
|
1
1
|
import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog'
|
|
2
2
|
import * as React from 'react'
|
|
3
|
-
import { uic } from '../utils'
|
|
4
|
-
import { createComponentOpenHooks } from '../utils/createComponentOpenHooks'
|
|
5
|
-
import { buttonConfig } from './button'
|
|
3
|
+
import { uic } from '../utils/index.js'
|
|
4
|
+
import { createComponentOpenHooks } from '../utils/createComponentOpenHooks.js'
|
|
5
|
+
import { buttonConfig } from './button.js'
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* `AlertDialog` component - an interruptive modal dialog that requires a user interaction
|
|
9
|
+
* to be dismissed. It is used to confirm user actions or to inform the user
|
|
10
|
+
* about important information that requires attention.
|
|
11
|
+
*
|
|
12
|
+
* ## Example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* <AlertDialog>
|
|
15
|
+
* <AlertDialogTrigger>Open Dialog</AlertDialogTrigger>
|
|
16
|
+
* <AlertDialogContent>
|
|
17
|
+
* <AlertDialogHeader>
|
|
18
|
+
* <AlertDialogTitle>Are you sure?</AlertDialogTitle>
|
|
19
|
+
* <AlertDialogDescription>
|
|
20
|
+
* This action cannot be undone.
|
|
21
|
+
* </AlertDialogDescription>
|
|
22
|
+
* </AlertDialogHeader>
|
|
23
|
+
* <AlertDialogFooter>
|
|
24
|
+
* <AlertDialogCancel>Cancel</AlertDialogCancel>
|
|
25
|
+
* <AlertDialogAction>Continue</AlertDialogAction>
|
|
26
|
+
* </AlertDialogFooter>
|
|
27
|
+
* </AlertDialogContent>
|
|
28
|
+
* </AlertDialog>
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* ## Sub-components
|
|
32
|
+
* - {@link AlertDialogPortal}
|
|
33
|
+
* - {@link AlertDialogContent}
|
|
34
|
+
* - {@link AlertDialogHeader}
|
|
35
|
+
* - {@link AlertDialogFooter}
|
|
36
|
+
* - {@link AlertDialogTitle}
|
|
37
|
+
* - {@link AlertDialogDescription}
|
|
38
|
+
* - {@link AlertDialogAction}
|
|
39
|
+
* - {@link AlertDialogCancel}
|
|
40
|
+
*
|
|
41
|
+
* ## Hooks
|
|
42
|
+
* - {@link useAlertDialogOpenState}
|
|
43
|
+
*/
|
|
7
44
|
export const {
|
|
8
45
|
Component: AlertDialog,
|
|
9
46
|
useOpen: useAlertDialogOpenState,
|
|
10
47
|
} = createComponentOpenHooks(AlertDialogPrimitive.Root)
|
|
11
48
|
|
|
49
|
+
/**
|
|
50
|
+
* `AlertDialogTrigger` is the trigger button to open the dialog.
|
|
51
|
+
* Must be used within `AlertDialog`.
|
|
52
|
+
*
|
|
53
|
+
* See more {@link AlertDialog}
|
|
54
|
+
*
|
|
55
|
+
* @group AlertDialog
|
|
56
|
+
*/
|
|
12
57
|
export const AlertDialogTrigger = AlertDialogPrimitive.Trigger
|
|
13
58
|
|
|
59
|
+
/**
|
|
60
|
+
* `AlertDialogPortal` is the portal to render the dialog.
|
|
61
|
+
* Must be used within `AlertDialog`.
|
|
62
|
+
*
|
|
63
|
+
* See more {@link AlertDialog}
|
|
64
|
+
*
|
|
65
|
+
* @group AlertDialog
|
|
66
|
+
*/
|
|
14
67
|
export const AlertDialogPortal = AlertDialogPrimitive.Portal
|
|
15
68
|
|
|
69
|
+
/**
|
|
70
|
+
* `AlertDialogOverlay` is the overlay to render the dialog.
|
|
71
|
+
* Must be used within `AlertDialog`.
|
|
72
|
+
*
|
|
73
|
+
* See more {@link AlertDialog}
|
|
74
|
+
*
|
|
75
|
+
* @group AlertDialog
|
|
76
|
+
*/
|
|
16
77
|
export const AlertDialogOverlay = uic(AlertDialogPrimitive.Overlay, {
|
|
17
78
|
baseClass:
|
|
18
79
|
'fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
|
|
19
80
|
displayName: 'AlertDialogOverlay',
|
|
20
81
|
})
|
|
21
82
|
|
|
83
|
+
/**
|
|
84
|
+
* `AlertDialogContent` is the content of the alert dialog.
|
|
85
|
+
* Must be used within `AlertDialog`.
|
|
86
|
+
*
|
|
87
|
+
* For documentation see {@link AlertDialog}
|
|
88
|
+
*
|
|
89
|
+
* @group AlertDialog
|
|
90
|
+
*/
|
|
22
91
|
export const AlertDialogContent = uic(AlertDialogPrimitive.Content, {
|
|
23
92
|
baseClass:
|
|
24
93
|
'fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg',
|
|
@@ -33,27 +102,69 @@ export const AlertDialogContent = uic(AlertDialogPrimitive.Content, {
|
|
|
33
102
|
displayName: 'AlertDialogContent',
|
|
34
103
|
})
|
|
35
104
|
|
|
105
|
+
/**
|
|
106
|
+
* `AlertDialogHeader` is the header of the alert dialog. Must be used within `AlertDialog`. Usually contains the title and description of the alert dialog.
|
|
107
|
+
*
|
|
108
|
+
* See more {@link AlertDialog}
|
|
109
|
+
*
|
|
110
|
+
* @group AlertDialog
|
|
111
|
+
*/
|
|
36
112
|
export const AlertDialogHeader = uic('div', {
|
|
37
113
|
baseClass: 'flex flex-col space-y-2 text-center sm:text-left',
|
|
38
114
|
displayName: 'AlertDialogHeader',
|
|
39
115
|
})
|
|
40
116
|
|
|
117
|
+
/**
|
|
118
|
+
* `AlertDialogFooter` is the footer of the alert dialog. Must be used within `AlertDialog`. Usually contains the buttons of the alert dialog.
|
|
119
|
+
*
|
|
120
|
+
* See more {@link AlertDialog}
|
|
121
|
+
*
|
|
122
|
+
* @group AlertDialog
|
|
123
|
+
*/
|
|
41
124
|
export const AlertDialogFooter = uic('div', {
|
|
42
125
|
baseClass: 'flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2',
|
|
43
126
|
displayName: 'AlertDialogFooter',
|
|
44
127
|
})
|
|
45
128
|
|
|
129
|
+
/**
|
|
130
|
+
* `AlertDialogTitle` is the title of the alert dialog. Must be used within `AlertDialogHeader`. Usually contains the title of the alert dialog.
|
|
131
|
+
*
|
|
132
|
+
* See more {@link AlertDialog}
|
|
133
|
+
*
|
|
134
|
+
* @group AlertDialog
|
|
135
|
+
*/
|
|
46
136
|
export const AlertDialogTitle = uic(AlertDialogPrimitive.Title, {
|
|
47
137
|
baseClass: 'text-lg font-semibold',
|
|
48
138
|
displayName: 'AlertDialogTitle',
|
|
49
139
|
})
|
|
50
140
|
|
|
141
|
+
/**
|
|
142
|
+
* `AlertDialogDescription` is the description of the alert dialog. Must be used within `AlertDialogHeader`. Usually contains the description of the alert dialog.
|
|
143
|
+
*
|
|
144
|
+
* See more {@link AlertDialog}
|
|
145
|
+
*
|
|
146
|
+
* @group AlertDialog
|
|
147
|
+
*/
|
|
51
148
|
export const AlertDialogDescription = uic(AlertDialogPrimitive.Description, {
|
|
52
149
|
baseClass: 'text-sm text-muted-foreground',
|
|
53
150
|
displayName: 'AlertDialogDescription',
|
|
54
151
|
})
|
|
55
152
|
|
|
153
|
+
/**
|
|
154
|
+
* `AlertDialogAction` is the action button of the alert dialog. Must be used within `AlertDialogFooter`. Usually contains the action button of the alert dialog.
|
|
155
|
+
*
|
|
156
|
+
* See more {@link AlertDialog}
|
|
157
|
+
*
|
|
158
|
+
* @group AlertDialog
|
|
159
|
+
*/
|
|
56
160
|
export const AlertDialogAction = uic(AlertDialogPrimitive.Action, buttonConfig)
|
|
161
|
+
/**
|
|
162
|
+
* `AlertDialogCancel` is the cancel button of the alert dialog. Must be used within `AlertDialogFooter`. Usually contains the cancel button of the alert dialog.
|
|
163
|
+
*
|
|
164
|
+
* See more {@link AlertDialog}
|
|
165
|
+
*
|
|
166
|
+
* @group AlertDialog
|
|
167
|
+
*/
|
|
57
168
|
export const AlertDialogCancel = uic(AlertDialogPrimitive.Cancel, {
|
|
58
169
|
...buttonConfig,
|
|
59
170
|
defaultVariants: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as AvatarPrimitive from '@radix-ui/react-avatar'
|
|
2
2
|
import { ComponentPropsWithoutRef, ElementRef, forwardRef } from 'react'
|
|
3
|
-
import { cn, uic } from '../utils'
|
|
3
|
+
import { cn, uic } from '../utils/index.js'
|
|
4
4
|
|
|
5
5
|
export const Avatar = uic(AvatarPrimitive.Root, {
|
|
6
6
|
baseClass: 'relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as CollapsiblePrimitive from '@radix-ui/react-collapsible'
|
|
2
|
-
import { createComponentOpenHooks } from '../utils/createComponentOpenHooks'
|
|
2
|
+
import { createComponentOpenHooks } from '../utils/createComponentOpenHooks.js'
|
|
3
3
|
|
|
4
4
|
export const {
|
|
5
5
|
Component: Collapsible,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
2
|
import * as DialogPrimitive from '@radix-ui/react-dialog'
|
|
3
|
-
import { uic } from '../utils/uic'
|
|
3
|
+
import { uic } from '../utils/uic.js'
|
|
4
4
|
import { XIcon } from 'lucide-react'
|
|
5
|
-
import { createComponentOpenHooks } from '../utils/createComponentOpenHooks'
|
|
5
|
+
import { createComponentOpenHooks } from '../utils/createComponentOpenHooks.js'
|
|
6
6
|
|
|
7
7
|
export const { Component: Dialog, useOpen: useDialogOpenState } = createComponentOpenHooks(DialogPrimitive.Root)
|
|
8
8
|
|
|
@@ -2,9 +2,9 @@ import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu'
|
|
|
2
2
|
import { Check, ChevronRight, Circle, MoreHorizontalIcon } from 'lucide-react'
|
|
3
3
|
import * as React from 'react'
|
|
4
4
|
import { ReactNode } from 'react'
|
|
5
|
-
import { uic } from '../utils'
|
|
6
|
-
import { createComponentOpenHooks } from '../utils/createComponentOpenHooks'
|
|
7
|
-
import { buttonConfig } from './button'
|
|
5
|
+
import { uic } from '../utils/index.js'
|
|
6
|
+
import { createComponentOpenHooks } from '../utils/createComponentOpenHooks.js'
|
|
7
|
+
import { buttonConfig } from './button.js'
|
|
8
8
|
|
|
9
9
|
export const {
|
|
10
10
|
Component: DropdownMenu,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as LabelPrimitive from '@radix-ui/react-label'
|
|
2
|
-
import { uic } from '../utils'
|
|
2
|
+
import { uic } from '../utils/index.js'
|
|
3
3
|
|
|
4
4
|
export const Label = uic(LabelPrimitive.Root, {
|
|
5
5
|
baseClass: 'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 data-[invalid]:text-destructive',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
|
-
import { uic } from '../utils'
|
|
2
|
+
import { uic } from '../utils/index.js'
|
|
3
3
|
import { Loader2Icon } from 'lucide-react'
|
|
4
|
-
import { Overlay, OverlayProps } from './overlay'
|
|
4
|
+
import { Overlay, OverlayProps } from './overlay.js'
|
|
5
5
|
|
|
6
6
|
export interface LoaderProps extends Omit<OverlayProps, 'children'> {
|
|
7
7
|
size?: 'sm' | 'md' | 'lg'
|