feat: add tabulator

This commit is contained in:
chenos 2025-06-21 23:19:21 +08:00
parent c653c84803
commit 38b972519b
14 changed files with 1477 additions and 32 deletions

View File

@ -10,6 +10,7 @@ console.log('process.env.DOC_LANG', lang);
export default defineConfig({
hash: true,
mfsu:false,
alias: {
...umiConfig.alias,
},

View File

@ -65,6 +65,8 @@
"react-router-dom": "^6.11.2",
"react-to-print": "^2.14.7",
"sanitize-html": "2.13.0",
"tabulator-tables": "^6.3.1",
"@types/tabulator-tables": "^6.2.6",
"use-deep-compare-effect": "^1.8.1"
},
"peerDependencies": {

View File

@ -0,0 +1,56 @@
/**
* This file is part of the NocoBase (R) project.
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
* Authors: NocoBase Team.
*
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
* For more information, please refer to: https://www.nocobase.com/agreement.
*/
// AntdInputEditor.tsx
import { Input, Select } from 'antd';
import React, { useEffect, useRef } from 'react';
interface Props {
value: any;
onSuccess: (value: any) => void;
onCancel: (value?: any) => void;
}
export const AntdInputEditor: React.FC<Props> = (props) => {
const { value, onSuccess, onCancel } = props;
const inputRef = useRef<any>(null);
useEffect(() => {
inputRef.current?.focus();
}, []);
const handleKeyDown = (e: React.KeyboardEvent) => {
console.log('Key pressed:', inputRef.current);
// if (e.key === 'Enter') onSuccess(inputRef.current?.input?.value);
if (e.key === 'Escape') onCancel();
};
return (
<Input
ref={inputRef}
onKeyDown={handleKeyDown}
defaultValue={value}
// autoSize={{ minRows: 3 }}
onBlur={(e) => onSuccess(e.target.value)}
/>
// <Select
// options={[
// { label: 'Option 1', value: 'option1' },
// { label: 'Option 2', value: 'option2' },
// { label: 'Option 3', value: 'option3' },
// ]}
// />
// <Input
// ref={inputRef}
// defaultValue={value}
// onBlur={() => onSuccess(inputRef.current?.input?.value)}
// onKeyDown={handleKeyDown}
// />
);
};

View File

@ -0,0 +1,310 @@
/**
* This file is part of the NocoBase (R) project.
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
* Authors: NocoBase Team.
*
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
* For more information, please refer to: https://www.nocobase.com/agreement.
*/
import { SettingOutlined } from '@ant-design/icons';
import { observer } from '@formily/react';
import {
AddActionButton,
AddFieldButton,
CollectionField,
FlowEngineProvider,
FlowModel,
FlowModelRenderer,
FlowsFloatContextMenu,
MultiRecordResource,
useApplyAutoFlows,
useFlowEngine,
} from '@nocobase/flow-engine';
import { Button, Card, ConfigProvider, Pagination, Skeleton, Space, theme } from 'antd';
import { head } from 'lodash';
import React from 'react';
import ReactDOM, { createRoot } from 'react-dom/client';
import { ColumnDefinition, TabulatorFull as Tabulator } from 'tabulator-tables';
import { ActionModel } from '../../base/ActionModel';
import { DataBlockModel } from '../../base/BlockModel';
import { TableFieldModel } from '../table/fields';
import { AntdInputEditor } from './AntdInputEditor';
import TabulatorTable from './TabulatorTable';
type S = {
subModels: {
columns: TabulatorColumnModel[];
actions: ActionModel[];
};
};
export class TabulatorColumnModel extends FlowModel {
collectionField: CollectionField;
fieldPath: string;
getColumnProps(): ColumnDefinition {
return {
title: 'abcd',
width: 100,
headerSort: false,
editable: true,
field: this.collectionField.name,
editor: (cell, onRendered, success, cancel) => {
return this.reactView.render(
<AntdInputEditor value={cell.getValue()} onSuccess={success} onCancel={cancel} />,
{ onRendered },
);
},
titleFormatter: (cell) => {
return this.reactView.render(<span>{this.collectionField.title}</span>);
},
formatter: (cell) => {
return this.reactView.render(
<span>
{this.mapSubModels('field', (action: TableFieldModel) => {
const fork = action.createFork({}, `${cell.getRow().getIndex()}`);
fork.setSharedContext({ index: cell.getRow().getIndex(), value: cell.getValue() });
return fork.render();
})}
</span>,
);
},
};
}
}
TabulatorColumnModel.registerFlow({
key: 'default',
auto: true,
steps: {
step1: {
async handler(ctx, params) {
if (!params.fieldPath) {
return;
}
if (ctx.model.collectionField) {
return;
}
const field = ctx.globals.dataSourceManager.getCollectionField(params.fieldPath);
ctx.model.collectionField = field;
ctx.model.fieldPath = params.fieldPath;
ctx.model.setProps('title', field.title);
ctx.model.setProps('dataIndex', field.name);
await ctx.model.applySubModelsAutoFlows('field');
},
},
},
});
const Columns = observer<any>(({ record, model, index }) => {
return (
<Space>
{model.mapSubModels('actions', (action: ActionModel) => {
const fork = action.createFork({}, `${index}`);
return (
<FlowModelRenderer showFlowSettings key={fork.uid} model={fork} extraContext={{ currentRecord: record }} />
);
})}
</Space>
);
});
export class TabulatorTableActionsColumnModel extends TabulatorColumnModel {
getColumnProps(): ColumnDefinition {
return {
title: 'ID',
headerSort: false,
field: 'id',
width: 200,
titleFormatter: (cell) => {
return this.reactView.render(
<FlowsFloatContextMenu
model={this}
containerStyle={{ display: 'block', padding: '11px 8px', margin: '-11px -8px' }}
>
<Space>
{this.props.title || 'Actions'}
<AddActionButton model={this} subModelBaseClass="RecordActionModel" subModelKey="actions">
<SettingOutlined />
</AddActionButton>
</Space>
</FlowsFloatContextMenu>,
);
},
formatter: (cell) => {
return this.reactView.render(
<Columns model={this} record={cell.getRow().getData()} index={cell.getRow().getIndex()} />,
);
},
};
}
}
export class TabulatorModel extends DataBlockModel<S> {
declare resource: MultiRecordResource;
getColumns() {
return this.mapSubModels('columns', (column) => {
return column.getColumnProps();
}).concat({
frozen: true,
frozenPosition: 'right',
title: 'abcd',
width: 200,
headerSort: false,
titleFormatter: (cell) => {
return this.reactView.render(
<AddFieldButton
collection={this.collection}
model={this}
subModelKey={'columns'}
subModelBaseClass="TableFieldModel"
buildCreateModelOptions={(field, fieldClass) => ({
use: 'TabulatorColumnModel',
stepParams: {
default: {
step1: {
fieldPath: field.fullpath,
},
},
},
subModels: {
field: {
use: fieldClass.name,
},
},
})}
appendItems={[
{
key: 'actions',
label: 'Actions column',
createModelOptions: {
use: 'TabulatorTableActionsColumnModel',
},
},
]}
onModelAdded={async (model: TabulatorColumnModel) => {
model.setSharedContext({ currentBlockModel: this });
await model.applyAutoFlows();
}}
/>,
);
},
} as ColumnDefinition);
}
render() {
return (
<Card>
{this.subModels.columns?.length}
<Space style={{ marginBottom: 16 }}>
{this.mapSubModels('actions', (action) => (
<FlowModelRenderer model={action} showFlowSettings sharedContext={{ currentBlockModel: this }} />
))}
<AddActionButton model={this} subModelBaseClass="GlobalActionModel" subModelKey="actions">
<Button icon={<SettingOutlined />}>Configure actions</Button>
</AddActionButton>
</Space>
<TabulatorTable
{...{
height: '75vh',
renderHorizontal: 'virtual',
// selectableRows: true,
data: this.resource.getData(),
movableColumns: true,
movableRows: true,
rowFormatter: (row) => {
row.getElement().style.height = '40px';
},
columns: [
{
title: '',
titleFormatter: 'rowSelection', // 复选框全选按钮
formatter: 'rowSelection', // 复选框单选按钮
hozAlign: 'center',
headerHozAlign: 'center',
headerSort: false,
width: 50,
frozen: true,
titleFormatterParams: { rowRange: 'active' }, // 只全选当前页数据
},
...this.getColumns(),
],
layout: 'fitColumns',
autoResize: true,
}}
/>
<Pagination
style={{ marginTop: 16 }}
align="end"
{...{
current: this.resource.getMeta('page'),
pageSize: this.resource.getMeta('pageSize'),
total: this.resource.getMeta('count'),
}}
onChange={(page, pageSize) => {
this.resource.setPage(page);
this.resource.setPageSize(pageSize);
this.resource.refresh();
}}
/>
</Card>
);
}
}
TabulatorModel.registerFlow({
key: 'default',
auto: true,
steps: {
step1: {
paramsRequired: true,
hideInSettings: true,
uiSchema: {
dataSourceKey: {
type: 'string',
title: 'Data Source Key',
'x-decorator': 'FormItem',
'x-component': 'Input',
'x-component-props': {
placeholder: 'Enter data source key',
},
},
collectionName: {
type: 'string',
title: 'Collection Name',
'x-decorator': 'FormItem',
'x-component': 'Input',
'x-component-props': {
placeholder: 'Enter collection name',
},
},
},
defaultParams: {
dataSourceKey: 'main',
},
handler: async (ctx, params) => {
const collection = ctx.globals.dataSourceManager.getCollection(params.dataSourceKey, params.collectionName);
ctx.model.collection = collection;
const resource = new MultiRecordResource();
resource.setDataSourceKey(params.dataSourceKey);
resource.setResourceName(params.collectionName);
resource.setAPIClient(ctx.globals.api);
resource.setPageSize(200);
ctx.model.resource = resource;
await ctx.model.applySubModelsAutoFlows('columns', null, { currentBlockModel: ctx.model });
await resource.refresh();
},
},
},
});
TabulatorModel.define({
title: 'Tabulator',
group: 'Content',
requiresDataSource: true,
defaultOptions: {
use: 'TabulatorModel',
},
});

View File

@ -0,0 +1,52 @@
/**
* This file is part of the NocoBase (R) project.
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
* Authors: NocoBase Team.
*
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
* For more information, please refer to: https://www.nocobase.com/agreement.
*/
import React, { useEffect, useRef } from 'react';
import ReactDOM from 'react-dom/client';
import { Options, TabulatorFull as Tabulator } from 'tabulator-tables';
import './tabulator.css';
export type TabulatorTableProps = Options;
const TabulatorTable: React.FC<TabulatorTableProps> = (props) => {
const ref = React.useRef();
const instanceRef: any = React.useRef();
const initTabulator = async () => {
const domEle: any = ref.current; // Directly access the DOM element
instanceRef.current = new Tabulator(domEle, {
layout: 'fitColumns', // fit columns to width of table (optional)
...props,
});
};
React.useEffect(() => {
// console.log('useEffect - onmount');
initTabulator();
// Cleanup function to destroy Tabulator instance on unmount
return () => {
if (instanceRef.current) {
instanceRef.current.destroy();
}
};
}, []);
React.useEffect(() => {
// console.log('useEffect - props.data changed');
if (instanceRef?.current) {
initTabulator();
}
}, [props]);
return <div ref={ref} />;
};
export default TabulatorTable;

View File

@ -0,0 +1,965 @@
.tabulator {
position: relative;
border: 1px solid #999;
background-color: #fff;
font-size: 14px;
text-align: left;
overflow: hidden;
-webkit-transform: translateZ(0);
-moz-transform: translateZ(0);
-ms-transform: translateZ(0);
-o-transform: translateZ(0);
transform: translateZ(0); }
.tabulator[tabulator-layout="fitDataFill"] .tabulator-tableholder .tabulator-table {
min-width: 100%; }
.tabulator[tabulator-layout="fitDataTable"] {
display: inline-block; }
.tabulator.tabulator-block-select {
user-select: none; }
.tabulator.tabulator-ranges .tabulator-cell:not(.tabulator-editing) {
user-select: none; }
.tabulator .tabulator-header {
position: relative;
box-sizing: border-box;
width: 100%;
border-bottom: 1px solid #f0f0f0;
background-color: #fafafa;
/* color: #555; */
font-weight: 600;
white-space: nowrap;
overflow: hidden;
-moz-user-select: none;
-khtml-user-select: none;
-webkit-user-select: none;
-o-user-select: none;
outline: none; }
.tabulator .tabulator-header.tabulator-header-hidden {
display: none; }
.tabulator .tabulator-header .tabulator-header-contents {
position: relative;
overflow: hidden; }
.tabulator .tabulator-header .tabulator-header-contents .tabulator-headers {
display: inline-block; }
.tabulator .tabulator-header .tabulator-col {
display: inline-flex;
position: relative;
box-sizing: border-box;
flex-direction: column;
justify-content: flex-end;
/* border-right: 1px solid #ddd; */
background: #fafafa;
text-align: left;
vertical-align: bottom;
overflow: hidden; }
.tabulator .tabulator-header .tabulator-col.tabulator-moving {
position: absolute;
border: 1px solid #999;
background: #e6e6e6;
pointer-events: none; }
.tabulator .tabulator-header .tabulator-col.tabulator-range-highlight {
background-color: #D6D6D6;
color: #000000; }
.tabulator .tabulator-header .tabulator-col.tabulator-range-selected {
background-color: #3876ca;
color: #FFFFFF; }
.tabulator .tabulator-header .tabulator-col .tabulator-col-content {
box-sizing: border-box;
position: relative;
padding: 10px 4px; }
.tabulator .tabulator-header .tabulator-col .tabulator-col-content .tabulator-header-popup-button {
padding: 0 8px; }
.tabulator .tabulator-header .tabulator-col .tabulator-col-content .tabulator-header-popup-button:hover {
cursor: pointer;
opacity: .6; }
.tabulator .tabulator-header .tabulator-col .tabulator-col-content .tabulator-col-title-holder {
position: relative; }
.tabulator .tabulator-header .tabulator-col .tabulator-col-content .tabulator-col-title {
box-sizing: border-box;
width: 100%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
vertical-align: bottom; }
.tabulator .tabulator-header .tabulator-col .tabulator-col-content .tabulator-col-title.tabulator-col-title-wrap {
white-space: normal;
text-overflow: initial; }
.tabulator .tabulator-header .tabulator-col .tabulator-col-content .tabulator-col-title .tabulator-title-editor {
box-sizing: border-box;
width: 100%;
border: 1px solid #999;
padding: 1px;
background: #fff; }
.tabulator .tabulator-header .tabulator-col .tabulator-col-content .tabulator-col-title .tabulator-header-popup-button + .tabulator-title-editor {
width: calc(100% - 22px); }
.tabulator .tabulator-header .tabulator-col .tabulator-col-content .tabulator-col-sorter {
display: flex;
align-items: center;
position: absolute;
top: 0;
bottom: 0;
right: 4px; }
.tabulator .tabulator-header .tabulator-col .tabulator-col-content .tabulator-col-sorter .tabulator-arrow {
width: 0;
height: 0;
border-left: 6px solid transparent;
border-right: 6px solid transparent;
border-bottom: 6px solid #bbb; }
.tabulator .tabulator-header .tabulator-col.tabulator-col-group .tabulator-col-group-cols {
position: relative;
display: flex;
border-top: 1px solid #ddd;
overflow: hidden;
margin-right: -1px; }
.tabulator .tabulator-header .tabulator-col .tabulator-header-filter {
position: relative;
box-sizing: border-box;
margin-top: 2px;
width: 100%;
text-align: center; }
.tabulator .tabulator-header .tabulator-col .tabulator-header-filter textarea {
height: auto !important; }
.tabulator .tabulator-header .tabulator-col .tabulator-header-filter svg {
margin-top: 3px; }
.tabulator .tabulator-header .tabulator-col .tabulator-header-filter input::-ms-clear {
width: 0;
height: 0; }
.tabulator .tabulator-header .tabulator-col.tabulator-sortable .tabulator-col-title {
padding-right: 25px; }
@media (hover: hover) and (pointer: fine) {
.tabulator .tabulator-header .tabulator-col.tabulator-sortable.tabulator-col-sorter-element:hover {
cursor: pointer;
background-color: #e6e6e6; } }
.tabulator .tabulator-header .tabulator-col.tabulator-sortable[aria-sort="none"] .tabulator-col-content .tabulator-col-sorter {
color: #bbb; }
@media (hover: hover) and (pointer: fine) {
.tabulator .tabulator-header .tabulator-col.tabulator-sortable[aria-sort="none"] .tabulator-col-content .tabulator-col-sorter.tabulator-col-sorter-element .tabulator-arrow:hover {
cursor: pointer;
border-bottom: 6px solid #555; } }
.tabulator .tabulator-header .tabulator-col.tabulator-sortable[aria-sort="none"] .tabulator-col-content .tabulator-col-sorter .tabulator-arrow {
border-top: none;
border-bottom: 6px solid #bbb; }
.tabulator .tabulator-header .tabulator-col.tabulator-sortable[aria-sort="ascending"] .tabulator-col-content .tabulator-col-sorter {
color: #666; }
@media (hover: hover) and (pointer: fine) {
.tabulator .tabulator-header .tabulator-col.tabulator-sortable[aria-sort="ascending"] .tabulator-col-content .tabulator-col-sorter.tabulator-col-sorter-element .tabulator-arrow:hover {
cursor: pointer;
border-bottom: 6px solid #555; } }
.tabulator .tabulator-header .tabulator-col.tabulator-sortable[aria-sort="ascending"] .tabulator-col-content .tabulator-col-sorter .tabulator-arrow {
border-top: none;
border-bottom: 6px solid #666; }
.tabulator .tabulator-header .tabulator-col.tabulator-sortable[aria-sort="descending"] .tabulator-col-content .tabulator-col-sorter {
color: #666; }
@media (hover: hover) and (pointer: fine) {
.tabulator .tabulator-header .tabulator-col.tabulator-sortable[aria-sort="descending"] .tabulator-col-content .tabulator-col-sorter.tabulator-col-sorter-element .tabulator-arrow:hover {
cursor: pointer;
border-top: 6px solid #555; } }
.tabulator .tabulator-header .tabulator-col.tabulator-sortable[aria-sort="descending"] .tabulator-col-content .tabulator-col-sorter .tabulator-arrow {
border-bottom: none;
border-top: 6px solid #666;
color: #666; }
.tabulator .tabulator-header .tabulator-col.tabulator-col-vertical .tabulator-col-content .tabulator-col-title {
writing-mode: vertical-rl;
text-orientation: mixed;
display: flex;
align-items: center;
justify-content: center; }
.tabulator .tabulator-header .tabulator-col.tabulator-col-vertical.tabulator-col-vertical-flip .tabulator-col-title {
transform: rotate(180deg); }
.tabulator .tabulator-header .tabulator-col.tabulator-col-vertical.tabulator-sortable .tabulator-col-title {
padding-right: 0;
padding-top: 20px; }
.tabulator .tabulator-header .tabulator-col.tabulator-col-vertical.tabulator-sortable.tabulator-col-vertical-flip .tabulator-col-title {
padding-right: 0;
padding-bottom: 20px; }
.tabulator .tabulator-header .tabulator-col.tabulator-col-vertical.tabulator-sortable .tabulator-col-sorter {
justify-content: center;
left: 0;
right: 0;
top: 4px;
bottom: auto; }
.tabulator .tabulator-header .tabulator-frozen {
position: sticky;
left: 0;
z-index: 11; }
.tabulator .tabulator-header .tabulator-frozen.tabulator-frozen-left {
border-right: 2px solid #f0f0f0; }
.tabulator .tabulator-header .tabulator-frozen.tabulator-frozen-right {
border-left: 2px solid #f0f0f0; }
.tabulator .tabulator-header .tabulator-calcs-holder {
box-sizing: border-box;
display: inline-block;
background: white !important;
border-top: 1px solid #ddd;
border-bottom: 1px solid #ddd; }
.tabulator .tabulator-header .tabulator-calcs-holder .tabulator-row {
background: white !important; }
.tabulator .tabulator-header .tabulator-calcs-holder .tabulator-row .tabulator-col-resize-handle {
display: none; }
.tabulator .tabulator-header .tabulator-frozen-rows-holder {
display: inline-block; }
.tabulator .tabulator-header .tabulator-frozen-rows-holder:empty {
display: none; }
.tabulator .tabulator-tableholder {
position: relative;
width: 100%;
white-space: nowrap;
overflow: auto;
-webkit-overflow-scrolling: touch; }
.tabulator .tabulator-tableholder:focus {
outline: none; }
.tabulator .tabulator-tableholder .tabulator-placeholder {
box-sizing: border-box;
display: flex;
align-items: center;
justify-content: center;
min-width: 100%;
width: 100%; }
.tabulator .tabulator-tableholder .tabulator-placeholder[tabulator-render-mode="virtual"] {
min-height: 100%; }
.tabulator .tabulator-tableholder .tabulator-placeholder .tabulator-placeholder-contents {
display: inline-block;
text-align: center;
padding: 10px;
color: #ccc;
font-weight: bold;
font-size: 20px;
white-space: normal; }
.tabulator .tabulator-tableholder .tabulator-table {
position: relative;
display: inline-block;
background-color: #fff;
white-space: nowrap;
overflow: visible;
color: #333; }
.tabulator .tabulator-tableholder .tabulator-table .tabulator-row.tabulator-calcs {
font-weight: bold;
background: #f2f2f2 !important; }
.tabulator .tabulator-tableholder .tabulator-table .tabulator-row.tabulator-calcs.tabulator-calcs-top {
border-bottom: 2px solid #ddd; }
.tabulator .tabulator-tableholder .tabulator-table .tabulator-row.tabulator-calcs.tabulator-calcs-bottom {
border-top: 2px solid #ddd; }
.tabulator .tabulator-tableholder .tabulator-range-overlay {
position: absolute;
inset: 0;
z-index: 10;
pointer-events: none; }
.tabulator .tabulator-tableholder .tabulator-range-overlay .tabulator-range {
position: absolute;
box-sizing: border-box;
border: 1px solid #2975DD; }
.tabulator .tabulator-tableholder .tabulator-range-overlay .tabulator-range.tabulator-range-active::after {
content: '';
position: absolute;
right: -3px;
bottom: -3px;
width: 6px;
height: 6px;
background-color: #2975DD;
border-radius: 999px; }
.tabulator .tabulator-tableholder .tabulator-range-overlay .tabulator-range-cell-active {
position: absolute;
box-sizing: border-box;
border: 2px solid #2975DD; }
.tabulator .tabulator-footer {
border-top: 1px solid #999;
background-color: #fff;
color: #555;
font-weight: bold;
white-space: nowrap;
user-select: none;
-moz-user-select: none;
-khtml-user-select: none;
-webkit-user-select: none;
-o-user-select: none; }
.tabulator .tabulator-footer .tabulator-footer-contents {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
padding: 5px 10px; }
.tabulator .tabulator-footer .tabulator-footer-contents:empty {
display: none; }
.tabulator .tabulator-footer .tabulator-spreadsheet-tabs {
margin-top: -5px;
overflow-x: auto; }
.tabulator .tabulator-footer .tabulator-spreadsheet-tabs .tabulator-spreadsheet-tab {
display: inline-block;
padding: 5px;
border: #999 1px solid;
border-top: none;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
font-size: .9em; }
.tabulator .tabulator-footer .tabulator-spreadsheet-tabs .tabulator-spreadsheet-tab:hover {
cursor: pointer;
opacity: .7; }
.tabulator .tabulator-footer .tabulator-spreadsheet-tabs .tabulator-spreadsheet-tab.tabulator-spreadsheet-tab-active {
background: #fff; }
.tabulator .tabulator-footer .tabulator-calcs-holder {
box-sizing: border-box;
width: 100%;
text-align: left;
background: white !important;
border-bottom: 1px solid #ddd;
border-top: 1px solid #ddd;
overflow: hidden; }
.tabulator .tabulator-footer .tabulator-calcs-holder .tabulator-row {
display: inline-block;
background: white !important; }
.tabulator .tabulator-footer .tabulator-calcs-holder .tabulator-row .tabulator-col-resize-handle {
display: none; }
.tabulator .tabulator-footer .tabulator-calcs-holder:only-child {
margin-bottom: -5px;
border-bottom: none; }
.tabulator .tabulator-footer > * + .tabulator-page-counter {
margin-left: 10px; }
.tabulator .tabulator-footer .tabulator-page-counter {
font-weight: normal; }
.tabulator .tabulator-footer .tabulator-paginator {
flex: 1;
text-align: right;
color: #555;
font-family: inherit;
font-weight: inherit;
font-size: inherit; }
.tabulator .tabulator-footer .tabulator-page-size {
display: inline-block;
margin: 0 5px;
padding: 2px 5px;
border: 1px solid #aaa;
border-radius: 3px; }
.tabulator .tabulator-footer .tabulator-pages {
margin: 0 7px; }
.tabulator .tabulator-footer .tabulator-page {
display: inline-block;
margin: 0 2px;
padding: 2px 5px;
border: 1px solid #aaa;
border-radius: 3px;
background: rgba(255, 255, 255, 0.2); }
.tabulator .tabulator-footer .tabulator-page.active {
color: #d00; }
.tabulator .tabulator-footer .tabulator-page:disabled {
opacity: .5; }
@media (hover: hover) and (pointer: fine) {
.tabulator .tabulator-footer .tabulator-page:not(disabled):hover {
cursor: pointer;
background: rgba(0, 0, 0, 0.2);
color: #fff; } }
.tabulator .tabulator-col-resize-handle {
position: relative;
display: inline-block;
width: 4px;
margin-left: -2px;
margin-right: -2px;
z-index: 11;
vertical-align: middle; }
.tabulator .tabulator-col-resize-handle:hover {
background: #ddd; }
@media (hover: hover) and (pointer: fine) {
.tabulator .tabulator-col-resize-handle:hover {
cursor: ew-resize; } }
.tabulator .tabulator-col-resize-handle:last-of-type {
width: 3px;
margin-right: 0; }
.tabulator .tabulator-col-resize-guide {
position: absolute;
top: 0;
width: 4px;
height: 100%;
margin-left: -0.5px;
background-color: #999;
opacity: .5; }
.tabulator .tabulator-row-resize-guide {
position: absolute;
left: 0;
width: 100%;
height: 4px;
margin-top: -0.5px;
background-color: #999;
opacity: .5; }
.tabulator .tabulator-alert {
position: absolute;
display: flex;
align-items: center;
top: 0;
left: 0;
z-index: 100;
height: 100%;
width: 100%;
background: rgba(0, 0, 0, 0.4);
text-align: center; }
.tabulator .tabulator-alert .tabulator-alert-msg {
display: inline-block;
margin: 0 auto;
padding: 10px 20px;
border-radius: 10px;
background: #fff;
font-weight: bold;
font-size: 16px; }
.tabulator .tabulator-alert .tabulator-alert-msg.tabulator-alert-state-msg {
border: 4px solid #333;
color: #000; }
.tabulator .tabulator-alert .tabulator-alert-msg.tabulator-alert-state-error {
border: 4px solid #D00;
color: #590000; }
.tabulator-row {
position: relative;
box-sizing: border-box;
min-height: 22px;
background-color: #fff; }
.tabulator-row.tabulator-row-even {
background-color: #fff; }
@media (hover: hover) and (pointer: fine) {
.tabulator-row.tabulator-selectable:hover {
background-color: #f0f0f0;
cursor: pointer; } }
.tabulator-row.tabulator-selected {
background-color: #e6f4ff; }
@media (hover: hover) and (pointer: fine) {
.tabulator-row.tabulator-selected:hover {
background-color: #bae0ff;
cursor: pointer; } }
.tabulator-row.tabulator-row-moving {
border: 1px solid #000;
background: #fff; }
.tabulator-row.tabulator-moving {
position: absolute;
border-top: 1px solid #ddd;
border-bottom: 1px solid #ddd;
pointer-events: none;
z-index: 15; }
.tabulator-row.tabulator-range-highlight .tabulator-cell.tabulator-range-row-header {
background-color: #D6D6D6;
color: #000000; }
.tabulator-row.tabulator-range-highlight.tabulator-range-selected .tabulator-cell.tabulator-range-row-header {
background-color: #3876ca;
color: #FFFFFF; }
.tabulator-row.tabulator-range-selected .tabulator-cell.tabulator-range-row-header {
background-color: #3876ca;
color: #FFFFFF; }
.tabulator-row .tabulator-row-resize-handle {
position: absolute;
right: 0;
bottom: 0;
left: 0;
height: 5px; }
.tabulator-row .tabulator-row-resize-handle.prev {
top: 0;
bottom: auto; }
@media (hover: hover) and (pointer: fine) {
.tabulator-row .tabulator-row-resize-handle:hover {
cursor: ns-resize; } }
.tabulator-row .tabulator-responsive-collapse {
box-sizing: border-box;
padding: 5px;
border-top: 1px solid #ddd;
border-bottom: 1px solid #ddd; }
.tabulator-row .tabulator-responsive-collapse:empty {
display: none; }
.tabulator-row .tabulator-responsive-collapse table {
font-size: 14px; }
.tabulator-row .tabulator-responsive-collapse table tr td {
position: relative; }
.tabulator-row .tabulator-responsive-collapse table tr td:first-of-type {
padding-right: 10px; }
.tabulator-row .tabulator-cell {
display: inline-block;
position: relative;
box-sizing: border-box;
padding: 8px 4px;
/* border-right: 1px solid #ddd; */
vertical-align: middle;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
outline: none; }
.tabulator-row .tabulator-cell.tabulator-row-header {
border-right: 1px solid #999;
border-bottom: 1px solid #ddd;
background: #fff; }
.tabulator-row .tabulator-cell.tabulator-frozen {
display: inline-block;
position: sticky;
left: 0;
background-color: inherit;
z-index: 11; }
.tabulator-row .tabulator-cell.tabulator-frozen.tabulator-frozen-left {
border-right: 2px solid #f0f0f0; }
.tabulator-row .tabulator-cell.tabulator-frozen.tabulator-frozen-right {
border-left: 2px solid #f0f0f0; }
.tabulator-row .tabulator-cell.tabulator-editing {
/* border: 1px solid #1D68CD; */
outline: none;
z-index: 20;
overflow: inherit;
padding: 0; }
.tabulator-row .tabulator-cell.tabulator-editing input, .tabulator-row .tabulator-cell.tabulator-editing select {
/* border: 1px;
background: transparent;
outline: none; */}
.tabulator-row .tabulator-cell.tabulator-validation-fail {
border: 1px solid #dd0000; }
.tabulator-row .tabulator-cell.tabulator-validation-fail input, .tabulator-row .tabulator-cell.tabulator-validation-fail select {
border: 1px;
background: transparent;
color: #dd0000; }
.tabulator-row .tabulator-cell.tabulator-row-handle {
display: inline-flex;
align-items: center;
justify-content: center;
-moz-user-select: none;
-khtml-user-select: none;
-webkit-user-select: none;
-o-user-select: none; }
.tabulator-row .tabulator-cell.tabulator-row-handle .tabulator-row-handle-box {
width: 80%; }
.tabulator-row .tabulator-cell.tabulator-row-handle .tabulator-row-handle-box .tabulator-row-handle-bar {
width: 100%;
height: 3px;
margin-top: 2px;
background: #666; }
.tabulator-row .tabulator-cell.tabulator-range-selected:not(.tabulator-range-only-cell-selected):not(.tabulator-range-row-header) {
background-color: #9ABCEA; }
.tabulator-row .tabulator-cell .tabulator-data-tree-branch-empty {
display: inline-block;
width: 7px; }
.tabulator-row .tabulator-cell .tabulator-data-tree-branch {
display: inline-block;
vertical-align: middle;
height: 9px;
width: 7px;
margin-top: -9px;
margin-right: 5px;
border-bottom-left-radius: 1px;
border-left: 2px solid #ddd;
border-bottom: 2px solid #ddd; }
.tabulator-row .tabulator-cell .tabulator-data-tree-control {
display: inline-flex;
justify-content: center;
align-items: center;
vertical-align: middle;
height: 11px;
width: 11px;
margin-right: 5px;
border: 1px solid #333;
border-radius: 2px;
background: rgba(0, 0, 0, 0.1);
overflow: hidden; }
@media (hover: hover) and (pointer: fine) {
.tabulator-row .tabulator-cell .tabulator-data-tree-control:hover {
cursor: pointer;
background: rgba(0, 0, 0, 0.2); } }
.tabulator-row .tabulator-cell .tabulator-data-tree-control .tabulator-data-tree-control-collapse {
display: inline-block;
position: relative;
height: 7px;
width: 1px;
background: transparent; }
.tabulator-row .tabulator-cell .tabulator-data-tree-control .tabulator-data-tree-control-collapse:after {
position: absolute;
content: "";
left: -3px;
top: 3px;
height: 1px;
width: 7px;
background: #333; }
.tabulator-row .tabulator-cell .tabulator-data-tree-control .tabulator-data-tree-control-expand {
display: inline-block;
position: relative;
height: 7px;
width: 1px;
background: #333; }
.tabulator-row .tabulator-cell .tabulator-data-tree-control .tabulator-data-tree-control-expand:after {
position: absolute;
content: "";
left: -3px;
top: 3px;
height: 1px;
width: 7px;
background: #333; }
.tabulator-row .tabulator-cell .tabulator-responsive-collapse-toggle {
display: inline-flex;
align-items: center;
justify-content: center;
-moz-user-select: none;
-khtml-user-select: none;
-webkit-user-select: none;
-o-user-select: none;
height: 15px;
width: 15px;
border-radius: 20px;
background: #666;
color: #fff;
font-weight: bold;
font-size: 1.1em; }
@media (hover: hover) and (pointer: fine) {
.tabulator-row .tabulator-cell .tabulator-responsive-collapse-toggle:hover {
opacity: .7;
cursor: pointer; } }
.tabulator-row .tabulator-cell .tabulator-responsive-collapse-toggle.open .tabulator-responsive-collapse-toggle-close {
display: initial; }
.tabulator-row .tabulator-cell .tabulator-responsive-collapse-toggle.open .tabulator-responsive-collapse-toggle-open {
display: none; }
.tabulator-row .tabulator-cell .tabulator-responsive-collapse-toggle svg {
stroke: #fff; }
.tabulator-row .tabulator-cell .tabulator-responsive-collapse-toggle .tabulator-responsive-collapse-toggle-close {
display: none; }
.tabulator-row .tabulator-cell .tabulator-traffic-light {
display: inline-block;
height: 14px;
width: 14px;
border-radius: 14px; }
.tabulator-row.tabulator-group {
box-sizing: border-box;
border-bottom: 1px solid #999;
border-right: 1px solid #ddd;
border-top: 1px solid #999;
padding: 5px;
padding-left: 10px;
background: #ccc;
font-weight: bold;
min-width: 100%; }
@media (hover: hover) and (pointer: fine) {
.tabulator-row.tabulator-group:hover {
cursor: pointer;
background-color: rgba(0, 0, 0, 0.1); } }
.tabulator-row.tabulator-group.tabulator-group-visible .tabulator-arrow {
margin-right: 10px;
border-left: 6px solid transparent;
border-right: 6px solid transparent;
border-top: 6px solid #666;
border-bottom: 0; }
.tabulator-row.tabulator-group.tabulator-group-level-1 {
padding-left: 30px; }
.tabulator-row.tabulator-group.tabulator-group-level-2 {
padding-left: 50px; }
.tabulator-row.tabulator-group.tabulator-group-level-3 {
padding-left: 70px; }
.tabulator-row.tabulator-group.tabulator-group-level-4 {
padding-left: 90px; }
.tabulator-row.tabulator-group.tabulator-group-level-5 {
padding-left: 110px; }
.tabulator-row.tabulator-group .tabulator-group-toggle {
display: inline-block; }
.tabulator-row.tabulator-group .tabulator-arrow {
display: inline-block;
width: 0;
height: 0;
margin-right: 16px;
border-top: 6px solid transparent;
border-bottom: 6px solid transparent;
border-right: 0;
border-left: 6px solid #666;
vertical-align: middle; }
.tabulator-row.tabulator-group span {
margin-left: 10px;
color: #d00; }
.tabulator-toggle {
box-sizing: border-box;
display: flex;
flex-direction: row;
border: 1px solid #ccc;
background: #dcdcdc; }
.tabulator-toggle.tabulator-toggle-on {
background: #1c6cc2; }
.tabulator-toggle .tabulator-toggle-switch {
box-sizing: border-box;
border: 1px solid #ccc;
background: #fff; }
.tabulator-popup-container {
position: absolute;
display: inline-block;
box-sizing: border-box;
background: #fff;
border: 1px solid #ddd;
box-shadow: 0 0 5px 0 rgba(0, 0, 0, 0.2);
font-size: 14px;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
z-index: 10000; }
.tabulator-popup {
padding: 5px;
border-radius: 3px; }
.tabulator-tooltip {
max-width: Min(500px, 100%);
padding: 3px 5px;
border-radius: 2px;
box-shadow: none;
font-size: 12px;
pointer-events: none; }
.tabulator-menu .tabulator-menu-item {
position: relative;
box-sizing: border-box;
padding: 5px 10px;
user-select: none; }
.tabulator-menu .tabulator-menu-item.tabulator-menu-item-disabled {
opacity: .5; }
@media (hover: hover) and (pointer: fine) {
.tabulator-menu .tabulator-menu-item:not(.tabulator-menu-item-disabled):hover {
cursor: pointer;
background: #fff; } }
.tabulator-menu .tabulator-menu-item.tabulator-menu-item-submenu {
padding-right: 25px; }
.tabulator-menu .tabulator-menu-item.tabulator-menu-item-submenu::after {
display: inline-block;
position: absolute;
top: calc(5px + .4em);
right: 10px;
height: 7px;
width: 7px;
content: '';
border-width: 1px 1px 0 0;
border-style: solid;
border-color: #ddd;
vertical-align: top;
transform: rotate(45deg); }
.tabulator-menu .tabulator-menu-separator {
border-top: 1px solid #ddd; }
.tabulator-edit-list {
max-height: 200px;
font-size: 14px;
overflow-y: auto;
-webkit-overflow-scrolling: touch; }
.tabulator-edit-list .tabulator-edit-list-item {
padding: 4px;
color: #333;
outline: none; }
.tabulator-edit-list .tabulator-edit-list-item.active {
color: #fff;
background: #1D68CD; }
.tabulator-edit-list .tabulator-edit-list-item.active.focused {
outline: 1px solid rgba(255, 255, 255, 0.5); }
.tabulator-edit-list .tabulator-edit-list-item.focused {
outline: 1px solid #1D68CD; }
@media (hover: hover) and (pointer: fine) {
.tabulator-edit-list .tabulator-edit-list-item:hover {
cursor: pointer;
color: #fff;
background: #1D68CD; } }
.tabulator-edit-list .tabulator-edit-list-placeholder {
padding: 4px;
color: #333;
text-align: center; }
.tabulator-edit-list .tabulator-edit-list-group {
border-bottom: 1px solid #ddd;
padding: 4px;
padding-top: 6px;
color: #333;
font-weight: bold; }
.tabulator-edit-list .tabulator-edit-list-item.tabulator-edit-list-group-level-2, .tabulator-edit-list .tabulator-edit-list-group.tabulator-edit-list-group-level-2 {
padding-left: 12px; }
.tabulator-edit-list .tabulator-edit-list-item.tabulator-edit-list-group-level-3, .tabulator-edit-list .tabulator-edit-list-group.tabulator-edit-list-group-level-3 {
padding-left: 20px; }
.tabulator-edit-list .tabulator-edit-list-item.tabulator-edit-list-group-level-4, .tabulator-edit-list .tabulator-edit-list-group.tabulator-edit-list-group-level-4 {
padding-left: 28px; }
.tabulator-edit-list .tabulator-edit-list-item.tabulator-edit-list-group-level-5, .tabulator-edit-list .tabulator-edit-list-group.tabulator-edit-list-group-level-5 {
padding-left: 36px; }
.tabulator.tabulator-ltr {
direction: ltr; }
.tabulator.tabulator-rtl {
text-align: initial;
direction: rtl; }
.tabulator.tabulator-rtl .tabulator-header .tabulator-col {
text-align: initial;
border-left: 1px solid #ddd;
border-right: initial; }
.tabulator.tabulator-rtl .tabulator-header .tabulator-col.tabulator-col-group .tabulator-col-group-cols {
margin-right: initial;
margin-left: -1px; }
.tabulator.tabulator-rtl .tabulator-header .tabulator-col.tabulator-sortable .tabulator-col-title {
padding-right: 0;
padding-left: 25px; }
.tabulator.tabulator-rtl .tabulator-header .tabulator-col .tabulator-col-content .tabulator-col-sorter {
left: 8px;
right: initial; }
.tabulator.tabulator-rtl .tabulator-tableholder .tabulator-range-overlay .tabulator-range.tabulator-range-active::after {
content: '';
position: absolute;
left: -3px;
right: initial;
bottom: -3px;
width: 6px;
height: 6px;
background-color: #2975DD;
border-radius: 999px; }
.tabulator.tabulator-rtl .tabulator-row .tabulator-cell {
border-right: initial;
border-left: 1px solid #ddd; }
.tabulator.tabulator-rtl .tabulator-row .tabulator-cell .tabulator-data-tree-branch {
margin-right: initial;
margin-left: 5px;
border-bottom-left-radius: initial;
border-bottom-right-radius: 1px;
border-left: initial;
border-right: 2px solid #ddd; }
.tabulator.tabulator-rtl .tabulator-row .tabulator-cell .tabulator-data-tree-control {
margin-right: initial;
margin-left: 5px; }
.tabulator.tabulator-rtl .tabulator-row .tabulator-cell.tabulator-frozen.tabulator-frozen-left {
border-left: 2px solid #ddd; }
.tabulator.tabulator-rtl .tabulator-row .tabulator-cell.tabulator-frozen.tabulator-frozen-right {
border-right: 2px solid #ddd; }
.tabulator.tabulator-rtl .tabulator-row .tabulator-col-resize-handle:last-of-type {
width: 3px;
margin-left: 0;
margin-right: -3px; }
.tabulator.tabulator-rtl .tabulator-footer .tabulator-calcs-holder {
text-align: initial; }
.tabulator-print-fullscreen {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: 10000; }
body.tabulator-print-fullscreen-hide > *:not(.tabulator-print-fullscreen) {
display: none !important; }
.tabulator-print-table {
border-collapse: collapse; }
.tabulator-print-table .tabulator-data-tree-branch {
display: inline-block;
vertical-align: middle;
height: 9px;
width: 7px;
margin-top: -9px;
margin-right: 5px;
border-bottom-left-radius: 1px;
border-left: 2px solid #ddd;
border-bottom: 2px solid #ddd; }
.tabulator-print-table .tabulator-print-table-group {
box-sizing: border-box;
border-bottom: 1px solid #999;
border-right: 1px solid #ddd;
border-top: 1px solid #999;
padding: 5px;
padding-left: 10px;
background: #ccc;
font-weight: bold;
min-width: 100%; }
@media (hover: hover) and (pointer: fine) {
.tabulator-print-table .tabulator-print-table-group:hover {
cursor: pointer;
background-color: rgba(0, 0, 0, 0.1); } }
.tabulator-print-table .tabulator-print-table-group.tabulator-group-visible .tabulator-arrow {
margin-right: 10px;
border-left: 6px solid transparent;
border-right: 6px solid transparent;
border-top: 6px solid #666;
border-bottom: 0; }
.tabulator-print-table .tabulator-print-table-group.tabulator-group-level-1 td {
padding-left: 30px !important; }
.tabulator-print-table .tabulator-print-table-group.tabulator-group-level-2 td {
padding-left: 50px !important; }
.tabulator-print-table .tabulator-print-table-group.tabulator-group-level-3 td {
padding-left: 70px !important; }
.tabulator-print-table .tabulator-print-table-group.tabulator-group-level-4 td {
padding-left: 90px !important; }
.tabulator-print-table .tabulator-print-table-group.tabulator-group-level-5 td {
padding-left: 110px !important; }
.tabulator-print-table .tabulator-print-table-group .tabulator-group-toggle {
display: inline-block; }
.tabulator-print-table .tabulator-print-table-group .tabulator-arrow {
display: inline-block;
width: 0;
height: 0;
margin-right: 16px;
border-top: 6px solid transparent;
border-bottom: 6px solid transparent;
border-right: 0;
border-left: 6px solid #666;
vertical-align: middle; }
.tabulator-print-table .tabulator-print-table-group span {
margin-left: 10px;
color: #d00; }
.tabulator-print-table .tabulator-data-tree-control {
display: inline-flex;
justify-content: center;
align-items: center;
vertical-align: middle;
height: 11px;
width: 11px;
margin-right: 5px;
border: 1px solid #333;
border-radius: 2px;
background: rgba(0, 0, 0, 0.1);
overflow: hidden; }
@media (hover: hover) and (pointer: fine) {
.tabulator-print-table .tabulator-data-tree-control:hover {
cursor: pointer;
background: rgba(0, 0, 0, 0.2); } }
.tabulator-print-table .tabulator-data-tree-control .tabulator-data-tree-control-collapse {
display: inline-block;
position: relative;
height: 7px;
width: 1px;
background: transparent; }
.tabulator-print-table .tabulator-data-tree-control .tabulator-data-tree-control-collapse:after {
position: absolute;
content: "";
left: -3px;
top: 3px;
height: 1px;
width: 7px;
background: #333; }
.tabulator-print-table .tabulator-data-tree-control .tabulator-data-tree-control-expand {
display: inline-block;
position: relative;
height: 7px;
width: 1px;
background: #333; }
.tabulator-print-table .tabulator-data-tree-control .tabulator-data-tree-control-expand:after {
position: absolute;
content: "";
left: -3px;
top: 3px;
height: 1px;
width: 7px;
background: #333; }
.tabulator {
border: none;
background-color: #fff; }
.tabulator .tabulator-header .tabulator-calcs-holder {
background: #f2f2f2 !important;
border-bottom: 1px solid #999; }
.tabulator .tabulator-header .tabulator-calcs-holder .tabulator-row {
background: #f2f2f2 !important; }
.tabulator .tabulator-tableholder .tabulator-placeholder span {
color: #000; }
.tabulator .tabulator-footer .tabulator-calcs-holder {
background: #f2f2f2 !important;
border-bottom: 1px solid #fff; }
.tabulator .tabulator-footer .tabulator-calcs-holder .tabulator-row {
background: #f2f2f2 !important; }
.tabulator .tabulator-footer .tabulator-spreadsheet-tabs .tabulator-spreadsheet-tab {
font-weight: normal; }
.tabulator .tabulator-footer .tabulator-spreadsheet-tabs .tabulator-spreadsheet-tab.tabulator-spreadsheet-tab-active {
color: #d00;
font-weight: bold; }
.tabulator-row {
border-bottom: 1px solid #f0f0f0; }
.tabulator-row .tabulator-cell:last-of-type {
border-right: none; }
.tabulator-row .tabulator-cell.tabulator-row-header {
border-bottom: none; }
.tabulator-row.tabulator-group span {
color: #666; }
.tabulator-print-table .tabulator-print-table-group span {
margin-left: 10px;
color: #666; }

View File

@ -22,6 +22,7 @@ export * from './data-blocks/table/fields';
export * from './data-blocks/table/TableActionsColumnModel';
export * from './data-blocks/table/TableColumnModel';
export * from './data-blocks/table/TableModel';
export * from './data-blocks/tabulator/TabulatorModel';
export * from './filter-blocks/form/FilterFormActionModel';
export * from './filter-blocks/form/FilterFormFieldModel';
export * from './filter-blocks/form/FilterFormModel';

View File

@ -0,0 +1,55 @@
/**
* This file is part of the NocoBase (R) project.
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
* Authors: NocoBase Team.
*
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
* For more information, please refer to: https://www.nocobase.com/agreement.
*/
import { ConfigProvider } from 'antd';
import React from 'react';
import { Root, createRoot } from 'react-dom/client';
import { FlowEngine } from './flowEngine';
import { FlowEngineProvider } from './provider';
function Provider({ config, engine, children }) {
return (
<FlowEngineProvider engine={engine}>
<ConfigProvider {...config}>{children}</ConfigProvider>
</FlowEngineProvider>
);
}
export class ReactView {
constructor(private flowEngine: FlowEngine) {}
render(children: React.ReactNode | ((root: Root) => React.ReactNode), options: any = {}) {
const container = document.createElement('span');
const { onRendered } = options;
let root: Root;
const renderContent = (root: Root) => {
const content = typeof children === 'function' ? (children as (root: Root) => React.ReactNode)(root) : children;
return (
<Provider engine={this.flowEngine} config={this.flowEngine.context['antdConfig']}>
{content}
</Provider>
);
};
if (onRendered) {
onRendered(() => {
root = createRoot(container);
root.render(renderContent(root));
});
} else {
root = createRoot(container);
root.render(renderContent(root));
}
(container as any)._reactRoot = root;
return container;
}
}

View File

@ -36,17 +36,19 @@
*/
import { observer } from '@formily/reactive-react';
import { Spin } from 'antd';
import React, { Suspense, useEffect } from 'react';
import { useApplyAutoFlows, useFlowExtraContext } from '../hooks';
import { FlowModel } from '../models';
import { FlowsContextMenu } from './settings/wrappers/contextual/FlowsContextMenu';
import { FlowsFloatContextMenu } from './settings/wrappers/contextual/FlowsFloatContextMenu';
import { Spin } from 'antd';
interface FlowModelRendererProps {
model?: FlowModel;
uid?: string;
fallback?: React.ReactNode; // 渲染失败时的回退内容
/** 是否显示流程设置入口(如按钮、菜单等) */
showFlowSettings?: boolean; // 默认 false
@ -196,6 +198,7 @@ const FlowModelRendererCore: React.FC<{
export const FlowModelRenderer: React.FC<FlowModelRendererProps> = observer(
({
model,
fallback = <Spin />,
showFlowSettings = false,
flowSettingsVariant = 'dropdown',
hideRemoveInSettings = false,
@ -229,7 +232,7 @@ export const FlowModelRenderer: React.FC<FlowModelRendererProps> = observer(
);
} else {
return (
<Suspense fallback={<Spin />}>
<Suspense fallback={fallback}>
<FlowModelRendererWithAutoFlows
model={model}
showFlowSettings={showFlowSettings}

View File

@ -9,6 +9,7 @@
import { observable } from '@formily/reactive';
import { FlowSettings } from './flowSettings';
import { FlowModel } from './models';
import { ReactView } from './ReactView';
import {
ActionDefinition,
ActionOptions,
@ -39,6 +40,13 @@ export class FlowEngine {
private modelRepository: IFlowModelRepository | null = null;
private _applyFlowCache = new Map<string, ApplyFlowCacheEntry>();
reactView: ReactView;
constructor() {
this.reactView = new ReactView(this);
}
// 注册默认的 FlowModel
setModelRepository(modelRepository: IFlowModelRepository) {
if (this.modelRepository) {
console.warn('FlowEngine: Model repository is already set and will be overwritten.');

View File

@ -102,6 +102,10 @@ export class FlowModel<Structure extends { parent?: any; subModels?: any } = Def
return this._options.async || false;
}
get reactView() {
return this.flowEngine.reactView;
}
static get meta() {
return modelMetas.get(this);
}

View File

@ -7,7 +7,7 @@
* For more information, please refer to: https://www.nocobase.com/agreement.
*/
import { App } from 'antd';
import { App, ConfigProvider } from 'antd';
import React, { createContext, useContext, useEffect } from 'react';
import { FlowEngine } from './flowEngine';
import useDrawer from './useDrawer';
@ -31,13 +31,15 @@ export const FlowEngineGlobalsContextProvider: React.FC<{ children: React.ReactN
const { modal, message, notification } = App.useApp();
const [drawer, contextHolder] = useDrawer();
const engine = useFlowEngine();
const config = useContext(ConfigProvider.ConfigContext);
useEffect(() => {
engine.context['antdConfig'] = config;
engine.context['drawer'] = drawer;
engine.context['modal'] = modal;
engine.context['message'] = message;
engine.context['notification'] = notification;
}, [engine, drawer, modal, message, notification]);
}, [engine, drawer, modal, message, notification, config]);
return (
<>

View File

@ -301,6 +301,7 @@ export interface FlowModelOptions<Structure extends { parent?: any; subModels?:
export interface FlowModelMeta {
title: string;
group?: string;
requiresDataSource?: boolean; // 是否需要数据源
defaultOptions?: Record<string, any>;
icon?: string;
// uniqueSub?: boolean;

View File

@ -8747,6 +8747,11 @@
dependencies:
"@types/superagent" "*"
"@types/tabulator-tables@^6.2.6":
version "6.2.6"
resolved "https://registry.npmmirror.com/@types/tabulator-tables/-/tabulator-tables-6.2.6.tgz#580ee6d01a8cc439b4936543e749bbbc00babf99"
integrity sha512-A+2VrqDluI6hNw5dQl1Z7b8pjQfAE62+3Kj0cFfenWzj0T0ewMicPrpPINHL7ASqz9u9FTDn1Mz1Ige2tF4Wlw==
"@types/tapable@2.2.7":
version "2.2.7"
resolved "https://registry.npmmirror.com/@types/tapable/-/tapable-2.2.7.tgz#4b55aa23daca730d83f192dd0933409d5a0338e4"
@ -28695,7 +28700,7 @@ string-template@1.0.0:
resolved "https://registry.npmmirror.com/string-template/-/string-template-1.0.0.tgz#9e9f2233dc00f218718ec379a28a5673ecca8b96"
integrity sha512-SLqR3GBUXuoPP5MmYtD7ompvXiG87QjT6lzOszyXjTM86Uu7At7vNnt2xgyTLq5o9T4IxTYFyGxcULqpsmsfdg==
"string-width-cjs@npm:string-width@^4.2.0":
"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.npmmirror.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
@ -28713,15 +28718,6 @@ string-width@^1.0.1, string-width@^1.0.2:
is-fullwidth-code-point "^1.0.0"
strip-ansi "^3.0.0"
"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.npmmirror.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"
string-width@^2.0.0, string-width@^2.1.0, string-width@^2.1.1:
version "2.1.1"
resolved "https://registry.npmmirror.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e"
@ -28849,7 +28845,7 @@ stringz@2.1.0:
dependencies:
char-regex "^1.0.2"
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.npmmirror.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
@ -28877,13 +28873,6 @@ strip-ansi@^5.1.0:
dependencies:
ansi-regex "^4.1.0"
strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.npmmirror.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"
strip-ansi@^7.0.1:
version "7.1.0"
resolved "https://registry.npmmirror.com/strip-ansi/-/strip-ansi-7.1.0.tgz#d5b6568ca689d8561370b0707685d22434faff45"
@ -29254,6 +29243,11 @@ systemjs@^6.14.1:
resolved "https://registry.npmmirror.com/systemjs/-/systemjs-6.14.2.tgz#e289f959f8c8b407403bd39c6abaa16f2c13f316"
integrity sha512-1TlOwvKWdXxAY9vba+huLu99zrQURDWA8pUTYsRIYDZYQbGyK+pyEP4h4dlySsqo7ozyJBmYD20F+iUHhAltEg==
tabulator-tables@^6.3.1:
version "6.3.1"
resolved "https://registry.npmmirror.com/tabulator-tables/-/tabulator-tables-6.3.1.tgz#648c2893167bfb1f531c52670fad92d6353b8b40"
integrity sha512-qFW7kfadtcaISQIibKAIy0f3eeIXUVi8242Vly1iJfMD79kfEGzfczNuPBN/80hDxHzQJXYbmJ8VipI40hQtfA==
tapable@2.2.1, tapable@^2.0.0, tapable@^2.2.0, tapable@^2.2.1:
version "2.2.1"
resolved "https://registry.npmmirror.com/tapable/-/tapable-2.2.1.tgz#1967a73ef4060a82f12ab96af86d52fdb76eeca0"
@ -31566,7 +31560,7 @@ wordwrap@^1.0.0:
resolved "https://registry.npmmirror.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb"
integrity sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.npmmirror.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
@ -31592,15 +31586,6 @@ wrap-ansi@^6.0.1:
string-width "^4.1.0"
strip-ansi "^6.0.0"
wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.npmmirror.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"
wrap-ansi@^8.0.1, wrap-ansi@^8.1.0:
version "8.1.0"
resolved "https://registry.npmmirror.com/wrap-ansi/-/wrap-ansi-8.1.0.tgz#56dc22368ee570face1b49819975d9b9a5ead214"