@contember/create 1.4.0-rc.4 → 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.
- package/dist/src/commands/WorkspaceCreateCommand.d.ts +4 -3
- package/dist/src/commands/WorkspaceCreateCommand.d.ts.map +1 -1
- package/dist/src/commands/WorkspaceCreateCommand.js +10 -4
- package/dist/src/commands/WorkspaceCreateCommand.js.map +1 -1
- package/dist/src/lib/FileSystem.d.ts +14 -0
- package/dist/src/lib/FileSystem.d.ts.map +1 -0
- package/dist/src/lib/FileSystem.js +54 -0
- package/dist/src/lib/FileSystem.js.map +1 -0
- package/dist/src/lib/PackageDownloader.d.ts +7 -0
- package/dist/src/lib/PackageDownloader.d.ts.map +1 -0
- package/dist/src/lib/PackageDownloader.js +32 -0
- package/dist/src/lib/PackageDownloader.js.map +1 -0
- package/dist/src/lib/TemplateInstaller.d.ts +13 -0
- package/dist/src/lib/TemplateInstaller.d.ts.map +1 -0
- package/dist/src/lib/TemplateInstaller.js +75 -0
- package/dist/src/lib/TemplateInstaller.js.map +1 -0
- package/dist/src/lib/pathUtils.d.ts +3 -0
- package/dist/src/lib/pathUtils.d.ts.map +1 -0
- package/dist/src/lib/pathUtils.js +7 -0
- package/dist/src/lib/pathUtils.js.map +1 -0
- package/dist/src/run.js +7 -3
- package/dist/src/run.js.map +1 -1
- package/dist/src/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -3
- package/resources/templates/template-workspace/.gitignore.dist +3 -0
- package/resources/templates/template-workspace/admin/.env.development +3 -0
- package/resources/templates/template-workspace/admin/.env.production +3 -0
- package/resources/templates/template-workspace/admin/app/components/layout.tsx +32 -0
- package/resources/templates/template-workspace/admin/app/components/logo.tsx +16 -0
- package/resources/templates/template-workspace/admin/app/components/navigation.tsx +1 -0
- package/resources/templates/template-workspace/admin/app/config.ts +27 -0
- package/resources/templates/template-workspace/admin/app/index.html +15 -0
- package/resources/templates/template-workspace/admin/app/index.tsx +40 -0
- package/resources/templates/template-workspace/admin/app/pages/index.tsx +5 -0
- package/resources/templates/template-workspace/admin/index.css +53 -0
- package/resources/templates/template-workspace/admin/index.html +13 -0
- package/resources/templates/template-workspace/admin/index.tsx +268 -0
- package/resources/templates/template-workspace/admin/lib/binding/binding.tsx +45 -0
- package/resources/templates/template-workspace/admin/lib/binding/delete.tsx +43 -0
- package/resources/templates/template-workspace/admin/lib/binding/hooks.tsx +71 -0
- package/resources/templates/template-workspace/admin/lib/binding/identity.tsx +19 -0
- package/resources/templates/template-workspace/admin/lib/binding/index.ts +5 -0
- package/resources/templates/template-workspace/admin/lib/binding/persist.tsx +70 -0
- package/resources/templates/template-workspace/admin/lib/block-repeater/block-repeater.tsx +224 -0
- package/resources/templates/template-workspace/admin/lib/block-repeater/index.ts +1 -0
- package/resources/templates/template-workspace/admin/lib/board/board.tsx +240 -0
- package/resources/templates/template-workspace/admin/lib/board/index.ts +1 -0
- package/resources/templates/template-workspace/admin/lib/buttons/back-button.tsx +20 -0
- package/resources/templates/template-workspace/admin/lib/buttons/index.ts +2 -0
- package/resources/templates/template-workspace/admin/lib/buttons/link-back-button.tsx +21 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/cells.tsx +64 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/column-header.tsx +65 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/columns.tsx +166 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/elements.tsx +42 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/empty.tsx +8 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/export.tsx +17 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/boolean.tsx +76 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/common.tsx +29 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/date.tsx +153 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/enum.tsx +115 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/index.ts +7 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/mobile.tsx +19 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/number.tsx +100 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/relation.tsx +180 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/text.tsx +121 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/grid.tsx +61 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/index.ts +16 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/layout-switcher.tsx +32 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/loader.tsx +10 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/pagination.tsx +103 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/table.tsx +69 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/tiles.tsx +24 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/toolbar.tsx +66 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/ui.tsx +153 -0
- package/resources/templates/template-workspace/admin/lib/dev/index.ts +2 -0
- package/resources/templates/template-workspace/admin/lib/dev/login-panel.tsx +56 -0
- package/resources/templates/template-workspace/admin/lib/dev/todo.tsx +14 -0
- package/resources/templates/template-workspace/admin/lib/dict.ts +324 -0
- package/resources/templates/template-workspace/admin/lib/dimensions/dimensions.tsx +135 -0
- package/resources/templates/template-workspace/admin/lib/dimensions/index.ts +1 -0
- package/resources/templates/template-workspace/admin/lib/editor/block-editor.tsx +111 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/baseEditorPlugins.tsx +66 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/buttons.tsx +83 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/editor-block-toolbar.tsx +17 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/editor-canvas.tsx +30 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/editor-editable-canvas.tsx +50 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/editor-inline-toolbar.tsx +63 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/elements/AnchorRenderer.tsx +36 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/elements/BlockElement.tsx +48 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/elements/HeadingRenderer.tsx +48 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/elements/HorizontalRuleRenderer.tsx +28 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/elements/ListItemRenderer.tsx +13 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/elements/OrderedListRenderer.tsx +13 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/elements/ParagraphRenderer.tsx +15 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/elements/ScrollTargetRenderer.tsx +30 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/elements/TableCellElementRenderer.tsx +20 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/elements/TableElementRenderer.tsx +96 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/elements/TableRowElementRenderer.tsx +15 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/elements/UnorderedListRenderer.tsx +13 -0
- package/resources/templates/template-workspace/admin/lib/editor/common/index.ts +6 -0
- package/resources/templates/template-workspace/admin/lib/editor/editor-block.tsx +96 -0
- package/resources/templates/template-workspace/admin/lib/editor/index.ts +5 -0
- package/resources/templates/template-workspace/admin/lib/editor/plugins.tsx +36 -0
- package/resources/templates/template-workspace/admin/lib/editor/rich-text.tsx +54 -0
- package/resources/templates/template-workspace/admin/lib/editor/sortable-block.tsx +51 -0
- package/resources/templates/template-workspace/admin/lib/errors/index.ts +1 -0
- package/resources/templates/template-workspace/admin/lib/errors/use-error-formatter.ts +26 -0
- package/resources/templates/template-workspace/admin/lib/form/container.tsx +63 -0
- package/resources/templates/template-workspace/admin/lib/form/index.ts +5 -0
- package/resources/templates/template-workspace/admin/lib/form/inputs.tsx +99 -0
- package/resources/templates/template-workspace/admin/lib/form/select.tsx +123 -0
- package/resources/templates/template-workspace/admin/lib/form/ui.tsx +29 -0
- package/resources/templates/template-workspace/admin/lib/form/upload.tsx +243 -0
- package/resources/templates/template-workspace/admin/lib/formatting/formatting.ts +62 -0
- package/resources/templates/template-workspace/admin/lib/formatting/index.ts +1 -0
- package/resources/templates/template-workspace/admin/lib/images/formatImageResizeUrl.ts +23 -0
- package/resources/templates/template-workspace/admin/lib/images/index.ts +1 -0
- package/resources/templates/template-workspace/admin/lib/layout/index.ts +2 -0
- package/resources/templates/template-workspace/admin/lib/layout/layout.tsx +167 -0
- package/resources/templates/template-workspace/admin/lib/layout/slots.tsx +24 -0
- package/resources/templates/template-workspace/admin/lib/outdated-application-dialog/index.ts +1 -0
- package/resources/templates/template-workspace/admin/lib/outdated-application-dialog/outdated-application-dialog.tsx +41 -0
- package/resources/templates/template-workspace/admin/lib/repeater/index.ts +1 -0
- package/resources/templates/template-workspace/admin/lib/repeater/repeater.tsx +142 -0
- package/resources/templates/template-workspace/admin/lib/select/create-new.tsx +34 -0
- package/resources/templates/template-workspace/admin/lib/select/filter.tsx +13 -0
- package/resources/templates/template-workspace/admin/lib/select/highlight.tsx +16 -0
- package/resources/templates/template-workspace/admin/lib/select/index.ts +7 -0
- package/resources/templates/template-workspace/admin/lib/select/list.tsx +49 -0
- package/resources/templates/template-workspace/admin/lib/select/multi-select.tsx +95 -0
- package/resources/templates/template-workspace/admin/lib/select/pagination.tsx +48 -0
- package/resources/templates/template-workspace/admin/lib/select/select.tsx +87 -0
- package/resources/templates/template-workspace/admin/lib/select/sortable-select.tsx +129 -0
- package/resources/templates/template-workspace/admin/lib/select/ui.tsx +80 -0
- package/resources/templates/template-workspace/admin/lib/tenant/forms/change-my-password.tsx +40 -0
- package/resources/templates/template-workspace/admin/lib/tenant/forms/common.tsx +94 -0
- package/resources/templates/template-workspace/admin/lib/tenant/forms/create-api-key.tsx +39 -0
- package/resources/templates/template-workspace/admin/lib/tenant/forms/index.ts +8 -0
- package/resources/templates/template-workspace/admin/lib/tenant/forms/invite.tsx +46 -0
- package/resources/templates/template-workspace/admin/lib/tenant/forms/login.tsx +52 -0
- package/resources/templates/template-workspace/admin/lib/tenant/forms/memberships-control.tsx +128 -0
- package/resources/templates/template-workspace/admin/lib/tenant/forms/password-reset-request.tsx +31 -0
- package/resources/templates/template-workspace/admin/lib/tenant/forms/password-reset.tsx +44 -0
- package/resources/templates/template-workspace/admin/lib/tenant/forms/update-project-member.tsx +32 -0
- package/resources/templates/template-workspace/admin/lib/tenant/hooks/useInvite.ts +28 -0
- package/resources/templates/template-workspace/admin/lib/tenant/hooks/useInviteUser.tsx +45 -0
- package/resources/templates/template-workspace/admin/lib/tenant/index.ts +3 -0
- package/resources/templates/template-workspace/admin/lib/tenant/listing/api-key-list.tsx +25 -0
- package/resources/templates/template-workspace/admin/lib/tenant/listing/index.ts +4 -0
- package/resources/templates/template-workspace/admin/lib/tenant/listing/member-delete-dialog.tsx +38 -0
- package/resources/templates/template-workspace/admin/lib/tenant/listing/member-list.tsx +147 -0
- package/resources/templates/template-workspace/admin/lib/tenant/listing/person-list.tsx +25 -0
- package/resources/templates/template-workspace/admin/lib/tenant/otp/index.ts +1 -0
- package/resources/templates/template-workspace/admin/lib/tenant/otp/otp-setup.tsx +146 -0
- package/resources/templates/template-workspace/admin/lib/toast/index.ts +2 -0
- package/resources/templates/template-workspace/admin/lib/toast/toast.tsx +112 -0
- package/resources/templates/template-workspace/admin/lib/toast/toaster.tsx +104 -0
- package/resources/templates/template-workspace/admin/lib/ui/alert-dialog.tsx +59 -0
- package/resources/templates/template-workspace/admin/lib/ui/button.tsx +29 -0
- package/resources/templates/template-workspace/admin/lib/ui/card.tsx +25 -0
- package/resources/templates/template-workspace/admin/lib/ui/dialog.tsx +51 -0
- package/resources/templates/template-workspace/admin/lib/ui/divider.tsx +11 -0
- package/resources/templates/template-workspace/admin/lib/ui/dropdown.tsx +108 -0
- package/resources/templates/template-workspace/admin/lib/ui/input.tsx +62 -0
- package/resources/templates/template-workspace/admin/lib/ui/label.tsx +7 -0
- package/resources/templates/template-workspace/admin/lib/ui/loader.tsx +30 -0
- package/resources/templates/template-workspace/admin/lib/ui/menu.tsx +103 -0
- package/resources/templates/template-workspace/admin/lib/ui/overlay.tsx +33 -0
- package/resources/templates/template-workspace/admin/lib/ui/popover.tsx +31 -0
- package/resources/templates/template-workspace/admin/lib/ui/progress.tsx +25 -0
- package/resources/templates/template-workspace/admin/lib/ui/scroll-area.tsx +45 -0
- package/resources/templates/template-workspace/admin/lib/ui/sheet.tsx +67 -0
- package/resources/templates/template-workspace/admin/lib/ui/sortable.tsx +13 -0
- package/resources/templates/template-workspace/admin/lib/ui/switch.tsx +10 -0
- package/resources/templates/template-workspace/admin/lib/ui/table.tsx +46 -0
- package/resources/templates/template-workspace/admin/lib/ui/textarea.tsx +18 -0
- package/resources/templates/template-workspace/admin/lib/ui/toggle-group.tsx +44 -0
- package/resources/templates/template-workspace/admin/lib/ui/toggle.tsx +29 -0
- package/resources/templates/template-workspace/admin/lib/ui/tooltip.tsx +24 -0
- package/resources/templates/template-workspace/admin/lib/upload/dropzone.tsx +21 -0
- package/resources/templates/template-workspace/admin/lib/upload/index.ts +3 -0
- package/resources/templates/template-workspace/admin/lib/upload/repeater.tsx +12 -0
- package/resources/templates/template-workspace/admin/lib/upload/ui.tsx +57 -0
- package/resources/templates/template-workspace/admin/lib/upload/upload-progress.tsx +130 -0
- package/resources/templates/template-workspace/admin/lib/upload/view.tsx +219 -0
- package/resources/templates/template-workspace/admin/lib/utils/cn.ts +4 -0
- package/resources/templates/template-workspace/admin/lib/utils/dict-format.tsx +3 -0
- package/resources/templates/template-workspace/admin/lib/utils/format-image-resize-url.ts +17 -0
- package/resources/templates/template-workspace/admin/lib/utils/formatting.ts +60 -0
- package/resources/templates/template-workspace/admin/lib/utils/index.ts +2 -0
- package/resources/templates/template-workspace/admin/lib/utils/uic.tsx +79 -0
- package/resources/templates/template-workspace/admin/package.json +63 -0
- package/resources/templates/template-workspace/admin/postcss.config.js +6 -0
- package/resources/templates/template-workspace/admin/public/favicon.png +0 -0
- package/resources/templates/template-workspace/admin/tailwind.config.js +73 -0
- package/resources/templates/template-workspace/admin/tsconfig.json +23 -0
- package/resources/templates/template-workspace/admin/vite-env.d.ts +7 -0
- package/resources/templates/template-workspace/admin/vite.config.ts +39 -0
- package/resources/templates/template-workspace/api/index.ts +7 -0
- package/resources/templates/template-workspace/api/migrations/.gitkeep +1 -0
- package/resources/templates/template-workspace/api/model/index.ts +1 -0
- package/resources/templates/template-workspace/api/package.json +16 -0
- package/resources/templates/template-workspace/api/tsconfig.json +10 -0
- package/resources/templates/template-workspace/biome.json +45 -0
- package/resources/templates/template-workspace/client/package.json +16 -0
- package/resources/templates/template-workspace/client/src/index.ts +1 -0
- package/resources/templates/template-workspace/client/tsconfig.json +9 -0
- package/resources/templates/template-workspace/contember.template.yaml +7 -0
- package/resources/templates/template-workspace/docker-compose.yaml +124 -0
- package/resources/templates/template-workspace/package.json +32 -0
- package/resources/templates/template-workspace/scripts/generate-client.sh +8 -0
- package/resources/templates/template-workspace/tsconfig.json +9 -0
- package/resources/templates/template-workspace/tsconfig.settings.json +15 -0
- package/src/commands/WorkspaceCreateCommand.ts +15 -6
- package/src/lib/FileSystem.ts +24 -0
- package/src/lib/PackageDownloader.ts +33 -0
- package/src/lib/TemplateInstaller.ts +102 -0
- package/src/lib/pathUtils.ts +4 -0
- package/src/run.ts +14 -5
- package/tsconfig.settings.json +5 -1
- package/types/download-tarball/index.d.ts +7 -0
- package/types/get-package-json-from-registry/index.d.ts +3 -0
- package/types/registry-info/index.d.ts +7 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { Component } from '@contember/interface'
|
|
2
|
+
import {
|
|
3
|
+
Repeater,
|
|
4
|
+
RepeaterAddItemTrigger,
|
|
5
|
+
RepeaterEachItem,
|
|
6
|
+
RepeaterEmpty,
|
|
7
|
+
RepeaterProps,
|
|
8
|
+
RepeaterRemoveItemTrigger,
|
|
9
|
+
} from '@contember/react-repeater'
|
|
10
|
+
import {
|
|
11
|
+
RepeaterSortable,
|
|
12
|
+
RepeaterSortableDragOverlay,
|
|
13
|
+
RepeaterSortableDropIndicator,
|
|
14
|
+
RepeaterSortableEachItem,
|
|
15
|
+
RepeaterSortableItemActivator,
|
|
16
|
+
RepeaterSortableItemNode,
|
|
17
|
+
} from '@contember/react-repeater-dnd-kit'
|
|
18
|
+
import { GripVerticalIcon, PlusCircleIcon, Trash2Icon } from 'lucide-react'
|
|
19
|
+
import { Button } from '../ui/button'
|
|
20
|
+
import { uic } from '../utils/uic'
|
|
21
|
+
import { DropIndicator } from '../ui/sortable'
|
|
22
|
+
import { dict } from '../dict'
|
|
23
|
+
|
|
24
|
+
export const RepeaterWrapperUI = uic('div', {
|
|
25
|
+
baseClass: 'flex flex-col gap-2 p-4 pr-8 relative shadow-sm bg-white rounded border border-gray-300 max-w-md',
|
|
26
|
+
})
|
|
27
|
+
export const RepeaterItemUI = uic('div', {
|
|
28
|
+
baseClass: 'rounded border border-gray-300 p-4 relative',
|
|
29
|
+
})
|
|
30
|
+
export const RepeaterDragOverlayUI = uic('div', {
|
|
31
|
+
baseClass: 'rounded border border-gray-300 p-4 relative bg-opacity-60 bg-gray-100 backdrop-blur-sm',
|
|
32
|
+
})
|
|
33
|
+
export const RepeaterHandleUI = uic('button', {
|
|
34
|
+
baseClass: 'absolute top-1/2 -left-6 h-6 w-6 flex justify-end align-center opacity-10 hover:opacity-100 transition-opacity -translate-y-1/2',
|
|
35
|
+
beforeChildren: <GripVerticalIcon size={16}/>,
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
export const RepeaterDropIndicator = ({ position }: { position: 'before' | 'after' }) => (
|
|
39
|
+
<div className={'relative'}>
|
|
40
|
+
<RepeaterSortableDropIndicator position={position}>
|
|
41
|
+
<DropIndicator placement={position === 'before' ? 'top' : 'bottom'}/>
|
|
42
|
+
</RepeaterSortableDropIndicator>
|
|
43
|
+
</div>
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
export const RepeaterAddItemButton = ({ children }: { children?: React.ReactNode }) => (
|
|
47
|
+
<RepeaterAddItemTrigger index={'last'}>
|
|
48
|
+
<div>
|
|
49
|
+
<Button variant={'link'} size={'sm'} className={'gap-1 px-0'}>
|
|
50
|
+
{children || <>
|
|
51
|
+
<PlusCircleIcon size={16}/>
|
|
52
|
+
<span>Add item</span>
|
|
53
|
+
</>}
|
|
54
|
+
</Button>
|
|
55
|
+
</div>
|
|
56
|
+
</RepeaterAddItemTrigger>
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
export const RepeaterRemoveItemButton = ({ children }: { children?: React.ReactNode }) => (
|
|
60
|
+
<RepeaterRemoveItemTrigger>
|
|
61
|
+
<Button variant={'link'} size={'sm'} className={'gap-1 px-0 group/button'}>
|
|
62
|
+
{children || <>
|
|
63
|
+
<Trash2Icon className={'group-hover/button:text-red-600'} size={16}/>
|
|
64
|
+
</>}
|
|
65
|
+
</Button>
|
|
66
|
+
</RepeaterRemoveItemTrigger>
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
export const RepeaterItemActions = uic('div', {
|
|
70
|
+
baseClass: 'absolute top-1 right-2 flex gap-2',
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
export type DefaultRepeaterProps = { title?: string }
|
|
74
|
+
& RepeaterProps
|
|
75
|
+
|
|
76
|
+
export const DefaultRepeater = Component<DefaultRepeaterProps>(({ title, children, ...props }) => {
|
|
77
|
+
const isSortable = props.sortableBy !== undefined
|
|
78
|
+
|
|
79
|
+
if (!isSortable) {
|
|
80
|
+
return (
|
|
81
|
+
<div>
|
|
82
|
+
<Repeater {...props}>
|
|
83
|
+
{title && <h3 className={'font-medium'}>{title}</h3>}
|
|
84
|
+
|
|
85
|
+
<RepeaterWrapperUI>
|
|
86
|
+
<RepeaterEmpty>
|
|
87
|
+
<div className="italic text-sm text-gray-600">
|
|
88
|
+
{dict.repeater.empty}
|
|
89
|
+
</div>
|
|
90
|
+
</RepeaterEmpty>
|
|
91
|
+
<RepeaterEachItem>
|
|
92
|
+
<RepeaterItemUI>
|
|
93
|
+
{children}
|
|
94
|
+
</RepeaterItemUI>
|
|
95
|
+
</RepeaterEachItem>
|
|
96
|
+
</RepeaterWrapperUI>
|
|
97
|
+
|
|
98
|
+
<RepeaterAddItemButton/>
|
|
99
|
+
</Repeater>
|
|
100
|
+
</div>
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
return (
|
|
104
|
+
<div>
|
|
105
|
+
<Repeater {...props}>
|
|
106
|
+
<RepeaterWrapperUI>
|
|
107
|
+
{title && <h3 className={'font-medium'}>{title}</h3>}
|
|
108
|
+
<RepeaterSortable>
|
|
109
|
+
<RepeaterEmpty>
|
|
110
|
+
<div className="italic text-sm text-gray-600">
|
|
111
|
+
{dict.repeater.empty}
|
|
112
|
+
</div>
|
|
113
|
+
</RepeaterEmpty>
|
|
114
|
+
<RepeaterSortableEachItem>
|
|
115
|
+
<div>
|
|
116
|
+
<RepeaterDropIndicator position={'before'}/>
|
|
117
|
+
<RepeaterSortableItemNode>
|
|
118
|
+
<RepeaterItemUI>
|
|
119
|
+
<RepeaterSortableItemActivator>
|
|
120
|
+
<RepeaterHandleUI/>
|
|
121
|
+
</RepeaterSortableItemActivator>
|
|
122
|
+
{children}
|
|
123
|
+
</RepeaterItemUI>
|
|
124
|
+
</RepeaterSortableItemNode>
|
|
125
|
+
<RepeaterDropIndicator position={'after'}/>
|
|
126
|
+
</div>
|
|
127
|
+
</RepeaterSortableEachItem>
|
|
128
|
+
<RepeaterSortableDragOverlay>
|
|
129
|
+
<RepeaterDragOverlayUI>
|
|
130
|
+
{children}
|
|
131
|
+
</RepeaterDragOverlayUI>
|
|
132
|
+
</RepeaterSortableDragOverlay>
|
|
133
|
+
</RepeaterSortable>
|
|
134
|
+
|
|
135
|
+
<RepeaterAddItemButton />
|
|
136
|
+
</RepeaterWrapperUI>
|
|
137
|
+
</Repeater>
|
|
138
|
+
</div>
|
|
139
|
+
)
|
|
140
|
+
}, props => {
|
|
141
|
+
return <Repeater {...props}/>
|
|
142
|
+
})
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { ReactElement, ReactNode } from 'react'
|
|
3
|
+
import { Button } from '../ui/button'
|
|
4
|
+
import { SelectItemTrigger, SelectNewItem } from '@contember/react-select'
|
|
5
|
+
import { dict } from '../dict'
|
|
6
|
+
import { Dialog, DialogClose, DialogContent, DialogFooter, DialogTrigger } from '../ui/dialog'
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export const CreateEntityDialog = ({ trigger, children }: { trigger: ReactElement, children: ReactNode }) => {
|
|
10
|
+
return (
|
|
11
|
+
<Dialog>
|
|
12
|
+
<DialogTrigger asChild>
|
|
13
|
+
{trigger}
|
|
14
|
+
</DialogTrigger>
|
|
15
|
+
<DialogContent>
|
|
16
|
+
<SelectNewItem>
|
|
17
|
+
{children}
|
|
18
|
+
<DialogFooter>
|
|
19
|
+
<DialogClose asChild>
|
|
20
|
+
<Button variant="outline">{dict.select.cancelNew}</Button>
|
|
21
|
+
</DialogClose>
|
|
22
|
+
<DialogClose asChild>
|
|
23
|
+
<SelectItemTrigger>
|
|
24
|
+
<Button>{dict.select.confirmNew}</Button>
|
|
25
|
+
</SelectItemTrigger>
|
|
26
|
+
</DialogClose>
|
|
27
|
+
</DialogFooter>
|
|
28
|
+
|
|
29
|
+
</SelectNewItem>
|
|
30
|
+
</DialogContent>
|
|
31
|
+
</Dialog>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { Input } from '../ui/input'
|
|
3
|
+
import { DataViewHasFilterType, DataViewQueryFilterName, DataViewTextFilterInput } from '@contember/react-dataview'
|
|
4
|
+
import { dict } from '../dict'
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export const SelectDefaultFilter = () => (
|
|
8
|
+
<DataViewHasFilterType name={DataViewQueryFilterName}>
|
|
9
|
+
<DataViewTextFilterInput name={DataViewQueryFilterName}>
|
|
10
|
+
<Input placeholder={dict.select.search} className={'w-full'} autoFocus inputSize={'sm'} />
|
|
11
|
+
</DataViewTextFilterInput>
|
|
12
|
+
</DataViewHasFilterType>
|
|
13
|
+
)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useCallback } from 'react'
|
|
2
|
+
import { DataViewHighlightEvent } from '@contember/react-dataview'
|
|
3
|
+
|
|
4
|
+
export const useOnHighlight = () => {
|
|
5
|
+
return useCallback((event: DataViewHighlightEvent) => {
|
|
6
|
+
const scrollArea = event.element.closest('[data-radix-scroll-area-viewport]')
|
|
7
|
+
if (scrollArea) {
|
|
8
|
+
let scrollTo = event.element.offsetTop - scrollArea.clientHeight / 2 + event.element.clientHeight / 2
|
|
9
|
+
scrollArea.scrollTo({
|
|
10
|
+
// to center
|
|
11
|
+
top: scrollTo,
|
|
12
|
+
behavior: 'smooth',
|
|
13
|
+
})
|
|
14
|
+
}
|
|
15
|
+
}, [])
|
|
16
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { ReactNode } from 'react'
|
|
3
|
+
import { ScrollArea } from '../ui/scroll-area'
|
|
4
|
+
import { DataGridOverlayLoader } from '../datagrid'
|
|
5
|
+
import { SelectPagination } from './pagination'
|
|
6
|
+
import { Loader } from '../ui/loader'
|
|
7
|
+
import { DataViewEachRow, DataViewHighlightRow, DataViewKeyboardEventHandler, DataViewLoaderState } from '@contember/react-dataview'
|
|
8
|
+
import { useOnHighlight } from './highlight'
|
|
9
|
+
import { Component } from '@contember/interface'
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
export type SelectListProps =
|
|
13
|
+
& {
|
|
14
|
+
children: ReactNode
|
|
15
|
+
filterToolbar?: ReactNode
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const SelectListInner = Component(({ children, filterToolbar }: SelectListProps) => {
|
|
19
|
+
return (
|
|
20
|
+
<DataViewKeyboardEventHandler>
|
|
21
|
+
<div className={'flex flex-col gap-4 group-data-[side="top"]:flex-col-reverse'}>
|
|
22
|
+
{filterToolbar}
|
|
23
|
+
<ScrollArea className={'max-h-96'}>
|
|
24
|
+
<div className={'flex flex-col gap-1'}>
|
|
25
|
+
<DataViewLoaderState refreshing>
|
|
26
|
+
<DataGridOverlayLoader />
|
|
27
|
+
</DataViewLoaderState>
|
|
28
|
+
<DataViewLoaderState refreshing loaded>
|
|
29
|
+
<DataViewEachRow>
|
|
30
|
+
<DataViewHighlightRow onHighlight={useOnHighlight()}>
|
|
31
|
+
{children}
|
|
32
|
+
</DataViewHighlightRow>
|
|
33
|
+
</DataViewEachRow>
|
|
34
|
+
<SelectPagination />
|
|
35
|
+
</DataViewLoaderState>
|
|
36
|
+
</div>
|
|
37
|
+
</ScrollArea>
|
|
38
|
+
<DataViewLoaderState initial>
|
|
39
|
+
<Loader position={'static'} size={'sm'} />
|
|
40
|
+
</DataViewLoaderState>
|
|
41
|
+
</div>
|
|
42
|
+
</DataViewKeyboardEventHandler>
|
|
43
|
+
)
|
|
44
|
+
}, ({ children, filterToolbar }) => {
|
|
45
|
+
return <>
|
|
46
|
+
{filterToolbar}
|
|
47
|
+
{children}
|
|
48
|
+
</>
|
|
49
|
+
})
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { ReactNode } from 'react'
|
|
3
|
+
import {
|
|
4
|
+
MultiSelectItemContentUI,
|
|
5
|
+
MultiSelectItemRemoveButtonUI,
|
|
6
|
+
MultiSelectItemUI,
|
|
7
|
+
SelectCreateNewTrigger,
|
|
8
|
+
SelectDefaultPlaceholderUI,
|
|
9
|
+
SelectInputActionsUI,
|
|
10
|
+
SelectInputUI,
|
|
11
|
+
SelectInputWrapperUI,
|
|
12
|
+
SelectListItemUI,
|
|
13
|
+
SelectPopoverContent,
|
|
14
|
+
} from './ui'
|
|
15
|
+
import { ChevronDownIcon } from 'lucide-react'
|
|
16
|
+
import { Popover, PopoverTrigger } from '../ui/popover'
|
|
17
|
+
import { Component, SugaredQualifiedEntityList, SugaredRelativeEntityList } from '@contember/interface'
|
|
18
|
+
import { SelectDefaultFilter } from './filter'
|
|
19
|
+
import { SelectListInner } from './list'
|
|
20
|
+
import { MultiSelect, SelectDataView, SelectEachValue, SelectItemTrigger, SelectOption, SelectPlaceholder } from '@contember/react-select'
|
|
21
|
+
import { CreateEntityDialog } from './create-new'
|
|
22
|
+
import { DataViewSortingDirections, DataViewUnionFilterFields } from '@contember/react-dataview'
|
|
23
|
+
import { useFormFieldId } from '@contember/react-form'
|
|
24
|
+
|
|
25
|
+
export type MultiSelectInputProps =
|
|
26
|
+
& {
|
|
27
|
+
field: SugaredRelativeEntityList['field']
|
|
28
|
+
options?: SugaredQualifiedEntityList['entities']
|
|
29
|
+
children: ReactNode
|
|
30
|
+
placeholder?: ReactNode
|
|
31
|
+
createNewForm?: ReactNode
|
|
32
|
+
queryField?: DataViewUnionFilterFields
|
|
33
|
+
initialSorting?: DataViewSortingDirections
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const MultiSelectInput = Component<MultiSelectInputProps>(({ field, queryField, options, children, placeholder, createNewForm, initialSorting }) => {
|
|
37
|
+
const id = useFormFieldId()
|
|
38
|
+
return (
|
|
39
|
+
<MultiSelect field={field} options={options}>
|
|
40
|
+
<div className="flex gap-1 items-center">
|
|
41
|
+
<Popover>
|
|
42
|
+
<SelectInputWrapperUI>
|
|
43
|
+
<PopoverTrigger asChild>
|
|
44
|
+
<SelectInputUI id={id ? `${id}-input` : undefined}>
|
|
45
|
+
<SelectPlaceholder>
|
|
46
|
+
{placeholder ?? <SelectDefaultPlaceholderUI />}
|
|
47
|
+
</SelectPlaceholder>
|
|
48
|
+
|
|
49
|
+
<SelectEachValue>
|
|
50
|
+
<MultiSelectItemUI>
|
|
51
|
+
<MultiSelectItemContentUI>
|
|
52
|
+
{children}
|
|
53
|
+
</MultiSelectItemContentUI>
|
|
54
|
+
<SelectItemTrigger>
|
|
55
|
+
<MultiSelectItemRemoveButtonUI onClick={e => e.stopPropagation()} />
|
|
56
|
+
</SelectItemTrigger>
|
|
57
|
+
</MultiSelectItemUI>
|
|
58
|
+
</SelectEachValue>
|
|
59
|
+
|
|
60
|
+
<SelectInputActionsUI>
|
|
61
|
+
<ChevronDownIcon className={'w-4 h-4'} />
|
|
62
|
+
</SelectInputActionsUI>
|
|
63
|
+
</SelectInputUI>
|
|
64
|
+
</PopoverTrigger>
|
|
65
|
+
|
|
66
|
+
</SelectInputWrapperUI>
|
|
67
|
+
<SelectPopoverContent>
|
|
68
|
+
<SelectDataView initialSorting={initialSorting} queryField={queryField}>
|
|
69
|
+
<SelectListInner filterToolbar={<SelectDefaultFilter />}>
|
|
70
|
+
<SelectOption>
|
|
71
|
+
<SelectItemTrigger>
|
|
72
|
+
<SelectListItemUI>
|
|
73
|
+
{children}
|
|
74
|
+
</SelectListItemUI>
|
|
75
|
+
</SelectItemTrigger>
|
|
76
|
+
</SelectOption>
|
|
77
|
+
</SelectListInner>
|
|
78
|
+
</SelectDataView>
|
|
79
|
+
</SelectPopoverContent>
|
|
80
|
+
</Popover>
|
|
81
|
+
{createNewForm && (
|
|
82
|
+
<CreateEntityDialog trigger={<SelectCreateNewTrigger />}>
|
|
83
|
+
{createNewForm}
|
|
84
|
+
</CreateEntityDialog>
|
|
85
|
+
)}
|
|
86
|
+
</div>
|
|
87
|
+
</MultiSelect>
|
|
88
|
+
)
|
|
89
|
+
}, ({ field, options, children }) => {
|
|
90
|
+
return (
|
|
91
|
+
<MultiSelect field={field} options={options}>
|
|
92
|
+
{children}
|
|
93
|
+
</MultiSelect>
|
|
94
|
+
)
|
|
95
|
+
})
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { MouseEventHandler } from 'react'
|
|
3
|
+
import { ChevronLeftIcon, ChevronRightIcon } from 'lucide-react'
|
|
4
|
+
import { DataViewChangePageTrigger, useDataViewPagingInfo } from '@contember/react-dataview'
|
|
5
|
+
import { Button } from '../ui/button'
|
|
6
|
+
import { dict } from '../dict'
|
|
7
|
+
|
|
8
|
+
export const SelectPagination = () => {
|
|
9
|
+
const scrollToTop: MouseEventHandler = e => {
|
|
10
|
+
const el = (e.target as HTMLElement).closest('[data-radix-scroll-area-viewport]')
|
|
11
|
+
if (el) {
|
|
12
|
+
requestAnimationFrame(() => {
|
|
13
|
+
el.scrollTo({ top: 0, behavior: 'smooth' })
|
|
14
|
+
})
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const pageInfo = useDataViewPagingInfo()
|
|
18
|
+
if ((pageInfo.pagesCount ?? 1) <= 1) {
|
|
19
|
+
return null
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<div className="flex gap-6 lg:gap-8 justify-center items-center">
|
|
24
|
+
<div className={'flex gap-1'}>
|
|
25
|
+
<DataViewChangePageTrigger page="previous">
|
|
26
|
+
<Button
|
|
27
|
+
size={'xs'}
|
|
28
|
+
variant="outline"
|
|
29
|
+
onClick={scrollToTop}
|
|
30
|
+
>
|
|
31
|
+
<span className="sr-only">{dict.select.paginationPreviousPage}</span>
|
|
32
|
+
<ChevronLeftIcon className="h-3 w-3"/>
|
|
33
|
+
</Button>
|
|
34
|
+
</DataViewChangePageTrigger>
|
|
35
|
+
<DataViewChangePageTrigger page="next">
|
|
36
|
+
<Button
|
|
37
|
+
size={'xs'}
|
|
38
|
+
variant="outline"
|
|
39
|
+
onClick={scrollToTop}
|
|
40
|
+
>
|
|
41
|
+
<span className="sr-only">{dict.select.paginationNextPage}</span>
|
|
42
|
+
<ChevronRightIcon className="h-3 w-3"/>
|
|
43
|
+
</Button>
|
|
44
|
+
</DataViewChangePageTrigger>
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { ReactNode } from 'react'
|
|
3
|
+
import { Popover, PopoverTrigger } from '../ui/popover'
|
|
4
|
+
import { Component, SugaredQualifiedEntityList } from '@contember/interface'
|
|
5
|
+
import { Button } from '../ui/button'
|
|
6
|
+
import { SugaredRelativeSingleEntity } from '@contember/interface'
|
|
7
|
+
import { ChevronDownIcon, XIcon } from 'lucide-react'
|
|
8
|
+
import { SelectCreateNewTrigger, SelectDefaultPlaceholderUI, SelectInputActionsUI, SelectInputUI, SelectInputWrapperUI, SelectListItemUI, SelectPopoverContent } from './ui'
|
|
9
|
+
import { SelectListInner } from './list'
|
|
10
|
+
import { Select, SelectDataView, SelectEachValue, SelectItemTrigger, SelectOption, SelectPlaceholder } from '@contember/react-select'
|
|
11
|
+
import { CreateEntityDialog } from './create-new'
|
|
12
|
+
import { SelectDefaultFilter } from './filter'
|
|
13
|
+
import { DataViewSortingDirections, DataViewUnionFilterFields } from '@contember/react-dataview'
|
|
14
|
+
import { useFormFieldId } from '@contember/react-form'
|
|
15
|
+
|
|
16
|
+
export type SelectInputProps =
|
|
17
|
+
& {
|
|
18
|
+
field: SugaredRelativeSingleEntity['field']
|
|
19
|
+
children: ReactNode
|
|
20
|
+
options?: SugaredQualifiedEntityList['entities']
|
|
21
|
+
placeholder?: ReactNode
|
|
22
|
+
createNewForm?: ReactNode
|
|
23
|
+
queryField?: DataViewUnionFilterFields
|
|
24
|
+
initialSorting?: DataViewSortingDirections
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
export const SelectInput = Component<SelectInputProps>(({ field, queryField, options, children, placeholder, createNewForm, initialSorting }) => {
|
|
29
|
+
const [open, setOpen] = React.useState(false)
|
|
30
|
+
const id = useFormFieldId()
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<Select field={field} onSelect={() => setOpen(false)} options={options}>
|
|
34
|
+
<div className="flex gap-1 items-center">
|
|
35
|
+
<Popover open={open} onOpenChange={setOpen}>
|
|
36
|
+
<SelectInputWrapperUI>
|
|
37
|
+
<PopoverTrigger asChild>
|
|
38
|
+
<SelectInputUI id={id ? `${id}-input` : undefined}>
|
|
39
|
+
<SelectPlaceholder>
|
|
40
|
+
{placeholder ?? <SelectDefaultPlaceholderUI />}
|
|
41
|
+
</SelectPlaceholder>
|
|
42
|
+
<SelectEachValue>
|
|
43
|
+
{children}
|
|
44
|
+
</SelectEachValue>
|
|
45
|
+
</SelectInputUI>
|
|
46
|
+
</PopoverTrigger>
|
|
47
|
+
<SelectInputActionsUI>
|
|
48
|
+
<SelectEachValue>
|
|
49
|
+
<SelectItemTrigger>
|
|
50
|
+
<Button size={'xs'} variant={'ghost'}>
|
|
51
|
+
<XIcon className={'w-4 h-4'} />
|
|
52
|
+
</Button>
|
|
53
|
+
</SelectItemTrigger>
|
|
54
|
+
</SelectEachValue>
|
|
55
|
+
<ChevronDownIcon className={'w-4 h-4'} />
|
|
56
|
+
</SelectInputActionsUI>
|
|
57
|
+
</SelectInputWrapperUI>
|
|
58
|
+
<SelectPopoverContent>
|
|
59
|
+
<SelectDataView initialSorting={initialSorting} queryField={queryField}>
|
|
60
|
+
<SelectListInner filterToolbar={<SelectDefaultFilter />}>
|
|
61
|
+
<SelectOption>
|
|
62
|
+
<SelectItemTrigger>
|
|
63
|
+
<SelectListItemUI>
|
|
64
|
+
{children}
|
|
65
|
+
</SelectListItemUI>
|
|
66
|
+
</SelectItemTrigger>
|
|
67
|
+
</SelectOption>
|
|
68
|
+
</SelectListInner>
|
|
69
|
+
</SelectDataView>
|
|
70
|
+
</SelectPopoverContent>
|
|
71
|
+
</Popover>
|
|
72
|
+
{createNewForm && (
|
|
73
|
+
<CreateEntityDialog trigger={<SelectCreateNewTrigger />}>
|
|
74
|
+
{createNewForm}
|
|
75
|
+
</CreateEntityDialog>
|
|
76
|
+
)}
|
|
77
|
+
</div>
|
|
78
|
+
</Select>
|
|
79
|
+
)
|
|
80
|
+
}, ({ field, children, options }) => {
|
|
81
|
+
return (
|
|
82
|
+
<Select field={field} options={options}>
|
|
83
|
+
{children}
|
|
84
|
+
</Select>
|
|
85
|
+
)
|
|
86
|
+
})
|
|
87
|
+
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { cn } from '../utils/cn'
|
|
2
|
+
import { DropIndicator } from '../ui/sortable'
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { ReactNode } from 'react'
|
|
5
|
+
import {
|
|
6
|
+
MultiSelectItemDragOverlayUI,
|
|
7
|
+
MultiSelectItemRemoveButtonUI,
|
|
8
|
+
MultiSelectItemUI,
|
|
9
|
+
MultiSelectSortableItemContentUI,
|
|
10
|
+
SelectCreateNewTrigger,
|
|
11
|
+
SelectDefaultPlaceholderUI,
|
|
12
|
+
SelectInputActionsUI,
|
|
13
|
+
SelectInputUI, SelectInputWrapperUI,
|
|
14
|
+
SelectListItemUI,
|
|
15
|
+
SelectPopoverContent,
|
|
16
|
+
} from './ui'
|
|
17
|
+
import { Popover, PopoverTrigger } from '../ui/popover'
|
|
18
|
+
import { ChevronDownIcon } from 'lucide-react'
|
|
19
|
+
import { SelectListInner } from './list'
|
|
20
|
+
import { RepeaterSortable, RepeaterSortableDragOverlay, RepeaterSortableDropIndicator, RepeaterSortableEachItem, RepeaterSortableItemActivator, RepeaterSortableItemNode } from '@contember/react-repeater-dnd-kit'
|
|
21
|
+
import { Component, HasOne, SugaredQualifiedEntityList, SugaredRelativeEntityList, SugaredRelativeSingleEntity, SugaredRelativeSingleField } from '@contember/interface'
|
|
22
|
+
import { SelectDataView, SelectItemTrigger, SelectOption, SelectPlaceholder, SortableMultiSelect } from '@contember/react-select'
|
|
23
|
+
import { CreateEntityDialog } from './create-new'
|
|
24
|
+
import { DataViewSortingDirections, DataViewUnionFilterFields } from '@contember/react-dataview'
|
|
25
|
+
import { SelectDefaultFilter } from './filter'
|
|
26
|
+
import { useFormFieldId } from '@contember/react-form'
|
|
27
|
+
|
|
28
|
+
const MultiSortableSelectDropIndicator = ({ position }: { position: 'before' | 'after' }) => (
|
|
29
|
+
<div className={cn('relative', position === 'before' ? '-translate-x-0.5' : 'translate-x-1.5')}>
|
|
30
|
+
<RepeaterSortableDropIndicator position={position}>
|
|
31
|
+
<DropIndicator placement={position === 'before' ? 'left' : 'right'} />
|
|
32
|
+
</RepeaterSortableDropIndicator>
|
|
33
|
+
</div>
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
export type SortableMultiSelectInputProps =
|
|
37
|
+
& {
|
|
38
|
+
field: SugaredRelativeEntityList['field']
|
|
39
|
+
sortableBy: SugaredRelativeSingleField['field']
|
|
40
|
+
connectAt: SugaredRelativeSingleEntity['field']
|
|
41
|
+
children: ReactNode
|
|
42
|
+
options?: SugaredQualifiedEntityList['entities']
|
|
43
|
+
placeholder?: ReactNode
|
|
44
|
+
createNewForm?: ReactNode
|
|
45
|
+
queryField?: DataViewUnionFilterFields
|
|
46
|
+
initialSorting?: DataViewSortingDirections
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const SortableMultiSelectInput = Component<SortableMultiSelectInputProps>(({ field, queryField, options, children, sortableBy, connectAt, placeholder, createNewForm, initialSorting }) => {
|
|
50
|
+
const id = useFormFieldId()
|
|
51
|
+
return (
|
|
52
|
+
<SortableMultiSelect field={field} sortableBy={sortableBy} connectAt={connectAt} options={options}>
|
|
53
|
+
<div className="flex gap-1 items-center">
|
|
54
|
+
<Popover>
|
|
55
|
+
<SelectInputWrapperUI>
|
|
56
|
+
<PopoverTrigger asChild>
|
|
57
|
+
<SelectInputUI id={id ? `${id}-input` : undefined}>
|
|
58
|
+
<SelectPlaceholder>
|
|
59
|
+
{placeholder ?? <SelectDefaultPlaceholderUI />}
|
|
60
|
+
</SelectPlaceholder>
|
|
61
|
+
|
|
62
|
+
<RepeaterSortable>
|
|
63
|
+
<RepeaterSortableEachItem>
|
|
64
|
+
<div className={'flex'}>
|
|
65
|
+
<MultiSortableSelectDropIndicator position={'before'} />
|
|
66
|
+
<RepeaterSortableItemNode>
|
|
67
|
+
<MultiSelectItemUI>
|
|
68
|
+
<HasOne field={connectAt}>
|
|
69
|
+
<RepeaterSortableItemActivator>
|
|
70
|
+
<MultiSelectSortableItemContentUI>
|
|
71
|
+
{children}
|
|
72
|
+
</MultiSelectSortableItemContentUI>
|
|
73
|
+
</RepeaterSortableItemActivator>
|
|
74
|
+
|
|
75
|
+
<SelectItemTrigger>
|
|
76
|
+
<MultiSelectItemRemoveButtonUI onClick={e => e.stopPropagation()} />
|
|
77
|
+
</SelectItemTrigger>
|
|
78
|
+
</HasOne>
|
|
79
|
+
</MultiSelectItemUI>
|
|
80
|
+
</RepeaterSortableItemNode>
|
|
81
|
+
<MultiSortableSelectDropIndicator position={'after'} />
|
|
82
|
+
</div>
|
|
83
|
+
</RepeaterSortableEachItem>
|
|
84
|
+
|
|
85
|
+
<RepeaterSortableDragOverlay>
|
|
86
|
+
<MultiSelectItemDragOverlayUI>
|
|
87
|
+
<HasOne field={connectAt}>
|
|
88
|
+
{children}
|
|
89
|
+
</HasOne>
|
|
90
|
+
</MultiSelectItemDragOverlayUI>
|
|
91
|
+
</RepeaterSortableDragOverlay>
|
|
92
|
+
</RepeaterSortable>
|
|
93
|
+
|
|
94
|
+
<SelectInputActionsUI>
|
|
95
|
+
<ChevronDownIcon className={'w-4 h-4'} />
|
|
96
|
+
</SelectInputActionsUI>
|
|
97
|
+
</SelectInputUI>
|
|
98
|
+
</PopoverTrigger>
|
|
99
|
+
</SelectInputWrapperUI>
|
|
100
|
+
|
|
101
|
+
<SelectPopoverContent>
|
|
102
|
+
<SelectDataView initialSorting={initialSorting} queryField={queryField}>
|
|
103
|
+
<SelectListInner filterToolbar={<SelectDefaultFilter />}>
|
|
104
|
+
<SelectOption>
|
|
105
|
+
<SelectItemTrigger>
|
|
106
|
+
<SelectListItemUI>
|
|
107
|
+
{children}
|
|
108
|
+
</SelectListItemUI>
|
|
109
|
+
</SelectItemTrigger>
|
|
110
|
+
</SelectOption>
|
|
111
|
+
</SelectListInner>
|
|
112
|
+
</SelectDataView>
|
|
113
|
+
</SelectPopoverContent>
|
|
114
|
+
</Popover>
|
|
115
|
+
{createNewForm && (
|
|
116
|
+
<CreateEntityDialog trigger={<SelectCreateNewTrigger />}>
|
|
117
|
+
{createNewForm}
|
|
118
|
+
</CreateEntityDialog>
|
|
119
|
+
)}
|
|
120
|
+
</div>
|
|
121
|
+
</SortableMultiSelect>
|
|
122
|
+
)
|
|
123
|
+
}, ({ children, field, sortableBy, connectAt, options }) => {
|
|
124
|
+
return (
|
|
125
|
+
<SortableMultiSelect field={field} sortableBy={sortableBy} connectAt={connectAt} options={options}>
|
|
126
|
+
{children}
|
|
127
|
+
</SortableMultiSelect>
|
|
128
|
+
)
|
|
129
|
+
})
|