plain-design 1.0.0-beta.130 → 1.0.0-beta.131
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/plain-design.commonjs.min.js +2 -2
- package/dist/plain-design.min.js +2 -2
- package/dist/report.html +2 -2
- package/package.json +2 -2
- package/src/packages/components/Button/index.tsx +9 -2
- package/src/packages/components/Cascade/createSingleCascadeRender.tsx +1 -0
- package/src/packages/components/Dialog/index.tsx +6 -2
- package/src/packages/components/Input/uses/useInputEnterHandler.tsx +9 -2
- package/src/packages/components/Scroll/index.tsx +1 -0
- package/src/packages/components/Table/plc/useTablePlc.tsx +2 -1
- package/src/packages/components/usePopup/trigger/useManagerTrigger.clickOutside.tsx +18 -23
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "plain-design",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.131",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/plain-design.min.js",
|
|
6
6
|
"module": "dist/plain-design.commonjs.min.js",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@peryl/icon": "0.0.8",
|
|
34
|
-
"@peryl/utils": "^0.1.
|
|
34
|
+
"@peryl/utils": "^0.1.73",
|
|
35
35
|
"@types/color": "3.0.6",
|
|
36
36
|
"@types/react-transition-group": "4.4.10",
|
|
37
37
|
"color": "4.2.3",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import './button.scss';
|
|
2
|
-
import {computed, designComponent, getComponentCls, iHTMLButtonElement, mergeAttrs, PropType, reactive, StyleProperties, useClasses, useNumber, useRefs, useStyles, watch} from "@peryl/react-compose";
|
|
2
|
+
import {computed, designComponent, getComponentCls, iHTMLButtonElement, mergeAttrs, onBeforeUnmount, PropType, reactive, StyleProperties, useClasses, useNumber, useRefs, useStyles, watch} from "@peryl/react-compose";
|
|
3
3
|
import {EditProps, useEdit} from "../../uses/useEdit";
|
|
4
4
|
import {StyleProps, ThemeMode, ThemeStatus, useStyle} from "../../uses/useStyle";
|
|
5
5
|
import {throttle} from "@peryl/utils/throttle";
|
|
@@ -10,6 +10,7 @@ import {Loading} from "../Loading";
|
|
|
10
10
|
import {ButtonGroup} from "../ButtonGroup";
|
|
11
11
|
import {AutoLoadingObserver} from "../AutoLoadingObserver";
|
|
12
12
|
import {useCollapseStyles} from "../../uses/useCollapseStyles";
|
|
13
|
+
import {createEffects} from "@peryl/utils/createEffects";
|
|
13
14
|
|
|
14
15
|
export const Button = designComponent({
|
|
15
16
|
name: '-button',
|
|
@@ -82,16 +83,22 @@ export const Button = designComponent({
|
|
|
82
83
|
},
|
|
83
84
|
});
|
|
84
85
|
|
|
86
|
+
const { effects: throttleClickEffects } = createEffects();
|
|
87
|
+
onBeforeUnmount(() => {throttleClickEffects.clear();});
|
|
88
|
+
|
|
85
89
|
watch(
|
|
86
90
|
() => props.throttleClick,
|
|
87
91
|
(val) => {
|
|
92
|
+
throttleClickEffects.clear();
|
|
88
93
|
if (!val) {
|
|
89
94
|
return state.handleClick = state.handleClickInner;
|
|
90
95
|
}
|
|
91
96
|
if (val === true) {
|
|
92
97
|
val = 1000;
|
|
93
98
|
}
|
|
94
|
-
|
|
99
|
+
const throttleClickHandler = throttle(state.handleClickInner, val, { trailing: false });
|
|
100
|
+
throttleClickEffects.push(() => throttleClickHandler.dispose());
|
|
101
|
+
state.handleClick = throttleClickHandler;
|
|
95
102
|
},
|
|
96
103
|
{ immediate: true }
|
|
97
104
|
);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {computed, createHooks, designComponent, getComponentCls, iMouseEvent, mergeAttrs, nextIndex, nextTick, Portal, PropType, reactive, useClasses, useModel, useRefs, useStyles, watch} from "@peryl/react-compose";
|
|
1
|
+
import {computed, createHooks, designComponent, getComponentCls, iMouseEvent, mergeAttrs, nextIndex, nextTick, onBeforeUnmount, Portal, PropType, reactive, useClasses, useModel, useRefs, useStyles, watch} from "@peryl/react-compose";
|
|
2
2
|
import {DialogAlign, DialogAnimations, DialogCloseType, DialogPositions} from "./utils/dialog.utils";
|
|
3
3
|
import {APPLICATION_SERVICE_CONTAINER_CLASS} from "../Application/utils/application.utils";
|
|
4
4
|
import {unit} from "@peryl/utils/unit";
|
|
@@ -81,7 +81,6 @@ export const Dialog = designComponent({
|
|
|
81
81
|
const { styleComputed } = useStyle();
|
|
82
82
|
|
|
83
83
|
const { emit } = event;
|
|
84
|
-
|
|
85
84
|
const model = useModel(() => props.modelValue, emit.onUpdateModelValue);
|
|
86
85
|
const open = useModel(() => props.open, emit.onUpdateOpen);
|
|
87
86
|
|
|
@@ -320,6 +319,11 @@ export const Dialog = designComponent({
|
|
|
320
319
|
}, 300, { trailing: false }),
|
|
321
320
|
};
|
|
322
321
|
|
|
322
|
+
onBeforeUnmount(() => {
|
|
323
|
+
methods.confirm.dispose();
|
|
324
|
+
methods.cancel.dispose();
|
|
325
|
+
});
|
|
326
|
+
|
|
323
327
|
watch(() => model.value, async show => {
|
|
324
328
|
await nextTick();
|
|
325
329
|
await (show ? methods.show() : methods.hide());
|
|
@@ -40,15 +40,19 @@ export function useInputEnterHandler(
|
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
const enterHandler = reactive({ value: doNothing, });
|
|
43
|
+
const { effects: throttleEffects } = createEffects();
|
|
43
44
|
|
|
44
45
|
watch(() => props.throttleEnter, (val) => {
|
|
46
|
+
throttleEffects.clear();
|
|
45
47
|
if (!val) {
|
|
46
48
|
enterHandler.value = innerHandler;
|
|
47
49
|
}
|
|
48
50
|
if (val === true) {
|
|
49
51
|
val = 1000;
|
|
50
52
|
}
|
|
51
|
-
|
|
53
|
+
const throttleHandler = throttle(innerHandler, val as number, { trailing: true });
|
|
54
|
+
throttleEffects.push(() => throttleHandler.dispose());
|
|
55
|
+
enterHandler.value = throttleHandler;
|
|
52
56
|
}, { immediate: true });
|
|
53
57
|
|
|
54
58
|
const handler = {
|
|
@@ -72,5 +76,8 @@ export function useInputEnterHandler(
|
|
|
72
76
|
effects.push(() => {input.removeEventListener('keydown', handler.onKeydown);});
|
|
73
77
|
});
|
|
74
78
|
|
|
75
|
-
onBeforeUnmount(() =>
|
|
79
|
+
onBeforeUnmount(() => {
|
|
80
|
+
effects.clear();
|
|
81
|
+
throttleEffects.clear();
|
|
82
|
+
});
|
|
76
83
|
}
|
|
@@ -47,7 +47,7 @@ export function useTablePlc(
|
|
|
47
47
|
getPlcTypeArr: null as null | (() => tPlcType[]),
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
-
onBeforeUnmount(()=>{state.getTableEl = null})
|
|
50
|
+
onBeforeUnmount(() => {state.getTableEl = null;});
|
|
51
51
|
|
|
52
52
|
hooks.onPlcTypes.use(list => {state.getPlcTypeArr = () => list;});
|
|
53
53
|
|
|
@@ -109,6 +109,7 @@ export function useTablePlc(
|
|
|
109
109
|
const virtualFlatPlcList = (() => {
|
|
110
110
|
const state = reactive({ scrollLeft: 0 });
|
|
111
111
|
const setScrollLeft = throttle((scrollLeft: number) => {state.scrollLeft !== scrollLeft && (state.scrollLeft = scrollLeft);}, 50);
|
|
112
|
+
onBeforeUnmount(() => {setScrollLeft.dispose();});
|
|
112
113
|
hooks.onScroll.use((e) => {setScrollLeft(e.target.scrollLeft);});
|
|
113
114
|
return computed((): tPlc[] => {
|
|
114
115
|
if (!plcData.value) {return [];}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import {iPopupManager} from "../utils/popup.utils";
|
|
2
2
|
import {onBeforeUnmount, onMounted} from "@peryl/react-compose";
|
|
3
|
-
import {throttle} from "@peryl/utils/throttle";
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* 处理点击页面任何元素的时候检查是否触发了某个popup的click outside动作
|
|
@@ -13,28 +12,24 @@ export function useManagerTriggerClickOutside({ hooks }: iPopupManager) {
|
|
|
13
12
|
* @author 韦胜健
|
|
14
13
|
* @date 2023/5/16 16:23
|
|
15
14
|
*/
|
|
16
|
-
const onClick =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
},
|
|
35
|
-
100,
|
|
36
|
-
{ trailing: false }
|
|
37
|
-
);
|
|
15
|
+
const onClick = (e: MouseEvent) => {
|
|
16
|
+
const el = e.target as HTMLElement;
|
|
17
|
+
const list = hooks.onGetPopupElements.exec([]);
|
|
18
|
+
list.forEach(i => {
|
|
19
|
+
const { option, popupEl } = i();
|
|
20
|
+
const { reference } = option;
|
|
21
|
+
if (!popupEl) {return;}
|
|
22
|
+
if (reference.contains(el)) {
|
|
23
|
+
/*点击了reference*/
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
if (popupEl.contains(el)) {
|
|
27
|
+
/*点击了popup*/
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
hooks.onTriggerOutsideClick.exec({ e, option });
|
|
31
|
+
});
|
|
32
|
+
}
|
|
38
33
|
onMounted(() => {
|
|
39
34
|
window.addEventListener('mouseup', onClick, true);
|
|
40
35
|
});
|