dgz-ui-shared
Version:
Custom ui library using React.js, Shadcn/ui, TailwindCSS, Typescript, dgz-ui library
133 lines (132 loc) • 5.08 kB
JavaScript
import { a as x, f as A, j as O, x as w, c as z } from "./index-DqTIeHVj-CYOpXZHK.js";
import { R as _, m as S } from "./utils-D0f6bOsw-HrLsble-.js";
import * as $ from "react";
import p, { forwardRef as V } from "react";
import { k as I } from "./createLucideIcon-B950nf2d-WasJb88J.js";
const C = (e) => typeof e == "boolean" ? `${e}` : e === 0 ? "0" : e, M = _, E = (e, i) => (t) => {
var f;
if ((i == null ? void 0 : i.variants) == null) return M(e, t == null ? void 0 : t.class, t == null ? void 0 : t.className);
const { variants: g, defaultVariants: s } = i, b = Object.keys(g).map((o) => {
const n = t == null ? void 0 : t[o], c = s == null ? void 0 : s[o];
if (n === null) return null;
const l = C(n) || C(c);
return g[o][l];
}), h = t && Object.entries(t).reduce((o, n) => {
let [c, l] = n;
return l === void 0 || (o[c] = l), o;
}, {}), R = i == null || (f = i.compoundVariants) === null || f === void 0 ? void 0 : f.reduce((o, n) => {
let { class: c, className: l, ...y } = n;
return Object.entries(y).every((j) => {
let [a, r] = j;
return Array.isArray(r) ? r.includes({
...s,
...h
}[a]) : {
...s,
...h
}[a] === r;
}) ? [
...o,
c,
l
] : o;
}, []);
return M(e, b, R, t == null ? void 0 : t.class, t == null ? void 0 : t.className);
}, P = E(
"inline-flex border border-border-alpha-strong items-center justify-center gap-2 whitespace-nowrap font-medium focus:ring-2 focus:ring-offset-2 focus:ring-offset-bg focus:ring-item-primary-focus transition-colors disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
{
variants: {
variant: {
default: "bg-item-primary hover:bg-item-primary-hover active:bg-item-primary-active !text-white",
destructive: "bg-item-destructive hover:bg-item-destructive-hover active:bg-item-destructive-active focus:ring-2 focus:ring-item-destructive-focus !text-white",
secondary: "bg-item-secondary hover:bg-item-secondary-hover active:bg-item-secondary-active",
tertiary: "bg-item-tertiary hover:bg-item-tertiary-hover active:bg-item-tertiary-active border-0",
ghost: "bg-item-ghost hover:bg-item-ghost-hover active:bg-item-ghost-active border-0"
},
size: {
lg: "h-12 px-4 text-body-sm-medium [&>svg]:size-5 rounded-5",
default: "h-10 px-3 text-body-sm-medium [&>svg]:size-5 rounded-4",
sm: "h-8 px-2.5 text-body-xs-medium [&>svg]:size-4 rounded-3",
xs: "h-7 px-2 text-body-xs-medium [&>svg]:size-4 rounded-2",
icon: "h-10 w-10 text-body-xs-medium [&>svg]:size-4 rounded-3"
}
},
defaultVariants: {
variant: "default",
size: "default"
}
}
), q = V(
({ className: e, variant: i, size: t, asChild: f = !1, ...g }, s) => {
const b = f ? A : "button";
return /* @__PURE__ */ x.jsx(
b,
{
className: S(P({ variant: i, size: t, className: e })),
ref: s,
...g
}
);
}
);
q.displayName = "Button";
function J(e) {
const i = e + "CollectionProvider", [t, f] = O(i), [g, s] = t(
i,
{ collectionRef: { current: null }, itemMap: /* @__PURE__ */ new Map() }
), b = (a) => {
const { scope: r, children: u } = a, d = p.useRef(null), v = p.useRef(/* @__PURE__ */ new Map()).current;
return /* @__PURE__ */ x.jsx(g, { scope: r, itemMap: v, collectionRef: d, children: u });
};
b.displayName = i;
const h = e + "CollectionSlot", R = z(h), o = p.forwardRef(
(a, r) => {
const { scope: u, children: d } = a, v = s(h, u), m = w(r, v.collectionRef);
return /* @__PURE__ */ x.jsx(R, { ref: m, children: d });
}
);
o.displayName = h;
const n = e + "CollectionItemSlot", c = "data-radix-collection-item", l = z(n), y = p.forwardRef(
(a, r) => {
const { scope: u, children: d, ...v } = a, m = p.useRef(null), k = w(r, m), N = s(n, u);
return p.useEffect(() => (N.itemMap.set(m, { ref: m, ...v }), () => void N.itemMap.delete(m))), /* @__PURE__ */ x.jsx(l, { [c]: "", ref: k, children: d });
}
);
y.displayName = n;
function j(a) {
const r = s(e + "CollectionConsumer", a);
return p.useCallback(() => {
const u = r.collectionRef.current;
if (!u) return [];
const d = Array.from(u.querySelectorAll(`[${c}]`));
return Array.from(r.itemMap.values()).sort(
(v, m) => d.indexOf(v.ref.current) - d.indexOf(m.ref.current)
);
}, [r.collectionRef, r.itemMap]);
}
return [
{ Provider: b, Slot: o, ItemSlot: y },
j,
f
];
}
var B = $.createContext(void 0);
function K(e) {
const i = $.useContext(B);
return e || i || "ltr";
}
/**
* @license lucide-react v0.511.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/
const T = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]], L = I("check", T);
export {
P as g,
J as h,
E as j,
K as n,
L as t,
q as u
};