@crossed/styled
Version:
A universal & performant styling library for React Native, Next.js & React
58 lines (57 loc) • 2.43 kB
JavaScript
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 PseudoClass_exports = {};
__export(PseudoClass_exports, {
PseudoClassPlugin: () => PseudoClassPlugin
});
module.exports = __toCommonJS(PseudoClass_exports);
var import_utils = require("./../utils");
const PseudoClassPlugin = {
name: "PseudoClassPlugin",
test: [":hover", ":active", ":focus", ":focus-visible", ":disabled"],
apply: ({ styles, key: ctxKey, addClassname, props, isWeb }) => {
const pseudoClass = ctxKey.replace(/:/i, "");
Object.entries(styles).forEach(([key, value]) => {
const valueNormalized = (0, import_utils.normalizeUnitPixel)(key, value, isWeb);
if (isWeb) {
addClassname({
suffix: `:${pseudoClass}${pseudoClass === "hover" ? ":not(:disabled):not(:active)" : pseudoClass === "active" ? ":not(:disabled)" : ""}`,
body: {
[`${pseudoClass}:${(0, import_utils.convertKeyToCss)(key)}-[${typeof valueNormalized === "number" ? valueNormalized : valueNormalized == null ? void 0 : valueNormalized.replace(/ /g, "-")}]`]: {
[key]: valueNormalized
}
}
});
}
if ((props == null ? void 0 : props[pseudoClass]) || !props) {
addClassname({
body: {
[`${(0, import_utils.convertKeyToCss)(key)}-[${typeof valueNormalized === "number" ? valueNormalized : valueNormalized == null ? void 0 : valueNormalized.replace(/ /g, "-")}]`]: {
[key]: valueNormalized
}
}
});
}
}, {});
}
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
PseudoClassPlugin
});
//# sourceMappingURL=PseudoClass.js.map