@tachui/modifiers
Version:
Essential styling modifiers for tachUI framework
130 lines (129 loc) • 4 kB
JavaScript
var p = Object.defineProperty;
var d = (i, n, r) => n in i ? p(i, n, { enumerable: !0, configurable: !0, writable: !0, value: r }) : i[n] = r;
var a = (i, n, r) => d(i, typeof n != "symbol" ? n + "" : n, r);
import { B as t } from "../base-CkGf4b9G.js";
import { ModifierPriority as s } from "@tachui/core/modifiers/types";
class f extends t {
constructor() {
super(...arguments);
a(this, "type", "lineClamp");
a(this, "priority", s.APPEARANCE + 15);
}
apply(r, e) {
if (!e.element) return;
const { lines: o } = this.properties;
process.env.NODE_ENV === "development" && this.validateLines(o);
const l = this.generateLineClampStyles(o);
this.applyStyles(e.element, l);
}
generateLineClampStyles(r) {
const e = {};
return e.display = "-webkit-box", e.webkitLineClamp = String(r), e.webkitBoxOrient = "vertical", e.overflow = "hidden", e.textOverflow = "ellipsis", e.wordWrap = "break-word", e;
}
validateLines(r) {
if (typeof r != "number" || !Number.isInteger(r) || r < 1) {
console.warn(
"TachUI LineClamp Modifier: lines must be a positive integer"
);
return;
}
r > 10 && console.info(
"TachUI LineClamp Modifier: Large line clamp values (>10) may impact readability. Consider if this is intentional."
);
}
}
function m(i) {
return new f({ lines: i });
}
class h extends t {
constructor() {
super(...arguments);
a(this, "type", "wordBreak");
a(this, "priority", s.APPEARANCE + 8);
}
apply(r, e) {
if (!e.element) return;
const { wordBreak: o } = this.properties;
process.env.NODE_ENV === "development" && this.validateWordBreak(o), this.applyStyles(e.element, { wordBreak: o });
}
validateWordBreak(r) {
const e = [
"normal",
"break-all",
"keep-all",
"break-word"
];
e.includes(r) || console.warn(
`TachUI WordBreak Modifier: Invalid word-break value "${r}". Valid values are: ${e.join(", ")}`
), r === "break-word" && console.info(
'TachUI WordBreak Modifier: "break-word" is deprecated. Consider using overflowWrap("break-word") instead.'
);
}
}
function k(i) {
return new h({ wordBreak: i });
}
class y extends t {
constructor() {
super(...arguments);
a(this, "type", "overflowWrap");
a(this, "priority", s.APPEARANCE + 9);
}
apply(r, e) {
if (!e.element) return;
const { overflowWrap: o } = this.properties;
process.env.NODE_ENV === "development" && this.validateOverflowWrap(o), this.applyStyles(e.element, { overflowWrap: o });
}
validateOverflowWrap(r) {
const e = [
"normal",
"break-word",
"anywhere"
];
e.includes(r) || console.warn(
`TachUI OverflowWrap Modifier: Invalid overflow-wrap value "${r}". Valid values are: ${e.join(", ")}`
);
}
}
function b(i) {
return new y({ overflowWrap: i });
}
class v extends t {
constructor() {
super(...arguments);
a(this, "type", "hyphens");
a(this, "priority", s.APPEARANCE + 10);
}
apply(r, e) {
if (!e.element) return;
const { hyphens: o } = this.properties;
process.env.NODE_ENV === "development" && this.validateHyphens(o), this.applyStyles(e.element, {
hyphens: o,
// Add vendor prefixes for better browser support
webkitHyphens: o,
msHyphens: o
});
}
validateHyphens(r) {
const e = ["none", "manual", "auto"];
e.includes(r) || console.warn(
`TachUI Hyphens Modifier: Invalid hyphens value "${r}". Valid values are: ${e.join(", ")}`
), r === "auto" && console.info(
"TachUI Hyphens Modifier: Automatic hyphenation requires proper lang attribute on the document or element for best results."
);
}
}
function W(i) {
return new v({ hyphens: i });
}
export {
v as HyphensModifier,
f as LineClampModifier,
y as OverflowWrapModifier,
h as WordBreakModifier,
W as hyphens,
m as lineClamp,
b as overflowWrap,
k as wordBreak
};
//# sourceMappingURL=text.js.map