@luscii-healthtech/web-ui 30.9.1 → 30.10.0
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/PaginationMenu/PaginationMenu.types.d.ts +33 -9
- package/dist/components/PaginationMenu/PaginationMenuCursor.d.ts +3 -0
- package/dist/components/Table/Table.utils.d.ts +2 -0
- package/dist/index.development.js +30 -9
- package/dist/index.development.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/web-ui.esm.js +1 -1
- package/dist/web-ui.esm.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,13 +1,28 @@
|
|
|
1
|
-
export
|
|
2
|
-
pageCount: number;
|
|
3
|
-
currentPageNumber: number;
|
|
4
|
-
onChange: OnPaginationChange;
|
|
5
|
-
pageSize?: PageSize;
|
|
6
|
-
localization?: Localization;
|
|
7
|
-
resultCount?: number;
|
|
8
|
-
small?: boolean;
|
|
1
|
+
export type PaginationMenuProps = {
|
|
9
2
|
className?: string;
|
|
10
|
-
|
|
3
|
+
type?: "small" | "large" | "cursor";
|
|
4
|
+
/** @deprecated use type instead */
|
|
5
|
+
small?: boolean;
|
|
6
|
+
pageSize?: PageSize;
|
|
7
|
+
} & (PaginationMenuPropsSmall | PaginationMenuPropsLarge | PaginationMenuPropsCursor);
|
|
8
|
+
type PaginationMenuPropsSmall = ({
|
|
9
|
+
type: "small";
|
|
10
|
+
small?: never;
|
|
11
|
+
} | {
|
|
12
|
+
small: true;
|
|
13
|
+
type?: never;
|
|
14
|
+
}) & PaginationMenuSmallProps;
|
|
15
|
+
type PaginationMenuPropsLarge = ({
|
|
16
|
+
type: "large";
|
|
17
|
+
small?: never;
|
|
18
|
+
} | {
|
|
19
|
+
small?: false | undefined;
|
|
20
|
+
type?: never;
|
|
21
|
+
}) & PaginationMenuLargeProps;
|
|
22
|
+
type PaginationMenuPropsCursor = {
|
|
23
|
+
type: "cursor";
|
|
24
|
+
small?: never;
|
|
25
|
+
} & PaginationMenuCursorProps;
|
|
11
26
|
export interface PaginationMenuSmallProps {
|
|
12
27
|
pageCount: number;
|
|
13
28
|
currentPageNumber: number;
|
|
@@ -22,7 +37,15 @@ export interface PaginationMenuLargeProps {
|
|
|
22
37
|
localization: Localization;
|
|
23
38
|
resultCount?: number;
|
|
24
39
|
}
|
|
40
|
+
export interface PaginationMenuCursorProps {
|
|
41
|
+
previousCursor?: string | null;
|
|
42
|
+
nextCursor?: string | null;
|
|
43
|
+
onChange: OnPaginationCursorChange;
|
|
44
|
+
pageSize?: number;
|
|
45
|
+
localization: Pick<Localization, "previous" | "next">;
|
|
46
|
+
}
|
|
25
47
|
export type OnPaginationChange = (pageNumber: number, pageSize?: PageSize) => void;
|
|
48
|
+
export type OnPaginationCursorChange = (newCursor: string) => void;
|
|
26
49
|
export type PageSize = 25 | 50 | 75 | 100;
|
|
27
50
|
export interface Localization {
|
|
28
51
|
display: string;
|
|
@@ -35,3 +58,4 @@ export type Option = {
|
|
|
35
58
|
value: number;
|
|
36
59
|
label: string;
|
|
37
60
|
};
|
|
61
|
+
export {};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import { PaginationMenuProps } from "../PaginationMenu/PaginationMenu.types";
|
|
1
2
|
import { TableFieldText, TableFieldAction, TableFieldContent } from "./Table.types";
|
|
2
3
|
export declare function isTableFieldText<Item>(content: TableFieldContent<Item>): content is TableFieldText;
|
|
3
4
|
export declare function isTableFieldAction<Item>(content: TableFieldContent<Item>): content is [TableFieldAction<Item>?, TableFieldAction<Item>?];
|
|
5
|
+
export declare const shouldShowPagination: (paginationMenuProps: PaginationMenuProps | undefined) => paginationMenuProps is PaginationMenuProps;
|
|
4
6
|
/**
|
|
5
7
|
* This function is to be used when the data we need can be completely on the client side.
|
|
6
8
|
* By doing so we have a centralized way to deal with pagination.
|
|
@@ -3745,6 +3745,15 @@ function isTableFieldText(content) {
|
|
|
3745
3745
|
function isTableFieldAction(content) {
|
|
3746
3746
|
return Array.isArray(content) && content.some((action) => action && "key" in action && "icon" in action && "handleClick" in action);
|
|
3747
3747
|
}
|
|
3748
|
+
const shouldShowPagination = (paginationMenuProps) => {
|
|
3749
|
+
if (!paginationMenuProps) {
|
|
3750
|
+
return false;
|
|
3751
|
+
}
|
|
3752
|
+
if (paginationMenuProps.type === "cursor") {
|
|
3753
|
+
return Boolean(paginationMenuProps.previousCursor || paginationMenuProps.nextCursor);
|
|
3754
|
+
}
|
|
3755
|
+
return paginationMenuProps.currentPageNumber > 0 && paginationMenuProps.pageCount > 0;
|
|
3756
|
+
};
|
|
3748
3757
|
function prepareClientSidePagination({
|
|
3749
3758
|
/**
|
|
3750
3759
|
* The array to be split into chunks.
|
|
@@ -4097,15 +4106,27 @@ const PaginationMenuLarge = (props) => {
|
|
|
4097
4106
|
);
|
|
4098
4107
|
};
|
|
4099
4108
|
|
|
4100
|
-
const
|
|
4101
|
-
const
|
|
4102
|
-
|
|
4103
|
-
|
|
4104
|
-
return React__namespace.default.createElement("span", null, "Invalid props passed to this component.");
|
|
4105
|
-
}
|
|
4106
|
-
return React__namespace.default.createElement(PaginationMenuLarge, { pageCount: props.pageCount, currentPageNumber: props.currentPageNumber, onChange: props.onChange, pageSize: props.pageSize, localization: props.localization, resultCount: props.resultCount });
|
|
4109
|
+
const PaginationMenuCursor = (props) => {
|
|
4110
|
+
const handleOnChange = (event) => {
|
|
4111
|
+
const cursor = event.currentTarget.dataset.cursor;
|
|
4112
|
+
cursor && props.onChange(cursor);
|
|
4107
4113
|
};
|
|
4108
|
-
return React__namespace.default.createElement(
|
|
4114
|
+
return React__namespace.default.createElement(
|
|
4115
|
+
Stack,
|
|
4116
|
+
{ axis: "x", gap: "m", justify: "end", width: "full" },
|
|
4117
|
+
React__namespace.default.createElement(SecondaryButton, { "data-test-id": "prev-button", leadingIcon: React__namespace.default.createElement(LeftArrowIcon, null), "data-cursor": props.previousCursor, isDisabled: !props.previousCursor, onClick: handleOnChange }, props.localization.previous),
|
|
4118
|
+
React__namespace.default.createElement(SecondaryButton, { "data-test-id": "next-button", trailingIcon: React__namespace.default.createElement(RightArrowIcon, null), "data-cursor": props.nextCursor, isDisabled: !props.nextCursor, onClick: handleOnChange }, props.localization.next)
|
|
4119
|
+
);
|
|
4120
|
+
};
|
|
4121
|
+
|
|
4122
|
+
const PaginationMenu = (props) => {
|
|
4123
|
+
return React__namespace.default.createElement(
|
|
4124
|
+
"div",
|
|
4125
|
+
{ className: classNames__default.default("ui-flex ui-w-full ui-flex-row ui-items-center ui-justify-between", props.className) },
|
|
4126
|
+
(props.type === "small" || props.small) && React__namespace.default.createElement(PaginationMenuSmall, { pageCount: props.pageCount, currentPageNumber: props.currentPageNumber, pageSize: props.pageSize, onChange: props.onChange }),
|
|
4127
|
+
(props.type === "large" || !props.small && props.type === void 0) && React__namespace.default.createElement(PaginationMenuLarge, { pageCount: props.pageCount, currentPageNumber: props.currentPageNumber, onChange: props.onChange, pageSize: props.pageSize, localization: props.localization, resultCount: props.resultCount }),
|
|
4128
|
+
props.type === "cursor" && React__namespace.default.createElement(PaginationMenuCursor, { previousCursor: props.previousCursor, nextCursor: props.nextCursor, onChange: props.onChange, pageSize: props.pageSize, localization: props.localization })
|
|
4129
|
+
);
|
|
4109
4130
|
};
|
|
4110
4131
|
|
|
4111
4132
|
const TableFooter = (props) => {
|
|
@@ -4147,7 +4168,7 @@ function Table(_a) {
|
|
|
4147
4168
|
setIsPristine(false);
|
|
4148
4169
|
}, [items, isLoading]);
|
|
4149
4170
|
const showEmptyView = !isPristine && !isLoading && !(items && items.length > 0);
|
|
4150
|
-
const showFooter = !isLoading && !showEmptyView && paginationMenuProps
|
|
4171
|
+
const showFooter = !isLoading && !showEmptyView && shouldShowPagination(paginationMenuProps);
|
|
4151
4172
|
const colSpan = isSelectable ? fieldConfigurations.length + 1 : fieldConfigurations.length;
|
|
4152
4173
|
const handleOnToggleAll = () => {
|
|
4153
4174
|
const newState = getSelectAllCheckboxState() === "checked" ? [] : (items !== null && items !== void 0 ? items : []).map((value, index) => ({
|