@postenbring/hedwig-react 4.1.1 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (247) hide show
  1. package/dist/accordion/accordion-content.js.map +1 -1
  2. package/dist/accordion/accordion-content.mjs +3 -3
  3. package/dist/accordion/accordion.js.map +1 -1
  4. package/dist/accordion/accordion.mjs +4 -4
  5. package/dist/accordion/index.js.map +1 -1
  6. package/dist/accordion/index.mjs +4 -4
  7. package/dist/{chunk-77M2ZTP7.mjs → chunk-3V4GFS46.mjs} +11 -1
  8. package/dist/chunk-3V4GFS46.mjs.map +1 -0
  9. package/dist/chunk-4K54KSRB.mjs +113 -0
  10. package/dist/chunk-4K54KSRB.mjs.map +1 -0
  11. package/dist/{chunk-HEDGKRGC.mjs → chunk-54HLJVAF.mjs} +6 -32
  12. package/dist/chunk-54HLJVAF.mjs.map +1 -0
  13. package/dist/chunk-5M6MEYM7.mjs +1 -0
  14. package/dist/{chunk-Z56XN4AZ.mjs → chunk-6O5AEAIL.mjs} +14 -5
  15. package/dist/chunk-6O5AEAIL.mjs.map +1 -0
  16. package/dist/chunk-77UAHNU6.mjs +24 -0
  17. package/dist/chunk-77UAHNU6.mjs.map +1 -0
  18. package/dist/{chunk-LHIG6RW7.mjs → chunk-7REW23LO.mjs} +6 -6
  19. package/dist/chunk-7REW23LO.mjs.map +1 -0
  20. package/dist/chunk-BUFV457A.mjs +103 -0
  21. package/dist/chunk-BUFV457A.mjs.map +1 -0
  22. package/dist/chunk-CD4LCDK3.mjs +27 -0
  23. package/dist/chunk-CD4LCDK3.mjs.map +1 -0
  24. package/dist/chunk-CSIXGT7P.mjs +1 -0
  25. package/dist/chunk-CVE23PMJ.mjs +1 -0
  26. package/dist/chunk-CVE23PMJ.mjs.map +1 -0
  27. package/dist/chunk-D2XZT2RA.mjs +17 -0
  28. package/dist/chunk-D2XZT2RA.mjs.map +1 -0
  29. package/dist/chunk-D7L7OLFL.mjs +65 -0
  30. package/dist/chunk-D7L7OLFL.mjs.map +1 -0
  31. package/dist/{chunk-5RXT5GLF.mjs → chunk-F6QJWZJX.mjs} +2 -2
  32. package/dist/{chunk-UYLKAPXD.mjs → chunk-GICUX46A.mjs} +2 -2
  33. package/dist/{chunk-JFTUBOIF.mjs → chunk-GIFDGUFW.mjs} +27 -9
  34. package/dist/chunk-GIFDGUFW.mjs.map +1 -0
  35. package/dist/{chunk-SF6EDUHP.mjs → chunk-HOLFVKXQ.mjs} +2 -2
  36. package/dist/chunk-J2DJ6ELO.mjs +64 -0
  37. package/dist/chunk-J2DJ6ELO.mjs.map +1 -0
  38. package/dist/{chunk-GYI4NCUY.mjs → chunk-KPNAC2WN.mjs} +2 -2
  39. package/dist/{chunk-WNYCOHSD.mjs → chunk-NAXSP4VU.mjs} +2 -2
  40. package/dist/chunk-NMW3IWZ4.mjs +65 -0
  41. package/dist/chunk-NMW3IWZ4.mjs.map +1 -0
  42. package/dist/{chunk-R6MQFVHE.mjs → chunk-O55OTMJ5.mjs} +2 -2
  43. package/dist/{chunk-E6OOFTRQ.mjs → chunk-OHPDYPZ5.mjs} +14 -8
  44. package/dist/chunk-OHPDYPZ5.mjs.map +1 -0
  45. package/dist/{chunk-B4D2GO6E.mjs → chunk-QDG2QLFV.mjs} +2 -2
  46. package/dist/{chunk-B6T36QDV.mjs → chunk-QTC4ATZD.mjs} +2 -2
  47. package/dist/{chunk-AGIY7SFP.mjs → chunk-SO7TS4TS.mjs} +2 -2
  48. package/dist/{chunk-HBGFFKP3.mjs → chunk-WVCJV74B.mjs} +2 -2
  49. package/dist/{chunk-EDPWJWQO.mjs → chunk-YQT2TN3U.mjs} +2 -2
  50. package/dist/footer/footer.js.map +1 -1
  51. package/dist/footer/footer.mjs +5 -5
  52. package/dist/footer/index.js.map +1 -1
  53. package/dist/footer/index.mjs +5 -5
  54. package/dist/form/checkbox/checkbox.d.ts +10 -1
  55. package/dist/form/checkbox/checkbox.d.ts.map +1 -1
  56. package/dist/form/checkbox/checkbox.js +167 -65
  57. package/dist/form/checkbox/checkbox.js.map +1 -1
  58. package/dist/form/checkbox/checkbox.mjs +11 -4
  59. package/dist/form/checkbox/index.js +167 -65
  60. package/dist/form/checkbox/index.js.map +1 -1
  61. package/dist/form/checkbox/index.mjs +11 -4
  62. package/dist/form/date-picker/date-picker.d.ts.map +1 -1
  63. package/dist/form/date-picker/date-picker.js +72 -39
  64. package/dist/form/date-picker/date-picker.js.map +1 -1
  65. package/dist/form/date-picker/date-picker.mjs +8 -4
  66. package/dist/form/date-picker/index.js +72 -39
  67. package/dist/form/date-picker/index.js.map +1 -1
  68. package/dist/form/date-picker/index.mjs +8 -4
  69. package/dist/form/error-message/error-message.d.ts +2 -0
  70. package/dist/form/error-message/error-message.d.ts.map +1 -1
  71. package/dist/form/error-message/error-message.js +15 -2
  72. package/dist/form/error-message/error-message.js.map +1 -1
  73. package/dist/form/error-message/error-message.mjs +3 -1
  74. package/dist/form/error-message/index.js +15 -2
  75. package/dist/form/error-message/index.js.map +1 -1
  76. package/dist/form/error-message/index.mjs +3 -1
  77. package/dist/form/error-summary/error-summary.js.map +1 -1
  78. package/dist/form/error-summary/error-summary.mjs +4 -4
  79. package/dist/form/error-summary/index.js.map +1 -1
  80. package/dist/form/error-summary/index.mjs +4 -4
  81. package/dist/form/fieldset/fieldset-description.d.ts +12 -0
  82. package/dist/form/fieldset/fieldset-description.d.ts.map +1 -0
  83. package/dist/form/fieldset/fieldset-description.js +51 -0
  84. package/dist/form/fieldset/fieldset-description.js.map +1 -0
  85. package/dist/form/fieldset/fieldset-description.mjs +8 -0
  86. package/dist/form/fieldset/fieldset-description.mjs.map +1 -0
  87. package/dist/form/fieldset/fieldset-legend.d.ts +9 -0
  88. package/dist/form/fieldset/fieldset-legend.d.ts.map +1 -0
  89. package/dist/form/fieldset/fieldset-legend.js +72 -0
  90. package/dist/form/fieldset/fieldset-legend.js.map +1 -0
  91. package/dist/form/fieldset/fieldset-legend.mjs +8 -0
  92. package/dist/form/fieldset/fieldset-legend.mjs.map +1 -0
  93. package/dist/form/fieldset/fieldset.d.ts +30 -6
  94. package/dist/form/fieldset/fieldset.d.ts.map +1 -1
  95. package/dist/form/fieldset/fieldset.js +107 -29
  96. package/dist/form/fieldset/fieldset.js.map +1 -1
  97. package/dist/form/fieldset/fieldset.mjs +9 -2
  98. package/dist/form/fieldset/index.d.ts +2 -0
  99. package/dist/form/fieldset/index.d.ts.map +1 -1
  100. package/dist/form/fieldset/index.js +111 -29
  101. package/dist/form/fieldset/index.js.map +1 -1
  102. package/dist/form/fieldset/index.mjs +16 -3
  103. package/dist/form/index.d.ts +1 -0
  104. package/dist/form/index.d.ts.map +1 -1
  105. package/dist/form/index.js +443 -252
  106. package/dist/form/index.js.map +1 -1
  107. package/dist/form/index.mjs +40 -27
  108. package/dist/form/input/index.js +99 -32
  109. package/dist/form/input/index.js.map +1 -1
  110. package/dist/form/input/index.mjs +8 -3
  111. package/dist/form/input/input.d.ts.map +1 -1
  112. package/dist/form/input/input.js +99 -32
  113. package/dist/form/input/input.js.map +1 -1
  114. package/dist/form/input/input.mjs +8 -3
  115. package/dist/form/input-group/index.js +55 -16
  116. package/dist/form/input-group/index.js.map +1 -1
  117. package/dist/form/input-group/index.mjs +7 -2
  118. package/dist/form/input-group/input-group.d.ts +8 -0
  119. package/dist/form/input-group/input-group.d.ts.map +1 -1
  120. package/dist/form/input-group/input-group.js +55 -16
  121. package/dist/form/input-group/input-group.js.map +1 -1
  122. package/dist/form/input-group/input-group.mjs +7 -2
  123. package/dist/form/radio-button/index.js +136 -80
  124. package/dist/form/radio-button/index.js.map +1 -1
  125. package/dist/form/radio-button/index.mjs +12 -5
  126. package/dist/form/radio-button/radio-button.d.ts +2 -10
  127. package/dist/form/radio-button/radio-button.d.ts.map +1 -1
  128. package/dist/form/radio-button/radio-button.js +136 -80
  129. package/dist/form/radio-button/radio-button.js.map +1 -1
  130. package/dist/form/radio-button/radio-button.mjs +12 -5
  131. package/dist/form/radio-button/radio-group.d.ts +11 -13
  132. package/dist/form/radio-button/radio-group.d.ts.map +1 -1
  133. package/dist/form/radio-button/radio-group.js +120 -42
  134. package/dist/form/radio-button/radio-group.js.map +1 -1
  135. package/dist/form/radio-button/radio-group.mjs +11 -4
  136. package/dist/form/select/index.js +88 -20
  137. package/dist/form/select/index.js.map +1 -1
  138. package/dist/form/select/index.mjs +8 -3
  139. package/dist/form/select/select.d.ts.map +1 -1
  140. package/dist/form/select/select.js +88 -20
  141. package/dist/form/select/select.js.map +1 -1
  142. package/dist/form/select/select.mjs +8 -3
  143. package/dist/form/textarea/index.js +88 -20
  144. package/dist/form/textarea/index.js.map +1 -1
  145. package/dist/form/textarea/index.mjs +8 -3
  146. package/dist/form/textarea/textarea.d.ts.map +1 -1
  147. package/dist/form/textarea/textarea.js +88 -20
  148. package/dist/form/textarea/textarea.js.map +1 -1
  149. package/dist/form/textarea/textarea.mjs +8 -3
  150. package/dist/form/validation-message/index.d.ts +3 -0
  151. package/dist/form/validation-message/index.d.ts.map +1 -0
  152. package/dist/form/validation-message/index.js +81 -0
  153. package/dist/form/validation-message/index.js.map +1 -0
  154. package/dist/form/validation-message/index.mjs +9 -0
  155. package/dist/form/validation-message/index.mjs.map +1 -0
  156. package/dist/form/validation-message/validation-message.d.ts +8 -0
  157. package/dist/form/validation-message/validation-message.d.ts.map +1 -0
  158. package/dist/form/validation-message/validation-message.js +79 -0
  159. package/dist/form/validation-message/validation-message.js.map +1 -0
  160. package/dist/form/validation-message/validation-message.mjs +8 -0
  161. package/dist/form/validation-message/validation-message.mjs.map +1 -0
  162. package/dist/index.js +652 -459
  163. package/dist/index.js.map +1 -1
  164. package/dist/index.mjs +64 -49
  165. package/dist/modal/index.js.map +1 -1
  166. package/dist/modal/index.mjs +2 -2
  167. package/dist/modal/modal.js.map +1 -1
  168. package/dist/modal/modal.mjs +2 -2
  169. package/dist/navbar/index.js.map +1 -1
  170. package/dist/navbar/index.mjs +3 -3
  171. package/dist/navbar/navbar-expandable-menu.js.map +1 -1
  172. package/dist/navbar/navbar-expandable-menu.mjs +2 -2
  173. package/dist/navbar/navbar.js.map +1 -1
  174. package/dist/navbar/navbar.mjs +3 -3
  175. package/dist/skeleton/index.js.map +1 -1
  176. package/dist/skeleton/index.mjs +3 -3
  177. package/dist/skeleton/skeleton.js.map +1 -1
  178. package/dist/skeleton/skeleton.mjs +3 -3
  179. package/dist/tabs/index.js.map +1 -1
  180. package/dist/tabs/index.mjs +3 -3
  181. package/dist/tabs/tabs-list.js.map +1 -1
  182. package/dist/tabs/tabs-list.mjs +2 -2
  183. package/dist/tabs/tabs.js.map +1 -1
  184. package/dist/tabs/tabs.mjs +3 -3
  185. package/dist/utils/auto-animate-height.js.map +1 -1
  186. package/dist/utils/auto-animate-height.mjs +2 -2
  187. package/dist/utils/index.js +11 -0
  188. package/dist/utils/index.js.map +1 -1
  189. package/dist/utils/index.mjs +4 -2
  190. package/dist/utils/utils.d.ts +4 -0
  191. package/dist/utils/utils.d.ts.map +1 -1
  192. package/dist/utils/utils.js +11 -0
  193. package/dist/utils/utils.js.map +1 -1
  194. package/dist/utils/utils.mjs +3 -1
  195. package/package.json +2 -2
  196. package/src/form/checkbox/checkbox.tsx +32 -11
  197. package/src/form/date-picker/date-picker.tsx +7 -1
  198. package/src/form/error-message/error-message.tsx +8 -14
  199. package/src/form/fieldset/fieldset-description.tsx +17 -0
  200. package/src/form/fieldset/fieldset-legend.tsx +22 -0
  201. package/src/form/fieldset/fieldset.stories.tsx +2 -1
  202. package/src/form/fieldset/fieldset.tsx +95 -26
  203. package/src/form/fieldset/index.tsx +2 -0
  204. package/src/form/index.tsx +1 -0
  205. package/src/form/input/input.tsx +23 -8
  206. package/src/form/input-group/input-group.tsx +22 -7
  207. package/src/form/radio-button/radio-button.stories.tsx +0 -1
  208. package/src/form/radio-button/radio-button.tsx +8 -34
  209. package/src/form/radio-button/radio-group.tsx +20 -19
  210. package/src/form/select/select.tsx +19 -2
  211. package/src/form/textarea/textarea.tsx +19 -2
  212. package/src/form/validation-message/index.tsx +2 -0
  213. package/src/form/validation-message/validation-message.stories.tsx +20 -0
  214. package/src/form/validation-message/validation-message.tsx +23 -0
  215. package/src/utils/utils.ts +16 -0
  216. package/dist/chunk-6BDVJ3J2.mjs +0 -37
  217. package/dist/chunk-6BDVJ3J2.mjs.map +0 -1
  218. package/dist/chunk-77M2ZTP7.mjs.map +0 -1
  219. package/dist/chunk-7T2GDVFS.mjs +0 -37
  220. package/dist/chunk-7T2GDVFS.mjs.map +0 -1
  221. package/dist/chunk-BO3EWZGA.mjs +0 -78
  222. package/dist/chunk-BO3EWZGA.mjs.map +0 -1
  223. package/dist/chunk-BOPY5K4T.mjs +0 -1
  224. package/dist/chunk-E6OOFTRQ.mjs.map +0 -1
  225. package/dist/chunk-HEDGKRGC.mjs.map +0 -1
  226. package/dist/chunk-IZFODQCF.mjs +0 -36
  227. package/dist/chunk-IZFODQCF.mjs.map +0 -1
  228. package/dist/chunk-JFTUBOIF.mjs.map +0 -1
  229. package/dist/chunk-LHIG6RW7.mjs.map +0 -1
  230. package/dist/chunk-LMF3QGSF.mjs +0 -1
  231. package/dist/chunk-Z2ZPTZ6F.mjs +0 -69
  232. package/dist/chunk-Z2ZPTZ6F.mjs.map +0 -1
  233. package/dist/chunk-Z56XN4AZ.mjs.map +0 -1
  234. package/src/form/error-message/error-message.stories.tsx +0 -20
  235. /package/dist/{chunk-BOPY5K4T.mjs.map → chunk-5M6MEYM7.mjs.map} +0 -0
  236. /package/dist/{chunk-LMF3QGSF.mjs.map → chunk-CSIXGT7P.mjs.map} +0 -0
  237. /package/dist/{chunk-5RXT5GLF.mjs.map → chunk-F6QJWZJX.mjs.map} +0 -0
  238. /package/dist/{chunk-UYLKAPXD.mjs.map → chunk-GICUX46A.mjs.map} +0 -0
  239. /package/dist/{chunk-SF6EDUHP.mjs.map → chunk-HOLFVKXQ.mjs.map} +0 -0
  240. /package/dist/{chunk-GYI4NCUY.mjs.map → chunk-KPNAC2WN.mjs.map} +0 -0
  241. /package/dist/{chunk-WNYCOHSD.mjs.map → chunk-NAXSP4VU.mjs.map} +0 -0
  242. /package/dist/{chunk-R6MQFVHE.mjs.map → chunk-O55OTMJ5.mjs.map} +0 -0
  243. /package/dist/{chunk-B4D2GO6E.mjs.map → chunk-QDG2QLFV.mjs.map} +0 -0
  244. /package/dist/{chunk-B6T36QDV.mjs.map → chunk-QTC4ATZD.mjs.map} +0 -0
  245. /package/dist/{chunk-AGIY7SFP.mjs.map → chunk-SO7TS4TS.mjs.map} +0 -0
  246. /package/dist/{chunk-HBGFFKP3.mjs.map → chunk-WVCJV74B.mjs.map} +0 -0
  247. /package/dist/{chunk-EDPWJWQO.mjs.map → chunk-YQT2TN3U.mjs.map} +0 -0
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
8
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
+ var __spreadValues = (a, b) => {
10
+ for (var prop in b || (b = {}))
11
+ if (__hasOwnProp.call(b, prop))
12
+ __defNormalProp(a, prop, b[prop]);
13
+ if (__getOwnPropSymbols)
14
+ for (var prop of __getOwnPropSymbols(b)) {
15
+ if (__propIsEnum.call(b, prop))
16
+ __defNormalProp(a, prop, b[prop]);
17
+ }
18
+ return a;
19
+ };
20
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
32
+ var __export = (target, all) => {
33
+ for (var name in all)
34
+ __defProp(target, name, { get: all[name], enumerable: true });
35
+ };
36
+ var __copyProps = (to, from, except, desc) => {
37
+ if (from && typeof from === "object" || typeof from === "function") {
38
+ for (let key of __getOwnPropNames(from))
39
+ if (!__hasOwnProp.call(to, key) && key !== except)
40
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
41
+ }
42
+ return to;
43
+ };
44
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
45
+
46
+ // src/form/fieldset/fieldset-legend.tsx
47
+ var fieldset_legend_exports = {};
48
+ __export(fieldset_legend_exports, {
49
+ FieldsetLegend: () => FieldsetLegend
50
+ });
51
+ module.exports = __toCommonJS(fieldset_legend_exports);
52
+ var import_react = require("react");
53
+ var import_typed_classname = require("@postenbring/hedwig-css/typed-classname");
54
+ var import_jsx_runtime = require("react/jsx-runtime");
55
+ var FieldsetLegend = (0, import_react.forwardRef)(
56
+ function FieldsetLegend2(_a, ref) {
57
+ var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
58
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
59
+ "legend",
60
+ __spreadValues({
61
+ className: (0, import_typed_classname.clsx)("hds-fieldset__legend", className),
62
+ ref
63
+ }, rest)
64
+ );
65
+ }
66
+ );
67
+ FieldsetLegend.displayName = "Fieldset.Legend";
68
+ // Annotate the CommonJS export names for ESM import in node:
69
+ 0 && (module.exports = {
70
+ FieldsetLegend
71
+ });
72
+ //# sourceMappingURL=fieldset-legend.js.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;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAgD;AAChD,6BAAqB;AAWf;AAHC,IAAM,qBAAiB;AAAA,EAC5B,SAASA,gBAAe,IAAwB,KAAK;AAA7B,iBAAE,YAV5B,IAU0B,IAAgB,iBAAhB,IAAgB,CAAd;AACxB,WACE;AAAA,MAAC;AAAA;AAAA,QACC,eAAW,6BAAK,wBAAwB,SAAsB;AAAA,QAC9D;AAAA,SACI;AAAA,IACN;AAAA,EAEJ;AACF;AAEA,eAAe,cAAc;","names":["FieldsetLegend"]}
@@ -0,0 +1,8 @@
1
+ import {
2
+ FieldsetLegend
3
+ } from "../../chunk-CD4LCDK3.mjs";
4
+ import "../../chunk-YOSPWY5K.mjs";
5
+ export {
6
+ FieldsetLegend
7
+ };
8
+ //# sourceMappingURL=fieldset-legend.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,24 +1,48 @@
1
- import type { FieldsetHTMLAttributes, HTMLAttributes, ReactNode, CSSProperties } from "react";
1
+ import { forwardRef } from "react";
2
+ import type { FieldsetHTMLAttributes, ReactNode, CSSProperties, ComponentProps } from "react";
3
+ import { type ValidationMessageProps } from "../validation-message";
2
4
  import { type ErrorMessageProps } from "../error-message";
5
+ import { FieldsetDescription } from "./fieldset-description";
6
+ import { FieldsetLegend } from "./fieldset-legend";
7
+ type FieldsetLegendProps = ComponentProps<typeof FieldsetLegend>;
3
8
  export interface FieldsetProps extends FieldsetHTMLAttributes<HTMLFieldSetElement> {
4
9
  className?: string;
5
10
  style?: CSSProperties;
11
+ "data-color"?: "info" | "success" | "warning" | "error";
12
+ validationMessage?: ReactNode | {
13
+ value: ReactNode;
14
+ };
15
+ validationMessageProps?: Partial<ValidationMessageProps>;
6
16
  /**
7
17
  * Providing an errorMessage will also give contained Checkboxes or Radio buttons
8
18
  * error styling and aria to indicate invalid state.
9
19
  *
10
20
  * For Radio buttons you are even better off using RadioGroup.
11
21
  */
22
+ /** @deprecated Use `validationMessage` instead */
12
23
  errorMessage?: ReactNode;
13
- legendProps?: HTMLAttributes<HTMLElement> & {
14
- size: "default" | "large";
15
- };
16
- legend: ReactNode;
24
+ /**
25
+ * @deprecated Pass props directly to <Fieldset.Legend> instead.
26
+ */
27
+ legendProps?: FieldsetLegendProps;
28
+ /**
29
+ * @deprecated Use <Fieldset.Legend>...</Fieldset.Legend> instead.
30
+ */
31
+ legend?: ReactNode;
32
+ size?: "small" | "";
17
33
  children: ReactNode;
34
+ /** @deprecated Use `validationMessageProps` instead */
18
35
  errorMessageProps?: Partial<ErrorMessageProps>;
19
36
  }
37
+ /** @deprecated Will no longer be needed */
20
38
  export declare const useFieldsetContext: () => {
21
39
  hasError: boolean;
40
+ size: "small" | "";
41
+ };
42
+ export declare const Fieldset: FieldsetType;
43
+ type FieldsetType = ReturnType<typeof forwardRef<HTMLFieldSetElement, FieldsetProps>> & {
44
+ Description: typeof FieldsetDescription;
45
+ Legend: typeof FieldsetLegend;
22
46
  };
23
- export declare const Fieldset: import("react").ForwardRefExoticComponent<FieldsetProps & import("react").RefAttributes<HTMLFieldSetElement>>;
47
+ export {};
24
48
  //# sourceMappingURL=fieldset.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fieldset.d.ts","sourceRoot":"","sources":["../../../src/form/fieldset/fieldset.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,cAAc,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE9F,OAAO,EAAgB,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAExE,MAAM,WAAW,aAAc,SAAQ,sBAAsB,CAAC,mBAAmB,CAAC;IAChF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,WAAW,CAAC,EAAE,cAAc,CAAC,WAAW,CAAC,GAAG;QAAE,IAAI,EAAE,SAAS,GAAG,OAAO,CAAA;KAAE,CAAC;IAC1E,MAAM,EAAE,SAAS,CAAC;IAClB,QAAQ,EAAE,SAAS,CAAC;IACpB,iBAAiB,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAChD;AAID,eAAO,MAAM,kBAAkB;cAFmB,OAAO;CAEU,CAAC;AAEpE,eAAO,MAAM,QAAQ,+GA0CnB,CAAC"}
1
+ {"version":3,"file":"fieldset.d.ts","sourceRoot":"","sources":["../../../src/form/fieldset/fieldset.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,UAAU,EAGX,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EACV,sBAAsB,EAEtB,SAAS,EACT,aAAa,EACb,cAAc,EACf,MAAM,OAAO,CAAC;AAEf,OAAO,EAAqB,KAAK,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AACvF,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,KAAK,mBAAmB,GAAG,cAAc,CAAC,OAAO,cAAc,CAAC,CAAC;AAEjE,MAAM,WAAW,aAAc,SAAQ,sBAAsB,CAAC,mBAAmB,CAAC;IAChF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;IACxD,iBAAiB,CAAC,EAAE,SAAS,GAAG;QAAE,KAAK,EAAE,SAAS,CAAA;KAAE,CAAC;IACrD,sBAAsB,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACzD;;;;;OAKG;IAEH,kDAAkD;IAClD,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB;;OAEG;IACH,WAAW,CAAC,EAAE,mBAAmB,CAAC;IAClC;;OAEG;IACH,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,IAAI,CAAC,EAAE,OAAO,GAAG,EAAE,CAAC;IACpB,QAAQ,EAAE,SAAS,CAAC;IACpB,uDAAuD;IACvD,iBAAiB,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;CAChD;AAQD,2CAA2C;AAC3C,eAAO,MAAM,kBAAkB;cANmB,OAAO;UAAQ,OAAO,GAAG,EAAE;CAMV,CAAC;AAEpE,eAAO,MAAM,QAAQ,EAiEf,YAAY,CAAC;AAEnB,KAAK,YAAY,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,mBAAmB,EAAE,aAAa,CAAC,CAAC,GAAG;IACtF,WAAW,EAAE,OAAO,mBAAmB,CAAC;IACxC,MAAM,EAAE,OAAO,cAAc,CAAC;CAC/B,CAAC"}
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __defProps = Object.defineProperties;
4
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
6
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
7
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
8
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
9
+ var __getProtoOf = Object.getPrototypeOf;
8
10
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
11
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
10
12
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -44,6 +46,14 @@ var __copyProps = (to, from, except, desc) => {
44
46
  }
45
47
  return to;
46
48
  };
49
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
50
+ // If the importer is in node compatibility mode or this is not an ESM
51
+ // file that has been converted to a CommonJS file using a Babel-
52
+ // compatible transform (i.e. "__esModule" has not been set), then set
53
+ // "default" to the CommonJS "module.exports" for node compatibility.
54
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
55
+ mod
56
+ ));
47
57
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
48
58
 
49
59
  // src/form/fieldset/fieldset.tsx
@@ -53,21 +63,21 @@ __export(fieldset_exports, {
53
63
  useFieldsetContext: () => useFieldsetContext
54
64
  });
55
65
  module.exports = __toCommonJS(fieldset_exports);
56
- var import_react2 = require("react");
57
- var import_typed_classname2 = require("@postenbring/hedwig-css/typed-classname");
66
+ var import_react5 = require("react");
67
+ var import_typed_classname3 = require("@postenbring/hedwig-css/typed-classname");
58
68
 
59
- // src/form/error-message/error-message.tsx
69
+ // src/form/validation-message/validation-message.tsx
60
70
  var import_typed_classname = require("@postenbring/hedwig-css/typed-classname");
61
71
  var import_react = require("react");
62
72
  var import_jsx_runtime = require("react/jsx-runtime");
63
- var ErrorMessage = (0, import_react.forwardRef)(
73
+ var ValidationMessage = (0, import_react.forwardRef)(
64
74
  (_a, ref) => {
65
75
  var _b = _a, { children, id, className } = _b, rest = __objRest(_b, ["children", "id", "className"]);
66
76
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
67
77
  "div",
68
78
  __spreadProps(__spreadValues({
69
79
  "aria-live": "polite",
70
- className: (0, import_typed_classname.clsx)("hds-error-message", className),
80
+ className: (0, import_typed_classname.clsx)("hds-validation-message", className),
71
81
  id,
72
82
  ref
73
83
  }, rest), {
@@ -76,60 +86,128 @@ var ErrorMessage = (0, import_react.forwardRef)(
76
86
  );
77
87
  }
78
88
  );
79
- ErrorMessage.displayName = "ErrorMessage";
89
+ ValidationMessage.displayName = "ValidationMessage";
80
90
 
81
- // src/form/fieldset/fieldset.tsx
91
+ // src/utils/utils.ts
92
+ var React = __toESM(require("react"));
93
+ var import_react2 = require("react");
94
+ function getValidationMessageValue(validationMessage, errorMessage) {
95
+ if (validationMessage) {
96
+ if (typeof validationMessage === "object" && "value" in validationMessage) {
97
+ return validationMessage.value;
98
+ }
99
+ return validationMessage;
100
+ }
101
+ return errorMessage;
102
+ }
103
+ var inertBooleanSupported = Number(import_react2.version.split(".")[0]) >= 19;
104
+
105
+ // src/form/fieldset/fieldset-description.tsx
106
+ var import_react3 = require("react");
82
107
  var import_jsx_runtime2 = require("react/jsx-runtime");
83
- var FieldsetContext = (0, import_react2.createContext)({ hasError: false });
84
- var useFieldsetContext = () => (0, import_react2.useContext)(FieldsetContext);
85
- var Fieldset = (0, import_react2.forwardRef)(function Fieldset2(_a, ref) {
108
+ var FieldsetDescription = (0, import_react3.forwardRef)(
109
+ function FieldsetDescription2(rest, ref) {
110
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", __spreadValues({ className: "hds-fieldset__description", ref }, rest));
111
+ }
112
+ );
113
+
114
+ // src/form/fieldset/fieldset-legend.tsx
115
+ var import_react4 = require("react");
116
+ var import_typed_classname2 = require("@postenbring/hedwig-css/typed-classname");
117
+ var import_jsx_runtime3 = require("react/jsx-runtime");
118
+ var FieldsetLegend = (0, import_react4.forwardRef)(
119
+ function FieldsetLegend2(_a, ref) {
120
+ var _b = _a, { className } = _b, rest = __objRest(_b, ["className"]);
121
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
122
+ "legend",
123
+ __spreadValues({
124
+ className: (0, import_typed_classname2.clsx)("hds-fieldset__legend", className),
125
+ ref
126
+ }, rest)
127
+ );
128
+ }
129
+ );
130
+ FieldsetLegend.displayName = "Fieldset.Legend";
131
+
132
+ // src/form/fieldset/fieldset.tsx
133
+ var import_jsx_runtime4 = require("react/jsx-runtime");
134
+ var FieldsetContext = (0, import_react5.createContext)({
135
+ hasError: false,
136
+ size: ""
137
+ });
138
+ var useFieldsetContext = () => (0, import_react5.useContext)(FieldsetContext);
139
+ var Fieldset = (0, import_react5.forwardRef)(function Fieldset2(_a, ref) {
86
140
  var _b = _a, {
87
141
  className,
88
142
  style,
143
+ "data-color": dataColor = void 0,
144
+ validationMessage,
145
+ validationMessageProps,
89
146
  errorMessage,
90
147
  errorMessageProps,
91
- legendProps: _c = {}
92
- } = _b, _d = _c, { size: legendSize = "default", className: legendClassName } = _d, legendProps = __objRest(_d, ["size", "className"]), _e = _b, {
148
+ legendProps,
93
149
  legend,
150
+ size = "",
94
151
  children
95
- } = _e, rest = __objRest(_e, [
152
+ } = _b, rest = __objRest(_b, [
96
153
  "className",
97
154
  "style",
155
+ "data-color",
156
+ "validationMessage",
157
+ "validationMessageProps",
98
158
  "errorMessage",
99
159
  "errorMessageProps",
100
160
  "legendProps",
101
161
  "legend",
162
+ "size",
102
163
  "children"
103
164
  ]);
104
- const errorMessageId = (0, import_react2.useId)();
105
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
165
+ const validationMessageId = (0, import_react5.useId)();
166
+ const validationColor = errorMessage ? "error" : dataColor;
167
+ const validationMessageValue = getValidationMessageValue(validationMessage, errorMessage);
168
+ const childArray = import_react5.Children.toArray(children);
169
+ const legendChild = childArray.find(
170
+ (child) => (0, import_react5.isValidElement)(child) && child.type === FieldsetLegend
171
+ );
172
+ const contentChildren = legendChild ? childArray.filter((child) => child !== legendChild) : childArray;
173
+ let renderedLegend = null;
174
+ if (legendChild) {
175
+ renderedLegend = (0, import_react5.cloneElement)(legendChild, __spreadProps(__spreadValues(__spreadValues({}, legendProps), legendChild.props), {
176
+ className: (0, import_typed_classname3.clsx)(
177
+ legendProps == null ? void 0 : legendProps.className,
178
+ legendChild.props.className
179
+ )
180
+ }));
181
+ } else if (legend !== void 0) {
182
+ renderedLegend = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FieldsetLegend, __spreadProps(__spreadValues({}, legendProps), { children: legend }));
183
+ }
184
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
106
185
  "fieldset",
107
186
  __spreadProps(__spreadValues({
108
- "aria-describedby": errorMessage ? errorMessageId : void 0,
187
+ "aria-describedby": validationMessageValue ? validationMessageId : void 0,
109
188
  "aria-invalid": errorMessage ? true : void 0,
110
- className: (0, import_typed_classname2.clsx)("hds-fieldset", className),
189
+ className: (0, import_typed_classname3.clsx)("hds-fieldset", { [`hds-fieldset--${size}`]: size }, className),
190
+ "data-color": validationColor,
111
191
  ref,
112
192
  style
113
193
  }, rest), {
114
194
  children: [
115
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
116
- "legend",
195
+ renderedLegend,
196
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FieldsetContext.Provider, { value: { hasError: Boolean(errorMessage), size }, children: contentChildren }),
197
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
198
+ ValidationMessage,
117
199
  __spreadProps(__spreadValues({
118
- className: (0, import_typed_classname2.clsx)(
119
- "hds-fieldset__legend",
120
- { [`hds-fieldset__legend--${legendSize}`]: legendSize },
121
- legendClassName
122
- )
123
- }, legendProps), {
124
- children: legend
200
+ id: validationMessageId
201
+ }, validationMessageProps != null ? validationMessageProps : errorMessageProps), {
202
+ children: validationMessageValue
125
203
  })
126
- ),
127
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(FieldsetContext.Provider, { value: { hasError: Boolean(errorMessage) }, children }),
128
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ErrorMessage, __spreadProps(__spreadValues({ id: errorMessageId }, errorMessageProps), { children: errorMessage }))
204
+ )
129
205
  ]
130
206
  })
131
207
  );
132
208
  });
209
+ Fieldset.Description = FieldsetDescription;
210
+ Fieldset.Legend = FieldsetLegend;
133
211
  // Annotate the CommonJS export names for ESM import in node:
134
212
  0 && (module.exports = {
135
213
  Fieldset,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/form/fieldset/fieldset.tsx","../../../src/form/error-message/error-message.tsx"],"sourcesContent":["import { useId, forwardRef, createContext, useContext } from \"react\";\nimport type { FieldsetHTMLAttributes, HTMLAttributes, ReactNode, CSSProperties } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { ErrorMessage, type ErrorMessageProps } from \"../error-message\";\n\nexport interface FieldsetProps extends FieldsetHTMLAttributes<HTMLFieldSetElement> {\n className?: string;\n style?: CSSProperties;\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 errorMessage?: ReactNode;\n legendProps?: HTMLAttributes<HTMLElement> & { size: \"default\" | \"large\" };\n legend: ReactNode;\n children: ReactNode;\n errorMessageProps?: Partial<ErrorMessageProps>;\n}\n\nconst FieldsetContext = createContext<{ hasError: boolean }>({ hasError: false });\n\nexport const useFieldsetContext = () => useContext(FieldsetContext);\n\nexport const Fieldset = forwardRef<HTMLFieldSetElement, FieldsetProps>(function Fieldset(\n {\n className,\n style,\n errorMessage,\n errorMessageProps,\n legendProps: { size: legendSize = \"default\", className: legendClassName, ...legendProps } = {},\n legend,\n children,\n ...rest\n },\n ref,\n) {\n const errorMessageId = useId();\n\n return (\n <fieldset\n aria-describedby={errorMessage ? errorMessageId : undefined}\n aria-invalid={errorMessage ? true : undefined}\n className={clsx(\"hds-fieldset\", className as undefined)}\n ref={ref}\n style={style}\n {...rest}\n >\n <legend\n className={clsx(\n \"hds-fieldset__legend\",\n { [`hds-fieldset__legend--${legendSize}`]: legendSize },\n legendClassName as undefined,\n )}\n {...legendProps}\n >\n {legend}\n </legend>\n <FieldsetContext.Provider value={{ hasError: Boolean(errorMessage) }}>\n {children}\n </FieldsetContext.Provider>\n <ErrorMessage id={errorMessageId} {...errorMessageProps}>\n {errorMessage}\n </ErrorMessage>\n </fieldset>\n );\n});\n","import { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { forwardRef, type ReactNode } from \"react\";\n\nexport interface ErrorMessageProps extends React.HTMLAttributes<HTMLDivElement> {\n children: ReactNode;\n id: string;\n className?: string;\n}\n\nexport const ErrorMessage = forwardRef<HTMLDivElement, ErrorMessageProps>(\n ({ children, id, className, ...rest }, ref) => {\n return (\n <div\n aria-live=\"polite\"\n className={clsx(\"hds-error-message\", className as undefined)}\n id={id}\n ref={ref}\n {...rest}\n >\n {children}\n </div>\n );\n },\n);\nErrorMessage.displayName = \"ErrorMessage\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,gBAA6D;AAE7D,IAAAC,0BAAqB;;;ACFrB,6BAAqB;AACrB,mBAA2C;AAWrC;AAHC,IAAM,mBAAe;AAAA,EAC1B,CAAC,IAAsC,QAAQ;AAA9C,iBAAE,YAAU,IAAI,UAVnB,IAUG,IAA8B,iBAA9B,IAA8B,CAA5B,YAAU,MAAI;AACf,WACE;AAAA,MAAC;AAAA;AAAA,QACC,aAAU;AAAA,QACV,eAAW,6BAAK,qBAAqB,SAAsB;AAAA,QAC3D;AAAA,QACA;AAAA,SACI,OALL;AAAA,QAOE;AAAA;AAAA,IACH;AAAA,EAEJ;AACF;AACA,aAAa,cAAc;;;ADiBvB,IAAAC,sBAAA;AApBJ,IAAM,sBAAkB,6BAAqC,EAAE,UAAU,MAAM,CAAC;AAEzE,IAAM,qBAAqB,UAAM,0BAAW,eAAe;AAE3D,IAAM,eAAW,0BAA+C,SAASC,UAC9E,IAUA,KACA;AAXA,eAKe;AAAA,IAJb;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,aAAa,KAA+E,CAAC;AAAA,EA/BjG,IA0BE,IAKe,SAAE,QAAM,aAAa,WAAW,WAAW,gBA/B5D,IA+BiB,IAA+D,wBAA/D,IAA+D,CAA7D,QAA8B,eAL/C,SAME;AAAA;AAAA,IACA;AAAA,EAjCJ,IA0BE,IAQK,iBARL,IAQK;AAAA,IAPH;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA;AAKF,QAAM,qBAAiB,qBAAM;AAE7B,SACE;AAAA,IAAC;AAAA;AAAA,MACC,oBAAkB,eAAe,iBAAiB;AAAA,MAClD,gBAAc,eAAe,OAAO;AAAA,MACpC,eAAW,8BAAK,gBAAgB,SAAsB;AAAA,MACtD;AAAA,MACA;AAAA,OACI,OANL;AAAA,MAQC;AAAA;AAAA,UAAC;AAAA;AAAA,YACC,eAAW;AAAA,cACT;AAAA,cACA,EAAE,CAAC,yBAAyB,UAAU,EAAE,GAAG,WAAW;AAAA,cACtD;AAAA,YACF;AAAA,aACI,cANL;AAAA,YAQE;AAAA;AAAA,QACH;AAAA,QACA,6CAAC,gBAAgB,UAAhB,EAAyB,OAAO,EAAE,UAAU,QAAQ,YAAY,EAAE,GAChE,UACH;AAAA,QACA,6CAAC,6CAAa,IAAI,kBAAoB,oBAArC,EACE,yBACH;AAAA;AAAA;AAAA,EACF;AAEJ,CAAC;","names":["import_react","import_typed_classname","import_jsx_runtime","Fieldset"]}
1
+ {"version":3,"sources":["../../../src/form/fieldset/fieldset.tsx","../../../src/form/validation-message/validation-message.tsx","../../../src/utils/utils.ts","../../../src/form/fieldset/fieldset-description.tsx","../../../src/form/fieldset/fieldset-legend.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","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\";\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 { 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":"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","names":["import_react","import_typed_classname","import_react","import_react","import_jsx_runtime","FieldsetDescription","import_react","import_typed_classname","import_jsx_runtime","FieldsetLegend","import_jsx_runtime","Fieldset"]}
@@ -1,9 +1,16 @@
1
1
  import {
2
2
  Fieldset,
3
3
  useFieldsetContext
4
- } from "../../chunk-Z2ZPTZ6F.mjs";
4
+ } from "../../chunk-4K54KSRB.mjs";
5
+ import "../../chunk-D2XZT2RA.mjs";
6
+ import "../../chunk-CD4LCDK3.mjs";
5
7
  import "../../chunk-NSLSA7F7.mjs";
6
- import "../../chunk-LHIG6RW7.mjs";
8
+ import "../../chunk-77UAHNU6.mjs";
9
+ import "../../chunk-5M6MEYM7.mjs";
10
+ import "../../chunk-7REW23LO.mjs";
11
+ import "../../chunk-CYDWEPFL.mjs";
12
+ import "../../chunk-KPNAC2WN.mjs";
13
+ import "../../chunk-3V4GFS46.mjs";
7
14
  import "../../chunk-YOSPWY5K.mjs";
8
15
  export {
9
16
  Fieldset,
@@ -1,3 +1,5 @@
1
1
  export { Fieldset, useFieldsetContext } from "./fieldset";
2
2
  export type * from "./fieldset";
3
+ export { FieldsetDescription } from "./fieldset-description";
4
+ export { FieldsetLegend } from "./fieldset-legend";
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/form/fieldset/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAC1D,mBAAmB,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/form/fieldset/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAC1D,mBAAmB,YAAY,CAAC;AAChC,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC"}