@wzyjs/hooks 0.0.31 → 0.2.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/dist/{index.d.ts → cjs/index.d.ts} +4 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +63 -0
- package/dist/cjs/useDateRange.d.ts +23 -0
- package/dist/cjs/useDateRange.d.ts.map +1 -0
- package/dist/cjs/useDateRange.js +131 -0
- package/dist/{useEffectValue.d.ts → cjs/useEffectValue.d.ts} +1 -0
- package/dist/cjs/useEffectValue.d.ts.map +1 -0
- package/dist/cjs/useEffectValue.js +34 -0
- package/dist/{useElementScrollVisible.d.ts → cjs/useElementScrollVisible.d.ts} +1 -0
- package/dist/cjs/useElementScrollVisible.d.ts.map +1 -0
- package/dist/cjs/useElementScrollVisible.js +61 -0
- package/dist/{useHideFooter.d.ts → cjs/useHideFooter.d.ts} +1 -0
- package/dist/cjs/useHideFooter.d.ts.map +1 -0
- package/dist/cjs/useHideFooter.js +38 -0
- package/dist/cjs/useOptions.d.ts +14 -0
- package/dist/cjs/useOptions.d.ts.map +1 -0
- package/dist/cjs/useOptions.js +60 -0
- package/dist/{useRequestPro.d.ts → cjs/useRequestPro.d.ts} +1 -0
- package/dist/cjs/useRequestPro.d.ts.map +1 -0
- package/dist/cjs/useRequestPro.js +76 -0
- package/dist/{useVisibleInfo.d.ts → cjs/useVisibleInfo.d.ts} +1 -0
- package/dist/cjs/useVisibleInfo.d.ts.map +1 -0
- package/dist/cjs/useVisibleInfo.js +45 -0
- package/dist/{index.js → esm/index.d.ts} +4 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/useDateRange.d.ts +23 -0
- package/dist/esm/useDateRange.d.ts.map +1 -0
- package/dist/esm/useDateRange.js +113 -0
- package/dist/esm/useEffectValue.d.ts +3 -0
- package/dist/esm/useEffectValue.d.ts.map +1 -0
- package/dist/esm/useEffectValue.js +18 -0
- package/dist/esm/useElementScrollVisible.d.ts +6 -0
- package/dist/esm/useElementScrollVisible.d.ts.map +1 -0
- package/dist/esm/useElementScrollVisible.js +52 -0
- package/dist/esm/useHideFooter.d.ts +2 -0
- package/dist/esm/useHideFooter.d.ts.map +1 -0
- package/dist/esm/useHideFooter.js +13 -0
- package/dist/esm/useOptions.d.ts +14 -0
- package/dist/esm/useOptions.d.ts.map +1 -0
- package/dist/esm/useOptions.js +60 -0
- package/dist/esm/useRequestPro.d.ts +12 -0
- package/dist/esm/useRequestPro.d.ts.map +1 -0
- package/dist/esm/useRequestPro.js +64 -0
- package/dist/esm/useVisibleInfo.d.ts +6 -0
- package/dist/esm/useVisibleInfo.d.ts.map +1 -0
- package/dist/esm/useVisibleInfo.js +32 -0
- package/package.json +16 -9
- package/dist/useEffectValue.js +0 -6
- package/dist/useElementScrollVisible.js +0 -36
- package/dist/useFormRef.d.ts +0 -2
- package/dist/useFormRef.js +0 -4
- package/dist/useHideFooter.js +0 -11
- package/dist/useRequestPro.js +0 -51
- package/dist/useStateCallback.d.ts +0 -1
- package/dist/useStateCallback.js +0 -12
- package/dist/useVisibleInfo.js +0 -18
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
export * from 'ahooks';
|
|
2
|
+
export { default as useUrlState } from '@ahooksjs/use-url-state';
|
|
2
3
|
export { useCopyToClipboard, useCookie, useUpdate } from 'react-use';
|
|
3
4
|
export * from './useRequestPro';
|
|
4
5
|
export * from './useEffectValue';
|
|
5
6
|
export * from './useElementScrollVisible';
|
|
6
7
|
export * from './useHideFooter';
|
|
7
8
|
export * from './useVisibleInfo';
|
|
9
|
+
export * from './useDateRange';
|
|
10
|
+
export * from './useOptions';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AAEtB,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAEhE,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAEpE,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,2BAA2B,CAAA;AACzC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA"}
|
|
@@ -0,0 +1,63 @@
|
|
|
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 __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var src_exports = {};
|
|
32
|
+
__export(src_exports, {
|
|
33
|
+
useCookie: () => import_react_use.useCookie,
|
|
34
|
+
useCopyToClipboard: () => import_react_use.useCopyToClipboard,
|
|
35
|
+
useUpdate: () => import_react_use.useUpdate,
|
|
36
|
+
useUrlState: () => import_use_url_state.default
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(src_exports);
|
|
39
|
+
__reExport(src_exports, require("ahooks"), module.exports);
|
|
40
|
+
var import_use_url_state = __toESM(require("@ahooksjs/use-url-state"));
|
|
41
|
+
var import_react_use = require("react-use");
|
|
42
|
+
__reExport(src_exports, require("./useRequestPro"), module.exports);
|
|
43
|
+
__reExport(src_exports, require("./useEffectValue"), module.exports);
|
|
44
|
+
__reExport(src_exports, require("./useElementScrollVisible"), module.exports);
|
|
45
|
+
__reExport(src_exports, require("./useHideFooter"), module.exports);
|
|
46
|
+
__reExport(src_exports, require("./useVisibleInfo"), module.exports);
|
|
47
|
+
__reExport(src_exports, require("./useDateRange"), module.exports);
|
|
48
|
+
__reExport(src_exports, require("./useOptions"), module.exports);
|
|
49
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
50
|
+
0 && (module.exports = {
|
|
51
|
+
useCookie,
|
|
52
|
+
useCopyToClipboard,
|
|
53
|
+
useUpdate,
|
|
54
|
+
useUrlState,
|
|
55
|
+
...require("ahooks"),
|
|
56
|
+
...require("./useRequestPro"),
|
|
57
|
+
...require("./useEffectValue"),
|
|
58
|
+
...require("./useElementScrollVisible"),
|
|
59
|
+
...require("./useHideFooter"),
|
|
60
|
+
...require("./useVisibleInfo"),
|
|
61
|
+
...require("./useDateRange"),
|
|
62
|
+
...require("./useOptions")
|
|
63
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { dayjs, Dayjs } from '@wzyjs/utils';
|
|
2
|
+
export declare enum PresetType {
|
|
3
|
+
TODAY = "\u4ECA\u5929",
|
|
4
|
+
THIS_WEEK = "\u672C\u5468",
|
|
5
|
+
LAST_WEEK = "\u4E0A\u5468",
|
|
6
|
+
THIS_MONTH = "\u672C\u6708",
|
|
7
|
+
LAST_MONTH = "\u4E0A\u6708"
|
|
8
|
+
}
|
|
9
|
+
export declare const rangePresets: {
|
|
10
|
+
label: string;
|
|
11
|
+
value: [Dayjs, Dayjs];
|
|
12
|
+
}[];
|
|
13
|
+
interface Config {
|
|
14
|
+
defaultDateRange?: PresetType | [Dayjs, Dayjs];
|
|
15
|
+
}
|
|
16
|
+
export declare const useDateRange: (config: Config) => {
|
|
17
|
+
dateRange: [dayjs.Dayjs, dayjs.Dayjs];
|
|
18
|
+
onChange: (dateRange?: any) => void;
|
|
19
|
+
onClickPrev: () => void;
|
|
20
|
+
onClickNext: () => void;
|
|
21
|
+
};
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=useDateRange.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useDateRange.d.ts","sourceRoot":"","sources":["../src/useDateRange.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,cAAc,CAAA;AAE3C,oBAAY,UAAU;IACpB,KAAK,iBAAO;IACZ,SAAS,iBAAO;IAChB,SAAS,iBAAO;IAChB,UAAU,iBAAO;IACjB,UAAU,iBAAO;CAClB;AAED,eAAO,MAAM,YAAY,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;CAAE,EAqBlE,CAAA;AA4BD,UAAU,MAAM;IACd,gBAAgB,CAAC,EAAE,UAAU,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;CAC/C;AAED,eAAO,MAAM,YAAY,WAAY,MAAM;;2BAgBhB,GAAG;;;CAyC7B,CAAA"}
|
|
@@ -0,0 +1,131 @@
|
|
|
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/useDateRange.ts
|
|
20
|
+
var useDateRange_exports = {};
|
|
21
|
+
__export(useDateRange_exports, {
|
|
22
|
+
PresetType: () => PresetType,
|
|
23
|
+
rangePresets: () => rangePresets,
|
|
24
|
+
useDateRange: () => useDateRange
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(useDateRange_exports);
|
|
27
|
+
var import_react = require("react");
|
|
28
|
+
var import_utils = require("@wzyjs/utils");
|
|
29
|
+
var PresetType = /* @__PURE__ */ ((PresetType2) => {
|
|
30
|
+
PresetType2["TODAY"] = "今天";
|
|
31
|
+
PresetType2["THIS_WEEK"] = "本周";
|
|
32
|
+
PresetType2["LAST_WEEK"] = "上周";
|
|
33
|
+
PresetType2["THIS_MONTH"] = "本月";
|
|
34
|
+
PresetType2["LAST_MONTH"] = "上月";
|
|
35
|
+
return PresetType2;
|
|
36
|
+
})(PresetType || {});
|
|
37
|
+
var rangePresets = [
|
|
38
|
+
{
|
|
39
|
+
label: "今天" /* TODAY */,
|
|
40
|
+
value: [(0, import_utils.dayjs)().startOf("day"), (0, import_utils.dayjs)().endOf("day")]
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
label: "本周" /* THIS_WEEK */,
|
|
44
|
+
value: [(0, import_utils.dayjs)().startOf("week"), (0, import_utils.dayjs)().endOf("week")]
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
label: "上周" /* LAST_WEEK */,
|
|
48
|
+
value: [(0, import_utils.dayjs)().subtract(1, "week").startOf("week"), (0, import_utils.dayjs)().subtract(1, "week").endOf("week")]
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
label: "本月" /* THIS_MONTH */,
|
|
52
|
+
value: [(0, import_utils.dayjs)().startOf("month"), (0, import_utils.dayjs)().endOf("month")]
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
label: "上月" /* LAST_MONTH */,
|
|
56
|
+
value: [(0, import_utils.dayjs)().subtract(1, "month").startOf("month"), (0, import_utils.dayjs)().subtract(1, "month").endOf("month")]
|
|
57
|
+
}
|
|
58
|
+
];
|
|
59
|
+
var checkDateRules = (dateRange) => {
|
|
60
|
+
const [date1, date2] = dateRange;
|
|
61
|
+
if (date1.isSame(date2, "day")) {
|
|
62
|
+
return 1;
|
|
63
|
+
}
|
|
64
|
+
if (date1.day() === 1 && date2.day() === 0 || date1.day() === 0 && date2.day() === 1) {
|
|
65
|
+
return 2;
|
|
66
|
+
}
|
|
67
|
+
const isStartOrEndOfMonth = (date) => {
|
|
68
|
+
return date.date() === 1 || date.date() === date.daysInMonth();
|
|
69
|
+
};
|
|
70
|
+
if (isStartOrEndOfMonth(date1) && isStartOrEndOfMonth(date2)) {
|
|
71
|
+
return 3;
|
|
72
|
+
}
|
|
73
|
+
return 0;
|
|
74
|
+
};
|
|
75
|
+
var useDateRange = (config) => {
|
|
76
|
+
var _a;
|
|
77
|
+
const { defaultDateRange = "今天" /* TODAY */ } = config;
|
|
78
|
+
const [dateRange, setDateRange] = (0, import_react.useState)(
|
|
79
|
+
Array.isArray(defaultDateRange) ? defaultDateRange : ((_a = rangePresets.find((item) => item.label === defaultDateRange)) == null ? void 0 : _a.value) || [(0, import_utils.dayjs)().startOf("day"), (0, import_utils.dayjs)().endOf("day")]
|
|
80
|
+
);
|
|
81
|
+
const rangeType = checkDateRules(dateRange);
|
|
82
|
+
return {
|
|
83
|
+
dateRange,
|
|
84
|
+
// 这里的 any 实际应该是 antd 的 RangeValue<Dayjs> 类型,
|
|
85
|
+
// 但是这个类型不好获取,所以这里先用 any 代替
|
|
86
|
+
onChange: (dateRange2) => {
|
|
87
|
+
if (!dateRange2) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
setDateRange(dateRange2);
|
|
91
|
+
},
|
|
92
|
+
onClickPrev: () => {
|
|
93
|
+
switch (rangeType) {
|
|
94
|
+
case 1:
|
|
95
|
+
setDateRange([dateRange[0].subtract(1, "day"), dateRange[1].subtract(1, "day")]);
|
|
96
|
+
break;
|
|
97
|
+
case 2:
|
|
98
|
+
setDateRange([dateRange[0].subtract(1, "week"), dateRange[1].subtract(1, "week")]);
|
|
99
|
+
break;
|
|
100
|
+
case 3:
|
|
101
|
+
setDateRange([dateRange[0].subtract(1, "month").startOf("month"), dateRange[1].subtract(1, "month").endOf("month")]);
|
|
102
|
+
break;
|
|
103
|
+
default:
|
|
104
|
+
setDateRange([dateRange[0].subtract(1, "day"), dateRange[1]]);
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
onClickNext: () => {
|
|
109
|
+
switch (rangeType) {
|
|
110
|
+
case 1:
|
|
111
|
+
setDateRange([dateRange[0].add(1, "day"), dateRange[1].add(1, "day")]);
|
|
112
|
+
break;
|
|
113
|
+
case 2:
|
|
114
|
+
setDateRange([dateRange[0].add(1, "week"), dateRange[1].add(1, "week")]);
|
|
115
|
+
break;
|
|
116
|
+
case 3:
|
|
117
|
+
setDateRange([dateRange[0].add(1, "month").startOf("month"), dateRange[1].add(1, "month").endOf("month")]);
|
|
118
|
+
break;
|
|
119
|
+
default:
|
|
120
|
+
setDateRange([dateRange[0], dateRange[1].add(1, "day")]);
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
127
|
+
0 && (module.exports = {
|
|
128
|
+
PresetType,
|
|
129
|
+
rangePresets,
|
|
130
|
+
useDateRange
|
|
131
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useEffectValue.d.ts","sourceRoot":"","sources":["../src/useEffectValue.ts"],"names":[],"mappings":";AAEA,eAAO,MAAM,cAAc,OAAQ,GAAG,wGAIrC,CAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
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/useEffectValue.ts
|
|
20
|
+
var useEffectValue_exports = {};
|
|
21
|
+
__export(useEffectValue_exports, {
|
|
22
|
+
useEffectValue: () => useEffectValue
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(useEffectValue_exports);
|
|
25
|
+
var import_react = require("react");
|
|
26
|
+
var useEffectValue = (fn, deps = []) => {
|
|
27
|
+
const [value, setValue] = (0, import_react.useState)();
|
|
28
|
+
(0, import_react.useEffect)(() => setValue(fn()), deps);
|
|
29
|
+
return [value, setValue];
|
|
30
|
+
};
|
|
31
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
32
|
+
0 && (module.exports = {
|
|
33
|
+
useEffectValue
|
|
34
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useElementScrollVisible.d.ts","sourceRoot":"","sources":["../src/useElementScrollVisible.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,uBAAuB,WAAY,GAAG,UAAU,GAAG;;;;CAwC/D,CAAA"}
|
|
@@ -0,0 +1,61 @@
|
|
|
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/useElementScrollVisible.ts
|
|
20
|
+
var useElementScrollVisible_exports = {};
|
|
21
|
+
__export(useElementScrollVisible_exports, {
|
|
22
|
+
useElementScrollVisible: () => useElementScrollVisible
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(useElementScrollVisible_exports);
|
|
25
|
+
var import_react = require("react");
|
|
26
|
+
var useElementScrollVisible = (scroll, target) => {
|
|
27
|
+
const $scroll = document.querySelector(scroll) || {};
|
|
28
|
+
const $scrollRect = $scroll.getBoundingClientRect();
|
|
29
|
+
const [visible, setVisible] = (0, import_react.useState)(false);
|
|
30
|
+
const [direction, setDirection] = (0, import_react.useState)("");
|
|
31
|
+
const [rect, setRect] = (0, import_react.useState)("");
|
|
32
|
+
(0, import_react.useEffect)(() => {
|
|
33
|
+
const fn = () => {
|
|
34
|
+
const $target = document.querySelector(target) || {};
|
|
35
|
+
const rect2 = $target.getBoundingClientRect();
|
|
36
|
+
setRect(rect2);
|
|
37
|
+
if (rect2.bottom < $scrollRect.top) {
|
|
38
|
+
setDirection("top");
|
|
39
|
+
setVisible(false);
|
|
40
|
+
} else if (rect2.top > $scrollRect.bottom) {
|
|
41
|
+
setDirection("bottom");
|
|
42
|
+
setVisible(false);
|
|
43
|
+
} else {
|
|
44
|
+
setDirection("show");
|
|
45
|
+
setVisible(true);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
fn();
|
|
49
|
+
$scroll.addEventListener("scroll", fn);
|
|
50
|
+
return () => $scroll.removeEventListener("scroll", fn);
|
|
51
|
+
}, []);
|
|
52
|
+
return {
|
|
53
|
+
visible,
|
|
54
|
+
direction,
|
|
55
|
+
rect
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
59
|
+
0 && (module.exports = {
|
|
60
|
+
useElementScrollVisible
|
|
61
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useHideFooter.d.ts","sourceRoot":"","sources":["../src/useHideFooter.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,aAAa,uBAQzB,CAAA"}
|
|
@@ -0,0 +1,38 @@
|
|
|
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/useHideFooter.ts
|
|
20
|
+
var useHideFooter_exports = {};
|
|
21
|
+
__export(useHideFooter_exports, {
|
|
22
|
+
useHideFooter: () => useHideFooter
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(useHideFooter_exports);
|
|
25
|
+
var import_react = require("react");
|
|
26
|
+
var useHideFooter = (el = ".ant-layout-footer") => {
|
|
27
|
+
(0, import_react.useEffect)(() => {
|
|
28
|
+
const e = document.querySelector(el);
|
|
29
|
+
e.style.display = "none";
|
|
30
|
+
return () => {
|
|
31
|
+
e.style.display = "block";
|
|
32
|
+
};
|
|
33
|
+
}, []);
|
|
34
|
+
};
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
useHideFooter
|
|
38
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface Option {
|
|
3
|
+
apis: any;
|
|
4
|
+
onChange?: (data?: any) => void;
|
|
5
|
+
}
|
|
6
|
+
export declare const useOptions: (option: Option) => {
|
|
7
|
+
loading: boolean;
|
|
8
|
+
options: any;
|
|
9
|
+
value: string | undefined;
|
|
10
|
+
onChange: import("react").Dispatch<import("react").SetStateAction<string | undefined>>;
|
|
11
|
+
currentData: any;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=useOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOptions.d.ts","sourceRoot":"","sources":["../src/useOptions.ts"],"names":[],"mappings":";AAGA,UAAU,MAAM;IACd,IAAI,EAAE,GAAG,CAAA;IACT,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,GAAG,KAAK,IAAI,CAAA;CAChC;AAED,eAAO,MAAM,UAAU,WAAY,MAAM;;;;;;CAqCxC,CAAA"}
|
|
@@ -0,0 +1,60 @@
|
|
|
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/useOptions.ts
|
|
20
|
+
var useOptions_exports = {};
|
|
21
|
+
__export(useOptions_exports, {
|
|
22
|
+
useOptions: () => useOptions
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(useOptions_exports);
|
|
25
|
+
var import_react = require("react");
|
|
26
|
+
var import_useRequestPro = require("./useRequestPro");
|
|
27
|
+
var useOptions = (option) => {
|
|
28
|
+
const { apis } = option;
|
|
29
|
+
const [value, setValue] = (0, import_react.useState)();
|
|
30
|
+
const { data, loading } = (0, import_useRequestPro.useRequestPro)(apis.list, {
|
|
31
|
+
onSuccess: (res) => {
|
|
32
|
+
var _a;
|
|
33
|
+
const [first] = ((_a = res.data) == null ? void 0 : _a.data) || [];
|
|
34
|
+
if (first) {
|
|
35
|
+
setValue(first == null ? void 0 : first.id);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
const options = (0, import_react.useMemo)(() => {
|
|
40
|
+
return (data == null ? void 0 : data.data.map((item) => ({ label: item.name, value: item.id }))) || [];
|
|
41
|
+
}, [data]);
|
|
42
|
+
const currentData = (0, import_react.useMemo)(() => {
|
|
43
|
+
return data == null ? void 0 : data.data.find((item) => item.id === value);
|
|
44
|
+
}, [data, value]);
|
|
45
|
+
(0, import_react.useEffect)(() => {
|
|
46
|
+
var _a;
|
|
47
|
+
(_a = option.onChange) == null ? void 0 : _a.call(option, currentData);
|
|
48
|
+
}, [currentData]);
|
|
49
|
+
return {
|
|
50
|
+
loading,
|
|
51
|
+
options,
|
|
52
|
+
value,
|
|
53
|
+
onChange: setValue,
|
|
54
|
+
currentData
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
58
|
+
0 && (module.exports = {
|
|
59
|
+
useOptions
|
|
60
|
+
});
|
|
@@ -9,3 +9,4 @@ interface IResult<R extends RequestRes, P extends any[]> extends Omit<Result<R,
|
|
|
9
9
|
}
|
|
10
10
|
export declare const useRequestPro: <P extends any[], R extends RequestRes<any>>(reqPromise?: Service<R, P> | undefined, userOptions?: UserOptions<P, R> | undefined) => IResult<R, P>;
|
|
11
11
|
export {};
|
|
12
|
+
//# sourceMappingURL=useRequestPro.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRequestPro.d.ts","sourceRoot":"","sources":["../src/useRequestPro.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAA;AAG1E,UAAU,WAAW,CAAC,CAAC,SAAS,GAAG,EAAE,EAAE,CAAC,CAAE,SAAQ,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;IAC7D,iBAAiB,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IACnC,mBAAmB,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;CACrC;AAGD,UAAU,OAAO,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,SAAS,GAAG,EAAE,CAAE,SAAQ,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC;IACzF,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;CAClB;AAeD,eAAO,MAAM,aAAa,oJA0CzB,CAAA"}
|
|
@@ -0,0 +1,76 @@
|
|
|
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/useRequestPro.ts
|
|
20
|
+
var useRequestPro_exports = {};
|
|
21
|
+
__export(useRequestPro_exports, {
|
|
22
|
+
useRequestPro: () => useRequestPro
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(useRequestPro_exports);
|
|
25
|
+
var import_antd = require("antd");
|
|
26
|
+
var import_ahooks = require("ahooks");
|
|
27
|
+
var import_utils = require("@wzyjs/utils");
|
|
28
|
+
var defaultResult = {
|
|
29
|
+
loading: false,
|
|
30
|
+
data: void 0,
|
|
31
|
+
error: void 0,
|
|
32
|
+
params: [],
|
|
33
|
+
cancel: import_utils.noop,
|
|
34
|
+
refresh: import_utils.noop,
|
|
35
|
+
refreshAsync: import_utils.noop,
|
|
36
|
+
run: import_utils.noop,
|
|
37
|
+
runAsync: import_utils.noop,
|
|
38
|
+
mutate: import_utils.noop
|
|
39
|
+
};
|
|
40
|
+
var useRequestPro = (reqPromise, userOptions) => {
|
|
41
|
+
var _a;
|
|
42
|
+
if (!reqPromise) {
|
|
43
|
+
return defaultResult;
|
|
44
|
+
}
|
|
45
|
+
const { alertErrorMessage = true, alertSuccessMessage = false } = userOptions || {};
|
|
46
|
+
const defaultOptions = {
|
|
47
|
+
debounceWait: 300,
|
|
48
|
+
throttleWait: 300,
|
|
49
|
+
onError: (err, params) => {
|
|
50
|
+
var _a2;
|
|
51
|
+
if (alertErrorMessage) {
|
|
52
|
+
import_antd.message.error(typeof alertErrorMessage === "string" ? alertErrorMessage : err.message || "请求失败");
|
|
53
|
+
}
|
|
54
|
+
(_a2 = userOptions == null ? void 0 : userOptions.onError) == null ? void 0 : _a2.call(userOptions, err, params);
|
|
55
|
+
},
|
|
56
|
+
onSuccess: (res, params) => {
|
|
57
|
+
var _a2;
|
|
58
|
+
if (!(res == null ? void 0 : res.success)) {
|
|
59
|
+
defaultOptions.onError(new Error(res == null ? void 0 : res.message), params);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (alertSuccessMessage) {
|
|
63
|
+
import_antd.message.success(typeof alertSuccessMessage === "string" ? alertSuccessMessage : res.message || "请求成功");
|
|
64
|
+
}
|
|
65
|
+
(_a2 = userOptions == null ? void 0 : userOptions.onSuccess) == null ? void 0 : _a2.call(userOptions, res, params);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const options = Object.assign(defaultOptions, (0, import_utils.omit)(userOptions, ["onSuccess", "onError"]));
|
|
69
|
+
const state = (0, import_ahooks.useRequest)(reqPromise, options);
|
|
70
|
+
state.data = (_a = state.data) == null ? void 0 : _a.data;
|
|
71
|
+
return state;
|
|
72
|
+
};
|
|
73
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
74
|
+
0 && (module.exports = {
|
|
75
|
+
useRequestPro
|
|
76
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useVisibleInfo.d.ts","sourceRoot":"","sources":["../src/useVisibleInfo.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,cAAc,8BAAkB,GAAG;;;;IAe/C,CAAA"}
|
|
@@ -0,0 +1,45 @@
|
|
|
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/useVisibleInfo.ts
|
|
20
|
+
var useVisibleInfo_exports = {};
|
|
21
|
+
__export(useVisibleInfo_exports, {
|
|
22
|
+
useVisibleInfo: () => useVisibleInfo
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(useVisibleInfo_exports);
|
|
25
|
+
var import_react = require("react");
|
|
26
|
+
var useVisibleInfo = (v = false, i) => {
|
|
27
|
+
const [visible, setVisible] = (0, import_react.useState)(v);
|
|
28
|
+
const [info, setInfo] = (0, import_react.useState)(i);
|
|
29
|
+
return [
|
|
30
|
+
visible,
|
|
31
|
+
{
|
|
32
|
+
setTrue: () => setVisible(true),
|
|
33
|
+
setFalse: () => setVisible(false),
|
|
34
|
+
toggle: () => setVisible(!visible)
|
|
35
|
+
},
|
|
36
|
+
[
|
|
37
|
+
info,
|
|
38
|
+
setInfo
|
|
39
|
+
]
|
|
40
|
+
];
|
|
41
|
+
};
|
|
42
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
+
0 && (module.exports = {
|
|
44
|
+
useVisibleInfo
|
|
45
|
+
});
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
export * from 'ahooks';
|
|
2
|
+
export { default as useUrlState } from '@ahooksjs/use-url-state';
|
|
2
3
|
export { useCopyToClipboard, useCookie, useUpdate } from 'react-use';
|
|
3
4
|
export * from './useRequestPro';
|
|
4
5
|
export * from './useEffectValue';
|
|
5
6
|
export * from './useElementScrollVisible';
|
|
6
7
|
export * from './useHideFooter';
|
|
7
8
|
export * from './useVisibleInfo';
|
|
9
|
+
export * from './useDateRange';
|
|
10
|
+
export * from './useOptions';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAA;AAEtB,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAEhE,OAAO,EAAE,kBAAkB,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAEpE,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,2BAA2B,CAAA;AACzC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from 'ahooks';
|
|
2
|
+
export { default as useUrlState } from '@ahooksjs/use-url-state';
|
|
3
|
+
export { useCopyToClipboard, useCookie, useUpdate } from 'react-use';
|
|
4
|
+
export * from "./useRequestPro";
|
|
5
|
+
export * from "./useEffectValue";
|
|
6
|
+
export * from "./useElementScrollVisible";
|
|
7
|
+
export * from "./useHideFooter";
|
|
8
|
+
export * from "./useVisibleInfo";
|
|
9
|
+
export * from "./useDateRange";
|
|
10
|
+
export * from "./useOptions";
|