@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
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.js","names":["_extends","React","useState","useRef","useEffect","useCallback","useOnClickOutside","Icon","useOnEdgeProximityDetect","Tooltip","props","triggerId","triggerStyle","icon","customCssClass","containsBlockElements","children","label","showPointer","visualIndicators","underline","colouredText","undefined","isOpen","setIsOpen","tooltipElement","triggerElement","contentElement","iconIsElement","isValidElement","triggerRef","wrapperRef","contentRef","requiresRecalc","handleSpecialKeyPresses","event","key","keyCode","current","addEventListener","createElement","role","ref","className","type","onClick","toString","id"],"sources":["../../../../../src/components/design/tooltip/Tooltip.tsx"],"sourcesContent":["'use client';\n\nimport React, { useState, useRef, useEffect, useCallback, ReactNode, ReactElement } from 'react';\nimport { useOnClickOutside } from '../../../hooks/ClickOutside';\nimport { Icon } from '../icons/basicIcon/Icon';\nimport { useOnEdgeProximityDetect } from '../../../hooks/EdgeProximityDetect';\nimport './tooltip.scss';\n\n// Define the props for Tooltip\nexport type TooltipProps =\n {\n triggerId?: string;\n icon?: ReactElement | string;\n customCssClass?: string;\n children: ReactNode;\n containsBlockElements?: boolean;\n triggerStyle?: 'icon';\n label?: string | ReactNode;\n showPointer?: boolean;\n }\n | {\n triggerId?: string;\n icon?: ReactElement | string;\n customCssClass?: string;\n children: ReactNode;\n containsBlockElements?: boolean;\n triggerStyle: 'text';\n label?: string | ReactNode;\n showPointer?: boolean;\n visualIndicators?: { underline?: boolean; colouredText?: boolean };\n };\n\nexport const Tooltip: React.FC<TooltipProps> = (props) => {\n const {\n triggerId,\n triggerStyle = 'icon',\n icon = 'info',\n customCssClass,\n containsBlockElements = false,\n children,\n label = 'Toggle tooltip open state',\n showPointer = true,\n // visualIndicators will be handled below\n } = props as any;\n\n // Only use visualIndicators if triggerStyle is 'text'\n const visualIndicators =\n triggerStyle === 'text'\n ? (props as { visualIndicators?: { underline?: boolean; colouredText?: boolean } }).visualIndicators ?? { underline: true, colouredText: true }\n : undefined;\n const [isOpen, setIsOpen] = useState(false);\n const tooltipElement = useRef<HTMLDivElement | HTMLSpanElement>(null);\n const triggerElement = useRef<HTMLButtonElement>(null);\n const contentElement = useRef<HTMLDivElement | HTMLSpanElement>(null);\n\n const iconIsElement = React.isValidElement(icon);\n\n useOnClickOutside(tooltipElement, () => setIsOpen(false));\n\n useOnEdgeProximityDetect({\n triggerRef: triggerElement,\n wrapperRef: tooltipElement,\n contentRef: contentElement,\n requiresRecalc: isOpen,\n });\n\n // Handle special key presses\n const handleSpecialKeyPresses = useCallback(\n (event: KeyboardEvent) => {\n if (event.key === 'Escape' || event.keyCode === 27) {\n setIsOpen(false);\n }\n },\n [setIsOpen],\n );\n\n useEffect(() => {\n if (tooltipElement.current) {\n tooltipElement.current.addEventListener('keydown', handleSpecialKeyPresses as EventListener);\n }\n }, [handleSpecialKeyPresses]);\n\n if (containsBlockElements) {\n return (\n <div\n role=\"tooltip\"\n ref={ tooltipElement as React.RefObject<HTMLDivElement> }\n className={ `tooltip tooltip_block ${ isOpen ? 'isOpen' : '' } ${ triggerStyle === 'text' && 'textDisplay' } ${ customCssClass || '' }` }\n >\n <button\n ref={ triggerElement }\n type=\"button\"\n onClick={ () => setIsOpen(!isOpen) }\n className={ `button ${ triggerStyle === 'text' ? 'text_only' : 'icon_only' } ${ triggerStyle === 'text' && !visualIndicators?.underline ? 'underline_off' : '' } ${ triggerStyle === 'text' && !visualIndicators?.colouredText ? 'colouredText_off' : '' }` }\n { ...(triggerId ? { 'id': triggerId, 'aria-describedby': `${ triggerId }_content` } : {}) }\n { ...(triggerStyle === 'icon' ? { 'aria-label': typeof label === 'string' ? label : undefined } : {}) }\n >\n { triggerStyle === 'icon' && (iconIsElement ? icon : <Icon icon={ icon.toString() } />) }\n { triggerStyle === 'text' && <span className=\"labelText\">{ label }</span> }\n </button>\n <div\n ref={ contentElement as React.RefObject<HTMLDivElement> }\n className={ `content ${ showPointer ? 'showPointer' : '' }` }\n { ...(triggerId ? { id: `${ triggerId }_content` } : {}) }\n >\n { children }\n </div>\n </div>\n );\n }\n\n return (\n <span\n ref={ tooltipElement as React.RefObject<HTMLSpanElement> }\n className={ `tooltip ${ isOpen ? 'isOpen' : '' } ${ triggerStyle === 'text' && 'textDisplay' } ${ customCssClass || '' }` }\n >\n <button\n ref={ triggerElement }\n type=\"button\"\n onClick={ () => setIsOpen(!isOpen) }\n className={ `button ${ triggerStyle === 'text' ? 'text_only' : 'icon_only' } ${ triggerStyle === 'text' && !visualIndicators?.underline ? 'underline_off' : '' } ${ triggerStyle === 'text' && !visualIndicators?.colouredText ? 'colouredText_off' : '' }` }\n { ...(triggerId ? { id: triggerId } : {}) }\n { ...(triggerStyle === 'icon' ? { 'aria-label': typeof label === 'string' ? label : undefined } : {}) }\n >\n { triggerStyle === 'icon' && (iconIsElement ? icon : <Icon icon={ icon.toString() } />) }\n { triggerStyle === 'text' && <span className=\"labelText\">{ label }</span> }\n </button>\n <span\n aria-hidden\n role=\"presentation\"\n ref={ contentElement as React.RefObject<HTMLSpanElement> }\n className={ `content ${ showPointer ? 'showPointer' : '' }` }\n { ...(triggerId ? { id: `${ triggerId }_content` } : {}) }\n >\n { children }\n </span>\n </span>\n );\n};\n\nexport default Tooltip;\n"],"mappings":"AAAA,YAAY;;AAAC,OAAAA,QAAA;AAEb,OAAOC,KAAK,IAAIC,QAAQ,EAAEC,MAAM,EAAEC,SAAS,EAAEC,WAAW,QAAiC,OAAO;AAChG,SAASC,iBAAiB,QAAQ,6BAA6B;AAC/D,SAASC,IAAI,QAAQ,yBAAyB;AAC9C,SAASC,wBAAwB,QAAQ,oCAAoC;AAC7E,OAAO,gBAAgB;;AAEvB;;AAwBA,OAAO,MAAMC,OAA+B,GAAIC,KAAK,IAAK;EACxD,MAAM;IACJC,SAAS;IACTC,YAAY,GAAG,MAAM;IACrBC,IAAI,GAAG,MAAM;IACbC,cAAc;IACdC,qBAAqB,GAAG,KAAK;IAC7BC,QAAQ;IACRC,KAAK,GAAG,2BAA2B;IACnCC,WAAW,GAAG;IACd;EACF,CAAC,GAAGR,KAAY;;EAEhB;EACA,MAAMS,gBAAgB,GACpBP,YAAY,KAAK,MAAM,GAClBF,KAAK,CAA4ES,gBAAgB,IAAI;IAAEC,SAAS,EAAE,IAAI;IAAEC,YAAY,EAAE;EAAK,CAAC,GAC7IC,SAAS;EACf,MAAM,CAACC,MAAM,EAAEC,SAAS,CAAC,GAAGtB,QAAQ,CAAC,KAAK,CAAC;EAC3C,MAAMuB,cAAc,GAAGtB,MAAM,CAAmC,IAAI,CAAC;EACrE,MAAMuB,cAAc,GAAGvB,MAAM,CAAoB,IAAI,CAAC;EACtD,MAAMwB,cAAc,GAAGxB,MAAM,CAAmC,IAAI,CAAC;EAErE,MAAMyB,aAAa,gBAAG3B,KAAK,CAAC4B,cAAc,CAAChB,IAAI,CAAC;EAEhDP,iBAAiB,CAACmB,cAAc,EAAE,MAAMD,SAAS,CAAC,KAAK,CAAC,CAAC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AG,eAAe,GAAG,EAAE,IAAMR,YAAY,KAAK,MAAM,IAAI,CAACO,gBAAgB,EAAEE,YAAY,GAAG,kBAAkB,GAAG,EAAE;EAAK,GACvPV,SAAS,GAAG;IAAEoC,EAAE,EAAEpC;EAAU,CAAC,GAAG,CAAC,CAAC,EAClCC,YAAY,KAAK,MAAM,GAAG;IAAE,YAAY,EAAE,OAAOK,KAAK,KAAK,QAAQ,GAAGA,KAAK,GAAGK;EAAU,CAAC,GAAG,CAAC,CAAC,GAElGV,YAAY,KAAK,MAAM,KAAKgB,aAAa,GAAGf,IAAI,gBAAGZ,KAAA,CAAAuC,aAAA,CAACjC,IAAI;IAACM,IAAI,EAAGA,IAAI,CAACiC,QAAQ,CAAC;EAAG,CAAE,CAAC,CAAC,EACrFlC,YAAY,KAAK,MAAM,iBAAIX,KAAA,CAAAuC,aAAA;IAAMG,SAAS,EAAC;EAAW,GAAG1B,KAAa,CAClE,CAAC,eACThB,KAAA,CAAAuC,aAAA,SAAAxC,QAAA;IACE,mBAAW;IACXyC,IAAI,EAAC,cAAc;IACnBC,GAAG,EAAGf,cAAoD;IAC1DgB,SAAS,EAAG,WAAYzB,WAAW,GAAG,aAAa,GAAG,EAAE;EAAK,GACvDP,SAAS,GAAG;IAAEoC,EAAE,EAAE,GAAIpC,SAAS;EAAY,CAAC,GAAG,CAAC,CAAC,GAErDK,QACE,CACF,CAAC;AAEX,CAAC;AAED,eAAeP,OAAO","ignoreList":[]}
1
+ {"version":3,"file":"Tooltip.js","names":["_extends","React","useState","useRef","useEffect","useCallback","useOnClickOutside","Icon","useOnEdgeProximityDetect","Tooltip","props","triggerId","triggerStyle","icon","customCssClass","containsBlockElements","children","label","showPointer","hoverDelay","visualIndicators","underline","colouredText","undefined","isOpen","setIsOpen","isHovered","setIsHovered","tooltipElement","triggerElement","contentElement","hoverTimer","iconIsElement","isValidElement","hasHoverDelay","isVisible","clearHoverTimer","current","clearTimeout","handleMouseEnter","setTimeout","handleMouseLeave","dismiss","handleTriggerClick","hoverHandlers","onMouseEnter","onMouseLeave","triggerRef","wrapperRef","contentRef","requiresRecalc","handleSpecialKeyPresses","event","key","keyCode","wrapper","addEventListener","removeEventListener","createElement","role","ref","className","type","onClick","toString","id"],"sources":["../../../../../src/components/design/tooltip/Tooltip.tsx"],"sourcesContent":["'use client';\n\nimport React, { useState, useRef, useEffect, useCallback, ReactNode, ReactElement } from 'react';\nimport { useOnClickOutside } from '../../../hooks/ClickOutside';\nimport { Icon } from '../icons/basicIcon/Icon';\nimport { useOnEdgeProximityDetect } from '../../../hooks/EdgeProximityDetect';\nimport './tooltip.scss';\n\n// Define the props for Tooltip\nexport type TooltipProps =\n {\n triggerId?: string;\n icon?: ReactElement | string;\n customCssClass?: string;\n children: ReactNode;\n containsBlockElements?: boolean;\n triggerStyle?: 'icon';\n label?: string | ReactNode;\n showPointer?: boolean;\n hoverDelay?: number;\n }\n | {\n triggerId?: string;\n icon?: ReactElement | string;\n customCssClass?: string;\n children: ReactNode;\n containsBlockElements?: boolean;\n triggerStyle: 'text';\n label?: string | ReactNode;\n showPointer?: boolean;\n hoverDelay?: number;\n visualIndicators?: { underline?: boolean; colouredText?: boolean };\n };\n\nexport const Tooltip: React.FC<TooltipProps> = (props) => {\n const {\n triggerId,\n triggerStyle = 'icon',\n icon = 'info',\n customCssClass,\n containsBlockElements = false,\n children,\n label = 'Toggle tooltip open state',\n showPointer = true,\n hoverDelay,\n // visualIndicators will be handled below\n } = props as any;\n\n // Only use visualIndicators if triggerStyle is 'text'\n const visualIndicators =\n triggerStyle === 'text'\n ? (props as { visualIndicators?: { underline?: boolean; colouredText?: boolean } }).visualIndicators ?? { underline: true, colouredText: true }\n : undefined;\n const [isOpen, setIsOpen] = useState(false);\n const [isHovered, setIsHovered] = useState(false);\n const tooltipElement = useRef<HTMLDivElement | HTMLSpanElement>(null);\n const triggerElement = useRef<HTMLButtonElement>(null);\n const contentElement = useRef<HTMLDivElement | HTMLSpanElement>(null);\n const hoverTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const iconIsElement = React.isValidElement(icon);\n\n // Hover is handled in css by default. It is only taken over by js when a delay is requested.\n const hasHoverDelay = typeof hoverDelay === 'number' && hoverDelay > 0;\n const isVisible = isOpen || isHovered;\n\n const clearHoverTimer = useCallback(() => {\n if (hoverTimer.current) {\n clearTimeout(hoverTimer.current);\n hoverTimer.current = null;\n }\n }, []);\n\n const handleMouseEnter = useCallback(() => {\n clearHoverTimer();\n hoverTimer.current = setTimeout(() => setIsHovered(true), hoverDelay);\n }, [clearHoverTimer, hoverDelay]);\n\n const handleMouseLeave = useCallback(() => {\n clearHoverTimer();\n setIsHovered(false);\n }, [clearHoverTimer]);\n\n // Single dismissal path, so every close route clears both the click and hover state\n const dismiss = useCallback(() => {\n clearHoverTimer();\n setIsHovered(false);\n setIsOpen(false);\n }, [clearHoverTimer]);\n\n const handleTriggerClick = useCallback(() => {\n if (isVisible) {\n dismiss();\n return;\n }\n clearHoverTimer();\n setIsOpen(true);\n }, [isVisible, dismiss, clearHoverTimer]);\n\n // Releasing the delay detaches the mouse handlers, so reset any hover state they left behind\n useEffect(() => {\n if (!hasHoverDelay) {\n clearHoverTimer();\n setIsHovered(false);\n }\n }, [hasHoverDelay, clearHoverTimer]);\n\n useEffect(() => clearHoverTimer, [clearHoverTimer]);\n\n const hoverHandlers = hasHoverDelay\n ? { onMouseEnter: handleMouseEnter, onMouseLeave: handleMouseLeave }\n : {};\n\n useOnClickOutside(tooltipElement, dismiss);\n\n useOnEdgeProximityDetect({\n triggerRef: triggerElement,\n wrapperRef: tooltipElement,\n contentRef: contentElement,\n requiresRecalc: isVisible,\n });\n\n // Handle special key presses\n const handleSpecialKeyPresses = useCallback(\n (event: KeyboardEvent) => {\n if (event.key === 'Escape' || event.keyCode === 27) {\n dismiss();\n }\n },\n [dismiss],\n );\n\n useEffect(() => {\n const wrapper = tooltipElement.current;\n if (!wrapper) {\n return undefined;\n }\n wrapper.addEventListener('keydown', handleSpecialKeyPresses as EventListener);\n return () => wrapper.removeEventListener('keydown', handleSpecialKeyPresses as EventListener);\n }, [handleSpecialKeyPresses]);\n\n if (containsBlockElements) {\n return (\n <div\n role=\"tooltip\"\n ref={ tooltipElement as React.RefObject<HTMLDivElement> }\n className={ `tooltip tooltip_block ${ isVisible ? 'isOpen' : '' } ${ hasHoverDelay ? 'hoverDelayed' : '' } ${ triggerStyle === 'text' ? 'textDisplay' : '' } ${ customCssClass || '' }` }\n { ...hoverHandlers }\n >\n <button\n ref={ triggerElement }\n type=\"button\"\n onClick={ handleTriggerClick }\n className={ `button ${ triggerStyle === 'text' ? 'text_only' : 'icon_only' } ${ triggerStyle === 'text' && !visualIndicators?.underline ? 'underline_off' : '' } ${ triggerStyle === 'text' && !visualIndicators?.colouredText ? 'colouredText_off' : '' }` }\n { ...(triggerId ? { 'id': triggerId, 'aria-describedby': `${ triggerId }_content` } : {}) }\n { ...(triggerStyle === 'icon' ? { 'aria-label': typeof label === 'string' ? label : undefined } : {}) }\n >\n { triggerStyle === 'icon' && (iconIsElement ? icon : <Icon icon={ icon.toString() } />) }\n { triggerStyle === 'text' && <span className=\"labelText\">{ label }</span> }\n </button>\n <div\n ref={ contentElement as React.RefObject<HTMLDivElement> }\n className={ `content ${ showPointer ? 'showPointer' : '' }` }\n { ...(triggerId ? { id: `${ triggerId }_content` } : {}) }\n >\n { children }\n </div>\n </div>\n );\n }\n\n return (\n <span\n ref={ tooltipElement as React.RefObject<HTMLSpanElement> }\n className={ `tooltip ${ isVisible ? 'isOpen' : '' } ${ hasHoverDelay ? 'hoverDelayed' : '' } ${ triggerStyle === 'text' ? 'textDisplay' : '' } ${ customCssClass || '' }` }\n { ...hoverHandlers }\n >\n <button\n ref={ triggerElement }\n type=\"button\"\n onClick={ handleTriggerClick }\n className={ `button ${ triggerStyle === 'text' ? 'text_only' : 'icon_only' } ${ triggerStyle === 'text' && !visualIndicators?.underline ? 'underline_off' : '' } ${ triggerStyle === 'text' && !visualIndicators?.colouredText ? 'colouredText_off' : '' }` }\n { ...(triggerId ? { id: triggerId } : {}) }\n { ...(triggerStyle === 'icon' ? { 'aria-label': typeof label === 'string' ? label : undefined } : {}) }\n >\n { triggerStyle === 'icon' && (iconIsElement ? icon : <Icon icon={ icon.toString() } />) }\n { triggerStyle === 'text' && <span className=\"labelText\">{ label }</span> }\n </button>\n <span\n aria-hidden\n role=\"presentation\"\n ref={ contentElement as React.RefObject<HTMLSpanElement> }\n className={ `content ${ showPointer ? 'showPointer' : '' }` }\n { ...(triggerId ? { id: `${ triggerId }_content` } : {}) }\n >\n { children }\n </span>\n </span>\n );\n};\n\nexport default Tooltip;\n"],"mappings":"AAAA,YAAY;;AAAC,OAAAA,QAAA;AAEb,OAAOC,KAAK,IAAIC,QAAQ,EAAEC,MAAM,EAAEC,SAAS,EAAEC,WAAW,QAAiC,OAAO;AAChG,SAASC,iBAAiB,QAAQ,6BAA6B;AAC/D,SAASC,IAAI,QAAQ,yBAAyB;AAC9C,SAASC,wBAAwB,QAAQ,oCAAoC;AAC7E,OAAO,gBAAgB;;AAEvB;;AA0BA,OAAO,MAAMC,OAA+B,GAAIC,KAAK,IAAK;EACxD,MAAM;IACJC,SAAS;IACTC,YAAY,GAAG,MAAM;IACrBC,IAAI,GAAG,MAAM;IACbC,cAAc;IACdC,qBAAqB,GAAG,KAAK;IAC7BC,QAAQ;IACRC,KAAK,GAAG,2BAA2B;IACnCC,WAAW,GAAG,IAAI;IAClBC;IACA;EACF,CAAC,GAAGT,KAAY;;EAEhB;EACA,MAAMU,gBAAgB,GACpBR,YAAY,KAAK,MAAM,GAClBF,KAAK,CAA4EU,gBAAgB,IAAI;IAAEC,SAAS,EAAE,IAAI;IAAEC,YAAY,EAAE;EAAK,CAAC,GAC7IC,SAAS;EACf,MAAM,CAACC,MAAM,EAAEC,SAAS,CAAC,GAAGvB,QAAQ,CAAC,KAAK,CAAC;EAC3C,MAAM,CAACwB,SAAS,EAAEC,YAAY,CAAC,GAAGzB,QAAQ,CAAC,KAAK,C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M,IAAI,EAAGA,IAAI,CAACmD,QAAQ,CAAC;EAAG,CAAE,CAAC,CAAC,EACrFpD,YAAY,KAAK,MAAM,iBAAIX,KAAA,CAAAyD,aAAA;IAAMG,SAAS,EAAC;EAAW,GAAG5C,KAAa,CAClE,CAAC,eACThB,KAAA,CAAAyD,aAAA,SAAA1D,QAAA;IACE,mBAAW;IACX2D,IAAI,EAAC,cAAc;IACnBC,GAAG,EAAG9B,cAAoD;IAC1D+B,SAAS,EAAG,WAAY3C,WAAW,GAAG,aAAa,GAAG,EAAE;EAAK,GACvDP,SAAS,GAAG;IAAEsD,EAAE,EAAE,GAAItD,SAAS;EAAY,CAAC,GAAG,CAAC,CAAC,GAErDK,QACE,CACF,CAAC;AAEX,CAAC;AAED,eAAeP,OAAO","ignoreList":[]}
@@ -93,7 +93,7 @@
93
93
  .tooltip.large .content:before {
94
94
  left: 160px;
95
95
  }
96
- .tooltip:hover .content, .tooltip.isOpen .content {
96
+ .tooltip:not(.hoverDelayed):hover .content, .tooltip.isOpen .content {
97
97
  display: block;
98
98
  }
99
99
  .tooltip.measuring .content {
@@ -19,7 +19,8 @@ export const FormField = ({
19
19
  validation,
20
20
  customContent,
21
21
  customCssClasses,
22
- separateLabelAndField = false
22
+ separateLabelAndField = false,
23
+ formContext
23
24
  }) => {
24
25
  const [isTouched, setIsTouched] = useState(false);
25
26
  const wrapperCssClass = `
@@ -64,9 +65,9 @@ export const FormField = ({
64
65
  case 'select':
65
66
  return /*#__PURE__*/React.createElement(Select, fieldProps);
66
67
  case 'checkbox':
67
- return new Error('Checkboxes require special handling. Please use the InputCheckbox component instead.');
68
+ throw new Error('Checkboxes require special handling. Please use the InputCheckbox component instead.');
68
69
  case 'file':
69
- return new Error('File inputs require special handling. Please use the DragAndDropFileUpload component instead.');
70
+ throw new Error('File inputs require special handling. Please use the DragAndDropFileUpload component instead.');
70
71
  case 'password':
71
72
  return /*#__PURE__*/React.createElement(InputText, fieldProps);
72
73
  case 'date':
@@ -85,7 +86,9 @@ export const FormField = ({
85
86
  isRequired: validation && typeof validation.required !== 'undefined',
86
87
  customContent
87
88
  };
88
- return /*#__PURE__*/React.createElement(HookFormWrapper, null, /*#__PURE__*/React.createElement("div", {
89
+ return /*#__PURE__*/React.createElement(HookFormWrapper, {
90
+ formContext: formContext
91
+ }, /*#__PURE__*/React.createElement("div", {
89
92
  className: wrapperCssClass,
90
93
  title: wrapperHoverText()
91
94
  }, /*#__PURE__*/React.createElement("label", {
@@ -94,7 +97,7 @@ export const FormField = ({
94
97
  htmlFor: field.id
95
98
  }, (!label?.position || label.position === 'left' || separateLabelAndField) && /*#__PURE__*/React.createElement(FormFieldLabel, labelProps), !separateLabelAndField && /*#__PURE__*/React.createElement("span", {
96
99
  className: "inputContainer"
97
- }, getFieldElement(), label?.position === 'inset' && /*#__PURE__*/React.createElement(FormFieldLabel, labelProps)), label?.position === 'right' && /*#__PURE__*/React.createElement(FormFieldLabel, labelProps), showSpinner && /*#__PURE__*/React.createElement(Spinner, null), field.type !== 'textarea' && /*#__PURE__*/React.createElement(ValidationMessages, {
100
+ }, getFieldElement(), label?.position === 'inset' && /*#__PURE__*/React.createElement(FormFieldLabel, labelProps)), label?.position === 'right' && /*#__PURE__*/React.createElement(FormFieldLabel, labelProps), showSpinner && /*#__PURE__*/React.createElement(Spinner, null), /*#__PURE__*/React.createElement(ValidationMessages, {
98
101
  name: field.name,
99
102
  validation: validation
100
103
  })), separateLabelAndField && /*#__PURE__*/React.createElement("div", {
@@ -1 +1 @@
1
- {"version":3,"file":"FormField.js","names":["React","useState","HookFormWrapper","FormFieldLabel","InputText","ValidationMessages","Spinner","InputSearch","InputDate","Select","Textarea","Autocomplete","FormField","label","field","layout","showSpinner","validation","customContent","customCssClasses","separateLabelAndField","isTouched","setIsTouched","wrapperCssClass","type","wrapper","position","wrapperHoverText","hide","undefined","placeholder","text","getFieldElement","fieldType","toLowerCase","fieldProps","defaultValue","onTouched","createElement","Error","labelProps","inputId","id","isRequired","required","className","title","labelId","htmlFor","name"],"sources":["../../../../../../src/components/form/formFields/formFieldWrapper/FormField.tsx"],"sourcesContent":["'use client';\n\nimport React, { ReactNode, useState } from 'react';\nimport { HookFormWrapper } from '../../hookFormWrapper/HookFormWrapper';\nimport { FormFieldLabel } from '../subComponents/labels/FormFieldLabel';\nimport { FormFieldProps } from './formFieldProps';\nimport { InputText } from '../subComponents/inputs/text/InputText';\nimport { ValidationMessages } from '../../validation/ValidationMessages';\nimport { Spinner } from '../../../design/spinner/Spinner';\nimport { InputSearch } from '../subComponents/inputs/search/InputSearch';\nimport { InputDate } from '../subComponents/inputs/date/InputDate';\nimport { Select } from '../subComponents/select/Select';\nimport { Textarea } from '../subComponents/textarea/Textarea';\nimport { Autocomplete } from '../subComponents/inputs/autocomplete/Autocomplete';\n\nexport const FormField: React.FC<FormFieldProps> = (\n {\n label,\n field,\n layout = 'stacked',\n showSpinner,\n validation,\n customContent,\n customCssClasses,\n separateLabelAndField = false\n }\n) => {\n const [isTouched, setIsTouched] = useState(false);\n\n const wrapperCssClass = `\n formField \n ${ layout } \n ${ field.type }_Field \n ${ customCssClasses?.wrapper || '' } \n ${ isTouched ? 'touched' : '' } \n ${ typeof validation !== 'undefined' ? 'withValidation' : '' } \n ${ label?.position === 'inset' ? 'insetLabel' : '' }\n `;\n\n const wrapperHoverText = (): string | undefined => {\n if (!label.hide) {\n return undefined;\n }\n\n if (field.placeholder) {\n return field.placeholder;\n }\n\n if (typeof label.text === 'string') {\n return label.text;\n }\n\n return undefined;\n };\n\n const getFieldElement = () => {\n const fieldType = field.type.toLowerCase();\n const fieldProps = {\n field: {\n ...field,\n ...(fieldType !== 'checkbox' ? { defaultValue: field.defaultValue || '' } : {}),\n onTouched: () => setIsTouched(true)\n },\n label,\n showSpinner,\n validation,\n customContent\n };\n\n switch (fieldType) {\n case 'textarea':\n return <Textarea { ...fieldProps } />;\n case 'select':\n return <Select { ...fieldProps } />;\n case 'checkbox':\n return new Error('Checkboxes require special handling. Please use the InputCheckbox component instead.');\n case 'file':\n return new Error('File inputs require special handling. Please use the DragAndDropFileUpload component instead.');\n case 'password':\n return <InputText { ...fieldProps } />;\n case 'date':\n return <InputDate { ...fieldProps } />;\n case 'search':\n return <InputSearch { ...fieldProps } />;\n case 'combobox':\n return <Autocomplete { ...fieldProps } />;\n default:\n return <InputText { ...fieldProps } />;\n }\n };\n\n const labelProps = {\n ...label,\n inputId: field.id,\n isRequired: validation && typeof validation.required !== 'undefined',\n customContent\n };\n\n return (\n <HookFormWrapper>\n <div\n className={ wrapperCssClass }\n title={ wrapperHoverText() }\n >\n <label\n id={ label.labelId || `${ field.id }_label` }\n className={ `${ customCssClasses?.label || '' } ${ showSpinner ? 'withSpinner' : '' } ${ label.hide ? 'hiddenLabel' : '' }` }\n htmlFor={ field.id }\n >\n\n { (!label?.position || label.position === 'left' || separateLabelAndField)\n && <FormFieldLabel { ...labelProps } /> }\n\n {\n !separateLabelAndField && (\n <span className=\"inputContainer\">\n {\n getFieldElement() as ReactNode\n }\n { label?.position === 'inset'\n && <FormFieldLabel { ...labelProps } /> }\n </span>\n )\n }\n\n { label?.position === 'right'\n && <FormFieldLabel { ...labelProps } /> }\n\n {\n showSpinner && <Spinner />\n }\n\n { field.type !== 'textarea' && <ValidationMessages name={ field.name } validation={ validation } /> }\n </label>\n\n {\n separateLabelAndField && (\n <div className=\"inputContainer\">\n {\n getFieldElement() as ReactNode\n }\n </div>\n )\n }\n </div>\n </HookFormWrapper>\n );\n};\n\nexport default FormField;\n"],"mappings":"AAAA,YAAY;;AAEZ,OAAOA,KAAK,IAAeC,QAAQ,QAAQ,OAAO;AAClD,SAASC,eAAe,QAAQ,uCAAuC;AACvE,SAASC,cAAc,QAAQ,wCAAwC;AAEvE,SAASC,SAAS,QAAQ,wCAAwC;AAClE,SAASC,kBAAkB,QAAQ,qCAAqC;AACxE,SAASC,OAAO,QAAQ,iCAAiC;AACzD,SAASC,WAAW,QAAQ,4CAA4C;AACxE,SAASC,SAAS,QAAQ,wCAAwC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[]}
1
+ {"version":3,"file":"FormField.js","names":["React","useState","HookFormWrapper","FormFieldLabel","InputText","ValidationMessages","Spinner","InputSearch","InputDate","Select","Textarea","Autocomplete","FormField","label","field","layout","showSpinner","validation","customContent","customCssClasses","separateLabelAndField","formContext","isTouched","setIsTouched","wrapperCssClass","type","wrapper","position","wrapperHoverText","hide","undefined","placeholder","text","getFieldElement","fieldType","toLowerCase","fieldProps","defaultValue","onTouched","createElement","Error","labelProps","inputId","id","isRequired","required","className","title","labelId","htmlFor","name"],"sources":["../../../../../../src/components/form/formFields/formFieldWrapper/FormField.tsx"],"sourcesContent":["'use client';\n\nimport React, { useState } from 'react';\nimport { HookFormWrapper } from '../../hookFormWrapper/HookFormWrapper';\nimport { FormFieldLabel } from '../subComponents/labels/FormFieldLabel';\nimport { FormFieldProps } from './formFieldProps';\nimport { InputText } from '../subComponents/inputs/text/InputText';\nimport { ValidationMessages } from '../../validation/ValidationMessages';\nimport { Spinner } from '../../../design/spinner/Spinner';\nimport { InputSearch } from '../subComponents/inputs/search/InputSearch';\nimport { InputDate } from '../subComponents/inputs/date/InputDate';\nimport { Select } from '../subComponents/select/Select';\nimport { Textarea } from '../subComponents/textarea/Textarea';\nimport { Autocomplete } from '../subComponents/inputs/autocomplete/Autocomplete';\n\nexport const FormField: React.FC<FormFieldProps> = (\n {\n label,\n field,\n layout = 'stacked',\n showSpinner,\n validation,\n customContent,\n customCssClasses,\n separateLabelAndField = false,\n formContext\n }\n) => {\n const [isTouched, setIsTouched] = useState(false);\n\n const wrapperCssClass = `\n formField \n ${ layout } \n ${ field.type }_Field \n ${ customCssClasses?.wrapper || '' } \n ${ isTouched ? 'touched' : '' } \n ${ typeof validation !== 'undefined' ? 'withValidation' : '' } \n ${ label?.position === 'inset' ? 'insetLabel' : '' }\n `;\n\n const wrapperHoverText = (): string | undefined => {\n if (!label.hide) {\n return undefined;\n }\n\n if (field.placeholder) {\n return field.placeholder;\n }\n\n if (typeof label.text === 'string') {\n return label.text;\n }\n\n return undefined;\n };\n\n const getFieldElement = () => {\n const fieldType = field.type.toLowerCase();\n const fieldProps = {\n field: {\n ...field,\n ...(fieldType !== 'checkbox' ? { defaultValue: field.defaultValue || '' } : {}),\n onTouched: () => setIsTouched(true)\n },\n label,\n showSpinner,\n validation,\n customContent\n };\n\n switch (fieldType) {\n case 'textarea':\n return <Textarea { ...fieldProps } />;\n case 'select':\n return <Select { ...fieldProps } />;\n case 'checkbox':\n throw new Error('Checkboxes require special handling. Please use the InputCheckbox component instead.');\n case 'file':\n throw new Error('File inputs require special handling. Please use the DragAndDropFileUpload component instead.');\n case 'password':\n return <InputText { ...fieldProps } />;\n case 'date':\n return <InputDate { ...fieldProps } />;\n case 'search':\n return <InputSearch { ...fieldProps } />;\n case 'combobox':\n return <Autocomplete { ...fieldProps } />;\n default:\n return <InputText { ...fieldProps } />;\n }\n };\n\n const labelProps = {\n ...label,\n inputId: field.id,\n isRequired: validation && typeof validation.required !== 'undefined',\n customContent\n };\n\n return (\n <HookFormWrapper formContext={ formContext }>\n <div\n className={ wrapperCssClass }\n title={ wrapperHoverText() }\n >\n <label\n id={ label.labelId || `${ field.id }_label` }\n className={ `${ customCssClasses?.label || '' } ${ showSpinner ? 'withSpinner' : '' } ${ label.hide ? 'hiddenLabel' : '' }` }\n htmlFor={ field.id }\n >\n\n { (!label?.position || label.position === 'left' || separateLabelAndField)\n && <FormFieldLabel { ...labelProps } /> }\n\n {\n !separateLabelAndField && (\n <span className=\"inputContainer\">\n {\n getFieldElement()\n }\n { label?.position === 'inset'\n && <FormFieldLabel { ...labelProps } /> }\n </span>\n )\n }\n\n { label?.position === 'right'\n && <FormFieldLabel { ...labelProps } /> }\n\n {\n showSpinner && <Spinner />\n }\n\n <ValidationMessages name={ field.name } validation={ validation } />\n </label>\n\n {\n separateLabelAndField && (\n <div className=\"inputContainer\">\n {\n getFieldElement()\n }\n </div>\n )\n }\n </div>\n </HookFormWrapper>\n );\n};\n\nexport default FormField;\n"],"mappings":"AAAA,YA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CAAC,eAG5BN,KAAA,CAAAuC,aAAA,CAAClC,kBAAkB;IAAC6C,IAAI,EAAGpC,KAAK,CAACoC,IAAM;IAACjC,UAAU,EAAGA;EAAY,CAAE,CAC9D,CAAC,EAGNG,qBAAqB,iBACnBpB,KAAA,CAAAuC,aAAA;IAAKO,SAAS,EAAC;EAAgB,GAE3Bb,eAAe,CAAC,CAEf,CAGN,CACU,CAAC;AAEtB,CAAC;AAED,eAAerB,SAAS","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"formFieldProps.js","names":[],"sources":["../../../../../../src/components/form/formFields/formFieldWrapper/formFieldProps.ts"],"sourcesContent":["/* eslint-disable no-unused-vars */\n\nimport {\n ChangeEvent, ChangeEventHandler, FormEventHandler,\n KeyboardEvent,\n ReactElement,\n ReactNode,\n} from 'react';\n\nimport type {\n InputHTMLAttributes,\n SelectHTMLAttributes,\n TextareaHTMLAttributes,\n} from 'react';\n\nimport {\n Message,\n Validate,\n ValidationRule\n} from 'react-hook-form';\nimport { GenericFunction } from '../../../../interfaces';\nimport { KeyboardEventHandler } from '../../../../interfaces/generic.interface';\n\n/**\n * Custom content props for additional elements around the label or field.\n */\nexport interface CustomContentProps {\n /** Element or text to display before the label. */\n preLabel?: ReactElement | string;\n /** Element or text to display after the label. */\n postLabel?: ReactElement | string;\n /** Element or text to display before the field. */\n preField?: ReactElement | string;\n /** Element or text to display after the field. */\n postField?: ReactElement | string;\n}\n\n/**\n * Props for the label element.\n */\nexport interface LabelProps {\n /** Text or element for the label. */\n text: string | ReactNode | ReactElement;\n /** The ID of the input the label is associated with. */\n inputId?: string;\n /** The ID of the label element. */\n labelId?: string;\n /** Whether to hide the label visually. */\n hide?: boolean;\n /** Position of the label relative to the field. */\n position?: 'inset' | 'left' | 'right' | string;\n /** Tooltip for the label. */\n labelTooltip?: {\n /** Text for the tooltip. */\n text: string;\n /** Optional icon for the tooltip. */\n icon?: ReactElement | string;\n };\n /** Screen reader instructions for the label. */\n srInstruction?: string;\n /** Whether the field is required. */\n isRequired?: boolean;\n /** Custom content for the label. */\n customContent?: CustomContentProps;\n}\n\n/**\n * Type for a single select option.\n */\nexport type SelectOptionObjectType = {\n /** Label of the option. */\n label: string;\n /** Value of the option. */\n value: string | number | boolean;\n};\n\n/**\n * Type for select options, which can be an object or string.\n */\nexport type SelectOptionType = SelectOptionObjectType | string;\n\n/**\n * Type for a single combobox (autocomplete) option.\n */\nexport type ComboboxOptionObjectType = {\n /** Label of the option. */\n label: string;\n /** Value of the option. */\n value: string | number | boolean;\n /** Additional data associated with the option. */\n data?: Record<string, unknown>;\n};\n\nexport type ComboboxOption = ComboboxOptionObjectType | string;\n\n// Everything we want to *override* with our own definitions in FieldProps\nexport type OverriddenKeys =\n | 'type'\n | 'id'\n | 'name'\n | 'placeholder'\n | 'defaultValue'\n | 'onChange'\n | 'onBlur'\n | 'onInput'\n | 'onKeyDown'\n | 'disabled'\n | 'readOnly'\n | 'min'\n | 'max';\n\n// All the native props we want to mix in, minus the ones we override\nexport type NativeFieldProps =\n & Omit<InputHTMLAttributes<HTMLInputElement>, OverriddenKeys>\n & Omit<SelectHTMLAttributes<HTMLSelectElement>, OverriddenKeys>\n & Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, OverriddenKeys>;\n\n/**\n * Props for the field element.\n */\nexport interface FieldProps extends NativeFieldProps {\n /** The type of the input field. */\n type: string;\n /** The ID of the input field. */\n id: string;\n /** The name of the input field. */\n name: string;\n /** Placeholder text for the input field. */\n placeholder?: string;\n /** Default value for the input field. */\n defaultValue?: string | number | readonly string[];\n /** Handler for the change event. */\n onChange?: ChangeEventHandler | ((\n event: ChangeEvent<HTMLInputElement> | KeyboardEvent<HTMLSelectElement> | KeyboardEvent<HTMLTextAreaElement>\n ) => void | GenericFunction);\n /** Handler for the blur event. */\n onBlur?: GenericFunction;\n /** Handler for the input event. */\n onInput?: FormEventHandler<\n HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement\n >;\n /** Handler for the keydown event. */\n onKeyDown?: KeyboardEventHandler | ((\n event: KeyboardEvent<HTMLInputElement> | KeyboardEvent<HTMLSelectElement> | KeyboardEvent<HTMLTextAreaElement>\n ) => void | GenericFunction);\n /** Handler for marking the field as touched. */\n onTouched?: GenericFunction;\n /** Whether to include an empty option in a dropdown. */\n includeEmptyOption?: boolean;\n /** Label for the empty option. */\n emptyOptionLabel?: string;\n /** Options for a dropdown field. */\n options?: SelectOptionType[] | ComboboxOption[];\n /** Auto-complete behaviour for the field. */\n autoComplete?: string;\n /** Whether the field allows editing and interaction. Note: Setting this to true makes it invisible to screen reader users. */\n disabled?: boolean;\n /** Setting to true prevents editing and interaction whilst still making the value visible to screen reader users. */\n readonly?: boolean;\n /** Minimum value or length. */\n min?: string | number;\n /** Maximum value or length. */\n max?: string | number;\n /**\n * Whether to enforce grapheme-aware max-length handling (used by textarea).\n * Uses `field.maxLength` (native field prop) as the source for the UI/input limit.\n * Keep `field.maxLength` and `validation.maxLength` aligned to avoid mixed UX/validation behaviour.\n */\n enforceMaxLength?: boolean;\n}\n\n/**\n * Validation rules for fields.\n */\nexport type CustomValidate<TFieldValue> = (\n value: TFieldValue,\n formValues?: unknown\n) => boolean | string | Promise<boolean | string>;\n\n/**\n * Props for validation rules.\n */\n\nexport type MinMaxRule<T> = T extends boolean\n ? ValidationRule<boolean>\n : ValidationRule<number | string>;\n\nexport interface ValidationProps<\n TFieldValue = unknown | string | boolean,\n TFormValues = unknown\n> {\n /** Whether the field is required. */\n required?: Message | ValidationRule<boolean>;\n /** Minimum value or length. */\n min?: MinMaxRule<TFieldValue>;\n /** Maximum value or length. */\n max?: MinMaxRule<TFieldValue>;\n /**\n * Maximum length validation rule.\n * Used for validation outcome/messages, while textarea UI/input limiting is driven by `field.maxLength`.\n * If both are provided, keep them equal.\n */\n maxLength?: ValidationRule<number>;\n /** Minimum length of the field. */\n minLength?: ValidationRule<number>;\n /** Regex pattern for validation. */\n pattern?: ValidationRule<RegExp>;\n /** Custom validation logic. */\n validate?: CustomValidate<TFieldValue> | Record<string, CustomValidate<TFieldValue>> | Validate<TFieldValue, TFormValues>;\n}\n\nexport type ValidationKey = keyof ValidationProps<unknown, unknown>; // Restrict to known keys\n\n/**\n * Custom CSS classes for the field components.\n */\nexport interface CustomFieldCssClassesProps {\n /** CSS class for the label. */\n label?: string;\n /** CSS class for the input field. */\n input?: string;\n /** CSS class for the wrapper. */\n wrapper?: string;\n}\n\n/**\n * Props for a form field component.\n */\nexport interface FormFieldProps {\n /** Props for the label. */\n label: LabelProps;\n /** Props for the field. */\n field: FieldProps;\n /** Layout style of the form field. */\n layout?: 'stacked' | 'horizontal' | string;\n /** Validation rules for the field. */\n validation?: ValidationProps;\n /** Whether to show a spinner. */\n showSpinner?: boolean;\n /** Custom CSS classes for the field. */\n customCssClasses?: CustomFieldCssClassesProps;\n /** Custom content for the field. */\n customContent?: CustomContentProps;\n /** Override the default nesting of the input inside the label. */\n separateLabelAndField?: boolean;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"formFieldProps.js","names":[],"sources":["../../../../../../src/components/form/formFields/formFieldWrapper/formFieldProps.ts"],"sourcesContent":["/* eslint-disable no-unused-vars */\n\nimport {\n ChangeEvent,\n ChangeEventHandler,\n FormEventHandler,\n KeyboardEvent,\n ReactElement,\n ReactEventHandler,\n ReactNode,\n} from 'react';\n\nimport type {\n InputHTMLAttributes,\n SelectHTMLAttributes,\n TextareaHTMLAttributes,\n} from 'react';\n\nimport {\n FieldValues,\n Message,\n UseFormReturn,\n Validate,\n ValidationRule\n} from 'react-hook-form';\nimport { GenericFunction } from '../../../../interfaces';\nimport { KeyboardEventHandler } from '../../../../interfaces/generic.interface';\n\n/**\n * Custom content props for additional elements around the label or field.\n */\nexport interface CustomContentProps {\n /** Element or text to display before the label. */\n preLabel?: ReactElement | string;\n /** Element or text to display after the label. */\n postLabel?: ReactElement | string;\n /** Element or text to display before the field. */\n preField?: ReactElement | string;\n /** Element or text to display after the field. */\n postField?: ReactElement | string;\n}\n\n/**\n * Props for the label element.\n */\nexport interface LabelProps {\n /** Text or element for the label. */\n text: string | ReactNode | ReactElement;\n /** The ID of the input the label is associated with. */\n inputId?: string;\n /** The ID of the label element. */\n labelId?: string;\n /** Whether to hide the label visually. */\n hide?: boolean;\n /** Position of the label relative to the field. */\n position?: 'inset' | 'left' | 'right' | string;\n /** Tooltip for the label. */\n labelTooltip?: {\n /** Text for the tooltip. */\n text: string;\n /** Optional icon for the tooltip. */\n icon?: ReactElement | string;\n };\n /** Screen reader instructions for the label. */\n srInstruction?: string;\n /** Whether the field is required. */\n isRequired?: boolean;\n /** Custom content for the label. */\n customContent?: CustomContentProps;\n}\n\n/**\n * Type for a single select option.\n */\nexport type SelectOptionObjectType = {\n /** Label of the option. */\n label: string;\n /** Value of the option. */\n value: string | number | boolean;\n};\n\n/**\n * Type for select options, which can be an object or string.\n */\nexport type SelectOptionType = SelectOptionObjectType | string;\n\n/**\n * Type for a single combobox (autocomplete) option.\n */\nexport type ComboboxOptionObjectType = {\n /** Label of the option. */\n label: string;\n /** Value of the option. */\n value: string | number | boolean;\n /** Additional data associated with the option. */\n data?: Record<string, unknown>;\n};\n\nexport type ComboboxOption = ComboboxOptionObjectType | string;\n\n// Everything we want to *override* with our own definitions in FieldProps\nexport type OverriddenKeys =\n | 'type'\n | 'id'\n | 'name'\n | 'placeholder'\n | 'defaultValue'\n | 'onChange'\n | 'onBlur'\n | 'onInput'\n | 'onKeyDown'\n | 'disabled'\n | 'readOnly'\n | 'min'\n | 'max';\n\n// All the native props we want to mix in, minus the ones we override\nexport type NativeFieldProps =\n & Omit<InputHTMLAttributes<HTMLInputElement>, OverriddenKeys>\n & Omit<SelectHTMLAttributes<HTMLSelectElement>, OverriddenKeys>\n & Omit<TextareaHTMLAttributes<HTMLTextAreaElement>, OverriddenKeys>;\n\n/**\n * Props for the field element.\n */\nexport interface FieldProps extends NativeFieldProps {\n /** The type of the input field. */\n type: string;\n /** The ID of the input field. */\n id: string;\n /** The name of the input field. */\n name: string;\n /** Placeholder text for the input field. */\n placeholder?: string;\n /** Default value for the input field. */\n defaultValue?: string | number | readonly string[];\n /** Handler for the change event. */\n onChange?: ChangeEventHandler | ((\n event: ChangeEvent<HTMLInputElement> | KeyboardEvent<HTMLSelectElement> | KeyboardEvent<HTMLTextAreaElement>\n ) => void | GenericFunction);\n /** Handler for the blur event. */\n onBlur?: GenericFunction;\n /** Handler for the input event. */\n onInput?: FormEventHandler<\n HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement\n >;\n /** Handler for the keydown event. */\n onKeyDown?: KeyboardEventHandler | ((\n event: KeyboardEvent<HTMLInputElement> | KeyboardEvent<HTMLSelectElement> | KeyboardEvent<HTMLTextAreaElement>\n ) => void | GenericFunction);\n /** Handler for marking the field as touched. */\n onTouched?: GenericFunction;\n /** Whether to include an empty option in a dropdown. */\n includeEmptyOption?: boolean;\n /** Label for the empty option. */\n emptyOptionLabel?: string;\n /** Options for a dropdown field. */\n options?: SelectOptionType[] | ComboboxOption[];\n /** Auto-complete behaviour for the field. */\n autoComplete?: string;\n /** Whether the field allows editing and interaction. Note: Setting this to true makes it invisible to screen reader users. */\n disabled?: boolean;\n /** Setting to true prevents editing and interaction whilst still making the value visible to screen reader users. */\n readonly?: boolean;\n /** Minimum value or length. */\n min?: string | number;\n /** Maximum value or length. */\n max?: string | number;\n /**\n * Whether to enforce grapheme-aware max-length handling (used by textarea).\n * Uses `field.maxLength` (native field prop) as the source for the UI/input limit.\n * Keep `field.maxLength` and `validation.maxLength` aligned to avoid mixed UX/validation behaviour.\n */\n enforceMaxLength?: boolean;\n}\n\n/**\n * Validation rules for fields.\n */\nexport type CustomValidate<TFieldValue> = (\n value: TFieldValue,\n formValues?: unknown\n) => boolean | string | Promise<boolean | string>;\n\n/**\n * Props for validation rules.\n */\n\nexport type MinMaxRule<T> = T extends boolean\n ? ValidationRule<boolean>\n : ValidationRule<number | string>;\n\nexport interface ValidationProps<\n TFieldValue = unknown | string | boolean,\n TFormValues = unknown\n> {\n /** Whether the field is required. */\n required?: Message | ValidationRule<boolean>;\n /** Minimum value or length. */\n min?: MinMaxRule<TFieldValue>;\n /** Maximum value or length. */\n max?: MinMaxRule<TFieldValue>;\n /**\n * Maximum length validation rule.\n * Used for validation outcome/messages, while textarea UI/input limiting is driven by `field.maxLength`.\n * If both are provided, keep them equal.\n */\n maxLength?: ValidationRule<number>;\n /** Minimum length of the field. */\n minLength?: ValidationRule<number>;\n /** Regex pattern for validation. */\n pattern?: ValidationRule<RegExp>;\n /** Custom validation logic. */\n validate?: CustomValidate<TFieldValue> | Record<string, CustomValidate<TFieldValue>> | Validate<TFieldValue, TFormValues>;\n}\n\nexport type ValidationKey = keyof ValidationProps<unknown, unknown>; // Restrict to known keys\n\n/**\n * Custom CSS classes for the field components.\n */\nexport interface CustomFieldCssClassesProps {\n /** CSS class for the label. */\n label?: string;\n /** CSS class for the input field. */\n input?: string;\n /** CSS class for the wrapper. */\n wrapper?: string;\n}\n\n/**\n * Props for a form field component.\n */\nexport interface FormFieldProps {\n /** Props for the label. */\n label: LabelProps;\n /** Props for the field. */\n field: FieldProps;\n /** Layout style of the form field. */\n layout?: 'stacked' | 'horizontal' | string;\n /** Validation rules for the field. */\n validation?: ValidationProps;\n /** Whether to show a spinner. */\n showSpinner?: boolean;\n /** Custom CSS classes for the field. */\n customCssClasses?: CustomFieldCssClassesProps;\n /** Custom content for the field. */\n customContent?: CustomContentProps;\n /** Override the default nesting of the input inside the label. */\n separateLabelAndField?: boolean;\n /** An existing form context to use when React context cannot reach this field, e.g. across a Next.js client boundary. */\n formContext?: UseFormReturn<FieldValues, any, FieldValues>;\n}\n\nexport type TextareaFieldProps = Omit<FieldProps, 'onSelect'> & {\n onSelect?: ReactEventHandler<HTMLTextAreaElement>;\n};\n"],"mappings":"","ignoreList":[]}
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- import React, { useState, useRef, useMemo } from 'react';
3
+ import React, { useState, useRef, useMemo, useCallback } from 'react';
4
4
  import { useFormContext } from 'react-hook-form';
5
5
  import { useDebouncedCallback } from 'use-debounce';
6
6
  import { useOnClickOutside, usePopupKeys } from '../../../../../../hooks';
@@ -24,7 +24,7 @@ export const Autocomplete = ({
24
24
  const [isOpen, setIsOpen] = useState(false);
25
25
  const [filteredOptions, setFilteredOptions] = useState(field.options || []);
26
26
  const [selectedOption, setSelectedOption] = useState(null);
27
- const [inputValue, setInputValue] = useState('');
27
+ const inputElement = useRef(null);
28
28
  useOnClickOutside(wrapperElement, () => setIsOpen(false));
29
29
  usePopupKeys(wrapperElement, () => setIsOpen(false));
30
30
  const filterOptions = useDebouncedCallback(searchTerm => {
@@ -43,15 +43,20 @@ export const Autocomplete = ({
43
43
  setIsOpen(true);
44
44
  onInputChange(searchTerm);
45
45
  }, debounceTime);
46
- const handleInputChange = event => {
47
- const newValue = event.target.value;
48
- setInputValue(newValue);
49
- filterOptions(newValue.toLowerCase());
50
- };
46
+ const handleInputChange = useCallback(event => {
47
+ inputElement.current = event.target;
48
+ filterOptions(event.target.value.toLowerCase());
49
+ }, [filterOptions]);
51
50
  const handleOptionSelect = option => {
52
51
  const displayValue = typeof option === 'string' ? option : JSON.stringify(option.label);
53
- setInputValue(displayValue);
54
- setValue(field.name, displayValue);
52
+ // The registered input is uncontrolled, so write to both the DOM and form state.
53
+ if (inputElement.current) {
54
+ inputElement.current.value = displayValue;
55
+ }
56
+ setValue(field.name, displayValue, {
57
+ shouldValidate: true,
58
+ shouldDirty: true
59
+ });
55
60
  setSelectedOption(option);
56
61
  setIsOpen(false);
57
62
  onOptionSelect(option);
@@ -68,8 +73,7 @@ export const Autocomplete = ({
68
73
  'aria-haspopup': 'listbox',
69
74
  role: 'combobox',
70
75
  onFocus: () => setIsOpen(true),
71
- onChange: handleInputChange,
72
- defaultValue: inputValue
76
+ onChange: handleInputChange
73
77
  },
74
78
  label,
75
79
  validation,
@@ -77,7 +81,7 @@ export const Autocomplete = ({
77
81
  customCssClasses,
78
82
  customContent
79
83
  };
80
- }, [field, isOpen, optionsContainerId, validation, showSpinner, customCssClasses, customContent, handleInputChange, selectedOption]);
84
+ }, [field, isOpen, optionsContainerId, label, validation, showSpinner, customCssClasses, customContent, handleInputChange]);
81
85
  return /*#__PURE__*/React.createElement("div", {
82
86
  ref: wrapperElement,
83
87
  className: `autocompleteWrapper ${isOpen ? 'open' : 'closed'}`
@@ -1 +1 @@
1
- {"version":3,"file":"Autocomplete.js","names":["React","useState","useRef","useMemo","useFormContext","useDebouncedCallback","useOnClickOutside","usePopupKeys","InputText","Autocomplete","field","label","validation","showSpinner","customCssClasses","customContent","onOptionSelect","onInputChange","debounceTime","setValue","wrapperElement","isOpen","setIsOpen","filteredOptions","setFilteredOptions","options","selectedOption","setSelectedOption","inputValue","setInputValue","filterOptions","searchTerm","matchingOptions","filter","option","toLowerCase","includes","JSON","stringify","handleInputChange","event","newValue","target","value","handleOptionSelect","displayValue","name","optionsContainerId","id","comboBoxFieldProps","type","role","onFocus","onChange","defaultValue","createElement","ref","className","tabIndex","length","map","optionId","key","onClick"],"sources":["../../../../../../../../src/components/form/formFields/subComponents/inputs/autocomplete/Autocomplete.tsx"],"sourcesContent":["'use client';\n\nimport React, { useState, useRef, useMemo } from 'react';\nimport { useFormContext } from 'react-hook-form';\nimport { useDebouncedCallback } from 'use-debounce';\nimport { ComboboxOption, FieldProps, FormFieldProps } from '../../../formFieldWrapper/formFieldProps';\nimport { useOnClickOutside, usePopupKeys } from '../../../../../../hooks';\n\nimport { InputText, InputTextProps } from '../text/InputText';\n\nimport './autocomplete.scss';\n\n\nexport interface ComboboxFieldProps extends React.InputHTMLAttributes<HTMLInputElement>, Omit<FormFieldProps, 'field'> {\n field: Omit<FieldProps, 'type' | 'options'> & {\n options?: ComboboxOption[] | string[];\n };\n /* eslint-disable-next-line no-unused-vars */\n onOptionSelect?: (option: ComboboxOption | string) => void;\n /* eslint-disable-next-line no-unused-vars */\n onInputChange?: (inputValue: string) => void;\n debounceTime?: number;\n}\n\nexport const Autocomplete: React.FC<ComboboxFieldProps> = (\n {\n field,\n label,\n validation,\n showSpinner,\n customCssClasses,\n customContent,\n onOptionSelect = () => {},\n onInputChange = () => {},\n debounceTime = 500,\n }\n) => {\n const { setValue } = useFormContext();\n\n const wrapperElement = useRef<HTMLDivElement>(null);\n const [isOpen, setIsOpen] = useState(false);\n const [filteredOptions, setFilteredOptions] = useState<(string | ComboboxOption)[]>(field.options || []);\n const [selectedOption, setSelectedOption] = useState<ComboboxOption | string | null>(null);\n const [inputValue, setInputValue] = useState('');\n\n useOnClickOutside(wrapperElement, () => setIsOpen(false));\n usePopupKeys(wrapperElement, () => setIsOpen(false));\n\n const filterOptions = useDebouncedCallback((searchTerm: string) => {\n const matchingOptions: (string | ComboboxOption)[] = field.options ? field.options.filter((option) => {\n if (typeof option === 'string') {\n return option.toLowerCase().includes(searchTerm);\n }\n if (typeof option.label === 'string') {\n return option.label.toLowerCase().includes(searchTerm);\n }\n // For non-string labels, convert to JSON string and check\n return JSON.stringify(option.label).toLowerCase().includes(searchTerm);\n }) : [];\n setSelectedOption(null);\n setFilteredOptions(matchingOptions);\n setIsOpen(true);\n onInputChange(searchTerm);\n }, debounceTime);\n\n const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n const newValue = event.target.value;\n setInputValue(newValue);\n filterOptions(newValue.toLowerCase());\n };\n\n const handleOptionSelect = (option: ComboboxOption | string) => {\n const displayValue = typeof option === 'string' ? option : JSON.stringify(option.label);\n setInputValue(displayValue);\n setValue(field.name, displayValue);\n setSelectedOption(option);\n setIsOpen(false);\n onOptionSelect(option);\n };\n\n const optionsContainerId = `${ field.id || field.name }Options`;\n\n const comboBoxFieldProps: InputTextProps = useMemo(() => {\n return {\n field: {\n ...field,\n type: 'search',\n 'aria-autocomplete': 'both',\n 'aria-expanded': isOpen,\n 'aria-controls': optionsContainerId,\n 'aria-haspopup': 'listbox',\n role: 'combobox',\n onFocus: () => setIsOpen(true),\n onChange: handleInputChange,\n defaultValue: inputValue,\n },\n label,\n validation,\n showSpinner,\n customCssClasses,\n customContent,\n };\n }, [field, isOpen, optionsContainerId, validation, showSpinner, customCssClasses, customContent, handleInputChange, selectedOption]);\n \n return (\n <div ref={ wrapperElement } className={ `autocompleteWrapper ${ isOpen ? 'open' : 'closed' }` }>\n <InputText { ...comboBoxFieldProps } />\n\n {\n isOpen && filteredOptions && (\n <div tabIndex={ -1 } className=\"autocompleteOptions\">\n {\n filteredOptions.length === 0 ?\n (\n <div aria-selected=\"false\" role=\"listbox\" id={ optionsContainerId }>\n No results found\n </div>\n )\n :\n (\n <ul className=\"noBullet\" role=\"listbox\" id={ optionsContainerId }>\n {\n filteredOptions.map((option) => {\n const optionId = `${ optionsContainerId }_${ option }`;\n\n return (\n <li\n key={ optionId }\n aria-selected={ option === selectedOption ? 'true' : 'false' }\n role=\"option\"\n data-option={ option }\n >\n <button className={ option === selectedOption ? 'selected' : '' } type=\"button\" id={ optionId } onClick={ () => handleOptionSelect(option) }>\n { typeof option === 'string' ? option : option.label }\n </button>\n </li>\n );\n })\n }\n </ul>\n )\n }\n </div>\n )\n }\n </div>\n );\n};\n\nexport default Autocomplete;"],"mappings":"AAAA,YAAY;;AAEZ,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,MAAM,EAAEC,OAAO,QAAQ,OAAO;AACxD,SAASC,cAAc,QAAQ,iBAAiB;AAChD,SAASC,oBAAoB,QAAQ,cAAc;AAEnD,SAASC,iBAAiB,EAAEC,YAAY,QAAQ,yBAAyB;AAEzE,SAASC,SAAS,QAAwB,mBAAmB;AAE7D,OAAO,qBAAqB;AAc5B,OAAO,MAAMC,YAA0C,GAAGA,CACxD;EACEC,KAAK;EACLC,KAAK;EACLC,UAAU;EACVC,WAAW;EACXC,gBAAgB;EAChBC,aAAa;EACbC,cAAc,GAAGA,CAAA,KAAM,CAAC,CAAC;EACzBC,aAAa,GAAGA,CAAA,KAAM,CAAC,CAAC;EACxBC,YAAY,GAAG;AACjB,CAAC,KACE;EACH,MAAM;IAAEC;EAA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M,KAAK,QAAQ,GAAGA,MAAM,GAAGA,MAAM,CAACvB,KACzC,CACN,CAAC;EAET,CAAC,CAED,CAGP,CAGN,CAAC;AAEV,CAAC;AAED,eAAeF,YAAY","ignoreList":[]}
1
+ {"version":3,"file":"Autocomplete.js","names":["React","useState","useRef","useMemo","useCallback","useFormContext","useDebouncedCallback","useOnClickOutside","usePopupKeys","InputText","Autocomplete","field","label","validation","showSpinner","customCssClasses","customContent","onOptionSelect","onInputChange","debounceTime","setValue","wrapperElement","isOpen","setIsOpen","filteredOptions","setFilteredOptions","options","selectedOption","setSelectedOption","inputElement","filterOptions","searchTerm","matchingOptions","filter","option","toLowerCase","includes","JSON","stringify","handleInputChange","event","current","target","value","handleOptionSelect","displayValue","name","shouldValidate","shouldDirty","optionsContainerId","id","comboBoxFieldProps","type","role","onFocus","onChange","createElement","ref","className","tabIndex","length","map","optionId","key","onClick"],"sources":["../../../../../../../../src/components/form/formFields/subComponents/inputs/autocomplete/Autocomplete.tsx"],"sourcesContent":["'use client';\n\nimport React, { useState, useRef, useMemo, useCallback } from 'react';\nimport { useFormContext } from 'react-hook-form';\nimport { useDebouncedCallback } from 'use-debounce';\nimport { ComboboxOption, FieldProps, FormFieldProps } from '../../../formFieldWrapper/formFieldProps';\nimport { useOnClickOutside, usePopupKeys } from '../../../../../../hooks';\n\nimport { InputText, InputTextProps } from '../text/InputText';\n\nimport './autocomplete.scss';\n\n\nexport interface ComboboxFieldProps extends React.InputHTMLAttributes<HTMLInputElement>, Omit<FormFieldProps, 'field'> {\n field: Omit<FieldProps, 'type' | 'options'> & {\n options?: ComboboxOption[] | string[];\n };\n /* eslint-disable-next-line no-unused-vars */\n onOptionSelect?: (option: ComboboxOption | string) => void;\n /* eslint-disable-next-line no-unused-vars */\n onInputChange?: (inputValue: string) => void;\n debounceTime?: number;\n}\n\nexport const Autocomplete: React.FC<ComboboxFieldProps> = (\n {\n field,\n label,\n validation,\n showSpinner,\n customCssClasses,\n customContent,\n onOptionSelect = () => {},\n onInputChange = () => {},\n debounceTime = 500,\n }\n) => {\n const { setValue } = useFormContext();\n\n const wrapperElement = useRef<HTMLDivElement>(null);\n const [isOpen, setIsOpen] = useState(false);\n const [filteredOptions, setFilteredOptions] = useState<(string | ComboboxOption)[]>(field.options || []);\n const [selectedOption, setSelectedOption] = useState<ComboboxOption | string | null>(null);\n const inputElement = useRef<HTMLInputElement | null>(null);\n\n useOnClickOutside(wrapperElement, () => setIsOpen(false));\n usePopupKeys(wrapperElement, () => setIsOpen(false));\n\n const filterOptions = useDebouncedCallback((searchTerm: string) => {\n const matchingOptions: (string | ComboboxOption)[] = field.options ? field.options.filter((option) => {\n if (typeof option === 'string') {\n return option.toLowerCase().includes(searchTerm);\n }\n if (typeof option.label === 'string') {\n return option.label.toLowerCase().includes(searchTerm);\n }\n // For non-string labels, convert to JSON string and check\n return JSON.stringify(option.label).toLowerCase().includes(searchTerm);\n }) : [];\n setSelectedOption(null);\n setFilteredOptions(matchingOptions);\n setIsOpen(true);\n onInputChange(searchTerm);\n }, debounceTime);\n\n const handleInputChange = useCallback((event: React.ChangeEvent<HTMLInputElement>) => {\n inputElement.current = event.target;\n filterOptions(event.target.value.toLowerCase());\n }, [filterOptions]);\n\n const handleOptionSelect = (option: ComboboxOption | string) => {\n const displayValue = typeof option === 'string' ? option : JSON.stringify(option.label);\n // The registered input is uncontrolled, so write to both the DOM and form state.\n if (inputElement.current) {\n inputElement.current.value = displayValue;\n }\n setValue(field.name, displayValue, { shouldValidate: true, shouldDirty: true });\n setSelectedOption(option);\n setIsOpen(false);\n onOptionSelect(option);\n };\n\n const optionsContainerId = `${ field.id || field.name }Options`;\n\n const comboBoxFieldProps: InputTextProps = useMemo(() => {\n return {\n field: {\n ...field,\n type: 'search',\n 'aria-autocomplete': 'both',\n 'aria-expanded': isOpen,\n 'aria-controls': optionsContainerId,\n 'aria-haspopup': 'listbox',\n role: 'combobox',\n onFocus: () => setIsOpen(true),\n onChange: handleInputChange,\n },\n label,\n validation,\n showSpinner,\n customCssClasses,\n customContent,\n };\n }, [field, isOpen, optionsContainerId, label, validation, showSpinner, customCssClasses, customContent, handleInputChange]);\n \n return (\n <div ref={ wrapperElement } className={ `autocompleteWrapper ${ isOpen ? 'open' : 'closed' }` }>\n <InputText { ...comboBoxFieldProps } />\n\n {\n isOpen && filteredOptions && (\n <div tabIndex={ -1 } className=\"autocompleteOptions\">\n {\n filteredOptions.length === 0 ?\n (\n <div aria-selected=\"false\" role=\"listbox\" id={ optionsContainerId }>\n No results found\n </div>\n )\n :\n (\n <ul className=\"noBullet\" role=\"listbox\" id={ optionsContainerId }>\n {\n filteredOptions.map((option) => {\n const optionId = `${ optionsContainerId }_${ option }`;\n\n return (\n <li\n key={ optionId }\n aria-selected={ option === selectedOption ? 'true' : 'false' }\n role=\"option\"\n data-option={ option }\n >\n <button className={ option === selectedOption ? 'selected' : '' } type=\"button\" id={ optionId } onClick={ () => handleOptionSelect(option) }>\n { typeof option === 'string' ? option : option.label }\n </button>\n </li>\n );\n })\n }\n </ul>\n )\n }\n </div>\n )\n }\n </div>\n );\n};\n\nexport default Autocomplete;"],"mappings":"AAAA,YAAY;;AAEZ,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,MAAM,EAAEC,OAAO,EAAEC,WAAW,QAAQ,OAAO;AACrE,SAASC,cAAc,QAAQ,iBAAiB;AAChD,SAASC,oBAAoB,QAAQ,cAAc;AAEnD,SAASC,iBAAiB,EAAEC,YAAY,QAAQ,yBAAyB;AAEzE,SAASC,SAAS,QAAwB,mBAAmB;AAE7D,OAAO,qBAAqB;AAc5B,OAAO,MAAMC,YAA0C,GAAGA,CACxD;EACEC,KAAK;EACLC,KAAK;EACLC,UAAU;EACVC,WAAW;EACXC,gBAAgB;EAChBC,aAAa;EACbC,cAAc,GAAGA,CAAA,KAAM,CAAC,CAAC;EACzBC,aAAa,GAAGA,CAAA,KAAM,CAAC,CAAC;EACxBC,YAAY,GAAG;AACjB,CAAC,KACE;EACH,MAAM;IAAEC;EA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;MAACF,EAAE,EAAGY,QAAU;MAACE,OAAO,EAAGA,CAAA,KAAMpB,kBAAkB,CAACV,MAAM;IAAG,GACxI,OAAOA,MAAM,KAAK,QAAQ,GAAGA,MAAM,GAAGA,MAAM,CAACtB,KACzC,CACN,CAAC;EAET,CAAC,CAED,CAGP,CAGN,CAAC;AAEV,CAAC;AAED,eAAeF,YAAY","ignoreList":[]}
@@ -1,19 +1,22 @@
1
1
  'use client';
2
2
 
3
- import React, { useState } from 'react';
3
+ import React, { useEffect, useState } from 'react';
4
4
  import { useFormContext } from 'react-hook-form';
5
- import { NoHookFormContext } from '../../../utilities/formUtilities';
6
5
  import { HookFormWrapper } from '../../../../hookFormWrapper/HookFormWrapper';
7
6
  import { FormFieldLabel } from '../../labels/FormFieldLabel';
8
7
  import { ValidationMessages } from '../../../../validation/ValidationMessages';
9
8
  import { Spinner } from '../../../../../design/spinner/Spinner';
10
9
  import { Icon } from '../../../../../design/icons/basicIcon/Icon';
11
10
  import './inputCheckbox.css';
12
- export const InputCheckbox = ({
11
+ export const InputCheckbox = props => /*#__PURE__*/React.createElement(HookFormWrapper, {
12
+ formContext: props.formContext
13
+ }, /*#__PURE__*/React.createElement(InputCheckboxField, props));
14
+ const InputCheckboxField = ({
13
15
  label,
14
16
  field: {
15
17
  id,
16
18
  name,
19
+ value,
17
20
  defaultChecked,
18
21
  onBlur = () => {},
19
22
  onChange = () => {},
@@ -21,16 +24,27 @@ export const InputCheckbox = ({
21
24
  },
22
25
  validation,
23
26
  showSpinner,
27
+ icons,
24
28
  customCssClasses,
25
29
  customContent
26
30
  }) => {
27
31
  const [isTouched, setIsTouched] = useState(false);
28
32
  const {
29
33
  register,
30
- getFieldState
31
- } = useFormContext() || NoHookFormContext;
32
- ;
34
+ getFieldState,
35
+ setValue
36
+ } = useFormContext();
33
37
  const fieldState = getFieldState(name);
38
+
39
+ // Initialize the form value with defaultChecked on mount
40
+ useEffect(() => {
41
+ if (defaultChecked) {
42
+ setValue(name, true, {
43
+ shouldValidate: false,
44
+ shouldDirty: false
45
+ });
46
+ }
47
+ }, [name, setValue, defaultChecked, value]);
34
48
  const wrapperCssClass = `formField checkBoxField ${customCssClasses?.wrapper || ''} ${isTouched ? 'touched' : ''}`;
35
49
  const inputCssClass = `${customCssClasses?.input || ''}${fieldState?.invalid ? ' invalidField' : ''}`;
36
50
  const isRequired = validation && typeof validation.required !== 'undefined';
@@ -50,19 +64,26 @@ export const InputCheckbox = ({
50
64
  isRequired,
51
65
  customContent
52
66
  };
67
+ const checkedIcon = icons?.checked ?? /*#__PURE__*/React.createElement(Icon, {
68
+ icon: "checkbox-checked"
69
+ });
70
+ const uncheckedIcon = icons?.unchecked ?? /*#__PURE__*/React.createElement(Icon, {
71
+ icon: "checkbox-unchecked"
72
+ });
53
73
  const inputProps = {
54
74
  type: 'checkbox',
55
75
  id,
76
+ value: String(value),
56
77
  className: inputCssClass,
57
- defaultChecked,
58
78
  'aria-required': isRequired,
59
79
  ...register(name, {
60
80
  onChange,
61
81
  onBlur: HandleOnBlur,
82
+ value: defaultChecked ? true : value,
62
83
  ...validation
63
84
  })
64
85
  };
65
- return /*#__PURE__*/React.createElement(HookFormWrapper, null, /*#__PURE__*/React.createElement("div", {
86
+ return /*#__PURE__*/React.createElement("div", {
66
87
  className: wrapperCssClass
67
88
  }, /*#__PURE__*/React.createElement("label", {
68
89
  id: label.labelId || `${id}_label`,
@@ -71,15 +92,16 @@ export const InputCheckbox = ({
71
92
  }, label.position === 'left' && /*#__PURE__*/React.createElement(FormFieldLabel, labelProps), /*#__PURE__*/React.createElement("div", {
72
93
  className: "inputContainer"
73
94
  }, /*#__PURE__*/React.createElement("input", inputProps), /*#__PURE__*/React.createElement("span", {
74
- className: "checkboxIcons"
75
- }, /*#__PURE__*/React.createElement(Icon, {
76
- icon: "checkbox-unchecked"
77
- }), /*#__PURE__*/React.createElement(Icon, {
78
- icon: "checkbox-checked"
79
- }))), (!label?.position || label?.position === 'right') && /*#__PURE__*/React.createElement(FormFieldLabel, labelProps), showSpinner && /*#__PURE__*/React.createElement(Spinner, null), /*#__PURE__*/React.createElement(ValidationMessages, {
95
+ className: "checkboxIcons",
96
+ "aria-hidden": "true"
97
+ }, /*#__PURE__*/React.createElement("span", {
98
+ className: "checkboxIcon checkboxIconUnchecked"
99
+ }, uncheckedIcon), /*#__PURE__*/React.createElement("span", {
100
+ className: "checkboxIcon checkboxIconChecked"
101
+ }, checkedIcon))), (!label?.position || label?.position === 'right') && /*#__PURE__*/React.createElement(FormFieldLabel, labelProps), showSpinner && /*#__PURE__*/React.createElement(Spinner, null), /*#__PURE__*/React.createElement(ValidationMessages, {
80
102
  name: name,
81
103
  validation: validation
82
- }))));
104
+ })));
83
105
  };
84
106
  export const CheckboxInput = props => /*#__PURE__*/React.createElement(InputCheckbox, props);
85
107
  //# sourceMappingURL=InputCheckbox.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"InputCheckbox.js","names":["React","useState","useFormContext","NoHookFormContext","HookFormWrapper","FormFieldLabel","ValidationMessages","Spinner","Icon","InputCheckbox","label","field","id","name","defaultChecked","onBlur","onChange","onTouched","validation","showSpinner","customCssClasses","customContent","isTouched","setIsTouched","register","getFieldState","fieldState","wrapperCssClass","wrapper","inputCssClass","input","invalid","isRequired","required","HandleOnBlur","event","target","labelProps","inputId","inputProps","type","className","createElement","labelId","htmlFor","position","icon","CheckboxInput","props"],"sources":["../../../../../../../../src/components/form/formFields/subComponents/inputs/checkbox/InputCheckbox.tsx"],"sourcesContent":["'use client';\n\nimport React, { useState } from 'react';\nimport { useFormContext } from 'react-hook-form';\nimport { NoHookFormContext } from '../../../utilities/formUtilities';\nimport { HookFormWrapper } from '../../../../hookFormWrapper/HookFormWrapper';\nimport { FormFieldLabel } from '../../labels/FormFieldLabel';\nimport { ValidationMessages } from '../../../../validation/ValidationMessages';\nimport { Spinner } from '../../../../../design/spinner/Spinner';\nimport { Icon } from '../../../../../design/icons/basicIcon/Icon';\n\nimport { InputCheckboxProps } from './inputCheckboxProps';\n\nimport './inputCheckbox.scss';\n\nexport const InputCheckbox: React.FC<InputCheckboxProps> = (\n {\n label,\n field: {\n id,\n name,\n defaultChecked,\n onBlur = () => {},\n onChange = () => {},\n onTouched = () => {}\n },\n validation,\n showSpinner,\n customCssClasses,\n customContent\n }\n) => {\n const [isTouched, setIsTouched] = useState(false);\n const { register, getFieldState } = useFormContext() || NoHookFormContext;;\n const fieldState = getFieldState(name);\n\n const wrapperCssClass = `formField checkBoxField ${ customCssClasses?.wrapper || '' } ${ isTouched ? 'touched' : '' }`;\n\n const inputCssClass = `${ customCssClasses?.input || '' }${ fieldState?.invalid ? ' invalidField' : '' }`;\n\n const isRequired = validation && typeof validation.required !== 'undefined';\n\n const HandleOnBlur = (event: React.FocusEvent<HTMLInputElement>) => {\n const { target } = event;\n setIsTouched(true);\n if (target) {\n onTouched();\n onBlur(event);\n }\n };\n\n const labelProps = {\n ...label,\n inputId: id,\n isRequired,\n customContent\n };\n\n const inputProps = {\n type: 'checkbox',\n id,\n className: inputCssClass,\n defaultChecked,\n 'aria-required': isRequired,\n ...register(\n name,\n {\n onChange,\n onBlur: HandleOnBlur,\n ...validation\n }\n )\n };\n\n return (\n <HookFormWrapper>\n <div\n className={ wrapperCssClass }\n >\n <label\n id={ label.labelId || `${ id }_label` }\n className={ `${ customCssClasses?.label || '' } ${ showSpinner ? 'withSpinner' : '' }` }\n htmlFor={ id }\n >\n\n { label.position === 'left'\n && <FormFieldLabel { ...labelProps } /> }\n\n <div className=\"inputContainer\">\n <input { ...inputProps } />\n <span className=\"checkboxIcons\">\n <Icon icon=\"checkbox-unchecked\" />\n <Icon icon=\"checkbox-checked\" />\n </span>\n </div>\n\n { (!label?.position || label?.position === 'right')\n && <FormFieldLabel { ...labelProps } /> }\n\n {\n showSpinner && <Spinner />\n }\n\n <ValidationMessages name={ name } validation={ validation } />\n </label>\n </div>\n </HookFormWrapper>\n );\n};\n\nexport const CheckboxInput: React.FC<InputCheckboxProps> = (props) => <InputCheckbox { ...props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A,CAAClC,IAAI;IAACsC,IAAI,EAAC;EAAkB,CAAE,CAC3B,CACH,CAAC,EAEJ,CAAC,CAACpC,KAAK,EAAEmC,QAAQ,IAAInC,KAAK,EAAEmC,QAAQ,KAAK,OAAO,kBAC7C7C,KAAA,CAAA0C,aAAA,CAACrC,cAAc,EAAMgC,UAAc,CAAC,EAGvClB,WAAW,iBAAInB,KAAA,CAAA0C,aAAA,CAACnC,OAAO,MAAE,CAAC,eAG5BP,KAAA,CAAA0C,aAAA,CAACpC,kBAAkB;IAACO,IAAI,EAAGA,IAAM;IAACK,UAAU,EAAGA;EAAY,CAAE,CACxD,CACJ,CACU,CAAC;AAEtB,CAAC;AAED,OAAO,MAAM6B,aAA2C,GAAIC,KAAK,iBAAKhD,KAAA,CAAA0C,aAAA,CAACjC,aAAa,EAAMuC,KAAS,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"InputCheckbox.js","names":["React","useEffect","useState","useFormContext","HookFormWrapper","FormFieldLabel","ValidationMessages","Spinner","Icon","InputCheckbox","props","createElement","formContext","InputCheckboxField","label","field","id","name","value","defaultChecked","onBlur","onChange","onTouched","validation","showSpinner","icons","customCssClasses","customContent","isTouched","setIsTouched","register","getFieldState","setValue","fieldState","shouldValidate","shouldDirty","wrapperCssClass","wrapper","inputCssClass","input","invalid","isRequired","required","HandleOnBlur","event","target","labelProps","inputId","checkedIcon","checked","icon","uncheckedIcon","unchecked","inputProps","type","String","className","labelId","htmlFor","position","CheckboxInput"],"sources":["../../../../../../../../src/components/form/formFields/subComponents/inputs/checkbox/InputCheckbox.tsx"],"sourcesContent":["'use client';\n\nimport React, { useEffect, useState } from 'react';\nimport { useFormContext } from 'react-hook-form';\nimport { HookFormWrapper } from '../../../../hookFormWrapper/HookFormWrapper';\nimport { FormFieldLabel } from '../../labels/FormFieldLabel';\nimport { ValidationMessages } from '../../../../validation/ValidationMessages';\nimport { Spinner } from '../../../../../design/spinner/Spinner';\nimport { Icon } from '../../../../../design/icons/basicIcon/Icon';\n\nimport { InputCheckboxProps } from './inputCheckboxProps';\n\nimport './inputCheckbox.scss';\n\nexport const InputCheckbox: React.FC<InputCheckboxProps> = (props) => (\n <HookFormWrapper formContext={ props.formContext }>\n <InputCheckboxField { ...props } />\n </HookFormWrapper>\n);\n\nconst InputCheckboxField: React.FC<InputCheckboxProps> = (\n {\n label,\n field: {\n id,\n name,\n value,\n defaultChecked,\n onBlur = () => {},\n onChange = () => {},\n onTouched = () => {}\n },\n validation,\n showSpinner,\n icons,\n customCssClasses,\n customContent\n }\n) => {\n const [isTouched, setIsTouched] = useState(false);\n const { register, getFieldState, setValue } = useFormContext();\n const fieldState = getFieldState(name);\n\n // Initialize the form value with defaultChecked on mount\n useEffect(() => {\n if (defaultChecked) {\n setValue(name, true, { shouldValidate: false, shouldDirty: false });\n }\n }, [name, setValue, defaultChecked, value]);\n\n const wrapperCssClass = `formField checkBoxField ${ customCssClasses?.wrapper || '' } ${ isTouched ? 'touched' : '' }`;\n\n const inputCssClass = `${ customCssClasses?.input || '' }${ fieldState?.invalid ? ' invalidField' : '' }`;\n\n const isRequired = validation && typeof validation.required !== 'undefined';\n\n const HandleOnBlur = (event: React.FocusEvent<HTMLInputElement>) => {\n const { target } = event;\n setIsTouched(true);\n if (target) {\n onTouched();\n onBlur(event);\n }\n };\n\n const labelProps = {\n ...label,\n inputId: id,\n isRequired,\n customContent\n };\n\n const checkedIcon = icons?.checked ?? <Icon icon=\"checkbox-checked\" />;\n const uncheckedIcon = icons?.unchecked ?? <Icon icon=\"checkbox-unchecked\" />;\n\n const inputProps = {\n type: 'checkbox',\n id,\n value: String(value),\n className: inputCssClass,\n 'aria-required': isRequired,\n ...register(\n name,\n {\n onChange,\n onBlur: HandleOnBlur,\n value: defaultChecked ? true : value,\n ...validation\n }\n )\n };\n\n return (\n <div\n className={ wrapperCssClass }\n >\n <label\n id={ label.labelId || `${ id }_label` }\n className={ `${ customCssClasses?.label || '' } ${ showSpinner ? 'withSpinner' : '' }` }\n htmlFor={ id }\n >\n\n { label.position === 'left'\n && <FormFieldLabel { ...labelProps } /> }\n\n <div className=\"inputContainer\">\n <input { ...inputProps } />\n { /* The input conveys the checked state, so the icons are decorative. */ }\n <span className=\"checkboxIcons\" aria-hidden=\"true\">\n <span className=\"checkboxIcon checkboxIconUnchecked\">{ uncheckedIcon }</span>\n <span className=\"checkboxIcon checkboxIconChecked\">{ checkedIcon }</span>\n </span>\n </div>\n\n { (!label?.position || label?.position === 'right')\n && <FormFieldLabel { ...labelProps } /> }\n\n {\n showSpinner && <Spinner />\n }\n\n <ValidationMessages name={ name } validation={ validation } />\n </label>\n </div>\n );\n};\n\nexport const CheckboxInput: React.FC<InputCheckboxProps> = (props) => <InputCheckbox { ...props } />;\n"],"mappings":"AAAA,YAAY;;AAEZ,OAAOA,KAAK,IAAIC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAClD,SAASC,cAAc,QAAQ,iBAAiB;AAChD,SAASC,eAAe,QAAQ,6CAA6C;AAC7E,SAASC,cAAc,QAAQ,6BAA6B;AAC5D,SAASC,kBAAkB,QAAQ,2CAA2C;AAC9E,SAASC,OAAO,QAAQ,uCAAuC;AAC/D,SAASC,IAAI,QAAQ,4CAA4C;AAIjE,OAAO,sBAAsB;AAE7B,OAAO,MAAMC,aAA2C,GAAIC,KAAK,iBAC/DV,KAAA,CAAAW,aAAA,CAACP,eAAe;EAACQ,WAAW,EAAGF,KAAK,CAACE;AAAa,gBAChDZ,KAAA,CAAAW,aAAA,CAACE,kBAAkB,EAAMH,KAAS,CACnB,CAClB;AAED,MAAMG,kBAAgD,GAAGA,CACvD;EACEC,KAAK;EACLC,KAAK,EAAE;IACLC,EAAE;IACFC,IAAI;IACJC,KAAK;IACLC,cAAc;IACdC,MAAM,GAAGA,CAAA,KAAM,CAAC,CAAC;IACjBC,QAAQ,GAAGA,CAAA,KAAM,CAAC,CAAC;IACnBC,SAAS,GAAGA,CAAA,KAAM,CAAC;EACrB,CAAC;EACDC,UAAU;EACVC,WAAW;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AmB,CACpE,CACH,CAAC,EAEJ,CAAC,CAAClC,KAAK,EAAE6C,QAAQ,IAAI7C,KAAK,EAAE6C,QAAQ,KAAK,OAAO,kBAC7C3D,KAAA,CAAAW,aAAA,CAACN,cAAc,EAAMyC,UAAc,CAAC,EAGvCtB,WAAW,iBAAIxB,KAAA,CAAAW,aAAA,CAACJ,OAAO,MAAE,CAAC,eAG5BP,KAAA,CAAAW,aAAA,CAACL,kBAAkB;IAACW,IAAI,EAAGA,IAAM;IAACM,UAAU,EAAGA;EAAY,CAAE,CACxD,CACJ,CAAC;AAEV,CAAC;AAED,OAAO,MAAMqC,aAA2C,GAAIlD,KAAK,iBAAKV,KAAA,CAAAW,aAAA,CAACF,aAAa,EAAMC,KAAS,CAAC","ignoreList":[]}
@@ -28,15 +28,15 @@
28
28
  .checkBoxField .inputContainer input[type=checkbox] ~ .checkboxIcons .icon {
29
29
  font-size: 24px;
30
30
  }
31
- .checkBoxField .inputContainer input[type=checkbox] ~ .checkboxIcons .icon-checkbox-unchecked {
31
+ .checkBoxField .inputContainer input[type=checkbox] ~ .checkboxIcons .checkboxIconUnchecked {
32
32
  display: block;
33
33
  }
34
- .checkBoxField .inputContainer input[type=checkbox] ~ .checkboxIcons .icon-checkbox-checked {
34
+ .checkBoxField .inputContainer input[type=checkbox] ~ .checkboxIcons .checkboxIconChecked {
35
35
  display: none;
36
36
  }
37
- .checkBoxField .inputContainer input[type=checkbox][checked] ~ .checkboxIcons .icon-checkbox-unchecked, .checkBoxField .inputContainer input[type=checkbox]:checked ~ .checkboxIcons .icon-checkbox-unchecked {
37
+ .checkBoxField .inputContainer input[type=checkbox][checked] ~ .checkboxIcons .checkboxIconUnchecked, .checkBoxField .inputContainer input[type=checkbox]:checked ~ .checkboxIcons .checkboxIconUnchecked {
38
38
  display: none;
39
39
  }
40
- .checkBoxField .inputContainer input[type=checkbox][checked] ~ .checkboxIcons .icon-checkbox-checked, .checkBoxField .inputContainer input[type=checkbox]:checked ~ .checkboxIcons .icon-checkbox-checked {
40
+ .checkBoxField .inputContainer input[type=checkbox][checked] ~ .checkboxIcons .checkboxIconChecked, .checkBoxField .inputContainer input[type=checkbox]:checked ~ .checkboxIcons .checkboxIconChecked {
41
41
  display: block;
42
42
  }
@@ -1 +1 @@
1
- {"version":3,"file":"inputCheckboxProps.js","names":[],"sources":["../../../../../../../../src/components/form/formFields/subComponents/inputs/checkbox/inputCheckboxProps.ts"],"sourcesContent":["import { Message, Validate, ValidationRule } from 'react-hook-form';\nimport {\n CustomContentProps,\n CustomFieldCssClassesProps,\n FieldProps,\n FormFieldProps,\n LabelProps\n} from '../../../formFieldWrapper/formFieldProps';\n\nexport interface InputCheckboxLabelProps extends Omit<LabelProps, 'hide' | 'position'> {\n position?: 'left' | 'right';\n}\n\nexport interface InputCheckboxFieldProps extends Omit<FieldProps, 'type' | 'placeholder' | 'value' | 'defaultValue' | 'referenceDate' | 'includeEmptyOption' | 'options'> {\n value: boolean | string;\n defaultChecked?: boolean;\n defaultValue?: boolean | string | number | readonly string[];\n}\n\nexport interface InputCheckboxValidationProps<TFieldValue = unknown, TFormValues = unknown> {\n required?: Message | ValidationRule<boolean>;\n validate?: Validate<TFieldValue, TFormValues> | Record<string, Validate<TFieldValue, TFormValues>>;\n [key: string]:\n | Message\n | ValidationRule<RegExp>\n | ValidationRule<number | string | boolean>\n | Validate<TFieldValue, TFormValues>\n | Record<string, Validate<TFieldValue, TFormValues>>\n | undefined;\n}\n\nexport interface InputCheckboxProps extends Omit<FormFieldProps, 'label' | 'field' | 'layout' | 'validation'> {\n label: InputCheckboxLabelProps,\n field: InputCheckboxFieldProps,\n validation?: InputCheckboxValidationProps;\n showSpinner?: boolean;\n customCssClasses?: CustomFieldCssClassesProps;\n customContent?: CustomContentProps;\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"inputCheckboxProps.js","names":[],"sources":["../../../../../../../../src/components/form/formFields/subComponents/inputs/checkbox/inputCheckboxProps.ts"],"sourcesContent":["import { ReactElement, ReactNode } from 'react';\nimport {\n CustomContentProps,\n CustomFieldCssClassesProps,\n FieldProps,\n FormFieldProps,\n LabelProps,\n ValidationProps\n} from '../../../formFieldWrapper/formFieldProps';\n\nexport interface InputCheckboxLabelProps extends Omit<LabelProps, 'hide' | 'position'> {\n position?: 'left' | 'right';\n}\n\nexport interface InputCheckboxIconsProps {\n checked: string | ReactNode | ReactElement;\n unchecked: string | ReactNode | ReactElement;\n}\n\nexport interface InputCheckboxFieldProps extends Omit<FieldProps, 'type' | 'placeholder' | 'value' | 'defaultValue' | 'referenceDate' | 'includeEmptyOption' | 'options'> {\n value: boolean | string;\n defaultChecked?: boolean;\n defaultValue?: boolean | string | number | readonly string[];\n}\n\nexport interface InputCheckboxValidationProps<TFieldValue = unknown, TFormValues = unknown>\n extends Omit<ValidationProps<TFieldValue, TFormValues>, 'validate'> {\n}\n\nexport interface InputCheckboxProps extends Omit<FormFieldProps, 'label' | 'field' | 'layout' | 'validation'> {\n label: InputCheckboxLabelProps,\n field: InputCheckboxFieldProps,\n validation?: InputCheckboxValidationProps;\n showSpinner?: boolean;\n icons?: InputCheckboxIconsProps;\n customCssClasses?: CustomFieldCssClassesProps;\n customContent?: CustomContentProps;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1,6 +1,5 @@
1
1
  'use client';
2
2
 
3
- /* eslint-disable no-unused-vars */
4
3
  import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
5
4
  import { arrowUpFromBracket } from '@x15ventures/x15-ui-library-icons/iconDefinitions';
6
5
  import { SvgIcon } from '@x15ventures/x15-ui-library-icons/svgIcon/SvgIcon';
@@ -10,12 +9,14 @@ import { Spinner } from '../../../../../../design/spinner/Spinner';
10
9
  import { FormFieldLabel } from '../../../../subComponents/labels/FormFieldLabel';
11
10
  import { InputFile } from '../../../../subComponents/inputs/file/InputFile';
12
11
  import { ValidationMessages } from '../../../../../validation/ValidationMessages';
13
- import { NoHookFormContext } from '../../../../utilities/formUtilities';
14
12
  import { generateButtonClass } from '../../../../../buttons/button.helpers';
15
13
  import { FileAttachmentsList } from '../fileAttachmentList/FileAttachmentsList';
16
14
  import { DEFAULT_UPLOAD_FILE_EXTENSIONS, DEFAULT_UPLOAD_FILE_TYPES, BLACKLISTED_FILE_TYPES } from '../../../../../../../constants';
17
15
  import './dragAndDropFileUpload.css';
18
- export const DragAndDropFileUpload = ({
16
+ export const DragAndDropFileUpload = props => /*#__PURE__*/React.createElement(HookFormWrapper, {
17
+ formContext: props.formContext
18
+ }, /*#__PURE__*/React.createElement(DragAndDropFileUploadField, props));
19
+ const DragAndDropFileUploadField = ({
19
20
  label,
20
21
  field,
21
22
  showSpinner,
@@ -45,9 +46,8 @@ export const DragAndDropFileUpload = ({
45
46
  }) => {
46
47
  const {
47
48
  setValue,
48
- trigger,
49
- setError
50
- } = useFormContext() || NoHookFormContext;
49
+ trigger
50
+ } = useFormContext();
51
51
  const [activeFileList, setFileList] = useState(fileList || []);
52
52
  const [isTouched, setIsTouched] = useState(false);
53
53
  const [isDragActive, setIsDragActive] = useState(false);
@@ -144,7 +144,7 @@ export const DragAndDropFileUpload = ({
144
144
  ${showSpinner ? 'withSpinner' : ''}
145
145
  ${label.hide ? 'hiddenLabel' : ''}
146
146
  `;
147
- return /*#__PURE__*/React.createElement(HookFormWrapper, null, /*#__PURE__*/React.createElement("div", {
147
+ return /*#__PURE__*/React.createElement("div", {
148
148
  className: wrapperCssClass,
149
149
  onDragOver: e => {
150
150
  e.preventDefault();
@@ -203,7 +203,7 @@ export const DragAndDropFileUpload = ({
203
203
  files: activeFileList,
204
204
  onFilesRemoved: handleFilesEdited,
205
205
  onFilesEdited: handleFilesEdited
206
- })));
206
+ }));
207
207
  };
208
208
  export default {
209
209
  DragAndDropFileUpload