@ni/nimble-angular 8.1.1 → 8.1.2
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/bundles/ni-nimble-angular.umd.js +29 -13
- package/bundles/ni-nimble-angular.umd.js.map +1 -1
- package/directives/combobox/nimble-combobox-control-value-accessor.directive.d.ts +11 -2
- package/esm2015/directives/combobox/nimble-combobox-control-value-accessor.directive.js +22 -6
- package/esm2015/directives/list-option/nimble-combobox-list-option.directive.js +5 -5
- package/fesm2015/ni-nimble-angular.js +25 -9
- package/fesm2015/ni-nimble-angular.js.map +1 -1
- package/package.json +1 -1
|
@@ -856,7 +856,6 @@
|
|
|
856
856
|
function NimbleComboboxControlValueAccessorDirective(_renderer, _elementRef) {
|
|
857
857
|
this._renderer = _renderer;
|
|
858
858
|
this._elementRef = _elementRef;
|
|
859
|
-
/** @internal */
|
|
860
859
|
this._optionMap = new Map();
|
|
861
860
|
this._compareWith = Object.is;
|
|
862
861
|
}
|
|
@@ -880,8 +879,8 @@
|
|
|
880
879
|
* @param value The ngValue set on the nimble-combobox
|
|
881
880
|
*/
|
|
882
881
|
NimbleComboboxControlValueAccessorDirective.prototype.writeValue = function (value) {
|
|
883
|
-
|
|
884
|
-
this.
|
|
882
|
+
this._modelValue = value;
|
|
883
|
+
this.updateDisplayValue();
|
|
885
884
|
};
|
|
886
885
|
/**
|
|
887
886
|
* Registers a function called when the control value changes.
|
|
@@ -890,8 +889,8 @@
|
|
|
890
889
|
NimbleComboboxControlValueAccessorDirective.prototype.registerOnChange = function (fn) {
|
|
891
890
|
var _this = this;
|
|
892
891
|
this.onChange = function (valueString) {
|
|
893
|
-
var
|
|
894
|
-
|
|
892
|
+
var modelValue = _this._optionMap.has(valueString) ? _this._optionMap.get(valueString) : OPTION_NOT_FOUND;
|
|
893
|
+
_this._modelValue = modelValue;
|
|
895
894
|
fn(modelValue);
|
|
896
895
|
};
|
|
897
896
|
};
|
|
@@ -902,11 +901,28 @@
|
|
|
902
901
|
NimbleComboboxControlValueAccessorDirective.prototype.registerOnTouched = function (fn) {
|
|
903
902
|
this.onTouched = fn;
|
|
904
903
|
};
|
|
904
|
+
/**
|
|
905
|
+
* @internal
|
|
906
|
+
*/
|
|
907
|
+
NimbleComboboxControlValueAccessorDirective.prototype.addOption = function (displayValue, modelValue) {
|
|
908
|
+
this._optionMap.set(displayValue, modelValue);
|
|
909
|
+
this.updateDisplayValue();
|
|
910
|
+
};
|
|
911
|
+
/**
|
|
912
|
+
* @internal
|
|
913
|
+
*/
|
|
914
|
+
NimbleComboboxControlValueAccessorDirective.prototype.removeOption = function (displayValue) {
|
|
915
|
+
this._optionMap.delete(displayValue);
|
|
916
|
+
};
|
|
917
|
+
NimbleComboboxControlValueAccessorDirective.prototype.updateDisplayValue = function () {
|
|
918
|
+
var valueAsString = this.getValueStringFromValue(this._modelValue);
|
|
919
|
+
this.setProperty('value', valueAsString !== null && valueAsString !== void 0 ? valueAsString : '');
|
|
920
|
+
};
|
|
905
921
|
NimbleComboboxControlValueAccessorDirective.prototype.getValueStringFromValue = function (value) {
|
|
906
|
-
var e_1,
|
|
922
|
+
var e_1, _a;
|
|
907
923
|
try {
|
|
908
|
-
for (var
|
|
909
|
-
var
|
|
924
|
+
for (var _b = __values(this._optionMap.entries()), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
925
|
+
var _d = __read(_c.value, 2), optionKey = _d[0], optionValue = _d[1];
|
|
910
926
|
if (this._compareWith(optionValue, value)) {
|
|
911
927
|
return optionKey;
|
|
912
928
|
}
|
|
@@ -915,7 +931,7 @@
|
|
|
915
931
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
916
932
|
finally {
|
|
917
933
|
try {
|
|
918
|
-
if (
|
|
934
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
919
935
|
}
|
|
920
936
|
finally { if (e_1) throw e_1.error; }
|
|
921
937
|
}
|
|
@@ -6288,19 +6304,19 @@
|
|
|
6288
6304
|
NimbleComboboxListOptionDirective.prototype.ngAfterViewInit = function () {
|
|
6289
6305
|
if (this.combobox) {
|
|
6290
6306
|
this._currentTextContent = this.elementRef.nativeElement.textContent;
|
|
6291
|
-
this.combobox.
|
|
6307
|
+
this.combobox.addOption(this._currentTextContent, this._modelValue);
|
|
6292
6308
|
}
|
|
6293
6309
|
};
|
|
6294
6310
|
NimbleComboboxListOptionDirective.prototype.ngOnDestroy = function () {
|
|
6295
6311
|
if (this.combobox) {
|
|
6296
|
-
this.combobox.
|
|
6312
|
+
this.combobox.removeOption(this._currentTextContent);
|
|
6297
6313
|
}
|
|
6298
6314
|
};
|
|
6299
6315
|
NimbleComboboxListOptionDirective.prototype.updateComboboxValue = function (value) {
|
|
6300
|
-
this.combobox.
|
|
6316
|
+
this.combobox.removeOption(this._currentTextContent);
|
|
6301
6317
|
this.changeDetector.detectChanges();
|
|
6302
6318
|
this._currentTextContent = this.elementRef.nativeElement.textContent;
|
|
6303
|
-
this.combobox.
|
|
6319
|
+
this.combobox.addOption(this._currentTextContent, value);
|
|
6304
6320
|
};
|
|
6305
6321
|
return NimbleComboboxListOptionDirective;
|
|
6306
6322
|
}());
|