@dmlibs/dm-cmps 0.1.11 → 0.1.13

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.11",
3
+ "version": "0.1.13",
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';
@@ -573,6 +573,11 @@ type DmMatSelectOutput<T> = T | T[] | string | string[] | number | number[] | nu
573
573
  type DmMatSelectOption<T> = T & {
574
574
  __dmMatSelectFormattedName: string;
575
575
  };
576
+ interface DmSelectOnSelectionChange<T> {
577
+ selected: boolean;
578
+ optionRef: T | null;
579
+ value: DmMatSelectOutput<T>;
580
+ }
576
581
  declare class DmMatSelect<T = any> implements DmMatSelectConfig<T>, OnDestroy {
577
582
  formFieldClass: _angular_core.InputSignal<string>;
578
583
  wrapperClass: _angular_core.InputSignal<string>;
@@ -606,6 +611,7 @@ declare class DmMatSelect<T = any> implements DmMatSelectConfig<T>, OnDestroy {
606
611
  private internalControl;
607
612
  protected control: _angular_core.Signal<FormControl<DmMatSelectOutput<T>>>;
608
613
  selectionChange: _angular_core.OutputEmitterRef<MatSelectChange<DmMatSelectOutput<T>>>;
614
+ onSelectionChange: _angular_core.OutputEmitterRef<DmSelectOnSelectionChange<T>>;
609
615
  icon: _angular_core.InputSignal<string | null>;
610
616
  protected isBootstrapIcon: _angular_core.Signal<boolean>;
611
617
  noDataLabel: _angular_core.InputSignal<string>;
@@ -626,12 +632,13 @@ declare class DmMatSelect<T = any> implements DmMatSelectConfig<T>, OnDestroy {
626
632
  protected applyFilter(event: KeyboardEvent): void;
627
633
  protected selectionChangeHandler(event: MatSelectChange<T | T[] | null>): void;
628
634
  private getOptionValue;
635
+ private emitSelectionChange;
629
636
  protected onSelectionChangeHandler(event: MatOptionSelectionChange, option: T | null): void;
630
637
  protected selectAllChange(event: MatCheckboxChange): void;
631
638
  protected resetSearch(): void;
632
639
  protected onPanelOpened(): void;
633
640
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<DmMatSelect<any>, never>;
634
- static ɵcmp: _angular_core.ɵɵComponentDeclaration<DmMatSelect<any>, "dm-mat-select", never, { "formFieldClass": { "alias": "formFieldClass"; "required": false; "isSignal": true; }; "wrapperClass": { "alias": "wrapperClass"; "required": false; "isSignal": true; }; "appearance": { "alias": "appearance"; "required": false; "isSignal": true; }; "multiple": { "alias": "multiple"; "required": false; "isSignal": true; }; "selectAllEnabled": { "alias": "selectAllEnabled"; "required": false; "isSignal": true; }; "selectAllLabel": { "alias": "selectAllLabel"; "required": false; "isSignal": true; }; "label": { "alias": "label"; "required": false; "isSignal": true; }; "options": { "alias": "options"; "required": false; "isSignal": true; }; "optionValueKey": { "alias": "optionValueKey"; "required": false; "isSignal": true; }; "optionLabelKey": { "alias": "optionLabelKey"; "required": false; "isSignal": true; }; "searchable": { "alias": "searchable"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "error": { "alias": "error"; "required": false; "isSignal": true; }; "searchPlaceholder": { "alias": "searchPlaceholder"; "required": false; "isSignal": true; }; "emptyOption": { "alias": "emptyOption"; "required": false; "isSignal": true; }; "emptyOptionLabel": { "alias": "emptyOptionLabel"; "required": false; "isSignal": true; }; "emptyOptionValue": { "alias": "emptyOptionValue"; "required": false; "isSignal": true; }; "optionNameFormat": { "alias": "optionNameFormat"; "required": false; "isSignal": true; }; "value": { "alias": "value"; "required": false; "isSignal": true; }; "formControl": { "alias": "formControl"; "required": false; "isSignal": true; }; "panelWidth": { "alias": "panelWidth"; "required": false; "isSignal": true; }; "panelClass": { "alias": "panelClass"; "required": false; "isSignal": true; }; "searchSectionBackgroundColor": { "alias": "searchSectionBackgroundColor"; "required": false; "isSignal": true; }; "sortBySelectedOnTop": { "alias": "sortBySelectedOnTop"; "required": false; "isSignal": true; }; "icon": { "alias": "icon"; "required": false; "isSignal": true; }; "noDataLabel": { "alias": "noDataLabel"; "required": false; "isSignal": true; }; "clearSearchAfterSelect": { "alias": "clearSearchAfterSelect"; "required": false; "isSignal": true; }; "clearSearchButtonTooltip": { "alias": "clearSearchButtonTooltip"; "required": false; "isSignal": true; }; "focusSearchInputOnPanelOpen": { "alias": "focusSearchInputOnPanelOpen"; "required": false; "isSignal": true; }; "filterPredicate": { "alias": "filterPredicate"; "required": false; "isSignal": true; }; "propertiesToSkipInSearch": { "alias": "propertiesToSkipInSearch"; "required": false; "isSignal": true; }; "filterText": { "alias": "filterText"; "required": false; "isSignal": true; }; }, { "value": "valueChange"; "selectionChange": "selectionChange"; "filterText": "filterTextChange"; }, never, ["[dm-mat-select-suffix]"], true, never>;
641
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<DmMatSelect<any>, "dm-mat-select", never, { "formFieldClass": { "alias": "formFieldClass"; "required": false; "isSignal": true; }; "wrapperClass": { "alias": "wrapperClass"; "required": false; "isSignal": true; }; "appearance": { "alias": "appearance"; "required": false; "isSignal": true; }; "multiple": { "alias": "multiple"; "required": false; "isSignal": true; }; "selectAllEnabled": { "alias": "selectAllEnabled"; "required": false; "isSignal": true; }; "selectAllLabel": { "alias": "selectAllLabel"; "required": false; "isSignal": true; }; "label": { "alias": "label"; "required": false; "isSignal": true; }; "options": { "alias": "options"; "required": false; "isSignal": true; }; "optionValueKey": { "alias": "optionValueKey"; "required": false; "isSignal": true; }; "optionLabelKey": { "alias": "optionLabelKey"; "required": false; "isSignal": true; }; "searchable": { "alias": "searchable"; "required": false; "isSignal": true; }; "required": { "alias": "required"; "required": false; "isSignal": true; }; "disabled": { "alias": "disabled"; "required": false; "isSignal": true; }; "error": { "alias": "error"; "required": false; "isSignal": true; }; "searchPlaceholder": { "alias": "searchPlaceholder"; "required": false; "isSignal": true; }; "emptyOption": { "alias": "emptyOption"; "required": false; "isSignal": true; }; "emptyOptionLabel": { "alias": "emptyOptionLabel"; "required": false; "isSignal": true; }; "emptyOptionValue": { "alias": "emptyOptionValue"; "required": false; "isSignal": true; }; "optionNameFormat": { "alias": "optionNameFormat"; "required": false; "isSignal": true; }; "value": { "alias": "value"; "required": false; "isSignal": true; }; "formControl": { "alias": "formControl"; "required": false; "isSignal": true; }; "panelWidth": { "alias": "panelWidth"; "required": false; "isSignal": true; }; "panelClass": { "alias": "panelClass"; "required": false; "isSignal": true; }; "searchSectionBackgroundColor": { "alias": "searchSectionBackgroundColor"; "required": false; "isSignal": true; }; "sortBySelectedOnTop": { "alias": "sortBySelectedOnTop"; "required": false; "isSignal": true; }; "icon": { "alias": "icon"; "required": false; "isSignal": true; }; "noDataLabel": { "alias": "noDataLabel"; "required": false; "isSignal": true; }; "clearSearchAfterSelect": { "alias": "clearSearchAfterSelect"; "required": false; "isSignal": true; }; "clearSearchButtonTooltip": { "alias": "clearSearchButtonTooltip"; "required": false; "isSignal": true; }; "focusSearchInputOnPanelOpen": { "alias": "focusSearchInputOnPanelOpen"; "required": false; "isSignal": true; }; "filterPredicate": { "alias": "filterPredicate"; "required": false; "isSignal": true; }; "propertiesToSkipInSearch": { "alias": "propertiesToSkipInSearch"; "required": false; "isSignal": true; }; "filterText": { "alias": "filterText"; "required": false; "isSignal": true; }; }, { "value": "valueChange"; "selectionChange": "selectionChange"; "onSelectionChange": "onSelectionChange"; "filterText": "filterTextChange"; }, never, ["[dm-mat-select-suffix]"], true, never>;
635
642
  }
636
643
 
637
644
  interface DmCmpsColor {
@@ -1350,15 +1357,15 @@ declare class DmIcon {
1350
1357
  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
1358
  }
1352
1359
 
1353
- type DmCmpsDateTypes = any | Date | string | {
1360
+ type DmDateTypes = any | Date | string | {
1354
1361
  _seconds: number;
1355
1362
  _nanoseconds: number;
1356
1363
  } | {
1357
1364
  seconds: number;
1358
1365
  nanoseconds: number;
1359
1366
  } | number | null;
1360
- type DmCmpsDateFormats = 'dd/MM/yyyy' | 'yyyy/MM/dd' | 'dd/MM/yyyy HH:mm';
1361
- type DmCmpsLangs = 'en' | 'he' | 'ar';
1367
+ type DmDateFormats = 'dd/MM/yyyy' | 'yyyy/MM/dd' | 'dd/MM/yyyy HH:mm';
1368
+ type DmLangs = 'en' | 'he' | 'ar';
1362
1369
  declare global {
1363
1370
  interface Date {
1364
1371
  getWeekOfYear(): number;
@@ -1367,7 +1374,7 @@ declare global {
1367
1374
  }
1368
1375
  }
1369
1376
  declare class DmDateService {
1370
- getDate(date: DmCmpsDateTypes): Date | null;
1377
+ getDate(date: DmDateTypes): Date | null;
1371
1378
  /**
1372
1379
  *
1373
1380
  * @param date the date to transform
@@ -1393,7 +1400,7 @@ declare class DmDateService {
1393
1400
  * - 'DM_mw' - the week of the month
1394
1401
  * - 'DM_yd' - the day of the year
1395
1402
  */
1396
- getDateString(date: DmCmpsDateTypes, format?: DmCmpsDateFormats | string, lang?: DmCmpsLangs): string;
1403
+ getDateString(date: DmDateTypes, format?: DmDateFormats | string, lang?: DmLangs): string;
1397
1404
  /**
1398
1405
  *
1399
1406
  * @param date the date to transform
@@ -1419,16 +1426,190 @@ declare class DmDateService {
1419
1426
  * - 'DM_mw' - the week of the month
1420
1427
  * - 'DM_yd' - the day of the year
1421
1428
  */
1422
- static getDateString(date: DmCmpsDateTypes, format?: DmCmpsDateFormats | string, lang?: DmCmpsLangs): string;
1423
- static getDate(date: DmCmpsDateTypes): Date | null;
1424
- static getTimeString(date: DmCmpsDateTypes): string;
1429
+ static getDateString(date: DmDateTypes, format?: DmDateFormats | string, lang?: DmLangs): string;
1430
+ static getDate(date: DmDateTypes): Date | null;
1431
+ static getTimeString(date: DmDateTypes): string;
1425
1432
  static now(): Date;
1426
1433
  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;
1434
+ getAge(date: DmDateTypes, fixed?: number | null, result?: 'string' | 'number'): number | string;
1435
+ static getAge(date: DmDateTypes, fixed?: number | null, result?: 'string' | 'number'): number | string;
1429
1436
  static ɵfac: _angular_core.ɵɵFactoryDeclaration<DmDateService, never>;
1430
1437
  static ɵprov: _angular_core.ɵɵInjectableDeclaration<DmDateService>;
1431
1438
  }
1432
1439
 
1433
- export { DmCmpsDataSource, DmColorPicker, DmDateService, DmIcon, DmMatSelect, DmSpinner, DmSpinnerService, DmTable };
1440
+ declare class DmDatePipe implements PipeTransform {
1441
+ /**
1442
+ * Transforms a date to a string
1443
+ * @param value - the date to transform
1444
+ * @param format - the format of the date
1445
+ * @param lang - the language of the date
1446
+ * @returns the date as a string
1447
+ * @example
1448
+ * {{ date | dmDate: 'dd/MM/yyyy' }}
1449
+ * {{ date | dmDate: 'dd/MM/yyyy HH:mm' }}
1450
+ * {{ date | dmDate: 'yyyy/MM/dd' }}
1451
+ * {{ date | dmDate: 'dd/MM/yyyy': 'en' }}
1452
+ * {{ date | dmDate: 'dd/MM/yyyy': 'he' }}
1453
+ * {{ date | dmDate: 'dd/MM/yyyy': 'ar' }}
1454
+ * {{ date | dmDate: 'dd/MM/yyyy HH:mm': 'en' }}
1455
+ * {{ date | dmDate: 'dd/MM/yyyy HH:mm': 'he' }}
1456
+ * {{ date | dmDate: 'dd/MM/yyyy HH:mm': 'ar' }}
1457
+ * {{ date | dmDate: 'yyyy/MM/dd': 'en' }}
1458
+ * {{ date | dmDate: 'yyyy/MM/dd': 'he' }}
1459
+ *
1460
+ * The format can be any string that contains the following:
1461
+ * - 'dd' - the day of the month
1462
+ * - 'MM' - the month
1463
+ * - 'yyyy' - the year
1464
+ * - 'yy' - the year (2 digits)
1465
+ * - 'HH' - the hour
1466
+ * - 'mm' - the minute
1467
+ * - 'ss' - the second
1468
+ * - 'SSS' - the millisecond
1469
+ * - 'DM_a' - the AM/PM
1470
+ * - 'DM_E' - the day of the week
1471
+ * - 'DM_Z' - the time zone
1472
+ * - 'DM_z' - the time zone offset
1473
+ * - 'DM_yw' - the week of the year
1474
+ * - 'DM_mw' - the week of the month
1475
+ * - 'DM_yd' - the day of the year
1476
+ */
1477
+ transform(value: DmDateTypes, format?: DmDateFormats | string, lang?: DmLangs): string;
1478
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<DmDatePipe, never>;
1479
+ static ɵpipe: _angular_core.ɵɵPipeDeclaration<DmDatePipe, "dmDate", true>;
1480
+ }
1481
+
1482
+ declare class DmRunOncePipeSevice {
1483
+ private cache;
1484
+ private argsMap;
1485
+ generateFunctionKey(func: (...args: any[]) => any, ...args: any[]): string;
1486
+ getOrCache(key: string, fn: () => any, args: any[]): any;
1487
+ private clearCache;
1488
+ /**
1489
+ *
1490
+ * @param func - the function that called with the pipe `runOnce`
1491
+ *
1492
+ * @result when you need to trigger the function again, just call `triggerFunction` with the function
1493
+ *
1494
+ * @usageExample
1495
+ *
1496
+ * #### html
1497
+ * ```html
1498
+ * <!-- example without properties -->
1499
+ * <div [innerText]="myFucntion.bind(this) | runOnce"></div>
1500
+ *
1501
+ * <!-- example with properties -->
1502
+ * <div [innerText]="myFucntion.bind(this) | runOnce : '1122'"></div>
1503
+ * ```
1504
+ *
1505
+ * you can define properties as you need
1506
+ *
1507
+ * #### typescript
1508
+ * ```typescript
1509
+ * export class YourComponent {
1510
+ * constructor(private runOncePipeService: DmCmpsRunOncePipeService) {}
1511
+ *
1512
+ * myFucntion(prop?: any) {
1513
+ * let result: any;
1514
+ * // any logic here
1515
+ * return result;
1516
+ * }
1517
+ *
1518
+ * //this will trigger the function every time its called
1519
+ * triggerFunction() {
1520
+ * this.runOncePipeService.triggerFunction(this.myFucntion)
1521
+ * }
1522
+ * }
1523
+ * ```
1524
+ */
1525
+ triggerFunction(func: (...args: any[]) => any): void;
1526
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<DmRunOncePipeSevice, never>;
1527
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<DmRunOncePipeSevice>;
1528
+ }
1529
+
1530
+ declare class DmFilterByPipe implements PipeTransform {
1531
+ /**
1532
+ *
1533
+ * @param array - (any[]) source array
1534
+ * @param filterPredicate - can get a function or object:
1535
+ *
1536
+ * @usageNotes
1537
+ * #### Example as function
1538
+ *
1539
+ * ```typescript
1540
+ * filterPredicateFunction(item: any) {
1541
+ * return item.age > 18 && item.weight > 80;
1542
+ * }
1543
+ * ```
1544
+ *
1545
+ * #### Example as object
1546
+ *
1547
+ * ```typescript
1548
+ * filterPredicateObject: { [key: string]: any } = {
1549
+ * age: 18,
1550
+ * weight: 80
1551
+ * }
1552
+ * ```
1553
+ *
1554
+ * @usageExample
1555
+ * #### Use function predicate
1556
+ * ```html
1557
+ * <div *ngFor="let item of source | filterBy: filterPredicateFunction.bind(this)">
1558
+ * <!-- any html content here -->
1559
+ * </div>
1560
+ * ```
1561
+ *
1562
+ * #### Use object - with check all
1563
+ * ```html
1564
+ * <div *ngFor="let item of source | filterBy: filterPredicateObject">
1565
+ * <!-- any html content here -->
1566
+ * </div>
1567
+ * ```
1568
+ *
1569
+ * #### Use object - returns the items that have some properties from the object
1570
+ * ```html
1571
+ * <div *ngFor="let item of source | filterBy: filterPredicateObject : false">
1572
+ * <!-- any html content here -->
1573
+ * </div>
1574
+ * ```
1575
+ *
1576
+ * @param checkAll - when `filterPredicate` is an object,
1577
+ * if `checkAll=true` it will return just the elements that have the `filterPredicate` keys and values,
1578
+ * if `checkAll=false` it will return all the elements thet have some properties from the `filterPredicate` with same values,
1579
+ * | default is `checkAll=true`
1580
+ *
1581
+ *
1582
+ * @returns (any[]) filterd array
1583
+ */
1584
+ transform(array: any[], filterPredicate: ((item: any) => boolean) | {
1585
+ [key: string]: any;
1586
+ }, checkAll?: boolean, ...args: any[]): any[];
1587
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<DmFilterByPipe, never>;
1588
+ static ɵpipe: _angular_core.ɵɵPipeDeclaration<DmFilterByPipe, "filterBy", true>;
1589
+ }
1590
+
1591
+ declare class DmRunOncePipe implements PipeTransform {
1592
+ private runOncePipeService;
1593
+ constructor(runOncePipeService: DmRunOncePipeSevice);
1594
+ /**
1595
+ * @explain - Runs the specified function only once, simplifying function calls in HTML.
1596
+ * - This prevents redundant computations by caching results.
1597
+ * @param func - The function to be executed only once.
1598
+ * @param args - The arguments to be passed to the `func` function.
1599
+ * @result The result of executing the `func` function, or the cached result if already executed.
1600
+ * ### Example of Usage
1601
+ * ```html
1602
+ * <!-- function without arguments -->
1603
+ * <div [innerText]="myFunction.bind(this) | runOnce"></div>
1604
+ *
1605
+ * <!-- function with arguments -->
1606
+ * <div [innerText]="myFunction.bind(this) | runOnce : '' : myVariable : false"></div>
1607
+ * ```
1608
+ */
1609
+ transform(func: (...args: any[]) => any, ...args: any[]): any;
1610
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<DmRunOncePipe, never>;
1611
+ static ɵpipe: _angular_core.ɵɵPipeDeclaration<DmRunOncePipe, "runOnce", true>;
1612
+ }
1613
+
1614
+ export { DmCmpsDataSource, DmColorPicker, DmDatePipe, DmDateService, DmFilterByPipe, DmIcon, DmMatSelect, DmRunOncePipe, DmRunOncePipeSevice, DmSpinner, DmSpinnerService, DmTable };
1434
1615
  export type { DmCmpsDataSourceSort, DmTableActionButton, DmTableClasses, DmTableColumn, DmTableColumnHeaderMenuItem, DmTablePaginatorSettings, DmTableRowActionButton, DmTableStyle };