es-grid-template 1.2.3 → 1.2.5

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/assets/index.css CHANGED
@@ -21,12 +21,6 @@
21
21
  overflow: hidden !important;
22
22
  border-inline-end: 0 !important;
23
23
  }
24
- .ui-rc-table-wrapper .ui-rc-table {
25
- line-height: 20px;
26
- }
27
- .ui-rc-table-wrapper .ui-rc-table .ui-rc-table-cell {
28
- min-height: 35px;
29
- }
30
24
  .ui-rc-table-wrapper .ui-rc-table .ui-rc-table-cell .ui-rc-table-filter-column .ui-rc-dropdown-trigger.ui-rc-table-filter-trigger {
31
25
  margin-left: 0;
32
26
  }
@@ -254,9 +248,6 @@
254
248
  .ui-rc-table-wrapper.grid-editable .ui-rc-table.ui-rc-table-ping-right .ui-rc-table-tbody .rc-ui-cell-editable.cell-border-end {
255
249
  z-index: 1;
256
250
  }
257
- .ui-rc-table-wrapper.grid-editable .ui-rc-table.ui-rc-table-small .ui-rc-table-selection-column {
258
- padding: 6px 8px;
259
- }
260
251
  .ui-rc-table-wrapper.grid-editable .ui-rc_cell-content {
261
252
  user-select: none;
262
253
  padding: 7px 8px;
@@ -333,77 +324,66 @@
333
324
  }
334
325
  .ui-rc-table-wrapper.grid-editable .ui-rc-table-tbody .ui-rc-table-row .ui-rc-table-cell:has(.indent-level-0) .ui-rc-table-row-expand-icon {
335
326
  position: absolute;
336
- padding-left: 0px;
337
327
  }
338
328
  .ui-rc-table-wrapper.grid-editable .ui-rc-table-tbody .ui-rc-table-row .ui-rc-table-cell:has(.indent-level-0) .ui-rc_cell-content {
339
329
  padding-left: 8px;
340
330
  }
341
331
  .ui-rc-table-wrapper.grid-editable .ui-rc-table-tbody .ui-rc-table-row .ui-rc-table-cell:has(.indent-level-1) .ui-rc-table-row-expand-icon {
342
332
  position: absolute;
343
- padding-left: 10px;
344
333
  }
345
334
  .ui-rc-table-wrapper.grid-editable .ui-rc-table-tbody .ui-rc-table-row .ui-rc-table-cell:has(.indent-level-1) .ui-rc_cell-content {
346
335
  padding-left: 33px;
347
336
  }
348
337
  .ui-rc-table-wrapper.grid-editable .ui-rc-table-tbody .ui-rc-table-row .ui-rc-table-cell:has(.indent-level-2) .ui-rc-table-row-expand-icon {
349
338
  position: absolute;
350
- padding-left: 20px;
351
339
  }
352
340
  .ui-rc-table-wrapper.grid-editable .ui-rc-table-tbody .ui-rc-table-row .ui-rc-table-cell:has(.indent-level-2) .ui-rc_cell-content {
353
341
  padding-left: 58px;
354
342
  }
355
343
  .ui-rc-table-wrapper.grid-editable .ui-rc-table-tbody .ui-rc-table-row .ui-rc-table-cell:has(.indent-level-3) .ui-rc-table-row-expand-icon {
356
344
  position: absolute;
357
- padding-left: 30px;
358
345
  }
359
346
  .ui-rc-table-wrapper.grid-editable .ui-rc-table-tbody .ui-rc-table-row .ui-rc-table-cell:has(.indent-level-3) .ui-rc_cell-content {
360
347
  padding-left: 83px;
361
348
  }
362
349
  .ui-rc-table-wrapper.grid-editable .ui-rc-table-tbody .ui-rc-table-row .ui-rc-table-cell:has(.indent-level-4) .ui-rc-table-row-expand-icon {
363
350
  position: absolute;
364
- padding-left: 40px;
365
351
  }
366
352
  .ui-rc-table-wrapper.grid-editable .ui-rc-table-tbody .ui-rc-table-row .ui-rc-table-cell:has(.indent-level-4) .ui-rc_cell-content {
367
353
  padding-left: 108px;
368
354
  }
369
355
  .ui-rc-table-wrapper.grid-editable .ui-rc-table-tbody .ui-rc-table-row .ui-rc-table-cell:has(.indent-level-5) .ui-rc-table-row-expand-icon {
370
356
  position: absolute;
371
- padding-left: 50px;
372
357
  }
373
358
  .ui-rc-table-wrapper.grid-editable .ui-rc-table-tbody .ui-rc-table-row .ui-rc-table-cell:has(.indent-level-5) .ui-rc_cell-content {
374
359
  padding-left: 133px;
375
360
  }
376
361
  .ui-rc-table-wrapper.grid-editable .ui-rc-table-tbody .ui-rc-table-row .ui-rc-table-cell:has(.indent-level-6) .ui-rc-table-row-expand-icon {
377
362
  position: absolute;
378
- padding-left: 60px;
379
363
  }
380
364
  .ui-rc-table-wrapper.grid-editable .ui-rc-table-tbody .ui-rc-table-row .ui-rc-table-cell:has(.indent-level-6) .ui-rc_cell-content {
381
365
  padding-left: 158px;
382
366
  }
383
367
  .ui-rc-table-wrapper.grid-editable .ui-rc-table-tbody .ui-rc-table-row .ui-rc-table-cell:has(.indent-level-7) .ui-rc-table-row-expand-icon {
384
368
  position: absolute;
385
- padding-left: 70px;
386
369
  }
387
370
  .ui-rc-table-wrapper.grid-editable .ui-rc-table-tbody .ui-rc-table-row .ui-rc-table-cell:has(.indent-level-7) .ui-rc_cell-content {
388
371
  padding-left: 183px;
389
372
  }
390
373
  .ui-rc-table-wrapper.grid-editable .ui-rc-table-tbody .ui-rc-table-row .ui-rc-table-cell:has(.indent-level-8) .ui-rc-table-row-expand-icon {
391
374
  position: absolute;
392
- padding-left: 80px;
393
375
  }
394
376
  .ui-rc-table-wrapper.grid-editable .ui-rc-table-tbody .ui-rc-table-row .ui-rc-table-cell:has(.indent-level-8) .ui-rc_cell-content {
395
377
  padding-left: 208px;
396
378
  }
397
379
  .ui-rc-table-wrapper.grid-editable .ui-rc-table-tbody .ui-rc-table-row .ui-rc-table-cell:has(.indent-level-9) .ui-rc-table-row-expand-icon {
398
380
  position: absolute;
399
- padding-left: 90px;
400
381
  }
401
382
  .ui-rc-table-wrapper.grid-editable .ui-rc-table-tbody .ui-rc-table-row .ui-rc-table-cell:has(.indent-level-9) .ui-rc_cell-content {
402
383
  padding-left: 233px;
403
384
  }
404
385
  .ui-rc-table-wrapper.grid-editable .ui-rc-table-tbody .ui-rc-table-row .ui-rc-table-cell:has(.indent-level-10) .ui-rc-table-row-expand-icon {
405
386
  position: absolute;
406
- padding-left: 100px;
407
387
  }
408
388
  .ui-rc-table-wrapper.grid-editable .ui-rc-table-tbody .ui-rc-table-row .ui-rc-table-cell:has(.indent-level-10) .ui-rc_cell-content {
409
389
  padding-left: 258px;
package/assets/index.scss CHANGED
@@ -42,6 +42,14 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
42
42
  //font-weight: 500;
43
43
  }
44
44
 
45
+ .ui-rc-table {
46
+ .#{$prefix}-table-cell {
47
+ &.#{$prefix}-table-selection-column {
48
+ //padding: 6px 8px !important;
49
+ //padding: 6px 8px !important;
50
+ }
51
+ }
52
+ }
45
53
 
46
54
 
47
55
  &.table-none-column-select {
@@ -57,9 +65,12 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
57
65
  }
58
66
 
59
67
  .#{$prefix}-table {
60
- line-height: 20px;
68
+
69
+ //line-height: 20px;
70
+
61
71
  .#{$prefix}-table-cell {
62
- min-height: 35px;
72
+ //min-height: 35px;
73
+ //height: 35px;
63
74
 
64
75
  .#{$prefix}-table-filter-column {
65
76
  .#{$prefix}-dropdown-trigger.#{$prefix}-table-filter-trigger {
@@ -324,6 +335,13 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
324
335
 
325
336
  .#{$prefix}-table-wrapper {
326
337
 
338
+ .#{$prefix}-table.#{$prefix}-table-small {
339
+ .#{$prefix}-table-selection-column{
340
+ //padding: 8px 8px;
341
+ //padding: 6px 8px;
342
+ }
343
+ }
344
+
327
345
  &.grid-editable {
328
346
 
329
347
  .#{$prefix}-table-row {
@@ -528,7 +546,7 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
528
546
  .#{$prefix}-table.#{$prefix}-table-small {
529
547
  .#{$prefix}-table-selection-column{
530
548
  //padding: 8px 8px;
531
- padding: 6px 8px;
549
+ //padding: 6px 8px;
532
550
  }
533
551
  }
534
552
 
@@ -620,7 +638,7 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
620
638
  .#{$prefix}-table-row-expand-icon {
621
639
  position: absolute;
622
640
  //.ui-rc_content {
623
- padding-left: $i * 10px;
641
+ //padding-left: $i * 10px;
624
642
  //}
625
643
  }
626
644
 
@@ -5,5 +5,6 @@ export type IColumnsChoose<RecordType> = {
5
5
  columnsGroup?: string[];
6
6
  triggerChangeColumns?: (columns: ColumnsTable<RecordType>, type: string) => void;
7
7
  t?: any;
8
+ triggerChangeKeys?: any;
8
9
  };
9
10
  export declare const ColumnsChoose: <RecordType extends object>(props: IColumnsChoose<RecordType>) => React.JSX.Element;
@@ -1,4 +1,326 @@
1
- import React, { Fragment, useMemo, useState } from "react";
1
+ // import React, {Fragment, useMemo, useState} from "react"
2
+ //
3
+ // import styled from "styled-components"
4
+ // import {Button, Input, Popover, Tooltip} from "antd";
5
+ // import {SettingOutlined} from "@ant-design/icons";
6
+ // import {
7
+ // getVisibleColumnKeys,
8
+ // updateColumns
9
+ // } from "./hooks";
10
+ //
11
+ // // import type {TableColumnsType} from "rc-master-ui";
12
+ // import Tree from "rc-master-ui/es/tree";
13
+ // import SearchOutlined from "@ant-design/icons/SearchOutlined";
14
+ // import type {ColumnsTable} from "./type";
15
+ // import useMergedState from "rc-util/lib/hooks/useMergedState";
16
+ //
17
+ //
18
+ // const BoxAction = styled.div`
19
+ // border-top: 1px solid #c4c4c4;
20
+ // padding-top: .75rem;
21
+ // display: flex;
22
+ // justify-content: end;
23
+ // gap: 10px;
24
+ //
25
+ // .btn-action {
26
+ // background: none !important;
27
+ // border: none !important;
28
+ // &.btn-action-submit {
29
+ // color: #df4318;
30
+ // &:disabled {
31
+ // background-color: #f0f0f0 !important;
32
+ // }
33
+ // &:hover {
34
+ // color: #df4318 !important;
35
+ // }
36
+ // }
37
+ //
38
+ // &:hover {
39
+ // background-color: #f0f0f0 !important;
40
+ // }
41
+ // }
42
+ // `
43
+ //
44
+ // export type IColumnsChoose<RecordType> = {
45
+ // columns: ColumnsTable<RecordType>
46
+ // columnsGroup?: string[]
47
+ // triggerChangeColumns?: (columns: ColumnsTable<RecordType>, type: string) => void
48
+ // t?: any
49
+ //
50
+ // }
51
+ //
52
+ //
53
+ // export const ColumnsChoose = <RecordType extends object>(props: IColumnsChoose<RecordType>) => {
54
+ // const {
55
+ // columns: propsColumns,
56
+ // triggerChangeColumns,
57
+ // t,
58
+ // columnsGroup,
59
+ // } = props
60
+ //
61
+ // // const dataList: { key: React.Key; title: string }[] = [];
62
+ //
63
+ // // const defaultColumns = useMemo(() => {
64
+ // // return propsColumns.filter((it) => it.key || it.dataIndex && it.showColumnChoose !== false)
65
+ // // }, [propsColumns])
66
+ //
67
+ //
68
+ // // const columnsChooseRef: any = useRef()
69
+ // // const searchRef: any = useRef()
70
+ //
71
+ //
72
+ //
73
+ // // const [columns, setColumns] = useState<TableColumnsType>([])
74
+ //
75
+ // // const [selectedKeys, setSelectedKeys] = useState<string[]>([]);
76
+ //
77
+ // // const [isManualUpdate, setIsManualUpdate] = useState(false);
78
+ //
79
+ //
80
+ // // useEffect(() => {
81
+ // //
82
+ // // const defaultColumns = propsColumns.filter((it) => it.key || it.dataIndex && it.showInColumnChoose !== false)
83
+ // // setColumns(defaultColumns as TableColumnsType)
84
+ // //
85
+ // // }, [propsColumns])
86
+ //
87
+ // const columns = useMemo(() => {
88
+ //
89
+ // // return propsColumns.filter((it) => (it.key || it.dataIndex) && it.showInColumnChoose !== false && !columnsGroup?.includes(it.field as string))
90
+ // return propsColumns.filter((it) => (it.key || it.dataIndex) && it.showInColumnChoose !== false)
91
+ // // setColumns(defaultColumns as TableColumnsType)
92
+ // }, [columnsGroup, propsColumns])
93
+ //
94
+ //
95
+ // // useEffect(() => {
96
+ // //
97
+ // // const defaultColumns = propsColumns.filter((it) => it.key || it.dataIndex && it.showInColumnChoose !== false)
98
+ // //
99
+ // // const defaultSelectedKeys = getVisibleColumnKeys(defaultColumns)
100
+ // //
101
+ // // if (!isManualUpdate) {
102
+ // // setSelectedKeys(defaultSelectedKeys)
103
+ // // }
104
+ // // setIsManualUpdate(false);
105
+ // //
106
+ // //
107
+ // // }, [isManualUpdate, propsColumns])
108
+ //
109
+ // const defaultSelectedKeys = React.useMemo(() => {
110
+ //
111
+ // const rs = propsColumns.filter((it) => (it.key || it.dataIndex) && it.showInColumnChoose !== false && !columnsGroup?.includes(it.field as string))
112
+ // return getVisibleColumnKeys(rs)
113
+ //
114
+ // }, [columnsGroup, propsColumns])
115
+ //
116
+ // const [mergedSelectedKeys, setMergedSelectedKeys] = useMergedState(
117
+ // defaultSelectedKeys || [],
118
+ // {
119
+ // value: defaultSelectedKeys,
120
+ // },
121
+ // );
122
+ //
123
+ // //
124
+ // // const defaultSelectedKeys = useMemo(() => {
125
+ // //
126
+ // // return getVisibleColumnKeys(propsColumns)
127
+ // //
128
+ // // }, [propsColumns])
129
+ //
130
+ //
131
+ // const [clicked, setClicked] = useState(false);
132
+ // const [autoExpandParent, setAutoExpandParent] = useState(true);
133
+ //
134
+ //
135
+ // // const treeData = useMemo(() => {
136
+ // // const loop = (data: TreeDataNode[]): TreeDataNode[] =>
137
+ // // data.map((item) => {
138
+ // // const strTitle = item.title as string;
139
+ // // const index = strTitle.indexOf(searchValue);
140
+ // // const beforeStr = strTitle.substring(0, index);
141
+ // // const afterStr = strTitle.slice(index + searchValue.length);
142
+ // // const title =
143
+ // // index > -1 ? (
144
+ // // <span key={item.key}>
145
+ // // {beforeStr}
146
+ // // <span className="site-tree-search-value">{searchValue}</span>
147
+ // // {afterStr}
148
+ // // </span>
149
+ // // ) : (
150
+ // // <span key={item.key}>{strTitle}</span>
151
+ // // );
152
+ // // if (item.children) {
153
+ // // return { title, key: item.key, children: loop(item.children) };
154
+ // // }
155
+ // //
156
+ // // return {
157
+ // // title,
158
+ // // key: item.key,
159
+ // // };
160
+ // // });
161
+ // //
162
+ // // // return loop(defaultData);
163
+ // // return loop(columns as any);
164
+ // // }, [searchValue, columns]);
165
+ //
166
+ //
167
+ // const hide = () => {
168
+ // setClicked(false)
169
+ // }
170
+ //
171
+ // const handleClickChange = (open: boolean) => {
172
+ // setClicked(open)
173
+ // }
174
+ //
175
+ // const onExpand = () => {
176
+ // // setExpandedKeys(newExpandedKeys)
177
+ // setAutoExpandParent(false)
178
+ // }
179
+ //
180
+ // // const getParentKey = (key: React.Key, tree: TreeDataNode[]): React.Key => {
181
+ // // let parentKey: React.Key
182
+ // // for (let i = 0; i < tree.length; i++) {
183
+ // // const node = tree[i]
184
+ // // if (node.children) {
185
+ // // if (node.children.some((item) => item.key === key)) {
186
+ // // parentKey = node.key
187
+ // // } else if (getParentKey(key, node.children)) {
188
+ // // parentKey = getParentKey(key, node.children)
189
+ // // }
190
+ // // }
191
+ // // }
192
+ // // return parentKey!
193
+ // // }
194
+ //
195
+ // // const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
196
+ // const onChange = () => {
197
+ // // const { value } = e.target
198
+ // // const newExpandedKeys = dataList
199
+ // // .map((item) => {
200
+ // // if (item.title.indexOf(value) > -1) {
201
+ // // return getParentKey(item.key, defaultData)
202
+ // // }
203
+ // // return null
204
+ // // })
205
+ // // .filter((item, i, self): item is React.Key => !!(item && self.indexOf(item) === i))
206
+ // // setExpandedKeys(newExpandedKeys)
207
+ //
208
+ // // setSearchValue(value)
209
+ // setAutoExpandParent(true)
210
+ // };
211
+ //
212
+ // const onCheck = (keys: string[]) => {
213
+ //
214
+ // console.log('keys', keys)
215
+ // // setSelectedKeys(keys)
216
+ // setMergedSelectedKeys(keys)
217
+ // // setIsManualUpdate(true)
218
+ //
219
+ // }
220
+ //
221
+ // const handleAccept = () => {
222
+ //
223
+ // console.log('mergedSelectedKeys', mergedSelectedKeys)
224
+ //
225
+ // // const rs1 = updateColumns(propsColumns, selectedKeys)
226
+ // const rs1 = updateColumns(propsColumns, mergedSelectedKeys)
227
+ //
228
+ // console.log('rs1', rs1)
229
+ //
230
+ // triggerChangeColumns?.(rs1, 'columnChoose')
231
+ //
232
+ // hide()
233
+ //
234
+ // }
235
+ //
236
+ // const handleCancel = () => {
237
+ // // setSelectedKeys(defaultSelectedKeys)
238
+ // hide()
239
+ // }
240
+ //
241
+ //
242
+ // return (
243
+ // <Fragment>
244
+ // <Popover
245
+ // placement={'bottomLeft'}
246
+ // content={
247
+ // <div style={{minWidth: 250}}>
248
+ // <Input style={{ marginBottom: 8 }} placeholder={t ? t("Search") : 'Search'} prefix={<SearchOutlined />} onChange={onChange} />
249
+ //
250
+ // <Tree
251
+ // onExpand={onExpand}
252
+ // // expandedKeys={expandedKeys}
253
+ // autoExpandParent={autoExpandParent}
254
+ // // treeData={treeData}
255
+ // treeData={columns}
256
+ // defaultExpandAll={true}
257
+ // checkable={true}
258
+ // // onSelect={(keys, info) => {
259
+ // // const key = info.node.key
260
+ // //
261
+ // // const find = findItemByKey(columns, 'key', key)
262
+ // //
263
+ // // // const tmpColumn
264
+ // //
265
+ // // // if (selectedKeys.includes(key as string)) {
266
+ // // // const rssss = findKeyPath(columns, key as string)
267
+ // // // const rs = selectedKeys.filter(item => !rssss.includes(item));
268
+ // // //
269
+ // // // setSelectedKeys(rs)
270
+ // // // } else {
271
+ // //
272
+ // // // const rs = [...selectedKeys, keys[0]]
273
+ // //
274
+ // // // setSelectedKeys(keys)
275
+ // // // }
276
+ // // }}
277
+ // onCheck={(keys) => onCheck(keys as string[])}
278
+ //
279
+ //
280
+ // multiple={true}
281
+ // // checkedKeys={selectedKeys}
282
+ //
283
+ // defaultCheckedKeys={mergedSelectedKeys}
284
+ // // defaultCheckedKeys={defaultSelectedKeys}
285
+ // // selectedKeys={[]}
286
+ //
287
+ // height={window.innerHeight - 200}
288
+ //
289
+ // />
290
+ //
291
+ //
292
+ // <BoxAction className={'px-1'}>
293
+ // <Button
294
+ // // className={classnames('btn-action btn-action-submit', {
295
+ // // // disable: !columns.find((item) => item.visible !== false || item.visible)
296
+ // // })}
297
+ // onClick={handleAccept}
298
+ // // disabled={!columns.find((item) => item.visible !== false || item.visible)}
299
+ // >
300
+ // {t ? t('OK') : 'OK'}
301
+ // {/*{'OK'}*/}
302
+ // </Button>
303
+ //
304
+ // {/*<Button className={'btn-action btn-action-cancel'} onClick={hide} >{('Cancel') }</Button>*/}
305
+ // <Button className={'btn-action btn-action-cancel'} onClick={handleCancel} >{t ? t('Cancel') : 'Cancel' }</Button>
306
+ // </BoxAction>
307
+ // </div>
308
+ // }
309
+ // trigger="click"
310
+ // open={clicked}
311
+ // onOpenChange={handleClickChange}
312
+ // arrow={false}
313
+ // >
314
+ // <Tooltip arrow={false} title={'Cài đặt'} >
315
+ // <SettingOutlined size={16} color={'#555555'} style={{fontSize: 16, color: '#555555'}} />
316
+ // </Tooltip>
317
+ //
318
+ // </Popover>
319
+ // </Fragment>
320
+ // )
321
+ // }
322
+
323
+ import React, { Fragment, useEffect, useMemo, useState } from "react";
2
324
  import styled from "styled-components";
3
325
  import { Button, Input, Popover, Tooltip } from "antd";
4
326
  import { SettingOutlined } from "@ant-design/icons";
@@ -7,7 +329,6 @@ import { getVisibleColumnKeys, updateColumns } from "./hooks";
7
329
  // import type {TableColumnsType} from "rc-master-ui";
8
330
  import Tree from "rc-master-ui/es/tree";
9
331
  import SearchOutlined from "@ant-design/icons/SearchOutlined";
10
- import useMergedState from "rc-util/es/hooks/useMergedState";
11
332
  const BoxAction = styled.div.withConfig({
12
333
  displayName: "BoxAction",
13
334
  componentId: "es-grid-template__sc-1ix8yky-0"
@@ -16,6 +337,7 @@ export const ColumnsChoose = props => {
16
337
  const {
17
338
  columns: propsColumns,
18
339
  triggerChangeColumns,
340
+ triggerChangeKeys,
19
341
  t,
20
342
  columnsGroup
21
343
  } = props;
@@ -30,10 +352,8 @@ export const ColumnsChoose = props => {
30
352
  // const searchRef: any = useRef()
31
353
 
32
354
  // const [columns, setColumns] = useState<TableColumnsType>([])
33
-
34
- // const [selectedKeys, setSelectedKeys] = useState<string[]>([]);
35
-
36
- // const [isManualUpdate, setIsManualUpdate] = useState(false);
355
+ const [selectedKeys, setSelectedKeys] = useState([]);
356
+ const [isManualUpdate, setIsManualUpdate] = useState(false);
37
357
 
38
358
  // useEffect(() => {
39
359
  //
@@ -43,40 +363,22 @@ export const ColumnsChoose = props => {
43
363
  // }, [propsColumns])
44
364
 
45
365
  const columns = useMemo(() => {
46
- // return propsColumns.filter((it) => (it.key || it.dataIndex) && it.showInColumnChoose !== false && !columnsGroup?.includes(it.field as string))
47
- return propsColumns.filter(it => (it.key || it.dataIndex) && it.showInColumnChoose !== false);
366
+ return propsColumns.filter(it => it.key || it.dataIndex && it.showInColumnChoose !== false);
48
367
  // setColumns(defaultColumns as TableColumnsType)
49
- }, [columnsGroup, propsColumns]);
50
-
51
- // useEffect(() => {
52
- //
53
- // const defaultColumns = propsColumns.filter((it) => it.key || it.dataIndex && it.showInColumnChoose !== false)
54
- //
55
- // const defaultSelectedKeys = getVisibleColumnKeys(defaultColumns)
56
- //
57
- // if (!isManualUpdate) {
58
- // setSelectedKeys(defaultSelectedKeys)
59
- // }
60
- // setIsManualUpdate(false);
61
- //
62
- //
63
- // }, [isManualUpdate, propsColumns])
64
-
65
- const defaultSelectedKeys = React.useMemo(() => {
66
- const rs = propsColumns.filter(it => (it.key || it.dataIndex) && it.showInColumnChoose !== false && !columnsGroup?.includes(it.field));
67
- return getVisibleColumnKeys(rs);
68
- }, [columnsGroup, propsColumns]);
69
- const [mergedSelectedKeys, setMergedSelectedKeys] = useMergedState(defaultSelectedKeys || [], {
70
- value: defaultSelectedKeys
71
- });
72
-
73
- //
74
- // const defaultSelectedKeys = useMemo(() => {
75
- //
76
- // return getVisibleColumnKeys(propsColumns)
77
- //
78
- // }, [propsColumns])
79
-
368
+ }, [propsColumns]);
369
+ useEffect(() => {
370
+ // const defaultColumns = propsColumns.filter((it) => it.key || it.dataIndex && it.showInColumnChoose !== false)
371
+ const defaultColumns = propsColumns.filter(it => (it.key || it.dataIndex) && it.showInColumnChoose !== false && !columnsGroup?.includes(it.field));
372
+ const defaultSelectedKeys = getVisibleColumnKeys(defaultColumns);
373
+ if (!isManualUpdate) {
374
+ setSelectedKeys(defaultSelectedKeys);
375
+ }
376
+ setIsManualUpdate(false);
377
+ }, [propsColumns]);
378
+ const defaultSelectedKeys = useMemo(() => {
379
+ const defaultColumns = propsColumns.filter(it => (it.key || it.dataIndex) && it.showInColumnChoose !== false && !columnsGroup?.includes(it.field));
380
+ return getVisibleColumnKeys(defaultColumns);
381
+ }, [propsColumns]);
80
382
  const [clicked, setClicked] = useState(false);
81
383
  const [autoExpandParent, setAutoExpandParent] = useState(true);
82
384
 
@@ -154,19 +456,17 @@ export const ColumnsChoose = props => {
154
456
  setAutoExpandParent(true);
155
457
  };
156
458
  const onCheck = keys => {
157
- console.log('keys', keys);
158
- // setSelectedKeys(keys)
159
- setMergedSelectedKeys(keys);
160
- // setIsManualUpdate(true)
459
+ setSelectedKeys(keys);
460
+ setIsManualUpdate(true);
161
461
  };
162
462
  const handleAccept = () => {
163
- // const rs1 = updateColumns(propsColumns, selectedKeys)
164
- const rs1 = updateColumns(propsColumns, mergedSelectedKeys);
463
+ const rs1 = updateColumns(propsColumns, selectedKeys);
464
+ triggerChangeKeys?.(selectedKeys);
165
465
  triggerChangeColumns?.(rs1, 'columnChoose');
166
466
  hide();
167
467
  };
168
468
  const handleCancel = () => {
169
- // setSelectedKeys(defaultSelectedKeys)
469
+ setSelectedKeys(defaultSelectedKeys);
170
470
  hide();
171
471
  };
172
472
  return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Popover, {
@@ -213,15 +513,12 @@ export const ColumnsChoose = props => {
213
513
  // }}
214
514
  ,
215
515
  onCheck: keys => onCheck(keys),
216
- multiple: true
217
- // checkedKeys={selectedKeys}
218
- ,
219
-
220
- defaultCheckedKeys: mergedSelectedKeys
516
+ multiple: true,
517
+ checkedKeys: selectedKeys,
518
+ defaultCheckedKeys: selectedKeys
221
519
  // defaultCheckedKeys={defaultSelectedKeys}
222
- // selectedKeys={[]}
223
520
  ,
224
-
521
+ selectedKeys: [],
225
522
  height: window.innerHeight - 200
226
523
  }), /*#__PURE__*/React.createElement(BoxAction, {
227
524
  className: 'px-1'
@@ -243,12 +540,5 @@ export const ColumnsChoose = props => {
243
540
  }, /*#__PURE__*/React.createElement(Tooltip, {
244
541
  arrow: false,
245
542
  title: 'Cài đặt'
246
- }, /*#__PURE__*/React.createElement(SettingOutlined, {
247
- size: 16,
248
- color: '#555555',
249
- style: {
250
- fontSize: 16,
251
- color: '#555555'
252
- }
253
- }))));
543
+ }, /*#__PURE__*/React.createElement(SettingOutlined, null))));
254
544
  };
@@ -6,6 +6,7 @@ import { checkDecimalSeparator, checkThousandSeparator, checkFieldKey, convertAr
6
6
  convertLabelToTitle,
7
7
  // customWeekStartEndFormat,
8
8
  getDatepickerFormat, getTemplate, isDisable, isEmpty, isNullOrUndefined, customWeekStartEndFormat, convertDayjsToDate, parseBooleanToValue, isColor, genPresets
9
+ // isEditable,
9
10
  // convertDayjsToDate
10
11
  } from "./hooks";
11
12
  // import moment from "moment";
@@ -79,10 +80,11 @@ const EditableCell = props => {
79
80
  toolbarClick,
80
81
  loadOptions,
81
82
  validateOption,
82
- options: selectOptions
83
+ options: propsOptions
83
84
  } = column.editSelectSettings || {};
84
85
  const isInvalid = false;
85
86
  const keySelect = checkFieldKey(column?.editSelectSettings?.fieldKey);
87
+ const selectOptions = typeof propsOptions === 'function' ? propsOptions(record, column.dataIndex) : propsOptions;
86
88
  const options = validateOption ? validateOption(record, column.dataIndex) : selectOptions ?? [];
87
89
  const optionsTree = validateOption ? convertArrayWithIndent(validateOption(record, column.dataIndex)) : selectOptions ? convertArrayWithIndent(selectOptions) : [];
88
90
  switch (editType) {
@@ -97,6 +97,7 @@ const InternalTable = props => {
97
97
  React.useEffect(() => {
98
98
  setColumns(propsColumns);
99
99
  }, [propsColumns]);
100
+ // }, [!!propsColumns.length && !!propsColumns])
100
101
 
101
102
  // const [data, setData] = useState<RecordType[]>([]);
102
103
 
@@ -147,8 +148,14 @@ const InternalTable = props => {
147
148
  }, [rowKey]);
148
149
 
149
150
  // const triggerChangeColumns = (newColumns: ColumnsTable<RecordType>) => {
150
- const triggerChangeColumns = newColumns => {
151
+ const triggerChangeColumns = (newColumns, type) => {
151
152
  setColumns(newColumns);
153
+ if (tableRef.current && type === 'columnChoose') {
154
+ tableRef.current.scrollTo({
155
+ left: 0.1,
156
+ behavior: "smooth"
157
+ });
158
+ }
152
159
  onChooseColumns?.({
153
160
  showColumns: [],
154
161
  columns: [],