@ccs-ui/rc-pro 1.1.12 → 1.1.14

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/ccs.d.ts ADDED
@@ -0,0 +1,209 @@
1
+ import { ButtonProps, MenuProps, ThemeConfig } from 'antd';
2
+ import { Rule } from 'antd/es/form';
3
+ import { ColumnGroupType, ColumnType } from 'antd/es/table';
4
+ import { MutableRefObject, ReactElement, ReactNode } from 'react';
5
+ type MenuTreeNodeData = {
6
+ buttonUrlId: number;
7
+ createTime: string;
8
+ icon?: string;
9
+ menuCode: string;
10
+ menuDesc: string;
11
+ menuName: string;
12
+ menuType: number;
13
+ 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;
41
+ };
42
+ type TableData<T> = {
43
+ /** loading */
44
+ loading?: boolean;
45
+ /** 总条数 */
46
+ totalNum?: number;
47
+ /** 单页记录数 */
48
+ pageSize?: number;
49
+ /** 页码 */
50
+ pageNo?: number;
51
+ /** Array List 数据 */
52
+ result?: T[];
53
+ };
54
+ type HttpResult<T = any> = {
55
+ code: string;
56
+ success: boolean;
57
+ data: T;
58
+ msg: string;
59
+ };
60
+ type PageType<T> = {
61
+ hasNext: boolean;
62
+ totalNum: number;
63
+ pageNo: number;
64
+ pageSize: number;
65
+ result: T[];
66
+ };
67
+ type HttpPageResult<T = any> = Omit<HttpResult<T>, 'data'> & {
68
+ data: PageType<T>;
69
+ };
70
+ type HttpListResult<T = any> = Omit<HttpResult<T>, 'data'> & {
71
+ data: T[];
72
+ };
73
+ type OrderProp = {
74
+ ascending: boolean;
75
+ prop: string;
76
+ };
77
+ type QueryLimit = {
78
+ fetchSize: number;
79
+ startIndex: number;
80
+ };
81
+ type PageQuery<T = any> = {
82
+ /** 查询的开始行数和取多少行,从0开始 */
83
+ limit?: QueryLimit;
84
+ /** 排序字段,一般前端不传,由后端指定 */
85
+ orderProps?: OrderProp[];
86
+ /** 页码 */
87
+ pageNo?: number;
88
+ /** 页长 */
89
+ pageSize?: number;
90
+ /** 查询条件 */
91
+ query: T;
92
+ };
93
+ type ListQuery<T = any> = {
94
+ /** 查询的开始行数和取多少行,从0开始 */
95
+ limit?: QueryLimit;
96
+ /** 排序字段,一般前端不传,由后端指定 */
97
+ orderProps?: OrderProp[];
98
+ /** 查询条件 */
99
+ query: T;
100
+ };
101
+ type RecordType = Record<string, any>;
102
+ type RouteHistory = {
103
+ menuName: string;
104
+ pathName: string;
105
+ time: Date;
106
+ };
107
+ type TableDataType<T> = {
108
+ /** loading */
109
+ loading?: boolean;
110
+ /** 总条数 */
111
+ totalNum?: number;
112
+ /** 单页记录数 */
113
+ pageSize?: number;
114
+ /** 页码 */
115
+ pageNo?: number;
116
+ /** Array List 数据 */
117
+ result?: T[];
118
+ };
119
+ type TableInstance<T = any> = {
120
+ /** 获取form表单数据 */
121
+ formValues: Record<string, any>;
122
+ /** 获取当前表单数据 */
123
+ data: TableDataType<T>;
124
+ /** 查询数据,根据条件,从第一页开始显示 */
125
+ onSearch: () => void;
126
+ /** 刷新数据、根据条件,当前页 */
127
+ onReload: () => void;
128
+ /** 异步树、局部刷新方法 */
129
+ onPartialReload: (id: React.Key) => void;
130
+ /** 重置数据,清空选择 */
131
+ onReset: () => void;
132
+ /** 改变data 数据 */
133
+ onChangeData: React.Dispatch<React.SetStateAction<TableDataType<T>>>;
134
+ };
135
+ type AuthButtonItem = {
136
+ key: string;
137
+ label: string;
138
+ auth?: string;
139
+ type?: ButtonProps['type'];
140
+ disabled?: boolean;
141
+ hidden?: boolean;
142
+ danger?: boolean;
143
+ icon?: ReactNode;
144
+ confirm?: string;
145
+ };
146
+ type TriggerChildrenProps<T = any> = {
147
+ /** 选中值 */
148
+ value?: T;
149
+ /** 选择框loading状态 */
150
+ onLoading?: (loading: boolean) => void;
151
+ /** 关闭弹框 */
152
+ onVisible?: (visible: boolean) => void;
153
+ /** 选中值改变事件 */
154
+ onChange?: ({}: T) => void;
155
+ /** 选择框显示名称 */
156
+ onChangeLabel?: (text: string | undefined) => void;
157
+ };
158
+ type ShowDependType = {
159
+ name: string;
160
+ value: any;
161
+ };
162
+ type TableFormItem = {
163
+ /** label 标题 */
164
+ label?: string;
165
+ /** form name */
166
+ name: string;
167
+ /** form item element */
168
+ value: ReactElement;
169
+ /** 主条件 */
170
+ isMain?: boolean;
171
+ /** 数据依赖、依赖项对应的name数组 */
172
+ depends?: string[];
173
+ /** 显示依赖 */
174
+ showDepends?: ShowDependType[];
175
+ /** 必填规则 */
176
+ rules?: Rule[];
177
+ /** 格式化值 */
178
+ onFormat?: (e: any) => any;
179
+ };
180
+ type GlobalConfig = {
181
+ /** 项目名称 */
182
+ AppName: string;
183
+ /** 主题 */
184
+ AppTheme: 'default' | 'dark';
185
+ /** ant组件配置 */
186
+ AppThemeConfig: ThemeConfig;
187
+ /** 菜单展开模式 */
188
+ MenuExpandMode: MenuProps['mode'];
189
+ /** 菜单展开宽度 */
190
+ MenuExpandWidth: number;
191
+ /** 菜单收起宽度 */
192
+ MenuCollapsedWidth: number;
193
+ /** tabs缓存页 */
194
+ IsTabsPage: boolean;
195
+ /** http 请求通用前缀 */
196
+ Api: string;
197
+ /** 路由上下文 */
198
+ Context: string;
199
+ /** 图片上传地址 */
200
+ UploadUrl?: string;
201
+ /** 图片下载地址 */
202
+ DownloadUrl?: string;
203
+ };
204
+ type TableFormItems = TableFormItem[];
205
+ type TableInstanceRef<T = any> = MutableRefObject<TableInstance<T> | undefined> | React.RefObject<TableInstance<T>>;
206
+ type TableColumns<RecordType = any> = ((ColumnGroupType<RecordType> | ColumnType<RecordType>) & {
207
+ hidden?: boolean;
208
+ })[];
209
+ export type { PageType, RecordType, MenuTreeNode, PageQuery, ListQuery, HttpResult, GlobalConfig, HttpListResult, HttpPageResult, AuthButtonItem, MenuTreeNodeData, UserDetail, RouteHistory, TableData, TableFormItems, TableColumns, TableInstance, TableInstanceRef, TriggerChildrenProps, };
@@ -2,7 +2,7 @@
2
2
  import { FormProps } from 'antd';
3
3
  import { DialogFormRef } from './form';
4
4
  import { CcsDialogModal, CcsDialogModalProps } from './hook';
5
- export declare const DialogSelfButton: ({ auth, formRef, formInitialValues, request, onCancel, onRequestBefore, }: Pick<CcsDialogModalProps, "auth" | "request" | "onRequestBefore" | "onCancel"> & {
5
+ export declare const DialogSelfButton: ({ auth, formRef, formInitialValues, request, onCancel, onRequestBefore, }: Pick<CcsDialogModalProps, "request" | "auth" | "onRequestBefore" | "onCancel"> & {
6
6
  formRef: React.RefObject<DialogFormRef>;
7
7
  formInitialValues: FormProps['initialValues'];
8
8
  }) => import("react/jsx-runtime").JSX.Element;
@@ -10,7 +10,7 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
10
10
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
11
11
  import { MoreOutlined } from '@ant-design/icons';
12
12
  import { useUpdate, useUpdateEffect } from 'ahooks';
13
- import { Button, Dropdown, Empty, Tabs } from 'antd';
13
+ import { Button, Dropdown, Empty, Tabs, theme } from 'antd';
14
14
  import classnames from 'classnames';
15
15
  import _debounce from 'lodash/debounce';
16
16
  import ResizeObserver from 'rc-resize-observer';
@@ -44,6 +44,9 @@ export default (function (_ref) {
44
44
  locationKey = location.key;
45
45
  var outlet = useOutlet();
46
46
  var update = useUpdate();
47
+ var _theme$useToken = theme.useToken(),
48
+ token = _theme$useToken.token;
49
+ var isDark = token._appTheme === 'dark';
47
50
 
48
51
  // 超过缓存数量,删除第一个
49
52
  if (components.current.length >= maxLen) {
@@ -219,12 +222,13 @@ export default (function (_ref) {
219
222
  children: /*#__PURE__*/_jsx("div", {})
220
223
  }), /*#__PURE__*/_jsx(Tabs, {
221
224
  id: "keep-alive-tabs",
222
- hideAdd: true,
223
- size: "small",
225
+ hideAdd: true
226
+ // size="small"
227
+ ,
224
228
  onChange: function onChange(e) {
225
229
  history.push(e);
226
230
  },
227
- className: "ccs-keep-alive-tabs",
231
+ className: "ccs-keep-alive-tabs ".concat(isDark ? 'dark' : ''),
228
232
  activeKey: pathname,
229
233
  type: "editable-card",
230
234
  onEdit: function onEdit(e) {
@@ -5,7 +5,11 @@
5
5
  flex-direction: column;
6
6
 
7
7
  &-tabs {
8
- // background: rgb(240 242 245);
8
+ background-color: #fff;
9
+
10
+ &.dark {
11
+ background-color: rgb(37, 37, 37);
12
+ }
9
13
 
10
14
  & > .ant-tabs-nav {
11
15
  margin: 0;
@@ -18,6 +22,15 @@
18
22
  border: 0;
19
23
  border-radius: 0 !important;
20
24
  }
25
+ .ant-tabs-tab-active {
26
+ background-color: #f0f2f5;
27
+ }
28
+ }
29
+
30
+ &.dark > .ant-tabs-nav {
31
+ .ant-tabs-tab-active {
32
+ background-color: #2b2c2c;
33
+ }
21
34
  }
22
35
  }
23
36
  }
@@ -0,0 +1,25 @@
1
+ import { CardProps } from 'antd';
2
+ import { CSSProperties, FC, ReactNode } from 'react';
3
+ import './index.less';
4
+ type ClassProps = {
5
+ className?: string;
6
+ style?: CSSProperties;
7
+ };
8
+ type CcsProGridProps = ClassProps & {
9
+ title?: string;
10
+ titleExtra?: ReactNode;
11
+ bordered?: boolean;
12
+ hideTitle?: boolean;
13
+ children?: ReactNode;
14
+ };
15
+ type ColProps = CardProps & {
16
+ colSpan?: string | number;
17
+ colStyle?: CSSProperties;
18
+ colClassName?: string;
19
+ };
20
+ type GridInstance = FC<CcsProGridProps> & {
21
+ Col: typeof GridCol;
22
+ };
23
+ declare const GridCol: ({ colSpan, colClassName, colStyle, ...otherProps }: ColProps) => import("react/jsx-runtime").JSX.Element;
24
+ declare const ProGrid: GridInstance;
25
+ export default ProGrid;
@@ -10,7 +10,6 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
10
10
  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; }
11
11
  import { Card } from 'antd';
12
12
  import classNames from 'classnames';
13
- import { GridContext } from "./context";
14
13
  import "./index.less";
15
14
  import { jsx as _jsx } from "react/jsx-runtime";
16
15
  import { Fragment as _Fragment } from "react/jsx-runtime";
@@ -47,36 +46,31 @@ var Grid = function Grid(_ref2) {
47
46
  bordered = _ref2.bordered,
48
47
  children = _ref2.children,
49
48
  restProps = _objectWithoutProperties(_ref2, _excluded2);
50
- return /*#__PURE__*/_jsx(GridContext.Provider, {
51
- value: {
52
- inProGrid: true
53
- },
54
- children: /*#__PURE__*/_jsxs("div", _objectSpread(_objectSpread({}, restProps), {}, {
55
- className: classNames({
56
- 'ccs-pg-border': bordered
57
- }),
58
- children: [!hideTitle && title ? /*#__PURE__*/_jsx(Card, {
59
- title: title,
60
- extra: titleExtra,
61
- bordered: false,
49
+ return /*#__PURE__*/_jsxs("div", _objectSpread(_objectSpread({}, restProps), {}, {
50
+ className: classNames({
51
+ 'ccs-pg-border': bordered
52
+ }),
53
+ children: [!hideTitle && title ? /*#__PURE__*/_jsx(Card, {
54
+ title: title,
55
+ extra: titleExtra,
56
+ bordered: false,
57
+ style: {
58
+ borderRadius: 0
59
+ },
60
+ bodyStyle: {
61
+ padding: 0
62
+ }
63
+ }) : null, /*#__PURE__*/_jsx("div", {
64
+ className: "ccs-pl-table-content",
65
+ children: /*#__PURE__*/_jsx("div", {
62
66
  style: {
63
- borderRadius: 0
67
+ display: 'flex',
68
+ padding: 10
64
69
  },
65
- bodyStyle: {
66
- padding: 0
67
- }
68
- }) : null, /*#__PURE__*/_jsx("div", {
69
- className: "ccs-pl-table-content",
70
- children: /*#__PURE__*/_jsx("div", {
71
- style: {
72
- display: 'flex',
73
- padding: 10
74
- },
75
- children: children
76
- })
77
- })]
78
- }))
79
- });
70
+ children: children
71
+ })
72
+ })]
73
+ }));
80
74
  };
81
75
  var ProGrid = Grid;
82
76
  ProGrid.Col = GridCol;
@@ -21,7 +21,6 @@ import _isArray from 'lodash/isArray';
21
21
  import React, { useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
22
22
  import { CcsUtils, CcsWaterMark } from '..';
23
23
  import { useCcsPage } from "../";
24
- import useProGrid from "../pro-grid/useProGrid";
25
24
  import CcsTable from "../table";
26
25
  import "./index.less";
27
26
  import SearchComponent from "./search";
@@ -106,8 +105,6 @@ var InternalProTable = function InternalProTable(props) {
106
105
  var tableRef = useRef(null);
107
106
  var _useCcsPage = useCcsPage(),
108
107
  onAuth = _useCcsPage.onAuth;
109
- var _useProGrid = useProGrid(),
110
- inProGrid = _useProGrid.inProGrid;
111
108
  var _ref = table || {},
112
109
  pagination = _ref.pagination,
113
110
  request = _ref.request,
@@ -476,9 +473,7 @@ var InternalProTable = function InternalProTable(props) {
476
473
  children: toolbarExtra
477
474
  }), /*#__PURE__*/_jsxs("div", {
478
475
  className: "".concat(classPrefix, "-table-content"),
479
- style: _objectSpread({
480
- padding: isInModalOrDrawer || inProGrid ? 0 : 16
481
- }, tableStyle),
476
+ style: tableStyle,
482
477
  ref: tableRef,
483
478
  children: [renderTable(), children]
484
479
  })]
package/es/table/index.js CHANGED
@@ -60,7 +60,7 @@ var CustomTable = function CustomTable(props) {
60
60
  if (_pagination && _pagination.length > 0) {
61
61
  pageHeight = _pagination[0].clientHeight;
62
62
  }
63
- var scrollHeight = bodyHeight - top - 16 - theadHeight - pageHeight - (restProps.title ? 46 : 0) - (restProps.footer ? 46 : 0);
63
+ var scrollHeight = bodyHeight - top - theadHeight - pageHeight - (restProps.title ? 46 : 0) - (restProps.footer ? 46 : 0);
64
64
 
65
65
  // 固定tbody高度
66
66
  var tbody = (_ref$current4 = ref.current) === null || _ref$current4 === void 0 ? void 0 : _ref$current4.getElementsByClassName('ant-table-body');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ccs-ui/rc-pro",
3
- "version": "1.1.12",
3
+ "version": "1.1.14",
4
4
  "description": "A react pro components",
5
5
  "license": "MIT",
6
6
  "module": "es/index.js",
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- export var GridContext = /*#__PURE__*/React.createContext({
3
- inProGrid: false
4
- });
@@ -1,10 +0,0 @@
1
- import { useContext } from 'react';
2
- import { GridContext } from "./context";
3
- function useProGrid() {
4
- var context = useContext(GridContext);
5
- if (context === undefined) {
6
- throw new Error('TabsContext must be used within a app page');
7
- }
8
- return context;
9
- }
10
- export default useProGrid;