@harvest-profit/npk
Version:
NPK UI Design System
28 lines • 1.28 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const jsx_runtime_1 = require("react/jsx-runtime");
const Placeholder_module_css_1 = __importDefault(require("./Placeholder.module.css"));
function randomIntFromInterval(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min);
}
function selectWidth(value) {
if (Number.isFinite(value))
return value;
if (typeof value === 'string')
return value;
if (!value)
return null;
if (Array.isArray(value) && value.length === 0)
return null;
const min = Array.isArray(value) ? value[0] : 0;
const max = Array.isArray(value) ? value[1] || min : 0;
return randomIntFromInterval(min, max);
}
const Placeholder = ({ className = '', width = [70, 150], style = {}, ...props }) => {
return ((0, jsx_runtime_1.jsx)("span", { title: "loading...", "aria-hidden": "true", className: `${Placeholder_module_css_1.default.Placeholder} ${className}`, style: { width: selectWidth(width) || 100, ...style }, ...props, children: "\u00A0" }));
};
exports.default = Placeholder;
//# sourceMappingURL=Placeholder.js.map