@magicbe/antd-crud 0.0.27 → 0.0.28

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,9 +1,5 @@
1
1
  import React, { PropsWithChildren } from "react";
2
- export interface ActionProps {
3
- className?: string;
4
- }
5
- export interface ActionRef {
6
- }
2
+ import { ActionProps, ActionRef } from "../interface";
7
3
  declare const _default: React.ForwardRefExoticComponent<ActionProps & React.RefAttributes<ActionRef>>;
8
4
  export default _default;
9
5
  /**自定义渲染 */
@@ -1,8 +1,5 @@
1
- import React, { PropsWithChildren } from "react";
2
- import { AnyObject, FormRef, type ContentProps } from "../interface";
3
- import { type FilterRef } from "./Filter";
4
- import { type ActionRef } from "./Action";
5
- import { type TableRef } from "./Table";
1
+ import React from "react";
2
+ import { AnyObject, ContentRef, type FilterRef, FormRef, type ContentProps, ActionRef, TableRef } from "../interface";
6
3
  interface TableContextProps<RecordType> extends ContentProps<RecordType> {
7
4
  filter_ref: React.RefObject<FilterRef>;
8
5
  action_ref: React.RefObject<ActionRef>;
@@ -10,6 +7,7 @@ interface TableContextProps<RecordType> extends ContentProps<RecordType> {
10
7
  content_ref: React.RefObject<HTMLDivElement>;
11
8
  form_ref: React.RefObject<FormRef>;
12
9
  }
13
- export declare const TableContextProvider: <RecordType extends AnyObject = AnyObject>({ children, drawer, ...props }: React.PropsWithChildren<ContentProps<RecordType>>) => import("react/jsx-runtime").JSX.Element;
10
+ type RefTable = <RecordType = AnyObject>(props: React.PropsWithChildren<ContentProps<RecordType>> & React.RefAttributes<ContentRef>) => React.ReactElement;
11
+ export declare const TableContextProvider: RefTable;
14
12
  export declare const useTableContext: () => Partial<TableContextProps<any>>;
15
13
  export {};
@@ -21,15 +21,23 @@ var __rest = (this && this.__rest) || function (s, e) {
21
21
  return t;
22
22
  };
23
23
  import { jsx as _jsx } from "react/jsx-runtime";
24
- import React, { useContext } from "react";
24
+ import React, { useContext, useImperativeHandle } from "react";
25
25
  var TableContext = React.createContext({});
26
- export var TableContextProvider = function (_a) {
26
+ var TableContextProviderPrev = function (_a, ref) {
27
27
  var children = _a.children, _b = _a.drawer, drawer = _b === void 0 ? 600 : _b, props = __rest(_a, ["children", "drawer"]);
28
28
  var filter_ref = React.createRef();
29
29
  var action_ref = React.createRef();
30
30
  var table_ref = React.createRef();
31
31
  var content_ref = React.createRef();
32
32
  var form_ref = React.createRef();
33
+ useImperativeHandle(ref, function () { return ({
34
+ filter_ref: filter_ref,
35
+ action_ref: action_ref,
36
+ table_ref: table_ref,
37
+ content_ref: content_ref,
38
+ form_ref: form_ref,
39
+ }); });
33
40
  return (_jsx(TableContext.Provider, __assign({ value: __assign(__assign({}, props), { drawer: drawer, filter_ref: filter_ref, action_ref: action_ref, table_ref: table_ref, content_ref: content_ref, form_ref: form_ref }) }, { children: children })));
34
41
  };
42
+ export var TableContextProvider = React.forwardRef(TableContextProviderPrev);
35
43
  export var useTableContext = function () { return useContext(TableContext); };
@@ -1,9 +1,4 @@
1
1
  import React from "react";
2
- import { FormInstance } from "antd";
3
- export interface FilterProps {
4
- }
5
- export interface FilterRef {
6
- form: FormInstance;
7
- }
2
+ import { FilterProps, FilterRef } from "../interface";
8
3
  declare const _default: React.ForwardRefExoticComponent<FilterProps & React.RefAttributes<FilterRef>>;
9
4
  export default _default;
@@ -1,18 +1,5 @@
1
1
  import React, { PropsWithChildren } from "react";
2
- import { type AnyObject } from "../interface";
3
- export interface TableProps {
4
- }
5
- type getPageData = () => ({
6
- current?: number;
7
- pageSize?: number;
8
- });
9
- type loadRecords = (params?: any) => void;
10
- export interface TableRef {
11
- getPageData: getPageData;
12
- loadRecords: loadRecords;
13
- selected_keys: React.Key[];
14
- selected_rows: AnyObject[];
15
- }
2
+ import { TableProps, TableRef, type AnyObject } from "../interface";
16
3
  declare const _default: React.ForwardRefExoticComponent<TableProps & React.RefAttributes<TableRef>>;
17
4
  export default _default;
18
5
  interface ActionProps {
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { type ContentProps, type AnyObject } from "../interface";
3
- type RefTable = <RecordType = AnyObject>(props: React.PropsWithChildren<ContentProps<RecordType>>) => React.ReactElement;
2
+ import { type ContentProps, type ContentRef, type AnyObject } from "../interface";
3
+ type RefTable = <RecordType = AnyObject>(props: React.PropsWithChildren<ContentProps<RecordType>> & React.RefAttributes<ContentRef>) => React.ReactElement;
4
4
  declare const _default: RefTable;
5
5
  export default _default;
@@ -10,7 +10,7 @@ var __assign = (this && this.__assign) || function () {
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
- import React, { useImperativeHandle } from "react";
13
+ import React from "react";
14
14
  import Filter from "./Filter";
15
15
  import Action from "./Action";
16
16
  import Table from "./Table";
@@ -20,7 +20,6 @@ var Content = function () {
20
20
  return (_jsxs("div", __assign({ ref: content_ref }, { children: [_jsx(Filter, { ref: filter_ref }), _jsx(Action, { ref: action_ref }), _jsx(Table, { ref: table_ref })] })));
21
21
  };
22
22
  var ContentPrev = function (props, ref) {
23
- useImperativeHandle(ref, function () { return ({}); });
24
- return (_jsx(TableContextProvider, __assign({}, props, { children: _jsx(Content, {}) })));
23
+ return (_jsx(TableContextProvider, __assign({}, props, { ref: ref }, { children: _jsx(Content, {}) })));
25
24
  };
26
25
  export default React.forwardRef(ContentPrev);
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- export { type AnyObject, type BaseColumnField, type ColumnInputField, type ColumnTextAreaField, type ColumnInputNumberField, type ColumnSelectField, type ColumnCascaderField, type ColumnCheckboxField, type ColumnCheckboxGroupField, type ColumnDatePickerField, type ColumnDatePickerYearPickerField, type ColumnDatePickerMonthPickerField, type ColumnDatePickerWeekPickerField, type ColumnDatePickerTimePickerField, type ColumnDatePickerRangePickerField, type ColumnDatePickerQuarterPickerField, type ColumnTimePickerField, type ColumnTimePickerRangePickerField, type ColumnRadioField, type ColumnRadioGroupField, type ColumnSwitchField, type ColumnField, type ColumnFieldKeys, type ColumnType, type Source, type getSourceFunction, type GetSourceFunctionParams, type add, type addHandleMap, type edit, type editHandleMap, type del, type CustomFilter, type filter, type MasterCustomActionGroup, type RecordCustomActionGroup, type CustomActionGroup, type CustomAction, type ContentProps, type ContentRef, type FormRef, } from "./interface";
1
+ export { type AnyObject, type BaseColumnField, type ColumnInputField, type ColumnTextAreaField, type ColumnInputNumberField, type ColumnSelectField, type ColumnCascaderField, type ColumnCheckboxField, type ColumnCheckboxGroupField, type ColumnDatePickerField, type ColumnDatePickerYearPickerField, type ColumnDatePickerMonthPickerField, type ColumnDatePickerWeekPickerField, type ColumnDatePickerTimePickerField, type ColumnDatePickerRangePickerField, type ColumnDatePickerQuarterPickerField, type ColumnTimePickerField, type ColumnTimePickerRangePickerField, type ColumnRadioField, type ColumnRadioGroupField, type ColumnSwitchField, type ColumnField, type ColumnFieldKeys, type ColumnType, type Source, type getSourceFunction, type GetSourceFunctionParams, type add, type addHandleMap, type edit, type editHandleMap, type del, type CustomFilter, type filter, type MasterCustomActionGroup, type RecordCustomActionGroup, type CustomActionGroup, type CustomAction, type ContentProps, type ContentRef, type FormRef, type FilterProps, type FilterRef, type ActionProps, type ActionRef, type TableProps, type getPageData, type loadRecords, type TableRef, } from "./interface";
2
2
  export { default as CrudTable, } from "./components";
3
3
  export { TableContextProvider, useTableContext, } from "./components/Context";
4
- export { default as Filter, type FilterProps, type FilterRef, } from "./components/Filter";
5
- export { default as Action, AppendAction as MastAppend, DeleteAction as MastDelete, EditAction as MastEdit, type ActionProps, type ActionRef, } from "./components/Action";
6
- export { default as Table, AppendAction as RowAppend, DeleteAction as RowDelete, EditAction as RowEdit, type TableProps, type TableRef, } from "./components/Table";
4
+ export { default as Filter, } from "./components/Filter";
5
+ export { default as Action, AppendAction as MastAppend, DeleteAction as MastDelete, EditAction as MastEdit, } from "./components/Action";
6
+ export { default as Table, AppendAction as RowAppend, DeleteAction as RowDelete, EditAction as RowEdit, } from "./components/Table";
7
7
  export { default as CrudConfigProvider, } from "./config";
@@ -1,4 +1,4 @@
1
- import { type TableProps, type InputProps, type SelectProps, type CascaderProps, type DatePickerProps, type InputNumberProps, type CheckboxProps, type RadioProps, type SwitchProps, type TimePickerProps, TreeSelectProps } from "antd";
1
+ import { type TableProps as AntdTableProps, type InputProps, type SelectProps, type CascaderProps, type DatePickerProps, type InputNumberProps, type CheckboxProps, type RadioProps, type SwitchProps, type TimePickerProps, TreeSelectProps } from "antd";
2
2
  import { type CheckboxGroupProps } from "antd/es/checkbox";
3
3
  import { FormInstance, Rule } from "antd/es/form";
4
4
  import { TextAreaProps } from "antd/es/input";
@@ -165,7 +165,7 @@ export interface DrawerProps {
165
165
  edit?: number;
166
166
  }
167
167
  /**主体参数 */
168
- export interface ContentProps<RecordType = AnyObject> extends Omit<TableProps<RecordType>, "columns" | "pagination" | "dataSource" | "loading" | "rowSelection"> {
168
+ export interface ContentProps<RecordType = AnyObject> extends Omit<AntdTableProps<RecordType>, "columns" | "pagination" | "dataSource" | "loading" | "rowSelection"> {
169
169
  columns?: ColumnType<RecordType>[];
170
170
  getSources?: getSourceFunction;
171
171
  add?: add;
@@ -179,9 +179,40 @@ export interface ContentProps<RecordType = AnyObject> extends Omit<TableProps<Re
179
179
  }
180
180
  /**主体暴露 */
181
181
  export interface ContentRef {
182
+ filter_ref: React.RefObject<FilterRef>;
183
+ action_ref: React.RefObject<ActionRef>;
184
+ table_ref: React.RefObject<TableRef>;
185
+ content_ref: React.RefObject<HTMLDivElement>;
186
+ form_ref: React.RefObject<FormRef>;
182
187
  }
183
188
  /**表单REF */
184
189
  export interface FormRef {
185
190
  form: FormInstance;
186
191
  }
192
+ /**筛选 */
193
+ export interface FilterProps {
194
+ }
195
+ export interface FilterRef {
196
+ form: FormInstance;
197
+ }
198
+ /**操作 */
199
+ export interface ActionProps {
200
+ className?: string;
201
+ }
202
+ export interface ActionRef {
203
+ }
204
+ /**表单 */
205
+ export interface TableProps {
206
+ }
207
+ export type getPageData = () => ({
208
+ current?: number;
209
+ pageSize?: number;
210
+ });
211
+ export type loadRecords = (params?: any) => void;
212
+ export interface TableRef {
213
+ getPageData: getPageData;
214
+ loadRecords: loadRecords;
215
+ selected_keys: React.Key[];
216
+ selected_rows: AnyObject[];
217
+ }
187
218
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magicbe/antd-crud",
3
- "version": "0.0.27",
3
+ "version": "0.0.28",
4
4
  "description": "antd crud table",
5
5
  "author": "wang quan",
6
6
  "private": false,