funda-ui 4.1.345 → 4.1.354

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 (55) hide show
  1. package/CascadingSelect/index.d.ts +1 -1
  2. package/CascadingSelectE2E/index.d.ts +1 -1
  3. package/Checkbox/index.d.ts +1 -1
  4. package/Checkbox/index.js +1 -1
  5. package/ColorPicker/index.js +2 -1
  6. package/Date/index.d.ts +2 -2
  7. package/DropdownMenu/index.js +1 -1
  8. package/Input/index.d.ts +1 -1
  9. package/LiveSearch/index.d.ts +2 -2
  10. package/MultiFuncSelect/index.d.ts +2 -2
  11. package/MultipleCheckboxes/index.d.ts +1 -1
  12. package/MultipleCheckboxes/index.js +4 -2
  13. package/MultipleSelect/index.js +2 -1
  14. package/Radio/index.d.ts +1 -1
  15. package/Table/index.d.ts +1 -1
  16. package/Table/index.js +44 -11
  17. package/TagInput/index.js +2 -1
  18. package/Textarea/index.d.ts +1 -1
  19. package/lib/cjs/CascadingSelect/index.d.ts +1 -1
  20. package/lib/cjs/CascadingSelectE2E/index.d.ts +1 -1
  21. package/lib/cjs/Checkbox/index.d.ts +1 -1
  22. package/lib/cjs/Checkbox/index.js +1 -1
  23. package/lib/cjs/ColorPicker/index.js +2 -1
  24. package/lib/cjs/Date/index.d.ts +2 -2
  25. package/lib/cjs/DropdownMenu/index.js +1 -1
  26. package/lib/cjs/Input/index.d.ts +1 -1
  27. package/lib/cjs/LiveSearch/index.d.ts +2 -2
  28. package/lib/cjs/MultiFuncSelect/index.d.ts +2 -2
  29. package/lib/cjs/MultipleCheckboxes/index.d.ts +1 -1
  30. package/lib/cjs/MultipleCheckboxes/index.js +4 -2
  31. package/lib/cjs/MultipleSelect/index.js +2 -1
  32. package/lib/cjs/Radio/index.d.ts +1 -1
  33. package/lib/cjs/Table/index.d.ts +1 -1
  34. package/lib/cjs/Table/index.js +44 -11
  35. package/lib/cjs/TagInput/index.js +2 -1
  36. package/lib/cjs/Textarea/index.d.ts +1 -1
  37. package/lib/esm/CascadingSelect/index.tsx +1 -1
  38. package/lib/esm/CascadingSelectE2E/index.tsx +1 -1
  39. package/lib/esm/Checkbox/index.tsx +2 -2
  40. package/lib/esm/ColorPicker/index.tsx +1 -1
  41. package/lib/esm/Date/index.tsx +2 -2
  42. package/lib/esm/DropdownMenu/index.tsx +1 -1
  43. package/lib/esm/Input/index.tsx +1 -1
  44. package/lib/esm/LiveSearch/index.tsx +2 -2
  45. package/lib/esm/MultiFuncSelect/index.tsx +2 -2
  46. package/lib/esm/MultipleCheckboxes/index.tsx +3 -3
  47. package/lib/esm/MultipleSelect/index.tsx +1 -1
  48. package/lib/esm/Radio/index.tsx +1 -1
  49. package/lib/esm/Table/TableFieldRow.tsx +46 -17
  50. package/lib/esm/Table/TableHeaders.tsx +2 -2
  51. package/lib/esm/Table/TableRow.tsx +1 -1
  52. package/lib/esm/Table/index.tsx +10 -6
  53. package/lib/esm/TagInput/index.tsx +1 -1
  54. package/lib/esm/Textarea/index.tsx +1 -1
  55. package/package.json +1 -1
@@ -6,7 +6,7 @@ declare module 'react' {
6
6
  }
7
7
  declare type CascadingSelectOptionChangeFnType = (input: any, currentData: any, index: any, depth: any, value: any, closeFunc: any) => void;
8
8
  declare type CascadingSelectProps = {
9
- popupRef?: React.RefObject<any>;
9
+ popupRef?: React.ForwardedRef<any>;
10
10
  wrapperClassName?: string;
11
11
  controlClassName?: string;
12
12
  controlExClassName?: string;
@@ -15,7 +15,7 @@ interface fetchArrayConfig {
15
15
  doubleIndent?: boolean;
16
16
  }
17
17
  declare type CascadingSelectE2EProps = {
18
- popupRef?: React.RefObject<any>;
18
+ popupRef?: React.ForwardedRef<any>;
19
19
  wrapperClassName?: string;
20
20
  controlClassName?: string;
21
21
  controlExClassName?: string;
@@ -6,7 +6,7 @@ declare module 'react' {
6
6
  }
7
7
  declare type CheckboxOptionChangeFnType = (arg1: any, arg2: any) => void;
8
8
  declare type CheckboxProps = {
9
- contentRef?: React.RefObject<any>;
9
+ contentRef?: React.ForwardedRef<any>;
10
10
  wrapperClassName?: string;
11
11
  itemSelectedClassName?: string;
12
12
  value: string | boolean;
package/Checkbox/index.js CHANGED
@@ -225,7 +225,7 @@ var Checkbox = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
225
225
  onFocus: handleFocus,
226
226
  onBlur: handleBlur,
227
227
  defaultValue: value || '',
228
- checked: val // component status will not change if defaultChecked is used
228
+ checked: val || false // component status will not change if defaultChecked is used, // Avoid the error "react checkbox changing an uncontrolled input to be controlled"
229
229
  ,
230
230
  style: _objectSpread({
231
231
  cursor: 'pointer'
@@ -226,7 +226,8 @@ var ColorPicker = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)
226
226
  type: "hidden",
227
227
  id: idRes,
228
228
  name: name,
229
- value: changedVal,
229
+ value: changedVal // do not use `defaultValue`
230
+ ,
230
231
  required: required || null
231
232
  }, attributes)), changedVal !== '' ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("button", {
232
233
  tabIndex: -1,
package/Date/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  declare type DateProps = {
3
- contentRef?: React.RefObject<any>;
4
- popupRef?: React.RefObject<any>;
3
+ contentRef?: React.ForwardedRef<any>;
4
+ popupRef?: React.ForwardedRef<any>;
5
5
  popupClassName?: string;
6
6
  triggerClassName?: string;
7
7
  wrapperClassName?: string;
@@ -4287,7 +4287,7 @@ var DropdownMenu = function DropdownMenu(props) {
4287
4287
  name: name || '',
4288
4288
  type: "hidden",
4289
4289
  value: selected === null || selected === void 0 ? void 0 : selected.value
4290
- }), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((cjs_default()), {
4290
+ }), " ", /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((cjs_default()), {
4291
4291
  show: true,
4292
4292
  containerClassName: "DropdownMenu"
4293
4293
  }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
package/Input/index.d.ts CHANGED
@@ -5,7 +5,7 @@ declare module 'react' {
5
5
  }
6
6
  }
7
7
  declare type InputProps = {
8
- contentRef?: React.RefObject<any>;
8
+ contentRef?: React.ForwardedRef<any>;
9
9
  wrapperClassName?: string;
10
10
  controlClassName?: string;
11
11
  controlExClassName?: string;
@@ -7,8 +7,8 @@ interface OptionConfig {
7
7
  queryString: string | number;
8
8
  }
9
9
  declare type LiveSearchProps = {
10
- contentRef?: React.RefObject<any>;
11
- popupRef?: React.RefObject<any>;
10
+ contentRef?: React.ForwardedRef<any>;
11
+ popupRef?: React.ForwardedRef<any>;
12
12
  wrapperClassName?: string;
13
13
  controlClassName?: string;
14
14
  controlExClassName?: string;
@@ -33,8 +33,8 @@ interface CleanTriggerConfig {
33
33
  cleanValueLabel?: string;
34
34
  }
35
35
  declare type MultiFuncSelectProps = {
36
- contentRef?: React.RefObject<any>;
37
- popupRef?: React.RefObject<any>;
36
+ contentRef?: React.ForwardedRef<any>;
37
+ popupRef?: React.ForwardedRef<any>;
38
38
  wrapperClassName?: string;
39
39
  controlClassName?: string;
40
40
  controlExClassName?: string;
@@ -3,7 +3,7 @@ interface OptionConfig {
3
3
  [propName: string]: string | number | boolean;
4
4
  }
5
5
  declare type MultipleCheckboxesProps = {
6
- contentRef?: React.RefObject<any>;
6
+ contentRef?: React.ForwardedRef<any>;
7
7
  wrapperClassName?: string;
8
8
  tableLayout?: boolean;
9
9
  tableLayoutClassName?: string;
@@ -4247,7 +4247,8 @@ var MultipleCheckboxes = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forw
4247
4247
  type: "hidden",
4248
4248
  id: idRes,
4249
4249
  name: name,
4250
- value: VALUE_BY_BRACKETS ? (0,funda_utils__WEBPACK_IMPORTED_MODULE_1__.convertArrToValByBrackets)(valRes(selectedItems)) : valRes(selectedItems).join(','),
4250
+ value: VALUE_BY_BRACKETS ? (0,funda_utils__WEBPACK_IMPORTED_MODULE_1__.convertArrToValByBrackets)(valRes(selectedItems)) : valRes(selectedItems).join(',') // do not use `defaultValue`
4251
+ ,
4251
4252
  required: required || null
4252
4253
  }, attributes))))) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
4253
4254
  id: "multiple-checkboxes__wrapper-".concat(idRes),
@@ -4270,7 +4271,8 @@ var MultipleCheckboxes = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forw
4270
4271
  type: "hidden",
4271
4272
  id: idRes,
4272
4273
  name: name,
4273
- value: VALUE_BY_BRACKETS ? (0,funda_utils__WEBPACK_IMPORTED_MODULE_1__.convertArrToValByBrackets)(valRes(selectedItems)) : valRes(selectedItems).join(','),
4274
+ value: VALUE_BY_BRACKETS ? (0,funda_utils__WEBPACK_IMPORTED_MODULE_1__.convertArrToValByBrackets)(valRes(selectedItems)) : valRes(selectedItems).join(',') // do not use `defaultValue`
4275
+ ,
4274
4276
  required: required || null
4275
4277
  }, attributes))))));
4276
4278
  });
@@ -4143,7 +4143,8 @@ var MultipleSelect = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardR
4143
4143
  type: "hidden",
4144
4144
  id: idRes,
4145
4145
  name: name,
4146
- value: VALUE_BY_BRACKETS ? (0,funda_utils__WEBPACK_IMPORTED_MODULE_1__.convertArrToValByBrackets)(valSelected) : valSelected.join(','),
4146
+ value: VALUE_BY_BRACKETS ? (0,funda_utils__WEBPACK_IMPORTED_MODULE_1__.convertArrToValByBrackets)(valSelected) : valSelected.join(',') // do not use `defaultValue`
4147
+ ,
4147
4148
  required: required || null
4148
4149
  }, attributes)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
4149
4150
  className: "m-select-inner"
package/Radio/index.d.ts CHANGED
@@ -9,7 +9,7 @@ interface OptionConfig {
9
9
  }
10
10
  declare type RadioOptionChangeFnType = (arg1: any, arg2: any, arg3?: any, arg4?: any) => void;
11
11
  declare type RadioProps = {
12
- contentRef?: React.RefObject<any>;
12
+ contentRef?: React.ForwardedRef<any>;
13
13
  wrapperClassName?: string;
14
14
  groupWrapperClassName?: string;
15
15
  groupLabelClassName?: string;
package/Table/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  declare type TableProps = {
3
- tableCheckRef?: React.RefObject<any>;
3
+ tableCheckRef?: React.ForwardedRef<any>;
4
4
  wrapperClassName?: string;
5
5
  tableClassName?: string;
6
6
  bodyClassName?: string;
package/Table/index.js CHANGED
@@ -3975,7 +3975,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
3975
3975
  -------------------------------------------------*/
3976
3976
 
3977
3977
  var TableFieldRow = function TableFieldRow(props) {
3978
- var _latestCheckedData$fi;
3978
+ var _latestCheckedData$fi3;
3979
3979
  var tableRootRef = props.tableRootRef,
3980
3980
  tableCheckRef = props.tableCheckRef,
3981
3981
  _props$rowActiveClass = props.rowActiveClassName,
@@ -4012,6 +4012,10 @@ var TableFieldRow = function TableFieldRow(props) {
4012
4012
  _useState2 = _slicedToArray(_useState, 2),
4013
4013
  firstInitCheckboxes = _useState2[0],
4014
4014
  setFirstInitCheckboxes = _useState2[1];
4015
+ var _useState3 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(null),
4016
+ _useState4 = _slicedToArray(_useState3, 2),
4017
+ checkboxDefaultVal = _useState4[0],
4018
+ setCheckboxDefaultVal = _useState4[1];
4015
4019
 
4016
4020
  //
4017
4021
  var _ref = fieldsCheckedAct || [null, null],
@@ -4106,8 +4110,9 @@ var TableFieldRow = function TableFieldRow(props) {
4106
4110
  if (typeof rowKey !== 'undefined' && typeof getCheckedData !== 'undefined') setCheckboxCheckedData(getCheckedData, rowKey, fieldsChecked[Number(rowIndex)]);
4107
4111
  // Update checked data
4108
4112
  updategetCheckedData(_checkedData);
4109
- setFirstInitCheckboxes(true);
4110
4113
  updateFirstInitCheckboxesClassName(true);
4114
+ //
4115
+ setFirstInitCheckboxes(true);
4111
4116
  return _checkedData;
4112
4117
  } else {
4113
4118
  return getCheckedData;
@@ -4214,6 +4219,14 @@ var TableFieldRow = function TableFieldRow(props) {
4214
4219
  var _e$target$closest;
4215
4220
  (_e$target$closest = e.target.closest('table')) === null || _e$target$closest === void 0 ? void 0 : _e$target$closest.querySelector('tbody').classList.add('drag-trigger-mousedown');
4216
4221
  }
4222
+
4223
+ // to aviod `Warning: Cannot update a component (ComponentName) while rendering a different component`
4224
+ (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
4225
+ var _latestCheckedData$fi;
4226
+ setCheckboxDefaultVal(((_latestCheckedData$fi = latestCheckedData().filter(function (cur) {
4227
+ return cur.key === rowKey;
4228
+ })[0]) === null || _latestCheckedData$fi === void 0 ? void 0 : _latestCheckedData$fi.checked) || false); // Avoid the error "react checkbox changing an uncontrolled input to be controlled"
4229
+ }, []);
4217
4230
  return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, null, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("th", {
4218
4231
  scope: "row",
4219
4232
  colSpan: cols,
@@ -4348,7 +4361,7 @@ var TableFieldRow = function TableFieldRow(props) {
4348
4361
  className: "form-check__wrapper"
4349
4362
  }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
4350
4363
  className: "form-check d-inline-block"
4351
- }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("input", {
4364
+ }, checkboxDefaultVal === null ? /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, null, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("input", {
4352
4365
  type: "checkbox",
4353
4366
  className: "form-check-input",
4354
4367
  name: "checkbox-".concat(checkboxNamePrefix, "-").concat(rowIndex),
@@ -4357,17 +4370,34 @@ var TableFieldRow = function TableFieldRow(props) {
4357
4370
  "data-index": "".concat(rowIndex),
4358
4371
  "data-key": "".concat(rowKey),
4359
4372
  "data-use": dataUse,
4360
- value: "".concat(rowKey),
4361
- checked: (_latestCheckedData$fi = latestCheckedData().filter(function (cur) {
4362
- return cur.key === rowKey;
4363
- })[0]) === null || _latestCheckedData$fi === void 0 ? void 0 : _latestCheckedData$fi.checked,
4373
+ defaultValue: "".concat(rowKey),
4374
+ checked: checkboxDefaultVal !== null ? checkboxDefaultVal : false,
4364
4375
  onChange: function onChange(e) {
4365
4376
  var _latestCheckedData$fi2;
4366
4377
  checkedAct(e.target, !((_latestCheckedData$fi2 = latestCheckedData().filter(function (cur) {
4367
4378
  return cur.key === rowKey;
4368
4379
  })[0]) !== null && _latestCheckedData$fi2 !== void 0 && _latestCheckedData$fi2.checked));
4369
4380
  }
4370
- }))))), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
4381
+ })) : /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, null, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("input", {
4382
+ type: "checkbox",
4383
+ className: "form-check-input",
4384
+ name: "checkbox-".concat(checkboxNamePrefix, "-").concat(rowIndex),
4385
+ ref: checkboxRef,
4386
+ tabIndex: -1,
4387
+ "data-index": "".concat(rowIndex),
4388
+ "data-key": "".concat(rowKey),
4389
+ "data-use": dataUse,
4390
+ defaultValue: "".concat(rowKey),
4391
+ checked: (_latestCheckedData$fi3 = latestCheckedData().filter(function (cur) {
4392
+ return cur.key === rowKey;
4393
+ })[0]) === null || _latestCheckedData$fi3 === void 0 ? void 0 : _latestCheckedData$fi3.checked,
4394
+ onChange: function onChange(e) {
4395
+ var _latestCheckedData$fi4;
4396
+ checkedAct(e.target, !((_latestCheckedData$fi4 = latestCheckedData().filter(function (cur) {
4397
+ return cur.key === rowKey;
4398
+ })[0]) !== null && _latestCheckedData$fi4 !== void 0 && _latestCheckedData$fi4.checked));
4399
+ }
4400
+ })))))), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
4371
4401
  ref: contentRef
4372
4402
  }, content)));
4373
4403
  };
@@ -4735,10 +4765,11 @@ var TableHeaders = function TableHeaders(props) {
4735
4765
  "data-index": -1,
4736
4766
  "data-key": "row-all",
4737
4767
  "data-use": "",
4738
- value: "row-all",
4739
- checked: (_filter$ = getCheckedRootData.filter(function (cur) {
4768
+ defaultValue: "row-all",
4769
+ checked: ((_filter$ = getCheckedRootData.filter(function (cur) {
4740
4770
  return cur.key === 'row-all';
4741
- })[0]) === null || _filter$ === void 0 ? void 0 : _filter$.checked,
4771
+ })[0]) === null || _filter$ === void 0 ? void 0 : _filter$.checked) || false // Avoid the error "react checkbox changing an uncontrolled input to be controlled"
4772
+ ,
4742
4773
  onChange: function onChange(e) {
4743
4774
  var _filter$2;
4744
4775
  checkedAct(e.target, !((_filter$2 = getCheckedRootData.filter(function (cur) {
@@ -4950,6 +4981,7 @@ var Table = function Table(props) {
4950
4981
  existingNode.parentNode.insertBefore(newNode, existingNode.nextSibling);
4951
4982
  };
4952
4983
  var allRows = function allRows() {
4984
+ if (tbodyRef.current === null) return [];
4953
4985
  return [].slice.call(tbodyRef.current.children);
4954
4986
  };
4955
4987
  var printData = function printData(data) {
@@ -5025,6 +5057,7 @@ var Table = function Table(props) {
5025
5057
  // checkboxes data
5026
5058
  // ================================================================
5027
5059
  function initCheckboxesData() {
5060
+ if (rootRef.current === null) return;
5028
5061
  var _checkboxes = (0,cjs.getChildren)(rootRef.current.querySelector('table').querySelector('tbody'), '[type="checkbox"]');
5029
5062
  var _data = [];
5030
5063
  [].slice.call(_checkboxes).forEach(function (node, i) {
package/TagInput/index.js CHANGED
@@ -4087,7 +4087,8 @@ var TagInput = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
4087
4087
  return item.content;
4088
4088
  })) : items.map(function (item) {
4089
4089
  return item.content;
4090
- }).join(','),
4090
+ }).join(',') // do not use `defaultValue`
4091
+ ,
4091
4092
  required: required || null
4092
4093
  }))));
4093
4094
  });
@@ -5,7 +5,7 @@ declare module 'react' {
5
5
  }
6
6
  }
7
7
  declare type TextareaProps = {
8
- contentRef?: React.RefObject<any>;
8
+ contentRef?: React.ForwardedRef<any>;
9
9
  wrapperClassName?: string;
10
10
  controlClassName?: string;
11
11
  controlExClassName?: string;
@@ -6,7 +6,7 @@ declare module 'react' {
6
6
  }
7
7
  declare type CascadingSelectOptionChangeFnType = (input: any, currentData: any, index: any, depth: any, value: any, closeFunc: any) => void;
8
8
  declare type CascadingSelectProps = {
9
- popupRef?: React.RefObject<any>;
9
+ popupRef?: React.ForwardedRef<any>;
10
10
  wrapperClassName?: string;
11
11
  controlClassName?: string;
12
12
  controlExClassName?: string;
@@ -15,7 +15,7 @@ interface fetchArrayConfig {
15
15
  doubleIndent?: boolean;
16
16
  }
17
17
  declare type CascadingSelectE2EProps = {
18
- popupRef?: React.RefObject<any>;
18
+ popupRef?: React.ForwardedRef<any>;
19
19
  wrapperClassName?: string;
20
20
  controlClassName?: string;
21
21
  controlExClassName?: string;
@@ -6,7 +6,7 @@ declare module 'react' {
6
6
  }
7
7
  declare type CheckboxOptionChangeFnType = (arg1: any, arg2: any) => void;
8
8
  declare type CheckboxProps = {
9
- contentRef?: React.RefObject<any>;
9
+ contentRef?: React.ForwardedRef<any>;
10
10
  wrapperClassName?: string;
11
11
  itemSelectedClassName?: string;
12
12
  value: string | boolean;
@@ -225,7 +225,7 @@ var Checkbox = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
225
225
  onFocus: handleFocus,
226
226
  onBlur: handleBlur,
227
227
  defaultValue: value || '',
228
- checked: val // component status will not change if defaultChecked is used
228
+ checked: val || false // component status will not change if defaultChecked is used, // Avoid the error "react checkbox changing an uncontrolled input to be controlled"
229
229
  ,
230
230
  style: _objectSpread({
231
231
  cursor: 'pointer'
@@ -226,7 +226,8 @@ var ColorPicker = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)
226
226
  type: "hidden",
227
227
  id: idRes,
228
228
  name: name,
229
- value: changedVal,
229
+ value: changedVal // do not use `defaultValue`
230
+ ,
230
231
  required: required || null
231
232
  }, attributes)), changedVal !== '' ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("button", {
232
233
  tabIndex: -1,
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  declare type DateProps = {
3
- contentRef?: React.RefObject<any>;
4
- popupRef?: React.RefObject<any>;
3
+ contentRef?: React.ForwardedRef<any>;
4
+ popupRef?: React.ForwardedRef<any>;
5
5
  popupClassName?: string;
6
6
  triggerClassName?: string;
7
7
  wrapperClassName?: string;
@@ -4287,7 +4287,7 @@ var DropdownMenu = function DropdownMenu(props) {
4287
4287
  name: name || '',
4288
4288
  type: "hidden",
4289
4289
  value: selected === null || selected === void 0 ? void 0 : selected.value
4290
- }), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((cjs_default()), {
4290
+ }), " ", /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((cjs_default()), {
4291
4291
  show: true,
4292
4292
  containerClassName: "DropdownMenu"
4293
4293
  }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
@@ -5,7 +5,7 @@ declare module 'react' {
5
5
  }
6
6
  }
7
7
  declare type InputProps = {
8
- contentRef?: React.RefObject<any>;
8
+ contentRef?: React.ForwardedRef<any>;
9
9
  wrapperClassName?: string;
10
10
  controlClassName?: string;
11
11
  controlExClassName?: string;
@@ -7,8 +7,8 @@ interface OptionConfig {
7
7
  queryString: string | number;
8
8
  }
9
9
  declare type LiveSearchProps = {
10
- contentRef?: React.RefObject<any>;
11
- popupRef?: React.RefObject<any>;
10
+ contentRef?: React.ForwardedRef<any>;
11
+ popupRef?: React.ForwardedRef<any>;
12
12
  wrapperClassName?: string;
13
13
  controlClassName?: string;
14
14
  controlExClassName?: string;
@@ -33,8 +33,8 @@ interface CleanTriggerConfig {
33
33
  cleanValueLabel?: string;
34
34
  }
35
35
  declare type MultiFuncSelectProps = {
36
- contentRef?: React.RefObject<any>;
37
- popupRef?: React.RefObject<any>;
36
+ contentRef?: React.ForwardedRef<any>;
37
+ popupRef?: React.ForwardedRef<any>;
38
38
  wrapperClassName?: string;
39
39
  controlClassName?: string;
40
40
  controlExClassName?: string;
@@ -3,7 +3,7 @@ interface OptionConfig {
3
3
  [propName: string]: string | number | boolean;
4
4
  }
5
5
  declare type MultipleCheckboxesProps = {
6
- contentRef?: React.RefObject<any>;
6
+ contentRef?: React.ForwardedRef<any>;
7
7
  wrapperClassName?: string;
8
8
  tableLayout?: boolean;
9
9
  tableLayoutClassName?: string;
@@ -4247,7 +4247,8 @@ var MultipleCheckboxes = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forw
4247
4247
  type: "hidden",
4248
4248
  id: idRes,
4249
4249
  name: name,
4250
- value: VALUE_BY_BRACKETS ? (0,funda_utils__WEBPACK_IMPORTED_MODULE_1__.convertArrToValByBrackets)(valRes(selectedItems)) : valRes(selectedItems).join(','),
4250
+ value: VALUE_BY_BRACKETS ? (0,funda_utils__WEBPACK_IMPORTED_MODULE_1__.convertArrToValByBrackets)(valRes(selectedItems)) : valRes(selectedItems).join(',') // do not use `defaultValue`
4251
+ ,
4251
4252
  required: required || null
4252
4253
  }, attributes))))) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
4253
4254
  id: "multiple-checkboxes__wrapper-".concat(idRes),
@@ -4270,7 +4271,8 @@ var MultipleCheckboxes = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forw
4270
4271
  type: "hidden",
4271
4272
  id: idRes,
4272
4273
  name: name,
4273
- value: VALUE_BY_BRACKETS ? (0,funda_utils__WEBPACK_IMPORTED_MODULE_1__.convertArrToValByBrackets)(valRes(selectedItems)) : valRes(selectedItems).join(','),
4274
+ value: VALUE_BY_BRACKETS ? (0,funda_utils__WEBPACK_IMPORTED_MODULE_1__.convertArrToValByBrackets)(valRes(selectedItems)) : valRes(selectedItems).join(',') // do not use `defaultValue`
4275
+ ,
4274
4276
  required: required || null
4275
4277
  }, attributes))))));
4276
4278
  });
@@ -4143,7 +4143,8 @@ var MultipleSelect = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardR
4143
4143
  type: "hidden",
4144
4144
  id: idRes,
4145
4145
  name: name,
4146
- value: VALUE_BY_BRACKETS ? (0,funda_utils__WEBPACK_IMPORTED_MODULE_1__.convertArrToValByBrackets)(valSelected) : valSelected.join(','),
4146
+ value: VALUE_BY_BRACKETS ? (0,funda_utils__WEBPACK_IMPORTED_MODULE_1__.convertArrToValByBrackets)(valSelected) : valSelected.join(',') // do not use `defaultValue`
4147
+ ,
4147
4148
  required: required || null
4148
4149
  }, attributes)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
4149
4150
  className: "m-select-inner"
@@ -9,7 +9,7 @@ interface OptionConfig {
9
9
  }
10
10
  declare type RadioOptionChangeFnType = (arg1: any, arg2: any, arg3?: any, arg4?: any) => void;
11
11
  declare type RadioProps = {
12
- contentRef?: React.RefObject<any>;
12
+ contentRef?: React.ForwardedRef<any>;
13
13
  wrapperClassName?: string;
14
14
  groupWrapperClassName?: string;
15
15
  groupLabelClassName?: string;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  declare type TableProps = {
3
- tableCheckRef?: React.RefObject<any>;
3
+ tableCheckRef?: React.ForwardedRef<any>;
4
4
  wrapperClassName?: string;
5
5
  tableClassName?: string;
6
6
  bodyClassName?: string;
@@ -3975,7 +3975,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
3975
3975
  -------------------------------------------------*/
3976
3976
 
3977
3977
  var TableFieldRow = function TableFieldRow(props) {
3978
- var _latestCheckedData$fi;
3978
+ var _latestCheckedData$fi3;
3979
3979
  var tableRootRef = props.tableRootRef,
3980
3980
  tableCheckRef = props.tableCheckRef,
3981
3981
  _props$rowActiveClass = props.rowActiveClassName,
@@ -4012,6 +4012,10 @@ var TableFieldRow = function TableFieldRow(props) {
4012
4012
  _useState2 = _slicedToArray(_useState, 2),
4013
4013
  firstInitCheckboxes = _useState2[0],
4014
4014
  setFirstInitCheckboxes = _useState2[1];
4015
+ var _useState3 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(null),
4016
+ _useState4 = _slicedToArray(_useState3, 2),
4017
+ checkboxDefaultVal = _useState4[0],
4018
+ setCheckboxDefaultVal = _useState4[1];
4015
4019
 
4016
4020
  //
4017
4021
  var _ref = fieldsCheckedAct || [null, null],
@@ -4106,8 +4110,9 @@ var TableFieldRow = function TableFieldRow(props) {
4106
4110
  if (typeof rowKey !== 'undefined' && typeof getCheckedData !== 'undefined') setCheckboxCheckedData(getCheckedData, rowKey, fieldsChecked[Number(rowIndex)]);
4107
4111
  // Update checked data
4108
4112
  updategetCheckedData(_checkedData);
4109
- setFirstInitCheckboxes(true);
4110
4113
  updateFirstInitCheckboxesClassName(true);
4114
+ //
4115
+ setFirstInitCheckboxes(true);
4111
4116
  return _checkedData;
4112
4117
  } else {
4113
4118
  return getCheckedData;
@@ -4214,6 +4219,14 @@ var TableFieldRow = function TableFieldRow(props) {
4214
4219
  var _e$target$closest;
4215
4220
  (_e$target$closest = e.target.closest('table')) === null || _e$target$closest === void 0 ? void 0 : _e$target$closest.querySelector('tbody').classList.add('drag-trigger-mousedown');
4216
4221
  }
4222
+
4223
+ // to aviod `Warning: Cannot update a component (ComponentName) while rendering a different component`
4224
+ (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
4225
+ var _latestCheckedData$fi;
4226
+ setCheckboxDefaultVal(((_latestCheckedData$fi = latestCheckedData().filter(function (cur) {
4227
+ return cur.key === rowKey;
4228
+ })[0]) === null || _latestCheckedData$fi === void 0 ? void 0 : _latestCheckedData$fi.checked) || false); // Avoid the error "react checkbox changing an uncontrolled input to be controlled"
4229
+ }, []);
4217
4230
  return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, null, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("th", {
4218
4231
  scope: "row",
4219
4232
  colSpan: cols,
@@ -4348,7 +4361,7 @@ var TableFieldRow = function TableFieldRow(props) {
4348
4361
  className: "form-check__wrapper"
4349
4362
  }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
4350
4363
  className: "form-check d-inline-block"
4351
- }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("input", {
4364
+ }, checkboxDefaultVal === null ? /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, null, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("input", {
4352
4365
  type: "checkbox",
4353
4366
  className: "form-check-input",
4354
4367
  name: "checkbox-".concat(checkboxNamePrefix, "-").concat(rowIndex),
@@ -4357,17 +4370,34 @@ var TableFieldRow = function TableFieldRow(props) {
4357
4370
  "data-index": "".concat(rowIndex),
4358
4371
  "data-key": "".concat(rowKey),
4359
4372
  "data-use": dataUse,
4360
- value: "".concat(rowKey),
4361
- checked: (_latestCheckedData$fi = latestCheckedData().filter(function (cur) {
4362
- return cur.key === rowKey;
4363
- })[0]) === null || _latestCheckedData$fi === void 0 ? void 0 : _latestCheckedData$fi.checked,
4373
+ defaultValue: "".concat(rowKey),
4374
+ checked: checkboxDefaultVal !== null ? checkboxDefaultVal : false,
4364
4375
  onChange: function onChange(e) {
4365
4376
  var _latestCheckedData$fi2;
4366
4377
  checkedAct(e.target, !((_latestCheckedData$fi2 = latestCheckedData().filter(function (cur) {
4367
4378
  return cur.key === rowKey;
4368
4379
  })[0]) !== null && _latestCheckedData$fi2 !== void 0 && _latestCheckedData$fi2.checked));
4369
4380
  }
4370
- }))))), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
4381
+ })) : /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, null, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("input", {
4382
+ type: "checkbox",
4383
+ className: "form-check-input",
4384
+ name: "checkbox-".concat(checkboxNamePrefix, "-").concat(rowIndex),
4385
+ ref: checkboxRef,
4386
+ tabIndex: -1,
4387
+ "data-index": "".concat(rowIndex),
4388
+ "data-key": "".concat(rowKey),
4389
+ "data-use": dataUse,
4390
+ defaultValue: "".concat(rowKey),
4391
+ checked: (_latestCheckedData$fi3 = latestCheckedData().filter(function (cur) {
4392
+ return cur.key === rowKey;
4393
+ })[0]) === null || _latestCheckedData$fi3 === void 0 ? void 0 : _latestCheckedData$fi3.checked,
4394
+ onChange: function onChange(e) {
4395
+ var _latestCheckedData$fi4;
4396
+ checkedAct(e.target, !((_latestCheckedData$fi4 = latestCheckedData().filter(function (cur) {
4397
+ return cur.key === rowKey;
4398
+ })[0]) !== null && _latestCheckedData$fi4 !== void 0 && _latestCheckedData$fi4.checked));
4399
+ }
4400
+ })))))), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
4371
4401
  ref: contentRef
4372
4402
  }, content)));
4373
4403
  };
@@ -4735,10 +4765,11 @@ var TableHeaders = function TableHeaders(props) {
4735
4765
  "data-index": -1,
4736
4766
  "data-key": "row-all",
4737
4767
  "data-use": "",
4738
- value: "row-all",
4739
- checked: (_filter$ = getCheckedRootData.filter(function (cur) {
4768
+ defaultValue: "row-all",
4769
+ checked: ((_filter$ = getCheckedRootData.filter(function (cur) {
4740
4770
  return cur.key === 'row-all';
4741
- })[0]) === null || _filter$ === void 0 ? void 0 : _filter$.checked,
4771
+ })[0]) === null || _filter$ === void 0 ? void 0 : _filter$.checked) || false // Avoid the error "react checkbox changing an uncontrolled input to be controlled"
4772
+ ,
4742
4773
  onChange: function onChange(e) {
4743
4774
  var _filter$2;
4744
4775
  checkedAct(e.target, !((_filter$2 = getCheckedRootData.filter(function (cur) {
@@ -4950,6 +4981,7 @@ var Table = function Table(props) {
4950
4981
  existingNode.parentNode.insertBefore(newNode, existingNode.nextSibling);
4951
4982
  };
4952
4983
  var allRows = function allRows() {
4984
+ if (tbodyRef.current === null) return [];
4953
4985
  return [].slice.call(tbodyRef.current.children);
4954
4986
  };
4955
4987
  var printData = function printData(data) {
@@ -5025,6 +5057,7 @@ var Table = function Table(props) {
5025
5057
  // checkboxes data
5026
5058
  // ================================================================
5027
5059
  function initCheckboxesData() {
5060
+ if (rootRef.current === null) return;
5028
5061
  var _checkboxes = (0,cjs.getChildren)(rootRef.current.querySelector('table').querySelector('tbody'), '[type="checkbox"]');
5029
5062
  var _data = [];
5030
5063
  [].slice.call(_checkboxes).forEach(function (node, i) {
@@ -4087,7 +4087,8 @@ var TagInput = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
4087
4087
  return item.content;
4088
4088
  })) : items.map(function (item) {
4089
4089
  return item.content;
4090
- }).join(','),
4090
+ }).join(',') // do not use `defaultValue`
4091
+ ,
4091
4092
  required: required || null
4092
4093
  }))));
4093
4094
  });
@@ -5,7 +5,7 @@ declare module 'react' {
5
5
  }
6
6
  }
7
7
  declare type TextareaProps = {
8
- contentRef?: React.RefObject<any>;
8
+ contentRef?: React.ForwardedRef<any>;
9
9
  wrapperClassName?: string;
10
10
  controlClassName?: string;
11
11
  controlExClassName?: string;
@@ -25,7 +25,7 @@ type CascadingSelectOptionChangeFnType = (input: any, currentData: any, index: a
25
25
 
26
26
 
27
27
  type CascadingSelectProps = {
28
- popupRef?: React.RefObject<any>;
28
+ popupRef?: React.ForwardedRef<any>; // could use "Array" on popupRef.current, such as popupRef.current[0], popupRef.current[1]
29
29
  wrapperClassName?: string;
30
30
  controlClassName?: string;
31
31
  controlExClassName?: string;
@@ -40,7 +40,7 @@ interface fetchArrayConfig {
40
40
  }
41
41
 
42
42
  type CascadingSelectE2EProps = {
43
- popupRef?: React.RefObject<any>;
43
+ popupRef?: React.ForwardedRef<any>; // could use "Array" on popupRef.current, such as popupRef.current[0], popupRef.current[1]
44
44
  wrapperClassName?: string;
45
45
  controlClassName?: string;
46
46
  controlExClassName?: string;
@@ -10,7 +10,7 @@ type CheckboxOptionChangeFnType = (arg1: any, arg2: any) => void;
10
10
 
11
11
 
12
12
  type CheckboxProps = {
13
- contentRef?: React.RefObject<any>;
13
+ contentRef?: React.ForwardedRef<any>; // could use "Array" on contentRef.current, such as contentRef.current[0], contentRef.current[1]
14
14
  wrapperClassName?: string;
15
15
  itemSelectedClassName?: string;
16
16
  value: string | boolean;
@@ -162,7 +162,7 @@ const Checkbox = forwardRef((props: CheckboxProps, externalRef: any) => {
162
162
  onFocus={handleFocus}
163
163
  onBlur={handleBlur}
164
164
  defaultValue={value as string || ''}
165
- checked={val} // component status will not change if defaultChecked is used
165
+ checked={val || false} // component status will not change if defaultChecked is used, // Avoid the error "react checkbox changing an uncontrolled input to be controlled"
166
166
  style={{ cursor: 'pointer', ...style }}
167
167
  {...attributes}
168
168
  />
@@ -163,7 +163,7 @@ const ColorPicker = forwardRef((props: ColorPickerProps, externalRef: any) => {
163
163
  type="hidden"
164
164
  id={idRes}
165
165
  name={name}
166
- value={changedVal}
166
+ value={changedVal} // do not use `defaultValue`
167
167
  required={required || null}
168
168
  {...attributes}
169
169
  />
@@ -37,8 +37,8 @@ import i18n__zh_CN from './localization/zh_CN';
37
37
 
38
38
 
39
39
  type DateProps = {
40
- contentRef?: React.RefObject<any>;
41
- popupRef?: React.RefObject<any>;
40
+ contentRef?: React.ForwardedRef<any>; // could use "Array" on contentRef.current, such as contentRef.current[0], contentRef.current[1]
41
+ popupRef?: React.ForwardedRef<any>; // could use "Array" on popupRef.current, such as popupRef.current[0], popupRef.current[1]
42
42
  popupClassName?: string;
43
43
  triggerClassName?: string;
44
44
  wrapperClassName?: string;
@@ -313,7 +313,7 @@ const DropdownMenu = (props: DropdownMenuProps) => {
313
313
 
314
314
 
315
315
  {/* INPUT */}
316
- <input name={name || ''} type="hidden" value={selected?.value} />
316
+ <input name={name || ''} type="hidden" value={selected?.value} /> {/* // do not use `defaultValue` */}
317
317
  {/* /INPUT */}
318
318
 
319
319
  {/* MENU LIST */}
@@ -7,7 +7,7 @@ declare module 'react' {
7
7
  }
8
8
 
9
9
  type InputProps = {
10
- contentRef?: React.RefObject<any>;
10
+ contentRef?: React.ForwardedRef<any>;
11
11
  wrapperClassName?: string;
12
12
  controlClassName?: string;
13
13
  controlExClassName?: string;
@@ -23,8 +23,8 @@ interface OptionConfig {
23
23
 
24
24
 
25
25
  type LiveSearchProps = {
26
- contentRef?: React.RefObject<any>;
27
- popupRef?: React.RefObject<any>;
26
+ contentRef?: React.ForwardedRef<any>; // could use "Array" on contentRef.current, such as contentRef.current[0], contentRef.current[1]
27
+ popupRef?: React.ForwardedRef<any>; // could use "Array" on popupRef.current, such as popupRef.current[0], popupRef.current[1]
28
28
  wrapperClassName?: string;
29
29
  controlClassName?: string;
30
30
  controlExClassName?: string;
@@ -67,8 +67,8 @@ interface CleanTriggerConfig {
67
67
 
68
68
 
69
69
  type MultiFuncSelectProps = {
70
- contentRef?: React.RefObject<any>;
71
- popupRef?: React.RefObject<any>;
70
+ contentRef?: React.ForwardedRef<any>; // could use "Array" on contentRef.current, such as contentRef.current[0], contentRef.current[1]
71
+ popupRef?: React.ForwardedRef<any>; // could use "Array" on popupRef.current, such as popupRef.current[0], popupRef.current[1]
72
72
  wrapperClassName?: string;
73
73
  controlClassName?: string;
74
74
  controlExClassName?: string;
@@ -14,7 +14,7 @@ interface OptionConfig {
14
14
 
15
15
 
16
16
  type MultipleCheckboxesProps = {
17
- contentRef?: React.RefObject<any>;
17
+ contentRef?: React.ForwardedRef<any>; // could use "Array" on contentRef.current, such as contentRef.current[0], contentRef.current[1]
18
18
  wrapperClassName?: string;
19
19
  tableLayout?: boolean;
20
20
  tableLayoutClassName?: string;
@@ -517,7 +517,7 @@ const MultipleCheckboxes = forwardRef((props: MultipleCheckboxesProps, externalR
517
517
  type="hidden"
518
518
  id={idRes}
519
519
  name={name}
520
- value={VALUE_BY_BRACKETS ? convertArrToValByBrackets(valRes(selectedItems)) : valRes(selectedItems).join(',')}
520
+ value={VALUE_BY_BRACKETS ? convertArrToValByBrackets(valRes(selectedItems)) : valRes(selectedItems).join(',')} // do not use `defaultValue`
521
521
  required={required || null}
522
522
  {...attributes}
523
523
  />
@@ -545,7 +545,7 @@ const MultipleCheckboxes = forwardRef((props: MultipleCheckboxesProps, externalR
545
545
  type="hidden"
546
546
  id={idRes}
547
547
  name={name}
548
- value={VALUE_BY_BRACKETS ? convertArrToValByBrackets(valRes(selectedItems)) : valRes(selectedItems).join(',')}
548
+ value={VALUE_BY_BRACKETS ? convertArrToValByBrackets(valRes(selectedItems)) : valRes(selectedItems).join(',')} // do not use `defaultValue`
549
549
  required={required || null}
550
550
  {...attributes}
551
551
  />
@@ -415,7 +415,7 @@ const MultipleSelect = forwardRef((props: MultipleSelectProps, externalRef: any)
415
415
  type="hidden"
416
416
  id={idRes}
417
417
  name={name}
418
- value={VALUE_BY_BRACKETS ? convertArrToValByBrackets(valSelected) : valSelected.join(',')}
418
+ value={VALUE_BY_BRACKETS ? convertArrToValByBrackets(valSelected) : valSelected.join(',')} // do not use `defaultValue`
419
419
  required={required || null}
420
420
  {...attributes}
421
421
  />
@@ -22,7 +22,7 @@ type RadioOptionChangeFnType = (arg1: any, arg2: any, arg3?: any, arg4?: any) =>
22
22
 
23
23
 
24
24
  type RadioProps = {
25
- contentRef?: React.RefObject<any>;
25
+ contentRef?: React.ForwardedRef<any>; // could use "Array" on contentRef.current, such as contentRef.current[0], contentRef.current[1]
26
26
  wrapperClassName?: string;
27
27
  groupWrapperClassName?: string;
28
28
  groupLabelClassName?: string;
@@ -1,4 +1,4 @@
1
- import React, { useRef, useState, useImperativeHandle } from 'react';
1
+ import React, { useEffect, useRef, useState, useImperativeHandle } from 'react';
2
2
 
3
3
  // HAS CHECKBOX
4
4
 
@@ -15,7 +15,7 @@ import { removeItemOnce, formatCheckboxControlVal, setCheckboxCheckedData, forma
15
15
  -------------------------------------------------*/
16
16
  type TableFieldRowProps = {
17
17
  tableRootRef: React.RefObject<any>;
18
- tableCheckRef?: React.RefObject<any>;
18
+ tableCheckRef?: React.ForwardedRef<any>; // could use "Array" on tableCheckRef.current, such as tableCheckRef.current[0], tableCheckRef.current[1]
19
19
  rowActiveClassName?: string;
20
20
  fieldsChecked?: boolean[] | boolean;
21
21
  fieldsCheckedAct?: any[];
@@ -82,6 +82,9 @@ const TableFieldRow = (props: TableFieldRowProps) => {
82
82
  const contentRef = useRef<any>(null);
83
83
  const checkboxRef = useRef<any>(null);
84
84
  const [firstInitCheckboxes, setFirstInitCheckboxes] = useState<boolean>(false);
85
+ const [checkboxDefaultVal, setCheckboxDefaultVal] = useState<null | boolean>(null);
86
+
87
+
85
88
 
86
89
  //
87
90
  const [fieldsCheckedUpdateDataPrint, setFieldsCheckedUpdateDataPrint] = fieldsCheckedAct || [null, null];
@@ -188,8 +191,10 @@ const TableFieldRow = (props: TableFieldRowProps) => {
188
191
  if (typeof rowKey !== 'undefined' && typeof getCheckedData !== 'undefined') setCheckboxCheckedData(getCheckedData, rowKey, fieldsChecked[Number(rowIndex)]);
189
192
  // Update checked data
190
193
  updategetCheckedData(_checkedData);
191
- setFirstInitCheckboxes(true);
192
194
  updateFirstInitCheckboxesClassName(true);
195
+ //
196
+ setFirstInitCheckboxes(true);
197
+
193
198
 
194
199
  return _checkedData;
195
200
  } else {
@@ -320,6 +325,11 @@ const TableFieldRow = (props: TableFieldRowProps) => {
320
325
  }
321
326
 
322
327
 
328
+ // to aviod `Warning: Cannot update a component (ComponentName) while rendering a different component`
329
+ useEffect(() => {
330
+ setCheckboxDefaultVal(latestCheckedData().filter((cur: any) => cur.key === rowKey)[0]?.checked || false); // Avoid the error "react checkbox changing an uncontrolled input to be controlled"
331
+ }, []);
332
+
323
333
 
324
334
  return (
325
335
  <>
@@ -431,21 +441,40 @@ const TableFieldRow = (props: TableFieldRowProps) => {
431
441
 
432
442
  <div className="form-check__wrapper">
433
443
  <div className="form-check d-inline-block">
444
+ {checkboxDefaultVal === null ? <>
445
+ <input
446
+ type="checkbox"
447
+ className="form-check-input"
448
+ name={`checkbox-${checkboxNamePrefix}-${rowIndex}`}
449
+ ref={checkboxRef}
450
+ tabIndex={-1}
451
+ data-index={`${rowIndex}`}
452
+ data-key={`${rowKey}`}
453
+ data-use={dataUse}
454
+ defaultValue={`${rowKey}`}
455
+ checked={checkboxDefaultVal !== null ? checkboxDefaultVal : false}
456
+ onChange={(e: any) => {
457
+ checkedAct(e.target, !latestCheckedData().filter((cur: any) => cur.key === rowKey)[0]?.checked);
458
+ }}
459
+ />
460
+ </> : <>
434
461
  <input
435
- type="checkbox"
436
- className="form-check-input"
437
- name={`checkbox-${checkboxNamePrefix}-${rowIndex}`}
438
- ref={checkboxRef}
439
- tabIndex={-1}
440
- data-index={`${rowIndex}`}
441
- data-key={`${rowKey}`}
442
- data-use={dataUse}
443
- value={`${rowKey}`}
444
- checked={latestCheckedData().filter((cur: any) => cur.key === rowKey)[0]?.checked}
445
- onChange={(e: any) => {
446
- checkedAct(e.target, !latestCheckedData().filter((cur: any) => cur.key === rowKey)[0]?.checked);
447
- }}
448
- />
462
+ type="checkbox"
463
+ className="form-check-input"
464
+ name={`checkbox-${checkboxNamePrefix}-${rowIndex}`}
465
+ ref={checkboxRef}
466
+ tabIndex={-1}
467
+ data-index={`${rowIndex}`}
468
+ data-key={`${rowKey}`}
469
+ data-use={dataUse}
470
+ defaultValue={`${rowKey}`}
471
+ checked={latestCheckedData().filter((cur: any) => cur.key === rowKey)[0]?.checked}
472
+ onChange={(e: any) => {
473
+ checkedAct(e.target, !latestCheckedData().filter((cur: any) => cur.key === rowKey)[0]?.checked);
474
+ }}
475
+ />
476
+ </>}
477
+
449
478
  </div>
450
479
 
451
480
  </div>
@@ -152,8 +152,8 @@ const TableHeaders = (props: TableHeadersProps) => {
152
152
  data-index={-1}
153
153
  data-key="row-all"
154
154
  data-use=""
155
- value={`row-all`}
156
- checked={getCheckedRootData!.filter((cur: any) => cur.key === 'row-all')[0]?.checked}
155
+ defaultValue={`row-all`}
156
+ checked={getCheckedRootData!.filter((cur: any) => cur.key === 'row-all')[0]?.checked || false} // Avoid the error "react checkbox changing an uncontrolled input to be controlled"
157
157
  onChange={(e: any) => {
158
158
  checkedAct(e.target, !getCheckedRootData!.filter((cur: any) => cur.key === 'row-all')[0]?.checked);
159
159
  }}
@@ -14,7 +14,7 @@ type TableRowProps = {
14
14
  rootDataInfo: any;
15
15
  refNode: React.RefObject<any>;
16
16
  tableRootRef: React.RefObject<any>;
17
- tableCheckRef?: React.RefObject<any>;
17
+ tableCheckRef?: React.ForwardedRef<any>;
18
18
  rowActiveClassName?: string;
19
19
  fieldsChecked?: boolean[] | boolean;
20
20
  fieldsCheckedAct?: any[];
@@ -17,7 +17,7 @@ import { formatRowControlVal, removeCellFocusClassName } from './table-utils';
17
17
 
18
18
 
19
19
  type TableProps = {
20
- tableCheckRef?: React.RefObject<any>;
20
+ tableCheckRef?: React.ForwardedRef<any>;
21
21
  wrapperClassName?: string;
22
22
  tableClassName?: string;
23
23
  bodyClassName?: string;
@@ -172,6 +172,8 @@ const Table = (props: TableProps) => {
172
172
  };
173
173
 
174
174
  const allRows = () => {
175
+ if (tbodyRef.current === null) return [];
176
+
175
177
  return [].slice.call(tbodyRef.current.children);
176
178
  };
177
179
 
@@ -267,6 +269,7 @@ const Table = (props: TableProps) => {
267
269
  // checkboxes data
268
270
  // ================================================================
269
271
  function initCheckboxesData() {
272
+ if (rootRef.current === null) return;
270
273
 
271
274
  const _checkboxes = getChildren(rootRef.current.querySelector('table').querySelector('tbody'), '[type="checkbox"]');
272
275
  const _data: any[] = [];
@@ -577,16 +580,17 @@ const Table = (props: TableProps) => {
577
580
  }, []);
578
581
 
579
582
 
583
+
580
584
  return (
581
585
  <>
582
586
 
583
- <div
584
- ref={rootRef}
585
- id={idRes}
587
+ <div
588
+ ref={rootRef}
589
+ id={idRes}
586
590
  className={`table__wrapper ${wrapperClassName || wrapperClassName === '' ? wrapperClassName : `mb-3 position-relative`} ${responsiveClasses} ${enhancedResponsiveClasses} ${checkableClasses} ${radioClasses} ${draggableClasses} ${sortableClasses}`}
587
591
  >
588
592
 
589
- <table
593
+ <table
590
594
  className={`${tableClassName || tableClassName === '' ? tableClassName : "table"} ${tableClasses} ${typeof cellAutoWidth === 'undefined' || cellAutoWidth === false ? '' : 'cell-autowidth'}`}
591
595
  >
592
596
 
@@ -657,7 +661,7 @@ const Table = (props: TableProps) => {
657
661
  evRowClick={onRowClick}
658
662
  evCellArrowKeys={onCellArrowKeys}
659
663
 
660
-
664
+
661
665
  />;
662
666
  }) : ""
663
667
  }
@@ -292,7 +292,7 @@ const TagInput = forwardRef((props: TagInputProps, externalRef: any) => {
292
292
  type="hidden"
293
293
  id={idRes}
294
294
  name={name}
295
- value={VALUE_BY_BRACKETS ? convertArrToValByBrackets(items.map((item: any) => item.content)) : items.map((item: any) => item.content).join(',')}
295
+ value={VALUE_BY_BRACKETS ? convertArrToValByBrackets(items.map((item: any) => item.content)) : items.map((item: any) => item.content).join(',')} // do not use `defaultValue`
296
296
  required={required || null}
297
297
  />
298
298
 
@@ -13,7 +13,7 @@ declare module 'react' {
13
13
  }
14
14
  }
15
15
  type TextareaProps = {
16
- contentRef?: React.RefObject<any>;
16
+ contentRef?: React.ForwardedRef<any>; // could use "Array" on contentRef.current, such as contentRef.current[0], contentRef.current[1]
17
17
  wrapperClassName?: string;
18
18
  controlClassName?: string;
19
19
  controlExClassName?: string;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "author": "UIUX Lab",
3
3
  "email": "uiuxlab@gmail.com",
4
4
  "name": "funda-ui",
5
- "version": "4.1.345",
5
+ "version": "4.1.354",
6
6
  "description": "React components using pure Bootstrap 5+ which does not contain any external style and script libraries.",
7
7
  "repository": {
8
8
  "type": "git",