@kineticdata/react 5.1.2 → 6.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/assets/task/icons/drag-handle.svg +3 -0
- package/assets/task/icons/plus_small.svg +2 -4
- package/lib/apis/agent/adapters.js +16 -12
- package/lib/apis/agent/bridges.js +54 -41
- package/lib/apis/agent/handlers.js +51 -38
- package/lib/apis/core/activity.js +19 -11
- package/lib/apis/core/attributeDefinitions.js +54 -46
- package/lib/apis/core/attributeDefinitions.test.js +47 -55
- package/lib/apis/core/authentication.js +58 -63
- package/lib/apis/core/backgroundJobs.js +38 -30
- package/lib/apis/core/bridgeModelAttributeMappings.js +42 -34
- package/lib/apis/core/bridgeModelAttributes.js +47 -37
- package/lib/apis/core/bridgeModelMappings.js +42 -34
- package/lib/apis/core/bridgeModelQualificationMappings.js +42 -34
- package/lib/apis/core/bridgeModelQualifications.js +42 -34
- package/lib/apis/core/bridgeModels.js +56 -46
- package/lib/apis/core/bridgeModels.test.js +64 -80
- package/lib/apis/core/bridgedresources.js +64 -72
- package/lib/apis/core/bridgedresources.test.js +33 -30
- package/lib/apis/core/categories.js +59 -52
- package/lib/apis/core/categories.test.js +36 -33
- package/lib/apis/core/fileResources.js +41 -33
- package/lib/apis/core/filestores.js +42 -34
- package/lib/apis/core/formTypes.js +50 -44
- package/lib/apis/core/forms.js +53 -49
- package/lib/apis/core/forms.test.js +60 -74
- package/lib/apis/core/kapps.js +45 -39
- package/lib/apis/core/kapps.test.js +45 -52
- package/lib/apis/core/logs.js +20 -16
- package/lib/apis/core/memberships.js +23 -20
- package/lib/apis/core/meta.js +31 -19
- package/lib/apis/core/notices.js +17 -9
- package/lib/apis/core/oauthClients.js +49 -45
- package/lib/apis/core/platformComponents.js +73 -57
- package/lib/apis/core/platformItems.js +22 -13
- package/lib/apis/core/profile.js +28 -21
- package/lib/apis/core/profile.test.js +20 -17
- package/lib/apis/core/securityPolicyDefinitions.js +48 -41
- package/lib/apis/core/securityPolicyDefinitions.test.js +50 -60
- package/lib/apis/core/space.js +23 -16
- package/lib/apis/core/space.test.js +31 -38
- package/lib/apis/core/submissions.js +213 -186
- package/lib/apis/core/submissions.test.js +39 -36
- package/lib/apis/core/teams.js +51 -44
- package/lib/apis/core/teams.test.js +42 -39
- package/lib/apis/core/translations.js +123 -130
- package/lib/apis/core/translations.test.js +278 -368
- package/lib/apis/core/users.js +56 -49
- package/lib/apis/core/users.test.js +42 -39
- package/lib/apis/core/version.js +20 -11
- package/lib/apis/core/webApis.js +42 -34
- package/lib/apis/core/webhooks.js +48 -41
- package/lib/apis/core/webhooks.test.js +50 -60
- package/lib/apis/core/webhooksJobs.js +30 -26
- package/lib/apis/core/workflows.js +52 -44
- package/lib/apis/http.js +89 -80
- package/lib/apis/http.test.js +37 -38
- package/lib/apis/index.js +506 -50
- package/lib/apis/system/index.js +228 -211
- package/lib/apis/task/index.js +280 -227
- package/lib/components/agent/bridge/BridgeForm.js +50 -50
- package/lib/components/agent/bridge/BridgeTable.js +12 -8
- package/lib/components/agent/filestore/FilestoreForm.js +49 -48
- package/lib/components/agent/filestore/FilestoreTable.js +12 -8
- package/lib/components/agent/handler/AgentHandlerForm.js +24 -27
- package/lib/components/agent/handler/AgentHandlerTable.js +12 -8
- package/lib/components/common/AttributeSelect.js +15 -9
- package/lib/components/common/BridgeSelect.js +48 -43
- package/lib/components/common/ComponentConfigContext.js +9 -2
- package/lib/components/common/ContentEditable.js +36 -60
- package/lib/components/common/FormSelect.js +70 -58
- package/lib/components/common/NodeSelect.js +23 -19
- package/lib/components/common/Scroller.js +24 -23
- package/lib/components/common/StaticSelect.js +57 -50
- package/lib/components/common/TableInput.js +54 -57
- package/lib/components/common/TeamSelect.js +42 -39
- package/lib/components/common/Typeahead.js +121 -138
- package/lib/components/common/UserSelect.js +42 -41
- package/lib/components/common/authentication/AuthInterceptor.js +15 -19
- package/lib/components/common/authentication/AuthInterceptor.test.js +46 -64
- package/lib/components/common/authentication/AuthenticationContainer.js +350 -454
- package/lib/components/common/authentication/RequestInterceptor.js +16 -19
- package/lib/components/common/code_input/CodeInput.js +92 -122
- package/lib/components/common/code_input/draftHelpers.js +96 -90
- package/lib/components/common/code_input/languageHelpers.js +49 -47
- package/lib/components/common/code_input/languageHelpers.test.js +21 -16
- package/lib/components/core/CoreFormModal.js +26 -24
- package/lib/components/core/CoreModal.js +37 -31
- package/lib/components/core/attribute_definition/AttributeDefinitionForm.js +24 -23
- package/lib/components/core/attribute_definition/AttributeDefinitionTable.js +18 -15
- package/lib/components/core/bridge_model/BridgeModelForm.js +27 -37
- package/lib/components/core/bridge_model/BridgeModelTable.js +12 -8
- package/lib/components/core/bridge_model_attribute/BridgeModelAttributeForm.js +17 -16
- package/lib/components/core/bridge_model_attribute/BridgeModelAttributeTable.js +25 -21
- package/lib/components/core/bridge_model_qualification/BridgeModelQualificationForm.js +20 -20
- package/lib/components/core/bridge_model_qualification/BridgeModelQualificationTable.js +27 -22
- package/lib/components/core/category/CategoryForm.js +22 -22
- package/lib/components/core/category/CategoryTable.js +15 -10
- package/lib/components/core/core_form/CoreForm.js +209 -285
- package/lib/components/core/core_form/CoreForm.test.js +12 -10
- package/lib/components/core/core_form/defaults/index.js +52 -44
- package/lib/components/core/core_form/globals.js +14 -5
- package/lib/components/core/field_definition/FieldDefinitionForm.js +23 -21
- package/lib/components/core/field_definition/FieldDefinitionTable.js +15 -10
- package/lib/components/core/file_resource/FileResourceForm.js +38 -37
- package/lib/components/core/file_resource/FileResourceTable.js +16 -12
- package/lib/components/core/form/FormForm.js +56 -61
- package/lib/components/core/form/FormTable.js +25 -22
- package/lib/components/core/form_type/FormTypeForm.js +14 -13
- package/lib/components/core/form_type/FormTypeTable.js +12 -8
- package/lib/components/core/i18n/I18n.js +54 -61
- package/lib/components/core/i18n/I18nContext.js +9 -2
- package/lib/components/core/i18n/I18nProvider.js +40 -43
- package/lib/components/core/i18n/Moment.js +40 -50
- package/lib/components/core/index_definition/IndexDefinitionForm.js +23 -24
- package/lib/components/core/index_definition/IndexDefinitionTable.js +19 -11
- package/lib/components/core/index_job/IndexJobTable.js +20 -15
- package/lib/components/core/kapp/KappForm.js +57 -58
- package/lib/components/core/kapp/KappTable.js +17 -12
- package/lib/components/core/log/LogTable.js +35 -33
- package/lib/components/core/oauth_client/OAuthClientForm.js +17 -17
- package/lib/components/core/oauth_client/OAuthClientTable.js +12 -8
- package/lib/components/core/platform_component/AgentComponentForm.js +15 -15
- package/lib/components/core/platform_component/AgentComponentTable.js +10 -5
- package/lib/components/core/platform_component/TaskComponentForm.js +14 -14
- package/lib/components/core/profile/ProfileForm.js +40 -39
- package/lib/components/core/security_definition/SecurityDefinitionForm.js +28 -25
- package/lib/components/core/security_definition/SecurityDefinitionTable.js +18 -13
- package/lib/components/core/space/SpaceForm.js +79 -90
- package/lib/components/core/submission/DatastoreSubmissionFilters.js +39 -40
- package/lib/components/core/submission/DatastoreSubmissionTable.js +37 -34
- package/lib/components/core/submission/FormSubmissionFilters.js +79 -75
- package/lib/components/core/submission/FormSubmissionTable.js +27 -20
- package/lib/components/core/submission/KappSubmissionTable.js +30 -29
- package/lib/components/core/submission/SubmissionForm.js +126 -55
- package/lib/components/core/submission/SubmissionTable.js +24 -20
- package/lib/components/core/submission/helpers.js +37 -33
- package/lib/components/core/submission/helpers.test.js +69 -20
- package/lib/components/core/team/TeamForm.js +24 -21
- package/lib/components/core/team/TeamTable.js +16 -11
- package/lib/components/core/translation/ContextForm.js +13 -10
- package/lib/components/core/translation/ContextTable.js +13 -10
- package/lib/components/core/translation/EntryForm.js +27 -24
- package/lib/components/core/translation/EntryTable.js +19 -16
- package/lib/components/core/translation/LocaleForm.js +16 -13
- package/lib/components/core/translation/LocaleTable.js +12 -8
- package/lib/components/core/user/UserForm.js +38 -37
- package/lib/components/core/user/UserTable.js +19 -15
- package/lib/components/core/webapi/WebApiForm.js +49 -61
- package/lib/components/core/webapi/WebApiTable.js +14 -10
- package/lib/components/core/webhook/WebhookForm.js +33 -32
- package/lib/components/core/webhook/WebhookTable.js +22 -20
- package/lib/components/core/webhook_job/WebhookJobTable.js +19 -16
- package/lib/components/form/Form.helpers.js +102 -90
- package/lib/components/form/Form.js +467 -524
- package/lib/components/form/Form.models.js +38 -24
- package/lib/components/form/FormState.js +8 -5
- package/lib/components/form/KitchenSinkForm.js +135 -4
- package/lib/components/form/defaults/AttributesField.js +48 -59
- package/lib/components/form/defaults/CheckboxField.js +14 -6
- package/lib/components/form/defaults/CodeField.js +15 -7
- package/lib/components/form/defaults/FormButtons.js +12 -4
- package/lib/components/form/defaults/FormError.js +12 -4
- package/lib/components/form/defaults/FormField.js +15 -7
- package/lib/components/form/defaults/FormLayout.js +12 -4
- package/lib/components/form/defaults/FormMultiField.js +15 -7
- package/lib/components/form/defaults/PasswordField.js +14 -6
- package/lib/components/form/defaults/RadioField.js +15 -7
- package/lib/components/form/defaults/SampleTeamsRolesFIeld.js +17 -9
- package/lib/components/form/defaults/SelectField.js +16 -8
- package/lib/components/form/defaults/SelectMultiField.js +15 -7
- package/lib/components/form/defaults/TableField.js +14 -6
- package/lib/components/form/defaults/TeamField.js +15 -7
- package/lib/components/form/defaults/TeamMultiField.js +15 -7
- package/lib/components/form/defaults/TextField.js +14 -6
- package/lib/components/form/defaults/TextMultiField.js +26 -28
- package/lib/components/form/defaults/UserField.js +15 -7
- package/lib/components/form/defaults/UserMultiField.js +15 -7
- package/lib/components/form/defaults/index.js +48 -41
- package/lib/components/form/tests/Form.test.js +568 -864
- package/lib/components/form/tests/components.js +15 -25
- package/lib/components/form/tests/helpers.test.js +35 -33
- package/lib/components/index.js +981 -135
- package/lib/components/system/SystemBackgroundTasksTable.js +14 -10
- package/lib/components/system/SystemFilestoreForm.js +28 -25
- package/lib/components/system/SystemForm.js +19 -16
- package/lib/components/system/SystemIngressForm.js +10 -9
- package/lib/components/system/SystemSecurityForm.js +17 -14
- package/lib/components/system/SystemSmtpForm.js +13 -13
- package/lib/components/system/SystemTaskAdapterForm.js +21 -17
- package/lib/components/system/SystemUserForm.js +15 -14
- package/lib/components/system/helpers.js +62 -60
- package/lib/components/system/helpers.test.js +16 -12
- package/lib/components/system/spaces/SystemSpaceForm.js +25 -24
- package/lib/components/system/spaces/SystemTenantForm.js +43 -40
- package/lib/components/system/spaces/SystemTenantTable.js +12 -8
- package/lib/components/table/Table.js +211 -224
- package/lib/components/table/Table.redux.js +292 -329
- package/lib/components/table/Table.redux.test.js +49 -47
- package/lib/components/table/Table.test.js +107 -132
- package/lib/components/table/defaults/BodyCell.js +12 -6
- package/lib/components/table/defaults/BodyRow.js +10 -4
- package/lib/components/table/defaults/BooleanFilter.js +17 -11
- package/lib/components/table/defaults/EmptyBodyRow.js +12 -6
- package/lib/components/table/defaults/FilterLayout.js +17 -11
- package/lib/components/table/defaults/Footer.js +11 -5
- package/lib/components/table/defaults/FooterCell.js +10 -4
- package/lib/components/table/defaults/FooterRow.js +10 -4
- package/lib/components/table/defaults/Header.js +10 -4
- package/lib/components/table/defaults/HeaderCell.js +16 -10
- package/lib/components/table/defaults/HeaderRow.js +10 -4
- package/lib/components/table/defaults/PaginationControl.js +18 -9
- package/lib/components/table/defaults/TableBody.js +10 -4
- package/lib/components/table/defaults/TableLayout.js +12 -6
- package/lib/components/table/defaults/TextFilter.js +16 -10
- package/lib/components/table/defaults/index.js +41 -33
- package/lib/components/task/builder/Connector.js +100 -111
- package/lib/components/task/builder/ConnectorForm.js +17 -11
- package/lib/components/task/builder/Node.js +101 -83
- package/lib/components/task/builder/NodeForm.js +30 -27
- package/lib/components/task/builder/NodeParametersForm.js +27 -24
- package/lib/components/task/builder/SvgCanvas.js +67 -96
- package/lib/components/task/builder/SvgText.js +19 -134
- package/lib/components/task/builder/TaskDefinitionConfigForm.js +27 -22
- package/lib/components/task/builder/TreeBuilder.js +140 -115
- package/lib/components/task/builder/builder.redux.js +311 -326
- package/lib/components/task/builder/constants.js +94 -45
- package/lib/components/task/builder/helpers.js +184 -173
- package/lib/components/task/builder/helpers.test.js +20 -18
- package/lib/components/task/builder/models.js +121 -98
- package/lib/components/task/category/TaskCategoryForm.js +31 -29
- package/lib/components/task/category/TaskCategoryTable.js +12 -8
- package/lib/components/task/common/UsageTable.js +16 -12
- package/lib/components/task/engine/EngineSettingsForm.js +13 -11
- package/lib/components/task/errors/RunErrorTable.js +17 -13
- package/lib/components/task/errors/SystemErrorsTable.js +13 -9
- package/lib/components/task/handlers/HandlerForm.js +55 -55
- package/lib/components/task/handlers/HandlerTable.js +12 -8
- package/lib/components/task/handlers/MissingHandlerTable.js +12 -8
- package/lib/components/task/policy_rule/PolicyRuleForm.js +33 -32
- package/lib/components/task/policy_rule/PolicyRuleTable.js +12 -8
- package/lib/components/task/runs/CreateManualTriggerForm.js +17 -15
- package/lib/components/task/runs/RunTable.js +23 -20
- package/lib/components/task/runs/RunTaskTable.js +10 -6
- package/lib/components/task/sources/SourceForm.js +47 -47
- package/lib/components/task/sources/SourceTable.js +14 -11
- package/lib/components/task/triggers/TriggerTable.js +21 -18
- package/lib/components/task/workflows/LinkedWorkflowForm.js +48 -54
- package/lib/components/task/workflows/LinkedWorkflowTable.js +14 -10
- package/lib/components/task/workflows/MissingRoutineTable.js +12 -8
- package/lib/components/task/workflows/WorkflowForm.js +49 -44
- package/lib/components/task/workflows/WorkflowTable.js +17 -14
- package/lib/helpers/SearchBuilder.js +73 -127
- package/lib/helpers/SearchBuilder.test.js +184 -175
- package/lib/helpers/index.js +116 -74
- package/lib/index.js +86 -38
- package/lib/reducer.js +11 -3
- package/lib/saga.js +42 -38
- package/lib/store.js +59 -35
- package/package.json +3 -28
- package/proxyhelper.js +105 -46
- package/assets/discussions/images/avi_128.png +0 -0
- package/assets/discussions/images/excel_128.png +0 -0
- package/assets/discussions/images/html_128.png +0 -0
- package/assets/discussions/images/illustrator_128.png +0 -0
- package/assets/discussions/images/indesign_128.png +0 -0
- package/assets/discussions/images/movie_128.png +0 -0
- package/assets/discussions/images/mpeg_128.png +0 -0
- package/assets/discussions/images/pdf_128.png +0 -0
- package/assets/discussions/images/photoshop_128.png +0 -0
- package/assets/discussions/images/powerpoint_128.png +0 -0
- package/assets/discussions/images/txt_128.png +0 -0
- package/assets/discussions/images/unknown_128.png +0 -0
- package/assets/discussions/images/word_128.png +0 -0
- package/assets/discussions/styles/_discussion.scss +0 -506
- package/lib/apis/discussions/index.js +0 -395
- package/lib/apis/socket/index.js +0 -77
- package/lib/apis/socket/socket.js +0 -350
- package/lib/apis/socket/socket.test.js +0 -90
- package/lib/apis/socket/timer.js +0 -45
- package/lib/apis/socket/timer.test.js +0 -51
- package/lib/apis/socket/topic.js +0 -185
- package/lib/apis/topics/index.js +0 -19
- package/lib/components/discussions/ChatInputForm.js +0 -424
- package/lib/components/discussions/DateBanner.js +0 -10
- package/lib/components/discussions/Discussion.js +0 -202
- package/lib/components/discussions/DiscussionForm.js +0 -227
- package/lib/components/discussions/InvitationForm.js +0 -107
- package/lib/components/discussions/MessageHistory.js +0 -110
- package/lib/components/discussions/MessagesByDate.js +0 -40
- package/lib/components/discussions/MessagesList.js +0 -30
- package/lib/components/discussions/MoreMessagesBanner.js +0 -26
- package/lib/components/discussions/ScrollHelper.js +0 -84
- package/lib/components/discussions/SystemMessage.js +0 -88
- package/lib/components/discussions/SystemMessageGroup.js +0 -15
- package/lib/components/discussions/UserMessage.js +0 -163
- package/lib/components/discussions/UserMessageGroup.js +0 -34
- package/lib/components/discussions/redux.js +0 -178
- package/lib/components/discussions/sagas.js +0 -500
- package/lib/helpers/discussions/canManage.js +0 -30
- package/lib/helpers/discussions/canManage.test.js +0 -69
- package/lib/helpers/discussions/generateSystemMessageContent.js +0 -131
- package/lib/helpers/discussions/generateSystemMessageContent.test.js +0 -450
- package/lib/models/discussions.js +0 -76
- package/lib/models/index.js +0 -1
|
@@ -1,32 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
5
|
-
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
|
|
6
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
7
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
8
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
9
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
10
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
1
|
+
"use strict";
|
|
11
2
|
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
|
|
5
|
+
var _regeneratorRuntime3 = require("@babel/runtime/helpers/regeneratorRuntime")["default"];
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.validateField = exports.unmountForm = exports.toggleMultiValue = exports.submitForm = exports.setValue = exports.serializeForm = exports.resetForm = exports.reloadDataSource = exports.onSubmit = exports.onReset = exports.onFocus = exports.onChange = exports.onBlur = exports.mountForm = exports.mapStateToProps = exports.isEmpty = exports.getTimestamp = exports.generateForm = exports.evaluateFieldProps = exports.configureForm = exports.clearError = exports.checkRequired = exports.checkPattern = exports.checkConstraint = exports.Form = void 0;
|
|
10
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectWithoutProperties"));
|
|
11
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/classCallCheck"));
|
|
12
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/createClass"));
|
|
13
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/inherits"));
|
|
14
|
+
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/createSuper"));
|
|
15
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/defineProperty"));
|
|
16
|
+
var _objectSpread3 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
|
|
17
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/toConsumableArray"));
|
|
18
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
|
|
19
|
+
var _regeneratorRuntime2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/regeneratorRuntime"));
|
|
20
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
21
|
+
var _effects = require("redux-saga/effects");
|
|
22
|
+
var _immutable = require("immutable");
|
|
23
|
+
var _lodashEs = require("lodash-es");
|
|
24
|
+
var _store = require("../../store");
|
|
25
|
+
var _ComponentConfigContext = require("../common/ComponentConfigContext");
|
|
26
|
+
var _helpers = require("../../helpers");
|
|
27
|
+
var _Form = require("./Form.models");
|
|
28
|
+
var _Form2 = require("./Form.helpers");
|
|
29
|
+
var _excluded = ["components"];
|
|
30
|
+
var _marked = /*#__PURE__*/_regeneratorRuntime3().mark(runDataSource);
|
|
31
|
+
var getTimestamp = function getTimestamp() {
|
|
24
32
|
return Math.floor(new Date().getTime() / 1000);
|
|
25
33
|
};
|
|
26
|
-
|
|
27
|
-
|
|
34
|
+
exports.getTimestamp = getTimestamp;
|
|
35
|
+
var isEmpty = function isEmpty(value) {
|
|
36
|
+
return value === null || value === undefined || value === false || value === '' || (0, _immutable.isImmutable)(value) && value.isEmpty();
|
|
28
37
|
};
|
|
29
|
-
|
|
38
|
+
exports.isEmpty = isEmpty;
|
|
30
39
|
var reinitializeFields = function reinitializeFields(fields) {
|
|
31
40
|
return fields.map(function (field) {
|
|
32
41
|
return field.merge({
|
|
@@ -36,7 +45,6 @@ var reinitializeFields = function reinitializeFields(fields) {
|
|
|
36
45
|
});
|
|
37
46
|
});
|
|
38
47
|
};
|
|
39
|
-
|
|
40
48
|
var resetValues = function resetValues(fields) {
|
|
41
49
|
return fields.map(function (field) {
|
|
42
50
|
return field.merge({
|
|
@@ -46,62 +54,60 @@ var resetValues = function resetValues(fields) {
|
|
|
46
54
|
});
|
|
47
55
|
});
|
|
48
56
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return field.required && isEmpty(field.value) ? List([field.requiredMessage]) : List();
|
|
57
|
+
var checkRequired = function checkRequired(field) {
|
|
58
|
+
return field.required && isEmpty(field.value) ? (0, _immutable.List)([field.requiredMessage]) : (0, _immutable.List)();
|
|
52
59
|
};
|
|
53
|
-
|
|
54
|
-
|
|
60
|
+
exports.checkRequired = checkRequired;
|
|
61
|
+
var checkPattern = function checkPattern(field) {
|
|
62
|
+
return field.pattern && field.type === 'text' && field.value !== '' && !field.value.match(field.pattern) ? (0, _immutable.List)([field.patternMessage]) : (0, _immutable.List)();
|
|
55
63
|
};
|
|
56
|
-
|
|
64
|
+
exports.checkPattern = checkPattern;
|
|
65
|
+
var checkConstraint = function checkConstraint(bindings) {
|
|
57
66
|
return function (field) {
|
|
58
67
|
if (field.constraint) {
|
|
59
68
|
var result = field.constraint(bindings);
|
|
60
|
-
|
|
61
69
|
if (!result) {
|
|
62
|
-
return List([field.constraintMessage]);
|
|
70
|
+
return (0, _immutable.List)([field.constraintMessage]);
|
|
63
71
|
} else if (typeof result === 'string') {
|
|
64
|
-
return List([result]);
|
|
72
|
+
return (0, _immutable.List)([result]);
|
|
65
73
|
}
|
|
66
|
-
}
|
|
74
|
+
}
|
|
75
|
+
// Return no errors if there was no constraint or if the constraint did not
|
|
67
76
|
// evaluate to false or an error string.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
return List();
|
|
77
|
+
return (0, _immutable.List)();
|
|
71
78
|
};
|
|
72
79
|
};
|
|
73
|
-
|
|
80
|
+
exports.checkConstraint = checkConstraint;
|
|
81
|
+
var validateField = function validateField(bindings) {
|
|
74
82
|
return function (field) {
|
|
75
|
-
return field.set('errors', List([checkRequired, checkPattern, checkConstraint(bindings)]).flatMap(function (fn) {
|
|
83
|
+
return field.set('errors', (0, _immutable.List)([checkRequired, checkPattern, checkConstraint(bindings)]).flatMap(function (fn) {
|
|
76
84
|
return fn(field);
|
|
77
85
|
}));
|
|
78
86
|
};
|
|
79
87
|
};
|
|
80
|
-
|
|
88
|
+
exports.validateField = validateField;
|
|
89
|
+
var evaluateFieldProps = function evaluateFieldProps(bindings) {
|
|
81
90
|
return function (field) {
|
|
82
91
|
return field.functions.filter(function (fn) {
|
|
83
92
|
return !!fn;
|
|
84
93
|
}).reduce(function (reduction, fn, prop) {
|
|
85
|
-
return reduction.set(prop, fromJS(fn(bindings)));
|
|
94
|
+
return reduction.set(prop, (0, _immutable.fromJS)(fn(bindings)));
|
|
86
95
|
}, field);
|
|
87
96
|
};
|
|
88
97
|
};
|
|
89
|
-
|
|
98
|
+
exports.evaluateFieldProps = evaluateFieldProps;
|
|
90
99
|
var initializeFields = function initializeFields(formState) {
|
|
91
100
|
if (!formState.fields) {
|
|
92
|
-
var fields = resolveFieldConfig(formState.formOptions, formState.bindings, formState.fieldsFn, formState.addFields, formState.alterFields);
|
|
93
|
-
|
|
101
|
+
var fields = (0, _Form2.resolveFieldConfig)(formState.formOptions, formState.bindings, formState.fieldsFn, formState.addFields, formState.alterFields);
|
|
94
102
|
if (!!fields) {
|
|
95
|
-
return buildBindings(formState.set('fields', fields.map(createField(formState.formKey))).set('callOnLoad', true));
|
|
103
|
+
return buildBindings(formState.set('fields', fields.map((0, _Form2.createField)(formState.formKey))).set('callOnLoad', true));
|
|
96
104
|
}
|
|
97
105
|
}
|
|
98
|
-
|
|
99
106
|
return formState.set('callOnLoad', false);
|
|
100
107
|
};
|
|
101
|
-
|
|
102
108
|
var buildBindings = function buildBindings(formState) {
|
|
103
109
|
return formState.set('bindings', formState.dataSources.filter(function (dataSource) {
|
|
104
|
-
return dataSource.status === DATA_SOURCE_STATUS.RESOLVED;
|
|
110
|
+
return dataSource.status === _Form.DATA_SOURCE_STATUS.RESOLVED;
|
|
105
111
|
}).map(function (dataSource) {
|
|
106
112
|
return dataSource.data;
|
|
107
113
|
}).merge(formState.fields ? {
|
|
@@ -110,7 +116,6 @@ var buildBindings = function buildBindings(formState) {
|
|
|
110
116
|
})
|
|
111
117
|
} : {}).toObject());
|
|
112
118
|
};
|
|
113
|
-
|
|
114
119
|
var evaluateDataSources = function evaluateDataSources(formState) {
|
|
115
120
|
return formState.update('dataSources', function (dataSources) {
|
|
116
121
|
return dataSources.map(function (dataSource) {
|
|
@@ -118,20 +123,17 @@ var evaluateDataSources = function evaluateDataSources(formState) {
|
|
|
118
123
|
});
|
|
119
124
|
});
|
|
120
125
|
};
|
|
121
|
-
|
|
122
126
|
var evaluateFields = function evaluateFields(formState) {
|
|
123
127
|
return formState.fields ? formState.update('fields', function (fields) {
|
|
124
128
|
return fields.map(evaluateFieldProps(formState.bindings)).map(validateField(formState.bindings));
|
|
125
129
|
}) : formState;
|
|
126
130
|
};
|
|
127
|
-
|
|
128
131
|
var digest = function digest(formState) {
|
|
129
132
|
return formState && [buildBindings, initializeFields, evaluateFields, evaluateDataSources].reduce(function (reduction, fn) {
|
|
130
133
|
return fn(reduction);
|
|
131
134
|
}, formState);
|
|
132
135
|
};
|
|
133
|
-
|
|
134
|
-
regHandlers({
|
|
136
|
+
(0, _store.regHandlers)({
|
|
135
137
|
MOUNT_FORM: function MOUNT_FORM(state, _ref) {
|
|
136
138
|
var formKey = _ref.payload.formKey;
|
|
137
139
|
return state.setIn(['forms', formKey], null);
|
|
@@ -142,46 +144,46 @@ regHandlers({
|
|
|
142
144
|
},
|
|
143
145
|
CONFIGURE_FORM: function CONFIGURE_FORM(state, _ref3) {
|
|
144
146
|
var payload = _ref3.payload;
|
|
145
|
-
return state.getIn(['forms', payload.formKey]) !== null ? state.setIn(['forms', payload.formKey, 'callOnLoad'], false) : state.setIn(['forms', payload.formKey], digest(createFormState(payload)));
|
|
147
|
+
return state.getIn(['forms', payload.formKey]) !== null ? state.setIn(['forms', payload.formKey, 'callOnLoad'], false) : state.setIn(['forms', payload.formKey], digest((0, _Form2.createFormState)(payload)));
|
|
146
148
|
},
|
|
147
149
|
SET_VALUE: function SET_VALUE(state, _ref4) {
|
|
148
150
|
var _ref4$payload = _ref4.payload,
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
151
|
+
formKey = _ref4$payload.formKey,
|
|
152
|
+
name = _ref4$payload.name,
|
|
153
|
+
value = _ref4$payload.value;
|
|
152
154
|
return state.updateIn(['forms', formKey, 'fields', name], function (field) {
|
|
153
155
|
return field.merge({
|
|
154
|
-
value: value || FIELD_DEFAULT_VALUES.get(field.type, ''),
|
|
156
|
+
value: value || _Form.FIELD_DEFAULT_VALUES.get(field.type, ''),
|
|
155
157
|
touched: true,
|
|
156
|
-
dirty: !is(value, field.initialValue)
|
|
158
|
+
dirty: !(0, _immutable.is)(value, field.initialValue)
|
|
157
159
|
});
|
|
158
160
|
}).updateIn(['forms', formKey], digest);
|
|
159
161
|
},
|
|
160
162
|
TOGGLE_MULTI_VALUE: function TOGGLE_MULTI_VALUE(state, _ref5) {
|
|
161
163
|
var _ref5$payload = _ref5.payload,
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
164
|
+
formKey = _ref5$payload.formKey,
|
|
165
|
+
name = _ref5$payload.name,
|
|
166
|
+
value = _ref5$payload.value;
|
|
165
167
|
return state.updateIn(['forms', formKey, 'fields', name], function (field) {
|
|
166
168
|
return field.merge({
|
|
167
169
|
value: field.get('value').includes(value) ? field.get('value').filter(function (v) {
|
|
168
170
|
return v !== value;
|
|
169
171
|
}) : field.get('value').push(value),
|
|
170
172
|
touched: true,
|
|
171
|
-
dirty: !is(value, field.initialValue)
|
|
173
|
+
dirty: !(0, _immutable.is)(value, field.initialValue)
|
|
172
174
|
});
|
|
173
175
|
}).updateIn(['forms', formKey], digest);
|
|
174
176
|
},
|
|
175
177
|
FOCUS_FIELD: function FOCUS_FIELD(state, _ref6) {
|
|
176
178
|
var _ref6$payload = _ref6.payload,
|
|
177
|
-
|
|
178
|
-
|
|
179
|
+
formKey = _ref6$payload.formKey,
|
|
180
|
+
name = _ref6$payload.name;
|
|
179
181
|
return state.setIn(['forms', formKey, 'fields', name, 'focused'], true);
|
|
180
182
|
},
|
|
181
183
|
BLUR_FIELD: function BLUR_FIELD(state, _ref7) {
|
|
182
184
|
var _ref7$payload = _ref7.payload,
|
|
183
|
-
|
|
184
|
-
|
|
185
|
+
formKey = _ref7$payload.formKey,
|
|
186
|
+
name = _ref7$payload.name;
|
|
185
187
|
return state.mergeIn(['forms', formKey, 'fields', name], {
|
|
186
188
|
focused: false,
|
|
187
189
|
touched: true
|
|
@@ -189,21 +191,21 @@ regHandlers({
|
|
|
189
191
|
},
|
|
190
192
|
CALL_DATA_SOURCE: function CALL_DATA_SOURCE(state, _ref8) {
|
|
191
193
|
var _ref8$payload = _ref8.payload,
|
|
192
|
-
|
|
193
|
-
|
|
194
|
+
formKey = _ref8$payload.formKey,
|
|
195
|
+
name = _ref8$payload.name;
|
|
194
196
|
return state.mergeIn(['forms', formKey, 'dataSources', name], {
|
|
195
|
-
status: DATA_SOURCE_STATUS.PENDING
|
|
197
|
+
status: _Form.DATA_SOURCE_STATUS.PENDING
|
|
196
198
|
});
|
|
197
199
|
},
|
|
198
200
|
RESOLVE_DATA_SOURCE: function RESOLVE_DATA_SOURCE(state, _ref9) {
|
|
199
201
|
var _ref9$payload = _ref9.payload,
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
202
|
+
formKey = _ref9$payload.formKey,
|
|
203
|
+
name = _ref9$payload.name,
|
|
204
|
+
data = _ref9$payload.data;
|
|
203
205
|
return state.updateIn(['forms', formKey, 'dataSources', name], function (dataSource) {
|
|
204
206
|
return dataSource && dataSource.merge({
|
|
205
|
-
data: fromJS(data),
|
|
206
|
-
status: DATA_SOURCE_STATUS.RESOLVED
|
|
207
|
+
data: (0, _immutable.fromJS)(data),
|
|
208
|
+
status: _Form.DATA_SOURCE_STATUS.RESOLVED
|
|
207
209
|
});
|
|
208
210
|
}).updateIn(['forms', formKey], digest);
|
|
209
211
|
},
|
|
@@ -213,11 +215,11 @@ regHandlers({
|
|
|
213
215
|
},
|
|
214
216
|
SUBMIT: function SUBMIT(state, _ref11) {
|
|
215
217
|
var _ref11$payload = _ref11.payload,
|
|
216
|
-
|
|
217
|
-
|
|
218
|
+
formKey = _ref11$payload.formKey,
|
|
219
|
+
values = _ref11$payload.values;
|
|
218
220
|
return state.setIn(['forms', formKey, 'submitting'], true).updateIn(['forms', formKey, 'fields'], function (fields) {
|
|
219
|
-
return Map(values).reduce(function (fields, value, fieldName) {
|
|
220
|
-
return fields.setIn([fieldName, 'value'], value || FIELD_DEFAULT_VALUES.get(fields.getIn([fieldName, 'type']), ''));
|
|
221
|
+
return (0, _immutable.Map)(values).reduce(function (fields, value, fieldName) {
|
|
222
|
+
return fields.setIn([fieldName, 'value'], value || _Form.FIELD_DEFAULT_VALUES.get(fields.getIn([fieldName, 'type']), ''));
|
|
221
223
|
}, fields);
|
|
222
224
|
}).updateIn(['forms', formKey], digest);
|
|
223
225
|
},
|
|
@@ -227,8 +229,8 @@ regHandlers({
|
|
|
227
229
|
},
|
|
228
230
|
SUBMIT_ERROR: function SUBMIT_ERROR(state, _ref13) {
|
|
229
231
|
var _ref13$payload = _ref13.payload,
|
|
230
|
-
|
|
231
|
-
|
|
232
|
+
formKey = _ref13$payload.formKey,
|
|
233
|
+
error = _ref13$payload.error;
|
|
232
234
|
return state.setIn(['forms', formKey, 'submitting'], false).setIn(['forms', formKey, 'error'], error);
|
|
233
235
|
},
|
|
234
236
|
CLEAR_ERROR: function CLEAR_ERROR(state, _ref14) {
|
|
@@ -237,8 +239,8 @@ regHandlers({
|
|
|
237
239
|
},
|
|
238
240
|
SUBMIT_FIELD_ERRORS: function SUBMIT_FIELD_ERRORS(state, _ref15) {
|
|
239
241
|
var _ref15$payload = _ref15.payload,
|
|
240
|
-
|
|
241
|
-
|
|
242
|
+
formKey = _ref15$payload.formKey,
|
|
243
|
+
fieldNames = _ref15$payload.fieldNames;
|
|
242
244
|
return state.setIn(['forms', formKey, 'submitting'], false).setIn(['forms', formKey, 'error'], 'There are invalid fields').updateIn(['forms', formKey, 'fields'], function (fields) {
|
|
243
245
|
return fields.map(function (field) {
|
|
244
246
|
return fieldNames.includes(field.name) ? field.set('touched', true) : field;
|
|
@@ -246,66 +248,58 @@ regHandlers({
|
|
|
246
248
|
});
|
|
247
249
|
}
|
|
248
250
|
});
|
|
249
|
-
|
|
250
251
|
var selectForm = function selectForm(formKey) {
|
|
251
252
|
return function (state) {
|
|
252
253
|
return state.getIn(['forms', formKey]);
|
|
253
254
|
};
|
|
254
255
|
};
|
|
255
|
-
|
|
256
256
|
var selectDataSource = function selectDataSource(formKey, name) {
|
|
257
257
|
return function (state) {
|
|
258
258
|
return selectForm(formKey)(state).getIn(['dataSources', name]);
|
|
259
259
|
};
|
|
260
260
|
};
|
|
261
|
-
|
|
262
|
-
regSaga('CHECK_ON_LOAD', /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
261
|
+
(0, _store.regSaga)('CHECK_ON_LOAD', /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee2() {
|
|
263
262
|
var checkActions;
|
|
264
|
-
return
|
|
263
|
+
return (0, _regeneratorRuntime2["default"])().wrap(function _callee2$(_context2) {
|
|
265
264
|
while (1) {
|
|
266
265
|
switch (_context2.prev = _context2.next) {
|
|
267
266
|
case 0:
|
|
268
267
|
checkActions = ['CONFIGURE_FORM', 'RESOLVE_DATA_SOURCE'];
|
|
269
268
|
_context2.next = 3;
|
|
270
|
-
return takeEvery(checkActions,
|
|
271
|
-
var formKey
|
|
272
|
-
return
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
269
|
+
return (0, _effects.takeEvery)(checkActions, function (_ref16) {
|
|
270
|
+
var formKey = _ref16.payload.formKey;
|
|
271
|
+
return /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee() {
|
|
272
|
+
var formState;
|
|
273
|
+
return (0, _regeneratorRuntime2["default"])().wrap(function _callee$(_context) {
|
|
274
|
+
while (1) {
|
|
275
|
+
switch (_context.prev = _context.next) {
|
|
276
|
+
case 0:
|
|
277
|
+
_context.prev = 0;
|
|
278
|
+
_context.next = 3;
|
|
279
|
+
return (0, _effects.select)(selectForm(formKey));
|
|
280
|
+
case 3:
|
|
281
|
+
formState = _context.sent;
|
|
282
|
+
if (!(formState && formState.callOnLoad && typeof formState.onLoad === 'function')) {
|
|
283
|
+
_context.next = 7;
|
|
284
|
+
break;
|
|
285
|
+
}
|
|
286
|
+
_context.next = 7;
|
|
287
|
+
return (0, _effects.call)(formState.onLoad, formState.bindings);
|
|
288
|
+
case 7:
|
|
289
|
+
_context.next = 12;
|
|
286
290
|
break;
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
case 10:
|
|
297
|
-
_context.prev = 10;
|
|
298
|
-
_context.t0 = _context["catch"](1);
|
|
299
|
-
console.error(_context.t0);
|
|
300
|
-
|
|
301
|
-
case 13:
|
|
302
|
-
case "end":
|
|
303
|
-
return _context.stop();
|
|
291
|
+
case 9:
|
|
292
|
+
_context.prev = 9;
|
|
293
|
+
_context.t0 = _context["catch"](0);
|
|
294
|
+
console.error(_context.t0);
|
|
295
|
+
case 12:
|
|
296
|
+
case "end":
|
|
297
|
+
return _context.stop();
|
|
298
|
+
}
|
|
304
299
|
}
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
})
|
|
308
|
-
|
|
300
|
+
}, _callee, null, [[0, 9]]);
|
|
301
|
+
})();
|
|
302
|
+
});
|
|
309
303
|
case 3:
|
|
310
304
|
case "end":
|
|
311
305
|
return _context2.stop();
|
|
@@ -313,122 +307,104 @@ regSaga('CHECK_ON_LOAD', /*#__PURE__*/_regeneratorRuntime.mark(function _callee2
|
|
|
313
307
|
}
|
|
314
308
|
}, _callee2);
|
|
315
309
|
}));
|
|
316
|
-
regSaga(takeEvery('CONFIGURE_FORM', /*#__PURE__*/
|
|
310
|
+
(0, _store.regSaga)((0, _effects.takeEvery)('CONFIGURE_FORM', /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee3(action) {
|
|
317
311
|
var formKey, _yield$select, dataSources;
|
|
318
|
-
|
|
319
|
-
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
312
|
+
return (0, _regeneratorRuntime2["default"])().wrap(function _callee3$(_context3) {
|
|
320
313
|
while (1) {
|
|
321
314
|
switch (_context3.prev = _context3.next) {
|
|
322
315
|
case 0:
|
|
323
316
|
formKey = action.payload.formKey;
|
|
324
317
|
_context3.next = 3;
|
|
325
|
-
return select(selectForm(formKey));
|
|
326
|
-
|
|
318
|
+
return (0, _effects.select)(selectForm(formKey));
|
|
327
319
|
case 3:
|
|
328
320
|
_yield$select = _context3.sent;
|
|
329
321
|
dataSources = _yield$select.dataSources;
|
|
330
322
|
_context3.next = 7;
|
|
331
|
-
return all(dataSources.map(function (ds, name) {
|
|
332
|
-
return fork(runDataSource, formKey, name, ds);
|
|
323
|
+
return (0, _effects.all)(dataSources.map(function (ds, name) {
|
|
324
|
+
return (0, _effects.fork)(runDataSource, formKey, name, ds);
|
|
333
325
|
}).valueSeq().toArray());
|
|
334
|
-
|
|
335
326
|
case 7:
|
|
336
327
|
case "end":
|
|
337
328
|
return _context3.stop();
|
|
338
329
|
}
|
|
339
330
|
}
|
|
340
331
|
}, _callee3);
|
|
341
|
-
})));
|
|
332
|
+
})));
|
|
333
|
+
|
|
334
|
+
// Create a process that represents a datasource, it listens for form events
|
|
342
335
|
// and checks to see if its parameters have changed, if it detects parameter
|
|
343
336
|
// changes it should trigger a call to the datasource function. Finally, it
|
|
344
337
|
// listens for a UNMOUNT_FORM action to end the while-loop.
|
|
345
|
-
|
|
346
338
|
function runDataSource(formKey, name, dataSource) {
|
|
347
339
|
var params, paramsFn, prevParams, _yield$race, _yield$race2, checkAction, unmountAction, formState, _params, nextParams;
|
|
348
|
-
|
|
349
|
-
return _regeneratorRuntime.wrap(function runDataSource$(_context4) {
|
|
340
|
+
return (0, _regeneratorRuntime2["default"])().wrap(function runDataSource$(_context4) {
|
|
350
341
|
while (1) {
|
|
351
342
|
switch (_context4.prev = _context4.next) {
|
|
352
343
|
case 0:
|
|
353
344
|
params = dataSource.params, paramsFn = dataSource.paramsFn;
|
|
354
|
-
prevParams = fromJS(params);
|
|
355
|
-
|
|
345
|
+
prevParams = (0, _immutable.fromJS)(params);
|
|
356
346
|
if (!params) {
|
|
357
347
|
_context4.next = 5;
|
|
358
348
|
break;
|
|
359
349
|
}
|
|
360
|
-
|
|
361
350
|
_context4.next = 5;
|
|
362
|
-
return put(action('CALL_DATA_SOURCE', {
|
|
351
|
+
return (0, _effects.put)((0, _store.action)('CALL_DATA_SOURCE', {
|
|
363
352
|
formKey: formKey,
|
|
364
353
|
name: name,
|
|
365
354
|
params: params
|
|
366
355
|
}));
|
|
367
|
-
|
|
368
356
|
case 5:
|
|
369
357
|
if (!paramsFn) {
|
|
370
358
|
_context4.next = 29;
|
|
371
359
|
break;
|
|
372
360
|
}
|
|
373
|
-
|
|
374
361
|
case 6:
|
|
375
362
|
if (!true) {
|
|
376
363
|
_context4.next = 29;
|
|
377
364
|
break;
|
|
378
365
|
}
|
|
379
|
-
|
|
380
366
|
_context4.next = 9;
|
|
381
|
-
return race([take(['CONFIGURE_FORM', 'REJECT_DATA_SOURCE', 'RESET', 'RESOLVE_DATA_SOURCE', 'SET_VALUE', 'TOGGLE_MULTI_VALUE', 'SUBMIT_SUCCESS']), take('UNMOUNT_FORM')]);
|
|
382
|
-
|
|
367
|
+
return (0, _effects.race)([(0, _effects.take)(['CONFIGURE_FORM', 'REJECT_DATA_SOURCE', 'RESET', 'RESOLVE_DATA_SOURCE', 'SET_VALUE', 'TOGGLE_MULTI_VALUE', 'SUBMIT_SUCCESS']), (0, _effects.take)('UNMOUNT_FORM')]);
|
|
383
368
|
case 9:
|
|
384
369
|
_yield$race = _context4.sent;
|
|
385
|
-
_yield$race2 =
|
|
370
|
+
_yield$race2 = (0, _slicedToArray2["default"])(_yield$race, 2);
|
|
386
371
|
checkAction = _yield$race2[0];
|
|
387
372
|
unmountAction = _yield$race2[1];
|
|
388
|
-
|
|
389
373
|
if (!(unmountAction && unmountAction.payload.formKey === formKey)) {
|
|
390
374
|
_context4.next = 17;
|
|
391
375
|
break;
|
|
392
376
|
}
|
|
393
|
-
|
|
394
377
|
return _context4.abrupt("break", 29);
|
|
395
|
-
|
|
396
378
|
case 17:
|
|
397
379
|
if (!(checkAction && checkAction.payload.formKey === formKey)) {
|
|
398
380
|
_context4.next = 27;
|
|
399
381
|
break;
|
|
400
382
|
}
|
|
401
|
-
|
|
402
383
|
_context4.next = 20;
|
|
403
|
-
return select(selectForm(formKey));
|
|
404
|
-
|
|
384
|
+
return (0, _effects.select)(selectForm(formKey));
|
|
405
385
|
case 20:
|
|
406
386
|
formState = _context4.sent;
|
|
407
387
|
_params = formState.getIn(['dataSources', name, 'params']);
|
|
408
|
-
nextParams = fromJS(_params);
|
|
409
|
-
|
|
410
|
-
if (is(nextParams, prevParams)) {
|
|
388
|
+
nextParams = (0, _immutable.fromJS)(_params);
|
|
389
|
+
if ((0, _immutable.is)(nextParams, prevParams)) {
|
|
411
390
|
_context4.next = 27;
|
|
412
391
|
break;
|
|
413
392
|
}
|
|
414
|
-
|
|
415
393
|
prevParams = nextParams;
|
|
416
394
|
_context4.next = 27;
|
|
417
|
-
return put(_params ? action('CALL_DATA_SOURCE', {
|
|
395
|
+
return (0, _effects.put)(_params ? (0, _store.action)('CALL_DATA_SOURCE', {
|
|
418
396
|
formKey: formKey,
|
|
419
397
|
name: name,
|
|
420
398
|
params: _params
|
|
421
|
-
}) : action('RESOLVE_DATA_SOURCE', {
|
|
399
|
+
}) : (0, _store.action)('RESOLVE_DATA_SOURCE', {
|
|
422
400
|
formKey: formKey,
|
|
423
401
|
name: name,
|
|
424
402
|
data: null,
|
|
425
403
|
timestamp: null
|
|
426
404
|
}));
|
|
427
|
-
|
|
428
405
|
case 27:
|
|
429
406
|
_context4.next = 6;
|
|
430
407
|
break;
|
|
431
|
-
|
|
432
408
|
case 29:
|
|
433
409
|
case "end":
|
|
434
410
|
return _context4.stop();
|
|
@@ -436,112 +412,104 @@ function runDataSource(formKey, name, dataSource) {
|
|
|
436
412
|
}
|
|
437
413
|
}, _marked);
|
|
438
414
|
}
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
case 20:
|
|
484
|
-
case "end":
|
|
485
|
-
return _context5.stop();
|
|
415
|
+
(0, _store.regSaga)((0, _effects.takeEvery)('CALL_DATA_SOURCE', function (_ref17) {
|
|
416
|
+
var _ref17$payload = _ref17.payload,
|
|
417
|
+
formKey = _ref17$payload.formKey,
|
|
418
|
+
name = _ref17$payload.name,
|
|
419
|
+
params = _ref17$payload.params;
|
|
420
|
+
return /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee4() {
|
|
421
|
+
var _yield$select2, fn, transform, data, timestamp;
|
|
422
|
+
return (0, _regeneratorRuntime2["default"])().wrap(function _callee4$(_context5) {
|
|
423
|
+
while (1) {
|
|
424
|
+
switch (_context5.prev = _context5.next) {
|
|
425
|
+
case 0:
|
|
426
|
+
_context5.prev = 0;
|
|
427
|
+
_context5.next = 3;
|
|
428
|
+
return (0, _effects.select)(selectDataSource(formKey, name));
|
|
429
|
+
case 3:
|
|
430
|
+
_yield$select2 = _context5.sent;
|
|
431
|
+
fn = _yield$select2.fn;
|
|
432
|
+
transform = _yield$select2.transform;
|
|
433
|
+
_context5.next = 8;
|
|
434
|
+
return _effects.call.apply(void 0, [fn].concat((0, _toConsumableArray2["default"])(params)));
|
|
435
|
+
case 8:
|
|
436
|
+
data = _context5.sent;
|
|
437
|
+
_context5.next = 11;
|
|
438
|
+
return (0, _effects.call)(getTimestamp);
|
|
439
|
+
case 11:
|
|
440
|
+
timestamp = _context5.sent;
|
|
441
|
+
_context5.next = 14;
|
|
442
|
+
return (0, _effects.put)((0, _store.action)('RESOLVE_DATA_SOURCE', {
|
|
443
|
+
formKey: formKey,
|
|
444
|
+
name: name,
|
|
445
|
+
data: transform ? transform(data) : data,
|
|
446
|
+
timestamp: timestamp
|
|
447
|
+
}));
|
|
448
|
+
case 14:
|
|
449
|
+
_context5.next = 19;
|
|
450
|
+
break;
|
|
451
|
+
case 16:
|
|
452
|
+
_context5.prev = 16;
|
|
453
|
+
_context5.t0 = _context5["catch"](0);
|
|
454
|
+
console.error(_context5.t0);
|
|
455
|
+
case 19:
|
|
456
|
+
case "end":
|
|
457
|
+
return _context5.stop();
|
|
458
|
+
}
|
|
486
459
|
}
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
}))
|
|
490
|
-
regSaga('HANDLE_SET_VALUE', /*#__PURE__*/
|
|
491
|
-
return
|
|
460
|
+
}, _callee4, null, [[0, 16]]);
|
|
461
|
+
})();
|
|
462
|
+
}));
|
|
463
|
+
(0, _store.regSaga)('HANDLE_SET_VALUE', /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee6() {
|
|
464
|
+
return (0, _regeneratorRuntime2["default"])().wrap(function _callee6$(_context7) {
|
|
492
465
|
while (1) {
|
|
493
466
|
switch (_context7.prev = _context7.next) {
|
|
494
467
|
case 0:
|
|
495
468
|
_context7.next = 2;
|
|
496
|
-
return takeEvery(['SET_VALUE', 'TOGGLE_MULTI_VALUE'],
|
|
497
|
-
var _ref18$payload
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
_context6.
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
469
|
+
return (0, _effects.takeEvery)(['SET_VALUE', 'TOGGLE_MULTI_VALUE'], function (_ref18) {
|
|
470
|
+
var _ref18$payload = _ref18.payload,
|
|
471
|
+
formKey = _ref18$payload.formKey,
|
|
472
|
+
name = _ref18$payload.name,
|
|
473
|
+
triggerChange = _ref18$payload.triggerChange;
|
|
474
|
+
return /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee5() {
|
|
475
|
+
var _yield$select3, bindings, fields, _fields$get, _onChange;
|
|
476
|
+
return (0, _regeneratorRuntime2["default"])().wrap(function _callee5$(_context6) {
|
|
477
|
+
while (1) {
|
|
478
|
+
switch (_context6.prev = _context6.next) {
|
|
479
|
+
case 0:
|
|
480
|
+
_context6.prev = 0;
|
|
481
|
+
if (!triggerChange) {
|
|
482
|
+
_context6.next = 11;
|
|
483
|
+
break;
|
|
484
|
+
}
|
|
485
|
+
_context6.next = 4;
|
|
486
|
+
return (0, _effects.select)(selectForm(formKey));
|
|
487
|
+
case 4:
|
|
488
|
+
_yield$select3 = _context6.sent;
|
|
489
|
+
bindings = _yield$select3.bindings;
|
|
490
|
+
fields = _yield$select3.fields;
|
|
491
|
+
_fields$get = fields.get(name), _onChange = _fields$get.onChange;
|
|
492
|
+
if (!_onChange) {
|
|
493
|
+
_context6.next = 11;
|
|
494
|
+
break;
|
|
495
|
+
}
|
|
496
|
+
_context6.next = 11;
|
|
497
|
+
return (0, _effects.call)(_onChange, bindings, bindActions(formKey));
|
|
498
|
+
case 11:
|
|
499
|
+
_context6.next = 16;
|
|
522
500
|
break;
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
case 14:
|
|
533
|
-
_context6.prev = 14;
|
|
534
|
-
_context6.t0 = _context6["catch"](1);
|
|
535
|
-
console.error(_context6.t0);
|
|
536
|
-
|
|
537
|
-
case 17:
|
|
538
|
-
case "end":
|
|
539
|
-
return _context6.stop();
|
|
501
|
+
case 13:
|
|
502
|
+
_context6.prev = 13;
|
|
503
|
+
_context6.t0 = _context6["catch"](0);
|
|
504
|
+
console.error(_context6.t0);
|
|
505
|
+
case 16:
|
|
506
|
+
case "end":
|
|
507
|
+
return _context6.stop();
|
|
508
|
+
}
|
|
540
509
|
}
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
})
|
|
544
|
-
|
|
510
|
+
}, _callee5, null, [[0, 13]]);
|
|
511
|
+
})();
|
|
512
|
+
});
|
|
545
513
|
case 2:
|
|
546
514
|
case "end":
|
|
547
515
|
return _context7.stop();
|
|
@@ -549,155 +517,144 @@ regSaga('HANDLE_SET_VALUE', /*#__PURE__*/_regeneratorRuntime.mark(function _call
|
|
|
549
517
|
}
|
|
550
518
|
}, _callee6);
|
|
551
519
|
}));
|
|
552
|
-
regSaga(takeEvery('REJECT_DATA_SOURCE',
|
|
553
|
-
var payload;
|
|
554
|
-
return
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
520
|
+
(0, _store.regSaga)((0, _effects.takeEvery)('REJECT_DATA_SOURCE', function (_ref19) {
|
|
521
|
+
var payload = _ref19.payload;
|
|
522
|
+
return /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee7() {
|
|
523
|
+
return (0, _regeneratorRuntime2["default"])().wrap(function _callee7$(_context8) {
|
|
524
|
+
while (1) {
|
|
525
|
+
switch (_context8.prev = _context8.next) {
|
|
526
|
+
case 0:
|
|
527
|
+
_context8.next = 2;
|
|
528
|
+
return (0, _effects.call)(console.error, 'REJECT_DATA_SOURCE', payload);
|
|
529
|
+
case 2:
|
|
530
|
+
case "end":
|
|
531
|
+
return _context8.stop();
|
|
532
|
+
}
|
|
565
533
|
}
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
}))
|
|
569
|
-
regSaga(takeEvery('SUBMIT',
|
|
570
|
-
var _ref20$payload
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
534
|
+
}, _callee7);
|
|
535
|
+
})();
|
|
536
|
+
}));
|
|
537
|
+
(0, _store.regSaga)((0, _effects.takeEvery)('SUBMIT', function (_ref20) {
|
|
538
|
+
var _ref20$payload = _ref20.payload,
|
|
539
|
+
formKey = _ref20$payload.formKey,
|
|
540
|
+
fieldSet = _ref20$payload.fieldSet,
|
|
541
|
+
onInvalid = _ref20$payload.onInvalid;
|
|
542
|
+
return /*#__PURE__*/(0, _regeneratorRuntime2["default"])().mark(function _callee8() {
|
|
543
|
+
var _yield$select4, bindings, fields, _onSubmit, onSave, onError, computedFieldSet, values, errors, result;
|
|
544
|
+
return (0, _regeneratorRuntime2["default"])().wrap(function _callee8$(_context9) {
|
|
545
|
+
while (1) {
|
|
546
|
+
switch (_context9.prev = _context9.next) {
|
|
547
|
+
case 0:
|
|
548
|
+
_context9.prev = 0;
|
|
549
|
+
_context9.next = 3;
|
|
550
|
+
return (0, _effects.select)(selectForm(formKey));
|
|
551
|
+
case 3:
|
|
552
|
+
_yield$select4 = _context9.sent;
|
|
553
|
+
bindings = _yield$select4.bindings;
|
|
554
|
+
fields = _yield$select4.fields;
|
|
555
|
+
_onSubmit = _yield$select4.onSubmit;
|
|
556
|
+
onSave = _yield$select4.onSave;
|
|
557
|
+
onError = _yield$select4.onError;
|
|
558
|
+
computedFieldSet = computeFieldSet(fields, fieldSet);
|
|
559
|
+
values = serializeImpl({
|
|
560
|
+
bindings: bindings,
|
|
561
|
+
fields: fields
|
|
562
|
+
}, fieldSet);
|
|
563
|
+
errors = fields.filter(function (field) {
|
|
564
|
+
return computedFieldSet.contains(field.name);
|
|
565
|
+
}).map(function (field) {
|
|
566
|
+
return field.errors;
|
|
567
|
+
}).filter(function (errors) {
|
|
568
|
+
return !errors.isEmpty();
|
|
569
|
+
});
|
|
570
|
+
if (!errors.isEmpty()) {
|
|
571
|
+
_context9.next = 32;
|
|
572
|
+
break;
|
|
573
|
+
}
|
|
574
|
+
_context9.prev = 13;
|
|
575
|
+
_context9.next = 16;
|
|
576
|
+
return (0, _effects.call)(_onSubmit, values, bindings);
|
|
577
|
+
case 16:
|
|
578
|
+
result = _context9.sent;
|
|
579
|
+
(0, _store.dispatch)('SUBMIT_SUCCESS', {
|
|
580
|
+
formKey: formKey
|
|
581
|
+
});
|
|
582
|
+
if (!onSave) {
|
|
583
|
+
_context9.next = 21;
|
|
584
|
+
break;
|
|
585
|
+
}
|
|
586
|
+
_context9.next = 21;
|
|
587
|
+
return (0, _effects.call)(onSave, result);
|
|
588
|
+
case 21:
|
|
589
|
+
_context9.next = 30;
|
|
603
590
|
break;
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
591
|
+
case 23:
|
|
592
|
+
_context9.prev = 23;
|
|
593
|
+
_context9.t0 = _context9["catch"](13);
|
|
594
|
+
(0, _store.dispatch)('SUBMIT_ERROR', {
|
|
595
|
+
formKey: formKey,
|
|
596
|
+
error: typeof _context9.t0 === 'string' ? _context9.t0 : 'Unexpected error occurred'
|
|
597
|
+
});
|
|
598
|
+
if (typeof _context9.t0 !== 'string') {
|
|
599
|
+
console.error('Error handling form submit', _context9.t0);
|
|
600
|
+
}
|
|
601
|
+
if (!onError) {
|
|
602
|
+
_context9.next = 30;
|
|
603
|
+
break;
|
|
604
|
+
}
|
|
605
|
+
_context9.next = 30;
|
|
606
|
+
return (0, _effects.call)(onError, _context9.t0);
|
|
607
|
+
case 30:
|
|
608
|
+
_context9.next = 34;
|
|
618
609
|
break;
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
_context9.prev = 24;
|
|
630
|
-
_context9.t0 = _context9["catch"](14);
|
|
631
|
-
dispatch('SUBMIT_ERROR', {
|
|
632
|
-
formKey: formKey,
|
|
633
|
-
error: typeof _context9.t0 === 'string' ? _context9.t0 : 'Unexpected error occurred'
|
|
634
|
-
});
|
|
635
|
-
|
|
636
|
-
if (typeof _context9.t0 !== 'string') {
|
|
637
|
-
console.error('Error handling form submit', _context9.t0);
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
if (!onError) {
|
|
641
|
-
_context9.next = 31;
|
|
610
|
+
case 32:
|
|
611
|
+
(0, _store.dispatch)('SUBMIT_FIELD_ERRORS', {
|
|
612
|
+
formKey: formKey,
|
|
613
|
+
fieldNames: errors.keySeq()
|
|
614
|
+
});
|
|
615
|
+
if ((0, _lodashEs.isFunction)(onInvalid)) {
|
|
616
|
+
onInvalid(errors);
|
|
617
|
+
}
|
|
618
|
+
case 34:
|
|
619
|
+
_context9.next = 39;
|
|
642
620
|
break;
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
case 33:
|
|
653
|
-
dispatch('SUBMIT_FIELD_ERRORS', {
|
|
654
|
-
formKey: formKey,
|
|
655
|
-
fieldNames: errors.keySeq()
|
|
656
|
-
});
|
|
657
|
-
|
|
658
|
-
if (isFunction(onInvalid)) {
|
|
659
|
-
onInvalid(errors);
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
case 35:
|
|
663
|
-
_context9.next = 40;
|
|
664
|
-
break;
|
|
665
|
-
|
|
666
|
-
case 37:
|
|
667
|
-
_context9.prev = 37;
|
|
668
|
-
_context9.t1 = _context9["catch"](1);
|
|
669
|
-
console.error(_context9.t1);
|
|
670
|
-
|
|
671
|
-
case 40:
|
|
672
|
-
case "end":
|
|
673
|
-
return _context9.stop();
|
|
621
|
+
case 36:
|
|
622
|
+
_context9.prev = 36;
|
|
623
|
+
_context9.t1 = _context9["catch"](0);
|
|
624
|
+
console.error(_context9.t1);
|
|
625
|
+
case 39:
|
|
626
|
+
case "end":
|
|
627
|
+
return _context9.stop();
|
|
628
|
+
}
|
|
674
629
|
}
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
}))
|
|
678
|
-
|
|
630
|
+
}, _callee8, null, [[0, 36], [13, 23]]);
|
|
631
|
+
})();
|
|
632
|
+
}));
|
|
633
|
+
var setValue = function setValue(formKey, name, value) {
|
|
679
634
|
var triggerChange = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
680
|
-
dispatch('SET_VALUE', {
|
|
635
|
+
(0, _store.dispatch)('SET_VALUE', {
|
|
681
636
|
formKey: formKey,
|
|
682
637
|
name: name,
|
|
683
638
|
value: value,
|
|
684
639
|
triggerChange: triggerChange
|
|
685
640
|
});
|
|
686
641
|
};
|
|
687
|
-
|
|
642
|
+
exports.setValue = setValue;
|
|
643
|
+
var toggleMultiValue = function toggleMultiValue(formKey, name, value) {
|
|
688
644
|
var triggerChange = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
689
|
-
dispatch('TOGGLE_MULTI_VALUE', {
|
|
645
|
+
(0, _store.dispatch)('TOGGLE_MULTI_VALUE', {
|
|
690
646
|
formKey: formKey,
|
|
691
647
|
name: name,
|
|
692
648
|
value: value,
|
|
693
649
|
triggerChange: triggerChange
|
|
694
650
|
});
|
|
695
651
|
};
|
|
652
|
+
exports.toggleMultiValue = toggleMultiValue;
|
|
696
653
|
var actions = {
|
|
697
654
|
setValue: function setValue(formKey) {
|
|
698
655
|
return function (name, value) {
|
|
699
656
|
var triggerChange = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
700
|
-
return dispatch('SET_VALUE', {
|
|
657
|
+
return (0, _store.dispatch)('SET_VALUE', {
|
|
701
658
|
formKey: formKey,
|
|
702
659
|
name: name,
|
|
703
660
|
value: value,
|
|
@@ -708,7 +665,7 @@ var actions = {
|
|
|
708
665
|
toggleMultiValue: function toggleMultiValue(formKey) {
|
|
709
666
|
return function (name, value) {
|
|
710
667
|
var triggerChange = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
|
711
|
-
return dispatch('TOGGLE_MULTI_VALUE', {
|
|
668
|
+
return (0, _store.dispatch)('TOGGLE_MULTI_VALUE', {
|
|
712
669
|
formKey: formKey,
|
|
713
670
|
name: name,
|
|
714
671
|
value: value,
|
|
@@ -717,51 +674,49 @@ var actions = {
|
|
|
717
674
|
};
|
|
718
675
|
}
|
|
719
676
|
};
|
|
720
|
-
|
|
721
677
|
var bindActions = function bindActions(formKey) {
|
|
722
678
|
return Object.entries(actions).reduce(function (acc, _ref21) {
|
|
723
|
-
var _ref22 =
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, name, fn(formKey)));
|
|
679
|
+
var _ref22 = (0, _slicedToArray2["default"])(_ref21, 2),
|
|
680
|
+
name = _ref22[0],
|
|
681
|
+
fn = _ref22[1];
|
|
682
|
+
return (0, _objectSpread3["default"])((0, _objectSpread3["default"])({}, acc), {}, (0, _defineProperty2["default"])({}, name, fn(formKey)));
|
|
728
683
|
}, {});
|
|
729
684
|
};
|
|
730
|
-
|
|
731
|
-
export var onFocus = function onFocus(_ref23) {
|
|
685
|
+
var onFocus = function onFocus(_ref23) {
|
|
732
686
|
var formKey = _ref23.formKey,
|
|
733
|
-
|
|
687
|
+
name = _ref23.name;
|
|
734
688
|
return function () {
|
|
735
|
-
dispatch('FOCUS_FIELD', {
|
|
689
|
+
(0, _store.dispatch)('FOCUS_FIELD', {
|
|
736
690
|
formKey: formKey,
|
|
737
691
|
name: name
|
|
738
692
|
});
|
|
739
693
|
};
|
|
740
694
|
};
|
|
741
|
-
|
|
695
|
+
exports.onFocus = onFocus;
|
|
696
|
+
var onBlur = function onBlur(_ref24) {
|
|
742
697
|
var formKey = _ref24.formKey,
|
|
743
|
-
|
|
698
|
+
name = _ref24.name;
|
|
744
699
|
return function () {
|
|
745
|
-
dispatch('BLUR_FIELD', {
|
|
700
|
+
(0, _store.dispatch)('BLUR_FIELD', {
|
|
746
701
|
formKey: formKey,
|
|
747
702
|
name: name
|
|
748
703
|
});
|
|
749
704
|
};
|
|
750
705
|
};
|
|
706
|
+
exports.onBlur = onBlur;
|
|
751
707
|
var LIST_VALUE_TYPES = ['checkbox-multi'];
|
|
752
|
-
|
|
708
|
+
var onChange = function onChange(_ref25) {
|
|
753
709
|
var formKey = _ref25.formKey,
|
|
754
|
-
|
|
755
|
-
|
|
710
|
+
type = _ref25.type,
|
|
711
|
+
name = _ref25.name;
|
|
756
712
|
return function (event) {
|
|
757
713
|
var value;
|
|
758
|
-
|
|
759
714
|
if (type === 'checkbox' && event && event.target) {
|
|
760
715
|
value = event.target.checked;
|
|
761
716
|
} else if (type === 'checkbox-multi') {
|
|
762
717
|
value = event.target.value;
|
|
763
718
|
} else if (type === 'select-multi' && event && event.target && event.target.options) {
|
|
764
|
-
value = List(event.target.options).filter(function (o) {
|
|
719
|
+
value = (0, _immutable.List)(event.target.options).filter(function (o) {
|
|
765
720
|
return o.selected;
|
|
766
721
|
}).map(function (o) {
|
|
767
722
|
return o.value;
|
|
@@ -771,7 +726,6 @@ export var onChange = function onChange(_ref25) {
|
|
|
771
726
|
} else {
|
|
772
727
|
value = event;
|
|
773
728
|
}
|
|
774
|
-
|
|
775
729
|
if (LIST_VALUE_TYPES.includes(type)) {
|
|
776
730
|
actions.toggleMultiValue(formKey)(name, value);
|
|
777
731
|
} else {
|
|
@@ -779,79 +733,90 @@ export var onChange = function onChange(_ref25) {
|
|
|
779
733
|
}
|
|
780
734
|
};
|
|
781
735
|
};
|
|
782
|
-
|
|
736
|
+
exports.onChange = onChange;
|
|
737
|
+
var onSubmit = function onSubmit(formKey, fieldSet) {
|
|
783
738
|
return function (event) {
|
|
784
739
|
event && event.preventDefault && event.preventDefault();
|
|
785
|
-
dispatch('SUBMIT', {
|
|
740
|
+
(0, _store.dispatch)('SUBMIT', {
|
|
786
741
|
formKey: formKey,
|
|
787
742
|
fieldSet: fieldSet
|
|
788
743
|
});
|
|
789
744
|
};
|
|
790
745
|
};
|
|
791
|
-
|
|
746
|
+
exports.onSubmit = onSubmit;
|
|
747
|
+
var onReset = function onReset(formKey) {
|
|
792
748
|
return function () {
|
|
793
749
|
return resetForm(formKey);
|
|
794
750
|
};
|
|
795
751
|
};
|
|
796
|
-
|
|
752
|
+
exports.onReset = onReset;
|
|
753
|
+
var clearError = function clearError(formKey) {
|
|
797
754
|
return function (event) {
|
|
798
|
-
dispatch('CLEAR_ERROR', {
|
|
755
|
+
(0, _store.dispatch)('CLEAR_ERROR', {
|
|
799
756
|
formKey: formKey
|
|
800
757
|
});
|
|
801
758
|
};
|
|
802
759
|
};
|
|
803
|
-
|
|
804
|
-
|
|
760
|
+
exports.clearError = clearError;
|
|
761
|
+
var mountForm = function mountForm(formKey) {
|
|
762
|
+
return (0, _store.dispatch)('MOUNT_FORM', {
|
|
805
763
|
formKey: formKey
|
|
806
764
|
});
|
|
807
765
|
};
|
|
808
|
-
|
|
809
|
-
|
|
766
|
+
exports.mountForm = mountForm;
|
|
767
|
+
var unmountForm = function unmountForm(formKey) {
|
|
768
|
+
return (0, _store.dispatch)('UNMOUNT_FORM', {
|
|
810
769
|
formKey: formKey
|
|
811
770
|
});
|
|
812
771
|
};
|
|
813
|
-
|
|
814
|
-
|
|
772
|
+
exports.unmountForm = unmountForm;
|
|
773
|
+
var resetForm = function resetForm(formKey) {
|
|
774
|
+
return (0, _store.dispatch)('RESET', {
|
|
815
775
|
formKey: formKey
|
|
816
776
|
});
|
|
817
777
|
};
|
|
818
|
-
|
|
819
|
-
|
|
778
|
+
exports.resetForm = resetForm;
|
|
779
|
+
var reloadDataSource = function reloadDataSource(formKey, name) {
|
|
780
|
+
return (0, _store.dispatch)('CALL_DATA_SOURCE', {
|
|
820
781
|
formKey: formKey,
|
|
821
782
|
name: name
|
|
822
783
|
});
|
|
823
784
|
};
|
|
824
|
-
|
|
825
|
-
|
|
785
|
+
exports.reloadDataSource = reloadDataSource;
|
|
786
|
+
var configureForm = function configureForm(config) {
|
|
787
|
+
return (0, _store.dispatch)('CONFIGURE_FORM', config);
|
|
826
788
|
};
|
|
827
|
-
|
|
789
|
+
exports.configureForm = configureForm;
|
|
790
|
+
var submitForm = function submitForm(formKey, _ref26) {
|
|
828
791
|
var fieldSet = _ref26.fieldSet,
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
return dispatch('SUBMIT', {
|
|
792
|
+
onInvalid = _ref26.onInvalid,
|
|
793
|
+
values = _ref26.values;
|
|
794
|
+
return (0, _store.dispatch)('SUBMIT', {
|
|
832
795
|
formKey: formKey,
|
|
833
796
|
fieldSet: fieldSet,
|
|
834
797
|
onInvalid: onInvalid,
|
|
835
798
|
values: values
|
|
836
799
|
});
|
|
837
800
|
};
|
|
838
|
-
|
|
801
|
+
exports.submitForm = submitForm;
|
|
802
|
+
var serializeForm = function serializeForm(formKey) {
|
|
839
803
|
var _ref27 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
return serializeImpl(selectForm(formKey)(store.getState()), fieldSet);
|
|
804
|
+
fieldSet = _ref27.fieldSet;
|
|
805
|
+
return serializeImpl(selectForm(formKey)(_store.store.getState()), fieldSet);
|
|
843
806
|
};
|
|
844
|
-
|
|
807
|
+
exports.serializeForm = serializeForm;
|
|
845
808
|
var serializeImpl = function serializeImpl(_ref28, fieldSet) {
|
|
846
809
|
var bindings = _ref28.bindings,
|
|
847
|
-
|
|
810
|
+
fields = _ref28.fields;
|
|
848
811
|
var computedFieldSet = computeFieldSet(fields, fieldSet);
|
|
849
812
|
return fields.filter(function (field) {
|
|
850
813
|
return !field["transient"] && computedFieldSet.contains(field.name);
|
|
851
814
|
}).map(function (field) {
|
|
852
815
|
return field.serialize ? field.serialize(bindings) : field.value;
|
|
853
816
|
});
|
|
854
|
-
};
|
|
817
|
+
};
|
|
818
|
+
|
|
819
|
+
// Wraps the FormImpl to handle the formKey behavior. If this is passed a
|
|
855
820
|
// formKey prop this wrapper is essentially a noop, but if it is not passed a
|
|
856
821
|
// formKey then it generates one and stores it as component state and passes
|
|
857
822
|
// that to FormImpl. When it generates its own form key it then mounts/unmounts
|
|
@@ -862,25 +827,18 @@ var serializeImpl = function serializeImpl(_ref28, fieldSet) {
|
|
|
862
827
|
/**
|
|
863
828
|
* @component
|
|
864
829
|
*/
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
_inherits(Form, _Component);
|
|
869
|
-
|
|
870
|
-
var _super = _createSuper(Form);
|
|
871
|
-
|
|
830
|
+
var Form = /*#__PURE__*/function (_Component) {
|
|
831
|
+
(0, _inherits2["default"])(Form, _Component);
|
|
832
|
+
var _super = (0, _createSuper2["default"])(Form);
|
|
872
833
|
function Form(props) {
|
|
873
834
|
var _this;
|
|
874
|
-
|
|
875
|
-
_classCallCheck(this, Form);
|
|
876
|
-
|
|
835
|
+
(0, _classCallCheck2["default"])(this, Form);
|
|
877
836
|
_this = _super.call(this, props);
|
|
878
837
|
_this.auto = !_this.props.formKey || _this.props.uncontrolled;
|
|
879
|
-
_this.formKey = _this.props.formKey || 'f' + generateKey();
|
|
838
|
+
_this.formKey = _this.props.formKey || 'f' + (0, _helpers.generateKey)();
|
|
880
839
|
return _this;
|
|
881
840
|
}
|
|
882
|
-
|
|
883
|
-
_createClass(Form, [{
|
|
841
|
+
(0, _createClass2["default"])(Form, [{
|
|
884
842
|
key: "componentDidMount",
|
|
885
843
|
value: function componentDidMount() {
|
|
886
844
|
if (this.auto) {
|
|
@@ -898,54 +856,43 @@ export var Form = /*#__PURE__*/function (_Component) {
|
|
|
898
856
|
key: "render",
|
|
899
857
|
value: function render() {
|
|
900
858
|
var _this2 = this;
|
|
901
|
-
|
|
902
859
|
var _this$props = this.props,
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
return /*#__PURE__*/React.createElement(FormImpl, Object.assign({}, props, {
|
|
860
|
+
components = _this$props.components,
|
|
861
|
+
props = (0, _objectWithoutProperties2["default"])(_this$props, _excluded);
|
|
862
|
+
return /*#__PURE__*/_react["default"].createElement(_ComponentConfigContext.ComponentConfigContext.Consumer, null, function (config) {
|
|
863
|
+
return /*#__PURE__*/_react["default"].createElement(FormImpl, Object.assign({}, props, {
|
|
908
864
|
formKey: _this2.auto ? _this2.formKey : _this2.props.formKey,
|
|
909
|
-
components: config.merge(Map(components).filter(function (c) {
|
|
865
|
+
components: config.merge((0, _immutable.Map)(components).filter(function (c) {
|
|
910
866
|
return !!c;
|
|
911
867
|
}))
|
|
912
868
|
}));
|
|
913
869
|
});
|
|
914
870
|
}
|
|
915
871
|
}]);
|
|
916
|
-
|
|
917
872
|
return Form;
|
|
918
|
-
}(Component);
|
|
919
|
-
|
|
873
|
+
}(_react.Component);
|
|
874
|
+
exports.Form = Form;
|
|
920
875
|
var computeFieldSet = function computeFieldSet(fields, fieldSetProp) {
|
|
921
|
-
var defaultFieldSet = OrderedSet(fields.keySeq());
|
|
922
|
-
return OrderedSet(!fieldSetProp ? defaultFieldSet : typeof fieldSetProp === 'function' ? fieldSetProp(defaultFieldSet) : fieldSetProp);
|
|
876
|
+
var defaultFieldSet = (0, _immutable.OrderedSet)(fields.keySeq());
|
|
877
|
+
return (0, _immutable.OrderedSet)(!fieldSetProp ? defaultFieldSet : typeof fieldSetProp === 'function' ? fieldSetProp(defaultFieldSet) : fieldSetProp);
|
|
923
878
|
};
|
|
924
|
-
|
|
925
879
|
var evaluateReadOnly = function evaluateReadOnly(readOnlyProp, bindings) {
|
|
926
880
|
return typeof readOnlyProp === 'boolean' ? readOnlyProp : typeof readOnlyProp === 'function' ? readOnlyProp(bindings) : false;
|
|
927
881
|
};
|
|
928
|
-
|
|
929
882
|
var FormImplComponent = /*#__PURE__*/function (_Component2) {
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
var _super2 = _createSuper(FormImplComponent);
|
|
933
|
-
|
|
883
|
+
(0, _inherits2["default"])(FormImplComponent, _Component2);
|
|
884
|
+
var _super2 = (0, _createSuper2["default"])(FormImplComponent);
|
|
934
885
|
function FormImplComponent() {
|
|
935
886
|
var _this3;
|
|
936
|
-
|
|
937
|
-
_classCallCheck(this, FormImplComponent);
|
|
938
|
-
|
|
887
|
+
(0, _classCallCheck2["default"])(this, FormImplComponent);
|
|
939
888
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
940
889
|
args[_key] = arguments[_key];
|
|
941
890
|
}
|
|
942
|
-
|
|
943
891
|
_this3 = _super2.call.apply(_super2, [this].concat(args));
|
|
944
|
-
_this3.focusRef = createRef();
|
|
892
|
+
_this3.focusRef = /*#__PURE__*/(0, _react.createRef)();
|
|
945
893
|
return _this3;
|
|
946
894
|
}
|
|
947
|
-
|
|
948
|
-
_createClass(FormImplComponent, [{
|
|
895
|
+
(0, _createClass2["default"])(FormImplComponent, [{
|
|
949
896
|
key: "checkConfigure",
|
|
950
897
|
value: function checkConfigure() {
|
|
951
898
|
if (this.props.formState === null) {
|
|
@@ -955,10 +902,10 @@ var FormImplComponent = /*#__PURE__*/function (_Component2) {
|
|
|
955
902
|
}, {
|
|
956
903
|
key: "componentDidMount",
|
|
957
904
|
value: function componentDidMount() {
|
|
958
|
-
this.checkConfigure();
|
|
905
|
+
this.checkConfigure();
|
|
906
|
+
// if the form was mounted then hidden (by being unrendered) its possible
|
|
959
907
|
// that when its shown again the fields will already be ready to render so
|
|
960
908
|
// we need to check focus on mount as well
|
|
961
|
-
|
|
962
909
|
if (this.props.formState && this.props.formState.fields && this.focusRef.current) {
|
|
963
910
|
this.focusRef.current.focus();
|
|
964
911
|
}
|
|
@@ -966,12 +913,13 @@ var FormImplComponent = /*#__PURE__*/function (_Component2) {
|
|
|
966
913
|
}, {
|
|
967
914
|
key: "componentDidUpdate",
|
|
968
915
|
value: function componentDidUpdate(prevProps) {
|
|
969
|
-
this.checkConfigure();
|
|
916
|
+
this.checkConfigure();
|
|
917
|
+
// after the first render where fields should be rendered, check to see if
|
|
970
918
|
// we should focus a field (based on the autoFocus prop passed to the Form)
|
|
971
|
-
|
|
972
919
|
if (this.props.formState && this.props.formState.fields && !(prevProps.formState && prevProps.formState.fields) && this.focusRef.current) {
|
|
973
920
|
this.focusRef.current.focus();
|
|
974
|
-
}
|
|
921
|
+
}
|
|
922
|
+
// else if the autoFocus prop has been changed we will also focus the new
|
|
975
923
|
// resulting focus element
|
|
976
924
|
else if (this.props.autoFocus !== prevProps.autoFocus && this.focusRef.current) {
|
|
977
925
|
this.focusRef.current.focus();
|
|
@@ -981,66 +929,62 @@ var FormImplComponent = /*#__PURE__*/function (_Component2) {
|
|
|
981
929
|
key: "render",
|
|
982
930
|
value: function render() {
|
|
983
931
|
var _this4 = this;
|
|
984
|
-
|
|
985
932
|
var _this$props2 = this.props,
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
933
|
+
addFields = _this$props2.addFields,
|
|
934
|
+
alterFields = _this$props2.alterFields,
|
|
935
|
+
autoFocus = _this$props2.autoFocus,
|
|
936
|
+
components = _this$props2.components,
|
|
937
|
+
fieldsFn = _this$props2.fields,
|
|
938
|
+
fieldSet = _this$props2.fieldSet,
|
|
939
|
+
formKey = _this$props2.formKey,
|
|
940
|
+
formState = _this$props2.formState,
|
|
941
|
+
readOnly = _this$props2.readOnly;
|
|
995
942
|
var bindings = formState ? formState.bindings : {};
|
|
996
943
|
var initialized = formState ? !!formState.fields : false;
|
|
997
944
|
var form = null;
|
|
998
|
-
|
|
999
945
|
if (initialized) {
|
|
1000
946
|
var _components$toObject = components.toObject(),
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
947
|
+
FormButtons = _components$toObject.FormButtons,
|
|
948
|
+
FormError = _components$toObject.FormError,
|
|
949
|
+
FormLayout = _components$toObject.FormLayout;
|
|
1005
950
|
var error = formState.error,
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
951
|
+
fields = formState.fields,
|
|
952
|
+
formOptions = formState.formOptions,
|
|
953
|
+
submitting = formState.submitting;
|
|
954
|
+
// Build a map of components by field, merging the fields, addFields, and
|
|
1010
955
|
var dirty = fields.some(function (field) {
|
|
1011
956
|
return field.dirty;
|
|
1012
|
-
});
|
|
957
|
+
});
|
|
958
|
+
// alterFields options. Note that we get those from the parent props not
|
|
1013
959
|
// redux store because we want to see new components on HMR updates.
|
|
1014
|
-
|
|
1015
|
-
var fieldComponents = resolveFieldConfig(formOptions, bindings, fieldsFn, addFields, alterFields).filter(function (fieldConfig) {
|
|
960
|
+
var fieldComponents = (0, _Form2.resolveFieldConfig)(formOptions, bindings, fieldsFn, addFields, alterFields).filter(function (fieldConfig) {
|
|
1016
961
|
return fieldConfig.component;
|
|
1017
962
|
}).map(function (fieldConfig) {
|
|
1018
963
|
return fieldConfig.component;
|
|
1019
964
|
});
|
|
1020
965
|
var readOnlyResult = evaluateReadOnly(readOnly, bindings);
|
|
1021
966
|
var computedFieldSet = computeFieldSet(fields, fieldSet);
|
|
1022
|
-
form = /*#__PURE__*/
|
|
967
|
+
form = /*#__PURE__*/_react["default"].createElement(FormLayout, {
|
|
1023
968
|
formKey: formKey,
|
|
1024
969
|
formOptions: formOptions,
|
|
1025
|
-
fields: OrderedMap(computedFieldSet.map(function (name) {
|
|
970
|
+
fields: (0, _immutable.OrderedMap)(computedFieldSet.map(function (name) {
|
|
1026
971
|
return [name, fields.get(name)];
|
|
1027
972
|
})).mapEntries(function (_ref29, index) {
|
|
1028
|
-
var _ref30 =
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
return [name, FieldImpl ? /*#__PURE__*/React.createElement(FieldImpl, Object.assign({
|
|
973
|
+
var _ref30 = (0, _slicedToArray2["default"])(_ref29, 2),
|
|
974
|
+
name = _ref30[0],
|
|
975
|
+
field = _ref30[1];
|
|
976
|
+
var FieldImpl = fieldComponents.get(name) || components.get((0, _Form2.getComponentName)(field), null);
|
|
977
|
+
return [name, FieldImpl ? /*#__PURE__*/_react["default"].createElement(FieldImpl, Object.assign({
|
|
1034
978
|
key: name,
|
|
1035
979
|
focusRef: name === autoFocus || index === autoFocus ? _this4.focusRef : null
|
|
1036
|
-
}, getFieldComponentProps(field, readOnlyResult))) : null];
|
|
980
|
+
}, (0, _Form2.getFieldComponentProps)(field, readOnlyResult))) : null];
|
|
1037
981
|
}),
|
|
1038
982
|
dirty: dirty,
|
|
1039
|
-
error: error && /*#__PURE__*/
|
|
983
|
+
error: error && /*#__PURE__*/_react["default"].createElement(FormError, {
|
|
1040
984
|
error: error,
|
|
1041
985
|
clear: clearError(formKey)
|
|
1042
986
|
}),
|
|
1043
|
-
buttons: !readOnlyResult && /*#__PURE__*/
|
|
987
|
+
buttons: !readOnlyResult && /*#__PURE__*/_react["default"].createElement(FormButtons, {
|
|
1044
988
|
formOptions: formOptions,
|
|
1045
989
|
fields: fields,
|
|
1046
990
|
formKey: formKey,
|
|
@@ -1053,13 +997,12 @@ var FormImplComponent = /*#__PURE__*/function (_Component2) {
|
|
|
1053
997
|
}),
|
|
1054
998
|
bindings: bindings,
|
|
1055
999
|
meta: fields.map(function (field) {
|
|
1056
|
-
return Map({
|
|
1000
|
+
return (0, _immutable.Map)({
|
|
1057
1001
|
visible: field.visible
|
|
1058
1002
|
});
|
|
1059
1003
|
})
|
|
1060
1004
|
});
|
|
1061
1005
|
}
|
|
1062
|
-
|
|
1063
1006
|
return typeof this.props.children === 'function' ? this.props.children({
|
|
1064
1007
|
bindings: bindings,
|
|
1065
1008
|
form: form,
|
|
@@ -1067,23 +1010,22 @@ var FormImplComponent = /*#__PURE__*/function (_Component2) {
|
|
|
1067
1010
|
}) : form;
|
|
1068
1011
|
}
|
|
1069
1012
|
}]);
|
|
1070
|
-
|
|
1071
1013
|
return FormImplComponent;
|
|
1072
|
-
}(Component);
|
|
1073
|
-
|
|
1074
|
-
export var mapStateToProps = function mapStateToProps(state, props) {
|
|
1014
|
+
}(_react.Component);
|
|
1015
|
+
var mapStateToProps = function mapStateToProps(state, props) {
|
|
1075
1016
|
return {
|
|
1076
1017
|
formState: selectForm(props.formKey)(state)
|
|
1077
1018
|
};
|
|
1078
1019
|
};
|
|
1079
|
-
|
|
1080
|
-
|
|
1020
|
+
exports.mapStateToProps = mapStateToProps;
|
|
1021
|
+
var FormImpl = (0, _store.connect)(mapStateToProps)(FormImplComponent);
|
|
1022
|
+
var generateForm = function generateForm(_ref31) {
|
|
1081
1023
|
var dataSources = _ref31.dataSources,
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1024
|
+
fields = _ref31.fields,
|
|
1025
|
+
handleSubmit = _ref31.handleSubmit,
|
|
1026
|
+
formOptions = _ref31.formOptions;
|
|
1085
1027
|
return function (configurationProps) {
|
|
1086
|
-
return /*#__PURE__*/
|
|
1028
|
+
return /*#__PURE__*/_react["default"].createElement(Form, {
|
|
1087
1029
|
addDataSources: configurationProps.addDataSources,
|
|
1088
1030
|
addFields: configurationProps.addFields,
|
|
1089
1031
|
alterFields: configurationProps.alterFields,
|
|
@@ -1093,7 +1035,7 @@ export var generateForm = function generateForm(_ref31) {
|
|
|
1093
1035
|
fields: fields,
|
|
1094
1036
|
fieldSet: configurationProps.fieldSet,
|
|
1095
1037
|
formKey: configurationProps.formKey,
|
|
1096
|
-
formOptions: pick(configurationProps, formOptions),
|
|
1038
|
+
formOptions: (0, _lodashEs.pick)(configurationProps, formOptions),
|
|
1097
1039
|
onSubmit: handleSubmit,
|
|
1098
1040
|
onSave: configurationProps.onSave,
|
|
1099
1041
|
onError: configurationProps.onError,
|
|
@@ -1102,4 +1044,5 @@ export var generateForm = function generateForm(_ref31) {
|
|
|
1102
1044
|
readOnly: configurationProps.readOnly
|
|
1103
1045
|
}, configurationProps.children);
|
|
1104
1046
|
};
|
|
1105
|
-
};
|
|
1047
|
+
};
|
|
1048
|
+
exports.generateForm = generateForm;
|