Merge branch 'next' into develop

This commit is contained in:
nocobase[bot] 2025-02-19 01:47:56 +00:00
commit 7d3d1fc657
3 changed files with 11 additions and 7 deletions

View File

@ -2,9 +2,7 @@
"version": "1.6.0-alpha.28", "version": "1.6.0-alpha.28",
"npmClient": "yarn", "npmClient": "yarn",
"useWorkspaces": true, "useWorkspaces": true,
"npmClientArgs": [ "npmClientArgs": ["--ignore-engines"],
"--ignore-engines"
],
"command": { "command": {
"version": { "version": {
"forcePublish": true, "forcePublish": true,

View File

@ -269,7 +269,7 @@ DatePicker.FilterWithPicker = function FilterWithPicker(props: any) {
const value = Array.isArray(props.value) ? props.value[0] : props.value; const value = Array.isArray(props.value) ? props.value[0] : props.value;
const compile = useCompile(); const compile = useCompile();
const fieldSchema = useFieldSchema(); const fieldSchema = useFieldSchema();
const targetPicker = value ? inferPickerType(value) : picker; const targetPicker = value ? inferPickerType(value, picker) : picker;
const targetDateFormat = getPickerFormat(targetPicker) || format; const targetDateFormat = getPickerFormat(targetPicker) || format;
const newProps = { const newProps = {
utc, utc,
@ -288,6 +288,12 @@ DatePicker.FilterWithPicker = function FilterWithPicker(props: any) {
}; };
const field: any = useField(); const field: any = useField();
const [stateProps, setStateProps] = useState(newProps); const [stateProps, setStateProps] = useState(newProps);
useEffect(() => {
newProps.picker = targetPicker;
const dateTimeFormat = getDateTimeFormat(targetPicker, format, showTime, timeFormat);
newProps.format = dateTimeFormat;
setStateProps(newProps);
}, [targetPicker]);
return ( return (
<Space.Compact style={{ width: '100%' }}> <Space.Compact style={{ width: '100%' }}>
<Select <Select
@ -296,7 +302,7 @@ DatePicker.FilterWithPicker = function FilterWithPicker(props: any) {
data-testid="select-picker" data-testid="select-picker"
style={{ width: '100px' }} style={{ width: '100px' }}
popupMatchSelectWidth={false} popupMatchSelectWidth={false}
defaultValue={targetPicker} value={targetPicker}
options={compile([ options={compile([
{ {
label: '{{t("Date")}}', label: '{{t("Date")}}',

View File

@ -271,7 +271,7 @@ function withParams(value: any[], params: { fieldOperator?: string; isParsingVar
return value; return value;
} }
export function inferPickerType(dateString: string): 'year' | 'month' | 'quarter' | 'date' { export function inferPickerType(dateString: string, picker): 'year' | 'month' | 'quarter' | 'date' {
if (/^\d{4}$/.test(dateString)) { if (/^\d{4}$/.test(dateString)) {
return 'year'; return 'year';
} else if (/^\d{4}-\d{2}$/.test(dateString)) { } else if (/^\d{4}-\d{2}$/.test(dateString)) {
@ -281,6 +281,6 @@ export function inferPickerType(dateString: string): 'year' | 'month' | 'quarter
} else if (/^\d{4}-\d{2}-\d{2}$/.test(dateString)) { } else if (/^\d{4}-\d{2}-\d{2}$/.test(dateString)) {
return 'date'; return 'date';
} else { } else {
return 'date'; return picker;
} }
} }