@contember/create 1.4.0-rc.3 → 1.4.0-rc.5

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 (223) hide show
  1. package/dist/src/commands/WorkspaceCreateCommand.d.ts +4 -3
  2. package/dist/src/commands/WorkspaceCreateCommand.d.ts.map +1 -1
  3. package/dist/src/commands/WorkspaceCreateCommand.js +10 -4
  4. package/dist/src/commands/WorkspaceCreateCommand.js.map +1 -1
  5. package/dist/src/lib/FileSystem.d.ts +14 -0
  6. package/dist/src/lib/FileSystem.d.ts.map +1 -0
  7. package/dist/src/lib/FileSystem.js +54 -0
  8. package/dist/src/lib/FileSystem.js.map +1 -0
  9. package/dist/src/lib/PackageDownloader.d.ts +7 -0
  10. package/dist/src/lib/PackageDownloader.d.ts.map +1 -0
  11. package/dist/src/lib/PackageDownloader.js +32 -0
  12. package/dist/src/lib/PackageDownloader.js.map +1 -0
  13. package/dist/src/lib/TemplateInstaller.d.ts +13 -0
  14. package/dist/src/lib/TemplateInstaller.d.ts.map +1 -0
  15. package/dist/src/lib/TemplateInstaller.js +75 -0
  16. package/dist/src/lib/TemplateInstaller.js.map +1 -0
  17. package/dist/src/lib/pathUtils.d.ts +3 -0
  18. package/dist/src/lib/pathUtils.d.ts.map +1 -0
  19. package/dist/src/lib/pathUtils.js +7 -0
  20. package/dist/src/lib/pathUtils.js.map +1 -0
  21. package/dist/src/run.js +7 -3
  22. package/dist/src/run.js.map +1 -1
  23. package/dist/src/tsconfig.tsbuildinfo +1 -1
  24. package/package.json +9 -3
  25. package/resources/templates/template-workspace/.gitignore.dist +3 -0
  26. package/resources/templates/template-workspace/admin/.env.development +3 -0
  27. package/resources/templates/template-workspace/admin/.env.production +3 -0
  28. package/resources/templates/template-workspace/admin/app/components/layout.tsx +32 -0
  29. package/resources/templates/template-workspace/admin/app/components/logo.tsx +16 -0
  30. package/resources/templates/template-workspace/admin/app/components/navigation.tsx +1 -0
  31. package/resources/templates/template-workspace/admin/app/config.ts +27 -0
  32. package/resources/templates/template-workspace/admin/app/index.html +15 -0
  33. package/resources/templates/template-workspace/admin/app/index.tsx +40 -0
  34. package/resources/templates/template-workspace/admin/app/pages/index.tsx +5 -0
  35. package/resources/templates/template-workspace/admin/index.css +53 -0
  36. package/resources/templates/template-workspace/admin/index.html +13 -0
  37. package/resources/templates/template-workspace/admin/index.tsx +268 -0
  38. package/resources/templates/template-workspace/admin/lib/binding/binding.tsx +45 -0
  39. package/resources/templates/template-workspace/admin/lib/binding/delete.tsx +43 -0
  40. package/resources/templates/template-workspace/admin/lib/binding/hooks.tsx +71 -0
  41. package/resources/templates/template-workspace/admin/lib/binding/identity.tsx +19 -0
  42. package/resources/templates/template-workspace/admin/lib/binding/index.ts +5 -0
  43. package/resources/templates/template-workspace/admin/lib/binding/persist.tsx +70 -0
  44. package/resources/templates/template-workspace/admin/lib/block-repeater/block-repeater.tsx +224 -0
  45. package/resources/templates/template-workspace/admin/lib/block-repeater/index.ts +1 -0
  46. package/resources/templates/template-workspace/admin/lib/board/board.tsx +240 -0
  47. package/resources/templates/template-workspace/admin/lib/board/index.ts +1 -0
  48. package/resources/templates/template-workspace/admin/lib/buttons/back-button.tsx +20 -0
  49. package/resources/templates/template-workspace/admin/lib/buttons/index.ts +2 -0
  50. package/resources/templates/template-workspace/admin/lib/buttons/link-back-button.tsx +21 -0
  51. package/resources/templates/template-workspace/admin/lib/datagrid/cells.tsx +64 -0
  52. package/resources/templates/template-workspace/admin/lib/datagrid/column-header.tsx +65 -0
  53. package/resources/templates/template-workspace/admin/lib/datagrid/columns.tsx +166 -0
  54. package/resources/templates/template-workspace/admin/lib/datagrid/elements.tsx +42 -0
  55. package/resources/templates/template-workspace/admin/lib/datagrid/empty.tsx +8 -0
  56. package/resources/templates/template-workspace/admin/lib/datagrid/export.tsx +17 -0
  57. package/resources/templates/template-workspace/admin/lib/datagrid/filters/boolean.tsx +76 -0
  58. package/resources/templates/template-workspace/admin/lib/datagrid/filters/common.tsx +29 -0
  59. package/resources/templates/template-workspace/admin/lib/datagrid/filters/date.tsx +153 -0
  60. package/resources/templates/template-workspace/admin/lib/datagrid/filters/enum.tsx +115 -0
  61. package/resources/templates/template-workspace/admin/lib/datagrid/filters/index.ts +7 -0
  62. package/resources/templates/template-workspace/admin/lib/datagrid/filters/mobile.tsx +19 -0
  63. package/resources/templates/template-workspace/admin/lib/datagrid/filters/number.tsx +100 -0
  64. package/resources/templates/template-workspace/admin/lib/datagrid/filters/relation.tsx +180 -0
  65. package/resources/templates/template-workspace/admin/lib/datagrid/filters/text.tsx +121 -0
  66. package/resources/templates/template-workspace/admin/lib/datagrid/grid.tsx +61 -0
  67. package/resources/templates/template-workspace/admin/lib/datagrid/index.ts +16 -0
  68. package/resources/templates/template-workspace/admin/lib/datagrid/layout-switcher.tsx +32 -0
  69. package/resources/templates/template-workspace/admin/lib/datagrid/loader.tsx +10 -0
  70. package/resources/templates/template-workspace/admin/lib/datagrid/pagination.tsx +103 -0
  71. package/resources/templates/template-workspace/admin/lib/datagrid/table.tsx +69 -0
  72. package/resources/templates/template-workspace/admin/lib/datagrid/tiles.tsx +24 -0
  73. package/resources/templates/template-workspace/admin/lib/datagrid/toolbar.tsx +66 -0
  74. package/resources/templates/template-workspace/admin/lib/datagrid/ui.tsx +153 -0
  75. package/resources/templates/template-workspace/admin/lib/dev/index.ts +2 -0
  76. package/resources/templates/template-workspace/admin/lib/dev/login-panel.tsx +56 -0
  77. package/resources/templates/template-workspace/admin/lib/dev/todo.tsx +14 -0
  78. package/resources/templates/template-workspace/admin/lib/dict.ts +324 -0
  79. package/resources/templates/template-workspace/admin/lib/dimensions/dimensions.tsx +135 -0
  80. package/resources/templates/template-workspace/admin/lib/dimensions/index.ts +1 -0
  81. package/resources/templates/template-workspace/admin/lib/editor/block-editor.tsx +111 -0
  82. package/resources/templates/template-workspace/admin/lib/editor/common/baseEditorPlugins.tsx +66 -0
  83. package/resources/templates/template-workspace/admin/lib/editor/common/buttons.tsx +83 -0
  84. package/resources/templates/template-workspace/admin/lib/editor/common/editor-block-toolbar.tsx +17 -0
  85. package/resources/templates/template-workspace/admin/lib/editor/common/editor-canvas.tsx +30 -0
  86. package/resources/templates/template-workspace/admin/lib/editor/common/editor-editable-canvas.tsx +50 -0
  87. package/resources/templates/template-workspace/admin/lib/editor/common/editor-inline-toolbar.tsx +63 -0
  88. package/resources/templates/template-workspace/admin/lib/editor/common/elements/AnchorRenderer.tsx +36 -0
  89. package/resources/templates/template-workspace/admin/lib/editor/common/elements/BlockElement.tsx +48 -0
  90. package/resources/templates/template-workspace/admin/lib/editor/common/elements/HeadingRenderer.tsx +48 -0
  91. package/resources/templates/template-workspace/admin/lib/editor/common/elements/HorizontalRuleRenderer.tsx +28 -0
  92. package/resources/templates/template-workspace/admin/lib/editor/common/elements/ListItemRenderer.tsx +13 -0
  93. package/resources/templates/template-workspace/admin/lib/editor/common/elements/OrderedListRenderer.tsx +13 -0
  94. package/resources/templates/template-workspace/admin/lib/editor/common/elements/ParagraphRenderer.tsx +15 -0
  95. package/resources/templates/template-workspace/admin/lib/editor/common/elements/ScrollTargetRenderer.tsx +30 -0
  96. package/resources/templates/template-workspace/admin/lib/editor/common/elements/TableCellElementRenderer.tsx +20 -0
  97. package/resources/templates/template-workspace/admin/lib/editor/common/elements/TableElementRenderer.tsx +96 -0
  98. package/resources/templates/template-workspace/admin/lib/editor/common/elements/TableRowElementRenderer.tsx +15 -0
  99. package/resources/templates/template-workspace/admin/lib/editor/common/elements/UnorderedListRenderer.tsx +13 -0
  100. package/resources/templates/template-workspace/admin/lib/editor/common/index.ts +6 -0
  101. package/resources/templates/template-workspace/admin/lib/editor/editor-block.tsx +96 -0
  102. package/resources/templates/template-workspace/admin/lib/editor/index.ts +5 -0
  103. package/resources/templates/template-workspace/admin/lib/editor/plugins.tsx +36 -0
  104. package/resources/templates/template-workspace/admin/lib/editor/rich-text.tsx +54 -0
  105. package/resources/templates/template-workspace/admin/lib/editor/sortable-block.tsx +51 -0
  106. package/resources/templates/template-workspace/admin/lib/errors/index.ts +1 -0
  107. package/resources/templates/template-workspace/admin/lib/errors/use-error-formatter.ts +26 -0
  108. package/resources/templates/template-workspace/admin/lib/form/container.tsx +63 -0
  109. package/resources/templates/template-workspace/admin/lib/form/index.ts +5 -0
  110. package/resources/templates/template-workspace/admin/lib/form/inputs.tsx +99 -0
  111. package/resources/templates/template-workspace/admin/lib/form/select.tsx +123 -0
  112. package/resources/templates/template-workspace/admin/lib/form/ui.tsx +29 -0
  113. package/resources/templates/template-workspace/admin/lib/form/upload.tsx +243 -0
  114. package/resources/templates/template-workspace/admin/lib/formatting/formatting.ts +62 -0
  115. package/resources/templates/template-workspace/admin/lib/formatting/index.ts +1 -0
  116. package/resources/templates/template-workspace/admin/lib/images/formatImageResizeUrl.ts +23 -0
  117. package/resources/templates/template-workspace/admin/lib/images/index.ts +1 -0
  118. package/resources/templates/template-workspace/admin/lib/layout/index.ts +2 -0
  119. package/resources/templates/template-workspace/admin/lib/layout/layout.tsx +167 -0
  120. package/resources/templates/template-workspace/admin/lib/layout/slots.tsx +24 -0
  121. package/resources/templates/template-workspace/admin/lib/outdated-application-dialog/index.ts +1 -0
  122. package/resources/templates/template-workspace/admin/lib/outdated-application-dialog/outdated-application-dialog.tsx +41 -0
  123. package/resources/templates/template-workspace/admin/lib/repeater/index.ts +1 -0
  124. package/resources/templates/template-workspace/admin/lib/repeater/repeater.tsx +142 -0
  125. package/resources/templates/template-workspace/admin/lib/select/create-new.tsx +34 -0
  126. package/resources/templates/template-workspace/admin/lib/select/filter.tsx +13 -0
  127. package/resources/templates/template-workspace/admin/lib/select/highlight.tsx +16 -0
  128. package/resources/templates/template-workspace/admin/lib/select/index.ts +7 -0
  129. package/resources/templates/template-workspace/admin/lib/select/list.tsx +49 -0
  130. package/resources/templates/template-workspace/admin/lib/select/multi-select.tsx +95 -0
  131. package/resources/templates/template-workspace/admin/lib/select/pagination.tsx +48 -0
  132. package/resources/templates/template-workspace/admin/lib/select/select.tsx +87 -0
  133. package/resources/templates/template-workspace/admin/lib/select/sortable-select.tsx +129 -0
  134. package/resources/templates/template-workspace/admin/lib/select/ui.tsx +80 -0
  135. package/resources/templates/template-workspace/admin/lib/tenant/forms/change-my-password.tsx +40 -0
  136. package/resources/templates/template-workspace/admin/lib/tenant/forms/common.tsx +94 -0
  137. package/resources/templates/template-workspace/admin/lib/tenant/forms/create-api-key.tsx +39 -0
  138. package/resources/templates/template-workspace/admin/lib/tenant/forms/index.ts +8 -0
  139. package/resources/templates/template-workspace/admin/lib/tenant/forms/invite.tsx +46 -0
  140. package/resources/templates/template-workspace/admin/lib/tenant/forms/login.tsx +52 -0
  141. package/resources/templates/template-workspace/admin/lib/tenant/forms/memberships-control.tsx +128 -0
  142. package/resources/templates/template-workspace/admin/lib/tenant/forms/password-reset-request.tsx +31 -0
  143. package/resources/templates/template-workspace/admin/lib/tenant/forms/password-reset.tsx +44 -0
  144. package/resources/templates/template-workspace/admin/lib/tenant/forms/update-project-member.tsx +32 -0
  145. package/resources/templates/template-workspace/admin/lib/tenant/hooks/useInvite.ts +28 -0
  146. package/resources/templates/template-workspace/admin/lib/tenant/hooks/useInviteUser.tsx +45 -0
  147. package/resources/templates/template-workspace/admin/lib/tenant/index.ts +3 -0
  148. package/resources/templates/template-workspace/admin/lib/tenant/listing/api-key-list.tsx +25 -0
  149. package/resources/templates/template-workspace/admin/lib/tenant/listing/index.ts +4 -0
  150. package/resources/templates/template-workspace/admin/lib/tenant/listing/member-delete-dialog.tsx +38 -0
  151. package/resources/templates/template-workspace/admin/lib/tenant/listing/member-list.tsx +147 -0
  152. package/resources/templates/template-workspace/admin/lib/tenant/listing/person-list.tsx +25 -0
  153. package/resources/templates/template-workspace/admin/lib/tenant/otp/index.ts +1 -0
  154. package/resources/templates/template-workspace/admin/lib/tenant/otp/otp-setup.tsx +146 -0
  155. package/resources/templates/template-workspace/admin/lib/toast/index.ts +2 -0
  156. package/resources/templates/template-workspace/admin/lib/toast/toast.tsx +112 -0
  157. package/resources/templates/template-workspace/admin/lib/toast/toaster.tsx +104 -0
  158. package/resources/templates/template-workspace/admin/lib/ui/alert-dialog.tsx +59 -0
  159. package/resources/templates/template-workspace/admin/lib/ui/button.tsx +29 -0
  160. package/resources/templates/template-workspace/admin/lib/ui/card.tsx +25 -0
  161. package/resources/templates/template-workspace/admin/lib/ui/dialog.tsx +51 -0
  162. package/resources/templates/template-workspace/admin/lib/ui/divider.tsx +11 -0
  163. package/resources/templates/template-workspace/admin/lib/ui/dropdown.tsx +108 -0
  164. package/resources/templates/template-workspace/admin/lib/ui/input.tsx +62 -0
  165. package/resources/templates/template-workspace/admin/lib/ui/label.tsx +7 -0
  166. package/resources/templates/template-workspace/admin/lib/ui/loader.tsx +30 -0
  167. package/resources/templates/template-workspace/admin/lib/ui/menu.tsx +103 -0
  168. package/resources/templates/template-workspace/admin/lib/ui/overlay.tsx +33 -0
  169. package/resources/templates/template-workspace/admin/lib/ui/popover.tsx +31 -0
  170. package/resources/templates/template-workspace/admin/lib/ui/progress.tsx +25 -0
  171. package/resources/templates/template-workspace/admin/lib/ui/scroll-area.tsx +45 -0
  172. package/resources/templates/template-workspace/admin/lib/ui/sheet.tsx +67 -0
  173. package/resources/templates/template-workspace/admin/lib/ui/sortable.tsx +13 -0
  174. package/resources/templates/template-workspace/admin/lib/ui/switch.tsx +10 -0
  175. package/resources/templates/template-workspace/admin/lib/ui/table.tsx +46 -0
  176. package/resources/templates/template-workspace/admin/lib/ui/textarea.tsx +18 -0
  177. package/resources/templates/template-workspace/admin/lib/ui/toggle-group.tsx +44 -0
  178. package/resources/templates/template-workspace/admin/lib/ui/toggle.tsx +29 -0
  179. package/resources/templates/template-workspace/admin/lib/ui/tooltip.tsx +24 -0
  180. package/resources/templates/template-workspace/admin/lib/upload/dropzone.tsx +21 -0
  181. package/resources/templates/template-workspace/admin/lib/upload/index.ts +3 -0
  182. package/resources/templates/template-workspace/admin/lib/upload/repeater.tsx +12 -0
  183. package/resources/templates/template-workspace/admin/lib/upload/ui.tsx +57 -0
  184. package/resources/templates/template-workspace/admin/lib/upload/upload-progress.tsx +130 -0
  185. package/resources/templates/template-workspace/admin/lib/upload/view.tsx +219 -0
  186. package/resources/templates/template-workspace/admin/lib/utils/cn.ts +4 -0
  187. package/resources/templates/template-workspace/admin/lib/utils/dict-format.tsx +3 -0
  188. package/resources/templates/template-workspace/admin/lib/utils/format-image-resize-url.ts +17 -0
  189. package/resources/templates/template-workspace/admin/lib/utils/formatting.ts +60 -0
  190. package/resources/templates/template-workspace/admin/lib/utils/index.ts +2 -0
  191. package/resources/templates/template-workspace/admin/lib/utils/uic.tsx +79 -0
  192. package/resources/templates/template-workspace/admin/package.json +63 -0
  193. package/resources/templates/template-workspace/admin/postcss.config.js +6 -0
  194. package/resources/templates/template-workspace/admin/public/favicon.png +0 -0
  195. package/resources/templates/template-workspace/admin/tailwind.config.js +73 -0
  196. package/resources/templates/template-workspace/admin/tsconfig.json +23 -0
  197. package/resources/templates/template-workspace/admin/vite-env.d.ts +7 -0
  198. package/resources/templates/template-workspace/admin/vite.config.ts +39 -0
  199. package/resources/templates/template-workspace/api/index.ts +7 -0
  200. package/resources/templates/template-workspace/api/migrations/.gitkeep +1 -0
  201. package/resources/templates/template-workspace/api/model/index.ts +1 -0
  202. package/resources/templates/template-workspace/api/package.json +16 -0
  203. package/resources/templates/template-workspace/api/tsconfig.json +10 -0
  204. package/resources/templates/template-workspace/biome.json +45 -0
  205. package/resources/templates/template-workspace/client/package.json +16 -0
  206. package/resources/templates/template-workspace/client/src/index.ts +1 -0
  207. package/resources/templates/template-workspace/client/tsconfig.json +9 -0
  208. package/resources/templates/template-workspace/contember.template.yaml +7 -0
  209. package/resources/templates/template-workspace/docker-compose.yaml +124 -0
  210. package/resources/templates/template-workspace/package.json +32 -0
  211. package/resources/templates/template-workspace/scripts/generate-client.sh +8 -0
  212. package/resources/templates/template-workspace/tsconfig.json +9 -0
  213. package/resources/templates/template-workspace/tsconfig.settings.json +15 -0
  214. package/src/commands/WorkspaceCreateCommand.ts +15 -6
  215. package/src/lib/FileSystem.ts +24 -0
  216. package/src/lib/PackageDownloader.ts +33 -0
  217. package/src/lib/TemplateInstaller.ts +102 -0
  218. package/src/lib/pathUtils.ts +4 -0
  219. package/src/run.ts +14 -5
  220. package/tsconfig.settings.json +5 -1
  221. package/types/download-tarball/index.d.ts +7 -0
  222. package/types/get-package-json-from-registry/index.d.ts +3 -0
  223. package/types/registry-info/index.d.ts +7 -0
@@ -0,0 +1,69 @@
1
+ import { Component, Environment } from '@contember/interface'
2
+ import { Table, TableBody, TableHeader, TableRow } from '../ui/table'
3
+ import * as React from 'react'
4
+ import { Fragment, ReactNode, useState } from 'react'
5
+ import { DataViewEachRow, DataViewLayout } from '@contember/react-dataview'
6
+ import { SheetIcon } from 'lucide-react'
7
+ import { dict } from '../dict'
8
+ import { ChildrenAnalyzer, Leaf } from '@contember/react-multipass-rendering'
9
+ import { DataGridColumnLeaf, DataGridColumnLeafProps } from './columns'
10
+
11
+ export interface DataViewTableProps {
12
+ children: ReactNode
13
+ }
14
+
15
+ export const DataGridTable = Component<DataViewTableProps>(({ children }) => {
16
+ return (
17
+ <DataViewLayout name="table" label={<>
18
+ <SheetIcon className={'w-3 h-3'} />
19
+ <span>{dict.datagrid.showTable}</span>
20
+ </>}>
21
+ <div className={'rounded-md border overflow-x-auto'}>
22
+ <DataGridTableRenderer>
23
+ {children}
24
+ </DataGridTableRenderer>
25
+ </div>
26
+ </DataViewLayout>
27
+ )
28
+ })
29
+
30
+ const DataGridTableRenderer = Component< DataViewTableProps>(({ children }, env) => {
31
+ const [columns] = useState(() => datagridColumnsAnalyzer.processChildren(children, env))
32
+ return (
33
+ <Table>
34
+ <TableHeader>
35
+ <TableRow>
36
+ {columns.map(({ header, name }, i) => (
37
+ <Fragment key={name ?? `_${i}`}>
38
+ {header}
39
+ </Fragment>
40
+ ))}
41
+ </TableRow>
42
+ </TableHeader>
43
+ <TableBody>
44
+ <DataViewEachRow>
45
+ <TableRow>
46
+ {columns.map(({ cell, name }, i) => (
47
+ <Fragment key={name ?? `_${i}`}>
48
+ {cell}
49
+ </Fragment>
50
+ ))}
51
+ </TableRow>
52
+ </DataViewEachRow>
53
+ </TableBody>
54
+ </Table>
55
+ )
56
+ }, ({ children }) => {
57
+ return <>{children}</>
58
+ })
59
+
60
+ const columnLeaf = new Leaf(node => node.props, DataGridColumnLeaf)
61
+
62
+ const datagridColumnsAnalyzer = new ChildrenAnalyzer<
63
+ DataGridColumnLeafProps,
64
+ never,
65
+ Environment
66
+ >([columnLeaf], {
67
+ staticRenderFactoryName: 'staticRender',
68
+ staticContextFactoryName: 'generateEnvironment',
69
+ })
@@ -0,0 +1,24 @@
1
+ import { Component } from '@contember/interface'
2
+ import { DataViewEachRow, DataViewLayout } from '@contember/react-dataview'
3
+ import * as React from 'react'
4
+ import { dict } from '../dict'
5
+ import { LayoutGridIcon } from 'lucide-react'
6
+
7
+ export interface DataGridTilesProps {
8
+ children: React.ReactNode
9
+ }
10
+
11
+ export const DataGridTiles = Component< DataGridTilesProps>(({ children }) => {
12
+ return (
13
+ <DataViewLayout name={'grid'} label={<>
14
+ <LayoutGridIcon className={'w-3 h-3'} />
15
+ <span>{dict.datagrid.showGrid}</span>
16
+ </>}>
17
+ <div className="grid grid-cols-2 md:grid-cols-4 gap-4">
18
+ <DataViewEachRow>
19
+ {children}
20
+ </DataViewEachRow>
21
+ </div>
22
+ </DataViewLayout>
23
+ )
24
+ })
@@ -0,0 +1,66 @@
1
+ import { Component } from '@contember/interface'
2
+ import * as React from 'react'
3
+ import { ReactNode } from 'react'
4
+ import { DataGridShowFiltersContext } from './filters/mobile'
5
+ import { DataGridToolbarUI } from './ui'
6
+ import { Button } from '../ui/button'
7
+ import { FilterIcon, SettingsIcon } from 'lucide-react'
8
+ import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover'
9
+ import { DataGridLayoutSwitcher } from './layout-switcher'
10
+ import { DataGridPerPageSelector } from './pagination'
11
+ import { DataGridQueryFilter } from './filters'
12
+ import { dataAttribute } from '@contember/utilities'
13
+ import { dict } from '../dict'
14
+ import { DataGridAutoExport } from './export'
15
+ import { DataGridToolbarVisibleElements } from './elements'
16
+
17
+ export interface DataGridToolbarProps {
18
+ children?: ReactNode
19
+ }
20
+
21
+ export const DataGridToolbar = Component<DataGridToolbarProps>(({ children }) => {
22
+ const [showFilters, setShowFilters] = React.useState(false)
23
+ return (
24
+ <DataGridShowFiltersContext.Provider value={showFilters}>
25
+ <DataGridToolbarUI>
26
+ <div className="ml-auto flex gap-2 items-center sm:order-1">
27
+ <Button
28
+ variant={'outline'}
29
+ size={'sm'}
30
+ className={'gap-2 sm:hidden data-[active]:bg-gray-50 data-[active]:shadow-inner'}
31
+ data-active={dataAttribute(showFilters)}
32
+ onClick={() => setShowFilters(!showFilters)}
33
+ >
34
+ <FilterIcon className="w-4 h-4" /> {dict.datagrid.filters}
35
+ </Button>
36
+
37
+ <Popover>
38
+ <PopoverTrigger>
39
+ <Button variant={'outline'} size={'sm'} className={'gap-2'}>
40
+ <SettingsIcon className={'w-4 h-4'} />
41
+ </Button>
42
+ </PopoverTrigger>
43
+ <PopoverContent className="w-64">
44
+ <div className="flex flex-col gap-2">
45
+ <DataGridLayoutSwitcher />
46
+ <DataGridToolbarVisibleElements />
47
+ <DataGridPerPageSelector />
48
+ </div>
49
+
50
+ </PopoverContent>
51
+ </Popover>
52
+
53
+ <DataGridAutoExport />
54
+ </div>
55
+
56
+ <div className="flex flex-wrap gap-2">
57
+ {children ?? <>
58
+ <DataGridQueryFilter />
59
+ </>}
60
+ </div>
61
+ </DataGridToolbarUI>
62
+ </DataGridShowFiltersContext.Provider>
63
+ )
64
+ }, ({ children }) => <>
65
+ {children}
66
+ </>)
@@ -0,0 +1,153 @@
1
+ import * as React from 'react'
2
+ import { forwardRef, ReactEventHandler, ReactNode, useCallback } from 'react'
3
+ import { CheckSquareIcon, FilterIcon, FilterXIcon, PlusIcon, SquareIcon, XIcon } from 'lucide-react'
4
+ import { Button } from '../ui/button'
5
+ import { cn } from '../utils/cn'
6
+ import { dict } from '../dict'
7
+ import { uic } from '../utils/uic'
8
+
9
+ export const DataGridTooltipLabel = uic('span', {
10
+ baseClass: 'cursor-pointer border-dashed border-b border-b-gray-400 hover:border-gray-800',
11
+ })
12
+
13
+ /**
14
+ * Button in a tooltip that triggers the filter action
15
+ */
16
+ export const DataGridFilterActionButtonUI = forwardRef<HTMLButtonElement, {}>((props: {}, ref) => {
17
+ return (
18
+ <Button
19
+ variant={'outline'}
20
+ size={'sm'}
21
+ className={'space-x-1 data-[active]:text-blue-600 data-[active]:bg-gray-50 data-[active]:shadow-inner'}
22
+ ref={ref}
23
+ {...props}
24
+ >
25
+ <FilterIcon className={'w-3 h-3'} />
26
+ <span>{dict.datagrid.filter}</span>
27
+ </Button>
28
+ )
29
+ })
30
+
31
+ /**
32
+ * Button in a tooltip that triggers the exclude action
33
+ */
34
+ export const DataGridExcludeActionButtonUI = forwardRef<HTMLButtonElement, {}>((props: {}, ref) => {
35
+ return (
36
+ <Button
37
+ variant={'outline'}
38
+ size={'sm'}
39
+ className={'space-x-1 data-[active]:text-blue-600 data-[active]:bg-gray-50 data-[active]:shadow-inner'}
40
+ ref={ref}
41
+ {...props}
42
+ >
43
+ <FilterXIcon className={'w-3 h-3'} />
44
+ <span>{dict.datagrid.exclude}</span>
45
+ </Button>
46
+ )
47
+ })
48
+
49
+ /**
50
+ * Button in a filter list that removes the filter
51
+ */
52
+ export const DataGridActiveFilterUI = forwardRef<HTMLButtonElement, {
53
+ children: ReactNode,
54
+ className?: string
55
+ }>(({ children, className, ...props }, ref) => {
56
+ return (
57
+ <Button
58
+ variant={'outline'}
59
+ size="sm"
60
+ className={cn('space-x-1 data-[current="none"]:hidden data-[current="exclude"]:line-through h-6', className)}
61
+ ref={ref}
62
+ {...props}
63
+ >
64
+ <span>
65
+ {children}
66
+ </span>
67
+ <XIcon className={'w-2 h-2'} />
68
+ </Button>
69
+ )
70
+ })
71
+
72
+
73
+ export const DataGridSingleFilterUI = forwardRef<HTMLDivElement, { children: ReactNode }>((props, ref) => {
74
+ return (
75
+ <div className={'flex flex-wrap gap-2 rounded bg-gray-50 items-center text-sm px-2 py-1.5 border'} ref={ref} {...props} />
76
+ )
77
+ })
78
+
79
+ export const DataGridFilterSelectTriggerUI = forwardRef<HTMLButtonElement, { children: ReactNode }>(({
80
+ children,
81
+ ...props
82
+ }, ref) => {
83
+ return (
84
+ <button className={'hover:underline inline-flex items-center gap-2 group px-1'} ref={ref} {...props}>
85
+ <span className={'text-xs font-medium'}>
86
+ {children}
87
+ </span>
88
+ <span
89
+ className={'bg-gray-100 rounded-full border group-data-[state=open]:bg-white group-data-[state=open]:shadow-inner p-1'}
90
+ >
91
+ <PlusIcon className={'w-3 h-3'} />
92
+ </span>
93
+ </button>
94
+ )
95
+ })
96
+
97
+ export interface DataGridFilterSelectItemProps {
98
+ onInclude: () => void
99
+ onExclude: () => void
100
+ isIncluded: boolean
101
+ isExcluded: boolean
102
+ children: ReactNode
103
+ }
104
+
105
+ export const DataGridFilterSelectItemUI = forwardRef<HTMLButtonElement, DataGridFilterSelectItemProps>(({
106
+ children,
107
+ onExclude,
108
+ isExcluded,
109
+ onInclude,
110
+ isIncluded,
111
+ ...props
112
+ }, ref) => {
113
+ const include = useCallback<ReactEventHandler>(e => {
114
+ onInclude()
115
+ e.preventDefault()
116
+ }, [onInclude])
117
+ const exclude = useCallback<ReactEventHandler>(e => {
118
+ onExclude()
119
+ e.preventDefault()
120
+ e.stopPropagation()
121
+ }, [onExclude])
122
+
123
+ return (
124
+ <div className={'relative flex gap-1 justify-between items-center'}>
125
+ <Button
126
+ ref={ref}
127
+ onClick={include}
128
+ size={'sm'}
129
+ className={'pl-1 w-full text-left justify-start gap-1 data-[highlighted]:bg-gray-200'}
130
+ variant={'ghost'} {...props}>
131
+ {isIncluded ? <CheckSquareIcon className={'w-3 h-3'}/> : <SquareIcon className={'w-3 h-3'}/>}
132
+ <span className={cn('font-normal', isIncluded && 'text-blue-700')}>
133
+ {children}
134
+ </span>
135
+ </Button>
136
+ <button
137
+ onClick={exclude}
138
+ className={cn(
139
+ 'p-1 border rounded hover:bg-red-200',
140
+ isExcluded ? 'bg-red-300 shadow-inner' : '',
141
+ )}
142
+ >
143
+ <FilterXIcon className={'h-3 w-3'}/>
144
+ </button>
145
+ </div>
146
+
147
+ )
148
+ })
149
+
150
+
151
+ export const DataGridToolbarUI = uic('div', {
152
+ baseClass: 'flex flex-col md:flex-row gap-2 md:items-end mb-4 items-stretch',
153
+ })
@@ -0,0 +1,2 @@
1
+ export * from './login-panel'
2
+ export * from './todo'
@@ -0,0 +1,56 @@
1
+ import { Button } from '../ui/button'
2
+ import { useSessionTokenWithMeta, useSetSessionToken } from '@contember/react-client'
3
+ import { CreateSessionTokenForm, useCreateSessionTokenForm } from '@contember/react-client-tenant'
4
+ import { Loader } from '../ui/loader'
5
+ import { TenantFormError, TenantFormField } from '../tenant/forms/common'
6
+
7
+ export const LoginWithEmail = () => {
8
+ const sessionToken = useSessionTokenWithMeta()
9
+ const setSessionToken = useSetSessionToken()
10
+
11
+ return <>
12
+ <CreateSessionTokenForm
13
+ expiration={3600 * 24 * 7}
14
+ apiToken={sessionToken.propsToken}
15
+ onSuccess={it => {
16
+ setSessionToken(it.result.token)
17
+ }}>
18
+ <form>
19
+ <CreateSessionTokenFormFields />
20
+ </form>
21
+ </CreateSessionTokenForm>
22
+ </>
23
+ }
24
+
25
+
26
+ const CreateSessionTokenFormFields = () => {
27
+ const form = useCreateSessionTokenForm()
28
+
29
+ const messages = {
30
+ FIELD_REQUIRED: 'This field is required',
31
+ UNKNOWN_ERROR: 'An unknown error occurred',
32
+ PERSON_DISABLED: 'Person is disabled',
33
+ UNKNOWN_EMAIL: 'Person with given email not found',
34
+ UNKNOWN_PERSON_ID: 'Person with given ID not found',
35
+ }
36
+ return (
37
+ <div className="relative flex flex-col gap-2">
38
+ {form.state === 'submitting' ? <Loader position="absolute" /> : null}
39
+
40
+ <TenantFormError
41
+ form={form} messages={messages}
42
+ />
43
+
44
+ <TenantFormField
45
+ form={form} messages={messages} field="email"
46
+ type="text" required autoFocus
47
+ >
48
+ E-mail
49
+ </TenantFormField>
50
+
51
+ <Button type="submit" className="w-full" disabled={form.state === 'submitting'}>
52
+ Login
53
+ </Button>
54
+ </div>
55
+ )
56
+ }
@@ -0,0 +1,14 @@
1
+ import { PropsWithChildren } from 'react'
2
+
3
+ export interface CommentProps extends PropsWithChildren {
4
+ }
5
+
6
+ export const Todo = ({ children }: CommentProps) => {
7
+ if (!import.meta.env.DEV) return null
8
+
9
+ return (
10
+ <div className="bg-yellow-100 p-4">
11
+ <strong>TODO:</strong> {children}
12
+ </div>
13
+ )
14
+ }