ng-matero / extensions

Angular Material Extensions Library.
https://ng-matero.github.io/extensions/
MIT License
393 stars 48 forks source link

Missing MtxDatetimepickerIntl in public-api #215

Closed hijamoya closed 1 year ago

hijamoya commented 1 year ago

MtxDatetimepickerIntl does not be lncluded in projects/extensions/datetimepicker/public-api.ts, which results we can not override the display label of the picker UI.

Module not found: Error: Package path ./datetimepicker/datetimepicker-intl is not exported from package

Please help to resolve this.

damingerdai commented 1 year ago

show your code

hijamoya commented 1 year ago

I just override the provide:

{ provide: MtxDatetimepickerIntl, useClass: MtxDatetimepickerIntlEx, deps: [TranslateService] },

With the class:

import { TranslateService } from '@ngx-translate/core';
import { MtxDatetimepickerIntl } from '@ng-matero/extensions/datetimepicker/datetimepicker-intl';

export class MtxDatetimepickerIntlEx extends MtxDatetimepickerIntl {
  constructor(private translate: TranslateService) {
    super();
  }

  /** A label for the calendar popup (used by screen readers). */
  calendarLabel = this.translate.instant('field.CALENDAR');

  /** A label for the button used to open the calendar popup (used by screen readers). */
  openCalendarLabel = `${this.translate.instant('field.OPEN')}${this.translate.instant('field.CALENDAR')}`;

  /** Label for the button used to close the calendar popup. */
  closeCalendarLabel = `${this.translate.instant('field.CLOSE')}${this.translate.instant('field.CALENDAR')}`;

  /** A label for the previous month button (used by screen readers). */
  prevMonthLabel = this.translate.instant('field.LAST_MONTH');

  /** A label for the next month button (used by screen readers). */
  nextMonthLabel = this.translate.instant('field.NEXT_MONTH');

  /** A label for the previous year button (used by screen readers). */
  prevYearLabel = this.translate.instant('field.LAST_YEAR');

  /** A label for the next year button (used by screen readers). */
  nextYearLabel = this.translate.instant('field.NEXT_YEAR');

  /** A label for the 'switch to month view' button (used by screen readers). */
  switchToMonthViewLabel = `${this.translate.instant('field.SELECT')}${this.translate.instant('field.DATE')}`;

  /** A label for the 'switch to year view' button (used by screen readers). */
  switchToYearViewLabel = `${this.translate.instant('field.SELECT')}${this.translate.instant('field.MONTH')}`;

  /** A label for the 'switch to multi-year view' button (used by screen readers). */
  switchToMultiYearViewLabel = `${this.translate.instant('field.SELECT')}${this.translate.instant(
    'field.YEAR'
  )}/${this.translate.instant('field.MONTH')}`;

  /** A label for the first date of a range of dates (used by screen readers). */
  startDateLabel = this.translate.instant('field.START_TIME');

  /** A label for the last date of a range of dates (used by screen readers). */
  endDateLabel = this.translate.instant('field.END_TIME');

  /** Formats a label for a range of years (used by screen readers). */
  formatYearRangeLabel(start: string, end: string): string {
    return `${start} to ${end}`;
  }

  /** A label for the 'switch to clock hour view' button (used by screen readers). */
  switchToClockHourViewLabel = `${this.translate.instant('field.SELECT')}${this.translate.instant('field.HOUR')}`;

  /** A label for the 'switch to clock minute view' button (used by screen readers). */
  switchToClockMinuteViewLabel = `${this.translate.instant('field.SELECT')}${this.translate.instant('field.TIME')}`;

  /** Label used for ok button within the manual time input. */
  okLabel = this.translate.instant('field.OK');

  /** Label used for cancel button within the manual time input. */
  cancelLabel = this.translate.instant('field.CANCEL');
}

The error message is:

Module not found: Error: Package path ./datetimepicker/datetimepicker-intl is not exported from package project/node_modules/@ng-matero/extensions (see exports field in project/node_modules/@ng-matero/extensions/package.json)
nzbin commented 1 year ago

Only >=14.6.0 support MtxDatetimepickerIntl

hijamoya commented 1 year ago

but my version is:

"@ng-matero/extensions": "^15.4.0",

I think the problem is missing:

export * from './datetimepicker-intl;

in the file https://github.com/ng-matero/extensions/blob/master/projects/extensions/datetimepicker/public-api.ts

nzbin commented 1 year ago

15.4.2 has fixed, please have a try.

hijamoya commented 1 year ago

@nzbin works now, thanks!