@ni/spright-components 5.5.3 → 5.5.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.
|
@@ -26828,7 +26828,7 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
26828
26828
|
?required="${x => x.required}"
|
|
26829
26829
|
size="${x => x.size}"
|
|
26830
26830
|
type="text"
|
|
26831
|
-
inputmode="
|
|
26831
|
+
inputmode="text"
|
|
26832
26832
|
min="${x => x.min}"
|
|
26833
26833
|
max="${x => x.max}"
|
|
26834
26834
|
step="${x => x.step}"
|
|
@@ -26890,11 +26890,53 @@ so this becomes the fallback color for the slot */ ''}
|
|
|
26890
26890
|
this.appearance = NumberFieldAppearance.underline;
|
|
26891
26891
|
this.fullBleed = false;
|
|
26892
26892
|
this.appearanceReadOnly = false;
|
|
26893
|
+
this.decimalSeparator = '.';
|
|
26894
|
+
this.inputFilterRegExp = this.buildFilterRegExp(this.decimalSeparator);
|
|
26895
|
+
this.langSubscriber = {
|
|
26896
|
+
handleChange: () => this.updateDecimalSeparatorAndInputFilter()
|
|
26897
|
+
};
|
|
26893
26898
|
}
|
|
26894
26899
|
connectedCallback() {
|
|
26895
26900
|
super.connectedCallback();
|
|
26896
26901
|
// This is a workaround for FAST issue: https://github.com/microsoft/fast/issues/6148
|
|
26897
26902
|
this.control.setAttribute('role', 'spinbutton');
|
|
26903
|
+
this.updateDecimalSeparatorAndInputFilter();
|
|
26904
|
+
lang.subscribe(this.langSubscriber, this);
|
|
26905
|
+
}
|
|
26906
|
+
disconnectedCallback() {
|
|
26907
|
+
super.disconnectedCallback();
|
|
26908
|
+
lang.unsubscribe(this.langSubscriber, this);
|
|
26909
|
+
}
|
|
26910
|
+
sanitizeInput(inputText) {
|
|
26911
|
+
return inputText.replace(this.inputFilterRegExp, '');
|
|
26912
|
+
}
|
|
26913
|
+
// this.value <-- this.control.value
|
|
26914
|
+
syncValueFromInnerControl() {
|
|
26915
|
+
this.value = this.decimalSeparator !== '.'
|
|
26916
|
+
? this.control.value.replace(this.decimalSeparator, '.')
|
|
26917
|
+
: this.control.value;
|
|
26918
|
+
}
|
|
26919
|
+
// this.value --> this.control.value
|
|
26920
|
+
syncValueToInnerControl() {
|
|
26921
|
+
this.control.value = this.decimalSeparator !== '.'
|
|
26922
|
+
? this.value.replace('.', this.decimalSeparator)
|
|
26923
|
+
: this.value;
|
|
26924
|
+
}
|
|
26925
|
+
updateDecimalSeparatorAndInputFilter() {
|
|
26926
|
+
const previousSeparator = this.decimalSeparator;
|
|
26927
|
+
this.decimalSeparator = this.getSeparatorForLanguange(lang.getValueFor(this));
|
|
26928
|
+
if (this.decimalSeparator !== previousSeparator) {
|
|
26929
|
+
this.inputFilterRegExp = this.buildFilterRegExp(this.decimalSeparator);
|
|
26930
|
+
this.control.value = this.control.value.replace(previousSeparator, this.decimalSeparator);
|
|
26931
|
+
}
|
|
26932
|
+
}
|
|
26933
|
+
getSeparatorForLanguange(language) {
|
|
26934
|
+
return Intl.NumberFormat(language)
|
|
26935
|
+
.formatToParts(1.1)
|
|
26936
|
+
.find(x => x.type === 'decimal').value;
|
|
26937
|
+
}
|
|
26938
|
+
buildFilterRegExp(decimalSeparator) {
|
|
26939
|
+
return new RegExp(`[^0-9\\-+e${decimalSeparator}]`, 'g');
|
|
26898
26940
|
}
|
|
26899
26941
|
}
|
|
26900
26942
|
__decorate([
|