diff --git a/.umirc.ts b/.umirc.ts index 58d605a48a..d95910411a 100644 --- a/.umirc.ts +++ b/.umirc.ts @@ -20,7 +20,7 @@ export default defineConfig({ }, }, resolve: { - includes: ['docs'], + includes: ['docs', 'packages/client/src/schemas'], }, styles: [ ` diff --git a/docs/components/collection-fields/attachment.md b/docs/components/collection-fields/attachment.md index 67c539ad61..d8b9f68dc1 100644 --- a/docs/components/collection-fields/attachment.md +++ b/docs/components/collection-fields/attachment.md @@ -3,4 +3,57 @@ group: title: Collection Fields path: /components/collection-fields order: 3 ---- \ No newline at end of file +--- + +# Attachment - 附件 + +## Interface + +```ts +export const attachment: FieldOptions = { + name: 'attachment', + type: 'object', + group: 'media', + title: '附件', + isAssociation: true, + default: { + dataType: 'belongsToMany', + target: 'attachments', + // name, + uiSchema: { + type: 'array', + // title, + 'x-component': 'Upload.Attachment', + 'x-decorator': 'FormItem', + 'x-designable-bar': 'Upload.DesignableBar', + }, + }, + initialize: (values: any) => { + if (!values.through) { + values.through = `t_${uid()}`; + } + if (!values.foreignKey) { + values.foreignKey = `f_${uid()}`; + } + if (!values.otherKey) { + values.otherKey = `f_${uid()}`; + } + if (!values.sourceKey) { + values.sourceKey = 'id'; + } + if (!values.targetKey) { + values.targetKey = 'id'; + } + }, + properties: { + ...defaultProps, + 'uiSchema.x-component-props.multiple': { + type: 'boolean', + 'x-content': '允许上传多个文件', + 'x-decorator': 'FormItem', + 'x-component': 'Checkbox', + default: true, + }, + }, +}; +``` \ No newline at end of file diff --git a/docs/components/collection-fields/attachment.zh-CN.md b/docs/components/collection-fields/attachment.zh-CN.md index 61e2e596e9..e6ed53b64e 100644 --- a/docs/components/collection-fields/attachment.zh-CN.md +++ b/docs/components/collection-fields/attachment.zh-CN.md @@ -4,3 +4,56 @@ group: path: /zh-CN/components/collection-fields order: 3 --- + +# Attachment - 附件 + +## Interface + +```ts +export const attachment: FieldOptions = { + name: 'attachment', + type: 'object', + group: 'media', + title: '附件', + isAssociation: true, + default: { + dataType: 'belongsToMany', + target: 'attachments', + // name, + uiSchema: { + type: 'array', + // title, + 'x-component': 'Upload.Attachment', + 'x-decorator': 'FormItem', + 'x-designable-bar': 'Upload.DesignableBar', + }, + }, + initialize: (values: any) => { + if (!values.through) { + values.through = `t_${uid()}`; + } + if (!values.foreignKey) { + values.foreignKey = `f_${uid()}`; + } + if (!values.otherKey) { + values.otherKey = `f_${uid()}`; + } + if (!values.sourceKey) { + values.sourceKey = 'id'; + } + if (!values.targetKey) { + values.targetKey = 'id'; + } + }, + properties: { + ...defaultProps, + 'uiSchema.x-component-props.multiple': { + type: 'boolean', + 'x-content': '允许上传多个文件', + 'x-decorator': 'FormItem', + 'x-component': 'Checkbox', + default: true, + }, + }, +}; +``` \ No newline at end of file diff --git a/docs/components/collection-fields/checkbox-group.md b/docs/components/collection-fields/checkbox-group.md index e69de29bb2..457ffeb9f5 100644 --- a/docs/components/collection-fields/checkbox-group.md +++ b/docs/components/collection-fields/checkbox-group.md @@ -0,0 +1,30 @@ +# CheckboxGroup - 复选框 + +## Interface + +```ts +export const checkboxGroup: FieldOptions = { + name: 'checkboxGroup', + type: 'object', + group: 'choices', + order: 5, + title: '复选框', + default: { + interface: 'checkboxGroup', + dataType: 'json', + // name, + uiSchema: { + type: 'string', + // title, + 'x-component': 'Checkbox.Group', + 'x-decorator': 'FormItem', + 'x-designable-bar': 'Checkbox.Group.DesignableBar', + }, + }, + properties: { + ...defaultProps, + 'uiSchema.enum': dataSource, + }, + operations: multipleSelect.operations, +}; +``` \ No newline at end of file diff --git a/docs/components/collection-fields/checkbox.md b/docs/components/collection-fields/checkbox.md index e69de29bb2..82e230611a 100644 --- a/docs/components/collection-fields/checkbox.md +++ b/docs/components/collection-fields/checkbox.md @@ -0,0 +1,31 @@ +# Checkbox - 勾选 + +## Interface + +```ts +export const checkbox: FieldOptions = { + name: 'checkbox', + type: 'object', + group: 'choices', + order: 1, + title: '勾选', + default: { + dataType: 'boolean', + // name, + uiSchema: { + type: 'boolean', + // title, + 'x-component': 'Checkbox', + 'x-decorator': 'FormItem', + 'x-designable-bar': 'Checkbox.DesignableBar', + }, + }, + properties: { + ...defaultProps, + }, + operations: [ + { label: '是', value: '$isTruly', selected: true, noValue: true }, + { label: '否', value: '$isFalsy', noValue: true }, + ], +}; +``` \ No newline at end of file diff --git a/docs/components/collection-fields/china-region.md b/docs/components/collection-fields/china-region.md index e69de29bb2..1e3eb53eb9 100644 --- a/docs/components/collection-fields/china-region.md +++ b/docs/components/collection-fields/china-region.md @@ -0,0 +1,83 @@ +# ChinaRegion - 中国行政区 + +## Interface + +```ts +export const chinaRegion: FieldOptions = { + name: 'chinaRegion', + type: 'object', + group: 'choices', + order: 7, + title: '中国行政区划', + isAssociation: true, + default: { + dataType: 'belongsToMany', + target: 'china_regions', + targetKey: 'code', + // name, + uiSchema: { + type: 'array', + // title, + 'x-component': 'Cascader', + 'x-component-props': { + changeOnSelectLast: false, + loadData: '{{ ChinaRegion.loadData() }}', + labelInValue: true, + maxLevel: 3, + fieldNames: { + label: 'name', + value: 'code', + children: 'children', + }, + }, + 'x-reactions': [ + '{{ ChinaRegion.useFieldValue }}', + '{{ useAsyncDataSource(ChinaRegion.loadDataSource()) }}', + ], + 'x-decorator': 'FormItem', + 'x-designable-bar': 'Cascader.DesignableBar', + }, + }, + initialize: (values: any) => { + if (!values.through) { + values.through = `t_${uid()}`; + } + if (!values.foreignKey) { + values.foreignKey = `f_${uid()}`; + } + if (!values.otherKey) { + values.otherKey = `f_${uid()}`; + } + if (!values.sourceKey) { + values.sourceKey = 'id'; + } + if (!values.targetKey) { + values.targetKey = 'id'; + } + }, + properties: { + ...defaultProps, + 'uiSchema.x-component-props.maxLevel': { + type: 'number', + 'x-component': 'Radio.Group', + 'x-decorator': 'FormItem', + title: '可选择的层级', + default: 3, + enum: [ + { value: 1, label: '省' }, + { value: 2, label: '市' }, + { value: 3, label: '区/县' }, + { value: 4, label: '乡镇/街道' }, + { value: 5, label: '村/居委会' }, + ], + }, + 'uiSchema.x-component-props.changeOnSelectLast': { + type: 'boolean', + 'x-component': 'Checkbox', + 'x-content': '必须选到最后一级', + 'x-decorator': 'FormItem', + }, + }, + operations: [{ label: '等于', value: 'code.in' }], +}; +``` \ No newline at end of file diff --git a/docs/components/collection-fields/created-at.md b/docs/components/collection-fields/created-at.md index e69de29bb2..cc300897b3 100644 --- a/docs/components/collection-fields/created-at.md +++ b/docs/components/collection-fields/created-at.md @@ -0,0 +1,33 @@ +# CreatedAt - 添加时间 + +## Interface + +```ts +export const createdAt: FieldOptions = { + name: 'createdAt', + type: 'object', + group: 'systemInfo', + order: 1, + title: '添加时间', + sortable: true, + default: { + dataType: 'date', + field: 'created_at', + // name, + uiSchema: { + type: 'datetime', + title: '添加时间', + 'x-component': 'DatePicker', + 'x-component-props': {}, + 'x-read-pretty': true, + 'x-decorator': 'FormItem', + 'x-designable-bar': 'DatePicker.DesignableBar', + }, + }, + properties: { + ...defaultProps, + ...dateTimeProps, + }, + operations: datetime.operations, +}; +``` diff --git a/docs/components/collection-fields/created-by.md b/docs/components/collection-fields/created-by.md index e69de29bb2..8b08a57627 100644 --- a/docs/components/collection-fields/created-by.md +++ b/docs/components/collection-fields/created-by.md @@ -0,0 +1,37 @@ +# createdBy - 添加人 + +## Interface + +```ts +export const createdBy: FieldOptions = { + name: 'createdBy', + type: 'object', + group: 'systemInfo', + order: 3, + title: '添加人', + isAssociation: true, + default: { + dataType: 'belongsTo', + target: 'users', + foreignKey: 'created_by_id', + // name, + uiSchema: { + type: 'object', + title: '添加人', + 'x-component': 'Select.Drawer', + 'x-component-props': { + fieldNames: { + value: 'id', + label: 'nickname', + }, + }, + 'x-decorator': 'FormItem', + 'x-read-pretty': true, + 'x-designable-bar': 'Select.Drawer.DesignableBar', + }, + }, + properties: { + ...defaultProps, + }, +}; +``` \ No newline at end of file diff --git a/docs/components/collection-fields/datetime.md b/docs/components/collection-fields/datetime.md index e69de29bb2..7f27270f6a 100644 --- a/docs/components/collection-fields/datetime.md +++ b/docs/components/collection-fields/datetime.md @@ -0,0 +1,42 @@ +# Datetime - 日期 + +## Interface + +```ts +export const datetime: FieldOptions = { + name: 'datetime', + type: 'object', + group: 'datetime', + order: 1, + title: '日期', + sortable: true, + default: { + dataType: 'date', + // name, + uiSchema: { + type: 'datetime', + // title, + 'x-component': 'DatePicker', + 'x-component-props': { + showTime: false, + }, + 'x-decorator': 'FormItem', + 'x-designable-bar': 'DatePicker.DesignableBar', + }, + }, + properties: { + ...defaultProps, + ...dateTimeProps, + }, + operations: [ + { label: '等于', value: '$dateOn', selected: true }, + { label: '不等于', value: '$dateNotOn' }, + { label: '早于', value: '$dateBefore' }, + { label: '晚于', value: '$dateAfter' }, + { label: '不早于', value: '$dateNotBefore' }, + { label: '不晚于', value: '$dateNotAfter' }, + { label: '非空', value: '$notNull', noValue: true }, + { label: '为空', value: '$null', noValue: true }, + ], +}; +``` \ No newline at end of file diff --git a/docs/components/collection-fields/email.md b/docs/components/collection-fields/email.md index e69de29bb2..189565e9e6 100644 --- a/docs/components/collection-fields/email.md +++ b/docs/components/collection-fields/email.md @@ -0,0 +1,30 @@ +# Email - 电子邮箱 + +## Interface + +```ts +export const email: FieldOptions = { + name: 'email', + type: 'object', + group: 'basic', + order: 4, + title: '电子邮箱', + sortable: true, + default: { + dataType: 'string', + // name, + uiSchema: { + type: 'string', + // title, + 'x-component': 'Input', + 'x-decorator': 'FormItem', + 'x-validator': 'email', + 'x-designable-bar': 'Input.DesignableBar', + }, + }, + properties: { + ...defaultProps, + }, + operations: string.operations, +}; +``` \ No newline at end of file diff --git a/docs/components/collection-fields/icon.md b/docs/components/collection-fields/icon.md index e69de29bb2..b7f6b62242 100644 --- a/docs/components/collection-fields/icon.md +++ b/docs/components/collection-fields/icon.md @@ -0,0 +1,27 @@ +# Icon - 图标 + +## Interface + +```ts +export const icon: FieldOptions = { + name: 'icon', + type: 'object', + group: 'basic', + order: 8, + title: '图标', + default: { + dataType: 'string', + // name, + uiSchema: { + type: 'string', + // title, + 'x-component': 'IconPicker', + 'x-decorator': 'FormItem', + 'x-designable-bar': 'IconPicker.DesignableBar', + }, + }, + properties: { + ...defaultProps, + }, +}; +``` \ No newline at end of file diff --git a/docs/components/collection-fields/link-to.md b/docs/components/collection-fields/link-to.md index e69de29bb2..7a8ee4e41a 100644 --- a/docs/components/collection-fields/link-to.md +++ b/docs/components/collection-fields/link-to.md @@ -0,0 +1,70 @@ +# LinkTo - 关联字段 + +## Interface + +```ts +export const linkTo: FieldOptions = { + name: 'linkTo', + type: 'object', + group: 'relation', + order: 1, + title: '关联字段', + isAssociation: true, + default: { + dataType: 'belongsToMany', + // name, + uiSchema: { + type: 'array', + // title, + 'x-component': 'Select.Drawer', + 'x-component-props': {}, + 'x-decorator': 'FormItem', + 'x-designable-bar': 'Select.Drawer.DesignableBar', + }, + }, + initialize: (values: any) => { + if (values.dataType === 'belongsToMany') { + if (!values.through) { + values.through = `t_${uid()}`; + } + if (!values.foreignKey) { + values.foreignKey = `f_${uid()}`; + } + if (!values.otherKey) { + values.otherKey = `f_${uid()}`; + } + if (!values.sourceKey) { + values.sourceKey = 'id'; + } + if (!values.targetKey) { + values.targetKey = 'id'; + } + } + }, + properties: { + ...defaultProps, + target: { + type: 'string', + title: '要关联的数据表', + required: true, + 'x-reactions': ['{{useAsyncDataSource(loadCollections)}}'], + 'x-decorator': 'FormItem', + 'x-component': 'Select', + }, + // 'uiSchema.x-component-props.fieldNames.label': { + // type: 'string', + // title: '要显示的标题字段', + // required: true, + // 'x-reactions': ['{{useAsyncDataSource(loadCollectionFields)}}'], + // 'x-decorator': 'FormItem', + // 'x-component': 'Select', + // }, + 'uiSchema.x-component-props.multiple': { + type: 'boolean', + 'x-content': '允许关联多条记录', + 'x-decorator': 'FormItem', + 'x-component': 'Checkbox', + }, + }, +}; +``` \ No newline at end of file diff --git a/docs/components/collection-fields/markdown.md b/docs/components/collection-fields/markdown.md index e69de29bb2..5d4842d769 100644 --- a/docs/components/collection-fields/markdown.md +++ b/docs/components/collection-fields/markdown.md @@ -0,0 +1,26 @@ +# Markdown + +## Interface + +```ts +export const markdown: FieldOptions = { + name: 'markdown', + type: 'object', + title: 'Markdown', + group: 'media', + default: { + dataType: 'text', + // name, + uiSchema: { + type: 'string', + // title, + 'x-component': 'Markdown', + 'x-decorator': 'FormItem', + 'x-designable-bar': 'Markdown.DesignableBar', + }, + }, + properties: { + ...defaultProps, + }, +}; +``` \ No newline at end of file diff --git a/docs/components/collection-fields/multiple-select.md b/docs/components/collection-fields/multiple-select.md index e69de29bb2..7f802a9465 100644 --- a/docs/components/collection-fields/multiple-select.md +++ b/docs/components/collection-fields/multiple-select.md @@ -0,0 +1,49 @@ +# MultipleSelect - 下拉选择(多选) + +## Interface + +```ts +export const multipleSelect: FieldOptions = { + name: 'multipleSelect', + type: 'object', + group: 'choices', + order: 3, + title: '下拉选择(多选)', + default: { + dataType: 'json', + // name, + uiSchema: { + type: 'array', + // title, + 'x-component': 'Select', + 'x-component-props': { + mode: 'multiple', + }, + 'x-decorator': 'FormItem', + 'x-designable-bar': 'Select.DesignableBar', + enum: [], + }, + }, + properties: { + ...defaultProps, + 'uiSchema.enum': dataSource, + }, + operations: [ + { + label: '等于', + value: '$match', + selected: true, + schema: { 'x-component': 'Select' }, + }, + { + label: '不等于', + value: '$notMatch', + schema: { 'x-component': 'Select' }, + }, + { label: '包含', value: '$anyOf', schema: { 'x-component': 'Select' } }, + { label: '不包含', value: '$noneOf', schema: { 'x-component': 'Select' } }, + { label: '非空', value: '$notNull', noValue: true }, + { label: '为空', value: '$null', noValue: true }, + ], +}; +``` \ No newline at end of file diff --git a/docs/components/collection-fields/number.md b/docs/components/collection-fields/number.md index e69de29bb2..f17328a483 100644 --- a/docs/components/collection-fields/number.md +++ b/docs/components/collection-fields/number.md @@ -0,0 +1,58 @@ +# Number - 数字 + +## Interface + +```ts +export const number: FieldOptions = { + name: 'number', + type: 'object', + group: 'basic', + order: 5, + title: '数字', + sortable: true, + default: { + dataType: 'float', + // name, + uiSchema: { + type: 'number', + // title, + 'x-component': 'InputNumber', + 'x-component-props': { + stringMode: true, + step: '0', + }, + 'x-decorator': 'FormItem', + 'x-designable-bar': 'InputNumber.DesignableBar', + }, + }, + properties: { + ...defaultProps, + 'uiSchema.x-component-props.step': { + type: 'string', + title: '精度', + 'x-component': 'Select', + 'x-decorator': 'FormItem', + default: '0', + enum: [ + { value: '0', label: '1' }, + { value: '0.1', label: '1.0' }, + { value: '0.01', label: '1.00' }, + { value: '0.001', label: '1.000' }, + { value: '0.0001', label: '1.0000' }, + { value: '0.00001', label: '1.00000' }, + ], + }, + }, + operations: [ + { label: '等于', value: 'eq', selected: true }, + { label: '不等于', value: 'ne' }, + { label: '大于', value: 'gt' }, + { label: '大于等于', value: 'gte' }, + { label: '小于', value: 'lt' }, + { label: '小于等于', value: 'lte' }, + // {label: '介于', value: 'between'}, + { label: '非空', value: '$notNull', noValue: true }, + { label: '为空', value: '$null', noValue: true }, + ], +}; +``` \ No newline at end of file diff --git a/docs/components/collection-fields/password.md b/docs/components/collection-fields/password.md index e69de29bb2..d43d5e495d 100644 --- a/docs/components/collection-fields/password.md +++ b/docs/components/collection-fields/password.md @@ -0,0 +1,27 @@ +# Password - 密码 + +## Interface + +```ts +export const password: FieldOptions = { + name: 'password', + type: 'object', + group: 'basic', + order: 7, + title: '密码', + default: { + dataType: 'password', + // name, + uiSchema: { + type: 'string', + // title, + 'x-component': 'Password', + 'x-decorator': 'FormItem', + 'x-designable-bar': 'Password.DesignableBar', + }, + }, + properties: { + ...defaultProps, + }, +}; +``` \ No newline at end of file diff --git a/docs/components/collection-fields/percent.md b/docs/components/collection-fields/percent.md index e69de29bb2..e2c7bd98b7 100644 --- a/docs/components/collection-fields/percent.md +++ b/docs/components/collection-fields/percent.md @@ -0,0 +1,49 @@ +# Percent - 百分比 + +## Interface + +```ts +export const percent: FieldOptions = { + name: 'percent', + type: 'object', + group: 'basic', + order: 6, + title: '百分比', + sortable: true, + default: { + dataType: 'float', + // name, + uiSchema: { + type: 'string', + // title, + 'x-component': 'InputNumber', + 'x-component-props': { + stringMode: true, + step: '0', + addonAfter: '%', + }, + 'x-decorator': 'FormItem', + 'x-designable-bar': 'InputNumber.DesignableBar', + }, + }, + properties: { + ...defaultProps, + 'uiSchema.x-component-props.step': { + type: 'string', + title: '精度', + 'x-component': 'Select', + 'x-decorator': 'FormItem', + default: '0', + enum: [ + { value: '0', label: '1' }, + { value: '0.1', label: '1.0' }, + { value: '0.01', label: '1.00' }, + { value: '0.001', label: '1.000' }, + { value: '0.0001', label: '1.0000' }, + { value: '0.00001', label: '1.00000' }, + ], + }, + }, + operations: number.operations, +}; +``` \ No newline at end of file diff --git a/docs/components/collection-fields/phone.md b/docs/components/collection-fields/phone.md index e69de29bb2..064756b493 100644 --- a/docs/components/collection-fields/phone.md +++ b/docs/components/collection-fields/phone.md @@ -0,0 +1,30 @@ +# Phone - 手机号码 + +## Interface + +```ts +export const phone: FieldOptions = { + name: 'phone', + type: 'object', + group: 'basic', + order: 3, + title: '手机号码', + sortable: true, + default: { + dataType: 'string', + // name, + uiSchema: { + type: 'string', + // title, + 'x-component': 'Input', + 'x-decorator': 'FormItem', + 'x-validator': 'phone', + 'x-designable-bar': 'Input.DesignableBar', + }, + }, + properties: { + ...defaultProps, + }, + operations: string.operations, +}; +``` \ No newline at end of file diff --git a/docs/components/collection-fields/radio-group.md b/docs/components/collection-fields/radio-group.md index e69de29bb2..a6650b1762 100644 --- a/docs/components/collection-fields/radio-group.md +++ b/docs/components/collection-fields/radio-group.md @@ -0,0 +1,29 @@ +# RadioGroup - 单选框 + +## Interface + +```ts +export const radioGroup: FieldOptions = { + name: 'radioGroup', + type: 'object', + group: 'choices', + order: 4, + title: '单选框', + default: { + dataType: 'string', + // name, + uiSchema: { + type: 'string', + // title, + 'x-component': 'Radio.Group', + 'x-decorator': 'FormItem', + 'x-designable-bar': 'Radio.DesignableBar', + }, + }, + properties: { + ...defaultProps, + 'uiSchema.enum': dataSource, + }, + operations: select.operations, +}; +``` \ No newline at end of file diff --git a/docs/components/collection-fields/select.md b/docs/components/collection-fields/select.md index e69de29bb2..e2c615c065 100644 --- a/docs/components/collection-fields/select.md +++ b/docs/components/collection-fields/select.md @@ -0,0 +1,56 @@ +# Select - 下拉选择(单选) + +## Interface + +```ts +export const select: FieldOptions = { + name: 'select', + type: 'object', + group: 'choices', + order: 2, + title: '下拉选择(单选)', + default: { + dataType: 'string', + // name, + uiSchema: { + type: 'string', + // title, + 'x-component': 'Select', + 'x-decorator': 'FormItem', + 'x-designable-bar': 'Select.DesignableBar', + enum: [], + }, + }, + properties: { + ...defaultProps, + 'uiSchema.enum': dataSource, + }, + operations: [ + { + label: '等于', + value: 'eq', + selected: true, + schema: { 'x-component': 'Select' }, + }, + { label: '不等于', value: 'ne', schema: { 'x-component': 'Select' } }, + { + label: '包含', + value: 'in', + schema: { + 'x-component': 'Select', + 'x-component-props': { mode: 'tags' }, + }, + }, + { + label: '不包含', + value: 'notIn', + schema: { + 'x-component': 'Select', + 'x-component-props': { mode: 'tags' }, + }, + }, + { label: '非空', value: '$notNull', noValue: true }, + { label: '为空', value: '$null', noValue: true }, + ], +}; +``` \ No newline at end of file diff --git a/docs/components/collection-fields/string.md b/docs/components/collection-fields/string.md index f1535c8bd4..db4160f11b 100644 --- a/docs/components/collection-fields/string.md +++ b/docs/components/collection-fields/string.md @@ -1,4 +1,37 @@ ---- -group: - path: /components/collection-fields ---- +# String - 单行文本 + +## Interface + +```ts +export const string: FieldOptions = { + name: 'string', + type: 'object', + group: 'basic', + order: 1, + title: '单行文本', + sortable: true, + default: { + interface: 'string', + dataType: 'string', + // name, + uiSchema: { + type: 'string', + // title, + 'x-component': 'Input', + 'x-decorator': 'FormItem', + 'x-designable-bar': 'Input.DesignableBar', + }, + }, + properties: { + ...defaultProps, + }, + operations: [ + { label: '包含', value: '$includes', selected: true }, + { label: '不包含', value: '$notIncludes' }, + { label: '等于', value: 'eq' }, + { label: '不等于', value: 'ne' }, + { label: '非空', value: '$notNull', noValue: true }, + { label: '为空', value: '$null', noValue: true }, + ], +}; +``` \ No newline at end of file diff --git a/docs/components/collection-fields/sub-table.md b/docs/components/collection-fields/sub-table.md index e69de29bb2..69197482c8 100644 --- a/docs/components/collection-fields/sub-table.md +++ b/docs/components/collection-fields/sub-table.md @@ -0,0 +1,45 @@ +# SubTable - 子表格 + +## Interface + +```ts +export const subTable: FieldOptions = { + name: 'subTable', + type: 'object', + group: 'relation', + order: 2, + title: '子表格', + isAssociation: true, + disabled: true, + default: { + dataType: 'hasMany', + // name, + uiSchema: { + type: 'array', + // title, + 'x-decorator': 'FormItem', + 'x-component': 'Table', + 'x-component-props': {}, + 'x-designable-bar': 'Table.DesignableBar', + enum: [], + }, + }, + initialize: (values: any) => { + if (!values.target) { + values.target = `t_${uid()}`; + } + if (!values.foreignKey) { + values.foreignKey = `f_${uid()}`; + } + }, + properties: { + ...defaultProps, + children: { + type: 'array', + title: '子表格字段', + 'x-decorator': 'FormItem', + 'x-component': 'DatabaseField', + }, + }, +}; +``` \ No newline at end of file diff --git a/docs/components/collection-fields/textarea.md b/docs/components/collection-fields/textarea.md index e69de29bb2..1e42188f88 100644 --- a/docs/components/collection-fields/textarea.md +++ b/docs/components/collection-fields/textarea.md @@ -0,0 +1,27 @@ +# TextArea - 多行文本 + +## Interface + +```ts +export const textarea: FieldOptions = { + name: 'textarea', + type: 'object', + group: 'basic', + order: 2, + title: '多行文本', + default: { + dataType: 'text', + // name, + uiSchema: { + type: 'string', + // title, + 'x-decorator': 'FormItem', + 'x-component': 'Input.TextArea', + 'x-designable-bar': 'Input.DesignableBar', + }, + }, + properties: { + ...defaultProps, + }, +}; +``` \ No newline at end of file diff --git a/docs/components/collection-fields/time.md b/docs/components/collection-fields/time.md index e69de29bb2..8b5c72c87e 100644 --- a/docs/components/collection-fields/time.md +++ b/docs/components/collection-fields/time.md @@ -0,0 +1,55 @@ +# Time - 时间 + +## Interface + +```ts +export const time: FieldOptions = { + name: 'time', + type: 'object', + group: 'datetime', + order: 2, + title: '时间', + sortable: true, + default: { + dataType: 'time', + // name, + uiSchema: { + type: 'string', + // title, + 'x-component': 'TimePicker', + 'x-decorator': 'FormItem', + 'x-designable-bar': 'TimePicker.DesignableBar', + }, + }, + properties: { + ...defaultProps, + 'uiSchema.x-component-props.format': { + type: 'string', + title: '时间格式', + 'x-component': 'Radio.Group', + 'x-decorator': 'FormItem', + default: 'HH:mm:ss', + enum: [ + { + label: '24小时制', + value: 'HH:mm:ss', + }, + { + label: '12小时制', + value: 'hh:mm:ss a', + }, + ], + }, + }, + operations: [ + { label: '等于', value: 'eq', selected: true }, + { label: '不等于', value: 'neq' }, + { label: '大于', value: 'gt' }, + { label: '大于等于', value: 'gte' }, + { label: '小于', value: 'lt' }, + { label: '小于等于', value: 'lte' }, + { label: '非空', value: '$notNull', noValue: true }, + { label: '为空', value: '$null', noValue: true }, + ], +}; +``` \ No newline at end of file diff --git a/docs/components/collection-fields/updated-at.md b/docs/components/collection-fields/updated-at.md index e69de29bb2..4f50efb3b3 100644 --- a/docs/components/collection-fields/updated-at.md +++ b/docs/components/collection-fields/updated-at.md @@ -0,0 +1,33 @@ +# UpdatedAt - 最后更新时间 + +## Interface + +```ts +export const updatedAt: FieldOptions = { + name: 'updatedAt', + type: 'object', + group: 'systemInfo', + order: 2, + title: '最后更新时间', + sortable: true, + default: { + dataType: 'date', + field: 'updated_at', + // name, + uiSchema: { + type: 'datetime', + title: '最后更新时间', + 'x-component': 'DatePicker', + 'x-component-props': {}, + 'x-read-pretty': true, + 'x-decorator': 'FormItem', + 'x-designable-bar': 'DatePicker.DesignableBar', + }, + }, + properties: { + ...defaultProps, + ...dateTimeProps, + }, + operations: datetime.operations, +}; +``` \ No newline at end of file diff --git a/docs/components/collection-fields/updated-by.md b/docs/components/collection-fields/updated-by.md index e69de29bb2..c2956db4a9 100644 --- a/docs/components/collection-fields/updated-by.md +++ b/docs/components/collection-fields/updated-by.md @@ -0,0 +1,37 @@ +# UpdatedBy - 最后修改人 + +## Interface + +```ts +export const updatedBy: FieldOptions = { + name: 'updatedBy', + type: 'object', + group: 'systemInfo', + order: 4, + title: '最后修改人', + isAssociation: true, + default: { + dataType: 'belongsTo', + target: 'users', + foreignKey: 'updated_by_id', + // name, + uiSchema: { + type: 'object', + title: '最后修改人', + 'x-component': 'Select.Drawer', + 'x-component-props': { + fieldNames: { + value: 'id', + label: 'nickname', + }, + }, + 'x-decorator': 'FormItem', + 'x-read-pretty': true, + 'x-designable-bar': 'Select.Drawer.DesignableBar', + }, + }, + properties: { + ...defaultProps, + }, +}; +``` \ No newline at end of file diff --git a/docs/components/index.md b/docs/components/index.md index 8738c363f2..c703c2c65b 100644 --- a/docs/components/index.md +++ b/docs/components/index.md @@ -13,3 +13,89 @@ There are a total of three types of client components for NocoBase. - Routing components created by createRouteSwitch, such as Layou, Page - Field components created by createCollectionField, which are used to extend fields - JSON Schema components created by createSchemaComponent, which can be anything, such as tables, forms, calendars, kanban, etc. Schema Component can be used in Route Component or Collection Field. + +## Route Components + +```js + +function Hello() { + return
-////////// 单节点 //////////
-
-// 常规按钮操作
-
-// 内链
-
-// 外链
-
-
-////////// 弹出层相关操作 //////////
-
-// 对话框
-
-
- // 添加其他节点
-
-
-
-// 抽屉
-
-
- // 添加其他节点
-
-
-
-// 气泡
-
-
- // 添加其他节点
-
-
-
-// 指定容器
-
-
- // 添加其他节点
-
-
-
-////////// 操作分组 //////////
-
-// 下拉操作
-
-
-
-
- // 添加其他节点
-
-
-
-
-
-## Designable Bar
-
-- Action.DesignableBar
-- Action.Modal.DesignableBar
-- Action.Drawer.DesignableBar
-- Action.Popover.DesignableBar
-
-## Examples
-
-### Action
-
-```tsx
-/**
- * title: 按钮操作
- * desc: 可以通过配置 `useAction` 来处理操作逻辑
- */
-import React from 'react';
-// @ts-ignore
-import { SchemaRenderer } from '@nocobase/client';
-
-function useAction() {
- return {
- run() {
- alert('这是自定义的操作逻辑');
- },
- };
-}
-
-const schema = {
- type: 'void',
- name: 'action1',
- title: '按钮',
- 'x-component': 'Action',
- 'x-designable-bar': 'Action.DesignableBar',
- 'x-component-props': {
- useAction: '{{ useAction }}',
- tooltip: '提示信息',
- confirm: {
- title: 'Do you Want to delete these items?',
- },
- },
-};
-
-export default () => {
- return (
-