@try-at-software/input-elements 1.2.0 → 1.2.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/SingleValueInputElements/DropdownInputElement/IMultiValueDropdownInputProps.d.ts +4 -0
- package/lib/SingleValueInputElements/DropdownInputElement/IMultiValueDropdownInputProps.js +2 -0
- package/lib/SingleValueInputElements/DropdownInputElement/MultiValueDropdownInput.d.ts +3 -2
- package/lib/SingleValueInputElements/DropdownInputElement/MultiValueDropdownInput.js +22 -18
- package/package.json +1 -1
|
@@ -3,7 +3,8 @@ import { IBaseInputElementProps } from '../IBaseInputElementProps';
|
|
|
3
3
|
import { IDynamicProps } from '../IDynamicProps';
|
|
4
4
|
import { IOperativeProps } from '../IOperativeProps';
|
|
5
5
|
import { ISingleValueInputElementProps } from '../ISingleValueInputElementProps';
|
|
6
|
-
import {
|
|
7
|
-
export declare class MultiValueDropdownInput extends React.Component<ISingleValueInputElementProps<string[]> & IOperativeProps<IBaseInputElementProps> & IDynamicProps<
|
|
6
|
+
import { IMultiValueDropdownInputProps } from './IMultiValueDropdownInputProps';
|
|
7
|
+
export declare class MultiValueDropdownInput extends React.Component<ISingleValueInputElementProps<string[]> & IOperativeProps<IBaseInputElementProps> & IDynamicProps<IMultiValueDropdownInputProps>> {
|
|
8
8
|
render(): JSX.Element;
|
|
9
|
+
private handleChange;
|
|
9
10
|
}
|
|
@@ -6,6 +6,26 @@ const React = require("react");
|
|
|
6
6
|
const Components_1 = require("../../Components");
|
|
7
7
|
const Utilities_1 = require("../../Utilities");
|
|
8
8
|
class MultiValueDropdownInput extends React.Component {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this.handleChange = (_event, option) => {
|
|
12
|
+
var _a, _b, _c;
|
|
13
|
+
const optionKey = (_a = option === null || option === void 0 ? void 0 : option.key) === null || _a === void 0 ? void 0 : _a.toString();
|
|
14
|
+
if (!optionKey)
|
|
15
|
+
return;
|
|
16
|
+
// We have to re-iterate the passed collection of values here in order to detect changes between the initial and the current values.
|
|
17
|
+
let currentValues = [];
|
|
18
|
+
if (this.props.value)
|
|
19
|
+
currentValues.push(...this.props.value);
|
|
20
|
+
// If the current option is selected, add it to the list.
|
|
21
|
+
// Else, remove it.
|
|
22
|
+
if (option.selected)
|
|
23
|
+
currentValues.push(optionKey);
|
|
24
|
+
else
|
|
25
|
+
currentValues = currentValues.filter((x) => x !== optionKey);
|
|
26
|
+
(_c = (_b = this.props).onChange) === null || _c === void 0 ? void 0 : _c.call(_b, currentValues);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
9
29
|
render() {
|
|
10
30
|
var _a;
|
|
11
31
|
if (!this.props)
|
|
@@ -14,25 +34,9 @@ class MultiValueDropdownInput extends React.Component {
|
|
|
14
34
|
const normalizedOptions = Utilities_1.DropdownHelper.getNormalizedOptions(dynamicProps.defaultOption, dynamicProps.options);
|
|
15
35
|
return (React.createElement(React.Fragment, null,
|
|
16
36
|
React.createElement(Components_1.LabelRenderer, { label: this.props.label, required: !!this.props.renderRequiredIndicator }),
|
|
17
|
-
React.createElement(react_1.Dropdown, { "data-automationid": "multi-value-dropdown-input", options: normalizedOptions, onChange:
|
|
18
|
-
var _a, _b, _c;
|
|
19
|
-
const optionKey = (_a = option === null || option === void 0 ? void 0 : option.key) === null || _a === void 0 ? void 0 : _a.toString();
|
|
20
|
-
if (!optionKey)
|
|
21
|
-
return;
|
|
22
|
-
// We have to re-iterate the passed collection of values here in order to detect changes between the initial and the current values.
|
|
23
|
-
let currentValues = [];
|
|
24
|
-
if (this.props.value)
|
|
25
|
-
currentValues.push(...this.props.value);
|
|
26
|
-
// If the current option is selected, add it to the list.
|
|
27
|
-
// Else, remove it.
|
|
28
|
-
if (option.selected)
|
|
29
|
-
currentValues.push(optionKey);
|
|
30
|
-
else
|
|
31
|
-
currentValues = currentValues.filter((x) => x !== optionKey);
|
|
32
|
-
(_c = (_b = this.props).onChange) === null || _c === void 0 ? void 0 : _c.call(_b, currentValues);
|
|
33
|
-
}, required: !!this.props.renderRequiredIndicator, placeholder: operativeProps.placeholder,
|
|
37
|
+
React.createElement(react_1.Dropdown, { "data-automationid": "multi-value-dropdown-input", options: normalizedOptions, onChange: this.handleChange, required: !!this.props.renderRequiredIndicator, placeholder: operativeProps.placeholder,
|
|
34
38
|
// This value should never be `undefined`.
|
|
35
|
-
defaultSelectedKeys: this.props.value || [(_a = dynamicProps.defaultOption) === null || _a === void 0 ? void 0 : _a.key] || null, disabled: dynamicProps.isDisabled, multiSelect: true }),
|
|
39
|
+
defaultSelectedKeys: this.props.value || [(_a = dynamicProps.defaultOption) === null || _a === void 0 ? void 0 : _a.key] || null, disabled: dynamicProps.isDisabled, multiSelect: true, multiSelectDelimiter: dynamicProps.multiSelectDelimiter }),
|
|
36
40
|
React.createElement(Components_1.ErrorRenderer, { error: this.props.errorMessage, messageBarType: react_1.MessageBarType.error })));
|
|
37
41
|
}
|
|
38
42
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@try-at-software/input-elements",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "A package providing different input elements that are extensible and easily configurable for your custom needs.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|