@vendure/admin-ui 1.3.0 → 1.3.4

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 (31) hide show
  1. package/bundles/vendure-admin-ui-catalog.umd.js +25 -13
  2. package/bundles/vendure-admin-ui-catalog.umd.js.map +1 -1
  3. package/bundles/vendure-admin-ui-core.umd.js +65 -31
  4. package/bundles/vendure-admin-ui-core.umd.js.map +1 -1
  5. package/bundles/vendure-admin-ui-dashboard.umd.js.map +1 -1
  6. package/catalog/components/collection-tree/collection-tree-node.component.d.ts +5 -4
  7. package/catalog/components/collection-tree/collection-tree.component.d.ts +11 -0
  8. package/catalog/vendure-admin-ui-catalog.metadata.json +1 -1
  9. package/core/common/generated-types.d.ts +4 -4
  10. package/core/common/version.d.ts +1 -1
  11. package/core/shared/components/channel-assignment-control/channel-assignment-control.component.d.ts +2 -0
  12. package/core/shared/components/currency-input/currency-input.component.d.ts +6 -3
  13. package/core/vendure-admin-ui-core.metadata.json +1 -1
  14. package/esm2015/catalog/components/collection-tree/array-to-tree.js +1 -1
  15. package/esm2015/catalog/components/collection-tree/collection-tree-node.component.js +4 -14
  16. package/esm2015/catalog/components/collection-tree/collection-tree.component.js +23 -1
  17. package/esm2015/core/common/generated-types.js +1 -1
  18. package/esm2015/core/common/introspection-result.js +1 -1
  19. package/esm2015/core/common/version.js +2 -2
  20. package/esm2015/core/data/data.module.js +1 -1
  21. package/esm2015/core/shared/components/channel-assignment-control/channel-assignment-control.component.js +36 -22
  22. package/esm2015/core/shared/components/currency-input/currency-input.component.js +26 -7
  23. package/esm2015/core/shared/components/object-tree/object-tree.component.js +3 -3
  24. package/esm2015/dashboard/widgets/welcome-widget/welcome-widget.component.js +1 -1
  25. package/fesm2015/vendure-admin-ui-catalog.js +25 -13
  26. package/fesm2015/vendure-admin-ui-catalog.js.map +1 -1
  27. package/fesm2015/vendure-admin-ui-core.js +63 -30
  28. package/fesm2015/vendure-admin-ui-core.js.map +1 -1
  29. package/fesm2015/vendure-admin-ui-dashboard.js.map +1 -1
  30. package/package.json +2 -2
  31. package/static/vendure-ui-config.json +1 -1
@@ -9042,7 +9042,15 @@ class ChannelAssignmentControlComponent {
9042
9042
  this.disabled = false;
9043
9043
  }
9044
9044
  ngOnInit() {
9045
- this.channels$ = this.dataService.client.userStatus().single$.pipe(map(({ userStatus }) => userStatus.channels.filter(c => this.includeDefaultChannel ? true : c.code !== DEFAULT_CHANNEL_CODE)), tap(channels => (this.channels = channels)));
9045
+ this.channels$ = this.dataService.client.userStatus().single$.pipe(map(({ userStatus }) => userStatus.channels.filter(c => this.includeDefaultChannel ? true : c.code !== DEFAULT_CHANNEL_CODE)), tap(channels => {
9046
+ if (!this.channels) {
9047
+ this.channels = channels;
9048
+ this.mapIncomingValueToChannels(this.lastIncomingValue);
9049
+ }
9050
+ else {
9051
+ this.channels = channels;
9052
+ }
9053
+ }));
9046
9054
  }
9047
9055
  registerOnChange(fn) {
9048
9056
  this.onChange = fn;
@@ -9054,26 +9062,8 @@ class ChannelAssignmentControlComponent {
9054
9062
  this.disabled = isDisabled;
9055
9063
  }
9056
9064
  writeValue(obj) {
9057
- var _a;
9058
- if (Array.isArray(obj)) {
9059
- if (typeof obj[0] === 'string') {
9060
- this.value = obj.map(id => { var _a; return (_a = this.channels) === null || _a === void 0 ? void 0 : _a.find(c => c.id === id); }).filter(notNullOrUndefined);
9061
- }
9062
- else {
9063
- this.value = obj;
9064
- }
9065
- }
9066
- else {
9067
- if (typeof obj === 'string') {
9068
- const channel = (_a = this.channels) === null || _a === void 0 ? void 0 : _a.find(c => c.id === obj);
9069
- if (channel) {
9070
- this.value = [channel];
9071
- }
9072
- }
9073
- else if (obj && obj.id) {
9074
- this.value = [obj];
9075
- }
9076
- }
9065
+ this.lastIncomingValue = obj;
9066
+ this.mapIncomingValueToChannels(obj);
9077
9067
  }
9078
9068
  focussed() {
9079
9069
  if (this.onTouched) {
@@ -9096,6 +9086,30 @@ class ChannelAssignmentControlComponent {
9096
9086
  const c2id = typeof c2 === 'string' ? c2 : c2.id;
9097
9087
  return c1id === c2id;
9098
9088
  }
9089
+ mapIncomingValueToChannels(value) {
9090
+ var _a;
9091
+ if (Array.isArray(value)) {
9092
+ if (typeof value[0] === 'string') {
9093
+ this.value = value
9094
+ .map(id => { var _a; return (_a = this.channels) === null || _a === void 0 ? void 0 : _a.find(c => c.id === id); })
9095
+ .filter(notNullOrUndefined);
9096
+ }
9097
+ else {
9098
+ this.value = value;
9099
+ }
9100
+ }
9101
+ else {
9102
+ if (typeof value === 'string') {
9103
+ const channel = (_a = this.channels) === null || _a === void 0 ? void 0 : _a.find(c => c.id === value);
9104
+ if (channel) {
9105
+ this.value = [channel];
9106
+ }
9107
+ }
9108
+ else if (value && value.id) {
9109
+ this.value = [value];
9110
+ }
9111
+ }
9112
+ }
9099
9113
  }
9100
9114
  ChannelAssignmentControlComponent.decorators = [
9101
9115
  { type: Component, args: [{
@@ -9409,6 +9423,7 @@ class CurrencyInputComponent {
9409
9423
  this.readonly = false;
9410
9424
  this.currencyCode = '';
9411
9425
  this.valueChange = new EventEmitter();
9426
+ this.hasFractionPart = true;
9412
9427
  this.currencyCode$ = new BehaviorSubject('');
9413
9428
  }
9414
9429
  ngOnInit() {
@@ -9434,6 +9449,19 @@ class CurrencyInputComponent {
9434
9449
  }));
9435
9450
  this.prefix$ = shouldPrefix$.pipe(map(shouldPrefix => (shouldPrefix ? this.currencyCode : '')));
9436
9451
  this.suffix$ = shouldPrefix$.pipe(map(shouldPrefix => (shouldPrefix ? '' : this.currencyCode)));
9452
+ this.subscription = combineLatest(languageCode$, this.currencyCode$).subscribe(([languageCode, currencyCode]) => {
9453
+ if (!currencyCode) {
9454
+ return '';
9455
+ }
9456
+ const locale = languageCode.replace(/_/g, '-');
9457
+ const parts = new Intl.NumberFormat(locale, {
9458
+ style: 'currency',
9459
+ currency: currencyCode,
9460
+ currencyDisplay: 'symbol',
9461
+ }).formatToParts(123.45);
9462
+ this.hasFractionPart = !!parts.find(p => p.type === 'fraction');
9463
+ this._inputValue = this.toNumericString(this._inputValue);
9464
+ });
9437
9465
  }
9438
9466
  ngOnChanges(changes) {
9439
9467
  if ('value' in changes) {
@@ -9443,6 +9471,11 @@ class CurrencyInputComponent {
9443
9471
  this.currencyCode$.next(this.currencyCode);
9444
9472
  }
9445
9473
  }
9474
+ ngOnDestroy() {
9475
+ if (this.subscription) {
9476
+ this.subscription.unsubscribe();
9477
+ }
9478
+ }
9446
9479
  registerOnChange(fn) {
9447
9480
  this.onChange = fn;
9448
9481
  }
@@ -9458,12 +9491,12 @@ class CurrencyInputComponent {
9458
9491
  this.onChange(integerValue);
9459
9492
  }
9460
9493
  this.valueChange.emit(integerValue);
9461
- const delta = Math.abs(Number(this._decimalValue) - Number(value));
9494
+ const delta = Math.abs(Number(this._inputValue) - Number(value));
9462
9495
  if (0.009 < delta && delta < 0.011) {
9463
- this._decimalValue = this.toNumericString(value);
9496
+ this._inputValue = this.toNumericString(value);
9464
9497
  }
9465
9498
  else {
9466
- this._decimalValue = value;
9499
+ this._inputValue = value;
9467
9500
  }
9468
9501
  }
9469
9502
  onFocus() {
@@ -9474,17 +9507,17 @@ class CurrencyInputComponent {
9474
9507
  writeValue(value) {
9475
9508
  const numericValue = +value;
9476
9509
  if (!Number.isNaN(numericValue)) {
9477
- this._decimalValue = this.toNumericString(Math.floor(value) / 100);
9510
+ this._inputValue = this.toNumericString(Math.floor(value) / 100);
9478
9511
  }
9479
9512
  }
9480
9513
  toNumericString(value) {
9481
- return Number(value).toFixed(2);
9514
+ return this.hasFractionPart ? Number(value).toFixed(2) : Number(value).toFixed(0);
9482
9515
  }
9483
9516
  }
9484
9517
  CurrencyInputComponent.decorators = [
9485
9518
  { type: Component, args: [{
9486
9519
  selector: 'vdr-currency-input',
9487
- template: "<vdr-affixed-input\r\n [prefix]=\"prefix$ | async | localeCurrencyName: 'symbol'\"\r\n [suffix]=\"suffix$ | async | localeCurrencyName: 'symbol'\"\r\n>\r\n <input\r\n type=\"number\"\r\n step=\"0.01\"\r\n [value]=\"_decimalValue\"\r\n [disabled]=\"disabled\"\r\n [readonly]=\"readonly\"\r\n (input)=\"onInput($event.target.value)\"\r\n (focus)=\"onFocus()\"\r\n />\r\n</vdr-affixed-input>\r\n",
9520
+ template: "<vdr-affixed-input\r\n [prefix]=\"prefix$ | async | localeCurrencyName: 'symbol'\"\r\n [suffix]=\"suffix$ | async | localeCurrencyName: 'symbol'\"\r\n>\r\n <input\r\n type=\"number\"\r\n [step]=\"hasFractionPart ? 0.01 : 1\"\r\n [value]=\"_inputValue\"\r\n [disabled]=\"disabled\"\r\n [readonly]=\"readonly\"\r\n (input)=\"onInput($event.target.value)\"\r\n (focus)=\"onFocus()\"\r\n />\r\n</vdr-affixed-input>\r\n",
9488
9521
  providers: [
9489
9522
  {
9490
9523
  provide: NG_VALUE_ACCESSOR,
@@ -10936,7 +10969,7 @@ class ObjectTreeComponent {
10936
10969
  return typeof value === 'object' && value !== null;
10937
10970
  }
10938
10971
  getEntries(inputValue) {
10939
- if (typeof inputValue === 'string') {
10972
+ if (!this.isObject(inputValue)) {
10940
10973
  return [{ key: '', value: inputValue }];
10941
10974
  }
10942
10975
  return Object.entries(inputValue).map(([key, value]) => ({ key, value }));
@@ -10945,7 +10978,7 @@ class ObjectTreeComponent {
10945
10978
  ObjectTreeComponent.decorators = [
10946
10979
  { type: Component, args: [{
10947
10980
  selector: 'vdr-object-tree',
10948
- template: "<button class=\"icon-button\" (click)=\"expanded = !expanded\" *ngIf=\"depth !== 0 && !isArrayItem\">\r\n <clr-icon shape=\"caret\" size=\"12\" [dir]=\"expanded ? 'down' : 'right'\"></clr-icon>\r\n</button>\r\n<ul\r\n class=\"object-tree-node\"\r\n [ngClass]=\"'depth-' + depth\"\r\n [class.array-value]=\"valueIsArray\"\r\n [class.array-item]=\"isArrayItem\"\r\n [class.expanded]=\"expanded\"\r\n>\r\n <li *ngFor=\"let entry of entries\">\r\n <span class=\"key\" *ngIf=\"entry.key\">{{ entry.key }}:</span>\r\n <ng-container *ngIf=\"isObject(entry.value)\">\r\n <vdr-object-tree [value]=\"entry.value\" [isArrayItem]=\"valueIsArray\"></vdr-object-tree>\r\n </ng-container>\r\n <ng-container *ngIf=\"!isObject(entry.value)\">\r\n {{ entry.value }}\r\n </ng-container>\r\n </li>\r\n</ul>\r\n",
10981
+ template: "<button class=\"icon-button\" (click)=\"expanded = !expanded\" *ngIf=\"depth !== 0 && !isArrayItem\">\r\n <clr-icon shape=\"caret\" size=\"12\" [dir]=\"expanded ? 'down' : 'right'\"></clr-icon>\r\n</button>\r\n<ul\r\n class=\"object-tree-node\"\r\n [ngClass]=\"'depth-' + depth\"\r\n [class.array-value]=\"valueIsArray\"\r\n [class.array-item]=\"isArrayItem\"\r\n [class.expanded]=\"expanded\"\r\n>\r\n <li *ngFor=\"let entry of entries\">\r\n <span class=\"key\" *ngIf=\"entry.key\">{{ entry.key }}:</span>\r\n <ng-container *ngIf=\"isObject(entry.value); else primitive\">\r\n <vdr-object-tree [value]=\"entry.value\" [isArrayItem]=\"valueIsArray\"></vdr-object-tree>\r\n </ng-container>\r\n <ng-template #primitive>\r\n {{ entry.value }}\r\n </ng-template>\r\n </li>\r\n</ul>\r\n",
10949
10982
  changeDetection: ChangeDetectionStrategy.OnPush,
10950
10983
  styles: [".object-tree-node{list-style-type:none;line-height:16px;font-size:12px;overflow:hidden;max-height:0}.object-tree-node.depth-0{margin-left:0;margin-top:8px}.object-tree-node.depth-1{margin-left:6px}.object-tree-node.depth-2{margin-left:6px}.object-tree-node.depth-3{margin-left:6px}.object-tree-node.depth-4{margin-left:6px}.object-tree-node.depth-5{margin-left:6px}.object-tree-node.depth-6{margin-left:6px}.object-tree-node.expanded{max-height:5000px}.object-tree-node.array-item{margin-top:-16px;margin-left:16px}.object-tree-node.array-value.expanded>li+li{margin-top:6px}.key{color:var(--color-text-300)}\n"]
10951
10984
  },] }
@@ -13936,7 +13969,7 @@ function patchObject(obj, patch) {
13936
13969
  }
13937
13970
 
13938
13971
  // Auto-generated by the set-version.js script.
13939
- const ADMIN_UI_VERSION = '1.3.0';
13972
+ const ADMIN_UI_VERSION = '1.3.4';
13940
13973
 
13941
13974
  /**
13942
13975
  * Responsible for registering dashboard widget components and querying for layouts.