@dmlibs/dm-cmps 0.1.10 → 0.1.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dmlibs/dm-cmps",
3
- "version": "0.1.10",
3
+ "version": "0.1.12",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^21.0.0",
6
6
  "@angular/core": "^21.0.0"
@@ -1,5 +1,5 @@
1
1
  import * as _angular_core from '@angular/core';
2
- import { Signal, InputSignal, InputSignalWithTransform, ModelSignal, OutputEmitterRef, OnDestroy, Renderer2, Type, TemplateRef } from '@angular/core';
2
+ import { Signal, InputSignal, InputSignalWithTransform, ModelSignal, OutputEmitterRef, OnDestroy, Renderer2, Type, TemplateRef, PipeTransform } from '@angular/core';
3
3
  import { MatSelectChange } from '@angular/material/select';
4
4
  import { FormControl } from '@angular/forms';
5
5
  import { MatOptionSelectionChange } from '@angular/material/core';
@@ -598,7 +598,7 @@ declare class DmMatSelect<T = any> implements DmMatSelectConfig<T>, OnDestroy {
598
598
  value: _angular_core.ModelSignal<DmMatSelectOutput<T>>;
599
599
  formControl: _angular_core.InputSignal<FormControl<DmMatSelectOutput<T>> | null>;
600
600
  panelWidth: _angular_core.InputSignal<string | null>;
601
- panelClass: _angular_core.InputSignal<string | Set<string> | string[] | {
601
+ panelClass: _angular_core.InputSignal<string | string[] | Set<string> | {
602
602
  [key: string]: any;
603
603
  }>;
604
604
  searchSectionBackgroundColor: _angular_core.InputSignal<string | null>;
@@ -1350,15 +1350,15 @@ declare class DmIcon {
1350
1350
  static ɵcmp: _angular_core.ɵɵComponentDeclaration<DmIcon, "dm-icon", never, { "icon": { "alias": "icon"; "required": true; "isSignal": true; }; "color": { "alias": "color"; "required": false; "isSignal": true; }; "size": { "alias": "size"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
1351
1351
  }
1352
1352
 
1353
- type DmCmpsDateTypes = any | Date | string | {
1353
+ type DmDateTypes = any | Date | string | {
1354
1354
  _seconds: number;
1355
1355
  _nanoseconds: number;
1356
1356
  } | {
1357
1357
  seconds: number;
1358
1358
  nanoseconds: number;
1359
1359
  } | number | null;
1360
- type DmCmpsDateFormats = 'dd/MM/yyyy' | 'yyyy/MM/dd' | 'dd/MM/yyyy HH:mm';
1361
- type DmCmpsLangs = 'en' | 'he' | 'ar';
1360
+ type DmDateFormats = 'dd/MM/yyyy' | 'yyyy/MM/dd' | 'dd/MM/yyyy HH:mm';
1361
+ type DmLangs = 'en' | 'he' | 'ar';
1362
1362
  declare global {
1363
1363
  interface Date {
1364
1364
  getWeekOfYear(): number;
@@ -1367,7 +1367,7 @@ declare global {
1367
1367
  }
1368
1368
  }
1369
1369
  declare class DmDateService {
1370
- getDate(date: DmCmpsDateTypes): Date | null;
1370
+ getDate(date: DmDateTypes): Date | null;
1371
1371
  /**
1372
1372
  *
1373
1373
  * @param date the date to transform
@@ -1393,7 +1393,7 @@ declare class DmDateService {
1393
1393
  * - 'DM_mw' - the week of the month
1394
1394
  * - 'DM_yd' - the day of the year
1395
1395
  */
1396
- getDateString(date: DmCmpsDateTypes, format?: DmCmpsDateFormats | string, lang?: DmCmpsLangs): string;
1396
+ getDateString(date: DmDateTypes, format?: DmDateFormats | string, lang?: DmLangs): string;
1397
1397
  /**
1398
1398
  *
1399
1399
  * @param date the date to transform
@@ -1419,16 +1419,190 @@ declare class DmDateService {
1419
1419
  * - 'DM_mw' - the week of the month
1420
1420
  * - 'DM_yd' - the day of the year
1421
1421
  */
1422
- static getDateString(date: DmCmpsDateTypes, format?: DmCmpsDateFormats | string, lang?: DmCmpsLangs): string;
1423
- static getDate(date: DmCmpsDateTypes): Date | null;
1424
- static getTimeString(date: DmCmpsDateTypes): string;
1422
+ static getDateString(date: DmDateTypes, format?: DmDateFormats | string, lang?: DmLangs): string;
1423
+ static getDate(date: DmDateTypes): Date | null;
1424
+ static getTimeString(date: DmDateTypes): string;
1425
1425
  static now(): Date;
1426
1426
  now(): Date;
1427
- getAge(date: DmCmpsDateTypes, fixed?: number | null, result?: 'string' | 'number'): number | string;
1428
- static getAge(date: DmCmpsDateTypes, fixed?: number | null, result?: 'string' | 'number'): number | string;
1427
+ getAge(date: DmDateTypes, fixed?: number | null, result?: 'string' | 'number'): number | string;
1428
+ static getAge(date: DmDateTypes, fixed?: number | null, result?: 'string' | 'number'): number | string;
1429
1429
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<DmDateService, never>;
1430
1430
  static ɵprov: _angular_core.ɵɵInjectableDeclaration<DmDateService>;
1431
1431
  }
1432
1432
 
1433
- export { DmCmpsDataSource, DmColorPicker, DmDateService, DmIcon, DmMatSelect, DmSpinner, DmSpinnerService, DmTable };
1433
+ declare class DmDatePipe implements PipeTransform {
1434
+ /**
1435
+ * Transforms a date to a string
1436
+ * @param value - the date to transform
1437
+ * @param format - the format of the date
1438
+ * @param lang - the language of the date
1439
+ * @returns the date as a string
1440
+ * @example
1441
+ * {{ date | dmDate: 'dd/MM/yyyy' }}
1442
+ * {{ date | dmDate: 'dd/MM/yyyy HH:mm' }}
1443
+ * {{ date | dmDate: 'yyyy/MM/dd' }}
1444
+ * {{ date | dmDate: 'dd/MM/yyyy': 'en' }}
1445
+ * {{ date | dmDate: 'dd/MM/yyyy': 'he' }}
1446
+ * {{ date | dmDate: 'dd/MM/yyyy': 'ar' }}
1447
+ * {{ date | dmDate: 'dd/MM/yyyy HH:mm': 'en' }}
1448
+ * {{ date | dmDate: 'dd/MM/yyyy HH:mm': 'he' }}
1449
+ * {{ date | dmDate: 'dd/MM/yyyy HH:mm': 'ar' }}
1450
+ * {{ date | dmDate: 'yyyy/MM/dd': 'en' }}
1451
+ * {{ date | dmDate: 'yyyy/MM/dd': 'he' }}
1452
+ *
1453
+ * The format can be any string that contains the following:
1454
+ * - 'dd' - the day of the month
1455
+ * - 'MM' - the month
1456
+ * - 'yyyy' - the year
1457
+ * - 'yy' - the year (2 digits)
1458
+ * - 'HH' - the hour
1459
+ * - 'mm' - the minute
1460
+ * - 'ss' - the second
1461
+ * - 'SSS' - the millisecond
1462
+ * - 'DM_a' - the AM/PM
1463
+ * - 'DM_E' - the day of the week
1464
+ * - 'DM_Z' - the time zone
1465
+ * - 'DM_z' - the time zone offset
1466
+ * - 'DM_yw' - the week of the year
1467
+ * - 'DM_mw' - the week of the month
1468
+ * - 'DM_yd' - the day of the year
1469
+ */
1470
+ transform(value: DmDateTypes, format?: DmDateFormats | string, lang?: DmLangs): string;
1471
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<DmDatePipe, never>;
1472
+ static ɵpipe: _angular_core.ɵɵPipeDeclaration<DmDatePipe, "dmDate", true>;
1473
+ }
1474
+
1475
+ declare class DmRunOncePipeSevice {
1476
+ private cache;
1477
+ private argsMap;
1478
+ generateFunctionKey(func: (...args: any[]) => any, ...args: any[]): string;
1479
+ getOrCache(key: string, fn: () => any, args: any[]): any;
1480
+ private clearCache;
1481
+ /**
1482
+ *
1483
+ * @param func - the function that called with the pipe `runOnce`
1484
+ *
1485
+ * @result when you need to trigger the function again, just call `triggerFunction` with the function
1486
+ *
1487
+ * @usageExample
1488
+ *
1489
+ * #### html
1490
+ * ```html
1491
+ * <!-- example without properties -->
1492
+ * <div [innerText]="myFucntion.bind(this) | runOnce"></div>
1493
+ *
1494
+ * <!-- example with properties -->
1495
+ * <div [innerText]="myFucntion.bind(this) | runOnce : '1122'"></div>
1496
+ * ```
1497
+ *
1498
+ * you can define properties as you need
1499
+ *
1500
+ * #### typescript
1501
+ * ```typescript
1502
+ * export class YourComponent {
1503
+ * constructor(private runOncePipeService: DmCmpsRunOncePipeService) {}
1504
+ *
1505
+ * myFucntion(prop?: any) {
1506
+ * let result: any;
1507
+ * // any logic here
1508
+ * return result;
1509
+ * }
1510
+ *
1511
+ * //this will trigger the function every time its called
1512
+ * triggerFunction() {
1513
+ * this.runOncePipeService.triggerFunction(this.myFucntion)
1514
+ * }
1515
+ * }
1516
+ * ```
1517
+ */
1518
+ triggerFunction(func: (...args: any[]) => any): void;
1519
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<DmRunOncePipeSevice, never>;
1520
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<DmRunOncePipeSevice>;
1521
+ }
1522
+
1523
+ declare class DmFilterByPipe implements PipeTransform {
1524
+ /**
1525
+ *
1526
+ * @param array - (any[]) source array
1527
+ * @param filterPredicate - can get a function or object:
1528
+ *
1529
+ * @usageNotes
1530
+ * #### Example as function
1531
+ *
1532
+ * ```typescript
1533
+ * filterPredicateFunction(item: any) {
1534
+ * return item.age > 18 && item.weight > 80;
1535
+ * }
1536
+ * ```
1537
+ *
1538
+ * #### Example as object
1539
+ *
1540
+ * ```typescript
1541
+ * filterPredicateObject: { [key: string]: any } = {
1542
+ * age: 18,
1543
+ * weight: 80
1544
+ * }
1545
+ * ```
1546
+ *
1547
+ * @usageExample
1548
+ * #### Use function predicate
1549
+ * ```html
1550
+ * <div *ngFor="let item of source | filterBy: filterPredicateFunction.bind(this)">
1551
+ * <!-- any html content here -->
1552
+ * </div>
1553
+ * ```
1554
+ *
1555
+ * #### Use object - with check all
1556
+ * ```html
1557
+ * <div *ngFor="let item of source | filterBy: filterPredicateObject">
1558
+ * <!-- any html content here -->
1559
+ * </div>
1560
+ * ```
1561
+ *
1562
+ * #### Use object - returns the items that have some properties from the object
1563
+ * ```html
1564
+ * <div *ngFor="let item of source | filterBy: filterPredicateObject : false">
1565
+ * <!-- any html content here -->
1566
+ * </div>
1567
+ * ```
1568
+ *
1569
+ * @param checkAll - when `filterPredicate` is an object,
1570
+ * if `checkAll=true` it will return just the elements that have the `filterPredicate` keys and values,
1571
+ * if `checkAll=false` it will return all the elements thet have some properties from the `filterPredicate` with same values,
1572
+ * | default is `checkAll=true`
1573
+ *
1574
+ *
1575
+ * @returns (any[]) filterd array
1576
+ */
1577
+ transform(array: any[], filterPredicate: ((item: any) => boolean) | {
1578
+ [key: string]: any;
1579
+ }, checkAll?: boolean, ...args: any[]): any[];
1580
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<DmFilterByPipe, never>;
1581
+ static ɵpipe: _angular_core.ɵɵPipeDeclaration<DmFilterByPipe, "filterBy", true>;
1582
+ }
1583
+
1584
+ declare class DmRunOncePipe implements PipeTransform {
1585
+ private runOncePipeService;
1586
+ constructor(runOncePipeService: DmRunOncePipeSevice);
1587
+ /**
1588
+ * @explain - Runs the specified function only once, simplifying function calls in HTML.
1589
+ * - This prevents redundant computations by caching results.
1590
+ * @param func - The function to be executed only once.
1591
+ * @param args - The arguments to be passed to the `func` function.
1592
+ * @result The result of executing the `func` function, or the cached result if already executed.
1593
+ * ### Example of Usage
1594
+ * ```html
1595
+ * <!-- function without arguments -->
1596
+ * <div [innerText]="myFunction.bind(this) | runOnce"></div>
1597
+ *
1598
+ * <!-- function with arguments -->
1599
+ * <div [innerText]="myFunction.bind(this) | runOnce : '' : myVariable : false"></div>
1600
+ * ```
1601
+ */
1602
+ transform(func: (...args: any[]) => any, ...args: any[]): any;
1603
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<DmRunOncePipe, never>;
1604
+ static ɵpipe: _angular_core.ɵɵPipeDeclaration<DmRunOncePipe, "runOnce", true>;
1605
+ }
1606
+
1607
+ export { DmCmpsDataSource, DmColorPicker, DmDatePipe, DmDateService, DmFilterByPipe, DmIcon, DmMatSelect, DmRunOncePipe, DmRunOncePipeSevice, DmSpinner, DmSpinnerService, DmTable };
1434
1608
  export type { DmCmpsDataSourceSort, DmTableActionButton, DmTableClasses, DmTableColumn, DmTableColumnHeaderMenuItem, DmTablePaginatorSettings, DmTableRowActionButton, DmTableStyle };