@kineticdata/react 6.0.1 → 6.0.3
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/CHANGELOG.md +86 -0
- package/lib/apis/agent/adapters.js +2 -3
- package/lib/apis/agent/bridges.js +7 -13
- package/lib/apis/agent/handlers.js +7 -13
- package/lib/apis/core/activity.js +2 -3
- package/lib/apis/core/attributeDefinitions.js +6 -11
- package/lib/apis/core/attributeDefinitions.test.js +201 -213
- package/lib/apis/core/authentication.js +74 -84
- package/lib/apis/core/backgroundJobs.js +5 -9
- package/lib/apis/core/bridgeModelAttributeMappings.js +5 -10
- package/lib/apis/core/bridgeModelAttributes.js +6 -11
- package/lib/apis/core/bridgeModelMappings.js +5 -10
- package/lib/apis/core/bridgeModelQualificationMappings.js +5 -10
- package/lib/apis/core/bridgeModelQualifications.js +5 -10
- package/lib/apis/core/bridgeModels.js +7 -13
- package/lib/apis/core/bridgeModels.test.js +313 -333
- package/lib/apis/core/bridgedresources.js +7 -13
- package/lib/apis/core/categories.js +6 -11
- package/lib/apis/core/fileResources.js +5 -10
- package/lib/apis/core/filestores.js +5 -10
- package/lib/apis/core/formTypes.js +6 -11
- package/lib/apis/core/forms.js +6 -11
- package/lib/apis/core/forms.test.js +201 -213
- package/lib/apis/core/kapps.js +6 -11
- package/lib/apis/core/kapps.test.js +122 -130
- package/lib/apis/core/logs.js +3 -5
- package/lib/apis/core/memberships.js +3 -5
- package/lib/apis/core/meta.js +6 -11
- package/lib/apis/core/notices.js +2 -3
- package/lib/apis/core/oauthClients.js +6 -11
- package/lib/apis/core/platformComponents.js +10 -19
- package/lib/apis/core/platformItems.js +2 -3
- package/lib/apis/core/profile.js +3 -5
- package/lib/apis/core/securityPolicyDefinitions.js +6 -11
- package/lib/apis/core/securityPolicyDefinitions.test.js +254 -268
- package/lib/apis/core/space.js +3 -5
- package/lib/apis/core/space.test.js +106 -114
- package/lib/apis/core/submissions.js +19 -35
- package/lib/apis/core/teams.js +6 -11
- package/lib/apis/core/translations.js +18 -35
- package/lib/apis/core/translations.test.js +1343 -1437
- package/lib/apis/core/users.js +6 -11
- package/lib/apis/core/version.js +2 -3
- package/lib/apis/core/webApis.js +5 -10
- package/lib/apis/core/webhooks.js +6 -11
- package/lib/apis/core/webhooks.test.js +243 -257
- package/lib/apis/core/webhooksJobs.js +3 -5
- package/lib/apis/core/workflows.js +7 -13
- package/lib/apis/http.js +16 -31
- package/lib/apis/system/index.js +46 -91
- package/lib/apis/task/index.js +60 -119
- package/lib/components/agent/bridge/BridgeForm.js +1 -2
- package/lib/components/agent/bridge/BridgeTable.js +1 -2
- package/lib/components/agent/filestore/FilestoreForm.js +1 -2
- package/lib/components/agent/filestore/FilestoreTable.js +1 -2
- package/lib/components/agent/handler/AgentHandlerForm.js +1 -2
- package/lib/components/agent/handler/AgentHandlerTable.js +1 -2
- package/lib/components/common/AttributeSelect.js +2 -3
- package/lib/components/common/BridgeSelect.js +16 -17
- package/lib/components/common/ComponentConfigContext.js +1 -2
- package/lib/components/common/ContentEditable.js +23 -3
- package/lib/components/common/FormSelect.js +16 -17
- package/lib/components/common/NodeSelect.js +2 -3
- package/lib/components/common/Scroller.js +2 -3
- package/lib/components/common/StaticSelect.js +14 -15
- package/lib/components/common/TableInput.js +276 -63
- package/lib/components/common/TeamSelect.js +16 -17
- package/lib/components/common/ToastContainer.js +7 -12
- package/lib/components/common/Typeahead.js +15 -2
- package/lib/components/common/UserSelect.js +16 -17
- package/lib/components/common/authentication/AuthInterceptor.js +2 -3
- package/lib/components/common/authentication/AuthInterceptor.test.js +141 -153
- package/lib/components/common/authentication/AuthenticationContainer.js +332 -343
- package/lib/components/common/authentication/RequestInterceptor.js +2 -10
- package/lib/components/common/code_input/CodeInput.js +4 -9
- package/lib/components/common/code_input/draftHelpers.js +20 -37
- package/lib/components/common/code_input/languageHelpers.js +6 -12
- package/lib/components/common/code_input/languageHelpers.test.js +10 -8
- package/lib/components/common/defaults/Toast.js +1 -2
- package/lib/components/common/defaults/index.js +2 -3
- package/lib/components/core/attribute_definition/AttributeDefinitionForm.js +1 -2
- package/lib/components/core/attribute_definition/AttributeDefinitionTable.js +1 -2
- package/lib/components/core/bridge_model/BridgeModelForm.js +52 -55
- package/lib/components/core/bridge_model/BridgeModelTable.js +1 -2
- package/lib/components/core/bridge_model_attribute/BridgeModelAttributeForm.js +1 -2
- package/lib/components/core/bridge_model_attribute/BridgeModelAttributeTable.js +1 -2
- package/lib/components/core/bridge_model_qualification/BridgeModelQualificationForm.js +1 -2
- package/lib/components/core/bridge_model_qualification/BridgeModelQualificationTable.js +1 -2
- package/lib/components/core/category/CategoryForm.js +1 -2
- package/lib/components/core/category/CategoryTable.js +1 -2
- package/lib/components/core/core_form/CoreForm.js +11 -22
- package/lib/components/core/core_form/defaults/index.js +11 -19
- package/lib/components/core/core_form/globals.js +3 -5
- package/lib/components/core/field_definition/FieldDefinitionForm.js +1 -2
- package/lib/components/core/field_definition/FieldDefinitionTable.js +2 -4
- package/lib/components/core/file_resource/FileResourceForm.js +1 -2
- package/lib/components/core/file_resource/FileResourceTable.js +1 -2
- package/lib/components/core/form/FormForm.js +4 -4
- package/lib/components/core/form/FormTable.js +1 -2
- package/lib/components/core/form_type/FormTypeForm.js +1 -2
- package/lib/components/core/form_type/FormTypeTable.js +1 -2
- package/lib/components/core/i18n/I18n.js +2 -4
- package/lib/components/core/i18n/I18nContext.js +1 -2
- package/lib/components/core/i18n/I18nProvider.js +2 -3
- package/lib/components/core/i18n/Moment.js +10 -9
- package/lib/components/core/index_definition/IndexDefinitionForm.js +1 -2
- package/lib/components/core/index_definition/IndexDefinitionTable.js +1 -2
- package/lib/components/core/index_job/IndexJobTable.js +1 -2
- package/lib/components/core/kapp/KappForm.js +1 -2
- package/lib/components/core/kapp/KappTable.js +1 -2
- package/lib/components/core/log/LogTable.js +2 -4
- package/lib/components/core/oauth_client/OAuthClientForm.js +1 -2
- package/lib/components/core/oauth_client/OAuthClientTable.js +1 -2
- package/lib/components/core/platform_component/AgentComponentForm.js +1 -2
- package/lib/components/core/platform_component/AgentComponentTable.js +1 -2
- package/lib/components/core/platform_component/TaskComponentForm.js +1 -2
- package/lib/components/core/profile/ProfileForm.js +1 -2
- package/lib/components/core/security_definition/SecurityDefinitionForm.js +3 -6
- package/lib/components/core/security_definition/SecurityDefinitionTable.js +1 -2
- package/lib/components/core/space/SpaceForm.js +1 -2
- package/lib/components/core/submission/DatastoreSubmissionFilters.js +3 -5
- package/lib/components/core/submission/DatastoreSubmissionTable.js +2 -4
- package/lib/components/core/submission/FormSubmissionFilters.js +4 -7
- package/lib/components/core/submission/FormSubmissionTable.js +2 -4
- package/lib/components/core/submission/KappSubmissionTable.js +2 -4
- package/lib/components/core/submission/SubmissionForm.js +1 -2
- package/lib/components/core/submission/SubmissionTable.js +2 -3
- package/lib/components/core/submission/helpers.js +4 -7
- package/lib/components/core/team/TeamForm.js +1 -2
- package/lib/components/core/team/TeamTable.js +1 -2
- package/lib/components/core/translation/ContextForm.js +1 -2
- package/lib/components/core/translation/ContextTable.js +1 -2
- package/lib/components/core/translation/EntryForm.js +1 -2
- package/lib/components/core/translation/EntryTable.js +1 -2
- package/lib/components/core/translation/LocaleForm.js +1 -2
- package/lib/components/core/translation/LocaleTable.js +1 -2
- package/lib/components/core/user/UserForm.js +1 -2
- package/lib/components/core/user/UserTable.js +1 -2
- package/lib/components/core/webapi/WebApiForm.js +97 -101
- package/lib/components/core/webapi/WebApiTable.js +1 -2
- package/lib/components/core/webhook/WebhookForm.js +1 -2
- package/lib/components/core/webhook/WebhookTable.js +1 -2
- package/lib/components/core/webhook_job/WebhookJobTable.js +1 -2
- package/lib/components/form/Form.helpers.js +10 -19
- package/lib/components/form/Form.js +312 -355
- package/lib/components/form/Form.models.js +6 -11
- package/lib/components/form/FormState.js +3 -3
- package/lib/components/form/KitchenSinkForm.js +23 -3
- package/lib/components/form/SimpleForm.helpers.js +262 -0
- package/lib/components/form/SimpleForm.js +462 -0
- package/lib/components/form/SimpleForm.models.js +62 -0
- package/lib/components/form/defaults/AttributesField.js +3 -4
- package/lib/components/form/defaults/CheckboxField.js +2 -3
- package/lib/components/form/defaults/CodeField.js +2 -3
- package/lib/components/form/defaults/FormButtons.js +2 -3
- package/lib/components/form/defaults/FormError.js +2 -3
- package/lib/components/form/defaults/FormField.js +2 -3
- package/lib/components/form/defaults/FormLayout.js +2 -3
- package/lib/components/form/defaults/FormMultiField.js +2 -3
- package/lib/components/form/defaults/PasswordField.js +2 -3
- package/lib/components/form/defaults/RadioField.js +2 -3
- package/lib/components/form/defaults/SampleTeamsRolesFIeld.js +2 -3
- package/lib/components/form/defaults/SelectField.js +2 -3
- package/lib/components/form/defaults/SelectMultiField.js +2 -3
- package/lib/components/form/defaults/TableField.js +2 -3
- package/lib/components/form/defaults/TeamField.js +2 -3
- package/lib/components/form/defaults/TeamMultiField.js +2 -3
- package/lib/components/form/defaults/TextField.js +2 -3
- package/lib/components/form/defaults/TextMultiField.js +2 -3
- package/lib/components/form/defaults/UserField.js +2 -3
- package/lib/components/form/defaults/UserMultiField.js +2 -3
- package/lib/components/form/defaults/index.js +2 -3
- package/lib/components/form/tests/Form.test.js +4354 -4508
- package/lib/components/form/tests/components.js +73 -64
- package/lib/components/index.js +7 -0
- package/lib/components/system/SystemBackgroundTasksTable.js +1 -2
- package/lib/components/system/SystemCassandraForm.js +1 -2
- package/lib/components/system/SystemElasticSearchForm.js +1 -2
- package/lib/components/system/SystemFilestoreForm.js +2 -3
- package/lib/components/system/SystemForm.js +1 -2
- package/lib/components/system/SystemIngressForm.js +1 -2
- package/lib/components/system/SystemSecurityForm.js +1 -2
- package/lib/components/system/SystemSmtpForm.js +1 -2
- package/lib/components/system/SystemTaskAdapterForm.js +1 -2
- package/lib/components/system/SystemTrustedCertificateForm.js +1 -2
- package/lib/components/system/SystemTrustedCertificatesTable.js +1 -2
- package/lib/components/system/SystemUserForm.js +1 -2
- package/lib/components/system/helpers.js +11 -21
- package/lib/components/system/spaces/SystemSpaceForm.js +2 -3
- package/lib/components/system/spaces/SystemTenantForm.js +2 -3
- package/lib/components/system/spaces/SystemTenantTable.js +1 -2
- package/lib/components/table/Table.js +48 -51
- package/lib/components/table/Table.redux.js +161 -188
- package/lib/components/table/Table.test.js +115 -123
- package/lib/components/table/defaults/BodyCell.js +1 -2
- package/lib/components/table/defaults/BodyRow.js +1 -2
- package/lib/components/table/defaults/BooleanFilter.js +1 -2
- package/lib/components/table/defaults/ColumnControl.js +1 -2
- package/lib/components/table/defaults/EmptyBodyRow.js +1 -2
- package/lib/components/table/defaults/FilterLayout.js +1 -2
- package/lib/components/table/defaults/Footer.js +1 -2
- package/lib/components/table/defaults/FooterCell.js +1 -2
- package/lib/components/table/defaults/FooterRow.js +1 -2
- package/lib/components/table/defaults/Header.js +1 -2
- package/lib/components/table/defaults/HeaderCell.js +1 -2
- package/lib/components/table/defaults/HeaderRow.js +1 -2
- package/lib/components/table/defaults/PaginationControl.js +2 -4
- package/lib/components/table/defaults/TableBody.js +1 -2
- package/lib/components/table/defaults/TableLayout.js +1 -2
- package/lib/components/table/defaults/TextFilter.js +1 -2
- package/lib/components/table/defaults/index.js +2 -3
- package/lib/components/table/tests/Table.redux.test.js +162 -0
- package/lib/components/table/tests/Table.test.js +767 -0
- package/lib/components/table/tests/components.js +182 -0
- package/lib/components/task/builder/Connector.js +26 -11
- package/lib/components/task/builder/ConnectorForm.js +1 -2
- package/lib/components/task/builder/Node.js +18 -9
- package/lib/components/task/builder/NodeForm.js +1 -2
- package/lib/components/task/builder/NodeParametersForm.js +1 -2
- package/lib/components/task/builder/SvgCanvas.js +2 -3
- package/lib/components/task/builder/SvgText.js +2 -3
- package/lib/components/task/builder/TaskDefinitionConfigForm.js +3 -6
- package/lib/components/task/builder/TreeBuilder.js +14 -5
- package/lib/components/task/builder/builder.redux.js +187 -186
- package/lib/components/task/builder/constants.js +38 -76
- package/lib/components/task/builder/helpers.js +23 -40
- package/lib/components/task/builder/models.js +24 -35
- package/lib/components/task/category/TaskCategoryForm.js +2 -3
- package/lib/components/task/category/TaskCategoryTable.js +1 -2
- package/lib/components/task/common/UsageTable.js +1 -2
- package/lib/components/task/engine/EngineSettingsForm.js +2 -3
- package/lib/components/task/errors/RunErrorTable.js +2 -3
- package/lib/components/task/errors/SystemErrorsTable.js +1 -2
- package/lib/components/task/handlers/HandlerForm.js +2 -3
- package/lib/components/task/handlers/HandlerTable.js +1 -2
- package/lib/components/task/handlers/MissingHandlerTable.js +1 -2
- package/lib/components/task/policy_rule/PolicyRuleForm.js +2 -3
- package/lib/components/task/policy_rule/PolicyRuleTable.js +1 -2
- package/lib/components/task/runs/CreateManualTriggerForm.js +1 -2
- package/lib/components/task/runs/RunTable.js +2 -3
- package/lib/components/task/runs/RunTaskTable.js +1 -2
- package/lib/components/task/sources/SourceForm.js +1 -2
- package/lib/components/task/sources/SourceTable.js +1 -2
- package/lib/components/task/triggers/TriggerTable.js +2 -3
- package/lib/components/task/workflows/LinkedWorkflowForm.js +3 -5
- package/lib/components/task/workflows/LinkedWorkflowTable.js +1 -2
- package/lib/components/task/workflows/MissingRoutineTable.js +1 -2
- package/lib/components/task/workflows/WorkflowForm.js +91 -41
- package/lib/components/task/workflows/WorkflowTable.js +1 -2
- package/lib/helpers/SearchBuilder.js +2 -4
- package/lib/helpers/index.js +13 -26
- package/lib/index.js +3 -6
- package/lib/reducer.js +3 -5
- package/lib/saga.js +32 -48
- package/lib/store.js +32 -42
- package/package.json +12 -15
- package/lib/components/core/CoreFormModal.js +0 -64
- package/lib/components/core/CoreModal.js +0 -114
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.FormState = exports.Field = exports.FIELD_DEFAULT_VALUES = exports.DataSource = exports.DATA_SOURCE_STATUS = void 0;
|
|
7
7
|
var _immutable = require("immutable");
|
|
8
|
-
var FormState = (0, _immutable.Record)({
|
|
8
|
+
var FormState = exports.FormState = (0, _immutable.Record)({
|
|
9
9
|
addFields: (0, _immutable.List)(),
|
|
10
10
|
alterFields: (0, _immutable.Map)(),
|
|
11
11
|
bindings: {},
|
|
@@ -23,14 +23,12 @@ var FormState = (0, _immutable.Record)({
|
|
|
23
23
|
onSubmit: null,
|
|
24
24
|
submitting: false
|
|
25
25
|
});
|
|
26
|
-
exports.
|
|
27
|
-
var DATA_SOURCE_STATUS = {
|
|
26
|
+
var DATA_SOURCE_STATUS = exports.DATA_SOURCE_STATUS = {
|
|
28
27
|
PENDING: 'PENDING',
|
|
29
28
|
RESOLVED: 'RESOLVED',
|
|
30
29
|
REJECTED: 'REJECTED'
|
|
31
30
|
};
|
|
32
|
-
exports.
|
|
33
|
-
var DataSource = (0, _immutable.Record)({
|
|
31
|
+
var DataSource = exports.DataSource = (0, _immutable.Record)({
|
|
34
32
|
data: null,
|
|
35
33
|
fn: null,
|
|
36
34
|
params: null,
|
|
@@ -38,8 +36,7 @@ var DataSource = (0, _immutable.Record)({
|
|
|
38
36
|
status: DATA_SOURCE_STATUS.PENDING,
|
|
39
37
|
transform: null
|
|
40
38
|
});
|
|
41
|
-
exports.
|
|
42
|
-
var FIELD_DEFAULT_VALUES = (0, _immutable.Map)({
|
|
39
|
+
var FIELD_DEFAULT_VALUES = exports.FIELD_DEFAULT_VALUES = (0, _immutable.Map)({
|
|
43
40
|
attributes: (0, _immutable.Map)(),
|
|
44
41
|
checkbox: false,
|
|
45
42
|
'checkbox-multi': (0, _immutable.List)(),
|
|
@@ -56,8 +53,7 @@ var FIELD_DEFAULT_VALUES = (0, _immutable.Map)({
|
|
|
56
53
|
user: null,
|
|
57
54
|
'user-multi': (0, _immutable.List)()
|
|
58
55
|
});
|
|
59
|
-
exports.
|
|
60
|
-
var Field = (0, _immutable.Record)({
|
|
56
|
+
var Field = exports.Field = (0, _immutable.Record)({
|
|
61
57
|
constraint: null,
|
|
62
58
|
constraintMessage: 'Invalid',
|
|
63
59
|
dirty: false,
|
|
@@ -89,5 +85,4 @@ var Field = (0, _immutable.Record)({
|
|
|
89
85
|
valid: true,
|
|
90
86
|
value: null,
|
|
91
87
|
visible: true
|
|
92
|
-
});
|
|
93
|
-
exports.Field = Field;
|
|
88
|
+
});
|
|
@@ -6,8 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.FormState = void 0;
|
|
7
7
|
var _store = require("../../store");
|
|
8
8
|
var selectFormState = function selectFormState(formState) {
|
|
9
|
+
var _formState$fields;
|
|
9
10
|
return {
|
|
10
|
-
dirty: formState.fields.some(function (field) {
|
|
11
|
+
dirty: (_formState$fields = formState.fields) === null || _formState$fields === void 0 ? void 0 : _formState$fields.some(function (field) {
|
|
11
12
|
return field.dirty;
|
|
12
13
|
}),
|
|
13
14
|
error: formState.error
|
|
@@ -21,5 +22,4 @@ var mapStateToProps = function mapStateToProps(state, props) {
|
|
|
21
22
|
var FormStateComopnent = function FormStateComopnent(props) {
|
|
22
23
|
return props.formState && props.children(selectFormState(props.formState));
|
|
23
24
|
};
|
|
24
|
-
var FormState = (0, _store.connect)(mapStateToProps)(FormStateComopnent);
|
|
25
|
-
exports.FormState = FormState;
|
|
25
|
+
var FormState = exports.FormState = (0, _store.connect)(mapStateToProps)(FormStateComopnent);
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.KitchenSinkForm = void 0;
|
|
7
7
|
var _Form = require("./Form");
|
|
8
|
-
var KitchenSinkForm = (0, _Form.generateForm)({
|
|
8
|
+
var KitchenSinkForm = exports.KitchenSinkForm = (0, _Form.generateForm)({
|
|
9
9
|
dataSources: function dataSources() {
|
|
10
10
|
return {};
|
|
11
11
|
},
|
|
@@ -392,6 +392,27 @@ var KitchenSinkForm = (0, _Form.generateForm)({
|
|
|
392
392
|
}],
|
|
393
393
|
helpText: 'Help Text',
|
|
394
394
|
placeholder: 'Placeholder'
|
|
395
|
+
}, {
|
|
396
|
+
name: 'number1',
|
|
397
|
+
type: 'number',
|
|
398
|
+
label: 'Number 1'
|
|
399
|
+
}, {
|
|
400
|
+
name: 'number2',
|
|
401
|
+
type: 'number',
|
|
402
|
+
label: 'Number 2',
|
|
403
|
+
required: true
|
|
404
|
+
}, {
|
|
405
|
+
name: 'number3',
|
|
406
|
+
type: 'number',
|
|
407
|
+
label: 'Number 3',
|
|
408
|
+
enabled: false,
|
|
409
|
+
initialValue: 'asdfasdf'
|
|
410
|
+
}, {
|
|
411
|
+
name: 'number4',
|
|
412
|
+
type: 'number',
|
|
413
|
+
label: 'Number 4',
|
|
414
|
+
helpText: 'Help Text',
|
|
415
|
+
placeholder: 'Placeholder'
|
|
395
416
|
}, {
|
|
396
417
|
name: 'password1',
|
|
397
418
|
type: 'password',
|
|
@@ -764,5 +785,4 @@ var KitchenSinkForm = (0, _Form.generateForm)({
|
|
|
764
785
|
});
|
|
765
786
|
};
|
|
766
787
|
}
|
|
767
|
-
});
|
|
768
|
-
exports.KitchenSinkForm = KitchenSinkForm;
|
|
788
|
+
});
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.isEmpty = exports.getFieldComponents = exports.getFieldComponentProps = exports.getComponentName = exports.evaluateFields = exports.createFormState = exports.createFieldState = void 0;
|
|
8
|
+
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
|
|
9
|
+
var _immutable = require("immutable");
|
|
10
|
+
var _SimpleForm = require("./SimpleForm");
|
|
11
|
+
var _SimpleForm2 = require("./SimpleForm.models");
|
|
12
|
+
var _Form = require("./Form.models");
|
|
13
|
+
// If value is null for a text or select field, change it to the default value
|
|
14
|
+
// to prevent HTML errors
|
|
15
|
+
var correctRenderValue = function correctRenderValue(type) {
|
|
16
|
+
var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _Form.FIELD_DEFAULT_VALUES.get(type, '');
|
|
17
|
+
switch (type) {
|
|
18
|
+
case 'text':
|
|
19
|
+
case 'select':
|
|
20
|
+
return value !== null ? value : _Form.FIELD_DEFAULT_VALUES.get(type, '');
|
|
21
|
+
default:
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// Converts an array of fields to an OrderedMap using the `name` as the key
|
|
27
|
+
var convertFieldsToMap = function convertFieldsToMap(fields) {
|
|
28
|
+
return (0, _immutable.OrderedMap)(fields.filter(Boolean).map(function (field) {
|
|
29
|
+
return [field.name, field];
|
|
30
|
+
}));
|
|
31
|
+
};
|
|
32
|
+
var createFieldState = exports.createFieldState = function createFieldState(formKey) {
|
|
33
|
+
return function (_ref) {
|
|
34
|
+
var bindings = _ref.bindings,
|
|
35
|
+
constraint = _ref.constraint,
|
|
36
|
+
constraintMessage = _ref.constraintMessage,
|
|
37
|
+
enabled = _ref.enabled,
|
|
38
|
+
form = _ref.form,
|
|
39
|
+
helpText = _ref.helpText,
|
|
40
|
+
label = _ref.label,
|
|
41
|
+
language = _ref.language,
|
|
42
|
+
name = _ref.name,
|
|
43
|
+
onFocus = _ref.onFocus,
|
|
44
|
+
onChange = _ref.onChange,
|
|
45
|
+
onBlur = _ref.onBlur,
|
|
46
|
+
options = _ref.options,
|
|
47
|
+
pattern = _ref.pattern,
|
|
48
|
+
patternMessage = _ref.patternMessage,
|
|
49
|
+
placeholder = _ref.placeholder,
|
|
50
|
+
renderAttributes = _ref.renderAttributes,
|
|
51
|
+
required = _ref.required,
|
|
52
|
+
requiredMessage = _ref.requiredMessage,
|
|
53
|
+
search = _ref.search,
|
|
54
|
+
serialize = _ref.serialize,
|
|
55
|
+
_transient = _ref["transient"],
|
|
56
|
+
type = _ref.type,
|
|
57
|
+
visible = _ref.visible;
|
|
58
|
+
return (0, _SimpleForm2.SimpleFieldState)({
|
|
59
|
+
// Derived options
|
|
60
|
+
id: btoa("".concat(formKey, " ").concat(name)).replace(/=+$/, ''),
|
|
61
|
+
renderAttributes: (0, _immutable.fromJS)(renderAttributes),
|
|
62
|
+
// Options supporting conditional expressions,
|
|
63
|
+
enabled: typeof enabled === 'function' ? false : enabled,
|
|
64
|
+
label: typeof label === 'function' ? '' : label,
|
|
65
|
+
options: typeof options === 'function' ? (0, _immutable.List)() : (0, _immutable.fromJS)(options),
|
|
66
|
+
placeholder: typeof placeholder === 'function' ? '' : placeholder,
|
|
67
|
+
required: typeof required === 'function' ? false : required,
|
|
68
|
+
search: typeof search === 'function' ? (0, _immutable.Map)() : (0, _immutable.fromJS)(search),
|
|
69
|
+
"transient": typeof _transient === 'function' ? false : _transient,
|
|
70
|
+
visible: typeof visible === 'function' ? false : visible,
|
|
71
|
+
language: typeof language === 'function' ? null : language,
|
|
72
|
+
bindings: typeof bindings === 'function' ? null : bindings,
|
|
73
|
+
functions: (0, _immutable.Map)({
|
|
74
|
+
enabled: typeof enabled === 'function' ? enabled : null,
|
|
75
|
+
label: typeof label === 'function' ? label : null,
|
|
76
|
+
options: typeof options === 'function' ? options : null,
|
|
77
|
+
placeholder: typeof placeholder === 'function' ? placeholder : null,
|
|
78
|
+
required: typeof required === 'function' ? required : null,
|
|
79
|
+
search: typeof search === 'function' ? search : null,
|
|
80
|
+
"transient": typeof _transient === 'function' ? _transient : null,
|
|
81
|
+
visible: typeof visible === 'function' ? visible : null,
|
|
82
|
+
language: typeof language === 'function' ? language : null,
|
|
83
|
+
bindings: typeof bindings === 'function' ? bindings : null
|
|
84
|
+
}),
|
|
85
|
+
// Event handlers
|
|
86
|
+
eventHandlers: (0, _immutable.Map)({
|
|
87
|
+
onBlur: null,
|
|
88
|
+
onChange: null,
|
|
89
|
+
onFocus: null
|
|
90
|
+
}),
|
|
91
|
+
eventHandlerFunctions: (0, _immutable.Map)({
|
|
92
|
+
onBlur: (0, _SimpleForm.onBlur)({
|
|
93
|
+
formKey: formKey,
|
|
94
|
+
name: name
|
|
95
|
+
}),
|
|
96
|
+
onChange: (0, _SimpleForm.onChange)({
|
|
97
|
+
formKey: formKey,
|
|
98
|
+
type: type,
|
|
99
|
+
name: name
|
|
100
|
+
}),
|
|
101
|
+
onFocus: (0, _SimpleForm.onFocus)({
|
|
102
|
+
formKey: formKey,
|
|
103
|
+
name: name
|
|
104
|
+
})
|
|
105
|
+
}),
|
|
106
|
+
// Pass-through options
|
|
107
|
+
constraint: constraint,
|
|
108
|
+
constraintMessage: constraintMessage,
|
|
109
|
+
form: form,
|
|
110
|
+
helpText: helpText,
|
|
111
|
+
name: name,
|
|
112
|
+
onFocus: onFocus,
|
|
113
|
+
onChange: onChange,
|
|
114
|
+
onBlur: onBlur,
|
|
115
|
+
pattern: pattern,
|
|
116
|
+
patternMessage: patternMessage,
|
|
117
|
+
requiredMessage: requiredMessage,
|
|
118
|
+
serialize: serialize,
|
|
119
|
+
type: type
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
};
|
|
123
|
+
var createFormState = exports.createFormState = function createFormState(_ref2) {
|
|
124
|
+
var fields = _ref2.fields,
|
|
125
|
+
formKey = _ref2.formKey,
|
|
126
|
+
onLoad = _ref2.onLoad,
|
|
127
|
+
onReset = _ref2.onReset,
|
|
128
|
+
onSubmit = _ref2.onSubmit,
|
|
129
|
+
values = _ref2.values;
|
|
130
|
+
return (0, _SimpleForm2.SimpleFormState)({
|
|
131
|
+
fields: convertFieldsToMap(fields).map(createFieldState(formKey)),
|
|
132
|
+
formKey: formKey,
|
|
133
|
+
initialValues: values,
|
|
134
|
+
onLoad: onLoad,
|
|
135
|
+
onReset: onReset,
|
|
136
|
+
onSubmit: onSubmit
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
var isEmpty = exports.isEmpty = function isEmpty(value) {
|
|
140
|
+
return value === null || value === undefined || value === false || value === '' || (0, _immutable.isImmutable)(value) && value.isEmpty();
|
|
141
|
+
};
|
|
142
|
+
var checkRequired = function checkRequired(field) {
|
|
143
|
+
return field.required && isEmpty(field.value) ? (0, _immutable.List)([field.requiredMessage]) : (0, _immutable.List)();
|
|
144
|
+
};
|
|
145
|
+
var checkPattern = function checkPattern(bindings) {
|
|
146
|
+
return function (field) {
|
|
147
|
+
return field.pattern && field.type === 'text' && field.value !== '' && field.value !== null && !field.value.match(typeof field.pattern === 'function' ? field.pattern((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, bindings), {}, {
|
|
148
|
+
field: (0, _SimpleForm2.SimpleFieldBinding)(field)
|
|
149
|
+
})) : field.pattern) ? (0, _immutable.List)([field.patternMessage]) : (0, _immutable.List)();
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
var checkConstraint = function checkConstraint(bindings) {
|
|
153
|
+
return function (field) {
|
|
154
|
+
if (field.constraint) {
|
|
155
|
+
var result = field.constraint((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, bindings), {}, {
|
|
156
|
+
field: (0, _SimpleForm2.SimpleFieldBinding)(field)
|
|
157
|
+
}));
|
|
158
|
+
if (!result) {
|
|
159
|
+
return (0, _immutable.List)([field.constraintMessage]);
|
|
160
|
+
} else if (typeof result === 'string') {
|
|
161
|
+
return (0, _immutable.List)([result]);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
// Return no errors if there was no constraint or if the constraint did not
|
|
165
|
+
// evaluate to false or an error string.
|
|
166
|
+
return (0, _immutable.List)();
|
|
167
|
+
};
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
// Validate the field
|
|
171
|
+
var validateField = function validateField(bindings) {
|
|
172
|
+
var validateOnLoad = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
173
|
+
return function (field, name, fields) {
|
|
174
|
+
var errors = (0, _immutable.List)([checkRequired, checkPattern((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, bindings), {}, {
|
|
175
|
+
fields: fields.map(_SimpleForm2.SimpleFieldBinding)
|
|
176
|
+
})), checkConstraint((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, bindings), {}, {
|
|
177
|
+
fields: fields.map(_SimpleForm2.SimpleFieldBinding)
|
|
178
|
+
}))]).flatMap(function (fn) {
|
|
179
|
+
return fn(field);
|
|
180
|
+
});
|
|
181
|
+
return field.set('errors', errors).update('touched',
|
|
182
|
+
// Set touched to true if there are errors and the validateOnLoad flag is
|
|
183
|
+
// true to allow for showing errors on load of the form
|
|
184
|
+
function (touched) {
|
|
185
|
+
return errors.isEmpty() ? touched : touched || validateOnLoad;
|
|
186
|
+
});
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
// Resolve function props of the field
|
|
191
|
+
var evaluateFieldProps = function evaluateFieldProps(bindings) {
|
|
192
|
+
return function (field, name, fields) {
|
|
193
|
+
return field.functions.filter(function (fn) {
|
|
194
|
+
return !!fn;
|
|
195
|
+
}).reduce(function (reduction, fn, prop) {
|
|
196
|
+
return reduction.set(prop, (0, _immutable.fromJS)(fn((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, bindings), {}, {
|
|
197
|
+
fields: fields.map(_SimpleForm2.SimpleFieldBinding)
|
|
198
|
+
}))));
|
|
199
|
+
}, field);
|
|
200
|
+
};
|
|
201
|
+
};
|
|
202
|
+
var evaluateFieldHandlers = function evaluateFieldHandlers(bindings) {
|
|
203
|
+
return function (field, name, fields) {
|
|
204
|
+
return field.eventHandlerFunctions.filter(function (fn) {
|
|
205
|
+
return !!fn;
|
|
206
|
+
}).reduce(function (reduction, fn, prop) {
|
|
207
|
+
return reduction.setIn(['eventHandlers', prop], (0, _immutable.fromJS)(fn((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, bindings), {}, {
|
|
208
|
+
fields: fields.map(_SimpleForm2.SimpleFieldBinding)
|
|
209
|
+
}))));
|
|
210
|
+
}, field);
|
|
211
|
+
};
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
// Set the value into the field state object and set the dirty flag
|
|
215
|
+
var evaluateFieldValue = function evaluateFieldValue(bindings) {
|
|
216
|
+
return function (field) {
|
|
217
|
+
var value = (0, _immutable.getIn)(bindings, ['values', field.name]);
|
|
218
|
+
var initialValue = (0, _immutable.getIn)(bindings, ['initialValues', field.name]);
|
|
219
|
+
return field.set('value', (0, _immutable.fromJS)(value)).set('dirty', typeof initialValue !== 'undefined' ? value !== initialValue : field.touched);
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
var evaluateFields = exports.evaluateFields = function evaluateFields(fields, bindings, validateOnLoad) {
|
|
223
|
+
return fields ? fields.map(evaluateFieldValue(bindings)).map(evaluateFieldProps(bindings)).map(evaluateFieldHandlers(bindings)).map(validateField(bindings, validateOnLoad)) : fields;
|
|
224
|
+
};
|
|
225
|
+
var getComponentName = exports.getComponentName = function getComponentName(field) {
|
|
226
|
+
return field.type ? field.type.split('-').map(function (word) {
|
|
227
|
+
return "".concat(word.charAt(0).toUpperCase()).concat(word.substring(1));
|
|
228
|
+
}).join('') + 'Field' : null;
|
|
229
|
+
};
|
|
230
|
+
var getFieldComponents = exports.getFieldComponents = function getFieldComponents(fields) {
|
|
231
|
+
return convertFieldsToMap(fields).filter(function (fieldConfig) {
|
|
232
|
+
return fieldConfig.component;
|
|
233
|
+
}).map(function (fieldConfig) {
|
|
234
|
+
return fieldConfig.component;
|
|
235
|
+
});
|
|
236
|
+
};
|
|
237
|
+
var getFieldComponentProps = exports.getFieldComponentProps = function getFieldComponentProps(field, readOnly) {
|
|
238
|
+
return {
|
|
239
|
+
bindings: field.bindings,
|
|
240
|
+
dirty: field.dirty,
|
|
241
|
+
enabled: readOnly ? false : field.enabled,
|
|
242
|
+
errors: field.errors,
|
|
243
|
+
focused: field.focused,
|
|
244
|
+
form: field.form,
|
|
245
|
+
helpText: field.helpText,
|
|
246
|
+
id: field.id,
|
|
247
|
+
label: field.label,
|
|
248
|
+
language: field.type === 'code' ? field.language : undefined,
|
|
249
|
+
name: field.name,
|
|
250
|
+
onBlur: field.eventHandlers.get('onBlur'),
|
|
251
|
+
onChange: field.eventHandlers.get('onChange'),
|
|
252
|
+
onFocus: field.eventHandlers.get('onFocus'),
|
|
253
|
+
options: ['attributes', 'checkbox-multi', 'code', 'form', 'form-multi', 'list', 'map', 'radio', 'select', 'select-multi', 'table', 'text', 'text-multi'].includes(field.type) ? field.options : undefined,
|
|
254
|
+
placeholder: field.placeholder,
|
|
255
|
+
renderAttributes: field.renderAttributes,
|
|
256
|
+
required: field.required,
|
|
257
|
+
search: ['form', 'form-multi'].includes(field.type) ? field.search : undefined,
|
|
258
|
+
touched: field.touched,
|
|
259
|
+
value: correctRenderValue(field.type, field.value),
|
|
260
|
+
visible: field.visible
|
|
261
|
+
};
|
|
262
|
+
};
|