@wizishop/angular-components 14.3.3 → 14.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.
- package/esm2020/lib/components/button/button.component.mjs +20 -5
- package/esm2020/lib/components/selects/select-test/select.component.mjs +1 -2
- package/esm2020/lib/components/selects/select-test/value-change.service.mjs +20 -15
- package/fesm2015/wizishop-angular-components.mjs +39 -20
- package/fesm2015/wizishop-angular-components.mjs.map +1 -1
- package/fesm2020/wizishop-angular-components.mjs +37 -20
- package/fesm2020/wizishop-angular-components.mjs.map +1 -1
- package/lib/components/button/button.component.d.ts +5 -2
- package/lib/components/selects/select-test/value-change.service.d.ts +3 -0
- package/package.json +1 -1
- package/wizishop-angular-components-14.3.4.tgz +0 -0
- package/wizishop-angular-components-14.3.3.tgz +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as i1$2 from '@wizishop/ng-wizi-bulma';
|
|
2
2
|
import { NwbAllModule, NwbFilterGroup } from '@wizishop/ng-wizi-bulma';
|
|
3
3
|
import * as i0 from '@angular/core';
|
|
4
|
-
import { Component, ViewEncapsulation, Input, EventEmitter, Directive, Output, HostListener, Injectable, InjectionToken, NgModule, Inject, Pipe, ContentChildren, ViewChild, ChangeDetectionStrategy, HostBinding, ContentChild } from '@angular/core';
|
|
4
|
+
import { Component, ViewEncapsulation, Input, EventEmitter, Directive, Output, HostListener, Injectable, InjectionToken, NgModule, Inject, Pipe, ContentChildren, Attribute, Optional, ViewChild, ChangeDetectionStrategy, HostBinding, ContentChild } from '@angular/core';
|
|
5
5
|
import * as i1 from '@angular/common';
|
|
6
6
|
import { CommonModule, DOCUMENT } from '@angular/common';
|
|
7
7
|
import * as i2 from '@angular/forms';
|
|
8
|
-
import { NG_VALUE_ACCESSOR, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
8
|
+
import { NG_VALUE_ACCESSOR, FormsModule, FormGroupDirective, ReactiveFormsModule } from '@angular/forms';
|
|
9
9
|
import * as i4$1 from 'ngx-perfect-scrollbar';
|
|
10
10
|
import { PerfectScrollbarModule } from 'ngx-perfect-scrollbar';
|
|
11
11
|
import { Subject, merge, fromEvent, ReplaySubject, interval, takeUntil as takeUntil$1, startWith as startWith$1, map as map$1 } from 'rxjs';
|
|
@@ -1098,7 +1098,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.7", ngImpor
|
|
|
1098
1098
|
}] } });
|
|
1099
1099
|
|
|
1100
1100
|
class ButtonComponent {
|
|
1101
|
-
constructor() {
|
|
1101
|
+
constructor(type, formGroup) {
|
|
1102
|
+
this.type = type;
|
|
1103
|
+
this.formGroup = formGroup;
|
|
1102
1104
|
// todo add button type (ex: for submit and check if it works with template driven forms)
|
|
1103
1105
|
this.extraClasses = 'is-info'; // todo make a list of existing class
|
|
1104
1106
|
this.label = '';
|
|
@@ -1172,6 +1174,9 @@ class ButtonComponent {
|
|
|
1172
1174
|
if (this.disabled) {
|
|
1173
1175
|
return;
|
|
1174
1176
|
}
|
|
1177
|
+
if (this.type === 'submit' && this.formGroup) { // Maybe there is a better way to handle submit
|
|
1178
|
+
this.formGroup.onSubmit(this.formGroup.value);
|
|
1179
|
+
}
|
|
1175
1180
|
if (this.hasLoader) {
|
|
1176
1181
|
this.isLoading = false;
|
|
1177
1182
|
setTimeout(() => {
|
|
@@ -1199,12 +1204,20 @@ class ButtonComponent {
|
|
|
1199
1204
|
}, 1000);
|
|
1200
1205
|
}
|
|
1201
1206
|
}
|
|
1202
|
-
ButtonComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.7", ngImport: i0, type: ButtonComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1207
|
+
ButtonComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.7", ngImport: i0, type: ButtonComponent, deps: [{ token: 'type', attribute: true }, { token: FormGroupDirective, optional: true }], target: i0.ɵɵFactoryTarget.Component });
|
|
1203
1208
|
ButtonComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.7", type: ButtonComponent, selector: "wac-button", inputs: { extraClasses: "extraClasses", label: "label", icon: "icon", iconNext: "iconNext", textcolor: "textcolor", widthAuto: "widthAuto", contentHorizontalPosition: "contentHorizontalPosition", iconFontSize: "iconFontSize", hasLoader: "hasLoader", disabled: "disabled", whiteSpaceNowrap: "whiteSpaceNowrap", opacity: "opacity", animation: "animation", animationRight: "animationRight", animationText: "animationText", confirmDelete: "confirmDelete", confirmDeleteText: "confirmDeleteText", coin: "coin", tooltip: "tooltip", tooltipWidth: "tooltipWidth", noPadding: "noPadding", tooltipPosition: "tooltipPosition", tooltipOneline: "tooltipOneline", confirmDeletePosition: "confirmDeletePosition", isLoading: "isLoading" }, outputs: { click: "click", isLoadingChange: "isLoadingChange" }, viewQueries: [{ propertyName: "calculWidth", first: true, predicate: ["calculWidth"], descendants: true }, { propertyName: "calculWidthDelete", first: true, predicate: ["calculWidthDelete"], descendants: true }], ngImport: i0, template: "<a\n [class]=\"'wac-button ' + extraClasses\"\n (click)=\"confirmDelete && waitForConfirmDelete ? addMaxWidthDelete() : '';onButtonClick($event);\"\n (mouseleave)=\"animation ? resetMaxWidth() : '';\"\n (mouseenter)=\"animation ? addMaxWidth() : '';\"\n wzAutoHide (clickOutside)=\"confirmDelete && !waitForConfirmDelete ? resetMaxWidthDelete() : ''\"\n [ngClass]=\"[\n label === '' ? 'alone' : '',\n coin ? 'has-coin width-auto' : '',\n animationRight ? 'animation-right' : '',\n animation ? 'animationText' : '',\n isLoading ? 'is-loading' : '',\n opacity ? 'opacity' : '',\n disabled ? 'disabled' : '',\n widthAuto ? 'width-auto' : '',\n noPadding ? 'no-padding' : '',\n whiteSpaceNowrap ? 'white-space-no-wrap' : '',\n !waitForConfirmDelete && confirmDelete ? 'step-delete' : '',\n confirmDelete ? 'deletePosition-' + confirmDeletePosition : ''\n ]\"\n [ngStyle]=\"{\n 'text-align': contentHorizontalPosition\n }\"\n>\n <span class=\"wac-button__wrapper\" [style.color]=\"textcolor ? textcolor : ''\">\n <i *ngIf=\"icon\" [ngClass]=\"icon\" [style.font-size.px]=\"iconFontSize\"></i>\n {{ label }}\n <i *ngIf=\"iconNext\" [ngClass]=\"iconNext\" [style.font-size.px]=\"iconFontSize\"></i>\n </span>\n <span class=\"wac-button__animation\" [style.maxWidth]=\"buttonMaxWidth\" [style.width]=\"buttonWidth + 'px'\">\n <span #calculWidth class=\"wac-button__animation__text\" [innerHTML]=\"animationText\"></span>\n </span>\n <span class=\"wac-button__confirmDelete\" [style.maxWidth]=\"buttonMaxWidthDelete\" [style.width]=\"buttonWidthDelete + 'px'\">\n <span #calculWidthDelete class=\"wac-button__confirmDelete__text\" [innerHTML]=\"confirmDeleteText\"></span>\n </span>\n <span *ngIf=\"coin\" class=\"wac-button__coin\"><i class=\"fa-solid fa-coin-front\"></i><span [innerHTML]=\"coin\"></span></span>\n <span\n class=\"wac-button__loader\"\n [ngClass]=\"extraClasses.includes('is-outlined') ? 'outlined' : ''\"\n *ngIf=\"isLoading\"\n [style.width]=\"currentLoading + '%'\"\n >\n <span *ngIf=\"extraClasses.includes('is-outlined')\">\n <i *ngIf=\"icon !== ''\" [ngClass]=\"icon\" [style.font-size.px]=\"iconFontSize\"></i>\n {{ label }}\n <i *ngIf=\"iconNext !== ''\" [ngClass]=\"iconNext\" [style.font-size.px]=\"iconFontSize\"></i>\n </span>\n </span>\n <span class=\"wac-button__tooltips {{ tooltipPosition }}\" [ngClass]=\"{'oneline': tooltipOneline}\" [style.minWidth]=\"tooltipWidth\" *ngIf=\"tooltip\">\n {{ tooltip }}\n </span>\n</a>\n", dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "directive", type: AutoHideDirective, selector: "[wzAutoHide]", inputs: ["triggerElement", "forceOn"], outputs: ["clickOutside"] }] });
|
|
1204
1209
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.7", ngImport: i0, type: ButtonComponent, decorators: [{
|
|
1205
1210
|
type: Component,
|
|
1206
1211
|
args: [{ selector: 'wac-button', template: "<a\n [class]=\"'wac-button ' + extraClasses\"\n (click)=\"confirmDelete && waitForConfirmDelete ? addMaxWidthDelete() : '';onButtonClick($event);\"\n (mouseleave)=\"animation ? resetMaxWidth() : '';\"\n (mouseenter)=\"animation ? addMaxWidth() : '';\"\n wzAutoHide (clickOutside)=\"confirmDelete && !waitForConfirmDelete ? resetMaxWidthDelete() : ''\"\n [ngClass]=\"[\n label === '' ? 'alone' : '',\n coin ? 'has-coin width-auto' : '',\n animationRight ? 'animation-right' : '',\n animation ? 'animationText' : '',\n isLoading ? 'is-loading' : '',\n opacity ? 'opacity' : '',\n disabled ? 'disabled' : '',\n widthAuto ? 'width-auto' : '',\n noPadding ? 'no-padding' : '',\n whiteSpaceNowrap ? 'white-space-no-wrap' : '',\n !waitForConfirmDelete && confirmDelete ? 'step-delete' : '',\n confirmDelete ? 'deletePosition-' + confirmDeletePosition : ''\n ]\"\n [ngStyle]=\"{\n 'text-align': contentHorizontalPosition\n }\"\n>\n <span class=\"wac-button__wrapper\" [style.color]=\"textcolor ? textcolor : ''\">\n <i *ngIf=\"icon\" [ngClass]=\"icon\" [style.font-size.px]=\"iconFontSize\"></i>\n {{ label }}\n <i *ngIf=\"iconNext\" [ngClass]=\"iconNext\" [style.font-size.px]=\"iconFontSize\"></i>\n </span>\n <span class=\"wac-button__animation\" [style.maxWidth]=\"buttonMaxWidth\" [style.width]=\"buttonWidth + 'px'\">\n <span #calculWidth class=\"wac-button__animation__text\" [innerHTML]=\"animationText\"></span>\n </span>\n <span class=\"wac-button__confirmDelete\" [style.maxWidth]=\"buttonMaxWidthDelete\" [style.width]=\"buttonWidthDelete + 'px'\">\n <span #calculWidthDelete class=\"wac-button__confirmDelete__text\" [innerHTML]=\"confirmDeleteText\"></span>\n </span>\n <span *ngIf=\"coin\" class=\"wac-button__coin\"><i class=\"fa-solid fa-coin-front\"></i><span [innerHTML]=\"coin\"></span></span>\n <span\n class=\"wac-button__loader\"\n [ngClass]=\"extraClasses.includes('is-outlined') ? 'outlined' : ''\"\n *ngIf=\"isLoading\"\n [style.width]=\"currentLoading + '%'\"\n >\n <span *ngIf=\"extraClasses.includes('is-outlined')\">\n <i *ngIf=\"icon !== ''\" [ngClass]=\"icon\" [style.font-size.px]=\"iconFontSize\"></i>\n {{ label }}\n <i *ngIf=\"iconNext !== ''\" [ngClass]=\"iconNext\" [style.font-size.px]=\"iconFontSize\"></i>\n </span>\n </span>\n <span class=\"wac-button__tooltips {{ tooltipPosition }}\" [ngClass]=\"{'oneline': tooltipOneline}\" [style.minWidth]=\"tooltipWidth\" *ngIf=\"tooltip\">\n {{ tooltip }}\n </span>\n</a>\n" }]
|
|
1207
|
-
}], ctorParameters: function () { return [
|
|
1212
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1213
|
+
type: Attribute,
|
|
1214
|
+
args: ['type']
|
|
1215
|
+
}] }, { type: i2.FormGroupDirective, decorators: [{
|
|
1216
|
+
type: Optional
|
|
1217
|
+
}, {
|
|
1218
|
+
type: Inject,
|
|
1219
|
+
args: [FormGroupDirective]
|
|
1220
|
+
}] }]; }, propDecorators: { extraClasses: [{
|
|
1208
1221
|
type: Input
|
|
1209
1222
|
}], label: [{
|
|
1210
1223
|
type: Input
|
|
@@ -4227,6 +4240,22 @@ class ValueChangeService {
|
|
|
4227
4240
|
this.valueChange$ = new Subject();
|
|
4228
4241
|
this.indexSelectedOption = null;
|
|
4229
4242
|
this.resetListeners$ = new Subject();
|
|
4243
|
+
this.indexOfMatchedOption = (option, index, letter) => {
|
|
4244
|
+
const textOption = option.getContentRef().nativeElement.textContent.trim().toLowerCase();
|
|
4245
|
+
return textOption.startsWith(letter) ? index : null;
|
|
4246
|
+
};
|
|
4247
|
+
this.isNotNull = (index) => {
|
|
4248
|
+
return index !== null;
|
|
4249
|
+
};
|
|
4250
|
+
this.highestAndClosestIndex = (index) => {
|
|
4251
|
+
if (isNaN(this.indexSelectedOption)) {
|
|
4252
|
+
return true;
|
|
4253
|
+
}
|
|
4254
|
+
if (index > this.indexSelectedOption) {
|
|
4255
|
+
return true;
|
|
4256
|
+
}
|
|
4257
|
+
return false;
|
|
4258
|
+
};
|
|
4230
4259
|
}
|
|
4231
4260
|
set value(value) {
|
|
4232
4261
|
this._value = value;
|
|
@@ -4276,26 +4305,15 @@ class ValueChangeService {
|
|
|
4276
4305
|
}
|
|
4277
4306
|
searchOptionByFirstLetter(letter) {
|
|
4278
4307
|
const matchedOptionsIndex = this.optionChildren
|
|
4279
|
-
.map((option, index) =>
|
|
4280
|
-
|
|
4281
|
-
return textOption.startsWith(letter) ? index : null;
|
|
4282
|
-
})
|
|
4283
|
-
.filter((index) => index !== null);
|
|
4308
|
+
.map((option, index) => this.indexOfMatchedOption(option, index, letter))
|
|
4309
|
+
.filter(this.isNotNull);
|
|
4284
4310
|
if (!matchedOptionsIndex.length) { // reset the selection
|
|
4285
4311
|
this.indexSelectedOption = null;
|
|
4286
4312
|
this.assignValue(null);
|
|
4287
4313
|
return;
|
|
4288
4314
|
}
|
|
4289
4315
|
// find the next option after the current selected option, or the first option
|
|
4290
|
-
const validOptionIndex = matchedOptionsIndex.find(
|
|
4291
|
-
if (isNaN(this.indexSelectedOption)) {
|
|
4292
|
-
return true;
|
|
4293
|
-
}
|
|
4294
|
-
if (index > this.indexSelectedOption) {
|
|
4295
|
-
return true;
|
|
4296
|
-
}
|
|
4297
|
-
return false;
|
|
4298
|
-
});
|
|
4316
|
+
const validOptionIndex = matchedOptionsIndex.find(this.highestAndClosestIndex);
|
|
4299
4317
|
this.indexSelectedOption = isNaN(validOptionIndex) ? matchedOptionsIndex[0] : validOptionIndex;
|
|
4300
4318
|
this.assignValue(this.optionChildren.get(this.indexSelectedOption).value);
|
|
4301
4319
|
}
|
|
@@ -4528,7 +4546,6 @@ class SelectTestComponent {
|
|
|
4528
4546
|
}
|
|
4529
4547
|
/** Handles keyboard events when the selected is open. */
|
|
4530
4548
|
_handleOpenKeydown(event) {
|
|
4531
|
-
console.log('event', event);
|
|
4532
4549
|
const keyCode = event.keyCode;
|
|
4533
4550
|
const isArrowKey = keyCode === DOWN_ARROW ||
|
|
4534
4551
|
keyCode === UP_ARROW ||
|