fix(client): set dropdownMatchSelectWidth to false globally (#497)

This commit is contained in:
Junyi 2022-06-10 23:27:35 +08:00 committed by GitHub
parent 9d5e2462d9
commit e4b13289d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 47 additions and 24 deletions

View File

@ -27,7 +27,11 @@ export function AntdConfigProvider(props) {
return <Spin />;
}
return (
<ConfigProvider {...others} locale={locale[i18n.language].antd}>
<ConfigProvider
dropdownMatchSelectWidth={false}
{...others}
locale={locale[i18n.language].antd}
>
{props.children}
</ConfigProvider>
);

View File

@ -499,6 +499,7 @@ export default {
'Boolean': '逻辑值',
'String': '字符串',
'Calculator': '运算',
'Comparison': '值比较',
'Arithmetic calculation': '算术运算',
'String operation': '字符串',
@ -581,5 +582,7 @@ export default {
"Record ID": "数据 ID",
"User": "用户",
"Field": "字段",
"Select": "选择",
"Select Field": "选择字段",
"Field value changes": "变更记录",
}

View File

@ -2,12 +2,14 @@ import { CloseCircleOutlined } from '@ant-design/icons';
import { observer } from '@formily/react';
import { Cascader, Select, Space } from 'antd';
import React, { useContext } from 'react';
import { useTranslation } from 'react-i18next';
import { useCompile } from '../..';
import { RemoveConditionContext } from './context';
import { DynamicComponent } from './DynamicComponent';
import { useValues } from './useValues';
export const FilterItem = observer((props: any) => {
const { t } = useTranslation();
const compile = useCompile();
const remove = useContext(RemoveConditionContext);
const { schema, fields, operators, dataIndex, operator, setDataIndex, setOperator, value, setValue } = useValues();
@ -20,15 +22,13 @@ export const FilterItem = observer((props: any) => {
value: 'name',
children: 'children',
}}
style={{
width: 150,
}}
changeOnSelect={false}
value={dataIndex}
options={compile(fields)}
onChange={(value) => {
setDataIndex(value);
}}
placeholder={t('Select Field')}
/>
<Select
value={operator?.value}
@ -36,9 +36,7 @@ export const FilterItem = observer((props: any) => {
onChange={(value) => {
setOperator(value);
}}
style={{
minWidth: 100,
}}
placeholder={t('Comparison')}
/>
{!operator?.noValue &&
React.createElement(DynamicComponent, {

View File

@ -9,7 +9,6 @@ import { useFlowContext } from "./WorkflowCanvas";
import { triggers } from "./triggers";
import { SchemaComponent, useCollectionManager, useCompile } from "..";
import { useTranslation } from "react-i18next";
import { t } from "i18next";
function NullRender() {
return null;
@ -109,7 +108,11 @@ const ConstantTypes = {
component({ onChange, type, options, value }) {
const { t } = useTranslation();
return (
<Select value={value} onChange={v => onChange({ value: v, type, options })}>
<Select
value={value}
onChange={v => onChange({ value: v, type, options })}
placeholder={t('Select')}
>
<Select.Option value={true}>{t('True')}</Select.Option>
<Select.Option value={false}>{t('False')}</Select.Option>
</Select>
@ -306,6 +309,7 @@ export function Operand({
}
export function Calculation({ calculator, operands = [], onChange }) {
const { t } = useTranslation();
const compile = useCompile();
return (
<VariableTypesContext.Provider value={VariableTypes}>
@ -316,14 +320,17 @@ export function Calculation({ calculator, operands = [], onChange }) {
.ant-select{
width: auto;
min-width: 6em;
}
`}>
<Operand value={operands[0]} onChange={(v => onChange({ calculator, operands: [v, operands[1]] }))} />
{operands[0]
? (
<>
<Select value={calculator} onChange={v => onChange({ operands, calculator: v })}>
<Select
value={calculator}
onChange={v => onChange({ operands, calculator: v })}
placeholder={t('Calculator')}
>
{calculators.map(group => (
<Select.OptGroup key={group.value} label={compile(group.title)}>
{group.children.map(item => (

View File

@ -220,7 +220,12 @@ export function NodeDefaultView(props) {
name: 'config',
'x-component': 'fieldset',
'x-component-props': {
disabled: workflow.executed
disabled: workflow.executed,
className: css`
.ant-select{
width: auto;
}
`
},
properties: instruction.fieldset
},

View File

@ -10,6 +10,9 @@ export const collection = {
'x-reactions': ['{{useCollectionDataSource()}}'],
'x-decorator': 'FormItem',
'x-component': 'Select',
'x-component-props': {
placeholder: '{{t("Select collection")}}'
}
};
export const values = {

View File

@ -1,6 +1,6 @@
import React from "react";
import { ISchema, useForm } from "@formily/react";
import { cx } from "@emotion/css";
import { css, cx } from "@emotion/css";
import { Registry } from "@nocobase/utils";
import { useTranslation } from "react-i18next";
import { message, Tag } from "antd";
@ -93,7 +93,13 @@ export const TriggerConfig = () => {
type: 'void',
name: 'config',
'x-component': 'fieldset',
'x-component-props': {},
'x-component-props': {
className: css`
.ant-select{
width: auto;
}
`
},
properties: fieldset
},
actions: {

View File

@ -3,15 +3,20 @@ import { observer, useForm } from "@formily/react";
import { Select } from "antd";
import { useCollectionManager, useCompile } from "@nocobase/client";
import { useTranslation } from "react-i18next";
export const DateFieldsSelect: React.FC<any> = observer((props) => {
const { t } = useTranslation();
const compile = useCompile();
const { getCollectionFields } = useCollectionManager();
const { values } = useForm();
const fields = getCollectionFields(values?.config?.collection);
return (
<Select {...props}>
<Select
placeholder={t('Select Field')}
{...props}
>
{fields
.filter(field => (
!field.hidden

View File

@ -6,7 +6,6 @@ import { css } from '@emotion/css';
import { SchemaComponent } from '@nocobase/client';
import { collection } from '../../schemas/collection';
// import { DateFieldsSelect } from './DateFieldsSelect';
import { OnField } from './OnField';
import { EndsByField } from './EndsByField';
import { RepeatField } from './RepeatField';
@ -191,11 +190,6 @@ export const ScheduleConfig = () => {
'x-component': 'fieldset',
'x-component-props': {
className: css`
.ant-select{
width: auto;
min-width: 6em;
}
.ant-input-number{
width: 4em;
}
@ -210,7 +204,6 @@ export const ScheduleConfig = () => {
}
}}
components={{
// DateFieldsSelect,
OnField,
RepeatField,
EndsByField

View File

@ -24,7 +24,6 @@ export default {
useCollectionDataSource
},
components: {
// FieldsSelect
ScheduleConfig
},
getter({ type, options, onChange }) {

View File

@ -19,7 +19,7 @@ export default {
prefixMonths: '的',
prefixMonthDays: '的',
prefixWeekDays: '的',
prefixWeekDaysForMonthAndYearPeriod: '',
prefixWeekDaysForMonthAndYearPeriod: '并且',
prefixHours: '的',
prefixMinutes: ':',
prefixMinutesForHourPeriod: '的',