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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plain-design",
3
- "version": "1.0.0-beta.130",
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.72",
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
- state.handleClick = throttle(state.handleClickInner, val, { trailing: false });
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
  );
@@ -63,6 +63,7 @@ export function createSingleCascadeRender(
63
63
  state.inputValue = null;
64
64
  },
65
65
  onBlur: (e: FocusEvent) => {
66
+ if (!event.emit) {return;}
66
67
  event.emit.onBlur(e);
67
68
  props.inputAttrs?.onBlur?.(e);
68
69
  state.isFocus = false;
@@ -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
- enterHandler.value = throttle(innerHandler, val as number, { trailing: true });
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(() => effects.clear());
79
+ onBeforeUnmount(() => {
80
+ effects.clear();
81
+ throttleEffects.clear();
82
+ });
76
83
  }
@@ -354,6 +354,7 @@ export const Scroll = designComponent({
354
354
  popper.event.off.onOpen(handler.popperOpen)
355
355
  popper.event.off.onShow(handler.popperShow)
356
356
  }*/
357
+ handler.windowResize.dispose();
357
358
  });
358
359
 
359
360
  watch(() => props.refreshState, methods.refresh);
@@ -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 = throttle(
17
- (e: MouseEvent) => {
18
- const el = e.target as HTMLElement;
19
- const list = hooks.onGetPopupElements.exec([]);
20
- list.forEach(i => {
21
- const { option, popupEl } = i();
22
- const { reference } = option;
23
- if (!popupEl) {return;}
24
- if (reference.contains(el)) {
25
- /*点击了reference*/
26
- return;
27
- }
28
- if (popupEl.contains(el)) {
29
- /*点击了popup*/
30
- return;
31
- }
32
- hooks.onTriggerOutsideClick.exec({ e, option });
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
  });