@vendure/admin-ui 1.4.2 → 1.4.6

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.
Files changed (44) hide show
  1. package/bundles/vendure-admin-ui-catalog.umd.js +1 -1
  2. package/bundles/vendure-admin-ui-catalog.umd.js.map +1 -1
  3. package/bundles/vendure-admin-ui-core.umd.js +56 -29
  4. package/bundles/vendure-admin-ui-core.umd.js.map +1 -1
  5. package/bundles/vendure-admin-ui-dashboard.umd.js +1 -0
  6. package/bundles/vendure-admin-ui-dashboard.umd.js.map +1 -1
  7. package/bundles/vendure-admin-ui-settings.umd.js +1 -1
  8. package/bundles/vendure-admin-ui-settings.umd.js.map +1 -1
  9. package/catalog/vendure-admin-ui-catalog.metadata.json +1 -1
  10. package/core/common/generated-types.d.ts +1 -1
  11. package/core/common/version.d.ts +1 -1
  12. package/core/providers/i18n/i18n.service.d.ts +3 -1
  13. package/core/shared/pipes/locale-base.pipe.d.ts +5 -0
  14. package/core/vendure-admin-ui-core.metadata.json +1 -1
  15. package/dashboard/vendure-admin-ui-dashboard.metadata.json +1 -1
  16. package/esm2015/catalog/components/product-list/product-list.component.js +2 -2
  17. package/esm2015/core/common/base-detail.component.js +4 -4
  18. package/esm2015/core/common/generated-types.js +1 -1
  19. package/esm2015/core/common/introspection-result.js +1 -1
  20. package/esm2015/core/common/version.js +2 -2
  21. package/esm2015/core/components/main-nav/main-nav.component.js +3 -3
  22. package/esm2015/core/providers/i18n/i18n.service.js +14 -5
  23. package/esm2015/core/shared/components/rich-text-editor/prosemirror/prosemirror.service.js +2 -2
  24. package/esm2015/core/shared/dynamic-form-inputs/select-form-input/select-form-input.component.js +2 -2
  25. package/esm2015/core/shared/pipes/asset-preview.pipe.js +2 -2
  26. package/esm2015/core/shared/pipes/locale-base.pipe.js +23 -1
  27. package/esm2015/core/shared/pipes/locale-currency-name.pipe.js +4 -4
  28. package/esm2015/core/shared/pipes/locale-currency.pipe.js +2 -2
  29. package/esm2015/core/shared/pipes/locale-date.pipe.js +2 -2
  30. package/esm2015/core/shared/pipes/locale-language-name.pipe.js +2 -3
  31. package/esm2015/core/shared/pipes/locale-region-name.pipe.js +2 -3
  32. package/esm2015/dashboard/widgets/latest-orders-widget/latest-orders-widget.component.js +2 -1
  33. package/esm2015/settings/components/zone-detail-dialog/zone-detail-dialog.component.js +2 -2
  34. package/fesm2015/vendure-admin-ui-catalog.js +1 -1
  35. package/fesm2015/vendure-admin-ui-catalog.js.map +1 -1
  36. package/fesm2015/vendure-admin-ui-core.js +48 -21
  37. package/fesm2015/vendure-admin-ui-core.js.map +1 -1
  38. package/fesm2015/vendure-admin-ui-dashboard.js +1 -0
  39. package/fesm2015/vendure-admin-ui-dashboard.js.map +1 -1
  40. package/fesm2015/vendure-admin-ui-settings.js +1 -1
  41. package/fesm2015/vendure-admin-ui-settings.js.map +1 -1
  42. package/package.json +2 -2
  43. package/settings/vendure-admin-ui-settings.metadata.json +1 -1
  44. package/static/i18n-messages/pt_PT.json +22 -22
@@ -5769,9 +5769,11 @@ AuthService.ctorParameters = () => [
5769
5769
  { type: ServerConfigService }
5770
5770
  ];
5771
5771
 
5772
+ /** @dynamic */
5772
5773
  class I18nService {
5773
- constructor(ngxTranslate) {
5774
+ constructor(ngxTranslate, document) {
5774
5775
  this.ngxTranslate = ngxTranslate;
5776
+ this.document = document;
5775
5777
  this._availableLanguages = [];
5776
5778
  }
5777
5779
  get availableLanguages() {
@@ -5787,7 +5789,11 @@ class I18nService {
5787
5789
  * Set the UI language
5788
5790
  */
5789
5791
  setLanguage(language) {
5792
+ var _a;
5790
5793
  this.ngxTranslate.use(language);
5794
+ if ((_a = this.document) === null || _a === void 0 ? void 0 : _a.documentElement) {
5795
+ this.document.documentElement.lang = language;
5796
+ }
5791
5797
  }
5792
5798
  /**
5793
5799
  * Set the available UI languages
@@ -5802,14 +5808,15 @@ class I18nService {
5802
5808
  return this.ngxTranslate.instant(key, params);
5803
5809
  }
5804
5810
  }
5805
- I18nService.ɵprov = i0.ɵɵdefineInjectable({ factory: function I18nService_Factory() { return new I18nService(i0.ɵɵinject(i1$1.TranslateService)); }, token: I18nService, providedIn: "root" });
5811
+ I18nService.ɵprov = i0.ɵɵdefineInjectable({ factory: function I18nService_Factory() { return new I18nService(i0.ɵɵinject(i1$1.TranslateService), i0.ɵɵinject(i1.DOCUMENT)); }, token: I18nService, providedIn: "root" });
5806
5812
  I18nService.decorators = [
5807
5813
  { type: Injectable, args: [{
5808
5814
  providedIn: 'root',
5809
5815
  },] }
5810
5816
  ];
5811
5817
  I18nService.ctorParameters = () => [
5812
- { type: TranslateService }
5818
+ { type: TranslateService },
5819
+ { type: Document, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
5813
5820
  ];
5814
5821
 
5815
5822
  /**
@@ -7188,8 +7195,8 @@ class MainNavComponent {
7188
7195
  MainNavComponent.decorators = [
7189
7196
  { type: Component, args: [{
7190
7197
  selector: 'vdr-main-nav',
7191
- template: "<nav class=\"sidenav\" [clr-nav-level]=\"2\">\r\n <section class=\"sidenav-content\">\r\n <ng-container *ngFor=\"let section of navBuilderService.navMenuConfig$ | async\">\r\n <section\r\n class=\"nav-group\"\r\n [attr.data-section-id]=\"section.id\"\r\n [class.collapsible]=\"section.collapsible\"\r\n *ngIf=\"shouldDisplayLink(section)\"\r\n >\r\n <vdr-ui-extension-point [locationId]=\"section.id\" api=\"navMenu\" [topPx]=\"-6\" [leftPx]=\"8\">\r\n <ng-container *ngIf=\"navBuilderService.sectionBadges[section.id] | async as sectionBadge\">\r\n <vdr-status-badge\r\n *ngIf=\"sectionBadge !== 'none'\"\r\n [type]=\"sectionBadge\"\r\n ></vdr-status-badge>\r\n </ng-container>\r\n <input [id]=\"section.id\" type=\"checkbox\" [checked]=\"section.collapsedByDefault\" />\r\n <label [for]=\"section.id\">{{ section.label | translate }}</label>\r\n <ul class=\"nav-list\">\r\n <ng-container *ngFor=\"let item of section.items\">\r\n <li *ngIf=\"shouldDisplayLink(item)\">\r\n <a\r\n class=\"nav-link\"\r\n [attr.data-item-id]=\"section.id\"\r\n [routerLink]=\"getRouterLink(item)\"\r\n routerLinkActive=\"active\"\r\n >\r\n <ng-container *ngIf=\"item.statusBadge | async as itemBadge\">\r\n <vdr-status-badge\r\n *ngIf=\"itemBadge.type !== 'none'\"\r\n [type]=\"itemBadge.type\"\r\n ></vdr-status-badge>\r\n </ng-container>\r\n <clr-icon [attr.shape]=\"item.icon || 'block'\" size=\"20\"></clr-icon>\r\n {{ item.label | translate }}\r\n </a>\r\n </li>\r\n </ng-container>\r\n </ul>\r\n </vdr-ui-extension-point>\r\n </section>\r\n </ng-container>\r\n </section>\r\n</nav>\r\n",
7192
- styles: [":host{order:-1;background-color:var(--clr-nav-background-color)}nav.sidenav{height:100%;width:10.8rem;border-right-color:var(--clr-sidenav-border-color)}.nav-list clr-icon{margin-right:12px}.nav-group,.nav-link{position:relative}.nav-group vdr-status-badge{left:10px;top:6px}.nav-link vdr-status-badge{left:25px;top:3px}\n"]
7198
+ template: "<nav class=\"sidenav\" [clr-nav-level]=\"2\">\r\n <section class=\"sidenav-content\">\r\n <ng-container *ngFor=\"let section of navBuilderService.navMenuConfig$ | async\">\r\n <section\r\n class=\"nav-group\"\r\n [attr.data-section-id]=\"section.id\"\r\n [class.collapsible]=\"section.collapsible\"\r\n *ngIf=\"shouldDisplayLink(section)\"\r\n >\r\n <vdr-ui-extension-point [locationId]=\"section.id\" api=\"navMenu\" [topPx]=\"-6\" [leftPx]=\"8\">\r\n <ng-container *ngIf=\"navBuilderService.sectionBadges[section.id] | async as sectionBadge\">\r\n <vdr-status-badge\r\n *ngIf=\"sectionBadge !== 'none'\"\r\n [type]=\"sectionBadge\"\r\n ></vdr-status-badge>\r\n </ng-container>\r\n <input [id]=\"section.id\" type=\"checkbox\" [checked]=\"section.collapsedByDefault\" />\r\n <label class=\"nav-group-header\" [for]=\"section.id\">{{ section.label | translate }}</label>\r\n <ul class=\"nav-list\">\r\n <ng-container *ngFor=\"let item of section.items\">\r\n <li *ngIf=\"shouldDisplayLink(item)\">\r\n <a\r\n class=\"nav-link\"\r\n [attr.data-item-id]=\"section.id\"\r\n [routerLink]=\"getRouterLink(item)\"\r\n routerLinkActive=\"active\"\r\n >\r\n <ng-container *ngIf=\"item.statusBadge | async as itemBadge\">\r\n <vdr-status-badge\r\n *ngIf=\"itemBadge.type !== 'none'\"\r\n [type]=\"itemBadge.type\"\r\n ></vdr-status-badge>\r\n </ng-container>\r\n <clr-icon [attr.shape]=\"item.icon || 'block'\" size=\"20\"></clr-icon>\r\n {{ item.label | translate }}\r\n </a>\r\n </li>\r\n </ng-container>\r\n </ul>\r\n </vdr-ui-extension-point>\r\n </section>\r\n </ng-container>\r\n </section>\r\n</nav>\r\n",
7199
+ styles: [":host{order:-1;background-color:var(--clr-nav-background-color)}nav.sidenav{height:100%;width:10.8rem;border-right-color:var(--clr-sidenav-border-color)}.sidenav .nav-group .nav-list{margin:0}.sidenav .nav-group .nav-group-header{margin:0;line-height:1.2}.sidenav .nav-group .nav-link{display:inline-flex;line-height:1rem;padding-right:.6rem}.nav-list clr-icon{flex-shrink:0;margin-right:12px}.nav-group{-webkit-hyphens:auto;hyphens:auto}.nav-group,.nav-link{position:relative}.nav-group vdr-status-badge{left:10px;top:6px}.nav-link vdr-status-badge{left:25px;top:3px}\n"]
7193
7200
  },] }
7194
7201
  ];
7195
7202
  MainNavComponent.ctorParameters = () => [
@@ -8788,7 +8795,7 @@ SelectFormInputComponent.id = 'select-form-input';
8788
8795
  SelectFormInputComponent.decorators = [
8789
8796
  { type: Component, args: [{
8790
8797
  selector: 'vdr-select-form-input',
8791
- template: "<select clrSelect [formControl]=\"formControl\" [vdrDisabled]=\"readonly\">\r\n <option *ngIf=\"config.nullable\" [ngValue]=\"null\"></option>\r\n <option *ngFor=\"let option of options\" [value]=\"option.value\">\r\n {{ (option | customFieldLabel) || option.label || option.value }}\r\n </option>\r\n</select>\r\n",
8798
+ template: "<select clrSelect [formControl]=\"formControl\" [vdrDisabled]=\"readonly\">\r\n <option *ngIf=\"config.nullable\" [ngValue]=\"null\"></option>\r\n <option *ngFor=\"let option of options\" [ngValue]=\"option.value\">\r\n {{ (option | customFieldLabel) || option.label || option.value }}\r\n </option>\r\n</select>\r\n",
8792
8799
  changeDetection: ChangeDetectionStrategy.OnPush,
8793
8800
  styles: ["select{width:100%}\n"]
8794
8801
  },] }
@@ -12856,7 +12863,7 @@ class ProsemirrorService {
12856
12863
  }
12857
12864
  getStateFromText(text) {
12858
12865
  const div = document.createElement('div');
12859
- div.innerHTML = text;
12866
+ div.innerHTML = text !== null && text !== void 0 ? text : '';
12860
12867
  return EditorState.create({
12861
12868
  doc: DOMParser.fromSchema(this.mySchema).parse(div),
12862
12869
  plugins: this.configurePlugins({ schema: this.mySchema, floatingMenu: false }),
@@ -14088,7 +14095,7 @@ class AssetPreviewPipe {
14088
14095
  if (!asset) {
14089
14096
  return '';
14090
14097
  }
14091
- if (!asset.preview || typeof asset.preview !== 'string') {
14098
+ if (asset.preview == null || typeof asset.preview !== 'string') {
14092
14099
  throw new Error(`Expected an Asset, got ${JSON.stringify(asset)}`);
14093
14100
  }
14094
14101
  const fp = asset.focalPoint ? `&fpx=${asset.focalPoint.x}&fpy=${asset.focalPoint.y}` : '';
@@ -14340,6 +14347,28 @@ class LocaleBasePipe {
14340
14347
  this.subscription.unsubscribe();
14341
14348
  }
14342
14349
  }
14350
+ /**
14351
+ * Returns the active locale after attempting to ensure that the locale string
14352
+ * is valid for the Intl API.
14353
+ */
14354
+ getActiveLocale(localeOverride) {
14355
+ var _a;
14356
+ const locale = typeof localeOverride === 'string' ? localeOverride : (_a = this.locale) !== null && _a !== void 0 ? _a : 'en';
14357
+ const hyphenated = locale === null || locale === void 0 ? void 0 : locale.replace(/_/g, '-');
14358
+ // Check for a double-region string, containing 2 region codes like
14359
+ // pt-BR-BR, which is invalid. In this case, the second region is used
14360
+ // and the first region discarded. This would only ever be an issue for
14361
+ // those languages where the translation file itself encodes the region,
14362
+ // as in pt_BR & pt_PT.
14363
+ const matches = hyphenated === null || hyphenated === void 0 ? void 0 : hyphenated.match(/^([a-zA-Z_-]+)(-[A-Z][A-Z])(-[A-Z][A-z])$/);
14364
+ if (matches === null || matches === void 0 ? void 0 : matches.length) {
14365
+ const overriddenLocale = matches[1] + matches[3];
14366
+ return overriddenLocale;
14367
+ }
14368
+ else {
14369
+ return hyphenated;
14370
+ }
14371
+ }
14343
14372
  }
14344
14373
  LocaleBasePipe.decorators = [
14345
14374
  { type: Injectable }
@@ -14365,7 +14394,7 @@ class LocaleCurrencyNamePipe extends LocaleBasePipe {
14365
14394
  super(dataService, changeDetectorRef);
14366
14395
  }
14367
14396
  transform(value, display = 'full', locale) {
14368
- var _a, _b;
14397
+ var _a;
14369
14398
  if (value == null || value === '') {
14370
14399
  return '';
14371
14400
  }
@@ -14374,7 +14403,7 @@ class LocaleCurrencyNamePipe extends LocaleBasePipe {
14374
14403
  }
14375
14404
  let name = '';
14376
14405
  let symbol = '';
14377
- const activeLocale = typeof locale === 'string' ? locale : (_a = this.locale) !== null && _a !== void 0 ? _a : 'en';
14406
+ const activeLocale = this.getActiveLocale(locale);
14378
14407
  // Awaiting TS types for this API: https://github.com/microsoft/TypeScript/pull/44022/files
14379
14408
  const DisplayNames = Intl.DisplayNames;
14380
14409
  if (display === 'full' || display === 'name') {
@@ -14388,7 +14417,7 @@ class LocaleCurrencyNamePipe extends LocaleBasePipe {
14388
14417
  currency: value,
14389
14418
  currencyDisplay: 'symbol',
14390
14419
  }).formatToParts();
14391
- symbol = ((_b = parts.find(p => p.type === 'currency')) === null || _b === void 0 ? void 0 : _b.value) || value;
14420
+ symbol = ((_a = parts.find(p => p.type === 'currency')) === null || _a === void 0 ? void 0 : _a.value) || value;
14392
14421
  }
14393
14422
  return display === 'full' ? `${name} (${symbol})` : display === 'name' ? name : symbol;
14394
14423
  }
@@ -14423,7 +14452,7 @@ class LocaleCurrencyPipe extends LocaleBasePipe {
14423
14452
  transform(value, ...args) {
14424
14453
  const [currencyCode, locale] = args;
14425
14454
  if (typeof value === 'number' && typeof currencyCode === 'string') {
14426
- const activeLocale = typeof locale === 'string' ? locale : this.locale;
14455
+ const activeLocale = this.getActiveLocale(locale);
14427
14456
  const majorUnits = value / 100;
14428
14457
  return new Intl.NumberFormat(activeLocale, { style: 'currency', currency: currencyCode }).format(majorUnits);
14429
14458
  }
@@ -14460,7 +14489,7 @@ class LocaleDatePipe extends LocaleBasePipe {
14460
14489
  transform(value, ...args) {
14461
14490
  const [format, locale] = args;
14462
14491
  if (this.locale || typeof locale === 'string') {
14463
- const activeLocale = typeof locale === 'string' ? locale : this.locale;
14492
+ const activeLocale = this.getActiveLocale(locale);
14464
14493
  const date = value instanceof Date ? value : typeof value === 'string' ? new Date(value) : undefined;
14465
14494
  if (date) {
14466
14495
  const options = this.getOptionsForFormat(typeof format === 'string' ? format : 'medium');
@@ -14534,14 +14563,13 @@ class LocaleLanguageNamePipe extends LocaleBasePipe {
14534
14563
  super(dataService, changeDetectorRef);
14535
14564
  }
14536
14565
  transform(value, locale) {
14537
- var _a;
14538
14566
  if (value == null || value === '') {
14539
14567
  return '';
14540
14568
  }
14541
14569
  if (typeof value !== 'string') {
14542
14570
  return `Invalid language code "${value}"`;
14543
14571
  }
14544
- const activeLocale = typeof locale === 'string' ? locale : (_a = this.locale) !== null && _a !== void 0 ? _a : 'en';
14572
+ const activeLocale = this.getActiveLocale(locale);
14545
14573
  // Awaiting TS types for this API: https://github.com/microsoft/TypeScript/pull/44022/files
14546
14574
  const DisplayNames = Intl.DisplayNames;
14547
14575
  try {
@@ -14579,14 +14607,13 @@ class LocaleRegionNamePipe extends LocaleBasePipe {
14579
14607
  super(dataService, changeDetectorRef);
14580
14608
  }
14581
14609
  transform(value, locale) {
14582
- var _a;
14583
14610
  if (value == null || value === '') {
14584
14611
  return '';
14585
14612
  }
14586
14613
  if (typeof value !== 'string') {
14587
14614
  return `Invalid region code "${value}"`;
14588
14615
  }
14589
- const activeLocale = typeof locale === 'string' ? locale : (_a = this.locale) !== null && _a !== void 0 ? _a : 'en';
14616
+ const activeLocale = this.getActiveLocale(locale);
14590
14617
  // Awaiting TS types for this API: https://github.com/microsoft/TypeScript/pull/44022/files
14591
14618
  const DisplayNames = Intl.DisplayNames;
14592
14619
  try {
@@ -15154,12 +15181,12 @@ class BaseDetailComponent {
15154
15181
  return this.detailForm && this.detailForm.pristine;
15155
15182
  }
15156
15183
  setCustomFieldFormValues(customFields, formGroup, entity, currentTranslation) {
15157
- var _a, _b;
15184
+ var _a, _b, _c;
15158
15185
  for (const fieldDef of customFields) {
15159
15186
  const key = fieldDef.name;
15160
15187
  const value = fieldDef.type === 'localeString'
15161
- ? (_a = currentTranslation.customFields) === null || _a === void 0 ? void 0 : _a[key]
15162
- : (_b = entity.customFields) === null || _b === void 0 ? void 0 : _b[key];
15188
+ ? (_b = (_a = currentTranslation) === null || _a === void 0 ? void 0 : _a.customFields) === null || _b === void 0 ? void 0 : _b[key]
15189
+ : (_c = entity.customFields) === null || _c === void 0 ? void 0 : _c[key];
15163
15190
  const control = formGroup === null || formGroup === void 0 ? void 0 : formGroup.get(key);
15164
15191
  if (control) {
15165
15192
  control.patchValue(value);
@@ -15493,7 +15520,7 @@ function patchObject(obj, patch) {
15493
15520
  }
15494
15521
 
15495
15522
  // Auto-generated by the set-version.js script.
15496
- const ADMIN_UI_VERSION = '1.4.2';
15523
+ const ADMIN_UI_VERSION = '1.4.6';
15497
15524
 
15498
15525
  /**
15499
15526
  * Responsible for registering dashboard widget components and querying for layouts.