@contember/create 2.0.0-alpha.9 → 2.0.0-beta.2

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.
Files changed (146) hide show
  1. package/dist/development/run.cjs +0 -2
  2. package/dist/development/run.cjs.map +1 -1
  3. package/dist/development/run.js +0 -2
  4. package/dist/development/run.js.map +1 -1
  5. package/dist/development/src/commands/WorkspaceCreateCommand.cjs.map +1 -1
  6. package/dist/development/src/commands/WorkspaceCreateCommand.js.map +1 -1
  7. package/dist/development/src/lib/FileSystem.cjs.map +1 -1
  8. package/dist/development/src/lib/FileSystem.js.map +1 -1
  9. package/dist/development/src/lib/TemplateInstaller.cjs +1 -8
  10. package/dist/development/src/lib/TemplateInstaller.cjs.map +1 -1
  11. package/dist/development/src/lib/TemplateInstaller.js +2 -9
  12. package/dist/development/src/lib/TemplateInstaller.js.map +1 -1
  13. package/dist/development/src/lib/version.cjs.map +1 -1
  14. package/dist/development/src/paths.cjs +3 -1
  15. package/dist/development/src/paths.cjs.map +1 -1
  16. package/dist/development/src/paths.js +4 -2
  17. package/dist/development/src/paths.js.map +1 -1
  18. package/dist/production/run.cjs +0 -2
  19. package/dist/production/run.cjs.map +1 -1
  20. package/dist/production/run.js +0 -2
  21. package/dist/production/run.js.map +1 -1
  22. package/dist/production/src/commands/WorkspaceCreateCommand.cjs.map +1 -1
  23. package/dist/production/src/commands/WorkspaceCreateCommand.js.map +1 -1
  24. package/dist/production/src/lib/FileSystem.cjs.map +1 -1
  25. package/dist/production/src/lib/FileSystem.js.map +1 -1
  26. package/dist/production/src/lib/TemplateInstaller.cjs +1 -8
  27. package/dist/production/src/lib/TemplateInstaller.cjs.map +1 -1
  28. package/dist/production/src/lib/TemplateInstaller.js +2 -9
  29. package/dist/production/src/lib/TemplateInstaller.js.map +1 -1
  30. package/dist/production/src/lib/version.cjs.map +1 -1
  31. package/dist/production/src/paths.cjs +3 -1
  32. package/dist/production/src/paths.cjs.map +1 -1
  33. package/dist/production/src/paths.js +4 -2
  34. package/dist/production/src/paths.js.map +1 -1
  35. package/dist/types/lib/TemplateInstaller.d.ts +1 -3
  36. package/dist/types/lib/TemplateInstaller.d.ts.map +1 -1
  37. package/dist/types/paths.d.ts.map +1 -1
  38. package/dist/types/tsconfig.tsbuildinfo +1 -1
  39. package/package.json +7 -31
  40. package/resources/templates/template-workspace/.github/scripts/setup-actions-variables.sh +36 -0
  41. package/resources/templates/template-workspace/.github/workflows/deploy.yaml +23 -0
  42. package/resources/templates/template-workspace/admin/lib/binding/binding.tsx +12 -2
  43. package/resources/templates/template-workspace/admin/lib/binding/delete.tsx +34 -23
  44. package/resources/templates/template-workspace/admin/lib/binding/hooks.tsx +5 -6
  45. package/resources/templates/template-workspace/admin/lib/binding/identity.tsx +34 -3
  46. package/resources/templates/template-workspace/admin/lib/binding/navigation-guard-dialog.tsx +39 -0
  47. package/resources/templates/template-workspace/admin/lib/binding/persist.tsx +10 -60
  48. package/resources/templates/template-workspace/admin/lib/block-repeater/block-repeater.tsx +109 -39
  49. package/resources/templates/template-workspace/admin/lib/buttons/link-back-button.tsx +1 -1
  50. package/resources/templates/template-workspace/admin/lib/datagrid/cells.tsx +90 -10
  51. package/resources/templates/template-workspace/admin/lib/datagrid/column-header.tsx +12 -4
  52. package/resources/templates/template-workspace/admin/lib/datagrid/column-leaf.tsx +21 -0
  53. package/resources/templates/template-workspace/admin/lib/datagrid/columns.tsx +367 -36
  54. package/resources/templates/template-workspace/admin/lib/datagrid/elements.tsx +6 -0
  55. package/resources/templates/template-workspace/admin/lib/datagrid/export.tsx +9 -0
  56. package/resources/templates/template-workspace/admin/lib/datagrid/filters/boolean.tsx +22 -5
  57. package/resources/templates/template-workspace/admin/lib/datagrid/filters/common.tsx +3 -0
  58. package/resources/templates/template-workspace/admin/lib/datagrid/filters/date.tsx +25 -2
  59. package/resources/templates/template-workspace/admin/lib/datagrid/filters/defined.tsx +103 -0
  60. package/resources/templates/template-workspace/admin/lib/datagrid/filters/enum.tsx +83 -27
  61. package/resources/templates/template-workspace/admin/lib/datagrid/filters/index.ts +1 -1
  62. package/resources/templates/template-workspace/admin/lib/datagrid/filters/mobile.tsx +0 -1
  63. package/resources/templates/template-workspace/admin/lib/datagrid/filters/number.tsx +21 -5
  64. package/resources/templates/template-workspace/admin/lib/datagrid/filters/relation.tsx +170 -43
  65. package/resources/templates/template-workspace/admin/lib/datagrid/filters/text.tsx +48 -5
  66. package/resources/templates/template-workspace/admin/lib/datagrid/grid.tsx +97 -25
  67. package/resources/templates/template-workspace/admin/lib/datagrid/index.ts +30 -4
  68. package/resources/templates/template-workspace/admin/lib/datagrid/labels.tsx +31 -0
  69. package/resources/templates/template-workspace/admin/lib/datagrid/layout-switcher.tsx +3 -0
  70. package/resources/templates/template-workspace/admin/lib/datagrid/loader.tsx +44 -2
  71. package/resources/templates/template-workspace/admin/lib/datagrid/pagination.tsx +8 -0
  72. package/resources/templates/template-workspace/admin/lib/datagrid/table.tsx +15 -1
  73. package/resources/templates/template-workspace/admin/lib/datagrid/tiles.tsx +13 -0
  74. package/resources/templates/template-workspace/admin/lib/datagrid/toolbar.tsx +27 -2
  75. package/resources/templates/template-workspace/admin/lib/dict.ts +54 -5
  76. package/resources/templates/template-workspace/admin/lib/dimensions/dimensions.tsx +1 -1
  77. package/resources/templates/template-workspace/admin/lib/editor/common/editor-canvas.tsx +2 -2
  78. package/resources/templates/template-workspace/admin/lib/editor/index.ts +1 -0
  79. package/resources/templates/template-workspace/admin/lib/editor/rich-text-view.tsx +17 -0
  80. package/resources/templates/template-workspace/admin/lib/field/formatted-field.tsx +10 -0
  81. package/resources/templates/template-workspace/admin/lib/field/index.ts +1 -0
  82. package/resources/templates/template-workspace/admin/lib/form/container.tsx +43 -45
  83. package/resources/templates/template-workspace/admin/lib/form/index.ts +1 -0
  84. package/resources/templates/template-workspace/admin/lib/form/inputs.tsx +56 -23
  85. package/resources/templates/template-workspace/admin/lib/form/select.tsx +61 -30
  86. package/resources/templates/template-workspace/admin/lib/form/ui.tsx +11 -2
  87. package/resources/templates/template-workspace/admin/lib/form/upload-repeaters.tsx +188 -0
  88. package/resources/templates/template-workspace/admin/lib/form/upload.tsx +57 -242
  89. package/resources/templates/template-workspace/admin/lib/formatting/formatting.ts +23 -0
  90. package/resources/templates/template-workspace/admin/lib/labels/enum-labels.ts +9 -0
  91. package/resources/templates/template-workspace/admin/lib/labels/field-labels.ts +7 -0
  92. package/resources/templates/template-workspace/admin/lib/labels/index.ts +2 -0
  93. package/resources/templates/template-workspace/admin/lib/layout/layout.tsx +3 -3
  94. package/resources/templates/template-workspace/admin/lib/repeater/repeater.tsx +97 -64
  95. package/resources/templates/template-workspace/admin/lib/select/filter.tsx +3 -2
  96. package/resources/templates/template-workspace/admin/lib/select/index.ts +0 -1
  97. package/resources/templates/template-workspace/admin/lib/select/list.tsx +78 -26
  98. package/resources/templates/template-workspace/admin/lib/select/multi-select.tsx +12 -19
  99. package/resources/templates/template-workspace/admin/lib/select/select.tsx +40 -23
  100. package/resources/templates/template-workspace/admin/lib/select/sortable-select.tsx +23 -18
  101. package/resources/templates/template-workspace/admin/lib/select/ui.tsx +3 -0
  102. package/resources/templates/template-workspace/admin/lib/tenant/forms/invite.tsx +5 -3
  103. package/resources/templates/template-workspace/admin/lib/tenant/forms/memberships-control.tsx +28 -16
  104. package/resources/templates/template-workspace/admin/lib/tenant/forms/password-reset.tsx +9 -6
  105. package/resources/templates/template-workspace/admin/lib/tenant/forms/passwordless-signin-init.tsx +31 -0
  106. package/resources/templates/template-workspace/admin/lib/tenant/forms/passwordless-signin.tsx +59 -0
  107. package/resources/templates/template-workspace/admin/lib/tenant/forms/update-project-member.tsx +5 -3
  108. package/resources/templates/template-workspace/admin/lib/tenant/hooks/useInvite.ts +1 -1
  109. package/resources/templates/template-workspace/admin/lib/tenant/listing/member-list.tsx +6 -5
  110. package/resources/templates/template-workspace/admin/lib/tenant/listing/person-list.tsx +2 -1
  111. package/resources/templates/template-workspace/admin/lib/ui/alert-dialog.tsx +2 -1
  112. package/resources/templates/template-workspace/admin/lib/ui/collapsible.tsx +9 -0
  113. package/resources/templates/template-workspace/admin/lib/ui/dialog.tsx +2 -1
  114. package/resources/templates/template-workspace/admin/lib/ui/dropdown.tsx +2 -1
  115. package/resources/templates/template-workspace/admin/lib/ui/input.tsx +14 -10
  116. package/resources/templates/template-workspace/admin/lib/ui/menu.tsx +2 -3
  117. package/resources/templates/template-workspace/admin/lib/ui/popover.tsx +2 -1
  118. package/resources/templates/template-workspace/admin/lib/ui/property-list.tsx +33 -0
  119. package/resources/templates/template-workspace/admin/lib/ui/select.tsx +80 -0
  120. package/resources/templates/template-workspace/admin/lib/ui/sheet.tsx +3 -2
  121. package/resources/templates/template-workspace/admin/lib/ui/textarea.tsx +9 -1
  122. package/resources/templates/template-workspace/admin/lib/upload/view.tsx +160 -165
  123. package/resources/templates/template-workspace/admin/lib/utils/createComponentOpenHooks.tsx +38 -0
  124. package/resources/templates/template-workspace/admin/lib/utils/uic.tsx +3 -3
  125. package/resources/templates/template-workspace/admin/package.json +21 -20
  126. package/resources/templates/template-workspace/package.json +3 -3
  127. package/src/lib/TemplateInstaller.ts +2 -9
  128. package/src/paths.ts +4 -3
  129. package/src/run.ts +0 -2
  130. package/tsconfig.settings.json +0 -4
  131. package/dist/development/src/lib/PackageDownloader.cjs +0 -33
  132. package/dist/development/src/lib/PackageDownloader.cjs.map +0 -1
  133. package/dist/development/src/lib/PackageDownloader.js +0 -33
  134. package/dist/development/src/lib/PackageDownloader.js.map +0 -1
  135. package/dist/production/src/lib/PackageDownloader.cjs +0 -33
  136. package/dist/production/src/lib/PackageDownloader.cjs.map +0 -1
  137. package/dist/production/src/lib/PackageDownloader.js +0 -33
  138. package/dist/production/src/lib/PackageDownloader.js.map +0 -1
  139. package/dist/types/lib/PackageDownloader.d.ts +0 -7
  140. package/dist/types/lib/PackageDownloader.d.ts.map +0 -1
  141. package/resources/templates/template-workspace/admin/.env.production +0 -3
  142. package/resources/templates/template-workspace/admin/lib/select/pagination.tsx +0 -48
  143. package/src/lib/PackageDownloader.ts +0 -33
  144. package/types/download-tarball/index.d.ts +0 -7
  145. package/types/get-package-json-from-registry/index.d.ts +0 -3
  146. package/types/registry-info/index.d.ts +0 -7
@@ -1,10 +1,52 @@
1
1
  import * as React from 'react'
2
+ import { ReactNode } from 'react'
2
3
  import { Loader } from '../ui/loader'
4
+ import { DataViewLoaderState } from '@contember/react-dataview'
3
5
 
4
- export const DataGridOverlayLoader = () => (
6
+ /**
7
+ * Props for the {@link DataGridLoader} component.
8
+ */
9
+ export interface DataGridLoaderProps {
10
+ children: ReactNode
11
+ }
12
+
13
+ /**
14
+ * A component that provides a loading state for a data grid.
15
+ * It displays different loaders based on the current loading state.
16
+ *
17
+ * ## Example
18
+ * ```tsx
19
+ * <DataGridLoader>
20
+ * <DataGridTable>
21
+ * <DataGridTextColumn header="Title" field="title" />
22
+ * </DataGridTable>
23
+ * </DataGridLoader>
24
+ * ```
25
+ */
26
+ export const DataGridLoader = ({ children }: { children: ReactNode }) => (
27
+ <>
28
+ <DataViewLoaderState refreshing loaded>
29
+ <div className="relative">
30
+ <DataViewLoaderState refreshing>
31
+ <DataGridOverlayLoader />
32
+ </DataViewLoaderState>
33
+ {children}
34
+ </div>
35
+ </DataViewLoaderState>
36
+ <DataViewLoaderState initial>
37
+ <DataGridInitialLoader />
38
+ </DataViewLoaderState>
39
+ <DataViewLoaderState failed>
40
+ <div>Failed to load data</div>
41
+ </DataViewLoaderState>
42
+ </>
43
+ )
44
+
45
+
46
+ const DataGridOverlayLoader = () => (
5
47
  <Loader position={'absolute'} />
6
48
  )
7
49
 
8
- export const DataGridInitialLoader = () => (
50
+ const DataGridInitialLoader = () => (
9
51
  <Loader position={'static'} />
10
52
  )
@@ -7,6 +7,14 @@ import { DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '../u
7
7
  import { dictFormat } from '../dict'
8
8
  import { dict } from '../dict'
9
9
 
10
+ /**
11
+ * Pagination controls UI for DataView.
12
+ *
13
+ * ## Example
14
+ * ```tsx
15
+ * <DataGridPagination />
16
+ * ```
17
+ */
10
18
  export const DataGridPagination = () => (
11
19
  <div className="flex gap-6 lg:gap-8 justify-between mt-4">
12
20
  <div className="">
@@ -6,12 +6,26 @@ import { DataViewEachRow, DataViewEmpty, DataViewLayout, DataViewNonEmpty } from
6
6
  import { SheetIcon } from 'lucide-react'
7
7
  import { dict } from '../dict'
8
8
  import { ChildrenAnalyzer, Leaf } from '@contember/react-multipass-rendering'
9
- import { DataGridColumnLeaf, DataGridColumnLeafProps } from './columns'
10
9
 
10
+ import { DataGridColumnLeaf, DataGridColumnLeafProps } from './column-leaf'
11
+
12
+ /**
13
+ * Props for the {@link DataGridTable} component.
14
+ */
11
15
  export interface DataViewTableProps {
12
16
  children: ReactNode
13
17
  }
14
18
 
19
+ /**
20
+ * Table layout for DataView.
21
+ *
22
+ * ## Example
23
+ * ```tsx
24
+ * <DataGridTable>
25
+ * <DataGridTextColumn header="Title" field="title" />
26
+ * </DataGridTable>
27
+ * ```
28
+ */
15
29
  export const DataGridTable = Component<DataViewTableProps>(({ children }) => {
16
30
  return (
17
31
  <DataViewLayout name="table" label={<>
@@ -5,11 +5,24 @@ import { dict } from '../dict'
5
5
  import { LayoutGridIcon } from 'lucide-react'
6
6
  import { cn } from '../utils'
7
7
 
8
+ /**
9
+ * Props for the {@link DataGridTiles} component.
10
+ */
8
11
  export interface DataGridTilesProps {
9
12
  children: React.ReactNode
10
13
  className?: string
11
14
  }
12
15
 
16
+ /**
17
+ * Simple grid layout for DataView.
18
+ *
19
+ * ## Example
20
+ * ```tsx
21
+ * <DataGridTiles>
22
+ * <MyCustomTile />
23
+ * </DataGridTiles>
24
+ * ```
25
+ */
13
26
  export const DataGridTiles = Component< DataGridTilesProps>(({ children, className }) => {
14
27
  return (
15
28
  <DataViewLayout name={'grid'} label={<>
@@ -4,7 +4,7 @@ import { ReactNode } from 'react'
4
4
  import { DataGridShowFiltersContext } from './filters/mobile'
5
5
  import { DataGridToolbarUI } from './ui'
6
6
  import { Button } from '../ui/button'
7
- import { FilterIcon, SettingsIcon } from 'lucide-react'
7
+ import { FilterIcon, RefreshCcwIcon, SettingsIcon } from 'lucide-react'
8
8
  import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover'
9
9
  import { DataGridLayoutSwitcher } from './layout-switcher'
10
10
  import { DataGridPerPageSelector } from './pagination'
@@ -13,11 +13,31 @@ import { dataAttribute } from '@contember/utilities'
13
13
  import { dict } from '../dict'
14
14
  import { DataGridAutoExport } from './export'
15
15
  import { DataGridToolbarVisibleElements } from './elements'
16
+ import { DataViewReloadTrigger } from '@contember/react-dataview'
16
17
 
18
+ /**
19
+ * Props for the {@link DataGridToolbar} component.
20
+ */
17
21
  export interface DataGridToolbarProps {
18
22
  children?: ReactNode
19
23
  }
20
24
 
25
+ /**
26
+ * Toolbar for DataGrid with default UI.
27
+ * It contains
28
+ * - filters (with default DataGridQueryFilter, which can be replaced by custom filters in children)
29
+ * - settings (layout switcher, visible elements, per page selector)
30
+ * - export button
31
+ * - reload button
32
+ *
33
+ * ## Example
34
+ * ```tsx
35
+ * <DataGridToolbar>
36
+ * <DataGridQueryFilter />
37
+ * <DataGridTextFilter field={'name'} label="Name" />
38
+ * </DataGridToolbar>
39
+ * ```
40
+ */
21
41
  export const DataGridToolbar = Component<DataGridToolbarProps>(({ children }) => {
22
42
  const [showFilters, setShowFilters] = React.useState(false)
23
43
  return (
@@ -35,7 +55,7 @@ export const DataGridToolbar = Component<DataGridToolbarProps>(({ children }) =>
35
55
  </Button>
36
56
 
37
57
  <Popover>
38
- <PopoverTrigger>
58
+ <PopoverTrigger asChild>
39
59
  <Button variant={'outline'} size={'sm'} className={'gap-2'}>
40
60
  <SettingsIcon className={'w-4 h-4'} />
41
61
  </Button>
@@ -51,6 +71,11 @@ export const DataGridToolbar = Component<DataGridToolbarProps>(({ children }) =>
51
71
  </Popover>
52
72
 
53
73
  <DataGridAutoExport />
74
+ <DataViewReloadTrigger>
75
+ <Button variant={'outline'} size={'sm'} className={'group gap-2'}>
76
+ <RefreshCcwIcon className={'w-4 h-4 group-data-[state=refreshing]:animate-spin '} />
77
+ </Button>
78
+ </DataViewReloadTrigger>
54
79
  </div>
55
80
 
56
81
  <div className="flex flex-1 flex-wrap gap-2">
@@ -2,7 +2,8 @@ import { TextFilterArtifactsMatchMode } from '@contember/react-dataview'
2
2
  import { InviteErrorCodes } from './tenant/hooks/useInvite'
3
3
  import { UploaderErrorType } from '@contember/react-uploader'
4
4
  import { ChangeMyPasswordFormErrorCode, CreateApiKeyFormErrorCode } from '@contember/interface'
5
- import { InviteFormErrorCode, LoginFormErrorCode, OtpPrepareFormErrorCode, OtpConfirmFormErrorCode, PasswordResetFormErrorCode, PasswordResetRequestFormErrorCode, UpdateProjectMemberFormErrorCode } from '@contember/react-identity'
5
+ import { InviteFormErrorCode, LoginFormErrorCode, OtpPrepareFormErrorCode, OtpConfirmFormErrorCode, PasswordResetFormErrorCode, PasswordResetRequestFormErrorCode, UpdateProjectMemberFormErrorCode, PasswordlessSignInInitFormErrorCode, PasswordlessSignInFormErrorCode } from '@contember/react-identity'
6
+ import { ActivatePasswordlessOtpErrorCode } from '@contember/graphql-client-tenant'
6
7
 
7
8
  export const dict = {
8
9
  deleteEntityDialog: {
@@ -25,6 +26,9 @@ export const dict = {
25
26
  toast: {
26
27
  showDetails: 'Show details',
27
28
  },
29
+ input: {
30
+ noValue: 'No value',
31
+ },
28
32
  datagrid: {
29
33
  na: 'N/A',
30
34
  dateStart: 'From',
@@ -69,8 +73,6 @@ export const dict = {
69
73
  confirmNew: 'Confirm',
70
74
  cancelNew: 'Cancel',
71
75
  search: 'Search',
72
- paginationPreviousPage: 'Previous page',
73
- paginationNextPage: 'Next page',
74
76
  placeholder: 'Select',
75
77
  },
76
78
  backButton: {
@@ -78,6 +80,7 @@ export const dict = {
78
80
  },
79
81
 
80
82
  errors: {
83
+ required: 'This field is required',
81
84
  unique: 'This value is already taken',
82
85
  unknown: 'An unknown error has occurred',
83
86
  },
@@ -162,6 +165,7 @@ export const dict = {
162
165
  name: 'Name',
163
166
  roles: 'Roles',
164
167
  submit: 'Invite',
168
+ addRole: 'Add new role',
165
169
  errorMessages: {
166
170
  'FIELD_REQUIRED': 'This field is required',
167
171
  'UNKNOWN_ERROR': 'Something went wrong. Please try again later',
@@ -193,7 +197,7 @@ export const dict = {
193
197
  login: {
194
198
  email: 'Email',
195
199
  password: 'Password',
196
- otpToken: 'OTP token',
200
+ otpToken: '2FA OTP token',
197
201
  forgotPassword: 'Forgot password?',
198
202
  login: 'Login',
199
203
  errorMessages: {
@@ -274,13 +278,14 @@ export const dict = {
274
278
  'TOKEN_EXPIRED': 'Token expired',
275
279
  'TOKEN_NOT_FOUND': 'Token not found',
276
280
  'TOKEN_USED': 'Token already used',
281
+ 'TOKEN_INVALID': 'Invalid token',
277
282
  } satisfies Record<PasswordResetFormErrorCode, string>,
278
283
  title: 'Reset password',
279
284
  description: 'Enter new password below',
280
285
  success: 'Password has been reset',
281
286
  },
282
287
  passwordResetRequest: {
283
- email: 'Email',
288
+ email: 'E-mail',
284
289
  submit: 'Request reset code',
285
290
  errorMessages: {
286
291
  'FIELD_REQUIRED': 'This field is required',
@@ -294,6 +299,50 @@ export const dict = {
294
299
  checkMail: 'Please check your mailbox for instructions on how to reset your password.',
295
300
  entryCode: 'Or enter the reset code directly.',
296
301
  },
302
+ passwordlessSignInInit: {
303
+ email: 'E-mail',
304
+ submit: 'Send magic link',
305
+ errorMessages: {
306
+ 'FIELD_REQUIRED': 'This field is required',
307
+ 'INVALID_VALUE': 'Invalid value',
308
+ 'UNKNOWN_ERROR': 'Something went wrong. Please try again later',
309
+ 'PERSON_NOT_FOUND': 'Unknown email',
310
+ 'PASSWORDLESS_DISABLED': 'Passwordless sign-in is not available',
311
+ } satisfies Record<PasswordlessSignInInitFormErrorCode, string>,
312
+ title: 'Sign in',
313
+ description: 'Enter your email below to sign in to your account',
314
+ success: 'Magic link has been sent',
315
+ checkMail: 'Please check your mailbox for instructions on how to sign in.',
316
+ entryCode: 'Or enter the reset code directly.',
317
+ },
318
+ passwordlessSignIn: {
319
+ token: 'Verification code',
320
+ otpToken: '2FA OTP token',
321
+ submit: 'Sign in',
322
+ errorMessages: {
323
+ 'FIELD_REQUIRED': 'This field is required',
324
+ 'INVALID_VALUE': 'Invalid value',
325
+ 'UNKNOWN_ERROR': 'Something went wrong. Please try again later',
326
+ 'INVALID_OTP_TOKEN': 'Invalid OTP token',
327
+ 'OTP_REQUIRED': undefined,
328
+ 'PERSON_DISABLED': 'Person disabled',
329
+ 'TOKEN_EXPIRED': 'Token expired',
330
+ 'TOKEN_NOT_FOUND': 'Token not found',
331
+ 'TOKEN_USED': 'Token already used',
332
+ 'TOKEN_INVALID': 'Invalid token',
333
+ } satisfies Record<PasswordlessSignInFormErrorCode, string | undefined>,
334
+ title: 'Sign in',
335
+ },
336
+ otpActivation: {
337
+ errorMessages: {
338
+ 'TOKEN_INVALID': 'This token is not valid. Please try again.',
339
+ 'TOKEN_USED': 'Token already used',
340
+ 'TOKEN_NOT_FOUND': 'Token not found',
341
+ 'TOKEN_EXPIRED': 'Token expired',
342
+ 'UNKNOWN_ERROR': 'Something went wrong. Please try again later',
343
+ } satisfies Record<ActivatePasswordlessOtpErrorCode | 'UNKNOWN_ERROR', string>,
344
+ },
345
+
297
346
  updateProjectMember: {
298
347
  updateSuccess: 'Roles updated',
299
348
  roles: 'Roles',
@@ -39,7 +39,7 @@ export const DimensionsSwitcher = Component(({ options, dimension, children, slu
39
39
  <DataViewLoaderState loaded>
40
40
 
41
41
  <Popover>
42
- <PopoverTrigger>
42
+ <PopoverTrigger asChild>
43
43
  <Button variant={'outline'} size="sm">
44
44
  <DimensionSwitcherCurrentValues dimension={dimension} slugField={slugField}>
45
45
  {children}
@@ -1,10 +1,10 @@
1
1
  import { dataAttribute } from '@contember/utilities'
2
- import { memo, ReactElement, ReactNode, TextareaHTMLAttributes } from 'react'
2
+ import { ComponentType, memo, ReactElement, ReactNode, TextareaHTMLAttributes } from 'react'
3
3
 
4
4
  export interface HTMLTextAreaDivTargetProps extends TextareaHTMLAttributes<HTMLDivElement> { }
5
5
 
6
6
  export interface EditorCanvasProps<P extends HTMLTextAreaDivTargetProps> {
7
- underlyingComponent: (props: P) => ReactElement
7
+ underlyingComponent: ComponentType<P>
8
8
  componentProps: P
9
9
  focusRing?: boolean
10
10
  children?: ReactNode
@@ -3,3 +3,4 @@ export * from './block-editor'
3
3
  export * from './editor-block'
4
4
  export * from './plugins'
5
5
  export * from './rich-text'
6
+ export * from './rich-text-view'
@@ -0,0 +1,17 @@
1
+ import { Component, FieldView, SugaredRelativeSingleField } from '@contember/interface'
2
+ import { RichTextFieldRenderer, RichTextFieldRendererProps } from '@contember/react-client'
3
+
4
+ export type RichTextRendererProps =
5
+ & {
6
+ field: SugaredRelativeSingleField['field']
7
+ }
8
+ & Omit<RichTextFieldRendererProps, 'source'>
9
+
10
+ export const RichTextView = Component<RichTextRendererProps>(({ field, ...props }) => {
11
+ return <FieldView<string> field={field} render={it => {
12
+ if (!it.value) {
13
+ return null
14
+ }
15
+ return <RichTextFieldRenderer source={JSON.parse(it.value)} {...props} />
16
+ }} />
17
+ })
@@ -0,0 +1,10 @@
1
+ import { Component, FieldView, SugaredRelativeSingleField } from '@contember/interface'
2
+ import { getFormatter } from '../formatting'
3
+
4
+ export interface FormattedFieldProps {
5
+ field: SugaredRelativeSingleField['field']
6
+ }
7
+
8
+ export const FormattedField = Component<FormattedFieldProps>(({ field }) => {
9
+ return <FieldView field={field} render={it => getFormatter(it.schema)(it.value)} />
10
+ })
@@ -0,0 +1 @@
1
+ export * from './formatted-field'
@@ -2,62 +2,60 @@ import * as React from 'react'
2
2
  import { ReactNode } from 'react'
3
3
  import { FormContainerUI, FormDescriptionUI, FormErrorUI, FormLabelUI, FormLabelWrapperUI } from './ui'
4
4
  import { useErrorFormatter } from '../errors'
5
- import { Component } from '@contember/interface'
6
- import { FormError, FormLabel } from '@contember/react-form'
5
+ import { Component, ErrorAccessor } from '@contember/interface'
6
+ import { FormError, FormFieldStateProvider, FormLabel, useFormFieldState } from '@contember/react-form'
7
+ import { useFieldLabelFormatter } from '../labels'
7
8
 
8
9
  export interface FormContainerProps {
9
10
  label?: ReactNode
10
11
  description?: ReactNode
11
12
  children: ReactNode
12
- errors?: ReactNode
13
+ errors?: ErrorAccessor.Error[] | ReactNode
14
+ required?: boolean
13
15
  }
14
16
 
15
17
 
16
- export const StandaloneFormContainer = ({ children, description, label, errors }: FormContainerProps) => (
17
- <FormContainerUI>
18
- <FormLabelWrapperUI>
19
- {label &&
20
- <FormLabelUI>
21
- {label}
22
- </FormLabelUI>
23
- }
24
- </FormLabelWrapperUI>
25
- <div>
26
- {children}
27
- </div>
28
- <div>
29
- {description && <FormDescriptionUI>
30
- {description}
31
- </FormDescriptionUI>}
32
- {errors}
33
- </div>
34
- </FormContainerUI>
35
- )
18
+ export const FormContainer = Component(({ children, description, label, required, errors }: FormContainerProps) => {
19
+ const errorsNode = Array.isArray(errors) ? undefined : errors
20
+ const errorsList = Array.isArray(errors) ? errors : []
21
+ const state = useFormFieldState()
22
+ const fieldLabelFormatter = useFieldLabelFormatter()
23
+ label ??= state?.field ? fieldLabelFormatter(state.field.entityName, state.field.fieldName) : undefined
36
24
 
37
- export const FormContainer = Component(({ children, description, label }: FormContainerProps) => (
38
- <FormContainerUI>
39
- <FormLabelWrapperUI>
40
- {label && <FormLabel>
41
- <FormLabelUI>
42
- {label}
43
- </FormLabelUI>
44
- </FormLabel>}
45
- </FormLabelWrapperUI>
46
- <div>
47
- {children}
48
- </div>
49
- <div>
50
- {description && <FormDescriptionUI>
51
- {description}
52
- </FormDescriptionUI>}
25
+ const inner = <>
26
+ <FormContainerUI>
27
+ <FormLabelWrapperUI>
28
+ {label && <FormLabel>
29
+ <FormLabelUI required={required}>
30
+ {label}
31
+ </FormLabelUI>
32
+ </FormLabel>}
33
+ </FormLabelWrapperUI>
34
+ <div>
35
+ {children}
36
+ </div>
37
+ <div>
38
+ {description && <FormDescriptionUI>
39
+ {description}
40
+ </FormDescriptionUI>}
53
41
 
54
- <FormError formatter={useErrorFormatter()}>
55
- <FormErrorUI />
56
- </FormError>
57
- </div>
58
- </FormContainerUI>
59
- ), ({ children, label, description }) => <>
42
+ <FormError formatter={useErrorFormatter()}>
43
+ <FormErrorUI />
44
+ </FormError>
45
+ {errorsNode}
46
+ </div>
47
+ </FormContainerUI>
48
+ </>
49
+ return state !== undefined
50
+ ? inner
51
+ : <FormFieldStateProvider required={required} errors={errorsList} dirty={false}>{inner}</FormFieldStateProvider>
52
+ }, ({ children, label, description }) => <>
60
53
  {label}
61
54
  {children}
62
55
  {description}
63
56
  </>)
57
+
58
+ /**
59
+ * @deprecated use `FormContainer` instead
60
+ */
61
+ export const StandaloneFormContainer = FormContainer
@@ -3,3 +3,4 @@ export * from './inputs'
3
3
  export * from './select'
4
4
  export * from './ui'
5
5
  export * from './upload'
6
+ export * from './upload-repeaters'
@@ -4,9 +4,20 @@ import { CheckboxInput, Input, RadioInput } from '../ui/input'
4
4
  import { cn } from '../utils'
5
5
  import { TextareaAutosize } from '../ui/textarea'
6
6
  import { FormLabelUI } from './ui'
7
- import { FormCheckbox, FormCheckboxProps, FormFieldScope, FormInput, FormInputProps, FormLabel, FormRadioInput, FormRadioItemProps } from '@contember/react-form'
7
+ import {
8
+ FormCheckbox,
9
+ FormCheckboxProps,
10
+ FormFieldScope,
11
+ FormInput,
12
+ FormInputProps,
13
+ FormLabel,
14
+ FormRadioInput,
15
+ FormRadioItemProps,
16
+ useFormFieldState,
17
+ } from '@contember/react-form'
8
18
  import { FormContainer, FormContainerProps } from './container'
9
- import { Component } from '@contember/interface'
19
+ import { Component, Field } from '@contember/interface'
20
+ import { useEnumOptionsFormatter } from '../labels'
10
21
 
11
22
 
12
23
  export type InputFieldProps =
@@ -19,7 +30,7 @@ export type InputFieldProps =
19
30
 
20
31
  export const InputField = Component(({ field, label, description, inputProps, isNonbearing, defaultValue, required }: InputFieldProps) => (
21
32
  <FormFieldScope field={field}>
22
- <FormContainer description={description} label={label}>
33
+ <FormContainer description={description} label={label} required={required}>
23
34
  <FormInput field={field} isNonbearing={isNonbearing} defaultValue={defaultValue}>
24
35
  <Input required={required} {...(inputProps ?? {})} className={cn('max-w-md', inputProps?.className)} />
25
36
  </FormInput>
@@ -31,14 +42,15 @@ export type TextareaFieldProps =
31
42
  & Omit<FormInputProps, 'children'>
32
43
  & Omit<FormContainerProps, 'children'>
33
44
  & {
45
+ required?: boolean
34
46
  inputProps?: ComponentProps<typeof TextareaAutosize>
35
47
  }
36
48
 
37
- export const TextareaField = Component(({ field, label, description, inputProps, isNonbearing, defaultValue }: TextareaFieldProps) => (
49
+ export const TextareaField = Component(({ field, label, description, inputProps, isNonbearing, defaultValue, required }: TextareaFieldProps) => (
38
50
  <FormFieldScope field={field}>
39
- <FormContainer description={description} label={label}>
51
+ <FormContainer description={description} label={label} required={required}>
40
52
  <FormInput field={field} isNonbearing={isNonbearing} defaultValue={defaultValue}>
41
- <TextareaAutosize {...(inputProps ?? {})} className={cn('max-w-md', inputProps?.className)} />
53
+ <TextareaAutosize required={required} {...(inputProps ?? {})} className={cn('max-w-md', inputProps?.className)} />
42
54
  </FormInput>
43
55
  </FormContainer>
44
56
  </FormFieldScope>
@@ -49,18 +61,19 @@ export type CheckboxFieldProps =
49
61
  & Omit<FormCheckboxProps, 'children'>
50
62
  & Omit<FormContainerProps, 'children'>
51
63
  & {
64
+ required?: boolean
52
65
  inputProps?: Omit<React.InputHTMLAttributes<HTMLInputElement>, 'defaultValue'>
53
66
  }
54
67
 
55
- export const CheckboxField = Component(({ field, label, description, inputProps, isNonbearing, defaultValue }: CheckboxFieldProps) => (
68
+ export const CheckboxField = Component(({ field, label, description, inputProps, isNonbearing, defaultValue, required }: CheckboxFieldProps) => (
56
69
  <FormFieldScope field={field}>
57
70
  <FormContainer description={description} label={undefined}>
58
71
  <div className="flex gap-2 items-center">
59
72
  <FormCheckbox field={field} isNonbearing={isNonbearing} defaultValue={defaultValue}>
60
- <CheckboxInput {...inputProps} />
73
+ <CheckboxInput required={required} {...inputProps} />
61
74
  </FormCheckbox>
62
75
  {label && <FormLabel>
63
- <FormLabelUI>
76
+ <FormLabelUI required={required}>
64
77
  {label}
65
78
  </FormLabelUI>
66
79
  </FormLabel>}
@@ -74,26 +87,46 @@ export type RadioEnumFieldProps =
74
87
  & Omit<FormRadioItemProps, 'children' | 'value'>
75
88
  & Omit<FormContainerProps, 'children'>
76
89
  & {
77
- options: Record<string, ReactNode>
90
+ required?: boolean
91
+ options?: Record<string, ReactNode> | Array<{ value: null | string | number | boolean; label: React.ReactNode }>
78
92
  orientation?: 'horizontal' | 'vertical'
79
93
  inputProps?: Omit<React.InputHTMLAttributes<HTMLInputElement>, 'defaultValue'>
80
94
  }
81
95
 
82
- export const RadioEnumField = Component<RadioEnumFieldProps>(({ field, label, description, options, inputProps, orientation, defaultValue, isNonbearing }) => {
96
+ export const RadioEnumField = Component<RadioEnumFieldProps>(({ field, label, description, required, ...rest }) => {
83
97
  return (
84
98
  <FormFieldScope field={field}>
85
- <FormContainer description={description} label={label}>
86
- <div className={'flex flex-wrap gap-3 data-[orientation=vertical]:flex-col'} data-orientation={orientation ?? 'vertical'}>
87
- {Object.entries(options).map(([value, label]) => (
88
- <FormLabelUI className="flex gap-2 items-center font-normal" key={value}>
89
- <FormRadioInput field={field} value={value} defaultValue={defaultValue} isNonbearing={isNonbearing}>
90
- <RadioInput {...inputProps} />
91
- </FormRadioInput>
92
- {label}
93
- </FormLabelUI>
94
- ))}
95
- </div>
99
+ <FormContainer description={description} label={label} required={required}>
100
+ <RadioEnumFieldInner field={field} required={required} {...rest} />
96
101
  </FormContainer>
97
102
  </FormFieldScope>
98
103
  )
99
- })
104
+ }, ({ field, isNonbearing, defaultValue }) => <Field field={field} isNonbearing={isNonbearing} defaultValue={defaultValue} />)
105
+
106
+ type RadioEnumFieldInnerProps = Pick<RadioEnumFieldProps, 'field' | 'options' | 'orientation' | 'inputProps' | 'defaultValue' | 'isNonbearing' | 'required'>
107
+
108
+ const RadioEnumFieldInner: React.FC<RadioEnumFieldInnerProps> = ({ field, inputProps, isNonbearing, required, options, orientation, defaultValue }) => {
109
+ const enumLabelsFormatter = useEnumOptionsFormatter()
110
+ const enumName = useFormFieldState()?.field?.enumName
111
+ options ??= enumName ? enumLabelsFormatter(enumName) : undefined
112
+ if (!options) {
113
+ throw new Error('RadioEnumField: options are required')
114
+ }
115
+
116
+ const normalizedOptions = React.useMemo(() => {
117
+ return Array.isArray(options) ? options : Object.entries(options).map(([value, label]) => ({ value, label }))
118
+ }, [options])
119
+
120
+ return (
121
+ <div className={'flex flex-wrap gap-3 data-[orientation=vertical]:flex-col'} data-orientation={orientation ?? 'vertical'}>
122
+ {normalizedOptions.map(({ value, label }) => (
123
+ <FormLabelUI className="flex gap-2 items-center font-normal" key={value?.toString()}>
124
+ <FormRadioInput field={field} value={value} defaultValue={defaultValue} isNonbearing={isNonbearing}>
125
+ <RadioInput required={required} {...inputProps} />
126
+ </FormRadioInput>
127
+ {label}
128
+ </FormLabelUI>
129
+ ))}
130
+ </div>
131
+ )
132
+ }