@polymer/iron-selector
Advanced tools
Comparing version 3.0.0-pre.19 to 3.0.0-pre.20
@@ -23,11 +23,7 @@ /** | ||
*/ | ||
multi: { | ||
type: Boolean, | ||
value: false, | ||
observer: 'multiChanged' | ||
}, | ||
multi: {type: Boolean, value: false, observer: 'multiChanged'}, | ||
/** | ||
* Gets or sets the selected elements. This is used instead of `selected` when `multi` | ||
* is true. | ||
* Gets or sets the selected elements. This is used instead of `selected` | ||
* when `multi` is true. | ||
*/ | ||
@@ -56,9 +52,8 @@ selectedValues: { | ||
observers: [ | ||
'_updateSelected(selectedValues.splices)' | ||
], | ||
observers: ['_updateSelected(selectedValues.splices)'], | ||
/** | ||
* Selects the given value. If the `multi` property is true, then the selected state of the | ||
* `value` will be toggled; otherwise the `value` will be selected. | ||
* Selects the given value. If the `multi` property is true, then the selected | ||
* state of the `value` will be toggled; otherwise the `value` will be | ||
* selected. | ||
* | ||
@@ -84,3 +79,3 @@ * @method select | ||
return this.selected != null || | ||
(this.selectedValues != null && this.selectedValues.length); | ||
(this.selectedValues != null && this.selectedValues.length); | ||
}, | ||
@@ -92,7 +87,12 @@ | ||
} else if (this.selectedItems && this.selectedItems.length > 0) { | ||
this.selectedValues = this.selectedItems.map(function(selectedItem) { | ||
return this._indexToValue(this.indexOf(selectedItem)); | ||
}, this).filter(function(unfilteredValue) { | ||
return unfilteredValue != null; | ||
}, this); | ||
this.selectedValues = | ||
this.selectedItems | ||
.map( | ||
function(selectedItem) { | ||
return this._indexToValue(this.indexOf(selectedItem)); | ||
}, | ||
this) | ||
.filter(function(unfilteredValue) { | ||
return unfilteredValue != null; | ||
}, this); | ||
} | ||
@@ -112,5 +112,6 @@ }, | ||
var selectedItems = (this._valuesToItems(values) || []).filter(function(item) { | ||
return item !== null && item !== undefined; | ||
}); | ||
var selectedItems = | ||
(this._valuesToItems(values) || []).filter(function(item) { | ||
return item !== null && item !== undefined; | ||
}); | ||
@@ -154,5 +155,5 @@ // clear all but the current selected items | ||
if (unselected) { | ||
this.push('selectedValues',value); | ||
this.push('selectedValues', value); | ||
} else { | ||
this.splice('selectedValues',i,1); | ||
this.splice('selectedValues', i, 1); | ||
} | ||
@@ -169,5 +170,2 @@ }, | ||
/** @polymerBehavior */ | ||
export const IronMultiSelectableBehavior = [ | ||
IronSelectableBehavior, | ||
IronMultiSelectableBehaviorImpl | ||
]; | ||
export const IronMultiSelectableBehavior = [IronSelectableBehavior, IronMultiSelectableBehaviorImpl]; |
@@ -21,29 +21,29 @@ /** | ||
/** | ||
* Fired when iron-selector is activated (selected or deselected). | ||
* It is fired before the selected items are changed. | ||
* Cancel the event to abort selection. | ||
* | ||
* @event iron-activate | ||
*/ | ||
/** | ||
* Fired when iron-selector is activated (selected or deselected). | ||
* It is fired before the selected items are changed. | ||
* Cancel the event to abort selection. | ||
* | ||
* @event iron-activate | ||
*/ | ||
/** | ||
* Fired when an item is selected | ||
* | ||
* @event iron-select | ||
*/ | ||
/** | ||
* Fired when an item is selected | ||
* | ||
* @event iron-select | ||
*/ | ||
/** | ||
* Fired when an item is deselected | ||
* | ||
* @event iron-deselect | ||
*/ | ||
/** | ||
* Fired when an item is deselected | ||
* | ||
* @event iron-deselect | ||
*/ | ||
/** | ||
* Fired when the list of selectable items changes (e.g., items are | ||
* added or removed). The detail of the event is a mutation record that | ||
* describes what changed. | ||
* | ||
* @event iron-items-changed | ||
*/ | ||
/** | ||
* Fired when the list of selectable items changes (e.g., items are | ||
* added or removed). The detail of the event is a mutation record that | ||
* describes what changed. | ||
* | ||
* @event iron-items-changed | ||
*/ | ||
@@ -62,15 +62,10 @@ properties: { | ||
*/ | ||
attrForSelected: { | ||
type: String, | ||
value: null | ||
}, | ||
attrForSelected: {type: String, value: null}, | ||
/** | ||
* Gets or sets the selected element. The default is to use the index of the item. | ||
* Gets or sets the selected element. The default is to use the index of the | ||
* item. | ||
* @type {string|number} | ||
*/ | ||
selected: { | ||
type: String, | ||
notify: true | ||
}, | ||
selected: {type: String, notify: true}, | ||
@@ -82,7 +77,3 @@ /** | ||
*/ | ||
selectedItem: { | ||
type: Object, | ||
readOnly: true, | ||
notify: true | ||
}, | ||
selectedItem: {type: Object, readOnly: true, notify: true}, | ||
@@ -94,11 +85,8 @@ /** | ||
*/ | ||
activateEvent: { | ||
type: String, | ||
value: 'tap', | ||
observer: '_activateEventChanged' | ||
}, | ||
activateEvent: | ||
{type: String, value: 'tap', observer: '_activateEventChanged'}, | ||
/** | ||
* This is a CSS selector string. If this is set, only items that match the CSS selector | ||
* are selectable. | ||
* This is a CSS selector string. If this is set, only items that match the | ||
* CSS selector are selectable. | ||
*/ | ||
@@ -110,6 +98,3 @@ selectable: String, | ||
*/ | ||
selectedClass: { | ||
type: String, | ||
value: 'iron-selected' | ||
}, | ||
selectedClass: {type: String, value: 'iron-selected'}, | ||
@@ -119,15 +104,9 @@ /** | ||
*/ | ||
selectedAttribute: { | ||
type: String, | ||
value: null | ||
}, | ||
selectedAttribute: {type: String, value: null}, | ||
/** | ||
* Default fallback if the selection based on selected with `attrForSelected` | ||
* is not found. | ||
* Default fallback if the selection based on selected with | ||
* `attrForSelected` is not found. | ||
*/ | ||
fallbackSelection: { | ||
type: String, | ||
value: null | ||
}, | ||
fallbackSelection: {type: String, value: null}, | ||
@@ -173,3 +152,4 @@ /** | ||
this._bindFilterItem = this._filterItem.bind(this); | ||
this._selection = new IronSelection(this._applySelection.bind(this)); | ||
this._selection = | ||
new IronSelection(this._applySelection.bind(this)); | ||
}, | ||
@@ -217,3 +197,6 @@ | ||
var length = this.items.length; | ||
var index = (Number(this._valueToIndex(this.selected)) - 1 + length) % length; | ||
var index = length - 1; | ||
if (this.selected !== undefined) { | ||
index = (Number(this._valueToIndex(this.selected)) - 1 + length) % length; | ||
} | ||
this.selected = this._indexToValue(index); | ||
@@ -228,3 +211,7 @@ }, | ||
selectNext: function() { | ||
var index = (Number(this._valueToIndex(this.selected)) + 1) % this.items.length; | ||
var index = 0; | ||
if (this.selected !== undefined) { | ||
index = | ||
(Number(this._valueToIndex(this.selected)) + 1) % this.items.length; | ||
} | ||
this.selected = this._indexToValue(index); | ||
@@ -255,3 +242,3 @@ }, | ||
forceSynchronousItemUpdate: function() { | ||
if (this._observer && typeof this._observer.flush === "function") { | ||
if (this._observer && typeof this._observer.flush === 'function') { | ||
// NOTE(bicknellr): `Polymer.dom.flush` above is no longer sufficient to | ||
@@ -292,3 +279,4 @@ // trigger `observeNodes` callbacks. Polymer 2.x returns an object from | ||
_updateItems: function() { | ||
var nodes = dom(this).queryDistributedElements(this.selectable || '*'); | ||
var nodes = | ||
dom(this).queryDistributedElements(this.selectable || '*'); | ||
nodes = Array.prototype.filter.call(nodes, this._bindFilterItem); | ||
@@ -321,3 +309,4 @@ this._setItems(nodes); | ||
// Since Number(0) is falsy, explicitly check for undefined | ||
if (this.fallbackSelection && this.items.length && (this._selection.get() === undefined)) { | ||
if (this.fallbackSelection && this.items.length && | ||
(this._selection.get() === undefined)) { | ||
this.selected = this.fallbackSelection; | ||
@@ -367,3 +356,4 @@ } | ||
var propValue = item[dashToCamelCase(this.attrForSelected)]; | ||
return propValue != undefined ? propValue : item.getAttribute(this.attrForSelected); | ||
return propValue != undefined ? propValue : | ||
item.getAttribute(this.attrForSelected); | ||
}, | ||
@@ -394,6 +384,4 @@ | ||
// we don't have to recreate mutation observers everywhere. | ||
this.fire('iron-items-changed', mutation, { | ||
bubbles: false, | ||
cancelable: false | ||
}); | ||
this.fire( | ||
'iron-items-changed', mutation, {bubbles: false, cancelable: false}); | ||
}); | ||
@@ -417,4 +405,6 @@ }, | ||
_itemActivate: function(value, item) { | ||
if (!this.fire('iron-activate', | ||
{selected: value, item: item}, {cancelable: true}).defaultPrevented) { | ||
if (!this.fire('iron-activate', {selected: value, item: item}, { | ||
cancelable: true | ||
}) | ||
.defaultPrevented) { | ||
this.select(value); | ||
@@ -421,0 +411,0 @@ } |
@@ -71,3 +71,4 @@ /** | ||
if (isSelected !== this.isSelected(item)) { | ||
// proceed to update selection only if requested state differs from current | ||
// proceed to update selection only if requested state differs from | ||
// current | ||
if (isSelected) { | ||
@@ -74,0 +75,0 @@ this.selection.push(item); |
@@ -16,4 +16,5 @@ /** | ||
`iron-selector` is an element which can be used to manage a list of elements | ||
that can be selected. Tapping on the item will make the item selected. The `selected` indicates | ||
which item is being selected. The default is to use the index of the item. | ||
that can be selected. Tapping on the item will make the item selected. The | ||
`selected` indicates which item is being selected. The default is to use the | ||
index of the item. | ||
@@ -28,5 +29,5 @@ Example: | ||
If you want to use the attribute value of an element for `selected` instead of the index, | ||
set `attrForSelected` to the name of the attribute. For example, if you want to select item by | ||
`name`, set `attrForSelected` to `name`. | ||
If you want to use the attribute value of an element for `selected` instead of | ||
the index, set `attrForSelected` to the name of the attribute. For example, if | ||
you want to select item by `name`, set `attrForSelected` to `name`. | ||
@@ -41,4 +42,5 @@ Example: | ||
You can specify a default fallback with `fallbackSelection` in case the `selected` attribute does | ||
not match the `attrForSelected` attribute of any elements. | ||
You can specify a default fallback with `fallbackSelection` in case the | ||
`selected` attribute does not match the `attrForSelected` attribute of any | ||
elements. | ||
@@ -54,6 +56,7 @@ Example: | ||
Note: When the selector is multi, the selection will set to `fallbackSelection` iff | ||
the number of matching elements is zero. | ||
Note: When the selector is multi, the selection will set to `fallbackSelection` | ||
iff the number of matching elements is zero. | ||
`iron-selector` is not styled. Use the `iron-selected` CSS class to style the selected element. | ||
`iron-selector` is not styled. Use the `iron-selected` CSS class to style the | ||
selected element. | ||
@@ -83,6 +86,4 @@ Example: | ||
behaviors: [ | ||
IronMultiSelectableBehavior | ||
] | ||
behaviors: [IronMultiSelectableBehavior] | ||
}); |
@@ -16,15 +16,17 @@ { | ||
"devDependencies": { | ||
"@polymer/gen-typescript-declarations": "^1.2.0", | ||
"@polymer/gen-typescript-declarations": "^1.2.2", | ||
"bower": "^1.8.0", | ||
"@polymer/iron-component-page": "^3.0.0-pre.19", | ||
"@polymer/iron-demo-helpers": "^3.0.0-pre.19", | ||
"@polymer/iron-test-helpers": "^3.0.0-pre.19", | ||
"@polymer/paper-styles": "^3.0.0-pre.19", | ||
"wct-browser-legacy": "^0.0.1-pre.11", | ||
"webmat": "^0.2.0", | ||
"@polymer/iron-component-page": "^3.0.0-pre.20", | ||
"@polymer/iron-demo-helpers": "^3.0.0-pre.20", | ||
"@polymer/iron-test-helpers": "^3.0.0-pre.20", | ||
"@polymer/paper-styles": "^3.0.0-pre.20", | ||
"wct-browser-legacy": "^1.0.1", | ||
"@webcomponents/webcomponentsjs": "^2.0.0" | ||
}, | ||
"scripts": { | ||
"update-types": "bower install && gen-typescript-declarations --deleteExisting --outDir ." | ||
"update-types": "bower install && gen-typescript-declarations --deleteExisting --outDir .", | ||
"format": "webmat && npm run update-types" | ||
}, | ||
"version": "3.0.0-pre.19", | ||
"version": "3.0.0-pre.20", | ||
"resolutions": { | ||
@@ -31,0 +33,0 @@ "inherits": "2.0.3", |
@@ -20,10 +20,3 @@ /** | ||
is: 'attr-reflector', | ||
properties: { | ||
someAttr: { | ||
type: String, | ||
value: "", | ||
reflectToAttribute: true | ||
} | ||
} | ||
properties: {someAttr: {type: String, value: '', reflectToAttribute: true}} | ||
}); |
@@ -14,3 +14,2 @@ /** | ||
import { html } from '@polymer/polymer/lib/utils/html-tag.js'; | ||
Polymer({ | ||
@@ -29,6 +28,3 @@ _template: html` | ||
selected: { | ||
type: String, | ||
notify: true | ||
} | ||
selected: {type: String, notify: true} | ||
@@ -35,0 +31,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
102744
28
9
818
1