@genesislcap/foundation-layout 14.368.0 → 14.369.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 (32) hide show
  1. package/dist/custom-elements.json +142 -3
  2. package/dist/dts/index.d.ts +2 -1
  3. package/dist/dts/index.d.ts.map +1 -1
  4. package/dist/dts/main/layout-item.d.ts +20 -0
  5. package/dist/dts/main/layout-item.d.ts.map +1 -1
  6. package/dist/dts/main/layout-main.d.ts +36 -8
  7. package/dist/dts/main/layout-main.d.ts.map +1 -1
  8. package/dist/dts/utils/factory-registry.d.ts +63 -0
  9. package/dist/dts/utils/factory-registry.d.ts.map +1 -0
  10. package/dist/dts/utils/index.d.ts +1 -0
  11. package/dist/dts/utils/index.d.ts.map +1 -1
  12. package/dist/dts/utils/types.d.ts +44 -3
  13. package/dist/dts/utils/types.d.ts.map +1 -1
  14. package/dist/esm/index.js +1 -0
  15. package/dist/esm/main/layout-item.js +26 -4
  16. package/dist/esm/main/layout-main.js +169 -46
  17. package/dist/esm/utils/factory-registry.js +88 -0
  18. package/dist/esm/utils/index.js +1 -0
  19. package/dist/foundation-layout.api.json +206 -9
  20. package/dist/foundation-layout.d.ts +156 -9
  21. package/docs/FRAMEWORK_COMPONENTS.md +568 -0
  22. package/docs/api/foundation-layout.componentfactory.md +46 -0
  23. package/docs/api/foundation-layout.foundationlayout.md +2 -2
  24. package/docs/api/foundation-layout.foundationlayout.registeritem.md +31 -7
  25. package/docs/api/foundation-layout.foundationlayoutitem.md +2 -0
  26. package/docs/api/foundation-layout.foundationlayoutitem.registration.md +18 -0
  27. package/docs/api/foundation-layout.getfactory.md +56 -0
  28. package/docs/api/foundation-layout.md +59 -0
  29. package/docs/api/foundation-layout.registerfactory.md +94 -0
  30. package/docs/api/foundation-layout.unregisterfactory.md +63 -0
  31. package/docs/api-report.md.api.md +20 -7
  32. package/package.json +12 -12
@@ -23,6 +23,14 @@
23
23
  "module": "./styles"
24
24
  }
25
25
  },
26
+ {
27
+ "kind": "js",
28
+ "name": "ComponentFactory",
29
+ "declaration": {
30
+ "name": "ComponentFactory",
31
+ "module": "./utils"
32
+ }
33
+ },
26
34
  {
27
35
  "kind": "js",
28
36
  "name": "CustomButton",
@@ -134,6 +142,30 @@
134
142
  "name": "LAYOUT_POPOUT_CONTAINER_CLASS",
135
143
  "module": "./utils"
136
144
  }
145
+ },
146
+ {
147
+ "kind": "js",
148
+ "name": "registerFactory",
149
+ "declaration": {
150
+ "name": "registerFactory",
151
+ "module": "./utils/factory-registry"
152
+ }
153
+ },
154
+ {
155
+ "kind": "js",
156
+ "name": "getFactory",
157
+ "declaration": {
158
+ "name": "getFactory",
159
+ "module": "./utils/factory-registry"
160
+ }
161
+ },
162
+ {
163
+ "kind": "js",
164
+ "name": "unregisterFactory",
165
+ "declaration": {
166
+ "name": "unregisterFactory",
167
+ "module": "./utils/factory-registry"
168
+ }
137
169
  }
138
170
  ]
139
171
  },
@@ -750,11 +782,11 @@
750
782
  "description": "string of the registration ID"
751
783
  },
752
784
  {
753
- "name": "elements",
785
+ "name": "elementsOrFactory",
754
786
  "type": {
755
- "text": "Element[]"
787
+ "text": "Element[] | ComponentFactory"
756
788
  },
757
- "description": "Elements[] containing the reference to the elements to register for later usage"
789
+ "description": "Either Elements[] containing the reference to the elements to register, or a ComponentFactory function"
758
790
  }
759
791
  ],
760
792
  "privacy": "public"
@@ -1404,6 +1436,105 @@
1404
1436
  }
1405
1437
  ]
1406
1438
  },
1439
+ {
1440
+ "kind": "javascript-module",
1441
+ "path": "src/utils/factory-registry.ts",
1442
+ "declarations": [
1443
+ {
1444
+ "kind": "function",
1445
+ "name": "registerFactory",
1446
+ "return": {
1447
+ "type": {
1448
+ "text": "void"
1449
+ }
1450
+ },
1451
+ "parameters": [
1452
+ {
1453
+ "name": "key",
1454
+ "type": {
1455
+ "text": "string"
1456
+ },
1457
+ "description": "Unique identifier for the factory. Should be descriptive and unique across the application."
1458
+ },
1459
+ {
1460
+ "name": "factory",
1461
+ "type": {
1462
+ "text": "ComponentFactory"
1463
+ },
1464
+ "description": "The factory function that creates the component."
1465
+ }
1466
+ ],
1467
+ "description": "Registers a factory function with a unique key.\nThis allows framework components to be used in the declarative layout API\nwithout needing to pass function references through HTML attributes.",
1468
+ "privacy": "public"
1469
+ },
1470
+ {
1471
+ "kind": "function",
1472
+ "name": "getFactory",
1473
+ "return": {
1474
+ "type": {
1475
+ "text": ""
1476
+ }
1477
+ },
1478
+ "parameters": [
1479
+ {
1480
+ "name": "key",
1481
+ "type": {
1482
+ "text": "string"
1483
+ },
1484
+ "description": "The unique identifier for the factory."
1485
+ }
1486
+ ],
1487
+ "description": "Retrieves a factory function by its key.",
1488
+ "privacy": "public"
1489
+ },
1490
+ {
1491
+ "kind": "function",
1492
+ "name": "unregisterFactory",
1493
+ "return": {
1494
+ "type": {
1495
+ "text": ""
1496
+ }
1497
+ },
1498
+ "parameters": [
1499
+ {
1500
+ "name": "key",
1501
+ "type": {
1502
+ "text": "string"
1503
+ },
1504
+ "description": "The unique identifier for the factory to remove."
1505
+ }
1506
+ ],
1507
+ "description": "Removes a factory from the registry.\nThis is useful for cleanup when a component is unmounted or no longer needed.",
1508
+ "privacy": "public"
1509
+ }
1510
+ ],
1511
+ "exports": [
1512
+ {
1513
+ "kind": "js",
1514
+ "name": "registerFactory",
1515
+ "declaration": {
1516
+ "name": "registerFactory",
1517
+ "module": "src/utils/factory-registry.ts"
1518
+ }
1519
+ },
1520
+ {
1521
+ "kind": "js",
1522
+ "name": "getFactory",
1523
+ "declaration": {
1524
+ "name": "getFactory",
1525
+ "module": "src/utils/factory-registry.ts"
1526
+ }
1527
+ },
1528
+ {
1529
+ "kind": "js",
1530
+ "name": "unregisterFactory",
1531
+ "declaration": {
1532
+ "name": "unregisterFactory",
1533
+ "module": "src/utils/factory-registry.ts"
1534
+ }
1535
+ }
1536
+ ]
1537
+ },
1407
1538
  {
1408
1539
  "kind": "javascript-module",
1409
1540
  "path": "src/utils/index.ts",
@@ -1433,6 +1564,14 @@
1433
1564
  "package": "./events"
1434
1565
  }
1435
1566
  },
1567
+ {
1568
+ "kind": "js",
1569
+ "name": "*",
1570
+ "declaration": {
1571
+ "name": "*",
1572
+ "package": "./factory-registry"
1573
+ }
1574
+ },
1436
1575
  {
1437
1576
  "kind": "js",
1438
1577
  "name": "*",
@@ -1,4 +1,5 @@
1
1
  export * from './main';
2
2
  export { LAYOUT_ICONS } from './styles';
3
- export { CustomButton, DEFAULT_RELOAD_BUFFER, LayoutComponentWithState, LayoutEmitEvents, LayoutReceiveEvents, LayoutReceiveEventsDetail, LayoutRegionType, LayoutRegistrationError, LayoutUsageError, Placement, RegisteredElementConfig, RegistrationConfig, SerialisedLayout, LAYOUT_POPOUT_CONTAINER_CLASS, } from './utils';
3
+ export { ComponentFactory, CustomButton, DEFAULT_RELOAD_BUFFER, LayoutComponentWithState, LayoutEmitEvents, LayoutReceiveEvents, LayoutReceiveEventsDetail, LayoutRegionType, LayoutRegistrationError, LayoutUsageError, Placement, RegisteredElementConfig, RegistrationConfig, SerialisedLayout, LAYOUT_POPOUT_CONTAINER_CLASS, } from './utils';
4
+ export { registerFactory, getFactory, unregisterFactory } from './utils/factory-registry';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EACL,YAAY,EACZ,qBAAqB,EACrB,wBAAwB,EACxB,gBAAgB,EAChB,mBAAmB,EACnB,yBAAyB,EACzB,gBAAgB,EAChB,uBAAuB,EACvB,gBAAgB,EAChB,SAAS,EACT,uBAAuB,EACvB,kBAAkB,EAClB,gBAAgB,EAChB,6BAA6B,GAC9B,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,qBAAqB,EACrB,wBAAwB,EACxB,gBAAgB,EAChB,mBAAmB,EACnB,yBAAyB,EACzB,gBAAgB,EAChB,uBAAuB,EACvB,gBAAgB,EAChB,SAAS,EACT,uBAAuB,EACvB,kBAAkB,EAClB,gBAAgB,EAChB,6BAA6B,GAC9B,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC"}
@@ -7,6 +7,9 @@ import { componentType, LayoutComponent, RegistrationConfig } from '../utils';
7
7
  * This element is used to wrap html elements and configure their layout settings as part of the layout system.
8
8
  *
9
9
  * This is a simple component which is only used to define the layout splits; any JavaScript API interactions or custom styling is used via {@link FoundationLayout}.
10
+ *
11
+ * The item can either use slotted content or a factory function registered via {@link registerFactory}.
12
+ * When a factory is registered with the same name as the registration attribute, it takes precedence over slotted content.
10
13
  * @tagname %%prefix%%-layout-item
11
14
  */
12
15
  export declare class FoundationLayoutItem extends FoundationElement implements LayoutComponent {
@@ -35,6 +38,23 @@ export declare class FoundationLayoutItem extends FoundationElement implements L
35
38
  * Using a duplicate registration name is a runtime error.
36
39
  * This registration name defaults to the number of the window it is.
37
40
  * It is highly recommended if you are using the JavaScript API that you set a registration name here manually.
41
+ *
42
+ * When using the declarative API with framework components, register a factory function via {@link registerFactory}
43
+ * using the same name as this registration attribute.
44
+ *
45
+ * @example
46
+ * ```typescript
47
+ * import { registerFactory } from '@genesislcap/foundation-layout';
48
+ * import { reactFactory } from './utils/react-layout-factory';
49
+ *
50
+ * // Register factory with the same name as the registration
51
+ * registerFactory('my-component', reactFactory(MyComponent));
52
+ * ```
53
+ *
54
+ * Then in JSX/HTML:
55
+ * ```tsx
56
+ * <rapid-layout-item registration="my-component" title="My Component" />
57
+ * ```
38
58
  * @public
39
59
  */
40
60
  registration: string;
@@ -1 +1 @@
1
- {"version":3,"file":"layout-item.d.ts","sourceRoot":"","sources":["../../../src/main/layout-item.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EACL,aAAa,EAEb,eAAe,EACf,kBAAkB,EAEnB,MAAM,UAAU,CAAC;AAIlB;;;;;;;;GAQG;AACH,qBAAa,oBAAqB,SAAQ,iBAAkB,YAAW,eAAe;IACpF;;;;;OAKG;IACG,KAAK,EAAE,MAAM,CAAC;IAEpB;;;;OAIG;IACwB,QAAQ,EAAE,OAAO,CAAS;IAErD;;;OAGG;IACG,IAAI,EAAE,MAAM,CAAC;IAEnB;;;;;;;;OAQG;IACG,YAAY,EAAE,MAAM,CAAC;IAE3B,gBAAgB;IAChB,CAAC,aAAa,CAAC,EAAG,MAAM,CAAU;IAElC,gBAAgB;IAChB,OAAO,CAAC,eAAe,CAAY;IAEnC,gBAAgB;IAChB,iBAAiB,IAAI,IAAI;IAyBzB,gBAAgB;IAChB,OAAO,CAAC,wBAAwB;IAIhC,gBAAgB;IAChB,mBAAmB,IAAI,IAAI;IAI3B,gBAAgB;IAChB,wBAAwB,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM;CAG7D;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB;;;;;;+BAG/B,CAAC"}
1
+ {"version":3,"file":"layout-item.d.ts","sourceRoot":"","sources":["../../../src/main/layout-item.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EACL,aAAa,EAEb,eAAe,EACf,kBAAkB,EAEnB,MAAM,UAAU,CAAC;AAMlB;;;;;;;;;;;GAWG;AACH,qBAAa,oBAAqB,SAAQ,iBAAkB,YAAW,eAAe;IACpF;;;;;OAKG;IACG,KAAK,EAAE,MAAM,CAAC;IAEpB;;;;OAIG;IACwB,QAAQ,EAAE,OAAO,CAAS;IAErD;;;OAGG;IACG,IAAI,EAAE,MAAM,CAAC;IAEnB;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACG,YAAY,EAAE,MAAM,CAAC;IAE3B,gBAAgB;IAChB,CAAC,aAAa,CAAC,EAAG,MAAM,CAAU;IAElC,gBAAgB;IAChB,OAAO,CAAC,eAAe,CAAY;IAEnC,gBAAgB;IAChB,iBAAiB,IAAI,IAAI;IA8CzB,gBAAgB;IAChB,OAAO,CAAC,wBAAwB;IAIhC,gBAAgB;IAChB,mBAAmB,IAAI,IAAI;IAI3B,gBAAgB;IAChB,wBAAwB,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM;CAG7D;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB;;;;;;+BAG/B,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import { LayoutConfig, RootItemConfig } from '@genesis-community/golden-layout';
2
2
  import { FoundationElement } from '@microsoft/fast-foundation';
3
- import { componentType, CustomButton, LayoutComponent, Placement, RegisteredElementConfig, RegistrationConfig, SerialisedLayout } from '../utils/';
3
+ import { ComponentFactory, componentType, CustomButton, LayoutComponent, Placement, RegisteredElementConfig, RegistrationConfig, SerialisedLayout } from '../utils/';
4
4
  export { layoutStyles } from '../styles';
5
5
  /**
6
6
  * @public
@@ -240,21 +240,48 @@ export declare class FoundationLayout extends FoundationElement implements Layou
240
240
  removeItems(registration: string, force?: boolean): number;
241
241
  /**
242
242
  * @public
243
- * Register a collection of `Element` and associate them with an `ID` with the layout system for later use.
243
+ * Register a collection of `Element` or a factory function and associate them with an `ID` with the layout system for later use.
244
244
  * @remarks
245
- * You would use this to register elements that you later want to load when using {@link FoundationLayout.loadLayout}.
245
+ * You can register either an array of elements or a factory function.
246
+ *
247
+ * **Element registration**: Use this to register elements that you later want to load when using {@link FoundationLayout.loadLayout}.
246
248
  * Use {@link FoundationLayout.layoutRequiredRegistrations} to see what components need to be registered for a certain config
247
249
  * and then register them using this function before calling {@link FoundationLayout.loadLayout}.
250
+ * When registering an element it is moved by reference into the internals of the layout, so if you pass elements already in the DOM then they will disappear.
251
+ * If you want to avoid this you can pass copies using `element.cloneNode(true)`.
248
252
  *
249
- * When registering an element it is moved by reference into the internals of the layout, so if you pass elements already in the DOM then they will disappear. If you want to avoid this you can pass copies using `element.cloneNode(true)`.
253
+ * **Factory registration**: This is the recommended approach for framework-rendered components (React, Angular, Vue, etc.)
254
+ * because it allows each layout instance to create a fresh component rather than cloning existing
255
+ * DOM elements (which loses event listeners and framework bindings).
256
+ * The factory function will be called each time a new instance of the component is needed. It receives
257
+ * a container element and should render the component into it. Optionally, it can return a cleanup
258
+ * function that will be called when the component is removed from the layout.
250
259
  *
251
260
  * @param registration - string of the registration ID
252
- * @param elements - Elements[] containing the reference to the elements to register for later usage
261
+ * @param elementsOrFactory - Either Elements[] containing the reference to the elements to register, or a ComponentFactory function
253
262
  * @throws {@link LayoutUsageError} if you attempt to add an item before the layout has been initialised.
254
263
  * @throws {@link LayoutRegistrationError} if you attempt to use a `registration` name which is already in use (declarative html API and JavaScript API registrations use the same "pool" of registration names).
255
264
  * @returns - string defining the name of the registered item with the layout system (config.id if set).
256
- */
257
- registerItem(registration: string, elements: Element[]): string;
265
+ *
266
+ * @example
267
+ * Element registration:
268
+ * ```typescript
269
+ * const div = document.createElement('div');
270
+ * div.innerHTML = '<h1>Hello</h1>';
271
+ * layout.registerItem('my-element', [div]);
272
+ * ```
273
+ *
274
+ * @example
275
+ * Factory registration (React):
276
+ * ```typescript
277
+ * layout.registerItem('text-field', (container) => {
278
+ * const root = createRoot(container);
279
+ * root.render(<TextFieldComponent />);
280
+ * return () => root.unmount();
281
+ * });
282
+ * ```
283
+ */
284
+ registerItem(registration: string, elementsOrFactory: Element[] | ComponentFactory): string;
258
285
  /**
259
286
  * Internal APIs
260
287
  */
@@ -283,12 +310,13 @@ export declare class FoundationLayout extends FoundationElement implements Layou
283
310
  /**
284
311
  * Registers a function with golden layout to create a pane
285
312
  * @param elements - Elements[] to add to new new pane
313
+ * @param factory - ComponentFactory function to create component instances
286
314
  * @param id - optional string which is used to register the new function with golden layout. Defaults to sequentially setting the IDs for default items
287
315
  * @returns - string which is the registered ID
288
316
  * @throws - {@link LayoutRegistrationError} if the id is already in use
289
317
  * @internal
290
318
  */
291
- cacheElementsAndRegister({ elements, id }: RegistrationConfig): string;
319
+ cacheElementsAndRegister(config: RegistrationConfig): string;
292
320
  /**
293
321
  * Sets up the event listeners for the layout receive events
294
322
  * @internal
@@ -1 +1 @@
1
- {"version":3,"file":"layout-main.d.ts","sourceRoot":"","sources":["../../../src/main/layout-main.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,YAAY,EAEZ,cAAc,EAGf,MAAM,kCAAkC,CAAC;AAI1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/D,OAAO,EAGL,aAAa,EACb,YAAY,EAOZ,eAAe,EAKf,SAAS,EAET,uBAAuB,EACvB,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,WAAW,CAAC;AAInB,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAiBzC;;;;;;;;;;;GAWG;AACH,qBAAa,gBAAiB,SAAQ,iBAAkB,YAAW,eAAe;;IAChF,OAAO,CAAC,MAAM,CAAe;IAC7B,gBAAgB;IAChB,aAAa,EAAE,WAAW,CAAC;IAC3B,OAAO,CAAC,YAAY,CAAqC;IACzD,OAAO,CAAC,mBAAmB,CAAqC;IAEhE,gBAAgB;IAChB,CAAC,aAAa,CAAC,EAAG,MAAM,CAAU;IAElC;;;;OAIG;IACmC,YAAY,EAAE,MAAM,CAAyB;IACnF,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,oBAAoB,CAAK;IAEjC,gBAAgB;IACV,OAAO,CAAC,IAAI,CAAO;IAEzB,gBAAgB;IACP,OAAO,CAAC,OAAO,CAAU;IAClC;;;;;OAKG;IACmC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC3D;;;;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ory function with a unique key.
4
+ * This allows framework components to be used in the declarative layout API
5
+ * without needing to pass function references through HTML attributes.
6
+ *
7
+ * @param key - Unique identifier for the factory. Should be descriptive and unique across the application.
8
+ * @param factory - The factory function that creates the component.
9
+ * @throws {Error} If a factory with the same key is already registered.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * // React example
14
+ * import { registerFactory } from '@genesislcap/foundation-layout';
15
+ * import { reactFactory } from './utils/react-layout-factory';
16
+ * import { MyComponent } from './components/MyComponent';
17
+ *
18
+ * registerFactory('my-component', reactFactory(MyComponent, { someProp: 'value' }));
19
+ * ```
20
+ *
21
+ * Then in your JSX:
22
+ * ```tsx
23
+ * <rapid-layout-item
24
+ * registration="my-item"
25
+ * title="My Component"
26
+ * />
27
+ * ```
28
+ *
29
+ * @public
30
+ */
31
+ export declare function registerFactory(key: string, factory: ComponentFactory): void;
32
+ /**
33
+ * Retrieves a factory function by its key.
34
+ *
35
+ * @param key - The unique identifier for the factory.
36
+ * @returns The factory function, or undefined if not found.
37
+ *
38
+ * @public
39
+ */
40
+ export declare function getFactory(key: string): ComponentFactory | undefined;
41
+ /**
42
+ * Removes a factory from the registry.
43
+ * This is useful for cleanup when a component is unmounted or no longer needed.
44
+ *
45
+ * @param key - The unique identifier for the factory to remove.
46
+ * @returns True if the factory was found and removed, false otherwise.
47
+ *
48
+ * @example
49
+ * ```typescript
50
+ * unregisterFactory('my-component');
51
+ * ```
52
+ *
53
+ * @public
54
+ */
55
+ export declare function unregisterFactory(key: string): boolean;
56
+ /**
57
+ * Clears all registered factories from the registry.
58
+ * This is primarily useful for testing purposes.
59
+ *
60
+ * @internal
61
+ */
62
+ export declare function clearFactoryRegistry(): void;
63
+ //# sourceMappingURL=factory-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory-registry.d.ts","sourceRoot":"","sources":["../../../src/utils/factory-registry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAShD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAQ5E;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAEpE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAQtD;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAG3C"}
@@ -1,6 +1,7 @@
1
1
  export * from './constants';
2
2
  export * from './error';
3
3
  export * from './events';
4
+ export * from './factory-registry';
4
5
  export * from './misc';
5
6
  export * from './templates';
6
7
  export * from './types';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,oBAAoB,CAAC;AACnC,cAAc,QAAQ,CAAC;AACvB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
@@ -134,11 +134,52 @@ export type InstanceContainer = {
134
134
  export type LayoutComponentItem<T> = Element & Partial<LayoutComponentWithState<T>> & {
135
135
  [instanceContainer]?: InstanceContainer;
136
136
  };
137
+ /**
138
+ * @public
139
+ * Factory function for creating component instances in the layout.
140
+ * @remarks
141
+ * This is the recommended approach for framework-rendered components (React, Angular, Vue, etc.)
142
+ * because it allows each layout instance to create a fresh component rather than cloning existing
143
+ * DOM elements (which loses event listeners and framework bindings).
144
+ *
145
+ * The factory function receives a container element and should render the component into it.
146
+ * Optionally, it can return a cleanup function that will be called when the component is removed
147
+ * from the layout.
148
+ *
149
+ * @param container - The HTMLElement container where the component should be rendered
150
+ * @returns Optional cleanup function to be called when the component is removed
151
+ *
152
+ * @example
153
+ * React example:
154
+ * ```typescript
155
+ * layout.registerItem('my-component', (container) => {
156
+ * const root = createRoot(container);
157
+ * root.render(<MyComponent />);
158
+ * return () => root.unmount();
159
+ * });
160
+ * ```
161
+ *
162
+ * @example
163
+ * Angular example:
164
+ * ```typescript
165
+ * layout.registerItem('my-component', (container) => {
166
+ * const componentRef = createComponent(MyComponent, {
167
+ * environmentInjector: this.injector,
168
+ * hostElement: container
169
+ * });
170
+ * return () => componentRef.destroy();
171
+ * });
172
+ * ```
173
+ */
174
+ export type ComponentFactory = (container: HTMLElement) => void | (() => void);
137
175
  /** @internal */
138
- export interface RegistrationConfig {
139
- elements: Element[];
176
+ export type RegistrationConfig = {
140
177
  id?: string;
141
- }
178
+ } & ({
179
+ elements: Element[];
180
+ } | {
181
+ factory: ComponentFactory;
182
+ });
142
183
  /** @internal */
143
184
  export declare const layoutRegionValue: readonly ["horizontal", "vertical", "tabs"];
144
185
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/utils/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAC5F,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAE/D;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,KAAK,IAAI,CAAC;CAC9D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AE,gBAAgB,CAAC;CAC3B,CACJ,CAAC;AAEF,gBAAgB;AAChB,eAAO,MAAM,iBAAiB,6CAA8C,CAAC;AAC7E;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAClE,gBAAgB;AAChB,MAAM,MAAM,cAAc,GAAG,gBAAgB,GAAG,MAAM,GAAG,MAAM,CAAC;AAEhE,gBAAgB;AAChB,MAAM,WAAW,eAAe;IAC9B,CAAC,aAAa,CAAC,EAAE,cAAc,CAAC;IAChC,wBAAwB,CAAC,MAAM,EAAE,kBAAkB,GAAG,MAAM,CAAC;IAC7D,mBAAmB,IAAI,IAAI,CAAC;CAC7B;AAED,gBAAgB;AAChB,MAAM,MAAM,gBAAgB,GAAG;IAC7B,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACrB,CAAC"}
package/dist/esm/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './main';
2
2
  export { LAYOUT_ICONS } from './styles';
3
3
  export { DEFAULT_RELOAD_BUFFER, LayoutEmitEvents, LayoutReceiveEvents, LayoutRegistrationError, LayoutUsageError, LAYOUT_POPOUT_CONTAINER_CLASS, } from './utils';
4
+ export { registerFactory, getFactory, unregisterFactory } from './utils/factory-registry';
@@ -3,6 +3,8 @@ import { __decorate } from "tslib";
3
3
  import { attr } from '@microsoft/fast-element';
4
4
  import { FoundationElement } from '@microsoft/fast-foundation';
5
5
  import { componentType, getParentLayoutComponent, wrapperTemplate, } from '../utils';
6
+ import { LayoutUsageError } from '../utils/error';
7
+ import { getFactory } from '../utils/factory-registry';
6
8
  /**
7
9
  * @public
8
10
  * `FoundationLayoutItem` is a custom element that represents an item in the layout.
@@ -10,6 +12,9 @@ import { componentType, getParentLayoutComponent, wrapperTemplate, } from '../ut
10
12
  * This element is used to wrap html elements and configure their layout settings as part of the layout system.
11
13
  *
12
14
  * This is a simple component which is only used to define the layout splits; any JavaScript API interactions or custom styling is used via {@link FoundationLayout}.
15
+ *
16
+ * The item can either use slotted content or a factory function registered via {@link registerFactory}.
17
+ * When a factory is registered with the same name as the registration attribute, it takes precedence over slotted content.
13
18
  * @tagname %%prefix%%-layout-item
14
19
  */
15
20
  export class FoundationLayoutItem extends FoundationElement {
@@ -28,11 +33,28 @@ export class FoundationLayoutItem extends FoundationElement {
28
33
  connectedCallback() {
29
34
  var _b;
30
35
  super.connectedCallback();
36
+ let registeredID;
37
+ // Look up factory from registry using registration name
38
+ const factory = getFactory(this.registration);
39
+ // Get slotted elements to check for conflicts
31
40
  this.slottedElements = this.shadowRoot.querySelector('slot.target').assignedElements();
32
- const registeredID = this.cacheElementsAndRegister({
33
- elements: this.slottedElements,
34
- id: this.registration,
35
- });
41
+ // Validate: cannot have both factory and slotted content
42
+ if (factory && this.slottedElements.length > 0) {
43
+ throw new LayoutUsageError(`Cannot use both factory registration and slotted content for registration "${this.registration}". ` +
44
+ `Either register a factory via registerFactory() OR provide slotted content, but not both.`);
45
+ }
46
+ if (factory) {
47
+ registeredID = this.cacheElementsAndRegister({
48
+ factory: factory,
49
+ id: this.registration,
50
+ });
51
+ }
52
+ else {
53
+ registeredID = this.cacheElementsAndRegister({
54
+ elements: this.slottedElements,
55
+ id: this.registration,
56
+ });
57
+ }
36
58
  const itemConfig = {
37
59
  type: 'component',
38
60
  componentType: registeredID,