cerxos-ui 0.0.15 → 0.0.17

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.
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Component, EventEmitter, ElementRef, HostListener, ViewChildren, ViewChild, Output, Input, ChangeDetectionStrategy, Attribute, forwardRef, Directive, ContentChildren, ContentChild, HostBinding } from '@angular/core';
2
+ import { Component, EventEmitter, ElementRef, HostListener, ViewChildren, ViewChild, Output, Input, ChangeDetectionStrategy, Attribute, forwardRef, Directive, ContentChildren, ContentChild, HostBinding, signal, Injectable, inject, Pipe } from '@angular/core';
3
3
  import { NG_VALUE_ACCESSOR } from '@angular/forms';
4
4
  import * as i1 from '@angular/common';
5
5
  import { NgTemplateOutlet, CommonModule } from '@angular/common';
@@ -655,6 +655,12 @@ const SIZE_CLASSES$5 = {
655
655
  lg: 'h-6 w-6'
656
656
  };
657
657
  const ICONS = {
658
+ banknotes: {
659
+ viewBox: '0 0 24 24',
660
+ paths: [
661
+ 'M12 6v12m-3-2.818.879.659c1.171.879 3.07.879 4.242 0 1.172-.879 1.172-2.303 0-3.182C13.536 12.219 12.768 12 12 12c-.725 0-1.45-.22-2.003-.659-1.106-.879-1.106-2.303 0-3.182s2.9-.879 4.006 0l.415.33M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z'
662
+ ]
663
+ },
658
664
  bell: {
659
665
  viewBox: '0 0 24 24',
660
666
  paths: [
@@ -662,6 +668,12 @@ const ICONS = {
662
668
  'M10.3 20a2 2 0 0 0 3.4 0'
663
669
  ]
664
670
  },
671
+ calendar: {
672
+ viewBox: '0 0 24 24',
673
+ paths: [
674
+ 'M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2Z'
675
+ ]
676
+ },
665
677
  'chevron-down': {
666
678
  viewBox: '0 0 24 24',
667
679
  paths: ['m6 9 6 6 6-6']
@@ -678,6 +690,38 @@ const ICONS = {
678
690
  viewBox: '0 0 24 24',
679
691
  paths: ['m18 15-6-6-6 6']
680
692
  },
693
+ eye: {
694
+ viewBox: '0 0 24 24',
695
+ paths: [
696
+ 'M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z',
697
+ 'M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7Z'
698
+ ]
699
+ },
700
+ 'eye-off': {
701
+ viewBox: '0 0 24 24',
702
+ paths: [
703
+ 'M13.875 18.825A10.05 10.05 0 0 1 12 19c-4.478 0-8.268-2.943-9.542-7a10.05 10.05 0 0 1 4.167-4.827M6.633 6.633A10.081 10.081 0 0 1 12 5c4.478 0 8.268 2.943 9.542 7a10.081 10.081 0 0 1-4.167 4.827M6.633 6.633L3 3m3.633 3L9.75 9m3.617-3L21 3m-33L17.25 9M3 3l18 18'
704
+ ]
705
+ },
706
+ filter: {
707
+ viewBox: '0 0 24 24',
708
+ paths: ['M3 4a1 1 0 0 1 1-1h16a1 1 0 0 1 1 1v2a1 1 0 0 1-.293.707L14.414 12l6.293 6.293A1 1 0 0 1 21 19V21a1 1 0 0 1-1-1H4a1 1 0 0 1-1-1V4Z']
709
+ },
710
+ folder: {
711
+ viewBox: '0 0 24 24',
712
+ paths: [
713
+ 'M3 6h5l2 2h11a2 2 0 0 1 2 2v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2Z',
714
+ 'M10 6V4a2 2 0 0 1 2-2h4'
715
+ ]
716
+ },
717
+ home: {
718
+ viewBox: '0 0 24 24',
719
+ paths: ['M3 12l9-9 9 9M4 10v10a1 1 0 001 1h3m10-11v10a1 1 0 001 1h3m-13 0h8']
720
+ },
721
+ pencil: {
722
+ viewBox: '0 0 24 24',
723
+ paths: ['M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z', 'm15 5 4 4']
724
+ },
681
725
  plus: {
682
726
  viewBox: '0 0 24 24',
683
727
  paths: ['M12 5v14', 'M5 12h14']
@@ -693,6 +737,16 @@ const ICONS = {
693
737
  'M10 11a4 4 0 1 0 0-8 4 4 0 0 0 0 8'
694
738
  ]
695
739
  },
740
+ trash: {
741
+ viewBox: '0 0 24 24',
742
+ paths: [
743
+ 'M3 6h18',
744
+ 'M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6',
745
+ 'M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2',
746
+ 'M10 11v6',
747
+ 'M14 11v6'
748
+ ]
749
+ },
696
750
  x: {
697
751
  viewBox: '0 0 24 24',
698
752
  paths: ['M18 6 6 18', 'M6 6l12 12']
@@ -4384,6 +4438,180 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.10", ngImpo
4384
4438
  type: Input
4385
4439
  }] } });
4386
4440
 
4441
+ const CXS_USER_SESSION_STORAGE_KEY = 'user_session';
4442
+ const CXS_USER_PREFERENCE_CHANGED_EVENT = 'cxs:user-preference-changed';
4443
+ const DATE_FORMAT_PREFERENCE_KEY = 'ui.dateFormat';
4444
+ const CURRENCY_FORMAT_PREFERENCE_KEY = 'ui.currencyFormat';
4445
+ const DATE_FORMAT_ALIASES = ['dateFormat', 'date_format'];
4446
+ const CURRENCY_FORMAT_ALIASES = ['currencyFormat', 'currency_format', 'currency'];
4447
+ const DEFAULT_DATE_FORMAT = 'mdy';
4448
+ const DEFAULT_CURRENCY_FORMAT = 'usd';
4449
+ const CURRENCY_FORMATS = {
4450
+ usd: { currency: 'USD', locale: 'en-US' },
4451
+ myr: { currency: 'MYR', locale: 'en-MY' },
4452
+ eur: { currency: 'EUR', locale: 'en-IE' },
4453
+ gbp: { currency: 'GBP', locale: 'en-GB' },
4454
+ jpy: { currency: 'JPY', locale: 'ja-JP' }
4455
+ };
4456
+ class CxsPreferenceFormattingService {
4457
+ preferenceVersionSignal = signal(0, ...(ngDevMode ? [{ debugName: "preferenceVersionSignal" }] : /* istanbul ignore next */ []));
4458
+ preferenceVersion = this.preferenceVersionSignal.asReadonly();
4459
+ constructor() {
4460
+ this.addPreferenceListeners();
4461
+ }
4462
+ formatDate(value) {
4463
+ if (value === null || value === undefined || value === '') {
4464
+ return '';
4465
+ }
4466
+ const date = value instanceof Date ? value : this.parseDateString(value);
4467
+ if (!date) {
4468
+ return String(value);
4469
+ }
4470
+ const format = this.dateFormatPreference();
4471
+ const year = date.getFullYear();
4472
+ const month = this.padDatePart(date.getMonth() + 1);
4473
+ const day = this.padDatePart(date.getDate());
4474
+ if (format === 'dmy') {
4475
+ return `${day}/${month}/${year}`;
4476
+ }
4477
+ if (format === 'ymd') {
4478
+ return `${year}-${month}-${day}`;
4479
+ }
4480
+ return `${month}/${day}/${year}`;
4481
+ }
4482
+ formatCurrency(value) {
4483
+ if (value === null || value === undefined || value === '') {
4484
+ return '';
4485
+ }
4486
+ const amount = typeof value === 'number' ? value : Number(value);
4487
+ if (!Number.isFinite(amount)) {
4488
+ return String(value);
4489
+ }
4490
+ const config = CURRENCY_FORMATS[this.currencyFormatPreference()];
4491
+ return new Intl.NumberFormat(config.locale, {
4492
+ currency: config.currency,
4493
+ style: 'currency'
4494
+ }).format(amount);
4495
+ }
4496
+ dateFormatPreference() {
4497
+ const value = this.getPreference(DATE_FORMAT_PREFERENCE_KEY, DATE_FORMAT_ALIASES);
4498
+ return this.isDateFormatPreference(value) ? value : DEFAULT_DATE_FORMAT;
4499
+ }
4500
+ currencyFormatPreference() {
4501
+ const value = this.getPreference(CURRENCY_FORMAT_PREFERENCE_KEY, CURRENCY_FORMAT_ALIASES);
4502
+ return this.isCurrencyFormatPreference(value) ? value : DEFAULT_CURRENCY_FORMAT;
4503
+ }
4504
+ getPreference(key, aliases) {
4505
+ const preferences = this.readSession()?.preferences ?? [];
4506
+ const keys = [key, ...aliases];
4507
+ const preference = keys
4508
+ .map((preferenceKey) => preferences.find((item) => item.key === preferenceKey))
4509
+ .find(Boolean);
4510
+ return preference?.value?.trim().toLowerCase();
4511
+ }
4512
+ readSession() {
4513
+ const storage = this.getLocalStorage();
4514
+ if (!storage) {
4515
+ return null;
4516
+ }
4517
+ const raw = storage.getItem(CXS_USER_SESSION_STORAGE_KEY);
4518
+ if (!raw) {
4519
+ return null;
4520
+ }
4521
+ try {
4522
+ return JSON.parse(raw);
4523
+ }
4524
+ catch {
4525
+ return null;
4526
+ }
4527
+ }
4528
+ parseDateString(value) {
4529
+ const apiDateMatch = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value);
4530
+ if (apiDateMatch) {
4531
+ const [, year, month, day] = apiDateMatch;
4532
+ return new Date(Number(year), Number(month) - 1, Number(day));
4533
+ }
4534
+ const parsed = new Date(value);
4535
+ return Number.isNaN(parsed.getTime()) ? null : parsed;
4536
+ }
4537
+ padDatePart(value) {
4538
+ return String(value).padStart(2, '0');
4539
+ }
4540
+ isDateFormatPreference(value) {
4541
+ return value === 'mdy' || value === 'dmy' || value === 'ymd';
4542
+ }
4543
+ isCurrencyFormatPreference(value) {
4544
+ return (value === 'usd' ||
4545
+ value === 'myr' ||
4546
+ value === 'eur' ||
4547
+ value === 'gbp' ||
4548
+ value === 'jpy');
4549
+ }
4550
+ addPreferenceListeners() {
4551
+ if (typeof window === 'undefined') {
4552
+ return;
4553
+ }
4554
+ window.addEventListener('storage', (event) => {
4555
+ if (event.key === CXS_USER_SESSION_STORAGE_KEY) {
4556
+ this.bumpPreferenceVersion();
4557
+ }
4558
+ });
4559
+ window.addEventListener(CXS_USER_PREFERENCE_CHANGED_EVENT, () => {
4560
+ this.bumpPreferenceVersion();
4561
+ });
4562
+ }
4563
+ bumpPreferenceVersion() {
4564
+ this.preferenceVersionSignal.update((version) => version + 1);
4565
+ }
4566
+ getLocalStorage() {
4567
+ return typeof localStorage === 'undefined' ? null : localStorage;
4568
+ }
4569
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.10", ngImport: i0, type: CxsPreferenceFormattingService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
4570
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.10", ngImport: i0, type: CxsPreferenceFormattingService, providedIn: 'root' });
4571
+ }
4572
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.10", ngImport: i0, type: CxsPreferenceFormattingService, decorators: [{
4573
+ type: Injectable,
4574
+ args: [{
4575
+ providedIn: 'root'
4576
+ }]
4577
+ }], ctorParameters: () => [] });
4578
+
4579
+ class CxsCurrencyPipe {
4580
+ formatter = inject(CxsPreferenceFormattingService);
4581
+ transform(value) {
4582
+ this.formatter.preferenceVersion();
4583
+ return this.formatter.formatCurrency(value);
4584
+ }
4585
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.10", ngImport: i0, type: CxsCurrencyPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
4586
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.2.10", ngImport: i0, type: CxsCurrencyPipe, isStandalone: true, name: "cxsCurrency", pure: false });
4587
+ }
4588
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.10", ngImport: i0, type: CxsCurrencyPipe, decorators: [{
4589
+ type: Pipe,
4590
+ args: [{
4591
+ name: 'cxsCurrency',
4592
+ standalone: true,
4593
+ pure: false
4594
+ }]
4595
+ }] });
4596
+
4597
+ class CxsDatePipe {
4598
+ formatter = inject(CxsPreferenceFormattingService);
4599
+ transform(value) {
4600
+ this.formatter.preferenceVersion();
4601
+ return this.formatter.formatDate(value);
4602
+ }
4603
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.10", ngImport: i0, type: CxsDatePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
4604
+ static ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "21.2.10", ngImport: i0, type: CxsDatePipe, isStandalone: true, name: "cxsDate", pure: false });
4605
+ }
4606
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.10", ngImport: i0, type: CxsDatePipe, decorators: [{
4607
+ type: Pipe,
4608
+ args: [{
4609
+ name: 'cxsDate',
4610
+ standalone: true,
4611
+ pure: false
4612
+ }]
4613
+ }] });
4614
+
4387
4615
  /*
4388
4616
  * Public API Surface of cerxos-ui
4389
4617
  */
@@ -4392,5 +4620,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.10", ngImpo
4392
4620
  * Generated bundle index. Do not edit.
4393
4621
  */
4394
4622
 
4395
- export { CerxosUi, CxsAccordionComponent, CxsAccordionItemComponent, CxsActionMenuComponent, CxsAlertComponent, CxsAvatarComponent, CxsBadgeComponent, CxsBreadcrumbComponent, CxsButtonComponent, CxsCardComponent, CxsCarouselComponent, CxsCheckboxComponent, CxsDataTableCellDirective, CxsDataTableComponent, CxsDatepickerComponent, CxsDialogComponent, CxsIconComponent, CxsInputComponent, CxsMenubarComponent, CxsMultiSelectComponent, CxsProgressBarComponent, CxsRadioComponent, CxsSelectComponent, CxsSkeletonComponent, CxsSliderComponent, CxsTabLabelDirective, CxsTabPanelComponent, CxsTableComponent, CxsTabsComponent, CxsThemeDirective, CxsToastComponent, CxsToggleComponent, CxsTooltipComponent };
4623
+ export { CXS_USER_PREFERENCE_CHANGED_EVENT, CXS_USER_SESSION_STORAGE_KEY, CerxosUi, CxsAccordionComponent, CxsAccordionItemComponent, CxsActionMenuComponent, CxsAlertComponent, CxsAvatarComponent, CxsBadgeComponent, CxsBreadcrumbComponent, CxsButtonComponent, CxsCardComponent, CxsCarouselComponent, CxsCheckboxComponent, CxsCurrencyPipe, CxsDataTableCellDirective, CxsDataTableComponent, CxsDatePipe, CxsDatepickerComponent, CxsDialogComponent, CxsIconComponent, CxsInputComponent, CxsMenubarComponent, CxsMultiSelectComponent, CxsPreferenceFormattingService, CxsProgressBarComponent, CxsRadioComponent, CxsSelectComponent, CxsSkeletonComponent, CxsSliderComponent, CxsTabLabelDirective, CxsTabPanelComponent, CxsTableComponent, CxsTabsComponent, CxsThemeDirective, CxsToastComponent, CxsToggleComponent, CxsTooltipComponent };
4396
4624
  //# sourceMappingURL=cerxos-ui.mjs.map