@nocobase/client-v2 2.2.0-alpha.1 → 2.2.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/PluginSettingsManager.d.ts +33 -0
- package/es/RouteRepository.d.ts +21 -6
- package/es/components/category-tabs/SortableCategoryTabs.d.ts +55 -0
- package/es/components/category-tabs/index.d.ts +9 -0
- package/es/components/form/JsonTextArea.d.ts +2 -1
- package/es/components/form/TypedVariableInput.d.ts +22 -4
- package/es/components/form/VariableJsonTextArea.d.ts +19 -0
- package/es/components/form/filter/CollectionFilterItem.d.ts +11 -1
- package/es/components/form/filter/index.d.ts +2 -0
- package/es/components/form/index.d.ts +1 -0
- package/es/components/index.d.ts +2 -0
- package/es/flow/actions/afterSuccess.d.ts +8 -1
- package/es/flow/actions/index.d.ts +1 -1
- package/es/flow/admin-shell/admin-layout/AdminLayoutEntryGuard.d.ts +2 -0
- package/es/flow/admin-shell/admin-layout/AdminLayoutMenuFlowUtils.d.ts +2 -1
- package/es/flow/admin-shell/admin-layout/AdminLayoutMenuModels.d.ts +2 -0
- package/es/flow/admin-shell/admin-layout/AdminLayoutMenuUtils.d.ts +3 -2
- package/es/flow/admin-shell/admin-layout/AdminLayoutSlotModels.d.ts +5 -0
- package/es/flow/admin-shell/admin-layout/resolveAdminRouteRuntimeTarget.d.ts +6 -0
- package/es/flow/components/FieldAssignRulesEditor.d.ts +3 -1
- package/es/flow/components/FieldAssignValueInput.d.ts +2 -0
- package/es/flow/index.d.ts +1 -0
- package/es/flow/models/base/GridModel.d.ts +1 -1
- package/es/flow/models/blocks/filter-form/FilterFormBlockModel.d.ts +5 -0
- package/es/flow/models/blocks/form/FormBlockModel.d.ts +4 -0
- package/es/flow/models/blocks/form/submitHandler.d.ts +1 -1
- package/es/flow/models/blocks/form/value-runtime/rules.d.ts +21 -0
- package/es/flow/models/blocks/form/value-runtime/runtime.d.ts +30 -0
- package/es/flow/models/blocks/form/value-runtime/types.d.ts +2 -2
- package/es/flow/models/blocks/js-block/JSBlock.d.ts +1 -0
- package/es/flow/models/blocks/table/TableActionsColumnModel.d.ts +1 -0
- package/es/flow/models/blocks/table/TableBlockModel.d.ts +1 -0
- package/es/flow/models/blocks/table/dragSort/dragSortHooks.d.ts +1 -1
- package/es/flow/models/blocks/table/dragSort/dragSortSettings.d.ts +2 -1
- package/es/flow/models/blocks/table/dragSort/dragSortUtils.d.ts +6 -4
- package/es/flow/models/fields/AssociationFieldModel/RecordSelectFieldModel.d.ts +2 -0
- package/es/flow/models/fields/AssociationFieldModel/SubTableFieldModel/SubTableColumnModel.d.ts +6 -0
- package/es/flow/resolveViewParamsToViewList.d.ts +1 -1
- package/es/flow/utils/dataScopeRowSnapshot.d.ts +59 -0
- package/es/flow/utils/dateTimeDisplayProps.d.ts +49 -0
- package/es/flow/utils/formValueDeps.d.ts +32 -0
- package/es/flow-compat/FieldValidation.d.ts +2 -1
- package/es/index.d.ts +2 -1
- package/es/index.mjs +233 -137
- package/lib/index.js +234 -138
- package/package.json +7 -7
- package/src/PluginSettingsManager.ts +53 -0
- package/src/RouteRepository.ts +126 -24
- package/src/__tests__/PluginSettingsManager.test.ts +13 -0
- package/src/__tests__/RouteRepository.test.ts +216 -0
- package/src/__tests__/browserChecker.test.ts +61 -0
- package/src/__tests__/exports.test.ts +16 -0
- package/src/__tests__/nocobase-buildin-plugin-auth.test.tsx +199 -0
- package/src/__tests__/plugin-manager.test.tsx +44 -2
- package/src/__tests__/settings-center.test.tsx +40 -1
- package/src/collection-manager/field-configure.ts +1 -1
- package/src/collection-manager/interfaces/id.ts +1 -1
- package/src/collection-manager/interfaces/m2m.tsx +2 -2
- package/src/collection-manager/interfaces/m2o.tsx +2 -2
- package/src/collection-manager/interfaces/nanoid.ts +1 -1
- package/src/collection-manager/interfaces/o2m.tsx +2 -2
- package/src/collection-manager/interfaces/obo.tsx +2 -2
- package/src/collection-manager/interfaces/oho.tsx +2 -2
- package/src/collection-manager/interfaces/properties/index.ts +2 -2
- package/src/collection-manager/interfaces/uuid.ts +1 -1
- package/src/components/AppComponents.tsx +19 -3
- package/src/components/README.md +7 -1
- package/src/components/README.zh-CN.md +6 -1
- package/src/components/category-tabs/SortableCategoryTabs.tsx +210 -0
- package/src/components/category-tabs/index.ts +10 -0
- package/src/components/form/JsonTextArea.tsx +21 -11
- package/src/components/form/TypedVariableInput.tsx +416 -93
- package/src/components/form/VariableJsonTextArea.tsx +175 -0
- package/src/components/form/__tests__/JsonTextArea.test.tsx +43 -0
- package/src/components/form/__tests__/TypedVariableInput.test.tsx +268 -9
- package/src/components/form/__tests__/VariableJsonTextArea.test.tsx +86 -0
- package/src/components/form/filter/CollectionFilterItem.tsx +32 -7
- package/src/components/form/filter/__tests__/CollectionFilterItem.test.tsx +38 -0
- package/src/components/form/filter/index.ts +2 -0
- package/src/components/form/index.tsx +1 -0
- package/src/components/index.ts +2 -0
- package/src/flow/__tests__/FlowRoute.test.tsx +443 -5
- package/src/flow/__tests__/getKey.test.ts +7 -0
- package/src/flow/__tests__/resolveViewParamsToViewList.test.ts +34 -0
- package/src/flow/actions/__tests__/afterSuccess.test.ts +73 -0
- package/src/flow/actions/__tests__/dataScopeFilter.test.ts +58 -0
- package/src/flow/actions/__tests__/dataScopeFormValueClear.test.ts +1022 -0
- package/src/flow/actions/__tests__/fieldLinkageRules.scopeDepth.test.ts +150 -1
- package/src/flow/actions/__tests__/linkageAssignField.legacy.test.ts +135 -0
- package/src/flow/actions/__tests__/linkageRules.hiddenSync.restore.test.ts +19 -5
- package/src/flow/actions/__tests__/linkageRules.subFormSetFieldProps.test.ts +92 -0
- package/src/flow/actions/__tests__/openView.defineProps.route.test.tsx +104 -0
- package/src/flow/actions/__tests__/subFormFieldLinkageRules.inputArgs.test.ts +2 -2
- package/src/flow/actions/afterSuccess.tsx +142 -3
- package/src/flow/actions/customVariable.tsx +1 -2
- package/src/flow/actions/dataScopeFilter.ts +10 -0
- package/src/flow/actions/dateTimeFormat.tsx +42 -28
- package/src/flow/actions/index.ts +1 -1
- package/src/flow/actions/linkageRules.tsx +123 -35
- package/src/flow/actions/linkageRulesFormValueRefresh.ts +22 -130
- package/src/flow/actions/openView.tsx +38 -4
- package/src/flow/actions/runjs.tsx +2 -14
- package/src/flow/actions/validation.tsx +62 -30
- package/src/flow/admin-shell/BaseLayoutModel.tsx +25 -3
- package/src/flow/admin-shell/BaseLayoutRouteCoordinator.ts +5 -2
- package/src/flow/admin-shell/__tests__/AdminLayoutRouteCoordinator.test.ts +13 -0
- package/src/flow/admin-shell/admin-layout/AdminLayoutComponent.tsx +34 -10
- package/src/flow/admin-shell/admin-layout/AdminLayoutEntryGuard.test.tsx +310 -0
- package/src/flow/admin-shell/admin-layout/AdminLayoutEntryGuard.tsx +44 -8
- package/src/flow/admin-shell/admin-layout/AdminLayoutMenuFlowUtils.ts +5 -3
- package/src/flow/admin-shell/admin-layout/AdminLayoutMenuModels.tsx +61 -9
- package/src/flow/admin-shell/admin-layout/AdminLayoutMenuUtils.tsx +71 -8
- package/src/flow/admin-shell/admin-layout/AdminLayoutModel.tsx +1 -1
- package/src/flow/admin-shell/admin-layout/AdminLayoutSlotModels.tsx +23 -9
- package/src/flow/admin-shell/admin-layout/HelpLite.tsx +1 -3
- package/src/flow/admin-shell/admin-layout/__tests__/AdminLayoutComponent.test.tsx +188 -0
- package/src/flow/admin-shell/admin-layout/__tests__/AdminLayoutMenuModels.test.ts +99 -0
- package/src/flow/admin-shell/admin-layout/__tests__/AdminLayoutModel.test.tsx +82 -0
- package/src/flow/admin-shell/admin-layout/__tests__/TopbarActionsBar.test.tsx +166 -2
- package/src/flow/admin-shell/admin-layout/resolveAdminRouteRuntimeTarget.test.ts +20 -0
- package/src/flow/admin-shell/admin-layout/resolveAdminRouteRuntimeTarget.ts +33 -5
- package/src/flow/components/DefaultValue.tsx +1 -2
- package/src/flow/components/DynamicFlowsIcon.tsx +447 -126
- package/src/flow/components/FieldAssignRulesEditor.tsx +128 -21
- package/src/flow/components/FieldAssignValueInput.tsx +10 -5
- package/src/flow/components/FlowRoute.tsx +56 -11
- package/src/flow/components/__tests__/DynamicFlowsIcon.test.tsx +148 -2
- package/src/flow/components/__tests__/FieldAssignRulesEditor.test.tsx +508 -4
- package/src/flow/components/__tests__/fieldAssignOptions.test.ts +151 -3
- package/src/flow/components/code-editor/__tests__/useCodeRunner.test.tsx +2 -17
- package/src/flow/components/code-editor/hooks/useCodeRunner.ts +2 -14
- package/src/flow/components/code-editor/runjsDiagnostics.ts +8 -45
- package/src/flow/components/fieldAssignOptions.ts +155 -27
- package/src/flow/flows/editMarkdownFlow.tsx +1 -1
- package/src/flow/getViewDiffAndUpdateHidden.tsx +1 -0
- package/src/flow/index.ts +2 -1
- package/src/flow/internal/utils/operatorSchemaHelper.ts +15 -1
- package/src/flow/models/actions/JSActionModel.tsx +2 -7
- package/src/flow/models/actions/JSCollectionActionModel.tsx +2 -7
- package/src/flow/models/actions/JSItemActionModel.tsx +2 -7
- package/src/flow/models/actions/JSRecordActionModel.tsx +2 -7
- package/src/flow/models/base/ActionModel.tsx +12 -1
- package/src/flow/models/base/ActionModelCore.tsx +6 -4
- package/src/flow/models/base/GridModel.tsx +38 -7
- package/src/flow/models/base/PageModel/PageModel.tsx +4 -1
- package/src/flow/models/base/PageModel/__tests__/PageModel.test.ts +28 -4
- package/src/flow/models/base/__tests__/ActionModel.test.ts +83 -0
- package/src/flow/models/base/__tests__/ActionModelCore.render.test.tsx +37 -0
- package/src/flow/models/base/__tests__/GridModel.dragSnapshotContainer.test.ts +239 -1
- package/src/flow/models/base/__tests__/transformRowsToSingleColumn.test.ts +48 -0
- package/src/flow/models/blocks/filter-form/FilterFormBlockModel.tsx +31 -3
- package/src/flow/models/blocks/filter-form/FilterFormJSActionModel.tsx +2 -7
- package/src/flow/models/blocks/filter-form/__tests__/defaultValues.wiring.test.ts +77 -0
- package/src/flow/models/blocks/filter-form/fields/FilterFormCustomFieldModel.tsx +1 -1
- package/src/flow/models/blocks/filter-manager/flow-actions/__tests__/customizeFilterRender.test.tsx +56 -1
- package/src/flow/models/blocks/form/EditFormModel.tsx +1 -0
- package/src/flow/models/blocks/form/FormActionModel.tsx +1 -1
- package/src/flow/models/blocks/form/FormBlockModel.tsx +7 -0
- package/src/flow/models/blocks/form/JSFormActionModel.tsx +2 -7
- package/src/flow/models/blocks/form/__tests__/FormBlockModel.test.tsx +17 -0
- package/src/flow/models/blocks/form/__tests__/submitHandler.test.ts +54 -1
- package/src/flow/models/blocks/form/submitHandler.ts +17 -3
- package/src/flow/models/blocks/form/value-runtime/__tests__/runtime.test.ts +940 -75
- package/src/flow/models/blocks/form/value-runtime/rules.ts +445 -13
- package/src/flow/models/blocks/form/value-runtime/runtime.ts +348 -13
- package/src/flow/models/blocks/form/value-runtime/types.ts +2 -2
- package/src/flow/models/blocks/js-block/JSBlock.tsx +225 -9
- package/src/flow/models/blocks/js-block/__tests__/JSBlockModel.test.tsx +150 -0
- package/src/flow/models/blocks/table/JSColumnModel.tsx +1 -9
- package/src/flow/models/blocks/table/TableActionsColumnModel.tsx +36 -13
- package/src/flow/models/blocks/table/TableBlockModel.tsx +38 -17
- package/src/flow/models/blocks/table/TableColumnModel.tsx +36 -3
- package/src/flow/models/blocks/table/__tests__/TableActionsColumnModel.test.tsx +111 -1
- package/src/flow/models/blocks/table/__tests__/TableBlockModel.dragSort.test.ts +127 -0
- package/src/flow/models/blocks/table/__tests__/TableBlockModel.mobileSettingsButtons.test.tsx +78 -0
- package/src/flow/models/blocks/table/__tests__/TableBlockModel.rowSelection.test.tsx +1 -0
- package/src/flow/models/blocks/table/__tests__/TableColumnModel.test.tsx +159 -1
- package/src/flow/models/blocks/table/dragSort/dragSortHooks.tsx +28 -17
- package/src/flow/models/blocks/table/dragSort/dragSortSettings.ts +13 -6
- package/src/flow/models/blocks/table/dragSort/dragSortUtils.ts +15 -2
- package/src/flow/models/fields/AssociationFieldModel/AssociationFieldModel.tsx +1 -1
- package/src/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/PopupSubTableFieldModel.tsx +29 -6
- package/src/flow/models/fields/AssociationFieldModel/RecordSelectFieldModel.tsx +16 -4
- package/src/flow/models/fields/AssociationFieldModel/SubTableFieldModel/SubTableColumnModel.tsx +141 -19
- package/src/flow/models/fields/AssociationFieldModel/SubTableFieldModel/SubTableField.tsx +13 -1
- package/src/flow/models/fields/AssociationFieldModel/SubTableFieldModel/__tests__/SubTableColumnModel.rowRecord.test.ts +197 -0
- package/src/flow/models/fields/AssociationFieldModel/SubTableFieldModel/__tests__/SubTableFieldModel.reset.test.ts +180 -0
- package/src/flow/models/fields/AssociationFieldModel/SubTableFieldModel/index.tsx +6 -4
- package/src/flow/models/fields/AssociationFieldModel/__tests__/AssociationFieldModel.updateAssociation.test.ts +72 -0
- package/src/flow/models/fields/AssociationFieldModel/__tests__/RecordPickerFieldModel.itemContext.test.ts +23 -0
- package/src/flow/models/fields/ClickableFieldModel.tsx +5 -0
- package/src/flow/models/fields/DisplayDateTimeFieldModel.tsx +29 -1
- package/src/flow/models/fields/InputFieldModel.tsx +40 -2
- package/src/flow/models/fields/JSEditableFieldModel.tsx +2 -11
- package/src/flow/models/fields/JSFieldModel.tsx +2 -7
- package/src/flow/models/fields/JSItemModel.tsx +2 -14
- package/src/flow/models/fields/SelectFieldModel.tsx +6 -4
- package/src/flow/models/fields/TextareaFieldModel.tsx +49 -3
- package/src/flow/models/fields/__tests__/DisplayDateTimeFieldModel.test.tsx +96 -0
- package/src/flow/models/fields/__tests__/InputFieldModel.test.tsx +117 -1
- package/src/flow/models/fields/__tests__/SelectFieldModel.test.tsx +43 -0
- package/src/flow/models/fields/__tests__/TextareaFieldModel.test.tsx +100 -0
- package/src/flow/models/topbar/TopbarActionModel.tsx +93 -10
- package/src/flow/resolveViewParamsToViewList.tsx +11 -3
- package/src/flow/utils/__tests__/dateTimeFormat.test.ts +258 -0
- package/src/flow/utils/dataScopeFormValueClear.ts +218 -81
- package/src/flow/utils/dataScopeRowSnapshot.ts +616 -0
- package/src/flow/utils/dateTimeDisplayProps.ts +135 -0
- package/src/flow/utils/formValueDeps.ts +170 -0
- package/src/flow-compat/FieldValidation.tsx +122 -60
- package/src/flow-compat/Popover.tsx +43 -4
- package/src/flow-compat/__tests__/Popover.test.tsx +34 -0
- package/src/index.ts +8 -1
- package/src/layout-manager/__tests__/LayoutRoute.test.tsx +41 -1
- package/src/nocobase-buildin-plugin/index.tsx +44 -14
- package/src/settings-center/AdminSettingsLayout.tsx +10 -2
- package/src/settings-center/SystemSettingsPage.tsx +1 -2
- package/src/settings-center/plugin-manager/PluginCard.tsx +2 -2
- package/src/settings-center/plugin-manager/index.tsx +3 -0
- package/src/settings-center/utils.tsx +0 -6
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import { ElementProxy, tExpr
|
|
10
|
+
import { ElementProxy, tExpr } from '@nocobase/flow-engine';
|
|
11
11
|
import React from 'react';
|
|
12
12
|
import { BlockModel } from '../../base';
|
|
13
13
|
import { BlockItemCard } from '../../../components';
|
|
@@ -16,24 +16,238 @@ import { CodeEditor } from '../../../components/code-editor';
|
|
|
16
16
|
|
|
17
17
|
const NAMESPACE = 'client';
|
|
18
18
|
|
|
19
|
+
const getRootElement = (element: HTMLElement | null) => {
|
|
20
|
+
if (!element) return document.documentElement;
|
|
21
|
+
return (
|
|
22
|
+
(element.closest('.nb-block-grid') as HTMLElement | null) ||
|
|
23
|
+
(element.closest('.nb-page-wrapper') as HTMLElement | null) ||
|
|
24
|
+
(element.closest('.nb-page') as HTMLElement | null) ||
|
|
25
|
+
document.documentElement
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const getOuterHeight = (element?: HTMLElement | null) => {
|
|
30
|
+
if (!element) return 0;
|
|
31
|
+
const rect = element.getBoundingClientRect();
|
|
32
|
+
const style = window.getComputedStyle(element);
|
|
33
|
+
const marginTop = parseFloat(style.marginTop) || 0;
|
|
34
|
+
const marginBottom = parseFloat(style.marginBottom) || 0;
|
|
35
|
+
return rect.height + marginTop + marginBottom;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const getPadding = (element: HTMLElement | null) => {
|
|
39
|
+
if (!element || element === document.documentElement) {
|
|
40
|
+
return { top: 0, bottom: 0 };
|
|
41
|
+
}
|
|
42
|
+
const style = window.getComputedStyle(element);
|
|
43
|
+
return {
|
|
44
|
+
top: parseFloat(style.paddingTop) || 0,
|
|
45
|
+
bottom: parseFloat(style.paddingBottom) || 0,
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const getPageHeader = (root: HTMLElement) => {
|
|
50
|
+
const page = root.closest('.nb-page') as HTMLElement | null;
|
|
51
|
+
if (!page) return null;
|
|
52
|
+
return (
|
|
53
|
+
(page.querySelector('.ant-page-header') as HTMLElement | null) ||
|
|
54
|
+
(page.querySelector('.pageHeaderCss') as HTMLElement | null)
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const getAddBlockContainer = (root: HTMLElement) => {
|
|
59
|
+
const button = root.querySelector('[data-flow-add-block]') as HTMLElement | null;
|
|
60
|
+
if (!button) return null;
|
|
61
|
+
return (button.parentElement as HTMLElement | null) || button;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
function getValidPageTop(a: number, b: number) {
|
|
65
|
+
const aValid = a > 0;
|
|
66
|
+
const bValid = b > 0;
|
|
67
|
+
|
|
68
|
+
if (aValid) return a;
|
|
69
|
+
if (bValid) return b;
|
|
70
|
+
return 0;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const usePlainHostHeight = ({
|
|
74
|
+
height,
|
|
75
|
+
heightMode,
|
|
76
|
+
hostRef,
|
|
77
|
+
marginBlock,
|
|
78
|
+
}: {
|
|
79
|
+
height?: number;
|
|
80
|
+
heightMode?: string;
|
|
81
|
+
hostRef: React.RefObject<HTMLDivElement>;
|
|
82
|
+
marginBlock: number;
|
|
83
|
+
}) => {
|
|
84
|
+
const [fullHeight, setFullHeight] = React.useState<number>();
|
|
85
|
+
const updateFullHeight = React.useCallback(() => {
|
|
86
|
+
if (heightMode !== 'fullHeight' || typeof window === 'undefined') {
|
|
87
|
+
setFullHeight((prev) => (prev === undefined ? prev : undefined));
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
const hostEl = hostRef.current;
|
|
91
|
+
if (!hostEl) return;
|
|
92
|
+
const root = getRootElement(hostEl);
|
|
93
|
+
const hostRect = hostEl.getBoundingClientRect();
|
|
94
|
+
const rootRect = root === document.documentElement ? { top: 0 } : root.getBoundingClientRect();
|
|
95
|
+
const padding = getPadding(root);
|
|
96
|
+
const addBlockContainer = getAddBlockContainer(root);
|
|
97
|
+
const pageTop = rootRect.top + padding.top;
|
|
98
|
+
const topOffset = Math.max(0, hostRect.top - pageTop);
|
|
99
|
+
let bottomOffset = padding.bottom + marginBlock;
|
|
100
|
+
if (addBlockContainer) {
|
|
101
|
+
const gapBetween = marginBlock;
|
|
102
|
+
bottomOffset = gapBetween + getOuterHeight(addBlockContainer) + padding.bottom;
|
|
103
|
+
}
|
|
104
|
+
const nextHeight = Math.max(
|
|
105
|
+
0,
|
|
106
|
+
Math.floor(window.innerHeight - getValidPageTop(pageTop, 110) - topOffset - bottomOffset - 1),
|
|
107
|
+
);
|
|
108
|
+
setFullHeight((prev) => (prev === nextHeight ? prev : nextHeight));
|
|
109
|
+
}, [heightMode, hostRef, marginBlock]);
|
|
110
|
+
|
|
111
|
+
React.useLayoutEffect(() => {
|
|
112
|
+
updateFullHeight();
|
|
113
|
+
}, [updateFullHeight]);
|
|
114
|
+
|
|
115
|
+
React.useEffect(() => {
|
|
116
|
+
if (heightMode !== 'fullHeight' || typeof window === 'undefined') return;
|
|
117
|
+
const hostEl = hostRef.current;
|
|
118
|
+
if (!hostEl || typeof ResizeObserver === 'undefined') return;
|
|
119
|
+
const root = getRootElement(hostEl);
|
|
120
|
+
const pageHeader = getPageHeader(root);
|
|
121
|
+
const addBlockContainer = getAddBlockContainer(root);
|
|
122
|
+
const observer = new ResizeObserver(() => updateFullHeight());
|
|
123
|
+
observer.observe(hostEl);
|
|
124
|
+
if (root instanceof HTMLElement) {
|
|
125
|
+
observer.observe(root);
|
|
126
|
+
}
|
|
127
|
+
if (pageHeader) observer.observe(pageHeader);
|
|
128
|
+
if (addBlockContainer) observer.observe(addBlockContainer);
|
|
129
|
+
window.addEventListener('resize', updateFullHeight);
|
|
130
|
+
return () => {
|
|
131
|
+
observer.disconnect();
|
|
132
|
+
window.removeEventListener('resize', updateFullHeight);
|
|
133
|
+
};
|
|
134
|
+
}, [heightMode, hostRef, updateFullHeight]);
|
|
135
|
+
|
|
136
|
+
if (heightMode === 'specifyValue') {
|
|
137
|
+
return height;
|
|
138
|
+
}
|
|
139
|
+
if (heightMode === 'fullHeight') {
|
|
140
|
+
return fullHeight;
|
|
141
|
+
}
|
|
142
|
+
return null;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const JSBlockPlainHost = ({
|
|
146
|
+
uid,
|
|
147
|
+
className,
|
|
148
|
+
heightMode,
|
|
149
|
+
height,
|
|
150
|
+
style,
|
|
151
|
+
beforeContent,
|
|
152
|
+
afterContent,
|
|
153
|
+
contentRef,
|
|
154
|
+
marginBlock,
|
|
155
|
+
...rest
|
|
156
|
+
}: React.HTMLAttributes<HTMLDivElement> & {
|
|
157
|
+
uid: string;
|
|
158
|
+
heightMode?: string;
|
|
159
|
+
height?: number;
|
|
160
|
+
beforeContent?: React.ReactNode;
|
|
161
|
+
afterContent?: React.ReactNode;
|
|
162
|
+
contentRef: React.RefObject<HTMLDivElement>;
|
|
163
|
+
marginBlock: number;
|
|
164
|
+
}) => {
|
|
165
|
+
const hostRef = React.useRef<HTMLDivElement | null>(null);
|
|
166
|
+
const resolvedHeight = usePlainHostHeight({ height, heightMode, hostRef, marginBlock });
|
|
167
|
+
|
|
168
|
+
return (
|
|
169
|
+
<div
|
|
170
|
+
{...rest}
|
|
171
|
+
ref={hostRef}
|
|
172
|
+
id={`model-${uid}`}
|
|
173
|
+
className={className}
|
|
174
|
+
style={{
|
|
175
|
+
display: 'flex',
|
|
176
|
+
flexDirection: 'column',
|
|
177
|
+
height: resolvedHeight ?? undefined,
|
|
178
|
+
minHeight: 0,
|
|
179
|
+
overflow: 'auto',
|
|
180
|
+
...(style || {}),
|
|
181
|
+
}}
|
|
182
|
+
>
|
|
183
|
+
{beforeContent}
|
|
184
|
+
<div ref={contentRef} />
|
|
185
|
+
{afterContent}
|
|
186
|
+
</div>
|
|
187
|
+
);
|
|
188
|
+
};
|
|
189
|
+
|
|
19
190
|
export class JSBlockModel extends BlockModel {
|
|
20
191
|
// Avoid double-run on first mount; only rerun after remounts
|
|
21
192
|
private _mountedOnce = false;
|
|
193
|
+
|
|
194
|
+
get showBlockCard() {
|
|
195
|
+
return this.getStepParams('jsSettings', 'showBlockCard')?.showBlockCard !== false;
|
|
196
|
+
}
|
|
197
|
+
|
|
22
198
|
renderComponent(): React.ReactNode {
|
|
23
199
|
return <div ref={this.context.ref} />;
|
|
24
200
|
}
|
|
25
201
|
render() {
|
|
26
202
|
const decoratorProps = this.decoratorProps || {};
|
|
27
|
-
const {
|
|
203
|
+
const {
|
|
204
|
+
className,
|
|
205
|
+
id: _ignoredId,
|
|
206
|
+
title,
|
|
207
|
+
description,
|
|
208
|
+
showCard: _ignoredShowCard,
|
|
209
|
+
heightMode,
|
|
210
|
+
height,
|
|
211
|
+
style,
|
|
212
|
+
beforeContent,
|
|
213
|
+
afterContent,
|
|
214
|
+
...rest
|
|
215
|
+
} = decoratorProps;
|
|
28
216
|
const mergedClassName = ['code-block', className].filter(Boolean).join(' ');
|
|
29
217
|
|
|
218
|
+
if (!this.showBlockCard) {
|
|
219
|
+
return (
|
|
220
|
+
<JSBlockPlainHost
|
|
221
|
+
{...rest}
|
|
222
|
+
uid={this.uid}
|
|
223
|
+
className={mergedClassName}
|
|
224
|
+
heightMode={heightMode}
|
|
225
|
+
height={height}
|
|
226
|
+
style={style}
|
|
227
|
+
beforeContent={beforeContent}
|
|
228
|
+
afterContent={afterContent}
|
|
229
|
+
contentRef={this.context.ref}
|
|
230
|
+
marginBlock={this.context.themeToken?.marginBlock ?? 0}
|
|
231
|
+
/>
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const cardProps = {
|
|
236
|
+
...rest,
|
|
237
|
+
height,
|
|
238
|
+
style,
|
|
239
|
+
...(beforeContent === undefined ? {} : { beforeContent }),
|
|
240
|
+
...(afterContent === undefined ? {} : { afterContent }),
|
|
241
|
+
};
|
|
242
|
+
|
|
30
243
|
return (
|
|
31
244
|
<BlockItemCard
|
|
32
245
|
id={`model-${this.uid}`}
|
|
33
246
|
className={mergedClassName}
|
|
34
247
|
title={title}
|
|
35
248
|
description={description}
|
|
36
|
-
{
|
|
249
|
+
heightMode={heightMode}
|
|
250
|
+
{...cardProps}
|
|
37
251
|
>
|
|
38
252
|
<div ref={this.context.ref} />
|
|
39
253
|
</BlockItemCard>
|
|
@@ -61,6 +275,13 @@ JSBlockModel.registerFlow({
|
|
|
61
275
|
key: 'jsSettings',
|
|
62
276
|
title: 'JavaScript settings',
|
|
63
277
|
steps: {
|
|
278
|
+
showBlockCard: {
|
|
279
|
+
title: tExpr('Show block card'),
|
|
280
|
+
uiMode: { type: 'switch', key: 'showBlockCard' },
|
|
281
|
+
defaultParams: {
|
|
282
|
+
showBlockCard: true,
|
|
283
|
+
},
|
|
284
|
+
},
|
|
64
285
|
runJs: {
|
|
65
286
|
title: tExpr('Write JavaScript'),
|
|
66
287
|
useRawParams: true,
|
|
@@ -167,12 +388,7 @@ ctx.render(\`
|
|
|
167
388
|
},
|
|
168
389
|
},
|
|
169
390
|
});
|
|
170
|
-
|
|
171
|
-
await ctx.runjs(
|
|
172
|
-
code,
|
|
173
|
-
{ window: createSafeWindow({ navigator }), document: createSafeDocument(), navigator },
|
|
174
|
-
{ version },
|
|
175
|
-
);
|
|
391
|
+
await ctx.runjs(code, undefined, { version });
|
|
176
392
|
});
|
|
177
393
|
},
|
|
178
394
|
},
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file is part of the NocoBase (R) project.
|
|
3
|
+
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
|
4
|
+
* Authors: NocoBase Team.
|
|
5
|
+
*
|
|
6
|
+
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
|
+
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import { App, ConfigProvider } from 'antd';
|
|
12
|
+
import { render } from '@nocobase/test/client';
|
|
13
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
14
|
+
import { FlowEngine, FlowEngineProvider } from '@nocobase/flow-engine';
|
|
15
|
+
import { JSBlockModel } from '../JSBlock';
|
|
16
|
+
|
|
17
|
+
function createJSBlock(uid: string, showBlockCard?: boolean, decoratorProps?: Record<string, unknown>) {
|
|
18
|
+
const engine = new FlowEngine();
|
|
19
|
+
engine.registerModels({ JSBlockModel });
|
|
20
|
+
const model = engine.createModel<JSBlockModel>({
|
|
21
|
+
use: 'JSBlockModel',
|
|
22
|
+
uid,
|
|
23
|
+
stepParams:
|
|
24
|
+
typeof showBlockCard === 'boolean'
|
|
25
|
+
? {
|
|
26
|
+
jsSettings: {
|
|
27
|
+
showBlockCard: {
|
|
28
|
+
showBlockCard,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
}
|
|
32
|
+
: undefined,
|
|
33
|
+
});
|
|
34
|
+
model.setDecoratorProps({
|
|
35
|
+
className: 'custom-js-block-shell',
|
|
36
|
+
style: {
|
|
37
|
+
minHeight: 120,
|
|
38
|
+
},
|
|
39
|
+
...(decoratorProps || {}),
|
|
40
|
+
});
|
|
41
|
+
return { engine, model };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function renderBlock(engine: FlowEngine, model: JSBlockModel) {
|
|
45
|
+
return render(
|
|
46
|
+
<FlowEngineProvider engine={engine}>
|
|
47
|
+
<ConfigProvider>
|
|
48
|
+
<App>{model.render()}</App>
|
|
49
|
+
</ConfigProvider>
|
|
50
|
+
</FlowEngineProvider>,
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
describe('JSBlockModel', () => {
|
|
55
|
+
it('renders with the outer block card by default', () => {
|
|
56
|
+
const { engine, model } = createJSBlock('js-block-with-card');
|
|
57
|
+
const { container } = renderBlock(engine, model);
|
|
58
|
+
const host = container.querySelector('#model-js-block-with-card');
|
|
59
|
+
|
|
60
|
+
expect(host).toBeTruthy();
|
|
61
|
+
expect(host?.classList.contains('ant-card')).toBe(true);
|
|
62
|
+
expect(host?.classList.contains('code-block')).toBe(true);
|
|
63
|
+
expect(host?.classList.contains('custom-js-block-shell')).toBe(true);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('renders a plain host without the outer card when showBlockCard is false', () => {
|
|
67
|
+
const { engine, model } = createJSBlock('js-block-without-card', false, {
|
|
68
|
+
showCard: true,
|
|
69
|
+
});
|
|
70
|
+
const { container } = renderBlock(engine, model);
|
|
71
|
+
const host = container.querySelector('#model-js-block-without-card') as HTMLElement | null;
|
|
72
|
+
|
|
73
|
+
expect(container.querySelector('.ant-card')).toBeNull();
|
|
74
|
+
expect(host).toBeInstanceOf(HTMLDivElement);
|
|
75
|
+
expect(host?.classList.contains('code-block')).toBe(true);
|
|
76
|
+
expect(host?.classList.contains('custom-js-block-shell')).toBe(true);
|
|
77
|
+
expect(host?.style.minHeight).toBe('120px');
|
|
78
|
+
expect(model.context.ref.current).toBe(host?.firstElementChild);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('keeps cardless specified-height content scrollable inside the plain host', () => {
|
|
82
|
+
const { engine, model } = createJSBlock('js-block-without-card-height', false, {
|
|
83
|
+
heightMode: 'specifyValue',
|
|
84
|
+
height: 80,
|
|
85
|
+
style: undefined,
|
|
86
|
+
});
|
|
87
|
+
const { container } = renderBlock(engine, model);
|
|
88
|
+
const host = container.querySelector('#model-js-block-without-card-height') as HTMLElement | null;
|
|
89
|
+
const overflowContent = document.createElement('div');
|
|
90
|
+
overflowContent.style.height = '200px';
|
|
91
|
+
model.context.ref.current?.appendChild(overflowContent);
|
|
92
|
+
|
|
93
|
+
expect(host?.style.height).toBe('80px');
|
|
94
|
+
expect(host?.style.minHeight).toBe('0');
|
|
95
|
+
expect(host?.style.overflow).toBe('auto');
|
|
96
|
+
expect(model.context.ref.current?.firstElementChild).toBe(overflowContent);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('calculates cardless full-height on the plain host', () => {
|
|
100
|
+
const originalInnerHeight = window.innerHeight;
|
|
101
|
+
Object.defineProperty(window, 'innerHeight', {
|
|
102
|
+
configurable: true,
|
|
103
|
+
value: 500,
|
|
104
|
+
});
|
|
105
|
+
const rectSpy = vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockImplementation(function () {
|
|
106
|
+
if ((this as HTMLElement).id === 'model-js-block-without-card-full-height') {
|
|
107
|
+
return {
|
|
108
|
+
x: 0,
|
|
109
|
+
y: 150,
|
|
110
|
+
top: 150,
|
|
111
|
+
left: 0,
|
|
112
|
+
bottom: 150,
|
|
113
|
+
right: 0,
|
|
114
|
+
width: 0,
|
|
115
|
+
height: 0,
|
|
116
|
+
toJSON: () => ({}),
|
|
117
|
+
} as DOMRect;
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
x: 0,
|
|
121
|
+
y: 0,
|
|
122
|
+
top: 0,
|
|
123
|
+
left: 0,
|
|
124
|
+
bottom: 0,
|
|
125
|
+
right: 0,
|
|
126
|
+
width: 0,
|
|
127
|
+
height: 0,
|
|
128
|
+
toJSON: () => ({}),
|
|
129
|
+
} as DOMRect;
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
try {
|
|
133
|
+
const { engine, model } = createJSBlock('js-block-without-card-full-height', false, {
|
|
134
|
+
heightMode: 'fullHeight',
|
|
135
|
+
style: undefined,
|
|
136
|
+
});
|
|
137
|
+
const { container } = renderBlock(engine, model);
|
|
138
|
+
const host = container.querySelector('#model-js-block-without-card-full-height') as HTMLElement | null;
|
|
139
|
+
|
|
140
|
+
expect(parseInt(host?.style.height || '0', 10)).toBeGreaterThan(0);
|
|
141
|
+
expect(host?.style.overflow).toBe('auto');
|
|
142
|
+
} finally {
|
|
143
|
+
rectSpy.mockRestore();
|
|
144
|
+
Object.defineProperty(window, 'innerHeight', {
|
|
145
|
+
configurable: true,
|
|
146
|
+
value: originalInnerHeight,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
});
|
|
@@ -19,9 +19,6 @@ import {
|
|
|
19
19
|
createRecordMetaFactory,
|
|
20
20
|
createRecordResolveOnServerWithLocal,
|
|
21
21
|
ElementProxy,
|
|
22
|
-
createSafeDocument,
|
|
23
|
-
createSafeWindow,
|
|
24
|
-
createSafeNavigator,
|
|
25
22
|
observer,
|
|
26
23
|
} from '@nocobase/flow-engine';
|
|
27
24
|
import { Tooltip } from 'antd';
|
|
@@ -294,12 +291,7 @@ JSColumnModel.registerFlow({
|
|
|
294
291
|
get: () => new ElementProxy((ctx.ref?.current as HTMLElement | null) || element),
|
|
295
292
|
cache: false,
|
|
296
293
|
});
|
|
297
|
-
|
|
298
|
-
await ctx.runjs(
|
|
299
|
-
code,
|
|
300
|
-
{ window: createSafeWindow({ navigator }), document: createSafeDocument(), navigator },
|
|
301
|
-
{ version },
|
|
302
|
-
);
|
|
294
|
+
await ctx.runjs(code, undefined, { version });
|
|
303
295
|
});
|
|
304
296
|
},
|
|
305
297
|
},
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
observer,
|
|
23
23
|
} from '@nocobase/flow-engine';
|
|
24
24
|
import { Skeleton, Tooltip } from 'antd';
|
|
25
|
+
import classNames from 'classnames';
|
|
25
26
|
import React from 'react';
|
|
26
27
|
import { ActionModel } from '../../base/ActionModel';
|
|
27
28
|
import { TableCustomColumnModel } from './TableCustomColumnModel';
|
|
@@ -33,6 +34,33 @@ const rowActionButtonTypeOptions = [
|
|
|
33
34
|
{ value: 'link', label: '{{t("Link")}}' },
|
|
34
35
|
{ value: 'text', label: '{{t("Text")}}' },
|
|
35
36
|
];
|
|
37
|
+
export const tableRowActionsClassName = css`
|
|
38
|
+
display: flex;
|
|
39
|
+
flex-wrap: wrap;
|
|
40
|
+
align-items: center;
|
|
41
|
+
line-height: inherit;
|
|
42
|
+
> div:empty {
|
|
43
|
+
display: none;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.nb-table-row-action-button.ant-btn-link,
|
|
47
|
+
.nb-table-row-action-button.ant-btn-text {
|
|
48
|
+
display: inline-flex;
|
|
49
|
+
align-items: center;
|
|
50
|
+
font: inherit;
|
|
51
|
+
height: auto;
|
|
52
|
+
line-height: inherit;
|
|
53
|
+
padding: 0;
|
|
54
|
+
border: 0;
|
|
55
|
+
box-shadow: none;
|
|
56
|
+
vertical-align: baseline;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.nb-table-row-action-button.ant-btn-link > span,
|
|
60
|
+
.nb-table-row-action-button.ant-btn-text > span {
|
|
61
|
+
line-height: inherit;
|
|
62
|
+
}
|
|
63
|
+
`;
|
|
36
64
|
|
|
37
65
|
const Columns = observer<any>(({ record, model, index }) => {
|
|
38
66
|
const isConfigMode = !!model.context.flowSettingsEnabled;
|
|
@@ -42,17 +70,7 @@ const Columns = observer<any>(({ record, model, index }) => {
|
|
|
42
70
|
<DndProvider>
|
|
43
71
|
<div
|
|
44
72
|
style={{ gap: model.context?.themeToken?.marginSM ?? 16 }}
|
|
45
|
-
className={
|
|
46
|
-
display: flex;
|
|
47
|
-
flex-wrap: wrap;
|
|
48
|
-
align-items: center;
|
|
49
|
-
> div:empty {
|
|
50
|
-
display: none;
|
|
51
|
-
}
|
|
52
|
-
button {
|
|
53
|
-
padding: 0;
|
|
54
|
-
}
|
|
55
|
-
`}
|
|
73
|
+
className={`nb-table-row-actions ${tableRowActionsClassName}`}
|
|
56
74
|
>
|
|
57
75
|
{model.mapSubModels('actions', (action: ActionModel) => {
|
|
58
76
|
// Static hidden can be skipped safely; dynamic hidden is handled by fork.beforeRender + model.render wrapper.
|
|
@@ -68,7 +86,12 @@ const Columns = observer<any>(({ record, model, index }) => {
|
|
|
68
86
|
cachedFork.dispose();
|
|
69
87
|
}
|
|
70
88
|
|
|
71
|
-
const fork = action.createFork(
|
|
89
|
+
const fork = action.createFork(
|
|
90
|
+
{
|
|
91
|
+
className: classNames(action.props?.className, 'nb-table-row-action-button'),
|
|
92
|
+
},
|
|
93
|
+
slotKey,
|
|
94
|
+
);
|
|
72
95
|
(fork as any).buttonTypeOptions = rowActionButtonTypeOptions;
|
|
73
96
|
recordIdentityByFork.set(fork, recordIdentity);
|
|
74
97
|
|
|
@@ -140,7 +163,7 @@ const AddActionToolbarComponent = observer(({ model }: any) => {
|
|
|
140
163
|
subModelBaseClass={model.context.getModelClassName('RecordActionGroupModel')}
|
|
141
164
|
subModelKey="actions"
|
|
142
165
|
afterSubModelInit={async (actionModel) => {
|
|
143
|
-
actionModel.setStepParams('buttonSettings', 'general', { type: 'link', icon: null });
|
|
166
|
+
actionModel.setStepParams('buttonSettings', 'general', { type: 'link', icon: null, iconOnly: false });
|
|
144
167
|
}}
|
|
145
168
|
>
|
|
146
169
|
<PlusOutlined />
|
|
@@ -55,6 +55,7 @@ import {
|
|
|
55
55
|
useDragSortRowComponent,
|
|
56
56
|
dragSortSettings,
|
|
57
57
|
dragSortBySettings,
|
|
58
|
+
hasSortField,
|
|
58
59
|
} from './dragSort';
|
|
59
60
|
|
|
60
61
|
const MemoizedTable = React.memo(Table);
|
|
@@ -179,11 +180,21 @@ const AddFieldColumn = ({ model }: { model: TableBlockModel }) => {
|
|
|
179
180
|
].filter(Boolean)}
|
|
180
181
|
keepDropdownOpen
|
|
181
182
|
>
|
|
182
|
-
|
|
183
|
+
{renderTableSettingsButton(model, 'Fields')}
|
|
183
184
|
</AddSubModelButton>
|
|
184
185
|
);
|
|
185
186
|
};
|
|
186
187
|
|
|
188
|
+
function renderTableSettingsButton(model: TableBlockModel, title: string) {
|
|
189
|
+
const label = model.translate(title);
|
|
190
|
+
|
|
191
|
+
return (
|
|
192
|
+
<FlowSettingsButton aria-label={label} icon={<SettingOutlined />}>
|
|
193
|
+
{model.context.isMobileLayout ? null : label}
|
|
194
|
+
</FlowSettingsButton>
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
|
|
187
198
|
type CustomTableBlockModelClassesEnum = {
|
|
188
199
|
CollectionActionGroupModel?: string;
|
|
189
200
|
RecordActionGroupModel?: string;
|
|
@@ -265,7 +276,7 @@ export class TableBlockModel extends CollectionBlockModel<TableBlockModelStructu
|
|
|
265
276
|
cols.push({
|
|
266
277
|
key: 'addColumn',
|
|
267
278
|
fixed: 'right',
|
|
268
|
-
width: 100,
|
|
279
|
+
...(this.context.isMobileLayout ? {} : { width: 100 }),
|
|
269
280
|
title: <AddFieldColumn model={this} />,
|
|
270
281
|
} as any);
|
|
271
282
|
}
|
|
@@ -419,9 +430,18 @@ export class TableBlockModel extends CollectionBlockModel<TableBlockModelStructu
|
|
|
419
430
|
return nextIndex;
|
|
420
431
|
}
|
|
421
432
|
|
|
433
|
+
getDragSortFieldName(): string | undefined {
|
|
434
|
+
const dragSortBy = this.props.dragSortBy;
|
|
435
|
+
if (!this.props.dragSort || typeof dragSortBy !== 'string' || !hasSortField(this.collection, dragSortBy)) {
|
|
436
|
+
return undefined;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
return dragSortBy;
|
|
440
|
+
}
|
|
441
|
+
|
|
422
442
|
getLeftAuxiliaryColumn() {
|
|
423
443
|
const showIndex = this.isShowIndexEnabled();
|
|
424
|
-
const showDragHandle = this.
|
|
444
|
+
const showDragHandle = !!this.getDragSortFieldName();
|
|
425
445
|
if (!showIndex && !showDragHandle) {
|
|
426
446
|
return null;
|
|
427
447
|
}
|
|
@@ -467,7 +487,7 @@ export class TableBlockModel extends CollectionBlockModel<TableBlockModelStructu
|
|
|
467
487
|
index = this.getRecordIndex(record, index);
|
|
468
488
|
const rowKey = getRowKey(record, this.collection.filterTargetKey);
|
|
469
489
|
const rowKeyString = rowKey == null ? rowKey : String(rowKey);
|
|
470
|
-
const showDragHandle = this.
|
|
490
|
+
const showDragHandle = !!this.getDragSortFieldName();
|
|
471
491
|
return (
|
|
472
492
|
<div
|
|
473
493
|
role="button"
|
|
@@ -508,7 +528,7 @@ export class TableBlockModel extends CollectionBlockModel<TableBlockModelStructu
|
|
|
508
528
|
subModelBaseClass={this.getModelClassName('CollectionActionGroupModel')}
|
|
509
529
|
subModelKey="actions"
|
|
510
530
|
>
|
|
511
|
-
|
|
531
|
+
{renderTableSettingsButton(this, 'Actions')}
|
|
512
532
|
</AddSubModelButton>
|
|
513
533
|
);
|
|
514
534
|
}
|
|
@@ -1072,11 +1092,13 @@ const HighPerformanceTable = React.memo(
|
|
|
1072
1092
|
};
|
|
1073
1093
|
}, [rowKeys]);
|
|
1074
1094
|
|
|
1095
|
+
const dragSortFieldName = model.getDragSortFieldName();
|
|
1096
|
+
|
|
1075
1097
|
// 拖拽相关的 Body Wrapper 组件
|
|
1076
|
-
const BodyWrapperComponent = useDragSortBodyWrapper(model, dataSourceRef, getRowKeyFunc);
|
|
1098
|
+
const BodyWrapperComponent = useDragSortBodyWrapper(model, dataSourceRef, getRowKeyFunc, dragSortFieldName);
|
|
1077
1099
|
|
|
1078
1100
|
// 行组件
|
|
1079
|
-
const RowComponent = useDragSortRowComponent(
|
|
1101
|
+
const RowComponent = useDragSortRowComponent(!!dragSortFieldName);
|
|
1080
1102
|
|
|
1081
1103
|
const components = useMemo(() => {
|
|
1082
1104
|
return {
|
|
@@ -1099,15 +1121,14 @@ const HighPerformanceTable = React.memo(
|
|
|
1099
1121
|
}
|
|
1100
1122
|
`;
|
|
1101
1123
|
|
|
1102
|
-
const selectionPaddingClass =
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
: undefined;
|
|
1124
|
+
const selectionPaddingClass = dragSortFieldName
|
|
1125
|
+
? css`
|
|
1126
|
+
.ant-table-thead > tr > th.ant-table-selection-column,
|
|
1127
|
+
.ant-table-tbody > tr > td.ant-table-selection-column {
|
|
1128
|
+
padding-left: 32px !important;
|
|
1129
|
+
}
|
|
1130
|
+
`
|
|
1131
|
+
: undefined;
|
|
1111
1132
|
|
|
1112
1133
|
const tableBodyMinHeightClass = tableScroll?.y
|
|
1113
1134
|
? css`
|
|
@@ -1118,7 +1139,7 @@ const HighPerformanceTable = React.memo(
|
|
|
1118
1139
|
: undefined;
|
|
1119
1140
|
|
|
1120
1141
|
return classNames(baseClass, selectionPaddingClass, tableBodyMinHeightClass);
|
|
1121
|
-
}, [
|
|
1142
|
+
}, [dragSortFieldName, tableScroll?.y]);
|
|
1122
1143
|
|
|
1123
1144
|
return (
|
|
1124
1145
|
<MemoizedTable
|