@kirbydesign/designsystem 4.0.12 → 4.0.16

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.
@@ -3809,6 +3809,42 @@
3809
3809
  return Array.isArray(value) && value.every(function (item) { return typeof item === 'number'; });
3810
3810
  }
3811
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
+
3812
3848
  function deepCopy(obj) {
3813
3849
  return JSON.parse(JSON.stringify(obj));
3814
3850
  }
@@ -4246,7 +4282,34 @@
4246
4282
  configurable: true
4247
4283
  });
4248
4284
  ChartComponent.prototype.ngAfterViewInit = function () {
4249
- 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
+ });
4250
4313
  };
4251
4314
  ChartComponent.prototype.ngOnChanges = function (simpleChanges) {
4252
4315
  var _this = this;
@@ -8584,49 +8647,14 @@
8584
8647
  },] }
8585
8648
  ];
8586
8649
 
8587
- var ComponentLoaderDirective = /** @class */ (function () {
8588
- function ComponentLoaderDirective(componentFactoryResolver, viewContainerRef, renderer) {
8589
- this.componentFactoryResolver = componentFactoryResolver;
8590
- this.viewContainerRef = viewContainerRef;
8591
- this.renderer = renderer;
8592
- }
8593
- ComponentLoaderDirective.prototype.ngOnInit = function () {
8594
- this.loadCard();
8595
- };
8596
- ComponentLoaderDirective.prototype.loadCard = function () {
8597
- var componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.configuration.component);
8598
- this.viewContainerRef.clear();
8599
- var componentRef = this.viewContainerRef.createComponent(componentFactory);
8600
- if (componentRef && componentRef.location && componentRef.location.nativeElement) {
8601
- this.renderer.addClass(componentRef.location.nativeElement, this.cssClass);
8602
- }
8603
- componentRef.instance.data = this.configuration.data;
8604
- };
8605
- return ComponentLoaderDirective;
8606
- }());
8607
- ComponentLoaderDirective.decorators = [
8608
- { type: i0.Directive, args: [{
8609
- selector: '[kirbyLoadComponent]',
8610
- },] }
8611
- ];
8612
- /** @nocollapse */
8613
- ComponentLoaderDirective.ctorParameters = function () { return [
8614
- { type: i0.ComponentFactoryResolver },
8615
- { type: i0.ViewContainerRef },
8616
- { type: i0.Renderer2 }
8617
- ]; };
8618
- ComponentLoaderDirective.propDecorators = {
8619
- configuration: [{ type: i0.Input, args: ['kirbyLoadComponent',] }],
8620
- cssClass: [{ type: i0.Input }]
8621
- };
8622
-
8623
8650
  (function (SegmentedControlMode) {
8624
8651
  SegmentedControlMode["chip"] = "chip";
8625
8652
  SegmentedControlMode["compactChip"] = "compactChip";
8626
8653
  SegmentedControlMode["default"] = "default";
8627
8654
  })(exports.SegmentedControlMode || (exports.SegmentedControlMode = {}));
8628
8655
  var SegmentedControlComponent = /** @class */ (function () {
8629
- function SegmentedControlComponent() {
8656
+ function SegmentedControlComponent(iconRegistryService) {
8657
+ this.iconRegistryService = iconRegistryService;
8630
8658
  this.mode = exports.SegmentedControlMode.default;
8631
8659
  this._items = [];
8632
8660
  this._selectedIndex = -1;
@@ -8656,7 +8684,16 @@
8656
8684
  return this._items;
8657
8685
  },
8658
8686
  set: function (value) {
8687
+ var _this = this;
8659
8688
  this._items = value || [];
8689
+ this._items.forEach(function (item) {
8690
+ if (!item.badge)
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
+ });
8660
8697
  var checkedItemIndex = this.items.findIndex(function (item) { return item.checked; });
8661
8698
  if (checkedItemIndex > -1) {
8662
8699
  console.warn('SegmentItem.checked is deprecated - please remove from your `items` configuration. Use `selectedIndex` or `value` on `<kirby-segmented-control>` instead ');
@@ -8709,12 +8746,16 @@
8709
8746
  SegmentedControlComponent.decorators = [
8710
8747
  { type: i0.Component, args: [{
8711
8748
  selector: 'kirby-segmented-control',
8712
- 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",
8713
8750
  // tslint:disable-next-line: no-host-metadata-property
8714
8751
  host: { role: 'group' },
8715
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}"]
8716
8753
  },] }
8717
8754
  ];
8755
+ /** @nocollapse */
8756
+ SegmentedControlComponent.ctorParameters = function () { return [
8757
+ { type: IconRegistryService }
8758
+ ]; };
8718
8759
  SegmentedControlComponent.propDecorators = {
8719
8760
  mode: [{ type: i0.Input }],
8720
8761
  _modeCssClass: [{ type: i0.HostBinding, args: ['class',] }],
@@ -8834,7 +8875,7 @@
8834
8875
  { type: i0.Component, args: [{
8835
8876
  selector: 'kirby-tab-button',
8836
8877
  template: "<ion-tab-button #ionTabButton [tab]=\"routerLink\" (click)=\"onClick($event, ionTabButton.selected)\">\n <div class=\"icon-container\" *ngIf=\"icons.length\">\n <ng-content\n *ngIf=\"icons.length === 1 || !ionTabButton.selected\"\n select=\"kirby-icon[:not([selected-tab])]\"\n ></ng-content>\n <ng-content *ngIf=\"ionTabButton.selected\" select=\"kirby-icon[selected-tab]\"></ng-content>\n <ng-content select=\"kirby-badge\"></ng-content>\n </div>\n <ion-label>\n <ng-content></ng-content>\n </ion-label>\n</ion-tab-button>\n",
8837
- styles: ["ion-tab-button{height:100%;flex:1 1 0%;max-width:168px;font-size:10px;--color-selected:get-color(\"black\");--kirby-badge-position:absolute;--kirby-badge-left:calc(50% + 5px);--kirby-badge-top:0}@media (min-width:721px){ion-tab-button{flex:none;padding:0 24px;margin-right:24px;font-size:14px;flex-direction:row;--kirby-badge-top:-5px;--kirby-badge-left:auto;--kirby-badge-right:-5px}ion-tab-button:last-child{margin-right:0}ion-tab-button .icon-container{position:relative;margin-right:8px}}@media (min-width:1025px) and (hover:hover) and (pointer:fine){ion-tab-button{padding:0 12px;margin-right:0}}"]
8878
+ styles: ["ion-tab-button{height:100%;flex:1 1 0%;max-width:168px;font-size:10px;--color-selected:get-color(\"black\");--kirby-badge-position:absolute;--kirby-badge-top:0;--kirby-badge-right:0}ion-tab-button ::ng-deep>div kirby-badge.md{--kirby-badge-top:-5px;--kirby-badge-right:-5px}ion-tab-button .icon-container{position:relative}@media (min-width:721px){ion-tab-button{flex:none;padding:0 24px;margin-right:24px;font-size:14px;flex-direction:row}ion-tab-button:last-child{margin-right:0}ion-tab-button .icon-container{margin-right:8px}}@media (min-width:1025px) and (hover:hover) and (pointer:fine){ion-tab-button{padding:0 12px;margin-right:0}}"]
8838
8879
  },] }
8839
8880
  ];
8840
8881
  /** @nocollapse */