@ccs-ui/rc-pro 2.1.5 → 2.1.7

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
@@ -68,7 +68,7 @@ function AppConfig(_ref) {
68
68
  isCompact = _ref.isCompact,
69
69
  watermark = _ref.watermark,
70
70
  themeConfig = _ref.themeConfig,
71
- CcsProTableFieldNames = _ref.CcsProTableFieldNames;
71
+ fieldNames = _ref.fieldNames;
72
72
  var holderRef = React.useRef(null);
73
73
  // 主题
74
74
  var appTheme = theme === 'dark' ? darkTheme : defaultTheme;
@@ -97,7 +97,7 @@ function AppConfig(_ref) {
97
97
  theme: theme,
98
98
  themeConfig: themeConfig,
99
99
  holderRef: holderRef,
100
- CcsProTableFieldNames: CcsProTableFieldNames
100
+ fieldNames: fieldNames
101
101
  },
102
102
  children: [children, /*#__PURE__*/_jsx(AppDialog, {}), /*#__PURE__*/_jsx(ElementsHolder, {
103
103
  ref: holderRef
@@ -48,6 +48,12 @@ type FnContextType<T = Store> = {
48
48
  formInitialValues: T;
49
49
  close: () => void;
50
50
  };
51
+ type CcsFieldNamesType = {
52
+ dataSource: string[];
53
+ total: string[];
54
+ current: string[];
55
+ pageSize: string[];
56
+ };
51
57
  type CssAppConfigType = {
52
58
  /** 主题 */
53
59
  theme?: 'dark' | 'light' | 'colorful';
@@ -59,12 +65,12 @@ type CssAppConfigType = {
59
65
  watermark?: WaterMarkProps;
60
66
  /** modal or drawer holder */
61
67
  holderRef?: React.RefObject<ElementsHolderRef>;
62
- /** CcsProTable 组件字段全局指定 */
63
- CcsProTableFieldNames?: {
64
- dataSource: string[];
65
- total: string[];
66
- current: string[];
67
- pageSize: string[];
68
+ /** 接口字段指定 */
69
+ fieldNames?: {
70
+ /** CcsProTable 组件字段全局指定 */
71
+ proTable?: CcsFieldNamesType;
72
+ /** CcsProTable.Tree 组件字段全局指定 */
73
+ proTableTree?: Pick<CcsFieldNamesType, 'dataSource'>;
68
74
  };
69
75
  };
70
76
  declare const DrawerAndModalContext: React.Context<FnContextType<any>>;
@@ -72,4 +78,4 @@ declare const PageContext: React.Context<PageContextType>;
72
78
  declare const TabsContext: React.Context<CcsTabsContextType>;
73
79
  declare const AppConfigContext: React.Context<CssAppConfigType>;
74
80
  export { AppConfigContext, DrawerAndModalContext, PageContext, TabsContext };
75
- export type { CcsTabsChangeProps, CcsTabsContextType, CssAppConfigType, FnContextType, };
81
+ export type { CcsFieldNamesType, CcsTabsChangeProps, CcsTabsContextType, CssAppConfigType, FnContextType, };
@@ -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" | "onCancel" | "extraBtn" | "request" | "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" | "onOk" | "extraBtn"> & {
5
5
  formRef: React.RefObject<DialogFormRef>;
6
6
  formInitialValues: FormProps['initialValues'];
7
7
  }) => import("react/jsx-runtime").JSX.Element;
@@ -3,10 +3,6 @@
3
3
  * @returns
4
4
  */
5
5
  declare const useAppConfig: () => import("../context").CssAppConfigType;
6
- export declare const useProTableFields: () => {
7
- dataSource: string[];
8
- total: string[];
9
- current: string[];
10
- pageSize: string[];
11
- } | undefined;
6
+ export declare const useProTableFields: () => import("../context").CcsFieldNamesType | undefined;
7
+ export declare const useProTableTreeFields: () => Pick<import("../context").CcsFieldNamesType, "dataSource"> | undefined;
12
8
  export default useAppConfig;
@@ -13,7 +13,13 @@ var useAppConfig = function useAppConfig() {
13
13
  return context;
14
14
  };
15
15
  export var useProTableFields = function useProTableFields() {
16
+ var _context$fieldNames;
16
17
  var context = useContext(AppConfigContext) || {};
17
- return context === null || context === void 0 ? void 0 : context.CcsProTableFieldNames;
18
+ return context === null || context === void 0 || (_context$fieldNames = context.fieldNames) === null || _context$fieldNames === void 0 ? void 0 : _context$fieldNames.proTable;
19
+ };
20
+ export var useProTableTreeFields = function useProTableTreeFields() {
21
+ var _context$fieldNames2;
22
+ var context = useContext(AppConfigContext) || {};
23
+ return context === null || context === void 0 || (_context$fieldNames2 = context.fieldNames) === null || _context$fieldNames2 === void 0 ? void 0 : _context$fieldNames2.proTableTree;
18
24
  };
19
25
  export default useAppConfig;
@@ -4,7 +4,7 @@ import { TableSticky } from 'rc-table/lib/interface';
4
4
  import React, { CSSProperties, ReactElement, ReactNode } from 'react';
5
5
  import CCS from '..';
6
6
  import { PropsWithCss, PropsWithNodeChildren, TableColumns } from '../ccs';
7
- import { CssAppConfigType } from '../context';
7
+ import { CcsFieldNamesType } from '../context';
8
8
  import './index.less';
9
9
  type ParamType = Record<string, any>;
10
10
  export type ShowDependType = {
@@ -33,7 +33,7 @@ export type CcsTableProps<T> = Omit<TableProps<T>, 'columns' | 'title'> & {
33
33
  /** request 额外参数 dataSource: ['data', 'result']; current: ['data', 'pageNo']; pageSize: ['data', 'pageSize']; total: ['data', 'totalNum'] */
34
34
  requestParam?: ParamType;
35
35
  /** 接口字段指定,默认: */
36
- fieldNames?: CssAppConfigType['CcsProTableFieldNames'];
36
+ fieldNames?: CcsFieldNamesType;
37
37
  /** class name */
38
38
  className?: string;
39
39
  /** style */
@@ -2,6 +2,7 @@ import { TableProps } from 'antd';
2
2
  import { TableSticky } from 'rc-table/lib/interface';
3
3
  import { RefObject } from 'react';
4
4
  import CCS from '..';
5
+ import { CcsFieldNamesType } from '../context';
5
6
  import { TableRefType } from '../table';
6
7
  import { CcsProTableProps } from './table';
7
8
  export type TreeInstance<T> = {
@@ -17,6 +18,7 @@ type TreeTableProps<T> = Pick<CcsProTableProps<T>, 'table' | 'onSearchBefore' |
17
18
  tableContentRef: React.RefObject<HTMLDivElement>;
18
19
  setData: React.Dispatch<React.SetStateAction<CCS.TableData<T>>>;
19
20
  handlePageChange: any;
21
+ fieldNames?: Pick<CcsFieldNamesType, 'dataSource'>;
20
22
  };
21
23
  declare const TableTree: <T extends object = any>(props: TreeTableProps<T>) => import("react/jsx-runtime").JSX.Element;
22
24
  export default TableTree;
@@ -20,6 +20,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
20
20
  import CcsUtils from '@ccs-ui/utils';
21
21
  import { useImperativeHandle, useState } from 'react';
22
22
  import { CcsTable } from '..';
23
+ import { useProTableTreeFields } from "../hooks/use-app";
23
24
  import { getDataFromFields } from "../select";
24
25
  import { jsx as _jsx } from "react/jsx-runtime";
25
26
  var TableTree = function TableTree(props) {
@@ -44,10 +45,16 @@ var TableTree = function TableTree(props) {
44
45
  rowKey = _ref.rowKey,
45
46
  expandable = _ref.expandable,
46
47
  columns = _ref.columns,
47
- httpRequest = _ref.request,
48
- fieldNames = _ref.fieldNames;
48
+ httpRequest = _ref.request;
49
49
  var childrenColumnName = (expandable === null || expandable === void 0 ? void 0 : expandable.childrenColumnName) || 'children';
50
50
 
51
+ // 接口字段指定全局配置
52
+ var globalFieldNames = useProTableTreeFields();
53
+ // 接口字段指定
54
+ var fieldNames = props.fieldNames || globalFieldNames || {
55
+ dataSource: ['data']
56
+ };
57
+
51
58
  // 获取数据
52
59
  var _onRequestTree = /*#__PURE__*/function () {
53
60
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ccs-ui/rc-pro",
3
- "version": "2.1.5",
3
+ "version": "2.1.7",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "author": {