@startlibs/form 1.0.0-alpha-10e → 1.0.0-alpha-10f
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/lib/index.js +31 -21
- package/package.json +3 -4
package/lib/index.js
CHANGED
|
@@ -3167,7 +3167,7 @@ var ConfirmEditableBoxes = React.forwardRef(function (_ref, ref) {
|
|
|
3167
3167
|
|
|
3168
3168
|
var modifiedEditablesPath = function modifiedEditablesPath(boxes) {
|
|
3169
3169
|
return modifiedEditableBoxes(boxes).map(function (_) {
|
|
3170
|
-
return _.path;
|
|
3170
|
+
return utils.callIfFunction(_.path);
|
|
3171
3171
|
});
|
|
3172
3172
|
};
|
|
3173
3173
|
|
|
@@ -3195,7 +3195,7 @@ var ConfirmEditableBoxes = React.forwardRef(function (_ref, ref) {
|
|
|
3195
3195
|
var validated = modifiedEditableBoxes(sharedBoxes()).reduce(function (_ref5, box) {
|
|
3196
3196
|
var success = _ref5.success,
|
|
3197
3197
|
errors = _ref5.errors;
|
|
3198
|
-
var index = box.path;
|
|
3198
|
+
var index = utils.callIfFunction(box.path);
|
|
3199
3199
|
|
|
3200
3200
|
var _box$modifiedValue = box.modifiedValue(),
|
|
3201
3201
|
_box$modifiedValue2 = _slicedToArray(_box$modifiedValue, 2),
|
|
@@ -3495,18 +3495,38 @@ var EditableBoxPresentation = styled__default(React.forwardRef(function (_ref13,
|
|
|
3495
3495
|
var SharedEditableTabBox = function SharedEditableTabBox(_ref15) {
|
|
3496
3496
|
var path = _ref15.path,
|
|
3497
3497
|
isSingle = _ref15.isSingle,
|
|
3498
|
-
|
|
3498
|
+
_ref15$checkIsNew = _ref15.checkIsNew,
|
|
3499
|
+
checkIsNew = _ref15$checkIsNew === void 0 ? function (a, b) {
|
|
3500
|
+
return a !== b;
|
|
3501
|
+
} : _ref15$checkIsNew,
|
|
3502
|
+
props = _objectWithoutProperties(_ref15, ["path", "isSingle", "checkIsNew"]);
|
|
3499
3503
|
|
|
3500
3504
|
var editableGroup = React.useContext(EditableContext);
|
|
3501
3505
|
var form = React.useContext(FormContext);
|
|
3502
|
-
var isNew = core.useRefState(
|
|
3506
|
+
var isNew = core.useRefState(function () {
|
|
3507
|
+
return isSingle ? false : checkIsNew(utils._s.get(path, form.getOriginalValues()), form.getValue(path));
|
|
3508
|
+
});
|
|
3503
3509
|
var internalBox = React__default.useRef();
|
|
3510
|
+
var pathRef = core.useRefMemo(path);
|
|
3504
3511
|
|
|
3505
3512
|
var loading = function loading() {
|
|
3506
3513
|
return internalBox.current.loading;
|
|
3507
3514
|
};
|
|
3508
3515
|
|
|
3509
|
-
var
|
|
3516
|
+
var modifiedValue = function modifiedValue() {
|
|
3517
|
+
var oldItem = internalBox.current.getValue(undefined, form.getOriginalValues());
|
|
3518
|
+
var newItem = internalBox.current.getValue();
|
|
3519
|
+
return newItem !== oldItem ? [newItem, true] : [oldItem, false];
|
|
3520
|
+
};
|
|
3521
|
+
|
|
3522
|
+
var selfRef = React.useRef({
|
|
3523
|
+
loading: loading,
|
|
3524
|
+
path: function path() {
|
|
3525
|
+
return pathRef.current;
|
|
3526
|
+
},
|
|
3527
|
+
form: form,
|
|
3528
|
+
modifiedValue: modifiedValue
|
|
3529
|
+
});
|
|
3510
3530
|
|
|
3511
3531
|
var resetField = function resetField() {
|
|
3512
3532
|
return form.resetField([].concat(path));
|
|
@@ -3526,12 +3546,6 @@ var SharedEditableTabBox = function SharedEditableTabBox(_ref15) {
|
|
|
3526
3546
|
editableGroup.sharedBoxes.register(selfRef.current);
|
|
3527
3547
|
};
|
|
3528
3548
|
|
|
3529
|
-
var modifiedValue = function modifiedValue() {
|
|
3530
|
-
var oldItem = internalBox.current.getValue(undefined, form.getOriginalValues());
|
|
3531
|
-
var newItem = internalBox.current.getValue();
|
|
3532
|
-
return newItem !== oldItem ? [newItem, true] : [oldItem, false];
|
|
3533
|
-
};
|
|
3534
|
-
|
|
3535
3549
|
var validate = function validate(props, path) {
|
|
3536
3550
|
var errors = editableGroup.itemValidation(props, path);
|
|
3537
3551
|
|
|
@@ -3622,12 +3636,6 @@ var SharedEditableTabBox = function SharedEditableTabBox(_ref15) {
|
|
|
3622
3636
|
}
|
|
3623
3637
|
};
|
|
3624
3638
|
|
|
3625
|
-
selfRef.current = {
|
|
3626
|
-
loading: loading,
|
|
3627
|
-
path: path,
|
|
3628
|
-
form: form,
|
|
3629
|
-
modifiedValue: modifiedValue
|
|
3630
|
-
};
|
|
3631
3639
|
return React__default.createElement(EditableBoxPresentation, _extends({
|
|
3632
3640
|
ref: internalBox,
|
|
3633
3641
|
resetField: resetField,
|
|
@@ -3651,7 +3659,6 @@ var EditableBox = function EditableBox(_ref17) {
|
|
|
3651
3659
|
|
|
3652
3660
|
var editableGroup = React.useContext(EditableContext);
|
|
3653
3661
|
var form = React.useContext(FormContext);
|
|
3654
|
-
var selfRef = React.useRef();
|
|
3655
3662
|
var internalBox = React__default.useRef();
|
|
3656
3663
|
|
|
3657
3664
|
var resetField = function resetField() {
|
|
@@ -3704,14 +3711,17 @@ var EditableBox = function EditableBox(_ref17) {
|
|
|
3704
3711
|
return internalBox.current.loading;
|
|
3705
3712
|
};
|
|
3706
3713
|
|
|
3707
|
-
|
|
3714
|
+
var pathRef = core.useRefMemo(path);
|
|
3715
|
+
var selfRef = React.useRef({
|
|
3708
3716
|
loading: loading,
|
|
3709
|
-
path: path
|
|
3717
|
+
path: function path() {
|
|
3718
|
+
return pathRef.current;
|
|
3719
|
+
},
|
|
3710
3720
|
form: form,
|
|
3711
3721
|
modifiedValue: modifiedValue,
|
|
3712
3722
|
handleSubmit: handleSubmit,
|
|
3713
3723
|
close: close
|
|
3714
|
-
};
|
|
3724
|
+
});
|
|
3715
3725
|
return React__default.createElement(EditableBoxPresentation, _extends({
|
|
3716
3726
|
ref: internalBox,
|
|
3717
3727
|
resetField: resetField,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@startlibs/form",
|
|
3
|
-
"version": "1.0.0-alpha-
|
|
3
|
+
"version": "1.0.0-alpha-10f",
|
|
4
4
|
"description": "Startlibs Form",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -8,9 +8,8 @@
|
|
|
8
8
|
"peerDependencies": {
|
|
9
9
|
"lodash": "^4.17.11",
|
|
10
10
|
"polished": "^1.1.3",
|
|
11
|
-
"react": "^
|
|
12
|
-
"react-dom": "^
|
|
13
|
-
"react-hot-loader": "^4.3.5",
|
|
11
|
+
"react": "^18.0",
|
|
12
|
+
"react-dom": "^18.0",
|
|
14
13
|
"styled-components": "^5.2.0"
|
|
15
14
|
},
|
|
16
15
|
"devDependencies": {
|