@cocoar/ui-components 0.1.0-beta.120 → 0.1.0-beta.125

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.
@@ -643,7 +643,9 @@ function transformStepperButtons(value) {
643
643
  class CoarNumberInputComponent extends CoarControlValueAccessor {
644
644
  destroyRef = inject(DestroyRef);
645
645
  localizationService = inject(CoarLocalizationService, { optional: true });
646
- currentLanguage = toSignal(this.localizationService?.languageChanged$ ?? of(navigator.language));
646
+ currentLanguage = toSignal(this.localizationService?.languageState.value$ ?? of(navigator.language), {
647
+ initialValue: this.localizationService?.languageState.value ?? navigator.language,
648
+ });
647
649
  maskitoInstance;
648
650
  /** Label text displayed above the input */
649
651
  label = input('', ...(ngDevMode ? [{ debugName: "label" }] : []));
@@ -841,9 +843,7 @@ class CoarNumberInputComponent extends CoarControlValueAccessor {
841
843
  return null;
842
844
  const format = this.resolveNumberFormat();
843
845
  // Remove thousand separators first (before converting decimal)
844
- const withoutThousands = format.thousand
845
- ? str.replace(new RegExp(`\\${format.thousand}`, 'g'), '')
846
- : str;
846
+ const withoutThousands = format.thousand ? str.replace(new RegExp(`\\${format.thousand}`, 'g'), '') : str;
847
847
  // Replace locale-specific decimal separator with period for parseFloat
848
848
  const normalized = withoutThousands.replace(format.decimal, '.');
849
849
  const parsed = parseFloat(normalized);
@@ -4036,7 +4036,9 @@ class CoarDatePickerComponent extends CoarControlValueAccessor {
4036
4036
  localizationDataStore = inject(CoarLocalizationDataStore, { optional: true });
4037
4037
  overlayRef = null;
4038
4038
  /** Current language from localization service (reactive) */
4039
- currentLanguage = toSignal(this.localizationService?.languageChanged$ ?? of(navigator.language));
4039
+ currentLanguage = toSignal(this.localizationService?.languageState.value$ ?? of(''), {
4040
+ initialValue: this.localizationService?.languageState.value ?? '',
4041
+ });
4040
4042
  // ============================================================
4041
4043
  // Inputs
4042
4044
  // ============================================================
@@ -4137,12 +4139,7 @@ class CoarDatePickerComponent extends CoarControlValueAccessor {
4137
4139
  /** Display value for the input field */
4138
4140
  displayValue = signal('', ...(ngDevMode ? [{ debugName: "displayValue" }] : []));
4139
4141
  /** Days of week header (localized based on locale and firstDayOfWeek) */
4140
- daysOfWeek = computed(() => {
4141
- const locale = this.effectiveLocale();
4142
- const firstDay = this.firstDayOfWeek();
4143
- console.log('[CoarDatePicker] daysOfWeek computed - locale:', locale, 'firstDay:', firstDay);
4144
- return getLocalizedWeekdays(locale, firstDay);
4145
- }, ...(ngDevMode ? [{ debugName: "daysOfWeek" }] : []));
4142
+ daysOfWeek = computed(() => getLocalizedWeekdays(this.effectiveLocale(), this.firstDayOfWeek()), ...(ngDevMode ? [{ debugName: "daysOfWeek" }] : []));
4146
4143
  /** Reference to the input element */
4147
4144
  inputRef = viewChild('dateInput', ...(ngDevMode ? [{ debugName: "inputRef" }] : []));
4148
4145
  /** Reference to the trigger element */
@@ -4163,9 +4160,9 @@ class CoarDatePickerComponent extends CoarControlValueAccessor {
4163
4160
  return directConfig;
4164
4161
  }
4165
4162
  // 2. Try to get from localization data store (which uses Intl with proper firstDayOfWeek detection)
4166
- const currentLang = this.localizationService?.getCurrentLanguage();
4167
- const localeData = currentLang
4168
- ? this.localizationDataStore?.getLocaleData(currentLang)
4163
+ const storeLocale = this.locale() ?? this.currentLanguage();
4164
+ const localeData = storeLocale
4165
+ ? this.localizationDataStore?.getLocaleData(storeLocale)
4169
4166
  : undefined;
4170
4167
  if (localeData?.date) {
4171
4168
  return {
@@ -4217,12 +4214,7 @@ class CoarDatePickerComponent extends CoarControlValueAccessor {
4217
4214
  * Priority: input locale > locale service language > browser locale
4218
4215
  */
4219
4216
  effectiveLocale = computed(() => {
4220
- // Always re-evaluate navigator.language to ensure fresh browser locale
4221
- const localeInput = this.locale();
4222
- const currentLang = this.currentLanguage();
4223
- const effective = localeInput ?? currentLang ?? navigator.language;
4224
- console.log('[CoarDatePicker] effectiveLocale computed - input:', localeInput, 'currentLang:', currentLang, 'effective:', effective);
4225
- return effective;
4217
+ return this.locale() ?? this.currentLanguage() ?? navigator.language;
4226
4218
  }, ...(ngDevMode ? [{ debugName: "effectiveLocale" }] : []));
4227
4219
  /** Whether the picker has an error state */
4228
4220
  hasError = computed(() => this.error(), ...(ngDevMode ? [{ debugName: "hasError" }] : []));
@@ -4276,9 +4268,7 @@ class CoarDatePickerComponent extends CoarControlValueAccessor {
4276
4268
  /** Month name for calendar header */
4277
4269
  viewMonth = computed(() => {
4278
4270
  const viewMonth = this.viewDate();
4279
- const locale = this.effectiveLocale();
4280
- console.log('[CoarDatePicker] viewMonth computed - locale:', locale, 'month:', viewMonth.month);
4281
- const formatter = new Intl.DateTimeFormat(locale, {
4271
+ const formatter = new Intl.DateTimeFormat(this.effectiveLocale(), {
4282
4272
  month: 'long',
4283
4273
  });
4284
4274
  const jsDate = new Date(viewMonth.year, viewMonth.month - 1, 1);
@@ -4323,12 +4313,14 @@ class CoarDatePickerComponent extends CoarControlValueAccessor {
4323
4313
  this.displayValue.set('');
4324
4314
  }
4325
4315
  });
4326
- // Initialize Maskito after render
4327
- afterNextRender(() => {
4316
+ // Keep Maskito config in sync with date format + constraints.
4317
+ effect(() => {
4328
4318
  const inputElement = this.inputRef()?.nativeElement;
4329
- if (inputElement) {
4330
- this.initializeMaskito(inputElement);
4319
+ if (!inputElement) {
4320
+ return;
4331
4321
  }
4322
+ this.maskitoInstance?.destroy();
4323
+ this.initializeMaskito(inputElement);
4332
4324
  });
4333
4325
  // Cleanup on destroy
4334
4326
  this.destroyRef.onDestroy(() => {