deepsea-components 5.8.4 → 5.9.1
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/dist/cjs/components/Unify.d.ts +13 -0
- package/dist/cjs/components/Unify.js +45 -0
- package/dist/cjs/components/Unify.js.map +7 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/index.js.map +2 -2
- package/dist/esm/components/Unify.d.ts +13 -0
- package/dist/esm/components/Unify.js +38 -0
- package/dist/esm/components/Unify.js.map +1 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Unify.tsx +35 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CSSProperties, ComponentProps, FC, ReactNode } from "react";
|
|
2
|
+
export interface UnifyConfig {
|
|
3
|
+
className?: string;
|
|
4
|
+
style?: CSSProperties;
|
|
5
|
+
}
|
|
6
|
+
export interface UnifyConfigProviderProps extends UnifyConfig {
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
export declare const UnifyConfigProvider: FC<UnifyConfigProviderProps>;
|
|
10
|
+
export type UnifyProps<T extends keyof JSX.IntrinsicElements = "div"> = ComponentProps<T> & {
|
|
11
|
+
as?: T;
|
|
12
|
+
};
|
|
13
|
+
export declare function Unify<T extends keyof JSX.IntrinsicElements = "div">(props: UnifyProps<T>): ReactNode;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/components/Unify.tsx
|
|
21
|
+
var Unify_exports = {};
|
|
22
|
+
__export(Unify_exports, {
|
|
23
|
+
Unify: () => Unify,
|
|
24
|
+
UnifyConfigProvider: () => UnifyConfigProvider
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(Unify_exports);
|
|
27
|
+
var import_react = require("react");
|
|
28
|
+
var import_deepsea_tools = require("deepsea-tools");
|
|
29
|
+
var UnifyConfigContext = (0, import_react.createContext)({});
|
|
30
|
+
var UnifyConfigProvider = ({ className, style, children }) => /* @__PURE__ */ React.createElement(UnifyConfigContext.Provider, { value: { className, style } }, children);
|
|
31
|
+
function Unify(props) {
|
|
32
|
+
const { as, className, style, ...rest } = props;
|
|
33
|
+
const { className: _className, style: _style } = (0, import_react.useContext)(UnifyConfigContext);
|
|
34
|
+
return (0, import_react.createElement)(as ?? "div", {
|
|
35
|
+
className: (0, import_deepsea_tools.clsx)(_className, className),
|
|
36
|
+
style: { ..._style, ...style },
|
|
37
|
+
...rest
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
+
0 && (module.exports = {
|
|
42
|
+
Unify,
|
|
43
|
+
UnifyConfigProvider
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=Unify.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/Unify.tsx"],
|
|
4
|
+
"sourcesContent": ["\"use client\"\r\n\r\nimport { CSSProperties, ComponentProps, FC, ReactNode, createContext, createElement, useContext } from \"react\"\r\nimport { clsx } from \"deepsea-tools\"\r\n\r\nexport interface UnifyConfig {\r\n className?: string\r\n style?: CSSProperties\r\n}\r\n\r\nconst UnifyConfigContext = createContext<UnifyConfig>({})\r\n\r\nexport interface UnifyConfigProviderProps extends UnifyConfig {\r\n children?: ReactNode\r\n}\r\n\r\nexport const UnifyConfigProvider: FC<UnifyConfigProviderProps> = ({ className, style, children }) => (\r\n <UnifyConfigContext.Provider value={{ className, style }}>{children}</UnifyConfigContext.Provider>\r\n)\r\n\r\nexport type UnifyProps<T extends keyof JSX.IntrinsicElements = \"div\"> = ComponentProps<T> & {\r\n as?: T\r\n}\r\n\r\nexport function Unify<T extends keyof JSX.IntrinsicElements = \"div\">(props: UnifyProps<T>) {\r\n const { as, className, style, ...rest } = props\r\n const { className: _className, style: _style } = useContext(UnifyConfigContext)\r\n\r\n return createElement(as ?? \"div\", {\r\n className: clsx(_className, className),\r\n style: { ..._style, ...style },\r\n ...rest,\r\n }) as ReactNode\r\n}\r\n\r\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAuG;AACvG,2BAAqB;AAOrB,IAAM,yBAAqB,4BAA2B,CAAC,CAAC;AAMjD,IAAM,sBAAoD,CAAC,EAAE,WAAW,OAAO,SAAS,MAC3F,oCAAC,mBAAmB,UAAnB,EAA4B,OAAO,EAAE,WAAW,MAAM,KAAI,QAAS;AAOjE,SAAS,MAAqD,OAAsB;AACvF,QAAM,EAAE,IAAI,WAAW,OAAO,GAAG,KAAK,IAAI;AAC1C,QAAM,EAAE,WAAW,YAAY,OAAO,OAAO,QAAI,yBAAW,kBAAkB;AAE9E,aAAO,4BAAc,MAAM,OAAO;AAAA,IAC9B,eAAW,2BAAK,YAAY,SAAS;AAAA,IACrC,OAAO,EAAE,GAAG,QAAQ,GAAG,MAAM;AAAA,IAC7B,GAAG;AAAA,EACP,CAAC;AACL;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -20,5 +20,6 @@ export * from "./components/Title";
|
|
|
20
20
|
export * from "./components/TransitionBox";
|
|
21
21
|
export * from "./components/TransitionNum";
|
|
22
22
|
export * from "./components/Trapezium";
|
|
23
|
+
export * from "./components/Unify";
|
|
23
24
|
export * from "./utils/getReactVersion";
|
|
24
25
|
export * from "./utils/index";
|
package/dist/cjs/index.js
CHANGED
|
@@ -38,6 +38,7 @@ __reExport(src_exports, require("./components/Title"), module.exports);
|
|
|
38
38
|
__reExport(src_exports, require("./components/TransitionBox"), module.exports);
|
|
39
39
|
__reExport(src_exports, require("./components/TransitionNum"), module.exports);
|
|
40
40
|
__reExport(src_exports, require("./components/Trapezium"), module.exports);
|
|
41
|
+
__reExport(src_exports, require("./components/Unify"), module.exports);
|
|
41
42
|
__reExport(src_exports, require("./utils/getReactVersion"), module.exports);
|
|
42
43
|
__reExport(src_exports, require("./utils/index"), module.exports);
|
|
43
44
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -64,6 +65,7 @@ __reExport(src_exports, require("./utils/index"), module.exports);
|
|
|
64
65
|
...require("./components/TransitionBox"),
|
|
65
66
|
...require("./components/TransitionNum"),
|
|
66
67
|
...require("./components/Trapezium"),
|
|
68
|
+
...require("./components/Unify"),
|
|
67
69
|
...require("./utils/getReactVersion"),
|
|
68
70
|
...require("./utils/index")
|
|
69
71
|
});
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export * from \"@/components/AutoFit\"\nexport * from \"@/components/AutoScroll\"\nexport * from \"@/components/AutoSizeTextarea\"\nexport * from \"@/components/CircleText\"\nexport * from \"@/components/CopyButton\"\nexport * from \"@/components/Echart\"\nexport * from \"@/components/ExportExcel\"\nexport * from \"@/components/Flow\"\nexport * from \"@/components/FormLabel\"\nexport * from \"@/components/HlsPlayer\"\nexport * from \"@/components/ImportExcel\"\nexport * from \"@/components/InfiniteScroll\"\nexport * from \"@/components/InputFile\"\nexport * from \"@/components/LoopSwiper\"\nexport * from \"@/components/Ring\"\nexport * from \"@/components/Scroll\"\nexport * from \"@/components/SectionRing\"\nexport * from \"@/components/Skeleton\"\nexport * from \"@/components/Title\"\nexport * from \"@/components/TransitionBox\"\nexport * from \"@/components/TransitionNum\"\nexport * from \"@/components/Trapezium\"\nexport * from \"@/utils/getReactVersion\"\nexport * from \"@/utils/index\"\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,iCAAd;AACA,wBAAc,oCADd;AAEA,wBAAc,0CAFd;AAGA,wBAAc,oCAHd;AAIA,wBAAc,oCAJd;AAKA,wBAAc,gCALd;AAMA,wBAAc,qCANd;AAOA,wBAAc,8BAPd;AAQA,wBAAc,mCARd;AASA,wBAAc,mCATd;AAUA,wBAAc,qCAVd;AAWA,wBAAc,wCAXd;AAYA,wBAAc,mCAZd;AAaA,wBAAc,oCAbd;AAcA,wBAAc,8BAdd;AAeA,wBAAc,gCAfd;AAgBA,wBAAc,qCAhBd;AAiBA,wBAAc,kCAjBd;AAkBA,wBAAc,+BAlBd;AAmBA,wBAAc,uCAnBd;AAoBA,wBAAc,uCApBd;AAqBA,wBAAc,mCArBd;AAsBA,wBAAc
|
|
4
|
+
"sourcesContent": ["export * from \"@/components/AutoFit\"\nexport * from \"@/components/AutoScroll\"\nexport * from \"@/components/AutoSizeTextarea\"\nexport * from \"@/components/CircleText\"\nexport * from \"@/components/CopyButton\"\nexport * from \"@/components/Echart\"\nexport * from \"@/components/ExportExcel\"\nexport * from \"@/components/Flow\"\nexport * from \"@/components/FormLabel\"\nexport * from \"@/components/HlsPlayer\"\nexport * from \"@/components/ImportExcel\"\nexport * from \"@/components/InfiniteScroll\"\nexport * from \"@/components/InputFile\"\nexport * from \"@/components/LoopSwiper\"\nexport * from \"@/components/Ring\"\nexport * from \"@/components/Scroll\"\nexport * from \"@/components/SectionRing\"\nexport * from \"@/components/Skeleton\"\nexport * from \"@/components/Title\"\nexport * from \"@/components/TransitionBox\"\nexport * from \"@/components/TransitionNum\"\nexport * from \"@/components/Trapezium\"\nexport * from \"@/components/Unify\"\nexport * from \"@/utils/getReactVersion\"\nexport * from \"@/utils/index\"\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,iCAAd;AACA,wBAAc,oCADd;AAEA,wBAAc,0CAFd;AAGA,wBAAc,oCAHd;AAIA,wBAAc,oCAJd;AAKA,wBAAc,gCALd;AAMA,wBAAc,qCANd;AAOA,wBAAc,8BAPd;AAQA,wBAAc,mCARd;AASA,wBAAc,mCATd;AAUA,wBAAc,qCAVd;AAWA,wBAAc,wCAXd;AAYA,wBAAc,mCAZd;AAaA,wBAAc,oCAbd;AAcA,wBAAc,8BAdd;AAeA,wBAAc,gCAfd;AAgBA,wBAAc,qCAhBd;AAiBA,wBAAc,kCAjBd;AAkBA,wBAAc,+BAlBd;AAmBA,wBAAc,uCAnBd;AAoBA,wBAAc,uCApBd;AAqBA,wBAAc,mCArBd;AAsBA,wBAAc,+BAtBd;AAuBA,wBAAc,oCAvBd;AAwBA,wBAAc,0BAxBd;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CSSProperties, ComponentProps, FC, ReactNode } from "react";
|
|
2
|
+
export interface UnifyConfig {
|
|
3
|
+
className?: string;
|
|
4
|
+
style?: CSSProperties;
|
|
5
|
+
}
|
|
6
|
+
export interface UnifyConfigProviderProps extends UnifyConfig {
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
export declare const UnifyConfigProvider: FC<UnifyConfigProviderProps>;
|
|
10
|
+
export type UnifyProps<T extends keyof JSX.IntrinsicElements = "div"> = ComponentProps<T> & {
|
|
11
|
+
as?: T;
|
|
12
|
+
};
|
|
13
|
+
export declare function Unify<T extends keyof JSX.IntrinsicElements = "div">(props: UnifyProps<T>): ReactNode;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { createContext, createElement, useContext } from "react";
|
|
4
|
+
import { clsx } from "deepsea-tools";
|
|
5
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
|
+
const UnifyConfigContext = /*#__PURE__*/createContext({});
|
|
7
|
+
export const UnifyConfigProvider = ({
|
|
8
|
+
className,
|
|
9
|
+
style,
|
|
10
|
+
children
|
|
11
|
+
}) => /*#__PURE__*/_jsx(UnifyConfigContext.Provider, {
|
|
12
|
+
value: {
|
|
13
|
+
className,
|
|
14
|
+
style
|
|
15
|
+
},
|
|
16
|
+
children: children
|
|
17
|
+
});
|
|
18
|
+
export function Unify(props) {
|
|
19
|
+
const {
|
|
20
|
+
as,
|
|
21
|
+
className,
|
|
22
|
+
style,
|
|
23
|
+
...rest
|
|
24
|
+
} = props;
|
|
25
|
+
const {
|
|
26
|
+
className: _className,
|
|
27
|
+
style: _style
|
|
28
|
+
} = useContext(UnifyConfigContext);
|
|
29
|
+
return /*#__PURE__*/createElement(as ?? "div", {
|
|
30
|
+
className: clsx(_className, className),
|
|
31
|
+
style: {
|
|
32
|
+
..._style,
|
|
33
|
+
...style
|
|
34
|
+
},
|
|
35
|
+
...rest
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=Unify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createContext","createElement","useContext","clsx","jsx","_jsx","UnifyConfigContext","UnifyConfigProvider","className","style","children","Provider","value","Unify","props","as","rest","_className","_style"],"sources":["../../../src/components/Unify.tsx"],"sourcesContent":["\"use client\"\r\n\r\nimport { CSSProperties, ComponentProps, FC, ReactNode, createContext, createElement, useContext } from \"react\"\r\nimport { clsx } from \"deepsea-tools\"\r\n\r\nexport interface UnifyConfig {\r\n className?: string\r\n style?: CSSProperties\r\n}\r\n\r\nconst UnifyConfigContext = createContext<UnifyConfig>({})\r\n\r\nexport interface UnifyConfigProviderProps extends UnifyConfig {\r\n children?: ReactNode\r\n}\r\n\r\nexport const UnifyConfigProvider: FC<UnifyConfigProviderProps> = ({ className, style, children }) => (\r\n <UnifyConfigContext.Provider value={{ className, style }}>{children}</UnifyConfigContext.Provider>\r\n)\r\n\r\nexport type UnifyProps<T extends keyof JSX.IntrinsicElements = \"div\"> = ComponentProps<T> & {\r\n as?: T\r\n}\r\n\r\nexport function Unify<T extends keyof JSX.IntrinsicElements = \"div\">(props: UnifyProps<T>) {\r\n const { as, className, style, ...rest } = props\r\n const { className: _className, style: _style } = useContext(UnifyConfigContext)\r\n\r\n return createElement(as ?? \"div\", {\r\n className: clsx(_className, className),\r\n style: { ..._style, ...style },\r\n ...rest,\r\n }) as ReactNode\r\n}\r\n\r\n"],"mappings":"AAAA,YAAY;;AAEZ,SAAuDA,aAAa,EAAEC,aAAa,EAAEC,UAAU,QAAQ,OAAO;AAC9G,SAASC,IAAI,QAAQ,eAAe;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAOpC,MAAMC,kBAAkB,gBAAGN,aAAa,CAAc,CAAC,CAAC,CAAC;AAMzD,OAAO,MAAMO,mBAAiD,GAAGA,CAAC;EAAEC,SAAS;EAAEC,KAAK;EAAEC;AAAS,CAAC,kBAC5FL,IAAA,CAACC,kBAAkB,CAACK,QAAQ;EAACC,KAAK,EAAE;IAAEJ,SAAS;IAAEC;EAAM,CAAE;EAAAC,QAAA,EAAEA;AAAQ,CAA8B,CACpG;AAMD,OAAO,SAASG,KAAKA,CAAgDC,KAAoB,EAAE;EACvF,MAAM;IAAEC,EAAE;IAAEP,SAAS;IAAEC,KAAK;IAAE,GAAGO;EAAK,CAAC,GAAGF,KAAK;EAC/C,MAAM;IAAEN,SAAS,EAAES,UAAU;IAAER,KAAK,EAAES;EAAO,CAAC,GAAGhB,UAAU,CAACI,kBAAkB,CAAC;EAE/E,oBAAOL,aAAa,CAACc,EAAE,IAAI,KAAK,EAAE;IAC9BP,SAAS,EAAEL,IAAI,CAACc,UAAU,EAAET,SAAS,CAAC;IACtCC,KAAK,EAAE;MAAE,GAAGS,MAAM;MAAE,GAAGT;IAAM,CAAC;IAC9B,GAAGO;EACP,CAAC,CAAC;AACN"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -20,5 +20,6 @@ export * from "./components/Title";
|
|
|
20
20
|
export * from "./components/TransitionBox";
|
|
21
21
|
export * from "./components/TransitionNum";
|
|
22
22
|
export * from "./components/Trapezium";
|
|
23
|
+
export * from "./components/Unify";
|
|
23
24
|
export * from "./utils/getReactVersion";
|
|
24
25
|
export * from "./utils/index";
|
package/dist/esm/index.js
CHANGED
|
@@ -20,6 +20,7 @@ export * from "./components/Title";
|
|
|
20
20
|
export * from "./components/TransitionBox";
|
|
21
21
|
export * from "./components/TransitionNum";
|
|
22
22
|
export * from "./components/Trapezium";
|
|
23
|
+
export * from "./components/Unify";
|
|
23
24
|
export * from "./utils/getReactVersion";
|
|
24
25
|
export * from "./utils";
|
|
25
26
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":["export * from \"@/components/AutoFit\"\nexport * from \"@/components/AutoScroll\"\nexport * from \"@/components/AutoSizeTextarea\"\nexport * from \"@/components/CircleText\"\nexport * from \"@/components/CopyButton\"\nexport * from \"@/components/Echart\"\nexport * from \"@/components/ExportExcel\"\nexport * from \"@/components/Flow\"\nexport * from \"@/components/FormLabel\"\nexport * from \"@/components/HlsPlayer\"\nexport * from \"@/components/ImportExcel\"\nexport * from \"@/components/InfiniteScroll\"\nexport * from \"@/components/InputFile\"\nexport * from \"@/components/LoopSwiper\"\nexport * from \"@/components/Ring\"\nexport * from \"@/components/Scroll\"\nexport * from \"@/components/SectionRing\"\nexport * from \"@/components/Skeleton\"\nexport * from \"@/components/Title\"\nexport * from \"@/components/TransitionBox\"\nexport * from \"@/components/TransitionNum\"\nexport * from \"@/components/Trapezium\"\nexport * from \"@/utils/getReactVersion\"\nexport * from \"@/utils/index\"\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
|
|
1
|
+
{"version":3,"names":[],"sources":["../../src/index.ts"],"sourcesContent":["export * from \"@/components/AutoFit\"\nexport * from \"@/components/AutoScroll\"\nexport * from \"@/components/AutoSizeTextarea\"\nexport * from \"@/components/CircleText\"\nexport * from \"@/components/CopyButton\"\nexport * from \"@/components/Echart\"\nexport * from \"@/components/ExportExcel\"\nexport * from \"@/components/Flow\"\nexport * from \"@/components/FormLabel\"\nexport * from \"@/components/HlsPlayer\"\nexport * from \"@/components/ImportExcel\"\nexport * from \"@/components/InfiniteScroll\"\nexport * from \"@/components/InputFile\"\nexport * from \"@/components/LoopSwiper\"\nexport * from \"@/components/Ring\"\nexport * from \"@/components/Scroll\"\nexport * from \"@/components/SectionRing\"\nexport * from \"@/components/Skeleton\"\nexport * from \"@/components/Title\"\nexport * from \"@/components/TransitionBox\"\nexport * from \"@/components/TransitionNum\"\nexport * from \"@/components/Trapezium\"\nexport * from \"@/components/Unify\"\nexport * from \"@/utils/getReactVersion\"\nexport * from \"@/utils/index\"\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { CSSProperties, ComponentProps, FC, ReactNode, createContext, createElement, useContext } from "react"
|
|
4
|
+
import { clsx } from "deepsea-tools"
|
|
5
|
+
|
|
6
|
+
export interface UnifyConfig {
|
|
7
|
+
className?: string
|
|
8
|
+
style?: CSSProperties
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const UnifyConfigContext = createContext<UnifyConfig>({})
|
|
12
|
+
|
|
13
|
+
export interface UnifyConfigProviderProps extends UnifyConfig {
|
|
14
|
+
children?: ReactNode
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const UnifyConfigProvider: FC<UnifyConfigProviderProps> = ({ className, style, children }) => (
|
|
18
|
+
<UnifyConfigContext.Provider value={{ className, style }}>{children}</UnifyConfigContext.Provider>
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
export type UnifyProps<T extends keyof JSX.IntrinsicElements = "div"> = ComponentProps<T> & {
|
|
22
|
+
as?: T
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function Unify<T extends keyof JSX.IntrinsicElements = "div">(props: UnifyProps<T>) {
|
|
26
|
+
const { as, className, style, ...rest } = props
|
|
27
|
+
const { className: _className, style: _style } = useContext(UnifyConfigContext)
|
|
28
|
+
|
|
29
|
+
return createElement(as ?? "div", {
|
|
30
|
+
className: clsx(_className, className),
|
|
31
|
+
style: { ..._style, ...style },
|
|
32
|
+
...rest,
|
|
33
|
+
}) as ReactNode
|
|
34
|
+
}
|
|
35
|
+
|
package/src/index.ts
CHANGED
|
@@ -20,5 +20,6 @@ export * from "@/components/Title"
|
|
|
20
20
|
export * from "@/components/TransitionBox"
|
|
21
21
|
export * from "@/components/TransitionNum"
|
|
22
22
|
export * from "@/components/Trapezium"
|
|
23
|
+
export * from "@/components/Unify"
|
|
23
24
|
export * from "@/utils/getReactVersion"
|
|
24
25
|
export * from "@/utils/index"
|