@seniorsistemas/angular-components 17.16.14 → 17.17.0

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 (37) hide show
  1. package/bundles/seniorsistemas-angular-components.umd.js +359 -0
  2. package/bundles/seniorsistemas-angular-components.umd.js.map +1 -1
  3. package/bundles/seniorsistemas-angular-components.umd.min.js +2 -2
  4. package/bundles/seniorsistemas-angular-components.umd.min.js.map +1 -1
  5. package/components/chips/chip-item/chip-item.component.d.ts +22 -0
  6. package/components/chips/chips/chips.component.d.ts +55 -0
  7. package/components/chips/chips.module.d.ts +2 -0
  8. package/components/chips/index.d.ts +3 -0
  9. package/components/chips/models/chip-models.d.ts +7 -0
  10. package/components/index.d.ts +1 -0
  11. package/components/shared/helpers.d.ts +18 -0
  12. package/components/shared/index.d.ts +1 -0
  13. package/esm2015/components/chips/chip-item/chip-item.component.js +68 -0
  14. package/esm2015/components/chips/chips/chips.component.js +228 -0
  15. package/esm2015/components/chips/chips.module.js +24 -0
  16. package/esm2015/components/chips/index.js +3 -0
  17. package/esm2015/components/chips/models/chip-models.js +1 -0
  18. package/esm2015/components/index.js +2 -1
  19. package/esm2015/components/shared/helpers.js +30 -0
  20. package/esm2015/components/shared/index.js +2 -1
  21. package/esm2015/seniorsistemas-angular-components.js +2 -1
  22. package/esm5/components/chips/chip-item/chip-item.component.js +77 -0
  23. package/esm5/components/chips/chips/chips.component.js +235 -0
  24. package/esm5/components/chips/chips.module.js +27 -0
  25. package/esm5/components/chips/index.js +3 -0
  26. package/esm5/components/chips/models/chip-models.js +1 -0
  27. package/esm5/components/index.js +2 -1
  28. package/esm5/components/shared/helpers.js +35 -0
  29. package/esm5/components/shared/index.js +2 -1
  30. package/esm5/seniorsistemas-angular-components.js +2 -1
  31. package/fesm2015/seniorsistemas-angular-components.js +334 -3
  32. package/fesm2015/seniorsistemas-angular-components.js.map +1 -1
  33. package/fesm5/seniorsistemas-angular-components.js +358 -3
  34. package/fesm5/seniorsistemas-angular-components.js.map +1 -1
  35. package/package.json +1 -1
  36. package/seniorsistemas-angular-components.d.ts +1 -0
  37. package/seniorsistemas-angular-components.metadata.json +1 -1
@@ -18338,6 +18338,41 @@
18338
18338
  return SelectButtonModule;
18339
18339
  }());
18340
18340
 
18341
+ /**
18342
+ * A decorator that can be used to disable functions based on a boolean property on the component.
18343
+ *
18344
+ * @param disabledField The name of the boolean property that will be used to determine if the decorated
18345
+ * function should be disabled. Defaults to 'disabled'.
18346
+ * @returns A decorator function that can be used to decorate a function.
18347
+ *
18348
+ * @example
18349
+ * class MyComponent {
18350
+ * disabled = true;
18351
+ *
18352
+ * @CheckDisabled()
18353
+ * onClick() {
18354
+ * console.log('Button was clicked');
18355
+ * }
18356
+ * }
18357
+ */
18358
+ function CheckDisabled(disabledField) {
18359
+ if (disabledField === void 0) { disabledField = 'disabled'; }
18360
+ return function (_target, _propertyKey, descriptor) {
18361
+ var originalMethod = descriptor.value;
18362
+ descriptor.value = function () {
18363
+ var args = [];
18364
+ for (var _i = 0; _i < arguments.length; _i++) {
18365
+ args[_i] = arguments[_i];
18366
+ }
18367
+ if (this[disabledField]) {
18368
+ return;
18369
+ }
18370
+ return originalMethod.apply(this, args);
18371
+ };
18372
+ return descriptor;
18373
+ };
18374
+ }
18375
+
18341
18376
  var SidebarComponent = /** @class */ (function () {
18342
18377
  function SidebarComponent(focusTrapFactory) {
18343
18378
  this.focusTrapFactory = focusTrapFactory;
@@ -20642,6 +20677,326 @@
20642
20677
  return PicklistModule;
20643
20678
  }());
20644
20679
 
20680
+ var ChipsComponent = /** @class */ (function () {
20681
+ function ChipsComponent(cdr) {
20682
+ this.cdr = cdr;
20683
+ this.newItem = '';
20684
+ this.value = [];
20685
+ this.placeholder = '';
20686
+ this.inputId = "chips-" + ChipsComponent_1._id++;
20687
+ this.allowDuplicated = true;
20688
+ this.caseSensitiveDuplication = false;
20689
+ this.addOnTab = true;
20690
+ this.addOnBlur = true;
20691
+ this.autofocus = false;
20692
+ this.infoLabel = '';
20693
+ this.showTooltip = true;
20694
+ this.maxLengthRenderWithoutTooltip = 20;
20695
+ this.onAdd = new core.EventEmitter();
20696
+ this.onRemove = new core.EventEmitter();
20697
+ this.onFocus = new core.EventEmitter();
20698
+ this.onBlur = new core.EventEmitter();
20699
+ this.onChipClick = new core.EventEmitter();
20700
+ this.valueChange = new core.EventEmitter();
20701
+ this.isTabEventActive = false;
20702
+ this.onChange = function () { };
20703
+ this.onTouched = function () { };
20704
+ }
20705
+ ChipsComponent_1 = ChipsComponent;
20706
+ ChipsComponent.prototype.ngAfterViewInit = function () {
20707
+ var _a;
20708
+ if (this.autofocus && this.input) {
20709
+ this.input.nativeElement.focus();
20710
+ }
20711
+ this.chipTemplate = (_a = this.templates.find(function (x) { return x.type === 'chip-container'; })) === null || _a === void 0 ? void 0 : _a.template;
20712
+ this.cdr.detectChanges();
20713
+ };
20714
+ ChipsComponent.prototype.writeValue = function (obj) {
20715
+ this.value = obj;
20716
+ };
20717
+ ChipsComponent.prototype.registerOnChange = function (fn) {
20718
+ this.onChange = fn;
20719
+ };
20720
+ ChipsComponent.prototype.registerOnTouched = function (fn) {
20721
+ this.onTouched = fn;
20722
+ };
20723
+ ChipsComponent.prototype.setDisabledState = function (isDisabled) {
20724
+ this.disabled = isDisabled;
20725
+ };
20726
+ ChipsComponent.prototype.onKeydown = function ($event) {
20727
+ var _this = this;
20728
+ var isEnter = $event.key === 'Enter';
20729
+ var isSeparator = this.separator && $event.key === this.separator;
20730
+ var eventKeyIsTab = $event.key === 'Tab';
20731
+ if (eventKeyIsTab) {
20732
+ this.isTabEventActive = true;
20733
+ setTimeout(function () {
20734
+ _this.isTabEventActive = false;
20735
+ }, 50);
20736
+ }
20737
+ var isTab = this.addOnTab && eventKeyIsTab;
20738
+ if (isEnter || isSeparator || isTab) {
20739
+ $event.preventDefault();
20740
+ this.addItem();
20741
+ }
20742
+ };
20743
+ ChipsComponent.prototype.onInputFocus = function ($event) {
20744
+ this.onFocus.emit($event);
20745
+ };
20746
+ ChipsComponent.prototype.onInputLostFocus = function ($event) {
20747
+ if (!this.addOnBlur || this.isTabEventActive) {
20748
+ return;
20749
+ }
20750
+ this.addItem();
20751
+ this.onBlur.emit($event);
20752
+ };
20753
+ ChipsComponent.prototype.removeItem = function (_a) {
20754
+ var itemIndex = _a.itemIndex, event = _a.event;
20755
+ var _removedItem = this.value[itemIndex];
20756
+ this.value.splice(itemIndex, 1);
20757
+ this.onRemove.emit({ value: _removedItem, originalEvent: event });
20758
+ };
20759
+ ChipsComponent.prototype.chipClicked = function (_a) {
20760
+ var event = _a.event, data = _a.data;
20761
+ this.onChipClick.emit({ value: data, originalEvent: event });
20762
+ };
20763
+ ChipsComponent.prototype.addItem = function () {
20764
+ var _a;
20765
+ var _this = this;
20766
+ var hasValue = !!this.newItem;
20767
+ if (!hasValue) {
20768
+ return;
20769
+ }
20770
+ if (this.max && this.value.length === this.max) {
20771
+ return;
20772
+ }
20773
+ var validItemLength = this.maxLength ? this.newItem.length <= this.maxLength : true;
20774
+ if (!validItemLength) {
20775
+ return;
20776
+ }
20777
+ var hasField = !!this.field;
20778
+ var _mappedValues = this.field ? this.value.map(function (x) { return x[_this.field]; }) : this.value;
20779
+ var valueToAdd = hasField ? (_a = {}, _a[this.field] = this.newItem, _a) : this.newItem;
20780
+ var duplicatedItem = _mappedValues.find(function (x) {
20781
+ if (_this.caseSensitiveDuplication) {
20782
+ return x === _this.newItem;
20783
+ }
20784
+ else {
20785
+ return x.toLowerCase() === _this.newItem.toLowerCase();
20786
+ }
20787
+ });
20788
+ var hasDuplicatedItem = false;
20789
+ if (!this.allowDuplicated) {
20790
+ hasDuplicatedItem = duplicatedItem ? Boolean(duplicatedItem) : false;
20791
+ }
20792
+ if (!hasDuplicatedItem) {
20793
+ this.storeValue(valueToAdd);
20794
+ }
20795
+ this.newItem = '';
20796
+ };
20797
+ ChipsComponent.prototype.storeValue = function (value) {
20798
+ this.value = __spread(this.value, [value]);
20799
+ this.onAdd.emit({ value: value });
20800
+ this.valueChange.emit(this.value);
20801
+ this.writeValue(this.value);
20802
+ this.onChange(this.value);
20803
+ this.onTouched(this.value);
20804
+ };
20805
+ var ChipsComponent_1;
20806
+ ChipsComponent._id = 0;
20807
+ ChipsComponent.ctorParameters = function () { return [
20808
+ { type: core.ChangeDetectorRef }
20809
+ ]; };
20810
+ __decorate([
20811
+ core.Input()
20812
+ ], ChipsComponent.prototype, "disabled", void 0);
20813
+ __decorate([
20814
+ core.Input()
20815
+ ], ChipsComponent.prototype, "field", void 0);
20816
+ __decorate([
20817
+ core.Input()
20818
+ ], ChipsComponent.prototype, "value", void 0);
20819
+ __decorate([
20820
+ core.Input()
20821
+ ], ChipsComponent.prototype, "placeholder", void 0);
20822
+ __decorate([
20823
+ core.Input()
20824
+ ], ChipsComponent.prototype, "max", void 0);
20825
+ __decorate([
20826
+ core.Input()
20827
+ ], ChipsComponent.prototype, "maxLength", void 0);
20828
+ __decorate([
20829
+ core.Input()
20830
+ ], ChipsComponent.prototype, "inputId", void 0);
20831
+ __decorate([
20832
+ core.Input()
20833
+ ], ChipsComponent.prototype, "allowDuplicated", void 0);
20834
+ __decorate([
20835
+ core.Input()
20836
+ ], ChipsComponent.prototype, "caseSensitiveDuplication", void 0);
20837
+ __decorate([
20838
+ core.Input()
20839
+ ], ChipsComponent.prototype, "addOnTab", void 0);
20840
+ __decorate([
20841
+ core.Input()
20842
+ ], ChipsComponent.prototype, "addOnBlur", void 0);
20843
+ __decorate([
20844
+ core.Input()
20845
+ ], ChipsComponent.prototype, "separator", void 0);
20846
+ __decorate([
20847
+ core.Input()
20848
+ ], ChipsComponent.prototype, "autofocus", void 0);
20849
+ __decorate([
20850
+ core.Input()
20851
+ ], ChipsComponent.prototype, "infoLabel", void 0);
20852
+ __decorate([
20853
+ core.Input()
20854
+ ], ChipsComponent.prototype, "keyFilter", void 0);
20855
+ __decorate([
20856
+ core.Input()
20857
+ ], ChipsComponent.prototype, "showTooltip", void 0);
20858
+ __decorate([
20859
+ core.Input()
20860
+ ], ChipsComponent.prototype, "maxLengthRenderWithoutTooltip", void 0);
20861
+ __decorate([
20862
+ core.Output()
20863
+ ], ChipsComponent.prototype, "onAdd", void 0);
20864
+ __decorate([
20865
+ core.Output()
20866
+ ], ChipsComponent.prototype, "onRemove", void 0);
20867
+ __decorate([
20868
+ core.Output()
20869
+ ], ChipsComponent.prototype, "onFocus", void 0);
20870
+ __decorate([
20871
+ core.Output()
20872
+ ], ChipsComponent.prototype, "onBlur", void 0);
20873
+ __decorate([
20874
+ core.Output()
20875
+ ], ChipsComponent.prototype, "onChipClick", void 0);
20876
+ __decorate([
20877
+ core.Output()
20878
+ ], ChipsComponent.prototype, "valueChange", void 0);
20879
+ __decorate([
20880
+ core.ContentChildren(TemplateDirective)
20881
+ ], ChipsComponent.prototype, "templates", void 0);
20882
+ __decorate([
20883
+ core.ViewChild('input', { read: core.ElementRef })
20884
+ ], ChipsComponent.prototype, "input", void 0);
20885
+ __decorate([
20886
+ core.HostListener("document:keydown", ["$event"]),
20887
+ CheckDisabled()
20888
+ ], ChipsComponent.prototype, "onKeydown", null);
20889
+ __decorate([
20890
+ CheckDisabled()
20891
+ ], ChipsComponent.prototype, "onInputLostFocus", null);
20892
+ ChipsComponent = ChipsComponent_1 = __decorate([
20893
+ core.Component({
20894
+ selector: 's-chips',
20895
+ template: "<ul class=\"chips-container\">\n <li *ngFor=\"let item of value; let index = index\">\n <s-chip-item\n [templateRef]=\"chipTemplate\"\n [dataRender]=\"item\"\n [objectField]=\"field\"\n [itemIndex]=\"index\"\n [disabled]=\"disabled\"\n [showTooltip]=\"showTooltip\"\n [maxLengthRenderWithoutTooltip]=\"maxLengthRenderWithoutTooltip\"\n (clickRemove)=\"removeItem($event)\"\n (chipClicked)=\"chipClicked($event)\">\n </s-chip-item>\n </li>\n <ng-container *ngIf=\"keyFilter\">\n <input\n #input\n [disabled]=\"disabled || max === value?.length\"\n [placeholder]=\"placeholder\"\n [maxlength]=\"maxLength\"\n [id]=\"inputId\"\n [(ngModel)]=\"newItem\"\n [pKeyFilter]=\"keyFilter\"\n (focus)=\"onInputFocus($event)\"\n (blur)=\"onInputLostFocus($event)\">\n </ng-container>\n <ng-container *ngIf=\"!keyFilter\">\n <input\n #input\n [disabled]=\"disabled || max === value?.length\"\n [placeholder]=\"placeholder\"\n [maxlength]=\"maxLength\"\n [id]=\"inputId\"\n [(ngModel)]=\"newItem\"\n (focus)=\"onInputFocus($event)\"\n (blur)=\"onInputLostFocus($event)\">\n </ng-container>\n</ul>\n<ng-container *ngIf=\"infoLabel\">\n <span class=\"info-label\">\n {{ infoLabel }}\n </span>\n</ng-container>\n",
20896
+ providers: [
20897
+ {
20898
+ provide: forms.NG_VALUE_ACCESSOR,
20899
+ useExisting: core.forwardRef(function () { return ChipsComponent_1; }),
20900
+ multi: true
20901
+ }
20902
+ ],
20903
+ styles: [".chips-container{width:100%;padding:8px;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;-ms-flex-align:center;align-items:center;border-radius:3px;border:1px solid #c1c1cc;background-color:#fff;list-style:none;gap:8px}.chips-container input{background-color:#fff;width:100%;border:none;min-height:2em;min-width:15%;-ms-flex:1;flex:1}.chips-container input:focus-visible{outline:0}.info-label{color:#888b99;font-size:12px;font-style:normal;font-weight:400}"]
20904
+ })
20905
+ ], ChipsComponent);
20906
+ return ChipsComponent;
20907
+ }());
20908
+
20909
+ var ChipItemComponent = /** @class */ (function () {
20910
+ function ChipItemComponent() {
20911
+ this.disabled = false;
20912
+ this.itemIndex = -1;
20913
+ this.showTooltip = true;
20914
+ this.maxLengthRenderWithoutTooltip = 20;
20915
+ this.clickRemove = new core.EventEmitter();
20916
+ this.chipClicked = new core.EventEmitter();
20917
+ }
20918
+ ChipItemComponent.prototype.clickedRemove = function ($event) {
20919
+ this.clickRemove.emit({ index: this.itemIndex, event: $event });
20920
+ };
20921
+ ChipItemComponent.prototype.onChipClicked = function ($event) {
20922
+ this.chipClicked.emit({ event: $event, data: this.dataRender });
20923
+ };
20924
+ Object.defineProperty(ChipItemComponent.prototype, "_text", {
20925
+ get: function () {
20926
+ var _text = this._rawText;
20927
+ return _text.substring(0, _text.length > this.maxLengthRenderWithoutTooltip ? this.maxLengthRenderWithoutTooltip : _text.length) + (_text.length > this.maxLengthRenderWithoutTooltip ? '...' : '');
20928
+ },
20929
+ enumerable: true,
20930
+ configurable: true
20931
+ });
20932
+ Object.defineProperty(ChipItemComponent.prototype, "_rawText", {
20933
+ get: function () {
20934
+ return this.objectField ? this.dataRender[this.objectField] || '' : this.dataRender || '';
20935
+ },
20936
+ enumerable: true,
20937
+ configurable: true
20938
+ });
20939
+ __decorate([
20940
+ core.Input()
20941
+ ], ChipItemComponent.prototype, "dataRender", void 0);
20942
+ __decorate([
20943
+ core.Input()
20944
+ ], ChipItemComponent.prototype, "objectField", void 0);
20945
+ __decorate([
20946
+ core.Input()
20947
+ ], ChipItemComponent.prototype, "disabled", void 0);
20948
+ __decorate([
20949
+ core.Input()
20950
+ ], ChipItemComponent.prototype, "templateRef", void 0);
20951
+ __decorate([
20952
+ core.Input()
20953
+ ], ChipItemComponent.prototype, "itemIndex", void 0);
20954
+ __decorate([
20955
+ core.Input()
20956
+ ], ChipItemComponent.prototype, "showTooltip", void 0);
20957
+ __decorate([
20958
+ core.Input()
20959
+ ], ChipItemComponent.prototype, "maxLengthRenderWithoutTooltip", void 0);
20960
+ __decorate([
20961
+ core.Output()
20962
+ ], ChipItemComponent.prototype, "clickRemove", void 0);
20963
+ __decorate([
20964
+ core.Output()
20965
+ ], ChipItemComponent.prototype, "chipClicked", void 0);
20966
+ __decorate([
20967
+ CheckDisabled()
20968
+ ], ChipItemComponent.prototype, "clickedRemove", null);
20969
+ __decorate([
20970
+ CheckDisabled()
20971
+ ], ChipItemComponent.prototype, "onChipClicked", null);
20972
+ ChipItemComponent = __decorate([
20973
+ core.Component({
20974
+ selector: 's-chip-item',
20975
+ template: "<ng-template #itemRender>\n <div\n class=\"chip-item\"\n [class.chip-item-disabled]=\"disabled\"\n (click)=\"onChipClicked($event)\"\n [sTooltip]=\"_rawText\"\n [showDelay]=\"0\"\n [visible]=\"showTooltip ? _rawText.length > maxLengthRenderWithoutTooltip : false\">\n <ng-container *ngIf=\"templateRef\">\n <ng-container *ngTemplateOutlet=\"templateRef; context: { $implicit: dataRender, text: _text }\"></ng-container>\n </ng-container>\n <ng-container *ngIf=\"!templateRef\">\n {{ _text }}\n </ng-container>\n <i class=\"fas fa-times\" (click)=\"clickedRemove($event)\"></i>\n </div>\n</ng-template>\n\n\n<ng-container *ngIf=\"objectField && !templateRef\">\n <ng-container *ngTemplateOutlet=\"itemRender;\"></ng-container>\n</ng-container>\n\n<ng-container *ngIf=\"!objectField && !templateRef\">\n <ng-container *ngTemplateOutlet=\"itemRender;\"></ng-container>\n</ng-container>\n\n<ng-container *ngIf=\"templateRef\">\n <ng-container *ngTemplateOutlet=\"itemRender\"></ng-container>\n</ng-container>\n",
20976
+ styles: [".chip-item{border-radius:4px;border:1px solid #888b99;background-color:#eeebf2;word-break:break-word;font-size:12px;font-weight:400;text-align:center;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;gap:8px;padding:0 8px}.chip-item i{cursor:pointer}.chip-item:hover:not(.chip-item-disabled){background:#c1c1cc}.chip-item-disabled{opacity:.5}.chip-item-disabled i{cursor:default}"]
20977
+ })
20978
+ ], ChipItemComponent);
20979
+ return ChipItemComponent;
20980
+ }());
20981
+
20982
+ var ChipsModule = /** @class */ (function () {
20983
+ function ChipsModule() {
20984
+ }
20985
+ ChipsModule = __decorate([
20986
+ core.NgModule({
20987
+ declarations: [ChipsComponent, ChipItemComponent],
20988
+ imports: [
20989
+ common.CommonModule,
20990
+ forms.FormsModule,
20991
+ TooltipModule,
20992
+ keyfilter.KeyFilterModule
20993
+ ],
20994
+ exports: [ChipsComponent]
20995
+ })
20996
+ ], ChipsModule);
20997
+ return ChipsModule;
20998
+ }());
20999
+
20645
21000
  var fallback = {
20646
21001
  "platform.angular_components.drag_your_photo_or": "Arraste sua foto ou",
20647
21002
  "platform.angular_components.select_a_file": "selecione um arquivo",
@@ -20990,9 +21345,12 @@
20990
21345
  exports.CalendarMaskModule = CalendarMaskModule;
20991
21346
  exports.CardComponent = CardComponent;
20992
21347
  exports.CardModule = CardModule;
21348
+ exports.CheckDisabled = CheckDisabled;
20993
21349
  exports.CheckboxComponent = CheckboxComponent;
20994
21350
  exports.CheckboxModule = CheckboxModule;
21351
+ exports.ChipsComponent = ChipsComponent;
20995
21352
  exports.ChipsField = ChipsField;
21353
+ exports.ChipsModule = ChipsModule;
20996
21354
  exports.CodeEditorModule = CodeEditorModule;
20997
21355
  exports.CollapseLinkComponent = CollapseLinkComponent;
20998
21356
  exports.CollapseLinkModule = CollapseLinkModule;
@@ -21247,6 +21605,7 @@
21247
21605
  exports.ɵed = CollapsedItemsComponent;
21248
21606
  exports.ɵee = VerticalItemsComponent;
21249
21607
  exports.ɵef = ButtonModule;
21608
+ exports.ɵeg = ChipItemComponent;
21250
21609
  exports.ɵf = TieredMenuComponent;
21251
21610
  exports.ɵg = TieredMenuNestedComponent;
21252
21611
  exports.ɵh = TieredMenuItemComponent;