dinocollab-core 1.0.0
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/README.md +54 -0
- package/dist/_virtual/_rollupPluginBabelHelpers.js +431 -0
- package/dist/_virtual/_rollupPluginBabelHelpers.js.map +1 -0
- package/dist/assets/vector-404265a04f4f9c8be1f.webp +0 -0
- package/dist/node_modules/.pnpm/@rollup_plugin-typescript@1_d0d2002d9033600b6738d939bd598bc6/node_modules/tslib/tslib.es6.js +46 -0
- package/dist/node_modules/.pnpm/@rollup_plugin-typescript@1_d0d2002d9033600b6738d939bd598bc6/node_modules/tslib/tslib.es6.js.map +1 -0
- package/dist/src/api-context/alert-global.js +151 -0
- package/dist/src/api-context/alert-global.js.map +1 -0
- package/dist/src/api-context/drawer-global.js +105 -0
- package/dist/src/api-context/drawer-global.js.map +1 -0
- package/dist/src/api-context/global-modal.js +87 -0
- package/dist/src/api-context/global-modal.js.map +1 -0
- package/dist/src/api-context/popover-global.js +102 -0
- package/dist/src/api-context/popover-global.js.map +1 -0
- package/dist/src/api-context/popover.js +86 -0
- package/dist/src/api-context/popover.js.map +1 -0
- package/dist/src/api-context/ui.units.js +21 -0
- package/dist/src/api-context/ui.units.js.map +1 -0
- package/dist/src/components/copy-to-clipboard.js +105 -0
- package/dist/src/components/copy-to-clipboard.js.map +1 -0
- package/dist/src/components/custom.breadcrumbs.js +61 -0
- package/dist/src/components/custom.breadcrumbs.js.map +1 -0
- package/dist/src/components/help-tooltip.js +91 -0
- package/dist/src/components/help-tooltip.js.map +1 -0
- package/dist/src/components/image-with-fallback.js +48 -0
- package/dist/src/components/image-with-fallback.js.map +1 -0
- package/dist/src/components/text-editor.js +117 -0
- package/dist/src/components/text-editor.js.map +1 -0
- package/dist/src/form/create.autocomplete.chips.js +218 -0
- package/dist/src/form/create.autocomplete.chips.js.map +1 -0
- package/dist/src/form/create.date-expired.js +201 -0
- package/dist/src/form/create.date-expired.js.map +1 -0
- package/dist/src/form/create.date-picker.js +125 -0
- package/dist/src/form/create.date-picker.js.map +1 -0
- package/dist/src/form/create.form-base.js +135 -0
- package/dist/src/form/create.form-base.js.map +1 -0
- package/dist/src/form/create.form-comfirm.js +119 -0
- package/dist/src/form/create.form-comfirm.js.map +1 -0
- package/dist/src/form/create.form-grid-layout.js +177 -0
- package/dist/src/form/create.form-grid-layout.js.map +1 -0
- package/dist/src/form/create.form-grid-layout.units.js +39 -0
- package/dist/src/form/create.form-grid-layout.units.js.map +1 -0
- package/dist/src/form/create.input-base.js +260 -0
- package/dist/src/form/create.input-base.js.map +1 -0
- package/dist/src/form/create.input.file.js +74 -0
- package/dist/src/form/create.input.file.js.map +1 -0
- package/dist/src/form/create.select-simple.js +104 -0
- package/dist/src/form/create.select-simple.js.map +1 -0
- package/dist/src/form/create.select-with-api.js +271 -0
- package/dist/src/form/create.select-with-api.js.map +1 -0
- package/dist/src/form/create.text-editor.js +156 -0
- package/dist/src/form/create.text-editor.js.map +1 -0
- package/dist/src/form/dino-form.js +42 -0
- package/dist/src/form/dino-form.js.map +1 -0
- package/dist/src/form/helper.js +157 -0
- package/dist/src/form/helper.js.map +1 -0
- package/dist/src/form/modal-wrapper.js +75 -0
- package/dist/src/form/modal-wrapper.js.map +1 -0
- package/dist/src/form/validator.js +186 -0
- package/dist/src/form/validator.js.map +1 -0
- package/dist/src/hooks/index.js +48 -0
- package/dist/src/hooks/index.js.map +1 -0
- package/dist/src/index.js +26 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/redux/create.hoc-lazy.js +67 -0
- package/dist/src/redux/create.hoc-lazy.js.map +1 -0
- package/dist/src/redux/dino.js +11 -0
- package/dist/src/redux/dino.js.map +1 -0
- package/dist/src/redux/types.js +9 -0
- package/dist/src/redux/types.js.map +1 -0
- package/dist/src/redux/ui.error-page.js +80 -0
- package/dist/src/redux/ui.error-page.js.map +1 -0
- package/dist/src/redux/vector-404.webp.js +4 -0
- package/dist/src/redux/vector-404.webp.js.map +1 -0
- package/dist/src/table/context.js +12 -0
- package/dist/src/table/context.js.map +1 -0
- package/dist/src/table/create.action-row.js +135 -0
- package/dist/src/table/create.action-row.js.map +1 -0
- package/dist/src/table/create.status-cell.js +49 -0
- package/dist/src/table/create.status-cell.js.map +1 -0
- package/dist/src/table/create.table.js +233 -0
- package/dist/src/table/create.table.js.map +1 -0
- package/dist/src/table/custom.filter-operators.js +89 -0
- package/dist/src/table/custom.filter-operators.js.map +1 -0
- package/dist/src/table/dino.js +129 -0
- package/dist/src/table/dino.js.map +1 -0
- package/dist/src/table/helpers.js +116 -0
- package/dist/src/table/helpers.js.map +1 -0
- package/dist/src/table/model-filter.js +23 -0
- package/dist/src/table/model-filter.js.map +1 -0
- package/dist/src/table/toolbar-pannel.js +134 -0
- package/dist/src/table/toolbar-pannel.js.map +1 -0
- package/dist/src/table/ui.buttons.js +60 -0
- package/dist/src/table/ui.buttons.js.map +1 -0
- package/dist/src/table/ui.units.js +201 -0
- package/dist/src/table/ui.units.js.map +1 -0
- package/dist/src/utils/dayjs-config.js +12 -0
- package/dist/src/utils/dayjs-config.js.map +1 -0
- package/dist/src/utils/helpers.js +197 -0
- package/dist/src/utils/helpers.js.map +1 -0
- package/dist/src/utils/json-object.js +38 -0
- package/dist/src/utils/json-object.js.map +1 -0
- package/dist/src/utils/query-param.js +172 -0
- package/dist/src/utils/query-param.js.map +1 -0
- package/package.json +52 -0
- package/rollup.config.js +39 -0
- package/src/@types/global.d.ts +5 -0
- package/src/api-context/alert-global.tsx +174 -0
- package/src/api-context/drawer-global.tsx +116 -0
- package/src/api-context/global-modal.tsx +109 -0
- package/src/api-context/index.ts +13 -0
- package/src/api-context/popover-global.tsx +107 -0
- package/src/api-context/popover.tsx +89 -0
- package/src/api-context/ui.units.tsx +10 -0
- package/src/components/copy-to-clipboard.tsx +86 -0
- package/src/components/custom.breadcrumbs.tsx +67 -0
- package/src/components/help-tooltip.tsx +75 -0
- package/src/components/image-with-fallback.tsx +51 -0
- package/src/components/index.tsx +1 -0
- package/src/components/input-debounce-timer.tsx +138 -0
- package/src/components/loading-buttons.tsx +35 -0
- package/src/components/text-editor.preview.tsx +30 -0
- package/src/components/text-editor.tsx +125 -0
- package/src/form/README.md +55 -0
- package/src/form/create.autocomplete.chips.tsx +199 -0
- package/src/form/create.date-expired.tsx +195 -0
- package/src/form/create.date-picker.tsx +122 -0
- package/src/form/create.form-base.tsx +102 -0
- package/src/form/create.form-comfirm.tsx +83 -0
- package/src/form/create.form-grid-layout.tsx +170 -0
- package/src/form/create.form-grid-layout.units.tsx +37 -0
- package/src/form/create.input-base.tsx +222 -0
- package/src/form/create.input.file.tsx +76 -0
- package/src/form/create.select-simple.tsx +101 -0
- package/src/form/create.select-with-api.tsx +213 -0
- package/src/form/create.text-editor.tsx +161 -0
- package/src/form/dino-form.tsx +40 -0
- package/src/form/helper.ts +132 -0
- package/src/form/index.ts +12 -0
- package/src/form/modal-wrapper.tsx +75 -0
- package/src/form/types.ts +16 -0
- package/src/form/validator.ts +202 -0
- package/src/hooks/index.ts +44 -0
- package/src/index.ts +7 -0
- package/src/lab/create.autocomplete.simple.tsx +57 -0
- package/src/lab/create.dino-store.ts +59 -0
- package/src/lab/create.multi-select-dropdown.tsx +189 -0
- package/src/lab/create.select-mul-with-api/index.tsx +271 -0
- package/src/lab/create.select-mul-with-api/table-custom.tsx +194 -0
- package/src/lab/create.select-mul-with-api/types.ts +26 -0
- package/src/lab/create.select-mul-with-api/ui.units.tsx +163 -0
- package/src/lab/filter-bar/base.tsx +162 -0
- package/src/lab/filter-bar/create.filter-bar.tsx +190 -0
- package/src/lab/filter-bar/create.filter-menu.tsx +156 -0
- package/src/lab/filter-bar/create.filter-panel.tsx +95 -0
- package/src/lab/filter-bar/create.filtered.tsx +41 -0
- package/src/lab/filter-bar/create.sort-menu.tsx +43 -0
- package/src/lab/filter-bar/demo.tsx +50 -0
- package/src/lab/filter-bar/index.ts +6 -0
- package/src/lab/filter-bar/types.ts +105 -0
- package/src/lab/filter-bar/ui.units.tsx +70 -0
- package/src/lab/grafana-dashboard/configs.ts +43 -0
- package/src/lab/grafana-dashboard/date-time-range/absolute-time-rage.tsx +137 -0
- package/src/lab/grafana-dashboard/date-time-range/helpers.ts +126 -0
- package/src/lab/grafana-dashboard/date-time-range/index.tsx +62 -0
- package/src/lab/grafana-dashboard/date-time-range/menu-wrap.tsx +101 -0
- package/src/lab/grafana-dashboard/date-time-range/quick-ranges.tsx +161 -0
- package/src/lab/grafana-dashboard/date-time-range/types.ts +9 -0
- package/src/lab/grafana-dashboard/date-time-range/units.tsx +18 -0
- package/src/lab/grafana-dashboard/helper.ts +25 -0
- package/src/lab/grafana-dashboard/hooks.tsx +79 -0
- package/src/lab/grafana-dashboard/icons.tsx +67 -0
- package/src/lab/grafana-dashboard/index.tsx +120 -0
- package/src/lab/grafana-dashboard/top-bar.tsx +62 -0
- package/src/lab/grafana-dashboard/top-bar.types.ts +5 -0
- package/src/lab/grafana-dashboard/types.ts +8 -0
- package/src/lab/media-player.core1.tsx +273 -0
- package/src/lab/media-player.muted.tsx +62 -0
- package/src/lab/media-player.units.ts +80 -0
- package/src/lab/table-grid/create.table-grid.tsx +183 -0
- package/src/lab/table-grid/demo.tsx +53 -0
- package/src/lab/table-grid/dino.tsx +8 -0
- package/src/lab/table-grid/helpers.tsx +11 -0
- package/src/lab/table-grid/index.ts +3 -0
- package/src/lab/table-grid/item-actions.tsx +138 -0
- package/src/lab/table-grid/toolbar-pannel.tsx +98 -0
- package/src/lab/table-grid/types.ts +68 -0
- package/src/redux/create.hoc-lazy.tsx +80 -0
- package/src/redux/dino.ts +9 -0
- package/src/redux/index.ts +6 -0
- package/src/redux/types.ts +27 -0
- package/src/redux/ui.error-page.tsx +62 -0
- package/src/redux/ui.units.tsx +41 -0
- package/src/redux/vector-404.webp +0 -0
- package/src/table/context.tsx +16 -0
- package/src/table/create.action-row.tsx +91 -0
- package/src/table/create.status-cell.tsx +51 -0
- package/src/table/create.table.tsx +239 -0
- package/src/table/custom.filter-operators.ts +94 -0
- package/src/table/dino.tsx +120 -0
- package/src/table/helpers.ts +94 -0
- package/src/table/index.ts +13 -0
- package/src/table/model-filter.ts +43 -0
- package/src/table/toolbar-pannel.tsx +106 -0
- package/src/table/types.ts +50 -0
- package/src/table/ui.buttons.tsx +54 -0
- package/src/table/ui.units.tsx +189 -0
- package/src/utils/dayjs-config.ts +13 -0
- package/src/utils/helpers.ts +171 -0
- package/src/utils/index.ts +7 -0
- package/src/utils/json-object.ts +29 -0
- package/src/utils/mfe-events.tsx +34 -0
- package/src/utils/query-param.ts +129 -0
- package/tsconfig.json +20 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React, { Component } from 'react'
|
|
2
|
+
import { SxProps, Theme, Typography, TypographyProps, styled } from '@mui/material'
|
|
3
|
+
|
|
4
|
+
export type StatusCellConfig<T extends string> = { [key in T]: SxProps<Theme> }
|
|
5
|
+
|
|
6
|
+
export interface StatusCellOptions {
|
|
7
|
+
sx?: SxProps<Theme>
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface StatusCellProps<T extends string> {
|
|
11
|
+
value?: T
|
|
12
|
+
title?: string
|
|
13
|
+
sx?: SxProps<Theme>
|
|
14
|
+
onClick?: TypographyProps['onClick']
|
|
15
|
+
slots?: {
|
|
16
|
+
typographyProps?: TypographyProps
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
const CreateStatusCell = function <T extends string>(config: StatusCellConfig<T>, options?: StatusCellOptions) {
|
|
22
|
+
class StatusCell extends Component<React.PropsWithChildren<StatusCellProps<T>>> {
|
|
23
|
+
render() {
|
|
24
|
+
if (!this.props.value) return <></>
|
|
25
|
+
return (
|
|
26
|
+
<CustomTypography onClick={this.props.onClick} {...this.props.slots?.typographyProps} sx={this.getSxProps()}>
|
|
27
|
+
{this.props.title || this.props.value}
|
|
28
|
+
</CustomTypography>
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
getSxProps = (): SxProps<Theme> => {
|
|
33
|
+
const { value: data, sx, slots } = this.props
|
|
34
|
+
return Object.assign({}, data ? config[data] : {}, options?.sx, sx, slots?.typographyProps?.sx)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return StatusCell
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default CreateStatusCell
|
|
41
|
+
|
|
42
|
+
const CustomTypography = styled(Typography)({
|
|
43
|
+
borderRadius: '4px',
|
|
44
|
+
fontSize: '0.8rem',
|
|
45
|
+
padding: '4px 9px',
|
|
46
|
+
fontWeight: 600,
|
|
47
|
+
minWidth: '70px',
|
|
48
|
+
textAlign: 'center',
|
|
49
|
+
color: '#ffffff',
|
|
50
|
+
display: 'inline-block'
|
|
51
|
+
})
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import React, { Component } from 'react'
|
|
2
|
+
import { Box, BoxProps, styled } from '@mui/material'
|
|
3
|
+
import { DataGrid, DataGridProps, GridColDef, GridFeatureMode, GridFilterOperator } from '@mui/x-data-grid'
|
|
4
|
+
import { GridSortModel, GridValidRowModel, GridRowIdGetter, GridRowSelectionModel } from '@mui/x-data-grid'
|
|
5
|
+
import { GridCallbackDetails, GridColumnVisibilityModel, GridDensity, GridFilterModel, GridPaginationModel } from '@mui/x-data-grid'
|
|
6
|
+
import { mergeObjects } from '../utils'
|
|
7
|
+
import { TableBaseContext } from './context'
|
|
8
|
+
import { IActionRowProps } from './create.action-row'
|
|
9
|
+
import { CustomFilterOperators } from './custom.filter-operators'
|
|
10
|
+
import { GlobalModal, MapGlobalModalContext } from '../api-context'
|
|
11
|
+
import { CustomGridColDef, CustomGridFilterModel, CustomGridSortModel, TableData, TableQueryParams } from './types'
|
|
12
|
+
import ToolbarPannel, { IToolbarPannelProps } from './toolbar-pannel'
|
|
13
|
+
import TableHelper, { dinoTableClasses } from './helpers'
|
|
14
|
+
|
|
15
|
+
interface TableSlots<T> {
|
|
16
|
+
maxSelection?: number
|
|
17
|
+
density?: GridDensity
|
|
18
|
+
toolbar?: React.ComponentType<IToolbarPannelProps>
|
|
19
|
+
actionRow?: React.ComponentType<IActionRowProps<T>>
|
|
20
|
+
toolbarProps?: IToolbarPannelProps
|
|
21
|
+
dataGridProps?: DataGridProps
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
type TableParamsSlots<T> = Pick<TableSlots<T>, 'maxSelection' | 'toolbarProps' | 'dataGridProps'>
|
|
25
|
+
|
|
26
|
+
interface TableProps<T> {
|
|
27
|
+
data?: TableData<T>
|
|
28
|
+
query?: TableQueryParams<T>
|
|
29
|
+
onChange?: (query: TableQueryParams<T>) => void
|
|
30
|
+
onRowSelectionChange?: DataGridProps['onRowSelectionModelChange']
|
|
31
|
+
slots?: TableSlots<T>
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface TableParams<T extends GridValidRowModel> extends TableParamsSlots<T> {
|
|
35
|
+
featureMode?: GridFeatureMode
|
|
36
|
+
getRowId: GridRowIdGetter<T>
|
|
37
|
+
columns: CustomGridColDef<T>
|
|
38
|
+
filterOperators?: (config: GridColDef) => GridFilterOperator[]
|
|
39
|
+
columnVisibilityModel?: Partial<Record<keyof T, boolean>>
|
|
40
|
+
actionRow?: Omit<GridColDef, 'field'>
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function CreateTable<T extends GridValidRowModel>(params: TableParams<T>) {
|
|
44
|
+
const generateColumns = (extendColDefs?: GridColDef[]) => {
|
|
45
|
+
const columns = Object.keys(params.columns).map<GridColDef>((key) => {
|
|
46
|
+
const obj = { field: key, ...params.columns[key] }
|
|
47
|
+
obj.filterOperators = params.filterOperators ? params.filterOperators(obj) : CustomFilterOperators(obj)
|
|
48
|
+
return obj
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
if (!!extendColDefs && extendColDefs.length > 0) columns.push(...extendColDefs)
|
|
52
|
+
return columns
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
class TableBase extends Component<TableProps<T>> {
|
|
56
|
+
private tableQueryParams: TableQueryParams<T>
|
|
57
|
+
private tableQueryParamsCache: TableQueryParams<T> = {}
|
|
58
|
+
private defaultTableQueryParams: TableQueryParams<T>
|
|
59
|
+
private columns: GridColDef<T>[]
|
|
60
|
+
private rowSelecteds: GridRowSelectionModel
|
|
61
|
+
constructor(props: TableProps<T>) {
|
|
62
|
+
super(props)
|
|
63
|
+
this.columns = this.initialColumns()
|
|
64
|
+
this.tableQueryParams = { ...props.query }
|
|
65
|
+
this.defaultTableQueryParams = this.tableQueryParams
|
|
66
|
+
this.rowSelecteds = []
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
get mergeConfig() {
|
|
70
|
+
const toolbarPannelProps = mergeObjects({}, params?.toolbarProps, this.props.slots?.toolbarProps)
|
|
71
|
+
return {
|
|
72
|
+
toolbar: this.props.slots?.toolbar ?? (() => <ToolbarPannel {...toolbarPannelProps} />),
|
|
73
|
+
ActionRow: this.props.slots?.actionRow,
|
|
74
|
+
columnVisibilityModel: params.columnVisibilityModel,
|
|
75
|
+
maxSelcion: this.props.slots?.maxSelection ?? params.maxSelection,
|
|
76
|
+
dataGridProps: mergeObjects({}, params.dataGridProps, this.props.slots?.dataGridProps)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
setTableQueryParams = (value: Partial<TableQueryParams<T>>) => {
|
|
81
|
+
this.tableQueryParams = mergeObjects({}, this.tableQueryParams, value)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
shouldComponentUpdate(nextProps: Readonly<TableProps<T>>): boolean {
|
|
85
|
+
if (params.featureMode === 'server' && !TableHelper.equalTableQueryParams(nextProps.query, this.props.query)) {
|
|
86
|
+
this.setTableQueryParams(nextProps.query ?? {})
|
|
87
|
+
return true
|
|
88
|
+
} else if (params.featureMode !== 'server') {
|
|
89
|
+
return true
|
|
90
|
+
} else {
|
|
91
|
+
return false
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
render() {
|
|
96
|
+
return this.renderWrapContext(
|
|
97
|
+
<Wrap>
|
|
98
|
+
<DataGrid {...this.getDataGridProps()} />
|
|
99
|
+
</Wrap>
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
renderWrapContext = (children: React.ReactNode) => (
|
|
104
|
+
<GlobalModal>
|
|
105
|
+
{MapGlobalModalContext((context) => (
|
|
106
|
+
<TableBaseContext.Provider value={{ showModal: context.show, closeModal: context.close }}>{children}</TableBaseContext.Provider>
|
|
107
|
+
))}
|
|
108
|
+
</GlobalModal>
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
getDataGridProps = (): DataGridProps<T> => {
|
|
112
|
+
const mergeConfig = this.mergeConfig
|
|
113
|
+
const obj: DataGridProps<T> = {
|
|
114
|
+
getRowId: params.getRowId,
|
|
115
|
+
columns: this.columns,
|
|
116
|
+
rows: this.props.data?.items ?? [],
|
|
117
|
+
checkboxSelection: true,
|
|
118
|
+
pagination: true,
|
|
119
|
+
density: this.props.slots?.density ?? 'standard',
|
|
120
|
+
initialState: TableHelper.mapInitialState(this.props.query, {
|
|
121
|
+
columns: { columnVisibilityModel: params.columnVisibilityModel as GridColumnVisibilityModel }
|
|
122
|
+
}),
|
|
123
|
+
filterDebounceMs: 800,
|
|
124
|
+
sx: { border: 0 },
|
|
125
|
+
slots: { toolbar: mergeConfig.toolbar },
|
|
126
|
+
rowSelectionModel: this.rowSelecteds,
|
|
127
|
+
onRowSelectionModelChange: this.handleRowSelectionChange
|
|
128
|
+
}
|
|
129
|
+
if (params.featureMode === 'server') {
|
|
130
|
+
const objServer: Partial<DataGridProps<T>> = {
|
|
131
|
+
filterMode: 'server',
|
|
132
|
+
sortingMode: 'server',
|
|
133
|
+
paginationMode: 'server',
|
|
134
|
+
onPaginationModelChange: this.onPaginationModelChange,
|
|
135
|
+
onFilterModelChange: this.onFilterModelChange,
|
|
136
|
+
onSortModelChange: this.onSortModelChange,
|
|
137
|
+
rowCount: this.props.data?.rowTotal ?? 0,
|
|
138
|
+
paginationModel: this.tableQueryParams.pagination,
|
|
139
|
+
filterModel: this.tableQueryParams.filter as GridFilterModel,
|
|
140
|
+
sortModel: TableHelper.mapSortModel(this.tableQueryParams.sort),
|
|
141
|
+
loading: this.tableQueryParams.loading
|
|
142
|
+
}
|
|
143
|
+
Object.assign(obj, objServer)
|
|
144
|
+
}
|
|
145
|
+
return mergeObjects(obj, this.mergeConfig.dataGridProps)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
initialColumns = (): GridColDef<T>[] => {
|
|
149
|
+
const { ActionRow } = this.mergeConfig
|
|
150
|
+
const list: GridColDef<T>[] = []
|
|
151
|
+
if (!!ActionRow) {
|
|
152
|
+
list.push({
|
|
153
|
+
field: 'Actions',
|
|
154
|
+
minWidth: 100,
|
|
155
|
+
headerAlign: 'right',
|
|
156
|
+
align: 'right',
|
|
157
|
+
filterable: false,
|
|
158
|
+
sortable: false,
|
|
159
|
+
renderCell: (value) => <ActionRow value={value.row} />,
|
|
160
|
+
...params.actionRow
|
|
161
|
+
})
|
|
162
|
+
}
|
|
163
|
+
return generateColumns(list)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
onPaginationModelChange = (model: GridPaginationModel, details: GridCallbackDetails<'pagination'>) => {
|
|
167
|
+
this.setTableQueryParams({ pagination: model, detail: 'pagination' })
|
|
168
|
+
this.handleChange()
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
onFilterModelChange = (model: GridFilterModel, details: GridCallbackDetails<'filter'>) => {
|
|
172
|
+
const { pagination } = this.tableQueryParams
|
|
173
|
+
this.setTableQueryParams({
|
|
174
|
+
filter: model as CustomGridFilterModel<T>,
|
|
175
|
+
pagination: { page: 0, pageSize: pagination?.pageSize ?? 25 },
|
|
176
|
+
detail: TableHelper.detectSearchType(model)
|
|
177
|
+
})
|
|
178
|
+
this.handleChange()
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
onSortModelChange = (model: GridSortModel, details: GridCallbackDetails<any>) => {
|
|
182
|
+
let sortValue = model as CustomGridSortModel<T>
|
|
183
|
+
const { sort } = this.tableQueryParams
|
|
184
|
+
if (!!sort?.length && !sortValue.length) {
|
|
185
|
+
if (sort?.[0]?.field === this.defaultTableQueryParams.sort?.[0]?.field) {
|
|
186
|
+
sortValue = [{ field: sort[0]?.field, sort: sort[0]?.sort === 'desc' ? 'asc' : 'desc' }]
|
|
187
|
+
} else {
|
|
188
|
+
sortValue = this.defaultTableQueryParams.sort ?? []
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
this.setTableQueryParams({ sort: sortValue, detail: 'sort' })
|
|
192
|
+
this.handleChange()
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
handleChange = () => {
|
|
196
|
+
const check = TableHelper.isEmpty(this.tableQueryParams)
|
|
197
|
+
const checkCache = TableHelper.isEmpty(this.tableQueryParamsCache)
|
|
198
|
+
const isChange = this.props.onChange && this.props.onChange(this.tableQueryParams)
|
|
199
|
+
this.tableQueryParamsCache = this.tableQueryParams
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
handleRowSelectionChange = (value: GridRowSelectionModel, details: GridCallbackDetails) => {
|
|
203
|
+
if (this.mergeConfig.maxSelcion && value.length > this.mergeConfig.maxSelcion) {
|
|
204
|
+
this.rowSelecteds = value.slice(0, this.mergeConfig.maxSelcion)
|
|
205
|
+
} else {
|
|
206
|
+
this.rowSelecteds = value
|
|
207
|
+
}
|
|
208
|
+
this.props.onRowSelectionChange && this.props.onRowSelectionChange(this.rowSelecteds, details)
|
|
209
|
+
this.forceUpdate()
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return TableBase
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export default CreateTable
|
|
217
|
+
|
|
218
|
+
const Wrap = styled(({ children, ...p }: BoxProps) => (
|
|
219
|
+
<Box {...p}>
|
|
220
|
+
<div>{children}</div>
|
|
221
|
+
</Box>
|
|
222
|
+
))({
|
|
223
|
+
flex: 1,
|
|
224
|
+
position: 'relative',
|
|
225
|
+
'& > div': {
|
|
226
|
+
position: 'absolute',
|
|
227
|
+
top: 0,
|
|
228
|
+
left: 0,
|
|
229
|
+
width: '100%',
|
|
230
|
+
height: '100%',
|
|
231
|
+
overflowY: 'auto'
|
|
232
|
+
},
|
|
233
|
+
'& .MuiDataGrid-root': {
|
|
234
|
+
'--unstable_DataGrid-radius': 0
|
|
235
|
+
},
|
|
236
|
+
[`& .MuiDataGrid-cell.${dinoTableClasses.whiteSpacePre} .MuiDataGrid-cellContent`]: {
|
|
237
|
+
whiteSpace: 'pre'
|
|
238
|
+
}
|
|
239
|
+
})
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { getGridBooleanOperators, getGridDateOperators, getGridNumericOperators, getGridStringOperators, GridColDef } from '@mui/x-data-grid'
|
|
2
|
+
import { EOperator } from './model-filter'
|
|
3
|
+
|
|
4
|
+
const StringMap = {
|
|
5
|
+
contains: EOperator.Contains,
|
|
6
|
+
equals: EOperator.Equal
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const NumericMap = {
|
|
10
|
+
'=': EOperator.Equal,
|
|
11
|
+
'!=': EOperator.NotEqual,
|
|
12
|
+
'>': EOperator.GreaterThan,
|
|
13
|
+
'>=': EOperator.GreaterThanOrEqual,
|
|
14
|
+
'<': EOperator.LessThan,
|
|
15
|
+
'<=': EOperator.LessThanOrEqual
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const BooleanMap = {
|
|
19
|
+
'is=': EOperator.Equal
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const DateMap = {
|
|
23
|
+
is: EOperator.Equal,
|
|
24
|
+
not: EOperator.NotEqual,
|
|
25
|
+
after: EOperator.GreaterThan,
|
|
26
|
+
onOrAfter: EOperator.GreaterThanOrEqual,
|
|
27
|
+
before: EOperator.LessThan,
|
|
28
|
+
onOrBefore: EOperator.LessThanOrEqual
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const getCustomGridStringOperators = () => {
|
|
32
|
+
const keys = new Set(Object.keys(StringMap))
|
|
33
|
+
const options = getGridStringOperators()
|
|
34
|
+
.filter((x) => keys.has(x.value))
|
|
35
|
+
.map((x) => {
|
|
36
|
+
x.label = x.value
|
|
37
|
+
x.value = (StringMap as any)[x.value] + ''
|
|
38
|
+
return x
|
|
39
|
+
})
|
|
40
|
+
return options
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const getCustomGridNumericOperators = () => {
|
|
44
|
+
const keys = new Set(Object.keys(NumericMap))
|
|
45
|
+
const options = getGridNumericOperators()
|
|
46
|
+
.filter((x) => keys.has(x.value))
|
|
47
|
+
.map((x) => {
|
|
48
|
+
x.label = x.value
|
|
49
|
+
x.value = (NumericMap as any)[x.value] + ''
|
|
50
|
+
return x
|
|
51
|
+
})
|
|
52
|
+
return options
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const getCustomGridBooleanOperators = () => {
|
|
56
|
+
const keys = new Set(Object.keys(BooleanMap))
|
|
57
|
+
const options = getGridBooleanOperators()
|
|
58
|
+
.filter((x) => keys.has(x.value))
|
|
59
|
+
.map((x) => {
|
|
60
|
+
x.label = x.value
|
|
61
|
+
x.value = (BooleanMap as any)[x.value] + ''
|
|
62
|
+
return x
|
|
63
|
+
})
|
|
64
|
+
return options
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const getCustomGridDateOperators = (showTime?: boolean) => {
|
|
68
|
+
const keys = new Set(Object.keys(DateMap))
|
|
69
|
+
const options = getGridDateOperators(showTime)
|
|
70
|
+
.filter((x) => keys.has(x.value))
|
|
71
|
+
.map((x) => {
|
|
72
|
+
x.label = x.value
|
|
73
|
+
x.value = (DateMap as any)[x.value] + ''
|
|
74
|
+
return x
|
|
75
|
+
})
|
|
76
|
+
return options
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export const CustomFilterOperators = (option: GridColDef) => {
|
|
80
|
+
switch (option.type) {
|
|
81
|
+
case 'string':
|
|
82
|
+
return getCustomGridStringOperators()
|
|
83
|
+
case 'number':
|
|
84
|
+
return getCustomGridNumericOperators()
|
|
85
|
+
case 'boolean':
|
|
86
|
+
return getCustomGridBooleanOperators()
|
|
87
|
+
case 'date':
|
|
88
|
+
return getCustomGridDateOperators()
|
|
89
|
+
case 'dateTime':
|
|
90
|
+
return getCustomGridDateOperators(true)
|
|
91
|
+
default:
|
|
92
|
+
return getCustomGridStringOperators()
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { FC } from 'react'
|
|
2
|
+
import { GridRenderCellParams, GridTreeNodeWithRender, GridValueFormatterParams } from '@mui/x-data-grid'
|
|
3
|
+
import { dayjsCustom } from '../utils'
|
|
4
|
+
import { MapTableBaseContext } from './context'
|
|
5
|
+
import { BtnDetail, BtnFormDetail } from './ui.buttons'
|
|
6
|
+
import { CellBase, CellImageSmall, CellBaseOptions, CellChips, CellChipsProps, CellDate, CellDatePropsOwner } from './ui.units'
|
|
7
|
+
import ToolbarPannel, { IToolbarPannelProps } from './toolbar-pannel'
|
|
8
|
+
import CustomBreadcrumbs, { CustomBreadcrumbConfig } from '../components/custom.breadcrumbs'
|
|
9
|
+
import CreateStatusCell, { StatusCellOptions, StatusCellConfig } from './create.status-cell'
|
|
10
|
+
import TableHelper from './helpers'
|
|
11
|
+
import CreateTable from './create.table'
|
|
12
|
+
import CreateActionRow from './create.action-row'
|
|
13
|
+
|
|
14
|
+
const formatDateString = 'MM/DD/YYYY HH:mm'
|
|
15
|
+
|
|
16
|
+
type RenderCellBaseParams<T> = Omit<CellBaseOptions, 'imageUrl'> & {
|
|
17
|
+
imageUrl?: (value: any, model: T) => string
|
|
18
|
+
valueFormatter?: (value: any, model: T) => string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface FormatterDateOptions {
|
|
22
|
+
formatString?: string
|
|
23
|
+
showRelative?: boolean
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
class DinoTableBase {
|
|
27
|
+
//#region Base
|
|
28
|
+
|
|
29
|
+
createTable = CreateTable
|
|
30
|
+
|
|
31
|
+
createActionRow = CreateActionRow
|
|
32
|
+
|
|
33
|
+
setUrlQuery = TableHelper.setUrlQuery
|
|
34
|
+
|
|
35
|
+
getUrlQuery = TableHelper.getUrlQuery
|
|
36
|
+
|
|
37
|
+
mapContext = MapTableBaseContext
|
|
38
|
+
|
|
39
|
+
ToolbarPannel = ToolbarPannel
|
|
40
|
+
|
|
41
|
+
createToolbar = (props: IToolbarPannelProps): FC<IToolbarPannelProps> => {
|
|
42
|
+
return (p) => <ToolbarPannel {...{ ...p, ...props }} />
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
BtnFormDetail = BtnFormDetail
|
|
46
|
+
|
|
47
|
+
BtnDetail = BtnDetail
|
|
48
|
+
|
|
49
|
+
createBreadcrumbConfigs = (value: CustomBreadcrumbConfig[]) => value
|
|
50
|
+
|
|
51
|
+
createBreadcrumbs = (value: CustomBreadcrumbConfig[]): FC => {
|
|
52
|
+
return () => <CustomBreadcrumbs value={value} />
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
createStatusCell = CreateStatusCell
|
|
56
|
+
|
|
57
|
+
//#endregion
|
|
58
|
+
|
|
59
|
+
//#region Value Formatter
|
|
60
|
+
formatterDate = (value: any, options?: FormatterDateOptions): string => {
|
|
61
|
+
const f = options?.formatString ?? formatDateString
|
|
62
|
+
const showRelative = options?.showRelative ?? false
|
|
63
|
+
try {
|
|
64
|
+
if (!value) return ''
|
|
65
|
+
|
|
66
|
+
const date = dayjsCustom(value)
|
|
67
|
+
const formatted = date.format(f)
|
|
68
|
+
|
|
69
|
+
return showRelative ? `${formatted} (${dayjsCustom().to(date)})` : formatted
|
|
70
|
+
} catch (error) {
|
|
71
|
+
return ''
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
valueFormatterDate = (options?: FormatterDateOptions) => {
|
|
76
|
+
return (params: GridValueFormatterParams<any>) => this.formatterDate(params.value, options)
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
|
|
80
|
+
//#region Render Cell
|
|
81
|
+
renderCellChips = (params?: CellChipsProps) => {
|
|
82
|
+
return function func(tableRow: GridRenderCellParams<any, any, any, GridTreeNodeWithRender>) {
|
|
83
|
+
return <CellChips {...params} value={tableRow.value ?? params?.value} />
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
renderCellStatus = function <E extends string>(config: StatusCellConfig<E>, options?: StatusCellOptions) {
|
|
88
|
+
const StatusCellInstance = CreateStatusCell(config, { sx: { minWidth: '90px' }, ...options })
|
|
89
|
+
return function func(tableRow: GridRenderCellParams<any, any, any, GridTreeNodeWithRender>) {
|
|
90
|
+
return <StatusCellInstance value={tableRow.value} />
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
renderCellBase = function <T = any>(options?: RenderCellBaseParams<T>) {
|
|
95
|
+
return function func(tableRow: GridRenderCellParams<any, any, any, GridTreeNodeWithRender>) {
|
|
96
|
+
const { imageUrl, valueFormatter, ...p } = options ?? {}
|
|
97
|
+
const value = valueFormatter ? valueFormatter(tableRow.value, tableRow.row) : undefined
|
|
98
|
+
const img = imageUrl ? imageUrl(tableRow.value, tableRow.row) : undefined
|
|
99
|
+
return <CellBase value={tableRow.value} valueFormatted={value} {...p} imageUrl={img} />
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
renderCellImage = function <T>(selectImage: (value: T) => T[keyof T], options?: { fallbackSrc?: string }) {
|
|
104
|
+
return function func(tableRow: GridRenderCellParams<any, any, any, GridTreeNodeWithRender>) {
|
|
105
|
+
return <CellImageSmall value={tableRow.value} imageUri={selectImage(tableRow.row)?.toString()} fallbackSrc={options?.fallbackSrc} />
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
renderCellDate = function (params?: CellDatePropsOwner) {
|
|
110
|
+
return function func(tableRow: GridRenderCellParams<any, any, any, GridTreeNodeWithRender>) {
|
|
111
|
+
const { formatString, ...props } = params ?? {}
|
|
112
|
+
return <CellDate {...props} value={tableRow.value} formatString={formatString ?? formatDateString} />
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
//#endregion
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const DinoTable = new DinoTableBase()
|
|
119
|
+
|
|
120
|
+
export default DinoTable
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { GridFilterModel, GridSortItem, GridSortModel } from '@mui/x-data-grid'
|
|
2
|
+
import { GridInitialStateCommunity } from '@mui/x-data-grid/models/gridStateCommunity'
|
|
3
|
+
import { CustomGridSortModel, TableQueryParams, TableQueryDetail } from './types'
|
|
4
|
+
import { decodeBase64, encodeBase64, QueryParam, tryParseObject } from '../utils'
|
|
5
|
+
|
|
6
|
+
export const dinoTableClasses = {
|
|
7
|
+
whiteSpacePre: 'white-space-pre-wrap'
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface TableQueryParamModel {
|
|
11
|
+
table?: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
class TableHelperBase {
|
|
15
|
+
private extractTableQueryParams = <T>(data?: TableQueryParams<T>): TableQueryParams<T> => {
|
|
16
|
+
if (!data) return {}
|
|
17
|
+
const { pagination, filter, sort, loading } = data
|
|
18
|
+
return { pagination, filter, sort, loading }
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
isEmpty = <T>(value: TableQueryParams<T>, defaultValue?: TableQueryParams<T>): boolean => {
|
|
22
|
+
const obj = this.extractTableQueryParams<T>(value)
|
|
23
|
+
const check1 = !obj.filter || obj.filter.items.filter((x) => !!x.value).length < 1
|
|
24
|
+
const check2 = !value.filter?.quickFilterValues || value.filter.quickFilterValues.length < 1
|
|
25
|
+
// const check3 =
|
|
26
|
+
return check1 || check2
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
equalTableQueryParams = <T>(ti1?: TableQueryParams<T>, ti2?: TableQueryParams<T>): boolean => {
|
|
30
|
+
return JSON.stringify(this.extractTableQueryParams<T>(ti1)) === JSON.stringify(this.extractTableQueryParams<T>(ti2))
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
mapInitialState = <T>(value?: TableQueryParams<T>, initialState?: GridInitialStateCommunity): GridInitialStateCommunity => {
|
|
34
|
+
if (!value) return initialState ?? {}
|
|
35
|
+
return {
|
|
36
|
+
pagination: { paginationModel: value.pagination },
|
|
37
|
+
filter: { filterModel: value.filter as GridFilterModel },
|
|
38
|
+
sorting: { sortModel: this.mapSortModel(value.sort) },
|
|
39
|
+
...initialState
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
mapSortModel = <T>(value?: CustomGridSortModel<T>): GridSortModel | undefined => {
|
|
44
|
+
return value?.map<GridSortItem>((x) => ({ field: x.field.toString(), sort: x.sort }))
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
detectSearchType = (data: GridFilterModel): TableQueryDetail => {
|
|
48
|
+
const hasQuickSearch = data.quickFilterValues && data.quickFilterValues.length > 0
|
|
49
|
+
const hasFilter = data.items && data.items.length > 0
|
|
50
|
+
if (hasQuickSearch && !hasFilter) return 'quickSearch'
|
|
51
|
+
if (hasFilter) return 'filter'
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//#region Query Params
|
|
55
|
+
private extractToUrlQuery = <TModel>(tableInfo: Partial<TableQueryParams<TModel>>): Partial<TableQueryParams<TModel>> => {
|
|
56
|
+
const { filter, sort, pagination } = tableInfo
|
|
57
|
+
const obj = { filter, sort, pagination }
|
|
58
|
+
const isQuickSearchEmpty = !filter?.quickFilterValues?.filter((x) => !!x).length
|
|
59
|
+
if (!filter?.items.length && isQuickSearchEmpty) {
|
|
60
|
+
obj.filter = undefined
|
|
61
|
+
}
|
|
62
|
+
return obj
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
private equals = <TModel>(tableInfo: Partial<TableQueryParams<TModel>>, tableInfoOld: Partial<TableQueryParams<TModel>>) => {
|
|
66
|
+
return JSON.stringify(this.extractToUrlQuery(tableInfo)) === JSON.stringify(this.extractToUrlQuery(tableInfoOld))
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
setUrlQuery = <TModel>(tableInfo: Partial<TableQueryParams<TModel>>, defaultValue: TableQueryParams<TModel>) => {
|
|
70
|
+
try {
|
|
71
|
+
if (!this.equals(tableInfo, defaultValue)) {
|
|
72
|
+
const data = this.extractToUrlQuery(tableInfo)
|
|
73
|
+
const tqp: TableQueryParamModel = { table: encodeBase64(JSON.stringify(data)) }
|
|
74
|
+
QueryParam.Patch(tqp)
|
|
75
|
+
} else {
|
|
76
|
+
QueryParam.Deletes<TableQueryParamModel>('table')
|
|
77
|
+
}
|
|
78
|
+
} catch (error) {
|
|
79
|
+
console.log(error)
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
getUrlQuery = <TModel>(defaultValue: TableQueryParams<TModel>): TableQueryParams<TModel> => {
|
|
84
|
+
const temp = QueryParam.GetAll() as TableQueryParamModel
|
|
85
|
+
if (!temp?.table) return defaultValue
|
|
86
|
+
const data = tryParseObject<TableQueryParams<TModel>>(decodeBase64(temp.table ?? ''), {})
|
|
87
|
+
if (Object.keys(data).length < 1) return defaultValue
|
|
88
|
+
return data
|
|
89
|
+
}
|
|
90
|
+
//#endregion
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const TableHelper = new TableHelperBase()
|
|
94
|
+
export default TableHelper
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './types'
|
|
2
|
+
|
|
3
|
+
export * from './model-filter'
|
|
4
|
+
|
|
5
|
+
export * from './create.action-row'
|
|
6
|
+
|
|
7
|
+
export { default as CreateTable } from './create.table'
|
|
8
|
+
|
|
9
|
+
export { default as DinoTable } from './dino'
|
|
10
|
+
|
|
11
|
+
export { default as TableHelper, dinoTableClasses } from './helpers'
|
|
12
|
+
|
|
13
|
+
export type { StatusCellConfig as TStatusCellConfig } from './create.status-cell'
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export enum ELogic {
|
|
2
|
+
And,
|
|
3
|
+
Or
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export enum EOperator {
|
|
7
|
+
GreaterThan,
|
|
8
|
+
LessThan,
|
|
9
|
+
GreaterThanOrEqual,
|
|
10
|
+
LessThanOrEqual,
|
|
11
|
+
NotEqual,
|
|
12
|
+
Equal,
|
|
13
|
+
Contains
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export enum EOrder {
|
|
17
|
+
Ascending,
|
|
18
|
+
Descending
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface FieldFilter<TModel> {
|
|
22
|
+
Logic?: ELogic
|
|
23
|
+
Operator?: EOperator
|
|
24
|
+
FieldName: keyof TModel
|
|
25
|
+
Value: string
|
|
26
|
+
}
|
|
27
|
+
export interface ScopeFilter<TModel> {
|
|
28
|
+
Logic?: ELogic
|
|
29
|
+
Scopes: PropFilter<TModel>[]
|
|
30
|
+
}
|
|
31
|
+
export type PropFilter<TModel> = FieldFilter<TModel> | ScopeFilter<TModel>
|
|
32
|
+
|
|
33
|
+
export interface PropOrderBy<TModel> {
|
|
34
|
+
Type: EOrder
|
|
35
|
+
FieldName: keyof TModel
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface IModelFilter<TModel> {
|
|
39
|
+
Page?: number
|
|
40
|
+
Amount?: number
|
|
41
|
+
PropFilters?: PropFilter<TModel>[]
|
|
42
|
+
PropOrders?: PropOrderBy<TModel>[]
|
|
43
|
+
}
|