@flipdish/ui-library 0.35.2 → 0.36.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/dist/components/atoms/Badge/Badge.styles.cjs +194 -0
- package/dist/components/atoms/Badge/Badge.styles.cjs.map +1 -0
- package/dist/components/atoms/Badge/Badge.styles.d.ts +236 -0
- package/dist/components/atoms/Badge/Badge.styles.d.ts.map +1 -0
- package/dist/components/atoms/Badge/Badge.styles.js +192 -0
- package/dist/components/atoms/Badge/Badge.styles.js.map +1 -0
- package/dist/components/atoms/Badge/badge.types.cjs.map +1 -1
- package/dist/components/atoms/Badge/badge.types.d.ts +0 -2
- package/dist/components/atoms/Badge/badge.types.d.ts.map +1 -1
- package/dist/components/atoms/Badge/badge.types.js.map +1 -1
- package/dist/components/atoms/Badge/badge.utils.d.ts +21 -0
- package/dist/components/atoms/Badge/badge.utils.d.ts.map +1 -0
- package/dist/components/atoms/Badge/index.cjs +15 -248
- package/dist/components/atoms/Badge/index.cjs.map +1 -1
- package/dist/components/atoms/Badge/index.d.ts +11 -50
- package/dist/components/atoms/Badge/index.d.ts.map +1 -1
- package/dist/components/atoms/Badge/index.js +15 -248
- package/dist/components/atoms/Badge/index.js.map +1 -1
- package/dist/components/molecules/Pagination/components/PaginationBase.cjs +2 -104
- package/dist/components/molecules/Pagination/components/PaginationBase.cjs.map +1 -1
- package/dist/components/molecules/Pagination/components/PaginationBase.d.ts +2 -14
- package/dist/components/molecules/Pagination/components/PaginationBase.d.ts.map +1 -1
- package/dist/components/molecules/Pagination/components/PaginationBase.js +3 -105
- package/dist/components/molecules/Pagination/components/PaginationBase.js.map +1 -1
- package/dist/components/molecules/Pagination/pagination.utils.cjs +89 -0
- package/dist/components/molecules/Pagination/pagination.utils.cjs.map +1 -0
- package/dist/components/molecules/Pagination/pagination.utils.d.ts +32 -0
- package/dist/components/molecules/Pagination/pagination.utils.d.ts.map +1 -0
- package/dist/components/molecules/Pagination/pagination.utils.js +87 -0
- package/dist/components/molecules/Pagination/pagination.utils.js.map +1 -0
- package/dist/native/components/atoms/Badge/Badge.styles.d.ts +236 -0
- package/dist/native/components/atoms/Badge/Badge.styles.d.ts.map +1 -0
- package/dist/native/components/atoms/Badge/Badge.styles.js +327 -0
- package/dist/native/components/atoms/Badge/Badge.styles.js.map +1 -0
- package/dist/native/components/atoms/Badge/badge.types.d.ts +21 -0
- package/dist/native/components/atoms/Badge/badge.types.d.ts.map +1 -0
- package/dist/native/components/atoms/Badge/badge.types.js +8 -0
- package/dist/native/components/atoms/Badge/badge.types.js.map +1 -0
- package/dist/native/components/atoms/Badge/badge.utils.d.ts +21 -0
- package/dist/native/components/atoms/Badge/badge.utils.d.ts.map +1 -0
- package/dist/native/components/atoms/Badge/badge.utils.js +32 -0
- package/dist/native/components/atoms/Badge/badge.utils.js.map +1 -0
- package/dist/native/components/atoms/Badge/index.d.ts +94 -8
- package/dist/native/components/atoms/Badge/index.d.ts.map +1 -0
- package/dist/native/components/atoms/Badge/index.js +66 -0
- package/dist/native/components/atoms/Badge/index.js.map +1 -0
- package/package.json +1 -1
|
@@ -1,104 +1,12 @@
|
|
|
1
1
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { useResolvedTestId, joinTestId } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
3
|
-
import { createContext,
|
|
3
|
+
import { createContext, useContext, isValidElement, cloneElement } from 'react';
|
|
4
|
+
import { createPaginationItems } from '../pagination.utils.js';
|
|
4
5
|
|
|
5
6
|
const PaginationContext = createContext(undefined);
|
|
6
7
|
const PaginationRoot = ({ total, siblingCount = 1, page, onPageChange, children, style, className, 'data-testid': dataTestId, }) => {
|
|
7
|
-
const [pages, setPages] = useState([]);
|
|
8
8
|
const rootTestId = useResolvedTestId({ testId: dataTestId, segment: 'pagination', rootName: 'pagination' });
|
|
9
|
-
const
|
|
10
|
-
const items = [];
|
|
11
|
-
// Calculate the maximum number of pagination elements (pages, potential ellipsis, first and last) to show
|
|
12
|
-
const totalPageNumbers = siblingCount * 2 + 5;
|
|
13
|
-
// If the total number of items to show is greater than or equal to the total pages,
|
|
14
|
-
// we can simply list all pages without needing to collapse with ellipsis
|
|
15
|
-
if (totalPageNumbers >= total) {
|
|
16
|
-
for (let i = 1; i <= total; i++) {
|
|
17
|
-
items.push({
|
|
18
|
-
type: 'page',
|
|
19
|
-
value: i,
|
|
20
|
-
isCurrent: i === page,
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
// Calculate left and right sibling boundaries around the current page
|
|
26
|
-
const leftSiblingIndex = Math.max(page - siblingCount, 1);
|
|
27
|
-
const rightSiblingIndex = Math.min(page + siblingCount, total);
|
|
28
|
-
// Determine if we need to show ellipsis on either side
|
|
29
|
-
const showLeftEllipsis = leftSiblingIndex > 2;
|
|
30
|
-
const showRightEllipsis = rightSiblingIndex < total - 1;
|
|
31
|
-
// Case 1: No left ellipsis, but right ellipsis is needed
|
|
32
|
-
if (!showLeftEllipsis && showRightEllipsis) {
|
|
33
|
-
// Calculate how many page numbers to show starting from the beginning
|
|
34
|
-
const leftItemCount = siblingCount * 2 + 3;
|
|
35
|
-
const leftRange = range(1, leftItemCount);
|
|
36
|
-
// biome-ignore lint/suspicious/useIterableCallbackReturn: This is a side effect
|
|
37
|
-
leftRange.forEach((pageNum) => items.push({
|
|
38
|
-
type: 'page',
|
|
39
|
-
value: pageNum,
|
|
40
|
-
isCurrent: pageNum === page,
|
|
41
|
-
}));
|
|
42
|
-
// Insert ellipsis after the left range and add the last page
|
|
43
|
-
items.push({ type: 'ellipsis', key: leftItemCount + 1 });
|
|
44
|
-
items.push({
|
|
45
|
-
type: 'page',
|
|
46
|
-
value: total,
|
|
47
|
-
isCurrent: total === page,
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
// Case 2: Left ellipsis needed, but right ellipsis is not needed
|
|
51
|
-
else if (showLeftEllipsis && !showRightEllipsis) {
|
|
52
|
-
// Determine how many items from the end should be shown
|
|
53
|
-
const rightItemCount = siblingCount * 2 + 3;
|
|
54
|
-
const rightRange = range(total - rightItemCount + 1, total);
|
|
55
|
-
// Always show the first page, then add an ellipsis to indicate skipped pages
|
|
56
|
-
items.push({
|
|
57
|
-
type: 'page',
|
|
58
|
-
value: 1,
|
|
59
|
-
isCurrent: page === 1,
|
|
60
|
-
});
|
|
61
|
-
items.push({ type: 'ellipsis', key: total - rightItemCount });
|
|
62
|
-
// biome-ignore lint/suspicious/useIterableCallbackReturn: This is a side effect
|
|
63
|
-
rightRange.forEach((pageNum) => items.push({
|
|
64
|
-
type: 'page',
|
|
65
|
-
value: pageNum,
|
|
66
|
-
isCurrent: pageNum === page,
|
|
67
|
-
}));
|
|
68
|
-
}
|
|
69
|
-
// Case 3: Both left and right ellipsis are needed
|
|
70
|
-
else if (showLeftEllipsis && showRightEllipsis) {
|
|
71
|
-
// Always show the first page
|
|
72
|
-
items.push({
|
|
73
|
-
type: 'page',
|
|
74
|
-
value: 1,
|
|
75
|
-
isCurrent: page === 1,
|
|
76
|
-
});
|
|
77
|
-
// Insert left ellipsis after the first page
|
|
78
|
-
items.push({ type: 'ellipsis', key: leftSiblingIndex - 1 });
|
|
79
|
-
// Show a range of pages around the current page
|
|
80
|
-
const middleRange = range(leftSiblingIndex, rightSiblingIndex);
|
|
81
|
-
// biome-ignore lint/suspicious/useIterableCallbackReturn: This is a side effect
|
|
82
|
-
middleRange.forEach((pageNum) => items.push({
|
|
83
|
-
type: 'page',
|
|
84
|
-
value: pageNum,
|
|
85
|
-
isCurrent: pageNum === page,
|
|
86
|
-
}));
|
|
87
|
-
// Insert right ellipsis and finally the last page
|
|
88
|
-
items.push({ type: 'ellipsis', key: rightSiblingIndex + 1 });
|
|
89
|
-
items.push({
|
|
90
|
-
type: 'page',
|
|
91
|
-
value: total,
|
|
92
|
-
isCurrent: total === page,
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
return items;
|
|
97
|
-
}, [total, siblingCount, page]);
|
|
98
|
-
useEffect(() => {
|
|
99
|
-
const paginationItems = createPaginationItems();
|
|
100
|
-
setPages(paginationItems);
|
|
101
|
-
}, [createPaginationItems]);
|
|
9
|
+
const pages = createPaginationItems({ total, siblingCount, page });
|
|
102
10
|
const onPageChangeHandler = (newPage) => {
|
|
103
11
|
onPageChange?.(newPage);
|
|
104
12
|
};
|
|
@@ -111,16 +19,6 @@ const PaginationRoot = ({ total, siblingCount = 1, page, onPageChange, children,
|
|
|
111
19
|
};
|
|
112
20
|
return (jsx(PaginationContext.Provider, { value: paginationContextValue, children: jsx("nav", { "aria-label": "Pagination Navigation", "data-testid": rootTestId, style: style, className: className, children: children }) }));
|
|
113
21
|
};
|
|
114
|
-
/**
|
|
115
|
-
* Creates an array of numbers from start to end.
|
|
116
|
-
* @param start - The start number.
|
|
117
|
-
* @param end - The end number.
|
|
118
|
-
* @returns An array of numbers from start to end.
|
|
119
|
-
*/
|
|
120
|
-
const range = (start, end) => {
|
|
121
|
-
const length = end - start + 1;
|
|
122
|
-
return Array.from({ length }, (_, index) => index + start);
|
|
123
|
-
};
|
|
124
22
|
const Trigger = ({ children, style, className, asChild = false, direction, ariaLabel }) => {
|
|
125
23
|
const context = useContext(PaginationContext);
|
|
126
24
|
if (!context) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PaginationBase.js","sources":["../../../../../src/components/molecules/Pagination/components/PaginationBase.tsx"],"sourcesContent":[null],"names":["_jsx","_Fragment"],"mappings":"
|
|
1
|
+
{"version":3,"file":"PaginationBase.js","sources":["../../../../../src/components/molecules/Pagination/components/PaginationBase.tsx"],"sourcesContent":[null],"names":["_jsx","_Fragment"],"mappings":";;;;;AAoBA,MAAM,iBAAiB,GAAG,aAAa,CAAoC,SAAS,CAAC;AAwBrF,MAAM,cAAc,GAAG,CAAC,EACtB,KAAK,EACL,YAAY,GAAG,CAAC,EAChB,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,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G,OAAO,SAAS,KAAK,UAAU,GAAG,SAAS,EAAE,GAAG,SAAS;AAEnF,IAAA,QACEA,GAAA,CAAA,MAAA,EAAA,EAAM,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,iBAAiB,iBAAc,MAAM,EAAA,QAAA,EACjE,QAAQ,EAAA,CACJ;AAEX,CAAC;AAMD,MAAM,0BAA0B,GAAwC,CAAC,EAAE,QAAQ,EAAE,KAAI;AACvF,IAAA,MAAM,OAAO,GAAG,UAAU,CAAC,iBAAiB,CAAC;IAC7C,IAAI,CAAC,OAAO,EAAE;AACZ,QAAA,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC;IAChF;AAEA,IAAA,OAAOA,0BAAG,QAAQ,CAAC,OAAO,CAAC,GAAI;AACjC,CAAC;AAEM,MAAM,UAAU,GAAG;AACxB,IAAA,IAAI,EAAE,cAAc;AACpB,IAAA,WAAW,EAAE,qBAAqB;AAClC,IAAA,WAAW,EAAE,qBAAqB;AAClC,IAAA,IAAI,EAAE,cAAc;AACpB,IAAA,QAAQ,EAAE,kBAAkB;AAC5B,IAAA,OAAO,EAAE,0BAA0B;;;"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const range = (start, end) => {
|
|
4
|
+
const length = end - start + 1;
|
|
5
|
+
return Array.from({ length }, (_, index) => index + start);
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Chooses the page numbers and ellipses shown between the previous and next controls.
|
|
9
|
+
*
|
|
10
|
+
* @param options Current page, total pages and how many siblings stay beside the current page.
|
|
11
|
+
* @returns Items in display order. Every page is listed when they fit; otherwise a run at the start or the end collapses behind one ellipsis, and a page in the middle keeps both.
|
|
12
|
+
*/
|
|
13
|
+
const createPaginationItems = ({ page, total, siblingCount }) => {
|
|
14
|
+
const items = [];
|
|
15
|
+
// Current page, one sibling run on each side, the first and last pages, and two ellipses.
|
|
16
|
+
const totalPageNumbers = siblingCount * 2 + 5;
|
|
17
|
+
if (totalPageNumbers >= total) {
|
|
18
|
+
for (let i = 1; i <= total; i++) {
|
|
19
|
+
items.push({
|
|
20
|
+
type: 'page',
|
|
21
|
+
value: i,
|
|
22
|
+
isCurrent: i === page,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
return items;
|
|
26
|
+
}
|
|
27
|
+
const leftSiblingIndex = Math.max(page - siblingCount, 1);
|
|
28
|
+
const rightSiblingIndex = Math.min(page + siblingCount, total);
|
|
29
|
+
const showLeftEllipsis = leftSiblingIndex > 2;
|
|
30
|
+
const showRightEllipsis = rightSiblingIndex < total - 1;
|
|
31
|
+
if (!showLeftEllipsis && showRightEllipsis) {
|
|
32
|
+
const leftItemCount = siblingCount * 2 + 3;
|
|
33
|
+
for (const pageNum of range(1, leftItemCount)) {
|
|
34
|
+
items.push({
|
|
35
|
+
type: 'page',
|
|
36
|
+
value: pageNum,
|
|
37
|
+
isCurrent: pageNum === page,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
items.push({ type: 'ellipsis', key: leftItemCount + 1 });
|
|
41
|
+
items.push({
|
|
42
|
+
type: 'page',
|
|
43
|
+
value: total,
|
|
44
|
+
isCurrent: total === page,
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
else if (showLeftEllipsis && !showRightEllipsis) {
|
|
48
|
+
const rightItemCount = siblingCount * 2 + 3;
|
|
49
|
+
const rightRange = range(total - rightItemCount + 1, total);
|
|
50
|
+
items.push({
|
|
51
|
+
type: 'page',
|
|
52
|
+
value: 1,
|
|
53
|
+
isCurrent: page === 1,
|
|
54
|
+
});
|
|
55
|
+
items.push({ type: 'ellipsis', key: total - rightItemCount });
|
|
56
|
+
for (const pageNum of rightRange) {
|
|
57
|
+
items.push({
|
|
58
|
+
type: 'page',
|
|
59
|
+
value: pageNum,
|
|
60
|
+
isCurrent: pageNum === page,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else if (showLeftEllipsis && showRightEllipsis) {
|
|
65
|
+
items.push({
|
|
66
|
+
type: 'page',
|
|
67
|
+
value: 1,
|
|
68
|
+
isCurrent: page === 1,
|
|
69
|
+
});
|
|
70
|
+
items.push({ type: 'ellipsis', key: leftSiblingIndex - 1 });
|
|
71
|
+
for (const pageNum of range(leftSiblingIndex, rightSiblingIndex)) {
|
|
72
|
+
items.push({
|
|
73
|
+
type: 'page',
|
|
74
|
+
value: pageNum,
|
|
75
|
+
isCurrent: pageNum === page,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
items.push({ type: 'ellipsis', key: rightSiblingIndex + 1 });
|
|
79
|
+
items.push({
|
|
80
|
+
type: 'page',
|
|
81
|
+
value: total,
|
|
82
|
+
isCurrent: total === page,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return items;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
exports.createPaginationItems = createPaginationItems;
|
|
89
|
+
//# sourceMappingURL=pagination.utils.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.utils.cjs","sources":["../../../../src/components/molecules/Pagination/pagination.utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;AA4BA,MAAM,KAAK,GAAG,CAAC,KAAa,EAAE,GAAW,KAAc;AACrD,IAAA,MAAM,MAAM,GAAG,GAAG,GAAG,KAAK,GAAG,CAAC;AAE9B,IAAA,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,KAAK,KAAK,GAAG,KAAK,CAAC;AAC5D,CAAC;AAED;;;;;AAKG;AACI,MAAM,qBAAqB,GAAG,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAA2B,KAA4B;IACtH,MAAM,KAAK,GAA2B,EAAE;;AAExC,IAAA,MAAM,gBAAgB,GAAG,YAAY,GAAG,CAAC,GAAG,CAAC;AAE7C,IAAA,IAAI,gBAAgB,IAAI,KAAK,EAAE;AA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AC,EAAE,CAAC;QAC5D,KAAK,CAAC,IAAI,CAAC;AACT,YAAA,IAAI,EAAE,MAAM;AACZ,YAAA,KAAK,EAAE,KAAK;YACZ,SAAS,EAAE,KAAK,KAAK,IAAI;AAC1B,SAAA,CAAC;IACJ;AAEA,IAAA,OAAO,KAAK;AACd;;"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** One numbered page in the window between the previous and next controls. */
|
|
2
|
+
export interface PaginationPageItem {
|
|
3
|
+
type: 'page';
|
|
4
|
+
/** 1-based page number. */
|
|
5
|
+
value: number;
|
|
6
|
+
/** Whether this page is the one currently selected. */
|
|
7
|
+
isCurrent: boolean;
|
|
8
|
+
}
|
|
9
|
+
/** A collapsed gap. `key` is the page number on the collapsed side of the visible window. */
|
|
10
|
+
export interface PaginationEllipsisItem {
|
|
11
|
+
type: 'ellipsis';
|
|
12
|
+
key: number;
|
|
13
|
+
}
|
|
14
|
+
/** A page button or an ellipsis, in the order the numbered row renders them. */
|
|
15
|
+
export type PaginationWindowItem = PaginationPageItem | PaginationEllipsisItem;
|
|
16
|
+
/** Inputs that decide which page numbers stay visible. */
|
|
17
|
+
export interface PaginationWindowOptions {
|
|
18
|
+
/** 1-based page currently selected. A page outside `1..total` selects nothing. */
|
|
19
|
+
page: number;
|
|
20
|
+
/** Total number of pages. `0` yields no items. */
|
|
21
|
+
total: number;
|
|
22
|
+
/** How many pages stay visible on each side of the current page before the row collapses. */
|
|
23
|
+
siblingCount: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Chooses the page numbers and ellipses shown between the previous and next controls.
|
|
27
|
+
*
|
|
28
|
+
* @param options Current page, total pages and how many siblings stay beside the current page.
|
|
29
|
+
* @returns Items in display order. Every page is listed when they fit; otherwise a run at the start or the end collapses behind one ellipsis, and a page in the middle keeps both.
|
|
30
|
+
*/
|
|
31
|
+
export declare const createPaginationItems: ({ page, total, siblingCount }: PaginationWindowOptions) => PaginationWindowItem[];
|
|
32
|
+
//# sourceMappingURL=pagination.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.utils.d.ts","sourceRoot":"","sources":["../../../../src/components/molecules/Pagination/pagination.utils.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,2BAA2B;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,uDAAuD;IACvD,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,6FAA6F;AAC7F,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,UAAU,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;CACb;AAED,gFAAgF;AAChF,MAAM,MAAM,oBAAoB,GAAG,kBAAkB,GAAG,sBAAsB,CAAC;AAE/E,0DAA0D;AAC1D,MAAM,WAAW,uBAAuB;IACtC,kFAAkF;IAClF,IAAI,EAAE,MAAM,CAAC;IACb,kDAAkD;IAClD,KAAK,EAAE,MAAM,CAAC;IACd,6FAA6F;IAC7F,YAAY,EAAE,MAAM,CAAC;CACtB;AAQD;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,+BAA+B,uBAAuB,KAAG,oBAAoB,EAgFlH,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
const range = (start, end) => {
|
|
2
|
+
const length = end - start + 1;
|
|
3
|
+
return Array.from({ length }, (_, index) => index + start);
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Chooses the page numbers and ellipses shown between the previous and next controls.
|
|
7
|
+
*
|
|
8
|
+
* @param options Current page, total pages and how many siblings stay beside the current page.
|
|
9
|
+
* @returns Items in display order. Every page is listed when they fit; otherwise a run at the start or the end collapses behind one ellipsis, and a page in the middle keeps both.
|
|
10
|
+
*/
|
|
11
|
+
const createPaginationItems = ({ page, total, siblingCount }) => {
|
|
12
|
+
const items = [];
|
|
13
|
+
// Current page, one sibling run on each side, the first and last pages, and two ellipses.
|
|
14
|
+
const totalPageNumbers = siblingCount * 2 + 5;
|
|
15
|
+
if (totalPageNumbers >= total) {
|
|
16
|
+
for (let i = 1; i <= total; i++) {
|
|
17
|
+
items.push({
|
|
18
|
+
type: 'page',
|
|
19
|
+
value: i,
|
|
20
|
+
isCurrent: i === page,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
return items;
|
|
24
|
+
}
|
|
25
|
+
const leftSiblingIndex = Math.max(page - siblingCount, 1);
|
|
26
|
+
const rightSiblingIndex = Math.min(page + siblingCount, total);
|
|
27
|
+
const showLeftEllipsis = leftSiblingIndex > 2;
|
|
28
|
+
const showRightEllipsis = rightSiblingIndex < total - 1;
|
|
29
|
+
if (!showLeftEllipsis && showRightEllipsis) {
|
|
30
|
+
const leftItemCount = siblingCount * 2 + 3;
|
|
31
|
+
for (const pageNum of range(1, leftItemCount)) {
|
|
32
|
+
items.push({
|
|
33
|
+
type: 'page',
|
|
34
|
+
value: pageNum,
|
|
35
|
+
isCurrent: pageNum === page,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
items.push({ type: 'ellipsis', key: leftItemCount + 1 });
|
|
39
|
+
items.push({
|
|
40
|
+
type: 'page',
|
|
41
|
+
value: total,
|
|
42
|
+
isCurrent: total === page,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
else if (showLeftEllipsis && !showRightEllipsis) {
|
|
46
|
+
const rightItemCount = siblingCount * 2 + 3;
|
|
47
|
+
const rightRange = range(total - rightItemCount + 1, total);
|
|
48
|
+
items.push({
|
|
49
|
+
type: 'page',
|
|
50
|
+
value: 1,
|
|
51
|
+
isCurrent: page === 1,
|
|
52
|
+
});
|
|
53
|
+
items.push({ type: 'ellipsis', key: total - rightItemCount });
|
|
54
|
+
for (const pageNum of rightRange) {
|
|
55
|
+
items.push({
|
|
56
|
+
type: 'page',
|
|
57
|
+
value: pageNum,
|
|
58
|
+
isCurrent: pageNum === page,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else if (showLeftEllipsis && showRightEllipsis) {
|
|
63
|
+
items.push({
|
|
64
|
+
type: 'page',
|
|
65
|
+
value: 1,
|
|
66
|
+
isCurrent: page === 1,
|
|
67
|
+
});
|
|
68
|
+
items.push({ type: 'ellipsis', key: leftSiblingIndex - 1 });
|
|
69
|
+
for (const pageNum of range(leftSiblingIndex, rightSiblingIndex)) {
|
|
70
|
+
items.push({
|
|
71
|
+
type: 'page',
|
|
72
|
+
value: pageNum,
|
|
73
|
+
isCurrent: pageNum === page,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
items.push({ type: 'ellipsis', key: rightSiblingIndex + 1 });
|
|
77
|
+
items.push({
|
|
78
|
+
type: 'page',
|
|
79
|
+
value: total,
|
|
80
|
+
isCurrent: total === page,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return items;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export { createPaginationItems };
|
|
87
|
+
//# sourceMappingURL=pagination.utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.utils.js","sources":["../../../../src/components/molecules/Pagination/pagination.utils.ts"],"sourcesContent":[null],"names":[],"mappings":"AA4BA,MAAM,KAAK,GAAG,CAAC,KAAa,EAAE,GAAW,KAAc;AACrD,IAAA,MAAM,MAAM,GAAG,GAAG,GAAG,KAAK,GAAG,CAAC;AAE9B,IAAA,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,KAAK,KAAK,GAAG,KAAK,CAAC;AAC5D,CAAC;AAED;;;;;AAKG;AACI,MAAM,qBAAqB,GAAG,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,YAAY,EAA2B,KAA4B;IACtH,MAAM,KAAK,GAA2B,EAAE;;AAExC,IAAA,MAAM,gBAAgB,GAAG,YAAY,GAAG,CAAC,GAAG,CAAC;AAE7C,IAAA,IAAI,gBAAgB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AAE,iBAAiB,GAAG,CAAC,EAAE,CAAC;QAC5D,KAAK,CAAC,IAAI,CAAC;AACT,YAAA,IAAI,EAAE,MAAM;AACZ,YAAA,KAAK,EAAE,KAAK;YACZ,SAAS,EAAE,KAAK,KAAK,IAAI;AAC1B,SAAA,CAAC;IACJ;AAEA,IAAA,OAAO,KAAK;AACd;;"}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import type { DotColor } from '@flipdish/ui-library/components/atoms/Dot';
|
|
2
|
+
import type { BadgeColors, BadgeTypes, Sizes } from './badge.types';
|
|
3
|
+
/** React Native colour set for one badge colour: `View` classes plus the hex values `Text` and icons need. */
|
|
4
|
+
export type NativeTone = {
|
|
5
|
+
bg: string;
|
|
6
|
+
border: string;
|
|
7
|
+
text: string;
|
|
8
|
+
addon: string;
|
|
9
|
+
button: string;
|
|
10
|
+
buttonPressed: string;
|
|
11
|
+
buttonPressedBg: string;
|
|
12
|
+
};
|
|
13
|
+
export type BadgeColorStyles = {
|
|
14
|
+
root: string;
|
|
15
|
+
addon: string;
|
|
16
|
+
dotColor: DotColor;
|
|
17
|
+
addonButton: string;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Shared `Badge` style config, read by `index.tsx` (and by `index.native.tsx` once it exists).
|
|
21
|
+
*
|
|
22
|
+
* `types.standard` serves `Badge`, `BadgeWithFlag`, `BadgeWithImage`, `BadgeWithButton` and `BadgeIcon`:
|
|
23
|
+
* its `modern` type only offers `gray`, with the fill in `root`. `types.addon` serves `BadgeWithDot`
|
|
24
|
+
* and `BadgeWithIcon`: its `modern` type takes every colour, which tints only the dot or icon while
|
|
25
|
+
* the fill sits in `common`.
|
|
26
|
+
*
|
|
27
|
+
* Complete literal class names, never template literals — Tailwind scans source for whole candidates.
|
|
28
|
+
*/
|
|
29
|
+
export declare const styles: {
|
|
30
|
+
types: {
|
|
31
|
+
standard: {
|
|
32
|
+
"pill-color": {
|
|
33
|
+
common: string;
|
|
34
|
+
styles: Record<BadgeColors, BadgeColorStyles>;
|
|
35
|
+
};
|
|
36
|
+
color: {
|
|
37
|
+
common: string;
|
|
38
|
+
styles: Record<BadgeColors, BadgeColorStyles>;
|
|
39
|
+
};
|
|
40
|
+
modern: {
|
|
41
|
+
common: string;
|
|
42
|
+
styles: {
|
|
43
|
+
gray: {
|
|
44
|
+
root: string;
|
|
45
|
+
addon: string;
|
|
46
|
+
dotColor: "fg-quaternary";
|
|
47
|
+
addonButton: string;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
addon: {
|
|
53
|
+
"pill-color": {
|
|
54
|
+
common: string;
|
|
55
|
+
styles: Record<BadgeColors, BadgeColorStyles>;
|
|
56
|
+
};
|
|
57
|
+
color: {
|
|
58
|
+
common: string;
|
|
59
|
+
styles: Record<BadgeColors, BadgeColorStyles>;
|
|
60
|
+
};
|
|
61
|
+
modern: {
|
|
62
|
+
common: string;
|
|
63
|
+
styles: Record<BadgeColors, Omit<BadgeColorStyles, "addonButton">>;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
sizes: {
|
|
68
|
+
label: Record<BadgeTypes, Record<Sizes, string>>;
|
|
69
|
+
dot: Record<BadgeTypes, Record<Sizes, string>>;
|
|
70
|
+
icon: Record<BadgeTypes, Record<Sizes, {
|
|
71
|
+
trailing: string;
|
|
72
|
+
leading: string;
|
|
73
|
+
}>>;
|
|
74
|
+
/** Shared by `BadgeWithFlag` and `BadgeWithImage`, whose media sits flush to the leading edge. */
|
|
75
|
+
media: Record<BadgeTypes, Record<Sizes, string>>;
|
|
76
|
+
button: Record<BadgeTypes, Record<Sizes, string>>;
|
|
77
|
+
iconOnly: Record<BadgeTypes, Record<Sizes, string>>;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* React Native only. Text and icon colours are light-mode hex rather than tokens: `Text` ignores
|
|
81
|
+
* `className` under the current `react-native-css` preview (see `Avatar/index.native.tsx`) and an icon
|
|
82
|
+
* has no `currentColor` to inherit, so both take an explicit value, as `Button` does. `text` mirrors
|
|
83
|
+
* web's `*-700`, `addon` its `*-500`, and `button`, `buttonPressed` and `buttonPressedBg` the dismiss button's resting tint and `hover:` state.
|
|
84
|
+
* `bg` and `border` are classes because a `View` resolves them. Primitive hex values are
|
|
85
|
+
* Tailwind's, so they match web in light mode only.
|
|
86
|
+
*/
|
|
87
|
+
native: {
|
|
88
|
+
common: {
|
|
89
|
+
"pill-color": string;
|
|
90
|
+
color: string;
|
|
91
|
+
modern: string;
|
|
92
|
+
};
|
|
93
|
+
colors: {
|
|
94
|
+
gray: {
|
|
95
|
+
bg: string;
|
|
96
|
+
border: string;
|
|
97
|
+
text: string;
|
|
98
|
+
addon: string;
|
|
99
|
+
button: string;
|
|
100
|
+
buttonPressed: string;
|
|
101
|
+
buttonPressedBg: string;
|
|
102
|
+
};
|
|
103
|
+
brand: {
|
|
104
|
+
bg: string;
|
|
105
|
+
border: string;
|
|
106
|
+
text: string;
|
|
107
|
+
addon: string;
|
|
108
|
+
button: string;
|
|
109
|
+
buttonPressed: string;
|
|
110
|
+
buttonPressedBg: string;
|
|
111
|
+
};
|
|
112
|
+
error: {
|
|
113
|
+
bg: string;
|
|
114
|
+
border: string;
|
|
115
|
+
text: string;
|
|
116
|
+
addon: string;
|
|
117
|
+
button: string;
|
|
118
|
+
buttonPressed: string;
|
|
119
|
+
buttonPressedBg: string;
|
|
120
|
+
};
|
|
121
|
+
warning: {
|
|
122
|
+
bg: string;
|
|
123
|
+
border: string;
|
|
124
|
+
text: string;
|
|
125
|
+
addon: string;
|
|
126
|
+
button: string;
|
|
127
|
+
buttonPressed: string;
|
|
128
|
+
buttonPressedBg: string;
|
|
129
|
+
};
|
|
130
|
+
success: {
|
|
131
|
+
bg: string;
|
|
132
|
+
border: string;
|
|
133
|
+
text: string;
|
|
134
|
+
addon: string;
|
|
135
|
+
button: string;
|
|
136
|
+
buttonPressed: string;
|
|
137
|
+
buttonPressedBg: string;
|
|
138
|
+
};
|
|
139
|
+
slate: {
|
|
140
|
+
bg: string;
|
|
141
|
+
border: string;
|
|
142
|
+
text: string;
|
|
143
|
+
addon: string;
|
|
144
|
+
button: string;
|
|
145
|
+
buttonPressed: string;
|
|
146
|
+
buttonPressedBg: string;
|
|
147
|
+
};
|
|
148
|
+
sky: {
|
|
149
|
+
bg: string;
|
|
150
|
+
border: string;
|
|
151
|
+
text: string;
|
|
152
|
+
addon: string;
|
|
153
|
+
button: string;
|
|
154
|
+
buttonPressed: string;
|
|
155
|
+
buttonPressedBg: string;
|
|
156
|
+
};
|
|
157
|
+
blue: {
|
|
158
|
+
bg: string;
|
|
159
|
+
border: string;
|
|
160
|
+
text: string;
|
|
161
|
+
addon: string;
|
|
162
|
+
button: string;
|
|
163
|
+
buttonPressed: string;
|
|
164
|
+
buttonPressedBg: string;
|
|
165
|
+
};
|
|
166
|
+
indigo: {
|
|
167
|
+
bg: string;
|
|
168
|
+
border: string;
|
|
169
|
+
text: string;
|
|
170
|
+
addon: string;
|
|
171
|
+
button: string;
|
|
172
|
+
buttonPressed: string;
|
|
173
|
+
buttonPressedBg: string;
|
|
174
|
+
};
|
|
175
|
+
purple: {
|
|
176
|
+
bg: string;
|
|
177
|
+
border: string;
|
|
178
|
+
text: string;
|
|
179
|
+
addon: string;
|
|
180
|
+
button: string;
|
|
181
|
+
buttonPressed: string;
|
|
182
|
+
buttonPressedBg: string;
|
|
183
|
+
};
|
|
184
|
+
pink: {
|
|
185
|
+
bg: string;
|
|
186
|
+
border: string;
|
|
187
|
+
text: string;
|
|
188
|
+
addon: string;
|
|
189
|
+
button: string;
|
|
190
|
+
buttonPressed: string;
|
|
191
|
+
buttonPressedBg: string;
|
|
192
|
+
};
|
|
193
|
+
orange: {
|
|
194
|
+
bg: string;
|
|
195
|
+
border: string;
|
|
196
|
+
text: string;
|
|
197
|
+
addon: string;
|
|
198
|
+
button: string;
|
|
199
|
+
buttonPressed: string;
|
|
200
|
+
buttonPressedBg: string;
|
|
201
|
+
};
|
|
202
|
+
};
|
|
203
|
+
/** The neutral `modern` fill; `text` is `text-secondary` and `addon` is `fg-quaternary`. */
|
|
204
|
+
modern: {
|
|
205
|
+
bg: string;
|
|
206
|
+
border: string;
|
|
207
|
+
text: string;
|
|
208
|
+
addon: string;
|
|
209
|
+
button: string;
|
|
210
|
+
buttonPressed: string;
|
|
211
|
+
buttonPressedBg: string;
|
|
212
|
+
};
|
|
213
|
+
/** Pixel size of the leading, trailing and dismiss icons — web's `size-3`. */
|
|
214
|
+
iconSize: number;
|
|
215
|
+
/** Stroke width of those icons, in the 24px icon viewBox — web's `stroke-3`. */
|
|
216
|
+
iconStrokeWidth: number;
|
|
217
|
+
/** Diameter of the image in `BadgeWithImage` — web's `size-4`. */
|
|
218
|
+
imageSize: number;
|
|
219
|
+
/** Label type scale, web's `text-xs` for `sm` and `text-sm` otherwise. */
|
|
220
|
+
text: {
|
|
221
|
+
sm: {
|
|
222
|
+
fontSize: number;
|
|
223
|
+
lineHeight: number;
|
|
224
|
+
};
|
|
225
|
+
md: {
|
|
226
|
+
fontSize: number;
|
|
227
|
+
lineHeight: number;
|
|
228
|
+
};
|
|
229
|
+
lg: {
|
|
230
|
+
fontSize: number;
|
|
231
|
+
lineHeight: number;
|
|
232
|
+
};
|
|
233
|
+
};
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
//# sourceMappingURL=Badge.styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Badge.styles.d.ts","sourceRoot":"","sources":["../../../../../src/components/atoms/Badge/Badge.styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2CAA2C,CAAC;AAC1E,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAGpE,8GAA8G;AAC9G,MAAM,MAAM,UAAU,GAAG;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,QAAQ,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC;AAuGxG;;;;;;;;;GASG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAuEf,kGAAkG;;;;;IA2BpG;;;;;;;OAOG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAiID,4FAA4F;;;;;;;;;;QAW5F,8EAA8E;;QAE9E,gFAAgF;;QAEhF,kEAAkE;;QAElE,0EAA0E;;;;;;;;;;;;;;;;CAO7E,CAAC"}
|