plain-design 1.0.0-beta.107 → 1.0.0-beta.109
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.css +1 -1
- package/dist/plain-design.min.js +2 -2
- package/dist/report.html +2 -2
- package/package.json +3 -3
- package/src/packages/components/AddressCascade/createAddressCascade.multiple.tsx +5 -6
- package/src/packages/components/AddressCascade/createAddressCascade.single.tsx +6 -7
- package/src/packages/components/Application/utils/application.utils.ts +2 -3
- package/src/packages/components/Badge/badge.scss +4 -0
- package/src/packages/components/Cascade/createMultipleCascadeRender.tsx +3 -4
- package/src/packages/components/Cascade/createSingleCascadeRender.tsx +4 -5
- package/src/packages/components/DatePicker/createDateRender.multiple.tsx +5 -5
- package/src/packages/components/DatePicker/createDateRender.single.tsx +6 -5
- package/src/packages/components/DatePicker/index.tsx +2 -0
- package/src/packages/components/DatePicker/useRangeDateRender.tsx +6 -6
- package/src/packages/components/Form/validate/useFormItemValidation.tsx +25 -27
- package/src/packages/components/Input/useMultipleInput.tsx +4 -3
- package/src/packages/components/Input/useSuggestionInput.tsx +3 -4
- package/src/packages/components/Input/useTextareaInput.tsx +3 -3
- package/src/packages/components/Input/uses/useInputEnterHandler.tsx +10 -6
- package/src/packages/components/Object/createObjectRender.multiple.tsx +7 -7
- package/src/packages/components/Object/createObjectRender.single.tsx +10 -10
- package/src/packages/components/PageThemeUtils/index.tsx +2 -2
- package/src/packages/components/Select/createMultipleSelectRender.tsx +10 -6
- package/src/packages/components/Select/createPublicSelectRender.tsx +8 -4
- package/src/packages/components/Select/createSingleSelectRender.tsx +11 -7
- package/src/packages/components/Slider/useSlider.range.tsx +12 -9
- package/src/packages/components/Slider/useSlider.single.tsx +7 -8
- package/src/packages/components/Table/standard/PlcCheck/PlcCheck.hooks.tsx +2 -2
- package/src/packages/components/Table/standard/PlcCheck/PlcCheck.multiple.tsx +4 -5
- package/src/packages/components/Table/standard/PlcCheck/PlcCheck.single.tsx +3 -4
- package/src/packages/components/TimePicker/createSingleTimeRender.tsx +4 -5
- package/src/packages/components/TimePicker/useRangeTimeRender.tsx +6 -6
- package/src/packages/components/usePopup/PopupItem.tsx +3 -3
- package/src/packages/components/usePopup/trigger/useReferenceTrigger.tsx +51 -45
- package/src/packages/components/usePopupEditor/index.tsx +6 -9
- package/src/packages/components/useTooltip/index.tsx +5 -6
- package/src/packages/uses/useDragHorizontalScroll.ts +4 -5
- package/src/packages/uses/useFocusHandler.ts +25 -12
- package/src/packages/uses/useMultipleModel.tsx +3 -1
@@ -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 {
|
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 } =
|
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 =
|
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 =
|
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
|
-
|
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 =
|
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 =
|
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 {
|
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 =
|
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
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
245
|
+
effects.push(hooks.onInputClear.use(() => {state.multipleText = null;}));
|
242
246
|
|
243
|
-
return
|
247
|
+
return effects.clear;
|
244
248
|
}
|
@@ -10,7 +10,7 @@ import {VirtualList} from "../VirtualList";
|
|
10
10
|
import {delay} from "@peryl/utils/delay";
|
11
11
|
import {handleKeyboard} from "@peryl/utils/keyboard";
|
12
12
|
import {useRenderReference} from "../../uses/useRenderReference";
|
13
|
-
import {
|
13
|
+
import {iEffects} from "@peryl/utils/createEffects";
|
14
14
|
import {createPopupEditor} from "../usePopupEditor";
|
15
15
|
|
16
16
|
export function createPublicSelectRender(
|
@@ -33,6 +33,7 @@ export function createPublicSelectRender(
|
|
33
33
|
defaultCurrent,
|
34
34
|
multiple,
|
35
35
|
processRenderPanel,
|
36
|
+
effects,
|
36
37
|
}: {
|
37
38
|
/**
|
38
39
|
* 判断选项是否已经选中,用来provide给option组件判断自身是否已经选中
|
@@ -88,9 +89,13 @@ export function createPublicSelectRender(
|
|
88
89
|
* @date 2022/8/16 8:40
|
89
90
|
*/
|
90
91
|
processRenderPanel?: (defaultRender: () => RenderNode) => RenderNode,
|
92
|
+
/**
|
93
|
+
* 副作用收集函数
|
94
|
+
* @author 韦胜健
|
95
|
+
* @date 2024.9.3 22:45
|
96
|
+
*/
|
97
|
+
effects: iEffects,
|
91
98
|
}) {
|
92
|
-
/*记录副作用函数*/
|
93
|
-
const { effects } = createEffects();
|
94
99
|
|
95
100
|
const { refs, onRef } = useRefs({
|
96
101
|
/*用来创建popper的reference对象*/
|
@@ -391,7 +396,6 @@ export function createPublicSelectRender(
|
|
391
396
|
};
|
392
397
|
|
393
398
|
return {
|
394
|
-
effects,
|
395
399
|
refs,
|
396
400
|
onRef,
|
397
401
|
state,
|
@@ -3,6 +3,7 @@ import {Input} from "../Input";
|
|
3
3
|
import {createPublicSelectRender} from "./createPublicSelectRender";
|
4
4
|
import {reactive, useModel} from "@peryl/react-compose";
|
5
5
|
import {delay} from "@peryl/utils/delay";
|
6
|
+
import {createEffects} from "@peryl/utils/createEffects";
|
6
7
|
|
7
8
|
/**
|
8
9
|
* 单选组合函数,支持普通单选以及虚拟列表的方式
|
@@ -18,15 +19,18 @@ export function createSingleSelectRender(params: iSelectCompositionParams) {
|
|
18
19
|
inputValue: null as null | string
|
19
20
|
});
|
20
21
|
|
22
|
+
const { effects } = createEffects();
|
23
|
+
|
21
24
|
const model = useModel(() => props.modelValue, params.emit.onUpdateModelValue, {
|
22
25
|
onChange: async () => {
|
23
26
|
await delay();
|
24
27
|
state.inputValue = selector.optionListHandler.getMatchLabel();
|
25
28
|
}
|
26
|
-
});
|
29
|
+
}, effects);
|
27
30
|
|
28
31
|
const selector = createPublicSelectRender(params, {
|
29
32
|
isActivated: props => isMatch({ option: props.val, value: model.value }),
|
33
|
+
effects,
|
30
34
|
model,
|
31
35
|
...(() => {
|
32
36
|
/**
|
@@ -69,7 +73,7 @@ export function createSingleSelectRender(params: iSelectCompositionParams) {
|
|
69
73
|
defaultCurrent: undefined,
|
70
74
|
});
|
71
75
|
|
72
|
-
|
76
|
+
effects.push(hooks.renderInput.use(() => {
|
73
77
|
|
74
78
|
selector.optionListHandler.decode();
|
75
79
|
/*显示文本*/
|
@@ -106,24 +110,24 @@ export function createSingleSelectRender(params: iSelectCompositionParams) {
|
|
106
110
|
});
|
107
111
|
}));
|
108
112
|
|
109
|
-
|
113
|
+
effects.push(hooks.onPopperClose.use(() => {
|
110
114
|
/*重置input绑定值,防止输入一半取消选择时显示不正确的文本*/
|
111
115
|
state.inputValue = selector.optionListHandler.getMatchLabel();
|
112
116
|
}));
|
113
117
|
|
114
|
-
|
118
|
+
effects.push(hooks.onPopperShow.use(() => {
|
115
119
|
state.inputValue = null;
|
116
120
|
}));
|
117
121
|
|
118
|
-
|
122
|
+
effects.push(hooks.onInputTextChange.use((val) => {
|
119
123
|
/*应用绑定值*/
|
120
124
|
state.inputValue = val;
|
121
125
|
}));
|
122
126
|
|
123
|
-
|
127
|
+
effects.push(hooks.onInputClear.use(() => {
|
124
128
|
/*点击clear的时候,应用输入绑定值*/
|
125
129
|
state.inputValue = null;
|
126
130
|
}));
|
127
131
|
|
128
|
-
return
|
132
|
+
return effects.clear;
|
129
133
|
}
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import {iSliderPublicParams} from "./slider.utils";
|
2
|
-
import {
|
3
|
-
import {computed, useModel, useStyles} from "@peryl/react-compose";
|
2
|
+
import {createEffectsOfReaction, useModel, useStyles} from "@peryl/react-compose";
|
4
3
|
import {unit} from "@peryl/utils/unit";
|
5
4
|
import {useSliderDotDraggier} from "./useSliderDotDragier";
|
6
5
|
|
@@ -14,7 +13,7 @@ export function useSliderRange(
|
|
14
13
|
utils,
|
15
14
|
}: iSliderPublicParams) {
|
16
15
|
|
17
|
-
const { effects } =
|
16
|
+
const { effects, effectComputed } = createEffectsOfReaction();
|
18
17
|
|
19
18
|
/**
|
20
19
|
* 创建指示器管理对象
|
@@ -22,14 +21,16 @@ export function useSliderRange(
|
|
22
21
|
* @date 2022.12.10 15:43
|
23
22
|
*/
|
24
23
|
function createDotManager(type: 'start' | 'end') {
|
25
|
-
const model = type === "start" ?
|
26
|
-
useModel(() => props.
|
24
|
+
const model = type === "start" ?
|
25
|
+
useModel(() => props.start, event.emit.onUpdateStart, { autoEmit: props.emitImmediate }, effects) :
|
26
|
+
useModel(() => props.end, event.emit.onUpdateEnd, { autoEmit: props.emitImmediate }, effects);
|
27
27
|
/**
|
28
28
|
* 当前指示器位置百分比
|
29
29
|
* @author 韦胜健
|
30
30
|
* @date 2022.12.10 15:44
|
31
31
|
*/
|
32
|
-
const percent =
|
32
|
+
const percent = effectComputed(() => Number(((model.value == null ? 0 : Number(model.value)) / props.total).toFixed(2)));
|
33
|
+
|
33
34
|
/**
|
34
35
|
* 指示器行内样式
|
35
36
|
* @author 韦胜健
|
@@ -51,16 +52,18 @@ export function useSliderRange(
|
|
51
52
|
} else {
|
52
53
|
styles.transform = `translateY(${length}px)`;
|
53
54
|
}
|
54
|
-
});
|
55
|
+
}, effects);
|
56
|
+
|
55
57
|
/**
|
56
58
|
* 指示器tooltip显示文本
|
57
59
|
* @author 韦胜健
|
58
60
|
* @date 2022.12.10 15:44
|
59
61
|
*/
|
60
|
-
const tooltipLabel =
|
62
|
+
const tooltipLabel = effectComputed(() => {
|
61
63
|
let ret = model.value;
|
62
64
|
return !!props.tooltipFormatter ? props.tooltipFormatter(ret || 0) : ret;
|
63
65
|
});
|
66
|
+
|
64
67
|
/**
|
65
68
|
* 指示器拖拽处理对象
|
66
69
|
* @author 韦胜健
|
@@ -117,7 +120,7 @@ export function useSliderRange(
|
|
117
120
|
styles.transform = `translateY(${start.percent.value * totalLength.value}px) scaleY(${percentValue})`;
|
118
121
|
styles.transformOrigin = props.alignEnd ? 'bottom' : 'top';
|
119
122
|
}
|
120
|
-
});
|
123
|
+
}, effects);
|
121
124
|
|
122
125
|
/**
|
123
126
|
* 拖拽的时候一直显示tooltip
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import {iSliderPublicParams} from "./slider.utils";
|
2
|
-
import {
|
3
|
-
import {computed, useModel, useStyles} from "@peryl/react-compose";
|
2
|
+
import {createEffectsOfReaction, useModel, useStyles} from "@peryl/react-compose";
|
4
3
|
import {unit} from "@peryl/utils/unit";
|
5
4
|
import {useSliderDotDraggier} from "./useSliderDotDragier";
|
6
5
|
|
@@ -14,16 +13,16 @@ export function useSliderSingle(
|
|
14
13
|
editComputed,
|
15
14
|
}: iSliderPublicParams) {
|
16
15
|
|
17
|
-
const
|
16
|
+
const { effects, effectComputed } = createEffectsOfReaction();
|
18
17
|
|
19
|
-
const {
|
18
|
+
const model = useModel(() => props.modelValue, event.emit.onUpdateModelValue, { autoEmit: props.emitImmediate }, effects);
|
20
19
|
|
21
20
|
/**
|
22
21
|
* 当前百分比
|
23
22
|
* @author 韦胜健
|
24
23
|
* @date 2022.12.10 15:42
|
25
24
|
*/
|
26
|
-
const percent =
|
25
|
+
const percent = effectComputed(() => Number(((model.value == null ? 0 : Number(model.value)) / props.total).toFixed(2)));
|
27
26
|
|
28
27
|
/**
|
29
28
|
* 进度条行内样式
|
@@ -44,7 +43,7 @@ export function useSliderSingle(
|
|
44
43
|
styles.transform = `scaleY(${percentValue})`;
|
45
44
|
styles.transformOrigin = props.alignEnd ? 'bottom' : 'top';
|
46
45
|
}
|
47
|
-
});
|
46
|
+
}, effects);
|
48
47
|
|
49
48
|
/**
|
50
49
|
* 指示器行内样式
|
@@ -60,7 +59,7 @@ export function useSliderSingle(
|
|
60
59
|
} else {
|
61
60
|
styles.transform = `translateY(${length}px)`;
|
62
61
|
}
|
63
|
-
});
|
62
|
+
}, effects);
|
64
63
|
|
65
64
|
/**
|
66
65
|
* 指示器拖拽行为
|
@@ -83,7 +82,7 @@ export function useSliderSingle(
|
|
83
82
|
* @author 韦胜健
|
84
83
|
* @date 2022.12.10 15:43
|
85
84
|
*/
|
86
|
-
const tooltipLabel =
|
85
|
+
const tooltipLabel = effectComputed(() => {
|
87
86
|
let ret = model.value;
|
88
87
|
return !!props.tooltipFormatter ? props.tooltipFormatter(ret || 0) : ret;
|
89
88
|
});
|
@@ -3,8 +3,8 @@ import {iTableCellRenderScope, iTableRowRenderScope} from "../../table/utils/tab
|
|
3
3
|
|
4
4
|
export function createPlcCheckHooks() {
|
5
5
|
return {
|
6
|
-
onRenderNormal: createSyncHooks<(data: { scope: iTableCellRenderScope, content: RenderNode }) => void>(),
|
7
|
-
onRenderHead: createSyncHooks<(renderNode: RenderNode) => void>(),
|
6
|
+
onRenderNormal: createSyncHooks<(data: { scope: iTableCellRenderScope, content: RenderNode }) => void>(true),
|
7
|
+
onRenderHead: createSyncHooks<(renderNode: RenderNode) => void>(true),
|
8
8
|
onClickRow: createHooks<(data: { rowRenderScope: iTableRowRenderScope }) => void>(),
|
9
9
|
|
10
10
|
onTriggerCheckAll: createHooks(),
|
@@ -1,12 +1,11 @@
|
|
1
1
|
import {iPlcCheckEventType, iPlcCheckPropsType} from "./PlcCheck.utils";
|
2
|
-
import {
|
2
|
+
import {createEffectsOfReaction, reactive, toRaw, useModel} from "@peryl/react-compose";
|
3
3
|
import {toArray} from "@peryl/utils/toArray";
|
4
4
|
import {PlainObject} from "@peryl/utils/event";
|
5
5
|
import {iTableRowRenderScope} from "../../table/utils/table.utils";
|
6
6
|
import {CheckboxStatus} from "../../../../utils/constant";
|
7
7
|
import {Checkbox} from "../../../Checkbox";
|
8
8
|
import {iPlcCheckHooks} from "./PlcCheck.hooks";
|
9
|
-
import {createEffects} from "@peryl/utils/createEffects";
|
10
9
|
import {iTableRefer} from "../../table/Table";
|
11
10
|
import {Badge} from "../../../Badge";
|
12
11
|
import {Dropdown} from "../../../Dropdown";
|
@@ -37,21 +36,21 @@ export function usePlcCheckMultiple(
|
|
37
36
|
}
|
38
37
|
) {
|
39
38
|
|
40
|
-
const { effects } =
|
39
|
+
const { effects, effectComputed } = createEffectsOfReaction();
|
41
40
|
|
42
41
|
/**
|
43
42
|
* 双向绑定值
|
44
43
|
* @author 韦胜健
|
45
44
|
* @date 2022.11.27 16:36
|
46
45
|
*/
|
47
|
-
const model = useModel(() => props.modelValue as PlainObject[] | null | undefined, event.emit.onUpdateModelValue as any);
|
46
|
+
const model = useModel(() => props.modelValue as PlainObject[] | null | undefined, event.emit.onUpdateModelValue as any, undefined, effects);
|
48
47
|
|
49
48
|
/**
|
50
49
|
* 已经选中的keys
|
51
50
|
* @author 韦胜健
|
52
51
|
* @date 2022.11.27 16:36
|
53
52
|
*/
|
54
|
-
const checkKeys =
|
53
|
+
const checkKeys = effectComputed(() => {
|
55
54
|
if (!model.value) {return {};}
|
56
55
|
return toArray(model.value).reduce((prev, item) => {
|
57
56
|
prev[item[props.field]] = true;
|
@@ -1,10 +1,9 @@
|
|
1
1
|
import {iPlcCheckEventType, iPlcCheckPropsType} from "./PlcCheck.utils";
|
2
|
-
import {useModel} from "@peryl/react-compose";
|
2
|
+
import {createEffectsOfReaction, useModel} from "@peryl/react-compose";
|
3
3
|
import {PlainObject} from "@peryl/utils/event";
|
4
4
|
import {iTableRowRenderScope} from "../../table/utils/table.utils";
|
5
5
|
import {Radio} from "../../../Radio";
|
6
6
|
import {CheckboxStatus} from "../../../../utils/constant";
|
7
|
-
import {createEffects} from "@peryl/utils/createEffects";
|
8
7
|
import {iPlcCheckHooks} from "./PlcCheck.hooks";
|
9
8
|
import {iTableRefer} from "../../table/Table";
|
10
9
|
|
@@ -22,14 +21,14 @@ export function usePlcCheckSingle(
|
|
22
21
|
}
|
23
22
|
) {
|
24
23
|
|
25
|
-
const { effects } =
|
24
|
+
const { effects } = createEffectsOfReaction();
|
26
25
|
|
27
26
|
/**
|
28
27
|
* 双向绑定值
|
29
28
|
* @author 韦胜健
|
30
29
|
* @date 2022.11.27 16:36
|
31
30
|
*/
|
32
|
-
const model = useModel(() => props.modelValue as PlainObject | null | undefined, event.emit.onUpdateModelValue as any);
|
31
|
+
const model = useModel(() => props.modelValue as PlainObject | null | undefined, event.emit.onUpdateModelValue as any, undefined, effects);
|
33
32
|
|
34
33
|
const utils = {
|
35
34
|
/**
|
@@ -1,22 +1,21 @@
|
|
1
1
|
import {TimePanel} from "./panel/TimePanel";
|
2
2
|
import Input from "../Input";
|
3
|
-
import {
|
3
|
+
import {createEffectsOfReaction, getComponentCls, reactive, useModel, useRefs} from "@peryl/react-compose";
|
4
4
|
import {delay} from "@peryl/utils/delay";
|
5
5
|
import {PDate, plainDate} from "../../utils/plainDate";
|
6
6
|
import {limitDatetimeTimePlainData, TimeLayoutToFormat, tTimeCompositionParams} from "./time.utils";
|
7
7
|
import {TimePanelLayout} from "./panel/TimeBasePanel";
|
8
8
|
import {debounce} from "@peryl/utils/debounce";
|
9
9
|
import {useRenderReference} from "../../uses/useRenderReference";
|
10
|
-
import {createEffects} from "@peryl/utils/createEffects";
|
11
10
|
import {createPopupEditor} from "../usePopupEditor";
|
12
11
|
|
13
12
|
export function createSingleTimeRender({ emit, props, hooks, displayPattern, today, maxmin, editComputed, slots, getPublicPopperAttrs, getInheritPublicTimeAttrs, formatString }: tTimeCompositionParams) {
|
14
13
|
|
15
|
-
const { effects } =
|
14
|
+
const { effects, effectComputed } = createEffectsOfReaction();
|
16
15
|
const { refs, onRef } = useRefs({ input: Input });
|
17
16
|
const reference = useRenderReference();
|
18
|
-
const model = useModel(() => props.modelValue, emit.onUpdateModelValue, { onChange: () => delay().then(() => state.input = format.value?.getDisplay()) });
|
19
|
-
const format =
|
17
|
+
const model = useModel(() => props.modelValue, emit.onUpdateModelValue, { onChange: () => delay().then(() => state.input = format.value?.getDisplay()) }, effects);
|
18
|
+
const format = effectComputed((): null | PDate => !model.value ? null : plainDate(model.value, formatString.value));
|
20
19
|
const state = reactive({
|
21
20
|
input: format.value?.getDisplay(),
|
22
21
|
hoverColumnType: null as null | TimePanelLayout,
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import {createEffectsOfReaction, getComponentCls, iHTMLInputElement, reactive, useModel, useRefs} from "@peryl/react-compose";
|
2
2
|
import Input from "../Input";
|
3
3
|
import {delay} from "@peryl/utils/delay";
|
4
4
|
import {useFocusHandler} from "../../uses/useFocusHandler";
|
@@ -8,16 +8,16 @@ import {TimeRangePanelType} from "./panel/TimeRangePanel";
|
|
8
8
|
import {limitDatetimeTimePlainData, TimeLayoutToFormat, tTimeCompositionParams} from "./time.utils";
|
9
9
|
import {debounce} from "@peryl/utils/debounce";
|
10
10
|
import {useRenderReference} from "../../uses/useRenderReference";
|
11
|
-
import {createEffects} from "@peryl/utils/createEffects";
|
12
11
|
|
13
12
|
export function useRangeTimeRender({ props, emit, onBlur, slots, displayPattern, today, onInputClear, maxmin, formatString }: tTimeCompositionParams & { onBlur: () => void, onInputClear?: (range: TimeRangePanelType) => void, }) {
|
14
|
-
const { effects } =
|
13
|
+
const { effects, effectComputed } = createEffectsOfReaction();
|
15
14
|
const { refs, onRef } = useRefs({ input: Input, start: iHTMLInputElement, end: iHTMLInputElement, });
|
16
15
|
const reference = useRenderReference();
|
17
|
-
const startModel = useModel(() => props.start, emit.onUpdateStart, { onChange: () => delay().then(() => state.input.start = format.value.start?.getDisplay()) });
|
18
|
-
const endModel = useModel(() => props.end, emit.onUpdateEnd, { onChange: () => delay().then(() => state.input.end = format.value.end?.getDisplay()) });
|
16
|
+
const startModel = useModel(() => props.start, emit.onUpdateStart, { onChange: () => delay().then(() => state.input.start = format.value.start?.getDisplay()) }, effects);
|
17
|
+
const endModel = useModel(() => props.end, emit.onUpdateEnd, { onChange: () => delay().then(() => state.input.end = format.value.end?.getDisplay()) }, effects);
|
19
18
|
|
20
19
|
const { isFocus } = useFocusHandler({
|
20
|
+
effects,
|
21
21
|
getEls: () => [refs.start, refs.end],
|
22
22
|
/**
|
23
23
|
* Input失去焦点事件,将文本框的值重置为display的值,以避免显示输入不正确的值
|
@@ -33,7 +33,7 @@ export function useRangeTimeRender({ props, emit, onBlur, slots, displayPattern,
|
|
33
33
|
onFocus: emit.onFocus,
|
34
34
|
});
|
35
35
|
|
36
|
-
const format =
|
36
|
+
const format = effectComputed((): { start: null | PDate, end: null | PDate } => ({
|
37
37
|
start: !startModel.value ? null : plainDate(startModel.value, formatString.value),
|
38
38
|
end: !endModel.value ? null : plainDate(endModel.value, formatString.value),
|
39
39
|
}));
|
@@ -322,9 +322,9 @@ export const PopupItem = designComponent({
|
|
322
322
|
* @author 韦胜健
|
323
323
|
* @date 2023/5/16 17:14
|
324
324
|
*/
|
325
|
-
useWatchAutoClear(() => state.option.reference, () => {
|
326
|
-
const effects: SimpleFunction[] = [];
|
325
|
+
useWatchAutoClear(() => state.option.reference, (): (() => void) => {
|
327
326
|
if (!state.option.reference) {return doNothing;}
|
327
|
+
const { effects } = createEffects();
|
328
328
|
const parents = getElementParents(state.option.reference).concat(window as any);
|
329
329
|
const onScroll = () => {
|
330
330
|
if (state.option.hideOnScroll) {
|
@@ -341,7 +341,7 @@ export const PopupItem = designComponent({
|
|
341
341
|
parent.addEventListener('scroll', onScroll);
|
342
342
|
effects.push(() => {parent.removeEventListener('scroll', onScroll);});
|
343
343
|
});
|
344
|
-
return
|
344
|
+
return effects.clear;
|
345
345
|
});
|
346
346
|
|
347
347
|
/**
|