@ni/fast-foundation 10.1.1 → 10.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.
|
@@ -160,6 +160,7 @@ export declare class NumberField extends FormAssociatedNumberField {
|
|
|
160
160
|
valueChanged(previous: string, next: string): void;
|
|
161
161
|
/** {@inheritDoc (FormAssociated:interface).validate} */
|
|
162
162
|
validate(): void;
|
|
163
|
+
private limitPrecision;
|
|
163
164
|
/**
|
|
164
165
|
* Sets the internal value to a valid number between the min and max properties
|
|
165
166
|
* @param value - user input
|
|
@@ -119,6 +119,9 @@ export class NumberField extends FormAssociatedNumberField {
|
|
|
119
119
|
validate() {
|
|
120
120
|
super.validate(this.control);
|
|
121
121
|
}
|
|
122
|
+
limitPrecision(value) {
|
|
123
|
+
return parseFloat(value.toPrecision(15));
|
|
124
|
+
}
|
|
122
125
|
/**
|
|
123
126
|
* Sets the internal value to a valid number between the min and max properties
|
|
124
127
|
* @param value - user input
|
|
@@ -126,16 +129,17 @@ export class NumberField extends FormAssociatedNumberField {
|
|
|
126
129
|
* @internal
|
|
127
130
|
*/
|
|
128
131
|
getValidValue(value) {
|
|
129
|
-
|
|
130
|
-
let validValue = parseFloat(parseFloat(value).toPrecision(15));
|
|
132
|
+
let validValue = this.limitPrecision(parseFloat(value));
|
|
131
133
|
if (isNaN(validValue)) {
|
|
132
|
-
|
|
134
|
+
return "";
|
|
135
|
+
}
|
|
136
|
+
if (this.max !== undefined) {
|
|
137
|
+
validValue = Math.min(validValue, this.limitPrecision(this.max));
|
|
133
138
|
}
|
|
134
|
-
|
|
135
|
-
validValue = Math.
|
|
136
|
-
validValue = Math.max(validValue, (_b = this.min) !== null && _b !== void 0 ? _b : validValue).toString();
|
|
139
|
+
if (this.min !== undefined) {
|
|
140
|
+
validValue = Math.max(validValue, this.limitPrecision(this.min));
|
|
137
141
|
}
|
|
138
|
-
return validValue;
|
|
142
|
+
return validValue.toString();
|
|
139
143
|
}
|
|
140
144
|
/**
|
|
141
145
|
* Increments the value using the step value
|
|
@@ -6096,6 +6096,7 @@ export declare class NumberField extends FormAssociatedNumberField {
|
|
|
6096
6096
|
valueChanged(previous: string, next: string): void;
|
|
6097
6097
|
/** {@inheritDoc (FormAssociated:interface).validate} */
|
|
6098
6098
|
validate(): void;
|
|
6099
|
+
private limitPrecision;
|
|
6099
6100
|
/**
|
|
6100
6101
|
* Sets the internal value to a valid number between the min and max properties
|
|
6101
6102
|
* @param value - user input
|
package/dist/fast-foundation.js
CHANGED
|
@@ -16129,6 +16129,9 @@ class NumberField extends FormAssociatedNumberField {
|
|
|
16129
16129
|
validate() {
|
|
16130
16130
|
super.validate(this.control);
|
|
16131
16131
|
}
|
|
16132
|
+
limitPrecision(value) {
|
|
16133
|
+
return parseFloat(value.toPrecision(15));
|
|
16134
|
+
}
|
|
16132
16135
|
/**
|
|
16133
16136
|
* Sets the internal value to a valid number between the min and max properties
|
|
16134
16137
|
* @param value - user input
|
|
@@ -16136,16 +16139,17 @@ class NumberField extends FormAssociatedNumberField {
|
|
|
16136
16139
|
* @internal
|
|
16137
16140
|
*/
|
|
16138
16141
|
getValidValue(value) {
|
|
16139
|
-
|
|
16140
|
-
let validValue = parseFloat(parseFloat(value).toPrecision(15));
|
|
16142
|
+
let validValue = this.limitPrecision(parseFloat(value));
|
|
16141
16143
|
if (isNaN(validValue)) {
|
|
16142
|
-
|
|
16144
|
+
return "";
|
|
16143
16145
|
}
|
|
16144
|
-
|
|
16145
|
-
validValue = Math.min(validValue, (
|
|
16146
|
-
|
|
16146
|
+
if (this.max !== undefined) {
|
|
16147
|
+
validValue = Math.min(validValue, this.limitPrecision(this.max));
|
|
16148
|
+
}
|
|
16149
|
+
if (this.min !== undefined) {
|
|
16150
|
+
validValue = Math.max(validValue, this.limitPrecision(this.min));
|
|
16147
16151
|
}
|
|
16148
|
-
return validValue;
|
|
16152
|
+
return validValue.toString();
|
|
16149
16153
|
}
|
|
16150
16154
|
/**
|
|
16151
16155
|
* Increments the value using the step value
|
|
@@ -848,7 +848,7 @@ const t=function(){if("undefined"!=typeof globalThis)return globalThis;if("undef
|
|
|
848
848
|
${Jt(0,e)}
|
|
849
849
|
</div>
|
|
850
850
|
</template>
|
|
851
|
-
`;class On extends ei{}class Sn extends(hs(On)){constructor(){super(...arguments),this.proxy=document.createElement("input")}}const Rn={email:"email",password:"password",tel:"tel",text:"text",url:"url"};class An extends Sn{constructor(){super(...arguments),this.type=Rn.text}readOnlyChanged(){this.proxy instanceof HTMLInputElement&&(this.proxy.readOnly=this.readOnly,this.validate())}autofocusChanged(){this.proxy instanceof HTMLInputElement&&(this.proxy.autofocus=this.autofocus,this.validate())}placeholderChanged(){this.proxy instanceof HTMLInputElement&&(this.proxy.placeholder=this.placeholder)}typeChanged(){this.proxy instanceof HTMLInputElement&&(this.proxy.type=this.type,this.validate())}listChanged(){this.proxy instanceof HTMLInputElement&&(this.proxy.setAttribute("list",this.list),this.validate())}maxlengthChanged(){this.proxy instanceof HTMLInputElement&&(this.proxy.maxLength=this.maxlength,this.validate())}minlengthChanged(){this.proxy instanceof HTMLInputElement&&(this.proxy.minLength=this.minlength,this.validate())}patternChanged(){this.proxy instanceof HTMLInputElement&&(this.proxy.pattern=this.pattern,this.validate())}sizeChanged(){this.proxy instanceof HTMLInputElement&&(this.proxy.size=this.size)}spellcheckChanged(){this.proxy instanceof HTMLInputElement&&(this.proxy.spellcheck=this.spellcheck)}connectedCallback(){super.connectedCallback(),this.proxy.setAttribute("type",this.type),this.validate(),this.autofocus&&c.queueUpdate((()=>{this.focus()}))}select(){this.control.select(),this.$emit("select")}handleTextInput(){this.value=this.control.value}handleChange(){this.$emit("change")}validate(){super.validate(this.control)}}oe([lt({attribute:"readonly",mode:"boolean"})],An.prototype,"readOnly",void 0),oe([lt({mode:"boolean"})],An.prototype,"autofocus",void 0),oe([lt],An.prototype,"placeholder",void 0),oe([lt],An.prototype,"type",void 0),oe([lt],An.prototype,"list",void 0),oe([lt({converter:rt})],An.prototype,"maxlength",void 0),oe([lt({converter:rt})],An.prototype,"minlength",void 0),oe([lt],An.prototype,"pattern",void 0),oe([lt({converter:rt})],An.prototype,"size",void 0),oe([lt({mode:"boolean"})],An.prototype,"spellcheck",void 0),oe([v],An.prototype,"defaultSlottedNodes",void 0);class Dn{}oi(Dn,Vi),oi(An,Zt,Dn);class Fn extends ei{}class Ln extends(hs(Fn)){constructor(){super(...arguments),this.proxy=document.createElement("input")}}class Pn extends Ln{constructor(){super(...arguments),this.hideStep=!1,this.step=1,this.isUserInput=!1}maxChanged(t,e){var i;this.max=Math.max(e,null!==(i=this.min)&&void 0!==i?i:e);const s=Math.min(this.min,this.max);void 0!==this.min&&this.min!==s&&(this.min=s),this.value=this.getValidValue(this.value)}minChanged(t,e){var i;this.min=Math.min(e,null!==(i=this.max)&&void 0!==i?i:e);const s=Math.max(this.min,this.max);void 0!==this.max&&this.max!==s&&(this.max=s),this.value=this.getValidValue(this.value)}get valueAsNumber(){return parseFloat(super.value)}set valueAsNumber(t){this.value=t.toString()}valueChanged(t,e){this.value=this.getValidValue(e),e===this.value&&(this.control&&!this.isUserInput&&this.syncValueToInnerControl(),super.valueChanged(t,this.value),void 0===t||this.isUserInput||(this.$emit("input"),this.$emit("change")),this.isUserInput=!1)}validate(){super.validate(this.control)}getValidValue(t){
|
|
851
|
+
`;class On extends ei{}class Sn extends(hs(On)){constructor(){super(...arguments),this.proxy=document.createElement("input")}}const Rn={email:"email",password:"password",tel:"tel",text:"text",url:"url"};class An extends Sn{constructor(){super(...arguments),this.type=Rn.text}readOnlyChanged(){this.proxy instanceof HTMLInputElement&&(this.proxy.readOnly=this.readOnly,this.validate())}autofocusChanged(){this.proxy instanceof HTMLInputElement&&(this.proxy.autofocus=this.autofocus,this.validate())}placeholderChanged(){this.proxy instanceof HTMLInputElement&&(this.proxy.placeholder=this.placeholder)}typeChanged(){this.proxy instanceof HTMLInputElement&&(this.proxy.type=this.type,this.validate())}listChanged(){this.proxy instanceof HTMLInputElement&&(this.proxy.setAttribute("list",this.list),this.validate())}maxlengthChanged(){this.proxy instanceof HTMLInputElement&&(this.proxy.maxLength=this.maxlength,this.validate())}minlengthChanged(){this.proxy instanceof HTMLInputElement&&(this.proxy.minLength=this.minlength,this.validate())}patternChanged(){this.proxy instanceof HTMLInputElement&&(this.proxy.pattern=this.pattern,this.validate())}sizeChanged(){this.proxy instanceof HTMLInputElement&&(this.proxy.size=this.size)}spellcheckChanged(){this.proxy instanceof HTMLInputElement&&(this.proxy.spellcheck=this.spellcheck)}connectedCallback(){super.connectedCallback(),this.proxy.setAttribute("type",this.type),this.validate(),this.autofocus&&c.queueUpdate((()=>{this.focus()}))}select(){this.control.select(),this.$emit("select")}handleTextInput(){this.value=this.control.value}handleChange(){this.$emit("change")}validate(){super.validate(this.control)}}oe([lt({attribute:"readonly",mode:"boolean"})],An.prototype,"readOnly",void 0),oe([lt({mode:"boolean"})],An.prototype,"autofocus",void 0),oe([lt],An.prototype,"placeholder",void 0),oe([lt],An.prototype,"type",void 0),oe([lt],An.prototype,"list",void 0),oe([lt({converter:rt})],An.prototype,"maxlength",void 0),oe([lt({converter:rt})],An.prototype,"minlength",void 0),oe([lt],An.prototype,"pattern",void 0),oe([lt({converter:rt})],An.prototype,"size",void 0),oe([lt({mode:"boolean"})],An.prototype,"spellcheck",void 0),oe([v],An.prototype,"defaultSlottedNodes",void 0);class Dn{}oi(Dn,Vi),oi(An,Zt,Dn);class Fn extends ei{}class Ln extends(hs(Fn)){constructor(){super(...arguments),this.proxy=document.createElement("input")}}class Pn extends Ln{constructor(){super(...arguments),this.hideStep=!1,this.step=1,this.isUserInput=!1}maxChanged(t,e){var i;this.max=Math.max(e,null!==(i=this.min)&&void 0!==i?i:e);const s=Math.min(this.min,this.max);void 0!==this.min&&this.min!==s&&(this.min=s),this.value=this.getValidValue(this.value)}minChanged(t,e){var i;this.min=Math.min(e,null!==(i=this.max)&&void 0!==i?i:e);const s=Math.max(this.min,this.max);void 0!==this.max&&this.max!==s&&(this.max=s),this.value=this.getValidValue(this.value)}get valueAsNumber(){return parseFloat(super.value)}set valueAsNumber(t){this.value=t.toString()}valueChanged(t,e){this.value=this.getValidValue(e),e===this.value&&(this.control&&!this.isUserInput&&this.syncValueToInnerControl(),super.valueChanged(t,this.value),void 0===t||this.isUserInput||(this.$emit("input"),this.$emit("change")),this.isUserInput=!1)}validate(){super.validate(this.control)}limitPrecision(t){return parseFloat(t.toPrecision(15))}getValidValue(t){let e=this.limitPrecision(parseFloat(t));return isNaN(e)?"":(void 0!==this.max&&(e=Math.min(e,this.limitPrecision(this.max))),void 0!==this.min&&(e=Math.max(e,this.limitPrecision(this.min))),e.toString())}stepUp(){const t=parseFloat(this.value),e=isNaN(t)?this.min>0?this.min:this.max<0?this.max:this.min?0:this.step:t+this.step;this.value=e.toString()}stepDown(){const t=parseFloat(this.value),e=isNaN(t)?this.min>0?this.min:this.max<0?this.max:this.min?0:0-this.step:t-this.step;this.value=e.toString()}connectedCallback(){super.connectedCallback(),this.proxy.setAttribute("type","number"),this.validate(),this.syncValueToInnerControl(),this.autofocus&&c.queueUpdate((()=>{this.focus()}))}select(){this.control.select(),this.$emit("select")}handleTextInput(){this.control.value=this.sanitizeInput(this.control.value),this.isUserInput=!0,this.syncValueFromInnerControl()}handleChange(){this.$emit("change")}handleKeyDown(t){switch(t.key){case xi:return this.stepUp(),!1;case bi:return this.stepDown(),!1}return!0}handleBlur(){this.syncValueToInnerControl()}sanitizeInput(t){return t.replace(/[^0-9\-+e.]/g,"")}syncValueFromInnerControl(){this.value=this.control.value}syncValueToInnerControl(){this.control.value=this.value}}oe([lt({attribute:"readonly",mode:"boolean"})],Pn.prototype,"readOnly",void 0),oe([lt({mode:"boolean"})],Pn.prototype,"autofocus",void 0),oe([lt({attribute:"hide-step",mode:"boolean"})],Pn.prototype,"hideStep",void 0),oe([lt],Pn.prototype,"placeholder",void 0),oe([lt],Pn.prototype,"list",void 0),oe([lt({converter:rt})],Pn.prototype,"maxlength",void 0),oe([lt({converter:rt})],Pn.prototype,"minlength",void 0),oe([lt({converter:rt})],Pn.prototype,"size",void 0),oe([lt({converter:rt})],Pn.prototype,"step",void 0),oe([lt({converter:rt})],Pn.prototype,"max",void 0),oe([lt({converter:rt})],Pn.prototype,"min",void 0),oe([v],Pn.prototype,"defaultSlottedNodes",void 0),oi(Pn,Zt,Dn);const Mn=(t,e)=>K`
|
|
852
852
|
<template
|
|
853
853
|
role="progressbar"
|
|
854
854
|
aria-valuenow="${t=>t.value}"
|