@kne/react-form-antd 2.0.14 → 2.0.17-alpha.0.0
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/LICENSE +21 -21
- package/README.md +35 -35
- package/dist/index.js +632 -25
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +625 -26
- package/dist/index.modern.js.map +1 -1
- package/package.json +89 -89
package/dist/index.js
CHANGED
|
@@ -61,7 +61,7 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
61
61
|
return target;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
var _excluded$
|
|
64
|
+
var _excluded$7 = ["className", "cache", "enterSubmit", "scrollToError", "scrollProps", "type", "size", "children"];
|
|
65
65
|
var ScrollToError = reactFormHelper.widget.ScrollToError,
|
|
66
66
|
EnterSubmit = reactFormHelper.widget.EnterSubmit,
|
|
67
67
|
FormStore = reactFormHelper.widget.FormStore,
|
|
@@ -76,7 +76,7 @@ var Form = React.forwardRef(function (_ref, ref) {
|
|
|
76
76
|
type = _ref.type,
|
|
77
77
|
size = _ref.size,
|
|
78
78
|
children = _ref.children,
|
|
79
|
-
props = _objectWithoutPropertiesLoose(_ref, _excluded$
|
|
79
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$7);
|
|
80
80
|
|
|
81
81
|
var computedClass = 'react-form';
|
|
82
82
|
|
|
@@ -446,17 +446,23 @@ var MonthPicker = antd.DatePicker.MonthPicker,
|
|
|
446
446
|
WeekPicker = antd.DatePicker.WeekPicker;
|
|
447
447
|
|
|
448
448
|
var _DatePicker = function _DatePicker(props) {
|
|
449
|
-
var render = useOnChange$8(
|
|
449
|
+
var render = useOnChange$8(Object.assign({
|
|
450
|
+
placeholder: "\u8BF7\u9009\u62E9" + props.label
|
|
451
|
+
}, props));
|
|
450
452
|
return render(antd.DatePicker);
|
|
451
453
|
};
|
|
452
454
|
|
|
453
455
|
var _MonthPicker = function _MonthPicker(props) {
|
|
454
|
-
var render = useOnChange$8(
|
|
456
|
+
var render = useOnChange$8(Object.assign({
|
|
457
|
+
placeholder: "\u8BF7\u9009\u62E9" + props.label
|
|
458
|
+
}, props));
|
|
455
459
|
return render(MonthPicker);
|
|
456
460
|
};
|
|
457
461
|
|
|
458
462
|
var _RangePicker$1 = function _RangePicker(props) {
|
|
459
|
-
var render = useOnChange$8(
|
|
463
|
+
var render = useOnChange$8(Object.assign({
|
|
464
|
+
placeholder: "\u8BF7\u9009\u62E9" + props.label
|
|
465
|
+
}, props)); // if(props.selectToday){
|
|
460
466
|
// return render(RangePickerToday);
|
|
461
467
|
// }
|
|
462
468
|
|
|
@@ -464,7 +470,9 @@ var _RangePicker$1 = function _RangePicker(props) {
|
|
|
464
470
|
};
|
|
465
471
|
|
|
466
472
|
var _WeekPicker = function _WeekPicker(props) {
|
|
467
|
-
var render = useOnChange$8(
|
|
473
|
+
var render = useOnChange$8(Object.assign({
|
|
474
|
+
placeholder: "\u8BF7\u9009\u62E9" + props.label
|
|
475
|
+
}, props));
|
|
468
476
|
return render(WeekPicker);
|
|
469
477
|
};
|
|
470
478
|
|
|
@@ -472,9 +480,13 @@ _DatePicker.MonthPicker = _MonthPicker;
|
|
|
472
480
|
_DatePicker.RangePicker = _RangePicker$1;
|
|
473
481
|
_DatePicker.WeekPicker = _WeekPicker;
|
|
474
482
|
|
|
483
|
+
var _excluded$6 = ["soFarButtonText"];
|
|
475
484
|
var useOnChange$7 = reactFormHelper.hooks.useOnChange;
|
|
476
485
|
|
|
477
|
-
var PickerToday = function PickerToday(
|
|
486
|
+
var PickerToday = function PickerToday(_ref) {
|
|
487
|
+
var soFarButtonText = _ref.soFarButtonText,
|
|
488
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$6);
|
|
489
|
+
|
|
478
490
|
// console.log('>>>>data', data);
|
|
479
491
|
var _useControlValue = useControlValue__default["default"](props),
|
|
480
492
|
data = _useControlValue[0],
|
|
@@ -519,7 +531,7 @@ var PickerToday = function PickerToday(props) {
|
|
|
519
531
|
ref_d.current.blur();
|
|
520
532
|
onChange([newData.start || '', '至今']);
|
|
521
533
|
}
|
|
522
|
-
},
|
|
534
|
+
}, soFarButtonText || '至今');
|
|
523
535
|
};
|
|
524
536
|
|
|
525
537
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
@@ -571,7 +583,9 @@ RangePickerToday.field = PickerToday;
|
|
|
571
583
|
var useDecorator$2 = reactFormHelper.hooks.useDecorator;
|
|
572
584
|
|
|
573
585
|
var InputField = function InputField(props) {
|
|
574
|
-
var render = useDecorator$2(
|
|
586
|
+
var render = useDecorator$2(Object.assign({
|
|
587
|
+
placeholder: "\u8BF7\u8F93\u5165" + props.label
|
|
588
|
+
}, props));
|
|
575
589
|
return render(antd.Input);
|
|
576
590
|
};
|
|
577
591
|
|
|
@@ -582,7 +596,9 @@ InputField.defaultProps = {
|
|
|
582
596
|
var useDecorator$1 = reactFormHelper.hooks.useDecorator;
|
|
583
597
|
|
|
584
598
|
var InputNumberField = function InputNumberField(props) {
|
|
585
|
-
var render = useDecorator$1(
|
|
599
|
+
var render = useDecorator$1(Object.assign({
|
|
600
|
+
placeholder: "\u8BF7\u8F93\u5165" + props.label
|
|
601
|
+
}, props));
|
|
586
602
|
return render(antd.InputNumber);
|
|
587
603
|
};
|
|
588
604
|
|
|
@@ -615,24 +631,582 @@ _RadioGroup.Radio = antd.Radio;
|
|
|
615
631
|
var useOnChange$5 = reactFormHelper.hooks.useOnChange;
|
|
616
632
|
|
|
617
633
|
var _Select = function _Select(props) {
|
|
618
|
-
var render = useOnChange$5(
|
|
634
|
+
var render = useOnChange$5(Object.assign({
|
|
635
|
+
placeholder: "\u8BF7\u9009\u62E9" + props.label
|
|
636
|
+
}, props));
|
|
619
637
|
return render(antd.Select);
|
|
620
638
|
};
|
|
621
639
|
|
|
622
640
|
_Select.Option = antd.Select.Option;
|
|
623
641
|
_Select.OptGroup = antd.Select.OptGroup;
|
|
624
642
|
|
|
625
|
-
|
|
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"];
|
|
626
1176
|
var useOnChange$4 = reactFormHelper.hooks.useOnChange;
|
|
627
1177
|
|
|
628
1178
|
var _SelectFetch = reactFetch.withFetch(function (_ref) {
|
|
629
1179
|
var data = _ref.data,
|
|
630
1180
|
setData = _ref.setData,
|
|
631
1181
|
refresh = _ref.refresh,
|
|
1182
|
+
reload = _ref.reload,
|
|
1183
|
+
emitter = _ref.emitter,
|
|
632
1184
|
isLoading = _ref.isLoading,
|
|
633
1185
|
children = _ref.children,
|
|
634
1186
|
props = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
635
1187
|
|
|
1188
|
+
var refreshRef = React.useRef(refresh);
|
|
1189
|
+
refreshRef.current = refresh;
|
|
1190
|
+
var reloadRef = React.useRef(reload);
|
|
1191
|
+
reloadRef.current = reload;
|
|
1192
|
+
var setDataRef = React.useRef(setData);
|
|
1193
|
+
setDataRef.current = setData;
|
|
1194
|
+
React.useEffect(function () {
|
|
1195
|
+
var token1 = emitter.addListener('select-fetch-refresh', function () {
|
|
1196
|
+
return refreshRef.current();
|
|
1197
|
+
});
|
|
1198
|
+
var token2 = emitter.addListener('select-fetch-reload', function () {
|
|
1199
|
+
return reloadRef.current();
|
|
1200
|
+
});
|
|
1201
|
+
var token3 = emitter.addListener('select-fetch-set-data', function () {
|
|
1202
|
+
return setDataRef.current();
|
|
1203
|
+
});
|
|
1204
|
+
return function () {
|
|
1205
|
+
token1 && token1.remove();
|
|
1206
|
+
token2 && token2.remove();
|
|
1207
|
+
token3 && token3.remove();
|
|
1208
|
+
};
|
|
1209
|
+
}, [emitter]);
|
|
636
1210
|
return /*#__PURE__*/React__default["default"].createElement(antd.Select, props, children({
|
|
637
1211
|
data: data,
|
|
638
1212
|
refresh: refresh,
|
|
@@ -641,11 +1215,28 @@ var _SelectFetch = reactFetch.withFetch(function (_ref) {
|
|
|
641
1215
|
}));
|
|
642
1216
|
});
|
|
643
1217
|
|
|
644
|
-
var SelectFetch$1 = function
|
|
645
|
-
var
|
|
1218
|
+
var SelectFetch$1 = React.forwardRef(function (props, ref) {
|
|
1219
|
+
var emitter = useEvent();
|
|
1220
|
+
React.useImperativeHandle(ref, function () {
|
|
1221
|
+
return {
|
|
1222
|
+
refresh: function refresh() {
|
|
1223
|
+
return emitter.emit('select-fetch-refresh');
|
|
1224
|
+
},
|
|
1225
|
+
reload: function reload() {
|
|
1226
|
+
return emitter.emit('select-fetch-reload');
|
|
1227
|
+
},
|
|
1228
|
+
setData: function setData(data) {
|
|
1229
|
+
return emitter.emit('select-fetch-set-data', data);
|
|
1230
|
+
}
|
|
1231
|
+
};
|
|
1232
|
+
}, [emitter]);
|
|
1233
|
+
var render = useOnChange$4(Object.assign({
|
|
1234
|
+
placeholder: "\u8BF7\u9009\u62E9" + props.label
|
|
1235
|
+
}, props, {
|
|
1236
|
+
emitter: emitter
|
|
1237
|
+
}));
|
|
646
1238
|
return render(_SelectFetch);
|
|
647
|
-
};
|
|
648
|
-
|
|
1239
|
+
});
|
|
649
1240
|
SelectFetch$1.Option = antd.Select.Option;
|
|
650
1241
|
SelectFetch$1.OptGroup = antd.Select.OptGroup;
|
|
651
1242
|
|
|
@@ -663,7 +1254,9 @@ var Switch$1 = function Switch(props) {
|
|
|
663
1254
|
var useDecorator = reactFormHelper.hooks.useDecorator;
|
|
664
1255
|
|
|
665
1256
|
var TextArea$1 = function TextArea(props) {
|
|
666
|
-
var render = useDecorator(
|
|
1257
|
+
var render = useDecorator(Object.assign({
|
|
1258
|
+
placeholder: "\u8BF7\u8F93\u5165" + props.label
|
|
1259
|
+
}, props));
|
|
667
1260
|
return render(antd.Input.TextArea);
|
|
668
1261
|
};
|
|
669
1262
|
|
|
@@ -671,12 +1264,16 @@ var useOnChange$2 = reactFormHelper.hooks.useOnChange;
|
|
|
671
1264
|
var RangePicker = antd.TimePicker.RangePicker;
|
|
672
1265
|
|
|
673
1266
|
var _TimePicker = function _TimePicker(props) {
|
|
674
|
-
var render = useOnChange$2(
|
|
1267
|
+
var render = useOnChange$2(Object.assign({
|
|
1268
|
+
placeholder: "\u8BF7\u9009\u62E9" + props.label
|
|
1269
|
+
}, props));
|
|
675
1270
|
return render(antd.TimePicker);
|
|
676
1271
|
};
|
|
677
1272
|
|
|
678
1273
|
var _RangePicker = function _RangePicker(props) {
|
|
679
|
-
var render = useOnChange$2(
|
|
1274
|
+
var render = useOnChange$2(Object.assign({
|
|
1275
|
+
placeholder: "\u8BF7\u9009\u62E9" + props.label
|
|
1276
|
+
}, props));
|
|
680
1277
|
return render(RangePicker);
|
|
681
1278
|
};
|
|
682
1279
|
|
|
@@ -685,7 +1282,9 @@ _TimePicker.RangePicker = _RangePicker;
|
|
|
685
1282
|
var useOnChange$1 = reactFormHelper.hooks.useOnChange;
|
|
686
1283
|
|
|
687
1284
|
var _TreeSelect = function _TreeSelect(props) {
|
|
688
|
-
var render = useOnChange$1(
|
|
1285
|
+
var render = useOnChange$1(Object.assign({
|
|
1286
|
+
placeholder: "\u8BF7\u9009\u62E9" + props.label
|
|
1287
|
+
}, props));
|
|
689
1288
|
return render(antd.TreeSelect);
|
|
690
1289
|
};
|
|
691
1290
|
|
|
@@ -861,20 +1460,28 @@ var UploadInput = function UploadInput(props) {
|
|
|
861
1460
|
|
|
862
1461
|
UploadInput.field = _Upload;
|
|
863
1462
|
|
|
864
|
-
var _excluded$2 = ["
|
|
1463
|
+
var _excluded$2 = ["realTime", "disabled"],
|
|
1464
|
+
_excluded2$1 = ["isPass", "isLoading"];
|
|
1465
|
+
|
|
1466
|
+
var SubmitButton = function SubmitButton(_ref) {
|
|
1467
|
+
var realTime = _ref.realTime,
|
|
1468
|
+
disabled = _ref.disabled,
|
|
1469
|
+
props = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
865
1470
|
|
|
866
|
-
var SubmitButton = function SubmitButton(props) {
|
|
867
1471
|
var _useSubmit = ReactForm.useSubmit(props),
|
|
1472
|
+
isPass = _useSubmit.isPass,
|
|
868
1473
|
isLoading = _useSubmit.isLoading,
|
|
869
|
-
submitProps = _objectWithoutPropertiesLoose(_useSubmit,
|
|
1474
|
+
submitProps = _objectWithoutPropertiesLoose(_useSubmit, _excluded2$1);
|
|
870
1475
|
|
|
871
1476
|
return /*#__PURE__*/React__default["default"].createElement(antd.Button, _extends({
|
|
872
|
-
loading: isLoading
|
|
1477
|
+
loading: isLoading,
|
|
1478
|
+
disabled: disabled || (realTime ? !isPass : false)
|
|
873
1479
|
}, submitProps, props));
|
|
874
1480
|
};
|
|
875
1481
|
|
|
876
1482
|
SubmitButton.defaultProps = {
|
|
877
|
-
type: 'primary'
|
|
1483
|
+
type: 'primary',
|
|
1484
|
+
disabled: false
|
|
878
1485
|
};
|
|
879
1486
|
|
|
880
1487
|
var ResetButton = function ResetButton(props) {
|