@try-at-software/input-elements 1.2.0-beta.9 → 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/DropdownInput.d.ts +2 -7
- package/lib/SingleValueInputElements/DropdownInputElement/IDropdownInputConfiguration.d.ts +8 -0
- package/lib/SingleValueInputElements/DropdownInputElement/IDropdownInputConfiguration.js +2 -0
- 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/lib/SingleValueInputElements/DropdownInputElement/index.d.ts +1 -0
- package/lib/SingleValueInputElements/DropdownInputElement/index.js +1 -0
- package/lib/SingleValueInputElements/SingleValueInputElement.d.ts +4 -4
- package/lib/SingleValueInputElements/TextInputElement/ILongTextInputProps.d.ts +5 -0
- package/lib/SingleValueInputElements/TextInputElement/ILongTextInputProps.js +2 -0
- package/lib/SingleValueInputElements/TextInputElement/LongTextInput.d.ts +3 -10
- package/lib/SingleValueInputElements/TextInputElement/LongTextInput.js +5 -15
- package/lib/SingleValueInputElements/TextInputElement/TextInput.d.ts +1 -0
- package/lib/SingleValueInputElements/TextInputElement/TextInput.js +8 -3
- package/lib/SingleValueInputElements/TextInputElement/index.d.ts +1 -0
- package/lib/SingleValueInputElements/TextInputElement/index.js +1 -0
- package/package.json +2 -2
|
@@ -1,17 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { FormText } from '../../Components';
|
|
3
2
|
import { IBaseInputElementProps } from '../IBaseInputElementProps';
|
|
4
3
|
import { IDynamicProps } from '../IDynamicProps';
|
|
5
4
|
import { IOperativeProps } from '../IOperativeProps';
|
|
6
5
|
import { ISingleValueInputElementProps } from '../ISingleValueInputElementProps';
|
|
6
|
+
import { IDropdownInputConfiguration } from './IDropdownInputConfiguration';
|
|
7
7
|
import { IDropdownInputProps } from './IDropdownInputProps';
|
|
8
8
|
import { IFluentUiDropdownInputProps } from './IFluentUiDropdownInputProps';
|
|
9
|
-
interface
|
|
10
|
-
automaticHeight?: boolean;
|
|
11
|
-
}
|
|
12
|
-
interface ISingleValueDropdownInputProps extends ISingleValueInputElementProps<string>, IOperativeProps<IBaseInputElementProps>, IDynamicProps<IDropdownInputProps & IFluentUiDropdownInputProps> {
|
|
13
|
-
consistencyErrorMessage?: FormText;
|
|
14
|
-
styles?: IDropdownInputStyles;
|
|
9
|
+
interface ISingleValueDropdownInputProps extends ISingleValueInputElementProps<string>, IDropdownInputConfiguration, IOperativeProps<IBaseInputElementProps>, IDynamicProps<IDropdownInputProps & IFluentUiDropdownInputProps> {
|
|
15
10
|
}
|
|
16
11
|
export declare const DropdownInput: React.MemoExoticComponent<(props: ISingleValueDropdownInputProps) => JSX.Element>;
|
|
17
12
|
export {};
|
|
@@ -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
|
}
|
|
@@ -11,6 +11,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./DropdownInput"), exports);
|
|
14
|
+
__exportStar(require("./IDropdownInputConfiguration"), exports);
|
|
14
15
|
__exportStar(require("./IDropdownInputOption"), exports);
|
|
15
16
|
__exportStar(require("./IDropdownInputProps"), exports);
|
|
16
17
|
__exportStar(require("./IFluentUiDropdownInputProps"), exports);
|
|
@@ -9,14 +9,14 @@ import { IOperativeProps } from './IOperativeProps';
|
|
|
9
9
|
import { ISingleValueInputElementConfiguration } from './ISingleInputElementConfiguration';
|
|
10
10
|
import { ISingleValueInputElement } from './ISingleValueInputElement';
|
|
11
11
|
import { ISingleValueInputElementProps } from './ISingleValueInputElementProps';
|
|
12
|
-
export declare class SingleValueInputElement<TValue,
|
|
12
|
+
export declare class SingleValueInputElement<TValue, TOperativeProps, TDynamicProps = unknown> extends ExtendedInputElement<TValue, SingleValueInputElementWrapper<TValue, TOperativeProps, TDynamicProps>> implements ISingleValueInputElement<TValue, TOperativeProps, TDynamicProps> {
|
|
13
13
|
private readonly _configuration;
|
|
14
14
|
private readonly valueChangeSubscriptions;
|
|
15
15
|
private readonly initialValueChangeSubscriptions;
|
|
16
16
|
private readonly invalidValueChangeSubscriptions;
|
|
17
17
|
private _dynamicProps;
|
|
18
18
|
private _isInvalidated;
|
|
19
|
-
constructor(config: ISingleValueInputElementConfiguration<TValue>, component: React.ComponentType<ISingleValueInputElementProps<TValue> & IOperativeProps<
|
|
19
|
+
constructor(config: ISingleValueInputElementConfiguration<TValue>, component: React.ComponentType<ISingleValueInputElementProps<TValue> & IOperativeProps<TOperativeProps> & IDynamicProps<TDynamicProps>>, props: TOperativeProps, update: UpdateCallback, ...validationRules: ValidationRule<TValue>[]);
|
|
20
20
|
/** @inheritdoc */
|
|
21
21
|
subscribeToValueChange(subscription: ValueChangeSubscription<TValue>): void;
|
|
22
22
|
/** @inheritdoc */
|
|
@@ -34,9 +34,9 @@ export declare class SingleValueInputElement<TValue, TComponentProps, TDynamicPr
|
|
|
34
34
|
/** @inheritdoc */
|
|
35
35
|
get isValid(): boolean;
|
|
36
36
|
/** @inheritdoc */
|
|
37
|
-
readonly componentToRender: React.ComponentType<ISingleValueInputElementProps<TValue> & IOperativeProps<
|
|
37
|
+
readonly componentToRender: React.ComponentType<ISingleValueInputElementProps<TValue> & IOperativeProps<TOperativeProps> & IDynamicProps<TDynamicProps>>;
|
|
38
38
|
/** @inheritdoc */
|
|
39
|
-
componentProps:
|
|
39
|
+
componentProps: TOperativeProps;
|
|
40
40
|
/** @inheritdoc */
|
|
41
41
|
getDynamicProps(): TDynamicProps;
|
|
42
42
|
/** @inheritdoc */
|
|
@@ -3,15 +3,8 @@ import { IBaseInputElementDynamicProps } from '../IBaseInputElementDynamicProps'
|
|
|
3
3
|
import { IDynamicProps } from '../IDynamicProps';
|
|
4
4
|
import { IOperativeProps } from '../IOperativeProps';
|
|
5
5
|
import { ISingleValueInputElementProps } from '../ISingleValueInputElementProps';
|
|
6
|
-
import {
|
|
7
|
-
export
|
|
8
|
-
isMultiline: boolean;
|
|
9
|
-
}
|
|
10
|
-
export declare class LongTextInput extends React.Component<ISingleValueInputElementProps<string> & IOperativeProps<ITextInputProps> & IDynamicProps<IBaseInputElementDynamicProps>, ILongTextInputState> {
|
|
11
|
-
/**
|
|
12
|
-
* The number of characters after which the text input is changed to a multiline textbox.
|
|
13
|
-
*/
|
|
14
|
-
private multilineThreshold;
|
|
15
|
-
state: ILongTextInputState;
|
|
6
|
+
import { ILongTextInputProps } from './ILongTextInputProps';
|
|
7
|
+
export declare class LongTextInput extends React.Component<ISingleValueInputElementProps<string> & IOperativeProps<ILongTextInputProps> & IDynamicProps<IBaseInputElementDynamicProps>> {
|
|
16
8
|
render(): JSX.Element;
|
|
9
|
+
private handleChange;
|
|
17
10
|
}
|
|
@@ -8,12 +8,9 @@ const Components_2 = require("../../Components");
|
|
|
8
8
|
class LongTextInput extends React.Component {
|
|
9
9
|
constructor() {
|
|
10
10
|
super(...arguments);
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
this.multilineThreshold = 70;
|
|
15
|
-
this.state = {
|
|
16
|
-
isMultiline: false
|
|
11
|
+
this.handleChange = (_event, newValue) => {
|
|
12
|
+
const { onChange } = this.props;
|
|
13
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
|
|
17
14
|
};
|
|
18
15
|
}
|
|
19
16
|
render() {
|
|
@@ -21,17 +18,10 @@ class LongTextInput extends React.Component {
|
|
|
21
18
|
return null;
|
|
22
19
|
const { dynamicProps, operativeProps } = this.props;
|
|
23
20
|
const { isDisabled } = dynamicProps;
|
|
24
|
-
const { autoFocus, contentType, placeholder } = operativeProps;
|
|
21
|
+
const { autoAdjustHeight, autoFocus, contentType, placeholder, resizable } = operativeProps;
|
|
25
22
|
return (React.createElement(React.Fragment, null,
|
|
26
23
|
React.createElement(Components_2.LabelRenderer, { label: this.props.label, required: !!this.props.renderRequiredIndicator }),
|
|
27
|
-
React.createElement(react_1.TextField, { "data-automationid": "long-text-input", value: this.props.value || '', onChange:
|
|
28
|
-
// Dynamically change the 'isMultiline' state property.
|
|
29
|
-
const isMultiline = newValue.length > this.multilineThreshold;
|
|
30
|
-
if (this.state.isMultiline !== isMultiline) {
|
|
31
|
-
this.setState({ isMultiline: isMultiline });
|
|
32
|
-
}
|
|
33
|
-
this.props.onChange(newValue);
|
|
34
|
-
}, errorMessage: Components_1.materializeErrorMessage(this.props.errorMessage), type: contentType, placeholder: placeholder, multiline: this.state.isMultiline, autoAdjustHeight: this.state.isMultiline, validateOnFocusOut: true, disabled: isDisabled, autoFocus: autoFocus })));
|
|
24
|
+
React.createElement(react_1.TextField, { "data-automationid": "long-text-input", value: this.props.value || '', onChange: this.handleChange, errorMessage: Components_1.materializeErrorMessage(this.props.errorMessage), type: contentType, placeholder: placeholder, autoAdjustHeight: autoAdjustHeight, resizable: resizable, disabled: isDisabled, autoFocus: autoFocus, validateOnFocusOut: true, multiline: true })));
|
|
35
25
|
}
|
|
36
26
|
}
|
|
37
27
|
exports.LongTextInput = LongTextInput;
|
|
@@ -6,4 +6,5 @@ import { ISingleValueInputElementProps } from '../ISingleValueInputElementProps'
|
|
|
6
6
|
import { ITextInputProps } from './ITextInputProps';
|
|
7
7
|
export declare class TextInput extends React.Component<ISingleValueInputElementProps<string> & IOperativeProps<ITextInputProps> & IDynamicProps<IBaseInputElementDynamicProps>> {
|
|
8
8
|
render(): JSX.Element;
|
|
9
|
+
private handleChange;
|
|
9
10
|
}
|
|
@@ -5,6 +5,13 @@ const react_1 = require("@fluentui/react");
|
|
|
5
5
|
const React = require("react");
|
|
6
6
|
const Components_1 = require("../../Components");
|
|
7
7
|
class TextInput extends React.Component {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.handleChange = (_event, newValue) => {
|
|
11
|
+
const { onChange } = this.props;
|
|
12
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(newValue);
|
|
13
|
+
};
|
|
14
|
+
}
|
|
8
15
|
render() {
|
|
9
16
|
if (!this.props)
|
|
10
17
|
return null;
|
|
@@ -13,9 +20,7 @@ class TextInput extends React.Component {
|
|
|
13
20
|
const { autoFocus, contentType, placeholder } = operativeProps;
|
|
14
21
|
return (React.createElement(React.Fragment, null,
|
|
15
22
|
React.createElement(Components_1.LabelRenderer, { label: this.props.label, required: !!this.props.renderRequiredIndicator }),
|
|
16
|
-
React.createElement(react_1.TextField, { "data-automationid": "text-input", value: this.props.value || '', onChange:
|
|
17
|
-
this.props.onChange(newValue);
|
|
18
|
-
}, errorMessage: Components_1.materializeErrorMessage(this.props.errorMessage), type: contentType, placeholder: placeholder, validateOnFocusOut: true, disabled: isDisabled, autoFocus: autoFocus })));
|
|
23
|
+
React.createElement(react_1.TextField, { "data-automationid": "text-input", value: this.props.value || '', onChange: this.handleChange, errorMessage: Components_1.materializeErrorMessage(this.props.errorMessage), type: contentType, placeholder: placeholder, validateOnFocusOut: true, disabled: isDisabled, autoFocus: autoFocus })));
|
|
19
24
|
}
|
|
20
25
|
}
|
|
21
26
|
exports.TextInput = TextInput;
|
|
@@ -11,6 +11,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./EmptyValidationRules"), exports);
|
|
14
|
+
__exportStar(require("./ILongTextInputProps"), exports);
|
|
14
15
|
__exportStar(require("./ITextInputProps"), exports);
|
|
15
16
|
__exportStar(require("./LengthValidationRules"), exports);
|
|
16
17
|
__exportStar(require("./LongTextInput"), exports);
|
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",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"ts-jest": "27.1.4",
|
|
66
66
|
"ts-loader": "9.2.8",
|
|
67
67
|
"typescript": "4.3.2",
|
|
68
|
-
"webpack": "5.
|
|
68
|
+
"webpack": "5.76.0",
|
|
69
69
|
"webpack-cli": "4.9.2",
|
|
70
70
|
"webpack-dev-server": "4.8.1"
|
|
71
71
|
},
|