@kineticdata/react 6.0.0 → 6.0.2
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/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 +17 -33
- 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 +47 -30
- package/lib/apis/http.test.js +100 -0
- package/lib/apis/system/index.js +167 -81
- package/lib/apis/task/index.js +73 -118
- package/lib/components/agent/bridge/BridgeForm.js +1 -2
- package/lib/components/agent/bridge/BridgeTable.js +5 -3
- package/lib/components/agent/filestore/FilestoreForm.js +1 -2
- package/lib/components/agent/filestore/FilestoreTable.js +5 -3
- package/lib/components/agent/handler/AgentHandlerForm.js +1 -2
- package/lib/components/agent/handler/AgentHandlerTable.js +6 -4
- 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 +165 -0
- 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 +25 -0
- package/lib/components/common/defaults/index.js +12 -0
- package/lib/components/core/attribute_definition/AttributeDefinitionForm.js +1 -2
- package/lib/components/core/attribute_definition/AttributeDefinitionTable.js +8 -5
- package/lib/components/core/bridge_model/BridgeModelForm.js +52 -55
- package/lib/components/core/bridge_model/BridgeModelTable.js +6 -4
- 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 +14 -8
- 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 +13 -9
- 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 +1 -2
- package/lib/components/core/form/FormTable.js +23 -13
- package/lib/components/core/form_type/FormTypeForm.js +1 -2
- package/lib/components/core/form_type/FormTypeTable.js +4 -3
- 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 +13 -7
- 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 +18 -34
- package/lib/components/core/log/LogTable.js +10 -6
- 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 +10 -6
- 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 +39 -23
- package/lib/components/core/submission/KappSubmissionTable.js +39 -23
- 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 +2 -3
- package/lib/components/core/team/TeamTable.js +12 -7
- 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 +24 -7
- package/lib/components/core/webapi/WebApiForm.js +138 -123
- package/lib/components/core/webapi/WebApiTable.js +15 -9
- package/lib/components/core/webhook/WebhookForm.js +1 -2
- package/lib/components/core/webhook/WebhookTable.js +20 -11
- package/lib/components/core/webhook_job/WebhookJobTable.js +40 -21
- package/lib/components/form/Form.helpers.js +91 -38
- package/lib/components/form/Form.js +312 -355
- package/lib/components/form/Form.models.js +7 -11
- package/lib/components/form/FormState.js +1 -2
- 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 +3865 -4257
- package/lib/components/form/tests/components.js +2 -3
- package/lib/components/index.js +60 -0
- package/lib/components/system/SystemBackgroundTasksTable.js +1 -2
- package/lib/components/system/SystemCassandraForm.js +97 -0
- package/lib/components/system/SystemElasticSearchForm.js +97 -0
- package/lib/components/system/SystemFilestoreForm.js +12 -8
- package/lib/components/system/SystemForm.js +1 -2
- package/lib/components/system/SystemIngressForm.js +78 -31
- package/lib/components/system/SystemSecurityForm.js +1 -2
- package/lib/components/system/SystemSmtpForm.js +1 -2
- package/lib/components/system/SystemTaskAdapterForm.js +30 -7
- package/lib/components/system/SystemTrustedCertificateForm.js +39 -0
- package/lib/components/system/SystemTrustedCertificatesTable.js +73 -0
- package/lib/components/system/SystemUserForm.js +1 -2
- package/lib/components/system/helpers.js +236 -65
- package/lib/components/system/spaces/SystemSpaceForm.js +2 -3
- package/lib/components/system/spaces/SystemTenantForm.js +77 -37
- package/lib/components/system/spaces/SystemTenantTable.js +1 -2
- package/lib/components/table/Table.js +132 -54
- package/lib/components/table/Table.redux.js +229 -235
- package/lib/components/table/Table.test.js +154 -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 +25 -0
- 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 +5 -4
- 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 +10 -4
- package/lib/components/task/builder/builder.redux.js +171 -182
- 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 +19 -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 +35 -17
- 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 +24 -13
- 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 +24 -12
- 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 +16 -9
- package/lib/components/task/triggers/TriggerTable.js +52 -26
- package/lib/components/task/workflows/LinkedWorkflowForm.js +3 -5
- package/lib/components/task/workflows/LinkedWorkflowTable.js +33 -18
- package/lib/components/task/workflows/MissingRoutineTable.js +1 -2
- package/lib/components/task/workflows/WorkflowForm.js +2 -3
- package/lib/components/task/workflows/WorkflowTable.js +31 -17
- package/lib/helpers/SearchBuilder.js +2 -4
- package/lib/helpers/index.js +13 -26
- package/lib/index.js +7 -9
- package/lib/reducer.js +3 -5
- package/lib/saga.js +32 -48
- package/lib/store.js +32 -42
- package/package.json +26 -16
- package/proxyhelper.js +17 -11
- package/lib/components/core/CoreFormModal.js +0 -64
- package/lib/components/core/CoreModal.js +0 -114
|
@@ -1,19 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
|
|
4
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.TableLayout = exports.TableInput = void 0;
|
|
9
9
|
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
|
|
10
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
|
|
11
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectWithoutProperties"));
|
|
10
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
13
|
var _immutable = require("immutable");
|
|
12
14
|
var _reactBeautifulDnd = require("react-beautiful-dnd");
|
|
15
|
+
var _excluded = ["newRow"],
|
|
16
|
+
_excluded2 = ["name", "type", "options", "component"];
|
|
17
|
+
var TextDisplay = function TextDisplay(props) {
|
|
18
|
+
return /*#__PURE__*/_react["default"].createElement("span", {
|
|
19
|
+
id: props.id
|
|
20
|
+
}, props.value || '');
|
|
21
|
+
};
|
|
13
22
|
var TextInput = function TextInput(props) {
|
|
14
23
|
return /*#__PURE__*/_react["default"].createElement("input", {
|
|
15
24
|
type: "text",
|
|
16
|
-
id: props.id
|
|
25
|
+
id: props.id,
|
|
17
26
|
name: props.name,
|
|
18
27
|
value: props.value || '',
|
|
19
28
|
onBlur: props.onBlur,
|
|
@@ -22,10 +31,28 @@ var TextInput = function TextInput(props) {
|
|
|
22
31
|
form: props.form
|
|
23
32
|
});
|
|
24
33
|
};
|
|
34
|
+
var SelectInput = function SelectInput(props) {
|
|
35
|
+
return /*#__PURE__*/_react["default"].createElement("select", {
|
|
36
|
+
id: props.id,
|
|
37
|
+
name: props.name,
|
|
38
|
+
value: props.value || '',
|
|
39
|
+
onBlur: props.onBlur,
|
|
40
|
+
onChange: props.onChange,
|
|
41
|
+
onFocus: props.onFocus,
|
|
42
|
+
form: props.form
|
|
43
|
+
}, /*#__PURE__*/_react["default"].createElement("option", {
|
|
44
|
+
value: ""
|
|
45
|
+
}), props.options.map(function (option) {
|
|
46
|
+
return /*#__PURE__*/_react["default"].createElement("option", {
|
|
47
|
+
value: option.get('value'),
|
|
48
|
+
key: option.get('value')
|
|
49
|
+
}, option.get('label'));
|
|
50
|
+
}));
|
|
51
|
+
};
|
|
25
52
|
var CheckboxInput = function CheckboxInput(props) {
|
|
26
53
|
return /*#__PURE__*/_react["default"].createElement("input", {
|
|
27
54
|
type: "checkbox",
|
|
28
|
-
id: props.id
|
|
55
|
+
id: props.id,
|
|
29
56
|
name: props.name,
|
|
30
57
|
checked: props.value || false,
|
|
31
58
|
onBlur: props.onBlur,
|
|
@@ -34,123 +61,309 @@ var CheckboxInput = function CheckboxInput(props) {
|
|
|
34
61
|
form: props.form
|
|
35
62
|
});
|
|
36
63
|
};
|
|
37
|
-
var DragHandle = function DragHandle(
|
|
38
|
-
|
|
64
|
+
var DragHandle = function DragHandle(_ref) {
|
|
65
|
+
var newRow = _ref.newRow,
|
|
66
|
+
props = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
|
|
67
|
+
return !newRow && /*#__PURE__*/_react["default"].createElement("span", props, "\u2195");
|
|
39
68
|
};
|
|
40
|
-
var TableLayout = function TableLayout(
|
|
41
|
-
var
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
69
|
+
var TableLayout = exports.TableLayout = function TableLayout(_ref2) {
|
|
70
|
+
var droppableRef = _ref2.droppableRef,
|
|
71
|
+
focusRef = _ref2.focusRef,
|
|
72
|
+
rows = _ref2.rows,
|
|
73
|
+
onAdd = _ref2.onAdd,
|
|
74
|
+
options = _ref2.options;
|
|
75
|
+
return /*#__PURE__*/_react["default"].createElement(_react.Fragment, null, /*#__PURE__*/_react["default"].createElement("div", {
|
|
76
|
+
className: "table-responsive",
|
|
77
|
+
ref: focusRef,
|
|
78
|
+
tabIndex: "-1"
|
|
79
|
+
}, /*#__PURE__*/_react["default"].createElement("table", null, /*#__PURE__*/_react["default"].createElement("thead", null, /*#__PURE__*/_react["default"].createElement("tr", null, options.toIndexedSeq().toList().filter(function (config) {
|
|
80
|
+
return config.get('visible') !== false;
|
|
81
|
+
}).map(function (config) {
|
|
45
82
|
return /*#__PURE__*/_react["default"].createElement("th", {
|
|
46
83
|
key: config.get('name')
|
|
47
84
|
}, config.get('label'));
|
|
48
|
-
}), /*#__PURE__*/_react["default"].createElement("th", null, "\xA0"))), /*#__PURE__*/_react["default"].createElement("tbody",
|
|
85
|
+
}), /*#__PURE__*/_react["default"].createElement("th", null, "\xA0"))), /*#__PURE__*/_react["default"].createElement("tbody", {
|
|
86
|
+
ref: droppableRef
|
|
87
|
+
}, rows))), onAdd && /*#__PURE__*/_react["default"].createElement("button", {
|
|
49
88
|
type: "button",
|
|
50
89
|
onClick: onAdd
|
|
51
90
|
}, "Add"));
|
|
52
91
|
};
|
|
53
|
-
|
|
54
|
-
var
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
92
|
+
var RowLayout = function RowLayout(_ref3) {
|
|
93
|
+
var rowProps = _ref3.rowProps,
|
|
94
|
+
dragging = _ref3.dragging,
|
|
95
|
+
draggableRef = _ref3.draggableRef,
|
|
96
|
+
draggableProps = _ref3.draggableProps,
|
|
97
|
+
fields = _ref3.fields,
|
|
98
|
+
onDelete = _ref3.onDelete,
|
|
99
|
+
onEdit = _ref3.onEdit;
|
|
100
|
+
return /*#__PURE__*/_react["default"].createElement("tr", Object.assign({}, rowProps, {
|
|
101
|
+
ref: draggableRef
|
|
102
|
+
}, draggableProps, {
|
|
103
|
+
className: dragging ? 'dragging' : ''
|
|
104
|
+
}), fields.map(function (field, name) {
|
|
58
105
|
return /*#__PURE__*/_react["default"].createElement("td", {
|
|
59
106
|
key: name
|
|
60
107
|
}, field);
|
|
61
|
-
}).toList(), /*#__PURE__*/_react["default"].createElement("td", null, /*#__PURE__*/_react["default"].createElement("button", {
|
|
108
|
+
}).toList(), /*#__PURE__*/_react["default"].createElement("td", null, onEdit && /*#__PURE__*/_react["default"].createElement("button", {
|
|
109
|
+
type: "button",
|
|
110
|
+
onClick: onEdit
|
|
111
|
+
}, "Edit"), onDelete && /*#__PURE__*/_react["default"].createElement("button", {
|
|
62
112
|
type: "button",
|
|
63
113
|
onClick: onDelete
|
|
64
114
|
}, "Delete")));
|
|
65
115
|
};
|
|
66
116
|
var typeToComponent = {
|
|
67
117
|
drag: 'DragHandle',
|
|
68
|
-
|
|
69
|
-
checkbox: 'CheckboxInput'
|
|
118
|
+
display: 'TextDisplay',
|
|
119
|
+
checkbox: 'CheckboxInput',
|
|
120
|
+
select: 'SelectInput',
|
|
121
|
+
text: 'TextInput'
|
|
70
122
|
};
|
|
71
123
|
var defaultComponents = {
|
|
72
124
|
TableLayout: TableLayout,
|
|
73
125
|
RowLayout: RowLayout,
|
|
74
|
-
|
|
126
|
+
DragHandle: DragHandle,
|
|
127
|
+
TextDisplay: TextDisplay,
|
|
75
128
|
CheckboxInput: CheckboxInput,
|
|
76
|
-
|
|
129
|
+
SelectInput: SelectInput,
|
|
130
|
+
TextInput: TextInput
|
|
77
131
|
};
|
|
78
132
|
var fieldFromConfig = function fieldFromConfig(config) {
|
|
79
133
|
var components = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
80
|
-
return components[typeToComponent[config.get('type')]] || components['
|
|
134
|
+
return config.get('component') || components[typeToComponent[config.get('type')]] || components['TextDisplay'];
|
|
135
|
+
};
|
|
136
|
+
var getEmptyRowValues = function getEmptyRowValues(options) {
|
|
137
|
+
return options
|
|
138
|
+
// Exclude drag columns from data object and any transient columns
|
|
139
|
+
.filter(function (config) {
|
|
140
|
+
return config.get('type') !== 'drag' && !config.get('transient');
|
|
141
|
+
})
|
|
142
|
+
// Reduce list of options to a map of values
|
|
143
|
+
.reduce(function (row, config) {
|
|
144
|
+
return row.set(config.get('name'), typeof config.get('initialValue') !== 'undefined' ? config.get('initialValue') : config.get('type') === 'checkbox' ? false : '');
|
|
145
|
+
}, (0, _immutable.Map)());
|
|
81
146
|
};
|
|
82
|
-
var TableInput = function TableInput(props) {
|
|
147
|
+
var TableInput = exports.TableInput = function TableInput(props) {
|
|
83
148
|
var _props$components = props.components,
|
|
84
149
|
components = _props$components === void 0 ? {} : _props$components,
|
|
85
150
|
options = props.options,
|
|
86
151
|
rows = props.rows,
|
|
87
152
|
onChange = props.onChange,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
153
|
+
onAdd = props.onAdd,
|
|
154
|
+
omitAdd = props.omitAdd,
|
|
155
|
+
autoAdd = props.autoAdd,
|
|
156
|
+
onDelete = props.onDelete,
|
|
157
|
+
omitDelete = props.omitDelete,
|
|
158
|
+
onEdit = props.onEdit,
|
|
159
|
+
disabled = props.disabled,
|
|
160
|
+
form = props.form,
|
|
161
|
+
focusRef = props.focusRef;
|
|
162
|
+
// State for new order row
|
|
163
|
+
var _useState = (0, _react.useState)(getEmptyRowValues(options)),
|
|
164
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
165
|
+
newRow = _useState2[0],
|
|
166
|
+
setNewRow = _useState2[1];
|
|
167
|
+
// Change event for new row
|
|
168
|
+
var newFieldChangeHandler = !disabled && autoAdd ? function (name, type) {
|
|
169
|
+
return function (e) {
|
|
170
|
+
// Update the new row value
|
|
171
|
+
var updatedValues = newRow.set(name, e && e.target ? type === 'checkbox' ? e.target.checked : e.target.value : e);
|
|
172
|
+
// Check if all required values in the new row have data, and if they
|
|
173
|
+
// do, add that row and reset the newRow to initial values
|
|
174
|
+
if (options.filter(function (option) {
|
|
175
|
+
return option.get('required');
|
|
176
|
+
}).every(function (option) {
|
|
177
|
+
return !!updatedValues.get(option.get('name'));
|
|
178
|
+
})) {
|
|
179
|
+
onChange(rows.push(updatedValues));
|
|
180
|
+
setNewRow(getEmptyRowValues(options));
|
|
181
|
+
} else {
|
|
182
|
+
// Otherwise just update the current field in the new row
|
|
183
|
+
setNewRow(updatedValues);
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
} : undefined;
|
|
187
|
+
// State to track if we need to focus one of the new row fields, This is used
|
|
188
|
+
// when mirroring is used to focus the next row on press of enter.
|
|
189
|
+
var _useState3 = (0, _react.useState)(null),
|
|
190
|
+
_useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
|
|
191
|
+
mirrorFocusField = _useState4[0],
|
|
192
|
+
setMirrorFocusField = _useState4[1];
|
|
193
|
+
var mirrorFocusRef = function mirrorFocusRef(node) {
|
|
194
|
+
if (node) node.focus();
|
|
195
|
+
setMirrorFocusField(null);
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
// Create a list of components, overriding any defualts by those provided
|
|
91
199
|
var appliedComponents = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, defaultComponents), components);
|
|
92
200
|
var RowLayout = appliedComponents.RowLayout,
|
|
93
201
|
TableLayout = appliedComponents.TableLayout;
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}, (0, _immutable.Map)());
|
|
101
|
-
onChange(rows.push(newRow));
|
|
102
|
-
};
|
|
202
|
+
|
|
203
|
+
// Disable drag if there are no columns of type drag
|
|
204
|
+
var isDragDisabled = !options.some(function (option) {
|
|
205
|
+
return option.get('type') === 'drag';
|
|
206
|
+
});
|
|
207
|
+
// Handler for moving rows via dragging
|
|
103
208
|
var onDragEnd = function onDragEnd(e) {
|
|
104
209
|
if (e.source && e.destination) {
|
|
105
210
|
onChange(rows["delete"](e.source.index).insert(e.destination.index, rows.get(e.source.index)));
|
|
106
211
|
}
|
|
107
212
|
};
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
213
|
+
|
|
214
|
+
// Create add handler for adding new rows to the table
|
|
215
|
+
var handleAddRow = !disabled && !omitAdd && !autoAdd ? typeof onAdd === 'function' ?
|
|
216
|
+
// If onAdd is provided, us it as the handler, and pass the data it
|
|
217
|
+
// may need and the onChange function
|
|
218
|
+
function (event) {
|
|
219
|
+
return onAdd(event, {
|
|
220
|
+
rows: rows,
|
|
221
|
+
options: options,
|
|
222
|
+
onChange: onChange
|
|
223
|
+
});
|
|
224
|
+
} :
|
|
225
|
+
// Otherwise, add a blank row
|
|
226
|
+
function () {
|
|
227
|
+
return onChange(rows.push(getEmptyRowValues(options)));
|
|
228
|
+
} : undefined;
|
|
229
|
+
var rowCount = rows.size;
|
|
230
|
+
var fieldRows = rows
|
|
231
|
+
// Add new row if autoAdd is enabled
|
|
232
|
+
.push(!disabled && autoAdd && newRow).filter(Boolean).map(function (row, index) {
|
|
233
|
+
// Create delete handler for a row
|
|
234
|
+
var handleDeleteRow = !disabled && !omitDelete ? typeof onDelete === 'function' ?
|
|
235
|
+
// If onDelete is provided, us it as the handler, and pass the data
|
|
236
|
+
// it may need and the onChange function
|
|
237
|
+
function (event) {
|
|
238
|
+
return onDelete(event, {
|
|
239
|
+
index: index,
|
|
240
|
+
rows: rows,
|
|
241
|
+
options: options,
|
|
242
|
+
onChange: onChange
|
|
243
|
+
});
|
|
244
|
+
} :
|
|
245
|
+
// Otherwise, delete the row
|
|
246
|
+
function () {
|
|
247
|
+
return onChange(rows["delete"](index));
|
|
248
|
+
} : undefined;
|
|
249
|
+
|
|
250
|
+
// Create edit handler for a row, but only if onEdit was provided
|
|
251
|
+
var handleEditRow = !disabled && typeof onEdit === 'function' ? function (event) {
|
|
252
|
+
return onEdit(event, {
|
|
253
|
+
index: index,
|
|
254
|
+
rows: rows,
|
|
255
|
+
options: options,
|
|
256
|
+
onChange: onChange
|
|
257
|
+
});
|
|
258
|
+
} : undefined;
|
|
259
|
+
// Check if we're on a new row (not one that's saved in the table)
|
|
260
|
+
var isNewRow = autoAdd && index >= rowCount;
|
|
261
|
+
// Filter the options to the fields that are visible
|
|
262
|
+
var fieldOptions = options.toOrderedMap().mapKeys(function (_, config) {
|
|
263
|
+
return config.get('name');
|
|
264
|
+
}).filter(function (config) {
|
|
265
|
+
return config.get('visible') !== false;
|
|
266
|
+
});
|
|
267
|
+
// Check if any of the fields have the mirror property, which specifies
|
|
268
|
+
// that the field should mirror (copy) the value of the configured field
|
|
269
|
+
var hasMirroring = !!fieldOptions.find(function (c) {
|
|
270
|
+
return !!c.get('mirror');
|
|
271
|
+
});
|
|
116
272
|
return /*#__PURE__*/_react["default"].createElement(_reactBeautifulDnd.Draggable, {
|
|
117
273
|
draggableId: "draggable".concat(index),
|
|
118
274
|
index: index,
|
|
119
275
|
key: index,
|
|
120
|
-
isDragDisabled: isDragDisabled
|
|
276
|
+
isDragDisabled: !isNewRow ? isDragDisabled : true
|
|
121
277
|
}, function (provided, snapshot) {
|
|
122
278
|
// For each of the options specified for the field, we render a table
|
|
123
279
|
// cell with a field in it. The field type is determined by the type
|
|
124
280
|
// of the option.
|
|
125
|
-
var fields =
|
|
126
|
-
return config.get('name');
|
|
127
|
-
}).map(function (config) {
|
|
281
|
+
var fields = fieldOptions.map(function (config) {
|
|
128
282
|
var Field = fieldFromConfig(config, appliedComponents);
|
|
129
283
|
var _config$toObject = config.toObject(),
|
|
130
|
-
label = _config$toObject.label,
|
|
131
284
|
name = _config$toObject.name,
|
|
132
|
-
type = _config$toObject.type
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
var
|
|
137
|
-
|
|
138
|
-
label: label,
|
|
139
|
-
onBlur: onBlur,
|
|
140
|
-
onChange: fieldOnChange,
|
|
141
|
-
onFocus: onFocus,
|
|
142
|
-
value: value,
|
|
143
|
-
form: form
|
|
285
|
+
type = _config$toObject.type,
|
|
286
|
+
optionsOrig = _config$toObject.options,
|
|
287
|
+
component = _config$toObject.component,
|
|
288
|
+
fieldProps = (0, _objectWithoutProperties2["default"])(_config$toObject, _excluded2);
|
|
289
|
+
var fieldChangeHandler = function fieldChangeHandler(e) {
|
|
290
|
+
return onChange(rows.setIn([index, name], e && e.target ? type === 'checkbox' ? e.target.checked : e.target.value : e));
|
|
144
291
|
};
|
|
292
|
+
var props = type === 'drag' ? (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, provided.dragHandleProps), {}, {
|
|
293
|
+
newRow: isNewRow
|
|
294
|
+
}) : (0, _objectSpread2["default"])((0, _objectSpread2["default"])({
|
|
295
|
+
visible: true
|
|
296
|
+
}, fieldProps), {}, {
|
|
297
|
+
name: name,
|
|
298
|
+
// If this field is mirroring another field, show the
|
|
299
|
+
// mirrored value when there is no value
|
|
300
|
+
value: row.get(name) || (isNewRow && config.has('mirror') ? row.get(config.get('mirror')) : row.get(name)),
|
|
301
|
+
onChange: !isNewRow ? fieldChangeHandler : newFieldChangeHandler(name, type),
|
|
302
|
+
// If this field is being mirrored, set the value of the
|
|
303
|
+
// mirroring field on blur of this field
|
|
304
|
+
onBlur: isNewRow && !!fieldOptions.find(function (c) {
|
|
305
|
+
return c.get('mirror') === name;
|
|
306
|
+
}) ? function (e) {
|
|
307
|
+
// Find the mirroring field (there should only be one)
|
|
308
|
+
var mirroringConfig = fieldOptions.find(function (c) {
|
|
309
|
+
return c.get('mirror') === name;
|
|
310
|
+
});
|
|
311
|
+
// If the mirroring field's value is empty,
|
|
312
|
+
// update its value to match this field's value
|
|
313
|
+
if (!row.get(mirroringConfig.get('name'))) {
|
|
314
|
+
newFieldChangeHandler(mirroringConfig.get('name'), type)(row.get(name));
|
|
315
|
+
}
|
|
316
|
+
// Trigger the original onBlur event if any
|
|
317
|
+
if (typeof fieldProps.onBlur === 'function') fieldProps.onBlur(e);
|
|
318
|
+
} : fieldProps.onFocus,
|
|
319
|
+
// If options is a function, pass it the current value
|
|
320
|
+
// so we can do things like only allow each value to be
|
|
321
|
+
// selected once
|
|
322
|
+
options: typeof optionsOrig === 'function' ? optionsOrig({
|
|
323
|
+
value: row.get(name)
|
|
324
|
+
}) : optionsOrig,
|
|
325
|
+
enabled: !disabled,
|
|
326
|
+
form: form,
|
|
327
|
+
row: row,
|
|
328
|
+
newRow: isNewRow,
|
|
329
|
+
focusRef: isNewRow && mirrorFocusField === name ? mirrorFocusRef : fieldProps.focusRef
|
|
330
|
+
});
|
|
145
331
|
return /*#__PURE__*/_react["default"].createElement(Field, props);
|
|
146
332
|
});
|
|
147
333
|
return /*#__PURE__*/_react["default"].createElement(RowLayout, {
|
|
148
334
|
draggableRef: provided.innerRef,
|
|
149
335
|
draggableProps: provided.draggableProps,
|
|
150
336
|
dragging: snapshot.isDragging,
|
|
337
|
+
index: index,
|
|
338
|
+
rowCount: rowCount,
|
|
151
339
|
fields: fields,
|
|
152
340
|
options: options,
|
|
153
|
-
onDelete: handleDeleteRow
|
|
341
|
+
onDelete: !isNewRow ? handleDeleteRow : undefined,
|
|
342
|
+
onEdit: !isNewRow ? handleEditRow : undefined,
|
|
343
|
+
rowProps: {
|
|
344
|
+
// If mirroring is used, add a keyDown event to the new row
|
|
345
|
+
// to capture a press of Enter in the mirrored field that
|
|
346
|
+
// should trigger the update of the mirroring field's value
|
|
347
|
+
onKeyDown: isNewRow && hasMirroring ? function (e) {
|
|
348
|
+
if (e.key === 'Enter') {
|
|
349
|
+
// Find the mirroring field and mirrored field
|
|
350
|
+
var mirroringConfig = fieldOptions.find(function (c) {
|
|
351
|
+
return !!c.get('mirror');
|
|
352
|
+
});
|
|
353
|
+
var mirroredConfig = fieldOptions.find(function (c) {
|
|
354
|
+
return mirroringConfig.get('mirror') === c.get('name');
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
// If we're in the mirrored field, the mirroring
|
|
358
|
+
// field is empty, and the mirrored field is not
|
|
359
|
+
// empty, set the mirroring field's value
|
|
360
|
+
if (mirroredConfig.get('name') === e.target.name && !!newRow.get(mirroredConfig.get('name')) && !newRow.get(mirroringConfig.get('name'))) {
|
|
361
|
+
newFieldChangeHandler(mirroringConfig.get('name'))(newRow.get(mirroredConfig.get('name')));
|
|
362
|
+
setMirrorFocusField(e.target.name);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
} : undefined
|
|
366
|
+
}
|
|
154
367
|
});
|
|
155
368
|
});
|
|
156
369
|
});
|
|
@@ -161,11 +374,11 @@ var TableInput = function TableInput(props) {
|
|
|
161
374
|
}, function (provided) {
|
|
162
375
|
return /*#__PURE__*/_react["default"].createElement(TableLayout, {
|
|
163
376
|
droppableRef: provided.innerRef,
|
|
377
|
+
focusRef: focusRef,
|
|
164
378
|
rows: fieldRows,
|
|
165
379
|
onAdd: handleAddRow,
|
|
166
380
|
options: options,
|
|
167
381
|
placeholder: provided.placeholder
|
|
168
382
|
});
|
|
169
383
|
}));
|
|
170
|
-
};
|
|
171
|
-
exports.TableInput = TableInput;
|
|
384
|
+
};
|
|
@@ -56,20 +56,20 @@ var valueToCustomTeam = function valueToCustomTeam(_ref3) {
|
|
|
56
56
|
var getStatusProps = function getStatusProps(_ref4) {
|
|
57
57
|
var _ref4$search = _ref4.search,
|
|
58
58
|
search = _ref4$search === void 0 ? (0, _immutable.Map)() : _ref4$search,
|
|
59
|
-
_ref4$messages = _ref4.messages
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
_short = _ref4$
|
|
63
|
-
_ref4$
|
|
64
|
-
empty = _ref4$
|
|
65
|
-
_ref4$
|
|
66
|
-
custom = _ref4$
|
|
67
|
-
_ref4$
|
|
68
|
-
pending = _ref4$
|
|
69
|
-
_ref4$
|
|
70
|
-
more = _ref4$
|
|
71
|
-
_ref4$
|
|
72
|
-
error = _ref4$
|
|
59
|
+
_ref4$messages = _ref4.messages,
|
|
60
|
+
_ref4$messages2 = _ref4$messages === void 0 ? {} : _ref4$messages,
|
|
61
|
+
_ref4$messages2$short = _ref4$messages2["short"],
|
|
62
|
+
_short = _ref4$messages2$short === void 0 ? 'Type to find a team.' : _ref4$messages2$short,
|
|
63
|
+
_ref4$messages2$empty = _ref4$messages2.empty,
|
|
64
|
+
empty = _ref4$messages2$empty === void 0 ? 'No matching teams.' : _ref4$messages2$empty,
|
|
65
|
+
_ref4$messages2$custo = _ref4$messages2.custom,
|
|
66
|
+
custom = _ref4$messages2$custo === void 0 ? 'No matching teams. Type to enter a custom option.' : _ref4$messages2$custo,
|
|
67
|
+
_ref4$messages2$pendi = _ref4$messages2.pending,
|
|
68
|
+
pending = _ref4$messages2$pendi === void 0 ? 'Searching...' : _ref4$messages2$pendi,
|
|
69
|
+
_ref4$messages2$more = _ref4$messages2.more,
|
|
70
|
+
more = _ref4$messages2$more === void 0 ? "Too many teams, first ".concat(search.get('limit') || 25, " shown. Please refine your search.") : _ref4$messages2$more,
|
|
71
|
+
_ref4$messages2$error = _ref4$messages2.error,
|
|
72
|
+
error = _ref4$messages2$error === void 0 ? 'There was an error fetching teams.' : _ref4$messages2$error;
|
|
73
73
|
return function (props) {
|
|
74
74
|
return {
|
|
75
75
|
meta: props.searchField ? "Find Teams by ".concat(fields[props.searchField]) : null,
|
|
@@ -91,7 +91,7 @@ var getStatusProps = function getStatusProps(_ref4) {
|
|
|
91
91
|
};
|
|
92
92
|
};
|
|
93
93
|
};
|
|
94
|
-
var TeamSelect = function TeamSelect(props) {
|
|
94
|
+
var TeamSelect = exports.TeamSelect = function TeamSelect(props) {
|
|
95
95
|
return /*#__PURE__*/_react["default"].createElement(_Typeahead.Typeahead, {
|
|
96
96
|
components: props.components || {},
|
|
97
97
|
disabled: props.disabled,
|
|
@@ -109,5 +109,4 @@ var TeamSelect = function TeamSelect(props) {
|
|
|
109
109
|
id: props.id,
|
|
110
110
|
form: props.form
|
|
111
111
|
});
|
|
112
|
-
};
|
|
113
|
-
exports.TeamSelect = TeamSelect;
|
|
112
|
+
};
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard")["default"];
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.showToast = exports.hideToast = exports.clearToasts = exports.ToastState = exports.ToastContainer = void 0;
|
|
9
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectWithoutProperties"));
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
|
+
var _store = require("../../store");
|
|
13
|
+
var _react2 = require("@kineticdata/react");
|
|
14
|
+
var _immutable = require("immutable");
|
|
15
|
+
var _ComponentConfigContext = require("./ComponentConfigContext");
|
|
16
|
+
var _excluded = ["autoHide", "content"];
|
|
17
|
+
var ToastState = exports.ToastState = (0, _immutable.Record)({
|
|
18
|
+
title: null,
|
|
19
|
+
content: null,
|
|
20
|
+
icon: null,
|
|
21
|
+
color: null,
|
|
22
|
+
className: '',
|
|
23
|
+
autoHide: true,
|
|
24
|
+
duration: null
|
|
25
|
+
});
|
|
26
|
+
(0, _store.regHandlers)({
|
|
27
|
+
// Initialize state for toasts as an OrderedMap so the order doesn't change
|
|
28
|
+
INIT_TOASTS: function INIT_TOASTS(state) {
|
|
29
|
+
return state.update('toasts', function (toasts) {
|
|
30
|
+
return _immutable.OrderedMap.isOrderedMap(toasts) ? toasts : (0, _immutable.OrderedMap)(toasts || {});
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
ADD_TOAST: function ADD_TOAST(state, action) {
|
|
34
|
+
return state.setIn(['toasts', action.payload.toastKey], action.payload);
|
|
35
|
+
},
|
|
36
|
+
SHOW_TOAST: function SHOW_TOAST(state, action) {
|
|
37
|
+
return state.hasIn(['toasts', action.payload]) ? state.setIn(['toasts', action.payload, 'show'], true) : state;
|
|
38
|
+
},
|
|
39
|
+
HIDE_TOAST: function HIDE_TOAST(state, action) {
|
|
40
|
+
return state.hasIn(['toasts', action.payload]) ? state.setIn(['toasts', action.payload, 'show'], false) : state;
|
|
41
|
+
},
|
|
42
|
+
REMOVE_TOAST: function REMOVE_TOAST(state, action) {
|
|
43
|
+
return state.removeIn(['toasts', action.payload]);
|
|
44
|
+
},
|
|
45
|
+
CLEAR_TOASTS: function CLEAR_TOASTS(state, action) {
|
|
46
|
+
return state.update('toasts', function (toasts) {
|
|
47
|
+
return action.payload ? toasts.filter(function (toast) {
|
|
48
|
+
return toast.containerKey !== action.payload;
|
|
49
|
+
}) : (0, _immutable.OrderedMap)();
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// Adds toast to state and shows it after 100ms delay to trigger animation
|
|
55
|
+
var showToast = exports.showToast = function showToast(toast) {
|
|
56
|
+
var toastKey = (0, _react2.generateKey)();
|
|
57
|
+
(0, _store.dispatch)('ADD_TOAST', {
|
|
58
|
+
containerKey: toast.containerKey,
|
|
59
|
+
toast: ToastState(toast).update(
|
|
60
|
+
// Make sure duration is a number, or set to a default numeric value
|
|
61
|
+
'duration', function (duration) {
|
|
62
|
+
return typeof duration === 'number' ? Math.max(duration, 4000) : toast.content ? 7000 : 4000;
|
|
63
|
+
}),
|
|
64
|
+
toastKey: toastKey,
|
|
65
|
+
show: false
|
|
66
|
+
});
|
|
67
|
+
setTimeout(function () {
|
|
68
|
+
(0, _store.dispatch)('SHOW_TOAST', toastKey);
|
|
69
|
+
}, 100);
|
|
70
|
+
return toastKey;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// Hides the toast and removes it from state after animation ends
|
|
74
|
+
var hideToast = exports.hideToast = function hideToast(toastKey) {
|
|
75
|
+
(0, _store.dispatch)('HIDE_TOAST', toastKey);
|
|
76
|
+
setTimeout(function () {
|
|
77
|
+
(0, _store.dispatch)('REMOVE_TOAST', toastKey);
|
|
78
|
+
}, 300);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// Clears all toasts, or if containerKey is provided, only the matching ones
|
|
82
|
+
var clearToasts = exports.clearToasts = function clearToasts(containerKey) {
|
|
83
|
+
(0, _store.dispatch)('CLEAR_TOASTS', containerKey);
|
|
84
|
+
};
|
|
85
|
+
var ToastWrapper = function ToastWrapper(_ref) {
|
|
86
|
+
var Toast = _ref.component,
|
|
87
|
+
show = _ref.show,
|
|
88
|
+
toastKey = _ref.toastKey,
|
|
89
|
+
toast = _ref.toast;
|
|
90
|
+
var _toast$toJS = toast.toJS(),
|
|
91
|
+
autoHide = _toast$toJS.autoHide,
|
|
92
|
+
content = _toast$toJS.content,
|
|
93
|
+
toastProps = (0, _objectWithoutProperties2["default"])(_toast$toJS, _excluded);
|
|
94
|
+
var toggle = (0, _react.useCallback)(function () {
|
|
95
|
+
return hideToast(toastKey);
|
|
96
|
+
}, [toastKey]);
|
|
97
|
+
return /*#__PURE__*/_react["default"].createElement(Toast, Object.assign({
|
|
98
|
+
key: toastKey
|
|
99
|
+
}, toastProps, {
|
|
100
|
+
show: show,
|
|
101
|
+
toggle: toggle,
|
|
102
|
+
autoHide: autoHide
|
|
103
|
+
}), content);
|
|
104
|
+
};
|
|
105
|
+
var ToastContainerComponent = function ToastContainerComponent(_ref2) {
|
|
106
|
+
var components = _ref2.components,
|
|
107
|
+
toasts = _ref2.toasts,
|
|
108
|
+
persistentToasts = _ref2.persistentToasts;
|
|
109
|
+
(0, _react.useEffect)(function () {
|
|
110
|
+
(0, _store.dispatch)('INIT_TOASTS');
|
|
111
|
+
return function () {};
|
|
112
|
+
}, []);
|
|
113
|
+
return /*#__PURE__*/_react["default"].createElement(_ComponentConfigContext.ComponentConfigContext.Consumer, null, function (componentConfig) {
|
|
114
|
+
var component = (0, _immutable.get)(components, 'Toast', componentConfig.get('Toast'));
|
|
115
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("div", {
|
|
116
|
+
className: "toast-container",
|
|
117
|
+
"aria-live": "polite",
|
|
118
|
+
"aria-atomic": "true"
|
|
119
|
+
}, toasts.map(function (props) {
|
|
120
|
+
return /*#__PURE__*/_react["default"].createElement(ToastWrapper, Object.assign({
|
|
121
|
+
key: props.toastKey
|
|
122
|
+
}, props, {
|
|
123
|
+
component: component
|
|
124
|
+
}));
|
|
125
|
+
})), /*#__PURE__*/_react["default"].createElement("div", {
|
|
126
|
+
className: "toast-container-persistent",
|
|
127
|
+
"aria-live": "polite",
|
|
128
|
+
"aria-atomic": "true"
|
|
129
|
+
}, persistentToasts.map(function (props) {
|
|
130
|
+
return /*#__PURE__*/_react["default"].createElement(ToastWrapper, Object.assign({
|
|
131
|
+
key: props.toastKey
|
|
132
|
+
}, props, {
|
|
133
|
+
component: component
|
|
134
|
+
}));
|
|
135
|
+
})));
|
|
136
|
+
});
|
|
137
|
+
};
|
|
138
|
+
var mapStateToProps = function mapStateToProps(state, props) {
|
|
139
|
+
// Get the toasts for this container
|
|
140
|
+
var containerToasts = state.get('toasts', (0, _immutable.List)()).filter(function (_ref3) {
|
|
141
|
+
var containerKey = _ref3.containerKey;
|
|
142
|
+
return props.containerKey ? containerKey === props.containerKey : !containerKey;
|
|
143
|
+
}).toList().reverse();
|
|
144
|
+
return {
|
|
145
|
+
// Get all toasts that hide automatically
|
|
146
|
+
toasts: containerToasts.filter(function (_ref4) {
|
|
147
|
+
var toast = _ref4.toast;
|
|
148
|
+
return !!toast.autoHide;
|
|
149
|
+
}),
|
|
150
|
+
// Get all toasts that require a user to close
|
|
151
|
+
persistentToasts: containerToasts.filter(function (_ref5) {
|
|
152
|
+
var toast = _ref5.toast;
|
|
153
|
+
return !toast.autoHide;
|
|
154
|
+
})
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
var ToastContainer = exports.ToastContainer = (0, _store.connect)(mapStateToProps)(ToastContainerComponent);
|
|
158
|
+
ToastContainer.propTypes = {
|
|
159
|
+
/** A key used to scope toasts to this container */
|
|
160
|
+
containerKey: _propTypes["default"].string,
|
|
161
|
+
components: _propTypes["default"].shape({
|
|
162
|
+
/** Override the default Toast component */
|
|
163
|
+
Toast: _propTypes["default"].func
|
|
164
|
+
})
|
|
165
|
+
};
|