Skip to content

Commit

Permalink
Merge branch '1.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
web-padawan committed Jan 8, 2021
2 parents 7990f46 + 7701034 commit 120116e
Show file tree
Hide file tree
Showing 22 changed files with 448 additions and 32 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
@@ -1,14 +1,14 @@
sudo: false
dist: xenial
language: node_js
node_js: 8.11
node_js: 10.23

cache:
directories:
- node_modules

addons:
firefox: "66.0"
firefox: latest
chrome: stable

jobs:
Expand All @@ -22,12 +22,12 @@ jobs:
- if: type = pull_request
env: POLYMER=2
addons:
firefox: "66.0"
firefox: latest
chrome: stable
- if: type = pull_request
env: POLYMER=3
addons:
firefox: "66.0"
firefox: latest
chrome: stable
- if: type = cron
env: TEST_SUITE=unit_tests POLYMER=2
Expand Down
17 changes: 7 additions & 10 deletions bower.json
Expand Up @@ -29,22 +29,19 @@
],
"dependencies": {
"polymer": "^2.0.0",
"vaadin-control-state-mixin": "vaadin/vaadin-control-state-mixin#^2.1.1",
"vaadin-themable-mixin": "vaadin/vaadin-themable-mixin#^1.2.1",
"vaadin-lumo-styles": "vaadin/vaadin-lumo-styles#^1.2.0",
"vaadin-material-styles": "vaadin/vaadin-material-styles#^1.2.0",
"vaadin-element-mixin": "vaadin/vaadin-element-mixin#^2.3.0"
"vaadin-control-state-mixin": "vaadin/vaadin-control-state-mixin#^2.2.1",
"vaadin-themable-mixin": "vaadin/vaadin-themable-mixin#^1.6.1",
"vaadin-lumo-styles": "vaadin/vaadin-lumo-styles#^1.6.0",
"vaadin-material-styles": "vaadin/vaadin-material-styles#^1.3.2",
"vaadin-element-mixin": "vaadin/vaadin-element-mixin#^2.4.1"
},
"devDependencies": {
"iron-component-page": "^3.0.0",
"iron-form": "^2.0.0",
"iron-test-helpers": "^2.0.0",
"vaadin-button": "vaadin/vaadin-button#^2.1.0",
"vaadin-button": "vaadin/vaadin-button#^2.4.0",
"webcomponentsjs": "^1.0.0",
"web-component-tester": "^6.1.5",
"vaadin-demo-helpers": "vaadin/vaadin-demo-helpers#^3.0.0"
},
"resolutions": {
"vaadin-element-mixin": "^2.0.0"
"vaadin-demo-helpers": "vaadin/vaadin-demo-helpers#^3.1.0"
}
}
17 changes: 15 additions & 2 deletions demo/radio-button-basic-demos.html
Expand Up @@ -46,6 +46,19 @@ <h3>Read-only</h3>
</template>
</vaadin-demo-snippet>

<h3>Helper text</h3>
<p>Use the <code>helper-text</code> attribute or add content to the <code>helper</code> slot to set helper content.</p>
<vaadin-demo-snippet id="basic-demos-helper-text">
<template preserve-content>
<vaadin-radio-group label="Label" theme="vertical">
<span slot="helper">Select an option</span>
<vaadin-radio-button checked>Option one</vaadin-radio-button>
<vaadin-radio-button>Option two</vaadin-radio-button>
<vaadin-radio-button>Option three</vaadin-radio-button>
</vaadin-radio-group>
</template>
</vaadin-demo-snippet>

<h3>Object list</h3>
<vaadin-demo-snippet id="object-list" when-defined="vaadin-radio-button">
<template preserve-content>
Expand Down Expand Up @@ -78,12 +91,12 @@ <h3>Value change event</h3>
<vaadin-radio-button value="two">Option two</vaadin-radio-button>
<vaadin-radio-button value="three">Option three</vaadin-radio-button>
</vaadin-radio-group>
<div id="output">Selected value:</div>
<div>Selected value: <span id="output"></span></div>
<script>
window.addDemoReadyListener('#value-change-event', function(document) {
const radioButtonGroup = document.querySelector('vaadin-radio-group');
const output = document.querySelector('#output');
radioButtonGroup.addEventListener('value-changed', function(event) {
radioButtonGroup.addEventListener('change', function(event) {
output.textContent = radioButtonGroup.value;
});
});
Expand Down
19 changes: 19 additions & 0 deletions demo/radio-button-theme-variants-demos.html
Expand Up @@ -24,6 +24,25 @@ <h4>Vertical</h4>
</template>
</vaadin-demo-snippet>

<h3>Helper text position</h3>
<vaadin-demo-snippet id="theme-demos-helper-text-position">
<template preserve-content>
<h4>Below</h4>
<vaadin-radio-group label="Label" helper-text="Helper text below">
<vaadin-radio-button checked>Option one</vaadin-radio-button>
<vaadin-radio-button>Option two</vaadin-radio-button>
<vaadin-radio-button>Option three</vaadin-radio-button>
</vaadin-radio-group>

<h4>Above</h4>
<vaadin-radio-group label="Label" helper-text="Helper text above" theme="helper-above-field">
<vaadin-radio-button checked>Option one</vaadin-radio-button>
<vaadin-radio-button>Option two</vaadin-radio-button>
<vaadin-radio-button>Option three</vaadin-radio-button>
</vaadin-radio-group>
</template>
</vaadin-demo-snippet>


</template>
<script>
Expand Down
9 changes: 9 additions & 0 deletions gen-tsd.json
@@ -0,0 +1,9 @@
{
"excludeFiles": [
"wct.conf.js",
"index.html",
"demo/**/*",
"test/**/*",
"theme/**/*"
]
}
12 changes: 12 additions & 0 deletions magi-p3-post.js
@@ -0,0 +1,12 @@
module.exports = {
files: [
'vaadin-radio-button.js',
'vaadin-radio-group.js'
],
from: [
/import '\.\/theme\/lumo\/vaadin-(.+)\.js';/
],
to: [
`import './theme/lumo/vaadin-$1.js';\nexport * from './src/vaadin-$1.js';`
]
};
3 changes: 2 additions & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "@vaadin/vaadin-radio-button",
"version": "1.2.3",
"version": "1.5.1",
"description": "vaadin-radio-button",
"main": "vaadin-radio-button.html",
"repository": "vaadin/vaadin-radio-button",
Expand All @@ -19,6 +19,7 @@
},
"homepage": "https://vaadin.com/components",
"files": [
"vaadin-*.d.ts",
"vaadin-*.js",
"src",
"theme"
Expand Down
34 changes: 29 additions & 5 deletions src/vaadin-radio-button.html
Expand Up @@ -50,7 +50,7 @@
<span part="radio">
<input
type="radio"
checked="{{checked::change}}"
checked="[[checked]]"
disabled$="[[disabled]]"
role="presentation"
on-change="_onChange"
Expand Down Expand Up @@ -112,13 +112,14 @@
}

static get version() {
return '1.2.3';
return '1.5.1';
}

static get properties() {
return {
/**
* True if the radio button is checked.
* @type {boolean}
*/
checked: {
type: Boolean,
Expand All @@ -135,6 +136,7 @@

/**
* The value for this element.
* @type {string}
*/
value: {
type: String,
Expand All @@ -152,6 +154,9 @@
}

/**
* @param {string} prop
* @param {?string} oldVal
* @param {?string} newVal
* @protected
*/
attributeChangedCallback(prop, oldVal, newVal) {
Expand All @@ -173,7 +178,7 @@
}
}


/** @protected */
ready() {
super.ready();

Expand All @@ -192,6 +197,7 @@
this._updateLabelAttribute();
}

/** @private */
_updateLabelAttribute() {
const label = this.shadowRoot.querySelector('[part~="label"]');
const assignedNodes = label.firstElementChild.assignedNodes();
Expand All @@ -202,6 +208,7 @@
}
}

/** @private */
_isAssignedNodesEmpty(nodes) {
// The assigned nodes considered to be empty if there is no slotted content or only one empty text node
return nodes.length === 0 ||
Expand All @@ -210,10 +217,12 @@
&& nodes[0].textContent.trim() === '');
}

/** @private */
_checkedChanged(checked) {
this.setAttribute('aria-checked', checked);
}

/** @private */
_addListeners() {
this._addEventListenerToNode(this, 'down', (e) => {
if (!this.disabled) {
Expand All @@ -225,6 +234,10 @@
this.removeAttribute('active');

if (!this.checked && !this.disabled) {
// If you change this block, please test manually that radio-button and
// radio-group still works ok on iOS 12/13 and up as it may cause
// an issue that is not possible to test programmatically.
// See: https://github.com/vaadin/vaadin-radio-button/issues/140
this.click();
}
});
Expand All @@ -251,15 +264,26 @@
* @protected
*/
click() {
this.shadowRoot.querySelector('input').click();
// If you change this block, please test manually that radio-button and
// radio-group still works ok on iOS 12/13 and up as it may cause
// an issue that is not possible to test programmatically.
// See: https://github.com/vaadin/vaadin-radio-button/issues/140
if (!this.disabled) {
this.shadowRoot.querySelector('input').dispatchEvent(new MouseEvent('click'));
}
}

/** @protected */
/**
* @return {!HTMLInputElement}
* @protected
*/
get focusElement() {
return this.shadowRoot.querySelector('input');
}

/** @private */
_onChange(e) {
this.checked = e.target.checked;
// In the Shadow DOM, the `change` event is not leaked into the
// ancestor tree, so we must do this manually.
const changeEvent = new CustomEvent('change', {
Expand Down

0 comments on commit 120116e

Please sign in to comment.