@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
@@ -7092,7 +7092,15 @@
7092
7092
  this.channels$ = this.dataService.client.userStatus().single$.pipe(operators.map(function (_b) {
7093
7093
  var userStatus = _b.userStatus;
7094
7094
  return userStatus.channels.filter(function (c) { return _this.includeDefaultChannel ? true : c.code !== sharedConstants.DEFAULT_CHANNEL_CODE; });
7095
- }), operators.tap(function (channels) { return (_this.channels = channels); }));
7095
+ }), operators.tap(function (channels) {
7096
+ if (!_this.channels) {
7097
+ _this.channels = channels;
7098
+ _this.mapIncomingValueToChannels(_this.lastIncomingValue);
7099
+ }
7100
+ else {
7101
+ _this.channels = channels;
7102
+ }
7103
+ }));
7096
7104
  };
7097
7105
  ChannelAssignmentControlComponent.prototype.registerOnChange = function (fn) {
7098
7106
  this.onChange = fn;
@@ -7104,27 +7112,8 @@
7104
7112
  this.disabled = isDisabled;
7105
7113
  };
7106
7114
  ChannelAssignmentControlComponent.prototype.writeValue = function (obj) {
7107
- var _this = this;
7108
- var _a;
7109
- if (Array.isArray(obj)) {
7110
- if (typeof obj[0] === 'string') {
7111
- this.value = obj.map(function (id) { var _a; return (_a = _this.channels) === null || _a === void 0 ? void 0 : _a.find(function (c) { return c.id === id; }); }).filter(sharedUtils.notNullOrUndefined);
7112
- }
7113
- else {
7114
- this.value = obj;
7115
- }
7116
- }
7117
- else {
7118
- if (typeof obj === 'string') {
7119
- var channel = (_a = this.channels) === null || _a === void 0 ? void 0 : _a.find(function (c) { return c.id === obj; });
7120
- if (channel) {
7121
- this.value = [channel];
7122
- }
7123
- }
7124
- else if (obj && obj.id) {
7125
- this.value = [obj];
7126
- }
7127
- }
7115
+ this.lastIncomingValue = obj;
7116
+ this.mapIncomingValueToChannels(obj);
7128
7117
  };
7129
7118
  ChannelAssignmentControlComponent.prototype.focussed = function () {
7130
7119
  if (this.onTouched) {
@@ -7147,6 +7136,31 @@
7147
7136
  var c2id = typeof c2 === 'string' ? c2 : c2.id;
7148
7137
  return c1id === c2id;
7149
7138
  };
7139
+ ChannelAssignmentControlComponent.prototype.mapIncomingValueToChannels = function (value) {
7140
+ var _this = this;
7141
+ var _a;
7142
+ if (Array.isArray(value)) {
7143
+ if (typeof value[0] === 'string') {
7144
+ this.value = value
7145
+ .map(function (id) { var _a; return (_a = _this.channels) === null || _a === void 0 ? void 0 : _a.find(function (c) { return c.id === id; }); })
7146
+ .filter(sharedUtils.notNullOrUndefined);
7147
+ }
7148
+ else {
7149
+ this.value = value;
7150
+ }
7151
+ }
7152
+ else {
7153
+ if (typeof value === 'string') {
7154
+ var channel = (_a = this.channels) === null || _a === void 0 ? void 0 : _a.find(function (c) { return c.id === value; });
7155
+ if (channel) {
7156
+ this.value = [channel];
7157
+ }
7158
+ }
7159
+ else if (value && value.id) {
7160
+ this.value = [value];
7161
+ }
7162
+ }
7163
+ };
7150
7164
  return ChannelAssignmentControlComponent;
7151
7165
  }());
7152
7166
  ChannelAssignmentControlComponent.decorators = [
@@ -7497,6 +7511,7 @@
7497
7511
  this.readonly = false;
7498
7512
  this.currencyCode = '';
7499
7513
  this.valueChange = new i0.EventEmitter();
7514
+ this.hasFractionPart = true;
7500
7515
  this.currencyCode$ = new rxjs.BehaviorSubject('');
7501
7516
  }
7502
7517
  CurrencyInputComponent.prototype.ngOnInit = function () {
@@ -7524,6 +7539,20 @@
7524
7539
  }));
7525
7540
  this.prefix$ = shouldPrefix$.pipe(operators.map(function (shouldPrefix) { return (shouldPrefix ? _this.currencyCode : ''); }));
7526
7541
  this.suffix$ = shouldPrefix$.pipe(operators.map(function (shouldPrefix) { return (shouldPrefix ? '' : _this.currencyCode); }));
7542
+ this.subscription = rxjs.combineLatest(languageCode$, this.currencyCode$).subscribe(function (_c) {
7543
+ var _d = __read(_c, 2), languageCode = _d[0], currencyCode = _d[1];
7544
+ if (!currencyCode) {
7545
+ return '';
7546
+ }
7547
+ var locale = languageCode.replace(/_/g, '-');
7548
+ var parts = new Intl.NumberFormat(locale, {
7549
+ style: 'currency',
7550
+ currency: currencyCode,
7551
+ currencyDisplay: 'symbol',
7552
+ }).formatToParts(123.45);
7553
+ _this.hasFractionPart = !!parts.find(function (p) { return p.type === 'fraction'; });
7554
+ _this._inputValue = _this.toNumericString(_this._inputValue);
7555
+ });
7527
7556
  };
7528
7557
  CurrencyInputComponent.prototype.ngOnChanges = function (changes) {
7529
7558
  if ('value' in changes) {
@@ -7533,6 +7562,11 @@
7533
7562
  this.currencyCode$.next(this.currencyCode);
7534
7563
  }
7535
7564
  };
7565
+ CurrencyInputComponent.prototype.ngOnDestroy = function () {
7566
+ if (this.subscription) {
7567
+ this.subscription.unsubscribe();
7568
+ }
7569
+ };
7536
7570
  CurrencyInputComponent.prototype.registerOnChange = function (fn) {
7537
7571
  this.onChange = fn;
7538
7572
  };
@@ -7548,12 +7582,12 @@
7548
7582
  this.onChange(integerValue);
7549
7583
  }
7550
7584
  this.valueChange.emit(integerValue);
7551
- var delta = Math.abs(Number(this._decimalValue) - Number(value));
7585
+ var delta = Math.abs(Number(this._inputValue) - Number(value));
7552
7586
  if (0.009 < delta && delta < 0.011) {
7553
- this._decimalValue = this.toNumericString(value);
7587
+ this._inputValue = this.toNumericString(value);
7554
7588
  }
7555
7589
  else {
7556
- this._decimalValue = value;
7590
+ this._inputValue = value;
7557
7591
  }
7558
7592
  };
7559
7593
  CurrencyInputComponent.prototype.onFocus = function () {
@@ -7564,18 +7598,18 @@
7564
7598
  CurrencyInputComponent.prototype.writeValue = function (value) {
7565
7599
  var numericValue = +value;
7566
7600
  if (!Number.isNaN(numericValue)) {
7567
- this._decimalValue = this.toNumericString(Math.floor(value) / 100);
7601
+ this._inputValue = this.toNumericString(Math.floor(value) / 100);
7568
7602
  }
7569
7603
  };
7570
7604
  CurrencyInputComponent.prototype.toNumericString = function (value) {
7571
- return Number(value).toFixed(2);
7605
+ return this.hasFractionPart ? Number(value).toFixed(2) : Number(value).toFixed(0);
7572
7606
  };
7573
7607
  return CurrencyInputComponent;
7574
7608
  }());
7575
7609
  CurrencyInputComponent.decorators = [
7576
7610
  { type: i0.Component, args: [{
7577
7611
  selector: 'vdr-currency-input',
7578
- 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",
7612
+ 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",
7579
7613
  providers: [
7580
7614
  {
7581
7615
  provide: forms.NG_VALUE_ACCESSOR,
@@ -9117,7 +9151,7 @@
9117
9151
  return typeof value === 'object' && value !== null;
9118
9152
  };
9119
9153
  ObjectTreeComponent.prototype.getEntries = function (inputValue) {
9120
- if (typeof inputValue === 'string') {
9154
+ if (!this.isObject(inputValue)) {
9121
9155
  return [{ key: '', value: inputValue }];
9122
9156
  }
9123
9157
  return Object.entries(inputValue).map(function (_a) {
@@ -9130,7 +9164,7 @@
9130
9164
  ObjectTreeComponent.decorators = [
9131
9165
  { type: i0.Component, args: [{
9132
9166
  selector: 'vdr-object-tree',
9133
- 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",
9167
+ 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",
9134
9168
  changeDetection: i0.ChangeDetectionStrategy.OnPush,
9135
9169
  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"]
9136
9170
  },] }
@@ -12349,7 +12383,7 @@
12349
12383
  }
12350
12384
 
12351
12385
  // Auto-generated by the set-version.js script.
12352
- var ADMIN_UI_VERSION = '1.3.0';
12386
+ var ADMIN_UI_VERSION = '1.3.4';
12353
12387
 
12354
12388
  /**
12355
12389
  * Responsible for registering dashboard widget components and querying for layouts.