mirror of
https://github.com/Choices-js/Choices.git
synced 2024-05-03 14:23:12 +02:00
e6882f3e4b
* Add wrapped element getters + fix some types * Remove comment * Add missing config options to types * Add types to constants * Rename sortFn to sorter * Update PR template * Add refactor to PR template * Add passed element types to constants * Add js doc comments to actions * Add "returns" to js doc comments * Add missing choice prop to type * Add types to store.js * Add jsdoc comments to components * Ignore strict null checks * Move loading action into misc.js * Further type def additions * Rename itemCompare to valueCompare * Update badges * Rename scrollToChoice to scrollToChildElement
58 lines
981 B
JavaScript
58 lines
981 B
JavaScript
/**
|
|
* @typedef {import('../../../types/index').Choices.Choice} Choice
|
|
*/
|
|
|
|
import { ACTION_TYPES } from '../constants';
|
|
|
|
/**
|
|
* @argument {Choice} choice
|
|
* @returns {{ type: string } & Choice}
|
|
*/
|
|
export const addChoice = ({
|
|
value,
|
|
label,
|
|
id,
|
|
groupId,
|
|
disabled,
|
|
elementId,
|
|
customProperties,
|
|
placeholder,
|
|
keyCode,
|
|
}) => ({
|
|
type: ACTION_TYPES.ADD_CHOICE,
|
|
value,
|
|
label,
|
|
id,
|
|
groupId,
|
|
disabled,
|
|
elementId,
|
|
customProperties,
|
|
placeholder,
|
|
keyCode,
|
|
});
|
|
|
|
/**
|
|
* @argument {Choice[]} results
|
|
* @returns {{ type: string, results: Choice[] }}
|
|
*/
|
|
export const filterChoices = results => ({
|
|
type: ACTION_TYPES.FILTER_CHOICES,
|
|
results,
|
|
});
|
|
|
|
/**
|
|
* @argument {boolean} active
|
|
* @returns {{ type: string, active: boolean }}
|
|
*/
|
|
export const activateChoices = (active = true) => ({
|
|
type: ACTION_TYPES.ACTIVATE_CHOICES,
|
|
active,
|
|
});
|
|
|
|
/**
|
|
* @returns {{ type: string }}
|
|
*/
|
|
export const clearChoices = () => ({
|
|
type: ACTION_TYPES.CLEAR_CHOICES,
|
|
});
|