ng-primitives 0.60.0 → 0.62.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-internal.mjs +1 -1
- package/fesm2022/ng-primitives-internal.mjs.map +1 -1
- package/fesm2022/ng-primitives-toast.mjs +405 -160
- package/fesm2022/ng-primitives-toast.mjs.map +1 -1
- package/package.json +1 -1
- package/schematics/ng-generate/templates/toast/toast.__fileSuffix@dasherize__.ts.template +104 -36
- package/toast/config/toast-config.d.ts +36 -7
- package/toast/index.d.ts +2 -1
- package/toast/toast/toast-context.d.ts +3 -0
- package/toast/toast/toast-manager.d.ts +50 -0
- package/toast/toast/toast-options.d.ts +34 -0
- package/toast/toast/toast-timer.d.ts +14 -0
- package/toast/toast/toast.d.ts +60 -37
- package/toast/toast/toast-ref.d.ts +0 -49
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-primitives-toast.mjs","sources":["../../../../packages/ng-primitives/toast/src/config/toast-config.ts","../../../../packages/ng-primitives/toast/src/toast/toast-ref.ts","../../../../packages/ng-primitives/toast/src/toast/toast.ts","../../../../packages/ng-primitives/toast/src/ng-primitives-toast.ts"],"sourcesContent":["import { InjectionToken, Provider, inject } from '@angular/core';\nimport { NgpToastGravity, NgpToastPosition } from '../toast/toast-ref';\n\nexport interface NgpToastConfig {\n /**\n * The duration of each toast.\n */\n duration: number;\n\n /**\n * The gravity of each toast.\n */\n gravity: NgpToastGravity;\n\n /**\n * The position of each toast.\n */\n position: NgpToastPosition;\n\n /**\n * Whether we should stop on hover.\n */\n stopOnHover: boolean;\n\n /**\n * The aria live setting.\n */\n ariaLive: string;\n\n /**\n * The gap between each toast.\n */\n gap: number;\n}\n\nexport const defaultToastConfig: NgpToastConfig = {\n gap: 16,\n duration: 3000,\n gravity: 'top',\n position: 'end',\n stopOnHover: true,\n ariaLive: 'polite',\n};\n\nexport const NgpToastConfigToken = new InjectionToken<NgpToastConfig>('NgpToastConfigToken');\n\n/**\n * Provide the default Toast configuration\n * @param config The Toast configuration\n * @returns The provider\n */\nexport function provideToastConfig(config: Partial<NgpToastConfig>): Provider[] {\n return [\n {\n provide: NgpToastConfigToken,\n useValue: { ...defaultToastConfig, ...config },\n },\n ];\n}\n\n/**\n * Inject the Toast configuration\n * @returns The global Toast configuration\n */\nexport function injectToastConfig(): NgpToastConfig {\n return inject(NgpToastConfigToken, { optional: true }) ?? defaultToastConfig;\n}\n","export type NgpToastPosition = 'start' | 'center' | 'end';\nexport type NgpToastGravity = 'top' | 'bottom';\n\nexport class NgpToastRef {\n /** Store the current timeout */\n private timeoutId: number | null = null;\n\n /** Get the toast height */\n get height(): number {\n return this.toastElement.offsetHeight;\n }\n\n constructor(\n /** Store the toast element */\n private readonly toastElement: HTMLElement,\n /** Store the duration */\n private readonly duration: number,\n /** The position of the toast */\n public readonly position: NgpToastPosition,\n /** The gravity of the toast */\n public readonly gravity: NgpToastGravity,\n /** Whether we should stop on focus */\n private readonly stopOnHover: boolean,\n /** The aria live setting */\n private readonly ariaLive: string,\n private readonly onDismiss: () => void,\n ) {\n this.toastElement.setAttribute('data-toast', 'visible');\n\n this.setPosition(position);\n this.setGravity(gravity);\n this.setAriaLive(ariaLive);\n this.setupTimeouts();\n this.setupListeners();\n }\n\n dismiss(): void {\n // determine if there is a transition on the element\n const transitionDuration = parseFloat(getComputedStyle(this.toastElement).transitionDuration);\n\n // if there is no transition, dismiss immediately\n if (transitionDuration === 0) {\n this.removeElement();\n return;\n }\n\n // wait for the transition to end\n this.toastElement.addEventListener('transitionend', () => this.removeElement());\n\n this.toastElement.setAttribute('data-toast', 'hidden');\n }\n\n private removeElement(): void {\n this.toastElement.parentNode?.removeChild(this.toastElement);\n this.onDismiss();\n }\n\n /** Setup duration timeouts */\n private setupTimeouts(): void {\n // if the duration is 0 skip\n if (this.duration === 0) {\n return;\n }\n\n this.timeoutId = window.setTimeout(() => this.dismiss(), this.duration);\n }\n\n private setupListeners(): void {\n if (!this.stopOnHover) {\n return;\n }\n\n // setup event listeners if we should stop on focus\n this.toastElement.addEventListener('mouseover', () => {\n window.clearTimeout(this.timeoutId!);\n this.timeoutId = null;\n });\n\n this.toastElement.addEventListener('mouseleave', () => this.setupTimeouts());\n }\n\n /** Set the position attribute */\n private setPosition(position: NgpToastPosition): void {\n this.toastElement.setAttribute('data-position', position);\n }\n\n /** Set the gravity attribute */\n private setGravity(gravity: NgpToastGravity): void {\n this.toastElement.setAttribute('data-gravity', gravity);\n }\n\n /** Set the aria live attribute */\n private setAriaLive(ariaLive: string): void {\n this.toastElement.setAttribute('aria-live', ariaLive);\n }\n\n /**\n * @internal\n */\n setInset(property: 'top' | 'bottom', value: string): void {\n this.toastElement.style[property] = value;\n }\n}\n","import { BooleanInput, NumberInput } from '@angular/cdk/coercion';\nimport { DomPortalOutlet, TemplatePortal } from '@angular/cdk/portal';\nimport { DOCUMENT } from '@angular/common';\nimport {\n booleanAttribute,\n Directive,\n inject,\n Injector,\n input,\n numberAttribute,\n TemplateRef,\n ViewContainerRef,\n} from '@angular/core';\nimport { injectToastConfig } from '../config/toast-config';\nimport { NgpToastGravity, NgpToastPosition, NgpToastRef } from './toast-ref';\n\nexport interface NgpToastContext {\n dismiss: () => void;\n}\n\n@Directive({\n selector: '[ngpToast]',\n exportAs: 'ngpToast',\n})\nexport class NgpToast {\n private readonly config = injectToastConfig();\n\n /** Access the ng-template */\n private readonly template = inject<TemplateRef<NgpToastContext>>(TemplateRef);\n\n /** Access the view container */\n private readonly viewContainer = inject(ViewContainerRef);\n\n /** Access the injector */\n private readonly injector = inject(Injector);\n\n /** Access the document */\n private readonly document = inject(DOCUMENT);\n\n /**\n * The duration the toast will display for before it is automatically dismissed in milliseconds.\n * @default 3000\n */\n readonly duration = input<number, NumberInput>(this.config.duration, {\n alias: 'ngpToastDuration',\n transform: numberAttribute,\n });\n\n /**\n * The direction the toast will appear from.\n * @default 'top'\n */\n readonly gravity = input<NgpToastGravity>(this.config.gravity, {\n alias: 'ngpToastGravity',\n });\n\n /**\n * The position the toast will on the horizontal axis.\n * @default 'end'\n */\n readonly position = input<NgpToastPosition>(this.config.position, {\n alias: 'ngpToastPosition',\n });\n\n /**\n * Whether the automatic dismissal of the toast should be paused when the user hovers over it.\n * @default true\n */\n readonly stopOnHover = input<boolean, BooleanInput>(this.config.stopOnHover, {\n alias: 'ngpToastStopOnHover',\n transform: booleanAttribute,\n });\n\n /**\n * Whether the toast should be announced to assistive technologies.\n * @default 'polite'\n */\n readonly ariaLive = input(this.config.ariaLive, {\n alias: 'ngpToastAriaLive',\n });\n\n /** Store the list of toasts */\n private static toasts: NgpToastRef[] = [];\n\n /** Show the toast. */\n show(): void {\n this.createToast();\n this.reposition();\n }\n\n /** Build the toast */\n private createToast(): void {\n const portal = new TemplatePortal<NgpToastContext>(\n this.template,\n this.viewContainer,\n {\n dismiss: () => toastRef.dismiss(),\n },\n this.injector,\n );\n\n const domOutlet = new DomPortalOutlet(\n this.document.body,\n undefined,\n undefined,\n Injector.create({\n parent: this.injector,\n providers: [],\n }),\n );\n\n const viewRef = domOutlet.attach(portal);\n viewRef.detectChanges();\n\n const toastElement = viewRef.rootNodes[0];\n\n const toastRef = new NgpToastRef(\n toastElement,\n this.duration(),\n this.position(),\n this.gravity(),\n this.stopOnHover(),\n this.ariaLive(),\n () => {\n NgpToast.toasts = NgpToast.toasts.filter(t => t !== toastRef);\n this.reposition();\n },\n );\n\n NgpToast.toasts = [...NgpToast.toasts, toastRef];\n }\n\n /** Position the toast on the DOM */\n private reposition(): void {\n const topStartOffsetSize = {\n top: this.config.gap,\n bottom: this.config.gap,\n };\n\n const topEndOffsetSize = {\n top: this.config.gap,\n bottom: this.config.gap,\n };\n\n let position: 'top' | 'bottom';\n\n // update the position of the toasts\n for (const toast of NgpToast.toasts) {\n // Getting the applied gravity\n position = toast.gravity;\n\n const height = toast.height;\n\n if (toast.position === 'start') {\n toast.setInset(position, `${topStartOffsetSize[position]}px`);\n topStartOffsetSize[position] += height + this.config.gap;\n } else {\n toast.setInset(position, `${topEndOffsetSize[position]}px`);\n topEndOffsetSize[position] += height + this.config.gap;\n }\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;AAmCO,MAAM,kBAAkB,GAAmB;AAChD,IAAA,GAAG,EAAE,EAAE;AACP,IAAA,QAAQ,EAAE,IAAI;AACd,IAAA,OAAO,EAAE,KAAK;AACd,IAAA,QAAQ,EAAE,KAAK;AACf,IAAA,WAAW,EAAE,IAAI;AACjB,IAAA,QAAQ,EAAE,QAAQ;CACnB;AAEM,MAAM,mBAAmB,GAAG,IAAI,cAAc,CAAiB,qBAAqB,CAAC;AAE5F;;;;AAIG;AACG,SAAU,kBAAkB,CAAC,MAA+B,EAAA;IAChE,OAAO;AACL,QAAA;AACE,YAAA,OAAO,EAAE,mBAAmB;AAC5B,YAAA,QAAQ,EAAE,EAAE,GAAG,kBAAkB,EAAE,GAAG,MAAM,EAAE;AAC/C,SAAA;KACF;AACH;AAEA;;;AAGG;SACa,iBAAiB,GAAA;AAC/B,IAAA,OAAO,MAAM,CAAC,mBAAmB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,IAAI,kBAAkB;AAC9E;;MC/Da,WAAW,CAAA;;AAKtB,IAAA,IAAI,MAAM,GAAA;AACR,QAAA,OAAO,IAAI,CAAC,YAAY,CAAC,YAAY;IACvC;AAEA,IAAA,WAAA;;IAEmB,YAAyB;;IAEzB,QAAgB;;IAEjB,QAA0B;;IAE1B,OAAwB;;IAEvB,WAAoB;;AAEpB,IAAA,QAAgB,EAChB,SAAqB,EAAA;QAXrB,IAAA,CAAA,YAAY,GAAZ,YAAY;QAEZ,IAAA,CAAA,QAAQ,GAAR,QAAQ;QAET,IAAA,CAAA,QAAQ,GAAR,QAAQ;QAER,IAAA,CAAA,OAAO,GAAP,OAAO;QAEN,IAAA,CAAA,WAAW,GAAX,WAAW;QAEX,IAAA,CAAA,QAAQ,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,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,QAAA,EAAA,CAAA,UAAA,CAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;;4FAAR,QAAQ,EAAA,UAAA,EAAA,CAAA;kBAJpB,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,YAAY;AACtB,oBAAA,QAAQ,EAAE,UAAU;AACrB,iBAAA;;;ACvBD;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ng-primitives-toast.mjs","sources":["../../../../packages/ng-primitives/toast/src/config/toast-config.ts","../../../../packages/ng-primitives/toast/src/toast/toast-context.ts","../../../../packages/ng-primitives/toast/src/toast/toast-options.ts","../../../../packages/ng-primitives/toast/src/toast/toast-manager.ts","../../../../packages/ng-primitives/toast/src/toast/toast-timer.ts","../../../../packages/ng-primitives/toast/src/toast/toast.ts","../../../../packages/ng-primitives/toast/src/ng-primitives-toast.ts"],"sourcesContent":["import { InjectionToken, Provider, inject } from '@angular/core';\nimport { NgpToastSwipeDirection } from '../toast/toast';\n\nexport interface NgpToastConfig {\n /**\n * The duration of each toast.\n */\n duration: number;\n\n /**\n * The width of each toast in pixels.\n */\n width: number;\n\n /**\n * The offset from the top of the viewport in pixels.\n */\n offsetTop: number;\n\n /**\n * The offset from the bottom of the viewport in pixels.\n */\n offsetBottom: number;\n\n /**\n * The offset from the left of the viewport in pixels.\n */\n offsetLeft: number;\n\n /**\n * The offset from the right of the viewport in pixels.\n */\n offsetRight: number;\n\n /**\n * Whether a toast can be dismissed by swiping.\n */\n dismissible: boolean;\n\n /**\n * The amount a toast must be swiped before it is considered dismissed.\n */\n swipeThreshold: number;\n\n /**\n * The default swipe directions supported by the toast.\n */\n swipeDirections: NgpToastSwipeDirection[];\n\n /**\n * The maximum number of toasts that can be displayed at once.\n */\n maxToasts: number;\n\n /**\n * The aria live setting.\n */\n ariaLive: string;\n\n /**\n * The gap between each toast.\n */\n gap: number;\n\n /**\n * The z-index of the toast container.\n * This is used to ensure that the toast container is always on top of other elements.\n */\n zIndex: number;\n}\n\nexport const defaultToastConfig: NgpToastConfig = {\n gap: 14,\n duration: 3000,\n width: 360,\n offsetTop: 24,\n offsetBottom: 24,\n offsetLeft: 24,\n offsetRight: 24,\n swipeThreshold: 45,\n swipeDirections: ['left', 'right', 'top', 'bottom'],\n dismissible: true,\n maxToasts: 3,\n zIndex: 9999999,\n ariaLive: 'polite',\n};\n\nexport const NgpToastConfigToken = new InjectionToken<NgpToastConfig>('NgpToastConfigToken');\n\n/**\n * Provide the default Toast configuration\n * @param config The Toast configuration\n * @returns The provider\n */\nexport function provideToastConfig(config: Partial<NgpToastConfig>): Provider[] {\n return [\n {\n provide: NgpToastConfigToken,\n useValue: { ...defaultToastConfig, ...config },\n },\n ];\n}\n\n/**\n * Inject the Toast configuration\n * @returns The global Toast configuration\n */\nexport function injectToastConfig(): NgpToastConfig {\n return inject(NgpToastConfigToken, { optional: true }) ?? defaultToastConfig;\n}\n","import { inject, InjectionToken, ValueProvider } from '@angular/core';\n\nconst NgpToastContext = new InjectionToken<unknown>('NgpToastContext');\n\nexport function provideToastContext<T>(context: T): ValueProvider {\n return { provide: NgpToastContext, useValue: context };\n}\n\nexport function injectToastContext<T>(): T {\n return inject(NgpToastContext) as T;\n}\n","import { inject, InjectionToken, Signal, ValueProvider } from '@angular/core';\nimport type { NgpToast, NgpToastSwipeDirection } from './toast';\n\nconst NgpToastOptions = new InjectionToken<NgpToastOptions>('NgpToastOptions');\n\nexport function provideToastOptions(context: NgpToastOptions): ValueProvider {\n return { provide: NgpToastOptions, useValue: context };\n}\n\nexport function injectToastOptions(): NgpToastOptions {\n return inject(NgpToastOptions);\n}\n\nexport interface NgpToastOptions {\n /**\n * The position of the toast.\n */\n placement:\n | 'top-start'\n | 'top-end'\n | 'bottom-start'\n | 'bottom-end'\n | 'top-center'\n | 'bottom-center';\n /**\n * The duration of the toast in milliseconds.\n */\n duration: number;\n\n /**\n * A function to register the toast instance with the manager.\n * @internal\n */\n register: (toast: NgpToast) => void;\n\n /**\n * Whether the toast region is expanded.\n * @internal\n */\n expanded: Signal<boolean>;\n\n /**\n * Whether the toast supports swipe dismiss.\n * @internal\n */\n dismissible: boolean;\n\n /**\n * The swipe directions supported by the toast.\n * @internal\n */\n swipeDirections: NgpToastSwipeDirection[];\n}\n","import {\n ApplicationRef,\n computed,\n inject,\n Injectable,\n Injector,\n RendererFactory2,\n signal,\n TemplateRef,\n Type,\n ViewContainerRef,\n} from '@angular/core';\nimport { createPortal, NgpPortal } from 'ng-primitives/portal';\nimport { injectToastConfig } from '../config/toast-config';\nimport { NgpToast, NgpToastSwipeDirection } from './toast';\nimport { provideToastContext } from './toast-context';\nimport { provideToastOptions } from './toast-options';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class NgpToastManager {\n private readonly config = injectToastConfig();\n private readonly applicationRef = inject(ApplicationRef);\n private readonly rendererFactory = inject(RendererFactory2);\n private readonly renderer = this.rendererFactory.createRenderer(null, null);\n private readonly injector = inject(Injector);\n // Map to store containers by placement\n private readonly containers = new Map<string, HTMLElement>();\n\n readonly toasts = signal<NgpToastRecord[]>([]);\n\n /** Signal that tracks which placements are expanded */\n private readonly expanded = signal<NgpToastPlacement[]>([]);\n\n /** Show a toast notification */\n show(toast: TemplateRef<void> | Type<unknown>, options: NgpToastOptions = {}): NgpToastRef {\n // services can't access the view container directly, so this is a workaround\n const viewContainerRef = this.applicationRef.components[0].injector.get(ViewContainerRef);\n\n let instance: NgpToast | null = null;\n const placement = options.placement ?? 'top-end';\n const container = this.getOrCreateContainer(placement);\n\n const portal = createPortal(\n toast,\n viewContainerRef,\n Injector.create({\n parent: this.injector,\n providers: [\n provideToastContext(options.context),\n provideToastOptions({\n placement,\n duration: options.duration ?? 5000,\n register: (toast: NgpToast) => (instance = toast),\n expanded: computed(() => this.expanded().includes(placement)),\n dismissible: options.dismissible ?? this.config.dismissible,\n swipeDirections: options.swipeDirections ?? this.config.swipeDirections,\n }),\n ],\n }),\n {\n // Hide the toast when the dismiss method is called\n dismiss: () => this.dismiss(instance!),\n context: options.context,\n },\n );\n\n portal.attach(container);\n\n // Add the toast to the list of toasts\n if (!instance) {\n throw new Error('A toast must have the NgpToast directive applied.');\n }\n\n this.toasts.update(toasts => [{ instance: instance!, portal }, ...toasts]);\n\n return {\n dismiss: () => this.dismiss(instance!),\n };\n }\n\n /** Hide a toast notification */\n async dismiss(toast: NgpToast): Promise<void> {\n const ref = this.toasts().find(t => t.instance === toast);\n\n if (ref) {\n // Detach the portal from the container\n await ref.portal.detach();\n\n // Remove the toast from the list of toasts\n this.toasts.update(toasts => toasts.filter(t => t !== ref));\n\n // if there are no more toasts, ensure the container is no longer considered expanded\n if (this.toasts().length === 0) {\n this.expanded.update(expanded => expanded.filter(p => p !== toast.context.placement));\n }\n }\n }\n\n /**\n * Lazily create or get a container for a given placement.\n */\n private getOrCreateContainer(placement: string): HTMLElement {\n if (this.containers.has(placement)) {\n return this.containers.get(placement)!;\n }\n const container = this.createContainer(placement);\n this.containers.set(placement, container);\n return container;\n }\n\n /**\n * Create a section in which toasts will be rendered for a specific placement.\n */\n private createContainer(placement: string): HTMLElement {\n const container = this.renderer.createElement('section') as HTMLElement;\n this.renderer.setAttribute(container, 'aria-live', this.config.ariaLive);\n this.renderer.setAttribute(container, 'aria-atomic', 'false');\n this.renderer.setAttribute(container, 'tabindex', '-1');\n this.renderer.setAttribute(container, 'data-ngp-toast-container', placement);\n\n container.style.setProperty('position', 'fixed');\n container.style.setProperty('z-index', `${this.config.zIndex}`);\n container.style.setProperty('width', `${this.config.width}px`);\n\n container.style.setProperty('--ngp-toast-offset-top', `${this.config.offsetTop}px`);\n container.style.setProperty('--ngp-toast-offset-bottom', `${this.config.offsetBottom}px`);\n container.style.setProperty('--ngp-toast-offset-left', `${this.config.offsetLeft}px`);\n container.style.setProperty('--ngp-toast-offset-right', `${this.config.offsetRight}px`);\n container.style.setProperty('--ngp-toast-gap', `${this.config.gap}px`);\n container.style.setProperty('--ngp-toast-width', `${this.config.width}px`);\n\n // mark the container as expanded\n this.renderer.listen(container, 'mouseenter', () =>\n this.expanded.update(expanded => [...expanded, placement as NgpToastPlacement]),\n );\n\n this.renderer.listen(container, 'mouseleave', () => {\n this.expanded.update(expanded =>\n expanded.filter(p => p !== (placement as NgpToastPlacement)),\n );\n });\n\n // Set placement styles\n switch (placement) {\n case 'top-start':\n container.style.setProperty('top', `${this.config.offsetTop}px`);\n container.style.setProperty('left', `${this.config.offsetLeft}px`);\n break;\n case 'top-center':\n container.style.setProperty('top', '0');\n container.style.setProperty('left', '50%');\n container.style.setProperty('transform', 'translateX(-50%)');\n break;\n case 'top-end':\n container.style.setProperty('top', `${this.config.offsetTop}px`);\n container.style.setProperty('right', `${this.config.offsetRight}px`);\n break;\n case 'bottom-start':\n container.style.setProperty('bottom', `${this.config.offsetBottom}px`);\n container.style.setProperty('left', `${this.config.offsetLeft}px`);\n break;\n case 'bottom-center':\n container.style.setProperty('bottom', '0');\n container.style.setProperty('left', '50%');\n container.style.setProperty('transform', 'translateX(-50%)');\n break;\n case 'bottom-end':\n container.style.setProperty('bottom', `${this.config.offsetBottom}px`);\n container.style.setProperty('right', `${this.config.offsetRight}px`);\n break;\n default:\n throw new Error(`Unknown toast placement: ${placement}`);\n }\n\n this.renderer.appendChild(document.body, container);\n return container;\n }\n}\n\nexport type NgpToastPlacement =\n | 'top-start'\n | 'top-end'\n | 'top-center'\n | 'bottom-start'\n | 'bottom-end'\n | 'bottom-center';\n\nexport interface NgpToastOptions<T = unknown> {\n /** The position of the toast */\n placement?: NgpToastPlacement;\n\n /** The duration of the toast in milliseconds */\n duration?: number;\n\n /** Whether the toast is dismissible */\n dismissible?: boolean;\n\n /** The swipe directions supported by the toast */\n swipeDirections?: NgpToastSwipeDirection[];\n\n /** The context to make available to the toast */\n context?: T;\n}\n\ninterface NgpToastRecord {\n instance: NgpToast;\n portal: NgpPortal;\n}\n\ninterface NgpToastRef {\n dismiss(): Promise<void>;\n}\n","class NgpToastTimer {\n private startTime: number | null = null;\n private remaining: number;\n private timeoutId: ReturnType<typeof setTimeout> | null = null;\n private isRunning = false;\n\n constructor(\n private duration: number,\n private callback: () => void,\n ) {\n this.remaining = duration;\n }\n\n start(): void {\n if (this.isRunning) return;\n\n this.isRunning = true;\n this.startTime = Date.now();\n\n this.timeoutId = setTimeout(() => {\n this.isRunning = false;\n this.callback();\n }, this.remaining);\n }\n\n pause(): void {\n if (!this.isRunning || this.startTime === null) return;\n\n this.isRunning = false;\n clearTimeout(this.timeoutId!);\n\n const elapsed = Date.now() - this.startTime;\n this.remaining -= elapsed;\n this.startTime = null;\n this.timeoutId = null;\n }\n\n stop(): void {\n this.isRunning = false;\n clearTimeout(this.timeoutId!);\n this.timeoutId = null;\n this.startTime = null;\n this.remaining = this.duration;\n }\n}\n\nexport function toastTimer(duration: number, callback: () => void): NgpToastTimer {\n return new NgpToastTimer(duration, callback);\n}\n","import { InteractivityChecker } from '@angular/cdk/a11y';\nimport {\n afterNextRender,\n computed,\n Directive,\n HostListener,\n inject,\n Injector,\n signal,\n} from '@angular/core';\nimport { explicitEffect } from 'ng-primitives/internal';\nimport { injectDimensions } from 'ng-primitives/utils';\nimport { injectToastConfig } from '../config/toast-config';\nimport { NgpToastManager } from './toast-manager';\nimport { injectToastOptions } from './toast-options';\nimport { toastTimer } from './toast-timer';\n\n@Directive({\n selector: '[ngpToast]',\n exportAs: 'ngpToast',\n host: {\n '[attr.data-position-x]': 'x',\n '[attr.data-position-y]': 'y',\n '[attr.data-visible]': 'visible()',\n '[attr.data-front]': 'index() === 0',\n '[attr.data-swiping]': 'swiping()',\n '[attr.data-swipe-direction]': 'swipeOutDirection()',\n '[attr.data-expanded]': 'context.expanded()',\n '[style.--ngp-toast-gap.px]': 'config.gap',\n '[style.--ngp-toast-z-index]': 'zIndex()',\n '[style.--ngp-toasts-before]': 'index()',\n '[style.--ngp-toast-index]': 'index() + 1',\n '[style.--ngp-toast-width.px]': 'config.width',\n '[style.--ngp-toast-height.px]': 'dimensions().height',\n '[style.--ngp-toast-offset.px]': 'offset()',\n '[style.--ngp-toast-front-height.px]': 'frontToastHeight()',\n '[style.--ngp-toast-swipe-amount-x.px]': 'swipeAmount().x',\n '[style.--ngp-toast-swipe-amount-y.px]': 'swipeAmount().y',\n '[style.--ngp-toast-swipe-x]': 'swipeAmount().x',\n '[style.--ngp-toast-swipe-y]': 'swipeAmount().y',\n },\n})\nexport class NgpToast {\n private readonly manager = inject(NgpToastManager);\n private readonly injector = inject(Injector);\n protected readonly config = injectToastConfig();\n /** @internal */\n readonly context = injectToastOptions();\n private readonly interactivityChecker = inject(InteractivityChecker);\n private readonly isInteracting = signal(false);\n\n private pointerStartRef: { x: number; y: number } | null = null;\n private dragStartTime: Date | null = null;\n protected readonly swiping = signal(false);\n protected readonly swipeDirection = signal<'x' | 'y' | null>(null);\n protected readonly swipeAmount = signal({ x: 0, y: 0 });\n\n protected readonly swipeOutDirection = computed(() => {\n const direction = this.swipeDirection();\n if (direction === 'x') {\n return this.swipeAmount().x > 0 ? 'right' : 'left';\n } else if (direction === 'y') {\n return this.swipeAmount().y > 0 ? 'bottom' : 'top';\n }\n return null;\n });\n\n /**\n * Get all toasts that are currently being displayed in the same position.\n */\n private readonly toasts = computed(() =>\n this.manager\n .toasts()\n .filter(toast => toast.instance.context.placement === this.context.placement),\n );\n\n /**\n * The number of toasts that are currently being displayed before this toast.\n */\n protected readonly index = computed(() => {\n return this.toasts().findIndex(toast => toast.instance === this);\n });\n\n /**\n * Determine the position of the toast in the list of toasts.\n * This is the combination of the heights of all the toasts before this one, plus the gap between them.\n */\n protected readonly offset = computed(() => {\n const gap = this.config.gap;\n\n return this.toasts()\n .slice(0, this.index())\n .reduce((acc, toast) => acc + toast.instance.dimensions().height + gap, 0);\n });\n\n /**\n * Determine if this toast is visible.\n * Visible considers the maximum number of toasts that can be displayed at once, and the last x toasts that are currently being displayed.\n */\n protected readonly visible = computed(() => {\n const maxToasts = this.config.maxToasts;\n // determine if this toast is within the maximum number of toasts that can be displayed\n return this.index() < maxToasts || this.toasts().length <= maxToasts;\n });\n\n /**\n * Determine the height of the front toast.\n * This is used to determine the height of the toast when it is not expanded.\n */\n protected readonly frontToastHeight = computed(() => {\n // get the first toast in the list with height - as when a new toast is added, it may not initially have dimensions\n return (\n this.toasts()\n .find(toast => toast.instance.dimensions().height)\n ?.instance.dimensions().height || 0\n );\n });\n\n /**\n * Determine the z-index of the toast. This is the inverse of the index.\n * The first toast will have the highest z-index, and the last toast will have the lowest z-index.\n * This is used to ensure that the first toast is always on top of the others.\n */\n protected readonly zIndex = computed(() => this.toasts().length - this.index());\n\n /**\n * The height of the toast in pixels.\n */\n protected readonly dimensions = injectDimensions();\n\n /**\n * The x position of the toast.\n */\n readonly x = this.context.placement.split('-')[1] || 'end';\n\n /**\n * The y position of the toast.\n */\n readonly y = this.context.placement.split('-')[0] || 'top';\n\n /**\n * The toast timer instance.\n */\n private readonly timer = toastTimer(this.config.duration, () => this.manager.dismiss(this));\n\n constructor() {\n this.context.register(this);\n\n // Start the timer when the toast is created\n this.timer.start();\n\n // Pause the timer when the toast is expanded or when the user is interacting with it\n explicitEffect([this.context.expanded, this.isInteracting], ([expanded, interacting]) => {\n // If the toast is expanded, or if the user is interacting with it, reset the timer\n if (expanded || interacting) {\n this.timer.pause();\n } else {\n this.timer.start();\n }\n });\n }\n\n @HostListener('pointerdown', ['$event'])\n protected onPointerDown(event: PointerEvent): void {\n // right click should not trigger swipe and we check if the toast is dismissible\n if (event.button === 2 || !this.context.dismissible) {\n return;\n }\n\n this.isInteracting.set(true);\n\n // we need to check if the pointer is on an interactive element, if so, we should not start swiping\n if (this.interactivityChecker.isFocusable(event.target as HTMLElement)) {\n return;\n }\n\n this.dragStartTime = new Date();\n // Ensure we maintain correct pointer capture even when going outside of the toast (e.g. when swiping)\n (event.target as HTMLElement).setPointerCapture(event.pointerId);\n this.swiping.set(true);\n this.pointerStartRef = { x: event.clientX, y: event.clientY };\n }\n\n @HostListener('pointermove', ['$event'])\n protected onPointerMove(event: PointerEvent): void {\n if (!this.pointerStartRef || !this.context.dismissible) {\n return;\n }\n\n const isHighlighted = window.getSelection()?.toString().length ?? 0 > 0;\n\n if (isHighlighted) {\n return;\n }\n\n const yDelta = event.clientY - this.pointerStartRef.y;\n const xDelta = event.clientX - this.pointerStartRef.x;\n\n const swipeDirections = this.context.swipeDirections;\n\n // Determine swipe direction if not already locked\n if (!this.swipeDirection() && (Math.abs(xDelta) > 1 || Math.abs(yDelta) > 1)) {\n this.swipeDirection.set(Math.abs(xDelta) > Math.abs(yDelta) ? 'x' : 'y');\n }\n\n const swipeAmount = { x: 0, y: 0 };\n\n const getDampening = (delta: number) => {\n const factor = Math.abs(delta) / 20;\n\n return 1 / (1.5 + factor);\n };\n\n // Only apply swipe in the locked direction\n if (this.swipeDirection() === 'y') {\n // Handle vertical swipes\n if (swipeDirections.includes('top') || swipeDirections.includes('bottom')) {\n if (\n (swipeDirections.includes('top') && yDelta < 0) ||\n (swipeDirections.includes('bottom') && yDelta > 0)\n ) {\n swipeAmount.y = yDelta;\n } else {\n // Smoothly transition to dampened movement\n const dampenedDelta = yDelta * getDampening(yDelta);\n // Ensure we don't jump when transitioning to dampened movement\n swipeAmount.y = Math.abs(dampenedDelta) < Math.abs(yDelta) ? dampenedDelta : yDelta;\n }\n }\n } else if (this.swipeDirection() === 'x') {\n // Handle horizontal swipes\n if (swipeDirections.includes('left') || swipeDirections.includes('right')) {\n if (\n (swipeDirections.includes('left') && xDelta < 0) ||\n (swipeDirections.includes('right') && xDelta > 0)\n ) {\n swipeAmount.x = xDelta;\n } else {\n // Smoothly transition to dampened movement\n const dampenedDelta = xDelta * getDampening(xDelta);\n // Ensure we don't jump when transitioning to dampened movement\n swipeAmount.x = Math.abs(dampenedDelta) < Math.abs(xDelta) ? dampenedDelta : xDelta;\n }\n }\n }\n\n this.swipeAmount.set({ x: swipeAmount.x, y: swipeAmount.y });\n\n if (Math.abs(swipeAmount.x) > 0 || Math.abs(swipeAmount.y) > 0) {\n this.swiping.set(true);\n }\n }\n\n @HostListener('pointerup')\n protected onPointerUp(): void {\n this.isInteracting.set(false);\n\n if (\n !this.config.dismissible ||\n !this.pointerStartRef ||\n !this.swiping() ||\n !this.dragStartTime\n ) {\n return;\n }\n\n this.pointerStartRef = null;\n\n const swipeAmountX = this.swipeAmount().x;\n const swipeAmountY = this.swipeAmount().y;\n const timeTaken = new Date().getTime() - this.dragStartTime.getTime();\n\n const swipeAmount = this.swipeDirection() === 'x' ? swipeAmountX : swipeAmountY;\n const velocity = Math.abs(swipeAmount) / timeTaken;\n\n if (Math.abs(swipeAmount) >= this.config.swipeThreshold || velocity > 0.11) {\n afterNextRender({ write: () => this.manager.dismiss(this) }, { injector: this.injector });\n return;\n } else {\n this.swipeAmount.set({ x: 0, y: 0 });\n }\n\n // Reset swipe state\n this.swipeDirection.set(null);\n this.swiping.set(false);\n }\n}\n\nexport type NgpToastSwipeDirection = 'top' | 'right' | 'bottom' | 'left';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAuEO,MAAM,kBAAkB,GAAmB;AAChD,IAAA,GAAG,EAAE,EAAE;AACP,IAAA,QAAQ,EAAE,IAAI;AACd,IAAA,KAAK,EAAE,GAAG;AACV,IAAA,SAAS,EAAE,EAAE;AACb,IAAA,YAAY,EAAE,EAAE;AAChB,IAAA,UAAU,EAAE,EAAE;AACd,IAAA,WAAW,EAAE,EAAE;AACf,IAAA,cAAc,EAAE,EAAE;IAClB,eAAe,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC;AACnD,IAAA,WAAW,EAAE,IAAI;AACjB,IAAA,SAAS,EAAE,CAAC;AACZ,IAAA,MAAM,EAAE,OAAO;AACf,IAAA,QAAQ,EAAE,QAAQ;CACnB;AAEM,MAAM,mBAAmB,GAAG,IAAI,cAAc,CAAiB,qBAA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AAA,CAAA;AACT,oBAAA,QAAQ,EAAE,YAAY;AACtB,oBAAA,QAAQ,EAAE,UAAU;AACpB,oBAAA,IAAI,EAAE;AACJ,wBAAA,wBAAwB,EAAE,GAAG;AAC7B,wBAAA,wBAAwB,EAAE,GAAG;AAC7B,wBAAA,qBAAqB,EAAE,WAAW;AAClC,wBAAA,mBAAmB,EAAE,eAAe;AACpC,wBAAA,qBAAqB,EAAE,WAAW;AAClC,wBAAA,6BAA6B,EAAE,qBAAqB;AACpD,wBAAA,sBAAsB,EAAE,oBAAoB;AAC5C,wBAAA,4BAA4B,EAAE,YAAY;AAC1C,wBAAA,6BAA6B,EAAE,UAAU;AACzC,wBAAA,6BAA6B,EAAE,SAAS;AACxC,wBAAA,2BAA2B,EAAE,aAAa;AAC1C,wBAAA,8BAA8B,EAAE,cAAc;AAC9C,wBAAA,+BAA+B,EAAE,qBAAqB;AACtD,wBAAA,+BAA+B,EAAE,UAAU;AAC3C,wBAAA,qCAAqC,EAAE,oBAAoB;AAC3D,wBAAA,uCAAuC,EAAE,iBAAiB;AAC1D,wBAAA,uCAAuC,EAAE,iBAAiB;AAC1D,wBAAA,6BAA6B,EAAE,iBAAiB;AAChD,wBAAA,6BAA6B,EAAE,iBAAiB;AACjD,qBAAA;AACF,iBAAA;wDA0HW,aAAa,EAAA,CAAA;sBADtB,YAAY;uBAAC,aAAa,EAAE,CAAC,QAAQ,CAAC;gBAsB7B,aAAa,EAAA,CAAA;sBADtB,YAAY;uBAAC,aAAa,EAAE,CAAC,QAAQ,CAAC;gBAuE7B,WAAW,EAAA,CAAA;sBADpB,YAAY;uBAAC,WAAW;;;AC7P3B;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "ng-primitives",
|
|
3
3
|
"description": "Angular Primitives is a low-level headless UI component library with a focus on accessibility, customization, and developer experience. ",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.62.0",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"angular",
|
|
8
8
|
"primitives",
|
|
@@ -1,28 +1,30 @@
|
|
|
1
|
-
import { Component,
|
|
1
|
+
import { Component, inject } from '@angular/core';
|
|
2
2
|
import { NgpButton } from 'ng-primitives/button';
|
|
3
|
-
import { NgpToast } from 'ng-primitives/toast';
|
|
3
|
+
import { injectToastContext, NgpToast, NgpToastManager } from 'ng-primitives/toast';
|
|
4
4
|
|
|
5
5
|
@Component({
|
|
6
6
|
selector: '<%= prefix %>-toast',
|
|
7
|
-
imports: [NgpButton
|
|
7
|
+
imports: [NgpButton],
|
|
8
|
+
hostDirectives: [NgpToast],
|
|
8
9
|
template: `
|
|
9
|
-
<
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
<p class="toast-description">{{ description() }}</p>
|
|
13
|
-
<button class="toast-dismiss" (click)="dismiss()" ngpButton>Dismiss</button>
|
|
14
|
-
</div>
|
|
15
|
-
</ng-template>
|
|
10
|
+
<p class="toast-title">{{ context.header }}</p>
|
|
11
|
+
<p class="toast-description">{{ context.description }}</p>
|
|
12
|
+
<button class="toast-dismiss" (click)="dismiss()" ngpButton>Dismiss</button>
|
|
16
13
|
`,
|
|
17
14
|
styles: `
|
|
18
15
|
/* These styles rely on CSS variables that can be imported from ng-primitives/example-theme/index.css in your global styles */
|
|
19
16
|
|
|
20
17
|
:host {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
position: absolute;
|
|
19
|
+
touch-action: none;
|
|
20
|
+
transition:
|
|
21
|
+
transform 0.4s,
|
|
22
|
+
opacity 0.4s,
|
|
23
|
+
height 0.4s,
|
|
24
|
+
box-shadow 0.2s;
|
|
25
|
+
box-sizing: border-box;
|
|
26
|
+
align-items: center;
|
|
27
|
+
gap: 6px;
|
|
26
28
|
display: inline-grid;
|
|
27
29
|
background: var(--ngp-background);
|
|
28
30
|
box-shadow: var(--ngp-shadow);
|
|
@@ -31,11 +33,14 @@ import { NgpToast } from 'ng-primitives/toast';
|
|
|
31
33
|
opacity: 0;
|
|
32
34
|
transition: all 0.4s cubic-bezier(0.215, 0.61, 0.355, 1);
|
|
33
35
|
border-radius: 8px;
|
|
34
|
-
z-index:
|
|
36
|
+
z-index: var(--ngp-toast-z-index);
|
|
35
37
|
grid-template-columns: 1fr auto;
|
|
36
38
|
grid-template-rows: auto auto;
|
|
37
39
|
column-gap: 12px;
|
|
38
40
|
align-items: center;
|
|
41
|
+
width: var(--ngp-toast-width);
|
|
42
|
+
height: fit-content;
|
|
43
|
+
transform: var(--y);
|
|
39
44
|
}
|
|
40
45
|
|
|
41
46
|
.toast-title {
|
|
@@ -46,6 +51,7 @@ import { NgpToast } from 'ng-primitives/toast';
|
|
|
46
51
|
grid-column: 1 / 2;
|
|
47
52
|
grid-row: 1;
|
|
48
53
|
line-height: 16px;
|
|
54
|
+
user-select: none;
|
|
49
55
|
}
|
|
50
56
|
|
|
51
57
|
.toast-description {
|
|
@@ -55,6 +61,7 @@ import { NgpToast } from 'ng-primitives/toast';
|
|
|
55
61
|
grid-column: 1 / 2;
|
|
56
62
|
grid-row: 2;
|
|
57
63
|
line-height: 16px;
|
|
64
|
+
user-select: none;
|
|
58
65
|
}
|
|
59
66
|
|
|
60
67
|
.toast-dismiss {
|
|
@@ -71,41 +78,102 @@ import { NgpToast } from 'ng-primitives/toast';
|
|
|
71
78
|
max-height: 27px;
|
|
72
79
|
}
|
|
73
80
|
|
|
74
|
-
|
|
75
|
-
|
|
81
|
+
:host[data-position-x='end'] {
|
|
82
|
+
right: 0;
|
|
76
83
|
}
|
|
77
84
|
|
|
78
|
-
|
|
79
|
-
|
|
85
|
+
:host[data-position-x='start'] {
|
|
86
|
+
left: 0;
|
|
80
87
|
}
|
|
81
88
|
|
|
82
|
-
|
|
83
|
-
|
|
89
|
+
:host[data-position-y='top'] {
|
|
90
|
+
top: 0;
|
|
91
|
+
--lift: 1;
|
|
92
|
+
--lift-amount: calc(var(--lift) * var(--ngp-toast-gap));
|
|
93
|
+
--y: translateY(-100%);
|
|
84
94
|
}
|
|
85
95
|
|
|
86
|
-
|
|
87
|
-
|
|
96
|
+
:host[data-position-y='bottom'] {
|
|
97
|
+
bottom: 0;
|
|
98
|
+
--lift: -1;
|
|
99
|
+
--lift-amount: calc(var(--lift) * var(--ngp-toast-gap));
|
|
100
|
+
--y: translateY(100%);
|
|
88
101
|
}
|
|
89
102
|
|
|
90
|
-
|
|
91
|
-
|
|
103
|
+
:host[data-enter] {
|
|
104
|
+
opacity: 1;
|
|
105
|
+
--y: translateY(0);
|
|
92
106
|
}
|
|
93
107
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
108
|
+
:host[data-exit] {
|
|
109
|
+
opacity: 0;
|
|
110
|
+
--y: translateY(calc(calc(var(--lift) * var(--ngp-toast-gap)) * -1));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
:host[data-visible='false'] {
|
|
114
|
+
opacity: 0;
|
|
115
|
+
pointer-events: none;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
:host[data-expanded='true']::after {
|
|
119
|
+
content: '';
|
|
120
|
+
position: absolute;
|
|
97
121
|
left: 0;
|
|
98
|
-
|
|
99
|
-
|
|
122
|
+
height: calc(var(--ngp-toast-gap) + 1px);
|
|
123
|
+
bottom: 100%;
|
|
124
|
+
width: 100%;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
:host[data-expanded='false'][data-front='false'] {
|
|
128
|
+
--scale: var(--ngp-toasts-before) * 0.05 + 1;
|
|
129
|
+
--y: translateY(calc(var(--lift-amount) * var(--ngp-toasts-before)))
|
|
130
|
+
scale(calc(-1 * var(--scale)));
|
|
131
|
+
height: var(--ngp-toast-front-height);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
:host[data-expanded='true'] {
|
|
135
|
+
--y: translateY(calc(var(--lift) * var(--ngp-toast-offset)));
|
|
136
|
+
height: var(--ngp-toast-height);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
:host[data-swiping='true'] {
|
|
140
|
+
transform: var(--y) translateY(var(--ngp-toast-swipe-amount-y, 0))
|
|
141
|
+
translateX(var(--ngp-toast-swipe-amount-x, 0));
|
|
142
|
+
transition: none;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
:host[data-swiping='true'][data-swipe-direction='left'] {
|
|
146
|
+
/* Fade out from -45px to -100px swipe */
|
|
147
|
+
opacity: calc(1 - clamp(0, ((-1 * var(--ngp-toast-swipe-x, 0px)) - 45) / 55, 1));
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
:host[data-swiping='true'][data-swipe-direction='right'] {
|
|
151
|
+
/* Fade out from 45px to 100px swipe */
|
|
152
|
+
opacity: calc(1 - clamp(0, (var(--ngp-toast-swipe-x, 0px) - 45) / 55, 1));
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
:host[data-swiping='true'][data-swipe-direction='top'] {
|
|
156
|
+
/* Fade out from -45px to -100px swipe */
|
|
157
|
+
opacity: calc(1 - clamp(0, ((-1 * var(--ngp-toast-swipe-y, 0px)) - 45) / 55, 1));
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
:host[data-swiping='true'][data-swipe-direction='bottom'] {
|
|
161
|
+
/* Fade out from 45px to 100px swipe */
|
|
162
|
+
opacity: calc(1 - clamp(0, (var(--ngp-toast-swipe-y, 0px) - 45) / 55, 1));
|
|
100
163
|
}
|
|
101
164
|
`,
|
|
102
165
|
})
|
|
103
166
|
export class Toast<%= componentSuffix %> {
|
|
104
|
-
readonly
|
|
105
|
-
readonly
|
|
106
|
-
protected readonly
|
|
167
|
+
private readonly toastManager = inject(NgpToastManager);
|
|
168
|
+
private readonly toast = inject(NgpToast);
|
|
169
|
+
protected readonly context = injectToastContext<ToastContext>();
|
|
107
170
|
|
|
108
|
-
|
|
109
|
-
this.
|
|
171
|
+
dismiss(): void {
|
|
172
|
+
this.toastManager.dismiss(this.toast);
|
|
110
173
|
}
|
|
111
174
|
}
|
|
175
|
+
|
|
176
|
+
interface ToastContext {
|
|
177
|
+
header: string;
|
|
178
|
+
description: string;
|
|
179
|
+
}
|
|
@@ -1,22 +1,46 @@
|
|
|
1
1
|
import { InjectionToken, Provider } from '@angular/core';
|
|
2
|
-
import {
|
|
2
|
+
import { NgpToastSwipeDirection } from '../toast/toast';
|
|
3
3
|
export interface NgpToastConfig {
|
|
4
4
|
/**
|
|
5
5
|
* The duration of each toast.
|
|
6
6
|
*/
|
|
7
7
|
duration: number;
|
|
8
8
|
/**
|
|
9
|
-
* The
|
|
9
|
+
* The width of each toast in pixels.
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
width: number;
|
|
12
12
|
/**
|
|
13
|
-
* The
|
|
13
|
+
* The offset from the top of the viewport in pixels.
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
offsetTop: number;
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
17
|
+
* The offset from the bottom of the viewport in pixels.
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
offsetBottom: number;
|
|
20
|
+
/**
|
|
21
|
+
* The offset from the left of the viewport in pixels.
|
|
22
|
+
*/
|
|
23
|
+
offsetLeft: number;
|
|
24
|
+
/**
|
|
25
|
+
* The offset from the right of the viewport in pixels.
|
|
26
|
+
*/
|
|
27
|
+
offsetRight: number;
|
|
28
|
+
/**
|
|
29
|
+
* Whether a toast can be dismissed by swiping.
|
|
30
|
+
*/
|
|
31
|
+
dismissible: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* The amount a toast must be swiped before it is considered dismissed.
|
|
34
|
+
*/
|
|
35
|
+
swipeThreshold: number;
|
|
36
|
+
/**
|
|
37
|
+
* The default swipe directions supported by the toast.
|
|
38
|
+
*/
|
|
39
|
+
swipeDirections: NgpToastSwipeDirection[];
|
|
40
|
+
/**
|
|
41
|
+
* The maximum number of toasts that can be displayed at once.
|
|
42
|
+
*/
|
|
43
|
+
maxToasts: number;
|
|
20
44
|
/**
|
|
21
45
|
* The aria live setting.
|
|
22
46
|
*/
|
|
@@ -25,6 +49,11 @@ export interface NgpToastConfig {
|
|
|
25
49
|
* The gap between each toast.
|
|
26
50
|
*/
|
|
27
51
|
gap: number;
|
|
52
|
+
/**
|
|
53
|
+
* The z-index of the toast container.
|
|
54
|
+
* This is used to ensure that the toast container is always on top of other elements.
|
|
55
|
+
*/
|
|
56
|
+
zIndex: number;
|
|
28
57
|
}
|
|
29
58
|
export declare const defaultToastConfig: NgpToastConfig;
|
|
30
59
|
export declare const NgpToastConfigToken: InjectionToken<NgpToastConfig>;
|
package/toast/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { NgpToastConfig, provideToastConfig } from './config/toast-config';
|
|
2
2
|
export { NgpToast } from './toast/toast';
|
|
3
|
-
export {
|
|
3
|
+
export { injectToastContext } from './toast/toast-context';
|
|
4
|
+
export { NgpToastManager } from './toast/toast-manager';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { TemplateRef, Type } from '@angular/core';
|
|
2
|
+
import { NgpPortal } from 'ng-primitives/portal';
|
|
3
|
+
import { NgpToast, NgpToastSwipeDirection } from './toast';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
export declare class NgpToastManager {
|
|
6
|
+
private readonly config;
|
|
7
|
+
private readonly applicationRef;
|
|
8
|
+
private readonly rendererFactory;
|
|
9
|
+
private readonly renderer;
|
|
10
|
+
private readonly injector;
|
|
11
|
+
private readonly containers;
|
|
12
|
+
readonly toasts: import("@angular/core").WritableSignal<NgpToastRecord[]>;
|
|
13
|
+
/** Signal that tracks which placements are expanded */
|
|
14
|
+
private readonly expanded;
|
|
15
|
+
/** Show a toast notification */
|
|
16
|
+
show(toast: TemplateRef<void> | Type<unknown>, options?: NgpToastOptions): NgpToastRef;
|
|
17
|
+
/** Hide a toast notification */
|
|
18
|
+
dismiss(toast: NgpToast): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Lazily create or get a container for a given placement.
|
|
21
|
+
*/
|
|
22
|
+
private getOrCreateContainer;
|
|
23
|
+
/**
|
|
24
|
+
* Create a section in which toasts will be rendered for a specific placement.
|
|
25
|
+
*/
|
|
26
|
+
private createContainer;
|
|
27
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<NgpToastManager, never>;
|
|
28
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<NgpToastManager>;
|
|
29
|
+
}
|
|
30
|
+
export type NgpToastPlacement = 'top-start' | 'top-end' | 'top-center' | 'bottom-start' | 'bottom-end' | 'bottom-center';
|
|
31
|
+
export interface NgpToastOptions<T = unknown> {
|
|
32
|
+
/** The position of the toast */
|
|
33
|
+
placement?: NgpToastPlacement;
|
|
34
|
+
/** The duration of the toast in milliseconds */
|
|
35
|
+
duration?: number;
|
|
36
|
+
/** Whether the toast is dismissible */
|
|
37
|
+
dismissible?: boolean;
|
|
38
|
+
/** The swipe directions supported by the toast */
|
|
39
|
+
swipeDirections?: NgpToastSwipeDirection[];
|
|
40
|
+
/** The context to make available to the toast */
|
|
41
|
+
context?: T;
|
|
42
|
+
}
|
|
43
|
+
interface NgpToastRecord {
|
|
44
|
+
instance: NgpToast;
|
|
45
|
+
portal: NgpPortal;
|
|
46
|
+
}
|
|
47
|
+
interface NgpToastRef {
|
|
48
|
+
dismiss(): Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Signal, ValueProvider } from '@angular/core';
|
|
2
|
+
import type { NgpToast, NgpToastSwipeDirection } from './toast';
|
|
3
|
+
export declare function provideToastOptions(context: NgpToastOptions): ValueProvider;
|
|
4
|
+
export declare function injectToastOptions(): NgpToastOptions;
|
|
5
|
+
export interface NgpToastOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The position of the toast.
|
|
8
|
+
*/
|
|
9
|
+
placement: 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'top-center' | 'bottom-center';
|
|
10
|
+
/**
|
|
11
|
+
* The duration of the toast in milliseconds.
|
|
12
|
+
*/
|
|
13
|
+
duration: number;
|
|
14
|
+
/**
|
|
15
|
+
* A function to register the toast instance with the manager.
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
register: (toast: NgpToast) => void;
|
|
19
|
+
/**
|
|
20
|
+
* Whether the toast region is expanded.
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
expanded: Signal<boolean>;
|
|
24
|
+
/**
|
|
25
|
+
* Whether the toast supports swipe dismiss.
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
dismissible: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* The swipe directions supported by the toast.
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
swipeDirections: NgpToastSwipeDirection[];
|
|
34
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare class NgpToastTimer {
|
|
2
|
+
private duration;
|
|
3
|
+
private callback;
|
|
4
|
+
private startTime;
|
|
5
|
+
private remaining;
|
|
6
|
+
private timeoutId;
|
|
7
|
+
private isRunning;
|
|
8
|
+
constructor(duration: number, callback: () => void);
|
|
9
|
+
start(): void;
|
|
10
|
+
pause(): void;
|
|
11
|
+
stop(): void;
|
|
12
|
+
}
|
|
13
|
+
export declare function toastTimer(duration: number, callback: () => void): NgpToastTimer;
|
|
14
|
+
export {};
|
package/toast/toast/toast.d.ts
CHANGED
|
@@ -1,52 +1,75 @@
|
|
|
1
|
-
import { BooleanInput, NumberInput } from '@angular/cdk/coercion';
|
|
2
|
-
import { NgpToastGravity, NgpToastPosition } from './toast-ref';
|
|
3
1
|
import * as i0 from "@angular/core";
|
|
4
|
-
export interface NgpToastContext {
|
|
5
|
-
dismiss: () => void;
|
|
6
|
-
}
|
|
7
2
|
export declare class NgpToast {
|
|
8
|
-
private readonly
|
|
9
|
-
/** Access the ng-template */
|
|
10
|
-
private readonly template;
|
|
11
|
-
/** Access the view container */
|
|
12
|
-
private readonly viewContainer;
|
|
13
|
-
/** Access the injector */
|
|
3
|
+
private readonly manager;
|
|
14
4
|
private readonly injector;
|
|
15
|
-
|
|
16
|
-
|
|
5
|
+
protected readonly config: import("../config/toast-config").NgpToastConfig;
|
|
6
|
+
/** @internal */
|
|
7
|
+
readonly context: import("./toast-options").NgpToastOptions;
|
|
8
|
+
private readonly interactivityChecker;
|
|
9
|
+
private readonly isInteracting;
|
|
10
|
+
private pointerStartRef;
|
|
11
|
+
private dragStartTime;
|
|
12
|
+
protected readonly swiping: import("@angular/core").WritableSignal<boolean>;
|
|
13
|
+
protected readonly swipeDirection: import("@angular/core").WritableSignal<"x" | "y" | null>;
|
|
14
|
+
protected readonly swipeAmount: import("@angular/core").WritableSignal<{
|
|
15
|
+
x: number;
|
|
16
|
+
y: number;
|
|
17
|
+
}>;
|
|
18
|
+
protected readonly swipeOutDirection: import("@angular/core").Signal<"right" | "left" | "bottom" | "top" | null>;
|
|
19
|
+
/**
|
|
20
|
+
* Get all toasts that are currently being displayed in the same position.
|
|
21
|
+
*/
|
|
22
|
+
private readonly toasts;
|
|
23
|
+
/**
|
|
24
|
+
* The number of toasts that are currently being displayed before this toast.
|
|
25
|
+
*/
|
|
26
|
+
protected readonly index: import("@angular/core").Signal<number>;
|
|
27
|
+
/**
|
|
28
|
+
* Determine the position of the toast in the list of toasts.
|
|
29
|
+
* This is the combination of the heights of all the toasts before this one, plus the gap between them.
|
|
30
|
+
*/
|
|
31
|
+
protected readonly offset: import("@angular/core").Signal<number>;
|
|
32
|
+
/**
|
|
33
|
+
* Determine if this toast is visible.
|
|
34
|
+
* Visible considers the maximum number of toasts that can be displayed at once, and the last x toasts that are currently being displayed.
|
|
35
|
+
*/
|
|
36
|
+
protected readonly visible: import("@angular/core").Signal<boolean>;
|
|
37
|
+
/**
|
|
38
|
+
* Determine the height of the front toast.
|
|
39
|
+
* This is used to determine the height of the toast when it is not expanded.
|
|
40
|
+
*/
|
|
41
|
+
protected readonly frontToastHeight: import("@angular/core").Signal<number>;
|
|
17
42
|
/**
|
|
18
|
-
*
|
|
19
|
-
*
|
|
43
|
+
* Determine the z-index of the toast. This is the inverse of the index.
|
|
44
|
+
* The first toast will have the highest z-index, and the last toast will have the lowest z-index.
|
|
45
|
+
* This is used to ensure that the first toast is always on top of the others.
|
|
20
46
|
*/
|
|
21
|
-
readonly
|
|
47
|
+
protected readonly zIndex: import("@angular/core").Signal<number>;
|
|
22
48
|
/**
|
|
23
|
-
* The
|
|
24
|
-
* @default 'top'
|
|
49
|
+
* The height of the toast in pixels.
|
|
25
50
|
*/
|
|
26
|
-
readonly
|
|
51
|
+
protected readonly dimensions: import("@angular/core").WritableSignal<{
|
|
52
|
+
width: number;
|
|
53
|
+
height: number;
|
|
54
|
+
mounted: boolean;
|
|
55
|
+
}>;
|
|
27
56
|
/**
|
|
28
|
-
* The position the toast
|
|
29
|
-
* @default 'end'
|
|
57
|
+
* The x position of the toast.
|
|
30
58
|
*/
|
|
31
|
-
readonly
|
|
59
|
+
readonly x: string;
|
|
32
60
|
/**
|
|
33
|
-
*
|
|
34
|
-
* @default true
|
|
61
|
+
* The y position of the toast.
|
|
35
62
|
*/
|
|
36
|
-
readonly
|
|
63
|
+
readonly y: string;
|
|
37
64
|
/**
|
|
38
|
-
*
|
|
39
|
-
* @default 'polite'
|
|
65
|
+
* The toast timer instance.
|
|
40
66
|
*/
|
|
41
|
-
readonly
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
/** Build the toast */
|
|
47
|
-
private createToast;
|
|
48
|
-
/** Position the toast on the DOM */
|
|
49
|
-
private reposition;
|
|
67
|
+
private readonly timer;
|
|
68
|
+
constructor();
|
|
69
|
+
protected onPointerDown(event: PointerEvent): void;
|
|
70
|
+
protected onPointerMove(event: PointerEvent): void;
|
|
71
|
+
protected onPointerUp(): void;
|
|
50
72
|
static ɵfac: i0.ɵɵFactoryDeclaration<NgpToast, never>;
|
|
51
|
-
static ɵdir: i0.ɵɵDirectiveDeclaration<NgpToast, "[ngpToast]", ["ngpToast"], {
|
|
73
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<NgpToast, "[ngpToast]", ["ngpToast"], {}, {}, never, never, true, never>;
|
|
52
74
|
}
|
|
75
|
+
export type NgpToastSwipeDirection = 'top' | 'right' | 'bottom' | 'left';
|