Skip to content

Commit

Permalink
feat: ✨ 提交构建修改
Browse files Browse the repository at this point in the history
  • Loading branch information
G committed Dec 13, 2023
1 parent 27768c3 commit b565ae7
Show file tree
Hide file tree
Showing 50 changed files with 11,593 additions and 4,713 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ dist-ssr
.env
.cache
server/dist
public/dist
public/dist
es
lib
33 changes: 22 additions & 11 deletions packages/gbeata/.fatherrc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,26 @@ import { defineConfig } from 'father';

export default defineConfig({
// more father config: https://github.com/umijs/father/blob/master/docs/config.md
esm: { output: 'dist' },
extraBabelPlugins: [
[
'babel-plugin-import',
{
libraryName: 'antd',
libraryDirectory: 'es',
style: true,
},
],
],
cjs: {
output: 'lib',
// input: 'src/index.ts',
},
esm: {
output: 'es',
// input: 'src/index.ts',
},
umd: {
output: 'dist',
entry: 'src/index.ts',
},
// extraBabelPlugins: [
// [
// 'babel-plugin-import',
// {
// libraryName: 'antd',
// libraryDirectory: 'es',
// style: true,
// },
// ],
// ],
});
8 changes: 4 additions & 4 deletions packages/gbeata/docs/components/EditTable.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ order: 2

```js
// 需要设置先设置表格的编辑模式
<MwSearchTable editMode="col" />
<GSearchTable editMode="col" />
```

## 可编辑行
Expand All @@ -21,7 +21,7 @@ order: 2

```js
// 需要设置先设置表格的编辑模式
<MwSearchTable editMode="row" />
<GSearchTable editMode="row" />
```

## editable
Expand All @@ -41,10 +41,10 @@ order: 2
扩展一个简易版的 number 类型编辑框。

```js
import { registerTableRender, RenderProps } from 'multiway'
import { registerTableRender, RenderProps } from 'gbeata'
import { InputNumber } from 'antd'

// 全局注册一次,放在全局 /multiway/index.tsx 里面
// 全局注册一次,放在全局 /gbeata/index.tsx 里面
registerTableRender('editable-cell-number', ({ text, field }: RenderProps) => {
return ({ editing, mode, save }: AnyKeyProps) => {
return !editing ? text : <InputNumber {...field.contentProps} onBlur={save} />
Expand Down
2 changes: 1 addition & 1 deletion packages/gbeata/docs/components/RegisterFieldDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import CharaSelect from './CharaSelect';

// 注册自定义类型表单项
// 注册一个角色选择
// 这段代码放在 /src/multiway/index 下面
// 这段代码放在 /src/gbeata/index 下面
registerField('chara-select', {
type: 'chara-select',
defaultValue: '',
Expand Down
6 changes: 3 additions & 3 deletions packages/gbeata/docs/components/registerAction.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ group: 全局配置

# 注册 action 事件

这个页面的代码是写在 `/src/multiway/index.tsx` 文件里的,如果你还没有,可点击 [这里](../) 查看如何创建。
这个页面的代码是写在 `/src/gbeata/index.tsx` 文件里的,如果你还没有,可点击 [这里](../) 查看如何创建。

## registerAction

Expand Down Expand Up @@ -108,7 +108,7 @@ registerAction('actionName', (props, record, searchTable) => {

## 覆盖默认实现

multiway 自带 action:
gbeata 自带 action:

1. view: 查看
2. update: 修改
Expand All @@ -118,7 +118,7 @@ multiway 自带 action:

你可以注册同名的 action 来覆盖原本的实现。

自带的 action: https://github.com/viewweiwu/multiway/blob/master/src/gAction/index.tsx
自带的 action: https://github.com/viewweiwu/gbeata/blob/master/src/gAction/index.tsx

```js
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/gbeata/docs/components/registerField.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ group: 全局配置
* @desc render 函数参数
* @desc render 出来组件需要支持组件受控
* @param field 当前表单项
* @param setFieldsValue 设置表单值,MwForm 的 setFieldsValue
* @param setFieldsValue 设置表单值,GForm 的 setFieldsValue
* @param getFieldValue 获取某个表单项的值
* @param readonly 是否只读
* @param formInstans 可以调用表单方法
Expand Down
2 changes: 1 addition & 1 deletion packages/gbeata/docs/components/setDefaultDataFilter.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const listApi = () => axios.get('/some/list')

```

如果接口放回的格式是上面的格式,请把下面的配置文件复制到 `/src/multiway/index.tsx` 下。
如果接口放回的格式是上面的格式,请把下面的配置文件复制到 `/src/gbeata/index.tsx` 下。

```js
import { setDefaultDataFilter } from 'gbeata';
Expand Down
18 changes: 9 additions & 9 deletions packages/gbeata/docs/components/setPermissionList.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ group: 全局配置

# 按钮权限控制

此参数用于控制 MwButton 或者 MwAction 的展示权限。
此参数用于控制 GButton 或者 GAction 的展示权限。

```tsx
import React from 'react';
import { MwButton, MwCtrl, MwAction, setPermissionList } from 'multiway';
import { GButton, GCtrl, GAction, setPermissionList } from 'gbeata';
import { Space } from 'antd';

export default function Demo() {
Expand All @@ -23,22 +23,22 @@ export default function Demo() {
return (
<>
<Space>
<MwButton onClick={addPermission}>设置权限</MwButton>
<MwButton onClick={clearPermission}>清空权限</MwButton>
<GButton onClick={addPermission}>设置权限</GButton>
<GButton onClick={clearPermission}>清空权限</GButton>
</Space>
<div style={{ marginTop: 12 }}>
<MwButton permission="delete">删除</MwButton>
<MwCtrl>
<MwAction permission="delete">删除</MwAction>
</MwCtrl>
<GButton permission="delete">删除</GButton>
<GCtrl>
<GAction permission="delete">删除</GAction>
</GCtrl>
</div>
</>
);
}
```

```js
import { setPermissionList } from 'multiway';
import { setPermissionList } from 'gbeata';

const addPermission = () => {
setPermissionList(['delete']);
Expand Down
4 changes: 3 additions & 1 deletion packages/gbeata/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
"dependencies": {
"@minko-fe/use-antd-resizable-header": "^2.9.0",
"dumi-theme-antd-style": "^0.29.7",
"moment": "^2.29.4"
"moment": "^2.29.4",
"@ant-design/icons": "^5.2.6",
"antd": "^5.12.1"
},
"devDependencies": {
"@commitlint/cli": "^17.1.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/gbeata/src/GAction/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ registerAction('editable-delete', (props, record, searchTable) => {
onConfirm: () => {
const key = getKey(record, searchTable?.rowKey);
searchTable.tableRef.current.deleteRowByKey(key);
props.callback && props.callback(key);
props.callback?.(key);
},
...props,
};
Expand All @@ -334,7 +334,7 @@ registerAction('editable-add', (props, _record, searchTable) => {
},
onClick: () => {
searchTable.tableRef.current.addRow({
[getRowKey({}, searchTable?.rowKey)]: Date.now(),
[getRowKey({}, searchTable?.rowKey) as any]: Date.now(),
// 正在编辑
editing: true,
// 新增标识
Expand Down
4 changes: 2 additions & 2 deletions packages/gbeata/src/GButton/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GButtonProps } from './g-button';

declare const MwButton: React.ForwardRefExoticComponent<
declare const GButton: React.ForwardRefExoticComponent<
GButtonProps & React.RefAttributes<HTMLDivElement>
>;

export default MwButton;
export default GButton;
4 changes: 2 additions & 2 deletions packages/gbeata/src/GCtrl/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GCtrlProps } from './g-ctrl';

declare const MwCtrl: React.ForwardRefExoticComponent<
declare const GCtrl: React.ForwardRefExoticComponent<
GCtrlProps & React.RefAttributes<HTMLDivElement>
>;

export default MwCtrl;
export default GCtrl;
8 changes: 4 additions & 4 deletions packages/gbeata/src/GCtrl/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Divider, Dropdown, Menu, Space } from 'antd';
import classNames from 'classnames';
import React, { ReactNode, useEffect, useState } from 'react';
import GAction from '../GAction';
import MwButton, { addRefresh, hasPermission } from '../GButton';
import GButton, { addRefresh, hasPermission } from '../GButton';
import { CTRL_DEFAULT_MAX, CTRL_DEFAULT_MORE_TEXT } from '../constant';
import locale from '../locale';
import { AnyKeyProps } from '../types/AnyKeyProps';
Expand All @@ -27,7 +27,7 @@ const getCtrlItem = (node: any, key?: any, defaultProps?: AnyKeyProps) => {
};

/**
* 将子节点转化成 MwAction 按钮
* 将子节点转化成 GAction 按钮
* @param children 子节点
*/
const getCtrlList = (
Expand Down Expand Up @@ -99,9 +99,9 @@ const getCtrlList = (

ctrlList.push(
<Dropdown key={max} overlay={menu} placement="bottomRight">
<MwButton type="link" className={classNames('mw-button', sub && 'sub')}>
<GButton type="link" className={classNames('mw-button', sub && 'sub')}>
{more}
</MwButton>
</GButton>
</Dropdown>,
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/gbeata/src/GDialog/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { default as MwDialog } from './g-dialog';
export { default as GDialog } from './g-dialog';

import { GDialogProps } from './g-dialog';

Expand Down
2 changes: 1 addition & 1 deletion packages/gbeata/src/GDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const setGlobalDialogField = (cb: () => ModalProps) => {
defaultProps = { ...cb(), ...defaultProps };
};

export default function MwDialog(props: GDialogProps) {
export default function GDialog(props: GDialogProps) {
const {
title,
titleBefore,
Expand Down
4 changes: 2 additions & 2 deletions packages/gbeata/src/GDialogForm/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { GDialogFormProps } from './g-dialog-form';

declare const MwDialogForm: React.ForwardRefExoticComponent<
declare const GDialogForm: React.ForwardRefExoticComponent<
GDialogFormProps & React.RefAttributes<HTMLDivElement>
>;

export default MwDialogForm;
export default GDialogForm;
10 changes: 5 additions & 5 deletions packages/gbeata/src/GDialogForm/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ export default function AyDialogFormDemo() {

## 另一种使用方式

gbeata 提供了另一种使用方式,通过 add()、update()、view() 方法,可以减少声明 `state` 的声明,在 `MwSearchTable` 里,内嵌的 `GDialogForm` 也默认的是此使用方式。
gbeata 提供了另一种使用方式,通过 add()、update()、view() 方法,可以减少声明 `state` 的声明,在 `GSearchTable` 里,内嵌的 `GDialogForm` 也默认的是此使用方式。

```tsx
import React, { useRef } from 'react';
Expand Down Expand Up @@ -584,13 +584,13 @@ export default function AyDialogFormDemo() {
| name | 弹窗名字,一般不需要设置。 | string | - | - |
| width | 弹窗宽度。 | number | - | - |
| span | 每个 Field 所占的 span 值。 | number | 24 | - |
| fields | 表单项,跟 MwForm 一致。 | Array[MwFormField] | - | - |
| fields | 表单项,跟 GForm 一致。 | Array[GFormField] | - | - |
| addApi | 进入编辑模式。 | Promise | - | - |
| updateApi | 进出详情模式。 | Promise | - | - |
| beforeSubmit | 表单的提交前校验,return false 则不会提交。 | (params?: AnyKeyProps, mode?: string) => boolean \| obejct | - | - |
| dialogOnly | 是否只使用申明了 dialog 的 Field。 | boolean | false | - |
| dialogExtend | [MwDialog](../mw-dialog#参数) 的扩展值。 | object | - | - |
| formExtend | [MwForm](../form#props-参数) 的扩展值。 | object | - | - |
| dialogExtend | [GDialog](../mw-dialog#参数) 的扩展值。 | object | - | - |
| formExtend | [GForm](../form#props-参数) 的扩展值。 | object | - | - |
| autoClose | 成功后是否自动关闭弹窗。 | boolean | true | - |
| drawer | 是否用 Drawer 替换 Modal。 | boolean | false | - |
| visible | 弹窗是否可见。 | boolean | false | 0.1.0 |
Expand All @@ -610,7 +610,7 @@ export default function AyDialogFormDemo() {
| update | 进入编辑模式,会自动设置 mode="update"。 | formRef.current.update(record: Record, [config](#config)) |
| view | 进入详情模式,会自动设置 mode="view"。 | formRef.current.view(record: Record, [config](#config)) |
| closeDialog | 关闭弹窗。 | formRef.current.view(record: Record) |
| getFormRef | 获取里面嵌套的 MwForm 的对象,可以调用 MwForm 的一些方法。 | formRef.current.getFormRef() |
| getFormRef | 获取里面嵌套的 GForm 的对象,可以调用 GForm 的一些方法。 | formRef.current.getFormRef() |
| refreshFields | 刷新 form 的列。 | formRef.current.refreshFields() |
| submit() | 主动提交表单。 | - |
| resetFields() | 重置表单。 | - |
Expand Down
6 changes: 3 additions & 3 deletions packages/gbeata/src/GDialogForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import React, {
useRef,
useState,
} from 'react';
import GDialog from '../GDialog';
import { convertChildrenToField } from '../GFields/convertFields';
import GForm from '../GForm';
import { GFormField } from '../GForm/g-form';
import MwDialog from '../MwDialog';
import locale from '../locale';
import { AnyKeyProps } from '../types/AnyKeyProps';
import { omitObj } from '../utils';
Expand Down Expand Up @@ -434,7 +434,7 @@ export default forwardRef(function GDialogForm(
};

return (
<MwDialog
<GDialog
width={width}
title={getTitle(mode, dialogTitle)}
visible={visible}
Expand All @@ -461,6 +461,6 @@ export default forwardRef(function GDialogForm(
{...formExtend}
/>
</Spin>
</MwDialog>
</GDialog>
);
});
12 changes: 4 additions & 8 deletions packages/gbeata/src/GForm/FieldsInit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import {
} from 'antd';
import React from 'react';
import GCardGroup from '../GCardGroup';
import MwSelect from '../GSelect';
import MwTagGroup from '../GTagGroup';
import GSelect from '../GSelect';
import GTagGroup from '../GTagGroup';
import {
FORM_DEFAULT_ALLOW_CLEAR,
FORM_DEFAULT_VALUE_CARD_GROUP,
Expand Down Expand Up @@ -231,7 +231,7 @@ export const install = (
}

return (
<MwSelect
<GSelect
placeholder={`${locale.form.pleaseSelect}${field.title || ''}${
locale.form.pleaseSelectAfter
}`}
Expand Down Expand Up @@ -378,11 +378,7 @@ export const install = (
type: FORM_TYPE_TAG_GROUP,
defaultValue: FORM_DEFAULT_VALUE_TAG_GROUP,
render: ({ field, readonly }: AnyKeyProps) => (
<MwTagGroup
readonly={readonly}
options={field.options}
{...field.props}
/>
<GTagGroup readonly={readonly} options={field.options} {...field.props} />
),
});

Expand Down
2 changes: 1 addition & 1 deletion packages/gbeata/src/GForm/g-form.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export interface RegisterFieldProps {
}

/**
* 所有 field 的 最小单元,会被这些类型扩展: GForm AySearch MwTable MwSearchTable MwDialogForm
* 所有 field 的 最小单元,会被这些类型扩展: GForm AySearch GTable GSearchTable GDialogForm
*/
export interface Field {
/** 标题 */
Expand Down
2 changes: 1 addition & 1 deletion packages/gbeata/src/GForm/parseFields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default function parseFields(
for (const key in rest) {
if (Array.isArray(rest[key]) && key === 'children') {
// 携带子元素
rest[key] = rest[key].map((field) => loop({ ...field }));
rest[key] = rest[key].map((field: GFormField) => loop({ ...field }));
} else if (
isObj(rest[key]) &&
!(moment.isMoment(rest[key]) || isValidElement(rest[key]))
Expand Down
Loading

0 comments on commit b565ae7

Please sign in to comment.