@agnos-ui/angular-headless 0.4.4 → 0.5.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.
@@ -1 +1 @@
1
- {"version":3,"file":"agnos-ui-angular-headless.mjs","sources":["../../src/utils/zone.ts","../../src/utils/stores.ts","../../src/utils/directive.ts","../../src/types.ts","../../src/utils/widget.ts","../../src/config.ts","../../src/utils/coercion.ts","../../src/slot.directive.ts","../../src/index.ts","../../src/agnos-ui-angular-headless.ts"],"sourcesContent":["import {Injectable, NgZone, inject} from '@angular/core';\n\nconst noop = () => {};\nconst identity = <T>(a: T) => a;\n\ntype Wrapper = <T>(fn: T) => T;\n\nconst createObjectWrapper =\n\t(wrap: Wrapper): Wrapper =>\n\t(object) => {\n\t\tif (!object || typeof object !== 'object') {\n\t\t\treturn object;\n\t\t}\n\t\tconst res = {} as any;\n\t\tfor (const key of Object.keys(object)) {\n\t\t\tres[key] = wrap((object as any)[key]);\n\t\t}\n\t\treturn res;\n\t};\n\nconst createReturnValueWrapper =\n\t(wrapReturnValue: Wrapper, wrapResult: Wrapper): Wrapper =>\n\t(fn) =>\n\t\twrapResult(typeof fn === 'function' ? (((...args: any[]) => wrapReturnValue(fn(...args))) as any) : fn);\n\n@Injectable({\n\tprovidedIn: 'root',\n})\nexport class ZoneWrapper {\n\treadonly #zone = inject(NgZone);\n\treadonly #hasZone = this.#zone.run(() => NgZone.isInAngularZone()); // check if zone is enabled (can be NoopZone, cf https://angular.io/guide/zone#noopzone)\n\t#runNeeded = false;\n\t#runPlanned = false;\n\n\tplanNgZoneRun = this.#hasZone\n\t\t? () => {\n\t\t\t\tif (this.#zone.isStable) {\n\t\t\t\t\tthis.#runNeeded = true;\n\t\t\t\t\tif (!this.#runPlanned) {\n\t\t\t\t\t\tthis.#runPlanned = true;\n\t\t\t\t\t\tvoid (async () => {\n\t\t\t\t\t\t\tawait 0;\n\t\t\t\t\t\t\tthis.#runPlanned = false;\n\t\t\t\t\t\t\tif (this.#runNeeded) {\n\t\t\t\t\t\t\t\tthis.ngZoneRun(noop);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t})();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t: noop;\n\n\t/**\n\t * Run the input function synchronously within the Angular zone\n\t *\n\t * @param fn - a function to run\n\t * @returns the value returned by the function\n\t */\n\tngZoneRun<T>(fn: () => T): T {\n\t\tthis.#runNeeded = false;\n\t\treturn this.#zone.run(fn);\n\t}\n\n\tinsideNgZone: Wrapper = this.#hasZone\n\t\t? (fn) => (typeof fn === 'function' ? (((...args: any[]) => this.ngZoneRun(() => fn(...args))) as any) : fn)\n\t\t: identity;\n\tinsideNgZoneWrapFunctionsObject = createObjectWrapper(this.insideNgZone);\n\n\toutsideNgZone: Wrapper = this.#hasZone\n\t\t? (fn) => (typeof fn === 'function' ? (((...args: any[]) => this.#zone.runOutsideAngular(() => fn(...args))) as any) : fn)\n\t\t: identity;\n\n\toutsideNgZoneWrapFunctionsObject = createObjectWrapper(this.outsideNgZone);\n\toutsideNgZoneWrapDirective = createReturnValueWrapper(this.outsideNgZoneWrapFunctionsObject, this.outsideNgZone);\n\toutsideNgZoneWrapDirectivesObject = createObjectWrapper(this.outsideNgZoneWrapDirective);\n}\n","import type {ReadableSignal} from '@amadeus-it-group/tansu';\nimport type {Signal} from '@angular/core';\nimport {DestroyRef, inject, signal} from '@angular/core';\nimport {ZoneWrapper} from './zone';\n\nexport * from '@agnos-ui/core/utils/stores';\n\n/**\n * Convert a tansu readable signal into an Angular signal.\n *\n * @param tansuSignal - a tansu readable signal\n * @returns an angular signal\n *\n * @remarks\n * Note that as it uses Angular's `inject`, this can only be called at component construction time.\n */\nexport const toAngularSignal = <T>(tansuSignal: ReadableSignal<T>): Signal<T> => {\n\tconst zoneWrapper = inject(ZoneWrapper);\n\t// The equality of objects from 2 sequential emissions is already checked in tansu signal.\n\t// Here we'll always emit the value received from tansu signal, therefor the equality function\n\tconst res = signal(undefined as any as T, {equal: () => false});\n\tconst subscription = zoneWrapper.outsideNgZone(tansuSignal.subscribe)((value) => {\n\t\tres.set(value);\n\t\tzoneWrapper.planNgZoneRun();\n\t});\n\tinject(DestroyRef).onDestroy(zoneWrapper.outsideNgZone(subscription));\n\treturn res;\n};\n","import type {Directive as AgnosUIDirective, DirectiveAndParam, DirectivesAndOptParam} from '@agnos-ui/core/types';\nimport {multiDirective} from '@agnos-ui/core/utils/directive';\nimport {isPlatformServer} from '@angular/common';\nimport type {OnChanges} from '@angular/core';\nimport {DestroyRef, Directive, ElementRef, Injector, Input, PLATFORM_ID, afterNextRender, inject, runInInjectionContext} from '@angular/core';\n\nexport * from '@agnos-ui/core/utils/directive';\n\n/**\n * Set up an agnos-ui directive as an angular host directive.\n *\n * @param directive - the directive\n * @param params - the params to pass to the directive\n * @returns the update function to change the directive or params\n */\nexport const useDirectiveForHost = <T>(directive?: AgnosUIDirective<T>, params?: T) => {\n\tconst injector = inject(Injector);\n\tconst ref = inject(ElementRef);\n\tconst platform = inject(PLATFORM_ID);\n\n\tlet instance: undefined | ReturnType<AgnosUIDirective<T>>;\n\tlet plannedCallDirective = false;\n\n\tconst callDirective = isPlatformServer(platform)\n\t\t? () => {\n\t\t\t\tinstance = directive?.(ref.nativeElement, params as T);\n\t\t\t}\n\t\t: () => {\n\t\t\t\tif (plannedCallDirective || !directive) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tplannedCallDirective = true;\n\t\t\t\trunInInjectionContext(injector, () => {\n\t\t\t\t\tafterNextRender(() => {\n\t\t\t\t\t\tplannedCallDirective = false;\n\t\t\t\t\t\tinstance = directive?.(ref.nativeElement, params as T);\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t};\n\n\tfunction destroyDirectiveInstance() {\n\t\tconst oldInstance = instance;\n\t\tinstance = undefined;\n\t\tdirective = undefined;\n\t\toldInstance?.destroy?.();\n\t}\n\n\tinject(DestroyRef).onDestroy(destroyDirectiveInstance);\n\n\tfunction update(newDirective?: AgnosUIDirective<T>, newParams?: T) {\n\t\tif (newDirective !== directive) {\n\t\t\tvoid destroyDirectiveInstance();\n\t\t\tdirective = newDirective;\n\t\t\tparams = newParams;\n\t\t\tcallDirective();\n\t\t} else if (newParams != params) {\n\t\t\tparams = newParams;\n\t\t\tinstance?.update?.(params as T);\n\t\t}\n\t}\n\n\tcallDirective();\n\treturn {update};\n};\n\n@Directive({\n\tstandalone: true,\n\tselector: '[auUse]',\n})\nexport class UseDirective<T> implements OnChanges {\n\t@Input('auUse')\n\tuse: AgnosUIDirective | DirectiveAndParam<T> | undefined;\n\n\treadonly #useDirective = useDirectiveForHost<T>();\n\n\t/** @inheritdoc */\n\tngOnChanges() {\n\t\tconst use = this.use;\n\t\tconst [directive, param] = Array.isArray(use) ? use : [use as any];\n\t\tthis.#useDirective.update(directive, param);\n\t}\n}\n\n@Directive({\n\tstandalone: true,\n\tselector: '[auUseMulti]',\n})\nexport class UseMultiDirective<T extends any[]> implements OnChanges {\n\t@Input({alias: 'auUseMulti', required: true})\n\tuseMulti!: DirectivesAndOptParam<T>;\n\n\treadonly #useDirective = useDirectiveForHost<DirectivesAndOptParam<T>>();\n\n\t/** @inheritdoc */\n\tngOnChanges() {\n\t\tthis.#useDirective.update(multiDirective, this.useMulti);\n\t}\n}\n","import type {ContextWidget, SlotContent as CoreSlotContent, Widget, WidgetProps, WidgetState, Extends} from '@agnos-ui/core/types';\nimport type {Signal, TemplateRef, Type} from '@angular/core';\nimport {Directive, Input} from '@angular/core';\n\nexport * from '@agnos-ui/core/types';\n\nexport class ComponentTemplate<Props, K extends string, T extends {[key in K]: TemplateRef<Props>}> {\n\tconstructor(\n\t\tpublic readonly component: Type<T>,\n\t\tpublic readonly templateProp: K,\n\t) {}\n}\n\nexport type SlotContent<Props extends object = object> =\n\t| CoreSlotContent<Props>\n\t| TemplateRef<Props>\n\t| Type<unknown>\n\t| ComponentTemplate<Props, any, any>;\n\n@Directive()\nexport abstract class SlotComponent<W extends Widget> {\n\t@Input()\n\tstate!: WidgetState<W>;\n\t@Input()\n\twidget!: ContextWidget<W>;\n}\n\nexport type IsSlotContent<T> = Extends<T, SlotContent<any>> | Extends<SlotContent<any>, T> extends 1 ? T : 0;\n\nexport type AngularWidget<W extends Widget> = W & {\n\tinitialized: Promise<void>;\n\twidget: ContextWidget<W>;\n\tngState: Signal<WidgetState<W>>;\n\tngInit: () => void;\n\tpatchSlots(slots: {\n\t\t[K in keyof WidgetProps<W> as IsSlotContent<WidgetProps<W>[K]> extends 0 ? never : K]: WidgetProps<W>[K] extends SlotContent<infer U>\n\t\t\t? TemplateRef<U> | undefined\n\t\t\t: never;\n\t}): void;\n};\n","import {computed, writable, type ReadableSignal} from '@amadeus-it-group/tansu';\nimport type {OnChanges, OnInit, Signal, SimpleChanges} from '@angular/core';\nimport {Directive, Injector, inject, runInInjectionContext} from '@angular/core';\nimport {\n\ttoSlotContextWidget,\n\ttype AngularWidget,\n\ttype ContextWidget,\n\ttype Widget,\n\ttype WidgetFactory,\n\ttype WidgetProps,\n\ttype WidgetState,\n} from '../types';\nimport {toAngularSignal, toReadableStore} from './stores';\nimport {ZoneWrapper} from './zone';\n\nconst createPatchSlots = <T extends object>(set: (object: Partial<T>) => void) => {\n\tlet lastValue: Partial<T> = {};\n\treturn (object: T) => {\n\t\tconst newValue: Partial<T> = {};\n\t\tlet hasChange = false;\n\t\tfor (const key of Object.keys(object) as (string & keyof T)[]) {\n\t\t\tconst objectKey = (object as any)[key];\n\t\t\tif (objectKey != null) {\n\t\t\t\t// only use defined slots\n\t\t\t\tnewValue[key] = objectKey;\n\t\t\t}\n\t\t\tif (objectKey != lastValue[key]) {\n\t\t\t\thasChange = true;\n\t\t\t}\n\t\t}\n\t\tif (hasChange) {\n\t\t\tlastValue = newValue;\n\t\t\tset(newValue);\n\t\t}\n\t};\n};\n\n/**\n * Call a widget factory using provided configs.\n *\n * @param parameter - the parameter\n * @param parameter.factory - the widget factory to call\n * @param parameter.defaultConfig - the default config of the widget\n * @param parameter.widgetConfig - the config of the widget, overriding the defaultConfig\n * @param parameter.events - the events of the widget\n * @param parameter.afterInit - a callback to call after successful setup of the widget\n * @returns the widget\n */\nexport const callWidgetFactoryWithConfig = <W extends Widget>({\n\tfactory,\n\tdefaultConfig,\n\twidgetConfig,\n\tevents,\n\tafterInit,\n}: {\n\tfactory: WidgetFactory<W>;\n\tdefaultConfig?: Partial<WidgetProps<W>> | ReadableSignal<Partial<WidgetProps<W>> | undefined>;\n\twidgetConfig?: null | undefined | ReadableSignal<Partial<WidgetProps<W>> | undefined>;\n\tevents?: Pick<WidgetProps<W>, keyof WidgetProps<W> & `on${string}`>;\n\tafterInit?: () => void;\n}): AngularWidget<W> => {\n\tconst injector = inject(Injector);\n\tconst slots$ = writable({});\n\tconst props = {};\n\tlet initDone: () => void;\n\tconst res = {\n\t\tinitialized: new Promise((resolve) => {\n\t\t\tinitDone = resolve;\n\t\t}),\n\t\tpatchSlots: createPatchSlots(slots$.set),\n\t\tpatch(newProps) {\n\t\t\t// temporary function replaced in ngInit\n\t\t\tObject.assign(props, newProps);\n\t\t},\n\t\tngInit() {\n\t\t\trunInInjectionContext(injector, () => {\n\t\t\t\tconst zoneWrapper = inject(ZoneWrapper);\n\t\t\t\tfactory = zoneWrapper.outsideNgZone(factory);\n\t\t\t\tconst defaultConfig$ = toReadableStore(defaultConfig);\n\t\t\t\tevents = zoneWrapper.insideNgZoneWrapFunctionsObject(events);\n\t\t\t\tconst widget = factory({\n\t\t\t\t\tconfig: computed(() => ({...defaultConfig$(), ...widgetConfig?.(), ...slots$(), ...(events as Partial<WidgetProps<W>>)})),\n\t\t\t\t\tprops,\n\t\t\t\t});\n\t\t\t\tconst wrappedWidget: W = {\n\t\t\t\t\t...widget,\n\t\t\t\t\tpatch: zoneWrapper.outsideNgZone(widget.patch),\n\t\t\t\t\tdirectives: zoneWrapper.outsideNgZoneWrapDirectivesObject(widget.directives),\n\t\t\t\t\tactions: zoneWrapper.outsideNgZoneWrapFunctionsObject(widget.actions),\n\t\t\t\t\tapi: zoneWrapper.outsideNgZoneWrapFunctionsObject(widget.api),\n\t\t\t\t};\n\t\t\t\tObject.assign(res, wrappedWidget, {\n\t\t\t\t\twidget: toSlotContextWidget(wrappedWidget),\n\t\t\t\t\tngState: toAngularSignal(wrappedWidget.state$ as ReadableSignal<WidgetState<W>>),\n\t\t\t\t});\n\t\t\t\tafterInit?.();\n\t\t\t\tinitDone();\n\t\t\t});\n\t\t},\n\t} as AngularWidget<W>;\n\n\treturn res;\n};\n\nfunction patchSimpleChanges(patchFn: (obj: any) => void, changes: SimpleChanges) {\n\tconst obj: any = {};\n\tfor (const [key, simpleChange] of Object.entries(changes)) {\n\t\tif (simpleChange !== undefined) {\n\t\t\tobj[key] = simpleChange.currentValue;\n\t\t}\n\t}\n\tpatchFn(obj);\n}\n\n@Directive()\nexport abstract class BaseWidgetDirective<W extends Widget> implements OnChanges, OnInit {\n\tprotected abstract readonly _widget: AngularWidget<W>;\n\n\tget api(): W['api'] {\n\t\treturn this._widget.api;\n\t}\n\n\tget state(): Signal<WidgetState<W>> {\n\t\treturn this._widget.ngState;\n\t}\n\n\tget widget(): ContextWidget<W> {\n\t\treturn this._widget.widget;\n\t}\n\n\t/** @inheritdoc */\n\tngOnChanges(changes: SimpleChanges): void {\n\t\tpatchSimpleChanges(this._widget.patch, changes);\n\t}\n\n\t/** @inheritdoc */\n\tngOnInit(): void {\n\t\tthis._widget.ngInit();\n\t}\n}\n","import type {Widget, WidgetFactory, WidgetProps} from '@agnos-ui/core/types';\nimport type {Partial2Levels, WidgetsConfigStore, WidgetsConfig} from '@agnos-ui/core/config';\nimport {createWidgetsConfig} from '@agnos-ui/core/config';\nimport type {ReadableSignal} from '@amadeus-it-group/tansu';\nimport {computed} from '@amadeus-it-group/tansu';\nimport type {FactoryProvider} from '@angular/core';\nimport {InjectionToken, Injector, Optional, SkipSelf, inject, runInInjectionContext} from '@angular/core';\nimport type {AngularWidget} from './types';\nimport {callWidgetFactoryWithConfig} from './utils/widget';\n\nexport * from '@agnos-ui/core/config';\n\ntype AdaptParentConfig<Config> = (config: Partial2Levels<Config>) => Partial2Levels<Config>;\ntype InjectWidgetsConfig<Config> = (config?: Partial2Levels<Config>) => WidgetsConfigStore<Config>;\n\n/**\n * A factory to create the utilities to allow widgets to be context-aware.\n *\n * It can be used when extending the core and creating new widgets.\n *\n * @param widgetsConfigInjectionToken - the widgets config injection token\n * @returns the utilities to create / manage widgets and contexts\n */\nexport const widgetsConfigFactory = <Config extends {[widgetName: string]: object} = WidgetsConfig>(\n\twidgetsConfigInjectionToken = new InjectionToken<WidgetsConfigStore<Config>>('widgetsConfig'),\n) => {\n\t/**\n\t * Creates a provider of widgets default configuration that inherits from any widgets default configuration already defined at an upper level\n\t * in the Angular dependency injection system. It contains its own set of widgets configuration properties that override the same properties form\n\t * the parent configuration.\n\t *\n\t * @remarks\n\t * The configuration is computed from the parent configuration in two steps:\n\t * - first step: the parent configuration is transformed by the adaptParentConfig function (if specified).\n\t * If adaptParentConfig is not specified, this step is skipped.\n\t * - second step: the configuration from step 1 is merged (2-levels deep) with the own$ store. The own$ store initially contains\n\t * an empty object (i.e. no property from the parent is overridden). It can be changed by calling set on the store returned by\n\t * {@link injectWidgetsConfig}.\n\t *\n\t * @param adaptParentConfig - optional function that receives a 2-levels copy of the widgets default configuration\n\t * defined at an upper level in the Angular dependency injection system (or an empty object if there is none) and returns the widgets\n\t * default configuration to be used.\n\t * It is called only if the configuration is needed, and was not yet computed for the current value of the parent configuration.\n\t * It is called in a tansu reactive context, so it can use any tansu store and will be called again if those stores change.\n\t * It is also called in an Angular injection context, so it can call the Angular inject function to get and use dependencies from the\n\t * Angular dependency injection system.\n\t *\n\t * @returns DI provider to be included a list of `providers` (for example at a component level or\n\t * any other level of the Angular dependency injection system)\n\t *\n\t * @example\n\t * ```typescript\n\t * @Component({\n\t * // ...\n\t * providers: [\n\t * provideWidgetsConfig((parentConfig) => {\n\t * // first step configuration: transforms the parent configuration\n\t * parentConfig.rating = parentConfig.rating ?? {};\n\t * parentConfig.rating.className = `${parentConfig.rating.className ?? ''} my-rating-extra-class`\n\t * return parentConfig;\n\t * })\n\t * ]\n\t * })\n\t * class MyComponent {\n\t * widgetsConfig = injectWidgetsConfig();\n\t * constructor() {\n\t * this.widgetsConfig.set({\n\t * // second step configuration: overrides the parent configuration\n\t * rating: {\n\t * slotStar: MyCustomSlotStar\n\t * }\n\t * });\n\t * }\n\t * // ...\n\t * }\n\t * ```\n\t */\n\tconst provideWidgetsConfig = (adaptParentConfig?: AdaptParentConfig<Config>): FactoryProvider => ({\n\t\tprovide: widgetsConfigInjectionToken,\n\t\tuseFactory: (parent: WidgetsConfigStore<Config> | null) => {\n\t\t\tif (adaptParentConfig) {\n\t\t\t\tconst injector = inject(Injector);\n\t\t\t\tconst originalAdaptParentConfig = adaptParentConfig;\n\t\t\t\tadaptParentConfig = (value) => runInInjectionContext(injector, () => originalAdaptParentConfig(value));\n\t\t\t}\n\t\t\treturn createWidgetsConfig(parent ?? undefined, adaptParentConfig);\n\t\t},\n\t\tdeps: [[new SkipSelf(), new Optional(), widgetsConfigInjectionToken]],\n\t});\n\n\t/**\n\t * Returns the widgets default configuration store that was provided in the current injection context.\n\t * Throws if the no widgets default configuration store was provided.\n\t *\n\t * @param defaultConfig - values to set as soon as the config is injected\n\t * @remarks\n\t * This function must be called from an injection context, such as a constructor, a factory function, a field initializer or\n\t * a function used with {@link https://angular.io/api/core/runInInjectionContext | runInInjectionContext}.\n\t *\n\t * @returns the widgets default configuration store.\n\t */\n\tconst injectWidgetsConfig: InjectWidgetsConfig<Config> = (defaultConfig?: Partial2Levels<Config>) => {\n\t\tconst widgetsConfig = inject(widgetsConfigInjectionToken);\n\t\tif (defaultConfig) {\n\t\t\twidgetsConfig.set(defaultConfig);\n\t\t}\n\t\treturn widgetsConfig;\n\t};\n\n\tconst injectWidgetConfig = <N extends keyof Config>(widgetName: N): ReadableSignal<Partial<Config[N]> | undefined> => {\n\t\tconst widgetsConfig = inject(widgetsConfigInjectionToken, {optional: true});\n\t\treturn computed(() => widgetsConfig?.()[widgetName]);\n\t};\n\n\tconst callWidgetFactory = <W extends Widget>({\n\t\tfactory,\n\t\twidgetName = null,\n\t\tdefaultConfig = {},\n\t\tevents,\n\t\tafterInit,\n\t}: {\n\t\tfactory: WidgetFactory<W>;\n\t\twidgetName?: null | keyof Config;\n\t\tdefaultConfig?: Partial<WidgetProps<W>> | ReadableSignal<Partial<WidgetProps<W>> | undefined>;\n\t\tevents?: Pick<WidgetProps<W>, keyof WidgetProps<W> & `on${string}`>;\n\t\tafterInit?: () => void;\n\t}): AngularWidget<W> =>\n\t\tcallWidgetFactoryWithConfig({\n\t\t\tfactory,\n\t\t\twidgetConfig: widgetName ? (injectWidgetConfig(widgetName) as any) : null,\n\t\t\tdefaultConfig,\n\t\t\tevents,\n\t\t\tafterInit,\n\t\t});\n\n\treturn {\n\t\t/**\n\t\t * Dependency Injection token which can be used to provide or inject the widgets default configuration store.\n\t\t */\n\t\twidgetsConfigInjectionToken,\n\t\tprovideWidgetsConfig,\n\t\tinjectWidgetsConfig,\n\t\tinjectWidgetConfig,\n\t\tcallWidgetFactory,\n\t};\n};\n\nexport const {widgetsConfigInjectionToken, provideWidgetsConfig, injectWidgetConfig, injectWidgetsConfig, callWidgetFactory} =\n\twidgetsConfigFactory<WidgetsConfig>();\n","import {booleanAttribute, numberAttribute} from '@angular/core';\n\n/**\n * Transforms a value (typically a string) to a boolean.\n * Intended to be used as a transform function of an input.\n *\n * @example\n * ```@Input({ transform: auBooleanAttribute }) status: boolean | undefined;```\n * @param value - Value to be transformed.\n * @returns the value transformed\n */\nexport function auBooleanAttribute(value: unknown): boolean | undefined {\n\tif (value === undefined) {\n\t\treturn undefined;\n\t}\n\treturn booleanAttribute(value);\n}\n\n/**\n * Transforms a value (typically a string) to a number.\n * Intended to be used as a transform function of an input.\n * @param value - Value to be transformed.\n *\n * @example\n * ```@Input({ transform: auNumberAttribute }) id: number | undefined;```\n * @returns the value transformed\n */\nexport function auNumberAttribute(value: unknown): number | undefined {\n\tif (value === undefined) {\n\t\treturn undefined;\n\t}\n\treturn numberAttribute(value);\n}\n","import type {ComponentRef, EmbeddedViewRef, OnChanges, OnDestroy, SimpleChanges, Type, OnInit} from '@angular/core';\nimport {\n\tComponent,\n\tDirective,\n\tEnvironmentInjector,\n\tInput,\n\tTemplateRef,\n\tViewChild,\n\tViewContainerRef,\n\tcreateComponent,\n\tinject,\n\treflectComponentType,\n} from '@angular/core';\nimport type {SlotContent} from './types';\nimport {ComponentTemplate} from './types';\nimport type {WritableSignal} from '@amadeus-it-group/tansu';\n\nabstract class SlotHandler<Props extends Record<string, any>, Slot extends SlotContent<Props> = SlotContent<Props>> {\n\tconstructor(public viewContainerRef: ViewContainerRef) {}\n\tslotChange(slot: Slot, props: Props) {}\n\tpropsChange(slot: Slot, props: Props) {}\n\tdestroy() {}\n}\n\n@Component({\n\ttemplate: `<ng-template #text let-content=\"content\">{{ content }}</ng-template>`,\n})\nclass StringSlotComponent {\n\t@ViewChild('text', {static: true}) text!: TemplateRef<{content: string}>;\n}\nconst stringSlotComponentTemplate = new ComponentTemplate<{content: string}, 'text', StringSlotComponent>(StringSlotComponent, 'text');\n\nclass StringSlotHandler<Props extends Record<string, any>> extends SlotHandler<Props, string> {\n\treadonly #templateRefSlotHandler = new ComponentTemplateSlotHandler<{content: string}, 'text', StringSlotComponent>(this.viewContainerRef);\n\t#initialized = false;\n\n\toverride slotChange(content: string): void {\n\t\tif (!this.#initialized) {\n\t\t\tthis.#initialized = true;\n\t\t\tthis.#templateRefSlotHandler.slotChange(stringSlotComponentTemplate, {content});\n\t\t} else {\n\t\t\tthis.#templateRefSlotHandler.propsChange(stringSlotComponentTemplate, {content});\n\t\t}\n\t}\n\n\toverride destroy(): void {\n\t\tthis.#templateRefSlotHandler.destroy();\n\t}\n}\n\nclass FunctionSlotHandler<Props extends Record<string, any>> extends SlotHandler<Props, (props: Props) => string> {\n\treadonly #stringSlotHandler = new StringSlotHandler(this.viewContainerRef);\n\n\toverride slotChange(slot: (props: Props) => string, props: Props): void {\n\t\tthis.#stringSlotHandler.slotChange(slot(props));\n\t}\n\n\toverride propsChange(slot: (props: Props) => string, props: Props): void {\n\t\tthis.#stringSlotHandler.slotChange(slot(props));\n\t}\n\n\toverride destroy(): void {\n\t\tthis.#stringSlotHandler.destroy();\n\t}\n}\n\nclass ComponentSlotHandler<Props extends Record<string, any>> extends SlotHandler<Props, Type<unknown>> {\n\t#componentRef: ComponentRef<any> | undefined;\n\t#properties?: string[];\n\n\toverride slotChange(slot: Type<unknown>, props: Props): void {\n\t\tif (this.#componentRef) {\n\t\t\tthis.destroy();\n\t\t}\n\t\tthis.#componentRef = this.viewContainerRef.createComponent(slot);\n\t\tthis.#applyProperties(props);\n\t}\n\n\t#applyProperties(props: Props, oldProperties?: Set<string>) {\n\t\tconst properties = Object.keys(props);\n\t\tthis.#properties = properties;\n\t\tconst componentRef = this.#componentRef!;\n\t\tfor (const property of properties) {\n\t\t\tcomponentRef.setInput(property, props[property]);\n\t\t\toldProperties?.delete(property);\n\t\t}\n\t}\n\n\toverride propsChange(slot: Type<unknown>, props: Props): void {\n\t\tconst oldProperties = new Set(this.#properties);\n\t\tthis.#applyProperties(props, oldProperties);\n\t\tconst componentRef = this.#componentRef!;\n\t\tfor (const property of oldProperties) {\n\t\t\tcomponentRef.setInput(property, undefined);\n\t\t}\n\t}\n\n\toverride destroy(): void {\n\t\tthis.viewContainerRef.clear();\n\t\tthis.#componentRef = undefined;\n\t}\n}\n\nclass TemplateRefSlotHandler<Props extends Record<string, any>> extends SlotHandler<Props, TemplateRef<Props>> {\n\t#viewRef: EmbeddedViewRef<Props> | undefined;\n\t#props?: Props;\n\n\toverride slotChange(slot: TemplateRef<Props>, props: Props): void {\n\t\tif (this.#viewRef) {\n\t\t\tthis.destroy();\n\t\t}\n\t\tprops = {...props};\n\t\tthis.#props = props;\n\t\tthis.#viewRef = this.viewContainerRef.createEmbeddedView(slot, props);\n\t}\n\n\toverride propsChange(slot: TemplateRef<Props>, props: Props): void {\n\t\tif (this.#viewRef) {\n\t\t\tconst templateProps = this.#props!;\n\t\t\tconst oldProperties = new Set<keyof Props>(Object.keys(templateProps));\n\t\t\tfor (const property of Object.keys(props) as (keyof Props)[]) {\n\t\t\t\ttemplateProps[property] = props[property];\n\t\t\t\toldProperties.delete(property);\n\t\t\t}\n\t\t\tfor (const oldProperty of oldProperties) {\n\t\t\t\tdelete templateProps[oldProperty];\n\t\t\t}\n\t\t\tthis.#viewRef.markForCheck();\n\t\t}\n\t}\n\n\toverride destroy(): void {\n\t\tthis.viewContainerRef.clear();\n\t}\n}\n\nclass ComponentTemplateSlotHandler<\n\tProps extends Record<string, any>,\n\tK extends string,\n\tT extends {[key in K]: TemplateRef<Props>},\n> extends SlotHandler<Props, ComponentTemplate<Props, K, T>> {\n\t#componentRef: ComponentRef<T> | undefined;\n\treadonly #templateSlotHandler = new TemplateRefSlotHandler(this.viewContainerRef);\n\t#templateRef: TemplateRef<Props> | undefined;\n\n\toverride slotChange(slot: ComponentTemplate<Props, K, T>, props: Props): void {\n\t\tif (this.#componentRef) {\n\t\t\tthis.destroy();\n\t\t}\n\t\tthis.#componentRef = createComponent(slot.component, {\n\t\t\telementInjector: this.viewContainerRef.injector,\n\t\t\tenvironmentInjector: this.viewContainerRef.injector.get(EnvironmentInjector),\n\t\t});\n\t\tthis.#templateRef = this.#componentRef.instance[slot.templateProp];\n\t\tthis.#templateSlotHandler.slotChange(this.#templateRef, props);\n\t}\n\n\toverride propsChange(slot: ComponentTemplate<Props, K, T>, props: Props): void {\n\t\tthis.#templateSlotHandler.propsChange(this.#templateRef!, props);\n\t}\n\n\toverride destroy(): void {\n\t\tthis.#templateSlotHandler.destroy();\n\t\tthis.#componentRef?.destroy();\n\t\tthis.#componentRef = undefined;\n\t}\n}\n\nconst getSlotType = (value: any): undefined | {new (viewContainerRef: ViewContainerRef): SlotHandler<any>} => {\n\tif (!value) return undefined;\n\tconst type = typeof value;\n\tswitch (type) {\n\t\tcase 'string':\n\t\t\treturn StringSlotHandler;\n\t\tcase 'function':\n\t\t\tif (reflectComponentType(value)) {\n\t\t\t\treturn ComponentSlotHandler;\n\t\t\t}\n\t\t\treturn FunctionSlotHandler;\n\t\tcase 'object':\n\t\t\tif (value instanceof TemplateRef) {\n\t\t\t\treturn TemplateRefSlotHandler;\n\t\t\t}\n\t\t\tif (value instanceof ComponentTemplate) {\n\t\t\t\treturn ComponentTemplateSlotHandler;\n\t\t\t}\n\t\t\tbreak;\n\t}\n\treturn undefined;\n};\n\n@Directive({\n\tselector: '[auSlot]',\n\tstandalone: true,\n})\nexport class SlotDirective<Props extends Record<string, any>> implements OnChanges, OnDestroy {\n\t@Input('auSlot') slot: SlotContent<Props>;\n\t@Input({alias: 'auSlotProps', required: true}) props!: Props;\n\n\tprivate readonly _viewContainerRef = inject(ViewContainerRef);\n\tprivate _slotType: ReturnType<typeof getSlotType>;\n\tprivate _slotHandler: SlotHandler<Props> | undefined;\n\n\t/** @inheritdoc */\n\tngOnChanges(changes: SimpleChanges): void {\n\t\tconst slotChange = changes['slot'];\n\t\tconst propsChange = changes['props'];\n\t\tconst slot = this.slot;\n\t\tif (slotChange) {\n\t\t\tconst newSlotType = getSlotType(slot);\n\t\t\tif (newSlotType !== this._slotType) {\n\t\t\t\tthis._slotHandler?.destroy();\n\t\t\t\tthis._slotHandler = newSlotType ? new newSlotType(this._viewContainerRef) : undefined;\n\t\t\t\tthis._slotType = newSlotType;\n\t\t\t}\n\t\t\tthis._slotHandler?.slotChange(slot, this.props);\n\t\t} else if (propsChange) {\n\t\t\tthis._slotHandler?.propsChange(slot, this.props);\n\t\t}\n\t}\n\n\t/** @inheritdoc */\n\tngOnDestroy(): void {\n\t\tthis._slotHandler?.destroy();\n\t\tthis._slotHandler = undefined;\n\t}\n}\n\n/**\n * Directive that allows to pass the templateRef associated to a ng-content to a store.\n * The input of the directive is a {@link WritableSignal}<{children: {@link SlotContent}<T>}>.\n */\n@Directive({selector: '[auContentAsSlot]', standalone: true})\nexport class ContentAsSlotDirective<T extends object> implements OnInit {\n\t@Input({alias: 'auContentAsSlot', required: true}) auContentAsSlot!: WritableSignal<{children?: SlotContent<T>}>;\n\n\ttemplateRef = inject(TemplateRef<T>);\n\n\t/** @inheritdoc */\n\tngOnInit(): void {\n\t\tthis.auContentAsSlot.update((value) => ({...value, children: this.templateRef}));\n\t}\n}\n","/*\n * Public API Surface of @agnos-ui/angular-headless\n */\nexport * from './generated';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAM,IAAI,GAAG,MAAK,GAAG,CAAC;AACtB,MAAM,QAAQ,GAAG,CAAI,CAAI,KAAK,CAAC,CAAC;AAIhC,MAAM,mBAAmB,GACxB,CAAC,IAAa,KACd,CAAC,MAAM,KAAI;IACV,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;AAC1C,QAAA,OAAO,MAAM,CAAC;KACd;IACD,MAAM,GAAG,GAAG,EAAS,CAAC;IACtB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;QACtC,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAE,MAAc,CAAC,GAAG,CAAC,CAAC,CAAC;KACtC;AACD,IAAA,OAAO,GAAG,CAAC;AACZ,CAAC,CAAC;AAEH,MAAM,wBAAwB,GAC7B,CAAC,eAAwB,EAAE,UAAmB,KAC9C,CAAC,EAAE,KACF,UAAU,CAAC,OAAO,EAAE,KAAK,UAAU,IAAK,CAAC,GAAG,IAAW,KAAK,eAAe,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,IAAY,EAAE,CAAC,CAAC;MAK7F,WAAW,CAAA;AAHxB,IAAA,WAAA,GAAA;AAIU,QAAA,IAAA,CAAA,KAAK,GAAG,MAAM,CAA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E,KAAK;AAAC,YAAA,IAAA,EAAA,CAAA,EAAC,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAA;;;AC1OlD;;AAEG;;ACFH;;AAEG;;;;"}
1
+ {"version":3,"file":"agnos-ui-angular-headless.mjs","sources":["../../src/utils/zone.ts","../../src/utils/stores.ts","../../src/utils/directive.ts","../../src/types.ts","../../src/utils/widget.ts","../../src/config.ts","../../src/utils/coercion.ts","../../src/slot.directive.ts","../../src/index.ts","../../src/agnos-ui-angular-headless.ts"],"sourcesContent":["import {Injectable, NgZone, inject} from '@angular/core';\n\nconst noop = () => {};\nconst identity = <T>(a: T) => a;\n\ntype Wrapper = <T>(fn: T) => T;\n\nconst createObjectWrapper =\n\t(wrap: Wrapper): Wrapper =>\n\t(object) => {\n\t\tif (!object || typeof object !== 'object') {\n\t\t\treturn object;\n\t\t}\n\t\tconst res = {} as any;\n\t\tfor (const key of Object.keys(object)) {\n\t\t\tres[key] = wrap((object as any)[key]);\n\t\t}\n\t\treturn res;\n\t};\n\nconst createReturnValueWrapper =\n\t(wrapReturnValue: Wrapper, wrapResult: Wrapper): Wrapper =>\n\t(fn) =>\n\t\twrapResult(typeof fn === 'function' ? (((...args: any[]) => wrapReturnValue(fn(...args))) as any) : fn);\n\n/**\n * A utility class that provides methods to run functions inside or outside of Angular's NgZone.\n * This can be useful for optimizing performance by avoiding unnecessary change detection cycles.\n */\n@Injectable({\n\tprovidedIn: 'root',\n})\nexport class ZoneWrapper {\n\treadonly #zone = inject(NgZone);\n\treadonly #hasZone = this.#zone.run(() => NgZone.isInAngularZone()); // check if zone is enabled (can be NoopZone, cf https://angular.io/guide/zone#noopzone)\n\t#runNeeded = false;\n\t#runPlanned = false;\n\n\tplanNgZoneRun = this.#hasZone\n\t\t? () => {\n\t\t\t\tif (this.#zone.isStable) {\n\t\t\t\t\tthis.#runNeeded = true;\n\t\t\t\t\tif (!this.#runPlanned) {\n\t\t\t\t\t\tthis.#runPlanned = true;\n\t\t\t\t\t\tvoid (async () => {\n\t\t\t\t\t\t\tawait Promise.resolve();\n\t\t\t\t\t\t\tthis.#runPlanned = false;\n\t\t\t\t\t\t\tif (this.#runNeeded) {\n\t\t\t\t\t\t\t\tthis.ngZoneRun(noop);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t})();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t: noop;\n\n\t/**\n\t * Run the input function synchronously within the Angular zone\n\t *\n\t * @param fn - a function to run\n\t * @returns the value returned by the function\n\t */\n\tngZoneRun<T>(fn: () => T): T {\n\t\tthis.#runNeeded = false;\n\t\treturn this.#zone.run(fn);\n\t}\n\n\tinsideNgZone: Wrapper = this.#hasZone\n\t\t? (fn) => (typeof fn === 'function' ? (((...args: any[]) => this.ngZoneRun(() => fn(...args))) as any) : fn)\n\t\t: identity;\n\tinsideNgZoneWrapFunctionsObject = createObjectWrapper(this.insideNgZone);\n\n\toutsideNgZone: Wrapper = this.#hasZone\n\t\t? (fn) => (typeof fn === 'function' ? (((...args: any[]) => this.#zone.runOutsideAngular(() => fn(...args))) as any) : fn)\n\t\t: identity;\n\n\toutsideNgZoneWrapFunctionsObject = createObjectWrapper(this.outsideNgZone);\n\toutsideNgZoneWrapDirective = createReturnValueWrapper(this.outsideNgZoneWrapFunctionsObject, this.outsideNgZone);\n\toutsideNgZoneWrapDirectivesObject = createObjectWrapper(this.outsideNgZoneWrapDirective);\n}\n","import type {ReadableSignal} from '@amadeus-it-group/tansu';\nimport type {Signal} from '@angular/core';\nimport {DestroyRef, inject, signal} from '@angular/core';\nimport {ZoneWrapper} from './zone';\n\nexport * from '@agnos-ui/core/utils/stores';\n\n/**\n * Converts a Tansu `ReadableSignal` to an Angular `Signal`.\n *\n * This function wraps the provided Tansu signal in an Angular signal, ensuring that updates\n * are properly handled within Angular's zone. It subscribes to the Tansu signal and updates\n * the Angular signal with the received values. The equality function for the Angular signal\n * is set to always return false, ensuring that every new value from the Tansu signal triggers\n * an update.\n *\n * @template T - The type of the value emitted by the signals.\n * @param tansuSignal - The Tansu signal to convert.\n * @returns - The resulting Angular signal.\n */\nexport const toAngularSignal = <T>(tansuSignal: ReadableSignal<T>): Signal<T> => {\n\tconst zoneWrapper = inject(ZoneWrapper);\n\t// The equality of objects from 2 sequential emissions is already checked in tansu signal.\n\t// Here we'll always emit the value received from tansu signal, therefor the equality function\n\tconst res = signal(undefined as any as T, {equal: () => false});\n\tconst subscription = zoneWrapper.outsideNgZone(tansuSignal.subscribe)((value) => {\n\t\tres.set(value);\n\t\tzoneWrapper.planNgZoneRun();\n\t});\n\tinject(DestroyRef).onDestroy(zoneWrapper.outsideNgZone(subscription));\n\treturn res;\n};\n","import type {Directive as AgnosUIDirective, DirectiveAndParam, DirectivesAndOptParam} from '@agnos-ui/core/types';\nimport {multiDirective} from '@agnos-ui/core/utils/directive';\nimport {isPlatformServer} from '@angular/common';\nimport type {OnChanges} from '@angular/core';\nimport {DestroyRef, Directive, ElementRef, Injector, Input, PLATFORM_ID, afterNextRender, inject, runInInjectionContext} from '@angular/core';\n\nexport * from '@agnos-ui/core/utils/directive';\n\n/**\n * A utility function to manage the lifecycle of a directive for a host element.\n *\n * This function handles the creation, updating, and destruction of a directive instance\n * associated with a host element. It ensures that the directive is called appropriately\n * based on the platform (server or client) and manages the directive's lifecycle within\n * the Angular injection context.\n *\n * @template T - The type of parameters that the directive accepts.\n *\n * @param [directive] - The directive to be applied to the host element.\n * @param [params] - The parameters to be passed to the directive.\n *\n * @returns An object containing an `update` function to update the directive and its parameters.\n */\nexport const useDirectiveForHost = <T>(directive?: AgnosUIDirective<T>, params?: T) => {\n\tconst injector = inject(Injector);\n\tconst ref = inject(ElementRef);\n\tconst platform = inject(PLATFORM_ID);\n\n\tlet instance: undefined | ReturnType<AgnosUIDirective<T>>;\n\tlet plannedCallDirective = false;\n\n\tconst callDirective = isPlatformServer(platform)\n\t\t? () => {\n\t\t\t\tinstance = directive?.(ref.nativeElement, params as T);\n\t\t\t}\n\t\t: () => {\n\t\t\t\tif (plannedCallDirective || !directive) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tplannedCallDirective = true;\n\t\t\t\trunInInjectionContext(injector, () => {\n\t\t\t\t\tafterNextRender(() => {\n\t\t\t\t\t\tplannedCallDirective = false;\n\t\t\t\t\t\tinstance = directive?.(ref.nativeElement, params as T);\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t};\n\n\tfunction destroyDirectiveInstance() {\n\t\tconst oldInstance = instance;\n\t\tinstance = undefined;\n\t\tdirective = undefined;\n\t\toldInstance?.destroy?.();\n\t}\n\n\tinject(DestroyRef).onDestroy(destroyDirectiveInstance);\n\n\tfunction update(newDirective?: AgnosUIDirective<T>, newParams?: T) {\n\t\tif (newDirective !== directive) {\n\t\t\tvoid destroyDirectiveInstance();\n\t\t\tdirective = newDirective;\n\t\t\tparams = newParams;\n\t\t\tcallDirective();\n\t\t} else if (newParams != params) {\n\t\t\tparams = newParams;\n\t\t\tinstance?.update?.(params as T);\n\t\t}\n\t}\n\n\tcallDirective();\n\treturn {update};\n};\n\n/**\n * A directive that allows the use of another directive with optional parameters.\n *\n * @template T - The type of the parameter that can be passed to the directive.\n *\n * @remarks\n * This directive uses a private instance of {@link useDirectiveForHost} to manage the directive and its parameter.\n */\n@Directive({\n\tstandalone: true,\n\tselector: '[auUse]',\n})\nexport class UseDirective<T> implements OnChanges {\n\t@Input('auUse')\n\tuse: AgnosUIDirective | DirectiveAndParam<T> | undefined;\n\n\treadonly #useDirective = useDirectiveForHost<T>();\n\n\t/** @internal */\n\tngOnChanges() {\n\t\tconst use = this.use;\n\t\tconst [directive, param] = Array.isArray(use) ? use : [use as any];\n\t\tthis.#useDirective.update(directive, param);\n\t}\n}\n\n/**\n * A directive that allows the use of multiple directives on a host element.\n *\n * @template T - A tuple type representing the directives and their optional parameters.\n */\n@Directive({\n\tstandalone: true,\n\tselector: '[auUseMulti]',\n})\nexport class UseMultiDirective<T extends any[]> implements OnChanges {\n\t/**\n\t * An input property that takes a tuple of directives and their optional parameters.\n\t */\n\t@Input({alias: 'auUseMulti', required: true})\n\tuseMulti!: DirectivesAndOptParam<T>;\n\n\treadonly #useDirective = useDirectiveForHost<DirectivesAndOptParam<T>>();\n\n\t/** @internal */\n\tngOnChanges() {\n\t\tthis.#useDirective.update(multiDirective, this.useMulti);\n\t}\n}\n","import type {SlotContent as CoreSlotContent, Widget, WidgetState, Extends} from '@agnos-ui/core/types';\nimport type {Signal, TemplateRef, Type} from '@angular/core';\nimport {Directive, Input} from '@angular/core';\n\nexport * from '@agnos-ui/core/types';\n\n/**\n * Represents a template for a component with specified properties.\n *\n * @template Props - The type of properties that the template accepts.\n * @template K - The key in the template object that maps to the template reference.\n * @template T - An object type where each key of type K maps to a TemplateRef of Props.\n *\n * @param component - The component type that contains the template.\n * @param templateProp - The key in the component that maps to the template reference.\n */\nexport class ComponentTemplate<Props, K extends string, T extends {[key in K]: TemplateRef<Props>}> {\n\tconstructor(\n\t\tpublic readonly component: Type<T>,\n\t\tpublic readonly templateProp: K,\n\t) {}\n}\n\n/**\n * Represents the content that can be used in a slot.\n *\n * @template Props - The type of the properties that the slot content can accept.\n *\n * This type can be one of the following:\n * - `undefined | null`: Nullish value\n * - `string`: A static string\n * - `(props: Props) => string`: A function that takes props as input and returns a string template\n * - `TemplateRef<Props>`: A reference to an Angular template with the specified properties.\n * - `Type<unknown>`: A type representing an unknown component or directive.\n * - `ComponentTemplate<Props, any, any>`: A component template with the specified properties.\n */\nexport type SlotContent<Props extends object = object> =\n\t| CoreSlotContent<Props>\n\t| TemplateRef<Props>\n\t| Type<unknown>\n\t| ComponentTemplate<Props, any, any>;\n\n/**\n * A directive representing a slot component that can be used to manage the state and context of a widget.\n *\n * @template W - The type of the widget that this slot component manages.\n */\n@Directive()\nexport abstract class SlotComponent<W extends Widget> {\n\t/**\n\t * The state of the widget. Each property of the state is exposed through an Angular {@link https://angular.dev/api/core/Signal | Signal}\n\t */\n\t@Input()\n\tstate!: AngularState<W>;\n\t/**\n\t * all the api functions to interact with the widget\n\t */\n\t@Input()\n\tapi!: W['api'];\n\t/**\n\t * directives to be used on html elements in the template of the slot\n\t */\n\t@Input()\n\tdirectives!: W['directives'];\n}\n\n/**\n * Type utility to determine if a given type `T` is or extends `SlotContent<any>`.\n *\n * This type alias uses conditional types to check if `T` extends `SlotContent<any>` or if `SlotContent<any>` extends `T`.\n * If either condition is true, it resolves to `T`, otherwise it resolves to `0`.\n *\n * @template T - The type to be checked.\n */\nexport type IsSlotContent<T> = Extends<T, SlotContent<any>> | Extends<SlotContent<any>, T> extends 1 ? T : 0;\n\n/**\n * Represents the state of an Angular widget, where each key in the widget's state\n * is mapped to a Signal of the corresponding state value.\n *\n * @template W - The type of the widget.\n */\nexport type AngularState<W extends Widget> = {[key in keyof WidgetState<W>]: Signal<WidgetState<W>[key]>};\n\n/**\n * Represents an Angular widget that extends a base widget type.\n *\n * @template W - The type of the base widget.\n */\nexport interface AngularWidget<W extends Widget> extends Pick<W, 'api' | 'directives' | 'patch'> {\n\t/**\n\t * A promise that resolves when the widget is initialized\n\t */\n\tinitialized: Promise<void>;\n\t/**\n\t * The state of the widget. Each property of the state is exposed through an Angular {@link https://angular.dev/api/core/Signal | Signal}\n\t */\n\tstate: AngularState<W>;\n\t/**\n\t * A function to initialize the Angular widget.\n\t */\n\tngInit: () => void;\n\t/**\n\t * A utility function to update the slot properties.\n\t */\n\tupdateSlots: () => void;\n}\n\nexport interface WidgetSlotContext<W extends Widget> extends Pick<W, 'api' | 'directives'> {\n\t/**\n\t * the state of the widget\n\t */\n\tstate: AngularState<W>;\n}\n","import {computed, type ReadableSignal, writable} from '@amadeus-it-group/tansu';\nimport type {AfterContentChecked, OnChanges, OnInit, SimpleChanges, TemplateRef} from '@angular/core';\nimport {Directive, Injector, inject, runInInjectionContext} from '@angular/core';\nimport type {AngularState, AngularWidget, IsSlotContent, SlotContent, Widget, WidgetFactory, WidgetProps} from '../types';\nimport {toAngularSignal, toReadableStore} from './stores';\nimport {ZoneWrapper} from './zone';\n\nconst createPatchSlots = <T extends object>(set: (object: Partial<T>) => void) => {\n\tlet lastValue: Partial<T> = {};\n\treturn (object: T) => {\n\t\tconst newValue: Partial<T> = {};\n\t\tlet hasChange = false;\n\t\tfor (const key of Object.keys(object) as (string & keyof T)[]) {\n\t\t\tconst objectKey = (object as any)[key];\n\t\t\tif (objectKey != null) {\n\t\t\t\t// only use defined slots\n\t\t\t\tnewValue[key] = objectKey;\n\t\t\t}\n\t\t\tif (objectKey != lastValue[key]) {\n\t\t\t\thasChange = true;\n\t\t\t}\n\t\t}\n\t\tif (hasChange) {\n\t\t\tlastValue = newValue;\n\t\t\tset(newValue);\n\t\t}\n\t};\n};\n\n/**\n * Call a widget factory using provided configs.\n *\n * @param parameter - the parameter\n * @param parameter.factory - the widget factory to call\n * @param parameter.defaultConfig - the default config of the widget\n * @param parameter.widgetConfig - the config of the widget, overriding the defaultConfig\n * @param parameter.events - the events of the widget\n * @param parameter.afterInit - a callback to call after successful setup of the widget\n * @param parameter.slotTemplates - a function to provide all slot templates using child queries\n * @param parameter.slotChildren - a function to provide the default children slot using a view query\n * @returns the widget\n */\nexport const callWidgetFactoryWithConfig = <W extends Widget>({\n\tfactory,\n\tdefaultConfig,\n\twidgetConfig,\n\tevents,\n\tafterInit,\n\tslotTemplates,\n\tslotChildren,\n}: {\n\tfactory: WidgetFactory<W>;\n\tdefaultConfig?: Partial<WidgetProps<W>> | ReadableSignal<Partial<WidgetProps<W>> | undefined>;\n\twidgetConfig?: null | undefined | ReadableSignal<Partial<WidgetProps<W>> | undefined>;\n\tevents?: Partial<Pick<WidgetProps<W>, keyof WidgetProps<W> & `on${string}`>>;\n\tafterInit?: (widget: AngularWidget<W>) => void;\n\tslotTemplates?: () => {\n\t\t[K in keyof WidgetProps<W> as IsSlotContent<WidgetProps<W>[K]> extends 0 ? never : K]: WidgetProps<W>[K] extends SlotContent<infer U>\n\t\t\t? TemplateRef<U> | undefined\n\t\t\t: never;\n\t};\n\tslotChildren?: () => TemplateRef<void> | undefined;\n}): AngularWidget<W> => {\n\tconst injector = inject(Injector);\n\tconst slots$ = writable({});\n\tconst props = {};\n\tlet initDone: () => void;\n\tconst patchSlots = createPatchSlots(slots$.set);\n\n\tconst res = {\n\t\tinitialized: new Promise<void>((resolve) => {\n\t\t\tinitDone = resolve;\n\t\t}),\n\t\tupdateSlots: () => {\n\t\t\tif (slotTemplates) {\n\t\t\t\tpatchSlots(slotTemplates());\n\t\t\t}\n\t\t},\n\t\tpatch(newProps: Partial<WidgetProps<W>>) {\n\t\t\t// temporary function replaced in ngInit\n\t\t\tObject.assign(props, newProps);\n\t\t},\n\t\tngInit() {\n\t\t\trunInInjectionContext(injector, () => {\n\t\t\t\tconst zoneWrapper = inject(ZoneWrapper);\n\t\t\t\tfactory = zoneWrapper.outsideNgZone(factory);\n\t\t\t\tconst defaultConfig$ = toReadableStore(defaultConfig);\n\t\t\t\tevents = zoneWrapper.insideNgZoneWrapFunctionsObject(events);\n\t\t\t\tconst widget = factory({\n\t\t\t\t\tconfig: computed(() => ({\n\t\t\t\t\t\t...defaultConfig$(),\n\t\t\t\t\t\tchildren: slotChildren?.(),\n\t\t\t\t\t\t...widgetConfig?.(),\n\t\t\t\t\t\t...slots$(),\n\t\t\t\t\t\t...(events as Partial<WidgetProps<W>>),\n\t\t\t\t\t})),\n\t\t\t\t\tprops,\n\t\t\t\t});\n\t\t\t\tObject.assign(res, {\n\t\t\t\t\tpatch: zoneWrapper.outsideNgZone(widget.patch),\n\t\t\t\t\tdirectives: zoneWrapper.outsideNgZoneWrapDirectivesObject(widget.directives),\n\t\t\t\t\tapi: zoneWrapper.outsideNgZoneWrapFunctionsObject(widget.api),\n\t\t\t\t\tstate: Object.fromEntries(\n\t\t\t\t\t\tObject.entries<ReadableSignal<unknown>>(widget.stores as any).map(([key, val]) => [key.slice(0, -1), toAngularSignal(val)]),\n\t\t\t\t\t),\n\t\t\t\t});\n\t\t\t\tafterInit?.(res as AngularWidget<W>);\n\t\t\t\tinitDone();\n\t\t\t});\n\t\t},\n\t};\n\n\treturn res as AngularWidget<W>;\n};\n\nfunction patchSimpleChanges(patchFn: (obj: any) => void, changes: SimpleChanges) {\n\tconst obj: any = {};\n\tfor (const [key, simpleChange] of Object.entries(changes)) {\n\t\tif (simpleChange !== undefined) {\n\t\t\tobj[key] = simpleChange.currentValue;\n\t\t}\n\t}\n\tpatchFn(obj);\n}\n\n/**\n * An abstract base class for widget directives, providing common functionality\n * for Angular components that interact with widgets.\n *\n * @template W - The type of the widget.\n */\n@Directive()\nexport abstract class BaseWidgetDirective<W extends Widget> implements OnChanges, OnInit, AfterContentChecked {\n\tconstructor(private readonly _widget: AngularWidget<W>) {}\n\n\t/**\n\t * Retrieves the widget api\n\t * @returns the widget api\n\t */\n\tget api(): W['api'] {\n\t\treturn this._widget.api;\n\t}\n\n\t/**\n\t * Retrieves the widget state as an Angular {@link https://angular.dev/api/core/Signal | Signal}\n\t * @returns the widget state\n\t */\n\tget state(): AngularState<W> {\n\t\treturn this._widget.state;\n\t}\n\n\t/**\n\t * Retrieves the widget directives\n\t * @returns the widget directives\n\t */\n\tget directives(): W['directives'] {\n\t\treturn this._widget.directives;\n\t}\n\n\t/**\n\t * @inheritdoc\n\t * @internal\n\t */\n\tngOnChanges(changes: SimpleChanges): void {\n\t\tpatchSimpleChanges(this._widget.patch, changes);\n\t}\n\n\t/** @internal */\n\tngOnInit(): void {\n\t\tthis._widget.ngInit();\n\t}\n\n\t/** @internal */\n\tngAfterContentChecked(): void {\n\t\tthis._widget.updateSlots();\n\t}\n}\n","import type {Widget, WidgetFactory, WidgetProps} from '@agnos-ui/core/types';\nimport type {Partial2Levels, WidgetsConfigStore, WidgetsConfig} from '@agnos-ui/core/config';\nimport {createWidgetsConfig} from '@agnos-ui/core/config';\nimport type {ReadableSignal} from '@amadeus-it-group/tansu';\nimport {computed} from '@amadeus-it-group/tansu';\nimport type {FactoryProvider, TemplateRef} from '@angular/core';\nimport {InjectionToken, Injector, Optional, SkipSelf, inject, runInInjectionContext} from '@angular/core';\nimport type {AngularWidget, IsSlotContent, SlotContent} from './types';\nimport {callWidgetFactoryWithConfig} from './utils/widget';\n\nexport * from '@agnos-ui/core/config';\n\ntype AdaptParentConfig<Config> = (config: Partial2Levels<Config>) => Partial2Levels<Config>;\ntype InjectWidgetsConfig<Config> = (config?: Partial2Levels<Config>) => WidgetsConfigStore<Config>;\n\n/**\n * A factory to create the utilities to allow widgets to be context-aware.\n *\n * It can be used when extending the core and creating new widgets.\n *\n * @template Config - The type of the widgets configuration object.\n * @param widgetsConfigInjectionToken - the widgets config injection token\n * @returns the utilities to create / manage widgets and contexts\n */\nexport const widgetsConfigFactory = <Config extends {[widgetName: string]: object} = WidgetsConfig>(\n\twidgetsConfigInjectionToken = new InjectionToken<WidgetsConfigStore<Config>>('widgetsConfig'),\n) => {\n\t/**\n\t * Creates a provider of widgets default configuration that inherits from any widgets default configuration already defined at an upper level\n\t * in the Angular dependency injection system. It contains its own set of widgets configuration properties that override the same properties form\n\t * the parent configuration.\n\t *\n\t * @remarks\n\t * The configuration is computed from the parent configuration in two steps:\n\t * - first step: the parent configuration is transformed by the adaptParentConfig function (if specified).\n\t * If adaptParentConfig is not specified, this step is skipped.\n\t * - second step: the configuration from step 1 is merged (2-levels deep) with the own$ store. The own$ store initially contains\n\t * an empty object (i.e. no property from the parent is overridden). It can be changed by calling set on the store returned by\n\t * {@link injectWidgetsConfig}.\n\t *\n\t * @param adaptParentConfig - optional function that receives a 2-levels copy of the widgets default configuration\n\t * defined at an upper level in the Angular dependency injection system (or an empty object if there is none) and returns the widgets\n\t * default configuration to be used.\n\t * It is called only if the configuration is needed, and was not yet computed for the current value of the parent configuration.\n\t * It is called in a tansu reactive context, so it can use any tansu store and will be called again if those stores change.\n\t * It is also called in an Angular injection context, so it can call the Angular inject function to get and use dependencies from the\n\t * Angular dependency injection system.\n\t *\n\t * @returns DI provider to be included a list of `providers` (for example at a component level or\n\t * any other level of the Angular dependency injection system)\n\t *\n\t * @example\n\t * ```typescript\n\t * @Component({\n\t * // ...\n\t * providers: [\n\t * provideWidgetsConfig((parentConfig) => {\n\t * // first step configuration: transforms the parent configuration\n\t * parentConfig.rating = parentConfig.rating ?? {};\n\t * parentConfig.rating.className = `${parentConfig.rating.className ?? ''} my-rating-extra-class`\n\t * return parentConfig;\n\t * })\n\t * ]\n\t * })\n\t * class MyComponent {\n\t * widgetsConfig = injectWidgetsConfig();\n\t * constructor() {\n\t * this.widgetsConfig.set({\n\t * // second step configuration: overrides the parent configuration\n\t * rating: {\n\t * slotStar: MyCustomSlotStar\n\t * }\n\t * });\n\t * }\n\t * // ...\n\t * }\n\t * ```\n\t */\n\tconst provideWidgetsConfig = (adaptParentConfig?: AdaptParentConfig<Config>): FactoryProvider => ({\n\t\tprovide: widgetsConfigInjectionToken,\n\t\tuseFactory: (parent: WidgetsConfigStore<Config> | null) => {\n\t\t\tif (adaptParentConfig) {\n\t\t\t\tconst injector = inject(Injector);\n\t\t\t\tconst originalAdaptParentConfig = adaptParentConfig;\n\t\t\t\tadaptParentConfig = (value) => runInInjectionContext(injector, () => originalAdaptParentConfig(value));\n\t\t\t}\n\t\t\treturn createWidgetsConfig(parent ?? undefined, adaptParentConfig);\n\t\t},\n\t\tdeps: [[new SkipSelf(), new Optional(), widgetsConfigInjectionToken]],\n\t});\n\n\t/**\n\t * Returns the widgets default configuration store that was provided in the current injection context.\n\t * Throws if the no widgets default configuration store was provided.\n\t *\n\t * @param defaultConfig - values to set as soon as the config is injected\n\t * @remarks\n\t * This function must be called from an injection context, such as a constructor, a factory function, a field initializer or\n\t * a function used with {@link https://angular.io/api/core/runInInjectionContext | runInInjectionContext}.\n\t *\n\t * @returns the widgets default configuration store.\n\t */\n\tconst injectWidgetsConfig: InjectWidgetsConfig<Config> = (defaultConfig?: Partial2Levels<Config>) => {\n\t\tconst widgetsConfig = inject(widgetsConfigInjectionToken);\n\t\tif (defaultConfig) {\n\t\t\twidgetsConfig.set(defaultConfig);\n\t\t}\n\t\treturn widgetsConfig;\n\t};\n\n\t/**\n\t * Injects the configuration for a specific widget.\n\t *\n\t * @template N - The key of the widget configuration in the `Config` type.\n\t * @param widgetName - The name of the widget whose configuration is to be injected.\n\t * @returns A `ReadableSignal` that provides a partial configuration of the specified widget or `undefined` if the configuration is not available.\n\t */\n\tconst injectWidgetConfig = <N extends keyof Config>(widgetName: N): ReadableSignal<Partial<Config[N]> | undefined> => {\n\t\tconst widgetsConfig = inject(widgetsConfigInjectionToken, {optional: true});\n\t\treturn computed(() => widgetsConfig?.()[widgetName]);\n\t};\n\n\t/**\n\t * Creates and initializes a widget using the provided factory and configuration options.\n\t *\n\t * @template W - The type of the widget.\n\t * @param params - The parameters for creating the widget.\n\t * @param params.factory - The factory function to create the widget.\n\t * @param params.widgetName - The name of the widget configuration to inject, if any.\n\t * @param params.defaultConfig - The default configuration for the widget.\n\t * @param params.events - The event handlers for the widget.\n\t * @param params.slotTemplates - A function that returns the slot templates for the widget.\n\t * @param params.slotChildren - A function that returns the slot children for the widget.\n\t * @param params.afterInit - A callback function to be called after the widget is initialized.\n\t * @returns The initialized widget.\n\t */\n\tconst callWidgetFactory = <W extends Widget>({\n\t\tfactory,\n\t\twidgetName = null,\n\t\tdefaultConfig = {},\n\t\tevents,\n\t\tafterInit,\n\t\tslotTemplates,\n\t\tslotChildren,\n\t}: {\n\t\tfactory: WidgetFactory<W>;\n\t\twidgetName?: null | keyof Config;\n\t\tdefaultConfig?: Partial<WidgetProps<W>> | ReadableSignal<Partial<WidgetProps<W>> | undefined>;\n\t\tevents?: Partial<Pick<WidgetProps<W>, keyof WidgetProps<W> & `on${string}`>>;\n\t\tafterInit?: (widget: AngularWidget<W>) => void;\n\t\tslotTemplates?: () => {\n\t\t\t[K in keyof WidgetProps<W> as IsSlotContent<WidgetProps<W>[K]> extends 0 ? never : K]: WidgetProps<W>[K] extends SlotContent<infer U>\n\t\t\t\t? TemplateRef<U> | undefined\n\t\t\t\t: never;\n\t\t};\n\t\tslotChildren?: () => TemplateRef<void> | undefined;\n\t}): AngularWidget<W> =>\n\t\tcallWidgetFactoryWithConfig({\n\t\t\tfactory,\n\t\t\twidgetConfig: widgetName ? (injectWidgetConfig(widgetName) as any) : null,\n\t\t\tdefaultConfig,\n\t\t\tevents,\n\t\t\tafterInit,\n\t\t\tslotTemplates: slotTemplates as any,\n\t\t\tslotChildren,\n\t\t});\n\n\treturn {\n\t\t/**\n\t\t * Dependency Injection token which can be used to provide or inject the widgets default configuration store.\n\t\t */\n\t\twidgetsConfigInjectionToken,\n\t\tprovideWidgetsConfig,\n\t\tinjectWidgetsConfig,\n\t\tinjectWidgetConfig,\n\t\tcallWidgetFactory,\n\t};\n};\n\nexport const {widgetsConfigInjectionToken, provideWidgetsConfig, injectWidgetConfig, injectWidgetsConfig, callWidgetFactory} =\n\twidgetsConfigFactory<WidgetsConfig>();\n","import {booleanAttribute, numberAttribute} from '@angular/core';\n\n/**\n * Transforms a value (typically a string) to a boolean.\n * Intended to be used as a transform function of an input.\n *\n * @example\n * ```@Input({ transform: auBooleanAttribute }) status: boolean | undefined;```\n * @param value - Value to be transformed.\n * @returns the value transformed\n */\nexport function auBooleanAttribute(value: unknown): boolean | undefined {\n\tif (value === undefined) {\n\t\treturn undefined;\n\t}\n\treturn booleanAttribute(value);\n}\n\n/**\n * Transforms a value (typically a string) to a number.\n * Intended to be used as a transform function of an input.\n * @param value - Value to be transformed.\n *\n * @example\n * ```@Input({ transform: auNumberAttribute }) id: number | undefined;```\n * @returns the value transformed\n */\nexport function auNumberAttribute(value: unknown): number | undefined {\n\tif (value === undefined) {\n\t\treturn undefined;\n\t}\n\treturn numberAttribute(value);\n}\n","import type {ComponentRef, EmbeddedViewRef, OnChanges, OnDestroy, SimpleChanges, Type} from '@angular/core';\nimport {\n\tComponent,\n\tDirective,\n\tEnvironmentInjector,\n\tInput,\n\tTemplateRef,\n\tViewChild,\n\tViewContainerRef,\n\tcreateComponent,\n\tinject,\n\treflectComponentType,\n} from '@angular/core';\nimport type {SlotContent} from './types';\nimport {ComponentTemplate} from './types';\n\nabstract class SlotHandler<Props extends Record<string, any>, Slot extends SlotContent<Props> = SlotContent<Props>> {\n\tconstructor(public viewContainerRef: ViewContainerRef) {}\n\tslotChange(_slot: Slot, _props: Props) {}\n\tpropsChange(_slot: Slot, _props: Props) {}\n\tdestroy() {}\n}\n\n@Component({\n\ttemplate: `<ng-template #text let-content=\"content\">{{ content }}</ng-template>`,\n})\nclass StringSlotComponent {\n\t@ViewChild('text', {static: true}) text!: TemplateRef<{content: string}>;\n}\nconst stringSlotComponentTemplate = new ComponentTemplate<{content: string}, 'text', StringSlotComponent>(StringSlotComponent, 'text');\n\nclass StringSlotHandler<Props extends Record<string, any>> extends SlotHandler<Props, string> {\n\treadonly #templateRefSlotHandler = new ComponentTemplateSlotHandler<{content: string}, 'text', StringSlotComponent>(this.viewContainerRef);\n\t#initialized = false;\n\n\toverride slotChange(content: string): void {\n\t\tif (!this.#initialized) {\n\t\t\tthis.#initialized = true;\n\t\t\tthis.#templateRefSlotHandler.slotChange(stringSlotComponentTemplate, {content});\n\t\t} else {\n\t\t\tthis.#templateRefSlotHandler.propsChange(stringSlotComponentTemplate, {content});\n\t\t}\n\t}\n\n\toverride destroy(): void {\n\t\tthis.#templateRefSlotHandler.destroy();\n\t}\n}\n\nclass FunctionSlotHandler<Props extends Record<string, any>> extends SlotHandler<Props, (props: Props) => string> {\n\treadonly #stringSlotHandler = new StringSlotHandler(this.viewContainerRef);\n\n\toverride slotChange(slot: (props: Props) => string, props: Props): void {\n\t\tthis.#stringSlotHandler.slotChange(slot(props));\n\t}\n\n\toverride propsChange(slot: (props: Props) => string, props: Props): void {\n\t\tthis.#stringSlotHandler.slotChange(slot(props));\n\t}\n\n\toverride destroy(): void {\n\t\tthis.#stringSlotHandler.destroy();\n\t}\n}\n\nclass ComponentSlotHandler<Props extends Record<string, any>> extends SlotHandler<Props, Type<unknown>> {\n\t#componentRef: ComponentRef<any> | undefined;\n\t#properties?: string[];\n\n\toverride slotChange(slot: Type<unknown>, props: Props): void {\n\t\tif (this.#componentRef) {\n\t\t\tthis.destroy();\n\t\t}\n\t\tthis.#componentRef = this.viewContainerRef.createComponent(slot);\n\t\tthis.#applyProperties(props);\n\t}\n\n\t#applyProperties(props: Props, oldProperties?: Set<string>) {\n\t\tconst properties = Object.keys(props);\n\t\tthis.#properties = properties;\n\t\tconst componentRef = this.#componentRef!;\n\t\tfor (const property of properties) {\n\t\t\tcomponentRef.setInput(property, props[property]);\n\t\t\toldProperties?.delete(property);\n\t\t}\n\t}\n\n\toverride propsChange(_slot: Type<unknown>, props: Props): void {\n\t\tconst oldProperties = new Set(this.#properties);\n\t\tthis.#applyProperties(props, oldProperties);\n\t\tconst componentRef = this.#componentRef!;\n\t\tfor (const property of oldProperties) {\n\t\t\tcomponentRef.setInput(property, undefined);\n\t\t}\n\t}\n\n\toverride destroy(): void {\n\t\tthis.viewContainerRef.clear();\n\t\tthis.#componentRef = undefined;\n\t}\n}\n\nclass TemplateRefSlotHandler<Props extends Record<string, any>> extends SlotHandler<Props, TemplateRef<Props>> {\n\t#viewRef: EmbeddedViewRef<Props> | undefined;\n\t#props?: Props;\n\n\toverride slotChange(slot: TemplateRef<Props>, props: Props): void {\n\t\tif (this.#viewRef) {\n\t\t\tthis.destroy();\n\t\t}\n\t\tprops = {...props};\n\t\tthis.#props = props;\n\t\tthis.#viewRef = this.viewContainerRef.createEmbeddedView(slot, props);\n\t}\n\n\toverride propsChange(_slot: TemplateRef<Props>, props: Props): void {\n\t\tif (this.#viewRef) {\n\t\t\tconst templateProps = this.#props!;\n\t\t\tconst oldProperties = new Set<keyof Props>(Object.keys(templateProps));\n\t\t\tfor (const property of Object.keys(props) as (keyof Props)[]) {\n\t\t\t\ttemplateProps[property] = props[property];\n\t\t\t\toldProperties.delete(property);\n\t\t\t}\n\t\t\tfor (const oldProperty of oldProperties) {\n\t\t\t\tdelete templateProps[oldProperty];\n\t\t\t}\n\t\t\tthis.#viewRef.markForCheck();\n\t\t}\n\t}\n\n\toverride destroy(): void {\n\t\tthis.viewContainerRef.clear();\n\t}\n}\n\nclass ComponentTemplateSlotHandler<\n\tProps extends Record<string, any>,\n\tK extends string,\n\tT extends {[key in K]: TemplateRef<Props>},\n> extends SlotHandler<Props, ComponentTemplate<Props, K, T>> {\n\t#componentRef: ComponentRef<T> | undefined;\n\treadonly #templateSlotHandler = new TemplateRefSlotHandler(this.viewContainerRef);\n\t#templateRef: TemplateRef<Props> | undefined;\n\n\toverride slotChange(slot: ComponentTemplate<Props, K, T>, props: Props): void {\n\t\tif (this.#componentRef) {\n\t\t\tthis.destroy();\n\t\t}\n\t\tthis.#componentRef = createComponent(slot.component, {\n\t\t\telementInjector: this.viewContainerRef.injector,\n\t\t\tenvironmentInjector: this.viewContainerRef.injector.get(EnvironmentInjector),\n\t\t});\n\t\tthis.#templateRef = this.#componentRef.instance[slot.templateProp];\n\t\tthis.#templateSlotHandler.slotChange(this.#templateRef, props);\n\t}\n\n\toverride propsChange(_slot: ComponentTemplate<Props, K, T>, props: Props): void {\n\t\tthis.#templateSlotHandler.propsChange(this.#templateRef!, props);\n\t}\n\n\toverride destroy(): void {\n\t\tthis.#templateSlotHandler.destroy();\n\t\tthis.#componentRef?.destroy();\n\t\tthis.#componentRef = undefined;\n\t}\n}\n\nconst getSlotType = (value: any): undefined | {new (viewContainerRef: ViewContainerRef): SlotHandler<any>} => {\n\tif (!value) return undefined;\n\tconst type = typeof value;\n\tswitch (type) {\n\t\tcase 'string':\n\t\t\treturn StringSlotHandler;\n\t\tcase 'function':\n\t\t\tif (reflectComponentType(value)) {\n\t\t\t\treturn ComponentSlotHandler;\n\t\t\t}\n\t\t\treturn FunctionSlotHandler;\n\t\tcase 'object':\n\t\t\tif (value instanceof TemplateRef) {\n\t\t\t\treturn TemplateRefSlotHandler;\n\t\t\t}\n\t\t\tif (value instanceof ComponentTemplate) {\n\t\t\t\treturn ComponentTemplateSlotHandler;\n\t\t\t}\n\t\t\tbreak;\n\t}\n\treturn undefined;\n};\n\n/**\n * A directive that manages slot content and its properties.\n *\n * @template Props - A record type representing the properties for the slot.\n *\n * @remarks\n * This directive handles changes to the slot content and its properties,\n * and manages the lifecycle of the slot handler.\n */\n@Directive({\n\tselector: '[auSlot]',\n\tstandalone: true,\n})\nexport class SlotDirective<Props extends Record<string, any>> implements OnChanges, OnDestroy {\n\t/**\n\t * The slot content to be managed.\n\t */\n\t@Input('auSlot') slot: SlotContent<Props>;\n\t/**\n\t * The properties for the slot content.\n\t */\n\t@Input({alias: 'auSlotProps', required: true}) props!: Props;\n\n\tprivate readonly _viewContainerRef = inject(ViewContainerRef);\n\tprivate _slotType: ReturnType<typeof getSlotType>;\n\tprivate _slotHandler: SlotHandler<Props> | undefined;\n\n\t/**\n\t * @param changes SimpleChanges from Angular\n\t * @internal\n\t */\n\tngOnChanges(changes: SimpleChanges): void {\n\t\tconst slotChange = changes['slot'];\n\t\tconst propsChange = changes['props'];\n\t\tconst slot = this.slot;\n\t\tif (slotChange) {\n\t\t\tconst newSlotType = getSlotType(slot);\n\t\t\tif (newSlotType !== this._slotType) {\n\t\t\t\tthis._slotHandler?.destroy();\n\t\t\t\tthis._slotHandler = newSlotType ? new newSlotType(this._viewContainerRef) : undefined;\n\t\t\t\tthis._slotType = newSlotType;\n\t\t\t}\n\t\t\tthis._slotHandler?.slotChange(slot, this.props);\n\t\t} else if (propsChange) {\n\t\t\tthis._slotHandler?.propsChange(slot, this.props);\n\t\t}\n\t}\n\n\t/** @internal */\n\tngOnDestroy(): void {\n\t\tthis._slotHandler?.destroy();\n\t\tthis._slotHandler = undefined;\n\t}\n}\n","/*\n * Public API Surface of @agnos-ui/angular-headless\n */\nexport * from './generated';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAM,IAAI,GAAG,MAAK,GAAG,CAAC;AACtB,MAAM,QA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E,OAAO,EAAE,CAAC;AAC7B,QAAA,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC;KAC9B;8GAvCW,aAAa,GAAA,CAAA,EAAA,CAAA,EAAA;oEAAb,aAAa,EAAA,SAAA,EAAA,CAAA,CAAA,EAAA,EAAA,QAAA,EAAA,EAAA,CAAA,CAAA,EAAA,MAAA,EAAA,EAAA,IAAA,EAAA,CAAA,CAAA,EAAA,QAAA,EAAA,MAAA,CAAA,EAAA,KAAA,EAAA,CAAA,CAAA,EAAA,aAAA,EAAA,OAAA,CAAA,EAAA,EAAA,UAAA,EAAA,IAAA,EAAA,QAAA,EAAA,CAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,CAAA,CAAA,EAAA;;iFAAb,aAAa,EAAA,CAAA;cAJzB,SAAS;AAAC,QAAA,IAAA,EAAA,CAAA;AACV,gBAAA,QAAQ,EAAE,UAAU;AACpB,gBAAA,UAAU,EAAE,IAAI;AAChB,aAAA,CAAA;gBAKiB,IAAI,EAAA,CAAA;kBAApB,KAAK;mBAAC,QAAQ,CAAA;YAIgC,KAAK,EAAA,CAAA;kBAAnD,KAAK;AAAC,YAAA,IAAA,EAAA,CAAA,EAAC,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,IAAI,EAAC,CAAA;;;ACnN9C;;AAEG;;ACFH;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@agnos-ui/angular-headless",
3
- "description": "Headless widget library for Angular.",
4
- "version": "0.4.4",
3
+ "description": "Headless component library for Angular.",
4
+ "version": "0.5.0",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {
@@ -13,15 +13,15 @@
13
13
  },
14
14
  "peerDependencies": {
15
15
  "@amadeus-it-group/tansu": "^1.0.0",
16
- "@angular/common": "^18.1.2",
17
- "@angular/core": "^18.1.2"
16
+ "@angular/common": "^18.2.9",
17
+ "@angular/core": "^18.2.9"
18
18
  },
19
19
  "dependencies": {
20
- "@agnos-ui/core": "0.4.4",
21
- "tslib": "^2.6.3"
20
+ "@agnos-ui/core": "0.5.0",
21
+ "tslib": "^2.8.0"
22
22
  },
23
23
  "sideEffects": false,
24
- "homepage": "https://amadeusitgroup.github.io/AgnosUI/latest/",
24
+ "homepage": "https://www.agnosui.dev/latest/",
25
25
  "bugs": "https://github.com/AmadeusITGroup/AgnosUI/issues",
26
26
  "license": "MIT",
27
27
  "repository": {
@@ -35,6 +35,7 @@
35
35
  "accordion",
36
36
  "AgnosUI",
37
37
  "alert",
38
+ "collapse",
38
39
  "components",
39
40
  "modal",
40
41
  "pagination",
@@ -1,32 +1,34 @@
1
- import type { OnChanges, OnDestroy, SimpleChanges, OnInit } from '@angular/core';
2
- import { TemplateRef } from '@angular/core';
1
+ import type { OnChanges, OnDestroy, SimpleChanges } from '@angular/core';
3
2
  import type { SlotContent } from './types';
4
- import type { WritableSignal } from '@amadeus-it-group/tansu';
5
3
  import * as i0 from "@angular/core";
4
+ /**
5
+ * A directive that manages slot content and its properties.
6
+ *
7
+ * @template Props - A record type representing the properties for the slot.
8
+ *
9
+ * @remarks
10
+ * This directive handles changes to the slot content and its properties,
11
+ * and manages the lifecycle of the slot handler.
12
+ */
6
13
  export declare class SlotDirective<Props extends Record<string, any>> implements OnChanges, OnDestroy {
14
+ /**
15
+ * The slot content to be managed.
16
+ */
7
17
  slot: SlotContent<Props>;
18
+ /**
19
+ * The properties for the slot content.
20
+ */
8
21
  props: Props;
9
22
  private readonly _viewContainerRef;
10
23
  private _slotType;
11
24
  private _slotHandler;
12
- /** @inheritdoc */
25
+ /**
26
+ * @param changes SimpleChanges from Angular
27
+ * @internal
28
+ */
13
29
  ngOnChanges(changes: SimpleChanges): void;
14
- /** @inheritdoc */
30
+ /** @internal */
15
31
  ngOnDestroy(): void;
16
32
  static ɵfac: i0.ɵɵFactoryDeclaration<SlotDirective<any>, never>;
17
33
  static ɵdir: i0.ɵɵDirectiveDeclaration<SlotDirective<any>, "[auSlot]", never, { "slot": { "alias": "auSlot"; "required": false; }; "props": { "alias": "auSlotProps"; "required": true; }; }, {}, never, never, true, never>;
18
34
  }
19
- /**
20
- * Directive that allows to pass the templateRef associated to a ng-content to a store.
21
- * The input of the directive is a {@link WritableSignal}<{children: {@link SlotContent}<T>}>.
22
- */
23
- export declare class ContentAsSlotDirective<T extends object> implements OnInit {
24
- auContentAsSlot: WritableSignal<{
25
- children?: SlotContent<T>;
26
- }>;
27
- templateRef: TemplateRef<any>;
28
- /** @inheritdoc */
29
- ngOnInit(): void;
30
- static ɵfac: i0.ɵɵFactoryDeclaration<ContentAsSlotDirective<any>, never>;
31
- static ɵdir: i0.ɵɵDirectiveDeclaration<ContentAsSlotDirective<any>, "[auContentAsSlot]", never, { "auContentAsSlot": { "alias": "auContentAsSlot"; "required": true; }; }, {}, never, never, true, never>;
32
- }
package/types.d.ts CHANGED
@@ -1,7 +1,17 @@
1
- import type { ContextWidget, SlotContent as CoreSlotContent, Widget, WidgetProps, WidgetState, Extends } from '@agnos-ui/core/types';
1
+ import type { SlotContent as CoreSlotContent, Widget, WidgetState, Extends } from '@agnos-ui/core/types';
2
2
  import type { Signal, TemplateRef, Type } from '@angular/core';
3
3
  import * as i0 from "@angular/core";
4
4
  export * from '@agnos-ui/core/types';
5
+ /**
6
+ * Represents a template for a component with specified properties.
7
+ *
8
+ * @template Props - The type of properties that the template accepts.
9
+ * @template K - The key in the template object that maps to the template reference.
10
+ * @template T - An object type where each key of type K maps to a TemplateRef of Props.
11
+ *
12
+ * @param component - The component type that contains the template.
13
+ * @param templateProp - The key in the component that maps to the template reference.
14
+ */
5
15
  export declare class ComponentTemplate<Props, K extends string, T extends {
6
16
  [key in K]: TemplateRef<Props>;
7
17
  }> {
@@ -9,20 +19,85 @@ export declare class ComponentTemplate<Props, K extends string, T extends {
9
19
  readonly templateProp: K;
10
20
  constructor(component: Type<T>, templateProp: K);
11
21
  }
22
+ /**
23
+ * Represents the content that can be used in a slot.
24
+ *
25
+ * @template Props - The type of the properties that the slot content can accept.
26
+ *
27
+ * This type can be one of the following:
28
+ * - `undefined | null`: Nullish value
29
+ * - `string`: A static string
30
+ * - `(props: Props) => string`: A function that takes props as input and returns a string template
31
+ * - `TemplateRef<Props>`: A reference to an Angular template with the specified properties.
32
+ * - `Type<unknown>`: A type representing an unknown component or directive.
33
+ * - `ComponentTemplate<Props, any, any>`: A component template with the specified properties.
34
+ */
12
35
  export type SlotContent<Props extends object = object> = CoreSlotContent<Props> | TemplateRef<Props> | Type<unknown> | ComponentTemplate<Props, any, any>;
36
+ /**
37
+ * A directive representing a slot component that can be used to manage the state and context of a widget.
38
+ *
39
+ * @template W - The type of the widget that this slot component manages.
40
+ */
13
41
  export declare abstract class SlotComponent<W extends Widget> {
14
- state: WidgetState<W>;
15
- widget: ContextWidget<W>;
42
+ /**
43
+ * The state of the widget. Each property of the state is exposed through an Angular {@link https://angular.dev/api/core/Signal | Signal}
44
+ */
45
+ state: AngularState<W>;
46
+ /**
47
+ * all the api functions to interact with the widget
48
+ */
49
+ api: W['api'];
50
+ /**
51
+ * directives to be used on html elements in the template of the slot
52
+ */
53
+ directives: W['directives'];
16
54
  static ɵfac: i0.ɵɵFactoryDeclaration<SlotComponent<any>, never>;
17
- static ɵdir: i0.ɵɵDirectiveDeclaration<SlotComponent<any>, never, never, { "state": { "alias": "state"; "required": false; }; "widget": { "alias": "widget"; "required": false; }; }, {}, never, never, false, never>;
55
+ static ɵdir: i0.ɵɵDirectiveDeclaration<SlotComponent<any>, never, never, { "state": { "alias": "state"; "required": false; }; "api": { "alias": "api"; "required": false; }; "directives": { "alias": "directives"; "required": false; }; }, {}, never, never, false, never>;
18
56
  }
57
+ /**
58
+ * Type utility to determine if a given type `T` is or extends `SlotContent<any>`.
59
+ *
60
+ * This type alias uses conditional types to check if `T` extends `SlotContent<any>` or if `SlotContent<any>` extends `T`.
61
+ * If either condition is true, it resolves to `T`, otherwise it resolves to `0`.
62
+ *
63
+ * @template T - The type to be checked.
64
+ */
19
65
  export type IsSlotContent<T> = Extends<T, SlotContent<any>> | Extends<SlotContent<any>, T> extends 1 ? T : 0;
20
- export type AngularWidget<W extends Widget> = W & {
66
+ /**
67
+ * Represents the state of an Angular widget, where each key in the widget's state
68
+ * is mapped to a Signal of the corresponding state value.
69
+ *
70
+ * @template W - The type of the widget.
71
+ */
72
+ export type AngularState<W extends Widget> = {
73
+ [key in keyof WidgetState<W>]: Signal<WidgetState<W>[key]>;
74
+ };
75
+ /**
76
+ * Represents an Angular widget that extends a base widget type.
77
+ *
78
+ * @template W - The type of the base widget.
79
+ */
80
+ export interface AngularWidget<W extends Widget> extends Pick<W, 'api' | 'directives' | 'patch'> {
81
+ /**
82
+ * A promise that resolves when the widget is initialized
83
+ */
21
84
  initialized: Promise<void>;
22
- widget: ContextWidget<W>;
23
- ngState: Signal<WidgetState<W>>;
85
+ /**
86
+ * The state of the widget. Each property of the state is exposed through an Angular {@link https://angular.dev/api/core/Signal | Signal}
87
+ */
88
+ state: AngularState<W>;
89
+ /**
90
+ * A function to initialize the Angular widget.
91
+ */
24
92
  ngInit: () => void;
25
- patchSlots(slots: {
26
- [K in keyof WidgetProps<W> as IsSlotContent<WidgetProps<W>[K]> extends 0 ? never : K]: WidgetProps<W>[K] extends SlotContent<infer U> ? TemplateRef<U> | undefined : never;
27
- }): void;
28
- };
93
+ /**
94
+ * A utility function to update the slot properties.
95
+ */
96
+ updateSlots: () => void;
97
+ }
98
+ export interface WidgetSlotContext<W extends Widget> extends Pick<W, 'api' | 'directives'> {
99
+ /**
100
+ * the state of the widget
101
+ */
102
+ state: AngularState<W>;
103
+ }
@@ -3,27 +3,51 @@ import type { OnChanges } from '@angular/core';
3
3
  import * as i0 from "@angular/core";
4
4
  export * from '@agnos-ui/core/utils/directive';
5
5
  /**
6
- * Set up an agnos-ui directive as an angular host directive.
6
+ * A utility function to manage the lifecycle of a directive for a host element.
7
7
  *
8
- * @param directive - the directive
9
- * @param params - the params to pass to the directive
10
- * @returns the update function to change the directive or params
8
+ * This function handles the creation, updating, and destruction of a directive instance
9
+ * associated with a host element. It ensures that the directive is called appropriately
10
+ * based on the platform (server or client) and manages the directive's lifecycle within
11
+ * the Angular injection context.
12
+ *
13
+ * @template T - The type of parameters that the directive accepts.
14
+ *
15
+ * @param [directive] - The directive to be applied to the host element.
16
+ * @param [params] - The parameters to be passed to the directive.
17
+ *
18
+ * @returns An object containing an `update` function to update the directive and its parameters.
11
19
  */
12
20
  export declare const useDirectiveForHost: <T>(directive?: AgnosUIDirective<T>, params?: T) => {
13
21
  update: (newDirective?: AgnosUIDirective<T>, newParams?: T) => void;
14
22
  };
23
+ /**
24
+ * A directive that allows the use of another directive with optional parameters.
25
+ *
26
+ * @template T - The type of the parameter that can be passed to the directive.
27
+ *
28
+ * @remarks
29
+ * This directive uses a private instance of {@link useDirectiveForHost} to manage the directive and its parameter.
30
+ */
15
31
  export declare class UseDirective<T> implements OnChanges {
16
32
  #private;
17
33
  use: AgnosUIDirective | DirectiveAndParam<T> | undefined;
18
- /** @inheritdoc */
34
+ /** @internal */
19
35
  ngOnChanges(): void;
20
36
  static ɵfac: i0.ɵɵFactoryDeclaration<UseDirective<any>, never>;
21
37
  static ɵdir: i0.ɵɵDirectiveDeclaration<UseDirective<any>, "[auUse]", never, { "use": { "alias": "auUse"; "required": false; }; }, {}, never, never, true, never>;
22
38
  }
39
+ /**
40
+ * A directive that allows the use of multiple directives on a host element.
41
+ *
42
+ * @template T - A tuple type representing the directives and their optional parameters.
43
+ */
23
44
  export declare class UseMultiDirective<T extends any[]> implements OnChanges {
24
45
  #private;
46
+ /**
47
+ * An input property that takes a tuple of directives and their optional parameters.
48
+ */
25
49
  useMulti: DirectivesAndOptParam<T>;
26
- /** @inheritdoc */
50
+ /** @internal */
27
51
  ngOnChanges(): void;
28
52
  static ɵfac: i0.ɵɵFactoryDeclaration<UseMultiDirective<any>, never>;
29
53
  static ɵdir: i0.ɵɵDirectiveDeclaration<UseMultiDirective<any>, "[auUseMulti]", never, { "useMulti": { "alias": "auUseMulti"; "required": true; }; }, {}, never, never, true, never>;
package/utils/stores.d.ts CHANGED
@@ -2,12 +2,16 @@ import type { ReadableSignal } from '@amadeus-it-group/tansu';
2
2
  import type { Signal } from '@angular/core';
3
3
  export * from '@agnos-ui/core/utils/stores';
4
4
  /**
5
- * Convert a tansu readable signal into an Angular signal.
5
+ * Converts a Tansu `ReadableSignal` to an Angular `Signal`.
6
6
  *
7
- * @param tansuSignal - a tansu readable signal
8
- * @returns an angular signal
7
+ * This function wraps the provided Tansu signal in an Angular signal, ensuring that updates
8
+ * are properly handled within Angular's zone. It subscribes to the Tansu signal and updates
9
+ * the Angular signal with the received values. The equality function for the Angular signal
10
+ * is set to always return false, ensuring that every new value from the Tansu signal triggers
11
+ * an update.
9
12
  *
10
- * @remarks
11
- * Note that as it uses Angular's `inject`, this can only be called at component construction time.
13
+ * @template T - The type of the value emitted by the signals.
14
+ * @param tansuSignal - The Tansu signal to convert.
15
+ * @returns - The resulting Angular signal.
12
16
  */
13
17
  export declare const toAngularSignal: <T>(tansuSignal: ReadableSignal<T>) => Signal<T>;
package/utils/widget.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { type ReadableSignal } from '@amadeus-it-group/tansu';
2
- import type { OnChanges, OnInit, Signal, SimpleChanges } from '@angular/core';
3
- import { type AngularWidget, type ContextWidget, type Widget, type WidgetFactory, type WidgetProps, type WidgetState } from '../types';
2
+ import type { AfterContentChecked, OnChanges, OnInit, SimpleChanges, TemplateRef } from '@angular/core';
3
+ import type { AngularState, AngularWidget, IsSlotContent, SlotContent, Widget, WidgetFactory, WidgetProps } from '../types';
4
4
  import * as i0 from "@angular/core";
5
5
  /**
6
6
  * Call a widget factory using provided configs.
@@ -11,24 +11,52 @@ import * as i0 from "@angular/core";
11
11
  * @param parameter.widgetConfig - the config of the widget, overriding the defaultConfig
12
12
  * @param parameter.events - the events of the widget
13
13
  * @param parameter.afterInit - a callback to call after successful setup of the widget
14
+ * @param parameter.slotTemplates - a function to provide all slot templates using child queries
15
+ * @param parameter.slotChildren - a function to provide the default children slot using a view query
14
16
  * @returns the widget
15
17
  */
16
- export declare const callWidgetFactoryWithConfig: <W extends Widget>({ factory, defaultConfig, widgetConfig, events, afterInit, }: {
18
+ export declare const callWidgetFactoryWithConfig: <W extends Widget>({ factory, defaultConfig, widgetConfig, events, afterInit, slotTemplates, slotChildren, }: {
17
19
  factory: WidgetFactory<W>;
18
20
  defaultConfig?: Partial<WidgetProps<W>> | ReadableSignal<Partial<WidgetProps<W>> | undefined>;
19
21
  widgetConfig?: null | undefined | ReadableSignal<Partial<WidgetProps<W>> | undefined>;
20
- events?: Pick<WidgetProps<W>, keyof WidgetProps<W> & `on${string}`>;
21
- afterInit?: () => void;
22
+ events?: Partial<Pick<WidgetProps<W>, keyof WidgetProps<W> & `on${string}`>>;
23
+ afterInit?: (widget: AngularWidget<W>) => void;
24
+ slotTemplates?: () => { [K in keyof WidgetProps<W> as IsSlotContent<WidgetProps<W>[K]> extends 0 ? never : K]: WidgetProps<W>[K] extends SlotContent<infer U> ? TemplateRef<U> | undefined : never; };
25
+ slotChildren?: () => TemplateRef<void> | undefined;
22
26
  }) => AngularWidget<W>;
23
- export declare abstract class BaseWidgetDirective<W extends Widget> implements OnChanges, OnInit {
24
- protected abstract readonly _widget: AngularWidget<W>;
27
+ /**
28
+ * An abstract base class for widget directives, providing common functionality
29
+ * for Angular components that interact with widgets.
30
+ *
31
+ * @template W - The type of the widget.
32
+ */
33
+ export declare abstract class BaseWidgetDirective<W extends Widget> implements OnChanges, OnInit, AfterContentChecked {
34
+ private readonly _widget;
35
+ constructor(_widget: AngularWidget<W>);
36
+ /**
37
+ * Retrieves the widget api
38
+ * @returns the widget api
39
+ */
25
40
  get api(): W['api'];
26
- get state(): Signal<WidgetState<W>>;
27
- get widget(): ContextWidget<W>;
28
- /** @inheritdoc */
41
+ /**
42
+ * Retrieves the widget state as an Angular {@link https://angular.dev/api/core/Signal | Signal}
43
+ * @returns the widget state
44
+ */
45
+ get state(): AngularState<W>;
46
+ /**
47
+ * Retrieves the widget directives
48
+ * @returns the widget directives
49
+ */
50
+ get directives(): W['directives'];
51
+ /**
52
+ * @inheritdoc
53
+ * @internal
54
+ */
29
55
  ngOnChanges(changes: SimpleChanges): void;
30
- /** @inheritdoc */
56
+ /** @internal */
31
57
  ngOnInit(): void;
58
+ /** @internal */
59
+ ngAfterContentChecked(): void;
32
60
  static ɵfac: i0.ɵɵFactoryDeclaration<BaseWidgetDirective<any>, never>;
33
61
  static ɵdir: i0.ɵɵDirectiveDeclaration<BaseWidgetDirective<any>, never, never, {}, {}, never, never, false, never>;
34
62
  }
package/utils/zone.d.ts CHANGED
@@ -1,5 +1,9 @@
1
1
  import * as i0 from "@angular/core";
2
2
  type Wrapper = <T>(fn: T) => T;
3
+ /**
4
+ * A utility class that provides methods to run functions inside or outside of Angular's NgZone.
5
+ * This can be useful for optimizing performance by avoiding unnecessary change detection cycles.
6
+ */
3
7
  export declare class ZoneWrapper {
4
8
  #private;
5
9
  planNgZoneRun: () => void;