@try-at-software/input-elements 1.2.0-aplha.6 → 1.2.0-beta.10

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.
Files changed (112) hide show
  1. package/LICENSE +21 -0
  2. package/lib/ChangingInputElement.d.ts +16 -0
  3. package/lib/ChangingInputElement.js +34 -0
  4. package/lib/Components/Buttons/ClearButton.d.ts +10 -0
  5. package/lib/Components/Buttons/ClearButton.js +12 -0
  6. package/lib/Components/Buttons/index.d.ts +1 -0
  7. package/lib/Components/Buttons/index.js +13 -0
  8. package/lib/Components/Text/ErrorRenderer.d.ts +9 -0
  9. package/lib/Components/Text/ErrorRenderer.js +14 -0
  10. package/lib/Components/Text/FormTextRenderer.d.ts +8 -0
  11. package/lib/Components/Text/FormTextRenderer.js +19 -0
  12. package/lib/Components/Text/LabelRenderer.d.ts +8 -0
  13. package/lib/Components/Text/LabelRenderer.js +16 -0
  14. package/lib/Components/Text/Types.d.ts +2 -0
  15. package/lib/Components/Text/Types.js +2 -0
  16. package/lib/Components/Text/index.d.ts +4 -0
  17. package/lib/Components/Text/index.js +16 -0
  18. package/lib/Components/index.d.ts +2 -0
  19. package/lib/Components/index.js +14 -0
  20. package/lib/DynamicListInputElement/DynamicListInputElement.js +1 -1
  21. package/lib/DynamicListInputElement/IBasicMenuButtonConfiguration.d.ts +2 -1
  22. package/lib/DynamicListInputElement/IMenuButtonConfiguration.d.ts +0 -3
  23. package/lib/DynamicListInputElement/InternalPresentationComponents/DynamicListInputElementWrapper.d.ts +1 -1
  24. package/lib/DynamicListInputElement/InternalPresentationComponents/DynamicListInputElementWrapper.js +1 -1
  25. package/lib/DynamicListInputElement/Menu/DynamicListMenu.js +18 -12
  26. package/lib/DynamicListInputElement/Menu/index.js +1 -1
  27. package/lib/DynamicListInputElement/index.js +1 -1
  28. package/lib/ExtendedInputElement.d.ts +2 -13
  29. package/lib/ExtendedInputElement.js +2 -26
  30. package/lib/IInputElement.d.ts +2 -1
  31. package/lib/IInputElementConfiguration.d.ts +3 -2
  32. package/lib/ILoadingInputElementConfiguration.d.ts +2 -2
  33. package/lib/IValueInputElement.d.ts +2 -1
  34. package/lib/InputElement.d.ts +2 -1
  35. package/lib/InputElement.js +1 -1
  36. package/lib/Presentations/IPresentation.d.ts +2 -1
  37. package/lib/Presentations/PresentationRenderers.d.ts +1 -1
  38. package/lib/Presentations/PresentationRenderers.js +12 -9
  39. package/lib/Presentations/index.js +1 -1
  40. package/lib/SingleValueInputElements/Comparators/ArrayComparator.d.ts +3 -0
  41. package/lib/SingleValueInputElements/Comparators/ArrayComparator.js +5 -1
  42. package/lib/SingleValueInputElements/Comparators/DefaultEqualityComparer.d.ts +4 -0
  43. package/lib/SingleValueInputElements/Comparators/DefaultEqualityComparer.js +9 -0
  44. package/lib/SingleValueInputElements/Comparators/IEqualityComparer.d.ts +3 -0
  45. package/lib/SingleValueInputElements/Comparators/IEqualityComparer.js +2 -0
  46. package/lib/SingleValueInputElements/Comparators/index.d.ts +2 -0
  47. package/lib/SingleValueInputElements/Comparators/index.js +3 -1
  48. package/lib/SingleValueInputElements/DropdownInputElement/ConsistencyValidationRules.d.ts +2 -1
  49. package/lib/SingleValueInputElements/DropdownInputElement/DropdownInput.d.ts +8 -4
  50. package/lib/SingleValueInputElements/DropdownInputElement/DropdownInput.js +35 -30
  51. package/lib/SingleValueInputElements/DropdownInputElement/IDropdownInputConfiguration.d.ts +8 -0
  52. package/lib/SingleValueInputElements/DropdownInputElement/IDropdownInputConfiguration.js +2 -0
  53. package/lib/SingleValueInputElements/DropdownInputElement/IDropdownInputProps.d.ts +4 -2
  54. package/lib/SingleValueInputElements/DropdownInputElement/IFluentUiDropdownInputProps.d.ts +5 -0
  55. package/lib/SingleValueInputElements/DropdownInputElement/IFluentUiDropdownInputProps.js +2 -0
  56. package/lib/SingleValueInputElements/DropdownInputElement/MultiValueDropdownInput.d.ts +4 -2
  57. package/lib/SingleValueInputElements/DropdownInputElement/MultiValueDropdownInput.js +29 -19
  58. package/lib/SingleValueInputElements/DropdownInputElement/index.d.ts +2 -1
  59. package/lib/SingleValueInputElements/DropdownInputElement/index.js +3 -2
  60. package/lib/SingleValueInputElements/IBaseInputElementDynamicProps.d.ts +1 -1
  61. package/lib/SingleValueInputElements/IDynamicProps.d.ts +3 -0
  62. package/lib/SingleValueInputElements/IDynamicProps.js +2 -0
  63. package/lib/SingleValueInputElements/IOperativeProps.d.ts +3 -0
  64. package/lib/SingleValueInputElements/IOperativeProps.js +2 -0
  65. package/lib/SingleValueInputElements/ISingleValueInputElement.d.ts +5 -2
  66. package/lib/SingleValueInputElements/ISingleValueInputElementProps.d.ts +7 -3
  67. package/lib/SingleValueInputElements/IdentityPickerInputElement/IIdentityPickerProps.d.ts +2 -3
  68. package/lib/SingleValueInputElements/IdentityPickerInputElement/IdentityPicker.d.ts +6 -3
  69. package/lib/SingleValueInputElements/IdentityPickerInputElement/IdentityPicker.js +12 -10
  70. package/lib/SingleValueInputElements/IdentityPickerInputElement/index.js +1 -1
  71. package/lib/SingleValueInputElements/InternalPresentationComponents/SingleValueInputElementWrapper.d.ts +13 -8
  72. package/lib/SingleValueInputElements/InternalPresentationComponents/SingleValueInputElementWrapper.js +10 -5
  73. package/lib/SingleValueInputElements/NumberInputElement/INumberInputProps.d.ts +1 -2
  74. package/lib/SingleValueInputElements/NumberInputElement/NumberInput.d.ts +6 -2
  75. package/lib/SingleValueInputElements/NumberInputElement/NumberInput.js +34 -35
  76. package/lib/SingleValueInputElements/NumberInputElement/index.js +1 -1
  77. package/lib/SingleValueInputElements/SingleValueInputElement.d.ts +12 -8
  78. package/lib/SingleValueInputElements/SingleValueInputElement.js +42 -17
  79. package/lib/SingleValueInputElements/TextInputElement/EmptyValidationRules.d.ts +2 -1
  80. package/lib/SingleValueInputElements/TextInputElement/ITextInputProps.d.ts +1 -2
  81. package/lib/SingleValueInputElements/TextInputElement/LengthValidationRules.d.ts +3 -2
  82. package/lib/SingleValueInputElements/TextInputElement/LongTextInput.d.ts +4 -1
  83. package/lib/SingleValueInputElements/TextInputElement/LongTextInput.js +9 -5
  84. package/lib/SingleValueInputElements/TextInputElement/PathValidationRules.d.ts +2 -1
  85. package/lib/SingleValueInputElements/TextInputElement/TextInput.d.ts +4 -1
  86. package/lib/SingleValueInputElements/TextInputElement/TextInput.js +8 -5
  87. package/lib/SingleValueInputElements/TextInputElement/index.js +1 -1
  88. package/lib/SingleValueInputElements/TimePickerInputElement/ITimePickerProps.d.ts +3 -2
  89. package/lib/SingleValueInputElements/TimePickerInputElement/TimePicker.d.ts +6 -1
  90. package/lib/SingleValueInputElements/TimePickerInputElement/TimePicker.js +16 -7
  91. package/lib/SingleValueInputElements/TimePickerInputElement/TimePicker.less +28 -0
  92. package/lib/SingleValueInputElements/TimePickerInputElement/index.js +1 -1
  93. package/lib/SingleValueInputElements/index.d.ts +2 -0
  94. package/lib/SingleValueInputElements/index.js +3 -1
  95. package/lib/Subscriptions/ValueChangeSubscription.d.ts +2 -2
  96. package/lib/Subscriptions/index.js +1 -1
  97. package/lib/Utilities/DropdownHelper.d.ts +1 -1
  98. package/lib/Utilities/DropdownHelper.js +8 -6
  99. package/lib/Utilities/FormHelper.js +8 -2
  100. package/lib/Utilities/InputElementsBuilding.d.ts +13 -0
  101. package/lib/Utilities/InputElementsBuilding.js +18 -0
  102. package/lib/Utilities/index.d.ts +1 -0
  103. package/lib/Utilities/index.js +2 -1
  104. package/lib/index.d.ts +1 -0
  105. package/lib/index.js +2 -1
  106. package/package.json +42 -40
  107. package/lib/SingleValueInputElements/DependentInputElement/DependentInputElementInitializer.d.ts +0 -0
  108. package/lib/SingleValueInputElements/DependentInputElement/DependentInputElementInitializer.js +0 -51
  109. package/lib/SingleValueInputElements/DependentInputElement/index.d.ts +0 -0
  110. package/lib/SingleValueInputElements/DependentInputElement/index.js +0 -1
  111. package/lib/SingleValueInputElements/DropdownInputElement/DropdownInputElement.d.ts +0 -11
  112. 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 office_ui_fabric_react_1 = require("office-ui-fabric-react");
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, _b;
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
- this.props.label && React.createElement(office_ui_fabric_react_1.Label, { required: this.props.renderRequiredIndicator }, this.props.label),
22
- React.createElement(office_ui_fabric_react_1.SpinButton, { styles: {
23
- input: {
24
- fontFamily: '"Segoe UI", "Segoe UI Web (West European)"',
25
- fontSize: 14,
26
- fontWeight: 400
27
- }
28
- }, inputProps: {
29
- autoFocus: this.props.autoFocus,
30
- placeholder: this.props.placeholder,
31
- disabled: this.props.isDisabled
32
- }, value: (_a = this.state.intermediateValue) !== null && _a !== void 0 ? _a : '', onChange: (event) => {
33
- var _a;
34
- const value = NumberInput.normalizeData((_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.value);
35
- if (!value || isNaN(Number(value))) {
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
- const numericValue = NumberInput.getNumericValue(value);
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
- !!((_b = this.props) === null || _b === void 0 ? void 0 : _b.errorMessage) && React.createElement(office_ui_fabric_react_1.MessageBar, { messageBarType: office_ui_fabric_react_1.MessageBarType.warning }, this.props.errorMessage),
54
- !!this.state.customWarning && React.createElement(office_ui_fabric_react_1.MessageBar, { messageBarType: office_ui_fabric_react_1.MessageBarType.warning }, this.state.customWarning)));
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 ${maxValue}`, newValue: undefined };
71
- if (!this.props.handleDecimalValues && value % 1 !== 0)
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, _b;
80
- return (_b = (_a = this.props) === null || _a === void 0 ? void 0 : _a.max) !== null && _b !== void 0 ? _b : Number.MAX_SAFE_INTEGER;
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, _b;
84
- return (_b = (_a = this.props) === null || _a === void 0 ? void 0 : _a.min) !== null && _b !== void 0 ? _b : Number.MIN_SAFE_INTEGER;
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, _b;
88
- return (_b = (_a = this.props) === null || _a === void 0 ? void 0 : _a.step) !== null && _b !== void 0 ? _b : 1;
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" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
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 type WrapperType<TValue, TComponentProps, TRenderProps> = SingleValueInputElementWrapper<TValue, ISingleValueInputElementProps<TValue> & TComponentProps & TRenderProps>;
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>, props: TComponentProps, update: UpdateCallback, ...validationRules: ValidationRule<TValue>[]);
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
- subscribeToInvalidValueChange(subscription: InvalidValueChangeSubscription<TValue>): void;
23
+ subscribeToInitialValueChange(subscription: ValueChangeSubscription<TValue>): void;
22
24
  /** @inheritdoc */
23
- protected setInternalValue(value: TValue): void;
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(renderData?: TDynamicProps): JSX.Element;
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 === null || options === void 0 ? void 0 : 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
- this.valueChangeSubscriptions.forEach((x) => x === null || x === void 0 ? void 0 : x(this.value));
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
  }
@@ -67,9 +86,7 @@ class SingleValueInputElement extends ExtendedInputElement_1.ExtendedInputElemen
67
86
  }
68
87
  /** @inheritdoc */
69
88
  get isValid() {
70
- if (this._isInvalidated)
71
- return false;
72
- if (this.errorMessage && this.errorMessage.length > 0)
89
+ if (this._isInvalidated || this.isLoading || this.errorMessage)
73
90
  return false;
74
91
  return (!!this._configuration && !this._configuration.isRequired) || this._valueIsSet || this._initialValueIsSet;
75
92
  }
@@ -78,11 +95,18 @@ class SingleValueInputElement extends ExtendedInputElement_1.ExtendedInputElemen
78
95
  return this._dynamicProps;
79
96
  }
80
97
  /** @inheritdoc */
81
- renderComponent(renderData) {
98
+ renderComponent() {
82
99
  var _a, _b, _c, _d, _e, _f;
83
100
  return (React.createElement("div", { className: Utilities_1.combineClasses('tas-input-element', (_a = this._configuration) === null || _a === void 0 ? void 0 : _a.className) },
84
101
  React.createElement("div", { className: "tas-input-element-content" },
85
- React.createElement(SingleValueInputElementWrapper_1.SingleValueInputElementWrapper, { internalComponent: this.componentToRender, renderLoadingIndicator: (_b = this._configuration) === null || _b === void 0 ? void 0 : _b.renderLoadingComponent, componentProps: Object.assign(Object.assign(Object.assign({}, this.componentProps), renderData), { label: (_c = this._configuration) === null || _c === void 0 ? void 0 : _c.label, value: this.value, renderRequiredIndicator: ((_d = this._configuration) === null || _d === void 0 ? void 0 : _d.renderRequiredIndicator) && ((_e = this._configuration) === null || _e === void 0 ? void 0 : _e.isRequired), errorMessage: ((_f = this._configuration) === null || _f === void 0 ? void 0 : _f.renderErrors) && this.errorMessage, onChange: (newValue) => this.setValue(newValue), invalidateInput: this.invalidateInput }), initialDynamicProps: this._dynamicProps, isInitiallyLoading: this.isLoading, isInitiallyVisible: this.isVisible, ref: this._componentRef }))));
102
+ 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: {
103
+ label: (_d = this._configuration) === null || _d === void 0 ? void 0 : _d.label,
104
+ value: this.value,
105
+ renderRequiredIndicator: ((_e = this._configuration) === null || _e === void 0 ? void 0 : _e.renderRequiredIndicator) && ((_f = this._configuration) === null || _f === void 0 ? void 0 : _f.isRequired),
106
+ errorMessage: this.errorMessage,
107
+ onChange: (newValue) => this.setValue(newValue),
108
+ invalidateInput: this.invalidateInput
109
+ }, operativeProps: this.componentProps, initialDynamicProps: this._dynamicProps, isInitiallyLoading: this.isLoading, isInitiallyVisible: this.isVisible, ref: this._componentRef }))));
86
110
  }
87
111
  /** @inheritdoc */
88
112
  changeDynamicProps(dynamicProps) {
@@ -99,21 +123,22 @@ class SingleValueInputElement extends ExtendedInputElement_1.ExtendedInputElemen
99
123
  var _a, _b, _c, _d, _e;
100
124
  if (!!((_a = this._configuration) === null || _a === void 0 ? void 0 : _a.shouldExecuteValidation) && this._configuration.shouldExecuteValidation() === false)
101
125
  return;
102
- let errorMessage = null;
126
+ let errorMessage = undefined;
103
127
  if (((_b = this._configuration) === null || _b === void 0 ? void 0 : _b.isRequired) && !this.valueIsValid()) {
104
128
  // If a value is required but the input field is empty.
105
129
  errorMessage = ((_c = this._configuration) === null || _c === void 0 ? void 0 : _c.requiredValidationMessage) || `The field is required`;
106
130
  }
107
131
  else if (((_d = this._configuration) === null || _d === void 0 ? void 0 : _d.isRequired) || this.value || ((_e = this._configuration) === null || _e === void 0 ? void 0 : _e.executeAllValidations)) {
108
132
  // If a value is provided.
109
- this.validationRules.forEach((rule) => {
110
- if (!errorMessage)
111
- errorMessage = rule(this.value);
112
- });
133
+ for (const validationRule of this.validationRules) {
134
+ const currentError = validationRule(this.value);
135
+ if (currentError) {
136
+ errorMessage = currentError;
137
+ break;
138
+ }
139
+ }
113
140
  }
114
- this.errorMessage = errorMessage;
115
- if (this._componentRef.current)
116
- this._componentRef.current.setError(errorMessage);
141
+ this.setError(errorMessage);
117
142
  }
118
143
  }
119
144
  exports.SingleValueInputElement = SingleValueInputElement;
@@ -1,2 +1,3 @@
1
+ import { FormText } from '../../Components';
1
2
  import { ValidationRule } from '../../IValueInputElement';
2
- export declare function restrictEmptyText(errorMessage?: string): ValidationRule<string>;
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, IBaseInputElementDynamicProps {
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?: string): ValidationRule<string>;
3
- export declare function restrictMaximumLength(maxLength: number, errorMessage?: string): ValidationRule<string>;
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, ILongTextInputState> {
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 office_ui_fabric_react_1 = require("office-ui-fabric-react");
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
- !!((_a = this.props) === null || _a === void 0 ? void 0 : _a.label) && React.createElement(office_ui_fabric_react_1.Label, { required: !!this.props.renderRequiredIndicator }, this.props.label),
23
- React.createElement(office_ui_fabric_react_1.TextField, { value: this.props.value || '', onChange: (_event, newValue) => {
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: this.props.contentType, placeholder: this.props.placeholder, multiline: this.state.isMultiline, autoAdjustHeight: this.state.isMultiline, validateOnFocusOut: true, disabled: this.props.isDisabled })));
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?: string): ValidationRule<string>;
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 office_ui_fabric_react_1 = require("office-ui-fabric-react");
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
- !!((_a = this.props) === null || _a === void 0 ? void 0 : _a.label) && React.createElement(office_ui_fabric_react_1.Label, { required: !!this.props.renderRequiredIndicator }, this.props.label),
13
- React.createElement(office_ui_fabric_react_1.TextField, { value: this.props.value || '', onChange: (_event, newValue) => {
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: this.props.contentType, placeholder: this.props.placeholder, validateOnFocusOut: true, disabled: this.props.isDisabled, autoFocus: this.props.autoFocus })));
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" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
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, IBaseInputElementDynamicProps {
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
- export declare class TimePicker extends React.Component<ISingleValueInputElementProps<Date> & ITimePickerProps> {
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 office_ui_fabric_react_1 = require("office-ui-fabric-react");
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
- !!((_a = this.props) === null || _a === void 0 ? void 0 : _a.label) && React.createElement(office_ui_fabric_react_1.Label, { required: !!this.props.renderRequiredIndicator }, this.props.label),
20
- React.createElement(office_ui_fabric_react_1.DatePicker, { placeholder: this.props.placeholder, onSelectDate: this.onChange, textField: {
21
- errorMessage: this.props.errorMessage,
22
- disabled: this.props.isDisabled
23
- }, showGoToToday: !!this.props.showGoToToday, formatDate: this.props.formatDate, firstDayOfWeek: this.props.startWeekOnSunday ? office_ui_fabric_react_1.DayOfWeek.Sunday : office_ui_fabric_react_1.DayOfWeek.Monday, isMonthPickerVisible: !!this.props.showMonthPicker, highlightSelectedMonth: !!this.props.showMonthPicker, value: this.props.value })));
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" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
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" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
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<TValue> = () => void;
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" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
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 'office-ui-fabric-react';
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[];