@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":"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":[]}
@@ -30,7 +30,7 @@ const Autocomplete = ({
30
30
  const [isOpen, setIsOpen] = (0, _react.useState)(false);
31
31
  const [filteredOptions, setFilteredOptions] = (0, _react.useState)(field.options || []);
32
32
  const [selectedOption, setSelectedOption] = (0, _react.useState)(null);
33
- const [inputValue, setInputValue] = (0, _react.useState)('');
33
+ const inputElement = (0, _react.useRef)(null);
34
34
  (0, _hooks.useOnClickOutside)(wrapperElement, () => setIsOpen(false));
35
35
  (0, _hooks.usePopupKeys)(wrapperElement, () => setIsOpen(false));
36
36
  const filterOptions = (0, _useDebounce.useDebouncedCallback)(searchTerm => {
@@ -49,15 +49,20 @@ const Autocomplete = ({
49
49
  setIsOpen(true);
50
50
  onInputChange(searchTerm);
51
51
  }, debounceTime);
52
- const handleInputChange = event => {
53
- const newValue = event.target.value;
54
- setInputValue(newValue);
55
- filterOptions(newValue.toLowerCase());
56
- };
52
+ const handleInputChange = (0, _react.useCallback)(event => {
53
+ inputElement.current = event.target;
54
+ filterOptions(event.target.value.toLowerCase());
55
+ }, [filterOptions]);
57
56
  const handleOptionSelect = option => {
58
57
  const displayValue = typeof option === 'string' ? option : JSON.stringify(option.label);
59
- setInputValue(displayValue);
60
- setValue(field.name, displayValue);
58
+ // The registered input is uncontrolled, so write to both the DOM and form state.
59
+ if (inputElement.current) {
60
+ inputElement.current.value = displayValue;
61
+ }
62
+ setValue(field.name, displayValue, {
63
+ shouldValidate: true,
64
+ shouldDirty: true
65
+ });
61
66
  setSelectedOption(option);
62
67
  setIsOpen(false);
63
68
  onOptionSelect(option);
@@ -74,8 +79,7 @@ const Autocomplete = ({
74
79
  'aria-haspopup': 'listbox',
75
80
  role: 'combobox',
76
81
  onFocus: () => setIsOpen(true),
77
- onChange: handleInputChange,
78
- defaultValue: inputValue
82
+ onChange: handleInputChange
79
83
  },
80
84
  label,
81
85
  validation,
@@ -83,7 +87,7 @@ const Autocomplete = ({
83
87
  customCssClasses,
84
88
  customContent
85
89
  };
86
- }, [field, isOpen, optionsContainerId, validation, showSpinner, customCssClasses, customContent, handleInputChange, selectedOption]);
90
+ }, [field, isOpen, optionsContainerId, label, validation, showSpinner, customCssClasses, customContent, handleInputChange]);
87
91
  return /*#__PURE__*/_react.default.createElement("div", {
88
92
  ref: wrapperElement,
89
93
  className: `autocompleteWrapper ${isOpen ? 'open' : 'closed'}`
@@ -1 +1 @@
1
- {"version":3,"file":"Autocomplete.js","names":["Object","defineProperty","exports","value","default","Autocomplete","_react","_interopRequireWildcard","require","_reactHookForm","_useDebounce","_hooks","_InputText","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","has","get","set","hasOwnProperty","call","getOwnPropertyDescriptor","field","label","validation","showSpinner","customCssClasses","customContent","onOptionSelect","onInputChange","debounceTime","setValue","useFormContext","wrapperElement","useRef","isOpen","setIsOpen","useState","filteredOptions","setFilteredOptions","options","selectedOption","setSelectedOption","inputValue","setInputValue","useOnClickOutside","usePopupKeys","filterOptions","useDebouncedCallback","searchTerm","matchingOptions","filter","option","toLowerCase","includes","JSON","stringify","handleInputChange","event","newValue","target","handleOptionSelect","displayValue","name","optionsContainerId","id","comboBoxFieldProps","useMemo","type","role","onFocus","onChange","defaultValue","createElement","ref","className","InputText","tabIndex","length","map","optionId","key","onClick","_default"],"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;;AAACA,MAAA,CAAAC,cAAA,CAAAC,OAAA;EAAAC,KAAA;AAAA;AAAAD,OAAA,CAAAE,OAAA,GAAAF,OAAA,CAAAG,Y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,QAAU;MAChB,iBAAgB5B,MAAM,KAAKX,cAAc,GAAG,MAAM,GAAG,OAAS;MAC9D4B,IAAI,EAAC,QAAQ;MACb,eAAcjB;IAAQ,gBAEtBrD,MAAA,CAAAF,OAAA,CAAA4E,aAAA;MAAQE,SAAS,EAAGvB,MAAM,KAAKX,cAAc,GAAG,UAAU,GAAG,EAAI;MAAC2B,IAAI,EAAC,QAAQ;MAACH,EAAE,EAAGe,QAAU;MAACE,OAAO,EAAGA,CAAA,KAAMrB,kBAAkB,CAACT,MAAM;IAAG,GACxI,OAAOA,MAAM,KAAK,QAAQ,GAAGA,MAAM,GAAGA,MAAM,CAAC7B,KACzC,CACN,CAAC;EAET,CAAC,CAED,CAGP,CAGN,CAAC;AAEV,CAAC;AAAC5B,OAAA,CAAAG,YAAA,GAAAA,YAAA;AAAA,IAAAqF,QAAA,GAAAxF,OAAA,CAAAE,OAAA,GAEaC,YAAY","ignoreList":[]}
1
+ {"version":3,"file":"Autocomplete.js","names":["Object","defineProperty","exports","value","default","Autocomplete","_react","_interopRequireWildcard","require","_reactHookForm","_useDebounce","_hooks","_InputText","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","has","get","set","hasOwnProperty","call","getOwnPropertyDescriptor","field","label","validation","showSpinner","customCssClasses","customContent","onOptionSelect","onInputChange","debounceTime","setValue","useFormContext","wrapperElement","useRef","isOpen","setIsOpen","useState","filteredOptions","setFilteredOptions","options","selectedOption","setSelectedOption","inputElement","useOnClickOutside","usePopupKeys","filterOptions","useDebouncedCallback","searchTerm","matchingOptions","filter","option","toLowerCase","includes","JSON","stringify","handleInputChange","useCallback","event","current","target","handleOptionSelect","displayValue","name","shouldValidate","shouldDirty","optionsContainerId","id","comboBoxFieldProps","useMemo","type","role","onFocus","onChange","createElement","ref","className","InputText","tabIndex","length","map","optionId","key","onClick","_default"],"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>\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A,CAAA6E,aAAA;IAAIE,SAAS,EAAC,UAAU;IAACL,IAAI,EAAC,SAAS;IAACJ,EAAE,EAAGD;EAAoB,GAE7D5B,eAAe,CAAC0C,GAAG,CAAE7B,MAAM,IAAK;IAC9B,MAAM8B,QAAQ,GAAG,GAAIf,kBAAkB,IAAMf,MAAM,EAAG;IAEtD,oBACEpD,MAAA,CAAAF,OAAA,CAAA6E,aAAA;MACEQ,GAAG,EAAGD,QAAU;MAChB,iBAAgB9B,MAAM,KAAKV,cAAc,GAAG,MAAM,GAAG,OAAS;MAC9D8B,IAAI,EAAC,QAAQ;MACb,eAAcpB;IAAQ,gBAEtBpD,MAAA,CAAAF,OAAA,CAAA6E,aAAA;MAAQE,SAAS,EAAGzB,MAAM,KAAKV,cAAc,GAAG,UAAU,GAAG,EAAI;MAAC6B,IAAI,EAAC,QAAQ;MAACH,EAAE,EAAGc,QAAU;MAACE,OAAO,EAAGA,CAAA,KAAMtB,kBAAkB,CAACV,MAAM;IAAG,GACxI,OAAOA,MAAM,KAAK,QAAQ,GAAGA,MAAM,GAAGA,MAAM,CAAC5B,KACzC,CACN,CAAC;EAET,CAAC,CAED,CAGP,CAGN,CAAC;AAEV,CAAC;AAAC5B,OAAA,CAAAG,YAAA,GAAAA,YAAA;AAAA,IAAAsF,QAAA,GAAAzF,OAAA,CAAAE,OAAA,GAEaC,YAAY","ignoreList":[]}
@@ -7,7 +7,6 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.InputCheckbox = exports.CheckboxInput = void 0;
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
  var _reactHookForm = require("react-hook-form");
10
- var _formUtilities = require("../../../utilities/formUtilities");
11
10
  var _HookFormWrapper = require("../../../../hookFormWrapper/HookFormWrapper");
12
11
  var _FormFieldLabel = require("../../labels/FormFieldLabel");
13
12
  var _ValidationMessages = require("../../../../validation/ValidationMessages");
@@ -15,11 +14,16 @@ var _Spinner = require("../../../../../design/spinner/Spinner");
15
14
  var _Icon = require("../../../../../design/icons/basicIcon/Icon");
16
15
  require("./inputCheckbox.css");
17
16
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
18
- const InputCheckbox = ({
17
+ const InputCheckbox = props => /*#__PURE__*/_react.default.createElement(_HookFormWrapper.HookFormWrapper, {
18
+ formContext: props.formContext
19
+ }, /*#__PURE__*/_react.default.createElement(InputCheckboxField, props));
20
+ exports.InputCheckbox = InputCheckbox;
21
+ const InputCheckboxField = ({
19
22
  label,
20
23
  field: {
21
24
  id,
22
25
  name,
26
+ value,
23
27
  defaultChecked,
24
28
  onBlur = () => {},
25
29
  onChange = () => {},
@@ -27,16 +31,27 @@ const InputCheckbox = ({
27
31
  },
28
32
  validation,
29
33
  showSpinner,
34
+ icons,
30
35
  customCssClasses,
31
36
  customContent
32
37
  }) => {
33
38
  const [isTouched, setIsTouched] = (0, _react.useState)(false);
34
39
  const {
35
40
  register,
36
- getFieldState
37
- } = (0, _reactHookForm.useFormContext)() || _formUtilities.NoHookFormContext;
38
- ;
41
+ getFieldState,
42
+ setValue
43
+ } = (0, _reactHookForm.useFormContext)();
39
44
  const fieldState = getFieldState(name);
45
+
46
+ // Initialize the form value with defaultChecked on mount
47
+ (0, _react.useEffect)(() => {
48
+ if (defaultChecked) {
49
+ setValue(name, true, {
50
+ shouldValidate: false,
51
+ shouldDirty: false
52
+ });
53
+ }
54
+ }, [name, setValue, defaultChecked, value]);
40
55
  const wrapperCssClass = `formField checkBoxField ${customCssClasses?.wrapper || ''} ${isTouched ? 'touched' : ''}`;
41
56
  const inputCssClass = `${customCssClasses?.input || ''}${fieldState?.invalid ? ' invalidField' : ''}`;
42
57
  const isRequired = validation && typeof validation.required !== 'undefined';
@@ -56,19 +71,26 @@ const InputCheckbox = ({
56
71
  isRequired,
57
72
  customContent
58
73
  };
74
+ const checkedIcon = icons?.checked ?? /*#__PURE__*/_react.default.createElement(_Icon.Icon, {
75
+ icon: "checkbox-checked"
76
+ });
77
+ const uncheckedIcon = icons?.unchecked ?? /*#__PURE__*/_react.default.createElement(_Icon.Icon, {
78
+ icon: "checkbox-unchecked"
79
+ });
59
80
  const inputProps = {
60
81
  type: 'checkbox',
61
82
  id,
83
+ value: String(value),
62
84
  className: inputCssClass,
63
- defaultChecked,
64
85
  'aria-required': isRequired,
65
86
  ...register(name, {
66
87
  onChange,
67
88
  onBlur: HandleOnBlur,
89
+ value: defaultChecked ? true : value,
68
90
  ...validation
69
91
  })
70
92
  };
71
- return /*#__PURE__*/_react.default.createElement(_HookFormWrapper.HookFormWrapper, null, /*#__PURE__*/_react.default.createElement("div", {
93
+ return /*#__PURE__*/_react.default.createElement("div", {
72
94
  className: wrapperCssClass
73
95
  }, /*#__PURE__*/_react.default.createElement("label", {
74
96
  id: label.labelId || `${id}_label`,
@@ -77,17 +99,17 @@ const InputCheckbox = ({
77
99
  }, label.position === 'left' && /*#__PURE__*/_react.default.createElement(_FormFieldLabel.FormFieldLabel, labelProps), /*#__PURE__*/_react.default.createElement("div", {
78
100
  className: "inputContainer"
79
101
  }, /*#__PURE__*/_react.default.createElement("input", inputProps), /*#__PURE__*/_react.default.createElement("span", {
80
- className: "checkboxIcons"
81
- }, /*#__PURE__*/_react.default.createElement(_Icon.Icon, {
82
- icon: "checkbox-unchecked"
83
- }), /*#__PURE__*/_react.default.createElement(_Icon.Icon, {
84
- icon: "checkbox-checked"
85
- }))), (!label?.position || label?.position === 'right') && /*#__PURE__*/_react.default.createElement(_FormFieldLabel.FormFieldLabel, labelProps), showSpinner && /*#__PURE__*/_react.default.createElement(_Spinner.Spinner, null), /*#__PURE__*/_react.default.createElement(_ValidationMessages.ValidationMessages, {
102
+ className: "checkboxIcons",
103
+ "aria-hidden": "true"
104
+ }, /*#__PURE__*/_react.default.createElement("span", {
105
+ className: "checkboxIcon checkboxIconUnchecked"
106
+ }, uncheckedIcon), /*#__PURE__*/_react.default.createElement("span", {
107
+ className: "checkboxIcon checkboxIconChecked"
108
+ }, checkedIcon))), (!label?.position || label?.position === 'right') && /*#__PURE__*/_react.default.createElement(_FormFieldLabel.FormFieldLabel, labelProps), showSpinner && /*#__PURE__*/_react.default.createElement(_Spinner.Spinner, null), /*#__PURE__*/_react.default.createElement(_ValidationMessages.ValidationMessages, {
86
109
  name: name,
87
110
  validation: validation
88
- }))));
111
+ })));
89
112
  };
90
- exports.InputCheckbox = InputCheckbox;
91
113
  const CheckboxInput = props => /*#__PURE__*/_react.default.createElement(InputCheckbox, props);
92
114
  exports.CheckboxInput = CheckboxInput;
93
115
  //# sourceMappingURL=InputCheckbox.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"InputCheckbox.js","names":["Object","defineProperty","exports","value","InputCheckbox","CheckboxInput","_react","_interopRequireWildcard","require","_reactHookForm","_formUtilities","_HookFormWrapper","_FormFieldLabel","_ValidationMessages","_Spinner","_Icon","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","getOwnPropertyDescriptor","label","field","id","name","defaultChecked","onBlur","onChange","onTouched","validation","showSpinner","customCssClasses","customContent","isTouched","setIsTouched","useState","register","getFieldState","useFormContext","NoHookFormContext","fieldState","wrapperCssClass","wrapper","inputCssClass","input","invalid","isRequired","required","HandleOnBlur","event","target","labelProps","inputId","inputProps","type","className","createElement","HookFormWrapper","labelId","htmlFor","position","FormFieldLabel","Icon","icon","Spinner","ValidationMessages","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 } />;\n"],"mappings":";AAAA,YAAY;;AAACA,MAAA,CAAAC,cAAA,CAAAC,OAAA;EAAAC,KAAA;AAAA;AAAAD,OAAA,CAAAE,aAAA,GAAAF,OAAA,CAAAG,aAAA;AAEb,IAAAC,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AACA,IAAAI,eAAA,GAAAJ,OAAA;AACA,IAAAK,mBAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,KAAA,GAAAP,OAAA;AAIAA,OAAA;AAA8B,SAAAD,wBAAAS,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAX,uBAAA,YAAAA,CAAAS,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,C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AAoB,OAAA,CAAA0C,aAAA,UAAYH,UAAc,CAAC,eAC3B3D,MAAA,CAAAoB,OAAA,CAAA0C,aAAA;IAAMD,SAAS,EAAC;EAAe,gBAC7B7D,MAAA,CAAAoB,OAAA,CAAA0C,aAAA,CAACrD,KAAA,CAAA2D,IAAI;IAACC,IAAI,EAAC;EAAoB,CAAE,CAAC,eAClCrE,MAAA,CAAAoB,OAAA,CAAA0C,aAAA,CAACrD,KAAA,CAAA2D,IAAI;IAACC,IAAI,EAAC;EAAkB,CAAE,CAC3B,CACH,CAAC,EAEJ,CAAC,CAAC1C,KAAK,EAAEuC,QAAQ,IAAIvC,KAAK,EAAEuC,QAAQ,KAAK,OAAO,kBAC7ClE,MAAA,CAAAoB,OAAA,CAAA0C,aAAA,CAACxD,eAAA,CAAA6D,cAAc,EAAMV,UAAc,CAAC,EAGvCrB,WAAW,iBAAIpC,MAAA,CAAAoB,OAAA,CAAA0C,aAAA,CAACtD,QAAA,CAAA8D,OAAO,MAAE,CAAC,eAG5BtE,MAAA,CAAAoB,OAAA,CAAA0C,aAAA,CAACvD,mBAAA,CAAAgE,kBAAkB;IAACzC,IAAI,EAAGA,IAAM;IAACK,UAAU,EAAGA;EAAY,CAAE,CACxD,CACJ,CACU,CAAC;AAEtB,CAAC;AAACvC,OAAA,CAAAE,aAAA,GAAAA,aAAA;AAEK,MAAMC,aAA2C,GAAIyE,KAAK,iBAAKxE,MAAA,CAAAoB,OAAA,CAAA0C,aAAA,CAAChE,aAAa,EAAM0E,KAAS,CAAC;AAAC5E,OAAA,CAAAG,aAAA,GAAAA,aAAA","ignoreList":[]}
1
+ {"version":3,"file":"InputCheckbox.js","names":["Object","defineProperty","exports","value","InputCheckbox","CheckboxInput","_react","_interopRequireWildcard","require","_reactHookForm","_HookFormWrapper","_FormFieldLabel","_ValidationMessages","_Spinner","_Icon","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","getOwnPropertyDescriptor","props","createElement","HookFormWrapper","formContext","InputCheckboxField","label","field","id","name","defaultChecked","onBlur","onChange","onTouched","validation","showSpinner","icons","customCssClasses","customContent","isTouched","setIsTouched","useState","register","getFieldState","setValue","useFormContext","fieldState","useEffect","shouldValidate","shouldDirty","wrapperCssClass","wrapper","inputCssClass","input","invalid","isRequired","required","HandleOnBlur","event","target","labelProps","inputId","checkedIcon","checked","Icon","icon","uncheckedIcon","unchecked","inputProps","type","String","className","labelId","htmlFor","position","FormFieldLabel","Spinner","ValidationMessages"],"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;;AAACA,MAAA,CAAAC,cAAA,CAAAC,OAAA;EAAAC,KAAA;AAAA;AAAAD,OAAA,CAAAE,aAAA,GAAAF,OAAA,CAAAG,aAAA;AAEb,IAAAC,MAA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AAK,iBAAK1B,MAAA,CAAAmB,OAAA,CAAAQ,aAAA,CAAC7B,aAAa,EAAM4B,KAAS,CAAC;AAAC9B,OAAA,CAAAG,aAAA,GAAAA,aAAA","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,7 +1,6 @@
1
1
  "use strict";
2
2
  'use client';
3
3
 
4
- /* eslint-disable no-unused-vars */
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
@@ -15,13 +14,16 @@ var _Spinner = require("../../../../../../design/spinner/Spinner");
15
14
  var _FormFieldLabel = require("../../../../subComponents/labels/FormFieldLabel");
16
15
  var _InputFile = require("../../../../subComponents/inputs/file/InputFile");
17
16
  var _ValidationMessages = require("../../../../../validation/ValidationMessages");
18
- var _formUtilities = require("../../../../utilities/formUtilities");
19
17
  var _button = require("../../../../../buttons/button.helpers");
20
18
  var _FileAttachmentsList = require("../fileAttachmentList/FileAttachmentsList");
21
19
  var _constants = require("../../../../../../../constants");
22
20
  require("./dragAndDropFileUpload.css");
23
21
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
24
- const DragAndDropFileUpload = ({
22
+ const DragAndDropFileUpload = props => /*#__PURE__*/_react.default.createElement(_HookFormWrapper.HookFormWrapper, {
23
+ formContext: props.formContext
24
+ }, /*#__PURE__*/_react.default.createElement(DragAndDropFileUploadField, props));
25
+ exports.DragAndDropFileUpload = DragAndDropFileUpload;
26
+ const DragAndDropFileUploadField = ({
25
27
  label,
26
28
  field,
27
29
  showSpinner,
@@ -51,9 +53,8 @@ const DragAndDropFileUpload = ({
51
53
  }) => {
52
54
  const {
53
55
  setValue,
54
- trigger,
55
- setError
56
- } = (0, _reactHookForm.useFormContext)() || _formUtilities.NoHookFormContext;
56
+ trigger
57
+ } = (0, _reactHookForm.useFormContext)();
57
58
  const [activeFileList, setFileList] = (0, _react.useState)(fileList || []);
58
59
  const [isTouched, setIsTouched] = (0, _react.useState)(false);
59
60
  const [isDragActive, setIsDragActive] = (0, _react.useState)(false);
@@ -150,7 +151,7 @@ const DragAndDropFileUpload = ({
150
151
  ${showSpinner ? 'withSpinner' : ''}
151
152
  ${label.hide ? 'hiddenLabel' : ''}
152
153
  `;
153
- return /*#__PURE__*/_react.default.createElement(_HookFormWrapper.HookFormWrapper, null, /*#__PURE__*/_react.default.createElement("div", {
154
+ return /*#__PURE__*/_react.default.createElement("div", {
154
155
  className: wrapperCssClass,
155
156
  onDragOver: e => {
156
157
  e.preventDefault();
@@ -209,9 +210,8 @@ const DragAndDropFileUpload = ({
209
210
  files: activeFileList,
210
211
  onFilesRemoved: handleFilesEdited,
211
212
  onFilesEdited: handleFilesEdited
212
- })));
213
+ }));
213
214
  };
214
- exports.DragAndDropFileUpload = DragAndDropFileUpload;
215
215
  var _default = exports.default = {
216
216
  DragAndDropFileUpload
217
217
  };
@@ -1 +1 @@
1
- {"version":3,"file":"DragAndDropFileUpload.js","names":["Object","defineProperty","exports","value","default","DragAndDropFileUpload","_react","_interopRequireWildcard","require","_iconDefinitions","_SvgIcon","_reactHookForm","_HookFormWrapper","_Spinner","_FormFieldLabel","_InputFile","_ValidationMessages","_formUtilities","_button","_FileAttachmentsList","_constants","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","has","get","set","hasOwnProperty","call","getOwnPropertyDescriptor","label","field","showSpinner","fileDisplayStyle","fileListSettings","fileList","validation","customContent","customCssClasses","labelStyle","labelAsButtonStyles","color","variant","labelUploadIcon","createElement","SvgIcon","svgDefinition","arrowUpFromBracket","multiple","restrictionsTxt","validFiles","extensions","DEFAULT_UPLOAD_FILE_EXTENSIONS","fileTypes","DEFAULT_UPLOAD_FILE_TYPES","maxFileCount","maxFileSize","onFilesChange","setValue","trigger","setError","useFormContext","NoHookFormContext","activeFileList","setFileList","useState","isTouched","setIsTouched","isDragActive","setIsDragActive","inputId","id","inputElRef","useRef","dialogOpenRef","useEffect","current","document","getElementById","onFocus","noneSelected","files","length","name","window","addEventListener","removeEventListener","supportedFileTypes","useMemo","join","validateAndCommit","useCallback","validated","filter","file","ext","split","pop","toLowerCase","isBlacklisted","BLACKLISTED_FILE_TYPES","includes","isValidExt","isValidSize","size","clipped","slice","shouldValidate","shouldDirty","shouldTouch","handleFileInputChange","event","target","Array","from","handleDrop","dropped","handleFilesEdited","wrapperCssClass","wrapper","position","labelProps","isRequired","required","labelStyleAsButtonClasses","generateButtonClass","cssClass","buttonStyle","hideLabel","hide","labelCssClass","HookFormWrapper","className","onDragOver","preventDefault","onDragLeave","currentTarget","onDrop","dataTransfer","labelId","htmlFor","onClick","FormFieldLabel","InputFile","type","defaultValue","accept","onInput","Spinner","map","index","key","ValidationMessages","FileAttachmentsList","customFileListSettings","onFilesRemoved","onFilesEdited","_default"],"sources":["../../../../../../../../../src/components/form/formFields/subComponents/inputs/file/dragAndDrop/DragAndDropFileUpload.tsx"],"sourcesContent":["'use client';\n\n/* eslint-disable no-unused-vars */\nimport React, { FormEvent, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { arrowUpFromBracket } from '@x15ventures/x15-ui-library-icons/iconDefinitions';\nimport { SvgIcon } from '@x15ventures/x15-ui-library-icons/svgIcon/SvgIcon';\nimport { useFormContext } from 'react-hook-form';\nimport { HookFormWrapper } from '../../../../../hookFormWrapper/HookFormWrapper';\nimport { Spinner } from '../../../../../../design/spinner/Spinner';\nimport { FormFieldLabel } from '../../../../subComponents/labels/FormFieldLabel';\nimport { InputFile } from '../../../../subComponents/inputs/file/InputFile';\nimport { ValidationMessages } from '../../../../../validation/ValidationMessages';\nimport { NoHookFormContext } from '../../../../utilities/formUtilities';\nimport { generateButtonClass } from '../../../../../buttons/button.helpers';\nimport { FileAttachmentsList } from '../fileAttachmentList/FileAttachmentsList';\nimport { DragAndDropFileUploadProps } from '../fileInputProps';\nimport {\n DEFAULT_UPLOAD_FILE_EXTENSIONS,\n DEFAULT_UPLOAD_FILE_TYPES,\n BLACKLISTED_FILE_TYPES\n} from '../../../../../../../constants';\n\nimport './dragAndDropFileUpload.scss';\n\nexport const DragAndDropFileUpload: React.FC<DragAndDropFileUploadProps> = (\n {\n label,\n field,\n showSpinner,\n fileDisplayStyle = 'names',\n fileListSettings,\n fileList,\n validation,\n customContent,\n customCssClasses,\n labelStyle = 'dragArea',\n labelAsButtonStyles = { color: 'primary', variant: 'outline' },\n labelUploadIcon = <SvgIcon svgDefinition={ arrowUpFromBracket } />,\n multiple = false,\n restrictionsTxt = '',\n validFiles = {\n extensions: DEFAULT_UPLOAD_FILE_EXTENSIONS,\n fileTypes: DEFAULT_UPLOAD_FILE_TYPES,\n maxFileCount: 5,\n maxFileSize: 52428800 // 50 MB\n },\n onFilesChange = () => {}\n }\n) => {\n const { setValue, trigger, setError } = useFormContext() || NoHookFormContext;\n\n const [activeFileList, setFileList] = useState<File[]>(fileList || []);\n const [isTouched, setIsTouched] = useState(false);\n const [isDragActive, setIsDragActive] = useState(false);\n\n const inputId = field.id;\n const inputElRef = useRef<HTMLInputElement | null>(null);\n const dialogOpenRef = useRef(false);\n\n useEffect(() => {\n inputElRef.current = document.getElementById(inputId) as HTMLInputElement | null;\n }, [inputId]);\n\n // Detect “Cancel” -> dialog closes, window regains focus, but input had no change.\n useEffect(() => {\n const onFocus = () => {\n if (!dialogOpenRef.current) { return; }\n dialogOpenRef.current = false;\n const noneSelected = !inputElRef.current?.files?.length;\n if (noneSelected) {\n // Trigger React Hook Form validators (e.g., required)\n trigger(field.name);\n }\n };\n window.addEventListener('focus', onFocus);\n return () => window.removeEventListener('focus', onFocus);\n }, [trigger, field.name]);\n\n const supportedFileTypes = useMemo(\n () => validFiles?.fileTypes?.join(', ') || '',\n [validFiles?.fileTypes]\n );\n\n const validateAndCommit = useCallback(\n (files: File[]) => {\n // basic validations\n const validated = files.filter((file) => {\n const ext = file.name.split('.').pop()?.toLowerCase() || '';\n const isBlacklisted = BLACKLISTED_FILE_TYPES.includes(ext);\n const isValidExt = validFiles.extensions ? validFiles.extensions.includes(ext) : true;\n const isValidSize = validFiles.maxFileSize ? file.size <= validFiles.maxFileSize : true;\n return !isBlacklisted && isValidExt && isValidSize;\n });\n\n const clipped = validFiles.maxFileCount\n ? validated.slice(0, validFiles.maxFileCount)\n : validated;\n\n setFileList(clipped);\n setIsTouched(true);\n\n setValue(field.name, clipped.length ? clipped : null, {\n shouldValidate: true,\n shouldDirty: true,\n shouldTouch: true\n });\n\n onFilesChange(clipped);\n },\n [field.name, onFilesChange, setValue, fileDisplayStyle, validFiles]\n );\n\n const handleFileInputChange = useCallback((event: FormEvent<HTMLInputElement>) => {\n const target = event.target as HTMLInputElement;\n const files = Array.from(target.files ?? []);\n validateAndCommit(files);\n trigger(field.name);\n dialogOpenRef.current = false;\n }, [trigger, field.name, validateAndCommit]);\n\n const handleDrop = useCallback((dropped: File[]) => {\n validateAndCommit(dropped);\n trigger(field.name);\n }, [trigger, field.name, validateAndCommit]);\n\n const handleFilesEdited = useCallback((files: File[]) => {\n // No need to validate again as they were already validated\n // Changes may include renaming or removing files\n setFileList(files);\n setValue(field.name, files.length > 0 ? files : null, {\n shouldValidate: true,\n shouldDirty: true,\n shouldTouch: true\n });\n onFilesChange(files);\n }, [field.name, setValue, onFilesChange]);\n\n const wrapperCssClass = `\n formField \n dragAndDropFileUpload \n ${ fileDisplayStyle === 'list' ? 'withFileList' : '' } \n ${ labelStyle || '' }Style \n ${ customCssClasses?.wrapper || '' } \n ${ isTouched ? 'touched' : '' } \n ${ typeof validation !== 'undefined' ? 'withValidation' : '' } \n ${ label?.position === 'inset' ? 'insetLabel' : '' } \n ${ isDragActive ? 'isDragActive' : '' }\n `;\n\n const labelProps = {\n ...label,\n inputId: inputId,\n isRequired: validation && typeof validation.required !== 'undefined',\n customContent\n };\n\n const labelStyleAsButtonClasses = generateButtonClass({\n cssClass: 'button dragAndDropFileUploadButtonLabel',\n buttonStyle: labelAsButtonStyles,\n hideLabel: label.hide\n });\n\n const labelCssClass = `\n ${ labelStyle === 'button' ? labelStyleAsButtonClasses : '' }\n ${ customCssClasses?.label || '' } \n ${ showSpinner ? 'withSpinner' : '' } \n ${ label.hide ? 'hiddenLabel' : '' }\n `;\n\n return (\n <HookFormWrapper>\n <div\n className={ wrapperCssClass }\n onDragOver={ (e) => {\n e.preventDefault();\n if (!isDragActive) setIsDragActive(true);\n } }\n onDragLeave={ (e) => {\n if (e.currentTarget === e.target) setIsDragActive(false);\n } }\n onDrop={ (e) => {\n e.preventDefault();\n setIsDragActive(false);\n const files = Array.from(e.dataTransfer?.files ?? []);\n handleDrop(files);\n } }\n >\n <label\n id={ label.labelId || `${ inputId }_label` }\n className={ labelCssClass }\n htmlFor={ inputId }\n onClick={ () => { dialogOpenRef.current = true; } }\n >\n <span className=\"dragAndDropFileUploadLabel\">\n { labelUploadIcon || null }\n <FormFieldLabel { ...labelProps } />\n { restrictionsTxt && <span className=\"fileRestrictionsText\">{ restrictionsTxt }</span> }\n </span>\n\n <span className=\"inputContainer\">\n <InputFile\n {\n ...{\n label,\n field: {\n ...field,\n type: 'file',\n id: inputId, // ensure we can query it by id\n defaultValue: '',\n multiple,\n accept: supportedFileTypes,\n onInput: (event: FormEvent<HTMLInputElement>) => {\n handleFileInputChange(event);\n }\n },\n validation,\n showSpinner,\n customCssClasses,\n customContent\n }\n }\n />\n </span>\n\n { showSpinner && <Spinner /> }\n\n { fileDisplayStyle === 'names' && activeFileList.length > 0 && (\n <span className=\"uploadedFileNames\">\n { activeFileList.map((file, index) => (\n <small key={ index } className=\"uploadedFileName\">\n { file.name }{ index < activeFileList.length - 1 ? ', ' : '' }\n </small>\n )) }\n </span>\n ) }\n\n <ValidationMessages name={ field.name } validation={ validation } />\n </label>\n\n { fileDisplayStyle === 'list' && activeFileList.length > 0 && (\n <FileAttachmentsList\n customFileListSettings={ fileListSettings }\n files={ activeFileList }\n onFilesRemoved={ handleFilesEdited }\n onFilesEdited={ handleFilesEdited }\n />\n ) }\n </div>\n </HookFormWrapper>\n );\n};\n\nexport default { DragAndDropFileUpload };\n"],"mappings":";AAAA,YAAY;;AAEZ;AAAAA,MAAA,CAAAC,cAAA,CAAAC,OAAA;EAAAC,KAAA;AAAA;AAAAD,OAAA,CAAAE,OAAA,GAAAF,OAAA,CAAAG,qBAAA;AACA,IAAAC,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AACA,IAAAI,gBAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,eAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAP,OAAA;AACA,IAAAQ,mBAAA,GAAAR,OAAA;AACA,IAAAS,cAAA,GAAAT,OAAA;AACA,IAAAU,OAAA,GAAAV,OAAA;AACA,IAAAW,oBAAA,GAAAX,OAAA;AAEA,IAAAY,UAAA,GAAAZ,OAAA;AAMAA,OAAA;AAAsC,SAAAD,wBAAAc,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,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AA,CAAChC,oBAAA,CAAA6I,mBAAmB;IAClBC,sBAAsB,EAAGxH,gBAAkB;IAC3C+C,KAAK,EAAGlB,cAAgB;IACxB4F,cAAc,EAAGtC,iBAAmB;IACpCuC,aAAa,EAAGvC;EAAmB,CACpC,CAEA,CACU,CAAC;AAEtB,CAAC;AAAC1H,OAAA,CAAAG,qBAAA,GAAAA,qBAAA;AAAA,IAAA+J,QAAA,GAAAlK,OAAA,CAAAE,OAAA,GAEa;EAAEC;AAAsB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"DragAndDropFileUpload.js","names":["Object","defineProperty","exports","value","default","DragAndDropFileUpload","_react","_interopRequireWildcard","require","_iconDefinitions","_SvgIcon","_reactHookForm","_HookFormWrapper","_Spinner","_FormFieldLabel","_InputFile","_ValidationMessages","_button","_FileAttachmentsList","_constants","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","has","get","set","hasOwnProperty","call","getOwnPropertyDescriptor","props","createElement","HookFormWrapper","formContext","DragAndDropFileUploadField","label","field","showSpinner","fileDisplayStyle","fileListSettings","fileList","validation","customContent","customCssClasses","labelStyle","labelAsButtonStyles","color","variant","labelUploadIcon","SvgIcon","svgDefinition","arrowUpFromBracket","multiple","restrictionsTxt","validFiles","extensions","DEFAULT_UPLOAD_FILE_EXTENSIONS","fileTypes","DEFAULT_UPLOAD_FILE_TYPES","maxFileCount","maxFileSize","onFilesChange","setValue","trigger","useFormContext","activeFileList","setFileList","useState","isTouched","setIsTouched","isDragActive","setIsDragActive","inputId","id","inputElRef","useRef","dialogOpenRef","useEffect","current","document","getElementById","onFocus","noneSelected","files","length","name","window","addEventListener","removeEventListener","supportedFileTypes","useMemo","join","validateAndCommit","useCallback","validated","filter","file","ext","split","pop","toLowerCase","isBlacklisted","BLACKLISTED_FILE_TYPES","includes","isValidExt","isValidSize","size","clipped","slice","shouldValidate","shouldDirty","shouldTouch","handleFileInputChange","event","target","Array","from","handleDrop","dropped","handleFilesEdited","wrapperCssClass","wrapper","position","labelProps","isRequired","required","labelStyleAsButtonClasses","generateButtonClass","cssClass","buttonStyle","hideLabel","hide","labelCssClass","className","onDragOver","preventDefault","onDragLeave","currentTarget","onDrop","dataTransfer","labelId","htmlFor","onClick","FormFieldLabel","InputFile","type","defaultValue","accept","onInput","Spinner","map","index","key","ValidationMessages","FileAttachmentsList","customFileListSettings","onFilesRemoved","onFilesEdited","_default"],"sources":["../../../../../../../../../src/components/form/formFields/subComponents/inputs/file/dragAndDrop/DragAndDropFileUpload.tsx"],"sourcesContent":["'use client';\n\nimport React, { FormEvent, useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { arrowUpFromBracket } from '@x15ventures/x15-ui-library-icons/iconDefinitions';\nimport { SvgIcon } from '@x15ventures/x15-ui-library-icons/svgIcon/SvgIcon';\nimport { useFormContext } from 'react-hook-form';\nimport { HookFormWrapper } from '../../../../../hookFormWrapper/HookFormWrapper';\nimport { Spinner } from '../../../../../../design/spinner/Spinner';\nimport { FormFieldLabel } from '../../../../subComponents/labels/FormFieldLabel';\nimport { InputFile } from '../../../../subComponents/inputs/file/InputFile';\nimport { ValidationMessages } from '../../../../../validation/ValidationMessages';\nimport { generateButtonClass } from '../../../../../buttons/button.helpers';\nimport { FileAttachmentsList } from '../fileAttachmentList/FileAttachmentsList';\nimport { DragAndDropFileUploadProps } from '../fileInputProps';\nimport {\n DEFAULT_UPLOAD_FILE_EXTENSIONS,\n DEFAULT_UPLOAD_FILE_TYPES,\n BLACKLISTED_FILE_TYPES\n} from '../../../../../../../constants';\n\nimport './dragAndDropFileUpload.scss';\n\nexport const DragAndDropFileUpload: React.FC<DragAndDropFileUploadProps> = (props) => (\n <HookFormWrapper formContext={ props.formContext }>\n <DragAndDropFileUploadField { ...props } />\n </HookFormWrapper>\n);\n\nconst DragAndDropFileUploadField: React.FC<DragAndDropFileUploadProps> = (\n {\n label,\n field,\n showSpinner,\n fileDisplayStyle = 'names',\n fileListSettings,\n fileList,\n validation,\n customContent,\n customCssClasses,\n labelStyle = 'dragArea',\n labelAsButtonStyles = { color: 'primary', variant: 'outline' },\n labelUploadIcon = <SvgIcon svgDefinition={ arrowUpFromBracket } />,\n multiple = false,\n restrictionsTxt = '',\n validFiles = {\n extensions: DEFAULT_UPLOAD_FILE_EXTENSIONS,\n fileTypes: DEFAULT_UPLOAD_FILE_TYPES,\n maxFileCount: 5,\n maxFileSize: 52428800 // 50 MB\n },\n onFilesChange = () => {}\n }\n) => {\n const { setValue, trigger } = useFormContext();\n\n const [activeFileList, setFileList] = useState<File[]>(fileList || []);\n const [isTouched, setIsTouched] = useState(false);\n const [isDragActive, setIsDragActive] = useState(false);\n\n const inputId = field.id;\n const inputElRef = useRef<HTMLInputElement | null>(null);\n const dialogOpenRef = useRef(false);\n\n useEffect(() => {\n inputElRef.current = document.getElementById(inputId) as HTMLInputElement | null;\n }, [inputId]);\n\n // Detect “Cancel” -> dialog closes, window regains focus, but input had no change.\n useEffect(() => {\n const onFocus = () => {\n if (!dialogOpenRef.current) { return; }\n dialogOpenRef.current = false;\n const noneSelected = !inputElRef.current?.files?.length;\n if (noneSelected) {\n // Trigger React Hook Form validators (e.g., required)\n trigger(field.name);\n }\n };\n window.addEventListener('focus', onFocus);\n return () => window.removeEventListener('focus', onFocus);\n }, [trigger, field.name]);\n\n const supportedFileTypes = useMemo(\n () => validFiles?.fileTypes?.join(', ') || '',\n [validFiles?.fileTypes]\n );\n\n const validateAndCommit = useCallback(\n (files: File[]) => {\n // basic validations\n const validated = files.filter((file) => {\n const ext = file.name.split('.').pop()?.toLowerCase() || '';\n const isBlacklisted = BLACKLISTED_FILE_TYPES.includes(ext);\n const isValidExt = validFiles.extensions ? validFiles.extensions.includes(ext) : true;\n const isValidSize = validFiles.maxFileSize ? file.size <= validFiles.maxFileSize : true;\n return !isBlacklisted && isValidExt && isValidSize;\n });\n\n const clipped = validFiles.maxFileCount\n ? validated.slice(0, validFiles.maxFileCount)\n : validated;\n\n setFileList(clipped);\n setIsTouched(true);\n\n setValue(field.name, clipped.length ? clipped : null, {\n shouldValidate: true,\n shouldDirty: true,\n shouldTouch: true\n });\n\n onFilesChange(clipped);\n },\n [field.name, onFilesChange, setValue, fileDisplayStyle, validFiles]\n );\n\n const handleFileInputChange = useCallback((event: FormEvent<HTMLInputElement>) => {\n const target = event.target as HTMLInputElement;\n const files = Array.from(target.files ?? []);\n validateAndCommit(files);\n trigger(field.name);\n dialogOpenRef.current = false;\n }, [trigger, field.name, validateAndCommit]);\n\n const handleDrop = useCallback((dropped: File[]) => {\n validateAndCommit(dropped);\n trigger(field.name);\n }, [trigger, field.name, validateAndCommit]);\n\n const handleFilesEdited = useCallback((files: File[]) => {\n // No need to validate again as they were already validated\n // Changes may include renaming or removing files\n setFileList(files);\n setValue(field.name, files.length > 0 ? files : null, {\n shouldValidate: true,\n shouldDirty: true,\n shouldTouch: true\n });\n onFilesChange(files);\n }, [field.name, setValue, onFilesChange]);\n\n const wrapperCssClass = `\n formField \n dragAndDropFileUpload \n ${ fileDisplayStyle === 'list' ? 'withFileList' : '' } \n ${ labelStyle || '' }Style \n ${ customCssClasses?.wrapper || '' } \n ${ isTouched ? 'touched' : '' } \n ${ typeof validation !== 'undefined' ? 'withValidation' : '' } \n ${ label?.position === 'inset' ? 'insetLabel' : '' } \n ${ isDragActive ? 'isDragActive' : '' }\n `;\n\n const labelProps = {\n ...label,\n inputId: inputId,\n isRequired: validation && typeof validation.required !== 'undefined',\n customContent\n };\n\n const labelStyleAsButtonClasses = generateButtonClass({\n cssClass: 'button dragAndDropFileUploadButtonLabel',\n buttonStyle: labelAsButtonStyles,\n hideLabel: label.hide\n });\n\n const labelCssClass = `\n ${ labelStyle === 'button' ? labelStyleAsButtonClasses : '' }\n ${ customCssClasses?.label || '' } \n ${ showSpinner ? 'withSpinner' : '' } \n ${ label.hide ? 'hiddenLabel' : '' }\n `;\n\n return (\n <div\n className={ wrapperCssClass }\n onDragOver={ (e) => {\n e.preventDefault();\n if (!isDragActive) setIsDragActive(true);\n } }\n onDragLeave={ (e) => {\n if (e.currentTarget === e.target) setIsDragActive(false);\n } }\n onDrop={ (e) => {\n e.preventDefault();\n setIsDragActive(false);\n const files = Array.from(e.dataTransfer?.files ?? []);\n handleDrop(files);\n } }\n >\n <label\n id={ label.labelId || `${ inputId }_label` }\n className={ labelCssClass }\n htmlFor={ inputId }\n onClick={ () => { dialogOpenRef.current = true; } }\n >\n <span className=\"dragAndDropFileUploadLabel\">\n { labelUploadIcon || null }\n <FormFieldLabel { ...labelProps } />\n { restrictionsTxt && <span className=\"fileRestrictionsText\">{ restrictionsTxt }</span> }\n </span>\n\n <span className=\"inputContainer\">\n <InputFile\n {\n ...{\n label,\n field: {\n ...field,\n type: 'file',\n id: inputId, // ensure we can query it by id\n defaultValue: '',\n multiple,\n accept: supportedFileTypes,\n onInput: (event: FormEvent<HTMLInputElement>) => {\n handleFileInputChange(event);\n }\n },\n validation,\n showSpinner,\n customCssClasses,\n customContent\n }\n }\n />\n </span>\n\n { showSpinner && <Spinner /> }\n\n { fileDisplayStyle === 'names' && activeFileList.length > 0 && (\n <span className=\"uploadedFileNames\">\n { activeFileList.map((file, index) => (\n <small key={ index } className=\"uploadedFileName\">\n { file.name }{ index < activeFileList.length - 1 ? ', ' : '' }\n </small>\n )) }\n </span>\n ) }\n\n <ValidationMessages name={ field.name } validation={ validation } />\n </label>\n\n { fileDisplayStyle === 'list' && activeFileList.length > 0 && (\n <FileAttachmentsList\n customFileListSettings={ fileListSettings }\n files={ activeFileList }\n onFilesRemoved={ handleFilesEdited }\n onFilesEdited={ handleFilesEdited }\n />\n ) }\n </div>\n );\n};\n\nexport default { DragAndDropFileUpload };\n"],"mappings":";AAAA,YAAY;;AAACA,MAAA,CAAAC,cAAA,CAAAC,OAAA;EAAAC,KAAA;AAAA;AAAAD,OAAA,CAAAE,OAAA,GAAAF,OAAA,CAAAG,qBAAA;AAEb,IAAAC,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAA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,CAAAF,OAAA,CAAAiC,aAAA;IAAMsG,SAAS,EAAC;EAAmB,GAC/BpE,cAAc,CAACqF,GAAG,CAAC,CAACtD,IAAI,EAAEuD,KAAK,kBAC/BvJ,MAAA,CAAAF,OAAA,CAAAiC,aAAA;IAAOyH,GAAG,EAAGD,KAAO;IAAClB,SAAS,EAAC;EAAkB,GAC7CrC,IAAI,CAACX,IAAI,EAAIkE,KAAK,GAAGtF,cAAc,CAACmB,MAAM,GAAG,CAAC,GAAG,IAAI,GAAG,EACrD,CACR,CACG,CACP,eAEDpF,MAAA,CAAAF,OAAA,CAAAiC,aAAA,CAACrB,mBAAA,CAAA+I,kBAAkB;IAACpE,IAAI,EAAGjD,KAAK,CAACiD,IAAM;IAAC5C,UAAU,EAAGA;EAAY,CAAE,CAC9D,CAAC,EAENH,gBAAgB,KAAK,MAAM,IAAI2B,cAAc,CAACmB,MAAM,GAAG,CAAC,iBACxDpF,MAAA,CAAAF,OAAA,CAAAiC,aAAA,CAACnB,oBAAA,CAAA8I,mBAAmB;IAClBC,sBAAsB,EAAGpH,gBAAkB;IAC3C4C,KAAK,EAAGlB,cAAgB;IACxB2F,cAAc,EAAGrC,iBAAmB;IACpCsC,aAAa,EAAGtC;EAAmB,CACpC,CAEA,CAAC;AAEV,CAAC;AAAC,IAAAuC,QAAA,GAAAlK,OAAA,CAAAE,OAAA,GAEa;EAAEC;AAAsB,CAAC","ignoreList":[]}
@@ -33,11 +33,19 @@ const StyledRadioGroup = ({
33
33
  }) => {
34
34
  const [isTouched, setIsTouched] = (0, _react.useState)(false);
35
35
  const {
36
- getValues,
36
+ control,
37
37
  setValue
38
38
  } = (0, _reactHookForm.useFormContext)();
39
- const [groupValue, setGroupValue] = (0, _react.useState)(typeof defaultGroupValue !== 'undefined' ? defaultGroupValue : getValues(groupName));
39
+ const groupValue = (0, _reactHookForm.useWatch)({
40
+ control,
41
+ name: groupName
42
+ });
40
43
  const radioInputsGroup = (0, _react.useRef)(null);
44
+ (0, _react.useEffect)(() => {
45
+ if (typeof defaultGroupValue !== 'undefined') {
46
+ setValue(groupName, defaultGroupValue);
47
+ }
48
+ }, [defaultGroupValue, groupName, setValue]);
41
49
  (0, _hooks.useTabbableInputGroup)({
42
50
  groupWrappingElementRef: radioInputsGroup
43
51
  });
@@ -46,8 +54,10 @@ const StyledRadioGroup = ({
46
54
  target
47
55
  } = event;
48
56
  const newValue = target.value;
49
- setValue(groupName, newValue);
50
- setGroupValue(newValue);
57
+ setValue(groupName, newValue, {
58
+ shouldValidate: true,
59
+ shouldDirty: true
60
+ });
51
61
  setIsTouched(true);
52
62
  onChange(newValue);
53
63
  };