yuand 1.0.0
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 +23 -0
- package/es/components/Table/index.d.ts +12 -0
- package/es/components/Table/index.js +326 -0
- package/es/components/Table/style.css +3 -0
- package/es/components/Table/types.d.ts +101 -0
- package/es/components/Table/types.js +1 -0
- package/es/components/Table/useTable.d.ts +3 -0
- package/es/components/Table/useTable.js +76 -0
- package/es/components/TableConfig/index.d.ts +11 -0
- package/es/components/TableConfig/index.js +19 -0
- package/es/components/TableUseFetch/index.d.ts +12 -0
- package/es/components/TableUseFetch/index.js +283 -0
- package/es/components/TableUseFetch/style.css +3 -0
- package/es/components/TableUseFetch/types.d.ts +100 -0
- package/es/components/TableUseFetch/types.js +1 -0
- package/es/components/TableUseFetch/useTable.d.ts +3 -0
- package/es/components/TableUseFetch/useTable.js +78 -0
- package/es/components/index.d.ts +3 -0
- package/es/components/index.js +3 -0
- package/es/fetch.d.ts +137 -0
- package/es/fetch.js +534 -0
- package/es/hooks/index.d.ts +4 -0
- package/es/hooks/index.js +4 -0
- package/es/hooks/useFetch.d.ts +17 -0
- package/es/hooks/useFetch.js +41 -0
- package/es/hooks/useMutation.d.ts +14 -0
- package/es/hooks/useMutation.js +26 -0
- package/es/hooks/useQuery.d.ts +14 -0
- package/es/hooks/useQuery.js +40 -0
- package/es/hooks/useX.d.ts +1 -0
- package/es/hooks/useX.js +13 -0
- package/es/index.d.ts +4 -0
- package/es/index.js +4 -0
- package/es/utils/index.d.ts +6 -0
- package/es/utils/index.js +23 -0
- package/es/utils/table.d.ts +15 -0
- package/es/utils/table.js +106 -0
- package/es/utils/util.d.ts +2 -0
- package/es/utils/util.js +6 -0
- package/lang/en_US.json +6 -0
- package/lang/zh_CN.json +6 -0
- package/lib/components/Table/index.d.ts +12 -0
- package/lib/components/Table/index.js +330 -0
- package/lib/components/Table/style.css +3 -0
- package/lib/components/Table/types.d.ts +101 -0
- package/lib/components/Table/types.js +17 -0
- package/lib/components/Table/useTable.d.ts +3 -0
- package/lib/components/Table/useTable.js +85 -0
- package/lib/components/TableConfig/index.d.ts +11 -0
- package/lib/components/TableConfig/index.js +55 -0
- package/lib/components/TableUseFetch/index.d.ts +12 -0
- package/lib/components/TableUseFetch/index.js +303 -0
- package/lib/components/TableUseFetch/style.css +3 -0
- package/lib/components/TableUseFetch/types.d.ts +100 -0
- package/lib/components/TableUseFetch/types.js +17 -0
- package/lib/components/TableUseFetch/useTable.d.ts +3 -0
- package/lib/components/TableUseFetch/useTable.js +86 -0
- package/lib/components/index.d.ts +3 -0
- package/lib/components/index.js +45 -0
- package/lib/fetch.d.ts +137 -0
- package/lib/fetch.js +366 -0
- package/lib/hooks/index.d.ts +4 -0
- package/lib/hooks/index.js +48 -0
- package/lib/hooks/useFetch.d.ts +17 -0
- package/lib/hooks/useFetch.js +62 -0
- package/lib/hooks/useMutation.d.ts +14 -0
- package/lib/hooks/useMutation.js +43 -0
- package/lib/hooks/useQuery.d.ts +14 -0
- package/lib/hooks/useQuery.js +57 -0
- package/lib/hooks/useX.d.ts +1 -0
- package/lib/hooks/useX.js +37 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.js +29 -0
- package/lib/utils/index.d.ts +6 -0
- package/lib/utils/index.js +60 -0
- package/lib/utils/table.d.ts +15 -0
- package/lib/utils/table.js +124 -0
- package/lib/utils/util.d.ts +2 -0
- package/lib/utils/util.js +32 -0
- package/package.json +46 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/hooks/index.ts
|
|
30
|
+
var hooks_exports = {};
|
|
31
|
+
__export(hooks_exports, {
|
|
32
|
+
useFetch: () => import_useFetch.default,
|
|
33
|
+
useMutation: () => import_useMutation.default,
|
|
34
|
+
useQuery: () => import_useQuery.default,
|
|
35
|
+
useX: () => import_useX.default
|
|
36
|
+
});
|
|
37
|
+
module.exports = __toCommonJS(hooks_exports);
|
|
38
|
+
var import_useX = __toESM(require("./useX"));
|
|
39
|
+
var import_useFetch = __toESM(require("./useFetch"));
|
|
40
|
+
var import_useMutation = __toESM(require("./useMutation"));
|
|
41
|
+
var import_useQuery = __toESM(require("./useQuery"));
|
|
42
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
+
0 && (module.exports = {
|
|
44
|
+
useFetch,
|
|
45
|
+
useMutation,
|
|
46
|
+
useQuery,
|
|
47
|
+
useX
|
|
48
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { HttpClientConfig, HttpMethod } from "../fetch";
|
|
2
|
+
import type { Result } from "ahooks/lib/useRequest/src/types";
|
|
3
|
+
import type { Options } from "ahooks/lib/useRequest/src/types";
|
|
4
|
+
export interface UseFetchOption<TData = any> extends Options<TData, any[]> {
|
|
5
|
+
ignoreError?: boolean;
|
|
6
|
+
returnData?: boolean;
|
|
7
|
+
json?: unknown;
|
|
8
|
+
data?: unknown;
|
|
9
|
+
method?: HttpMethod;
|
|
10
|
+
headers?: HeadersInit;
|
|
11
|
+
onLogout?: (error: any) => any;
|
|
12
|
+
}
|
|
13
|
+
declare const useFetch: {
|
|
14
|
+
<TData = any>(url: string, options?: UseFetchOption<TData>): Result<TData, any[]>;
|
|
15
|
+
config(options?: HttpClientConfig): void;
|
|
16
|
+
};
|
|
17
|
+
export default useFetch;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/hooks/useFetch.ts
|
|
20
|
+
var useFetch_exports = {};
|
|
21
|
+
__export(useFetch_exports, {
|
|
22
|
+
default: () => useFetch_default
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(useFetch_exports);
|
|
25
|
+
var import_ahooks = require("ahooks");
|
|
26
|
+
var import_fetch = require("../fetch");
|
|
27
|
+
var import_util = require("../utils/util");
|
|
28
|
+
var useFetch = (url, options) => {
|
|
29
|
+
const {
|
|
30
|
+
ignoreError,
|
|
31
|
+
returnData,
|
|
32
|
+
method,
|
|
33
|
+
json,
|
|
34
|
+
data,
|
|
35
|
+
headers,
|
|
36
|
+
onLogout,
|
|
37
|
+
...others
|
|
38
|
+
} = options || {};
|
|
39
|
+
let body = json ?? data;
|
|
40
|
+
const fetcher = (fetcherData, fetcherOptions) => {
|
|
41
|
+
if ((0, import_util.isObject)(fetcherData) && Object.prototype.hasOwnProperty.call(fetcherData, "nativeEvent")) {
|
|
42
|
+
fetcherData = void 0;
|
|
43
|
+
}
|
|
44
|
+
body = fetcherData ?? body;
|
|
45
|
+
fetcherOptions = fetcherOptions ?? {};
|
|
46
|
+
fetcherOptions = {
|
|
47
|
+
json: body,
|
|
48
|
+
returnData,
|
|
49
|
+
method,
|
|
50
|
+
ignoreError,
|
|
51
|
+
headers,
|
|
52
|
+
onLogout,
|
|
53
|
+
...fetcherOptions
|
|
54
|
+
};
|
|
55
|
+
return import_fetch.rq.request(url, fetcherOptions);
|
|
56
|
+
};
|
|
57
|
+
return (0, import_ahooks.useRequest)(fetcher, others);
|
|
58
|
+
};
|
|
59
|
+
useFetch.config = (options = {}) => {
|
|
60
|
+
import_fetch.rq.config(options);
|
|
61
|
+
};
|
|
62
|
+
var useFetch_default = useFetch;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { HttpMethod } from "../fetch";
|
|
2
|
+
import type { UseMutationResult, UseMutationOptions } from "@tanstack/react-query";
|
|
3
|
+
interface Options<TData, TError = unknown, TVariables = void, TOnMutateResult = unknown> extends UseMutationOptions<TData, TError, TVariables, TOnMutateResult> {
|
|
4
|
+
url: string;
|
|
5
|
+
method?: HttpMethod;
|
|
6
|
+
json?: unknown;
|
|
7
|
+
headers?: Record<string, string>;
|
|
8
|
+
}
|
|
9
|
+
type Result<TData, TError = unknown, TVariables = any, TOnMutateResult = unknown> = UseMutationResult<TData, TError, TVariables, TOnMutateResult> & {
|
|
10
|
+
mutate: (...args: any[]) => void;
|
|
11
|
+
mutateAsync: (...args: any[]) => void;
|
|
12
|
+
};
|
|
13
|
+
export default function useMutationHooks<TData = unknown, TError = unknown, TVariables = void, TOnMutateResult = unknown>(options: Options<TData, TError, TVariables, TOnMutateResult>): Result<TData, TError, TVariables, TOnMutateResult>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/hooks/useMutation.ts
|
|
20
|
+
var useMutation_exports = {};
|
|
21
|
+
__export(useMutation_exports, {
|
|
22
|
+
default: () => useMutationHooks
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(useMutation_exports);
|
|
25
|
+
var import_react_query = require("@tanstack/react-query");
|
|
26
|
+
var import_fetch = require("../fetch");
|
|
27
|
+
var import_util = require("../utils/util");
|
|
28
|
+
function useMutationHooks(options) {
|
|
29
|
+
const { url, json, method, headers, ...others } = options;
|
|
30
|
+
return (0, import_react_query.useMutation)({
|
|
31
|
+
mutationFn(data) {
|
|
32
|
+
if ((0, import_util.isObject)(data) && Object.prototype.hasOwnProperty.call(data, "nativeEvent")) {
|
|
33
|
+
data = void 0;
|
|
34
|
+
}
|
|
35
|
+
return import_fetch.rq.request(url, {
|
|
36
|
+
method,
|
|
37
|
+
json: data ?? json,
|
|
38
|
+
headers
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
...others
|
|
42
|
+
});
|
|
43
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { HttpMethod } from "../fetch";
|
|
2
|
+
import type { UseQueryResult, UseQueryOptions } from "@tanstack/react-query";
|
|
3
|
+
type UseQueryOptionsPartial<TData> = Partial<Pick<UseQueryOptions<TData>, "queryFn">> & Omit<UseQueryOptions<TData>, "queryFn">;
|
|
4
|
+
interface Options<TData> extends UseQueryOptionsPartial<TData> {
|
|
5
|
+
method?: HttpMethod;
|
|
6
|
+
headers?: Record<string, string>;
|
|
7
|
+
ignoreError?: boolean;
|
|
8
|
+
returnData?: boolean;
|
|
9
|
+
useSignal?: boolean;
|
|
10
|
+
onBefore?: () => void;
|
|
11
|
+
onLogout?: () => void;
|
|
12
|
+
}
|
|
13
|
+
declare function useQueryHooks<TData = unknown>(options: Options<TData>): UseQueryResult<TData>;
|
|
14
|
+
export default useQueryHooks;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/hooks/useQuery.ts
|
|
20
|
+
var useQuery_exports = {};
|
|
21
|
+
__export(useQuery_exports, {
|
|
22
|
+
default: () => useQuery_default
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(useQuery_exports);
|
|
25
|
+
var import_react_query = require("@tanstack/react-query");
|
|
26
|
+
var import_fetch = require("../fetch");
|
|
27
|
+
function useQueryHooks(options) {
|
|
28
|
+
const {
|
|
29
|
+
queryKey,
|
|
30
|
+
ignoreError,
|
|
31
|
+
returnData,
|
|
32
|
+
method,
|
|
33
|
+
headers,
|
|
34
|
+
onLogout,
|
|
35
|
+
onBefore,
|
|
36
|
+
useSignal = false,
|
|
37
|
+
...others
|
|
38
|
+
} = options || {};
|
|
39
|
+
return (0, import_react_query.useQuery)({
|
|
40
|
+
queryKey,
|
|
41
|
+
queryFn: ({ queryKey: queryKey2, signal }) => {
|
|
42
|
+
onBefore == null ? void 0 : onBefore();
|
|
43
|
+
const [url, json] = queryKey2;
|
|
44
|
+
return import_fetch.rq.request(url, {
|
|
45
|
+
json,
|
|
46
|
+
returnData,
|
|
47
|
+
method,
|
|
48
|
+
ignoreError,
|
|
49
|
+
signal: useSignal ? signal : void 0,
|
|
50
|
+
headers,
|
|
51
|
+
onLogout
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
...others
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
var useQuery_default = useQueryHooks;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function useX(column: any[] | ((data: any) => any[])): number;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/hooks/useX.ts
|
|
20
|
+
var useX_exports = {};
|
|
21
|
+
__export(useX_exports, {
|
|
22
|
+
default: () => useX
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(useX_exports);
|
|
25
|
+
var import_react = require("react");
|
|
26
|
+
function useX(column) {
|
|
27
|
+
if (!Array.isArray(column))
|
|
28
|
+
return 0;
|
|
29
|
+
return (0, import_react.useMemo)(() => {
|
|
30
|
+
if (!column.length)
|
|
31
|
+
return 0;
|
|
32
|
+
const columns = column.filter((item) => !item.hidden);
|
|
33
|
+
return columns.reduce((a, b) => {
|
|
34
|
+
return a + parseInt(b.width || 0);
|
|
35
|
+
}, 0);
|
|
36
|
+
}, [column]);
|
|
37
|
+
}
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
|
|
16
|
+
// src/index.ts
|
|
17
|
+
var src_exports = {};
|
|
18
|
+
module.exports = __toCommonJS(src_exports);
|
|
19
|
+
__reExport(src_exports, require("./components"), module.exports);
|
|
20
|
+
__reExport(src_exports, require("./utils"), module.exports);
|
|
21
|
+
__reExport(src_exports, require("./hooks"), module.exports);
|
|
22
|
+
__reExport(src_exports, require("./fetch"), module.exports);
|
|
23
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
24
|
+
0 && (module.exports = {
|
|
25
|
+
...require("./components"),
|
|
26
|
+
...require("./utils"),
|
|
27
|
+
...require("./hooks"),
|
|
28
|
+
...require("./fetch")
|
|
29
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/utils/index.ts
|
|
30
|
+
var utils_exports = {};
|
|
31
|
+
__export(utils_exports, {
|
|
32
|
+
formatDuration: () => formatDuration
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(utils_exports);
|
|
35
|
+
var import_dayjs = __toESM(require("dayjs"));
|
|
36
|
+
var import_duration = __toESM(require("dayjs/plugin/duration"));
|
|
37
|
+
import_dayjs.default.extend(import_duration.default);
|
|
38
|
+
function formatDuration(seconds) {
|
|
39
|
+
if (!seconds || seconds === 0)
|
|
40
|
+
return "0秒";
|
|
41
|
+
const duration2 = import_dayjs.default.duration(seconds, "seconds");
|
|
42
|
+
const days = Math.floor(duration2.asDays());
|
|
43
|
+
const hours = duration2.hours();
|
|
44
|
+
const minutes = duration2.minutes();
|
|
45
|
+
const secs = duration2.seconds();
|
|
46
|
+
let result = "";
|
|
47
|
+
if (days > 0)
|
|
48
|
+
result += `${days}天`;
|
|
49
|
+
if (hours > 0)
|
|
50
|
+
result += `${hours}小时`;
|
|
51
|
+
if (minutes > 0)
|
|
52
|
+
result += `${minutes}分`;
|
|
53
|
+
if (secs > 0)
|
|
54
|
+
result += `${secs}秒`;
|
|
55
|
+
return result || "0秒";
|
|
56
|
+
}
|
|
57
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
58
|
+
0 && (module.exports = {
|
|
59
|
+
formatDuration
|
|
60
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface GetQueryProps {
|
|
2
|
+
page: number;
|
|
3
|
+
size: number;
|
|
4
|
+
sorter: {
|
|
5
|
+
field?: string;
|
|
6
|
+
order?: string;
|
|
7
|
+
};
|
|
8
|
+
search: Record<string, unknown>;
|
|
9
|
+
params: Record<string, unknown>;
|
|
10
|
+
}
|
|
11
|
+
export declare const getDataSource: <T extends Record<string, unknown>>(data: T, key: string) => T[];
|
|
12
|
+
export declare const getQuery: ({ page, size, sorter, search, params, }: GetQueryProps) => Record<string, unknown>;
|
|
13
|
+
export declare const getTotal: <T = unknown>(key: string, data: T) => number;
|
|
14
|
+
export declare const formatDate: (key: string, data: Record<string, any>, format?: string) => Record<string, any>;
|
|
15
|
+
export declare const removeEmpty: (data: Record<string, any>) => Record<string, any>;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/utils/table.ts
|
|
20
|
+
var table_exports = {};
|
|
21
|
+
__export(table_exports, {
|
|
22
|
+
formatDate: () => formatDate,
|
|
23
|
+
getDataSource: () => getDataSource,
|
|
24
|
+
getQuery: () => getQuery,
|
|
25
|
+
getTotal: () => getTotal,
|
|
26
|
+
removeEmpty: () => removeEmpty
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(table_exports);
|
|
29
|
+
var isObject = (oj) => Object.prototype.toString.call(oj) === "[object Object]";
|
|
30
|
+
var getDataSource = (data, key) => {
|
|
31
|
+
if (Array.isArray(data))
|
|
32
|
+
return data;
|
|
33
|
+
if (key.includes(".")) {
|
|
34
|
+
const keys = key.split(".");
|
|
35
|
+
let source = data;
|
|
36
|
+
keys.forEach((it) => {
|
|
37
|
+
if (source) {
|
|
38
|
+
source = source[it];
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
if (Array.isArray(source)) {
|
|
42
|
+
return source;
|
|
43
|
+
}
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
return data[key];
|
|
47
|
+
};
|
|
48
|
+
var getQuery = ({
|
|
49
|
+
page,
|
|
50
|
+
size,
|
|
51
|
+
sorter = {},
|
|
52
|
+
search = {},
|
|
53
|
+
params = {}
|
|
54
|
+
}) => {
|
|
55
|
+
const sort = sorter.order ? {
|
|
56
|
+
orderField: sorter.field,
|
|
57
|
+
isAsc: sorter.order === "ascend"
|
|
58
|
+
} : {};
|
|
59
|
+
return {
|
|
60
|
+
page,
|
|
61
|
+
size,
|
|
62
|
+
...sort,
|
|
63
|
+
...params,
|
|
64
|
+
...search
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
var getTotal = (key, data) => {
|
|
68
|
+
if (Array.isArray(data))
|
|
69
|
+
return 0;
|
|
70
|
+
if (key.includes(".")) {
|
|
71
|
+
const keys = key.split(".");
|
|
72
|
+
let source = data;
|
|
73
|
+
keys.forEach((it) => {
|
|
74
|
+
if (source) {
|
|
75
|
+
source = source[it];
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
return source;
|
|
79
|
+
}
|
|
80
|
+
return data[key] || 0;
|
|
81
|
+
};
|
|
82
|
+
var formatValue = (key, data, format = "YYYY-MM-DD") => {
|
|
83
|
+
const it = data[key];
|
|
84
|
+
if (Array.isArray(it) && it.length > 0) {
|
|
85
|
+
data[key] = it.map((item) => item.format(format));
|
|
86
|
+
} else {
|
|
87
|
+
data[key] = it.format(format);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
var formatDate = (key, data, format = "YYYY-MM-DD") => {
|
|
91
|
+
if (!isObject(data))
|
|
92
|
+
return data;
|
|
93
|
+
if (typeof key === "string" && key in data) {
|
|
94
|
+
formatValue(key, data, format);
|
|
95
|
+
return data;
|
|
96
|
+
}
|
|
97
|
+
if (Array.isArray(key)) {
|
|
98
|
+
for (const it of key) {
|
|
99
|
+
if (it in data) {
|
|
100
|
+
formatValue(it, data, format);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return data;
|
|
104
|
+
}
|
|
105
|
+
return data;
|
|
106
|
+
};
|
|
107
|
+
var removeEmpty = (data) => {
|
|
108
|
+
if (!isObject(data))
|
|
109
|
+
return data;
|
|
110
|
+
Object.keys(data).forEach((key) => {
|
|
111
|
+
if (data[key] === "" || Array.isArray(data[key]) && data[key].toString() === "") {
|
|
112
|
+
delete data[key];
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
return data;
|
|
116
|
+
};
|
|
117
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
118
|
+
0 && (module.exports = {
|
|
119
|
+
formatDate,
|
|
120
|
+
getDataSource,
|
|
121
|
+
getQuery,
|
|
122
|
+
getTotal,
|
|
123
|
+
removeEmpty
|
|
124
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/utils/util.ts
|
|
20
|
+
var util_exports = {};
|
|
21
|
+
__export(util_exports, {
|
|
22
|
+
isFunction: () => isFunction,
|
|
23
|
+
isObject: () => isObject
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(util_exports);
|
|
26
|
+
var isObject = (oj) => Object.prototype.toString.call(oj) === "[object Object]";
|
|
27
|
+
var isFunction = (oj) => Object.prototype.toString.call(oj) === "[object Function]";
|
|
28
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
29
|
+
0 && (module.exports = {
|
|
30
|
+
isFunction,
|
|
31
|
+
isObject
|
|
32
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "yuand",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "hyu",
|
|
5
|
+
"module": "./es/index",
|
|
6
|
+
"main": "./lib/index",
|
|
7
|
+
"types": "./es/index.d.ts",
|
|
8
|
+
"repository": "git@github.com:suyi660/and-yu.git",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"dev": "father dev",
|
|
11
|
+
"build": "sudo father build",
|
|
12
|
+
"build:deps": "father prebundle",
|
|
13
|
+
"prepublishOnly": "father doctor && npm run build",
|
|
14
|
+
"publish": "npm publish --access public"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [],
|
|
17
|
+
"authors": [
|
|
18
|
+
"yu"
|
|
19
|
+
],
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"files": [
|
|
22
|
+
"es",
|
|
23
|
+
"lib",
|
|
24
|
+
"lang"
|
|
25
|
+
],
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@rc-component/father-plugin": "^2.1.3",
|
|
28
|
+
"@types/react": "^18.3.12",
|
|
29
|
+
"@types/react-dom": "^18.3.1",
|
|
30
|
+
"babel-plugin-import": "^1.13.8",
|
|
31
|
+
"father": "^4.6.9",
|
|
32
|
+
"typescript": "^5.9.3"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@babel/runtime": "^7.28.4",
|
|
36
|
+
"ahooks": "^3.9.6",
|
|
37
|
+
"dayjs": "^1.11.19",
|
|
38
|
+
"zustand": "^5.0.9"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"@tanstack/react-query": "^5.80.0",
|
|
42
|
+
"antd": ">=5.25.2",
|
|
43
|
+
"react": ">=18.2",
|
|
44
|
+
"react-dom": ">=18.2"
|
|
45
|
+
}
|
|
46
|
+
}
|