Files
MiragenFlow/packages/ui/src/index.tsx
T

93 lines
4.0 KiB
TypeScript

import type { ReactNode } from "react";
import { ConfigProvider } from "tdesign-react/es/config-provider";
import enUS from "tdesign-react/es/locale/en_US";
import zhCN from "tdesign-react/es/locale/zh_CN";
export { MiragenFlowButton } from "./button";
export type { MiragenFlowButtonProps, MiragenFlowButtonType } from "./button";
export { Alert } from "./alert";
export type { AlertProps } from "./alert";
export { Card } from "./card";
export type { CardProps } from "./card";
export { Breadcrumb } from "./breadcrumb";
export type { BreadcrumbProps, BreadcrumbItemProps } from "./breadcrumb";
export { Checkbox } from "./checkbox";
export type { CheckboxProps } from "./checkbox";
export { Dialog, DialogPlugin } from "./dialog";
export type { DialogInstance, DialogProps } from "./dialog";
export { Drawer, DrawerPlugin } from "./drawer";
export type { DrawerInstance, DrawerProps } from "./drawer";
export { Dropdown } from "./dropdown";
export type { DropdownProps } from "./dropdown";
export { Form } from "./form";
export type { FormInstanceFunctions, FormItemProps, FormProps, FormRule, SubmitContext } from "./form";
export { Col, Row } from "./grid";
export type { ColProps, RowProps } from "./grid";
export { Layout } from "./layout";
export type { LayoutProps } from "./layout";
export { Menu } from "./menu";
export type { HeadMenuProps, MenuItemProps, MenuProps, MenuValue, SubMenuProps } from "./menu";
export { ColorPicker, ColorPickerPanel } from "./color-picker";
export type { ColorPickerProps } from "./color-picker";
export { DatePicker, DateRangePicker, DatePickerPanel, DateRangePickerPanel } from "./date-picker";
export type { DatePickerProps, DateRangePickerProps, DatePickerPanelProps, DateRangePickerPanelProps, DateRangeValue } from "./date-picker";
export { Input, InputGroup } from "./input";
export type { InputGroupProps, InputProps, InputRef } from "./input";
export { InputNumber } from "./input-number";
export type { InputNumberProps } from "./input-number";
export { Loading } from "./loading";
export type { LoadingProps } from "./loading";
export { MessagePlugin } from "./message";
export type { MessageOptions } from "./message";
export { Popup, PopupPlugin } from "./popup";
export type { PopupProps, PopupRef } from "./popup";
export { Pagination } from "./pagination";
export type { PaginationProps } from "./pagination";
export { Select } from "./select";
export type { SelectProps } from "./select";
export { Space } from "./space";
export type { SpaceProps } from "./space";
export { Switch } from "./switch";
export type { SwitchProps } from "./switch";
export { Statistic } from "./statistic";
export type { StatisticProps, StatisticRef } from "./statistic";
export { Table, BaseTable, EnhancedTable, PrimaryTable, SimpleTable } from "./table";
export type {
BaseTableColumns,
BaseTableProps,
DragSortContext,
EnhancedTableProps,
PrimaryTableCol,
PrimaryTableProps,
TableProps,
TableRowData,
} from "./table";
export { Tag } from "./tag";
export type { TagProps } from "./tag";
export { Textarea } from "./textarea";
export type { TextareaProps } from "./textarea";
export { Tabs } from "./tabs";
export type { TabPanelProps, TabValue, TabsProps } from "./tabs";
export { Slider } from "./slider";
export type { SliderProps } from "./slider";
export { Tooltip, TooltipLite } from "./tooltip";
export type { TooltipLiteProps, TooltipProps } from "./tooltip";
export type MiragenFlowLocale = "zh-CN" | "en-US";
export type TDesignThemeVariables = Record<string, string>;
export function TDesignProvider({ locale, children }: { locale: MiragenFlowLocale; children: ReactNode }) {
return <ConfigProvider globalConfig={locale === "zh-CN" ? zhCN : enUS}>{children}</ConfigProvider>;
}
export function applyTDesignVariables(mode: "light" | "dark", variables: TDesignThemeVariables) {
const root = document.documentElement;
root.setAttribute("theme-mode", mode);
root.setAttribute("data-mf-tdesign", "true");
Object.entries(variables).forEach(([name, value]) => {
root.style.setProperty(name, value);
});
}