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

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.
@@ -3,12 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LabelRenderer = void 0;
4
4
  const React = require("react");
5
5
  const react_1 = require("@fluentui/react");
6
+ const FormTextRenderer_1 = require("./FormTextRenderer");
6
7
  const LabelRendererComponent = (props) => {
7
8
  if (!props)
8
9
  return null;
9
10
  const { label, required } = props;
10
11
  if (!label)
11
12
  return null;
12
- return React.createElement(react_1.Label, { required: required }, label);
13
+ return (React.createElement(react_1.Label, { required: required },
14
+ React.createElement(FormTextRenderer_1.FormTextRenderer, { text: label })));
13
15
  };
14
16
  exports.LabelRenderer = React.memo(LabelRendererComponent);
@@ -22,7 +22,7 @@ const DropdownInputComponent = (props) => {
22
22
  React.createElement(Components_1.LabelRenderer, { label: props.label, required: !!props.renderRequiredIndicator }),
23
23
  React.createElement(DropdownComponent, { "data-automationid": "dropdown-input", options: normalizedOptions, onChange: (_event, option) => !!props.onChange && props.onChange(option.key), placeholder: operativeProps.placeholder,
24
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 }),
25
+ selectedKey: props.value || ((_a = dynamicProps.defaultOption) === null || _a === void 0 ? void 0 : _a.key) || null, disabled: dynamicProps.isDisabled }),
26
26
  React.createElement(Components_1.ErrorRenderer, { error: props.errorMessage, messageBarType: react_1.MessageBarType.error })));
27
27
  };
28
28
  exports.DropdownInput = React.memo(DropdownInputComponent);
@@ -86,11 +86,7 @@ class SingleValueInputElement extends ExtendedInputElement_1.ExtendedInputElemen
86
86
  }
87
87
  /** @inheritdoc */
88
88
  get isValid() {
89
- if (this._isInvalidated)
90
- return false;
91
- if (this.isLoading)
92
- return false;
93
- if (this.errorMessage && this.errorMessage.length > 0)
89
+ if (this._isInvalidated || this.isLoading || this.errorMessage)
94
90
  return false;
95
91
  return (!!this._configuration && !this._configuration.isRequired) || this._valueIsSet || this._initialValueIsSet;
96
92
  }
@@ -127,17 +123,20 @@ class SingleValueInputElement extends ExtendedInputElement_1.ExtendedInputElemen
127
123
  var _a, _b, _c, _d, _e;
128
124
  if (!!((_a = this._configuration) === null || _a === void 0 ? void 0 : _a.shouldExecuteValidation) && this._configuration.shouldExecuteValidation() === false)
129
125
  return;
130
- let errorMessage = null;
126
+ let errorMessage = undefined;
131
127
  if (((_b = this._configuration) === null || _b === void 0 ? void 0 : _b.isRequired) && !this.valueIsValid()) {
132
128
  // If a value is required but the input field is empty.
133
129
  errorMessage = ((_c = this._configuration) === null || _c === void 0 ? void 0 : _c.requiredValidationMessage) || `The field is required`;
134
130
  }
135
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)) {
136
132
  // If a value is provided.
137
- this.validationRules.forEach((rule) => {
138
- if (!errorMessage)
139
- errorMessage = rule(this.value);
140
- });
133
+ for (const validationRule of this.validationRules) {
134
+ const currentError = validationRule(this.value);
135
+ if (currentError) {
136
+ errorMessage = currentError;
137
+ break;
138
+ }
139
+ }
141
140
  }
142
141
  this.setError(errorMessage);
143
142
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@try-at-software/input-elements",
3
- "version": "1.2.0-beta.2",
3
+ "version": "1.2.0-beta.5",
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",