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 <Spin />;
} }
return ( return (
<ConfigProvider {...others} locale={locale[i18n.language].antd}> <ConfigProvider
dropdownMatchSelectWidth={false}
{...others}
locale={locale[i18n.language].antd}
>
{props.children} {props.children}
</ConfigProvider> </ConfigProvider>
); );

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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