ng-primitives 0.91.2 → 0.92.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/ng-primitives-file-upload.mjs +202 -196
- package/fesm2022/ng-primitives-file-upload.mjs.map +1 -1
- package/fesm2022/ng-primitives-form-field.mjs +13 -47
- package/fesm2022/ng-primitives-form-field.mjs.map +1 -1
- package/fesm2022/ng-primitives-menu.mjs.map +1 -1
- package/fesm2022/ng-primitives-portal.mjs +5 -1
- package/fesm2022/ng-primitives-portal.mjs.map +1 -1
- package/fesm2022/ng-primitives-state.mjs +9 -4
- package/fesm2022/ng-primitives-state.mjs.map +1 -1
- package/fesm2022/ng-primitives-utils.mjs +23 -14
- package/fesm2022/ng-primitives-utils.mjs.map +1 -1
- package/file-upload/index.d.ts +82 -52
- package/package.json +1 -1
- package/state/index.d.ts +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-primitives-portal.mjs","sources":["../../../../packages/ng-primitives/portal/src/overlay-token.ts","../../../../packages/ng-primitives/portal/src/portal.ts","../../../../packages/ng-primitives/portal/src/scroll-strategy.ts","../../../../packages/ng-primitives/portal/src/overlay.ts","../../../../packages/ng-primitives/portal/src/overlay-arrow.ts","../../../../packages/ng-primitives/portal/src/offset.ts","../../../../packages/ng-primitives/portal/src/ng-primitives-portal.ts"],"sourcesContent":["import { inject, InjectionToken, Signal, ValueProvider } from '@angular/core';\n\nconst NgpOverlayContextToken = new InjectionToken<unknown>('NgpOverlayContextToken');\n\n/**\n * Injects the context for the overlay.\n * @internal\n */\nexport function injectOverlayContext<T>(): Signal<T> {\n return inject(NgpOverlayContextToken) as Signal<T>;\n}\n\n/**\n * Provides the context for the overlay.\n * @param value The value to provide as the context.\n * @internal\n */\nexport function provideOverlayContext<T>(value: Signal<T | undefined> | undefined): ValueProvider {\n return { provide: NgpOverlayContextToken, useValue: value };\n}\n","import { VERSION } from '@angular/cdk';\nimport { ComponentPortal, DomPortalOutlet, TemplatePortal } from '@angular/cdk/portal';\nimport {\n type ApplicationRef,\n ComponentRef,\n EmbeddedViewRef,\n Injector,\n TemplateRef,\n Type,\n ViewContainerRef,\n} from '@angular/core';\nimport { NgpExitAnimationRef, setupExitAnimation } from 'ng-primitives/internal';\n\nexport abstract class NgpPortal {\n constructor(\n protected readonly viewContainerRef: ViewContainerRef,\n protected readonly injector: Injector,\n ) {}\n\n /**\n * Get the elements of the portal.\n */\n abstract getElements(): HTMLElement[];\n\n /**\n * Detect changes in the portal.\n */\n abstract detectChanges(): void;\n\n /**\n * Whether the portal is attached to a DOM element.\n */\n abstract getAttached(): boolean;\n\n /**\n * Attach the portal to a DOM element.\n * @param container The DOM element to attach the portal to.\n */\n abstract attach(container: HTMLElement): this;\n\n /**\n * Detach the portal from the DOM.\n */\n abstract detach(): Promise<void>;\n\n /**\n * Angular v20 removes `_unusedComponentFactoryResolver` and `_document` from DomPortalOutlet's\n * constructor signature as they have been deprecated since v18, and replaced with optional\n * `_appRef` and `_defaultInjector` params.\n * This temporary change ensures consistent behaviour for consumers using ng v20+.\n * @see {@link https://github.com/angular/components/pull/24504 The implementing PR} for the new implementation.\n * @see {@link https://github.com/angular/components/blob/732a0d7ab69ec25925cc06a0fb17b0fb16a4b0ae/src/cdk/portal/dom-portal-outlet.ts#L27 The latest v20 version comments}\n * describe the importance of passing the `_appRef` and `_defaultInjector` when it comes to component portals\n */\n // todo: remove this compat fix once support for v19 is dropped when v21 is released\n // - should aim to add appRef also to prevent unforeseen issues in certain edge cases\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n protected _getDomPortalOutletCtorParamsCompat(): (ApplicationRef | Injector | undefined | any)[] {\n return Number(VERSION.major) >= 20 ? [this.injector] : [undefined, this.injector];\n }\n}\n\nexport class NgpComponentPortal<T> extends NgpPortal {\n private readonly componentPortal: ComponentPortal<T>;\n private viewRef: ComponentRef<T> | null = null;\n private isDestroying = false;\n private exitAnimationRef: NgpExitAnimationRef | null = null;\n\n constructor(component: Type<T>, viewContainerRef: ViewContainerRef, injector: Injector) {\n super(viewContainerRef, injector);\n this.componentPortal = new ComponentPortal(component, viewContainerRef, injector);\n }\n\n /**\n * Attach the portal to a DOM element.\n * @param container The DOM element to attach the portal to.\n */\n attach(container: HTMLElement): this {\n const domOutlet = new DomPortalOutlet(\n container,\n undefined,\n ...this._getDomPortalOutletCtorParamsCompat(),\n );\n this.viewRef = domOutlet.attach(this.componentPortal);\n\n const element = this.viewRef.location.nativeElement as HTMLElement;\n\n this.exitAnimationRef = setupExitAnimation({ element });\n\n return this;\n }\n\n /**\n * Get the root elements of the portal.\n */\n getElements(): HTMLElement[] {\n return this.viewRef ? [this.viewRef.location.nativeElement] : [];\n }\n\n /**\n * Detect changes in the portal.\n */\n detectChanges(): void {\n this.viewRef?.changeDetectorRef.detectChanges();\n }\n\n /**\n * Whether the portal is attached to a DOM element.\n */\n getAttached(): boolean {\n return !!this.viewRef && (this.viewRef.location.nativeElement as HTMLElement).isConnected;\n }\n\n /**\n * Detach the portal from the DOM.\n */\n async detach(): Promise<void> {\n if (this.isDestroying) {\n return;\n }\n this.isDestroying = true;\n\n // if there is an exit animation manager, wait for it to finish\n await this.exitAnimationRef?.exit();\n\n if (this.viewRef) {\n this.viewRef.destroy();\n this.viewRef = null;\n }\n }\n}\n\nexport class NgpTemplatePortal<T> extends NgpPortal {\n private readonly templatePortal: TemplatePortal<T>;\n private viewRef: EmbeddedViewRef<T> | null = null;\n private exitAnimationRefs: NgpExitAnimationRef[] = [];\n private isDestroying = false;\n\n constructor(\n template: TemplateRef<T>,\n viewContainerRef: ViewContainerRef,\n injector: Injector,\n context?: T,\n ) {\n super(viewContainerRef, injector);\n this.templatePortal = new TemplatePortal(template, viewContainerRef, context, injector);\n }\n\n /**\n * Attach the portal to a DOM element.\n * @param container The DOM element to attach the portal to.\n */\n attach(container: HTMLElement): this {\n const domOutlet = new DomPortalOutlet(\n container,\n undefined,\n ...this._getDomPortalOutletCtorParamsCompat(),\n );\n this.viewRef = domOutlet.attach(this.templatePortal);\n\n for (const rootNode of this.viewRef.rootNodes) {\n if (rootNode instanceof HTMLElement) {\n // Setup exit animation for each root node\n const exitAnimationRef = setupExitAnimation({ element: rootNode });\n this.exitAnimationRefs.push(exitAnimationRef);\n }\n }\n\n return this;\n }\n\n /**\n * Get the root elements of the portal.\n */\n getElements(): HTMLElement[] {\n return this.viewRef ? this.viewRef.rootNodes : [];\n }\n\n /**\n * Detect changes in the portal.\n */\n detectChanges(): void {\n this.viewRef?.detectChanges();\n }\n\n /**\n * Whether the portal is attached to a DOM element.\n */\n getAttached(): boolean {\n return !!this.viewRef && this.viewRef.rootNodes.length > 0;\n }\n\n /**\n * Detach the portal from the DOM.\n */\n async detach(): Promise<void> {\n if (this.isDestroying) {\n return;\n }\n\n this.isDestroying = true;\n\n // if there is an exit animation manager, wait for it to finish\n await Promise.all(this.exitAnimationRefs.map(ref => ref.exit()));\n\n if (this.viewRef) {\n this.viewRef.destroy();\n this.viewRef = null;\n }\n }\n}\n\nexport function createPortal<T>(\n componentOrTemplate: Type<T> | TemplateRef<T>,\n viewContainerRef: ViewContainerRef,\n injector: Injector,\n context?: T,\n): NgpPortal {\n if (componentOrTemplate instanceof TemplateRef) {\n return new NgpTemplatePortal(componentOrTemplate, viewContainerRef, injector, context);\n } else {\n return new NgpComponentPortal(componentOrTemplate, viewContainerRef, injector);\n }\n}\n","/**\n * This code is largely based on the CDK Overlay's scroll strategy implementation, however it\n * has been modified so that it does not rely on the CDK's global overlay styles.\n */\nimport { coerceCssPixelValue } from '@angular/cdk/coercion';\nimport { ViewportRuler } from '@angular/cdk/overlay';\nimport { isFunction, isObject } from 'ng-primitives/utils';\n\nexport interface ScrollStrategy {\n enable(): void;\n disable(): void;\n}\n\n/** Cached result of the check that indicates whether the browser supports scroll behaviors. */\nlet scrollBehaviorSupported: boolean | undefined;\n\nexport function supportsScrollBehavior(): boolean {\n if (scrollBehaviorSupported != null) {\n return scrollBehaviorSupported;\n }\n\n // If we're not in the browser, it can't be supported. Also check for `Element`, because\n // some projects stub out the global `document` during SSR which can throw us off.\n if (!isObject(document) || !document || !isFunction(Element) || !Element) {\n return (scrollBehaviorSupported = false);\n }\n\n // If the element can have a `scrollBehavior` style, we can be sure that it's supported.\n if ('scrollBehavior' in document.documentElement!.style) {\n return (scrollBehaviorSupported = true);\n }\n\n // Check if scrollTo is supported and if it's been polyfilled\n const scrollToFunction = Element.prototype.scrollTo;\n if (!scrollToFunction) {\n return (scrollBehaviorSupported = false);\n }\n\n // We can detect if the function has been polyfilled by calling `toString` on it. Native\n // functions are obfuscated using `[native code]`, whereas if it was overwritten we'd get\n // the actual function source. Via https://davidwalsh.name/detect-native-function. Consider\n // polyfilled functions as supporting scroll behavior.\n return (scrollBehaviorSupported = !/\\{\\s*\\[native code\\]\\s*\\}/.test(scrollToFunction.toString()));\n}\n\ninterface HTMLStyles {\n top: string;\n left: string;\n position: string;\n overflowY: string;\n width: string;\n}\n\nexport class BlockScrollStrategy implements ScrollStrategy {\n private readonly previousHTMLStyles: HTMLStyles = {\n top: '',\n left: '',\n position: '',\n overflowY: '',\n width: '',\n };\n private previousScrollPosition = { top: 0, left: 0 };\n private isEnabled = false;\n\n constructor(\n private readonly viewportRuler: ViewportRuler,\n private readonly document: Document,\n ) {}\n\n /** Blocks page-level scroll while the attached overlay is open. */\n enable() {\n if (this.canBeEnabled()) {\n const root = this.document.documentElement!;\n\n this.previousScrollPosition = this.viewportRuler.getViewportScrollPosition();\n\n // Cache the previous inline styles in case the user had set them.\n this.previousHTMLStyles.left = root.style.left || '';\n this.previousHTMLStyles.top = root.style.top || '';\n this.previousHTMLStyles.position = root.style.position || '';\n this.previousHTMLStyles.overflowY = root.style.overflowY || '';\n this.previousHTMLStyles.width = root.style.width || '';\n\n // Set the styles to block scrolling.\n root.style.position = 'fixed';\n\n // Necessary for the content not to lose its width. Note that we're using 100%, instead of\n // 100vw, because 100vw includes the width plus the scrollbar, whereas 100% is the width\n // that the element had before we made it `fixed`.\n root.style.width = '100%';\n\n // Note: this will always add a scrollbar to whatever element it is on, which can\n // potentially result in double scrollbars. It shouldn't be an issue, because we won't\n // block scrolling on a page that doesn't have a scrollbar in the first place.\n root.style.overflowY = 'scroll';\n\n // Note: we're using the `html` node, instead of the `body`, because the `body` may\n // have the user agent margin, whereas the `html` is guaranteed not to have one.\n root.style.left = coerceCssPixelValue(-this.previousScrollPosition.left);\n root.style.top = coerceCssPixelValue(-this.previousScrollPosition.top);\n root.setAttribute('data-scrollblock', '');\n this.isEnabled = true;\n }\n }\n\n /** Unblocks page-level scroll while the attached overlay is open. */\n disable(): void {\n if (this.isEnabled) {\n const html = this.document.documentElement!;\n const body = this.document.body!;\n const htmlStyle = html.style;\n const bodyStyle = body.style;\n const previousHtmlScrollBehavior = htmlStyle.scrollBehavior || '';\n const previousBodyScrollBehavior = bodyStyle.scrollBehavior || '';\n\n this.isEnabled = false;\n\n htmlStyle.left = this.previousHTMLStyles.left;\n htmlStyle.top = this.previousHTMLStyles.top;\n htmlStyle.position = this.previousHTMLStyles.position;\n htmlStyle.overflowY = this.previousHTMLStyles.overflowY;\n htmlStyle.width = this.previousHTMLStyles.width;\n html.removeAttribute('data-scrollblock');\n\n // Disable user-defined smooth scrolling temporarily while we restore the scroll position.\n // See https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-behavior\n // Note that we don't mutate the property if the browser doesn't support `scroll-behavior`,\n // because it can throw off feature detections in `supportsScrollBehavior` which\n // checks for `'scrollBehavior' in documentElement.style`.\n if (scrollBehaviorSupported) {\n htmlStyle.scrollBehavior = bodyStyle.scrollBehavior = 'auto';\n }\n\n window.scroll(this.previousScrollPosition.left, this.previousScrollPosition.top);\n\n if (scrollBehaviorSupported) {\n htmlStyle.scrollBehavior = previousHtmlScrollBehavior;\n bodyStyle.scrollBehavior = previousBodyScrollBehavior;\n }\n }\n }\n\n private canBeEnabled(): boolean {\n // Since the scroll strategies can't be singletons, we have to use a global CSS class\n // (`cdk-global-scrollblock`) to make sure that we don't try to disable global\n // scrolling multiple times.\n const html = this.document.documentElement!;\n\n if (html.classList.contains('cdk-global-scrollblock') || this.isEnabled) {\n return false;\n }\n\n const viewport = this.viewportRuler.getViewportSize();\n return html.scrollHeight > viewport.height || html.scrollWidth > viewport.width;\n }\n}\n\nexport class NoopScrollStrategy implements ScrollStrategy {\n enable(): void {\n // No operation for enabling\n }\n\n disable(): void {\n // No operation for disabling\n }\n}\n","import { FocusMonitor, FocusOrigin } from '@angular/cdk/a11y';\nimport { ViewportRuler } from '@angular/cdk/overlay';\nimport {\n DestroyRef,\n Injector,\n Provider,\n Signal,\n TemplateRef,\n Type,\n ViewContainerRef,\n computed,\n inject,\n runInInjectionContext,\n signal,\n DOCUMENT,\n} from '@angular/core';\nimport {\n Middleware,\n Placement,\n Strategy,\n arrow,\n autoUpdate,\n computePosition,\n flip,\n offset,\n shift,\n} from '@floating-ui/dom';\nimport { explicitEffect, fromResizeEvent } from 'ng-primitives/internal';\nimport { injectDisposables, safeTakeUntilDestroyed, uniqueId } from 'ng-primitives/utils';\nimport { Subject, fromEvent } from 'rxjs';\nimport { NgpOffset } from './offset';\nimport { provideOverlayContext } from './overlay-token';\nimport { NgpPortal, createPortal } from './portal';\nimport { BlockScrollStrategy, NoopScrollStrategy } from './scroll-strategy';\n\n/**\n * Configuration options for creating an overlay\n * @internal\n */\nexport interface NgpOverlayConfig<T = unknown> {\n /** Content to display in the overlay (component or template) */\n content: NgpOverlayContent<T>;\n\n /** The element that triggers the overlay */\n triggerElement: HTMLElement;\n\n /** The element to use for positioning the overlay (if different from trigger) */\n anchorElement?: HTMLElement | null;\n\n /** The injector to use for creating the portal */\n injector: Injector;\n /** ViewContainerRef to use for creating the portal */\n viewContainerRef: ViewContainerRef;\n\n /** Context data to pass to the overlay content */\n context?: Signal<T | undefined>;\n\n /** Container element or selector to attach the overlay to (defaults to document.body) */\n container?: HTMLElement | string | null;\n\n /** Preferred placement of the overlay relative to the trigger. */\n placement?: Signal<Placement>;\n\n /** Offset distance between the overlay and trigger. Can be a number or an object with axis-specific offsets */\n offset?: NgpOffset;\n\n /** Whether to enable flip behavior when space is limited */\n flip?: boolean;\n\n /** Delay before showing the overlay in milliseconds */\n showDelay?: number;\n\n /** Delay before hiding the overlay in milliseconds */\n hideDelay?: number;\n\n /** Whether the overlay should be positioned with fixed or absolute strategy */\n strategy?: Strategy;\n\n /** The scroll strategy to use for the overlay */\n scrollBehaviour?: 'reposition' | 'block';\n /** Whether to close the overlay when clicking outside */\n closeOnOutsideClick?: boolean;\n /** Whether to close the overlay when pressing escape */\n closeOnEscape?: boolean;\n /** Whether to restore focus to the trigger element when hiding the overlay */\n restoreFocus?: boolean;\n /** Additional middleware for floating UI positioning */\n additionalMiddleware?: Middleware[];\n\n /** Additional providers */\n providers?: Provider[];\n}\n\n/** Type for overlay content which can be either a template or component */\nexport type NgpOverlayContent<T> = TemplateRef<NgpOverlayTemplateContext<T>> | Type<unknown>;\n\n/** Context for template-based overlays */\nexport type NgpOverlayTemplateContext<T> = {\n $implicit: T;\n};\n\n/**\n * NgpOverlay manages the lifecycle and positioning of overlay UI elements.\n * It abstracts the common behavior shared by tooltips, popovers, menus, etc.\n * @internal\n */\nexport class NgpOverlay<T = unknown> {\n private readonly disposables = injectDisposables();\n private readonly document = inject(DOCUMENT);\n private readonly destroyRef = inject(DestroyRef);\n private readonly viewContainerRef: ViewContainerRef;\n private readonly viewportRuler = inject(ViewportRuler);\n private readonly focusMonitor = inject(FocusMonitor);\n /** Access any parent overlays */\n private readonly parentOverlay = inject(NgpOverlay, { optional: true });\n /** Signal tracking the portal instance */\n private readonly portal = signal<NgpPortal | null>(null);\n\n /** Signal tracking the overlay position */\n readonly position = signal<{ x: number | undefined; y: number | undefined }>({\n x: undefined,\n y: undefined,\n });\n\n /**\n * Determine if the overlay has been positioned\n * @internal\n */\n readonly isPositioned = computed(\n () => this.position().x !== undefined && this.position().y !== undefined,\n );\n\n /** Signal tracking the trigger element width */\n readonly triggerWidth = signal<number | null>(null);\n\n /** The transform origin for the overlay */\n readonly transformOrigin = signal<string>('center center');\n\n /** Signal tracking the final placement of the overlay */\n readonly finalPlacement = signal<Placement | undefined>(undefined);\n\n /** Function to dispose the positioning auto-update */\n private disposePositioning?: () => void;\n\n /** Timeout handle for showing the overlay */\n private openTimeout?: () => void;\n\n /** Timeout handle for hiding the overlay */\n private closeTimeout?: () => void;\n\n /** Signal tracking whether the overlay is open */\n readonly isOpen = signal(false);\n\n /** A unique id for the overlay */\n readonly id = signal<string>(uniqueId('ngp-overlay'));\n\n /** The aria-describedby attribute for accessibility */\n readonly ariaDescribedBy = computed(() => (this.isOpen() ? this.id() : undefined));\n\n /** The scroll strategy */\n private scrollStrategy = new NoopScrollStrategy();\n\n /** An observable that emits when the overlay is closing */\n readonly closing = new Subject<void>();\n\n /** Store the arrow element */\n private arrowElement: HTMLElement | null = null;\n\n /** @internal The position of the arrow */\n readonly arrowPosition = signal<{ x: number | undefined; y: number | undefined }>({\n x: undefined,\n y: undefined,\n });\n\n /**\n * Creates a new overlay instance\n * @param config Initial configuration for the overlay\n * @param destroyRef Reference for automatic cleanup\n */\n constructor(private config: NgpOverlayConfig<T>) {\n // we cannot inject the viewContainerRef as this can throw an error during hydration in SSR\n this.viewContainerRef = config.viewContainerRef;\n\n // Listen for placement signal changes to update position\n if (config.placement) {\n explicitEffect([config.placement], () => this.updatePosition());\n }\n\n // this must be done after the config is set\n this.transformOrigin.set(this.getTransformOrigin());\n\n // Monitor trigger element resize\n const elementToMonitor = this.config.anchorElement || this.config.triggerElement;\n fromResizeEvent(elementToMonitor)\n .pipe(safeTakeUntilDestroyed(this.destroyRef))\n .subscribe(({ width, height }) => {\n this.triggerWidth.set(width);\n\n // if the element has been hidden, hide immediately\n if (width === 0 || height === 0) {\n this.hideImmediate();\n }\n });\n\n // if there is a parent overlay and it is closed, close this overlay\n this.parentOverlay?.closing.pipe(safeTakeUntilDestroyed(this.destroyRef)).subscribe(() => {\n if (this.isOpen()) {\n this.hideImmediate();\n }\n });\n\n // If closeOnOutsideClick is enabled, set up a click listener\n fromEvent<MouseEvent>(this.document, 'mouseup', { capture: true })\n .pipe(safeTakeUntilDestroyed(this.destroyRef))\n .subscribe(event => {\n if (!this.config.closeOnOutsideClick) {\n return;\n }\n\n const overlay = this.portal();\n\n if (!overlay || !this.isOpen()) {\n return;\n }\n\n const path = event.composedPath();\n const isInsideOverlay = overlay.getElements().some(el => path.includes(el));\n const isInsideTrigger = path.includes(this.config.triggerElement);\n const isInsideAnchor = this.config.anchorElement\n ? path.includes(this.config.anchorElement)\n : false;\n\n if (!isInsideOverlay && !isInsideTrigger && !isInsideAnchor) {\n this.hide();\n }\n });\n\n // If closeOnEscape is enabled, set up a keydown listener\n fromEvent<KeyboardEvent>(this.document, 'keydown', { capture: true })\n .pipe(safeTakeUntilDestroyed(this.destroyRef))\n .subscribe(event => {\n if (!this.config.closeOnEscape) return;\n if (event.key === 'Escape' && this.isOpen()) {\n this.hide({ origin: 'keyboard', immediate: true });\n }\n });\n\n // Ensure cleanup on destroy\n this.destroyRef.onDestroy(() => this.destroy());\n }\n\n /**\n * Show the overlay with the specified delay\n * @param showDelay Optional delay to override the configured showDelay\n */\n show(): Promise<void> {\n return new Promise<void>(resolve => {\n // If closing is in progress, cancel it\n if (this.closeTimeout) {\n this.closeTimeout();\n this.closeTimeout = undefined;\n }\n\n // Don't proceed if already opening or open\n if (this.openTimeout || this.isOpen()) {\n return;\n }\n\n // Use the provided delay or fall back to config\n const delay = this.config.showDelay ?? 0;\n\n this.openTimeout = this.disposables.setTimeout(() => {\n this.openTimeout = undefined;\n this.createOverlay();\n resolve();\n }, delay);\n });\n }\n\n /**\n * Stop any pending close operation. This is useful for example, if we move the mouse from the tooltip trigger to the tooltip itself.\n * This will prevent the tooltip from closing immediately when the mouse leaves the trigger.\n * @internal\n */\n cancelPendingClose(): void {\n if (this.closeTimeout) {\n this.closeTimeout();\n this.closeTimeout = undefined;\n }\n }\n\n /**\n * Hide the overlay with the specified delay\n * @param options Optional options for hiding the overlay\n */\n hide(options?: OverlayTriggerOptions): void {\n // If opening is in progress, cancel it\n if (this.openTimeout) {\n this.openTimeout();\n this.openTimeout = undefined;\n }\n\n // Don't proceed if already closing or closed unless immediate is true\n if ((this.closeTimeout && !options?.immediate) || !this.isOpen()) {\n return;\n }\n\n this.closing.next();\n\n const dispose = async () => {\n this.closeTimeout = undefined;\n\n if (this.config.restoreFocus) {\n this.focusMonitor.focusVia(this.config.triggerElement, options?.origin ?? 'program', {\n preventScroll: true,\n });\n }\n\n await this.destroyOverlay();\n };\n\n if (options?.immediate) {\n // If immediate, dispose right away\n dispose();\n } else {\n this.closeTimeout = this.disposables.setTimeout(dispose, this.config.hideDelay ?? 0);\n }\n }\n\n /**\n * Update the configuration of this overlay\n * @param config New configuration (partial)\n */\n updateConfig(config: Partial<NgpOverlayConfig<T>>): void {\n this.config = { ...this.config, ...config };\n\n // If the overlay is already open, update its position\n if (this.isOpen()) {\n this.updatePosition();\n }\n }\n\n /**\n * Immediately hide the overlay without any delay\n */\n hideImmediate(): void {\n this.hide({ immediate: true });\n }\n\n /**\n * Toggle the overlay open/closed state\n */\n toggle(): void {\n if (this.isOpen()) {\n this.hide();\n } else {\n this.show();\n }\n }\n\n /**\n * Force update the position of the overlay\n */\n updatePosition(): void {\n const portal = this.portal();\n\n if (!portal) {\n return;\n }\n\n const elements = portal.getElements();\n\n if (elements.length === 0) {\n return;\n }\n\n const overlayElement = elements[0] as HTMLElement;\n\n // Compute new position\n this.computePosition(overlayElement);\n }\n\n /**\n * Completely destroy this overlay instance\n */\n destroy(): void {\n this.hideImmediate();\n this.disposePositioning?.();\n this.scrollStrategy.disable();\n }\n\n /**\n * Get the elements of the overlay\n */\n getElements(): HTMLElement[] {\n return this.portal()?.getElements() ?? [];\n }\n\n /**\n * Internal method to create the overlay\n */\n private createOverlay(): void {\n if (!this.config.content) {\n throw new Error('Overlay content must be provided');\n }\n\n // Create a new portal with context\n const portal = createPortal(\n this.config.content,\n this.viewContainerRef,\n Injector.create({\n parent: this.config.injector,\n providers: [\n ...(this.config.providers || []),\n { provide: NgpOverlay, useValue: this },\n provideOverlayContext<T>(this.config.context),\n ],\n }),\n { $implicit: this.config.context } as NgpOverlayTemplateContext<T>,\n );\n\n // Attach portal to container\n const container = this.resolveContainer();\n portal.attach(container);\n\n // Update portal signal\n this.portal.set(portal);\n\n // Ensure view is up to date\n portal.detectChanges();\n\n // find a dedicated outlet element\n // this is the element that has the `data-overlay` attribute\n // if no such element exists, we use the first element in the portal\n const outletElement =\n portal.getElements().find(el => el.hasAttribute('data-overlay')) ?? portal.getElements()[0];\n\n if (!outletElement) {\n throw new Error('Overlay element is not available.');\n }\n\n // Set up positioning\n this.setupPositioning(outletElement);\n\n // Mark as open\n this.isOpen.set(true);\n\n this.scrollStrategy =\n this.config.scrollBehaviour === 'block'\n ? new BlockScrollStrategy(this.viewportRuler, this.document)\n : new NoopScrollStrategy();\n\n this.scrollStrategy.enable();\n }\n\n /**\n * Internal method to setup positioning of the overlay\n */\n private setupPositioning(overlayElement: HTMLElement): void {\n // Determine positioning strategy based on overlay element's CSS\n const strategy =\n getComputedStyle(overlayElement).position === 'fixed'\n ? 'fixed'\n : this.config.strategy || 'absolute';\n\n // Use anchor element for positioning if provided, otherwise use trigger element\n const referenceElement = this.config.anchorElement || this.config.triggerElement;\n\n // Setup auto-update for positioning\n this.disposePositioning = autoUpdate(referenceElement, overlayElement, () =>\n this.computePosition(overlayElement, strategy),\n );\n }\n\n /**\n * Compute the overlay position using floating-ui\n */\n private async computePosition(\n overlayElement: HTMLElement,\n strategy: Strategy = 'absolute',\n ): Promise<void> {\n // Create middleware array\n const middleware: Middleware[] = [offset(this.config.offset ?? 0), shift()];\n\n // Add flip middleware if requested\n if (this.config.flip !== false) {\n middleware.push(flip());\n }\n\n // Add any additional middleware\n if (this.config.additionalMiddleware) {\n middleware.push(...this.config.additionalMiddleware);\n }\n\n // If the arrow element is registered, add arrow middleware\n if (this.arrowElement) {\n middleware.push(arrow({ element: this.arrowElement }));\n }\n\n // Compute the position\n const placement = this.config.placement?.() ?? 'top';\n\n // Use anchor element for positioning if provided, otherwise use trigger element\n const referenceElement = this.config.anchorElement || this.config.triggerElement;\n\n const position = await computePosition(referenceElement, overlayElement, {\n placement,\n middleware,\n strategy,\n });\n\n // Update position signal\n this.position.set({ x: position.x, y: position.y });\n\n // Update final placement signal\n this.finalPlacement.set(position.placement);\n\n // Update arrow position if available\n if (this.arrowElement) {\n this.arrowPosition.set({\n x: position.middlewareData.arrow?.x,\n y: position.middlewareData.arrow?.y,\n });\n }\n\n // Ensure view is updated\n this.portal()?.detectChanges();\n }\n\n /**\n * Internal method to destroy the overlay portal\n */\n private async destroyOverlay(): Promise<void> {\n const portal = this.portal();\n\n if (!portal) {\n return;\n }\n\n // Clear portal reference to prevent double destruction\n this.portal.set(null);\n\n // Clean up positioning\n this.disposePositioning?.();\n this.disposePositioning = undefined;\n\n // Detach the portal\n await portal.detach();\n\n // Mark as closed\n this.isOpen.set(false);\n\n // Reset final placement\n this.finalPlacement.set(undefined);\n\n // disable scroll strategy\n this.scrollStrategy.disable();\n this.scrollStrategy = new NoopScrollStrategy();\n }\n\n /**\n * Get the transform origin for the overlay\n */\n private getTransformOrigin(): string {\n const placement = this.config.placement?.() ?? 'top';\n const basePlacement = placement.split('-')[0]; // Extract \"top\", \"bottom\", etc.\n const alignment = placement.split('-')[1]; // Extract \"start\" or \"end\"\n\n const map: Record<string, string> = {\n top: 'bottom',\n bottom: 'top',\n left: 'right',\n right: 'left',\n };\n\n let x = 'center';\n let y = 'center';\n\n if (basePlacement === 'top' || basePlacement === 'bottom') {\n y = map[basePlacement];\n if (alignment === 'start') x = 'left';\n else if (alignment === 'end') x = 'right';\n } else {\n x = map[basePlacement];\n if (alignment === 'start') y = 'top';\n else if (alignment === 'end') y = 'bottom';\n }\n\n return `${y} ${x}`;\n }\n\n /**\n * Register the arrow element for positioning\n * @internal\n */\n registerArrow(arrowElement: HTMLElement | null): void {\n this.arrowElement = arrowElement;\n }\n\n /**\n * Remove the registered arrow element\n * @internal\n */\n unregisterArrow(): void {\n this.arrowElement = null;\n }\n\n /**\n * Resolve the container element from the configuration\n * @internal\n */\n private resolveContainer(): HTMLElement {\n if (!this.config.container) {\n return this.document.body;\n }\n\n if (typeof this.config.container === 'string') {\n const element = this.document.querySelector(this.config.container);\n if (!element) {\n // Fallback to document.body if the container is not found\n console.warn(\n `NgPrimitives: Container element with selector \"${this.config.container}\" not found. Falling back to document.body.`,\n );\n return this.document.body;\n }\n\n return element as HTMLElement;\n }\n\n return this.config.container;\n }\n}\n\n/**\n * Helper function to create an overlay in a single call\n * @internal\n */\nexport function createOverlay<T>(config: NgpOverlayConfig<T>): NgpOverlay<T> {\n // we run the overlay creation in the injector context to ensure that it can call the inject function\n return runInInjectionContext(config.injector, () => new NgpOverlay<T>(config));\n}\n\n/**\n * Helper function to inject the NgpOverlay instance\n * @internal\n */\nexport function injectOverlay<T>(): NgpOverlay<T> {\n return inject(NgpOverlay);\n}\n\nexport interface OverlayTriggerOptions {\n /**\n * Whether the visibility change should be immediate.\n */\n immediate?: boolean;\n /**\n * The origin of the focus event that triggered the visibility change.\n */\n origin?: FocusOrigin;\n}\n","import { DestroyRef, afterRenderEffect, inject } from '@angular/core';\nimport { injectElementRef } from 'ng-primitives/internal';\nimport { injectOverlay } from './overlay';\n\nexport function setupOverlayArrow(): void {\n const overlay = injectOverlay();\n const element = injectElementRef();\n const destroyRef = inject(DestroyRef);\n\n // register the arrow element with the overlay\n overlay.registerArrow(element.nativeElement);\n\n // cleanup the arrow element on destroy\n destroyRef.onDestroy(() => overlay.unregisterArrow());\n\n // update the arrow position after the overlay is rendered\n afterRenderEffect(() => {\n const position = overlay.arrowPosition();\n element.nativeElement.style.setProperty('inset-inline-start', `${position.x}px`);\n element.nativeElement.style.setProperty('inset-block-start', `${position.y}px`);\n element.nativeElement.dataset['placement'] = overlay.finalPlacement();\n });\n}\n","import { coerceNumberProperty } from '@angular/cdk/coercion';\nimport { isObject, isNil } from 'ng-primitives/utils';\n\n/**\n * Options for configuring offset between a floating element and its reference element.\n * Can be a single number for uniform offset or an object for axis-specific control.\n */\nexport interface NgpOffsetOptions {\n /**\n * The offset along the main axis (the axis that runs along the side of the floating element).\n * Represents the distance between the floating element and the reference element.\n * @default 0\n */\n mainAxis?: number;\n\n /**\n * The offset along the cross axis (the axis that runs along the alignment of the floating element).\n * Represents the skidding between the floating element and the reference element.\n * @default 0\n */\n crossAxis?: number;\n\n /**\n * Same axis as crossAxis but applies only to aligned placements and inverts the end alignment.\n * When set to a number, it overrides the crossAxis value.\n * @default null\n */\n alignmentAxis?: number | null;\n}\n\n/**\n * Type representing all valid offset values.\n * Can be a number (applies to mainAxis) or an object with axis-specific offsets.\n */\nexport type NgpOffset = number | NgpOffsetOptions;\n\n/**\n * Input type for offset that also accepts string representations of numbers\n */\nexport type NgpOffsetInput = NgpOffset | string;\n\n/**\n * Transform function to coerce offset input values to the correct type\n * @param value The input value to coerce\n * @returns The coerced offset value\n */\nexport function coerceOffset(value: NgpOffsetInput | null | undefined): NgpOffset {\n if (isNil(value)) {\n return 0;\n }\n\n if (isObject(value)) {\n return value;\n }\n\n // Use CDK's coerceNumberProperty for consistent number coercion\n // This handles strings, numbers, and other input types just like Angular CDK inputs\n return coerceNumberProperty(value, 0);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;AAEA,MAAM,sBAAsB,GAAG,IAAI,cAAc,CAAU,wBAAwB,CAAC;AAEpF;;;AAGG;SACa,oBAAoB,GAAA;AAClC,IAAA,OAAO,MAAM,CAAC,sBAAsB,CAAc;AACpD;AAEA;;;;AAIG;AACG,SAAU,qBAAqB,CAAI,KAAwC,EAAA;IAC/E,OAAO,EAAE,OAAO,EAAE,sBAAsB,EAAE,QAAQ,EAAE,KAAK,EAAE;AAC7D;;MCNsB,SAAS,CAAA;IAC7B,WAAA,CACqB,gBAAkC,EAClC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AAG,aAAa,EAAE;AAC/B,IAAA,MAAM,OAAO,GAAG,gBAAgB,EAAE;AAClC,IAAA,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC;;AAGrC,IAAA,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,aAAa,CAAC;;IAG5C,UAAU,CAAC,SAAS,CAAC,MAAM,OAAO,CAAC,eAAe,EAAE,CAAC;;IAGrD,iBAAiB,CAAC,MAAK;AACrB,QAAA,MAAM,QAAQ,GAAG,OAAO,CAAC,aAAa,EAAE;AACxC,QAAA,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,WAAW,CAAC,oBAAoB,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAA,EAAA,CAAI,CAAC;AAChF,QAAA,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,WAAW,CAAC,mBAAmB,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAA,EAAA,CAAI,CAAC;AAC/E,QAAA,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,cAAc,EAAE;AACvE,IAAA,CAAC,CAAC;AACJ;;ACmBA;;;;AAIG;AACG,SAAU,YAAY,CAAC,KAAwC,EAAA;AACnE,IAAA,IAAI,KAAK,CAAC,KAAK,CAAC,EAAE;AAChB,QAAA,OAAO,CAAC;IACV;AAEA,IAAA,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE;AACnB,QAAA,OAAO,KAAK;IACd;;;AAIA,IAAA,OAAO,oBAAoB,CAAC,KAAK,EAAE,CAAC,CAAC;AACvC;;AC1DA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ng-primitives-portal.mjs","sources":["../../../../packages/ng-primitives/portal/src/overlay-token.ts","../../../../packages/ng-primitives/portal/src/portal.ts","../../../../packages/ng-primitives/portal/src/scroll-strategy.ts","../../../../packages/ng-primitives/portal/src/overlay.ts","../../../../packages/ng-primitives/portal/src/overlay-arrow.ts","../../../../packages/ng-primitives/portal/src/offset.ts","../../../../packages/ng-primitives/portal/src/ng-primitives-portal.ts"],"sourcesContent":["import { inject, InjectionToken, Signal, ValueProvider } from '@angular/core';\n\nconst NgpOverlayContextToken = new InjectionToken<unknown>('NgpOverlayContextToken');\n\n/**\n * Injects the context for the overlay.\n * @internal\n */\nexport function injectOverlayContext<T>(): Signal<T> {\n return inject(NgpOverlayContextToken) as Signal<T>;\n}\n\n/**\n * Provides the context for the overlay.\n * @param value The value to provide as the context.\n * @internal\n */\nexport function provideOverlayContext<T>(value: Signal<T | undefined> | undefined): ValueProvider {\n return { provide: NgpOverlayContextToken, useValue: value };\n}\n","import { VERSION } from '@angular/cdk';\nimport { ComponentPortal, DomPortalOutlet, TemplatePortal } from '@angular/cdk/portal';\nimport {\n type ApplicationRef,\n ComponentRef,\n EmbeddedViewRef,\n Injector,\n TemplateRef,\n Type,\n ViewContainerRef,\n} from '@angular/core';\nimport { NgpExitAnimationRef, setupExitAnimation } from 'ng-primitives/internal';\n\nexport abstract class NgpPortal {\n constructor(\n protected readonly viewContainerRef: ViewContainerRef,\n protected readonly injector: Injector,\n ) {}\n\n /**\n * Get the elements of the portal.\n */\n abstract getElements(): HTMLElement[];\n\n /**\n * Detect changes in the portal.\n */\n abstract detectChanges(): void;\n\n /**\n * Whether the portal is attached to a DOM element.\n */\n abstract getAttached(): boolean;\n\n /**\n * Attach the portal to a DOM element.\n * @param container The DOM element to attach the portal to.\n */\n abstract attach(container: HTMLElement): this;\n\n /**\n * Detach the portal from the DOM.\n */\n abstract detach(): Promise<void>;\n\n /**\n * Angular v20 removes `_unusedComponentFactoryResolver` and `_document` from DomPortalOutlet's\n * constructor signature as they have been deprecated since v18, and replaced with optional\n * `_appRef` and `_defaultInjector` params.\n * This temporary change ensures consistent behaviour for consumers using ng v20+.\n * @see {@link https://github.com/angular/components/pull/24504 The implementing PR} for the new implementation.\n * @see {@link https://github.com/angular/components/blob/732a0d7ab69ec25925cc06a0fb17b0fb16a4b0ae/src/cdk/portal/dom-portal-outlet.ts#L27 The latest v20 version comments}\n * describe the importance of passing the `_appRef` and `_defaultInjector` when it comes to component portals\n */\n // todo: remove this compat fix once support for v19 is dropped when v21 is released\n // - should aim to add appRef also to prevent unforeseen issues in certain edge cases\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n protected _getDomPortalOutletCtorParamsCompat(): (ApplicationRef | Injector | undefined | any)[] {\n return Number(VERSION.major) >= 20 ? [this.injector] : [undefined, this.injector];\n }\n}\n\nexport class NgpComponentPortal<T> extends NgpPortal {\n private readonly componentPortal: ComponentPortal<T>;\n private viewRef: ComponentRef<T> | null = null;\n private isDestroying = false;\n private exitAnimationRef: NgpExitAnimationRef | null = null;\n\n constructor(component: Type<T>, viewContainerRef: ViewContainerRef, injector: Injector) {\n super(viewContainerRef, injector);\n this.componentPortal = new ComponentPortal(component, viewContainerRef, injector);\n }\n\n /**\n * Attach the portal to a DOM element.\n * @param container The DOM element to attach the portal to.\n */\n attach(container: HTMLElement): this {\n const domOutlet = new DomPortalOutlet(\n container,\n undefined,\n ...this._getDomPortalOutletCtorParamsCompat(),\n );\n this.viewRef = domOutlet.attach(this.componentPortal);\n\n const element = this.viewRef.location.nativeElement as HTMLElement;\n\n this.exitAnimationRef = setupExitAnimation({ element });\n\n return this;\n }\n\n /**\n * Get the root elements of the portal.\n */\n getElements(): HTMLElement[] {\n return this.viewRef ? [this.viewRef.location.nativeElement] : [];\n }\n\n /**\n * Detect changes in the portal.\n */\n detectChanges(): void {\n this.viewRef?.changeDetectorRef.detectChanges();\n }\n\n /**\n * Whether the portal is attached to a DOM element.\n */\n getAttached(): boolean {\n return !!this.viewRef && (this.viewRef.location.nativeElement as HTMLElement).isConnected;\n }\n\n /**\n * Detach the portal from the DOM.\n */\n async detach(): Promise<void> {\n if (this.isDestroying) {\n return;\n }\n this.isDestroying = true;\n\n // if there is an exit animation manager, wait for it to finish\n await this.exitAnimationRef?.exit();\n\n if (this.viewRef) {\n this.viewRef.destroy();\n this.viewRef = null;\n }\n }\n}\n\nexport class NgpTemplatePortal<T> extends NgpPortal {\n private readonly templatePortal: TemplatePortal<T>;\n private viewRef: EmbeddedViewRef<T> | null = null;\n private exitAnimationRefs: NgpExitAnimationRef[] = [];\n private isDestroying = false;\n\n constructor(\n template: TemplateRef<T>,\n viewContainerRef: ViewContainerRef,\n injector: Injector,\n context?: T,\n ) {\n super(viewContainerRef, injector);\n this.templatePortal = new TemplatePortal(template, viewContainerRef, context, injector);\n }\n\n /**\n * Attach the portal to a DOM element.\n * @param container The DOM element to attach the portal to.\n */\n attach(container: HTMLElement): this {\n const domOutlet = new DomPortalOutlet(\n container,\n undefined,\n ...this._getDomPortalOutletCtorParamsCompat(),\n );\n this.viewRef = domOutlet.attach(this.templatePortal);\n\n for (const rootNode of this.viewRef.rootNodes) {\n if (rootNode instanceof HTMLElement) {\n // Setup exit animation for each root node\n const exitAnimationRef = setupExitAnimation({ element: rootNode });\n this.exitAnimationRefs.push(exitAnimationRef);\n }\n }\n\n return this;\n }\n\n /**\n * Get the root elements of the portal.\n */\n getElements(): HTMLElement[] {\n return this.viewRef ? this.viewRef.rootNodes : [];\n }\n\n /**\n * Detect changes in the portal.\n */\n detectChanges(): void {\n this.viewRef?.detectChanges();\n }\n\n /**\n * Whether the portal is attached to a DOM element.\n */\n getAttached(): boolean {\n return !!this.viewRef && this.viewRef.rootNodes.length > 0;\n }\n\n /**\n * Detach the portal from the DOM.\n */\n async detach(): Promise<void> {\n if (this.isDestroying) {\n return;\n }\n\n this.isDestroying = true;\n\n // if there is an exit animation manager, wait for it to finish\n await Promise.all(this.exitAnimationRefs.map(ref => ref.exit()));\n\n if (this.viewRef) {\n this.viewRef.destroy();\n this.viewRef = null;\n }\n }\n}\n\nexport function createPortal<T>(\n componentOrTemplate: Type<T> | TemplateRef<T>,\n viewContainerRef: ViewContainerRef,\n injector: Injector,\n context?: T,\n): NgpPortal {\n if (componentOrTemplate instanceof TemplateRef) {\n return new NgpTemplatePortal(componentOrTemplate, viewContainerRef, injector, context);\n } else {\n return new NgpComponentPortal(componentOrTemplate, viewContainerRef, injector);\n }\n}\n","/**\n * This code is largely based on the CDK Overlay's scroll strategy implementation, however it\n * has been modified so that it does not rely on the CDK's global overlay styles.\n */\nimport { coerceCssPixelValue } from '@angular/cdk/coercion';\nimport { ViewportRuler } from '@angular/cdk/overlay';\nimport { isFunction, isObject } from 'ng-primitives/utils';\n\nexport interface ScrollStrategy {\n enable(): void;\n disable(): void;\n}\n\n/** Cached result of the check that indicates whether the browser supports scroll behaviors. */\nlet scrollBehaviorSupported: boolean | undefined;\n\nexport function supportsScrollBehavior(): boolean {\n if (scrollBehaviorSupported != null) {\n return scrollBehaviorSupported;\n }\n\n // If we're not in the browser, it can't be supported. Also check for `Element`, because\n // some projects stub out the global `document` during SSR which can throw us off.\n if (!isObject(document) || !document || !isFunction(Element) || !Element) {\n return (scrollBehaviorSupported = false);\n }\n\n // If the element can have a `scrollBehavior` style, we can be sure that it's supported.\n if ('scrollBehavior' in document.documentElement!.style) {\n return (scrollBehaviorSupported = true);\n }\n\n // Check if scrollTo is supported and if it's been polyfilled\n const scrollToFunction = Element.prototype.scrollTo;\n if (!scrollToFunction) {\n return (scrollBehaviorSupported = false);\n }\n\n // We can detect if the function has been polyfilled by calling `toString` on it. Native\n // functions are obfuscated using `[native code]`, whereas if it was overwritten we'd get\n // the actual function source. Via https://davidwalsh.name/detect-native-function. Consider\n // polyfilled functions as supporting scroll behavior.\n return (scrollBehaviorSupported = !/\\{\\s*\\[native code\\]\\s*\\}/.test(scrollToFunction.toString()));\n}\n\ninterface HTMLStyles {\n top: string;\n left: string;\n position: string;\n overflowY: string;\n width: string;\n}\n\nexport class BlockScrollStrategy implements ScrollStrategy {\n private readonly previousHTMLStyles: HTMLStyles = {\n top: '',\n left: '',\n position: '',\n overflowY: '',\n width: '',\n };\n private previousScrollPosition = { top: 0, left: 0 };\n private isEnabled = false;\n\n constructor(\n private readonly viewportRuler: ViewportRuler,\n private readonly document: Document,\n ) {}\n\n /** Blocks page-level scroll while the attached overlay is open. */\n enable() {\n if (this.canBeEnabled()) {\n const root = this.document.documentElement!;\n\n this.previousScrollPosition = this.viewportRuler.getViewportScrollPosition();\n\n // Cache the previous inline styles in case the user had set them.\n this.previousHTMLStyles.left = root.style.left || '';\n this.previousHTMLStyles.top = root.style.top || '';\n this.previousHTMLStyles.position = root.style.position || '';\n this.previousHTMLStyles.overflowY = root.style.overflowY || '';\n this.previousHTMLStyles.width = root.style.width || '';\n\n // Set the styles to block scrolling.\n root.style.position = 'fixed';\n\n // Necessary for the content not to lose its width. Note that we're using 100%, instead of\n // 100vw, because 100vw includes the width plus the scrollbar, whereas 100% is the width\n // that the element had before we made it `fixed`.\n root.style.width = '100%';\n\n // Note: this will always add a scrollbar to whatever element it is on, which can\n // potentially result in double scrollbars. It shouldn't be an issue, because we won't\n // block scrolling on a page that doesn't have a scrollbar in the first place.\n root.style.overflowY = 'scroll';\n\n // Note: we're using the `html` node, instead of the `body`, because the `body` may\n // have the user agent margin, whereas the `html` is guaranteed not to have one.\n root.style.left = coerceCssPixelValue(-this.previousScrollPosition.left);\n root.style.top = coerceCssPixelValue(-this.previousScrollPosition.top);\n root.setAttribute('data-scrollblock', '');\n this.isEnabled = true;\n }\n }\n\n /** Unblocks page-level scroll while the attached overlay is open. */\n disable(): void {\n if (this.isEnabled) {\n const html = this.document.documentElement!;\n const body = this.document.body!;\n const htmlStyle = html.style;\n const bodyStyle = body.style;\n const previousHtmlScrollBehavior = htmlStyle.scrollBehavior || '';\n const previousBodyScrollBehavior = bodyStyle.scrollBehavior || '';\n\n this.isEnabled = false;\n\n htmlStyle.left = this.previousHTMLStyles.left;\n htmlStyle.top = this.previousHTMLStyles.top;\n htmlStyle.position = this.previousHTMLStyles.position;\n htmlStyle.overflowY = this.previousHTMLStyles.overflowY;\n htmlStyle.width = this.previousHTMLStyles.width;\n html.removeAttribute('data-scrollblock');\n\n // Disable user-defined smooth scrolling temporarily while we restore the scroll position.\n // See https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-behavior\n // Note that we don't mutate the property if the browser doesn't support `scroll-behavior`,\n // because it can throw off feature detections in `supportsScrollBehavior` which\n // checks for `'scrollBehavior' in documentElement.style`.\n if (scrollBehaviorSupported) {\n htmlStyle.scrollBehavior = bodyStyle.scrollBehavior = 'auto';\n }\n\n window.scroll(this.previousScrollPosition.left, this.previousScrollPosition.top);\n\n if (scrollBehaviorSupported) {\n htmlStyle.scrollBehavior = previousHtmlScrollBehavior;\n bodyStyle.scrollBehavior = previousBodyScrollBehavior;\n }\n }\n }\n\n private canBeEnabled(): boolean {\n // Since the scroll strategies can't be singletons, we have to use a global CSS class\n // (`cdk-global-scrollblock`) to make sure that we don't try to disable global\n // scrolling multiple times.\n const html = this.document.documentElement!;\n\n if (html.classList.contains('cdk-global-scrollblock') || this.isEnabled) {\n return false;\n }\n\n const viewport = this.viewportRuler.getViewportSize();\n return html.scrollHeight > viewport.height || html.scrollWidth > viewport.width;\n }\n}\n\nexport class NoopScrollStrategy implements ScrollStrategy {\n enable(): void {\n // No operation for enabling\n }\n\n disable(): void {\n // No operation for disabling\n }\n}\n","import { FocusMonitor, FocusOrigin } from '@angular/cdk/a11y';\nimport { ViewportRuler } from '@angular/cdk/overlay';\nimport {\n DOCUMENT,\n DestroyRef,\n Injector,\n Provider,\n Signal,\n TemplateRef,\n Type,\n ViewContainerRef,\n computed,\n inject,\n runInInjectionContext,\n signal,\n} from '@angular/core';\nimport {\n Middleware,\n Placement,\n Strategy,\n arrow,\n autoUpdate,\n computePosition,\n flip,\n offset,\n shift,\n} from '@floating-ui/dom';\nimport { explicitEffect, fromResizeEvent } from 'ng-primitives/internal';\nimport { injectDisposables, safeTakeUntilDestroyed, uniqueId } from 'ng-primitives/utils';\nimport { Subject, fromEvent } from 'rxjs';\nimport { debounceTime } from 'rxjs/operators';\nimport { NgpOffset } from './offset';\nimport { provideOverlayContext } from './overlay-token';\nimport { NgpPortal, createPortal } from './portal';\nimport { BlockScrollStrategy, NoopScrollStrategy } from './scroll-strategy';\n\n/**\n * Configuration options for creating an overlay\n * @internal\n */\nexport interface NgpOverlayConfig<T = unknown> {\n /** Content to display in the overlay (component or template) */\n content: NgpOverlayContent<T>;\n\n /** The element that triggers the overlay */\n triggerElement: HTMLElement;\n\n /** The element to use for positioning the overlay (if different from trigger) */\n anchorElement?: HTMLElement | null;\n\n /** The injector to use for creating the portal */\n injector: Injector;\n /** ViewContainerRef to use for creating the portal */\n viewContainerRef: ViewContainerRef;\n\n /** Context data to pass to the overlay content */\n context?: Signal<T | undefined>;\n\n /** Container element or selector to attach the overlay to (defaults to document.body) */\n container?: HTMLElement | string | null;\n\n /** Preferred placement of the overlay relative to the trigger. */\n placement?: Signal<Placement>;\n\n /** Offset distance between the overlay and trigger. Can be a number or an object with axis-specific offsets */\n offset?: NgpOffset;\n\n /** Whether to enable flip behavior when space is limited */\n flip?: boolean;\n\n /** Delay before showing the overlay in milliseconds */\n showDelay?: number;\n\n /** Delay before hiding the overlay in milliseconds */\n hideDelay?: number;\n\n /** Whether the overlay should be positioned with fixed or absolute strategy */\n strategy?: Strategy;\n\n /** The scroll strategy to use for the overlay */\n scrollBehaviour?: 'reposition' | 'block';\n /** Whether to close the overlay when clicking outside */\n closeOnOutsideClick?: boolean;\n /** Whether to close the overlay when pressing escape */\n closeOnEscape?: boolean;\n /** Whether to restore focus to the trigger element when hiding the overlay */\n restoreFocus?: boolean;\n /** Additional middleware for floating UI positioning */\n additionalMiddleware?: Middleware[];\n\n /** Additional providers */\n providers?: Provider[];\n}\n\n/** Type for overlay content which can be either a template or component */\nexport type NgpOverlayContent<T> = TemplateRef<NgpOverlayTemplateContext<T>> | Type<unknown>;\n\n/** Context for template-based overlays */\nexport type NgpOverlayTemplateContext<T> = {\n $implicit: T;\n};\n\n/**\n * NgpOverlay manages the lifecycle and positioning of overlay UI elements.\n * It abstracts the common behavior shared by tooltips, popovers, menus, etc.\n * @internal\n */\nexport class NgpOverlay<T = unknown> {\n private readonly disposables = injectDisposables();\n private readonly document = inject(DOCUMENT);\n private readonly destroyRef = inject(DestroyRef);\n private readonly viewContainerRef: ViewContainerRef;\n private readonly viewportRuler = inject(ViewportRuler);\n private readonly focusMonitor = inject(FocusMonitor);\n /** Access any parent overlays */\n private readonly parentOverlay = inject(NgpOverlay, { optional: true });\n /** Signal tracking the portal instance */\n private readonly portal = signal<NgpPortal | null>(null);\n\n /** Signal tracking the overlay position */\n readonly position = signal<{ x: number | undefined; y: number | undefined }>({\n x: undefined,\n y: undefined,\n });\n\n /**\n * Determine if the overlay has been positioned\n * @internal\n */\n readonly isPositioned = computed(\n () => this.position().x !== undefined && this.position().y !== undefined,\n );\n\n /** Signal tracking the trigger element width */\n readonly triggerWidth = signal<number | null>(null);\n\n /** The transform origin for the overlay */\n readonly transformOrigin = signal<string>('center center');\n\n /** Signal tracking the final placement of the overlay */\n readonly finalPlacement = signal<Placement | undefined>(undefined);\n\n /** Function to dispose the positioning auto-update */\n private disposePositioning?: () => void;\n\n /** Timeout handle for showing the overlay */\n private openTimeout?: () => void;\n\n /** Timeout handle for hiding the overlay */\n private closeTimeout?: () => void;\n\n /** Signal tracking whether the overlay is open */\n readonly isOpen = signal(false);\n\n /** A unique id for the overlay */\n readonly id = signal<string>(uniqueId('ngp-overlay'));\n\n /** The aria-describedby attribute for accessibility */\n readonly ariaDescribedBy = computed(() => (this.isOpen() ? this.id() : undefined));\n\n /** The scroll strategy */\n private scrollStrategy = new NoopScrollStrategy();\n\n /** An observable that emits when the overlay is closing */\n readonly closing = new Subject<void>();\n\n /** Store the arrow element */\n private arrowElement: HTMLElement | null = null;\n\n /** @internal The position of the arrow */\n readonly arrowPosition = signal<{ x: number | undefined; y: number | undefined }>({\n x: undefined,\n y: undefined,\n });\n\n /**\n * Creates a new overlay instance\n * @param config Initial configuration for the overlay\n * @param destroyRef Reference for automatic cleanup\n */\n constructor(private config: NgpOverlayConfig<T>) {\n // we cannot inject the viewContainerRef as this can throw an error during hydration in SSR\n this.viewContainerRef = config.viewContainerRef;\n\n // Listen for placement signal changes to update position\n if (config.placement) {\n explicitEffect([config.placement], () => this.updatePosition());\n }\n\n // this must be done after the config is set\n this.transformOrigin.set(this.getTransformOrigin());\n\n // Monitor trigger element resize\n const elementToMonitor = this.config.anchorElement || this.config.triggerElement;\n fromResizeEvent(elementToMonitor)\n .pipe(safeTakeUntilDestroyed(this.destroyRef))\n .subscribe(({ width, height }) => {\n this.triggerWidth.set(width);\n\n // if the element has been hidden, hide immediately\n if (width === 0 || height === 0) {\n this.hideImmediate();\n }\n });\n\n // if there is a parent overlay and it is closed, close this overlay\n this.parentOverlay?.closing\n // we add a debounce here to ensure any dom events like clicks are processed first\n .pipe(debounceTime(0), safeTakeUntilDestroyed(this.destroyRef))\n .subscribe(() => {\n if (this.isOpen()) {\n this.hideImmediate();\n }\n });\n\n // If closeOnOutsideClick is enabled, set up a click listener\n fromEvent<MouseEvent>(this.document, 'mouseup', { capture: true })\n .pipe(safeTakeUntilDestroyed(this.destroyRef))\n .subscribe(event => {\n if (!this.config.closeOnOutsideClick) {\n return;\n }\n\n const overlay = this.portal();\n\n if (!overlay || !this.isOpen()) {\n return;\n }\n\n const path = event.composedPath();\n const isInsideOverlay = overlay.getElements().some(el => path.includes(el));\n const isInsideTrigger = path.includes(this.config.triggerElement);\n const isInsideAnchor = this.config.anchorElement\n ? path.includes(this.config.anchorElement)\n : false;\n\n if (!isInsideOverlay && !isInsideTrigger && !isInsideAnchor) {\n this.hide();\n }\n });\n\n // If closeOnEscape is enabled, set up a keydown listener\n fromEvent<KeyboardEvent>(this.document, 'keydown', { capture: true })\n .pipe(safeTakeUntilDestroyed(this.destroyRef))\n .subscribe(event => {\n if (!this.config.closeOnEscape) return;\n if (event.key === 'Escape' && this.isOpen()) {\n this.hide({ origin: 'keyboard', immediate: true });\n }\n });\n\n // Ensure cleanup on destroy\n this.destroyRef.onDestroy(() => this.destroy());\n }\n\n /**\n * Show the overlay with the specified delay\n * @param showDelay Optional delay to override the configured showDelay\n */\n show(): Promise<void> {\n return new Promise<void>(resolve => {\n // If closing is in progress, cancel it\n if (this.closeTimeout) {\n this.closeTimeout();\n this.closeTimeout = undefined;\n }\n\n // Don't proceed if already opening or open\n if (this.openTimeout || this.isOpen()) {\n return;\n }\n\n // Use the provided delay or fall back to config\n const delay = this.config.showDelay ?? 0;\n\n this.openTimeout = this.disposables.setTimeout(() => {\n this.openTimeout = undefined;\n this.createOverlay();\n resolve();\n }, delay);\n });\n }\n\n /**\n * Stop any pending close operation. This is useful for example, if we move the mouse from the tooltip trigger to the tooltip itself.\n * This will prevent the tooltip from closing immediately when the mouse leaves the trigger.\n * @internal\n */\n cancelPendingClose(): void {\n if (this.closeTimeout) {\n this.closeTimeout();\n this.closeTimeout = undefined;\n }\n }\n\n /**\n * Hide the overlay with the specified delay\n * @param options Optional options for hiding the overlay\n */\n hide(options?: OverlayTriggerOptions): void {\n // If opening is in progress, cancel it\n if (this.openTimeout) {\n this.openTimeout();\n this.openTimeout = undefined;\n }\n\n // Don't proceed if already closing or closed unless immediate is true\n if ((this.closeTimeout && !options?.immediate) || !this.isOpen()) {\n return;\n }\n\n this.closing.next();\n\n const dispose = async () => {\n this.closeTimeout = undefined;\n\n if (this.config.restoreFocus) {\n this.focusMonitor.focusVia(this.config.triggerElement, options?.origin ?? 'program', {\n preventScroll: true,\n });\n }\n\n await this.destroyOverlay();\n };\n\n if (options?.immediate) {\n // If immediate, dispose right away\n dispose();\n } else {\n this.closeTimeout = this.disposables.setTimeout(dispose, this.config.hideDelay ?? 0);\n }\n }\n\n /**\n * Update the configuration of this overlay\n * @param config New configuration (partial)\n */\n updateConfig(config: Partial<NgpOverlayConfig<T>>): void {\n this.config = { ...this.config, ...config };\n\n // If the overlay is already open, update its position\n if (this.isOpen()) {\n this.updatePosition();\n }\n }\n\n /**\n * Immediately hide the overlay without any delay\n */\n hideImmediate(): void {\n this.hide({ immediate: true });\n }\n\n /**\n * Toggle the overlay open/closed state\n */\n toggle(): void {\n if (this.isOpen()) {\n this.hide();\n } else {\n this.show();\n }\n }\n\n /**\n * Force update the position of the overlay\n */\n updatePosition(): void {\n const portal = this.portal();\n\n if (!portal) {\n return;\n }\n\n const elements = portal.getElements();\n\n if (elements.length === 0) {\n return;\n }\n\n const overlayElement = elements[0] as HTMLElement;\n\n // Compute new position\n this.computePosition(overlayElement);\n }\n\n /**\n * Completely destroy this overlay instance\n */\n destroy(): void {\n this.hideImmediate();\n this.disposePositioning?.();\n this.scrollStrategy.disable();\n }\n\n /**\n * Get the elements of the overlay\n */\n getElements(): HTMLElement[] {\n return this.portal()?.getElements() ?? [];\n }\n\n /**\n * Internal method to create the overlay\n */\n private createOverlay(): void {\n if (!this.config.content) {\n throw new Error('Overlay content must be provided');\n }\n\n // Create a new portal with context\n const portal = createPortal(\n this.config.content,\n this.viewContainerRef,\n Injector.create({\n parent: this.config.injector,\n providers: [\n ...(this.config.providers || []),\n { provide: NgpOverlay, useValue: this },\n provideOverlayContext<T>(this.config.context),\n ],\n }),\n { $implicit: this.config.context } as NgpOverlayTemplateContext<T>,\n );\n\n // Attach portal to container\n const container = this.resolveContainer();\n portal.attach(container);\n\n // Update portal signal\n this.portal.set(portal);\n\n // Ensure view is up to date\n portal.detectChanges();\n\n // find a dedicated outlet element\n // this is the element that has the `data-overlay` attribute\n // if no such element exists, we use the first element in the portal\n const outletElement =\n portal.getElements().find(el => el.hasAttribute('data-overlay')) ?? portal.getElements()[0];\n\n if (!outletElement) {\n throw new Error('Overlay element is not available.');\n }\n\n // Set up positioning\n this.setupPositioning(outletElement);\n\n // Mark as open\n this.isOpen.set(true);\n\n this.scrollStrategy =\n this.config.scrollBehaviour === 'block'\n ? new BlockScrollStrategy(this.viewportRuler, this.document)\n : new NoopScrollStrategy();\n\n this.scrollStrategy.enable();\n }\n\n /**\n * Internal method to setup positioning of the overlay\n */\n private setupPositioning(overlayElement: HTMLElement): void {\n // Determine positioning strategy based on overlay element's CSS\n const strategy =\n getComputedStyle(overlayElement).position === 'fixed'\n ? 'fixed'\n : this.config.strategy || 'absolute';\n\n // Use anchor element for positioning if provided, otherwise use trigger element\n const referenceElement = this.config.anchorElement || this.config.triggerElement;\n\n // Setup auto-update for positioning\n this.disposePositioning = autoUpdate(referenceElement, overlayElement, () =>\n this.computePosition(overlayElement, strategy),\n );\n }\n\n /**\n * Compute the overlay position using floating-ui\n */\n private async computePosition(\n overlayElement: HTMLElement,\n strategy: Strategy = 'absolute',\n ): Promise<void> {\n // Create middleware array\n const middleware: Middleware[] = [offset(this.config.offset ?? 0), shift()];\n\n // Add flip middleware if requested\n if (this.config.flip !== false) {\n middleware.push(flip());\n }\n\n // Add any additional middleware\n if (this.config.additionalMiddleware) {\n middleware.push(...this.config.additionalMiddleware);\n }\n\n // If the arrow element is registered, add arrow middleware\n if (this.arrowElement) {\n middleware.push(arrow({ element: this.arrowElement }));\n }\n\n // Compute the position\n const placement = this.config.placement?.() ?? 'top';\n\n // Use anchor element for positioning if provided, otherwise use trigger element\n const referenceElement = this.config.anchorElement || this.config.triggerElement;\n\n const position = await computePosition(referenceElement, overlayElement, {\n placement,\n middleware,\n strategy,\n });\n\n // Update position signal\n this.position.set({ x: position.x, y: position.y });\n\n // Update final placement signal\n this.finalPlacement.set(position.placement);\n\n // Update arrow position if available\n if (this.arrowElement) {\n this.arrowPosition.set({\n x: position.middlewareData.arrow?.x,\n y: position.middlewareData.arrow?.y,\n });\n }\n\n // Ensure view is updated\n this.portal()?.detectChanges();\n }\n\n /**\n * Internal method to destroy the overlay portal\n */\n private async destroyOverlay(): Promise<void> {\n const portal = this.portal();\n\n if (!portal) {\n return;\n }\n\n // Clear portal reference to prevent double destruction\n this.portal.set(null);\n\n // Clean up positioning\n this.disposePositioning?.();\n this.disposePositioning = undefined;\n\n // Detach the portal\n await portal.detach();\n\n // Mark as closed\n this.isOpen.set(false);\n\n // Reset final placement\n this.finalPlacement.set(undefined);\n\n // disable scroll strategy\n this.scrollStrategy.disable();\n this.scrollStrategy = new NoopScrollStrategy();\n }\n\n /**\n * Get the transform origin for the overlay\n */\n private getTransformOrigin(): string {\n const placement = this.config.placement?.() ?? 'top';\n const basePlacement = placement.split('-')[0]; // Extract \"top\", \"bottom\", etc.\n const alignment = placement.split('-')[1]; // Extract \"start\" or \"end\"\n\n const map: Record<string, string> = {\n top: 'bottom',\n bottom: 'top',\n left: 'right',\n right: 'left',\n };\n\n let x = 'center';\n let y = 'center';\n\n if (basePlacement === 'top' || basePlacement === 'bottom') {\n y = map[basePlacement];\n if (alignment === 'start') x = 'left';\n else if (alignment === 'end') x = 'right';\n } else {\n x = map[basePlacement];\n if (alignment === 'start') y = 'top';\n else if (alignment === 'end') y = 'bottom';\n }\n\n return `${y} ${x}`;\n }\n\n /**\n * Register the arrow element for positioning\n * @internal\n */\n registerArrow(arrowElement: HTMLElement | null): void {\n this.arrowElement = arrowElement;\n }\n\n /**\n * Remove the registered arrow element\n * @internal\n */\n unregisterArrow(): void {\n this.arrowElement = null;\n }\n\n /**\n * Resolve the container element from the configuration\n * @internal\n */\n private resolveContainer(): HTMLElement {\n if (!this.config.container) {\n return this.document.body;\n }\n\n if (typeof this.config.container === 'string') {\n const element = this.document.querySelector(this.config.container);\n if (!element) {\n // Fallback to document.body if the container is not found\n console.warn(\n `NgPrimitives: Container element with selector \"${this.config.container}\" not found. Falling back to document.body.`,\n );\n return this.document.body;\n }\n\n return element as HTMLElement;\n }\n\n return this.config.container;\n }\n}\n\n/**\n * Helper function to create an overlay in a single call\n * @internal\n */\nexport function createOverlay<T>(config: NgpOverlayConfig<T>): NgpOverlay<T> {\n // we run the overlay creation in the injector context to ensure that it can call the inject function\n return runInInjectionContext(config.injector, () => new NgpOverlay<T>(config));\n}\n\n/**\n * Helper function to inject the NgpOverlay instance\n * @internal\n */\nexport function injectOverlay<T>(): NgpOverlay<T> {\n return inject(NgpOverlay);\n}\n\nexport interface OverlayTriggerOptions {\n /**\n * Whether the visibility change should be immediate.\n */\n immediate?: boolean;\n /**\n * The origin of the focus event that triggered the visibility change.\n */\n origin?: FocusOrigin;\n}\n","import { DestroyRef, afterRenderEffect, inject } from '@angular/core';\nimport { injectElementRef } from 'ng-primitives/internal';\nimport { injectOverlay } from './overlay';\n\nexport function setupOverlayArrow(): void {\n const overlay = injectOverlay();\n const element = injectElementRef();\n const destroyRef = inject(DestroyRef);\n\n // register the arrow element with the overlay\n overlay.registerArrow(element.nativeElement);\n\n // cleanup the arrow element on destroy\n destroyRef.onDestroy(() => overlay.unregisterArrow());\n\n // update the arrow position after the overlay is rendered\n afterRenderEffect(() => {\n const position = overlay.arrowPosition();\n element.nativeElement.style.setProperty('inset-inline-start', `${position.x}px`);\n element.nativeElement.style.setProperty('inset-block-start', `${position.y}px`);\n element.nativeElement.dataset['placement'] = overlay.finalPlacement();\n });\n}\n","import { coerceNumberProperty } from '@angular/cdk/coercion';\nimport { isObject, isNil } from 'ng-primitives/utils';\n\n/**\n * Options for configuring offset between a floating element and its reference element.\n * Can be a single number for uniform offset or an object for axis-specific control.\n */\nexport interface NgpOffsetOptions {\n /**\n * The offset along the main axis (the axis that runs along the side of the floating element).\n * Represents the distance between the floating element and the reference element.\n * @default 0\n */\n mainAxis?: number;\n\n /**\n * The offset along the cross axis (the axis that runs along the alignment of the floating element).\n * Represents the skidding between the floating element and the reference element.\n * @default 0\n */\n crossAxis?: number;\n\n /**\n * Same axis as crossAxis but applies only to aligned placements and inverts the end alignment.\n * When set to a number, it overrides the crossAxis value.\n * @default null\n */\n alignmentAxis?: number | null;\n}\n\n/**\n * Type representing all valid offset values.\n * Can be a number (applies to mainAxis) or an object with axis-specific offsets.\n */\nexport type NgpOffset = number | NgpOffsetOptions;\n\n/**\n * Input type for offset that also accepts string representations of numbers\n */\nexport type NgpOffsetInput = NgpOffset | string;\n\n/**\n * Transform function to coerce offset input values to the correct type\n * @param value The input value to coerce\n * @returns The coerced offset value\n */\nexport function coerceOffset(value: NgpOffsetInput | null | undefined): NgpOffset {\n if (isNil(value)) {\n return 0;\n }\n\n if (isObject(value)) {\n return value;\n }\n\n // Use CDK's coerceNumberProperty for consistent number coercion\n // This handles strings, numbers, and other input types just like Angular CDK inputs\n return coerceNumberProperty(value, 0);\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;AAEA,MAAM,sBAAsB,GAAG,IAAI,cAAc,CAAU,wBAAwB,CAAC;AAEpF;;;AAGG;SACa,oBAAoB,GAAA;AAClC,IAAA,OAAO,MAAM,CAAC,sBAAsB,CAAc;AACpD;AAEA;;;;AAIG;AACG,SAAU,qBAAqB,CAAI,KAAwC,EAAA;IAC/E,OAAO,EAAE,OAAO,EAAE,sBAAsB,EAAE,QAAQ,EAAE,KAAK,EAAE;AAC7D;;MCNsB,SAAS,CAAA;IAC7B,WAAA,CACqB,gBAAkC,EAClC,QAAkB,EAAA;QADlB,IAAA,CAAA,gBAAgB,GAAhB,gBAAgB;QAChB,IAAA,CAAA,QAAQ,GAAR,QAAQ;IAC1B;AA4BH;;;;;;;;AAQG;;;;IAIO,mCAAmC,GAAA;QAC3C,OAAO,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC,QAAQ,CAAC;IACnF;AACD;AAEK,MAAO,kBAAsB,SAAQ,SAAS,CAAA;AAMlD,IAAA,WAAA,CAAY,SAAkB,EAAE,gBAAkC,EAAE,QAAkB,EAAA;AACpF,QAAA,KAAK,CAAC,gBAAgB,EAAE,QAAQ,CAAC;QAL3B,IAAA,CAAA,OAAO,GAA2B,IAAI;QACtC,IAAA,CAAA,YAAY,GAAG,KAAK;QACpB,IAAA,CAAA,gBAAgB,GAA+B,IAAI;AAIzD,QAAA,IAAI,CAAC,eAAe,GAAG,IAAI,eAAe,CAAC,SAAS,EAAE,gBAAgB,EAAE,QAAQ,CAAC;IACnF;AAEA;;;AAGG;AACH,IAAA,MAAM,CAAC,SAAsB,EAAA;AAC3B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;AAIG;AACG,SAAU,YAAY,CAAC,KAAwC,EAAA;AACnE,IAAA,IAAI,KAAK,CAAC,KAAK,CAAC,EAAE;AAChB,QAAA,OAAO,CAAC;IACV;AAEA,IAAA,IAAI,QAAQ,CAAC,KAAK,CAAC,EAAE;AACnB,QAAA,OAAO,KAAK;IACd;;;AAIA,IAAA,OAAO,oBAAoB,CAAC,KAAK,EAAE,CAAC,CAAC;AACvC;;AC1DA;;AAEG;;;;"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { coerceElement } from '@angular/cdk/coercion';
|
|
2
2
|
import { InjectionToken, signal, inject, computed, linkedSignal, isSignal, Injector, ElementRef, runInInjectionContext, afterRenderEffect, NgZone, DestroyRef, forwardRef } from '@angular/core';
|
|
3
|
-
import { isFunction } from 'ng-primitives/utils';
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* Create a new injection token for the state.
|
|
@@ -66,7 +65,7 @@ function createState(token) {
|
|
|
66
65
|
if (descriptor?.get || descriptor?.set) {
|
|
67
66
|
Object.defineProperty(obj, key, descriptor);
|
|
68
67
|
}
|
|
69
|
-
else if (
|
|
68
|
+
else if (typeof prototype[key] === 'function') {
|
|
70
69
|
obj[key] = prototype[key].bind(state);
|
|
71
70
|
}
|
|
72
71
|
else {
|
|
@@ -86,7 +85,9 @@ function createControlledInput(property) {
|
|
|
86
85
|
const symbol = Object.getOwnPropertySymbols(property).find(s => s.description === 'SIGNAL');
|
|
87
86
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
88
87
|
const inputDefinition = symbol ? property[symbol] : undefined;
|
|
89
|
-
if (!symbol ||
|
|
88
|
+
if (!symbol ||
|
|
89
|
+
!inputDefinition ||
|
|
90
|
+
typeof inputDefinition.applyValueToInputSignal !== 'function') {
|
|
90
91
|
console.warn('Angular has changed its internal Input implementation, report this issue to ng-primitives.');
|
|
91
92
|
// fallback to a linked signal which is partially controlled
|
|
92
93
|
return linkedSignal(() => property());
|
|
@@ -265,6 +266,10 @@ function listener(element, event, handler, options) {
|
|
|
265
266
|
destroyRef.onDestroy(() => nativeElement.removeEventListener(event, handler));
|
|
266
267
|
});
|
|
267
268
|
}
|
|
269
|
+
function onMount(callback) {
|
|
270
|
+
const injector = inject(Injector);
|
|
271
|
+
afterRenderEffect(() => runInInjectionContext(injector, callback), { injector });
|
|
272
|
+
}
|
|
268
273
|
function onDestroy(callback) {
|
|
269
274
|
const destroyRef = inject(DestroyRef);
|
|
270
275
|
destroyRef.onDestroy(callback);
|
|
@@ -300,5 +305,5 @@ function injectInheritedState(token, injectOptions = {}) {
|
|
|
300
305
|
* Generated bundle index. Do not edit.
|
|
301
306
|
*/
|
|
302
307
|
|
|
303
|
-
export { attrBinding, controlled, createPrimitive, createState, createStateInjector, createStateProvider, createStateToken, dataBinding, deprecatedSetter, injectInheritedState, listener, onDestroy, styleBinding };
|
|
308
|
+
export { attrBinding, controlled, createPrimitive, createState, createStateInjector, createStateProvider, createStateToken, dataBinding, deprecatedSetter, injectInheritedState, listener, onDestroy, onMount, styleBinding };
|
|
304
309
|
//# sourceMappingURL=ng-primitives-state.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-primitives-state.mjs","sources":["../../../../packages/ng-primitives/state/src/index.ts","../../../../packages/ng-primitives/state/src/ng-primitives-state.ts"],"sourcesContent":["import { coerceElement } from '@angular/cdk/coercion';\nimport {\n afterRenderEffect,\n computed,\n DestroyRef,\n ElementRef,\n FactoryProvider,\n forwardRef,\n inject,\n InjectionToken,\n InjectOptions,\n Injector,\n InputSignal,\n InputSignalWithTransform,\n isSignal,\n linkedSignal,\n NgZone,\n ProviderToken,\n runInInjectionContext,\n signal,\n Signal,\n WritableSignal,\n} from '@angular/core';\nimport { isFunction } from 'ng-primitives/utils';\n\n/**\n * This converts the state object to a writable state object.\n * This means that inputs become signals which are writable.\n */\nexport type State<T> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [K in keyof T]: T[K] extends InputSignalWithTransform<infer U, any>\n ? WritableSignal<U>\n : T[K] extends InputSignal<infer R>\n ? WritableSignal<R>\n : T[K];\n};\n\n/**\n * This is similar to the state object, but we don't expose properties that are not\n * inputs.\n */\nexport type CreatedState<T> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [K in keyof T]: T[K] extends InputSignalWithTransform<infer U, any>\n ? WritableSignal<U>\n : T[K] extends InputSignal<infer R>\n ? WritableSignal<R>\n : never;\n};\n\nexport type InjectedState<T> = Signal<State<T>>;\n\n/**\n * Create a new injection token for the state.\n * @param description The description of the token\n */\nexport function createStateToken<T>(description: string): InjectionToken<T> {\n return new InjectionToken<Signal<State<T>>>(`Ngp${description}StateToken`);\n}\n\nexport interface CreateStateProviderOptions {\n /**\n * Whether we should check for the state in the parent injector.\n */\n inherit?: boolean;\n}\n\n/**\n * Create a new provider for the state. It first tries to inject the state from the parent injector,\n * as this allows for the state to be hoisted to a higher level in the component tree. This can\n * be useful to avoid issues where the injector can't be shared in some cases when ng-content is used.\n * @param token The token for the state\n */\nexport function createStateProvider<T>(\n token: ProviderToken<T>,\n): (options?: CreateStateProviderOptions) => FactoryProvider {\n return ({ inherit }: CreateStateProviderOptions = {}) => ({\n provide: token,\n useFactory: () => {\n if (inherit === false) {\n // if we are not checking the parent, we want to create a new state\n return signal({});\n }\n // if we are checking the parent, we want to check if the state is already defined\n return inject(token, { optional: true, skipSelf: true }) ?? signal({});\n },\n });\n}\n\ntype CreateStateInjectorOptions = {\n /**\n * Whether the state may not be immediately available. This can happen when the child is instantiated before the parent.\n */\n deferred?: boolean;\n};\n\n/**\n * Create a new state injector for the state.\n * @param token The token for the state\n */\nexport function createStateInjector<T>(\n token: ProviderToken<State<T>>,\n options: { deferred: true },\n): <U = T>(injectOptions?: InjectOptions) => Signal<State<U> | undefined>;\nexport function createStateInjector<T>(\n token: ProviderToken<State<T>>,\n options?: CreateStateInjectorOptions,\n): <U = T>(injectOptions?: InjectOptions) => Signal<State<U>>;\nexport function createStateInjector<T>(\n token: ProviderToken<State<T>>,\n options: CreateStateInjectorOptions = {},\n): <U = T>(injectOptions?: InjectOptions) => Signal<State<U> | undefined> {\n return <U = T>(injectOptions: InjectOptions = {}) => {\n const value = inject(token, injectOptions) as Signal<State<U> | undefined> | null;\n\n if (options.deferred) {\n return computed(() =>\n value && Object.keys(value() ?? {}).length === 0 ? undefined : value?.(),\n ) as Signal<State<U> | undefined>;\n }\n\n return (value as Signal<State<U>>) ?? signal(undefined);\n };\n}\n\n/**\n * Convert the original state object into a writable state object.\n * @param token The token for the state\n */\nexport function createState(token: ProviderToken<WritableSignal<State<unknown>>>) {\n return <U>(state: U): CreatedState<U> => {\n const internalState = inject(token);\n\n internalState.update(obj => {\n // Iterating over properties\n for (const key in state) {\n const value = state[key as keyof U];\n\n // We want to make this a controlled input if it is an InputSignal or InputSignalWithTransform\n if (isSignalInput(value)) {\n // @ts-ignore\n obj[key] = createControlledInput(value);\n } else {\n // @ts-ignore\n obj[key] = value;\n }\n }\n\n // Iterating over prototype methods\n const prototype = Object.getPrototypeOf(state);\n\n for (const key of Object.getOwnPropertyNames(prototype)) {\n const descriptor = Object.getOwnPropertyDescriptor(prototype, key);\n\n // if this is a getter or setter, we need to define it on the object\n if (descriptor?.get || descriptor?.set) {\n Object.defineProperty(obj, key, descriptor);\n } else if (isFunction(prototype[key as keyof U])) {\n (obj as Record<string, unknown>)[key] = prototype[key as keyof U].bind(state);\n } else {\n // @ts-ignore\n obj[key] = prototype[key as keyof U];\n }\n }\n\n return { ...obj };\n });\n\n return internalState() as unknown as CreatedState<U>;\n };\n}\n\n// this is a bit hacky, but we need to do it to track whether this is controlled\nfunction createControlledInput(\n property: InputSignal<unknown> | InputSignalWithTransform<unknown, unknown>,\n): WritableSignal<unknown> {\n const value = signal(property());\n let isControlled = false;\n\n const symbol = Object.getOwnPropertySymbols(property).find(s => s.description === 'SIGNAL');\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const inputDefinition = symbol ? (property as any)[symbol] : undefined;\n\n if (!symbol || !inputDefinition || !isFunction(inputDefinition.applyValueToInputSignal)) {\n console.warn(\n 'Angular has changed its internal Input implementation, report this issue to ng-primitives.',\n );\n // fallback to a linked signal which is partially controlled\n return linkedSignal(() => property());\n }\n\n const originalApply = inputDefinition.applyValueToInputSignal.bind(inputDefinition);\n const originalSet = value.set.bind(value);\n const originalUpdate = value.update.bind(value);\n\n inputDefinition.applyValueToInputSignal = (inputSignalNode: unknown, newValue: unknown) => {\n isControlled = true;\n originalSet(newValue);\n originalApply(inputSignalNode, newValue);\n };\n\n value.set = (newValue: unknown) => {\n if (!isControlled) {\n originalSet(newValue);\n }\n };\n\n value.update = (updateFn: (value: unknown) => unknown) => {\n if (!isControlled) {\n originalUpdate(updateFn);\n }\n };\n\n return value;\n}\n\nfunction isSignalInput(\n property: unknown,\n): property is InputSignal<unknown> | InputSignalWithTransform<unknown, unknown> {\n if (!isSignal(property)) {\n return false;\n }\n\n const symbol = Object.getOwnPropertySymbols(property).find(s => s.description === 'SIGNAL');\n\n if (!symbol) {\n return false;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const inputDefinition = symbol ? (property as any)[symbol] : undefined;\n\n if (!inputDefinition) {\n return false;\n }\n\n return 'transformFn' in inputDefinition || 'applyValueToInputSignal' in inputDefinition;\n}\n\nexport interface CreatePrimitiveOptions {\n injector?: Injector;\n elementRef?: ElementRef<HTMLElement>;\n}\n\ntype PrimitiveState<TFactory extends (...args: any[]) => unknown> = TFactory extends (\n props: unknown,\n) => infer R\n ? R\n : TFactory extends (...args: any[]) => infer R\n ? R\n : never;\n\ntype BasePrimitiveInjectionFn<TState> = {\n (): Signal<TState>;\n (options: { hoisted: true }): Signal<TState | null>;\n (options?: { hoisted?: boolean }): Signal<TState | null>;\n};\n\ntype PrimitiveInjectionFn<TFactory extends (...args: any[]) => unknown> = TFactory extends (\n props: unknown,\n) => infer R\n ? {\n (): Signal<R>;\n (options: { hoisted: true }): Signal<R | null>;\n (options?: { hoisted?: boolean }): Signal<R | null>;\n }\n : BasePrimitiveInjectionFn<PrimitiveState<TFactory>>;\n\nexport function createPrimitive<TFactory extends (...args: any[]) => unknown>(\n name: string,\n fn: TFactory,\n options?: CreatePrimitiveOptions,\n): [\n InjectionToken<WritableSignal<PrimitiveState<TFactory>>>,\n TFactory,\n PrimitiveInjectionFn<TFactory>,\n (opts?: { inherit?: boolean }) => FactoryProvider,\n];\nexport function createPrimitive<TFactory extends (...args: any[]) => unknown>(\n name: string,\n fn: TFactory,\n options: CreatePrimitiveOptions = {},\n): [\n InjectionToken<WritableSignal<PrimitiveState<TFactory>>>,\n TFactory,\n PrimitiveInjectionFn<TFactory>,\n (opts?: { inherit?: boolean }) => FactoryProvider,\n] {\n // Create a unique injection token for the primitive's state signal\n const token = new InjectionToken<WritableSignal<PrimitiveState<TFactory>>>(`Primitive: ${name}`);\n\n // Create the state signal within the appropriate injection context\n const factory = ((props: Parameters<TFactory>[0]) => {\n // determine the injector to use\n let injector = options.injector ?? inject(Injector);\n\n // If an ElementRef is provided in options, create a child injector\n if (options.elementRef) {\n injector = Injector.create({\n providers: [{ provide: ElementRef, useValue: options.elementRef }],\n parent: injector,\n });\n }\n\n return runInInjectionContext(injector, () => {\n const state = inject(token, { optional: true });\n const instance = fn(props);\n state?.set(instance as PrimitiveState<TFactory>);\n return instance;\n });\n }) as TFactory;\n\n // create an injection function that provides the state signal\n function injectFn<T = PrimitiveState<TFactory>>(): Signal<T>;\n function injectFn<T = PrimitiveState<TFactory>>(options: { hoisted: true }): Signal<T | null>;\n function injectFn<T = PrimitiveState<TFactory>>(options?: {\n hoisted?: boolean;\n }): Signal<T | null> {\n const hoisted = options?.hoisted ?? false;\n\n if (hoisted) {\n return (inject(token, { optional: true }) ?? signal(null)) as unknown as Signal<T | null>;\n }\n\n return inject(token) as unknown as Signal<T>;\n }\n\n // create a function to provide the state\n const provideFn = (opts?: { inherit?: boolean }): FactoryProvider => {\n const inherit = opts?.inherit ?? true;\n return {\n provide: token,\n useFactory: () => {\n if (inherit === false) {\n return signal(null);\n }\n\n return inject(token, { optional: true, skipSelf: true }) ?? signal(null);\n },\n };\n };\n\n return [token, factory as TFactory, injectFn as PrimitiveInjectionFn<TFactory>, provideFn];\n}\n\nexport function controlled<T>(value: Signal<T>): WritableSignal<T> {\n return linkedSignal(() => value());\n}\n\nfunction setAttribute(\n element: ElementRef<HTMLElement>,\n attr: string,\n value: string | null | undefined,\n): void {\n // if the attribute is \"disabled\" and the value is 'false', we need to remove the attribute\n if (attr === 'disabled' && value === 'false') {\n element.nativeElement.removeAttribute(attr);\n return;\n }\n\n if (value !== null && value !== undefined) {\n element.nativeElement.setAttribute(attr, value);\n } else {\n element.nativeElement.removeAttribute(attr);\n }\n}\n\nexport function attrBinding(\n element: ElementRef<HTMLElement>,\n attr: string,\n value:\n | (() => string | number | boolean | null | undefined)\n | string\n | number\n | boolean\n | null\n | undefined,\n): void {\n afterRenderEffect({\n write: () => {\n const valueResult = typeof value === 'function' ? value() : value;\n\n setAttribute(element, attr, valueResult?.toString() ?? null);\n },\n });\n}\n\nfunction getStyleUnit(style: string): string {\n const parts = style.split('.');\n\n if (parts.length > 1) {\n const unit = parts[parts.length - 1];\n\n switch (unit) {\n case 'px':\n case 'em':\n case 'rem':\n case '%':\n case 'vh':\n case 'vw':\n case 'vmin':\n case 'vmax':\n case 'cm':\n case 'mm':\n case 'in':\n case 'pt':\n case 'pc':\n case 'ex':\n case 'ch':\n return unit;\n default:\n return '';\n }\n }\n\n return '';\n}\n\nexport function styleBinding(\n element: ElementRef<HTMLElement>,\n style: string,\n value: (() => string | number | null) | string | number | null,\n): void {\n afterRenderEffect({\n write: () => {\n const styleValue = typeof value === 'function' ? value() : value;\n // we should look for units in the style name, just like Angular does e.g. width.px\n const styleUnit = getStyleUnit(style);\n const styleName = styleUnit ? style.replace(`.${styleUnit}`, '') : style;\n\n if (styleValue !== null) {\n element.nativeElement.style.setProperty(styleName, styleValue + styleUnit);\n } else {\n element.nativeElement.style.removeProperty(styleName);\n }\n },\n });\n}\n\nexport function dataBinding(\n element: ElementRef<HTMLElement>,\n attr: string,\n value: (() => string | boolean | null) | string | boolean | null,\n): void {\n if (!attr.startsWith('data-')) {\n throw new Error(`dataBinding: attribute \"${attr}\" must start with \"data-\"`);\n }\n\n afterRenderEffect({\n write: () => {\n let valueResult = typeof value === 'function' ? value() : value;\n\n if (valueResult === false) {\n valueResult = null;\n } else if (valueResult === true) {\n valueResult = '';\n } else if (valueResult !== null && typeof valueResult !== 'string') {\n valueResult = String(valueResult);\n }\n\n setAttribute(element, attr, valueResult);\n },\n });\n}\nexport function listener<K extends keyof HTMLElementEventMap>(\n element: HTMLElement | ElementRef<HTMLElement>,\n event: K,\n handler: (event: HTMLElementEventMap[K]) => void,\n options?: { injector?: Injector },\n): void;\nexport function listener(\n element: HTMLElement | ElementRef<HTMLElement>,\n event: string,\n handler: (event: Event) => void,\n options?: { injector?: Injector },\n): void;\nexport function listener<K extends keyof HTMLElementEventMap>(\n element: HTMLElement | ElementRef<HTMLElement>,\n event: K | string,\n handler: (event: HTMLElementEventMap[K] | Event) => void,\n options?: { injector?: Injector },\n): void {\n runInInjectionContext(options?.injector ?? inject(Injector), () => {\n const ngZone = inject(NgZone);\n const destroyRef = inject(DestroyRef);\n const nativeElement = coerceElement(element);\n ngZone.runOutsideAngular(() => nativeElement.addEventListener(event, handler as EventListener));\n destroyRef.onDestroy(() => nativeElement.removeEventListener(event, handler as EventListener));\n });\n}\n\nexport function onDestroy(callback: () => void): void {\n const destroyRef = inject(DestroyRef);\n destroyRef.onDestroy(callback);\n}\n\n/**\n * Previously, with our state approach, we allowed signals to be written directly using their setters.\n * However, with our new approach, we want people to use the appropriate set method instead. This function takes in a writable\n * signal and returns a proxy that warns the user when set is called directly.\n */\nexport function deprecatedSetter<T>(\n signal: WritableSignal<T>,\n methodName: string,\n): WritableSignal<T> {\n return new Proxy(signal, {\n get(target, prop) {\n if (prop === 'set') {\n return (value: T) => {\n console.warn(\n `Deprecation warning: Use ${methodName}() instead of setting the value directly.`,\n );\n target.set(value);\n };\n }\n return target[prop as keyof WritableSignal<T>];\n },\n });\n}\n\n/**\n * A utility function to inject an inherited state from a parent injector. This is useful for cases\n * where a primitive needs to inherit state from a parent primitive, such as in roving focus groups.\n * We could use inject with a forwardRef, but forwardRef returns an any - no thanks...\n */\nexport function injectInheritedState<T>(\n token: () => InjectionToken<T>,\n injectOptions: InjectOptions = {},\n): T | null {\n return (\n inject<T>(\n forwardRef(() => token()),\n { optional: true, skipSelf: true, ...injectOptions },\n ) ?? null\n );\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAqDA;;;AAGG;AACG,SAAU,gBAAgB,CAAI,WAAmB,EAAA;AACrD,IAAA,OAAO,IAAI,cAAc,CAAmB,MAAM,WAAW,CAAA,UAAA,CAAY,CAAC;AAC5E;AASA;;;;;AAKG;AACG,SAAU,mBAAmB,CACjC,KAAuB,EAAA;IAEvB,OAAO,CAAC,EAAE,OAAO,EAAA,GAAiC,EAAE,MAAM;AACxD,QAAA,OAAO,EAAE,KAAK;QACd,UAAU,EAAE,MAAK;AACf,YAAA,IAAI,OAAO,KAAK,KAAK,EAAE;;AAErB,gBAAA,OAAO,MAAM,CAAC,EAAE,CAAC;YACnB;;AAEA,YAAA,OAAO,MAAM,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,IAAI,MAAM,CAAC,EAAE,CAAC;QACxE,CAAC;AACF,KAAA,CAAC;AACJ;SAqBgB,mBAAmB,CACjC,KAA8B,EAC9B,UAAsC,EAAE,EAAA;AAExC,IAAA,OAAO,CAAQ,aAAA,GAA+B,EAAE,KAAI;QAClD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,EAAE,aAAa,CAAwC;AAEjF,QAAA,IAAI,OAAO,CAAC,QAAQ,EAAE;AACpB,YAAA,OAAO,QAAQ,CAAC,MACd,K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AK,EAAE;gBAClB,OAAO,CAAC,KAAQ,KAAI;AAClB,oBAAA,OAAO,CAAC,IAAI,CACV,4BAA4B,UAAU,CAAA,yCAAA,CAA2C,CAClF;AACD,oBAAA,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC;AACnB,gBAAA,CAAC;YACH;AACA,YAAA,OAAO,MAAM,CAAC,IAA+B,CAAC;QAChD,CAAC;AACF,KAAA,CAAC;AACJ;AAEA;;;;AAIG;SACa,oBAAoB,CAClC,KAA8B,EAC9B,gBAA+B,EAAE,EAAA;AAEjC,IAAA,QACE,MAAM,CACJ,UAAU,CAAC,MAAM,KAAK,EAAE,CAAC,EACzB,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,aAAa,EAAE,CACrD,IAAI,IAAI;AAEb;;ACxhBA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ng-primitives-state.mjs","sources":["../../../../packages/ng-primitives/state/src/index.ts","../../../../packages/ng-primitives/state/src/ng-primitives-state.ts"],"sourcesContent":["import { coerceElement } from '@angular/cdk/coercion';\nimport {\n afterRenderEffect,\n computed,\n DestroyRef,\n ElementRef,\n FactoryProvider,\n forwardRef,\n inject,\n InjectionToken,\n InjectOptions,\n Injector,\n InputSignal,\n InputSignalWithTransform,\n isSignal,\n linkedSignal,\n NgZone,\n ProviderToken,\n runInInjectionContext,\n signal,\n Signal,\n WritableSignal,\n} from '@angular/core';\n\n/**\n * This converts the state object to a writable state object.\n * This means that inputs become signals which are writable.\n */\nexport type State<T> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [K in keyof T]: T[K] extends InputSignalWithTransform<infer U, any>\n ? WritableSignal<U>\n : T[K] extends InputSignal<infer R>\n ? WritableSignal<R>\n : T[K];\n};\n\n/**\n * This is similar to the state object, but we don't expose properties that are not\n * inputs.\n */\nexport type CreatedState<T> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [K in keyof T]: T[K] extends InputSignalWithTransform<infer U, any>\n ? WritableSignal<U>\n : T[K] extends InputSignal<infer R>\n ? WritableSignal<R>\n : never;\n};\n\nexport type InjectedState<T> = Signal<State<T>>;\n\n/**\n * Create a new injection token for the state.\n * @param description The description of the token\n */\nexport function createStateToken<T>(description: string): InjectionToken<T> {\n return new InjectionToken<Signal<State<T>>>(`Ngp${description}StateToken`);\n}\n\nexport interface CreateStateProviderOptions {\n /**\n * Whether we should check for the state in the parent injector.\n */\n inherit?: boolean;\n}\n\n/**\n * Create a new provider for the state. It first tries to inject the state from the parent injector,\n * as this allows for the state to be hoisted to a higher level in the component tree. This can\n * be useful to avoid issues where the injector can't be shared in some cases when ng-content is used.\n * @param token The token for the state\n */\nexport function createStateProvider<T>(\n token: ProviderToken<T>,\n): (options?: CreateStateProviderOptions) => FactoryProvider {\n return ({ inherit }: CreateStateProviderOptions = {}) => ({\n provide: token,\n useFactory: () => {\n if (inherit === false) {\n // if we are not checking the parent, we want to create a new state\n return signal({});\n }\n // if we are checking the parent, we want to check if the state is already defined\n return inject(token, { optional: true, skipSelf: true }) ?? signal({});\n },\n });\n}\n\ntype CreateStateInjectorOptions = {\n /**\n * Whether the state may not be immediately available. This can happen when the child is instantiated before the parent.\n */\n deferred?: boolean;\n};\n\n/**\n * Create a new state injector for the state.\n * @param token The token for the state\n */\nexport function createStateInjector<T>(\n token: ProviderToken<State<T>>,\n options: { deferred: true },\n): <U = T>(injectOptions?: InjectOptions) => Signal<State<U> | undefined>;\nexport function createStateInjector<T>(\n token: ProviderToken<State<T>>,\n options?: CreateStateInjectorOptions,\n): <U = T>(injectOptions?: InjectOptions) => Signal<State<U>>;\nexport function createStateInjector<T>(\n token: ProviderToken<State<T>>,\n options: CreateStateInjectorOptions = {},\n): <U = T>(injectOptions?: InjectOptions) => Signal<State<U> | undefined> {\n return <U = T>(injectOptions: InjectOptions = {}) => {\n const value = inject(token, injectOptions) as Signal<State<U> | undefined> | null;\n\n if (options.deferred) {\n return computed(() =>\n value && Object.keys(value() ?? {}).length === 0 ? undefined : value?.(),\n ) as Signal<State<U> | undefined>;\n }\n\n return (value as Signal<State<U>>) ?? signal(undefined);\n };\n}\n\n/**\n * Convert the original state object into a writable state object.\n * @param token The token for the state\n */\nexport function createState(token: ProviderToken<WritableSignal<State<unknown>>>) {\n return <U>(state: U): CreatedState<U> => {\n const internalState = inject(token);\n\n internalState.update(obj => {\n // Iterating over properties\n for (const key in state) {\n const value = state[key as keyof U];\n\n // We want to make this a controlled input if it is an InputSignal or InputSignalWithTransform\n if (isSignalInput(value)) {\n // @ts-ignore\n obj[key] = createControlledInput(value);\n } else {\n // @ts-ignore\n obj[key] = value;\n }\n }\n\n // Iterating over prototype methods\n const prototype = Object.getPrototypeOf(state);\n\n for (const key of Object.getOwnPropertyNames(prototype)) {\n const descriptor = Object.getOwnPropertyDescriptor(prototype, key);\n\n // if this is a getter or setter, we need to define it on the object\n if (descriptor?.get || descriptor?.set) {\n Object.defineProperty(obj, key, descriptor);\n } else if (typeof prototype[key as keyof U] === 'function') {\n (obj as Record<string, unknown>)[key] = prototype[key as keyof U].bind(state);\n } else {\n // @ts-ignore\n obj[key] = prototype[key as keyof U];\n }\n }\n\n return { ...obj };\n });\n\n return internalState() as unknown as CreatedState<U>;\n };\n}\n\n// this is a bit hacky, but we need to do it to track whether this is controlled\nfunction createControlledInput(\n property: InputSignal<unknown> | InputSignalWithTransform<unknown, unknown>,\n): WritableSignal<unknown> {\n const value = signal(property());\n let isControlled = false;\n\n const symbol = Object.getOwnPropertySymbols(property).find(s => s.description === 'SIGNAL');\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const inputDefinition = symbol ? (property as any)[symbol] : undefined;\n\n if (\n !symbol ||\n !inputDefinition ||\n typeof inputDefinition.applyValueToInputSignal !== 'function'\n ) {\n console.warn(\n 'Angular has changed its internal Input implementation, report this issue to ng-primitives.',\n );\n // fallback to a linked signal which is partially controlled\n return linkedSignal(() => property());\n }\n\n const originalApply = inputDefinition.applyValueToInputSignal.bind(inputDefinition);\n const originalSet = value.set.bind(value);\n const originalUpdate = value.update.bind(value);\n\n inputDefinition.applyValueToInputSignal = (inputSignalNode: unknown, newValue: unknown) => {\n isControlled = true;\n originalSet(newValue);\n originalApply(inputSignalNode, newValue);\n };\n\n value.set = (newValue: unknown) => {\n if (!isControlled) {\n originalSet(newValue);\n }\n };\n\n value.update = (updateFn: (value: unknown) => unknown) => {\n if (!isControlled) {\n originalUpdate(updateFn);\n }\n };\n\n return value;\n}\n\nfunction isSignalInput(\n property: unknown,\n): property is InputSignal<unknown> | InputSignalWithTransform<unknown, unknown> {\n if (!isSignal(property)) {\n return false;\n }\n\n const symbol = Object.getOwnPropertySymbols(property).find(s => s.description === 'SIGNAL');\n\n if (!symbol) {\n return false;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const inputDefinition = symbol ? (property as any)[symbol] : undefined;\n\n if (!inputDefinition) {\n return false;\n }\n\n return 'transformFn' in inputDefinition || 'applyValueToInputSignal' in inputDefinition;\n}\n\nexport interface CreatePrimitiveOptions {\n injector?: Injector;\n elementRef?: ElementRef<HTMLElement>;\n}\n\ntype PrimitiveState<TFactory extends (...args: any[]) => unknown> = TFactory extends (\n props: unknown,\n) => infer R\n ? R\n : TFactory extends (...args: any[]) => infer R\n ? R\n : never;\n\ntype BasePrimitiveInjectionFn<TState> = {\n (): Signal<TState>;\n (options: { hoisted: true }): Signal<TState | null>;\n (options?: { hoisted?: boolean }): Signal<TState | null>;\n};\n\ntype PrimitiveInjectionFn<TFactory extends (...args: any[]) => unknown> = TFactory extends (\n props: unknown,\n) => infer R\n ? {\n (): Signal<R>;\n (options: { hoisted: true }): Signal<R | null>;\n (options?: { hoisted?: boolean }): Signal<R | null>;\n }\n : BasePrimitiveInjectionFn<PrimitiveState<TFactory>>;\n\nexport function createPrimitive<TFactory extends (...args: any[]) => unknown>(\n name: string,\n fn: TFactory,\n options?: CreatePrimitiveOptions,\n): [\n InjectionToken<WritableSignal<PrimitiveState<TFactory>>>,\n TFactory,\n PrimitiveInjectionFn<TFactory>,\n (opts?: { inherit?: boolean }) => FactoryProvider,\n];\nexport function createPrimitive<TFactory extends (...args: any[]) => unknown>(\n name: string,\n fn: TFactory,\n options: CreatePrimitiveOptions = {},\n): [\n InjectionToken<WritableSignal<PrimitiveState<TFactory>>>,\n TFactory,\n PrimitiveInjectionFn<TFactory>,\n (opts?: { inherit?: boolean }) => FactoryProvider,\n] {\n // Create a unique injection token for the primitive's state signal\n const token = new InjectionToken<WritableSignal<PrimitiveState<TFactory>>>(`Primitive: ${name}`);\n\n // Create the state signal within the appropriate injection context\n const factory = ((props: Parameters<TFactory>[0]) => {\n // determine the injector to use\n let injector = options.injector ?? inject(Injector);\n\n // If an ElementRef is provided in options, create a child injector\n if (options.elementRef) {\n injector = Injector.create({\n providers: [{ provide: ElementRef, useValue: options.elementRef }],\n parent: injector,\n });\n }\n\n return runInInjectionContext(injector, () => {\n const state = inject(token, { optional: true });\n const instance = fn(props);\n state?.set(instance as PrimitiveState<TFactory>);\n return instance;\n });\n }) as TFactory;\n\n // create an injection function that provides the state signal\n function injectFn<T = PrimitiveState<TFactory>>(): Signal<T>;\n function injectFn<T = PrimitiveState<TFactory>>(options: { hoisted: true }): Signal<T | null>;\n function injectFn<T = PrimitiveState<TFactory>>(options?: {\n hoisted?: boolean;\n }): Signal<T | null> {\n const hoisted = options?.hoisted ?? false;\n\n if (hoisted) {\n return (inject(token, { optional: true }) ?? signal(null)) as unknown as Signal<T | null>;\n }\n\n return inject(token) as unknown as Signal<T>;\n }\n\n // create a function to provide the state\n const provideFn = (opts?: { inherit?: boolean }): FactoryProvider => {\n const inherit = opts?.inherit ?? true;\n return {\n provide: token,\n useFactory: () => {\n if (inherit === false) {\n return signal(null);\n }\n\n return inject(token, { optional: true, skipSelf: true }) ?? signal(null);\n },\n };\n };\n\n return [token, factory as TFactory, injectFn as PrimitiveInjectionFn<TFactory>, provideFn];\n}\n\nexport function controlled<T>(value: Signal<T>): WritableSignal<T> {\n return linkedSignal(() => value());\n}\n\nfunction setAttribute(\n element: ElementRef<HTMLElement>,\n attr: string,\n value: string | null | undefined,\n): void {\n // if the attribute is \"disabled\" and the value is 'false', we need to remove the attribute\n if (attr === 'disabled' && value === 'false') {\n element.nativeElement.removeAttribute(attr);\n return;\n }\n\n if (value !== null && value !== undefined) {\n element.nativeElement.setAttribute(attr, value);\n } else {\n element.nativeElement.removeAttribute(attr);\n }\n}\n\nexport function attrBinding(\n element: ElementRef<HTMLElement>,\n attr: string,\n value:\n | (() => string | number | boolean | null | undefined)\n | string\n | number\n | boolean\n | null\n | undefined,\n): void {\n afterRenderEffect({\n write: () => {\n const valueResult = typeof value === 'function' ? value() : value;\n\n setAttribute(element, attr, valueResult?.toString() ?? null);\n },\n });\n}\n\nfunction getStyleUnit(style: string): string {\n const parts = style.split('.');\n\n if (parts.length > 1) {\n const unit = parts[parts.length - 1];\n\n switch (unit) {\n case 'px':\n case 'em':\n case 'rem':\n case '%':\n case 'vh':\n case 'vw':\n case 'vmin':\n case 'vmax':\n case 'cm':\n case 'mm':\n case 'in':\n case 'pt':\n case 'pc':\n case 'ex':\n case 'ch':\n return unit;\n default:\n return '';\n }\n }\n\n return '';\n}\n\nexport function styleBinding(\n element: ElementRef<HTMLElement>,\n style: string,\n value: (() => string | number | null) | string | number | null,\n): void {\n afterRenderEffect({\n write: () => {\n const styleValue = typeof value === 'function' ? value() : value;\n // we should look for units in the style name, just like Angular does e.g. width.px\n const styleUnit = getStyleUnit(style);\n const styleName = styleUnit ? style.replace(`.${styleUnit}`, '') : style;\n\n if (styleValue !== null) {\n element.nativeElement.style.setProperty(styleName, styleValue + styleUnit);\n } else {\n element.nativeElement.style.removeProperty(styleName);\n }\n },\n });\n}\n\nexport function dataBinding(\n element: ElementRef<HTMLElement>,\n attr: string,\n value: (() => string | boolean | null) | string | boolean | null,\n): void {\n if (!attr.startsWith('data-')) {\n throw new Error(`dataBinding: attribute \"${attr}\" must start with \"data-\"`);\n }\n\n afterRenderEffect({\n write: () => {\n let valueResult = typeof value === 'function' ? value() : value;\n\n if (valueResult === false) {\n valueResult = null;\n } else if (valueResult === true) {\n valueResult = '';\n } else if (valueResult !== null && typeof valueResult !== 'string') {\n valueResult = String(valueResult);\n }\n\n setAttribute(element, attr, valueResult);\n },\n });\n}\nexport function listener<K extends keyof HTMLElementEventMap>(\n element: HTMLElement | ElementRef<HTMLElement>,\n event: K,\n handler: (event: HTMLElementEventMap[K]) => void,\n options?: { injector?: Injector },\n): void;\nexport function listener(\n element: HTMLElement | ElementRef<HTMLElement>,\n event: string,\n handler: (event: Event) => void,\n options?: { injector?: Injector },\n): void;\nexport function listener<K extends keyof HTMLElementEventMap>(\n element: HTMLElement | ElementRef<HTMLElement>,\n event: K | string,\n handler: (event: HTMLElementEventMap[K] | Event) => void,\n options?: { injector?: Injector },\n): void {\n runInInjectionContext(options?.injector ?? inject(Injector), () => {\n const ngZone = inject(NgZone);\n const destroyRef = inject(DestroyRef);\n const nativeElement = coerceElement(element);\n ngZone.runOutsideAngular(() => nativeElement.addEventListener(event, handler as EventListener));\n destroyRef.onDestroy(() => nativeElement.removeEventListener(event, handler as EventListener));\n });\n}\n\nexport function onMount(callback: () => void): void {\n const injector = inject(Injector);\n afterRenderEffect(() => runInInjectionContext(injector, callback), { injector });\n}\n\nexport function onDestroy(callback: () => void): void {\n const destroyRef = inject(DestroyRef);\n destroyRef.onDestroy(callback);\n}\n\n/**\n * Previously, with our state approach, we allowed signals to be written directly using their setters.\n * However, with our new approach, we want people to use the appropriate set method instead. This function takes in a writable\n * signal and returns a proxy that warns the user when set is called directly.\n */\nexport function deprecatedSetter<T>(\n signal: WritableSignal<T>,\n methodName: string,\n): WritableSignal<T> {\n return new Proxy(signal, {\n get(target, prop) {\n if (prop === 'set') {\n return (value: T) => {\n console.warn(\n `Deprecation warning: Use ${methodName}() instead of setting the value directly.`,\n );\n target.set(value);\n };\n }\n return target[prop as keyof WritableSignal<T>];\n },\n });\n}\n\n/**\n * A utility function to inject an inherited state from a parent injector. This is useful for cases\n * where a primitive needs to inherit state from a parent primitive, such as in roving focus groups.\n * We could use inject with a forwardRef, but forwardRef returns an any - no thanks...\n */\nexport function injectInheritedState<T>(\n token: () => InjectionToken<T>,\n injectOptions: InjectOptions = {},\n): T | null {\n return (\n inject<T>(\n forwardRef(() => token()),\n { optional: true, skipSelf: true, ...injectOptions },\n ) ?? null\n );\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;AAoDA;;;AAGG;AACG,SAAU,gBAAgB,CAAI,WAAmB,EAAA;AACrD,IAAA,OAAO,IAAI,cAAc,CAAmB,MAAM,WAAW,CAAA,UAAA,CAAY,CAAC;AAC5E;AASA;;;;;AAKG;AACG,SAAU,mBAAmB,CACjC,KAAuB,EAAA;IAEvB,OAAO,CAAC,EAAE,OAAO,EAAA,GAAiC,EAAE,MAAM;AACxD,QAAA,OAAO,EAAE,KAAK;QACd,UAAU,EAAE,MAAK;AACf,YAAA,IAAI,OAAO,KAAK,KAAK,EAAE;;AAErB,gBAAA,OAAO,MAAM,CAAC,EAAE,CAAC;YACnB;;AAEA,YAAA,OAAO,MAAM,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,IAAI,MAAM,CAAC,EAAE,CAAC;QACxE,CAAC;AACF,KAAA,CAAC;AACJ;SAqBgB,mBAAmB,CACjC,KAA8B,EAC9B,UAAsC,EAAE,EAAA;AAExC,IAAA,OAAO,CAAQ,aAAA,GAA+B,EAAE,KAAI;QAClD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,EAAE,aAAa,CAAwC;AAEjF,QAAA,IAAI,OAAO,CAAC,QAAQ,EAAE;AACpB,YAAA,OAAO,QAAQ,CAAC,MACd,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,MAAM,KAAK,CAAC,GAAG,SAAS,GAAG,KAAK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AAK,CAAC,MAAM,EAAE;QACvB,GAAG,CAAC,MAAM,EAAE,IAAI,EAAA;AACd,YAAA,IAAI,IAAI,KAAK,KAAK,EAAE;gBAClB,OAAO,CAAC,KAAQ,KAAI;AAClB,oBAAA,OAAO,CAAC,IAAI,CACV,4BAA4B,UAAU,CAAA,yCAAA,CAA2C,CAClF;AACD,oBAAA,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC;AACnB,gBAAA,CAAC;YACH;AACA,YAAA,OAAO,MAAM,CAAC,IAA+B,CAAC;QAChD,CAAC;AACF,KAAA,CAAC;AACJ;AAEA;;;;AAIG;SACa,oBAAoB,CAClC,KAA8B,EAC9B,gBAA+B,EAAE,EAAA;AAEjC,IAAA,QACE,MAAM,CACJ,UAAU,CAAC,MAAM,KAAK,EAAE,CAAC,EACzB,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,aAAa,EAAE,CACrD,IAAI,IAAI;AAEb;;AChiBA;;AAEG;;;;"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { NG_VALUE_ACCESSOR, NgControl } from '@angular/forms';
|
|
2
|
-
import { untracked, inject, DestroyRef, signal, effect, afterRenderEffect } from '@angular/core';
|
|
2
|
+
import { untracked, inject, Injector, DestroyRef, signal, effect, afterRenderEffect } from '@angular/core';
|
|
3
|
+
import { onMount } from 'ng-primitives/state';
|
|
3
4
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
4
5
|
import { pipe, NEVER, EMPTY } from 'rxjs';
|
|
5
6
|
import { takeUntil, catchError, defaultIfEmpty } from 'rxjs/operators';
|
|
@@ -64,8 +65,9 @@ function updateStatus(control, status) {
|
|
|
64
65
|
* @internal
|
|
65
66
|
*/
|
|
66
67
|
function controlStatus() {
|
|
67
|
-
const
|
|
68
|
+
const injector = inject(Injector);
|
|
68
69
|
const destroyRef = inject(DestroyRef);
|
|
70
|
+
const control = signal(null, ...(ngDevMode ? [{ debugName: "control" }] : []));
|
|
69
71
|
const status = signal({
|
|
70
72
|
valid: null,
|
|
71
73
|
invalid: null,
|
|
@@ -75,23 +77,30 @@ function controlStatus() {
|
|
|
75
77
|
pending: null,
|
|
76
78
|
disabled: null,
|
|
77
79
|
}, ...(ngDevMode ? [{ debugName: "status" }] : []));
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
onMount(() => {
|
|
81
|
+
control.set(inject(NgControl, { optional: true }));
|
|
82
|
+
if (!control()) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
updateStatus(control(), status);
|
|
86
|
+
// For classic controls, also subscribe to the events observable.
|
|
87
|
+
const underlyingControl = control().control;
|
|
88
|
+
if (underlyingControl?.events) {
|
|
89
|
+
underlyingControl.events
|
|
90
|
+
.pipe(safeTakeUntilDestroyed(destroyRef))
|
|
91
|
+
.subscribe(() => updateStatus(control(), status));
|
|
92
|
+
}
|
|
93
|
+
});
|
|
81
94
|
// Use an effect to reactively track status changes.
|
|
82
95
|
// For signal-forms interop controls, the status properties are signals.
|
|
83
96
|
// For classic controls, this will read the current values and establish
|
|
84
97
|
// no signal dependencies, but we also subscribe to events below.
|
|
85
98
|
effect(() => {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
underlyingControl.events
|
|
92
|
-
.pipe(safeTakeUntilDestroyed(destroyRef))
|
|
93
|
-
.subscribe(() => updateStatus(control, status));
|
|
94
|
-
}
|
|
99
|
+
const c = control();
|
|
100
|
+
if (c) {
|
|
101
|
+
updateStatus(c, status);
|
|
102
|
+
}
|
|
103
|
+
}, { injector });
|
|
95
104
|
return status;
|
|
96
105
|
}
|
|
97
106
|
|