dinocollab-core 1.1.3 → 1.1.4
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/_virtual/_rollupPluginBabelHelpers.js +2 -2
- package/dist/data-view/context.js +2 -0
- package/dist/data-view/context.js.map +1 -0
- package/dist/data-view/convert-filter-to-graphql.js +2 -0
- package/dist/data-view/convert-filter-to-graphql.js.map +1 -0
- package/dist/data-view/create.active-filters-panel.js +2 -0
- package/dist/data-view/create.active-filters-panel.js.map +1 -0
- package/dist/data-view/create.data-view.js +1 -1
- package/dist/data-view/create.data-view.js.map +1 -1
- package/dist/data-view/create.filter-bar.js +2 -0
- package/dist/data-view/create.filter-bar.js.map +1 -0
- package/dist/data-view/create.filter-menu.js +2 -0
- package/dist/data-view/create.filter-menu.js.map +1 -0
- package/dist/data-view/create.pagination-bar.js +2 -0
- package/dist/data-view/create.pagination-bar.js.map +1 -0
- package/dist/data-view/create.popper-panel.js +2 -0
- package/dist/data-view/create.popper-panel.js.map +1 -0
- package/dist/data-view/create.search-match.js +2 -0
- package/dist/data-view/create.search-match.js.map +1 -0
- package/dist/data-view/create.sort-menu.js +2 -0
- package/dist/data-view/create.sort-menu.js.map +1 -0
- package/dist/data-view/create.view-mode.js +2 -0
- package/dist/data-view/create.view-mode.js.map +1 -0
- package/dist/data-view/dino.js +2 -0
- package/dist/data-view/dino.js.map +1 -0
- package/dist/data-view/filter-store.js +2 -0
- package/dist/data-view/filter-store.js.map +1 -0
- package/dist/data-view/helpers.js +1 -1
- package/dist/data-view/helpers.js.map +1 -1
- package/dist/data-view/key-converter.js +2 -0
- package/dist/data-view/key-converter.js.map +1 -0
- package/dist/data-view/query-param-url.js +2 -0
- package/dist/data-view/query-param-url.js.map +1 -0
- package/dist/data-view/scroll-tracking.js +2 -0
- package/dist/data-view/scroll-tracking.js.map +1 -0
- package/dist/data-view/types.js +1 -1
- package/dist/data-view/types.js.map +1 -1
- package/dist/data-view/ui.units.js +1 -1
- package/dist/data-view/ui.units.js.map +1 -1
- package/dist/data-view/view-mode.content.js +2 -0
- package/dist/data-view/view-mode.content.js.map +1 -0
- package/dist/data-view/view-mode.types.js +2 -0
- package/dist/data-view/view-mode.types.js.map +1 -0
- package/dist/data-view/view-mode.units.js +2 -0
- package/dist/data-view/view-mode.units.js.map +1 -0
- package/dist/form/create.form-base.js +1 -1
- package/dist/form/create.form-base.js.map +1 -1
- package/dist/form/create.form-grid-layout.js +1 -1
- package/dist/form/create.form-grid-layout.js.map +1 -1
- package/dist/form/create.text-editor.js +1 -1
- package/dist/form/helpers.js +1 -1
- package/dist/form/helpers.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/table/helpers.js +1 -1
- package/dist/table/helpers.js.map +1 -1
- package/dist/table-grid/create.table-grid.js +1 -1
- package/dist/table-grid/create.table-grid.js.map +1 -1
- package/dist/table-grid/filter-bar/base.js +2 -0
- package/dist/table-grid/filter-bar/base.js.map +1 -0
- package/dist/table-grid/filter-bar/create.filter-bar.js +2 -0
- package/dist/table-grid/filter-bar/create.filter-bar.js.map +1 -0
- package/dist/table-grid/filter-bar/create.filter-menu.js +2 -0
- package/dist/table-grid/filter-bar/create.filter-menu.js.map +1 -0
- package/dist/table-grid/filter-bar/create.filter-panel.js +2 -0
- package/dist/table-grid/filter-bar/create.filter-panel.js.map +1 -0
- package/dist/table-grid/filter-bar/create.filtered.js +2 -0
- package/dist/table-grid/filter-bar/create.filtered.js.map +1 -0
- package/dist/{filter-bar → table-grid/filter-bar}/types.js +1 -1
- package/dist/table-grid/filter-bar/types.js.map +1 -0
- package/dist/table-grid/filter-bar/ui.units.js +2 -0
- package/dist/table-grid/filter-bar/ui.units.js.map +1 -0
- package/dist/table-grid/url-query-param.js +1 -1
- package/dist/table-grid/url-query-param.js.map +1 -1
- package/dist/types/data-view/context.d.ts +27 -0
- package/dist/types/data-view/convert-filter-to-graphql.d.ts +30 -0
- package/dist/types/data-view/create.active-filters-panel.d.ts +20 -0
- package/dist/types/data-view/create.data-view.d.ts +51 -52
- package/dist/types/data-view/create.filter-bar.d.ts +87 -0
- package/dist/types/data-view/create.filter-menu.d.ts +10 -0
- package/dist/types/data-view/create.pagination-bar.d.ts +15 -0
- package/dist/types/data-view/create.popper-panel.d.ts +54 -0
- package/dist/types/data-view/create.search-match.d.ts +5 -0
- package/dist/types/data-view/create.sort-menu.d.ts +5 -0
- package/dist/types/data-view/create.view-mode.d.ts +14 -0
- package/dist/types/data-view/dino.d.ts +32 -0
- package/dist/types/data-view/filter-store.d.ts +39 -0
- package/dist/types/data-view/helpers.d.ts +12 -6
- package/dist/types/data-view/index.d.ts +8 -5
- package/dist/types/data-view/key-converter.d.ts +13 -0
- package/dist/types/data-view/query-param-url.d.ts +26 -0
- package/dist/types/data-view/scroll-tracking.d.ts +10 -0
- package/dist/types/data-view/types.d.ts +200 -18
- package/dist/types/data-view/ui.units.d.ts +77 -11
- package/dist/types/data-view/view-mode.content.d.ts +17 -0
- package/dist/types/data-view/view-mode.types.d.ts +46 -0
- package/dist/types/data-view/view-mode.units.d.ts +18 -0
- package/dist/types/form/create.form-base.d.ts +11 -5
- package/dist/types/form/create.form-grid-layout.d.ts +7 -4
- package/dist/types/index.d.ts +2 -3
- package/dist/types/{filter-bar → table-grid/filter-bar}/types.d.ts +4 -4
- package/dist/types/table-grid/index.d.ts +1 -0
- package/dist/types/table-grid/types.d.ts +1 -1
- package/dist/types/utils/query-param.d.ts +14 -14
- package/dist/utils/query-param.js +1 -1
- package/dist/utils/query-param.js.map +1 -1
- package/package.json +66 -64
- package/dist/data-view/create.table.js +0 -2
- package/dist/data-view/create.table.js.map +0 -1
- package/dist/data-view/custom-toolbar.js +0 -2
- package/dist/data-view/custom-toolbar.js.map +0 -1
- package/dist/data-view/index.js +0 -2
- package/dist/data-view/index.js.map +0 -1
- package/dist/filter-bar/base.js +0 -2
- package/dist/filter-bar/base.js.map +0 -1
- package/dist/filter-bar/create.filter-bar.js +0 -2
- package/dist/filter-bar/create.filter-bar.js.map +0 -1
- package/dist/filter-bar/create.filter-menu.js +0 -2
- package/dist/filter-bar/create.filter-menu.js.map +0 -1
- package/dist/filter-bar/create.filter-panel.js +0 -2
- package/dist/filter-bar/create.filter-panel.js.map +0 -1
- package/dist/filter-bar/create.filtered.js +0 -2
- package/dist/filter-bar/create.filtered.js.map +0 -1
- package/dist/filter-bar/types.js.map +0 -1
- package/dist/filter-bar/ui.units.js +0 -2
- package/dist/filter-bar/ui.units.js.map +0 -1
- package/dist/types/data-view/create.table.d.ts +0 -9
- package/dist/types/data-view/custom-toolbar.d.ts +0 -11
- package/dist/types/data-view/filter-operators.d.ts +0 -1
- package/dist/types/filter-bar/create.sort-menu.d.ts +0 -1
- package/dist/types/table-grid/demo.d.ts +0 -3
- /package/dist/types/{filter-bar → table-grid/filter-bar}/base.d.ts +0 -0
- /package/dist/types/{filter-bar → table-grid/filter-bar}/create.filter-bar.d.ts +0 -0
- /package/dist/types/{filter-bar → table-grid/filter-bar}/create.filter-menu.d.ts +0 -0
- /package/dist/types/{filter-bar → table-grid/filter-bar}/create.filter-panel.d.ts +0 -0
- /package/dist/types/{filter-bar → table-grid/filter-bar}/create.filtered.d.ts +0 -0
- /package/dist/types/{filter-bar → table-grid/filter-bar}/index.d.ts +0 -0
- /package/dist/types/{filter-bar → table-grid/filter-bar}/ui.units.d.ts +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { IFilterState, IFilterMap, IPagination, ISort, IFilterChangeDetails, IFilterItem, SingleOrArray } from './types';
|
|
2
|
+
export declare class FilterStore<T> {
|
|
3
|
+
private _state;
|
|
4
|
+
private _defaultFilter;
|
|
5
|
+
constructor(initialState?: IFilterState<T>, defaultFilter?: IFilterState<T>);
|
|
6
|
+
get state(): IFilterState<T>;
|
|
7
|
+
addFilterItem(field: keyof T, filterItem: IFilterItem, details?: IFilterChangeDetails): FilterStore<T>;
|
|
8
|
+
removeFilterFiled(field: keyof T, details?: IFilterChangeDetails): FilterStore<T>;
|
|
9
|
+
removeFilterItem(field: keyof T, value: string, details?: IFilterChangeDetails): FilterStore<T>;
|
|
10
|
+
updateFilter(filter?: IFilterMap<T>, details?: IFilterChangeDetails): this;
|
|
11
|
+
addQuickSearch(value?: SingleOrArray<string>, details?: IFilterChangeDetails): FilterStore<T>;
|
|
12
|
+
removeQuickSearch(details?: IFilterChangeDetails): FilterStore<T>;
|
|
13
|
+
removeQuickSearchItem(value: string, details?: IFilterChangeDetails): FilterStore<T>;
|
|
14
|
+
updateSearchInput(quickSearch: SingleOrArray<string>): FilterStore<T>;
|
|
15
|
+
changePagination(pagination: IPagination, details?: IFilterChangeDetails): FilterStore<T>;
|
|
16
|
+
removePagination(details?: IFilterChangeDetails): FilterStore<T>;
|
|
17
|
+
changeSort(sort: ISort<T>, details?: IFilterChangeDetails): FilterStore<T>;
|
|
18
|
+
removeSort(details?: IFilterChangeDetails): FilterStore<T>;
|
|
19
|
+
toggleSortDirection(details: IFilterChangeDetails): FilterStore<T>;
|
|
20
|
+
updateState(updates: Partial<IFilterState<T>>, details?: IFilterChangeDetails): FilterStore<T>;
|
|
21
|
+
reset(): FilterStore<T>;
|
|
22
|
+
resetFilter(details?: IFilterChangeDetails): FilterStore<T>;
|
|
23
|
+
resetQuickSearch(details?: IFilterChangeDetails): FilterStore<T>;
|
|
24
|
+
resetPagination(details?: IFilterChangeDetails): FilterStore<T>;
|
|
25
|
+
resetSort(details?: IFilterChangeDetails): FilterStore<T>;
|
|
26
|
+
private isPaginationEqualToDefault;
|
|
27
|
+
private isSortEqualToDefault;
|
|
28
|
+
extractFilter(): IFilterState<T>;
|
|
29
|
+
countFilterItems(): number;
|
|
30
|
+
hasFilter(): boolean;
|
|
31
|
+
hasQuickSearch(): boolean;
|
|
32
|
+
hasPagination(): boolean;
|
|
33
|
+
hasSort(): boolean;
|
|
34
|
+
isEmpty(): boolean;
|
|
35
|
+
converToQueryParam: (base: string) => string;
|
|
36
|
+
build(): IFilterState<T>;
|
|
37
|
+
}
|
|
38
|
+
export default FilterStore;
|
|
39
|
+
export declare function createFilterStore<T>(filterState: IFilterState<T>, defaultFilter?: IFilterState<T>): FilterStore<T>;
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
export declare const
|
|
1
|
+
import { IFilterConfig, IFilterConfigs } from './types';
|
|
2
|
+
export declare const filterMenuClasses: {
|
|
3
|
+
list: string;
|
|
4
|
+
item: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const convertFormDataToJson: <TModel>(form: FormData) => Partial<TModel>;
|
|
7
|
+
export declare const getFieldsMatches: <T>(fields?: IFilterConfigs<T> | undefined, keyword?: string) => IFilterConfigs<T>;
|
|
8
|
+
export declare const getFieldsValidation: <T>(fields?: IFilterConfigs<T> | undefined) => IFilterConfigs<T>;
|
|
9
|
+
export declare const filterFieldValidated: <T>(value: string, fieldKey: keyof T, filterField?: IFilterConfig) => {
|
|
10
|
+
error: boolean;
|
|
11
|
+
message?: string;
|
|
12
|
+
};
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import createDataView from './create.data-view';
|
|
2
1
|
export * from './types';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export
|
|
2
|
+
export { EViewMode } from './view-mode.types';
|
|
3
|
+
export * from './create.pagination-bar';
|
|
4
|
+
export * from './filter-store';
|
|
5
|
+
export * from './key-converter';
|
|
6
|
+
export * from './convert-filter-to-graphql';
|
|
7
|
+
export * from './create.view-mode';
|
|
8
|
+
export type { IViewModeProps } from './view-mode.units';
|
|
9
|
+
export * from './dino';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SingleOrArray } from './types';
|
|
2
|
+
export interface IKeyConverterDef<Q> {
|
|
3
|
+
field?: keyof Q;
|
|
4
|
+
deep?: string;
|
|
5
|
+
prefix?: string;
|
|
6
|
+
suffix?: string;
|
|
7
|
+
custom?: (value: string) => string;
|
|
8
|
+
}
|
|
9
|
+
export type IKeyConverterModel<T, Q> = {
|
|
10
|
+
[key in keyof T]?: SingleOrArray<IKeyConverterDef<Q>>;
|
|
11
|
+
};
|
|
12
|
+
export declare const createKeyConverter: <T, Q>(params: IKeyConverterModel<T, Q>) => IKeyConverterModel<T, Q>;
|
|
13
|
+
export declare const getKeyConverter: <T, Q>(key: keyof T, converter: IKeyConverterModel<T, Q>) => IKeyConverterDef<Q>[];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { IFilterState } from './types';
|
|
2
|
+
import { EViewMode } from './view-mode.types';
|
|
3
|
+
export interface IViewDataQueryParams {
|
|
4
|
+
filter?: string;
|
|
5
|
+
sk?: string;
|
|
6
|
+
mode?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface IViewDataHandlerDef<T> {
|
|
9
|
+
filter?: IFilterState<T>;
|
|
10
|
+
seedKey?: string;
|
|
11
|
+
defaultFilter?: IFilterState<T>;
|
|
12
|
+
defaultSeedKey?: string;
|
|
13
|
+
defaultValue?: string;
|
|
14
|
+
viewMode?: EViewMode;
|
|
15
|
+
defaultViewMode?: EViewMode;
|
|
16
|
+
}
|
|
17
|
+
export type IViewDataHandlerParams<T, K extends keyof IViewDataHandlerDef<T> = keyof IViewDataHandlerDef<T>> = Pick<IViewDataHandlerDef<T>, K>;
|
|
18
|
+
export declare const syncQueryToURL: <T>(params: IViewDataHandlerParams<T, "filter" | "defaultFilter" | "seedKey">) => void;
|
|
19
|
+
export declare const getQueryFromURL: <T>(params: IViewDataHandlerParams<T, "defaultFilter" | "defaultSeedKey">) => {
|
|
20
|
+
filter: IFilterState<T>;
|
|
21
|
+
seedKey: string;
|
|
22
|
+
} | null;
|
|
23
|
+
export declare const getSeedKeyFromURL: <T>(params: IViewDataHandlerParams<T, "defaultSeedKey">) => string;
|
|
24
|
+
export declare const syncViewModeToURL: <T>(params: IViewDataHandlerParams<T, "viewMode" | "defaultViewMode">) => void;
|
|
25
|
+
export declare const getViewModeFromURL: <T>(params: IViewDataHandlerParams<T, "defaultViewMode">) => EViewMode | undefined;
|
|
26
|
+
export declare const converFilterToQueryParam: <T>(filterState?: IFilterState<T> | undefined) => string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
export interface IScrollTrackingData {
|
|
3
|
+
isScrolled: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare const useScrollTracking: () => IScrollTrackingData;
|
|
6
|
+
export interface IScrollTrackingProps {
|
|
7
|
+
onChange: (data: IScrollTrackingData) => void;
|
|
8
|
+
}
|
|
9
|
+
declare const ScrollTracking: FC<IScrollTrackingProps>;
|
|
10
|
+
export default ScrollTracking;
|
|
@@ -1,24 +1,206 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { ButtonProps } from '@mui/material';
|
|
3
|
+
import type { IFilterNotesProps } from './ui.units';
|
|
4
|
+
export type SingleOrArray<T> = T | T[];
|
|
5
|
+
export type IRelativePosition = 'above' | 'below' | 'left' | 'right';
|
|
6
|
+
export type IPositionElementDef = {
|
|
7
|
+
[key in IRelativePosition]?: ReactNode;
|
|
8
|
+
};
|
|
9
|
+
export type IPositionElement<K extends IRelativePosition = IRelativePosition> = Pick<IPositionElementDef, K>;
|
|
10
|
+
export declare enum EViewStatus {
|
|
11
|
+
Loading = "Loading",
|
|
12
|
+
Loaded = "Loaded",
|
|
13
|
+
Error = "Error"
|
|
14
|
+
}
|
|
15
|
+
export type IFilterArea = 'input' | 'filterButton' | 'sortButton';
|
|
16
|
+
export type IFilterReason = 'field' | 'quickSearch' | 'pagination' | 'sort';
|
|
17
|
+
export type IFilterAction = 'add' | 'remove' | 'change' | 'reset';
|
|
18
|
+
export type IFilterType = 'string' | 'select' | 'select-multi' | 'date' | 'date-range';
|
|
19
|
+
export type IFilterLogic = 'and' | 'or';
|
|
20
|
+
export type IFilterDateLogic = 'equals' | 'before' | 'after';
|
|
21
|
+
export type IFilterDateRangeLogic = 'between' | 'not-between';
|
|
22
|
+
export interface IItemBase {
|
|
23
|
+
value: string;
|
|
24
|
+
label?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface IValidationResult {
|
|
27
|
+
hasError: boolean;
|
|
28
|
+
message?: string;
|
|
29
|
+
}
|
|
30
|
+
export declare enum EFieldMatch {
|
|
31
|
+
AlwaysVisible = "AlwaysVisible",
|
|
32
|
+
MatchOnly = "MatchOnly",
|
|
33
|
+
LinkYoutube = "LinkYoutube",
|
|
34
|
+
Link = "Link",
|
|
35
|
+
Guid = "Guid"
|
|
36
|
+
}
|
|
37
|
+
export interface IFieldMatchDef {
|
|
38
|
+
rule: EFieldMatch;
|
|
39
|
+
}
|
|
40
|
+
export interface IFieldMatchMatchOnly extends IFieldMatchDef {
|
|
41
|
+
rule: EFieldMatch.MatchOnly;
|
|
42
|
+
match: (value: string) => boolean;
|
|
43
|
+
}
|
|
44
|
+
export interface IFieldMatchBasic extends IFieldMatchDef {
|
|
45
|
+
rule: EFieldMatch.AlwaysVisible | EFieldMatch.LinkYoutube | EFieldMatch.Link | EFieldMatch.Guid;
|
|
46
|
+
}
|
|
47
|
+
export type IFieldMatchConfig = IFieldMatchMatchOnly | IFieldMatchBasic;
|
|
48
|
+
export type IFieldMatchConfigs = {
|
|
49
|
+
rules: SingleOrArray<IFieldMatchConfig>;
|
|
50
|
+
notes?: IFilterNotesProps;
|
|
51
|
+
};
|
|
52
|
+
export declare enum EFieldValidate {
|
|
53
|
+
Required = "Required",
|
|
54
|
+
LinkYoutube = "LinkYoutube",
|
|
55
|
+
Link = "Link",
|
|
56
|
+
Custom = "Custom"
|
|
57
|
+
}
|
|
58
|
+
export interface IFieldValidateDef {
|
|
59
|
+
rule: EFieldValidate;
|
|
60
|
+
}
|
|
61
|
+
export interface IFieldValidateCustom extends IFieldValidateDef {
|
|
62
|
+
rule: EFieldValidate.Custom;
|
|
63
|
+
validator: (value: string) => boolean;
|
|
64
|
+
}
|
|
65
|
+
export interface IFieldValidateBasic extends IFieldValidateDef {
|
|
66
|
+
rule: EFieldValidate.Required | EFieldValidate.Link | EFieldValidate.LinkYoutube;
|
|
5
67
|
}
|
|
6
|
-
export type
|
|
7
|
-
|
|
68
|
+
export type IFieldValidateConfig = IFieldValidateCustom | IFieldValidateBasic;
|
|
69
|
+
export type IFieldValidateConfigs = {
|
|
70
|
+
rules: SingleOrArray<IFieldValidateConfig>;
|
|
71
|
+
notes?: IFilterNotesProps;
|
|
8
72
|
};
|
|
9
|
-
export interface
|
|
10
|
-
|
|
11
|
-
|
|
73
|
+
export interface IPagination {
|
|
74
|
+
page?: number;
|
|
75
|
+
pageSize?: number;
|
|
76
|
+
}
|
|
77
|
+
export interface ISort<T> {
|
|
78
|
+
field: keyof T;
|
|
79
|
+
direction: 'asc' | 'desc';
|
|
80
|
+
}
|
|
81
|
+
export interface IQuickSearchConfig<T> {
|
|
82
|
+
fields: SingleOrArray<keyof T>;
|
|
83
|
+
label?: string;
|
|
84
|
+
notes?: IFilterNotesProps;
|
|
85
|
+
logic?: IFilterLogic;
|
|
86
|
+
}
|
|
87
|
+
interface IFilterDef {
|
|
88
|
+
/** Display label for the filter field */
|
|
89
|
+
label?: string;
|
|
90
|
+
/**
|
|
91
|
+
* Filter input type
|
|
92
|
+
* @default 'string'
|
|
93
|
+
*/
|
|
94
|
+
type?: IFilterType;
|
|
95
|
+
/**
|
|
96
|
+
* Configuration for quick search matching behavior.
|
|
97
|
+
* Determines how the quick search should match against field values.
|
|
98
|
+
*/
|
|
99
|
+
quickSearchMatch?: IFieldMatchConfigs;
|
|
100
|
+
/**
|
|
101
|
+
* Notes for the filter field.
|
|
102
|
+
*/
|
|
103
|
+
notes?: IFilterNotesProps;
|
|
104
|
+
/**
|
|
105
|
+
* Validation rules for the filter menu input.
|
|
106
|
+
* @default
|
|
107
|
+
* { rules: [{ rule: EFieldValidate.Required }] }
|
|
108
|
+
*/
|
|
109
|
+
validation?: IFieldValidateConfigs;
|
|
110
|
+
/**
|
|
111
|
+
* Notes to display in the filter menu.
|
|
112
|
+
* Useful for providing additional context or instructions.
|
|
113
|
+
*/
|
|
114
|
+
filterable?: boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Whether the filter field is sortable.
|
|
117
|
+
* If true, the field can be used for sorting in the filter menu.
|
|
118
|
+
* @default true
|
|
119
|
+
*/
|
|
120
|
+
sortable?: boolean;
|
|
121
|
+
}
|
|
122
|
+
export interface IFilterBasicDef extends IFilterDef {
|
|
123
|
+
type?: 'string';
|
|
124
|
+
}
|
|
125
|
+
export interface IFilterSelectDef extends IFilterDef {
|
|
126
|
+
type: 'select' | 'select-multi';
|
|
127
|
+
options: {
|
|
128
|
+
value: string;
|
|
129
|
+
label?: string;
|
|
130
|
+
}[];
|
|
131
|
+
}
|
|
132
|
+
export interface IFilterDateDef extends IFilterDef {
|
|
133
|
+
type: 'date' | 'date-range';
|
|
134
|
+
/**
|
|
135
|
+
* Date format for display and validation
|
|
136
|
+
* @default 'YYYY-MM-DD'
|
|
137
|
+
*/
|
|
138
|
+
format?: string;
|
|
139
|
+
/**
|
|
140
|
+
* Minimum date allowed
|
|
141
|
+
*/
|
|
142
|
+
minDate?: string | Date;
|
|
143
|
+
/**
|
|
144
|
+
* Maximum date allowed
|
|
145
|
+
*/
|
|
146
|
+
maxDate?: string | Date;
|
|
147
|
+
}
|
|
148
|
+
export type IFilterConfig = IFilterBasicDef | IFilterSelectDef | IFilterDateDef;
|
|
149
|
+
export type IFilterConfigs<T> = {
|
|
150
|
+
[key in keyof T]?: IFilterConfig;
|
|
151
|
+
};
|
|
152
|
+
export interface IFilterItem {
|
|
153
|
+
type?: IFilterType;
|
|
154
|
+
value?: string | number | boolean;
|
|
155
|
+
label?: string;
|
|
156
|
+
logic?: IFilterLogic;
|
|
157
|
+
dateLogic?: IFilterDateLogic;
|
|
158
|
+
dateRangeLogic?: IFilterDateRangeLogic;
|
|
159
|
+
startDate?: string;
|
|
160
|
+
endDate?: string;
|
|
161
|
+
}
|
|
162
|
+
export type IFilterMap<T> = {
|
|
163
|
+
[key in keyof T]?: IFilterItem[];
|
|
164
|
+
};
|
|
165
|
+
export interface IFilterChangeDetails {
|
|
166
|
+
reason?: IFilterReason;
|
|
167
|
+
area?: IFilterArea;
|
|
168
|
+
action?: IFilterAction;
|
|
169
|
+
isChanged?: boolean;
|
|
170
|
+
}
|
|
171
|
+
export interface IFilterState<T> {
|
|
172
|
+
filter?: IFilterMap<T>;
|
|
173
|
+
quickSearch?: SingleOrArray<string>;
|
|
174
|
+
quickSearchLogic?: IFilterLogic;
|
|
175
|
+
pagination?: IPagination;
|
|
176
|
+
sort?: ISort<T>;
|
|
177
|
+
details?: IFilterChangeDetails;
|
|
178
|
+
}
|
|
179
|
+
export type IFilterStateChangeHandler<T> = (filterState: IFilterState<T>) => void;
|
|
180
|
+
export interface ISortButtonConfigs {
|
|
181
|
+
text?: string;
|
|
182
|
+
icon?: ReactNode;
|
|
183
|
+
wrapProps?: ButtonProps;
|
|
12
184
|
}
|
|
13
|
-
export interface
|
|
14
|
-
|
|
185
|
+
export interface IFilterBarConfigBase {
|
|
186
|
+
/** @default false */
|
|
187
|
+
enableSticky?: boolean;
|
|
188
|
+
/** @default false */
|
|
189
|
+
enableSort?: boolean;
|
|
15
190
|
}
|
|
16
|
-
export interface
|
|
17
|
-
|
|
18
|
-
|
|
191
|
+
export interface IFilterBarConfigs<T> extends IFilterBarConfigBase {
|
|
192
|
+
id?: string;
|
|
193
|
+
placeholder?: string;
|
|
194
|
+
notes?: IFilterNotesProps;
|
|
195
|
+
fields?: IFilterConfigs<T>;
|
|
196
|
+
quickSearch?: IQuickSearchConfig<T>;
|
|
197
|
+
defaultValue?: IFilterState<T>;
|
|
198
|
+
sortButton?: ISortButtonConfigs;
|
|
19
199
|
}
|
|
20
|
-
export interface
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
200
|
+
export interface IViewData<T> {
|
|
201
|
+
items: T[];
|
|
202
|
+
totalItems?: number;
|
|
203
|
+
hasPreviousPage?: boolean;
|
|
204
|
+
hasNextPage?: boolean;
|
|
24
205
|
}
|
|
206
|
+
export {};
|
|
@@ -1,11 +1,77 @@
|
|
|
1
|
-
import { FC, ReactNode } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import React, { FC, ReactNode } from 'react';
|
|
2
|
+
import { ButtonProps, InputBaseProps } from '@mui/material';
|
|
3
|
+
import { IconButtonProps } from '@mui/material';
|
|
4
|
+
import { IFilterLogic, IFilterDateLogic, IFilterDateRangeLogic, IFilterSelectDef, IValidationResult, IFilterDateDef, IFilterBasicDef } from './types';
|
|
5
|
+
export declare const mapSortConfigs: Record<'asc' | 'desc', {
|
|
6
|
+
title: string;
|
|
7
|
+
icon: ReactNode;
|
|
8
|
+
}>;
|
|
9
|
+
export interface IFilterLogicToggleProps {
|
|
10
|
+
value?: IFilterLogic;
|
|
11
|
+
onChange?: (event: React.MouseEvent<HTMLElement>, value: IFilterLogic) => void;
|
|
12
|
+
}
|
|
13
|
+
export declare const FilterLogicToggle: FC<IFilterLogicToggleProps>;
|
|
14
|
+
export interface IDateLogicToggleProps {
|
|
15
|
+
value?: IFilterDateLogic;
|
|
16
|
+
onChange?: (event: React.MouseEvent<HTMLElement>, value: IFilterDateLogic) => void;
|
|
17
|
+
}
|
|
18
|
+
export declare const DateLogicToggle: FC<IDateLogicToggleProps>;
|
|
19
|
+
export interface IDateRangeLogicToggleProps {
|
|
20
|
+
value?: IFilterDateRangeLogic;
|
|
21
|
+
onChange?: (event: React.MouseEvent<HTMLElement>, value: IFilterDateRangeLogic) => void;
|
|
22
|
+
}
|
|
23
|
+
export declare const DateRangeLogicToggle: FC<IDateRangeLogicToggleProps>;
|
|
24
|
+
export interface IFilterNotesProps {
|
|
25
|
+
title?: string;
|
|
26
|
+
items?: string[];
|
|
27
|
+
disabledSize?: boolean;
|
|
28
|
+
renderContent?: () => ReactNode;
|
|
29
|
+
}
|
|
30
|
+
export declare const FilterNotes: FC<IFilterNotesProps>;
|
|
31
|
+
export declare const FilterInput: React.ForwardRefExoticComponent<Omit<InputBaseProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
32
|
+
interface IFilterInputAdornmentProps {
|
|
33
|
+
notes?: IFilterNotesProps;
|
|
34
|
+
keyword?: string;
|
|
35
|
+
onClear: IconButtonProps['onClick'];
|
|
36
|
+
onEnterSearch: ButtonProps['onClick'];
|
|
37
|
+
}
|
|
38
|
+
export declare const FilterInputAdornment: FC<IFilterInputAdornmentProps>;
|
|
39
|
+
export interface IButtonClearProps {
|
|
40
|
+
visibled?: boolean;
|
|
41
|
+
onClick: IconButtonProps['onClick'];
|
|
42
|
+
}
|
|
43
|
+
export declare const ButtonClear: FC<IButtonClearProps>;
|
|
44
|
+
export declare const ClearAllButton: React.ForwardRefExoticComponent<Omit<ButtonProps<"button", {}>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
45
|
+
export declare const FilterButton: React.ForwardRefExoticComponent<Omit<IconButtonProps<"button", {}>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
46
|
+
export declare const SortIconButton: React.ForwardRefExoticComponent<Omit<IconButtonProps<"button", {}>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
47
|
+
export declare const SortButton: FC<ButtonProps>;
|
|
48
|
+
export declare const PanelNotFound: FC<{
|
|
49
|
+
area?: string;
|
|
50
|
+
}>;
|
|
51
|
+
interface IMenuWithTypeBaseProps {
|
|
52
|
+
name: string;
|
|
53
|
+
validationResult?: IValidationResult;
|
|
54
|
+
}
|
|
55
|
+
interface IMenuWithTypeStringProps extends IMenuWithTypeBaseProps {
|
|
56
|
+
fieldConfig?: IFilterBasicDef;
|
|
57
|
+
}
|
|
58
|
+
export declare const MenuWithTypeString: FC<IMenuWithTypeStringProps>;
|
|
59
|
+
export interface IMenuWithTypeSelectProps extends IMenuWithTypeBaseProps {
|
|
60
|
+
fieldConfig?: IFilterSelectDef;
|
|
61
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
62
|
+
}
|
|
63
|
+
export declare const MenuWithTypeSelect: FC<IMenuWithTypeSelectProps>;
|
|
64
|
+
export interface IMenuWithTypeSelectMultiProps extends IMenuWithTypeBaseProps {
|
|
65
|
+
fieldConfig?: IFilterSelectDef;
|
|
66
|
+
onChange?: (event: React.SyntheticEvent, checked: boolean) => void;
|
|
67
|
+
}
|
|
68
|
+
export declare const MenuWithTypeSelectMulti: FC<IMenuWithTypeSelectMultiProps>;
|
|
69
|
+
export interface IMenuWithTypeDateProps extends IMenuWithTypeBaseProps {
|
|
70
|
+
fieldConfig?: IFilterDateDef;
|
|
71
|
+
}
|
|
72
|
+
export declare const MenuWithTypeDate: FC<IMenuWithTypeDateProps>;
|
|
73
|
+
export interface IMenuWithTypeDateRangeProps extends IMenuWithTypeBaseProps {
|
|
74
|
+
fieldConfig?: IFilterDateDef;
|
|
75
|
+
}
|
|
76
|
+
export declare const MenuWithTypeDateRange: FC<IMenuWithTypeDateRangeProps>;
|
|
77
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ComponentType } from 'react';
|
|
2
|
+
import { DataGridProps } from '@mui/x-data-grid';
|
|
3
|
+
import { IViewModeListConfig, IViewModeModuleConfig, IViewModeValidModel } from './view-mode.types';
|
|
4
|
+
interface IViewModeModuleProps<T extends IViewModeValidModel> {
|
|
5
|
+
data: T[];
|
|
6
|
+
configs: IViewModeModuleConfig<T>;
|
|
7
|
+
}
|
|
8
|
+
export declare function createViewModeModule<T extends IViewModeValidModel>(): ComponentType<IViewModeModuleProps<T>>;
|
|
9
|
+
export interface IViewModeListProps<T extends IViewModeValidModel> {
|
|
10
|
+
value: T[];
|
|
11
|
+
configs: IViewModeListConfig<T>;
|
|
12
|
+
slots?: {
|
|
13
|
+
dataGridProps?: Partial<Omit<DataGridProps, 'columns' | 'rows'>>;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export declare function createViewModeList<T extends IViewModeValidModel>(): ComponentType<IViewModeListProps<T>>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { BoxProps, Breakpoint, GridProps } from '@mui/material';
|
|
3
|
+
import { GridColDef, GridRowIdGetter } from '@mui/x-data-grid';
|
|
4
|
+
export type IViewModeValidModel = {
|
|
5
|
+
[key: string | symbol]: any;
|
|
6
|
+
};
|
|
7
|
+
export declare enum EViewMode {
|
|
8
|
+
List = "list",
|
|
9
|
+
Module = "module"
|
|
10
|
+
}
|
|
11
|
+
export type IResponsiveSize = {
|
|
12
|
+
[key in Breakpoint]?: number;
|
|
13
|
+
};
|
|
14
|
+
export interface IViewModeElementProps {
|
|
15
|
+
mode?: EViewMode;
|
|
16
|
+
}
|
|
17
|
+
export interface IViewModeItemProps<T> {
|
|
18
|
+
data: T;
|
|
19
|
+
index: number;
|
|
20
|
+
}
|
|
21
|
+
export type GridColsDef<T extends IViewModeValidModel> = {
|
|
22
|
+
[key in keyof T]?: Omit<GridColDef<T>, 'field'>;
|
|
23
|
+
};
|
|
24
|
+
export interface IViewModeListConfig<T extends IViewModeValidModel> {
|
|
25
|
+
getRowId?: GridRowIdGetter<T>;
|
|
26
|
+
columns?: GridColsDef<T>;
|
|
27
|
+
rowHeight?: number;
|
|
28
|
+
}
|
|
29
|
+
export type IViewModeModuleConfig<T> = {
|
|
30
|
+
getElementId?: (value: T) => string | number;
|
|
31
|
+
Element?: React.ComponentType<IViewModeItemProps<T>>;
|
|
32
|
+
elementWrapProps?: Omit<GridProps, 'size' | 'children'>;
|
|
33
|
+
elementWrapPropsGetter?: (props: IViewModeItemProps<T>) => Omit<GridProps, 'size' | 'children'>;
|
|
34
|
+
spacing?: GridProps['spacing'];
|
|
35
|
+
size?: IResponsiveSize;
|
|
36
|
+
wrapProps?: Omit<GridProps, 'size' | 'children'>;
|
|
37
|
+
};
|
|
38
|
+
export interface IViewModeConfigs<T extends IViewModeValidModel> {
|
|
39
|
+
list?: IViewModeListConfig<T>;
|
|
40
|
+
module?: IViewModeModuleConfig<T>;
|
|
41
|
+
NoData?: React.ComponentType<IViewModeElementProps>;
|
|
42
|
+
ErrorData?: React.ComponentType<IViewModeElementProps>;
|
|
43
|
+
Skeleton?: React.ComponentType<IViewModeElementProps>;
|
|
44
|
+
wrapProps?: BoxProps;
|
|
45
|
+
defaultValue?: EViewMode;
|
|
46
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { BoxProps } from '@mui/material';
|
|
3
|
+
import { EViewMode, IResponsiveSize, IViewModeElementProps } from './view-mode.types';
|
|
4
|
+
export declare const defaultSize: IResponsiveSize;
|
|
5
|
+
export declare const defaultViewMode = EViewMode.List;
|
|
6
|
+
export interface IViewModeProps {
|
|
7
|
+
value?: EViewMode;
|
|
8
|
+
onChange?: (value: EViewMode) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare const ViewModeButtons: FC<IViewModeProps>;
|
|
11
|
+
export declare const createViewModeButtons: () => FC<IViewModeProps>;
|
|
12
|
+
export declare const LoadingOverlay: FC<BoxProps>;
|
|
13
|
+
export declare const LoadingError: FC<{
|
|
14
|
+
error: string;
|
|
15
|
+
}>;
|
|
16
|
+
export declare const LoadingNoData: FC<IViewModeElementProps>;
|
|
17
|
+
export declare const LoadingWaiting: FC;
|
|
18
|
+
export declare const LoadingMissingConfig: React.FC;
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import React, { ComponentType, PropsWithChildren } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { BoxProps } from '@mui/material';
|
|
3
3
|
import { IFormBaseContext } from './types';
|
|
4
4
|
import FormValidator, { IPartialError } from './validator';
|
|
5
|
-
export interface
|
|
6
|
-
|
|
5
|
+
export interface IFormBaseSlots {
|
|
6
|
+
formProps?: Omit<BoxProps, 'ref' | 'onSubmit' | 'component'>;
|
|
7
7
|
}
|
|
8
|
-
export interface
|
|
9
|
-
sx?: SxProps<Theme>;
|
|
8
|
+
export interface IFormBaseConfigs<T> {
|
|
10
9
|
validate?: FormValidator<Partial<T>>;
|
|
10
|
+
dataTrimed?: boolean;
|
|
11
|
+
dataGetter?: (data: Partial<T>) => Partial<T>;
|
|
12
|
+
}
|
|
13
|
+
export interface IFormBaseParams<T> extends IFormBaseConfigs<T> {
|
|
14
|
+
}
|
|
15
|
+
export interface IFormBaseProps<T> extends PropsWithChildren, IFormBaseConfigs<T> {
|
|
11
16
|
onSubmit: (data: Partial<T>, e: React.FormEvent<HTMLFormElement>) => Promise<void>;
|
|
17
|
+
slots?: IFormBaseSlots;
|
|
12
18
|
}
|
|
13
19
|
export interface IFormBaseState<T> {
|
|
14
20
|
modelState?: Partial<T>;
|
|
@@ -2,6 +2,7 @@ import React, { ComponentType } from 'react';
|
|
|
2
2
|
import { BoxProps, RegularBreakpoints, SxProps, Theme } from '@mui/material';
|
|
3
3
|
import { IFormBase, IFormInputBase } from './types';
|
|
4
4
|
import FormValidator from './validator';
|
|
5
|
+
import { IFormBaseSlots } from './create.form-base';
|
|
5
6
|
export interface IFormGridLayoutConfig<T> {
|
|
6
7
|
key: keyof T;
|
|
7
8
|
label?: string;
|
|
@@ -10,20 +11,22 @@ export interface IFormGridLayoutConfig<T> {
|
|
|
10
11
|
defaultValue?: any;
|
|
11
12
|
inputElement?: React.ComponentType<IFormInputBase<T>>;
|
|
12
13
|
}
|
|
13
|
-
export type
|
|
14
|
+
export type IPreSubmitEvent<T> = (value: Partial<T>, oldValue?: T) => Partial<T>;
|
|
14
15
|
export interface IFormGridLayoutSlots<T> {
|
|
15
16
|
action?: React.ComponentType<IFormBase<T>>;
|
|
16
17
|
actionBefore?: JSX.Element;
|
|
17
18
|
contentBefore?: JSX.Element;
|
|
18
19
|
contentAfter?: JSX.Element;
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
hiddenFields?: Partial<Record<keyof T, boolean>>;
|
|
21
|
+
getHiddenFields?: (value: Partial<T>) => Partial<Record<keyof T, boolean>>;
|
|
22
|
+
disabledFields?: Partial<Record<keyof T, boolean>>;
|
|
21
23
|
closeState?: {
|
|
22
24
|
Success?: boolean;
|
|
23
25
|
Fail?: boolean;
|
|
24
26
|
};
|
|
25
27
|
contentProps?: BoxProps;
|
|
26
|
-
|
|
28
|
+
preSubmit?: IPreSubmitEvent<T>;
|
|
29
|
+
formSlots?: IFormBaseSlots;
|
|
27
30
|
}
|
|
28
31
|
export interface IFormGridLayoutParams<T> extends IFormGridLayoutSlots<T> {
|
|
29
32
|
configs: IFormGridLayoutConfig<T>[];
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/// <reference path="./@types/global.d.ts" />
|
|
2
|
+
export * from './utils';
|
|
2
3
|
export * from './api-context';
|
|
3
4
|
export * from './components';
|
|
4
|
-
export * from './data-view';
|
|
5
|
-
export * from './filter-bar';
|
|
6
5
|
export * from './form';
|
|
7
6
|
export * from './hooks';
|
|
8
7
|
export * from './redux';
|
|
9
8
|
export * from './table';
|
|
10
9
|
export * from './table-grid';
|
|
11
|
-
export * from './
|
|
10
|
+
export * from './data-view';
|
|
@@ -20,20 +20,20 @@ interface ISearchMatchQuickly extends ISearchMatchBase {
|
|
|
20
20
|
rule: ESearchMatch.AlwaysVisible | ESearchMatch.LinkYoutube | ESearchMatch.Link | ESearchMatch.Guid;
|
|
21
21
|
}
|
|
22
22
|
type IFieldSearchMatch = ISearchMatchMatchOnly | ISearchMatchQuickly;
|
|
23
|
-
export declare enum
|
|
23
|
+
export declare enum EMenuValidate {
|
|
24
24
|
LinkYoutube = "LinkYoutube",
|
|
25
25
|
Link = "Link",
|
|
26
26
|
Custom = "Custom"
|
|
27
27
|
}
|
|
28
28
|
interface IFieldValidateBase {
|
|
29
|
-
rule:
|
|
29
|
+
rule: EMenuValidate;
|
|
30
30
|
}
|
|
31
31
|
interface IFieldValidateCustom extends IFieldValidateBase {
|
|
32
|
-
rule:
|
|
32
|
+
rule: EMenuValidate.Custom;
|
|
33
33
|
custom: (value: string) => boolean;
|
|
34
34
|
}
|
|
35
35
|
interface IFieldValidateQuickly extends IFieldValidateBase {
|
|
36
|
-
rule:
|
|
36
|
+
rule: EMenuValidate.Link | EMenuValidate.LinkYoutube;
|
|
37
37
|
}
|
|
38
38
|
type IFieldValidate = IFieldValidateQuickly | IFieldValidateCustom;
|
|
39
39
|
export interface IQuickSearchDef<T> {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ComponentType, ReactNode } from 'react';
|
|
2
2
|
import { GridProps, RegularBreakpoints } from '@mui/material';
|
|
3
3
|
import { IToolbarPannelProps } from './toolbar-pannel';
|
|
4
|
-
import { IFilterBarConfigs, IFilterState } from '
|
|
4
|
+
import { IFilterBarConfigs, IFilterState } from './filter-bar';
|
|
5
5
|
import { TableGridItemActionsConfig, ITableGridItemActionsBaseProps } from './item-actions';
|
|
6
6
|
export interface ITableGridItemProps<T = any> {
|
|
7
7
|
value: T;
|