@kne/react-form-antd 2.0.17-alpha.0.0 → 2.0.19
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/index.js +28 -534
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +21 -534
- package/dist/index.modern.js.map +1 -1
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -11,6 +11,7 @@ var AvatarEditor = require('react-avatar-editor');
|
|
|
11
11
|
var moment = require('moment');
|
|
12
12
|
var useControlValue = require('@kne/use-control-value');
|
|
13
13
|
var reactFetch = require('@kne/react-fetch');
|
|
14
|
+
var useEvent = require('@kne/use-event');
|
|
14
15
|
var groupBy = require('lodash/groupBy');
|
|
15
16
|
var uniqueId = require('lodash/uniqueId');
|
|
16
17
|
|
|
@@ -25,6 +26,7 @@ var get__default = /*#__PURE__*/_interopDefaultLegacy(get);
|
|
|
25
26
|
var AvatarEditor__default = /*#__PURE__*/_interopDefaultLegacy(AvatarEditor);
|
|
26
27
|
var moment__default = /*#__PURE__*/_interopDefaultLegacy(moment);
|
|
27
28
|
var useControlValue__default = /*#__PURE__*/_interopDefaultLegacy(useControlValue);
|
|
29
|
+
var useEvent__default = /*#__PURE__*/_interopDefaultLegacy(useEvent);
|
|
28
30
|
var groupBy__default = /*#__PURE__*/_interopDefaultLegacy(groupBy);
|
|
29
31
|
var uniqueId__default = /*#__PURE__*/_interopDefaultLegacy(uniqueId);
|
|
30
32
|
|
|
@@ -640,539 +642,7 @@ var _Select = function _Select(props) {
|
|
|
640
642
|
_Select.Option = antd.Select.Option;
|
|
641
643
|
_Select.OptGroup = antd.Select.OptGroup;
|
|
642
644
|
|
|
643
|
-
|
|
644
|
-
* Copyright (c) 2014-present, Facebook, Inc.
|
|
645
|
-
* All rights reserved.
|
|
646
|
-
*
|
|
647
|
-
* This source code is licensed under the BSD-style license found in the
|
|
648
|
-
* LICENSE file in the root directory of this source tree. An additional grant
|
|
649
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
|
650
|
-
*
|
|
651
|
-
* @providesModule EventSubscription
|
|
652
|
-
* @typechecks
|
|
653
|
-
*/
|
|
654
|
-
/**
|
|
655
|
-
* EventSubscription represents a subscription to a particular event. It can
|
|
656
|
-
* remove its own subscription.
|
|
657
|
-
*/
|
|
658
|
-
|
|
659
|
-
var EventSubscription = /*#__PURE__*/function () {
|
|
660
|
-
/**
|
|
661
|
-
* @param {EventSubscriptionVendor} subscriber the subscriber that controls
|
|
662
|
-
* this subscription.
|
|
663
|
-
*/
|
|
664
|
-
function EventSubscription(subscriber) {
|
|
665
|
-
this.subscriber = subscriber;
|
|
666
|
-
}
|
|
667
|
-
/**
|
|
668
|
-
* Removes this subscription from the subscriber that controls it.
|
|
669
|
-
*/
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
var _proto = EventSubscription.prototype;
|
|
673
|
-
|
|
674
|
-
_proto.remove = function remove() {
|
|
675
|
-
if (this.subscriber) {
|
|
676
|
-
this.subscriber.removeSubscription(this);
|
|
677
|
-
this.subscriber = null;
|
|
678
|
-
}
|
|
679
|
-
};
|
|
680
|
-
|
|
681
|
-
return EventSubscription;
|
|
682
|
-
}();
|
|
683
|
-
|
|
684
|
-
var EventSubscription_1 = EventSubscription;
|
|
685
|
-
|
|
686
|
-
/**
|
|
687
|
-
* Copyright (c) 2014-present, Facebook, Inc.
|
|
688
|
-
* All rights reserved.
|
|
689
|
-
*
|
|
690
|
-
* This source code is licensed under the BSD-style license found in the
|
|
691
|
-
* LICENSE file in the root directory of this source tree. An additional grant
|
|
692
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
|
693
|
-
*
|
|
694
|
-
* @providesModule EmitterSubscription
|
|
695
|
-
* @typechecks
|
|
696
|
-
*/
|
|
697
|
-
|
|
698
|
-
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
/**
|
|
702
|
-
* EmitterSubscription represents a subscription with listener and context data.
|
|
703
|
-
*/
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
var EmitterSubscription = /*#__PURE__*/function (_EventSubscription) {
|
|
707
|
-
_inheritsLoose(EmitterSubscription, _EventSubscription);
|
|
708
|
-
|
|
709
|
-
/**
|
|
710
|
-
* @param {EventSubscriptionVendor} subscriber - The subscriber that controls
|
|
711
|
-
* this subscription
|
|
712
|
-
* @param {function} listener - Function to invoke when the specified event is
|
|
713
|
-
* emitted
|
|
714
|
-
* @param {*} context - Optional context object to use when invoking the
|
|
715
|
-
* listener
|
|
716
|
-
*/
|
|
717
|
-
function EmitterSubscription(subscriber, listener, context) {
|
|
718
|
-
var _this;
|
|
719
|
-
|
|
720
|
-
_this = _EventSubscription.call(this, subscriber) || this;
|
|
721
|
-
_this.listener = listener;
|
|
722
|
-
_this.context = context;
|
|
723
|
-
return _this;
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
return EmitterSubscription;
|
|
727
|
-
}(EventSubscription_1);
|
|
728
|
-
|
|
729
|
-
var EmitterSubscription_1 = EmitterSubscription;
|
|
730
|
-
|
|
731
|
-
/**
|
|
732
|
-
* Copyright (c) 2013-present, Facebook, Inc.
|
|
733
|
-
*
|
|
734
|
-
* This source code is licensed under the MIT license found in the
|
|
735
|
-
* LICENSE file in the root directory of this source tree.
|
|
736
|
-
*
|
|
737
|
-
*
|
|
738
|
-
*/
|
|
739
|
-
|
|
740
|
-
var validateFormat = process.env.NODE_ENV !== "production" ? function (format) {
|
|
741
|
-
if (format === undefined) {
|
|
742
|
-
throw new Error('invariant(...): Second argument must be a string.');
|
|
743
|
-
}
|
|
744
|
-
} : function (format) {};
|
|
745
|
-
/**
|
|
746
|
-
* Use invariant() to assert state which your program assumes to be true.
|
|
747
|
-
*
|
|
748
|
-
* Provide sprintf-style format (only %s is supported) and arguments to provide
|
|
749
|
-
* information about what broke and what you were expecting.
|
|
750
|
-
*
|
|
751
|
-
* The invariant message will be stripped in production, but the invariant will
|
|
752
|
-
* remain to ensure logic does not differ in production.
|
|
753
|
-
*/
|
|
754
|
-
|
|
755
|
-
function invariant(condition, format) {
|
|
756
|
-
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
757
|
-
args[_key - 2] = arguments[_key];
|
|
758
|
-
}
|
|
759
|
-
|
|
760
|
-
validateFormat(format);
|
|
761
|
-
|
|
762
|
-
if (!condition) {
|
|
763
|
-
var error;
|
|
764
|
-
|
|
765
|
-
if (format === undefined) {
|
|
766
|
-
error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
|
|
767
|
-
} else {
|
|
768
|
-
var argIndex = 0;
|
|
769
|
-
error = new Error(format.replace(/%s/g, function () {
|
|
770
|
-
return String(args[argIndex++]);
|
|
771
|
-
}));
|
|
772
|
-
error.name = 'Invariant Violation';
|
|
773
|
-
}
|
|
774
|
-
|
|
775
|
-
error.framesToPop = 1; // Skip invariant's own stack frame.
|
|
776
|
-
|
|
777
|
-
throw error;
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
|
|
781
|
-
var invariant_1 = invariant;
|
|
782
|
-
|
|
783
|
-
/**
|
|
784
|
-
* Copyright (c) 2014-present, Facebook, Inc.
|
|
785
|
-
* All rights reserved.
|
|
786
|
-
*
|
|
787
|
-
* This source code is licensed under the BSD-style license found in the
|
|
788
|
-
* LICENSE file in the root directory of this source tree. An additional grant
|
|
789
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
|
790
|
-
*
|
|
791
|
-
* @providesModule EventSubscriptionVendor
|
|
792
|
-
* @typechecks
|
|
793
|
-
*/
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
/**
|
|
797
|
-
* EventSubscriptionVendor stores a set of EventSubscriptions that are
|
|
798
|
-
* subscribed to a particular event type.
|
|
799
|
-
*/
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
var EventSubscriptionVendor = /*#__PURE__*/function () {
|
|
803
|
-
function EventSubscriptionVendor() {
|
|
804
|
-
this._subscriptionsForType = {};
|
|
805
|
-
this._currentSubscription = null;
|
|
806
|
-
}
|
|
807
|
-
/**
|
|
808
|
-
* Adds a subscription keyed by an event type.
|
|
809
|
-
*
|
|
810
|
-
* @param {string} eventType
|
|
811
|
-
* @param {EventSubscription} subscription
|
|
812
|
-
*/
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
var _proto = EventSubscriptionVendor.prototype;
|
|
816
|
-
|
|
817
|
-
_proto.addSubscription = function addSubscription(eventType, subscription) {
|
|
818
|
-
!(subscription.subscriber === this) ? process.env.NODE_ENV !== "production" ? invariant_1(false, 'The subscriber of the subscription is incorrectly set.') : invariant_1(false) : void 0;
|
|
819
|
-
|
|
820
|
-
if (!this._subscriptionsForType[eventType]) {
|
|
821
|
-
this._subscriptionsForType[eventType] = [];
|
|
822
|
-
}
|
|
823
|
-
|
|
824
|
-
var key = this._subscriptionsForType[eventType].length;
|
|
825
|
-
|
|
826
|
-
this._subscriptionsForType[eventType].push(subscription);
|
|
827
|
-
|
|
828
|
-
subscription.eventType = eventType;
|
|
829
|
-
subscription.key = key;
|
|
830
|
-
return subscription;
|
|
831
|
-
}
|
|
832
|
-
/**
|
|
833
|
-
* Removes a bulk set of the subscriptions.
|
|
834
|
-
*
|
|
835
|
-
* @param {?string} eventType - Optional name of the event type whose
|
|
836
|
-
* registered supscriptions to remove, if null remove all subscriptions.
|
|
837
|
-
*/
|
|
838
|
-
;
|
|
839
|
-
|
|
840
|
-
_proto.removeAllSubscriptions = function removeAllSubscriptions(eventType) {
|
|
841
|
-
if (eventType === undefined) {
|
|
842
|
-
this._subscriptionsForType = {};
|
|
843
|
-
} else {
|
|
844
|
-
delete this._subscriptionsForType[eventType];
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
/**
|
|
848
|
-
* Removes a specific subscription. Instead of calling this function, call
|
|
849
|
-
* `subscription.remove()` directly.
|
|
850
|
-
*
|
|
851
|
-
* @param {object} subscription
|
|
852
|
-
*/
|
|
853
|
-
;
|
|
854
|
-
|
|
855
|
-
_proto.removeSubscription = function removeSubscription(subscription) {
|
|
856
|
-
var eventType = subscription.eventType;
|
|
857
|
-
var key = subscription.key;
|
|
858
|
-
var subscriptionsForType = this._subscriptionsForType[eventType];
|
|
859
|
-
|
|
860
|
-
if (subscriptionsForType) {
|
|
861
|
-
delete subscriptionsForType[key];
|
|
862
|
-
}
|
|
863
|
-
}
|
|
864
|
-
/**
|
|
865
|
-
* Returns the array of subscriptions that are currently registered for the
|
|
866
|
-
* given event type.
|
|
867
|
-
*
|
|
868
|
-
* Note: This array can be potentially sparse as subscriptions are deleted
|
|
869
|
-
* from it when they are removed.
|
|
870
|
-
*
|
|
871
|
-
* TODO: This returns a nullable array. wat?
|
|
872
|
-
*
|
|
873
|
-
* @param {string} eventType
|
|
874
|
-
* @return {?array}
|
|
875
|
-
*/
|
|
876
|
-
;
|
|
877
|
-
|
|
878
|
-
_proto.getSubscriptionsForType = function getSubscriptionsForType(eventType) {
|
|
879
|
-
return this._subscriptionsForType[eventType];
|
|
880
|
-
};
|
|
881
|
-
|
|
882
|
-
return EventSubscriptionVendor;
|
|
883
|
-
}();
|
|
884
|
-
|
|
885
|
-
var EventSubscriptionVendor_1 = EventSubscriptionVendor;
|
|
886
|
-
|
|
887
|
-
/**
|
|
888
|
-
* Copyright (c) 2013-present, Facebook, Inc.
|
|
889
|
-
*
|
|
890
|
-
* This source code is licensed under the MIT license found in the
|
|
891
|
-
* LICENSE file in the root directory of this source tree.
|
|
892
|
-
*
|
|
893
|
-
*
|
|
894
|
-
*/
|
|
895
|
-
function makeEmptyFunction(arg) {
|
|
896
|
-
return function () {
|
|
897
|
-
return arg;
|
|
898
|
-
};
|
|
899
|
-
}
|
|
900
|
-
/**
|
|
901
|
-
* This function accepts and discards inputs; it has no side effects. This is
|
|
902
|
-
* primarily useful idiomatically for overridable function endpoints which
|
|
903
|
-
* always need to be callable, since JS lacks a null-call idiom ala Cocoa.
|
|
904
|
-
*/
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
var emptyFunction = function emptyFunction() {};
|
|
908
|
-
|
|
909
|
-
emptyFunction.thatReturns = makeEmptyFunction;
|
|
910
|
-
emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
|
|
911
|
-
emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
|
|
912
|
-
emptyFunction.thatReturnsNull = makeEmptyFunction(null);
|
|
913
|
-
|
|
914
|
-
emptyFunction.thatReturnsThis = function () {
|
|
915
|
-
return this;
|
|
916
|
-
};
|
|
917
|
-
|
|
918
|
-
emptyFunction.thatReturnsArgument = function (arg) {
|
|
919
|
-
return arg;
|
|
920
|
-
};
|
|
921
|
-
|
|
922
|
-
var emptyFunction_1 = emptyFunction;
|
|
923
|
-
|
|
924
|
-
/**
|
|
925
|
-
* Copyright (c) 2014-present, Facebook, Inc.
|
|
926
|
-
* All rights reserved.
|
|
927
|
-
*
|
|
928
|
-
* This source code is licensed under the BSD-style license found in the
|
|
929
|
-
* LICENSE file in the root directory of this source tree. An additional grant
|
|
930
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
|
931
|
-
*
|
|
932
|
-
* @providesModule BaseEventEmitter
|
|
933
|
-
* @typechecks
|
|
934
|
-
*/
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
/**
|
|
943
|
-
* @class BaseEventEmitter
|
|
944
|
-
* @description
|
|
945
|
-
* An EventEmitter is responsible for managing a set of listeners and publishing
|
|
946
|
-
* events to them when it is told that such events happened. In addition to the
|
|
947
|
-
* data for the given event it also sends a event control object which allows
|
|
948
|
-
* the listeners/handlers to prevent the default behavior of the given event.
|
|
949
|
-
*
|
|
950
|
-
* The emitter is designed to be generic enough to support all the different
|
|
951
|
-
* contexts in which one might want to emit events. It is a simple multicast
|
|
952
|
-
* mechanism on top of which extra functionality can be composed. For example, a
|
|
953
|
-
* more advanced emitter may use an EventHolder and EventFactory.
|
|
954
|
-
*/
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
var BaseEventEmitter = /*#__PURE__*/function () {
|
|
958
|
-
/**
|
|
959
|
-
* @constructor
|
|
960
|
-
*/
|
|
961
|
-
function BaseEventEmitter() {
|
|
962
|
-
this._subscriber = new EventSubscriptionVendor_1();
|
|
963
|
-
this._currentSubscription = null;
|
|
964
|
-
}
|
|
965
|
-
/**
|
|
966
|
-
* Adds a listener to be invoked when events of the specified type are
|
|
967
|
-
* emitted. An optional calling context may be provided. The data arguments
|
|
968
|
-
* emitted will be passed to the listener function.
|
|
969
|
-
*
|
|
970
|
-
* TODO: Annotate the listener arg's type. This is tricky because listeners
|
|
971
|
-
* can be invoked with varargs.
|
|
972
|
-
*
|
|
973
|
-
* @param {string} eventType - Name of the event to listen to
|
|
974
|
-
* @param {function} listener - Function to invoke when the specified event is
|
|
975
|
-
* emitted
|
|
976
|
-
* @param {*} context - Optional context object to use when invoking the
|
|
977
|
-
* listener
|
|
978
|
-
*/
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
var _proto = BaseEventEmitter.prototype;
|
|
982
|
-
|
|
983
|
-
_proto.addListener = function addListener(eventType, listener, context) {
|
|
984
|
-
return this._subscriber.addSubscription(eventType, new EmitterSubscription_1(this._subscriber, listener, context));
|
|
985
|
-
}
|
|
986
|
-
/**
|
|
987
|
-
* Similar to addListener, except that the listener is removed after it is
|
|
988
|
-
* invoked once.
|
|
989
|
-
*
|
|
990
|
-
* @param {string} eventType - Name of the event to listen to
|
|
991
|
-
* @param {function} listener - Function to invoke only once when the
|
|
992
|
-
* specified event is emitted
|
|
993
|
-
* @param {*} context - Optional context object to use when invoking the
|
|
994
|
-
* listener
|
|
995
|
-
*/
|
|
996
|
-
;
|
|
997
|
-
|
|
998
|
-
_proto.once = function once(eventType, listener, context) {
|
|
999
|
-
var emitter = this;
|
|
1000
|
-
return this.addListener(eventType, function () {
|
|
1001
|
-
emitter.removeCurrentListener();
|
|
1002
|
-
listener.apply(context, arguments);
|
|
1003
|
-
});
|
|
1004
|
-
}
|
|
1005
|
-
/**
|
|
1006
|
-
* Removes all of the registered listeners, including those registered as
|
|
1007
|
-
* listener maps.
|
|
1008
|
-
*
|
|
1009
|
-
* @param {?string} eventType - Optional name of the event whose registered
|
|
1010
|
-
* listeners to remove
|
|
1011
|
-
*/
|
|
1012
|
-
;
|
|
1013
|
-
|
|
1014
|
-
_proto.removeAllListeners = function removeAllListeners(eventType) {
|
|
1015
|
-
this._subscriber.removeAllSubscriptions(eventType);
|
|
1016
|
-
}
|
|
1017
|
-
/**
|
|
1018
|
-
* Provides an API that can be called during an eventing cycle to remove the
|
|
1019
|
-
* last listener that was invoked. This allows a developer to provide an event
|
|
1020
|
-
* object that can remove the listener (or listener map) during the
|
|
1021
|
-
* invocation.
|
|
1022
|
-
*
|
|
1023
|
-
* If it is called when not inside of an emitting cycle it will throw.
|
|
1024
|
-
*
|
|
1025
|
-
* @throws {Error} When called not during an eventing cycle
|
|
1026
|
-
*
|
|
1027
|
-
* @example
|
|
1028
|
-
* var subscription = emitter.addListenerMap({
|
|
1029
|
-
* someEvent: function(data, event) {
|
|
1030
|
-
* console.log(data);
|
|
1031
|
-
* emitter.removeCurrentListener();
|
|
1032
|
-
* }
|
|
1033
|
-
* });
|
|
1034
|
-
*
|
|
1035
|
-
* emitter.emit('someEvent', 'abc'); // logs 'abc'
|
|
1036
|
-
* emitter.emit('someEvent', 'def'); // does not log anything
|
|
1037
|
-
*/
|
|
1038
|
-
;
|
|
1039
|
-
|
|
1040
|
-
_proto.removeCurrentListener = function removeCurrentListener() {
|
|
1041
|
-
!!!this._currentSubscription ? process.env.NODE_ENV !== "production" ? invariant_1(false, 'Not in an emitting cycle; there is no current subscription') : invariant_1(false) : void 0;
|
|
1042
|
-
|
|
1043
|
-
this._subscriber.removeSubscription(this._currentSubscription);
|
|
1044
|
-
}
|
|
1045
|
-
/**
|
|
1046
|
-
* Returns an array of listeners that are currently registered for the given
|
|
1047
|
-
* event.
|
|
1048
|
-
*
|
|
1049
|
-
* @param {string} eventType - Name of the event to query
|
|
1050
|
-
* @return {array}
|
|
1051
|
-
*/
|
|
1052
|
-
;
|
|
1053
|
-
|
|
1054
|
-
_proto.listeners = function listeners(eventType)
|
|
1055
|
-
/* TODO: Array<EventSubscription> */
|
|
1056
|
-
{
|
|
1057
|
-
var subscriptions = this._subscriber.getSubscriptionsForType(eventType);
|
|
1058
|
-
|
|
1059
|
-
return subscriptions ? subscriptions.filter(emptyFunction_1.thatReturnsTrue).map(function (subscription) {
|
|
1060
|
-
return subscription.listener;
|
|
1061
|
-
}) : [];
|
|
1062
|
-
}
|
|
1063
|
-
/**
|
|
1064
|
-
* Emits an event of the given type with the given data. All handlers of that
|
|
1065
|
-
* particular type will be notified.
|
|
1066
|
-
*
|
|
1067
|
-
* @param {string} eventType - Name of the event to emit
|
|
1068
|
-
* @param {*} Arbitrary arguments to be passed to each registered listener
|
|
1069
|
-
*
|
|
1070
|
-
* @example
|
|
1071
|
-
* emitter.addListener('someEvent', function(message) {
|
|
1072
|
-
* console.log(message);
|
|
1073
|
-
* });
|
|
1074
|
-
*
|
|
1075
|
-
* emitter.emit('someEvent', 'abc'); // logs 'abc'
|
|
1076
|
-
*/
|
|
1077
|
-
;
|
|
1078
|
-
|
|
1079
|
-
_proto.emit = function emit(eventType) {
|
|
1080
|
-
var subscriptions = this._subscriber.getSubscriptionsForType(eventType);
|
|
1081
|
-
|
|
1082
|
-
if (subscriptions) {
|
|
1083
|
-
var keys = Object.keys(subscriptions);
|
|
1084
|
-
|
|
1085
|
-
for (var ii = 0; ii < keys.length; ii++) {
|
|
1086
|
-
var key = keys[ii];
|
|
1087
|
-
var subscription = subscriptions[key]; // The subscription may have been removed during this event loop.
|
|
1088
|
-
|
|
1089
|
-
if (subscription) {
|
|
1090
|
-
this._currentSubscription = subscription;
|
|
1091
|
-
|
|
1092
|
-
this.__emitToSubscription.apply(this, [subscription].concat(Array.prototype.slice.call(arguments)));
|
|
1093
|
-
}
|
|
1094
|
-
}
|
|
1095
|
-
|
|
1096
|
-
this._currentSubscription = null;
|
|
1097
|
-
}
|
|
1098
|
-
}
|
|
1099
|
-
/**
|
|
1100
|
-
* Provides a hook to override how the emitter emits an event to a specific
|
|
1101
|
-
* subscription. This allows you to set up logging and error boundaries
|
|
1102
|
-
* specific to your environment.
|
|
1103
|
-
*
|
|
1104
|
-
* @param {EmitterSubscription} subscription
|
|
1105
|
-
* @param {string} eventType
|
|
1106
|
-
* @param {*} Arbitrary arguments to be passed to each registered listener
|
|
1107
|
-
*/
|
|
1108
|
-
;
|
|
1109
|
-
|
|
1110
|
-
_proto.__emitToSubscription = function __emitToSubscription(subscription, eventType) {
|
|
1111
|
-
var args = Array.prototype.slice.call(arguments, 2);
|
|
1112
|
-
subscription.listener.apply(subscription.context, args);
|
|
1113
|
-
};
|
|
1114
|
-
|
|
1115
|
-
return BaseEventEmitter;
|
|
1116
|
-
}();
|
|
1117
|
-
|
|
1118
|
-
var BaseEventEmitter_1 = BaseEventEmitter;
|
|
1119
|
-
|
|
1120
|
-
/**
|
|
1121
|
-
* Copyright (c) 2014-present, Facebook, Inc.
|
|
1122
|
-
* All rights reserved.
|
|
1123
|
-
*
|
|
1124
|
-
* This source code is licensed under the BSD-style license found in the
|
|
1125
|
-
* LICENSE file in the root directory of this source tree. An additional grant
|
|
1126
|
-
* of patent rights can be found in the PATENTS file in the same directory.
|
|
1127
|
-
*/
|
|
1128
|
-
|
|
1129
|
-
var fbemitter = {
|
|
1130
|
-
EventEmitter: BaseEventEmitter_1,
|
|
1131
|
-
EmitterSubscription : EmitterSubscription_1
|
|
1132
|
-
};
|
|
1133
|
-
|
|
1134
|
-
var fbemitter_1 = fbemitter;
|
|
1135
|
-
|
|
1136
|
-
const {
|
|
1137
|
-
EventEmitter
|
|
1138
|
-
} = fbemitter_1;
|
|
1139
|
-
|
|
1140
|
-
class FormEventEmitter extends EventEmitter {
|
|
1141
|
-
constructor(options) {
|
|
1142
|
-
super();
|
|
1143
|
-
const {
|
|
1144
|
-
debug,
|
|
1145
|
-
name = 'event'
|
|
1146
|
-
} = Object.assign({}, options);
|
|
1147
|
-
this.debug = debug;
|
|
1148
|
-
this.name = name;
|
|
1149
|
-
}
|
|
1150
|
-
|
|
1151
|
-
emit(...args) {
|
|
1152
|
-
if (this.debug) {
|
|
1153
|
-
console.log(`[${this.name}][debug]:`, ...args);
|
|
1154
|
-
}
|
|
1155
|
-
|
|
1156
|
-
super.emit(...args);
|
|
1157
|
-
}
|
|
1158
|
-
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1161
|
-
const useEvent = debug => {
|
|
1162
|
-
const debugRef = React.useRef(debug);
|
|
1163
|
-
return React.useMemo(() => {
|
|
1164
|
-
const emitter = new FormEventEmitter(debugRef.current);
|
|
1165
|
-
return {
|
|
1166
|
-
addListener: (...args) => emitter.addListener(...args),
|
|
1167
|
-
emit: (...args) => emitter.emit(...args),
|
|
1168
|
-
removeAllListeners: (...args) => emitter.removeAllListeners(...args),
|
|
1169
|
-
listeners: (...args) => emitter.listeners(...args),
|
|
1170
|
-
once: (...args) => emitter.once(...args)
|
|
1171
|
-
};
|
|
1172
|
-
}, []);
|
|
1173
|
-
};
|
|
1174
|
-
|
|
1175
|
-
var _excluded$4 = ["data", "setData", "refresh", "reload", "emitter", "isLoading", "children"];
|
|
645
|
+
var _excluded$4 = ["data", "setData", "refresh", "reload", "emitter", "isLoading", "children", "onLoaded"];
|
|
1176
646
|
var useOnChange$4 = reactFormHelper.hooks.useOnChange;
|
|
1177
647
|
|
|
1178
648
|
var _SelectFetch = reactFetch.withFetch(function (_ref) {
|
|
@@ -1183,6 +653,7 @@ var _SelectFetch = reactFetch.withFetch(function (_ref) {
|
|
|
1183
653
|
emitter = _ref.emitter,
|
|
1184
654
|
isLoading = _ref.isLoading,
|
|
1185
655
|
children = _ref.children,
|
|
656
|
+
onLoaded = _ref.onLoaded,
|
|
1186
657
|
props = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
1187
658
|
|
|
1188
659
|
var refreshRef = React.useRef(refresh);
|
|
@@ -1191,6 +662,7 @@ var _SelectFetch = reactFetch.withFetch(function (_ref) {
|
|
|
1191
662
|
reloadRef.current = reload;
|
|
1192
663
|
var setDataRef = React.useRef(setData);
|
|
1193
664
|
setDataRef.current = setData;
|
|
665
|
+
var dataRef = React.useRef(data);
|
|
1194
666
|
React.useEffect(function () {
|
|
1195
667
|
var token1 = emitter.addListener('select-fetch-refresh', function () {
|
|
1196
668
|
return refreshRef.current();
|
|
@@ -1207,6 +679,9 @@ var _SelectFetch = reactFetch.withFetch(function (_ref) {
|
|
|
1207
679
|
token3 && token3.remove();
|
|
1208
680
|
};
|
|
1209
681
|
}, [emitter]);
|
|
682
|
+
React.useEffect(function () {
|
|
683
|
+
onLoaded && onLoaded(dataRef.current);
|
|
684
|
+
}, []);
|
|
1210
685
|
return /*#__PURE__*/React__default["default"].createElement(antd.Select, props, children({
|
|
1211
686
|
data: data,
|
|
1212
687
|
refresh: refresh,
|
|
@@ -1216,7 +691,7 @@ var _SelectFetch = reactFetch.withFetch(function (_ref) {
|
|
|
1216
691
|
});
|
|
1217
692
|
|
|
1218
693
|
var SelectFetch$1 = React.forwardRef(function (props, ref) {
|
|
1219
|
-
var emitter =
|
|
694
|
+
var emitter = useEvent__default["default"]();
|
|
1220
695
|
React.useImperativeHandle(ref, function () {
|
|
1221
696
|
return {
|
|
1222
697
|
refresh: function refresh() {
|
|
@@ -1237,6 +712,25 @@ var SelectFetch$1 = React.forwardRef(function (props, ref) {
|
|
|
1237
712
|
}));
|
|
1238
713
|
return render(_SelectFetch);
|
|
1239
714
|
});
|
|
715
|
+
SelectFetch$1.field = React.forwardRef(function (props, ref) {
|
|
716
|
+
var emitter = useEvent__default["default"]();
|
|
717
|
+
React.useImperativeHandle(ref, function () {
|
|
718
|
+
return {
|
|
719
|
+
refresh: function refresh() {
|
|
720
|
+
return emitter.emit('select-fetch-refresh');
|
|
721
|
+
},
|
|
722
|
+
reload: function reload() {
|
|
723
|
+
return emitter.emit('select-fetch-reload');
|
|
724
|
+
},
|
|
725
|
+
setData: function setData(data) {
|
|
726
|
+
return emitter.emit('select-fetch-set-data', data);
|
|
727
|
+
}
|
|
728
|
+
};
|
|
729
|
+
}, [emitter]);
|
|
730
|
+
return /*#__PURE__*/React__default["default"].createElement(_SelectFetch, _extends({}, props, {
|
|
731
|
+
emitter: emitter
|
|
732
|
+
}));
|
|
733
|
+
});
|
|
1240
734
|
SelectFetch$1.Option = antd.Select.Option;
|
|
1241
735
|
SelectFetch$1.OptGroup = antd.Select.OptGroup;
|
|
1242
736
|
|