Skip to content

Commit

Permalink
feat(generator): colorPicker add defaultValue configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
mengshang918 committed Mar 13, 2022
1 parent d1590df commit b896ef0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,19 @@ const PropertyConfig = () => {
}
}
break
case 'colorPicker':
if (key === 'ui.defaultValue') {
setFormData = true
fieldData = get('ui.defaultValue').data
generatorContext.current?.set(
selectedFieldKey || '',
'dataSchema',
(draft) => {
setDeepProp(['default'], draft as Map, data)
}
)
}
break
case 'timePicker':
case 'datePicker':
if (changeKey.startsWith('ui.placeholder__range')) {
Expand Down Expand Up @@ -239,7 +252,7 @@ const PropertyConfig = () => {
data = {}
}
}
if (changeKey.includes('ui.default')) {
if (key === 'ui.default') {
changeSchema = 'dataSchema'
// 在ajv校验时,如果formData中已经有值,则不再生成新的formData,需要set formData
setFormData = true
Expand Down
8 changes: 8 additions & 0 deletions packages/generator/src/fields/formItem/colorpicker.field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ const config: Field = {
type: 'switch',
},
},
{
fieldKey: 'defaultValue',
type: 'string',
title: '默认颜色',
ui: {
type: 'colorPicker',
},
},
],
},
}
Expand Down

0 comments on commit b896ef0

Please sign in to comment.