funda-ui 2.9.305 → 3.0.105
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Checkbox/index.js +1 -0
- package/MultipleCheckboxes/index.js +1 -0
- package/Table/index.d.ts +1 -1
- package/Table/index.js +125 -45
- package/Tree/index.js +1 -0
- package/lib/cjs/Checkbox/index.js +1 -0
- package/lib/cjs/MultipleCheckboxes/index.js +1 -0
- package/lib/cjs/Table/index.d.ts +1 -1
- package/lib/cjs/Table/index.js +125 -45
- package/lib/cjs/Tree/index.js +1 -0
- package/lib/esm/Checkbox/index.tsx +1 -0
- package/lib/esm/Table/TableFieldRow.tsx +133 -41
- package/lib/esm/Table/TableHeaders.tsx +5 -3
- package/lib/esm/Table/TableRow.tsx +6 -3
- package/lib/esm/Table/index.tsx +4 -3
- package/package.json +1 -1
package/Checkbox/index.js
CHANGED
|
@@ -198,6 +198,7 @@ var Checkbox = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
|
|
|
198
198
|
,
|
|
199
199
|
"data-name": name !== null && name !== void 0 && name.match(/(\[.*?\])/gi) ? "".concat(name.split('[')[0], "-label[]") : "".concat(name, "-label"),
|
|
200
200
|
"data-checkbox": true,
|
|
201
|
+
"data-checked": val,
|
|
201
202
|
disabled: disabled || null,
|
|
202
203
|
required: required || null,
|
|
203
204
|
onChange: handleChange,
|
|
@@ -393,6 +393,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
393
393
|
|
|
394
394
|
"data-name": name !== null && name !== void 0 && name.match(/(\[.*?\])/gi) ? "".concat(name.split('[')[0], "-label[]") : "".concat(name, "-label"),
|
|
395
395
|
"data-checkbox": true,
|
|
396
|
+
"data-checked": val,
|
|
396
397
|
disabled: disabled || null,
|
|
397
398
|
required: required || null,
|
|
398
399
|
onChange: handleChange,
|
package/Table/index.d.ts
CHANGED
package/Table/index.js
CHANGED
|
@@ -393,6 +393,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
393
393
|
|
|
394
394
|
"data-name": name !== null && name !== void 0 && name.match(/(\[.*?\])/gi) ? "".concat(name.split('[')[0], "-label[]") : "".concat(name, "-label"),
|
|
395
395
|
"data-checkbox": true,
|
|
396
|
+
"data-checked": val,
|
|
396
397
|
disabled: disabled || null,
|
|
397
398
|
required: required || null,
|
|
398
399
|
onChange: handleChange,
|
|
@@ -825,7 +826,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
825
826
|
|
|
826
827
|
var TableFieldRow = function TableFieldRow(props) {
|
|
827
828
|
var _latestCheckedData$fi;
|
|
828
|
-
var
|
|
829
|
+
var tableRootRef = props.tableRootRef,
|
|
830
|
+
tableCheckRef = props.tableCheckRef,
|
|
829
831
|
_props$rowActiveClass = props.rowActiveClassName,
|
|
830
832
|
rowActiveClassName = _props$rowActiveClass === void 0 ? 'active' : _props$rowActiveClass,
|
|
831
833
|
fieldsChecked = props.fieldsChecked,
|
|
@@ -862,13 +864,82 @@ var TableFieldRow = function TableFieldRow(props) {
|
|
|
862
864
|
var rowIndex = rowKey === null || rowKey === void 0 ? void 0 : rowKey.replace('row-', '');
|
|
863
865
|
|
|
864
866
|
// exposes the following methods
|
|
865
|
-
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useImperativeHandle)(
|
|
867
|
+
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useImperativeHandle)(tableCheckRef, function () {
|
|
866
868
|
return {
|
|
867
|
-
check: function check(
|
|
868
|
-
|
|
869
|
+
check: function check(data, cb) {
|
|
870
|
+
var _checkedData = getCheckedData;
|
|
871
|
+
var _res = [];
|
|
872
|
+
|
|
873
|
+
// STEP 1:
|
|
874
|
+
// Update checked data
|
|
875
|
+
//-----------
|
|
876
|
+
data.forEach(function (v, i) {
|
|
877
|
+
var _curKey = "row-".concat(v.index);
|
|
878
|
+
if (v.value === true) {
|
|
879
|
+
setCheckboxCheckedData(_checkedData, _curKey, true);
|
|
880
|
+
} else {
|
|
881
|
+
setCheckboxCheckedData(_checkedData, _curKey, false);
|
|
882
|
+
}
|
|
883
|
+
});
|
|
884
|
+
updategetCheckedData(_checkedData);
|
|
885
|
+
|
|
886
|
+
// STEP 2:
|
|
887
|
+
// get per checkbox value
|
|
888
|
+
//-----------
|
|
889
|
+
if (tableRootRef.current !== null) {
|
|
890
|
+
_checkedData.forEach(function (item) {
|
|
891
|
+
if (item.checked === true) {
|
|
892
|
+
var _index = item.key.replace('row-', '');
|
|
893
|
+
var curCheckbox = tableRootRef.current.querySelector('table').querySelector("tbody [data-key=\"row-".concat(_index, "\"]"));
|
|
894
|
+
_res.push(formatRowControlVal(curCheckbox, checkboxNamePrefix));
|
|
895
|
+
} else {
|
|
896
|
+
_res = removeItemOnce(_res, item.key);
|
|
897
|
+
}
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
// STEP 3:
|
|
902
|
+
// Update checked print
|
|
903
|
+
//-----------
|
|
904
|
+
updateCheckedPrint(_res);
|
|
905
|
+
|
|
906
|
+
// STEP 4:
|
|
907
|
+
// Update root checkbox
|
|
908
|
+
//-----------
|
|
909
|
+
var _headRow = tableRootRef.current.querySelector('table').querySelectorAll('thead th')[0];
|
|
910
|
+
var allChecked = _checkedData.every(function (item) {
|
|
911
|
+
return item.checked === true;
|
|
912
|
+
});
|
|
913
|
+
if (allChecked) {
|
|
914
|
+
updategetCheckedRootData([{
|
|
915
|
+
key: "row-all",
|
|
916
|
+
checked: true
|
|
917
|
+
}]);
|
|
918
|
+
} else {
|
|
919
|
+
updategetCheckedRootData([{
|
|
920
|
+
key: "row-all",
|
|
921
|
+
checked: false
|
|
922
|
+
}]);
|
|
923
|
+
}
|
|
924
|
+
if (typeof _headRow !== 'undefined') {
|
|
925
|
+
var _rootCheckbox = _headRow.querySelector('[type="checkbox"]');
|
|
926
|
+
var hasAnyChecked = _checkedData.some(function (item) {
|
|
927
|
+
return item.checked === true;
|
|
928
|
+
});
|
|
929
|
+
if (hasAnyChecked && !allChecked) {
|
|
930
|
+
_rootCheckbox.indeterminate = true;
|
|
931
|
+
} else {
|
|
932
|
+
_rootCheckbox.indeterminate = false;
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
// STEP 5:
|
|
937
|
+
// callback
|
|
938
|
+
//-----------
|
|
939
|
+
cb === null || cb === void 0 ? void 0 : cb(_res);
|
|
869
940
|
}
|
|
870
941
|
};
|
|
871
|
-
}, [
|
|
942
|
+
}, [tableCheckRef]);
|
|
872
943
|
|
|
873
944
|
// initialize actived checkboxes
|
|
874
945
|
var latestCheckedData = function latestCheckedData() {
|
|
@@ -885,40 +956,14 @@ var TableFieldRow = function TableFieldRow(props) {
|
|
|
885
956
|
return getCheckedData;
|
|
886
957
|
}
|
|
887
958
|
};
|
|
888
|
-
function
|
|
889
|
-
|
|
890
|
-
var
|
|
891
|
-
var _res = getCheckedPrint;
|
|
892
|
-
|
|
893
|
-
// STEP 1:
|
|
894
|
-
// Current checkbox
|
|
895
|
-
//-----------
|
|
896
|
-
if (val === true) {
|
|
897
|
-
_res.push(formatCheckboxControlVal(e.target));
|
|
898
|
-
setCheckboxCheckedData(_checkedData, _curKey, true);
|
|
899
|
-
} else {
|
|
900
|
-
setCheckboxCheckedData(_checkedData, _curKey, false);
|
|
901
|
-
_res = removeItemOnce(_res, _curKey);
|
|
902
|
-
}
|
|
903
|
-
|
|
904
|
-
// STEP 2:
|
|
905
|
-
// Array deduplication
|
|
906
|
-
//-----------
|
|
907
|
-
_res = _res.filter(function (item, index, self) {
|
|
908
|
-
return index === self.findIndex(function (t) {
|
|
909
|
-
return t.key === item.key;
|
|
910
|
-
});
|
|
911
|
-
});
|
|
912
|
-
|
|
913
|
-
// STEP 3:
|
|
914
|
-
// ALl parent checkboxes
|
|
915
|
-
//-----------
|
|
916
|
-
var _headRow = e.target.closest('table').querySelectorAll('thead th')[0];
|
|
959
|
+
function updateRootcheckbox(el) {
|
|
960
|
+
if (el === null) return;
|
|
961
|
+
var _headRow = el.closest('table').querySelectorAll('thead th')[0];
|
|
917
962
|
if (typeof _headRow !== 'undefined') {
|
|
918
963
|
var _rootCheckbox = _headRow.querySelector('[type="checkbox"]');
|
|
919
|
-
var _checkboxes = (0,dom.getChildren)(
|
|
920
|
-
var _checkedLength = _checkboxes.filter(function (
|
|
921
|
-
return
|
|
964
|
+
var _checkboxes = (0,dom.getChildren)(el.closest('table').querySelector('tbody'), '[type="checkbox"]');
|
|
965
|
+
var _checkedLength = _checkboxes.filter(function (checkbox) {
|
|
966
|
+
return checkbox.checked === true;
|
|
922
967
|
}).length;
|
|
923
968
|
if (_checkedLength === 0) {
|
|
924
969
|
_rootCheckbox.indeterminate = false;
|
|
@@ -943,6 +988,37 @@ var TableFieldRow = function TableFieldRow(props) {
|
|
|
943
988
|
}
|
|
944
989
|
}
|
|
945
990
|
}
|
|
991
|
+
}
|
|
992
|
+
function checkedAct(el, val) {
|
|
993
|
+
if (el === null) return;
|
|
994
|
+
var _curKey = el.value;
|
|
995
|
+
var _checkedData = getCheckedData;
|
|
996
|
+
var _res = getCheckedPrint;
|
|
997
|
+
|
|
998
|
+
// STEP 1:
|
|
999
|
+
// Current checkbox
|
|
1000
|
+
//-----------
|
|
1001
|
+
if (val === true) {
|
|
1002
|
+
_res.push(formatCheckboxControlVal(el));
|
|
1003
|
+
setCheckboxCheckedData(_checkedData, _curKey, true);
|
|
1004
|
+
} else {
|
|
1005
|
+
setCheckboxCheckedData(_checkedData, _curKey, false);
|
|
1006
|
+
_res = removeItemOnce(_res, _curKey);
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
// STEP 2:
|
|
1010
|
+
// Array deduplication
|
|
1011
|
+
//-----------
|
|
1012
|
+
_res = _res.filter(function (item, index, self) {
|
|
1013
|
+
return index === self.findIndex(function (t) {
|
|
1014
|
+
return t.key === item.key;
|
|
1015
|
+
});
|
|
1016
|
+
});
|
|
1017
|
+
|
|
1018
|
+
// STEP 3:
|
|
1019
|
+
// ALl parent checkboxes
|
|
1020
|
+
//-----------
|
|
1021
|
+
updateRootcheckbox(el);
|
|
946
1022
|
|
|
947
1023
|
// STEP 4:
|
|
948
1024
|
// Update checked data
|
|
@@ -1103,7 +1179,7 @@ var TableFieldRow = function TableFieldRow(props) {
|
|
|
1103
1179
|
return cur.key === rowKey;
|
|
1104
1180
|
})[0]) === null || _latestCheckedData$fi === void 0 ? void 0 : _latestCheckedData$fi.checked,
|
|
1105
1181
|
onChange: function onChange(e, val) {
|
|
1106
|
-
checkedAct(e, val);
|
|
1182
|
+
checkedAct(e.target, val);
|
|
1107
1183
|
}
|
|
1108
1184
|
}))), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
|
|
1109
1185
|
ref: contentRef
|
|
@@ -1127,7 +1203,8 @@ function TableRow_arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
1127
1203
|
|
|
1128
1204
|
var TableRow = function TableRow(props) {
|
|
1129
1205
|
var _filter$, _filter$2;
|
|
1130
|
-
var
|
|
1206
|
+
var tableRootRef = props.tableRootRef,
|
|
1207
|
+
tableCheckRef = props.tableCheckRef,
|
|
1131
1208
|
_props$rowActiveClass = props.rowActiveClassName,
|
|
1132
1209
|
rowActiveClassName = _props$rowActiveClass === void 0 ? 'active' : _props$rowActiveClass,
|
|
1133
1210
|
fieldsChecked = props.fieldsChecked,
|
|
@@ -1205,7 +1282,8 @@ var TableRow = function TableRow(props) {
|
|
|
1205
1282
|
if (i === 0) {
|
|
1206
1283
|
return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(src_TableFieldRow, {
|
|
1207
1284
|
key: 'th-row' + i,
|
|
1208
|
-
|
|
1285
|
+
tableRootRef: tableRootRef,
|
|
1286
|
+
tableCheckRef: tableCheckRef,
|
|
1209
1287
|
rowActiveClassName: rowActiveClassName,
|
|
1210
1288
|
fieldsChecked: fieldsChecked,
|
|
1211
1289
|
updateFirstInitCheckboxesClassName: setFirstInitCheckboxesClassName,
|
|
@@ -1277,7 +1355,8 @@ var TableHeaders = function TableHeaders(props) {
|
|
|
1277
1355
|
evHeadCellMouseEnter = props.evHeadCellMouseEnter,
|
|
1278
1356
|
evHeadCellMouseLeave = props.evHeadCellMouseLeave,
|
|
1279
1357
|
evHeadCellClick = props.evHeadCellClick;
|
|
1280
|
-
function checkedAct(
|
|
1358
|
+
function checkedAct(el, val) {
|
|
1359
|
+
if (el === null) return;
|
|
1281
1360
|
var _checkedData = getCheckedData;
|
|
1282
1361
|
var _res = getCheckedPrint;
|
|
1283
1362
|
|
|
@@ -1299,7 +1378,7 @@ var TableHeaders = function TableHeaders(props) {
|
|
|
1299
1378
|
// STEP 2:
|
|
1300
1379
|
// All child checkboxes
|
|
1301
1380
|
//-----------
|
|
1302
|
-
var _checkboxes = (0,dom.getChildren)(
|
|
1381
|
+
var _checkboxes = (0,dom.getChildren)(el.closest('table').querySelector('tbody'), '[type="checkbox"]');
|
|
1303
1382
|
[].slice.call(_checkboxes).forEach(function (node) {
|
|
1304
1383
|
if (val === true) {
|
|
1305
1384
|
setCheckboxCheckedData(_checkedData, node.dataset.key, true);
|
|
@@ -1373,7 +1452,7 @@ var TableHeaders = function TableHeaders(props) {
|
|
|
1373
1452
|
return cur.key === 'row-all';
|
|
1374
1453
|
})[0]) === null || _filter$ === void 0 ? void 0 : _filter$.checked,
|
|
1375
1454
|
onChange: function onChange(e, val) {
|
|
1376
|
-
checkedAct(e, val);
|
|
1455
|
+
checkedAct(e.target, val);
|
|
1377
1456
|
}
|
|
1378
1457
|
})) : null, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
|
|
1379
1458
|
dangerouslySetInnerHTML: {
|
|
@@ -1452,7 +1531,7 @@ function src_arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
1452
1531
|
|
|
1453
1532
|
|
|
1454
1533
|
var Table = function Table(props) {
|
|
1455
|
-
var
|
|
1534
|
+
var tableCheckRef = props.tableCheckRef,
|
|
1456
1535
|
wrapperClassName = props.wrapperClassName,
|
|
1457
1536
|
tableClassName = props.tableClassName,
|
|
1458
1537
|
bodyClassName = props.bodyClassName,
|
|
@@ -1905,7 +1984,8 @@ var Table = function Table(props) {
|
|
|
1905
1984
|
key: i + String(mainUpdate) // Trigger child component update when prop of parent changes
|
|
1906
1985
|
,
|
|
1907
1986
|
index: i,
|
|
1908
|
-
|
|
1987
|
+
tableRootRef: rootRef,
|
|
1988
|
+
tableCheckRef: tableCheckRef,
|
|
1909
1989
|
rowActiveClassName: rowActiveClassName,
|
|
1910
1990
|
fieldsChecked: _fieldsChecked,
|
|
1911
1991
|
rowKey: "row-".concat(i),
|
package/Tree/index.js
CHANGED
|
@@ -393,6 +393,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
393
393
|
|
|
394
394
|
"data-name": name !== null && name !== void 0 && name.match(/(\[.*?\])/gi) ? "".concat(name.split('[')[0], "-label[]") : "".concat(name, "-label"),
|
|
395
395
|
"data-checkbox": true,
|
|
396
|
+
"data-checked": val,
|
|
396
397
|
disabled: disabled || null,
|
|
397
398
|
required: required || null,
|
|
398
399
|
onChange: handleChange,
|
|
@@ -198,6 +198,7 @@ var Checkbox = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(fu
|
|
|
198
198
|
,
|
|
199
199
|
"data-name": name !== null && name !== void 0 && name.match(/(\[.*?\])/gi) ? "".concat(name.split('[')[0], "-label[]") : "".concat(name, "-label"),
|
|
200
200
|
"data-checkbox": true,
|
|
201
|
+
"data-checked": val,
|
|
201
202
|
disabled: disabled || null,
|
|
202
203
|
required: required || null,
|
|
203
204
|
onChange: handleChange,
|
|
@@ -393,6 +393,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
393
393
|
|
|
394
394
|
"data-name": name !== null && name !== void 0 && name.match(/(\[.*?\])/gi) ? "".concat(name.split('[')[0], "-label[]") : "".concat(name, "-label"),
|
|
395
395
|
"data-checkbox": true,
|
|
396
|
+
"data-checked": val,
|
|
396
397
|
disabled: disabled || null,
|
|
397
398
|
required: required || null,
|
|
398
399
|
onChange: handleChange,
|
package/lib/cjs/Table/index.d.ts
CHANGED
package/lib/cjs/Table/index.js
CHANGED
|
@@ -393,6 +393,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
393
393
|
|
|
394
394
|
"data-name": name !== null && name !== void 0 && name.match(/(\[.*?\])/gi) ? "".concat(name.split('[')[0], "-label[]") : "".concat(name, "-label"),
|
|
395
395
|
"data-checkbox": true,
|
|
396
|
+
"data-checked": val,
|
|
396
397
|
disabled: disabled || null,
|
|
397
398
|
required: required || null,
|
|
398
399
|
onChange: handleChange,
|
|
@@ -825,7 +826,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
825
826
|
|
|
826
827
|
var TableFieldRow = function TableFieldRow(props) {
|
|
827
828
|
var _latestCheckedData$fi;
|
|
828
|
-
var
|
|
829
|
+
var tableRootRef = props.tableRootRef,
|
|
830
|
+
tableCheckRef = props.tableCheckRef,
|
|
829
831
|
_props$rowActiveClass = props.rowActiveClassName,
|
|
830
832
|
rowActiveClassName = _props$rowActiveClass === void 0 ? 'active' : _props$rowActiveClass,
|
|
831
833
|
fieldsChecked = props.fieldsChecked,
|
|
@@ -862,13 +864,82 @@ var TableFieldRow = function TableFieldRow(props) {
|
|
|
862
864
|
var rowIndex = rowKey === null || rowKey === void 0 ? void 0 : rowKey.replace('row-', '');
|
|
863
865
|
|
|
864
866
|
// exposes the following methods
|
|
865
|
-
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useImperativeHandle)(
|
|
867
|
+
(0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useImperativeHandle)(tableCheckRef, function () {
|
|
866
868
|
return {
|
|
867
|
-
check: function check(
|
|
868
|
-
|
|
869
|
+
check: function check(data, cb) {
|
|
870
|
+
var _checkedData = getCheckedData;
|
|
871
|
+
var _res = [];
|
|
872
|
+
|
|
873
|
+
// STEP 1:
|
|
874
|
+
// Update checked data
|
|
875
|
+
//-----------
|
|
876
|
+
data.forEach(function (v, i) {
|
|
877
|
+
var _curKey = "row-".concat(v.index);
|
|
878
|
+
if (v.value === true) {
|
|
879
|
+
setCheckboxCheckedData(_checkedData, _curKey, true);
|
|
880
|
+
} else {
|
|
881
|
+
setCheckboxCheckedData(_checkedData, _curKey, false);
|
|
882
|
+
}
|
|
883
|
+
});
|
|
884
|
+
updategetCheckedData(_checkedData);
|
|
885
|
+
|
|
886
|
+
// STEP 2:
|
|
887
|
+
// get per checkbox value
|
|
888
|
+
//-----------
|
|
889
|
+
if (tableRootRef.current !== null) {
|
|
890
|
+
_checkedData.forEach(function (item) {
|
|
891
|
+
if (item.checked === true) {
|
|
892
|
+
var _index = item.key.replace('row-', '');
|
|
893
|
+
var curCheckbox = tableRootRef.current.querySelector('table').querySelector("tbody [data-key=\"row-".concat(_index, "\"]"));
|
|
894
|
+
_res.push(formatRowControlVal(curCheckbox, checkboxNamePrefix));
|
|
895
|
+
} else {
|
|
896
|
+
_res = removeItemOnce(_res, item.key);
|
|
897
|
+
}
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
// STEP 3:
|
|
902
|
+
// Update checked print
|
|
903
|
+
//-----------
|
|
904
|
+
updateCheckedPrint(_res);
|
|
905
|
+
|
|
906
|
+
// STEP 4:
|
|
907
|
+
// Update root checkbox
|
|
908
|
+
//-----------
|
|
909
|
+
var _headRow = tableRootRef.current.querySelector('table').querySelectorAll('thead th')[0];
|
|
910
|
+
var allChecked = _checkedData.every(function (item) {
|
|
911
|
+
return item.checked === true;
|
|
912
|
+
});
|
|
913
|
+
if (allChecked) {
|
|
914
|
+
updategetCheckedRootData([{
|
|
915
|
+
key: "row-all",
|
|
916
|
+
checked: true
|
|
917
|
+
}]);
|
|
918
|
+
} else {
|
|
919
|
+
updategetCheckedRootData([{
|
|
920
|
+
key: "row-all",
|
|
921
|
+
checked: false
|
|
922
|
+
}]);
|
|
923
|
+
}
|
|
924
|
+
if (typeof _headRow !== 'undefined') {
|
|
925
|
+
var _rootCheckbox = _headRow.querySelector('[type="checkbox"]');
|
|
926
|
+
var hasAnyChecked = _checkedData.some(function (item) {
|
|
927
|
+
return item.checked === true;
|
|
928
|
+
});
|
|
929
|
+
if (hasAnyChecked && !allChecked) {
|
|
930
|
+
_rootCheckbox.indeterminate = true;
|
|
931
|
+
} else {
|
|
932
|
+
_rootCheckbox.indeterminate = false;
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
// STEP 5:
|
|
937
|
+
// callback
|
|
938
|
+
//-----------
|
|
939
|
+
cb === null || cb === void 0 ? void 0 : cb(_res);
|
|
869
940
|
}
|
|
870
941
|
};
|
|
871
|
-
}, [
|
|
942
|
+
}, [tableCheckRef]);
|
|
872
943
|
|
|
873
944
|
// initialize actived checkboxes
|
|
874
945
|
var latestCheckedData = function latestCheckedData() {
|
|
@@ -885,40 +956,14 @@ var TableFieldRow = function TableFieldRow(props) {
|
|
|
885
956
|
return getCheckedData;
|
|
886
957
|
}
|
|
887
958
|
};
|
|
888
|
-
function
|
|
889
|
-
|
|
890
|
-
var
|
|
891
|
-
var _res = getCheckedPrint;
|
|
892
|
-
|
|
893
|
-
// STEP 1:
|
|
894
|
-
// Current checkbox
|
|
895
|
-
//-----------
|
|
896
|
-
if (val === true) {
|
|
897
|
-
_res.push(formatCheckboxControlVal(e.target));
|
|
898
|
-
setCheckboxCheckedData(_checkedData, _curKey, true);
|
|
899
|
-
} else {
|
|
900
|
-
setCheckboxCheckedData(_checkedData, _curKey, false);
|
|
901
|
-
_res = removeItemOnce(_res, _curKey);
|
|
902
|
-
}
|
|
903
|
-
|
|
904
|
-
// STEP 2:
|
|
905
|
-
// Array deduplication
|
|
906
|
-
//-----------
|
|
907
|
-
_res = _res.filter(function (item, index, self) {
|
|
908
|
-
return index === self.findIndex(function (t) {
|
|
909
|
-
return t.key === item.key;
|
|
910
|
-
});
|
|
911
|
-
});
|
|
912
|
-
|
|
913
|
-
// STEP 3:
|
|
914
|
-
// ALl parent checkboxes
|
|
915
|
-
//-----------
|
|
916
|
-
var _headRow = e.target.closest('table').querySelectorAll('thead th')[0];
|
|
959
|
+
function updateRootcheckbox(el) {
|
|
960
|
+
if (el === null) return;
|
|
961
|
+
var _headRow = el.closest('table').querySelectorAll('thead th')[0];
|
|
917
962
|
if (typeof _headRow !== 'undefined') {
|
|
918
963
|
var _rootCheckbox = _headRow.querySelector('[type="checkbox"]');
|
|
919
|
-
var _checkboxes = (0,dom.getChildren)(
|
|
920
|
-
var _checkedLength = _checkboxes.filter(function (
|
|
921
|
-
return
|
|
964
|
+
var _checkboxes = (0,dom.getChildren)(el.closest('table').querySelector('tbody'), '[type="checkbox"]');
|
|
965
|
+
var _checkedLength = _checkboxes.filter(function (checkbox) {
|
|
966
|
+
return checkbox.checked === true;
|
|
922
967
|
}).length;
|
|
923
968
|
if (_checkedLength === 0) {
|
|
924
969
|
_rootCheckbox.indeterminate = false;
|
|
@@ -943,6 +988,37 @@ var TableFieldRow = function TableFieldRow(props) {
|
|
|
943
988
|
}
|
|
944
989
|
}
|
|
945
990
|
}
|
|
991
|
+
}
|
|
992
|
+
function checkedAct(el, val) {
|
|
993
|
+
if (el === null) return;
|
|
994
|
+
var _curKey = el.value;
|
|
995
|
+
var _checkedData = getCheckedData;
|
|
996
|
+
var _res = getCheckedPrint;
|
|
997
|
+
|
|
998
|
+
// STEP 1:
|
|
999
|
+
// Current checkbox
|
|
1000
|
+
//-----------
|
|
1001
|
+
if (val === true) {
|
|
1002
|
+
_res.push(formatCheckboxControlVal(el));
|
|
1003
|
+
setCheckboxCheckedData(_checkedData, _curKey, true);
|
|
1004
|
+
} else {
|
|
1005
|
+
setCheckboxCheckedData(_checkedData, _curKey, false);
|
|
1006
|
+
_res = removeItemOnce(_res, _curKey);
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
// STEP 2:
|
|
1010
|
+
// Array deduplication
|
|
1011
|
+
//-----------
|
|
1012
|
+
_res = _res.filter(function (item, index, self) {
|
|
1013
|
+
return index === self.findIndex(function (t) {
|
|
1014
|
+
return t.key === item.key;
|
|
1015
|
+
});
|
|
1016
|
+
});
|
|
1017
|
+
|
|
1018
|
+
// STEP 3:
|
|
1019
|
+
// ALl parent checkboxes
|
|
1020
|
+
//-----------
|
|
1021
|
+
updateRootcheckbox(el);
|
|
946
1022
|
|
|
947
1023
|
// STEP 4:
|
|
948
1024
|
// Update checked data
|
|
@@ -1103,7 +1179,7 @@ var TableFieldRow = function TableFieldRow(props) {
|
|
|
1103
1179
|
return cur.key === rowKey;
|
|
1104
1180
|
})[0]) === null || _latestCheckedData$fi === void 0 ? void 0 : _latestCheckedData$fi.checked,
|
|
1105
1181
|
onChange: function onChange(e, val) {
|
|
1106
|
-
checkedAct(e, val);
|
|
1182
|
+
checkedAct(e.target, val);
|
|
1107
1183
|
}
|
|
1108
1184
|
}))), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
|
|
1109
1185
|
ref: contentRef
|
|
@@ -1127,7 +1203,8 @@ function TableRow_arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
1127
1203
|
|
|
1128
1204
|
var TableRow = function TableRow(props) {
|
|
1129
1205
|
var _filter$, _filter$2;
|
|
1130
|
-
var
|
|
1206
|
+
var tableRootRef = props.tableRootRef,
|
|
1207
|
+
tableCheckRef = props.tableCheckRef,
|
|
1131
1208
|
_props$rowActiveClass = props.rowActiveClassName,
|
|
1132
1209
|
rowActiveClassName = _props$rowActiveClass === void 0 ? 'active' : _props$rowActiveClass,
|
|
1133
1210
|
fieldsChecked = props.fieldsChecked,
|
|
@@ -1205,7 +1282,8 @@ var TableRow = function TableRow(props) {
|
|
|
1205
1282
|
if (i === 0) {
|
|
1206
1283
|
return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(src_TableFieldRow, {
|
|
1207
1284
|
key: 'th-row' + i,
|
|
1208
|
-
|
|
1285
|
+
tableRootRef: tableRootRef,
|
|
1286
|
+
tableCheckRef: tableCheckRef,
|
|
1209
1287
|
rowActiveClassName: rowActiveClassName,
|
|
1210
1288
|
fieldsChecked: fieldsChecked,
|
|
1211
1289
|
updateFirstInitCheckboxesClassName: setFirstInitCheckboxesClassName,
|
|
@@ -1277,7 +1355,8 @@ var TableHeaders = function TableHeaders(props) {
|
|
|
1277
1355
|
evHeadCellMouseEnter = props.evHeadCellMouseEnter,
|
|
1278
1356
|
evHeadCellMouseLeave = props.evHeadCellMouseLeave,
|
|
1279
1357
|
evHeadCellClick = props.evHeadCellClick;
|
|
1280
|
-
function checkedAct(
|
|
1358
|
+
function checkedAct(el, val) {
|
|
1359
|
+
if (el === null) return;
|
|
1281
1360
|
var _checkedData = getCheckedData;
|
|
1282
1361
|
var _res = getCheckedPrint;
|
|
1283
1362
|
|
|
@@ -1299,7 +1378,7 @@ var TableHeaders = function TableHeaders(props) {
|
|
|
1299
1378
|
// STEP 2:
|
|
1300
1379
|
// All child checkboxes
|
|
1301
1380
|
//-----------
|
|
1302
|
-
var _checkboxes = (0,dom.getChildren)(
|
|
1381
|
+
var _checkboxes = (0,dom.getChildren)(el.closest('table').querySelector('tbody'), '[type="checkbox"]');
|
|
1303
1382
|
[].slice.call(_checkboxes).forEach(function (node) {
|
|
1304
1383
|
if (val === true) {
|
|
1305
1384
|
setCheckboxCheckedData(_checkedData, node.dataset.key, true);
|
|
@@ -1373,7 +1452,7 @@ var TableHeaders = function TableHeaders(props) {
|
|
|
1373
1452
|
return cur.key === 'row-all';
|
|
1374
1453
|
})[0]) === null || _filter$ === void 0 ? void 0 : _filter$.checked,
|
|
1375
1454
|
onChange: function onChange(e, val) {
|
|
1376
|
-
checkedAct(e, val);
|
|
1455
|
+
checkedAct(e.target, val);
|
|
1377
1456
|
}
|
|
1378
1457
|
})) : null, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
|
|
1379
1458
|
dangerouslySetInnerHTML: {
|
|
@@ -1452,7 +1531,7 @@ function src_arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
1452
1531
|
|
|
1453
1532
|
|
|
1454
1533
|
var Table = function Table(props) {
|
|
1455
|
-
var
|
|
1534
|
+
var tableCheckRef = props.tableCheckRef,
|
|
1456
1535
|
wrapperClassName = props.wrapperClassName,
|
|
1457
1536
|
tableClassName = props.tableClassName,
|
|
1458
1537
|
bodyClassName = props.bodyClassName,
|
|
@@ -1905,7 +1984,8 @@ var Table = function Table(props) {
|
|
|
1905
1984
|
key: i + String(mainUpdate) // Trigger child component update when prop of parent changes
|
|
1906
1985
|
,
|
|
1907
1986
|
index: i,
|
|
1908
|
-
|
|
1987
|
+
tableRootRef: rootRef,
|
|
1988
|
+
tableCheckRef: tableCheckRef,
|
|
1909
1989
|
rowActiveClassName: rowActiveClassName,
|
|
1910
1990
|
fieldsChecked: _fieldsChecked,
|
|
1911
1991
|
rowKey: "row-".concat(i),
|
package/lib/cjs/Tree/index.js
CHANGED
|
@@ -393,6 +393,7 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_
|
|
|
393
393
|
|
|
394
394
|
"data-name": name !== null && name !== void 0 && name.match(/(\[.*?\])/gi) ? "".concat(name.split('[')[0], "-label[]") : "".concat(name, "-label"),
|
|
395
395
|
"data-checkbox": true,
|
|
396
|
+
"data-checked": val,
|
|
396
397
|
disabled: disabled || null,
|
|
397
398
|
required: required || null,
|
|
398
399
|
onChange: handleChange,
|
|
@@ -131,6 +131,7 @@ const Checkbox = forwardRef((props: CheckboxProps, ref: any) => {
|
|
|
131
131
|
// Don't use "name", it's just a container to display the label
|
|
132
132
|
data-name={name?.match(/(\[.*?\])/gi) ? `${name.split('[')[0]}-label[]` : `${name}-label`}
|
|
133
133
|
data-checkbox
|
|
134
|
+
data-checked={val}
|
|
134
135
|
disabled={disabled || null}
|
|
135
136
|
required={required || null}
|
|
136
137
|
onChange={handleChange}
|
|
@@ -6,12 +6,15 @@ import Checkbox from 'funda-checkbox';
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
import { getChildren } from './utils/dom';
|
|
9
|
-
import { removeItemOnce, formatCheckboxControlVal, setCheckboxCheckedData } from './table-utils';
|
|
9
|
+
import { removeItemOnce, formatCheckboxControlVal, setCheckboxCheckedData, formatRowControlVal } from './table-utils';
|
|
10
|
+
|
|
11
|
+
|
|
10
12
|
|
|
11
13
|
/* Table Field Row
|
|
12
14
|
-------------------------------------------------*/
|
|
13
15
|
type TableFieldRowProps = {
|
|
14
|
-
|
|
16
|
+
tableRootRef: React.RefObject<any>;
|
|
17
|
+
tableCheckRef?: React.RefObject<any>;
|
|
15
18
|
rowActiveClassName?: string;
|
|
16
19
|
fieldsChecked?: boolean[] | boolean;
|
|
17
20
|
updateFirstInitCheckboxesClassName?: any;
|
|
@@ -43,7 +46,8 @@ const TableFieldRow = (props: TableFieldRowProps) => {
|
|
|
43
46
|
|
|
44
47
|
|
|
45
48
|
const {
|
|
46
|
-
|
|
49
|
+
tableRootRef,
|
|
50
|
+
tableCheckRef,
|
|
47
51
|
rowActiveClassName = 'active',
|
|
48
52
|
fieldsChecked,
|
|
49
53
|
updateFirstInitCheckboxesClassName,
|
|
@@ -81,13 +85,90 @@ const TableFieldRow = (props: TableFieldRowProps) => {
|
|
|
81
85
|
|
|
82
86
|
// exposes the following methods
|
|
83
87
|
useImperativeHandle(
|
|
84
|
-
|
|
88
|
+
tableCheckRef,
|
|
85
89
|
() => ({
|
|
86
|
-
check: (
|
|
87
|
-
|
|
90
|
+
check: (data: any, cb: any) => {
|
|
91
|
+
|
|
92
|
+
const _checkedData: any = getCheckedData;
|
|
93
|
+
let _res: any[] = [];
|
|
94
|
+
|
|
95
|
+
// STEP 1:
|
|
96
|
+
// Update checked data
|
|
97
|
+
//-----------
|
|
98
|
+
data.forEach((v: any, i: number) => {
|
|
99
|
+
|
|
100
|
+
const _curKey: string = `row-${v.index}`;
|
|
101
|
+
if (v.value === true) {
|
|
102
|
+
setCheckboxCheckedData(_checkedData, _curKey, true);
|
|
103
|
+
} else {
|
|
104
|
+
setCheckboxCheckedData(_checkedData, _curKey, false);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
updategetCheckedData(_checkedData);
|
|
108
|
+
|
|
109
|
+
// STEP 2:
|
|
110
|
+
// get per checkbox value
|
|
111
|
+
//-----------
|
|
112
|
+
if (tableRootRef.current !== null) {
|
|
113
|
+
_checkedData.forEach((item: any) => {
|
|
114
|
+
|
|
115
|
+
if (item.checked === true) {
|
|
116
|
+
const _index = item.key.replace('row-', '');
|
|
117
|
+
const curCheckbox = tableRootRef.current.querySelector('table').querySelector(`tbody [data-key="row-${_index}"]`);
|
|
118
|
+
|
|
119
|
+
_res.push(formatRowControlVal(curCheckbox, checkboxNamePrefix as string));
|
|
120
|
+
} else {
|
|
121
|
+
_res = removeItemOnce(_res, item.key);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
// STEP 3:
|
|
129
|
+
// Update checked print
|
|
130
|
+
//-----------
|
|
131
|
+
updateCheckedPrint(_res);
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
// STEP 4:
|
|
135
|
+
// Update root checkbox
|
|
136
|
+
//-----------
|
|
137
|
+
const _headRow = tableRootRef.current.querySelector('table').querySelectorAll('thead th')[0];
|
|
138
|
+
const allChecked = _checkedData.every((item: any) => item.checked === true);
|
|
139
|
+
|
|
140
|
+
if (allChecked) {
|
|
141
|
+
updategetCheckedRootData([{
|
|
142
|
+
key: `row-all`,
|
|
143
|
+
checked: true
|
|
144
|
+
}]);
|
|
145
|
+
} else {
|
|
146
|
+
updategetCheckedRootData([{
|
|
147
|
+
key: `row-all`,
|
|
148
|
+
checked: false
|
|
149
|
+
}]);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (typeof _headRow !== 'undefined') {
|
|
153
|
+
const _rootCheckbox = _headRow.querySelector('[type="checkbox"]');
|
|
154
|
+
const hasAnyChecked = _checkedData.some((item: any) => item.checked === true);
|
|
155
|
+
if (hasAnyChecked && !allChecked) {
|
|
156
|
+
_rootCheckbox.indeterminate = true;
|
|
157
|
+
} else {
|
|
158
|
+
_rootCheckbox.indeterminate = false;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
// STEP 5:
|
|
163
|
+
// callback
|
|
164
|
+
//-----------
|
|
165
|
+
cb?.(_res);
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
88
169
|
},
|
|
89
170
|
}),
|
|
90
|
-
[
|
|
171
|
+
[tableCheckRef],
|
|
91
172
|
);
|
|
92
173
|
|
|
93
174
|
|
|
@@ -110,43 +191,16 @@ const TableFieldRow = (props: TableFieldRowProps) => {
|
|
|
110
191
|
}
|
|
111
192
|
};
|
|
112
193
|
|
|
113
|
-
function checkedAct(e: any, val: any) {
|
|
114
|
-
|
|
115
|
-
const _curKey: string = e.target.value;
|
|
116
|
-
const _checkedData: any = getCheckedData;
|
|
117
|
-
|
|
118
|
-
let _res: any = getCheckedPrint;
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
// STEP 1:
|
|
122
|
-
// Current checkbox
|
|
123
|
-
//-----------
|
|
124
|
-
if (val === true) {
|
|
125
|
-
_res.push(formatCheckboxControlVal(e.target));
|
|
126
|
-
setCheckboxCheckedData(_checkedData, _curKey, true);
|
|
127
|
-
} else {
|
|
128
|
-
setCheckboxCheckedData(_checkedData, _curKey, false);
|
|
129
|
-
_res = removeItemOnce(_res, _curKey);
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// STEP 2:
|
|
134
|
-
// Array deduplication
|
|
135
|
-
//-----------
|
|
136
|
-
_res = _res.filter((item: any, index: number, self: any[]) => index === self.findIndex((t) => (t.key === item.key)))
|
|
137
|
-
|
|
138
|
-
|
|
139
194
|
|
|
195
|
+
function updateRootcheckbox(el: any) {
|
|
196
|
+
if (el === null) return;
|
|
140
197
|
|
|
141
|
-
|
|
142
|
-
// ALl parent checkboxes
|
|
143
|
-
//-----------
|
|
144
|
-
const _headRow = e.target.closest('table').querySelectorAll('thead th')[0];
|
|
198
|
+
const _headRow = el.closest('table').querySelectorAll('thead th')[0];
|
|
145
199
|
if (typeof _headRow !== 'undefined') {
|
|
146
200
|
const _rootCheckbox = _headRow.querySelector('[type="checkbox"]');
|
|
147
|
-
const _checkboxes = getChildren(
|
|
148
|
-
const _checkedLength = _checkboxes.filter((
|
|
149
|
-
return
|
|
201
|
+
const _checkboxes = getChildren(el.closest('table').querySelector('tbody'), '[type="checkbox"]');
|
|
202
|
+
const _checkedLength = _checkboxes.filter((checkbox: any) => {
|
|
203
|
+
return checkbox.checked === true;
|
|
150
204
|
}).length;
|
|
151
205
|
|
|
152
206
|
if (_checkedLength === 0) {
|
|
@@ -176,6 +230,43 @@ const TableFieldRow = (props: TableFieldRowProps) => {
|
|
|
176
230
|
|
|
177
231
|
}
|
|
178
232
|
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function checkedAct(el: any, val: any) {
|
|
236
|
+
|
|
237
|
+
if (el === null) return;
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
const _curKey: string = el.value;
|
|
241
|
+
const _checkedData: any = getCheckedData;
|
|
242
|
+
|
|
243
|
+
let _res: any = getCheckedPrint;
|
|
244
|
+
|
|
245
|
+
// STEP 1:
|
|
246
|
+
// Current checkbox
|
|
247
|
+
//-----------
|
|
248
|
+
if (val === true) {
|
|
249
|
+
_res.push(formatCheckboxControlVal(el));
|
|
250
|
+
setCheckboxCheckedData(_checkedData, _curKey, true);
|
|
251
|
+
} else {
|
|
252
|
+
setCheckboxCheckedData(_checkedData, _curKey, false);
|
|
253
|
+
_res = removeItemOnce(_res, _curKey);
|
|
254
|
+
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
// STEP 2:
|
|
258
|
+
// Array deduplication
|
|
259
|
+
//-----------
|
|
260
|
+
_res = _res.filter((item: any, index: number, self: any[]) => index === self.findIndex((t) => (t.key === item.key)))
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
// STEP 3:
|
|
266
|
+
// ALl parent checkboxes
|
|
267
|
+
//-----------
|
|
268
|
+
updateRootcheckbox(el);
|
|
269
|
+
|
|
179
270
|
|
|
180
271
|
// STEP 4:
|
|
181
272
|
// Update checked data
|
|
@@ -193,6 +284,7 @@ const TableFieldRow = (props: TableFieldRowProps) => {
|
|
|
193
284
|
// callback
|
|
194
285
|
//-----------
|
|
195
286
|
onCheck?.(_res);
|
|
287
|
+
|
|
196
288
|
}
|
|
197
289
|
|
|
198
290
|
|
|
@@ -315,7 +407,7 @@ const TableFieldRow = (props: TableFieldRowProps) => {
|
|
|
315
407
|
value={`${rowKey}`}
|
|
316
408
|
checked={latestCheckedData().filter((cur: any) => cur.key === rowKey)[0]?.checked}
|
|
317
409
|
onChange={(e: any, val: any) => {
|
|
318
|
-
checkedAct(e, val);
|
|
410
|
+
checkedAct(e.target, val);
|
|
319
411
|
}}
|
|
320
412
|
/>
|
|
321
413
|
</>}
|
|
@@ -49,7 +49,9 @@ const TableHeaders = (props: TableHeadersProps) => {
|
|
|
49
49
|
} = props;
|
|
50
50
|
|
|
51
51
|
|
|
52
|
-
function checkedAct(
|
|
52
|
+
function checkedAct(el: any, val: any) {
|
|
53
|
+
|
|
54
|
+
if (el === null) return;
|
|
53
55
|
|
|
54
56
|
const _checkedData: any = getCheckedData;
|
|
55
57
|
let _res: any = getCheckedPrint;
|
|
@@ -74,7 +76,7 @@ const TableHeaders = (props: TableHeadersProps) => {
|
|
|
74
76
|
// STEP 2:
|
|
75
77
|
// All child checkboxes
|
|
76
78
|
//-----------
|
|
77
|
-
const _checkboxes = getChildren(
|
|
79
|
+
const _checkboxes = getChildren(el.closest('table').querySelector('tbody'), '[type="checkbox"]');
|
|
78
80
|
[].slice.call(_checkboxes).forEach((node: any) => {
|
|
79
81
|
if (val === true) {
|
|
80
82
|
setCheckboxCheckedData(_checkedData, node.dataset.key, true);
|
|
@@ -146,7 +148,7 @@ const TableHeaders = (props: TableHeadersProps) => {
|
|
|
146
148
|
value={`row-all`}
|
|
147
149
|
checked={getCheckedRootData!.filter((cur: any) => cur.key === 'row-all')[0]?.checked}
|
|
148
150
|
onChange={(e: any, val: any) => {
|
|
149
|
-
checkedAct(e, val);
|
|
151
|
+
checkedAct(e.target, val);
|
|
150
152
|
}}
|
|
151
153
|
/>
|
|
152
154
|
</span> : null}
|
|
@@ -10,7 +10,8 @@ import { formatPerlineControlVal } from './table-utils';
|
|
|
10
10
|
/* Table Row
|
|
11
11
|
-------------------------------------------------*/
|
|
12
12
|
type TableRowProps = {
|
|
13
|
-
|
|
13
|
+
tableRootRef: React.RefObject<any>;
|
|
14
|
+
tableCheckRef?: React.RefObject<any>;
|
|
14
15
|
rowActiveClassName?: string;
|
|
15
16
|
fieldsChecked?: boolean[] | boolean;
|
|
16
17
|
index: React.Key;
|
|
@@ -41,7 +42,8 @@ type TableRowProps = {
|
|
|
41
42
|
const TableRow = (props: TableRowProps) => {
|
|
42
43
|
|
|
43
44
|
const {
|
|
44
|
-
|
|
45
|
+
tableRootRef,
|
|
46
|
+
tableCheckRef,
|
|
45
47
|
rowActiveClassName = 'active',
|
|
46
48
|
fieldsChecked,
|
|
47
49
|
index,
|
|
@@ -122,7 +124,8 @@ const TableRow = (props: TableRowProps) => {
|
|
|
122
124
|
if ( i === 0 ) {
|
|
123
125
|
return <TableFieldRow
|
|
124
126
|
key={'th-row' + i}
|
|
125
|
-
|
|
127
|
+
tableRootRef={tableRootRef}
|
|
128
|
+
tableCheckRef={tableCheckRef}
|
|
126
129
|
rowActiveClassName={rowActiveClassName}
|
|
127
130
|
fieldsChecked={fieldsChecked}
|
|
128
131
|
updateFirstInitCheckboxesClassName={setFirstInitCheckboxesClassName}
|
package/lib/esm/Table/index.tsx
CHANGED
|
@@ -14,7 +14,7 @@ import { formatRowControlVal } from './table-utils';
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
type TableProps = {
|
|
17
|
-
|
|
17
|
+
tableCheckRef?: React.RefObject<any>;
|
|
18
18
|
wrapperClassName?: string;
|
|
19
19
|
tableClassName?: string;
|
|
20
20
|
bodyClassName?: string;
|
|
@@ -51,7 +51,7 @@ type TableProps = {
|
|
|
51
51
|
|
|
52
52
|
const Table = (props: TableProps) => {
|
|
53
53
|
const {
|
|
54
|
-
|
|
54
|
+
tableCheckRef,
|
|
55
55
|
wrapperClassName,
|
|
56
56
|
tableClassName,
|
|
57
57
|
bodyClassName,
|
|
@@ -576,7 +576,8 @@ const Table = (props: TableProps) => {
|
|
|
576
576
|
return <TableRow
|
|
577
577
|
key={i + String(mainUpdate)} // Trigger child component update when prop of parent changes
|
|
578
578
|
index={i}
|
|
579
|
-
|
|
579
|
+
tableRootRef={rootRef}
|
|
580
|
+
tableCheckRef={tableCheckRef}
|
|
580
581
|
rowActiveClassName={rowActiveClassName}
|
|
581
582
|
fieldsChecked={_fieldsChecked}
|
|
582
583
|
rowKey={`row-${i}`}
|
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": "
|
|
5
|
+
"version": "3.0.105",
|
|
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",
|