UNPKG

3.46 kBJavaScriptView Raw
1import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2import _createClass from "@babel/runtime/helpers/createClass";
3import _inherits from "@babel/runtime/helpers/inherits";
4import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
7function _createSuper(Derived) {
8 function isNativeReflectConstruct() {
9 if (typeof Reflect === "undefined" || !Reflect.construct) return false;
10 if (Reflect.construct.sham) return false;
11 if (typeof Proxy === "function") return true;
12
13 try {
14 Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
15 return true;
16 } catch (e) {
17 return false;
18 }
19 }
20
21 return function () {
22 var Super = _getPrototypeOf(Derived),
23 result;
24
25 if (isNativeReflectConstruct()) {
26 var NewTarget = _getPrototypeOf(this).constructor;
27
28 result = Reflect.construct(Super, arguments, NewTarget);
29 } else {
30 result = Super.apply(this, arguments);
31 }
32
33 return _possibleConstructorReturn(this, result);
34 };
35}
36
37/* tslint:disable */
38import React, { Component } from 'react';
39import Form from '../Form'; // test Form.create on component without own props
40
41var WithoutOwnProps =
42/*#__PURE__*/
43function (_Component) {
44 _inherits(WithoutOwnProps, _Component);
45
46 var _super = _createSuper(WithoutOwnProps);
47
48 function WithoutOwnProps() {
49 var _this;
50
51 _classCallCheck(this, WithoutOwnProps);
52
53 _this = _super.apply(this, arguments);
54 _this.state = {
55 foo: 'bar'
56 };
57 return _this;
58 }
59
60 _createClass(WithoutOwnProps, [{
61 key: "render",
62 value: function render() {
63 return React.createElement("div", null, "foo");
64 }
65 }]);
66
67 return WithoutOwnProps;
68}(Component);
69
70var WithoutOwnPropsForm = Form.create()(WithoutOwnProps);
71React.createElement(WithoutOwnPropsForm, null);
72
73var WithOwnProps =
74/*#__PURE__*/
75function (_Component2) {
76 _inherits(WithOwnProps, _Component2);
77
78 var _super2 = _createSuper(WithOwnProps);
79
80 function WithOwnProps() {
81 var _this2;
82
83 _classCallCheck(this, WithOwnProps);
84
85 _this2 = _super2.apply(this, arguments);
86 _this2.state = {
87 foo: 'bar'
88 };
89 return _this2;
90 }
91
92 _createClass(WithOwnProps, [{
93 key: "render",
94 value: function render() {
95 return React.createElement("div", null, "foo");
96 }
97 }]);
98
99 return WithOwnProps;
100}(Component);
101
102var WithOwnPropsForm = Form.create()(WithOwnProps);
103React.createElement(WithOwnPropsForm, {
104 name: "foo"
105});
106
107var WithCreateOptions =
108/*#__PURE__*/
109function (_Component3) {
110 _inherits(WithCreateOptions, _Component3);
111
112 var _super3 = _createSuper(WithCreateOptions);
113
114 function WithCreateOptions() {
115 _classCallCheck(this, WithCreateOptions);
116
117 return _super3.apply(this, arguments);
118 }
119
120 _createClass(WithCreateOptions, [{
121 key: "render",
122 value: function render() {
123 return React.createElement("div", null, "foo");
124 }
125 }]);
126
127 return WithCreateOptions;
128}(Component);
129
130var mapPropsToFields = function mapPropsToFields(props) {
131 var username = props.username;
132 return {
133 username: Form.createFormField({
134 value: username
135 })
136 };
137};
138
139var formOptions = {
140 mapPropsToFields: mapPropsToFields
141};
142var WithCreateOptionsForm = Form.create(formOptions)(WithCreateOptions);
143React.createElement(WithCreateOptionsForm, {
144 username: "foo"
145});
146//# sourceMappingURL=type.js.map