Skip to content

Commit

Permalink
feat: add view (#23)
Browse files Browse the repository at this point in the history
* feat: 一些修改

* feat: plugins 删除

* fix: 修复 scenes 逻辑

* feat: 添加 view

* feat: 修改 demo

* refactor: useSubmit 重构

* feat: submit 重构

* fix: test

* feat: 搜索场景完善

* fix: 修复 placeholder

* test: snap

* fix: 修复渲染 dom 样式问题 去掉 scens 参数

* feat: custom 支持 showType

* fix: 单选自定义 render

* test: 完善单元测试

* test: test

* feat: add flags

* test: test

* test: test

* test: test

* test: test

* test: test

* test: test

* test: test

* test: test

* test: test

* feat: 0.8.5

* feat: 添加日期区间

* test: remove _item_type

* feat: 添加初步对比功能

* feat: 开始做 isShow Function 判断

* feat: items 添加 isshow function

* feat: 如果字段是 undefined 则不需要执行 set 了

* fix: 修复值渲染问题

* fix: test

* fix: test

* feat: 代码优化

* fix:  List 透传 scenes

* refactor: format 修改为 2 个参数

* refactor: 删除 showType

* feat: 添加 modify

* feat: date 重构格式化方式

* feat: 完善基础 diff view

* fix: 修复报错抛出

* feat: test

* feat: list 处理参数

* fix: 修复会改 name 源数据

* feat: 优化代码

* feat: 开始做 ModalForm

* feat: 删除 required

* feat: 更新规则

* feat: 添加 space

* feat: 添加校验

* feat: 终于可以多层级有动态对比交互

* fix: test

* chore: 此方案不通,不太好

* feat: 完善 diff 逻辑

* chore: 删除未使用

* feat: vercel

Co-authored-by: crazyair <jianfeng.huang@yunzhanghu.com>
  • Loading branch information
crazyair and crazyair authored Jun 8, 2020
1 parent d9c4560 commit 0643144
Show file tree
Hide file tree
Showing 44 changed files with 1,303 additions and 492 deletions.
49 changes: 13 additions & 36 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,24 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'react-hooks'],
extends: ['airbnb-typescript', 'prettier/@typescript-eslint'],
plugins: ['react-hooks'],
extends: [require.resolve('@umijs/fabric/dist/eslint')],
rules: {
'react-hooks/rules-of-hooks': 'error', // 检查 Hook 的规则
'react-hooks/exhaustive-deps': 'error', // 检查 effect 的依赖
'jsx-a11y/heading-has-content': 0,
'react/destructuring-assignment': 0,
'react/prop-types': 0,
'jsx-a11y/label-has-associated-control': 0,
'arrow-body-style': 0,
'import/no-extraneous-dependencies': 0,
'no-param-reassign': 0,
'object-curly-newline': 0,
'import/prefer-default-export': 0,
'react/jsx-indent': 0,
'react/jsx-indent-props': 0,
'comma-dangle': 0,
'no-template-curly-in-string': 0,
'implicit-arrow-linebreak': 0,
'react/jsx-one-expression-per-line': 0,
'import/no-cycle': 0,
'import/no-unresolved': 0,
'no-underscore-dangle': 0,
'consistent-return': 0,
'max-len': 0,
'operator-linebreak': 0,
'no-shadow': 0,
'prefer-promise-reject-errors': 0,
'no-else-return': 0,
'import/no-extraneous-dependencies': 0,
'global-require': 0,
'import/no-dynamic-require': 0,
'react/sort-comp': 0,
'jsx-a11y/aria-role': 0,
'no-void': 0,
'no-param-reassign': 0,
'no-control-regex': 0,
'no-plusplus': 0,
'consistent-return': 0,
'no-template-curly-in-string': 0,
'prefer-promise-reject-errors': 0,
'no-lonely-if': 0,
'no-undef': 0,
'no-tabs': 0,
'no-mixed-spaces-and-tabs': 0,
'import/no-unresolved': [0],
'no-unused-expressions': 0,
'jsx-a11y/click-events-have-key-events': 0,
'jsx-a11y/anchor-is-valid': 0,
'jsx-a11y/no-static-element-interactions': 0,
'arrow-parens': 0,
'@typescript-eslint/camelcase': 0,
'no-shadow': 0,
},
};
2 changes: 1 addition & 1 deletion .github/workflows/now.yml → .github/workflows/vercel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
run: |
yarn
yarn doc:build
now --token=$ZEIT_TOKEN --prod --confirm --force
vercel --token=$ZEIT_TOKEN --prod --confirm --force
4 changes: 2 additions & 2 deletions docs/apis/hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default () => {

onFormatFieldsValue([
{ name: 'append_field', format: () => '追加字段' },
{ name: 'name', format: ({ name }) => `${name}_改变字段值` },
{ name: 'name', format: (value) => `${value}_改变字段值` },
]);

return (
Expand Down Expand Up @@ -104,7 +104,7 @@ export default () => {
return (
<>
<h4>{typeName}</h4>
<YForm {...layout} required onFinish={onFinish} submit={submit} params={{ type: 'create' }}>
<YForm {...layout} onFinish={onFinish} submit={submit} params={{ type: 'create' }}>
{[{ type: 'input', label: '姓名', name: 'name' }, { type: 'submit' }]}
</YForm>
</>
Expand Down
1 change: 0 additions & 1 deletion docs/apis/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ nav:
| -------- | ---------------- | -------------------------- | ------ |
| isShow | 是否渲染 | boolean | - |
| disabled | 字段是否全部禁用 | boolean | - |
| required | 字段是否全部必填 | boolean | - |
| children | 数据源 | YFormItemProps['children'] | - |

## YForm
Expand Down
20 changes: 12 additions & 8 deletions docs/examples/demo/demo1.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ const Demo = () => {
onSave={onSave}
scenes={{ view: disabled }}
params={{ type: 'view' }}
required
>
{[
// {
Expand Down Expand Up @@ -176,18 +175,23 @@ const Demo = () => {
{ label: '文本', name: 'text', type: 'text' },
{
label: '自定义渲染',
showType: 'input',
type: 'custom',
name: 'custom',
component: <Input />,
},
{ type: 'submit' },
{
type: 'button',
componentProps: {
onClick: () => message.success(JSON.stringify(form.getFormatFieldsValue())),
children: '获取提交前数据',
},
type: 'space',
items: [
{ type: 'submit' },
{
type: 'button',
noStyle: true,
componentProps: {
onClick: () => message.success(JSON.stringify(form.getFormatFieldsValue())),
children: '获取提交前数据',
},
},
],
},
]}
</YForm>
Expand Down
12 changes: 1 addition & 11 deletions docs/examples/demo/demo3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ const Demo: React.FC<RouteComponentProps> = () => {
console.log('Failed:', errorInfo);
};

const onSave = async (values: any) => {
console.log('values:', values);
};
return (
<>
<Button type="link" onClick={() => setVisible(true)}>
Expand All @@ -40,9 +37,7 @@ const Demo: React.FC<RouteComponentProps> = () => {
>
<YForm
{...layout}
required
onFinish={onFinish}
onSave={onSave}
onFinishFailed={onFinishFailed}
onCancel={handleCancel}
params={{ type: 'create' }}
Expand All @@ -51,12 +46,7 @@ const Demo: React.FC<RouteComponentProps> = () => {
{[{ type: 'input', name: 'age', label: '姓名' }]}
</YForm.Items>
<YForm.Items className="ant-modal-footer">
{[
{
type: 'submit',
componentProps: { reverseBtns: true, showBtns: { showSave: false } },
},
]}
{[{ type: 'submit', className: 'mb0', componentProps: { reverseBtns: true } }]}
</YForm.Items>
</YForm>
</Modal>
Expand Down
Loading

0 comments on commit 0643144

Please sign in to comment.