@lanaco/lnc-react-ui
Version:
React component library
71 lines (70 loc) • 2.12 kB
JavaScript
import { jsxs as N } from "react/jsx-runtime";
import { forwardRef as O, useState as S, Children as i, isValidElement as c, cloneElement as f } from "react";
import { P as s } from "./index-S5Cd7WrG.js";
import { n as x } from "./emotion-styled.browser.esm-CjCaF13H.js";
import { b as D, c as R, h as T } from "./utils-DtRLzzTZ.js";
import { u as I } from "./emotion-element-f0de968e.browser.esm-CkCiQliQ.js";
import { u as P } from "./useUpdateEffect-CuYWz7EA.js";
const M = x.div`
color: ${(o) => !o.disabled && D(o.theme, "Accordion", "primary", "enabled", "text")};
background-color: transparent;
${(o) => R(o.theme, "Accordion", o.size, "enabled")};
${(o) => o.disabled === !0 ? T(o.theme) : ""}
`, Y = O((o, u) => {
const {
expanded: r = !1,
disabled: m = !1,
change: y = () => {
},
size: n = "small",
className: C = "",
style: b = {},
children: p,
...A
} = o, _ = {
theme: I(),
size: n,
style: b,
className: "lnc-ui-accordion " + C
}, [a, l] = S(r);
P(() => {
l(r);
}, [r]);
const d = (e) => {
y(!a, e), l(!a);
}, g = i.map(p, (e) => {
var t;
if (c(e) && (e.props.__TYPE__ == "ACCORDION_SUMMARY" || ((t = e == null ? void 0 : e.type) == null ? void 0 : t.displayName) === "ACCORDION_SUMMARY"))
return f(e, {
size: n,
onClick: d,
onExpand: d,
isExpanded: a,
disabled: m
});
}), E = i.map(p, (e) => {
var t;
if (c(e) && (e.props.__TYPE__ == "ACCORDION_DETAILS" || ((t = e == null ? void 0 : e.type) == null ? void 0 : t.displayName) === "ACCORDION_DETAILS"))
return f(e, {
size: n,
isExpanded: a
});
});
return /* @__PURE__ */ N(M, { ref: u, ..._, disabled: m, ...A, children: [
g,
E
] });
});
Y.propTypes = {
expanded: s.bool,
disabled: s.bool,
//--------------------------------------------------------------
change: s.func,
//---------------------------------------------------------------
className: s.string,
style: s.object,
size: s.oneOf(["small", "medium", "large"])
};
export {
Y as default
};