@zat-design/sisyphus-react 4.4.1-beta.1 → 4.4.1-beta.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.
Files changed (40) hide show
  1. package/dist/index.esm.css +1 -1
  2. package/dist/less.esm.css +1 -1
  3. package/es/ProConfigProvider/index.d.ts +1 -1
  4. package/es/ProConfigProvider/index.js +6 -7
  5. package/es/ProConfigProvider/propsType.d.ts +22 -0
  6. package/es/ProEditTable/components/RcTable/DraggableTable.js +18 -32
  7. package/es/ProEditTable/index.js +7 -1
  8. package/es/ProEditTable/style/index.less +0 -5
  9. package/es/ProEditTable/utils/config.js +2 -0
  10. package/es/ProEditTable/utils/index.d.ts +15 -1
  11. package/es/ProEditTable/utils/index.js +27 -15
  12. package/es/ProForm/components/base/DatePicker/index.js +1 -1
  13. package/es/ProForm/components/combination/Group/utils/index.d.ts +9 -9
  14. package/es/ProForm/utils/useWatch.d.ts +14 -4
  15. package/es/ProForm/utils/useWatch.js +48 -18
  16. package/es/ProTable/components/EditableCell/index.js +55 -22
  17. package/es/ProTable/components/EditableCell/propsType.d.ts +14 -0
  18. package/es/ProTable/components/FormatColumn/index.d.ts +4 -2
  19. package/es/ProTable/components/FormatColumn/index.js +13 -46
  20. package/es/ProTable/components/RcTable/components/BaseTable/index.d.ts +1 -8
  21. package/es/ProTable/components/RcTable/components/BaseTable/index.js +5 -4
  22. package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.d.ts +1 -1
  23. package/es/ProTable/components/RcTable/components/DraggableTable/components/DndWrapper/index.js +19 -32
  24. package/es/ProTable/components/RcTable/components/DraggableTable/index.d.ts +1 -8
  25. package/es/ProTable/components/RcTable/components/DraggableTable/index.js +5 -4
  26. package/es/ProTable/components/RenderColumn/index.js +1 -17
  27. package/es/ProTable/index.d.ts +9 -8
  28. package/es/ProTable/index.js +151 -111
  29. package/es/ProTable/propsType.d.ts +21 -6
  30. package/es/ProTable/utils/columnStorage.d.ts +35 -0
  31. package/es/ProTable/utils/columnStorage.js +171 -0
  32. package/es/ProTable/utils/index.d.ts +16 -2
  33. package/es/ProTable/utils/index.js +34 -21
  34. package/es/hooks/useDraggableRow.d.ts +34 -0
  35. package/es/hooks/useDraggableRow.js +70 -0
  36. package/package.json +1 -3
  37. package/es/ProForm/components/base/DatePicker/useDateLimit.d.ts +0 -3
  38. package/es/ProForm/components/base/DatePicker/useDateLimit.js +0 -7
  39. package/es/ProForm/components/combination/FormList/components/BlockTitle.d.ts +0 -13
  40. package/es/ProForm/components/combination/FormList/components/BlockTitle.js +0 -31
@@ -1,10 +1,44 @@
1
+ import _isFunction from "lodash/isFunction";
1
2
  import _isEqual from "lodash/isEqual";
3
+ import _isBoolean from "lodash/isBoolean";
2
4
  import _get from "lodash/get";
3
5
  import { validate } from '@zat-design/utils';
4
6
  const {
5
7
  isEmpty
6
8
  } = validate;
7
9
 
10
+ /**
11
+ * 列可见性过滤:hidden 优先(antd 5.13+ 原生),show 兼容(已废弃)
12
+ * - hidden 为布尔值 → 直接按 hidden 决定
13
+ * - hidden 缺省、show 为布尔值 → 按 show 决定
14
+ * - hidden 缺省、show 为函数 → 调用 show() 决定
15
+ * - 都缺省 → 显示
16
+ *
17
+ * 返回过滤后的列与 deprecated show 使用情况,由调用方决定告警时机/去重。
18
+ */
19
+ export const filterVisibleColumns = (columns = []) => {
20
+ let usedShow = false;
21
+ const filtered = columns.filter(item => {
22
+ const {
23
+ hidden,
24
+ show
25
+ } = item;
26
+ if (_isBoolean(hidden)) {
27
+ return !hidden;
28
+ }
29
+ if (show !== undefined) {
30
+ usedShow = true;
31
+ if (_isBoolean(show)) return show;
32
+ if (_isFunction(show)) return show();
33
+ }
34
+ return true;
35
+ });
36
+ return {
37
+ columns: filtered,
38
+ usedShow
39
+ };
40
+ };
41
+
8
42
  /**
9
43
  * 获取小数点后的位数
10
44
  * @param num 数字
@@ -97,25 +131,4 @@ export const removeEmptyKeys = obj => {
97
131
  /** 判断是有值的对象 */
98
132
  export const isNonEmptyObject = obj => {
99
133
  return obj !== null && typeof obj === 'object' && !Array.isArray(obj) && Object.keys(obj).length > 0;
100
- };
101
-
102
- /** 解析宽度值 */
103
- export const parseWidth = (widthValue, trWidth) => {
104
- // 如果是数字,直接返回
105
- if (typeof widthValue === 'number') return widthValue;
106
- // 如果是字符串,检查是否是百分比
107
- if (typeof widthValue === 'string') {
108
- if (widthValue.endsWith('%')) {
109
- // 计算百分比
110
- const percentage = parseFloat(widthValue) / 100;
111
- return Math.max(trWidth * percentage, 0);
112
- }
113
- // 尝试解析为数字(处理如'300px'这样的情况)
114
- const numericValue = parseFloat(widthValue);
115
- if (!Number.isNaN(numericValue)) {
116
- return numericValue;
117
- }
118
- }
119
- // 所有其他情况,返回默认值
120
- return null;
121
134
  };
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+ import type { CollisionDetection, DragEndEvent, DragStartEvent } from '@dnd-kit/core';
3
+ /**
4
+ * 行拖拽 hook 公共实现(薄封装)
5
+ * - 仅封装 dnd-kit 集成(useSortable + DndContext + SortableContext)
6
+ * - 业务方各自处理拖拽手柄渲染、树形/简单 arrayMove、占位行检查、rowDraggable 等差异化逻辑
7
+ */
8
+ export interface UseDraggableRowStateOptions {
9
+ id: string;
10
+ disabled?: boolean;
11
+ }
12
+ export declare const useDraggableRowState: ({ id, disabled }: UseDraggableRowStateOptions) => {
13
+ setNodeRef: (node: HTMLElement) => void;
14
+ style: React.CSSProperties;
15
+ listeners: import("@dnd-kit/core/dist/hooks/utilities").SyntheticListenerMap;
16
+ attributes: import("@dnd-kit/core").DraggableAttributes;
17
+ isDragging: boolean;
18
+ };
19
+ export interface SortableTableContextProps {
20
+ /** 是否启用拖拽 */
21
+ draggable?: boolean;
22
+ /** 整体禁用(与 draggable=false 等价:不包装 DndContext) */
23
+ disabled?: boolean;
24
+ /** 排序条目 id 列表(rowKey) */
25
+ items: (string | number)[];
26
+ /** 拖拽开始回调 */
27
+ onDragStart?: (event: DragStartEvent) => void | Promise<void>;
28
+ /** 拖拽结束回调 */
29
+ onDragEnd?: (event: DragEndEvent) => void | Promise<void>;
30
+ /** 碰撞检测策略(默认 dnd-kit 内置 closestCenter) */
31
+ collisionDetection?: CollisionDetection;
32
+ children: React.ReactNode;
33
+ }
34
+ export declare const SortableTableContext: React.FC<SortableTableContextProps>;
@@ -0,0 +1,70 @@
1
+ import React from 'react';
2
+ import { DndContext } from '@dnd-kit/core';
3
+ import { SortableContext, useSortable, verticalListSortingStrategy } from '@dnd-kit/sortable';
4
+ import { CSS } from '@dnd-kit/utilities';
5
+
6
+ /**
7
+ * 行拖拽 hook 公共实现(薄封装)
8
+ * - 仅封装 dnd-kit 集成(useSortable + DndContext + SortableContext)
9
+ * - 业务方各自处理拖拽手柄渲染、树形/简单 arrayMove、占位行检查、rowDraggable 等差异化逻辑
10
+ */
11
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
12
+ export const useDraggableRowState = ({
13
+ id,
14
+ disabled
15
+ }) => {
16
+ const {
17
+ attributes,
18
+ listeners,
19
+ setNodeRef,
20
+ transform,
21
+ transition,
22
+ isDragging
23
+ } = useSortable({
24
+ id,
25
+ disabled
26
+ });
27
+ const style = {
28
+ transform: CSS.Transform.toString(transform && {
29
+ ...transform,
30
+ scaleY: 1
31
+ }),
32
+ transition,
33
+ ...(isDragging ? {
34
+ position: 'relative',
35
+ zIndex: 2
36
+ } : {})
37
+ };
38
+ return {
39
+ setNodeRef,
40
+ style,
41
+ listeners,
42
+ attributes,
43
+ isDragging
44
+ };
45
+ };
46
+ export const SortableTableContext = ({
47
+ draggable,
48
+ disabled,
49
+ items,
50
+ onDragStart,
51
+ onDragEnd,
52
+ collisionDetection,
53
+ children
54
+ }) => {
55
+ if (!draggable || disabled) {
56
+ return /*#__PURE__*/_jsx(_Fragment, {
57
+ children: children
58
+ });
59
+ }
60
+ return /*#__PURE__*/_jsx(DndContext, {
61
+ onDragStart: onDragStart,
62
+ onDragEnd: onDragEnd,
63
+ collisionDetection: collisionDetection,
64
+ children: /*#__PURE__*/_jsx(SortableContext, {
65
+ items: items,
66
+ strategy: verticalListSortingStrategy,
67
+ children: children
68
+ })
69
+ });
70
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zat-design/sisyphus-react",
3
- "version": "4.4.1-beta.1",
3
+ "version": "4.4.1-beta.3",
4
4
  "license": "MIT",
5
5
  "files": [
6
6
  "es",
@@ -110,14 +110,12 @@
110
110
  "@dnd-kit/core": "^6.0.8",
111
111
  "@dnd-kit/sortable": "^7.0.2",
112
112
  "@dnd-kit/utilities": "^3.2.1",
113
- "@rc-component/picker": "^1.9.0",
114
113
  "@zat-design/utils": "^4.0.0",
115
114
  "big.js": "^6.2.1",
116
115
  "classnames": "^2.3.1",
117
116
  "dayjs": "^1.11.13",
118
117
  "idb-keyval": "^6.2.2",
119
118
  "lodash": "^4.17.21",
120
- "rc-resize-observer": "^1.4.0",
121
119
  "react-intersection-observer": "^9.13.0",
122
120
  "react-resizable": "^3.0.5",
123
121
  "react-svg": "^15.1.7"
@@ -1,3 +0,0 @@
1
- export declare const useDateLimit: () => {
2
- onCalendarChange: (val: any) => void;
3
- };
@@ -1,7 +0,0 @@
1
- import { useState } from 'react';
2
- export const useDateLimit = () => {
3
- const [dates, setDates] = useState();
4
- return {
5
- onCalendarChange: val => setDates(val)
6
- };
7
- };
@@ -1,13 +0,0 @@
1
- import React from 'react';
2
- import { NamePath } from 'antd/es/form/interface';
3
- import { FormInstance } from 'antd';
4
- import type { FormListMode, TitleType } from '../propsType';
5
- interface Props {
6
- mode: FormListMode;
7
- namePath: NamePath;
8
- index: number;
9
- form: FormInstance;
10
- title: TitleType;
11
- }
12
- declare const BlockTitle: React.FC<Props>;
13
- export default BlockTitle;
@@ -1,31 +0,0 @@
1
- import _isFunction from "lodash/isFunction";
2
- import React from 'react';
3
- import { jsx as _jsx } from "react/jsx-runtime";
4
- const BlockTitle = props => {
5
- const {
6
- mode,
7
- namePath,
8
- index,
9
- form,
10
- title
11
- } = props;
12
- if (mode !== 'block') {
13
- return null;
14
- }
15
- if (!title) {
16
- return /*#__PURE__*/_jsx("div", {});
17
- }
18
- if ( /*#__PURE__*/React.isValidElement(title)) {
19
- return title;
20
- }
21
- let titleContent = title;
22
- if (_isFunction(title)) {
23
- const record = form.getFieldValue(namePath);
24
- titleContent = title(record, index, form);
25
- }
26
- return /*#__PURE__*/_jsx("div", {
27
- className: "pro-form-list-block-title",
28
- children: titleContent
29
- });
30
- };
31
- export default BlockTitle;