Skip to content

Commit

Permalink
Feat no hook 2 (#1189)
Browse files Browse the repository at this point in the history
* feat: RareWordsKeyboard 去掉hook相关实现

* feat: RareWordsKeyboard 去掉hook相关实现

* feat: Form 去掉hook相关实现,并适配微信

* feat: 部分form组件传入defaultValue

* feat: formInput适配微信

* feat: 部分form组件传入defaultValue

* feat: 部分form组件传入defaultValue

* feat: form相关的fef判空

* feat: form相关的fef判空

* feat: form相关的fef判空
  • Loading branch information
rayhomie authored May 21, 2024
1 parent b1298be commit 44c4edf
Show file tree
Hide file tree
Showing 121 changed files with 1,860 additions and 2,250 deletions.
1 change: 1 addition & 0 deletions compiled/alipay/src/DatePicker/RangePicker/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,5 @@ export const DateRangePickerFunctionalProps: Partial<IDateRangePickerProps> = {
popStyle: '',
disabled: false,
onFormatLabel: null,
onFormat: null,
};
1 change: 1 addition & 0 deletions compiled/alipay/src/DatePicker/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,5 @@ export const DatePickerFunctionalProps: IDatePickerProps = {
popStyle: '',
disabled: false,
onFormatLabel: null,
onFormat: null,
};
96 changes: 44 additions & 52 deletions compiled/alipay/src/Form/FormCascaderPicker/index.ts
Original file line number Diff line number Diff line change
@@ -1,56 +1,48 @@
import { useEvent } from 'functional-mini/component';
import { mountComponent } from '../../_util/component';
import { useComponentEvent } from '../../_util/hooks/useComponentEvent';
import {
useHandleCustomEvent,
useHandleCustomEventOnly,
useMultipleValueHandleCustomEvent,
} from '../../_util/hooks/useHandleCustomEvent';
import { useFormItem } from '../use-form-item';
import {
Component,
triggerEvent,
triggerEventValues,
triggerEventOnly,
getValueFromProps,
} from '../../_util/simply';
import { resolveEventValue, resolveEventValues } from '../../_util/platform';
import { FormCascaderPickerDefaultProps } from './props';
import { createForm } from '../form';

Component(
FormCascaderPickerDefaultProps,
FormCascaderPickerProps,
} from './props';

const FormCascaderPicker = (props: FormCascaderPickerProps) => {
const { formData, emit } = useFormItem(props);
const { triggerEventValues, triggerEventOnly, triggerEvent } =
useComponentEvent(props);

useMultipleValueHandleCustomEvent('onOk', (value, option, e) => {
emit('onChange', value);
triggerEventValues('ok', [value, option], e);
});

useMultipleValueHandleCustomEvent('onPickerChange', (value, option, e) => {
triggerEventValues('pickerChange', [value, option], e);
});

useHandleCustomEvent('onVisibleChange', (visible, e) => {
triggerEvent('visibleChange', visible, e);
});

useEvent(
'handleFormat',
(value, option) => {
if (props.onFormat) {
return props.onFormat(value, option);
{
onOk(value, option, e) {
const v = resolveEventValues(value, option);
this.emit('onChange', v[0]);
triggerEventValues(this, 'ok', v, e);
},
onPickerChange(value, option, e) {
triggerEventValues(
this,
'pickerChange',
resolveEventValues(value, option),
e
);
},
onVisibleChange(visible, e) {
triggerEvent(this, 'visibleChange', resolveEventValue(visible), e);
},
onDismissPicker(e) {
triggerEventOnly(this, 'cancel', e);
},
onChange(value, options, e) {
triggerEventValues(this, 'change', resolveEventValues(value, options), e);
},
handleFormat(value, option) {
const onFormat = getValueFromProps(this, 'onFormat');
if (onFormat) {
return onFormat(value, option);
}
},
{ handleResult: true }
);

useHandleCustomEventOnly('onDismissPicker', (e) => {
triggerEventOnly('cancel', e);
});

useMultipleValueHandleCustomEvent('onChange', (value, options, e) => {
triggerEventValues('change', [value, options], e);
});

return {
formData,
};
};

mountComponent(FormCascaderPicker, FormCascaderPickerDefaultProps);
},
{},
[createForm()],
{
}
);
4 changes: 2 additions & 2 deletions compiled/alipay/src/Form/FormCascaderPicker/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
CascaderFunctionalProps,
ICascaderProps,
} from '../../Picker/CascaderPicker/props';
import { FormItemFunctionalProps, FormItemProps } from '../FormItem/props';
import { FormItemDefaultProps, FormItemProps } from '../FormItem/props';

export interface FormCascaderPickerProps extends ICascaderProps, FormItemProps {
/**
Expand All @@ -13,7 +13,7 @@ export interface FormCascaderPickerProps extends ICascaderProps, FormItemProps {

export const FormCascaderPickerDefaultProps: Partial<FormCascaderPickerProps> =
{
...FormItemFunctionalProps,
...FormItemDefaultProps,
...CascaderFunctionalProps,
arrow: false,
};
35 changes: 15 additions & 20 deletions compiled/alipay/src/Form/FormCheckboxGroup/index.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
import { mountComponent } from '../../_util/component';
import { useComponentEvent } from '../../_util/hooks/useComponentEvent';
import { useHandleCustomEvent } from '../../_util/hooks/useHandleCustomEvent';
import { useFormItem } from '../use-form-item';
import { FormCheckboxGroupDefaultProps, FormCheckboxGroupProps } from './props';
import { Component, triggerEvent } from '../../_util/simply';
import { FormCheckboxGroupDefaultProps } from './props';
import { resolveEventValue } from '../../_util/platform';
import { createForm } from '../form';

const FormCheckboxGroup = (props: FormCheckboxGroupProps) => {
const { formData, emit } = useFormItem(props);
const { triggerEvent } = useComponentEvent(props);

useHandleCustomEvent('onChange', (value, e) => {
emit('onChange', value);
triggerEvent('change', value, e);
});

return {
formData,
};
};

mountComponent(FormCheckboxGroup, FormCheckboxGroupDefaultProps);
Component(
FormCheckboxGroupDefaultProps,
{
onChange(value, e) {
this.emit('onChange', resolveEventValue(value));
triggerEvent(this, 'change', resolveEventValue(value), e);
},
},
null,
[createForm()]
);
4 changes: 2 additions & 2 deletions compiled/alipay/src/Form/FormCheckboxGroup/props.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FormItemFunctionalProps, FormItemProps } from '../FormItem/props';
import { FormItemDefaultProps, FormItemProps } from '../FormItem/props';
import {
CheckboxGroupDefaultProps,
ICheckboxGroupProps,
Expand All @@ -13,7 +13,7 @@ export interface FormCheckboxGroupProps
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { position, ...rest } = CheckboxGroupDefaultProps;
export const FormCheckboxGroupDefaultProps: Partial<FormCheckboxGroupProps> = {
...FormItemFunctionalProps,
...FormItemDefaultProps,
...rest,
checkboxPosition: 'horizontal',
};
105 changes: 45 additions & 60 deletions compiled/alipay/src/Form/FormDatePicker/index.ts
Original file line number Diff line number Diff line change
@@ -1,67 +1,52 @@
import { useEvent } from 'functional-mini/component';
import { mountComponent } from '../../_util/component';
import { useComponentEvent } from '../../_util/hooks/useComponentEvent';
import {
useHandleCustomEvent,
useHandleCustomEventOnly,
useMultipleValueHandleCustomEvent,
} from '../../_util/hooks/useHandleCustomEvent';
import { useFormItem } from '../use-form-item';
import { FormDatePickerDefaultProps, FormDatePickerProps } from './props';
import { platform } from '../../_util/platform';

const FormDatePicker = (props: FormDatePickerProps) => {
const { formData, emit } = useFormItem(props);
const { triggerEventValues, triggerEventOnly, triggerEvent } =
useComponentEvent(props);

useMultipleValueHandleCustomEvent('onOk', (date, dateStr, e) => {
emit('onChange', platform() === 'wechat' ? date.getTime() : date);
triggerEventValues('ok', [date, dateStr], e);
});

useMultipleValueHandleCustomEvent('onPickerChange', (date, dateStr, e) => {
triggerEventValues('pickerChange', [date, dateStr], e);
});

useHandleCustomEvent('onVisibleChange', (visible, e) => {
triggerEvent('visibleChange', visible, e);
});

useHandleCustomEventOnly('onDismissPicker', (e) => {
triggerEventOnly('dismissPicker', e);
});
Component,
triggerEvent,
triggerEventValues,
triggerEventOnly,
getValueFromProps,
} from '../../_util/simply';
import { resolveEventValue, resolveEventValues } from '../../_util/platform';
import { FormDatePickerDefaultProps } from './props';
import { createForm } from '../form';

Component(
FormDatePickerDefaultProps,
{
onOk(date, dateStr, e) {
const v = resolveEventValues(date, dateStr);
this.emit('onChange', v[0]);
triggerEventValues(this, 'ok', v, e);
},
onPickerChange(date, dateStr, e) {
triggerEventValues(
this,
'pickerChange',
resolveEventValues(date, dateStr),
e
);
},
onVisibleChange(visible, e) {
triggerEvent(this, 'visibleChange', resolveEventValue(visible), e);
},
onDismissPicker(e) {
triggerEventOnly(this, 'dismissPicker', e);
},

useEvent(
'handleFormat',
(date, dateStr) => {
if (props.onFormat) {
return props.onFormat(date, dateStr);
handleFormat(date, dateStr) {
const onFormat = getValueFromProps(this, 'onFormat');
if (onFormat) {
return onFormat(date, dateStr);
}
},
{
handleResult: true,
}
);

useEvent(
'handleFormatLabel',
(type, value) => {
if (props.onFormatLabel) {
return props.onFormatLabel(type, value);
handleFormatLabel(type, value) {
const onFormatLabel = getValueFromProps(this, 'onFormatLabel');
if (onFormatLabel) {
return onFormatLabel(type, value);
}
},
{
handleResult: true,
}
);

return {
formData,
};
};

mountComponent(
FormDatePicker,
FormDatePickerDefaultProps as FormDatePickerProps
},
{},
[createForm()],
{
}
);
4 changes: 2 additions & 2 deletions compiled/alipay/src/Form/FormDatePicker/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
DatePickerFunctionalProps,
IDatePickerProps,
} from '../../DatePicker/props';
import { FormItemFunctionalProps, FormItemProps } from '../FormItem/props';
import { FormItemDefaultProps, FormItemProps } from '../FormItem/props';

export interface FormDatePickerProps extends IDatePickerProps, FormItemProps {
/**
Expand All @@ -12,7 +12,7 @@ export interface FormDatePickerProps extends IDatePickerProps, FormItemProps {
}

export const FormDatePickerDefaultProps: Partial<FormDatePickerProps> = {
...FormItemFunctionalProps,
...FormItemDefaultProps,
...DatePickerFunctionalProps,
arrow: false,
};
Loading

0 comments on commit 44c4edf

Please sign in to comment.