@zat-design/sisyphus-react 3.3.4 → 3.4.0
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,6 +1,6 @@
|
|
|
1
1
|
import type { ProThemeToolsProps } from './propsType';
|
|
2
2
|
declare const ProThemeTools: {
|
|
3
|
-
({ size, className, cacheTime, color, mode, iconFollowTheme, prefixCls, tableBorder, tableStripe, theme, ...props }: ProThemeToolsProps): JSX.Element;
|
|
3
|
+
({ size, className, cacheTime, color, mode, iconFollowTheme, prefixCls, tableBorder, tableStripe, theme, onChange, ...props }: ProThemeToolsProps): JSX.Element;
|
|
4
4
|
defaultProps: {
|
|
5
5
|
size: number;
|
|
6
6
|
mode: string;
|
|
@@ -6,11 +6,13 @@ import _message from "antd/es/message";
|
|
|
6
6
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
7
7
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
8
8
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
9
|
-
var _excluded = ["size", "className", "cacheTime", "color", "mode", "iconFollowTheme", "prefixCls", "tableBorder", "tableStripe", "theme"];
|
|
9
|
+
var _excluded = ["size", "className", "cacheTime", "color", "mode", "iconFollowTheme", "prefixCls", "tableBorder", "tableStripe", "theme", "onChange"];
|
|
10
10
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
11
|
/* eslint-disable prefer-const */
|
|
12
12
|
import { SettingOutlined } from '@ant-design/icons';
|
|
13
13
|
import { useEffect, useState } from 'react';
|
|
14
|
+
import { usePrevious, useUpdateEffect } from 'ahooks';
|
|
15
|
+
import { isEqual } from 'lodash';
|
|
14
16
|
import classnames from 'classnames';
|
|
15
17
|
import { getKebabCase, setThemes, setTableNoStripe, setTableBorder, getMapKebabCase, getMapHumpCase } from './utils/index';
|
|
16
18
|
import { PrdTools } from './component';
|
|
@@ -46,6 +48,7 @@ var ProThemeTools = function ProThemeTools(_ref) {
|
|
|
46
48
|
tableStripe = _ref$tableStripe === void 0 ? false : _ref$tableStripe,
|
|
47
49
|
_ref$theme = _ref.theme,
|
|
48
50
|
theme = _ref$theme === void 0 ? {} : _ref$theme,
|
|
51
|
+
onChange = _ref.onChange,
|
|
49
52
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
50
53
|
var _useState = useState(false),
|
|
51
54
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -55,6 +58,7 @@ var ProThemeTools = function ProThemeTools(_ref) {
|
|
|
55
58
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
56
59
|
state = _useState4[0],
|
|
57
60
|
setState = _useState4[1];
|
|
61
|
+
var previousState = usePrevious(state);
|
|
58
62
|
var zauiBrand = state.zauiBrand,
|
|
59
63
|
zauiStripe = state.zauiStripe,
|
|
60
64
|
zauiTableBorder = state.zauiTableBorder;
|
|
@@ -165,6 +169,11 @@ var ProThemeTools = function ProThemeTools(_ref) {
|
|
|
165
169
|
localStorage.setItem('themeConfig', JSON.stringify(newThemeConfig));
|
|
166
170
|
}
|
|
167
171
|
}, [state, cacheTime]);
|
|
172
|
+
useUpdateEffect(function () {
|
|
173
|
+
if (!isEqual(state, previousState) && visible) {
|
|
174
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(state);
|
|
175
|
+
}
|
|
176
|
+
}, [state]);
|
|
168
177
|
var cls = classnames(_defineProperty({
|
|
169
178
|
'pro-theme-tools': true,
|
|
170
179
|
'pro-theme-tools-follow': iconFollowTheme
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ProThemeToolsProps } from './propsType';
|
|
2
2
|
declare const ProThemeTools: {
|
|
3
|
-
({ size, className, cacheTime, color, mode, iconFollowTheme, prefixCls, tableBorder, tableStripe, theme, ...props }: ProThemeToolsProps): JSX.Element;
|
|
3
|
+
({ size, className, cacheTime, color, mode, iconFollowTheme, prefixCls, tableBorder, tableStripe, theme, onChange, ...props }: ProThemeToolsProps): JSX.Element;
|
|
4
4
|
defaultProps: {
|
|
5
5
|
size: number;
|
|
6
6
|
mode: string;
|
|
@@ -13,11 +13,13 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
13
13
|
var _icons = require("@ant-design/icons");
|
|
14
14
|
var _antd = require("antd");
|
|
15
15
|
var _react = require("react");
|
|
16
|
+
var _ahooks = require("ahooks");
|
|
17
|
+
var _lodash = require("lodash");
|
|
16
18
|
var _classnames2 = _interopRequireDefault(require("classnames"));
|
|
17
19
|
var _index = require("./utils/index");
|
|
18
20
|
var _component = require("./component");
|
|
19
21
|
var _locale = _interopRequireDefault(require("../locale"));
|
|
20
|
-
var _excluded = ["size", "className", "cacheTime", "color", "mode", "iconFollowTheme", "prefixCls", "tableBorder", "tableStripe", "theme"];
|
|
22
|
+
var _excluded = ["size", "className", "cacheTime", "color", "mode", "iconFollowTheme", "prefixCls", "tableBorder", "tableStripe", "theme", "onChange"];
|
|
21
23
|
/* eslint-disable prefer-const */
|
|
22
24
|
var defaultCacheTime = 1; // 配置保存时间为一天
|
|
23
25
|
var defaultThemeConfig = {
|
|
@@ -50,6 +52,7 @@ var ProThemeTools = function ProThemeTools(_ref) {
|
|
|
50
52
|
tableStripe = _ref$tableStripe === void 0 ? false : _ref$tableStripe,
|
|
51
53
|
_ref$theme = _ref.theme,
|
|
52
54
|
theme = _ref$theme === void 0 ? {} : _ref$theme,
|
|
55
|
+
onChange = _ref.onChange,
|
|
53
56
|
props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
54
57
|
var _useState = (0, _react.useState)(false),
|
|
55
58
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -59,6 +62,7 @@ var ProThemeTools = function ProThemeTools(_ref) {
|
|
|
59
62
|
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
60
63
|
state = _useState4[0],
|
|
61
64
|
setState = _useState4[1];
|
|
65
|
+
var previousState = (0, _ahooks.usePrevious)(state);
|
|
62
66
|
var zauiBrand = state.zauiBrand,
|
|
63
67
|
zauiStripe = state.zauiStripe,
|
|
64
68
|
zauiTableBorder = state.zauiTableBorder;
|
|
@@ -169,6 +173,11 @@ var ProThemeTools = function ProThemeTools(_ref) {
|
|
|
169
173
|
localStorage.setItem('themeConfig', JSON.stringify(newThemeConfig));
|
|
170
174
|
}
|
|
171
175
|
}, [state, cacheTime]);
|
|
176
|
+
(0, _ahooks.useUpdateEffect)(function () {
|
|
177
|
+
if (!(0, _lodash.isEqual)(state, previousState) && visible) {
|
|
178
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(state);
|
|
179
|
+
}
|
|
180
|
+
}, [state]);
|
|
172
181
|
var cls = (0, _classnames2.default)((0, _defineProperty2.default)({
|
|
173
182
|
'pro-theme-tools': true,
|
|
174
183
|
'pro-theme-tools-follow': iconFollowTheme
|