@agnos-ui/angular-headless 0.4.3 → 0.5.0-next.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.
- package/README.md +2 -2
- package/config.d.ts +13 -8
- package/esm2022/config.mjs +26 -2
- package/esm2022/slot.directive.mjs +23 -33
- package/esm2022/types.mjs +21 -4
- package/esm2022/utils/directive.mjs +30 -9
- package/esm2022/utils/stores.mjs +10 -6
- package/esm2022/utils/widget.mjs +55 -20
- package/esm2022/utils/zone.mjs +7 -3
- package/fesm2022/agnos-ui-angular-headless.mjs +166 -71
- package/fesm2022/agnos-ui-angular-headless.mjs.map +1 -1
- package/package.json +8 -7
- package/slot.directive.d.ts +21 -19
- package/types.d.ts +86 -11
- package/utils/directive.d.ts +30 -6
- package/utils/stores.d.ts +9 -5
- package/utils/widget.d.ts +39 -11
- package/utils/zone.d.ts +4 -0
|
@@ -20,7 +20,6 @@ export * from '@agnos-ui/core/utils/stores';
|
|
|
20
20
|
import { multiDirective } from '@agnos-ui/core/utils/directive';
|
|
21
21
|
export * from '@agnos-ui/core/utils/directive';
|
|
22
22
|
import { isPlatformServer } from '@angular/common';
|
|
23
|
-
import { toSlotContextWidget } from '@agnos-ui/core/types';
|
|
24
23
|
export * from '@agnos-ui/core/types';
|
|
25
24
|
import { createWidgetsConfig } from '@agnos-ui/core/config';
|
|
26
25
|
export * from '@agnos-ui/core/config';
|
|
@@ -48,6 +47,10 @@ const createObjectWrapper = (wrap) => (object) => {
|
|
|
48
47
|
return res;
|
|
49
48
|
};
|
|
50
49
|
const createReturnValueWrapper = (wrapReturnValue, wrapResult) => (fn) => wrapResult(typeof fn === 'function' ? ((...args) => wrapReturnValue(fn(...args))) : fn);
|
|
50
|
+
/**
|
|
51
|
+
* A utility class that provides methods to run functions inside or outside of Angular's NgZone.
|
|
52
|
+
* This can be useful for optimizing performance by avoiding unnecessary change detection cycles.
|
|
53
|
+
*/
|
|
51
54
|
class ZoneWrapper {
|
|
52
55
|
constructor() {
|
|
53
56
|
this.#zone = inject(NgZone);
|
|
@@ -61,7 +64,7 @@ class ZoneWrapper {
|
|
|
61
64
|
if (!this.#runPlanned) {
|
|
62
65
|
this.#runPlanned = true;
|
|
63
66
|
void (async () => {
|
|
64
|
-
await
|
|
67
|
+
await Promise.resolve();
|
|
65
68
|
this.#runPlanned = false;
|
|
66
69
|
if (this.#runNeeded) {
|
|
67
70
|
this.ngZoneRun(noop);
|
|
@@ -96,7 +99,7 @@ class ZoneWrapper {
|
|
|
96
99
|
this.#runNeeded = false;
|
|
97
100
|
return this.#zone.run(fn);
|
|
98
101
|
}
|
|
99
|
-
static { this.ɵfac = function ZoneWrapper_Factory(
|
|
102
|
+
static { this.ɵfac = function ZoneWrapper_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ZoneWrapper)(); }; }
|
|
100
103
|
static { this.ɵprov = /*@__PURE__*/ i0.ɵɵdefineInjectable({ token: ZoneWrapper, factory: ZoneWrapper.ɵfac, providedIn: 'root' }); }
|
|
101
104
|
}
|
|
102
105
|
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ZoneWrapper, [{
|
|
@@ -107,13 +110,17 @@ class ZoneWrapper {
|
|
|
107
110
|
}], null, null); })();
|
|
108
111
|
|
|
109
112
|
/**
|
|
110
|
-
*
|
|
113
|
+
* Converts a Tansu `ReadableSignal` to an Angular `Signal`.
|
|
111
114
|
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
115
|
+
* This function wraps the provided Tansu signal in an Angular signal, ensuring that updates
|
|
116
|
+
* are properly handled within Angular's zone. It subscribes to the Tansu signal and updates
|
|
117
|
+
* the Angular signal with the received values. The equality function for the Angular signal
|
|
118
|
+
* is set to always return false, ensuring that every new value from the Tansu signal triggers
|
|
119
|
+
* an update.
|
|
114
120
|
*
|
|
115
|
-
* @
|
|
116
|
-
*
|
|
121
|
+
* @template T - The type of the value emitted by the signals.
|
|
122
|
+
* @param tansuSignal - The Tansu signal to convert.
|
|
123
|
+
* @returns - The resulting Angular signal.
|
|
117
124
|
*/
|
|
118
125
|
const toAngularSignal = (tansuSignal) => {
|
|
119
126
|
const zoneWrapper = inject(ZoneWrapper);
|
|
@@ -129,11 +136,19 @@ const toAngularSignal = (tansuSignal) => {
|
|
|
129
136
|
};
|
|
130
137
|
|
|
131
138
|
/**
|
|
132
|
-
*
|
|
139
|
+
* A utility function to manage the lifecycle of a directive for a host element.
|
|
140
|
+
*
|
|
141
|
+
* This function handles the creation, updating, and destruction of a directive instance
|
|
142
|
+
* associated with a host element. It ensures that the directive is called appropriately
|
|
143
|
+
* based on the platform (server or client) and manages the directive's lifecycle within
|
|
144
|
+
* the Angular injection context.
|
|
133
145
|
*
|
|
134
|
-
* @
|
|
135
|
-
*
|
|
136
|
-
* @
|
|
146
|
+
* @template T - The type of parameters that the directive accepts.
|
|
147
|
+
*
|
|
148
|
+
* @param [directive] - The directive to be applied to the host element.
|
|
149
|
+
* @param [params] - The parameters to be passed to the directive.
|
|
150
|
+
*
|
|
151
|
+
* @returns An object containing an `update` function to update the directive and its parameters.
|
|
137
152
|
*/
|
|
138
153
|
const useDirectiveForHost = (directive, params) => {
|
|
139
154
|
const injector = inject(Injector);
|
|
@@ -179,15 +194,23 @@ const useDirectiveForHost = (directive, params) => {
|
|
|
179
194
|
callDirective();
|
|
180
195
|
return { update };
|
|
181
196
|
};
|
|
197
|
+
/**
|
|
198
|
+
* A directive that allows the use of another directive with optional parameters.
|
|
199
|
+
*
|
|
200
|
+
* @template T - The type of the parameter that can be passed to the directive.
|
|
201
|
+
*
|
|
202
|
+
* @remarks
|
|
203
|
+
* This directive uses a private instance of {@link useDirectiveForHost} to manage the directive and its parameter.
|
|
204
|
+
*/
|
|
182
205
|
class UseDirective {
|
|
183
206
|
#useDirective = useDirectiveForHost();
|
|
184
|
-
/** @
|
|
207
|
+
/** @internal */
|
|
185
208
|
ngOnChanges() {
|
|
186
209
|
const use = this.use;
|
|
187
210
|
const [directive, param] = Array.isArray(use) ? use : [use];
|
|
188
211
|
this.#useDirective.update(directive, param);
|
|
189
212
|
}
|
|
190
|
-
static { this.ɵfac = function UseDirective_Factory(
|
|
213
|
+
static { this.ɵfac = function UseDirective_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || UseDirective)(); }; }
|
|
191
214
|
static { this.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: UseDirective, selectors: [["", "auUse", ""]], inputs: { use: [0, "auUse", "use"] }, standalone: true, features: [i0.ɵɵNgOnChangesFeature] }); }
|
|
192
215
|
}
|
|
193
216
|
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(UseDirective, [{
|
|
@@ -200,13 +223,18 @@ class UseDirective {
|
|
|
200
223
|
type: Input,
|
|
201
224
|
args: ['auUse']
|
|
202
225
|
}] }); })();
|
|
226
|
+
/**
|
|
227
|
+
* A directive that allows the use of multiple directives on a host element.
|
|
228
|
+
*
|
|
229
|
+
* @template T - A tuple type representing the directives and their optional parameters.
|
|
230
|
+
*/
|
|
203
231
|
class UseMultiDirective {
|
|
204
232
|
#useDirective = useDirectiveForHost();
|
|
205
|
-
/** @
|
|
233
|
+
/** @internal */
|
|
206
234
|
ngOnChanges() {
|
|
207
235
|
this.#useDirective.update(multiDirective, this.useMulti);
|
|
208
236
|
}
|
|
209
|
-
static { this.ɵfac = function UseMultiDirective_Factory(
|
|
237
|
+
static { this.ɵfac = function UseMultiDirective_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || UseMultiDirective)(); }; }
|
|
210
238
|
static { this.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: UseMultiDirective, selectors: [["", "auUseMulti", ""]], inputs: { useMulti: [0, "auUseMulti", "useMulti"] }, standalone: true, features: [i0.ɵɵNgOnChangesFeature] }); }
|
|
211
239
|
}
|
|
212
240
|
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(UseMultiDirective, [{
|
|
@@ -220,21 +248,38 @@ class UseMultiDirective {
|
|
|
220
248
|
args: [{ alias: 'auUseMulti', required: true }]
|
|
221
249
|
}] }); })();
|
|
222
250
|
|
|
251
|
+
/**
|
|
252
|
+
* Represents a template for a component with specified properties.
|
|
253
|
+
*
|
|
254
|
+
* @template Props - The type of properties that the template accepts.
|
|
255
|
+
* @template K - The key in the template object that maps to the template reference.
|
|
256
|
+
* @template T - An object type where each key of type K maps to a TemplateRef of Props.
|
|
257
|
+
*
|
|
258
|
+
* @param component - The component type that contains the template.
|
|
259
|
+
* @param templateProp - The key in the component that maps to the template reference.
|
|
260
|
+
*/
|
|
223
261
|
class ComponentTemplate {
|
|
224
262
|
constructor(component, templateProp) {
|
|
225
263
|
this.component = component;
|
|
226
264
|
this.templateProp = templateProp;
|
|
227
265
|
}
|
|
228
266
|
}
|
|
267
|
+
/**
|
|
268
|
+
* A directive representing a slot component that can be used to manage the state and context of a widget.
|
|
269
|
+
*
|
|
270
|
+
* @template W - The type of the widget that this slot component manages.
|
|
271
|
+
*/
|
|
229
272
|
class SlotComponent {
|
|
230
|
-
static { this.ɵfac = function SlotComponent_Factory(
|
|
231
|
-
static { this.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: SlotComponent, inputs: { state: "state",
|
|
273
|
+
static { this.ɵfac = function SlotComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || SlotComponent)(); }; }
|
|
274
|
+
static { this.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: SlotComponent, inputs: { state: "state", api: "api", directives: "directives" } }); }
|
|
232
275
|
}
|
|
233
276
|
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SlotComponent, [{
|
|
234
277
|
type: Directive
|
|
235
278
|
}], null, { state: [{
|
|
236
279
|
type: Input
|
|
237
|
-
}],
|
|
280
|
+
}], api: [{
|
|
281
|
+
type: Input
|
|
282
|
+
}], directives: [{
|
|
238
283
|
type: Input
|
|
239
284
|
}] }); })();
|
|
240
285
|
|
|
@@ -268,18 +313,25 @@ const createPatchSlots = (set) => {
|
|
|
268
313
|
* @param parameter.widgetConfig - the config of the widget, overriding the defaultConfig
|
|
269
314
|
* @param parameter.events - the events of the widget
|
|
270
315
|
* @param parameter.afterInit - a callback to call after successful setup of the widget
|
|
316
|
+
* @param parameter.slotTemplates - a function to provide all slot templates using child queries
|
|
317
|
+
* @param parameter.slotChildren - a function to provide the default children slot using a view query
|
|
271
318
|
* @returns the widget
|
|
272
319
|
*/
|
|
273
|
-
const callWidgetFactoryWithConfig = ({ factory, defaultConfig, widgetConfig, events, afterInit, }) => {
|
|
320
|
+
const callWidgetFactoryWithConfig = ({ factory, defaultConfig, widgetConfig, events, afterInit, slotTemplates, slotChildren, }) => {
|
|
274
321
|
const injector = inject(Injector);
|
|
275
322
|
const slots$ = writable({});
|
|
276
323
|
const props = {};
|
|
277
324
|
let initDone;
|
|
325
|
+
const patchSlots = createPatchSlots(slots$.set);
|
|
278
326
|
const res = {
|
|
279
327
|
initialized: new Promise((resolve) => {
|
|
280
328
|
initDone = resolve;
|
|
281
329
|
}),
|
|
282
|
-
|
|
330
|
+
updateSlots: () => {
|
|
331
|
+
if (slotTemplates) {
|
|
332
|
+
patchSlots(slotTemplates());
|
|
333
|
+
}
|
|
334
|
+
},
|
|
283
335
|
patch(newProps) {
|
|
284
336
|
// temporary function replaced in ngInit
|
|
285
337
|
Object.assign(props, newProps);
|
|
@@ -291,21 +343,22 @@ const callWidgetFactoryWithConfig = ({ factory, defaultConfig, widgetConfig, eve
|
|
|
291
343
|
const defaultConfig$ = toReadableStore(defaultConfig);
|
|
292
344
|
events = zoneWrapper.insideNgZoneWrapFunctionsObject(events);
|
|
293
345
|
const widget = factory({
|
|
294
|
-
config: computed(() => ({
|
|
346
|
+
config: computed(() => ({
|
|
347
|
+
...defaultConfig$(),
|
|
348
|
+
children: slotChildren?.(),
|
|
349
|
+
...widgetConfig?.(),
|
|
350
|
+
...slots$(),
|
|
351
|
+
...events,
|
|
352
|
+
})),
|
|
295
353
|
props,
|
|
296
354
|
});
|
|
297
|
-
|
|
298
|
-
...widget,
|
|
355
|
+
Object.assign(res, {
|
|
299
356
|
patch: zoneWrapper.outsideNgZone(widget.patch),
|
|
300
357
|
directives: zoneWrapper.outsideNgZoneWrapDirectivesObject(widget.directives),
|
|
301
|
-
actions: zoneWrapper.outsideNgZoneWrapFunctionsObject(widget.actions),
|
|
302
358
|
api: zoneWrapper.outsideNgZoneWrapFunctionsObject(widget.api),
|
|
303
|
-
|
|
304
|
-
Object.assign(res, wrappedWidget, {
|
|
305
|
-
widget: toSlotContextWidget(wrappedWidget),
|
|
306
|
-
ngState: toAngularSignal(wrappedWidget.state$),
|
|
359
|
+
state: Object.fromEntries(Object.entries(widget.stores).map(([key, val]) => [key.slice(0, -1), toAngularSignal(val)])),
|
|
307
360
|
});
|
|
308
|
-
afterInit?.();
|
|
361
|
+
afterInit?.(res);
|
|
309
362
|
initDone();
|
|
310
363
|
});
|
|
311
364
|
},
|
|
@@ -321,36 +374,65 @@ function patchSimpleChanges(patchFn, changes) {
|
|
|
321
374
|
}
|
|
322
375
|
patchFn(obj);
|
|
323
376
|
}
|
|
377
|
+
/**
|
|
378
|
+
* An abstract base class for widget directives, providing common functionality
|
|
379
|
+
* for Angular components that interact with widgets.
|
|
380
|
+
*
|
|
381
|
+
* @template W - The type of the widget.
|
|
382
|
+
*/
|
|
324
383
|
class BaseWidgetDirective {
|
|
384
|
+
constructor(_widget) {
|
|
385
|
+
this._widget = _widget;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Retrieves the widget api
|
|
389
|
+
* @returns the widget api
|
|
390
|
+
*/
|
|
325
391
|
get api() {
|
|
326
392
|
return this._widget.api;
|
|
327
393
|
}
|
|
394
|
+
/**
|
|
395
|
+
* Retrieves the widget state as an Angular {@link https://angular.dev/api/core/Signal | Signal}
|
|
396
|
+
* @returns the widget state
|
|
397
|
+
*/
|
|
328
398
|
get state() {
|
|
329
|
-
return this._widget.
|
|
399
|
+
return this._widget.state;
|
|
330
400
|
}
|
|
331
|
-
|
|
332
|
-
|
|
401
|
+
/**
|
|
402
|
+
* Retrieves the widget directives
|
|
403
|
+
* @returns the widget directives
|
|
404
|
+
*/
|
|
405
|
+
get directives() {
|
|
406
|
+
return this._widget.directives;
|
|
333
407
|
}
|
|
334
|
-
/**
|
|
408
|
+
/**
|
|
409
|
+
* @inheritdoc
|
|
410
|
+
* @internal
|
|
411
|
+
*/
|
|
335
412
|
ngOnChanges(changes) {
|
|
336
413
|
patchSimpleChanges(this._widget.patch, changes);
|
|
337
414
|
}
|
|
338
|
-
/** @
|
|
415
|
+
/** @internal */
|
|
339
416
|
ngOnInit() {
|
|
340
417
|
this._widget.ngInit();
|
|
341
418
|
}
|
|
342
|
-
|
|
419
|
+
/** @internal */
|
|
420
|
+
ngAfterContentChecked() {
|
|
421
|
+
this._widget.updateSlots();
|
|
422
|
+
}
|
|
423
|
+
static { this.ɵfac = function BaseWidgetDirective_Factory(__ngFactoryType__) { i0.ɵɵinvalidFactory(); }; }
|
|
343
424
|
static { this.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: BaseWidgetDirective, features: [i0.ɵɵNgOnChangesFeature] }); }
|
|
344
425
|
}
|
|
345
426
|
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(BaseWidgetDirective, [{
|
|
346
427
|
type: Directive
|
|
347
|
-
}],
|
|
428
|
+
}], () => [{ type: undefined }], null); })();
|
|
348
429
|
|
|
349
430
|
/**
|
|
350
431
|
* A factory to create the utilities to allow widgets to be context-aware.
|
|
351
432
|
*
|
|
352
433
|
* It can be used when extending the core and creating new widgets.
|
|
353
434
|
*
|
|
435
|
+
* @template Config - The type of the widgets configuration object.
|
|
354
436
|
* @param widgetsConfigInjectionToken - the widgets config injection token
|
|
355
437
|
* @returns the utilities to create / manage widgets and contexts
|
|
356
438
|
*/
|
|
@@ -436,16 +518,39 @@ const widgetsConfigFactory = (widgetsConfigInjectionToken = new InjectionToken('
|
|
|
436
518
|
}
|
|
437
519
|
return widgetsConfig;
|
|
438
520
|
};
|
|
521
|
+
/**
|
|
522
|
+
* Injects the configuration for a specific widget.
|
|
523
|
+
*
|
|
524
|
+
* @template N - The key of the widget configuration in the `Config` type.
|
|
525
|
+
* @param widgetName - The name of the widget whose configuration is to be injected.
|
|
526
|
+
* @returns A `ReadableSignal` that provides a partial configuration of the specified widget or `undefined` if the configuration is not available.
|
|
527
|
+
*/
|
|
439
528
|
const injectWidgetConfig = (widgetName) => {
|
|
440
529
|
const widgetsConfig = inject(widgetsConfigInjectionToken, { optional: true });
|
|
441
530
|
return computed(() => widgetsConfig?.()[widgetName]);
|
|
442
531
|
};
|
|
443
|
-
|
|
532
|
+
/**
|
|
533
|
+
* Creates and initializes a widget using the provided factory and configuration options.
|
|
534
|
+
*
|
|
535
|
+
* @template W - The type of the widget.
|
|
536
|
+
* @param params - The parameters for creating the widget.
|
|
537
|
+
* @param params.factory - The factory function to create the widget.
|
|
538
|
+
* @param params.widgetName - The name of the widget configuration to inject, if any.
|
|
539
|
+
* @param params.defaultConfig - The default configuration for the widget.
|
|
540
|
+
* @param params.events - The event handlers for the widget.
|
|
541
|
+
* @param params.slotTemplates - A function that returns the slot templates for the widget.
|
|
542
|
+
* @param params.slotChildren - A function that returns the slot children for the widget.
|
|
543
|
+
* @param params.afterInit - A callback function to be called after the widget is initialized.
|
|
544
|
+
* @returns The initialized widget.
|
|
545
|
+
*/
|
|
546
|
+
const callWidgetFactory = ({ factory, widgetName = null, defaultConfig = {}, events, afterInit, slotTemplates, slotChildren, }) => callWidgetFactoryWithConfig({
|
|
444
547
|
factory,
|
|
445
548
|
widgetConfig: widgetName ? injectWidgetConfig(widgetName) : null,
|
|
446
549
|
defaultConfig,
|
|
447
550
|
events,
|
|
448
551
|
afterInit,
|
|
552
|
+
slotTemplates: slotTemplates,
|
|
553
|
+
slotChildren,
|
|
449
554
|
});
|
|
450
555
|
return {
|
|
451
556
|
/**
|
|
@@ -502,12 +607,12 @@ class SlotHandler {
|
|
|
502
607
|
constructor(viewContainerRef) {
|
|
503
608
|
this.viewContainerRef = viewContainerRef;
|
|
504
609
|
}
|
|
505
|
-
slotChange(
|
|
506
|
-
propsChange(
|
|
610
|
+
slotChange(_slot, _props) { }
|
|
611
|
+
propsChange(_slot, _props) { }
|
|
507
612
|
destroy() { }
|
|
508
613
|
}
|
|
509
614
|
class StringSlotComponent {
|
|
510
|
-
static { this.ɵfac = function StringSlotComponent_Factory(
|
|
615
|
+
static { this.ɵfac = function StringSlotComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || StringSlotComponent)(); }; }
|
|
511
616
|
static { this.ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: StringSlotComponent, selectors: [["ng-component"]], viewQuery: function StringSlotComponent_Query(rf, ctx) { if (rf & 1) {
|
|
512
617
|
i0.ɵɵviewQuery(_c0, 7);
|
|
513
618
|
} if (rf & 2) {
|
|
@@ -526,7 +631,7 @@ class StringSlotComponent {
|
|
|
526
631
|
type: ViewChild,
|
|
527
632
|
args: ['text', { static: true }]
|
|
528
633
|
}] }); })();
|
|
529
|
-
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(StringSlotComponent, { className: "StringSlotComponent", filePath: "slot.directive.ts", lineNumber:
|
|
634
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(StringSlotComponent, { className: "StringSlotComponent", filePath: "slot.directive.ts", lineNumber: 27 }); })();
|
|
530
635
|
const stringSlotComponentTemplate = new ComponentTemplate(StringSlotComponent, 'text');
|
|
531
636
|
class StringSlotHandler extends SlotHandler {
|
|
532
637
|
#templateRefSlotHandler = new ComponentTemplateSlotHandler(this.viewContainerRef);
|
|
@@ -575,7 +680,7 @@ class ComponentSlotHandler extends SlotHandler {
|
|
|
575
680
|
oldProperties?.delete(property);
|
|
576
681
|
}
|
|
577
682
|
}
|
|
578
|
-
propsChange(
|
|
683
|
+
propsChange(_slot, props) {
|
|
579
684
|
const oldProperties = new Set(this.#properties);
|
|
580
685
|
this.#applyProperties(props, oldProperties);
|
|
581
686
|
const componentRef = this.#componentRef;
|
|
@@ -599,7 +704,7 @@ class TemplateRefSlotHandler extends SlotHandler {
|
|
|
599
704
|
this.#props = props;
|
|
600
705
|
this.#viewRef = this.viewContainerRef.createEmbeddedView(slot, props);
|
|
601
706
|
}
|
|
602
|
-
propsChange(
|
|
707
|
+
propsChange(_slot, props) {
|
|
603
708
|
if (this.#viewRef) {
|
|
604
709
|
const templateProps = this.#props;
|
|
605
710
|
const oldProperties = new Set(Object.keys(templateProps));
|
|
@@ -632,7 +737,7 @@ class ComponentTemplateSlotHandler extends SlotHandler {
|
|
|
632
737
|
this.#templateRef = this.#componentRef.instance[slot.templateProp];
|
|
633
738
|
this.#templateSlotHandler.slotChange(this.#templateRef, props);
|
|
634
739
|
}
|
|
635
|
-
propsChange(
|
|
740
|
+
propsChange(_slot, props) {
|
|
636
741
|
this.#templateSlotHandler.propsChange(this.#templateRef, props);
|
|
637
742
|
}
|
|
638
743
|
destroy() {
|
|
@@ -664,11 +769,23 @@ const getSlotType = (value) => {
|
|
|
664
769
|
}
|
|
665
770
|
return undefined;
|
|
666
771
|
};
|
|
772
|
+
/**
|
|
773
|
+
* A directive that manages slot content and its properties.
|
|
774
|
+
*
|
|
775
|
+
* @template Props - A record type representing the properties for the slot.
|
|
776
|
+
*
|
|
777
|
+
* @remarks
|
|
778
|
+
* This directive handles changes to the slot content and its properties,
|
|
779
|
+
* and manages the lifecycle of the slot handler.
|
|
780
|
+
*/
|
|
667
781
|
class SlotDirective {
|
|
668
782
|
constructor() {
|
|
669
783
|
this._viewContainerRef = inject(ViewContainerRef);
|
|
670
784
|
}
|
|
671
|
-
/**
|
|
785
|
+
/**
|
|
786
|
+
* @param changes SimpleChanges from Angular
|
|
787
|
+
* @internal
|
|
788
|
+
*/
|
|
672
789
|
ngOnChanges(changes) {
|
|
673
790
|
const slotChange = changes['slot'];
|
|
674
791
|
const propsChange = changes['props'];
|
|
@@ -686,12 +803,12 @@ class SlotDirective {
|
|
|
686
803
|
this._slotHandler?.propsChange(slot, this.props);
|
|
687
804
|
}
|
|
688
805
|
}
|
|
689
|
-
/** @
|
|
806
|
+
/** @internal */
|
|
690
807
|
ngOnDestroy() {
|
|
691
808
|
this._slotHandler?.destroy();
|
|
692
809
|
this._slotHandler = undefined;
|
|
693
810
|
}
|
|
694
|
-
static { this.ɵfac = function SlotDirective_Factory(
|
|
811
|
+
static { this.ɵfac = function SlotDirective_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || SlotDirective)(); }; }
|
|
695
812
|
static { this.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: SlotDirective, selectors: [["", "auSlot", ""]], inputs: { slot: [0, "auSlot", "slot"], props: [0, "auSlotProps", "props"] }, standalone: true, features: [i0.ɵɵNgOnChangesFeature] }); }
|
|
696
813
|
}
|
|
697
814
|
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(SlotDirective, [{
|
|
@@ -707,28 +824,6 @@ class SlotDirective {
|
|
|
707
824
|
type: Input,
|
|
708
825
|
args: [{ alias: 'auSlotProps', required: true }]
|
|
709
826
|
}] }); })();
|
|
710
|
-
/**
|
|
711
|
-
* Directive that allows to pass the templateRef associated to a ng-content to a store.
|
|
712
|
-
* The input of the directive is a {@link WritableSignal}<{children: {@link SlotContent}<T>}>.
|
|
713
|
-
*/
|
|
714
|
-
class ContentAsSlotDirective {
|
|
715
|
-
constructor() {
|
|
716
|
-
this.templateRef = inject((TemplateRef));
|
|
717
|
-
}
|
|
718
|
-
/** @inheritdoc */
|
|
719
|
-
ngOnInit() {
|
|
720
|
-
this.auContentAsSlot.update((value) => ({ ...value, children: this.templateRef }));
|
|
721
|
-
}
|
|
722
|
-
static { this.ɵfac = function ContentAsSlotDirective_Factory(t) { return new (t || ContentAsSlotDirective)(); }; }
|
|
723
|
-
static { this.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: ContentAsSlotDirective, selectors: [["", "auContentAsSlot", ""]], inputs: { auContentAsSlot: "auContentAsSlot" }, standalone: true }); }
|
|
724
|
-
}
|
|
725
|
-
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ContentAsSlotDirective, [{
|
|
726
|
-
type: Directive,
|
|
727
|
-
args: [{ selector: '[auContentAsSlot]', standalone: true }]
|
|
728
|
-
}], null, { auContentAsSlot: [{
|
|
729
|
-
type: Input,
|
|
730
|
-
args: [{ alias: 'auContentAsSlot', required: true }]
|
|
731
|
-
}] }); })();
|
|
732
827
|
|
|
733
828
|
/*
|
|
734
829
|
* Public API Surface of @agnos-ui/angular-headless
|
|
@@ -738,5 +833,5 @@ class ContentAsSlotDirective {
|
|
|
738
833
|
* Generated bundle index. Do not edit.
|
|
739
834
|
*/
|
|
740
835
|
|
|
741
|
-
export { BaseWidgetDirective, ComponentTemplate,
|
|
836
|
+
export { BaseWidgetDirective, ComponentTemplate, SlotComponent, SlotDirective, UseDirective, UseMultiDirective, ZoneWrapper, auBooleanAttribute, auNumberAttribute, callWidgetFactory, callWidgetFactoryWithConfig, injectWidgetConfig, injectWidgetsConfig, provideWidgetsConfig, toAngularSignal, useDirectiveForHost, widgetsConfigFactory, widgetsConfigInjectionToken };
|
|
742
837
|
//# sourceMappingURL=agnos-ui-angular-headless.mjs.map
|