@acorex/components 21.0.2-next.35 → 21.0.2-next.36

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.
@@ -8,7 +8,7 @@ import { AXFormatService, AXFormatPipe } from '@acorex/core/format';
8
8
  import { AXTranslatorPipe } from '@acorex/core/translation';
9
9
  import { NgTemplateOutlet, AsyncPipe } from '@angular/common';
10
10
  import * as i0 from '@angular/core';
11
- import { InjectionToken, inject, input, computed, signal, linkedSignal, effect, forwardRef, ViewChild, Input, ViewEncapsulation, ChangeDetectionStrategy, Component, NgModule } from '@angular/core';
11
+ import { InjectionToken, inject, input, computed, signal, linkedSignal, effect, untracked, forwardRef, ViewChild, Input, ViewEncapsulation, ChangeDetectionStrategy, Component, NgModule } from '@angular/core';
12
12
  import * as i1 from '@angular/forms';
13
13
  import { FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
14
14
  import { classes } from 'polytype';
@@ -93,7 +93,7 @@ class AXDateTimePickerComponent extends classes(MXCalendarBaseComponent, (MXValu
93
93
  day: {
94
94
  key: 'day',
95
95
  placeholder: 'dd',
96
- placeholders: ['dd', 'd', 'E', 'dddd'],
96
+ placeholders: ['dd', 'DD', 'd', 'E', 'dddd'],
97
97
  enabled: false,
98
98
  default: 1,
99
99
  realValue: () => this.formatService.format(this.editingDateObj(), 'datetime', this._parts.day.placeholder),
@@ -139,12 +139,12 @@ class AXDateTimePickerComponent extends classes(MXCalendarBaseComponent, (MXValu
139
139
  // /**
140
140
  // * @ignore
141
141
  // */
142
- this.editingDateObj = linkedSignal(() => this.calendarService.now(this.calendar()), ...(ngDevMode ? [{ debugName: "editingDateObj" }] : []));
143
142
  /**
144
143
  * @description The calendar type to use for the datetime input.
145
144
  */
146
145
  this.calendar = input(null, ...(ngDevMode ? [{ debugName: "calendar" }] : []));
147
- this._calendarSystem = linkedSignal(() => this.calendar() ?? this.type, ...(ngDevMode ? [{ debugName: "_calendarSystem" }] : []));
146
+ this._calendarSystem = computed(() => this.calendar() ?? this.localeService.activeProfile().calendar.system, ...(ngDevMode ? [{ debugName: "_calendarSystem" }] : []));
147
+ this.editingDateObj = linkedSignal(() => this.calendarService.now(this._calendarSystem()), ...(ngDevMode ? [{ debugName: "editingDateObj" }] : []));
148
148
  this.picker = input('datetime', ...(ngDevMode ? [{ debugName: "picker" }] : []));
149
149
  this.#effectPicker = effect(() => {
150
150
  if (this.picker() === 'time') {
@@ -156,25 +156,22 @@ class AXDateTimePickerComponent extends classes(MXCalendarBaseComponent, (MXValu
156
156
  this._activePart.set('date');
157
157
  }
158
158
  }, ...(ngDevMode ? [{ debugName: "#effectPicker" }] : []));
159
- this._format = linkedSignal(() => this.format() ?? this.localeService.activeProfile().formats[this.picker()]?.short ?? '', ...(ngDevMode ? [{ debugName: "_format" }] : []));
159
+ this._resolvedFormat = computed(() => this.format() ?? this.localeService.activeProfile().formats[this.picker()]?.short ?? '', ...(ngDevMode ? [{ debugName: "_resolvedFormat" }] : []));
160
160
  /**
161
161
  * @deprecated use locale & mode instead
162
162
  */
163
163
  this.format = input(...(ngDevMode ? [undefined, { debugName: "format" }] : []));
164
164
  this.#effect = effect(() => {
165
- const profile = this.localeService.activeProfile();
166
- //
167
- if (!this.format()) {
168
- this._format.set(this.format() ?? profile.formats[this.picker()]?.short ?? '');
169
- }
170
- //
171
- if (!this.calendar()) {
172
- this._calendarSystem.set(profile.calendar.system);
173
- }
174
- //
175
- this.type = this._calendarSystem();
176
- //
165
+ const system = this._calendarSystem();
166
+ this._resolvedFormat();
167
+ this.type = system;
177
168
  this._detectParts();
169
+ untracked(() => {
170
+ const current = this.editingDateObj();
171
+ if (current) {
172
+ this.editingDateObj.set(this.calendarService.create(current.date, system));
173
+ }
174
+ });
178
175
  }, ...(ngDevMode ? [{ debugName: "#effect" }] : []));
179
176
  }
180
177
  /**
@@ -226,14 +223,14 @@ class AXDateTimePickerComponent extends classes(MXCalendarBaseComponent, (MXValu
226
223
  internalValueChanged(value) {
227
224
  try {
228
225
  if (this.calendarService.isValidDate(value)) {
229
- this.editingDateObj.set(this.calendarService.create(value, this.calendar()));
226
+ this.editingDateObj.set(this.calendarService.create(value, this._calendarSystem()));
230
227
  }
231
228
  else {
232
229
  throw new Error();
233
230
  }
234
231
  }
235
232
  catch {
236
- this.editingDateObj.set(this.calendarService.now(this.calendar()));
233
+ this.editingDateObj.set(this.calendarService.now(this._calendarSystem()));
237
234
  }
238
235
  }
239
236
  /**
@@ -249,7 +246,7 @@ class AXDateTimePickerComponent extends classes(MXCalendarBaseComponent, (MXValu
249
246
  if (e.isUserInteraction) {
250
247
  this.editingDateObj.set(this.editingDateObj().set(part, Number(e.value['id'])));
251
248
  if (this.minValue) {
252
- const minv = this.calendarService.convert(this.minValue, this.calendar());
249
+ const minv = this.calendarService.convert(this.minValue, this._calendarSystem());
253
250
  // Only apply minute restrictions if we're on the same day and same hour
254
251
  if (this.editingDateObj().isAfter(this.minValue, 'day') || this.editingDateObj().hour > minv.hour) {
255
252
  this.pickerMinuteMinValue.set(null);
@@ -259,7 +256,7 @@ class AXDateTimePickerComponent extends classes(MXCalendarBaseComponent, (MXValu
259
256
  }
260
257
  }
261
258
  if (this.maxValue) {
262
- const maxv = this.calendarService.convert(this.maxValue, this.calendar());
259
+ const maxv = this.calendarService.convert(this.maxValue, this._calendarSystem());
263
260
  // Only apply minute restrictions if we're on the same day and same hour
264
261
  if (this.editingDateObj().isBefore(this.maxValue, 'day') || this.editingDateObj().hour < maxv.hour) {
265
262
  this.pickerMinuteMaxValue.set(null);
@@ -281,9 +278,9 @@ class AXDateTimePickerComponent extends classes(MXCalendarBaseComponent, (MXValu
281
278
  */
282
279
  _handleCalendarOnValueChanged(e) {
283
280
  if (e.isUserInteraction) {
284
- const selectedValue = this.calendarService.create(e.value, this.calendar());
281
+ const selectedValue = this.calendarService.create(e.value, this._calendarSystem());
285
282
  const currentValue = this.calendarService
286
- .create(e.value, this.calendar())
283
+ .create(e.value, this._calendarSystem())
287
284
  .set('day', selectedValue.dayOfMonth)
288
285
  .set('month', selectedValue.monthOfYear)
289
286
  .set('year', selectedValue.year);
@@ -315,7 +312,7 @@ class AXDateTimePickerComponent extends classes(MXCalendarBaseComponent, (MXValu
315
312
  this.pickerSecondMinValue.set(null);
316
313
  }
317
314
  else {
318
- const minv = this.calendarService.convert(this.minValue, this.calendar());
315
+ const minv = this.calendarService.convert(this.minValue, this._calendarSystem());
319
316
  this.pickerHoursMinValue.set(minv.hour);
320
317
  this.pickerMinuteMinValue.set(minv.minute);
321
318
  this.pickerSecondMinValue.set(minv.second);
@@ -332,7 +329,7 @@ class AXDateTimePickerComponent extends classes(MXCalendarBaseComponent, (MXValu
332
329
  this.pickerSecondMaxValue.set(null);
333
330
  }
334
331
  else {
335
- const maxv = this.calendarService.convert(this.maxValue, this.calendar());
332
+ const maxv = this.calendarService.convert(this.maxValue, this._calendarSystem());
336
333
  this.pickerHoursMaxValue.set(maxv.hour);
337
334
  this.pickerMinuteMaxValue.set(maxv.minute);
338
335
  this.pickerSecondMaxValue.set(maxv.second);
@@ -345,7 +342,7 @@ class AXDateTimePickerComponent extends classes(MXCalendarBaseComponent, (MXValu
345
342
  Object.values(this._parts).forEach((e) => {
346
343
  e.enabled = false;
347
344
  });
348
- const formatParts = this._format().split(/[^a-zA-Z]+/);
345
+ const formatParts = this._resolvedFormat().split(/[^a-zA-Z]+/);
349
346
  formatParts.forEach((f) => {
350
347
  const found = Object.values(this._parts).find((c) => c.placeholders.some((d) => d == f));
351
348
  if (found) {
@@ -367,7 +364,7 @@ class AXDateTimePickerComponent extends classes(MXCalendarBaseComponent, (MXValu
367
364
  * @ignore
368
365
  */
369
366
  _handleNowClick() {
370
- this.editingDateObj.set(this.calendarService.now(this.calendar()));
367
+ this.editingDateObj.set(this.calendarService.now(this._calendarSystem()));
371
368
  this.commitValue(this.editingDateObj().date, true);
372
369
  this.checkSelectedMinValue(this.editingDateObj());
373
370
  this.checkSelectedMaxValue(this.editingDateObj());
@@ -391,9 +388,9 @@ class AXDateTimePickerComponent extends classes(MXCalendarBaseComponent, (MXValu
391
388
  if (!value || !this.calendarService.isValidDate(value)) {
392
389
  return null;
393
390
  }
394
- const v = this.calendarService.convert(value, this.calendar());
395
- this.checkSelectedMinValue(this.calendarService.convert(v, this.calendar()));
396
- this.checkSelectedMaxValue(this.calendarService.convert(v, this.calendar()));
391
+ const v = this.calendarService.convert(value, this._calendarSystem());
392
+ this.checkSelectedMinValue(this.calendarService.convert(v, this._calendarSystem()));
393
+ this.checkSelectedMaxValue(this.calendarService.convert(v, this._calendarSystem()));
397
394
  if (this.isDisabled(v)) {
398
395
  return null;
399
396
  }