@postenbring/hedwig-react 0.0.0-validation-message-2-20260629115009 → 0.0.0-validation-message-2-20260629124635

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 (76) hide show
  1. package/dist/{chunk-QFCNFKRO.mjs → chunk-4K54KSRB.mjs} +46 -21
  2. package/dist/chunk-4K54KSRB.mjs.map +1 -0
  3. package/dist/{chunk-4PJO4J5D.mjs → chunk-54HLJVAF.mjs} +5 -4
  4. package/dist/chunk-54HLJVAF.mjs.map +1 -0
  5. package/dist/{chunk-5UIJC6LJ.mjs → chunk-BUFV457A.mjs} +6 -5
  6. package/dist/chunk-BUFV457A.mjs.map +1 -0
  7. package/dist/chunk-CD4LCDK3.mjs +27 -0
  8. package/dist/chunk-CD4LCDK3.mjs.map +1 -0
  9. package/dist/chunk-CSIXGT7P.mjs +1 -0
  10. package/dist/chunk-D2XZT2RA.mjs +17 -0
  11. package/dist/chunk-D2XZT2RA.mjs.map +1 -0
  12. package/dist/{chunk-3P2CW67R.mjs → chunk-OHPDYPZ5.mjs} +14 -5
  13. package/dist/chunk-OHPDYPZ5.mjs.map +1 -0
  14. package/dist/form/checkbox/checkbox.d.ts.map +1 -1
  15. package/dist/form/checkbox/checkbox.js +83 -44
  16. package/dist/form/checkbox/checkbox.js.map +1 -1
  17. package/dist/form/checkbox/checkbox.mjs +5 -3
  18. package/dist/form/checkbox/index.js +83 -44
  19. package/dist/form/checkbox/index.js.map +1 -1
  20. package/dist/form/checkbox/index.mjs +5 -3
  21. package/dist/form/fieldset/fieldset-description.d.ts +12 -0
  22. package/dist/form/fieldset/fieldset-description.d.ts.map +1 -0
  23. package/dist/form/fieldset/fieldset-description.js +51 -0
  24. package/dist/form/fieldset/fieldset-description.js.map +1 -0
  25. package/dist/form/fieldset/fieldset-description.mjs +8 -0
  26. package/dist/form/fieldset/fieldset-description.mjs.map +1 -0
  27. package/dist/form/fieldset/fieldset-legend.d.ts +9 -0
  28. package/dist/form/fieldset/fieldset-legend.d.ts.map +1 -0
  29. package/dist/form/fieldset/fieldset-legend.js +72 -0
  30. package/dist/form/fieldset/fieldset-legend.js.map +1 -0
  31. package/dist/form/fieldset/fieldset-legend.mjs +8 -0
  32. package/dist/form/fieldset/fieldset-legend.mjs.map +1 -0
  33. package/dist/form/fieldset/fieldset.d.ts +21 -6
  34. package/dist/form/fieldset/fieldset.d.ts.map +1 -1
  35. package/dist/form/fieldset/fieldset.js +65 -27
  36. package/dist/form/fieldset/fieldset.js.map +1 -1
  37. package/dist/form/fieldset/fieldset.mjs +3 -1
  38. package/dist/form/fieldset/index.d.ts +2 -0
  39. package/dist/form/fieldset/index.d.ts.map +1 -1
  40. package/dist/form/fieldset/index.js +69 -27
  41. package/dist/form/fieldset/index.js.map +1 -1
  42. package/dist/form/fieldset/index.mjs +10 -2
  43. package/dist/form/index.js +210 -163
  44. package/dist/form/index.js.map +1 -1
  45. package/dist/form/index.mjs +26 -18
  46. package/dist/form/radio-button/index.js +94 -52
  47. package/dist/form/radio-button/index.js.map +1 -1
  48. package/dist/form/radio-button/index.mjs +6 -4
  49. package/dist/form/radio-button/radio-button.d.ts.map +1 -1
  50. package/dist/form/radio-button/radio-button.js +94 -52
  51. package/dist/form/radio-button/radio-button.js.map +1 -1
  52. package/dist/form/radio-button/radio-button.mjs +6 -4
  53. package/dist/form/radio-button/radio-group.d.ts +11 -6
  54. package/dist/form/radio-button/radio-group.d.ts.map +1 -1
  55. package/dist/form/radio-button/radio-group.js +81 -40
  56. package/dist/form/radio-button/radio-group.js.map +1 -1
  57. package/dist/form/radio-button/radio-group.mjs +5 -3
  58. package/dist/index.js +438 -389
  59. package/dist/index.js.map +1 -1
  60. package/dist/index.mjs +29 -21
  61. package/dist/layout/index.mjs +3 -3
  62. package/package.json +4 -4
  63. package/src/form/checkbox/checkbox.tsx +4 -3
  64. package/src/form/fieldset/fieldset-description.tsx +17 -0
  65. package/src/form/fieldset/fieldset-legend.tsx +22 -0
  66. package/src/form/fieldset/fieldset.stories.tsx +2 -1
  67. package/src/form/fieldset/fieldset.tsx +71 -21
  68. package/src/form/fieldset/index.tsx +2 -0
  69. package/src/form/radio-button/radio-button.tsx +5 -4
  70. package/src/form/radio-button/radio-group.tsx +19 -8
  71. package/dist/chunk-3P2CW67R.mjs.map +0 -1
  72. package/dist/chunk-4PJO4J5D.mjs.map +0 -1
  73. package/dist/chunk-5UIJC6LJ.mjs.map +0 -1
  74. package/dist/chunk-LMF3QGSF.mjs +0 -1
  75. package/dist/chunk-QFCNFKRO.mjs.map +0 -1
  76. /package/dist/{chunk-LMF3QGSF.mjs.map → chunk-CSIXGT7P.mjs.map} +0 -0
@@ -1,3 +1,9 @@
1
+ import {
2
+ FieldsetDescription
3
+ } from "./chunk-D2XZT2RA.mjs";
4
+ import {
5
+ FieldsetLegend
6
+ } from "./chunk-CD4LCDK3.mjs";
1
7
  import {
2
8
  ValidationMessage
3
9
  } from "./chunk-7REW23LO.mjs";
@@ -11,10 +17,21 @@ import {
11
17
  } from "./chunk-YOSPWY5K.mjs";
12
18
 
13
19
  // src/form/fieldset/fieldset.tsx
14
- import { useId, forwardRef, createContext, useContext } from "react";
20
+ import {
21
+ Children,
22
+ cloneElement,
23
+ isValidElement,
24
+ useId,
25
+ forwardRef,
26
+ createContext,
27
+ useContext
28
+ } from "react";
15
29
  import { clsx } from "@postenbring/hedwig-css/typed-classname";
16
30
  import { jsx, jsxs } from "react/jsx-runtime";
17
- var FieldsetContext = createContext({ hasError: false });
31
+ var FieldsetContext = createContext({
32
+ hasError: false,
33
+ size: ""
34
+ });
18
35
  var useFieldsetContext = () => useContext(FieldsetContext);
19
36
  var Fieldset = forwardRef(function Fieldset2(_a, ref) {
20
37
  var _b = _a, {
@@ -25,11 +42,11 @@ var Fieldset = forwardRef(function Fieldset2(_a, ref) {
25
42
  validationMessageProps,
26
43
  errorMessage,
27
44
  errorMessageProps,
28
- legendProps: _c = {}
29
- } = _b, _d = _c, { size: legendSize = "default", className: legendClassName } = _d, legendProps = __objRest(_d, ["size", "className"]), _e = _b, {
45
+ legendProps,
30
46
  legend,
47
+ size = "",
31
48
  children
32
- } = _e, rest = __objRest(_e, [
49
+ } = _b, rest = __objRest(_b, [
33
50
  "className",
34
51
  "style",
35
52
  "data-color",
@@ -39,35 +56,41 @@ var Fieldset = forwardRef(function Fieldset2(_a, ref) {
39
56
  "errorMessageProps",
40
57
  "legendProps",
41
58
  "legend",
59
+ "size",
42
60
  "children"
43
61
  ]);
44
62
  const validationMessageId = useId();
45
63
  const validationColor = errorMessage ? "error" : dataColor;
46
64
  const validationMessageValue = getValidationMessageValue(validationMessage, errorMessage);
65
+ const childArray = Children.toArray(children);
66
+ const legendChild = childArray.find(
67
+ (child) => isValidElement(child) && child.type === FieldsetLegend
68
+ );
69
+ const contentChildren = legendChild ? childArray.filter((child) => child !== legendChild) : childArray;
70
+ let renderedLegend = null;
71
+ if (legendChild) {
72
+ renderedLegend = cloneElement(legendChild, __spreadProps(__spreadValues(__spreadValues({}, legendProps), legendChild.props), {
73
+ className: clsx(
74
+ legendProps == null ? void 0 : legendProps.className,
75
+ legendChild.props.className
76
+ )
77
+ }));
78
+ } else if (legend !== void 0) {
79
+ renderedLegend = /* @__PURE__ */ jsx(FieldsetLegend, __spreadProps(__spreadValues({}, legendProps), { children: legend }));
80
+ }
47
81
  return /* @__PURE__ */ jsxs(
48
82
  "fieldset",
49
83
  __spreadProps(__spreadValues({
50
- "aria-describedby": validationMessage ? validationMessageId : void 0,
84
+ "aria-describedby": validationMessageValue ? validationMessageId : void 0,
51
85
  "aria-invalid": errorMessage ? true : void 0,
52
- className: clsx("hds-fieldset", className),
86
+ className: clsx("hds-fieldset", { [`hds-fieldset--${size}`]: size }, className),
53
87
  "data-color": validationColor,
54
88
  ref,
55
89
  style
56
90
  }, rest), {
57
91
  children: [
58
- /* @__PURE__ */ jsx(
59
- "legend",
60
- __spreadProps(__spreadValues({
61
- className: clsx(
62
- "hds-fieldset__legend",
63
- { [`hds-fieldset__legend--${legendSize}`]: legendSize },
64
- legendClassName
65
- )
66
- }, legendProps), {
67
- children: legend
68
- })
69
- ),
70
- /* @__PURE__ */ jsx(FieldsetContext.Provider, { value: { hasError: Boolean(errorMessage) }, children }),
92
+ renderedLegend,
93
+ /* @__PURE__ */ jsx(FieldsetContext.Provider, { value: { hasError: Boolean(errorMessage), size }, children: contentChildren }),
71
94
  /* @__PURE__ */ jsx(
72
95
  ValidationMessage,
73
96
  __spreadProps(__spreadValues({
@@ -80,9 +103,11 @@ var Fieldset = forwardRef(function Fieldset2(_a, ref) {
80
103
  })
81
104
  );
82
105
  });
106
+ Fieldset.Description = FieldsetDescription;
107
+ Fieldset.Legend = FieldsetLegend;
83
108
 
84
109
  export {
85
110
  useFieldsetContext,
86
111
  Fieldset
87
112
  };
88
- //# sourceMappingURL=chunk-QFCNFKRO.mjs.map
113
+ //# sourceMappingURL=chunk-4K54KSRB.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/form/fieldset/fieldset.tsx"],"sourcesContent":["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"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAQP,SAAS,YAAY;AAuFA,cAIjB,YAJiB;AAhDrB,IAAM,kBAAkB,cAAyD;AAAA,EAC/E,UAAU;AAAA,EACV,MAAM;AACR,CAAC;AAGM,IAAM,qBAAqB,MAAM,WAAW,eAAe;AAE3D,IAAM,WAAW,WAA+C,SAASA,UAC9E,IAcA,KACA;AAfA,eACE;AAAA;AAAA,IACA;AAAA,IACA,cAAc,YAAY;AAAA,IAC1B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP;AAAA,EA3EJ,IAgEE,IAYK,iBAZL,IAYK;AAAA,IAXH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAKF,QAAM,sBAAsB,MAAM;AAClC,QAAM,kBAAkB,eAAe,UAAU;AACjD,QAAM,yBAAyB,0BAA0B,mBAAmB,YAAY;AACxF,QAAM,aAAa,SAAS,QAAQ,QAAQ;AAC5C,QAAM,cAAc,WAAW;AAAA,IAC7B,CAAC,UACC,eAAoC,KAAK,KAAK,MAAM,SAAS;AAAA,EACjE;AACA,QAAM,kBAAkB,cACpB,WAAW,OAAO,CAAC,UAAU,UAAU,WAAW,IAClD;AACJ,MAAI,iBAAiB;AAErB,MAAI,aAAa;AACf,qBAAiB,aAAa,aAAa,gDACtC,cACA,YAAY,QAF0B;AAAA,MAGzC,WAAW;AAAA,QACT,2CAAa;AAAA,QACb,YAAY,MAAM;AAAA,MACpB;AAAA,IACF,EAAC;AAAA,EACH,WAAW,WAAW,QAAW;AAC/B,qBAAiB,oBAAC,iDAAmB,cAAnB,EAAiC,mBAAO;AAAA,EAC5D;AAEA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,oBAAkB,yBAAyB,sBAAsB;AAAA,MACjE,gBAAc,eAAe,OAAO;AAAA,MACpC,WAAW,KAAK,gBAAgB,EAAE,CAAC,iBAAiB,IAAI,EAAE,GAAG,KAAK,GAAG,SAAsB;AAAA,MAC3F,cAAY;AAAA,MACZ;AAAA,MACA;AAAA,OACI,OAPL;AAAA,MASE;AAAA;AAAA,QACD,oBAAC,gBAAgB,UAAhB,EAAyB,OAAO,EAAE,UAAU,QAAQ,YAAY,GAAG,KAAK,GACtE,2BACH;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,IAAI;AAAA,aACC,0DAA0B,oBAFhC;AAAA,YAIE;AAAA;AAAA,QACH;AAAA;AAAA;AAAA,EACF;AAEJ,CAAC;AAOD,SAAS,cAAc;AACvB,SAAS,SAAS;","names":["Fieldset"]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useRadioGroupContext
3
- } from "./chunk-3P2CW67R.mjs";
3
+ } from "./chunk-OHPDYPZ5.mjs";
4
4
  import {
5
5
  __objRest,
6
6
  __spreadProps,
@@ -23,7 +23,8 @@ var isChecked = ({
23
23
  var RadioButton = forwardRef(
24
24
  (_a, ref) => {
25
25
  var _b = _a, { checked, value, variant = "plain", title, children, className, size = "" } = _b, rest = __objRest(_b, ["checked", "value", "variant", "title", "children", "className", "size"]);
26
- const _a2 = useRadioGroupContext(), { value: selectedValue } = _a2, context = __objRest(_a2, ["value"]);
26
+ const _a2 = useRadioGroupContext(), { value: selectedValue, size: groupSize } = _a2, context = __objRest(_a2, ["value", "size"]);
27
+ const effectiveSize = size || groupSize;
27
28
  return /* @__PURE__ */ jsxs(
28
29
  "div",
29
30
  {
@@ -31,7 +32,7 @@ var RadioButton = forwardRef(
31
32
  "hds-radio-button",
32
33
  {
33
34
  [`hds-radio-button--${variant}`]: variant === "bounding-box",
34
- [`hds-radio-button--${size}`]: size
35
+ [`hds-radio-button--${effectiveSize}`]: effectiveSize === "small"
35
36
  },
36
37
  className
37
38
  ),
@@ -60,4 +61,4 @@ RadioButton.displayName = "RadioButton";
60
61
  export {
61
62
  RadioButton
62
63
  };
63
- //# sourceMappingURL=chunk-4PJO4J5D.mjs.map
64
+ //# sourceMappingURL=chunk-54HLJVAF.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/form/radio-button/radio-button.tsx"],"sourcesContent":["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"],"mappings":";;;;;;;;;;AAAA,SAAS,kBAA4D;AACrE,SAAS,YAAY;AAuCb,SACE,KADF;AA5BR,IAAM,YAAY,CAAC;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AACF,MAEM;AACJ,MAAI,OAAO,YAAY,YAAa,QAAO;AAC3C,MAAI,OAAO,kBAAkB,YAAa,QAAO,UAAU;AAC3D,SAAO;AACT;AAEO,IAAM,cAAc;AAAA,EACzB,CAAC,IAAuF,QAAQ;AAA/F,iBAAE,WAAS,OAAO,UAAU,SAAS,OAAO,UAAU,WAAW,OAAO,GAzB3E,IAyBG,IAA+E,iBAA/E,IAA+E,CAA7E,WAAS,SAAO,WAAmB,SAAO,YAAU,aAAW;AAChE,UAA8DA,MAAA,qBAAqB,GAA3E,SAAO,eAAe,MAAM,UA1BxC,IA0BkEA,KAAZ,oBAAYA,KAAZ,CAA1C,SAAsB;AAC9B,UAAM,gBAAgB,QAAQ;AAE9B,WACE;AAAA,MAAC;AAAA;AAAA,QACC,WAAW;AAAA,UACT;AAAA,UACA;AAAA,YACE,CAAC,qBAAqB,OAAO,EAAE,GAAG,YAAY;AAAA,YAC9C,CAAC,qBAAqB,aAAa,EAAE,GAAG,kBAAkB;AAAA,UAC5D;AAAA,UACA;AAAA,QACF;AAAA,QAEA;AAAA,+BAAC,WACC;AAAA;AAAA,cAAC;AAAA,8DACK,UACA,OAFL;AAAA,gBAGC,SAAS,UAAU,EAAE,SAAS,eAAe,MAAM,CAAC;AAAA,gBACpD;AAAA,gBACA;AAAA,gBACA,MAAK;AAAA;AAAA,YACP;AAAA,YACA,oBAAC,UAAK,eAAW,MAAC,WAAU,+BAA8B;AAAA,YACzD,QAAQ,oBAAC,OAAE,WAAU,2BAA2B,iBAAM,IAAO;AAAA,aAChE;AAAA,UACC,QAAQ,WAAW;AAAA;AAAA;AAAA,IACtB;AAAA,EAEJ;AACF;AAEA,YAAY,cAAc;","names":["_a"]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useFieldsetContext
3
- } from "./chunk-QFCNFKRO.mjs";
3
+ } from "./chunk-4K54KSRB.mjs";
4
4
  import {
5
5
  ValidationMessage
6
6
  } from "./chunk-7REW23LO.mjs";
@@ -43,14 +43,15 @@ var Checkbox = forwardRef(
43
43
  "size"
44
44
  ]);
45
45
  const validationMessageId = useId();
46
- const { hasError: hasFieldsetError } = useFieldsetContext();
46
+ const { hasError: hasFieldsetError, size: fieldsetSize } = useFieldsetContext();
47
47
  const hasError = !!errorMessage || hasFieldsetError || hasErrorProp;
48
+ const effectiveSize = size || fieldsetSize;
48
49
  const validationMessageValue = getValidationMessageValue(validationMessage, errorMessage);
49
50
  return /* @__PURE__ */ jsxs(
50
51
  "div",
51
52
  {
52
53
  className: clsx("hds-checkbox-wrapper", {
53
- "hds-checkbox-wrapper--small": size === "small"
54
+ "hds-checkbox-wrapper--small": effectiveSize === "small"
54
55
  }),
55
56
  children: [
56
57
  /* @__PURE__ */ jsxs(
@@ -69,7 +70,7 @@ var Checkbox = forwardRef(
69
70
  "input",
70
71
  __spreadValues({
71
72
  "aria-invalid": hasError ? true : void 0,
72
- "aria-describedby": validationMessage ? validationMessageId : void 0,
73
+ "aria-describedby": validationMessageValue ? validationMessageId : void 0,
73
74
  ref,
74
75
  type: "checkbox"
75
76
  }, rest)
@@ -99,4 +100,4 @@ Checkbox.displayName = "Checkbox";
99
100
  export {
100
101
  Checkbox
101
102
  };
102
- //# sourceMappingURL=chunk-5UIJC6LJ.mjs.map
103
+ //# sourceMappingURL=chunk-BUFV457A.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/form/checkbox/checkbox.tsx"],"sourcesContent":["import { forwardRef, useId, type InputHTMLAttributes, type ReactNode } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { ValidationMessage, type ValidationMessageProps } from \"../validation-message\";\nimport { type ErrorMessageProps } from \"../error-message\";\nimport { useFieldsetContext } from \"../fieldset\";\nimport { getValidationMessageValue } from \"../../utils\";\n\nexport type CheckboxProps = Omit<InputHTMLAttributes<HTMLInputElement>, \"defaultValue\" | \"size\"> & {\n children: ReactNode;\n variant?: \"plain\" | \"bounding-box\";\n title?: string;\n validationMessage?: ReactNode | { value: ReactNode };\n validationMessageProps?: Partial<ValidationMessageProps>;\n /** @deprecated Use `validationMessageProps` instead */\n errorMessageProps?: Partial<ErrorMessageProps>;\n size?: \"small\" | \"\";\n} & (\n | {\n /**\n * Set to `true` to add error styling. The component will take care of aria to indicate invalid state.\n *\n * Normally you don't need this, as you should wrap your Checkboxes in the Fieldset component.\n * When providing an errorMessage to Fieldset, all contained Checkboxes will get correct hasError state.\n *\n * You can use this when your checkbox is part of a non-HDS fieldset which shows an error message.\n */\n hasError?: boolean;\n //validationMessage?: never;\n /** @deprecated Use `validationMessage` instead */\n errorMessage?: never;\n }\n | {\n hasError?: never;\n /**\n * Set an error message to add error styling, and display the error message.\n * The component will take care of aria to connect the error message to the checkbox.\n *\n * Use this when your checkbox is standalone (not part of a fieldset).\n */\n //validationMessage?: ReactNode;\n /** @deprecated Use `validationMessage` instead */\n errorMessage?: ReactNode;\n }\n );\n\nexport const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(\n (\n {\n variant = \"plain\",\n hasError: hasErrorProp,\n validationMessage,\n validationMessageProps,\n errorMessage,\n errorMessageProps,\n title,\n children,\n className,\n size = \"\",\n ...rest\n },\n ref,\n ) => {\n const validationMessageId = useId();\n const { hasError: hasFieldsetError, size: fieldsetSize } = useFieldsetContext();\n const hasError = !!errorMessage || hasFieldsetError || hasErrorProp;\n const effectiveSize = size || fieldsetSize;\n const validationMessageValue = getValidationMessageValue(validationMessage, errorMessage);\n\n return (\n <div\n className={clsx(\"hds-checkbox-wrapper\", {\n \"hds-checkbox-wrapper--small\": effectiveSize === \"small\",\n })}\n >\n <div\n className={clsx(\n \"hds-checkbox\",\n {\n [`hds-checkbox--${variant}`]: variant === \"bounding-box\",\n },\n className as undefined,\n )}\n >\n <label>\n <input\n aria-invalid={hasError ? true : undefined}\n aria-describedby={validationMessageValue ? validationMessageId : undefined}\n ref={ref}\n type=\"checkbox\"\n {...rest}\n />\n <span aria-hidden className=\"hds-checkbox__checkmark\" />\n {title ? <p className=\"hds-checkbox__title\">{title}</p> : children}\n </label>\n {title ? children : null}\n </div>\n <ValidationMessage\n id={validationMessageId}\n {...(validationMessageProps ?? errorMessageProps)}\n >\n {validationMessageValue}\n </ValidationMessage>\n </div>\n );\n },\n);\nCheckbox.displayName = \"Checkbox\";\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,SAAS,YAAY,aAAuD;AAC5E,SAAS,YAAY;AAkFX,SACE,KADF;AAtCH,IAAM,WAAW;AAAA,EACtB,CACE,IAaA,QACG;AAdH,iBACE;AAAA,gBAAU;AAAA,MACV,UAAU;AAAA,MACV;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,OAAO;AAAA,IAzDb,IA+CI,IAWK,iBAXL,IAWK;AAAA,MAVH;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAKF,UAAM,sBAAsB,MAAM;AAClC,UAAM,EAAE,UAAU,kBAAkB,MAAM,aAAa,IAAI,mBAAmB;AAC9E,UAAM,WAAW,CAAC,CAAC,gBAAgB,oBAAoB;AACvD,UAAM,gBAAgB,QAAQ;AAC9B,UAAM,yBAAyB,0BAA0B,mBAAmB,YAAY;AAExF,WACE;AAAA,MAAC;AAAA;AAAA,QACC,WAAW,KAAK,wBAAwB;AAAA,UACtC,+BAA+B,kBAAkB;AAAA,QACnD,CAAC;AAAA,QAED;AAAA;AAAA,YAAC;AAAA;AAAA,cACC,WAAW;AAAA,gBACT;AAAA,gBACA;AAAA,kBACE,CAAC,iBAAiB,OAAO,EAAE,GAAG,YAAY;AAAA,gBAC5C;AAAA,gBACA;AAAA,cACF;AAAA,cAEA;AAAA,qCAAC,WACC;AAAA;AAAA,oBAAC;AAAA;AAAA,sBACC,gBAAc,WAAW,OAAO;AAAA,sBAChC,oBAAkB,yBAAyB,sBAAsB;AAAA,sBACjE;AAAA,sBACA,MAAK;AAAA,uBACD;AAAA,kBACN;AAAA,kBACA,oBAAC,UAAK,eAAW,MAAC,WAAU,2BAA0B;AAAA,kBACrD,QAAQ,oBAAC,OAAE,WAAU,uBAAuB,iBAAM,IAAO;AAAA,mBAC5D;AAAA,gBACC,QAAQ,WAAW;AAAA;AAAA;AAAA,UACtB;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACC,IAAI;AAAA,eACC,0DAA0B,oBAFhC;AAAA,cAIE;AAAA;AAAA,UACH;AAAA;AAAA;AAAA,IACF;AAAA,EAEJ;AACF;AACA,SAAS,cAAc;","names":[]}
@@ -0,0 +1,27 @@
1
+ import {
2
+ __objRest,
3
+ __spreadValues
4
+ } from "./chunk-YOSPWY5K.mjs";
5
+
6
+ // src/form/fieldset/fieldset-legend.tsx
7
+ import { forwardRef } from "react";
8
+ import { clsx } from "@postenbring/hedwig-css/typed-classname";
9
+ import { jsx } from "react/jsx-runtime";
10
+ var FieldsetLegend = forwardRef(
11
+ function FieldsetLegend2(_a, ref) {
12
+ var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
13
+ return /* @__PURE__ */ jsx(
14
+ "legend",
15
+ __spreadValues({
16
+ className: clsx("hds-fieldset__legend", className),
17
+ ref
18
+ }, rest)
19
+ );
20
+ }
21
+ );
22
+ FieldsetLegend.displayName = "Fieldset.Legend";
23
+
24
+ export {
25
+ FieldsetLegend
26
+ };
27
+ //# sourceMappingURL=chunk-CD4LCDK3.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/form/fieldset/fieldset-legend.tsx"],"sourcesContent":["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,SAAS,kBAAuC;AAChD,SAAS,YAAY;AAWf;AAHC,IAAM,iBAAiB;AAAA,EAC5B,SAASA,gBAAe,IAAwB,KAAK;AAA7B,iBAAE,YAV5B,IAU0B,IAAgB,iBAAhB,IAAgB,CAAd;AACxB,WACE;AAAA,MAAC;AAAA;AAAA,QACC,WAAW,KAAK,wBAAwB,SAAsB;AAAA,QAC9D;AAAA,SACI;AAAA,IACN;AAAA,EAEJ;AACF;AAEA,eAAe,cAAc;","names":["FieldsetLegend"]}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=chunk-CSIXGT7P.mjs.map
@@ -0,0 +1,17 @@
1
+ import {
2
+ __spreadValues
3
+ } from "./chunk-YOSPWY5K.mjs";
4
+
5
+ // src/form/fieldset/fieldset-description.tsx
6
+ import { forwardRef } from "react";
7
+ import { jsx } from "react/jsx-runtime";
8
+ var FieldsetDescription = forwardRef(
9
+ function FieldsetDescription2(rest, ref) {
10
+ return /* @__PURE__ */ jsx("p", __spreadValues({ className: "hds-fieldset__description", ref }, rest));
11
+ }
12
+ );
13
+
14
+ export {
15
+ FieldsetDescription
16
+ };
17
+ //# sourceMappingURL=chunk-D2XZT2RA.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/form/fieldset/fieldset-description.tsx"],"sourcesContent":["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"],"mappings":";;;;;AAAA,SAAS,kBAAuC;AAcrC;AAFJ,IAAM,sBAAsB;AAAA,EACjC,SAASA,qBAAoB,MAAM,KAAK;AACtC,WAAO,oBAAC,sBAAE,WAAU,6BAA4B,OAAc,KAAM;AAAA,EACtE;AACF;","names":["FieldsetDescription"]}
@@ -1,6 +1,12 @@
1
1
  import {
2
2
  Fieldset
3
- } from "./chunk-QFCNFKRO.mjs";
3
+ } from "./chunk-4K54KSRB.mjs";
4
+ import {
5
+ FieldsetDescription
6
+ } from "./chunk-D2XZT2RA.mjs";
7
+ import {
8
+ FieldsetLegend
9
+ } from "./chunk-CD4LCDK3.mjs";
4
10
  import {
5
11
  __objRest,
6
12
  __spreadProps,
@@ -16,17 +22,20 @@ import {
16
22
  import { jsx } from "react/jsx-runtime";
17
23
  var RadioGroupContext = createContext({
18
24
  name: void 0,
19
- onChange: () => void 0
25
+ onChange: () => void 0,
26
+ size: void 0
20
27
  });
21
28
  var useRadioGroupContext = () => useContext(RadioGroupContext);
22
29
  var RadioGroup = forwardRef(function RadioGroup2(_a, ref) {
23
- var _b = _a, { name, value, onChange, children } = _b, rest = __objRest(_b, ["name", "value", "onChange", "children"]);
24
- return /* @__PURE__ */ jsx(RadioGroupContext.Provider, { value: { name, value, onChange }, children: /* @__PURE__ */ jsx(Fieldset, __spreadProps(__spreadValues({}, rest), { ref, children })) });
30
+ var _b = _a, { name, value, onChange, children, size } = _b, rest = __objRest(_b, ["name", "value", "onChange", "children", "size"]);
31
+ return /* @__PURE__ */ jsx(RadioGroupContext.Provider, { value: { name, value, onChange, size }, children: /* @__PURE__ */ jsx(Fieldset, __spreadProps(__spreadValues({ size }, rest), { ref, children })) });
25
32
  });
33
+ RadioGroup.Description = FieldsetDescription;
34
+ RadioGroup.Legend = FieldsetLegend;
26
35
  RadioGroup.displayName = "RadioGroup";
27
36
 
28
37
  export {
29
38
  useRadioGroupContext,
30
39
  RadioGroup
31
40
  };
32
- //# sourceMappingURL=chunk-3P2CW67R.mjs.map
41
+ //# sourceMappingURL=chunk-OHPDYPZ5.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/form/radio-button/radio-group.tsx"],"sourcesContent":["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"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA,EAEE;AAAA,EACA;AAAA,EAGA;AAAA,OACK;AA+BD;AAdN,IAAM,oBAAoB,cAAsC;AAAA,EAC9D,MAAM;AAAA,EACN,UAAU,MAAM;AAAA,EAChB,MAAM;AACR,CAAC;AAEM,IAAM,uBAAuB,MAAM,WAAW,iBAAiB;AAE/D,IAAM,aAAa,WAAiD,SAASA,YAClF,IACA,KACA;AAFA,eAAE,QAAM,OAAO,UAAU,UAAU,KAjCrC,IAiCE,IAA4C,iBAA5C,IAA4C,CAA1C,QAAM,SAAO,YAAU,YAAU;AAGnC,SACE,oBAAC,kBAAkB,UAAlB,EAA2B,OAAO,EAAE,MAAM,OAAO,UAAU,KAAK,GAC/D,8BAAC,yCAAS,QAAgB,OAAzB,EAA+B,KAC7B,WACH,GACF;AAEJ,CAAC;AAOD,WAAW,cAAc;AACzB,WAAW,SAAS;AAEpB,WAAW,cAAc;","names":["RadioGroup"]}
@@ -1 +1 @@
1
- {"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../../src/form/checkbox/checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,mBAAmB,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEpF,OAAO,EAAqB,KAAK,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AACvF,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAI1D,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,cAAc,GAAG,MAAM,CAAC,GAAG;IACjG,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,GAAG,cAAc,CAAC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE,SAAS,GAAG;QAAE,KAAK,EAAE,SAAS,CAAA;KAAE,CAAC;IACrD,sBAAsB,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACzD,uDAAuD;IACvD,iBAAiB,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC/C,IAAI,CAAC,EAAE,OAAO,GAAG,EAAE,CAAC;CACrB,GAAG,CACE;IACE;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,kDAAkD;IAClD,YAAY,CAAC,EAAE,KAAK,CAAC;CACtB,GACD;IACE,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB;;;;;OAKG;IAEH,kDAAkD;IAClD,YAAY,CAAC,EAAE,SAAS,CAAC;CAC1B,CACJ,CAAC;AAEJ,eAAO,MAAM,QAAQ,4GA2DpB,CAAC"}
1
+ {"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../../src/form/checkbox/checkbox.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,mBAAmB,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEpF,OAAO,EAAqB,KAAK,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AACvF,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAI1D,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,cAAc,GAAG,MAAM,CAAC,GAAG;IACjG,QAAQ,EAAE,SAAS,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,GAAG,cAAc,CAAC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE,SAAS,GAAG;QAAE,KAAK,EAAE,SAAS,CAAA;KAAE,CAAC;IACrD,sBAAsB,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACzD,uDAAuD;IACvD,iBAAiB,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC/C,IAAI,CAAC,EAAE,OAAO,GAAG,EAAE,CAAC;CACrB,GAAG,CACE;IACE;;;;;;;OAOG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,kDAAkD;IAClD,YAAY,CAAC,EAAE,KAAK,CAAC;CACtB,GACD;IACE,QAAQ,CAAC,EAAE,KAAK,CAAC;IACjB;;;;;OAKG;IAEH,kDAAkD;IAClD,YAAY,CAAC,EAAE,SAAS,CAAC;CAC1B,CACJ,CAAC;AAEJ,eAAO,MAAM,QAAQ,4GA4DpB,CAAC"}
@@ -62,8 +62,8 @@ __export(checkbox_exports, {
62
62
  Checkbox: () => Checkbox
63
63
  });
64
64
  module.exports = __toCommonJS(checkbox_exports);
65
- var import_react4 = require("react");
66
- var import_typed_classname3 = require("@postenbring/hedwig-css/typed-classname");
65
+ var import_react6 = require("react");
66
+ var import_typed_classname4 = require("@postenbring/hedwig-css/typed-classname");
67
67
 
68
68
  // src/form/validation-message/validation-message.tsx
69
69
  var import_typed_classname = require("@postenbring/hedwig-css/typed-classname");
@@ -88,8 +88,8 @@ var ValidationMessage = (0, import_react.forwardRef)(
88
88
  ValidationMessage.displayName = "ValidationMessage";
89
89
 
90
90
  // src/form/fieldset/fieldset.tsx
91
- var import_react3 = require("react");
92
- var import_typed_classname2 = require("@postenbring/hedwig-css/typed-classname");
91
+ var import_react5 = require("react");
92
+ var import_typed_classname3 = require("@postenbring/hedwig-css/typed-classname");
93
93
 
94
94
  // src/utils/utils.ts
95
95
  var React = __toESM(require("react"));
@@ -105,11 +105,41 @@ function getValidationMessageValue(validationMessage, errorMessage) {
105
105
  }
106
106
  var inertBooleanSupported = Number(import_react2.version.split(".")[0]) >= 19;
107
107
 
108
- // src/form/fieldset/fieldset.tsx
108
+ // src/form/fieldset/fieldset-description.tsx
109
+ var import_react3 = require("react");
109
110
  var import_jsx_runtime2 = require("react/jsx-runtime");
110
- var FieldsetContext = (0, import_react3.createContext)({ hasError: false });
111
- var useFieldsetContext = () => (0, import_react3.useContext)(FieldsetContext);
112
- var Fieldset = (0, import_react3.forwardRef)(function Fieldset2(_a, ref) {
111
+ var FieldsetDescription = (0, import_react3.forwardRef)(
112
+ function FieldsetDescription2(rest, ref) {
113
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", __spreadValues({ className: "hds-fieldset__description", ref }, rest));
114
+ }
115
+ );
116
+
117
+ // src/form/fieldset/fieldset-legend.tsx
118
+ var import_react4 = require("react");
119
+ var import_typed_classname2 = require("@postenbring/hedwig-css/typed-classname");
120
+ var import_jsx_runtime3 = require("react/jsx-runtime");
121
+ var FieldsetLegend = (0, import_react4.forwardRef)(
122
+ function FieldsetLegend2(_a, ref) {
123
+ var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
124
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
125
+ "legend",
126
+ __spreadValues({
127
+ className: (0, import_typed_classname2.clsx)("hds-fieldset__legend", className),
128
+ ref
129
+ }, rest)
130
+ );
131
+ }
132
+ );
133
+ FieldsetLegend.displayName = "Fieldset.Legend";
134
+
135
+ // src/form/fieldset/fieldset.tsx
136
+ var import_jsx_runtime4 = require("react/jsx-runtime");
137
+ var FieldsetContext = (0, import_react5.createContext)({
138
+ hasError: false,
139
+ size: ""
140
+ });
141
+ var useFieldsetContext = () => (0, import_react5.useContext)(FieldsetContext);
142
+ var Fieldset = (0, import_react5.forwardRef)(function Fieldset2(_a, ref) {
113
143
  var _b = _a, {
114
144
  className,
115
145
  style,
@@ -118,11 +148,11 @@ var Fieldset = (0, import_react3.forwardRef)(function Fieldset2(_a, ref) {
118
148
  validationMessageProps,
119
149
  errorMessage,
120
150
  errorMessageProps,
121
- legendProps: _c = {}
122
- } = _b, _d = _c, { size: legendSize = "default", className: legendClassName } = _d, legendProps = __objRest(_d, ["size", "className"]), _e = _b, {
151
+ legendProps,
123
152
  legend,
153
+ size = "",
124
154
  children
125
- } = _e, rest = __objRest(_e, [
155
+ } = _b, rest = __objRest(_b, [
126
156
  "className",
127
157
  "style",
128
158
  "data-color",
@@ -132,36 +162,42 @@ var Fieldset = (0, import_react3.forwardRef)(function Fieldset2(_a, ref) {
132
162
  "errorMessageProps",
133
163
  "legendProps",
134
164
  "legend",
165
+ "size",
135
166
  "children"
136
167
  ]);
137
- const validationMessageId = (0, import_react3.useId)();
168
+ const validationMessageId = (0, import_react5.useId)();
138
169
  const validationColor = errorMessage ? "error" : dataColor;
139
170
  const validationMessageValue = getValidationMessageValue(validationMessage, errorMessage);
140
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
171
+ const childArray = import_react5.Children.toArray(children);
172
+ const legendChild = childArray.find(
173
+ (child) => (0, import_react5.isValidElement)(child) && child.type === FieldsetLegend
174
+ );
175
+ const contentChildren = legendChild ? childArray.filter((child) => child !== legendChild) : childArray;
176
+ let renderedLegend = null;
177
+ if (legendChild) {
178
+ renderedLegend = (0, import_react5.cloneElement)(legendChild, __spreadProps(__spreadValues(__spreadValues({}, legendProps), legendChild.props), {
179
+ className: (0, import_typed_classname3.clsx)(
180
+ legendProps == null ? void 0 : legendProps.className,
181
+ legendChild.props.className
182
+ )
183
+ }));
184
+ } else if (legend !== void 0) {
185
+ renderedLegend = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FieldsetLegend, __spreadProps(__spreadValues({}, legendProps), { children: legend }));
186
+ }
187
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
141
188
  "fieldset",
142
189
  __spreadProps(__spreadValues({
143
- "aria-describedby": validationMessage ? validationMessageId : void 0,
190
+ "aria-describedby": validationMessageValue ? validationMessageId : void 0,
144
191
  "aria-invalid": errorMessage ? true : void 0,
145
- className: (0, import_typed_classname2.clsx)("hds-fieldset", className),
192
+ className: (0, import_typed_classname3.clsx)("hds-fieldset", { [`hds-fieldset--${size}`]: size }, className),
146
193
  "data-color": validationColor,
147
194
  ref,
148
195
  style
149
196
  }, rest), {
150
197
  children: [
151
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
152
- "legend",
153
- __spreadProps(__spreadValues({
154
- className: (0, import_typed_classname2.clsx)(
155
- "hds-fieldset__legend",
156
- { [`hds-fieldset__legend--${legendSize}`]: legendSize },
157
- legendClassName
158
- )
159
- }, legendProps), {
160
- children: legend
161
- })
162
- ),
163
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(FieldsetContext.Provider, { value: { hasError: Boolean(errorMessage) }, children }),
164
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
198
+ renderedLegend,
199
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FieldsetContext.Provider, { value: { hasError: Boolean(errorMessage), size }, children: contentChildren }),
200
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
165
201
  ValidationMessage,
166
202
  __spreadProps(__spreadValues({
167
203
  id: validationMessageId
@@ -173,10 +209,12 @@ var Fieldset = (0, import_react3.forwardRef)(function Fieldset2(_a, ref) {
173
209
  })
174
210
  );
175
211
  });
212
+ Fieldset.Description = FieldsetDescription;
213
+ Fieldset.Legend = FieldsetLegend;
176
214
 
177
215
  // src/form/checkbox/checkbox.tsx
178
- var import_jsx_runtime3 = require("react/jsx-runtime");
179
- var Checkbox = (0, import_react4.forwardRef)(
216
+ var import_jsx_runtime5 = require("react/jsx-runtime");
217
+ var Checkbox = (0, import_react6.forwardRef)(
180
218
  (_a, ref) => {
181
219
  var _b = _a, {
182
220
  variant = "plain",
@@ -201,21 +239,22 @@ var Checkbox = (0, import_react4.forwardRef)(
201
239
  "className",
202
240
  "size"
203
241
  ]);
204
- const validationMessageId = (0, import_react4.useId)();
205
- const { hasError: hasFieldsetError } = useFieldsetContext();
242
+ const validationMessageId = (0, import_react6.useId)();
243
+ const { hasError: hasFieldsetError, size: fieldsetSize } = useFieldsetContext();
206
244
  const hasError = !!errorMessage || hasFieldsetError || hasErrorProp;
245
+ const effectiveSize = size || fieldsetSize;
207
246
  const validationMessageValue = getValidationMessageValue(validationMessage, errorMessage);
208
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
247
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
209
248
  "div",
210
249
  {
211
- className: (0, import_typed_classname3.clsx)("hds-checkbox-wrapper", {
212
- "hds-checkbox-wrapper--small": size === "small"
250
+ className: (0, import_typed_classname4.clsx)("hds-checkbox-wrapper", {
251
+ "hds-checkbox-wrapper--small": effectiveSize === "small"
213
252
  }),
214
253
  children: [
215
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
254
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
216
255
  "div",
217
256
  {
218
- className: (0, import_typed_classname3.clsx)(
257
+ className: (0, import_typed_classname4.clsx)(
219
258
  "hds-checkbox",
220
259
  {
221
260
  [`hds-checkbox--${variant}`]: variant === "bounding-box"
@@ -223,24 +262,24 @@ var Checkbox = (0, import_react4.forwardRef)(
223
262
  className
224
263
  ),
225
264
  children: [
226
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("label", { children: [
227
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
265
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("label", { children: [
266
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
228
267
  "input",
229
268
  __spreadValues({
230
269
  "aria-invalid": hasError ? true : void 0,
231
- "aria-describedby": validationMessage ? validationMessageId : void 0,
270
+ "aria-describedby": validationMessageValue ? validationMessageId : void 0,
232
271
  ref,
233
272
  type: "checkbox"
234
273
  }, rest)
235
274
  ),
236
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { "aria-hidden": true, className: "hds-checkbox__checkmark" }),
237
- title ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: "hds-checkbox__title", children: title }) : children
275
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { "aria-hidden": true, className: "hds-checkbox__checkmark" }),
276
+ title ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "hds-checkbox__title", children: title }) : children
238
277
  ] }),
239
278
  title ? children : null
240
279
  ]
241
280
  }
242
281
  ),
243
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
282
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
244
283
  ValidationMessage,
245
284
  __spreadProps(__spreadValues({
246
285
  id: validationMessageId