@zat-design/sisyphus-react 4.6.1-beta.3 → 4.6.1-beta.5

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.
@@ -1,10 +1,50 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { createContext, forwardRef, useContext, useImperativeHandle, useMemo } from "react";
2
+ import {
3
+ createContext,
4
+ forwardRef,
5
+ useContext,
6
+ useEffect,
7
+ useImperativeHandle,
8
+ useMemo
9
+ } from "react";
3
10
  import { ProDrawer, ProModal } from "./components";
4
11
  import ProForm from "../ProForm";
5
12
  import { resolveDrawerSize } from "./utils";
6
13
  import locale from "../locale";
7
14
  const ProDrawerFormContext = createContext(null);
15
+ const scrollLockClassName = "pro-drawer-form-scroll-lock";
16
+ let openDrawerCount = 0;
17
+ let lockedScrollLeft = 0;
18
+ let lockedScrollTop = 0;
19
+ const lockRootScroll = () => {
20
+ if (typeof document === "undefined") {
21
+ return void 0;
22
+ }
23
+ if (openDrawerCount === 0) {
24
+ const scrollingElement = document.scrollingElement ?? document.documentElement;
25
+ lockedScrollLeft = scrollingElement.scrollLeft;
26
+ lockedScrollTop = scrollingElement.scrollTop;
27
+ document.body.style.setProperty("--pro-drawer-form-scroll-top", `-${lockedScrollTop}px`);
28
+ document.body.style.setProperty("--pro-drawer-form-scroll-left", `-${lockedScrollLeft}px`);
29
+ document.documentElement.classList.add(scrollLockClassName);
30
+ document.body.classList.add(scrollLockClassName);
31
+ }
32
+ openDrawerCount += 1;
33
+ return () => {
34
+ openDrawerCount = Math.max(0, openDrawerCount - 1);
35
+ if (openDrawerCount === 0) {
36
+ document.documentElement.classList.remove(scrollLockClassName);
37
+ document.body.classList.remove(scrollLockClassName);
38
+ document.body.style.removeProperty("--pro-drawer-form-scroll-top");
39
+ document.body.style.removeProperty("--pro-drawer-form-scroll-left");
40
+ if (lockedScrollLeft !== 0 || lockedScrollTop !== 0) {
41
+ window.scrollTo(lockedScrollLeft, lockedScrollTop);
42
+ }
43
+ lockedScrollLeft = 0;
44
+ lockedScrollTop = 0;
45
+ }
46
+ };
47
+ };
8
48
  const useProDrawerFormContext = () => useContext(ProDrawerFormContext);
9
49
  const ProDrawerForm = forwardRef((props, ref) => {
10
50
  var _a, _b, _c, _d, _e, _f;
@@ -27,6 +67,12 @@ const ProDrawerForm = forwardRef((props, ref) => {
27
67
  } = props;
28
68
  const nextIsView = isView || disabled;
29
69
  const nextOkText = okText ?? (mode === "Drawer" ? (_d = (_c = locale) == null ? void 0 : _c.ProDrawerForm) == null ? void 0 : _d.save : (_f = (_e = locale) == null ? void 0 : _e.ProDrawerForm) == null ? void 0 : _f.confirm);
70
+ useEffect(() => {
71
+ if (!open || mode !== "Drawer") {
72
+ return void 0;
73
+ }
74
+ return lockRootScroll();
75
+ }, [mode, open]);
30
76
  const { width: deprecatedWidth, ...restPropsWithoutWidth } = restProps;
31
77
  const width = resolveDrawerSize(size, deprecatedWidth);
32
78
  const [form] = ProForm.useForm(originalForm);
@@ -1,5 +1,17 @@
1
1
  @import '../../style/variables.less';
2
2
 
3
+ html.pro-drawer-form-scroll-lock {
4
+ overflow: hidden !important;
5
+ }
6
+
7
+ body.pro-drawer-form-scroll-lock {
8
+ position: fixed !important;
9
+ top: var(--pro-drawer-form-scroll-top, 0);
10
+ left: var(--pro-drawer-form-scroll-left, 0);
11
+ width: 100%;
12
+ overflow: hidden !important;
13
+ }
14
+
3
15
  .pro-drawer {
4
16
  .original-value-tooltip {
5
17
  position: fixed;
@@ -138,7 +138,8 @@ const RenderField = ({ text: value, record, index, column, config }) => {
138
138
  lastFieldProps = dynamicProps.fieldProps ?? fieldProps(rowData, reactiveParams);
139
139
  }
140
140
  if (isFunction(rules)) {
141
- lastRules = dynamicProps.rules ?? rules(rowData, reactiveParams);
141
+ const canReuseDynamicRules = isRecordShallowEqual(dynamicProps.rowSnapshot, rowData);
142
+ lastRules = canReuseDynamicRules ? dynamicProps.rules ?? rules(rowData, reactiveParams) : rules(rowData, reactiveParams);
142
143
  }
143
144
  if (isFunction(valueType)) {
144
145
  lastValueType = dynamicProps.valueType ?? valueType(currentValue, rowData, {
@@ -43,8 +43,9 @@ const useShouldUpdateForTable = (props) => {
43
43
  }
44
44
  if (isFunction(column.rules)) {
45
45
  const newRules = column.rules(values, reactiveParams);
46
- if (!isEqualWith(rulesRef.current, newRules, customEqualForFunction)) {
47
- rulesRef.current = newRules;
46
+ const rulesChanged = !isEqualWith(rulesRef.current, newRules, customEqualForFunction);
47
+ rulesRef.current = newRules;
48
+ if (rulesChanged) {
48
49
  hasChange = true;
49
50
  }
50
51
  } else {
@@ -30,7 +30,8 @@ const LineFields = (props) => {
30
30
  className,
31
31
  id,
32
32
  diffConfig,
33
- hideStartEndActionProps
33
+ hideStartEndActionProps,
34
+ actionAlign
34
35
  } = props;
35
36
  const isLess = mode === "less";
36
37
  const {
@@ -48,6 +49,7 @@ const LineFields = (props) => {
48
49
  const classnames = classNames({
49
50
  "pro-form-list": true,
50
51
  "pro-form-list-line": mode === "line",
52
+ [`pro-form-list-action-${actionAlign}`]: !!actionAlign,
51
53
  [className]: !!className
52
54
  });
53
55
  const style = {
@@ -66,7 +68,7 @@ const LineFields = (props) => {
66
68
  children: /* @__PURE__ */ jsx(ProIcon, { component: dragSvg, size: 20, color: "#949599" })
67
69
  }
68
70
  ),
69
- /* @__PURE__ */ jsx(Row, { gutter: isLess ? 0 : 24, children: /* @__PURE__ */ jsx(
71
+ /* @__PURE__ */ jsx(Row, { className: "pro-form-list-fields", gutter: isLess ? 0 : 24, children: /* @__PURE__ */ jsx(
70
72
  MemoRenderFields,
71
73
  {
72
74
  columns,
@@ -62,6 +62,7 @@ export interface FormListType {
62
62
  emptyBtnText?: string;
63
63
  hideStartEndActionProps?: [boolean, boolean];
64
64
  titlePosition?: 'top' | 'left';
65
+ actionAlign?: 'top' | 'center' | 'bottom';
65
66
  className?: string;
66
67
  }
67
68
  export type TypeWithRef = FormListType & React.RefAttributes<FormListRefType>;
@@ -52,6 +52,11 @@
52
52
  padding-right: @zaui-space-size-sm;
53
53
  border: none;
54
54
  }
55
+
56
+ > .pro-form-list-fields {
57
+ flex: 1;
58
+ min-width: 0;
59
+ }
55
60
  }
56
61
 
57
62
  .pro-form-list-line {
@@ -63,6 +68,18 @@
63
68
  }
64
69
  }
65
70
 
71
+ .pro-form-list-action-top > .pro-form-list-action {
72
+ align-self: flex-start;
73
+ }
74
+
75
+ .pro-form-list-action-center > .pro-form-list-action {
76
+ align-self: center;
77
+ }
78
+
79
+ .pro-form-list-action-bottom > .pro-form-list-action {
80
+ align-self: flex-end;
81
+ }
82
+
66
83
  .pro-form-list-toolbar,
67
84
  .pro-form-list-action {
68
85
  .@{ant-prefix}-btn-link {
@@ -36,6 +36,14 @@
36
36
  border-radius: 8px !important;
37
37
  }
38
38
 
39
+ .@{ant-prefix}-collapse-item-active {
40
+ &.pro-collapse-panel {
41
+ & > .@{ant-prefix}-collapse-header {
42
+ border-radius: var(--zaui-border-radius, 8px) var(--zaui-border-radius, 8px) 0 0 !important;
43
+ }
44
+ }
45
+ }
46
+
39
47
  .@{ant-prefix}-collapse-title {
40
48
  color: var(--zaui-text, #343434);
41
49
  font-weight: 500;
@@ -62,6 +70,7 @@
62
70
  padding-bottom: 0;
63
71
  background: var(--zaui-base-bg, #ffffff);
64
72
  border: 1px solid #ebecee;
73
+ border-radius: 0 0 var(--zaui-border-radius, 8px) var(--zaui-border-radius, 8px);
65
74
  }
66
75
  }
67
76
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zat-design/sisyphus-react",
3
- "version": "4.6.1-beta.3",
3
+ "version": "4.6.1-beta.5",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public",