feat: integrate platform backend and application interfaces
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
export { Alert } from "tdesign-react/es/alert";
|
||||
export type { AlertProps } from "tdesign-react/es/alert";
|
||||
@@ -0,0 +1,2 @@
|
||||
export { Breadcrumb } from "tdesign-react/es/breadcrumb";
|
||||
export type { BreadcrumbProps, BreadcrumbItemProps } from "tdesign-react/es/breadcrumb";
|
||||
@@ -0,0 +1,7 @@
|
||||
.t-button.mf-button--rich {
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.t-button.mf-button--rich > .t-button__text {
|
||||
display: contents;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
import { Children, forwardRef, isValidElement, type ReactElement, type ReactNode } from "react";
|
||||
import { Button as TDesignButton } from "tdesign-react/es/button";
|
||||
import type { ButtonProps as TDesignButtonProps } from "tdesign-react/es/button";
|
||||
import "./button.css";
|
||||
|
||||
export type MiragenFlowButtonType = "default" | "primary" | "outline" | "dashed" | "link" | "text" | "danger" | "danger-outline";
|
||||
|
||||
export interface MiragenFlowButtonProps extends Omit<TDesignButtonProps, "children" | "content" | "icon" | "theme" | "type" | "variant"> {
|
||||
children?: ReactNode;
|
||||
htmlType?: "button" | "submit" | "reset";
|
||||
icon?: ReactElement;
|
||||
type?: MiragenFlowButtonType;
|
||||
}
|
||||
|
||||
const buttonTypeMap: Record<MiragenFlowButtonType, { theme: "default" | "primary" | "danger"; variant: "base" | "outline" | "dashed" | "text" }> = {
|
||||
default: { theme: "default", variant: "base" },
|
||||
primary: { theme: "primary", variant: "base" },
|
||||
outline: { theme: "default", variant: "outline" },
|
||||
dashed: { theme: "default", variant: "dashed" },
|
||||
link: { theme: "primary", variant: "text" },
|
||||
text: { theme: "default", variant: "text" },
|
||||
danger: { theme: "danger", variant: "base" },
|
||||
"danger-outline": { theme: "danger", variant: "outline" },
|
||||
};
|
||||
|
||||
export const MiragenFlowButton = forwardRef<HTMLElement, MiragenFlowButtonProps>(function MiragenFlowButton(
|
||||
{ children, className, htmlType = "button", icon, loading, onClick, tag, type = "default", ...rest },
|
||||
ref,
|
||||
) {
|
||||
const mapped = buttonTypeMap[type];
|
||||
const hasRichChildren = Children.count(children) > 1 || Children.toArray(children).some(isValidElement);
|
||||
const resolvedClassName = ["mf-button", hasRichChildren && "mf-button--rich", className].filter(Boolean).join(" ");
|
||||
|
||||
return (
|
||||
<TDesignButton
|
||||
{...rest}
|
||||
ref={ref}
|
||||
className={resolvedClassName}
|
||||
icon={icon}
|
||||
loading={loading}
|
||||
onClick={onClick}
|
||||
tag={tag ?? (rest.href ? undefined : "button")}
|
||||
theme={mapped.theme}
|
||||
type={htmlType}
|
||||
variant={mapped.variant}
|
||||
>
|
||||
{children}
|
||||
</TDesignButton>
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,2 @@
|
||||
export { Card } from "tdesign-react/es/card";
|
||||
export type { CardProps } from "tdesign-react/es/card";
|
||||
@@ -0,0 +1,2 @@
|
||||
export { Checkbox } from "tdesign-react/es/checkbox";
|
||||
export type { CheckboxProps } from "tdesign-react/es/checkbox";
|
||||
@@ -0,0 +1,2 @@
|
||||
export { ColorPicker, ColorPickerPanel } from "tdesign-react/es/color-picker";
|
||||
export type { ColorPickerProps } from "tdesign-react/es/color-picker";
|
||||
@@ -0,0 +1,8 @@
|
||||
export { DatePicker, DateRangePicker, DatePickerPanel, DateRangePickerPanel } from "tdesign-react/es/date-picker";
|
||||
export type {
|
||||
DatePickerProps,
|
||||
DateRangePickerProps,
|
||||
DatePickerPanelProps,
|
||||
DateRangePickerPanelProps,
|
||||
DateRangeValue,
|
||||
} from "tdesign-react/es/date-picker";
|
||||
@@ -0,0 +1,2 @@
|
||||
export { Dialog, DialogPlugin } from "tdesign-react/es/dialog";
|
||||
export type { DialogInstance, DialogProps } from "tdesign-react/es/dialog";
|
||||
@@ -0,0 +1,2 @@
|
||||
export { Drawer, DrawerPlugin } from "tdesign-react/es/drawer";
|
||||
export type { DrawerInstance, DrawerProps } from "tdesign-react/es/drawer";
|
||||
@@ -0,0 +1,2 @@
|
||||
export { Dropdown } from "tdesign-react/es/dropdown";
|
||||
export type { DropdownProps } from "tdesign-react/es/dropdown";
|
||||
@@ -0,0 +1,8 @@
|
||||
export { Form } from "tdesign-react/es/form";
|
||||
export type {
|
||||
FormInstanceFunctions,
|
||||
FormItemProps,
|
||||
FormProps,
|
||||
FormRule,
|
||||
SubmitContext,
|
||||
} from "tdesign-react/es/form";
|
||||
@@ -0,0 +1,2 @@
|
||||
export { Col, Row } from "tdesign-react/es/grid";
|
||||
export type { ColProps, RowProps } from "tdesign-react/es/grid";
|
||||
@@ -0,0 +1,92 @@
|
||||
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);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export { InputNumber } from "tdesign-react/es/input-number";
|
||||
export type { InputNumberProps } from "tdesign-react/es/input-number";
|
||||
@@ -0,0 +1,2 @@
|
||||
export { Input, InputGroup } from "tdesign-react/es/input";
|
||||
export type { InputGroupProps, InputProps, InputRef } from "tdesign-react/es/input";
|
||||
@@ -0,0 +1,2 @@
|
||||
export { Layout } from "tdesign-react/es/layout";
|
||||
export type { LayoutProps } from "tdesign-react/es/layout";
|
||||
@@ -0,0 +1,2 @@
|
||||
export { Loading } from "tdesign-react/es/loading";
|
||||
export type { LoadingProps } from "tdesign-react/es/loading";
|
||||
@@ -0,0 +1,2 @@
|
||||
export { Menu } from "tdesign-react/es/menu";
|
||||
export type { HeadMenuProps, MenuItemProps, MenuProps, MenuValue, SubMenuProps } from "tdesign-react/es/menu";
|
||||
@@ -0,0 +1,2 @@
|
||||
export { MessagePlugin } from "tdesign-react/es/message";
|
||||
export type { MessageOptions } from "tdesign-react/es/message";
|
||||
@@ -0,0 +1,2 @@
|
||||
export { Pagination } from "tdesign-react/es/pagination";
|
||||
export type { PaginationProps } from "tdesign-react/es/pagination";
|
||||
@@ -0,0 +1,2 @@
|
||||
export { Popup, PopupPlugin } from "tdesign-react/es/popup";
|
||||
export type { PopupProps, PopupRef } from "tdesign-react/es/popup";
|
||||
@@ -0,0 +1,2 @@
|
||||
export { Select } from "tdesign-react/es/select";
|
||||
export type { SelectProps } from "tdesign-react/es/select";
|
||||
@@ -0,0 +1,2 @@
|
||||
export { Slider } from "tdesign-react/es/slider";
|
||||
export type { SliderProps } from "tdesign-react/es/slider";
|
||||
@@ -0,0 +1,2 @@
|
||||
export { Space } from "tdesign-react/es/space";
|
||||
export type { SpaceProps } from "tdesign-react/es/space";
|
||||
@@ -0,0 +1,2 @@
|
||||
export { Statistic } from "tdesign-react/es/statistic";
|
||||
export type { StatisticProps, StatisticRef } from "tdesign-react/es/statistic";
|
||||
@@ -0,0 +1,2 @@
|
||||
export { Switch } from "tdesign-react/es/switch";
|
||||
export type { SwitchProps } from "tdesign-react/es/switch";
|
||||
@@ -0,0 +1,11 @@
|
||||
export { Table, BaseTable, EnhancedTable, PrimaryTable, SimpleTable } from "tdesign-react/es/table";
|
||||
export type {
|
||||
BaseTableColumns,
|
||||
BaseTableProps,
|
||||
DragSortContext,
|
||||
EnhancedTableProps,
|
||||
PrimaryTableCol,
|
||||
PrimaryTableProps,
|
||||
TableProps,
|
||||
TableRowData,
|
||||
} from "tdesign-react/es/table";
|
||||
@@ -0,0 +1,2 @@
|
||||
export { Tabs } from "tdesign-react/es/tabs";
|
||||
export type { TabPanelProps, TabValue, TabsProps } from "tdesign-react/es/tabs";
|
||||
@@ -0,0 +1,2 @@
|
||||
export { Tag } from "tdesign-react/es/tag";
|
||||
export type { TagProps } from "tdesign-react/es/tag";
|
||||
@@ -0,0 +1,2 @@
|
||||
export { Textarea } from "tdesign-react/es/textarea";
|
||||
export type { TextareaProps } from "tdesign-react/es/textarea";
|
||||
@@ -0,0 +1,2 @@
|
||||
export { Tooltip, TooltipLite } from "tdesign-react/es/tooltip";
|
||||
export type { TooltipLiteProps, TooltipProps } from "tdesign-react/es/tooltip";
|
||||
Reference in New Issue
Block a user