UNPKG

@tachui/modifiers

Version:

Essential styling modifiers for tachUI framework

125 lines (124 loc) 3.98 kB
var a = Object.defineProperty; var d = (i, o, e) => o in i ? a(i, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[o] = e; var r = (i, o, e) => d(i, typeof o != "symbol" ? o + "" : o, e); import { B as f } from "./base-CkGf4b9G.js"; class l extends f { // Lower priority for utility properties constructor(e) { const t = {}; for (const [s, n] of Object.entries(e)) typeof n == "function" && "peek" in n ? t[s] = n.peek() : t[s] = n; super(t); r(this, "type", "utility"); r(this, "priority", 10); } apply(e, t) { if (!t.element) return; const s = this.computeUtilityStyles(this.properties); this.applyStyles(t.element, s); } computeUtilityStyles(e) { const t = {}; return e.cursor !== void 0 && (process.env.NODE_ENV === "development" && this.validateCursorValue(e.cursor), t.cursor = e.cursor), e.overflow !== void 0 && (t.overflow = e.overflow), e.overflowX !== void 0 && (t.overflowX = e.overflowX), e.overflowY !== void 0 && (t.overflowY = e.overflowY), e.position !== void 0 && (t.position = e.position), e.top !== void 0 && (t.top = this.toCSSValue(e.top)), e.right !== void 0 && (t.right = this.toCSSValue(e.right)), e.bottom !== void 0 && (t.bottom = this.toCSSValue(e.bottom)), e.left !== void 0 && (t.left = this.toCSSValue(e.left)), e.zIndex !== void 0 && (t.zIndex = e.zIndex.toString()), e.display !== void 0 && (t.display = e.display), e.visibility !== void 0 && (t.visibility = e.visibility), e.pointerEvents !== void 0 && (t.pointerEvents = e.pointerEvents), e.userSelect !== void 0 && (t.userSelect = e.userSelect), e.boxSizing !== void 0 && (t.boxSizing = e.boxSizing), e.objectFit !== void 0 && (t.objectFit = e.objectFit), e.objectPosition !== void 0 && (t.objectPosition = e.objectPosition), e.resize !== void 0 && (t.resize = e.resize), e.outline !== void 0 && (t.outline = e.outline), e.outlineOffset !== void 0 && (t.outlineOffset = this.toCSSValue(e.outlineOffset)), t; } validateCursorValue(e) { ![ "auto", "default", "pointer", "text", "wait", "help", "not-allowed", "none", "grab", "grabbing", "zoom-in", "zoom-out", "alias", "cell", "copy" ].includes(e) && !e.includes("url(") && console.warn( `Unknown cursor value: "${e}". See documentation for valid cursor values.` ); } } function S(i) { return new l(i); } function w(i) { return new l({ cursor: i }); } function b(i) { return new l({ overflowY: i }); } function h(i) { return new l({ overflowX: i }); } function C(i) { return new l({ display: i }); } function m(i) { return new l({ outline: i }); } function z(i) { return new l({ outlineOffset: i }); } class u extends f { // Very low priority so raw CSS doesn't override specific modifiers constructor(e) { const t = {}; for (const [s, n] of Object.entries(e)) typeof n == "function" && "peek" in n ? t[s] = n.peek() : t[s] = n; super(t); r(this, "type", "css"); r(this, "priority", 5); } apply(e, t) { if (!t.element) return; const s = this.computeCSSStyles(this.properties); this.applyStyles(t.element, s); } computeCSSStyles(e) { const t = {}; for (const [s, n] of Object.entries(e)) if (n !== void 0) { const c = this.toCSSProperty(s); t[c] = this.toCSSValue(n); } return t; } } function g(i) { return new u(i); } function O(i, o) { return new u({ [i]: o }); } function V(i, o) { const e = i.startsWith("--") ? i : `--${i}`; return new u({ [e]: o }); } function j(i, o, e) { const t = i.charAt(0).toUpperCase() + i.slice(1), s = `-${i.toLowerCase()}-${o}`, n = t + o.charAt(0).toUpperCase() + o.slice(1); return new u({ [s]: e, [n]: e }); } export { u as C, l as U, h as a, m as b, w as c, C as d, z as e, g as f, O as g, V as h, j as i, b as o, S as u }; //# sourceMappingURL=css-CJEXRr6H.js.map