Commit 1d797a09 authored by Hector Carmona's avatar Hector Carmona Committed by Commit Bot

WebUI: Update Polymer paper-input version 2.1.0 -> 2.2.2

This is in preparation of updating iron-input to its latest version

Bug: 812926
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I6cbcb4869fadac14956ac5c9e9a9d3d7289dda46
Reviewed-on: https://chromium-review.googlesource.com/1026639
Commit-Queue: Hector Carmona <hcarmona@chromium.org>
Reviewed-by: default avatarDemetrios Papadopoulos <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#553624}
parent 8a251470
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
"paper-checkbox": "PolymerElements/paper-checkbox#2.0.2", "paper-checkbox": "PolymerElements/paper-checkbox#2.0.2",
"paper-fab": "PolymerElements/paper-fab#2.0.0", "paper-fab": "PolymerElements/paper-fab#2.0.0",
"paper-icon-button": "PolymerElements/paper-icon-button#2.1.0", "paper-icon-button": "PolymerElements/paper-icon-button#2.1.0",
"paper-input": "PolymerElements/paper-input#2.1.0", "paper-input": "PolymerElements/paper-input#2.2.2",
"paper-item": "PolymerElements/paper-item#2.0.0", "paper-item": "PolymerElements/paper-item#2.0.0",
"paper-listbox": "PolymerelEments/paper-listbox#2.0.0", "paper-listbox": "PolymerelEments/paper-listbox#2.0.0",
"paper-progress": "PolymerElements/paper-progress#2.0.1", "paper-progress": "PolymerElements/paper-progress#2.0.1",
......
{ {
"name": "paper-input", "name": "paper-input",
"version": "2.1.0", "version": "2.2.2",
"description": "Material design text fields", "description": "Material design text fields",
"authors": [ "authors": [
"The Polymer Authors" "The Polymer Authors"
......
...@@ -14,9 +14,9 @@ ...@@ -14,9 +14,9 @@
/** /**
* The function called by `<paper-input-container>` when the input value or validity changes. * The function called by `<paper-input-container>` when the input value or validity changes.
* @param {{ * @param {{
* invalid: boolean,
* inputElement: (Element|undefined), * inputElement: (Element|undefined),
* value: (string|undefined), * value: (string|undefined)
* invalid: boolean
* }} state - * }} state -
* inputElement: The input element. * inputElement: The input element.
* value: The input value. * value: The input value.
......
...@@ -338,16 +338,19 @@ ...@@ -338,16 +338,19 @@
type: Boolean type: Boolean
}, },
/** @private */
_ariaDescribedBy: { _ariaDescribedBy: {
type: String, type: String,
value: '' value: ''
}, },
/** @private */
_ariaLabelledBy: { _ariaLabelledBy: {
type: String, type: String,
value: '' value: ''
}, },
/** @private */
_inputId: { _inputId: {
type: String, type: String,
value: '' value: ''
...@@ -358,16 +361,21 @@ ...@@ -358,16 +361,21 @@
'addon-attached': '_onAddonAttached', 'addon-attached': '_onAddonAttached',
}, },
/**
* @type {!Object}
*/
keyBindings: { keyBindings: {
'shift+tab:keydown': '_onShiftTabDown' 'shift+tab:keydown': '_onShiftTabDown'
}, },
/** @private */
hostAttributes: { hostAttributes: {
tabindex: 0 tabindex: 0
}, },
/** /**
* Returns a reference to the input element. * Returns a reference to the input element.
* @return {!HTMLElement}
*/ */
get inputElement() { get inputElement() {
// Chrome generates audit errors if an <input type="password"> has a // Chrome generates audit errors if an <input type="password"> has a
...@@ -385,6 +393,7 @@ ...@@ -385,6 +393,7 @@
/** /**
* Returns a reference to the focusable element. * Returns a reference to the focusable element.
* @return {!HTMLElement}
*/ */
get _focusableElement() { get _focusableElement() {
return this.inputElement; return this.inputElement;
......
...@@ -123,6 +123,12 @@ Polymer({ ...@@ -123,6 +123,12 @@ Polymer({
}, },
ready: function() { ready: function() {
// Paper-input treats a value of undefined differently at startup than
// the rest of the time (specifically: it does not validate it at startup, but
// it does after that. We need to track whether the first time we encounter
// the value is basically this first time, so that we can validate it
// correctly the rest of the time. See https://github.com/PolymerElements/paper-input/issues/605
this.__isFirstValueUpdate = true;
if (!this._addons) { if (!this._addons) {
this._addons = []; this._addons = [];
} }
...@@ -145,6 +151,7 @@ Polymer({ ...@@ -145,6 +151,7 @@ Polymer({
} }
}, },
/** @private */
_onAddonAttached: function(event) { _onAddonAttached: function(event) {
if (!this._addons) { if (!this._addons) {
this._addons = []; this._addons = [];
...@@ -158,37 +165,41 @@ Polymer({ ...@@ -158,37 +165,41 @@ Polymer({
} }
}, },
/** @private */
_onFocus: function() { _onFocus: function() {
this._setFocused(true); this._setFocused(true);
}, },
/** @private */
_onBlur: function() { _onBlur: function() {
this._setFocused(false); this._setFocused(false);
this._handleValueAndAutoValidate(this._inputElement); this._handleValueAndAutoValidate(this._inputElement);
}, },
/** @private */
_onInput: function(event) { _onInput: function(event) {
this._handleValueAndAutoValidate(event.target); this._handleValueAndAutoValidate(event.target);
}, },
/** @private */
_onValueChanged: function(event) { _onValueChanged: function(event) {
var input = event.target; var input = event.target;
// Problem: if the input is required but has no text entered, we should // Paper-input treats a value of undefined differently at startup than
// only validate it on blur (so that an empty form doesn't come up red // the rest of the time (specifically: it does not validate it at startup, but
// immediately; however, in this handler, we don't know whether this is // it does after that. If this is in fact the bootup case, ignore validation,
// the booting up value or a value in the future. I am assuming that the // just this once.
// case we care about manifests itself when the value is undefined. if (this.__isFirstValueUpdate) {
// If this causes future problems, we need to do something like track whether this.__isFirstValueUpdate = false;
// the iron-input-ready event has fired, and this handler came before that.
if (input.value === undefined) { if (input.value === undefined) {
return; return;
} }
}
this._handleValueAndAutoValidate(event.target); this._handleValueAndAutoValidate(event.target);
}, },
/** @private */
_handleValue: function(inputElement) { _handleValue: function(inputElement) {
var value = this._inputElementValue; var value = this._inputElementValue;
...@@ -206,6 +217,7 @@ Polymer({ ...@@ -206,6 +217,7 @@ Polymer({
}); });
}, },
/** @private */
_handleValueAndAutoValidate: function(inputElement) { _handleValueAndAutoValidate: function(inputElement) {
if (this.autoValidate && inputElement) { if (this.autoValidate && inputElement) {
var valid; var valid;
...@@ -222,10 +234,12 @@ Polymer({ ...@@ -222,10 +234,12 @@ Polymer({
this._handleValue(inputElement); this._handleValue(inputElement);
}, },
/** @private */
_onIronInputValidate: function(event) { _onIronInputValidate: function(event) {
this.invalid = this._inputElement.invalid; this.invalid = this._inputElement.invalid;
}, },
/** @private */
_invalidChanged: function() { _invalidChanged: function() {
if (this._addons) { if (this._addons) {
this.updateAddons({invalid: this.invalid}); this.updateAddons({invalid: this.invalid});
...@@ -242,6 +256,7 @@ Polymer({ ...@@ -242,6 +256,7 @@ Polymer({
} }
}, },
/** @private */
_computeInputContentClass: function(noLabelFloat, alwaysFloatLabel, focused, invalid, _inputHasContent) { _computeInputContentClass: function(noLabelFloat, alwaysFloatLabel, focused, invalid, _inputHasContent) {
var cls = 'input-content'; var cls = 'input-content';
if (!noLabelFloat) { if (!noLabelFloat) {
...@@ -281,6 +296,7 @@ Polymer({ ...@@ -281,6 +296,7 @@ Polymer({
return cls; return cls;
}, },
/** @private */
_computeUnderlineClass: function(focused, invalid) { _computeUnderlineClass: function(focused, invalid) {
var cls = 'underline'; var cls = 'underline';
if (invalid) { if (invalid) {
...@@ -291,6 +307,7 @@ Polymer({ ...@@ -291,6 +307,7 @@ Polymer({
return cls; return cls;
}, },
/** @private */
_computeAddOnContentClass: function(focused, invalid) { _computeAddOnContentClass: function(focused, invalid) {
var cls = 'add-on-content'; var cls = 'add-on-content';
if (invalid) { if (invalid) {
......
...@@ -102,6 +102,7 @@ Custom property | Description | Default ...@@ -102,6 +102,7 @@ Custom property | Description | Default
`--paper-input-container-input-invalid` | Mixin applied to the input when invalid | `{}` `--paper-input-container-input-invalid` | Mixin applied to the input when invalid | `{}`
`--paper-input-container-input-webkit-spinner` | Mixin applied to the webkit spinner | `{}` `--paper-input-container-input-webkit-spinner` | Mixin applied to the webkit spinner | `{}`
`--paper-input-container-input-webkit-clear` | Mixin applied to the webkit clear button | `{}` `--paper-input-container-input-webkit-clear` | Mixin applied to the webkit clear button | `{}`
`--paper-input-container-input-webkit-calendar-picker-indicator` | Mixin applied to the webkit calendar picker indicator | `{}`
`--paper-input-container-ms-clear` | Mixin applied to the Internet Explorer clear button | `{}` `--paper-input-container-ms-clear` | Mixin applied to the Internet Explorer clear button | `{}`
`--paper-input-container-underline` | Mixin applied to the underline | `{}` `--paper-input-container-underline` | Mixin applied to the underline | `{}`
`--paper-input-container-underline-focus` | Mixin applied to the underline when the input is focused | `{}` `--paper-input-container-underline-focus` | Mixin applied to the underline when the input is focused | `{}`
...@@ -113,18 +114,15 @@ This element is `display:block` by default, but you can set the `inline` attribu ...@@ -113,18 +114,15 @@ This element is `display:block` by default, but you can set the `inline` attribu
`display:inline-block`. `display:inline-block`.
--> -->
</head><body><dom-module id="paper-input-container"> </head><body><custom-style>
<template> <style is="custom-style">
<style> html {
:host {
display: block;
padding: 8px 0;
--paper-input-container-shared-input-style: { --paper-input-container-shared-input-style: {
position: relative; /* to make a stacking context */ position: relative; /* to make a stacking context */
outline: none; outline: none;
box-shadow: none; box-shadow: none;
padding: 0; padding: 0;
margin: 0;
width: 100%; width: 100%;
max-width: 100%; max-width: 100%;
background: transparent; background: transparent;
...@@ -136,7 +134,16 @@ This element is `display:block` by default, but you can set the `inline` attribu ...@@ -136,7 +134,16 @@ This element is `display:block` by default, but you can set the `inline` attribu
@apply --paper-font-subhead; @apply --paper-font-subhead;
}; };
}
</style>
</custom-style>
<dom-module id="paper-input-container">
<template>
<style>
:host {
display: block;
padding: 8px 0;
@apply --paper-input-container; @apply --paper-input-container;
} }
...@@ -271,15 +278,15 @@ This element is `display:block` by default, but you can set the `inline` attribu ...@@ -271,15 +278,15 @@ This element is `display:block` by default, but you can set the `inline` attribu
visibility: hidden; visibility: hidden;
} }
.input-content ::slotted(iron-input) {
@apply --paper-input-container-shared-input-style;
}
.input-content ::slotted(input), .input-content ::slotted(input),
.input-content ::slotted(iron-input),
.input-content ::slotted(textarea), .input-content ::slotted(textarea),
.input-content ::slotted(iron-autogrow-textarea), .input-content ::slotted(iron-autogrow-textarea),
.input-content ::slotted(.paper-input-input) { .input-content ::slotted(.paper-input-input) {
@apply --paper-input-container-shared-input-style; @apply --paper-input-container-shared-input-style;
/* The apply shim doesn't apply the nested color custom property,
so we have to re-apply it here. */
color: var(--paper-input-container-input-color, var(--primary-text-color));
@apply --paper-input-container-input; @apply --paper-input-container-input;
} }
...@@ -289,6 +296,7 @@ This element is `display:block` by default, but you can set the `inline` attribu ...@@ -289,6 +296,7 @@ This element is `display:block` by default, but you can set the `inline` attribu
} }
.input-content.focused ::slotted(input), .input-content.focused ::slotted(input),
.input-content.focused ::slotted(iron-input),
.input-content.focused ::slotted(textarea), .input-content.focused ::slotted(textarea),
.input-content.focused ::slotted(iron-autogrow-textarea), .input-content.focused ::slotted(iron-autogrow-textarea),
.input-content.focused ::slotted(.paper-input-input) { .input-content.focused ::slotted(.paper-input-input) {
...@@ -296,6 +304,7 @@ This element is `display:block` by default, but you can set the `inline` attribu ...@@ -296,6 +304,7 @@ This element is `display:block` by default, but you can set the `inline` attribu
} }
.input-content.is-invalid ::slotted(input), .input-content.is-invalid ::slotted(input),
.input-content.is-invalid ::slotted(iron-input),
.input-content.is-invalid ::slotted(textarea), .input-content.is-invalid ::slotted(textarea),
.input-content.is-invalid ::slotted(iron-autogrow-textarea), .input-content.is-invalid ::slotted(iron-autogrow-textarea),
.input-content.is-invalid ::slotted(.paper-input-input) { .input-content.is-invalid ::slotted(.paper-input-input) {
......
...@@ -26,6 +26,8 @@ Polymer({ ...@@ -26,6 +26,8 @@ Polymer({
/** /**
* Returns a reference to the focusable element. Overridden from PaperInputBehavior * Returns a reference to the focusable element. Overridden from PaperInputBehavior
* to correctly focus the native input. * to correctly focus the native input.
*
* @return {!HTMLElement}
*/ */
get _focusableElement() { get _focusableElement() {
return Polymer.Element ? this.inputElement._inputElement : this.inputElement; return Polymer.Element ? this.inputElement._inputElement : this.inputElement;
......
...@@ -87,25 +87,25 @@ Custom property | Description | Default ...@@ -87,25 +87,25 @@ Custom property | Description | Default
} }
input { input {
position: relative; /* to make a stacking context */
outline: none;
box-shadow: none;
margin: 0;
padding: 0;
width: 100%;
max-width: 100%;
background: transparent;
border: none;
color: var(--paper-input-container-input-color, var(--primary-text-color));
-webkit-appearance: none;
text-align: inherit;
vertical-align: bottom;
/* Firefox sets a min-width on the input, which can cause layout issues */ /* Firefox sets a min-width on the input, which can cause layout issues */
min-width: 0; min-width: 0;
}
@apply --paper-font-subhead; /* In 1.x, the <input> is distributed to paper-input-container, which styles it.
@apply --paper-input-container-input; In 2.x the <iron-input> is distributed to paper-input-container, which styles
it, but in order for this to work correctly, we need to reset some
of the native input's properties to inherit (from the iron-input) */
iron-input > input {
@apply --paper-input-container-shared-input-style;
font-family: inherit;
font-weight: inherit;
font-size: inherit;
letter-spacing: inherit;
word-spacing: inherit;
line-height: inherit;
text-shadow: inherit;
color: inherit;
cursor: inherit;
} }
input:disabled { input:disabled {
...@@ -121,6 +121,10 @@ Custom property | Description | Default ...@@ -121,6 +121,10 @@ Custom property | Description | Default
@apply --paper-input-container-input-webkit-clear; @apply --paper-input-container-input-webkit-clear;
} }
input::-webkit-calendar-picker-indicator {
@apply --paper-input-container-input-webkit-calendar-picker-indicator;
}
input::-webkit-input-placeholder { input::-webkit-input-placeholder {
color: var(--paper-input-container-color, var(--secondary-text-color)); color: var(--paper-input-container-color, var(--secondary-text-color));
} }
......
...@@ -43,6 +43,9 @@ Polymer({ ...@@ -43,6 +43,9 @@ Polymer({
}, },
}, },
/**
* @return {number}
*/
get selectionStart() { get selectionStart() {
return this.$.input.textarea.selectionStart; return this.$.input.textarea.selectionStart;
}, },
...@@ -50,6 +53,9 @@ Polymer({ ...@@ -50,6 +53,9 @@ Polymer({
this.$.input.textarea.selectionStart = start; this.$.input.textarea.selectionStart = start;
}, },
/**
* @return {number}
*/
get selectionEnd() { get selectionEnd() {
return this.$.input.textarea.selectionEnd; return this.$.input.textarea.selectionEnd;
}, },
......
...@@ -216,9 +216,9 @@ Tree link: https://github.com/PolymerElements/paper-icon-button/tree/v2.1.0 ...@@ -216,9 +216,9 @@ Tree link: https://github.com/PolymerElements/paper-icon-button/tree/v2.1.0
Name: paper-input Name: paper-input
Repository: https://github.com/PolymerElements/paper-input.git Repository: https://github.com/PolymerElements/paper-input.git
Tree: v2.1.0 Tree: v2.2.2
Revision: 6a45a9d7495078e56b04a944635f70c1c67f3c23 Revision: a89e8f491d01c77e167a4361d0535683591e0a01
Tree link: https://github.com/PolymerElements/paper-input/tree/v2.1.0 Tree link: https://github.com/PolymerElements/paper-input/tree/v2.2.2
Name: paper-item Name: paper-item
Repository: https://github.com/PolymerElements/paper-item.git Repository: https://github.com/PolymerElements/paper-item.git
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment