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
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.109",
|
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.
|
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.
|
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 {
|
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
|
10
|
+
const { effects, effectWatch } = createEffectsOfReaction();
|
12
11
|
|
13
|
-
const
|
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
|
-
|
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 {
|
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 } =
|
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 =
|
20
|
+
const metaArray = effectComputed((): iAddressSyncMeta[] | null => {
|
22
21
|
if (!filterData.value) {
|
23
22
|
return null;
|
24
23
|
}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import {ComputedRef, createRenderHook, inject, provide} from "@peryl/react-compose";
|
2
2
|
import {iThemeConfiguration} from "../theme/theme";
|
3
3
|
import {UseStyleProvideData} from "../../../uses/useStyle";
|
4
|
+
import {createEffects} from "@peryl/utils/createEffects";
|
4
5
|
|
5
6
|
export interface iApplicationConfiguration {
|
6
7
|
theme: iThemeConfiguration;
|
@@ -17,6 +18,4 @@ export const ApplicationConfigurationProvider = (() => {
|
|
17
18
|
|
18
19
|
export const APPLICATION_SERVICE_CONTAINER_CLASS = 'application-service-container';
|
19
20
|
|
20
|
-
export const ApplicationHooks = {
|
21
|
-
onRender: createRenderHook(),
|
22
|
-
};
|
21
|
+
export const ApplicationHooks = { onRender: createRenderHook({ effects: createEffects().effects }), };
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import {
|
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 } =
|
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 =
|
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 {
|
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 =
|
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 {
|
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 } =
|
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 {
|
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 } =
|
18
|
+
const { effects, effectComputed } = createEffectsOfReaction();
|
20
19
|
const { refs, onRef } = useRefs({ input: Input });
|
21
|
-
|
22
|
-
const format =
|
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 {
|
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 } =
|
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 =
|
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
|
}));
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import {eFormValidateMode, eFormValidateTrigger, getRuleValue, iFormItemValidatePropsType, isRuleRequired, iValidateRule} from "./validate.utils";
|
2
|
-
import {
|
2
|
+
import {createEffectsOfReaction, globalWatch, inject, onBeforeUnmount} from "@peryl/react-compose";
|
3
3
|
import {FORM_VALIDATION_PROVIDER, useFormValidation} from "./useFormValidation";
|
4
4
|
import {Validation} from "./createValidation";
|
5
|
-
import {createEffects} from "@peryl/utils/createEffects";
|
5
|
+
import {createEffects, iEffects} from "@peryl/utils/createEffects";
|
6
6
|
|
7
7
|
/**
|
8
8
|
* 抽离FormItem中的校验逻辑
|
@@ -11,6 +11,8 @@ import {createEffects} from "@peryl/utils/createEffects";
|
|
11
11
|
*/
|
12
12
|
export function useFormItemValidation({ props }: { props: iFormItemValidatePropsType }) {
|
13
13
|
|
14
|
+
const { effects, effectComputed, effectWatchEffect } = createEffectsOfReaction();
|
15
|
+
|
14
16
|
/*Form校验*/
|
15
17
|
const formValidation = inject<ReturnType<typeof useFormValidation>>(FORM_VALIDATION_PROVIDER)!;
|
16
18
|
|
@@ -22,14 +24,14 @@ export function useFormItemValidation({ props }: { props: iFormItemValidateProps
|
|
22
24
|
* @author 韦胜健
|
23
25
|
* @date 2022.11.5 23:39
|
24
26
|
*/
|
25
|
-
const isRequired =
|
27
|
+
const isRequired = effectComputed(() => childValidation.getRules().some(rule => isRuleRequired(rule, formValidation.props.modelValue)));
|
26
28
|
|
27
29
|
/**
|
28
30
|
* 当前的校验不通过的信息
|
29
31
|
* @author 韦胜健
|
30
32
|
* @date 2022/8/22 23:48
|
31
33
|
*/
|
32
|
-
const validateMessage =
|
34
|
+
const validateMessage = effectComputed((): string | null => {
|
33
35
|
if (!props.field && !props.validateValueGetter && !props.rules) {
|
34
36
|
return null;
|
35
37
|
}
|
@@ -53,7 +55,7 @@ export function useFormItemValidation({ props }: { props: iFormItemValidateProps
|
|
53
55
|
* @author 韦胜健
|
54
56
|
* @date 2022.11.6 0:00
|
55
57
|
*/
|
56
|
-
const
|
58
|
+
const getValueByRule = (rule: iValidateRule): { label?: string | null, field?: string, value?: string } | null => {
|
57
59
|
if (formValidation.props.validateMode === eFormValidateMode.table) {return null;}
|
58
60
|
const { field, label, valueGetter } = rule;
|
59
61
|
if (!rule.field && !rule.valueGetter) {return null;}
|
@@ -69,12 +71,9 @@ export function useFormItemValidation({ props }: { props: iFormItemValidateProps
|
|
69
71
|
* @author 韦胜健
|
70
72
|
* @date 2022.11.6 0:58
|
71
73
|
*/
|
72
|
-
const watchRuleValueChange = (
|
73
|
-
|
74
|
-
() =>
|
75
|
-
const rule = getRule();
|
76
|
-
return !rule || rule.trigger === eFormValidateTrigger.blur ? null : getWatchData(rule);
|
77
|
-
},
|
74
|
+
const watchRuleValueChange = (rule: iValidateRule, effects: iEffects) => {
|
75
|
+
effects.push(globalWatch(
|
76
|
+
() => rule.trigger === eFormValidateTrigger.blur ? null : getValueByRule(rule),
|
78
77
|
(newValue, oldValue) => {
|
79
78
|
/*校验规则已经消失*/
|
80
79
|
if (!newValue || (!newValue.field && !newValue.label)) {
|
@@ -94,28 +93,27 @@ export function useFormItemValidation({ props }: { props: iFormItemValidateProps
|
|
94
93
|
}
|
95
94
|
formValidation.handler.onFieldChange({ label: newValue.label, field: newValue.field });
|
96
95
|
}
|
97
|
-
);
|
98
|
-
return () => unwatch();
|
96
|
+
));
|
99
97
|
};
|
100
98
|
|
101
|
-
|
102
|
-
|
103
|
-
|
99
|
+
const { effects: innerEffects } = createEffects();
|
100
|
+
effects.push(() => innerEffects.clear());
|
101
|
+
|
102
|
+
effectWatchEffect(() => {
|
103
|
+
innerEffects.clear();
|
104
104
|
[
|
105
|
+
childValidation.formItemRules.outerRule.value,
|
105
106
|
/*监听props.rules的值变化然后触发校验*/
|
106
|
-
childValidation.formItemRules.formRules,
|
107
|
+
...childValidation.formItemRules.formRules.value || [],
|
107
108
|
/*监听form.rules的值变化然后触发校验*/
|
108
|
-
childValidation.formItemRules.propsRules
|
109
|
-
].forEach(
|
110
|
-
/*当rule变化时,将上一次的watch
|
111
|
-
|
112
|
-
watchEffect(() => {
|
113
|
-
effects.clear();
|
114
|
-
item.value?.forEach(rule => {effects.push(watchRuleValueChange(() => rule));});
|
115
|
-
});
|
116
|
-
onBeforeUnmount(() => effects.clear());
|
109
|
+
...childValidation.formItemRules.propsRules.value || []
|
110
|
+
].forEach(rule => {
|
111
|
+
/*当rule变化时,将上一次的watch注销,这里重新watch*/
|
112
|
+
!!rule && watchRuleValueChange(rule, innerEffects);
|
117
113
|
});
|
118
|
-
})
|
114
|
+
});
|
115
|
+
|
116
|
+
onBeforeUnmount(effects.clear);
|
119
117
|
|
120
118
|
return { formValidation, childValidation, isRequired, validateMessage };
|
121
119
|
}
|
@@ -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 {
|
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 {
|
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 } =
|
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 =
|
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
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
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 {
|
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 } =
|
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 =
|
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 =
|
226
|
+
const popperAttrs = effectComputed(() => ({ ...handler, }));
|
228
227
|
|
229
228
|
/*给select传递的属性*/
|
230
|
-
const selectAttrs =
|
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
|
})();
|