UNPKG

@carbon/react

Version:

React components for the Carbon Design System

25 lines (23 loc) 921 B
/** * Copyright IBM Corp. 2016, 2026 * * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree. */ //#region src/internal/getAnnouncement.ts /** * Copyright IBM Corp. 2016, 2025 * * This source code is licensed under the Apache-2.0 license found in the * LICENSE file in the root directory of this source tree. */ /** Returns an announcement message when the remaining count is low. */ const getAnnouncement = (count, maxCount, singularEntityName = "character", pluralEntityName = "characters") => { if (typeof maxCount === "undefined") return null; const remaining = maxCount - count; if (remaining <= 10 && remaining > 0) return `${remaining} ${remaining === 1 ? singularEntityName : pluralEntityName} left.`; if (remaining <= 0) return `Maximum ${pluralEntityName} reached.`; return null; }; //#endregion export { getAnnouncement };