@contember/create 2.0.0-beta.2 → 2.0.0-beta.3
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/package.json +2 -2
- package/resources/templates/template-workspace/admin/lib/datagrid/grid.tsx +5 -6
- package/resources/templates/template-workspace/admin/lib/datagrid/pagination.tsx +38 -14
- package/resources/templates/template-workspace/admin/lib/datagrid/table.tsx +13 -10
- package/resources/templates/template-workspace/admin/lib/datagrid/toolbar.tsx +22 -18
- package/resources/templates/template-workspace/admin/lib/datagrid/ui.tsx +29 -26
- package/resources/templates/template-workspace/admin/lib/form/container.tsx +5 -8
- package/resources/templates/template-workspace/admin/lib/form/inputs.tsx +5 -6
- package/resources/templates/template-workspace/admin/lib/form/labels.tsx +8 -0
- package/resources/templates/template-workspace/admin/lib/layout/index.ts +1 -0
- package/resources/templates/template-workspace/admin/lib/layout/layout-boxed.tsx +184 -0
- package/resources/templates/template-workspace/admin/lib/layout/layout.tsx +80 -160
- package/resources/templates/template-workspace/admin/lib/layout/slots.tsx +1 -0
- package/resources/templates/template-workspace/admin/lib/select/ui.tsx +1 -1
- package/resources/templates/template-workspace/admin/lib/ui/alert-dialog.tsx +6 -4
- package/resources/templates/template-workspace/admin/lib/ui/avatar.tsx +42 -0
- package/resources/templates/template-workspace/admin/lib/ui/collapsible.tsx +7 -5
- package/resources/templates/template-workspace/admin/lib/ui/dropdown.tsx +18 -16
- package/resources/templates/template-workspace/admin/lib/ui/menu.tsx +102 -74
- package/resources/templates/template-workspace/admin/lib/ui/popover.tsx +2 -2
- package/resources/templates/template-workspace/admin/lib/ui/progress.tsx +16 -18
- package/resources/templates/template-workspace/admin/lib/ui/separator.tsx +13 -0
- package/resources/templates/template-workspace/admin/lib/ui/sidebar.tsx +560 -0
- package/resources/templates/template-workspace/admin/lib/ui/skeleton.tsx +3 -0
- package/resources/templates/template-workspace/admin/lib/ui/switch.tsx +4 -5
- package/resources/templates/template-workspace/admin/lib/ui/toggle-group.tsx +2 -3
- package/resources/templates/template-workspace/admin/lib/ui/toggle.tsx +1 -2
- package/resources/templates/template-workspace/admin/lib/ui/tooltip.tsx +2 -2
- package/resources/templates/template-workspace/admin/lib/utils/uic.tsx +40 -6
- package/resources/templates/template-workspace/admin/lib/utils/use-mobile.ts +28 -0
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/create",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.3",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"bin": "dist/production/run.js",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@contember/cli-common": "2.0.0-beta.
|
|
7
|
+
"@contember/cli-common": "2.0.0-beta.3",
|
|
8
8
|
"chalk": "^5.3.0",
|
|
9
9
|
"fs-extra": "^11.2.0",
|
|
10
10
|
"js-yaml": "^4.1.0"
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
import { Component } from '@contember/interface'
|
|
1
2
|
import { DataView, DataViewProps } from '@contember/react-dataview'
|
|
2
|
-
import * as React from 'react'
|
|
3
3
|
import { ReactNode } from 'react'
|
|
4
|
-
import { Component } from '@contember/interface'
|
|
5
|
-
import { DataGridToolbar } from './toolbar'
|
|
6
4
|
import { DataGridLoader } from './loader'
|
|
7
|
-
import { DataGridTable } from './table'
|
|
8
5
|
import { DataGridPagination } from './pagination'
|
|
6
|
+
import { DataGridTable } from './table'
|
|
7
|
+
import { DataGridToolbar } from './toolbar'
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* Props for {@link DataGrid}.
|
|
@@ -109,7 +108,7 @@ export type DefaultDataGridProps =
|
|
|
109
108
|
export const DefaultDataGrid = Component(({ children, toolbar, ...props }: DefaultDataGridProps) => {
|
|
110
109
|
return (
|
|
111
110
|
<DataGrid {...props}>
|
|
112
|
-
<DataGridToolbar>
|
|
111
|
+
<DataGridToolbar sticky>
|
|
113
112
|
{toolbar}
|
|
114
113
|
</DataGridToolbar>
|
|
115
114
|
|
|
@@ -119,7 +118,7 @@ export const DefaultDataGrid = Component(({ children, toolbar, ...props }: Defau
|
|
|
119
118
|
</DataGridTable>
|
|
120
119
|
</DataGridLoader>
|
|
121
120
|
|
|
122
|
-
<DataGridPagination />
|
|
121
|
+
<DataGridPagination sticky />
|
|
123
122
|
</DataGrid>
|
|
124
123
|
)
|
|
125
124
|
})
|
|
@@ -1,11 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import {
|
|
2
|
+
DataViewChangePageTrigger,
|
|
3
|
+
DataViewPagingStateView,
|
|
4
|
+
DataViewSetItemsPerPageTrigger,
|
|
5
|
+
} from '@contember/react-dataview'
|
|
5
6
|
import { DropdownMenu } from '@radix-ui/react-dropdown-menu'
|
|
7
|
+
import {
|
|
8
|
+
ChevronDownIcon,
|
|
9
|
+
ChevronLeftIcon,
|
|
10
|
+
ChevronRightIcon,
|
|
11
|
+
ChevronsLeftIcon,
|
|
12
|
+
ChevronsRightIcon,
|
|
13
|
+
Loader2Icon,
|
|
14
|
+
} from 'lucide-react'
|
|
15
|
+
import { FC } from 'react'
|
|
16
|
+
import { dict, dictFormat } from '../dict'
|
|
17
|
+
import { Button } from '../ui/button'
|
|
6
18
|
import { DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '../ui/dropdown'
|
|
7
|
-
import {
|
|
8
|
-
|
|
19
|
+
import { uic } from '../utils'
|
|
20
|
+
|
|
21
|
+
const PaginationWrapper = uic('div', {
|
|
22
|
+
baseClass: 'flex gap-6 lg:gap-8 items-center justify-between mt-4 pb-4',
|
|
23
|
+
variants: {
|
|
24
|
+
sticky: {
|
|
25
|
+
true: 'sticky bottom-0 z-50 bg-white pt-4 border-t border-gray-200',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
interface DataGridPaginationProps {
|
|
31
|
+
sticky?: boolean
|
|
32
|
+
}
|
|
9
33
|
|
|
10
34
|
/**
|
|
11
35
|
* Pagination controls UI for DataView.
|
|
@@ -15,12 +39,12 @@ import { dict } from '../dict'
|
|
|
15
39
|
* <DataGridPagination />
|
|
16
40
|
* ```
|
|
17
41
|
*/
|
|
18
|
-
export const DataGridPagination = () => (
|
|
19
|
-
<
|
|
20
|
-
<div
|
|
42
|
+
export const DataGridPagination: FC<DataGridPaginationProps> = ({ sticky }) => (
|
|
43
|
+
<PaginationWrapper sticky={sticky}>
|
|
44
|
+
<div>
|
|
21
45
|
<DataViewPagingStateView render={it => <>
|
|
22
|
-
<div className=
|
|
23
|
-
<div className=
|
|
46
|
+
<div className="flex gap-2 items-center">
|
|
47
|
+
<div className="font-normal text-sm text-gray-500">
|
|
24
48
|
{it.totalCount === undefined ? <Loader2Icon className="animate-spin h-3 w-3 inline-block" />
|
|
25
49
|
: dictFormat(dict.datagrid.pageRowsCount, {
|
|
26
50
|
totalCount: it.totalCount.toString(),
|
|
@@ -32,8 +56,8 @@ export const DataGridPagination = () => (
|
|
|
32
56
|
</div>
|
|
33
57
|
<div className="flex items-center space-x-2">
|
|
34
58
|
<DataViewPagingStateView render={it => <>
|
|
35
|
-
<div className=
|
|
36
|
-
<div className=
|
|
59
|
+
<div className="flex gap-2 items-center">
|
|
60
|
+
<div className="text-sm">
|
|
37
61
|
{dictFormat(it.pagesCount !== undefined ? dict.datagrid.pageInfo : dict.datagrid.pageInfoShort, {
|
|
38
62
|
page: (it.pageIndex + 1).toString(),
|
|
39
63
|
pagesCount: it.pagesCount?.toString() ?? '',
|
|
@@ -78,7 +102,7 @@ export const DataGridPagination = () => (
|
|
|
78
102
|
</Button>
|
|
79
103
|
</DataViewChangePageTrigger>
|
|
80
104
|
</div>
|
|
81
|
-
</
|
|
105
|
+
</PaginationWrapper>
|
|
82
106
|
)
|
|
83
107
|
|
|
84
108
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Component, Environment } from '@contember/interface'
|
|
2
|
-
import { Table, TableBody, TableHeader, TableRow } from '../ui/table'
|
|
3
|
-
import * as React from 'react'
|
|
4
|
-
import { Fragment, ReactNode, useMemo } from 'react'
|
|
5
2
|
import { DataViewEachRow, DataViewEmpty, DataViewLayout, DataViewNonEmpty } from '@contember/react-dataview'
|
|
3
|
+
import { ChildrenAnalyzer, Leaf } from '@contember/react-multipass-rendering'
|
|
6
4
|
import { SheetIcon } from 'lucide-react'
|
|
5
|
+
import * as React from 'react'
|
|
6
|
+
import { Fragment, ReactNode, useMemo } from 'react'
|
|
7
7
|
import { dict } from '../dict'
|
|
8
|
-
import {
|
|
8
|
+
import { Table, TableBody, TableHeader, TableRow } from '../ui/table'
|
|
9
9
|
|
|
10
10
|
import { DataGridColumnLeaf, DataGridColumnLeafProps } from './column-leaf'
|
|
11
11
|
|
|
@@ -28,11 +28,14 @@ export interface DataViewTableProps {
|
|
|
28
28
|
*/
|
|
29
29
|
export const DataGridTable = Component<DataViewTableProps>(({ children }) => {
|
|
30
30
|
return (
|
|
31
|
-
<DataViewLayout
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
<DataViewLayout
|
|
32
|
+
name="table"
|
|
33
|
+
label={<>
|
|
34
|
+
<SheetIcon className="w-3 h-3" />
|
|
35
|
+
<span>{dict.datagrid.showTable}</span>
|
|
36
|
+
</>}
|
|
37
|
+
>
|
|
38
|
+
<div className="relative rounded-md border overflow-y-auto">
|
|
36
39
|
<DataGridTableRenderer>
|
|
37
40
|
{children}
|
|
38
41
|
</DataGridTableRenderer>
|
|
@@ -41,7 +44,7 @@ export const DataGridTable = Component<DataViewTableProps>(({ children }) => {
|
|
|
41
44
|
)
|
|
42
45
|
})
|
|
43
46
|
|
|
44
|
-
const DataGridTableRenderer = Component<
|
|
47
|
+
const DataGridTableRenderer = Component<DataViewTableProps>(({ children }, env) => {
|
|
45
48
|
const columns = useMemo(() => datagridColumnsAnalyzer.processChildren(children, env), [children, env])
|
|
46
49
|
return (
|
|
47
50
|
<Table>
|
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
import { Component } from '@contember/interface'
|
|
2
|
+
import { DataViewReloadTrigger } from '@contember/react-dataview'
|
|
3
|
+
import { dataAttribute } from '@contember/utilities'
|
|
4
|
+
import { FilterIcon, RefreshCcwIcon, SettingsIcon } from 'lucide-react'
|
|
2
5
|
import * as React from 'react'
|
|
3
6
|
import { ReactNode } from 'react'
|
|
4
|
-
import {
|
|
5
|
-
import { DataGridToolbarUI } from './ui'
|
|
7
|
+
import { dict } from '../dict'
|
|
6
8
|
import { Button } from '../ui/button'
|
|
7
|
-
import { FilterIcon, RefreshCcwIcon, SettingsIcon } from 'lucide-react'
|
|
8
9
|
import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover'
|
|
10
|
+
import { DataGridToolbarVisibleElements } from './elements'
|
|
11
|
+
import { DataGridAutoExport } from './export'
|
|
12
|
+
import { DataGridQueryFilter } from './filters'
|
|
13
|
+
import { DataGridShowFiltersContext } from './filters/mobile'
|
|
9
14
|
import { DataGridLayoutSwitcher } from './layout-switcher'
|
|
10
15
|
import { DataGridPerPageSelector } from './pagination'
|
|
11
|
-
import {
|
|
12
|
-
import { dataAttribute } from '@contember/utilities'
|
|
13
|
-
import { dict } from '../dict'
|
|
14
|
-
import { DataGridAutoExport } from './export'
|
|
15
|
-
import { DataGridToolbarVisibleElements } from './elements'
|
|
16
|
-
import { DataViewReloadTrigger } from '@contember/react-dataview'
|
|
16
|
+
import { DataGridToolbarUI } from './ui'
|
|
17
17
|
|
|
18
18
|
/**
|
|
19
19
|
* Props for the {@link DataGridToolbar} component.
|
|
20
20
|
*/
|
|
21
21
|
export interface DataGridToolbarProps {
|
|
22
22
|
children?: ReactNode
|
|
23
|
+
|
|
24
|
+
// UI props from DataGridToolbarUI
|
|
25
|
+
sticky?: boolean
|
|
23
26
|
}
|
|
24
27
|
|
|
25
28
|
/**
|
|
@@ -38,16 +41,17 @@ export interface DataGridToolbarProps {
|
|
|
38
41
|
* </DataGridToolbar>
|
|
39
42
|
* ```
|
|
40
43
|
*/
|
|
41
|
-
export const DataGridToolbar = Component<DataGridToolbarProps>(({ children }) => {
|
|
44
|
+
export const DataGridToolbar = Component<DataGridToolbarProps>(({ children, sticky }) => {
|
|
42
45
|
const [showFilters, setShowFilters] = React.useState(false)
|
|
46
|
+
|
|
43
47
|
return (
|
|
44
48
|
<DataGridShowFiltersContext.Provider value={showFilters}>
|
|
45
|
-
<DataGridToolbarUI>
|
|
49
|
+
<DataGridToolbarUI sticky={sticky}>
|
|
46
50
|
<div className="ml-auto flex gap-2 items-center sm:order-1">
|
|
47
51
|
<Button
|
|
48
|
-
variant=
|
|
49
|
-
size=
|
|
50
|
-
className=
|
|
52
|
+
variant="outline"
|
|
53
|
+
size="sm"
|
|
54
|
+
className="gap-2 sm:hidden data-[active]:bg-gray-50 data-[active]:shadow-inner"
|
|
51
55
|
data-active={dataAttribute(showFilters)}
|
|
52
56
|
onClick={() => setShowFilters(!showFilters)}
|
|
53
57
|
>
|
|
@@ -56,8 +60,8 @@ export const DataGridToolbar = Component<DataGridToolbarProps>(({ children }) =>
|
|
|
56
60
|
|
|
57
61
|
<Popover>
|
|
58
62
|
<PopoverTrigger asChild>
|
|
59
|
-
<Button variant=
|
|
60
|
-
<SettingsIcon className=
|
|
63
|
+
<Button variant="outline" size="sm" className="gap-2">
|
|
64
|
+
<SettingsIcon className="w-4 h-4" />
|
|
61
65
|
</Button>
|
|
62
66
|
</PopoverTrigger>
|
|
63
67
|
<PopoverContent className="w-64">
|
|
@@ -72,8 +76,8 @@ export const DataGridToolbar = Component<DataGridToolbarProps>(({ children }) =>
|
|
|
72
76
|
|
|
73
77
|
<DataGridAutoExport />
|
|
74
78
|
<DataViewReloadTrigger>
|
|
75
|
-
<Button variant=
|
|
76
|
-
<RefreshCcwIcon className=
|
|
79
|
+
<Button variant="outline" size="sm" className="group gap-2">
|
|
80
|
+
<RefreshCcwIcon className="w-4 h-4 group-data-[state=refreshing]:animate-spin " />
|
|
77
81
|
</Button>
|
|
78
82
|
</DataViewReloadTrigger>
|
|
79
83
|
</div>
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import * as React from 'react'
|
|
2
|
-
import { forwardRef, ReactEventHandler, ReactNode, useCallback } from 'react'
|
|
3
1
|
import { CheckSquareIcon, FilterIcon, FilterXIcon, PlusIcon, SquareIcon, XIcon } from 'lucide-react'
|
|
4
|
-
import {
|
|
5
|
-
import { cn } from '../utils/cn'
|
|
2
|
+
import { forwardRef, ReactEventHandler, ReactNode, useCallback } from 'react'
|
|
6
3
|
import { dict } from '../dict'
|
|
7
|
-
import {
|
|
4
|
+
import { Button } from '../ui/button'
|
|
5
|
+
import { cn, uic } from '../utils'
|
|
8
6
|
|
|
9
7
|
export const DataGridTooltipLabel = uic('span', {
|
|
10
8
|
baseClass: 'cursor-pointer border-dashed border-b border-b-gray-400 hover:border-gray-800',
|
|
@@ -16,13 +14,13 @@ export const DataGridTooltipLabel = uic('span', {
|
|
|
16
14
|
export const DataGridFilterActionButtonUI = forwardRef<HTMLButtonElement, {}>((props: {}, ref) => {
|
|
17
15
|
return (
|
|
18
16
|
<Button
|
|
19
|
-
variant=
|
|
20
|
-
size=
|
|
21
|
-
className=
|
|
17
|
+
variant="outline"
|
|
18
|
+
size="sm"
|
|
19
|
+
className="space-x-1 data-[active]:text-blue-600 data-[active]:bg-gray-50 data-[active]:shadow-inner"
|
|
22
20
|
ref={ref}
|
|
23
21
|
{...props}
|
|
24
22
|
>
|
|
25
|
-
<FilterIcon className=
|
|
23
|
+
<FilterIcon className="w-3 h-3" />
|
|
26
24
|
<span>{dict.datagrid.filter}</span>
|
|
27
25
|
</Button>
|
|
28
26
|
)
|
|
@@ -34,13 +32,13 @@ export const DataGridFilterActionButtonUI = forwardRef<HTMLButtonElement, {}>((p
|
|
|
34
32
|
export const DataGridExcludeActionButtonUI = forwardRef<HTMLButtonElement, {}>((props: {}, ref) => {
|
|
35
33
|
return (
|
|
36
34
|
<Button
|
|
37
|
-
variant=
|
|
38
|
-
size=
|
|
39
|
-
className=
|
|
35
|
+
variant="outline"
|
|
36
|
+
size="sm"
|
|
37
|
+
className="space-x-1 data-[active]:text-blue-600 data-[active]:bg-gray-50 data-[active]:shadow-inner"
|
|
40
38
|
ref={ref}
|
|
41
39
|
{...props}
|
|
42
40
|
>
|
|
43
|
-
<FilterXIcon className=
|
|
41
|
+
<FilterXIcon className="w-3 h-3" />
|
|
44
42
|
<span>{dict.datagrid.exclude}</span>
|
|
45
43
|
</Button>
|
|
46
44
|
)
|
|
@@ -55,7 +53,7 @@ export const DataGridActiveFilterUI = forwardRef<HTMLButtonElement, {
|
|
|
55
53
|
}>(({ children, className, ...props }, ref) => {
|
|
56
54
|
return (
|
|
57
55
|
<Button
|
|
58
|
-
variant=
|
|
56
|
+
variant="outline"
|
|
59
57
|
size="sm"
|
|
60
58
|
className={cn('space-x-1 data-[current="none"]:hidden data-[current="exclude"]:line-through h-6', className)}
|
|
61
59
|
ref={ref}
|
|
@@ -64,7 +62,7 @@ export const DataGridActiveFilterUI = forwardRef<HTMLButtonElement, {
|
|
|
64
62
|
<span>
|
|
65
63
|
{children}
|
|
66
64
|
</span>
|
|
67
|
-
<XIcon className=
|
|
65
|
+
<XIcon className="w-2 h-2" />
|
|
68
66
|
</Button>
|
|
69
67
|
)
|
|
70
68
|
})
|
|
@@ -72,7 +70,7 @@ export const DataGridActiveFilterUI = forwardRef<HTMLButtonElement, {
|
|
|
72
70
|
|
|
73
71
|
export const DataGridSingleFilterUI = forwardRef<HTMLDivElement, { children: ReactNode }>((props, ref) => {
|
|
74
72
|
return (
|
|
75
|
-
<div className=
|
|
73
|
+
<div className="flex flex-wrap gap-2 rounded bg-gray-50 items-center text-sm px-2 py-1.5 border" ref={ref} {...props} />
|
|
76
74
|
)
|
|
77
75
|
})
|
|
78
76
|
|
|
@@ -81,14 +79,14 @@ export const DataGridFilterSelectTriggerUI = forwardRef<HTMLButtonElement, { chi
|
|
|
81
79
|
...props
|
|
82
80
|
}, ref) => {
|
|
83
81
|
return (
|
|
84
|
-
<button className=
|
|
85
|
-
{children && <span className=
|
|
82
|
+
<button className="hover:underline inline-flex items-center gap-2 group px-1" ref={ref} {...props}>
|
|
83
|
+
{children && <span className="text-xs font-medium">
|
|
86
84
|
{children}
|
|
87
85
|
</span>}
|
|
88
86
|
<span
|
|
89
|
-
className=
|
|
87
|
+
className="bg-gray-100 rounded-full border group-data-[state=open]:bg-white group-data-[state=open]:shadow-inner h-5 w-5 inline-flex items-center justify-center"
|
|
90
88
|
>
|
|
91
|
-
<PlusIcon className=
|
|
89
|
+
<PlusIcon className="w-3 h-3" />
|
|
92
90
|
</span>
|
|
93
91
|
</button>
|
|
94
92
|
)
|
|
@@ -121,14 +119,14 @@ export const DataGridFilterSelectItemUI = forwardRef<HTMLButtonElement, DataGrid
|
|
|
121
119
|
}, [onExclude])
|
|
122
120
|
|
|
123
121
|
return (
|
|
124
|
-
<div className=
|
|
122
|
+
<div className="relative flex gap-1 justify-between items-center">
|
|
125
123
|
<Button
|
|
126
124
|
ref={ref}
|
|
127
125
|
onClick={include}
|
|
128
|
-
size=
|
|
129
|
-
className=
|
|
130
|
-
variant=
|
|
131
|
-
{isIncluded ? <CheckSquareIcon className=
|
|
126
|
+
size="sm"
|
|
127
|
+
className="pl-1 w-full text-left justify-start gap-1 data-[highlighted]:bg-gray-200"
|
|
128
|
+
variant="ghost" {...props}>
|
|
129
|
+
{isIncluded ? <CheckSquareIcon className="w-3 h-3" /> : <SquareIcon className="w-3 h-3" />}
|
|
132
130
|
<span className={cn('font-normal', isIncluded && 'text-blue-700')}>
|
|
133
131
|
{children}
|
|
134
132
|
</span>
|
|
@@ -140,7 +138,7 @@ export const DataGridFilterSelectItemUI = forwardRef<HTMLButtonElement, DataGrid
|
|
|
140
138
|
isExcluded ? 'bg-red-300 shadow-inner' : '',
|
|
141
139
|
)}
|
|
142
140
|
>
|
|
143
|
-
<FilterXIcon className=
|
|
141
|
+
<FilterXIcon className="h-3 w-3" />
|
|
144
142
|
</button>
|
|
145
143
|
</div>
|
|
146
144
|
|
|
@@ -150,4 +148,9 @@ export const DataGridFilterSelectItemUI = forwardRef<HTMLButtonElement, DataGrid
|
|
|
150
148
|
|
|
151
149
|
export const DataGridToolbarUI = uic('div', {
|
|
152
150
|
baseClass: 'flex flex-col md:flex-row gap-2 md:items-end mb-4 items-stretch',
|
|
151
|
+
variants: {
|
|
152
|
+
sticky: {
|
|
153
|
+
true: 'sticky top-0 z-50 border-b bg-white border-gray-200 pb-4',
|
|
154
|
+
},
|
|
155
|
+
},
|
|
153
156
|
})
|
|
@@ -4,7 +4,7 @@ import { FormContainerUI, FormDescriptionUI, FormErrorUI, FormLabelUI, FormLabel
|
|
|
4
4
|
import { useErrorFormatter } from '../errors'
|
|
5
5
|
import { Component, ErrorAccessor } from '@contember/interface'
|
|
6
6
|
import { FormError, FormFieldStateProvider, FormLabel, useFormFieldState } from '@contember/react-form'
|
|
7
|
-
import {
|
|
7
|
+
import { FormFieldLabel } from './labels'
|
|
8
8
|
|
|
9
9
|
export interface FormContainerProps {
|
|
10
10
|
label?: ReactNode
|
|
@@ -19,8 +19,7 @@ export const FormContainer = Component(({ children, description, label, required
|
|
|
19
19
|
const errorsNode = Array.isArray(errors) ? undefined : errors
|
|
20
20
|
const errorsList = Array.isArray(errors) ? errors : []
|
|
21
21
|
const state = useFormFieldState()
|
|
22
|
-
|
|
23
|
-
label ??= state?.field ? fieldLabelFormatter(state.field.entityName, state.field.fieldName) : undefined
|
|
22
|
+
label ??= <FormFieldLabel />
|
|
24
23
|
|
|
25
24
|
const inner = <>
|
|
26
25
|
<FormContainerUI>
|
|
@@ -34,16 +33,14 @@ export const FormContainer = Component(({ children, description, label, required
|
|
|
34
33
|
<div>
|
|
35
34
|
{children}
|
|
36
35
|
</div>
|
|
37
|
-
<div>
|
|
38
|
-
{description && <FormDescriptionUI>
|
|
39
|
-
{description}
|
|
40
|
-
</FormDescriptionUI>}
|
|
36
|
+
{(description || errorsNode || state?.errors?.length || errorsList?.length) ? <div>
|
|
37
|
+
{description && <FormDescriptionUI>{description}</FormDescriptionUI>}
|
|
41
38
|
|
|
42
39
|
<FormError formatter={useErrorFormatter()}>
|
|
43
40
|
<FormErrorUI />
|
|
44
41
|
</FormError>
|
|
45
42
|
{errorsNode}
|
|
46
|
-
</div>
|
|
43
|
+
</div> : null}
|
|
47
44
|
</FormContainerUI>
|
|
48
45
|
</>
|
|
49
46
|
return state !== undefined
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
import { FormContainer, FormContainerProps } from './container'
|
|
19
19
|
import { Component, Field } from '@contember/interface'
|
|
20
20
|
import { useEnumOptionsFormatter } from '../labels'
|
|
21
|
+
import { FormFieldLabel } from './labels'
|
|
21
22
|
|
|
22
23
|
|
|
23
24
|
export type InputFieldProps =
|
|
@@ -67,16 +68,14 @@ export type CheckboxFieldProps =
|
|
|
67
68
|
|
|
68
69
|
export const CheckboxField = Component(({ field, label, description, inputProps, isNonbearing, defaultValue, required }: CheckboxFieldProps) => (
|
|
69
70
|
<FormFieldScope field={field}>
|
|
70
|
-
<FormContainer description={description} label={
|
|
71
|
+
<FormContainer description={description} label={false}>
|
|
71
72
|
<div className="flex gap-2 items-center">
|
|
72
73
|
<FormCheckbox field={field} isNonbearing={isNonbearing} defaultValue={defaultValue}>
|
|
73
74
|
<CheckboxInput required={required} {...inputProps} />
|
|
74
75
|
</FormCheckbox>
|
|
75
|
-
|
|
76
|
-
<FormLabelUI required={required}>
|
|
77
|
-
|
|
78
|
-
</FormLabelUI>
|
|
79
|
-
</FormLabel>}
|
|
76
|
+
<FormLabel>
|
|
77
|
+
<FormLabelUI required={required}>{label ?? <FormFieldLabel />}</FormLabelUI>
|
|
78
|
+
</FormLabel>
|
|
80
79
|
</div>
|
|
81
80
|
</FormContainer>
|
|
82
81
|
</FormFieldScope>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { useFormFieldState } from '@contember/react-form'
|
|
2
|
+
import { useFieldLabelFormatter } from '../labels'
|
|
3
|
+
|
|
4
|
+
export const FormFieldLabel = () => {
|
|
5
|
+
const state = useFormFieldState()
|
|
6
|
+
const fieldLabelFormatter = useFieldLabelFormatter()
|
|
7
|
+
return state?.field ? fieldLabelFormatter(state.field.entityName, state.field.fieldName) : undefined
|
|
8
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { useCurrentRequest } from '@contember/interface'
|
|
2
|
+
import { LogoutTrigger } from '@contember/react-identity'
|
|
3
|
+
import { useHasActiveSlotsFactory } from '@contember/react-slots'
|
|
4
|
+
import { useStoredState } from '@contember/react-utils'
|
|
5
|
+
import {
|
|
6
|
+
LogOutIcon,
|
|
7
|
+
Maximize2Icon,
|
|
8
|
+
MenuIcon,
|
|
9
|
+
Minimize2Icon,
|
|
10
|
+
PanelLeftCloseIcon,
|
|
11
|
+
PanelLeftOpenIcon,
|
|
12
|
+
PanelRightCloseIcon,
|
|
13
|
+
PanelRightOpenIcon,
|
|
14
|
+
} from 'lucide-react'
|
|
15
|
+
import { PropsWithChildren, useEffect, useState } from 'react'
|
|
16
|
+
import { dict } from '../dict'
|
|
17
|
+
import { Button } from '../ui/button'
|
|
18
|
+
import { SidebarProvider } from '../ui/sidebar'
|
|
19
|
+
import { uic } from '../utils'
|
|
20
|
+
import { SlotTargets } from './slots'
|
|
21
|
+
|
|
22
|
+
const LayoutBodyUI = uic('div', { baseClass: 'bg-gray-50 h-full min-h-screen relative py-4 pl-[calc(100vw-100%)]' })
|
|
23
|
+
const LayoutMaxWidthUI = uic('div', {
|
|
24
|
+
baseClass: 'mx-auto transition-all',
|
|
25
|
+
variants: {
|
|
26
|
+
layout: {
|
|
27
|
+
stretch: 'max-w-[calc(100vw-5rem)]',
|
|
28
|
+
default: 'max-w-[100rem]',
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
defaultVariants: {
|
|
32
|
+
layout: 'default',
|
|
33
|
+
},
|
|
34
|
+
})
|
|
35
|
+
const LayoutBoxUI = uic('div', { baseClass: 'rounded-xl shadow-lg border bg-white gap-1 flex flex-col lg:flex-row mt-4 relative min-h-[calc(100vh-10rem)]' })
|
|
36
|
+
|
|
37
|
+
const LayoutCenterPanelUI = uic('div', { baseClass: 'flex flex-col flex-2 p-4 gap-2 w-full flex-auto overflow-hidden' })
|
|
38
|
+
const LayoutCenterTopUI = uic('div', { baseClass: 'flex justify-between pb-4 mb-4 border-b' })
|
|
39
|
+
|
|
40
|
+
const LayoutLeftSidebarUI = uic('div', {
|
|
41
|
+
baseClass: 'flex-col lg:border-r bg-neutral-50 border-r-gray-300 lg:w-96 flex-auto gap-2 relative rounded-l-xl',
|
|
42
|
+
variants: {
|
|
43
|
+
visibility: {
|
|
44
|
+
show: 'flex',
|
|
45
|
+
hidden: 'hidden',
|
|
46
|
+
auto: 'hidden lg:flex',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
defaultVariants: {
|
|
50
|
+
visibility: 'auto',
|
|
51
|
+
},
|
|
52
|
+
})
|
|
53
|
+
const LayoutRightSidebarUI = uic('div', {
|
|
54
|
+
baseClass: ' flex-col p-4 pt-6 gap-2 lg:border-l border-l-gray-300 lg:w-96 flex-auto relative',
|
|
55
|
+
variants: {
|
|
56
|
+
visibility: {
|
|
57
|
+
show: 'flex',
|
|
58
|
+
hidden: 'hidden',
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
defaultVariants: {
|
|
62
|
+
visibility: 'show',
|
|
63
|
+
},
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
const LayoutTitleUI = uic('h1', { baseClass: 'text-2xl font-bold' })
|
|
67
|
+
|
|
68
|
+
const LayoutFooterUI = uic('div', { baseClass: 'flex justify-end mt-2 mx-4' })
|
|
69
|
+
|
|
70
|
+
const LayoutLeftPanelCloserUI = uic('a', { baseClass: 'hidden lg:flex self-end absolute top-1 right-1 opacity-0 text-gray-400 hover:opacity-100 transition-opacity cursor-pointer' })
|
|
71
|
+
const LayoutLeftPanelOpenerUI = uic('a', { baseClass: 'hidden lg:block absolute top-1 left-1' })
|
|
72
|
+
const LayoutRightPanelCloserUI = uic('a', { baseClass: 'hidden lg:flex self-end absolute top-1 right-1 opacity-0 text-gray-400 hover:opacity-100 transition-opacity cursor-pointer' })
|
|
73
|
+
const LayoutRightPanelOpenerUI = uic('a', { baseClass: 'absolute top-1 right-1' })
|
|
74
|
+
const LayoutSwitcherUI = uic('a', { baseClass: 'hidden lg:flex self-end absolute top-1 right-1 opacity-20 text-gray-400 hover:opacity-100 transition-opacity cursor-pointer' })
|
|
75
|
+
const LayoutContentWrapperUI = uic('div', { baseClass: 'flex flex-col gap-12' })
|
|
76
|
+
|
|
77
|
+
export const LayoutBoxedComponent = ({ children, ...rest }: PropsWithChildren<{}>) => {
|
|
78
|
+
const isActive = useHasActiveSlotsFactory()
|
|
79
|
+
|
|
80
|
+
const [leftSidebarVisibility, setLeftSidebarVisibility] = useState<'show' | 'hidden' | 'auto'>('auto')
|
|
81
|
+
const [layout, setLayout] = useStoredState<'default' | 'stretch'>('local', ['', 'layout'], it => it ?? 'default')
|
|
82
|
+
|
|
83
|
+
const request = useCurrentRequest()
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
setLeftSidebarVisibility(it => it === 'show' ? 'auto' : it)
|
|
86
|
+
}, [request])
|
|
87
|
+
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
window.scrollTo({ top: 0 })
|
|
90
|
+
}, [request?.pageName])
|
|
91
|
+
|
|
92
|
+
const [rightSidebarVisibility, setRightSidebarVisibility] = useState<'show' | 'hidden'>('show')
|
|
93
|
+
|
|
94
|
+
const hasRightSidebar = isActive('SidebarRightHeader', 'SidebarRightBody', 'SidebarRightFooter', 'Sidebar')
|
|
95
|
+
return (
|
|
96
|
+
<SidebarProvider>
|
|
97
|
+
<LayoutBodyUI>
|
|
98
|
+
<LayoutSwitcherUI className="absolute top-0.5 right-0.5" onClick={() => setLayout(it => it === 'default' ? 'stretch' : 'default')}>
|
|
99
|
+
{layout === 'default' ? <Maximize2Icon /> : <Minimize2Icon />}
|
|
100
|
+
</LayoutSwitcherUI>
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
<LayoutMaxWidthUI layout={layout}>
|
|
104
|
+
<LayoutBoxUI>
|
|
105
|
+
{leftSidebarVisibility === 'hidden' && (
|
|
106
|
+
<LayoutLeftPanelOpenerUI onClick={() => setLeftSidebarVisibility('auto')}>
|
|
107
|
+
<PanelLeftOpenIcon className="w-4 h-4" />
|
|
108
|
+
</LayoutLeftPanelOpenerUI>
|
|
109
|
+
)}
|
|
110
|
+
{hasRightSidebar && rightSidebarVisibility === 'hidden' ? (
|
|
111
|
+
<LayoutRightPanelOpenerUI onClick={() => setRightSidebarVisibility('show')}>
|
|
112
|
+
<PanelRightOpenIcon className="w-4 h-4" />
|
|
113
|
+
</LayoutRightPanelOpenerUI>
|
|
114
|
+
) : null}
|
|
115
|
+
|
|
116
|
+
<LayoutLeftSidebarUI visibility={leftSidebarVisibility}>
|
|
117
|
+
|
|
118
|
+
<LayoutLeftPanelCloserUI onClick={() => setLeftSidebarVisibility('hidden')}>
|
|
119
|
+
<PanelLeftCloseIcon className="w-4 h-4" />
|
|
120
|
+
</LayoutLeftPanelCloserUI>
|
|
121
|
+
|
|
122
|
+
<div className={'p-4 flex gap-2'}>
|
|
123
|
+
<SlotTargets.Logo />
|
|
124
|
+
</div>
|
|
125
|
+
|
|
126
|
+
<div className="px-4">
|
|
127
|
+
<SlotTargets.Navigation />
|
|
128
|
+
</div>
|
|
129
|
+
|
|
130
|
+
<div className={'mt-auto rounded-bl py-2 px-2 border-t'}>
|
|
131
|
+
<LogoutTrigger>
|
|
132
|
+
<Button variant={'ghost'} size="sm" className="gap-2 hover:underline">
|
|
133
|
+
<LogOutIcon className="w-3 h-3 text-gray-500" /> {dict.logout}
|
|
134
|
+
</Button>
|
|
135
|
+
</LogoutTrigger>
|
|
136
|
+
</div>
|
|
137
|
+
|
|
138
|
+
</LayoutLeftSidebarUI>
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
<LayoutCenterPanelUI>
|
|
142
|
+
<LayoutCenterTopUI>
|
|
143
|
+
<div className={'flex gap-2'}>
|
|
144
|
+
<SlotTargets.Back />
|
|
145
|
+
<SlotTargets.Title as={LayoutTitleUI} />
|
|
146
|
+
</div>
|
|
147
|
+
<SlotTargets.ContentHeader />
|
|
148
|
+
<div className={'flex gap-2'}>
|
|
149
|
+
<SlotTargets.Actions />
|
|
150
|
+
<div className={'flex flex-col lg:hidden p-4 gap-2 w-full flex-auto'}>
|
|
151
|
+
<a onClick={() => setLeftSidebarVisibility(it => it !== 'show' ? 'show' : 'auto')}><MenuIcon /></a>
|
|
152
|
+
</div>
|
|
153
|
+
</div>
|
|
154
|
+
</LayoutCenterTopUI>
|
|
155
|
+
|
|
156
|
+
<LayoutContentWrapperUI>
|
|
157
|
+
{children}
|
|
158
|
+
</LayoutContentWrapperUI>
|
|
159
|
+
</LayoutCenterPanelUI>
|
|
160
|
+
{hasRightSidebar ?
|
|
161
|
+
<LayoutRightSidebarUI visibility={rightSidebarVisibility ? 'show' : 'hidden'}>
|
|
162
|
+
<LayoutRightPanelCloserUI onClick={() => setRightSidebarVisibility('hidden')}>
|
|
163
|
+
<PanelRightCloseIcon />
|
|
164
|
+
</LayoutRightPanelCloserUI>
|
|
165
|
+
<div>
|
|
166
|
+
<SlotTargets.Sidebar />
|
|
167
|
+
</div>
|
|
168
|
+
</LayoutRightSidebarUI>
|
|
169
|
+
: null
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
</LayoutBoxUI>
|
|
173
|
+
|
|
174
|
+
<LayoutFooterUI>
|
|
175
|
+
<div>
|
|
176
|
+
<SlotTargets.Footer />
|
|
177
|
+
</div>
|
|
178
|
+
</LayoutFooterUI>
|
|
179
|
+
</LayoutMaxWidthUI>
|
|
180
|
+
</LayoutBodyUI>
|
|
181
|
+
</SidebarProvider>
|
|
182
|
+
)
|
|
183
|
+
}
|
|
184
|
+
LayoutBoxedComponent.displayName = 'LayoutBoxed'
|