UNPKG

@yamada-ui/react

Version:

React UI components of the Yamada, by the Yamada, for the Yamada built with React and Emotion

38 lines (36 loc) 1.14 kB
import { getCSSFunction, globalValues, isCSSFunction, isCSSToken, splitValues } from "./utils.js"; import { generateCalc } from "./calc.js"; //#region src/core/css/grid.ts const repeats = { fill: "auto-fill", fit: "auto-fit" }; function grid(value, { system,...rest }) { if (value == null || globalValues.has(value)) return value; const values = splitValues(value, (current) => current === " "); if (!values.length) return value; return values.map((value$1) => { if (!isCSSFunction(value$1)) { const token = `sizes.${value$1}`; if (isCSSToken(system)(token)) return system.cssMap[token].ref; else return value$1; } const { type, values: values$1 } = getCSSFunction(value$1); if (!type || !values$1) return value$1; if (type === "repeat") { let [repeat, tracks] = splitValues(values$1); repeat = repeat && repeat in repeats ? repeats[repeat] : repeat; tracks = grid(tracks, { system, ...rest }); return `repeat(${repeat}, ${tracks})`; } else return generateCalc("sizes")(value$1, { system, ...rest }); }).join(" "); } //#endregion export { grid }; //# sourceMappingURL=grid.js.map