@meta-1/design 0.0.159
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +412 -0
- package/package.json +138 -0
- package/src/assets/icons/empty.svg +1 -0
- package/src/assets/icons/spin.svg +1 -0
- package/src/assets/locales/en-us.ts +74 -0
- package/src/assets/locales/zh-cn.ts +74 -0
- package/src/assets/locales/zh-tw.ts +74 -0
- package/src/assets/style/theme.css +173 -0
- package/src/components/icons/Empty.tsx +18 -0
- package/src/components/icons/Spin.tsx +16 -0
- package/src/components/icons/index.ts +2 -0
- package/src/components/ui/alert-dialog.tsx +111 -0
- package/src/components/ui/alert.tsx +49 -0
- package/src/components/ui/avatar.tsx +32 -0
- package/src/components/ui/badge.tsx +36 -0
- package/src/components/ui/breadcrumb.tsx +92 -0
- package/src/components/ui/button.tsx +52 -0
- package/src/components/ui/calendar.tsx +56 -0
- package/src/components/ui/card.tsx +56 -0
- package/src/components/ui/checkbox.tsx +28 -0
- package/src/components/ui/command.tsx +137 -0
- package/src/components/ui/dialog.tsx +127 -0
- package/src/components/ui/dropdown-menu.tsx +217 -0
- package/src/components/ui/form.tsx +138 -0
- package/src/components/ui/hover-card.tsx +36 -0
- package/src/components/ui/input-otp.tsx +66 -0
- package/src/components/ui/input.tsx +21 -0
- package/src/components/ui/label.tsx +21 -0
- package/src/components/ui/navigation-menu.tsx +142 -0
- package/src/components/ui/pagination.tsx +118 -0
- package/src/components/ui/popover.tsx +40 -0
- package/src/components/ui/progress.tsx +22 -0
- package/src/components/ui/radio-group.tsx +31 -0
- package/src/components/ui/resizable.tsx +46 -0
- package/src/components/ui/scroll-area.tsx +46 -0
- package/src/components/ui/select.tsx +158 -0
- package/src/components/ui/separator.tsx +26 -0
- package/src/components/ui/sheet.tsx +101 -0
- package/src/components/ui/skeleton.tsx +7 -0
- package/src/components/ui/sonner.tsx +23 -0
- package/src/components/ui/switch.tsx +26 -0
- package/src/components/ui/table.tsx +73 -0
- package/src/components/ui/tabs.tsx +40 -0
- package/src/components/ui/textarea.tsx +18 -0
- package/src/components/ui/tooltip.tsx +46 -0
- package/src/components/uix/action/index.tsx +37 -0
- package/src/components/uix/alert/index.tsx +43 -0
- package/src/components/uix/alert-dialog/index.tsx +109 -0
- package/src/components/uix/avatar/index.tsx +25 -0
- package/src/components/uix/breadcrumbs/index.tsx +38 -0
- package/src/components/uix/broadcast-channel-context/index.tsx +28 -0
- package/src/components/uix/button/index.tsx +29 -0
- package/src/components/uix/card/index.tsx +32 -0
- package/src/components/uix/checkbox/index.tsx +79 -0
- package/src/components/uix/checkbox-group/index.tsx +60 -0
- package/src/components/uix/combo-select/index.tsx +364 -0
- package/src/components/uix/config-provider/index.tsx +31 -0
- package/src/components/uix/data-table/index.tsx +491 -0
- package/src/components/uix/data-table/style.css +40 -0
- package/src/components/uix/date-picker/index.tsx +88 -0
- package/src/components/uix/date-range-picker/index.tsx +71 -0
- package/src/components/uix/dialog/index.tsx +70 -0
- package/src/components/uix/divider/index.tsx +23 -0
- package/src/components/uix/dropdown/index.tsx +117 -0
- package/src/components/uix/empty/index.tsx +29 -0
- package/src/components/uix/filters/index.tsx +105 -0
- package/src/components/uix/form/index.tsx +274 -0
- package/src/components/uix/image/index.tsx +13 -0
- package/src/components/uix/loading/index.tsx +24 -0
- package/src/components/uix/message/index.tsx +21 -0
- package/src/components/uix/pagination/index.tsx +180 -0
- package/src/components/uix/radio-group/index.tsx +35 -0
- package/src/components/uix/result/index.tsx +45 -0
- package/src/components/uix/select/index.tsx +93 -0
- package/src/components/uix/space/index.tsx +24 -0
- package/src/components/uix/spin/index.tsx +12 -0
- package/src/components/uix/steps/index.tsx +67 -0
- package/src/components/uix/switch/index.tsx +33 -0
- package/src/components/uix/tooltip/index.tsx +29 -0
- package/src/components/uix/tree/index.tsx +39 -0
- package/src/components/uix/tree/style.css +75 -0
- package/src/components/uix/tree-select/index.tsx +137 -0
- package/src/components/uix/tree-table/action.tsx +24 -0
- package/src/components/uix/tree-table/config.ts +2 -0
- package/src/components/uix/tree-table/index.tsx +86 -0
- package/src/components/uix/tree-table/utils.tsx +63 -0
- package/src/components/uix/uploader/index.tsx +237 -0
- package/src/components/uix/uploader/type.ts +20 -0
- package/src/components/uix/uploader/utils.ts +41 -0
- package/src/components/uix/value-formatter/index.tsx +59 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/resize.ts +29 -0
- package/src/hooks/use.outside.ts +30 -0
- package/src/index.ts +159 -0
- package/src/lib/formatters.ts +13 -0
- package/src/lib/index.ts +4 -0
- package/src/lib/is.ts +6 -0
- package/src/lib/react-dom.ts +98 -0
- package/src/lib/utils.ts +39 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type RefObject, useCallback, useEffect, useState } from "react";
|
|
2
|
+
|
|
3
|
+
export interface Size {
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const useSize = (ref: RefObject<HTMLElement | null>) => {
|
|
9
|
+
const [size, setSize] = useState<Size>({ width: 0, height: 0 });
|
|
10
|
+
|
|
11
|
+
const resize = useCallback(() => {
|
|
12
|
+
setSize({
|
|
13
|
+
width: ref.current?.offsetWidth || 0,
|
|
14
|
+
height: ref.current?.offsetHeight || 0,
|
|
15
|
+
});
|
|
16
|
+
}, [ref]);
|
|
17
|
+
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
const ro = new ResizeObserver(resize);
|
|
20
|
+
if (ref.current) {
|
|
21
|
+
ro.observe(ref.current);
|
|
22
|
+
}
|
|
23
|
+
return () => {
|
|
24
|
+
ro.disconnect();
|
|
25
|
+
};
|
|
26
|
+
}, [ref, resize]);
|
|
27
|
+
|
|
28
|
+
return size;
|
|
29
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Hook that alerts clicks outside of the passed ref
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// biome-ignore lint/suspicious/noExplicitAny: <refs>
|
|
8
|
+
export const useOutside = (call: () => void, refs: any) => {
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
/**
|
|
11
|
+
* Alert if clicked on outside of element
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
// biome-ignore lint/suspicious/noExplicitAny: <event>
|
|
15
|
+
const handleClickOutside = (event: any) => {
|
|
16
|
+
if (!refs) return;
|
|
17
|
+
// biome-ignore lint/suspicious/noExplicitAny: <hit>
|
|
18
|
+
const hit = refs.filter((ref: any) => !ref.current.contains(event.target));
|
|
19
|
+
if (hit.length === refs.length) {
|
|
20
|
+
call();
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
// Bind the event listener
|
|
24
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
25
|
+
return () => {
|
|
26
|
+
// Unbind the event listener on clean up
|
|
27
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
28
|
+
};
|
|
29
|
+
}, [refs, call]);
|
|
30
|
+
};
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
// utils
|
|
2
|
+
|
|
3
|
+
export { toast } from "sonner";
|
|
4
|
+
|
|
5
|
+
export {
|
|
6
|
+
InputOTP,
|
|
7
|
+
InputOTPGroup,
|
|
8
|
+
InputOTPSeparator,
|
|
9
|
+
InputOTPSlot,
|
|
10
|
+
} from "@meta-1/design/components/ui/input-otp";
|
|
11
|
+
export { Badge } from "./components/ui/badge";
|
|
12
|
+
export {
|
|
13
|
+
Breadcrumb,
|
|
14
|
+
BreadcrumbItem,
|
|
15
|
+
BreadcrumbLink,
|
|
16
|
+
BreadcrumbList,
|
|
17
|
+
BreadcrumbPage,
|
|
18
|
+
BreadcrumbSeparator,
|
|
19
|
+
} from "./components/ui/breadcrumb";
|
|
20
|
+
export { Calendar } from "./components/ui/calendar";
|
|
21
|
+
export {
|
|
22
|
+
Command,
|
|
23
|
+
CommandEmpty,
|
|
24
|
+
CommandGroup,
|
|
25
|
+
CommandInput,
|
|
26
|
+
CommandItem,
|
|
27
|
+
CommandList,
|
|
28
|
+
CommandSeparator,
|
|
29
|
+
CommandShortcut,
|
|
30
|
+
} from "./components/ui/command";
|
|
31
|
+
export * from "./components/ui/dropdown-menu";
|
|
32
|
+
export {
|
|
33
|
+
HoverCard,
|
|
34
|
+
HoverCardContent,
|
|
35
|
+
HoverCardTrigger,
|
|
36
|
+
} from "./components/ui/hover-card";
|
|
37
|
+
export { Input } from "./components/ui/input";
|
|
38
|
+
export * from "./components/ui/navigation-menu";
|
|
39
|
+
export {
|
|
40
|
+
Popover,
|
|
41
|
+
PopoverContent,
|
|
42
|
+
PopoverTrigger,
|
|
43
|
+
} from "./components/ui/popover";
|
|
44
|
+
export { Progress } from "./components/ui/progress";
|
|
45
|
+
export {
|
|
46
|
+
RadioGroup,
|
|
47
|
+
RadioGroupItem,
|
|
48
|
+
} from "./components/ui/radio-group";
|
|
49
|
+
export {
|
|
50
|
+
ResizableHandle,
|
|
51
|
+
ResizablePanel,
|
|
52
|
+
ResizablePanelGroup,
|
|
53
|
+
} from "./components/ui/resizable";
|
|
54
|
+
export { ScrollArea, ScrollBar } from "./components/ui/scroll-area";
|
|
55
|
+
export { Separator } from "./components/ui/separator";
|
|
56
|
+
export {
|
|
57
|
+
Sheet,
|
|
58
|
+
SheetClose,
|
|
59
|
+
SheetContent,
|
|
60
|
+
SheetDescription,
|
|
61
|
+
SheetFooter,
|
|
62
|
+
SheetHeader,
|
|
63
|
+
SheetTitle,
|
|
64
|
+
SheetTrigger,
|
|
65
|
+
} from "./components/ui/sheet";
|
|
66
|
+
export { Skeleton } from "./components/ui/skeleton";
|
|
67
|
+
// base
|
|
68
|
+
export { Toaster } from "./components/ui/sonner";
|
|
69
|
+
export {
|
|
70
|
+
Table,
|
|
71
|
+
TableBody,
|
|
72
|
+
TableCaption,
|
|
73
|
+
TableCell,
|
|
74
|
+
TableFooter,
|
|
75
|
+
TableHead,
|
|
76
|
+
TableHeader,
|
|
77
|
+
TableRow,
|
|
78
|
+
} from "./components/ui/table";
|
|
79
|
+
export { Tabs, TabsContent, TabsList, TabsTrigger } from "./components/ui/tabs";
|
|
80
|
+
export { Textarea } from "./components/ui/textarea";
|
|
81
|
+
export type { ActionProps } from "./components/uix/action";
|
|
82
|
+
export { Action } from "./components/uix/action";
|
|
83
|
+
export type { AlertProps } from "./components/uix/alert";
|
|
84
|
+
// extend
|
|
85
|
+
export { Alert } from "./components/uix/alert";
|
|
86
|
+
export type { ConfirmProps } from "./components/uix/alert-dialog";
|
|
87
|
+
export { useAlert } from "./components/uix/alert-dialog";
|
|
88
|
+
export type { AvatarProps } from "./components/uix/avatar";
|
|
89
|
+
export { Avatar } from "./components/uix/avatar";
|
|
90
|
+
export type { BreadcrumbsItemProps, BreadcrumbsProps } from "./components/uix/breadcrumbs";
|
|
91
|
+
export { Breadcrumbs, BreadcrumbsItem } from "./components/uix/breadcrumbs";
|
|
92
|
+
export type { BroadcastChannelProviderProps } from "./components/uix/broadcast-channel-context";
|
|
93
|
+
export { BroadcastChannelProvider, useBroadcastChannel } from "./components/uix/broadcast-channel-context";
|
|
94
|
+
export type { ButtonProps } from "./components/uix/button";
|
|
95
|
+
export { Button } from "./components/uix/button";
|
|
96
|
+
export type { CardProps } from "./components/uix/card";
|
|
97
|
+
export { Card } from "./components/uix/card";
|
|
98
|
+
export type { CheckboxProps } from "./components/uix/checkbox";
|
|
99
|
+
export { Checkbox } from "./components/uix/checkbox";
|
|
100
|
+
export type { CheckboxGroupOptionProps, CheckboxGroupProps } from "./components/uix/checkbox-group";
|
|
101
|
+
export { CheckboxGroup } from "./components/uix/checkbox-group";
|
|
102
|
+
export type { ComboSelectOptionProps, ComboSelectProps } from "./components/uix/combo-select";
|
|
103
|
+
export { ComboSelect } from "./components/uix/combo-select";
|
|
104
|
+
export type { ConfigProviderProps } from "./components/uix/config-provider";
|
|
105
|
+
export { ConfigProvider } from "./components/uix/config-provider";
|
|
106
|
+
export type { DataTableColumn, DataTableProps } from "./components/uix/data-table";
|
|
107
|
+
export { DataTable } from "./components/uix/data-table";
|
|
108
|
+
export type { DatePickerProps } from "./components/uix/date-picker";
|
|
109
|
+
export { DatePicker } from "./components/uix/date-picker";
|
|
110
|
+
export type { DateRangePickerProps } from "./components/uix/date-range-picker";
|
|
111
|
+
export { DateRangePicker } from "./components/uix/date-range-picker";
|
|
112
|
+
export type { DialogProps } from "./components/uix/dialog";
|
|
113
|
+
export { Dialog } from "./components/uix/dialog";
|
|
114
|
+
export type { DividerProps } from "./components/uix/divider";
|
|
115
|
+
export { Divider } from "./components/uix/divider";
|
|
116
|
+
export type { DropdownMenuItemProps, DropdownProps } from "./components/uix/dropdown";
|
|
117
|
+
export { Dropdown } from "./components/uix/dropdown";
|
|
118
|
+
export type { EmptyProps } from "./components/uix/empty";
|
|
119
|
+
export { Empty } from "./components/uix/empty";
|
|
120
|
+
export type { FilterItemProps, FiltersProps } from "./components/uix/filters";
|
|
121
|
+
export { Filters } from "./components/uix/filters";
|
|
122
|
+
export type { FieldItem, FormInstance, FormProps, RenderProps } from "./components/uix/form";
|
|
123
|
+
export { Form, FormItem } from "./components/uix/form";
|
|
124
|
+
export type { ImageProps } from "./components/uix/image";
|
|
125
|
+
export { Image } from "./components/uix/image";
|
|
126
|
+
export type { LoadingProps } from "./components/uix/loading";
|
|
127
|
+
export { Loading } from "./components/uix/loading";
|
|
128
|
+
export { useMessage } from "./components/uix/message";
|
|
129
|
+
export type { PaginationProps } from "./components/uix/pagination";
|
|
130
|
+
export { Pagination } from "./components/uix/pagination";
|
|
131
|
+
export type { SimpleRadioGroupOptionProps, SimpleRadioGroupProps } from "./components/uix/radio-group";
|
|
132
|
+
export { SimpleRadioGroup } from "./components/uix/radio-group";
|
|
133
|
+
export type { ResultProps } from "./components/uix/result";
|
|
134
|
+
export { Result } from "./components/uix/result";
|
|
135
|
+
export type { SelectOptionProps, SelectProps } from "./components/uix/select";
|
|
136
|
+
export { Select } from "./components/uix/select";
|
|
137
|
+
export { Space } from "./components/uix/space";
|
|
138
|
+
export type { SpinProps } from "./components/uix/spin";
|
|
139
|
+
export { Spin } from "./components/uix/spin";
|
|
140
|
+
export type { StepsItemProps, StepsProps } from "./components/uix/steps";
|
|
141
|
+
export { Steps, StepsItem } from "./components/uix/steps";
|
|
142
|
+
export type { SwitchProps } from "./components/uix/switch";
|
|
143
|
+
export { Switch } from "./components/uix/switch";
|
|
144
|
+
export type { TooltipProps } from "./components/uix/tooltip";
|
|
145
|
+
export { Tooltip } from "./components/uix/tooltip";
|
|
146
|
+
export type { TreeData, TreeProps } from "./components/uix/tree";
|
|
147
|
+
export { Tree } from "./components/uix/tree";
|
|
148
|
+
export type { TreeSelectProps } from "./components/uix/tree-select";
|
|
149
|
+
export { TreeSelect } from "./components/uix/tree-select";
|
|
150
|
+
export type { TreeTableColumn, TreeTableProps } from "./components/uix/tree-table";
|
|
151
|
+
export { TreeTable } from "./components/uix/tree-table";
|
|
152
|
+
export type { UploaderProps } from "./components/uix/uploader";
|
|
153
|
+
export { Uploader } from "./components/uix/uploader";
|
|
154
|
+
export type { HandleProps, UploadFile } from "./components/uix/uploader/type";
|
|
155
|
+
export type { ValueFormatterProps } from "./components/uix/value-formatter";
|
|
156
|
+
export { register, ValueFormatter } from "./components/uix/value-formatter";
|
|
157
|
+
// hooks
|
|
158
|
+
export * from "./hooks";
|
|
159
|
+
export * from "./lib";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import day from "dayjs";
|
|
2
|
+
|
|
3
|
+
// biome-ignore lint/suspicious/noExplicitAny: <v>
|
|
4
|
+
export const time = (v: any, format = "YYYY-MM-DD HH:mm:ss") => {
|
|
5
|
+
if (!v) return "--";
|
|
6
|
+
const d = day(v);
|
|
7
|
+
return d.isValid() ? d.format(format) : "--";
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
// biome-ignore lint/suspicious/noExplicitAny: <v>
|
|
11
|
+
export const defaultValue = (v: any) => {
|
|
12
|
+
return v === 0 ? v : v || "--";
|
|
13
|
+
};
|
package/src/lib/index.ts
ADDED
package/src/lib/is.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/** biome-ignore-all lint/suspicious/noExplicitAny: <any> */
|
|
2
|
+
|
|
3
|
+
import type { ReactElement } from "react";
|
|
4
|
+
import ReactDOM from "react-dom";
|
|
5
|
+
import { createRoot as reactDOMCreateRoot } from "react-dom/client";
|
|
6
|
+
|
|
7
|
+
import { isObject } from "./is";
|
|
8
|
+
|
|
9
|
+
type CreateRootFnType = (container: Element | DocumentFragment) => {
|
|
10
|
+
render: (container: ReactElement) => void;
|
|
11
|
+
unmount: () => void;
|
|
12
|
+
_unmount: () => void;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const reactDOMCreateRootCopy = reactDOMCreateRoot as CreateRootFnType;
|
|
16
|
+
|
|
17
|
+
const __SECRET_INTERNALS__ = "__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED";
|
|
18
|
+
|
|
19
|
+
const CopyReactDOM = ReactDOM as typeof ReactDOM & {
|
|
20
|
+
createRoot: CreateRootFnType;
|
|
21
|
+
// https://github.com/facebook/react/blob/4ff5f5719b348d9d8db14aaa49a48532defb4ab7/packages/react-dom/src/client/ReactDOM.js#L181
|
|
22
|
+
[__SECRET_INTERNALS__]: {
|
|
23
|
+
usingClientEntryPoint?: boolean;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
let copyRender: (
|
|
28
|
+
app: ReactElement,
|
|
29
|
+
container: Element | DocumentFragment,
|
|
30
|
+
) => {
|
|
31
|
+
render: (container: ReactElement) => void;
|
|
32
|
+
_unmount: () => void;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const isReact18 = Number(CopyReactDOM.version?.split(".")[0]) > 17;
|
|
36
|
+
const isReact19 = Number(CopyReactDOM.version?.split(".")[0]) > 18;
|
|
37
|
+
|
|
38
|
+
const updateUsingClientEntryPoint = (skipWarning?: boolean) => {
|
|
39
|
+
// https://github.com/facebook/react/blob/17806594cc28284fe195f918e8d77de3516848ec/packages/react-dom/npm/client.js#L10
|
|
40
|
+
// Avoid console warning
|
|
41
|
+
if (isObject(CopyReactDOM[__SECRET_INTERNALS__])) {
|
|
42
|
+
CopyReactDOM[__SECRET_INTERNALS__].usingClientEntryPoint = skipWarning;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
let createRoot: CreateRootFnType;
|
|
47
|
+
try {
|
|
48
|
+
createRoot = CopyReactDOM.createRoot;
|
|
49
|
+
} catch (_) {
|
|
50
|
+
//
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (isReact19) {
|
|
54
|
+
copyRender = (app: ReactElement, container: Element | DocumentFragment) => {
|
|
55
|
+
updateUsingClientEntryPoint(true);
|
|
56
|
+
const root = reactDOMCreateRootCopy(container);
|
|
57
|
+
updateUsingClientEntryPoint(false);
|
|
58
|
+
|
|
59
|
+
root.render(app);
|
|
60
|
+
|
|
61
|
+
root._unmount = () => {
|
|
62
|
+
setTimeout(() => {
|
|
63
|
+
root?.unmount?.();
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
return root;
|
|
67
|
+
};
|
|
68
|
+
} else if (isReact18) {
|
|
69
|
+
copyRender = (app: ReactElement, container: Element | DocumentFragment) => {
|
|
70
|
+
updateUsingClientEntryPoint(true);
|
|
71
|
+
const root = createRoot(container);
|
|
72
|
+
updateUsingClientEntryPoint(false);
|
|
73
|
+
|
|
74
|
+
root.render(app);
|
|
75
|
+
|
|
76
|
+
root._unmount = () => {
|
|
77
|
+
setTimeout(() => {
|
|
78
|
+
root?.unmount?.();
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
return root;
|
|
82
|
+
};
|
|
83
|
+
} else {
|
|
84
|
+
copyRender = (app: ReactElement, container: Element | DocumentFragment) => {
|
|
85
|
+
(CopyReactDOM as any).render(app, container);
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
render: (app: ReactElement) => {
|
|
89
|
+
(CopyReactDOM as any).render(app, container);
|
|
90
|
+
},
|
|
91
|
+
_unmount() {
|
|
92
|
+
(CopyReactDOM as any).unmountComponentAtNode(container);
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export const render = copyRender;
|
package/src/lib/utils.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type ClassValue, clsx } from "clsx";
|
|
2
|
+
import { twMerge } from "tailwind-merge";
|
|
3
|
+
|
|
4
|
+
export function cn(...inputs: ClassValue[]) {
|
|
5
|
+
return twMerge(clsx(inputs));
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// 简单的MD5实现(用于生成存储key)
|
|
9
|
+
export function md5Hash(text: string): string {
|
|
10
|
+
// 简化版MD5哈希算法
|
|
11
|
+
let hash = 0;
|
|
12
|
+
if (text.length === 0) return hash.toString();
|
|
13
|
+
|
|
14
|
+
for (let i = 0; i < text.length; i++) {
|
|
15
|
+
const char = text.charCodeAt(i);
|
|
16
|
+
hash = (hash << 5) - hash + char;
|
|
17
|
+
hash &= hash; // 转换为32位整数
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// 转换为16进制并确保长度
|
|
21
|
+
return Math.abs(hash).toString(16).padStart(8, "0");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// 生成DataTable列配置的存储key
|
|
25
|
+
export function generateColumnStorageKey(
|
|
26
|
+
columns: Array<{ accessorKey?: string | number | symbol; id?: string }>,
|
|
27
|
+
): string {
|
|
28
|
+
const keys = columns
|
|
29
|
+
.map((col) => {
|
|
30
|
+
const accessorKey = col.accessorKey ? String(col.accessorKey) : "";
|
|
31
|
+
const id = col.id || "";
|
|
32
|
+
return accessorKey || id;
|
|
33
|
+
})
|
|
34
|
+
.filter((key) => key)
|
|
35
|
+
.sort()
|
|
36
|
+
.join(",");
|
|
37
|
+
|
|
38
|
+
return md5Hash(keys);
|
|
39
|
+
}
|