choices.js
Advanced tools
Comparing version 2.8.3 to 2.8.4
@@ -28,3 +28,3 @@ export const addItem = (value, label, id, choiceId, groupId) => { | ||
export const addChoice = (value, label, id, groupId, disabled) => { | ||
export const addChoice = (value, label, id, groupId, disabled, elementId) => { | ||
return { | ||
@@ -37,2 +37,3 @@ type: 'ADD_CHOICE', | ||
disabled, | ||
elementId: elementId, | ||
}; | ||
@@ -39,0 +40,0 @@ }; |
@@ -14,2 +14,33 @@ /* eslint-disable */ | ||
/** | ||
* Generates a string of random chars | ||
* @param {Number} length Length of the string to generate | ||
* @return {String} String of random chars | ||
*/ | ||
export const generateChars = function (length) { | ||
var chars = ''; | ||
for (var i = 0; i < length; i++) { | ||
var randomChar = getRandomNumber(0, 36); | ||
chars += randomChar.toString(36); | ||
} | ||
return chars; | ||
}; | ||
/** | ||
* Generates a unique id based on an element | ||
* @param {HTMLElement} element Element to generate the id from | ||
* @param {String} Prefix for the Id | ||
* @return {String} Unique Id | ||
*/ | ||
export const generateId = function (element, prefix) { | ||
var id = element.id || (element.name && (element.name + '-' + generateChars(2))) || generateChars(4); | ||
id = id.replace(/(:|\.|\[|\]|,)/g, ''); | ||
id = prefix + id; | ||
return id; | ||
}; | ||
/** | ||
* Tests the type of an object | ||
@@ -16,0 +47,0 @@ * @param {String} type Type to test object against |
@@ -11,2 +11,3 @@ const choices = (state = [], action) => { | ||
id: action.id, | ||
elementId: action.elementId, | ||
groupId: action.groupId, | ||
@@ -13,0 +14,0 @@ value: action.value, |
{ | ||
"name": "choices.js", | ||
"version": "2.8.3", | ||
"version": "2.8.4", | ||
"description": "A vanilla JS customisable text input/select box plugin", | ||
@@ -5,0 +5,0 @@ "main": [ |
{ | ||
"name": "choices.js", | ||
"version": "2.8.3", | ||
"version": "2.8.4", | ||
"description": "A vanilla JS customisable text input/select box plugin", | ||
@@ -5,0 +5,0 @@ "main": "./assets/scripts/dist/choices.min.js", |
@@ -652,3 +652,3 @@ # Choices.js ![Build Status](https://travis-ci.org/jshjohnson/Choices.svg?branch=master) | ||
{value: 'One', label: 'Label One', disabled: true}, | ||
{value: 'Two', label: 'Label Two' selected: true}, | ||
{value: 'Two', label: 'Label Two', selected: true}, | ||
{value: 'Three', label: 'Label Three'}, | ||
@@ -655,0 +655,0 @@ ], 'value', 'label', false); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
719045
9662