@fakeoai/ui 0.0.0 → 0.0.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/README.md +4 -6
- package/dist/index.d.mts +10 -2
- package/dist/index.mjs +62 -1
- package/dist/index.mjs.map +1 -1
- package/dist/style.css +1 -0
- package/dist/style.d.mts +2 -0
- package/package.json +12 -6
- package/dist/index.d.ts +0 -6
- package/dist/index.js +0 -59
- package/dist/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ pnpm add my-react-component-library
|
|
|
15
15
|
## 使用
|
|
16
16
|
|
|
17
17
|
```tsx
|
|
18
|
-
import { Button, Card } from
|
|
18
|
+
import { Button, Card } from "my-react-component-library";
|
|
19
19
|
|
|
20
20
|
function App() {
|
|
21
21
|
return (
|
|
@@ -35,16 +35,13 @@ function App() {
|
|
|
35
35
|
按钮组件,支持多种样式和尺寸。
|
|
36
36
|
|
|
37
37
|
```tsx
|
|
38
|
-
<Button
|
|
39
|
-
variant="primary"
|
|
40
|
-
size="md"
|
|
41
|
-
onClick={() => console.log('clicked')}
|
|
42
|
-
>
|
|
38
|
+
<Button variant="primary" size="md" onClick={() => console.log("clicked")}>
|
|
43
39
|
按钮文本
|
|
44
40
|
</Button>
|
|
45
41
|
```
|
|
46
42
|
|
|
47
43
|
**Props:**
|
|
44
|
+
|
|
48
45
|
- `variant`: 'primary' | 'secondary' | 'outline'
|
|
49
46
|
- `size`: 'sm' | 'md' | 'lg'
|
|
50
47
|
- `onClick`: () => void
|
|
@@ -62,6 +59,7 @@ function App() {
|
|
|
62
59
|
```
|
|
63
60
|
|
|
64
61
|
**Props:**
|
|
62
|
+
|
|
65
63
|
- `title`: string (可选)
|
|
66
64
|
- `shadow`: 'sm' | 'md' | 'lg'
|
|
67
65
|
- `className`: string
|
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { SpinnerProps } from '@heroui/react';
|
|
2
|
+
import { SpinnerProps, InputProps } from '@heroui/react';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { ClassValue } from 'clsx';
|
|
3
5
|
|
|
4
6
|
declare function Loading({ className, ...p }: SpinnerProps): react_jsx_runtime.JSX.Element;
|
|
5
7
|
|
|
6
|
-
|
|
8
|
+
declare const Input: React.ForwardRefExoticComponent<Omit<InputProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
9
|
+
|
|
10
|
+
declare function Progress(): null;
|
|
11
|
+
|
|
12
|
+
declare function cn(...inputs: ClassValue[]): string;
|
|
13
|
+
|
|
14
|
+
export { Input, Loading, Progress, cn };
|
package/dist/index.mjs
CHANGED
|
@@ -26,7 +26,68 @@ function Loading({ className, ...p }) {
|
|
|
26
26
|
}
|
|
27
27
|
);
|
|
28
28
|
}
|
|
29
|
+
|
|
30
|
+
// src/components/input.tsx
|
|
31
|
+
import { Input as NextInput } from "@heroui/react";
|
|
32
|
+
import React from "react";
|
|
33
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
34
|
+
var Input = React.forwardRef(function Input2({ classNames, ...props }, ref) {
|
|
35
|
+
return /* @__PURE__ */ jsx2(
|
|
36
|
+
NextInput,
|
|
37
|
+
{
|
|
38
|
+
ref,
|
|
39
|
+
...props,
|
|
40
|
+
classNames: {
|
|
41
|
+
...classNames ?? {},
|
|
42
|
+
label: cn(
|
|
43
|
+
"group-data-[filled-within=true]:!-translate-y-1/2 group-data-[filled-within=true]:top-0 bg-transparent group-data-[filled-within=true]:bg-white group-data-[filled-within=true]:dark:bg-black transition-[transform,color,left,opacity,background] px-1",
|
|
44
|
+
classNames?.label
|
|
45
|
+
),
|
|
46
|
+
input: cn("h-full", classNames?.input)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// src/components/nprogress.tsx
|
|
53
|
+
import NProgress from "nprogress";
|
|
54
|
+
import { useEffect } from "react";
|
|
55
|
+
NProgress.configure({ showSpinner: false });
|
|
56
|
+
function Progress() {
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
let lastHref = window.location.href;
|
|
59
|
+
const handleRouteChange = () => {
|
|
60
|
+
NProgress.start();
|
|
61
|
+
const timer = setTimeout(() => NProgress.done(), 100);
|
|
62
|
+
return () => {
|
|
63
|
+
clearTimeout(timer);
|
|
64
|
+
NProgress.done();
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
const observer = new MutationObserver(() => {
|
|
68
|
+
const currentHref = window.location.href;
|
|
69
|
+
if (currentHref !== lastHref) {
|
|
70
|
+
lastHref = currentHref;
|
|
71
|
+
handleRouteChange();
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
observer.observe(document, {
|
|
75
|
+
subtree: true,
|
|
76
|
+
childList: true
|
|
77
|
+
});
|
|
78
|
+
window.addEventListener("popstate", handleRouteChange);
|
|
79
|
+
handleRouteChange();
|
|
80
|
+
return () => {
|
|
81
|
+
observer.disconnect();
|
|
82
|
+
window.removeEventListener("popstate", handleRouteChange);
|
|
83
|
+
};
|
|
84
|
+
}, []);
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
29
87
|
export {
|
|
30
|
-
|
|
88
|
+
Input,
|
|
89
|
+
Loading,
|
|
90
|
+
Progress,
|
|
91
|
+
cn
|
|
31
92
|
};
|
|
32
93
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/loading.tsx","../src/utils/clsx.ts"],"sourcesContent":["import { Spinner, SpinnerProps } from \"@heroui/react\";\nimport { cn } from \"../utils/clsx\";\n\nexport function Loading({ className, ...p }: SpinnerProps) {\n return (\n <Spinner\n color=\"default\"\n className={cn(\"absolute inset-0\", className)}\n label=\"加载中...\"\n classNames={{\n circle2: \"border-b-foreground\",\n circle1: \"border-b-foreground\",\n label: \"text-sm mt-2\"
|
|
1
|
+
{"version":3,"sources":["../src/components/loading.tsx","../src/utils/clsx.ts","../src/components/input.tsx","../src/components/nprogress.tsx"],"sourcesContent":["import { Spinner, SpinnerProps } from \"@heroui/react\";\nimport { cn } from \"../utils/clsx\";\n\nexport function Loading({ className, ...p }: SpinnerProps) {\n return (\n <Spinner\n color=\"default\"\n className={cn(\"absolute inset-0\", className)}\n label=\"加载中...\"\n classNames={{\n circle2: \"border-b-foreground\",\n circle1: \"border-b-foreground\",\n label: \"text-sm mt-2\"\n }}\n {...p}\n />\n );\n}\n","import { type ClassValue, clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n","import { Input as NextInput, InputProps } from \"@heroui/react\";\nimport React from \"react\";\nimport { cn } from \"../utils/clsx\";\n\nexport const Input = React.forwardRef<HTMLInputElement, InputProps>(function Input(\n { classNames, ...props },\n ref\n) {\n return (\n <NextInput\n ref={ref}\n {...(props as any)}\n classNames={{\n ...(classNames ?? {}),\n label: cn(\n \"group-data-[filled-within=true]:!-translate-y-1/2 group-data-[filled-within=true]:top-0 bg-transparent group-data-[filled-within=true]:bg-white group-data-[filled-within=true]:dark:bg-black transition-[transform,color,left,opacity,background] px-1\",\n classNames?.label\n ),\n input: cn(\"h-full\", classNames?.input)\n }}\n />\n );\n});\n","import NProgress from \"nprogress\";\nimport { useEffect } from \"react\";\n\nNProgress.configure({ showSpinner: false });\n\nexport function Progress() {\n useEffect(() => {\n let lastHref = window.location.href;\n\n const handleRouteChange = () => {\n NProgress.start();\n const timer = setTimeout(() => NProgress.done(), 100);\n return () => {\n clearTimeout(timer);\n NProgress.done();\n };\n };\n\n const observer = new MutationObserver(() => {\n const currentHref = window.location.href;\n if (currentHref !== lastHref) {\n lastHref = currentHref;\n handleRouteChange();\n }\n });\n\n observer.observe(document, {\n subtree: true,\n childList: true\n });\n\n window.addEventListener(\"popstate\", handleRouteChange);\n\n handleRouteChange();\n\n return () => {\n observer.disconnect();\n window.removeEventListener(\"popstate\", handleRouteChange);\n };\n }, []);\n\n return null;\n}\n"],"mappings":";AAAA,SAAS,eAA6B;;;ACAtC,SAA0B,YAAY;AACtC,SAAS,eAAe;AAEjB,SAAS,MAAM,QAAsB;AAC1C,SAAO,QAAQ,KAAK,MAAM,CAAC;AAC7B;;;ADAI;AAFG,SAAS,QAAQ,EAAE,WAAW,GAAG,EAAE,GAAiB;AACzD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAM;AAAA,MACN,WAAW,GAAG,oBAAoB,SAAS;AAAA,MAC3C,OAAM;AAAA,MACN,YAAY;AAAA,QACV,SAAS;AAAA,QACT,SAAS;AAAA,QACT,OAAO;AAAA,MACT;AAAA,MACC,GAAG;AAAA;AAAA,EACN;AAEJ;;;AEjBA,SAAS,SAAS,iBAA6B;AAC/C,OAAO,WAAW;AAQd,gBAAAA,YAAA;AALG,IAAM,QAAQ,MAAM,WAAyC,SAASC,OAC3E,EAAE,YAAY,GAAG,MAAM,GACvB,KACA;AACA,SACE,gBAAAD;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACC,GAAI;AAAA,MACL,YAAY;AAAA,QACV,GAAI,cAAc,CAAC;AAAA,QACnB,OAAO;AAAA,UACL;AAAA,UACA,YAAY;AAAA,QACd;AAAA,QACA,OAAO,GAAG,UAAU,YAAY,KAAK;AAAA,MACvC;AAAA;AAAA,EACF;AAEJ,CAAC;;;ACtBD,OAAO,eAAe;AACtB,SAAS,iBAAiB;AAE1B,UAAU,UAAU,EAAE,aAAa,MAAM,CAAC;AAEnC,SAAS,WAAW;AACzB,YAAU,MAAM;AACd,QAAI,WAAW,OAAO,SAAS;AAE/B,UAAM,oBAAoB,MAAM;AAC9B,gBAAU,MAAM;AAChB,YAAM,QAAQ,WAAW,MAAM,UAAU,KAAK,GAAG,GAAG;AACpD,aAAO,MAAM;AACX,qBAAa,KAAK;AAClB,kBAAU,KAAK;AAAA,MACjB;AAAA,IACF;AAEA,UAAM,WAAW,IAAI,iBAAiB,MAAM;AAC1C,YAAM,cAAc,OAAO,SAAS;AACpC,UAAI,gBAAgB,UAAU;AAC5B,mBAAW;AACX,0BAAkB;AAAA,MACpB;AAAA,IACF,CAAC;AAED,aAAS,QAAQ,UAAU;AAAA,MACzB,SAAS;AAAA,MACT,WAAW;AAAA,IACb,CAAC;AAED,WAAO,iBAAiB,YAAY,iBAAiB;AAErD,sBAAkB;AAElB,WAAO,MAAM;AACX,eAAS,WAAW;AACpB,aAAO,oBAAoB,YAAY,iBAAiB;AAAA,IAC1D;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO;AACT;","names":["jsx","Input"]}
|
package/dist/style.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import url("nprogress/nprogress.css");
|
package/dist/style.d.mts
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fakeoai/ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "A modern React component library",
|
|
4
5
|
"main": "./dist/index.js",
|
|
5
6
|
"module": "./dist/index.mjs",
|
|
6
7
|
"types": "./dist/index.d.ts",
|
|
@@ -9,12 +10,14 @@
|
|
|
9
10
|
"types": "./dist/index.d.ts",
|
|
10
11
|
"import": "./dist/index.mjs",
|
|
11
12
|
"require": "./dist/index.js"
|
|
12
|
-
}
|
|
13
|
+
},
|
|
14
|
+
"./style": "./dist/src/style.css"
|
|
13
15
|
},
|
|
14
16
|
"files": [
|
|
15
17
|
"dist"
|
|
16
18
|
],
|
|
17
19
|
"scripts": {
|
|
20
|
+
"format": "prettier --write .",
|
|
18
21
|
"build": "tsup",
|
|
19
22
|
"dev": "tsup --watch",
|
|
20
23
|
"prepublishOnly": "npm run build"
|
|
@@ -25,7 +28,7 @@
|
|
|
25
28
|
"ui",
|
|
26
29
|
"typescript"
|
|
27
30
|
],
|
|
28
|
-
"author": "
|
|
31
|
+
"author": "Your Name",
|
|
29
32
|
"license": "MIT",
|
|
30
33
|
"peerDependencies": {
|
|
31
34
|
"react": ">=16.8.0",
|
|
@@ -34,13 +37,16 @@
|
|
|
34
37
|
"dependencies": {
|
|
35
38
|
"@heroui/react": "^2.8.4",
|
|
36
39
|
"clsx": "^2.1.1",
|
|
40
|
+
"nprogress": "^0.2.0",
|
|
37
41
|
"tailwind-merge": "^3.3.1",
|
|
38
42
|
"tsup": "^8.5.0",
|
|
39
43
|
"tsx": "^4.20.5",
|
|
40
44
|
"typescript": "^5.9.2"
|
|
41
45
|
},
|
|
42
46
|
"devDependencies": {
|
|
43
|
-
"@types/
|
|
44
|
-
"@types/react
|
|
47
|
+
"@types/nprogress": "^0.2.3",
|
|
48
|
+
"@types/react": "^19.1.13",
|
|
49
|
+
"@types/react-dom": "^19.1.9",
|
|
50
|
+
"prettier": "^3.6.2"
|
|
45
51
|
}
|
|
46
|
-
}
|
|
52
|
+
}
|
package/dist/index.d.ts
DELETED
package/dist/index.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
-
// index.tsx
|
|
21
|
-
var index_exports = {};
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
Loading: () => Loading
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(index_exports);
|
|
26
|
-
|
|
27
|
-
// src/components/loading.tsx
|
|
28
|
-
var import_react = require("@heroui/react");
|
|
29
|
-
|
|
30
|
-
// src/utils/clsx.ts
|
|
31
|
-
var import_clsx = require("clsx");
|
|
32
|
-
var import_tailwind_merge = require("tailwind-merge");
|
|
33
|
-
function cn(...inputs) {
|
|
34
|
-
return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// src/components/loading.tsx
|
|
38
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
39
|
-
function Loading({ className, ...p }) {
|
|
40
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
41
|
-
import_react.Spinner,
|
|
42
|
-
{
|
|
43
|
-
color: "default",
|
|
44
|
-
className: cn("absolute inset-0", className),
|
|
45
|
-
label: "\u52A0\u8F7D\u4E2D...",
|
|
46
|
-
classNames: {
|
|
47
|
-
circle2: "border-b-foreground",
|
|
48
|
-
circle1: "border-b-foreground",
|
|
49
|
-
label: "text-sm mt-2"
|
|
50
|
-
},
|
|
51
|
-
...p
|
|
52
|
-
}
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
56
|
-
0 && (module.exports = {
|
|
57
|
-
Loading
|
|
58
|
-
});
|
|
59
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../index.tsx","../src/components/loading.tsx","../src/utils/clsx.ts"],"sourcesContent":["export * from \"./src/components\";\n","import { Spinner, SpinnerProps } from \"@heroui/react\";\nimport { cn } from \"../utils/clsx\";\n\nexport function Loading({ className, ...p }: SpinnerProps) {\n return (\n <Spinner\n color=\"default\"\n className={cn(\"absolute inset-0\", className)}\n label=\"加载中...\"\n classNames={{\n circle2: \"border-b-foreground\",\n circle1: \"border-b-foreground\",\n label: \"text-sm mt-2\",\n }}\n {...p}\n />\n );\n}\n","import { type ClassValue, clsx } from 'clsx'\nimport { twMerge } from 'tailwind-merge'\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs))\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAsC;;;ACAtC,kBAAsC;AACtC,4BAAwB;AAEjB,SAAS,MAAM,QAAsB;AAC1C,aAAO,mCAAQ,kBAAK,MAAM,CAAC;AAC7B;;;ADAI;AAFG,SAAS,QAAQ,EAAE,WAAW,GAAG,EAAE,GAAiB;AACzD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAM;AAAA,MACN,WAAW,GAAG,oBAAoB,SAAS;AAAA,MAC3C,OAAM;AAAA,MACN,YAAY;AAAA,QACV,SAAS;AAAA,QACT,SAAS;AAAA,QACT,OAAO;AAAA,MACT;AAAA,MACC,GAAG;AAAA;AAAA,EACN;AAEJ;","names":[]}
|