ng-primitives 0.58.0 → 0.59.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/combobox/combobox-dropdown/combobox-dropdown.d.ts +3 -3
- package/fesm2022/ng-primitives-a11y.mjs.map +1 -1
- package/fesm2022/ng-primitives-accordion.mjs.map +1 -1
- package/fesm2022/ng-primitives-autofill.mjs.map +1 -1
- package/fesm2022/ng-primitives-avatar.mjs.map +1 -1
- package/fesm2022/ng-primitives-button.mjs.map +1 -1
- package/fesm2022/ng-primitives-checkbox.mjs.map +1 -1
- package/fesm2022/ng-primitives-combobox.mjs +1 -2
- package/fesm2022/ng-primitives-combobox.mjs.map +1 -1
- package/fesm2022/ng-primitives-common.mjs.map +1 -1
- package/fesm2022/ng-primitives-date-picker.mjs.map +1 -1
- package/fesm2022/ng-primitives-date-time-luxon.mjs.map +1 -1
- package/fesm2022/ng-primitives-date-time.mjs.map +1 -1
- package/fesm2022/ng-primitives-dialog.mjs.map +1 -1
- package/fesm2022/ng-primitives-file-upload.mjs.map +1 -1
- package/fesm2022/ng-primitives-focus-trap.mjs.map +1 -1
- package/fesm2022/ng-primitives-form-field.mjs.map +1 -1
- package/fesm2022/ng-primitives-input.mjs.map +1 -1
- package/fesm2022/ng-primitives-interactions.mjs.map +1 -1
- package/fesm2022/ng-primitives-internal.mjs +132 -25
- package/fesm2022/ng-primitives-internal.mjs.map +1 -1
- package/fesm2022/ng-primitives-listbox.mjs.map +1 -1
- package/fesm2022/ng-primitives-menu.mjs.map +1 -1
- package/fesm2022/ng-primitives-meter.mjs.map +1 -1
- package/fesm2022/ng-primitives-pagination.mjs.map +1 -1
- package/fesm2022/ng-primitives-popover.mjs +4 -2
- package/fesm2022/ng-primitives-popover.mjs.map +1 -1
- package/fesm2022/ng-primitives-portal.mjs +8 -2
- package/fesm2022/ng-primitives-portal.mjs.map +1 -1
- package/fesm2022/ng-primitives-progress.mjs.map +1 -1
- package/fesm2022/ng-primitives-radio.mjs.map +1 -1
- package/fesm2022/ng-primitives-resize.mjs +5 -66
- package/fesm2022/ng-primitives-resize.mjs.map +1 -1
- package/fesm2022/ng-primitives-roving-focus.mjs.map +1 -1
- package/fesm2022/ng-primitives-search.mjs.map +1 -1
- package/fesm2022/ng-primitives-select.mjs.map +1 -1
- package/fesm2022/ng-primitives-separator.mjs.map +1 -1
- package/fesm2022/ng-primitives-slider.mjs.map +1 -1
- package/fesm2022/ng-primitives-state.mjs.map +1 -1
- package/fesm2022/ng-primitives-switch.mjs.map +1 -1
- package/fesm2022/ng-primitives-tabs.mjs.map +1 -1
- package/fesm2022/ng-primitives-textarea.mjs.map +1 -1
- package/fesm2022/ng-primitives-toast.mjs.map +1 -1
- package/fesm2022/ng-primitives-toggle-group.mjs.map +1 -1
- package/fesm2022/ng-primitives-toggle.mjs.map +1 -1
- package/fesm2022/ng-primitives-toolbar.mjs.map +1 -1
- package/fesm2022/ng-primitives-tooltip.mjs +22 -3
- package/fesm2022/ng-primitives-tooltip.mjs.map +1 -1
- package/fesm2022/ng-primitives-utils.mjs.map +1 -1
- package/internal/index.d.ts +3 -0
- package/internal/utilities/mutation-observer.d.ts +39 -0
- package/internal/utilities/overflow.d.ts +13 -0
- package/{resize/utils → internal/utilities}/resize.d.ts +13 -2
- package/package.json +32 -32
- package/portal/overlay.d.ts +2 -0
- package/resize/index.d.ts +1 -1
- package/resize/resize/resize.d.ts +3 -4
- package/schematics/ng-generate/__snapshots__/index.spec.ts.snap +148 -5
- package/schematics/ng-generate/templates/button/button.__fileSuffix@dasherize__.ts.template +106 -5
- package/schematics/ng-generate/templates/tooltip/tooltip-trigger.__fileSuffix@dasherize__.ts.template +1 -0
- package/tooltip/config/tooltip-config.d.ts +5 -0
- package/tooltip/tooltip-trigger/tooltip-trigger.d.ts +13 -3
|
@@ -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;;;AAG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,iBAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,QAAA,EAAA,EAAA,iBAAA,EAAA,UAAA,EAAA,UAAA,EAAA,kBAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,WAAA,EAAA,EAAA,iBAAA,EAAA,aAAA,EAAA,UAAA,EAAA,qBAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,QAAA,EAAA,EAAA,iBAAA,EAAA,UAAA,EAAA,UAAA,EAAA,kBAAA,EAAA,QAAA,EAAA,IAAA,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-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,IAA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,EAAA,WAAA,EAAA,EAAA,iBAAA,EAAA,aAAA,EAAA,UAAA,EAAA,qBAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,QAAA,EAAA,EAAA,iBAAA,EAAA,UAAA,EAAA,UAAA,EAAA,kBAAA,EAAA,QAAA,EAAA,IAAA,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-primitives-toggle-group.mjs","sources":["../../../../packages/ng-primitives/toggle-group/src/config/toggle-group-config.ts","../../../../packages/ng-primitives/toggle-group/src/toggle-group/toggle-group-state.ts","../../../../packages/ng-primitives/toggle-group/src/toggle-group-item/toggle-group-item-state.ts","../../../../packages/ng-primitives/toggle-group/src/toggle-group-item/toggle-group-item.ts","../../../../packages/ng-primitives/toggle-group/src/toggle-group/toggle-group.ts","../../../../packages/ng-primitives/toggle-group/src/ng-primitives-toggle-group.ts"],"sourcesContent":["import { InjectionToken, Provider, inject } from '@angular/core';\nimport { NgpOrientation } from 'ng-primitives/common';\n\nexport interface NgpToggleGroupConfig {\n /**\n * The orientation of the toggle group.\n * @default 'horizontal'\n */\n orientation: NgpOrientation;\n\n /**\n * The type of the toggle group, whether only one item can be selected or multiple.\n * @default 'single'\n */\n type: 'single' | 'multiple';\n\n /**\n * Whether a toggle button can be deselected.\n * @default true\n */\n allowDeselection: boolean;\n}\n\nexport const defaultToggleGroupConfig: NgpToggleGroupConfig = {\n orientation: 'horizontal',\n type: 'single',\n allowDeselection: true,\n};\n\nexport const NgpToggleGroupConfigToken = new InjectionToken<NgpToggleGroupConfig>(\n 'NgpToggleGroupConfigToken',\n);\n\n/**\n * Provide the default ToggleGroup configuration\n * @param config The ToggleGroup configuration\n * @returns The provider\n */\nexport function provideToggleGroupConfig(config: Partial<NgpToggleGroupConfig>): Provider[] {\n return [\n {\n provide: NgpToggleGroupConfigToken,\n useValue: { ...defaultToggleGroupConfig, ...config },\n },\n ];\n}\n\n/**\n * Inject the ToggleGroup configuration\n * @returns The global ToggleGroup configuration\n */\nexport function injectToggleGroupConfig(): NgpToggleGroupConfig {\n return inject(NgpToggleGroupConfigToken, { optional: true }) ?? defaultToggleGroupConfig;\n}\n","import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n} from 'ng-primitives/state';\nimport type { NgpToggleGroup } from './toggle-group';\n\n/**\n * The state token for the ToggleGroup primitive.\n */\nexport const NgpToggleGroupStateToken = createStateToken<NgpToggleGroup>('ToggleGroup');\n\n/**\n * Provides the ToggleGroup state.\n */\nexport const provideToggleGroupState = createStateProvider(NgpToggleGroupStateToken);\n\n/**\n * Injects the ToggleGroup state.\n */\nexport const injectToggleGroupState = createStateInjector<NgpToggleGroup>(NgpToggleGroupStateToken);\n\n/**\n * The ToggleGroup state registration function.\n */\nexport const toggleGroupState = createState(NgpToggleGroupStateToken);\n","import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n} from 'ng-primitives/state';\nimport type { NgpToggleGroupItem } from './toggle-group-item';\n\n/**\n * The state token for the ToggleGroupItem primitive.\n */\nexport const NgpToggleGroupItemStateToken = createStateToken<NgpToggleGroupItem>('ToggleGroupItem');\n\n/**\n * Provides the ToggleGroupItem state.\n */\nexport const provideToggleGroupItemState = createStateProvider(NgpToggleGroupItemStateToken);\n\n/**\n * Injects the ToggleGroupItem state.\n */\nexport const injectToggleGroupItemState = createStateInjector<NgpToggleGroupItem>(\n NgpToggleGroupItemStateToken,\n);\n\n/**\n * The ToggleGroupItem state registration function.\n */\nexport const toggleGroupItemState = createState(NgpToggleGroupItemStateToken);\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport { booleanAttribute, computed, Directive, input, OnInit } from '@angular/core';\nimport { NgpRovingFocusItem } from 'ng-primitives/roving-focus';\nimport { injectToggleGroupState } from '../toggle-group/toggle-group-state';\nimport { provideToggleGroupItemState, toggleGroupItemState } from './toggle-group-item-state';\n\n@Directive({\n selector: '[ngpToggleGroupItem]',\n exportAs: 'ngpToggleGroupItem',\n providers: [provideToggleGroupItemState()],\n hostDirectives: [\n {\n directive: NgpRovingFocusItem,\n inputs: ['ngpRovingFocusItemDisabled: ngpToggleGroupItemDisabled'],\n },\n ],\n host: {\n role: 'radio',\n '[attr.aria-checked]': 'selected()',\n '[attr.data-selected]': 'selected() ? \"\" : null',\n '[attr.aria-disabled]': 'state.disabled()',\n '[attr.data-disabled]': 'state.disabled() ? \"\" : null',\n '(click)': 'toggle()',\n },\n})\nexport class NgpToggleGroupItem implements OnInit {\n /**\n * Access the group that the item belongs to.\n */\n private readonly toggleGroup = injectToggleGroupState();\n\n /**\n * The value of the item.\n */\n readonly value = input<string>(undefined, {\n alias: 'ngpToggleGroupItemValue',\n });\n\n /**\n * Whether the item is disabled.\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpToggleGroupItemDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * Whether the item is selected.\n */\n protected readonly selected = computed(() => this.toggleGroup().isSelected(this.state.value()!));\n\n /**\n * The state of the item.\n */\n protected readonly state = toggleGroupItemState<NgpToggleGroupItem>(this);\n\n ngOnInit(): void {\n // we can't use a required input for value as it is used in a computed property before the input is set\n if (this.state.value() === undefined) {\n throw new Error('The value input is required for the toggle group item.');\n }\n }\n\n /**\n * Toggle the item.\n */\n protected toggle(): void {\n if (this.state.disabled()) {\n return;\n }\n\n this.toggleGroup().toggle(this.state.value()!);\n }\n}\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport { booleanAttribute, Directive, input, output } from '@angular/core';\nimport { NgpOrientation } from 'ng-primitives/common';\nimport { explicitEffect } from 'ng-primitives/internal';\nimport { injectRovingFocusGroupState, NgpRovingFocusGroup } from 'ng-primitives/roving-focus';\nimport { injectToggleGroupConfig } from '../config/toggle-group-config';\nimport { provideToggleGroupState, toggleGroupState } from './toggle-group-state';\n\n@Directive({\n selector: '[ngpToggleGroup]',\n exportAs: 'ngpToggleGroup',\n providers: [provideToggleGroupState()],\n hostDirectives: [NgpRovingFocusGroup],\n host: {\n role: 'group',\n '[attr.data-orientation]': 'state.orientation()',\n '[attr.data-type]': 'state.type()',\n '[attr.data-disabled]': 'state.disabled() ? \"\" : null',\n },\n})\nexport class NgpToggleGroup {\n /**\n * Access the roving focus group state.\n */\n private readonly rovingFocusGroupState = injectRovingFocusGroupState();\n\n /**\n * Access the global toggle group configuration.\n */\n private readonly config = injectToggleGroupConfig();\n\n /**\n * The orientation of the toggle group.\n */\n readonly orientation = input<NgpOrientation>(this.config.orientation, {\n alias: 'ngpToggleGroupOrientation',\n });\n\n /**\n * Whether toggle buttons can be deselected. If set to `false`, clicking a selected toggle button will not deselect it.\n * @default true\n */\n readonly allowDeselection = input<boolean, BooleanInput>(this.config.allowDeselection, {\n alias: 'ngpToggleGroupAllowDeselection',\n transform: booleanAttribute,\n });\n\n /**\n * The type of the toggle group, whether only one item can be selected or multiple.\n */\n readonly type = input<'single' | 'multiple'>(this.config.type, { alias: 'ngpToggleGroupType' });\n\n /**\n * The selected value(s) of the toggle group.\n */\n readonly value = input<string[]>([], { alias: 'ngpToggleGroupValue' });\n\n /**\n * Emits when the value of the toggle group changes.\n */\n readonly valueChange = output<string[]>({ alias: 'ngpToggleGroupValueChange' });\n\n /**\n * Whether the toggle group is disabled.\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpToggleGroupDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * The state of the toggle group.\n */\n protected readonly state = toggleGroupState<NgpToggleGroup>(this);\n\n constructor() {\n // the roving focus group defaults to vertical orientation whereas\n // the default for the toggle group may be different if provided via global config\n explicitEffect([this.state.orientation], ([orientation]) =>\n this.rovingFocusGroupState().orientation.set(orientation),\n );\n }\n\n /**\n * Select a value in the toggle group.\n */\n private select(value: string): void {\n if (this.state.disabled()) {\n return;\n }\n\n let newValue: string[] = [];\n\n if (this.state.type() === 'single') {\n newValue = [value];\n } else {\n newValue = [...this.state.value(), value];\n }\n\n this.state.value.set(newValue);\n this.valueChange.emit(newValue);\n }\n\n /**\n * De-select a value in the toggle group.\n */\n private deselect(value: string): void {\n if (this.state.disabled() || !this.state.allowDeselection()) {\n return;\n }\n\n const newValue = this.state.value().filter(v => v !== value);\n this.state.value.set(newValue);\n this.valueChange.emit(newValue);\n }\n\n /**\n * Check if a value is selected in the toggle group.\n * @internal\n */\n isSelected(value: string): boolean {\n return this.state.value()?.includes(value) ?? false;\n }\n\n /**\n * Toggle a value in the toggle group.\n * @internal\n */\n toggle(value: string): void {\n if (this.isSelected(value)) {\n this.deselect(value);\n } else {\n this.select(value);\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAuBO,MAAM,wBAAwB,GAAyB;AAC5D,IAAA,WAAW,EAAE,YAAY;AACzB,IAAA,IAAI,EAAE,QAAQ;AACd,IAAA,gBAAgB,EAAE,IAAI;CACvB;AAEM,MAAM,yBAAyB,GAAG,IAAI,cAAc,CACzD,2BAA2B,CAC5B;AAED;;;;AAIG;AACG,SAAU,wBAAwB,CAAC,MAAqC,EAAA;IAC5E,OAAO;AACL,QAAA;AACE,YAAA,OAAO,EAAE,yBAAyB;AAClC,YAAA,QAAQ,EAAE,EAAE,GAAG,wBAAwB,EAAE,GAAG,MAAM,EAAE;AACrD,SAAA;KACF;AACH;AAEA;;;AAGG;SACa,uBAAuB,GAAA;AACrC,IAAA,OAAO,MAAM,CAAC,yBAAyB,EAAE,EAAE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EAAE,gBAAgB;AAC1B,oBAAA,SAAS,EAAE,CAAC,uBAAuB,EAAE,CAAC;oBACtC,cAAc,EAAE,CAAC,mBAAmB,CAAC;AACrC,oBAAA,IAAI,EAAE;AACJ,wBAAA,IAAI,EAAE,OAAO;AACb,wBAAA,yBAAyB,EAAE,qBAAqB;AAChD,wBAAA,kBAAkB,EAAE,cAAc;AAClC,wBAAA,sBAAsB,EAAE,8BAA8B;AACvD,qBAAA;AACF,iBAAA;;;ACnBD;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ng-primitives-toggle-group.mjs","sources":["../../../../packages/ng-primitives/toggle-group/src/config/toggle-group-config.ts","../../../../packages/ng-primitives/toggle-group/src/toggle-group/toggle-group-state.ts","../../../../packages/ng-primitives/toggle-group/src/toggle-group-item/toggle-group-item-state.ts","../../../../packages/ng-primitives/toggle-group/src/toggle-group-item/toggle-group-item.ts","../../../../packages/ng-primitives/toggle-group/src/toggle-group/toggle-group.ts","../../../../packages/ng-primitives/toggle-group/src/ng-primitives-toggle-group.ts"],"sourcesContent":["import { InjectionToken, Provider, inject } from '@angular/core';\nimport { NgpOrientation } from 'ng-primitives/common';\n\nexport interface NgpToggleGroupConfig {\n /**\n * The orientation of the toggle group.\n * @default 'horizontal'\n */\n orientation: NgpOrientation;\n\n /**\n * The type of the toggle group, whether only one item can be selected or multiple.\n * @default 'single'\n */\n type: 'single' | 'multiple';\n\n /**\n * Whether a toggle button can be deselected.\n * @default true\n */\n allowDeselection: boolean;\n}\n\nexport const defaultToggleGroupConfig: NgpToggleGroupConfig = {\n orientation: 'horizontal',\n type: 'single',\n allowDeselection: true,\n};\n\nexport const NgpToggleGroupConfigToken = new InjectionToken<NgpToggleGroupConfig>(\n 'NgpToggleGroupConfigToken',\n);\n\n/**\n * Provide the default ToggleGroup configuration\n * @param config The ToggleGroup configuration\n * @returns The provider\n */\nexport function provideToggleGroupConfig(config: Partial<NgpToggleGroupConfig>): Provider[] {\n return [\n {\n provide: NgpToggleGroupConfigToken,\n useValue: { ...defaultToggleGroupConfig, ...config },\n },\n ];\n}\n\n/**\n * Inject the ToggleGroup configuration\n * @returns The global ToggleGroup configuration\n */\nexport function injectToggleGroupConfig(): NgpToggleGroupConfig {\n return inject(NgpToggleGroupConfigToken, { optional: true }) ?? defaultToggleGroupConfig;\n}\n","import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n} from 'ng-primitives/state';\nimport type { NgpToggleGroup } from './toggle-group';\n\n/**\n * The state token for the ToggleGroup primitive.\n */\nexport const NgpToggleGroupStateToken = createStateToken<NgpToggleGroup>('ToggleGroup');\n\n/**\n * Provides the ToggleGroup state.\n */\nexport const provideToggleGroupState = createStateProvider(NgpToggleGroupStateToken);\n\n/**\n * Injects the ToggleGroup state.\n */\nexport const injectToggleGroupState = createStateInjector<NgpToggleGroup>(NgpToggleGroupStateToken);\n\n/**\n * The ToggleGroup state registration function.\n */\nexport const toggleGroupState = createState(NgpToggleGroupStateToken);\n","import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n} from 'ng-primitives/state';\nimport type { NgpToggleGroupItem } from './toggle-group-item';\n\n/**\n * The state token for the ToggleGroupItem primitive.\n */\nexport const NgpToggleGroupItemStateToken = createStateToken<NgpToggleGroupItem>('ToggleGroupItem');\n\n/**\n * Provides the ToggleGroupItem state.\n */\nexport const provideToggleGroupItemState = createStateProvider(NgpToggleGroupItemStateToken);\n\n/**\n * Injects the ToggleGroupItem state.\n */\nexport const injectToggleGroupItemState = createStateInjector<NgpToggleGroupItem>(\n NgpToggleGroupItemStateToken,\n);\n\n/**\n * The ToggleGroupItem state registration function.\n */\nexport const toggleGroupItemState = createState(NgpToggleGroupItemStateToken);\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport { booleanAttribute, computed, Directive, input, OnInit } from '@angular/core';\nimport { NgpRovingFocusItem } from 'ng-primitives/roving-focus';\nimport { injectToggleGroupState } from '../toggle-group/toggle-group-state';\nimport { provideToggleGroupItemState, toggleGroupItemState } from './toggle-group-item-state';\n\n@Directive({\n selector: '[ngpToggleGroupItem]',\n exportAs: 'ngpToggleGroupItem',\n providers: [provideToggleGroupItemState()],\n hostDirectives: [\n {\n directive: NgpRovingFocusItem,\n inputs: ['ngpRovingFocusItemDisabled: ngpToggleGroupItemDisabled'],\n },\n ],\n host: {\n role: 'radio',\n '[attr.aria-checked]': 'selected()',\n '[attr.data-selected]': 'selected() ? \"\" : null',\n '[attr.aria-disabled]': 'state.disabled()',\n '[attr.data-disabled]': 'state.disabled() ? \"\" : null',\n '(click)': 'toggle()',\n },\n})\nexport class NgpToggleGroupItem implements OnInit {\n /**\n * Access the group that the item belongs to.\n */\n private readonly toggleGroup = injectToggleGroupState();\n\n /**\n * The value of the item.\n */\n readonly value = input<string>(undefined, {\n alias: 'ngpToggleGroupItemValue',\n });\n\n /**\n * Whether the item is disabled.\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpToggleGroupItemDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * Whether the item is selected.\n */\n protected readonly selected = computed(() => this.toggleGroup().isSelected(this.state.value()!));\n\n /**\n * The state of the item.\n */\n protected readonly state = toggleGroupItemState<NgpToggleGroupItem>(this);\n\n ngOnInit(): void {\n // we can't use a required input for value as it is used in a computed property before the input is set\n if (this.state.value() === undefined) {\n throw new Error('The value input is required for the toggle group item.');\n }\n }\n\n /**\n * Toggle the item.\n */\n protected toggle(): void {\n if (this.state.disabled()) {\n return;\n }\n\n this.toggleGroup().toggle(this.state.value()!);\n }\n}\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport { booleanAttribute, Directive, input, output } from '@angular/core';\nimport { NgpOrientation } from 'ng-primitives/common';\nimport { explicitEffect } from 'ng-primitives/internal';\nimport { injectRovingFocusGroupState, NgpRovingFocusGroup } from 'ng-primitives/roving-focus';\nimport { injectToggleGroupConfig } from '../config/toggle-group-config';\nimport { provideToggleGroupState, toggleGroupState } from './toggle-group-state';\n\n@Directive({\n selector: '[ngpToggleGroup]',\n exportAs: 'ngpToggleGroup',\n providers: [provideToggleGroupState()],\n hostDirectives: [NgpRovingFocusGroup],\n host: {\n role: 'group',\n '[attr.data-orientation]': 'state.orientation()',\n '[attr.data-type]': 'state.type()',\n '[attr.data-disabled]': 'state.disabled() ? \"\" : null',\n },\n})\nexport class NgpToggleGroup {\n /**\n * Access the roving focus group state.\n */\n private readonly rovingFocusGroupState = injectRovingFocusGroupState();\n\n /**\n * Access the global toggle group configuration.\n */\n private readonly config = injectToggleGroupConfig();\n\n /**\n * The orientation of the toggle group.\n */\n readonly orientation = input<NgpOrientation>(this.config.orientation, {\n alias: 'ngpToggleGroupOrientation',\n });\n\n /**\n * Whether toggle buttons can be deselected. If set to `false`, clicking a selected toggle button will not deselect it.\n * @default true\n */\n readonly allowDeselection = input<boolean, BooleanInput>(this.config.allowDeselection, {\n alias: 'ngpToggleGroupAllowDeselection',\n transform: booleanAttribute,\n });\n\n /**\n * The type of the toggle group, whether only one item can be selected or multiple.\n */\n readonly type = input<'single' | 'multiple'>(this.config.type, { alias: 'ngpToggleGroupType' });\n\n /**\n * The selected value(s) of the toggle group.\n */\n readonly value = input<string[]>([], { alias: 'ngpToggleGroupValue' });\n\n /**\n * Emits when the value of the toggle group changes.\n */\n readonly valueChange = output<string[]>({ alias: 'ngpToggleGroupValueChange' });\n\n /**\n * Whether the toggle group is disabled.\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpToggleGroupDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * The state of the toggle group.\n */\n protected readonly state = toggleGroupState<NgpToggleGroup>(this);\n\n constructor() {\n // the roving focus group defaults to vertical orientation whereas\n // the default for the toggle group may be different if provided via global config\n explicitEffect([this.state.orientation], ([orientation]) =>\n this.rovingFocusGroupState().orientation.set(orientation),\n );\n }\n\n /**\n * Select a value in the toggle group.\n */\n private select(value: string): void {\n if (this.state.disabled()) {\n return;\n }\n\n let newValue: string[] = [];\n\n if (this.state.type() === 'single') {\n newValue = [value];\n } else {\n newValue = [...this.state.value(), value];\n }\n\n this.state.value.set(newValue);\n this.valueChange.emit(newValue);\n }\n\n /**\n * De-select a value in the toggle group.\n */\n private deselect(value: string): void {\n if (this.state.disabled() || !this.state.allowDeselection()) {\n return;\n }\n\n const newValue = this.state.value().filter(v => v !== value);\n this.state.value.set(newValue);\n this.valueChange.emit(newValue);\n }\n\n /**\n * Check if a value is selected in the toggle group.\n * @internal\n */\n isSelected(value: string): boolean {\n return this.state.value()?.includes(value) ?? false;\n }\n\n /**\n * Toggle a value in the toggle group.\n * @internal\n */\n toggle(value: string): void {\n if (this.isSelected(value)) {\n this.deselect(value);\n } else {\n this.select(value);\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAuBO,MAAM,wBAAwB,GAAyB;AAC5D,IAAA,WAAW,EAAE,YAAY;AACzB,IAAA,IAAI,EAAE,QAAQ;AACd,IAAA,gBAAgB,EAAE,IAAI;CACvB;AAEM,MAAM,yBAAyB,GAAG,IAAI,cAAc,CACzD,2BAA2B,CAC5B;AAED;;;;AAIG;AACG,SAAU,wBAAwB,CAAC,MAAqC,EAAA;IAC5E,OAAO;AACL,QAAA;AACE,YAAA,OAAO,EAAE,yBAAyB;AAClC,YAAA,QAAQ,EAAE,EAAE,GAAG,wBAAwB,EAAE,GAAG,MAAM,EAAE;AACrD,SAAA;KACF;AACH;AAEA;;;AAGG;SACa,uBAAuB,GAAA;AACrC,IAAA,OAAO,MAAM,CAAC,yBAAyB,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,IAAI,wBAAwB;AAC1F;;AC7CA;;AAEG;AACI,MAAM,wBAAwB,GAAG,gBAAgB,CAAiB,aAAa,CAAC;AAEvF;;AAEG;MACU,uBAAuB,GAAG,mBAAmB,CAAC,wBAAwB;AAEnF;;AAEG;MACU,sBAAsB,GAAG,mBAAmB,CAAiB,wBAAwB;AAElG;;AAEG;AACI,MAAM,gBAAgB,G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D,wBAAA,kBAAkB,EAAE,cAAc;AAClC,wBAAA,sBAAsB,EAAE,8BAA8B;AACvD,qBAAA;AACF,iBAAA;;;ACnBD;;AAEG;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-primitives-toggle.mjs","sources":["../../../../packages/ng-primitives/toggle/src/toggle/toggle-state.ts","../../../../packages/ng-primitives/toggle/src/toggle/toggle.ts","../../../../packages/ng-primitives/toggle/src/ng-primitives-toggle.ts"],"sourcesContent":["import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n} from 'ng-primitives/state';\nimport type { NgpToggle } from './toggle';\n\n/**\n * The state token for the Toggle primitive.\n */\nexport const NgpToggleStateToken = createStateToken<NgpToggle>('Toggle');\n\n/**\n * Provides the Toggle state.\n */\nexport const provideToggleState = createStateProvider(NgpToggleStateToken);\n\n/**\n * Injects the Toggle state.\n */\nexport const injectToggleState = createStateInjector<NgpToggle>(NgpToggleStateToken);\n\n/**\n * The Toggle state registration function.\n */\nexport const toggleState = createState(NgpToggleStateToken);\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport {\n Directive,\n ElementRef,\n HostListener,\n booleanAttribute,\n inject,\n input,\n output,\n} from '@angular/core';\nimport { provideToggleState, toggleState } from './toggle-state';\n\n/**\n * Apply the `ngpToggle` directive to an element to manage the toggle state. This must be applied to a `button` element.\n */\n@Directive({\n selector: '[ngpToggle]',\n exportAs: 'ngpToggle',\n providers: [provideToggleState()],\n host: {\n '[attr.type]': 'isButton ? \"button\" : null',\n '[attr.aria-pressed]': 'state.selected()',\n '[attr.data-selected]': 'state.selected() ? \"\" : null',\n '[attr.data-disabled]': 'state.disabled() ? \"\" : null',\n },\n})\nexport class NgpToggle {\n /**\n * Access the element.\n */\n private readonly element = inject<ElementRef<HTMLElement>>(ElementRef);\n\n /**\n * Whether the toggle is selected.\n * @default false\n */\n readonly selected = input<boolean, BooleanInput>(false, {\n alias: 'ngpToggleSelected',\n transform: booleanAttribute,\n });\n\n /**\n * Emits when the selected state changes.\n */\n readonly selectedChange = output<boolean>({\n alias: 'ngpToggleSelectedChange',\n });\n\n /**\n * Whether the toggle is disabled.\n * @default false\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpToggleDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * Determine if the element is a button.\n */\n protected isButton = this.element.nativeElement.tagName === 'BUTTON';\n\n /**\n * The state for the toggle primitive.\n * @internal\n */\n protected readonly state = toggleState<NgpToggle>(this);\n\n /**\n * Toggle the selected state.\n */\n @HostListener('click')\n toggle(): void {\n if (this.state.disabled()) {\n return;\n }\n\n const isSelected = !this.state.selected();\n\n this.state.selected.set(isSelected);\n this.selectedChange.emit(isSelected);\n }\n\n /**\n * If the element is not a button or a link the space key should toggle the selected state.\n */\n @HostListener('keydown.space', ['$event'])\n protected onKeyDown(event: KeyboardEvent): void {\n if (!this.isButton && this.element.nativeElement.tagName !== 'A') {\n event.preventDefault();\n this.toggle();\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAQA;;AAEG;AACI,MAAM,mBAAmB,GAAG,gBAAgB,CAAY,QAAQ,CAAC;AAExE;;AAEG;MACU,kBAAkB,GAAG,mBAAmB,CAAC,mBAAmB;AAEzE;;AAEG;MACU,iBAAiB,GAAG,mBAAmB,CAAY,mBAAmB;AAEnF;;AAEG;AACI,MAAM,WAAW,GAAG,WAAW,CAAC,mBAAmB,CAAC;;ACd3D;;AAEG;MAYU,SAAS,CAAA;AAXtB,IAAA,WAAA,GAAA;AAYE;;AAEG;AACc,QAAA,IAAA,CAAA,OAAO,GAAG,MAAM,CAA0B,UAAU,CAAC;AAEtE;;;AAGG;AACM,QAAA,IAAA,CAAA,QAAQ,GAAG,KAAK,CAAwB,KAAK,EAAE;AACtD,YAAA,KAAK,EAAE,mBAAmB;AAC1B,YAAA,SAAS,EAAE,gBAAgB;AAC5B,SAAA,CAAC;AAEF;;AAEG;QACM,
|
|
1
|
+
{"version":3,"file":"ng-primitives-toggle.mjs","sources":["../../../../packages/ng-primitives/toggle/src/toggle/toggle-state.ts","../../../../packages/ng-primitives/toggle/src/toggle/toggle.ts","../../../../packages/ng-primitives/toggle/src/ng-primitives-toggle.ts"],"sourcesContent":["import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n} from 'ng-primitives/state';\nimport type { NgpToggle } from './toggle';\n\n/**\n * The state token for the Toggle primitive.\n */\nexport const NgpToggleStateToken = createStateToken<NgpToggle>('Toggle');\n\n/**\n * Provides the Toggle state.\n */\nexport const provideToggleState = createStateProvider(NgpToggleStateToken);\n\n/**\n * Injects the Toggle state.\n */\nexport const injectToggleState = createStateInjector<NgpToggle>(NgpToggleStateToken);\n\n/**\n * The Toggle state registration function.\n */\nexport const toggleState = createState(NgpToggleStateToken);\n","import { BooleanInput } from '@angular/cdk/coercion';\nimport {\n Directive,\n ElementRef,\n HostListener,\n booleanAttribute,\n inject,\n input,\n output,\n} from '@angular/core';\nimport { provideToggleState, toggleState } from './toggle-state';\n\n/**\n * Apply the `ngpToggle` directive to an element to manage the toggle state. This must be applied to a `button` element.\n */\n@Directive({\n selector: '[ngpToggle]',\n exportAs: 'ngpToggle',\n providers: [provideToggleState()],\n host: {\n '[attr.type]': 'isButton ? \"button\" : null',\n '[attr.aria-pressed]': 'state.selected()',\n '[attr.data-selected]': 'state.selected() ? \"\" : null',\n '[attr.data-disabled]': 'state.disabled() ? \"\" : null',\n },\n})\nexport class NgpToggle {\n /**\n * Access the element.\n */\n private readonly element = inject<ElementRef<HTMLElement>>(ElementRef);\n\n /**\n * Whether the toggle is selected.\n * @default false\n */\n readonly selected = input<boolean, BooleanInput>(false, {\n alias: 'ngpToggleSelected',\n transform: booleanAttribute,\n });\n\n /**\n * Emits when the selected state changes.\n */\n readonly selectedChange = output<boolean>({\n alias: 'ngpToggleSelectedChange',\n });\n\n /**\n * Whether the toggle is disabled.\n * @default false\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpToggleDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * Determine if the element is a button.\n */\n protected isButton = this.element.nativeElement.tagName === 'BUTTON';\n\n /**\n * The state for the toggle primitive.\n * @internal\n */\n protected readonly state = toggleState<NgpToggle>(this);\n\n /**\n * Toggle the selected state.\n */\n @HostListener('click')\n toggle(): void {\n if (this.state.disabled()) {\n return;\n }\n\n const isSelected = !this.state.selected();\n\n this.state.selected.set(isSelected);\n this.selectedChange.emit(isSelected);\n }\n\n /**\n * If the element is not a button or a link the space key should toggle the selected state.\n */\n @HostListener('keydown.space', ['$event'])\n protected onKeyDown(event: KeyboardEvent): void {\n if (!this.isButton && this.element.nativeElement.tagName !== 'A') {\n event.preventDefault();\n this.toggle();\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;AAQA;;AAEG;AACI,MAAM,mBAAmB,GAAG,gBAAgB,CAAY,QAAQ,CAAC;AAExE;;AAEG;MACU,kBAAkB,GAAG,mBAAmB,CAAC,mBAAmB;AAEzE;;AAEG;MACU,iBAAiB,GAAG,mBAAmB,CAAY,mBAAmB;AAEnF;;AAEG;AACI,MAAM,WAAW,GAAG,WAAW,CAAC,mBAAmB,CAAC;;ACd3D;;AAEG;MAYU,SAAS,CAAA;AAXtB,IAAA,WAAA,GAAA;AAYE;;AAEG;AACc,QAAA,IAAA,CAAA,OAAO,GAAG,MAAM,CAA0B,UAAU,CAAC;AAEtE;;;AAGG;AACM,QAAA,IAAA,CAAA,QAAQ,GAAG,KAAK,CAAwB,KAAK,EAAE;AACtD,YAAA,KAAK,EAAE,mBAAmB;AAC1B,YAAA,SAAS,EAAE,gBAAgB;AAC5B,SAAA,CAAC;AAEF;;AAEG;QACM,IAAA,CAAA,cAAc,GAAG,MAAM,CAAU;AACxC,YAAA,KAAK,EAAE,yBAAyB;AACjC,SAAA,CAAC;AAEF;;;AAGG;AACM,QAAA,IAAA,CAAA,QA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mjs","sources":["../../../../packages/ng-primitives/toolbar/src/toolbar/toolbar-state.ts","../../../../packages/ng-primitives/toolbar/src/toolbar/toolbar.ts","../../../../packages/ng-primitives/toolbar/src/ng-primitives-toolbar.ts"],"sourcesContent":["import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n} from 'ng-primitives/state';\nimport type { NgpToolbar } from './toolbar';\n\n/**\n * The state token for the Toolbar primitive.\n */\nexport const NgpToolbarStateToken = createStateToken<NgpToolbar>('Toolbar');\n\n/**\n * Provides the Toolbar state.\n */\nexport const provideToolbarState = createStateProvider(NgpToolbarStateToken);\n\n/**\n * Injects the Toolbar state.\n */\nexport const injectToolbarState = createStateInjector<NgpToolbar>(NgpToolbarStateToken);\n\n/**\n * The Toolbar state registration function.\n */\nexport const toolbarState = createState(NgpToolbarStateToken);\n","import { Directive, input } from '@angular/core';\nimport { NgpOrientation } from 'ng-primitives/common';\nimport { explicitEffect } from 'ng-primitives/internal';\nimport { injectRovingFocusGroupState, NgpRovingFocusGroup } from 'ng-primitives/roving-focus';\nimport { provideToolbarState, toolbarState } from './toolbar-state';\n\n@Directive({\n selector: '[ngpToolbar]',\n exportAs: 'ngpToolbar',\n providers: [provideToolbarState()],\n hostDirectives: [NgpRovingFocusGroup],\n host: {\n role: 'toolbar',\n '[attr.aria-orientation]': 'state.orientation()',\n '[attr.data-orientation]': 'state.orientation()',\n },\n})\nexport class NgpToolbar {\n /**\n * Access the roving focus group state.\n */\n private readonly rovingFocusGroup = injectRovingFocusGroupState();\n\n /**\n * The orientation of the toolbar.\n */\n readonly orientation = input<NgpOrientation>('horizontal', {\n alias: 'ngpToolbarOrientation',\n });\n\n /**\n * The toolbar state.\n */\n protected readonly state = toolbarState<NgpToolbar>(this);\n\n constructor() {\n explicitEffect([this.state.orientation], ([orientation]) =>\n this.rovingFocusGroup().orientation.set(orientation),\n );\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAQA;;AAEG;AACI,MAAM,oBAAoB,GAAG,gBAAgB,CAAa,SAAS,CAAC;AAE3E;;AAEG;MACU,mBAAmB,GAAG,mBAAmB,CAAC,oBAAoB;AAE3E;;AAEG;MACU,kBAAkB,GAAG,mBAAmB,CAAa,oBAAoB;AAEtF;;AAEG;AACI,MAAM,YAAY,GAAG,WAAW,CAAC,oBAAoB,CAAC;;MCThD,UAAU,CAAA;AAkBrB,IAAA,WAAA,GAAA;AAjBA;;AAEG;QACc,
|
|
1
|
+
{"version":3,"file":"ng-primitives-toolbar.mjs","sources":["../../../../packages/ng-primitives/toolbar/src/toolbar/toolbar-state.ts","../../../../packages/ng-primitives/toolbar/src/toolbar/toolbar.ts","../../../../packages/ng-primitives/toolbar/src/ng-primitives-toolbar.ts"],"sourcesContent":["import {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n} from 'ng-primitives/state';\nimport type { NgpToolbar } from './toolbar';\n\n/**\n * The state token for the Toolbar primitive.\n */\nexport const NgpToolbarStateToken = createStateToken<NgpToolbar>('Toolbar');\n\n/**\n * Provides the Toolbar state.\n */\nexport const provideToolbarState = createStateProvider(NgpToolbarStateToken);\n\n/**\n * Injects the Toolbar state.\n */\nexport const injectToolbarState = createStateInjector<NgpToolbar>(NgpToolbarStateToken);\n\n/**\n * The Toolbar state registration function.\n */\nexport const toolbarState = createState(NgpToolbarStateToken);\n","import { Directive, input } from '@angular/core';\nimport { NgpOrientation } from 'ng-primitives/common';\nimport { explicitEffect } from 'ng-primitives/internal';\nimport { injectRovingFocusGroupState, NgpRovingFocusGroup } from 'ng-primitives/roving-focus';\nimport { provideToolbarState, toolbarState } from './toolbar-state';\n\n@Directive({\n selector: '[ngpToolbar]',\n exportAs: 'ngpToolbar',\n providers: [provideToolbarState()],\n hostDirectives: [NgpRovingFocusGroup],\n host: {\n role: 'toolbar',\n '[attr.aria-orientation]': 'state.orientation()',\n '[attr.data-orientation]': 'state.orientation()',\n },\n})\nexport class NgpToolbar {\n /**\n * Access the roving focus group state.\n */\n private readonly rovingFocusGroup = injectRovingFocusGroupState();\n\n /**\n * The orientation of the toolbar.\n */\n readonly orientation = input<NgpOrientation>('horizontal', {\n alias: 'ngpToolbarOrientation',\n });\n\n /**\n * The toolbar state.\n */\n protected readonly state = toolbarState<NgpToolbar>(this);\n\n constructor() {\n explicitEffect([this.state.orientation], ([orientation]) =>\n this.rovingFocusGroup().orientation.set(orientation),\n );\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AAQA;;AAEG;AACI,MAAM,oBAAoB,GAAG,gBAAgB,CAAa,SAAS,CAAC;AAE3E;;AAEG;MACU,mBAAmB,GAAG,mBAAmB,CAAC,oBAAoB;AAE3E;;AAEG;MACU,kBAAkB,GAAG,mBAAmB,CAAa,oBAAoB;AAEtF;;AAEG;AACI,MAAM,YAAY,GAAG,WAAW,CAAC,oBAAoB,CAAC;;MCThD,UAAU,CAAA;AAkBrB,IAAA,WAAA,GAAA;AAjBA;;AAEG;QACc,IAAA,CAAA,gBAAgB,GAAG,2BAA2B,EAAE;AAEjE;;AAEG;AACM,QAAA,IAAA,CAAA,WAAW,GAAG,KAAK,CAAiB,YAAY,EAAE;AACzD,YAAA,KAAK,EAAE,uBAAuB;AAC/B,SAAA,CAAC;AAEF;;AAEG;AACgB,QAAA,IAAA,CAAA,KAAK,GAAG,YAAY,CAAa,IAAI,CAAC;AAGvD,QAAA,cAAc,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,WAAW,CAAC,KACrD,IAAI,CAAC,gBAAgB,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,WAAW,CAAC,CACrD;IACH;+GAtBW,UAAU,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA,CAAA;AAAV,IAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,IAAA,EAAA,UAAU,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,cAAA,EAAA,MAAA,EAAA,EAAA,WAAA,EAAA,EAAA,iBAAA,EAAA,aAAA,EAAA,UAAA,EAAA,uBAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,IAAA,EAAA,EAAA,UAAA,EAAA,EAAA,MAAA,EAAA,SAAA,EAAA,EAAA,UAAA,EAAA,EAAA,uBAAA,EAAA,qBAAA,EAAA,uBAAA,EAAA,qBAAA,EAAA,EAAA,EAAA,SAAA,EARV,CAAC,mBAAmB,EAAE,CAAC,EAAA,QAAA,EAAA,CAAA,YAAA,CAAA,EAAA,cAAA,EAAA,CAAA,EAAA,SAAA,EAAA,EAAA,CAAA,mBAAA,EAAA,CAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;;4FAQvB,UAAU,EAAA,UAAA,EAAA,CAAA;kBAXtB,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,cAAc;AACxB,oBAAA,QAAQ,EAAE,YAAY;AACtB,oBAAA,SAAS,EAAE,CAAC,mBAAmB,EAAE,CAAC;oBAClC,cAAc,EAAE,CAAC,mBAAmB,CAAC;AACrC,oBAAA,IAAI,EAAE;AACJ,wBAAA,IAAI,EAAE,SAAS;AACf,wBAAA,yBAAyB,EAAE,qBAAqB;AAChD,wBAAA,yBAAyB,EAAE,qBAAqB;AACjD,qBAAA;AACF,iBAAA;;;AChBD;;AAEG;;;;"}
|
|
@@ -2,6 +2,7 @@ import { createOverlay, injectOverlay, setupOverlayArrow } from 'ng-primitives/p
|
|
|
2
2
|
export { injectOverlayContext as injectTooltipContext } from 'ng-primitives/portal';
|
|
3
3
|
import * as i0 from '@angular/core';
|
|
4
4
|
import { InjectionToken, inject, ElementRef, Injector, ViewContainerRef, input, booleanAttribute, numberAttribute, signal, computed, Directive } from '@angular/core';
|
|
5
|
+
import { setupOverflowListener } from 'ng-primitives/internal';
|
|
5
6
|
import { createStateToken, createStateProvider, createStateInjector, createState } from 'ng-primitives/state';
|
|
6
7
|
|
|
7
8
|
const defaultTooltipConfig = {
|
|
@@ -11,6 +12,7 @@ const defaultTooltipConfig = {
|
|
|
11
12
|
hideDelay: 0,
|
|
12
13
|
flip: true,
|
|
13
14
|
container: null,
|
|
15
|
+
showOnOverflow: false,
|
|
14
16
|
};
|
|
15
17
|
const NgpTooltipConfigToken = new InjectionToken('NgpTooltipConfigToken');
|
|
16
18
|
/**
|
|
@@ -132,6 +134,14 @@ class NgpTooltipTrigger {
|
|
|
132
134
|
this.container = input(this.config.container, {
|
|
133
135
|
alias: 'ngpTooltipTriggerContainer',
|
|
134
136
|
});
|
|
137
|
+
/**
|
|
138
|
+
* Define whether the tooltip should only show when the trigger element overflows.
|
|
139
|
+
* @default false
|
|
140
|
+
*/
|
|
141
|
+
this.showOnOverflow = input(this.config.showOnOverflow, {
|
|
142
|
+
alias: 'ngpTooltipTriggerShowOnOverflow',
|
|
143
|
+
transform: booleanAttribute,
|
|
144
|
+
});
|
|
135
145
|
/**
|
|
136
146
|
* Provide context to the tooltip. This can be used to pass data to the tooltip content.
|
|
137
147
|
*/
|
|
@@ -153,6 +163,9 @@ class NgpTooltipTrigger {
|
|
|
153
163
|
* @internal
|
|
154
164
|
*/
|
|
155
165
|
this.state = tooltipTriggerState(this);
|
|
166
|
+
this.hasOverflow = setupOverflowListener(this.trigger.nativeElement, {
|
|
167
|
+
disabled: computed(() => !this.state.showOnOverflow()),
|
|
168
|
+
});
|
|
156
169
|
}
|
|
157
170
|
ngOnDestroy() {
|
|
158
171
|
this.overlay()?.destroy();
|
|
@@ -165,6 +178,11 @@ class NgpTooltipTrigger {
|
|
|
165
178
|
if (this.state.disabled() || this.open()) {
|
|
166
179
|
return;
|
|
167
180
|
}
|
|
181
|
+
// if we should only show when there is overflow, check if the trigger has overflow
|
|
182
|
+
if (this.state.showOnOverflow() && !this.hasOverflow()) {
|
|
183
|
+
// If the trigger does not have overflow, do not show the tooltip
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
168
186
|
// Create the overlay if it doesn't exist yet
|
|
169
187
|
if (!this.overlay()) {
|
|
170
188
|
this.createOverlay();
|
|
@@ -209,7 +227,7 @@ class NgpTooltipTrigger {
|
|
|
209
227
|
this.overlay.set(createOverlay(config));
|
|
210
228
|
}
|
|
211
229
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: NgpTooltipTrigger, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
212
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.11", type: NgpTooltipTrigger, isStandalone: true, selector: "[ngpTooltipTrigger]", inputs: { tooltip: { classPropertyName: "tooltip", publicName: "ngpTooltipTrigger", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "ngpTooltipTriggerDisabled", isSignal: true, isRequired: false, transformFunction: null }, placement: { classPropertyName: "placement", publicName: "ngpTooltipTriggerPlacement", isSignal: true, isRequired: false, transformFunction: null }, offset: { classPropertyName: "offset", publicName: "ngpTooltipTriggerOffset", isSignal: true, isRequired: false, transformFunction: null }, showDelay: { classPropertyName: "showDelay", publicName: "ngpTooltipTriggerShowDelay", isSignal: true, isRequired: false, transformFunction: null }, hideDelay: { classPropertyName: "hideDelay", publicName: "ngpTooltipTriggerHideDelay", isSignal: true, isRequired: false, transformFunction: null }, flip: { classPropertyName: "flip", publicName: "ngpTooltipTriggerFlip", isSignal: true, isRequired: false, transformFunction: null }, container: { classPropertyName: "container", publicName: "ngpTooltipTriggerContainer", isSignal: true, isRequired: false, transformFunction: null }, context: { classPropertyName: "context", publicName: "ngpTooltipTriggerContext", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "mouseenter": "show()", "mouseleave": "hide()", "focus": "show()", "blur": "hide()" }, properties: { "attr.data-open": "open() ? \"\" : null", "attr.data-disabled": "state.disabled() ? \"\" : null" } }, providers: [provideTooltipTriggerState()], exportAs: ["ngpTooltipTrigger"], ngImport: i0 }); }
|
|
230
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "19.2.11", type: NgpTooltipTrigger, isStandalone: true, selector: "[ngpTooltipTrigger]", inputs: { tooltip: { classPropertyName: "tooltip", publicName: "ngpTooltipTrigger", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "ngpTooltipTriggerDisabled", isSignal: true, isRequired: false, transformFunction: null }, placement: { classPropertyName: "placement", publicName: "ngpTooltipTriggerPlacement", isSignal: true, isRequired: false, transformFunction: null }, offset: { classPropertyName: "offset", publicName: "ngpTooltipTriggerOffset", isSignal: true, isRequired: false, transformFunction: null }, showDelay: { classPropertyName: "showDelay", publicName: "ngpTooltipTriggerShowDelay", isSignal: true, isRequired: false, transformFunction: null }, hideDelay: { classPropertyName: "hideDelay", publicName: "ngpTooltipTriggerHideDelay", isSignal: true, isRequired: false, transformFunction: null }, flip: { classPropertyName: "flip", publicName: "ngpTooltipTriggerFlip", isSignal: true, isRequired: false, transformFunction: null }, container: { classPropertyName: "container", publicName: "ngpTooltipTriggerContainer", isSignal: true, isRequired: false, transformFunction: null }, showOnOverflow: { classPropertyName: "showOnOverflow", publicName: "ngpTooltipTriggerShowOnOverflow", isSignal: true, isRequired: false, transformFunction: null }, context: { classPropertyName: "context", publicName: "ngpTooltipTriggerContext", isSignal: true, isRequired: false, transformFunction: null } }, host: { listeners: { "mouseenter": "show()", "mouseleave": "hide()", "focus": "show()", "blur": "hide()" }, properties: { "attr.data-open": "open() ? \"\" : null", "attr.data-disabled": "state.disabled() ? \"\" : null" } }, providers: [provideTooltipTriggerState()], exportAs: ["ngpTooltipTrigger"], ngImport: i0 }); }
|
|
213
231
|
}
|
|
214
232
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: NgpTooltipTrigger, decorators: [{
|
|
215
233
|
type: Directive,
|
|
@@ -226,7 +244,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.11", ngImpo
|
|
|
226
244
|
'(blur)': 'hide()',
|
|
227
245
|
},
|
|
228
246
|
}]
|
|
229
|
-
}] });
|
|
247
|
+
}], ctorParameters: () => [] });
|
|
230
248
|
|
|
231
249
|
/**
|
|
232
250
|
* Apply the `ngpTooltip` directive to an element that represents the tooltip. This typically would be a `div` inside an `ng-template`.
|
|
@@ -239,7 +257,7 @@ class NgpTooltip {
|
|
|
239
257
|
this.overlay = injectOverlay();
|
|
240
258
|
}
|
|
241
259
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: NgpTooltip, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
242
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.11", type: NgpTooltip, isStandalone: true, selector: "[ngpTooltip]", host: { attributes: { "role": "tooltip" }, properties: { "style.left.px": "overlay.position().x", "style.top.px": "overlay.position().y", "style.--ngp-tooltip-trigger-width.px": "overlay.triggerWidth()", "style.--ngp-tooltip-transform-origin": "overlay.transformOrigin()" } }, exportAs: ["ngpTooltip"], ngImport: i0 }); }
|
|
260
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.11", type: NgpTooltip, isStandalone: true, selector: "[ngpTooltip]", host: { attributes: { "role": "tooltip" }, properties: { "style.left.px": "overlay.position().x", "style.top.px": "overlay.position().y", "style.--ngp-tooltip-trigger-width.px": "overlay.triggerWidth()", "style.--ngp-tooltip-transform-origin": "overlay.transformOrigin()", "attr.data-placement": "overlay.finalPlacement()" } }, exportAs: ["ngpTooltip"], ngImport: i0 }); }
|
|
243
261
|
}
|
|
244
262
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.11", ngImport: i0, type: NgpTooltip, decorators: [{
|
|
245
263
|
type: Directive,
|
|
@@ -252,6 +270,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.11", ngImpo
|
|
|
252
270
|
'[style.top.px]': 'overlay.position().y',
|
|
253
271
|
'[style.--ngp-tooltip-trigger-width.px]': 'overlay.triggerWidth()',
|
|
254
272
|
'[style.--ngp-tooltip-transform-origin]': 'overlay.transformOrigin()',
|
|
273
|
+
'[attr.data-placement]': 'overlay.finalPlacement()',
|
|
255
274
|
},
|
|
256
275
|
}]
|
|
257
276
|
}] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-primitives-tooltip.mjs","sources":["../../../../packages/ng-primitives/tooltip/src/config/tooltip-config.ts","../../../../packages/ng-primitives/tooltip/src/tooltip-trigger/tooltip-trigger-state.ts","../../../../packages/ng-primitives/tooltip/src/tooltip-trigger/tooltip-trigger.ts","../../../../packages/ng-primitives/tooltip/src/tooltip/tooltip.ts","../../../../packages/ng-primitives/tooltip/src/tooltip-arrow/tooltip-arrow.ts","../../../../packages/ng-primitives/tooltip/src/ng-primitives-tooltip.ts"],"sourcesContent":["import { InjectionToken, Provider, inject } from '@angular/core';\nimport { type Placement } from '@floating-ui/dom';\n\nexport interface NgpTooltipConfig {\n /**\n * Define the offset of the tooltip relative to the trigger.\n * @default 4\n */\n offset: number;\n\n /**\n * Define the placement of the tooltip relative to the trigger.\n * @default 'top'\n */\n placement: Placement;\n\n /**\n * Define the delay before the tooltip is shown.\n * @default 0\n */\n showDelay: number;\n\n /**\n * Define the delay before the tooltip is hidden.\n * @default 0\n */\n hideDelay: number;\n\n /**\n * Define whether the tooltip should flip when there is not enough space for the tooltip.\n * @default true\n */\n flip: boolean;\n\n /**\n * Define the container in to which the tooltip should be attached.\n * @default document.body\n */\n container: HTMLElement | null;\n}\n\nexport const defaultTooltipConfig: NgpTooltipConfig = {\n offset: 4,\n placement: 'top',\n showDelay: 0,\n hideDelay: 0,\n flip: true,\n container: null,\n};\n\nexport const NgpTooltipConfigToken = new InjectionToken<NgpTooltipConfig>('NgpTooltipConfigToken');\n\n/**\n * Provide the default Tooltip configuration\n * @param config The Tooltip configuration\n * @returns The provider\n */\nexport function provideTooltipConfig(config: Partial<NgpTooltipConfig>): Provider[] {\n return [\n {\n provide: NgpTooltipConfigToken,\n useValue: { ...defaultTooltipConfig, ...config },\n },\n ];\n}\n\n/**\n * Inject the Tooltip configuration\n * @returns The global Tooltip configuration\n */\nexport function injectTooltipConfig(): NgpTooltipConfig {\n return inject(NgpTooltipConfigToken, { optional: true }) ?? defaultTooltipConfig;\n}\n","import { Signal } from '@angular/core';\nimport {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n State,\n} from 'ng-primitives/state';\nimport type { NgpTooltipTrigger } from './tooltip-trigger';\n\n/**\n * The state token for the TooltipTrigger primitive.\n */\nexport const NgpTooltipTriggerStateToken =\n createStateToken<NgpTooltipTrigger<unknown>>('TooltipTrigger');\n\n/**\n * Provides the TooltipTrigger state.\n */\nexport const provideTooltipTriggerState = createStateProvider(NgpTooltipTriggerStateToken);\n\n/**\n * Injects the TooltipTrigger state.\n */\nexport const injectTooltipTriggerState = createStateInjector<NgpTooltipTrigger<unknown>>(\n NgpTooltipTriggerStateToken,\n);\n\n/**\n * The TooltipTrigger state registration function.\n */\nexport const tooltipTriggerState = createState(NgpTooltipTriggerStateToken);\n","import { BooleanInput, NumberInput } from '@angular/cdk/coercion';\nimport {\n booleanAttribute,\n computed,\n Directive,\n ElementRef,\n inject,\n Injector,\n input,\n numberAttribute,\n OnDestroy,\n signal,\n ViewContainerRef,\n} from '@angular/core';\nimport { Placement } from '@floating-ui/dom';\nimport {\n createOverlay,\n NgpOverlay,\n NgpOverlayConfig,\n NgpOverlayContent,\n} from 'ng-primitives/portal';\nimport { injectTooltipConfig } from '../config/tooltip-config';\nimport { provideTooltipTriggerState, tooltipTriggerState } from './tooltip-trigger-state';\n\n/**\n * Apply the `ngpTooltipTrigger` directive to an element that triggers the tooltip to show.\n */\n@Directive({\n selector: '[ngpTooltipTrigger]',\n exportAs: 'ngpTooltipTrigger',\n providers: [provideTooltipTriggerState()],\n host: {\n '[attr.data-open]': 'open() ? \"\" : null',\n '[attr.data-disabled]': 'state.disabled() ? \"\" : null',\n '(mouseenter)': 'show()',\n '(mouseleave)': 'hide()',\n '(focus)': 'show()',\n '(blur)': 'hide()',\n },\n})\nexport class NgpTooltipTrigger<T = null> implements OnDestroy {\n /**\n * Access the trigger element\n */\n private readonly trigger = inject(ElementRef<HTMLElement>);\n\n /**\n * Access the injector.\n */\n private readonly injector = inject(Injector);\n\n /**\n * Access the view container reference.\n */\n private readonly viewContainerRef = inject(ViewContainerRef);\n\n /**\n * Access the global tooltip configuration.\n */\n private readonly config = injectTooltipConfig();\n\n /**\n * Access the tooltip template ref.\n */\n readonly tooltip = input<NgpOverlayContent<T>>(undefined, {\n alias: 'ngpTooltipTrigger',\n });\n\n /**\n * Define if the trigger should be disabled.\n * @default false\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpTooltipTriggerDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * Define the placement of the tooltip relative to the trigger.\n * @default 'top'\n */\n readonly placement = input<Placement>(this.config.placement, {\n alias: 'ngpTooltipTriggerPlacement',\n });\n\n /**\n * Define the offset of the tooltip relative to the trigger.\n * @default 0\n */\n readonly offset = input<number, NumberInput>(this.config.offset, {\n alias: 'ngpTooltipTriggerOffset',\n transform: numberAttribute,\n });\n\n /**\n * Define the delay before the tooltip is displayed.\n * @default 0\n */\n readonly showDelay = input<number, NumberInput>(this.config.showDelay, {\n alias: 'ngpTooltipTriggerShowDelay',\n transform: numberAttribute,\n });\n\n /**\n * Define the delay before the tooltip is hidden.\n * @default 0\n */\n readonly hideDelay = input<number, NumberInput>(this.config.hideDelay, {\n alias: 'ngpTooltipTriggerHideDelay',\n transform: numberAttribute,\n });\n\n /**\n * Define whether the tooltip should flip when there is not enough space for the tooltip.\n * @default true\n */\n readonly flip = input<boolean, BooleanInput>(this.config.flip, {\n alias: 'ngpTooltipTriggerFlip',\n transform: booleanAttribute,\n });\n\n /**\n * Define the container in which the tooltip should be attached.\n * @default document.body\n */\n readonly container = input<HTMLElement | null>(this.config.container, {\n alias: 'ngpTooltipTriggerContainer',\n });\n\n /**\n * Provide context to the tooltip. This can be used to pass data to the tooltip content.\n */\n readonly context = input<T>(undefined, {\n alias: 'ngpTooltipTriggerContext',\n });\n\n /**\n * The overlay that manages the tooltip\n * @internal\n */\n readonly overlay = signal<NgpOverlay<T> | null>(null);\n\n /**\n * The open state of the tooltip.\n * @internal\n */\n readonly open = computed(() => this.overlay()?.isOpen() ?? false);\n\n /**\n * Store the state of the tooltip.\n * @internal\n */\n readonly state = tooltipTriggerState<NgpTooltipTrigger<T>>(this);\n\n ngOnDestroy(): void {\n this.overlay()?.destroy();\n }\n\n /**\n * Show the tooltip.\n */\n show(): void {\n // If the trigger is disabled, do not show the tooltip\n if (this.state.disabled() || this.open()) {\n return;\n }\n\n // Create the overlay if it doesn't exist yet\n if (!this.overlay()) {\n this.createOverlay();\n }\n\n this.overlay()?.show();\n }\n\n /**\n * Hide the tooltip.\n */\n hide(): void {\n // If the trigger is disabled, do nothing\n if (this.state.disabled()) {\n return;\n }\n\n this.overlay()?.hide();\n }\n\n /**\n * Create the overlay that will contain the tooltip\n */\n private createOverlay(): void {\n const tooltip = this.state.tooltip();\n\n if (!tooltip) {\n throw new Error('Tooltip must be either a TemplateRef or a ComponentType');\n }\n\n // Create config for the overlay\n const config: NgpOverlayConfig<T> = {\n content: tooltip,\n triggerElement: this.trigger.nativeElement,\n injector: this.injector,\n context: this.state.context,\n container: this.state.container(),\n placement: this.state.placement(),\n offset: this.state.offset(),\n flip: this.state.flip(),\n showDelay: this.state.showDelay(),\n hideDelay: this.state.hideDelay(),\n closeOnEscape: true,\n closeOnOutsideClick: true,\n viewContainerRef: this.viewContainerRef,\n };\n\n // Create the overlay instance\n this.overlay.set(createOverlay(config));\n }\n}\n","import { Directive } from '@angular/core';\nimport { injectOverlay } from 'ng-primitives/portal';\n\n/**\n * Apply the `ngpTooltip` directive to an element that represents the tooltip. This typically would be a `div` inside an `ng-template`.\n */\n@Directive({\n selector: '[ngpTooltip]',\n exportAs: 'ngpTooltip',\n host: {\n role: 'tooltip',\n '[style.left.px]': 'overlay.position().x',\n '[style.top.px]': 'overlay.position().y',\n '[style.--ngp-tooltip-trigger-width.px]': 'overlay.triggerWidth()',\n '[style.--ngp-tooltip-transform-origin]': 'overlay.transformOrigin()',\n },\n})\nexport class NgpTooltip {\n /**\n * Access the overlay.\n */\n protected readonly overlay = injectOverlay();\n}\n","import { Directive } from '@angular/core';\nimport { setupOverlayArrow } from 'ng-primitives/portal';\n\n@Directive({\n selector: '[ngpTooltipArrow]',\n exportAs: 'ngpTooltipArrow',\n})\nexport class NgpTooltipArrow {\n constructor() {\n setupOverlayArrow();\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAyCO,MAAM,oBAAoB,GAAqB;AACpD,IAAA,MAAM,EAAE,CAAC;AACT,IAAA,SAAS,EAAE,KAAK;AAChB,IAAA,SAAS,EAAE,CAAC;AACZ,IAAA,SAAS,EAAE,CAAC;AACZ,IAAA,IAAI,EAAE,IAAI;AACV,IAAA,SAAS,EAAE,IAAI;CAChB;AAEM,MAAM,qBAAqB,GAAG,IAAI,cAAc,CAAmB,uBAAuB,CAAC;AAElG;;;;AAIG;AACG,SAAU,oBAAoB,CAAC,MAAiC,EAAA;IACpE,OAAO;AACL,QAAA;AACE,YAAA,OAAO,EAAE,qBAAqB;AAC9B,YAAA,QAAQ,EAAE,EAAE,GAAG,oBAAoB,EAAE,GAAG,MAAM,EAAE;AACjD,SAAA;KACF;AACH;AAEA;;;AAG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AAA,CAAA,SAAA,EAAA,CAAA,CAAA;mGAAf,eAAe,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,mBAAA,EAAA,QAAA,EAAA,CAAA,iBAAA,CAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;;4FAAf,eAAe,EAAA,UAAA,EAAA,CAAA;kBAJ3B,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,mBAAmB;AAC7B,oBAAA,QAAQ,EAAE,iBAAiB;AAC5B,iBAAA;;;ACND;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ng-primitives-tooltip.mjs","sources":["../../../../packages/ng-primitives/tooltip/src/config/tooltip-config.ts","../../../../packages/ng-primitives/tooltip/src/tooltip-trigger/tooltip-trigger-state.ts","../../../../packages/ng-primitives/tooltip/src/tooltip-trigger/tooltip-trigger.ts","../../../../packages/ng-primitives/tooltip/src/tooltip/tooltip.ts","../../../../packages/ng-primitives/tooltip/src/tooltip-arrow/tooltip-arrow.ts","../../../../packages/ng-primitives/tooltip/src/ng-primitives-tooltip.ts"],"sourcesContent":["import { InjectionToken, Provider, inject } from '@angular/core';\nimport { type Placement } from '@floating-ui/dom';\n\nexport interface NgpTooltipConfig {\n /**\n * Define the offset of the tooltip relative to the trigger.\n * @default 4\n */\n offset: number;\n\n /**\n * Define the placement of the tooltip relative to the trigger.\n * @default 'top'\n */\n placement: Placement;\n\n /**\n * Define the delay before the tooltip is shown.\n * @default 0\n */\n showDelay: number;\n\n /**\n * Define the delay before the tooltip is hidden.\n * @default 0\n */\n hideDelay: number;\n\n /**\n * Define whether the tooltip should flip when there is not enough space for the tooltip.\n * @default true\n */\n flip: boolean;\n\n /**\n * Define the container in to which the tooltip should be attached.\n * @default document.body\n */\n container: HTMLElement | null;\n\n /**\n * Whether the tooltip should only show when the trigger element overflows.\n * @default false\n */\n showOnOverflow: boolean;\n}\n\nexport const defaultTooltipConfig: NgpTooltipConfig = {\n offset: 4,\n placement: 'top',\n showDelay: 0,\n hideDelay: 0,\n flip: true,\n container: null,\n showOnOverflow: false,\n};\n\nexport const NgpTooltipConfigToken = new InjectionToken<NgpTooltipConfig>('NgpTooltipConfigToken');\n\n/**\n * Provide the default Tooltip configuration\n * @param config The Tooltip configuration\n * @returns The provider\n */\nexport function provideTooltipConfig(config: Partial<NgpTooltipConfig>): Provider[] {\n return [\n {\n provide: NgpTooltipConfigToken,\n useValue: { ...defaultTooltipConfig, ...config },\n },\n ];\n}\n\n/**\n * Inject the Tooltip configuration\n * @returns The global Tooltip configuration\n */\nexport function injectTooltipConfig(): NgpTooltipConfig {\n return inject(NgpTooltipConfigToken, { optional: true }) ?? defaultTooltipConfig;\n}\n","import { Signal } from '@angular/core';\nimport {\n createState,\n createStateInjector,\n createStateProvider,\n createStateToken,\n State,\n} from 'ng-primitives/state';\nimport type { NgpTooltipTrigger } from './tooltip-trigger';\n\n/**\n * The state token for the TooltipTrigger primitive.\n */\nexport const NgpTooltipTriggerStateToken =\n createStateToken<NgpTooltipTrigger<unknown>>('TooltipTrigger');\n\n/**\n * Provides the TooltipTrigger state.\n */\nexport const provideTooltipTriggerState = createStateProvider(NgpTooltipTriggerStateToken);\n\n/**\n * Injects the TooltipTrigger state.\n */\nexport const injectTooltipTriggerState = createStateInjector<NgpTooltipTrigger<unknown>>(\n NgpTooltipTriggerStateToken,\n);\n\n/**\n * The TooltipTrigger state registration function.\n */\nexport const tooltipTriggerState = createState(NgpTooltipTriggerStateToken);\n","import { BooleanInput, NumberInput } from '@angular/cdk/coercion';\nimport {\n booleanAttribute,\n computed,\n Directive,\n ElementRef,\n inject,\n Injector,\n input,\n numberAttribute,\n OnDestroy,\n Signal,\n signal,\n ViewContainerRef,\n} from '@angular/core';\nimport { Placement } from '@floating-ui/dom';\nimport { setupOverflowListener } from 'ng-primitives/internal';\nimport {\n createOverlay,\n NgpOverlay,\n NgpOverlayConfig,\n NgpOverlayContent,\n} from 'ng-primitives/portal';\nimport { injectTooltipConfig } from '../config/tooltip-config';\nimport { provideTooltipTriggerState, tooltipTriggerState } from './tooltip-trigger-state';\n\n/**\n * Apply the `ngpTooltipTrigger` directive to an element that triggers the tooltip to show.\n */\n@Directive({\n selector: '[ngpTooltipTrigger]',\n exportAs: 'ngpTooltipTrigger',\n providers: [provideTooltipTriggerState()],\n host: {\n '[attr.data-open]': 'open() ? \"\" : null',\n '[attr.data-disabled]': 'state.disabled() ? \"\" : null',\n '(mouseenter)': 'show()',\n '(mouseleave)': 'hide()',\n '(focus)': 'show()',\n '(blur)': 'hide()',\n },\n})\nexport class NgpTooltipTrigger<T = null> implements OnDestroy {\n /**\n * Access the trigger element\n */\n private readonly trigger = inject(ElementRef<HTMLElement>);\n\n /**\n * Access the injector.\n */\n private readonly injector = inject(Injector);\n\n /**\n * Access the view container reference.\n */\n private readonly viewContainerRef = inject(ViewContainerRef);\n\n /**\n * Access the global tooltip configuration.\n */\n private readonly config = injectTooltipConfig();\n\n /**\n * Access the tooltip template ref.\n */\n readonly tooltip = input<NgpOverlayContent<T>>(undefined, {\n alias: 'ngpTooltipTrigger',\n });\n\n /**\n * Define if the trigger should be disabled.\n * @default false\n */\n readonly disabled = input<boolean, BooleanInput>(false, {\n alias: 'ngpTooltipTriggerDisabled',\n transform: booleanAttribute,\n });\n\n /**\n * Define the placement of the tooltip relative to the trigger.\n * @default 'top'\n */\n readonly placement = input<Placement>(this.config.placement, {\n alias: 'ngpTooltipTriggerPlacement',\n });\n\n /**\n * Define the offset of the tooltip relative to the trigger.\n * @default 0\n */\n readonly offset = input<number, NumberInput>(this.config.offset, {\n alias: 'ngpTooltipTriggerOffset',\n transform: numberAttribute,\n });\n\n /**\n * Define the delay before the tooltip is displayed.\n * @default 0\n */\n readonly showDelay = input<number, NumberInput>(this.config.showDelay, {\n alias: 'ngpTooltipTriggerShowDelay',\n transform: numberAttribute,\n });\n\n /**\n * Define the delay before the tooltip is hidden.\n * @default 0\n */\n readonly hideDelay = input<number, NumberInput>(this.config.hideDelay, {\n alias: 'ngpTooltipTriggerHideDelay',\n transform: numberAttribute,\n });\n\n /**\n * Define whether the tooltip should flip when there is not enough space for the tooltip.\n * @default true\n */\n readonly flip = input<boolean, BooleanInput>(this.config.flip, {\n alias: 'ngpTooltipTriggerFlip',\n transform: booleanAttribute,\n });\n\n /**\n * Define the container in which the tooltip should be attached.\n * @default document.body\n */\n readonly container = input<HTMLElement | null>(this.config.container, {\n alias: 'ngpTooltipTriggerContainer',\n });\n\n /**\n * Define whether the tooltip should only show when the trigger element overflows.\n * @default false\n */\n readonly showOnOverflow = input<boolean, BooleanInput>(this.config.showOnOverflow, {\n alias: 'ngpTooltipTriggerShowOnOverflow',\n transform: booleanAttribute,\n });\n\n /**\n * Provide context to the tooltip. This can be used to pass data to the tooltip content.\n */\n readonly context = input<T>(undefined, {\n alias: 'ngpTooltipTriggerContext',\n });\n\n /**\n * The overlay that manages the tooltip\n * @internal\n */\n readonly overlay = signal<NgpOverlay<T> | null>(null);\n\n /**\n * The open state of the tooltip.\n * @internal\n */\n readonly open = computed(() => this.overlay()?.isOpen() ?? false);\n\n /**\n * Determine if the trigger element has overflow.\n */\n private readonly hasOverflow: Signal<boolean>;\n\n /**\n * Store the state of the tooltip.\n * @internal\n */\n readonly state = tooltipTriggerState<NgpTooltipTrigger<T>>(this);\n\n constructor() {\n this.hasOverflow = setupOverflowListener(this.trigger.nativeElement, {\n disabled: computed(() => !this.state.showOnOverflow()),\n });\n }\n\n ngOnDestroy(): void {\n this.overlay()?.destroy();\n }\n\n /**\n * Show the tooltip.\n */\n show(): void {\n // If the trigger is disabled, do not show the tooltip\n if (this.state.disabled() || this.open()) {\n return;\n }\n\n // if we should only show when there is overflow, check if the trigger has overflow\n if (this.state.showOnOverflow() && !this.hasOverflow()) {\n // If the trigger does not have overflow, do not show the tooltip\n return;\n }\n\n // Create the overlay if it doesn't exist yet\n if (!this.overlay()) {\n this.createOverlay();\n }\n\n this.overlay()?.show();\n }\n\n /**\n * Hide the tooltip.\n */\n hide(): void {\n // If the trigger is disabled, do nothing\n if (this.state.disabled()) {\n return;\n }\n\n this.overlay()?.hide();\n }\n\n /**\n * Create the overlay that will contain the tooltip\n */\n private createOverlay(): void {\n const tooltip = this.state.tooltip();\n\n if (!tooltip) {\n throw new Error('Tooltip must be either a TemplateRef or a ComponentType');\n }\n\n // Create config for the overlay\n const config: NgpOverlayConfig<T> = {\n content: tooltip,\n triggerElement: this.trigger.nativeElement,\n injector: this.injector,\n context: this.state.context,\n container: this.state.container(),\n placement: this.state.placement(),\n offset: this.state.offset(),\n flip: this.state.flip(),\n showDelay: this.state.showDelay(),\n hideDelay: this.state.hideDelay(),\n closeOnEscape: true,\n closeOnOutsideClick: true,\n viewContainerRef: this.viewContainerRef,\n };\n\n // Create the overlay instance\n this.overlay.set(createOverlay(config));\n }\n}\n","import { Directive } from '@angular/core';\nimport { injectOverlay } from 'ng-primitives/portal';\n\n/**\n * Apply the `ngpTooltip` directive to an element that represents the tooltip. This typically would be a `div` inside an `ng-template`.\n */\n@Directive({\n selector: '[ngpTooltip]',\n exportAs: 'ngpTooltip',\n host: {\n role: 'tooltip',\n '[style.left.px]': 'overlay.position().x',\n '[style.top.px]': 'overlay.position().y',\n '[style.--ngp-tooltip-trigger-width.px]': 'overlay.triggerWidth()',\n '[style.--ngp-tooltip-transform-origin]': 'overlay.transformOrigin()',\n '[attr.data-placement]': 'overlay.finalPlacement()',\n },\n})\nexport class NgpTooltip {\n /**\n * Access the overlay.\n */\n protected readonly overlay = injectOverlay();\n}\n","import { Directive } from '@angular/core';\nimport { setupOverlayArrow } from 'ng-primitives/portal';\n\n@Directive({\n selector: '[ngpTooltipArrow]',\n exportAs: 'ngpTooltipArrow',\n})\nexport class NgpTooltipArrow {\n constructor() {\n setupOverlayArrow();\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;AA+CO,MAAM,oBAAoB,GAAqB;AACpD,IAAA,MAAM,EAAE,CA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f,eAAe,EAAA,YAAA,EAAA,IAAA,EAAA,QAAA,EAAA,mBAAA,EAAA,QAAA,EAAA,CAAA,iBAAA,CAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;;4FAAf,eAAe,EAAA,UAAA,EAAA,CAAA;kBAJ3B,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,mBAAmB;AAC7B,oBAAA,QAAQ,EAAE,iBAAiB;AAC5B,iBAAA;;;ACND;;AAEG;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ng-primitives-utils.mjs","sources":["../../../../packages/ng-primitives/utils/src/forms/providers.ts","../../../../packages/ng-primitives/utils/src/observables/take-until-destroyed.ts","../../../../packages/ng-primitives/utils/src/forms/status.ts","../../../../packages/ng-primitives/utils/src/helpers/attributes.ts","../../../../packages/ng-primitives/utils/src/helpers/disposables.ts","../../../../packages/ng-primitives/utils/src/helpers/unique-id.ts","../../../../packages/ng-primitives/utils/src/signals/index.ts","../../../../packages/ng-primitives/utils/src/ui/dimensions.ts","../../../../packages/ng-primitives/utils/src/ng-primitives-utils.ts"],"sourcesContent":["import { ExistingProvider, Type } from '@angular/core';\nimport { NG_VALUE_ACCESSOR } from '@angular/forms';\n\n/**\n * A simple helper function to provide a value accessor for a given type.\n * @param type The type to provide the value accessor for\n */\nexport function provideValueAccessor<T>(type: Type<T>): ExistingProvider {\n return { provide: NG_VALUE_ACCESSOR, useExisting: type, multi: true };\n}\n","/* eslint-disable @nx/workspace-take-until-destroyed */\nimport { DestroyRef } from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { EMPTY, MonoTypeOperatorFunction, NEVER, pipe } from 'rxjs';\nimport { catchError, defaultIfEmpty, takeUntil } from 'rxjs/operators';\n\n/**\n * The built-in `takeUntilDestroyed` operator does not handle the case when the component is destroyed before the source observable emits.\n * This operator ensures that the source observable completes gracefully without throwing an error.\n * https://github.com/angular/angular/issues/54527#issuecomment-2098254508\n *\n * @internal\n */\nexport function safeTakeUntilDestroyed<T>(destroyRef?: DestroyRef): MonoTypeOperatorFunction<T> {\n return pipe(\n takeUntil(\n NEVER.pipe(\n takeUntilDestroyed(destroyRef),\n catchError(() => EMPTY),\n defaultIfEmpty(null),\n ),\n ),\n );\n}\n","import { DestroyRef, Signal, WritableSignal, afterNextRender, inject, signal } from '@angular/core';\nimport { NgControl } from '@angular/forms';\nimport { safeTakeUntilDestroyed } from '../observables/take-until-destroyed';\n\nexport interface NgpControlStatus {\n valid: boolean | null;\n invalid: boolean | null;\n pristine: boolean | null;\n dirty: boolean | null;\n touched: boolean | null;\n pending: boolean | null;\n disabled: boolean | null;\n}\n\nfunction setStatusSignal(\n control: NgControl | null,\n status: WritableSignal<NgpControlStatus>,\n): void {\n if (!control?.control) {\n return;\n }\n\n status.set({\n valid: control?.control?.valid ?? null,\n invalid: control?.control?.invalid ?? null,\n pristine: control?.control?.pristine ?? null,\n dirty: control?.control?.dirty ?? null,\n touched: control?.control?.touched ?? null,\n pending: control?.control?.pending ?? null,\n disabled: control?.control?.disabled ?? null,\n });\n}\n\nfunction subscribeToControlStatus(\n control: NgControl | null,\n status: WritableSignal<NgpControlStatus>,\n destroyRef?: DestroyRef,\n): void {\n if (!control?.control) {\n return;\n }\n\n control.control.events\n .pipe(safeTakeUntilDestroyed(destroyRef))\n .subscribe(() => setStatusSignal(control, status));\n}\n\n/**\n * A utility function to get the status of an Angular form control as a reactive signal.\n * This function injects the NgControl and returns a signal that reflects the control's status.\n * @internal\n */\nexport function controlStatus(): Signal<NgpControlStatus> {\n const control = inject(NgControl, { optional: true });\n const destroyRef = inject(DestroyRef);\n\n const status = signal<NgpControlStatus>({\n valid: null,\n invalid: null,\n pristine: null,\n dirty: null,\n touched: null,\n pending: null,\n disabled: null,\n });\n\n // Fallback if control is not yet available\n if (!control?.control) {\n // There is still a chance that the control will be available i.e. after executing OnInit lifecycle hook\n // in `formControlName` directive, so we set up an effect to subscribe to the control status\n afterNextRender({\n write: () => {\n // If control is still not available, we do nothing, otherwise we subscribe to the control status\n if (control?.control) {\n subscribeToControlStatus(control, status, destroyRef);\n // We re-set the status to ensure it reflects the current state on initialization\n setStatusSignal(control, status);\n }\n },\n });\n return status;\n }\n\n subscribeToControlStatus(control, status);\n\n return status;\n}\n","import { afterNextRender, Signal } from '@angular/core';\n\nexport function booleanAttributeBinding(\n element: HTMLElement,\n attribute: string,\n value: Signal<boolean> | undefined,\n): void {\n if (!value) {\n return;\n }\n\n afterNextRender({\n write: () =>\n value() ? element.setAttribute(attribute, '') : element.removeAttribute(attribute),\n });\n}\n","import { DestroyRef, inject } from '@angular/core';\n\n/**\n * Disposable functions are a way to manage timers, intervals, and event listeners\n * that should be cleared when a component is destroyed.\n *\n * This is heavily inspired by Headless UI disposables:\n * https://github.com/tailwindlabs/headlessui/blob/main/packages/%40headlessui-react/src/utils/disposables.ts\n */\nexport function injectDisposables() {\n const destroyRef = inject(DestroyRef);\n let isDestroyed = false;\n\n destroyRef.onDestroy(() => (isDestroyed = true));\n\n return {\n /**\n * Set a timeout that will be cleared when the component is destroyed.\n * @param callback The callback to execute\n * @param delay The delay before the callback is executed\n * @returns A function to clear the timeout\n */\n setTimeout: (callback: () => void, delay: number) => {\n if (isDestroyed) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n return () => {};\n }\n\n const id = setTimeout(callback, delay);\n const cleanup = () => clearTimeout(id);\n destroyRef.onDestroy(cleanup);\n return cleanup;\n },\n /**\n * Set an interval that will be cleared when the component is destroyed.\n * @param callback The callback to execute\n * @param delay The delay before the callback is executed\n * @param target\n * @param type\n * @param listener\n * @param options\n * @returns A function to clear the interval\n */\n addEventListener: <K extends keyof HTMLElementEventMap>(\n target: EventTarget,\n type: K,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any,\n options?: boolean | AddEventListenerOptions,\n ) => {\n if (isDestroyed) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n return () => {};\n }\n\n target.addEventListener(type, listener as EventListenerOrEventListenerObject, options);\n const cleanup = () =>\n target.removeEventListener(type, listener as EventListenerOrEventListenerObject, options);\n destroyRef.onDestroy(cleanup);\n return cleanup;\n },\n /**\n * Set an interval that will be cleared when the component is destroyed.\n * @param callback The callback to execute\n * @param delay The delay before the callback is executed\n * @returns A function to clear the interval\n */\n setInterval: (callback: () => void, delay: number) => {\n if (isDestroyed) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n return () => {};\n }\n\n const id = setInterval(callback, delay);\n const cleanup = () => clearInterval(id);\n destroyRef.onDestroy(cleanup);\n return cleanup;\n },\n /**\n * Set a requestAnimationFrame that will be cleared when the component is destroyed.\n * @param callback The callback to execute\n * @returns A function to clear the requestAnimationFrame\n */\n requestAnimationFrame: (callback: FrameRequestCallback) => {\n if (isDestroyed) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n return () => {};\n }\n\n const id = requestAnimationFrame(callback);\n const cleanup = () => cancelAnimationFrame(id);\n destroyRef.onDestroy(cleanup);\n return cleanup;\n },\n };\n}\n","/**\n * Store a map of unique ids for elements so that there are no collisions.\n */\nconst uniqueIdMap = new Map<string, number>();\n\n/**\n * Generate a unique id for an element\n * @param prefix - The prefix to use for the id\n * @returns The generated id\n */\nexport function uniqueId(prefix: string): string {\n const id = uniqueIdMap.get(prefix) ?? 0;\n uniqueIdMap.set(prefix, id + 1);\n return `${prefix}-${id}`;\n}\n","import { effect, Injector, Signal, signal, untracked } from '@angular/core';\n\n/**\n * Listen for changes to a signal and call a function when the signal changes.\n * @param source\n * @param fn\n * @param options\n * @param options.injector\n * @internal\n */\nexport function onChange<T>(\n source: Signal<T | null | undefined>,\n fn: (value: T | null | undefined, previousValue: T | null | undefined) => void,\n options?: { injector: Injector },\n): void {\n const previousValue = signal(source());\n\n effect(\n () => {\n const value = source();\n if (value !== previousValue()) {\n untracked(() => fn(value, previousValue()));\n previousValue.set(value);\n }\n },\n { injector: options?.injector },\n );\n\n // call the fn with the initial value\n fn(source(), null);\n}\n\n/**\n * Listen for changes to a boolean signal and call one of two functions when the signal changes.\n * @param source\n * @param onTrue\n * @param onFalse\n * @param options\n */\nexport function onBooleanChange(\n source: Signal<boolean>,\n onTrue?: () => void,\n onFalse?: () => void,\n options?: { injector: Injector },\n): void {\n onChange(source, value => (value ? onTrue?.() : onFalse?.()), options);\n}\n","import { ElementRef, Renderer2, afterNextRender, inject, signal } from '@angular/core';\n\n/**\n * Injects the dimensions of the element\n * @returns The dimensions of the element\n */\nexport function injectDimensions() {\n const renderer = inject(Renderer2);\n const element = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;\n const size = signal<{ width: number; height: number; mounted: boolean }>({\n width: 0,\n height: 0,\n mounted: false,\n });\n let transitionDuration: string | undefined, animationName: string | undefined;\n\n afterNextRender({\n earlyRead: () => {\n transitionDuration = element.style.transitionDuration;\n animationName = element.style.animationName;\n },\n write: () => {\n // block any animations/transitions so the element renders at its full dimensions\n renderer.setStyle(element, 'transitionDuration', '0s');\n renderer.setStyle(element, 'animationName', 'none');\n },\n read: () => {\n const { width, height } = element.getBoundingClientRect();\n size.set({ width, height, mounted: true });\n // restore the original transition duration and animation name\n renderer.setStyle(element, 'transitionDuration', transitionDuration);\n renderer.setStyle(element, 'animationName', animationName);\n },\n });\n\n return size;\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAGA;;;AAGG;AACG,SAAU,oBAAoB,CAAI,IAAa,EAAA;AACnD,IAAA,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE;AACvE;;ACHA;;;;;;AAMG;AACG,SAAU,sBAAsB,CAAI,UAAuB,EAAA;AAC/D,IAAA,OAAO,IAAI,CACT,SAAS,CACP,KAAK,CAAC,IAAI,CACR,kBAAkB,CAAC,UAAU,CAAC,EAC9B,UAAU,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K,EAAE,CAAC;AACR,QAAA,MAAM,EAAE,CAAC;AACT,QAAA,OAAO,EAAE,KAAK;AACf,KAAA,CAAC;IACF,IAAI,kBAAsC,EAAE,aAAiC;AAE7E,IAAA,eAAe,CAAC;QACd,SAAS,EAAE,MAAK;AACd,YAAA,kBAAkB,GAAG,OAAO,CAAC,KAAK,CAAC,kBAAkB;AACrD,YAAA,aAAa,GAAG,OAAO,CAAC,KAAK,CAAC,aAAa;SAC5C;QACD,KAAK,EAAE,MAAK;;YAEV,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,oBAAoB,EAAE,IAAI,CAAC;YACtD,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,eAAe,EAAE,MAAM,CAAC;SACpD;QACD,IAAI,EAAE,MAAK;YACT,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,qBAAqB,EAAE;AACzD,YAAA,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;YAE1C,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,CAAC;YACpE,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,eAAe,EAAE,aAAa,CAAC;SAC3D;AACF,KAAA,CAAC;AAEF,IAAA,OAAO,IAAI;AACb;;ACpCA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"ng-primitives-utils.mjs","sources":["../../../../packages/ng-primitives/utils/src/forms/providers.ts","../../../../packages/ng-primitives/utils/src/observables/take-until-destroyed.ts","../../../../packages/ng-primitives/utils/src/forms/status.ts","../../../../packages/ng-primitives/utils/src/helpers/attributes.ts","../../../../packages/ng-primitives/utils/src/helpers/disposables.ts","../../../../packages/ng-primitives/utils/src/helpers/unique-id.ts","../../../../packages/ng-primitives/utils/src/signals/index.ts","../../../../packages/ng-primitives/utils/src/ui/dimensions.ts","../../../../packages/ng-primitives/utils/src/ng-primitives-utils.ts"],"sourcesContent":["import { ExistingProvider, Type } from '@angular/core';\nimport { NG_VALUE_ACCESSOR } from '@angular/forms';\n\n/**\n * A simple helper function to provide a value accessor for a given type.\n * @param type The type to provide the value accessor for\n */\nexport function provideValueAccessor<T>(type: Type<T>): ExistingProvider {\n return { provide: NG_VALUE_ACCESSOR, useExisting: type, multi: true };\n}\n","/* eslint-disable @nx/workspace-take-until-destroyed */\nimport { DestroyRef } from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { EMPTY, MonoTypeOperatorFunction, NEVER, pipe } from 'rxjs';\nimport { catchError, defaultIfEmpty, takeUntil } from 'rxjs/operators';\n\n/**\n * The built-in `takeUntilDestroyed` operator does not handle the case when the component is destroyed before the source observable emits.\n * This operator ensures that the source observable completes gracefully without throwing an error.\n * https://github.com/angular/angular/issues/54527#issuecomment-2098254508\n *\n * @internal\n */\nexport function safeTakeUntilDestroyed<T>(destroyRef?: DestroyRef): MonoTypeOperatorFunction<T> {\n return pipe(\n takeUntil(\n NEVER.pipe(\n takeUntilDestroyed(destroyRef),\n catchError(() => EMPTY),\n defaultIfEmpty(null),\n ),\n ),\n );\n}\n","import { DestroyRef, Signal, WritableSignal, afterNextRender, inject, signal } from '@angular/core';\nimport { NgControl } from '@angular/forms';\nimport { safeTakeUntilDestroyed } from '../observables/take-until-destroyed';\n\nexport interface NgpControlStatus {\n valid: boolean | null;\n invalid: boolean | null;\n pristine: boolean | null;\n dirty: boolean | null;\n touched: boolean | null;\n pending: boolean | null;\n disabled: boolean | null;\n}\n\nfunction setStatusSignal(\n control: NgControl | null,\n status: WritableSignal<NgpControlStatus>,\n): void {\n if (!control?.control) {\n return;\n }\n\n status.set({\n valid: control?.control?.valid ?? null,\n invalid: control?.control?.invalid ?? null,\n pristine: control?.control?.pristine ?? null,\n dirty: control?.control?.dirty ?? null,\n touched: control?.control?.touched ?? null,\n pending: control?.control?.pending ?? null,\n disabled: control?.control?.disabled ?? null,\n });\n}\n\nfunction subscribeToControlStatus(\n control: NgControl | null,\n status: WritableSignal<NgpControlStatus>,\n destroyRef?: DestroyRef,\n): void {\n if (!control?.control) {\n return;\n }\n\n control.control.events\n .pipe(safeTakeUntilDestroyed(destroyRef))\n .subscribe(() => setStatusSignal(control, status));\n}\n\n/**\n * A utility function to get the status of an Angular form control as a reactive signal.\n * This function injects the NgControl and returns a signal that reflects the control's status.\n * @internal\n */\nexport function controlStatus(): Signal<NgpControlStatus> {\n const control = inject(NgControl, { optional: true });\n const destroyRef = inject(DestroyRef);\n\n const status = signal<NgpControlStatus>({\n valid: null,\n invalid: null,\n pristine: null,\n dirty: null,\n touched: null,\n pending: null,\n disabled: null,\n });\n\n // Fallback if control is not yet available\n if (!control?.control) {\n // There is still a chance that the control will be available i.e. after executing OnInit lifecycle hook\n // in `formControlName` directive, so we set up an effect to subscribe to the control status\n afterNextRender({\n write: () => {\n // If control is still not available, we do nothing, otherwise we subscribe to the control status\n if (control?.control) {\n subscribeToControlStatus(control, status, destroyRef);\n // We re-set the status to ensure it reflects the current state on initialization\n setStatusSignal(control, status);\n }\n },\n });\n return status;\n }\n\n subscribeToControlStatus(control, status);\n\n return status;\n}\n","import { afterNextRender, Signal } from '@angular/core';\n\nexport function booleanAttributeBinding(\n element: HTMLElement,\n attribute: string,\n value: Signal<boolean> | undefined,\n): void {\n if (!value) {\n return;\n }\n\n afterNextRender({\n write: () =>\n value() ? element.setAttribute(attribute, '') : element.removeAttribute(attribute),\n });\n}\n","import { DestroyRef, inject } from '@angular/core';\n\n/**\n * Disposable functions are a way to manage timers, intervals, and event listeners\n * that should be cleared when a component is destroyed.\n *\n * This is heavily inspired by Headless UI disposables:\n * https://github.com/tailwindlabs/headlessui/blob/main/packages/%40headlessui-react/src/utils/disposables.ts\n */\nexport function injectDisposables() {\n const destroyRef = inject(DestroyRef);\n let isDestroyed = false;\n\n destroyRef.onDestroy(() => (isDestroyed = true));\n\n return {\n /**\n * Set a timeout that will be cleared when the component is destroyed.\n * @param callback The callback to execute\n * @param delay The delay before the callback is executed\n * @returns A function to clear the timeout\n */\n setTimeout: (callback: () => void, delay: number) => {\n if (isDestroyed) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n return () => {};\n }\n\n const id = setTimeout(callback, delay);\n const cleanup = () => clearTimeout(id);\n destroyRef.onDestroy(cleanup);\n return cleanup;\n },\n /**\n * Set an interval that will be cleared when the component is destroyed.\n * @param callback The callback to execute\n * @param delay The delay before the callback is executed\n * @param target\n * @param type\n * @param listener\n * @param options\n * @returns A function to clear the interval\n */\n addEventListener: <K extends keyof HTMLElementEventMap>(\n target: EventTarget,\n type: K,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any,\n options?: boolean | AddEventListenerOptions,\n ) => {\n if (isDestroyed) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n return () => {};\n }\n\n target.addEventListener(type, listener as EventListenerOrEventListenerObject, options);\n const cleanup = () =>\n target.removeEventListener(type, listener as EventListenerOrEventListenerObject, options);\n destroyRef.onDestroy(cleanup);\n return cleanup;\n },\n /**\n * Set an interval that will be cleared when the component is destroyed.\n * @param callback The callback to execute\n * @param delay The delay before the callback is executed\n * @returns A function to clear the interval\n */\n setInterval: (callback: () => void, delay: number) => {\n if (isDestroyed) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n return () => {};\n }\n\n const id = setInterval(callback, delay);\n const cleanup = () => clearInterval(id);\n destroyRef.onDestroy(cleanup);\n return cleanup;\n },\n /**\n * Set a requestAnimationFrame that will be cleared when the component is destroyed.\n * @param callback The callback to execute\n * @returns A function to clear the requestAnimationFrame\n */\n requestAnimationFrame: (callback: FrameRequestCallback) => {\n if (isDestroyed) {\n // eslint-disable-next-line @typescript-eslint/no-empty-function\n return () => {};\n }\n\n const id = requestAnimationFrame(callback);\n const cleanup = () => cancelAnimationFrame(id);\n destroyRef.onDestroy(cleanup);\n return cleanup;\n },\n };\n}\n","/**\n * Store a map of unique ids for elements so that there are no collisions.\n */\nconst uniqueIdMap = new Map<string, number>();\n\n/**\n * Generate a unique id for an element\n * @param prefix - The prefix to use for the id\n * @returns The generated id\n */\nexport function uniqueId(prefix: string): string {\n const id = uniqueIdMap.get(prefix) ?? 0;\n uniqueIdMap.set(prefix, id + 1);\n return `${prefix}-${id}`;\n}\n","import { effect, Injector, Signal, signal, untracked } from '@angular/core';\n\n/**\n * Listen for changes to a signal and call a function when the signal changes.\n * @param source\n * @param fn\n * @param options\n * @param options.injector\n * @internal\n */\nexport function onChange<T>(\n source: Signal<T | null | undefined>,\n fn: (value: T | null | undefined, previousValue: T | null | undefined) => void,\n options?: { injector: Injector },\n): void {\n const previousValue = signal(source());\n\n effect(\n () => {\n const value = source();\n if (value !== previousValue()) {\n untracked(() => fn(value, previousValue()));\n previousValue.set(value);\n }\n },\n { injector: options?.injector },\n );\n\n // call the fn with the initial value\n fn(source(), null);\n}\n\n/**\n * Listen for changes to a boolean signal and call one of two functions when the signal changes.\n * @param source\n * @param onTrue\n * @param onFalse\n * @param options\n */\nexport function onBooleanChange(\n source: Signal<boolean>,\n onTrue?: () => void,\n onFalse?: () => void,\n options?: { injector: Injector },\n): void {\n onChange(source, value => (value ? onTrue?.() : onFalse?.()), options);\n}\n","import { ElementRef, Renderer2, afterNextRender, inject, signal } from '@angular/core';\n\n/**\n * Injects the dimensions of the element\n * @returns The dimensions of the element\n */\nexport function injectDimensions() {\n const renderer = inject(Renderer2);\n const element = inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;\n const size = signal<{ width: number; height: number; mounted: boolean }>({\n width: 0,\n height: 0,\n mounted: false,\n });\n let transitionDuration: string | undefined, animationName: string | undefined;\n\n afterNextRender({\n earlyRead: () => {\n transitionDuration = element.style.transitionDuration;\n animationName = element.style.animationName;\n },\n write: () => {\n // block any animations/transitions so the element renders at its full dimensions\n renderer.setStyle(element, 'transitionDuration', '0s');\n renderer.setStyle(element, 'animationName', 'none');\n },\n read: () => {\n const { width, height } = element.getBoundingClientRect();\n size.set({ width, height, mounted: true });\n // restore the original transition duration and animation name\n renderer.setStyle(element, 'transitionDuration', transitionDuration);\n renderer.setStyle(element, 'animationName', animationName);\n },\n });\n\n return size;\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAGA;;;AAGG;AACG,SAAU,oBAAoB,CAAI,IAAa,EAAA;AACnD,IAAA,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE;AACvE;;ACHA;;;;;;AAMG;AACG,SAAU,sBAAsB,CAAI,UAAuB,EAAA;AAC/D,IAAA,OAAO,IAAI,CACT,SAAS,CACP,KAAK,CAAC,IAAI,CACR,kBAAkB,CAAC,UAAU,CAAC,EAC9B,UAAU,CAAC,MAAM,KAAK,CAAC,EACvB,cAAc,CAAC,IAAI,CAAC,CACrB,CACF,CACF;AACH;;ACTA,SAAS,eAAe,CACtB,OAAyB,EACzB,MAAwC,EAAA;AAExC,IAAA,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE;QACrB;IACF;IAEA,MAAM,CAAC,GAAG,CAAC;AACT,QAAA,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,IAAI,IAAI;AACtC,QAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,IAAI;AAC1C,QAAA,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,IAAI,IAAI;AAC5C,QAAA,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,IAAI,IAAI;AACtC,QAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,IAAI;AAC1C,QAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,IAAI;AAC1C,QAAA,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,IAAI,IAAI;AAC7C,KAAA,CAAC;AACJ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KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;YAE1C,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,CAAC;YACpE,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,eAAe,EAAE,aAAa,CAAC;QAC5D,CAAC;AACF,KAAA,CAAC;AAEF,IAAA,OAAO,IAAI;AACb;;ACpCA;;AAEG;;;;"}
|
package/internal/index.d.ts
CHANGED
|
@@ -6,4 +6,7 @@ export * from './signals/explicit-effect';
|
|
|
6
6
|
export * from './style-injector/style-injector';
|
|
7
7
|
export * from './utilities/dom-removal';
|
|
8
8
|
export * from './utilities/element-ref';
|
|
9
|
+
export { fromMutationObserver } from './utilities/mutation-observer';
|
|
10
|
+
export { setupOverflowListener } from './utilities/overflow';
|
|
11
|
+
export { Dimensions, fromResizeEvent, observeResize } from './utilities/resize';
|
|
9
12
|
export * from './utilities/scrolling';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Injector, Signal } from '@angular/core';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
interface NgpMutationObserverOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Whether to listen for events.
|
|
6
|
+
*/
|
|
7
|
+
disabled?: Signal<boolean>;
|
|
8
|
+
/**
|
|
9
|
+
* The injector to use when called from outside of the injector context.
|
|
10
|
+
*/
|
|
11
|
+
injector?: Injector;
|
|
12
|
+
/**
|
|
13
|
+
* Whether the childList should be observed.
|
|
14
|
+
*/
|
|
15
|
+
childList?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Whether the subtree should be observed.
|
|
18
|
+
*/
|
|
19
|
+
subtree?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Whether the attributes should be observed.
|
|
22
|
+
*/
|
|
23
|
+
attributes?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Whether the characterData should be observed.
|
|
26
|
+
*/
|
|
27
|
+
characterData?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Whether the attributeFilter should be observed.
|
|
30
|
+
*/
|
|
31
|
+
attributeFilter?: string[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* This function sets up a mutation observer to listen for changes in the DOM.
|
|
35
|
+
* It will stop listening when the `disabled` signal is true, and re-enable when it is false.
|
|
36
|
+
* @param options - Options for the mutation observer
|
|
37
|
+
*/
|
|
38
|
+
export declare function fromMutationObserver(element: HTMLElement, { childList, subtree, attributes, characterData, disabled, injector, }?: NgpMutationObserverOptions): Observable<MutationRecord[]>;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Injector, Signal } from '@angular/core';
|
|
2
|
+
interface NgpOverflowListenerOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Whether to listen for overflow changes.
|
|
5
|
+
*/
|
|
6
|
+
disabled?: Signal<boolean>;
|
|
7
|
+
/**
|
|
8
|
+
* The injector to use when called from outside of the injector context.
|
|
9
|
+
*/
|
|
10
|
+
injector?: Injector;
|
|
11
|
+
}
|
|
12
|
+
export declare function setupOverflowListener(element: HTMLElement, { disabled, injector }: NgpOverflowListenerOptions): Signal<boolean>;
|
|
13
|
+
export {};
|
|
@@ -1,11 +1,21 @@
|
|
|
1
|
-
import { Signal } from '@angular/core';
|
|
1
|
+
import { Injector, Signal } from '@angular/core';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
|
+
interface NgpResizeObserverOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Whether to listen for events.
|
|
6
|
+
*/
|
|
7
|
+
disabled?: Signal<boolean>;
|
|
8
|
+
/**
|
|
9
|
+
* The injector to use when called from outside of the injector context.
|
|
10
|
+
*/
|
|
11
|
+
injector?: Injector;
|
|
12
|
+
}
|
|
3
13
|
/**
|
|
4
14
|
* A simple helper function to create a resize observer as an RxJS Observable.
|
|
5
15
|
* @param element The element to observe for resize events.
|
|
6
16
|
* @returns The resize event as an Observable.
|
|
7
17
|
*/
|
|
8
|
-
export declare function fromResizeEvent(element: HTMLElement): Observable<Dimensions>;
|
|
18
|
+
export declare function fromResizeEvent(element: HTMLElement, { disabled, injector }?: NgpResizeObserverOptions): Observable<Dimensions>;
|
|
9
19
|
/**
|
|
10
20
|
* A utility function to observe any element for resize events and return the dimensions as a signal.
|
|
11
21
|
*/
|
|
@@ -14,3 +24,4 @@ export interface Dimensions {
|
|
|
14
24
|
width: number;
|
|
15
25
|
height: number;
|
|
16
26
|
}
|
|
27
|
+
export {};
|