@vaadin/number-field
Advanced tools
Comparing version 23.2.0-alpha3 to 23.2.0-alpha4
{ | ||
"name": "@vaadin/number-field", | ||
"version": "23.2.0-alpha3", | ||
"version": "23.2.0-alpha4", | ||
"publishConfig": { | ||
@@ -26,3 +26,5 @@ "access": "public" | ||
"vaadin-*.d.ts", | ||
"vaadin-*.js" | ||
"vaadin-*.js", | ||
"web-types.json", | ||
"web-types.lit.json" | ||
], | ||
@@ -37,8 +39,8 @@ "keywords": [ | ||
"@polymer/polymer": "^3.0.0", | ||
"@vaadin/component-base": "23.2.0-alpha3", | ||
"@vaadin/field-base": "23.2.0-alpha3", | ||
"@vaadin/input-container": "23.2.0-alpha3", | ||
"@vaadin/vaadin-lumo-styles": "23.2.0-alpha3", | ||
"@vaadin/vaadin-material-styles": "23.2.0-alpha3", | ||
"@vaadin/vaadin-themable-mixin": "23.2.0-alpha3" | ||
"@vaadin/component-base": "23.2.0-alpha4", | ||
"@vaadin/field-base": "23.2.0-alpha4", | ||
"@vaadin/input-container": "23.2.0-alpha4", | ||
"@vaadin/vaadin-lumo-styles": "23.2.0-alpha4", | ||
"@vaadin/vaadin-material-styles": "23.2.0-alpha4", | ||
"@vaadin/vaadin-themable-mixin": "23.2.0-alpha4" | ||
}, | ||
@@ -50,3 +52,7 @@ "devDependencies": { | ||
}, | ||
"gitHead": "06e5875be93ca50da2846dafc65a8531010c0576" | ||
"web-types": [ | ||
"web-types.json", | ||
"web-types.lit.json" | ||
], | ||
"gitHead": "cbf5f1d0f38ac9b81c65cf9ef5660182e176e598" | ||
} |
@@ -92,3 +92,3 @@ /** | ||
*/ | ||
step: number; | ||
step: number | null | undefined; | ||
@@ -98,3 +98,3 @@ addEventListener<K extends keyof NumberFieldEventMap>( | ||
listener: (this: NumberField, ev: NumberFieldEventMap[K]) => void, | ||
options?: boolean | AddEventListenerOptions, | ||
options?: AddEventListenerOptions | boolean, | ||
): void; | ||
@@ -105,3 +105,3 @@ | ||
listener: (this: NumberField, ev: NumberFieldEventMap[K]) => void, | ||
options?: boolean | EventListenerOptions, | ||
options?: EventListenerOptions | boolean, | ||
): void; | ||
@@ -108,0 +108,0 @@ } |
@@ -150,3 +150,2 @@ /** | ||
type: Number, | ||
observer: '_minChanged', | ||
}, | ||
@@ -159,3 +158,2 @@ | ||
type: Number, | ||
observer: '_maxChanged', | ||
}, | ||
@@ -169,4 +167,2 @@ | ||
type: Number, | ||
value: 1, | ||
observer: '_stepChanged', | ||
}, | ||
@@ -176,2 +172,10 @@ }; | ||
static get observers() { | ||
return ['_stepChanged(step, inputElement)']; | ||
} | ||
static get delegateProps() { | ||
return [...super.delegateProps, 'min', 'max']; | ||
} | ||
static get constraints() { | ||
@@ -233,6 +237,2 @@ return [...super.constraints, 'min', 'max', 'step']; | ||
this.inputElement.min = this.min; | ||
this.inputElement.max = this.max; | ||
this.__applyStep(this.step); | ||
this.addController(new LabelledInputController(this.inputElement, this._labelController)); | ||
@@ -255,19 +255,2 @@ } | ||
/** | ||
* @protected | ||
* @override | ||
*/ | ||
_constraintsChanged(required, min, max, _step) { | ||
if (!this.invalid) { | ||
return; | ||
} | ||
const isNumUnset = (n) => !n && n !== 0; | ||
if (!isNumUnset(min) || !isNumUnset(max)) { | ||
this.validate(); | ||
} else if (!required) { | ||
this._setInvalid(false); | ||
} | ||
} | ||
/** @private */ | ||
@@ -289,2 +272,3 @@ _decreaseValue() { | ||
const step = this.step || 1; | ||
let value = parseFloat(this.value); | ||
@@ -308,7 +292,7 @@ | ||
incr = 0; | ||
} else if (this._getIncrement(1, value - this.step) > this.max) { | ||
value -= 2 * this.step; | ||
} else if (this._getIncrement(1, value - step) > this.max) { | ||
value -= 2 * step; | ||
// FIXME(yuriy): find a proper solution to make correct step back | ||
} else { | ||
value -= this.step; | ||
value -= step; | ||
} | ||
@@ -389,41 +373,13 @@ } | ||
/** @private */ | ||
__applyStep(step) { | ||
if (this.inputElement) { | ||
this.inputElement.step = this.__validateByStep ? step : 'any'; | ||
} | ||
} | ||
/** | ||
* @param {number} newVal | ||
* @param {number | undefined} oldVal | ||
* @param {number} step | ||
* @param {HTMLElement | undefined} inputElement | ||
* @protected | ||
*/ | ||
_stepChanged(newVal) { | ||
// TODO: refactor to not have initial value | ||
// https://github.com/vaadin/vaadin-text-field/issues/435 | ||
// Avoid using initial value in validation | ||
this.__validateByStep = this.__stepChangedCalled || this.getAttribute('step') !== null; | ||
this.__applyStep(newVal); | ||
this.__stepChangedCalled = true; | ||
this.setAttribute('step', newVal); | ||
} | ||
/** @private */ | ||
_minChanged(min) { | ||
if (this.inputElement) { | ||
this.inputElement.min = min; | ||
_stepChanged(step, inputElement) { | ||
if (inputElement) { | ||
inputElement.step = step || 'any'; | ||
} | ||
} | ||
/** @private */ | ||
_maxChanged(max) { | ||
if (this.inputElement) { | ||
this.inputElement.max = max; | ||
} | ||
} | ||
/** | ||
@@ -464,18 +420,4 @@ * @param {unknown} newVal | ||
} | ||
/** | ||
* Returns true if the current input value satisfies all constraints (if any). | ||
* @return {boolean} | ||
*/ | ||
checkValidity() { | ||
if ( | ||
this.inputElement && | ||
(this.required || this.min !== undefined || this.max !== undefined || this.__validateByStep) | ||
) { | ||
return this.inputElement.checkValidity(); | ||
} | ||
return !this.invalid; | ||
} | ||
} | ||
customElements.define(NumberField.is, NumberField); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
58952
13
1289
+ Added@vaadin/component-base@23.2.0-alpha4(transitive)
+ Added@vaadin/field-base@23.2.0-alpha4(transitive)
+ Added@vaadin/icon@23.2.0-alpha4(transitive)
+ Added@vaadin/input-container@23.2.0-alpha4(transitive)
+ Added@vaadin/vaadin-lumo-styles@23.2.0-alpha4(transitive)
+ Added@vaadin/vaadin-material-styles@23.2.0-alpha4(transitive)
+ Added@vaadin/vaadin-themable-mixin@23.2.0-alpha4(transitive)
- Removed@vaadin/component-base@23.2.0-alpha3(transitive)
- Removed@vaadin/field-base@23.2.0-alpha3(transitive)
- Removed@vaadin/icon@23.2.0-alpha3(transitive)
- Removed@vaadin/input-container@23.2.0-alpha3(transitive)
- Removed@vaadin/vaadin-lumo-styles@23.2.0-alpha3(transitive)
- Removed@vaadin/vaadin-material-styles@23.2.0-alpha3(transitive)
- Removed@vaadin/vaadin-themable-mixin@23.2.0-alpha3(transitive)