es-grid-template 1.8.71 → 1.8.72

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 (235) hide show
  1. package/es/grid-component/TempTable.js +2 -1
  2. package/es/group-component/ColumnsChoose.d.ts +13 -0
  3. package/es/group-component/ColumnsChoose.js +211 -0
  4. package/es/group-component/ColumnsGroup/ColumnsGroup.d.ts +12 -0
  5. package/es/group-component/ColumnsGroup/ColumnsGroup.js +230 -0
  6. package/es/group-component/ColumnsGroup/index.d.ts +1 -0
  7. package/es/group-component/ColumnsGroup/index.js +1 -0
  8. package/es/group-component/ContextMenu.d.ts +19 -0
  9. package/es/group-component/ContextMenu.js +74 -0
  10. package/es/group-component/InternalTable.d.ts +8 -0
  11. package/es/group-component/InternalTable.js +224 -0
  12. package/es/group-component/TableContainer.d.ts +49 -0
  13. package/es/group-component/TableContainer.js +375 -0
  14. package/es/group-component/TableContainerEdit.d.ts +48 -0
  15. package/es/group-component/TableContainerEdit.js +2068 -0
  16. package/es/group-component/body/EditableCell.d.ts +16 -0
  17. package/es/group-component/body/EditableCell.js +1066 -0
  18. package/es/group-component/body/TableBody.d.ts +14 -0
  19. package/es/group-component/body/TableBody.js +82 -0
  20. package/es/group-component/body/TableBodyCell.d.ts +12 -0
  21. package/es/group-component/body/TableBodyCell.js +587 -0
  22. package/es/group-component/body/TableBodyCellEdit.d.ts +17 -0
  23. package/es/group-component/body/TableBodyCellEdit.js +1398 -0
  24. package/es/group-component/body/TableBodyCellEmpty.d.ts +12 -0
  25. package/es/group-component/body/TableBodyCellEmpty.js +149 -0
  26. package/es/group-component/body/TableBodyRow.d.ts +21 -0
  27. package/es/group-component/body/TableBodyRow.js +199 -0
  28. package/es/group-component/body/TableBodyRowGroupCell.d.ts +12 -0
  29. package/es/group-component/body/TableBodyRowGroupCell.js +567 -0
  30. package/es/group-component/components/ControlCheckbox.d.ts +13 -0
  31. package/es/group-component/components/ControlCheckbox.js +84 -0
  32. package/es/group-component/components/EditForm/EditForm.d.ts +27 -0
  33. package/es/group-component/components/EditForm/EditForm.js +394 -0
  34. package/es/group-component/components/EditForm/index.d.ts +1 -0
  35. package/es/group-component/components/EditForm/index.js +1 -0
  36. package/es/group-component/components/InputControl/InputControl.d.ts +27 -0
  37. package/es/group-component/components/InputControl/InputControl.js +118 -0
  38. package/es/group-component/components/InputControl/index.d.ts +1 -0
  39. package/es/group-component/components/InputControl/index.js +1 -0
  40. package/es/group-component/components/async-select/index.d.ts +11 -0
  41. package/es/group-component/components/async-select/index.js +38 -0
  42. package/es/group-component/components/async-table-select/index.d.ts +11 -0
  43. package/es/group-component/components/async-table-select/index.js +40 -0
  44. package/es/group-component/components/checkbox-control/index.d.ts +13 -0
  45. package/es/group-component/components/checkbox-control/index.js +40 -0
  46. package/es/group-component/components/checkbox-filter/CheckboxFilter.d.ts +18 -0
  47. package/es/group-component/components/checkbox-filter/CheckboxFilter.js +258 -0
  48. package/es/group-component/components/checkbox-filter/FilterSearch.d.ts +12 -0
  49. package/es/group-component/components/checkbox-filter/FilterSearch.js +36 -0
  50. package/es/group-component/components/command/Command.d.ts +10 -0
  51. package/es/group-component/components/command/Command.js +35 -0
  52. package/es/group-component/components/number/index.d.ts +12 -0
  53. package/es/group-component/components/number/index.js +42 -0
  54. package/es/group-component/components/number-range/index.d.ts +13 -0
  55. package/es/group-component/components/number-range/index.js +79 -0
  56. package/es/group-component/features/operator.d.ts +24 -0
  57. package/es/group-component/features/operator.js +62 -0
  58. package/es/group-component/footer/TableFooter.d.ts +7 -0
  59. package/es/group-component/footer/TableFooter.js +34 -0
  60. package/es/group-component/footer/TableFooterCell.d.ts +7 -0
  61. package/es/group-component/footer/TableFooterCell.js +66 -0
  62. package/es/group-component/footer/TableFooterRow.d.ts +8 -0
  63. package/es/group-component/footer/TableFooterRow.js +30 -0
  64. package/es/group-component/header/TableHead.d.ts +15 -0
  65. package/es/group-component/header/TableHead.js +98 -0
  66. package/es/group-component/header/TableHeadCell.d.ts +15 -0
  67. package/es/group-component/header/TableHeadCell.js +310 -0
  68. package/es/group-component/header/TableHeadCell2.d.ts +17 -0
  69. package/es/group-component/header/TableHeadCell2.js +321 -0
  70. package/es/group-component/header/TableHeadGroupCell.d.ts +17 -0
  71. package/es/group-component/header/TableHeadGroupCell.js +94 -0
  72. package/es/group-component/header/TableHeadRow.d.ts +15 -0
  73. package/es/group-component/header/TableHeadRow.js +52 -0
  74. package/es/group-component/header/renderFilter.d.ts +20 -0
  75. package/es/group-component/header/renderFilter.js +291 -0
  76. package/es/group-component/hook/convert.d.ts +1 -0
  77. package/es/group-component/hook/convert.js +28 -0
  78. package/es/group-component/hook/useColumns.d.ts +28 -0
  79. package/es/group-component/hook/useColumns.js +306 -0
  80. package/es/group-component/hook/useFilterOperator.d.ts +7 -0
  81. package/es/group-component/hook/useFilterOperator.js +33 -0
  82. package/es/group-component/hook/utils.d.ts +220 -0
  83. package/es/group-component/hook/utils.js +2340 -0
  84. package/es/group-component/index.d.ts +2 -0
  85. package/es/group-component/index.js +2 -0
  86. package/es/group-component/style.d.ts +22 -0
  87. package/es/group-component/style.js +48 -0
  88. package/es/group-component/style.scss +1438 -0
  89. package/es/group-component/table/Grid.d.ts +33 -0
  90. package/es/group-component/table/Grid.js +438 -0
  91. package/es/group-component/table/TableWrapper.d.ts +33 -0
  92. package/es/group-component/table/TableWrapper.js +250 -0
  93. package/es/group-component/useContext.d.ts +100 -0
  94. package/es/group-component/useContext.js +21 -0
  95. package/es/table-component/InternalTable.js +6 -1
  96. package/es/table-component/TableContainer.js +4 -2
  97. package/es/table-component/body/TableBodyCell.js +49 -40
  98. package/es/table-component/body/TableBodyRow.js +4 -1
  99. package/es/table-component/hook/utils.d.ts +1 -0
  100. package/es/table-component/hook/utils.js +15 -7
  101. package/es/table-component/style.js +1 -1
  102. package/es/table-component/table/Grid.js +3 -0
  103. package/es/table-component/useContext.d.ts +5 -0
  104. package/es/table-virtuoso/InternalTable.js +2 -2
  105. package/es/table-virtuoso/body/TableBodyCell.js +2 -7
  106. package/es/table-virtuoso/body/TableBodyCellRowGroup.d.ts +14 -0
  107. package/es/table-virtuoso/body/TableBodyCellRowGroup.js +196 -0
  108. package/es/table-virtuoso/body/TableBodyRow.d.ts +1 -1
  109. package/es/table-virtuoso/body/TableBodyRow.js +43 -1
  110. package/es/table-virtuoso/hook/utils.d.ts +1 -0
  111. package/es/table-virtuoso/hook/utils.js +29 -0
  112. package/es/table-virtuoso/style.js +3 -1
  113. package/es/table-virtuoso/table/Grid.js +2 -2
  114. package/es/table-virtuoso/table/TableWrapper.d.ts +7 -1
  115. package/es/table-virtuoso/table/TableWrapper.js +24 -5
  116. package/es/table-virtuoso/useContext.d.ts +6 -3
  117. package/es/table-virtuoso/useContext.js +18 -0
  118. package/lib/grid-component/TempTable.js +2 -1
  119. package/lib/group-component/ColumnsChoose.d.ts +13 -0
  120. package/lib/group-component/ColumnsChoose.js +221 -0
  121. package/lib/group-component/ColumnsGroup/ColumnsGroup.d.ts +12 -0
  122. package/lib/group-component/ColumnsGroup/ColumnsGroup.js +241 -0
  123. package/lib/group-component/ColumnsGroup/index.d.ts +1 -0
  124. package/lib/group-component/ColumnsGroup/index.js +16 -0
  125. package/lib/group-component/ContextMenu.d.ts +19 -0
  126. package/lib/group-component/ContextMenu.js +83 -0
  127. package/lib/group-component/InternalTable.d.ts +8 -0
  128. package/lib/group-component/InternalTable.js +233 -0
  129. package/lib/group-component/TableContainer.d.ts +49 -0
  130. package/lib/group-component/TableContainer.js +382 -0
  131. package/lib/group-component/TableContainerEdit.d.ts +48 -0
  132. package/lib/group-component/TableContainerEdit.js +2075 -0
  133. package/lib/group-component/body/EditableCell.d.ts +16 -0
  134. package/lib/group-component/body/EditableCell.js +1075 -0
  135. package/lib/group-component/body/TableBody.d.ts +14 -0
  136. package/lib/group-component/body/TableBody.js +91 -0
  137. package/lib/group-component/body/TableBodyCell.d.ts +12 -0
  138. package/lib/group-component/body/TableBodyCell.js +595 -0
  139. package/lib/group-component/body/TableBodyCellEdit.d.ts +17 -0
  140. package/lib/group-component/body/TableBodyCellEdit.js +1405 -0
  141. package/lib/group-component/body/TableBodyCellEmpty.d.ts +12 -0
  142. package/lib/group-component/body/TableBodyCellEmpty.js +156 -0
  143. package/lib/group-component/body/TableBodyRow.d.ts +21 -0
  144. package/lib/group-component/body/TableBodyRow.js +206 -0
  145. package/lib/group-component/body/TableBodyRowGroupCell.d.ts +12 -0
  146. package/lib/group-component/body/TableBodyRowGroupCell.js +575 -0
  147. package/lib/group-component/components/ControlCheckbox.d.ts +13 -0
  148. package/lib/group-component/components/ControlCheckbox.js +92 -0
  149. package/lib/group-component/components/EditForm/EditForm.d.ts +27 -0
  150. package/lib/group-component/components/EditForm/EditForm.js +404 -0
  151. package/lib/group-component/components/EditForm/index.d.ts +1 -0
  152. package/lib/group-component/components/EditForm/index.js +16 -0
  153. package/lib/group-component/components/InputControl/InputControl.d.ts +27 -0
  154. package/lib/group-component/components/InputControl/InputControl.js +127 -0
  155. package/lib/group-component/components/InputControl/index.d.ts +1 -0
  156. package/lib/group-component/components/InputControl/index.js +16 -0
  157. package/lib/group-component/components/async-select/index.d.ts +11 -0
  158. package/lib/group-component/components/async-select/index.js +47 -0
  159. package/lib/group-component/components/async-table-select/index.d.ts +11 -0
  160. package/lib/group-component/components/async-table-select/index.js +49 -0
  161. package/lib/group-component/components/checkbox-control/index.d.ts +13 -0
  162. package/lib/group-component/components/checkbox-control/index.js +48 -0
  163. package/lib/group-component/components/checkbox-filter/CheckboxFilter.d.ts +18 -0
  164. package/lib/group-component/components/checkbox-filter/CheckboxFilter.js +267 -0
  165. package/lib/group-component/components/checkbox-filter/FilterSearch.d.ts +12 -0
  166. package/lib/group-component/components/checkbox-filter/FilterSearch.js +44 -0
  167. package/lib/group-component/components/command/Command.d.ts +10 -0
  168. package/lib/group-component/components/command/Command.js +44 -0
  169. package/lib/group-component/components/number/index.d.ts +12 -0
  170. package/lib/group-component/components/number/index.js +50 -0
  171. package/lib/group-component/components/number-range/index.d.ts +13 -0
  172. package/lib/group-component/components/number-range/index.js +87 -0
  173. package/lib/group-component/features/operator.d.ts +24 -0
  174. package/lib/group-component/features/operator.js +67 -0
  175. package/lib/group-component/footer/TableFooter.d.ts +7 -0
  176. package/lib/group-component/footer/TableFooter.js +44 -0
  177. package/lib/group-component/footer/TableFooterCell.d.ts +7 -0
  178. package/lib/group-component/footer/TableFooterCell.js +75 -0
  179. package/lib/group-component/footer/TableFooterRow.d.ts +8 -0
  180. package/lib/group-component/footer/TableFooterRow.js +37 -0
  181. package/lib/group-component/header/TableHead.d.ts +15 -0
  182. package/lib/group-component/header/TableHead.js +107 -0
  183. package/lib/group-component/header/TableHeadCell.d.ts +15 -0
  184. package/lib/group-component/header/TableHeadCell.js +319 -0
  185. package/lib/group-component/header/TableHeadCell2.d.ts +17 -0
  186. package/lib/group-component/header/TableHeadCell2.js +330 -0
  187. package/lib/group-component/header/TableHeadGroupCell.d.ts +17 -0
  188. package/lib/group-component/header/TableHeadGroupCell.js +103 -0
  189. package/lib/group-component/header/TableHeadRow.d.ts +15 -0
  190. package/lib/group-component/header/TableHeadRow.js +59 -0
  191. package/lib/group-component/header/renderFilter.d.ts +20 -0
  192. package/lib/group-component/header/renderFilter.js +301 -0
  193. package/lib/group-component/hook/convert.d.ts +1 -0
  194. package/lib/group-component/hook/convert.js +34 -0
  195. package/lib/group-component/hook/useColumns.d.ts +28 -0
  196. package/lib/group-component/hook/useColumns.js +318 -0
  197. package/lib/group-component/hook/useFilterOperator.d.ts +7 -0
  198. package/lib/group-component/hook/useFilterOperator.js +40 -0
  199. package/lib/group-component/hook/utils.d.ts +220 -0
  200. package/lib/group-component/hook/utils.js +2468 -0
  201. package/lib/group-component/index.d.ts +2 -0
  202. package/lib/group-component/index.js +9 -0
  203. package/lib/group-component/style.d.ts +22 -0
  204. package/lib/group-component/style.js +55 -0
  205. package/lib/group-component/style.scss +1438 -0
  206. package/lib/group-component/table/Grid.d.ts +33 -0
  207. package/lib/group-component/table/Grid.js +443 -0
  208. package/lib/group-component/table/TableWrapper.d.ts +33 -0
  209. package/lib/group-component/table/TableWrapper.js +259 -0
  210. package/lib/group-component/useContext.d.ts +100 -0
  211. package/lib/group-component/useContext.js +27 -0
  212. package/lib/table-component/InternalTable.js +6 -1
  213. package/lib/table-component/TableContainer.js +4 -2
  214. package/lib/table-component/body/TableBodyCell.js +49 -40
  215. package/lib/table-component/body/TableBodyRow.js +4 -1
  216. package/lib/table-component/hook/utils.d.ts +1 -0
  217. package/lib/table-component/hook/utils.js +16 -7
  218. package/lib/table-component/style.js +1 -1
  219. package/lib/table-component/table/Grid.js +3 -0
  220. package/lib/table-component/useContext.d.ts +5 -0
  221. package/lib/table-virtuoso/InternalTable.js +2 -2
  222. package/lib/table-virtuoso/body/TableBodyCell.js +2 -7
  223. package/lib/table-virtuoso/body/TableBodyCellRowGroup.d.ts +14 -0
  224. package/lib/table-virtuoso/body/TableBodyCellRowGroup.js +203 -0
  225. package/lib/table-virtuoso/body/TableBodyRow.d.ts +1 -1
  226. package/lib/table-virtuoso/body/TableBodyRow.js +43 -1
  227. package/lib/table-virtuoso/hook/utils.d.ts +1 -0
  228. package/lib/table-virtuoso/hook/utils.js +32 -1
  229. package/lib/table-virtuoso/style.js +3 -1
  230. package/lib/table-virtuoso/table/Grid.js +2 -2
  231. package/lib/table-virtuoso/table/TableWrapper.d.ts +7 -1
  232. package/lib/table-virtuoso/table/TableWrapper.js +24 -5
  233. package/lib/table-virtuoso/useContext.d.ts +6 -3
  234. package/lib/table-virtuoso/useContext.js +18 -0
  235. package/package.json +1 -1
@@ -0,0 +1,394 @@
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 { isNullOrUndefined, isObjEmpty } from "../../hook/utils";
7
+ import { Input } from "rc-master-ui";
8
+ import { Dropdown } from "antd";
9
+ import Divider from "rc-master-ui/es/divider";
10
+ import Button from "rc-master-ui/es/button";
11
+ import InputControl from "../InputControl/InputControl";
12
+ export const SelectStyle = styled.div.withConfig({
13
+ displayName: "SelectStyle",
14
+ componentId: "es-grid-template__sc-6p8cbm-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
+ rowData,
29
+ // onKeyDown,
30
+ t,
31
+ cellFocus,
32
+ column
33
+ } = props;
34
+ const formRef = useRef();
35
+ const divRef = useRef(null);
36
+ const inputRef = useRef(null);
37
+ const defaultValue = !isNullOrUndefined(value) ? column?.editFromSettings?.formatLabel ? column?.editFromSettings?.formatLabel(value) : value[fieldKey] : '';
38
+ const {
39
+ control,
40
+ handleSubmit,
41
+ getValues,
42
+ reset,
43
+ setValue,
44
+ setError,
45
+ formState: {
46
+ errors
47
+ }
48
+ } = useForm({
49
+ mode: 'onChange',
50
+ defaultValues: column.editFromSettings?.defaultValues,
51
+ resolver: column.editFromSettings?.schema ? yupResolver(column.editFromSettings?.schema) : undefined
52
+ });
53
+ const handleToggle = () => {
54
+ divRef?.current?.click(); // Giả lập click vào nút để mở dropdown
55
+ };
56
+ React.useEffect(() => {
57
+ if (cellFocus) {
58
+ handleToggle();
59
+ }
60
+ }, [cellFocus]);
61
+ const handleOnSubmit = val => {
62
+ handleToggle();
63
+ onChange(val);
64
+ };
65
+
66
+ // const handleOnKeyDown = (e: any) => {
67
+ //
68
+ // if (dropdownOpen) {
69
+ // e.preventDefault()
70
+ //
71
+ // if (e.code === 'Tab') {
72
+ // e.stopPropagation()
73
+ // const formElement = document.getElementById('edit-form')
74
+ //
75
+ // if (formElement) {
76
+ //
77
+ // formElement.getElementsByTagName('input')[0]?.focus()
78
+ //
79
+ // }
80
+ //
81
+ // }
82
+ //
83
+ // if (e.code === "Escape") {
84
+ // e.preventDefault()
85
+ // e.stopPropagation()
86
+ // return e
87
+ // }
88
+ //
89
+ // const formElement = document.getElementById('edit-form')
90
+ //
91
+ // if (formElement) {
92
+ //
93
+ // formElement.getElementsByTagName('input')[0]?.focus()
94
+ //
95
+ // }
96
+ // return e.code
97
+ //
98
+ //
99
+ // } else {
100
+ // if (e.code === 'ArrowDown') {
101
+ // e.preventDefault()
102
+ //
103
+ // setTimeout(() => {
104
+ // const formElement = document.getElementById('edit-form')
105
+ // if (formElement) {
106
+ // formElement.getElementsByTagName('input')[0]?.focus()
107
+ //
108
+ // }
109
+ //
110
+ // }, 100)
111
+ //
112
+ //
113
+ // }
114
+ // }
115
+ //
116
+ // if (onKeyDown) {
117
+ // onKeyDown(e)
118
+ // }
119
+ //
120
+ //
121
+ // }
122
+ //
123
+
124
+ const handleOnFocus = e => {
125
+ e.target.setSelectionRange(0, e.target.innerText.length - 1);
126
+ };
127
+ const formItemKeyDown = (e, index, length) => {
128
+ if (e.code === 'Tab' || e.code === 'ArrowDown') {
129
+ const itemElement = document.getElementById(`edit-form-${index + 1}`);
130
+ if (itemElement && index < length) {
131
+ if (itemElement.className.includes('be-select')) {
132
+ itemElement.getElementsByTagName('input')[0]?.focus();
133
+ } else {
134
+ itemElement.focus();
135
+ }
136
+ }
137
+ e.preventDefault();
138
+ }
139
+ if (e.code === 'ArrowUp') {
140
+ const itemElement = document.getElementById(`edit-form-${index - 1}`);
141
+ if (itemElement && index !== 0) {
142
+ if (itemElement.className.includes('be-select')) {
143
+ itemElement.getElementsByTagName('input')[0]?.focus();
144
+ } else {
145
+ itemElement.focus();
146
+ }
147
+ }
148
+ e.preventDefault();
149
+ }
150
+ if (e.code === 'Enter') {
151
+ if (isObjEmpty(errors)) {
152
+ const rs = getValues();
153
+ if (column.editFromSettings?.schema) {
154
+ column.editFromSettings?.schema.validate(rs, {
155
+ abortEarly: false
156
+ }).then(() => {
157
+ handleToggle();
158
+ onChange(rs);
159
+ if (column.editFromSettings && column?.editFromSettings?.formClose) {
160
+ column?.editFromSettings?.formClose({
161
+ value,
162
+ setValue,
163
+ getValues,
164
+ reset
165
+ });
166
+ }
167
+ if (inputRef) {
168
+ inputRef.current.focus();
169
+ }
170
+ }).catch(err => {
171
+ e.preventDefault();
172
+ e.stopPropagation();
173
+ err.inner.forEach(error => {
174
+ setError(error.path ? error.path : '', {
175
+ type: "manual",
176
+ message: error.message
177
+ });
178
+ });
179
+ });
180
+ }
181
+ } else {
182
+ e.preventDefault();
183
+ e.stopPropagation();
184
+ }
185
+ }
186
+ };
187
+
188
+ // const checkErrors = () => {
189
+ //
190
+ //
191
+ // if (isObjEmpty(errors)) {
192
+ // const rs = getValues()
193
+ // if (column.editFromSettings?.schema) {
194
+ // column.editFromSettings?.schema.validate(rs, { abortEarly: false })
195
+ // .then(() => {
196
+ // handleToggle()
197
+ // onChange(rs)
198
+ //
199
+ // if (column.editFromSettings && column?.editFromSettings?.formClose) {
200
+ // column?.editFromSettings?.formClose({value, setValue, getValues, reset})
201
+ // }
202
+ // if (inputRef) {
203
+ // inputRef.current.focus()
204
+ // }
205
+ // })
206
+ // .catch((err: ValidationError) => {
207
+ //
208
+ // err.inner.forEach((error: ValidationError) => {
209
+ //
210
+ // setError(error.path ? error.path : '', {
211
+ // type: "manual",
212
+ // message: error.message
213
+ // })
214
+ // })
215
+ // })
216
+ // }
217
+ //
218
+ //
219
+ // } else {
220
+ //
221
+ // }
222
+ // }
223
+
224
+ const handleFormKeydown = e => {
225
+ // if (dropdownOpen) {
226
+
227
+ if (e.code === 'Tab' || e.code === 'ArrowUp' || e.code === 'ArrowDown') {
228
+ e.preventDefault();
229
+ e.stopPropagation();
230
+ // if (formElement && indexRowForm <= totalRowFrom) {
231
+ // setIndexRowForm((prevState) => prevState + 1)
232
+ // formElement.getElementsByTagName('input')[indexRowForm + 1]?.focus()
233
+ // }
234
+ }
235
+
236
+ // if (e.code === 'Enter') {
237
+ // const rs = getValues()
238
+ //
239
+ //
240
+ // onChange(rs)
241
+ //
242
+ // if (column.editFromSettings && column?.editFromSettings?.formClose) {
243
+ // column?.editFromSettings?.formClose({value, setValue, getValues, reset})
244
+ // }
245
+ // if (inputRef) {
246
+ // inputRef.current.focus()
247
+ // }
248
+ //
249
+ // e.preventDefault()
250
+ // e.stopPropagation()
251
+ // }
252
+
253
+ if (e.code === "Escape") {
254
+ handleToggle();
255
+ if (inputRef) {
256
+ inputRef.current.focus();
257
+ }
258
+ e.preventDefault();
259
+ e.stopPropagation();
260
+ }
261
+ return e.code;
262
+ // }
263
+ };
264
+ const renderForm = rows => {
265
+ return /*#__PURE__*/React.createElement(Row, {
266
+ gutter: [0, 10]
267
+ }, rows.map((item, index) => {
268
+ return /*#__PURE__*/React.createElement(Col, {
269
+ key: `${index}`,
270
+ xl: column.editFromSettings?.layout?.xl ? column.editFromSettings?.layout?.xl : 24,
271
+ lg: column.editFromSettings?.layout?.lg ? column.editFromSettings?.layout?.lg : 24,
272
+ md: column.editFromSettings?.layout?.md ? column.editFromSettings?.layout?.md : 24,
273
+ sm: column.editFromSettings?.layout?.sm ? column.editFromSettings?.layout?.sm : 24,
274
+ xs: column.editFromSettings?.layout?.xs ? column.editFromSettings?.layout?.xs : 24,
275
+ className: 'mb-1'
276
+ }, /*#__PURE__*/React.createElement(InputControl, {
277
+ id: `edit-form-${index}`,
278
+ t: t,
279
+ control: control
280
+ // name={`specificationCode${index + 1}`}
281
+ ,
282
+ name: item.name,
283
+ label: item.label ? item.label : '',
284
+ labelSize: "label-medium",
285
+ errors: errors[item.name],
286
+ onKeyDown: e => formItemKeyDown(e, index, column.editFromSettings?.items ? column.editFromSettings?.items.length : 0)
287
+ }));
288
+ }));
289
+ };
290
+ const contentStyle = {
291
+ padding: 6,
292
+ width: menuWidth,
293
+ backgroundColor: '#fff',
294
+ borderRadius: '6px',
295
+ 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)'
296
+ };
297
+ return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(SelectStyle, {
298
+ ref: formRef,
299
+ id: id ? id : ''
300
+ }, /*#__PURE__*/React.createElement(Dropdown, {
301
+ menu: {
302
+ items: []
303
+ },
304
+ autoFocus: true,
305
+ onOpenChange: open => {
306
+ if (open) {
307
+ setTimeout(() => {
308
+ const formElement = document.getElementById('edit-form-0');
309
+ if (formElement) {
310
+ formElement.focus();
311
+ }
312
+ }, 10);
313
+ if (column.editFromSettings && column?.editFromSettings?.formOpen) {
314
+ column?.editFromSettings?.formOpen({
315
+ value,
316
+ setValue,
317
+ getValues,
318
+ reset,
319
+ rowData
320
+ });
321
+ }
322
+ } else {
323
+ if (column.editFromSettings && column?.editFromSettings?.formClose) {
324
+ column?.editFromSettings?.formClose({
325
+ value,
326
+ setValue,
327
+ getValues,
328
+ reset,
329
+ rowData
330
+ });
331
+ }
332
+ }
333
+ },
334
+ trigger: ['click'],
335
+ destroyPopupOnHide: true,
336
+ rootClassName: 'be-popup-container',
337
+ dropdownRender: () => /*#__PURE__*/React.createElement("div", {
338
+ style: contentStyle,
339
+ onKeyDown: e => handleFormKeydown(e),
340
+ onClick: e => {
341
+ e.preventDefault();
342
+ e.stopPropagation();
343
+ }
344
+ }, /*#__PURE__*/React.createElement("form", {
345
+ className: "todo-modal",
346
+ onSubmit: handleSubmit(handleOnSubmit)
347
+ }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
348
+ className: 'p-1',
349
+ style: {
350
+ maxHeight: menuHeight ? menuHeight : 300,
351
+ overflow: "auto"
352
+ }
353
+ }, column.editFromSettings?.items ? renderForm(column.editFromSettings?.items) : ''), /*#__PURE__*/React.createElement(Divider, {
354
+ style: {
355
+ margin: 0
356
+ }
357
+ }), /*#__PURE__*/React.createElement("div", {
358
+ className: "d-flex justify-content-end p-1"
359
+ // style={{ boxShadow: "0 4px 24px 0 rgb(34 41 47 / 10%)" }}
360
+ }, /*#__PURE__*/React.createElement(Button, {
361
+ variant: "solid",
362
+ className: ""
363
+ // onSubmit={handleSubmit(handleOnSubmit)}
364
+ ,
365
+ onClick: handleSubmit(handleOnSubmit),
366
+ color: "primary",
367
+ style: {}
368
+ }, /*#__PURE__*/React.createElement("div", {
369
+ className: "d-flex "
370
+ }, t ? t('Save') : 'Save'))))))
371
+ }, /*#__PURE__*/React.createElement("div", {
372
+ ref: divRef,
373
+ style: {
374
+ height: '100%'
375
+ }
376
+ }, /*#__PURE__*/React.createElement(Input, {
377
+ style: {
378
+ borderRadius: 0,
379
+ height: '100%'
380
+ },
381
+ ref: inputRef,
382
+ defaultValue: defaultValue,
383
+ value: defaultValue,
384
+ placeholder: placeholder,
385
+ className: 'be-select__input'
386
+ // onChange={handleOnChange}
387
+ ,
388
+ onFocus: handleOnFocus
389
+ // onClick={handleOnClick}
390
+ // onKeyDown={handleOnKeyDown}
391
+ ,
392
+ readOnly: true
393
+ })))));
394
+ };
@@ -0,0 +1 @@
1
+ export * from './EditForm';
@@ -0,0 +1 @@
1
+ export * from "./EditForm";
@@ -0,0 +1,27 @@
1
+ import type { HTMLInputTypeAttribute } from "react";
2
+ import React from "react";
3
+ interface IFFormInput {
4
+ id?: any;
5
+ control: any;
6
+ name: string;
7
+ type?: HTMLInputTypeAttribute;
8
+ label: string;
9
+ labelSize?: string;
10
+ required?: boolean;
11
+ errors?: any;
12
+ height?: number | string;
13
+ disabled?: boolean;
14
+ row?: number;
15
+ isLabel?: boolean;
16
+ inLine?: boolean;
17
+ autoFocus?: boolean;
18
+ placeholder?: string;
19
+ classes?: string;
20
+ callback?: any;
21
+ readOnly?: boolean;
22
+ isView?: boolean;
23
+ t?: any;
24
+ onKeyDown?: (event: any) => void;
25
+ }
26
+ declare const InputControl: (props: IFFormInput) => React.JSX.Element;
27
+ export default InputControl;
@@ -0,0 +1,118 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import { Controller } from "react-hook-form";
3
+ import { Input } from "rc-master-ui";
4
+ import { Typography } from "antd";
5
+ import classnames from "classnames";
6
+ import React, { Fragment } from "react";
7
+ import { Col, Row } from "rc-master-ui/es/grid";
8
+ import { isNullOrUndefined } from "../../hook/utils";
9
+ const {
10
+ Text
11
+ } = Typography;
12
+ const InputControl = props => {
13
+ const {
14
+ id,
15
+ control,
16
+ name,
17
+ type,
18
+ label,
19
+ labelSize,
20
+ required,
21
+ errors,
22
+ height,
23
+ disabled,
24
+ row,
25
+ isLabel,
26
+ placeholder,
27
+ autoFocus,
28
+ inLine,
29
+ callback,
30
+ readOnly,
31
+ classes,
32
+ isView,
33
+ t,
34
+ onKeyDown,
35
+ ...rest
36
+ } = props;
37
+ const renderLabel = () => {
38
+ return /*#__PURE__*/React.createElement(Col, {
39
+ span: 6
40
+ }, isLabel === false ? '' : /*#__PURE__*/React.createElement("label", {
41
+ className: "form-label"
42
+ }, t ? t(label ? label : '') : label ? label : '', " ", required ? /*#__PURE__*/React.createElement("span", {
43
+ className: "text-danger"
44
+ }, "*") : '', " "));
45
+ };
46
+
47
+ // const renderText = () => {
48
+ // return (
49
+ // <Fragment>
50
+ // <Controller
51
+ // name={name}
52
+ // control={control}
53
+ // render={({ field: { value } }) => (
54
+ // <span>{value}</span>
55
+ // )}
56
+ // />
57
+ // </Fragment>
58
+ // )
59
+ // }
60
+
61
+ const renderInput = () => {
62
+ return /*#__PURE__*/React.createElement("div", {
63
+ style: {
64
+ display: 'flex',
65
+ flexDirection: 'column'
66
+ }
67
+ }, /*#__PURE__*/React.createElement(Controller, {
68
+ name: name,
69
+ control: control,
70
+ render: ({
71
+ field: {
72
+ value,
73
+ onChange
74
+ }
75
+ }) => /*#__PURE__*/React.createElement(Input, _extends({}, rest, {
76
+ id: id,
77
+ value: !isNullOrUndefined(value) ? value : '',
78
+ onChange: val => {
79
+ onChange(val.target.value);
80
+ if (callback) {
81
+ callback(val);
82
+ }
83
+ },
84
+ style: {
85
+ height: `${height}px`
86
+ },
87
+ autoFocus: autoFocus,
88
+ disabled: disabled,
89
+ placeholder: placeholder,
90
+ type: type ? type : 'text'
91
+ // invalid={errors && true}
92
+ ,
93
+ status: errors && true ? 'error' : undefined
94
+ // rows={row}
95
+ ,
96
+ readOnly: readOnly,
97
+ onKeyDown: onKeyDown
98
+ }))
99
+ }), errors && /*#__PURE__*/React.createElement(Text, {
100
+ type: "danger"
101
+ }, errors?.message));
102
+ };
103
+ return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Row, {
104
+ gutter: [4, 4]
105
+ // className={classnames(' align', {
106
+ // [labelSize ? labelSize : '']: labelSize,
107
+ // [classes ? classes : '']: classes,
108
+ // 'form-row-inline-error': errors
109
+ // }, inLine === false ? 'form-group ' : 'form-row-inline d-flex'
110
+ // )}
111
+ }, renderLabel(), /*#__PURE__*/React.createElement(Col, {
112
+ span: 18,
113
+ className: classnames('', {
114
+ 'hidden-label': isLabel === false
115
+ })
116
+ }, renderInput())));
117
+ };
118
+ export default InputControl;
@@ -0,0 +1 @@
1
+ export * from './InputControl';
@@ -0,0 +1 @@
1
+ export * from "./InputControl";
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import type { BaseOptionType, DefaultOptionType } from "rc-select/lib/Select";
3
+ import type { SelectProps } from "rc-master-ui/es/select";
4
+ import type { LoadOptionsArgs } from '../../../grid-component/type';
5
+ export interface DebounceSelectProps<OptionType extends BaseOptionType = DefaultOptionType> extends SelectProps {
6
+ loadOptions?: (search: string, callback: (newOptions: OptionType[]) => void, args?: LoadOptionsArgs) => void;
7
+ debounceTimeout?: number;
8
+ defaultOptions?: OptionType[];
9
+ rowData?: any;
10
+ }
11
+ export declare function AsyncSelect<OptionType extends BaseOptionType>({ loadOptions, debounceTimeout, defaultOptions, rowData, ...props }: DebounceSelectProps<OptionType>): React.JSX.Element;
@@ -0,0 +1,38 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import React, { useEffect, useMemo, useState } from 'react';
3
+ import debounce from 'lodash/debounce';
4
+ import { Select } from "rc-master-ui";
5
+ export function AsyncSelect({
6
+ loadOptions,
7
+ debounceTimeout = 500,
8
+ defaultOptions,
9
+ rowData,
10
+ ...props
11
+ }) {
12
+ const [options, setOptions] = useState(defaultOptions ?? []);
13
+ const debounceFetcher = useMemo(() => {
14
+ const fetchOptions = value => {
15
+ if (value.trim().length === 0) {
16
+ setOptions(defaultOptions ?? []);
17
+ return;
18
+ }
19
+ if (loadOptions) {
20
+ loadOptions(value, newOptions => {
21
+ setOptions(newOptions);
22
+ }, {
23
+ rowData
24
+ });
25
+ }
26
+ };
27
+ return debounce(fetchOptions, debounceTimeout);
28
+ }, [loadOptions, debounceTimeout]);
29
+ useEffect(() => {
30
+ setOptions(defaultOptions ?? []);
31
+ }, [defaultOptions]);
32
+ return /*#__PURE__*/React.createElement(Select, _extends({}, props, {
33
+ filterOption: loadOptions ? false : props?.filterOption,
34
+ onSearch: debounceFetcher,
35
+ onSelect: () => setOptions(defaultOptions ?? []),
36
+ options: options
37
+ }));
38
+ }
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import type { BaseOptionType, DefaultOptionType } from "rc-select/lib/Select";
3
+ import type { TableSelectProps } from "rc-master-ui";
4
+ import type { LoadOptionsArgs } from '../../../grid-component/type';
5
+ export interface DebounceSelectProps<OptionType extends BaseOptionType = DefaultOptionType> extends TableSelectProps {
6
+ loadOptions?: (search: string, callback: (newOptions: OptionType[]) => void, args?: LoadOptionsArgs) => void;
7
+ debounceTimeout?: number;
8
+ defaultOptions?: OptionType[];
9
+ rowData?: any;
10
+ }
11
+ export declare function AsyncTableSelect<OptionType extends BaseOptionType>({ loadOptions, debounceTimeout, defaultOptions, columns, rowData, ...props }: DebounceSelectProps<OptionType>): React.JSX.Element;
@@ -0,0 +1,40 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import React, { useEffect, useMemo, useState } from 'react';
3
+ import debounce from 'lodash/debounce';
4
+ import { TableSelect } from "rc-master-ui";
5
+ export function AsyncTableSelect({
6
+ loadOptions,
7
+ debounceTimeout = 500,
8
+ defaultOptions,
9
+ columns,
10
+ rowData,
11
+ ...props
12
+ }) {
13
+ const [options, setOptions] = useState(defaultOptions ?? []);
14
+ const debounceFetcher = useMemo(() => {
15
+ const fetchOptions = value => {
16
+ if (value.trim().length === 0) {
17
+ setOptions(defaultOptions ?? []);
18
+ return;
19
+ }
20
+ if (loadOptions) {
21
+ loadOptions(value, newOptions => {
22
+ setOptions(newOptions);
23
+ }, {
24
+ rowData
25
+ });
26
+ }
27
+ };
28
+ return debounce(fetchOptions, debounceTimeout);
29
+ }, [debounceTimeout, loadOptions, defaultOptions, rowData]);
30
+ useEffect(() => {
31
+ setOptions(defaultOptions ?? []);
32
+ }, [defaultOptions]);
33
+ return /*#__PURE__*/React.createElement(TableSelect, _extends({}, props, {
34
+ filterOption: loadOptions ? false : props?.filterOption,
35
+ onSearch: debounceFetcher,
36
+ onSelect: () => setOptions(defaultOptions ?? []),
37
+ options: options,
38
+ columns: columns
39
+ }));
40
+ }
@@ -0,0 +1,13 @@
1
+ import React from "react";
2
+ type OptionType = {
3
+ value: any;
4
+ label: string;
5
+ [key: string]: any;
6
+ };
7
+ type Props<T> = {
8
+ options: T[];
9
+ value: any[];
10
+ onChange?: (value: any[]) => void;
11
+ };
12
+ declare const CheckboxControl: <T extends OptionType>(props: Props<T>) => React.JSX.Element;
13
+ export default CheckboxControl;