Skip to content

Commit 814127e

Browse files
author
Fergus Bisset
committed
build: add BehavioursLoader to distribution
1 parent ba43ea8 commit 814127e

File tree

5 files changed

+79
-26
lines changed

5 files changed

+79
-26
lines changed

dist/behaviours/index.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/behaviours/index.js.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/meta/components.json

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"version": "0.0.43",
3-
"generatedAt": "2025-10-22T09:30:39.872Z",
3+
"generatedAt": "2025-10-25T14:16:58.774Z",
44
"count": 18,
55
"components": {
66
"Textarea": {
@@ -387,6 +387,29 @@
387387
],
388388
"source": "src/components/Panel/Panel.schema.ts"
389389
},
390+
"InsetText": {
391+
"name": "InsetText",
392+
"category": "content",
393+
"since": "0.1.1",
394+
"props": [
395+
{
396+
"name": "text",
397+
"type": "string",
398+
"description": "Plain text content (ignored if html is provided)"
399+
},
400+
{
401+
"name": "html",
402+
"type": "string",
403+
"description": "HTML content (overrides text)"
404+
},
405+
{
406+
"name": "className",
407+
"type": "string",
408+
"description": "Additional CSS classes"
409+
}
410+
],
411+
"source": "src/components/InsetText/InsetText.schema.ts"
412+
},
390413
"Label": {
391414
"name": "Label",
392415
"category": "form",
@@ -568,29 +591,6 @@
568591
],
569592
"source": "src/components/Input/Input.schema.ts"
570593
},
571-
"InsetText": {
572-
"name": "InsetText",
573-
"category": "content",
574-
"since": "0.1.1",
575-
"props": [
576-
{
577-
"name": "text",
578-
"type": "string",
579-
"description": "Plain text content (ignored if html is provided)"
580-
},
581-
{
582-
"name": "html",
583-
"type": "string",
584-
"description": "HTML content (overrides text)"
585-
},
586-
{
587-
"name": "className",
588-
"type": "string",
589-
"description": "Additional CSS classes"
590-
}
591-
],
592-
"source": "src/components/InsetText/InsetText.schema.ts"
593-
},
594594
"Hint": {
595595
"name": "Hint",
596596
"category": "typography",
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* BehavioursLoader - React component for loading and initializing behaviours after hydration
3+
*
4+
* This client component ensures behaviours are initialized after React hydration completes,
5+
* preventing SSR/client attribute mismatches and hydration warnings. It dynamically imports
6+
* the behaviours bundle to keep it out of the server chunk.
7+
*
8+
* @example
9+
* ```tsx
10+
* // app/layout.tsx (Next.js App Router)
11+
* import { BehavioursLoader } from '@fergusbisset/nhs-fdp-design-system/behaviours';
12+
*
13+
* export default function RootLayout({ children }) {
14+
* return (
15+
* <html>
16+
* <body>
17+
* {children}
18+
* <BehavioursLoader />
19+
* </body>
20+
* </html>
21+
* );
22+
* }
23+
* ```
24+
*
25+
* @example
26+
* ```tsx
27+
* // Scoped initialization
28+
* <div ref={containerRef}>
29+
* <YourComponents />
30+
* <BehavioursLoader scope={containerRef.current} />
31+
* </div>
32+
* ```
33+
*/
34+
export interface BehavioursLoaderProps {
35+
/**
36+
* Optional scope to limit behaviour initialization to a specific container.
37+
* If not provided, behaviours will be initialized on the entire document.
38+
*/
39+
scope?: ParentNode | null;
40+
/**
41+
* Optional callback invoked after behaviours are successfully initialized.
42+
*/
43+
onInit?: () => void;
44+
/**
45+
* Optional callback invoked if behaviour initialization fails.
46+
*/
47+
onError?: (error: unknown) => void;
48+
}
49+
export declare function BehavioursLoader({ scope, onInit, onError }?: BehavioursLoaderProps): null;

dist/src/behaviours/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,7 @@ export { initCharacterCounts, detachCharacterCounts, } from "./characterCountBeh
55
export { initCheckboxes, detachCheckboxes } from "./checkboxesBehaviour.js";
66
export { initHeaders, detachHeaders } from "./headerBehaviour.js";
77
export { initSkipLinks, detachSkipLinks } from "./skipLinkBehaviour.js";
8+
export { BehavioursLoader } from "./BehavioursLoader.js";
9+
export type { BehavioursLoaderProps } from "./BehavioursLoader.js";
810
export declare function initAll(scope?: ParentNode): void;
911
export declare function teardownAll(scope?: ParentNode): void;

0 commit comments

Comments
 (0)