@acorex/platform 20.0.13 → 20.0.20

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.
@@ -20,7 +20,7 @@ import { AXLabelModule } from '@acorex/components/label';
20
20
  import { AXValidationModule, AXValidationService } from '@acorex/core/validation';
21
21
  import * as i2$3 from '@angular/forms';
22
22
  import { FormsModule } from '@angular/forms';
23
- import { AXPClipBoardService, AXPRegionalService, AXPFilterOperatorMiddlewareService, AXPCleanNestedFilters, AXPFileStorageService, AXPFileTypeProviderService, ALL_DEFAULT_OPERATORS, DATE_OPERATORS, BOOLEAN_OPERATORS, NUMBER_OPERATORS, STRING_OPERATORS } from '@acorex/platform/common';
23
+ import { AXPClipBoardService, AXPSettingService, AXPRegionalService, AXPFilterOperatorMiddlewareService, AXPCleanNestedFilters, AXPFileStorageService, AXPFileTypeProviderService, ALL_DEFAULT_OPERATORS, DATE_OPERATORS, BOOLEAN_OPERATORS, NUMBER_OPERATORS, STRING_OPERATORS } from '@acorex/platform/common';
24
24
  import { AXPopupService } from '@acorex/components/popup';
25
25
  import * as i3 from '@acorex/components/select-box';
26
26
  import { AXSelectBoxModule, AXSelectBoxComponent } from '@acorex/components/select-box';
@@ -31,7 +31,7 @@ import { AXTranslationModule, AXTranslationService } from '@acorex/core/translat
31
31
  import * as i1$1 from '@angular/common';
32
32
  import { CommonModule } from '@angular/common';
33
33
  import { AXBasePageComponent } from '@acorex/components/page';
34
- import { AXDateTimeFormatter, AXTimeDurationFormatter, AXCalendarService } from '@acorex/core/date-time';
34
+ import { AXFormatService } from '@acorex/core/format';
35
35
  import * as i3$1 from '@acorex/components/datetime-box';
36
36
  import { AXDateTimeBoxModule } from '@acorex/components/datetime-box';
37
37
  import * as i5 from '@acorex/components/text-area';
@@ -39,7 +39,6 @@ import { AXTextAreaModule } from '@acorex/components/text-area';
39
39
  import { set, isNumber, castArray, cloneDeep, isEqual, sum, get } from 'lodash-es';
40
40
  import * as i4$1 from '@acorex/components/tabs';
41
41
  import { AXTabsModule } from '@acorex/components/tabs';
42
- import { AXFormatService } from '@acorex/core/format';
43
42
  import * as i1$4 from '@acorex/components/number-box';
44
43
  import { AXNumberBoxModule } from '@acorex/components/number-box';
45
44
  import * as i3$2 from '@acorex/components/password-box';
@@ -90,6 +89,7 @@ import { AXColorUtil } from '@acorex/core/utils';
90
89
  import * as i6$3 from '@acorex/components/dropdown-button';
91
90
  import { AXDropdownButtonModule } from '@acorex/components/dropdown-button';
92
91
  import { AXDataTableModule } from '@acorex/components/data-table';
92
+ import { AXTimeDurationFormatter, AXCalendarService } from '@acorex/core/date-time';
93
93
  import * as i2$a from '@acorex/components/time-duration';
94
94
  import { AXTimeDurationModule } from '@acorex/components/time-duration';
95
95
  import * as i1$c from '@acorex/components/collapse';
@@ -1834,9 +1834,10 @@ const AXPContactWidget = {
1834
1834
  class AXPDateTimeBoxWidgetViewComponent extends AXPValueWidgetComponent {
1835
1835
  constructor() {
1836
1836
  super(...arguments);
1837
- this.formatter = inject(AXDateTimeFormatter);
1838
- this.translationService = inject(AXTranslationService);
1837
+ this.formatter = inject(AXFormatService);
1838
+ this.settingService = inject(AXPSettingService);
1839
1839
  this.multiple = computed(() => this.options()['multiple']);
1840
+ this.convertedValue = signal(null);
1840
1841
  this.format = computed(() => {
1841
1842
  const rawValue = this.options()['format'];
1842
1843
  if (typeof rawValue == 'string')
@@ -1846,28 +1847,47 @@ class AXPDateTimeBoxWidgetViewComponent extends AXPValueWidgetComponent {
1846
1847
  else
1847
1848
  return 'date';
1848
1849
  });
1849
- this.internalValue = computed(() => Array.isArray(this.getValue())
1850
- ? this.getValue().map((v) => this.handleFormat(v))
1851
- : [this.handleFormat(this.getValue())]);
1850
+ this.#effect = effect(() => {
1851
+ this.updateValue();
1852
+ });
1853
+ this.updateValue = async () => {
1854
+ const rawValue = this.getValue();
1855
+ if (rawValue == null) {
1856
+ this.convertedValue.set(null);
1857
+ }
1858
+ if (this.isArray(rawValue)) {
1859
+ this.convertedValue.set(rawValue.map((item) => this.handleFormat(item)).join(', '));
1860
+ }
1861
+ else {
1862
+ this.convertedValue.set(await this.handleFormat(rawValue));
1863
+ }
1864
+ };
1852
1865
  }
1853
- handleFormat(value) {
1866
+ #effect;
1867
+ async handleFormat(value) {
1868
+ let mode = '';
1869
+ if (this.format() == 'date') {
1870
+ mode = await this.settingService.get('regional:short-date');
1871
+ }
1872
+ else if (this.format() == 'time') {
1873
+ mode = await this.settingService.get('regional:short-time');
1874
+ }
1875
+ else if (this.format() == 'datetime') {
1876
+ mode = `${await this.settingService.get('regional:short-date')} ${await this.settingService.get('regional:short-time')}`;
1877
+ }
1854
1878
  return value
1855
- ? this.formatter.format(new Date(value), {
1856
- format: this.format(),
1857
- locale: this.translationService.getActiveLang() === 'fa' ? 'fa' : undefined,
1879
+ ? this.formatter.format(new Date(value), this.format(), {
1880
+ format: mode,
1858
1881
  })
1859
1882
  : '---';
1860
1883
  }
1884
+ isArray(val) {
1885
+ return Array.isArray(val);
1886
+ }
1861
1887
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXPDateTimeBoxWidgetViewComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
1862
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.0.7", type: AXPDateTimeBoxWidgetViewComponent, isStandalone: true, selector: "ng-component", usesInheritance: true, ngImport: i0, template: `
1888
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.0.7", type: AXPDateTimeBoxWidgetViewComponent, isStandalone: true, selector: "ng-component", usesInheritance: true, ngImport: i0, template: `
1863
1889
  <div class="ax-text-muted">
1864
- @if(multiple()){
1865
- @for (item of internalValue(); track $index) {
1866
- <span dir="ltr" >{{ item }}</span>
1867
- }
1868
- } @else {
1869
- <span dir="ltr" >{{ internalValue()[0] }}</span>
1870
- }
1890
+ <span [dir]="'ltr'" [title]="convertedValue()">{{ convertedValue() }}</span>
1871
1891
  </div>
1872
1892
  `, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
1873
1893
  }
@@ -1876,18 +1896,12 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.7", ngImpor
1876
1896
  args: [{
1877
1897
  template: `
1878
1898
  <div class="ax-text-muted">
1879
- @if(multiple()){
1880
- @for (item of internalValue(); track $index) {
1881
- <span dir="ltr" >{{ item }}</span>
1882
- }
1883
- } @else {
1884
- <span dir="ltr" >{{ internalValue()[0] }}</span>
1885
- }
1899
+ <span [dir]="'ltr'" [title]="convertedValue()">{{ convertedValue() }}</span>
1886
1900
  </div>
1887
1901
  `,
1888
1902
  changeDetection: ChangeDetectionStrategy.OnPush,
1889
1903
  imports: [],
1890
- inputs: []
1904
+ inputs: [],
1891
1905
  }]
1892
1906
  }] });
1893
1907
 
@@ -2077,9 +2091,10 @@ var dateTimeBoxWidgetFilter_component = /*#__PURE__*/Object.freeze({
2077
2091
  class AXPDateTimeBoxWidgetColumnComponent extends AXPColumnWidgetComponent {
2078
2092
  constructor() {
2079
2093
  super(...arguments);
2080
- this.formatter = inject(AXDateTimeFormatter);
2081
- this.translationService = inject(AXTranslationService);
2082
- this.multiple = this.options['multiple'];
2094
+ this.formatter = inject(AXFormatService);
2095
+ this.settingService = inject(AXPSettingService);
2096
+ this.convertedValue = signal(this.rawValue);
2097
+ this.multiple = this.options['multiple'] || false;
2083
2098
  this.format = computed(() => {
2084
2099
  const rawValue = this.options['format'];
2085
2100
  if (typeof rawValue == 'string')
@@ -2089,28 +2104,53 @@ class AXPDateTimeBoxWidgetColumnComponent extends AXPColumnWidgetComponent {
2089
2104
  else
2090
2105
  return 'date';
2091
2106
  });
2092
- this.internalValue = () => Array.isArray(this.rawValue)
2093
- ? this.rawValue.map((v) => this.handleFormat(v))
2094
- : [this.handleFormat(this.rawValue)];
2107
+ this.#effect = effect(() => {
2108
+ this.updateValue();
2109
+ });
2110
+ this.updateValue = async () => {
2111
+ const rawValue = this.rawValue;
2112
+ if (rawValue == null) {
2113
+ this.convertedValue.set(null);
2114
+ }
2115
+ if (this.isArray(rawValue)) {
2116
+ this.convertedValue.set(rawValue.map((item) => this.handleFormat(item)).join(', '));
2117
+ }
2118
+ else {
2119
+ this.convertedValue.set(await this.handleFormat(rawValue));
2120
+ }
2121
+ };
2095
2122
  }
2096
- handleFormat(value) {
2123
+ #effect;
2124
+ async handleFormat(value) {
2125
+ let mode = '';
2126
+ if (this.format() == 'date') {
2127
+ mode = await this.settingService.get('regional:short-date');
2128
+ }
2129
+ else if (this.format() == 'time') {
2130
+ mode = await this.settingService.get('regional:short-time');
2131
+ }
2132
+ else if (this.format() == 'datetime') {
2133
+ mode = `${await this.settingService.get('regional:short-date')} ${await this.settingService.get('regional:short-time')}`;
2134
+ }
2097
2135
  return value
2098
- ? this.formatter.format(new Date(value), {
2099
- format: this.format(),
2100
- locale: this.translationService.getActiveLang() === 'fa' ? 'fa' : undefined,
2136
+ ? this.formatter.format(new Date(value), this.format(), {
2137
+ format: mode,
2101
2138
  })
2102
2139
  : '---';
2103
2140
  }
2141
+ isArray(val) {
2142
+ return Array.isArray(val);
2143
+ }
2104
2144
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXPDateTimeBoxWidgetColumnComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
2105
2145
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.0.7", type: AXPDateTimeBoxWidgetColumnComponent, isStandalone: true, selector: "ng-component", inputs: { rawValue: "rawValue", rowData: "rowData" }, usesInheritance: true, ngImport: i0, template: `<div class="ax-flex">
2106
- <span [dir]="'ltr'" [title]="internalValue()">{{ internalValue() }}</span>
2146
+ <span [dir]="'ltr'" [title]="convertedValue()">{{ convertedValue() }}</span>
2107
2147
  </div>`, isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
2108
2148
  }
2109
2149
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: AXPDateTimeBoxWidgetColumnComponent, decorators: [{
2110
2150
  type: Component,
2111
2151
  args: [{
2112
2152
  template: `<div class="ax-flex">
2113
- <span [dir]="'ltr'" [title]="internalValue()">{{ internalValue() }}</span>
2153
+ <span [dir]="'ltr'" [title]="convertedValue()">{{ convertedValue() }}</span>
2114
2154
  </div>`,
2115
2155
  changeDetection: ChangeDetectionStrategy.OnPush,
2116
2156
  imports: [CommonModule],