plain-design 1.0.0-beta.118 → 1.0.0-beta.119

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plain-design",
3
- "version": "1.0.0-beta.118",
3
+ "version": "1.0.0-beta.119",
4
4
  "description": "",
5
5
  "main": "dist/plain-design.min.js",
6
6
  "module": "dist/plain-design.commonjs.min.js",
@@ -40,7 +40,7 @@
40
40
  "react-transition-group": "4.4.5"
41
41
  },
42
42
  "devDependencies": {
43
- "@peryl/react-compose": "0.0.215",
43
+ "@peryl/react-compose": "0.0.219",
44
44
  "@babel/plugin-proposal-optional-chaining": "7.21.0",
45
45
  "@babel/plugin-transform-class-properties": "7.23.3",
46
46
  "@babel/preset-env": "7.23.7",
@@ -1,12 +1,13 @@
1
1
  import {iCascadePanelItemPublicParam} from "../cascade-panel.utils";
2
- import {computed, Fragment, getComponentCls} from "@peryl/react-compose";
2
+ import {Fragment, getComponentCls, globalComputed} from "@peryl/react-compose";
3
+ import {createEffects} from "@peryl/utils/createEffects";
3
4
  import './cascade-flat-panel.scss';
4
- import Scroll from "../../Scroll";
5
- import Icon from "../../Icon";
5
+ import {Scroll} from "../../Scroll";
6
+ import {Icon} from "../../Icon";
6
7
  import {CascadeFlatPanelNode} from "./CascadeFlatPanelNode";
7
- import Loading from "../../Loading";
8
- import Empty from "../../Empty";
9
- import i18n from "../../i18n";
8
+ import {Loading} from "../../Loading";
9
+ import {Empty} from "../../Empty";
10
+ import {i18n} from "../../i18n";
10
11
 
11
12
  export function createCascadeFlatRender(
12
13
  {
@@ -17,7 +18,9 @@ export function createCascadeFlatRender(
17
18
  }: iCascadePanelItemPublicParam
18
19
  ) {
19
20
 
20
- const headers = computed(() => {
21
+ const { effects } = createEffects();
22
+
23
+ const headers = globalComputed(() => {
21
24
  const renderContent = <div className="cascade-panel-flat-header">
22
25
  {panels.value.slice(1).map((panel, index) => (
23
26
  <Fragment key={index}>
@@ -33,8 +36,9 @@ export function createCascadeFlatRender(
33
36
  </div>;
34
37
  return () => renderContent;
35
38
  });
39
+ effects.push(() => headers.effect.stop());
36
40
 
37
- const content = computed(() => {
41
+ const content = globalComputed(() => {
38
42
  const { parent, treeNodes } = panels.value[panels.value.length - 1];
39
43
  const renderContent = <div className="cascade-panel-flat-body">
40
44
  {(() => {
@@ -68,6 +72,7 @@ export function createCascadeFlatRender(
68
72
  </div>;
69
73
  return () => renderContent;
70
74
  });
75
+ effects.push(() => content.effect.stop());
71
76
 
72
77
  const render = () => (
73
78
  <div className={getComponentCls('cascade-panel-flat')}>
@@ -78,5 +83,5 @@ export function createCascadeFlatRender(
78
83
  </div>
79
84
  );
80
85
 
81
- return { render };
86
+ return { render, effects };
82
87
  }
@@ -1,4 +1,4 @@
1
- import {computed, designComponent, getComponentCls, onMounted, useClasses, useStyles} from "@peryl/react-compose";
1
+ import {computed, designComponent, getComponentCls, onBeforeUnmount, onMounted, useClasses, useStyles} from "@peryl/react-compose";
2
2
  import {TreeEmitOptions, TreePropsOptions} from "../TreeCore/createTreeProps";
3
3
  import {createTreeCore} from "../TreeCore/createTreeCore";
4
4
  import {iTreeNode} from "../TreeCore/createTreeNode";
@@ -11,6 +11,7 @@ import {createCascadeListRender} from "./list/createCascadeListRender";
11
11
  import {createCascadeFlatRender} from "./flat/createCascadeFlatRender";
12
12
  import {LoadingMask} from "../LoadingMask";
13
13
  import {StyleProps, useStyle} from "../../uses/useStyle";
14
+ import {iEffects} from "@peryl/utils/createEffects";
14
15
 
15
16
  export const CascadePanel = designComponent({
16
17
  name: 'cascade-panel',
@@ -155,15 +156,32 @@ export const CascadePanel = designComponent({
155
156
  * @author 韦胜健
156
157
  * @date 2022.12.12 21:18
157
158
  */
159
+ let contentCache: undefined | { type: typeof eCascadePanelType.TYPE, effects: iEffects, render: () => any } = undefined;
158
160
  const content = computed(() => {
161
+
159
162
  const param = { props, handleClickNode: handler.handleClickNode, panels, treeCore };
160
- return props.panelType === eCascadePanelType.cascade ? createCascadeListRender(param) : createCascadeFlatRender(param);
163
+ const { panelType } = props;
164
+
165
+ if (!!contentCache && contentCache.type === panelType) {return { render: contentCache.render };}
166
+
167
+ contentCache?.effects.clear();
168
+ contentCache = {
169
+ type: panelType,
170
+ ...panelType === eCascadePanelType.cascade ? createCascadeListRender(param) : createCascadeFlatRender(param)
171
+ };
172
+ return { render: contentCache.render };
161
173
  });
162
174
 
163
175
  onMounted(() => {
164
176
  props.panelType === 'cascade' && !props.multiple && treeCore.methods.expand(Object.keys(treeCore.state.checkedMap));
165
177
  treeCore.hooks.onMounted.exec(undefined);
166
178
  });
179
+ onBeforeUnmount(() => {
180
+ if (!!contentCache) {
181
+ contentCache.effects.clear();
182
+ contentCache = undefined;
183
+ }
184
+ });
167
185
 
168
186
  return {
169
187
  refer: {
@@ -1,6 +1,7 @@
1
1
  import {unit} from "@peryl/utils/unit";
2
2
  import {iCascadePanelItemPublicParam} from "../cascade-panel.utils";
3
3
  import {CascadeListPanelItem} from "./CascadeListPanelItem";
4
+ import {createEffects} from "@peryl/utils/createEffects";
4
5
 
5
6
  export function createCascadeListRender(
6
7
  {
@@ -10,6 +11,9 @@ export function createCascadeListRender(
10
11
  }: iCascadePanelItemPublicParam
11
12
  ) {
12
13
 
14
+ /*没用,仅用于适配类型*/
15
+ const { effects } = createEffects();
16
+
13
17
  const render = () => (
14
18
  panels.value
15
19
  .map(({ parent, treeNodes }) => (
@@ -23,5 +27,5 @@ export function createCascadeListRender(
23
27
  ))
24
28
  );
25
29
 
26
- return { render };
30
+ return { render, effects };
27
31
  }
@@ -16,7 +16,7 @@ import {createPopupEditor} from "../usePopupEditor";
16
16
  */
17
17
  export function createDateRenderMultiple({ props, emit, formatString, getPublicPopperAttrs, editComputed, getInheritPublicDateAttrs, slots, displayPattern, today, hooks, maxmin, }: tDateCompositionPublicParams) {
18
18
  const { effects, effectComputed } = createEffectsOfReaction();
19
- const { refs, onRef } = useRefs({ input: Input });
19
+ const { refs, onRef } = useRefs({ input: Input }, { effects });
20
20
  const { getReference, renderReference } = useRenderReference();
21
21
 
22
22
  const format = effectComputed((): null | PDate[] => !model.value ? [] : model.value.map?.(i => plainDate(i, formatString.value)));
@@ -16,7 +16,7 @@ import {createPopupEditor} from "../usePopupEditor";
16
16
  export function createDateRenderSingle({ props, emit, slots, hooks, formatString, getPublicPopperAttrs, editComputed, getInheritPublicDateAttrs, displayPattern, today, maxmin }: tDateCompositionPublicParams) {
17
17
 
18
18
  const { effects, effectComputed } = createEffectsOfReaction();
19
- const { refs, onRef } = useRefs({ input: Input });
19
+ const { refs, onRef } = useRefs({ input: Input }, { effects });
20
20
 
21
21
  const format = effectComputed((): null | PDate => !model.value ? null : plainDate(model.value as string, formatString.value));
22
22
 
@@ -29,7 +29,7 @@ export function useRangeDateRender(
29
29
  getEndPopper?: () => iPopupEditor,
30
30
  }) {
31
31
  const { effects, effectComputed } = createEffectsOfReaction();
32
- const { refs, onRef } = useRefs({ input: Input, start: iHTMLInputElement, end: iHTMLInputElement, });
32
+ const { refs, onRef } = useRefs({ input: Input, start: iHTMLInputElement, end: iHTMLInputElement, }, { effects });
33
33
  const reference = useRenderReference();
34
34
  const startModel = useModel(() => props.start, emit.onUpdateStart, { onChange: () => delay().then(() => state.input.start = format.value.start?.getDisplay()) }, effects);
35
35
  const endModel = useModel(() => props.end, emit.onUpdateEnd, { onChange: () => delay().then(() => state.input.end = format.value.end?.getDisplay()) }, effects);
@@ -19,7 +19,7 @@ export const useMultipleInput = createEffectiveHandler(({ hooks, props, model, r
19
19
 
20
20
  const text = useModel(() => props.multipleText as any, emit.onUpdateMultipleText, undefined, effects);
21
21
 
22
- const { refs: innerRefs, onRef: innerOnRef } = useRefs({ container: iHTMLElement });
22
+ const { refs: innerRefs, onRef: innerOnRef } = useRefs({ container: iHTMLElement }, { effects });
23
23
 
24
24
  const handler = {
25
25
  onRef: (input: typeof AutoWidthInput.use.class | null) => hooks.onRefInput.exec(input?.refs.input || null),
@@ -33,7 +33,7 @@ export function createObjectRenderMultiple(
33
33
  }
34
34
  }, effects);
35
35
 
36
- const { refs, onRef } = useRefs({ select: Select });
36
+ const { refs, onRef } = useRefs({ select: Select }, { effects });
37
37
 
38
38
  const publicHandler = {
39
39
  /**
@@ -16,7 +16,7 @@ export function createObjectRenderSingle(
16
16
  ) {
17
17
  const { effects, effectComputed, effectWatch } = createEffectsOfReaction();
18
18
 
19
- const { refs, onRef } = useRefs({ select: Select });
19
+ const { refs, onRef } = useRefs({ select: Select }, { effects });
20
20
 
21
21
  const publicHandler = {
22
22
  /**
@@ -102,7 +102,7 @@ export function createPublicSelectRender(
102
102
  input: Input,
103
103
  /*用来上移下移hover元素的时候滚动到目标位置,如果用的是虚拟列表,则不会有这个对象,暂定虚拟列表不支持滚动*/
104
104
  scroll: Scroll,
105
- });
105
+ }, { effects });
106
106
 
107
107
  const reference = useRenderReference();
108
108
 
@@ -12,7 +12,7 @@ import {createPopupEditor} from "../usePopupEditor";
12
12
  export function createSingleTimeRender({ emit, props, hooks, displayPattern, today, maxmin, editComputed, slots, getPublicPopperAttrs, getInheritPublicTimeAttrs, formatString }: tTimeCompositionParams) {
13
13
 
14
14
  const { effects, effectComputed } = createEffectsOfReaction();
15
- const { refs, onRef } = useRefs({ input: Input });
15
+ const { refs, onRef } = useRefs({ input: Input }, { effects });
16
16
  const reference = useRenderReference();
17
17
  const model = useModel(() => props.modelValue, emit.onUpdateModelValue, { onChange: () => delay().then(() => state.input = format.value?.getDisplay()) }, effects);
18
18
  const format = effectComputed((): null | PDate => !model.value ? null : plainDate(model.value, formatString.value));
@@ -11,7 +11,7 @@ import {useRenderReference} from "../../uses/useRenderReference";
11
11
 
12
12
  export function useRangeTimeRender({ props, emit, onBlur, slots, displayPattern, today, onInputClear, maxmin, formatString }: tTimeCompositionParams & { onBlur: () => void, onInputClear?: (range: TimeRangePanelType) => void, }) {
13
13
  const { effects, effectComputed } = createEffectsOfReaction();
14
- const { refs, onRef } = useRefs({ input: Input, start: iHTMLInputElement, end: iHTMLInputElement, });
14
+ const { refs, onRef } = useRefs({ input: Input, start: iHTMLInputElement, end: iHTMLInputElement, }, { effects });
15
15
  const reference = useRenderReference();
16
16
  const startModel = useModel(() => props.start, emit.onUpdateStart, { onChange: () => delay().then(() => state.input.start = format.value.start?.getDisplay()) }, effects);
17
17
  const endModel = useModel(() => props.end, emit.onUpdateEnd, { onChange: () => delay().then(() => state.input.end = format.value.end?.getDisplay()) }, effects);
@@ -48,7 +48,7 @@ export const useStyle = useFunctionWrapper('style', (ctx, option: UseStyleOption
48
48
 
49
49
  const styleComputed = computed(() => {
50
50
  if (ctx.isDestroyed) {return {} as UseStyleProvideData;}
51
-
51
+
52
52
  const defaultData = Object.assign({ shape: applicationConfiguration.value.default.shape, size: applicationConfiguration.value.default.size, inputMode: applicationConfiguration.value.default.inputMode }, option);
53
53
 
54
54
  const { shape, size, status, inputMode } = ctx.props;
@@ -72,8 +72,6 @@ export const useStyle = useFunctionWrapper('style', (ctx, option: UseStyleOption
72
72
 
73
73
  onBeforeUnmount(() => {
74
74
  setTimeout(() => {
75
- (styleComputed.value as any).ctx = null;
76
- (styleComputed.value as any).parent = null;
77
75
  styleComputed.effect.stop();
78
76
  });
79
77
  });