UNPKG

@progress/kendo-react-buttons

Version:

All you need in React Button in one package: disabled/enabled states, built-in styles and more. KendoReact Buttons package

47 lines (46 loc) 1.56 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ var n = /* @__PURE__ */ ((r) => (r.toggle = "toggle", r.remove = "remove", r))(n || {}); const o = (r, e) => { switch (e.selection) { case "single": switch (e.type) { case "toggle": { if (!Array.isArray(r) || r === null) return e.payload === r ? null : e.payload; throw new Error("State cannot be an array in single selection"); } case "remove": return e.payload === r ? null : r; default: return r; } case "multiple": switch (e.type) { case "toggle": { if (Array.isArray(r)) return r.some((l) => l === e.payload) ? r.filter((l) => l !== e.payload) : [...r, e.payload]; if (r === null) return [e.payload]; throw new Error("State cannot be non-array in multiple selection"); } case "remove": return Array.isArray(r) ? r.some((l) => l === e.payload) ? r.filter((l) => l !== e.payload) : [...r, e.payload] : r; default: return r; } case "none": return null; default: return r; } }; export { n as SELECTION_ACTION, o as selectionReducer };