@pisell/materials 6.0.12 → 6.0.14
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/index.js +1 -1
- package/build/lowcode/meta.js +7 -7
- package/build/lowcode/preview.js +8 -8
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +11 -11
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +11 -11
- package/es/components/dataSourceComponents/dataSourceForm/provider/formSetting/FormSettingContext.d.ts +1 -1
- package/es/components/dataSourceComponents/dataSourceForm/submitButton/index.js +1 -1
- package/es/components/dataSourceComponents/dataSourceForm/utils.js +6 -9
- package/es/components/dataSourceComponents/dataSourceMenu/Basic.d.ts +2 -0
- package/es/components/dataSourceComponents/dataSourceMenu/Basic.js +61 -0
- package/es/components/dataSourceComponents/dataSourceMenu/index.js +39 -10
- package/es/components/dataSourceComponents/dataSourceTable/hooks/useDrawerState.d.ts +2 -2
- package/es/components/dataSourceComponents/dataSourceTable/hooks/useFormat.d.ts +6 -2
- package/es/components/dataSourceComponents/dataSourceTable/hooks/useFormat.js +16 -1
- package/es/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +3 -3
- package/es/components/dataSourceComponents/fields/DatePicker/ReadPretty.d.ts +2 -2
- package/es/components/dataSourceComponents/fields/DatePicker/ReadPretty.js +42 -5
- package/es/components/dataSourceComponents/fields/DatePicker/WithMode.js +1 -1
- package/es/components/dataSourceComponents/fields/DatePicker/type.d.ts +1 -0
- package/es/components/dataSourceComponents/fields/Input.Subdomain/WithMode.js +4 -2
- package/es/components/dataSourceComponents/fields/index.d.ts +1 -1
- package/es/components/dataSourceComponents/hooks/useActions.js +9 -3
- package/es/components/date-picker/datePickerCpt.js +4 -2
- package/es/components/pisellDraggable/components/TreeItem/TreeItem.d.ts +1 -0
- package/es/components/pisellDraggable/components/TreeItem/TreeItem.js +2 -1
- package/es/components/pisellDraggable/index.d.ts +3 -1
- package/es/components/pisellDraggable/index.js +89 -9
- package/es/components/pisellDraggable/types.d.ts +1 -0
- package/es/components/pisellLayout/content.d.ts +2 -0
- package/es/components/pisellLayout/content.js +26 -4
- package/es/components/pisellLayout/footer.d.ts +1 -0
- package/es/components/pisellLayout/footer.js +18 -3
- package/es/components/pisellLayout/header.d.ts +3 -0
- package/es/components/pisellLayout/header.js +26 -3
- package/es/components/pisellLayout/index.js +4 -1
- package/es/components/pisellLayout/index.less +23 -0
- package/es/components/pisellLayout/sider.d.ts +1 -0
- package/es/components/pisellLayout/sider.js +38 -3
- package/es/components/pisellMenu/PisellMenu.d.ts +5 -1
- package/es/components/pisellMenu/PisellMenu.js +10 -4
- package/es/components/pisellMenu/types.d.ts +6 -10
- package/es/components/table/Table/utils.d.ts +1 -1
- package/es/hooks/useEngineContext.js +11 -0
- package/lib/components/dataSourceComponents/dataSourceForm/provider/formSetting/FormSettingContext.d.ts +1 -1
- package/lib/components/dataSourceComponents/dataSourceForm/submitButton/index.js +1 -1
- package/lib/components/dataSourceComponents/dataSourceForm/utils.js +0 -6
- package/lib/components/dataSourceComponents/dataSourceMenu/Basic.d.ts +2 -0
- package/lib/components/dataSourceComponents/dataSourceMenu/Basic.js +92 -0
- package/lib/components/dataSourceComponents/dataSourceMenu/index.js +36 -6
- package/lib/components/dataSourceComponents/dataSourceTable/hooks/useDrawerState.d.ts +2 -2
- package/lib/components/dataSourceComponents/dataSourceTable/hooks/useFormat.d.ts +6 -2
- package/lib/components/dataSourceComponents/dataSourceTable/hooks/useFormat.js +17 -1
- package/lib/components/dataSourceComponents/dataSourceTable/hooks/useTableProps.d.ts +3 -3
- package/lib/components/dataSourceComponents/fields/DatePicker/ReadPretty.d.ts +2 -2
- package/lib/components/dataSourceComponents/fields/DatePicker/ReadPretty.js +37 -3
- package/lib/components/dataSourceComponents/fields/DatePicker/WithMode.js +1 -1
- package/lib/components/dataSourceComponents/fields/DatePicker/type.d.ts +1 -0
- package/lib/components/dataSourceComponents/fields/Input.Subdomain/WithMode.js +2 -2
- package/lib/components/dataSourceComponents/fields/index.d.ts +1 -1
- package/lib/components/dataSourceComponents/hooks/useActions.js +3 -0
- package/lib/components/date-picker/datePickerCpt.js +4 -2
- package/lib/components/pisellDraggable/components/TreeItem/TreeItem.d.ts +1 -0
- package/lib/components/pisellDraggable/components/TreeItem/TreeItem.js +1 -0
- package/lib/components/pisellDraggable/index.d.ts +3 -1
- package/lib/components/pisellDraggable/index.js +59 -7
- package/lib/components/pisellDraggable/types.d.ts +1 -0
- package/lib/components/pisellLayout/content.d.ts +2 -0
- package/lib/components/pisellLayout/content.js +14 -3
- package/lib/components/pisellLayout/footer.d.ts +1 -0
- package/lib/components/pisellLayout/footer.js +8 -2
- package/lib/components/pisellLayout/header.d.ts +3 -0
- package/lib/components/pisellLayout/header.js +13 -2
- package/lib/components/pisellLayout/index.js +3 -0
- package/lib/components/pisellLayout/index.less +23 -0
- package/lib/components/pisellLayout/sider.d.ts +1 -0
- package/lib/components/pisellLayout/sider.js +30 -2
- package/lib/components/pisellMenu/PisellMenu.d.ts +5 -1
- package/lib/components/pisellMenu/PisellMenu.js +12 -4
- package/lib/components/pisellMenu/types.d.ts +6 -10
- package/lib/components/table/Table/utils.d.ts +1 -1
- package/lib/hooks/useEngineContext.js +6 -0
- package/lowcode/data-source-menu/meta.ts +66 -6
- package/lowcode/form-item-translation/meta.ts +59 -1
- package/lowcode/pisell-content/__screenshots__/content.png +0 -0
- package/lowcode/pisell-content/meta.ts +28 -5
- package/lowcode/pisell-footer/__screenshots__/footer.png +0 -0
- package/lowcode/pisell-footer/meta.ts +17 -4
- package/lowcode/pisell-header/__screenshots__/header.png +0 -0
- package/lowcode/pisell-header/meta.ts +29 -5
- package/lowcode/pisell-layout/__screenshots__/layout.png +0 -0
- package/lowcode/pisell-layout/meta.ts +10 -5
- package/lowcode/pisell-sider/__screenshots__/sider.png +0 -0
- package/lowcode/pisell-sider/meta.ts +41 -4
- package/package.json +30 -28
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { ModeType } from '../../type';
|
|
3
3
|
export interface FormSettingContextType {
|
|
4
|
-
onDataSourceFinish?: (values: any, result: any) => void;
|
|
4
|
+
onDataSourceFinish?: (values: any, result: any, form: any) => void;
|
|
5
5
|
renderMode?: ModeType;
|
|
6
6
|
groupInfoPosition?: 'top' | 'side';
|
|
7
7
|
children?: React.ReactNode;
|
|
@@ -155,7 +155,7 @@ var SubmitButton = function SubmitButton(props) {
|
|
|
155
155
|
result = _context2.sent;
|
|
156
156
|
// 数据源提交成功
|
|
157
157
|
if (onDataSourceFinish) {
|
|
158
|
-
onDataSourceFinish(formattedValues, result);
|
|
158
|
+
onDataSourceFinish(formattedValues, result, form);
|
|
159
159
|
}
|
|
160
160
|
if (refreshData) {
|
|
161
161
|
refreshTableData === null || refreshTableData === void 0 ? void 0 : refreshTableData();
|
|
@@ -170,7 +170,7 @@ export var withFormItem = function withFormItem(WrappedComponent, overlayProps)
|
|
|
170
170
|
}));
|
|
171
171
|
break;
|
|
172
172
|
case 'phone':
|
|
173
|
-
rules.push(
|
|
173
|
+
rules.push({
|
|
174
174
|
validator: function validator(_, value) {
|
|
175
175
|
// 如果值为空或者只有空格,直接返回成功,不进行校验
|
|
176
176
|
if (!(value !== null && value !== void 0 && value.trim())) {
|
|
@@ -189,10 +189,10 @@ export var withFormItem = function withFormItem(WrappedComponent, overlayProps)
|
|
|
189
189
|
return Promise.reject(new Error(typeobj.message || getText('pisell-data-source-form-phone-message')));
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
|
-
})
|
|
192
|
+
});
|
|
193
193
|
break;
|
|
194
194
|
case 'mobile':
|
|
195
|
-
rules.push(
|
|
195
|
+
rules.push({
|
|
196
196
|
validator: function validator(_, value) {
|
|
197
197
|
// 如果值为空或者只有空格,直接返回成功,不进行校验
|
|
198
198
|
if (!(value !== null && value !== void 0 && value.trim())) {
|
|
@@ -232,16 +232,13 @@ export var withFormItem = function withFormItem(WrappedComponent, overlayProps)
|
|
|
232
232
|
return Promise.resolve();
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
|
-
})
|
|
235
|
+
});
|
|
236
236
|
break;
|
|
237
237
|
case 'subdomain':
|
|
238
|
-
rules.push(
|
|
238
|
+
rules.push({
|
|
239
239
|
validator: function validator(_, value) {
|
|
240
240
|
if (!value) return Promise.resolve();
|
|
241
241
|
var subdomain = value.split('.')[0];
|
|
242
|
-
if (!subdomain) {
|
|
243
|
-
return Promise.resolve();
|
|
244
|
-
}
|
|
245
242
|
if (!/^[a-z0-9-]+$/.test(subdomain)) {
|
|
246
243
|
return Promise.reject(new Error(getText('subdomain-error-pattern')));
|
|
247
244
|
}
|
|
@@ -256,7 +253,7 @@ export var withFormItem = function withFormItem(WrappedComponent, overlayProps)
|
|
|
256
253
|
}
|
|
257
254
|
return Promise.resolve();
|
|
258
255
|
}
|
|
259
|
-
})
|
|
256
|
+
});
|
|
260
257
|
break;
|
|
261
258
|
}
|
|
262
259
|
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import useEngineContext from "../../../hooks/useEngineContext";
|
|
4
|
+
import BaseMenu from "../../pisellMenu";
|
|
5
|
+
/**
|
|
6
|
+
* @title: 数据源表单组件
|
|
7
|
+
* @description: 基于数据源动态生成表单,支持编辑、查看、禁用三种模式
|
|
8
|
+
*/
|
|
9
|
+
var DataSourceMenu = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
10
|
+
var _appHelper$utils, _appHelper$utils$getA2, _appHelper$utils$getA3, _appHelper$utils$getA4;
|
|
11
|
+
var _useEngineContext = useEngineContext(),
|
|
12
|
+
appHelper = _useEngineContext.appHelper;
|
|
13
|
+
var _appHelper$utils$getA = appHelper === null || appHelper === void 0 ? void 0 : (_appHelper$utils = appHelper.utils) === null || _appHelper$utils === void 0 ? void 0 : (_appHelper$utils$getA2 = _appHelper$utils.getApp) === null || _appHelper$utils$getA2 === void 0 ? void 0 : (_appHelper$utils$getA3 = _appHelper$utils$getA2.call(_appHelper$utils)) === null || _appHelper$utils$getA3 === void 0 ? void 0 : (_appHelper$utils$getA4 = _appHelper$utils$getA3.menuManager) === null || _appHelper$utils$getA4 === void 0 ? void 0 : _appHelper$utils$getA4.useMenu(),
|
|
14
|
+
menuItems = _appHelper$utils$getA.menuItems,
|
|
15
|
+
selectedKeys = _appHelper$utils$getA.selectedKeys,
|
|
16
|
+
openKeys = _appHelper$utils$getA.openKeys,
|
|
17
|
+
setOpenKeys = _appHelper$utils$getA.setOpenKeys,
|
|
18
|
+
getShowChildren = _appHelper$utils$getA.getShowChildren,
|
|
19
|
+
handleClick = _appHelper$utils$getA.handleClick;
|
|
20
|
+
// 递归渲染菜单项
|
|
21
|
+
var renderMenuItems = function renderMenuItems(items) {
|
|
22
|
+
return items.map(function (item) {
|
|
23
|
+
if (item.hide) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
var _children = getShowChildren(item.children || []);
|
|
27
|
+
if (_children !== null && _children !== void 0 && _children.length) {
|
|
28
|
+
return /*#__PURE__*/React.createElement(BaseMenu.SubMenu, {
|
|
29
|
+
key: item.key,
|
|
30
|
+
title: item.label,
|
|
31
|
+
icon: item.icon,
|
|
32
|
+
router: item.path
|
|
33
|
+
}, renderMenuItems(_children));
|
|
34
|
+
}
|
|
35
|
+
return /*#__PURE__*/React.createElement(BaseMenu.Item, {
|
|
36
|
+
key: item.key,
|
|
37
|
+
icon: item.icon,
|
|
38
|
+
router: item.path
|
|
39
|
+
}, item.label);
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
return /*#__PURE__*/React.createElement(BaseMenu, _extends({
|
|
43
|
+
ref: ref,
|
|
44
|
+
mode: "inline"
|
|
45
|
+
// theme="dark"
|
|
46
|
+
,
|
|
47
|
+
selectedKeys: selectedKeys,
|
|
48
|
+
openKeys: openKeys,
|
|
49
|
+
onOpenChange: setOpenKeys,
|
|
50
|
+
onClick: function onClick(_ref) {
|
|
51
|
+
var _item$props;
|
|
52
|
+
var item = _ref.item;
|
|
53
|
+
handleClick((_item$props = item.props) === null || _item$props === void 0 ? void 0 : _item$props.router);
|
|
54
|
+
}
|
|
55
|
+
}, props, {
|
|
56
|
+
other: {
|
|
57
|
+
items: undefined
|
|
58
|
+
}
|
|
59
|
+
}), renderMenuItems(menuItems));
|
|
60
|
+
});
|
|
61
|
+
export default DataSourceMenu;
|
|
@@ -1,19 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import useEngineContext from "../../../hooks/useEngineContext";
|
|
3
|
+
import PisellMenu from "../../pisellMenu";
|
|
4
4
|
import useVariables from "../hooks/useVariables";
|
|
5
|
-
|
|
5
|
+
import BaseMenu from "./Basic";
|
|
6
6
|
/**
|
|
7
7
|
* @title: 数据源表单组件
|
|
8
8
|
* @description: 基于数据源动态生成表单,支持编辑、查看、禁用三种模式
|
|
9
9
|
*/
|
|
10
|
-
var DataSourceMenu =
|
|
10
|
+
var DataSourceMenu = function DataSourceMenu(props, ref) {
|
|
11
|
+
var _appHelper$utils, _appHelper$utils$getA, _appHelper$utils$getA2, _appHelper$utils$getA3;
|
|
11
12
|
var dataSource = props.dataSource;
|
|
12
13
|
var _useVariables = useVariables(),
|
|
13
14
|
parseVariable = _useVariables.parseVariable;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
var _useEngineContext = useEngineContext(),
|
|
16
|
+
appHelper = _useEngineContext.appHelper;
|
|
17
|
+
var _dataSource = useMemo(function () {
|
|
18
|
+
if (Array.isArray(dataSource)) {
|
|
19
|
+
return dataSource;
|
|
20
|
+
}
|
|
21
|
+
if (props.__designMode === 'design') {
|
|
22
|
+
return [{
|
|
23
|
+
label: '菜单项1',
|
|
24
|
+
key: 'item-1',
|
|
25
|
+
path: '/item-1'
|
|
26
|
+
}, {
|
|
27
|
+
label: '菜单项2',
|
|
28
|
+
key: 'item-2',
|
|
29
|
+
path: '/item-2'
|
|
30
|
+
}];
|
|
31
|
+
}
|
|
32
|
+
if (typeof dataSource === 'string') {
|
|
33
|
+
return parseVariable === null || parseVariable === void 0 ? void 0 : parseVariable(dataSource);
|
|
34
|
+
}
|
|
35
|
+
return [];
|
|
36
|
+
}, [dataSource]);
|
|
37
|
+
|
|
38
|
+
// 设计模式下使用PisellMenu, 否则缺少app注入导致报错
|
|
39
|
+
if (props.__designMode === 'design') {
|
|
40
|
+
return /*#__PURE__*/React.createElement(PisellMenu, props);
|
|
41
|
+
}
|
|
42
|
+
var MenuProvider = appHelper === null || appHelper === void 0 ? void 0 : (_appHelper$utils = appHelper.utils) === null || _appHelper$utils === void 0 ? void 0 : (_appHelper$utils$getA = _appHelper$utils.getApp) === null || _appHelper$utils$getA === void 0 ? void 0 : (_appHelper$utils$getA2 = _appHelper$utils$getA.call(_appHelper$utils)) === null || _appHelper$utils$getA2 === void 0 ? void 0 : (_appHelper$utils$getA3 = _appHelper$utils$getA2.menuManager) === null || _appHelper$utils$getA3 === void 0 ? void 0 : _appHelper$utils$getA3.MenuProvider;
|
|
43
|
+
console.log('MenuProvider11', appHelper);
|
|
44
|
+
return /*#__PURE__*/React.createElement(MenuProvider, {
|
|
45
|
+
menus: _dataSource
|
|
46
|
+
}, /*#__PURE__*/React.createElement(BaseMenu, props));
|
|
47
|
+
};
|
|
19
48
|
export default DataSourceMenu;
|
|
@@ -9,7 +9,7 @@ declare const useDrawerState: (operationContent?: {
|
|
|
9
9
|
openDrawer: (item: OperationItem) => void;
|
|
10
10
|
closeDrawer: () => void;
|
|
11
11
|
drawerContent: import("react").ReactNode;
|
|
12
|
-
Container:
|
|
12
|
+
Container: {
|
|
13
13
|
(props: import("../../../pisellModal").PisellModalProps): import("react").JSX.Element;
|
|
14
14
|
confirm: (props: import("../../../pisellModal/components/functions").PisellModalFuncProps) => {
|
|
15
15
|
destroy: () => void;
|
|
@@ -33,7 +33,7 @@ declare const useDrawerState: (operationContent?: {
|
|
|
33
33
|
update: (configUpdate: import("antd").ModalFuncProps | ((prevConfig: import("antd").ModalFuncProps) => import("antd").ModalFuncProps)) => void;
|
|
34
34
|
};
|
|
35
35
|
Information: (props: import("../../../pisellModal/components/Information").InformationProps) => import("react").JSX.Element;
|
|
36
|
-
};
|
|
36
|
+
} | typeof Drawer;
|
|
37
37
|
containerProps: {};
|
|
38
38
|
};
|
|
39
39
|
export default useDrawerState;
|
|
@@ -9,12 +9,16 @@ export declare type UseFormatParams = {
|
|
|
9
9
|
dataSourceKey: string;
|
|
10
10
|
fields: Field[];
|
|
11
11
|
};
|
|
12
|
-
export declare type
|
|
12
|
+
export declare type ApiListResult = {
|
|
13
13
|
list: any[];
|
|
14
14
|
count: number;
|
|
15
|
-
page: number;
|
|
16
15
|
size: number;
|
|
16
|
+
} & ({
|
|
17
|
+
page: number;
|
|
17
18
|
} | {
|
|
19
|
+
skip: number;
|
|
20
|
+
});
|
|
21
|
+
export declare type FormatListResultParams = ApiListResult | {
|
|
18
22
|
data: any[];
|
|
19
23
|
meta: {
|
|
20
24
|
count: number;
|
|
@@ -122,7 +122,7 @@ var useFormat = function useFormat(_ref4) {
|
|
|
122
122
|
fields = _ref4.fields;
|
|
123
123
|
// list接口请求 结果格式化
|
|
124
124
|
var formatListResult = useMemoizedFn(function (res) {
|
|
125
|
-
if (dataSourceKey === 'pisell2-api' && 'list' in res) {
|
|
125
|
+
if (dataSourceKey === 'pisell2-api' && 'list' in res && 'page' in res) {
|
|
126
126
|
return {
|
|
127
127
|
data: res.list,
|
|
128
128
|
count: res.count,
|
|
@@ -130,6 +130,15 @@ var useFormat = function useFormat(_ref4) {
|
|
|
130
130
|
pageSize: res.size
|
|
131
131
|
};
|
|
132
132
|
}
|
|
133
|
+
if (dataSourceKey === 'mypisell-api' && 'list' in res && 'skip' in res) {
|
|
134
|
+
var skip = typeof res.skip === 'number' ? res.skip : 1;
|
|
135
|
+
return {
|
|
136
|
+
data: res.list,
|
|
137
|
+
count: res.count,
|
|
138
|
+
page: skip - 1 || 1,
|
|
139
|
+
pageSize: res.size
|
|
140
|
+
};
|
|
141
|
+
}
|
|
133
142
|
if ('meta' in res) {
|
|
134
143
|
return {
|
|
135
144
|
data: res.data,
|
|
@@ -156,6 +165,12 @@ var useFormat = function useFormat(_ref4) {
|
|
|
156
165
|
size: (params === null || params === void 0 ? void 0 : params.pageSize) || 10
|
|
157
166
|
}, customApiFormatFilter(params.filter || {}));
|
|
158
167
|
}
|
|
168
|
+
if (dataSourceKey === 'mypisell-api') {
|
|
169
|
+
return _objectSpread({
|
|
170
|
+
skip: (params === null || params === void 0 ? void 0 : params.page) || 1,
|
|
171
|
+
num: (params === null || params === void 0 ? void 0 : params.pageSize) || 10
|
|
172
|
+
}, customApiFormatFilter(params.filter || {}));
|
|
173
|
+
}
|
|
159
174
|
return params;
|
|
160
175
|
});
|
|
161
176
|
var formatCreateUpdateParams = useMemoizedFn(function (params) {
|
|
@@ -17,7 +17,7 @@ interface UseTablePropsProps {
|
|
|
17
17
|
* @returns
|
|
18
18
|
*/
|
|
19
19
|
declare const useTableProps: (props: UseTablePropsProps) => {
|
|
20
|
-
title: number | boolean | React.
|
|
20
|
+
title: number | boolean | Iterable<React.ReactNode> | React.JSX.Element | (() => React.ReactNode) | null | undefined;
|
|
21
21
|
pagination: {
|
|
22
22
|
total: number;
|
|
23
23
|
current: number;
|
|
@@ -26,7 +26,7 @@ declare const useTableProps: (props: UseTablePropsProps) => {
|
|
|
26
26
|
showSizeChanger: boolean;
|
|
27
27
|
};
|
|
28
28
|
columns: import("./useColumns").Column[];
|
|
29
|
-
subTitle: number | boolean | React.
|
|
29
|
+
subTitle: number | boolean | Iterable<React.ReactNode> | React.JSX.Element | (() => React.ReactNode) | null | undefined;
|
|
30
30
|
buttons: any[] | null;
|
|
31
31
|
filter: React.JSX.Element | null;
|
|
32
32
|
onRow: (record: any) => any;
|
|
@@ -65,7 +65,7 @@ declare const useTableProps: (props: UseTablePropsProps) => {
|
|
|
65
65
|
useCustomAction: boolean;
|
|
66
66
|
actionType: string;
|
|
67
67
|
openMode: "modal" | "drawer";
|
|
68
|
-
openContentSize: "small" | "
|
|
68
|
+
openContentSize: "small" | "large" | "middle";
|
|
69
69
|
openTitle: string;
|
|
70
70
|
key: string;
|
|
71
71
|
} | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { FC } from 'react';
|
|
2
2
|
import { DatePickerProps } from './type';
|
|
3
3
|
import './ReadPretty.less';
|
|
4
|
-
declare const DatePickerReadPretty:
|
|
4
|
+
declare const DatePickerReadPretty: FC<DatePickerProps>;
|
|
5
5
|
export default DatePickerReadPretty;
|
|
@@ -1,14 +1,51 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import dayjs from 'dayjs';
|
|
4
|
+
import usePisellConfig from "../../../pisell-config-provider/hooks/usePisellConfig";
|
|
4
5
|
import "./ReadPretty.less";
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
var DEFAULT_FORMAT = 'YYYY-MM-DD HH:mm:ss';
|
|
7
|
+
var DATE_FORMATS = {
|
|
8
|
+
'zh-CN': {
|
|
9
|
+
withTime: 'YYYY-MM-DD HH:mm:ss',
|
|
10
|
+
withoutTime: 'YYYY-MM-DD'
|
|
11
|
+
},
|
|
12
|
+
'en-US': {
|
|
13
|
+
withTime: 'HH:mm:ss YYYY-MM-DD',
|
|
14
|
+
withoutTime: 'YYYY-MM-DD'
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var DatePickerReadPretty = function DatePickerReadPretty(_ref) {
|
|
18
|
+
var value = _ref.value,
|
|
19
|
+
renderMode = _ref.renderMode,
|
|
20
|
+
showTime = _ref.showTime;
|
|
21
|
+
var _usePisellConfig = usePisellConfig(),
|
|
22
|
+
_usePisellConfig$loca = _usePisellConfig.locale,
|
|
23
|
+
locale = _usePisellConfig$loca === void 0 ? 'zh-CN' : _usePisellConfig$loca;
|
|
24
|
+
var dateFormat = useMemo(function () {
|
|
25
|
+
if (locale in DATE_FORMATS) {
|
|
26
|
+
var formats = DATE_FORMATS[locale];
|
|
27
|
+
return showTime ? formats.withTime : formats.withoutTime;
|
|
28
|
+
}
|
|
29
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
30
|
+
console.warn("Unsupported locale: ".concat(locale, ", falling back to default format"));
|
|
31
|
+
}
|
|
32
|
+
return DEFAULT_FORMAT;
|
|
33
|
+
}, [locale, showTime]);
|
|
34
|
+
var formattedDate = useMemo(function () {
|
|
35
|
+
if (!value) return '';
|
|
36
|
+
try {
|
|
37
|
+
return dayjs(value).format(dateFormat);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
40
|
+
console.error('Error formatting date:', error);
|
|
41
|
+
}
|
|
42
|
+
return '';
|
|
43
|
+
}
|
|
44
|
+
}, [value, dateFormat]);
|
|
8
45
|
return /*#__PURE__*/React.createElement("span", {
|
|
9
46
|
className: classNames('pisell-date-picker-read-pretty', {
|
|
10
47
|
'pisell-date-picker-read-pretty-table-view': renderMode === 'tableView'
|
|
11
48
|
})
|
|
12
|
-
},
|
|
49
|
+
}, formattedDate);
|
|
13
50
|
};
|
|
14
51
|
export default DatePickerReadPretty;
|
|
@@ -11,7 +11,7 @@ import ReadPretty from "./ReadPretty";
|
|
|
11
11
|
import { withMode } from "../../dataSourceForm/utils";
|
|
12
12
|
var DatePickerWithMode = withMode(DatePickerCpt, ReadPretty, function (props) {
|
|
13
13
|
return _objectSpread(_objectSpread({}, props), {}, {
|
|
14
|
-
value: isString(props.value) ? dayjs(props.value) : props.value
|
|
14
|
+
value: isString(props.value) && props.value ? dayjs(props.value) : props.value
|
|
15
15
|
});
|
|
16
16
|
});
|
|
17
17
|
export default DatePickerWithMode;
|
|
@@ -171,7 +171,8 @@ var Subdomain = function Subdomain(props) {
|
|
|
171
171
|
var _parseExternalValue2 = parseExternalValue(inputValue),
|
|
172
172
|
newSubdomain = _parseExternalValue2.subdomain;
|
|
173
173
|
setSubdomain(newSubdomain);
|
|
174
|
-
|
|
174
|
+
// 当输入为空时,传递空字符串而不是带后缀的值
|
|
175
|
+
propsOnChange === null || propsOnChange === void 0 ? void 0 : propsOnChange(newSubdomain ? newSubdomain + suffix : '');
|
|
175
176
|
} catch (error) {
|
|
176
177
|
console.error('Error handling change:', error);
|
|
177
178
|
}
|
|
@@ -181,7 +182,8 @@ var Subdomain = function Subdomain(props) {
|
|
|
181
182
|
var onBlur = useCallback(function (e) {
|
|
182
183
|
try {
|
|
183
184
|
propsOnBlur === null || propsOnBlur === void 0 ? void 0 : propsOnBlur(e);
|
|
184
|
-
|
|
185
|
+
// 当输入为空时,传递空字符串而不是带后缀的值
|
|
186
|
+
propsOnChange === null || propsOnChange === void 0 ? void 0 : propsOnChange(subdomain ? subdomain + suffix : '');
|
|
185
187
|
} catch (error) {
|
|
186
188
|
console.error('Error handling blur:', error);
|
|
187
189
|
}
|
|
@@ -58,7 +58,7 @@ declare const formFieldMap: {
|
|
|
58
58
|
FormItemUpload: import("react").FC<import("./Upload/type").UploadProps & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps>;
|
|
59
59
|
FormItemTranslation: import("react").FC<import("./Translation/type").TranslationProps & import("../dataSourceForm/utils").WithModeProps & import("../dataSourceForm/utils").WithFormItemProps>;
|
|
60
60
|
};
|
|
61
|
-
declare const getFieldComponent: (fieldComponent: string) => import("react").FC<
|
|
61
|
+
declare const getFieldComponent: (fieldComponent: string) => import("react").FC<import("./Checkbox/type").CheckboxGroupProps & import("../dataSourceForm/utils").WithModeProps> | import("react").FC<any> | (import("react").FC<{}> & {
|
|
62
62
|
Group: import("react").FC<import("./Checkbox/type").CheckboxGroupProps & import("../dataSourceForm/utils").WithModeProps>;
|
|
63
63
|
} & {
|
|
64
64
|
Group: import("react").FC<import("./Checkbox/type").CheckboxGroupProps & import("../dataSourceForm/utils").WithModeProps>;
|
|
@@ -116,13 +116,19 @@ var useActions = function useActions() {
|
|
|
116
116
|
case 2:
|
|
117
117
|
result = _context.sent;
|
|
118
118
|
if (!['pisell2-api', 'mypisell-api'].includes(dataSourceKey)) {
|
|
119
|
-
_context.next =
|
|
119
|
+
_context.next = 7;
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
if (!('mypisell-api' === dataSourceKey && designMode === 'design')) {
|
|
123
|
+
_context.next = 6;
|
|
120
124
|
break;
|
|
121
125
|
}
|
|
122
|
-
return _context.abrupt("return", result.data);
|
|
123
|
-
case 5:
|
|
124
126
|
return _context.abrupt("return", result);
|
|
125
127
|
case 6:
|
|
128
|
+
return _context.abrupt("return", result.data);
|
|
129
|
+
case 7:
|
|
130
|
+
return _context.abrupt("return", result);
|
|
131
|
+
case 8:
|
|
126
132
|
case "end":
|
|
127
133
|
return _context.stop();
|
|
128
134
|
}
|
|
@@ -84,7 +84,8 @@ var DatePickerCpt = function DatePickerCpt(props) {
|
|
|
84
84
|
setValue(value);
|
|
85
85
|
}, [value]);
|
|
86
86
|
useEffect(function () {
|
|
87
|
-
|
|
87
|
+
var _value$format;
|
|
88
|
+
setValueStr((_value === null || _value === void 0 ? void 0 : (_value$format = _value.format) === null || _value$format === void 0 ? void 0 : _value$format.call(_value, format || 'YYYY-MM-DD')) || '');
|
|
88
89
|
}, [_value]);
|
|
89
90
|
var customPresetItems = useMemo(function () {
|
|
90
91
|
var preset = [{
|
|
@@ -218,6 +219,7 @@ var DatePickerCpt = function DatePickerCpt(props) {
|
|
|
218
219
|
});
|
|
219
220
|
};
|
|
220
221
|
var timeInputProps = useMemo(function () {
|
|
222
|
+
var _value$format2;
|
|
221
223
|
var step = 1;
|
|
222
224
|
var _format = '';
|
|
223
225
|
if ((showTime === null || showTime === void 0 ? void 0 : showTime.format) === 'HH:mm') {
|
|
@@ -233,7 +235,7 @@ var DatePickerCpt = function DatePickerCpt(props) {
|
|
|
233
235
|
var val = e.target.value;
|
|
234
236
|
handleTimeChange(window.dayjs(val, _format));
|
|
235
237
|
},
|
|
236
|
-
value: _value === null || _value === void 0 ? void 0 : _value.format(_format)
|
|
238
|
+
value: _value === null || _value === void 0 ? void 0 : (_value$format2 = _value.format) === null || _value$format2 === void 0 ? void 0 : _value$format2.call(_value, _format)
|
|
237
239
|
};
|
|
238
240
|
}, [showTime, _value]);
|
|
239
241
|
if (!picker || picker === 'date') {
|
|
@@ -17,5 +17,6 @@ export interface Props extends Omit<HTMLAttributes<HTMLLIElement>, 'id'> {
|
|
|
17
17
|
wrapperRef?(node: HTMLLIElement): void;
|
|
18
18
|
item: TreeItemType;
|
|
19
19
|
renderItem?(item: TreeItemType): React.ReactNode;
|
|
20
|
+
isBlocked?: boolean;
|
|
20
21
|
}
|
|
21
22
|
export declare const TreeItem: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["childCount", "clone", "depth", "disableSelection", "disableInteraction", "ghost", "handleProps", "indentationWidth", "indicator", "collapsed", "onCollapse", "onRemove", "style", "wrapperRef", "item", "renderItem"];
|
|
1
|
+
var _excluded = ["childCount", "clone", "depth", "disableSelection", "disableInteraction", "ghost", "handleProps", "indentationWidth", "indicator", "collapsed", "onCollapse", "onRemove", "style", "wrapperRef", "item", "renderItem", "isBlocked"];
|
|
2
2
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
3
3
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
4
4
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
@@ -23,6 +23,7 @@ export var TreeItem = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
23
23
|
wrapperRef = props.wrapperRef,
|
|
24
24
|
item = props.item,
|
|
25
25
|
renderItem = props.renderItem,
|
|
26
|
+
isBlocked = props.isBlocked,
|
|
26
27
|
otherProps = _objectWithoutProperties(props, _excluded);
|
|
27
28
|
if (renderItem) {
|
|
28
29
|
return renderItem(props);
|
|
@@ -21,7 +21,9 @@ interface Props {
|
|
|
21
21
|
onChange?: (items: TreeItems) => void;
|
|
22
22
|
/** 删除节点前 */
|
|
23
23
|
onRemoveBefore?: (item: TreeItem) => Promise<boolean>;
|
|
24
|
+
/** 最大层级 */
|
|
25
|
+
maxLevel?: number;
|
|
24
26
|
}
|
|
25
|
-
export declare function SortableTree({ collapsible, value, indicator, indentationWidth, removable, renderItem, onChange, onRemoveBefore, }: Props): React.JSX.Element;
|
|
27
|
+
export declare function SortableTree({ collapsible, value, indicator, indentationWidth, removable, renderItem, onChange, onRemoveBefore, maxLevel, }: Props): React.JSX.Element;
|
|
26
28
|
declare const Demo: () => React.JSX.Element;
|
|
27
29
|
export default Demo;
|
|
@@ -50,7 +50,8 @@ var initialItems = [{
|
|
|
50
50
|
children: []
|
|
51
51
|
}, {
|
|
52
52
|
id: 'Winter',
|
|
53
|
-
children: []
|
|
53
|
+
children: [],
|
|
54
|
+
disabledDrop: true
|
|
54
55
|
}]
|
|
55
56
|
}, {
|
|
56
57
|
id: 'About Us',
|
|
@@ -120,7 +121,9 @@ export function SortableTree(_ref3) {
|
|
|
120
121
|
removable = _ref3$removable === void 0 ? true : _ref3$removable,
|
|
121
122
|
renderItem = _ref3.renderItem,
|
|
122
123
|
onChange = _ref3.onChange,
|
|
123
|
-
onRemoveBefore = _ref3.onRemoveBefore
|
|
124
|
+
onRemoveBefore = _ref3.onRemoveBefore,
|
|
125
|
+
_ref3$maxLevel = _ref3.maxLevel,
|
|
126
|
+
maxLevel = _ref3$maxLevel === void 0 ? 3 : _ref3$maxLevel;
|
|
124
127
|
// 状态管理
|
|
125
128
|
/** 当前树形数据 */
|
|
126
129
|
var _useState = useState([]),
|
|
@@ -146,6 +149,9 @@ export function SortableTree(_ref3) {
|
|
|
146
149
|
console.log('初始化', value);
|
|
147
150
|
setItems(value);
|
|
148
151
|
}, [value]);
|
|
152
|
+
var flattenTreeData = useMemo(function () {
|
|
153
|
+
return flattenTree(items);
|
|
154
|
+
}, [items]);
|
|
149
155
|
|
|
150
156
|
/**
|
|
151
157
|
* 扁平化处理树形数据
|
|
@@ -154,16 +160,15 @@ export function SortableTree(_ref3) {
|
|
|
154
160
|
* 3. 移除被折叠节点的子节点
|
|
155
161
|
*/
|
|
156
162
|
var flattenedItems = useMemo(function () {
|
|
157
|
-
var
|
|
158
|
-
var collapsedItems = flattenedTree.reduce(function (acc, _ref4) {
|
|
163
|
+
var collapsedItems = flattenTreeData.reduce(function (acc, _ref4) {
|
|
159
164
|
var children = _ref4.children,
|
|
160
165
|
collapsed = _ref4.collapsed,
|
|
161
166
|
id = _ref4.id;
|
|
162
167
|
return collapsed && children.length ? [].concat(_toConsumableArray(acc), [id]) : acc;
|
|
163
168
|
}, []);
|
|
164
|
-
return removeChildrenOf(
|
|
165
|
-
}, [activeId,
|
|
166
|
-
|
|
169
|
+
return removeChildrenOf(flattenTreeData, activeId != null ? [activeId].concat(_toConsumableArray(collapsedItems)) : collapsedItems);
|
|
170
|
+
}, [activeId, flattenTreeData]);
|
|
171
|
+
console.log('flattenedItems', flattenedItems);
|
|
167
172
|
/**
|
|
168
173
|
* 计算拖拽投影
|
|
169
174
|
* 根据当前拖拽状态计算目标位置和深度
|
|
@@ -198,6 +203,39 @@ export function SortableTree(_ref3) {
|
|
|
198
203
|
useEffect(function () {
|
|
199
204
|
document.body.id = 'body';
|
|
200
205
|
}, []);
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* 检查子树是否超过最大深度限制
|
|
209
|
+
* @param items 当前项目列表
|
|
210
|
+
* @param itemId 要检查的项目ID
|
|
211
|
+
* @param baseDepth 基础深度
|
|
212
|
+
* @returns 是否超过限制
|
|
213
|
+
*/
|
|
214
|
+
function checkSubtreeDepth(items, itemId, baseDepth) {
|
|
215
|
+
var item = items.find(function (i) {
|
|
216
|
+
return i.id === itemId;
|
|
217
|
+
});
|
|
218
|
+
if (!item) return false;
|
|
219
|
+
|
|
220
|
+
// 首先检查目标位置的深度
|
|
221
|
+
if (baseDepth >= maxLevel) return true;
|
|
222
|
+
|
|
223
|
+
// 获取所有子节点
|
|
224
|
+
var children = items.filter(function (i) {
|
|
225
|
+
return i.parentId === itemId;
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
// 如果当前节点已经是最大深度,且尝试添加子节点,则返回 true
|
|
229
|
+
if (baseDepth >= maxLevel - 1 && children.length > 0) return true;
|
|
230
|
+
|
|
231
|
+
// 递归检查所有子节点
|
|
232
|
+
return children.some(function (child) {
|
|
233
|
+
// 计算子节点在新位置的深度
|
|
234
|
+
var childNewDepth = baseDepth + 1;
|
|
235
|
+
// 如果子节点深度超过限制,或者子节点的子树超过限制,则返回 true
|
|
236
|
+
return childNewDepth >= maxLevel || checkSubtreeDepth(items, child.id, childNewDepth);
|
|
237
|
+
});
|
|
238
|
+
}
|
|
201
239
|
return /*#__PURE__*/React.createElement(DndContext, {
|
|
202
240
|
sensors: sensors,
|
|
203
241
|
collisionDetection: closestCenter,
|
|
@@ -264,9 +302,32 @@ export function SortableTree(_ref3) {
|
|
|
264
302
|
setOffsetLeft(delta.x);
|
|
265
303
|
}
|
|
266
304
|
function handleDragOver(_ref9) {
|
|
267
|
-
var _over$id;
|
|
268
305
|
var over = _ref9.over;
|
|
269
|
-
|
|
306
|
+
if (!projected || !over) {
|
|
307
|
+
var _over$id;
|
|
308
|
+
setOverId((_over$id = over === null || over === void 0 ? void 0 : over.id) !== null && _over$id !== void 0 ? _over$id : null);
|
|
309
|
+
return;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
// 检查目标父节点是否禁止拖入
|
|
313
|
+
var targetParent = projected.parentId ? flattenedItems.find(function (item) {
|
|
314
|
+
return item.id === projected.parentId;
|
|
315
|
+
}) : null;
|
|
316
|
+
if (targetParent !== null && targetParent !== void 0 && targetParent.disabledDrop) {
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// 检查目标深度是否超过最大层级限制
|
|
321
|
+
if (projected.depth >= maxLevel) {
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// 检查整个子树的深度是否会超过限制
|
|
326
|
+
var willExceedLimit = checkSubtreeDepth(flattenTreeData, activeId, projected.depth);
|
|
327
|
+
if (willExceedLimit) {
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
setOverId(over.id);
|
|
270
331
|
}
|
|
271
332
|
|
|
272
333
|
/**
|
|
@@ -282,6 +343,25 @@ export function SortableTree(_ref3) {
|
|
|
282
343
|
if (projected && over) {
|
|
283
344
|
var depth = projected.depth,
|
|
284
345
|
parentId = projected.parentId;
|
|
346
|
+
|
|
347
|
+
// 检查目标父节点是否禁止拖入
|
|
348
|
+
var targetParent = parentId ? flattenedItems.find(function (item) {
|
|
349
|
+
return item.id === parentId;
|
|
350
|
+
}) : null;
|
|
351
|
+
if (targetParent !== null && targetParent !== void 0 && targetParent.disabledDrop) {
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
// 检查是否超过最大层级限制
|
|
356
|
+
if (depth >= maxLevel) {
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
// 检查整个子树的深度是否会超过限制
|
|
361
|
+
var willExceedLimit = checkSubtreeDepth(flattenTreeData, active.id, depth);
|
|
362
|
+
if (willExceedLimit) {
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
285
365
|
var clonedItems = JSON.parse(JSON.stringify(flattenTree(items)));
|
|
286
366
|
var overIndex = clonedItems.findIndex(function (_ref11) {
|
|
287
367
|
var id = _ref11.id;
|