@zat-design/sisyphus-react 3.3.3-beta.3 → 3.3.3-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.
@@ -5505,3 +5505,28 @@ input[type='button'] {
5505
5505
  width: -moz-max-content;
5506
5506
  width: max-content;
5507
5507
  }
5508
+ .ant-tooltip > .ant-tooltip-content > .ant-tooltip-inner {
5509
+ color: #1d2129;
5510
+ background-color: #fff;
5511
+ -webkit-box-shadow: 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 9px 28px 8px rgba(0, 0, 0, 0.05);
5512
+ box-shadow: 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 9px 28px 8px rgba(0, 0, 0, 0.05);
5513
+ }
5514
+ .ant-tooltip > .ant-tooltip-content > .ant-tooltip-inner::-moz-selection {
5515
+ color: inherit !important;
5516
+ background: rgba(24, 144, 255, 0.3) !important;
5517
+ }
5518
+ .ant-tooltip > .ant-tooltip-content > .ant-tooltip-inner::selection {
5519
+ color: inherit !important;
5520
+ background: rgba(24, 144, 255, 0.3) !important;
5521
+ }
5522
+ .ant-tooltip > .ant-tooltip-content > .ant-tooltip-inner > div::-moz-selection {
5523
+ color: inherit !important;
5524
+ background: rgba(24, 144, 255, 0.3) !important;
5525
+ }
5526
+ .ant-tooltip > .ant-tooltip-content > .ant-tooltip-inner > div::selection {
5527
+ color: inherit !important;
5528
+ background: rgba(24, 144, 255, 0.3) !important;
5529
+ }
5530
+ .ant-tooltip > .ant-tooltip-content > .ant-tooltip-arrow > .ant-tooltip-arrow-content {
5531
+ --antd-arrow-background-color: linear-gradient(to right bottom, rgba(255, 255, 255, 0.95), #ffffff);
5532
+ }
@@ -1,4 +1,5 @@
1
1
  import React, { FC } from 'react';
2
+ import { FormInstance } from 'antd';
2
3
  import { PropSelectProps } from '../ProSelect/propsType';
3
4
  import { ProModalSelectPropsType } from '../ProForm/components/combination/ProModalSelect/propsType';
4
5
  import { AddressProps } from '../ProForm/components/combination/ProAddressBar/propsType';
@@ -9,17 +10,24 @@ export interface ProConfigState {
9
10
  ProSelect?: Partial<PropSelectProps> & Record<string, any>;
10
11
  ProModalSelect?: Partial<ProModalSelectPropsType> & Record<string, any>;
11
12
  ProAddressBar?: Partial<AddressProps> & Record<string, any>;
13
+ forms: Record<string, FormInstance | undefined>;
12
14
  [key: string]: any;
13
15
  }
14
16
  interface ConfigContext {
15
17
  state: ProConfigState;
16
- dispatch: React.Dispatch<ProConfigState>;
18
+ dispatch: React.Dispatch<Actions>;
17
19
  }
18
20
  export declare const ProConfigContext: React.Context<ConfigContext>;
19
21
  export declare function useProConfig(): ConfigContext;
20
22
  export declare function useProConfig(name: keyof ConfigContext['state']): ConfigContext['state'][keyof ConfigContext['state']];
23
+ export declare function useContextForm(): Record<string, FormInstance<any>>;
24
+ type ActionsType = 'set' | 'setProEnum' | 'setProEnumDic';
25
+ interface Actions {
26
+ type: ActionsType;
27
+ payload: any;
28
+ }
21
29
  export declare const ProConfigProvider: FC<{
22
- value: ProConfigState;
30
+ value?: ProConfigState;
23
31
  locale?: string;
24
32
  }>;
25
33
  export default ProConfigProvider;
@@ -9,12 +9,14 @@ import enUS from 'antd/es/locale/en_US';
9
9
  import merge from 'lodash/merge';
10
10
  import useEnumRequest from '../ProEnum/hooks/useEnumRequest';
11
11
  import { setLanguage } from '../locale';
12
- export var ProConfigContext = /*#__PURE__*/React.createContext({
13
- state: {
14
- ProEnum: {
15
- dics: {}
16
- }
12
+ var initialState = {
13
+ ProEnum: {
14
+ dics: {}
17
15
  },
16
+ forms: {}
17
+ };
18
+ export var ProConfigContext = /*#__PURE__*/React.createContext({
19
+ state: initialState,
18
20
  dispatch: function dispatch() {}
19
21
  });
20
22
  // eslint-disable-next-line no-redeclare
@@ -22,6 +24,11 @@ export function useProConfig(name) {
22
24
  var config = useContext(ProConfigContext);
23
25
  return name ? config.state[name] : config;
24
26
  }
27
+ export function useContextForm() {
28
+ var _config$state;
29
+ var config = useContext(ProConfigContext);
30
+ return (_config$state = config.state) === null || _config$state === void 0 ? void 0 : _config$state.forms;
31
+ }
25
32
  var antdLangMap = {
26
33
  'zh-CN': zhCN,
27
34
  'en-US': enUS // en-US
@@ -47,7 +54,7 @@ var reducer = function reducer(state, action) {
47
54
  };
48
55
  export var ProConfigProvider = function ProConfigProvider(props) {
49
56
  var _props$value, _props$value2;
50
- var _useReducer = useReducer(reducer, {}),
57
+ var _useReducer = useReducer(reducer, initialState),
51
58
  _useReducer2 = _slicedToArray(_useReducer, 2),
52
59
  state = _useReducer2[0],
53
60
  dispatch = _useReducer2[1];
@@ -1,33 +1,32 @@
1
1
  import _toArray from "@babel/runtime/helpers/esm/toArray";
2
2
  import "antd/es/row/style";
3
3
  import _Row from "antd/es/row";
4
+ import "antd/es/form/style";
5
+ import _Form from "antd/es/form";
4
6
  import "antd/es/col/style";
5
7
  import _Col from "antd/es/col";
6
8
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
7
9
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
8
10
  import "antd/es/space/style";
9
11
  import _Space from "antd/es/space";
10
- import "antd/es/form/style";
11
- import _Form from "antd/es/form";
12
12
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
13
13
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
14
14
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
15
- var _excluded = ["mode", "span", "disabled", "isView", "columns", "footer", "onOk", "okText", "onCancel", "confirmLoading", "cancelText", "form", "children", "rowProps", "className", "expand", "expandOpen", "expandOpenChange", "viewEmpty", "labelAlign", "labelWidth", "onValuesChange", "onFinish", "originalValues", "submitOnEnter", "clearNotShow", "initialValues", "requiredOnView", "formId", "required", "originalTip", "groupName"];
15
+ var _excluded = ["mode", "span", "disabled", "isView", "columns", "footer", "onOk", "okText", "onCancel", "confirmLoading", "cancelText", "form", "children", "rowProps", "className", "expand", "expandOpen", "expandOpenChange", "viewEmpty", "labelAlign", "labelWidth", "onValuesChange", "onFinish", "originalValues", "submitOnEnter", "clearNotShow", "initialValues", "requiredOnView", "formId", "required", "originalTip", "formKey"];
16
16
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
17
17
  import { DoubleLeftOutlined } from '@ant-design/icons';
18
18
  import classnames from 'classnames';
19
- import React, { forwardRef, useContext, useImperativeHandle, useMemo } from 'react';
19
+ import React, { forwardRef, useImperativeHandle, useMemo } from 'react';
20
20
  import { isObject, isString, merge } from 'lodash';
21
21
  import { FormFooter, InputRange, ProAddress, ProAddressBar, ProCertNo, ProCertValidity, ProCombination, ProModalSelect, ProNumberRange, ProRangeBox, ProTimeLimit, transferAddressInfoToRegion, ProUpload, ProTreeSelect, ProTreeModal, ProTree, EnumSelect } from './components';
22
22
  import RenderFields from './components/render/RenderFields';
23
- import { useProConfig } from '../ProConfigProvider';
23
+ import { useProConfig, useContextForm } from '../ProConfigProvider';
24
24
  import { getLayout, splitNameStr, useControlled, initialValuesToNames } from './utils/index';
25
25
  import { useForm } from './utils/useForm';
26
26
  import { useFieldProps } from './utils/useFieldProps';
27
27
  import locale from '../locale';
28
- import { groupContext } from './components/ProFormGroup';
29
28
  var ProForm = function ProForm(props, ref) {
30
- var _groupForm$groupName, _localStorage;
29
+ var _forms$formKey, _localStorage;
31
30
  var _props$mode = props.mode,
32
31
  mode = _props$mode === void 0 ? 'search' : _props$mode,
33
32
  span = props.span,
@@ -66,13 +65,14 @@ var ProForm = function ProForm(props, ref) {
66
65
  required = props.required,
67
66
  _props$originalTip = props.originalTip,
68
67
  originalTip = _props$originalTip === void 0 ? true : _props$originalTip,
69
- groupName = props.groupName,
68
+ formKey = props.formKey,
70
69
  otherProps = _objectWithoutProperties(props, _excluded);
71
- var _ref = useContext(groupContext) || [],
72
- _ref2 = _slicedToArray(_ref, 2),
73
- groupForm = _ref2[0],
74
- setGroupForm = _ref2[1];
75
- var _useForm = useForm((_groupForm$groupName = groupForm[groupName]) !== null && _groupForm$groupName !== void 0 ? _groupForm$groupName : originForm),
70
+ var _useProConfig = useProConfig(),
71
+ state = _useProConfig.state,
72
+ dispatch = _useProConfig.dispatch;
73
+ var config = state.ProForm,
74
+ forms = state.forms;
75
+ var _useForm = useForm((_forms$formKey = forms[formKey]) !== null && _forms$formKey !== void 0 ? _forms$formKey : originForm),
76
76
  _useForm2 = _slicedToArray(_useForm, 1),
77
77
  form = _useForm2[0];
78
78
  var _useControlled = useControlled({
@@ -82,21 +82,30 @@ var ProForm = function ProForm(props, ref) {
82
82
  _useControlled2 = _slicedToArray(_useControlled, 2),
83
83
  openState = _useControlled2[0],
84
84
  setOpenState = _useControlled2[1];
85
- var config = useProConfig('ProForm');
86
85
  // 把表单实例存入表单组
87
86
  useMemo(function () {
88
- if (groupName && groupForm[groupName] !== form) {
89
- groupForm[groupName] = form;
90
- setGroupForm(_objectSpread({}, groupForm));
87
+ if (formKey && forms[formKey] !== form) {
88
+ forms[formKey] = form;
89
+ dispatch({
90
+ type: 'set',
91
+ payload: {
92
+ forms: _objectSpread({}, forms)
93
+ }
94
+ });
91
95
  }
92
96
  // 销毁
93
97
  return function () {
94
- if (groupName && groupForm[groupName]) {
95
- delete _Form[groupName];
96
- setGroupForm(_objectSpread({}, groupForm));
98
+ if (formKey && forms[formKey]) {
99
+ delete forms[formKey];
100
+ dispatch({
101
+ type: 'set',
102
+ payload: {
103
+ forms: _objectSpread({}, forms)
104
+ }
105
+ });
97
106
  }
98
107
  };
99
- }, [groupName, form]);
108
+ }, [formKey, form]);
100
109
  var _getLayout = getLayout({
101
110
  span: span,
102
111
  form: form
@@ -301,6 +310,7 @@ var ProFormProvider = function ProFormProvider(props) {
301
310
  };
302
311
  ProFormForward.Provider = ProFormProvider; // 包装Provider
303
312
  ProFormForward.useFieldProps = useFieldProps; // 获取每个字段的其他参数 -otherProps
313
+ ProFormForward.useContextForm = useContextForm; // 获取 ProConfigProvider中的表单实例map
304
314
  // 内置组合
305
315
  ProFormForward.ProAddressBar = ProAddressBar;
306
316
  ProFormForward.ProCombination = ProCombination;
@@ -43,7 +43,7 @@ export interface ProFormOtherProps {
43
43
  export interface ProFormProps<Values = any> extends FormProps<Values> {
44
44
  disabled?: boolean;
45
45
  mode?: ModeEnum;
46
- groupName?: string;
46
+ formKey?: string;
47
47
  /** 是否查看 */
48
48
  isView?: boolean;
49
49
  span?: number;
@@ -84,4 +84,8 @@ export declare const deleteForPath: (values: any, namePath: string | number | (s
84
84
  * @returns {}
85
85
  */
86
86
  export declare const findOptionByValue: (treeData: any[], value: string | number) => any;
87
+ /**
88
+ * 对比依赖列表中的 值是否变更
89
+ */
90
+ export declare const equalDependencies: (dependencies: any, prevValues: any, currentValues: any) => any;
87
91
  export {};
@@ -407,4 +407,17 @@ export var findOptionByValue = function findOptionByValue(treeData, value) {
407
407
  }
408
408
  }
409
409
  }
410
+ };
411
+ /**
412
+ * 对比依赖列表中的 值是否变更
413
+ */
414
+ export var equalDependencies = function equalDependencies(dependencies, prevValues, currentValues) {
415
+ if (dependencies === null || dependencies === void 0 ? void 0 : dependencies.length) {
416
+ return dependencies.some(function (namePath) {
417
+ var prevValue = get(prevValues, namePath);
418
+ var currentValue = get(currentValues, namePath);
419
+ return prevValue !== currentValue;
420
+ });
421
+ }
422
+ return false;
410
423
  };
@@ -2,7 +2,7 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
2
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
3
  import { useRef, useState } from 'react';
4
4
  import { isFunction, isEqualWith } from 'lodash';
5
- import { customEqualForFun } from './index';
5
+ import { customEqualForFun, equalDependencies } from './index';
6
6
  // 代理shouldUpdate事件, 执行函数值的[show, disabled], 当[show, disabled]与上一次值不相同时更新状态
7
7
  var useShouldUpdate = function useShouldUpdate(props) {
8
8
  var show = props.show,
@@ -20,7 +20,8 @@ var useShouldUpdate = function useShouldUpdate(props) {
20
20
  clearNotShow = formItemProps.clearNotShow,
21
21
  index = formItemProps.index,
22
22
  namePath = formItemProps.namePath,
23
- names = formItemProps.names;
23
+ names = formItemProps.names,
24
+ dependencies = formItemProps.dependencies;
24
25
  var timerRef = useRef();
25
26
  var showRef = useRef();
26
27
  var disabledRef = useRef();
@@ -171,7 +172,7 @@ var useShouldUpdate = function useShouldUpdate(props) {
171
172
  if (_required !== requiredRef.current || !isEqualWith(rulesRef.current, _rules, customEqualForFun)) {
172
173
  form.validateFields([name]);
173
174
  }
174
- if (_show !== showRef.current || _disabled !== disabledRef.current || _required !== requiredRef.current || !isEqualWith(rulesRef.current, _rules, customEqualForFun) || !isEqualWith(fieldPropsRef.current, _fieldProps, customEqualForFun) || !isEqualWith(originComponentRef.current, _component, customEqualForFun)) {
175
+ if (_show !== showRef.current || _disabled !== disabledRef.current || _required !== requiredRef.current || !isEqualWith(rulesRef.current, _rules, customEqualForFun) || !isEqualWith(fieldPropsRef.current, _fieldProps, customEqualForFun) || !isEqualWith(originComponentRef.current, _component, customEqualForFun) || equalDependencies(dependencies, prevValues, _currentValues)) {
175
176
  showRef.current = _show;
176
177
  disabledRef.current = _disabled;
177
178
  requiredRef.current = _required;
package/es/index.d.ts CHANGED
@@ -8,7 +8,6 @@ export { default as ProViewer } from './ProViewer';
8
8
  export { default as ProEditTable } from './ProEditTable';
9
9
  export { default as ProDrawerForm } from './ProDrawerForm';
10
10
  export { default as ProEditLabel } from './ProEditLabel';
11
- export { ProFormGroup, useProFormGroup } from './ProForm/components/ProFormGroup';
12
11
  export { default as ProForm } from './ProForm';
13
12
  export * from './ProForm';
14
13
  export * from './ProForm/components';
package/es/index.js CHANGED
@@ -12,7 +12,6 @@ export { default as ProEditTable } from './ProEditTable';
12
12
  export { default as ProDrawerForm } from './ProDrawerForm';
13
13
  export { default as ProEditLabel } from './ProEditLabel';
14
14
  // 表单
15
- export { ProFormGroup, useProFormGroup } from './ProForm/components/ProFormGroup';
16
15
  export { default as ProForm } from './ProForm';
17
16
  export * from './ProForm';
18
17
  export * from './ProForm/components'; // ProForm 中组件导出
@@ -93,7 +93,8 @@
93
93
 
94
94
  .@{ant-prefix}-input[disabled],
95
95
  .@{ant-prefix}-select-disabled,
96
- .@{ant-prefix}-select-disabled.@{ant-prefix}-select:not(.@{ant-prefix}-select-customize-input) .@{ant-prefix}-select-selector,
96
+ .@{ant-prefix}-select-disabled.@{ant-prefix}-select:not(.@{ant-prefix}-select-customize-input)
97
+ .@{ant-prefix}-select-selector,
97
98
  .@{ant-prefix}-input-number-disabled,
98
99
  .@{ant-prefix}-picker-input > input[disabled],
99
100
  .@{ant-prefix}-select-disabled.@{ant-prefix}-select-multiple .@{ant-prefix}-select-selection-item {
@@ -218,7 +219,11 @@
218
219
  .@{ant-prefix}-table tfoot > tr > td {
219
220
  padding: calc(4px + var(--zaui-size) * 8px);
220
221
  }
221
- .@{ant-prefix}-table-tbody > tr > td > .@{ant-prefix}-table-wrapper:only-child .@{ant-prefix}-table,
222
+ .@{ant-prefix}-table-tbody
223
+ > tr
224
+ > td
225
+ > .@{ant-prefix}-table-wrapper:only-child
226
+ .@{ant-prefix}-table,
222
227
  .@{ant-prefix}-table-tbody
223
228
  > tr
224
229
  > td
@@ -508,7 +513,8 @@
508
513
  border-radius: @zaui-border-radius;
509
514
  }
510
515
 
511
- .@{ant-prefix}-select-single:not(.@{ant-prefix}-select-customize-input) .@{ant-prefix}-select-selector {
516
+ .@{ant-prefix}-select-single:not(.@{ant-prefix}-select-customize-input)
517
+ .@{ant-prefix}-select-selector {
512
518
  .set-text-color();
513
519
  .set-text-size();
514
520
  width: 100%;
@@ -523,8 +529,12 @@
523
529
  border-radius: @zaui-border-radius;
524
530
  }
525
531
 
526
- .@{ant-prefix}-pagination-jump-prev .@{ant-prefix}-pagination-item-container .@{ant-prefix}-pagination-item-link-icon,
527
- .@{ant-prefix}-pagination-jump-next .@{ant-prefix}-pagination-item-container .@{ant-prefix}-pagination-item-link-icon {
532
+ .@{ant-prefix}-pagination-jump-prev
533
+ .@{ant-prefix}-pagination-item-container
534
+ .@{ant-prefix}-pagination-item-link-icon,
535
+ .@{ant-prefix}-pagination-jump-next
536
+ .@{ant-prefix}-pagination-item-container
537
+ .@{ant-prefix}-pagination-item-link-icon {
528
538
  color: @zaui-brand;
529
539
  }
530
540
  }
@@ -705,3 +715,34 @@
705
715
  .@{ant-prefix}-popover {
706
716
  width: max-content;
707
717
  }
718
+
719
+ // tooltip样式重载
720
+ .@{ant-prefix}-tooltip {
721
+ > .ant-tooltip-content {
722
+ > .ant-tooltip-inner {
723
+ color: rgb(29, 33, 41);
724
+ background-color: #fff;
725
+ box-shadow: 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 6px 16px 0 rgba(0, 0, 0, 0.08),
726
+ 0 9px 28px 8px rgba(0, 0, 0, 0.05);
727
+ &::selection {
728
+ color: inherit !important;
729
+ background: rgba(@primary-color, 0.3) !important;
730
+ }
731
+ > div {
732
+ &::selection {
733
+ color: inherit !important;
734
+ background: rgba(@primary-color, 0.3) !important;
735
+ }
736
+ }
737
+ }
738
+ > .ant-tooltip-arrow {
739
+ > .ant-tooltip-arrow-content {
740
+ --antd-arrow-background-color: linear-gradient(
741
+ to right bottom,
742
+ rgba(255, 255, 255, 0.95),
743
+ rgba(255, 255, 255, 1)
744
+ );
745
+ }
746
+ }
747
+ }
748
+ }
@@ -1,4 +1,5 @@
1
1
  import React, { FC } from 'react';
2
+ import { FormInstance } from 'antd';
2
3
  import { PropSelectProps } from '../ProSelect/propsType';
3
4
  import { ProModalSelectPropsType } from '../ProForm/components/combination/ProModalSelect/propsType';
4
5
  import { AddressProps } from '../ProForm/components/combination/ProAddressBar/propsType';
@@ -9,17 +10,24 @@ export interface ProConfigState {
9
10
  ProSelect?: Partial<PropSelectProps> & Record<string, any>;
10
11
  ProModalSelect?: Partial<ProModalSelectPropsType> & Record<string, any>;
11
12
  ProAddressBar?: Partial<AddressProps> & Record<string, any>;
13
+ forms: Record<string, FormInstance | undefined>;
12
14
  [key: string]: any;
13
15
  }
14
16
  interface ConfigContext {
15
17
  state: ProConfigState;
16
- dispatch: React.Dispatch<ProConfigState>;
18
+ dispatch: React.Dispatch<Actions>;
17
19
  }
18
20
  export declare const ProConfigContext: React.Context<ConfigContext>;
19
21
  export declare function useProConfig(): ConfigContext;
20
22
  export declare function useProConfig(name: keyof ConfigContext['state']): ConfigContext['state'][keyof ConfigContext['state']];
23
+ export declare function useContextForm(): Record<string, FormInstance<any>>;
24
+ type ActionsType = 'set' | 'setProEnum' | 'setProEnumDic';
25
+ interface Actions {
26
+ type: ActionsType;
27
+ payload: any;
28
+ }
21
29
  export declare const ProConfigProvider: FC<{
22
- value: ProConfigState;
30
+ value?: ProConfigState;
23
31
  locale?: string;
24
32
  }>;
25
33
  export default ProConfigProvider;
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.default = exports.ProConfigProvider = exports.ProConfigContext = void 0;
9
+ exports.useContextForm = useContextForm;
9
10
  exports.useProConfig = useProConfig;
10
11
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
12
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
@@ -17,12 +18,14 @@ var _en_US = _interopRequireDefault(require("antd/es/locale/en_US"));
17
18
  var _merge = _interopRequireDefault(require("lodash/merge"));
18
19
  var _useEnumRequest = _interopRequireDefault(require("../ProEnum/hooks/useEnumRequest"));
19
20
  var _locale = require("../locale");
20
- var ProConfigContext = exports.ProConfigContext = /*#__PURE__*/_react.default.createContext({
21
- state: {
22
- ProEnum: {
23
- dics: {}
24
- }
21
+ var initialState = {
22
+ ProEnum: {
23
+ dics: {}
25
24
  },
25
+ forms: {}
26
+ };
27
+ var ProConfigContext = exports.ProConfigContext = /*#__PURE__*/_react.default.createContext({
28
+ state: initialState,
26
29
  dispatch: function dispatch() {}
27
30
  });
28
31
  // eslint-disable-next-line no-redeclare
@@ -30,6 +33,11 @@ function useProConfig(name) {
30
33
  var config = (0, _react.useContext)(ProConfigContext);
31
34
  return name ? config.state[name] : config;
32
35
  }
36
+ function useContextForm() {
37
+ var _config$state;
38
+ var config = (0, _react.useContext)(ProConfigContext);
39
+ return (_config$state = config.state) === null || _config$state === void 0 ? void 0 : _config$state.forms;
40
+ }
33
41
  var antdLangMap = {
34
42
  'zh-CN': _zh_CN.default,
35
43
  'en-US': _en_US.default // en-US
@@ -55,7 +63,7 @@ var reducer = function reducer(state, action) {
55
63
  };
56
64
  var ProConfigProvider = exports.ProConfigProvider = function ProConfigProvider(props) {
57
65
  var _props$value, _props$value2;
58
- var _useReducer = (0, _react.useReducer)(reducer, {}),
66
+ var _useReducer = (0, _react.useReducer)(reducer, initialState),
59
67
  _useReducer2 = (0, _slicedToArray2.default)(_useReducer, 2),
60
68
  state = _useReducer2[0],
61
69
  dispatch = _useReducer2[1];
@@ -25,10 +25,9 @@ var _index = require("./utils/index");
25
25
  var _useForm3 = require("./utils/useForm");
26
26
  var _useFieldProps = require("./utils/useFieldProps");
27
27
  var _locale = _interopRequireDefault(require("../locale"));
28
- var _ProFormGroup = require("./components/ProFormGroup");
29
- var _excluded = ["mode", "span", "disabled", "isView", "columns", "footer", "onOk", "okText", "onCancel", "confirmLoading", "cancelText", "form", "children", "rowProps", "className", "expand", "expandOpen", "expandOpenChange", "viewEmpty", "labelAlign", "labelWidth", "onValuesChange", "onFinish", "originalValues", "submitOnEnter", "clearNotShow", "initialValues", "requiredOnView", "formId", "required", "originalTip", "groupName"];
28
+ var _excluded = ["mode", "span", "disabled", "isView", "columns", "footer", "onOk", "okText", "onCancel", "confirmLoading", "cancelText", "form", "children", "rowProps", "className", "expand", "expandOpen", "expandOpenChange", "viewEmpty", "labelAlign", "labelWidth", "onValuesChange", "onFinish", "originalValues", "submitOnEnter", "clearNotShow", "initialValues", "requiredOnView", "formId", "required", "originalTip", "formKey"];
30
29
  var ProForm = function ProForm(props, ref) {
31
- var _groupForm$groupName, _localStorage;
30
+ var _forms$formKey, _localStorage;
32
31
  var _props$mode = props.mode,
33
32
  mode = _props$mode === void 0 ? 'search' : _props$mode,
34
33
  span = props.span,
@@ -67,13 +66,14 @@ var ProForm = function ProForm(props, ref) {
67
66
  required = props.required,
68
67
  _props$originalTip = props.originalTip,
69
68
  originalTip = _props$originalTip === void 0 ? true : _props$originalTip,
70
- groupName = props.groupName,
69
+ formKey = props.formKey,
71
70
  otherProps = (0, _objectWithoutProperties2.default)(props, _excluded);
72
- var _ref = (0, _react.useContext)(_ProFormGroup.groupContext) || [],
73
- _ref2 = (0, _slicedToArray2.default)(_ref, 2),
74
- groupForm = _ref2[0],
75
- setGroupForm = _ref2[1];
76
- var _useForm = (0, _useForm3.useForm)((_groupForm$groupName = groupForm[groupName]) !== null && _groupForm$groupName !== void 0 ? _groupForm$groupName : originForm),
71
+ var _useProConfig = (0, _ProConfigProvider.useProConfig)(),
72
+ state = _useProConfig.state,
73
+ dispatch = _useProConfig.dispatch;
74
+ var config = state.ProForm,
75
+ forms = state.forms;
76
+ var _useForm = (0, _useForm3.useForm)((_forms$formKey = forms[formKey]) !== null && _forms$formKey !== void 0 ? _forms$formKey : originForm),
77
77
  _useForm2 = (0, _slicedToArray2.default)(_useForm, 1),
78
78
  form = _useForm2[0];
79
79
  var _useControlled = (0, _index.useControlled)({
@@ -83,21 +83,30 @@ var ProForm = function ProForm(props, ref) {
83
83
  _useControlled2 = (0, _slicedToArray2.default)(_useControlled, 2),
84
84
  openState = _useControlled2[0],
85
85
  setOpenState = _useControlled2[1];
86
- var config = (0, _ProConfigProvider.useProConfig)('ProForm');
87
86
  // 把表单实例存入表单组
88
87
  (0, _react.useMemo)(function () {
89
- if (groupName && groupForm[groupName] !== form) {
90
- groupForm[groupName] = form;
91
- setGroupForm((0, _objectSpread2.default)({}, groupForm));
88
+ if (formKey && forms[formKey] !== form) {
89
+ forms[formKey] = form;
90
+ dispatch({
91
+ type: 'set',
92
+ payload: {
93
+ forms: (0, _objectSpread2.default)({}, forms)
94
+ }
95
+ });
92
96
  }
93
97
  // 销毁
94
98
  return function () {
95
- if (groupName && groupForm[groupName]) {
96
- delete _antd.Form[groupName];
97
- setGroupForm((0, _objectSpread2.default)({}, groupForm));
99
+ if (formKey && forms[formKey]) {
100
+ delete forms[formKey];
101
+ dispatch({
102
+ type: 'set',
103
+ payload: {
104
+ forms: (0, _objectSpread2.default)({}, forms)
105
+ }
106
+ });
98
107
  }
99
108
  };
100
- }, [groupName, form]);
109
+ }, [formKey, form]);
101
110
  var _getLayout = (0, _index.getLayout)({
102
111
  span: span,
103
112
  form: form
@@ -302,6 +311,7 @@ var ProFormProvider = function ProFormProvider(props) {
302
311
  };
303
312
  ProFormForward.Provider = ProFormProvider; // 包装Provider
304
313
  ProFormForward.useFieldProps = _useFieldProps.useFieldProps; // 获取每个字段的其他参数 -otherProps
314
+ ProFormForward.useContextForm = _ProConfigProvider.useContextForm; // 获取 ProConfigProvider中的表单实例map
305
315
  // 内置组合
306
316
  ProFormForward.ProAddressBar = _components.ProAddressBar;
307
317
  ProFormForward.ProCombination = _components.ProCombination;
@@ -43,7 +43,7 @@ export interface ProFormOtherProps {
43
43
  export interface ProFormProps<Values = any> extends FormProps<Values> {
44
44
  disabled?: boolean;
45
45
  mode?: ModeEnum;
46
- groupName?: string;
46
+ formKey?: string;
47
47
  /** 是否查看 */
48
48
  isView?: boolean;
49
49
  span?: number;
@@ -84,4 +84,8 @@ export declare const deleteForPath: (values: any, namePath: string | number | (s
84
84
  * @returns {}
85
85
  */
86
86
  export declare const findOptionByValue: (treeData: any[], value: string | number) => any;
87
+ /**
88
+ * 对比依赖列表中的 值是否变更
89
+ */
90
+ export declare const equalDependencies: (dependencies: any, prevValues: any, currentValues: any) => any;
87
91
  export {};
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.getAllNamePath = exports.findOptionByValue = exports.filterInternalFields = exports.deleteForPath = exports.customEqualForFun = exports.contrast = void 0;
8
+ exports.getAllNamePath = exports.findOptionByValue = exports.filterInternalFields = exports.equalDependencies = exports.deleteForPath = exports.customEqualForFun = exports.contrast = void 0;
9
9
  exports.getArrayBeforeNumber = getArrayBeforeNumber;
10
10
  exports.hasRowKey = exports.getLayout = exports.getDecimalDigits = void 0;
11
11
  exports.initialValuesToNames = initialValuesToNames;
@@ -423,4 +423,17 @@ var findOptionByValue = exports.findOptionByValue = function findOptionByValue(t
423
423
  }
424
424
  }
425
425
  }
426
+ };
427
+ /**
428
+ * 对比依赖列表中的 值是否变更
429
+ */
430
+ var equalDependencies = exports.equalDependencies = function equalDependencies(dependencies, prevValues, currentValues) {
431
+ if (dependencies === null || dependencies === void 0 ? void 0 : dependencies.length) {
432
+ return dependencies.some(function (namePath) {
433
+ var prevValue = (0, _lodash.get)(prevValues, namePath);
434
+ var currentValue = (0, _lodash.get)(currentValues, namePath);
435
+ return prevValue !== currentValue;
436
+ });
437
+ }
438
+ return false;
426
439
  };
@@ -27,7 +27,8 @@ var useShouldUpdate = function useShouldUpdate(props) {
27
27
  clearNotShow = formItemProps.clearNotShow,
28
28
  index = formItemProps.index,
29
29
  namePath = formItemProps.namePath,
30
- names = formItemProps.names;
30
+ names = formItemProps.names,
31
+ dependencies = formItemProps.dependencies;
31
32
  var timerRef = (0, _react.useRef)();
32
33
  var showRef = (0, _react.useRef)();
33
34
  var disabledRef = (0, _react.useRef)();
@@ -178,7 +179,7 @@ var useShouldUpdate = function useShouldUpdate(props) {
178
179
  if (_required !== requiredRef.current || !(0, _lodash.isEqualWith)(rulesRef.current, _rules, _index.customEqualForFun)) {
179
180
  form.validateFields([name]);
180
181
  }
181
- if (_show !== showRef.current || _disabled !== disabledRef.current || _required !== requiredRef.current || !(0, _lodash.isEqualWith)(rulesRef.current, _rules, _index.customEqualForFun) || !(0, _lodash.isEqualWith)(fieldPropsRef.current, _fieldProps, _index.customEqualForFun) || !(0, _lodash.isEqualWith)(originComponentRef.current, _component, _index.customEqualForFun)) {
182
+ if (_show !== showRef.current || _disabled !== disabledRef.current || _required !== requiredRef.current || !(0, _lodash.isEqualWith)(rulesRef.current, _rules, _index.customEqualForFun) || !(0, _lodash.isEqualWith)(fieldPropsRef.current, _fieldProps, _index.customEqualForFun) || !(0, _lodash.isEqualWith)(originComponentRef.current, _component, _index.customEqualForFun) || (0, _index.equalDependencies)(dependencies, prevValues, _currentValues)) {
182
183
  showRef.current = _show;
183
184
  disabledRef.current = _disabled;
184
185
  requiredRef.current = _required;
package/lib/index.d.ts CHANGED
@@ -8,7 +8,6 @@ export { default as ProViewer } from './ProViewer';
8
8
  export { default as ProEditTable } from './ProEditTable';
9
9
  export { default as ProDrawerForm } from './ProDrawerForm';
10
10
  export { default as ProEditLabel } from './ProEditLabel';
11
- export { ProFormGroup, useProFormGroup } from './ProForm/components/ProFormGroup';
12
11
  export { default as ProForm } from './ProForm';
13
12
  export * from './ProForm';
14
13
  export * from './ProForm/components';
package/lib/index.js CHANGED
@@ -15,8 +15,6 @@ var _exportNames = {
15
15
  ProEditTable: true,
16
16
  ProDrawerForm: true,
17
17
  ProEditLabel: true,
18
- ProFormGroup: true,
19
- useProFormGroup: true,
20
18
  ProForm: true,
21
19
  ProSelect: true,
22
20
  ProEnum: true,
@@ -97,12 +95,6 @@ Object.defineProperty(exports, "ProForm", {
97
95
  return _ProForm.default;
98
96
  }
99
97
  });
100
- Object.defineProperty(exports, "ProFormGroup", {
101
- enumerable: true,
102
- get: function get() {
103
- return _ProFormGroup.ProFormGroup;
104
- }
105
- });
106
98
  Object.defineProperty(exports, "ProIcon", {
107
99
  enumerable: true,
108
100
  get: function get() {
@@ -169,12 +161,6 @@ Object.defineProperty(exports, "ProWaterMark", {
169
161
  return _ProWaterMark.default;
170
162
  }
171
163
  });
172
- Object.defineProperty(exports, "useProFormGroup", {
173
- enumerable: true,
174
- get: function get() {
175
- return _ProFormGroup.useProFormGroup;
176
- }
177
- });
178
164
  var _ProLayout = _interopRequireDefault(require("./ProLayout"));
179
165
  var _ProStep = _interopRequireDefault(require("./ProStep"));
180
166
  var _ProTabs = _interopRequireDefault(require("./ProTabs"));
@@ -184,7 +170,6 @@ var _ProViewer = _interopRequireDefault(require("./ProViewer"));
184
170
  var _ProEditTable = _interopRequireDefault(require("./ProEditTable"));
185
171
  var _ProDrawerForm = _interopRequireDefault(require("./ProDrawerForm"));
186
172
  var _ProEditLabel = _interopRequireDefault(require("./ProEditLabel"));
187
- var _ProFormGroup = require("./ProForm/components/ProFormGroup");
188
173
  var _ProForm = _interopRequireWildcard(require("./ProForm"));
189
174
  Object.keys(_ProForm).forEach(function (key) {
190
175
  if (key === "default" || key === "__esModule") return;
@@ -93,7 +93,8 @@
93
93
 
94
94
  .@{ant-prefix}-input[disabled],
95
95
  .@{ant-prefix}-select-disabled,
96
- .@{ant-prefix}-select-disabled.@{ant-prefix}-select:not(.@{ant-prefix}-select-customize-input) .@{ant-prefix}-select-selector,
96
+ .@{ant-prefix}-select-disabled.@{ant-prefix}-select:not(.@{ant-prefix}-select-customize-input)
97
+ .@{ant-prefix}-select-selector,
97
98
  .@{ant-prefix}-input-number-disabled,
98
99
  .@{ant-prefix}-picker-input > input[disabled],
99
100
  .@{ant-prefix}-select-disabled.@{ant-prefix}-select-multiple .@{ant-prefix}-select-selection-item {
@@ -218,7 +219,11 @@
218
219
  .@{ant-prefix}-table tfoot > tr > td {
219
220
  padding: calc(4px + var(--zaui-size) * 8px);
220
221
  }
221
- .@{ant-prefix}-table-tbody > tr > td > .@{ant-prefix}-table-wrapper:only-child .@{ant-prefix}-table,
222
+ .@{ant-prefix}-table-tbody
223
+ > tr
224
+ > td
225
+ > .@{ant-prefix}-table-wrapper:only-child
226
+ .@{ant-prefix}-table,
222
227
  .@{ant-prefix}-table-tbody
223
228
  > tr
224
229
  > td
@@ -508,7 +513,8 @@
508
513
  border-radius: @zaui-border-radius;
509
514
  }
510
515
 
511
- .@{ant-prefix}-select-single:not(.@{ant-prefix}-select-customize-input) .@{ant-prefix}-select-selector {
516
+ .@{ant-prefix}-select-single:not(.@{ant-prefix}-select-customize-input)
517
+ .@{ant-prefix}-select-selector {
512
518
  .set-text-color();
513
519
  .set-text-size();
514
520
  width: 100%;
@@ -523,8 +529,12 @@
523
529
  border-radius: @zaui-border-radius;
524
530
  }
525
531
 
526
- .@{ant-prefix}-pagination-jump-prev .@{ant-prefix}-pagination-item-container .@{ant-prefix}-pagination-item-link-icon,
527
- .@{ant-prefix}-pagination-jump-next .@{ant-prefix}-pagination-item-container .@{ant-prefix}-pagination-item-link-icon {
532
+ .@{ant-prefix}-pagination-jump-prev
533
+ .@{ant-prefix}-pagination-item-container
534
+ .@{ant-prefix}-pagination-item-link-icon,
535
+ .@{ant-prefix}-pagination-jump-next
536
+ .@{ant-prefix}-pagination-item-container
537
+ .@{ant-prefix}-pagination-item-link-icon {
528
538
  color: @zaui-brand;
529
539
  }
530
540
  }
@@ -705,3 +715,34 @@
705
715
  .@{ant-prefix}-popover {
706
716
  width: max-content;
707
717
  }
718
+
719
+ // tooltip样式重载
720
+ .@{ant-prefix}-tooltip {
721
+ > .ant-tooltip-content {
722
+ > .ant-tooltip-inner {
723
+ color: rgb(29, 33, 41);
724
+ background-color: #fff;
725
+ box-shadow: 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 6px 16px 0 rgba(0, 0, 0, 0.08),
726
+ 0 9px 28px 8px rgba(0, 0, 0, 0.05);
727
+ &::selection {
728
+ color: inherit !important;
729
+ background: rgba(@primary-color, 0.3) !important;
730
+ }
731
+ > div {
732
+ &::selection {
733
+ color: inherit !important;
734
+ background: rgba(@primary-color, 0.3) !important;
735
+ }
736
+ }
737
+ }
738
+ > .ant-tooltip-arrow {
739
+ > .ant-tooltip-arrow-content {
740
+ --antd-arrow-background-color: linear-gradient(
741
+ to right bottom,
742
+ rgba(255, 255, 255, 0.95),
743
+ rgba(255, 255, 255, 1)
744
+ );
745
+ }
746
+ }
747
+ }
748
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zat-design/sisyphus-react",
3
- "version": "3.3.3-beta.3",
3
+ "version": "3.3.3-beta.5",
4
4
  "license": "Apache-2.0",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -1,13 +0,0 @@
1
- import React from 'react';
2
- import { FormInstance } from 'antd';
3
- interface FormGroup {
4
- [K: string]: FormInstance | undefined;
5
- }
6
- type ContextType = [FormGroup, (forms: FormGroup) => void];
7
- export declare const groupContext: React.Context<ContextType>;
8
- interface Props {
9
- formGroup?: FormGroup;
10
- }
11
- export declare const useProFormGroup: () => FormGroup;
12
- export declare const ProFormGroup: React.FC<Props>;
13
- export {};
@@ -1,27 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
- import { jsx as _jsx } from "react/jsx-runtime";
4
- import React, { useContext, useMemo, useState } from 'react';
5
- export var groupContext = /*#__PURE__*/React.createContext([{}, function () {
6
- return undefined;
7
- }]);
8
- export var useProFormGroup = function useProFormGroup() {
9
- var formGroup = useContext(groupContext);
10
- return formGroup[0];
11
- };
12
- export var ProFormGroup = function ProFormGroup(props) {
13
- var formGroup = props.formGroup,
14
- children = props.children;
15
- var Provider = groupContext.Provider;
16
- var initialFormGroup = useMemo(function () {
17
- return formGroup ? _objectSpread({}, formGroup) : {};
18
- }, [formGroup]);
19
- var _useState = useState(initialFormGroup),
20
- _useState2 = _slicedToArray(_useState, 2),
21
- forms = _useState2[0],
22
- setForms = _useState2[1];
23
- return _jsx(Provider, {
24
- value: [forms, setForms],
25
- children: children
26
- });
27
- };
@@ -1,13 +0,0 @@
1
- import React from 'react';
2
- import { FormInstance } from 'antd';
3
- interface FormGroup {
4
- [K: string]: FormInstance | undefined;
5
- }
6
- type ContextType = [FormGroup, (forms: FormGroup) => void];
7
- export declare const groupContext: React.Context<ContextType>;
8
- interface Props {
9
- formGroup?: FormGroup;
10
- }
11
- export declare const useProFormGroup: () => FormGroup;
12
- export declare const ProFormGroup: React.FC<Props>;
13
- export {};
@@ -1,35 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.useProFormGroup = exports.groupContext = exports.ProFormGroup = void 0;
9
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
11
- var _jsxRuntime = require("react/jsx-runtime");
12
- var _react = _interopRequireWildcard(require("react"));
13
- var groupContext = exports.groupContext = /*#__PURE__*/_react.default.createContext([{}, function () {
14
- return undefined;
15
- }]);
16
- var useProFormGroup = exports.useProFormGroup = function useProFormGroup() {
17
- var formGroup = (0, _react.useContext)(groupContext);
18
- return formGroup[0];
19
- };
20
- var ProFormGroup = exports.ProFormGroup = function ProFormGroup(props) {
21
- var formGroup = props.formGroup,
22
- children = props.children;
23
- var Provider = groupContext.Provider;
24
- var initialFormGroup = (0, _react.useMemo)(function () {
25
- return formGroup ? (0, _objectSpread2.default)({}, formGroup) : {};
26
- }, [formGroup]);
27
- var _useState = (0, _react.useState)(initialFormGroup),
28
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
29
- forms = _useState2[0],
30
- setForms = _useState2[1];
31
- return (0, _jsxRuntime.jsx)(Provider, {
32
- value: [forms, setForms],
33
- children: children
34
- });
35
- };