@acorex/components 20.7.37 → 20.7.39

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.
@@ -5,7 +5,7 @@ import { AXLocaleService } from '@acorex/core/locale';
5
5
  import { AXPlatform } from '@acorex/core/platform';
6
6
  import { getWordBoundsAtPosition } from '@acorex/core/utils';
7
7
  import * as i0 from '@angular/core';
8
- import { inject, signal, input, linkedSignal, viewChild, output, effect, untracked, forwardRef, HostBinding, HostListener, ViewEncapsulation, ChangeDetectionStrategy, Component, NgModule } from '@angular/core';
8
+ import { inject, signal, input, computed, linkedSignal, viewChild, output, effect, untracked, forwardRef, HostBinding, HostListener, ViewEncapsulation, ChangeDetectionStrategy, Component, NgModule } from '@angular/core';
9
9
  import * as i1 from '@angular/forms';
10
10
  import { FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
11
11
  import { map } from 'rxjs';
@@ -107,7 +107,7 @@ class AXDateTimeInputComponent extends MXInputBaseValueComponent {
107
107
  * @description The calendar type to use for the datetime input.
108
108
  */
109
109
  this.calendar = input(null, ...(ngDevMode ? [{ debugName: "calendar" }] : []));
110
- this._calendarSystem = linkedSignal(() => this.calendar(), ...(ngDevMode ? [{ debugName: "_calendarSystem" }] : []));
110
+ this._calendarSystem = computed(() => this.calendar() ?? this.localeService.activeProfile().calendar.system, ...(ngDevMode ? [{ debugName: "_calendarSystem" }] : []));
111
111
  this._activePart = signal(null, ...(ngDevMode ? [{ debugName: "_activePart" }] : []));
112
112
  // TODO: fix this
113
113
  // #effect = effect(() => {
@@ -127,22 +127,14 @@ class AXDateTimeInputComponent extends MXInputBaseValueComponent {
127
127
  */
128
128
  this.onClick = output();
129
129
  this.picker = input('datetime', ...(ngDevMode ? [{ debugName: "picker" }] : []));
130
- this._format = linkedSignal(() => this.format(), ...(ngDevMode ? [{ debugName: "_format" }] : []));
130
+ this._resolvedFormat = computed(() => this.format() ?? this.localeService.activeProfile().formats[this.picker()]?.short ?? '', ...(ngDevMode ? [{ debugName: "_resolvedFormat" }] : []));
131
131
  /**
132
132
  * @deprecated use locale & mode instead
133
133
  */
134
134
  this.format = input(...(ngDevMode ? [undefined, { debugName: "format" }] : []));
135
135
  this.#effect = effect(() => {
136
- const profile = this.localeService.activeProfile();
137
- //
138
- if (!this.format()) {
139
- this._format.set(this.format() ?? profile.formats[this.picker()]?.short ?? '');
140
- }
141
- //
142
- if (!this.calendar()) {
143
- this._calendarSystem.set(profile.calendar.system);
144
- }
145
- //
136
+ this._resolvedFormat();
137
+ this._calendarSystem();
146
138
  this._detectParts();
147
139
  untracked(() => {
148
140
  this._updateText();
@@ -158,7 +150,7 @@ class AXDateTimeInputComponent extends MXInputBaseValueComponent {
158
150
  Object.values(this._editingParts).forEach((e) => {
159
151
  e.enabled = false;
160
152
  });
161
- const formatParts = this._format().split(/[^a-zA-Z]+/);
153
+ const formatParts = this._resolvedFormat().split(/[^a-zA-Z]+/);
162
154
  formatParts.forEach((f) => {
163
155
  const found = Object.values(this._editingParts).find((c) => c.placeholders.some((d) => d == f));
164
156
  if (found) {
@@ -178,7 +170,7 @@ class AXDateTimeInputComponent extends MXInputBaseValueComponent {
178
170
  */
179
171
  _getOrderedParts() {
180
172
  // TODO: better spliter format
181
- const formatParts = this._format().split(/[^a-zA-Z]+/);
173
+ const formatParts = this._resolvedFormat().split(/[^a-zA-Z]+/);
182
174
  const result = [];
183
175
  formatParts.forEach((f) => {
184
176
  const found = Object.values(this._editingParts).find((c) => c.placeholders.some((d) => d == f));
@@ -197,7 +189,7 @@ class AXDateTimeInputComponent extends MXInputBaseValueComponent {
197
189
  * @ignore
198
190
  */
199
191
  _updateText() {
200
- let text = this._format();
192
+ let text = this._resolvedFormat();
201
193
  //
202
194
  Object.values(this._editingParts).forEach((part) => {
203
195
  if (this._activePart() == part.key) {
@@ -210,7 +202,7 @@ class AXDateTimeInputComponent extends MXInputBaseValueComponent {
210
202
  }
211
203
  }
212
204
  });
213
- this._editingText.set(text == this._format() ? '' : text);
205
+ this._editingText.set(text == this._resolvedFormat() ? '' : text);
214
206
  if (this._activePart()) {
215
207
  this._highlightActivePart();
216
208
  }