@unicom-cloud/ui-common 0.1.19 → 0.1.20
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/.virtual/_rolldown/runtime.js +1 -1
- package/.vite/manifest.json +88 -67
- package/development/index.js +1 -1
- package/empty/index.js +1 -1
- package/flex/index.js +1 -1
- package/flex/utils.js +1 -1
- package/higher-order/index.js +1 -1
- package/higher-order/with-speech-synthesis/index.js +1 -1
- package/hooks/create-deep-compare-effect/index.js +8 -7
- package/hooks/create-update-effect/index.d.ts +1 -1
- package/hooks/create-update-effect/index.js +9 -10
- package/hooks/create-use-storage-state/index.js +1 -1
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +82 -81
- package/hooks/use-async-effect/index.js +1 -1
- package/hooks/use-boolean/index.js +1 -1
- package/hooks/use-click-away/index.d.ts +2 -2
- package/hooks/use-click-away/index.js +7 -3
- package/hooks/use-computed-state/index.js +1 -1
- package/hooks/use-controllable-value/index.js +1 -1
- package/hooks/use-cookie-state/index.d.ts +34 -1
- package/hooks/use-cookie-state/index.js +16 -16
- package/hooks/use-count-down/index.js +1 -1
- package/hooks/use-counter/index.js +1 -1
- package/hooks/use-create/index.d.ts +4 -1
- package/hooks/use-create/index.js +1 -1
- package/hooks/use-creation/index.js +1 -1
- package/hooks/use-debounce/index.js +1 -1
- package/hooks/use-debounce-effect/index.js +1 -1
- package/hooks/use-debounce-fn/index.js +1 -1
- package/hooks/use-deep-compare-effect/index.js +1 -1
- package/hooks/use-deep-compare-layout-effect/index.js +1 -1
- package/hooks/use-document-visibility/index.js +1 -1
- package/hooks/use-drag/index.js +1 -1
- package/hooks/use-drop/index.js +1 -1
- package/hooks/use-effect-event/index.js +1 -1
- package/hooks/use-event/index.js +1 -1
- package/hooks/use-event-emitter/demo/demo1.d.ts +10 -0
- package/hooks/use-event-emitter/index.d.ts +8 -0
- package/hooks/use-event-emitter/index.js +26 -0
- package/hooks/use-event-listener/index.js +1 -1
- package/hooks/use-event-target/index.js +1 -1
- package/hooks/use-external/index.js +25 -24
- package/hooks/use-favicon/index.js +1 -1
- package/hooks/use-focus-within/index.js +1 -1
- package/hooks/use-force-update/index.js +1 -1
- package/hooks/use-fullscreen/index.js +1 -1
- package/hooks/use-get-state/index.js +1 -1
- package/hooks/use-history-travel/index.js +1 -1
- package/hooks/use-hover/index.js +1 -1
- package/hooks/use-id/index.js +1 -1
- package/hooks/use-in-view/index.js +1 -1
- package/hooks/use-in-viewport/index.js +1 -1
- package/hooks/use-infinite-scroll/index.js +1 -1
- package/hooks/use-intersection-observer/index.js +1 -1
- package/hooks/use-intersection-observers/index.js +1 -1
- package/hooks/use-interval/index.js +1 -1
- package/hooks/use-is-first-render/index.js +1 -1
- package/hooks/use-isomorphic-layout-effect/index.js +1 -1
- package/hooks/use-key-press/index.js +1 -1
- package/hooks/use-keyboard-event/index.js +3 -3
- package/hooks/use-latest/index.js +1 -1
- package/hooks/use-listen-window-resize/index.d.ts +1 -1
- package/hooks/use-listen-window-resize/index.js +3 -3
- package/hooks/use-local-storage-state/index.js +1 -1
- package/hooks/use-lock-fn/index.js +1 -1
- package/hooks/use-long-press/index.js +1 -1
- package/hooks/use-map/index.js +1 -1
- package/hooks/use-media/index.js +1 -1
- package/hooks/use-memo/index.js +1 -1
- package/hooks/use-memoized-fn/index.d.ts +1 -1
- package/hooks/use-memoized-fn/index.js +3 -3
- package/hooks/use-merge-props/index.js +1 -1
- package/hooks/use-merge-value/index.js +1 -1
- package/hooks/use-mobile/index.js +1 -1
- package/hooks/use-mount/index.js +1 -1
- package/hooks/use-mouse/index.js +1 -1
- package/hooks/use-move/index.js +1 -1
- package/hooks/use-mutation-observer/index.js +1 -1
- package/hooks/use-mutation-observers/index.js +1 -1
- package/hooks/use-network/index.js +1 -1
- package/hooks/use-online-status/index.js +1 -1
- package/hooks/use-overflow-hidden/index.js +1 -1
- package/hooks/use-override-ref/index.js +1 -1
- package/hooks/use-pagination/index.js +1 -1
- package/hooks/use-paste-image/index.js +1 -1
- package/hooks/use-persist-callback/index.js +1 -1
- package/hooks/use-prefers-color-scheme-dark/index.js +1 -1
- package/hooks/use-previous/index.js +1 -1
- package/hooks/use-raf-interval/index.js +1 -1
- package/hooks/use-raf-state/index.js +1 -1
- package/hooks/use-raf-timeout/index.js +1 -1
- package/hooks/use-reactive/index.js +1 -1
- package/hooks/use-ref-latest/index.js +1 -1
- package/hooks/use-refs/index.js +13 -12
- package/hooks/use-request/index.js +1 -1
- package/hooks/use-request/src/Fetch.js +1 -1
- package/hooks/use-request/src/plugins/useAutoRunPlugin.js +1 -1
- package/hooks/use-request/src/plugins/useCachePlugin.js +1 -1
- package/hooks/use-request/src/plugins/useDebouncePlugin.js +1 -1
- package/hooks/use-request/src/plugins/useLoadingDelayPlugin.js +1 -1
- package/hooks/use-request/src/plugins/usePollingPlugin.js +1 -1
- package/hooks/use-request/src/plugins/useRefreshOnWindowFocusPlugin.js +1 -1
- package/hooks/use-request/src/plugins/useRetryPlugin.js +1 -1
- package/hooks/use-request/src/plugins/useThrottlePlugin.js +1 -1
- package/hooks/use-request/src/useRequest.js +1 -1
- package/hooks/use-request/src/useRequestImplement.js +1 -1
- package/hooks/use-request/src/utils/cache.js +1 -1
- package/hooks/use-request/src/utils/cachePromise.js +1 -1
- package/hooks/use-request/src/utils/cacheSubscribe.js +1 -1
- package/hooks/use-request/src/utils/isDocumentVisible.js +1 -1
- package/hooks/use-request/src/utils/isOnline.js +1 -1
- package/hooks/use-request/src/utils/limit.js +1 -1
- package/hooks/use-request/src/utils/subscribeFocus.js +1 -1
- package/hooks/use-request/src/utils/subscribeReVisible.js +1 -1
- package/hooks/use-reset-state/index.js +1 -1
- package/hooks/use-resize-observer/index.js +1 -1
- package/hooks/use-resize-observers/index.js +1 -1
- package/hooks/use-responsive/index.js +1 -1
- package/hooks/use-safe-state/index.js +1 -1
- package/hooks/use-scroll/index.js +1 -1
- package/hooks/use-selections/index.js +1 -1
- package/hooks/use-session-storage-state/index.js +1 -1
- package/hooks/use-set/index.js +1 -1
- package/hooks/use-set-state/index.js +1 -1
- package/hooks/use-size/index.js +1 -1
- package/hooks/use-state-callback/index.js +1 -1
- package/hooks/use-state-with-promise/index.d.ts +11 -1
- package/hooks/use-state-with-promise/index.js +21 -20
- package/hooks/use-sync-state/index.js +1 -1
- package/hooks/use-text-selection/index.js +1 -1
- package/hooks/use-theme/index.js +1 -1
- package/hooks/use-throttle/index.js +1 -1
- package/hooks/use-throttle-effect/index.js +1 -1
- package/hooks/use-throttle-fn/index.js +1 -1
- package/hooks/use-timeout/index.js +1 -1
- package/hooks/use-title/index.js +1 -1
- package/hooks/use-toggle/index.js +12 -11
- package/hooks/use-tracked-effect/index.js +1 -1
- package/hooks/use-unmount/index.js +1 -1
- package/hooks/use-unmounted-ref/index.js +1 -1
- package/hooks/use-update/index.d.ts +3 -1
- package/hooks/use-update/index.js +5 -5
- package/hooks/use-update-effect/index.js +1 -1
- package/hooks/use-update-layout-effect/index.js +1 -1
- package/hooks/use-url-state/index.js +1 -1
- package/hooks/use-virtual-list/index.js +1 -1
- package/hooks/use-watch/index.js +1 -1
- package/hooks/use-web-socket/index.js +1 -1
- package/hooks/use-why-did-you-update/index.js +1 -1
- package/hooks/use-window-size/index.d.ts +1 -1
- package/hooks/use-window-size/index.js +1 -1
- package/hooks/utils/createEffectWithTarget.js +1 -1
- package/hooks/utils/depsAreSame.js +1 -1
- package/hooks/utils/depsEqual.js +1 -1
- package/hooks/utils/domTarget.js +1 -1
- package/hooks/utils/getDocumentOrShadow.js +1 -1
- package/hooks/utils/index.js +1 -1
- package/hooks/utils/isAppleDevice.js +1 -1
- package/hooks/utils/isBrowser.js +1 -1
- package/hooks/utils/isDev.js +1 -1
- package/hooks/utils/rect.js +1 -1
- package/hooks/utils/useDeepCompareWithTarget.js +1 -1
- package/hooks/utils/useEffectWithTarget.js +1 -1
- package/hooks/utils/useIsomorphicLayoutEffectWithTarget.js +1 -1
- package/hooks/utils/useLayoutEffectWithTarget.js +1 -1
- package/icons/file/index.js +1 -1
- package/index.d.ts +1 -1
- package/index.js +574 -544
- package/package.json +1 -1
- package/progress/index.js +43 -43
- package/resize-observer/Collection.d.ts +2 -2
- package/resize-observer/Collection.js +1 -1
- package/resize-observer/SingleObserver.js +1 -1
- package/resize-observer/index.js +1 -1
- package/resize-observer/observerUtil.js +1 -1
- package/space/index.js +1 -1
- package/style/animation.less +13 -1
- package/style.css +1 -1
- package/suspense-fallback-test/index.js +1 -1
- package/test.js +1 -1
- package/timer/index.js +1 -1
- package/transition/Transition.d.ts +11 -0
- package/transition/Transition.js +92 -0
- package/transition/TransitionCSS.d.ts +11 -0
- package/transition/TransitionCSS.js +33 -0
- package/transition/TransitionGroup.d.ts +11 -0
- package/transition/TransitionGroup.js +62 -0
- package/transition/TransitionStyle.d.ts +11 -0
- package/transition/TransitionStyle.js +46 -0
- package/transition/constants.d.ts +43 -0
- package/transition/constants.js +46 -0
- package/transition/index.d.ts +12 -0
- package/transition/index.js +12 -0
- package/transition/interface.d.ts +192 -0
- package/transition/utils.d.ts +19 -0
- package/transition/utils.js +97 -0
- package/utils/callOrReturn.js +1 -1
- package/utils/callbackOriginRef.js +1 -1
- package/utils/caseName.js +1 -1
- package/utils/className.js +1 -1
- package/utils/constant.js +1 -1
- package/utils/copy.js +1 -1
- package/utils/date.js +1 -1
- package/utils/dayjs.js +1 -1
- package/utils/dom.js +1 -1
- package/utils/emitter.js +1 -1
- package/utils/fileRead.js +1 -1
- package/utils/fileToDataURL.js +1 -1
- package/utils/fillNBSP.js +1 -1
- package/utils/findRootElement.d.ts +3 -3
- package/utils/findRootElement.js +2 -2
- package/utils/findScrollParent.js +1 -1
- package/utils/getHighlightText.js +1 -1
- package/utils/getHotkeyHandler.js +1 -1
- package/utils/getScrollBarHeight.js +1 -1
- package/utils/getScrollBarSize.js +1 -1
- package/utils/getScrollBarWidth.js +1 -1
- package/utils/getStringLength.js +1 -1
- package/utils/include.js +1 -1
- package/utils/index.js +277 -276
- package/utils/intersectionObserver.js +1 -1
- package/utils/is.d.ts +6 -5
- package/utils/is.js +23 -20
- package/utils/keyboardCode.js +1 -1
- package/utils/lodash.js +1 -1
- package/utils/math.js +1 -1
- package/utils/mergeProps.js +1 -1
- package/utils/mergedToString.js +1 -1
- package/utils/mutationObserver.js +1 -1
- package/utils/omit.js +1 -1
- package/utils/pad.js +1 -1
- package/utils/pick.js +1 -1
- package/utils/pinyin.js +1 -1
- package/utils/react19Adapter.js +1 -1
- package/utils/ref.js +2 -2
- package/utils/resizeObserver.js +1 -1
- package/utils/saveAs.js +1 -1
- package/utils/screenfull.js +1 -1
- package/utils/scrollIntoViewIfNeeded.js +1 -1
- package/utils/setCreateRoot.js +1 -1
- package/utils/setDarkTheme.js +1 -1
- package/utils/setDir.js +1 -1
- package/utils/setPrimaryColor.js +1 -1
- package/utils/setTheme.js +1 -1
- package/utils/string.js +1 -1
- package/utils/style.js +1 -1
- package/utils/throttleByRaf.js +1 -1
- package/utils/throttleByRaf2.js +1 -1
- package/utils/tinycolor.js +1 -1
- package/utils/toArray.js +1 -1
- package/utils/tree.js +1 -1
- package/utils/tween.js +1 -1
- package/utils/uuid.js +1 -1
- package/utils/validate.js +1 -1
- package/utils/warning.js +1 -1
- package/version/index.js +9 -9
- package/transition-group/ChildMapping.d.ts +0 -27
- package/transition-group/ChildMapping.js +0 -61
- package/transition-group/Transition.d.ts +0 -126
- package/transition-group/Transition.js +0 -133
- package/transition-group/TransitionCSS.d.ts +0 -97
- package/transition-group/TransitionCSS.js +0 -73
- package/transition-group/TransitionGroup.d.ts +0 -31
- package/transition-group/TransitionGroup.js +0 -54
- package/transition-group/TransitionReplace.d.ts +0 -23
- package/transition-group/TransitionReplace.js +0 -38
- package/transition-group/TransitionSwitch.d.ts +0 -88
- package/transition-group/TransitionSwitch.js +0 -84
- package/transition-group/context.d.ts +0 -2
- package/transition-group/context.js +0 -7
- package/transition-group/index.d.ts +0 -9
- package/transition-group/index.js +0 -11
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
export type State = string | undefined;
|
|
2
|
-
export interface
|
|
2
|
+
export interface CookieAttributes {
|
|
3
|
+
/**
|
|
4
|
+
* Define when the cookie will be removed. Value can be a Number
|
|
5
|
+
* which will be interpreted as days from time of creation or a
|
|
6
|
+
* Date instance. If omitted, the cookie becomes a session cookie.
|
|
7
|
+
*/
|
|
8
|
+
expires?: number | Date | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* Define the path where the cookie is available. Defaults to '/'
|
|
11
|
+
*/
|
|
12
|
+
path?: string | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Define the domain where the cookie is available. Defaults to
|
|
15
|
+
* the domain of the page where the cookie was created.
|
|
16
|
+
*/
|
|
17
|
+
domain?: string | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* A Boolean indicating if the cookie transmission requires a
|
|
20
|
+
* secure protocol (https). Defaults to false.
|
|
21
|
+
*/
|
|
22
|
+
secure?: boolean | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Asserts that a cookie must not be sent with cross-origin requests,
|
|
25
|
+
* providing some protection against cross-site request forgery
|
|
26
|
+
* attacks (CSRF)
|
|
27
|
+
*/
|
|
28
|
+
sameSite?: 'strict' | 'Strict' | 'lax' | 'Lax' | 'none' | 'None' | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* An attribute which will be serialized, conformably to RFC 6265
|
|
31
|
+
* section 5.2.
|
|
32
|
+
*/
|
|
33
|
+
[property: string]: any;
|
|
34
|
+
}
|
|
35
|
+
export interface Options extends CookieAttributes {
|
|
3
36
|
defaultValue?: State | (() => State);
|
|
4
37
|
}
|
|
5
38
|
declare function useCookieState(cookieKey: string, options?: Options): readonly [State, (this: unknown, ...args: unknown[]) => unknown];
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
/* 潘启宝 2026-04-
|
|
2
|
-
import { isFunction as e, isString as t } from "../../utils/is.js";
|
|
3
|
-
import
|
|
4
|
-
import { useState as
|
|
5
|
-
import
|
|
1
|
+
/* 潘启宝 2026-04-14 16:51:31 星期二 */
|
|
2
|
+
import { isFunction as e, isString as t, isUndefined as n } from "../../utils/is.js";
|
|
3
|
+
import r from "../use-memoized-fn/index.js";
|
|
4
|
+
import { useState as i } from "react";
|
|
5
|
+
import a from "@unicom-cloud/utils/cookie";
|
|
6
6
|
//#region components/common/hooks/use-cookie-state/index.ts
|
|
7
|
-
function
|
|
8
|
-
let [
|
|
9
|
-
let n =
|
|
10
|
-
return t(n) ? n : e(
|
|
7
|
+
function o(o, s = {}) {
|
|
8
|
+
let [c, l] = i(() => {
|
|
9
|
+
let n = a.get(o);
|
|
10
|
+
return t(n) ? n : e(s.defaultValue) ? s.defaultValue() : s.defaultValue;
|
|
11
11
|
});
|
|
12
|
-
return [
|
|
13
|
-
let { defaultValue:
|
|
14
|
-
...
|
|
15
|
-
...
|
|
16
|
-
},
|
|
17
|
-
|
|
12
|
+
return [c, r((t, r = {}) => {
|
|
13
|
+
let { defaultValue: i, ...u } = {
|
|
14
|
+
...s,
|
|
15
|
+
...r
|
|
16
|
+
}, d = e(t) ? t(c) : t;
|
|
17
|
+
l(d), n(d) ? a.remove(o) : a.set(o, d, u);
|
|
18
18
|
})];
|
|
19
19
|
}
|
|
20
20
|
//#endregion
|
|
21
|
-
export {
|
|
21
|
+
export { o as default };
|
|
22
22
|
/* 独立思考,明辨是非 */
|
package/hooks/use-drag/index.js
CHANGED
package/hooks/use-drop/index.js
CHANGED
package/hooks/use-event/index.js
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* title: Parent component shares a event
|
|
3
|
+
* desc: The parent component creates a `focus$` event emitter, and passes it to its children. When calling `focus$.emit` in MessageBox, InputBox will get notified.
|
|
4
|
+
*
|
|
5
|
+
* title.zh-CN: 父组件向子组件共享事件
|
|
6
|
+
* desc.zh-CN: 父组件创建了一个 `focus$` 事件,并且将它传递给了两个子组件。在 MessageBox 中调用 `focus$.emit` ,InputBox 组件就可以收到通知。
|
|
7
|
+
*/
|
|
8
|
+
import React from 'react';
|
|
9
|
+
declare const Demo: React.FC;
|
|
10
|
+
export default Demo;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type Subscription<T> = (val: T) => void;
|
|
2
|
+
export declare class EventEmitter<T> {
|
|
3
|
+
private subscriptions;
|
|
4
|
+
emit: (val: T) => void;
|
|
5
|
+
useSubscription: (callback: Subscription<T>) => void;
|
|
6
|
+
}
|
|
7
|
+
declare const useEventEmitter: <T = void>() => EventEmitter<T>;
|
|
8
|
+
export default useEventEmitter;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/* 潘启宝 2026-04-14 16:51:31 星期二 */
|
|
2
|
+
import { useEffect as e, useRef as t } from "react";
|
|
3
|
+
//#region components/common/hooks/use-event-emitter/index.ts
|
|
4
|
+
var n = class {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.subscriptions = /* @__PURE__ */ new Set(), this.emit = (e) => {
|
|
7
|
+
for (let t of this.subscriptions) t(e);
|
|
8
|
+
}, this.useSubscription = (n) => {
|
|
9
|
+
let r = t(void 0);
|
|
10
|
+
r.current = n, e(() => {
|
|
11
|
+
function e(e) {
|
|
12
|
+
r.current && r.current(e);
|
|
13
|
+
}
|
|
14
|
+
return this.subscriptions.add(e), () => {
|
|
15
|
+
this.subscriptions.delete(e);
|
|
16
|
+
};
|
|
17
|
+
}, []);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
}, r = () => {
|
|
21
|
+
let e = t(void 0);
|
|
22
|
+
return e.current ||= new n(), e.current;
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
export { n as EventEmitter, r as default };
|
|
26
|
+
/* 独立思考,明辨是非 */
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
/* 潘启宝 2026-04-
|
|
2
|
-
import {
|
|
1
|
+
/* 潘启宝 2026-04-14 16:51:31 星期二 */
|
|
2
|
+
import { isUndefined as e } from "../../utils/is.js";
|
|
3
|
+
import { useEffect as t, useRef as n, useState as r } from "react";
|
|
3
4
|
//#region components/common/hooks/use-external/index.ts
|
|
4
|
-
var
|
|
5
|
+
var i = {}, a = (e, t = {}) => {
|
|
5
6
|
let n = document.querySelector(`script[src="${e}"]`);
|
|
6
7
|
if (!n) {
|
|
7
8
|
let n = document.createElement("script");
|
|
@@ -16,7 +17,7 @@ var r = {}, i = (e, t = {}) => {
|
|
|
16
17
|
ref: n,
|
|
17
18
|
status: n.getAttribute("data-status") || "ready"
|
|
18
19
|
};
|
|
19
|
-
},
|
|
20
|
+
}, o = (e, t = {}) => {
|
|
20
21
|
let n = document.querySelector(`link[href="${e}"]`);
|
|
21
22
|
if (!n) {
|
|
22
23
|
let n = document.createElement("link");
|
|
@@ -31,32 +32,32 @@ var r = {}, i = (e, t = {}) => {
|
|
|
31
32
|
ref: n,
|
|
32
33
|
status: n.getAttribute("data-status") || "ready"
|
|
33
34
|
};
|
|
34
|
-
},
|
|
35
|
-
let [
|
|
36
|
-
return
|
|
37
|
-
if (!
|
|
38
|
-
|
|
35
|
+
}, s = (s, c) => {
|
|
36
|
+
let [l, u] = r(s ? "loading" : "unset"), d = n(void 0);
|
|
37
|
+
return t(() => {
|
|
38
|
+
if (!s) {
|
|
39
|
+
u("unset");
|
|
39
40
|
return;
|
|
40
41
|
}
|
|
41
|
-
let
|
|
42
|
-
if (
|
|
43
|
-
let e =
|
|
44
|
-
|
|
45
|
-
} else if (
|
|
46
|
-
let e =
|
|
47
|
-
|
|
42
|
+
let t = s.replace(/[|#].*$/, "");
|
|
43
|
+
if (c?.type === "css" || !c?.type && /(^css!|\.css$)/.test(t)) {
|
|
44
|
+
let e = o(s, c?.css);
|
|
45
|
+
d.current = e.ref, u(e.status);
|
|
46
|
+
} else if (c?.type === "js" || !c?.type && /(^js!|\.js$)/.test(t)) {
|
|
47
|
+
let e = a(s, c?.js);
|
|
48
|
+
d.current = e.ref, u(e.status);
|
|
48
49
|
} else console.error("Cannot infer the type of external resource, and please provide a type ('js' | 'css'). ");
|
|
49
|
-
if (!
|
|
50
|
-
|
|
51
|
-
let
|
|
50
|
+
if (!d.current) return;
|
|
51
|
+
e(i[s]) ? i[s] = 1 : i[s] += 1;
|
|
52
|
+
let n = (e) => {
|
|
52
53
|
let t = e.type === "load" ? "ready" : "error";
|
|
53
|
-
|
|
54
|
+
d.current?.setAttribute?.("data-status", t), u(t);
|
|
54
55
|
};
|
|
55
|
-
return
|
|
56
|
-
|
|
56
|
+
return d.current.addEventListener("load", n), d.current.addEventListener("error", n), () => {
|
|
57
|
+
d.current?.removeEventListener?.("load", n), d.current?.removeEventListener?.("error", n), --i[s], i[s] === 0 && !c?.keepWhenUnused && d.current?.remove?.(), d.current = void 0;
|
|
57
58
|
};
|
|
58
|
-
}, [
|
|
59
|
+
}, [s]), l;
|
|
59
60
|
};
|
|
60
61
|
//#endregion
|
|
61
|
-
export {
|
|
62
|
+
export { s as default };
|
|
62
63
|
/* 独立思考,明辨是非 */
|
package/hooks/use-hover/index.js
CHANGED
package/hooks/use-id/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* 潘启宝 2026-04-
|
|
1
|
+
/* 潘启宝 2026-04-14 16:51:31 星期二 */
|
|
2
2
|
import e, { supportIntersectionObserver as t } from "../use-intersection-observer/index.js";
|
|
3
3
|
import { useCallback as n, useEffect as r, useState as i } from "react";
|
|
4
4
|
//#region components/common/hooks/use-in-view/index.ts
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/* 潘启宝 2026-04-
|
|
1
|
+
/* 潘启宝 2026-04-14 16:51:31 星期二 */
|
|
2
2
|
import { useCallback as e } from "react";
|
|
3
3
|
import { ArrowDown as t, ArrowLeft as n, ArrowRight as r, ArrowUp as i, Enter as a } from "@unicom-cloud/utils/constant/keyboardCode";
|
|
4
4
|
//#region components/common/hooks/use-keyboard-event/index.ts
|
|
5
|
-
function o(o) {
|
|
5
|
+
function o(o = {}) {
|
|
6
6
|
return e((e) => ({ onKeyDown(s) {
|
|
7
7
|
let c = s.key;
|
|
8
|
-
c === a.key && e.onPressEnter?.(s, c), c === t.key && e.onArrowDown?.(s, c), c === n.key && e.onArrowLeft?.(s, c), c === r.key && e.onArrowRight?.(s, c), c === i.key && e.onArrowUp?.(s, c), o
|
|
8
|
+
c === a.key && e.onPressEnter?.(s, c), c === t.key && e.onArrowDown?.(s, c), c === n.key && e.onArrowLeft?.(s, c), c === r.key && e.onArrowRight?.(s, c), c === i.key && e.onArrowUp?.(s, c), o.onKeyDown?.(s);
|
|
9
9
|
} }), []);
|
|
10
10
|
}
|
|
11
11
|
//#endregion
|
|
@@ -10,5 +10,5 @@
|
|
|
10
10
|
* useListenWindowResize(callback, []);
|
|
11
11
|
* ```
|
|
12
12
|
*/
|
|
13
|
-
declare function useListenWindowResize(callback: (e: Event) => void): void;
|
|
13
|
+
declare function useListenWindowResize(callback: (e: Event) => void, deps?: unknown[]): void;
|
|
14
14
|
export default useListenWindowResize;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/* 潘启宝 2026-04-
|
|
1
|
+
/* 潘启宝 2026-04-14 16:51:31 星期二 */
|
|
2
2
|
import { useEffect as e } from "react";
|
|
3
3
|
//#region components/common/hooks/use-listen-window-resize/index.ts
|
|
4
|
-
function t(t) {
|
|
4
|
+
function t(t, n = []) {
|
|
5
5
|
e(() => (window.addEventListener("resize", t), window.addEventListener("orientationchange", t), () => {
|
|
6
6
|
window.removeEventListener("resize", t), window.removeEventListener("orientationchange", t);
|
|
7
|
-
}), []);
|
|
7
|
+
}), [...n]);
|
|
8
8
|
}
|
|
9
9
|
//#endregion
|
|
10
10
|
export { t as default };
|
package/hooks/use-map/index.js
CHANGED
package/hooks/use-media/index.js
CHANGED
package/hooks/use-memo/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
type noop = (this: unknown, ...args: unknown[]) => unknown;
|
|
2
2
|
type PickFunction<T extends noop> = (this: ThisParameterType<T>, ...args: Parameters<T>) => ReturnType<T>;
|
|
3
|
-
declare
|
|
3
|
+
declare function useMemoizedFn<T extends noop>(fn: T): PickFunction<T>;
|
|
4
4
|
export default useMemoizedFn;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
/* 潘启宝 2026-04-
|
|
1
|
+
/* 潘启宝 2026-04-14 16:51:31 星期二 */
|
|
2
2
|
import { isFunction as e } from "../../utils/is.js";
|
|
3
3
|
import t from "../utils/isDev.js";
|
|
4
4
|
import { useMemo as n, useRef as r } from "react";
|
|
5
5
|
//#region components/common/hooks/use-memoized-fn/index.ts
|
|
6
|
-
|
|
6
|
+
function i(i) {
|
|
7
7
|
t && (e(i) || console.error(`useMemoizedFn expected parameter is a function, got ${typeof i}`));
|
|
8
8
|
let a = r(i);
|
|
9
9
|
return a.current = n(() => i, [i]), r(function(...e) {
|
|
10
10
|
return a.current.apply(this, e);
|
|
11
11
|
}).current;
|
|
12
|
-
}
|
|
12
|
+
}
|
|
13
13
|
//#endregion
|
|
14
14
|
export { i as default };
|
|
15
15
|
/* 独立思考,明辨是非 */
|
package/hooks/use-mount/index.js
CHANGED
package/hooks/use-mouse/index.js
CHANGED