@ccs-ui/rc-pro 2.0.8 → 2.1.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.
package/es/config.js CHANGED
@@ -11,12 +11,13 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
11
11
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
12
12
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
13
  import { darkTheme, defaultTheme } from '@ant-design/compatible';
14
- import { App, ConfigProvider, message, Modal, notification } from 'antd';
14
+ import { theme as antTheme, App, ConfigProvider, message, Modal, notification } from 'antd';
15
15
  import zhCN from 'antd/locale/zh_CN';
16
16
  import React, { useState } from 'react';
17
17
  import { AppConfigContext } from "./context";
18
18
  import usePatchElement from "./dialog/usePatchElement";
19
19
  import ThemeDialog from "./theme-dialog";
20
+ import WaterMarkRelative from "./water-mark/relative";
20
21
  import { Fragment as _Fragment } from "react/jsx-runtime";
21
22
  import { jsx as _jsx } from "react/jsx-runtime";
22
23
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -61,15 +62,22 @@ function AppConfig(_ref) {
61
62
  var children = _ref.children,
62
63
  _ref$theme = _ref.theme,
63
64
  theme = _ref$theme === void 0 ? 'light' : _ref$theme,
65
+ isCompact = _ref.isCompact,
66
+ watermark = _ref.watermark,
64
67
  themeConfig = _ref.themeConfig;
65
68
  var holderRef = React.useRef(null);
66
69
  // 主题
67
70
  var appTheme = theme === 'dark' ? darkTheme : defaultTheme;
71
+ var algorithm = function algorithm() {
72
+ var algorithms = theme === 'dark' ? [antTheme.darkAlgorithm] : [antTheme.defaultAlgorithm];
73
+ if (isCompact) {
74
+ algorithms.push(antTheme.compactAlgorithm);
75
+ }
76
+ return algorithms;
77
+ };
68
78
 
69
79
  // 合并token
70
- var token = _objectSpread(_objectSpread(_objectSpread({}, appTheme.token), themeConfig === null || themeConfig === void 0 ? void 0 : themeConfig.token), {}, {
71
- _appTheme: theme
72
- });
80
+ var token = _objectSpread(_objectSpread({}, appTheme.token), themeConfig === null || themeConfig === void 0 ? void 0 : themeConfig.token);
73
81
 
74
82
  // 暗黑模式背景色
75
83
  if (theme === 'dark') token.colorBgContainer = 'rgb(36, 37, 37)';
@@ -77,7 +85,8 @@ function AppConfig(_ref) {
77
85
  locale: zhCN,
78
86
  theme: _objectSpread(_objectSpread({}, appTheme), {}, {
79
87
  token: token,
80
- components: _objectSpread(_objectSpread({}, appTheme.components), themeConfig === null || themeConfig === void 0 ? void 0 : themeConfig.components)
88
+ components: _objectSpread(_objectSpread({}, appTheme.components), themeConfig === null || themeConfig === void 0 ? void 0 : themeConfig.components),
89
+ algorithm: algorithm()
81
90
  }),
82
91
  children: /*#__PURE__*/_jsxs(AppConfigContext.Provider, {
83
92
  value: {
@@ -87,7 +96,11 @@ function AppConfig(_ref) {
87
96
  },
88
97
  children: [children, /*#__PURE__*/_jsx(AppDialog, {}), /*#__PURE__*/_jsx(ElementsHolder, {
89
98
  ref: holderRef
90
- }, "modal-drawer-holder")]
99
+ }, "modal-drawer-holder"), (watermark === null || watermark === void 0 ? void 0 : watermark.content) && /*#__PURE__*/_jsx(WaterMarkRelative, {
100
+ content: watermark.content,
101
+ fontColor: "rgba(0,0,0,.15)",
102
+ zIndex: 105
103
+ })]
91
104
  })
92
105
  });
93
106
  }
@@ -4,6 +4,7 @@ import React from 'react';
4
4
  import { Location } from 'react-router';
5
5
  import CCS from '..';
6
6
  import { ElementsHolderRef } from '../dialog/hook';
7
+ import { WaterMarkProps } from '../water-mark/relative';
7
8
  type CcsTabsChangeProps = {
8
9
  /** 当前激活tab面板的key */
9
10
  activeKey?: string;
@@ -52,6 +53,10 @@ type CssAppConfigType = {
52
53
  theme?: 'dark' | 'light' | 'colorful';
53
54
  /** 主题参数配置 */
54
55
  themeConfig?: ThemeConfig;
56
+ /** 紧凑模式 */
57
+ isCompact?: boolean;
58
+ /** 全局水印 */
59
+ watermark?: WaterMarkProps;
55
60
  /** modal or drawer holder */
56
61
  holderRef?: React.RefObject<ElementsHolderRef>;
57
62
  };
@@ -1,7 +1,7 @@
1
1
  import { FormProps } from 'antd';
2
2
  import { DialogFormRef } from './form';
3
3
  import { CcsDialogModalProps } from './hook';
4
- declare const DialogRequestButton: ({ auth, formRef, extraBtn, formInitialValues, request, onCancel, onRequestBefore, }: Pick<CcsDialogModalProps, "auth" | "request" | "onCancel" | "extraBtn" | "onRequestBefore"> & {
4
+ declare const DialogRequestButton: ({ auth, formRef, extraBtn, formInitialValues, request, onCancel, onRequestBefore, }: Pick<CcsDialogModalProps, "auth" | "request" | "extraBtn" | "onCancel" | "onRequestBefore"> & {
5
5
  formRef: React.RefObject<DialogFormRef>;
6
6
  formInitialValues: FormProps['initialValues'];
7
7
  }) => import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,7 @@
1
1
  import { FormProps } from 'antd';
2
2
  import { DialogFormRef } from './form';
3
3
  import { CcsDialogModalProps } from './hook';
4
- declare const DialogSelfOkButton: ({ auth, formRef, extraBtn, formInitialValues, onCancel, onOk, }: Pick<CcsDialogModalProps, "auth" | "onOk" | "onCancel" | "extraBtn"> & {
4
+ declare const DialogSelfOkButton: ({ auth, formRef, extraBtn, formInitialValues, onCancel, onOk, }: Pick<CcsDialogModalProps, "auth" | "onOk" | "extraBtn" | "onCancel"> & {
5
5
  formRef: React.RefObject<DialogFormRef>;
6
6
  formInitialValues: FormProps['initialValues'];
7
7
  }) => import("react/jsx-runtime").JSX.Element;
package/es/dialog/form.js CHANGED
@@ -44,10 +44,6 @@ var DialogForm = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
44
44
  },
45
45
  preserve: false
46
46
  }, restProps), {}, {
47
- style: _objectSpread({
48
- height: '100%',
49
- overflow: 'auto'
50
- }, restProps.style),
51
47
  children: children
52
48
  }));
53
49
  });
@@ -9,8 +9,8 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
9
9
  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; }
10
10
  import { javascript } from '@codemirror/lang-javascript';
11
11
  import CodeMirror from '@uiw/react-codemirror';
12
- import { theme } from 'antd';
13
12
  import classNames from 'classnames';
13
+ import useAppConfig from "../hooks/use-app";
14
14
  import { jsx as _jsx } from "react/jsx-runtime";
15
15
  export default function JavaScriptEditor(_ref) {
16
16
  var _ref$placeholder = _ref.placeholder,
@@ -22,9 +22,9 @@ export default function JavaScriptEditor(_ref) {
22
22
  style = _ref.style,
23
23
  className = _ref.className,
24
24
  restProps = _objectWithoutProperties(_ref, _excluded);
25
- var _theme$useToken = theme.useToken(),
26
- token = _theme$useToken.token;
27
- var isDark = token._appTheme === 'dark';
25
+ var _useAppConfig = useAppConfig(),
26
+ theme = _useAppConfig.theme;
27
+ var isDark = theme === 'dark';
28
28
  var styles = style || {};
29
29
  var previewProps = {};
30
30
  if (bordered !== false) {
package/es/editor/json.js CHANGED
@@ -11,8 +11,8 @@ import { json } from '@codemirror/lang-json';
11
11
  import { syntaxTree } from '@codemirror/language';
12
12
  import { linter } from '@codemirror/lint';
13
13
  import CodeMirror from '@uiw/react-codemirror';
14
- import { theme } from 'antd';
15
14
  import classNames from 'classnames';
15
+ import useAppConfig from "../hooks/use-app";
16
16
  import { jsx as _jsx } from "react/jsx-runtime";
17
17
  var regexpLinter = linter(function (view) {
18
18
  var diagnostics = [];
@@ -46,9 +46,9 @@ export default function JsonEditor(_ref) {
46
46
  className = _ref.className,
47
47
  isPreview = _ref.isPreview,
48
48
  restProps = _objectWithoutProperties(_ref, _excluded);
49
- var _theme$useToken = theme.useToken(),
50
- token = _theme$useToken.token;
51
- var isDark = token._appTheme === 'dark';
49
+ var _useAppConfig = useAppConfig(),
50
+ theme = _useAppConfig.theme;
51
+ var isDark = theme === 'dark';
52
52
  var styles = style || {};
53
53
  var previewProps = {};
54
54
  if (bordered !== false) {
package/es/editor/sql.js CHANGED
@@ -9,8 +9,8 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
9
9
  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; }
10
10
  import { sql } from '@codemirror/lang-sql';
11
11
  import CodeMirror from '@uiw/react-codemirror';
12
- import { theme } from 'antd';
13
12
  import classNames from 'classnames';
13
+ import useAppConfig from "../hooks/use-app";
14
14
  import { jsx as _jsx } from "react/jsx-runtime";
15
15
  export default function SqlEditor(_ref) {
16
16
  var _ref$placeholder = _ref.placeholder,
@@ -22,9 +22,9 @@ export default function SqlEditor(_ref) {
22
22
  style = _ref.style,
23
23
  className = _ref.className,
24
24
  restProps = _objectWithoutProperties(_ref, _excluded);
25
- var _theme$useToken = theme.useToken(),
26
- token = _theme$useToken.token;
27
- var isDark = token._appTheme === 'dark';
25
+ var _useAppConfig = useAppConfig(),
26
+ theme = _useAppConfig.theme;
27
+ var isDark = theme === 'dark';
28
28
  var styles = style || {};
29
29
  var previewProps = {};
30
30
  if (bordered !== false) {
@@ -8,7 +8,7 @@ import { AppConfigContext } from "../context";
8
8
  var useAppConfig = function useAppConfig() {
9
9
  var context = useContext(AppConfigContext);
10
10
  if (context === undefined) {
11
- throw new Error('AppConfigContext not found');
11
+ throw new Error('AppConfigContext not found 未全局使用 CcsAppConfig');
12
12
  }
13
13
  return context;
14
14
  };
@@ -14,11 +14,12 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
14
14
  import { MoreOutlined } from '@ant-design/icons';
15
15
  import CcsUtils from '@ccs-ui/utils';
16
16
  import { useUpdate, useUpdateEffect } from 'ahooks';
17
- import { Button, Dropdown, Empty, Tabs, theme } from 'antd';
17
+ import { Button, Dropdown, Empty, Tabs } from 'antd';
18
18
  import classnames from 'classnames';
19
19
  import { useMemo, useRef } from 'react';
20
20
  import { useLocation } from 'react-router';
21
21
  import { useOutlet } from 'react-router-dom';
22
+ import { useAppConfig } from '..';
22
23
  import "./index.less";
23
24
  import Page from "./page";
24
25
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -45,10 +46,10 @@ export default function KeepAliveTabs(_ref) {
45
46
  locationKey = location.key;
46
47
  var outlet = useOutlet();
47
48
  var update = useUpdate();
48
- var _theme$useToken = theme.useToken(),
49
- token = _theme$useToken.token;
50
- var isDark = token._appTheme === 'dark';
51
- var isColorful = token._appTheme === 'colorful';
49
+ var _useAppConfig = useAppConfig(),
50
+ theme = _useAppConfig.theme;
51
+ var isDark = theme === 'dark';
52
+ var isColorful = theme === 'colorful';
52
53
 
53
54
  // 超过缓存数量,删除第一个
54
55
  if (components.current.length >= maxLen) {
@@ -69,8 +69,6 @@ export type CcsProTableProps<RecordType> = Pick<PropsWithCss, 'className'> & Pro
69
69
  };
70
70
  /** 父级值字段 */
71
71
  parentFieldName?: string;
72
- /** 水印文字 */
73
- watermark?: string;
74
72
  /** ref 回调方法 */
75
73
  proRef?: CCS.TableInstanceRef<RecordType>;
76
74
  /** 显示序号 */
@@ -15,12 +15,12 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
15
15
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
16
16
  import CcsUtils from '@ccs-ui/utils';
17
17
  import { useSize, useUpdateEffect } from 'ahooks';
18
- import { Empty, Form, theme } from 'antd';
18
+ import { Empty, Form, theme as antTheme } from 'antd';
19
19
  import classNames from 'classnames';
20
20
  import React, { useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
21
+ import { useAppConfig } from '..';
21
22
  import { useCcsPage } from "../";
22
23
  import CcsTable from "../table";
23
- import WaterMarkRelative from "../water-mark/relative";
24
24
  import { getAllChildrenId, getDataById, onTableInModalOrDrawer, onTableInTabItem } from "./_utils";
25
25
  import HeadComponent from "./head";
26
26
  import "./index.less";
@@ -50,7 +50,6 @@ var InternalProTable = function InternalProTable(props) {
50
50
  proRef = props.proRef,
51
51
  toolbar = props.toolbar,
52
52
  children = props.children,
53
- watermark = props.watermark,
54
53
  className = props.className,
55
54
  expandForm = props.expandForm,
56
55
  searchEvent = props.searchEvent,
@@ -105,9 +104,9 @@ var InternalProTable = function InternalProTable(props) {
105
104
  tableRowSize = _useState6[0],
106
105
  setTableRowSize = _useState6[1];
107
106
  // 暗黑模式
108
- var _theme$useToken = theme.useToken(),
109
- token = _theme$useToken.token;
110
- var isDark = token._appTheme === 'dark';
107
+ var _useAppConfig = useAppConfig(),
108
+ theme = _useAppConfig.theme;
109
+ var isDark = theme === 'dark';
111
110
 
112
111
  // 权限判断
113
112
  var isAuth = useMemo(function () {
@@ -506,6 +505,8 @@ var InternalProTable = function InternalProTable(props) {
506
505
  },
507
506
  children: toolbarExtra
508
507
  });
508
+ var _antTheme$useToken = antTheme.useToken(),
509
+ token = _antTheme$useToken.token;
509
510
  var rootStyle = styles.root || {};
510
511
  if (table !== null && table !== void 0 && table.bordered) {
511
512
  rootStyle = _objectSpread({
@@ -515,11 +516,14 @@ var InternalProTable = function InternalProTable(props) {
515
516
  }
516
517
  var onFullScreen = function onFullScreen(isFull) {
517
518
  var _ref4 = containerRef.current || {},
518
- classList = _ref4.classList;
519
+ classList = _ref4.classList,
520
+ style = _ref4.style;
519
521
  if (isFull) {
520
522
  classList === null || classList === void 0 || classList.add('css-table-full');
523
+ style.backgroundColor = token.colorBgContainer;
521
524
  } else {
522
525
  classList === null || classList === void 0 || classList.remove('css-table-full');
526
+ style.backgroundColor = 'transparent';
523
527
  }
524
528
  };
525
529
  return /*#__PURE__*/_jsxs("div", {
@@ -528,11 +532,7 @@ var InternalProTable = function InternalProTable(props) {
528
532
  overflow: (table === null || table === void 0 || (_table$scroll2 = table.scroll) === null || _table$scroll2 === void 0 ? void 0 : _table$scroll2.y) === 'auto' ? 'hidden' : 'unset'
529
533
  }),
530
534
  ref: containerRef,
531
- children: [watermark && /*#__PURE__*/_jsx(WaterMarkRelative, {
532
- content: watermark,
533
- fontColor: "rgba(0,0,0,.15)",
534
- zIndex: 105
535
- }), !(!formItems.length && !toolbar) && isAuth && /*#__PURE__*/_jsx(HeadComponent, {
535
+ children: [!(!formItems.length && !toolbar) && isAuth && /*#__PURE__*/_jsx(HeadComponent, {
536
536
  form: form,
537
537
  toolbar: newToolbar,
538
538
  formItems: formItems,
@@ -5,7 +5,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
5
5
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
7
  import { useUpdateEffect } from 'ahooks';
8
- import { theme } from 'antd';
8
+ import { theme as antTheme } from 'antd';
9
9
  import update from 'immutability-helper';
10
10
  import { cloneElement, useState } from 'react';
11
11
  import { TabsContext } from "../context";
@@ -40,15 +40,15 @@ export default (function (_ref) {
40
40
  }, [items === null || items === void 0 ? void 0 : items.map(function (t) {
41
41
  return t.key;
42
42
  }).join(',')]);
43
- var _theme$useToken = theme.useToken(),
44
- token = _theme$useToken.token;
43
+ var _antTheme$useToken = antTheme.useToken(),
44
+ token = _antTheme$useToken.token;
45
45
  var addOptions = {
46
46
  items: tabsProps.items,
47
47
  className: 'ccs-tabs',
48
48
  tabBarStyle: {
49
49
  margin: 0,
50
50
  paddingLeft: 16,
51
- backgroundColor: token._appTheme === 'dark' ? token.colorBgContainer : '#fff'
51
+ backgroundColor: token.colorBgContainer
52
52
  }
53
53
  };
54
54
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ccs-ui/rc-pro",
3
- "version": "2.0.8",
3
+ "version": "2.1.0",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "author": {