es-grid-template 0.0.7 → 0.0.13

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.
Files changed (116) hide show
  1. package/LICENSE +21 -19
  2. package/es/{CheckboxFilter.d.ts → grid-component/CheckboxFilter.d.ts} +1 -1
  3. package/es/{CheckboxFilter.js → grid-component/CheckboxFilter.js} +7 -11
  4. package/es/grid-component/ColumnsChoose.d.ts +9 -0
  5. package/es/{ColumnsChoose.js → grid-component/ColumnsChoose.js} +66 -70
  6. package/es/grid-component/EditableCell.d.ts +19 -0
  7. package/es/grid-component/EditableCell.js +842 -0
  8. package/es/{FilterSearch.js → grid-component/FilterSearch.js} +2 -2
  9. package/es/grid-component/GridStyle.d.ts +4 -0
  10. package/es/grid-component/GridStyle.js +5 -0
  11. package/es/grid-component/InternalTable.d.ts +6 -0
  12. package/es/grid-component/InternalTable.js +283 -0
  13. package/es/grid-component/LoadingSpinner.d.ts +3 -0
  14. package/es/grid-component/LoadingSpinner.js +20 -0
  15. package/es/grid-component/Message/Message.d.ts +2 -0
  16. package/es/grid-component/Message/Message.js +16 -0
  17. package/es/grid-component/Message/index.d.ts +1 -0
  18. package/es/grid-component/Message/index.js +1 -0
  19. package/es/grid-component/TableGrid.d.ts +10 -0
  20. package/es/grid-component/TableGrid.js +375 -0
  21. package/es/grid-component/async-table-select/index.d.ts +9 -0
  22. package/es/grid-component/async-table-select/index.js +37 -0
  23. package/es/{hooks → grid-component/hooks}/constant.d.ts +14 -0
  24. package/es/{hooks → grid-component/hooks}/constant.js +17 -2
  25. package/es/grid-component/hooks/useColumns/index.d.ts +6 -0
  26. package/es/grid-component/hooks/useColumns/index.js +422 -0
  27. package/es/grid-component/hooks/utils.d.ts +35 -0
  28. package/es/{hooks → grid-component/hooks}/utils.js +147 -19
  29. package/es/grid-component/index.d.ts +2 -0
  30. package/es/grid-component/index.js +2 -0
  31. package/es/grid-component/rc-table/Grid.d.ts +8 -0
  32. package/es/grid-component/rc-table/Grid.js +99 -0
  33. package/es/grid-component/rc-table/GridEdit.d.ts +9 -0
  34. package/es/grid-component/rc-table/GridEdit.js +706 -0
  35. package/es/grid-component/type.d.ts +225 -0
  36. package/es/grid-component/useContext.d.ts +27 -0
  37. package/es/grid-component/useContext.js +4 -0
  38. package/es/index.d.ts +1 -2
  39. package/es/index.js +2 -2
  40. package/es/table-grid/styles.scss +551 -0
  41. package/lib/{CheckboxFilter.d.ts → grid-component/CheckboxFilter.d.ts} +1 -1
  42. package/lib/{CheckboxFilter.js → grid-component/CheckboxFilter.js} +11 -14
  43. package/lib/grid-component/ColumnsChoose.d.ts +9 -0
  44. package/lib/{ColumnsChoose.js → grid-component/ColumnsChoose.js} +66 -70
  45. package/lib/grid-component/EditableCell.d.ts +19 -0
  46. package/lib/grid-component/EditableCell.js +844 -0
  47. package/lib/{FilterSearch.js → grid-component/FilterSearch.js} +3 -3
  48. package/lib/grid-component/GridStyle.d.ts +4 -0
  49. package/lib/grid-component/GridStyle.js +12 -0
  50. package/lib/grid-component/InternalTable.d.ts +6 -0
  51. package/lib/grid-component/InternalTable.js +292 -0
  52. package/lib/grid-component/LoadingSpinner.d.ts +3 -0
  53. package/lib/grid-component/LoadingSpinner.js +29 -0
  54. package/lib/grid-component/Message/Message.d.ts +2 -0
  55. package/lib/grid-component/Message/Message.js +25 -0
  56. package/lib/grid-component/Message/index.d.ts +1 -0
  57. package/lib/grid-component/Message/index.js +16 -0
  58. package/lib/grid-component/TableGrid.d.ts +10 -0
  59. package/lib/grid-component/TableGrid.js +382 -0
  60. package/lib/grid-component/async-table-select/index.d.ts +9 -0
  61. package/lib/grid-component/async-table-select/index.js +46 -0
  62. package/lib/{hooks → grid-component/hooks}/constant.d.ts +14 -0
  63. package/lib/{hooks → grid-component/hooks}/constant.js +18 -3
  64. package/lib/grid-component/hooks/useColumns/index.d.ts +6 -0
  65. package/lib/grid-component/hooks/useColumns/index.js +435 -0
  66. package/lib/grid-component/hooks/utils.d.ts +35 -0
  67. package/lib/{hooks → grid-component/hooks}/utils.js +164 -22
  68. package/lib/grid-component/index.d.ts +2 -0
  69. package/lib/grid-component/index.js +9 -0
  70. package/lib/grid-component/rc-table/Grid.d.ts +8 -0
  71. package/lib/grid-component/rc-table/Grid.js +108 -0
  72. package/lib/grid-component/rc-table/GridEdit.d.ts +9 -0
  73. package/lib/grid-component/rc-table/GridEdit.js +715 -0
  74. package/lib/grid-component/type.d.ts +225 -0
  75. package/lib/grid-component/useContext.d.ts +27 -0
  76. package/lib/grid-component/useContext.js +10 -0
  77. package/lib/index.d.ts +1 -2
  78. package/lib/index.js +7 -3
  79. package/lib/table-grid/styles.scss +551 -0
  80. package/package.json +17 -6
  81. package/es/ColumnsChoose.d.ts +0 -10
  82. package/es/GridTable.d.ts +0 -7
  83. package/es/GridTable.js +0 -927
  84. package/es/hooks/useColumns/index.d.ts +0 -2
  85. package/es/hooks/useColumns/index.js +0 -25
  86. package/es/hooks/utils.d.ts +0 -18
  87. package/es/styles.scss +0 -30
  88. package/es/type.d.ts +0 -88
  89. package/lib/ColumnsChoose.d.ts +0 -10
  90. package/lib/GridTable.d.ts +0 -7
  91. package/lib/GridTable.js +0 -936
  92. package/lib/hooks/useColumns/index.d.ts +0 -2
  93. package/lib/hooks/useColumns/index.js +0 -31
  94. package/lib/hooks/utils.d.ts +0 -18
  95. package/lib/styles.scss +0 -30
  96. package/lib/type.d.ts +0 -88
  97. /package/es/{ContextMenu.d.ts → grid-component/ContextMenu.d.ts} +0 -0
  98. /package/es/{ContextMenu.js → grid-component/ContextMenu.js} +0 -0
  99. /package/es/{FilterSearch.d.ts → grid-component/FilterSearch.d.ts} +0 -0
  100. /package/es/{hooks → grid-component/hooks}/index.d.ts +0 -0
  101. /package/es/{hooks → grid-component/hooks}/index.js +0 -0
  102. /package/es/{hooks → grid-component/hooks}/useIsOverflow.d.ts +0 -0
  103. /package/es/{hooks → grid-component/hooks}/useIsOverflow.js +0 -0
  104. /package/es/{hooks → grid-component/hooks}/useOnClickOutside.d.ts +0 -0
  105. /package/es/{hooks → grid-component/hooks}/useOnClickOutside.js +0 -0
  106. /package/es/{type.js → grid-component/type.js} +0 -0
  107. /package/lib/{ContextMenu.d.ts → grid-component/ContextMenu.d.ts} +0 -0
  108. /package/lib/{ContextMenu.js → grid-component/ContextMenu.js} +0 -0
  109. /package/lib/{FilterSearch.d.ts → grid-component/FilterSearch.d.ts} +0 -0
  110. /package/lib/{hooks → grid-component/hooks}/index.d.ts +0 -0
  111. /package/lib/{hooks → grid-component/hooks}/index.js +0 -0
  112. /package/lib/{hooks → grid-component/hooks}/useIsOverflow.d.ts +0 -0
  113. /package/lib/{hooks → grid-component/hooks}/useIsOverflow.js +0 -0
  114. /package/lib/{hooks → grid-component/hooks}/useOnClickOutside.d.ts +0 -0
  115. /package/lib/{hooks → grid-component/hooks}/useOnClickOutside.js +0 -0
  116. /package/lib/{type.js → grid-component/type.js} +0 -0
@@ -0,0 +1,225 @@
1
+ import type { Key, ReactElement, ReactNode } from "react";
2
+ import type React from "react";
3
+ import type { IOperator } from "./hooks";
4
+ import type { TypeFilter, TableProps as RcTableProps, TableColumnType as RcColumnType, EditType } from "rc-master-ui";
5
+ import type { FilterOperator, TableRowSelection } from "rc-master-ui/es/table/interface";
6
+ import type { ToolbarItem } from "rc-master-ui/es/toolbar";
7
+ import type { ItemType } from "rc-master-ui/es/menu/interface";
8
+ import type { FieldNames, FilterFunc } from "rc-select/es/Select";
9
+ export type IColumnType = "number" | "time" | "date" | "week" | "month" | "file" | "quarter" | "year" | "datetime" | "string" | "boolean" | "checkbox" | "color" | null | undefined;
10
+ export type AnyObject = Record<PropertyKey, any>;
11
+ export type SelectMode = 'checkbox' | 'radio' | undefined;
12
+ export type ITextAlign = 'center' | 'left' | 'right';
13
+ export type ITemplateColumn = {
14
+ value: any;
15
+ column: any;
16
+ rowData: any;
17
+ field: number | string;
18
+ index: number;
19
+ };
20
+ export type ColumnSelectTable = {
21
+ field: string;
22
+ dataIndex: string;
23
+ type?: IColumnType;
24
+ headerText?: string;
25
+ fixedType?: 'left' | 'right' | undefined;
26
+ width?: number | undefined;
27
+ minWidth?: number;
28
+ maxWidth?: number;
29
+ visible?: boolean;
30
+ textAlign?: ITextAlign;
31
+ headerTextAlign?: ITextAlign;
32
+ template?: (props: ITemplateColumn) => ReactNode | ReactElement;
33
+ headerTemplate?: any;
34
+ ellipsis?: boolean | undefined;
35
+ format?: IFormat;
36
+ tooltipDescription?: string | ((rowData: any) => string | ReactNode);
37
+ showTooltip?: boolean;
38
+ showTooltipHeader?: boolean;
39
+ };
40
+ export type IEditSelectSettings = {
41
+ fieldKey?: string;
42
+ /** get value form other field **/
43
+ fieldValue?: string;
44
+ /** get label form other field **/
45
+ fieldLabel?: string;
46
+ inputKey?: string;
47
+ filterKey?: string[];
48
+ selectMode?: SelectMode;
49
+ options: any[];
50
+ getPasteValue?: (value: any) => Record<string, any> | null;
51
+ validateOption?: (rowData: any, field: string) => any[];
52
+ defaultOptions?: any[];
53
+ defaultValue?: (value: any, rowData: any) => {
54
+ value: any;
55
+ label: string;
56
+ [key: string]: string;
57
+ } | null;
58
+ formatOptionLabel?: (option: any) => ReactNode | ReactElement;
59
+ loadOptions?: (search: string, callback: (newOptions: any[]) => void) => void;
60
+ isMulti?: boolean;
61
+ closeMenuOnSelect?: boolean;
62
+ menuWidth?: number;
63
+ menuHeight?: number;
64
+ columns?: ColumnSelectTable[];
65
+ toolbarItems?: ToolbarItem[];
66
+ toolbarClick?: (props: ToolbarClick) => void;
67
+ toolbarHeight?: number;
68
+ hideSelectedOptions?: boolean;
69
+ showItems?: number;
70
+ isLengthSelected?: boolean;
71
+ fieldNames?: FieldNames;
72
+ filterOption?: boolean | FilterFunc<any>;
73
+ };
74
+ export type ToolbarClick = {
75
+ item: any;
76
+ column: any;
77
+ };
78
+ export type ColumnType<RecordType> = Omit<RcColumnType<RecordType>, 'headerTemplate'> & {
79
+ field?: string;
80
+ type?: IColumnType;
81
+ isSummary?: boolean;
82
+ summaryTemplate?: (data: number, key: string) => ReactElement | ReactNode;
83
+ maxWidth?: string | number;
84
+ format?: IFormat;
85
+ allowFiltering?: boolean;
86
+ operator?: FilterOperator;
87
+ placeholder?: string;
88
+ showInColumnChoose?: boolean;
89
+ typeFilter?: TypeFilter;
90
+ headerText?: string;
91
+ template?: ReactNode | ReactElement | ((value: any, record: RecordType, index: number) => ReactNode | ReactElement);
92
+ showTooltip?: boolean;
93
+ tooltipDescription?: ReactNode | ReactElement | ((value: any, record: RecordType, index: number) => ReactNode | ReactElement);
94
+ headerTemplate?: React.ReactNode | React.ReactElement | ((column: ColumnType<RecordType>) => React.ReactNode | React.ReactElement);
95
+ children?: ColumnType<RecordType>[];
96
+ };
97
+ export type ColumnEditType<RecordType> = ColumnType<RecordType> & {
98
+ editType?: EditType | ((rowData?: any) => EditType);
99
+ template?: ReactNode | ReactElement | ((value: any, record: RecordType, index: number) => ReactNode | ReactElement);
100
+ disable?: boolean | ((rowData: any) => boolean);
101
+ isClearable?: boolean;
102
+ maxDate?: any;
103
+ minDate?: any;
104
+ maxTime?: any;
105
+ minTime?: any;
106
+ max?: number;
107
+ min?: number;
108
+ editSelectSettings?: IEditSelectSettings;
109
+ };
110
+ export type ColumnsType<RecordType = AnyObject> = ColumnType<RecordType>[];
111
+ export type ColumnsEditType<RecordType = AnyObject> = ColumnEditType<RecordType>[];
112
+ export type ColumnTable<RecordType = AnyObject> = ColumnEditType<RecordType> | ColumnType<RecordType>;
113
+ export type ColumnsTable<RecordType = AnyObject> = (ColumnType<RecordType> | ColumnEditType<RecordType>)[];
114
+ export interface TableProps<RecordType> extends Omit<RcTableProps<RecordType>, 'columns' | 'rowSelection' | 'loading' | 'dataSource'> {
115
+ editAble?: boolean;
116
+ dataSource: RecordType[];
117
+ columns: ColumnsTable<RecordType>;
118
+ height?: number;
119
+ format?: IFormat;
120
+ t?: any;
121
+ lang?: string;
122
+ contextMenuItems?: any[];
123
+ contextMenuHidden?: string[] | ((args?: Omit<ContextInfo<RecordType>, 'item' | 'event'>) => string[]);
124
+ contextMenuOpen?: (args: Omit<ContextInfo<RecordType>, 'item'>) => void;
125
+ contextMenuClick?: (args: ContextInfo<RecordType>) => void;
126
+ recordDoubleClick?: (args: RecordDoubleClickEventArgs<RecordType>) => void;
127
+ toolbarItems?: ToolbarItem[];
128
+ showColumnChoose?: boolean;
129
+ onFilter?: (query: {
130
+ field: string;
131
+ key: string;
132
+ operator: IOperator;
133
+ predicate: 'and' | 'or';
134
+ value: any;
135
+ }[]) => void;
136
+ onSorter?: (args: {
137
+ column: ColumnType<RecordType>;
138
+ columnKey: string;
139
+ field: string;
140
+ direction: 'Ascending' | 'Descending' | null;
141
+ }) => void;
142
+ selectionSettings?: SelectionSettings;
143
+ rowKey?: string;
144
+ rowSelection?: RowSelection<RecordType>;
145
+ rowSelected?: (args: {
146
+ type: string;
147
+ rowData: RecordType;
148
+ selected: RecordType | RecordType[];
149
+ }) => void;
150
+ dataSourceFilter?: SourceFilter[];
151
+ onFilterClick?: (column: ColumnType<RecordType>, callback: (key: string, data: any) => void) => void;
152
+ loading?: boolean;
153
+ allowResizing?: boolean;
154
+ onDataChange?: (data: RecordType[]) => void;
155
+ }
156
+ export interface TableEditProps<RecordType = AnyObject> extends Omit<TableProps<RecordType>, 'columns'> {
157
+ columns: ColumnsTable<RecordType>;
158
+ onCellPaste?: ICellPasteModel<RecordType>;
159
+ onCellChange?: (args: CellChangeArgs, handleCallback: (rowData: any, index: any, value?: any) => void) => void;
160
+ }
161
+ export type GridTableProps<RecordType = AnyObject> = TableProps<RecordType> | TableEditProps<RecordType>;
162
+ export type CellChangeArgs = {
163
+ type: 'onPaste' | 'onChange' | 'onCellPaste';
164
+ value: any;
165
+ rowData: any;
166
+ rows: any[];
167
+ rowsData: any[];
168
+ indexRow: number;
169
+ rowId?: string;
170
+ field: string;
171
+ indexCol: any;
172
+ sumValue?: any[];
173
+ };
174
+ export type IOnPastedProps = {
175
+ data: any[];
176
+ pastedColumns: string[];
177
+ pasteData: any[];
178
+ type: 'onPaste' | 'onChange' | 'onCellPaste';
179
+ };
180
+ export interface ICellPasteModel<RecordType = AnyObject> {
181
+ onPasted?: (args: IOnPastedProps, handleCallback: (callbackData: any[]) => void) => void;
182
+ dataChange?: (data: RecordType[]) => void;
183
+ getCallbackData?: (props: any) => void;
184
+ }
185
+ export type SourceFilter = {
186
+ key: string;
187
+ data: any[];
188
+ loadOptions?: (search: string, callback: (newOptions: any[]) => void) => void;
189
+ };
190
+ export type RowSelection<RecordType> = Omit<TableRowSelection<RecordType>, 'type' | 'columnWidth' | 'hideSelectAll' | 'defaultSelectedRowKeys'>;
191
+ export type SelectionSettings = {
192
+ mode?: 'checkbox' | 'radio';
193
+ type?: 'single' | 'multiple';
194
+ checkboxOnly?: boolean;
195
+ hideSelectAll?: boolean;
196
+ columnWidth?: number | string;
197
+ defaultSelectedRowKeys?: Key[];
198
+ };
199
+ export type RecordDoubleClickEventArgs<RecordType> = {
200
+ rowData: RecordType;
201
+ rowIndex: number | undefined;
202
+ e: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>;
203
+ };
204
+ export type ContextInfo<RecordType> = {
205
+ rowInfo: {
206
+ rowData: RecordType | null;
207
+ };
208
+ event: React.MouseEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>;
209
+ item: ItemType;
210
+ };
211
+ export type IFormat = {
212
+ thousandSeparator?: string;
213
+ decimalSeparator?: string;
214
+ decimalScale?: number | undefined;
215
+ allowNegative?: boolean;
216
+ prefix?: string | undefined;
217
+ suffix?: string | undefined;
218
+ fixedDecimalScale?: boolean;
219
+ dateFormat?: string;
220
+ datetimeFormat?: string;
221
+ timeFormat?: string;
222
+ weekFormat?: string;
223
+ monthFormat?: string;
224
+ yearFormat?: string;
225
+ };
@@ -0,0 +1,27 @@
1
+ /// <reference types="react" />
2
+ import type { IFormat } from "./type";
3
+ import type { SubmitHandler } from "react-hook-form";
4
+ export interface IContext {
5
+ searchValue?: any;
6
+ setSearchValue?: any;
7
+ open?: boolean;
8
+ setOpen?: any;
9
+ rowKey: string;
10
+ onSave?: any;
11
+ form?: any;
12
+ format?: IFormat;
13
+ control?: any;
14
+ trigger?: any;
15
+ handleSubmit?: any;
16
+ onSubmit?: SubmitHandler<any>;
17
+ getValues?: any;
18
+ handleCellChange?: ({ key, record, type }: ContextCellChange) => void;
19
+ }
20
+ export type ContextCellChange = {
21
+ key: string;
22
+ record: any;
23
+ newState?: any;
24
+ prevState?: any;
25
+ type: 'enter' | 'blur' | 'outClick';
26
+ };
27
+ export declare const TableContext: import("react").Context<IContext>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.TableContext = void 0;
7
+ var _react = require("react");
8
+ const TableContext = exports.TableContext = /*#__PURE__*/(0, _react.createContext)({
9
+ rowKey: 'id'
10
+ });
package/lib/index.d.ts CHANGED
@@ -1,2 +1 @@
1
- import GridTable from './GridTable';
2
- export default GridTable;
1
+ export { default as GridTable } from './grid-component';
package/lib/index.js CHANGED
@@ -4,6 +4,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.default = void 0;
8
- var _GridTable = _interopRequireDefault(require("./GridTable"));
9
- var _default = exports.default = _GridTable.default;
7
+ Object.defineProperty(exports, "GridTable", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _gridComponent.default;
11
+ }
12
+ });
13
+ var _gridComponent = _interopRequireDefault(require("./grid-component"));