plain-design 1.0.0-beta.107 → 1.0.0-beta.108

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. package/dist/plain-design.commonjs.min.js +2 -2
  2. package/dist/plain-design.min.css +1 -1
  3. package/dist/plain-design.min.js +2 -2
  4. package/dist/report.html +2 -2
  5. package/package.json +3 -3
  6. package/src/packages/components/AddressCascade/createAddressCascade.multiple.tsx +5 -6
  7. package/src/packages/components/AddressCascade/createAddressCascade.single.tsx +6 -7
  8. package/src/packages/components/Badge/badge.scss +4 -0
  9. package/src/packages/components/Cascade/createMultipleCascadeRender.tsx +3 -4
  10. package/src/packages/components/Cascade/createSingleCascadeRender.tsx +4 -5
  11. package/src/packages/components/DatePicker/createDateRender.multiple.tsx +5 -5
  12. package/src/packages/components/DatePicker/createDateRender.single.tsx +6 -5
  13. package/src/packages/components/DatePicker/index.tsx +2 -0
  14. package/src/packages/components/DatePicker/useRangeDateRender.tsx +6 -6
  15. package/src/packages/components/Input/useMultipleInput.tsx +4 -3
  16. package/src/packages/components/Input/useSuggestionInput.tsx +3 -4
  17. package/src/packages/components/Input/useTextareaInput.tsx +3 -3
  18. package/src/packages/components/Input/uses/useInputEnterHandler.tsx +10 -6
  19. package/src/packages/components/Object/createObjectRender.multiple.tsx +7 -7
  20. package/src/packages/components/Object/createObjectRender.single.tsx +10 -10
  21. package/src/packages/components/PageThemeUtils/index.tsx +2 -2
  22. package/src/packages/components/Select/createMultipleSelectRender.tsx +10 -6
  23. package/src/packages/components/Select/createPublicSelectRender.tsx +8 -4
  24. package/src/packages/components/Select/createSingleSelectRender.tsx +11 -7
  25. package/src/packages/components/Slider/useSlider.range.tsx +12 -9
  26. package/src/packages/components/Slider/useSlider.single.tsx +7 -8
  27. package/src/packages/components/Table/standard/PlcCheck/PlcCheck.hooks.tsx +2 -2
  28. package/src/packages/components/Table/standard/PlcCheck/PlcCheck.multiple.tsx +4 -5
  29. package/src/packages/components/Table/standard/PlcCheck/PlcCheck.single.tsx +3 -4
  30. package/src/packages/components/TimePicker/createSingleTimeRender.tsx +4 -5
  31. package/src/packages/components/TimePicker/useRangeTimeRender.tsx +6 -6
  32. package/src/packages/components/usePopup/PopupItem.tsx +3 -3
  33. package/src/packages/components/usePopup/trigger/useReferenceTrigger.tsx +51 -45
  34. package/src/packages/components/usePopupEditor/index.tsx +6 -9
  35. package/src/packages/components/useTooltip/index.tsx +5 -6
  36. package/src/packages/uses/useDragHorizontalScroll.ts +4 -5
  37. package/src/packages/uses/useFocusHandler.ts +25 -12
  38. package/src/packages/uses/useMultipleModel.tsx +3 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "plain-design",
3
- "version": "1.0.0-beta.107",
3
+ "version": "1.0.0-beta.108",
4
4
  "description": "",
5
5
  "main": "dist/plain-design.min.js",
6
6
  "module": "dist/plain-design.commonjs.min.js",
@@ -19,7 +19,7 @@
19
19
  "author": "",
20
20
  "license": "ISC",
21
21
  "peerDependencies": {
22
- "@peryl/react-compose": "0.0.197",
22
+ "@peryl/react-compose": "0.0.201",
23
23
  "exceljs": "^4.2.1",
24
24
  "file-saver": "^2.0.5",
25
25
  "react": "^18.0.1",
@@ -45,7 +45,7 @@
45
45
  "@babel/preset-env": "7.23.7",
46
46
  "@babel/preset-react": "7.23.3",
47
47
  "@babel/preset-typescript": "7.23.3",
48
- "@peryl/react-compose": "0.0.197",
48
+ "@peryl/react-compose": "0.0.201",
49
49
  "@types/classnames": "^2.2.11",
50
50
  "@types/react": "18.2.4",
51
51
  "@types/react-dom": "18.2.4",
@@ -1,16 +1,15 @@
1
1
  import {iAddressCascadeCompositionParam} from "./address-cascade.utils";
2
- import {createEffects} from "@peryl/utils/createEffects";
3
2
  import Cascade from "../Cascade";
4
3
  import {useMultipleModel} from "../../uses/useMultipleModel";
5
- import {reactive, watch} from "@peryl/react-compose";
4
+ import {createEffectsOfReaction, reactive} from "@peryl/react-compose";
6
5
  import {iAddressLazyMeta} from "../$address/address.utils";
7
6
 
8
7
  export function createAddressCascadeMultiple(
9
8
  { props, event: { emit }, service, hooks, filterData }: iAddressCascadeCompositionParam,
10
9
  ) {
11
- const model = useMultipleModel(() => props.modelValue, emit.onUpdateModelValue, props);
10
+ const { effects, effectWatch } = createEffectsOfReaction();
12
11
 
13
- const { effects } = createEffects();
12
+ const model = useMultipleModel(() => props.modelValue, emit.onUpdateModelValue, props, undefined, effects);
14
13
 
15
14
  const state = reactive({
16
15
  modelMetas: [] as iAddressLazyMeta[],
@@ -23,7 +22,7 @@ export function createAddressCascadeMultiple(
23
22
  },
24
23
  };
25
24
 
26
- effects.push(watch(() => model.value as string[] | null | undefined, async (value, oldValue) => {
25
+ effectWatch(() => model.value as string[] | null | undefined, async (value, oldValue) => {
27
26
  if (!!value && !!oldValue && value.length == oldValue.length && value.every(i => oldValue.indexOf(i) > -1)) {
28
27
  return;
29
28
  }
@@ -31,7 +30,7 @@ export function createAddressCascadeMultiple(
31
30
  const newMetas = !value ? [] : await service.getAddressByCodes(value as string[]);
32
31
  if (newMetas.length === 0 && state.modelMetas.length === 0) {return;}
33
32
  state.modelMetas = newMetas;
34
- }, { immediate: true }));
33
+ }, { immediate: true });
35
34
 
36
35
  effects.push(hooks.onRender.use({
37
36
  processor: ({ list, render }) => {list.push({ render, key: '1', seq: 1 });},
@@ -1,8 +1,7 @@
1
1
  import {AddressCascadeType2map, iAddressCascadeCompositionParam} from "./address-cascade.utils";
2
- import {computed, useModel} from "@peryl/react-compose";
2
+ import {createEffectsOfReaction, useModel} from "@peryl/react-compose";
3
3
  import {iAddressSyncMeta} from "../$address/address.utils";
4
4
  import Cascade from "../Cascade";
5
- import {createEffects} from "@peryl/utils/createEffects";
6
5
 
7
6
  export function createAddressCascadeSingle(
8
7
  {
@@ -10,15 +9,15 @@ export function createAddressCascadeSingle(
10
9
  }: iAddressCascadeCompositionParam
11
10
  ) {
12
11
 
13
- const { effects } = createEffects();
12
+ const { effects, effectComputed } = createEffectsOfReaction();
14
13
 
15
14
  const model = {
16
- province: useModel(() => props.province, emit.onUpdateProvince),
17
- city: useModel(() => props.city, emit.onUpdateCity),
18
- district: useModel(() => props.district, emit.onUpdateDistrict),
15
+ province: useModel(() => props.province, emit.onUpdateProvince, undefined, effects),
16
+ city: useModel(() => props.city, emit.onUpdateCity, undefined, effects),
17
+ district: useModel(() => props.district, emit.onUpdateDistrict, undefined, effects),
19
18
  };
20
19
 
21
- const metaArray = computed((): iAddressSyncMeta[] | null => {
20
+ const metaArray = effectComputed((): iAddressSyncMeta[] | null => {
22
21
  if (!filterData.value) {
23
22
  return null;
24
23
  }
@@ -19,6 +19,10 @@
19
19
  background-color: $color-6;
20
20
  border-radius: 100px;
21
21
  color: plv(pbfc);
22
+ z-index: 2;
23
+ span {
24
+ transform: scale(0.8);
25
+ }
22
26
  }
23
27
 
24
28
  &.badge-content-top {
@@ -1,5 +1,4 @@
1
- import {createEffects} from "@peryl/utils/createEffects";
2
- import {computed, mergeAttrs, nextTick, reactive, useRefs} from "@peryl/react-compose";
1
+ import {createEffectsOfReaction, mergeAttrs, nextTick, reactive, useRefs} from "@peryl/react-compose";
3
2
  import {Tree} from "../Tree";
4
3
  import {iCascadeCompositionParam} from "./cascade.utils";
5
4
  import {Input} from "../Input";
@@ -24,7 +23,7 @@ export function createMultipleCascadeRender(
24
23
  cascadeProps,
25
24
  styleComputed,
26
25
  }: iCascadeCompositionParam) {
27
- const { effects } = createEffects();
26
+ const { effects, effectComputed } = createEffectsOfReaction();
28
27
 
29
28
  const { refs, onRef } = useRefs({
30
29
  tree: Tree,
@@ -36,7 +35,7 @@ export function createMultipleCascadeRender(
36
35
  * @author 韦胜健
37
36
  * @date 2022/10/24 20:27
38
37
  */
39
- const label = computed(() => {
38
+ const label = effectComputed(() => {
40
39
  if (model.value == null || model.value.length === 0) {return null;}
41
40
  return (model.value as PlainObject[]).map(i => utils.getLabel.value(i));
42
41
  });
@@ -1,5 +1,4 @@
1
- import {createEffects} from "@peryl/utils/createEffects";
2
- import {computed, mergeAttrs, nextTick, reactive, useRefs} from "@peryl/react-compose";
1
+ import {createEffectsOfReaction, mergeAttrs, nextTick, reactive, useRefs} from "@peryl/react-compose";
3
2
  import {Tree} from "../Tree";
4
3
  import {iCascadeCompositionParam} from "./cascade.utils";
5
4
  import {Input} from "../Input";
@@ -30,12 +29,14 @@ export function createSingleCascadeRender(
30
29
  styleComputed,
31
30
  }: iCascadeCompositionParam) {
32
31
 
32
+ const { effects, effectComputed } = createEffectsOfReaction();
33
+
33
34
  /**
34
35
  * input输入框显示值
35
36
  * @author 韦胜健
36
37
  * @date 2022/10/24 20:29
37
38
  */
38
- const label = computed(() => {
39
+ const label = effectComputed(() => {
39
40
  if (model.value == null) {return null;}
40
41
  if (props.multiple) {return; }
41
42
  return Array.isArray(model.value) ? (model.value as PlainObject[]).map(i => utils.getLabel.value(i)).join('/') : utils.getLabel.value(model.value as PlainObject);
@@ -48,8 +49,6 @@ export function createSingleCascadeRender(
48
49
  inputValue: label.value as null | string,
49
50
  });
50
51
 
51
- const { effects } = createEffects();
52
-
53
52
  const { refs, onRef } = useRefs({
54
53
  tree: Tree,
55
54
  plcTree: PlcTree,
@@ -1,4 +1,4 @@
1
- import {computed, getComponentCls, reactive, useRefs} from "@peryl/react-compose";
1
+ import {createEffectsOfReaction, getComponentCls, reactive, useRefs} from "@peryl/react-compose";
2
2
  import Input from "../Input";
3
3
  import {delay} from "@peryl/utils/delay";
4
4
  import {PDate, plainDate} from "../../utils/plainDate";
@@ -7,7 +7,6 @@ import {limitDatetimeTimePlainData} from "../TimePicker/time.utils";
7
7
  import {tDateCompositionPublicParams} from "./date.utils";
8
8
  import {useRenderReference} from "../../uses/useRenderReference";
9
9
  import {useMultipleModel} from "../../uses/useMultipleModel";
10
- import {createEffects} from "@peryl/utils/createEffects";
11
10
  import {createPopupEditor} from "../usePopupEditor";
12
11
 
13
12
  /**
@@ -16,13 +15,14 @@ import {createPopupEditor} from "../usePopupEditor";
16
15
  * @date 2022.7.4 14:05
17
16
  */
18
17
  export function createDateRenderMultiple({ props, emit, formatString, getPublicPopperAttrs, editComputed, getInheritPublicDateAttrs, slots, displayPattern, today, hooks, maxmin, }: tDateCompositionPublicParams) {
19
- const { effects } = createEffects();
18
+ const { effects, effectComputed } = createEffectsOfReaction();
20
19
  const { refs, onRef } = useRefs({ input: Input });
21
20
  const { getReference, renderReference } = useRenderReference();
22
21
 
22
+ const format = effectComputed((): null | PDate[] => !model.value ? [] : model.value.map?.(i => plainDate(i, formatString.value)));
23
+
23
24
  const getFormatValue = () => format.value?.map(i => i.getDisplay());
24
- const model = useMultipleModel(() => (props.modelValue as string[] | undefined), emit.onUpdateModelValue, props, { onChange: () => delay().then(() => state.input = getFormatValue()) });
25
- const format = computed((): null | PDate[] => !model.value ? [] : model.value.map?.(i => plainDate(i, formatString.value)));
25
+ const model = useMultipleModel(() => (props.modelValue as string[] | undefined), emit.onUpdateModelValue, props, { onChange: () => delay().then(() => state.input = getFormatValue()) }, effects);
26
26
  const state = reactive({ input: getFormatValue() });
27
27
 
28
28
  const popper = createPopupEditor({
@@ -3,7 +3,7 @@
3
3
  * @author 韦胜健
4
4
  * @date 2022.7.4 14:04
5
5
  */
6
- import {computed, getComponentCls, reactive, useModel, useRefs} from "@peryl/react-compose";
6
+ import {createEffectsOfReaction, getComponentCls, reactive, useModel, useRefs} from "@peryl/react-compose";
7
7
  import {tDateCompositionPublicParams} from "./date.utils";
8
8
  import Input from "../Input";
9
9
  import {delay} from "@peryl/utils/delay";
@@ -11,15 +11,16 @@ import {PDate, plainDate} from "../../utils/plainDate";
11
11
  import {DatePanel} from "./panel/DatePanel";
12
12
  import {limitDatetimeTimePlainData} from "../TimePicker/time.utils";
13
13
  import {useRenderReference} from "../../uses/useRenderReference";
14
- import {createEffects} from "@peryl/utils/createEffects";
15
14
  import {createPopupEditor} from "../usePopupEditor";
16
15
 
17
16
  export function createDateRenderSingle({ props, emit, slots, hooks, formatString, getPublicPopperAttrs, editComputed, getInheritPublicDateAttrs, displayPattern, today, maxmin }: tDateCompositionPublicParams) {
18
17
 
19
- const { effects } = createEffects();
18
+ const { effects, effectComputed } = createEffectsOfReaction();
20
19
  const { refs, onRef } = useRefs({ input: Input });
21
- const model = useModel(() => props.modelValue, emit.onUpdateModelValue, { onChange: () => delay().then(() => state.input = format.value?.getDisplay()) });
22
- const format = computed((): null | PDate => !model.value ? null : plainDate(model.value as string, formatString.value));
20
+
21
+ const format = effectComputed((): null | PDate => !model.value ? null : plainDate(model.value as string, formatString.value));
22
+
23
+ const model = useModel(() => props.modelValue, emit.onUpdateModelValue, { onChange: () => delay().then(() => state.input = format.value?.getDisplay()) }, effects);
23
24
  const state = reactive({ input: format.value?.getDisplay() });
24
25
  const reference = useRenderReference();
25
26
 
@@ -18,10 +18,12 @@ import {createDateRenderSingle} from "./createDateRender.single";
18
18
  import {plainDate} from "../../utils/plainDate";
19
19
  import {createPopupAttrsGetter} from "../usePopup/utils/createPopperAttrsGetter";
20
20
  import {useParentPopupId} from "../usePopup/utils/popup.utils";
21
+ import Input from "../Input";
21
22
 
22
23
  export const DatePicker = designComponent({
23
24
  name: '-date-picker',
24
25
  props: DatePropsOptions,
26
+ inheritPropsType: Input,
25
27
  expose: {
26
28
  DatePanel,
27
29
  DatePanelDate,
@@ -1,13 +1,12 @@
1
1
  import {eDateEmitRangeType, tDateCompositionPublicParams} from "./date.utils";
2
2
  import {TimeRangePanelType} from "../TimePicker/panel/TimeRangePanel";
3
- import {computed, getComponentCls, iHTMLInputElement, nextTick, reactive, useModel, useRefs} from "@peryl/react-compose";
3
+ import {createEffectsOfReaction, getComponentCls, iHTMLInputElement, nextTick, reactive, useModel, useRefs} from "@peryl/react-compose";
4
4
  import Input from "../Input";
5
5
  import {delay} from "@peryl/utils/delay";
6
6
  import {useFocusHandler} from "../../uses/useFocusHandler";
7
7
  import {PDate, plainDate} from "../../utils/plainDate";
8
8
  import {limitDatetimeTimePlainData} from "../TimePicker/time.utils";
9
9
  import {useRenderReference} from "../../uses/useRenderReference";
10
- import {createEffects} from "@peryl/utils/createEffects";
11
10
  import {iPopupEditor} from "../usePopupEditor";
12
11
 
13
12
  export function useRangeDateRender(
@@ -29,11 +28,11 @@ export function useRangeDateRender(
29
28
  getStartPopper?: () => iPopupEditor,
30
29
  getEndPopper?: () => iPopupEditor,
31
30
  }) {
32
- const { effects } = createEffects();
31
+ const { effects, effectComputed } = createEffectsOfReaction();
33
32
  const { refs, onRef } = useRefs({ input: Input, start: iHTMLInputElement, end: iHTMLInputElement, });
34
33
  const reference = useRenderReference();
35
- const startModel = useModel(() => props.start, emit.onUpdateStart, { onChange: () => delay().then(() => state.input.start = format.value.start?.getDisplay()) });
36
- const endModel = useModel(() => props.end, emit.onUpdateEnd, { onChange: () => delay().then(() => state.input.end = format.value.end?.getDisplay()) });
34
+ const startModel = useModel(() => props.start, emit.onUpdateStart, { onChange: () => delay().then(() => state.input.start = format.value.start?.getDisplay()) }, effects);
35
+ const endModel = useModel(() => props.end, emit.onUpdateEnd, { onChange: () => delay().then(() => state.input.end = format.value.end?.getDisplay()) }, effects);
37
36
 
38
37
  const { isFocus } = useFocusHandler({
39
38
  getEls: () => [refs.start, refs.end],
@@ -60,9 +59,10 @@ export function useRangeDateRender(
60
59
  onBlur();
61
60
  },
62
61
  onFocus: emit.onFocus,
62
+ effects,
63
63
  });
64
64
 
65
- const format = computed((): { start: null | PDate, end: null | PDate } => ({
65
+ const format = effectComputed((): { start: null | PDate, end: null | PDate } => ({
66
66
  start: !startModel.value ? null : plainDate(startModel.value, formatString.value),
67
67
  end: !endModel.value ? null : plainDate(endModel.value, formatString.value),
68
68
  }));
@@ -2,7 +2,7 @@ import {AutoWidthInput} from "../AutoWidthInput";
2
2
  import {iInputCompositionData, inputScrollEnd} from "./input.utils";
3
3
  import Icon from "../Icon";
4
4
  import {iHTMLElement, useClasses, useModel, useRefs} from "@peryl/react-compose";
5
- import {getKeyNameByKeyboardEvent, eKeyboardKeys} from "@peryl/utils/keyboard";
5
+ import {eKeyboardKeys, getKeyNameByKeyboardEvent} from "@peryl/utils/keyboard";
6
6
  import {delay} from "@peryl/utils/delay";
7
7
  import {createEffectiveHandler} from "../../utils/createEffectiveHandler";
8
8
  import {createEffects} from "@peryl/utils/createEffects";
@@ -15,9 +15,10 @@ import {useDragHorizontalScroll} from "../../uses/useDragHorizontalScroll";
15
15
  */
16
16
  export const useMultipleInput = createEffectiveHandler(({ hooks, props, model, refs, editComputed, emit, styleComputed }: iInputCompositionData) => {
17
17
 
18
- const text = useModel(() => props.multipleText as any, emit.onUpdateMultipleText);
19
18
  const { effects } = createEffects();
20
19
 
20
+ const text = useModel(() => props.multipleText as any, emit.onUpdateMultipleText, undefined, effects);
21
+
21
22
  const { refs: innerRefs, onRef: innerOnRef } = useRefs({ container: iHTMLElement });
22
23
 
23
24
  const handler = {
@@ -92,7 +93,7 @@ export const useMultipleInput = createEffectiveHandler(({ hooks, props, model, r
92
93
  {
93
94
  'input-tag-container-wrap': props.tagsWrap,
94
95
  }
95
- ]);
96
+ ], effects);
96
97
 
97
98
  effects.push(hooks.onRenderDefault.use(() => (
98
99
  <span className={classes.value} onMouseDown={handler.onMousedownContainer} ref={innerOnRef.container} data-input-el="container">
@@ -1,5 +1,5 @@
1
1
  import {iInputCompositionData, inputScrollEnd} from "./input.utils";
2
- import {computed, iKeyboardEvent, reactive, useRefs} from "@peryl/react-compose";
2
+ import {createEffectsOfReaction, iKeyboardEvent, reactive, useRefs} from "@peryl/react-compose";
3
3
  import {SelectPanel} from "../Select/SelectPanel";
4
4
  import {SelectOption} from "../SelectOption";
5
5
  import {Scroll} from "../Scroll";
@@ -7,13 +7,12 @@ import {createSelectHover, iSelectOptionProps} from "../Select/select.utils";
7
7
  import {decodeSelectRenderNode} from '../Select/decodeSelectRenderNode';
8
8
  import {delay} from '@peryl/utils/delay';
9
9
  import {handleKeyboard} from "@peryl/utils/keyboard";
10
- import {createEffects} from "@peryl/utils/createEffects";
11
10
  import {createPopupEditor} from "../usePopupEditor";
12
11
 
13
12
  export function useSuggestionInput({ props, hooks, editComputed, styleComputed, refs, model, parentPopupId }: iInputCompositionData) {
14
13
 
15
14
  /*记录副作用函数*/
16
- const { effects } = createEffects();
15
+ const { effects, effectComputed } = createEffectsOfReaction();
17
16
 
18
17
  const { refs: innerRefs, onRef: innerOnRef } = useRefs({
19
18
  /*需要scroll引用,当有scroll的时候,每次关闭都需要滚动回顶部*/
@@ -30,7 +29,7 @@ export function useSuggestionInput({ props, hooks, editComputed, styleComputed,
30
29
  let matchOptionPropsList: iSelectOptionProps[] = [];
31
30
 
32
31
  /*自动补全的数据*/
33
- const suggestion = computed((): string[] | undefined => typeof props.suggestion === "function" ? props.suggestion(state.searchText) : props.suggestion!);
32
+ const suggestion = effectComputed((): string[] | undefined => typeof props.suggestion === "function" ? props.suggestion(state.searchText) : props.suggestion!);
34
33
 
35
34
  /*管理select panel的hover状态*/
36
35
  const hover = createSelectHover({
@@ -37,8 +37,8 @@ export function useTextareaInput(data: iInputCompositionData) {
37
37
  'input-box input-fill input-textarea-container',
38
38
  {
39
39
  'input-textarea-has-height': !!state.height || !!props.height || !!props.maxHeight,
40
- }
41
- ]);
40
+ },
41
+ ], effects);
42
42
 
43
43
  const takeoverStyles = useStyles(style => {
44
44
  if (!!props.height || !!state.height) {
@@ -50,7 +50,7 @@ export function useTextareaInput(data: iInputCompositionData) {
50
50
  if (!!props.maxHeight) {
51
51
  style.maxHeight = unit(props.maxHeight);
52
52
  }
53
- });
53
+ }, effects);
54
54
 
55
55
  effects.push(useTextareaResize({ ...data, onResize: (val) => state.height = val }));
56
56
 
@@ -1,8 +1,9 @@
1
- import {reactive, watch} from "@peryl/react-compose";
1
+ import {onBeforeUnmount, reactive, watch} from "@peryl/react-compose";
2
2
  import {doNothing} from "@peryl/utils/doNothing";
3
3
  import {throttle} from "@peryl/utils/throttle";
4
4
  import {iInputCompositionData} from "../input.utils";
5
5
  import {eKeyboardKeys, getKeyNameByKeyboardEvent} from "@peryl/utils/keyboard";
6
+ import {createEffects} from "@peryl/utils/createEffects";
6
7
 
7
8
  /**
8
9
  * 自动监听input ref动作
@@ -51,7 +52,6 @@ export function useInputEnterHandler(
51
52
  }, { immediate: true });
52
53
 
53
54
  const handler = {
54
- input: null as null | HTMLInputElement,
55
55
  onKeydown: (e: KeyboardEvent) => {
56
56
  emit.onKeydown(e);
57
57
  switch (getKeyNameByKeyboardEvent(e)) {
@@ -63,10 +63,14 @@ export function useInputEnterHandler(
63
63
  },
64
64
  };
65
65
 
66
+ const { effects } = createEffects();
67
+
66
68
  hooks.onRefInput.use(input => {
67
- if (!!input) {input.removeEventListener('keydown', handler.onKeydown);}
68
- handler.input = input;
69
- if (!handler.input) {return;}
70
- handler.input.addEventListener('keydown', handler.onKeydown);
69
+ effects.clear();
70
+ if (!input) {return;}
71
+ input.addEventListener('keydown', handler.onKeydown);
72
+ effects.push(() => {input.removeEventListener('keydown', handler.onKeydown);});
71
73
  });
74
+
75
+ onBeforeUnmount(() => effects.clear());
72
76
  }
@@ -1,7 +1,6 @@
1
1
  import {iObjectCompositionParam, iObjectSelectOption} from "./object.utils";
2
- import {createEffects} from "@peryl/utils/createEffects";
3
2
  import {Select} from "../Select";
4
- import {computed, reactive, useModel, useRefs} from "@peryl/react-compose";
3
+ import {createEffectsOfReaction, reactive, useModel, useRefs} from "@peryl/react-compose";
5
4
  import {PlainObject} from "@peryl/utils/event";
6
5
  import {delay} from "@peryl/utils/delay";
7
6
  import {SelectOption} from "../SelectOption";
@@ -16,7 +15,7 @@ import i18n from "../i18n";
16
15
  export function createObjectRenderMultiple(
17
16
  { props, hooks, classes, inputSlots, event, object, loading, loadData, editComputed }: iObjectCompositionParam
18
17
  ) {
19
- const { effects } = createEffects();
18
+ const { effects, effectComputed } = createEffectsOfReaction();
20
19
 
21
20
  const model = useModel(() => props.modelValue as PlainObject[] | null | undefined, event.emit.onUpdateModelValue as any, {
22
21
  /**
@@ -32,7 +31,7 @@ export function createObjectRenderMultiple(
32
31
  await delay();
33
32
  selectHandler.reset();
34
33
  }
35
- });
34
+ }, effects);
36
35
 
37
36
  const { refs, onRef } = useRefs({ select: Select });
38
37
 
@@ -110,7 +109,7 @@ export function createObjectRenderMultiple(
110
109
  publicHandler.onSelect(modelValue);
111
110
  },
112
111
  };
113
- const inputAttrs = computed(() => {
112
+ const inputAttrs = effectComputed(() => {
114
113
  /*当前选中数据的显示值*/
115
114
  const label = props.modelValue;
116
115
  /*空值占位符,没有focus的时候就显示真实的placeholder,否则显示当前匹配option的label*/
@@ -224,10 +223,10 @@ export function createObjectRenderMultiple(
224
223
  },
225
224
  };
226
225
  /*监听popper的部分参数*/
227
- const popperAttrs = computed(() => ({ ...handler, }));
226
+ const popperAttrs = effectComputed(() => ({ ...handler, }));
228
227
 
229
228
  /*给select传递的属性*/
230
- const selectAttrs = computed(() => ({
229
+ const selectAttrs = effectComputed(() => ({
231
230
  ...checkHandler,
232
231
  modelValue: state.value,
233
232
  onUpdateModelValue: onSelectChange,
@@ -243,6 +242,7 @@ export function createObjectRenderMultiple(
243
242
  /*没有关键词的时候,提示输入关键词,已经有关键词并且没有选项的情况下提示placeholder*/
244
243
  noDataLabel: !inputHandler.state.multipleText && state.option == null ? (props.searchPlaceholder || i18n.$it('table.pleaseEnterSearchKey').d('请输入搜索关键词')) : undefined
245
244
  }));
245
+
246
246
  return { state, popperAttrs, onSelectChange, selectAttrs, reset };
247
247
 
248
248
  })();
@@ -1,7 +1,6 @@
1
1
  import {iObjectCompositionParam, iObjectSelectOption} from "./object.utils";
2
- import {createEffects} from "@peryl/utils/createEffects";
3
2
  import {Select} from "../Select";
4
- import {computed, reactive, useRefs, watch} from "@peryl/react-compose";
3
+ import {createEffectsOfReaction, reactive, useRefs} from "@peryl/react-compose";
5
4
  import {convertRowToSelected, convertSelectedToRow} from "../$object/object.conver";
6
5
  import {PlainObject} from "@peryl/utils/event";
7
6
  import {SelectOption} from "../SelectOption";
@@ -15,7 +14,7 @@ import i18n from "../i18n";
15
14
  export function createObjectRenderSingle(
16
15
  { props, event, hooks, classes, inputSlots, object, loading, loadData, editComputed }: iObjectCompositionParam
17
16
  ) {
18
- const { effects } = createEffects();
17
+ const { effects, effectComputed, effectWatch } = createEffectsOfReaction();
19
18
 
20
19
  const { refs, onRef } = useRefs({ select: Select });
21
20
 
@@ -82,7 +81,7 @@ export function createObjectRenderSingle(
82
81
  hooks.onInputChange.exec(val);
83
82
  },
84
83
  };
85
- const inputAttrs = computed(() => {
84
+ const inputAttrs = effectComputed(() => {
86
85
  /*当前选中数据的显示值*/
87
86
  const label = props.modelValue;
88
87
  /*空值占位符,没有focus的时候就显示真实的placeholder,否则显示当前匹配option的label*/
@@ -98,6 +97,7 @@ export function createObjectRenderSingle(
98
97
  clearHandler: publicHandler.onClear
99
98
  });
100
99
  });
100
+
101
101
  return { state, inputAttrs };
102
102
  })();
103
103
 
@@ -109,7 +109,7 @@ export function createObjectRenderSingle(
109
109
  const selectHandler = (() => {
110
110
 
111
111
  /*将row转化为selected对象,用来辅助getSelectValue实现功能*/
112
- const row2selected = computed(() => {return !props.row || !props.modelValue ? null : convertRowToSelected(props.row, props.map);});
112
+ const row2selected = effectComputed(() => {return !props.row || !props.modelValue ? null : convertRowToSelected(props.row, props.map);});
113
113
 
114
114
  /*获取当前select的modelValue以及要渲染的select options数组*/
115
115
  const getSelectValue = (): { value: any, option: null | iObjectSelectOption[] } => {
@@ -124,9 +124,7 @@ export function createObjectRenderSingle(
124
124
  const state = reactive(getSelectValue());
125
125
 
126
126
  /*当绑定值变化时,重新计算select的modelValue以及option数组*/
127
- effects.push(
128
- watch(() => props.modelValue, () => {Object.assign(state, getSelectValue());})
129
- );
127
+ effectWatch(() => props.modelValue, () => {Object.assign(state, getSelectValue());});
130
128
 
131
129
  /**
132
130
  * 根据搜索关键词加载数据
@@ -147,16 +145,17 @@ export function createObjectRenderSingle(
147
145
  onClose: () => {Object.assign(state, getSelectValue());},
148
146
  };
149
147
  /*监听popper的部分参数*/
150
- const popperAttrs = computed(() => ({
148
+ const popperAttrs = effectComputed(() => ({
151
149
  ...handler,
152
150
  }));
151
+
153
152
  /*监听select的选中选项动作*/
154
153
  const onSelectChange = (code: string | null) => {
155
154
  const selected = !code ? null : state.option?.find(i => i.val === code)?.data;
156
155
  publicHandler.onSelect(selected);
157
156
  };
158
157
  /*给select传递的属性*/
159
- const selectAttrs = computed(() => ({
158
+ const selectAttrs = effectComputed(() => ({
160
159
  onUpdateModelValue: onSelectChange,
161
160
  loading: loading.value,
162
161
  class: classes.value,
@@ -169,6 +168,7 @@ export function createObjectRenderSingle(
169
168
  /*没有关键词的时候,提示输入关键词,已经有关键词并且没有选项的情况下提示placeholder*/
170
169
  noDataLabel: !inputHandler.state.inputValue && state.option == null ? (props.searchPlaceholder || i18n.$it('table.pleaseEnterSearchKey').d('请输入搜索关键词')) : undefined
171
170
  }));
171
+
172
172
  return { state, popperAttrs, onSelectChange, selectAttrs };
173
173
  })();
174
174
 
@@ -1,4 +1,4 @@
1
- import {computed, getComponentCls, reactive} from "@peryl/react-compose";
1
+ import {getComponentCls, globalComputed, reactive} from "@peryl/react-compose";
2
2
  import {createCache} from "../../utils/createCache";
3
3
  import {InputMode, ThemeMode, ThemeShape, ThemeSize} from "../../uses/useStyle";
4
4
  import {DeepPartial} from "../../utils/type";
@@ -27,7 +27,7 @@ export const PageThemeUtils = (() => {
27
27
  zoom: zoomCache.get(),
28
28
  });
29
29
 
30
- const configuration = computed((): DeepPartial<iApplicationConfiguration> => {
30
+ const configuration = globalComputed((): DeepPartial<iApplicationConfiguration> => {
31
31
  const config: DeepPartial<iApplicationConfiguration> = {};
32
32
  if (!config.theme) {config.theme = {};}
33
33
  if (!config.theme.base) {config.theme.base = {};}
@@ -8,6 +8,7 @@ import {useMultipleModel} from "../../uses/useMultipleModel";
8
8
  import i18n from "../i18n";
9
9
  import {Checkbox} from "../Checkbox";
10
10
  import {CheckboxStatus} from "../../utils/constant";
11
+ import {createEffects} from "@peryl/utils/createEffects";
11
12
 
12
13
  export function createMultipleSelectRender(params: iSelectCompositionParams) {
13
14
 
@@ -32,7 +33,9 @@ export function createMultipleSelectRender(params: iSelectCompositionParams) {
32
33
  */
33
34
  const scrollEnd = () => {delay().then(() => inputScrollEnd(() => selector.refs.input?.refs.el));};
34
35
 
35
- const model = useMultipleModel<any[] | null | undefined>(() => props.modelValue as any, emit.onUpdateModelValue, props);
36
+ const { effects } = createEffects();
37
+
38
+ const model = useMultipleModel<any[] | null | undefined>(() => props.modelValue as any, emit.onUpdateModelValue, props, undefined, effects);
36
39
 
37
40
  const selector = createPublicSelectRender(params, {
38
41
  isActivated,
@@ -97,6 +100,7 @@ export function createMultipleSelectRender(params: iSelectCompositionParams) {
97
100
  </>
98
101
  );
99
102
  },
103
+ effects,
100
104
  });
101
105
 
102
106
  const handler = {
@@ -181,7 +185,7 @@ export function createMultipleSelectRender(params: iSelectCompositionParams) {
181
185
  * @author 韦胜健
182
186
  * @date 2022/8/16 9:16
183
187
  */
184
- selector.effects.push(hooks.renderInput.use(() => {
188
+ effects.push(hooks.renderInput.use(() => {
185
189
 
186
190
  /*每次render input的时候解析内容*/
187
191
  selector.optionListHandler.decode();
@@ -224,21 +228,21 @@ export function createMultipleSelectRender(params: iSelectCompositionParams) {
224
228
  * @author 韦胜健
225
229
  * @date 2022/8/16 9:17
226
230
  */
227
- selector.effects.push(hooks.onPopperClose.use(() => {state.multipleText = null;}));
231
+ effects.push(hooks.onPopperClose.use(() => {state.multipleText = null;}));
228
232
 
229
233
  /**
230
234
  * input多值输入文本的时候保留这个文本
231
235
  * @author 韦胜健
232
236
  * @date 2022/8/16 9:17
233
237
  */
234
- selector.effects.push(hooks.onInputTextChange.use((val) => {state.multipleText = val;}));
238
+ effects.push(hooks.onInputTextChange.use((val) => {state.multipleText = val;}));
235
239
 
236
240
  /**
237
241
  * input清空动作
238
242
  * @author 韦胜健
239
243
  * @date 2022/8/16 9:17
240
244
  */
241
- selector.effects.push(hooks.onInputClear.use(() => {state.multipleText = null;}));
245
+ effects.push(hooks.onInputClear.use(() => {state.multipleText = null;}));
242
246
 
243
- return () => selector.effects.clear();
247
+ return effects.clear;
244
248
  }