@ccs-ui/rc-pro 1.2.1-beta-4 → 2.0.1

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 (45) hide show
  1. package/es/auth/auth-button.d.ts +3 -1
  2. package/es/auth/auth-button.js +40 -5
  3. package/es/auth/index.d.ts +2 -1
  4. package/es/ccs.d.ts +27 -66
  5. package/es/color-picker/index.d.ts +2 -4
  6. package/es/config.d.ts +5 -3
  7. package/es/config.js +98 -9
  8. package/es/context/index.d.ts +13 -9
  9. package/es/context/index.js +2 -2
  10. package/es/dialog/DialogRequestButton.d.ts +1 -1
  11. package/es/dialog/DialogSelfOkButton.d.ts +1 -1
  12. package/es/dialog/button.d.ts +3 -3
  13. package/es/dialog/drawer-footer.d.ts +2 -3
  14. package/es/dialog/hook.d.ts +4 -0
  15. package/es/dialog/hook.js +13 -7
  16. package/es/editor/index.d.ts +2 -4
  17. package/es/hooks/use-app.d.ts +6 -0
  18. package/es/hooks/use-app.js +15 -0
  19. package/es/index.d.ts +2 -3
  20. package/es/index.js +2 -3
  21. package/es/layout-keep-alive/index.d.ts +1 -1
  22. package/es/layout-keep-alive/index.js +14 -18
  23. package/es/layout-keep-alive/page.d.ts +1 -0
  24. package/es/layout-single-page/index.d.ts +1 -1
  25. package/es/layout-single-page/index.js +7 -23
  26. package/es/pro-grid/index.d.ts +4 -9
  27. package/es/pro-table/head.d.ts +2 -2
  28. package/es/pro-table/index.less +0 -27
  29. package/es/pro-table/table.d.ts +8 -16
  30. package/es/pro-table/table.js +6 -33
  31. package/es/result/index.js +3 -1
  32. package/es/trigger/index.d.ts +2 -8
  33. package/es/upload/index.d.ts +4 -3
  34. package/es/upload/index.js +48 -10
  35. package/es/upload/upload-image.d.ts +1 -1
  36. package/es/upload/upload-image.js +50 -16
  37. package/es/virtual-list/index.d.ts +3 -4
  38. package/es/water-mark/index.d.ts +3 -10
  39. package/package.json +5 -6
  40. package/es/hooks/use-global.d.ts +0 -4
  41. package/es/hooks/use-global.js +0 -10
  42. package/es/pro-table/search.d.ts +0 -17
  43. package/es/pro-table/search.js +0 -312
  44. package/es/theme.d.ts +0 -12
  45. package/es/theme.js +0 -66
@@ -7,6 +7,8 @@ type CcsAuthButtonProps = Omit<ButtonProps, 'onClick'> & {
7
7
  text?: string;
8
8
  /** 二次确认消息 */
9
9
  confirm?: string;
10
+ /** 输入确认的值 */
11
+ inputConfirm?: string;
10
12
  /** 点击事件 */
11
13
  onClick?: (e: React.MouseEvent<HTMLElement, MouseEvent>, selectedRows?: any[]) => void;
12
14
  /** 按钮禁用方法 */
@@ -17,5 +19,5 @@ type CcsAuthButtonProps = Omit<ButtonProps, 'onClick'> & {
17
19
  * @param CcsAuthButtonProps
18
20
  * @returns
19
21
  */
20
- declare const _default: ({ auth, text, confirm, disabled, onClick, onDisabled, ...restProps }: CcsAuthButtonProps) => import("react/jsx-runtime").JSX.Element;
22
+ declare const _default: ({ auth, text, confirm, disabled, inputConfirm, onClick, onDisabled, ...restProps }: CcsAuthButtonProps) => import("react/jsx-runtime").JSX.Element;
21
23
  export default _default;
@@ -1,5 +1,5 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- var _excluded = ["auth", "text", "confirm", "disabled", "onClick", "onDisabled"];
2
+ var _excluded = ["auth", "text", "confirm", "disabled", "inputConfirm", "onClick", "onDisabled"];
3
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
5
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -8,14 +8,14 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
8
8
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
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 { ExclamationCircleOutlined } from '@ant-design/icons';
11
- import { Button } from 'antd';
11
+ import { Button, Input } from 'antd';
12
12
  import { useContext, useRef } from 'react';
13
13
  import { ModalConfirm } from '.';
14
14
  import { useCcsPage } from "../";
15
15
  import { TableSelectionContext } from "../pro-table/table";
16
16
  import { jsx as _jsx } from "react/jsx-runtime";
17
- import { jsxs as _jsxs } from "react/jsx-runtime";
18
17
  import { Fragment as _Fragment } from "react/jsx-runtime";
18
+ import { jsxs as _jsxs } from "react/jsx-runtime";
19
19
  /**
20
20
  * 带权限的按钮组件、继承Ant Button所有属性
21
21
  * @param CcsAuthButtonProps
@@ -26,6 +26,7 @@ export default (function (_ref) {
26
26
  text = _ref.text,
27
27
  confirm = _ref.confirm,
28
28
  disabled = _ref.disabled,
29
+ inputConfirm = _ref.inputConfirm,
29
30
  _onClick = _ref.onClick,
30
31
  onDisabled = _ref.onDisabled,
31
32
  restProps = _objectWithoutProperties(_ref, _excluded);
@@ -34,6 +35,7 @@ export default (function (_ref) {
34
35
  var modalRef = useRef(null);
35
36
  var _ref3 = useContext(TableSelectionContext) || {},
36
37
  selectedRows = _ref3.selectedRows;
38
+ var ref = useRef(null);
37
39
  var button = /*#__PURE__*/_jsxs(Button, _objectSpread(_objectSpread({}, restProps), {}, {
38
40
  onClick: function onClick(e) {
39
41
  if (!_onClick) return;
@@ -43,11 +45,44 @@ export default (function (_ref) {
43
45
  title: '操作确认',
44
46
  icon: /*#__PURE__*/_jsx(ExclamationCircleOutlined, {}),
45
47
  centered: true,
46
- content: confirm,
48
+ content: /*#__PURE__*/_jsxs(_Fragment, {
49
+ children: [confirm, inputConfirm && /*#__PURE__*/_jsx(Input, {
50
+ ref: ref,
51
+ placeholder: "\u8BF7\u8F93\u5165",
52
+ style: {
53
+ marginTop: 5
54
+ },
55
+ onFocus: function onFocus() {
56
+ var errorDom = document.getElementById('_inputConfirmError');
57
+ if (errorDom) {
58
+ errorDom.innerHTML = '';
59
+ }
60
+ }
61
+ })]
62
+ }),
47
63
  okText: '确认',
48
64
  cancelText: '取消',
49
65
  onOk: function onOk() {
50
- return _onClick(e, selectedRows);
66
+ console.log('inputConfirm', inputConfirm);
67
+ if (inputConfirm) {
68
+ return new Promise(function (resolve, reject) {
69
+ var _ref$current;
70
+ if (((_ref$current = ref.current) === null || _ref$current === void 0 || (_ref$current = _ref$current.input) === null || _ref$current === void 0 ? void 0 : _ref$current.value) === inputConfirm) {
71
+ _onClick(e, selectedRows);
72
+ resolve(true);
73
+ } else {
74
+ var errorDom = document.getElementById('_inputConfirmError');
75
+ if (errorDom) {
76
+ errorDom.innerHTML = '输入验证失败!';
77
+ } else {
78
+ var _ref$current2;
79
+ (_ref$current2 = ref.current) === null || _ref$current2 === void 0 || (_ref$current2 = _ref$current2.input) === null || _ref$current2 === void 0 || (_ref$current2 = _ref$current2.parentElement) === null || _ref$current2 === void 0 || _ref$current2.insertAdjacentHTML('beforeend', '<span id="_inputConfirmError" style="color:red">输入验证失败!</span>');
80
+ }
81
+ reject(false);
82
+ }
83
+ });
84
+ }
85
+ _onClick(e, selectedRows);
51
86
  }
52
87
  });
53
88
  return;
@@ -30,10 +30,11 @@ export declare function ModalConfirm({ modalRef }: {
30
30
  declare function CcsAuth({ auth, children }: CcsAuthProps): ReactElement<any, string | import("react").JSXElementConstructor<any>> | null;
31
31
  declare namespace CcsAuth {
32
32
  var Group: typeof AuthGroup;
33
- var Button: ({ auth, text, confirm, disabled, onClick, onDisabled, ...restProps }: Omit<ButtonProps, "onClick"> & {
33
+ var Button: ({ auth, text, confirm, disabled, inputConfirm, onClick, onDisabled, ...restProps }: Omit<ButtonProps, "onClick"> & {
34
34
  auth: string;
35
35
  text?: string | undefined;
36
36
  confirm?: string | undefined;
37
+ inputConfirm?: string | undefined;
37
38
  onClick?: ((e: import("react").MouseEvent<HTMLElement, MouseEvent>, selectedRows?: any[] | undefined) => void) | undefined;
38
39
  onDisabled?: ((selectedRows?: any[] | undefined) => boolean) | undefined;
39
40
  }) => import("react/jsx-runtime").JSX.Element;
package/es/ccs.d.ts CHANGED
@@ -1,43 +1,22 @@
1
- import { ButtonProps, MenuProps, ThemeConfig } from 'antd';
1
+ import { ButtonProps } from 'antd';
2
2
  import { Rule } from 'antd/es/form';
3
- import { MutableRefObject, ReactElement, ReactNode } from 'react';
3
+ import { CSSProperties, MutableRefObject, ReactElement, ReactNode } from 'react';
4
4
  import { TableColumn } from './pro-table/table';
5
- type MenuTreeNodeData = {
6
- buttonUrlId: number;
7
- createTime: string;
8
- icon?: string;
9
- menuCode: string;
10
- menuDesc: string;
11
- menuName: string;
12
- menuType: number;
5
+ type MenuType = {
6
+ /** 菜单ID */
7
+ menuId: string;
8
+ /** 菜单路由 */
13
9
  menuUrl: string;
14
- parentMenuCode: string;
15
- sortId: number;
16
- state: number;
17
- updateTime: string;
18
- urlName: string;
19
- urlPath: string;
20
- };
21
- type MenuParentType = {
22
- key: string;
23
- url: string;
24
- name: string;
25
- };
26
- type MenuTreeNode = {
27
- nodeId: string;
28
- nodeName: string;
29
- icon: string;
30
- leaf: boolean;
31
- nodeData: MenuTreeNodeData;
32
- children?: MenuTreeNode[];
33
- topUrl?: string;
34
- parents?: MenuParentType[];
35
- };
36
- type UserDetail = {
37
- /** 头像 */
38
- avatar?: string;
39
- /** 用户名 */
40
- workerName: string;
10
+ /** 菜单名称 */
11
+ menuName: string;
12
+ /** 面包屑数据 */
13
+ breadcrumb?: {
14
+ key: any;
15
+ title: string;
16
+ href?: string;
17
+ }[];
18
+ /** 菜单URL权限 */
19
+ urlAuthList?: string[];
41
20
  };
42
21
  type TableData<T> = {
43
22
  /** loading */
@@ -184,8 +163,6 @@ export type TableFormItem = {
184
163
  name: string;
185
164
  /** form item element */
186
165
  value: ReactElement;
187
- /** @deprecated 主条件 */
188
- isMain?: boolean;
189
166
  /** 数据依赖、依赖项对应的name数组 */
190
167
  depends?: string[];
191
168
  /** 显示依赖 */
@@ -195,33 +172,17 @@ export type TableFormItem = {
195
172
  /** 格式化值 */
196
173
  onFormat?: (e: any) => any;
197
174
  };
198
- type GlobalConfig = {
199
- /** 项目名称 */
200
- AppName: string;
201
- /** 主题 */
202
- AppTheme: 'light' | 'dark' | 'colorful';
203
- /** ant组件配置 */
204
- AppThemeConfig: ThemeConfig;
205
- /** 菜单展开模式 */
206
- MenuExpandMode: MenuProps['mode'];
207
- /** 菜单展开宽度 */
208
- MenuExpandWidth: number;
209
- /** 菜单收起宽度 */
210
- MenuCollapsedWidth: number;
211
- /** http 请求通用前缀 */
212
- Api: string;
213
- /** 路由上下文 */
214
- Context: string;
215
- /** 图片上传地址 */
216
- UploadUrl?: string;
217
- /** 图片下载地址 */
218
- DownloadUrl?: string;
219
- /** 允许改变主题 */
220
- AllowChangeTheme?: boolean;
221
- /** 布局模式、single:单页,tabs:缓存页面 */
222
- layoutMode?: 'tabs' | 'single';
223
- };
224
175
  type TableFormItems = TableFormItem[];
225
176
  type TableInstanceRef<T = any> = MutableRefObject<TableInstance<T> | undefined> | React.RefObject<TableInstance<T>>;
226
177
  type TableColumns<RecordType = any> = TableColumn<RecordType>[];
227
- export type { AuthButtonItem, GlobalConfig, HttpListResult, HttpPageResult, HttpResult, ListQuery, MenuTreeNode, MenuTreeNodeData, PageQuery, PageType, RecordType, RouteHistory, TableColumns, TableData, TableFormItems, TableInstance, TableInstanceRef, TriggerChildrenProps, UserDetail, };
178
+ type PropsWithCss = {
179
+ style?: CSSProperties;
180
+ className?: string;
181
+ };
182
+ type PropsWithNodeChildren = {
183
+ children?: ReactNode;
184
+ };
185
+ type PropsWithElementChildren = {
186
+ children?: ReactElement;
187
+ };
188
+ export type { AuthButtonItem, HttpListResult, HttpPageResult, HttpResult, ListQuery, MenuType, PageQuery, PageType, PropsWithCss, PropsWithElementChildren, PropsWithNodeChildren, RecordType, RouteHistory, TableColumns, TableData, TableFormItems, TableInstance, TableInstanceRef, TriggerChildrenProps, };
@@ -1,13 +1,11 @@
1
- import { CSSProperties } from 'react';
2
1
  import { RGBColor } from 'react-color';
2
+ import { PropsWithCss } from '../ccs';
3
3
  import './index.less';
4
- export type PropsType = {
4
+ export type PropsType = PropsWithCss & {
5
5
  /** 指定选中项 */
6
6
  value?: RGBColor;
7
7
  /** 占位 */
8
8
  placeholder?: string;
9
- /** 内部样式 */
10
- style?: CSSProperties;
11
9
  /** 选择完成后的回调 */
12
10
  onChange?: (value: RGBColor) => void;
13
11
  };
package/es/config.d.ts CHANGED
@@ -1,3 +1,5 @@
1
- import { GlobalContextPropsType } from './context';
2
- declare const _default: ({ userDetail, children }: GlobalContextPropsType) => import("react/jsx-runtime").JSX.Element;
3
- export default _default;
1
+ import { PropsWithElementChildren } from './ccs';
2
+ import { CssAppConfigType } from './context';
3
+ type AppConfigProps = PropsWithElementChildren & CssAppConfigType;
4
+ export default function CssAppConfig(props: AppConfigProps): import("react/jsx-runtime").JSX.Element;
5
+ export {};
package/es/config.js CHANGED
@@ -1,12 +1,101 @@
1
- import { GlobalContext } from "./context";
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
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
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
+ import { darkTheme, defaultTheme } from '@ant-design/compatible';
14
+ import { App, ConfigProvider, message, Modal, notification } from 'antd';
15
+ import zhCN from 'antd/locale/zh_CN';
16
+ import React, { useState } from 'react';
17
+ import { AppConfigContext } from "./context";
18
+ import usePatchElement from "./dialog/usePatchElement";
19
+ import ThemeDialog from "./theme-dialog";
20
+ import { Fragment as _Fragment } from "react/jsx-runtime";
2
21
  import { jsx as _jsx } from "react/jsx-runtime";
3
- export default (function (_ref) {
4
- var userDetail = _ref.userDetail,
5
- children = _ref.children;
6
- return /*#__PURE__*/_jsx(GlobalContext.Provider, {
7
- value: {
8
- userDetail: userDetail
22
+ import { jsxs as _jsxs } from "react/jsx-runtime";
23
+ var ElementsHolder = /*#__PURE__*/React.memo( /*#__PURE__*/React.forwardRef(function (_props, ref) {
24
+ var _usePatchElement = usePatchElement(),
25
+ _usePatchElement2 = _slicedToArray(_usePatchElement, 2),
26
+ elements = _usePatchElement2[0],
27
+ patchElement = _usePatchElement2[1];
28
+ React.useImperativeHandle(ref, function () {
29
+ return {
30
+ patchElement: patchElement
31
+ };
32
+ }, []);
33
+ // eslint-disable-next-line react/jsx-no-useless-fragment
34
+ return /*#__PURE__*/_jsx(_Fragment, {
35
+ children: elements
36
+ });
37
+ }));
38
+ function AppDialog() {
39
+ var _message$useMessage = message.useMessage(),
40
+ _message$useMessage2 = _slicedToArray(_message$useMessage, 2),
41
+ messageApi = _message$useMessage2[0],
42
+ contextMsgHolder = _message$useMessage2[1];
43
+ var _notification$useNoti = notification.useNotification(),
44
+ _notification$useNoti2 = _slicedToArray(_notification$useNoti, 2),
45
+ noticeApi = _notification$useNoti2[0],
46
+ contextNotifHolder = _notification$useNoti2[1];
47
+ var _Modal$useModal = Modal.useModal(),
48
+ _Modal$useModal2 = _slicedToArray(_Modal$useModal, 2),
49
+ modalApi = _Modal$useModal2[0],
50
+ contextModalHolder = _Modal$useModal2[1];
51
+ useState(function () {
52
+ ThemeDialog.setConfig(messageApi, noticeApi, modalApi);
53
+ });
54
+ return /*#__PURE__*/_jsxs(_Fragment, {
55
+ children: [contextMsgHolder, contextNotifHolder, contextModalHolder]
56
+ });
57
+ }
58
+
59
+ /** 主题设置 */
60
+ function AppConfig(_ref) {
61
+ var children = _ref.children,
62
+ _ref$theme = _ref.theme,
63
+ theme = _ref$theme === void 0 ? 'light' : _ref$theme,
64
+ themeConfig = _ref.themeConfig;
65
+ var holderRef = React.useRef(null);
66
+ // 主题
67
+ var appTheme = theme === 'dark' ? darkTheme : defaultTheme;
68
+
69
+ // 合并token
70
+ var token = _objectSpread(_objectSpread(_objectSpread({}, appTheme.token), themeConfig === null || themeConfig === void 0 ? void 0 : themeConfig.token), {}, {
71
+ _appTheme: theme
72
+ });
73
+
74
+ // 暗黑模式背景色
75
+ if (theme === 'dark') token.colorBgContainer = 'rgb(36, 37, 37)';
76
+ return /*#__PURE__*/_jsx(ConfigProvider, {
77
+ locale: zhCN,
78
+ theme: _objectSpread(_objectSpread({}, appTheme), {}, {
79
+ token: token,
80
+ components: _objectSpread(_objectSpread({}, appTheme.components), themeConfig === null || themeConfig === void 0 ? void 0 : themeConfig.components)
81
+ }),
82
+ children: /*#__PURE__*/_jsxs(AppConfigContext.Provider, {
83
+ value: {
84
+ theme: theme,
85
+ themeConfig: themeConfig,
86
+ holderRef: holderRef
87
+ },
88
+ children: [children, /*#__PURE__*/_jsx(AppDialog, {}), /*#__PURE__*/_jsx(ElementsHolder, {
89
+ ref: holderRef
90
+ }, "modal-drawer-holder")]
91
+ })
92
+ });
93
+ }
94
+ export default function CssAppConfig(props) {
95
+ return /*#__PURE__*/_jsx(App, {
96
+ style: {
97
+ height: '100%'
9
98
  },
10
- children: children
99
+ children: /*#__PURE__*/_jsx(AppConfig, _objectSpread({}, props))
11
100
  });
12
- });
101
+ }
@@ -1,8 +1,9 @@
1
- import { TabPaneProps } from 'antd';
1
+ import { TabPaneProps, ThemeConfig } from 'antd';
2
2
  import { Store } from 'antd/es/form/interface';
3
3
  import React from 'react';
4
4
  import { Location } from 'react-router';
5
5
  import CCS from '..';
6
+ import { ElementsHolderRef } from '../dialog/hook';
6
7
  type CcsTabsChangeProps = {
7
8
  /** 当前激活tab面板的key */
8
9
  activeKey?: string;
@@ -41,19 +42,22 @@ type PageContextType = {
41
42
  /** 获取按钮权限 */
42
43
  onAuth: (code: string) => boolean;
43
44
  };
44
- type GlobalContextPropsType = {
45
- userDetail: CCS.UserDetail;
46
- children: React.ReactElement;
47
- };
48
- type GlobalContextType = Omit<GlobalContextPropsType, 'children'>;
49
45
  type FnContextType<T = Store> = {
50
46
  locationKey: string;
51
47
  formInitialValues: T;
52
48
  close: () => void;
53
49
  };
54
- declare const GlobalContext: React.Context<GlobalContextType>;
50
+ type CssAppConfigType = {
51
+ /** 主题 */
52
+ theme?: 'dark' | 'light' | 'colorful';
53
+ /** 主题参数配置 */
54
+ themeConfig?: ThemeConfig;
55
+ /** modal or drawer holder */
56
+ holderRef?: React.RefObject<ElementsHolderRef>;
57
+ };
55
58
  declare const DrawerAndModalContext: React.Context<FnContextType<any>>;
56
59
  declare const PageContext: React.Context<PageContextType>;
57
60
  declare const TabsContext: React.Context<CcsTabsContextType>;
58
- export { DrawerAndModalContext, GlobalContext, PageContext, TabsContext };
59
- export type { CcsTabsChangeProps, CcsTabsContextType, FnContextType, GlobalContextPropsType, };
61
+ declare const AppConfigContext: React.Context<CssAppConfigType>;
62
+ export { AppConfigContext, DrawerAndModalContext, PageContext, TabsContext };
63
+ export type { CcsTabsChangeProps, CcsTabsContextType, CssAppConfigType, FnContextType, };
@@ -1,6 +1,6 @@
1
1
  import React, { createContext } from 'react';
2
- var GlobalContext = /*#__PURE__*/createContext({});
3
2
  var DrawerAndModalContext = /*#__PURE__*/createContext({});
4
3
  var PageContext = /*#__PURE__*/createContext({});
5
4
  var TabsContext = /*#__PURE__*/React.createContext({});
6
- export { DrawerAndModalContext, GlobalContext, PageContext, TabsContext };
5
+ var AppConfigContext = /*#__PURE__*/React.createContext({});
6
+ export { AppConfigContext, DrawerAndModalContext, PageContext, TabsContext };
@@ -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, "onCancel" | "auth" | "request" | "extraBtn" | "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" | "onCancel" | "onOk" | "extraBtn"> & {
4
+ declare const DialogSelfOkButton: ({ auth, formRef, extraBtn, formInitialValues, onCancel, onOk, }: Pick<CcsDialogModalProps, "onCancel" | "auth" | "extraBtn" | "onOk"> & {
5
5
  formRef: React.RefObject<DialogFormRef>;
6
6
  formInitialValues: FormProps['initialValues'];
7
7
  }) => import("react/jsx-runtime").JSX.Element;
@@ -1,9 +1,9 @@
1
- import React, { ReactNode } from 'react';
1
+ import React from 'react';
2
+ import { PropsWithNodeChildren } from '../ccs';
2
3
  import { CcsDialogModalProps } from './hook';
3
- export type DialogButtonsProps = Pick<CcsDialogModalProps, 'okText' | 'onCancel' | 'cancelText' | 'onOk'> & {
4
+ export type DialogButtonsProps = Pick<CcsDialogModalProps, 'okText' | 'onCancel' | 'cancelText' | 'onOk'> & PropsWithNodeChildren & {
4
5
  okAuth?: string;
5
6
  loading?: boolean;
6
- children?: ReactNode;
7
7
  hideCancel?: boolean;
8
8
  };
9
9
  export type DialogButtonRef = {
@@ -1,10 +1,9 @@
1
- import { ReactNode } from 'react';
2
- type DialogButtonsProps = {
1
+ import { PropsWithNodeChildren } from '../ccs';
2
+ type DialogButtonsProps = PropsWithNodeChildren & {
3
3
  okText?: string;
4
4
  cancelText?: string;
5
5
  okAuth?: string;
6
6
  loading?: boolean;
7
- children?: ReactNode;
8
7
  hideCancel?: boolean;
9
8
  onOk?: (values?: any) => void;
10
9
  };
@@ -1,5 +1,6 @@
1
1
  import { DrawerProps, FormProps, ModalFuncProps } from 'antd';
2
2
  import React, { ReactNode } from 'react';
3
+ import usePatchElement from './usePatchElement';
3
4
  export type CcsDialogModal = {
4
5
  destroy: () => void;
5
6
  update: (config: CcsDialogModalProps) => void;
@@ -59,5 +60,8 @@ export type CcsDialogType = {
59
60
  openModal: (props: CcsDialogModalProps) => ReturnType<ModalDialog>;
60
61
  contextHolder: React.JSX.Element;
61
62
  };
63
+ export type ElementsHolderRef = {
64
+ patchElement: ReturnType<typeof usePatchElement>[1];
65
+ };
62
66
  export default function useCcsDialog(): CcsDialogType;
63
67
  export {};
package/es/dialog/hook.js CHANGED
@@ -13,6 +13,7 @@ import CcsUtils from '@ccs-ui/utils';
13
13
  import _debounce from 'lodash.debounce';
14
14
  import React from 'react';
15
15
  import { createRoot } from 'react-dom/client';
16
+ import useAppConfig from "../hooks/use-app";
16
17
  import HookDrawer from "./HookDrawer";
17
18
  import HookModal from "./HookModal";
18
19
  import usePatchElement from "./usePatchElement";
@@ -44,6 +45,7 @@ export default function useCcsDialog() {
44
45
  _React$useState2 = _slicedToArray(_React$useState, 2),
45
46
  actionQueue = _React$useState2[0],
46
47
  setActionQueue = _React$useState2[1];
48
+ var appConfig = useAppConfig() || {};
47
49
  React.useEffect(function () {
48
50
  if (actionQueue.length) {
49
51
  var cloneQueue = _toConsumableArray(actionQueue);
@@ -68,11 +70,14 @@ export default function useCcsDialog() {
68
70
  },
69
71
  ref: modalRef
70
72
  }, "modal-".concat(modalUuid));
71
- if (holderRef.current) {
73
+
74
+ // 优先使用自定义contextHolder、其次使用全局contextHolder
75
+ var $holderRef = holderRef.current ? holderRef : appConfig.holderRef;
76
+ if ($holderRef !== null && $holderRef !== void 0 && $holderRef.current) {
72
77
  // 加载了contextHolder
73
- closeFunc = holderRef.current.patchElement(modal);
78
+ closeFunc = $holderRef.current.patchElement(modal);
74
79
  } else {
75
- CcsUtils.showWarning(true, "\u672A\u5C06contextHolder\u63D2\u5165\u7EC4\u4EF6\u4E2D\uFF0C\u5C06\u65E0\u6CD5\u9002\u914Dantd\u4E3B\u9898\u914D\u7F6E\u548C\u83B7\u53D6context\u3002");
80
+ CcsUtils.showWarning(false, "\u672A\u4F7F\u7528CssAppConfig\u5168\u5C40\u914D\u7F6E\u3001\u4E5F\u672A\u5C06contextHolder\u63D2\u5165\u7EC4\u4EF6\u4E2D\uFF0C\u5C06\u65E0\u6CD5\u9002\u914Dantd\u4E3B\u9898\u914D\u7F6E\u548C\u83B7\u53D6context\u3002");
76
81
  // 未加载contextHolder,创建dom
77
82
  var dialogEle = document.createElement('div');
78
83
  document.body.append(dialogEle);
@@ -131,12 +136,13 @@ export default function useCcsDialog() {
131
136
  },
132
137
  ref: modalRef
133
138
  }, "drawer-".concat(drawerUuid));
134
- if (holderRef.current) {
135
- var _holderRef$current;
139
+ var $holderRef = holderRef.current ? holderRef : appConfig.holderRef;
140
+ if ($holderRef !== null && $holderRef !== void 0 && $holderRef.current) {
141
+ var _$holderRef$current;
136
142
  // 加载了contextHolder
137
- closeFunc = (_holderRef$current = holderRef.current) === null || _holderRef$current === void 0 ? void 0 : _holderRef$current.patchElement(modal);
143
+ closeFunc = (_$holderRef$current = $holderRef.current) === null || _$holderRef$current === void 0 ? void 0 : _$holderRef$current.patchElement(modal);
138
144
  } else {
139
- CcsUtils.showWarning(true, "\u672A\u5C06contextHolder\u63D2\u5165\u7EC4\u4EF6\u4E2D\uFF0C\u5C06\u65E0\u6CD5\u9002\u914Dantd\u4E3B\u9898\u914D\u7F6E\u548C\u83B7\u53D6context\u3002");
145
+ CcsUtils.showWarning(false, "\u672A\u4F7F\u7528CssAppConfig\u5168\u5C40\u914D\u7F6E\u3001\u4E5F\u672A\u5C06contextHolder\u63D2\u5165\u7EC4\u4EF6\u4E2D\uFF0C\u5C06\u65E0\u6CD5\u9002\u914Dantd\u4E3B\u9898\u914D\u7F6E\u548C\u83B7\u53D6context\u3002");
140
146
  // 未加载contextHolder,创建dom
141
147
  var dialogEle = document.createElement('div');
142
148
  document.body.append(dialogEle);
@@ -1,13 +1,11 @@
1
1
  import { ReactCodeMirrorProps } from '@uiw/react-codemirror';
2
- import { CSSProperties } from 'react';
2
+ import { PropsWithCss } from '../ccs';
3
3
  import './index.less';
4
4
  import JavaScriptEditor from './javascript';
5
5
  import JsonEditor from './json';
6
6
  import SqlEditor from './sql';
7
- export type EditorPropsType = Omit<ReactCodeMirrorProps, 'height'> & {
7
+ export type EditorPropsType = PropsWithCss & Omit<ReactCodeMirrorProps, 'height'> & {
8
8
  value?: string;
9
- className?: string;
10
- style?: CSSProperties;
11
9
  placeholder?: string;
12
10
  bordered?: boolean;
13
11
  isPreview?: boolean;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * app配置
3
+ * @returns
4
+ */
5
+ declare const useAppConfig: () => import("../context").CssAppConfigType;
6
+ export default useAppConfig;
@@ -0,0 +1,15 @@
1
+ import { useContext } from 'react';
2
+ import { AppConfigContext } from "../context";
3
+
4
+ /**
5
+ * app配置
6
+ * @returns
7
+ */
8
+ var useAppConfig = function useAppConfig() {
9
+ var context = useContext(AppConfigContext);
10
+ if (context === undefined) {
11
+ throw new Error('AppConfigContext not found');
12
+ }
13
+ return context;
14
+ };
15
+ export default useAppConfig;
package/es/index.d.ts CHANGED
@@ -2,13 +2,13 @@ export { default as CcsAjCaptcha } from './aj-captcha';
2
2
  export { default as CcsAuth } from './auth';
3
3
  export { default as CcsApiCascader } from './cascader';
4
4
  export { default as CcsColorPicker } from './color-picker';
5
- export { default as CcsConfigProvider } from './config';
5
+ export { default as CcsAppConfig } from './config';
6
6
  export { default as CcsDatePicker } from './date-picker';
7
7
  export { default as CcsDialog } from './dialog';
8
8
  export { default as CcsEditor } from './editor';
9
9
  export { default as CcsLinesEllipsis } from './ellipsis';
10
10
  export { default as CcsFullScreenButton } from './full-screen';
11
- export { default as useCcsGlobal } from './hooks/use-global';
11
+ export { default as useAppConfig } from './hooks/use-app';
12
12
  export { default as useCcsOnceEvent } from './hooks/use-once-event';
13
13
  export { default as useCcsPage } from './hooks/use-page';
14
14
  export { default as useCcsTabs } from './hooks/use-tabs';
@@ -25,7 +25,6 @@ export { default as CcsResult } from './result';
25
25
  export { default as CcsApiSelect } from './select';
26
26
  export { default as CcsStatusTag } from './status-tag';
27
27
  export { default as CcsTable } from './table';
28
- export { default as CcsAppTheme } from './theme';
29
28
  export { default as CcsTimePicker } from './time-picker';
30
29
  export { default as CcsTrigger } from './trigger';
31
30
  export { default as CcsUpload } from './upload';
package/es/index.js CHANGED
@@ -2,13 +2,13 @@ export { default as CcsAjCaptcha } from "./aj-captcha";
2
2
  export { default as CcsAuth } from "./auth";
3
3
  export { default as CcsApiCascader } from "./cascader";
4
4
  export { default as CcsColorPicker } from "./color-picker";
5
- export { default as CcsConfigProvider } from "./config";
5
+ export { default as CcsAppConfig } from "./config";
6
6
  export { default as CcsDatePicker } from "./date-picker";
7
7
  export { default as CcsDialog } from "./dialog";
8
8
  export { default as CcsEditor } from "./editor";
9
9
  export { default as CcsLinesEllipsis } from "./ellipsis";
10
10
  export { default as CcsFullScreenButton } from "./full-screen";
11
- export { default as useCcsGlobal } from "./hooks/use-global";
11
+ export { default as useAppConfig } from "./hooks/use-app";
12
12
  export { default as useCcsOnceEvent } from "./hooks/use-once-event";
13
13
  export { default as useCcsPage } from "./hooks/use-page";
14
14
  export { default as useCcsTabs } from "./hooks/use-tabs";
@@ -25,7 +25,6 @@ export { default as CcsResult } from "./result";
25
25
  export { default as CcsApiSelect } from "./select";
26
26
  export { default as CcsStatusTag } from "./status-tag";
27
27
  export { default as CcsTable } from "./table";
28
- export { default as CcsAppTheme } from "./theme";
29
28
  export { default as CcsTimePicker } from "./time-picker";
30
29
  export { default as CcsTrigger } from "./trigger";
31
30
  export { default as CcsUpload } from "./upload";
@@ -3,7 +3,7 @@ import './index.less';
3
3
  type PropsType = {
4
4
  maxLen?: number;
5
5
  appName: string;
6
- menus: CCS.MenuTreeNode[];
6
+ menus: CCS.MenuType[];
7
7
  className?: string;
8
8
  history: any;
9
9
  };