@postenbring/hedwig-react 2.1.4 → 2.2.1
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.
- package/dist/accordion/accordion-content.d.ts.map +1 -1
- package/dist/accordion/accordion-content.js +22 -6
- package/dist/accordion/accordion-content.js.map +1 -1
- package/dist/accordion/accordion-content.mjs +4 -1
- package/dist/accordion/accordion.js +24 -6
- package/dist/accordion/accordion.js.map +1 -1
- package/dist/accordion/accordion.mjs +5 -2
- package/dist/accordion/index.js +24 -6
- package/dist/accordion/index.js.map +1 -1
- package/dist/accordion/index.mjs +5 -2
- package/dist/alert/alert.d.ts +36 -0
- package/dist/alert/alert.d.ts.map +1 -0
- package/dist/alert/alert.js +186 -0
- package/dist/alert/alert.js.map +1 -0
- package/dist/alert/alert.mjs +13 -0
- package/dist/alert/alert.mjs.map +1 -0
- package/dist/alert/index.d.ts +3 -0
- package/dist/alert/index.d.ts.map +1 -0
- package/dist/alert/index.js +188 -0
- package/dist/alert/index.js.map +1 -0
- package/dist/alert/index.mjs +14 -0
- package/dist/alert/index.mjs.map +1 -0
- package/dist/{chunk-GVO57ZWU.mjs → chunk-23IZCRJA.mjs} +2 -2
- package/dist/chunk-4P4GPVKZ.mjs +63 -0
- package/dist/chunk-4P4GPVKZ.mjs.map +1 -0
- package/dist/{chunk-KNGG6M2I.mjs → chunk-5RXT5GLF.mjs} +2 -2
- package/dist/{chunk-ILFK3VKS.mjs → chunk-77M2ZTP7.mjs} +6 -3
- package/dist/chunk-77M2ZTP7.mjs.map +1 -0
- package/dist/{chunk-5FWY7FIX.mjs → chunk-AGIY7SFP.mjs} +5 -2
- package/dist/chunk-AGIY7SFP.mjs.map +1 -0
- package/dist/{chunk-WLESNP6Z.mjs → chunk-B6T36QDV.mjs} +5 -2
- package/dist/chunk-B6T36QDV.mjs.map +1 -0
- package/dist/{chunk-GXIKHXWC.mjs → chunk-EQFY63YP.mjs} +2 -2
- package/dist/{chunk-6SVLMQUW.mjs → chunk-FUIKSOJF.mjs} +4 -4
- package/dist/{chunk-KCEWKQ4W.mjs → chunk-GYI4NCUY.mjs} +2 -2
- package/dist/{chunk-J5SCUELT.mjs → chunk-HBGFFKP3.mjs} +2 -2
- package/dist/{chunk-4C76JM3T.mjs → chunk-I4NL4ESV.mjs} +2 -2
- package/dist/{chunk-DTU7AXY3.mjs → chunk-NUP7ZBVE.mjs} +2 -2
- package/dist/chunk-OVKUPO5U.mjs +1 -0
- package/dist/chunk-OVKUPO5U.mjs.map +1 -0
- package/dist/{chunk-CKG2XRMX.mjs → chunk-R6MQFVHE.mjs} +2 -2
- package/dist/{chunk-YQMTDQSQ.mjs → chunk-TC5PD4TA.mjs} +4 -4
- package/dist/{chunk-DRSAVDIE.mjs → chunk-W6CFPK2C.mjs} +5 -4
- package/dist/chunk-W6CFPK2C.mjs.map +1 -0
- package/dist/{chunk-4YCM72TQ.mjs → chunk-W7CPW23K.mjs} +27 -18
- package/dist/chunk-W7CPW23K.mjs.map +1 -0
- package/dist/footer/footer.js +37 -19
- package/dist/footer/footer.js.map +1 -1
- package/dist/footer/footer.mjs +6 -3
- package/dist/footer/index.js +37 -19
- package/dist/footer/index.js.map +1 -1
- package/dist/footer/index.mjs +6 -3
- package/dist/form/date-picker/date-picker.js +1 -0
- package/dist/form/date-picker/date-picker.js.map +1 -1
- package/dist/form/date-picker/date-picker.mjs +2 -2
- package/dist/form/date-picker/index.js +1 -0
- package/dist/form/date-picker/index.js.map +1 -1
- package/dist/form/date-picker/index.mjs +2 -2
- package/dist/form/error-summary/error-summary.d.ts +5 -5
- package/dist/form/error-summary/error-summary.d.ts.map +1 -1
- package/dist/form/error-summary/error-summary.js +47 -93
- package/dist/form/error-summary/error-summary.js.map +1 -1
- package/dist/form/error-summary/error-summary.mjs +5 -6
- package/dist/form/error-summary/index.js +47 -93
- package/dist/form/error-summary/index.js.map +1 -1
- package/dist/form/error-summary/index.mjs +5 -6
- package/dist/form/index.js +75 -121
- package/dist/form/index.js.map +1 -1
- package/dist/form/index.mjs +15 -16
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +784 -713
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +86 -75
- package/dist/layout/grid/grid.mjs +2 -2
- package/dist/layout/grid/index.mjs +2 -2
- package/dist/layout/index.mjs +9 -9
- package/dist/layout/stack/index.mjs +2 -2
- package/dist/layout/stack/stack.mjs +2 -2
- package/dist/modal/index.js +1 -0
- package/dist/modal/index.js.map +1 -1
- package/dist/modal/index.mjs +2 -2
- package/dist/modal/modal.js +1 -0
- package/dist/modal/modal.js.map +1 -1
- package/dist/modal/modal.mjs +2 -2
- package/dist/navbar/index.js +3 -1
- package/dist/navbar/index.js.map +1 -1
- package/dist/navbar/index.mjs +3 -3
- package/dist/navbar/navbar-expandable-menu.d.ts.map +1 -1
- package/dist/navbar/navbar-expandable-menu.js +3 -1
- package/dist/navbar/navbar-expandable-menu.js.map +1 -1
- package/dist/navbar/navbar-expandable-menu.mjs +2 -2
- package/dist/navbar/navbar.js +3 -1
- package/dist/navbar/navbar.js.map +1 -1
- package/dist/navbar/navbar.mjs +3 -3
- package/dist/skeleton/index.js +20 -2
- package/dist/skeleton/index.js.map +1 -1
- package/dist/skeleton/index.mjs +4 -1
- package/dist/skeleton/skeleton.d.ts.map +1 -1
- package/dist/skeleton/skeleton.js +20 -2
- package/dist/skeleton/skeleton.js.map +1 -1
- package/dist/skeleton/skeleton.mjs +4 -1
- package/dist/tabs/index.js +1 -0
- package/dist/tabs/index.js.map +1 -1
- package/dist/tabs/index.mjs +3 -3
- package/dist/tabs/tabs-list.js +1 -0
- package/dist/tabs/tabs-list.js.map +1 -1
- package/dist/tabs/tabs-list.mjs +2 -2
- package/dist/tabs/tabs.js +1 -0
- package/dist/tabs/tabs.js.map +1 -1
- package/dist/tabs/tabs.mjs +3 -3
- package/dist/text/text.d.ts +1 -1
- package/dist/utils/auto-animate-height.js +1 -0
- package/dist/utils/auto-animate-height.js.map +1 -1
- package/dist/utils/auto-animate-height.mjs +2 -2
- package/dist/utils/index.js +4 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +4 -2
- package/dist/utils/utils.d.ts +4 -0
- package/dist/utils/utils.d.ts.map +1 -1
- package/dist/utils/utils.js +4 -0
- package/dist/utils/utils.js.map +1 -1
- package/dist/utils/utils.mjs +3 -1
- package/package.json +5 -5
- package/src/accordion/accordion-content.tsx +2 -1
- package/src/alert/alert.stories.tsx +36 -0
- package/src/alert/alert.tsx +83 -0
- package/src/alert/index.tsx +2 -0
- package/src/form/error-summary/error-summary.tsx +32 -31
- package/src/index.ts +1 -0
- package/src/navbar/navbar-expandable-menu.tsx +3 -2
- package/src/skeleton/skeleton.tsx +2 -1
- package/src/utils/utils.ts +14 -1
- package/dist/chunk-4YCM72TQ.mjs.map +0 -1
- package/dist/chunk-5FWY7FIX.mjs.map +0 -1
- package/dist/chunk-DRSAVDIE.mjs.map +0 -1
- package/dist/chunk-ILFK3VKS.mjs.map +0 -1
- package/dist/chunk-WLESNP6Z.mjs.map +0 -1
- /package/dist/{chunk-GVO57ZWU.mjs.map → chunk-23IZCRJA.mjs.map} +0 -0
- /package/dist/{chunk-KNGG6M2I.mjs.map → chunk-5RXT5GLF.mjs.map} +0 -0
- /package/dist/{chunk-GXIKHXWC.mjs.map → chunk-EQFY63YP.mjs.map} +0 -0
- /package/dist/{chunk-6SVLMQUW.mjs.map → chunk-FUIKSOJF.mjs.map} +0 -0
- /package/dist/{chunk-KCEWKQ4W.mjs.map → chunk-GYI4NCUY.mjs.map} +0 -0
- /package/dist/{chunk-J5SCUELT.mjs.map → chunk-HBGFFKP3.mjs.map} +0 -0
- /package/dist/{chunk-4C76JM3T.mjs.map → chunk-I4NL4ESV.mjs.map} +0 -0
- /package/dist/{chunk-DTU7AXY3.mjs.map → chunk-NUP7ZBVE.mjs.map} +0 -0
- /package/dist/{chunk-CKG2XRMX.mjs.map → chunk-R6MQFVHE.mjs.map} +0 -0
- /package/dist/{chunk-YQMTDQSQ.mjs.map → chunk-TC5PD4TA.mjs.map} +0 -0
|
@@ -65,12 +65,9 @@ __export(error_summary_exports, {
|
|
|
65
65
|
ErrorSummaryList: () => ErrorSummaryList
|
|
66
66
|
});
|
|
67
67
|
module.exports = __toCommonJS(error_summary_exports);
|
|
68
|
-
var
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
var import_react2 = require("react");
|
|
72
|
-
var import_typed_classname2 = require("@postenbring/hedwig-css/typed-classname");
|
|
73
|
-
var import_react_slot2 = require("@radix-ui/react-slot");
|
|
68
|
+
var import_react5 = require("react");
|
|
69
|
+
var import_typed_classname4 = require("@postenbring/hedwig-css/typed-classname");
|
|
70
|
+
var import_react_slot3 = require("@radix-ui/react-slot");
|
|
74
71
|
|
|
75
72
|
// src/box/box.tsx
|
|
76
73
|
var import_react = require("react");
|
|
@@ -147,69 +144,18 @@ var Box = (0, import_react.forwardRef)(
|
|
|
147
144
|
Box.displayName = "Box";
|
|
148
145
|
Box.CloseButton = BoxCloseButton;
|
|
149
146
|
|
|
150
|
-
// src/message/message.tsx
|
|
151
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
152
|
-
var MessageTitle = (0, import_react2.forwardRef)(
|
|
153
|
-
(_a, ref) => {
|
|
154
|
-
var _b = _a, { asChild, className } = _b, rest = __objRest(_b, ["asChild", "className"]);
|
|
155
|
-
const Component = asChild ? import_react_slot2.Slot : "div";
|
|
156
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
157
|
-
Component,
|
|
158
|
-
__spreadValues({
|
|
159
|
-
className: (0, import_typed_classname2.clsx)("hds-message__title", className),
|
|
160
|
-
ref
|
|
161
|
-
}, rest)
|
|
162
|
-
);
|
|
163
|
-
}
|
|
164
|
-
);
|
|
165
|
-
MessageTitle.displayName = "Message.Title";
|
|
166
|
-
var MessageDescription = (0, import_react2.forwardRef)(
|
|
167
|
-
(_a, ref) => {
|
|
168
|
-
var _b = _a, { asChild, className } = _b, rest = __objRest(_b, ["asChild", "className"]);
|
|
169
|
-
const Component = asChild ? import_react_slot2.Slot : "div";
|
|
170
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
171
|
-
Component,
|
|
172
|
-
__spreadValues({
|
|
173
|
-
className: (0, import_typed_classname2.clsx)("hds-message__description", className),
|
|
174
|
-
ref
|
|
175
|
-
}, rest)
|
|
176
|
-
);
|
|
177
|
-
}
|
|
178
|
-
);
|
|
179
|
-
MessageDescription.displayName = "Message.Description";
|
|
180
|
-
var Message = (0, import_react2.forwardRef)(
|
|
181
|
-
(_a, ref) => {
|
|
182
|
-
var _b = _a, { children, className, variant = "success", icon, iconClassName } = _b, rest = __objRest(_b, ["children", "className", "variant", "icon", "iconClassName"]);
|
|
183
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
184
|
-
Box,
|
|
185
|
-
__spreadProps(__spreadValues({
|
|
186
|
-
className: (0, import_typed_classname2.clsx)(`hds-message`, `hds-message--${variant}`, className),
|
|
187
|
-
ref
|
|
188
|
-
}, rest), {
|
|
189
|
-
children: [
|
|
190
|
-
variant === "neutral" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: (0, import_typed_classname2.clsx)("hds-message--neutral__icon", iconClassName), children: icon }),
|
|
191
|
-
children
|
|
192
|
-
]
|
|
193
|
-
})
|
|
194
|
-
);
|
|
195
|
-
}
|
|
196
|
-
);
|
|
197
|
-
Message.displayName = "Message";
|
|
198
|
-
Message.Title = MessageTitle;
|
|
199
|
-
Message.Description = MessageDescription;
|
|
200
|
-
|
|
201
147
|
// src/list/list.tsx
|
|
202
|
-
var
|
|
203
|
-
var
|
|
204
|
-
var
|
|
205
|
-
var UnorderedList = (0,
|
|
148
|
+
var import_react2 = require("react");
|
|
149
|
+
var import_typed_classname2 = require("@postenbring/hedwig-css/typed-classname");
|
|
150
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
151
|
+
var UnorderedList = (0, import_react2.forwardRef)(
|
|
206
152
|
(_a, ref) => {
|
|
207
153
|
var _b = _a, { size = "default", className } = _b, rest = __objRest(_b, ["size", "className"]);
|
|
208
|
-
return /* @__PURE__ */ (0,
|
|
154
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
209
155
|
"ul",
|
|
210
156
|
__spreadValues({
|
|
211
157
|
ref,
|
|
212
|
-
className: (0,
|
|
158
|
+
className: (0, import_typed_classname2.clsx)(
|
|
213
159
|
"hds-list",
|
|
214
160
|
size !== "default" && `hds-list--${size}`,
|
|
215
161
|
className
|
|
@@ -219,14 +165,14 @@ var UnorderedList = (0, import_react3.forwardRef)(
|
|
|
219
165
|
}
|
|
220
166
|
);
|
|
221
167
|
UnorderedList.displayName = "UnorderedList";
|
|
222
|
-
var OrderedList = (0,
|
|
168
|
+
var OrderedList = (0, import_react2.forwardRef)(
|
|
223
169
|
(_a, ref) => {
|
|
224
170
|
var _b = _a, { size = "medium", className } = _b, rest = __objRest(_b, ["size", "className"]);
|
|
225
|
-
return /* @__PURE__ */ (0,
|
|
171
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
226
172
|
"ol",
|
|
227
173
|
__spreadValues({
|
|
228
174
|
ref,
|
|
229
|
-
className: (0,
|
|
175
|
+
className: (0, import_typed_classname2.clsx)(
|
|
230
176
|
"hds-list",
|
|
231
177
|
size !== "default" && `hds-list--${size}`,
|
|
232
178
|
className
|
|
@@ -239,18 +185,18 @@ OrderedList.displayName = "OrderedList";
|
|
|
239
185
|
|
|
240
186
|
// src/link/link.tsx
|
|
241
187
|
var React = require("react");
|
|
242
|
-
var
|
|
243
|
-
var
|
|
244
|
-
var
|
|
245
|
-
var
|
|
246
|
-
var Link = (0,
|
|
188
|
+
var import_typed_classname3 = require("@postenbring/hedwig-css/typed-classname");
|
|
189
|
+
var import_react3 = require("react");
|
|
190
|
+
var import_react_slot2 = require("@radix-ui/react-slot");
|
|
191
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
192
|
+
var Link = (0, import_react3.forwardRef)(
|
|
247
193
|
(_a, ref) => {
|
|
248
194
|
var _b = _a, { asChild, children, variant = "underline", size = "default", icon, className } = _b, rest = __objRest(_b, ["asChild", "children", "variant", "size", "icon", "className"]);
|
|
249
|
-
const Component = asChild ?
|
|
250
|
-
return /* @__PURE__ */ (0,
|
|
195
|
+
const Component = asChild ? import_react_slot2.Slot : "a";
|
|
196
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
251
197
|
Component,
|
|
252
198
|
__spreadProps(__spreadValues({
|
|
253
|
-
className: (0,
|
|
199
|
+
className: (0, import_typed_classname3.clsx)(
|
|
254
200
|
"hds-link",
|
|
255
201
|
variant !== "underline" && `hds-link--${variant}`,
|
|
256
202
|
size !== "default" && `hds-link--${size}`,
|
|
@@ -269,7 +215,7 @@ Link.displayName = "Link";
|
|
|
269
215
|
|
|
270
216
|
// src/utils/utils.ts
|
|
271
217
|
var React2 = __toESM(require("react"));
|
|
272
|
-
var
|
|
218
|
+
var import_react4 = require("react");
|
|
273
219
|
function useMergeRefs(refs) {
|
|
274
220
|
return React2.useMemo(() => {
|
|
275
221
|
if (refs.every((ref) => ref === null)) {
|
|
@@ -286,6 +232,7 @@ function useMergeRefs(refs) {
|
|
|
286
232
|
};
|
|
287
233
|
}, refs);
|
|
288
234
|
}
|
|
235
|
+
var inertBooleanSupported = Number(import_react4.version.split(".")[0]) >= 19;
|
|
289
236
|
|
|
290
237
|
// src/form/error-summary/focus.ts
|
|
291
238
|
function focusWithLegendOrLabelInViewport(id) {
|
|
@@ -329,33 +276,30 @@ function labelForInput(input) {
|
|
|
329
276
|
}
|
|
330
277
|
|
|
331
278
|
// src/form/error-summary/error-summary.tsx
|
|
332
|
-
var
|
|
333
|
-
var ErrorSummaryHeading = (0,
|
|
334
|
-
var _b = _a, { children, as: Tag, autoFocus = true } = _b, rest = __objRest(_b, ["children", "as", "autoFocus"]);
|
|
335
|
-
const focusRef = (0,
|
|
279
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
280
|
+
var ErrorSummaryHeading = (0, import_react5.forwardRef)((_a, ref) => {
|
|
281
|
+
var _b = _a, { asChild, children, as: Tag, autoFocus = true } = _b, rest = __objRest(_b, ["asChild", "children", "as", "autoFocus"]);
|
|
282
|
+
const focusRef = (0, import_react5.useRef)(null);
|
|
336
283
|
const mergedRef = useMergeRefs([focusRef, ref]);
|
|
337
|
-
|
|
284
|
+
const Component = asChild ? import_react_slot3.Slot : Tag;
|
|
285
|
+
(0, import_react5.useEffect)(() => {
|
|
338
286
|
setTimeout(() => {
|
|
339
287
|
if (focusRef.current && autoFocus) {
|
|
340
288
|
focusRef.current.focus();
|
|
341
289
|
}
|
|
342
290
|
});
|
|
343
291
|
}, []);
|
|
344
|
-
return /* @__PURE__ */ (0,
|
|
292
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Component, __spreadProps(__spreadValues({ className: (0, import_typed_classname4.clsx)(`hds-error-summary__title`), ref: mergedRef, tabIndex: -1 }, rest), { children }));
|
|
345
293
|
});
|
|
346
294
|
ErrorSummaryHeading.displayName = "ErrorSummary.Heading";
|
|
347
|
-
var ErrorSummaryList = (0,
|
|
295
|
+
var ErrorSummaryList = (0, import_react5.forwardRef)(
|
|
348
296
|
(_a, ref) => {
|
|
349
|
-
var _b = _a, { children,
|
|
350
|
-
|
|
351
|
-
// Match the link `solid` style, which black underline
|
|
352
|
-
"--_hds-list-marker-color": "var(--hds-ui-colors-black)"
|
|
353
|
-
}, _style);
|
|
354
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Message.Description, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(UnorderedList, __spreadProps(__spreadValues({ size, ref, style }, rest), { children })) });
|
|
297
|
+
var _b = _a, { children, size = "small" } = _b, rest = __objRest(_b, ["children", "size"]);
|
|
298
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(UnorderedList, __spreadProps(__spreadValues({ size, ref }, rest), { children }));
|
|
355
299
|
}
|
|
356
300
|
);
|
|
357
301
|
ErrorSummaryList.displayName = "ErrorSummary.List";
|
|
358
|
-
var ErrorSummaryItem = (0,
|
|
302
|
+
var ErrorSummaryItem = (0, import_react5.forwardRef)(
|
|
359
303
|
(_a, ref) => {
|
|
360
304
|
var _b = _a, { children, href, linkProps } = _b, rest = __objRest(_b, ["children", "href", "linkProps"]);
|
|
361
305
|
function onClick(e) {
|
|
@@ -365,14 +309,24 @@ var ErrorSummaryItem = (0, import_react6.forwardRef)(
|
|
|
365
309
|
e.preventDefault();
|
|
366
310
|
}
|
|
367
311
|
}
|
|
368
|
-
return /* @__PURE__ */ (0,
|
|
312
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("li", __spreadProps(__spreadValues({ className: (0, import_typed_classname4.clsx)(`hds-error-summary__list-item`), ref }, rest), { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
313
|
+
Link,
|
|
314
|
+
__spreadProps(__spreadValues({
|
|
315
|
+
size: "small",
|
|
316
|
+
href,
|
|
317
|
+
variant: "inverted-no-underline"
|
|
318
|
+
}, linkProps), {
|
|
319
|
+
onClick,
|
|
320
|
+
children
|
|
321
|
+
})
|
|
322
|
+
) }));
|
|
369
323
|
}
|
|
370
324
|
);
|
|
371
325
|
ErrorSummaryItem.displayName = "ErrorSummary.Item";
|
|
372
|
-
var ErrorSummary = (0,
|
|
326
|
+
var ErrorSummary = (0, import_react5.forwardRef)(
|
|
373
327
|
(_a, ref) => {
|
|
374
|
-
var _b = _a, { children } = _b, rest = __objRest(_b, ["children"]);
|
|
375
|
-
return /* @__PURE__ */ (0,
|
|
328
|
+
var _b = _a, { children, className } = _b, rest = __objRest(_b, ["children", "className"]);
|
|
329
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Box, __spreadProps(__spreadValues({ ref }, rest), { className: (0, import_typed_classname4.clsx)(`hds-error-summary`, className), children }));
|
|
376
330
|
}
|
|
377
331
|
);
|
|
378
332
|
ErrorSummary.displayName = "ErrorSummary";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/form/error-summary/error-summary.tsx","../../../src/message/message.tsx","../../../src/box/box.tsx","../../../src/list/list.tsx","../../../src/link/link.tsx","../../../src/utils/utils.ts","../../../src/form/error-summary/focus.ts"],"sourcesContent":["import { forwardRef, useEffect, useRef } from \"react\";\nimport { Message, type MessageProps, type MessageTitleProps } from \"../../message\";\nimport { UnorderedList, type ListProps } from \"../../list\";\nimport { Link } from \"../../link\";\nimport { useMergeRefs } from \"../../utils\";\nimport { focusWithLegendOrLabelInViewport } from \"./focus\";\n\ninterface ErrorSummaryHeadingPropsAutoFocus {\n /**\n * The heading will be focused when the component mounts\n *\n * On following errornous form submissions you should manually focus the heading\n * e.g. by passing a ref and calling `ref.current.focus()`\n *\n * @default true\n */\n autoFocus?: boolean;\n}\n\ninterface ErrorSummaryHeadingPropsAs {\n /**\n * A heading level must be selected, or optionally opting out for a different element\n *\n * Use {@link ErrorSummaryHeadingPropsAsChild.asChild} if you need more control of the rendered element.\n */\n as: \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\" | \"span\" | \"div\" | \"label\" | \"p\";\n asChild?: never;\n}\n\ninterface ErrorSummaryHeadingPropsAsChild {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n */\n asChild: true;\n as?: never;\n}\n\nexport type ErrorSummaryHeadingProps = MessageTitleProps &\n ErrorSummaryHeadingPropsAutoFocus &\n (ErrorSummaryHeadingPropsAs | ErrorSummaryHeadingPropsAsChild);\n\nexport const ErrorSummaryHeading = forwardRef<\n HTMLParagraphElement,\n ErrorSummaryHeadingProps & (ErrorSummaryHeadingPropsAs | ErrorSummaryHeadingPropsAsChild)\n>(({ children, as: Tag, autoFocus = true, ...rest }, ref) => {\n const focusRef = useRef<HTMLElement>(null);\n const mergedRef = useMergeRefs([focusRef, ref]);\n\n useEffect(() => {\n /**\n * Hack: Safari 18 on mac at the time of writing\n * does not correctly focus it with VoiceOver without the timeout\n */\n setTimeout(() => {\n if (focusRef.current && autoFocus) {\n focusRef.current.focus();\n }\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps -- Only on initial render\n }, []);\n\n return (\n <Message.Title ref={mergedRef} tabIndex={-1} asChild {...rest}>\n {Tag ? <Tag>{children}</Tag> : children}\n </Message.Title>\n );\n});\nErrorSummaryHeading.displayName = \"ErrorSummary.Heading\";\n\nexport interface ErrorSummaryListProps extends ListProps {\n /**\n * Sets the size of the items (font)\n *\n * @default \"small\"\n */\n size?: ListProps[\"size\"];\n}\nexport const ErrorSummaryList = forwardRef<HTMLUListElement, ErrorSummaryListProps>(\n ({ children, style: _style, size = \"small\", ...rest }, ref) => {\n const style = {\n // Match the link `solid` style, which black underline\n \"--_hds-list-marker-color\": \"var(--hds-ui-colors-black)\",\n ..._style,\n };\n return (\n <Message.Description asChild>\n <UnorderedList size={size} ref={ref} style={style} {...rest}>\n {children}\n </UnorderedList>\n </Message.Description>\n );\n },\n);\nErrorSummaryList.displayName = \"ErrorSummary.List\";\n\nexport interface ErrorSummaryItemProps extends React.HTMLAttributes<HTMLLIElement> {\n /**\n * A hash link to the element that the error message refers to\n *\n * Must start with \"#\" as it's passed to the `href` attribute of an anchor element\n *\n * @example \"#email\"\n */\n href: `#${string}`;\n\n /**\n * Extra props to pass to the link element\n */\n linkProps?: React.AnchorHTMLAttributes<HTMLAnchorElement>;\n}\nexport const ErrorSummaryItem = forwardRef<HTMLLIElement, ErrorSummaryItemProps>(\n ({ children, href, linkProps, ...rest }, ref) => {\n function onClick(e: React.MouseEvent<HTMLAnchorElement>) {\n linkProps?.onClick?.(e);\n if (focusWithLegendOrLabelInViewport(href.replace(\"#\", \"\"))) {\n e.preventDefault();\n }\n }\n\n return (\n <li ref={ref} {...rest}>\n <Link size=\"small\" href={href} variant=\"solid\" {...linkProps} onClick={onClick}>\n {children}\n </Link>\n </li>\n );\n },\n);\nErrorSummaryItem.displayName = \"ErrorSummary.Item\";\n\nexport type ErrorSummaryProps = Omit<MessageProps, \"variant\" | \"icon\" | \"iconClassName\">;\n\nexport const ErrorSummary = forwardRef<HTMLDivElement, ErrorSummaryProps>(\n ({ children, ...rest }, ref) => {\n return (\n <Message variant=\"warning\" ref={ref} {...rest}>\n {children}\n </Message>\n );\n },\n) as ErrorSummaryType;\nErrorSummary.displayName = \"ErrorSummary\";\n\ntype ErrorSummaryType = ReturnType<typeof forwardRef<HTMLDivElement, ErrorSummaryProps>> & {\n Heading: typeof ErrorSummaryHeading;\n List: typeof ErrorSummaryList;\n Item: typeof ErrorSummaryItem;\n};\nErrorSummary.Heading = ErrorSummaryHeading;\nErrorSummary.List = ErrorSummaryList;\nErrorSummary.Item = ErrorSummaryItem;\n","import { forwardRef } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { Box, type BoxProps } from \"../box/box\";\n\nexport interface MessageTitleProps extends React.HTMLAttributes<HTMLParagraphElement> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\nexport const MessageTitle = forwardRef<HTMLParagraphElement, MessageTitleProps>(\n ({ asChild, className, ...rest }, ref) => {\n const Component = asChild ? Slot : \"div\";\n return (\n <Component\n className={clsx(\"hds-message__title\", className as undefined)}\n ref={ref}\n {...rest}\n />\n );\n },\n);\nMessageTitle.displayName = \"Message.Title\";\n\nexport interface MessageDescriptionProps extends React.HTMLAttributes<HTMLParagraphElement> {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\nexport const MessageDescription = forwardRef<HTMLParagraphElement, MessageDescriptionProps>(\n ({ asChild, className, ...rest }, ref) => {\n const Component = asChild ? Slot : \"div\";\n return (\n <Component\n className={clsx(\"hds-message__description\", className as undefined)}\n ref={ref}\n {...rest}\n />\n );\n },\n);\nMessageDescription.displayName = \"Message.Description\";\n\nexport type MessageProps = (\n | {\n variant?: \"success\" | \"attention\" | \"warning\" | \"info\";\n icon?: never;\n iconClassName?: never;\n }\n | {\n variant: \"neutral\";\n icon?: React.ReactNode;\n iconClassName?: string;\n }\n) &\n Omit<BoxProps, \"variant\" | \"asChild\">;\n\nexport const Message = forwardRef<HTMLDivElement, MessageProps>(\n ({ children, className, variant = \"success\", icon, iconClassName, ...rest }, ref) => {\n return (\n <Box\n className={clsx(`hds-message`, `hds-message--${variant}`, className as undefined)}\n ref={ref}\n {...rest}\n >\n {variant === \"neutral\" && (\n <div className={clsx(\"hds-message--neutral__icon\", iconClassName as undefined)}>\n {icon}\n </div>\n )}\n {children}\n </Box>\n );\n },\n) as MessageType;\nMessage.displayName = \"Message\";\n\ntype MessageType = ReturnType<typeof forwardRef<HTMLDivElement, MessageProps>> & {\n Title: typeof MessageTitle;\n Description: typeof MessageDescription;\n};\nMessage.Title = MessageTitle;\nMessage.Description = MessageDescription;\n","import { forwardRef, useCallback, useState } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot, Slottable } from \"@radix-ui/react-slot\";\n\nexport type BoxCloseButtonProps = Omit<React.HTMLAttributes<HTMLButtonElement>, \"children\">;\nexport const BoxCloseButton = forwardRef<HTMLButtonElement, BoxCloseButtonProps>(\n ({ className, ...rest }, ref) => {\n return (\n <button\n className={clsx(\"hds-box__close-button\", className as undefined)}\n ref={ref}\n type=\"button\"\n {...rest}\n />\n );\n },\n);\nBoxCloseButton.displayName = \"Box.CloseButton\";\n\nexport interface BoxProps extends React.HTMLAttributes<HTMLDivElement> {\n children?: React.ReactNode;\n\n /**\n * Color variant of the box\n *\n * @default \"light-grey\"\n */\n variant?: \"light-grey\" | \"lighter\" | \"white\" | \"warning\";\n\n /**\n * If `true`, a close button will be shown.\n * Use when you want to control the close button using the BoxCloseButton component.\n *\n * @default false\n */\n closeable?: boolean;\n\n /**\n * Callback fired when the component requests to be closed.\n * If not set, the component will be closed without any user interaction.\n *\n * If set, and the handler returns non-true value, the component will not be closed.\n * Use this if you want to control the closing of the component, using the `closed` prop\n *\n * If set, and the handler returns the true, the component will be closed.\n * Use this with `window.confirm()` to ask the user to confirm closing the component.\n */\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents -- It's fine, I want to have the boolean in the type\n onClose?: () => boolean | unknown;\n\n /**\n * If `true`, the box will be closed and hidden from view\n */\n closed?: boolean;\n\n /**\n * Props applied to the close button element.\n */\n closeButtonProps?: BoxCloseButtonProps;\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\nexport const Box = forwardRef<HTMLDivElement, BoxProps>(\n (\n {\n asChild,\n variant,\n closeable = false,\n onClose: onCloseProp,\n closed: closedProp,\n closeButtonProps,\n children,\n className,\n ...rest\n },\n ref,\n ) => {\n const [closedState, setClosedState] = useState(false);\n const onClose = useCallback(() => {\n if (onCloseProp) {\n const result = onCloseProp();\n if (result === true) {\n setClosedState(true);\n }\n } else {\n setClosedState(true);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps -- I know better\n }, []);\n const closed = closedProp ?? closedState;\n const Component = asChild ? Slot : \"div\";\n\n return (\n <Component\n className={clsx(\n \"hds-box\",\n variant && `hds-box--${variant}`,\n { \"hds-box--closed\": closed },\n className as undefined,\n )}\n ref={ref}\n {...rest}\n >\n {closeable ? <BoxCloseButton onClick={onClose} {...closeButtonProps} /> : null}\n <Slottable>{children}</Slottable>\n </Component>\n );\n },\n) as BoxType;\nBox.displayName = \"Box\";\n\nBox.CloseButton = BoxCloseButton;\n\ntype BoxType = ReturnType<typeof forwardRef<HTMLDivElement, BoxProps>> & {\n CloseButton: typeof BoxCloseButton;\n};\n","import { forwardRef, type HTMLAttributes } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\n\nexport interface ListProps extends HTMLAttributes<HTMLOListElement | HTMLUListElement> {\n /**\n * Sets the size of the items (font)\n *\n * @default \"medium\"\n */\n size?: \"default\" | \"small\" | \"technical\" | \"medium\" | \"large\";\n}\n\n/**\n * An unordered list of simple items, often text. You can nest other lists inside this component.\n *\n * If you have other list needs, you can build your own using the semantic `ul` and `ol` tags.\n *\n * @example\n * ```tsx\n * <UnorderedList>\n * <li>Item 1</li>\n * <li>Item 2</li>\n * <li>Item 3</li>\n * </UnorderedList>\n * ```\n */\nexport const UnorderedList = forwardRef<HTMLUListElement, ListProps>(\n ({ size = \"default\", className, ...rest }, ref) => {\n return (\n <ul\n ref={ref}\n className={clsx(\n \"hds-list\",\n size !== \"default\" && `hds-list--${size}`,\n className as undefined,\n )}\n {...rest}\n />\n );\n },\n);\nUnorderedList.displayName = \"UnorderedList\";\n\n/**\n * An ordered list of simple items\n *\n * If you have other list needs, you can build your own using the semantic `ul` and `ol` tags.\n *\n * @example\n * ```tsx\n * <OrderedList>\n * <li>Item 1</li>\n * <li>Item 2</li>\n * <li>Item 3</li>\n * </OrderedList>\n * ```\n */\nexport const OrderedList = forwardRef<HTMLOListElement, ListProps>(\n ({ size = \"medium\", className, ...rest }, ref) => {\n return (\n <ol\n ref={ref}\n className={clsx(\n \"hds-list\",\n size !== \"default\" && `hds-list--${size}`,\n className as undefined,\n )}\n {...rest}\n />\n );\n },\n);\nOrderedList.displayName = \"OrderedList\";\n","import * as React from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { forwardRef } from \"react\";\nimport { Slot } from \"@radix-ui/react-slot\";\n\nexport interface LinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {\n /**\n * The visual style of the link\n */\n variant?: \"underline\" | \"solid\" | \"inverted\" | \"no-underline\" | \"inverted-no-underline\";\n\n /**\n * Font size of the link\n * @default \"default\"\n */\n size?: \"default\" | \"small\" | \"large\" | \"technical\";\n\n /**\n * Specify that there is an icon in the link.\n * `icon=\"leading\"`: There is an icon before the text.\n * `icon=\"trailing\"`: There is an icon after the text.\n *\n */\n icon?: \"leading\" | \"trailing\";\n\n children: React.ReactNode;\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\nexport const Link = forwardRef<HTMLAnchorElement, LinkProps>(\n (\n { asChild, children, variant = \"underline\", size = \"default\", icon, className, ...rest },\n ref,\n ) => {\n const Component = asChild ? Slot : \"a\";\n\n return (\n <Component\n className={clsx(\n \"hds-link\",\n variant !== \"underline\" && `hds-link--${variant}`,\n size !== \"default\" && `hds-link--${size}`,\n { \"hds-link--trailing-icon\": icon === \"trailing\" },\n { \"hds-link--leading-icon\": icon === \"leading\" },\n className as undefined,\n )}\n ref={ref}\n {...rest}\n >\n {children}\n </Component>\n );\n },\n);\nLink.displayName = \"Link\";\n","import * as React from \"react\";\nimport { useCallback, useEffect, useState } 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\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 * Focus a form field while showing the associated legend or label in the viewport.\n *\n * Gives the user a better context of what field they are focusing on.\n *\n * Copied from https://github.com/alphagov/govuk-frontend/blob/cbf4ef1e329711be5b78a92bda6ba84a7db9ca40/packages/govuk-frontend/src/govuk/components/error-summary/error-summary.mjs#L60-L108\n */\nexport function focusWithLegendOrLabelInViewport(id: string) {\n const input = document.getElementById(id);\n if (!input) {\n return false;\n }\n\n const legendOrLabel = maybeLegendForInput(input) ?? labelForInput(input);\n if (!legendOrLabel) {\n return false;\n }\n\n legendOrLabel.scrollIntoView();\n input.focus({ preventScroll: true });\n\n return true;\n}\n\nfunction maybeLegendForInput(input: HTMLElement) {\n const fieldset = input.closest(\"fieldset\");\n if (!fieldset) {\n return null;\n }\n\n const legend = fieldset.querySelector(\"legend\");\n if (!legend) {\n return null;\n }\n\n // If the input type is radio or checkbox, always use the legend if\n // there is one.\n if (input instanceof HTMLInputElement && (input.type === \"checkbox\" || input.type === \"radio\")) {\n return legend;\n }\n\n // For other input types, only scroll to the fieldset’s legend (instead\n // of the label associated with the input) if the input would end up in\n // the top half of the screen.\n //\n // This should avoid situations where the input either ends up off the\n // screen, or obscured by a software keyboard.\n const legendTop = legend.getBoundingClientRect().top;\n const inputRect = input.getBoundingClientRect();\n\n // If the browser doesn't support Element.getBoundingClientRect().height\n // or window.innerHeight (like IE8), bail and just link to the label.\n if (inputRect.height && window.innerHeight) {\n const inputBottom = inputRect.top + inputRect.height;\n\n if (inputBottom - legendTop < window.innerHeight / 2) {\n return legend;\n }\n }\n}\n\nfunction labelForInput(input: HTMLElement) {\n return (\n document.querySelector(`label[for='${input.getAttribute(\"id\")}']`) ?? input.closest(\"label\")\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,gBAA8C;;;ACA9C,IAAAC,gBAA2B;AAC3B,IAAAC,0BAAqB;AACrB,IAAAC,qBAAqB;;;ACFrB,mBAAkD;AAClD,6BAAqB;AACrB,wBAAgC;AAM1B;AAHC,IAAM,qBAAiB;AAAA,EAC5B,CAAC,IAAwB,QAAQ;AAAhC,iBAAE,YANL,IAMG,IAAgB,iBAAhB,IAAgB,CAAd;AACD,WACE;AAAA,MAAC;AAAA;AAAA,QACC,eAAW,6BAAK,yB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AQ,MAAY,SAAQ,WAAY,YAAlD,EAA6D,SAC3D,WACH,IACF;AAAA,EAEJ;AACF;AACA,iBAAiB,cAAc;AAIxB,IAAM,mBAAe;AAAA,EAC1B,CAAC,IAAuB,QAAQ;AAA/B,iBAAE,WArIL,IAqIG,IAAe,iBAAf,IAAe,CAAb;AACD,WACE,6CAAC,wCAAQ,SAAQ,WAAU,OAAc,OAAxC,EACE,WACH;AAAA,EAEJ;AACF;AACA,aAAa,cAAc;AAO3B,aAAa,UAAU;AACvB,aAAa,OAAO;AACpB,aAAa,OAAO;","names":["import_react","import_react","import_typed_classname","import_react_slot","import_jsx_runtime","import_react","import_typed_classname","import_jsx_runtime","import_typed_classname","import_react","import_react_slot","import_jsx_runtime","React","import_react","import_jsx_runtime","_a"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/form/error-summary/error-summary.tsx","../../../src/box/box.tsx","../../../src/list/list.tsx","../../../src/link/link.tsx","../../../src/utils/utils.ts","../../../src/form/error-summary/focus.ts"],"sourcesContent":["import { forwardRef, useEffect, useRef, type HTMLAttributes } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot } from \"@radix-ui/react-slot\";\nimport { Box, type BoxProps } from \"../../box\";\nimport { UnorderedList, type ListProps } from \"../../list\";\nimport { Link } from \"../../link\";\nimport { useMergeRefs } from \"../../utils\";\nimport { focusWithLegendOrLabelInViewport } from \"./focus\";\n\ninterface ErrorSummaryHeadingPropsAutoFocus {\n /**\n * The heading will be focused when the component mounts\n *\n * On following errornous form submissions you should manually focus the heading\n * e.g. by passing a ref and calling `ref.current.focus()`\n *\n * @default true\n */\n autoFocus?: boolean;\n}\n\ninterface ErrorSummaryHeadingPropsAs {\n /**\n * A heading level must be selected, or optionally opting out for a different element\n *\n * Use {@link ErrorSummaryHeadingPropsAsChild.asChild} if you need more control of the rendered element.\n */\n as: \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\" | \"span\" | \"div\" | \"label\" | \"p\";\n asChild?: never;\n}\n\ninterface ErrorSummaryHeadingPropsAsChild {\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n */\n asChild: true;\n as?: never;\n}\n\nexport type ErrorSummaryHeadingProps = HTMLAttributes<HTMLElement> &\n ErrorSummaryHeadingPropsAutoFocus &\n (ErrorSummaryHeadingPropsAs | ErrorSummaryHeadingPropsAsChild);\n\nexport const ErrorSummaryHeading = forwardRef<\n HTMLParagraphElement,\n ErrorSummaryHeadingProps & (ErrorSummaryHeadingPropsAs | ErrorSummaryHeadingPropsAsChild)\n>(({ asChild, children, as: Tag, autoFocus = true, ...rest }, ref) => {\n const focusRef = useRef<HTMLElement>(null);\n const mergedRef = useMergeRefs([focusRef, ref]);\n const Component = asChild ? Slot : Tag;\n\n useEffect(() => {\n /**\n * Hack: Safari 18 on mac at the time of writing\n * does not correctly focus it with VoiceOver without the timeout\n */\n setTimeout(() => {\n if (focusRef.current && autoFocus) {\n focusRef.current.focus();\n }\n });\n // eslint-disable-next-line react-hooks/exhaustive-deps -- Only on initial render\n }, []);\n\n return (\n <Component className={clsx(`hds-error-summary__title`)} ref={mergedRef} tabIndex={-1} {...rest}>\n {children}\n </Component>\n );\n});\nErrorSummaryHeading.displayName = \"ErrorSummary.Heading\";\n\nexport interface ErrorSummaryListProps extends ListProps {\n /**\n * Sets the size of the items (font)\n *\n * @default \"small\"\n */\n size?: ListProps[\"size\"];\n}\nexport const ErrorSummaryList = forwardRef<HTMLUListElement, ErrorSummaryListProps>(\n ({ children, size = \"small\", ...rest }, ref) => (\n <UnorderedList size={size} ref={ref} {...rest}>\n {children}\n </UnorderedList>\n ),\n);\nErrorSummaryList.displayName = \"ErrorSummary.List\";\n\nexport interface ErrorSummaryItemProps extends React.HTMLAttributes<HTMLLIElement> {\n /**\n * A hash link to the element that the error message refers to\n *\n * Must start with \"#\" as it's passed to the `href` attribute of an anchor element\n *\n * @example \"#email\"\n */\n href: `#${string}`;\n\n /**\n * Extra props to pass to the link element\n */\n linkProps?: React.AnchorHTMLAttributes<HTMLAnchorElement>;\n}\nexport const ErrorSummaryItem = forwardRef<HTMLLIElement, ErrorSummaryItemProps>(\n ({ children, href, linkProps, ...rest }, ref) => {\n function onClick(e: React.MouseEvent<HTMLAnchorElement>) {\n linkProps?.onClick?.(e);\n if (focusWithLegendOrLabelInViewport(href.replace(\"#\", \"\"))) {\n e.preventDefault();\n }\n }\n\n return (\n <li className={clsx(`hds-error-summary__list-item`)} ref={ref} {...rest}>\n <Link\n size=\"small\"\n href={href}\n variant=\"inverted-no-underline\"\n {...linkProps}\n onClick={onClick}\n >\n {children}\n </Link>\n </li>\n );\n },\n);\nErrorSummaryItem.displayName = \"ErrorSummary.Item\";\n\nexport type ErrorSummaryProps = Omit<\n BoxProps,\n \"variant\" | \"closeable\" | \"onClose\" | \"closed\" | \"closeButtonProps\"\n>;\n\nexport const ErrorSummary = forwardRef<HTMLDivElement, ErrorSummaryProps>(\n ({ children, className, ...rest }, ref) => (\n <Box ref={ref} {...rest} className={clsx(`hds-error-summary`, className as undefined)}>\n {children}\n </Box>\n ),\n) as ErrorSummaryType;\nErrorSummary.displayName = \"ErrorSummary\";\n\ntype ErrorSummaryType = ReturnType<typeof forwardRef<HTMLDivElement, ErrorSummaryProps>> & {\n Heading: typeof ErrorSummaryHeading;\n List: typeof ErrorSummaryList;\n Item: typeof ErrorSummaryItem;\n};\nErrorSummary.Heading = ErrorSummaryHeading;\nErrorSummary.List = ErrorSummaryList;\nErrorSummary.Item = ErrorSummaryItem;\n","import { forwardRef, useCallback, useState } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { Slot, Slottable } from \"@radix-ui/react-slot\";\n\nexport type BoxCloseButtonProps = Omit<React.HTMLAttributes<HTMLButtonElement>, \"children\">;\nexport const BoxCloseButton = forwardRef<HTMLButtonElement, BoxCloseButtonProps>(\n ({ className, ...rest }, ref) => {\n return (\n <button\n className={clsx(\"hds-box__close-button\", className as undefined)}\n ref={ref}\n type=\"button\"\n {...rest}\n />\n );\n },\n);\nBoxCloseButton.displayName = \"Box.CloseButton\";\n\nexport interface BoxProps extends React.HTMLAttributes<HTMLDivElement> {\n children?: React.ReactNode;\n\n /**\n * Color variant of the box\n *\n * @default \"light-grey\"\n */\n variant?: \"light-grey\" | \"lighter\" | \"white\" | \"warning\";\n\n /**\n * If `true`, a close button will be shown.\n * Use when you want to control the close button using the BoxCloseButton component.\n *\n * @default false\n */\n closeable?: boolean;\n\n /**\n * Callback fired when the component requests to be closed.\n * If not set, the component will be closed without any user interaction.\n *\n * If set, and the handler returns non-true value, the component will not be closed.\n * Use this if you want to control the closing of the component, using the `closed` prop\n *\n * If set, and the handler returns the true, the component will be closed.\n * Use this with `window.confirm()` to ask the user to confirm closing the component.\n */\n // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents -- It's fine, I want to have the boolean in the type\n onClose?: () => boolean | unknown;\n\n /**\n * If `true`, the box will be closed and hidden from view\n */\n closed?: boolean;\n\n /**\n * Props applied to the close button element.\n */\n closeButtonProps?: BoxCloseButtonProps;\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\nexport const Box = forwardRef<HTMLDivElement, BoxProps>(\n (\n {\n asChild,\n variant,\n closeable = false,\n onClose: onCloseProp,\n closed: closedProp,\n closeButtonProps,\n children,\n className,\n ...rest\n },\n ref,\n ) => {\n const [closedState, setClosedState] = useState(false);\n const onClose = useCallback(() => {\n if (onCloseProp) {\n const result = onCloseProp();\n if (result === true) {\n setClosedState(true);\n }\n } else {\n setClosedState(true);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps -- I know better\n }, []);\n const closed = closedProp ?? closedState;\n const Component = asChild ? Slot : \"div\";\n\n return (\n <Component\n className={clsx(\n \"hds-box\",\n variant && `hds-box--${variant}`,\n { \"hds-box--closed\": closed },\n className as undefined,\n )}\n ref={ref}\n {...rest}\n >\n {closeable ? <BoxCloseButton onClick={onClose} {...closeButtonProps} /> : null}\n <Slottable>{children}</Slottable>\n </Component>\n );\n },\n) as BoxType;\nBox.displayName = \"Box\";\n\nBox.CloseButton = BoxCloseButton;\n\ntype BoxType = ReturnType<typeof forwardRef<HTMLDivElement, BoxProps>> & {\n CloseButton: typeof BoxCloseButton;\n};\n","import { forwardRef, type HTMLAttributes } from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\n\nexport interface ListProps extends HTMLAttributes<HTMLOListElement | HTMLUListElement> {\n /**\n * Sets the size of the items (font)\n *\n * @default \"medium\"\n */\n size?: \"default\" | \"small\" | \"technical\" | \"medium\" | \"large\";\n}\n\n/**\n * An unordered list of simple items, often text. You can nest other lists inside this component.\n *\n * If you have other list needs, you can build your own using the semantic `ul` and `ol` tags.\n *\n * @example\n * ```tsx\n * <UnorderedList>\n * <li>Item 1</li>\n * <li>Item 2</li>\n * <li>Item 3</li>\n * </UnorderedList>\n * ```\n */\nexport const UnorderedList = forwardRef<HTMLUListElement, ListProps>(\n ({ size = \"default\", className, ...rest }, ref) => {\n return (\n <ul\n ref={ref}\n className={clsx(\n \"hds-list\",\n size !== \"default\" && `hds-list--${size}`,\n className as undefined,\n )}\n {...rest}\n />\n );\n },\n);\nUnorderedList.displayName = \"UnorderedList\";\n\n/**\n * An ordered list of simple items\n *\n * If you have other list needs, you can build your own using the semantic `ul` and `ol` tags.\n *\n * @example\n * ```tsx\n * <OrderedList>\n * <li>Item 1</li>\n * <li>Item 2</li>\n * <li>Item 3</li>\n * </OrderedList>\n * ```\n */\nexport const OrderedList = forwardRef<HTMLOListElement, ListProps>(\n ({ size = \"medium\", className, ...rest }, ref) => {\n return (\n <ol\n ref={ref}\n className={clsx(\n \"hds-list\",\n size !== \"default\" && `hds-list--${size}`,\n className as undefined,\n )}\n {...rest}\n />\n );\n },\n);\nOrderedList.displayName = \"OrderedList\";\n","import * as React from \"react\";\nimport { clsx } from \"@postenbring/hedwig-css/typed-classname\";\nimport { forwardRef } from \"react\";\nimport { Slot } from \"@radix-ui/react-slot\";\n\nexport interface LinkProps extends React.AnchorHTMLAttributes<HTMLAnchorElement> {\n /**\n * The visual style of the link\n */\n variant?: \"underline\" | \"solid\" | \"inverted\" | \"no-underline\" | \"inverted-no-underline\";\n\n /**\n * Font size of the link\n * @default \"default\"\n */\n size?: \"default\" | \"small\" | \"large\" | \"technical\";\n\n /**\n * Specify that there is an icon in the link.\n * `icon=\"leading\"`: There is an icon before the text.\n * `icon=\"trailing\"`: There is an icon after the text.\n *\n */\n icon?: \"leading\" | \"trailing\";\n\n children: React.ReactNode;\n\n /**\n * Change the default rendered element for the one passed as a child, merging their props and behavior.\n *\n * @default false\n */\n asChild?: boolean;\n}\n\nexport const Link = forwardRef<HTMLAnchorElement, LinkProps>(\n (\n { asChild, children, variant = \"underline\", size = \"default\", icon, className, ...rest },\n ref,\n ) => {\n const Component = asChild ? Slot : \"a\";\n\n return (\n <Component\n className={clsx(\n \"hds-link\",\n variant !== \"underline\" && `hds-link--${variant}`,\n size !== \"default\" && `hds-link--${size}`,\n { \"hds-link--trailing-icon\": icon === \"trailing\" },\n { \"hds-link--leading-icon\": icon === \"leading\" },\n className as undefined,\n )}\n ref={ref}\n {...rest}\n >\n {children}\n </Component>\n );\n },\n);\nLink.displayName = \"Link\";\n","import * as React from \"react\";\nimport { useCallback, useEffect, useState, version } 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\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","/**\n * Focus a form field while showing the associated legend or label in the viewport.\n *\n * Gives the user a better context of what field they are focusing on.\n *\n * Copied from https://github.com/alphagov/govuk-frontend/blob/cbf4ef1e329711be5b78a92bda6ba84a7db9ca40/packages/govuk-frontend/src/govuk/components/error-summary/error-summary.mjs#L60-L108\n */\nexport function focusWithLegendOrLabelInViewport(id: string) {\n const input = document.getElementById(id);\n if (!input) {\n return false;\n }\n\n const legendOrLabel = maybeLegendForInput(input) ?? labelForInput(input);\n if (!legendOrLabel) {\n return false;\n }\n\n legendOrLabel.scrollIntoView();\n input.focus({ preventScroll: true });\n\n return true;\n}\n\nfunction maybeLegendForInput(input: HTMLElement) {\n const fieldset = input.closest(\"fieldset\");\n if (!fieldset) {\n return null;\n }\n\n const legend = fieldset.querySelector(\"legend\");\n if (!legend) {\n return null;\n }\n\n // If the input type is radio or checkbox, always use the legend if\n // there is one.\n if (input instanceof HTMLInputElement && (input.type === \"checkbox\" || input.type === \"radio\")) {\n return legend;\n }\n\n // For other input types, only scroll to the fieldset’s legend (instead\n // of the label associated with the input) if the input would end up in\n // the top half of the screen.\n //\n // This should avoid situations where the input either ends up off the\n // screen, or obscured by a software keyboard.\n const legendTop = legend.getBoundingClientRect().top;\n const inputRect = input.getBoundingClientRect();\n\n // If the browser doesn't support Element.getBoundingClientRect().height\n // or window.innerHeight (like IE8), bail and just link to the label.\n if (inputRect.height && window.innerHeight) {\n const inputBottom = inputRect.top + inputRect.height;\n\n if (inputBottom - legendTop < window.innerHeight / 2) {\n return legend;\n }\n }\n}\n\nfunction labelForInput(input: HTMLElement) {\n return (\n document.querySelector(`label[for='${input.getAttribute(\"id\")}']`) ?? input.closest(\"label\")\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,gBAAmE;AACnE,IAAAC,0BAAqB;AACrB,IAAAC,qBAAqB;;;ACFrB,mBAAkD;AAClD,6BAAqB;AACrB,wBAAgC;AAM1B;AAHC,IAAM,qBAAiB;AAAA,EAC5B,CAAC,IAAwB,QAAQ;AAAhC,iBAAE,YANL,IAMG,IAAgB,iBAAhB,IAAgB,CAAd;AACD,WACE;AAAA,MAAC;AAAA;AAAA,QACC,eAAW,6BAAK,yBAAyB,SAAsB;AAAA,QAC/D;AAAA,QACA,MAAK;AAAA,SACD;AAAA,IACN;AAAA,EAEJ;AACF;AACA,eAAe,cAAc;AAmDtB,IAAM,UAAM;AAAA,EACjB,CACE,IAWA,QACG;AAZH,iBACE;AAAA;AAAA,MACA;AAAA,MACA,YAAY;AAAA,MACZ,SAAS;AAAA,MACT,QAAQ;AAAA,MACR;AAAA,MACA;AAAA,MACA;AAAA,IA9EN,IAsEI,IASK,iBATL,IASK;AAAA,MARH;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAKF,UAAM,CAAC,aAAa,cAAc,QAAI,uBAAS,KAAK;AACpD,UAAM,cAAU,0BAAY,MAAM;AAChC,UAAI,aAAa;AACf,cAAM,SAAS,YAAY;AAC3B,YAAI,WAAW,MAAM;AACnB,yBAAe,IAAI;AAAA,QACrB;AAAA,MACF,OAAO;AACL,uBAAe,IAAI;AAAA,MACrB;AAAA,IAEF,GAAG,CAAC,CAAC;AACL,UAAM,SAAS,kCAAc;AAC7B,UAAM,YAAY,UAAU,yBAAO;AAEnC,WACE;AAA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,uBAAmB;AAAA,EAC9B,CAAC,IAAuC,QAAK;AAA5C,iBAAE,YAAU,OAAO,QAjFtB,IAiFG,IAA+B,iBAA/B,IAA+B,CAA7B,YAAU;AACX,wDAAC,8CAAc,MAAY,OAAc,OAAxC,EACE,WACH;AAAA;AAEJ;AACA,iBAAiB,cAAc;AAiBxB,IAAM,uBAAmB;AAAA,EAC9B,CAAC,IAAwC,QAAQ;AAAhD,iBAAE,YAAU,MAAM,UAzGrB,IAyGG,IAAgC,iBAAhC,IAAgC,CAA9B,YAAU,QAAM;AACjB,aAAS,QAAQ,GAAwC;AA1G7D,UAAAC;AA2GM,OAAAA,MAAA,uCAAW,YAAX,gBAAAA,IAAA,gBAAqB;AACrB,UAAI,iCAAiC,KAAK,QAAQ,KAAK,EAAE,CAAC,GAAG;AAC3D,UAAE,eAAe;AAAA,MACnB;AAAA,IACF;AAEA,WACE,6CAAC,qCAAG,eAAW,8BAAK,8BAA8B,GAAG,OAAc,OAAlE,EACC;AAAA,MAAC;AAAA;AAAA,QACC,MAAK;AAAA,QACL;AAAA,QACA,SAAQ;AAAA,SACJ,YAJL;AAAA,QAKC;AAAA,QAEC;AAAA;AAAA,IACH,IACF;AAAA,EAEJ;AACF;AACA,iBAAiB,cAAc;AAOxB,IAAM,mBAAe;AAAA,EAC1B,CAAC,IAAkC,QAAK;AAAvC,iBAAE,YAAU,UAxIf,IAwIG,IAA0B,iBAA1B,IAA0B,CAAxB,YAAU;AACX,wDAAC,oCAAI,OAAc,OAAlB,EAAwB,eAAW,8BAAK,qBAAqB,SAAsB,GACjF,WACH;AAAA;AAEJ;AACA,aAAa,cAAc;AAO3B,aAAa,UAAU;AACvB,aAAa,OAAO;AACpB,aAAa,OAAO;","names":["import_react","import_typed_classname","import_react_slot","import_react","import_typed_classname","import_jsx_runtime","import_typed_classname","import_react","import_react_slot","import_jsx_runtime","React","import_react","import_jsx_runtime","_a"]}
|
|
@@ -3,18 +3,17 @@ import {
|
|
|
3
3
|
ErrorSummaryHeading,
|
|
4
4
|
ErrorSummaryItem,
|
|
5
5
|
ErrorSummaryList
|
|
6
|
-
} from "../../chunk-
|
|
6
|
+
} from "../../chunk-W7CPW23K.mjs";
|
|
7
7
|
import "../../chunk-CKAL5ZJZ.mjs";
|
|
8
|
-
import "../../chunk-CYDWEPFL.mjs";
|
|
9
|
-
import "../../chunk-KCEWKQ4W.mjs";
|
|
10
|
-
import "../../chunk-ILFK3VKS.mjs";
|
|
11
8
|
import "../../chunk-XLLYMQLW.mjs";
|
|
12
9
|
import "../../chunk-OHDHIRAW.mjs";
|
|
13
10
|
import "../../chunk-6QV3OV66.mjs";
|
|
14
|
-
import "../../chunk-RC76SXBP.mjs";
|
|
15
|
-
import "../../chunk-BYFBK3J7.mjs";
|
|
16
11
|
import "../../chunk-OS24UCTD.mjs";
|
|
17
12
|
import "../../chunk-3QHKPEXO.mjs";
|
|
13
|
+
import "../../chunk-BCFV6VOE.mjs";
|
|
14
|
+
import "../../chunk-CYDWEPFL.mjs";
|
|
15
|
+
import "../../chunk-GYI4NCUY.mjs";
|
|
16
|
+
import "../../chunk-77M2ZTP7.mjs";
|
|
18
17
|
import "../../chunk-3OGHJOJF.mjs";
|
|
19
18
|
import "../../chunk-YOSPWY5K.mjs";
|
|
20
19
|
export {
|
|
@@ -64,12 +64,9 @@ __export(error_summary_exports, {
|
|
|
64
64
|
module.exports = __toCommonJS(error_summary_exports);
|
|
65
65
|
|
|
66
66
|
// src/form/error-summary/error-summary.tsx
|
|
67
|
-
var
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
var import_react2 = require("react");
|
|
71
|
-
var import_typed_classname2 = require("@postenbring/hedwig-css/typed-classname");
|
|
72
|
-
var import_react_slot2 = require("@radix-ui/react-slot");
|
|
67
|
+
var import_react5 = require("react");
|
|
68
|
+
var import_typed_classname4 = require("@postenbring/hedwig-css/typed-classname");
|
|
69
|
+
var import_react_slot3 = require("@radix-ui/react-slot");
|
|
73
70
|
|
|
74
71
|
// src/box/box.tsx
|
|
75
72
|
var import_react = require("react");
|
|
@@ -146,69 +143,18 @@ var Box = (0, import_react.forwardRef)(
|
|
|
146
143
|
Box.displayName = "Box";
|
|
147
144
|
Box.CloseButton = BoxCloseButton;
|
|
148
145
|
|
|
149
|
-
// src/message/message.tsx
|
|
150
|
-
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
151
|
-
var MessageTitle = (0, import_react2.forwardRef)(
|
|
152
|
-
(_a, ref) => {
|
|
153
|
-
var _b = _a, { asChild, className } = _b, rest = __objRest(_b, ["asChild", "className"]);
|
|
154
|
-
const Component = asChild ? import_react_slot2.Slot : "div";
|
|
155
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
156
|
-
Component,
|
|
157
|
-
__spreadValues({
|
|
158
|
-
className: (0, import_typed_classname2.clsx)("hds-message__title", className),
|
|
159
|
-
ref
|
|
160
|
-
}, rest)
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
);
|
|
164
|
-
MessageTitle.displayName = "Message.Title";
|
|
165
|
-
var MessageDescription = (0, import_react2.forwardRef)(
|
|
166
|
-
(_a, ref) => {
|
|
167
|
-
var _b = _a, { asChild, className } = _b, rest = __objRest(_b, ["asChild", "className"]);
|
|
168
|
-
const Component = asChild ? import_react_slot2.Slot : "div";
|
|
169
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
170
|
-
Component,
|
|
171
|
-
__spreadValues({
|
|
172
|
-
className: (0, import_typed_classname2.clsx)("hds-message__description", className),
|
|
173
|
-
ref
|
|
174
|
-
}, rest)
|
|
175
|
-
);
|
|
176
|
-
}
|
|
177
|
-
);
|
|
178
|
-
MessageDescription.displayName = "Message.Description";
|
|
179
|
-
var Message = (0, import_react2.forwardRef)(
|
|
180
|
-
(_a, ref) => {
|
|
181
|
-
var _b = _a, { children, className, variant = "success", icon, iconClassName } = _b, rest = __objRest(_b, ["children", "className", "variant", "icon", "iconClassName"]);
|
|
182
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
183
|
-
Box,
|
|
184
|
-
__spreadProps(__spreadValues({
|
|
185
|
-
className: (0, import_typed_classname2.clsx)(`hds-message`, `hds-message--${variant}`, className),
|
|
186
|
-
ref
|
|
187
|
-
}, rest), {
|
|
188
|
-
children: [
|
|
189
|
-
variant === "neutral" && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: (0, import_typed_classname2.clsx)("hds-message--neutral__icon", iconClassName), children: icon }),
|
|
190
|
-
children
|
|
191
|
-
]
|
|
192
|
-
})
|
|
193
|
-
);
|
|
194
|
-
}
|
|
195
|
-
);
|
|
196
|
-
Message.displayName = "Message";
|
|
197
|
-
Message.Title = MessageTitle;
|
|
198
|
-
Message.Description = MessageDescription;
|
|
199
|
-
|
|
200
146
|
// src/list/list.tsx
|
|
201
|
-
var
|
|
202
|
-
var
|
|
203
|
-
var
|
|
204
|
-
var UnorderedList = (0,
|
|
147
|
+
var import_react2 = require("react");
|
|
148
|
+
var import_typed_classname2 = require("@postenbring/hedwig-css/typed-classname");
|
|
149
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
150
|
+
var UnorderedList = (0, import_react2.forwardRef)(
|
|
205
151
|
(_a, ref) => {
|
|
206
152
|
var _b = _a, { size = "default", className } = _b, rest = __objRest(_b, ["size", "className"]);
|
|
207
|
-
return /* @__PURE__ */ (0,
|
|
153
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
208
154
|
"ul",
|
|
209
155
|
__spreadValues({
|
|
210
156
|
ref,
|
|
211
|
-
className: (0,
|
|
157
|
+
className: (0, import_typed_classname2.clsx)(
|
|
212
158
|
"hds-list",
|
|
213
159
|
size !== "default" && `hds-list--${size}`,
|
|
214
160
|
className
|
|
@@ -218,14 +164,14 @@ var UnorderedList = (0, import_react3.forwardRef)(
|
|
|
218
164
|
}
|
|
219
165
|
);
|
|
220
166
|
UnorderedList.displayName = "UnorderedList";
|
|
221
|
-
var OrderedList = (0,
|
|
167
|
+
var OrderedList = (0, import_react2.forwardRef)(
|
|
222
168
|
(_a, ref) => {
|
|
223
169
|
var _b = _a, { size = "medium", className } = _b, rest = __objRest(_b, ["size", "className"]);
|
|
224
|
-
return /* @__PURE__ */ (0,
|
|
170
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
225
171
|
"ol",
|
|
226
172
|
__spreadValues({
|
|
227
173
|
ref,
|
|
228
|
-
className: (0,
|
|
174
|
+
className: (0, import_typed_classname2.clsx)(
|
|
229
175
|
"hds-list",
|
|
230
176
|
size !== "default" && `hds-list--${size}`,
|
|
231
177
|
className
|
|
@@ -238,18 +184,18 @@ OrderedList.displayName = "OrderedList";
|
|
|
238
184
|
|
|
239
185
|
// src/link/link.tsx
|
|
240
186
|
var React = require("react");
|
|
241
|
-
var
|
|
242
|
-
var
|
|
243
|
-
var
|
|
244
|
-
var
|
|
245
|
-
var Link = (0,
|
|
187
|
+
var import_typed_classname3 = require("@postenbring/hedwig-css/typed-classname");
|
|
188
|
+
var import_react3 = require("react");
|
|
189
|
+
var import_react_slot2 = require("@radix-ui/react-slot");
|
|
190
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
191
|
+
var Link = (0, import_react3.forwardRef)(
|
|
246
192
|
(_a, ref) => {
|
|
247
193
|
var _b = _a, { asChild, children, variant = "underline", size = "default", icon, className } = _b, rest = __objRest(_b, ["asChild", "children", "variant", "size", "icon", "className"]);
|
|
248
|
-
const Component = asChild ?
|
|
249
|
-
return /* @__PURE__ */ (0,
|
|
194
|
+
const Component = asChild ? import_react_slot2.Slot : "a";
|
|
195
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
250
196
|
Component,
|
|
251
197
|
__spreadProps(__spreadValues({
|
|
252
|
-
className: (0,
|
|
198
|
+
className: (0, import_typed_classname3.clsx)(
|
|
253
199
|
"hds-link",
|
|
254
200
|
variant !== "underline" && `hds-link--${variant}`,
|
|
255
201
|
size !== "default" && `hds-link--${size}`,
|
|
@@ -268,7 +214,7 @@ Link.displayName = "Link";
|
|
|
268
214
|
|
|
269
215
|
// src/utils/utils.ts
|
|
270
216
|
var React2 = __toESM(require("react"));
|
|
271
|
-
var
|
|
217
|
+
var import_react4 = require("react");
|
|
272
218
|
function useMergeRefs(refs) {
|
|
273
219
|
return React2.useMemo(() => {
|
|
274
220
|
if (refs.every((ref) => ref === null)) {
|
|
@@ -285,6 +231,7 @@ function useMergeRefs(refs) {
|
|
|
285
231
|
};
|
|
286
232
|
}, refs);
|
|
287
233
|
}
|
|
234
|
+
var inertBooleanSupported = Number(import_react4.version.split(".")[0]) >= 19;
|
|
288
235
|
|
|
289
236
|
// src/form/error-summary/focus.ts
|
|
290
237
|
function focusWithLegendOrLabelInViewport(id) {
|
|
@@ -328,33 +275,30 @@ function labelForInput(input) {
|
|
|
328
275
|
}
|
|
329
276
|
|
|
330
277
|
// src/form/error-summary/error-summary.tsx
|
|
331
|
-
var
|
|
332
|
-
var ErrorSummaryHeading = (0,
|
|
333
|
-
var _b = _a, { children, as: Tag, autoFocus = true } = _b, rest = __objRest(_b, ["children", "as", "autoFocus"]);
|
|
334
|
-
const focusRef = (0,
|
|
278
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
279
|
+
var ErrorSummaryHeading = (0, import_react5.forwardRef)((_a, ref) => {
|
|
280
|
+
var _b = _a, { asChild, children, as: Tag, autoFocus = true } = _b, rest = __objRest(_b, ["asChild", "children", "as", "autoFocus"]);
|
|
281
|
+
const focusRef = (0, import_react5.useRef)(null);
|
|
335
282
|
const mergedRef = useMergeRefs([focusRef, ref]);
|
|
336
|
-
|
|
283
|
+
const Component = asChild ? import_react_slot3.Slot : Tag;
|
|
284
|
+
(0, import_react5.useEffect)(() => {
|
|
337
285
|
setTimeout(() => {
|
|
338
286
|
if (focusRef.current && autoFocus) {
|
|
339
287
|
focusRef.current.focus();
|
|
340
288
|
}
|
|
341
289
|
});
|
|
342
290
|
}, []);
|
|
343
|
-
return /* @__PURE__ */ (0,
|
|
291
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Component, __spreadProps(__spreadValues({ className: (0, import_typed_classname4.clsx)(`hds-error-summary__title`), ref: mergedRef, tabIndex: -1 }, rest), { children }));
|
|
344
292
|
});
|
|
345
293
|
ErrorSummaryHeading.displayName = "ErrorSummary.Heading";
|
|
346
|
-
var ErrorSummaryList = (0,
|
|
294
|
+
var ErrorSummaryList = (0, import_react5.forwardRef)(
|
|
347
295
|
(_a, ref) => {
|
|
348
|
-
var _b = _a, { children,
|
|
349
|
-
|
|
350
|
-
// Match the link `solid` style, which black underline
|
|
351
|
-
"--_hds-list-marker-color": "var(--hds-ui-colors-black)"
|
|
352
|
-
}, _style);
|
|
353
|
-
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Message.Description, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(UnorderedList, __spreadProps(__spreadValues({ size, ref, style }, rest), { children })) });
|
|
296
|
+
var _b = _a, { children, size = "small" } = _b, rest = __objRest(_b, ["children", "size"]);
|
|
297
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(UnorderedList, __spreadProps(__spreadValues({ size, ref }, rest), { children }));
|
|
354
298
|
}
|
|
355
299
|
);
|
|
356
300
|
ErrorSummaryList.displayName = "ErrorSummary.List";
|
|
357
|
-
var ErrorSummaryItem = (0,
|
|
301
|
+
var ErrorSummaryItem = (0, import_react5.forwardRef)(
|
|
358
302
|
(_a, ref) => {
|
|
359
303
|
var _b = _a, { children, href, linkProps } = _b, rest = __objRest(_b, ["children", "href", "linkProps"]);
|
|
360
304
|
function onClick(e) {
|
|
@@ -364,14 +308,24 @@ var ErrorSummaryItem = (0, import_react6.forwardRef)(
|
|
|
364
308
|
e.preventDefault();
|
|
365
309
|
}
|
|
366
310
|
}
|
|
367
|
-
return /* @__PURE__ */ (0,
|
|
311
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("li", __spreadProps(__spreadValues({ className: (0, import_typed_classname4.clsx)(`hds-error-summary__list-item`), ref }, rest), { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
312
|
+
Link,
|
|
313
|
+
__spreadProps(__spreadValues({
|
|
314
|
+
size: "small",
|
|
315
|
+
href,
|
|
316
|
+
variant: "inverted-no-underline"
|
|
317
|
+
}, linkProps), {
|
|
318
|
+
onClick,
|
|
319
|
+
children
|
|
320
|
+
})
|
|
321
|
+
) }));
|
|
368
322
|
}
|
|
369
323
|
);
|
|
370
324
|
ErrorSummaryItem.displayName = "ErrorSummary.Item";
|
|
371
|
-
var ErrorSummary = (0,
|
|
325
|
+
var ErrorSummary = (0, import_react5.forwardRef)(
|
|
372
326
|
(_a, ref) => {
|
|
373
|
-
var _b = _a, { children } = _b, rest = __objRest(_b, ["children"]);
|
|
374
|
-
return /* @__PURE__ */ (0,
|
|
327
|
+
var _b = _a, { children, className } = _b, rest = __objRest(_b, ["children", "className"]);
|
|
328
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Box, __spreadProps(__spreadValues({ ref }, rest), { className: (0, import_typed_classname4.clsx)(`hds-error-summary`, className), children }));
|
|
375
329
|
}
|
|
376
330
|
);
|
|
377
331
|
ErrorSummary.displayName = "ErrorSummary";
|