@alaarab/ogrid-angular 2.0.2 → 2.0.4

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.
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Debounce utilities for Angular using signals.
3
+ * Provides functional parity with React's useDebounce and useDebouncedCallback.
4
+ */
5
+ import { type Signal } from '@angular/core';
6
+ /**
7
+ * Creates a debounced signal that updates after the specified delay when the source value changes.
8
+ *
9
+ * @param source - The signal to debounce
10
+ * @param delayMs - Delay in milliseconds
11
+ * @returns A signal containing the debounced value
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * const searchQuery = signal('');
16
+ * const debouncedQuery = createDebouncedSignal(searchQuery, 300);
17
+ *
18
+ * effect(() => {
19
+ * console.log('Debounced search:', debouncedQuery());
20
+ * });
21
+ * ```
22
+ */
23
+ export declare function createDebouncedSignal<T>(source: Signal<T>, delayMs: number): Signal<T>;
24
+ /**
25
+ * Creates a debounced function that delays invoking the provided function
26
+ * until after `delayMs` milliseconds have elapsed since the last time it was invoked.
27
+ *
28
+ * @param fn - The function to debounce
29
+ * @param delayMs - Delay in milliseconds
30
+ * @returns A debounced version of the function
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * const saveData = (value: string) => {
35
+ * console.log('Saving:', value);
36
+ * };
37
+ *
38
+ * const debouncedSave = createDebouncedCallback(saveData, 500);
39
+ *
40
+ * // Multiple rapid calls will only trigger once after 500ms
41
+ * debouncedSave('hello');
42
+ * debouncedSave('world'); // Only this will execute after 500ms
43
+ * ```
44
+ */
45
+ export declare function createDebouncedCallback<T extends (...args: unknown[]) => void>(fn: T, delayMs: number): T;
46
+ /**
47
+ * Simple debounce function (non-Angular-specific, can be used anywhere).
48
+ * Returns a debounced version of the provided function.
49
+ *
50
+ * @param fn - The function to debounce
51
+ * @param delayMs - Delay in milliseconds
52
+ * @returns A debounced version of the function with a `cancel()` method
53
+ *
54
+ * @example
55
+ * ```typescript
56
+ * const handleResize = debounce(() => {
57
+ * console.log('Window resized');
58
+ * }, 200);
59
+ *
60
+ * window.addEventListener('resize', handleResize);
61
+ *
62
+ * // Later, cancel pending execution
63
+ * handleResize.cancel();
64
+ * ```
65
+ */
66
+ export declare function debounce<T extends (...args: unknown[]) => void>(fn: T, delayMs: number): T & {
67
+ cancel: () => void;
68
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Shared utilities for Angular DataGridTable view layer.
3
+ */
4
+ export type { HeaderFilterConfigInput, HeaderFilterConfig, CellRenderDescriptorInput, CellRenderDescriptor, CellRenderMode, } from './dataGridViewModel';
5
+ export { getHeaderFilterConfig, getCellRenderDescriptor, resolveCellDisplayContent, resolveCellStyle, } from './dataGridViewModel';
6
+ export { createDebouncedSignal, createDebouncedCallback, debounce, } from './debounce';
7
+ export { createLatestRef, createLatestCallback, } from './latestRef';
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Latest ref utility for Angular using signals.
3
+ * Provides functional parity with React's useLatestRef.
4
+ */
5
+ import { type Signal } from '@angular/core';
6
+ /**
7
+ * Creates a stable wrapper function that always calls the latest version of the provided function.
8
+ * Useful for event handlers and callbacks where you want a stable reference but need to call
9
+ * the latest implementation.
10
+ *
11
+ * @param fn - Signal containing the function to wrap
12
+ * @returns A stable function that always invokes the latest version
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * class MyService {
17
+ * readonly onSave = signal<(value: string) => void>((val) => console.log('Default:', val));
18
+ * readonly stableOnSave = createLatestCallback(this.onSave);
19
+ *
20
+ * constructor() {
21
+ * // Setup event listener with stable reference
22
+ * effect((onCleanup) => {
23
+ * // stableOnSave never changes, so this effect only runs once
24
+ * const callback = () => this.stableOnSave('data');
25
+ * window.addEventListener('click', callback);
26
+ * onCleanup(() => window.removeEventListener('click', callback));
27
+ * });
28
+ * }
29
+ *
30
+ * updateHandler(newFn: (value: string) => void) {
31
+ * // Even though we change the function, the callback reference stays stable
32
+ * this.onSave.set(newFn);
33
+ * }
34
+ * }
35
+ * ```
36
+ */
37
+ export declare function createLatestCallback<T extends (...args: unknown[]) => unknown>(fn: Signal<T>): T;
38
+ /**
39
+ * Alias for createLatestCallback for consistency with React/Vue naming.
40
+ * @deprecated Use createLatestCallback instead
41
+ */
42
+ export declare const createLatestRef: typeof createLatestCallback;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alaarab/ogrid-angular",
3
- "version": "2.0.2",
3
+ "version": "2.0.4",
4
4
  "description": "OGrid Angular – Angular services, signals, and headless components for OGrid data grids.",
5
5
  "main": "dist/esm/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -22,7 +22,7 @@
22
22
  "files": ["dist", "README.md", "LICENSE"],
23
23
  "engines": { "node": ">=18" },
24
24
  "dependencies": {
25
- "@alaarab/ogrid-core": "2.0.2"
25
+ "@alaarab/ogrid-core": "2.0.4"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "@angular/core": "^21.0.0",