@try-at-software/input-elements 1.2.0-aplha.6 → 1.2.0-beta.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/LICENSE +21 -0
- package/lib/ChangingInputElement.d.ts +16 -0
- package/lib/ChangingInputElement.js +34 -0
- package/lib/Components/Buttons/ClearButton.d.ts +10 -0
- package/lib/Components/Buttons/ClearButton.js +12 -0
- package/lib/Components/Buttons/index.d.ts +1 -0
- package/lib/Components/Buttons/index.js +13 -0
- package/lib/Components/Text/ErrorRenderer.d.ts +9 -0
- package/lib/Components/Text/ErrorRenderer.js +14 -0
- package/lib/Components/Text/FormTextRenderer.d.ts +8 -0
- package/lib/Components/Text/FormTextRenderer.js +19 -0
- package/lib/Components/Text/LabelRenderer.d.ts +8 -0
- package/lib/Components/Text/LabelRenderer.js +14 -0
- package/lib/Components/Text/Types.d.ts +2 -0
- package/lib/Components/Text/Types.js +2 -0
- package/lib/Components/Text/index.d.ts +4 -0
- package/lib/Components/Text/index.js +16 -0
- package/lib/Components/index.d.ts +2 -0
- package/lib/Components/index.js +14 -0
- package/lib/DynamicListInputElement/DynamicListInputElement.js +1 -1
- package/lib/DynamicListInputElement/IBasicMenuButtonConfiguration.d.ts +2 -1
- package/lib/DynamicListInputElement/IMenuButtonConfiguration.d.ts +0 -3
- package/lib/DynamicListInputElement/InternalPresentationComponents/DynamicListInputElementWrapper.d.ts +1 -1
- package/lib/DynamicListInputElement/InternalPresentationComponents/DynamicListInputElementWrapper.js +1 -1
- package/lib/DynamicListInputElement/Menu/DynamicListMenu.js +18 -12
- package/lib/DynamicListInputElement/Menu/index.js +1 -1
- package/lib/DynamicListInputElement/index.js +1 -1
- package/lib/ExtendedInputElement.d.ts +2 -13
- package/lib/ExtendedInputElement.js +2 -26
- package/lib/IInputElement.d.ts +2 -1
- package/lib/IInputElementConfiguration.d.ts +3 -2
- package/lib/ILoadingInputElementConfiguration.d.ts +2 -2
- package/lib/IValueInputElement.d.ts +2 -1
- package/lib/InputElement.d.ts +2 -1
- package/lib/InputElement.js +1 -1
- package/lib/Presentations/IPresentation.d.ts +2 -1
- package/lib/Presentations/PresentationRenderers.d.ts +1 -1
- package/lib/Presentations/PresentationRenderers.js +12 -9
- package/lib/Presentations/index.js +1 -1
- package/lib/SingleValueInputElements/Comparators/ArrayComparator.d.ts +3 -0
- package/lib/SingleValueInputElements/Comparators/ArrayComparator.js +5 -1
- package/lib/SingleValueInputElements/Comparators/DefaultEqualityComparer.d.ts +4 -0
- package/lib/SingleValueInputElements/Comparators/DefaultEqualityComparer.js +9 -0
- package/lib/SingleValueInputElements/Comparators/IEqualityComparer.d.ts +3 -0
- package/lib/SingleValueInputElements/Comparators/IEqualityComparer.js +2 -0
- package/lib/SingleValueInputElements/Comparators/index.d.ts +2 -0
- package/lib/SingleValueInputElements/Comparators/index.js +3 -1
- package/lib/SingleValueInputElements/DropdownInputElement/ConsistencyValidationRules.d.ts +2 -1
- package/lib/SingleValueInputElements/DropdownInputElement/DropdownInput.d.ts +9 -4
- package/lib/SingleValueInputElements/DropdownInputElement/DropdownInput.js +24 -30
- package/lib/SingleValueInputElements/DropdownInputElement/IDropdownInputProps.d.ts +2 -2
- package/lib/SingleValueInputElements/DropdownInputElement/IFluentUiDropdownInputProps.d.ts +5 -0
- package/lib/SingleValueInputElements/DropdownInputElement/IFluentUiDropdownInputProps.js +2 -0
- package/lib/SingleValueInputElements/DropdownInputElement/MultiValueDropdownInput.d.ts +4 -2
- package/lib/SingleValueInputElements/DropdownInputElement/MultiValueDropdownInput.js +29 -19
- package/lib/SingleValueInputElements/DropdownInputElement/index.d.ts +1 -1
- package/lib/SingleValueInputElements/DropdownInputElement/index.js +2 -2
- package/lib/SingleValueInputElements/IBaseInputElementDynamicProps.d.ts +1 -1
- package/lib/SingleValueInputElements/IDynamicProps.d.ts +3 -0
- package/lib/SingleValueInputElements/IDynamicProps.js +2 -0
- package/lib/SingleValueInputElements/IOperativeProps.d.ts +3 -0
- package/lib/SingleValueInputElements/IOperativeProps.js +2 -0
- package/lib/SingleValueInputElements/ISingleValueInputElement.d.ts +5 -2
- package/lib/SingleValueInputElements/ISingleValueInputElementProps.d.ts +7 -3
- package/lib/SingleValueInputElements/IdentityPickerInputElement/IIdentityPickerProps.d.ts +2 -3
- package/lib/SingleValueInputElements/IdentityPickerInputElement/IdentityPicker.d.ts +6 -3
- package/lib/SingleValueInputElements/IdentityPickerInputElement/IdentityPicker.js +12 -10
- package/lib/SingleValueInputElements/IdentityPickerInputElement/index.js +1 -1
- package/lib/SingleValueInputElements/InternalPresentationComponents/SingleValueInputElementWrapper.d.ts +13 -8
- package/lib/SingleValueInputElements/InternalPresentationComponents/SingleValueInputElementWrapper.js +10 -5
- package/lib/SingleValueInputElements/NumberInputElement/INumberInputProps.d.ts +1 -2
- package/lib/SingleValueInputElements/NumberInputElement/NumberInput.d.ts +6 -2
- package/lib/SingleValueInputElements/NumberInputElement/NumberInput.js +34 -35
- package/lib/SingleValueInputElements/NumberInputElement/index.js +1 -1
- package/lib/SingleValueInputElements/SingleValueInputElement.d.ts +12 -8
- package/lib/SingleValueInputElements/SingleValueInputElement.js +35 -9
- package/lib/SingleValueInputElements/TextInputElement/EmptyValidationRules.d.ts +2 -1
- package/lib/SingleValueInputElements/TextInputElement/ITextInputProps.d.ts +1 -2
- package/lib/SingleValueInputElements/TextInputElement/LengthValidationRules.d.ts +3 -2
- package/lib/SingleValueInputElements/TextInputElement/LongTextInput.d.ts +4 -1
- package/lib/SingleValueInputElements/TextInputElement/LongTextInput.js +9 -5
- package/lib/SingleValueInputElements/TextInputElement/PathValidationRules.d.ts +2 -1
- package/lib/SingleValueInputElements/TextInputElement/TextInput.d.ts +4 -1
- package/lib/SingleValueInputElements/TextInputElement/TextInput.js +8 -5
- package/lib/SingleValueInputElements/TextInputElement/index.js +1 -1
- package/lib/SingleValueInputElements/TimePickerInputElement/ITimePickerProps.d.ts +3 -2
- package/lib/SingleValueInputElements/TimePickerInputElement/TimePicker.d.ts +6 -1
- package/lib/SingleValueInputElements/TimePickerInputElement/TimePicker.js +16 -7
- package/lib/SingleValueInputElements/TimePickerInputElement/TimePicker.less +28 -0
- package/lib/SingleValueInputElements/TimePickerInputElement/index.js +1 -1
- package/lib/SingleValueInputElements/index.d.ts +2 -0
- package/lib/SingleValueInputElements/index.js +3 -1
- package/lib/Subscriptions/ValueChangeSubscription.d.ts +2 -2
- package/lib/Subscriptions/index.js +1 -1
- package/lib/Utilities/DropdownHelper.d.ts +1 -1
- package/lib/Utilities/DropdownHelper.js +7 -6
- package/lib/Utilities/FormHelper.js +8 -2
- package/lib/Utilities/InputElementsBuilding.d.ts +13 -0
- package/lib/Utilities/InputElementsBuilding.js +18 -0
- package/lib/Utilities/index.d.ts +1 -0
- package/lib/Utilities/index.js +2 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +2 -1
- package/package.json +42 -40
- package/lib/SingleValueInputElements/DependentInputElement/DependentInputElementInitializer.d.ts +0 -0
- package/lib/SingleValueInputElements/DependentInputElement/DependentInputElementInitializer.js +0 -51
- package/lib/SingleValueInputElements/DependentInputElement/index.d.ts +0 -0
- package/lib/SingleValueInputElements/DependentInputElement/index.js +0 -1
- package/lib/SingleValueInputElements/DropdownInputElement/DropdownInputElement.d.ts +0 -11
- package/lib/SingleValueInputElements/DropdownInputElement/DropdownInputElement.js +0 -33
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NumberInput = void 0;
|
|
4
|
-
const
|
|
4
|
+
const react_1 = require("@fluentui/react");
|
|
5
5
|
const React = require("react");
|
|
6
|
+
const Components_1 = require("../../Components");
|
|
6
7
|
const delimiter = '.';
|
|
7
8
|
class NumberInput extends React.Component {
|
|
8
9
|
constructor() {
|
|
@@ -14,34 +15,28 @@ class NumberInput extends React.Component {
|
|
|
14
15
|
};
|
|
15
16
|
}
|
|
16
17
|
render() {
|
|
17
|
-
var _a
|
|
18
|
+
var _a;
|
|
18
19
|
if (!this.props)
|
|
19
20
|
return null;
|
|
21
|
+
const { dynamicProps, operativeProps } = this.props;
|
|
20
22
|
return (React.createElement(React.Fragment, null,
|
|
21
|
-
|
|
22
|
-
React.createElement(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
this.setState({ intermediateValue: value });
|
|
37
|
-
this.props.invalidateInput();
|
|
38
|
-
return;
|
|
23
|
+
React.createElement(Components_1.LabelRenderer, { label: this.props.label, required: !!this.props.renderRequiredIndicator }),
|
|
24
|
+
React.createElement(react_1.SpinButton, { "data-automationid": "number-input", inputProps: {
|
|
25
|
+
autoFocus: !!operativeProps.autoFocus,
|
|
26
|
+
placeholder: operativeProps.placeholder,
|
|
27
|
+
disabled: !!dynamicProps.isDisabled,
|
|
28
|
+
onChange: (event) => {
|
|
29
|
+
const newValue = event.target.value;
|
|
30
|
+
const value = NumberInput.normalizeData(newValue);
|
|
31
|
+
if (!value || isNaN(Number(value))) {
|
|
32
|
+
this.setState({ intermediateValue: value, customWarning: 'The provided value is not a valid number.' });
|
|
33
|
+
this.props.invalidateInput();
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const numericValue = NumberInput.getNumericValue(value);
|
|
37
|
+
this.handleUserInput(numericValue, value);
|
|
39
38
|
}
|
|
40
|
-
|
|
41
|
-
this.handleUserInput(numericValue, value);
|
|
42
|
-
},
|
|
43
|
-
// We should obligatorily define this function, because there will be a problem with incrementing/decrementing a newly typed value.
|
|
44
|
-
onValidate: () => this.state.intermediateValue, onIncrement: (value) => {
|
|
39
|
+
}, value: (_a = this.state.intermediateValue) !== null && _a !== void 0 ? _a : '', onIncrement: (value) => {
|
|
45
40
|
let numericValue = NumberInput.getNumericValue(value);
|
|
46
41
|
numericValue += this.getStep();
|
|
47
42
|
this.handleUserInput(numericValue, numericValue.toString());
|
|
@@ -50,8 +45,8 @@ class NumberInput extends React.Component {
|
|
|
50
45
|
numericValue -= this.getStep();
|
|
51
46
|
this.handleUserInput(numericValue, numericValue.toString());
|
|
52
47
|
} }),
|
|
53
|
-
|
|
54
|
-
|
|
48
|
+
React.createElement(Components_1.ErrorRenderer, { error: this.props.errorMessage, messageBarType: react_1.MessageBarType.warning }),
|
|
49
|
+
React.createElement(Components_1.ErrorRenderer, { error: this.state.customWarning, messageBarType: react_1.MessageBarType.warning })));
|
|
55
50
|
}
|
|
56
51
|
handleUserInput(value, intermediateValue) {
|
|
57
52
|
const changeResult = this.ensureValueConsistency(value);
|
|
@@ -67,8 +62,9 @@ class NumberInput extends React.Component {
|
|
|
67
62
|
return { warning: `The maximum value is ${maxValue}`, newValue: undefined };
|
|
68
63
|
const minValue = this.getMinValue();
|
|
69
64
|
if (value < minValue)
|
|
70
|
-
return { warning: `The minimum value is ${
|
|
71
|
-
|
|
65
|
+
return { warning: `The minimum value is ${minValue}`, newValue: undefined };
|
|
66
|
+
const { operativeProps } = this.props;
|
|
67
|
+
if (!operativeProps.handleDecimalValues && value % 1 !== 0)
|
|
72
68
|
return {
|
|
73
69
|
warning: 'Decimal values are not allowed',
|
|
74
70
|
newValue: undefined
|
|
@@ -76,16 +72,19 @@ class NumberInput extends React.Component {
|
|
|
76
72
|
return { warning: '', newValue: value };
|
|
77
73
|
}
|
|
78
74
|
getMaxValue() {
|
|
79
|
-
var _a
|
|
80
|
-
|
|
75
|
+
var _a;
|
|
76
|
+
const { operativeProps } = this.props;
|
|
77
|
+
return (_a = operativeProps.max) !== null && _a !== void 0 ? _a : Number.MAX_SAFE_INTEGER;
|
|
81
78
|
}
|
|
82
79
|
getMinValue() {
|
|
83
|
-
var _a
|
|
84
|
-
|
|
80
|
+
var _a;
|
|
81
|
+
const { operativeProps } = this.props;
|
|
82
|
+
return (_a = operativeProps.min) !== null && _a !== void 0 ? _a : Number.MIN_SAFE_INTEGER;
|
|
85
83
|
}
|
|
86
84
|
getStep() {
|
|
87
|
-
var _a
|
|
88
|
-
|
|
85
|
+
var _a;
|
|
86
|
+
const { operativeProps } = this.props;
|
|
87
|
+
return (_a = operativeProps.step) !== null && _a !== void 0 ? _a : 1;
|
|
89
88
|
}
|
|
90
89
|
static getNumericValue(value) {
|
|
91
90
|
const number = Number(NumberInput.normalizeData(value));
|
|
@@ -7,7 +7,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
7
7
|
o[k2] = m[k];
|
|
8
8
|
}));
|
|
9
9
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./INumberInputProps"), exports);
|
|
@@ -3,24 +3,28 @@ import { ExtendedInputElement } from '../ExtendedInputElement';
|
|
|
3
3
|
import { UpdateCallback } from '../IInputElement';
|
|
4
4
|
import { ValidationRule } from '../IValueInputElement';
|
|
5
5
|
import { InvalidValueChangeSubscription, ValueChangeSubscription } from '../Subscriptions';
|
|
6
|
+
import { IDynamicProps } from './IDynamicProps';
|
|
6
7
|
import { SingleValueInputElementWrapper } from './InternalPresentationComponents/SingleValueInputElementWrapper';
|
|
8
|
+
import { IOperativeProps } from './IOperativeProps';
|
|
7
9
|
import { ISingleValueInputElementConfiguration } from './ISingleInputElementConfiguration';
|
|
8
10
|
import { ISingleValueInputElement } from './ISingleValueInputElement';
|
|
9
11
|
import { ISingleValueInputElementProps } from './ISingleValueInputElementProps';
|
|
10
|
-
declare
|
|
11
|
-
export declare class SingleValueInputElement<TValue, TComponentProps, TDynamicProps = unknown> extends ExtendedInputElement<TValue, WrapperType<TValue, TComponentProps, TDynamicProps>> implements ISingleValueInputElement<TValue, TComponentProps, TDynamicProps> {
|
|
12
|
+
export declare class SingleValueInputElement<TValue, TComponentProps, TDynamicProps = unknown> extends ExtendedInputElement<TValue, SingleValueInputElementWrapper<TValue, TComponentProps, TDynamicProps>> implements ISingleValueInputElement<TValue, TComponentProps, TDynamicProps> {
|
|
12
13
|
private readonly _configuration;
|
|
13
14
|
private readonly valueChangeSubscriptions;
|
|
15
|
+
private readonly initialValueChangeSubscriptions;
|
|
14
16
|
private readonly invalidValueChangeSubscriptions;
|
|
15
17
|
private _dynamicProps;
|
|
16
18
|
private _isInvalidated;
|
|
17
|
-
constructor(config: ISingleValueInputElementConfiguration<TValue>, component: React.ComponentType<ISingleValueInputElementProps<TValue> & TComponentProps & TDynamicProps
|
|
19
|
+
constructor(config: ISingleValueInputElementConfiguration<TValue>, component: React.ComponentType<ISingleValueInputElementProps<TValue> & IOperativeProps<TComponentProps> & IDynamicProps<TDynamicProps>>, props: TComponentProps, update: UpdateCallback, ...validationRules: ValidationRule<TValue>[]);
|
|
18
20
|
/** @inheritdoc */
|
|
19
21
|
subscribeToValueChange(subscription: ValueChangeSubscription<TValue>): void;
|
|
20
22
|
/** @inheritdoc */
|
|
21
|
-
|
|
23
|
+
subscribeToInitialValueChange(subscription: ValueChangeSubscription<TValue>): void;
|
|
22
24
|
/** @inheritdoc */
|
|
23
|
-
|
|
25
|
+
subscribeToInvalidValueChange(subscription: InvalidValueChangeSubscription): void;
|
|
26
|
+
/** @inheritdoc */
|
|
27
|
+
protected setInternalValue(value: TValue, isInitial: boolean): void;
|
|
24
28
|
/** @inheritdoc */
|
|
25
29
|
get hasChanges(): boolean;
|
|
26
30
|
/** @inheritdoc */
|
|
@@ -30,18 +34,18 @@ export declare class SingleValueInputElement<TValue, TComponentProps, TDynamicPr
|
|
|
30
34
|
/** @inheritdoc */
|
|
31
35
|
get isValid(): boolean;
|
|
32
36
|
/** @inheritdoc */
|
|
33
|
-
readonly componentToRender: React.ComponentType<ISingleValueInputElementProps<TValue> & TComponentProps & TDynamicProps
|
|
37
|
+
readonly componentToRender: React.ComponentType<ISingleValueInputElementProps<TValue> & IOperativeProps<TComponentProps> & IDynamicProps<TDynamicProps>>;
|
|
34
38
|
/** @inheritdoc */
|
|
35
39
|
componentProps: TComponentProps;
|
|
36
40
|
/** @inheritdoc */
|
|
37
41
|
getDynamicProps(): TDynamicProps;
|
|
38
42
|
/** @inheritdoc */
|
|
39
|
-
protected renderComponent(
|
|
43
|
+
protected renderComponent(): JSX.Element;
|
|
40
44
|
/** @inheritdoc */
|
|
41
45
|
changeDynamicProps<K extends keyof TDynamicProps>(dynamicProps: Pick<TDynamicProps, K>): void;
|
|
42
46
|
/** @inheritdoc */
|
|
43
47
|
validate(): void;
|
|
48
|
+
private setError;
|
|
44
49
|
private valueIsValid;
|
|
45
50
|
private invalidateInput;
|
|
46
51
|
}
|
|
47
|
-
export {};
|
|
@@ -9,16 +9,24 @@ class SingleValueInputElement extends ExtendedInputElement_1.ExtendedInputElemen
|
|
|
9
9
|
constructor(config, component, props, update, ...validationRules) {
|
|
10
10
|
super(update);
|
|
11
11
|
this.valueChangeSubscriptions = [];
|
|
12
|
+
this.initialValueChangeSubscriptions = [];
|
|
12
13
|
this.invalidValueChangeSubscriptions = [];
|
|
13
14
|
this._isInvalidated = false;
|
|
15
|
+
this.setError = (errorMessage) => {
|
|
16
|
+
this.errorMessage = errorMessage;
|
|
17
|
+
if (this._componentRef.current)
|
|
18
|
+
this._componentRef.current.setError(errorMessage);
|
|
19
|
+
};
|
|
14
20
|
this.valueIsValid = () => {
|
|
15
21
|
var _a;
|
|
16
22
|
if (!!((_a = this._configuration) === null || _a === void 0 ? void 0 : _a.comparator))
|
|
17
23
|
return this._configuration.comparator.isValid(this.value);
|
|
18
24
|
return !!this.value;
|
|
19
25
|
};
|
|
20
|
-
this.invalidateInput = () => {
|
|
26
|
+
this.invalidateInput = (options) => {
|
|
21
27
|
this._isInvalidated = true;
|
|
28
|
+
if (options.errorMessage)
|
|
29
|
+
this.setError(options.errorMessage);
|
|
22
30
|
this.updateInternally();
|
|
23
31
|
this.invalidValueChangeSubscriptions.forEach((x) => x === null || x === void 0 ? void 0 : x());
|
|
24
32
|
};
|
|
@@ -39,22 +47,33 @@ class SingleValueInputElement extends ExtendedInputElement_1.ExtendedInputElemen
|
|
|
39
47
|
this.valueChangeSubscriptions.push(subscription);
|
|
40
48
|
}
|
|
41
49
|
/** @inheritdoc */
|
|
50
|
+
subscribeToInitialValueChange(subscription) {
|
|
51
|
+
if (!subscription)
|
|
52
|
+
return;
|
|
53
|
+
this.initialValueChangeSubscriptions.push(subscription);
|
|
54
|
+
}
|
|
55
|
+
/** @inheritdoc */
|
|
42
56
|
subscribeToInvalidValueChange(subscription) {
|
|
43
57
|
if (!subscription)
|
|
44
58
|
return;
|
|
45
59
|
this.invalidValueChangeSubscriptions.push(subscription);
|
|
46
60
|
}
|
|
47
61
|
/** @inheritdoc */
|
|
48
|
-
setInternalValue(value) {
|
|
62
|
+
setInternalValue(value, isInitial) {
|
|
49
63
|
var _a;
|
|
50
64
|
if (this._isInvalidated)
|
|
51
65
|
this._isInvalidated = false;
|
|
66
|
+
const previousValue = this.value;
|
|
52
67
|
this.value = value;
|
|
53
68
|
if ((_a = this._componentRef) === null || _a === void 0 ? void 0 : _a.current)
|
|
54
69
|
this._componentRef.current.update(value);
|
|
55
70
|
this.validate();
|
|
56
|
-
if (this.isValid)
|
|
57
|
-
|
|
71
|
+
if (this.isValid) {
|
|
72
|
+
if (isInitial)
|
|
73
|
+
this.initialValueChangeSubscriptions.forEach((x) => x === null || x === void 0 ? void 0 : x(this.value, previousValue));
|
|
74
|
+
else
|
|
75
|
+
this.valueChangeSubscriptions.forEach((x) => x === null || x === void 0 ? void 0 : x(this.value, previousValue));
|
|
76
|
+
}
|
|
58
77
|
else
|
|
59
78
|
this.invalidValueChangeSubscriptions.forEach((x) => x === null || x === void 0 ? void 0 : x());
|
|
60
79
|
}
|
|
@@ -69,6 +88,8 @@ class SingleValueInputElement extends ExtendedInputElement_1.ExtendedInputElemen
|
|
|
69
88
|
get isValid() {
|
|
70
89
|
if (this._isInvalidated)
|
|
71
90
|
return false;
|
|
91
|
+
if (this.isLoading)
|
|
92
|
+
return false;
|
|
72
93
|
if (this.errorMessage && this.errorMessage.length > 0)
|
|
73
94
|
return false;
|
|
74
95
|
return (!!this._configuration && !this._configuration.isRequired) || this._valueIsSet || this._initialValueIsSet;
|
|
@@ -78,11 +99,18 @@ class SingleValueInputElement extends ExtendedInputElement_1.ExtendedInputElemen
|
|
|
78
99
|
return this._dynamicProps;
|
|
79
100
|
}
|
|
80
101
|
/** @inheritdoc */
|
|
81
|
-
renderComponent(
|
|
102
|
+
renderComponent() {
|
|
82
103
|
var _a, _b, _c, _d, _e, _f;
|
|
83
104
|
return (React.createElement("div", { className: Utilities_1.combineClasses('tas-input-element', (_a = this._configuration) === null || _a === void 0 ? void 0 : _a.className) },
|
|
84
105
|
React.createElement("div", { className: "tas-input-element-content" },
|
|
85
|
-
React.createElement(SingleValueInputElementWrapper_1.SingleValueInputElementWrapper, { internalComponent: this.componentToRender,
|
|
106
|
+
React.createElement(SingleValueInputElementWrapper_1.SingleValueInputElementWrapper, { internalComponent: this.componentToRender, renderErrors: (_b = this._configuration) === null || _b === void 0 ? void 0 : _b.renderErrors, loadingIndicator: (_c = this._configuration) === null || _c === void 0 ? void 0 : _c.loadingComponent, inputProps: {
|
|
107
|
+
label: (_d = this._configuration) === null || _d === void 0 ? void 0 : _d.label,
|
|
108
|
+
value: this.value,
|
|
109
|
+
renderRequiredIndicator: ((_e = this._configuration) === null || _e === void 0 ? void 0 : _e.renderRequiredIndicator) && ((_f = this._configuration) === null || _f === void 0 ? void 0 : _f.isRequired),
|
|
110
|
+
errorMessage: this.errorMessage,
|
|
111
|
+
onChange: (newValue) => this.setValue(newValue),
|
|
112
|
+
invalidateInput: this.invalidateInput
|
|
113
|
+
}, operativeProps: this.componentProps, initialDynamicProps: this._dynamicProps, isInitiallyLoading: this.isLoading, isInitiallyVisible: this.isVisible, ref: this._componentRef }))));
|
|
86
114
|
}
|
|
87
115
|
/** @inheritdoc */
|
|
88
116
|
changeDynamicProps(dynamicProps) {
|
|
@@ -111,9 +139,7 @@ class SingleValueInputElement extends ExtendedInputElement_1.ExtendedInputElemen
|
|
|
111
139
|
errorMessage = rule(this.value);
|
|
112
140
|
});
|
|
113
141
|
}
|
|
114
|
-
this.errorMessage
|
|
115
|
-
if (this._componentRef.current)
|
|
116
|
-
this._componentRef.current.setError(errorMessage);
|
|
142
|
+
this.setError(errorMessage);
|
|
117
143
|
}
|
|
118
144
|
}
|
|
119
145
|
exports.SingleValueInputElement = SingleValueInputElement;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import { FormText } from '../../Components';
|
|
1
2
|
import { ValidationRule } from '../../IValueInputElement';
|
|
2
|
-
export declare function restrictEmptyText(errorMessage?:
|
|
3
|
+
export declare function restrictEmptyText(errorMessage?: FormText): ValidationRule<string>;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { IBaseInputElementDynamicProps } from '../IBaseInputElementDynamicProps';
|
|
2
1
|
import { IBaseInputElementProps } from '../IBaseInputElementProps';
|
|
3
|
-
export interface ITextInputProps extends IBaseInputElementProps
|
|
2
|
+
export interface ITextInputProps extends IBaseInputElementProps {
|
|
4
3
|
contentType?: string;
|
|
5
4
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FormText } from '../../Components';
|
|
1
2
|
import { ValidationRule } from '../../IValueInputElement';
|
|
2
|
-
export declare function restrictMinimumLength(minLength: number, errorMessage?:
|
|
3
|
-
export declare function restrictMaximumLength(maxLength: number, errorMessage?:
|
|
3
|
+
export declare function restrictMinimumLength(minLength: number, errorMessage?: FormText): ValidationRule<string>;
|
|
4
|
+
export declare function restrictMaximumLength(maxLength: number, errorMessage?: FormText): ValidationRule<string>;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { IBaseInputElementDynamicProps } from '../IBaseInputElementDynamicProps';
|
|
3
|
+
import { IDynamicProps } from '../IDynamicProps';
|
|
4
|
+
import { IOperativeProps } from '../IOperativeProps';
|
|
2
5
|
import { ISingleValueInputElementProps } from '../ISingleValueInputElementProps';
|
|
3
6
|
import { ITextInputProps } from './ITextInputProps';
|
|
4
7
|
export interface ILongTextInputState {
|
|
5
8
|
isMultiline: boolean;
|
|
6
9
|
}
|
|
7
|
-
export declare class LongTextInput extends React.Component<ISingleValueInputElementProps<string> & ITextInputProps
|
|
10
|
+
export declare class LongTextInput extends React.Component<ISingleValueInputElementProps<string> & IOperativeProps<ITextInputProps> & IDynamicProps<IBaseInputElementDynamicProps>, ILongTextInputState> {
|
|
8
11
|
/**
|
|
9
12
|
* The number of characters after which the text input is changed to a multiline textbox.
|
|
10
13
|
*/
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LongTextInput = void 0;
|
|
4
|
+
const react_1 = require("@fluentui/react");
|
|
4
5
|
const React = require("react");
|
|
5
|
-
const
|
|
6
|
+
const Components_1 = require("../../Components");
|
|
7
|
+
const Components_2 = require("../../Components");
|
|
6
8
|
class LongTextInput extends React.Component {
|
|
7
9
|
constructor() {
|
|
8
10
|
super(...arguments);
|
|
@@ -15,19 +17,21 @@ class LongTextInput extends React.Component {
|
|
|
15
17
|
};
|
|
16
18
|
}
|
|
17
19
|
render() {
|
|
18
|
-
var _a;
|
|
19
20
|
if (!this.props)
|
|
20
21
|
return null;
|
|
22
|
+
const { dynamicProps, operativeProps } = this.props;
|
|
23
|
+
const { isDisabled } = dynamicProps;
|
|
24
|
+
const { autoFocus, contentType, placeholder } = operativeProps;
|
|
21
25
|
return (React.createElement(React.Fragment, null,
|
|
22
|
-
|
|
23
|
-
React.createElement(
|
|
26
|
+
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: (_event, newValue) => {
|
|
24
28
|
// Dynamically change the 'isMultiline' state property.
|
|
25
29
|
const isMultiline = newValue.length > this.multilineThreshold;
|
|
26
30
|
if (this.state.isMultiline !== isMultiline) {
|
|
27
31
|
this.setState({ isMultiline: isMultiline });
|
|
28
32
|
}
|
|
29
33
|
this.props.onChange(newValue);
|
|
30
|
-
}, errorMessage: this.props.errorMessage, type:
|
|
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 })));
|
|
31
35
|
}
|
|
32
36
|
}
|
|
33
37
|
exports.LongTextInput = LongTextInput;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FormText } from '../../Components';
|
|
1
2
|
import { ValidationRule } from '../../IValueInputElement';
|
|
2
3
|
export declare const invalidCharacters: string[];
|
|
3
|
-
export declare function restrictValidPath(errorMessage?:
|
|
4
|
+
export declare function restrictValidPath(errorMessage?: FormText): ValidationRule<string>;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { IBaseInputElementDynamicProps } from '../IBaseInputElementDynamicProps';
|
|
3
|
+
import { IDynamicProps } from '../IDynamicProps';
|
|
4
|
+
import { IOperativeProps } from '../IOperativeProps';
|
|
2
5
|
import { ISingleValueInputElementProps } from '../ISingleValueInputElementProps';
|
|
3
6
|
import { ITextInputProps } from './ITextInputProps';
|
|
4
|
-
export declare class TextInput extends React.Component<ISingleValueInputElementProps<string> & ITextInputProps> {
|
|
7
|
+
export declare class TextInput extends React.Component<ISingleValueInputElementProps<string> & IOperativeProps<ITextInputProps> & IDynamicProps<IBaseInputElementDynamicProps>> {
|
|
5
8
|
render(): JSX.Element;
|
|
6
9
|
}
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TextInput = void 0;
|
|
4
|
+
const react_1 = require("@fluentui/react");
|
|
4
5
|
const React = require("react");
|
|
5
|
-
const
|
|
6
|
+
const Components_1 = require("../../Components");
|
|
6
7
|
class TextInput extends React.Component {
|
|
7
8
|
render() {
|
|
8
|
-
var _a;
|
|
9
9
|
if (!this.props)
|
|
10
10
|
return null;
|
|
11
|
+
const { dynamicProps, operativeProps } = this.props;
|
|
12
|
+
const { isDisabled } = dynamicProps;
|
|
13
|
+
const { autoFocus, contentType, placeholder } = operativeProps;
|
|
11
14
|
return (React.createElement(React.Fragment, null,
|
|
12
|
-
|
|
13
|
-
React.createElement(
|
|
15
|
+
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: (_event, newValue) => {
|
|
14
17
|
this.props.onChange(newValue);
|
|
15
|
-
}, errorMessage: this.props.errorMessage, type:
|
|
18
|
+
}, errorMessage: Components_1.materializeErrorMessage(this.props.errorMessage), type: contentType, placeholder: placeholder, validateOnFocusOut: true, disabled: isDisabled, autoFocus: autoFocus })));
|
|
16
19
|
}
|
|
17
20
|
}
|
|
18
21
|
exports.TextInput = TextInput;
|
|
@@ -7,7 +7,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
7
7
|
o[k2] = m[k];
|
|
8
8
|
}));
|
|
9
9
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./EmptyValidationRules"), exports);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { IBaseInputElementDynamicProps } from '../IBaseInputElementDynamicProps';
|
|
2
1
|
import { IBaseInputElementProps } from '../IBaseInputElementProps';
|
|
3
|
-
export interface ITimePickerProps extends IBaseInputElementProps
|
|
2
|
+
export interface ITimePickerProps extends IBaseInputElementProps {
|
|
3
|
+
inputClassName?: string;
|
|
4
|
+
clearButtonClassName?: string;
|
|
4
5
|
formatDate?: (date: Date) => string;
|
|
5
6
|
showGoToToday?: boolean;
|
|
6
7
|
showMonthPicker?: boolean;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
+
import { IBaseInputElementDynamicProps } from '../IBaseInputElementDynamicProps';
|
|
3
|
+
import { IDynamicProps } from '../IDynamicProps';
|
|
4
|
+
import { IOperativeProps } from '../IOperativeProps';
|
|
2
5
|
import { ISingleValueInputElementProps } from '../ISingleValueInputElementProps';
|
|
3
6
|
import { ITimePickerProps } from './ITimePickerProps';
|
|
4
|
-
|
|
7
|
+
import './TimePicker.less';
|
|
8
|
+
export declare class TimePicker extends React.Component<ISingleValueInputElementProps<Date> & IOperativeProps<ITimePickerProps> & IDynamicProps<IBaseInputElementDynamicProps>> {
|
|
5
9
|
render(): JSX.Element;
|
|
6
10
|
private onChange;
|
|
11
|
+
private clearDate;
|
|
7
12
|
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TimePicker = void 0;
|
|
4
|
+
const react_1 = require("@fluentui/react");
|
|
4
5
|
const React = require("react");
|
|
5
|
-
const
|
|
6
|
+
const Components_1 = require("../../Components");
|
|
7
|
+
const Utilities_1 = require("../../Utilities");
|
|
8
|
+
require("./TimePicker.less");
|
|
6
9
|
class TimePicker extends React.Component {
|
|
7
10
|
constructor() {
|
|
8
11
|
super(...arguments);
|
|
@@ -10,17 +13,23 @@ class TimePicker extends React.Component {
|
|
|
10
13
|
var _a;
|
|
11
14
|
(_a = this.props) === null || _a === void 0 ? void 0 : _a.onChange(newValue);
|
|
12
15
|
};
|
|
16
|
+
this.clearDate = () => {
|
|
17
|
+
this.onChange(null);
|
|
18
|
+
};
|
|
13
19
|
}
|
|
14
20
|
render() {
|
|
15
|
-
var _a;
|
|
16
21
|
if (!this.props)
|
|
17
22
|
return null;
|
|
23
|
+
const { dynamicProps, operativeProps } = this.props;
|
|
24
|
+
const clearButtonClassName = Utilities_1.combineClasses('q-clear-button', operativeProps.clearButtonClassName);
|
|
18
25
|
return (React.createElement(React.Fragment, null,
|
|
19
|
-
|
|
20
|
-
React.createElement(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
React.createElement(Components_1.LabelRenderer, { label: this.props.label, required: !!this.props.renderRequiredIndicator }),
|
|
27
|
+
React.createElement(react_1.DatePicker, { "data-automationid": "time-input", placeholder: operativeProps.placeholder, onSelectDate: this.onChange, textField: {
|
|
28
|
+
onRenderSuffix: () => React.createElement(Components_1.ClearButton, { onClick: this.clearDate, className: clearButtonClassName }),
|
|
29
|
+
inputClassName: operativeProps.inputClassName,
|
|
30
|
+
errorMessage: Components_1.materializeErrorMessage(this.props.errorMessage),
|
|
31
|
+
disabled: dynamicProps.isDisabled
|
|
32
|
+
}, showGoToToday: !!operativeProps.showGoToToday, formatDate: operativeProps.formatDate, firstDayOfWeek: !!operativeProps.startWeekOnSunday ? react_1.DayOfWeek.Sunday : react_1.DayOfWeek.Monday, isMonthPickerVisible: !!operativeProps.showMonthPicker, highlightSelectedMonth: !!operativeProps.showMonthPicker, value: this.props.value })));
|
|
24
33
|
}
|
|
25
34
|
}
|
|
26
35
|
exports.TimePicker = TimePicker;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
.ms-TextField-suffix {
|
|
2
|
+
padding: 0;
|
|
3
|
+
background: none;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
button.q-clear-button i {
|
|
7
|
+
font-size: 12px;
|
|
8
|
+
color: rgb(96, 94, 92);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.q-clear-button {
|
|
12
|
+
padding: 0.16em 0.3em 0 0;
|
|
13
|
+
min-width: 1.2em;
|
|
14
|
+
border: none;
|
|
15
|
+
height: 1.8em;
|
|
16
|
+
margin: 0 auto;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.q-clear-button:hover {
|
|
20
|
+
background-color: white;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// This is required because we need to display the calendar icon
|
|
24
|
+
// in the date input elements right before any other icon on the right.
|
|
25
|
+
div[data-automationid='time-input'] i[data-icon-name='Calendar'] {
|
|
26
|
+
position: relative;
|
|
27
|
+
right: 0;
|
|
28
|
+
}
|
|
@@ -7,7 +7,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
7
7
|
o[k2] = m[k];
|
|
8
8
|
}));
|
|
9
9
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./ITimePickerProps"), exports);
|
|
@@ -2,6 +2,8 @@ export * from './ISingleInputElementConfiguration';
|
|
|
2
2
|
export * from './ISingleValueInputElement';
|
|
3
3
|
export * from './ISingleValueInputElementProps';
|
|
4
4
|
export * from './IBaseInputElementProps';
|
|
5
|
+
export * from './IDynamicProps';
|
|
6
|
+
export * from './IOperativeProps';
|
|
5
7
|
export * from './IBaseInputElementDynamicProps';
|
|
6
8
|
export * from './SingleValueInputElement';
|
|
7
9
|
export * from './Comparators/index';
|
|
@@ -7,13 +7,15 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
7
7
|
o[k2] = m[k];
|
|
8
8
|
}));
|
|
9
9
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./ISingleInputElementConfiguration"), exports);
|
|
14
14
|
__exportStar(require("./ISingleValueInputElement"), exports);
|
|
15
15
|
__exportStar(require("./ISingleValueInputElementProps"), exports);
|
|
16
16
|
__exportStar(require("./IBaseInputElementProps"), exports);
|
|
17
|
+
__exportStar(require("./IDynamicProps"), exports);
|
|
18
|
+
__exportStar(require("./IOperativeProps"), exports);
|
|
17
19
|
__exportStar(require("./IBaseInputElementDynamicProps"), exports);
|
|
18
20
|
__exportStar(require("./SingleValueInputElement"), exports);
|
|
19
21
|
__exportStar(require("./Comparators/index"), exports);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare type ValueChangeSubscription<TValue> = (newValue: TValue) => void;
|
|
2
|
-
export declare type InvalidValueChangeSubscription
|
|
1
|
+
export declare type ValueChangeSubscription<TValue> = (newValue: TValue, previousValue: TValue) => void;
|
|
2
|
+
export declare type InvalidValueChangeSubscription = () => void;
|
|
@@ -7,7 +7,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
7
7
|
o[k2] = m[k];
|
|
8
8
|
}));
|
|
9
9
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./ValueChangeSubscription"), exports);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IDropdownOption } from '
|
|
1
|
+
import { IDropdownOption } from '@fluentui/react';
|
|
2
2
|
import { IDropdownInputOption } from '../SingleValueInputElements';
|
|
3
3
|
export declare class DropdownHelper {
|
|
4
4
|
static getNormalizedOptions(defaultOption: IDropdownInputOption, allOptions: IDropdownInputOption[]): IDropdownOption[];
|