@coolon/angular-ui-powerups 14.38.3 → 14.39.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.
- package/esm2020/lib/components/forms/select-input/select-input.component.mjs +37 -11
- package/fesm2015/coolon-angular-ui-powerups.mjs +36 -10
- package/fesm2015/coolon-angular-ui-powerups.mjs.map +1 -1
- package/fesm2020/coolon-angular-ui-powerups.mjs +36 -10
- package/fesm2020/coolon-angular-ui-powerups.mjs.map +1 -1
- package/lib/components/forms/select-input/select-input.component.d.ts +2 -1
- package/package.json +1 -1
- package/schematics/component/index.js +6 -2
- package/schematics/component/index.js.map +1 -1
- package/schematics/component/schema.d.ts +1 -0
- package/schematics/component/schema.json +12 -0
- package/schematics/component/templates/component/__name@dasherize__.component.ts.template +3 -2
- package/schematics/place-add/index.js +17 -9
- package/schematics/place-add/index.js.map +1 -1
- package/schematics/place-add/schema.d.ts +1 -0
- package/schematics/place-add/schema.json +6 -0
- package/schematics/place-add/templates/component/__name@dasherize__.component.ts.template +5 -3
- package/schematics/utils/build-context.d.ts +1 -0
- package/schematics/utils/build-context.js +6 -1
- package/schematics/utils/build-context.js.map +1 -1
- package/schematics/utils/source-file-utilities.js +1 -0
- package/schematics/utils/source-file-utilities.js.map +1 -1
|
@@ -2156,34 +2156,60 @@ 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
|
+
this.trackByIdentity = (index, item) => this.options$.identityOf(item) ?? index;
|
|
2159
2160
|
const { chain } = Dsl.disposeWith(this);
|
|
2160
2161
|
this.cookedOptions$ = chain(this.options$).reduceToList(options => {
|
|
2161
2162
|
return options.length < 1 && !isNil(this.componentValue$.value) ? [this.componentValue$.value] : options;
|
|
2162
|
-
}, { dependsOn: this.componentValue$ })
|
|
2163
|
+
}, { dependsOn: this.componentValue$ })
|
|
2164
|
+
.identifiedWith(this.options$.identityOf);
|
|
2165
|
+
this.cookedOptions$ = chain(this.options$)
|
|
2166
|
+
.otherwise(chain(this.componentValue$).mapToList(v => [v]))
|
|
2167
|
+
.identifiedWith(this.options$.identityOf);
|
|
2163
2168
|
}
|
|
2164
2169
|
select(item) {
|
|
2165
2170
|
this.id$.value = this.options$.identityOf(item);
|
|
2166
2171
|
}
|
|
2167
2172
|
ngOnInit() {
|
|
2168
2173
|
// NOTE: this has to be done after our parameter have been bound or we'll clobber the initial selected values with the writeRight
|
|
2169
|
-
const { chain, when } = Dsl.disposeWith(this);
|
|
2170
|
-
// TODO: I wouldn't have to do this if selectionModel.leadSelection$ was mutable...
|
|
2174
|
+
const { chain, before, when } = Dsl.disposeWith(this);
|
|
2171
2175
|
const lookup = chain(this.options$).indexUsing(this.options$.identityOf);
|
|
2172
2176
|
const self = this;
|
|
2173
|
-
this.registerDisposable(new Binding(this.componentValue$, this.id$, {
|
|
2174
|
-
toLeft(
|
|
2175
|
-
const newValue = lookup.get(
|
|
2177
|
+
const binding = this.registerDisposable(new Binding(this.componentValue$, this.id$, {
|
|
2178
|
+
toLeft(selectedId, currentValue) {
|
|
2179
|
+
const newValue = lookup.get(selectedId); // the list is empty or we're missing form it so don't touch the real value.
|
|
2176
2180
|
return isNil(newValue) ? currentValue : newValue;
|
|
2177
2181
|
},
|
|
2178
2182
|
leftDependsOn: lookup,
|
|
2179
|
-
toRight(
|
|
2180
|
-
return self.options$.identityOf(
|
|
2183
|
+
toRight(selectedValue, selectedId) {
|
|
2184
|
+
return self.options$.identityOf(selectedValue);
|
|
2181
2185
|
}
|
|
2182
2186
|
})).writeRight();
|
|
2187
|
+
// TODO: we have to do this as the options identity function can change from identity to somethign else after
|
|
2188
|
+
// we already have an initial value. In that case the stored id will be wrong.
|
|
2189
|
+
// Probably a reasonable solution for it be to track changes in the identity function and handle it
|
|
2190
|
+
// at a more fundamental level. This may include checking if the function has changed... but currently
|
|
2191
|
+
// the function change things under the hood.
|
|
2192
|
+
const snapshotValueAndId = (value) => ({
|
|
2193
|
+
value: value,
|
|
2194
|
+
id: this.options$.identityOf(value)
|
|
2195
|
+
});
|
|
2196
|
+
let lastIdSnapshot = snapshotValueAndId(this.componentValue$.value);
|
|
2197
|
+
console.log(lastIdSnapshot);
|
|
2198
|
+
before(this.options$).changes(() => {
|
|
2199
|
+
lastIdSnapshot = snapshotValueAndId(this.componentValue$.value);
|
|
2200
|
+
console.log(lastIdSnapshot);
|
|
2201
|
+
});
|
|
2202
|
+
when(this.options$).changes((is, was) => {
|
|
2203
|
+
const newIdSnapshot = snapshotValueAndId(lastIdSnapshot.value);
|
|
2204
|
+
console.log(lastIdSnapshot, newIdSnapshot);
|
|
2205
|
+
if (newIdSnapshot !== lastIdSnapshot.id) {
|
|
2206
|
+
this.id$.value = this.options$.identityOf(this.componentValue$.value);
|
|
2207
|
+
}
|
|
2208
|
+
});
|
|
2183
2209
|
}
|
|
2184
2210
|
}
|
|
2185
2211
|
SelectInputComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: SelectInputComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2186
|
-
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\"
|
|
2212
|
+
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\n <!--\n TODO: dave has a scenario where the selected item isn't rendering that I can't reproduce so we explicity render it..\n It typically happens because the ngModel value isn't the one contained in the list - this means our source model\n identifyOf function has changed and our id$/lookup$/componentValue$ are out of sync.\n We get around this for now by explicity rendering the component value.\n Please Note: I haven't been able to reproduce this\n -->\n <mat-select-trigger *ngIf=\"!selectedOptionTemplateRef\">\n {{optionLabelFormat(componentValue$.value)}}\n </mat-select-trigger>\n\n <mat-select-trigger *ngIf=\"selectedOptionTemplateRef\">\n <ng-container [ngTemplateOutlet]=\"selectedOptionTemplateRef\"\n [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 cookedOptions$.value; trackBy: trackByIdentity;let i = index\"\n [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"] }] });
|
|
2187
2213
|
__decorate([
|
|
2188
2214
|
TrackExternal({ delegateTo: "_options$" }),
|
|
2189
2215
|
__metadata("design:type", ListModel)
|
|
@@ -2198,7 +2224,7 @@ __decorate([
|
|
|
2198
2224
|
], SelectInputComponent.prototype, "options", void 0);
|
|
2199
2225
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.12", ngImport: i0, type: SelectInputComponent, decorators: [{
|
|
2200
2226
|
type: Component,
|
|
2201
|
-
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\"
|
|
2227
|
+
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\n <!--\n TODO: dave has a scenario where the selected item isn't rendering that I can't reproduce so we explicity render it..\n It typically happens because the ngModel value isn't the one contained in the list - this means our source model\n identifyOf function has changed and our id$/lookup$/componentValue$ are out of sync.\n We get around this for now by explicity rendering the component value.\n Please Note: I haven't been able to reproduce this\n -->\n <mat-select-trigger *ngIf=\"!selectedOptionTemplateRef\">\n {{optionLabelFormat(componentValue$.value)}}\n </mat-select-trigger>\n\n <mat-select-trigger *ngIf=\"selectedOptionTemplateRef\">\n <ng-container [ngTemplateOutlet]=\"selectedOptionTemplateRef\"\n [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 cookedOptions$.value; trackBy: trackByIdentity;let i = index\"\n [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"] }]
|
|
2202
2228
|
}], ctorParameters: function () { return []; }, propDecorators: { options$: [{
|
|
2203
2229
|
type: Input
|
|
2204
2230
|
}], optionsModel: [{
|