enr 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/cjs/components/ripples/Content.js +16 -0
- package/cjs/components/ripples/LazyRippleEle.js +5 -36
- package/cjs/components/ripples/RipplesEle.js +3 -35
- package/cjs/components/ripples/imperative-handle.js +48 -0
- package/cjs/components/ripples/{useOptionUpdate.js → use-option-update.js} +2 -1
- package/cjs/customHooks/useAnimationFrame.js +2 -2
- package/cjs/customHooks/useInputIsComposing.js +2 -2
- package/cjs/customHooks/useRipples/class-build-background.js +2 -3
- package/cjs/customHooks/useRipples/class-event-action.js +3 -4
- package/cjs/customHooks/useRipples/class-param.js +24 -1
- package/cjs/customHooks/useRipples/class-ripple.js +12 -1
- package/cjs/customHooks/useRipples/class-webgl.js +10 -2
- package/cjs/customHooks/useRipples/data-default.js +4 -1
- package/cjs/customHooks/useRipples/index.js +2 -2
- package/cjs/customHooks/useTimeId.js +2 -2
- package/es/components/ripples/Content.js +16 -1
- package/es/components/ripples/LazyRippleEle.js +8 -39
- package/es/components/ripples/RipplesEle.js +6 -38
- package/es/components/ripples/imperative-handle.js +46 -0
- package/es/components/ripples/{useOptionUpdate.js → use-option-update.js} +2 -1
- package/es/customHooks/useAnimationFrame.js +2 -2
- package/es/customHooks/useInputIsComposing.js +2 -2
- package/es/customHooks/useRipples/class-build-background.js +2 -3
- package/es/customHooks/useRipples/class-event-action.js +3 -4
- package/es/customHooks/useRipples/class-param.js +25 -2
- package/es/customHooks/useRipples/class-ripple.js +12 -1
- package/es/customHooks/useRipples/class-webgl.js +10 -2
- package/es/customHooks/useRipples/data-default.js +4 -2
- package/es/customHooks/useRipples/index.js +2 -2
- package/es/customHooks/useTimeId.js +2 -2
- package/es/src/components/ripples/Content.d.ts +7 -0
- package/es/src/components/ripples/LazyRippleEle.d.ts +5 -6
- package/es/src/components/ripples/RipplesEle.d.ts +3 -3
- package/es/src/components/ripples/imperative-handle.d.ts +19 -0
- package/es/src/components/ripples/types.d.ts +6 -1
- package/es/src/customHooks/useAnimationFrame.d.ts +2 -2
- package/es/src/customHooks/useInputIsComposing.d.ts +2 -2
- package/es/src/customHooks/useRipples/class-build-background.d.ts +1 -1
- package/es/src/customHooks/useRipples/class-event-action.d.ts +3 -4
- package/es/src/customHooks/useRipples/class-param.d.ts +8 -1
- package/es/src/customHooks/useRipples/class-ripple.d.ts +18 -21
- package/es/src/customHooks/useRipples/class-webgl.d.ts +5 -2
- package/es/src/customHooks/useRipples/data-default.d.ts +2 -1
- package/es/src/customHooks/useRipples/index.d.ts +2 -2
- package/es/src/customHooks/useRipples/types.d.ts +104 -30
- package/es/src/customHooks/useTimeId.d.ts +2 -2
- package/package.json +3 -3
- /package/es/src/components/ripples/{useOptionUpdate.d.ts → use-option-update.d.ts} +0 -0
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { useRef, useImperativeHandle } from 'react';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useRef } from 'react';
|
|
5
4
|
import { useRipples } from '../../customHooks/useRipples/index.js';
|
|
6
|
-
import {
|
|
7
|
-
import { useOptionUpdate } from './useOptionUpdate.js';
|
|
5
|
+
import { ComponentContent } from './Content.js';
|
|
8
6
|
|
|
9
7
|
/**
|
|
10
8
|
*
|
|
@@ -23,9 +21,9 @@ import { useOptionUpdate } from './useOptionUpdate.js';
|
|
|
23
21
|
* 使用:
|
|
24
22
|
*
|
|
25
23
|
* ```ts
|
|
26
|
-
* import { BackgroundRipple } from '
|
|
24
|
+
* import { BackgroundRipple } from 'enr/';
|
|
27
25
|
* // 也可以全量导入
|
|
28
|
-
* // import { BackgroundRipple } from '
|
|
26
|
+
* // import { BackgroundRipple } from 'enr';
|
|
29
27
|
* ...
|
|
30
28
|
* const animationFrameId = useAnimationFrame();
|
|
31
29
|
*
|
|
@@ -36,41 +34,11 @@ import { useOptionUpdate } from './useOptionUpdate.js';
|
|
|
36
34
|
*
|
|
37
35
|
*/
|
|
38
36
|
const BackgroundRipple = ({ option, ...props }) => {
|
|
39
|
-
const { children, style, ref, ..._props } = props;
|
|
40
37
|
/** canvas 元素 */
|
|
41
38
|
const canvas = useRef(null);
|
|
42
39
|
/** 使用 ripples */
|
|
43
40
|
const ripplesRef = useRipples(canvas, option);
|
|
44
|
-
|
|
45
|
-
useOptionUpdate(ripplesRef, option);
|
|
46
|
-
// 抛出事件 (自定义抛出事件)
|
|
47
|
-
useImperativeHandle(ref, () => ({
|
|
48
|
-
toggleState: () => ripplesRef.current?.changePlayingState() ?? false,
|
|
49
|
-
get state() {
|
|
50
|
-
return ripplesRef.current?.options.playingState ?? false;
|
|
51
|
-
},
|
|
52
|
-
pause() {
|
|
53
|
-
ripplesRef.current?.pause();
|
|
54
|
-
},
|
|
55
|
-
play() {
|
|
56
|
-
ripplesRef.current?.play();
|
|
57
|
-
},
|
|
58
|
-
set(options) {
|
|
59
|
-
if (isUndefined(options))
|
|
60
|
-
return;
|
|
61
|
-
const keys = Object.keys(options);
|
|
62
|
-
for (let i = 0, j = keys.length; i < j; i++) {
|
|
63
|
-
const key = keys[i];
|
|
64
|
-
ripplesRef.current?.set(key, options[key]);
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
}));
|
|
68
|
-
return (jsxs(Content, { style: {
|
|
69
|
-
backgroundRepeat: 'round',
|
|
70
|
-
// backgroundSize: 'cover',
|
|
71
|
-
// backgroundPosition: 'center',
|
|
72
|
-
...style,
|
|
73
|
-
}, ..._props, children: [jsx("canvas", { ref: canvas, "data-earthnut-ui": "canvas", width: 0, height: 0 }), children] }));
|
|
41
|
+
return jsx(ComponentContent, { ripplesRef: ripplesRef, canvas: canvas, option: option, ...props });
|
|
74
42
|
};
|
|
75
43
|
BackgroundRipple.displayName = 'enr-background-ripple';
|
|
76
44
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { isUndefined } from 'a-type-of-js';
|
|
2
|
+
import { defaultData } from '../../customHooks/useRipples/data-default.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @module @enr/imperative-handle
|
|
6
|
+
* @file imperative-handle.ts
|
|
7
|
+
* @description 公共的命令句柄
|
|
8
|
+
* @author Mr.MudBean <Mr.MudBean@outlook.com>
|
|
9
|
+
* @license MIT
|
|
10
|
+
* @copyright 2026 ©️ Mr.MudBean
|
|
11
|
+
* @since 2026-02-04 06:52
|
|
12
|
+
* @version 2.0.1
|
|
13
|
+
* @lastModified 2026-02-04 07:57
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* ## 通过函数构建公共的命令句柄
|
|
17
|
+
* @param ripplesRef
|
|
18
|
+
*/
|
|
19
|
+
function createImperativeHandle(ripplesRef) {
|
|
20
|
+
return () => ({
|
|
21
|
+
toggleState: () => ripplesRef.current?.changePlayingState() ?? false,
|
|
22
|
+
get state() {
|
|
23
|
+
return ripplesRef.current?.get('playingState') ?? false;
|
|
24
|
+
},
|
|
25
|
+
pause() {
|
|
26
|
+
ripplesRef.current?.pause();
|
|
27
|
+
},
|
|
28
|
+
play() {
|
|
29
|
+
ripplesRef.current?.play();
|
|
30
|
+
},
|
|
31
|
+
set(options) {
|
|
32
|
+
if (isUndefined(options))
|
|
33
|
+
return;
|
|
34
|
+
const keys = Object.keys(options);
|
|
35
|
+
for (let i = 0, j = keys.length; i < j; i++) {
|
|
36
|
+
const key = keys[i];
|
|
37
|
+
ripplesRef.current?.set(key, options[key]);
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
drop(x, y, options) {
|
|
41
|
+
ripplesRef.current?.drop(x, y, options?.radius ?? ripplesRef?.current.get('dropRadius') ?? defaultData.dropRadius, options?.strength ?? ripplesRef?.current?.get('perturbation') ?? 0.03);
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { createImperativeHandle };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isArray } from 'a-type-of-js';
|
|
2
2
|
import { useRef, useEffect } from 'react';
|
|
3
|
+
import { defaultDataKey } from '../../customHooks/useRipples/data-default.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* 更新参数数据
|
|
@@ -13,7 +14,7 @@ function useOptionUpdate(ripplesRef, option) {
|
|
|
13
14
|
if (!option || !ripplesRef.current) {
|
|
14
15
|
return;
|
|
15
16
|
}
|
|
16
|
-
|
|
17
|
+
defaultDataKey.forEach(e => {
|
|
17
18
|
/** 新的值 */
|
|
18
19
|
const value = option[e];
|
|
19
20
|
/** 测试值是否相等 */
|
|
@@ -11,7 +11,7 @@ import { useRef, useCallback, useEffect } from 'react';
|
|
|
11
11
|
* @copyright 2026 ©️ MrMudBean
|
|
12
12
|
* @since 2025-01-07 11:23
|
|
13
13
|
* @version 2.0.0-alpha.0
|
|
14
|
-
* @lastModified 2026-02-
|
|
14
|
+
* @lastModified 2026-02-04 08:18
|
|
15
15
|
*/
|
|
16
16
|
/**
|
|
17
17
|
*
|
|
@@ -28,7 +28,7 @@ import { useRef, useCallback, useEffect } from 'react';
|
|
|
28
28
|
* 使用:
|
|
29
29
|
*
|
|
30
30
|
* ```ts
|
|
31
|
-
* // import { useAnimationFrame } from '
|
|
31
|
+
* // import { useAnimationFrame } from 'enr';
|
|
32
32
|
* ...
|
|
33
33
|
*
|
|
34
34
|
* export function Home () {
|
|
@@ -10,7 +10,7 @@ import { useRef, useEffect } from 'react';
|
|
|
10
10
|
* @copyright 2026 ©️ MrMudBean
|
|
11
11
|
* @since 2025-01-07 11:23
|
|
12
12
|
* @version 2.0.0-alpha.0
|
|
13
|
-
* @lastModified 2026-
|
|
13
|
+
* @lastModified 2026-02-04 08:19
|
|
14
14
|
*/
|
|
15
15
|
/**
|
|
16
16
|
*
|
|
@@ -27,7 +27,7 @@ import { useRef, useEffect } from 'react';
|
|
|
27
27
|
* 使用:
|
|
28
28
|
*
|
|
29
29
|
* ```ts
|
|
30
|
-
* import { useInputIsComposing } from '
|
|
30
|
+
* import { useInputIsComposing } from 'enr';
|
|
31
31
|
*
|
|
32
32
|
* ...
|
|
33
33
|
* const inputRef = useRef<HTMLInputElement>(null);
|
|
@@ -12,7 +12,7 @@ import { createImageBySrc, isNoneBackGroundColor, extractUrl } from './tools.js'
|
|
|
12
12
|
* @copyright 2026 ©️ MrMudBean
|
|
13
13
|
* @since 2026-01-22 14:17
|
|
14
14
|
* @version 2.0.0-alpha.0
|
|
15
|
-
* @lastModified 2026-02-
|
|
15
|
+
* @lastModified 2026-02-05 17:41
|
|
16
16
|
*/
|
|
17
17
|
/**
|
|
18
18
|
* ## 构建背景
|
|
@@ -37,8 +37,7 @@ class BuildBackground {
|
|
|
37
37
|
* ## 默认加载的首个背景色
|
|
38
38
|
*/
|
|
39
39
|
get defaultColor() {
|
|
40
|
-
return this.elementMeta.isDark
|
|
41
|
-
// return '#00000000';
|
|
40
|
+
return this.options.loadingBackgroundColor[Number(this.elementMeta.isDark)];
|
|
42
41
|
}
|
|
43
42
|
/**
|
|
44
43
|
* ## 最后使用
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { debounce, getRandomInt } from 'a-js-tools';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @packageDocumentation
|
|
5
4
|
* @module @enr/class-event-action
|
|
6
5
|
* @file class-event-action.ts
|
|
7
6
|
* @description 交互事件
|
|
@@ -10,7 +9,7 @@ import { debounce, getRandomInt } from 'a-js-tools';
|
|
|
10
9
|
* @copyright 2026 ©️ MrMudBean
|
|
11
10
|
* @since 2026-01-23 01:23
|
|
12
11
|
* @version 2.0.0-alpha.0
|
|
13
|
-
* @lastModified 2026-02-
|
|
12
|
+
* @lastModified 2026-02-04 06:46
|
|
14
13
|
*/
|
|
15
14
|
/**
|
|
16
15
|
*
|
|
@@ -134,8 +133,8 @@ class EventAction {
|
|
|
134
133
|
}
|
|
135
134
|
/**
|
|
136
135
|
* 触发滴落效果
|
|
137
|
-
* @param x
|
|
138
|
-
* @param y
|
|
136
|
+
* @param x 横坐标
|
|
137
|
+
* @param y 纵坐标
|
|
139
138
|
* @param radius
|
|
140
139
|
* @param strength
|
|
141
140
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isBoolean, isUndefined } from 'a-type-of-js';
|
|
1
|
+
import { isBoolean, isUndefined, isArray, isString } from 'a-type-of-js';
|
|
2
2
|
import { defaultData } from './data-default.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -11,7 +11,7 @@ import { defaultData } from './data-default.js';
|
|
|
11
11
|
* @copyright 2026 ©️ MrMudBean
|
|
12
12
|
* @since 2026-01-22 02:40
|
|
13
13
|
* @version 2.0.0-alpha.0
|
|
14
|
-
* @lastModified 2026-02-
|
|
14
|
+
* @lastModified 2026-02-05 19:20
|
|
15
15
|
*/
|
|
16
16
|
/**
|
|
17
17
|
* ## 传入参数
|
|
@@ -34,6 +34,8 @@ class RippleParam {
|
|
|
34
34
|
firstDrawProgressStep = 12;
|
|
35
35
|
/** canvas 的显隐 */
|
|
36
36
|
visible = false;
|
|
37
|
+
/** 初始化设定值,该值由用户设置,但不可修改 */
|
|
38
|
+
loadingBackgroundColor;
|
|
37
39
|
// ++++++++++++++++++++++ 配置数据 《〈《〈《〈《 ++++++++++++++++++++++
|
|
38
40
|
// ++++++++++++++++++++++ 》〉》〉》〉》 用户控制变量 ++++++++++++++++++++++
|
|
39
41
|
// 这些变量通过 Ripple 类的 set 方法设定
|
|
@@ -183,6 +185,7 @@ class RippleParam {
|
|
|
183
185
|
this.running = Boolean(options.playingState ?? true);
|
|
184
186
|
this.crossOrigin = options.crossOrigin;
|
|
185
187
|
this.darkMode = options.darkMode;
|
|
188
|
+
this.loadingBackgroundColor = this.getLoadingBg(options.loadingBackgroundColor);
|
|
186
189
|
}
|
|
187
190
|
/**
|
|
188
191
|
* ## 切换最后一次执行的状态
|
|
@@ -190,6 +193,26 @@ class RippleParam {
|
|
|
190
193
|
toggleLastRunningState() {
|
|
191
194
|
this._lastRunningState = !this._lastRunningState;
|
|
192
195
|
}
|
|
196
|
+
/**
|
|
197
|
+
* ## 获取初始化背景值
|
|
198
|
+
* @param _v 初始化的值
|
|
199
|
+
*/
|
|
200
|
+
getLoadingBg(_v) {
|
|
201
|
+
if (isArray(_v)) {
|
|
202
|
+
const len = _v.length;
|
|
203
|
+
if (len === 1) {
|
|
204
|
+
const color = _v[0];
|
|
205
|
+
return [color, color];
|
|
206
|
+
}
|
|
207
|
+
else if (len === 2) {
|
|
208
|
+
return [..._v];
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
else if (isString(_v)) {
|
|
212
|
+
return [_v, _v];
|
|
213
|
+
}
|
|
214
|
+
return ['#00000000', '#00000000'];
|
|
215
|
+
}
|
|
193
216
|
}
|
|
194
217
|
|
|
195
218
|
export { RippleParam };
|
|
@@ -19,7 +19,7 @@ import { defaultData } from './data-default.js';
|
|
|
19
19
|
* @copyright 2026 ©️ MrMudBean
|
|
20
20
|
* @since 2026-01-22 03:03
|
|
21
21
|
* @version 2.0.0-alpha.0
|
|
22
|
-
* @lastModified 2026-02-
|
|
22
|
+
* @lastModified 2026-02-05 19:24
|
|
23
23
|
*
|
|
24
24
|
*/
|
|
25
25
|
/**
|
|
@@ -206,6 +206,10 @@ class Ripples {
|
|
|
206
206
|
* @param value
|
|
207
207
|
*/
|
|
208
208
|
set(property, value) {
|
|
209
|
+
// 该属性不允许被重新赋值
|
|
210
|
+
if (property === 'loadingBackgroundColor') {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
209
213
|
this.options[property] = value;
|
|
210
214
|
// 数仓更新
|
|
211
215
|
this.state.dispatch({
|
|
@@ -213,6 +217,13 @@ class Ripples {
|
|
|
213
217
|
payload: value,
|
|
214
218
|
});
|
|
215
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* 获取某一个参数的当前值
|
|
222
|
+
* @param property 要获取的键
|
|
223
|
+
*/
|
|
224
|
+
get(property) {
|
|
225
|
+
return this.options[property];
|
|
226
|
+
}
|
|
216
227
|
reducer = (state, action) => {
|
|
217
228
|
switch (action.type) {
|
|
218
229
|
case 'sizeChange':
|
|
@@ -10,7 +10,7 @@ import { isNull, isZero } from 'a-type-of-js';
|
|
|
10
10
|
* @copyright 2026 ©️ MrMudBean
|
|
11
11
|
* @since 2026-01-22 02:44
|
|
12
12
|
* @version 2.0.0-alpha.0
|
|
13
|
-
* @lastModified 2026-02-
|
|
13
|
+
* @lastModified 2026-02-04 06:51
|
|
14
14
|
*/
|
|
15
15
|
/**
|
|
16
16
|
* ## webGl
|
|
@@ -27,7 +27,10 @@ class RippleGl {
|
|
|
27
27
|
* 该值在 init 中进行初始化
|
|
28
28
|
*/
|
|
29
29
|
quad = null;
|
|
30
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* ## [着色器](https://developer.mozilla.org/zh-CN/docs/Web/API/WebGLProgram)
|
|
32
|
+
*
|
|
33
|
+
* 该值于初始化着色器时初始化 */
|
|
31
34
|
dropProgram;
|
|
32
35
|
/** 更新流 */
|
|
33
36
|
updateProgram;
|
|
@@ -244,6 +247,11 @@ class RippleGl {
|
|
|
244
247
|
const { gl } = this;
|
|
245
248
|
this.dropProgram = this.createProgram(this.vertexShader, this.dropProgramFragmentSource);
|
|
246
249
|
const updateProgram = (this.updateProgram = this.createProgram(this.vertexShader, this.updateProgramFragmentSource));
|
|
250
|
+
/**
|
|
251
|
+
* ### [指定了 uniform 变量的值](https://developer.mozilla.org/zh-CN/docs/Web/API/WebGLRenderingContext/uniform)
|
|
252
|
+
*
|
|
253
|
+
*
|
|
254
|
+
*/
|
|
247
255
|
gl.uniform2fv(updateProgram.locations.delta, this.textureDelta);
|
|
248
256
|
this.renderProgram = this.createProgram(this.renderVertexSource, this.renderProgramFragmentSource);
|
|
249
257
|
gl.uniform2fv(this.renderProgram.locations.delta, this.textureDelta);
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @copyright 2026 ©️ MrMudBean
|
|
9
9
|
* @since 2026-01-22 11:55
|
|
10
10
|
* @version 2.0.0-alpha.0
|
|
11
|
-
* @lastModified 2026-
|
|
11
|
+
* @lastModified 2026-02-05 17:22
|
|
12
12
|
*/
|
|
13
13
|
/**
|
|
14
14
|
* ## 默认值
|
|
@@ -25,8 +25,10 @@ const defaultData = {
|
|
|
25
25
|
raindropsTimeInterval: 3600,
|
|
26
26
|
idleFluctuations: true,
|
|
27
27
|
darkMode: undefined,
|
|
28
|
+
loadingBackgroundColor: ['#00000000', '#00000000'],
|
|
28
29
|
};
|
|
29
30
|
/** 冷冻执行 */
|
|
30
31
|
Object.freeze(defaultData);
|
|
32
|
+
const defaultDataKey = Object.keys(defaultData);
|
|
31
33
|
|
|
32
|
-
export { defaultData };
|
|
34
|
+
export { defaultData, defaultDataKey };
|
|
@@ -13,7 +13,7 @@ import { Ripples } from './class-ripple.js';
|
|
|
13
13
|
* @copyright 2026 ©️ MrMudBean
|
|
14
14
|
* @since 2025-06-20 01:37
|
|
15
15
|
* @version 2.0.0-alpha.0
|
|
16
|
-
* @lastModified 2026-02-
|
|
16
|
+
* @lastModified 2026-02-04 08:19
|
|
17
17
|
*/
|
|
18
18
|
/**
|
|
19
19
|
*
|
|
@@ -30,7 +30,7 @@ import { Ripples } from './class-ripple.js';
|
|
|
30
30
|
* 下面是在 <BackgroundRipple> 中使用
|
|
31
31
|
*
|
|
32
32
|
* ```ts
|
|
33
|
-
* import { useRipples } from '
|
|
33
|
+
* import { useRipples } from 'enr';
|
|
34
34
|
*
|
|
35
35
|
* export function BackgroundRipple(props: BackgroundRipplesProps) {
|
|
36
36
|
*
|
|
@@ -10,7 +10,7 @@ import { useRef, useEffect } from 'react';
|
|
|
10
10
|
* @copyright 2026 ©️ MrMudBean
|
|
11
11
|
* @since 2025-01-07 11:20
|
|
12
12
|
* @version 2.0.0-alpha.0
|
|
13
|
-
* @lastModified 2026-
|
|
13
|
+
* @lastModified 2026-02-04 08:19
|
|
14
14
|
*/
|
|
15
15
|
/**
|
|
16
16
|
*
|
|
@@ -25,7 +25,7 @@ import { useRef, useEffect } from 'react';
|
|
|
25
25
|
* 使用:
|
|
26
26
|
*
|
|
27
27
|
* ```ts
|
|
28
|
-
* // import { useTimeId } from '
|
|
28
|
+
* // import { useTimeId } from 'enr';
|
|
29
29
|
* ...
|
|
30
30
|
* const timeoutId = useTimeId();
|
|
31
31
|
*
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
import type { Ripples } from '../../customHooks/useRipples/class-ripple';
|
|
1
3
|
import type { JSXComponent } from '../type';
|
|
4
|
+
import type { BackgroundRipplesProps } from './types';
|
|
2
5
|
/** 内容组件 */
|
|
3
6
|
export declare const Content: JSXComponent;
|
|
7
|
+
export declare const ComponentContent: ({ option, ripplesRef, canvas, ...props }: BackgroundRipplesProps & {
|
|
8
|
+
ripplesRef: RefObject<Ripples | null>;
|
|
9
|
+
canvas: RefObject<HTMLCanvasElement | null>;
|
|
10
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @packageDocumentation
|
|
3
2
|
* @module @enr/LazyRippleEle
|
|
4
3
|
* @file LazyRippleEle.tsx
|
|
5
4
|
* @description 涟漪
|
|
@@ -8,7 +7,7 @@
|
|
|
8
7
|
* @copyright 2026 ©️ MrMudBean
|
|
9
8
|
* @since 2024-12-12 12:11
|
|
10
9
|
* @version 2.0.0-alpha.0
|
|
11
|
-
* @lastModified 2026-02-
|
|
10
|
+
* @lastModified 2026-02-04 08:18
|
|
12
11
|
*/
|
|
13
12
|
import type { BackgroundRipplesProps } from './types';
|
|
14
13
|
/**
|
|
@@ -30,15 +29,15 @@ import type { BackgroundRipplesProps } from './types';
|
|
|
30
29
|
* 使用:
|
|
31
30
|
*
|
|
32
31
|
* ```ts
|
|
33
|
-
* import {
|
|
32
|
+
* import { LazyBackgroundRipple } from 'enr/LazyBackgroundRipple';
|
|
34
33
|
* // 也可以全量导入
|
|
35
|
-
* // import {
|
|
34
|
+
* // import { LazyBackgroundRipple } from 'enr';
|
|
36
35
|
* ...
|
|
37
36
|
* const animationFrameId = useAnimationFrame();
|
|
38
37
|
*
|
|
39
|
-
* return <
|
|
38
|
+
* return <LazyBackgroundRipple>
|
|
40
39
|
* ...
|
|
41
|
-
* </
|
|
40
|
+
* </LazyBackgroundRipple>
|
|
42
41
|
* ```
|
|
43
42
|
*
|
|
44
43
|
*/
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @copyright 2026 ©️ MrMudBean
|
|
8
8
|
* @since 2024-12-12 12:18
|
|
9
9
|
* @version 2.0.0-alpha.0
|
|
10
|
-
* @lastModified 2026-02-
|
|
10
|
+
* @lastModified 2026-02-04 08:18
|
|
11
11
|
*/
|
|
12
12
|
import type { BackgroundRipplesProps } from './types';
|
|
13
13
|
/**
|
|
@@ -27,9 +27,9 @@ import type { BackgroundRipplesProps } from './types';
|
|
|
27
27
|
* 使用:
|
|
28
28
|
*
|
|
29
29
|
* ```ts
|
|
30
|
-
* import { BackgroundRipple } from '
|
|
30
|
+
* import { BackgroundRipple } from 'enr/';
|
|
31
31
|
* // 也可以全量导入
|
|
32
|
-
* // import { BackgroundRipple } from '
|
|
32
|
+
* // import { BackgroundRipple } from 'enr';
|
|
33
33
|
* ...
|
|
34
34
|
* const animationFrameId = useAnimationFrame();
|
|
35
35
|
*
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @enr/imperative-handle
|
|
3
|
+
* @file imperative-handle.ts
|
|
4
|
+
* @description 公共的命令句柄
|
|
5
|
+
* @author Mr.MudBean <Mr.MudBean@outlook.com>
|
|
6
|
+
* @license MIT
|
|
7
|
+
* @copyright 2026 ©️ Mr.MudBean
|
|
8
|
+
* @since 2026-02-04 06:52
|
|
9
|
+
* @version 2.0.1
|
|
10
|
+
* @lastModified 2026-02-04 07:57
|
|
11
|
+
*/
|
|
12
|
+
import type { RefObject } from 'react';
|
|
13
|
+
import type { Ripples } from '../../customHooks/useRipples/class-ripple';
|
|
14
|
+
import type { RippleEle } from './types';
|
|
15
|
+
/**
|
|
16
|
+
* ## 通过函数构建公共的命令句柄
|
|
17
|
+
* @param ripplesRef
|
|
18
|
+
*/
|
|
19
|
+
export declare function createImperativeHandle(ripplesRef: RefObject<Ripples | null>): () => RippleEle;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @copyright 2026 ©️ Mr.MudBean
|
|
8
8
|
* @since 2026-02-02 16:55
|
|
9
9
|
* @version 2.0.0-alpha.4
|
|
10
|
-
* @lastModified 2026-02-
|
|
10
|
+
* @lastModified 2026-02-04 06:42
|
|
11
11
|
*/
|
|
12
12
|
import type { RipplesOptions } from '../../customHooks/useRipples/types';
|
|
13
13
|
import type { PropsWithTagNameCustomRef } from '../type';
|
|
@@ -65,4 +65,9 @@ export type RippleEle = {
|
|
|
65
65
|
pause(): void;
|
|
66
66
|
/** 设置属性 */
|
|
67
67
|
set(options?: RipplesOptions): void;
|
|
68
|
+
/** 水滴落效果 */
|
|
69
|
+
drop(x: number, y: number, options?: {
|
|
70
|
+
radius: number;
|
|
71
|
+
strength: number;
|
|
72
|
+
}): void;
|
|
68
73
|
};
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @copyright 2026 ©️ MrMudBean
|
|
8
8
|
* @since 2025-01-07 11:23
|
|
9
9
|
* @version 2.0.0-alpha.0
|
|
10
|
-
* @lastModified 2026-02-
|
|
10
|
+
* @lastModified 2026-02-04 08:18
|
|
11
11
|
*/
|
|
12
12
|
/** 使用动画结果 */
|
|
13
13
|
export interface UseAnimationFrameResult {
|
|
@@ -56,7 +56,7 @@ export type AnimationFrameOption = boolean | {
|
|
|
56
56
|
* 使用:
|
|
57
57
|
*
|
|
58
58
|
* ```ts
|
|
59
|
-
* // import { useAnimationFrame } from '
|
|
59
|
+
* // import { useAnimationFrame } from 'enr';
|
|
60
60
|
* ...
|
|
61
61
|
*
|
|
62
62
|
* export function Home () {
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @copyright 2026 ©️ MrMudBean
|
|
8
8
|
* @since 2025-01-07 11:23
|
|
9
9
|
* @version 2.0.0-alpha.0
|
|
10
|
-
* @lastModified 2026-
|
|
10
|
+
* @lastModified 2026-02-04 08:19
|
|
11
11
|
*/
|
|
12
12
|
import type { RefObject } from 'react';
|
|
13
13
|
/**
|
|
@@ -25,7 +25,7 @@ import type { RefObject } from 'react';
|
|
|
25
25
|
* 使用:
|
|
26
26
|
*
|
|
27
27
|
* ```ts
|
|
28
|
-
* import { useInputIsComposing } from '
|
|
28
|
+
* import { useInputIsComposing } from 'enr';
|
|
29
29
|
*
|
|
30
30
|
* ...
|
|
31
31
|
* const inputRef = useRef<HTMLInputElement>(null);
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @copyright 2026 ©️ MrMudBean
|
|
9
9
|
* @since 2026-01-22 14:17
|
|
10
10
|
* @version 2.0.0-alpha.0
|
|
11
|
-
* @lastModified 2026-02-
|
|
11
|
+
* @lastModified 2026-02-05 17:41
|
|
12
12
|
*/
|
|
13
13
|
import type { ElementMeta } from './class-html-element-meta';
|
|
14
14
|
import type { RippleParam } from './class-param';
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @packageDocumentation
|
|
3
2
|
* @module @enr/class-event-action
|
|
4
3
|
* @file class-event-action.ts
|
|
5
4
|
* @description 交互事件
|
|
@@ -8,7 +7,7 @@
|
|
|
8
7
|
* @copyright 2026 ©️ MrMudBean
|
|
9
8
|
* @since 2026-01-23 01:23
|
|
10
9
|
* @version 2.0.0-alpha.0
|
|
11
|
-
* @lastModified 2026-02-
|
|
10
|
+
* @lastModified 2026-02-04 06:46
|
|
12
11
|
*/
|
|
13
12
|
import type { BuildBackground } from './class-build-background';
|
|
14
13
|
import type { ElementEnvironment } from './class-element-environment';
|
|
@@ -63,8 +62,8 @@ export declare class EventAction {
|
|
|
63
62
|
reloadBackground(): void;
|
|
64
63
|
/**
|
|
65
64
|
* 触发滴落效果
|
|
66
|
-
* @param x
|
|
67
|
-
* @param y
|
|
65
|
+
* @param x 横坐标
|
|
66
|
+
* @param y 纵坐标
|
|
68
67
|
* @param radius
|
|
69
68
|
* @param strength
|
|
70
69
|
*/
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @copyright 2026 ©️ MrMudBean
|
|
9
9
|
* @since 2026-01-22 02:40
|
|
10
10
|
* @version 2.0.0-alpha.0
|
|
11
|
-
* @lastModified 2026-02-
|
|
11
|
+
* @lastModified 2026-02-05 19:20
|
|
12
12
|
*/
|
|
13
13
|
import type { ImageCrossOrigin, RippleImgUrl, RipplesOptions } from './types';
|
|
14
14
|
/**
|
|
@@ -28,6 +28,8 @@ export declare class RippleParam {
|
|
|
28
28
|
readonly firstDrawProgressStep = 12;
|
|
29
29
|
/** canvas 的显隐 */
|
|
30
30
|
visible: boolean;
|
|
31
|
+
/** 初始化设定值,该值由用户设置,但不可修改 */
|
|
32
|
+
readonly loadingBackgroundColor: [string, string];
|
|
31
33
|
/** 倍级触发光标事件(值) */
|
|
32
34
|
private _accelerating;
|
|
33
35
|
/** 倍级触发光标事件 */
|
|
@@ -112,4 +114,9 @@ export declare class RippleParam {
|
|
|
112
114
|
* ## 切换最后一次执行的状态
|
|
113
115
|
*/
|
|
114
116
|
toggleLastRunningState(): void;
|
|
117
|
+
/**
|
|
118
|
+
* ## 获取初始化背景值
|
|
119
|
+
* @param _v 初始化的值
|
|
120
|
+
*/
|
|
121
|
+
private getLoadingBg;
|
|
115
122
|
}
|