@x15ventures/x15-ui-library 3.15.0 → 3.16.0

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 (145) hide show
  1. package/dist/cjs/autoGenerated/libraryThemes.js +12 -12
  2. package/dist/cjs/autoGenerated/libraryThemes.js.map +1 -1
  3. package/dist/cjs/autoGenerated/libraryThemes.json +12 -12
  4. package/dist/cjs/components/design/dialog/Dialog.js +1 -1
  5. package/dist/cjs/components/design/dialog/Dialog.js.map +1 -1
  6. package/dist/cjs/components/design/headerBar/HeaderBar.js +3 -1
  7. package/dist/cjs/components/design/headerBar/HeaderBar.js.map +1 -1
  8. package/dist/cjs/components/design/headerBar/headerBar.css +6 -1
  9. package/dist/cjs/components/design/tooltip/Tooltip.js +67 -15
  10. package/dist/cjs/components/design/tooltip/Tooltip.js.map +1 -1
  11. package/dist/cjs/components/design/tooltip/tooltip.css +1 -1
  12. package/dist/cjs/components/form/formFields/formFieldWrapper/FormField.js +8 -5
  13. package/dist/cjs/components/form/formFields/formFieldWrapper/FormField.js.map +1 -1
  14. package/dist/cjs/components/form/formFields/formFieldWrapper/formFieldProps.js.map +1 -1
  15. package/dist/cjs/components/form/formFields/subComponents/inputs/autocomplete/Autocomplete.js +15 -11
  16. package/dist/cjs/components/form/formFields/subComponents/inputs/autocomplete/Autocomplete.js.map +1 -1
  17. package/dist/cjs/components/form/formFields/subComponents/inputs/checkbox/InputCheckbox.js +37 -15
  18. package/dist/cjs/components/form/formFields/subComponents/inputs/checkbox/InputCheckbox.js.map +1 -1
  19. package/dist/cjs/components/form/formFields/subComponents/inputs/checkbox/inputCheckbox.css +4 -4
  20. package/dist/cjs/components/form/formFields/subComponents/inputs/checkbox/inputCheckboxProps.js.map +1 -1
  21. package/dist/cjs/components/form/formFields/subComponents/inputs/file/dragAndDrop/DragAndDropFileUpload.js +9 -9
  22. package/dist/cjs/components/form/formFields/subComponents/inputs/file/dragAndDrop/DragAndDropFileUpload.js.map +1 -1
  23. package/dist/cjs/components/form/formFields/subComponents/inputs/radio/styled/StyledRadioGroup.js +14 -4
  24. package/dist/cjs/components/form/formFields/subComponents/inputs/radio/styled/StyledRadioGroup.js.map +1 -1
  25. package/dist/cjs/components/form/formFields/subComponents/inputs/text/InputText.js +23 -17
  26. package/dist/cjs/components/form/formFields/subComponents/inputs/text/InputText.js.map +1 -1
  27. package/dist/cjs/components/form/formFields/subComponents/select/Select.js +6 -5
  28. package/dist/cjs/components/form/formFields/subComponents/select/Select.js.map +1 -1
  29. package/dist/cjs/components/form/formFields/subComponents/textarea/Textarea.js +55 -83
  30. package/dist/cjs/components/form/formFields/subComponents/textarea/Textarea.js.map +1 -1
  31. package/dist/cjs/components/form/formFields/subComponents/textarea/textarea.css +20 -0
  32. package/dist/cjs/components/form/hookFormWrapper/HookFormWrapper.js +22 -5
  33. package/dist/cjs/components/form/hookFormWrapper/HookFormWrapper.js.map +1 -1
  34. package/dist/cjs/components/form/validation/ValidationMessages.js +36 -38
  35. package/dist/cjs/components/form/validation/ValidationMessages.js.map +1 -1
  36. package/dist/cjs/exampleUIs/exampleComponents/DemoContactForm.js +1 -2
  37. package/dist/cjs/exampleUIs/exampleComponents/DemoContactForm.js.map +1 -1
  38. package/dist/cjs/helpers/index.js +12 -0
  39. package/dist/cjs/helpers/index.js.map +1 -1
  40. package/dist/cjs/helpers/stringHelpers.js +48 -2
  41. package/dist/cjs/helpers/stringHelpers.js.map +1 -1
  42. package/dist/cjs/hooks/EdgeProximityDetect.js +18 -10
  43. package/dist/cjs/hooks/EdgeProximityDetect.js.map +1 -1
  44. package/dist/cjs/interfaces/headerText.interface.js.map +1 -1
  45. package/dist/cjs/package.json +137 -151
  46. package/dist/cjs/styles/index.css +22 -25
  47. package/dist/cjs/styles/shared/_allPartials.css +22 -25
  48. package/dist/cjs/styles/shared/forms/_forms.css +22 -25
  49. package/dist/components/design/dialog/Dialog.d.ts.map +1 -1
  50. package/dist/components/design/dialog/Dialog.test.d.ts +5 -0
  51. package/dist/components/design/dialog/Dialog.test.d.ts.map +1 -0
  52. package/dist/components/design/headerBar/HeaderBar.d.ts.map +1 -1
  53. package/dist/components/design/tooltip/Tooltip.d.ts +2 -0
  54. package/dist/components/design/tooltip/Tooltip.d.ts.map +1 -1
  55. package/dist/components/design/tooltip/Tooltip.test.d.ts +2 -0
  56. package/dist/components/design/tooltip/Tooltip.test.d.ts.map +1 -0
  57. package/dist/components/form/formFields/formFieldWrapper/FormField.d.ts.map +1 -1
  58. package/dist/components/form/formFields/formFieldWrapper/formFieldProps.d.ts +7 -2
  59. package/dist/components/form/formFields/formFieldWrapper/formFieldProps.d.ts.map +1 -1
  60. package/dist/components/form/formFields/subComponents/inputs/autocomplete/Autocomplete.d.ts.map +1 -1
  61. package/dist/components/form/formFields/subComponents/inputs/checkbox/InputCheckbox.d.ts.map +1 -1
  62. package/dist/components/form/formFields/subComponents/inputs/checkbox/InputCheckbox.test.d.ts +5 -0
  63. package/dist/components/form/formFields/subComponents/inputs/checkbox/InputCheckbox.test.d.ts.map +1 -0
  64. package/dist/components/form/formFields/subComponents/inputs/checkbox/inputCheckboxProps.d.ts +8 -6
  65. package/dist/components/form/formFields/subComponents/inputs/checkbox/inputCheckboxProps.d.ts.map +1 -1
  66. package/dist/components/form/formFields/subComponents/inputs/file/dragAndDrop/DragAndDropFileUpload.d.ts.map +1 -1
  67. package/dist/components/form/formFields/subComponents/inputs/radio/styled/StyledRadioGroup.d.ts.map +1 -1
  68. package/dist/components/form/formFields/subComponents/inputs/text/InputText.d.ts.map +1 -1
  69. package/dist/components/form/formFields/subComponents/nestedFormContext.test.d.ts +5 -0
  70. package/dist/components/form/formFields/subComponents/nestedFormContext.test.d.ts.map +1 -0
  71. package/dist/components/form/formFields/subComponents/select/Select.d.ts.map +1 -1
  72. package/dist/components/form/formFields/subComponents/textarea/Textarea.d.ts +4 -3
  73. package/dist/components/form/formFields/subComponents/textarea/Textarea.d.ts.map +1 -1
  74. package/dist/components/form/hookFormWrapper/HookFormWrapper.d.ts +3 -0
  75. package/dist/components/form/hookFormWrapper/HookFormWrapper.d.ts.map +1 -1
  76. package/dist/components/form/hookFormWrapper/HookFormWrapper.test.d.ts +5 -0
  77. package/dist/components/form/hookFormWrapper/HookFormWrapper.test.d.ts.map +1 -0
  78. package/dist/components/form/validation/ValidationMessages.d.ts +8 -1
  79. package/dist/components/form/validation/ValidationMessages.d.ts.map +1 -1
  80. package/dist/components/form/validation/ValidationMessages.test.d.ts +5 -0
  81. package/dist/components/form/validation/ValidationMessages.test.d.ts.map +1 -0
  82. package/dist/esm/autoGenerated/libraryThemes.js +12 -12
  83. package/dist/esm/autoGenerated/libraryThemes.js.map +1 -1
  84. package/dist/esm/autoGenerated/libraryThemes.json +12 -12
  85. package/dist/esm/components/design/dialog/Dialog.js +1 -1
  86. package/dist/esm/components/design/dialog/Dialog.js.map +1 -1
  87. package/dist/esm/components/design/headerBar/HeaderBar.js +3 -1
  88. package/dist/esm/components/design/headerBar/HeaderBar.js.map +1 -1
  89. package/dist/esm/components/design/headerBar/headerBar.css +6 -1
  90. package/dist/esm/components/design/tooltip/Tooltip.js +67 -15
  91. package/dist/esm/components/design/tooltip/Tooltip.js.map +1 -1
  92. package/dist/esm/components/design/tooltip/tooltip.css +1 -1
  93. package/dist/esm/components/form/formFields/formFieldWrapper/FormField.js +8 -5
  94. package/dist/esm/components/form/formFields/formFieldWrapper/FormField.js.map +1 -1
  95. package/dist/esm/components/form/formFields/formFieldWrapper/formFieldProps.js.map +1 -1
  96. package/dist/esm/components/form/formFields/subComponents/inputs/autocomplete/Autocomplete.js +16 -12
  97. package/dist/esm/components/form/formFields/subComponents/inputs/autocomplete/Autocomplete.js.map +1 -1
  98. package/dist/esm/components/form/formFields/subComponents/inputs/checkbox/InputCheckbox.js +37 -15
  99. package/dist/esm/components/form/formFields/subComponents/inputs/checkbox/InputCheckbox.js.map +1 -1
  100. package/dist/esm/components/form/formFields/subComponents/inputs/checkbox/inputCheckbox.css +4 -4
  101. package/dist/esm/components/form/formFields/subComponents/inputs/checkbox/inputCheckboxProps.js.map +1 -1
  102. package/dist/esm/components/form/formFields/subComponents/inputs/file/dragAndDrop/DragAndDropFileUpload.js +8 -8
  103. package/dist/esm/components/form/formFields/subComponents/inputs/file/dragAndDrop/DragAndDropFileUpload.js.map +1 -1
  104. package/dist/esm/components/form/formFields/subComponents/inputs/radio/styled/StyledRadioGroup.js +16 -6
  105. package/dist/esm/components/form/formFields/subComponents/inputs/radio/styled/StyledRadioGroup.js.map +1 -1
  106. package/dist/esm/components/form/formFields/subComponents/inputs/text/InputText.js +23 -17
  107. package/dist/esm/components/form/formFields/subComponents/inputs/text/InputText.js.map +1 -1
  108. package/dist/esm/components/form/formFields/subComponents/select/Select.js +6 -5
  109. package/dist/esm/components/form/formFields/subComponents/select/Select.js.map +1 -1
  110. package/dist/esm/components/form/formFields/subComponents/textarea/Textarea.js +50 -78
  111. package/dist/esm/components/form/formFields/subComponents/textarea/Textarea.js.map +1 -1
  112. package/dist/esm/components/form/formFields/subComponents/textarea/textarea.css +20 -0
  113. package/dist/esm/components/form/hookFormWrapper/HookFormWrapper.js +22 -5
  114. package/dist/esm/components/form/hookFormWrapper/HookFormWrapper.js.map +1 -1
  115. package/dist/esm/components/form/validation/ValidationMessages.js +36 -38
  116. package/dist/esm/components/form/validation/ValidationMessages.js.map +1 -1
  117. package/dist/esm/exampleUIs/exampleComponents/DemoContactForm.js +1 -2
  118. package/dist/esm/exampleUIs/exampleComponents/DemoContactForm.js.map +1 -1
  119. package/dist/esm/helpers/index.js +1 -1
  120. package/dist/esm/helpers/index.js.map +1 -1
  121. package/dist/esm/helpers/stringHelpers.js +44 -0
  122. package/dist/esm/helpers/stringHelpers.js.map +1 -1
  123. package/dist/esm/hooks/EdgeProximityDetect.js +19 -11
  124. package/dist/esm/hooks/EdgeProximityDetect.js.map +1 -1
  125. package/dist/esm/interfaces/headerText.interface.js.map +1 -1
  126. package/dist/esm/package.json +137 -151
  127. package/dist/esm/styles/index.css +22 -25
  128. package/dist/esm/styles/shared/_allPartials.css +22 -25
  129. package/dist/esm/styles/shared/forms/_forms.css +22 -25
  130. package/dist/exampleUIs/exampleComponents/DemoContactForm.d.ts.map +1 -1
  131. package/dist/helpers/index.d.ts +1 -1
  132. package/dist/helpers/index.d.ts.map +1 -1
  133. package/dist/helpers/stringHelpers.d.ts +17 -0
  134. package/dist/helpers/stringHelpers.d.ts.map +1 -1
  135. package/dist/hooks/EdgeProximityDetect.d.ts.map +1 -1
  136. package/dist/interfaces/headerText.interface.d.ts +1 -0
  137. package/dist/interfaces/headerText.interface.d.ts.map +1 -1
  138. package/dist/package.json +137 -151
  139. package/package.json +137 -151
  140. package/dist/cjs/components/form/formFields/utilities/formUtilities.js +0 -22
  141. package/dist/cjs/components/form/formFields/utilities/formUtilities.js.map +0 -1
  142. package/dist/components/form/formFields/utilities/formUtilities.d.ts +0 -18
  143. package/dist/components/form/formFields/utilities/formUtilities.d.ts.map +0 -1
  144. package/dist/esm/components/form/formFields/utilities/formUtilities.js +0 -16
  145. package/dist/esm/components/form/formFields/utilities/formUtilities.js.map +0 -1
@@ -12,21 +12,38 @@ var _reactHookForm = require("react-hook-form");
12
12
  const HookFormWrapper = ({
13
13
  formCssClass = 'x15StandardForm',
14
14
  children,
15
- formProps
15
+ formProps,
16
+ formContext,
17
+ onSubmit
16
18
  }) => {
17
- const existingHookFormContext = (0, _reactHookForm.useFormContext)();
19
+ const inheritedHookFormContext = (0, _reactHookForm.useFormContext)();
18
20
  const hookFormMethods = (0, _reactHookForm.useForm)({
19
21
  mode: 'all',
20
22
  criteriaMode: 'all',
21
23
  shouldFocusError: true
22
24
  });
23
- if (existingHookFormContext) {
24
- return children;
25
+
26
+ // A manually supplied context re-publishes the form state across a boundary the
27
+ // React context could not cross (e.g. a Next.js server/client component split).
28
+ if (formContext) {
29
+ return /*#__PURE__*/_react.default.createElement(_reactHookForm.FormProvider, formContext, children);
30
+ }
31
+ if (inheritedHookFormContext) {
32
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, children);
25
33
  }
34
+ const {
35
+ onSubmit: nativeOnSubmit,
36
+ ...remainingFormProps
37
+ } = formProps || {};
38
+
39
+ // `onSubmit` receives the validated values, so consumers never need to call useForm themselves.
40
+ const handleFormSubmit = onSubmit ? hookFormMethods.handleSubmit(onSubmit) : nativeOnSubmit;
26
41
  return /*#__PURE__*/_react.default.createElement(_reactHookForm.FormProvider, hookFormMethods, /*#__PURE__*/_react.default.createElement("form", (0, _extends2.default)({
27
42
  className: formCssClass,
28
43
  autoComplete: "off"
29
- }, formProps), children));
44
+ }, remainingFormProps, {
45
+ onSubmit: handleFormSubmit
46
+ }), children));
30
47
  };
31
48
  exports.HookFormWrapper = HookFormWrapper;
32
49
  var _default = exports.default = HookFormWrapper;
@@ -1 +1 @@
1
- {"version":3,"file":"HookFormWrapper.js","names":["_interopRequireDefault","require","Object","defineProperty","exports","value","default","HookFormWrapper","_extends2","_react","_reactHookForm","formCssClass","children","formProps","existingHookFormContext","useFormContext","hookFormMethods","useForm","mode","criteriaMode","shouldFocusError","createElement","FormProvider","className","autoComplete","_default"],"sources":["../../../../../src/components/form/hookFormWrapper/HookFormWrapper.tsx"],"sourcesContent":["'use client';\n\nimport React, { ReactNode, ReactElement, FormHTMLAttributes } from 'react';\nimport { FormProvider, useForm, useFormContext } from 'react-hook-form';\n\ninterface FormWrapperProps {\n formCssClass?: string;\n formProps?: FormHTMLAttributes<HTMLFormElement>;\n children: ReactNode | ReactElement;\n}\n\nexport const HookFormWrapper: React.FC<FormWrapperProps> = (\n {\n formCssClass = 'x15StandardForm',\n children,\n formProps\n }\n) => {\n const existingHookFormContext = useFormContext();\n\n const hookFormMethods = useForm({\n mode: 'all',\n criteriaMode: 'all',\n shouldFocusError: true\n });\n\n if (existingHookFormContext) {\n return children;\n }\n\n return (\n <FormProvider { ...hookFormMethods }>\n <form className={ formCssClass } autoComplete=\"off\" { ...formProps }>\n {\n children\n }\n </form>\n </FormProvider>\n );\n};\n\nexport default HookFormWrapper;\n"],"mappings":";AAAA,YAAY;;AAAC,IAAAA,sBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,cAAA,CAAAC,OAAA;EAAAC,KAAA;AAAA;AAAAD,OAAA,CAAAE,OAAA,GAAAF,OAAA,CAAAG,eAAA;AAAA,IAAAC,SAAA,GAAAR,sBAAA,CAAAC,OAAA;AAEb,IAAAQ,MAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,cAAA,GAAAT,OAAA;AAQO,MAAMM,eAA2C,GAAGA,CACzD;EACEI,YAAY,GAAG,iBAAiB;EAChCC,QAAQ;EACRC;AACF,CAAC,KACE;EACH,MAAMC,uBAAuB,GAAG,IAAAC,6BAAc,EAAC,CAAC;EAEhD,MAAMC,eAAe,GAAG,IAAAC,sBAAO,EAAC;IAC9BC,IAAI,EAAE,KAAK;IACXC,YAAY,EAAE,KAAK;IACnBC,gBAAgB,EAAE;EACpB,CAAC,CAAC;EAEF,IAAIN,uBAAuB,EAAE;IAC3B,OAAOF,QAAQ;EACjB;EAEA,oBACEH,MAAA,CAAAH,OAAA,CAAAe,aAAA,CAACX,cAAA,CAAAY,YAAY,EAAMN,eAAe,eAChCP,MAAA,CAAAH,OAAA,CAAAe,aAAA,aAAAb,SAAA,CAAAF,OAAA;IAAMiB,SAAS,EAAGZ,YAAc;IAACa,YAAY,EAAC;EAAK,GAAMX,SAAS,GAE9DD,QAEE,CACM,CAAC;AAEnB,CAAC;AAACR,OAAA,CAAAG,eAAA,GAAAA,eAAA;AAAA,IAAAkB,QAAA,GAAArB,OAAA,CAAAE,OAAA,GAEaC,eAAe","ignoreList":[]}
1
+ {"version":3,"file":"HookFormWrapper.js","names":["_interopRequireDefault","require","Object","defineProperty","exports","value","default","HookFormWrapper","_extends2","_react","_reactHookForm","formCssClass","children","formProps","formContext","onSubmit","inheritedHookFormContext","useFormContext","hookFormMethods","useForm","mode","criteriaMode","shouldFocusError","createElement","FormProvider","Fragment","nativeOnSubmit","remainingFormProps","handleFormSubmit","handleSubmit","className","autoComplete","_default"],"sources":["../../../../../src/components/form/hookFormWrapper/HookFormWrapper.tsx"],"sourcesContent":["'use client';\n\nimport React, { ReactNode, ReactElement, FormHTMLAttributes } from 'react';\nimport { FieldValues, FormProvider, useForm, useFormContext, UseFormReturn } from 'react-hook-form';\n\ninterface FormWrapperProps {\n formCssClass?: string;\n formProps?: FormHTMLAttributes<HTMLFormElement>;\n children: ReactNode | ReactElement;\n formContext?: UseFormReturn<FieldValues, any, FieldValues>\n /* eslint-disable-next-line no-unused-vars */\n onSubmit?: (values: FieldValues) => void | Promise<void>;\n}\n\nexport const HookFormWrapper: React.FC<FormWrapperProps> = (\n {\n formCssClass = 'x15StandardForm',\n children,\n formProps,\n formContext,\n onSubmit,\n }\n) => {\n const inheritedHookFormContext = useFormContext();\n\n const hookFormMethods = useForm({\n mode: 'all',\n criteriaMode: 'all',\n shouldFocusError: true\n });\n\n // A manually supplied context re-publishes the form state across a boundary the\n // React context could not cross (e.g. a Next.js server/client component split).\n if (formContext) {\n return (\n <FormProvider { ...formContext }>\n { children }\n </FormProvider>\n );\n }\n\n if (inheritedHookFormContext) {\n return <>{ children }</>;\n }\n\n const { onSubmit: nativeOnSubmit, ...remainingFormProps } = formProps || {};\n\n // `onSubmit` receives the validated values, so consumers never need to call useForm themselves.\n const handleFormSubmit = onSubmit\n ? hookFormMethods.handleSubmit(onSubmit)\n : nativeOnSubmit;\n\n return (\n <FormProvider { ...hookFormMethods }>\n <form\n className={ formCssClass }\n autoComplete=\"off\"\n { ...remainingFormProps }\n onSubmit={ handleFormSubmit }\n >\n {\n children\n }\n </form>\n </FormProvider>\n );\n};\n\nexport default HookFormWrapper;\n"],"mappings":";AAAA,YAAY;;AAAC,IAAAA,sBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,cAAA,CAAAC,OAAA;EAAAC,KAAA;AAAA;AAAAD,OAAA,CAAAE,OAAA,GAAAF,OAAA,CAAAG,eAAA;AAA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AAG,eAAA,GAAAA,eAAA;AAAA,IAAAyB,QAAA,GAAA5B,OAAA,CAAAE,OAAA,GAEaC,eAAe","ignoreList":[]}
@@ -1,6 +1,4 @@
1
1
  "use strict";
2
- /* eslint-disable no-unused-vars */
3
-
4
2
  'use client';
5
3
 
6
4
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
@@ -9,17 +7,27 @@ Object.defineProperty(exports, "__esModule", {
9
7
  });
10
8
  exports.extractError = exports.default = exports.ValidationMessages = exports.GenericErrorMessages = void 0;
11
9
  var _react = _interopRequireDefault(require("react"));
12
- var _errorMessage = require("@hookform/error-message");
13
10
  var _reactHookForm = require("react-hook-form");
14
- var _formUtilities = require("../formFields/utilities/formUtilities");
15
11
  // Type for generic error messages
16
12
  const GenericErrorMessages = exports.GenericErrorMessages = {
17
- required: () => 'This field is required. Please enter a value.',
18
- minLength: value => `Please provide a minimum of ${value} characters.`,
19
- maxLength: value => `Please provide a maximum of ${value} characters.`,
20
- min: value => `The value must be a minimum of ${value}.`,
21
- max: value => `The value must be a maximum of ${value}.`,
22
- unknown: () => 'An unknown error has occurred.'
13
+ required: 'This field is required. Please enter a value.',
14
+ minLength: 'Please provide a minimum of {value} characters.',
15
+ maxLength: 'Please provide a maximum of {value} characters.',
16
+ min: 'The value must be a minimum of {value}.',
17
+ max: 'The value must be a maximum of {value}.',
18
+ unknown: 'An unknown error has occurred.'
19
+ };
20
+ const isGenericErrorType = errorType => typeof errorType === 'string' && errorType !== 'unknown' && Object.prototype.hasOwnProperty.call(GenericErrorMessages, errorType);
21
+ const getValidationValue = validator => typeof validator === 'object' ? validator.value : validator;
22
+ const getGenericErrorMessage = (errorType, validation) => {
23
+ if (!isGenericErrorType(errorType)) {
24
+ return undefined;
25
+ }
26
+ if (errorType === 'required') {
27
+ return GenericErrorMessages.required;
28
+ }
29
+ const value = getValidationValue(validation?.[errorType]);
30
+ return value === undefined ? undefined : GenericErrorMessages[errorType].replace('{value}', String(value));
23
31
  };
24
32
 
25
33
  // Helper function to extract nested errors
@@ -40,49 +48,39 @@ const ValidationMessages = ({
40
48
  name,
41
49
  validation
42
50
  }) => {
51
+ const formContext = (0, _reactHookForm.useFormContext)();
52
+ if (!formContext) {
53
+ return null;
54
+ }
43
55
  const {
44
56
  formState: {
45
57
  errors
46
58
  }
47
- } = (0, _reactHookForm.useFormContext)() || _formUtilities.NoHookFormContext;
59
+ } = formContext;
48
60
  const fieldError = extractError(errors, name);
49
61
  if (!fieldError) {
50
62
  return null;
51
63
  }
52
64
 
53
- // Check all the validators have a message
54
- if (validation) {
55
- Object.entries(validation).forEach(([validatorKey, validator]) => {
56
- if (GenericErrorMessages[validatorKey]) {
57
- if (typeof validator === 'boolean') {
58
- if (fieldError.type && fieldError.types && typeof fieldError.types[fieldError.type] === 'string') {
59
- fieldError.message = fieldError.types[fieldError.type];
60
- } else {
61
- fieldError.message = GenericErrorMessages[validatorKey]();
62
- }
63
- } else if (typeof validator === 'object' && 'value' in validator) {
64
- // @ts-ignore The hook form types don't seem to cater for versions with value properties properly
65
- fieldError.message = GenericErrorMessages[validatorKey](validator.value || undefined);
66
- }
67
- }
68
- });
69
- }
65
+ // Derive a fallback message rather than mutating the error object held in formState.
66
+ const resolveMessage = () => {
67
+ if (fieldError.message) {
68
+ return fieldError.message;
69
+ }
70
+ if (fieldError.type && fieldError.types && typeof fieldError.types[fieldError.type] === 'string') {
71
+ return fieldError.types[fieldError.type];
72
+ }
73
+ return getGenericErrorMessage(fieldError.type, validation);
74
+ };
75
+ const message = resolveMessage() || GenericErrorMessages.unknown;
70
76
  return /*#__PURE__*/_react.default.createElement("span", {
71
77
  className: "validation",
72
78
  id: `${name}_errors`
73
79
  }, /*#__PURE__*/_react.default.createElement("span", {
74
80
  className: "message"
75
- }, !fieldError?.message && /*#__PURE__*/_react.default.createElement("span", {
81
+ }, /*#__PURE__*/_react.default.createElement("span", {
76
82
  className: "error"
77
- }, GenericErrorMessages.unknown()), /*#__PURE__*/_react.default.createElement(_errorMessage.ErrorMessage, {
78
- errors: errors,
79
- name: name,
80
- render: ({
81
- message
82
- }) => /*#__PURE__*/_react.default.createElement("span", {
83
- className: "error"
84
- }, message)
85
- })));
83
+ }, message)));
86
84
  };
87
85
  exports.ValidationMessages = ValidationMessages;
88
86
  var _default = exports.default = ValidationMessages;
@@ -1 +1 @@
1
- {"version":3,"file":"ValidationMessages.js","names":["_interopRequireDefault","require","Object","defineProperty","exports","value","extractError","default","ValidationMessages","GenericErrorMessages","_react","_errorMessage","_reactHookForm","_formUtilities","required","minLength","maxLength","min","max","unknown","errors","fieldName","undefined","pathComponents","split","reduce","accumulator","pathComponent","name","validation","formState","useFormContext","NoHookFormContext","fieldError","entries","forEach","validatorKey","validator","type","types","message","createElement","className","id","ErrorMessage","render","_default"],"sources":["../../../../../src/components/form/validation/ValidationMessages.tsx"],"sourcesContent":["/* eslint-disable no-unused-vars */\n\n'use client';\n\nimport React from 'react';\nimport { ErrorMessage } from '@hookform/error-message';\nimport {\n FieldError,\n FieldErrors,\n FieldErrorsImpl,\n Merge, useFormContext\n} from 'react-hook-form';\nimport {\n ValidationProps\n} from '../formFields/formFieldWrapper/formFieldProps';\nimport { NoHookFormContext } from '../formFields/utilities/formUtilities';\nimport { InputCheckboxValidationProps } from '../formFields/subComponents/inputs/checkbox/inputCheckboxProps';\n\n// Type for generic error messages\nexport const GenericErrorMessages: Record<string, (value?: never) => string> = {\n required: () => 'This field is required. Please enter a value.',\n minLength: (value) => `Please provide a minimum of ${ value } characters.`,\n maxLength: (value) => `Please provide a maximum of ${ value } characters.`,\n min: (value) => `The value must be a minimum of ${ value }.`,\n max: (value) => `The value must be a maximum of ${ value }.`,\n unknown: () => 'An unknown error has occurred.'\n};\n\n// Helper function to extract nested errors\nexport const extractError = (\n errors: FieldErrors,\n fieldName: string\n): FieldError | Merge<FieldError, FieldErrorsImpl<never>> | undefined => {\n if (!errors) {\n return undefined;\n }\n\n const pathComponents = fieldName.split('.');\n\n return pathComponents.reduce<FieldError | Merge<FieldError, FieldErrorsImpl<never>> | undefined>(\n (accumulator, pathComponent) => {\n if (!accumulator) {\n return undefined;\n }\n\n return (accumulator as never)[pathComponent];\n },\n errors as never\n );\n};\n\ninterface ValidationMessagesProps {\n name: string;\n validation?: ValidationProps | InputCheckboxValidationProps\n}\n\nexport const ValidationMessages: React.FC<ValidationMessagesProps> = (\n {\n name,\n validation\n }\n) => {\n const { formState: { errors } } = useFormContext() || NoHookFormContext;\n\n const fieldError = extractError(errors, name);\n\n if (!fieldError) {\n return null;\n }\n\n // Check all the validators have a message\n if (validation) {\n Object.entries(validation).forEach(([validatorKey, validator]) => {\n if (GenericErrorMessages[validatorKey]) {\n if (typeof validator === 'boolean') {\n if (\n fieldError.type &&\n fieldError.types &&\n typeof fieldError.types[fieldError.type] === 'string'\n ) {\n fieldError.message = fieldError.types[fieldError.type] as string;\n } else {\n fieldError.message = GenericErrorMessages[validatorKey]();\n }\n } else if (typeof validator === 'object' && 'value' in validator) {\n // @ts-ignore The hook form types don't seem to cater for versions with value properties properly\n fieldError.message = GenericErrorMessages[validatorKey](validator.value || undefined);\n }\n }\n });\n }\n\n return (\n <span className=\"validation\" id={ `${ name }_errors` }>\n <span className=\"message\">\n { !fieldError?.message && (\n <span className=\"error\">{ GenericErrorMessages.unknown() }</span>\n ) }\n\n <ErrorMessage\n errors={ errors }\n name={ name }\n render={ ({ message }) => <span className=\"error\">{ message }</span> }\n />\n </span>\n </span>\n );\n};\n\nexport default ValidationMessages;\n"],"mappings":";AAAA;;AAEA,YAAY;;AAAC,IAAAA,sBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,cAAA,CAAAC,OAAA;EAAAC,KAAA;AAAA;AAAAD,OAAA,CAAAE,YAAA,GAAAF,OAAA,CAAAG,OAAA,GAAAH,OAAA,CAAAI,kBAAA,GAAAJ,OAAA,CAAAK,oBAAA;AAEb,IAAAC,MAAA,GAAAV,sBAAA,CAAAC,OAAA;AACA,IAAAU,aAAA,GAAAV,OAAA;AACA,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C,aAAA;MAAMC,SAAS,EAAC;IAAO,GAAGF,OAAe;EAAG,CACvE,CACG,CACF,CAAC;AAEX,CAAC;AAACpC,OAAA,CAAAI,kBAAA,GAAAA,kBAAA;AAAA,IAAAsC,QAAA,GAAA1C,OAAA,CAAAG,OAAA,GAEaC,kBAAkB","ignoreList":[]}
1
+ {"version":3,"file":"ValidationMessages.js","names":["_interopRequireDefault","require","Object","defineProperty","exports","value","extractError","default","ValidationMessages","GenericErrorMessages","_react","_reactHookForm","required","minLength","maxLength","min","max","unknown","isGenericErrorType","errorType","prototype","hasOwnProperty","call","getValidationValue","validator","getGenericErrorMessage","validation","undefined","replace","String","errors","fieldName","pathComponents","split","reduce","accumulator","pathComponent","name","formContext","useFormContext","formState","fieldError","resolveMessage","message","type","types","createElement","className","id","_default"],"sources":["../../../../../src/components/form/validation/ValidationMessages.tsx"],"sourcesContent":[" \n\n'use client';\n\nimport React from 'react';\nimport {\n FieldError,\n FieldErrors,\n FieldErrorsImpl,\n Merge,\n ValidationRule,\n useFormContext\n} from 'react-hook-form';\nimport {\n ValidationProps\n} from '../formFields/formFieldWrapper/formFieldProps';\nimport { InputCheckboxValidationProps } from '../formFields/subComponents/inputs/checkbox/inputCheckboxProps';\n\n// Type for generic error messages\nexport const GenericErrorMessages = {\n required: 'This field is required. Please enter a value.',\n minLength: 'Please provide a minimum of {value} characters.',\n maxLength: 'Please provide a maximum of {value} characters.',\n min: 'The value must be a minimum of {value}.',\n max: 'The value must be a maximum of {value}.',\n unknown: 'An unknown error has occurred.'\n};\n\ntype ValidationRules = ValidationProps | InputCheckboxValidationProps;\ntype GenericErrorType = Exclude<keyof typeof GenericErrorMessages, 'unknown'>;\ntype ValidationErrorType = NonNullable<ReturnType<typeof extractError>>['type'];\n\nconst isGenericErrorType = (errorType: ValidationErrorType): errorType is GenericErrorType =>\n typeof errorType === 'string'\n && errorType !== 'unknown'\n && Object.prototype.hasOwnProperty.call(GenericErrorMessages, errorType);\n\nconst getValidationValue = <TValue extends string | number>(\n validator: ValidationRule<TValue> | undefined\n): TValue | undefined => typeof validator === 'object' ? validator.value : validator;\n\nconst getGenericErrorMessage = (\n errorType: ValidationErrorType,\n validation?: ValidationRules\n): string | undefined => {\n if (!isGenericErrorType(errorType)) {\n return undefined;\n }\n\n if (errorType === 'required') {\n return GenericErrorMessages.required;\n }\n\n const value = getValidationValue(validation?.[errorType]);\n\n return value === undefined\n ? undefined\n : GenericErrorMessages[errorType].replace('{value}', String(value));\n};\n\n// Helper function to extract nested errors\nexport const extractError = (\n errors: FieldErrors,\n fieldName: string\n): FieldError | Merge<FieldError, FieldErrorsImpl<never>> | undefined => {\n if (!errors) {\n return undefined;\n }\n\n const pathComponents = fieldName.split('.');\n\n return pathComponents.reduce<FieldError | Merge<FieldError, FieldErrorsImpl<never>> | undefined>(\n (accumulator, pathComponent) => {\n if (!accumulator) {\n return undefined;\n }\n\n return (accumulator as never)[pathComponent];\n },\n errors as never\n );\n};\n\ninterface ValidationMessagesProps {\n name: string;\n validation?: ValidationProps | InputCheckboxValidationProps\n}\n\nexport const ValidationMessages: React.FC<ValidationMessagesProps> = (\n {\n name,\n validation\n }\n) => {\n const formContext = useFormContext();\n\n if (!formContext) {\n return null;\n }\n\n const { formState: { errors } } = formContext;\n\n const fieldError = extractError(errors, name);\n\n if (!fieldError) {\n return null;\n }\n\n // Derive a fallback message rather than mutating the error object held in formState.\n const resolveMessage = (): string | undefined => {\n if (fieldError.message) {\n return fieldError.message as string;\n }\n\n if (\n fieldError.type\n && fieldError.types\n && typeof fieldError.types[fieldError.type] === 'string'\n ) {\n return fieldError.types[fieldError.type] as string;\n }\n\n return getGenericErrorMessage(fieldError.type, validation);\n };\n\n const message = resolveMessage() || GenericErrorMessages.unknown;\n\n return (\n <span className=\"validation\" id={ `${ name }_errors` }>\n <span className=\"message\">\n <span className=\"error\">{ message }</span>\n </span>\n </span>\n );\n};\n\nexport default ValidationMessages;\n"],"mappings":";AAEA,YAAY;;AAAC,IAAAA,sBAAA,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,GAAGD,cAAc,CAAC,CAAC,IAAIjC,oBAAoB,CAACQ,OAAO;EAEhE,oBACEP,MAAA,CAAAH,OAAA,CAAAuC,aAAA;IAAMC,SAAS,EAAC,YAAY;IAACC,EAAE,EAAG,GAAIX,IAAI;EAAY,gBACpD3B,MAAA,CAAAH,OAAA,CAAAuC,aAAA;IAAMC,SAAS,EAAC;EAAS,gBACvBrC,MAAA,CAAAH,OAAA,CAAAuC,aAAA;IAAMC,SAAS,EAAC;EAAO,GAAGJ,OAAe,CACrC,CACF,CAAC;AAEX,CAAC;AAACvC,OAAA,CAAAI,kBAAA,GAAAA,kBAAA;AAAA,IAAAyC,QAAA,GAAA7C,OAAA,CAAAG,OAAA,GAEaC,kBAAkB","ignoreList":[]}
@@ -75,8 +75,7 @@ const DemoContactForm = ({
75
75
  }), /*#__PURE__*/_react.default.createElement(_Textarea.Textarea, {
76
76
  field: {
77
77
  id: 'yourMessage',
78
- name: 'yourMessage',
79
- type: 'textarea'
78
+ name: 'yourMessage'
80
79
  },
81
80
  label: {
82
81
  text: 'Your message'
@@ -1 +1 @@
1
- {"version":3,"file":"DemoContactForm.js","names":["_react","_interopRequireWildcard","require","_reactHookForm","_InputVariants","_SimpleButton","_Textarea","_InputCheckbox","_Tooltip","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","DemoContactForm","onConsentClick","consentIsGiven","hasConsent","setHasConsent","React","useState","formContext","useFormContext","handleConsentClick","event","isChecked","target","checked","setValue","useEffect","createElement","className","TextInput","field","id","name","label","text","validation","required","EmailInput","PhoneInput","Textarea","type","InputCheckbox","defaultChecked","value","onChange","Tooltip","icon","SimpleButton","buttonType","buttonStyle","color","rightIcon","exports","_default"],"sources":["../../../../src/exampleUIs/exampleComponents/DemoContactForm.tsx"],"sourcesContent":["import React, { FC, useEffect } from 'react';\nimport { useFormContext } from 'react-hook-form';\nimport {\n TextInput,\n EmailInput,\n PhoneInput\n} from '../../components/form/formFields/subComponents/InputVariants';\nimport { SimpleButton } from '../../components/form/buttons/SimpleButton';\nimport { Textarea } from '../../components/form/formFields/subComponents/textarea/Textarea';\nimport { InputCheckbox } from '../../components/form/formFields/subComponents/inputs/checkbox/InputCheckbox';\nimport { Tooltip } from '../../components/design/tooltip/Tooltip';\nimport { GenericFunction } from '../../interfaces/generic.interface';\n\nexport const DemoContactForm: FC<{\n onConsentClick: GenericFunction;\n consentIsGiven: boolean;\n}> = (\n {\n onConsentClick = () => {},\n consentIsGiven = false\n }\n) => {\n const [hasConsent, setHasConsent] = React.useState<boolean>(consentIsGiven);\n\n const formContext = useFormContext();\n\n const handleConsentClick = (event: React.ChangeEvent<HTMLInputElement>) => {\n const isChecked = event.target.checked;\n formContext.setValue('consentCheckbox1', isChecked);\n setHasConsent(isChecked);\n onConsentClick(isChecked);\n };\n\n useEffect(() => {\n formContext.setValue('consentCheckbox1', consentIsGiven);\n setHasConsent(consentIsGiven);\n });\n\n return (\n <div>\n <h2 className=\"spaceAfter\">Can't find what you're looking for?</h2>\n <h3 className=\"spaceAfter\">Send us a message</h3>\n\n <p className=\"spaceAfter\">To provide you with the best service possible we'll need some details about you.</p>\n\n <TextInput\n field={ {\n id: 'firstName',\n name: 'firstName'\n } }\n label={ {\n text: 'First Name'\n } }\n validation={ {\n required: 'This is required'\n } }\n />\n\n <TextInput\n field={ {\n id: 'lastName',\n name: 'lastName'\n } }\n label={ {\n text: 'Last Name'\n } }\n validation={ {\n required: 'This is required'\n } }\n />\n\n <EmailInput\n field={ {\n id: 'yourEmail',\n name: 'yourEmail'\n } }\n label={ {\n text: 'Your email address'\n } }\n />\n\n <PhoneInput\n field={ {\n id: 'yourPhone',\n name: 'yourPhone'\n } }\n label={ {\n text: 'A number we can reach you on'\n } }\n />\n\n <Textarea\n field={ {\n id: 'yourMessage',\n name: 'yourMessage',\n type: 'textarea'\n } }\n label={ {\n text: 'Your message'\n } }\n />\n\n <InputCheckbox\n field={ {\n defaultChecked: hasConsent,\n id: 'consentCheckbox1',\n name: 'consentCheckbox1',\n value: 'consentIsGiven',\n onChange: (event: React.ChangeEvent<HTMLInputElement>) => handleConsentClick(event)\n } }\n label={ {\n text: <span>By leaving this checked you are <strong>consenting</strong> to one of our support staff contacting you in the event that they need more information. <Tooltip icon=\"info\">More about why we might contact you.</Tooltip></span>\n } }\n />\n\n <div className=\"spaceBefore flexRow\">\n <SimpleButton\n label=\"Send Message\"\n id=\"demoSubmitButton1\"\n buttonType=\"submit\"\n buttonStyle={\n {\n color: 'primary'\n }\n }\n rightIcon={ {\n icon: 'telegram'\n } }\n />\n </div>\n </div>\n );\n};\n\nexport default DemoContactForm;"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AAKA,IAAAG,aAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,cAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AAAkE,SAAAD,wBAAAQ,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAV,uBAAA,YAAAA,CAAAQ,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,C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CACJ,CAAC,eAEFnD,MAAA,CAAAmB,OAAA,CAAAyB,aAAA,CAACrC,cAAA,CAAAmD,aAAa;IACZX,KAAK,EAAG;MACNY,cAAc,EAAE5B,UAAU;MAC1BiB,EAAE,EAAE,kBAAkB;MACtBC,IAAI,EAAE,kBAAkB;MACxBW,KAAK,EAAE,gBAAgB;MACvBC,QAAQ,EAAGvB,KAA0C,IAAKD,kBAAkB,CAACC,KAAK;IACpF,CAAG;IACHY,KAAK,EAAG;MACNC,IAAI,eAAEnD,MAAA,CAAAmB,OAAA,CAAAyB,aAAA,eAAM,kCAAgC,eAAA5C,MAAA,CAAAmB,OAAA,CAAAyB,aAAA,iBAAQ,YAAkB,CAAC,8FAA0F,eAAA5C,MAAA,CAAAmB,OAAA,CAAAyB,aAAA,CAACpC,QAAA,CAAAsD,OAAO;QAACC,IAAI,EAAC;MAAM,GAAC,sCAA6C,CAAO;IAC5O;EAAG,CACJ,CAAC,eAEF/D,MAAA,CAAAmB,OAAA,CAAAyB,aAAA;IAAKC,SAAS,EAAC;EAAqB,gBAClC7C,MAAA,CAAAmB,OAAA,CAAAyB,aAAA,CAACvC,aAAA,CAAA2D,YAAY;IACXd,KAAK,EAAC,cAAc;IACpBF,EAAE,EAAC,mBAAmB;IACtBiB,UAAU,EAAC,QAAQ;IACnBC,WAAW,EACT;MACEC,KAAK,EAAE;IACT,CACD;IACDC,SAAS,EAAG;MACVL,IAAI,EAAE;IACR;EAAG,CACJ,CACE,CACF,CAAC;AAEV,CAAC;AAACM,OAAA,CAAAzC,eAAA,GAAAA,eAAA;AAAA,IAAA0C,QAAA,GAAAD,OAAA,CAAAlD,OAAA,GAEaS,eAAe","ignoreList":[]}
1
+ {"version":3,"file":"DemoContactForm.js","names":["_react","_interopRequireWildcard","require","_reactHookForm","_InputVariants","_SimpleButton","_Textarea","_InputCheckbox","_Tooltip","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","DemoContactForm","onConsentClick","consentIsGiven","hasConsent","setHasConsent","React","useState","formContext","useFormContext","handleConsentClick","event","isChecked","target","checked","setValue","useEffect","createElement","className","TextInput","field","id","name","label","text","validation","required","EmailInput","PhoneInput","Textarea","InputCheckbox","defaultChecked","value","onChange","Tooltip","icon","SimpleButton","buttonType","buttonStyle","color","rightIcon","exports","_default"],"sources":["../../../../src/exampleUIs/exampleComponents/DemoContactForm.tsx"],"sourcesContent":["import React, { FC, useEffect } from 'react';\nimport { useFormContext } from 'react-hook-form';\nimport {\n TextInput,\n EmailInput,\n PhoneInput\n} from '../../components/form/formFields/subComponents/InputVariants';\nimport { SimpleButton } from '../../components/form/buttons/SimpleButton';\nimport { Textarea } from '../../components/form/formFields/subComponents/textarea/Textarea';\nimport { InputCheckbox } from '../../components/form/formFields/subComponents/inputs/checkbox/InputCheckbox';\nimport { Tooltip } from '../../components/design/tooltip/Tooltip';\nimport { GenericFunction } from '../../interfaces/generic.interface';\n\nexport const DemoContactForm: FC<{\n onConsentClick: GenericFunction;\n consentIsGiven: boolean;\n}> = (\n {\n onConsentClick = () => {},\n consentIsGiven = false\n }\n) => {\n const [hasConsent, setHasConsent] = React.useState<boolean>(consentIsGiven);\n\n const formContext = useFormContext();\n\n const handleConsentClick = (event: React.ChangeEvent<HTMLInputElement>) => {\n const isChecked = event.target.checked;\n formContext.setValue('consentCheckbox1', isChecked);\n setHasConsent(isChecked);\n onConsentClick(isChecked);\n };\n\n useEffect(() => {\n formContext.setValue('consentCheckbox1', consentIsGiven);\n setHasConsent(consentIsGiven);\n });\n\n return (\n <div>\n <h2 className=\"spaceAfter\">Can't find what you're looking for?</h2>\n <h3 className=\"spaceAfter\">Send us a message</h3>\n\n <p className=\"spaceAfter\">To provide you with the best service possible we'll need some details about you.</p>\n\n <TextInput\n field={ {\n id: 'firstName',\n name: 'firstName'\n } }\n label={ {\n text: 'First Name'\n } }\n validation={ {\n required: 'This is required'\n } }\n />\n\n <TextInput\n field={ {\n id: 'lastName',\n name: 'lastName'\n } }\n label={ {\n text: 'Last Name'\n } }\n validation={ {\n required: 'This is required'\n } }\n />\n\n <EmailInput\n field={ {\n id: 'yourEmail',\n name: 'yourEmail'\n } }\n label={ {\n text: 'Your email address'\n } }\n />\n\n <PhoneInput\n field={ {\n id: 'yourPhone',\n name: 'yourPhone'\n } }\n label={ {\n text: 'A number we can reach you on'\n } }\n />\n\n <Textarea\n field={ {\n id: 'yourMessage',\n name: 'yourMessage',\n } }\n label={ {\n text: 'Your message'\n } }\n />\n\n <InputCheckbox\n field={ {\n defaultChecked: hasConsent,\n id: 'consentCheckbox1',\n name: 'consentCheckbox1',\n value: 'consentIsGiven',\n onChange: (event: React.ChangeEvent<HTMLInputElement>) => handleConsentClick(event)\n } }\n label={ {\n text: <span>By leaving this checked you are <strong>consenting</strong> to one of our support staff contacting you in the event that they need more information. <Tooltip icon=\"info\">More about why we might contact you.</Tooltip></span>\n } }\n />\n\n <div className=\"spaceBefore flexRow\">\n <SimpleButton\n label=\"Send Message\"\n id=\"demoSubmitButton1\"\n buttonType=\"submit\"\n buttonStyle={\n {\n color: 'primary'\n }\n }\n rightIcon={ {\n icon: 'telegram'\n } }\n />\n </div>\n </div>\n );\n};\n\nexport default DemoContactForm;"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AAKA,IAAAG,aAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,cAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AAAkE,SAAAD,wBAAAQ,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAV,uBAAA,YAAAA,CAAAQ,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAA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,CACE,CACF,CAAC;AAEV,CAAC;AAACM,OAAA,CAAAxC,eAAA,GAAAA,eAAA;AAAA,IAAAyC,QAAA,GAAAD,OAAA,CAAAjD,OAAA,GAEaS,eAAe","ignoreList":[]}
@@ -33,6 +33,12 @@ Object.defineProperty(exports, "capitalizeFirstLetter", {
33
33
  return _stringHelpers.capitalizeFirstLetter;
34
34
  }
35
35
  });
36
+ Object.defineProperty(exports, "clampToGraphemeMax", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _stringHelpers.clampToGraphemeMax;
40
+ }
41
+ });
36
42
  Object.defineProperty(exports, "createCompareValueOverride", {
37
43
  enumerable: true,
38
44
  get: function () {
@@ -201,6 +207,12 @@ Object.defineProperty(exports, "getBranchFromPath", {
201
207
  return _objectHelpers.getBranchFromPath;
202
208
  }
203
209
  });
210
+ Object.defineProperty(exports, "getCharacterCount", {
211
+ enumerable: true,
212
+ get: function () {
213
+ return _stringHelpers.getCharacterCount;
214
+ }
215
+ });
204
216
  Object.defineProperty(exports, "getInitialsOrAcronym", {
205
217
  enumerable: true,
206
218
  get: function () {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_ageHelpers","require","_arrayHelpers","_dataHelpers","_dateHelpers","_formatters","_numberHelpers","_stringHelpers","_objectHelpers"],"sources":["../../../src/helpers/index.ts"],"sourcesContent":["export {\n getMinAge,\n getMaxAge,\n getMinAndMaxAges,\n validateBirthdate,\n isDateEntryComplete,\n getAgeInWeeks,\n getAgeInYears\n} from './ageHelpers';\n\nexport {\n binaryFindInArray,\n addAndSortArray,\n moveItemInArrayMutate,\n moveItemInArrayCopy,\n getRandomItemFromArray,\n getItemIndexWithinArray,\n getRoundedMedian,\n getMostOccurringBoolean,\n cssClassesArrayToString\n} from './arrayHelpers';\n\nexport {\n transformPlacesData,\n extractNamePieces\n} from './dataHelpers';\nexport type { NamePieces } from './dataHelpers';\n\nexport {\n dateToShortIsoString,\n isValidDate,\n dateToShortReadableDate,\n dateToShortReadableMonth,\n timeStampToShortReadableDate,\n dateToReadableTime,\n dateToShortReadableDateTime,\n getLastDateOfMonth,\n daysSince\n} from './dateHelpers';\n\nexport {\n USER_CURRENCY,\n intlCurrencyFormatter,\n intlNumberFormatter,\n formatNumberForLocale,\n formatAsCurrencyForLocale,\n getNumberAbbreviation,\n formatRoundedNumberWithAbbreviation,\n formatNumberWithAbbreviation,\n formatNumberForChartAxis,\n formatAsSimpleCurrencyForChartAxis,\n formatAsInternationalCurrencyForChartAxis,\n formatAsCurrencyWithAbbreviation,\n formatFileSize\n} from './formatters';\n\nexport {\n getRandomNumberBelow,\n getRandomBetweenInclusive,\n getRandomBetweenExclusive,\n hashCode,\n roundToDecimal,\n formatNumberToMinDigits,\n formatDigitalTime\n} from './numberHelpers';\n\nexport {\n richTextParser,\n capitalize,\n capitalizeFirstLetter,\n lowerCaseFirstLetter,\n useAnInsteadOfA,\n splitCamelCase,\n pluralize,\n pluralizeIfNeeded,\n getInitialsOrAcronym\n} from './stringHelpers';\n\nexport {\n objectsAreTheSame,\n isAnObject,\n createCompareValueOverride,\n deepMergeObjects,\n overrideMergeObjects,\n makeInheritanceObject,\n updateNestedProperty,\n filterObject,\n getArrayOfObjectKeys,\n getArrayOfReadableObjectKeys,\n getBranchFromPath,\n deepRemoveProps\n} from './objectHelpers';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAUA,IAAAC,aAAA,GAAAD,OAAA;AAYA,IAAAE,YAAA,GAAAF,OAAA;AAMA,IAAAG,YAAA,GAAAH,OAAA;AAYA,IAAAI,WAAA,GAAAJ,OAAA;AAgBA,IAAAK,cAAA,GAAAL,OAAA;AAUA,IAAAM,cAAA,GAAAN,OAAA;AAYA,IAAAO,cAAA,GAAAP,OAAA","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_ageHelpers","require","_arrayHelpers","_dataHelpers","_dateHelpers","_formatters","_numberHelpers","_stringHelpers","_objectHelpers"],"sources":["../../../src/helpers/index.ts"],"sourcesContent":["export {\n getMinAge,\n getMaxAge,\n getMinAndMaxAges,\n validateBirthdate,\n isDateEntryComplete,\n getAgeInWeeks,\n getAgeInYears\n} from './ageHelpers';\n\nexport {\n binaryFindInArray,\n addAndSortArray,\n moveItemInArrayMutate,\n moveItemInArrayCopy,\n getRandomItemFromArray,\n getItemIndexWithinArray,\n getRoundedMedian,\n getMostOccurringBoolean,\n cssClassesArrayToString\n} from './arrayHelpers';\n\nexport {\n transformPlacesData,\n extractNamePieces\n} from './dataHelpers';\nexport type { NamePieces } from './dataHelpers';\n\nexport {\n dateToShortIsoString,\n isValidDate,\n dateToShortReadableDate,\n dateToShortReadableMonth,\n timeStampToShortReadableDate,\n dateToReadableTime,\n dateToShortReadableDateTime,\n getLastDateOfMonth,\n daysSince\n} from './dateHelpers';\n\nexport {\n USER_CURRENCY,\n intlCurrencyFormatter,\n intlNumberFormatter,\n formatNumberForLocale,\n formatAsCurrencyForLocale,\n getNumberAbbreviation,\n formatRoundedNumberWithAbbreviation,\n formatNumberWithAbbreviation,\n formatNumberForChartAxis,\n formatAsSimpleCurrencyForChartAxis,\n formatAsInternationalCurrencyForChartAxis,\n formatAsCurrencyWithAbbreviation,\n formatFileSize\n} from './formatters';\n\nexport {\n getRandomNumberBelow,\n getRandomBetweenInclusive,\n getRandomBetweenExclusive,\n hashCode,\n roundToDecimal,\n formatNumberToMinDigits,\n formatDigitalTime\n} from './numberHelpers';\n\nexport {\n richTextParser,\n capitalize,\n capitalizeFirstLetter,\n lowerCaseFirstLetter,\n getCharacterCount,\n clampToGraphemeMax,\n useAnInsteadOfA,\n splitCamelCase,\n pluralize,\n pluralizeIfNeeded,\n getInitialsOrAcronym\n} from './stringHelpers';\n\nexport {\n objectsAreTheSame,\n isAnObject,\n createCompareValueOverride,\n deepMergeObjects,\n overrideMergeObjects,\n makeInheritanceObject,\n updateNestedProperty,\n filterObject,\n getArrayOfObjectKeys,\n getArrayOfReadableObjectKeys,\n getBranchFromPath,\n deepRemoveProps\n} from './objectHelpers';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAUA,IAAAC,aAAA,GAAAD,OAAA;AAYA,IAAAE,YAAA,GAAAF,OAAA;AAMA,IAAAG,YAAA,GAAAH,OAAA;AAYA,IAAAI,WAAA,GAAAJ,OAAA;AAgBA,IAAAK,cAAA,GAAAL,OAAA;AAUA,IAAAM,cAAA,GAAAN,OAAA;AAcA,IAAAO,cAAA,GAAAP,OAAA","ignoreList":[]}
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.useAnInsteadOfA = exports.splitCamelCase = exports.richTextParser = exports.pluralizeIfNeeded = exports.pluralize = exports.lowerCaseFirstLetter = exports.getInitialsOrAcronym = exports.capitalizeFirstLetter = exports.capitalize = void 0;
7
+ exports.useAnInsteadOfA = exports.splitCamelCase = exports.richTextParser = exports.pluralizeIfNeeded = exports.pluralize = exports.lowerCaseFirstLetter = exports.getInitialsOrAcronym = exports.getCharacterCount = exports.clampToGraphemeMax = exports.capitalizeFirstLetter = exports.capitalize = void 0;
8
8
  var _htmlReactParser = _interopRequireDefault(require("html-react-parser"));
9
9
  const richTextParser = (richText, supportEscapedCharacters) => {
10
10
  // Adjusts text to replace line breaks with <br/> tags
@@ -42,13 +42,59 @@ const capitalizeFirstLetter = pString => `${pString.substring(0, 1).toUpperCase(
42
42
  exports.capitalizeFirstLetter = capitalizeFirstLetter;
43
43
  const lowerCaseFirstLetter = pString => `${pString.substring(0, 1).toLowerCase()}${pString.substring(1)}`;
44
44
 
45
+ /**
46
+ * Splits a string into grapheme clusters so text metrics and clamping can share
47
+ * the same segmentation logic without forcing callers to pass pre-segmented data.
48
+ *
49
+ * @param {string} pString - The string to segment.
50
+ * @returns {string[]} The grapheme units in order, falling back to code points when Intl.Segmenter is unavailable.
51
+ */
52
+ exports.lowerCaseFirstLetter = lowerCaseFirstLetter;
53
+ const getGraphemeSegments = pString => {
54
+ if (typeof Intl !== 'undefined' && 'Segmenter' in Intl) {
55
+ const segmenter = new Intl.Segmenter(undefined, {
56
+ granularity: 'grapheme'
57
+ });
58
+ return Array.from(segmenter.segment(pString), ({
59
+ segment
60
+ }) => segment);
61
+ }
62
+ return Array.from(pString);
63
+ };
64
+
65
+ /**
66
+ * Counts user-perceived characters (grapheme clusters) so emojis and composed
67
+ * characters such as accented letters count as one.
68
+ *
69
+ * @param {string} pString - A string of text.
70
+ * @returns {number} The number of grapheme clusters, falling back to code points where Intl.Segmenter is unavailable.
71
+ */
72
+ const getCharacterCount = pString => getGraphemeSegments(pString).length;
73
+
74
+ /**
75
+ * Truncates a string to a maximum number of grapheme clusters without splitting
76
+ * an emoji or composed character in half.
77
+ *
78
+ * @param {string} pString - A string of text.
79
+ * @param {number} maxAllowed - The maximum number of user-perceived characters to keep.
80
+ * @returns {string} The truncated string, or the unchanged pString if it is already within the limit.
81
+ */
82
+ exports.getCharacterCount = getCharacterCount;
83
+ const clampToGraphemeMax = (pString, maxAllowed) => {
84
+ const graphemeSegments = getGraphemeSegments(pString);
85
+ if (graphemeSegments.length <= maxAllowed) {
86
+ return pString;
87
+ }
88
+ return graphemeSegments.slice(0, maxAllowed).join('');
89
+ };
90
+
45
91
  /**
46
92
  * Determines if "an" should be used instead of "a" before the given word.
47
93
  *
48
94
  * @param {string} word - The word to check.
49
95
  * @returns {boolean} True if "an" should be used, false otherwise.
50
96
  */
51
- exports.lowerCaseFirstLetter = lowerCaseFirstLetter;
97
+ exports.clampToGraphemeMax = clampToGraphemeMax;
52
98
  const useAnInsteadOfA = word => {
53
99
  const lettersRequiringAn = ['a', 'e', 'i', 'o', 'u', 'h'];
54
100
  const firstLetter = word.substring(0, 1).toLowerCase();
@@ -1 +1 @@
1
- {"version":3,"file":"stringHelpers.js","names":["_htmlReactParser","_interopRequireDefault","require","richTextParser","richText","supportEscapedCharacters","adjustedText","split","join","parse","exports","capitalize","pString","substring","toUpperCase","toLowerCase","capitalizeFirstLetter","lowerCaseFirstLetter","useAnInsteadOfA","word","lettersRequiringAn","firstLetter","includes","splitCamelCase","replace","pluralize","endsWith","slice","pluralizeIfNeeded","count","getInitialsOrAcronym","map","piece"],"sources":["../../../src/helpers/stringHelpers.ts"],"sourcesContent":["import React from 'react';\nimport parse from 'html-react-parser';\n\nexport const richTextParser = (richText: string, supportEscapedCharacters: boolean): string | React.JSX.Element | React.JSX.Element[] => {\n // Adjusts text to replace line breaks with <br/> tags\n const adjustedText = richText.split('\\r\\n').join('<br/>');\n if (supportEscapedCharacters) {\n return parse(adjustedText);\n }\n return parse(richText);\n};\n\n/**\n * Takes a string and returns it with the first character capitalized and the remaining characters as lowercase.\n *\n * @param {string} pString - A string of text.\n * @returns {string} The capitalized string or the unchanged pString if anything other than a string is sent to it.\n */\nexport const capitalize = (pString: string): string => `${ pString.substring(0, 1).toUpperCase() }${ pString.substring(1).toLowerCase() }`;\n\n/**\n * Capitalizes the first letter of the given string.\n *\n * @param {string} pString - A string of text.\n * @returns {string} The string with the first letter capitalized, or the unchanged pString if it's not a string.\n */\nexport const capitalizeFirstLetter = (pString: string): string => `${ pString.substring(0, 1).toUpperCase() }${ pString.substring(1) }`;\n\n/**\n * Converts the first letter of the given string to lowercase.\n *\n * @param {string} pString - A string of text.\n * @returns {string} The string with the first letter converted to lowercase, or the unchanged pString if it's not a string.\n */\nexport const lowerCaseFirstLetter = (pString: string): string => `${ pString.substring(0, 1).toLowerCase() }${ pString.substring(1) }`;\n\n/**\n * Determines if \"an\" should be used instead of \"a\" before the given word.\n *\n * @param {string} word - The word to check.\n * @returns {boolean} True if \"an\" should be used, false otherwise.\n */\nexport const useAnInsteadOfA = (word: string): boolean => {\n const lettersRequiringAn = ['a', 'e', 'i', 'o', 'u', 'h'];\n const firstLetter = word.substring(0, 1).toLowerCase();\n return lettersRequiringAn.includes(firstLetter);\n};\n\nexport const splitCamelCase = (pString: string): string => pString\n// Single regex to handle all cases: lowercase followed by uppercase/number, or number followed by letter\n .replace(/([a-z])([A-Z0-9])|([0-9])([a-zA-Z])/g, '$1$3 $2$4')\n// Insert a space between capital letters and lowercase letters where missing\n .replace(/([A-Z])([A-Z][a-z])/g, '$1 $2')\n// Convert the entire string to lowercase for consistency\n .toLowerCase();\n\nexport const pluralize = (pString: string): string => {\n if (pString.endsWith('y')) {\n // If the word ends with 'y', replace 'y' with 'ies'\n return `${ pString.slice(0, -1) }ies`;\n } if (pString.endsWith('s') || pString.endsWith('x') || pString.endsWith('z') || pString.endsWith('ch') || pString.endsWith('sh')) {\n // If the word ends with s, x, z, ch, or sh, add 'es'\n return `${ pString }es`;\n }\n // For other cases, just add 's'\n return `${ pString }s`;\n};\n\nexport const pluralizeIfNeeded = (pString: string, count: number): string => {\n if (count && count > 1) {\n return pluralize(pString);\n }\n return pString;\n};\n\nexport const getInitialsOrAcronym = (pString: string): string => {\n return pString.split(' ').map((piece) => capitalize(piece.substring(0, 1))).join('');\n};\n"],"mappings":";;;;;;;AACA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEO,MAAMC,cAAc,GAAGA,CAACC,QAAgB,EAAEC,wBAAiC,KAAuD;EACvI;EACA,MAAMC,YAAY,GAAGF,QAAQ,CAACG,KAAK,CAAC,MAAM,CAAC,CAACC,IAAI,CAAC,OAAO,CAAC;EACzD,IAAIH,wBAAwB,EAAE;IAC5B,OAAO,IAAAI,wBAAK,EAACH,YAAY,CAAC;EAC5B;EACA,OAAO,IAAAG,wBAAK,EAACL,QAAQ,CAAC;AACxB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AALAM,OAAA,CAAAP,cAAA,GAAAA,cAAA;AAMO,MAAMQ,UAAU,GAAIC,OAAe,IAAa,GAAIA,OAAO,CAACC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC,GAAKF,OAAO,CAACC,SAAS,CAAC,CAAC,CAAC,CAACE,WAAW,CAAC,CAAC,EAAG;;AAE1I;AACA;AACA;AACA;AACA;AACA;AALAL,OAAA,CAAAC,UAAA,GAAAA,UAAA;AAMO,MAAMK,qBAAqB,GAAIJ,OAAe,IAAa,GAAIA,OAAO,CAACC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC,GAAKF,OAAO,CAACC,SAAS,CAAC,CAAC,CAAC,EAAG;;A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IAAI,CAAC,IAAId,OAAO,CAACc,QAAQ,CAAC,IAAI,CAAC,EAAE;IACjI;IACA,OAAO,GAAId,OAAO,IAAK;EACzB;EACA;EACA,OAAO,GAAIA,OAAO,GAAI;AACxB,CAAC;AAACF,OAAA,CAAAe,SAAA,GAAAA,SAAA;AAEK,MAAMG,iBAAiB,GAAGA,CAAChB,OAAe,EAAEiB,KAAa,KAAa;EAC3E,IAAIA,KAAK,IAAIA,KAAK,GAAG,CAAC,EAAE;IACtB,OAAOJ,SAAS,CAACb,OAAO,CAAC;EAC3B;EACA,OAAOA,OAAO;AAChB,CAAC;AAACF,OAAA,CAAAkB,iBAAA,GAAAA,iBAAA;AAEK,MAAME,oBAAoB,GAAIlB,OAAe,IAAa;EAC/D,OAAOA,OAAO,CAACL,KAAK,CAAC,GAAG,CAAC,CAACwB,GAAG,CAAEC,KAAK,IAAKrB,UAAU,CAACqB,KAAK,CAACnB,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAACL,IAAI,CAAC,EAAE,CAAC;AACtF,CAAC;AAACE,OAAA,CAAAoB,oBAAA,GAAAA,oBAAA","ignoreList":[]}
1
+ {"version":3,"file":"stringHelpers.js","names":["_htmlReactParser","_interopRequireDefault","require","richTextParser","richText","supportEscapedCharacters","adjustedText","split","join","parse","exports","capitalize","pString","substring","toUpperCase","toLowerCase","capitalizeFirstLetter","lowerCaseFirstLetter","getGraphemeSegments","Intl","segmenter","Segmenter","undefined","granularity","Array","from","segment","getCharacterCount","length","clampToGraphemeMax","maxAllowed","graphemeSegments","slice","useAnInsteadOfA","word","lettersRequiringAn","firstLetter","includes","splitCamelCase","replace","pluralize","endsWith","pluralizeIfNeeded","count","getInitialsOrAcronym","map","piece"],"sources":["../../../src/helpers/stringHelpers.ts"],"sourcesContent":["import React from 'react';\nimport parse from 'html-react-parser';\n\nexport const richTextParser = (richText: string, supportEscapedCharacters: boolean): string | React.JSX.Element | React.JSX.Element[] => {\n // Adjusts text to replace line breaks with <br/> tags\n const adjustedText = richText.split('\\r\\n').join('<br/>');\n if (supportEscapedCharacters) {\n return parse(adjustedText);\n }\n return parse(richText);\n};\n\n/**\n * Takes a string and returns it with the first character capitalized and the remaining characters as lowercase.\n *\n * @param {string} pString - A string of text.\n * @returns {string} The capitalized string or the unchanged pString if anything other than a string is sent to it.\n */\nexport const capitalize = (pString: string): string => `${ pString.substring(0, 1).toUpperCase() }${ pString.substring(1).toLowerCase() }`;\n\n/**\n * Capitalizes the first letter of the given string.\n *\n * @param {string} pString - A string of text.\n * @returns {string} The string with the first letter capitalized, or the unchanged pString if it's not a string.\n */\nexport const capitalizeFirstLetter = (pString: string): string => `${ pString.substring(0, 1).toUpperCase() }${ pString.substring(1) }`;\n\n/**\n * Converts the first letter of the given string to lowercase.\n *\n * @param {string} pString - A string of text.\n * @returns {string} The string with the first letter converted to lowercase, or the unchanged pString if it's not a string.\n */\nexport const lowerCaseFirstLetter = (pString: string): string => `${ pString.substring(0, 1).toLowerCase() }${ pString.substring(1) }`;\n\n/**\n * Splits a string into grapheme clusters so text metrics and clamping can share\n * the same segmentation logic without forcing callers to pass pre-segmented data.\n *\n * @param {string} pString - The string to segment.\n * @returns {string[]} The grapheme units in order, falling back to code points when Intl.Segmenter is unavailable.\n */\nconst getGraphemeSegments = (pString: string): string[] => {\n if (typeof Intl !== 'undefined' && 'Segmenter' in Intl) {\n const segmenter = new Intl.Segmenter(undefined, { granularity: 'grapheme' });\n\n return Array.from(segmenter.segment(pString), ({ segment }) => segment);\n }\n\n return Array.from(pString);\n};\n\n/**\n * Counts user-perceived characters (grapheme clusters) so emojis and composed\n * characters such as accented letters count as one.\n *\n * @param {string} pString - A string of text.\n * @returns {number} The number of grapheme clusters, falling back to code points where Intl.Segmenter is unavailable.\n */\nexport const getCharacterCount = (pString: string): number => getGraphemeSegments(pString).length;\n\n/**\n * Truncates a string to a maximum number of grapheme clusters without splitting\n * an emoji or composed character in half.\n *\n * @param {string} pString - A string of text.\n * @param {number} maxAllowed - The maximum number of user-perceived characters to keep.\n * @returns {string} The truncated string, or the unchanged pString if it is already within the limit.\n */\nexport const clampToGraphemeMax = (pString: string, maxAllowed: number): string => {\n const graphemeSegments = getGraphemeSegments(pString);\n\n if (graphemeSegments.length <= maxAllowed) {\n return pString;\n }\n\n return graphemeSegments.slice(0, maxAllowed).join('');\n};\n\n/**\n * Determines if \"an\" should be used instead of \"a\" before the given word.\n *\n * @param {string} word - The word to check.\n * @returns {boolean} True if \"an\" should be used, false otherwise.\n */\nexport const useAnInsteadOfA = (word: string): boolean => {\n const lettersRequiringAn = ['a', 'e', 'i', 'o', 'u', 'h'];\n const firstLetter = word.substring(0, 1).toLowerCase();\n return lettersRequiringAn.includes(firstLetter);\n};\n\nexport const splitCamelCase = (pString: string): string => pString\n// Single regex to handle all cases: lowercase followed by uppercase/number, or number followed by letter\n .replace(/([a-z])([A-Z0-9])|([0-9])([a-zA-Z])/g, '$1$3 $2$4')\n// Insert a space between capital letters and lowercase letters where missing\n .replace(/([A-Z])([A-Z][a-z])/g, '$1 $2')\n// Convert the entire string to lowercase for consistency\n .toLowerCase();\n\nexport const pluralize = (pString: string): string => {\n if (pString.endsWith('y')) {\n // If the word ends with 'y', replace 'y' with 'ies'\n return `${ pString.slice(0, -1) }ies`;\n } if (pString.endsWith('s') || pString.endsWith('x') || pString.endsWith('z') || pString.endsWith('ch') || pString.endsWith('sh')) {\n // If the word ends with s, x, z, ch, or sh, add 'es'\n return `${ pString }es`;\n }\n // For other cases, just add 's'\n return `${ pString }s`;\n};\n\nexport const pluralizeIfNeeded = (pString: string, count: number): string => {\n if (count && count > 1) {\n return pluralize(pString);\n }\n return pString;\n};\n\nexport const getInitialsOrAcronym = (pString: string): string => {\n return pString.split(' ').map((piece) => capitalize(piece.substring(0, 1))).join('');\n};\n"],"mappings":";;;;;;;AACA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEO,MAAMC,cAAc,GAAGA,CAACC,QAAgB,EAAEC,wBAAiC,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AAAkC,oBAAA,GAAAA,oBAAA","ignoreList":[]}
@@ -11,6 +11,9 @@ const useOnEdgeProximityDetect = ({
11
11
  contentRef,
12
12
  requiresRecalc
13
13
  }) => {
14
+ // Only the shift classes this hook applied, so a consumer supplied
15
+ // customCssClass such as "shiftDown" is never stripped
16
+ const appliedShiftClasses = (0, _react.useRef)([]);
14
17
  const xAxisOverride = ({
15
18
  left,
16
19
  width,
@@ -45,6 +48,10 @@ const useOnEdgeProximityDetect = ({
45
48
  };
46
49
  (0, _react.useEffect)(() => {
47
50
  if (wrapperRef.current && contentRef.current && triggerRef.current && document && document.body) {
51
+ // Clear the previous run's shift, otherwise the content is measured in its
52
+ // already-shifted position and can accumulate opposing shift classes
53
+ appliedShiftClasses.current.forEach(cssClass => wrapperRef.current?.classList.remove(cssClass));
54
+ appliedShiftClasses.current = [];
48
55
  wrapperRef.current.classList.add('measuring');
49
56
  const {
50
57
  clientWidth,
@@ -58,22 +65,23 @@ const useOnEdgeProximityDetect = ({
58
65
  } = contentRef.current.getBoundingClientRect();
59
66
 
60
67
  // Check if it needs x-axis or y-axis adjustment
61
- const xAxisOverrideCssClass = xAxisOverride({
68
+ const applyShift = cssClass => {
69
+ if (!cssClass || !wrapperRef.current || wrapperRef.current.classList.contains(cssClass)) {
70
+ return;
71
+ }
72
+ wrapperRef.current.classList.add(cssClass);
73
+ appliedShiftClasses.current.push(cssClass);
74
+ };
75
+ applyShift(xAxisOverride({
62
76
  left,
63
77
  width,
64
78
  clientWidth
65
- });
66
- if (xAxisOverrideCssClass) {
67
- wrapperRef.current.classList.add(xAxisOverrideCssClass);
68
- }
69
- const yAxisOverrideCssClass = yAxisOverride({
79
+ }));
80
+ applyShift(yAxisOverride({
70
81
  top,
71
82
  height,
72
83
  clientHeight
73
- });
74
- if (yAxisOverrideCssClass) {
75
- wrapperRef.current.classList.add(yAxisOverrideCssClass);
76
- }
84
+ }));
77
85
  wrapperRef.current.classList.remove('measuring');
78
86
  }
79
87
  }, [triggerRef, wrapperRef, contentRef, requiresRecalc]);
@@ -1 +1 @@
1
- {"version":3,"file":"EdgeProximityDetect.js","names":["_react","require","useOnEdgeProximityDetect","triggerRef","wrapperRef","contentRef","requiresRecalc","xAxisOverride","left","width","clientWidth","yAxisOverride","top","height","clientHeight","useEffect","current","document","body","classList","add","getBoundingClientRect","xAxisOverrideCssClass","yAxisOverrideCssClass","remove","exports"],"sources":["../../../src/hooks/EdgeProximityDetect.ts"],"sourcesContent":["import React, { useEffect } from 'react';\n\ninterface UseOnEdgeProximityDetectProps {\n triggerRef: React.RefObject<HTMLElement>;\n wrapperRef: React.RefObject<HTMLElement>;\n contentRef: React.RefObject<HTMLElement>;\n requiresRecalc: boolean;\n preferredPlacement?: 'right-middle' | 'right-top' | 'right-bottom' | 'left-middle' | 'left-top' | 'left-bottom' | 'top-middle' | 'top-top' | 'top-bottom' | 'bottom-middle' | 'bottom-top' | 'bottom-bottom';\n}\n\nexport const useOnEdgeProximityDetect = (\n {\n triggerRef,\n wrapperRef,\n contentRef,\n requiresRecalc\n }\n :\n UseOnEdgeProximityDetectProps\n) => {\n const xAxisOverride = (\n {\n left,\n width,\n clientWidth\n }\n :\n {\n left: number;\n width: number;\n clientWidth: number\n }\n ) => {\n // Too close to left\n if (left < 0) {\n return 'shiftRight';\n }\n\n // Too close to right\n if (left + width > clientWidth) {\n return 'shiftLeft';\n }\n return '';\n };\n\n const yAxisOverride = (\n {\n top,\n height,\n clientHeight\n }\n :\n {\n top: number;\n height: number;\n clientHeight: number\n }\n ) => {\n // Too close to top\n if (top - height < 0) {\n return 'shiftDown';\n }\n\n // Too close to bottom\n if (top + height > clientHeight) {\n return 'shiftUp';\n }\n return '';\n };\n\n useEffect(() => {\n if (\n wrapperRef.current\n && contentRef.current\n && triggerRef.current\n && document\n && document.body\n ) {\n wrapperRef.current.classList.add('measuring');\n const { clientWidth, clientHeight } = document.body;\n const {\n width, height, top, left\n } = contentRef.current.getBoundingClientRect();\n\n // Check if it needs x-axis or y-axis adjustment\n const xAxisOverrideCssClass = xAxisOverride({ left, width, clientWidth });\n if (xAxisOverrideCssClass) {\n wrapperRef.current.classList.add(xAxisOverrideCssClass);\n }\n\n const yAxisOverrideCssClass = yAxisOverride({ top, height, clientHeight });\n if (yAxisOverrideCssClass) {\n wrapperRef.current.classList.add(yAxisOverrideCssClass);\n }\n\n wrapperRef.current.classList.remove('measuring');\n }\n }, [triggerRef, wrapperRef, contentRef, requiresRecalc]);\n\n return {};\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAUO,MAAMC,wBAAwB,GAAGA,CACtC;EACEC,UAAU;EACVC,UAAU;EACVC,UAAU;EACVC;AAG0B,CAAC,KAC1B;EACH,MAAMC,aAAa,GAAGA,CACpB;IACEC,IAAI;IACJC,KAAK;IACLC;EAOF,CAAC,KACE;IACH;IACA,IAAIF,IAAI,GAAG,CAAC,EAAE;MACZ,OAAO,YAAY;IACrB;;IAEA;IACA,IAAIA,IAAI,GAAGC,KAAK,GAAGC,WAAW,EAAE;MAC9B,OAAO,WAAW;IACpB;IACA,OAAO,EAAE;EACX,CAAC;EAED,MAAMC,aAAa,GAAGA,CACpB;IACEC,GAAG;IACHC,MAAM;IACNC;EAOF,CAAC,KACE;IACH;IACA,IAAIF,GAAG,GAAGC,MAAM,GAAG,CAAC,EAAE;MACpB,OAAO,WAAW;IACpB;;IAEA;IACA,IAAID,GAAG,GAAGC,MAAM,GAAGC,YAAY,EAAE;MAC/B,OAAO,SAAS;IAClB;IACA,OAAO,EAAE;EACX,CAAC;EAED,IAAAC,gBAAS,EAAC,MAAM;IACd,IACEX,UAAU,CAACY,OAAO,IACfX,UAAU,CAACW,OAAO,IAClBb,UAAU,CAACa,OAAO,IAClBC,QAAQ,IACRA,QAAQ,CAACC,IAAI,EAChB;MACAd,UAAU,CAACY,OAAO,CAACG,SAAS,CAACC,GAAG,CAAC,WAAW,CAAC;MAC7C,MAAM;QAAEV,WAAW;QAAEI;MAAa,CAAC,GAAGG,QAAQ,CAACC,IAAI;MACnD,MAAM;QACJT,KAAK;QAAEI,MAAM;QAAED,GAAG;QAAEJ;MACtB,CAAC,GAAGH,UAAU,CAACW,OAAO,CAACK,qBAAqB,CAAC,CAAC;;MAE9C;MACA,MAAMC,qBAAqB,GAAGf,aAAa,CAAC;QAAEC,IAAI;QAAEC,KAAK;QAAEC;MAAY,CAAC,CAAC;MACzE,IAAIY,qBAAqB,EAAE;QACzBlB,UAAU,CAACY,OAAO,CAACG,SAAS,CAACC,GAAG,CAACE,qBAAqB,CAAC;MACzD;MAEA,MAAMC,qBAAqB,GAAGZ,aAAa,CAAC;QAAEC,GAAG;QAAEC,MAAM;QAAEC;MAAa,CAAC,CAAC;MAC1E,IAAIS,qBAAqB,EAAE;QACzBnB,UAAU,CAACY,OAAO,CAACG,SAAS,CAACC,GAAG,CAACG,qBAAqB,CAAC;MACzD;MAEAnB,UAAU,CAACY,OAAO,CAACG,SAAS,CAACK,MAAM,CAAC,WAAW,CAAC;IAClD;EACF,CAAC,EAAE,CAACrB,UAAU,EAAEC,UAAU,EAAEC,UAAU,EAAEC,cAAc,CAAC,CAAC;EAExD,OAAO,CAAC,CAAC;AACX,CAAC;AAACmB,OAAA,CAAAvB,wBAAA,GAAAA,wBAAA","ignoreList":[]}
1
+ {"version":3,"file":"EdgeProximityDetect.js","names":["_react","require","useOnEdgeProximityDetect","triggerRef","wrapperRef","contentRef","requiresRecalc","appliedShiftClasses","useRef","xAxisOverride","left","width","clientWidth","yAxisOverride","top","height","clientHeight","useEffect","current","document","body","forEach","cssClass","classList","remove","add","getBoundingClientRect","applyShift","contains","push","exports"],"sources":["../../../src/hooks/EdgeProximityDetect.ts"],"sourcesContent":["import React, { useEffect, useRef } from 'react';\n\ninterface UseOnEdgeProximityDetectProps {\n triggerRef: React.RefObject<HTMLElement>;\n wrapperRef: React.RefObject<HTMLElement>;\n contentRef: React.RefObject<HTMLElement>;\n requiresRecalc: boolean;\n preferredPlacement?: 'right-middle' | 'right-top' | 'right-bottom' | 'left-middle' | 'left-top' | 'left-bottom' | 'top-middle' | 'top-top' | 'top-bottom' | 'bottom-middle' | 'bottom-top' | 'bottom-bottom';\n}\n\nexport const useOnEdgeProximityDetect = (\n {\n triggerRef,\n wrapperRef,\n contentRef,\n requiresRecalc\n }\n :\n UseOnEdgeProximityDetectProps\n) => {\n // Only the shift classes this hook applied, so a consumer supplied\n // customCssClass such as \"shiftDown\" is never stripped\n const appliedShiftClasses = useRef<string[]>([]);\n\n const xAxisOverride = (\n {\n left,\n width,\n clientWidth\n }\n :\n {\n left: number;\n width: number;\n clientWidth: number\n }\n ) => {\n // Too close to left\n if (left < 0) {\n return 'shiftRight';\n }\n\n // Too close to right\n if (left + width > clientWidth) {\n return 'shiftLeft';\n }\n return '';\n };\n\n const yAxisOverride = (\n {\n top,\n height,\n clientHeight\n }\n :\n {\n top: number;\n height: number;\n clientHeight: number\n }\n ) => {\n // Too close to top\n if (top - height < 0) {\n return 'shiftDown';\n }\n\n // Too close to bottom\n if (top + height > clientHeight) {\n return 'shiftUp';\n }\n return '';\n };\n\n useEffect(() => {\n if (\n wrapperRef.current\n && contentRef.current\n && triggerRef.current\n && document\n && document.body\n ) {\n // Clear the previous run's shift, otherwise the content is measured in its\n // already-shifted position and can accumulate opposing shift classes\n appliedShiftClasses.current.forEach((cssClass) => wrapperRef.current?.classList.remove(cssClass));\n appliedShiftClasses.current = [];\n\n wrapperRef.current.classList.add('measuring');\n const { clientWidth, clientHeight } = document.body;\n const {\n width, height, top, left\n } = contentRef.current.getBoundingClientRect();\n\n // Check if it needs x-axis or y-axis adjustment\n const applyShift = (cssClass: string) => {\n if (!cssClass || !wrapperRef.current || wrapperRef.current.classList.contains(cssClass)) {\n return;\n }\n wrapperRef.current.classList.add(cssClass);\n appliedShiftClasses.current.push(cssClass);\n };\n\n applyShift(xAxisOverride({ left, width, clientWidth }));\n applyShift(yAxisOverride({ top, height, clientHeight }));\n\n wrapperRef.current.classList.remove('measuring');\n }\n }, [trigg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GG,QAAQ,CAACC,IAAI;MACnD,MAAM;QACJT,KAAK;QAAEI,MAAM;QAAED,GAAG;QAAEJ;MACtB,CAAC,GAAGL,UAAU,CAACa,OAAO,CAACQ,qBAAqB,CAAC,CAAC;;MAE9C;MACA,MAAMC,UAAU,GAAIL,QAAgB,IAAK;QACvC,IAAI,CAACA,QAAQ,IAAI,CAAClB,UAAU,CAACc,OAAO,IAAId,UAAU,CAACc,OAAO,CAACK,SAAS,CAACK,QAAQ,CAACN,QAAQ,CAAC,EAAE;UACvF;QACF;QACAlB,UAAU,CAACc,OAAO,CAACK,SAAS,CAACE,GAAG,CAACH,QAAQ,CAAC;QAC1Cf,mBAAmB,CAACW,OAAO,CAACW,IAAI,CAACP,QAAQ,CAAC;MAC5C,CAAC;MAEDK,UAAU,CAAClB,aAAa,CAAC;QAAEC,IAAI;QAAEC,KAAK;QAAEC;MAAY,CAAC,CAAC,CAAC;MACvDe,UAAU,CAACd,aAAa,CAAC;QAAEC,GAAG;QAAEC,MAAM;QAAEC;MAAa,CAAC,CAAC,CAAC;MAExDZ,UAAU,CAACc,OAAO,CAACK,SAAS,CAACC,MAAM,CAAC,WAAW,CAAC;IAClD;EACF,CAAC,EAAE,CAACrB,UAAU,EAAEC,UAAU,EAAEC,UAAU,EAAEC,cAAc,CAAC,CAAC;EAExD,OAAO,CAAC,CAAC;AACX,CAAC;AAACwB,OAAA,CAAA5B,wBAAA,GAAAA,wBAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"headerText.interface.js","names":[],"sources":["../../../src/interfaces/headerText.interface.ts"],"sourcesContent":["import React from 'react';\nimport { NotificationIconProps } from '../components/design/icons/notificationIcon/NotificationIcon';\nimport { ButtonProps } from '../components/form/buttons/button.interface';\nimport { IconProps } from '../components/design/icons/basicIcon/Icon';\nimport { NotificationsButtonProps } from '../components/form/buttons/notificationsButton/NotificationsButton';\n\nexport type SimpleHeaderButton = ButtonProps & {\n kind?: 'simple'\n};\n\nexport type NotificationsHeaderButton = Omit<NotificationsButtonProps, 'label'> & {\n kind?: 'notifications'\n};\n\nexport type HeaderButtonTypes = SimpleHeaderButton | NotificationsHeaderButton;\n\nexport interface HeaderTextInterface {\n leftIcon?: IconProps;\n rightIcon?: IconProps;\n text?: string;\n notificationIcon?: NotificationIconProps;\n buttons?: HeaderButtonTypes[];\n children?: React.ReactNode;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"headerText.interface.js","names":[],"sources":["../../../src/interfaces/headerText.interface.ts"],"sourcesContent":["import React from 'react';\nimport { NotificationIconProps } from '../components/design/icons/notificationIcon/NotificationIcon';\nimport { ButtonProps } from '../components/form/buttons/button.interface';\nimport { IconProps } from '../components/design/icons/basicIcon/Icon';\nimport { NotificationsButtonProps } from '../components/form/buttons/notificationsButton/NotificationsButton';\n\nexport type SimpleHeaderButton = ButtonProps & {\n kind?: 'simple'\n};\n\nexport type NotificationsHeaderButton = Omit<NotificationsButtonProps, 'label'> & {\n kind?: 'notifications'\n};\n\nexport type HeaderButtonTypes = SimpleHeaderButton | NotificationsHeaderButton;\n\nexport interface HeaderTextInterface {\n leftIcon?: IconProps;\n rightIcon?: IconProps;\n text?: string;\n headingLevel?: 1 | 2 | 3 | 4 | 5 | 6;\n notificationIcon?: NotificationIconProps;\n buttons?: HeaderButtonTypes[];\n children?: React.ReactNode;\n}\n"],"mappings":"","ignoreList":[]}