alinea
Version:
[](https://npmjs.org/package/alinea) [](https://packagephobia.com/result?p=alinea)
109 lines (105 loc) • 4.3 kB
JavaScript
import {
Nt
} from "../../../chunks/chunk-G3BMTMIQ.js";
import "../../../chunks/chunk-Q2COWNH4.js";
import "../../../chunks/chunk-VKS6HYMO.js";
import "../../../chunks/chunk-CRWVV7PH.js";
import "../../../chunks/chunk-B5OJDF23.js";
import "../../../chunks/chunk-PB6GIAHT.js";
import "../../../chunks/chunk-QMGXID4H.js";
import "../../../chunks/chunk-KO7U3IBJ.js";
import "../../../chunks/chunk-QEHUZJO2.js";
import "../../../chunks/chunk-U5RRZUYZ.js";
// src/dashboard/view/entry/LangSwitch.tsx
import { HStack, Icon, fromModule } from "alinea/ui";
import { IcRoundLanguage } from "alinea/ui/icons/IcRoundLanguage";
import { IcRoundUnfoldMore } from "alinea/ui/icons/IcRoundUnfoldMore";
// src/dashboard/view/entry/LangSwitch.module.scss
var LangSwitch_module_default = {
"langswitch": "alinea-LangSwitch-langswitch",
"is-inline": "alinea-LangSwitch-is-inline",
"isInline": "alinea-LangSwitch-is-inline",
"langswitch-input": "alinea-LangSwitch-langswitch-input",
"langswitchInput": "alinea-LangSwitch-langswitch-input",
"langswitch-input-label": "alinea-LangSwitch-langswitch-input-label",
"langswitchInputLabel": "alinea-LangSwitch-langswitch-input-label",
"is-placeholder": "alinea-LangSwitch-is-placeholder",
"isPlaceholder": "alinea-LangSwitch-is-placeholder",
"langswitch-input-icon": "alinea-LangSwitch-langswitch-input-icon",
"langswitchInputIcon": "alinea-LangSwitch-langswitch-input-icon",
"is-lang": "alinea-LangSwitch-is-lang",
"isLang": "alinea-LangSwitch-is-lang",
"langswitch-dropdown": "alinea-LangSwitch-langswitch-dropdown",
"langswitchDropdown": "alinea-LangSwitch-langswitch-dropdown",
"langswitch-dropdown-inner": "alinea-LangSwitch-langswitch-dropdown-inner",
"langswitchDropdownInner": "alinea-LangSwitch-langswitch-dropdown-inner",
"langswitch-dropdown-option": "alinea-LangSwitch-langswitch-dropdown-option",
"langswitchDropdownOption": "alinea-LangSwitch-langswitch-dropdown-option",
"is-active": "alinea-LangSwitch-is-active",
"isActive": "alinea-LangSwitch-is-active",
"is-selected": "alinea-LangSwitch-is-selected",
"isSelected": "alinea-LangSwitch-is-selected",
"langswitch-dropdown-option-icon": "alinea-LangSwitch-langswitch-dropdown-option-icon",
"langswitchDropdownOptionIcon": "alinea-LangSwitch-langswitch-dropdown-option-icon"
};
// src/dashboard/view/entry/LangSwitch.tsx
import { jsx, jsxs } from "react/jsx-runtime";
var styles = fromModule(LangSwitch_module_default);
function Langswitch({
selected,
locales,
onChange,
inline
}) {
return /* @__PURE__ */ jsx("div", { className: styles.langswitch({ inline }), children: /* @__PURE__ */ jsx(
Nt,
{
value: selected,
onChange: (value) => {
if (!value)
return;
onChange(value);
},
children: /* @__PURE__ */ jsxs("div", { children: [
/* @__PURE__ */ jsxs(
Nt.Button,
{
className: styles.langswitch.input({ active: locales.length > 0 }),
children: [
/* @__PURE__ */ jsx(
Icon,
{
icon: IcRoundLanguage,
className: styles.langswitch.input.icon({ lang: true })
}
),
/* @__PURE__ */ jsx("span", { className: styles.langswitch.input.label(), children: selected }),
locales.length > 0 && /* @__PURE__ */ jsx(
Icon,
{
icon: IcRoundUnfoldMore,
className: styles.langswitch.input.icon()
}
)
]
}
),
locales.length > 0 && /* @__PURE__ */ jsx(Nt.Options, { className: styles.langswitch.dropdown(), children: /* @__PURE__ */ jsx("div", { className: styles.langswitch.dropdown.inner(), children: locales.map((locale) => /* @__PURE__ */ jsx(Nt.Option, { value: locale, children: ({ active, selected: selected2 }) => /* @__PURE__ */ jsx(
HStack,
{
center: true,
gap: 4,
className: styles.langswitch.dropdown.option({
active,
selected: selected2
}),
children: locale.toUpperCase()
}
) }, locale)) }) })
] })
}
) });
}
export {
Langswitch
};