@reactuses/core 2.2.8 → 3.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/dist/index.cjs +131 -79
- package/dist/index.d.ts +6 -1
- package/dist/index.mjs +130 -80
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2974,18 +2974,19 @@ function getTargetElement(target, defaultElement) {
|
|
|
2974
2974
|
return targetElement;
|
|
2975
2975
|
}
|
|
2976
2976
|
function useLatestElement(target, defaultElement) {
|
|
2977
|
-
const
|
|
2977
|
+
const [latestElement, setLatestElement] = React.useState(
|
|
2978
|
+
getTargetElement(target, defaultElement)
|
|
2979
|
+
);
|
|
2978
2980
|
React.useEffect(() => {
|
|
2979
|
-
|
|
2980
|
-
});
|
|
2981
|
-
return
|
|
2981
|
+
setLatestElement(getTargetElement(target, defaultElement));
|
|
2982
|
+
}, [target, defaultElement]);
|
|
2983
|
+
return latestElement;
|
|
2982
2984
|
}
|
|
2983
2985
|
|
|
2984
2986
|
function useEventListener(eventName, handler, element, options) {
|
|
2985
2987
|
const savedHandler = useLatest(handler);
|
|
2986
|
-
const
|
|
2988
|
+
const targetElement = useLatestElement(element, defaultWindow);
|
|
2987
2989
|
useDeepCompareEffect(() => {
|
|
2988
|
-
const targetElement = targetElementRef.current;
|
|
2989
2990
|
if (!(targetElement && targetElement.addEventListener)) {
|
|
2990
2991
|
return;
|
|
2991
2992
|
}
|
|
@@ -2997,7 +2998,7 @@ function useEventListener(eventName, handler, element, options) {
|
|
|
2997
2998
|
}
|
|
2998
2999
|
off(targetElement, eventName, eventListener);
|
|
2999
3000
|
};
|
|
3000
|
-
}, [eventName,
|
|
3001
|
+
}, [eventName, targetElement, options, savedHandler]);
|
|
3001
3002
|
}
|
|
3002
3003
|
|
|
3003
3004
|
function useCounter(initialValue = 0, max = null, min = null) {
|
|
@@ -3149,13 +3150,13 @@ function useMutationObserver(callback, target, options = {}) {
|
|
|
3149
3150
|
}
|
|
3150
3151
|
}, []);
|
|
3151
3152
|
useDeepCompareEffect(() => {
|
|
3152
|
-
if (!element
|
|
3153
|
+
if (!element) {
|
|
3153
3154
|
return;
|
|
3154
3155
|
}
|
|
3155
3156
|
observerRef.current = new MutationObserver(callbackRef.current);
|
|
3156
|
-
observerRef.current.observe(element
|
|
3157
|
+
observerRef.current.observe(element, options);
|
|
3157
3158
|
return stop;
|
|
3158
|
-
}, [options, element
|
|
3159
|
+
}, [options, element]);
|
|
3159
3160
|
return stop;
|
|
3160
3161
|
}
|
|
3161
3162
|
|
|
@@ -3878,11 +3879,11 @@ function useOnline() {
|
|
|
3878
3879
|
return online;
|
|
3879
3880
|
}
|
|
3880
3881
|
|
|
3881
|
-
const defaultState = {
|
|
3882
|
+
const defaultState$1 = {
|
|
3882
3883
|
angle: 0,
|
|
3883
3884
|
type: "landscape-primary"
|
|
3884
3885
|
};
|
|
3885
|
-
function useOrientation(initialState = defaultState) {
|
|
3886
|
+
function useOrientation(initialState = defaultState$1) {
|
|
3886
3887
|
const [state, setState] = React.useState(initialState);
|
|
3887
3888
|
React.useEffect(() => {
|
|
3888
3889
|
const screen = window.screen;
|
|
@@ -3939,16 +3940,16 @@ function useIntersectionObserver(target, callback, options = {}) {
|
|
|
3939
3940
|
}
|
|
3940
3941
|
}, []);
|
|
3941
3942
|
useDeepCompareEffect(() => {
|
|
3942
|
-
if (!element
|
|
3943
|
+
if (!element) {
|
|
3943
3944
|
return;
|
|
3944
3945
|
}
|
|
3945
3946
|
observerRef.current = new IntersectionObserver(
|
|
3946
3947
|
savedCallback.current,
|
|
3947
3948
|
options
|
|
3948
3949
|
);
|
|
3949
|
-
observerRef.current.observe(element
|
|
3950
|
+
observerRef.current.observe(element);
|
|
3950
3951
|
return stop;
|
|
3951
|
-
}, [options, element
|
|
3952
|
+
}, [options, element]);
|
|
3952
3953
|
return stop;
|
|
3953
3954
|
}
|
|
3954
3955
|
|
|
@@ -3995,13 +3996,13 @@ function useResizeObserver(target, callback, options = {}) {
|
|
|
3995
3996
|
}
|
|
3996
3997
|
}, []);
|
|
3997
3998
|
useDeepCompareEffect(() => {
|
|
3998
|
-
if (!element
|
|
3999
|
+
if (!element) {
|
|
3999
4000
|
return;
|
|
4000
4001
|
}
|
|
4001
4002
|
observerRef.current = new ResizeObserver(savedCallback.current);
|
|
4002
|
-
observerRef.current.observe(element
|
|
4003
|
+
observerRef.current.observe(element, options);
|
|
4003
4004
|
return stop;
|
|
4004
|
-
}, [options, element
|
|
4005
|
+
}, [options, element]);
|
|
4005
4006
|
return stop;
|
|
4006
4007
|
}
|
|
4007
4008
|
|
|
@@ -4050,19 +4051,19 @@ function useDropZone(target, onDrop) {
|
|
|
4050
4051
|
return over;
|
|
4051
4052
|
}
|
|
4052
4053
|
|
|
4053
|
-
var __defProp$
|
|
4054
|
-
var __getOwnPropSymbols$
|
|
4055
|
-
var __hasOwnProp$
|
|
4056
|
-
var __propIsEnum$
|
|
4057
|
-
var __defNormalProp$
|
|
4058
|
-
var __spreadValues$
|
|
4054
|
+
var __defProp$2 = Object.defineProperty;
|
|
4055
|
+
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
4056
|
+
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
4057
|
+
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
4058
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4059
|
+
var __spreadValues$2 = (a, b) => {
|
|
4059
4060
|
for (var prop in b || (b = {}))
|
|
4060
|
-
if (__hasOwnProp$
|
|
4061
|
-
__defNormalProp$
|
|
4062
|
-
if (__getOwnPropSymbols$
|
|
4063
|
-
for (var prop of __getOwnPropSymbols$
|
|
4064
|
-
if (__propIsEnum$
|
|
4065
|
-
__defNormalProp$
|
|
4061
|
+
if (__hasOwnProp$3.call(b, prop))
|
|
4062
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
4063
|
+
if (__getOwnPropSymbols$3)
|
|
4064
|
+
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
4065
|
+
if (__propIsEnum$3.call(b, prop))
|
|
4066
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
4066
4067
|
}
|
|
4067
4068
|
return a;
|
|
4068
4069
|
};
|
|
@@ -4090,7 +4091,7 @@ function useFileDialog(options = {}) {
|
|
|
4090
4091
|
if (!inputRef.current) {
|
|
4091
4092
|
return;
|
|
4092
4093
|
}
|
|
4093
|
-
const _options = __spreadValues$
|
|
4094
|
+
const _options = __spreadValues$2(__spreadValues$2(__spreadValues$2({}, DEFAULT_OPTIONS), options), localOptions);
|
|
4094
4095
|
inputRef.current.multiple = _options.multiple;
|
|
4095
4096
|
inputRef.current.accept = _options.accept;
|
|
4096
4097
|
inputRef.current.capture = _options.capture;
|
|
@@ -4177,21 +4178,21 @@ function useScroll(target, options = {}) {
|
|
|
4177
4178
|
return [x, y, isScrolling, arrivedState, directions];
|
|
4178
4179
|
}
|
|
4179
4180
|
|
|
4180
|
-
var __defProp = Object.defineProperty;
|
|
4181
|
+
var __defProp$1 = Object.defineProperty;
|
|
4181
4182
|
var __defProps = Object.defineProperties;
|
|
4182
4183
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4183
|
-
var __getOwnPropSymbols$
|
|
4184
|
-
var __hasOwnProp$
|
|
4185
|
-
var __propIsEnum$
|
|
4186
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4187
|
-
var __spreadValues = (a, b) => {
|
|
4184
|
+
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
4185
|
+
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
4186
|
+
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
4187
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4188
|
+
var __spreadValues$1 = (a, b) => {
|
|
4188
4189
|
for (var prop in b || (b = {}))
|
|
4189
|
-
if (__hasOwnProp$
|
|
4190
|
-
__defNormalProp(a, prop, b[prop]);
|
|
4191
|
-
if (__getOwnPropSymbols$
|
|
4192
|
-
for (var prop of __getOwnPropSymbols$
|
|
4193
|
-
if (__propIsEnum$
|
|
4194
|
-
__defNormalProp(a, prop, b[prop]);
|
|
4190
|
+
if (__hasOwnProp$2.call(b, prop))
|
|
4191
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
4192
|
+
if (__getOwnPropSymbols$2)
|
|
4193
|
+
for (var prop of __getOwnPropSymbols$2(b)) {
|
|
4194
|
+
if (__propIsEnum$2.call(b, prop))
|
|
4195
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
4195
4196
|
}
|
|
4196
4197
|
return a;
|
|
4197
4198
|
};
|
|
@@ -4220,8 +4221,8 @@ function useInfiniteScroll(target, onLoadMore, options = {}) {
|
|
|
4220
4221
|
var _a, _b;
|
|
4221
4222
|
const savedLoadMore = useLatest(onLoadMore);
|
|
4222
4223
|
const direction = (_a = options.direction) != null ? _a : "bottom";
|
|
4223
|
-
const state = useScroll(target, __spreadProps(__spreadValues({}, options), {
|
|
4224
|
-
offset: __spreadValues({
|
|
4224
|
+
const state = useScroll(target, __spreadProps(__spreadValues$1({}, options), {
|
|
4225
|
+
offset: __spreadValues$1({
|
|
4225
4226
|
[direction]: (_b = options.distance) != null ? _b : 0
|
|
4226
4227
|
}, options.offset)
|
|
4227
4228
|
}));
|
|
@@ -4231,16 +4232,16 @@ function useInfiniteScroll(target, onLoadMore, options = {}) {
|
|
|
4231
4232
|
useUpdateEffect(() => {
|
|
4232
4233
|
const opts = latestOptions.current;
|
|
4233
4234
|
const fn = () => __async$3(this, null, function* () {
|
|
4234
|
-
var _a2, _b2
|
|
4235
|
+
var _a2, _b2;
|
|
4235
4236
|
const previous = {
|
|
4236
|
-
height: (
|
|
4237
|
-
width: (
|
|
4237
|
+
height: (_a2 = element == null ? void 0 : element.scrollHeight) != null ? _a2 : 0,
|
|
4238
|
+
width: (_b2 = element == null ? void 0 : element.scrollWidth) != null ? _b2 : 0
|
|
4238
4239
|
};
|
|
4239
4240
|
yield savedLoadMore.current(state);
|
|
4240
|
-
if (opts.preserveScrollPosition && element
|
|
4241
|
-
element.
|
|
4242
|
-
top: element.
|
|
4243
|
-
left: element.
|
|
4241
|
+
if (opts.preserveScrollPosition && element) {
|
|
4242
|
+
element.scrollTo({
|
|
4243
|
+
top: element.scrollHeight - previous.height,
|
|
4244
|
+
left: element.scrollWidth - previous.width
|
|
4244
4245
|
});
|
|
4245
4246
|
}
|
|
4246
4247
|
});
|
|
@@ -4282,7 +4283,7 @@ function useMousePressed(target, options = {}) {
|
|
|
4282
4283
|
const { touch = true, drag = true, initialValue = false } = options;
|
|
4283
4284
|
const [pressed, setPressed] = React.useState(initialValue);
|
|
4284
4285
|
const [sourceType, setSourceType] = React.useState(null);
|
|
4285
|
-
const
|
|
4286
|
+
const element = useLatestElement(target);
|
|
4286
4287
|
const onPressed = React.useCallback(
|
|
4287
4288
|
(srcType) => () => {
|
|
4288
4289
|
setPressed(true);
|
|
@@ -4298,7 +4299,6 @@ function useMousePressed(target, options = {}) {
|
|
|
4298
4299
|
useEventListener("mouseleave", onReleased, () => window, { passive: true });
|
|
4299
4300
|
useEventListener("mouseup", onReleased, () => window, { passive: true });
|
|
4300
4301
|
React.useEffect(() => {
|
|
4301
|
-
const element = elementRef.current;
|
|
4302
4302
|
if (drag) {
|
|
4303
4303
|
element == null ? void 0 : element.addEventListener("dragstart", onPressed("mouse"), {
|
|
4304
4304
|
passive: true
|
|
@@ -4333,7 +4333,7 @@ function useMousePressed(target, options = {}) {
|
|
|
4333
4333
|
element == null ? void 0 : element.removeEventListener("touchcancel", onReleased);
|
|
4334
4334
|
}
|
|
4335
4335
|
};
|
|
4336
|
-
}, [drag, onPressed, onReleased, touch,
|
|
4336
|
+
}, [drag, onPressed, onReleased, touch, element]);
|
|
4337
4337
|
return [pressed, sourceType];
|
|
4338
4338
|
}
|
|
4339
4339
|
|
|
@@ -4352,32 +4352,32 @@ function useScrollLock(target, initialState = false) {
|
|
|
4352
4352
|
const initialOverflowRef = React.useRef("scroll");
|
|
4353
4353
|
const element = useLatestElement(target);
|
|
4354
4354
|
React.useEffect(() => {
|
|
4355
|
-
if (element
|
|
4356
|
-
initialOverflowRef.current = element.
|
|
4355
|
+
if (element) {
|
|
4356
|
+
initialOverflowRef.current = element.style.overflow;
|
|
4357
4357
|
if (locked) {
|
|
4358
|
-
element.
|
|
4358
|
+
element.style.overflow = "hidden";
|
|
4359
4359
|
}
|
|
4360
4360
|
}
|
|
4361
|
-
}, [locked, element
|
|
4361
|
+
}, [locked, element]);
|
|
4362
4362
|
const lock = useEvent(() => {
|
|
4363
|
-
if (!element
|
|
4363
|
+
if (!element || locked) {
|
|
4364
4364
|
return;
|
|
4365
4365
|
}
|
|
4366
4366
|
if (isIOS) {
|
|
4367
|
-
element.
|
|
4367
|
+
element.addEventListener("touchmove", preventDefault, {
|
|
4368
4368
|
passive: false
|
|
4369
4369
|
});
|
|
4370
4370
|
}
|
|
4371
4371
|
setLocked(true);
|
|
4372
4372
|
});
|
|
4373
4373
|
const unlock = useEvent(() => {
|
|
4374
|
-
if (!element
|
|
4374
|
+
if (!element || !locked) {
|
|
4375
4375
|
return;
|
|
4376
4376
|
}
|
|
4377
4377
|
if (isIOS) {
|
|
4378
|
-
element.
|
|
4378
|
+
element.removeEventListener("touchmove", preventDefault);
|
|
4379
4379
|
}
|
|
4380
|
-
element.
|
|
4380
|
+
element.style.overflow = initialOverflowRef.current;
|
|
4381
4381
|
setLocked(false);
|
|
4382
4382
|
});
|
|
4383
4383
|
const set = useEvent((flag) => {
|
|
@@ -4817,11 +4817,11 @@ function useClickOutSide(target, handler) {
|
|
|
4817
4817
|
const savedHandler = useLatest(handler);
|
|
4818
4818
|
const element = useLatestElement(target);
|
|
4819
4819
|
const listener = (event) => {
|
|
4820
|
-
if (!element
|
|
4820
|
+
if (!element) {
|
|
4821
4821
|
return;
|
|
4822
4822
|
}
|
|
4823
4823
|
const elements = event.composedPath();
|
|
4824
|
-
if (element
|
|
4824
|
+
if (element === event.target || elements.includes(element)) {
|
|
4825
4825
|
return;
|
|
4826
4826
|
}
|
|
4827
4827
|
savedHandler.current(event);
|
|
@@ -5066,7 +5066,7 @@ function useScrollIntoView({
|
|
|
5066
5066
|
const scrollIntoView = useEvent(
|
|
5067
5067
|
({ alignment = "start" } = {}) => {
|
|
5068
5068
|
var _a;
|
|
5069
|
-
const parent = getTargetElement(scrollElement) || getScrollParent(axis, element
|
|
5069
|
+
const parent = getTargetElement(scrollElement) || getScrollParent(axis, element);
|
|
5070
5070
|
shouldStop.current = false;
|
|
5071
5071
|
if (frameID.current) {
|
|
5072
5072
|
cancel();
|
|
@@ -5074,7 +5074,7 @@ function useScrollIntoView({
|
|
|
5074
5074
|
const start = (_a = getScrollStart({ parent, axis })) != null ? _a : 0;
|
|
5075
5075
|
const change = getRelativePosition({
|
|
5076
5076
|
parent,
|
|
5077
|
-
target: element
|
|
5077
|
+
target: element,
|
|
5078
5078
|
axis,
|
|
5079
5079
|
alignment,
|
|
5080
5080
|
offset,
|
|
@@ -5128,10 +5128,10 @@ const useSticky = ({
|
|
|
5128
5128
|
const [isSticky, setSticky] = React.useState(false);
|
|
5129
5129
|
const element = useLatestElement(targetElement);
|
|
5130
5130
|
const { run: scrollHandler } = useThrottleFn(() => {
|
|
5131
|
-
if (!element
|
|
5131
|
+
if (!element) {
|
|
5132
5132
|
return;
|
|
5133
5133
|
}
|
|
5134
|
-
const rect = element.
|
|
5134
|
+
const rect = element.getBoundingClientRect();
|
|
5135
5135
|
if (axis === "y") {
|
|
5136
5136
|
setSticky((rect == null ? void 0 : rect.top) <= nav);
|
|
5137
5137
|
} else {
|
|
@@ -5139,8 +5139,8 @@ const useSticky = ({
|
|
|
5139
5139
|
}
|
|
5140
5140
|
}, 50);
|
|
5141
5141
|
React.useEffect(() => {
|
|
5142
|
-
const scrollParent = getTargetElement(scrollElement) || getScrollParent(axis, element
|
|
5143
|
-
if (!element
|
|
5142
|
+
const scrollParent = getTargetElement(scrollElement) || getScrollParent(axis, element);
|
|
5143
|
+
if (!element || !scrollParent) {
|
|
5144
5144
|
return;
|
|
5145
5145
|
}
|
|
5146
5146
|
scrollParent.addEventListener("scroll", scrollHandler);
|
|
@@ -5417,17 +5417,17 @@ function init (converter, defaultAttributes) {
|
|
|
5417
5417
|
|
|
5418
5418
|
var api = init(defaultConverter, { path: '/' });
|
|
5419
5419
|
|
|
5420
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5421
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5422
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5420
|
+
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
5421
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
5422
|
+
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
5423
5423
|
var __objRest = (source, exclude) => {
|
|
5424
5424
|
var target = {};
|
|
5425
5425
|
for (var prop in source)
|
|
5426
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
5426
|
+
if (__hasOwnProp$1.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
5427
5427
|
target[prop] = source[prop];
|
|
5428
|
-
if (source != null && __getOwnPropSymbols)
|
|
5429
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
5430
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
5428
|
+
if (source != null && __getOwnPropSymbols$1)
|
|
5429
|
+
for (var prop of __getOwnPropSymbols$1(source)) {
|
|
5430
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$1.call(source, prop))
|
|
5431
5431
|
target[prop] = source[prop];
|
|
5432
5432
|
}
|
|
5433
5433
|
return target;
|
|
@@ -5511,6 +5511,56 @@ function useDoubleClick({
|
|
|
5511
5511
|
useEventListener("touchend", handleTouchEnd, element, { passive: false });
|
|
5512
5512
|
}
|
|
5513
5513
|
|
|
5514
|
+
var __defProp = Object.defineProperty;
|
|
5515
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5516
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5517
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5518
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5519
|
+
var __spreadValues = (a, b) => {
|
|
5520
|
+
for (var prop in b || (b = {}))
|
|
5521
|
+
if (__hasOwnProp.call(b, prop))
|
|
5522
|
+
__defNormalProp(a, prop, b[prop]);
|
|
5523
|
+
if (__getOwnPropSymbols)
|
|
5524
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
5525
|
+
if (__propIsEnum.call(b, prop))
|
|
5526
|
+
__defNormalProp(a, prop, b[prop]);
|
|
5527
|
+
}
|
|
5528
|
+
return a;
|
|
5529
|
+
};
|
|
5530
|
+
function useSetState(initialState) {
|
|
5531
|
+
const [state, _setState] = React.useState(initialState);
|
|
5532
|
+
const setState = React.useCallback(
|
|
5533
|
+
(statePartial) => _setState((current) => __spreadValues(__spreadValues({}, current), typeof statePartial === "function" ? statePartial(current) : statePartial)),
|
|
5534
|
+
[]
|
|
5535
|
+
);
|
|
5536
|
+
return [state, setState];
|
|
5537
|
+
}
|
|
5538
|
+
|
|
5539
|
+
const defaultState = {
|
|
5540
|
+
x: 0,
|
|
5541
|
+
y: 0,
|
|
5542
|
+
width: 0,
|
|
5543
|
+
height: 0,
|
|
5544
|
+
top: 0,
|
|
5545
|
+
left: 0,
|
|
5546
|
+
bottom: 0,
|
|
5547
|
+
right: 0
|
|
5548
|
+
};
|
|
5549
|
+
function useMeasure(target, options = {}) {
|
|
5550
|
+
const [rect, setRect] = React.useState(defaultState);
|
|
5551
|
+
const stop = useResizeObserver(
|
|
5552
|
+
target,
|
|
5553
|
+
(entries) => {
|
|
5554
|
+
if (entries[0]) {
|
|
5555
|
+
const { x, y, width, height, top, left, bottom, right } = entries[0].contentRect;
|
|
5556
|
+
setRect({ x, y, width, height, top, left, bottom, right });
|
|
5557
|
+
}
|
|
5558
|
+
},
|
|
5559
|
+
options
|
|
5560
|
+
);
|
|
5561
|
+
return [rect, stop];
|
|
5562
|
+
}
|
|
5563
|
+
|
|
5514
5564
|
exports.getHMSTime = getHMSTime;
|
|
5515
5565
|
exports.useActiveElement = useActiveElement;
|
|
5516
5566
|
exports.useAsyncEffect = useAsyncEffect;
|
|
@@ -5553,6 +5603,7 @@ exports.useKeyModifier = useKeyModifier;
|
|
|
5553
5603
|
exports.useLatest = useLatest;
|
|
5554
5604
|
exports.useLocalStorage = useLocalStorage;
|
|
5555
5605
|
exports.useLongPress = useLongPress;
|
|
5606
|
+
exports.useMeasure = useMeasure;
|
|
5556
5607
|
exports.useMediaDevices = index$3;
|
|
5557
5608
|
exports.useMediaQuery = useMediaQuery;
|
|
5558
5609
|
exports.useMount = useMount;
|
|
@@ -5581,6 +5632,7 @@ exports.useScroll = useScroll;
|
|
|
5581
5632
|
exports.useScrollIntoView = useScrollIntoView;
|
|
5582
5633
|
exports.useScrollLock = useScrollLock;
|
|
5583
5634
|
exports.useSessionStorage = useSessionStorage;
|
|
5635
|
+
exports.useSetState = useSetState;
|
|
5584
5636
|
exports.useSticky = useSticky;
|
|
5585
5637
|
exports.useSupported = useSupported;
|
|
5586
5638
|
exports.useTextDirection = useTextDirection;
|
package/dist/index.d.ts
CHANGED
|
@@ -847,4 +847,9 @@ declare function useDoubleClick({ target, latency, onSingleClick, onDoubleClick,
|
|
|
847
847
|
onDoubleClick?: (e?: MouseEvent | TouchEvent) => void;
|
|
848
848
|
}): void;
|
|
849
849
|
|
|
850
|
-
|
|
850
|
+
declare function useSetState<T extends Record<string, any>>(initialState: T): readonly [T, (statePartial: Partial<T> | ((currentState: T) => Partial<T>)) => void];
|
|
851
|
+
|
|
852
|
+
type UseMeasureRect = Omit<DOMRectReadOnly, "toJSON">;
|
|
853
|
+
declare function useMeasure(target: BasicTarget, options?: ResizeObserverOptions): readonly [UseMeasureRect, () => void];
|
|
854
|
+
|
|
855
|
+
export { ColorScheme, Contrast, CookieOptions, CookieState, CursorState, EyeDropperOpenReturnType, GeneralPermissionDescriptor, IDisposable, IEvent, IEventOnce, IListener, INetworkInformation, IState, IUseNetworkState, KeyModifier, MousePressedOptions, MouseSourceType, OrientationState, RafLoopReturns, ScrollIntoViewAnimation, ScrollIntoViewParams, State, Status, Target, UseDarkOptions, UseDraggableOptions, UseElementBoundingOptions, UseEventEmitterReturn, UseEyeDropperReturn, UseFileDialogOptions, UseFpsOptions, UseFullScreenOptions, UseInfiniteScrollOptions, UseLongPressOptions, UseMeasureRect, UseModifierOptions, UseScriptTagOptions, UseScrollOptions, UseStickyParams, UseTextDirectionOptions, UseTextDirectionValue, UseTimeoutFnOptions, UseVirtualListItem, UseVirtualListOptions, UseVirtualListReturn, WindowSize, getHMSTime, useActiveElement, useAsyncEffect, useClickOutSide as useClickOutside, useClipBorad as useClipboard, useControlled, useCookie, useCountDown, useCounter, useCustomCompareEffect, useCycleList, useDarkMode, useDebounce, useDebounceFn, useDeepCompareEffect, useDocumentVisibility, useDoubleClick, useDraggable, useDropZone, useElementBounding, useElementSize, useElementVisibility, useEvent, useEventEmitter, useEventListener, useEyeDropper, useFavicon, useFileDialog, useFirstMountState, useFocus, _default$2 as useFps, useFullscreen, useGeolocation, useIdle, useInfiniteScroll, useIntersectionObserver, useInterval, useIsomorphicLayoutEffect, useKeyModifier, useLatest, useLocalStorage, useLongPress, useMeasure, _default$3 as useMediaDevices, useMediaQuery, useMount, useMountedState, useMouse, useMousePressed, useMutationObserver, useNetwork, useObjectUrl, _default$1 as useOnceEffect, _default as useOnceLayoutEffect, useOnline, useOrientation, usePageLeave, usePermission, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePrevious, useRafFn, useRafState, useReducedMotion, useResizeObserver, useScriptTag, useScroll, useScrollIntoView, useScrollLock, useSessionStorage, useSetState, useSticky, useSupported, useTextDirection, useTextSelection, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useTitle, useToggle, useUnmount, useUpdate, _default$5 as useUpdateEffect, _default$4 as useUpdateLayoutEffect, useVirtualList, useWindowScroll, useWindowSize, useWindowsFocus };
|
package/dist/index.mjs
CHANGED
|
@@ -2966,18 +2966,19 @@ function getTargetElement(target, defaultElement) {
|
|
|
2966
2966
|
return targetElement;
|
|
2967
2967
|
}
|
|
2968
2968
|
function useLatestElement(target, defaultElement) {
|
|
2969
|
-
const
|
|
2969
|
+
const [latestElement, setLatestElement] = useState(
|
|
2970
|
+
getTargetElement(target, defaultElement)
|
|
2971
|
+
);
|
|
2970
2972
|
useEffect(() => {
|
|
2971
|
-
|
|
2972
|
-
});
|
|
2973
|
-
return
|
|
2973
|
+
setLatestElement(getTargetElement(target, defaultElement));
|
|
2974
|
+
}, [target, defaultElement]);
|
|
2975
|
+
return latestElement;
|
|
2974
2976
|
}
|
|
2975
2977
|
|
|
2976
2978
|
function useEventListener(eventName, handler, element, options) {
|
|
2977
2979
|
const savedHandler = useLatest(handler);
|
|
2978
|
-
const
|
|
2980
|
+
const targetElement = useLatestElement(element, defaultWindow);
|
|
2979
2981
|
useDeepCompareEffect(() => {
|
|
2980
|
-
const targetElement = targetElementRef.current;
|
|
2981
2982
|
if (!(targetElement && targetElement.addEventListener)) {
|
|
2982
2983
|
return;
|
|
2983
2984
|
}
|
|
@@ -2989,7 +2990,7 @@ function useEventListener(eventName, handler, element, options) {
|
|
|
2989
2990
|
}
|
|
2990
2991
|
off(targetElement, eventName, eventListener);
|
|
2991
2992
|
};
|
|
2992
|
-
}, [eventName,
|
|
2993
|
+
}, [eventName, targetElement, options, savedHandler]);
|
|
2993
2994
|
}
|
|
2994
2995
|
|
|
2995
2996
|
function useCounter(initialValue = 0, max = null, min = null) {
|
|
@@ -3141,13 +3142,13 @@ function useMutationObserver(callback, target, options = {}) {
|
|
|
3141
3142
|
}
|
|
3142
3143
|
}, []);
|
|
3143
3144
|
useDeepCompareEffect(() => {
|
|
3144
|
-
if (!element
|
|
3145
|
+
if (!element) {
|
|
3145
3146
|
return;
|
|
3146
3147
|
}
|
|
3147
3148
|
observerRef.current = new MutationObserver(callbackRef.current);
|
|
3148
|
-
observerRef.current.observe(element
|
|
3149
|
+
observerRef.current.observe(element, options);
|
|
3149
3150
|
return stop;
|
|
3150
|
-
}, [options, element
|
|
3151
|
+
}, [options, element]);
|
|
3151
3152
|
return stop;
|
|
3152
3153
|
}
|
|
3153
3154
|
|
|
@@ -3870,11 +3871,11 @@ function useOnline() {
|
|
|
3870
3871
|
return online;
|
|
3871
3872
|
}
|
|
3872
3873
|
|
|
3873
|
-
const defaultState = {
|
|
3874
|
+
const defaultState$1 = {
|
|
3874
3875
|
angle: 0,
|
|
3875
3876
|
type: "landscape-primary"
|
|
3876
3877
|
};
|
|
3877
|
-
function useOrientation(initialState = defaultState) {
|
|
3878
|
+
function useOrientation(initialState = defaultState$1) {
|
|
3878
3879
|
const [state, setState] = useState(initialState);
|
|
3879
3880
|
useEffect(() => {
|
|
3880
3881
|
const screen = window.screen;
|
|
@@ -3931,16 +3932,16 @@ function useIntersectionObserver(target, callback, options = {}) {
|
|
|
3931
3932
|
}
|
|
3932
3933
|
}, []);
|
|
3933
3934
|
useDeepCompareEffect(() => {
|
|
3934
|
-
if (!element
|
|
3935
|
+
if (!element) {
|
|
3935
3936
|
return;
|
|
3936
3937
|
}
|
|
3937
3938
|
observerRef.current = new IntersectionObserver(
|
|
3938
3939
|
savedCallback.current,
|
|
3939
3940
|
options
|
|
3940
3941
|
);
|
|
3941
|
-
observerRef.current.observe(element
|
|
3942
|
+
observerRef.current.observe(element);
|
|
3942
3943
|
return stop;
|
|
3943
|
-
}, [options, element
|
|
3944
|
+
}, [options, element]);
|
|
3944
3945
|
return stop;
|
|
3945
3946
|
}
|
|
3946
3947
|
|
|
@@ -3987,13 +3988,13 @@ function useResizeObserver(target, callback, options = {}) {
|
|
|
3987
3988
|
}
|
|
3988
3989
|
}, []);
|
|
3989
3990
|
useDeepCompareEffect(() => {
|
|
3990
|
-
if (!element
|
|
3991
|
+
if (!element) {
|
|
3991
3992
|
return;
|
|
3992
3993
|
}
|
|
3993
3994
|
observerRef.current = new ResizeObserver(savedCallback.current);
|
|
3994
|
-
observerRef.current.observe(element
|
|
3995
|
+
observerRef.current.observe(element, options);
|
|
3995
3996
|
return stop;
|
|
3996
|
-
}, [options, element
|
|
3997
|
+
}, [options, element]);
|
|
3997
3998
|
return stop;
|
|
3998
3999
|
}
|
|
3999
4000
|
|
|
@@ -4042,19 +4043,19 @@ function useDropZone(target, onDrop) {
|
|
|
4042
4043
|
return over;
|
|
4043
4044
|
}
|
|
4044
4045
|
|
|
4045
|
-
var __defProp$
|
|
4046
|
-
var __getOwnPropSymbols$
|
|
4047
|
-
var __hasOwnProp$
|
|
4048
|
-
var __propIsEnum$
|
|
4049
|
-
var __defNormalProp$
|
|
4050
|
-
var __spreadValues$
|
|
4046
|
+
var __defProp$2 = Object.defineProperty;
|
|
4047
|
+
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
4048
|
+
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
4049
|
+
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
4050
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4051
|
+
var __spreadValues$2 = (a, b) => {
|
|
4051
4052
|
for (var prop in b || (b = {}))
|
|
4052
|
-
if (__hasOwnProp$
|
|
4053
|
-
__defNormalProp$
|
|
4054
|
-
if (__getOwnPropSymbols$
|
|
4055
|
-
for (var prop of __getOwnPropSymbols$
|
|
4056
|
-
if (__propIsEnum$
|
|
4057
|
-
__defNormalProp$
|
|
4053
|
+
if (__hasOwnProp$3.call(b, prop))
|
|
4054
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
4055
|
+
if (__getOwnPropSymbols$3)
|
|
4056
|
+
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
4057
|
+
if (__propIsEnum$3.call(b, prop))
|
|
4058
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
4058
4059
|
}
|
|
4059
4060
|
return a;
|
|
4060
4061
|
};
|
|
@@ -4082,7 +4083,7 @@ function useFileDialog(options = {}) {
|
|
|
4082
4083
|
if (!inputRef.current) {
|
|
4083
4084
|
return;
|
|
4084
4085
|
}
|
|
4085
|
-
const _options = __spreadValues$
|
|
4086
|
+
const _options = __spreadValues$2(__spreadValues$2(__spreadValues$2({}, DEFAULT_OPTIONS), options), localOptions);
|
|
4086
4087
|
inputRef.current.multiple = _options.multiple;
|
|
4087
4088
|
inputRef.current.accept = _options.accept;
|
|
4088
4089
|
inputRef.current.capture = _options.capture;
|
|
@@ -4169,21 +4170,21 @@ function useScroll(target, options = {}) {
|
|
|
4169
4170
|
return [x, y, isScrolling, arrivedState, directions];
|
|
4170
4171
|
}
|
|
4171
4172
|
|
|
4172
|
-
var __defProp = Object.defineProperty;
|
|
4173
|
+
var __defProp$1 = Object.defineProperty;
|
|
4173
4174
|
var __defProps = Object.defineProperties;
|
|
4174
4175
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4175
|
-
var __getOwnPropSymbols$
|
|
4176
|
-
var __hasOwnProp$
|
|
4177
|
-
var __propIsEnum$
|
|
4178
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4179
|
-
var __spreadValues = (a, b) => {
|
|
4176
|
+
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
4177
|
+
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
4178
|
+
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
4179
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4180
|
+
var __spreadValues$1 = (a, b) => {
|
|
4180
4181
|
for (var prop in b || (b = {}))
|
|
4181
|
-
if (__hasOwnProp$
|
|
4182
|
-
__defNormalProp(a, prop, b[prop]);
|
|
4183
|
-
if (__getOwnPropSymbols$
|
|
4184
|
-
for (var prop of __getOwnPropSymbols$
|
|
4185
|
-
if (__propIsEnum$
|
|
4186
|
-
__defNormalProp(a, prop, b[prop]);
|
|
4182
|
+
if (__hasOwnProp$2.call(b, prop))
|
|
4183
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
4184
|
+
if (__getOwnPropSymbols$2)
|
|
4185
|
+
for (var prop of __getOwnPropSymbols$2(b)) {
|
|
4186
|
+
if (__propIsEnum$2.call(b, prop))
|
|
4187
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
4187
4188
|
}
|
|
4188
4189
|
return a;
|
|
4189
4190
|
};
|
|
@@ -4212,8 +4213,8 @@ function useInfiniteScroll(target, onLoadMore, options = {}) {
|
|
|
4212
4213
|
var _a, _b;
|
|
4213
4214
|
const savedLoadMore = useLatest(onLoadMore);
|
|
4214
4215
|
const direction = (_a = options.direction) != null ? _a : "bottom";
|
|
4215
|
-
const state = useScroll(target, __spreadProps(__spreadValues({}, options), {
|
|
4216
|
-
offset: __spreadValues({
|
|
4216
|
+
const state = useScroll(target, __spreadProps(__spreadValues$1({}, options), {
|
|
4217
|
+
offset: __spreadValues$1({
|
|
4217
4218
|
[direction]: (_b = options.distance) != null ? _b : 0
|
|
4218
4219
|
}, options.offset)
|
|
4219
4220
|
}));
|
|
@@ -4223,16 +4224,16 @@ function useInfiniteScroll(target, onLoadMore, options = {}) {
|
|
|
4223
4224
|
useUpdateEffect(() => {
|
|
4224
4225
|
const opts = latestOptions.current;
|
|
4225
4226
|
const fn = () => __async$3(this, null, function* () {
|
|
4226
|
-
var _a2, _b2
|
|
4227
|
+
var _a2, _b2;
|
|
4227
4228
|
const previous = {
|
|
4228
|
-
height: (
|
|
4229
|
-
width: (
|
|
4229
|
+
height: (_a2 = element == null ? void 0 : element.scrollHeight) != null ? _a2 : 0,
|
|
4230
|
+
width: (_b2 = element == null ? void 0 : element.scrollWidth) != null ? _b2 : 0
|
|
4230
4231
|
};
|
|
4231
4232
|
yield savedLoadMore.current(state);
|
|
4232
|
-
if (opts.preserveScrollPosition && element
|
|
4233
|
-
element.
|
|
4234
|
-
top: element.
|
|
4235
|
-
left: element.
|
|
4233
|
+
if (opts.preserveScrollPosition && element) {
|
|
4234
|
+
element.scrollTo({
|
|
4235
|
+
top: element.scrollHeight - previous.height,
|
|
4236
|
+
left: element.scrollWidth - previous.width
|
|
4236
4237
|
});
|
|
4237
4238
|
}
|
|
4238
4239
|
});
|
|
@@ -4274,7 +4275,7 @@ function useMousePressed(target, options = {}) {
|
|
|
4274
4275
|
const { touch = true, drag = true, initialValue = false } = options;
|
|
4275
4276
|
const [pressed, setPressed] = useState(initialValue);
|
|
4276
4277
|
const [sourceType, setSourceType] = useState(null);
|
|
4277
|
-
const
|
|
4278
|
+
const element = useLatestElement(target);
|
|
4278
4279
|
const onPressed = useCallback(
|
|
4279
4280
|
(srcType) => () => {
|
|
4280
4281
|
setPressed(true);
|
|
@@ -4290,7 +4291,6 @@ function useMousePressed(target, options = {}) {
|
|
|
4290
4291
|
useEventListener("mouseleave", onReleased, () => window, { passive: true });
|
|
4291
4292
|
useEventListener("mouseup", onReleased, () => window, { passive: true });
|
|
4292
4293
|
useEffect(() => {
|
|
4293
|
-
const element = elementRef.current;
|
|
4294
4294
|
if (drag) {
|
|
4295
4295
|
element == null ? void 0 : element.addEventListener("dragstart", onPressed("mouse"), {
|
|
4296
4296
|
passive: true
|
|
@@ -4325,7 +4325,7 @@ function useMousePressed(target, options = {}) {
|
|
|
4325
4325
|
element == null ? void 0 : element.removeEventListener("touchcancel", onReleased);
|
|
4326
4326
|
}
|
|
4327
4327
|
};
|
|
4328
|
-
}, [drag, onPressed, onReleased, touch,
|
|
4328
|
+
}, [drag, onPressed, onReleased, touch, element]);
|
|
4329
4329
|
return [pressed, sourceType];
|
|
4330
4330
|
}
|
|
4331
4331
|
|
|
@@ -4344,32 +4344,32 @@ function useScrollLock(target, initialState = false) {
|
|
|
4344
4344
|
const initialOverflowRef = useRef("scroll");
|
|
4345
4345
|
const element = useLatestElement(target);
|
|
4346
4346
|
useEffect(() => {
|
|
4347
|
-
if (element
|
|
4348
|
-
initialOverflowRef.current = element.
|
|
4347
|
+
if (element) {
|
|
4348
|
+
initialOverflowRef.current = element.style.overflow;
|
|
4349
4349
|
if (locked) {
|
|
4350
|
-
element.
|
|
4350
|
+
element.style.overflow = "hidden";
|
|
4351
4351
|
}
|
|
4352
4352
|
}
|
|
4353
|
-
}, [locked, element
|
|
4353
|
+
}, [locked, element]);
|
|
4354
4354
|
const lock = useEvent(() => {
|
|
4355
|
-
if (!element
|
|
4355
|
+
if (!element || locked) {
|
|
4356
4356
|
return;
|
|
4357
4357
|
}
|
|
4358
4358
|
if (isIOS) {
|
|
4359
|
-
element.
|
|
4359
|
+
element.addEventListener("touchmove", preventDefault, {
|
|
4360
4360
|
passive: false
|
|
4361
4361
|
});
|
|
4362
4362
|
}
|
|
4363
4363
|
setLocked(true);
|
|
4364
4364
|
});
|
|
4365
4365
|
const unlock = useEvent(() => {
|
|
4366
|
-
if (!element
|
|
4366
|
+
if (!element || !locked) {
|
|
4367
4367
|
return;
|
|
4368
4368
|
}
|
|
4369
4369
|
if (isIOS) {
|
|
4370
|
-
element.
|
|
4370
|
+
element.removeEventListener("touchmove", preventDefault);
|
|
4371
4371
|
}
|
|
4372
|
-
element.
|
|
4372
|
+
element.style.overflow = initialOverflowRef.current;
|
|
4373
4373
|
setLocked(false);
|
|
4374
4374
|
});
|
|
4375
4375
|
const set = useEvent((flag) => {
|
|
@@ -4809,11 +4809,11 @@ function useClickOutSide(target, handler) {
|
|
|
4809
4809
|
const savedHandler = useLatest(handler);
|
|
4810
4810
|
const element = useLatestElement(target);
|
|
4811
4811
|
const listener = (event) => {
|
|
4812
|
-
if (!element
|
|
4812
|
+
if (!element) {
|
|
4813
4813
|
return;
|
|
4814
4814
|
}
|
|
4815
4815
|
const elements = event.composedPath();
|
|
4816
|
-
if (element
|
|
4816
|
+
if (element === event.target || elements.includes(element)) {
|
|
4817
4817
|
return;
|
|
4818
4818
|
}
|
|
4819
4819
|
savedHandler.current(event);
|
|
@@ -5058,7 +5058,7 @@ function useScrollIntoView({
|
|
|
5058
5058
|
const scrollIntoView = useEvent(
|
|
5059
5059
|
({ alignment = "start" } = {}) => {
|
|
5060
5060
|
var _a;
|
|
5061
|
-
const parent = getTargetElement(scrollElement) || getScrollParent(axis, element
|
|
5061
|
+
const parent = getTargetElement(scrollElement) || getScrollParent(axis, element);
|
|
5062
5062
|
shouldStop.current = false;
|
|
5063
5063
|
if (frameID.current) {
|
|
5064
5064
|
cancel();
|
|
@@ -5066,7 +5066,7 @@ function useScrollIntoView({
|
|
|
5066
5066
|
const start = (_a = getScrollStart({ parent, axis })) != null ? _a : 0;
|
|
5067
5067
|
const change = getRelativePosition({
|
|
5068
5068
|
parent,
|
|
5069
|
-
target: element
|
|
5069
|
+
target: element,
|
|
5070
5070
|
axis,
|
|
5071
5071
|
alignment,
|
|
5072
5072
|
offset,
|
|
@@ -5120,10 +5120,10 @@ const useSticky = ({
|
|
|
5120
5120
|
const [isSticky, setSticky] = useState(false);
|
|
5121
5121
|
const element = useLatestElement(targetElement);
|
|
5122
5122
|
const { run: scrollHandler } = useThrottleFn(() => {
|
|
5123
|
-
if (!element
|
|
5123
|
+
if (!element) {
|
|
5124
5124
|
return;
|
|
5125
5125
|
}
|
|
5126
|
-
const rect = element.
|
|
5126
|
+
const rect = element.getBoundingClientRect();
|
|
5127
5127
|
if (axis === "y") {
|
|
5128
5128
|
setSticky((rect == null ? void 0 : rect.top) <= nav);
|
|
5129
5129
|
} else {
|
|
@@ -5131,8 +5131,8 @@ const useSticky = ({
|
|
|
5131
5131
|
}
|
|
5132
5132
|
}, 50);
|
|
5133
5133
|
useEffect(() => {
|
|
5134
|
-
const scrollParent = getTargetElement(scrollElement) || getScrollParent(axis, element
|
|
5135
|
-
if (!element
|
|
5134
|
+
const scrollParent = getTargetElement(scrollElement) || getScrollParent(axis, element);
|
|
5135
|
+
if (!element || !scrollParent) {
|
|
5136
5136
|
return;
|
|
5137
5137
|
}
|
|
5138
5138
|
scrollParent.addEventListener("scroll", scrollHandler);
|
|
@@ -5409,17 +5409,17 @@ function init (converter, defaultAttributes) {
|
|
|
5409
5409
|
|
|
5410
5410
|
var api = init(defaultConverter, { path: '/' });
|
|
5411
5411
|
|
|
5412
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5413
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5414
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5412
|
+
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
5413
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
5414
|
+
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
5415
5415
|
var __objRest = (source, exclude) => {
|
|
5416
5416
|
var target = {};
|
|
5417
5417
|
for (var prop in source)
|
|
5418
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
5418
|
+
if (__hasOwnProp$1.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
5419
5419
|
target[prop] = source[prop];
|
|
5420
|
-
if (source != null && __getOwnPropSymbols)
|
|
5421
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
5422
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
5420
|
+
if (source != null && __getOwnPropSymbols$1)
|
|
5421
|
+
for (var prop of __getOwnPropSymbols$1(source)) {
|
|
5422
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$1.call(source, prop))
|
|
5423
5423
|
target[prop] = source[prop];
|
|
5424
5424
|
}
|
|
5425
5425
|
return target;
|
|
@@ -5503,4 +5503,54 @@ function useDoubleClick({
|
|
|
5503
5503
|
useEventListener("touchend", handleTouchEnd, element, { passive: false });
|
|
5504
5504
|
}
|
|
5505
5505
|
|
|
5506
|
-
|
|
5506
|
+
var __defProp = Object.defineProperty;
|
|
5507
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5508
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5509
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5510
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
5511
|
+
var __spreadValues = (a, b) => {
|
|
5512
|
+
for (var prop in b || (b = {}))
|
|
5513
|
+
if (__hasOwnProp.call(b, prop))
|
|
5514
|
+
__defNormalProp(a, prop, b[prop]);
|
|
5515
|
+
if (__getOwnPropSymbols)
|
|
5516
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
5517
|
+
if (__propIsEnum.call(b, prop))
|
|
5518
|
+
__defNormalProp(a, prop, b[prop]);
|
|
5519
|
+
}
|
|
5520
|
+
return a;
|
|
5521
|
+
};
|
|
5522
|
+
function useSetState(initialState) {
|
|
5523
|
+
const [state, _setState] = useState(initialState);
|
|
5524
|
+
const setState = useCallback(
|
|
5525
|
+
(statePartial) => _setState((current) => __spreadValues(__spreadValues({}, current), typeof statePartial === "function" ? statePartial(current) : statePartial)),
|
|
5526
|
+
[]
|
|
5527
|
+
);
|
|
5528
|
+
return [state, setState];
|
|
5529
|
+
}
|
|
5530
|
+
|
|
5531
|
+
const defaultState = {
|
|
5532
|
+
x: 0,
|
|
5533
|
+
y: 0,
|
|
5534
|
+
width: 0,
|
|
5535
|
+
height: 0,
|
|
5536
|
+
top: 0,
|
|
5537
|
+
left: 0,
|
|
5538
|
+
bottom: 0,
|
|
5539
|
+
right: 0
|
|
5540
|
+
};
|
|
5541
|
+
function useMeasure(target, options = {}) {
|
|
5542
|
+
const [rect, setRect] = useState(defaultState);
|
|
5543
|
+
const stop = useResizeObserver(
|
|
5544
|
+
target,
|
|
5545
|
+
(entries) => {
|
|
5546
|
+
if (entries[0]) {
|
|
5547
|
+
const { x, y, width, height, top, left, bottom, right } = entries[0].contentRect;
|
|
5548
|
+
setRect({ x, y, width, height, top, left, bottom, right });
|
|
5549
|
+
}
|
|
5550
|
+
},
|
|
5551
|
+
options
|
|
5552
|
+
);
|
|
5553
|
+
return [rect, stop];
|
|
5554
|
+
}
|
|
5555
|
+
|
|
5556
|
+
export { getHMSTime, useActiveElement, useAsyncEffect, useClickOutSide as useClickOutside, useClipBorad as useClipboard, useControlled, useCookie, useCountDown, useCounter, useCustomCompareEffect, useCycleList, useDarkMode, useDebounce, useDebounceFn, useDeepCompareEffect, useDocumentVisibility, useDoubleClick, useDraggable, useDropZone, useElementBounding, useElementSize, useElementVisibility, useEvent, useEventEmitter, useEventListener, useEyeDropper, useFavicon, useFileDialog, useFirstMountState, useFocus, index$2 as useFps, useFullscreen, useGeolocation, useIdle, useInfiniteScroll, useIntersectionObserver, useInterval, useIsomorphicLayoutEffect, useKeyModifier, useLatest, useLocalStorage, useLongPress, useMeasure, index$3 as useMediaDevices, useMediaQuery, useMount, useMountedState, useMouse, useMousePressed, useMutationObserver, useNetwork, useObjectUrl, index$1 as useOnceEffect, index as useOnceLayoutEffect, useOnline, useOrientation, usePageLeave, usePermission, usePreferredColorScheme, usePreferredContrast, usePreferredDark, usePrevious, useRafFn, useRafState, useReducedMotion, useResizeObserver, useScriptTag, useScroll, useScrollIntoView, useScrollLock, useSessionStorage, useSetState, useSticky, useSupported, useTextDirection, useTextSelection, useThrottle, useThrottleFn, useTimeout, useTimeoutFn, useTitle, useToggle, useUnmount, useUpdate, useUpdateEffect, index$4 as useUpdateLayoutEffect, useVirtualList, useWindowScroll, useWindowSize, useWindowsFocus };
|