@agnos-ui/angular-headless
Version:
Headless component library for Angular.
1 lines • 59.8 kB
Source Map (JSON)
{"version":3,"file":"agnos-ui-angular-headless.mjs","sources":["../../src/utils/zone.ts","../../src/utils/stores.ts","../../src/utils/widget.ts","../../src/utils/directive.ts","../../src/types.ts","../../src/config.ts","../../src/components/toast/toaster.service.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, WritableSignal as TansuWritableSignal} from '@amadeus-it-group/tansu';\nimport type {Signal, WritableSignal} 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\n\treturn res.asReadonly();\n};\n\n/**\n * Converts a Tansu `WritableSignal` to an Angular `WritableSignal`.\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 toAngularWritableSignal = <T>(tansuSignal: TansuWritableSignal<T>): WritableSignal<T> => {\n\tconst zoneWrapper = inject(ZoneWrapper);\n\tconst res = signal(undefined as any as T, {equal: () => false});\n\tconst set = res.set.bind(res);\n\tconst subscription = zoneWrapper.outsideNgZone(tansuSignal.subscribe)((value) => {\n\t\tset(value);\n\t\tzoneWrapper.planNgZoneRun();\n\t});\n\tinject(DestroyRef).onDestroy(zoneWrapper.outsideNgZone(subscription));\n\tres.set = zoneWrapper.outsideNgZone(tansuSignal.set);\n\tres.update = zoneWrapper.outsideNgZone(tansuSignal.update);\n\treturn res;\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 * The resulting widget can be easily hooked into the lifecycle of an Angular component through {@link BaseWidgetDirective}.\n *\n * @param factory - the widget factory to call\n * @param options - the options\n * @param options.defaultConfig - the default config of the widget\n * @param options.widgetConfig - the config of the widget, overriding the defaultConfig\n * @param options.events - the events of the widget\n * @param options.afterInit - a callback to call after successful setup of the widget\n * @param options.slotTemplates - a function to provide all slot templates using child queries\n * @param options.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: WidgetFactory<W>,\n\toptions?: {\n\t\tdefaultConfig?: Partial<WidgetProps<W>> | ReadableSignal<Partial<WidgetProps<W>> | undefined>;\n\t\twidgetConfig?: null | undefined | 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},\n): AngularWidget<W> => {\n\tlet {defaultConfig, widgetConfig, events, afterInit, slotTemplates, slotChildren} = options ?? {};\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\t// eslint-disable-next-line @angular-eslint/prefer-inject\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. Each property of the state is exposed through 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 {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, PLATFORM_ID, afterNextRender, inject, runInInjectionContext, input} 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\tselector: '[auUse]',\n})\nexport class UseDirective<T> implements OnChanges {\n\treadonly use = input.required<AgnosUIDirective | DirectiveAndParam<T>>({alias: 'auUse'});\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\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\treadonly useMulti = input.required<DirectivesAndOptParam<T>>({alias: 'auUseMulti'});\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 {computed, 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]: Signal<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\treadonly state = input.required<AngularState<W>>();\n\t/**\n\t * all the api functions to interact with the widget\n\t */\n\treadonly api = input.required<W['api']>();\n\t/**\n\t * directives to be used on html elements in the template of the slot\n\t */\n\treadonly directives = input.required<W['directives']>();\n\t/**\n\t * The slot context, to be used when the slot component uses other slots.\n\t */\n\treadonly slotContext = computed(() => ({state: this.state(), api: this.api(), directives: this.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\n/**\n * Represents the context for a widget slot, providing access to the widget and its state.\n *\n * @template W - The type of the widget.\n */\nexport interface WidgetSlotContext<W extends Widget> extends Pick<W, 'api' | 'directives'> {\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}\n","import type {Widget, WidgetFactory, WidgetProps} from '@agnos-ui/core/types';\nimport {FACTORY_WIDGET_NAME} 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// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport type {BaseWidgetDirective} 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 * The resulting widget can be easily hooked into the lifecycle of an Angular component through {@link BaseWidgetDirective}.\n\t *\n\t * @template W - The type of the widget.\n\t * @param factory - The factory function to create the widget.\n\t * @param options - The options for creating the widget.\n\t * @param options.defaultConfig - The default configuration for the widget.\n\t * @param options.events - The event handlers for the widget.\n\t * @param options.slotTemplates - A function that returns the slot templates for the widget.\n\t * @param options.slotChildren - A function that returns the slot children for the widget.\n\t * @param options.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: WidgetFactory<W>,\n\t\toptions?: {\n\t\t\tdefaultConfig?: Partial<WidgetProps<W>> | ReadableSignal<Partial<WidgetProps<W>> | undefined>;\n\t\t\tevents?: Partial<Pick<WidgetProps<W>, keyof WidgetProps<W> & `on${string}`>>;\n\t\t\tafterInit?: (widget: AngularWidget<W>) => void;\n\t\t\tslotTemplates?: () => {\n\t\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\t? TemplateRef<U> | undefined\n\t\t\t\t\t: never;\n\t\t\t};\n\t\t\tslotChildren?: () => TemplateRef<void> | undefined;\n\t\t},\n\t): AngularWidget<W> =>\n\t\tcallWidgetFactoryWithConfig(factory, {\n\t\t\twidgetConfig: factory[FACTORY_WIDGET_NAME] ? (injectWidgetConfig(factory[FACTORY_WIDGET_NAME]) as any) : undefined,\n\t\t\tdefaultConfig: options?.defaultConfig,\n\t\t\tevents: options?.events,\n\t\t\tafterInit: options?.afterInit,\n\t\t\tslotTemplates: options?.slotTemplates as any,\n\t\t\tslotChildren: options?.slotChildren,\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 {type ToastProps} from '@agnos-ui/core/components/toast';\nimport type {ToasterToast, ToasterProps} from '@agnos-ui/core/components/toast';\nimport {Toaster as CoreToaster} from '@agnos-ui/core/components/toast';\nimport {toAngularSignal, toAngularWritableSignal} from '../../generated';\nimport type {Signal, WritableSignal} from '@angular/core';\nimport {inject, Injectable, InjectionToken} from '@angular/core';\n\n/**\n * Injection token used to provide configuration properties for the toaster service.\n *\n * This token is associated with the `ToasterProps` interface, which defines the\n * structure of the configuration object. It allows dependency injection to supply\n * custom properties for the toaster service, such as default settings or behavior.\n */\nexport const ToastPropsToken = new InjectionToken<ToasterProps>('ToasterProps');\n\n/**\n * Create a toaster provider with helpers and state.\n * @param props Options for the toaster.\n * @template Props Type of the toast properties.\n */\n@Injectable({\n\tprovidedIn: 'root',\n})\nexport class ToasterService<Props extends Partial<ToastProps>> {\n\treadonly optionsCore = inject(ToastPropsToken, {optional: true});\n\treadonly #toaster: CoreToaster<Props> = new CoreToaster<Props>(this.optionsCore ?? undefined);\n\treadonly toasts: Signal<ToasterToast<Props>[]> = toAngularSignal(this.#toaster.toasts);\n\treadonly options: WritableSignal<ToasterProps> = toAngularWritableSignal(this.#toaster.options);\n\treadonly addToast = this.#toaster.addToast;\n\treadonly removeToast = this.#toaster.removeToast;\n\treadonly eventsDirective = this.#toaster.eventsDirective;\n\treadonly closeAll = this.#toaster.closeAll;\n}\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 * ```readonly status = input({ transform: auBooleanAttribute });```\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 * ```readonly id = input({ transform: auNumberAttribute });```\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, Signal, SimpleChanges, Type} from '@angular/core';\nimport {\n\tComponent,\n\tDirective,\n\tEnvironmentInjector,\n\tTemplateRef,\n\tViewContainerRef,\n\tcreateComponent,\n\tinject,\n\treflectComponentType,\n\tChangeDetectionStrategy,\n\tinput,\n\tviewChild,\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\tchangeDetection: ChangeDetectionStrategy.OnPush,\n\ttemplate: `<ng-template #text let-content=\"content\">{{ content }}</ng-template>`,\n})\nclass StringSlotComponent {\n\treadonly text = viewChild.required<\n\t\tTemplateRef<{\n\t\t\tcontent: string;\n\t\t}>\n\t>('text');\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]: Signal<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: Signal<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})\nexport class SlotDirective<Props extends Record<string, any>> implements OnChanges, OnDestroy {\n\t/**\n\t * The slot content to be managed.\n\t */\n\treadonly slot = input.required<SlotContent<Props>>({alias: 'auSlot'});\n\t/**\n\t * The properties for the slot content.\n\t */\n\treadonly props = input.required<Props>({alias: 'auSlotProps'});\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":["computed","CoreToaster"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAM,IAAI,GAAG,MAAK,GAAG;AACrB,MAAM,QAAQ,GAAG,CAAI,CAAI,KAAK,CAAC;AAI/B,MAAM,mBAAmB,GACxB,CAAC,IAAa,KACd,CAAC,MAAM,KAAI;IACV,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;AAC1C,QAAA,OAAO,MAAM;;IAEd,MAAM,GAAG,GAAG,EAAS;IACrB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;QACtC,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAE,MAAc,CAAC,GAAG,CAAC,CAAC;;AAEtC,IAAA,OAAO,GAAG;AACX,CAAC;AAEF,MAAM,wBAAwB,GAC7B,CAAC,eAAwB,EAAE,UAAmB,KAC9C,CAAC,EAAE,KACF,UAAU,CAAC,OAAO,EAAE,KAAK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