@hi-ui/schema-editable-table 4.0.0-experimental.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.
- package/README.md +11 -0
- package/lib/cjs/body/index.js +110 -0
- package/lib/cjs/body/wrapper.js +132 -0
- package/lib/cjs/cell/aggregated.js +76 -0
- package/lib/cjs/cell/dependency.js +97 -0
- package/lib/cjs/cell/editing.js +89 -0
- package/lib/cjs/cell/footer.js +64 -0
- package/lib/cjs/cell/header.js +76 -0
- package/lib/cjs/cell/index.js +204 -0
- package/lib/cjs/const.js +35 -0
- package/lib/cjs/container/base.js +39 -0
- package/lib/cjs/container/bottom.js +86 -0
- package/lib/cjs/container/col-group.js +98 -0
- package/lib/cjs/container/column-virtual.js +53 -0
- package/lib/cjs/container/ctx.js +32 -0
- package/lib/cjs/container/full-virtual.js +61 -0
- package/lib/cjs/container/hooks.js +102 -0
- package/lib/cjs/container/index.js +69 -0
- package/lib/cjs/container/row-virtual.js +50 -0
- package/lib/cjs/container/wrapper.js +97 -0
- package/lib/cjs/ctx.js +32 -0
- package/lib/cjs/features/_overrides/aggregated.js +44 -0
- package/lib/cjs/features/_overrides/getter.js +61 -0
- package/lib/cjs/features/_overrides/grouping.js +40 -0
- package/lib/cjs/features/_overrides/overrides.js +43 -0
- package/lib/cjs/features/_overrides/row-selection.js +140 -0
- package/lib/cjs/features/async-data/getter.js +150 -0
- package/lib/cjs/features/async-data/normal.js +145 -0
- package/lib/cjs/features/async-data/use-data-fetcher.js +40 -0
- package/lib/cjs/features/async-data/use-reset-data.js +91 -0
- package/lib/cjs/features/column-grouping/get-grouping-config.js +27 -0
- package/lib/cjs/features/column-grouping/use-opts.js +42 -0
- package/lib/cjs/features/column-state.js +57 -0
- package/lib/cjs/features/filter/bridge.js +114 -0
- package/lib/cjs/features/filter/filter-fns/date.js +34 -0
- package/lib/cjs/features/filter/filter-fns/index.js +23 -0
- package/lib/cjs/features/filter/get-filter-config.js +61 -0
- package/lib/cjs/features/filter/index.js +29 -0
- package/lib/cjs/features/filter/use-opts.js +88 -0
- package/lib/cjs/features/header-actions/components/column-collapsing.js +74 -0
- package/lib/cjs/features/header-actions/get-actions.js +77 -0
- package/lib/cjs/features/pagination/component.js +89 -0
- package/lib/cjs/features/pagination/use-opts.js +98 -0
- package/lib/cjs/features/pagination/use-state.js +44 -0
- package/lib/cjs/features/row-controller.js +265 -0
- package/lib/cjs/features/row-edit/actions.js +65 -0
- package/lib/cjs/features/row-edit/hooks.js +29 -0
- package/lib/cjs/features/row-expanding/use-opts.js +39 -0
- package/lib/cjs/features/row-expanding/wrapper.js +74 -0
- package/lib/cjs/features/row-operation/buttons.js +91 -0
- package/lib/cjs/features/row-operation/cell.js +43 -0
- package/lib/cjs/features/row-operation/index.js +21 -0
- package/lib/cjs/features/row-operation/wrapper.js +114 -0
- package/lib/cjs/features/row-selection/cell.js +114 -0
- package/lib/cjs/features/row-selection/const.js +16 -0
- package/lib/cjs/features/row-selection/hooks/index.js +29 -0
- package/lib/cjs/features/row-selection/hooks/use-click-select.js +70 -0
- package/lib/cjs/features/row-selection/hooks/use-opts.js +120 -0
- package/lib/cjs/features/row-selection/hooks/use-set-selected-row-keys.js +48 -0
- package/lib/cjs/features/row-selection/hooks/use-sync-hover-style.js +86 -0
- package/lib/cjs/features/row-selection/indicator.js +173 -0
- package/lib/cjs/features/row-selection/wrapper.js +119 -0
- package/lib/cjs/features/setting-bridge.js +56 -0
- package/lib/cjs/features/sorter/bridge.js +65 -0
- package/lib/cjs/features/sorter/get-sorter-config.js +46 -0
- package/lib/cjs/features/sorter/index.js +29 -0
- package/lib/cjs/features/sorter/use-opts.js +81 -0
- package/lib/cjs/field-bridge/bridge.js +104 -0
- package/lib/cjs/field-bridge/index.js +58 -0
- package/lib/cjs/field-bridge/toolbar.js +53 -0
- package/lib/cjs/footer/index.js +99 -0
- package/lib/cjs/footer/use-first-cell-patch.js +42 -0
- package/lib/cjs/header/index.js +134 -0
- package/lib/cjs/header/validate.js +69 -0
- package/lib/cjs/hooks/use-get-fields-value.js +62 -0
- package/lib/cjs/hooks/use-global-actions.js +65 -0
- package/lib/cjs/hooks/use-global-static.js +158 -0
- package/lib/cjs/hooks/use-initial-render.js +30 -0
- package/lib/cjs/hooks/use-inner-ctx.js +105 -0
- package/lib/cjs/hooks/use-props.js +108 -0
- package/lib/cjs/hooks/use-table-columns.js +76 -0
- package/lib/cjs/hooks/use-table-meta.js +57 -0
- package/lib/cjs/hooks/use-update.js +57 -0
- package/lib/cjs/index.js +66 -0
- package/lib/cjs/index.scss.js +18 -0
- package/lib/cjs/table.js +263 -0
- package/lib/cjs/utils/cls.js +19 -0
- package/lib/cjs/utils/fixed.js +53 -0
- package/lib/cjs/utils/grouping.js +42 -0
- package/lib/cjs/utils/state-merge.js +43 -0
- package/lib/esm/body/index.js +98 -0
- package/lib/esm/body/wrapper.js +120 -0
- package/lib/esm/cell/aggregated.js +64 -0
- package/lib/esm/cell/dependency.js +90 -0
- package/lib/esm/cell/editing.js +76 -0
- package/lib/esm/cell/footer.js +52 -0
- package/lib/esm/cell/header.js +63 -0
- package/lib/esm/cell/index.js +192 -0
- package/lib/esm/const.js +24 -0
- package/lib/esm/container/base.js +27 -0
- package/lib/esm/container/bottom.js +74 -0
- package/lib/esm/container/col-group.js +85 -0
- package/lib/esm/container/column-virtual.js +41 -0
- package/lib/esm/container/ctx.js +19 -0
- package/lib/esm/container/full-virtual.js +49 -0
- package/lib/esm/container/hooks.js +95 -0
- package/lib/esm/container/index.js +57 -0
- package/lib/esm/container/row-virtual.js +38 -0
- package/lib/esm/container/wrapper.js +83 -0
- package/lib/esm/ctx.js +17 -0
- package/lib/esm/features/_overrides/aggregated.js +39 -0
- package/lib/esm/features/_overrides/getter.js +56 -0
- package/lib/esm/features/_overrides/grouping.js +35 -0
- package/lib/esm/features/_overrides/overrides.js +38 -0
- package/lib/esm/features/_overrides/row-selection.js +135 -0
- package/lib/esm/features/async-data/getter.js +143 -0
- package/lib/esm/features/async-data/normal.js +133 -0
- package/lib/esm/features/async-data/use-data-fetcher.js +34 -0
- package/lib/esm/features/async-data/use-reset-data.js +79 -0
- package/lib/esm/features/column-grouping/get-grouping-config.js +22 -0
- package/lib/esm/features/column-grouping/use-opts.js +36 -0
- package/lib/esm/features/column-state.js +51 -0
- package/lib/esm/features/filter/bridge.js +102 -0
- package/lib/esm/features/filter/filter-fns/date.js +28 -0
- package/lib/esm/features/filter/filter-fns/index.js +18 -0
- package/lib/esm/features/filter/get-filter-config.js +56 -0
- package/lib/esm/features/filter/index.js +24 -0
- package/lib/esm/features/filter/use-opts.js +82 -0
- package/lib/esm/features/header-actions/components/column-collapsing.js +62 -0
- package/lib/esm/features/header-actions/get-actions.js +65 -0
- package/lib/esm/features/pagination/component.js +77 -0
- package/lib/esm/features/pagination/use-opts.js +91 -0
- package/lib/esm/features/pagination/use-state.js +39 -0
- package/lib/esm/features/row-controller.js +253 -0
- package/lib/esm/features/row-edit/actions.js +53 -0
- package/lib/esm/features/row-edit/hooks.js +24 -0
- package/lib/esm/features/row-expanding/use-opts.js +33 -0
- package/lib/esm/features/row-expanding/wrapper.js +62 -0
- package/lib/esm/features/row-operation/buttons.js +79 -0
- package/lib/esm/features/row-operation/cell.js +31 -0
- package/lib/esm/features/row-operation/index.js +16 -0
- package/lib/esm/features/row-operation/wrapper.js +100 -0
- package/lib/esm/features/row-selection/cell.js +101 -0
- package/lib/esm/features/row-selection/const.js +11 -0
- package/lib/esm/features/row-selection/hooks/index.js +24 -0
- package/lib/esm/features/row-selection/hooks/use-click-select.js +65 -0
- package/lib/esm/features/row-selection/hooks/use-opts.js +114 -0
- package/lib/esm/features/row-selection/hooks/use-set-selected-row-keys.js +43 -0
- package/lib/esm/features/row-selection/hooks/use-sync-hover-style.js +81 -0
- package/lib/esm/features/row-selection/indicator.js +159 -0
- package/lib/esm/features/row-selection/wrapper.js +107 -0
- package/lib/esm/features/setting-bridge.js +50 -0
- package/lib/esm/features/sorter/bridge.js +53 -0
- package/lib/esm/features/sorter/get-sorter-config.js +41 -0
- package/lib/esm/features/sorter/index.js +24 -0
- package/lib/esm/features/sorter/use-opts.js +75 -0
- package/lib/esm/field-bridge/bridge.js +92 -0
- package/lib/esm/field-bridge/index.js +44 -0
- package/lib/esm/field-bridge/toolbar.js +41 -0
- package/lib/esm/footer/index.js +87 -0
- package/lib/esm/footer/use-first-cell-patch.js +37 -0
- package/lib/esm/header/index.js +121 -0
- package/lib/esm/header/validate.js +64 -0
- package/lib/esm/hooks/use-get-fields-value.js +56 -0
- package/lib/esm/hooks/use-global-actions.js +60 -0
- package/lib/esm/hooks/use-global-static.js +152 -0
- package/lib/esm/hooks/use-initial-render.js +18 -0
- package/lib/esm/hooks/use-inner-ctx.js +100 -0
- package/lib/esm/hooks/use-props.js +102 -0
- package/lib/esm/hooks/use-table-columns.js +70 -0
- package/lib/esm/hooks/use-table-meta.js +51 -0
- package/lib/esm/hooks/use-update.js +52 -0
- package/lib/esm/index.js +38 -0
- package/lib/esm/index.scss.js +13 -0
- package/lib/esm/table.js +251 -0
- package/lib/esm/utils/cls.js +13 -0
- package/lib/esm/utils/fixed.js +48 -0
- package/lib/esm/utils/grouping.js +36 -0
- package/lib/esm/utils/state-merge.js +37 -0
- package/lib/types/body/index.d.ts +14 -0
- package/lib/types/body/wrapper.d.ts +18 -0
- package/lib/types/cell/aggregated.d.ts +35 -0
- package/lib/types/cell/custom.d.ts +19 -0
- package/lib/types/cell/dependency.d.ts +47 -0
- package/lib/types/cell/editing.d.ts +8 -0
- package/lib/types/cell/footer.d.ts +5 -0
- package/lib/types/cell/header.d.ts +5 -0
- package/lib/types/cell/index.d.ts +6 -0
- package/lib/types/const.d.ts +11 -0
- package/lib/types/container/base.d.ts +2 -0
- package/lib/types/container/bottom.d.ts +20 -0
- package/lib/types/container/col-group.d.ts +11 -0
- package/lib/types/container/column-virtual.d.ts +7 -0
- package/lib/types/container/ctx.d.ts +23 -0
- package/lib/types/container/full-virtual.d.ts +8 -0
- package/lib/types/container/hooks.d.ts +13 -0
- package/lib/types/container/index.d.ts +17 -0
- package/lib/types/container/row-virtual.d.ts +7 -0
- package/lib/types/container/type.d.ts +17 -0
- package/lib/types/container/wrapper.d.ts +12 -0
- package/lib/types/ctx.d.ts +41 -0
- package/lib/types/features/_overrides/aggregated.d.ts +2 -0
- package/lib/types/features/_overrides/getter.d.ts +2 -0
- package/lib/types/features/_overrides/grouping.d.ts +7 -0
- package/lib/types/features/_overrides/index.d.ts +5 -0
- package/lib/types/features/_overrides/overrides.d.ts +2 -0
- package/lib/types/features/_overrides/row-selection.d.ts +2 -0
- package/lib/types/features/async-data/getter.d.ts +9 -0
- package/lib/types/features/async-data/group.d.ts +1 -0
- package/lib/types/features/async-data/index.d.ts +6 -0
- package/lib/types/features/async-data/normal.d.ts +48 -0
- package/lib/types/features/async-data/type.d.ts +22 -0
- package/lib/types/features/async-data/use-data-fetcher.d.ts +22 -0
- package/lib/types/features/async-data/use-reset-data.d.ts +14 -0
- package/lib/types/features/column-grouping/get-grouping-config.d.ts +2 -0
- package/lib/types/features/column-grouping/index.d.ts +3 -0
- package/lib/types/features/column-grouping/use-opts.d.ts +12 -0
- package/lib/types/features/column-state.d.ts +15 -0
- package/lib/types/features/filter/bridge.d.ts +9 -0
- package/lib/types/features/filter/filter-fns/date.d.ts +6 -0
- package/lib/types/features/filter/filter-fns/index.d.ts +6 -0
- package/lib/types/features/filter/get-filter-config.d.ts +4 -0
- package/lib/types/features/filter/index.d.ts +8 -0
- package/lib/types/features/filter/use-opts.d.ts +62 -0
- package/lib/types/features/header-actions/components/column-collapsing.d.ts +4 -0
- package/lib/types/features/header-actions/get-actions.d.ts +13 -0
- package/lib/types/features/header-actions/index.d.ts +3 -0
- package/lib/types/features/header-actions/type.d.ts +20 -0
- package/lib/types/features/pagination/component.d.ts +15 -0
- package/lib/types/features/pagination/index.d.ts +4 -0
- package/lib/types/features/pagination/use-opts.d.ts +14 -0
- package/lib/types/features/pagination/use-state.d.ts +11 -0
- package/lib/types/features/row-controller.d.ts +101 -0
- package/lib/types/features/row-edit/actions.d.ts +12 -0
- package/lib/types/features/row-edit/hooks.d.ts +1 -0
- package/lib/types/features/row-edit/index.d.ts +2 -0
- package/lib/types/features/row-expanding/index.d.ts +3 -0
- package/lib/types/features/row-expanding/use-opts.d.ts +12 -0
- package/lib/types/features/row-expanding/wrapper.d.ts +11 -0
- package/lib/types/features/row-operation/buttons.d.ts +41 -0
- package/lib/types/features/row-operation/cell.d.ts +6 -0
- package/lib/types/features/row-operation/index.d.ts +18 -0
- package/lib/types/features/row-operation/wrapper.d.ts +3 -0
- package/lib/types/features/row-selection/cell.d.ts +62 -0
- package/lib/types/features/row-selection/const.d.ts +1 -0
- package/lib/types/features/row-selection/hooks/index.d.ts +6 -0
- package/lib/types/features/row-selection/hooks/use-click-select.d.ts +1 -0
- package/lib/types/features/row-selection/hooks/use-opts.d.ts +15 -0
- package/lib/types/features/row-selection/hooks/use-set-selected-row-keys.d.ts +9 -0
- package/lib/types/features/row-selection/hooks/use-sync-hover-style.d.ts +5 -0
- package/lib/types/features/row-selection/index.d.ts +7 -0
- package/lib/types/features/row-selection/indicator.d.ts +8 -0
- package/lib/types/features/row-selection/wrapper.d.ts +9 -0
- package/lib/types/features/setting-bridge.d.ts +14 -0
- package/lib/types/features/sorter/bridge.d.ts +8 -0
- package/lib/types/features/sorter/get-sorter-config.d.ts +7 -0
- package/lib/types/features/sorter/index.d.ts +8 -0
- package/lib/types/features/sorter/use-opts.d.ts +71 -0
- package/lib/types/field-bridge/bridge.d.ts +18 -0
- package/lib/types/field-bridge/index.d.ts +11 -0
- package/lib/types/field-bridge/toolbar.d.ts +9 -0
- package/lib/types/footer/index.d.ts +6 -0
- package/lib/types/footer/use-first-cell-patch.d.ts +1 -0
- package/lib/types/header/index.d.ts +17 -0
- package/lib/types/header/validate.d.ts +10 -0
- package/lib/types/hooks/use-get-fields-value.d.ts +14 -0
- package/lib/types/hooks/use-global-actions.d.ts +24 -0
- package/lib/types/hooks/use-global-static.d.ts +83 -0
- package/lib/types/hooks/use-initial-render.d.ts +1 -0
- package/lib/types/hooks/use-inner-ctx.d.ts +12 -0
- package/lib/types/hooks/use-props.d.ts +109 -0
- package/lib/types/hooks/use-table-columns.d.ts +11 -0
- package/lib/types/hooks/use-table-meta.d.ts +15 -0
- package/lib/types/hooks/use-update.d.ts +11 -0
- package/lib/types/index.d.ts +32 -0
- package/lib/types/table.d.ts +152 -0
- package/lib/types/utils/cls.d.ts +4 -0
- package/lib/types/utils/fixed.d.ts +11 -0
- package/lib/types/utils/grouping.d.ts +6 -0
- package/lib/types/utils/index.d.ts +5 -0
- package/lib/types/utils/meta.d.ts +8 -0
- package/lib/types/utils/state-merge.d.ts +14 -0
- package/package.json +90 -0
- package/type.d.ts +143 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type VirtualItem } from '@tanstack/react-virtual';
|
|
2
|
+
import type { VirtualizerOptions } from './type';
|
|
3
|
+
type VirtualizerResult = {
|
|
4
|
+
virtualItems: VirtualItem[];
|
|
5
|
+
padding: {
|
|
6
|
+
start: number;
|
|
7
|
+
end: number;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export declare function useRowVirtualizer(options?: VirtualizerOptions): VirtualizerResult;
|
|
11
|
+
export declare function useColumnVirtualizer(options?: VirtualizerOptions): VirtualizerResult;
|
|
12
|
+
export declare function useTableScroll(): void;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TableHeader, TableBody, TableFooter } from './wrapper';
|
|
3
|
+
import type { VirtualizeOpts } from './type';
|
|
4
|
+
export * from './type';
|
|
5
|
+
type TableContainerProps = React.PropsWithChildren<{
|
|
6
|
+
virtualize?: VirtualizeOpts;
|
|
7
|
+
}>;
|
|
8
|
+
export declare function TableContainer(props: TableContainerProps): JSX.Element;
|
|
9
|
+
export declare namespace TableContainer {
|
|
10
|
+
var Header: typeof TableHeader;
|
|
11
|
+
var Body: typeof TableBody;
|
|
12
|
+
var Footer: typeof TableFooter;
|
|
13
|
+
}
|
|
14
|
+
export { useTableContainer } from './ctx';
|
|
15
|
+
export type { TableStickyOpts } from './type';
|
|
16
|
+
export type { TableHeaderProps, TableFooterProps } from './wrapper';
|
|
17
|
+
export { BottomRender, type BottomRenderConfigType } from './bottom';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { VirtualizerOptions } from './type';
|
|
3
|
+
type RowVirtualContainerProps = React.PropsWithChildren<{
|
|
4
|
+
options?: VirtualizerOptions;
|
|
5
|
+
}>;
|
|
6
|
+
export declare function RowVirtualContainer(props: RowVirtualContainerProps): JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { VirtualizerOptions as OriginalOptions } from '@tanstack/react-virtual';
|
|
2
|
+
import type { BoolConfig } from '@hi-ui/schema-utils';
|
|
3
|
+
export type VirtualizerOptions = Partial<Omit<OriginalOptions<HTMLDivElement, HTMLDivElement>, 'count' | 'getScrollElement'>>;
|
|
4
|
+
export type VirtualizeOpts = {
|
|
5
|
+
row?: VirtualizerOptions;
|
|
6
|
+
column?: VirtualizerOptions;
|
|
7
|
+
};
|
|
8
|
+
export type VirtualizeConfig = {
|
|
9
|
+
row?: BoolConfig<VirtualizerOptions>;
|
|
10
|
+
column?: BoolConfig<VirtualizerOptions>;
|
|
11
|
+
};
|
|
12
|
+
export type TableStickyOpts = {
|
|
13
|
+
header?: boolean;
|
|
14
|
+
footer?: boolean;
|
|
15
|
+
headerTop?: number;
|
|
16
|
+
footerBottom?: number;
|
|
17
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type TableHeaderProps = React.PropsWithChildren<{
|
|
3
|
+
sticky?: boolean;
|
|
4
|
+
stickyOffset?: number;
|
|
5
|
+
}>;
|
|
6
|
+
export type TableFooterProps = React.PropsWithChildren<{
|
|
7
|
+
sticky?: boolean;
|
|
8
|
+
stickyOffset?: number;
|
|
9
|
+
}>;
|
|
10
|
+
export declare function TableHeader({ children, sticky, stickyOffset }: TableHeaderProps): JSX.Element;
|
|
11
|
+
export declare function TableBody(props: React.PropsWithChildren<unknown>): JSX.Element;
|
|
12
|
+
export declare function TableFooter({ children, sticky, stickyOffset }: TableFooterProps): JSX.Element;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Table, TableOptions, RowSelectionState, PaginationState, ColumnFiltersState, SortingState } from '@tanstack/react-table';
|
|
3
|
+
import type { SetState } from 'ahooks/es/useSetState';
|
|
4
|
+
import type { SubscriptionType } from '@hi-ui/use-subscription';
|
|
5
|
+
import type { ReadonlyRefObject } from '@hi-ui/schema-hooks';
|
|
6
|
+
import type { TableRowController } from './features/row-controller';
|
|
7
|
+
import type { TableCtxRefType } from './table';
|
|
8
|
+
import type { NormalizedProps } from './hooks/use-props';
|
|
9
|
+
import type { GlobalStaticConfigType } from './hooks/use-global-static';
|
|
10
|
+
import type { GlobalStaticActionsType } from './hooks/use-global-actions';
|
|
11
|
+
export type EditableSchemaTableCtxType<TData extends AnyObject = AnyObject> = {
|
|
12
|
+
table: Table<TData>;
|
|
13
|
+
setDynamicOpts: SetState<Partial<TableOptions<TData>>>;
|
|
14
|
+
subscription: SubscriptionType<TData[]>;
|
|
15
|
+
/** 虚拟滚动依赖的可滚动的容器元素 */
|
|
16
|
+
tableContainerRef: React.RefObject<HTMLDivElement>;
|
|
17
|
+
/** 行操作控制器 */
|
|
18
|
+
rowActions: TableRowController<TData>;
|
|
19
|
+
/** 行选择状态 */
|
|
20
|
+
rowSelectionState: SubscriptionType<RowSelectionState>;
|
|
21
|
+
/** 分页状态 */
|
|
22
|
+
paginationState: SubscriptionType<PaginationState>;
|
|
23
|
+
/** 筛选状态 */
|
|
24
|
+
filterState: SubscriptionType<ColumnFiltersState>;
|
|
25
|
+
/** 排序状态 */
|
|
26
|
+
sorterState: SubscriptionType<SortingState>;
|
|
27
|
+
/** 组件 props 的最新值 */
|
|
28
|
+
propsRef: ReadonlyRefObject<NormalizedProps<TData>>;
|
|
29
|
+
/** 全局静态配置 */
|
|
30
|
+
globalStaticRef: ReadonlyRefObject<GlobalStaticConfigType>;
|
|
31
|
+
/** 全局静态函数 */
|
|
32
|
+
globalActionsRef: ReadonlyRefObject<GlobalStaticActionsType<TData>>;
|
|
33
|
+
/** 获取内部暴露给外部的值 */
|
|
34
|
+
exposeCtxValueRef: ReadonlyRefObject<() => TableCtxRefType<TData>>;
|
|
35
|
+
};
|
|
36
|
+
export declare const EditableSchemaTableCtx: React.Context<EditableSchemaTableCtxType<AnyObject>>;
|
|
37
|
+
export declare function useEditableSchemaTableCtx<TData extends AnyObject = AnyObject>(): EditableSchemaTableCtxType<TData>;
|
|
38
|
+
type EditableSchemaTableInnerRefType<TData extends AnyObject> = ReadonlyRefObject<EditableSchemaTableCtxType<TData>>;
|
|
39
|
+
type EditableSchemaTablePropsRefType<TData extends AnyObject> = EditableSchemaTableCtxType<TData>['propsRef'];
|
|
40
|
+
type EditableSchemaTableGlobalStaticConfigType<TData extends AnyObject> = EditableSchemaTableCtxType<TData>['globalStaticRef'];
|
|
41
|
+
export { EditableSchemaTableCtx as EditTableCtx, useEditableSchemaTableCtx as useEditTableCtx, type EditableSchemaTableCtxType as EditTableCtxType, type EditableSchemaTableInnerRefType as InnerRefType, type EditableSchemaTablePropsRefType as PropsRefType, type EditableSchemaTableGlobalStaticConfigType as GlobalStaticRefType, };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type InnerRefType } from '../../ctx';
|
|
2
|
+
import type { GetDataSourceResType } from './normal';
|
|
3
|
+
export declare function AsyncDataGetter(): null;
|
|
4
|
+
type UseAsyncDataCtxType<TData extends AnyObject> = {
|
|
5
|
+
innerRef: InnerRefType<TData>;
|
|
6
|
+
};
|
|
7
|
+
export declare function useAsyncData<TData extends AnyObject>(ctx: UseAsyncDataCtxType<TData>): void;
|
|
8
|
+
export declare function validateResData<TData extends AnyObject>(data: unknown): data is GetDataSourceResType<TData>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const _ASYNC_DATA_FILTER_GROUP_IGNORE_ME_ = "_ASYNC_DATA_FILTER_GROUP_IGNORE_ME_";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { useGetDataSource } from './normal';
|
|
2
|
+
export type { GetDataSourceType, GetDataSourceBasicParamsType, GetDataSourceParamsType, GetDataSourceResType, InnerGetDataSourceType, InnerUpdateDataSourceType, } from './normal';
|
|
3
|
+
export { useResetDataSource, type InnerResetDataSourceType } from './use-reset-data';
|
|
4
|
+
export type { AsyncDataOptsType } from './type';
|
|
5
|
+
export { useDataFetcher, defineDataFetcher } from './use-data-fetcher';
|
|
6
|
+
export { _ASYNC_DATA_FILTER_GROUP_IGNORE_ME_ } from './group';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ColumnFiltersState, SortingState } from '@tanstack/react-table';
|
|
2
|
+
import { type PipeGetter } from '@hi-ui/schema-utils';
|
|
3
|
+
import type { InnerRefType } from '../../ctx';
|
|
4
|
+
import type { GetPageDataCtxType } from '../pagination/component';
|
|
5
|
+
export type GetDataSourceCtxType<TData extends AnyObject> = {
|
|
6
|
+
innerRef: InnerRefType<TData>;
|
|
7
|
+
};
|
|
8
|
+
export type GetDataSourceBasicParamsType = {
|
|
9
|
+
/**
|
|
10
|
+
* 分页信息
|
|
11
|
+
* @desc 启用分页时,分页信息必然存在
|
|
12
|
+
*/
|
|
13
|
+
pagination?: GetPageDataCtxType;
|
|
14
|
+
/**
|
|
15
|
+
* 表头筛选信息
|
|
16
|
+
* @desc 启用远程筛选时,表头筛选信息必然存在
|
|
17
|
+
*/
|
|
18
|
+
filters?: ColumnFiltersState;
|
|
19
|
+
/**
|
|
20
|
+
* 表头排序信息
|
|
21
|
+
* @desc 启用远程排序时,表头排序信息必然存在
|
|
22
|
+
*/
|
|
23
|
+
sorters?: SortingState;
|
|
24
|
+
};
|
|
25
|
+
export type GetDataSourceParamsType = AnyObject & GetDataSourceBasicParamsType & {
|
|
26
|
+
/**
|
|
27
|
+
* 原始参数
|
|
28
|
+
* - 默认为空,可由上层组件自行决定参数类型
|
|
29
|
+
*/
|
|
30
|
+
raw?: GetDataSourceBasicParamsType;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* 异步数据源的返回类型
|
|
34
|
+
* @desc 请注意,启用分页时,返回类型中必须包含 total/pageSize/current 字段
|
|
35
|
+
*/
|
|
36
|
+
export type GetDataSourceResType<TData extends AnyObject = AnyObject> = {
|
|
37
|
+
list: TData[];
|
|
38
|
+
total?: number;
|
|
39
|
+
pageSize?: number;
|
|
40
|
+
current?: number;
|
|
41
|
+
};
|
|
42
|
+
export type GetDataSourceType<TData extends AnyObject> = (params: GetDataSourceParamsType) => Promise<GetDataSourceResType<TData>>;
|
|
43
|
+
export type InnerGetDataSourceType<TData extends AnyObject> = (customParams?: PipeGetter<GetDataSourceParamsType>) => Promise<GetDataSourceResType<TData>>;
|
|
44
|
+
export type InnerUpdateDataSourceType = (customParams?: PipeGetter<GetDataSourceParamsType>) => Promise<void>;
|
|
45
|
+
export declare function useGetDataSource<TData extends AnyObject>(ctx: GetDataSourceCtxType<TData>): {
|
|
46
|
+
getDataSource: InnerGetDataSourceType<TData>;
|
|
47
|
+
updateDataSource: InnerUpdateDataSourceType;
|
|
48
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { BeCheckedPromiseType } from '@hi-ui/schema-utils';
|
|
2
|
+
import type { GetDataSourceParamsType, GetDataSourceType } from './normal';
|
|
3
|
+
export type AsyncDataOptsType<TData extends AnyObject = AnyObject> = {
|
|
4
|
+
/**
|
|
5
|
+
* 请求数据的方法
|
|
6
|
+
*/
|
|
7
|
+
request: GetDataSourceType<TData>;
|
|
8
|
+
/**
|
|
9
|
+
* 请求前的钩子
|
|
10
|
+
* @desc 返回值为 falsy 时,不执行 request 函数
|
|
11
|
+
*/
|
|
12
|
+
beforeRequest?: (params: GetDataSourceParamsType) => BeCheckedPromiseType<GetDataSourceParamsType>;
|
|
13
|
+
/**
|
|
14
|
+
* 是否阻止默认的初始请求
|
|
15
|
+
*/
|
|
16
|
+
blockInitialRequest?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* 是否启用数据完整性验证
|
|
19
|
+
* @desc 建议至少在开发环境下启用
|
|
20
|
+
*/
|
|
21
|
+
enableDataValidate?: boolean;
|
|
22
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Options as AhooksRequestOptions } from 'ahooks/es/useRequest/src/types';
|
|
2
|
+
import type { GetDataSourceType, GetDataSourceParamsType, GetDataSourceResType } from './normal';
|
|
3
|
+
/**
|
|
4
|
+
* 定义的可编辑表的异步数据请求方法
|
|
5
|
+
* @desc 默认需要手动调用 fetchData 方法
|
|
6
|
+
* @desc 本质是 ahooks 的 useRequest 方法
|
|
7
|
+
*/
|
|
8
|
+
export declare function useDataFetcher<TData extends AnyObject = AnyObject>(getter: GetDataSourceType<TData>, extraOpts?: AhooksRequestOptions<GetDataSourceResType<TData>, [GetDataSourceParamsType]>): {
|
|
9
|
+
runAsync: (params_0: GetDataSourceParamsType) => Promise<GetDataSourceResType<TData>>;
|
|
10
|
+
fetchData: (params_0: GetDataSourceParamsType) => Promise<GetDataSourceResType<TData>>;
|
|
11
|
+
loading: boolean;
|
|
12
|
+
data?: GetDataSourceResType<TData> | undefined;
|
|
13
|
+
error?: Error;
|
|
14
|
+
params: [] | [GetDataSourceParamsType];
|
|
15
|
+
cancel: import("ahooks/lib/useRequest/src/Fetch").default<TData_1, TParams>["cancel"];
|
|
16
|
+
refresh: import("ahooks/lib/useRequest/src/Fetch").default<TData_1, TParams>["refresh"];
|
|
17
|
+
refreshAsync: () => Promise<GetDataSourceResType<TData>>;
|
|
18
|
+
run: (params_0: GetDataSourceParamsType) => void;
|
|
19
|
+
mutate: (data?: GetDataSourceResType<TData> | ((oldData?: GetDataSourceResType<TData> | undefined) => GetDataSourceResType<TData> | undefined) | undefined) => void;
|
|
20
|
+
};
|
|
21
|
+
/** 定义表格异步数据请求方法 */
|
|
22
|
+
export declare function defineDataFetcher<TData extends AnyObject = AnyObject>(getter: GetDataSourceType<TData>): GetDataSourceType<TData>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { InnerRefType } from '../../ctx';
|
|
2
|
+
export type ResetDataSourceCtxType<TData extends AnyObject> = {
|
|
3
|
+
innerRef: InnerRefType<TData>;
|
|
4
|
+
};
|
|
5
|
+
export type InnerResetDataSourceType = (opts?: ResetDataSourceOpts) => Promise<void>;
|
|
6
|
+
export type ResetDataSourceOpts = {
|
|
7
|
+
/**
|
|
8
|
+
* 重置状态时,是否强制触发请求,并更新表格数据
|
|
9
|
+
* @desc 默认情况下,只有状态发生变化时才会触发请求
|
|
10
|
+
* @desc 启用后,无论状态是否发生变化,都会触发请求
|
|
11
|
+
*/
|
|
12
|
+
forceRequest?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare function useResetDataSource<TData extends AnyObject>(ctx: ResetDataSourceCtxType<TData>): InnerResetDataSourceType;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { GroupingOptions } from '@tanstack/react-table';
|
|
2
|
+
import { StaticOptsRefType } from '../../hooks/use-global-static';
|
|
3
|
+
export type GroupingOpts = {};
|
|
4
|
+
type UseGroupedOptsCtxType = {
|
|
5
|
+
staticOptsRef: StaticOptsRefType;
|
|
6
|
+
};
|
|
7
|
+
export declare function useRowGroupedOpts(ctx: UseGroupedOptsCtxType): GroupingOptions;
|
|
8
|
+
/**
|
|
9
|
+
* 获取列分组配置选项
|
|
10
|
+
*/
|
|
11
|
+
export declare function getRowGroupedOptions(ctx: UseGroupedOptsCtxType): GroupingOptions;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { VisibilityState, ColumnPinningState, ColumnOrderState } from '@tanstack/table-core';
|
|
2
|
+
import type { FieldConfigType } from '@hi-ui/schema-core';
|
|
3
|
+
import type { EditableSchemaTableProps } from '../table';
|
|
4
|
+
export type ColumnState = {
|
|
5
|
+
columnVisibility: VisibilityState;
|
|
6
|
+
columnPinning: ColumnPinningState;
|
|
7
|
+
columnOrder: ColumnOrderState;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* 根据字段配置生成表格列的初始状态
|
|
11
|
+
*/
|
|
12
|
+
export declare function getInitialColumnState(fields: FieldConfigType[]): ColumnState;
|
|
13
|
+
type UseInitialStateCtxType<TData extends AnyObject> = Pick<EditableSchemaTableProps<TData>, 'fields'>;
|
|
14
|
+
export declare function useInitialColumnState<TData extends AnyObject>(ctx: UseInitialStateCtxType<TData>): ColumnState;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { HeaderContext } from '@tanstack/react-table';
|
|
2
|
+
import type { FieldConfigType, FieldFilterConfigType } from '@hi-ui/schema-core';
|
|
3
|
+
type TableFilterBridgeProps<TData extends AnyObject> = {
|
|
4
|
+
column: HeaderContext<TData, unknown>['column'];
|
|
5
|
+
field: FieldConfigType;
|
|
6
|
+
filter?: FieldFilterConfigType;
|
|
7
|
+
};
|
|
8
|
+
export declare function TableFilterBridge<TData extends AnyObject>(props: TableFilterBridgeProps<TData>): JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { BuiltInFilterFn as TanStackBuiltInFilterFn } from '@tanstack/react-table';
|
|
2
|
+
import type { FieldConfigType, FieldFilterConfigType } from '@hi-ui/schema-core';
|
|
3
|
+
export type BuiltInFilterFn = TanStackBuiltInFilterFn | 'inDateRange';
|
|
4
|
+
export declare function getFilterConfig(field: FieldConfigType): FieldFilterConfigType | undefined;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ColumnFiltersState } from '@tanstack/react-table';
|
|
2
|
+
export { useFilterOpts, getFilterOptions } from './use-opts';
|
|
3
|
+
export { getFilterConfig } from './get-filter-config';
|
|
4
|
+
export { TableFilterBridge } from './bridge';
|
|
5
|
+
export type { FilterOpts } from './use-opts';
|
|
6
|
+
export declare function useFilterState(): {
|
|
7
|
+
filterState: import("@hi-ui/use-subscription").SubscriptionType<ColumnFiltersState>;
|
|
8
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { ColumnFiltersState } from '@tanstack/react-table';
|
|
2
|
+
import { type OnChangeFnCtxType } from '../../utils';
|
|
3
|
+
import type { InnerRefType } from '../../ctx';
|
|
4
|
+
import type { StaticOptsRefType } from '../../hooks/use-global-static';
|
|
5
|
+
export type FilterOpts = {
|
|
6
|
+
remote?: boolean;
|
|
7
|
+
onChange?: (state: ColumnFiltersState, ctx: OnChangeFnCtxType<ColumnFiltersState>) => void;
|
|
8
|
+
};
|
|
9
|
+
type UseFilterOptsCtxType<TData extends AnyObject> = {
|
|
10
|
+
innerRef: InnerRefType<TData>;
|
|
11
|
+
staticOptsRef: StaticOptsRefType;
|
|
12
|
+
};
|
|
13
|
+
export declare function useFilterOpts<TData extends AnyObject>(ctx: UseFilterOptsCtxType<TData>): {
|
|
14
|
+
manualFiltering?: undefined;
|
|
15
|
+
getFacetedUniqueValues?: undefined;
|
|
16
|
+
onColumnFiltersChange?: undefined;
|
|
17
|
+
filterFns?: undefined;
|
|
18
|
+
getFilteredRowModel?: undefined;
|
|
19
|
+
} | {
|
|
20
|
+
manualFiltering: boolean;
|
|
21
|
+
getFacetedUniqueValues: (table: import("@tanstack/react-table").Table<TData>, columnId: string) => () => Map<any, number>;
|
|
22
|
+
onColumnFiltersChange: import("@tanstack/react-table").OnChangeFn<ColumnFiltersState>;
|
|
23
|
+
filterFns: {
|
|
24
|
+
inDateRange: import("@tanstack/react-table").FilterFn<AnyObject>;
|
|
25
|
+
};
|
|
26
|
+
getFilteredRowModel?: undefined;
|
|
27
|
+
} | {
|
|
28
|
+
manualFiltering: boolean;
|
|
29
|
+
getFilteredRowModel: (table: import("@tanstack/react-table").Table<TData>) => () => import("@tanstack/react-table").RowModel<TData>;
|
|
30
|
+
getFacetedUniqueValues: (table: import("@tanstack/react-table").Table<TData>, columnId: string) => () => Map<any, number>;
|
|
31
|
+
onColumnFiltersChange: import("@tanstack/react-table").OnChangeFn<ColumnFiltersState>;
|
|
32
|
+
filterFns: {
|
|
33
|
+
inDateRange: import("@tanstack/react-table").FilterFn<AnyObject>;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* 获取表格筛选配置选项
|
|
38
|
+
*/
|
|
39
|
+
export declare function getFilterOptions<TData extends AnyObject>(ctx: UseFilterOptsCtxType<TData>): {
|
|
40
|
+
manualFiltering?: undefined;
|
|
41
|
+
getFacetedUniqueValues?: undefined;
|
|
42
|
+
onColumnFiltersChange?: undefined;
|
|
43
|
+
filterFns?: undefined;
|
|
44
|
+
getFilteredRowModel?: undefined;
|
|
45
|
+
} | {
|
|
46
|
+
manualFiltering: boolean;
|
|
47
|
+
getFacetedUniqueValues: (table: import("@tanstack/react-table").Table<TData>, columnId: string) => () => Map<any, number>;
|
|
48
|
+
onColumnFiltersChange: import("@tanstack/react-table").OnChangeFn<ColumnFiltersState>;
|
|
49
|
+
filterFns: {
|
|
50
|
+
inDateRange: import("@tanstack/react-table").FilterFn<AnyObject>;
|
|
51
|
+
};
|
|
52
|
+
getFilteredRowModel?: undefined;
|
|
53
|
+
} | {
|
|
54
|
+
manualFiltering: boolean;
|
|
55
|
+
getFilteredRowModel: (table: import("@tanstack/react-table").Table<TData>) => () => import("@tanstack/react-table").RowModel<TData>;
|
|
56
|
+
getFacetedUniqueValues: (table: import("@tanstack/react-table").Table<TData>, columnId: string) => () => Map<any, number>;
|
|
57
|
+
onColumnFiltersChange: import("@tanstack/react-table").OnChangeFn<ColumnFiltersState>;
|
|
58
|
+
filterFns: {
|
|
59
|
+
inDateRange: import("@tanstack/react-table").FilterFn<AnyObject>;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { FieldCustomHeaderActionsCtxType } from '../type';
|
|
2
|
+
type ColumnCollapsingActionProps = Pick<FieldCustomHeaderActionsCtxType, 'column' | 'field' | 'table'>;
|
|
3
|
+
export declare function ColumnCollapsingAction(props: ColumnCollapsingActionProps): JSX.Element | null;
|
|
4
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { HeaderContext } from '@tanstack/react-table';
|
|
2
|
+
import type { FieldConfigType } from '@hi-ui/schema-core';
|
|
3
|
+
import type { GlobalStaticRefType } from '../../ctx';
|
|
4
|
+
type GetHeaderActionsCtxType<TData extends AnyObject> = Pick<HeaderContext<TData, unknown>, 'column' | 'table'> & {
|
|
5
|
+
field: FieldConfigType;
|
|
6
|
+
globalStaticRef: GlobalStaticRefType<TData>;
|
|
7
|
+
};
|
|
8
|
+
export declare function getHeaderActions<TData extends AnyObject>(props: GetHeaderActionsCtxType<TData>): {
|
|
9
|
+
filterAvailable: boolean;
|
|
10
|
+
sorterAvailable: boolean;
|
|
11
|
+
elements: any;
|
|
12
|
+
} | null;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Table, Column } from '@tanstack/react-table';
|
|
2
|
+
import type { FieldConfigType } from '@hi-ui/schema-core';
|
|
3
|
+
export type FieldCustomHeaderActionsCtxType = {
|
|
4
|
+
/** 字段配置 */
|
|
5
|
+
field: FieldConfigType;
|
|
6
|
+
builtin: {
|
|
7
|
+
sorter: React.ReactNode;
|
|
8
|
+
filter: React.ReactNode;
|
|
9
|
+
};
|
|
10
|
+
/** 表格实例 */
|
|
11
|
+
table: Table<AnyType>;
|
|
12
|
+
/** 表格实例 */
|
|
13
|
+
column: Column<AnyType, unknown>;
|
|
14
|
+
};
|
|
15
|
+
export type FieldCustomHeaderActionComponent = React.ComponentType<FieldCustomHeaderActionsCtxType>;
|
|
16
|
+
export type FieldCustomHeaderActionsFn = (ctx: FieldCustomHeaderActionsCtxType) => React.ReactNode[];
|
|
17
|
+
export type HeaderActionOptsType = {
|
|
18
|
+
/** 是否仅在 hover 时显示 */
|
|
19
|
+
onlyVisibleOnHover?: boolean;
|
|
20
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PaginationProps as HiUIPaginationProps } from '@hi-ui/pagination';
|
|
2
|
+
export type GetPageDataCtxType = {
|
|
3
|
+
current: number;
|
|
4
|
+
pageSize: number;
|
|
5
|
+
};
|
|
6
|
+
export type PaginationProps = Omit<Partial<HiUIPaginationProps>, 'current' | 'total'> & {
|
|
7
|
+
/** 总条数 */
|
|
8
|
+
total?: HiUIPaginationProps['total'];
|
|
9
|
+
/**
|
|
10
|
+
* pageSize 变化时,自动重置页码至首页
|
|
11
|
+
* - 默认会回到 current > pageCount ? pageCount : current
|
|
12
|
+
*/
|
|
13
|
+
autoResetCurrent?: boolean;
|
|
14
|
+
};
|
|
15
|
+
export declare function Pagination(props: PaginationProps): JSX.Element;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PaginationOptions, TableOptions } from '@tanstack/react-table';
|
|
2
|
+
import type { InnerRefType } from '../../ctx';
|
|
3
|
+
import type { StaticOptsRefType } from '../../hooks/use-global-static';
|
|
4
|
+
type UsePaginationOptsCtxType<TData extends AnyObject = AnyObject> = {
|
|
5
|
+
innerRef: InnerRefType<TData>;
|
|
6
|
+
staticOptsRef: StaticOptsRefType;
|
|
7
|
+
};
|
|
8
|
+
export declare function usePaginationOpts<TData extends AnyObject>(ctx: UsePaginationOptsCtxType<TData>): PaginationOptions & Pick<TableOptions<TData>, "initialState">;
|
|
9
|
+
export declare const dftPageSize = 10;
|
|
10
|
+
/**
|
|
11
|
+
* 获取表格分页配置选项
|
|
12
|
+
*/
|
|
13
|
+
export declare function getPaginationOptions<TData extends AnyObject>(ctx: UsePaginationOptsCtxType<TData>): PaginationOptions & Pick<TableOptions<TData>, 'initialState'>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { PaginationState } from '@tanstack/react-table';
|
|
2
|
+
import { type SubscriptionType } from '@hi-ui/use-subscription';
|
|
3
|
+
import type { PropsRefType } from '../../ctx';
|
|
4
|
+
type UsePaginationStateCtx<TData extends AnyObject> = {
|
|
5
|
+
propsRef: PropsRefType<TData>;
|
|
6
|
+
subscription: SubscriptionType<TData[]>;
|
|
7
|
+
};
|
|
8
|
+
export declare function usePaginationState<TData extends AnyObject>(ctx: UsePaginationStateCtx<TData>): {
|
|
9
|
+
paginationState: SubscriptionType<PaginationState>;
|
|
10
|
+
};
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { type SubscriptionType } from '@hi-ui/use-subscription';
|
|
2
|
+
import type { EditableSchemaTableCtxType } from '../ctx';
|
|
3
|
+
type TableRowControllerExtraOpts = {
|
|
4
|
+
/** 是否开启行编辑 */
|
|
5
|
+
rowEdit?: boolean;
|
|
6
|
+
propsRef?: EditableSchemaTableCtxType<AnyType>['propsRef'];
|
|
7
|
+
};
|
|
8
|
+
export declare class TableRowController<TData extends AnyObject = AnyObject> {
|
|
9
|
+
/** 表格数据订阅 */
|
|
10
|
+
private subscription;
|
|
11
|
+
/** 当前正在编辑的行索引订阅 */
|
|
12
|
+
editingSubscription: SubscriptionType<Record<string, boolean>> | null;
|
|
13
|
+
/** 当前正在编辑的行索引 */
|
|
14
|
+
private editingIndex;
|
|
15
|
+
private propsRef;
|
|
16
|
+
private onValuesChange?;
|
|
17
|
+
private afterRowsOperation;
|
|
18
|
+
constructor(subscription: SubscriptionType<TData[]>, opts?: TableRowControllerExtraOpts);
|
|
19
|
+
private get isEditing();
|
|
20
|
+
/** 检查是否处于编辑状态 */
|
|
21
|
+
private checkEditing;
|
|
22
|
+
/**
|
|
23
|
+
* 在指定位置添加新行
|
|
24
|
+
* @param data 行数据
|
|
25
|
+
* @param index 插入位置索引,可选,默认添加到末尾。如果为负数则插入到开头,如果超出长度则插入到末尾
|
|
26
|
+
*/
|
|
27
|
+
addRow(data: Partial<TData>, index?: number): void;
|
|
28
|
+
/**
|
|
29
|
+
* 删除指定行
|
|
30
|
+
* @param index 要删除的行索引
|
|
31
|
+
*/
|
|
32
|
+
deleteRow(index: number): void;
|
|
33
|
+
/**
|
|
34
|
+
* 批量添加多行
|
|
35
|
+
* @param rows 要添加的行数据数组
|
|
36
|
+
* @param index 插入位置索引,可选,默认添加到末尾。如果为负数则插入到开头,如果超出长度则插入到末尾
|
|
37
|
+
*/
|
|
38
|
+
addRows(rows: Partial<TData>[], index?: number): void;
|
|
39
|
+
/**
|
|
40
|
+
* 批量删除多行
|
|
41
|
+
* @param indexes 要删除的行索引数组,会自动按从大到小排序处理
|
|
42
|
+
*/
|
|
43
|
+
deleteRows(indexes: number[]): void;
|
|
44
|
+
/**
|
|
45
|
+
* 复制指定行
|
|
46
|
+
* @param sourceIndex 要复制的行索引
|
|
47
|
+
* @param options 复制选项
|
|
48
|
+
* @param options.targetIndex 目标位置索引,可选,默认复制到原位置的下一行
|
|
49
|
+
* @param options.rowKey 行数据中用于标识唯一性的字段名,默认为 'id'
|
|
50
|
+
*/
|
|
51
|
+
copyRow(sourceIndex: number, options?: {
|
|
52
|
+
targetIndex?: number;
|
|
53
|
+
rowKey?: string;
|
|
54
|
+
}): void;
|
|
55
|
+
/**
|
|
56
|
+
* 交换两行位置
|
|
57
|
+
* @param sourceIndex 源行索引
|
|
58
|
+
* @param targetIndex 目标行索引
|
|
59
|
+
*/
|
|
60
|
+
swapRow(sourceIndex: number, targetIndex: number): void;
|
|
61
|
+
/**
|
|
62
|
+
* 移动行到指定位置
|
|
63
|
+
* @param sourceIndex 要移动的行索引
|
|
64
|
+
* @param targetIndex 目标位置索引
|
|
65
|
+
*/
|
|
66
|
+
moveRow(sourceIndex: number, targetIndex: number): void;
|
|
67
|
+
/**
|
|
68
|
+
* 获取当前所有数据
|
|
69
|
+
* @returns 当前表格的所有行数据
|
|
70
|
+
*/
|
|
71
|
+
getData(): TData[];
|
|
72
|
+
/**
|
|
73
|
+
* 获取指定行数据
|
|
74
|
+
* @param index 行索引
|
|
75
|
+
* @returns 指定行的数据,如果索引无效则返回 undefined
|
|
76
|
+
*/
|
|
77
|
+
getRow(index: number): TData | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* 开始编辑指定行
|
|
80
|
+
* @param index 要编辑的行索引
|
|
81
|
+
*/
|
|
82
|
+
startEdit(index: number): void;
|
|
83
|
+
/**
|
|
84
|
+
* 保存当前编辑行的修改
|
|
85
|
+
*/
|
|
86
|
+
saveEdit(): void;
|
|
87
|
+
/**
|
|
88
|
+
* 取消当前行的编辑,还原数据
|
|
89
|
+
*/
|
|
90
|
+
cancelEdit(): void;
|
|
91
|
+
/**
|
|
92
|
+
* 判断指定行是否处于编辑状态
|
|
93
|
+
* @param index 行索引
|
|
94
|
+
*/
|
|
95
|
+
isRowEditing(index: number): boolean;
|
|
96
|
+
/**
|
|
97
|
+
* 获取当前正在编辑的行索引
|
|
98
|
+
*/
|
|
99
|
+
getEditingIndex(): number | null;
|
|
100
|
+
}
|
|
101
|
+
export type { TableRowController as TableRowControllerType };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TableCtxRefType } from '../../table';
|
|
2
|
+
/**
|
|
3
|
+
* 创建行编辑按钮
|
|
4
|
+
* @param rowActions 行操作对象
|
|
5
|
+
* @param index 行索引
|
|
6
|
+
* @returns 编辑按钮对象
|
|
7
|
+
*/
|
|
8
|
+
export declare function createEditButtons(rowActions: TableCtxRefType<AnyType>['rowActions'], index: number): {
|
|
9
|
+
edit: JSX.Element;
|
|
10
|
+
save: JSX.Element;
|
|
11
|
+
cancel: JSX.Element;
|
|
12
|
+
};
|