@progress/kendo-react-common
Version:
React Common package delivers common utilities that can be used with the KendoReact UI components. KendoReact Common Utilities package
87 lines (86 loc) • 2.89 kB
JavaScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
"use client";
import * as n from "react";
import t from "prop-types";
import { FONT_SIZE_CLASSES as L, FONT_WEIGHT_CLASSES as M, TEXT_ALIGN_CLASSES as x, TEXT_TRANSFORM_CLASSES as I, THEME_COLOR_CLASSES as b, MARGIN_ENUM_CLASSES as j, MARGIN_SIDES_CLASSES as v, MARGIN_ENUM_VALUES as G } from "./constants.mjs";
const r = (c) => {
const i = n.forwardRef((l, h) => {
const { id: m, style: g, className: y, fontSize: S, fontWeight: u, textAlign: d, textTransform: C, themeColor: E, margin: e, ...T } = l, p = n.useRef(null), f = n.useRef(null);
n.useImperativeHandle(p, () => ({
element: f.current,
props: l
})), n.useImperativeHandle(h, () => p.current);
const A = () => `k-${c === "p" ? "paragraph" : c}`, _ = c, N = (o, a) => {
const s = typeof a == "string" ? G[a] : a;
return `${v[o]}${s}`;
}, O = () => {
if (e !== void 0) {
if (typeof e == "string")
return [j[e]];
if (typeof e == "number" && e >= 0 && e <= 24)
return [`k-m-${e}`];
if (typeof e == "object") {
const o = [];
return Object.keys(e).forEach((s) => {
e[s] !== null && e[s] !== void 0 && o.push(N(s, e[s]));
}), o.join(" ");
}
}
}, R = () => [
A(),
L[S],
M[u],
x[d],
I[C],
b[E],
O(),
y
].filter((s) => s !== void 0).join(" ");
return /* @__PURE__ */ n.createElement(_, { id: m, ref: f, className: R(), style: g, ...T }, l.children);
});
return i.propTypes = {
style: t.object,
className: t.string,
fontSize: t.oneOf(["xsmall", "small", "medium", "large", "xlarge"]),
fontWeight: t.oneOf(["light", "normal", "bold"]),
margin: t.oneOfType([
t.number,
t.object,
t.oneOf(["xsmall", "small", "medium", "large", "xlarge", "thin", "hair"])
]),
textAlign: t.oneOf(["left", "right", "center", "justify"]),
textTransform: t.oneOf(["lowercase", "uppercase", "capitalize"]),
themeColor: t.oneOf([
"inherit",
"primary",
"secondary",
"tertiary",
"info",
"success",
"error",
"warning",
"dark",
"light",
"inverse"
])
}, i.displayName = `KendoReactTypography${c.toUpperCase()}`, i;
}, $ = r("h1"), H = r("h2"), U = r("h3"), w = r("h4"), z = r("h5"), F = r("h6"), W = r("p"), P = r("code"), X = r("pre"), K = {
h1: $,
h2: H,
h3: U,
h4: w,
h5: z,
h6: F,
p: W,
code: P,
pre: X
};
export {
K as Typography
};