@kirbydesign/designsystem 4.0.10 → 4.0.14

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 (23) hide show
  1. package/bundles/kirbydesign-designsystem.umd.js +92 -42
  2. package/bundles/kirbydesign-designsystem.umd.js.map +1 -1
  3. package/bundles/kirbydesign-designsystem.umd.min.js +1 -1
  4. package/bundles/kirbydesign-designsystem.umd.min.js.map +1 -1
  5. package/esm2015/lib/components/chart/chart.component.js +25 -2
  6. package/esm2015/lib/components/chart/chart.component.metadata.json +1 -1
  7. package/esm2015/lib/components/icon/kirby-icon-settings.js +2 -1
  8. package/esm2015/lib/components/icon/kirby-icon-settings.metadata.json +1 -1
  9. package/esm2015/lib/components/radio/radio-group/radio-group.component.js +8 -4
  10. package/esm2015/lib/components/radio/radio-group/radio-group.component.metadata.json +1 -1
  11. package/esm2015/lib/components/segmented-control/segment-item.js +1 -1
  12. package/esm2015/lib/components/segmented-control/segment-item.metadata.json +1 -1
  13. package/esm2015/lib/components/segmented-control/segmented-control.component.js +17 -3
  14. package/esm2015/lib/components/segmented-control/segmented-control.component.metadata.json +1 -1
  15. package/fesm2015/kirbydesign-designsystem.js +82 -42
  16. package/fesm2015/kirbydesign-designsystem.js.map +1 -1
  17. package/icons/svg/payment-card.svg +6 -0
  18. package/kirbydesign-designsystem.metadata.json +1 -1
  19. package/lib/components/chart/chart.component.d.ts +1 -0
  20. package/lib/components/radio/radio-group/radio-group.component.d.ts +1 -0
  21. package/lib/components/segmented-control/segment-item.d.ts +12 -6
  22. package/lib/components/segmented-control/segmented-control.component.d.ts +3 -0
  23. package/package.json +1 -1
@@ -1227,6 +1227,7 @@
1227
1227
  { name: 'misc', svg: 'assets/kirby/icons/svg/misc.svg' },
1228
1228
  { name: 'more', svg: 'assets/kirby/icons/svg/more.svg' },
1229
1229
  { name: 'move', svg: 'assets/kirby/icons/svg/move.svg' },
1230
+ { name: 'payment-card', svg: 'assets/kirby/icons/svg/payment-card.svg' },
1230
1231
  { name: 'pension', svg: 'assets/kirby/icons/svg/pension.svg' },
1231
1232
  { name: 'person-outline', svg: 'assets/kirby/icons/svg/person-outline.svg' },
1232
1233
  { name: 'person', svg: 'assets/kirby/icons/svg/person.svg' },
@@ -3808,6 +3809,42 @@
3808
3809
  return Array.isArray(value) && value.every(function (item) { return typeof item === 'number'; });
3809
3810
  }
3810
3811
 
3812
+ var ComponentLoaderDirective = /** @class */ (function () {
3813
+ function ComponentLoaderDirective(componentFactoryResolver, viewContainerRef, renderer) {
3814
+ this.componentFactoryResolver = componentFactoryResolver;
3815
+ this.viewContainerRef = viewContainerRef;
3816
+ this.renderer = renderer;
3817
+ }
3818
+ ComponentLoaderDirective.prototype.ngOnInit = function () {
3819
+ this.loadCard();
3820
+ };
3821
+ ComponentLoaderDirective.prototype.loadCard = function () {
3822
+ var componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.configuration.component);
3823
+ this.viewContainerRef.clear();
3824
+ var componentRef = this.viewContainerRef.createComponent(componentFactory);
3825
+ if (componentRef && componentRef.location && componentRef.location.nativeElement) {
3826
+ this.renderer.addClass(componentRef.location.nativeElement, this.cssClass);
3827
+ }
3828
+ componentRef.instance.data = this.configuration.data;
3829
+ };
3830
+ return ComponentLoaderDirective;
3831
+ }());
3832
+ ComponentLoaderDirective.decorators = [
3833
+ { type: i0.Directive, args: [{
3834
+ selector: '[kirbyLoadComponent]',
3835
+ },] }
3836
+ ];
3837
+ /** @nocollapse */
3838
+ ComponentLoaderDirective.ctorParameters = function () { return [
3839
+ { type: i0.ComponentFactoryResolver },
3840
+ { type: i0.ViewContainerRef },
3841
+ { type: i0.Renderer2 }
3842
+ ]; };
3843
+ ComponentLoaderDirective.propDecorators = {
3844
+ configuration: [{ type: i0.Input, args: ['kirbyLoadComponent',] }],
3845
+ cssClass: [{ type: i0.Input }]
3846
+ };
3847
+
3811
3848
  function deepCopy(obj) {
3812
3849
  return JSON.parse(JSON.stringify(obj));
3813
3850
  }
@@ -4245,7 +4282,34 @@
4245
4282
  configurable: true
4246
4283
  });
4247
4284
  ChartComponent.prototype.ngAfterViewInit = function () {
4248
- this.renderChart();
4285
+ var _this = this;
4286
+ /*
4287
+ A chart is not rendered until it has both a height and a width.
4288
+ If ChartComponent is slotted in an ionic component it will
4289
+ not have any height or width on afterViewInit. This will cause
4290
+ the animation to not be played on first draw.
4291
+ */
4292
+ var canvasElement = this.canvasElement.nativeElement;
4293
+ this.whenElementHasHeightAndWidth(canvasElement).then(function () { return _this.renderChart(); });
4294
+ };
4295
+ ChartComponent.prototype.whenElementHasHeightAndWidth = function (element) {
4296
+ var rectIs2D = function (_a) {
4297
+ var width = _a.width, height = _a.height;
4298
+ return height > 0 && width > 0;
4299
+ };
4300
+ return new Promise(function (resolve) {
4301
+ var initialClientRect = element.getBoundingClientRect();
4302
+ if (rectIs2D(initialClientRect))
4303
+ resolve();
4304
+ var resizeObserver = new ResizeObserverFactory().create(function (_a) {
4305
+ var _b = __read(_a, 1), resizeObserverEntry = _b[0];
4306
+ if (rectIs2D(resizeObserverEntry.contentRect)) {
4307
+ resizeObserver.unobserve(element);
4308
+ resolve();
4309
+ }
4310
+ });
4311
+ resizeObserver.observe(element);
4312
+ });
4249
4313
  };
4250
4314
  ChartComponent.prototype.ngOnChanges = function (simpleChanges) {
4251
4315
  var _this = this;
@@ -6191,6 +6255,13 @@
6191
6255
  enumerable: false,
6192
6256
  configurable: true
6193
6257
  });
6258
+ Object.defineProperty(RadioGroupComponent.prototype, "hasValue", {
6259
+ get: function () {
6260
+ return this.value !== undefined && this.value !== null;
6261
+ },
6262
+ enumerable: false,
6263
+ configurable: true
6264
+ });
6194
6265
  Object.defineProperty(RadioGroupComponent.prototype, "hasItemsFromContentProjection", {
6195
6266
  get: function () {
6196
6267
  return (!this.items.length &&
@@ -6258,7 +6329,7 @@
6258
6329
  // #endregion "protected" methods used by template
6259
6330
  // #region private methods
6260
6331
  RadioGroupComponent.prototype.getIndexOfSelectedValue = function () {
6261
- if (!this.value)
6332
+ if (!this.hasValue)
6262
6333
  return -1;
6263
6334
  return this.hasItemsFromContentProjection
6264
6335
  ? this.getIndexOfProjectedRadio(this.value)
@@ -6307,10 +6378,11 @@
6307
6378
  });
6308
6379
  };
6309
6380
  RadioGroupComponent.prototype.refreshSelectionState = function () {
6310
- if (this.value) {
6381
+ if (this.hasValue) {
6311
6382
  this._selectedIndex = this.getIndexOfSelectedValue(); // Ensure selectedIndex reflects value within items
6312
6383
  }
6313
- this._value = this.getValueFromSelectedIndex() || null; // Ensure value exists within items
6384
+ var valueFromSelectedIndex = this.getValueFromSelectedIndex();
6385
+ this._value = valueFromSelectedIndex !== undefined ? valueFromSelectedIndex : null;
6314
6386
  };
6315
6387
  RadioGroupComponent.prototype.refreshStateFromProjectedContent = function () {
6316
6388
  if (!!this._customItemTemplate)
@@ -8575,49 +8647,14 @@
8575
8647
  },] }
8576
8648
  ];
8577
8649
 
8578
- var ComponentLoaderDirective = /** @class */ (function () {
8579
- function ComponentLoaderDirective(componentFactoryResolver, viewContainerRef, renderer) {
8580
- this.componentFactoryResolver = componentFactoryResolver;
8581
- this.viewContainerRef = viewContainerRef;
8582
- this.renderer = renderer;
8583
- }
8584
- ComponentLoaderDirective.prototype.ngOnInit = function () {
8585
- this.loadCard();
8586
- };
8587
- ComponentLoaderDirective.prototype.loadCard = function () {
8588
- var componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.configuration.component);
8589
- this.viewContainerRef.clear();
8590
- var componentRef = this.viewContainerRef.createComponent(componentFactory);
8591
- if (componentRef && componentRef.location && componentRef.location.nativeElement) {
8592
- this.renderer.addClass(componentRef.location.nativeElement, this.cssClass);
8593
- }
8594
- componentRef.instance.data = this.configuration.data;
8595
- };
8596
- return ComponentLoaderDirective;
8597
- }());
8598
- ComponentLoaderDirective.decorators = [
8599
- { type: i0.Directive, args: [{
8600
- selector: '[kirbyLoadComponent]',
8601
- },] }
8602
- ];
8603
- /** @nocollapse */
8604
- ComponentLoaderDirective.ctorParameters = function () { return [
8605
- { type: i0.ComponentFactoryResolver },
8606
- { type: i0.ViewContainerRef },
8607
- { type: i0.Renderer2 }
8608
- ]; };
8609
- ComponentLoaderDirective.propDecorators = {
8610
- configuration: [{ type: i0.Input, args: ['kirbyLoadComponent',] }],
8611
- cssClass: [{ type: i0.Input }]
8612
- };
8613
-
8614
8650
  (function (SegmentedControlMode) {
8615
8651
  SegmentedControlMode["chip"] = "chip";
8616
8652
  SegmentedControlMode["compactChip"] = "compactChip";
8617
8653
  SegmentedControlMode["default"] = "default";
8618
8654
  })(exports.SegmentedControlMode || (exports.SegmentedControlMode = {}));
8619
8655
  var SegmentedControlComponent = /** @class */ (function () {
8620
- function SegmentedControlComponent() {
8656
+ function SegmentedControlComponent(iconRegistryService) {
8657
+ this.iconRegistryService = iconRegistryService;
8621
8658
  this.mode = exports.SegmentedControlMode.default;
8622
8659
  this._items = [];
8623
8660
  this._selectedIndex = -1;
@@ -8647,7 +8684,16 @@
8647
8684
  return this._items;
8648
8685
  },
8649
8686
  set: function (value) {
8687
+ var _this = this;
8650
8688
  this._items = value || [];
8689
+ this._items.forEach(function (item) {
8690
+ if (item.badge === undefined)
8691
+ return;
8692
+ // We need to verify whether badges icon is custom or default, so we can check for it in the template
8693
+ item.badge.isCustomIcon =
8694
+ item.badge.icon !== undefined &&
8695
+ _this.iconRegistryService.getIcon(item.badge.icon) !== undefined;
8696
+ });
8651
8697
  var checkedItemIndex = this.items.findIndex(function (item) { return item.checked; });
8652
8698
  if (checkedItemIndex > -1) {
8653
8699
  console.warn('SegmentItem.checked is deprecated - please remove from your `items` configuration. Use `selectedIndex` or `value` on `<kirby-segmented-control>` instead ');
@@ -8700,12 +8746,16 @@
8700
8746
  SegmentedControlComponent.decorators = [
8701
8747
  { type: i0.Component, args: [{
8702
8748
  selector: 'kirby-segmented-control',
8703
- template: "<ion-segment\n *ngIf=\"mode === 'default'\"\n [value]=\"value?.id\"\n (ionChange)=\"onSegmentSelect($event.detail.value)\"\n (click)=\"preventWrapperClick($event)\"\n>\n <div *ngFor=\"let item of items\" class=\"segment-btn-wrapper\">\n <ion-segment-button [value]=\"item.id\">{{ item.text }}</ion-segment-button>\n <kirby-badge\n *ngIf=\"item.badge\"\n role=\"text\"\n [attr.aria-label]=\"item.badge.description\"\n [themeColor]=\"item.badge.themeColor\"\n >\n <kirby-icon\n *ngIf=\"item.badge.icon; else badgeContent\"\n [customName]=\"item.badge.icon\"\n [name]=\"item.badge.icon\"\n ></kirby-icon>\n <ng-template #badgeContent>\n {{ item.badge.content }}\n </ng-template>\n </kirby-badge>\n </div>\n</ion-segment>\n\n<ng-container *ngIf=\"mode === 'chip' || mode === 'compactChip'\">\n <kirby-chip\n *ngFor=\"let item of items; let index = index\"\n [text]=\"item.text\"\n [isSelected]=\"index === selectedIndex\"\n (click)=\"onSegmentSelect(item.id)\"\n role=\"button\"\n ></kirby-chip>\n</ng-container>\n",
8749
+ template: "<ion-segment\n *ngIf=\"mode === 'default'\"\n [value]=\"value?.id\"\n (ionChange)=\"onSegmentSelect($event.detail.value)\"\n (click)=\"preventWrapperClick($event)\"\n>\n <div *ngFor=\"let item of items\" class=\"segment-btn-wrapper\">\n <ion-segment-button [value]=\"item.id\">{{ item.text }}</ion-segment-button>\n <kirby-badge\n *ngIf=\"item.badge\"\n role=\"text\"\n [attr.aria-label]=\"item.badge.description\"\n [themeColor]=\"item.badge.themeColor\"\n >\n <ng-container *ngIf=\"item.badge.icon; else badgeContent\">\n <kirby-icon\n *ngIf=\"item.badge.isCustomIcon; else defaultIconName\"\n [customName]=\"item.badge.icon\"\n ></kirby-icon>\n <ng-template #defaultIconName>\n <kirby-icon [name]=\"item.badge.icon\"></kirby-icon>\n </ng-template>\n </ng-container>\n <ng-template #badgeContent>\n {{ item.badge.content }}\n </ng-template>\n </kirby-badge>\n </div>\n</ion-segment>\n\n<ng-container *ngIf=\"mode === 'chip' || mode === 'compactChip'\">\n <kirby-chip\n *ngFor=\"let item of items; let index = index\"\n [text]=\"item.text\"\n [isSelected]=\"index === selectedIndex\"\n (click)=\"onSegmentSelect(item.id)\"\n role=\"button\"\n ></kirby-chip>\n</ng-container>\n",
8704
8750
  // tslint:disable-next-line: no-host-metadata-property
8705
8751
  host: { role: 'group' },
8706
8752
  styles: [":host{display:block;-webkit-user-select:none;user-select:none;--kirby-badge-elevation:0 5px 10px -10px rgba(28,28,28,0.3),0 0 5px 0 rgba(28,28,28,0.08);--kirby-badge-position:absolute;--kirby-badge-top:-8px;--kirby-badge-right:8px;--kirby-badge-z-index:2}:host.sm ion-segment-button{min-height:32px;font-size:12px;--padding-start:16px;--padding-end:16px}:host.chip-mode{display:flex;flex-wrap:nowrap;overflow-x:auto;overflow-y:hidden}@media (pointer:coarse){:host.chip-mode{scrollbar-width:none}:host.chip-mode::-webkit-scrollbar{display:none}}ion-segment{display:inline-flex;width:auto;overflow:visible;contain:unset;--background:var(--kirby-white);border-radius:999px}ion-segment-button{position:relative;min-height:40px;font-weight:400;font-size:14px;text-transform:none;--border-radius:999px;--border-style:none;--background:none;--color:var(--kirby-white-contrast);--indicator-color:var(--kirby-black);--color-checked:var(--kirby-black-contrast);--color-hover:var(--kirby-black-tint);--indicator-box-shadow:none;--padding-start:24px;--padding-end:24px;--margin-bottom:0;--margin-end:0;--margin-start:0;--margin-top:0;margin:0}ion-segment-button:after{content:\"\";position:absolute;min-height:44px;min-width:44px;width:100%;height:100%;transform:translate(-50%,-50%);left:50%;top:50%}.segment-btn-wrapper{position:relative}:host-context(.plt-desktop) ion-segment-button:focus-within{outline-color:-webkit-focus-ring-color;outline-style:auto}"]
8707
8753
  },] }
8708
8754
  ];
8755
+ /** @nocollapse */
8756
+ SegmentedControlComponent.ctorParameters = function () { return [
8757
+ { type: IconRegistryService }
8758
+ ]; };
8709
8759
  SegmentedControlComponent.propDecorators = {
8710
8760
  mode: [{ type: i0.Input }],
8711
8761
  _modeCssClass: [{ type: i0.HostBinding, args: ['class',] }],