@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,100 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { ReactNode } from 'react'
|
|
3
|
+
import {
|
|
4
|
+
DataViewNullFilterTrigger,
|
|
5
|
+
DataViewNumberFilter,
|
|
6
|
+
DataViewNumberFilterInput,
|
|
7
|
+
DataViewNumberFilterProps,
|
|
8
|
+
DataViewNumberFilterResetTrigger,
|
|
9
|
+
NumberRangeFilterArtifacts,
|
|
10
|
+
useDataViewFilter,
|
|
11
|
+
useDataViewFilterName,
|
|
12
|
+
} from '@contember/react-dataview'
|
|
13
|
+
import { Popover, PopoverContent, PopoverTrigger } from '../../ui/popover'
|
|
14
|
+
import { DataGridActiveFilterUI, DataGridFilterSelectTriggerUI, DataGridSingleFilterUI } from '../ui'
|
|
15
|
+
import { DataGridNullFilter } from './common'
|
|
16
|
+
import { Input } from '../../ui/input'
|
|
17
|
+
import { formatNumber } from '../../formatting'
|
|
18
|
+
import { dict } from '../../dict'
|
|
19
|
+
import { Component } from '@contember/interface'
|
|
20
|
+
import { DataGridFilterMobileHiding } from './mobile'
|
|
21
|
+
|
|
22
|
+
export type DataGridNumberFilterProps =
|
|
23
|
+
& Omit<DataViewNumberFilterProps, 'children'>
|
|
24
|
+
& {
|
|
25
|
+
label: ReactNode
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const DataGridNumberFilter = Component(({ label, ...props }: DataGridNumberFilterProps) => (
|
|
29
|
+
<DataViewNumberFilter {...props}>
|
|
30
|
+
<DataGridFilterMobileHiding>
|
|
31
|
+
<DataGridSingleFilterUI>
|
|
32
|
+
<DataGridNumberFilterSelect label={label} />
|
|
33
|
+
<DataGridNumberFilterList />
|
|
34
|
+
</DataGridSingleFilterUI>
|
|
35
|
+
</DataGridFilterMobileHiding>
|
|
36
|
+
</DataViewNumberFilter>
|
|
37
|
+
))
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
const DataGridNumberFilterRange = () => {
|
|
41
|
+
const [artifact] = useDataViewFilter<NumberRangeFilterArtifacts>(useDataViewFilterName())
|
|
42
|
+
if (!artifact) {
|
|
43
|
+
return null
|
|
44
|
+
}
|
|
45
|
+
if (artifact.from !== undefined && artifact.to !== undefined) {
|
|
46
|
+
return `${formatNumber(artifact.from)} – ${formatNumber(artifact.to)}`
|
|
47
|
+
}
|
|
48
|
+
if (artifact.from !== undefined) {
|
|
49
|
+
return `≥ ${formatNumber(artifact.from)}`
|
|
50
|
+
}
|
|
51
|
+
if (artifact.to !== undefined) {
|
|
52
|
+
return `≤ ${formatNumber(artifact.to)}`
|
|
53
|
+
}
|
|
54
|
+
return null
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
export const DataGridNumberFilterList = () => (
|
|
59
|
+
<>
|
|
60
|
+
<DataViewNumberFilterResetTrigger>
|
|
61
|
+
<DataGridActiveFilterUI>
|
|
62
|
+
<DataGridNumberFilterRange />
|
|
63
|
+
</DataGridActiveFilterUI>
|
|
64
|
+
</DataViewNumberFilterResetTrigger>
|
|
65
|
+
|
|
66
|
+
<DataViewNullFilterTrigger action={'unset'}>
|
|
67
|
+
<DataGridActiveFilterUI>
|
|
68
|
+
<span className={'italic'}>{dict.datagrid.na}</span>
|
|
69
|
+
</DataGridActiveFilterUI>
|
|
70
|
+
</DataViewNullFilterTrigger>
|
|
71
|
+
</>
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
export const DataGridNumberFilterSelect = ({ label }: {
|
|
76
|
+
label?: ReactNode
|
|
77
|
+
}) => (
|
|
78
|
+
<Popover>
|
|
79
|
+
<PopoverTrigger asChild>
|
|
80
|
+
<DataGridFilterSelectTriggerUI>{label}</DataGridFilterSelectTriggerUI>
|
|
81
|
+
</PopoverTrigger>
|
|
82
|
+
<PopoverContent>
|
|
83
|
+
<div className={'relative flex flex-col gap-4'}>
|
|
84
|
+
<div className={'flex justify-center items-center'}>
|
|
85
|
+
<DataViewNumberFilterInput type={'from'}>
|
|
86
|
+
<Input className={''} inputSize={'sm'} placeholder={dict.datagrid.numberFrom} type={'number'} />
|
|
87
|
+
</DataViewNumberFilterInput>
|
|
88
|
+
<span className={'mx-4 font-bold '}>
|
|
89
|
+
–
|
|
90
|
+
</span>
|
|
91
|
+
<DataViewNumberFilterInput type={'to'}>
|
|
92
|
+
<Input className={''} inputSize={'sm'} placeholder={dict.datagrid.numberTo} type={'number'} />
|
|
93
|
+
</DataViewNumberFilterInput>
|
|
94
|
+
</div>
|
|
95
|
+
|
|
96
|
+
<DataGridNullFilter />
|
|
97
|
+
</div>
|
|
98
|
+
</PopoverContent>
|
|
99
|
+
</Popover>
|
|
100
|
+
)
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { forwardRef, ReactNode, useCallback } from 'react'
|
|
3
|
+
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../../ui/tooltip'
|
|
4
|
+
import {
|
|
5
|
+
DataViewHasManyFilter,
|
|
6
|
+
DataViewHasManyFilterProps,
|
|
7
|
+
DataViewHasOneFilter,
|
|
8
|
+
DataViewHasOneFilterProps,
|
|
9
|
+
DataViewNullFilterTrigger,
|
|
10
|
+
DataViewRelationFilterList,
|
|
11
|
+
DataViewRelationFilterOptions,
|
|
12
|
+
DataViewRelationFilterTrigger, DataViewUnionFilterFields,
|
|
13
|
+
useDataViewFilterName,
|
|
14
|
+
useDataViewRelationFilterFactory,
|
|
15
|
+
UseDataViewRelationFilterResult,
|
|
16
|
+
} from '@contember/react-dataview'
|
|
17
|
+
import { Component, EntityId, useEntity } from '@contember/interface'
|
|
18
|
+
import { Popover, PopoverTrigger } from '../../ui/popover'
|
|
19
|
+
import { DataGridActiveFilterUI, DataGridExcludeActionButtonUI, DataGridFilterActionButtonUI, DataGridFilterSelectItemUI, DataGridFilterSelectTriggerUI, DataGridSingleFilterUI } from '../ui'
|
|
20
|
+
import { DataGridNullFilter } from './common'
|
|
21
|
+
import { SelectDefaultFilter, SelectListInner, SelectPopoverContent } from '../../select'
|
|
22
|
+
import { dict } from '../../dict'
|
|
23
|
+
import { DataGridFilterMobileHiding } from './mobile'
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
type DataGridRelationFilterInnerProps = {
|
|
27
|
+
children: ReactNode
|
|
28
|
+
label: ReactNode
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type DataGridHasOneFilterProps =
|
|
32
|
+
& DataViewHasOneFilterProps
|
|
33
|
+
& DataGridRelationFilterInnerProps
|
|
34
|
+
|
|
35
|
+
export const DataGridHasOneFilter = Component(({ label, children, ...props }: DataGridHasOneFilterProps) => (
|
|
36
|
+
<DataViewHasOneFilter {...props}>
|
|
37
|
+
<DataGridFilterMobileHiding>
|
|
38
|
+
<DataGridRelationFilterInner label={label}>
|
|
39
|
+
{children}
|
|
40
|
+
</DataGridRelationFilterInner>
|
|
41
|
+
</DataGridFilterMobileHiding>
|
|
42
|
+
</DataViewHasOneFilter>
|
|
43
|
+
))
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
export type DataGridHasManyFilterProps =
|
|
47
|
+
& DataViewHasManyFilterProps
|
|
48
|
+
& DataGridRelationFilterInnerProps
|
|
49
|
+
|
|
50
|
+
export const DataGridHasManyFilter = Component(({ label, children, ...props }: DataGridHasManyFilterProps) => (
|
|
51
|
+
<DataViewHasManyFilter {...props} >
|
|
52
|
+
<DataGridFilterMobileHiding>
|
|
53
|
+
<DataGridRelationFilterInner label={label}>
|
|
54
|
+
{children}
|
|
55
|
+
</DataGridRelationFilterInner>
|
|
56
|
+
</DataGridFilterMobileHiding>
|
|
57
|
+
</DataViewHasManyFilter>
|
|
58
|
+
))
|
|
59
|
+
|
|
60
|
+
const DataGridRelationFilterInner = Component(({ children, label }: DataGridRelationFilterInnerProps) => {
|
|
61
|
+
return (
|
|
62
|
+
<DataGridSingleFilterUI>
|
|
63
|
+
<DataGridRelationFilterSelect label={label}>
|
|
64
|
+
{children}
|
|
65
|
+
</DataGridRelationFilterSelect>
|
|
66
|
+
<DataGridRelationFilteredItemsList>
|
|
67
|
+
{children}
|
|
68
|
+
</DataGridRelationFilteredItemsList>
|
|
69
|
+
</DataGridSingleFilterUI>
|
|
70
|
+
)
|
|
71
|
+
}, () => null)
|
|
72
|
+
|
|
73
|
+
export const DataGridHasOneTooltip = Component(({ children, actions, ...props }: DataViewHasOneFilterProps & { children: ReactNode, actions?: ReactNode }) => (
|
|
74
|
+
<DataViewHasOneFilter {...props}>
|
|
75
|
+
<DataGridRelationFieldTooltipInner actions={actions}>
|
|
76
|
+
{children}
|
|
77
|
+
</DataGridRelationFieldTooltipInner>
|
|
78
|
+
</DataViewHasOneFilter>
|
|
79
|
+
))
|
|
80
|
+
|
|
81
|
+
export const DataGridHasManyTooltip = Component<DataViewHasManyFilterProps & { children: ReactNode, actions?: ReactNode }>(({ children, actions, ...props }, env) => {
|
|
82
|
+
return (
|
|
83
|
+
<DataViewHasManyFilter {...props}>
|
|
84
|
+
<DataGridRelationFieldTooltipInner actions={actions}>
|
|
85
|
+
{children}
|
|
86
|
+
</DataGridRelationFieldTooltipInner>
|
|
87
|
+
</DataViewHasManyFilter>
|
|
88
|
+
)
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
const DataGridRelationFieldTooltipInner = Component(({ children, actions }: { children: ReactNode, actions?: ReactNode }) => (
|
|
92
|
+
<TooltipProvider>
|
|
93
|
+
<Tooltip>
|
|
94
|
+
<TooltipTrigger asChild>
|
|
95
|
+
{children}
|
|
96
|
+
</TooltipTrigger>
|
|
97
|
+
<TooltipContent variant={'blurred'}>
|
|
98
|
+
<div className={'flex gap-1'}>
|
|
99
|
+
<DataViewRelationFilterTrigger action={'toggleInclude'}>
|
|
100
|
+
<DataGridFilterActionButtonUI />
|
|
101
|
+
</DataViewRelationFilterTrigger>
|
|
102
|
+
<DataViewRelationFilterTrigger action={'toggleExclude'}>
|
|
103
|
+
<DataGridExcludeActionButtonUI />
|
|
104
|
+
</DataViewRelationFilterTrigger>
|
|
105
|
+
{actions}
|
|
106
|
+
</div>
|
|
107
|
+
</TooltipContent>
|
|
108
|
+
</Tooltip>
|
|
109
|
+
</TooltipProvider>
|
|
110
|
+
))
|
|
111
|
+
|
|
112
|
+
const DataGridRelationFilteredItemsList = ({ children }: {
|
|
113
|
+
children: ReactNode
|
|
114
|
+
}) => (
|
|
115
|
+
<>
|
|
116
|
+
<DataViewRelationFilterList>
|
|
117
|
+
<DataViewRelationFilterTrigger action={'unset'}>
|
|
118
|
+
<DataGridActiveFilterUI>
|
|
119
|
+
{children}
|
|
120
|
+
</DataGridActiveFilterUI>
|
|
121
|
+
</DataViewRelationFilterTrigger>
|
|
122
|
+
</DataViewRelationFilterList>
|
|
123
|
+
<DataViewNullFilterTrigger action={'unset'}>
|
|
124
|
+
<DataGridActiveFilterUI>
|
|
125
|
+
<span className={'italic'}>{dict.datagrid.na}</span>
|
|
126
|
+
</DataGridActiveFilterUI>
|
|
127
|
+
</DataViewNullFilterTrigger>
|
|
128
|
+
</>
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
const DataGridRelationFilterSelectItem = forwardRef<HTMLButtonElement, {
|
|
132
|
+
children: ReactNode
|
|
133
|
+
filterFactory: (value: EntityId) => UseDataViewRelationFilterResult
|
|
134
|
+
}>(({ children, filterFactory, ...props }, ref) => {
|
|
135
|
+
const entity = useEntity()
|
|
136
|
+
const [current, setFilter] = filterFactory(entity.id)
|
|
137
|
+
|
|
138
|
+
const include = useCallback(() => setFilter('toggleInclude'), [setFilter])
|
|
139
|
+
const exclude = useCallback(() => setFilter('toggleExclude'), [setFilter])
|
|
140
|
+
|
|
141
|
+
const isIncluded = current === 'include'
|
|
142
|
+
const isExcluded = current == 'exclude'
|
|
143
|
+
|
|
144
|
+
return (
|
|
145
|
+
<DataGridFilterSelectItemUI ref={ref} onExclude={exclude} onInclude={include} isExcluded={isExcluded} isIncluded={isIncluded} {...props}>
|
|
146
|
+
{children}
|
|
147
|
+
</DataGridFilterSelectItemUI>
|
|
148
|
+
)
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
const DataGridRelationFilterSelect = ({ children, queryField, label }: {
|
|
153
|
+
queryField?: DataViewUnionFilterFields
|
|
154
|
+
children: ReactNode
|
|
155
|
+
label?: ReactNode
|
|
156
|
+
}) => {
|
|
157
|
+
const filterFactory = useDataViewRelationFilterFactory(useDataViewFilterName())
|
|
158
|
+
return (
|
|
159
|
+
<Popover>
|
|
160
|
+
<PopoverTrigger asChild>
|
|
161
|
+
<DataGridFilterSelectTriggerUI>
|
|
162
|
+
{label}
|
|
163
|
+
</DataGridFilterSelectTriggerUI>
|
|
164
|
+
</PopoverTrigger>
|
|
165
|
+
<SelectPopoverContent>
|
|
166
|
+
<DataViewRelationFilterOptions queryField={queryField}>
|
|
167
|
+
<SelectListInner filterToolbar={<SelectDefaultFilter />}>
|
|
168
|
+
<DataGridRelationFilterSelectItem filterFactory={filterFactory}>
|
|
169
|
+
{children}
|
|
170
|
+
</DataGridRelationFilterSelectItem>
|
|
171
|
+
</SelectListInner>
|
|
172
|
+
</DataViewRelationFilterOptions>
|
|
173
|
+
<div>
|
|
174
|
+
<DataGridNullFilter />
|
|
175
|
+
</div>
|
|
176
|
+
</SelectPopoverContent>
|
|
177
|
+
</Popover>
|
|
178
|
+
)
|
|
179
|
+
}
|
|
180
|
+
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { InputBare, InputLike } from '../../ui/input'
|
|
2
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '../../ui/dropdown'
|
|
3
|
+
import { Button } from '../../ui/button'
|
|
4
|
+
import { MoreHorizontalIcon, XIcon } from 'lucide-react'
|
|
5
|
+
import * as React from 'react'
|
|
6
|
+
import {
|
|
7
|
+
DataViewFilterScope,
|
|
8
|
+
DataViewHasFilterType,
|
|
9
|
+
DataViewNullFilterTrigger,
|
|
10
|
+
DataViewQueryFilterName,
|
|
11
|
+
DataViewTextFilter,
|
|
12
|
+
DataViewTextFilterInput,
|
|
13
|
+
DataViewTextFilterMatchModeLabel,
|
|
14
|
+
DataViewTextFilterMatchModeTrigger,
|
|
15
|
+
DataViewTextFilterProps,
|
|
16
|
+
DataViewTextFilterResetTrigger,
|
|
17
|
+
DataViewUnionTextFilter,
|
|
18
|
+
DataViewUnionTextFilterProps,
|
|
19
|
+
TextFilterArtifactsMatchMode,
|
|
20
|
+
} from '@contember/react-dataview'
|
|
21
|
+
import { Popover, PopoverContent, PopoverTrigger } from '../../ui/popover'
|
|
22
|
+
import { DataGridActiveFilterUI } from '../ui'
|
|
23
|
+
import { DataGridNullFilter } from './common'
|
|
24
|
+
import { dict } from '../../dict'
|
|
25
|
+
import { Component } from '@contember/interface'
|
|
26
|
+
import { DataGridFilterMobileHiding } from './mobile'
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
export type DataGridTextFilterProps =
|
|
30
|
+
& Omit<DataViewTextFilterProps, 'children'>
|
|
31
|
+
& {
|
|
32
|
+
label?: React.ReactNode
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const DataGridTextFilter = Component(({ label, ...props }: DataGridTextFilterProps) => (
|
|
36
|
+
<DataViewTextFilter {...props}>
|
|
37
|
+
<DataGridFilterMobileHiding>
|
|
38
|
+
<DataGridTextFilterInner label={label} />
|
|
39
|
+
</DataGridFilterMobileHiding>
|
|
40
|
+
</DataViewTextFilter>
|
|
41
|
+
))
|
|
42
|
+
|
|
43
|
+
export type DataGridUnionTextFilterProps =
|
|
44
|
+
& Omit<DataViewUnionTextFilterProps, 'children'>
|
|
45
|
+
& {
|
|
46
|
+
label?: React.ReactNode
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const DataGridUnionTextFilter = Component(({ label, ...props }: DataGridUnionTextFilterProps) => (
|
|
50
|
+
<DataViewUnionTextFilter {...props}>
|
|
51
|
+
<DataGridFilterMobileHiding>
|
|
52
|
+
<DataGridTextFilterInner label={label} />
|
|
53
|
+
</DataGridFilterMobileHiding>
|
|
54
|
+
</DataViewUnionTextFilter>
|
|
55
|
+
))
|
|
56
|
+
|
|
57
|
+
export const DataGridQueryFilter = Component(({ label }: {
|
|
58
|
+
label?: React.ReactNode
|
|
59
|
+
}) => (
|
|
60
|
+
<DataViewHasFilterType name={DataViewQueryFilterName}>
|
|
61
|
+
<DataViewFilterScope name={DataViewQueryFilterName}>
|
|
62
|
+
<DataGridFilterMobileHiding>
|
|
63
|
+
<DataGridTextFilterInner label={label} />
|
|
64
|
+
</DataGridFilterMobileHiding>
|
|
65
|
+
</DataViewFilterScope>
|
|
66
|
+
</DataViewHasFilterType>
|
|
67
|
+
))
|
|
68
|
+
|
|
69
|
+
export const DataGridTextFilterInner = ({ label }: {
|
|
70
|
+
label?: React.ReactNode
|
|
71
|
+
}) => {
|
|
72
|
+
return (
|
|
73
|
+
<>
|
|
74
|
+
<InputLike className={'p-1 relative basis-1/4 min-w-56'}>
|
|
75
|
+
<DropdownMenu>
|
|
76
|
+
<DropdownMenuTrigger asChild>
|
|
77
|
+
<Button size={'sm'} variant={'secondary'} className={'px-3'}>
|
|
78
|
+
{label} <DataViewTextFilterMatchModeLabel render={dict.datagrid.textMatchMode} />
|
|
79
|
+
</Button>
|
|
80
|
+
</DropdownMenuTrigger>
|
|
81
|
+
<DropdownMenuContent className="w-[160px]">
|
|
82
|
+
{Object.entries(dict.datagrid.textMatchMode).map(([mode, label]) => (
|
|
83
|
+
<DataViewTextFilterMatchModeTrigger mode={mode as TextFilterArtifactsMatchMode} key={mode}>
|
|
84
|
+
<DropdownMenuItem className={'data-[active]:font-bold'}>
|
|
85
|
+
{label}
|
|
86
|
+
</DropdownMenuItem>
|
|
87
|
+
</DataViewTextFilterMatchModeTrigger>
|
|
88
|
+
))}
|
|
89
|
+
</DropdownMenuContent>
|
|
90
|
+
</DropdownMenu>
|
|
91
|
+
|
|
92
|
+
<DataViewTextFilterInput>
|
|
93
|
+
<InputBare placeholder={dict.datagrid.textPlaceholder} className={'w-full ml-2'} />
|
|
94
|
+
</DataViewTextFilterInput>
|
|
95
|
+
|
|
96
|
+
<div className={'ml-auto flex gap-1 items-center'}>
|
|
97
|
+
<DataViewNullFilterTrigger action={'unset'}>
|
|
98
|
+
<DataGridActiveFilterUI className={'ml-auto'}>
|
|
99
|
+
<span className={'italic'}>{dict.datagrid.na}</span>
|
|
100
|
+
</DataGridActiveFilterUI>
|
|
101
|
+
</DataViewNullFilterTrigger>
|
|
102
|
+
<Popover>
|
|
103
|
+
<PopoverTrigger asChild>
|
|
104
|
+
<Button variant={'ghost'} size={'sm'} className={'p-0.5 h-5 w-5'}>
|
|
105
|
+
<MoreHorizontalIcon />
|
|
106
|
+
</Button>
|
|
107
|
+
</PopoverTrigger>
|
|
108
|
+
<PopoverContent>
|
|
109
|
+
<DataViewTextFilterResetTrigger>
|
|
110
|
+
<Button size={'sm'} className={'w-full text-left justify-start gap-1'} variant={'ghost'}>
|
|
111
|
+
<XIcon className={'w-3 h-3'} /> {dict.datagrid.textReset}
|
|
112
|
+
</Button>
|
|
113
|
+
</DataViewTextFilterResetTrigger>
|
|
114
|
+
<DataGridNullFilter />
|
|
115
|
+
</PopoverContent>
|
|
116
|
+
</Popover>
|
|
117
|
+
</div>
|
|
118
|
+
</InputLike>
|
|
119
|
+
</>
|
|
120
|
+
)
|
|
121
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { DataView, DataViewEmpty, DataViewLoaderState, DataViewNonEmpty, DataViewProps } from '@contember/react-dataview'
|
|
2
|
+
import * as React from 'react'
|
|
3
|
+
import { Fragment, ReactNode } from 'react'
|
|
4
|
+
import { DataGridNoResults } from './empty'
|
|
5
|
+
import { DataGridInitialLoader, DataGridOverlayLoader } from './loader'
|
|
6
|
+
import { Component } from '@contember/interface'
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export type DataGridProps =
|
|
10
|
+
& Omit<DataViewProps, 'children' | 'filterTypes'>
|
|
11
|
+
& {
|
|
12
|
+
children: ReactNode
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const dataGridDefaultStorages: Partial<DataGridProps> = {
|
|
16
|
+
filteringStateStorage: 'session',
|
|
17
|
+
sortingStateStorage: 'session',
|
|
18
|
+
currentPageStateStorage: 'session',
|
|
19
|
+
selectionStateStorage: 'local',
|
|
20
|
+
pagingSettingsStorage: 'local',
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const DataGrid = Component(({ children, ...props }: DataGridProps) => {
|
|
24
|
+
return (
|
|
25
|
+
<DataView
|
|
26
|
+
{...dataGridDefaultStorages}
|
|
27
|
+
{...props}
|
|
28
|
+
>
|
|
29
|
+
{children}
|
|
30
|
+
</DataView>
|
|
31
|
+
)
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
export interface DataViewBodyProps {
|
|
35
|
+
children: ReactNode
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const DataGridLoader = ({ children }: DataViewBodyProps) => (
|
|
39
|
+
<>
|
|
40
|
+
<DataViewLoaderState refreshing loaded>
|
|
41
|
+
<div className="relative">
|
|
42
|
+
<DataViewLoaderState refreshing>
|
|
43
|
+
<DataGridOverlayLoader />
|
|
44
|
+
</DataViewLoaderState>
|
|
45
|
+
|
|
46
|
+
<DataViewNonEmpty>
|
|
47
|
+
{children}
|
|
48
|
+
</DataViewNonEmpty>
|
|
49
|
+
|
|
50
|
+
<DataViewEmpty>
|
|
51
|
+
<DataGridNoResults />
|
|
52
|
+
</DataViewEmpty>
|
|
53
|
+
</div>
|
|
54
|
+
</DataViewLoaderState>
|
|
55
|
+
<DataViewLoaderState initial>
|
|
56
|
+
<DataGridInitialLoader />
|
|
57
|
+
</DataViewLoaderState>
|
|
58
|
+
</>
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from './filters'
|
|
2
|
+
|
|
3
|
+
export * from './cells'
|
|
4
|
+
export * from './column-header'
|
|
5
|
+
export * from './columns'
|
|
6
|
+
export * from './elements'
|
|
7
|
+
export * from './empty'
|
|
8
|
+
export * from './export'
|
|
9
|
+
export * from './grid'
|
|
10
|
+
export * from './layout-switcher'
|
|
11
|
+
export * from './loader'
|
|
12
|
+
export * from './pagination'
|
|
13
|
+
export * from './ui'
|
|
14
|
+
export * from './tiles'
|
|
15
|
+
export * from './toolbar'
|
|
16
|
+
export * from './table'
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { DataViewLayoutTrigger, useDataViewSelectionState } from '@contember/react-dataview'
|
|
2
|
+
import { Button } from '../ui/button'
|
|
3
|
+
import * as React from 'react'
|
|
4
|
+
import { dict } from '../dict'
|
|
5
|
+
import { uic } from '../utils/uic'
|
|
6
|
+
|
|
7
|
+
const LayoutSwitchButton = uic(Button, {
|
|
8
|
+
baseClass: 'data-[active]:text-blue-600 data-[active]:bg-gray-50 data-[active]:shadow-inner gap-2 flex-1',
|
|
9
|
+
defaultProps: {
|
|
10
|
+
variant: 'outline',
|
|
11
|
+
size: 'sm',
|
|
12
|
+
},
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
export const DataGridLayoutSwitcher = () => {
|
|
16
|
+
const layouts = useDataViewSelectionState().layouts
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<div>
|
|
20
|
+
<p className="text-gray-400 text-xs font-semibold mb-1">{dict.datagrid.layout}</p>
|
|
21
|
+
<div className={'flex gap-1'}>
|
|
22
|
+
{layouts.map(it => (
|
|
23
|
+
<DataViewLayoutTrigger name={it.name} key={it.name}>
|
|
24
|
+
<LayoutSwitchButton>
|
|
25
|
+
{it.label}
|
|
26
|
+
</LayoutSwitchButton>
|
|
27
|
+
</DataViewLayoutTrigger>
|
|
28
|
+
))}
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronsLeftIcon, ChevronsRightIcon, Loader2Icon } from 'lucide-react'
|
|
2
|
+
|
|
3
|
+
import { Button } from '../ui/button'
|
|
4
|
+
import { DataViewChangePageTrigger, DataViewPagingStateView, DataViewSetItemsPerPageTrigger } from '@contember/react-dataview'
|
|
5
|
+
import { DropdownMenu } from '@radix-ui/react-dropdown-menu'
|
|
6
|
+
import { DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '../ui/dropdown'
|
|
7
|
+
import { dictFormat } from '../dict'
|
|
8
|
+
import { dict } from '../dict'
|
|
9
|
+
|
|
10
|
+
export const DataGridPagination = () => (
|
|
11
|
+
<div className="flex gap-6 lg:gap-8 justify-between mt-4">
|
|
12
|
+
<div className="">
|
|
13
|
+
<DataViewPagingStateView render={it => <>
|
|
14
|
+
<div className={'flex gap-2 items-center'}>
|
|
15
|
+
<div className={'font-normal text-sm text-gray-500'}>
|
|
16
|
+
{it.totalCount === undefined ? <Loader2Icon className="animate-spin h-3 w-3 inline-block" />
|
|
17
|
+
: dictFormat(dict.datagrid.pageRowsCount, {
|
|
18
|
+
totalCount: it.totalCount.toString(),
|
|
19
|
+
})
|
|
20
|
+
}
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
23
|
+
</>} />
|
|
24
|
+
</div>
|
|
25
|
+
<div className="flex items-center space-x-2">
|
|
26
|
+
<DataViewPagingStateView render={it => <>
|
|
27
|
+
<div className={'flex gap-2 items-center'}>
|
|
28
|
+
<div className={'text-sm'}>
|
|
29
|
+
{dictFormat(it.pagesCount !== undefined ? dict.datagrid.pageInfo : dict.datagrid.pageInfoShort, {
|
|
30
|
+
page: (it.pageIndex + 1).toString(),
|
|
31
|
+
pagesCount: it.pagesCount?.toString() ?? '',
|
|
32
|
+
})}
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
</>} />
|
|
36
|
+
<DataViewChangePageTrigger page="first">
|
|
37
|
+
<Button
|
|
38
|
+
variant="outline"
|
|
39
|
+
className="hidden h-8 w-8 p-0 lg:flex"
|
|
40
|
+
>
|
|
41
|
+
<span className="sr-only">{dict.datagrid.paginationFirstPage}</span>
|
|
42
|
+
<ChevronsLeftIcon className="h-4 w-4" />
|
|
43
|
+
</Button>
|
|
44
|
+
</DataViewChangePageTrigger>
|
|
45
|
+
<DataViewChangePageTrigger page="previous">
|
|
46
|
+
<Button
|
|
47
|
+
variant="outline"
|
|
48
|
+
className="h-8 w-8 p-0"
|
|
49
|
+
>
|
|
50
|
+
<span className="sr-only">{dict.datagrid.paginationPreviousPage}</span>
|
|
51
|
+
<ChevronLeftIcon className="h-4 w-4" />
|
|
52
|
+
</Button>
|
|
53
|
+
</DataViewChangePageTrigger>
|
|
54
|
+
<DataViewChangePageTrigger page="next">
|
|
55
|
+
<Button
|
|
56
|
+
variant="outline"
|
|
57
|
+
className="h-8 w-8 p-0"
|
|
58
|
+
>
|
|
59
|
+
<span className="sr-only">{dict.datagrid.paginationNextPage}</span>
|
|
60
|
+
<ChevronRightIcon className="h-4 w-4" />
|
|
61
|
+
</Button>
|
|
62
|
+
</DataViewChangePageTrigger>
|
|
63
|
+
<DataViewChangePageTrigger page="last">
|
|
64
|
+
<Button
|
|
65
|
+
variant="outline"
|
|
66
|
+
className="hidden h-8 w-8 p-0 lg:flex"
|
|
67
|
+
>
|
|
68
|
+
<span className="sr-only">{dict.datagrid.paginationLastPage}</span>
|
|
69
|
+
<ChevronsRightIcon className="h-4 w-4" />
|
|
70
|
+
</Button>
|
|
71
|
+
</DataViewChangePageTrigger>
|
|
72
|
+
</div>
|
|
73
|
+
</div>
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
export const DataGridPerPageSelector = () => (
|
|
78
|
+
<div>
|
|
79
|
+
<p className="text-gray-400 text-xs font-semibold mb-1">{dict.datagrid.paginationRowsPerPage}</p>
|
|
80
|
+
<DropdownMenu
|
|
81
|
+
>
|
|
82
|
+
<DropdownMenuTrigger asChild>
|
|
83
|
+
<Button
|
|
84
|
+
variant="outline"
|
|
85
|
+
className="h-8 w-[70px] p-0 justify-between px-4"
|
|
86
|
+
>
|
|
87
|
+
<DataViewPagingStateView render={it => it.itemsPerPage} />
|
|
88
|
+
|
|
89
|
+
<ChevronDownIcon className="h-4 w-4" />
|
|
90
|
+
</Button>
|
|
91
|
+
</DropdownMenuTrigger>
|
|
92
|
+
<DropdownMenuContent>
|
|
93
|
+
{[5, 10, 20, 30, 40, 50].map(pageSize => (
|
|
94
|
+
<DataViewSetItemsPerPageTrigger value={pageSize} key={pageSize}>
|
|
95
|
+
<DropdownMenuItem key={pageSize} className={'data-[active]:font-bold'}>
|
|
96
|
+
{pageSize}
|
|
97
|
+
</DropdownMenuItem>
|
|
98
|
+
</DataViewSetItemsPerPageTrigger>
|
|
99
|
+
))}
|
|
100
|
+
</DropdownMenuContent>
|
|
101
|
+
</DropdownMenu>
|
|
102
|
+
</div>
|
|
103
|
+
)
|