ng-primitives 0.81.0 → 0.82.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/ng-primitives-combobox.mjs +2 -1
- package/fesm2022/ng-primitives-combobox.mjs.map +1 -1
- package/fesm2022/ng-primitives-menu.mjs +6 -4
- package/fesm2022/ng-primitives-menu.mjs.map +1 -1
- package/fesm2022/ng-primitives-popover.mjs +3 -2
- package/fesm2022/ng-primitives-popover.mjs.map +1 -1
- package/fesm2022/ng-primitives-portal.mjs +21 -4
- package/fesm2022/ng-primitives-portal.mjs.map +1 -1
- package/fesm2022/ng-primitives-tooltip.mjs +3 -2
- package/fesm2022/ng-primitives-tooltip.mjs.map +1 -1
- package/fesm2022/ng-primitives-utils.mjs +17 -1
- package/fesm2022/ng-primitives-utils.mjs.map +1 -1
- package/menu/config/menu-config.d.ts +3 -1
- package/menu/menu-trigger/menu-trigger.d.ts +4 -3
- package/menu/submenu-trigger/submenu-trigger.d.ts +4 -3
- package/package.json +41 -41
- package/popover/config/popover-config.d.ts +3 -1
- package/popover/popover-trigger/popover-trigger.d.ts +3 -2
- package/portal/index.d.ts +1 -0
- package/portal/offset.d.ts +39 -0
- package/portal/overlay.d.ts +3 -2
- package/tooltip/config/tooltip-config.d.ts +3 -1
- package/tooltip/tooltip-trigger/tooltip-trigger.d.ts +3 -2
- package/utils/helpers/validators.d.ts +12 -0
- package/utils/index.d.ts +1 -1
|
@@ -241,6 +241,22 @@ function isObject(value) {
|
|
|
241
241
|
function isUndefined(value) {
|
|
242
242
|
return typeof value === 'undefined';
|
|
243
243
|
}
|
|
244
|
+
/**
|
|
245
|
+
* Checks if a value is null or undefined
|
|
246
|
+
* @param value - The value to check
|
|
247
|
+
* @returns true if the value is null or undefined, false otherwise
|
|
248
|
+
*/
|
|
249
|
+
function isNil(value) {
|
|
250
|
+
return isUndefined(value) || value === null;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Checks if a value is not null and not undefined
|
|
254
|
+
* @param value - The value to check
|
|
255
|
+
* @returns true if the value is not null and not undefined, false otherwise
|
|
256
|
+
*/
|
|
257
|
+
function notNil(value) {
|
|
258
|
+
return !isNil(value);
|
|
259
|
+
}
|
|
244
260
|
|
|
245
261
|
/**
|
|
246
262
|
* Listen for changes to a signal and call a function when the signal changes.
|
|
@@ -277,5 +293,5 @@ function onBooleanChange(source, onTrue, onFalse, options) {
|
|
|
277
293
|
* Generated bundle index. Do not edit.
|
|
278
294
|
*/
|
|
279
295
|
|
|
280
|
-
export { booleanAttributeBinding, controlStatus, injectDisposables, isBoolean, isFunction, isNumber, isObject, isString, isUndefined, onBooleanChange, onChange, provideValueAccessor, safeTakeUntilDestroyed, uniqueId };
|
|
296
|
+
export { booleanAttributeBinding, controlStatus, injectDisposables, isBoolean, isFunction, isNil, isNumber, isObject, isString, isUndefined, notNil, onBooleanChange, onChange, provideValueAccessor, safeTakeUntilDestroyed, uniqueId };
|
|
281
297
|
//# sourceMappingURL=ng-primitives-utils.mjs.map
|
|
@@ -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/helpers/validators.ts","../../../../packages/ng-primitives/utils/src/signals/index.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 { afterRenderEffect, 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 afterRenderEffect({\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","/**\n * Type validation utilities\n */\n\n/**\n * Checks if a value is a string\n * @param value - The value to check\n * @returns true if the value is a string, false otherwise\n */\nexport function isString(value: unknown): value is string {\n return typeof value === 'string';\n}\n\n/**\n * Checks if a value is a number\n * @param value - The value to check\n * @returns true if the value is a number, false otherwise\n */\nexport function isNumber(value: unknown): value is number {\n return typeof value === 'number';\n}\n\n/**\n * Checks if a value is a boolean\n * @param value - The value to check\n * @returns true if the value is a boolean, false otherwise\n */\nexport function isBoolean(value: unknown): value is boolean {\n return typeof value === 'boolean';\n}\n\n/**\n * Checks if a value is a function\n * @param value - The value to check\n * @returns true if the value is a function, false otherwise\n */\nexport function isFunction(value: unknown): value is CallableFunction {\n return typeof value === 'function';\n}\n\n/**\n * Checks if a value is a plain object (but not null or array)\n * @param value - The value to check\n * @returns true if the value is a plain object, false otherwise\n */\nexport function isObject(value: unknown): value is Record<string, unknown> {\n return !!value && typeof value === 'object' && !Array.isArray(value);\n}\n\n/**\n * Checks if a value is undefined\n * @param value - The value to check\n * @returns true if the value is undefined, false otherwise\n */\nexport function isUndefined(value: unknown): value is undefined {\n return typeof value === 'undefined';\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","/**\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;AAEA,SAAS,wBAAwB,CAC/B,OAAyB,EACzB,MAAwC,EACxC,UAAuB,EAAA;AAEvB,I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,KAAK,KAAK,UAAU;AACpC;AAEA;;;;AAIG;AACG,SAAU,QAAQ,CAAC,KAAc,EAAA;AACrC,IAAA,OAAO,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;AACtE;AAEA;;;;AAIG;AACG,SAAU,WAAW,CAAC,KAAc,EAAA;AACxC,IAAA,OAAO,OAAO,KAAK,KAAK,WAAW;AACrC;;ACtDA;;;;;;;AAOG;SACa,QAAQ,CACtB,MAAoC,EACpC,EAA8E,EAC9E,OAAgC,EAAA;AAEhC,IAAA,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;IAEtC,MAAM,CACJ,MAAK;AACH,QAAA,MAAM,KAAK,GAAG,MAAM,EAAE;AACtB,QAAA,IAAI,KAAK,KAAK,aAAa,EAAE,EAAE;AAC7B,YAAA,SAAS,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,CAAC,CAAC;AAC3C,YAAA,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC;QAC1B;IACF,CAAC,EACD,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,CAChC;;AAGD,IAAA,EAAE,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC;AACpB;AAEA;;;;;;AAMG;AACG,SAAU,eAAe,CAC7B,MAAuB,EACvB,MAAmB,EACnB,OAAoB,EACpB,OAAgC,EAAA;IAEhC,QAAQ,CAAC,MAAM,EAAE,KAAK,KAAK,KAAK,GAAG,MAAM,IAAI,GAAG,OAAO,IAAI,CAAC,EAAE,OAAO,CAAC;AACxE;;AC9CA;;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/helpers/validators.ts","../../../../packages/ng-primitives/utils/src/signals/index.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 { afterRenderEffect, 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 afterRenderEffect({\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","/**\n * Type validation utilities\n */\n\n/**\n * Checks if a value is a string\n * @param value - The value to check\n * @returns true if the value is a string, false otherwise\n */\nexport function isString(value: unknown): value is string {\n return typeof value === 'string';\n}\n\n/**\n * Checks if a value is a number\n * @param value - The value to check\n * @returns true if the value is a number, false otherwise\n */\nexport function isNumber(value: unknown): value is number {\n return typeof value === 'number';\n}\n\n/**\n * Checks if a value is a boolean\n * @param value - The value to check\n * @returns true if the value is a boolean, false otherwise\n */\nexport function isBoolean(value: unknown): value is boolean {\n return typeof value === 'boolean';\n}\n\n/**\n * Checks if a value is a function\n * @param value - The value to check\n * @returns true if the value is a function, false otherwise\n */\nexport function isFunction(value: unknown): value is CallableFunction {\n return typeof value === 'function';\n}\n\n/**\n * Checks if a value is a plain object (but not null or array)\n * @param value - The value to check\n * @returns true if the value is a plain object, false otherwise\n */\nexport function isObject(value: unknown): value is Record<string, unknown> {\n return !!value && typeof value === 'object' && !Array.isArray(value);\n}\n\n/**\n * Checks if a value is undefined\n * @param value - The value to check\n * @returns true if the value is undefined, false otherwise\n */\nexport function isUndefined(value: unknown): value is undefined {\n return typeof value === 'undefined';\n}\n\n/**\n * Checks if a value is null or undefined\n * @param value - The value to check\n * @returns true if the value is null or undefined, false otherwise\n */\nexport function isNil(value: unknown): value is null | undefined {\n return isUndefined(value) || value === null;\n}\n\n/**\n * Checks if a value is not null and not undefined\n * @param value - The value to check\n * @returns true if the value is not null and not undefined, false otherwise\n */\nexport function notNil<T>(value: T | null | undefined): value is T {\n return !isNil(value);\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","/**\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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AA,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;IAEtC,MAAM,CACJ,MAAK;AACH,QAAA,MAAM,KAAK,GAAG,MAAM,EAAE;AACtB,QAAA,IAAI,KAAK,KAAK,aAAa,EAAE,EAAE;AAC7B,YAAA,SAAS,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,CAAC,CAAC;AAC3C,YAAA,aAAa,CAAC,GAAG,CAAC,KAAK,CAAC;QAC1B;IACF,CAAC,EACD,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,CAChC;;AAGD,IAAA,EAAE,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC;AACpB;AAEA;;;;;;AAMG;AACG,SAAU,eAAe,CAC7B,MAAuB,EACvB,MAAmB,EACnB,OAAoB,EACpB,OAAgC,EAAA;IAEhC,QAAQ,CAAC,MAAM,EAAE,KAAK,KAAK,KAAK,GAAG,MAAM,IAAI,GAAG,OAAO,IAAI,CAAC,EAAE,OAAO,CAAC;AACxE;;AC9CA;;AAEG;;;;"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { InjectionToken, Provider } from '@angular/core';
|
|
2
|
+
import { NgpOffset } from 'ng-primitives/portal';
|
|
2
3
|
import type { NgpMenuPlacement } from '../menu-trigger/menu-trigger';
|
|
3
4
|
export interface NgpMenuConfig {
|
|
4
5
|
/**
|
|
5
6
|
* Define the offset of the menu relative to the trigger.
|
|
7
|
+
* Can be a number (applies to mainAxis) or an object with mainAxis, crossAxis, and alignmentAxis.
|
|
6
8
|
* @default 4
|
|
7
9
|
*/
|
|
8
|
-
offset:
|
|
10
|
+
offset: NgpOffset;
|
|
9
11
|
/**
|
|
10
12
|
* Define the placement of the menu relative to the trigger.
|
|
11
13
|
* @default 'bottom-start'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FocusOrigin } from '@angular/cdk/a11y';
|
|
2
|
-
import { BooleanInput
|
|
2
|
+
import { BooleanInput } from '@angular/cdk/coercion';
|
|
3
3
|
import { OnDestroy } from '@angular/core';
|
|
4
|
-
import { NgpOverlay, NgpOverlayContent } from 'ng-primitives/portal';
|
|
4
|
+
import { NgpOverlay, NgpOverlayContent, NgpOffset, NgpOffsetInput } from 'ng-primitives/portal';
|
|
5
5
|
import * as i0 from "@angular/core";
|
|
6
6
|
/**
|
|
7
7
|
* The `NgpMenuTrigger` directive allows you to turn an element into a menu trigger.
|
|
@@ -39,9 +39,10 @@ export declare class NgpMenuTrigger<T = unknown> implements OnDestroy {
|
|
|
39
39
|
readonly placement: import("@angular/core").InputSignal<NgpMenuPlacement>;
|
|
40
40
|
/**
|
|
41
41
|
* Define the offset of the menu relative to the trigger.
|
|
42
|
+
* Can be a number (applies to mainAxis) or an object with mainAxis, crossAxis, and alignmentAxis.
|
|
42
43
|
* @default 4
|
|
43
44
|
*/
|
|
44
|
-
readonly offset: import("@angular/core").InputSignalWithTransform<
|
|
45
|
+
readonly offset: import("@angular/core").InputSignalWithTransform<NgpOffset, NgpOffsetInput>;
|
|
45
46
|
/**
|
|
46
47
|
* Define whether the menu should flip when there is not enough space for the menu.
|
|
47
48
|
* @default true
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FocusOrigin } from '@angular/cdk/a11y';
|
|
2
|
-
import { BooleanInput
|
|
3
|
-
import { NgpOverlay, NgpOverlayContent } from 'ng-primitives/portal';
|
|
2
|
+
import { BooleanInput } from '@angular/cdk/coercion';
|
|
3
|
+
import { NgpOverlay, NgpOverlayContent, NgpOffset, NgpOffsetInput } from 'ng-primitives/portal';
|
|
4
4
|
import { NgpMenuPlacement } from '../menu-trigger/menu-trigger';
|
|
5
5
|
import * as i0 from "@angular/core";
|
|
6
6
|
export declare class NgpSubmenuTrigger<T = unknown> {
|
|
@@ -34,9 +34,10 @@ export declare class NgpSubmenuTrigger<T = unknown> {
|
|
|
34
34
|
readonly placement: import("@angular/core").InputSignal<NgpMenuPlacement>;
|
|
35
35
|
/**
|
|
36
36
|
* Define the offset of the menu relative to the trigger.
|
|
37
|
+
* Can be a number (applies to mainAxis) or an object with mainAxis, crossAxis, and alignmentAxis.
|
|
37
38
|
* @default 0
|
|
38
39
|
*/
|
|
39
|
-
readonly offset: import("@angular/core").InputSignalWithTransform<
|
|
40
|
+
readonly offset: import("@angular/core").InputSignalWithTransform<NgpOffset, NgpOffsetInput>;
|
|
40
41
|
/**
|
|
41
42
|
* Define whether the menu should flip when there is not enough space for the menu.
|
|
42
43
|
* @default true
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "ng-primitives",
|
|
3
3
|
"description": "Angular Primitives is a low-level headless UI component library with a focus on accessibility, customization, and developer experience. ",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.82.0",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"angular",
|
|
8
8
|
"primitives",
|
|
@@ -67,46 +67,46 @@
|
|
|
67
67
|
"types": "./a11y/index.d.ts",
|
|
68
68
|
"default": "./fesm2022/ng-primitives-a11y.mjs"
|
|
69
69
|
},
|
|
70
|
-
"./
|
|
71
|
-
"types": "./
|
|
72
|
-
"default": "./fesm2022/ng-primitives-
|
|
73
|
-
},
|
|
74
|
-
"./button": {
|
|
75
|
-
"types": "./button/index.d.ts",
|
|
76
|
-
"default": "./fesm2022/ng-primitives-button.mjs"
|
|
70
|
+
"./autofill": {
|
|
71
|
+
"types": "./autofill/index.d.ts",
|
|
72
|
+
"default": "./fesm2022/ng-primitives-autofill.mjs"
|
|
77
73
|
},
|
|
78
74
|
"./ai": {
|
|
79
75
|
"types": "./ai/index.d.ts",
|
|
80
76
|
"default": "./fesm2022/ng-primitives-ai.mjs"
|
|
81
77
|
},
|
|
82
|
-
"./
|
|
83
|
-
"types": "./
|
|
84
|
-
"default": "./fesm2022/ng-primitives-
|
|
85
|
-
},
|
|
86
|
-
"./checkbox": {
|
|
87
|
-
"types": "./checkbox/index.d.ts",
|
|
88
|
-
"default": "./fesm2022/ng-primitives-checkbox.mjs"
|
|
78
|
+
"./button": {
|
|
79
|
+
"types": "./button/index.d.ts",
|
|
80
|
+
"default": "./fesm2022/ng-primitives-button.mjs"
|
|
89
81
|
},
|
|
90
82
|
"./avatar": {
|
|
91
83
|
"types": "./avatar/index.d.ts",
|
|
92
84
|
"default": "./fesm2022/ng-primitives-avatar.mjs"
|
|
93
85
|
},
|
|
86
|
+
"./accordion": {
|
|
87
|
+
"types": "./accordion/index.d.ts",
|
|
88
|
+
"default": "./fesm2022/ng-primitives-accordion.mjs"
|
|
89
|
+
},
|
|
94
90
|
"./combobox": {
|
|
95
91
|
"types": "./combobox/index.d.ts",
|
|
96
92
|
"default": "./fesm2022/ng-primitives-combobox.mjs"
|
|
97
93
|
},
|
|
94
|
+
"./checkbox": {
|
|
95
|
+
"types": "./checkbox/index.d.ts",
|
|
96
|
+
"default": "./fesm2022/ng-primitives-checkbox.mjs"
|
|
97
|
+
},
|
|
98
98
|
"./common": {
|
|
99
99
|
"types": "./common/index.d.ts",
|
|
100
100
|
"default": "./fesm2022/ng-primitives-common.mjs"
|
|
101
101
|
},
|
|
102
|
-
"./date-picker": {
|
|
103
|
-
"types": "./date-picker/index.d.ts",
|
|
104
|
-
"default": "./fesm2022/ng-primitives-date-picker.mjs"
|
|
105
|
-
},
|
|
106
102
|
"./date-time": {
|
|
107
103
|
"types": "./date-time/index.d.ts",
|
|
108
104
|
"default": "./fesm2022/ng-primitives-date-time.mjs"
|
|
109
105
|
},
|
|
106
|
+
"./date-picker": {
|
|
107
|
+
"types": "./date-picker/index.d.ts",
|
|
108
|
+
"default": "./fesm2022/ng-primitives-date-picker.mjs"
|
|
109
|
+
},
|
|
110
110
|
"./date-time-luxon": {
|
|
111
111
|
"types": "./date-time-luxon/index.d.ts",
|
|
112
112
|
"default": "./fesm2022/ng-primitives-date-time-luxon.mjs"
|
|
@@ -119,18 +119,10 @@
|
|
|
119
119
|
"types": "./file-upload/index.d.ts",
|
|
120
120
|
"default": "./fesm2022/ng-primitives-file-upload.mjs"
|
|
121
121
|
},
|
|
122
|
-
"./focus-trap": {
|
|
123
|
-
"types": "./focus-trap/index.d.ts",
|
|
124
|
-
"default": "./fesm2022/ng-primitives-focus-trap.mjs"
|
|
125
|
-
},
|
|
126
122
|
"./form-field": {
|
|
127
123
|
"types": "./form-field/index.d.ts",
|
|
128
124
|
"default": "./fesm2022/ng-primitives-form-field.mjs"
|
|
129
125
|
},
|
|
130
|
-
"./input": {
|
|
131
|
-
"types": "./input/index.d.ts",
|
|
132
|
-
"default": "./fesm2022/ng-primitives-input.mjs"
|
|
133
|
-
},
|
|
134
126
|
"./interactions": {
|
|
135
127
|
"types": "./interactions/index.d.ts",
|
|
136
128
|
"default": "./fesm2022/ng-primitives-interactions.mjs"
|
|
@@ -139,10 +131,18 @@
|
|
|
139
131
|
"types": "./internal/index.d.ts",
|
|
140
132
|
"default": "./fesm2022/ng-primitives-internal.mjs"
|
|
141
133
|
},
|
|
134
|
+
"./input": {
|
|
135
|
+
"types": "./input/index.d.ts",
|
|
136
|
+
"default": "./fesm2022/ng-primitives-input.mjs"
|
|
137
|
+
},
|
|
142
138
|
"./listbox": {
|
|
143
139
|
"types": "./listbox/index.d.ts",
|
|
144
140
|
"default": "./fesm2022/ng-primitives-listbox.mjs"
|
|
145
141
|
},
|
|
142
|
+
"./focus-trap": {
|
|
143
|
+
"types": "./focus-trap/index.d.ts",
|
|
144
|
+
"default": "./fesm2022/ng-primitives-focus-trap.mjs"
|
|
145
|
+
},
|
|
146
146
|
"./menu": {
|
|
147
147
|
"types": "./menu/index.d.ts",
|
|
148
148
|
"default": "./fesm2022/ng-primitives-menu.mjs"
|
|
@@ -155,14 +155,14 @@
|
|
|
155
155
|
"types": "./pagination/index.d.ts",
|
|
156
156
|
"default": "./fesm2022/ng-primitives-pagination.mjs"
|
|
157
157
|
},
|
|
158
|
-
"./popover": {
|
|
159
|
-
"types": "./popover/index.d.ts",
|
|
160
|
-
"default": "./fesm2022/ng-primitives-popover.mjs"
|
|
161
|
-
},
|
|
162
158
|
"./portal": {
|
|
163
159
|
"types": "./portal/index.d.ts",
|
|
164
160
|
"default": "./fesm2022/ng-primitives-portal.mjs"
|
|
165
161
|
},
|
|
162
|
+
"./popover": {
|
|
163
|
+
"types": "./popover/index.d.ts",
|
|
164
|
+
"default": "./fesm2022/ng-primitives-popover.mjs"
|
|
165
|
+
},
|
|
166
166
|
"./progress": {
|
|
167
167
|
"types": "./progress/index.d.ts",
|
|
168
168
|
"default": "./fesm2022/ng-primitives-progress.mjs"
|
|
@@ -175,26 +175,26 @@
|
|
|
175
175
|
"types": "./roving-focus/index.d.ts",
|
|
176
176
|
"default": "./fesm2022/ng-primitives-roving-focus.mjs"
|
|
177
177
|
},
|
|
178
|
-
"./
|
|
179
|
-
"types": "./
|
|
180
|
-
"default": "./fesm2022/ng-primitives-
|
|
178
|
+
"./select": {
|
|
179
|
+
"types": "./select/index.d.ts",
|
|
180
|
+
"default": "./fesm2022/ng-primitives-select.mjs"
|
|
181
181
|
},
|
|
182
182
|
"./search": {
|
|
183
183
|
"types": "./search/index.d.ts",
|
|
184
184
|
"default": "./fesm2022/ng-primitives-search.mjs"
|
|
185
185
|
},
|
|
186
|
-
"./
|
|
187
|
-
"types": "./
|
|
188
|
-
"default": "./fesm2022/ng-primitives-
|
|
186
|
+
"./slider": {
|
|
187
|
+
"types": "./slider/index.d.ts",
|
|
188
|
+
"default": "./fesm2022/ng-primitives-slider.mjs"
|
|
189
|
+
},
|
|
190
|
+
"./resize": {
|
|
191
|
+
"types": "./resize/index.d.ts",
|
|
192
|
+
"default": "./fesm2022/ng-primitives-resize.mjs"
|
|
189
193
|
},
|
|
190
194
|
"./separator": {
|
|
191
195
|
"types": "./separator/index.d.ts",
|
|
192
196
|
"default": "./fesm2022/ng-primitives-separator.mjs"
|
|
193
197
|
},
|
|
194
|
-
"./slider": {
|
|
195
|
-
"types": "./slider/index.d.ts",
|
|
196
|
-
"default": "./fesm2022/ng-primitives-slider.mjs"
|
|
197
|
-
},
|
|
198
198
|
"./state": {
|
|
199
199
|
"types": "./state/index.d.ts",
|
|
200
200
|
"default": "./fesm2022/ng-primitives-state.mjs"
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { InjectionToken, Provider } from '@angular/core';
|
|
2
2
|
import { type Placement } from '@floating-ui/dom';
|
|
3
|
+
import { NgpOffset } from 'ng-primitives/portal';
|
|
3
4
|
export interface NgpPopoverConfig {
|
|
4
5
|
/**
|
|
5
6
|
* Define the offset of the popover relative to the trigger.
|
|
7
|
+
* Can be a number (applies to mainAxis) or an object with mainAxis, crossAxis, and alignmentAxis.
|
|
6
8
|
* @default 4
|
|
7
9
|
*/
|
|
8
|
-
offset:
|
|
10
|
+
offset: NgpOffset;
|
|
9
11
|
/**
|
|
10
12
|
* Define the placement of the popover relative to the trigger.
|
|
11
13
|
* @default 'bottom'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FocusOrigin } from '@angular/cdk/a11y';
|
|
2
2
|
import { BooleanInput, NumberInput } from '@angular/cdk/coercion';
|
|
3
3
|
import { OnDestroy } from '@angular/core';
|
|
4
|
-
import { NgpOverlay, NgpOverlayContent } from 'ng-primitives/portal';
|
|
4
|
+
import { NgpOverlay, NgpOverlayContent, NgpOffset, NgpOffsetInput } from 'ng-primitives/portal';
|
|
5
5
|
import * as i0 from "@angular/core";
|
|
6
6
|
/**
|
|
7
7
|
* Apply the `ngpPopoverTrigger` directive to an element that triggers the popover to show.
|
|
@@ -39,9 +39,10 @@ export declare class NgpPopoverTrigger<T = null> implements OnDestroy {
|
|
|
39
39
|
readonly placement: import("@angular/core").InputSignal<NgpPopoverPlacement>;
|
|
40
40
|
/**
|
|
41
41
|
* Define the offset of the popover relative to the trigger.
|
|
42
|
+
* Can be a number (applies to mainAxis) or an object with mainAxis, crossAxis, and alignmentAxis.
|
|
42
43
|
* @default 0
|
|
43
44
|
*/
|
|
44
|
-
readonly offset: import("@angular/core").InputSignalWithTransform<
|
|
45
|
+
readonly offset: import("@angular/core").InputSignalWithTransform<NgpOffset, NgpOffsetInput>;
|
|
45
46
|
/**
|
|
46
47
|
* Define the delay before the popover is displayed.
|
|
47
48
|
* @default 0
|
package/portal/index.d.ts
CHANGED
|
@@ -3,3 +3,4 @@ export { setupOverlayArrow } from './overlay-arrow';
|
|
|
3
3
|
export { injectOverlayContext, provideOverlayContext } from './overlay-token';
|
|
4
4
|
export { createPortal, NgpComponentPortal, NgpPortal, NgpTemplatePortal } from './portal';
|
|
5
5
|
export { BlockScrollStrategy, NoopScrollStrategy, ScrollStrategy } from './scroll-strategy';
|
|
6
|
+
export { NgpOffset, NgpOffsetInput, NgpOffsetOptions, coerceOffset } from './offset';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for configuring offset between a floating element and its reference element.
|
|
3
|
+
* Can be a single number for uniform offset or an object for axis-specific control.
|
|
4
|
+
*/
|
|
5
|
+
export interface NgpOffsetOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The offset along the main axis (the axis that runs along the side of the floating element).
|
|
8
|
+
* Represents the distance between the floating element and the reference element.
|
|
9
|
+
* @default 0
|
|
10
|
+
*/
|
|
11
|
+
mainAxis?: number;
|
|
12
|
+
/**
|
|
13
|
+
* The offset along the cross axis (the axis that runs along the alignment of the floating element).
|
|
14
|
+
* Represents the skidding between the floating element and the reference element.
|
|
15
|
+
* @default 0
|
|
16
|
+
*/
|
|
17
|
+
crossAxis?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Same axis as crossAxis but applies only to aligned placements and inverts the end alignment.
|
|
20
|
+
* When set to a number, it overrides the crossAxis value.
|
|
21
|
+
* @default null
|
|
22
|
+
*/
|
|
23
|
+
alignmentAxis?: number | null;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Type representing all valid offset values.
|
|
27
|
+
* Can be a number (applies to mainAxis) or an object with axis-specific offsets.
|
|
28
|
+
*/
|
|
29
|
+
export type NgpOffset = number | NgpOffsetOptions;
|
|
30
|
+
/**
|
|
31
|
+
* Input type for offset that also accepts string representations of numbers
|
|
32
|
+
*/
|
|
33
|
+
export type NgpOffsetInput = NgpOffset | string;
|
|
34
|
+
/**
|
|
35
|
+
* Transform function to coerce offset input values to the correct type
|
|
36
|
+
* @param value The input value to coerce
|
|
37
|
+
* @returns The coerced offset value
|
|
38
|
+
*/
|
|
39
|
+
export declare function coerceOffset(value: NgpOffsetInput | null | undefined): NgpOffset;
|
package/portal/overlay.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { FocusOrigin } from '@angular/cdk/a11y';
|
|
|
2
2
|
import { Injector, Provider, Signal, TemplateRef, Type, ViewContainerRef } from '@angular/core';
|
|
3
3
|
import { Middleware, Placement, Strategy } from '@floating-ui/dom';
|
|
4
4
|
import { Subject } from 'rxjs';
|
|
5
|
+
import { NgpOffset } from './offset';
|
|
5
6
|
/**
|
|
6
7
|
* Configuration options for creating an overlay
|
|
7
8
|
* @internal
|
|
@@ -21,8 +22,8 @@ export interface NgpOverlayConfig<T = unknown> {
|
|
|
21
22
|
container?: HTMLElement | string | null;
|
|
22
23
|
/** Preferred placement of the overlay relative to the trigger. */
|
|
23
24
|
placement?: Signal<Placement>;
|
|
24
|
-
/** Offset distance between the overlay and trigger
|
|
25
|
-
offset?:
|
|
25
|
+
/** Offset distance between the overlay and trigger. Can be a number or an object with axis-specific offsets */
|
|
26
|
+
offset?: NgpOffset;
|
|
26
27
|
/** Whether to enable flip behavior when space is limited */
|
|
27
28
|
flip?: boolean;
|
|
28
29
|
/** Delay before showing the overlay in milliseconds */
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { InjectionToken, Provider } from '@angular/core';
|
|
2
2
|
import { type Placement } from '@floating-ui/dom';
|
|
3
|
+
import { NgpOffset } from 'ng-primitives/portal';
|
|
3
4
|
export interface NgpTooltipConfig {
|
|
4
5
|
/**
|
|
5
6
|
* Define the offset of the tooltip relative to the trigger.
|
|
7
|
+
* Can be a number (applies to mainAxis) or an object with mainAxis, crossAxis, and alignmentAxis.
|
|
6
8
|
* @default 4
|
|
7
9
|
*/
|
|
8
|
-
offset:
|
|
10
|
+
offset: NgpOffset;
|
|
9
11
|
/**
|
|
10
12
|
* Define the placement of the tooltip relative to the trigger.
|
|
11
13
|
* @default 'top'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BooleanInput, NumberInput } from '@angular/cdk/coercion';
|
|
2
2
|
import { OnDestroy, Signal } from '@angular/core';
|
|
3
|
-
import { NgpOverlay, NgpOverlayContent } from 'ng-primitives/portal';
|
|
3
|
+
import { NgpOverlay, NgpOverlayContent, NgpOffset, NgpOffsetInput } from 'ng-primitives/portal';
|
|
4
4
|
import * as i0 from "@angular/core";
|
|
5
5
|
type TooltipInput<T> = NgpOverlayContent<T> | string | null | undefined;
|
|
6
6
|
/**
|
|
@@ -39,9 +39,10 @@ export declare class NgpTooltipTrigger<T = null> implements OnDestroy {
|
|
|
39
39
|
readonly placement: import("@angular/core").InputSignal<NgpTooltipPlacement>;
|
|
40
40
|
/**
|
|
41
41
|
* Define the offset of the tooltip relative to the trigger.
|
|
42
|
+
* Can be a number (applies to mainAxis) or an object with mainAxis, crossAxis, and alignmentAxis.
|
|
42
43
|
* @default 0
|
|
43
44
|
*/
|
|
44
|
-
readonly offset: import("@angular/core").InputSignalWithTransform<
|
|
45
|
+
readonly offset: import("@angular/core").InputSignalWithTransform<NgpOffset, NgpOffsetInput>;
|
|
45
46
|
/**
|
|
46
47
|
* Define the delay before the tooltip is displayed.
|
|
47
48
|
* @default 500
|
|
@@ -37,3 +37,15 @@ export declare function isObject(value: unknown): value is Record<string, unknow
|
|
|
37
37
|
* @returns true if the value is undefined, false otherwise
|
|
38
38
|
*/
|
|
39
39
|
export declare function isUndefined(value: unknown): value is undefined;
|
|
40
|
+
/**
|
|
41
|
+
* Checks if a value is null or undefined
|
|
42
|
+
* @param value - The value to check
|
|
43
|
+
* @returns true if the value is null or undefined, false otherwise
|
|
44
|
+
*/
|
|
45
|
+
export declare function isNil(value: unknown): value is null | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Checks if a value is not null and not undefined
|
|
48
|
+
* @param value - The value to check
|
|
49
|
+
* @returns true if the value is not null and not undefined, false otherwise
|
|
50
|
+
*/
|
|
51
|
+
export declare function notNil<T>(value: T | null | undefined): value is T;
|
package/utils/index.d.ts
CHANGED
|
@@ -4,6 +4,6 @@ export { ChangeFn, TouchedFn } from './forms/types';
|
|
|
4
4
|
export { booleanAttributeBinding } from './helpers/attributes';
|
|
5
5
|
export { injectDisposables } from './helpers/disposables';
|
|
6
6
|
export { uniqueId } from './helpers/unique-id';
|
|
7
|
-
export { isBoolean, isFunction, isNumber, isObject, isString, isUndefined, } from './helpers/validators';
|
|
7
|
+
export { isBoolean, isFunction, isNumber, isObject, isString, isUndefined, isNil, notNil, } from './helpers/validators';
|
|
8
8
|
export { safeTakeUntilDestroyed } from './observables/take-until-destroyed';
|
|
9
9
|
export { onBooleanChange, onChange } from './signals';
|