es-grid-template 0.0.8 → 0.1.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.
Files changed (116) hide show
  1. package/CHANGELOG.md +6 -6
  2. package/LICENSE +21 -19
  3. package/README.md +1 -1
  4. package/es/{CheckboxFilter.js → grid-component/CheckboxFilter.js} +0 -1
  5. package/es/{ColumnsChoose.js → grid-component/ColumnsChoose.js} +1 -1
  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} +1 -1
  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.js +284 -0
  12. package/es/{LoadingSpinner.js → grid-component/LoadingSpinner.js} +1 -1
  13. package/es/grid-component/Message/Message.d.ts +2 -0
  14. package/es/grid-component/Message/Message.js +16 -0
  15. package/es/grid-component/Message/index.d.ts +1 -0
  16. package/es/grid-component/Message/index.js +1 -0
  17. package/{lib → es/grid-component}/TableGrid.d.ts +2 -2
  18. package/es/grid-component/TableGrid.js +375 -0
  19. package/es/grid-component/async-table-select/index.d.ts +9 -0
  20. package/es/grid-component/async-table-select/index.js +37 -0
  21. package/{lib → es/grid-component}/hooks/constant.d.ts +14 -0
  22. package/es/{hooks → grid-component/hooks}/constant.js +16 -1
  23. package/es/grid-component/hooks/useColumns/index.d.ts +6 -0
  24. package/es/grid-component/hooks/useColumns/index.js +422 -0
  25. package/es/grid-component/hooks/utils.d.ts +35 -0
  26. package/es/{hooks → grid-component/hooks}/utils.js +124 -16
  27. package/es/grid-component/index.d.ts +2 -0
  28. package/es/grid-component/index.js +2 -0
  29. package/es/grid-component/styles.scss +551 -0
  30. package/es/grid-component/table/Grid.d.ts +8 -0
  31. package/es/grid-component/table/Grid.js +99 -0
  32. package/es/grid-component/table/GridEdit.d.ts +9 -0
  33. package/es/grid-component/table/GridEdit.js +706 -0
  34. package/es/grid-component/type.d.ts +225 -0
  35. package/es/grid-component/useContext.d.ts +27 -0
  36. package/es/grid-component/useContext.js +4 -0
  37. package/es/index.d.ts +1 -2
  38. package/es/index.js +1 -2
  39. package/lib/{CheckboxFilter.js → grid-component/CheckboxFilter.js} +0 -1
  40. package/lib/{ColumnsChoose.js → grid-component/ColumnsChoose.js} +1 -1
  41. package/lib/grid-component/EditableCell.d.ts +19 -0
  42. package/lib/grid-component/EditableCell.js +844 -0
  43. package/lib/{FilterSearch.js → grid-component/FilterSearch.js} +1 -1
  44. package/lib/grid-component/GridStyle.d.ts +4 -0
  45. package/lib/grid-component/GridStyle.js +12 -0
  46. package/lib/grid-component/InternalTable.js +293 -0
  47. package/lib/{LoadingSpinner.js → grid-component/LoadingSpinner.js} +1 -1
  48. package/lib/grid-component/Message/Message.d.ts +2 -0
  49. package/lib/grid-component/Message/Message.js +25 -0
  50. package/lib/grid-component/Message/index.d.ts +1 -0
  51. package/lib/grid-component/Message/index.js +16 -0
  52. package/{es → lib/grid-component}/TableGrid.d.ts +2 -2
  53. package/lib/grid-component/TableGrid.js +382 -0
  54. package/lib/grid-component/async-table-select/index.d.ts +9 -0
  55. package/lib/grid-component/async-table-select/index.js +46 -0
  56. package/{es → lib/grid-component}/hooks/constant.d.ts +14 -0
  57. package/lib/{hooks → grid-component/hooks}/constant.js +17 -2
  58. package/lib/grid-component/hooks/useColumns/index.d.ts +6 -0
  59. package/lib/grid-component/hooks/useColumns/index.js +435 -0
  60. package/lib/grid-component/hooks/utils.d.ts +35 -0
  61. package/lib/{hooks → grid-component/hooks}/utils.js +140 -19
  62. package/lib/grid-component/index.d.ts +2 -0
  63. package/lib/grid-component/index.js +9 -0
  64. package/lib/grid-component/styles.scss +551 -0
  65. package/lib/grid-component/table/Grid.d.ts +8 -0
  66. package/lib/grid-component/table/Grid.js +108 -0
  67. package/lib/grid-component/table/GridEdit.d.ts +9 -0
  68. package/lib/grid-component/table/GridEdit.js +715 -0
  69. package/lib/grid-component/type.d.ts +225 -0
  70. package/lib/grid-component/useContext.d.ts +27 -0
  71. package/lib/grid-component/useContext.js +10 -0
  72. package/lib/index.d.ts +1 -2
  73. package/lib/index.js +7 -3
  74. package/package.json +112 -77
  75. package/es/InternalTable.js +0 -185
  76. package/es/TableGrid.js +0 -1055
  77. package/es/hooks/useColumns/index.d.ts +0 -2
  78. package/es/hooks/useColumns/index.js +0 -25
  79. package/es/hooks/utils.d.ts +0 -19
  80. package/es/styles.scss +0 -296
  81. package/es/type.d.ts +0 -100
  82. package/lib/InternalTable.js +0 -194
  83. package/lib/TableGrid.js +0 -1063
  84. package/lib/hooks/useColumns/index.d.ts +0 -2
  85. package/lib/hooks/useColumns/index.js +0 -31
  86. package/lib/hooks/utils.d.ts +0 -19
  87. package/lib/styles.scss +0 -296
  88. package/lib/type.d.ts +0 -100
  89. package/es/{CheckboxFilter.d.ts → grid-component/CheckboxFilter.d.ts} +0 -0
  90. package/es/{ColumnsChoose.d.ts → grid-component/ColumnsChoose.d.ts} +0 -0
  91. package/es/{ContextMenu.d.ts → grid-component/ContextMenu.d.ts} +0 -0
  92. package/es/{ContextMenu.js → grid-component/ContextMenu.js} +0 -0
  93. package/es/{FilterSearch.d.ts → grid-component/FilterSearch.d.ts} +0 -0
  94. package/es/{InternalTable.d.ts → grid-component/InternalTable.d.ts} +1 -1
  95. package/es/{LoadingSpinner.d.ts → grid-component/LoadingSpinner.d.ts} +0 -0
  96. package/es/{hooks → grid-component/hooks}/index.d.ts +0 -0
  97. package/es/{hooks → grid-component/hooks}/index.js +0 -0
  98. package/es/{hooks → grid-component/hooks}/useIsOverflow.d.ts +0 -0
  99. package/es/{hooks → grid-component/hooks}/useIsOverflow.js +0 -0
  100. package/es/{hooks → grid-component/hooks}/useOnClickOutside.d.ts +0 -0
  101. package/es/{hooks → grid-component/hooks}/useOnClickOutside.js +0 -0
  102. package/es/{type.js → grid-component/type.js} +0 -0
  103. package/lib/{CheckboxFilter.d.ts → grid-component/CheckboxFilter.d.ts} +0 -0
  104. package/lib/{ColumnsChoose.d.ts → grid-component/ColumnsChoose.d.ts} +0 -0
  105. package/lib/{ContextMenu.d.ts → grid-component/ContextMenu.d.ts} +0 -0
  106. package/lib/{ContextMenu.js → grid-component/ContextMenu.js} +0 -0
  107. package/lib/{FilterSearch.d.ts → grid-component/FilterSearch.d.ts} +0 -0
  108. package/lib/{InternalTable.d.ts → grid-component/InternalTable.d.ts} +1 -1
  109. /package/lib/{LoadingSpinner.d.ts → grid-component/LoadingSpinner.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,4 @@
1
+ import { createContext } from 'react';
2
+ export const TableContext = /*#__PURE__*/createContext({
3
+ rowKey: 'id'
4
+ });
package/es/index.d.ts CHANGED
@@ -1,2 +1 @@
1
- import InternalTable from './InternalTable';
2
- export default InternalTable;
1
+ export { default as GridComponent } from './grid-component';
package/es/index.js CHANGED
@@ -1,2 +1 @@
1
- import InternalTable from "./InternalTable";
2
- export default InternalTable;
1
+ export { default as GridComponent } from "./grid-component";
@@ -112,7 +112,6 @@ const CheckboxFilter = props => {
112
112
  // [`${dropdownPrefixCls}-menu-without-submenu`]: !hasSubMenu(column.filters || []),
113
113
  [`${dropdownPrefixCls}-menu-without-submenu`]: !hasSubMenu(options || [])
114
114
  });
115
- console.log('selectedKeys', selectedKeys);
116
115
  const empty = /*#__PURE__*/React.createElement(_rcMasterUi.Empty, {
117
116
  image: _rcMasterUi.Empty.PRESENTED_IMAGE_SIMPLE,
118
117
  description: locale.filterEmptyText,
@@ -20,7 +20,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
20
20
 
21
21
  const BoxAction = _styledComponents.default.div.withConfig({
22
22
  displayName: "BoxAction",
23
- componentId: "es-grid-template__sc-1k89i9w-0"
23
+ componentId: "es-grid-template__sc-1ix8yky-0"
24
24
  })(["border-top:1px solid #c4c4c4;padding-top:.75rem;display:flex;justify-content:end;gap:10px;.btn-action{background:none !important;border:none !important;&.btn-action-submit{color:#df4318;&:disabled{background-color:#f0f0f0 !important;}&:hover{color:#df4318 !important;}}&:hover{background-color:#f0f0f0 !important;}}"]);
25
25
  const ColumnsChoose = props => {
26
26
  const {
@@ -0,0 +1,19 @@
1
+ import React from "react";
2
+ import type { ColumnEditType, IFormat } from "./type";
3
+ import type { EditType } from "rc-master-ui";
4
+ interface EditableCellProps<DataType> extends React.HTMLAttributes<HTMLElement> {
5
+ t?: any;
6
+ editing: boolean;
7
+ dataIndex: string;
8
+ title: any;
9
+ editType: EditType;
10
+ record: DataType;
11
+ index: number;
12
+ format?: IFormat;
13
+ column: ColumnEditType<DataType>;
14
+ indexRow: number;
15
+ indexCol: number;
16
+ rowKey: any;
17
+ }
18
+ declare const EditableCell: <T>(props: React.PropsWithChildren<EditableCellProps<T>>) => React.JSX.Element;
19
+ export default EditableCell;