es-grid-template 1.5.17 → 1.6.1
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/es/grid-component/CheckboxFilter2.js +0 -4
- package/es/grid-component/ColumnsChoose.js +9 -4
- package/es/grid-component/ColumnsGroup/ColumnsGroup.js +11 -4
- package/es/grid-component/EditForm/EditForm.d.ts +27 -0
- package/es/grid-component/EditForm/EditForm.js +391 -0
- package/es/grid-component/EditForm/index.d.ts +1 -0
- package/es/grid-component/EditForm/index.js +1 -0
- package/es/grid-component/EditableCell.js +72 -52
- package/es/grid-component/InternalTable.js +79 -27
- package/es/grid-component/TableGrid.js +39 -107
- package/es/grid-component/control/InputControl/InputControl.d.ts +26 -0
- package/es/grid-component/control/InputControl/InputControl.js +121 -0
- package/es/grid-component/control/InputControl/index.d.ts +1 -0
- package/es/grid-component/control/InputControl/index.js +1 -0
- package/es/grid-component/hooks/columns/index.d.ts +3 -2
- package/es/grid-component/hooks/columns/index.js +84 -8
- package/es/grid-component/hooks/content/ControlCheckbox.d.ts +13 -0
- package/es/grid-component/hooks/content/ControlCheckbox.js +87 -0
- package/es/grid-component/hooks/content/HeaderContent.d.ts +1 -1
- package/es/grid-component/hooks/content/HeaderContent.js +9 -4
- package/es/grid-component/hooks/useColumns.js +5 -5
- package/es/grid-component/hooks/utils.d.ts +28 -3
- package/es/grid-component/hooks/utils.js +544 -12
- package/es/grid-component/styles.scss +50 -1
- package/es/grid-component/table/Grid.d.ts +3 -0
- package/es/grid-component/table/GridEdit.d.ts +3 -0
- package/es/grid-component/table/GridEdit.js +353 -328
- package/es/grid-component/table/Group.d.ts +3 -0
- package/es/grid-component/table/InfiniteTable.d.ts +3 -0
- package/es/grid-component/table/InfiniteTable.js +4 -2
- package/es/grid-component/type.d.ts +28 -0
- package/es/grid-component/useContext.d.ts +0 -1
- package/es/index.d.ts +2 -0
- package/es/index.js +1 -0
- package/es/select/index.d.ts +1 -1
- package/lib/grid-component/CheckboxFilter2.js +0 -4
- package/lib/grid-component/ColumnsChoose.js +9 -4
- package/lib/grid-component/ColumnsGroup/ColumnsGroup.js +11 -4
- package/lib/grid-component/EditForm/EditForm.d.ts +27 -0
- package/lib/grid-component/EditForm/EditForm.js +401 -0
- package/lib/grid-component/EditForm/index.d.ts +1 -0
- package/lib/grid-component/EditForm/index.js +16 -0
- package/lib/grid-component/EditableCell.js +72 -52
- package/lib/grid-component/InternalTable.js +78 -26
- package/lib/grid-component/TableGrid.js +37 -105
- package/lib/grid-component/control/InputControl/InputControl.d.ts +26 -0
- package/lib/grid-component/control/InputControl/InputControl.js +131 -0
- package/lib/grid-component/control/InputControl/index.d.ts +1 -0
- package/lib/grid-component/control/InputControl/index.js +16 -0
- package/lib/grid-component/hooks/columns/index.d.ts +3 -2
- package/lib/grid-component/hooks/columns/index.js +86 -9
- package/lib/grid-component/hooks/content/ControlCheckbox.d.ts +13 -0
- package/lib/grid-component/hooks/content/ControlCheckbox.js +95 -0
- package/lib/grid-component/hooks/content/HeaderContent.d.ts +1 -1
- package/lib/grid-component/hooks/content/HeaderContent.js +9 -4
- package/lib/grid-component/hooks/useColumns.js +5 -5
- package/lib/grid-component/hooks/utils.d.ts +28 -3
- package/lib/grid-component/hooks/utils.js +565 -19
- package/lib/grid-component/styles.scss +50 -1
- package/lib/grid-component/table/Grid.d.ts +3 -0
- package/lib/grid-component/table/GridEdit.d.ts +3 -0
- package/lib/grid-component/table/GridEdit.js +343 -325
- package/lib/grid-component/table/Group.d.ts +3 -0
- package/lib/grid-component/table/InfiniteTable.d.ts +3 -0
- package/lib/grid-component/table/InfiniteTable.js +4 -2
- package/lib/grid-component/type.d.ts +28 -0
- package/lib/grid-component/useContext.d.ts +0 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +7 -0
- package/lib/select/index.d.ts +1 -1
- package/package.json +2 -1
|
@@ -79,7 +79,6 @@ const CheckboxFilter = props => {
|
|
|
79
79
|
|
|
80
80
|
// const [searchValue, setSearchValue] = React.useState('');
|
|
81
81
|
|
|
82
|
-
console.log('options', options);
|
|
83
82
|
const [openKeys, setOpenKeys] = React.useState([]);
|
|
84
83
|
|
|
85
84
|
// clear search value after close filter dropdown
|
|
@@ -172,9 +171,6 @@ const CheckboxFilter = props => {
|
|
|
172
171
|
onSelect?.(keys);
|
|
173
172
|
}
|
|
174
173
|
};
|
|
175
|
-
console.log('getTreeData({ filters: options })', getTreeData({
|
|
176
|
-
filters: options
|
|
177
|
-
}));
|
|
178
174
|
if (filterMode === 'tree') {
|
|
179
175
|
return /*#__PURE__*/React.createElement(React.Fragment, null, showFilter && /*#__PURE__*/React.createElement(FilterSearch, {
|
|
180
176
|
filterSearch: filterSearch,
|
|
@@ -378,7 +378,7 @@ export const ColumnsChoose = props => {
|
|
|
378
378
|
const defaultSelectedKeys = useMemo(() => {
|
|
379
379
|
const defaultColumns = propsColumns.filter(it => (it.key || it.dataIndex) && it.showInColumnChoose !== false && !columnsGroup?.includes(it.field));
|
|
380
380
|
return getVisibleColumnKeys(defaultColumns);
|
|
381
|
-
}, [propsColumns]);
|
|
381
|
+
}, [columnsGroup, propsColumns]);
|
|
382
382
|
const [clicked, setClicked] = useState(false);
|
|
383
383
|
const [autoExpandParent, setAutoExpandParent] = useState(true);
|
|
384
384
|
|
|
@@ -473,7 +473,8 @@ export const ColumnsChoose = props => {
|
|
|
473
473
|
placement: 'bottomLeft',
|
|
474
474
|
content: /*#__PURE__*/React.createElement("div", {
|
|
475
475
|
style: {
|
|
476
|
-
minWidth: 250
|
|
476
|
+
minWidth: 250,
|
|
477
|
+
maxWidth: 320
|
|
477
478
|
}
|
|
478
479
|
}, /*#__PURE__*/React.createElement(Input, {
|
|
479
480
|
style: {
|
|
@@ -518,8 +519,12 @@ export const ColumnsChoose = props => {
|
|
|
518
519
|
defaultCheckedKeys: selectedKeys
|
|
519
520
|
// defaultCheckedKeys={defaultSelectedKeys}
|
|
520
521
|
,
|
|
521
|
-
selectedKeys: []
|
|
522
|
-
|
|
522
|
+
selectedKeys: []
|
|
523
|
+
|
|
524
|
+
// height={window.innerHeight - 200}
|
|
525
|
+
,
|
|
526
|
+
height: window.innerHeight / 2 > 450 ? 450 : window.innerHeight / 2 - 110
|
|
527
|
+
// style={{height: 300}}
|
|
523
528
|
}), /*#__PURE__*/React.createElement(BoxAction, {
|
|
524
529
|
className: 'px-1'
|
|
525
530
|
}, /*#__PURE__*/React.createElement(Button
|
|
@@ -10,6 +10,7 @@ import { Button, Popover, Tooltip } from "antd";
|
|
|
10
10
|
// import {SettingOutlined} from "@ant-design/icons";
|
|
11
11
|
import { Select } from "rc-master-ui";
|
|
12
12
|
import styled from "styled-components";
|
|
13
|
+
import { customFilterOption } from "../hooks";
|
|
13
14
|
const BoxAction = styled.div.withConfig({
|
|
14
15
|
displayName: "BoxAction",
|
|
15
16
|
componentId: "es-grid-template__sc-1uj3tyy-0"
|
|
@@ -119,7 +120,8 @@ export const ColumnsGroup = props => {
|
|
|
119
120
|
}, "M\u1EE9c 1"), /*#__PURE__*/React.createElement(Select, {
|
|
120
121
|
style: {
|
|
121
122
|
width: '100%'
|
|
122
|
-
}
|
|
123
|
+
},
|
|
124
|
+
showSearch: true
|
|
123
125
|
// labelInValue={true}
|
|
124
126
|
// options={columns.filter((it: any) => !tempGroup.includes(it.field))}
|
|
125
127
|
// options={columns && columns.length > 0 ? options : []}
|
|
@@ -136,7 +138,8 @@ export const ColumnsGroup = props => {
|
|
|
136
138
|
labelRender: labelProps => {
|
|
137
139
|
const it = columns.find(col => col.field === labelProps.value);
|
|
138
140
|
return t ? t(it?.columnGroupText ?? it?.headerText) : it?.columnGroupText ?? it?.headerText;
|
|
139
|
-
}
|
|
141
|
+
},
|
|
142
|
+
filterOption: customFilterOption
|
|
140
143
|
// hideSelectedOptions
|
|
141
144
|
})), /*#__PURE__*/React.createElement("div", {
|
|
142
145
|
className: 'mb-1',
|
|
@@ -149,6 +152,7 @@ export const ColumnsGroup = props => {
|
|
|
149
152
|
margin: 0
|
|
150
153
|
}
|
|
151
154
|
}, "M\u1EE9c 2"), /*#__PURE__*/React.createElement(Select, {
|
|
155
|
+
showSearch: true,
|
|
152
156
|
style: {
|
|
153
157
|
width: '100%'
|
|
154
158
|
},
|
|
@@ -165,7 +169,8 @@ export const ColumnsGroup = props => {
|
|
|
165
169
|
labelRender: labelProps => {
|
|
166
170
|
const it = columns.find(col => col.field === labelProps.value);
|
|
167
171
|
return t ? t(it?.columnGroupText ?? it?.headerText) : it?.columnGroupText ?? it?.headerText;
|
|
168
|
-
}
|
|
172
|
+
},
|
|
173
|
+
filterOption: customFilterOption
|
|
169
174
|
})), /*#__PURE__*/React.createElement("div", {
|
|
170
175
|
className: 'mb-1',
|
|
171
176
|
style: {
|
|
@@ -181,6 +186,7 @@ export const ColumnsGroup = props => {
|
|
|
181
186
|
width: '100%'
|
|
182
187
|
},
|
|
183
188
|
options: options,
|
|
189
|
+
showSearch: true,
|
|
184
190
|
value: tempGroup?.[2],
|
|
185
191
|
onChange: val => onChangeGroupColumns(val, 2),
|
|
186
192
|
allowClear: !!tempGroup?.[2] && !(unClearableLevel && unClearableLevel - 3 >= 0)
|
|
@@ -192,7 +198,8 @@ export const ColumnsGroup = props => {
|
|
|
192
198
|
labelRender: labelProps => {
|
|
193
199
|
const it = columns.find(col => col.field === labelProps.value);
|
|
194
200
|
return t ? t(it?.columnGroupText ?? it?.headerText) : it?.columnGroupText ?? it?.headerText;
|
|
195
|
-
}
|
|
201
|
+
},
|
|
202
|
+
filterOption: customFilterOption
|
|
196
203
|
}))), /*#__PURE__*/React.createElement(BoxAction, {
|
|
197
204
|
className: 'px-1'
|
|
198
205
|
}, /*#__PURE__*/React.createElement(Button
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
type Props = {
|
|
3
|
+
id?: string;
|
|
4
|
+
externalClick?: any;
|
|
5
|
+
menuPortalTarget?: any;
|
|
6
|
+
value: any;
|
|
7
|
+
onChange: (props: any) => void;
|
|
8
|
+
filterKey?: string;
|
|
9
|
+
customRender?: any;
|
|
10
|
+
filterHeaderKey?: string;
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
invalid?: any;
|
|
13
|
+
menuHeight?: number;
|
|
14
|
+
menuWidth?: number;
|
|
15
|
+
classNamePrefix?: string;
|
|
16
|
+
cellFocus?: boolean;
|
|
17
|
+
t?: any;
|
|
18
|
+
column: any;
|
|
19
|
+
fieldKey?: any;
|
|
20
|
+
rowData: any;
|
|
21
|
+
indexRow: any;
|
|
22
|
+
template?: any;
|
|
23
|
+
onKeyDown?: (event: any) => void;
|
|
24
|
+
};
|
|
25
|
+
export declare const SelectStyle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
26
|
+
export declare const EditForm: (props: Props) => React.JSX.Element;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
import React, { Fragment, useRef } from "react";
|
|
2
|
+
import styled from "styled-components";
|
|
3
|
+
import { useForm } from "react-hook-form";
|
|
4
|
+
import { yupResolver } from "@hookform/resolvers/yup";
|
|
5
|
+
import { Col, Row } from "rc-master-ui/es/grid";
|
|
6
|
+
import InputControl from "../control/InputControl/InputControl";
|
|
7
|
+
import { isNullOrUndefined, isObjEmpty } from "../hooks";
|
|
8
|
+
import { Input } from "rc-master-ui";
|
|
9
|
+
import { Dropdown } from "antd";
|
|
10
|
+
import Divider from "rc-master-ui/es/divider";
|
|
11
|
+
import Button from "rc-master-ui/es/button";
|
|
12
|
+
export const SelectStyle = styled.div.withConfig({
|
|
13
|
+
displayName: "SelectStyle",
|
|
14
|
+
componentId: "es-grid-template__sc-7ba05m-0"
|
|
15
|
+
})(["width:100%;&.be-select{.input-group-merge{flex-wrap:nowrap;}}"]);
|
|
16
|
+
export const EditForm = props => {
|
|
17
|
+
const {
|
|
18
|
+
id,
|
|
19
|
+
// menuPortalTarget,
|
|
20
|
+
value,
|
|
21
|
+
fieldKey,
|
|
22
|
+
placeholder,
|
|
23
|
+
// invalid,
|
|
24
|
+
menuHeight,
|
|
25
|
+
menuWidth,
|
|
26
|
+
// classNamePrefix,
|
|
27
|
+
onChange,
|
|
28
|
+
// onKeyDown,
|
|
29
|
+
t,
|
|
30
|
+
cellFocus,
|
|
31
|
+
column
|
|
32
|
+
} = props;
|
|
33
|
+
const formRef = useRef();
|
|
34
|
+
const divRef = useRef(null);
|
|
35
|
+
const inputRef = useRef(null);
|
|
36
|
+
const defaultValue = !isNullOrUndefined(value) ? column?.editFromSettings?.formatLabel ? column?.editFromSettings?.formatLabel(value) : value[fieldKey] : '';
|
|
37
|
+
const {
|
|
38
|
+
control,
|
|
39
|
+
handleSubmit,
|
|
40
|
+
getValues,
|
|
41
|
+
reset,
|
|
42
|
+
setValue,
|
|
43
|
+
setError,
|
|
44
|
+
formState: {
|
|
45
|
+
errors
|
|
46
|
+
}
|
|
47
|
+
} = useForm({
|
|
48
|
+
mode: 'onChange',
|
|
49
|
+
defaultValues: column.editFromSettings?.defaultValues,
|
|
50
|
+
resolver: column.editFromSettings?.schema ? yupResolver(column.editFromSettings?.schema) : undefined
|
|
51
|
+
});
|
|
52
|
+
const handleToggle = () => {
|
|
53
|
+
divRef?.current?.click(); // Giả lập click vào nút để mở dropdown
|
|
54
|
+
};
|
|
55
|
+
React.useEffect(() => {
|
|
56
|
+
if (cellFocus) {
|
|
57
|
+
handleToggle();
|
|
58
|
+
}
|
|
59
|
+
}, [cellFocus]);
|
|
60
|
+
const handleOnSubmit = val => {
|
|
61
|
+
handleToggle();
|
|
62
|
+
onChange(val);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// const handleOnKeyDown = (e: any) => {
|
|
66
|
+
//
|
|
67
|
+
// if (dropdownOpen) {
|
|
68
|
+
// e.preventDefault()
|
|
69
|
+
//
|
|
70
|
+
// if (e.code === 'Tab') {
|
|
71
|
+
// e.stopPropagation()
|
|
72
|
+
// const formElement = document.getElementById('edit-form')
|
|
73
|
+
//
|
|
74
|
+
// if (formElement) {
|
|
75
|
+
//
|
|
76
|
+
// formElement.getElementsByTagName('input')[0]?.focus()
|
|
77
|
+
//
|
|
78
|
+
// }
|
|
79
|
+
//
|
|
80
|
+
// }
|
|
81
|
+
//
|
|
82
|
+
// if (e.code === "Escape") {
|
|
83
|
+
// e.preventDefault()
|
|
84
|
+
// e.stopPropagation()
|
|
85
|
+
// return e
|
|
86
|
+
// }
|
|
87
|
+
//
|
|
88
|
+
// const formElement = document.getElementById('edit-form')
|
|
89
|
+
//
|
|
90
|
+
// if (formElement) {
|
|
91
|
+
//
|
|
92
|
+
// formElement.getElementsByTagName('input')[0]?.focus()
|
|
93
|
+
//
|
|
94
|
+
// }
|
|
95
|
+
// return e.code
|
|
96
|
+
//
|
|
97
|
+
//
|
|
98
|
+
// } else {
|
|
99
|
+
// if (e.code === 'ArrowDown') {
|
|
100
|
+
// e.preventDefault()
|
|
101
|
+
//
|
|
102
|
+
// setTimeout(() => {
|
|
103
|
+
// const formElement = document.getElementById('edit-form')
|
|
104
|
+
// if (formElement) {
|
|
105
|
+
// formElement.getElementsByTagName('input')[0]?.focus()
|
|
106
|
+
//
|
|
107
|
+
// }
|
|
108
|
+
//
|
|
109
|
+
// }, 100)
|
|
110
|
+
//
|
|
111
|
+
//
|
|
112
|
+
// }
|
|
113
|
+
// }
|
|
114
|
+
//
|
|
115
|
+
// if (onKeyDown) {
|
|
116
|
+
// onKeyDown(e)
|
|
117
|
+
// }
|
|
118
|
+
//
|
|
119
|
+
//
|
|
120
|
+
// }
|
|
121
|
+
//
|
|
122
|
+
|
|
123
|
+
const handleOnFocus = e => {
|
|
124
|
+
e.target.setSelectionRange(0, e.target.innerText.length - 1);
|
|
125
|
+
};
|
|
126
|
+
const formItemKeyDown = (e, index, length) => {
|
|
127
|
+
if (e.code === 'Tab' || e.code === 'ArrowDown') {
|
|
128
|
+
const itemElement = document.getElementById(`edit-form-${index + 1}`);
|
|
129
|
+
if (itemElement && index < length) {
|
|
130
|
+
if (itemElement.className.includes('be-select')) {
|
|
131
|
+
itemElement.getElementsByTagName('input')[0]?.focus();
|
|
132
|
+
} else {
|
|
133
|
+
itemElement.focus();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
e.preventDefault();
|
|
137
|
+
}
|
|
138
|
+
if (e.code === 'ArrowUp') {
|
|
139
|
+
const itemElement = document.getElementById(`edit-form-${index - 1}`);
|
|
140
|
+
if (itemElement && index !== 0) {
|
|
141
|
+
if (itemElement.className.includes('be-select')) {
|
|
142
|
+
itemElement.getElementsByTagName('input')[0]?.focus();
|
|
143
|
+
} else {
|
|
144
|
+
itemElement.focus();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
e.preventDefault();
|
|
148
|
+
}
|
|
149
|
+
if (e.code === 'Enter') {
|
|
150
|
+
if (isObjEmpty(errors)) {
|
|
151
|
+
const rs = getValues();
|
|
152
|
+
if (column.editFromSettings?.schema) {
|
|
153
|
+
column.editFromSettings?.schema.validate(rs, {
|
|
154
|
+
abortEarly: false
|
|
155
|
+
}).then(() => {
|
|
156
|
+
handleToggle();
|
|
157
|
+
onChange(rs);
|
|
158
|
+
if (column.editFromSettings && column?.editFromSettings?.formClose) {
|
|
159
|
+
column?.editFromSettings?.formClose({
|
|
160
|
+
value,
|
|
161
|
+
setValue,
|
|
162
|
+
getValues,
|
|
163
|
+
reset
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
if (inputRef) {
|
|
167
|
+
inputRef.current.focus();
|
|
168
|
+
}
|
|
169
|
+
}).catch(err => {
|
|
170
|
+
e.preventDefault();
|
|
171
|
+
e.stopPropagation();
|
|
172
|
+
err.inner.forEach(error => {
|
|
173
|
+
setError(error.path ? error.path : '', {
|
|
174
|
+
type: "manual",
|
|
175
|
+
message: error.message
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
} else {
|
|
181
|
+
e.preventDefault();
|
|
182
|
+
e.stopPropagation();
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
// const checkErrors = () => {
|
|
188
|
+
//
|
|
189
|
+
//
|
|
190
|
+
// if (isObjEmpty(errors)) {
|
|
191
|
+
// const rs = getValues()
|
|
192
|
+
// if (column.editFromSettings?.schema) {
|
|
193
|
+
// column.editFromSettings?.schema.validate(rs, { abortEarly: false })
|
|
194
|
+
// .then(() => {
|
|
195
|
+
// handleToggle()
|
|
196
|
+
// onChange(rs)
|
|
197
|
+
//
|
|
198
|
+
// if (column.editFromSettings && column?.editFromSettings?.formClose) {
|
|
199
|
+
// column?.editFromSettings?.formClose({value, setValue, getValues, reset})
|
|
200
|
+
// }
|
|
201
|
+
// if (inputRef) {
|
|
202
|
+
// inputRef.current.focus()
|
|
203
|
+
// }
|
|
204
|
+
// })
|
|
205
|
+
// .catch((err: ValidationError) => {
|
|
206
|
+
//
|
|
207
|
+
// err.inner.forEach((error: ValidationError) => {
|
|
208
|
+
//
|
|
209
|
+
// setError(error.path ? error.path : '', {
|
|
210
|
+
// type: "manual",
|
|
211
|
+
// message: error.message
|
|
212
|
+
// })
|
|
213
|
+
// })
|
|
214
|
+
// })
|
|
215
|
+
// }
|
|
216
|
+
//
|
|
217
|
+
//
|
|
218
|
+
// } else {
|
|
219
|
+
//
|
|
220
|
+
// }
|
|
221
|
+
// }
|
|
222
|
+
|
|
223
|
+
const handleFormKeydown = e => {
|
|
224
|
+
// if (dropdownOpen) {
|
|
225
|
+
|
|
226
|
+
if (e.code === 'Tab' || e.code === 'ArrowUp' || e.code === 'ArrowDown') {
|
|
227
|
+
e.preventDefault();
|
|
228
|
+
e.stopPropagation();
|
|
229
|
+
// if (formElement && indexRowForm <= totalRowFrom) {
|
|
230
|
+
// setIndexRowForm((prevState) => prevState + 1)
|
|
231
|
+
// formElement.getElementsByTagName('input')[indexRowForm + 1]?.focus()
|
|
232
|
+
// }
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// if (e.code === 'Enter') {
|
|
236
|
+
// const rs = getValues()
|
|
237
|
+
//
|
|
238
|
+
//
|
|
239
|
+
// onChange(rs)
|
|
240
|
+
//
|
|
241
|
+
// if (column.editFromSettings && column?.editFromSettings?.formClose) {
|
|
242
|
+
// column?.editFromSettings?.formClose({value, setValue, getValues, reset})
|
|
243
|
+
// }
|
|
244
|
+
// if (inputRef) {
|
|
245
|
+
// inputRef.current.focus()
|
|
246
|
+
// }
|
|
247
|
+
//
|
|
248
|
+
// e.preventDefault()
|
|
249
|
+
// e.stopPropagation()
|
|
250
|
+
// }
|
|
251
|
+
|
|
252
|
+
if (e.code === "Escape") {
|
|
253
|
+
handleToggle();
|
|
254
|
+
if (inputRef) {
|
|
255
|
+
inputRef.current.focus();
|
|
256
|
+
}
|
|
257
|
+
e.preventDefault();
|
|
258
|
+
e.stopPropagation();
|
|
259
|
+
}
|
|
260
|
+
return e.code;
|
|
261
|
+
// }
|
|
262
|
+
};
|
|
263
|
+
const renderForm = rows => {
|
|
264
|
+
return /*#__PURE__*/React.createElement(Row, {
|
|
265
|
+
gutter: [0, 10]
|
|
266
|
+
}, rows.map((item, index) => {
|
|
267
|
+
return /*#__PURE__*/React.createElement(Col, {
|
|
268
|
+
key: `${index}`,
|
|
269
|
+
xl: column.editFromSettings?.layout?.xl ? column.editFromSettings?.layout?.xl : 24,
|
|
270
|
+
lg: column.editFromSettings?.layout?.lg ? column.editFromSettings?.layout?.lg : 24,
|
|
271
|
+
md: column.editFromSettings?.layout?.md ? column.editFromSettings?.layout?.md : 24,
|
|
272
|
+
sm: column.editFromSettings?.layout?.sm ? column.editFromSettings?.layout?.sm : 24,
|
|
273
|
+
xs: column.editFromSettings?.layout?.xs ? column.editFromSettings?.layout?.xs : 24,
|
|
274
|
+
className: 'mb-1'
|
|
275
|
+
}, /*#__PURE__*/React.createElement(InputControl, {
|
|
276
|
+
id: `edit-form-${index}`,
|
|
277
|
+
t: t,
|
|
278
|
+
control: control
|
|
279
|
+
// name={`specificationCode${index + 1}`}
|
|
280
|
+
,
|
|
281
|
+
name: item.name,
|
|
282
|
+
label: item.label ? item.label : '',
|
|
283
|
+
labelSize: "label-medium",
|
|
284
|
+
errors: errors[item.name],
|
|
285
|
+
onKeyDown: e => formItemKeyDown(e, index, column.editFromSettings?.items ? column.editFromSettings?.items.length : 0)
|
|
286
|
+
}));
|
|
287
|
+
}));
|
|
288
|
+
};
|
|
289
|
+
const contentStyle = {
|
|
290
|
+
padding: 6,
|
|
291
|
+
width: menuWidth,
|
|
292
|
+
backgroundColor: '#fff',
|
|
293
|
+
borderRadius: '6px',
|
|
294
|
+
boxShadow: '0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05)'
|
|
295
|
+
};
|
|
296
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(SelectStyle, {
|
|
297
|
+
ref: formRef,
|
|
298
|
+
id: id ? id : ''
|
|
299
|
+
}, /*#__PURE__*/React.createElement(Dropdown, {
|
|
300
|
+
menu: {
|
|
301
|
+
items: []
|
|
302
|
+
},
|
|
303
|
+
autoFocus: true,
|
|
304
|
+
onOpenChange: open => {
|
|
305
|
+
if (open) {
|
|
306
|
+
setTimeout(() => {
|
|
307
|
+
const formElement = document.getElementById('edit-form-0');
|
|
308
|
+
if (formElement) {
|
|
309
|
+
formElement.focus();
|
|
310
|
+
}
|
|
311
|
+
}, 10);
|
|
312
|
+
if (column.editFromSettings && column?.editFromSettings?.formOpen) {
|
|
313
|
+
column?.editFromSettings?.formOpen({
|
|
314
|
+
value,
|
|
315
|
+
setValue,
|
|
316
|
+
getValues,
|
|
317
|
+
reset
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
} else {
|
|
321
|
+
if (column.editFromSettings && column?.editFromSettings?.formClose) {
|
|
322
|
+
column?.editFromSettings?.formClose({
|
|
323
|
+
value,
|
|
324
|
+
setValue,
|
|
325
|
+
getValues,
|
|
326
|
+
reset
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
},
|
|
331
|
+
trigger: ['click'],
|
|
332
|
+
destroyPopupOnHide: true,
|
|
333
|
+
rootClassName: 'be-popup-container',
|
|
334
|
+
dropdownRender: () => /*#__PURE__*/React.createElement("div", {
|
|
335
|
+
style: contentStyle,
|
|
336
|
+
onKeyDown: e => handleFormKeydown(e),
|
|
337
|
+
onClick: e => {
|
|
338
|
+
e.preventDefault();
|
|
339
|
+
e.stopPropagation();
|
|
340
|
+
}
|
|
341
|
+
}, /*#__PURE__*/React.createElement("form", {
|
|
342
|
+
className: "todo-modal",
|
|
343
|
+
onSubmit: handleSubmit(handleOnSubmit)
|
|
344
|
+
}, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
345
|
+
className: 'p-1',
|
|
346
|
+
style: {
|
|
347
|
+
maxHeight: menuHeight ? menuHeight : 300,
|
|
348
|
+
overflow: "auto"
|
|
349
|
+
}
|
|
350
|
+
}, column.editFromSettings?.items ? renderForm(column.editFromSettings?.items) : ''), /*#__PURE__*/React.createElement(Divider, {
|
|
351
|
+
style: {
|
|
352
|
+
margin: 0
|
|
353
|
+
}
|
|
354
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
355
|
+
className: "d-flex justify-content-end p-1"
|
|
356
|
+
// style={{ boxShadow: "0 4px 24px 0 rgb(34 41 47 / 10%)" }}
|
|
357
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
358
|
+
variant: "solid",
|
|
359
|
+
className: ""
|
|
360
|
+
// onSubmit={handleSubmit(handleOnSubmit)}
|
|
361
|
+
,
|
|
362
|
+
onClick: handleSubmit(handleOnSubmit),
|
|
363
|
+
color: "primary",
|
|
364
|
+
style: {}
|
|
365
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
366
|
+
className: "d-flex "
|
|
367
|
+
}, t ? t('Save') : 'Save'))))))
|
|
368
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
369
|
+
ref: divRef,
|
|
370
|
+
style: {
|
|
371
|
+
height: '100%'
|
|
372
|
+
}
|
|
373
|
+
}, /*#__PURE__*/React.createElement(Input, {
|
|
374
|
+
style: {
|
|
375
|
+
borderRadius: 0,
|
|
376
|
+
height: '100%'
|
|
377
|
+
},
|
|
378
|
+
ref: inputRef,
|
|
379
|
+
defaultValue: defaultValue,
|
|
380
|
+
value: defaultValue,
|
|
381
|
+
placeholder: placeholder,
|
|
382
|
+
className: 'be-select__input'
|
|
383
|
+
// onChange={handleOnChange}
|
|
384
|
+
,
|
|
385
|
+
onFocus: handleOnFocus
|
|
386
|
+
// onClick={handleOnClick}
|
|
387
|
+
// onKeyDown={handleOnKeyDown}
|
|
388
|
+
,
|
|
389
|
+
readOnly: true
|
|
390
|
+
})))));
|
|
391
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './EditForm';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./EditForm";
|