UNPKG

@teamsparta/stack-core

Version:
96 lines (94 loc) 3.29 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getOwnPropSymbols = Object.getOwnPropertySymbols; var __hasOwnProp = Object.prototype.hasOwnProperty; var __propIsEnum = Object.prototype.propertyIsEnumerable; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __spreadValues = (a, b) => { for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]); if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) { if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]); } return a; }; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // src/responsive/normalize.ts var normalize_exports = {}; __export(normalize_exports, { mergeBreakpointTable: () => mergeBreakpointTable, normalizeBreakpointTable: () => normalizeBreakpointTable, normalizeResponsiveKeys: () => normalizeResponsiveKeys, toCanonicalKey: () => toCanonicalKey }); module.exports = __toCommonJS(normalize_exports); var import_stack_tokens = require("@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({}, import_stack_tokens.breakpoint), overrides ? normalizeBreakpointTable(overrides) : {}); } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { mergeBreakpointTable, normalizeBreakpointTable, normalizeResponsiveKeys, toCanonicalKey });