@postenbring/hedwig-react 4.2.0 → 4.2.2

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 (115) hide show
  1. package/dist/{chunk-J2DJ6ELO.mjs → chunk-62VLFCXX.mjs} +2 -2
  2. package/dist/{chunk-GIFDGUFW.mjs → chunk-DMRQEQQK.mjs} +2 -2
  3. package/dist/{chunk-54HLJVAF.mjs → chunk-DOW6EHBI.mjs} +2 -2
  4. package/dist/{chunk-7REW23LO.mjs → chunk-F23MNQCK.mjs} +4 -8
  5. package/dist/chunk-F23MNQCK.mjs.map +1 -0
  6. package/dist/chunk-JGQTAIEP.mjs +67 -0
  7. package/dist/chunk-JGQTAIEP.mjs.map +1 -0
  8. package/dist/{chunk-BUFV457A.mjs → chunk-JGYPZ7ET.mjs} +3 -3
  9. package/dist/{chunk-NMW3IWZ4.mjs → chunk-OQD4GKOS.mjs} +2 -2
  10. package/dist/{chunk-OHPDYPZ5.mjs → chunk-QER35NXN.mjs} +2 -2
  11. package/dist/{chunk-4K54KSRB.mjs → chunk-QOIBRXYT.mjs} +2 -2
  12. package/dist/{chunk-6O5AEAIL.mjs → chunk-RGZSYJFL.mjs} +2 -2
  13. package/dist/chunk-RJ763KDH.mjs +21 -0
  14. package/dist/chunk-RJ763KDH.mjs.map +1 -0
  15. package/dist/{chunk-77UAHNU6.mjs → chunk-VNH7CZJ4.mjs} +2 -2
  16. package/dist/form/checkbox/checkbox.js +3 -6
  17. package/dist/form/checkbox/checkbox.js.map +1 -1
  18. package/dist/form/checkbox/checkbox.mjs +4 -4
  19. package/dist/form/checkbox/index.js +3 -6
  20. package/dist/form/checkbox/index.js.map +1 -1
  21. package/dist/form/checkbox/index.mjs +4 -4
  22. package/dist/form/date-picker/date-picker.js +3 -6
  23. package/dist/form/date-picker/date-picker.js.map +1 -1
  24. package/dist/form/date-picker/date-picker.mjs +4 -4
  25. package/dist/form/date-picker/index.js +3 -6
  26. package/dist/form/date-picker/index.js.map +1 -1
  27. package/dist/form/date-picker/index.mjs +4 -4
  28. package/dist/form/error-message/error-message.js +3 -6
  29. package/dist/form/error-message/error-message.js.map +1 -1
  30. package/dist/form/error-message/error-message.mjs +2 -2
  31. package/dist/form/error-message/index.js +3 -6
  32. package/dist/form/error-message/index.js.map +1 -1
  33. package/dist/form/error-message/index.mjs +2 -2
  34. package/dist/form/error-summary/error-summary.mjs +1 -1
  35. package/dist/form/error-summary/index.mjs +1 -1
  36. package/dist/form/fieldset/fieldset.js +3 -6
  37. package/dist/form/fieldset/fieldset.js.map +1 -1
  38. package/dist/form/fieldset/fieldset.mjs +3 -3
  39. package/dist/form/fieldset/index.js +3 -6
  40. package/dist/form/fieldset/index.js.map +1 -1
  41. package/dist/form/fieldset/index.mjs +3 -3
  42. package/dist/form/index.js +51 -60
  43. package/dist/form/index.js.map +1 -1
  44. package/dist/form/index.mjs +13 -13
  45. package/dist/form/input/index.js +3 -6
  46. package/dist/form/input/index.js.map +1 -1
  47. package/dist/form/input/index.mjs +4 -4
  48. package/dist/form/input/input.js +3 -6
  49. package/dist/form/input/input.js.map +1 -1
  50. package/dist/form/input/input.mjs +4 -4
  51. package/dist/form/input-group/index.js +3 -6
  52. package/dist/form/input-group/index.js.map +1 -1
  53. package/dist/form/input-group/index.mjs +3 -3
  54. package/dist/form/input-group/input-group.js +3 -6
  55. package/dist/form/input-group/input-group.js.map +1 -1
  56. package/dist/form/input-group/input-group.mjs +3 -3
  57. package/dist/form/radio-button/index.js +3 -6
  58. package/dist/form/radio-button/index.js.map +1 -1
  59. package/dist/form/radio-button/index.mjs +5 -5
  60. package/dist/form/radio-button/radio-button.js +3 -6
  61. package/dist/form/radio-button/radio-button.js.map +1 -1
  62. package/dist/form/radio-button/radio-button.mjs +5 -5
  63. package/dist/form/radio-button/radio-group.js +3 -6
  64. package/dist/form/radio-button/radio-group.js.map +1 -1
  65. package/dist/form/radio-button/radio-group.mjs +4 -4
  66. package/dist/form/search-wrapper/index.js +6 -17
  67. package/dist/form/search-wrapper/index.js.map +1 -1
  68. package/dist/form/search-wrapper/index.mjs +1 -1
  69. package/dist/form/search-wrapper/search-wrapper.d.ts +2 -5
  70. package/dist/form/search-wrapper/search-wrapper.d.ts.map +1 -1
  71. package/dist/form/search-wrapper/search-wrapper.js +6 -17
  72. package/dist/form/search-wrapper/search-wrapper.js.map +1 -1
  73. package/dist/form/search-wrapper/search-wrapper.mjs +1 -1
  74. package/dist/form/select/index.js +45 -46
  75. package/dist/form/select/index.js.map +1 -1
  76. package/dist/form/select/index.mjs +4 -4
  77. package/dist/form/select/select.d.ts.map +1 -1
  78. package/dist/form/select/select.js +45 -46
  79. package/dist/form/select/select.js.map +1 -1
  80. package/dist/form/select/select.mjs +4 -4
  81. package/dist/form/textarea/index.js +3 -6
  82. package/dist/form/textarea/index.js.map +1 -1
  83. package/dist/form/textarea/index.mjs +4 -4
  84. package/dist/form/textarea/textarea.js +3 -6
  85. package/dist/form/textarea/textarea.js.map +1 -1
  86. package/dist/form/textarea/textarea.mjs +4 -4
  87. package/dist/form/validation-message/index.js +3 -9
  88. package/dist/form/validation-message/index.js.map +1 -1
  89. package/dist/form/validation-message/index.mjs +1 -1
  90. package/dist/form/validation-message/validation-message.d.ts +2 -4
  91. package/dist/form/validation-message/validation-message.d.ts.map +1 -1
  92. package/dist/form/validation-message/validation-message.js +3 -9
  93. package/dist/form/validation-message/validation-message.js.map +1 -1
  94. package/dist/form/validation-message/validation-message.mjs +1 -1
  95. package/dist/index.js +51 -60
  96. package/dist/index.js.map +1 -1
  97. package/dist/index.mjs +27 -27
  98. package/package.json +2 -2
  99. package/src/form/search-wrapper/search-wrapper.tsx +7 -22
  100. package/src/form/select/select.tsx +21 -21
  101. package/src/form/validation-message/validation-message.tsx +4 -9
  102. package/dist/chunk-7REW23LO.mjs.map +0 -1
  103. package/dist/chunk-D7L7OLFL.mjs +0 -65
  104. package/dist/chunk-D7L7OLFL.mjs.map +0 -1
  105. package/dist/chunk-ZIVURWHY.mjs +0 -30
  106. package/dist/chunk-ZIVURWHY.mjs.map +0 -1
  107. /package/dist/{chunk-J2DJ6ELO.mjs.map → chunk-62VLFCXX.mjs.map} +0 -0
  108. /package/dist/{chunk-GIFDGUFW.mjs.map → chunk-DMRQEQQK.mjs.map} +0 -0
  109. /package/dist/{chunk-54HLJVAF.mjs.map → chunk-DOW6EHBI.mjs.map} +0 -0
  110. /package/dist/{chunk-BUFV457A.mjs.map → chunk-JGYPZ7ET.mjs.map} +0 -0
  111. /package/dist/{chunk-NMW3IWZ4.mjs.map → chunk-OQD4GKOS.mjs.map} +0 -0
  112. /package/dist/{chunk-OHPDYPZ5.mjs.map → chunk-QER35NXN.mjs.map} +0 -0
  113. /package/dist/{chunk-4K54KSRB.mjs.map → chunk-QOIBRXYT.mjs.map} +0 -0
  114. /package/dist/{chunk-6O5AEAIL.mjs.map → chunk-RGZSYJFL.mjs.map} +0 -0
  115. /package/dist/{chunk-77UAHNU6.mjs.map → chunk-VNH7CZJ4.mjs.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/form/input/index.tsx","../../../src/form/input/input.tsx","../../../src/form/input-group/input-group.tsx","../../../src/form/validation-message/validation-message.tsx","../../../src/utils/utils.ts"],"sourcesContent":["export { Input } from \"./input\";\nexport type * from \"./input\";\n","import { forwardRef } from \"react\";\nimport type { InputHTMLAttributes } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { InputGroup } from \"../input-group\";\nimport type { InputGroupProps } from \"../input-group\";\n\n/**\n * Omitting:\n * - `size` from InputHTMLAttributes\n * - `children` from InputGroupProps\n * The original `size` prop that input elements have is not in use in HDS.\n * It is overridden by styling.\n */\nexport type InputProps = Omit<\n InputGroupProps & Omit<InputHTMLAttributes<HTMLInputElement>, \"size\">,\n \"children\"\n>;\n\nexport const Input = forwardRef<HTMLInputElement, InputProps>(\n (\n {\n className,\n size,\n validationMessage,\n errorMessage,\n labelProps,\n label,\n id,\n style,\n disabled,\n readOnly,\n \"data-color\": dataColor,\n ...rest\n },\n ref,\n ) => (\n <InputGroup\n className={clsx(\"hds-input\", className as undefined)}\n disabled={disabled}\n validationMessage={validationMessage}\n errorMessage={errorMessage}\n id={id}\n label={label}\n labelProps={labelProps}\n readOnly={readOnly}\n style={style}\n size={size}\n data-color={dataColor}\n >\n <input disabled={disabled} readOnly={readOnly} ref={ref} {...rest} />\n </InputGroup>\n ),\n);\n\nInput.displayName = \"Input\";\n","import { useId, forwardRef, Children, isValidElement, cloneElement } from \"react\";\nimport type { LabelHTMLAttributes, ReactNode, CSSProperties } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { ValidationMessage, type ValidationMessageProps } from \"../validation-message\";\nimport { type ErrorMessageProps } from \"../error-message\";\nimport { getValidationMessageValue } from \"../../utils\";\n\ninterface InputProps {\n \"aria-describedby\"?: string;\n \"aria-invalid\"?: boolean;\n id?: string;\n className?: string;\n}\n\nexport interface InputGroupProps {\n id?: string;\n className?: string;\n style?: CSSProperties;\n \"data-color\"?: \"info\" | \"success\" | \"warning\" | \"error\";\n size?: \"large\" | \"small\";\n validationMessage?: ReactNode | { value: ReactNode };\n validationMessageProps?: Partial<ValidationMessageProps>;\n /** @deprecated Use `validationMessage` instead */\n errorMessage?: ReactNode;\n /** @deprecated Use `validationMessageProps` instead */\n errorMessageProps?: Partial<ErrorMessageProps>;\n labelProps?: LabelHTMLAttributes<HTMLLabelElement>;\n label?: ReactNode;\n disabled?: boolean;\n readOnly?: boolean;\n /**\n * `children` must be either a single input element or a render function.\n *\n * If you use a render function, make sure you spread the input props to the appropriate element.\n */\n children: Exclude<ReactNode, Iterable<ReactNode>> | ((inputProps: InputProps) => ReactNode);\n}\n\nexport const InputGroup = forwardRef<HTMLDivElement, InputGroupProps>(function InputGroup(\n {\n id,\n className,\n style,\n \"data-color\": dataColor = undefined,\n size = \"large\",\n validationMessage,\n validationMessageProps,\n errorMessage,\n errorMessageProps,\n labelProps: { className: labelClassName, ...labelProps } = {},\n label,\n disabled,\n readOnly,\n children,\n ...rest\n },\n ref,\n) {\n const validationMessageId = useId();\n const inputId = useId();\n const validationColor = errorMessage ? \"error\" : dataColor;\n const validationMessageValue = getValidationMessageValue(validationMessage, errorMessage);\n\n const renderInput = () => {\n const inputProps: InputProps = {\n \"aria-describedby\": validationMessage ? validationMessageId : undefined,\n \"aria-invalid\": errorMessage ? true : undefined,\n id: id ?? inputId,\n className: clsx(\"hds-input-group__input\"),\n };\n\n if (typeof children === \"function\") {\n return children(inputProps);\n }\n\n const input: ReactNode = Children.toArray(children)[0];\n\n if (!isValidElement<InputProps>(input)) {\n return;\n }\n\n return cloneElement<InputProps>(input, {\n ...inputProps,\n ...input.props,\n className: `${inputProps.className} ${input.props.className ?? \"\"}`,\n });\n };\n\n return (\n <div\n className={clsx(\n \"hds-input-group\",\n {\n [`hds-input-group--${size}`]: size,\n },\n className as undefined,\n )}\n ref={ref}\n style={style}\n data-color={validationColor}\n {...rest}\n >\n {label !== null && label !== undefined && label !== false && (\n <label\n className={clsx(\"hds-input-group__label\", labelClassName as undefined)}\n {...labelProps}\n htmlFor={id ?? inputId}\n >\n {label}\n </label>\n )}\n <div\n className={clsx(\"hds-input-group__input-wrapper\")}\n data-disabled={disabled}\n data-readonly={readOnly}\n >\n {renderInput()}\n </div>\n <ValidationMessage\n id={validationMessageId}\n {...(validationMessageProps ?? errorMessageProps)}\n >\n {validationMessageValue}\n </ValidationMessage>\n </div>\n );\n});\n","import { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { forwardRef, type ReactNode } from \"react\";\n\nexport interface ValidationMessageProps extends React.HTMLAttributes<HTMLDivElement> {\n children: ReactNode;\n id: string;\n className?: string;\n}\n\nexport const ValidationMessage = forwardRef<HTMLDivElement, ValidationMessageProps>(\n ({ children, id, className, ...rest }, ref) => (\n <div\n aria-live=\"polite\"\n className={clsx(\"hds-validation-message\", className as undefined)}\n id={id}\n ref={ref}\n {...rest}\n >\n {children}\n </div>\n ),\n);\nValidationMessage.displayName = \"ValidationMessage\";\n","import * as React from \"react\";\nimport { useCallback, useEffect, useState, version } from \"react\";\nimport type { ReactNode } from \"react\";\n\n/**\n * Merges an array of refs into a single memoized callback ref or `null`.\n * @see https://floating-ui.com/docs/useMergeRefs\n */\nexport function useMergeRefs<Instance>(\n refs: (React.Ref<Instance> | undefined)[],\n): React.RefCallback<Instance> | null {\n return React.useMemo(() => {\n if (refs.every((ref) => ref === null)) {\n return null;\n }\n\n return (value) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref !== null) {\n (ref as React.MutableRefObject<Instance | null>).current = value;\n }\n });\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, refs);\n}\n\nexport function useResize<Instance extends HTMLElement>(\n ref: React.RefObject<Instance> | undefined | null,\n): { width: number; height: number } {\n const [width, setWidth] = useState<number>(0);\n const [height, setHeight] = useState<number>(0);\n const handleResize = useCallback(() => {\n if (ref?.current !== null) {\n setWidth(ref?.current?.offsetWidth ?? 0);\n setHeight(ref?.current?.offsetHeight ?? 0);\n }\n }, [ref]);\n useEffect(() => {\n window.addEventListener(\"load\", handleResize);\n window.addEventListener(\"resize\", handleResize);\n return () => {\n window.removeEventListener(\"load\", handleResize);\n window.removeEventListener(\"resize\", handleResize);\n };\n }, [ref, handleResize]);\n useEffect(() => {\n handleResize();\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, []);\n return { width, height };\n}\n\nfunction subscribe() {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- It's ok\n return () => {};\n}\n\nexport function useHydrated() {\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n}\n\nexport function getValidationMessageValue(\n validationMessage?: ReactNode | { value: ReactNode },\n errorMessage?: ReactNode,\n): ReactNode {\n if (validationMessage) {\n if (typeof validationMessage === \"object\" && \"value\" in validationMessage) {\n return validationMessage.value;\n }\n\n return validationMessage;\n }\n\n return errorMessage;\n}\n\n/**\n * Trap focus inside an element using the `inert` attribute.\n *\n * Adds `inert` to all siblings of the given element, and all their ancestors up to the body.\n * Returns a cleanup function which removes the `inert` property from the elements, effectively giving focus back to rest of the document.\n *\n * NOTE: Does not support portals, i.e. elements outside the DOM hierarchy of the given element.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert\n * @see https://web.dev/articles/inert\n */\nexport function focusTrap(element: HTMLElement) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- NOP on focus trapping the body element\n if (element === document.body) return () => {};\n\n let inertElements: HTMLElement[] = [];\n for (let el: HTMLElement | null = element; el; el = el.parentElement) {\n if (el === document.body) break;\n\n for (const sibling of el.parentElement?.children ?? []) {\n if (sibling === el) continue;\n if (!(sibling instanceof HTMLElement)) continue;\n if (sibling.hasAttribute(\"inert\")) continue;\n\n sibling.setAttribute(\"inert\", \"true\");\n inertElements.push(sibling);\n }\n }\n\n return () => {\n releaseFocusTrap(inertElements);\n inertElements = [];\n };\n}\n\n/**\n * Unset the `inert` attribute on all elements given\n */\nfunction releaseFocusTrap(inertElements: Iterable<HTMLElement>) {\n for (const el of inertElements) {\n el.removeAttribute(\"inert\");\n }\n}\n\n/**\n * React 19 supports inert prop\n * React 18 needs inert to be a string\n */\nconst inertBooleanSupported: boolean = Number(version.split(\".\")[0]) >= 19;\n\n/**\n * Returns the inert prop value based on the React version.\n */\nexport const inertPropValue: (x: boolean) => boolean | \"\" | undefined = inertBooleanSupported\n ? (x: boolean): boolean => x\n : (x: boolean): \"\" | undefined => (x ? \"\" : undefined);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,gBAA2B;AAE3B,IAAAC,0BAAqB;;;ACFrB,IAAAC,gBAA0E;AAE1E,IAAAC,0BAAqB;;;ACFrB,6BAAqB;AACrB,mBAA2C;AAUvC;AAFG,IAAM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ACH;AAAA;AAAA;AAAA,EACF;AAEJ,CAAC;;;AD7EK,IAAAC,sBAAA;AA/BC,IAAM,YAAQ;AAAA,EACnB,CACE,IAcA,QACA;AAfA,iBACE;AAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,cAAc;AAAA,IA/BpB,IAoBI,IAYK,iBAZL,IAYK;AAAA,MAXH;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAKF;AAAA,MAAC;AAAA;AAAA,QACC,eAAW,8BAAK,aAAa,SAAsB;AAAA,QACnD;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,cAAY;AAAA,QAEZ,uDAAC,0BAAM,UAAoB,UAAoB,OAAc,KAAM;AAAA;AAAA,IACrE;AAAA;AAEJ;AAEA,MAAM,cAAc;","names":["import_react","import_typed_classname","import_react","import_typed_classname","import_react","import_jsx_runtime","InputGroup","_a","import_jsx_runtime"]}
1
+ {"version":3,"sources":["../../../src/form/input/index.tsx","../../../src/form/input/input.tsx","../../../src/form/input-group/input-group.tsx","../../../src/form/validation-message/validation-message.tsx","../../../src/utils/utils.ts"],"sourcesContent":["export { Input } from \"./input\";\nexport type * from \"./input\";\n","import { forwardRef } from \"react\";\nimport type { InputHTMLAttributes } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { InputGroup } from \"../input-group\";\nimport type { InputGroupProps } from \"../input-group\";\n\n/**\n * Omitting:\n * - `size` from InputHTMLAttributes\n * - `children` from InputGroupProps\n * The original `size` prop that input elements have is not in use in HDS.\n * It is overridden by styling.\n */\nexport type InputProps = Omit<\n InputGroupProps & Omit<InputHTMLAttributes<HTMLInputElement>, \"size\">,\n \"children\"\n>;\n\nexport const Input = forwardRef<HTMLInputElement, InputProps>(\n (\n {\n className,\n size,\n validationMessage,\n errorMessage,\n labelProps,\n label,\n id,\n style,\n disabled,\n readOnly,\n \"data-color\": dataColor,\n ...rest\n },\n ref,\n ) => (\n <InputGroup\n className={clsx(\"hds-input\", className as undefined)}\n disabled={disabled}\n validationMessage={validationMessage}\n errorMessage={errorMessage}\n id={id}\n label={label}\n labelProps={labelProps}\n readOnly={readOnly}\n style={style}\n size={size}\n data-color={dataColor}\n >\n <input disabled={disabled} readOnly={readOnly} ref={ref} {...rest} />\n </InputGroup>\n ),\n);\n\nInput.displayName = \"Input\";\n","import { useId, forwardRef, Children, isValidElement, cloneElement } from \"react\";\nimport type { LabelHTMLAttributes, ReactNode, CSSProperties } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { ValidationMessage, type ValidationMessageProps } from \"../validation-message\";\nimport { type ErrorMessageProps } from \"../error-message\";\nimport { getValidationMessageValue } from \"../../utils\";\n\ninterface InputProps {\n \"aria-describedby\"?: string;\n \"aria-invalid\"?: boolean;\n id?: string;\n className?: string;\n}\n\nexport interface InputGroupProps {\n id?: string;\n className?: string;\n style?: CSSProperties;\n \"data-color\"?: \"info\" | \"success\" | \"warning\" | \"error\";\n size?: \"large\" | \"small\";\n validationMessage?: ReactNode | { value: ReactNode };\n validationMessageProps?: Partial<ValidationMessageProps>;\n /** @deprecated Use `validationMessage` instead */\n errorMessage?: ReactNode;\n /** @deprecated Use `validationMessageProps` instead */\n errorMessageProps?: Partial<ErrorMessageProps>;\n labelProps?: LabelHTMLAttributes<HTMLLabelElement>;\n label?: ReactNode;\n disabled?: boolean;\n readOnly?: boolean;\n /**\n * `children` must be either a single input element or a render function.\n *\n * If you use a render function, make sure you spread the input props to the appropriate element.\n */\n children: Exclude<ReactNode, Iterable<ReactNode>> | ((inputProps: InputProps) => ReactNode);\n}\n\nexport const InputGroup = forwardRef<HTMLDivElement, InputGroupProps>(function InputGroup(\n {\n id,\n className,\n style,\n \"data-color\": dataColor = undefined,\n size = \"large\",\n validationMessage,\n validationMessageProps,\n errorMessage,\n errorMessageProps,\n labelProps: { className: labelClassName, ...labelProps } = {},\n label,\n disabled,\n readOnly,\n children,\n ...rest\n },\n ref,\n) {\n const validationMessageId = useId();\n const inputId = useId();\n const validationColor = errorMessage ? \"error\" : dataColor;\n const validationMessageValue = getValidationMessageValue(validationMessage, errorMessage);\n\n const renderInput = () => {\n const inputProps: InputProps = {\n \"aria-describedby\": validationMessage ? validationMessageId : undefined,\n \"aria-invalid\": errorMessage ? true : undefined,\n id: id ?? inputId,\n className: clsx(\"hds-input-group__input\"),\n };\n\n if (typeof children === \"function\") {\n return children(inputProps);\n }\n\n const input: ReactNode = Children.toArray(children)[0];\n\n if (!isValidElement<InputProps>(input)) {\n return;\n }\n\n return cloneElement<InputProps>(input, {\n ...inputProps,\n ...input.props,\n className: `${inputProps.className} ${input.props.className ?? \"\"}`,\n });\n };\n\n return (\n <div\n className={clsx(\n \"hds-input-group\",\n {\n [`hds-input-group--${size}`]: size,\n },\n className as undefined,\n )}\n ref={ref}\n style={style}\n data-color={validationColor}\n {...rest}\n >\n {label !== null && label !== undefined && label !== false && (\n <label\n className={clsx(\"hds-input-group__label\", labelClassName as undefined)}\n {...labelProps}\n htmlFor={id ?? inputId}\n >\n {label}\n </label>\n )}\n <div\n className={clsx(\"hds-input-group__input-wrapper\")}\n data-disabled={disabled}\n data-readonly={readOnly}\n >\n {renderInput()}\n </div>\n <ValidationMessage\n id={validationMessageId}\n {...(validationMessageProps ?? errorMessageProps)}\n >\n {validationMessageValue}\n </ValidationMessage>\n </div>\n );\n});\n","import { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { forwardRef, type HTMLAttributes } from \"react\";\n\nexport interface ValidationMessageProps extends HTMLAttributes<HTMLDivElement> {\n className?: string;\n}\n\nexport const ValidationMessage = forwardRef<HTMLDivElement, ValidationMessageProps>(\n ({ className, ...rest }, ref) => (\n <div\n aria-live=\"polite\"\n className={clsx(\"hds-validation-message\", className as undefined)}\n ref={ref}\n {...rest}\n />\n ),\n);\nValidationMessage.displayName = \"ValidationMessage\";\n","import * as React from \"react\";\nimport { useCallback, useEffect, useState, version } from \"react\";\nimport type { ReactNode } from \"react\";\n\n/**\n * Merges an array of refs into a single memoized callback ref or `null`.\n * @see https://floating-ui.com/docs/useMergeRefs\n */\nexport function useMergeRefs<Instance>(\n refs: (React.Ref<Instance> | undefined)[],\n): React.RefCallback<Instance> | null {\n return React.useMemo(() => {\n if (refs.every((ref) => ref === null)) {\n return null;\n }\n\n return (value) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref !== null) {\n (ref as React.MutableRefObject<Instance | null>).current = value;\n }\n });\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, refs);\n}\n\nexport function useResize<Instance extends HTMLElement>(\n ref: React.RefObject<Instance> | undefined | null,\n): { width: number; height: number } {\n const [width, setWidth] = useState<number>(0);\n const [height, setHeight] = useState<number>(0);\n const handleResize = useCallback(() => {\n if (ref?.current !== null) {\n setWidth(ref?.current?.offsetWidth ?? 0);\n setHeight(ref?.current?.offsetHeight ?? 0);\n }\n }, [ref]);\n useEffect(() => {\n window.addEventListener(\"load\", handleResize);\n window.addEventListener(\"resize\", handleResize);\n return () => {\n window.removeEventListener(\"load\", handleResize);\n window.removeEventListener(\"resize\", handleResize);\n };\n }, [ref, handleResize]);\n useEffect(() => {\n handleResize();\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, []);\n return { width, height };\n}\n\nfunction subscribe() {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- It's ok\n return () => {};\n}\n\nexport function useHydrated() {\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n}\n\nexport function getValidationMessageValue(\n validationMessage?: ReactNode | { value: ReactNode },\n errorMessage?: ReactNode,\n): ReactNode {\n if (validationMessage) {\n if (typeof validationMessage === \"object\" && \"value\" in validationMessage) {\n return validationMessage.value;\n }\n\n return validationMessage;\n }\n\n return errorMessage;\n}\n\n/**\n * Trap focus inside an element using the `inert` attribute.\n *\n * Adds `inert` to all siblings of the given element, and all their ancestors up to the body.\n * Returns a cleanup function which removes the `inert` property from the elements, effectively giving focus back to rest of the document.\n *\n * NOTE: Does not support portals, i.e. elements outside the DOM hierarchy of the given element.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert\n * @see https://web.dev/articles/inert\n */\nexport function focusTrap(element: HTMLElement) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- NOP on focus trapping the body element\n if (element === document.body) return () => {};\n\n let inertElements: HTMLElement[] = [];\n for (let el: HTMLElement | null = element; el; el = el.parentElement) {\n if (el === document.body) break;\n\n for (const sibling of el.parentElement?.children ?? []) {\n if (sibling === el) continue;\n if (!(sibling instanceof HTMLElement)) continue;\n if (sibling.hasAttribute(\"inert\")) continue;\n\n sibling.setAttribute(\"inert\", \"true\");\n inertElements.push(sibling);\n }\n }\n\n return () => {\n releaseFocusTrap(inertElements);\n inertElements = [];\n };\n}\n\n/**\n * Unset the `inert` attribute on all elements given\n */\nfunction releaseFocusTrap(inertElements: Iterable<HTMLElement>) {\n for (const el of inertElements) {\n el.removeAttribute(\"inert\");\n }\n}\n\n/**\n * React 19 supports inert prop\n * React 18 needs inert to be a string\n */\nconst inertBooleanSupported: boolean = Number(version.split(\".\")[0]) >= 19;\n\n/**\n * Returns the inert prop value based on the React version.\n */\nexport const inertPropValue: (x: boolean) => boolean | \"\" | undefined = inertBooleanSupported\n ? (x: boolean): boolean => x\n : (x: boolean): \"\" | undefined => (x ? \"\" : undefined);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,gBAA2B;AAE3B,IAAAC,0BAAqB;;;ACFrB,IAAAC,gB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YAIE;AAAA;AAAA,QACH;AAAA;AAAA;AAAA,EACF;AAEJ,CAAC;;;AD7EK,IAAAC,sBAAA;AA/BC,IAAM,YAAQ;AAAA,EACnB,CACE,IAcA,QACA;AAfA,iBACE;AAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,cAAc;AAAA,IA/BpB,IAoBI,IAYK,iBAZL,IAYK;AAAA,MAXH;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAKF;AAAA,MAAC;AAAA;AAAA,QACC,eAAW,8BAAK,aAAa,SAAsB;AAAA,QACnD;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,cAAY;AAAA,QAEZ,uDAAC,0BAAM,UAAoB,UAAoB,OAAc,KAAM;AAAA;AAAA,IACrE;AAAA;AAEJ;AAEA,MAAM,cAAc;","names":["import_react","import_typed_classname","import_react","import_typed_classname","import_react","import_jsx_runtime","InputGroup","_a","import_jsx_runtime"]}
@@ -1,13 +1,13 @@
1
1
  import "../../chunk-7LPYJC6S.mjs";
2
2
  import {
3
3
  Input
4
- } from "../../chunk-J2DJ6ELO.mjs";
4
+ } from "../../chunk-62VLFCXX.mjs";
5
5
  import "../../chunk-Y5SUMFYJ.mjs";
6
- import "../../chunk-GIFDGUFW.mjs";
6
+ import "../../chunk-DMRQEQQK.mjs";
7
7
  import "../../chunk-NSLSA7F7.mjs";
8
- import "../../chunk-77UAHNU6.mjs";
8
+ import "../../chunk-VNH7CZJ4.mjs";
9
9
  import "../../chunk-5M6MEYM7.mjs";
10
- import "../../chunk-7REW23LO.mjs";
10
+ import "../../chunk-F23MNQCK.mjs";
11
11
  import "../../chunk-CYDWEPFL.mjs";
12
12
  import "../../chunk-KPNAC2WN.mjs";
13
13
  import "../../chunk-3V4GFS46.mjs";
@@ -75,17 +75,14 @@ var import_react = require("react");
75
75
  var import_jsx_runtime = require("react/jsx-runtime");
76
76
  var ValidationMessage = (0, import_react.forwardRef)(
77
77
  (_a, ref) => {
78
- var _b = _a, { children, id, className } = _b, rest = __objRest(_b, ["children", "id", "className"]);
78
+ var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
79
79
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
80
80
  "div",
81
- __spreadProps(__spreadValues({
81
+ __spreadValues({
82
82
  "aria-live": "polite",
83
83
  className: (0, import_typed_classname.clsx)("hds-validation-message", className),
84
- id,
85
84
  ref
86
- }, rest), {
87
- children
88
- })
85
+ }, rest)
89
86
  );
90
87
  }
91
88
  );
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/form/input/input.tsx","../../../src/form/input-group/input-group.tsx","../../../src/form/validation-message/validation-message.tsx","../../../src/utils/utils.ts"],"sourcesContent":["import { forwardRef } from \"react\";\nimport type { InputHTMLAttributes } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { InputGroup } from \"../input-group\";\nimport type { InputGroupProps } from \"../input-group\";\n\n/**\n * Omitting:\n * - `size` from InputHTMLAttributes\n * - `children` from InputGroupProps\n * The original `size` prop that input elements have is not in use in HDS.\n * It is overridden by styling.\n */\nexport type InputProps = Omit<\n InputGroupProps & Omit<InputHTMLAttributes<HTMLInputElement>, \"size\">,\n \"children\"\n>;\n\nexport const Input = forwardRef<HTMLInputElement, InputProps>(\n (\n {\n className,\n size,\n validationMessage,\n errorMessage,\n labelProps,\n label,\n id,\n style,\n disabled,\n readOnly,\n \"data-color\": dataColor,\n ...rest\n },\n ref,\n ) => (\n <InputGroup\n className={clsx(\"hds-input\", className as undefined)}\n disabled={disabled}\n validationMessage={validationMessage}\n errorMessage={errorMessage}\n id={id}\n label={label}\n labelProps={labelProps}\n readOnly={readOnly}\n style={style}\n size={size}\n data-color={dataColor}\n >\n <input disabled={disabled} readOnly={readOnly} ref={ref} {...rest} />\n </InputGroup>\n ),\n);\n\nInput.displayName = \"Input\";\n","import { useId, forwardRef, Children, isValidElement, cloneElement } from \"react\";\nimport type { LabelHTMLAttributes, ReactNode, CSSProperties } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { ValidationMessage, type ValidationMessageProps } from \"../validation-message\";\nimport { type ErrorMessageProps } from \"../error-message\";\nimport { getValidationMessageValue } from \"../../utils\";\n\ninterface InputProps {\n \"aria-describedby\"?: string;\n \"aria-invalid\"?: boolean;\n id?: string;\n className?: string;\n}\n\nexport interface InputGroupProps {\n id?: string;\n className?: string;\n style?: CSSProperties;\n \"data-color\"?: \"info\" | \"success\" | \"warning\" | \"error\";\n size?: \"large\" | \"small\";\n validationMessage?: ReactNode | { value: ReactNode };\n validationMessageProps?: Partial<ValidationMessageProps>;\n /** @deprecated Use `validationMessage` instead */\n errorMessage?: ReactNode;\n /** @deprecated Use `validationMessageProps` instead */\n errorMessageProps?: Partial<ErrorMessageProps>;\n labelProps?: LabelHTMLAttributes<HTMLLabelElement>;\n label?: ReactNode;\n disabled?: boolean;\n readOnly?: boolean;\n /**\n * `children` must be either a single input element or a render function.\n *\n * If you use a render function, make sure you spread the input props to the appropriate element.\n */\n children: Exclude<ReactNode, Iterable<ReactNode>> | ((inputProps: InputProps) => ReactNode);\n}\n\nexport const InputGroup = forwardRef<HTMLDivElement, InputGroupProps>(function InputGroup(\n {\n id,\n className,\n style,\n \"data-color\": dataColor = undefined,\n size = \"large\",\n validationMessage,\n validationMessageProps,\n errorMessage,\n errorMessageProps,\n labelProps: { className: labelClassName, ...labelProps } = {},\n label,\n disabled,\n readOnly,\n children,\n ...rest\n },\n ref,\n) {\n const validationMessageId = useId();\n const inputId = useId();\n const validationColor = errorMessage ? \"error\" : dataColor;\n const validationMessageValue = getValidationMessageValue(validationMessage, errorMessage);\n\n const renderInput = () => {\n const inputProps: InputProps = {\n \"aria-describedby\": validationMessage ? validationMessageId : undefined,\n \"aria-invalid\": errorMessage ? true : undefined,\n id: id ?? inputId,\n className: clsx(\"hds-input-group__input\"),\n };\n\n if (typeof children === \"function\") {\n return children(inputProps);\n }\n\n const input: ReactNode = Children.toArray(children)[0];\n\n if (!isValidElement<InputProps>(input)) {\n return;\n }\n\n return cloneElement<InputProps>(input, {\n ...inputProps,\n ...input.props,\n className: `${inputProps.className} ${input.props.className ?? \"\"}`,\n });\n };\n\n return (\n <div\n className={clsx(\n \"hds-input-group\",\n {\n [`hds-input-group--${size}`]: size,\n },\n className as undefined,\n )}\n ref={ref}\n style={style}\n data-color={validationColor}\n {...rest}\n >\n {label !== null && label !== undefined && label !== false && (\n <label\n className={clsx(\"hds-input-group__label\", labelClassName as undefined)}\n {...labelProps}\n htmlFor={id ?? inputId}\n >\n {label}\n </label>\n )}\n <div\n className={clsx(\"hds-input-group__input-wrapper\")}\n data-disabled={disabled}\n data-readonly={readOnly}\n >\n {renderInput()}\n </div>\n <ValidationMessage\n id={validationMessageId}\n {...(validationMessageProps ?? errorMessageProps)}\n >\n {validationMessageValue}\n </ValidationMessage>\n </div>\n );\n});\n","import { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { forwardRef, type ReactNode } from \"react\";\n\nexport interface ValidationMessageProps extends React.HTMLAttributes<HTMLDivElement> {\n children: ReactNode;\n id: string;\n className?: string;\n}\n\nexport const ValidationMessage = forwardRef<HTMLDivElement, ValidationMessageProps>(\n ({ children, id, className, ...rest }, ref) => (\n <div\n aria-live=\"polite\"\n className={clsx(\"hds-validation-message\", className as undefined)}\n id={id}\n ref={ref}\n {...rest}\n >\n {children}\n </div>\n ),\n);\nValidationMessage.displayName = \"ValidationMessage\";\n","import * as React from \"react\";\nimport { useCallback, useEffect, useState, version } from \"react\";\nimport type { ReactNode } from \"react\";\n\n/**\n * Merges an array of refs into a single memoized callback ref or `null`.\n * @see https://floating-ui.com/docs/useMergeRefs\n */\nexport function useMergeRefs<Instance>(\n refs: (React.Ref<Instance> | undefined)[],\n): React.RefCallback<Instance> | null {\n return React.useMemo(() => {\n if (refs.every((ref) => ref === null)) {\n return null;\n }\n\n return (value) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref !== null) {\n (ref as React.MutableRefObject<Instance | null>).current = value;\n }\n });\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, refs);\n}\n\nexport function useResize<Instance extends HTMLElement>(\n ref: React.RefObject<Instance> | undefined | null,\n): { width: number; height: number } {\n const [width, setWidth] = useState<number>(0);\n const [height, setHeight] = useState<number>(0);\n const handleResize = useCallback(() => {\n if (ref?.current !== null) {\n setWidth(ref?.current?.offsetWidth ?? 0);\n setHeight(ref?.current?.offsetHeight ?? 0);\n }\n }, [ref]);\n useEffect(() => {\n window.addEventListener(\"load\", handleResize);\n window.addEventListener(\"resize\", handleResize);\n return () => {\n window.removeEventListener(\"load\", handleResize);\n window.removeEventListener(\"resize\", handleResize);\n };\n }, [ref, handleResize]);\n useEffect(() => {\n handleResize();\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, []);\n return { width, height };\n}\n\nfunction subscribe() {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- It's ok\n return () => {};\n}\n\nexport function useHydrated() {\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n}\n\nexport function getValidationMessageValue(\n validationMessage?: ReactNode | { value: ReactNode },\n errorMessage?: ReactNode,\n): ReactNode {\n if (validationMessage) {\n if (typeof validationMessage === \"object\" && \"value\" in validationMessage) {\n return validationMessage.value;\n }\n\n return validationMessage;\n }\n\n return errorMessage;\n}\n\n/**\n * Trap focus inside an element using the `inert` attribute.\n *\n * Adds `inert` to all siblings of the given element, and all their ancestors up to the body.\n * Returns a cleanup function which removes the `inert` property from the elements, effectively giving focus back to rest of the document.\n *\n * NOTE: Does not support portals, i.e. elements outside the DOM hierarchy of the given element.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert\n * @see https://web.dev/articles/inert\n */\nexport function focusTrap(element: HTMLElement) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- NOP on focus trapping the body element\n if (element === document.body) return () => {};\n\n let inertElements: HTMLElement[] = [];\n for (let el: HTMLElement | null = element; el; el = el.parentElement) {\n if (el === document.body) break;\n\n for (const sibling of el.parentElement?.children ?? []) {\n if (sibling === el) continue;\n if (!(sibling instanceof HTMLElement)) continue;\n if (sibling.hasAttribute(\"inert\")) continue;\n\n sibling.setAttribute(\"inert\", \"true\");\n inertElements.push(sibling);\n }\n }\n\n return () => {\n releaseFocusTrap(inertElements);\n inertElements = [];\n };\n}\n\n/**\n * Unset the `inert` attribute on all elements given\n */\nfunction releaseFocusTrap(inertElements: Iterable<HTMLElement>) {\n for (const el of inertElements) {\n el.removeAttribute(\"inert\");\n }\n}\n\n/**\n * React 19 supports inert prop\n * React 18 needs inert to be a string\n */\nconst inertBooleanSupported: boolean = Number(version.split(\".\")[0]) >= 19;\n\n/**\n * Returns the inert prop value based on the React version.\n */\nexport const inertPropValue: (x: boolean) => boolean | \"\" | undefined = inertBooleanSupported\n ? (x: boolean): boolean => x\n : (x: boolean): \"\" | undefined => (x ? \"\" : undefined);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,gBAA2B;AAE3B,IAAAC,0BAAqB;;;ACFrB,IAAAC,gBAA0E;AAE1E,IAAAC,0BAAqB;;;ACFrB,6BAAqB;AACrB,mBAA2C;AAUvC;AAFG,IAAM,wBAAoB;AAAA,EAC/B,CAAC,IAAsC,QAAK;AAA3C,iBAAE,YAAU,IAAI,UAVnB,IAUG,IAA8B,iBAA9B,IAA8B,CAA5B,YAAU,MAAI;AACf;AAAA,MAAC;AAAA;AAAA,QACC,aAAU;AAAA,QACV,e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AA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,cAAc;AAAA,IA/BpB,IAoBI,IAYK,iBAZL,IAYK;AAAA,MAXH;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAKF;AAAA,MAAC;AAAA;AAAA,QACC,eAAW,8BAAK,aAAa,SAAsB;AAAA,QACnD;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,cAAY;AAAA,QAEZ,uDAAC,0BAAM,UAAoB,UAAoB,OAAc,KAAM;AAAA;AAAA,IACrE;AAAA;AAEJ;AAEA,MAAM,cAAc;","names":["import_react","import_typed_classname","import_react","import_typed_classname","import_react","import_jsx_runtime","InputGroup","_a","import_jsx_runtime"]}
1
+ {"version":3,"sources":["../../../src/form/input/input.tsx","../../../src/form/input-group/input-group.tsx","../../../src/form/validation-message/validation-message.tsx","../../../src/utils/utils.ts"],"sourcesContent":["import { forwardRef } from \"react\";\nimport type { InputHTMLAttributes } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { InputGroup } from \"../input-group\";\nimport type { InputGroupProps } from \"../input-group\";\n\n/**\n * Omitting:\n * - `size` from InputHTMLAttributes\n * - `children` from InputGroupProps\n * The original `size` prop that input elements have is not in use in HDS.\n * It is overridden by styling.\n */\nexport type InputProps = Omit<\n InputGroupProps & Omit<InputHTMLAttributes<HTMLInputElement>, \"size\">,\n \"children\"\n>;\n\nexport const Input = forwardRef<HTMLInputElement, InputProps>(\n (\n {\n className,\n size,\n validationMessage,\n errorMessage,\n labelProps,\n label,\n id,\n style,\n disabled,\n readOnly,\n \"data-color\": dataColor,\n ...rest\n },\n ref,\n ) => (\n <InputGroup\n className={clsx(\"hds-input\", className as undefined)}\n disabled={disabled}\n validationMessage={validationMessage}\n errorMessage={errorMessage}\n id={id}\n label={label}\n labelProps={labelProps}\n readOnly={readOnly}\n style={style}\n size={size}\n data-color={dataColor}\n >\n <input disabled={disabled} readOnly={readOnly} ref={ref} {...rest} />\n </InputGroup>\n ),\n);\n\nInput.displayName = \"Input\";\n","import { useId, forwardRef, Children, isValidElement, cloneElement } from \"react\";\nimport type { LabelHTMLAttributes, ReactNode, CSSProperties } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { ValidationMessage, type ValidationMessageProps } from \"../validation-message\";\nimport { type ErrorMessageProps } from \"../error-message\";\nimport { getValidationMessageValue } from \"../../utils\";\n\ninterface InputProps {\n \"aria-describedby\"?: string;\n \"aria-invalid\"?: boolean;\n id?: string;\n className?: string;\n}\n\nexport interface InputGroupProps {\n id?: string;\n className?: string;\n style?: CSSProperties;\n \"data-color\"?: \"info\" | \"success\" | \"warning\" | \"error\";\n size?: \"large\" | \"small\";\n validationMessage?: ReactNode | { value: ReactNode };\n validationMessageProps?: Partial<ValidationMessageProps>;\n /** @deprecated Use `validationMessage` instead */\n errorMessage?: ReactNode;\n /** @deprecated Use `validationMessageProps` instead */\n errorMessageProps?: Partial<ErrorMessageProps>;\n labelProps?: LabelHTMLAttributes<HTMLLabelElement>;\n label?: ReactNode;\n disabled?: boolean;\n readOnly?: boolean;\n /**\n * `children` must be either a single input element or a render function.\n *\n * If you use a render function, make sure you spread the input props to the appropriate element.\n */\n children: Exclude<ReactNode, Iterable<ReactNode>> | ((inputProps: InputProps) => ReactNode);\n}\n\nexport const InputGroup = forwardRef<HTMLDivElement, InputGroupProps>(function InputGroup(\n {\n id,\n className,\n style,\n \"data-color\": dataColor = undefined,\n size = \"large\",\n validationMessage,\n validationMessageProps,\n errorMessage,\n errorMessageProps,\n labelProps: { className: labelClassName, ...labelProps } = {},\n label,\n disabled,\n readOnly,\n children,\n ...rest\n },\n ref,\n) {\n const validationMessageId = useId();\n const inputId = useId();\n const validationColor = errorMessage ? \"error\" : dataColor;\n const validationMessageValue = getValidationMessageValue(validationMessage, errorMessage);\n\n const renderInput = () => {\n const inputProps: InputProps = {\n \"aria-describedby\": validationMessage ? validationMessageId : undefined,\n \"aria-invalid\": errorMessage ? true : undefined,\n id: id ?? inputId,\n className: clsx(\"hds-input-group__input\"),\n };\n\n if (typeof children === \"function\") {\n return children(inputProps);\n }\n\n const input: ReactNode = Children.toArray(children)[0];\n\n if (!isValidElement<InputProps>(input)) {\n return;\n }\n\n return cloneElement<InputProps>(input, {\n ...inputProps,\n ...input.props,\n className: `${inputProps.className} ${input.props.className ?? \"\"}`,\n });\n };\n\n return (\n <div\n className={clsx(\n \"hds-input-group\",\n {\n [`hds-input-group--${size}`]: size,\n },\n className as undefined,\n )}\n ref={ref}\n style={style}\n data-color={validationColor}\n {...rest}\n >\n {label !== null && label !== undefined && label !== false && (\n <label\n className={clsx(\"hds-input-group__label\", labelClassName as undefined)}\n {...labelProps}\n htmlFor={id ?? inputId}\n >\n {label}\n </label>\n )}\n <div\n className={clsx(\"hds-input-group__input-wrapper\")}\n data-disabled={disabled}\n data-readonly={readOnly}\n >\n {renderInput()}\n </div>\n <ValidationMessage\n id={validationMessageId}\n {...(validationMessageProps ?? errorMessageProps)}\n >\n {validationMessageValue}\n </ValidationMessage>\n </div>\n );\n});\n","import { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { forwardRef, type HTMLAttributes } from \"react\";\n\nexport interface ValidationMessageProps extends HTMLAttributes<HTMLDivElement> {\n className?: string;\n}\n\nexport const ValidationMessage = forwardRef<HTMLDivElement, ValidationMessageProps>(\n ({ className, ...rest }, ref) => (\n <div\n aria-live=\"polite\"\n className={clsx(\"hds-validation-message\", className as undefined)}\n ref={ref}\n {...rest}\n />\n ),\n);\nValidationMessage.displayName = \"ValidationMessage\";\n","import * as React from \"react\";\nimport { useCallback, useEffect, useState, version } from \"react\";\nimport type { ReactNode } from \"react\";\n\n/**\n * Merges an array of refs into a single memoized callback ref or `null`.\n * @see https://floating-ui.com/docs/useMergeRefs\n */\nexport function useMergeRefs<Instance>(\n refs: (React.Ref<Instance> | undefined)[],\n): React.RefCallback<Instance> | null {\n return React.useMemo(() => {\n if (refs.every((ref) => ref === null)) {\n return null;\n }\n\n return (value) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref !== null) {\n (ref as React.MutableRefObject<Instance | null>).current = value;\n }\n });\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, refs);\n}\n\nexport function useResize<Instance extends HTMLElement>(\n ref: React.RefObject<Instance> | undefined | null,\n): { width: number; height: number } {\n const [width, setWidth] = useState<number>(0);\n const [height, setHeight] = useState<number>(0);\n const handleResize = useCallback(() => {\n if (ref?.current !== null) {\n setWidth(ref?.current?.offsetWidth ?? 0);\n setHeight(ref?.current?.offsetHeight ?? 0);\n }\n }, [ref]);\n useEffect(() => {\n window.addEventListener(\"load\", handleResize);\n window.addEventListener(\"resize\", handleResize);\n return () => {\n window.removeEventListener(\"load\", handleResize);\n window.removeEventListener(\"resize\", handleResize);\n };\n }, [ref, handleResize]);\n useEffect(() => {\n handleResize();\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, []);\n return { width, height };\n}\n\nfunction subscribe() {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- It's ok\n return () => {};\n}\n\nexport function useHydrated() {\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n}\n\nexport function getValidationMessageValue(\n validationMessage?: ReactNode | { value: ReactNode },\n errorMessage?: ReactNode,\n): ReactNode {\n if (validationMessage) {\n if (typeof validationMessage === \"object\" && \"value\" in validationMessage) {\n return validationMessage.value;\n }\n\n return validationMessage;\n }\n\n return errorMessage;\n}\n\n/**\n * Trap focus inside an element using the `inert` attribute.\n *\n * Adds `inert` to all siblings of the given element, and all their ancestors up to the body.\n * Returns a cleanup function which removes the `inert` property from the elements, effectively giving focus back to rest of the document.\n *\n * NOTE: Does not support portals, i.e. elements outside the DOM hierarchy of the given element.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert\n * @see https://web.dev/articles/inert\n */\nexport function focusTrap(element: HTMLElement) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- NOP on focus trapping the body element\n if (element === document.body) return () => {};\n\n let inertElements: HTMLElement[] = [];\n for (let el: HTMLElement | null = element; el; el = el.parentElement) {\n if (el === document.body) break;\n\n for (const sibling of el.parentElement?.children ?? []) {\n if (sibling === el) continue;\n if (!(sibling instanceof HTMLElement)) continue;\n if (sibling.hasAttribute(\"inert\")) continue;\n\n sibling.setAttribute(\"inert\", \"true\");\n inertElements.push(sibling);\n }\n }\n\n return () => {\n releaseFocusTrap(inertElements);\n inertElements = [];\n };\n}\n\n/**\n * Unset the `inert` attribute on all elements given\n */\nfunction releaseFocusTrap(inertElements: Iterable<HTMLElement>) {\n for (const el of inertElements) {\n el.removeAttribute(\"inert\");\n }\n}\n\n/**\n * React 19 supports inert prop\n * React 18 needs inert to be a string\n */\nconst inertBooleanSupported: boolean = Number(version.split(\".\")[0]) >= 19;\n\n/**\n * Returns the inert prop value based on the React version.\n */\nexport const inertPropValue: (x: boolean) => boolean | \"\" | undefined = inertBooleanSupported\n ? (x: boolean): boolean => x\n : (x: boolean): \"\" | undefined => (x ? \"\" : undefined);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,gBAA2B;AAE3B,IAAAC,0BAAqB;;;ACFrB,IAAAC,gBAA0E;AAE1E,IAAAC,0BAAqB;;;ACFrB,6BAAqB;AACrB,mBAAgD;AAQ5C;AAFG,IAAM,wBAAoB;AAAA,EAC/B,CAAC,IAAwB,QAAK;AAA7B,iBAAE,YARL,IAQG,IAAgB,iBAAhB,IAAgB,CAAd;AACD;AAAA,MAAC;AAAA;AAAA,QACC,aAAU;AAAA,QACV,eA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,MACA;AAAA,MACA;AAAA,MACA,cAAc;AAAA,IA/BpB,IAoBI,IAYK,iBAZL,IAYK;AAAA,MAXH;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAKF;AAAA,MAAC;AAAA;AAAA,QACC,eAAW,8BAAK,aAAa,SAAsB;AAAA,QACnD;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,cAAY;AAAA,QAEZ,uDAAC,0BAAM,UAAoB,UAAoB,OAAc,KAAM;AAAA;AAAA,IACrE;AAAA;AAEJ;AAEA,MAAM,cAAc;","names":["import_react","import_typed_classname","import_react","import_typed_classname","import_react","import_jsx_runtime","InputGroup","_a","import_jsx_runtime"]}
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  Input
3
- } from "../../chunk-J2DJ6ELO.mjs";
3
+ } from "../../chunk-62VLFCXX.mjs";
4
4
  import "../../chunk-Y5SUMFYJ.mjs";
5
- import "../../chunk-GIFDGUFW.mjs";
5
+ import "../../chunk-DMRQEQQK.mjs";
6
6
  import "../../chunk-NSLSA7F7.mjs";
7
- import "../../chunk-77UAHNU6.mjs";
7
+ import "../../chunk-VNH7CZJ4.mjs";
8
8
  import "../../chunk-5M6MEYM7.mjs";
9
- import "../../chunk-7REW23LO.mjs";
9
+ import "../../chunk-F23MNQCK.mjs";
10
10
  import "../../chunk-CYDWEPFL.mjs";
11
11
  import "../../chunk-KPNAC2WN.mjs";
12
12
  import "../../chunk-3V4GFS46.mjs";
@@ -73,17 +73,14 @@ var import_react = require("react");
73
73
  var import_jsx_runtime = require("react/jsx-runtime");
74
74
  var ValidationMessage = (0, import_react.forwardRef)(
75
75
  (_a, ref) => {
76
- var _b = _a, { children, id, className } = _b, rest = __objRest(_b, ["children", "id", "className"]);
76
+ var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
77
77
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
78
78
  "div",
79
- __spreadProps(__spreadValues({
79
+ __spreadValues({
80
80
  "aria-live": "polite",
81
81
  className: (0, import_typed_classname.clsx)("hds-validation-message", className),
82
- id,
83
82
  ref
84
- }, rest), {
85
- children
86
- })
83
+ }, rest)
87
84
  );
88
85
  }
89
86
  );
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/form/input-group/index.tsx","../../../src/form/input-group/input-group.tsx","../../../src/form/validation-message/validation-message.tsx","../../../src/utils/utils.ts"],"sourcesContent":["export { InputGroup } from \"./input-group\";\nexport type * from \"./input-group\";\n","import { useId, forwardRef, Children, isValidElement, cloneElement } from \"react\";\nimport type { LabelHTMLAttributes, ReactNode, CSSProperties } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { ValidationMessage, type ValidationMessageProps } from \"../validation-message\";\nimport { type ErrorMessageProps } from \"../error-message\";\nimport { getValidationMessageValue } from \"../../utils\";\n\ninterface InputProps {\n \"aria-describedby\"?: string;\n \"aria-invalid\"?: boolean;\n id?: string;\n className?: string;\n}\n\nexport interface InputGroupProps {\n id?: string;\n className?: string;\n style?: CSSProperties;\n \"data-color\"?: \"info\" | \"success\" | \"warning\" | \"error\";\n size?: \"large\" | \"small\";\n validationMessage?: ReactNode | { value: ReactNode };\n validationMessageProps?: Partial<ValidationMessageProps>;\n /** @deprecated Use `validationMessage` instead */\n errorMessage?: ReactNode;\n /** @deprecated Use `validationMessageProps` instead */\n errorMessageProps?: Partial<ErrorMessageProps>;\n labelProps?: LabelHTMLAttributes<HTMLLabelElement>;\n label?: ReactNode;\n disabled?: boolean;\n readOnly?: boolean;\n /**\n * `children` must be either a single input element or a render function.\n *\n * If you use a render function, make sure you spread the input props to the appropriate element.\n */\n children: Exclude<ReactNode, Iterable<ReactNode>> | ((inputProps: InputProps) => ReactNode);\n}\n\nexport const InputGroup = forwardRef<HTMLDivElement, InputGroupProps>(function InputGroup(\n {\n id,\n className,\n style,\n \"data-color\": dataColor = undefined,\n size = \"large\",\n validationMessage,\n validationMessageProps,\n errorMessage,\n errorMessageProps,\n labelProps: { className: labelClassName, ...labelProps } = {},\n label,\n disabled,\n readOnly,\n children,\n ...rest\n },\n ref,\n) {\n const validationMessageId = useId();\n const inputId = useId();\n const validationColor = errorMessage ? \"error\" : dataColor;\n const validationMessageValue = getValidationMessageValue(validationMessage, errorMessage);\n\n const renderInput = () => {\n const inputProps: InputProps = {\n \"aria-describedby\": validationMessage ? validationMessageId : undefined,\n \"aria-invalid\": errorMessage ? true : undefined,\n id: id ?? inputId,\n className: clsx(\"hds-input-group__input\"),\n };\n\n if (typeof children === \"function\") {\n return children(inputProps);\n }\n\n const input: ReactNode = Children.toArray(children)[0];\n\n if (!isValidElement<InputProps>(input)) {\n return;\n }\n\n return cloneElement<InputProps>(input, {\n ...inputProps,\n ...input.props,\n className: `${inputProps.className} ${input.props.className ?? \"\"}`,\n });\n };\n\n return (\n <div\n className={clsx(\n \"hds-input-group\",\n {\n [`hds-input-group--${size}`]: size,\n },\n className as undefined,\n )}\n ref={ref}\n style={style}\n data-color={validationColor}\n {...rest}\n >\n {label !== null && label !== undefined && label !== false && (\n <label\n className={clsx(\"hds-input-group__label\", labelClassName as undefined)}\n {...labelProps}\n htmlFor={id ?? inputId}\n >\n {label}\n </label>\n )}\n <div\n className={clsx(\"hds-input-group__input-wrapper\")}\n data-disabled={disabled}\n data-readonly={readOnly}\n >\n {renderInput()}\n </div>\n <ValidationMessage\n id={validationMessageId}\n {...(validationMessageProps ?? errorMessageProps)}\n >\n {validationMessageValue}\n </ValidationMessage>\n </div>\n );\n});\n","import { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { forwardRef, type ReactNode } from \"react\";\n\nexport interface ValidationMessageProps extends React.HTMLAttributes<HTMLDivElement> {\n children: ReactNode;\n id: string;\n className?: string;\n}\n\nexport const ValidationMessage = forwardRef<HTMLDivElement, ValidationMessageProps>(\n ({ children, id, className, ...rest }, ref) => (\n <div\n aria-live=\"polite\"\n className={clsx(\"hds-validation-message\", className as undefined)}\n id={id}\n ref={ref}\n {...rest}\n >\n {children}\n </div>\n ),\n);\nValidationMessage.displayName = \"ValidationMessage\";\n","import * as React from \"react\";\nimport { useCallback, useEffect, useState, version } from \"react\";\nimport type { ReactNode } from \"react\";\n\n/**\n * Merges an array of refs into a single memoized callback ref or `null`.\n * @see https://floating-ui.com/docs/useMergeRefs\n */\nexport function useMergeRefs<Instance>(\n refs: (React.Ref<Instance> | undefined)[],\n): React.RefCallback<Instance> | null {\n return React.useMemo(() => {\n if (refs.every((ref) => ref === null)) {\n return null;\n }\n\n return (value) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref !== null) {\n (ref as React.MutableRefObject<Instance | null>).current = value;\n }\n });\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, refs);\n}\n\nexport function useResize<Instance extends HTMLElement>(\n ref: React.RefObject<Instance> | undefined | null,\n): { width: number; height: number } {\n const [width, setWidth] = useState<number>(0);\n const [height, setHeight] = useState<number>(0);\n const handleResize = useCallback(() => {\n if (ref?.current !== null) {\n setWidth(ref?.current?.offsetWidth ?? 0);\n setHeight(ref?.current?.offsetHeight ?? 0);\n }\n }, [ref]);\n useEffect(() => {\n window.addEventListener(\"load\", handleResize);\n window.addEventListener(\"resize\", handleResize);\n return () => {\n window.removeEventListener(\"load\", handleResize);\n window.removeEventListener(\"resize\", handleResize);\n };\n }, [ref, handleResize]);\n useEffect(() => {\n handleResize();\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, []);\n return { width, height };\n}\n\nfunction subscribe() {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- It's ok\n return () => {};\n}\n\nexport function useHydrated() {\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n}\n\nexport function getValidationMessageValue(\n validationMessage?: ReactNode | { value: ReactNode },\n errorMessage?: ReactNode,\n): ReactNode {\n if (validationMessage) {\n if (typeof validationMessage === \"object\" && \"value\" in validationMessage) {\n return validationMessage.value;\n }\n\n return validationMessage;\n }\n\n return errorMessage;\n}\n\n/**\n * Trap focus inside an element using the `inert` attribute.\n *\n * Adds `inert` to all siblings of the given element, and all their ancestors up to the body.\n * Returns a cleanup function which removes the `inert` property from the elements, effectively giving focus back to rest of the document.\n *\n * NOTE: Does not support portals, i.e. elements outside the DOM hierarchy of the given element.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert\n * @see https://web.dev/articles/inert\n */\nexport function focusTrap(element: HTMLElement) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- NOP on focus trapping the body element\n if (element === document.body) return () => {};\n\n let inertElements: HTMLElement[] = [];\n for (let el: HTMLElement | null = element; el; el = el.parentElement) {\n if (el === document.body) break;\n\n for (const sibling of el.parentElement?.children ?? []) {\n if (sibling === el) continue;\n if (!(sibling instanceof HTMLElement)) continue;\n if (sibling.hasAttribute(\"inert\")) continue;\n\n sibling.setAttribute(\"inert\", \"true\");\n inertElements.push(sibling);\n }\n }\n\n return () => {\n releaseFocusTrap(inertElements);\n inertElements = [];\n };\n}\n\n/**\n * Unset the `inert` attribute on all elements given\n */\nfunction releaseFocusTrap(inertElements: Iterable<HTMLElement>) {\n for (const el of inertElements) {\n el.removeAttribute(\"inert\");\n }\n}\n\n/**\n * React 19 supports inert prop\n * React 18 needs inert to be a string\n */\nconst inertBooleanSupported: boolean = Number(version.split(\".\")[0]) >= 19;\n\n/**\n * Returns the inert prop value based on the React version.\n */\nexport const inertPropValue: (x: boolean) => boolean | \"\" | undefined = inertBooleanSupported\n ? (x: boolean): boolean => x\n : (x: boolean): \"\" | undefined => (x ? \"\" : undefined);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,g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AAC;AAAA;AAAA,YACC,IAAI;AAAA,aACC,0DAA0B,oBAFhC;AAAA,YAIE;AAAA;AAAA,QACH;AAAA;AAAA;AAAA,EACF;AAEJ,CAAC;","names":["import_react","import_typed_classname","import_react","import_jsx_runtime","InputGroup","_a"]}
1
+ {"version":3,"sources":["../../../src/form/input-group/index.tsx","../../../src/form/input-group/input-group.tsx","../../../src/form/validation-message/validation-message.tsx","../../../src/utils/utils.ts"],"sourcesContent":["export { InputGroup } from \"./input-group\";\nexport type * from \"./input-group\";\n","import { useId, forwardRef, Children, isValidElement, cloneElement } from \"react\";\nimport type { LabelHTMLAttributes, ReactNode, CSSProperties } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { ValidationMessage, type ValidationMessageProps } from \"../validation-message\";\nimport { type ErrorMessageProps } from \"../error-message\";\nimport { getValidationMessageValue } from \"../../utils\";\n\ninterface InputProps {\n \"aria-describedby\"?: string;\n \"aria-invalid\"?: boolean;\n id?: string;\n className?: string;\n}\n\nexport interface InputGroupProps {\n id?: string;\n className?: string;\n style?: CSSProperties;\n \"data-color\"?: \"info\" | \"success\" | \"warning\" | \"error\";\n size?: \"large\" | \"small\";\n validationMessage?: ReactNode | { value: ReactNode };\n validationMessageProps?: Partial<ValidationMessageProps>;\n /** @deprecated Use `validationMessage` instead */\n errorMessage?: ReactNode;\n /** @deprecated Use `validationMessageProps` instead */\n errorMessageProps?: Partial<ErrorMessageProps>;\n labelProps?: LabelHTMLAttributes<HTMLLabelElement>;\n label?: ReactNode;\n disabled?: boolean;\n readOnly?: boolean;\n /**\n * `children` must be either a single input element or a render function.\n *\n * If you use a render function, make sure you spread the input props to the appropriate element.\n */\n children: Exclude<ReactNode, Iterable<ReactNode>> | ((inputProps: InputProps) => ReactNode);\n}\n\nexport const InputGroup = forwardRef<HTMLDivElement, InputGroupProps>(function InputGroup(\n {\n id,\n className,\n style,\n \"data-color\": dataColor = undefined,\n size = \"large\",\n validationMessage,\n validationMessageProps,\n errorMessage,\n errorMessageProps,\n labelProps: { className: labelClassName, ...labelProps } = {},\n label,\n disabled,\n readOnly,\n children,\n ...rest\n },\n ref,\n) {\n const validationMessageId = useId();\n const inputId = useId();\n const validationColor = errorMessage ? \"error\" : dataColor;\n const validationMessageValue = getValidationMessageValue(validationMessage, errorMessage);\n\n const renderInput = () => {\n const inputProps: InputProps = {\n \"aria-describedby\": validationMessage ? validationMessageId : undefined,\n \"aria-invalid\": errorMessage ? true : undefined,\n id: id ?? inputId,\n className: clsx(\"hds-input-group__input\"),\n };\n\n if (typeof children === \"function\") {\n return children(inputProps);\n }\n\n const input: ReactNode = Children.toArray(children)[0];\n\n if (!isValidElement<InputProps>(input)) {\n return;\n }\n\n return cloneElement<InputProps>(input, {\n ...inputProps,\n ...input.props,\n className: `${inputProps.className} ${input.props.className ?? \"\"}`,\n });\n };\n\n return (\n <div\n className={clsx(\n \"hds-input-group\",\n {\n [`hds-input-group--${size}`]: size,\n },\n className as undefined,\n )}\n ref={ref}\n style={style}\n data-color={validationColor}\n {...rest}\n >\n {label !== null && label !== undefined && label !== false && (\n <label\n className={clsx(\"hds-input-group__label\", labelClassName as undefined)}\n {...labelProps}\n htmlFor={id ?? inputId}\n >\n {label}\n </label>\n )}\n <div\n className={clsx(\"hds-input-group__input-wrapper\")}\n data-disabled={disabled}\n data-readonly={readOnly}\n >\n {renderInput()}\n </div>\n <ValidationMessage\n id={validationMessageId}\n {...(validationMessageProps ?? errorMessageProps)}\n >\n {validationMessageValue}\n </ValidationMessage>\n </div>\n );\n});\n","import { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { forwardRef, type HTMLAttributes } from \"react\";\n\nexport interface ValidationMessageProps extends HTMLAttributes<HTMLDivElement> {\n className?: string;\n}\n\nexport const ValidationMessage = forwardRef<HTMLDivElement, ValidationMessageProps>(\n ({ className, ...rest }, ref) => (\n <div\n aria-live=\"polite\"\n className={clsx(\"hds-validation-message\", className as undefined)}\n ref={ref}\n {...rest}\n />\n ),\n);\nValidationMessage.displayName = \"ValidationMessage\";\n","import * as React from \"react\";\nimport { useCallback, useEffect, useState, version } from \"react\";\nimport type { ReactNode } from \"react\";\n\n/**\n * Merges an array of refs into a single memoized callback ref or `null`.\n * @see https://floating-ui.com/docs/useMergeRefs\n */\nexport function useMergeRefs<Instance>(\n refs: (React.Ref<Instance> | undefined)[],\n): React.RefCallback<Instance> | null {\n return React.useMemo(() => {\n if (refs.every((ref) => ref === null)) {\n return null;\n }\n\n return (value) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref !== null) {\n (ref as React.MutableRefObject<Instance | null>).current = value;\n }\n });\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, refs);\n}\n\nexport function useResize<Instance extends HTMLElement>(\n ref: React.RefObject<Instance> | undefined | null,\n): { width: number; height: number } {\n const [width, setWidth] = useState<number>(0);\n const [height, setHeight] = useState<number>(0);\n const handleResize = useCallback(() => {\n if (ref?.current !== null) {\n setWidth(ref?.current?.offsetWidth ?? 0);\n setHeight(ref?.current?.offsetHeight ?? 0);\n }\n }, [ref]);\n useEffect(() => {\n window.addEventListener(\"load\", handleResize);\n window.addEventListener(\"resize\", handleResize);\n return () => {\n window.removeEventListener(\"load\", handleResize);\n window.removeEventListener(\"resize\", handleResize);\n };\n }, [ref, handleResize]);\n useEffect(() => {\n handleResize();\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, []);\n return { width, height };\n}\n\nfunction subscribe() {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- It's ok\n return () => {};\n}\n\nexport function useHydrated() {\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n}\n\nexport function getValidationMessageValue(\n validationMessage?: ReactNode | { value: ReactNode },\n errorMessage?: ReactNode,\n): ReactNode {\n if (validationMessage) {\n if (typeof validationMessage === \"object\" && \"value\" in validationMessage) {\n return validationMessage.value;\n }\n\n return validationMessage;\n }\n\n return errorMessage;\n}\n\n/**\n * Trap focus inside an element using the `inert` attribute.\n *\n * Adds `inert` to all siblings of the given element, and all their ancestors up to the body.\n * Returns a cleanup function which removes the `inert` property from the elements, effectively giving focus back to rest of the document.\n *\n * NOTE: Does not support portals, i.e. elements outside the DOM hierarchy of the given element.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert\n * @see https://web.dev/articles/inert\n */\nexport function focusTrap(element: HTMLElement) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- NOP on focus trapping the body element\n if (element === document.body) return () => {};\n\n let inertElements: HTMLElement[] = [];\n for (let el: HTMLElement | null = element; el; el = el.parentElement) {\n if (el === document.body) break;\n\n for (const sibling of el.parentElement?.children ?? []) {\n if (sibling === el) continue;\n if (!(sibling instanceof HTMLElement)) continue;\n if (sibling.hasAttribute(\"inert\")) continue;\n\n sibling.setAttribute(\"inert\", \"true\");\n inertElements.push(sibling);\n }\n }\n\n return () => {\n releaseFocusTrap(inertElements);\n inertElements = [];\n };\n}\n\n/**\n * Unset the `inert` attribute on all elements given\n */\nfunction releaseFocusTrap(inertElements: Iterable<HTMLElement>) {\n for (const el of inertElements) {\n el.removeAttribute(\"inert\");\n }\n}\n\n/**\n * React 19 supports inert prop\n * React 18 needs inert to be a string\n */\nconst inertBooleanSupported: boolean = Number(version.split(\".\")[0]) >= 19;\n\n/**\n * Returns the inert prop value based on the React version.\n */\nexport const inertPropValue: (x: boolean) => boolean | \"\" | undefined = inertBooleanSupported\n ? (x: boolean): boolean => x\n : (x: boolean): \"\" | undefined => (x ? \"\" : undefined);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,gBAA0E;AAE1E,IAAAC,0BAAqB;;;ACFrB,6BAAqB;AACrB,mBAAgD;AAQ5C;AAFG,IAAM,wBAAoB;AAAA,EAC/B,CAAC,IAAwB,QAAK;AAA7B,iBA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  import "../../chunk-Y5SUMFYJ.mjs";
2
2
  import {
3
3
  InputGroup
4
- } from "../../chunk-GIFDGUFW.mjs";
4
+ } from "../../chunk-DMRQEQQK.mjs";
5
5
  import "../../chunk-NSLSA7F7.mjs";
6
- import "../../chunk-77UAHNU6.mjs";
6
+ import "../../chunk-VNH7CZJ4.mjs";
7
7
  import "../../chunk-5M6MEYM7.mjs";
8
- import "../../chunk-7REW23LO.mjs";
8
+ import "../../chunk-F23MNQCK.mjs";
9
9
  import "../../chunk-CYDWEPFL.mjs";
10
10
  import "../../chunk-KPNAC2WN.mjs";
11
11
  import "../../chunk-3V4GFS46.mjs";
@@ -71,17 +71,14 @@ var import_react = require("react");
71
71
  var import_jsx_runtime = require("react/jsx-runtime");
72
72
  var ValidationMessage = (0, import_react.forwardRef)(
73
73
  (_a, ref) => {
74
- var _b = _a, { children, id, className } = _b, rest = __objRest(_b, ["children", "id", "className"]);
74
+ var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
75
75
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
76
76
  "div",
77
- __spreadProps(__spreadValues({
77
+ __spreadValues({
78
78
  "aria-live": "polite",
79
79
  className: (0, import_typed_classname.clsx)("hds-validation-message", className),
80
- id,
81
80
  ref
82
- }, rest), {
83
- children
84
- })
81
+ }, rest)
85
82
  );
86
83
  }
87
84
  );
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/form/input-group/input-group.tsx","../../../src/form/validation-message/validation-message.tsx","../../../src/utils/utils.ts"],"sourcesContent":["import { useId, forwardRef, Children, isValidElement, cloneElement } from \"react\";\nimport type { LabelHTMLAttributes, ReactNode, CSSProperties } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { ValidationMessage, type ValidationMessageProps } from \"../validation-message\";\nimport { type ErrorMessageProps } from \"../error-message\";\nimport { getValidationMessageValue } from \"../../utils\";\n\ninterface InputProps {\n \"aria-describedby\"?: string;\n \"aria-invalid\"?: boolean;\n id?: string;\n className?: string;\n}\n\nexport interface InputGroupProps {\n id?: string;\n className?: string;\n style?: CSSProperties;\n \"data-color\"?: \"info\" | \"success\" | \"warning\" | \"error\";\n size?: \"large\" | \"small\";\n validationMessage?: ReactNode | { value: ReactNode };\n validationMessageProps?: Partial<ValidationMessageProps>;\n /** @deprecated Use `validationMessage` instead */\n errorMessage?: ReactNode;\n /** @deprecated Use `validationMessageProps` instead */\n errorMessageProps?: Partial<ErrorMessageProps>;\n labelProps?: LabelHTMLAttributes<HTMLLabelElement>;\n label?: ReactNode;\n disabled?: boolean;\n readOnly?: boolean;\n /**\n * `children` must be either a single input element or a render function.\n *\n * If you use a render function, make sure you spread the input props to the appropriate element.\n */\n children: Exclude<ReactNode, Iterable<ReactNode>> | ((inputProps: InputProps) => ReactNode);\n}\n\nexport const InputGroup = forwardRef<HTMLDivElement, InputGroupProps>(function InputGroup(\n {\n id,\n className,\n style,\n \"data-color\": dataColor = undefined,\n size = \"large\",\n validationMessage,\n validationMessageProps,\n errorMessage,\n errorMessageProps,\n labelProps: { className: labelClassName, ...labelProps } = {},\n label,\n disabled,\n readOnly,\n children,\n ...rest\n },\n ref,\n) {\n const validationMessageId = useId();\n const inputId = useId();\n const validationColor = errorMessage ? \"error\" : dataColor;\n const validationMessageValue = getValidationMessageValue(validationMessage, errorMessage);\n\n const renderInput = () => {\n const inputProps: InputProps = {\n \"aria-describedby\": validationMessage ? validationMessageId : undefined,\n \"aria-invalid\": errorMessage ? true : undefined,\n id: id ?? inputId,\n className: clsx(\"hds-input-group__input\"),\n };\n\n if (typeof children === \"function\") {\n return children(inputProps);\n }\n\n const input: ReactNode = Children.toArray(children)[0];\n\n if (!isValidElement<InputProps>(input)) {\n return;\n }\n\n return cloneElement<InputProps>(input, {\n ...inputProps,\n ...input.props,\n className: `${inputProps.className} ${input.props.className ?? \"\"}`,\n });\n };\n\n return (\n <div\n className={clsx(\n \"hds-input-group\",\n {\n [`hds-input-group--${size}`]: size,\n },\n className as undefined,\n )}\n ref={ref}\n style={style}\n data-color={validationColor}\n {...rest}\n >\n {label !== null && label !== undefined && label !== false && (\n <label\n className={clsx(\"hds-input-group__label\", labelClassName as undefined)}\n {...labelProps}\n htmlFor={id ?? inputId}\n >\n {label}\n </label>\n )}\n <div\n className={clsx(\"hds-input-group__input-wrapper\")}\n data-disabled={disabled}\n data-readonly={readOnly}\n >\n {renderInput()}\n </div>\n <ValidationMessage\n id={validationMessageId}\n {...(validationMessageProps ?? errorMessageProps)}\n >\n {validationMessageValue}\n </ValidationMessage>\n </div>\n );\n});\n","import { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { forwardRef, type ReactNode } from \"react\";\n\nexport interface ValidationMessageProps extends React.HTMLAttributes<HTMLDivElement> {\n children: ReactNode;\n id: string;\n className?: string;\n}\n\nexport const ValidationMessage = forwardRef<HTMLDivElement, ValidationMessageProps>(\n ({ children, id, className, ...rest }, ref) => (\n <div\n aria-live=\"polite\"\n className={clsx(\"hds-validation-message\", className as undefined)}\n id={id}\n ref={ref}\n {...rest}\n >\n {children}\n </div>\n ),\n);\nValidationMessage.displayName = \"ValidationMessage\";\n","import * as React from \"react\";\nimport { useCallback, useEffect, useState, version } from \"react\";\nimport type { ReactNode } from \"react\";\n\n/**\n * Merges an array of refs into a single memoized callback ref or `null`.\n * @see https://floating-ui.com/docs/useMergeRefs\n */\nexport function useMergeRefs<Instance>(\n refs: (React.Ref<Instance> | undefined)[],\n): React.RefCallback<Instance> | null {\n return React.useMemo(() => {\n if (refs.every((ref) => ref === null)) {\n return null;\n }\n\n return (value) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref !== null) {\n (ref as React.MutableRefObject<Instance | null>).current = value;\n }\n });\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, refs);\n}\n\nexport function useResize<Instance extends HTMLElement>(\n ref: React.RefObject<Instance> | undefined | null,\n): { width: number; height: number } {\n const [width, setWidth] = useState<number>(0);\n const [height, setHeight] = useState<number>(0);\n const handleResize = useCallback(() => {\n if (ref?.current !== null) {\n setWidth(ref?.current?.offsetWidth ?? 0);\n setHeight(ref?.current?.offsetHeight ?? 0);\n }\n }, [ref]);\n useEffect(() => {\n window.addEventListener(\"load\", handleResize);\n window.addEventListener(\"resize\", handleResize);\n return () => {\n window.removeEventListener(\"load\", handleResize);\n window.removeEventListener(\"resize\", handleResize);\n };\n }, [ref, handleResize]);\n useEffect(() => {\n handleResize();\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, []);\n return { width, height };\n}\n\nfunction subscribe() {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- It's ok\n return () => {};\n}\n\nexport function useHydrated() {\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n}\n\nexport function getValidationMessageValue(\n validationMessage?: ReactNode | { value: ReactNode },\n errorMessage?: ReactNode,\n): ReactNode {\n if (validationMessage) {\n if (typeof validationMessage === \"object\" && \"value\" in validationMessage) {\n return validationMessage.value;\n }\n\n return validationMessage;\n }\n\n return errorMessage;\n}\n\n/**\n * Trap focus inside an element using the `inert` attribute.\n *\n * Adds `inert` to all siblings of the given element, and all their ancestors up to the body.\n * Returns a cleanup function which removes the `inert` property from the elements, effectively giving focus back to rest of the document.\n *\n * NOTE: Does not support portals, i.e. elements outside the DOM hierarchy of the given element.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert\n * @see https://web.dev/articles/inert\n */\nexport function focusTrap(element: HTMLElement) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- NOP on focus trapping the body element\n if (element === document.body) return () => {};\n\n let inertElements: HTMLElement[] = [];\n for (let el: HTMLElement | null = element; el; el = el.parentElement) {\n if (el === document.body) break;\n\n for (const sibling of el.parentElement?.children ?? []) {\n if (sibling === el) continue;\n if (!(sibling instanceof HTMLElement)) continue;\n if (sibling.hasAttribute(\"inert\")) continue;\n\n sibling.setAttribute(\"inert\", \"true\");\n inertElements.push(sibling);\n }\n }\n\n return () => {\n releaseFocusTrap(inertElements);\n inertElements = [];\n };\n}\n\n/**\n * Unset the `inert` attribute on all elements given\n */\nfunction releaseFocusTrap(inertElements: Iterable<HTMLElement>) {\n for (const el of inertElements) {\n el.removeAttribute(\"inert\");\n }\n}\n\n/**\n * React 19 supports inert prop\n * React 18 needs inert to be a string\n */\nconst inertBooleanSupported: boolean = Number(version.split(\".\")[0]) >= 19;\n\n/**\n * Returns the inert prop value based on the React version.\n */\nexport const inertPropValue: (x: boolean) => boolean | \"\" | undefined = inertBooleanSupported\n ? (x: boolean): boolean => x\n : (x: boolean): \"\" | undefined => (x ? \"\" : undefined);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,gBAA0E;AAE1E,IAAAC,0BAAqB;;;ACFrB,6BAAqB;AACrB,mBAA2C;AAUvC;AAFG,IAAM,wBAAoB;AAAA,EAC/B,CAAC,IAAsC,QAAK;AAA3C,iBAAE,YAAU,IAAI,UAVnB,IAUG,IAA8B,iBAA9B,IAA8B,CAA5B,YAAU,MAAI;AACf;AAAA,MAAC;AAAA;AAAA,QACC,aAAU;AAAA,QACV,eAAW,6BAAK,0BAA0B,SAAsB;AAAA,QAChE;AAAA,QACA;AAAA,SACI,OALL;AAAA,QAOE;AAAA;AAAA,IACH;AAAA;AAEJ;AACA,kBAAkB,cAAc;;;ACtBhC,YAAuB;AACvB,IAAAC,gBAA0D;AAmEnD,SAAS,0BACd,mBACA,cACW;AACX,MAAI,mBAAmB;AACrB,QAAI,OAAO,sBAAsB,YAAY,WAAW,mBAAmB;AACzE,aAAO,kBAAkB;AAAA,IAC3B;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAkDA,IAAM,wBAAiC,OAAO,sBAAQ,MAAM,GAAG,EAAE,CAAC,CAAC,KAAK;;;AF1CpE,IAAAC,sBAAA;AAnDG,IAAM,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AA,IAAC;AAAA;AAAA,MACC,eAAW;AAAA,QACT;AAAA,QACA;AAAA,UACE,CAAC,oBAAoB,IAAI,EAAE,GAAG;AAAA,QAChC;AAAA,QACA;AAAA,MACF;AAAA,MACA;AAAA,MACA;AAAA,MACA,cAAY;AAAA,OACR,OAXL;AAAA,MAaE;AAAA,kBAAU,QAAQ,UAAU,UAAa,UAAU,SAClD;AAAA,UAAC;AAAA;AAAA,YACC,eAAW,8BAAK,0BAA0B,cAA2B;AAAA,aACjE,aAFL;AAAA,YAGC,SAAS,kBAAM;AAAA,YAEd;AAAA;AAAA,QACH;AAAA,QAEF;AAAA,UAAC;AAAA;AAAA,YACC,eAAW,8BAAK,gCAAgC;AAAA,YAChD,iBAAe;AAAA,YACf,iBAAe;AAAA,YAEd,sBAAY;AAAA;AAAA,QACf;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,IAAI;AAAA,aACC,0DAA0B,oBAFhC;AAAA,YAIE;AAAA;AAAA,QACH;AAAA;AAAA;AAAA,EACF;AAEJ,CAAC;","names":["import_react","import_typed_classname","import_react","import_jsx_runtime","InputGroup","_a"]}
1
+ {"version":3,"sources":["../../../src/form/input-group/input-group.tsx","../../../src/form/validation-message/validation-message.tsx","../../../src/utils/utils.ts"],"sourcesContent":["import { useId, forwardRef, Children, isValidElement, cloneElement } from \"react\";\nimport type { LabelHTMLAttributes, ReactNode, CSSProperties } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { ValidationMessage, type ValidationMessageProps } from \"../validation-message\";\nimport { type ErrorMessageProps } from \"../error-message\";\nimport { getValidationMessageValue } from \"../../utils\";\n\ninterface InputProps {\n \"aria-describedby\"?: string;\n \"aria-invalid\"?: boolean;\n id?: string;\n className?: string;\n}\n\nexport interface InputGroupProps {\n id?: string;\n className?: string;\n style?: CSSProperties;\n \"data-color\"?: \"info\" | \"success\" | \"warning\" | \"error\";\n size?: \"large\" | \"small\";\n validationMessage?: ReactNode | { value: ReactNode };\n validationMessageProps?: Partial<ValidationMessageProps>;\n /** @deprecated Use `validationMessage` instead */\n errorMessage?: ReactNode;\n /** @deprecated Use `validationMessageProps` instead */\n errorMessageProps?: Partial<ErrorMessageProps>;\n labelProps?: LabelHTMLAttributes<HTMLLabelElement>;\n label?: ReactNode;\n disabled?: boolean;\n readOnly?: boolean;\n /**\n * `children` must be either a single input element or a render function.\n *\n * If you use a render function, make sure you spread the input props to the appropriate element.\n */\n children: Exclude<ReactNode, Iterable<ReactNode>> | ((inputProps: InputProps) => ReactNode);\n}\n\nexport const InputGroup = forwardRef<HTMLDivElement, InputGroupProps>(function InputGroup(\n {\n id,\n className,\n style,\n \"data-color\": dataColor = undefined,\n size = \"large\",\n validationMessage,\n validationMessageProps,\n errorMessage,\n errorMessageProps,\n labelProps: { className: labelClassName, ...labelProps } = {},\n label,\n disabled,\n readOnly,\n children,\n ...rest\n },\n ref,\n) {\n const validationMessageId = useId();\n const inputId = useId();\n const validationColor = errorMessage ? \"error\" : dataColor;\n const validationMessageValue = getValidationMessageValue(validationMessage, errorMessage);\n\n const renderInput = () => {\n const inputProps: InputProps = {\n \"aria-describedby\": validationMessage ? validationMessageId : undefined,\n \"aria-invalid\": errorMessage ? true : undefined,\n id: id ?? inputId,\n className: clsx(\"hds-input-group__input\"),\n };\n\n if (typeof children === \"function\") {\n return children(inputProps);\n }\n\n const input: ReactNode = Children.toArray(children)[0];\n\n if (!isValidElement<InputProps>(input)) {\n return;\n }\n\n return cloneElement<InputProps>(input, {\n ...inputProps,\n ...input.props,\n className: `${inputProps.className} ${input.props.className ?? \"\"}`,\n });\n };\n\n return (\n <div\n className={clsx(\n \"hds-input-group\",\n {\n [`hds-input-group--${size}`]: size,\n },\n className as undefined,\n )}\n ref={ref}\n style={style}\n data-color={validationColor}\n {...rest}\n >\n {label !== null && label !== undefined && label !== false && (\n <label\n className={clsx(\"hds-input-group__label\", labelClassName as undefined)}\n {...labelProps}\n htmlFor={id ?? inputId}\n >\n {label}\n </label>\n )}\n <div\n className={clsx(\"hds-input-group__input-wrapper\")}\n data-disabled={disabled}\n data-readonly={readOnly}\n >\n {renderInput()}\n </div>\n <ValidationMessage\n id={validationMessageId}\n {...(validationMessageProps ?? errorMessageProps)}\n >\n {validationMessageValue}\n </ValidationMessage>\n </div>\n );\n});\n","import { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { forwardRef, type HTMLAttributes } from \"react\";\n\nexport interface ValidationMessageProps extends HTMLAttributes<HTMLDivElement> {\n className?: string;\n}\n\nexport const ValidationMessage = forwardRef<HTMLDivElement, ValidationMessageProps>(\n ({ className, ...rest }, ref) => (\n <div\n aria-live=\"polite\"\n className={clsx(\"hds-validation-message\", className as undefined)}\n ref={ref}\n {...rest}\n />\n ),\n);\nValidationMessage.displayName = \"ValidationMessage\";\n","import * as React from \"react\";\nimport { useCallback, useEffect, useState, version } from \"react\";\nimport type { ReactNode } from \"react\";\n\n/**\n * Merges an array of refs into a single memoized callback ref or `null`.\n * @see https://floating-ui.com/docs/useMergeRefs\n */\nexport function useMergeRefs<Instance>(\n refs: (React.Ref<Instance> | undefined)[],\n): React.RefCallback<Instance> | null {\n return React.useMemo(() => {\n if (refs.every((ref) => ref === null)) {\n return null;\n }\n\n return (value) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref !== null) {\n (ref as React.MutableRefObject<Instance | null>).current = value;\n }\n });\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, refs);\n}\n\nexport function useResize<Instance extends HTMLElement>(\n ref: React.RefObject<Instance> | undefined | null,\n): { width: number; height: number } {\n const [width, setWidth] = useState<number>(0);\n const [height, setHeight] = useState<number>(0);\n const handleResize = useCallback(() => {\n if (ref?.current !== null) {\n setWidth(ref?.current?.offsetWidth ?? 0);\n setHeight(ref?.current?.offsetHeight ?? 0);\n }\n }, [ref]);\n useEffect(() => {\n window.addEventListener(\"load\", handleResize);\n window.addEventListener(\"resize\", handleResize);\n return () => {\n window.removeEventListener(\"load\", handleResize);\n window.removeEventListener(\"resize\", handleResize);\n };\n }, [ref, handleResize]);\n useEffect(() => {\n handleResize();\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, []);\n return { width, height };\n}\n\nfunction subscribe() {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- It's ok\n return () => {};\n}\n\nexport function useHydrated() {\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n}\n\nexport function getValidationMessageValue(\n validationMessage?: ReactNode | { value: ReactNode },\n errorMessage?: ReactNode,\n): ReactNode {\n if (validationMessage) {\n if (typeof validationMessage === \"object\" && \"value\" in validationMessage) {\n return validationMessage.value;\n }\n\n return validationMessage;\n }\n\n return errorMessage;\n}\n\n/**\n * Trap focus inside an element using the `inert` attribute.\n *\n * Adds `inert` to all siblings of the given element, and all their ancestors up to the body.\n * Returns a cleanup function which removes the `inert` property from the elements, effectively giving focus back to rest of the document.\n *\n * NOTE: Does not support portals, i.e. elements outside the DOM hierarchy of the given element.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert\n * @see https://web.dev/articles/inert\n */\nexport function focusTrap(element: HTMLElement) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- NOP on focus trapping the body element\n if (element === document.body) return () => {};\n\n let inertElements: HTMLElement[] = [];\n for (let el: HTMLElement | null = element; el; el = el.parentElement) {\n if (el === document.body) break;\n\n for (const sibling of el.parentElement?.children ?? []) {\n if (sibling === el) continue;\n if (!(sibling instanceof HTMLElement)) continue;\n if (sibling.hasAttribute(\"inert\")) continue;\n\n sibling.setAttribute(\"inert\", \"true\");\n inertElements.push(sibling);\n }\n }\n\n return () => {\n releaseFocusTrap(inertElements);\n inertElements = [];\n };\n}\n\n/**\n * Unset the `inert` attribute on all elements given\n */\nfunction releaseFocusTrap(inertElements: Iterable<HTMLElement>) {\n for (const el of inertElements) {\n el.removeAttribute(\"inert\");\n }\n}\n\n/**\n * React 19 supports inert prop\n * React 18 needs inert to be a string\n */\nconst inertBooleanSupported: boolean = Number(version.split(\".\")[0]) >= 19;\n\n/**\n * Returns the inert prop value based on the React version.\n */\nexport const inertPropValue: (x: boolean) => boolean | \"\" | undefined = inertBooleanSupported\n ? (x: boolean): boolean => x\n : (x: boolean): \"\" | undefined => (x ? \"\" : undefined);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,gBAA0E;AAE1E,IAAAC,0BAAqB;;;ACFrB,6BAAqB;AACrB,mBAAgD;AAQ5C;AAFG,IAAM,wBAAoB;AAAA,EAC/B,CAAC,IAAwB,QAAK;AAA7B,iBAAE,YARL,IAQG,IAAgB,iBAAhB,IAAgB,CAAd;AACD;AAAA,MAAC;AAAA;AAAA,QACC,aAAU;AAAA,QACV,eAAW,6BAAK,0BAA0B,SAAsB;AAAA,QAChE;AAAA,SACI;AAAA,IACN;AAAA;AAEJ;AACA,kBAAkB,cAAc;;;ACjBhC,YAAuB;AACvB,IAAAC,gBAA0D;AAmEnD,SAAS,0BACd,mBACA,cACW;AACX,MAAI,mBAAmB;AACrB,QAAI,OAAO,sBAAsB,YAAY,WAAW,mBAAmB;AACzE,aAAO,kBAAkB;AAAA,IAC3B;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;AAkDA,IAAM,wBAAiC,OAAO,sBAAQ,MAAM,GAAG,EAAE,CAAC,CAAC,KAAK;;;AF1CpE,IAAAC,sBAAA;AAnDG,IAAM,iBAAa,0BAA4C,SAASC,YAC7E,IAiBA,KACA;AAlBA,eAUc;AAAA,IATZ;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc,YAAY;AAAA,IAC1B,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,YAAY,KAA+C,CAAC;AAAA,EAjDhE,IAuCE,IAUc,SAAE,aAAW,eAjD7B,IAiDgB,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;AAAA,YACC,eAAW,8BAAK,0BAA0B,cAA2B;AAAA,aACjE,aAFL;AAAA,YAGC,SAAS,kBAAM;AAAA,YAEd;AAAA;AAAA,QACH;AAAA,QAEF;AAAA,UAAC;AAAA;AAAA,YACC,eAAW,8BAAK,gCAAgC;AAAA,YAChD,iBAAe;AAAA,YACf,iBAAe;AAAA,YAEd,sBAAY;AAAA;AAAA,QACf;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,IAAI;AAAA,aACC,0DAA0B,oBAFhC;AAAA,YAIE;AAAA;AAAA,QACH;AAAA;AAAA;AAAA,EACF;AAEJ,CAAC;","names":["import_react","import_typed_classname","import_react","import_jsx_runtime","InputGroup","_a"]}
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  InputGroup
3
- } from "../../chunk-GIFDGUFW.mjs";
3
+ } from "../../chunk-DMRQEQQK.mjs";
4
4
  import "../../chunk-NSLSA7F7.mjs";
5
- import "../../chunk-77UAHNU6.mjs";
5
+ import "../../chunk-VNH7CZJ4.mjs";
6
6
  import "../../chunk-5M6MEYM7.mjs";
7
- import "../../chunk-7REW23LO.mjs";
7
+ import "../../chunk-F23MNQCK.mjs";
8
8
  import "../../chunk-CYDWEPFL.mjs";
9
9
  import "../../chunk-KPNAC2WN.mjs";
10
10
  import "../../chunk-3V4GFS46.mjs";
@@ -91,17 +91,14 @@ var import_react2 = require("react");
91
91
  var import_jsx_runtime2 = require("react/jsx-runtime");
92
92
  var ValidationMessage = (0, import_react2.forwardRef)(
93
93
  (_a, ref) => {
94
- var _b = _a, { children, id, className } = _b, rest = __objRest(_b, ["children", "id", "className"]);
94
+ var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
95
95
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
96
96
  "div",
97
- __spreadProps(__spreadValues({
97
+ __spreadValues({
98
98
  "aria-live": "polite",
99
99
  className: (0, import_typed_classname.clsx)("hds-validation-message", className),
100
- id,
101
100
  ref
102
- }, rest), {
103
- children
104
- })
101
+ }, rest)
105
102
  );
106
103
  }
107
104
  );
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/form/radio-button/index.tsx","../../../src/form/radio-button/radio-button.tsx","../../../src/form/radio-button/radio-group.tsx","../../../src/form/fieldset/fieldset-description.tsx","../../../src/form/fieldset/fieldset.tsx","../../../src/form/validation-message/validation-message.tsx","../../../src/utils/utils.ts","../../../src/form/fieldset/fieldset-legend.tsx"],"sourcesContent":["export { RadioButton } from \"./radio-button\";\nexport type * from \"./radio-button\";\nexport { RadioGroup, useRadioGroupContext } from \"./radio-group\";\nexport type * from \"./radio-group\";\n","import { forwardRef, type InputHTMLAttributes, type ReactNode } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { useRadioGroupContext } from \"./radio-group\";\n\nexport interface RadioButtonProps\n extends Omit<InputHTMLAttributes<HTMLInputElement>, \"defaultValue\" | \"size\"> {\n children: ReactNode;\n variant?: \"plain\" | \"bounding-box\";\n title?: string;\n size?: \"small\" | \"\";\n}\n\nconst isChecked = ({\n checked,\n selectedValue,\n value,\n}: Pick<RadioButtonProps, \"checked\" | \"value\"> & {\n selectedValue: RadioButtonProps[\"value\"];\n}) => {\n if (typeof checked !== \"undefined\") return checked;\n if (typeof selectedValue !== \"undefined\") return value === selectedValue;\n return undefined;\n};\n\nexport const RadioButton = forwardRef<HTMLInputElement, RadioButtonProps>(\n ({ checked, value, variant = \"plain\", title, children, className, size = \"\", ...rest }, ref) => {\n const { value: selectedValue, size: groupSize, ...context } = useRadioGroupContext();\n const effectiveSize = size || groupSize;\n\n return (\n <div\n className={clsx(\n \"hds-radio-button\",\n {\n [`hds-radio-button--${variant}`]: variant === \"bounding-box\",\n [`hds-radio-button--${effectiveSize}`]: effectiveSize === \"small\",\n },\n className as undefined,\n )}\n >\n <label>\n <input\n {...context}\n {...rest}\n checked={isChecked({ checked, selectedValue, value })}\n value={value}\n ref={ref}\n type=\"radio\"\n />\n <span aria-hidden className=\"hds-radio-button__checkmark\" />\n {title ? <p className=\"hds-radio-button__title\">{title}</p> : children}\n </label>\n {title ? children : null}\n </div>\n );\n },\n);\n\nRadioButton.displayName = \"RadioButton\";\n","import {\n type ChangeEventHandler,\n createContext,\n forwardRef,\n type InputHTMLAttributes,\n type ReactNode,\n useContext,\n} from \"react\";\nimport { FieldsetDescription } from \"../fieldset/fieldset-description\";\nimport { Fieldset, type FieldsetProps } from \"../fieldset\";\nimport { FieldsetLegend } from \"../fieldset/fieldset-legend\";\n\nexport interface RadioGroupProps extends Omit<FieldsetProps, \"onChange\"> {\n children: ReactNode;\n /** Will be passed to all Radio buttons within the radio group */\n name?: InputHTMLAttributes<HTMLInputElement>[\"name\"];\n /** If you want the group to be controlled, you can pass the selected value here */\n value?: InputHTMLAttributes<HTMLInputElement>[\"value\"];\n /** Will be passed to all Radio buttons within the radio group */\n onChange?: ChangeEventHandler<HTMLInputElement> | undefined;\n}\n\ntype RadioGroupContextProps = Pick<RadioGroupProps, \"name\" | \"value\" | \"onChange\" | \"size\">;\n\nconst RadioGroupContext = createContext<RadioGroupContextProps>({\n name: undefined,\n onChange: () => undefined,\n size: undefined,\n});\n\nexport const useRadioGroupContext = () => useContext(RadioGroupContext);\n\nexport const RadioGroup = forwardRef<HTMLFieldSetElement, RadioGroupProps>(function RadioGroup(\n { name, value, onChange, children, size, ...rest },\n ref,\n) {\n return (\n <RadioGroupContext.Provider value={{ name, value, onChange, size }}>\n <Fieldset size={size} {...rest} ref={ref}>\n {children}\n </Fieldset>\n </RadioGroupContext.Provider>\n );\n}) as RadioGroupType;\n\ntype RadioGroupType = ReturnType<typeof forwardRef<HTMLFieldSetElement, RadioGroupProps>> & {\n Description: typeof FieldsetDescription;\n Legend: typeof FieldsetLegend;\n};\n\nRadioGroup.Description = FieldsetDescription;\nRadioGroup.Legend = FieldsetLegend;\n\nRadioGroup.displayName = \"RadioGroup\";\n","import { forwardRef, type HTMLAttributes } from \"react\";\n\nexport type FieldsetDescriptionProps = HTMLAttributes<HTMLParagraphElement>;\n\n/**\n * FieldsetDescription component, used to display a description for a fieldset.\n *\n * @example\n * <FieldsetDescription>\n * Gi en kort beskrivelse i begge feltene\n * </FieldsetDescription>\n */\nexport const FieldsetDescription = forwardRef<HTMLParagraphElement, FieldsetDescriptionProps>(\n function FieldsetDescription(rest, ref) {\n return <p className=\"hds-fieldset__description\" ref={ref} {...rest} />;\n },\n);\n","import {\n Children,\n cloneElement,\n isValidElement,\n useId,\n forwardRef,\n createContext,\n useContext,\n} from \"react\";\nimport type {\n FieldsetHTMLAttributes,\n ReactElement,\n ReactNode,\n CSSProperties,\n ComponentProps,\n} from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { ValidationMessage, type ValidationMessageProps } from \"../validation-message\";\nimport { type ErrorMessageProps } from \"../error-message\";\nimport { getValidationMessageValue } from \"../../utils\";\nimport { FieldsetDescription } from \"./fieldset-description\";\nimport { FieldsetLegend } from \"./fieldset-legend\";\n\ntype FieldsetLegendProps = ComponentProps<typeof FieldsetLegend>;\n\nexport interface FieldsetProps extends FieldsetHTMLAttributes<HTMLFieldSetElement> {\n className?: string;\n style?: CSSProperties;\n \"data-color\"?: \"info\" | \"success\" | \"warning\" | \"error\";\n validationMessage?: ReactNode | { value: ReactNode };\n validationMessageProps?: Partial<ValidationMessageProps>;\n /**\n * Providing an errorMessage will also give contained Checkboxes or Radio buttons\n * error styling and aria to indicate invalid state.\n *\n * For Radio buttons you are even better off using RadioGroup.\n */\n\n /** @deprecated Use `validationMessage` instead */\n errorMessage?: ReactNode;\n /**\n * @deprecated Pass props directly to <Fieldset.Legend> instead.\n */\n legendProps?: FieldsetLegendProps;\n /**\n * @deprecated Use <Fieldset.Legend>...</Fieldset.Legend> instead.\n */\n legend?: ReactNode;\n size?: \"small\" | \"\";\n children: ReactNode;\n /** @deprecated Use `validationMessageProps` instead */\n errorMessageProps?: Partial<ErrorMessageProps>;\n}\n\n/** @deprecated Will no longer be needed */\nconst FieldsetContext = createContext<{ hasError: boolean; size: \"small\" | \"\" }>({\n hasError: false,\n size: \"\",\n});\n\n/** @deprecated Will no longer be needed */\nexport const useFieldsetContext = () => useContext(FieldsetContext);\n\nexport const Fieldset = forwardRef<HTMLFieldSetElement, FieldsetProps>(function Fieldset(\n {\n className,\n style,\n \"data-color\": dataColor = undefined,\n validationMessage,\n validationMessageProps,\n errorMessage,\n errorMessageProps,\n legendProps,\n legend,\n size = \"\",\n children,\n ...rest\n },\n ref,\n) {\n const validationMessageId = useId();\n const validationColor = errorMessage ? \"error\" : dataColor;\n const validationMessageValue = getValidationMessageValue(validationMessage, errorMessage);\n const childArray = Children.toArray(children);\n const legendChild = childArray.find(\n (child): child is ReactElement<FieldsetLegendProps> =>\n isValidElement<FieldsetLegendProps>(child) && child.type === FieldsetLegend,\n );\n const contentChildren = legendChild\n ? childArray.filter((child) => child !== legendChild)\n : childArray;\n let renderedLegend = null;\n\n if (legendChild) {\n renderedLegend = cloneElement(legendChild, {\n ...legendProps,\n ...legendChild.props,\n className: clsx(\n legendProps?.className as undefined,\n legendChild.props.className as undefined,\n ),\n });\n } else if (legend !== undefined) {\n renderedLegend = <FieldsetLegend {...legendProps}>{legend}</FieldsetLegend>;\n }\n\n return (\n <fieldset\n aria-describedby={validationMessageValue ? validationMessageId : undefined}\n aria-invalid={errorMessage ? true : undefined}\n className={clsx(\"hds-fieldset\", { [`hds-fieldset--${size}`]: size }, className as undefined)}\n data-color={validationColor}\n ref={ref}\n style={style}\n {...rest}\n >\n {renderedLegend}\n <FieldsetContext.Provider value={{ hasError: Boolean(errorMessage), size }}>\n {contentChildren}\n </FieldsetContext.Provider>\n <ValidationMessage\n id={validationMessageId}\n {...(validationMessageProps ?? errorMessageProps)}\n >\n {validationMessageValue}\n </ValidationMessage>\n </fieldset>\n );\n}) as FieldsetType;\n\ntype FieldsetType = ReturnType<typeof forwardRef<HTMLFieldSetElement, FieldsetProps>> & {\n Description: typeof FieldsetDescription;\n Legend: typeof FieldsetLegend;\n};\n\nFieldset.Description = FieldsetDescription;\nFieldset.Legend = FieldsetLegend;\n","import { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { forwardRef, type ReactNode } from \"react\";\n\nexport interface ValidationMessageProps extends React.HTMLAttributes<HTMLDivElement> {\n children: ReactNode;\n id: string;\n className?: string;\n}\n\nexport const ValidationMessage = forwardRef<HTMLDivElement, ValidationMessageProps>(\n ({ children, id, className, ...rest }, ref) => (\n <div\n aria-live=\"polite\"\n className={clsx(\"hds-validation-message\", className as undefined)}\n id={id}\n ref={ref}\n {...rest}\n >\n {children}\n </div>\n ),\n);\nValidationMessage.displayName = \"ValidationMessage\";\n","import * as React from \"react\";\nimport { useCallback, useEffect, useState, version } from \"react\";\nimport type { ReactNode } from \"react\";\n\n/**\n * Merges an array of refs into a single memoized callback ref or `null`.\n * @see https://floating-ui.com/docs/useMergeRefs\n */\nexport function useMergeRefs<Instance>(\n refs: (React.Ref<Instance> | undefined)[],\n): React.RefCallback<Instance> | null {\n return React.useMemo(() => {\n if (refs.every((ref) => ref === null)) {\n return null;\n }\n\n return (value) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref !== null) {\n (ref as React.MutableRefObject<Instance | null>).current = value;\n }\n });\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, refs);\n}\n\nexport function useResize<Instance extends HTMLElement>(\n ref: React.RefObject<Instance> | undefined | null,\n): { width: number; height: number } {\n const [width, setWidth] = useState<number>(0);\n const [height, setHeight] = useState<number>(0);\n const handleResize = useCallback(() => {\n if (ref?.current !== null) {\n setWidth(ref?.current?.offsetWidth ?? 0);\n setHeight(ref?.current?.offsetHeight ?? 0);\n }\n }, [ref]);\n useEffect(() => {\n window.addEventListener(\"load\", handleResize);\n window.addEventListener(\"resize\", handleResize);\n return () => {\n window.removeEventListener(\"load\", handleResize);\n window.removeEventListener(\"resize\", handleResize);\n };\n }, [ref, handleResize]);\n useEffect(() => {\n handleResize();\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, []);\n return { width, height };\n}\n\nfunction subscribe() {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- It's ok\n return () => {};\n}\n\nexport function useHydrated() {\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n}\n\nexport function getValidationMessageValue(\n validationMessage?: ReactNode | { value: ReactNode },\n errorMessage?: ReactNode,\n): ReactNode {\n if (validationMessage) {\n if (typeof validationMessage === \"object\" && \"value\" in validationMessage) {\n return validationMessage.value;\n }\n\n return validationMessage;\n }\n\n return errorMessage;\n}\n\n/**\n * Trap focus inside an element using the `inert` attribute.\n *\n * Adds `inert` to all siblings of the given element, and all their ancestors up to the body.\n * Returns a cleanup function which removes the `inert` property from the elements, effectively giving focus back to rest of the document.\n *\n * NOTE: Does not support portals, i.e. elements outside the DOM hierarchy of the given element.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert\n * @see https://web.dev/articles/inert\n */\nexport function focusTrap(element: HTMLElement) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- NOP on focus trapping the body element\n if (element === document.body) return () => {};\n\n let inertElements: HTMLElement[] = [];\n for (let el: HTMLElement | null = element; el; el = el.parentElement) {\n if (el === document.body) break;\n\n for (const sibling of el.parentElement?.children ?? []) {\n if (sibling === el) continue;\n if (!(sibling instanceof HTMLElement)) continue;\n if (sibling.hasAttribute(\"inert\")) continue;\n\n sibling.setAttribute(\"inert\", \"true\");\n inertElements.push(sibling);\n }\n }\n\n return () => {\n releaseFocusTrap(inertElements);\n inertElements = [];\n };\n}\n\n/**\n * Unset the `inert` attribute on all elements given\n */\nfunction releaseFocusTrap(inertElements: Iterable<HTMLElement>) {\n for (const el of inertElements) {\n el.removeAttribute(\"inert\");\n }\n}\n\n/**\n * React 19 supports inert prop\n * React 18 needs inert to be a string\n */\nconst inertBooleanSupported: boolean = Number(version.split(\".\")[0]) >= 19;\n\n/**\n * Returns the inert prop value based on the React version.\n */\nexport const inertPropValue: (x: boolean) => boolean | \"\" | undefined = inertBooleanSupported\n ? (x: boolean): boolean => x\n : (x: boolean): \"\" | undefined => (x ? \"\" : undefined);\n","import { forwardRef, type HTMLAttributes } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\n\n/**\n * FieldsetLegend component, used to display a legend for a fieldset.\n *\n * @example\n * <FieldsetLegend>Skriv inn dine svar</FieldsetLegend>\n */\nexport const FieldsetLegend = forwardRef<HTMLLegendElement, HTMLAttributes<HTMLLegendElement>>(\n function FieldsetLegend({ className, ...rest }, ref) {\n return (\n <legend\n className={clsx(\"hds-fieldset__legend\", className as undefined)}\n ref={ref}\n {...rest}\n />\n );\n },\n);\n\nFieldsetLegend.displayName = \"Fieldset.Legend\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,gBAAqE;AACrE,IAAAC,0BAAqB;;;ACDrB,IAAAC,gBAOO;;;ACPP,mBAAgD;AAcrC;AAFJ,IAAM,0BAAsB;AAAA,EACjC,SAASC,qBAAoB,MAAM,KAAK;AACtC,WAAO,4CAAC,sBAAE,WAAU,6BAA4B,OAAc,KAAM;AAAA,EACtE;AACF;;;AChBA,IAAAC,gBAQO;AAQP,IAAAC,0BAAqB;;;AChBrB,6BAAqB;AACrB,IAAAC,gBAA2C;AAUvC,IAAAC,sBAAA;AAFG,IAAM,wBAAoB;AAAA,EAC/B,CAAC,IAAsC,QAAK;AAA3C,iBAAE,YAAU,IAAI,UAVnB,IAUG,IAA8B,iBAA9B,IAA8B,CAA5B,YAAU,MAAI;AACf;AAAA,MAAC;AAAA;AAAA,QACC,aAAU;AAAA,QACV,eAAW,6BAAK,0BAA0B,SAAsB;AAAA,QAChE;AAAA,QACA;AAAA,SACI,OALL;AAAA,QAOE;AAAA;AAAA,IACH;AAAA;AAEJ;AACA,kBAAk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8B;AAAA,YACzD,QAAQ,6CAAC,OAAE,WAAU,2BAA2B,iBAAM,IAAO;AAAA,aAChE;AAAA,UACC,QAAQ,WAAW;AAAA;AAAA;AAAA,IACtB;AAAA,EAEJ;AACF;AAEA,YAAY,cAAc;","names":["import_react","import_typed_classname","import_react","FieldsetDescription","import_react","import_typed_classname","import_react","import_jsx_runtime","import_react","import_react","import_typed_classname","import_jsx_runtime","FieldsetLegend","import_jsx_runtime","Fieldset","import_jsx_runtime","RadioGroup","import_jsx_runtime","_a"]}
1
+ {"version":3,"sources":["../../../src/form/radio-button/index.tsx","../../../src/form/radio-button/radio-button.tsx","../../../src/form/radio-button/radio-group.tsx","../../../src/form/fieldset/fieldset-description.tsx","../../../src/form/fieldset/fieldset.tsx","../../../src/form/validation-message/validation-message.tsx","../../../src/utils/utils.ts","../../../src/form/fieldset/fieldset-legend.tsx"],"sourcesContent":["export { RadioButton } from \"./radio-button\";\nexport type * from \"./radio-button\";\nexport { RadioGroup, useRadioGroupContext } from \"./radio-group\";\nexport type * from \"./radio-group\";\n","import { forwardRef, type InputHTMLAttributes, type ReactNode } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { useRadioGroupContext } from \"./radio-group\";\n\nexport interface RadioButtonProps\n extends Omit<InputHTMLAttributes<HTMLInputElement>, \"defaultValue\" | \"size\"> {\n children: ReactNode;\n variant?: \"plain\" | \"bounding-box\";\n title?: string;\n size?: \"small\" | \"\";\n}\n\nconst isChecked = ({\n checked,\n selectedValue,\n value,\n}: Pick<RadioButtonProps, \"checked\" | \"value\"> & {\n selectedValue: RadioButtonProps[\"value\"];\n}) => {\n if (typeof checked !== \"undefined\") return checked;\n if (typeof selectedValue !== \"undefined\") return value === selectedValue;\n return undefined;\n};\n\nexport const RadioButton = forwardRef<HTMLInputElement, RadioButtonProps>(\n ({ checked, value, variant = \"plain\", title, children, className, size = \"\", ...rest }, ref) => {\n const { value: selectedValue, size: groupSize, ...context } = useRadioGroupContext();\n const effectiveSize = size || groupSize;\n\n return (\n <div\n className={clsx(\n \"hds-radio-button\",\n {\n [`hds-radio-button--${variant}`]: variant === \"bounding-box\",\n [`hds-radio-button--${effectiveSize}`]: effectiveSize === \"small\",\n },\n className as undefined,\n )}\n >\n <label>\n <input\n {...context}\n {...rest}\n checked={isChecked({ checked, selectedValue, value })}\n value={value}\n ref={ref}\n type=\"radio\"\n />\n <span aria-hidden className=\"hds-radio-button__checkmark\" />\n {title ? <p className=\"hds-radio-button__title\">{title}</p> : children}\n </label>\n {title ? children : null}\n </div>\n );\n },\n);\n\nRadioButton.displayName = \"RadioButton\";\n","import {\n type ChangeEventHandler,\n createContext,\n forwardRef,\n type InputHTMLAttributes,\n type ReactNode,\n useContext,\n} from \"react\";\nimport { FieldsetDescription } from \"../fieldset/fieldset-description\";\nimport { Fieldset, type FieldsetProps } from \"../fieldset\";\nimport { FieldsetLegend } from \"../fieldset/fieldset-legend\";\n\nexport interface RadioGroupProps extends Omit<FieldsetProps, \"onChange\"> {\n children: ReactNode;\n /** Will be passed to all Radio buttons within the radio group */\n name?: InputHTMLAttributes<HTMLInputElement>[\"name\"];\n /** If you want the group to be controlled, you can pass the selected value here */\n value?: InputHTMLAttributes<HTMLInputElement>[\"value\"];\n /** Will be passed to all Radio buttons within the radio group */\n onChange?: ChangeEventHandler<HTMLInputElement> | undefined;\n}\n\ntype RadioGroupContextProps = Pick<RadioGroupProps, \"name\" | \"value\" | \"onChange\" | \"size\">;\n\nconst RadioGroupContext = createContext<RadioGroupContextProps>({\n name: undefined,\n onChange: () => undefined,\n size: undefined,\n});\n\nexport const useRadioGroupContext = () => useContext(RadioGroupContext);\n\nexport const RadioGroup = forwardRef<HTMLFieldSetElement, RadioGroupProps>(function RadioGroup(\n { name, value, onChange, children, size, ...rest },\n ref,\n) {\n return (\n <RadioGroupContext.Provider value={{ name, value, onChange, size }}>\n <Fieldset size={size} {...rest} ref={ref}>\n {children}\n </Fieldset>\n </RadioGroupContext.Provider>\n );\n}) as RadioGroupType;\n\ntype RadioGroupType = ReturnType<typeof forwardRef<HTMLFieldSetElement, RadioGroupProps>> & {\n Description: typeof FieldsetDescription;\n Legend: typeof FieldsetLegend;\n};\n\nRadioGroup.Description = FieldsetDescription;\nRadioGroup.Legend = FieldsetLegend;\n\nRadioGroup.displayName = \"RadioGroup\";\n","import { forwardRef, type HTMLAttributes } from \"react\";\n\nexport type FieldsetDescriptionProps = HTMLAttributes<HTMLParagraphElement>;\n\n/**\n * FieldsetDescription component, used to display a description for a fieldset.\n *\n * @example\n * <FieldsetDescription>\n * Gi en kort beskrivelse i begge feltene\n * </FieldsetDescription>\n */\nexport const FieldsetDescription = forwardRef<HTMLParagraphElement, FieldsetDescriptionProps>(\n function FieldsetDescription(rest, ref) {\n return <p className=\"hds-fieldset__description\" ref={ref} {...rest} />;\n },\n);\n","import {\n Children,\n cloneElement,\n isValidElement,\n useId,\n forwardRef,\n createContext,\n useContext,\n} from \"react\";\nimport type {\n FieldsetHTMLAttributes,\n ReactElement,\n ReactNode,\n CSSProperties,\n ComponentProps,\n} from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { ValidationMessage, type ValidationMessageProps } from \"../validation-message\";\nimport { type ErrorMessageProps } from \"../error-message\";\nimport { getValidationMessageValue } from \"../../utils\";\nimport { FieldsetDescription } from \"./fieldset-description\";\nimport { FieldsetLegend } from \"./fieldset-legend\";\n\ntype FieldsetLegendProps = ComponentProps<typeof FieldsetLegend>;\n\nexport interface FieldsetProps extends FieldsetHTMLAttributes<HTMLFieldSetElement> {\n className?: string;\n style?: CSSProperties;\n \"data-color\"?: \"info\" | \"success\" | \"warning\" | \"error\";\n validationMessage?: ReactNode | { value: ReactNode };\n validationMessageProps?: Partial<ValidationMessageProps>;\n /**\n * Providing an errorMessage will also give contained Checkboxes or Radio buttons\n * error styling and aria to indicate invalid state.\n *\n * For Radio buttons you are even better off using RadioGroup.\n */\n\n /** @deprecated Use `validationMessage` instead */\n errorMessage?: ReactNode;\n /**\n * @deprecated Pass props directly to <Fieldset.Legend> instead.\n */\n legendProps?: FieldsetLegendProps;\n /**\n * @deprecated Use <Fieldset.Legend>...</Fieldset.Legend> instead.\n */\n legend?: ReactNode;\n size?: \"small\" | \"\";\n children: ReactNode;\n /** @deprecated Use `validationMessageProps` instead */\n errorMessageProps?: Partial<ErrorMessageProps>;\n}\n\n/** @deprecated Will no longer be needed */\nconst FieldsetContext = createContext<{ hasError: boolean; size: \"small\" | \"\" }>({\n hasError: false,\n size: \"\",\n});\n\n/** @deprecated Will no longer be needed */\nexport const useFieldsetContext = () => useContext(FieldsetContext);\n\nexport const Fieldset = forwardRef<HTMLFieldSetElement, FieldsetProps>(function Fieldset(\n {\n className,\n style,\n \"data-color\": dataColor = undefined,\n validationMessage,\n validationMessageProps,\n errorMessage,\n errorMessageProps,\n legendProps,\n legend,\n size = \"\",\n children,\n ...rest\n },\n ref,\n) {\n const validationMessageId = useId();\n const validationColor = errorMessage ? \"error\" : dataColor;\n const validationMessageValue = getValidationMessageValue(validationMessage, errorMessage);\n const childArray = Children.toArray(children);\n const legendChild = childArray.find(\n (child): child is ReactElement<FieldsetLegendProps> =>\n isValidElement<FieldsetLegendProps>(child) && child.type === FieldsetLegend,\n );\n const contentChildren = legendChild\n ? childArray.filter((child) => child !== legendChild)\n : childArray;\n let renderedLegend = null;\n\n if (legendChild) {\n renderedLegend = cloneElement(legendChild, {\n ...legendProps,\n ...legendChild.props,\n className: clsx(\n legendProps?.className as undefined,\n legendChild.props.className as undefined,\n ),\n });\n } else if (legend !== undefined) {\n renderedLegend = <FieldsetLegend {...legendProps}>{legend}</FieldsetLegend>;\n }\n\n return (\n <fieldset\n aria-describedby={validationMessageValue ? validationMessageId : undefined}\n aria-invalid={errorMessage ? true : undefined}\n className={clsx(\"hds-fieldset\", { [`hds-fieldset--${size}`]: size }, className as undefined)}\n data-color={validationColor}\n ref={ref}\n style={style}\n {...rest}\n >\n {renderedLegend}\n <FieldsetContext.Provider value={{ hasError: Boolean(errorMessage), size }}>\n {contentChildren}\n </FieldsetContext.Provider>\n <ValidationMessage\n id={validationMessageId}\n {...(validationMessageProps ?? errorMessageProps)}\n >\n {validationMessageValue}\n </ValidationMessage>\n </fieldset>\n );\n}) as FieldsetType;\n\ntype FieldsetType = ReturnType<typeof forwardRef<HTMLFieldSetElement, FieldsetProps>> & {\n Description: typeof FieldsetDescription;\n Legend: typeof FieldsetLegend;\n};\n\nFieldset.Description = FieldsetDescription;\nFieldset.Legend = FieldsetLegend;\n","import { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { forwardRef, type HTMLAttributes } from \"react\";\n\nexport interface ValidationMessageProps extends HTMLAttributes<HTMLDivElement> {\n className?: string;\n}\n\nexport const ValidationMessage = forwardRef<HTMLDivElement, ValidationMessageProps>(\n ({ className, ...rest }, ref) => (\n <div\n aria-live=\"polite\"\n className={clsx(\"hds-validation-message\", className as undefined)}\n ref={ref}\n {...rest}\n />\n ),\n);\nValidationMessage.displayName = \"ValidationMessage\";\n","import * as React from \"react\";\nimport { useCallback, useEffect, useState, version } from \"react\";\nimport type { ReactNode } from \"react\";\n\n/**\n * Merges an array of refs into a single memoized callback ref or `null`.\n * @see https://floating-ui.com/docs/useMergeRefs\n */\nexport function useMergeRefs<Instance>(\n refs: (React.Ref<Instance> | undefined)[],\n): React.RefCallback<Instance> | null {\n return React.useMemo(() => {\n if (refs.every((ref) => ref === null)) {\n return null;\n }\n\n return (value) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref !== null) {\n (ref as React.MutableRefObject<Instance | null>).current = value;\n }\n });\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, refs);\n}\n\nexport function useResize<Instance extends HTMLElement>(\n ref: React.RefObject<Instance> | undefined | null,\n): { width: number; height: number } {\n const [width, setWidth] = useState<number>(0);\n const [height, setHeight] = useState<number>(0);\n const handleResize = useCallback(() => {\n if (ref?.current !== null) {\n setWidth(ref?.current?.offsetWidth ?? 0);\n setHeight(ref?.current?.offsetHeight ?? 0);\n }\n }, [ref]);\n useEffect(() => {\n window.addEventListener(\"load\", handleResize);\n window.addEventListener(\"resize\", handleResize);\n return () => {\n window.removeEventListener(\"load\", handleResize);\n window.removeEventListener(\"resize\", handleResize);\n };\n }, [ref, handleResize]);\n useEffect(() => {\n handleResize();\n // eslint-disable-next-line react-hooks/exhaustive-deps -- It's ok\n }, []);\n return { width, height };\n}\n\nfunction subscribe() {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- It's ok\n return () => {};\n}\n\nexport function useHydrated() {\n return React.useSyncExternalStore(\n subscribe,\n () => true,\n () => false,\n );\n}\n\nexport function getValidationMessageValue(\n validationMessage?: ReactNode | { value: ReactNode },\n errorMessage?: ReactNode,\n): ReactNode {\n if (validationMessage) {\n if (typeof validationMessage === \"object\" && \"value\" in validationMessage) {\n return validationMessage.value;\n }\n\n return validationMessage;\n }\n\n return errorMessage;\n}\n\n/**\n * Trap focus inside an element using the `inert` attribute.\n *\n * Adds `inert` to all siblings of the given element, and all their ancestors up to the body.\n * Returns a cleanup function which removes the `inert` property from the elements, effectively giving focus back to rest of the document.\n *\n * NOTE: Does not support portals, i.e. elements outside the DOM hierarchy of the given element.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/inert\n * @see https://web.dev/articles/inert\n */\nexport function focusTrap(element: HTMLElement) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- NOP on focus trapping the body element\n if (element === document.body) return () => {};\n\n let inertElements: HTMLElement[] = [];\n for (let el: HTMLElement | null = element; el; el = el.parentElement) {\n if (el === document.body) break;\n\n for (const sibling of el.parentElement?.children ?? []) {\n if (sibling === el) continue;\n if (!(sibling instanceof HTMLElement)) continue;\n if (sibling.hasAttribute(\"inert\")) continue;\n\n sibling.setAttribute(\"inert\", \"true\");\n inertElements.push(sibling);\n }\n }\n\n return () => {\n releaseFocusTrap(inertElements);\n inertElements = [];\n };\n}\n\n/**\n * Unset the `inert` attribute on all elements given\n */\nfunction releaseFocusTrap(inertElements: Iterable<HTMLElement>) {\n for (const el of inertElements) {\n el.removeAttribute(\"inert\");\n }\n}\n\n/**\n * React 19 supports inert prop\n * React 18 needs inert to be a string\n */\nconst inertBooleanSupported: boolean = Number(version.split(\".\")[0]) >= 19;\n\n/**\n * Returns the inert prop value based on the React version.\n */\nexport const inertPropValue: (x: boolean) => boolean | \"\" | undefined = inertBooleanSupported\n ? (x: boolean): boolean => x\n : (x: boolean): \"\" | undefined => (x ? \"\" : undefined);\n","import { forwardRef, type HTMLAttributes } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\n\n/**\n * FieldsetLegend component, used to display a legend for a fieldset.\n *\n * @example\n * <FieldsetLegend>Skriv inn dine svar</FieldsetLegend>\n */\nexport const FieldsetLegend = forwardRef<HTMLLegendElement, HTMLAttributes<HTMLLegendElement>>(\n function FieldsetLegend({ className, ...rest }, ref) {\n return (\n <legend\n className={clsx(\"hds-fieldset__legend\", className as undefined)}\n ref={ref}\n {...rest}\n />\n );\n },\n);\n\nFieldsetLegend.displayName = \"Fieldset.Legend\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,gBAAqE;AACrE,IAAAC,0BAAqB;;;ACDrB,IAAAC,gBAOO;;;ACPP,mBAAgD;AAcrC;AAFJ,IAAM,0BAAsB;AAAA,EACjC,SAASC,qBAAoB,MAAM,KAAK;AACtC,WAAO,4CAAC,sBAAE,WAAU,6BAA4B,OAAc,KAAM;AAAA,EACtE;AACF;;;AChBA,IAAAC,gBAQO;AAQP,IAAAC,0BAAqB;;;AChBrB,6BAAqB;AACrB,IAAAC,gBAAgD;AAQ5C,IAAAC,sBAAA;AAFG,IAAM,wBAAoB;AAAA,EAC/B,CAAC,IAAwB,QAAK;AAA7B,iBAAE,YARL,IAQG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AFL;AAAA,gBAGC,SAAS,UAAU,EAAE,SAAS,eAAe,MAAM,CAAC;AAAA,gBACpD;AAAA,gBACA;AAAA,gBACA,MAAK;AAAA;AAAA,YACP;AAAA,YACA,6CAAC,UAAK,eAAW,MAAC,WAAU,+BAA8B;AAAA,YACzD,QAAQ,6CAAC,OAAE,WAAU,2BAA2B,iBAAM,IAAO;AAAA,aAChE;AAAA,UACC,QAAQ,WAAW;AAAA;AAAA;AAAA,IACtB;AAAA,EAEJ;AACF;AAEA,YAAY,cAAc;","names":["import_react","import_typed_classname","import_react","FieldsetDescription","import_react","import_typed_classname","import_react","import_jsx_runtime","import_react","import_react","import_typed_classname","import_jsx_runtime","FieldsetLegend","import_jsx_runtime","Fieldset","import_jsx_runtime","RadioGroup","import_jsx_runtime","_a"]}
@@ -1,19 +1,19 @@
1
1
  import "../../chunk-XAFNJELJ.mjs";
2
2
  import {
3
3
  RadioButton
4
- } from "../../chunk-54HLJVAF.mjs";
4
+ } from "../../chunk-DOW6EHBI.mjs";
5
5
  import {
6
6
  RadioGroup,
7
7
  useRadioGroupContext
8
- } from "../../chunk-OHPDYPZ5.mjs";
8
+ } from "../../chunk-QER35NXN.mjs";
9
9
  import "../../chunk-CSIXGT7P.mjs";
10
- import "../../chunk-4K54KSRB.mjs";
10
+ import "../../chunk-QOIBRXYT.mjs";
11
11
  import "../../chunk-D2XZT2RA.mjs";
12
12
  import "../../chunk-CD4LCDK3.mjs";
13
13
  import "../../chunk-NSLSA7F7.mjs";
14
- import "../../chunk-77UAHNU6.mjs";
14
+ import "../../chunk-VNH7CZJ4.mjs";
15
15
  import "../../chunk-5M6MEYM7.mjs";
16
- import "../../chunk-7REW23LO.mjs";
16
+ import "../../chunk-F23MNQCK.mjs";
17
17
  import "../../chunk-CYDWEPFL.mjs";
18
18
  import "../../chunk-KPNAC2WN.mjs";
19
19
  import "../../chunk-3V4GFS46.mjs";
@@ -87,17 +87,14 @@ var import_react2 = require("react");
87
87
  var import_jsx_runtime2 = require("react/jsx-runtime");
88
88
  var ValidationMessage = (0, import_react2.forwardRef)(
89
89
  (_a, ref) => {
90
- var _b = _a, { children, id, className } = _b, rest = __objRest(_b, ["children", "id", "className"]);
90
+ var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
91
91
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
92
92
  "div",
93
- __spreadProps(__spreadValues({
93
+ __spreadValues({
94
94
  "aria-live": "polite",
95
95
  className: (0, import_typed_classname.clsx)("hds-validation-message", className),
96
- id,
97
96
  ref
98
- }, rest), {
99
- children
100
- })
97
+ }, rest)
101
98
  );
102
99
  }
103
100
  );