@contember/create 2.0.0-alpha.8 → 2.0.0-beta.1
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/development/run.cjs +0 -2
- package/dist/development/run.cjs.map +1 -1
- package/dist/development/run.js +0 -2
- package/dist/development/run.js.map +1 -1
- package/dist/development/src/commands/WorkspaceCreateCommand.cjs.map +1 -1
- package/dist/development/src/commands/WorkspaceCreateCommand.js.map +1 -1
- package/dist/development/src/lib/FileSystem.cjs.map +1 -1
- package/dist/development/src/lib/FileSystem.js.map +1 -1
- package/dist/development/src/lib/TemplateInstaller.cjs +1 -8
- package/dist/development/src/lib/TemplateInstaller.cjs.map +1 -1
- package/dist/development/src/lib/TemplateInstaller.js +2 -9
- package/dist/development/src/lib/TemplateInstaller.js.map +1 -1
- package/dist/development/src/lib/version.cjs.map +1 -1
- package/dist/development/src/paths.cjs +3 -1
- package/dist/development/src/paths.cjs.map +1 -1
- package/dist/development/src/paths.js +4 -2
- package/dist/development/src/paths.js.map +1 -1
- package/dist/production/run.cjs +0 -2
- package/dist/production/run.cjs.map +1 -1
- package/dist/production/run.js +0 -2
- package/dist/production/run.js.map +1 -1
- package/dist/production/src/commands/WorkspaceCreateCommand.cjs.map +1 -1
- package/dist/production/src/commands/WorkspaceCreateCommand.js.map +1 -1
- package/dist/production/src/lib/FileSystem.cjs.map +1 -1
- package/dist/production/src/lib/FileSystem.js.map +1 -1
- package/dist/production/src/lib/TemplateInstaller.cjs +1 -8
- package/dist/production/src/lib/TemplateInstaller.cjs.map +1 -1
- package/dist/production/src/lib/TemplateInstaller.js +2 -9
- package/dist/production/src/lib/TemplateInstaller.js.map +1 -1
- package/dist/production/src/lib/version.cjs.map +1 -1
- package/dist/production/src/paths.cjs +3 -1
- package/dist/production/src/paths.cjs.map +1 -1
- package/dist/production/src/paths.js +4 -2
- package/dist/production/src/paths.js.map +1 -1
- package/dist/types/lib/TemplateInstaller.d.ts +1 -3
- package/dist/types/lib/TemplateInstaller.d.ts.map +1 -1
- package/dist/types/paths.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -31
- package/resources/templates/template-workspace/.github/scripts/setup-actions-variables.sh +36 -0
- package/resources/templates/template-workspace/.github/workflows/deploy.yaml +23 -0
- package/resources/templates/template-workspace/admin/lib/binding/binding.tsx +12 -2
- package/resources/templates/template-workspace/admin/lib/binding/delete.tsx +34 -23
- package/resources/templates/template-workspace/admin/lib/binding/hooks.tsx +5 -6
- package/resources/templates/template-workspace/admin/lib/binding/identity.tsx +34 -3
- package/resources/templates/template-workspace/admin/lib/binding/navigation-guard-dialog.tsx +39 -0
- package/resources/templates/template-workspace/admin/lib/binding/persist.tsx +10 -60
- package/resources/templates/template-workspace/admin/lib/block-repeater/block-repeater.tsx +109 -39
- package/resources/templates/template-workspace/admin/lib/buttons/link-back-button.tsx +1 -1
- package/resources/templates/template-workspace/admin/lib/datagrid/cells.tsx +90 -10
- package/resources/templates/template-workspace/admin/lib/datagrid/column-header.tsx +12 -4
- package/resources/templates/template-workspace/admin/lib/datagrid/column-leaf.tsx +21 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/columns.tsx +367 -36
- package/resources/templates/template-workspace/admin/lib/datagrid/elements.tsx +6 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/export.tsx +9 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/boolean.tsx +22 -5
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/common.tsx +3 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/date.tsx +25 -2
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/defined.tsx +103 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/enum.tsx +83 -27
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/index.ts +1 -1
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/mobile.tsx +0 -1
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/number.tsx +21 -5
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/relation.tsx +170 -43
- package/resources/templates/template-workspace/admin/lib/datagrid/filters/text.tsx +48 -5
- package/resources/templates/template-workspace/admin/lib/datagrid/grid.tsx +97 -25
- package/resources/templates/template-workspace/admin/lib/datagrid/index.ts +30 -4
- package/resources/templates/template-workspace/admin/lib/datagrid/labels.tsx +31 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/layout-switcher.tsx +3 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/loader.tsx +44 -2
- package/resources/templates/template-workspace/admin/lib/datagrid/pagination.tsx +8 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/table.tsx +15 -1
- package/resources/templates/template-workspace/admin/lib/datagrid/tiles.tsx +13 -0
- package/resources/templates/template-workspace/admin/lib/datagrid/toolbar.tsx +27 -2
- package/resources/templates/template-workspace/admin/lib/dict.ts +54 -5
- package/resources/templates/template-workspace/admin/lib/dimensions/dimensions.tsx +1 -1
- package/resources/templates/template-workspace/admin/lib/editor/common/editor-canvas.tsx +2 -2
- package/resources/templates/template-workspace/admin/lib/editor/index.ts +1 -0
- package/resources/templates/template-workspace/admin/lib/editor/rich-text-view.tsx +17 -0
- package/resources/templates/template-workspace/admin/lib/field/formatted-field.tsx +10 -0
- package/resources/templates/template-workspace/admin/lib/field/index.ts +1 -0
- package/resources/templates/template-workspace/admin/lib/form/container.tsx +43 -45
- package/resources/templates/template-workspace/admin/lib/form/index.ts +1 -0
- package/resources/templates/template-workspace/admin/lib/form/inputs.tsx +56 -23
- package/resources/templates/template-workspace/admin/lib/form/select.tsx +61 -30
- package/resources/templates/template-workspace/admin/lib/form/ui.tsx +11 -2
- package/resources/templates/template-workspace/admin/lib/form/upload-repeaters.tsx +188 -0
- package/resources/templates/template-workspace/admin/lib/form/upload.tsx +57 -242
- package/resources/templates/template-workspace/admin/lib/formatting/formatting.ts +23 -0
- package/resources/templates/template-workspace/admin/lib/labels/enum-labels.ts +9 -0
- package/resources/templates/template-workspace/admin/lib/labels/field-labels.ts +7 -0
- package/resources/templates/template-workspace/admin/lib/labels/index.ts +2 -0
- package/resources/templates/template-workspace/admin/lib/layout/layout.tsx +3 -3
- package/resources/templates/template-workspace/admin/lib/repeater/repeater.tsx +97 -64
- package/resources/templates/template-workspace/admin/lib/select/filter.tsx +3 -2
- package/resources/templates/template-workspace/admin/lib/select/index.ts +0 -1
- package/resources/templates/template-workspace/admin/lib/select/list.tsx +78 -26
- package/resources/templates/template-workspace/admin/lib/select/multi-select.tsx +12 -19
- package/resources/templates/template-workspace/admin/lib/select/select.tsx +40 -23
- package/resources/templates/template-workspace/admin/lib/select/sortable-select.tsx +23 -18
- package/resources/templates/template-workspace/admin/lib/select/ui.tsx +3 -0
- package/resources/templates/template-workspace/admin/lib/tenant/forms/invite.tsx +5 -3
- package/resources/templates/template-workspace/admin/lib/tenant/forms/memberships-control.tsx +28 -16
- package/resources/templates/template-workspace/admin/lib/tenant/forms/password-reset.tsx +9 -6
- package/resources/templates/template-workspace/admin/lib/tenant/forms/passwordless-signin-init.tsx +31 -0
- package/resources/templates/template-workspace/admin/lib/tenant/forms/passwordless-signin.tsx +59 -0
- package/resources/templates/template-workspace/admin/lib/tenant/forms/update-project-member.tsx +5 -3
- package/resources/templates/template-workspace/admin/lib/tenant/hooks/useInvite.ts +1 -1
- package/resources/templates/template-workspace/admin/lib/tenant/listing/member-list.tsx +6 -5
- package/resources/templates/template-workspace/admin/lib/tenant/listing/person-list.tsx +2 -1
- package/resources/templates/template-workspace/admin/lib/ui/alert-dialog.tsx +2 -1
- package/resources/templates/template-workspace/admin/lib/ui/collapsible.tsx +9 -0
- package/resources/templates/template-workspace/admin/lib/ui/dialog.tsx +2 -1
- package/resources/templates/template-workspace/admin/lib/ui/dropdown.tsx +2 -1
- package/resources/templates/template-workspace/admin/lib/ui/input.tsx +14 -10
- package/resources/templates/template-workspace/admin/lib/ui/menu.tsx +2 -3
- package/resources/templates/template-workspace/admin/lib/ui/popover.tsx +2 -1
- package/resources/templates/template-workspace/admin/lib/ui/property-list.tsx +33 -0
- package/resources/templates/template-workspace/admin/lib/ui/select.tsx +80 -0
- package/resources/templates/template-workspace/admin/lib/ui/sheet.tsx +3 -2
- package/resources/templates/template-workspace/admin/lib/ui/textarea.tsx +9 -1
- package/resources/templates/template-workspace/admin/lib/upload/view.tsx +160 -165
- package/resources/templates/template-workspace/admin/lib/utils/createComponentOpenHooks.tsx +38 -0
- package/resources/templates/template-workspace/admin/lib/utils/uic.tsx +3 -3
- package/resources/templates/template-workspace/admin/package.json +21 -20
- package/resources/templates/template-workspace/package.json +3 -3
- package/src/lib/TemplateInstaller.ts +2 -9
- package/src/paths.ts +4 -3
- package/src/run.ts +0 -2
- package/tsconfig.settings.json +0 -4
- package/dist/development/src/lib/PackageDownloader.cjs +0 -33
- package/dist/development/src/lib/PackageDownloader.cjs.map +0 -1
- package/dist/development/src/lib/PackageDownloader.js +0 -33
- package/dist/development/src/lib/PackageDownloader.js.map +0 -1
- package/dist/production/src/lib/PackageDownloader.cjs +0 -33
- package/dist/production/src/lib/PackageDownloader.cjs.map +0 -1
- package/dist/production/src/lib/PackageDownloader.js +0 -33
- package/dist/production/src/lib/PackageDownloader.js.map +0 -1
- package/dist/types/lib/PackageDownloader.d.ts +0 -7
- package/dist/types/lib/PackageDownloader.d.ts.map +0 -1
- package/resources/templates/template-workspace/admin/.env.production +0 -3
- package/resources/templates/template-workspace/admin/lib/select/pagination.tsx +0 -48
- package/src/lib/PackageDownloader.ts +0 -33
- package/types/download-tarball/index.d.ts +0 -7
- package/types/get-package-json-from-registry/index.d.ts +0 -3
- package/types/registry-info/index.d.ts +0 -7
|
@@ -12,7 +12,13 @@ import { DataGridFilterMobileHiding } from './mobile'
|
|
|
12
12
|
import { Button } from '../../ui/button'
|
|
13
13
|
import { Label } from '../../ui/label'
|
|
14
14
|
import { XIcon } from 'lucide-react'
|
|
15
|
+
import { DataViewFieldLabel } from '../labels'
|
|
15
16
|
|
|
17
|
+
export type DataGridPredefinedDateRange = { start: string; end: string; label: ReactNode }
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Props for {@link DataGridDateFilter}.
|
|
21
|
+
*/
|
|
16
22
|
export type DataGridDateFilterProps =
|
|
17
23
|
& Omit<DataViewDateFilterProps, 'children'>
|
|
18
24
|
& {
|
|
@@ -20,11 +26,22 @@ export type DataGridDateFilterProps =
|
|
|
20
26
|
ranges?: DataGridPredefinedDateRange[]
|
|
21
27
|
}
|
|
22
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Date filter for DataGrid with default UI.
|
|
31
|
+
*
|
|
32
|
+
* ## Props {@link DataGridDateFilterProps}
|
|
33
|
+
* field, label, ?ranges, ?name
|
|
34
|
+
*
|
|
35
|
+
* ## Example
|
|
36
|
+
* ```tsx
|
|
37
|
+
* <DataGridDateFilter field={'createdAt'} label="Created at" />
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
23
40
|
export const DataGridDateFilter = Component(({ label, ranges, ...props }: DataGridDateFilterProps) => (
|
|
24
41
|
<DataViewDateFilter {...props}>
|
|
25
42
|
<DataGridFilterMobileHiding>
|
|
26
43
|
<DataGridSingleFilterUI>
|
|
27
|
-
<DataGridDateFilterSelect label={label} ranges={ranges} />
|
|
44
|
+
<DataGridDateFilterSelect label={label ?? <DataViewFieldLabel field={props.field} />} ranges={ranges} />
|
|
28
45
|
<DataGridDateFilterList />
|
|
29
46
|
</DataGridSingleFilterUI>
|
|
30
47
|
</DataGridFilterMobileHiding>
|
|
@@ -69,6 +86,9 @@ const DataGridDateFilterList = () => (
|
|
|
69
86
|
</>
|
|
70
87
|
)
|
|
71
88
|
|
|
89
|
+
/**
|
|
90
|
+
* Utility function to create a predefined date range
|
|
91
|
+
*/
|
|
72
92
|
export const createDataGridDateRange = (label: ReactNode, dayDeltaStart: number, dayDeltaEnd: number): DataGridPredefinedDateRange => {
|
|
73
93
|
const start = new Date(new Date().setDate(new Date().getDate() + dayDeltaStart))
|
|
74
94
|
const end = new Date(new Date().setDate(new Date().getDate() + dayDeltaEnd))
|
|
@@ -105,7 +125,7 @@ const DataGridDateFilterSelect = ({ label, ranges = defaultRanges }: {
|
|
|
105
125
|
)
|
|
106
126
|
}
|
|
107
127
|
|
|
108
|
-
|
|
128
|
+
|
|
109
129
|
const DataGridRangeFilter = ({ start, end, label }: DataGridPredefinedDateRange) => {
|
|
110
130
|
const name = useDataViewFilterName()
|
|
111
131
|
const [filter, setFilter] = useDataViewFilter<DateRangeFilterArtifacts>(name)
|
|
@@ -120,6 +140,9 @@ const DataGridRangeFilter = ({ start, end, label }: DataGridPredefinedDateRange)
|
|
|
120
140
|
)
|
|
121
141
|
}
|
|
122
142
|
|
|
143
|
+
/**
|
|
144
|
+
* @internal
|
|
145
|
+
*/
|
|
123
146
|
export const DataGridDateFilterControls = ({ layout }: { layout?: 'row' | 'column' }) => {
|
|
124
147
|
const id = useId()
|
|
125
148
|
return (
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import * as React from 'react'
|
|
2
|
+
import { ReactNode } from 'react'
|
|
3
|
+
import { DataViewBooleanFilterProps, DataViewIsDefinedFilter, DataViewNullFilterTrigger } from '@contember/react-dataview'
|
|
4
|
+
import { Popover, PopoverContent, PopoverTrigger } from '../../ui/popover'
|
|
5
|
+
import { DataGridFilterSelectTriggerUI, DataGridSingleFilterUI } from '../ui'
|
|
6
|
+
import { dict } from '../../dict'
|
|
7
|
+
import { Component } from '@contember/interface'
|
|
8
|
+
import { DataGridFilterMobileHiding } from './mobile'
|
|
9
|
+
import { CheckIcon, XIcon } from 'lucide-react'
|
|
10
|
+
import { Button } from '../../ui/button'
|
|
11
|
+
import { DataViewFieldLabel } from '../labels'
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Props for {@link DataGridIsDefinedFilter}.
|
|
15
|
+
*/
|
|
16
|
+
export type DataGridIsDefinedFilterProps =
|
|
17
|
+
& Omit<DataViewBooleanFilterProps, 'children'>
|
|
18
|
+
& {
|
|
19
|
+
label: ReactNode
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Is defined filter for DataGrid with default UI.
|
|
24
|
+
*
|
|
25
|
+
* ## Props {@link DataGridIsDefinedFilterProps}
|
|
26
|
+
* field, label, ?name
|
|
27
|
+
*
|
|
28
|
+
* ## Example
|
|
29
|
+
* ```tsx
|
|
30
|
+
* <DataGridIsDefinedFilter field={'deletedAt'} label="Is Deleted?" />
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export const DataGridIsDefinedFilter = Component(({ label, ...props }: DataGridIsDefinedFilterProps) => (
|
|
34
|
+
<DataViewIsDefinedFilter {...props}>
|
|
35
|
+
<DataGridFilterMobileHiding>
|
|
36
|
+
<DataGridSingleFilterUI>
|
|
37
|
+
<DataGridIsDefinedFilterSelect label={label ?? <DataViewFieldLabel field={props.field} />} />
|
|
38
|
+
<DataGridIsDefinedFilterList />
|
|
39
|
+
</DataGridSingleFilterUI>
|
|
40
|
+
</DataGridFilterMobileHiding>
|
|
41
|
+
</DataViewIsDefinedFilter>
|
|
42
|
+
))
|
|
43
|
+
|
|
44
|
+
const DataGridIsDefinedFilterList = () => (
|
|
45
|
+
<>
|
|
46
|
+
<DataViewNullFilterTrigger action={'unset'}>
|
|
47
|
+
<Button variant={'outline'} size="sm" className={'space-x-1 data-[current="none"]:hidden data-[current="include"]:hidden h-6'}>
|
|
48
|
+
<CheckIcon size={16} />
|
|
49
|
+
<span>
|
|
50
|
+
{dict.boolean.true}
|
|
51
|
+
</span>
|
|
52
|
+
<XIcon className={'w-2 h-2'} />
|
|
53
|
+
</Button>
|
|
54
|
+
</DataViewNullFilterTrigger>
|
|
55
|
+
<DataViewNullFilterTrigger action={'unset'}>
|
|
56
|
+
<Button variant={'outline'} size="sm" className={'space-x-1 data-[current="none"]:hidden data-[current="exclude"]:hidden h-6'}>
|
|
57
|
+
<XIcon size={16} />
|
|
58
|
+
<span>
|
|
59
|
+
{dict.boolean.false}
|
|
60
|
+
</span>
|
|
61
|
+
<XIcon className={'w-2 h-2'} />
|
|
62
|
+
</Button>
|
|
63
|
+
</DataViewNullFilterTrigger>
|
|
64
|
+
</>
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
const DataGridIsDefinedFilterSelect = ({ label }: {
|
|
69
|
+
label?: ReactNode
|
|
70
|
+
}) => (
|
|
71
|
+
<Popover>
|
|
72
|
+
<PopoverTrigger asChild>
|
|
73
|
+
<DataGridFilterSelectTriggerUI>{label}</DataGridFilterSelectTriggerUI>
|
|
74
|
+
</PopoverTrigger>
|
|
75
|
+
<PopoverContent className={'w-52'}>
|
|
76
|
+
<DataGridIsDefinedFilterControls />
|
|
77
|
+
</PopoverContent>
|
|
78
|
+
</Popover>
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* @internal
|
|
83
|
+
*/
|
|
84
|
+
export const DataGridIsDefinedFilterControls = () => {
|
|
85
|
+
return (
|
|
86
|
+
<div className={'flex flex-col gap-2'}>
|
|
87
|
+
<div className={'flex gap-2'}>
|
|
88
|
+
<DataViewNullFilterTrigger action={'toggleExclude'}>
|
|
89
|
+
<Button size={'sm'} className={'w-full data-[active]:shadow-inner data-[active]:text-blue-500'} variant={'outline'}>
|
|
90
|
+
<CheckIcon size={16} />
|
|
91
|
+
{dict.boolean.true}
|
|
92
|
+
</Button>
|
|
93
|
+
</DataViewNullFilterTrigger>
|
|
94
|
+
<DataViewNullFilterTrigger action={'toggleInclude'}>
|
|
95
|
+
<Button size={'sm'} className={'w-full data-[active]:shadow-inner data-[active]:text-blue-500'} variant={'outline'}>
|
|
96
|
+
<XIcon size={16} />
|
|
97
|
+
{dict.boolean.false}
|
|
98
|
+
</Button>
|
|
99
|
+
</DataViewNullFilterTrigger>
|
|
100
|
+
</div>
|
|
101
|
+
</div>
|
|
102
|
+
)
|
|
103
|
+
}
|
|
@@ -1,34 +1,77 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
2
|
import { ReactNode, useCallback } from 'react'
|
|
3
3
|
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../../ui/tooltip'
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
DataViewEnumFilter,
|
|
6
|
+
DataViewEnumFilterProps,
|
|
7
|
+
DataViewEnumFilterTrigger,
|
|
8
|
+
DataViewNullFilterTrigger,
|
|
9
|
+
UseDataViewEnumFilter,
|
|
10
|
+
useDataViewEnumFilterArgs,
|
|
11
|
+
useDataViewEnumFilterFactory,
|
|
12
|
+
useDataViewFilterName,
|
|
13
|
+
} from '@contember/react-dataview'
|
|
5
14
|
import { Component } from '@contember/interface'
|
|
6
15
|
import { Popover, PopoverContent, PopoverTrigger } from '../../ui/popover'
|
|
7
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
DataGridActiveFilterUI,
|
|
18
|
+
DataGridExcludeActionButtonUI,
|
|
19
|
+
DataGridFilterActionButtonUI,
|
|
20
|
+
DataGridFilterSelectItemUI,
|
|
21
|
+
DataGridFilterSelectTriggerUI,
|
|
22
|
+
DataGridSingleFilterUI,
|
|
23
|
+
} from '../ui'
|
|
8
24
|
import { DataGridNullFilter } from './common'
|
|
9
25
|
import { dict } from '../../dict'
|
|
10
26
|
import { DataGridFilterMobileHiding } from './mobile'
|
|
27
|
+
import { useEnumOptionsFormatter } from '../../labels'
|
|
28
|
+
import { DataViewFieldLabel } from '../labels'
|
|
11
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Props for {@link DataGridEnumFilter}.
|
|
32
|
+
*/
|
|
12
33
|
export type DataGridEnumFilterProps =
|
|
13
34
|
& Omit<DataViewEnumFilterProps, 'children'>
|
|
14
35
|
& {
|
|
15
|
-
options
|
|
36
|
+
options?: Record<string, ReactNode>
|
|
16
37
|
label?: ReactNode
|
|
17
38
|
}
|
|
18
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Enum filter for DataGrid with default UI.
|
|
42
|
+
*
|
|
43
|
+
* ## Props {@link DataGridEnumFilterProps}
|
|
44
|
+
* field, label, ?name, ?options
|
|
45
|
+
*
|
|
46
|
+
* ## Example
|
|
47
|
+
* ```tsx
|
|
48
|
+
* <DataGridEnumFilter field={'status'} />
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
19
51
|
export const DataGridEnumFilter = Component(({ options, label, ...props }: DataGridEnumFilterProps) =>
|
|
20
52
|
(
|
|
21
53
|
<DataViewEnumFilter {...props}>
|
|
22
54
|
<DataGridFilterMobileHiding>
|
|
23
55
|
<DataGridSingleFilterUI>
|
|
24
|
-
<DataGridEnumFilterSelect options={options} label={label} />
|
|
56
|
+
<DataGridEnumFilterSelect options={options} label={label ?? <DataViewFieldLabel field={props.field} />} />
|
|
25
57
|
<DataGridEnumFilterList options={options} />
|
|
26
58
|
</DataGridSingleFilterUI>
|
|
27
59
|
</DataGridFilterMobileHiding>
|
|
28
60
|
</DataViewEnumFilter>
|
|
29
61
|
))
|
|
30
62
|
|
|
31
|
-
|
|
63
|
+
/**
|
|
64
|
+
* Props for {@link DataGridEnumFieldTooltip}.
|
|
65
|
+
*/
|
|
66
|
+
export type DataGridEnumFieldTooltipProps = Omit<DataViewEnumFilterProps, 'children'>
|
|
67
|
+
/**
|
|
68
|
+
* Component for rendering a value with a tooltip that allows to include/exclude the value from the filter.
|
|
69
|
+
* Used in {@link DataGridEnumColumn} but can be used in custom columns as well.
|
|
70
|
+
*
|
|
71
|
+
* ## Props {@link DataGridEnumFieldTooltipProps}
|
|
72
|
+
* field, label, ?name, ?options
|
|
73
|
+
*/
|
|
74
|
+
export const DataGridEnumFieldTooltip = ({ children, actions, value, ...props }: DataGridEnumFieldTooltipProps & { children: ReactNode; value: string; actions?: ReactNode }) => (
|
|
32
75
|
<DataViewEnumFilter {...props}>
|
|
33
76
|
<TooltipProvider>
|
|
34
77
|
<Tooltip>
|
|
@@ -52,25 +95,28 @@ export const DataGridEnumFieldTooltip = ({ children, actions, value, ...props }:
|
|
|
52
95
|
)
|
|
53
96
|
|
|
54
97
|
|
|
55
|
-
|
|
56
|
-
options
|
|
57
|
-
}) =>
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
98
|
+
const DataGridEnumFilterList = ({ options }: {
|
|
99
|
+
options?: Record<string, ReactNode>
|
|
100
|
+
}) => {
|
|
101
|
+
const resolvedOptions = useEnumOptions(options)
|
|
102
|
+
return (
|
|
103
|
+
<>
|
|
104
|
+
{Object.entries(resolvedOptions).map(([value, label]) => (
|
|
105
|
+
<DataViewEnumFilterTrigger action={'unset'} value={value} key={value}>
|
|
106
|
+
<DataGridActiveFilterUI>
|
|
107
|
+
{label}
|
|
108
|
+
</DataGridActiveFilterUI>
|
|
109
|
+
</DataViewEnumFilterTrigger>
|
|
110
|
+
))}
|
|
111
|
+
|
|
112
|
+
<DataViewNullFilterTrigger action={'unset'}>
|
|
61
113
|
<DataGridActiveFilterUI>
|
|
62
|
-
{
|
|
114
|
+
<span className={'italic'}>{dict.datagrid.na}</span>
|
|
63
115
|
</DataGridActiveFilterUI>
|
|
64
|
-
</
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
<DataGridActiveFilterUI>
|
|
69
|
-
<span className={'italic'}>{dict.datagrid.na}</span>
|
|
70
|
-
</DataGridActiveFilterUI>
|
|
71
|
-
</DataViewNullFilterTrigger>
|
|
72
|
-
</>
|
|
73
|
-
)
|
|
116
|
+
</DataViewNullFilterTrigger>
|
|
117
|
+
</>
|
|
118
|
+
)
|
|
119
|
+
}
|
|
74
120
|
const DataGridEnumFilterSelectItem = ({ value, children, filterFactory }: {
|
|
75
121
|
value: string
|
|
76
122
|
children: ReactNode
|
|
@@ -82,7 +128,7 @@ const DataGridEnumFilterSelectItem = ({ value, children, filterFactory }: {
|
|
|
82
128
|
const exclude = useCallback(() => setFilter('toggleExclude'), [setFilter])
|
|
83
129
|
const isIncluded = current === 'include'
|
|
84
130
|
|
|
85
|
-
const isExcluded = current
|
|
131
|
+
const isExcluded = current === 'exclude'
|
|
86
132
|
return (
|
|
87
133
|
<DataGridFilterSelectItemUI onExclude={exclude} onInclude={include} isExcluded={isExcluded} isIncluded={isIncluded}>
|
|
88
134
|
{children}
|
|
@@ -90,8 +136,8 @@ const DataGridEnumFilterSelectItem = ({ value, children, filterFactory }: {
|
|
|
90
136
|
)
|
|
91
137
|
|
|
92
138
|
}
|
|
93
|
-
|
|
94
|
-
options
|
|
139
|
+
const DataGridEnumFilterSelect = ({ options, label }: {
|
|
140
|
+
options?: Record<string, ReactNode>
|
|
95
141
|
label?: ReactNode
|
|
96
142
|
}) => {
|
|
97
143
|
return (
|
|
@@ -106,13 +152,17 @@ export const DataGridEnumFilterSelect = ({ options, label }: {
|
|
|
106
152
|
)
|
|
107
153
|
}
|
|
108
154
|
|
|
155
|
+
/**
|
|
156
|
+
* @internal
|
|
157
|
+
*/
|
|
109
158
|
export const DataGridEnumFilterControls = ({ options }: {
|
|
110
|
-
options
|
|
159
|
+
options?: Record<string, ReactNode>
|
|
111
160
|
}) => {
|
|
112
161
|
const filterFactory = useDataViewEnumFilterFactory(useDataViewFilterName())
|
|
162
|
+
const resolvedOptions = useEnumOptions(options)
|
|
113
163
|
return (
|
|
114
164
|
<div className={'relative flex flex-col gap-2'}>
|
|
115
|
-
{Object.entries(
|
|
165
|
+
{Object.entries(resolvedOptions).map(([value, label]) => (
|
|
116
166
|
<DataGridEnumFilterSelectItem value={value} key={value} filterFactory={filterFactory}>
|
|
117
167
|
{label}
|
|
118
168
|
</DataGridEnumFilterSelectItem>
|
|
@@ -121,3 +171,9 @@ export const DataGridEnumFilterControls = ({ options }: {
|
|
|
121
171
|
</div>
|
|
122
172
|
)
|
|
123
173
|
}
|
|
174
|
+
|
|
175
|
+
const useEnumOptions = (preferred: Record<string, ReactNode> | undefined): Record<string, ReactNode> => {
|
|
176
|
+
const enumOptionsProvider = useEnumOptionsFormatter()
|
|
177
|
+
const enumName = useDataViewEnumFilterArgs().enumName
|
|
178
|
+
return preferred ?? enumOptionsProvider(enumName)
|
|
179
|
+
}
|
|
@@ -2,7 +2,6 @@ import { useDataViewFilter, useDataViewFilteringState, useDataViewFilterName } f
|
|
|
2
2
|
import * as React from 'react'
|
|
3
3
|
import { createContext, ReactNode, useContext } from 'react'
|
|
4
4
|
|
|
5
|
-
|
|
6
5
|
export const DataGridShowFiltersContext = createContext(true)
|
|
7
6
|
|
|
8
7
|
export const DataGridFilterMobileHiding = ({ name, children }: { name?: string; children: ReactNode }) => {
|
|
@@ -18,18 +18,32 @@ import { formatNumber } from '../../formatting'
|
|
|
18
18
|
import { dict } from '../../dict'
|
|
19
19
|
import { Component } from '@contember/interface'
|
|
20
20
|
import { DataGridFilterMobileHiding } from './mobile'
|
|
21
|
+
import { DataViewFieldLabel } from '../labels'
|
|
21
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Props for {@link DataGridNumberFilter}.
|
|
25
|
+
*/
|
|
22
26
|
export type DataGridNumberFilterProps =
|
|
23
27
|
& Omit<DataViewNumberFilterProps, 'children'>
|
|
24
28
|
& {
|
|
25
29
|
label: ReactNode
|
|
26
30
|
}
|
|
27
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Number filter for DataGrid with default UI.
|
|
33
|
+
*
|
|
34
|
+
* ## Props {@link DataGridNumberFilterProps}
|
|
35
|
+
* field, label, ?name
|
|
36
|
+
*
|
|
37
|
+
* ## Example
|
|
38
|
+
* ```tsx
|
|
39
|
+
* <DataGridNumberFilter field={'views'} label="Views" />
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
28
42
|
export const DataGridNumberFilter = Component(({ label, ...props }: DataGridNumberFilterProps) => (
|
|
29
43
|
<DataViewNumberFilter {...props}>
|
|
30
44
|
<DataGridFilterMobileHiding>
|
|
31
45
|
<DataGridSingleFilterUI>
|
|
32
|
-
<DataGridNumberFilterSelect label={label} />
|
|
46
|
+
<DataGridNumberFilterSelect label={label ?? <DataViewFieldLabel field={props.field} />} />
|
|
33
47
|
<DataGridNumberFilterList />
|
|
34
48
|
</DataGridSingleFilterUI>
|
|
35
49
|
</DataGridFilterMobileHiding>
|
|
@@ -55,7 +69,7 @@ const DataGridNumberFilterRange = () => {
|
|
|
55
69
|
}
|
|
56
70
|
|
|
57
71
|
|
|
58
|
-
|
|
72
|
+
const DataGridNumberFilterList = () => (
|
|
59
73
|
<>
|
|
60
74
|
<DataViewNumberFilterResetTrigger>
|
|
61
75
|
<DataGridActiveFilterUI>
|
|
@@ -72,7 +86,7 @@ export const DataGridNumberFilterList = () => (
|
|
|
72
86
|
)
|
|
73
87
|
|
|
74
88
|
|
|
75
|
-
|
|
89
|
+
const DataGridNumberFilterSelect = ({ label }: {
|
|
76
90
|
label?: ReactNode
|
|
77
91
|
}) => (
|
|
78
92
|
<Popover>
|
|
@@ -85,7 +99,9 @@ export const DataGridNumberFilterSelect = ({ label }: {
|
|
|
85
99
|
</Popover>
|
|
86
100
|
)
|
|
87
101
|
|
|
88
|
-
|
|
102
|
+
/**
|
|
103
|
+
* @internal
|
|
104
|
+
*/
|
|
89
105
|
export const DataGridNumberFilterControls = () => {
|
|
90
106
|
return (
|
|
91
107
|
<div className={'flex flex-col gap-4'}>
|