@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.
Files changed (110) 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.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 +9 -4
  50. package/lib/SingleValueInputElements/DropdownInputElement/DropdownInput.js +24 -30
  51. package/lib/SingleValueInputElements/DropdownInputElement/IDropdownInputProps.d.ts +2 -2
  52. package/lib/SingleValueInputElements/DropdownInputElement/IFluentUiDropdownInputProps.d.ts +5 -0
  53. package/lib/SingleValueInputElements/DropdownInputElement/IFluentUiDropdownInputProps.js +2 -0
  54. package/lib/SingleValueInputElements/DropdownInputElement/MultiValueDropdownInput.d.ts +4 -2
  55. package/lib/SingleValueInputElements/DropdownInputElement/MultiValueDropdownInput.js +29 -19
  56. package/lib/SingleValueInputElements/DropdownInputElement/index.d.ts +1 -1
  57. package/lib/SingleValueInputElements/DropdownInputElement/index.js +2 -2
  58. package/lib/SingleValueInputElements/IBaseInputElementDynamicProps.d.ts +1 -1
  59. package/lib/SingleValueInputElements/IDynamicProps.d.ts +3 -0
  60. package/lib/SingleValueInputElements/IDynamicProps.js +2 -0
  61. package/lib/SingleValueInputElements/IOperativeProps.d.ts +3 -0
  62. package/lib/SingleValueInputElements/IOperativeProps.js +2 -0
  63. package/lib/SingleValueInputElements/ISingleValueInputElement.d.ts +5 -2
  64. package/lib/SingleValueInputElements/ISingleValueInputElementProps.d.ts +7 -3
  65. package/lib/SingleValueInputElements/IdentityPickerInputElement/IIdentityPickerProps.d.ts +2 -3
  66. package/lib/SingleValueInputElements/IdentityPickerInputElement/IdentityPicker.d.ts +6 -3
  67. package/lib/SingleValueInputElements/IdentityPickerInputElement/IdentityPicker.js +12 -10
  68. package/lib/SingleValueInputElements/IdentityPickerInputElement/index.js +1 -1
  69. package/lib/SingleValueInputElements/InternalPresentationComponents/SingleValueInputElementWrapper.d.ts +13 -8
  70. package/lib/SingleValueInputElements/InternalPresentationComponents/SingleValueInputElementWrapper.js +10 -5
  71. package/lib/SingleValueInputElements/NumberInputElement/INumberInputProps.d.ts +1 -2
  72. package/lib/SingleValueInputElements/NumberInputElement/NumberInput.d.ts +6 -2
  73. package/lib/SingleValueInputElements/NumberInputElement/NumberInput.js +34 -35
  74. package/lib/SingleValueInputElements/NumberInputElement/index.js +1 -1
  75. package/lib/SingleValueInputElements/SingleValueInputElement.d.ts +12 -8
  76. package/lib/SingleValueInputElements/SingleValueInputElement.js +35 -9
  77. package/lib/SingleValueInputElements/TextInputElement/EmptyValidationRules.d.ts +2 -1
  78. package/lib/SingleValueInputElements/TextInputElement/ITextInputProps.d.ts +1 -2
  79. package/lib/SingleValueInputElements/TextInputElement/LengthValidationRules.d.ts +3 -2
  80. package/lib/SingleValueInputElements/TextInputElement/LongTextInput.d.ts +4 -1
  81. package/lib/SingleValueInputElements/TextInputElement/LongTextInput.js +9 -5
  82. package/lib/SingleValueInputElements/TextInputElement/PathValidationRules.d.ts +2 -1
  83. package/lib/SingleValueInputElements/TextInputElement/TextInput.d.ts +4 -1
  84. package/lib/SingleValueInputElements/TextInputElement/TextInput.js +8 -5
  85. package/lib/SingleValueInputElements/TextInputElement/index.js +1 -1
  86. package/lib/SingleValueInputElements/TimePickerInputElement/ITimePickerProps.d.ts +3 -2
  87. package/lib/SingleValueInputElements/TimePickerInputElement/TimePicker.d.ts +6 -1
  88. package/lib/SingleValueInputElements/TimePickerInputElement/TimePicker.js +16 -7
  89. package/lib/SingleValueInputElements/TimePickerInputElement/TimePicker.less +28 -0
  90. package/lib/SingleValueInputElements/TimePickerInputElement/index.js +1 -1
  91. package/lib/SingleValueInputElements/index.d.ts +2 -0
  92. package/lib/SingleValueInputElements/index.js +3 -1
  93. package/lib/Subscriptions/ValueChangeSubscription.d.ts +2 -2
  94. package/lib/Subscriptions/index.js +1 -1
  95. package/lib/Utilities/DropdownHelper.d.ts +1 -1
  96. package/lib/Utilities/DropdownHelper.js +7 -6
  97. package/lib/Utilities/FormHelper.js +8 -2
  98. package/lib/Utilities/InputElementsBuilding.d.ts +13 -0
  99. package/lib/Utilities/InputElementsBuilding.js +18 -0
  100. package/lib/Utilities/index.d.ts +1 -0
  101. package/lib/Utilities/index.js +2 -1
  102. package/lib/index.d.ts +1 -0
  103. package/lib/index.js +2 -1
  104. package/package.json +42 -40
  105. package/lib/SingleValueInputElements/DependentInputElement/DependentInputElementInitializer.d.ts +0 -0
  106. package/lib/SingleValueInputElements/DependentInputElement/DependentInputElementInitializer.js +0 -51
  107. package/lib/SingleValueInputElements/DependentInputElement/index.d.ts +0 -0
  108. package/lib/SingleValueInputElements/DependentInputElement/index.js +0 -1
  109. package/lib/SingleValueInputElements/DropdownInputElement/DropdownInputElement.d.ts +0 -11
  110. package/lib/SingleValueInputElements/DropdownInputElement/DropdownInputElement.js +0 -33
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DropdownHelper = void 0;
4
- const office_ui_fabric_react_1 = require("office-ui-fabric-react");
4
+ const react_1 = require("@fluentui/react");
5
5
  const SingleValueInputElements_1 = require("../SingleValueInputElements");
6
6
  class DropdownHelper {
7
7
  static getNormalizedOptions(defaultOption, allOptions) {
@@ -14,7 +14,7 @@ class DropdownHelper {
14
14
  allOptions.forEach((o) => {
15
15
  if (!o)
16
16
  return;
17
- const newOption = Object.assign(Object.assign({}, DropdownHelper.toNormalizedDropdownOption(o)), { selected: false });
17
+ const newOption = this.toNormalizedDropdownOption(o);
18
18
  options.push(newOption);
19
19
  });
20
20
  return options;
@@ -40,19 +40,20 @@ DropdownHelper.toNormalizedDropdownOption = (inputOption) => {
40
40
  if (inputOption.type !== undefined) {
41
41
  switch (inputOption.type) {
42
42
  case SingleValueInputElements_1.DropdownOptionType.Normal:
43
- itemType = office_ui_fabric_react_1.SelectableOptionMenuItemType.Normal;
43
+ itemType = react_1.SelectableOptionMenuItemType.Normal;
44
44
  break;
45
45
  case SingleValueInputElements_1.DropdownOptionType.Divider:
46
- itemType = office_ui_fabric_react_1.SelectableOptionMenuItemType.Divider;
46
+ itemType = react_1.SelectableOptionMenuItemType.Divider;
47
47
  break;
48
48
  case SingleValueInputElements_1.DropdownOptionType.Header:
49
- itemType = office_ui_fabric_react_1.SelectableOptionMenuItemType.Header;
49
+ itemType = react_1.SelectableOptionMenuItemType.Header;
50
50
  break;
51
51
  }
52
52
  }
53
53
  return {
54
54
  text: inputOption.text,
55
55
  key: inputOption.key,
56
- itemType: itemType
56
+ itemType: itemType,
57
+ disabled: !!inputOption.disabled
57
58
  };
58
59
  };
@@ -8,8 +8,14 @@ function getFormState(inputs) {
8
8
  let hasChanges = false;
9
9
  let index = 0;
10
10
  while ((isValid || !hasChanges) && index < inputs.length) {
11
- isValid = isValid && inputs[index].isValid;
12
- hasChanges = hasChanges || inputs[index].hasChanges;
11
+ const currentInput = inputs[index];
12
+ if (!currentInput) {
13
+ isValid = false;
14
+ }
15
+ else {
16
+ isValid = isValid && currentInput.isValid;
17
+ hasChanges = hasChanges || currentInput.hasChanges;
18
+ }
13
19
  index++;
14
20
  }
15
21
  return {
@@ -0,0 +1,13 @@
1
+ import * as React from 'react';
2
+ import { UpdateCallback } from '../IInputElement';
3
+ import { ValidationRule } from '../IValueInputElement';
4
+ import { IDynamicProps, IOperativeProps, ISingleValueInputElement, ISingleValueInputElementConfiguration, ISingleValueInputElementProps } from '../SingleValueInputElements';
5
+ declare class InputElementBuilder<TValue> {
6
+ private readonly _config;
7
+ private readonly _updateCallback;
8
+ private readonly _validationRules;
9
+ constructor(config: ISingleValueInputElementConfiguration<TValue>, updateCallback: UpdateCallback, validationRules: ValidationRule<TValue>[]);
10
+ materialize<TComponentProps, TDynamicProps>(component: React.ComponentType<ISingleValueInputElementProps<TValue> & IDynamicProps<TDynamicProps> & IOperativeProps<TComponentProps>>, props: TComponentProps): ISingleValueInputElement<TValue, TComponentProps, TDynamicProps>;
11
+ }
12
+ export declare function prepareInputElement<TValue>(config: ISingleValueInputElementConfiguration<TValue>, updateCallback: UpdateCallback, ...validationRules: ValidationRule<TValue>[]): InputElementBuilder<TValue>;
13
+ export {};
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.prepareInputElement = void 0;
4
+ const SingleValueInputElements_1 = require("../SingleValueInputElements");
5
+ class InputElementBuilder {
6
+ constructor(config, updateCallback, validationRules) {
7
+ this._config = config;
8
+ this._updateCallback = updateCallback;
9
+ this._validationRules = validationRules;
10
+ }
11
+ materialize(component, props) {
12
+ return new SingleValueInputElements_1.SingleValueInputElement(this._config, component, props, this._updateCallback, ...this._validationRules);
13
+ }
14
+ }
15
+ function prepareInputElement(config, updateCallback, ...validationRules) {
16
+ return new InputElementBuilder(config, updateCallback, validationRules);
17
+ }
18
+ exports.prepareInputElement = prepareInputElement;
@@ -1,4 +1,5 @@
1
1
  export * from './DropdownHelper';
2
2
  export * from './FormHelper';
3
+ export * from './InputElementsBuilding';
3
4
  export * from './StylingHelper';
4
5
  export * from './TypingHelper';
@@ -7,10 +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("./DropdownHelper"), exports);
14
14
  __exportStar(require("./FormHelper"), exports);
15
+ __exportStar(require("./InputElementsBuilding"), exports);
15
16
  __exportStar(require("./StylingHelper"), exports);
16
17
  __exportStar(require("./TypingHelper"), exports);
package/lib/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './Components';
1
2
  export * from './ExtendedInputElement';
2
3
  export * from './IChangingInputElement';
3
4
  export * from './IHidingInputElement';
package/lib/index.js CHANGED
@@ -7,9 +7,10 @@ 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
+ __exportStar(require("./Components"), exports);
13
14
  __exportStar(require("./ExtendedInputElement"), exports);
14
15
  __exportStar(require("./IChangingInputElement"), exports);
15
16
  __exportStar(require("./IHidingInputElement"), exports);
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@try-at-software/input-elements",
3
- "version": "1.2.0-aplha.6",
3
+ "version": "1.2.0-beta.3",
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",
7
7
  "scripts": {
8
- "start-dev": "npm run lint && webpack-dev-server --mode development --open",
8
+ "start-dev": "npm run lint && webpack serve --mode development --open",
9
9
  "lint": ".\\node_modules\\.bin\\eslint \"./src/**/*.{js,jsx,ts,tsx}\" && prettier --check \"src/**/*.{ts,tsx,js,jsx,css,less,json}\"",
10
10
  "fix-code-style": "prettier --write \"src/**/*.{ts,tsx,js,jsx,css,less,json}\"",
11
11
  "test": "jest",
@@ -21,9 +21,9 @@
21
21
  },
22
22
  "repository": {
23
23
  "type": "git",
24
- "url": "https://dev.azure.com/TryAtSoftware/InputElements"
24
+ "url": "https://github.com/TryAtSoftware/InputElements"
25
25
  },
26
- "homepage": "https://dev.azure.com/TryAtSoftware/InputElements",
26
+ "homepage": "https://github.com/TryAtSoftware/InputElements",
27
27
  "files": [
28
28
  "lib/**/*"
29
29
  ],
@@ -34,44 +34,46 @@
34
34
  "validation"
35
35
  ],
36
36
  "author": "Tony Troeff",
37
- "license": "ISC",
37
+ "license": "MIT",
38
38
  "devDependencies": {
39
- "@types/enzyme": "^3.10.5",
40
- "@types/enzyme-adapter-react-16": "^1.0.6",
41
- "@types/jest": "^26.0.8",
42
- "@types/react": "^16.9.44",
43
- "@types/react-beautiful-dnd": "^13.0.0",
44
- "@types/react-dom": "^16.9.8",
45
- "@typescript-eslint/eslint-plugin": "^3.7.1",
46
- "@typescript-eslint/parser": "^3.7.1",
47
- "awesome-typescript-loader": "^5.2.1",
48
- "copyfiles": "^2.3.0",
49
- "css-loader": "^4.2.0",
50
- "enzyme": "^3.11.0",
51
- "enzyme-adapter-react-16": "^1.15.2",
52
- "eslint": "^7.6.0",
53
- "eslint-config-prettier": "^6.11.0",
54
- "eslint-loader": "^4.0.2",
55
- "eslint-plugin-prettier": "^3.1.4",
56
- "eslint-plugin-react": "^7.20.5",
57
- "html-webpack-plugin": "^4.3.0",
58
- "jest": "^26.2.2",
59
- "jest-each": "^26.2.0",
60
- "less-loader": "^6.2.0",
61
- "prettier": "^2.0.5",
62
- "react-dom": "^16.13.1",
63
- "rimraf": "^3.0.2",
64
- "source-map-loader": "^1.0.1",
65
- "style-loader": "^1.2.1",
66
- "ts-jest": "^26.1.4",
67
- "typescript": "^3.9.7",
68
- "webpack": "^4.44.1",
69
- "webpack-cli": "^3.3.12",
70
- "webpack-dev-server": "^3.11.0"
39
+ "@testing-library/react": "12.1.4",
40
+ "@types/enzyme": "3.10.12",
41
+ "@types/enzyme-adapter-react-16": "1.0.6",
42
+ "@types/jest": "27.4.1",
43
+ "@types/react": "16.9.0",
44
+ "@types/react-beautiful-dnd": "13.1.2",
45
+ "@types/react-dom": "16.9.0",
46
+ "@typescript-eslint/eslint-plugin": "5.18.0",
47
+ "@typescript-eslint/parser": "5.18.0",
48
+ "copyfiles": "2.4.1",
49
+ "css-loader": "6.7.1",
50
+ "eslint": "8.13.0",
51
+ "eslint-config-prettier": "8.5.0",
52
+ "eslint-plugin-prettier": "4.0.0",
53
+ "eslint-plugin-react": "7.29.4",
54
+ "html-webpack-plugin": "5.5.0",
55
+ "jest": "27.5.1",
56
+ "jest-each": "27.5.1",
57
+ "less": "4.1.2",
58
+ "less-loader": "10.2.0",
59
+ "@fluentui/react": "8.41.0",
60
+ "prettier": "2.6.2",
61
+ "react": "16.9.0",
62
+ "react-dom": "16.9.0",
63
+ "rimraf": "3.0.2",
64
+ "style-loader": "3.3.1",
65
+ "ts-jest": "27.1.4",
66
+ "ts-loader": "9.2.8",
67
+ "typescript": "4.3.2",
68
+ "webpack": "5.72.0",
69
+ "webpack-cli": "4.9.2",
70
+ "webpack-dev-server": "4.8.1"
71
71
  },
72
72
  "dependencies": {
73
- "office-ui-fabric-react": "^7.124.1",
74
- "react": "^16.13.1",
75
- "react-beautiful-dnd": "^13.0.0"
73
+ "react-beautiful-dnd": "13.1.0"
74
+ },
75
+ "peerDependencies": {
76
+ "@fluentui/react": ">=7.179.1",
77
+ "react": ">=16.9.0"
76
78
  }
77
79
  }
@@ -1,51 +0,0 @@
1
- // import { ISingleValueInputElement } from '../ISingleValueInputElement';
2
- // import { UpdateType } from '../../UpdateType';
3
- //
4
- // export class DependentInputElementInitializer {
5
- // public static initializeDependency<TDependent, TPrincipal, TDependentProps = unknown, TPrincipalProps = unknown>(
6
- // principal: ISingleValueInputElement<TPrincipal, TPrincipalProps>,
7
- // dependent: ISingleValueInputElement<TDependent, TDependentProps>,
8
- // onPrincipalValueChanged: (newValue: TPrincipal, doneCallback: () => void) => void,
9
- // handleFalsyPrincipalValue?: () => void,
10
- // handleInitialRender?: () => void
11
- // ): void {
12
- // if (!dependent || !principal || !onPrincipalValueChanged) return;
13
- //
14
- // // If the dependent input element is required, this means that the principal should be required as well.
15
- // if (!!dependent.configuration?.isRequired) {
16
- // if (!principal.configuration) principal.configuration = { isRequired: true };
17
- // else principal.configuration.isRequired = true;
18
- // }
19
- //
20
- // const originalUpdateFunction = principal.update;
21
- // principal.update = (updateType: UpdateType): void => {
22
- // if (!!originalUpdateFunction) originalUpdateFunction(updateType);
23
- //
24
- // if (updateType === UpdateType.System) {
25
- // // Handle the system events - loading/ hiding an input element.
26
- // if (principal.isLoading || !principal.isVisible) dependent.hide();
27
- // else dependent.show();
28
- // } else {
29
- // dependent.resetValue();
30
- // if (!!principal.value === false) {
31
- // // If the falsy value is handled explicitly, execute that callback.
32
- // // In every other case, hide the dependent component.
33
- // if (!!handleFalsyPrincipalValue) handleFalsyPrincipalValue();
34
- // else if (dependent.isVisible) dependent.hide();
35
- // } else {
36
- // // Ensure that the dependent input element is visible.
37
- // if (!dependent.isVisible) dependent.show();
38
- //
39
- // dependent.load((finish: () => void): void => {
40
- // onPrincipalValueChanged(principal.value, finish);
41
- // });
42
- // }
43
- // }
44
- // };
45
- //
46
- // // If a callback to handle the initial render is passed, execute it.
47
- // // Else, hide the input element.
48
- // if (!!handleInitialRender) handleInitialRender();
49
- // else dependent.hide();
50
- // }
51
- // }
@@ -1 +0,0 @@
1
- // export * from './DependentInputElementInitializer';
@@ -1,11 +0,0 @@
1
- import { UpdateCallback } from '../../IInputElement';
2
- import { ValidationRule } from '../../IValueInputElement';
3
- import { IBaseInputElementProps } from '../IBaseInputElementProps';
4
- import { ISingleValueInputElementConfiguration } from '../ISingleInputElementConfiguration';
5
- import { SingleValueInputElement } from '../SingleValueInputElement';
6
- import { IDropdownInputProps } from './IDropdownInputProps';
7
- export declare class DropdownInputElement extends SingleValueInputElement<string, IBaseInputElementProps, IDropdownInputProps> {
8
- constructor(config: ISingleValueInputElementConfiguration<string>, props: IBaseInputElementProps, update: UpdateCallback, ...validationRules: ValidationRule<string>[]);
9
- private static consistencyErrorMessage;
10
- private getConsistencyValidationRule;
11
- }
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DropdownInputElement = void 0;
4
- const SingleValueInputElement_1 = require("../SingleValueInputElement");
5
- const DropdownInput_1 = require("./DropdownInput");
6
- class DropdownInputElement extends SingleValueInputElement_1.SingleValueInputElement {
7
- constructor(config, props, update, ...validationRules) {
8
- super(config, DropdownInput_1.DropdownInput, props, update, ...validationRules);
9
- this.validationRules.push(this.getConsistencyValidationRule());
10
- }
11
- getConsistencyValidationRule() {
12
- return (newValue) => {
13
- const dynamicProps = this.getDynamicProps();
14
- if (!dynamicProps)
15
- return DropdownInputElement.consistencyErrorMessage;
16
- const allOptions = [];
17
- if (dynamicProps.defaultOption)
18
- allOptions.push(dynamicProps.defaultOption);
19
- if (dynamicProps.options && Array.isArray(dynamicProps.options)) {
20
- dynamicProps.options.forEach((o) => {
21
- if (!o)
22
- return;
23
- allOptions.push(o);
24
- });
25
- }
26
- if (allOptions.some((o) => o.key === newValue))
27
- return null;
28
- return DropdownInputElement.consistencyErrorMessage;
29
- };
30
- }
31
- }
32
- exports.DropdownInputElement = DropdownInputElement;
33
- DropdownInputElement.consistencyErrorMessage = 'The value is not present within the specified options.';