es-grid-template 0.0.4 → 0.0.7

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 (64) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/LICENSE +19 -0
  3. package/README.md +1 -6
  4. package/{dist/components/GridTable → es}/CheckboxFilter.d.ts +1 -1
  5. package/es/CheckboxFilter.js +249 -0
  6. package/{dist/components/GridTable → es}/ColumnsChoose.d.ts +3 -2
  7. package/es/ColumnsChoose.js +213 -0
  8. package/{dist/components/GridTable → es}/ContextMenu.d.ts +1 -1
  9. package/es/ContextMenu.js +126 -0
  10. package/{dist/components/GridTable → es}/FilterSearch.d.ts +3 -3
  11. package/es/FilterSearch.js +33 -0
  12. package/es/GridTable.d.ts +7 -0
  13. package/es/GridTable.js +927 -0
  14. package/es/hooks/constant.js +214 -0
  15. package/es/hooks/index.js +5 -0
  16. package/{dist → es}/hooks/useColumns/index.d.ts +1 -1
  17. package/es/hooks/useColumns/index.js +25 -0
  18. package/{dist → es}/hooks/useIsOverflow.d.ts +1 -1
  19. package/es/hooks/useIsOverflow.js +17 -0
  20. package/es/hooks/useOnClickOutside.js +28 -0
  21. package/{dist → es}/hooks/utils.d.ts +7 -3
  22. package/es/hooks/utils.js +192 -0
  23. package/es/index.d.ts +2 -0
  24. package/es/index.js +2 -0
  25. package/es/styles.scss +30 -0
  26. package/es/type.d.ts +88 -0
  27. package/es/type.js +1 -0
  28. package/lib/CheckboxFilter.d.ts +19 -0
  29. package/lib/CheckboxFilter.js +257 -0
  30. package/lib/ColumnsChoose.d.ts +10 -0
  31. package/lib/ColumnsChoose.js +223 -0
  32. package/lib/ContextMenu.d.ts +20 -0
  33. package/lib/ContextMenu.js +135 -0
  34. package/lib/FilterSearch.d.ts +12 -0
  35. package/lib/FilterSearch.js +42 -0
  36. package/lib/GridTable.d.ts +7 -0
  37. package/lib/GridTable.js +936 -0
  38. package/lib/hooks/constant.d.ts +48 -0
  39. package/lib/hooks/constant.js +221 -0
  40. package/lib/hooks/index.d.ts +4 -0
  41. package/lib/hooks/index.js +49 -0
  42. package/lib/hooks/useColumns/index.d.ts +2 -0
  43. package/lib/hooks/useColumns/index.js +31 -0
  44. package/lib/hooks/useIsOverflow.d.ts +1 -0
  45. package/lib/hooks/useIsOverflow.js +26 -0
  46. package/lib/hooks/useOnClickOutside.d.ts +1 -0
  47. package/lib/hooks/useOnClickOutside.js +36 -0
  48. package/lib/hooks/utils.d.ts +18 -0
  49. package/lib/hooks/utils.js +215 -0
  50. package/lib/index.d.ts +2 -0
  51. package/lib/index.js +9 -0
  52. package/lib/styles.scss +30 -0
  53. package/lib/type.d.ts +88 -0
  54. package/lib/type.js +5 -0
  55. package/package.json +75 -94
  56. package/dist/components/GridTable/GridTable.d.ts +0 -6
  57. package/dist/components/GridTable/index.d.ts +0 -1
  58. package/dist/components/index.d.ts +0 -1
  59. package/dist/index.d.ts +0 -2
  60. package/dist/index.js +0 -53
  61. package/dist/type.d.ts +0 -45
  62. /package/{dist → es}/hooks/constant.d.ts +0 -0
  63. /package/{dist → es}/hooks/index.d.ts +0 -0
  64. /package/{dist → es}/hooks/useOnClickOutside.d.ts +0 -0
@@ -0,0 +1,48 @@
1
+ export declare const defaultWidth: number;
2
+ export declare const defaultRowHeight: number;
3
+ export type IOperator = {
4
+ value: string;
5
+ label: string;
6
+ key: string;
7
+ };
8
+ export declare const numberOperator: IOperator[];
9
+ export declare const stringOperator: IOperator[];
10
+ export declare const dateOperator: IOperator[];
11
+ export declare const dateTimeOperator: IOperator[];
12
+ export declare const booleanOperator: IOperator[];
13
+ export declare const translateOption: (options: IOperator[], t: any) => any[];
14
+ export declare const transferFontSize: any;
15
+ export declare const defaultDateFormat = "d/m/Y";
16
+ export declare const defaultDateTimeFormat = "d/m/Y H:i";
17
+ export declare const defaultTimeFormat = "H:i";
18
+ export declare const defaultPageSizes: number[];
19
+ export declare const alignToFlex: any;
20
+ export declare const optionsSize: {
21
+ label: string;
22
+ value: string;
23
+ width: number;
24
+ height: number;
25
+ }[];
26
+ export declare const paperSize: {
27
+ a4: {
28
+ width: number;
29
+ height: number;
30
+ };
31
+ a3: {
32
+ width: number;
33
+ height: number;
34
+ };
35
+ letter: {
36
+ width: number;
37
+ height: number;
38
+ };
39
+ };
40
+ export declare const optionFont: {
41
+ value: string;
42
+ label: string;
43
+ }[];
44
+ export declare const optionsPaperOrientation: any[];
45
+ export declare const optionFontSize: {
46
+ value: number;
47
+ label: string;
48
+ }[];
@@ -0,0 +1,221 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.translateOption = exports.transferFontSize = exports.stringOperator = exports.paperSize = exports.optionsSize = exports.optionsPaperOrientation = exports.optionFontSize = exports.optionFont = exports.numberOperator = exports.defaultWidth = exports.defaultTimeFormat = exports.defaultRowHeight = exports.defaultPageSizes = exports.defaultDateTimeFormat = exports.defaultDateFormat = exports.dateTimeOperator = exports.dateOperator = exports.booleanOperator = exports.alignToFlex = void 0;
7
+ const defaultWidth = exports.defaultWidth = 100;
8
+ const defaultRowHeight = exports.defaultRowHeight = 35;
9
+ const numberOperator = exports.numberOperator = [{
10
+ value: 'equal',
11
+ label: 'Equal',
12
+ key: '=='
13
+ }, {
14
+ value: 'greaterthan',
15
+ label: 'Greater than',
16
+ key: '>'
17
+ }, {
18
+ value: 'greaterthan',
19
+ label: 'Greater Than or Equal',
20
+ key: '>='
21
+ }, {
22
+ value: 'lessthan',
23
+ label: 'Less Than',
24
+ key: '<'
25
+ }, {
26
+ value: 'lessthanorequal',
27
+ label: 'Less Than Or Equal',
28
+ key: '<='
29
+ }, {
30
+ value: 'notequal',
31
+ label: 'Not Equal',
32
+ key: '!='
33
+ }];
34
+ const stringOperator = exports.stringOperator = [{
35
+ value: 'startswith',
36
+ key: '_=',
37
+ label: 'Starts With'
38
+ }, {
39
+ value: 'endswith',
40
+ key: '|=',
41
+ label: 'Ends With'
42
+ }, {
43
+ value: 'contains',
44
+ key: '~=',
45
+ label: 'Contains'
46
+ }, {
47
+ value: 'equal',
48
+ key: '==',
49
+ label: 'Equal'
50
+ }, {
51
+ value: 'notequal',
52
+ key: '!=',
53
+ label: 'Not Equal'
54
+ }];
55
+ const dateOperator = exports.dateOperator = [{
56
+ value: 'equal',
57
+ key: '==',
58
+ label: 'Equal'
59
+ }, {
60
+ value: 'notequal',
61
+ key: '!=',
62
+ label: 'Not Equal'
63
+ }, {
64
+ value: 'greaterthan',
65
+ key: '>',
66
+ label: 'Greater Than'
67
+ }, {
68
+ value: 'lessthan',
69
+ key: '<',
70
+ label: 'Less Than'
71
+ }];
72
+ const dateTimeOperator = exports.dateTimeOperator = [{
73
+ value: 'equal',
74
+ key: '==',
75
+ label: 'Equal'
76
+ }, {
77
+ value: 'notequal',
78
+ key: '!=',
79
+ label: 'Not Equal'
80
+ }, {
81
+ value: 'greaterthan',
82
+ key: '>',
83
+ label: 'Greater Than'
84
+ }, {
85
+ value: 'lessthan',
86
+ key: '<',
87
+ label: 'Less Than'
88
+ }];
89
+ const booleanOperator = exports.booleanOperator = [{
90
+ value: 'equal',
91
+ key: '==',
92
+ label: 'Equal'
93
+ }, {
94
+ value: 'notequal',
95
+ key: '!=',
96
+ label: 'Not Equal'
97
+ }];
98
+ const translateOption = (options, t) => {
99
+ if (!t) {
100
+ return options;
101
+ }
102
+ return options.map(it => ({
103
+ ...it,
104
+ label: t(it.label)
105
+ }));
106
+ };
107
+ exports.translateOption = translateOption;
108
+ const transferFontSize = exports.transferFontSize = {
109
+ 6: 8,
110
+ 7: 9,
111
+ 8: 11,
112
+ 9: 12,
113
+ 10: 13,
114
+ 11: 15,
115
+ 12: 16,
116
+ 13: 17,
117
+ 14: 19,
118
+ 15: 20,
119
+ 16: 21,
120
+ 17: 23,
121
+ 18: 24,
122
+ 19: 25,
123
+ 20: 27,
124
+ 21: 28,
125
+ 22: 29,
126
+ 24: 32,
127
+ 26: 35,
128
+ 27: 36,
129
+ 28: 37
130
+ };
131
+ const defaultDateFormat = exports.defaultDateFormat = 'd/m/Y';
132
+ const defaultDateTimeFormat = exports.defaultDateTimeFormat = 'd/m/Y H:i';
133
+ const defaultTimeFormat = exports.defaultTimeFormat = 'H:i';
134
+ const defaultPageSizes = exports.defaultPageSizes = [20, 30, 50, 100];
135
+ const alignToFlex = exports.alignToFlex = {
136
+ center: 'center',
137
+ left: 'start',
138
+ right: 'end'
139
+ };
140
+ const optionsSize = exports.optionsSize = [{
141
+ label: 'letter',
142
+ value: 'letter',
143
+ width: 21.59,
144
+ height: 27.94
145
+ }, {
146
+ label: 'A3',
147
+ value: 'a3',
148
+ width: 27.94,
149
+ height: 42
150
+ }, {
151
+ label: 'A4',
152
+ value: 'a4',
153
+ width: 21,
154
+ height: 29.7
155
+ }];
156
+ const paperSize = exports.paperSize = {
157
+ a4: {
158
+ width: 21,
159
+ height: 29.7
160
+ },
161
+ a3: {
162
+ width: 27.94,
163
+ height: 42
164
+ },
165
+ letter: {
166
+ width: 21.59,
167
+ height: 27.94
168
+ }
169
+ };
170
+ const optionFont = exports.optionFont = [{
171
+ value: 'Times New Roman',
172
+ label: 'Times New Roman'
173
+ }, {
174
+ value: 'Calibri',
175
+ label: 'Calibri (Body)'
176
+ }];
177
+ // portrait' | 'landscape'
178
+ const optionsPaperOrientation = exports.optionsPaperOrientation = [{
179
+ value: 'portrait',
180
+ label: 'portrait'
181
+ }, {
182
+ value: 'landscape',
183
+ label: 'landscape'
184
+ }];
185
+ const optionFontSize = exports.optionFontSize = [{
186
+ value: 8,
187
+ label: '8'
188
+ }, {
189
+ value: 9,
190
+ label: '9'
191
+ }, {
192
+ value: 10,
193
+ label: '10'
194
+ }, {
195
+ value: 11,
196
+ label: '11'
197
+ }, {
198
+ value: 12,
199
+ label: '12'
200
+ }, {
201
+ value: 13,
202
+ label: '13'
203
+ }, {
204
+ value: 14,
205
+ label: '14'
206
+ }, {
207
+ value: 16,
208
+ label: '16'
209
+ }, {
210
+ value: 18,
211
+ label: '18'
212
+ }, {
213
+ value: 24,
214
+ label: '24'
215
+ }, {
216
+ value: 36,
217
+ label: '36'
218
+ }, {
219
+ value: 48,
220
+ label: '48'
221
+ }];
@@ -0,0 +1,4 @@
1
+ export * from './constant';
2
+ export * from './useIsOverflow';
3
+ export * from './useOnClickOutside';
4
+ export * from './utils';
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _constant = require("./constant");
7
+ Object.keys(_constant).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _constant[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _constant[key];
14
+ }
15
+ });
16
+ });
17
+ var _useIsOverflow = require("./useIsOverflow");
18
+ Object.keys(_useIsOverflow).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _useIsOverflow[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _useIsOverflow[key];
25
+ }
26
+ });
27
+ });
28
+ var _useOnClickOutside = require("./useOnClickOutside");
29
+ Object.keys(_useOnClickOutside).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _useOnClickOutside[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _useOnClickOutside[key];
36
+ }
37
+ });
38
+ });
39
+ var _utils = require("./utils");
40
+ Object.keys(_utils).forEach(function (key) {
41
+ if (key === "default" || key === "__esModule") return;
42
+ if (key in exports && exports[key] === _utils[key]) return;
43
+ Object.defineProperty(exports, key, {
44
+ enumerable: true,
45
+ get: function () {
46
+ return _utils[key];
47
+ }
48
+ });
49
+ });
@@ -0,0 +1,2 @@
1
+ import type { ColumnsType, ColumnType } from "../../type";
2
+ export declare function flatColumns<RecordType>(columns: ColumnsType<RecordType>, parentKey?: string): ColumnType<RecordType>[];
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.flatColumns = flatColumns;
7
+ // import * as React from 'react'
8
+
9
+ function flatColumns(columns, parentKey = 'key') {
10
+ // @ts-ignore
11
+ return columns.filter(column => column && typeof column === 'object').reduce((list, column, index) => {
12
+ const {
13
+ fixed
14
+ } = column;
15
+ // Convert `fixed='true'` to `fixed='left'` instead
16
+ const parsedFixed = fixed === true ? 'left' : fixed;
17
+ const mergedKey = `${parentKey}-${index}`;
18
+ const subColumns = column.children;
19
+ if (subColumns && subColumns.length > 0) {
20
+ return [...list, ...flatColumns(subColumns, mergedKey).map(subColum => ({
21
+ fixed: parsedFixed,
22
+ ...subColum
23
+ }))];
24
+ }
25
+ return [...list, {
26
+ key: mergedKey,
27
+ ...column,
28
+ fixed: parsedFixed
29
+ }];
30
+ }, []);
31
+ }
@@ -0,0 +1 @@
1
+ export declare const useIsOverflow: (ref: any, callback?: any) => boolean;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useIsOverflow = void 0;
7
+ var React = _interopRequireWildcard(require("react"));
8
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
9
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
10
+ const useIsOverflow = (ref, callback) => {
11
+ const [isOverflow, setIsOverflow] = React.useState(false);
12
+ React.useLayoutEffect(() => {
13
+ const trigger = () => {
14
+ const hasOverflow = ref?.current?.scrollWidth > ref?.current?.clientWidth;
15
+ setIsOverflow(hasOverflow);
16
+ if (callback) {
17
+ callback(hasOverflow);
18
+ }
19
+ };
20
+ if (ref) {
21
+ trigger();
22
+ }
23
+ }, [callback, ref]);
24
+ return isOverflow;
25
+ };
26
+ exports.useIsOverflow = useIsOverflow;
@@ -0,0 +1 @@
1
+ export declare const useOnClickOutside: (ref: any, handler: any) => void;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useOnClickOutside = void 0;
7
+ var _react = require("react");
8
+ //** React Imports
9
+
10
+ const useOnClickOutside = (ref, handler) => {
11
+ (0, _react.useEffect)(() => {
12
+ const listener = event => {
13
+ // ** Do nothing if clicking ref's element or descendent elements
14
+ if (!ref.current || ref.current.contains(event.target)) {
15
+ return;
16
+ }
17
+
18
+ // ** Call passed function on click outside
19
+ handler(event);
20
+ };
21
+ document.addEventListener('mousedown', listener);
22
+ document.addEventListener('touchstart', listener);
23
+ return () => {
24
+ document.removeEventListener('mousedown', listener);
25
+ document.removeEventListener('touchstart', listener);
26
+ };
27
+ },
28
+ // ** Add ref and handler to effect dependencies
29
+ // ** It's worth noting that because passed in handler is a new ...
30
+ // ** ... function on every render that will cause this effect ...
31
+ // ** ... callback/cleanup to run every render. It's not a big deal ...
32
+ // ** ... but to optimize you can wrap handler in useCallback before ...
33
+ // ** ... passing it into this hook.
34
+ [ref, handler]);
35
+ };
36
+ exports.useOnClickOutside = useOnClickOutside;
@@ -0,0 +1,18 @@
1
+ import dayjs from "dayjs";
2
+ import type { EditType, IColumnType, TypeFilter } from "ui-rc";
3
+ import type { ColumnType } from "../type";
4
+ export declare const sumDataByField: (data: any[], field: string) => any;
5
+ export declare const checkThousandSeparator: (thousandSeparator: string | undefined, decimalSeparator: string | undefined) => string;
6
+ export declare const checkDecimalSeparator: (thousandSeparator: string | undefined, decimalSeparator: string | undefined) => string;
7
+ export declare const isEmpty: (d: any) => boolean;
8
+ export declare const isNullOrUndefined: (d: any) => boolean;
9
+ export declare const convertDayjsToDate: (dateString: string, format: string) => Date;
10
+ export declare const convertDateToDayjs: (date: Date | undefined, format: string) => dayjs.Dayjs;
11
+ export declare const isNameColor: (strColor: string) => boolean;
12
+ export declare const isColor: (value: string) => boolean;
13
+ export declare const getAllVisibleKeys: (columns: any[]) => any[];
14
+ export declare const getVisibleColumnKeys: (columns: any[]) => string[];
15
+ export declare function getHiddenParentKeys(columns: any[], parentKeys?: string[]): string[];
16
+ export declare const updateColumns: (columns: any[], includes: string[]) => any[];
17
+ export declare const getDatepickerFormat: (type: EditType | TypeFilter | IColumnType, col: ColumnType<any>) => string;
18
+ export declare const getTypeFilter: (col: ColumnType<any>) => TypeFilter;
@@ -0,0 +1,215 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.getDatepickerFormat = exports.getAllVisibleKeys = exports.convertDayjsToDate = exports.convertDateToDayjs = exports.checkThousandSeparator = exports.checkDecimalSeparator = void 0;
8
+ exports.getHiddenParentKeys = getHiddenParentKeys;
9
+ exports.updateColumns = exports.sumDataByField = exports.isNullOrUndefined = exports.isNameColor = exports.isEmpty = exports.isColor = exports.getVisibleColumnKeys = exports.getTypeFilter = void 0;
10
+ var _dayjs = _interopRequireDefault(require("dayjs"));
11
+ const sumDataByField = (data, field) => {
12
+ if (data && data.length > 0) {
13
+ return data.reduce((accumulator, currentValue) => {
14
+ const val = typeof currentValue[field] === 'number' || !isNaN(currentValue[field]) ? Number(currentValue[field]) : 0;
15
+ return accumulator + val;
16
+ }, 0);
17
+ } else {
18
+ return 0;
19
+ }
20
+ };
21
+ exports.sumDataByField = sumDataByField;
22
+ const checkThousandSeparator = (thousandSeparator, decimalSeparator) => {
23
+ if (thousandSeparator) {
24
+ if (decimalSeparator) {
25
+ if (thousandSeparator === decimalSeparator) {
26
+ return ',';
27
+ } else {
28
+ return thousandSeparator;
29
+ }
30
+ } else {
31
+ return thousandSeparator;
32
+ }
33
+ } else {
34
+ return undefined;
35
+ }
36
+ };
37
+ exports.checkThousandSeparator = checkThousandSeparator;
38
+ const checkDecimalSeparator = (thousandSeparator, decimalSeparator) => {
39
+ if (decimalSeparator) {
40
+ if (thousandSeparator) {
41
+ if (thousandSeparator === decimalSeparator) {
42
+ return '.';
43
+ } else {
44
+ return decimalSeparator;
45
+ }
46
+ } else {
47
+ return decimalSeparator;
48
+ }
49
+ } else {
50
+ if (thousandSeparator && thousandSeparator === '.') {
51
+ return ',';
52
+ }
53
+ return '.';
54
+ }
55
+ };
56
+ exports.checkDecimalSeparator = checkDecimalSeparator;
57
+ const isEmpty = d => {
58
+ if (d === null || d === undefined || d === '') {
59
+ return true;
60
+ }
61
+ return false;
62
+ };
63
+ exports.isEmpty = isEmpty;
64
+ const isNullOrUndefined = d => {
65
+ if (d === null || d === undefined) {
66
+ return true;
67
+ }
68
+ return false;
69
+ };
70
+ exports.isNullOrUndefined = isNullOrUndefined;
71
+ const convertDayjsToDate = (dateString, format) => {
72
+ const dayjsDate = (0, _dayjs.default)(dateString, format); // Parse using the provided format
73
+ if (!dayjsDate.isValid()) {
74
+ throw new Error('Invalid date or format');
75
+ }
76
+ // return moment(dayjsDate.toDate()).format() // Convert to JavaScript Date
77
+ return dayjsDate.toDate(); // Convert to JavaScript Date
78
+ };
79
+ exports.convertDayjsToDate = convertDayjsToDate;
80
+ const convertDateToDayjs = (date, format) => {
81
+ const dateValue = date ? (0, _dayjs.default)(date).format(format) : null;
82
+ return dateValue ? (0, _dayjs.default)(dateValue, format) : null;
83
+ };
84
+ exports.convertDateToDayjs = convertDateToDayjs;
85
+ const isNameColor = strColor => {
86
+ const s = new Option().style;
87
+ s.color = strColor;
88
+ return s.color === strColor;
89
+ };
90
+ exports.isNameColor = isNameColor;
91
+ const isColor = value => {
92
+ const hexRegex = /^#([0-9A-F]{3}){1,2}$/i;
93
+ const rgbRegex = /^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/;
94
+ const rgbaRegex = /^rgba\((\d{1,3}), (\d{1,3}), (\d{1,3}), (0|1|0?\.\d+)\)$/;
95
+ const hslRegex = /^hsl\(\d{1,3}, \d{1,3}%, \d{1,3}%\)$/;
96
+ const hslaRegex = /^hsla\(\d{1,3}, \d{1,3}%, \d{1,3}%, (0|1|0?\.\d+)\)$/;
97
+ const namedColors = /^(?:aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|purple|red|silver|teal|white|yellow)$/i;
98
+ return hexRegex.test(value) || rgbRegex.test(value) || rgbaRegex.test(value) || hslRegex.test(value) || hslaRegex.test(value) || namedColors.test(value) || isNameColor(value);
99
+ };
100
+ exports.isColor = isColor;
101
+ const getAllVisibleKeys = columns => {
102
+ const keys = [];
103
+ const traverse = (cols, parentHidden = false) => {
104
+ for (const col of cols) {
105
+ if (col.hidden || parentHidden) {
106
+ continue;
107
+ }
108
+ if (col.key) {
109
+ keys.push(col.key);
110
+ }
111
+ if (col.children) {
112
+ traverse(col.children, col.hidden);
113
+ }
114
+ }
115
+ };
116
+ traverse(columns);
117
+ return keys;
118
+ };
119
+ exports.getAllVisibleKeys = getAllVisibleKeys;
120
+ const getVisibleColumnKeys = columns => {
121
+ const allKeys = getAllVisibleKeys(columns);
122
+ const allParentKeys = getHiddenParentKeys(columns);
123
+ const rs = allKeys.filter(item => !allParentKeys.includes(item));
124
+ return rs;
125
+ };
126
+ exports.getVisibleColumnKeys = getVisibleColumnKeys;
127
+ function getHiddenParentKeys(columns, parentKeys = []) {
128
+ const hiddenParents = new Set();
129
+ for (const column of columns) {
130
+ if (column.children) {
131
+ const currentPath = column.key ? [...parentKeys, column.key] : [...parentKeys];
132
+ const childHiddenParents = getHiddenParentKeys(column.children, currentPath);
133
+ if (childHiddenParents.length > 0) {
134
+ childHiddenParents.forEach(key => hiddenParents.add(key));
135
+ currentPath.forEach(key => hiddenParents.add(key));
136
+ }
137
+ } else if (column.hidden) {
138
+ parentKeys.forEach(key => hiddenParents.add(key));
139
+ }
140
+ }
141
+ return Array.from(hiddenParents);
142
+ }
143
+ const updateColumns = (columns, includes) => {
144
+ return columns.map(column => {
145
+ const newColumn = {
146
+ ...column
147
+ };
148
+ let hasVisibleChild = false;
149
+ if (newColumn.children) {
150
+ newColumn.children = updateColumns(newColumn.children, includes);
151
+ hasVisibleChild = newColumn.children.some(child => !child.hidden);
152
+ }
153
+ if (newColumn.key && !includes.includes(newColumn.key)) {
154
+ newColumn.hidden = true;
155
+ } else {
156
+ newColumn.hidden = false;
157
+ }
158
+ if (newColumn.children && newColumn.children.length > 0) {
159
+ newColumn.hidden = !hasVisibleChild;
160
+ }
161
+ return newColumn;
162
+ });
163
+ };
164
+ exports.updateColumns = updateColumns;
165
+ const getDatepickerFormat = (type, col) => {
166
+ const typeFormat = type ? type.toLowerCase() : '';
167
+ switch (typeFormat) {
168
+ case "date":
169
+ case "daterange":
170
+ return col.format?.dateFormat ? col.format?.dateFormat : 'DD/MM/YYYY';
171
+ case "datetime":
172
+ return col.format?.datetimeFormat ? col.format?.datetimeFormat : 'DD/MM/YYYY HH:mm';
173
+ case "week":
174
+ return col.format?.weekFormat ? col.format?.weekFormat : 'DD/MM';
175
+ case "month":
176
+ return col.format?.monthFormat ? col.format?.monthFormat : 'MM/YYYY';
177
+ case "quarter":
178
+ return col.format?.dateFormat ? col.format?.dateFormat : 'DD/MM/YYYY';
179
+ case "year":
180
+ return col.format?.yearFormat ? col.format?.yearFormat : 'YYYY';
181
+ case "time":
182
+ return col.format?.timeFormat ? col.format?.timeFormat : 'HH:mm';
183
+ default:
184
+ return undefined;
185
+ }
186
+ };
187
+ exports.getDatepickerFormat = getDatepickerFormat;
188
+ const getTypeFilter = col => {
189
+ if (col.typeFilter) {
190
+ return col.typeFilter;
191
+ }
192
+ const type = col.type ?? '';
193
+ switch (type) {
194
+ case "number":
195
+ return 'Number';
196
+ case "date":
197
+ return 'Date';
198
+ case "datetime":
199
+ return 'Datetime';
200
+ case "boolean":
201
+ return 'Checkbox';
202
+ case "checkbox":
203
+ return 'Checkbox';
204
+
205
+ // case "week": return ''
206
+ // case "month": return col.format?.monthFormat ? col.format?.monthFormat : 'MM/YYYY'
207
+ // case "quarter": return col.format?.dateFormat ? col.format?.dateFormat : 'DD/MM/YYYY'
208
+ // case "year": return col.format?.yearFormat ? col.format?.yearFormat : 'YYYY'
209
+ // case "time": return col.format?.timeFormat ? col.format?.timeFormat : 'HH:mm'
210
+ case "string":
211
+ default:
212
+ return 'Text';
213
+ }
214
+ };
215
+ exports.getTypeFilter = getTypeFilter;
package/lib/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import GridTable from './GridTable';
2
+ export default GridTable;
package/lib/index.js ADDED
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _GridTable = _interopRequireDefault(require("./GridTable"));
9
+ var _default = exports.default = _GridTable.default;