@trackunit/react-form-components 0.0.277-alpha-b966be6066.0 → 0.0.277

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.
package/index.cjs.js CHANGED
@@ -2227,6 +2227,14 @@ const UrlField = React.forwardRef((_a, ref) => {
2227
2227
  return (jsxRuntime.jsx(FormGroup, { htmlFor: htmlForId, label: label, tip: tip, isInvalid: renderAsInvalid, helpText: renderAsInvalid ? errorMessage : helpText, helpAddon: helpAddon, disabled: rest.disabled, dataTestId: dataTestId && `${dataTestId}-FormGroup`, children: jsxRuntime.jsx(UrlInput, Object.assign({ id: htmlForId, "aria-labelledby": htmlForId + "-label", ref: ref, value: value || defaultValue, isInvalid: renderAsInvalid, disabled: rest.disabled }, rest, { className: className, dataTestId: dataTestId })) }));
2228
2228
  });
2229
2229
 
2230
+ /**
2231
+ * A utility function to get the error message from a FieldError object.
2232
+ * This handles the case where the field is required and the u-ser has not entered a value.
2233
+ */
2234
+ const errorMessageFromFieldError = (cannotBeEmptyMessage, error) => {
2235
+ return (error === null || error === void 0 ? void 0 : error.message) || (error === null || error === void 0 ? void 0 : error.type) === "required" ? cannotBeEmptyMessage : undefined;
2236
+ };
2237
+
2230
2238
  /*
2231
2239
  * ----------------------------
2232
2240
  * | SETUP TRANSLATIONS START |
@@ -2297,6 +2305,7 @@ exports.cvaSelectMenu = cvaSelectMenu;
2297
2305
  exports.cvaSelectMenuList = cvaSelectMenuList;
2298
2306
  exports.cvaSelectPrefix = cvaSelectPrefix;
2299
2307
  exports.cvaSelectXIcon = cvaSelectXIcon;
2308
+ exports.errorMessageFromFieldError = errorMessageFromFieldError;
2300
2309
  exports.getCountryAbbreviation = getCountryAbbreviation;
2301
2310
  exports.getOrderedOptions = getOrderedOptions;
2302
2311
  exports.getPhoneNumberWithPlus = getPhoneNumberWithPlus;
package/index.esm.js CHANGED
@@ -2197,6 +2197,14 @@ const UrlField = forwardRef((_a, ref) => {
2197
2197
  return (jsx(FormGroup, { htmlFor: htmlForId, label: label, tip: tip, isInvalid: renderAsInvalid, helpText: renderAsInvalid ? errorMessage : helpText, helpAddon: helpAddon, disabled: rest.disabled, dataTestId: dataTestId && `${dataTestId}-FormGroup`, children: jsx(UrlInput, Object.assign({ id: htmlForId, "aria-labelledby": htmlForId + "-label", ref: ref, value: value || defaultValue, isInvalid: renderAsInvalid, disabled: rest.disabled }, rest, { className: className, dataTestId: dataTestId })) }));
2198
2198
  });
2199
2199
 
2200
+ /**
2201
+ * A utility function to get the error message from a FieldError object.
2202
+ * This handles the case where the field is required and the u-ser has not entered a value.
2203
+ */
2204
+ const errorMessageFromFieldError = (cannotBeEmptyMessage, error) => {
2205
+ return (error === null || error === void 0 ? void 0 : error.message) || (error === null || error === void 0 ? void 0 : error.type) === "required" ? cannotBeEmptyMessage : undefined;
2206
+ };
2207
+
2200
2208
  /*
2201
2209
  * ----------------------------
2202
2210
  * | SETUP TRANSLATIONS START |
@@ -2206,4 +2214,4 @@ const UrlField = forwardRef((_a, ref) => {
2206
2214
  */
2207
2215
  setupLibraryTranslations();
2208
2216
 
2209
- export { ActionButton, BaseInput, Checkbox, CreatableSelect, DateField, DateInput, DropZone, EMAIL_REGEX, EmailField, EmailInput, FormGroup, Label, MultiSelectMenuItem, NumberField, NumberInput, OptionCard, PasswordField, PasswordInput, PhoneField, PhoneInput, RadioGroup, RadioItem, Schedule, ScheduleVariant, Search, Select, SingleSelectMenuItem, TextArea, TextAreaField, TextField, TextInput, TimeRange, TimeRangeField, Toggle, UploadField, UploadInput, UrlField, UrlInput, checkIfPhoneNumberHasPlus, countryCodeToFlagEmoji, cvaInput, cvaInputAddon, cvaInputAddonAfter, cvaInputAddonBefore, cvaInputBase, cvaInputBaseDisabled, cvaInputBaseInvalid, cvaInputField, cvaInputPrefix, cvaInputSuffix, cvaSelect, cvaSelectCounter, cvaSelectDynamicTagContainer, cvaSelectIcon, cvaSelectMenu, cvaSelectMenuList, cvaSelectPrefix, cvaSelectXIcon, getCountryAbbreviation, getOrderedOptions, getPhoneNumberWithPlus, isInvalidCountryCode, isInvalidPhoneNumber, isMultiValue, parseSchedule, serializeSchedule, useCustomComponents, usePhoneInput, validateEmailAddress, validatePhoneNumber, weekDay };
2217
+ export { ActionButton, BaseInput, Checkbox, CreatableSelect, DateField, DateInput, DropZone, EMAIL_REGEX, EmailField, EmailInput, FormGroup, Label, MultiSelectMenuItem, NumberField, NumberInput, OptionCard, PasswordField, PasswordInput, PhoneField, PhoneInput, RadioGroup, RadioItem, Schedule, ScheduleVariant, Search, Select, SingleSelectMenuItem, TextArea, TextAreaField, TextField, TextInput, TimeRange, TimeRangeField, Toggle, UploadField, UploadInput, UrlField, UrlInput, checkIfPhoneNumberHasPlus, countryCodeToFlagEmoji, cvaInput, cvaInputAddon, cvaInputAddonAfter, cvaInputAddonBefore, cvaInputBase, cvaInputBaseDisabled, cvaInputBaseInvalid, cvaInputField, cvaInputPrefix, cvaInputSuffix, cvaSelect, cvaSelectCounter, cvaSelectDynamicTagContainer, cvaSelectIcon, cvaSelectMenu, cvaSelectMenuList, cvaSelectPrefix, cvaSelectXIcon, errorMessageFromFieldError, getCountryAbbreviation, getOrderedOptions, getPhoneNumberWithPlus, isInvalidCountryCode, isInvalidPhoneNumber, isMultiValue, parseSchedule, serializeSchedule, useCustomComponents, usePhoneInput, validateEmailAddress, validatePhoneNumber, weekDay };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-form-components",
3
- "version": "0.0.277-alpha-b966be6066.0",
3
+ "version": "0.0.277",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
package/src/index.d.ts CHANGED
@@ -34,4 +34,5 @@ export * from "./components/UploadInput/UploadInput";
34
34
  export * from "./components/UrlField/UrlField";
35
35
  export * from "./components/UrlInput/UrlInput";
36
36
  export * from "./utilities/emailUtils";
37
+ export * from "./utilities/formErrorMessageUtils";
37
38
  export * from "./utilities/usePhoneInput";
@@ -0,0 +1,8 @@
1
+ /**
2
+ * A utility function to get the error message from a FieldError object.
3
+ * This handles the case where the field is required and the u-ser has not entered a value.
4
+ */
5
+ export declare const errorMessageFromFieldError: (cannotBeEmptyMessage: string, error?: {
6
+ message?: string;
7
+ type?: string;
8
+ }) => string | undefined;