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