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

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.
@@ -6,6 +6,7 @@ const React = require("react");
6
6
  const react_2 = require("react");
7
7
  const Components_1 = require("../../Components");
8
8
  const Utilities_1 = require("../../Utilities");
9
+ // TODO: This is a temporary solution. Accept FormText value from the operative props instead.
9
10
  const ConsistencyErrorMessage = 'The value is not present within the specified options.';
10
11
  const DropdownInputComponent = (props) => {
11
12
  var _a;
@@ -18,9 +19,15 @@ const DropdownInputComponent = (props) => {
18
19
  props.invalidateInput(invalidationOptions);
19
20
  }, [props.value, normalizedOptions, props.consistencyErrorMessage, props.invalidateInput]);
20
21
  const DropdownComponent = react_2.useMemo(() => { var _a; return (_a = dynamicProps.dropdownComponent) !== null && _a !== void 0 ? _a : react_1.Dropdown; }, [dynamicProps.dropdownComponent]);
22
+ const onChange = react_2.useCallback((_event, option) => !!props.onChange && props.onChange(option.id), [props.onChange]);
23
+ const onRenderOption = react_2.useCallback((option, defaultRender) => {
24
+ if (!dynamicProps.renderOption)
25
+ return defaultRender(option);
26
+ return dynamicProps.renderOption(option.id);
27
+ }, []);
21
28
  return (React.createElement(React.Fragment, null,
22
29
  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,
30
+ React.createElement(DropdownComponent, { "data-automationid": "dropdown-input", options: normalizedOptions, onChange: onChange, onRenderOption: onRenderOption, placeholder: operativeProps.placeholder,
24
31
  // This value should never be `undefined`.
25
32
  selectedKey: props.value || ((_a = dynamicProps.defaultOption) === null || _a === void 0 ? void 0 : _a.key) || null, disabled: dynamicProps.isDisabled }),
26
33
  React.createElement(Components_1.ErrorRenderer, { error: props.errorMessage, messageBarType: react_1.MessageBarType.error })));
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { IBaseInputElementDynamicProps } from '../IBaseInputElementDynamicProps';
2
3
  import { IDropdownInputOption } from './IDropdownInputOption';
3
4
  export interface IDropdownInputProps extends IBaseInputElementDynamicProps {
@@ -6,4 +7,5 @@ export interface IDropdownInputProps extends IBaseInputElementDynamicProps {
6
7
  * The default option for the dropdown.
7
8
  */
8
9
  defaultOption: IDropdownInputOption;
10
+ renderOption?: (optionId: string) => JSX.Element;
9
11
  }
@@ -53,6 +53,7 @@ DropdownHelper.toNormalizedDropdownOption = (inputOption) => {
53
53
  return {
54
54
  text: inputOption.text,
55
55
  key: inputOption.key,
56
+ id: inputOption.key,
56
57
  itemType: itemType,
57
58
  disabled: !!inputOption.disabled
58
59
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@try-at-software/input-elements",
3
- "version": "1.2.0-beta.5",
3
+ "version": "1.2.0-beta.6",
4
4
  "description": "A package providing different input elements that are extensible and easily configurable for your custom needs.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",