UNPKG

@hisptz/react-ui

Version:

A collection of reusable complex DHIS2 react ui components.

35 lines (30 loc) 764 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.uid = uid; exports.updatePager = updatePager; function uid() { const letters = "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; const allowedChars = "0123456789" + letters; const NUMBER_OF_CODEPOINTS = allowedChars.length; const CODESIZE = 11; let uid; uid = letters.charAt(Math.random() * letters.length); for (let i = 1; i < CODESIZE; ++i) { uid += allowedChars.charAt(Math.random() * NUMBER_OF_CODEPOINTS); } return uid; } function updatePager(pager, itemListLength) { const { page, pageSize } = pager; return { page, pageSize, pageCount: Math.ceil(itemListLength / pageSize), total: itemListLength }; }