@lobehub/ui
Version:
Lobe UI is an open-source UI component library for building AIGC web apps
80 lines (79 loc) • 2.06 kB
JavaScript
"use client";
import FlexBasic_default from "../Flex/FlexBasic.mjs";
import Text from "../Text/Text.mjs";
import { stopPropagation } from "../utils/dom.mjs";
import Select from "../base-ui/Select/Select.mjs";
import MaterialFileTypeIcon from "../MaterialFileTypeIcon/MaterialFileTypeIcon.mjs";
import { memo, useMemo } from "react";
import { jsx, jsxs } from "react/jsx-runtime";
import { bundledLanguagesInfo } from "shiki";
//#region src/Highlighter/LangSelect.tsx
const LangSelect = memo(({ style, ...rest }) => {
const options = useMemo(() => [{
label: /* @__PURE__ */ jsxs(FlexBasic_default, {
horizontal: true,
align: "center",
gap: 4,
children: [/* @__PURE__ */ jsx(MaterialFileTypeIcon, {
fallbackUnknownType: false,
filename: `*.txt`,
size: 18,
type: "file",
variant: "raw"
}), /* @__PURE__ */ jsx(Text, {
ellipsis: true,
fontSize: 13,
children: "Plaintext"
})]
}),
title: "Plaintext,plaintext,*.text,*.txt",
value: "plaintext"
}, ...bundledLanguagesInfo.map((item) => ({
label: /* @__PURE__ */ jsxs(FlexBasic_default, {
horizontal: true,
align: "center",
gap: 4,
children: [/* @__PURE__ */ jsx(MaterialFileTypeIcon, {
fallbackUnknownType: false,
filename: `*.${item?.aliases?.[0] || item.id}`,
size: 18,
type: "file",
variant: "raw"
}), /* @__PURE__ */ jsx(Text, {
ellipsis: true,
fontSize: 13,
children: item.name
})]
}),
title: [
item.name,
item.id,
...(item.aliases || []).map((alias) => `*.${alias}`)
].join(","),
value: item.id
}))], []);
return /* @__PURE__ */ jsx("div", {
style: {
maxWidth: 240,
width: "100%"
},
onClick: stopPropagation,
children: /* @__PURE__ */ jsx(Select, {
showSearch: true,
virtual: true,
className: "language-title",
options,
size: "small",
style: {
width: "100%",
...style
},
suffixIcon: null,
variant: "borderless",
...rest
})
});
});
//#endregion
export { LangSelect, LangSelect as default };
//# sourceMappingURL=LangSelect.mjs.map