-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(merge): Merge master branch and fix conflicts
- Loading branch information
Showing
28 changed files
with
471 additions
and
739 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
import { webVitals } from './vitals'; | ||
|
||
webVitals({ debug: true }); | ||
webVitals({}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/codemod/transforms/__testfixtures__/obui-to-oceanbase-design-and-ui/obui.input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/codemod/transforms/__testfixtures__/obui-to-oceanbase-design-and-ui/obui.output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React from 'react'; | ||
import { Table } from '@oceanbase/design'; | ||
import type { ColumnsType } from '@oceanbase/design/es/table'; | ||
|
||
interface DataType { | ||
key: string; | ||
name: string; | ||
money: string; | ||
address: string; | ||
} | ||
|
||
const columns: ColumnsType<DataType> = [ | ||
{ | ||
title: 'Name', | ||
dataIndex: 'name', | ||
render: text => <a>{text}</a>, | ||
}, | ||
{ | ||
title: 'Cash Assets', | ||
className: 'column-money', | ||
dataIndex: 'money', | ||
align: 'right', | ||
}, | ||
{ | ||
title: 'Address', | ||
dataIndex: 'address', | ||
}, | ||
]; | ||
|
||
const data: DataType[] = [ | ||
{ | ||
key: '1', | ||
name: 'John Brown', | ||
money: '¥300,000.00', | ||
address: 'New York No. 1 Lake Park', | ||
}, | ||
{ | ||
key: '2', | ||
name: 'Jim Green', | ||
money: '¥1,256,000.00', | ||
address: 'London No. 1 Lake Park', | ||
}, | ||
{ | ||
key: '3', | ||
name: 'Joe Black', | ||
money: '¥120,000.00', | ||
address: 'Sydney No. 1 Lake Park', | ||
}, | ||
]; | ||
|
||
const App: React.FC = () => ( | ||
<Table | ||
columns={columns} | ||
dataSource={data} | ||
bordered | ||
title={() => 'Header'} | ||
footer={() => 'Footer'} | ||
/> | ||
); | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
import React, { useState } from 'react'; | ||
import { Form, Input, InputNumber, Popconfirm, Table, Typography } from '@oceanbase/design'; | ||
|
||
interface Item { | ||
key: string; | ||
name: string; | ||
age: number; | ||
address: string; | ||
} | ||
|
||
const originData: Item[] = []; | ||
for (let i = 0; i < 100; i++) { | ||
originData.push({ | ||
key: i.toString(), | ||
name: `Edward ${i}`, | ||
age: 32, | ||
address: `London Park no. ${i}`, | ||
}); | ||
} | ||
interface EditableCellProps extends React.HTMLAttributes<HTMLElement> { | ||
editing: boolean; | ||
dataIndex: string; | ||
title: any; | ||
inputType: 'number' | 'text'; | ||
record: Item; | ||
index: number; | ||
children: React.ReactNode; | ||
} | ||
|
||
const EditableCell: React.FC<EditableCellProps> = ({ | ||
editing, | ||
dataIndex, | ||
title, | ||
inputType, | ||
record, | ||
index, | ||
children, | ||
...restProps | ||
}) => { | ||
const inputNode = inputType === 'number' ? <InputNumber /> : <Input />; | ||
|
||
return ( | ||
<td {...restProps}> | ||
{editing ? ( | ||
<Form.Item | ||
name={dataIndex} | ||
style={{ margin: 0 }} | ||
rules={[ | ||
{ | ||
required: true, | ||
message: `Please Input ${title}!`, | ||
}, | ||
]} | ||
> | ||
{inputNode} | ||
</Form.Item> | ||
) : ( | ||
children | ||
)} | ||
</td> | ||
); | ||
}; | ||
|
||
const App: React.FC = () => { | ||
const [form] = Form.useForm(); | ||
const [data, setData] = useState(originData); | ||
const [editingKey, setEditingKey] = useState(''); | ||
|
||
const isEditing = (record: Item) => record.key === editingKey; | ||
|
||
const edit = (record: Partial<Item> & { key: React.Key }) => { | ||
form.setFieldsValue({ name: '', age: '', address: '', ...record }); | ||
setEditingKey(record.key); | ||
}; | ||
|
||
const cancel = () => { | ||
setEditingKey(''); | ||
}; | ||
|
||
const save = async (key: React.Key) => { | ||
try { | ||
const row = (await form.validateFields()) as Item; | ||
|
||
const newData = [...data]; | ||
const index = newData.findIndex(item => key === item.key); | ||
if (index > -1) { | ||
const item = newData[index]; | ||
newData.splice(index, 1, { | ||
...item, | ||
...row, | ||
}); | ||
setData(newData); | ||
setEditingKey(''); | ||
} else { | ||
newData.push(row); | ||
setData(newData); | ||
setEditingKey(''); | ||
} | ||
} catch (errInfo) { | ||
console.log('Validate Failed:', errInfo); | ||
} | ||
}; | ||
|
||
const columns = [ | ||
{ | ||
title: 'name', | ||
dataIndex: 'name', | ||
width: '25%', | ||
editable: true, | ||
}, | ||
{ | ||
title: 'age', | ||
dataIndex: 'age', | ||
width: '15%', | ||
editable: true, | ||
}, | ||
{ | ||
title: 'address', | ||
dataIndex: 'address', | ||
width: '40%', | ||
editable: true, | ||
}, | ||
{ | ||
title: 'operation', | ||
dataIndex: 'operation', | ||
render: (_: any, record: Item) => { | ||
const editable = isEditing(record); | ||
return editable ? ( | ||
<span> | ||
<Typography.Link onClick={() => save(record.key)} style={{ marginRight: 8 }}> | ||
Save | ||
</Typography.Link> | ||
<Popconfirm title="Sure to cancel?" onConfirm={cancel}> | ||
<a>Cancel</a> | ||
</Popconfirm> | ||
</span> | ||
) : ( | ||
<Typography.Link disabled={editingKey !== ''} onClick={() => edit(record)}> | ||
Edit | ||
</Typography.Link> | ||
); | ||
}, | ||
}, | ||
]; | ||
|
||
const mergedColumns = columns.map(col => { | ||
if (!col.editable) { | ||
return col; | ||
} | ||
return { | ||
...col, | ||
onCell: (record: Item) => ({ | ||
record, | ||
inputType: col.dataIndex === 'age' ? 'number' : 'text', | ||
dataIndex: col.dataIndex, | ||
title: col.title, | ||
editing: isEditing(record), | ||
}), | ||
}; | ||
}); | ||
|
||
return ( | ||
<Form form={form} component={false}> | ||
<Table | ||
components={{ | ||
body: { | ||
cell: EditableCell, | ||
}, | ||
}} | ||
bordered | ||
dataSource={data} | ||
columns={mergedColumns} | ||
rowClassName="editable-row" | ||
pagination={{ | ||
onChange: cancel, | ||
}} | ||
/> | ||
</Form> | ||
); | ||
}; | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.