UNPKG

@crossed/styled

Version:

A universal & performant styling library for React Native, Next.js & React

55 lines (54 loc) 1.93 kB
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); var Base_exports = {}; __export(Base_exports, { BasePlugin: () => BasePlugin }); module.exports = __toCommonJS(Base_exports); var import_utils = require("./utils"); const BasePlugin = { name: "BasePlugin", test: ["base"], apply: ({ addClassname, styles, isWeb, cache }) => { const old = cache.get(styles); if (old) { addClassname(old); return; } const body = Object.keys(styles).reduce( (acc, key) => { var _a; const value = styles[key]; const valueNormalized = (0, import_utils.normalizeUnitPixel)(key, value, isWeb); acc[`${(0, import_utils.convertKeyToCss)(key)}-[${typeof valueNormalized === "number" ? valueNormalized : (_a = valueNormalized == null ? void 0 : valueNormalized.replace) == null ? void 0 : _a.call(valueNormalized, / /g, "-")}]`] = { [key]: valueNormalized }; return acc; }, {} ); const result = { body }; cache.set(styles, result); addClassname(result); } }; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { BasePlugin }); //# sourceMappingURL=Base.js.map