@coolon/angular-ui-powerups 14.38.2 → 14.38.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/forms/select-input/select-input.component.mjs +38 -10
- package/fesm2015/coolon-angular-ui-powerups.mjs +37 -9
- package/fesm2015/coolon-angular-ui-powerups.mjs.map +1 -1
- package/fesm2020/coolon-angular-ui-powerups.mjs +37 -9
- package/fesm2020/coolon-angular-ui-powerups.mjs.map +1 -1
- package/lib/components/forms/select-input/select-input.component.d.ts +3 -1
- package/package.json +1 -1
|
@@ -2156,30 +2156,58 @@ class SelectInputComponent extends AbstractValueInputComponent {
|
|
|
2156
2156
|
this._options$ = new DelegatingListModel();
|
|
2157
2157
|
this.optionLabelFormat = (option) => (option && this.optionLabel) ? option[this.optionLabel] : option;
|
|
2158
2158
|
this.id$ = new MutableValueModel();
|
|
2159
|
+
const { chain } = Dsl.disposeWith(this);
|
|
2160
|
+
this.cookedOptions$ = chain(this.options$).reduceToList(options => {
|
|
2161
|
+
return options.length < 1 && !isNil(this.componentValue$.value) ? [this.componentValue$.value] : options;
|
|
2162
|
+
}, { dependsOn: this.componentValue$ })
|
|
2163
|
+
.identifiedWith(this.options$.identityOf);
|
|
2164
|
+
this.cookedOptions$ = chain(this.options$)
|
|
2165
|
+
.otherwise(chain(this.componentValue$).mapToList(v => [v]))
|
|
2166
|
+
.identifiedWith(this.options$.identityOf);
|
|
2159
2167
|
}
|
|
2160
2168
|
select(item) {
|
|
2161
2169
|
this.id$.value = this.options$.identityOf(item);
|
|
2162
2170
|
}
|
|
2163
2171
|
ngOnInit() {
|
|
2164
2172
|
// NOTE: this has to be done after our parameter have been bound or we'll clobber the initial selected values with the writeRight
|
|
2165
|
-
const { chain, when } = Dsl.disposeWith(this);
|
|
2166
|
-
// TODO: I wouldn't have to do this if selectionModel.leadSelection$ was mutable...
|
|
2173
|
+
const { chain, before, when } = Dsl.disposeWith(this);
|
|
2167
2174
|
const lookup = chain(this.options$).indexUsing(this.options$.identityOf);
|
|
2168
2175
|
const self = this;
|
|
2169
|
-
this.registerDisposable(new Binding(this.componentValue$, this.id$, {
|
|
2170
|
-
toLeft(
|
|
2171
|
-
const newValue = lookup.get(
|
|
2176
|
+
const binding = this.registerDisposable(new Binding(this.componentValue$, this.id$, {
|
|
2177
|
+
toLeft(selectedId, currentValue) {
|
|
2178
|
+
const newValue = lookup.get(selectedId); // the list is empty or we're missing form it so don't touch the real value.
|
|
2172
2179
|
return isNil(newValue) ? currentValue : newValue;
|
|
2173
2180
|
},
|
|
2174
2181
|
leftDependsOn: lookup,
|
|
2175
|
-
toRight(
|
|
2176
|
-
return self.options$.identityOf(
|
|
2182
|
+
toRight(selectedValue, selectedId) {
|
|
2183
|
+
return self.options$.identityOf(selectedValue);
|
|
2177
2184
|
}
|
|
2178
2185
|
})).writeRight();
|
|
2186
|
+
// TODO: we have to do this as the options identity function can change from identity to somethign else after
|
|
2187
|
+
// we already have an initial value. In that case the stored id will be wrong.
|
|
2188
|
+
// Probably a reasonable solution for it be to track changes in the identity function and handle it
|
|
2189
|
+
// at a more fundamental level. This may include checking if the function has changed... but currently
|
|
2190
|
+
// the function change things under the hood.
|
|
2191
|
+
let lastIdSnapshot = this.snapshotValueAndId(this.componentValue$.value);
|
|
2192
|
+
before(this.options$).changes(() => {
|
|
2193
|
+
this.snapshotValueAndId(this.componentValue$.value);
|
|
2194
|
+
});
|
|
2195
|
+
when(this.options$).changes((is, was) => {
|
|
2196
|
+
const newIdSnapshot = this.snapshotValueAndId(lastIdSnapshot.value);
|
|
2197
|
+
if (newIdSnapshot !== lastIdSnapshot.id) {
|
|
2198
|
+
this.id$.value = this.options$.identityOf(this.componentValue$.value);
|
|
2199
|
+
}
|
|
2200
|
+
});
|
|
2201
|
+
}
|
|
2202
|
+
snapshotValueAndId(value) {
|
|
2203
|
+
return {
|
|
2204
|
+
value: value,
|
|
2205
|
+
id: this.options$.identityOf(value)
|
|
2206
|
+
};
|
|
2179
2207
|
}
|
|
2180
2208
|
}
|
|
2181
2209
|
SelectInputComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: SelectInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2182
|
-
SelectInputComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.12", type: SelectInputComponent, selector: "aup-select-input", inputs: { options$: "options$", optionsModel: "optionsModel", options: "options", optionLabel: "optionLabel", allowNil: "allowNil", optionLabelFormat: "optionLabelFormat" }, queries: [{ propertyName: "selectedOptionTemplateRef", first: true, predicate: ["selectedOptionTemplate"], descendants: true }, { propertyName: "optionTemplateRef", first: true, predicate: ["optionTemplate"], descendants: true }, { propertyName: "nilOptionTemplateRef", first: true, predicate: ["nilOptionTemplate"], descendants: true }], usesInheritance: true, ngImport: i0, template: "<mat-form-field appearance=\"standard\" [floatLabel]=\"floatLabel\">\n <mat-label *ngIf=\"label\">{{label}}</mat-label>\n <mat-select placeholder=\"{{placeholder}}\"\n [ngModel]=\"componentValue$.value\"\n (ngModelChange)=\"select($event)\"\n [disabled]=\"!enabled$.value\"\n (keydown.enter)=\"notifyEnterKey()\"\n (keydown.escape)=\"notifyEscapeKey()\"\n [pectinFocusBinding]=\"focusContext\"\n [errorStateMatcher]=\"errorStateMatcher\"\n >\n <mat-select-trigger *ngIf=\"selectedOptionTemplateRef\">\n <ng-container [ngTemplateOutlet]=\"selectedOptionTemplateRef\" [ngTemplateOutletContext]=\"{ $implicit: componentValue$.value}\"></ng-container>\n </mat-select-trigger>\n\n <mat-option *ngIf=\"allowNil\">\n <ng-container *ngIf=\"!nilOptionTemplateRef\">{{placeholder}}</ng-container>\n <ng-container *ngIf=\"nilOptionTemplateRef\" [ngTemplateOutlet]=\"nilOptionTemplateRef\"></ng-container>\n </mat-option>\n <mat-option *ngFor=\"let option of
|
|
2210
|
+
SelectInputComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.12", type: SelectInputComponent, selector: "aup-select-input", inputs: { options$: "options$", optionsModel: "optionsModel", options: "options", optionLabel: "optionLabel", allowNil: "allowNil", optionLabelFormat: "optionLabelFormat" }, queries: [{ propertyName: "selectedOptionTemplateRef", first: true, predicate: ["selectedOptionTemplate"], descendants: true }, { propertyName: "optionTemplateRef", first: true, predicate: ["optionTemplate"], descendants: true }, { propertyName: "nilOptionTemplateRef", first: true, predicate: ["nilOptionTemplate"], descendants: true }], usesInheritance: true, ngImport: i0, template: "<mat-form-field appearance=\"standard\" [floatLabel]=\"floatLabel\">\n <mat-label *ngIf=\"label\">{{label}}</mat-label>\n <mat-select placeholder=\"{{placeholder}}\"\n [ngModel]=\"componentValue$.value\"\n (ngModelChange)=\"select($event)\"\n [disabled]=\"!enabled$.value\"\n (keydown.enter)=\"notifyEnterKey()\"\n (keydown.escape)=\"notifyEscapeKey()\"\n [pectinFocusBinding]=\"focusContext\"\n [errorStateMatcher]=\"errorStateMatcher\"\n >\n <mat-select-trigger *ngIf=\"selectedOptionTemplateRef\">\n <ng-container [ngTemplateOutlet]=\"selectedOptionTemplateRef\" [ngTemplateOutletContext]=\"{ $implicit: componentValue$.value}\"></ng-container>\n </mat-select-trigger>\n\n<!-- <mat-select-trigger *ngIf=\"!selectedOptionTemplateRef\">-->\n<!-- {{optionLabelFormat(componentValue$.value)}}-->\n<!-- </mat-select-trigger>-->\n\n <mat-option *ngIf=\"allowNil\">\n <ng-container *ngIf=\"!nilOptionTemplateRef\">{{placeholder}}</ng-container>\n <ng-container *ngIf=\"nilOptionTemplateRef\" [ngTemplateOutlet]=\"nilOptionTemplateRef\"></ng-container>\n </mat-option>\n <mat-option *ngFor=\"let option of cookedOptions$.value; let i = index\" [value]=\"option\">\n <ng-container *ngIf=\"!optionTemplateRef\">{{optionLabelFormat(option)}}</ng-container>\n <ng-container *ngIf=\"optionTemplateRef\"\n [ngTemplateOutlet]=\"optionTemplateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: option, index: i }\"\n >\n </ng-container>\n </mat-option>\n </mat-select>\n <mat-hint *ngIf=\"showHint\">{{hint}}</mat-hint>\n <mat-error *ngIf=\"hasErrors\">{{firstError}}</mat-error>\n</mat-form-field>\n<div class=\"width-strut\">\n <mat-label *ngIf=\"label\">{{label}}</mat-label>\n <div class=\"item\" *ngFor=\"let item of cookedOptions$.value\">\n <ng-container *ngIf=\"!optionTemplateRef\">{{optionLabelFormat(item)}}</ng-container>\n <ng-container *ngIf=\"optionTemplateRef\"\n [ngTemplateOutlet]=\"optionTemplateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: item, index: 0 }\"\n >\n </ng-container>\n </div>\n</div>\n", styles: [":host{display:inline-block}mat-form-field{width:100%}.width-strut{display:block;height:0;max-height:0;width:auto;visibility:hidden;overflow:hidden;padding-right:35px}.width-strut mat-label{font-size:75%}.width-strut>.item{font-size:16px;padding-left:0}\n"], dependencies: [{ kind: "directive", type: i1$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1$1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i2$4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2$4.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i3$1.MatError, selector: "mat-error", inputs: ["id"] }, { kind: "component", type: i3$1.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i3$1.MatHint, selector: "mat-hint", inputs: ["align", "id"] }, { kind: "directive", type: i3$1.MatLabel, selector: "mat-label" }, { kind: "component", type: i4$3.MatSelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex"], exportAs: ["matSelect"] }, { kind: "directive", type: i4$3.MatSelectTrigger, selector: "mat-select-trigger" }, { kind: "component", type: i5.MatOption, selector: "mat-option", exportAs: ["matOption"] }, { kind: "directive", type: FocusBindingDirective, selector: "[pectinFocusBinding]", inputs: ["pectinFocusBinding", "focusBindingTarget"] }] });
|
|
2183
2211
|
__decorate([
|
|
2184
2212
|
TrackExternal({ delegateTo: "_options$" }),
|
|
2185
2213
|
__metadata("design:type", ListModel)
|
|
@@ -2194,7 +2222,7 @@ __decorate([
|
|
|
2194
2222
|
], SelectInputComponent.prototype, "options", void 0);
|
|
2195
2223
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: SelectInputComponent, decorators: [{
|
|
2196
2224
|
type: Component,
|
|
2197
|
-
args: [{ selector: 'aup-select-input', template: "<mat-form-field appearance=\"standard\" [floatLabel]=\"floatLabel\">\n <mat-label *ngIf=\"label\">{{label}}</mat-label>\n <mat-select placeholder=\"{{placeholder}}\"\n [ngModel]=\"componentValue$.value\"\n (ngModelChange)=\"select($event)\"\n [disabled]=\"!enabled$.value\"\n (keydown.enter)=\"notifyEnterKey()\"\n (keydown.escape)=\"notifyEscapeKey()\"\n [pectinFocusBinding]=\"focusContext\"\n [errorStateMatcher]=\"errorStateMatcher\"\n >\n <mat-select-trigger *ngIf=\"selectedOptionTemplateRef\">\n <ng-container [ngTemplateOutlet]=\"selectedOptionTemplateRef\" [ngTemplateOutletContext]=\"{ $implicit: componentValue$.value}\"></ng-container>\n </mat-select-trigger>\n\n <mat-option *ngIf=\"allowNil\">\n <ng-container *ngIf=\"!nilOptionTemplateRef\">{{placeholder}}</ng-container>\n <ng-container *ngIf=\"nilOptionTemplateRef\" [ngTemplateOutlet]=\"nilOptionTemplateRef\"></ng-container>\n </mat-option>\n <mat-option *ngFor=\"let option of
|
|
2225
|
+
args: [{ selector: 'aup-select-input', template: "<mat-form-field appearance=\"standard\" [floatLabel]=\"floatLabel\">\n <mat-label *ngIf=\"label\">{{label}}</mat-label>\n <mat-select placeholder=\"{{placeholder}}\"\n [ngModel]=\"componentValue$.value\"\n (ngModelChange)=\"select($event)\"\n [disabled]=\"!enabled$.value\"\n (keydown.enter)=\"notifyEnterKey()\"\n (keydown.escape)=\"notifyEscapeKey()\"\n [pectinFocusBinding]=\"focusContext\"\n [errorStateMatcher]=\"errorStateMatcher\"\n >\n <mat-select-trigger *ngIf=\"selectedOptionTemplateRef\">\n <ng-container [ngTemplateOutlet]=\"selectedOptionTemplateRef\" [ngTemplateOutletContext]=\"{ $implicit: componentValue$.value}\"></ng-container>\n </mat-select-trigger>\n\n<!-- <mat-select-trigger *ngIf=\"!selectedOptionTemplateRef\">-->\n<!-- {{optionLabelFormat(componentValue$.value)}}-->\n<!-- </mat-select-trigger>-->\n\n <mat-option *ngIf=\"allowNil\">\n <ng-container *ngIf=\"!nilOptionTemplateRef\">{{placeholder}}</ng-container>\n <ng-container *ngIf=\"nilOptionTemplateRef\" [ngTemplateOutlet]=\"nilOptionTemplateRef\"></ng-container>\n </mat-option>\n <mat-option *ngFor=\"let option of cookedOptions$.value; let i = index\" [value]=\"option\">\n <ng-container *ngIf=\"!optionTemplateRef\">{{optionLabelFormat(option)}}</ng-container>\n <ng-container *ngIf=\"optionTemplateRef\"\n [ngTemplateOutlet]=\"optionTemplateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: option, index: i }\"\n >\n </ng-container>\n </mat-option>\n </mat-select>\n <mat-hint *ngIf=\"showHint\">{{hint}}</mat-hint>\n <mat-error *ngIf=\"hasErrors\">{{firstError}}</mat-error>\n</mat-form-field>\n<div class=\"width-strut\">\n <mat-label *ngIf=\"label\">{{label}}</mat-label>\n <div class=\"item\" *ngFor=\"let item of cookedOptions$.value\">\n <ng-container *ngIf=\"!optionTemplateRef\">{{optionLabelFormat(item)}}</ng-container>\n <ng-container *ngIf=\"optionTemplateRef\"\n [ngTemplateOutlet]=\"optionTemplateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: item, index: 0 }\"\n >\n </ng-container>\n </div>\n</div>\n", styles: [":host{display:inline-block}mat-form-field{width:100%}.width-strut{display:block;height:0;max-height:0;width:auto;visibility:hidden;overflow:hidden;padding-right:35px}.width-strut mat-label{font-size:75%}.width-strut>.item{font-size:16px;padding-left:0}\n"] }]
|
|
2198
2226
|
}], ctorParameters: function () { return []; }, propDecorators: { options$: [{
|
|
2199
2227
|
type: Input
|
|
2200
2228
|
}], optionsModel: [{
|