@stokr/components-library 2.3.44-beta.4 → 2.3.46
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/dist/components/AdminDashboard/Table/ReactTableWrapper.js +8 -2
- package/dist/components/ButtonContainer/ButtonContainer.styles.js +6 -1
- package/dist/components/CryptoAddress/CryptoAddress.js +6 -3
- package/dist/components/CryptoAddress/RadioWrap.js +2 -2
- package/dist/components/HeroBlock/HeroVideoBlock.js +108 -0
- package/dist/components/Modal/NewVentureModal/NewVentureModal.js +104 -265
- package/dist/components/Modal/NewVentureModal/NewVentureModal.stories.js +3 -2
- package/dist/context/AuthContext.js +159 -107
- package/dist/context/Checkbox/CheckboxContext.js +164 -0
- package/dist/hooks/useNewVentureForm.js +312 -0
- package/dist/index.js +11 -0
- package/package.json +1 -1
|
@@ -761,19 +761,70 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
761
761
|
return _ref14.apply(this, arguments);
|
|
762
762
|
};
|
|
763
763
|
}());
|
|
764
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
765
|
-
var
|
|
764
|
+
_defineProperty(_assertThisInitialized(_this), "checkIfUserSubscribedAll", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
765
|
+
var user,
|
|
766
|
+
returnData,
|
|
767
|
+
dataToSend,
|
|
768
|
+
result,
|
|
769
|
+
userCopy,
|
|
770
|
+
_args15 = arguments;
|
|
766
771
|
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
767
772
|
while (1) switch (_context15.prev = _context15.next) {
|
|
773
|
+
case 0:
|
|
774
|
+
user = _args15.length > 0 && _args15[0] !== undefined ? _args15[0] : _this.state.user;
|
|
775
|
+
returnData = _args15.length > 1 && _args15[1] !== undefined ? _args15[1] : false;
|
|
776
|
+
if (user) {
|
|
777
|
+
_context15.next = 4;
|
|
778
|
+
break;
|
|
779
|
+
}
|
|
780
|
+
return _context15.abrupt("return");
|
|
781
|
+
case 4:
|
|
782
|
+
_context15.prev = 4;
|
|
783
|
+
dataToSend = {
|
|
784
|
+
email: user.email
|
|
785
|
+
};
|
|
786
|
+
_context15.next = 8;
|
|
787
|
+
return _Auth.default.checkIfUserSubscribed(dataToSend);
|
|
788
|
+
case 8:
|
|
789
|
+
result = _context15.sent;
|
|
790
|
+
userCopy = _objectSpread({}, user);
|
|
791
|
+
userCopy.subscribedProjects = result;
|
|
792
|
+
if (!returnData) {
|
|
793
|
+
_context15.next = 15;
|
|
794
|
+
break;
|
|
795
|
+
}
|
|
796
|
+
return _context15.abrupt("return", userCopy);
|
|
797
|
+
case 15:
|
|
798
|
+
_this.setState({
|
|
799
|
+
user: userCopy
|
|
800
|
+
});
|
|
801
|
+
case 16:
|
|
802
|
+
_context15.next = 22;
|
|
803
|
+
break;
|
|
804
|
+
case 18:
|
|
805
|
+
_context15.prev = 18;
|
|
806
|
+
_context15.t0 = _context15["catch"](4);
|
|
807
|
+
console.log('🚀 ~ error in checkIfUserSubscribed', _context15.t0);
|
|
808
|
+
throw _context15.t0;
|
|
809
|
+
case 22:
|
|
810
|
+
case "end":
|
|
811
|
+
return _context15.stop();
|
|
812
|
+
}
|
|
813
|
+
}, _callee15, null, [[4, 18]]);
|
|
814
|
+
})));
|
|
815
|
+
_defineProperty(_assertThisInitialized(_this), "handleVerifyEmail", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
816
|
+
var location, query, oobCode, customToken, email;
|
|
817
|
+
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
818
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
768
819
|
case 0:
|
|
769
820
|
_this.setState({
|
|
770
821
|
isVerifyingEmail: true
|
|
771
822
|
});
|
|
772
823
|
location = _this.props.location;
|
|
773
824
|
query = new URLSearchParams(location.search);
|
|
774
|
-
|
|
825
|
+
_context16.prev = 3;
|
|
775
826
|
oobCode = query.get('oobCode');
|
|
776
|
-
|
|
827
|
+
_context16.next = 7;
|
|
777
828
|
return _Auth.default.handleVerifyEmail(oobCode);
|
|
778
829
|
case 7:
|
|
779
830
|
_this.setState({
|
|
@@ -783,188 +834,188 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
783
834
|
if (customToken) {
|
|
784
835
|
_this.loginUser(null, null, customToken);
|
|
785
836
|
}
|
|
786
|
-
|
|
837
|
+
_context16.next = 28;
|
|
787
838
|
break;
|
|
788
839
|
case 12:
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
840
|
+
_context16.prev = 12;
|
|
841
|
+
_context16.t0 = _context16["catch"](3);
|
|
842
|
+
_context16.t1 = _context16.t0 === null || _context16.t0 === void 0 ? void 0 : _context16.t0.code;
|
|
843
|
+
_context16.next = _context16.t1 === 'auth/expired-action-code' ? 17 : _context16.t1 === 'auth/invalid-action-code' ? 21 : _context16.t1 === 'auth/user-disabled' ? 23 : 25;
|
|
793
844
|
break;
|
|
794
845
|
case 17:
|
|
795
|
-
|
|
846
|
+
_context16.t0.message = 'The activation link has expired. We are sending you a new one right now.';
|
|
796
847
|
email = query.get('email');
|
|
797
848
|
if (email) {
|
|
798
|
-
|
|
849
|
+
_context16.t0.email = email;
|
|
799
850
|
//Auth.resendActivationEmail(email)
|
|
800
851
|
}
|
|
801
|
-
return
|
|
852
|
+
return _context16.abrupt("break", 26);
|
|
802
853
|
case 21:
|
|
803
|
-
|
|
804
|
-
return
|
|
854
|
+
_context16.t0.message = 'This link is invalid. Please try verifying email again.';
|
|
855
|
+
return _context16.abrupt("break", 26);
|
|
805
856
|
case 23:
|
|
806
|
-
|
|
807
|
-
return
|
|
857
|
+
_context16.t0.message = 'Your account has been disabled. Please contact our support.';
|
|
858
|
+
return _context16.abrupt("break", 26);
|
|
808
859
|
case 25:
|
|
809
|
-
return
|
|
860
|
+
return _context16.abrupt("break", 26);
|
|
810
861
|
case 26:
|
|
811
|
-
console.log('🚀 ~ file: AuthContext.js:446 ~ error:',
|
|
862
|
+
console.log('🚀 ~ file: AuthContext.js:446 ~ error:', _context16.t0);
|
|
812
863
|
_this.setState({
|
|
813
|
-
verifyEmailError:
|
|
864
|
+
verifyEmailError: _context16.t0,
|
|
814
865
|
isVerifyingEmail: false,
|
|
815
866
|
isFetchingUser: false
|
|
816
867
|
});
|
|
817
868
|
//throw error
|
|
818
869
|
case 28:
|
|
819
870
|
case "end":
|
|
820
|
-
return
|
|
871
|
+
return _context16.stop();
|
|
821
872
|
}
|
|
822
|
-
},
|
|
873
|
+
}, _callee16, null, [[3, 12]]);
|
|
823
874
|
})));
|
|
824
875
|
_defineProperty(_assertThisInitialized(_this), "handleResetPassword", /*#__PURE__*/function () {
|
|
825
|
-
var
|
|
876
|
+
var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(password) {
|
|
826
877
|
var location, query, oobCode;
|
|
827
|
-
return _regeneratorRuntime().wrap(function
|
|
828
|
-
while (1) switch (
|
|
878
|
+
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
879
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
829
880
|
case 0:
|
|
830
881
|
location = _this.props.location;
|
|
831
|
-
|
|
882
|
+
_context17.prev = 1;
|
|
832
883
|
query = new URLSearchParams(location.search);
|
|
833
884
|
oobCode = query.get('oobCode');
|
|
834
|
-
|
|
885
|
+
_context17.next = 6;
|
|
835
886
|
return _Auth.default.handleResetPassword(oobCode, password);
|
|
836
887
|
case 6:
|
|
837
|
-
|
|
888
|
+
_context17.next = 21;
|
|
838
889
|
break;
|
|
839
890
|
case 8:
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
891
|
+
_context17.prev = 8;
|
|
892
|
+
_context17.t0 = _context17["catch"](1);
|
|
893
|
+
_context17.t1 = _context17.t0 === null || _context17.t0 === void 0 ? void 0 : _context17.t0.code;
|
|
894
|
+
_context17.next = _context17.t1 === 'auth/expired-action-code' ? 13 : _context17.t1 === 'auth/invalid-action-code' ? 15 : _context17.t1 === 'auth/user-disabled' ? 17 : 19;
|
|
844
895
|
break;
|
|
845
896
|
case 13:
|
|
846
|
-
|
|
847
|
-
return
|
|
897
|
+
_context17.t0.message = 'This link has expired. Please try reseting password again.';
|
|
898
|
+
return _context17.abrupt("break", 20);
|
|
848
899
|
case 15:
|
|
849
|
-
|
|
850
|
-
return
|
|
900
|
+
_context17.t0.message = 'This link is invalid. Please try reseting password again.';
|
|
901
|
+
return _context17.abrupt("break", 20);
|
|
851
902
|
case 17:
|
|
852
|
-
|
|
853
|
-
return
|
|
903
|
+
_context17.t0.message = 'Your account has been disabled. Please contact our support.';
|
|
904
|
+
return _context17.abrupt("break", 20);
|
|
854
905
|
case 19:
|
|
855
|
-
return
|
|
906
|
+
return _context17.abrupt("break", 20);
|
|
856
907
|
case 20:
|
|
857
|
-
throw
|
|
908
|
+
throw _context17.t0;
|
|
858
909
|
case 21:
|
|
859
910
|
case "end":
|
|
860
|
-
return
|
|
911
|
+
return _context17.stop();
|
|
861
912
|
}
|
|
862
|
-
},
|
|
913
|
+
}, _callee17, null, [[1, 8]]);
|
|
863
914
|
}));
|
|
864
915
|
return function (_x18) {
|
|
865
|
-
return
|
|
916
|
+
return _ref17.apply(this, arguments);
|
|
866
917
|
};
|
|
867
918
|
}());
|
|
868
|
-
_defineProperty(_assertThisInitialized(_this), "sendWelcomeEmail", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
869
|
-
return _regeneratorRuntime().wrap(function
|
|
870
|
-
while (1) switch (
|
|
919
|
+
_defineProperty(_assertThisInitialized(_this), "sendWelcomeEmail", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
|
|
920
|
+
return _regeneratorRuntime().wrap(function _callee18$(_context18) {
|
|
921
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
871
922
|
case 0:
|
|
872
|
-
|
|
873
|
-
|
|
923
|
+
_context18.prev = 0;
|
|
924
|
+
_context18.next = 3;
|
|
874
925
|
return _Auth.default.sendWelcomeEmail();
|
|
875
926
|
case 3:
|
|
876
|
-
|
|
927
|
+
_context18.next = 8;
|
|
877
928
|
break;
|
|
878
929
|
case 5:
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
console.log("Error sending welcome email: ".concat(
|
|
930
|
+
_context18.prev = 5;
|
|
931
|
+
_context18.t0 = _context18["catch"](0);
|
|
932
|
+
console.log("Error sending welcome email: ".concat(_context18.t0));
|
|
882
933
|
// No need to throw error, let the app continue even if it fails
|
|
883
934
|
case 8:
|
|
884
935
|
case "end":
|
|
885
|
-
return
|
|
936
|
+
return _context18.stop();
|
|
886
937
|
}
|
|
887
|
-
},
|
|
938
|
+
}, _callee18, null, [[0, 5]]);
|
|
888
939
|
})));
|
|
889
940
|
_defineProperty(_assertThisInitialized(_this), "uploaProofOfAddress", /*#__PURE__*/function () {
|
|
890
|
-
var
|
|
941
|
+
var _ref19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(data, ip) {
|
|
891
942
|
var user;
|
|
892
|
-
return _regeneratorRuntime().wrap(function
|
|
893
|
-
while (1) switch (
|
|
943
|
+
return _regeneratorRuntime().wrap(function _callee19$(_context19) {
|
|
944
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
894
945
|
case 0:
|
|
895
|
-
|
|
896
|
-
|
|
946
|
+
_context19.prev = 0;
|
|
947
|
+
_context19.next = 3;
|
|
897
948
|
return _Auth.default.uploaProofOfAddress(data, ip);
|
|
898
949
|
case 3:
|
|
899
|
-
user =
|
|
950
|
+
user = _context19.sent;
|
|
900
951
|
_this.setUser(user);
|
|
901
|
-
|
|
952
|
+
_context19.next = 11;
|
|
902
953
|
break;
|
|
903
954
|
case 7:
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
console.log("Error uploading proof of address: ".concat(
|
|
907
|
-
throw
|
|
955
|
+
_context19.prev = 7;
|
|
956
|
+
_context19.t0 = _context19["catch"](0);
|
|
957
|
+
console.log("Error uploading proof of address: ".concat(_context19.t0));
|
|
958
|
+
throw _context19.t0;
|
|
908
959
|
case 11:
|
|
909
960
|
case "end":
|
|
910
|
-
return
|
|
961
|
+
return _context19.stop();
|
|
911
962
|
}
|
|
912
|
-
},
|
|
963
|
+
}, _callee19, null, [[0, 7]]);
|
|
913
964
|
}));
|
|
914
965
|
return function (_x19, _x20) {
|
|
915
|
-
return
|
|
966
|
+
return _ref19.apply(this, arguments);
|
|
916
967
|
};
|
|
917
968
|
}());
|
|
918
969
|
_defineProperty(_assertThisInitialized(_this), "validateGreenWalletId", /*#__PURE__*/function () {
|
|
919
|
-
var
|
|
920
|
-
return _regeneratorRuntime().wrap(function
|
|
921
|
-
while (1) switch (
|
|
970
|
+
var _ref20 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(id) {
|
|
971
|
+
return _regeneratorRuntime().wrap(function _callee20$(_context20) {
|
|
972
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
922
973
|
case 0:
|
|
923
|
-
|
|
924
|
-
|
|
974
|
+
_context20.prev = 0;
|
|
975
|
+
_context20.next = 3;
|
|
925
976
|
return _Auth.default.validateGreenWalletId(id);
|
|
926
977
|
case 3:
|
|
927
|
-
return
|
|
978
|
+
return _context20.abrupt("return", _context20.sent);
|
|
928
979
|
case 6:
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
console.log("Error validating Green Wallet ID: ".concat(
|
|
932
|
-
throw
|
|
980
|
+
_context20.prev = 6;
|
|
981
|
+
_context20.t0 = _context20["catch"](0);
|
|
982
|
+
console.log("Error validating Green Wallet ID: ".concat(_context20.t0));
|
|
983
|
+
throw _context20.t0;
|
|
933
984
|
case 10:
|
|
934
985
|
case "end":
|
|
935
|
-
return
|
|
986
|
+
return _context20.stop();
|
|
936
987
|
}
|
|
937
|
-
},
|
|
988
|
+
}, _callee20, null, [[0, 6]]);
|
|
938
989
|
}));
|
|
939
990
|
return function (_x21) {
|
|
940
|
-
return
|
|
991
|
+
return _ref20.apply(this, arguments);
|
|
941
992
|
};
|
|
942
993
|
}());
|
|
943
994
|
_defineProperty(_assertThisInitialized(_this), "createWallet", /*#__PURE__*/function () {
|
|
944
|
-
var
|
|
995
|
+
var _ref21 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(data) {
|
|
945
996
|
var wallet;
|
|
946
|
-
return _regeneratorRuntime().wrap(function
|
|
947
|
-
while (1) switch (
|
|
997
|
+
return _regeneratorRuntime().wrap(function _callee21$(_context21) {
|
|
998
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
948
999
|
case 0:
|
|
949
|
-
|
|
950
|
-
|
|
1000
|
+
_context21.prev = 0;
|
|
1001
|
+
_context21.next = 3;
|
|
951
1002
|
return _Auth.default.createWallet(data);
|
|
952
1003
|
case 3:
|
|
953
|
-
wallet =
|
|
954
|
-
return
|
|
1004
|
+
wallet = _context21.sent;
|
|
1005
|
+
return _context21.abrupt("return", wallet);
|
|
955
1006
|
case 7:
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
console.log("Error creating wallet: ".concat(
|
|
959
|
-
throw
|
|
1007
|
+
_context21.prev = 7;
|
|
1008
|
+
_context21.t0 = _context21["catch"](0);
|
|
1009
|
+
console.log("Error creating wallet: ".concat(_context21.t0));
|
|
1010
|
+
throw _context21.t0;
|
|
960
1011
|
case 11:
|
|
961
1012
|
case "end":
|
|
962
|
-
return
|
|
1013
|
+
return _context21.stop();
|
|
963
1014
|
}
|
|
964
|
-
},
|
|
1015
|
+
}, _callee21, null, [[0, 7]]);
|
|
965
1016
|
}));
|
|
966
1017
|
return function (_x22) {
|
|
967
|
-
return
|
|
1018
|
+
return _ref21.apply(this, arguments);
|
|
968
1019
|
};
|
|
969
1020
|
}());
|
|
970
1021
|
_defineProperty(_assertThisInitialized(_this), "setUser", function (user) {
|
|
@@ -976,12 +1027,12 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
976
1027
|
});
|
|
977
1028
|
});
|
|
978
1029
|
_defineProperty(_assertThisInitialized(_this), "fetchLastTime", /*#__PURE__*/function () {
|
|
979
|
-
var
|
|
1030
|
+
var _ref22 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(projectName, page, userId) {
|
|
980
1031
|
var filterBody, response;
|
|
981
|
-
return _regeneratorRuntime().wrap(function
|
|
982
|
-
while (1) switch (
|
|
1032
|
+
return _regeneratorRuntime().wrap(function _callee22$(_context22) {
|
|
1033
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
983
1034
|
case 0:
|
|
984
|
-
|
|
1035
|
+
_context22.prev = 0;
|
|
985
1036
|
filterBody = {
|
|
986
1037
|
projectName: projectName,
|
|
987
1038
|
page: page
|
|
@@ -989,25 +1040,25 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
989
1040
|
if (userId) {
|
|
990
1041
|
filterBody.userId = userId;
|
|
991
1042
|
}
|
|
992
|
-
|
|
1043
|
+
_context22.next = 5;
|
|
993
1044
|
return _Auth.default.fetchTrackingUserLastTime({
|
|
994
1045
|
filter: filterBody
|
|
995
1046
|
});
|
|
996
1047
|
case 5:
|
|
997
|
-
response =
|
|
998
|
-
return
|
|
1048
|
+
response = _context22.sent;
|
|
1049
|
+
return _context22.abrupt("return", response);
|
|
999
1050
|
case 9:
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
console.log(' error',
|
|
1051
|
+
_context22.prev = 9;
|
|
1052
|
+
_context22.t0 = _context22["catch"](0);
|
|
1053
|
+
console.log(' error', _context22.t0);
|
|
1003
1054
|
case 12:
|
|
1004
1055
|
case "end":
|
|
1005
|
-
return
|
|
1056
|
+
return _context22.stop();
|
|
1006
1057
|
}
|
|
1007
|
-
},
|
|
1058
|
+
}, _callee22, null, [[0, 9]]);
|
|
1008
1059
|
}));
|
|
1009
1060
|
return function (_x23, _x24, _x25) {
|
|
1010
|
-
return
|
|
1061
|
+
return _ref22.apply(this, arguments);
|
|
1011
1062
|
};
|
|
1012
1063
|
}());
|
|
1013
1064
|
return _this;
|
|
@@ -1047,6 +1098,7 @@ var AuthProviderClass = /*#__PURE__*/function (_Component) {
|
|
|
1047
1098
|
checkIfPrivateInvestor: this.checkIfPrivateInvestor,
|
|
1048
1099
|
checkPrivateInvestorAll: this.checkPrivateInvestorAll,
|
|
1049
1100
|
checkIfUserSubscribed: this.checkIfUserSubscribed,
|
|
1101
|
+
checkIfUserSubscribedAll: this.checkIfUserSubscribedAll,
|
|
1050
1102
|
sendWelcomeEmail: this.sendWelcomeEmail,
|
|
1051
1103
|
resendActivationEmail: _Auth.default.resendActivationEmail,
|
|
1052
1104
|
uploaProofOfAddress: this.uploaProofOfAddress,
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.useCheckboxes = exports.CheckboxProvider = void 0;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _fetchDataPublic = _interopRequireDefault(require("../../api/fetchDataPublic"));
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
12
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
16
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
17
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
18
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
19
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
20
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
21
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
22
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
23
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
24
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
25
|
+
var CheckboxContext = /*#__PURE__*/(0, _react.createContext)();
|
|
26
|
+
var CheckboxProvider = function CheckboxProvider(_ref) {
|
|
27
|
+
var children = _ref.children;
|
|
28
|
+
var _useState = (0, _react.useState)({}),
|
|
29
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
30
|
+
checkboxes = _useState2[0],
|
|
31
|
+
setCheckboxes = _useState2[1];
|
|
32
|
+
var _useState3 = (0, _react.useState)({}),
|
|
33
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
34
|
+
loadingStates = _useState4[0],
|
|
35
|
+
setLoadingStates = _useState4[1];
|
|
36
|
+
var fetchCheckboxes = /*#__PURE__*/function () {
|
|
37
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(key) {
|
|
38
|
+
var options,
|
|
39
|
+
group,
|
|
40
|
+
labels,
|
|
41
|
+
response,
|
|
42
|
+
_args = arguments;
|
|
43
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
44
|
+
while (1) switch (_context.prev = _context.next) {
|
|
45
|
+
case 0:
|
|
46
|
+
options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
|
|
47
|
+
group = options.group, labels = options.labels; // Don't fetch if already loading or already fetched
|
|
48
|
+
if (!(loadingStates[key] || checkboxes[key])) {
|
|
49
|
+
_context.next = 4;
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
return _context.abrupt("return");
|
|
53
|
+
case 4:
|
|
54
|
+
setLoadingStates(function (prev) {
|
|
55
|
+
return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, key, true));
|
|
56
|
+
});
|
|
57
|
+
_context.prev = 5;
|
|
58
|
+
if (!group) {
|
|
59
|
+
_context.next = 12;
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
_context.next = 9;
|
|
63
|
+
return (0, _fetchDataPublic.default)('compliance/get-checkbox-group', {
|
|
64
|
+
group: group
|
|
65
|
+
});
|
|
66
|
+
case 9:
|
|
67
|
+
response = _context.sent;
|
|
68
|
+
_context.next = 19;
|
|
69
|
+
break;
|
|
70
|
+
case 12:
|
|
71
|
+
if (!labels) {
|
|
72
|
+
_context.next = 18;
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
_context.next = 15;
|
|
76
|
+
return (0, _fetchDataPublic.default)('compliance/get-checkboxes', {
|
|
77
|
+
labels: labels
|
|
78
|
+
});
|
|
79
|
+
case 15:
|
|
80
|
+
response = _context.sent;
|
|
81
|
+
_context.next = 19;
|
|
82
|
+
break;
|
|
83
|
+
case 18:
|
|
84
|
+
throw new Error('Must provide either group or labels');
|
|
85
|
+
case 19:
|
|
86
|
+
setCheckboxes(function (prev) {
|
|
87
|
+
return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, key, response));
|
|
88
|
+
});
|
|
89
|
+
_context.next = 25;
|
|
90
|
+
break;
|
|
91
|
+
case 22:
|
|
92
|
+
_context.prev = 22;
|
|
93
|
+
_context.t0 = _context["catch"](5);
|
|
94
|
+
console.error("Failed to fetch checkboxes for key: ".concat(key), _context.t0);
|
|
95
|
+
case 25:
|
|
96
|
+
_context.prev = 25;
|
|
97
|
+
setLoadingStates(function (prev) {
|
|
98
|
+
return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, key, false));
|
|
99
|
+
});
|
|
100
|
+
return _context.finish(25);
|
|
101
|
+
case 28:
|
|
102
|
+
case "end":
|
|
103
|
+
return _context.stop();
|
|
104
|
+
}
|
|
105
|
+
}, _callee, null, [[5, 22, 25, 28]]);
|
|
106
|
+
}));
|
|
107
|
+
return function fetchCheckboxes(_x) {
|
|
108
|
+
return _ref2.apply(this, arguments);
|
|
109
|
+
};
|
|
110
|
+
}();
|
|
111
|
+
var getCheckboxes = function getCheckboxes(key) {
|
|
112
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
113
|
+
// Auto-fetch if not already loaded
|
|
114
|
+
if (!checkboxes[key] && !loadingStates[key]) {
|
|
115
|
+
fetchCheckboxes(key, options);
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
checkboxes: checkboxes[key] || null,
|
|
119
|
+
isLoading: loadingStates[key] || false,
|
|
120
|
+
refetch: function refetch() {
|
|
121
|
+
return fetchCheckboxes(key, options);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
var clearCheckboxes = function clearCheckboxes(key) {
|
|
126
|
+
if (key) {
|
|
127
|
+
// Clear specific key
|
|
128
|
+
setCheckboxes(function (prev) {
|
|
129
|
+
var newState = _objectSpread({}, prev);
|
|
130
|
+
delete newState[key];
|
|
131
|
+
return newState;
|
|
132
|
+
});
|
|
133
|
+
setLoadingStates(function (prev) {
|
|
134
|
+
var newState = _objectSpread({}, prev);
|
|
135
|
+
delete newState[key];
|
|
136
|
+
return newState;
|
|
137
|
+
});
|
|
138
|
+
} else {
|
|
139
|
+
// Clear all checkboxes
|
|
140
|
+
setCheckboxes({});
|
|
141
|
+
setLoadingStates({});
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
var value = {
|
|
145
|
+
getCheckboxes: getCheckboxes,
|
|
146
|
+
clearCheckboxes: clearCheckboxes
|
|
147
|
+
};
|
|
148
|
+
return /*#__PURE__*/React.createElement(CheckboxContext.Provider, {
|
|
149
|
+
value: value
|
|
150
|
+
}, children);
|
|
151
|
+
};
|
|
152
|
+
exports.CheckboxProvider = CheckboxProvider;
|
|
153
|
+
var useCheckboxes = function useCheckboxes(key) {
|
|
154
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
155
|
+
var context = (0, _react.useContext)(CheckboxContext);
|
|
156
|
+
if (!context) {
|
|
157
|
+
throw new Error('useCheckboxes must be used within CheckboxProvider');
|
|
158
|
+
}
|
|
159
|
+
if (!key) {
|
|
160
|
+
throw new Error('useCheckboxes requires a key parameter');
|
|
161
|
+
}
|
|
162
|
+
return context.getCheckboxes(key, options);
|
|
163
|
+
};
|
|
164
|
+
exports.useCheckboxes = useCheckboxes;
|