@try-at-software/input-elements 1.2.0-aplha.5 → 1.2.0-beta.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.
Files changed (111) 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 +14 -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.d.ts +1 -1
  21. package/lib/DynamicListInputElement/DynamicListInputElement.js +1 -1
  22. package/lib/DynamicListInputElement/IBasicMenuButtonConfiguration.d.ts +2 -1
  23. package/lib/DynamicListInputElement/IMenuButtonConfiguration.d.ts +0 -3
  24. package/lib/DynamicListInputElement/InternalPresentationComponents/DynamicListInputElementWrapper.d.ts +1 -1
  25. package/lib/DynamicListInputElement/InternalPresentationComponents/DynamicListInputElementWrapper.js +1 -1
  26. package/lib/DynamicListInputElement/Menu/DynamicListMenu.js +18 -12
  27. package/lib/DynamicListInputElement/Menu/index.js +1 -1
  28. package/lib/DynamicListInputElement/index.js +1 -1
  29. package/lib/ExtendedInputElement.d.ts +2 -13
  30. package/lib/ExtendedInputElement.js +2 -26
  31. package/lib/IInputElement.d.ts +2 -1
  32. package/lib/IInputElementConfiguration.d.ts +3 -2
  33. package/lib/ILoadingInputElementConfiguration.d.ts +2 -2
  34. package/lib/IValueInputElement.d.ts +2 -1
  35. package/lib/InputElement.d.ts +2 -1
  36. package/lib/InputElement.js +1 -1
  37. package/lib/Presentations/IPresentation.d.ts +2 -1
  38. package/lib/Presentations/PresentationRenderers.d.ts +1 -1
  39. package/lib/Presentations/PresentationRenderers.js +12 -9
  40. package/lib/Presentations/index.js +1 -1
  41. package/lib/SingleValueInputElements/Comparators/ArrayComparator.d.ts +3 -0
  42. package/lib/SingleValueInputElements/Comparators/ArrayComparator.js +5 -1
  43. package/lib/SingleValueInputElements/Comparators/DefaultEqualityComparer.d.ts +4 -0
  44. package/lib/SingleValueInputElements/Comparators/DefaultEqualityComparer.js +9 -0
  45. package/lib/SingleValueInputElements/Comparators/IEqualityComparer.d.ts +3 -0
  46. package/lib/SingleValueInputElements/Comparators/IEqualityComparer.js +2 -0
  47. package/lib/SingleValueInputElements/Comparators/index.d.ts +2 -0
  48. package/lib/SingleValueInputElements/Comparators/index.js +3 -1
  49. package/lib/SingleValueInputElements/DropdownInputElement/ConsistencyValidationRules.d.ts +2 -1
  50. package/lib/SingleValueInputElements/DropdownInputElement/DropdownInput.d.ts +9 -4
  51. package/lib/SingleValueInputElements/DropdownInputElement/DropdownInput.js +24 -30
  52. package/lib/SingleValueInputElements/DropdownInputElement/IDropdownInputProps.d.ts +2 -2
  53. package/lib/SingleValueInputElements/DropdownInputElement/IFluentUiDropdownInputProps.d.ts +5 -0
  54. package/lib/SingleValueInputElements/DropdownInputElement/IFluentUiDropdownInputProps.js +2 -0
  55. package/lib/SingleValueInputElements/DropdownInputElement/MultiValueDropdownInput.d.ts +4 -2
  56. package/lib/SingleValueInputElements/DropdownInputElement/MultiValueDropdownInput.js +29 -19
  57. package/lib/SingleValueInputElements/DropdownInputElement/index.d.ts +1 -1
  58. package/lib/SingleValueInputElements/DropdownInputElement/index.js +2 -2
  59. package/lib/SingleValueInputElements/IBaseInputElementDynamicProps.d.ts +1 -1
  60. package/lib/SingleValueInputElements/IDynamicProps.d.ts +3 -0
  61. package/lib/SingleValueInputElements/IDynamicProps.js +2 -0
  62. package/lib/SingleValueInputElements/IOperativeProps.d.ts +3 -0
  63. package/lib/SingleValueInputElements/IOperativeProps.js +2 -0
  64. package/lib/SingleValueInputElements/ISingleValueInputElement.d.ts +5 -2
  65. package/lib/SingleValueInputElements/ISingleValueInputElementProps.d.ts +7 -3
  66. package/lib/SingleValueInputElements/IdentityPickerInputElement/IIdentityPickerProps.d.ts +2 -3
  67. package/lib/SingleValueInputElements/IdentityPickerInputElement/IdentityPicker.d.ts +6 -3
  68. package/lib/SingleValueInputElements/IdentityPickerInputElement/IdentityPicker.js +12 -10
  69. package/lib/SingleValueInputElements/IdentityPickerInputElement/index.js +1 -1
  70. package/lib/SingleValueInputElements/InternalPresentationComponents/SingleValueInputElementWrapper.d.ts +13 -8
  71. package/lib/SingleValueInputElements/InternalPresentationComponents/SingleValueInputElementWrapper.js +10 -5
  72. package/lib/SingleValueInputElements/NumberInputElement/INumberInputProps.d.ts +1 -2
  73. package/lib/SingleValueInputElements/NumberInputElement/NumberInput.d.ts +6 -2
  74. package/lib/SingleValueInputElements/NumberInputElement/NumberInput.js +34 -35
  75. package/lib/SingleValueInputElements/NumberInputElement/index.js +1 -1
  76. package/lib/SingleValueInputElements/SingleValueInputElement.d.ts +12 -8
  77. package/lib/SingleValueInputElements/SingleValueInputElement.js +35 -9
  78. package/lib/SingleValueInputElements/TextInputElement/EmptyValidationRules.d.ts +2 -1
  79. package/lib/SingleValueInputElements/TextInputElement/ITextInputProps.d.ts +1 -2
  80. package/lib/SingleValueInputElements/TextInputElement/LengthValidationRules.d.ts +3 -2
  81. package/lib/SingleValueInputElements/TextInputElement/LongTextInput.d.ts +4 -1
  82. package/lib/SingleValueInputElements/TextInputElement/LongTextInput.js +9 -5
  83. package/lib/SingleValueInputElements/TextInputElement/PathValidationRules.d.ts +2 -1
  84. package/lib/SingleValueInputElements/TextInputElement/TextInput.d.ts +4 -1
  85. package/lib/SingleValueInputElements/TextInputElement/TextInput.js +8 -5
  86. package/lib/SingleValueInputElements/TextInputElement/index.js +1 -1
  87. package/lib/SingleValueInputElements/TimePickerInputElement/ITimePickerProps.d.ts +3 -2
  88. package/lib/SingleValueInputElements/TimePickerInputElement/TimePicker.d.ts +6 -1
  89. package/lib/SingleValueInputElements/TimePickerInputElement/TimePicker.js +16 -7
  90. package/lib/SingleValueInputElements/TimePickerInputElement/TimePicker.less +28 -0
  91. package/lib/SingleValueInputElements/TimePickerInputElement/index.js +1 -1
  92. package/lib/SingleValueInputElements/index.d.ts +2 -0
  93. package/lib/SingleValueInputElements/index.js +3 -1
  94. package/lib/Subscriptions/ValueChangeSubscription.d.ts +2 -2
  95. package/lib/Subscriptions/index.js +1 -1
  96. package/lib/Utilities/DropdownHelper.d.ts +1 -1
  97. package/lib/Utilities/DropdownHelper.js +7 -6
  98. package/lib/Utilities/FormHelper.js +8 -2
  99. package/lib/Utilities/InputElementsBuilding.d.ts +13 -0
  100. package/lib/Utilities/InputElementsBuilding.js +18 -0
  101. package/lib/Utilities/index.d.ts +1 -0
  102. package/lib/Utilities/index.js +2 -1
  103. package/lib/index.d.ts +1 -0
  104. package/lib/index.js +2 -1
  105. package/package.json +42 -40
  106. package/lib/SingleValueInputElements/DependentInputElement/DependentInputElementInitializer.d.ts +0 -0
  107. package/lib/SingleValueInputElements/DependentInputElement/DependentInputElementInitializer.js +0 -51
  108. package/lib/SingleValueInputElements/DependentInputElement/index.d.ts +0 -0
  109. package/lib/SingleValueInputElements/DependentInputElement/index.js +0 -1
  110. package/lib/SingleValueInputElements/DropdownInputElement/DropdownInputElement.d.ts +0 -11
  111. package/lib/SingleValueInputElements/DropdownInputElement/DropdownInputElement.js +0 -33
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ArrayComparator = void 0;
4
+ const DefaultEqualityComparer_1 = require("./DefaultEqualityComparer");
4
5
  class ArrayComparator {
6
+ constructor(equalityComparer = null) {
7
+ this._equalityComparer = equalityComparer !== null && equalityComparer !== void 0 ? equalityComparer : new DefaultEqualityComparer_1.DefaultEqualityComparer();
8
+ }
5
9
  /** @inheritdoc */
6
10
  areEqual(a, b) {
7
11
  if (a === b)
@@ -11,7 +15,7 @@ class ArrayComparator {
11
15
  if (a.length !== b.length)
12
16
  return false;
13
17
  for (let i = 0; i < a.length; ++i) {
14
- if (a[i] !== b[i])
18
+ if (!this._equalityComparer.areEqual(a[i], b[i]))
15
19
  return false;
16
20
  }
17
21
  return true;
@@ -0,0 +1,4 @@
1
+ import { IEqualityComparer } from './IEqualityComparer';
2
+ export declare class DefaultEqualityComparer<T> implements IEqualityComparer<T> {
3
+ areEqual(a: T, b: T): boolean;
4
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DefaultEqualityComparer = void 0;
4
+ class DefaultEqualityComparer {
5
+ areEqual(a, b) {
6
+ return a === b;
7
+ }
8
+ }
9
+ exports.DefaultEqualityComparer = DefaultEqualityComparer;
@@ -0,0 +1,3 @@
1
+ export interface IEqualityComparer<T> {
2
+ areEqual(a: T, b: T): boolean;
3
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +1,5 @@
1
1
  export * from './IValueComparator';
2
+ export * from './DefaultEqualityComparer';
3
+ export * from './IEqualityComparer';
2
4
  export * from './ArrayComparator';
3
5
  export * from './ZeroIsValidComparator';
@@ -7,9 +7,11 @@ 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("./IValueComparator"), exports);
14
+ __exportStar(require("./DefaultEqualityComparer"), exports);
15
+ __exportStar(require("./IEqualityComparer"), exports);
14
16
  __exportStar(require("./ArrayComparator"), exports);
15
17
  __exportStar(require("./ZeroIsValidComparator"), exports);
@@ -1,2 +1,3 @@
1
+ import { FormText } from '../../Components';
1
2
  import { ValidationRule } from '../../IValueInputElement';
2
- export declare function ensureConsistency(errorMessage?: string): ValidationRule<string>;
3
+ export declare function ensureConsistency(errorMessage?: FormText): ValidationRule<string>;
@@ -1,8 +1,13 @@
1
1
  import * as React from 'react';
2
+ import { FormText } from '../../Components';
2
3
  import { IBaseInputElementProps } from '../IBaseInputElementProps';
3
- import { IDropdownInputProps } from './IDropdownInputProps';
4
+ import { IDynamicProps } from '../IDynamicProps';
5
+ import { IOperativeProps } from '../IOperativeProps';
4
6
  import { ISingleValueInputElementProps } from '../ISingleValueInputElementProps';
5
- export declare class DropdownInput extends React.Component<ISingleValueInputElementProps<string> & IBaseInputElementProps & IDropdownInputProps> {
6
- render(): JSX.Element;
7
- private getNormalizedOptions;
7
+ import { IDropdownInputProps } from './IDropdownInputProps';
8
+ import { IFluentUiDropdownInputProps } from './IFluentUiDropdownInputProps';
9
+ interface ISingleValueDropdownInputProps extends ISingleValueInputElementProps<string>, IOperativeProps<IBaseInputElementProps>, IDynamicProps<IDropdownInputProps & IFluentUiDropdownInputProps> {
10
+ consistencyErrorMessage?: FormText;
8
11
  }
12
+ export declare const DropdownInput: React.MemoExoticComponent<(props: ISingleValueDropdownInputProps) => JSX.Element>;
13
+ export {};
@@ -1,34 +1,28 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DropdownInput = 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
- class DropdownInput extends React.Component {
7
- render() {
8
- var _a, _b, _c, _d, _e, _f, _g;
9
- const normalizedOptions = this.getNormalizedOptions();
10
- return (React.createElement(React.Fragment, null,
11
- !!((_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),
12
- React.createElement(office_ui_fabric_react_1.Dropdown, { options: normalizedOptions, onChange: (_event, option) => { var _a; return !!((_a = this.props) === null || _a === void 0 ? void 0 : _a.onChange) && this.props.onChange(option.key); }, errorMessage: (_b = this.props) === null || _b === void 0 ? void 0 : _b.errorMessage, placeholder: (_c = this.props) === null || _c === void 0 ? void 0 : _c.placeholder,
13
- // This value should never be `undefined`.
14
- defaultSelectedKey: ((_d = this.props) === null || _d === void 0 ? void 0 : _d.value) || ((_f = (_e = this.props) === null || _e === void 0 ? void 0 : _e.defaultOption) === null || _f === void 0 ? void 0 : _f.key) || null, disabled: (_g = this.props) === null || _g === void 0 ? void 0 : _g.isDisabled })));
15
- }
16
- getNormalizedOptions() {
17
- var _a, _b;
18
- const options = [];
19
- if (!!((_a = this.props) === null || _a === void 0 ? void 0 : _a.defaultOption)) {
20
- const defaultOption = Object.assign(Object.assign({}, this.props.defaultOption), { selected: true });
21
- options.push(defaultOption);
22
- }
23
- if (!((_b = this.props) === null || _b === void 0 ? void 0 : _b.options) || !Array.isArray(this.props.options))
24
- return options;
25
- this.props.options.forEach((o) => {
26
- if (!o)
27
- return;
28
- const newOption = Object.assign(Object.assign({}, o), { selected: false });
29
- options.push(newOption);
30
- });
31
- return options;
32
- }
33
- }
34
- exports.DropdownInput = DropdownInput;
6
+ const react_2 = require("react");
7
+ const Components_1 = require("../../Components");
8
+ const Utilities_1 = require("../../Utilities");
9
+ const ConsistencyErrorMessage = 'The value is not present within the specified options.';
10
+ const DropdownInputComponent = (props) => {
11
+ var _a;
12
+ const { dynamicProps, operativeProps } = props;
13
+ const normalizedOptions = react_2.useMemo(() => Utilities_1.DropdownHelper.getNormalizedOptions(dynamicProps.defaultOption, dynamicProps.options), [dynamicProps.defaultOption, dynamicProps.options]);
14
+ react_2.useEffect(() => {
15
+ if (!props.value || normalizedOptions.some((o) => o.key === props.value))
16
+ return;
17
+ const invalidationOptions = { errorMessage: props.consistencyErrorMessage || ConsistencyErrorMessage };
18
+ props.invalidateInput(invalidationOptions);
19
+ }, [props.value, normalizedOptions, props.consistencyErrorMessage, props.invalidateInput]);
20
+ const DropdownComponent = react_2.useMemo(() => { var _a; return (_a = dynamicProps.dropdownComponent) !== null && _a !== void 0 ? _a : react_1.Dropdown; }, [dynamicProps.dropdownComponent]);
21
+ return (React.createElement(React.Fragment, null,
22
+ React.createElement(Components_1.LabelRenderer, { label: props.label, required: !!props.renderRequiredIndicator }),
23
+ React.createElement(DropdownComponent, { "data-automationid": "dropdown-input", options: normalizedOptions, onChange: (_event, option) => !!props.onChange && props.onChange(option.key), placeholder: operativeProps.placeholder,
24
+ // This value should never be `undefined`.
25
+ defaultSelectedKey: props.value || ((_a = dynamicProps.defaultOption) === null || _a === void 0 ? void 0 : _a.key) || null, disabled: dynamicProps.isDisabled }),
26
+ React.createElement(Components_1.ErrorRenderer, { error: props.errorMessage, messageBarType: react_1.MessageBarType.error })));
27
+ };
28
+ exports.DropdownInput = React.memo(DropdownInputComponent);
@@ -1,9 +1,9 @@
1
1
  import { IBaseInputElementDynamicProps } from '../IBaseInputElementDynamicProps';
2
2
  import { IDropdownInputOption } from './IDropdownInputOption';
3
3
  export interface IDropdownInputProps extends IBaseInputElementDynamicProps {
4
- options?: IDropdownInputOption[];
4
+ options: IDropdownInputOption[];
5
5
  /**
6
6
  * The default option for the dropdown.
7
7
  */
8
- defaultOption?: IDropdownInputOption;
8
+ defaultOption: IDropdownInputOption;
9
9
  }
@@ -0,0 +1,5 @@
1
+ import { IDropdownProps } from '@fluentui/react';
2
+ import * as React from 'react';
3
+ export interface IFluentUiDropdownInputProps {
4
+ dropdownComponent: React.ComponentType<IDropdownProps>;
5
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,7 +1,9 @@
1
1
  import * as React from 'react';
2
2
  import { IBaseInputElementProps } from '../IBaseInputElementProps';
3
- import { IDropdownInputProps } from './IDropdownInputProps';
3
+ import { IDynamicProps } from '../IDynamicProps';
4
+ import { IOperativeProps } from '../IOperativeProps';
4
5
  import { ISingleValueInputElementProps } from '../ISingleValueInputElementProps';
5
- export declare class MultiValueDropdownInput extends React.Component<ISingleValueInputElementProps<string[]> & IBaseInputElementProps & IDropdownInputProps> {
6
+ import { IDropdownInputProps } from './IDropdownInputProps';
7
+ export declare class MultiValueDropdownInput extends React.Component<ISingleValueInputElementProps<string[]> & IOperativeProps<IBaseInputElementProps> & IDynamicProps<IDropdownInputProps>> {
6
8
  render(): JSX.Element;
7
9
  }
@@ -1,29 +1,39 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MultiValueDropdownInput = 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
  const Utilities_1 = require("../../Utilities");
7
8
  class MultiValueDropdownInput extends React.Component {
8
9
  render() {
9
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
10
- const normalizedOptions = Utilities_1.DropdownHelper.getNormalizedOptions((_a = this.props) === null || _a === void 0 ? void 0 : _a.defaultOption, (_b = this.props) === null || _b === void 0 ? void 0 : _b.options);
11
- return (React.createElement(office_ui_fabric_react_1.Dropdown, { label: (_c = this.props) === null || _c === void 0 ? void 0 : _c.label, options: normalizedOptions, onChange: (_event, option) => {
12
- var _a, _b, _c, _d;
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
- let currentValues = (_c = (_b = this.props) === null || _b === void 0 ? void 0 : _b.value) !== null && _c !== void 0 ? _c : [];
17
- // If the current option is selected, add it to the list.
18
- // Else, remove it.
19
- if (option.selected)
20
- currentValues.push(optionKey);
21
- else
22
- currentValues = currentValues.filter((x) => x !== optionKey);
23
- !!((_d = this.props) === null || _d === void 0 ? void 0 : _d.onChange) && this.props.onChange(currentValues);
24
- }, errorMessage: (_d = this.props) === null || _d === void 0 ? void 0 : _d.errorMessage, required: !!((_e = this.props) === null || _e === void 0 ? void 0 : _e.renderRequiredIndicator), placeholder: (_f = this.props) === null || _f === void 0 ? void 0 : _f.placeholder,
25
- // This value should never be `undefined`.
26
- defaultSelectedKeys: ((_g = this.props) === null || _g === void 0 ? void 0 : _g.value) || [(_j = (_h = this.props) === null || _h === void 0 ? void 0 : _h.defaultOption) === null || _j === void 0 ? void 0 : _j.key] || null, disabled: (_k = this.props) === null || _k === void 0 ? void 0 : _k.isDisabled, multiSelect: true }));
10
+ var _a;
11
+ if (!this.props)
12
+ return null;
13
+ const { dynamicProps, operativeProps } = this.props;
14
+ const normalizedOptions = Utilities_1.DropdownHelper.getNormalizedOptions(dynamicProps.defaultOption, dynamicProps.options);
15
+ return (React.createElement(React.Fragment, null,
16
+ 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: (_event, option) => {
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,
34
+ // 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 }),
36
+ React.createElement(Components_1.ErrorRenderer, { error: this.props.errorMessage, messageBarType: react_1.MessageBarType.error })));
27
37
  }
28
38
  }
29
39
  exports.MultiValueDropdownInput = MultiValueDropdownInput;
@@ -1,5 +1,5 @@
1
1
  export * from './DropdownInput';
2
- export * from './DropdownInputElement';
3
2
  export * from './IDropdownInputOption';
4
3
  export * from './IDropdownInputProps';
4
+ export * from './IFluentUiDropdownInputProps';
5
5
  export * from './MultiValueDropdownInput';
@@ -7,11 +7,11 @@ 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("./DropdownInput"), exports);
14
- __exportStar(require("./DropdownInputElement"), exports);
15
14
  __exportStar(require("./IDropdownInputOption"), exports);
16
15
  __exportStar(require("./IDropdownInputProps"), exports);
16
+ __exportStar(require("./IFluentUiDropdownInputProps"), exports);
17
17
  __exportStar(require("./MultiValueDropdownInput"), exports);
@@ -1,3 +1,3 @@
1
1
  export interface IBaseInputElementDynamicProps {
2
- isDisabled?: boolean;
2
+ isDisabled: boolean;
3
3
  }
@@ -0,0 +1,3 @@
1
+ export interface IDynamicProps<TDynamicProps> {
2
+ dynamicProps: Partial<TDynamicProps>;
3
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ export interface IOperativeProps<TComponentProps> {
2
+ operativeProps: TComponentProps;
3
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -4,6 +4,8 @@ import { IHidingInputElement } from '../IHidingInputElement';
4
4
  import { ILoadingInputElement } from '../ILoadingInputElement';
5
5
  import { IValueInputElement } from '../IValueInputElement';
6
6
  import { InvalidValueChangeSubscription, ValueChangeSubscription } from '../Subscriptions';
7
+ import { IDynamicProps } from './IDynamicProps';
8
+ import { IOperativeProps } from './IOperativeProps';
7
9
  import { ISingleValueInputElementProps } from './ISingleValueInputElementProps';
8
10
  export interface ISingleValueInputElement<TValue, TComponentProps = unknown, TDynamicProps = unknown> extends IValueInputElement<TValue>, IChangingInputElement<TValue>, IHidingInputElement, ILoadingInputElement {
9
11
  /**
@@ -13,7 +15,7 @@ export interface ISingleValueInputElement<TValue, TComponentProps = unknown, TDy
13
15
  *
14
16
  * @see React.Component
15
17
  */
16
- readonly componentToRender: React.ComponentType<ISingleValueInputElementProps<TValue> & TComponentProps & TDynamicProps>;
18
+ readonly componentToRender: React.ComponentType<ISingleValueInputElementProps<TValue> & IOperativeProps<TComponentProps> & IDynamicProps<TDynamicProps>>;
17
19
  /**
18
20
  * A property containing all additional props that the rendered component needs.
19
21
  * They should be initialized before the 'render' method is ever called (the best way of doing that is by passing them into the constructor).
@@ -22,5 +24,6 @@ export interface ISingleValueInputElement<TValue, TComponentProps = unknown, TDy
22
24
  getDynamicProps(): TDynamicProps;
23
25
  changeDynamicProps<K extends keyof TDynamicProps>(dynamicProps: Pick<TDynamicProps, K>): void;
24
26
  subscribeToValueChange(subscription: ValueChangeSubscription<TValue>): void;
25
- subscribeToInvalidValueChange(subscription: InvalidValueChangeSubscription<TValue>): void;
27
+ subscribeToInitialValueChange(subscription: ValueChangeSubscription<TValue>): void;
28
+ subscribeToInvalidValueChange(subscription: InvalidValueChangeSubscription): void;
26
29
  }
@@ -1,8 +1,12 @@
1
+ import { FormText } from '../Components';
2
+ export interface IInvalidationOptions {
3
+ errorMessage: FormText;
4
+ }
1
5
  export interface ISingleValueInputElementProps<TValue> {
2
6
  value: TValue;
3
- label: string;
7
+ label: FormText;
4
8
  renderRequiredIndicator: boolean;
5
- errorMessage: string;
9
+ errorMessage: FormText;
6
10
  onChange: (newValue: TValue) => void;
7
- invalidateInput: () => void;
11
+ invalidateInput: (options?: IInvalidationOptions) => void;
8
12
  }
@@ -1,7 +1,6 @@
1
- import { IBasePickerSuggestionsProps, IPersonaProps } from 'office-ui-fabric-react';
2
- import { IBaseInputElementDynamicProps } from '../IBaseInputElementDynamicProps';
1
+ import { IBasePickerSuggestionsProps, IPersonaProps } from '@fluentui/react';
3
2
  import { IBaseInputElementProps } from '../IBaseInputElementProps';
4
- export interface IIdentityPickerProps<TIdentity extends IPersonaProps = IPersonaProps> extends IBaseInputElementProps, IBaseInputElementDynamicProps {
3
+ export interface IIdentityPickerProps<TIdentity extends IPersonaProps = IPersonaProps> extends IBaseInputElementProps {
5
4
  onResolveSuggestions: (query: string, selectedItems?: TIdentity[]) => Promise<TIdentity[]>;
6
5
  getTextFromItem?: (item: TIdentity, currentValue?: string) => string;
7
6
  onEmptyResolveSuggestions?: (currentPersonas?: TIdentity[]) => Promise<TIdentity[]>;
@@ -1,7 +1,10 @@
1
+ import { IPersonaProps } from '@fluentui/react';
1
2
  import * as React from 'react';
2
- import { IPersonaProps } from 'office-ui-fabric-react';
3
- import { IIdentityPickerProps } from './IIdentityPickerProps';
3
+ import { IBaseInputElementDynamicProps } from '../IBaseInputElementDynamicProps';
4
+ import { IDynamicProps } from '../IDynamicProps';
5
+ import { IOperativeProps } from '../IOperativeProps';
4
6
  import { ISingleValueInputElementProps } from '../ISingleValueInputElementProps';
5
- export declare class IdentityPicker<TIdentity extends IPersonaProps = IPersonaProps> extends React.Component<IIdentityPickerProps<TIdentity> & ISingleValueInputElementProps<TIdentity[]>> {
7
+ import { IIdentityPickerProps } from './IIdentityPickerProps';
8
+ export declare class IdentityPicker<TIdentity extends IPersonaProps = IPersonaProps> extends React.Component<ISingleValueInputElementProps<TIdentity[]> & IOperativeProps<IIdentityPickerProps<TIdentity>> & IDynamicProps<IBaseInputElementDynamicProps>> {
6
9
  render(): JSX.Element;
7
10
  }
@@ -1,22 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.IdentityPicker = 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 IdentityPicker extends React.Component {
7
8
  render() {
8
- var _a;
9
9
  if (!this.props)
10
10
  return null;
11
+ const { dynamicProps, operativeProps } = this.props;
11
12
  return (React.createElement(React.Fragment, null,
12
- this.props.label && React.createElement(office_ui_fabric_react_1.Label, { required: this.props.renderRequiredIndicator }, this.props.label),
13
- React.createElement(office_ui_fabric_react_1.NormalPeoplePicker, { onResolveSuggestions: this.props.onResolveSuggestions, onEmptyResolveSuggestions: this.props.onEmptyResolveSuggestions, getTextFromItem: this.props.getTextFromItem, pickerSuggestionsProps: this.props.suggestionProps, onRemoveSuggestion: this.props.onRemoveSuggestion, onInputChange: this.props.onInputChange, resolveDelay: this.props.resolveDelay, itemLimit: this.props.itemLimit, disabled: this.props.isDisabled, defaultSelectedItems: this.props.value, inputProps: {
14
- required: this.props.renderRequiredIndicator,
15
- placeholder: !!this.props.value && this.props.value.length > 0 ? '' : this.props.placeholder
16
- }, onChange: (items) => {
17
- this.props.onChange(items);
18
- } }),
19
- !!((_a = this.props) === null || _a === void 0 ? void 0 : _a.errorMessage) && React.createElement(office_ui_fabric_react_1.MessageBar, { messageBarType: office_ui_fabric_react_1.MessageBarType.warning }, this.props.errorMessage)));
13
+ React.createElement(Components_1.LabelRenderer, { label: this.props.label, required: !!this.props.renderRequiredIndicator }),
14
+ React.createElement("div", { "data-automationid": "identity-picker" },
15
+ React.createElement(react_1.NormalPeoplePicker, { onResolveSuggestions: operativeProps.onResolveSuggestions, onEmptyResolveSuggestions: operativeProps.onEmptyResolveSuggestions, getTextFromItem: operativeProps.getTextFromItem, pickerSuggestionsProps: operativeProps.suggestionProps, onRemoveSuggestion: operativeProps.onRemoveSuggestion, onInputChange: operativeProps.onInputChange, resolveDelay: operativeProps.resolveDelay, itemLimit: operativeProps.itemLimit, disabled: dynamicProps.isDisabled, defaultSelectedItems: this.props.value, inputProps: {
16
+ required: this.props.renderRequiredIndicator,
17
+ placeholder: !!this.props.value && this.props.value.length > 0 ? '' : operativeProps.placeholder
18
+ }, onChange: (items) => {
19
+ this.props.onChange(items);
20
+ } })),
21
+ React.createElement(Components_1.ErrorRenderer, { error: this.props.errorMessage, messageBarType: react_1.MessageBarType.warning })));
20
22
  }
21
23
  }
22
24
  exports.IdentityPicker = IdentityPicker;
@@ -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("./IIdentityPickerProps"), exports);
@@ -1,29 +1,34 @@
1
1
  import * as React from 'react';
2
+ import { FormText } from '../../Components';
2
3
  import { IChangingPresentation, IDynamicPresentation, IPresentation, IRestrictedPresentation } from '../../Presentations';
4
+ import { IDynamicProps } from '../IDynamicProps';
5
+ import { IOperativeProps } from '../IOperativeProps';
3
6
  import { ISingleValueInputElementProps } from '../ISingleValueInputElementProps';
4
7
  interface ISingleValueInputElementWrapperState<TValue, TDynamicProps> {
5
8
  value: TValue;
6
- errorMessage: string;
9
+ errorMessage: FormText;
7
10
  isLoading: boolean;
8
11
  isVisible: boolean;
9
12
  dynamicProps: TDynamicProps;
10
13
  }
11
- export interface ISingleValueInputElementWrapperProps<TValue, TComponentProps extends ISingleValueInputElementProps<TValue>, TDynamicProps> {
12
- internalComponent: React.ComponentType<TComponentProps & TDynamicProps>;
13
- componentProps: TComponentProps;
14
+ export interface ISingleValueInputElementWrapperProps<TValue, TComponentProps, TDynamicProps> {
15
+ internalComponent: React.ComponentType<ISingleValueInputElementProps<TValue> & IOperativeProps<TComponentProps> & IDynamicProps<TDynamicProps>>;
16
+ inputProps: ISingleValueInputElementProps<TValue>;
17
+ operativeProps: TComponentProps;
14
18
  initialDynamicProps: TDynamicProps;
15
19
  isInitiallyLoading: boolean;
16
20
  isInitiallyVisible: boolean;
17
- renderLoadingIndicator(): JSX.Element;
21
+ loadingIndicator: React.ComponentType;
22
+ renderErrors: boolean;
18
23
  }
19
- export declare class SingleValueInputElementWrapper<TValue, TComponentProps extends ISingleValueInputElementProps<TValue>, TDynamicProps = unknown> extends React.Component<ISingleValueInputElementWrapperProps<TValue, TComponentProps, TDynamicProps>, ISingleValueInputElementWrapperState<TValue, TDynamicProps>> implements IPresentation, IChangingPresentation<TValue>, IRestrictedPresentation, IDynamicPresentation<TDynamicProps> {
20
- constructor(props: ISingleValueInputElementWrapperProps<TValue, TComponentProps, TDynamicProps>);
24
+ export declare class SingleValueInputElementWrapper<TValue, TComponentProps, TDynamicProps> extends React.Component<ISingleValueInputElementWrapperProps<TValue, TComponentProps, TDynamicProps>, ISingleValueInputElementWrapperState<TValue, TDynamicProps>> implements IPresentation, IChangingPresentation<TValue>, IRestrictedPresentation, IDynamicPresentation<TDynamicProps> {
25
+ constructor(props: ISingleValueInputElementWrapperProps<TValue, ISingleValueInputElementProps<TValue> & TComponentProps, TDynamicProps>);
21
26
  startLoading: () => void;
22
27
  stopLoading: () => void;
23
28
  hide: () => void;
24
29
  show: () => void;
25
30
  update: (newValue: TValue) => void;
26
- setError: (errorMessage: string) => void;
31
+ setError: (errorMessage: FormText) => void;
27
32
  changeDynamicProps: (dynamicProps: TDynamicProps) => void;
28
33
  render: () => JSX.Element;
29
34
  private renderInternalContent;
@@ -37,19 +37,24 @@ class SingleValueInputElementWrapper extends React.Component {
37
37
  this.setState({ dynamicProps: dynamicProps });
38
38
  };
39
39
  this.render = () => {
40
- return (React.createElement(Presentations_1.PresentationRenderer, { isVisible: this.state.isVisible, isLoading: this.state.isLoading, renderInternalContent: this.renderInternalContent, renderLoadingIndicator: this.props.renderLoadingIndicator }));
40
+ const { isVisible, isLoading } = this.state;
41
+ const { loadingIndicator } = this.props;
42
+ return (React.createElement(Presentations_1.PresentationRenderer, { isVisible: isVisible, isLoading: isLoading, renderInternalContent: this.renderInternalContent, loadingIndicator: loadingIndicator }));
41
43
  };
42
44
  this.renderInternalContent = () => {
43
- const { internalComponent: Component, componentProps } = this.props;
45
+ var _a;
46
+ const { internalComponent: Component, inputProps, operativeProps } = this.props;
44
47
  if (!Component)
45
48
  return null;
46
- return (React.createElement(Component, Object.assign({}, this.state.dynamicProps, componentProps, { value: this.state.value, errorMessage: this.state.errorMessage })));
49
+ const { renderErrors } = this.props;
50
+ const errorMessages = renderErrors ? this.state.errorMessage : null;
51
+ return (React.createElement(Component, Object.assign({ dynamicProps: (_a = this.state.dynamicProps) !== null && _a !== void 0 ? _a : {}, operativeProps: operativeProps }, inputProps, { value: this.state.value, errorMessage: errorMessages })));
47
52
  };
48
53
  this.state = {
49
54
  isLoading: props.isInitiallyLoading,
50
55
  isVisible: props.isInitiallyVisible,
51
- errorMessage: (_a = props.componentProps) === null || _a === void 0 ? void 0 : _a.errorMessage,
52
- value: (_b = props.componentProps) === null || _b === void 0 ? void 0 : _b.value,
56
+ errorMessage: (_a = props.inputProps) === null || _a === void 0 ? void 0 : _a.errorMessage,
57
+ value: (_b = props.inputProps) === null || _b === void 0 ? void 0 : _b.value,
53
58
  dynamicProps: props.initialDynamicProps
54
59
  };
55
60
  }
@@ -1,6 +1,5 @@
1
- import { IBaseInputElementDynamicProps } from '../IBaseInputElementDynamicProps';
2
1
  import { IBaseInputElementProps } from '../IBaseInputElementProps';
3
- export interface INumberInputProps extends IBaseInputElementProps, IBaseInputElementDynamicProps {
2
+ export interface INumberInputProps extends IBaseInputElementProps {
4
3
  handleDecimalValues?: boolean;
5
4
  min?: number;
6
5
  max?: number;
@@ -1,11 +1,15 @@
1
1
  import * as React from 'react';
2
+ import { FormText } from '../../Components';
3
+ import { IBaseInputElementDynamicProps } from '../IBaseInputElementDynamicProps';
4
+ import { IDynamicProps } from '../IDynamicProps';
5
+ import { IOperativeProps } from '../IOperativeProps';
2
6
  import { ISingleValueInputElementProps } from '../ISingleValueInputElementProps';
3
7
  import { INumberInputProps } from './INumberInputProps';
4
8
  interface INumberInputState {
5
9
  intermediateValue: string;
6
- customWarning: string;
10
+ customWarning: FormText;
7
11
  }
8
- export declare class NumberInput extends React.Component<ISingleValueInputElementProps<number> & INumberInputProps, INumberInputState> {
12
+ export declare class NumberInput extends React.Component<ISingleValueInputElementProps<number> & IOperativeProps<INumberInputProps> & IDynamicProps<IBaseInputElementDynamicProps>, INumberInputState> {
9
13
  state: INumberInputState;
10
14
  render(): JSX.Element;
11
15
  private handleUserInput;