mirror of
https://github.com/Choices-js/Choices.git
synced 2024-04-26 03:10:33 +02:00
62e849d1b4
* Include customProperties in removeItem * Add tests * Housekeeping * Update mac vm label * Add .nvmrc
54 lines
932 B
JavaScript
54 lines
932 B
JavaScript
import { ACTION_TYPES } from '../constants';
|
|
|
|
/**
|
|
* @typedef {import('redux').Action} Action
|
|
* @typedef {import('../../../types/index').Choices.Item} Item
|
|
*/
|
|
|
|
/**
|
|
* @param {Item} item
|
|
* @returns {Action & Item}
|
|
*/
|
|
export const addItem = ({
|
|
value,
|
|
label,
|
|
id,
|
|
choiceId,
|
|
groupId,
|
|
customProperties,
|
|
placeholder,
|
|
keyCode,
|
|
}) => ({
|
|
type: ACTION_TYPES.ADD_ITEM,
|
|
value,
|
|
label,
|
|
id,
|
|
choiceId,
|
|
groupId,
|
|
customProperties,
|
|
placeholder,
|
|
keyCode,
|
|
});
|
|
|
|
/**
|
|
* @param {number} id
|
|
* @param {number} choiceId
|
|
* @returns {Action & { id: number, choiceId: number }}
|
|
*/
|
|
export const removeItem = (id, choiceId) => ({
|
|
type: ACTION_TYPES.REMOVE_ITEM,
|
|
id,
|
|
choiceId,
|
|
});
|
|
|
|
/**
|
|
* @param {number} id
|
|
* @param {boolean} highlighted
|
|
* @returns {Action & { id: number, highlighted: boolean }}
|
|
*/
|
|
export const highlightItem = (id, highlighted) => ({
|
|
type: ACTION_TYPES.HIGHLIGHT_ITEM,
|
|
id,
|
|
highlighted,
|
|
});
|