UNPKG

@teamsparta/stack-core

Version:
59 lines (56 loc) 1.53 kB
import { __spreadValues } from "./chunk-FUJQIYOF.mjs"; // src/responsive/normalize.ts import { breakpoint } from "@teamsparta/stack-tokens"; var DEVICE_ALIAS = { mobile: "sm", tablet: "md", desktop: "lg", pc: "lg" }; function toCanonicalKey(key) { var _a; return (_a = DEVICE_ALIAS[key]) != null ? _a : key; } function normalizeResponsiveKeys(value) { const keys = Object.keys(value); if (keys.every((key) => toCanonicalKey(key) === key)) return value; const result = {}; for (const key of keys) { if (toCanonicalKey(key) === key) result[key] = value[key]; } for (const key of keys) { const canonical = toCanonicalKey(key); if (canonical === key) continue; if (canonical in result) { console.warn( `[Stack] Breakpoint "${key}"\uAC00 "${canonical}"\uC640 \uACB9\uCE69\uB2C8\uB2E4. "${canonical}" \uAC12\uC744 \uC720\uC9C0\uD569\uB2C8\uB2E4. sm/md/lg\uB9CC \uC0AC\uC6A9\uD558\uC138\uC694.` ); continue; } result[canonical] = value[key]; } return result; } function normalizeBreakpointTable(table) { const out = {}; for (const [key, value] of Object.entries(table)) { if (value === void 0) continue; out[toCanonicalKey(key)] = value; } return out; } function mergeBreakpointTable(overrides) { return __spreadValues(__spreadValues({}, breakpoint), overrides ? normalizeBreakpointTable(overrides) : {}); } export { toCanonicalKey, normalizeResponsiveKeys, normalizeBreakpointTable, mergeBreakpointTable };