Skip to content

Commit

Permalink
fix(next/antd/vue): fix Switch type & add classname to ArrayItems.Ind…
Browse files Browse the repository at this point in the history
…ex (#2093)
  • Loading branch information
ifblooms authored Sep 3, 2021
1 parent b56b5b2 commit 9f87569
Show file tree
Hide file tree
Showing 19 changed files with 43 additions and 33 deletions.
4 changes: 2 additions & 2 deletions designable/setters/src/components/ValidatorSetter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ const ValidatorSchema: ISchema = {
'x-component': 'NumberPicker',
},
whitespace: {
type: 'string',
type: 'boolean',
'x-decorator': 'FormItem',
'x-component': 'Switch',
},
required: {
type: 'string',
type: 'boolean',
'x-decorator': 'FormItem',
'x-component': 'Switch',
},
Expand Down
2 changes: 1 addition & 1 deletion packages/antd/docs/components/ArrayTable.md
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ const schema = {
'x-component-props': { width: 100, title: 'Explicitly hidden->A2' },
properties: {
a1: {
type: 'string',
type: 'boolean',
'x-decorator': 'FormItem',
'x-component': 'Switch',
},
Expand Down
2 changes: 1 addition & 1 deletion packages/antd/docs/components/ArrayTable.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ const schema = {
'x-component-props': { width: 100, title: '显隐->A2' },
properties: {
a1: {
type: 'string',
type: 'boolean',
'x-decorator': 'FormItem',
'x-component': 'Switch',
},
Expand Down
6 changes: 3 additions & 3 deletions packages/antd/docs/components/FormItem.md
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ export default () => {
bordered: false,
}}
/>
<SchemaField.String
<SchemaField.Boolean
name="Switch"
title="Switch"
x-decorator="FormItem"
Expand Down Expand Up @@ -616,7 +616,7 @@ export default () => {
inset: true,
}}
/>
<SchemaField.String
<SchemaField.Boolean
name="Switch"
title="Switch"
x-decorator="FormItem"
Expand Down Expand Up @@ -1040,7 +1040,7 @@ export default () => {
x-component="TreeSelect"
required
/>
<SchemaField.String
<SchemaField.Boolean
name="Switch"
title="Switch"
x-decorator="FormItem"
Expand Down
6 changes: 3 additions & 3 deletions packages/antd/docs/components/FormItem.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ export default () => {
bordered: false,
}}
/>
<SchemaField.String
<SchemaField.Boolean
name="Switch"
title="Switch"
x-decorator="FormItem"
Expand Down Expand Up @@ -616,7 +616,7 @@ export default () => {
inset: true,
}}
/>
<SchemaField.String
<SchemaField.Boolean
name="Switch"
title="Switch"
x-decorator="FormItem"
Expand Down Expand Up @@ -1040,7 +1040,7 @@ export default () => {
x-component="TreeSelect"
required
/>
<SchemaField.String
<SchemaField.Boolean
name="Switch"
title="Switch"
x-decorator="FormItem"
Expand Down
4 changes: 2 additions & 2 deletions packages/antd/docs/components/Switch.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const form = createForm()
export default () => (
<FormProvider form={form}>
<SchemaField>
<SchemaField.Number
<SchemaField.Boolean
name="switch"
title="Switch"
x-decorator="FormItem"
Expand Down Expand Up @@ -57,7 +57,7 @@ const schema = {
type: 'object',
properties: {
switch: {
type: 'number',
type: 'boolean',
title: 'Switch',
'x-decorator': 'FormItem',
'x-component': 'Switch',
Expand Down
4 changes: 2 additions & 2 deletions packages/antd/docs/components/Switch.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const form = createForm()
export default () => (
<FormProvider form={form}>
<SchemaField>
<SchemaField.Number
<SchemaField.Boolean
name="switch"
title="开关"
x-decorator="FormItem"
Expand Down Expand Up @@ -57,7 +57,7 @@ const schema = {
type: 'object',
properties: {
switch: {
type: 'number',
type: 'boolean',
title: '开关',
'x-decorator': 'FormItem',
'x-component': 'Switch',
Expand Down
7 changes: 6 additions & 1 deletion packages/antd/src/array-base/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,12 @@ ArrayBase.SortHandle = (props) => {

ArrayBase.Index = (props) => {
const index = useIndex()
return <span {...props}>#{index + 1}.</span>
const prefixCls = usePrefixCls('formily-array-base')
return (
<span {...props} className={`${prefixCls}-index`}>
#{index + 1}.
</span>
)
}

ArrayBase.Addition = (props) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default {
'x-component-props': { width: 100, title: '显隐->A2' },
properties: {
a1: {
type: 'string',
type: 'boolean',
'x-decorator': 'FormItem',
'x-component': 'Switch',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
bordered: false,
}"
/>
<SchemaStringField
<SchemaBooleanField
name="Switch"
title="Switch"
x-decorator="FormItem"
Expand Down
2 changes: 1 addition & 1 deletion packages/element/docs/demos/guide/form-item/inset.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
inset: true,
}"
/>
<SchemaStringField
<SchemaBooleanField
name="Switch"
title="Switch"
x-decorator="FormItem"
Expand Down
2 changes: 1 addition & 1 deletion packages/element/docs/demos/guide/form-item/size.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
x-component="InputNumber"
required
/>
<SchemaStringField
<SchemaBooleanField
name="Switch"
title="Switch"
x-decorator="FormItem"
Expand Down
2 changes: 1 addition & 1 deletion packages/next/docs/components/ArrayTable.md
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ const schema = {
'x-component-props': { width: 100, title: 'Explicitly hidden->A2' },
properties: {
a1: {
type: 'string',
type: 'boolean',
'x-decorator': 'FormItem',
'x-component': 'Switch',
},
Expand Down
2 changes: 1 addition & 1 deletion packages/next/docs/components/ArrayTable.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ const schema = {
'x-component-props': { width: 100, title: '显隐->A2' },
properties: {
a1: {
type: 'string',
type: 'boolean',
'x-decorator': 'FormItem',
'x-component': 'Switch',
},
Expand Down
6 changes: 3 additions & 3 deletions packages/next/docs/components/FormItem.md
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ export default () => {
bordered: false,
}}
/>
<SchemaField.String
<SchemaField.Boolean
name="Switch"
title="Switch"
x-decorator="FormItem"
Expand Down Expand Up @@ -616,7 +616,7 @@ export default () => {
inset: true,
}}
/>
<SchemaField.String
<SchemaField.Boolean
name="Switch"
title="Switch"
x-decorator="FormItem"
Expand Down Expand Up @@ -1023,7 +1023,7 @@ export default () => {
x-component="TreeSelect"
required
/>
<SchemaField.String
<SchemaField.Boolean
name="Switch"
title="Switch"
x-decorator="FormItem"
Expand Down
6 changes: 3 additions & 3 deletions packages/next/docs/components/FormItem.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ export default () => {
bordered: false,
}}
/>
<SchemaField.String
<SchemaField.Boolean
name="Switch"
title="Switch"
x-decorator="FormItem"
Expand Down Expand Up @@ -616,7 +616,7 @@ export default () => {
inset: true,
}}
/>
<SchemaField.String
<SchemaField.Boolean
name="Switch"
title="Switch"
x-decorator="FormItem"
Expand Down Expand Up @@ -1023,7 +1023,7 @@ export default () => {
x-component="TreeSelect"
required
/>
<SchemaField.String
<SchemaField.Boolean
name="Switch"
title="Switch"
x-decorator="FormItem"
Expand Down
4 changes: 2 additions & 2 deletions packages/next/docs/components/Switch.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const form = createForm()
export default () => (
<FormProvider form={form}>
<SchemaField>
<SchemaField.Number
<SchemaField.Boolean
name="switch"
title="Switch"
x-decorator="FormItem"
Expand Down Expand Up @@ -57,7 +57,7 @@ const schema = {
type: 'object',
properties: {
switch: {
type: 'number',
type: 'boolean',
title: 'Switch',
'x-decorator': 'FormItem',
'x-component': 'Switch',
Expand Down
4 changes: 2 additions & 2 deletions packages/next/docs/components/Switch.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const form = createForm()
export default () => (
<FormProvider form={form}>
<SchemaField>
<SchemaField.Number
<SchemaField.Boolean
name="switch"
title="开关"
x-decorator="FormItem"
Expand Down Expand Up @@ -57,7 +57,7 @@ const schema = {
type: 'object',
properties: {
switch: {
type: 'number',
type: 'boolean',
title: '开关',
'x-decorator': 'FormItem',
'x-component': 'Switch',
Expand Down
9 changes: 7 additions & 2 deletions packages/next/src/array-base/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,14 @@ ArrayBase.SortHandle = () => {
return <SortHandle />
}

ArrayBase.Index = () => {
ArrayBase.Index = (props) => {
const index = useIndex()
return <span>#{index + 1}.</span>
const prefixCls = usePrefixCls('formily-array-base')
return (
<span {...props} className={`${prefixCls}-index`}>
#{index + 1}.
</span>
)
}

ArrayBase.Addition = (props) => {
Expand Down

0 comments on commit 9f87569

Please sign in to comment.