UNPKG

@dndbuilder.com/react

Version:

Drag and drop builder for React

71 lines (70 loc) 2.48 kB
"use client"; import { jsxs as t, jsx as r } from "react/jsx-runtime"; import { Select as a } from "./select.js"; import { Tooltip as c } from "./tooltip.js"; import { setCurrentLanguage as m } from "../../store/builder-slice.js"; import { getCurrentLocale as u } from "../../../../../store/selectors.js"; import { useAppDispatch as d } from "../../hooks/use-app-dispatch.js"; import { useAppSelector as f } from "../../hooks/use-app-selector.js"; import { classNames as h } from "../../../../../utils.js"; import { FiGlobe as g, FiCheck as C } from "../../../../../node_modules/.pnpm/react-icons@5.5.0_react@19.0.0/node_modules/react-icons/fi/index.js"; const s = [], k = ({ className: l }) => { const o = f(u), i = d(), p = s.reduce( (e, n) => (e[n.code] = n.name, e), {} )[o]; return s.length === 0 ? null : /* @__PURE__ */ t( a, { onValueChange: (e) => { i(m(e)); }, value: o, defaultValue: "en", children: [ /* @__PURE__ */ r( a.Trigger, { className: h( "h-3 w-[40px] border-0 p-1 focus:ring-0 focus:ring-offset-0", l ), chevronDown: !1, children: /* @__PURE__ */ t(c, { children: [ /* @__PURE__ */ r(c.Trigger, { asChild: !0, children: /* @__PURE__ */ t("span", { className: "flex items-center gap-1", children: [ /* @__PURE__ */ r(g, {}), o.toLocaleUpperCase() ] }) }), /* @__PURE__ */ t(c.Content, { side: "right", children: [ p, " (", o.toLocaleUpperCase(), ")" ] }) ] }) } ), /* @__PURE__ */ r(a.Content, { sideOffset: -23, className: "min-w-[30px] border-0", align: "end", children: /* @__PURE__ */ r(a.Group, { children: s.map((e) => /* @__PURE__ */ r( a.Item, { className: "flex py-2 pe-3 ps-3", value: e.code, showCheck: !1, children: /* @__PURE__ */ t("span", { className: "flex items-center gap-2", children: [ e.name, " (", e.code.toLocaleUpperCase(), ")", o === e.code && /* @__PURE__ */ r(C, {}) ] }) }, e.code )) }) }) ] } ); }; export { k as LanguageSelector }; //# sourceMappingURL=language-selector.js.map