UNPKG

@etsoo/react

Version:

TypeScript ReactJs UI Independent Framework

50 lines (49 loc) 1.39 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GridSizeGet = void 0; exports.GridDataGet = GridDataGet; exports.GridDataGetData = GridDataGetData; const shared_1 = require("@etsoo/shared"); /** * Grid size calculation * @param size Size * @param input Input */ const GridSizeGet = (size, input) => { if (typeof size === "function") return size(input); return size; }; exports.GridSizeGet = GridSizeGet; /** * Grid data get with format * @param data Data * @param template Template * @param keepSource Keep source data * @returns Json data */ function GridDataGet(props, template, keepSource) { // Destruct const { data, ...rest } = props; // DomUtils.dataAs(data, template); return { ...GridDataGetData(data, template, keepSource), ...rest }; } /** * Grid data get with format * @param data Data * @param template Template * @param keepSource Keep source data * @returns Json data */ function GridDataGetData(data, template, keepSource) { // Clear form empty value if (data instanceof FormData) { shared_1.DomUtils.clearFormData(data); } // Conditions // Set keepSource to true to hold form data, even they are invisible from the conditions const conditions = data == null ? {} : shared_1.DomUtils.dataAs(data, template, keepSource); return conditions; }