UNPKG

@hitachivantara/uikit-react-core

Version:

Core React components for the NEXT Design System.

18 lines (17 loc) 619 B
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const getSelected = (list = []) => list.filter((elem) => elem.selected); const getSelectionLabel = (labels, placeholder, multiSelect, list = []) => { const { select } = labels || {}; const selected = getSelected(list); if (select) return { selected: select }; if (multiSelect) { return { selected: selected.length, total: list.length }; } return { selected: selected.length > 0 ? selected[0].label : placeholder }; }; exports.getSelected = getSelected; exports.getSelectionLabel = getSelectionLabel;