@ducor/react
Version:
admin template ui interface
43 lines (42 loc) • 1.77 kB
JavaScript
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
import { createElement, forwardRef } from "react";
import { twMerge } from "tailwind-merge";
import { getGapClass } from "../helpers/helpers";
const Flex = forwardRef((_a, ref) => {
var { as = "div", direction, wrap, align, justify, gap, className, children } = _a, props = __rest(_a, ["as", "direction", "wrap", "align", "justify", "gap", "className", "children"]);
const directionClasses = {
row: "flex-row",
col: "flex-col",
};
const wrapClasses = {
wrap: "flex-wrap",
nowrap: "flex-nowrap",
};
const alignClasses = {
start: "items-start",
center: "items-center",
end: "items-end",
stretch: "items-stretch",
};
const justifyClasses = {
start: "justify-start",
center: "justify-center",
end: "justify-end",
between: "justify-between",
around: "justify-around",
};
const attributes = Object.assign(Object.assign({}, props), { className: twMerge("flex", direction && directionClasses[direction], wrap && wrapClasses[wrap], align && alignClasses[align], justify && justifyClasses[justify], gap && getGapClass(gap), className), ref });
return createElement(as, attributes, children);
});
Flex.displayName = "Flex";
export default Flex;