gantri-components 2.38.0 → 2.39.0-beta.2
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/dist/components/dropdown-menu/dropdown-menu.styles.d.ts +3 -1
- package/dist/components/dropdown-menu/dropdown-menu.types.d.ts +2 -0
- package/dist/components/icon/generated/ui-control/ExlamationCircleFilled.d.ts +3 -0
- package/dist/components/icon/generated/ui-control/ExlamationCircleFilled24.d.ts +3 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/paging/__tests__/paging.test.d.ts +1 -0
- package/dist/components/paging/index.d.ts +1 -0
- package/dist/components/paging/paging.d.ts +5 -0
- package/dist/components/paging/paging.presets.d.ts +2 -0
- package/dist/components/paging/paging.styles.d.ts +3 -0
- package/dist/components/paging/paging.types.d.ts +8 -0
- package/dist/components/table/components/table-actions-wrapper/__test__/table-actions-wrapper.test.d.ts +1 -0
- package/dist/components/table/components/table-actions-wrapper/components/search/__tests__/search.test.d.ts +1 -0
- package/dist/components/table/components/table-actions-wrapper/components/search/index.d.ts +1 -0
- package/dist/components/table/components/table-actions-wrapper/components/search/search.d.ts +5 -0
- package/dist/components/table/components/table-actions-wrapper/components/search/search.presets.d.ts +2 -0
- package/dist/components/table/components/table-actions-wrapper/components/search/search.styles.d.ts +1 -0
- package/dist/components/table/components/table-actions-wrapper/components/search/search.types.d.ts +9 -0
- package/dist/components/table/components/table-actions-wrapper/components/sort/helpers/get-sort-mapping/get-sort-mapping.d.ts +3 -0
- package/dist/components/table/components/table-actions-wrapper/components/sort/helpers/get-sort-mapping/get-sort-mapping.types.d.ts +2 -0
- package/dist/components/table/components/table-actions-wrapper/components/sort/helpers/get-sort-mapping/index.d.ts +1 -0
- package/dist/components/table/components/table-actions-wrapper/components/sort/helpers/get-sort-options/__tests__/get-sort-options.test.d.ts +1 -0
- package/dist/components/table/components/table-actions-wrapper/components/sort/helpers/get-sort-options/get-sort-options.d.ts +8 -0
- package/dist/components/table/components/table-actions-wrapper/components/sort/helpers/get-sort-options/get-sort-options.types.d.ts +2 -0
- package/dist/components/table/components/table-actions-wrapper/components/sort/helpers/get-sort-options/index.d.ts +1 -0
- package/dist/components/table/components/table-actions-wrapper/components/sort/index.d.ts +1 -0
- package/dist/components/table/components/table-actions-wrapper/components/sort/sort.d.ts +2 -0
- package/dist/components/table/components/table-actions-wrapper/components/sort/sort.styles.d.ts +2 -0
- package/dist/components/table/components/table-actions-wrapper/components/sort/sort.types.d.ts +24 -0
- package/dist/components/table/components/table-actions-wrapper/index.d.ts +1 -0
- package/dist/components/table/components/table-actions-wrapper/table-actions-wrapper.d.ts +4 -0
- package/dist/components/table/components/table-actions-wrapper/table-actions-wrapper.types.d.ts +28 -0
- package/dist/components/table/components/table-footer/index.d.ts +1 -0
- package/dist/components/table/components/table-footer/table-footer.d.ts +7 -0
- package/dist/components/table/components/table-footer/table-footer.types.d.ts +4 -0
- package/dist/components/table/components/table-header/index.d.ts +1 -0
- package/dist/components/table/components/table-header/table-header.d.ts +7 -0
- package/dist/components/table/components/table-header/table-header.styles.d.ts +3 -0
- package/dist/components/table/components/table-header/table-header.types.d.ts +6 -0
- package/dist/components/table/components/table-row/hooks/use-drag-and-drop/index.d.ts +1 -0
- package/dist/components/table/components/table-row/hooks/use-drag-and-drop/use-drag-and-drop.d.ts +11 -0
- package/dist/components/table/components/table-row/hooks/use-drag-and-drop/use-drag-and-drop.types.d.ts +9 -0
- package/dist/components/table/components/table-row/index.d.ts +1 -0
- package/dist/components/table/components/table-row/table-row.constants.d.ts +10 -0
- package/dist/components/table/components/table-row/table-row.d.ts +7 -0
- package/dist/components/table/components/table-row/table-row.styles.d.ts +4 -0
- package/dist/components/table/components/table-row/table-row.types.d.ts +12 -0
- package/dist/components/table/helpers/add-missing-ids/index.d.ts +7 -0
- package/dist/components/table/helpers/hyphenate-column-id/hyphenate-column-id.d.ts +1 -0
- package/dist/components/table/helpers/hyphenate-column-id/index.d.ts +1 -0
- package/dist/components/table/hooks/use-move-row/index.d.ts +1 -0
- package/dist/components/table/hooks/use-move-row/use-move-row.d.ts +9 -0
- package/dist/components/table/hooks/use-move-row/use-move-row.types.d.ts +5 -0
- package/dist/components/table/hooks/use-track-sticky-cells/index.d.ts +1 -0
- package/dist/components/table/hooks/use-track-sticky-cells/use-track-sticky-cells.d.ts +3 -0
- package/dist/components/table/hooks/use-track-sticky-cells/use-track-sticky-cells.types.d.ts +7 -0
- package/dist/components/table/index.d.ts +3 -0
- package/dist/components/table/table.d.ts +10 -0
- package/dist/components/table/table.presets.d.ts +2 -0
- package/dist/components/table/table.styles.d.ts +4 -0
- package/dist/components/table/table.types.d.ts +44 -0
- package/dist/helpers/format-as-locale-number/format-as-locale-number.d.ts +6 -0
- package/dist/helpers/format-as-locale-number/format-as-locale-number.types.d.ts +3 -0
- package/dist/helpers/format-as-locale-number/index.d.ts +1 -0
- package/dist/helpers/mark-sticky-elements/__tests__/mark-sticky-elements.test.d.ts +1 -0
- package/dist/helpers/mark-sticky-elements/__tests__/setup.d.ts +8 -0
- package/dist/helpers/mark-sticky-elements/helpers/get-intersection-observer-callback/__tests__/get-intersection-observer-callback.test.d.ts +1 -0
- package/dist/helpers/mark-sticky-elements/helpers/get-intersection-observer-callback/get-intersection-observer-callback.d.ts +2 -0
- package/dist/helpers/mark-sticky-elements/helpers/get-intersection-observer-callback/get-intersection-observer-callback.types.d.ts +8 -0
- package/dist/helpers/mark-sticky-elements/helpers/get-intersection-observer-callback/index.d.ts +1 -0
- package/dist/helpers/mark-sticky-elements/index.d.ts +1 -0
- package/dist/helpers/mark-sticky-elements/mark-sticky-elements.constants.d.ts +2 -0
- package/dist/helpers/mark-sticky-elements/mark-sticky-elements.d.ts +28 -0
- package/dist/helpers/mark-sticky-elements/mark-sticky-elements.types.d.ts +28 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +1 -7
- package/dist/index.esm.js +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/setupTests.d.ts +9 -0
- package/package.json +7 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Property } from 'csstype';
|
|
1
2
|
export declare const StyledContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
|
|
2
3
|
$hasHeader?: boolean | undefined;
|
|
3
4
|
$noShadow: boolean;
|
|
@@ -5,6 +6,7 @@ export declare const StyledContainer: import("styled-components").StyledComponen
|
|
|
5
6
|
export declare const StyledHeader: import("styled-components").StyledComponent<"header", import("styled-components").DefaultTheme, {}, never>;
|
|
6
7
|
export declare const StyledItem: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {
|
|
7
8
|
$basic: boolean;
|
|
8
|
-
$disabled
|
|
9
|
+
$disabled: boolean | undefined;
|
|
10
|
+
$justifyContent: Property.JustifyContent | undefined;
|
|
9
11
|
$selected: boolean;
|
|
10
12
|
}, never>;
|
|
@@ -8,6 +8,8 @@ export interface DropdownMenuProps<T = Record<string, unknown>> {
|
|
|
8
8
|
idProperty?: keyof T;
|
|
9
9
|
/** Can optionally include `disabled: true` to any index to disable that item. */
|
|
10
10
|
items: T[];
|
|
11
|
+
/** Sets the alignment of the dropdown items. */
|
|
12
|
+
justifyContent?: Property.JustifyContent;
|
|
11
13
|
keyProperty?: (item?: T) => string;
|
|
12
14
|
labelProperty?: keyof T | ((item?: T) => string);
|
|
13
15
|
labelPropertyTx?: (item?: T) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Paging } from './paging';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const StyledFlex: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("../flex/flex.types").FlexProps & import("react").RefAttributes<import("../flex/flex.types").FlexProps>>, import("styled-components").DefaultTheme, {}, never>;
|
|
3
|
+
export declare const StyledPagingButton: import("styled-components").StyledComponent<import("react").FC<import("../button/button.types").ButtonProps>, import("styled-components").DefaultTheme, {}, never>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './search';
|
package/dist/components/table/components/table-actions-wrapper/components/search/search.styles.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const StyledSearchInputWrapper: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
package/dist/components/table/components/table-actions-wrapper/components/search/search.types.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TextFieldProps } from '../../../../../text-field';
|
|
2
|
+
export interface SearchProps extends Partial<SearchDefaultProps> {
|
|
3
|
+
onChange: TextFieldProps['onTextChange'];
|
|
4
|
+
onFocus?: TextFieldProps['onFocus'];
|
|
5
|
+
}
|
|
6
|
+
export interface SearchDefaultProps {
|
|
7
|
+
placeholder: string;
|
|
8
|
+
value: string;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './get-sort-mapping';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SortInfo, TableSortField } from '../../sort.types';
|
|
2
|
+
interface MappedSortItem<SortingField = string> {
|
|
3
|
+
id: string;
|
|
4
|
+
label: string;
|
|
5
|
+
value: SortInfo<SortingField>;
|
|
6
|
+
}
|
|
7
|
+
export declare const getSortOptions: <SortingField = string>(sortingOptions?: TableSortField<SortingField>[]) => MappedSortItem<SortingField>[];
|
|
8
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './get-sort-options';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './sort';
|
package/dist/components/table/components/table-actions-wrapper/components/sort/sort.types.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface SortProps {
|
|
2
|
+
current: SortInfo;
|
|
3
|
+
disabled?: boolean;
|
|
4
|
+
fields: TableSortField<string>[];
|
|
5
|
+
onSort: (sortInfo: SortInfo) => void;
|
|
6
|
+
}
|
|
7
|
+
export interface SortInfo<SortingField = string> {
|
|
8
|
+
label?: string;
|
|
9
|
+
sortingField: SortingField;
|
|
10
|
+
sortingType?: SortingType;
|
|
11
|
+
}
|
|
12
|
+
export type SortingType = 'ASC' | 'DESC';
|
|
13
|
+
export type TableSortField<SortingField = string> = {
|
|
14
|
+
bidirectional?: never;
|
|
15
|
+
label: string;
|
|
16
|
+
sortingField: SortingField;
|
|
17
|
+
/** If not provided, defaults to 'DESC' */
|
|
18
|
+
sortingType?: SortingType;
|
|
19
|
+
} | {
|
|
20
|
+
bidirectional: true;
|
|
21
|
+
label: string;
|
|
22
|
+
sortingField: SortingField;
|
|
23
|
+
sortingType?: never;
|
|
24
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './table-actions-wrapper';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { TableActionsWrapperProps } from './table-actions-wrapper.types';
|
|
3
|
+
/** Wraps the table with relevant components for paging, filters, sort, and table actions. */
|
|
4
|
+
export declare const TableActionsWrapper: (props: PropsWithChildren<TableActionsWrapperProps>) => JSX.Element;
|
package/dist/components/table/components/table-actions-wrapper/table-actions-wrapper.types.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { JSXElementConstructor } from 'react';
|
|
2
|
+
import { PagingProps } from '../../../paging/paging.types';
|
|
3
|
+
import { SortProps } from './components/sort/sort.types';
|
|
4
|
+
export type FiltersProps = {
|
|
5
|
+
count: number;
|
|
6
|
+
filtersContent: JSX.Element;
|
|
7
|
+
numActive: number;
|
|
8
|
+
onApply: () => void;
|
|
9
|
+
onClose: () => void;
|
|
10
|
+
onReset: () => void;
|
|
11
|
+
};
|
|
12
|
+
export interface SearchProps {
|
|
13
|
+
onSearch: (value: string) => void;
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
value: string;
|
|
16
|
+
}
|
|
17
|
+
export interface CustomActionProps {
|
|
18
|
+
Component: JSXElementConstructor<Record<never, never>>;
|
|
19
|
+
position?: 'left' | 'right';
|
|
20
|
+
}
|
|
21
|
+
export interface TableActionsWrapperProps {
|
|
22
|
+
className: string | undefined;
|
|
23
|
+
customAction: CustomActionProps | undefined;
|
|
24
|
+
filters: FiltersProps | undefined;
|
|
25
|
+
paging: PagingProps | undefined;
|
|
26
|
+
search: SearchProps | undefined;
|
|
27
|
+
sorting: SortProps | undefined;
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './table-footer';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RowData } from '@tanstack/react-table';
|
|
2
|
+
import { TableFooterProps } from './table-footer.types';
|
|
3
|
+
export declare const TableFooter: <DataType extends RowData<{
|
|
4
|
+
[key: string]: unknown;
|
|
5
|
+
id: string | number;
|
|
6
|
+
subRows?: any[] | undefined;
|
|
7
|
+
}>>(props: TableFooterProps<DataType>) => JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './table-header';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RowData } from '@tanstack/react-table';
|
|
2
|
+
import { TableHeaderProps } from './table-header.types';
|
|
3
|
+
export declare const TableHeader: <DataType extends RowData<{
|
|
4
|
+
[key: string]: unknown;
|
|
5
|
+
id: string | number;
|
|
6
|
+
subRows?: any[] | undefined;
|
|
7
|
+
}>>(props: TableHeaderProps<DataType>) => JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './use-drag-and-drop';
|
package/dist/components/table/components/table-row/hooks/use-drag-and-drop/use-drag-and-drop.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { RowData } from '@tanstack/react-table';
|
|
3
|
+
import { UseDragAndDropProps } from './use-drag-and-drop.types';
|
|
4
|
+
export declare const useDragAndDrop: <DataType extends RowData<{
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
id: string | number;
|
|
7
|
+
subRows?: any[] | undefined;
|
|
8
|
+
}>>(props: UseDragAndDropProps<DataType>) => {
|
|
9
|
+
dragAndDropRef: import("react").RefObject<HTMLTableRowElement>;
|
|
10
|
+
isDragging: boolean;
|
|
11
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Row, RowData } from '@tanstack/react-table';
|
|
2
|
+
export interface UseDragAndDropProps<DataType extends RowData> {
|
|
3
|
+
enableReordering: boolean;
|
|
4
|
+
handleOnReorder: () => Promise<void>;
|
|
5
|
+
index: number;
|
|
6
|
+
isSubRow: boolean;
|
|
7
|
+
moveRow: (startIndex: number, endIndex: number) => void;
|
|
8
|
+
row: Row<DataType>;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './table-row';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** See `RowStatusValue` type for possible values. */
|
|
2
|
+
export declare const dataAttrRowStatus: "data-row-status";
|
|
3
|
+
export declare const dataAttrRowIsClickable: "data-row-is-clickable";
|
|
4
|
+
export declare const dataAttrRowHighlightOnHover: "data-row-highlight-on-hover";
|
|
5
|
+
/** Applying this data attribute marks a row as active, applying a new background color. */
|
|
6
|
+
export declare const dataAttrActiveRow: "data-active-row";
|
|
7
|
+
/** Prefix added to table cell data attrs (like cell ID). */
|
|
8
|
+
export declare const dataAttrCellPrefix: "data-cell";
|
|
9
|
+
/** Applied when a sticky styled element is observed to have become sticky via `markStickyElements`. */
|
|
10
|
+
export declare const dataAttrIsSticky: "data-is-sticky";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RowData } from '@tanstack/react-table';
|
|
2
|
+
import { TableRowProps } from './table-row.types';
|
|
3
|
+
export declare const TableRow: <DataType extends RowData<{
|
|
4
|
+
[key: string]: unknown;
|
|
5
|
+
id: string | number;
|
|
6
|
+
subRows?: any[] | undefined;
|
|
7
|
+
}>>(props: TableRowProps<DataType>) => JSX.Element;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Row, RowData } from '@tanstack/react-table';
|
|
2
|
+
import { CustomRowProps, GetCellProps, OnRowClick } from '../../table.types';
|
|
3
|
+
export interface TableRowProps<DataType extends RowData> {
|
|
4
|
+
customRowProps: CustomRowProps;
|
|
5
|
+
enableReordering: boolean;
|
|
6
|
+
getCellProps: GetCellProps<DataType> | undefined;
|
|
7
|
+
handleOnReorder: () => Promise<void>;
|
|
8
|
+
index: number;
|
|
9
|
+
moveRow: (startIndex: number, endIndex: number) => void;
|
|
10
|
+
onRowClick?: OnRowClick<DataType>;
|
|
11
|
+
row: Row<DataType>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RowData } from '@tanstack/react-table';
|
|
2
|
+
/** If an index does not contain an `id` value, one is added using uuid. */
|
|
3
|
+
export declare const addMissingIds: <DataType extends RowData<{
|
|
4
|
+
[key: string]: unknown;
|
|
5
|
+
id: string | number;
|
|
6
|
+
subRows?: any[] | undefined;
|
|
7
|
+
}>>(data: DataType[]) => DataType[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const hyphenateColumnId: ((id: string) => string) & import("lodash").MemoizedFunction;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './hyphenate-column-id';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './use-move-row';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { RowData } from '@tanstack/react-table';
|
|
2
|
+
import { UseMoveRowProps } from './use-move-row.types';
|
|
3
|
+
export declare const useMoveRow: <TData extends RowData<{
|
|
4
|
+
[key: string]: unknown;
|
|
5
|
+
id: string | number;
|
|
6
|
+
subRows?: any[] | undefined;
|
|
7
|
+
}>>(props: UseMoveRowProps<TData>) => {
|
|
8
|
+
moveRow: (startIndex: number, endIndex: number) => void;
|
|
9
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './use-track-sticky-cells';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ColumnDef } from '@tanstack/react-table';
|
|
2
|
+
export interface UseTrackStickyCellsProps {
|
|
3
|
+
columns: ColumnDef<any, any>[];
|
|
4
|
+
/** The containing element that the child will intersect with. */
|
|
5
|
+
root: Element | null;
|
|
6
|
+
stickyFirstColumn: boolean | undefined;
|
|
7
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RowData } from '@tanstack/react-table';
|
|
2
|
+
import { TableProps } from './table.types';
|
|
3
|
+
export declare const Table: {
|
|
4
|
+
<DataType extends RowData<{
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
id: string | number;
|
|
7
|
+
subRows?: any[] | undefined;
|
|
8
|
+
}>>(props: TableProps<DataType>): JSX.Element;
|
|
9
|
+
defaultProps: import("./table.types").TableDefaultProps;
|
|
10
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const StyledTableContainer: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
2
|
+
export declare const StyledTable: import("styled-components").StyledComponent<"table", import("styled-components").DefaultTheme, {
|
|
3
|
+
stickyFirstColumn: boolean | undefined;
|
|
4
|
+
}, never>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Cell, ColumnDef, Header, Row, RowData, TableOptions } from '@tanstack/react-table';
|
|
2
|
+
import { HTMLAttributes, MouseEvent } from 'react';
|
|
3
|
+
import { PagingProps } from '../paging/paging.types';
|
|
4
|
+
import { CustomActionProps, FiltersProps, SearchProps } from './components/table-actions-wrapper/table-actions-wrapper.types';
|
|
5
|
+
import { SortProps } from './components/table-actions-wrapper/components/sort/sort.types';
|
|
6
|
+
export interface TableProps<DataType extends RowData> extends Partial<TableDefaultProps> {
|
|
7
|
+
className?: string;
|
|
8
|
+
columns: ColumnDef<DataType, any>[];
|
|
9
|
+
customAction?: CustomActionProps;
|
|
10
|
+
/**
|
|
11
|
+
* For each index, if no `id` key exists, one will be assigned.
|
|
12
|
+
*
|
|
13
|
+
* To create collapsable rows, optionally provide the index with a `subRows` key. It should be an array of objects matching the expected data type.
|
|
14
|
+
*/
|
|
15
|
+
data: DataType[];
|
|
16
|
+
filters?: FiltersProps;
|
|
17
|
+
getCellProps?: GetCellProps<DataType>;
|
|
18
|
+
getHeaderCellProps?: GetHeaderCellProps<DataType>;
|
|
19
|
+
/** Include `status` in the returned value to set the row status color. */
|
|
20
|
+
getRowProps?: GetRowProps<DataType>;
|
|
21
|
+
onRowClick?: OnRowClick<DataType>;
|
|
22
|
+
/** Any options provided are passed to `useReactTable` and may override default values. */
|
|
23
|
+
options?: Partial<TableOptions<DataType>>;
|
|
24
|
+
paging?: PagingProps;
|
|
25
|
+
reordering?: {
|
|
26
|
+
enable: boolean;
|
|
27
|
+
onReorder: (data: DataType[]) => Promise<void>;
|
|
28
|
+
};
|
|
29
|
+
search?: SearchProps;
|
|
30
|
+
sorting?: SortProps;
|
|
31
|
+
}
|
|
32
|
+
export interface TableDefaultProps {
|
|
33
|
+
stickyFirstColumn: boolean;
|
|
34
|
+
}
|
|
35
|
+
export type GetHeaderCellProps<DataType extends RowData> = (cell?: Header<DataType, unknown>) => CustomCellProps;
|
|
36
|
+
export type GetRowProps<DataType extends RowData> = (row?: Row<DataType>, rows?: Row<DataType>[]) => CustomRowProps;
|
|
37
|
+
export type GetCellProps<DataType extends RowData> = (cell?: Cell<DataType, unknown>) => CustomCellProps;
|
|
38
|
+
export type OnRowClick<DataType extends RowData> = (data: Row<DataType>, event: MouseEvent<HTMLTableRowElement>) => void;
|
|
39
|
+
export interface CustomRowProps extends Record<string, unknown>, HTMLAttributes<HTMLTableRowElement> {
|
|
40
|
+
status?: RowStatusValue | undefined;
|
|
41
|
+
}
|
|
42
|
+
export interface CustomCellProps extends Record<string, unknown>, HTMLAttributes<HTMLTableCellElement> {
|
|
43
|
+
}
|
|
44
|
+
export type RowStatusValue = 'handled' | 'next' | 'error' | 'warning';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FormatAsLocaleNumberOptions } from './format-as-locale-number.types';
|
|
2
|
+
/**
|
|
3
|
+
* Set `locale` in `options` to override default `'en-US'`.
|
|
4
|
+
*
|
|
5
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#options */
|
|
6
|
+
export declare const formatAsLocaleNumber: (value: number, options?: FormatAsLocaleNumberOptions) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './format-as-locale-number';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RenderResult } from '@testing-library/react';
|
|
2
|
+
import { StickyTo } from '../mark-sticky-elements.types';
|
|
3
|
+
interface SetupMockElementsResponse extends RenderResult {
|
|
4
|
+
elementsToMark: Element[];
|
|
5
|
+
elementsToObserve: Element[];
|
|
6
|
+
}
|
|
7
|
+
export declare const setupMockElements: (stickyTo: StickyTo) => SetupMockElementsResponse;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { StickyTo } from '../../mark-sticky-elements.types';
|
|
2
|
+
export interface GetIntersectionObserverCallbackArgs {
|
|
3
|
+
/** If not provided, the `dataAttrIsSticky` variable value will be used. If `stickyTo` is provided, it will apply that value as a suffix to the attr (ie `${dataAttrIsSticky}-${stickyTo}`). */
|
|
4
|
+
attrToApply?: string;
|
|
5
|
+
elementsToMark: Element[];
|
|
6
|
+
/** If not provided, an intersection in any direction mark the elements. */
|
|
7
|
+
stickyTo?: StickyTo;
|
|
8
|
+
}
|
package/dist/helpers/mark-sticky-elements/helpers/get-intersection-observer-callback/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './get-intersection-observer-callback';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './mark-sticky-elements';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { MarkStickyElementsArgs } from './mark-sticky-elements.types';
|
|
2
|
+
/**
|
|
3
|
+
* When each arg's `elementsToObserve` is recognized as sticky, the `dataAttrIsSticky` variable value is applied to that element.
|
|
4
|
+
* @example
|
|
5
|
+
* useEffect(() => {
|
|
6
|
+
* const elementsToMark = [document.querySelector('table')];
|
|
7
|
+
* const elementsToObserve = Array.from(
|
|
8
|
+
* document.querySelectorAll('tr td:first-child'),
|
|
9
|
+
* );
|
|
10
|
+
* const root = [document.querySelector('[data-table-container]')];
|
|
11
|
+
* const stickyTo = 'left';
|
|
12
|
+
*
|
|
13
|
+
* const { cleanupUseEffect } = markStickyElements({
|
|
14
|
+
* attrToApply: `${dataAttrIsSticky}-${stickyTo}`,
|
|
15
|
+
* elementsToMark,
|
|
16
|
+
* elementsToObserve,
|
|
17
|
+
* root,
|
|
18
|
+
* stickyTo,
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* return cleanupUseEffect;
|
|
22
|
+
* }, [allColumns]);
|
|
23
|
+
*
|
|
24
|
+
* @source https://css-tricks.com/how-to-detect-when-a-sticky-element-gets-pinned/
|
|
25
|
+
*/
|
|
26
|
+
export declare const markStickyElements: (...args: MarkStickyElementsArgs) => {
|
|
27
|
+
cleanupUseEffect: () => void;
|
|
28
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface StickyElementsDetails {
|
|
2
|
+
/** If not provided, the `dataAttrIsSticky` variable value will be used. If `stickyTo` is provided, it will apply that value as a suffix to the attr (ie `${dataAttrIsSticky}-${stickyTo}`). */
|
|
3
|
+
attrToApply?: string;
|
|
4
|
+
/**
|
|
5
|
+
* All elements in this array will be labeled as sticky according to the status of `elementsToObserve`.
|
|
6
|
+
*
|
|
7
|
+
* If using `document.querySelectorAll`, you can use `Array.from(document.querySelectorAll(SELECTOR))` to satisfy TypeScript.
|
|
8
|
+
*/
|
|
9
|
+
elementsToMark?: Element[];
|
|
10
|
+
/**
|
|
11
|
+
* When any of these elements are detected as sticky, all elements in `elementsToMark` are labeled with `attrToApply` (or fallback). If `elementsToMark` is not provided, only these elements will be labeled.
|
|
12
|
+
*
|
|
13
|
+
* If using `document.querySelectorAll`, you can use `Array.from(document.querySelectorAll(SELECTOR))` to satisfy TypeScript.
|
|
14
|
+
*
|
|
15
|
+
* **IMPORTANT:** These elements should have a `-1px` styling applied to them in the direction of the sticky direction (ie, if sticky to right, add `position: sticky; right: -1px;`). Without this styling, this function may not work.
|
|
16
|
+
*/
|
|
17
|
+
elementsToObserve: Element[];
|
|
18
|
+
/**
|
|
19
|
+
* The containing element that the child will intersect with. Value is passed to IntersectionObserver options.
|
|
20
|
+
*
|
|
21
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/root
|
|
22
|
+
* */
|
|
23
|
+
root?: Document | Element;
|
|
24
|
+
/** If not provided, an intersection in any direction mark the elements. */
|
|
25
|
+
stickyTo?: StickyTo;
|
|
26
|
+
}
|
|
27
|
+
export type StickyTo = 'top' | 'bottom' | 'left' | 'right';
|
|
28
|
+
export type MarkStickyElementsArgs = StickyElementsDetails[];
|