UNPKG

@tonyptang/unocss-config

Version:

unocss-config

184 lines (178 loc) 4.04 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; 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/index.ts var src_exports = {}; __export(src_exports, { createRules: () => createRules, createShortCuts: () => createShortCuts, default: () => src_default, presetTo: () => presetTo }); module.exports = __toCommonJS(src_exports); // node_modules/.pnpm/@unocss+core@0.61.9/node_modules/@unocss/core/dist/index.mjs var LAYER_DEFAULT = "default"; var LAYER_PREFLIGHTS = "preflights"; var LAYER_SHORTCUTS = "shortcuts"; var LAYER_IMPORTS = "imports"; var DEFAULT_LAYERS = { [LAYER_IMPORTS]: -200, [LAYER_PREFLIGHTS]: -100, [LAYER_SHORTCUTS]: -10, [LAYER_DEFAULT]: 0 }; function definePreset(preset) { return preset; } // src/rules.ts function createRules() { function createPersetRules() { const nameMap = { h: "height", w: "width" }; return [ /([wh])(\d+)p$/, ([_, name, value]) => { return { [nameMap[name]]: `${value}%` }; } ]; } function createFontSizeRule() { return [ /(?<=fs)(\d+)(.*)/, ([_, value, unit]) => { return { "font-size": `${value}${unit}` }; } ]; } function createPositionRules() { const posotionShortCuts = { re: "relative", ab: "absolute", st: "static", fi: "fixed", sta: "static", sti: "sticky", ini: "initial", inh: "inherit", un: "unset" }; return [ /(?<=ps)-(.+)/, ([_, value]) => { return { posotion: posotionShortCuts[value] }; } ]; } function createReverseRules() { const reverseMap = { r: "right", b: "bottom", t: "top", l: "left" }; return [ /^([rbtl])(\d+)(\D+)/, ([_, name, value, unit]) => { return { [reverseMap[name]]: value + unit }; } ]; } function createMarginPaddingRules() { const map = { m: "margin", p: "padding", border: "border" }; return [ /(m|p|border)-\((.*)\)/, ([_, name, value]) => { return { [map[name]]: value.split(",").join(" ") }; } ]; } function createBoxSizingRules() { const map = { bb: "border-box", bc: "content-box" }; return [ /(bb|bc)/, ([_, value]) => { return { "box-sizing": map[value] }; } ]; } return [ createPersetRules(), createFontSizeRule(), createPositionRules(), createReverseRules(), createMarginPaddingRules(), createBoxSizingRules() ]; } // src/shortcuts.ts var flex = { ic: "items-center", jc: "justify-center", jb: "justify-between", jend: "justify-end", jstart: "justify-start", jar: "justify-around", jev: "justify-evenly", iend: "items-end", istart: "items-start" }; var cursor = { cp: "cursor-pointer" }; function createShortCuts() { return { ...flex, ...cursor }; } // src/index.ts var presetTo = definePreset({ name: "to-unocss-config", rules: [...createRules()], shortcuts: { ...createShortCuts() } }); var src_default = presetTo; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { createRules, createShortCuts, presetTo });