@mediaradar/design-components 0.21.0 → 0.22.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/index.cjs +33 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -6
- package/dist/index.d.ts +24 -6
- package/dist/index.js +33 -26
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1882,12 +1882,19 @@ interface PagerProps {
|
|
|
1882
1882
|
page: number;
|
|
1883
1883
|
totalPages: number;
|
|
1884
1884
|
onPage: (p: number) => void;
|
|
1885
|
+
/** Disables every control, e.g. while the list loads the next page. */
|
|
1886
|
+
disabled?: boolean;
|
|
1885
1887
|
}
|
|
1886
1888
|
/**
|
|
1887
1889
|
* @pattern Pager
|
|
1888
1890
|
* @description Compact prev/next pager with a windowed page-number list —
|
|
1889
1891
|
* shows every page up to 7 total, otherwise 1 … current±1 … last with
|
|
1890
|
-
* ellipsis gaps. Shared by My Exports and Account Matcher.
|
|
1892
|
+
* ellipsis gaps. Shared by My Exports and Account Matcher. `disabled`
|
|
1893
|
+
* disables every control while the list loads.
|
|
1894
|
+
* @use in a card or a compact list, with the range ("Showing 1–10 of 48") on
|
|
1895
|
+
* the left if the reader needs it.
|
|
1896
|
+
* @avoid under a full-page table -- use TablePagination, which adds the
|
|
1897
|
+
* first/last steps, the range readout and the rows-per-page select.
|
|
1891
1898
|
* @tokens rounded-control, text-text-secondary, bg-brand-primaryAction, text-brand-onprimary, hover:bg-subtle, hover:text-text-primary, text-text-tertiary
|
|
1892
1899
|
* @dependencies lucide-react
|
|
1893
1900
|
* @a11y Page controls are buttons with their own aria-labels, and the current
|
|
@@ -1898,7 +1905,7 @@ interface PagerProps {
|
|
|
1898
1905
|
* <Pager page={page} totalPages={totalPages} onPage={setPage} />
|
|
1899
1906
|
* ```
|
|
1900
1907
|
*/
|
|
1901
|
-
declare function Pager({ page, totalPages, onPage }: PagerProps): react.JSX.Element;
|
|
1908
|
+
declare function Pager({ page, totalPages, onPage, disabled }: PagerProps): react.JSX.Element;
|
|
1902
1909
|
|
|
1903
1910
|
declare const SIZES$1: {
|
|
1904
1911
|
/** Matches a 15px lucide icon exactly, so a workspace name in a menu row
|
|
@@ -2058,14 +2065,22 @@ declare function Tag({ children, className }: TagProps): react.JSX.Element;
|
|
|
2058
2065
|
* @description Full table-footer pagination bar: a rows-per-page select, a
|
|
2059
2066
|
* first/prev/pages/next/last pager, and the resolved "1 – 25 of N results"
|
|
2060
2067
|
* range. Owns no state — the host page holds `page` and `perPage` so the
|
|
2061
|
-
* paged slice and the bar can't disagree.
|
|
2068
|
+
* paged slice and the bar can't disagree. Without `onPerPageChange` the
|
|
2069
|
+
* select is left out, and the range moves to the left of the pager.
|
|
2070
|
+
* @use under a full-page table: the results of a search or a list the user
|
|
2071
|
+
* works through, where the total and the page size matter.
|
|
2072
|
+
* @avoid in a card or a compact list -- use Pager, which is only the page
|
|
2073
|
+
* controls and fits the narrower space.
|
|
2062
2074
|
* @tokens border-border-strong, rounded-control, bg-input, text-text-primary, text-text-secondary, text-text-tertiary, bg-brand-primaryAction, text-brand-onprimary, hover:bg-subtle, hover:text-text-primary, focus:outline-border-focus
|
|
2063
2075
|
* @behavior The current page is filled with the brand action color (matching
|
|
2064
2076
|
* the Contacts pager). First/prev disable on page 1, next/last on the last
|
|
2065
2077
|
* page — disabled controls stay in the layout so the row never reflows.
|
|
2066
2078
|
* Changing the per-page count reports it and leaves the host to reset to page
|
|
2067
2079
|
* 1. With one page of results the pager still renders, so the bar's height
|
|
2068
|
-
* and the range readout don't come and go as filters narrow.
|
|
2080
|
+
* and the range readout don't come and go as filters narrow. `disabled`
|
|
2081
|
+
* disables every control (select and page buttons) while the table loads,
|
|
2082
|
+
* so a click can't request a second page on top of the first; the range
|
|
2083
|
+
* readout stays.
|
|
2069
2084
|
* @a11y A <nav aria-label="Pagination"> wrapping <button> controls, each with
|
|
2070
2085
|
* its own aria-label (Previous/Next/Last). The chevron icons are aria-
|
|
2071
2086
|
* hidden, so the labels are the only accessible names -- don't override
|
|
@@ -2082,14 +2097,17 @@ declare function Tag({ children, className }: TagProps): react.JSX.Element;
|
|
|
2082
2097
|
* />
|
|
2083
2098
|
* ```
|
|
2084
2099
|
*/
|
|
2085
|
-
declare function TablePagination({ page, perPage, totalItems, onPageChange, onPerPageChange, perPageOptions, itemLabel, className, testIdPrefix, }: {
|
|
2100
|
+
declare function TablePagination({ page, perPage, totalItems, onPageChange, onPerPageChange, perPageOptions, itemLabel, disabled, className, testIdPrefix, }: {
|
|
2086
2101
|
page: number;
|
|
2087
2102
|
perPage: number;
|
|
2088
2103
|
totalItems: number;
|
|
2089
2104
|
onPageChange: (page: number) => void;
|
|
2090
|
-
|
|
2105
|
+
/** Omit to hide the rows-per-page select, for a table with a fixed page size. */
|
|
2106
|
+
onPerPageChange?: (perPage: number) => void;
|
|
2091
2107
|
perPageOptions?: number[];
|
|
2092
2108
|
itemLabel?: string;
|
|
2109
|
+
/** Disables every control, e.g. while the table loads the next page. */
|
|
2110
|
+
disabled?: boolean;
|
|
2093
2111
|
className?: string;
|
|
2094
2112
|
/**
|
|
2095
2113
|
* Optional prefix for `data-testid` attributes on the bar (`testIdPrefix`
|
package/dist/index.d.ts
CHANGED
|
@@ -1882,12 +1882,19 @@ interface PagerProps {
|
|
|
1882
1882
|
page: number;
|
|
1883
1883
|
totalPages: number;
|
|
1884
1884
|
onPage: (p: number) => void;
|
|
1885
|
+
/** Disables every control, e.g. while the list loads the next page. */
|
|
1886
|
+
disabled?: boolean;
|
|
1885
1887
|
}
|
|
1886
1888
|
/**
|
|
1887
1889
|
* @pattern Pager
|
|
1888
1890
|
* @description Compact prev/next pager with a windowed page-number list —
|
|
1889
1891
|
* shows every page up to 7 total, otherwise 1 … current±1 … last with
|
|
1890
|
-
* ellipsis gaps. Shared by My Exports and Account Matcher.
|
|
1892
|
+
* ellipsis gaps. Shared by My Exports and Account Matcher. `disabled`
|
|
1893
|
+
* disables every control while the list loads.
|
|
1894
|
+
* @use in a card or a compact list, with the range ("Showing 1–10 of 48") on
|
|
1895
|
+
* the left if the reader needs it.
|
|
1896
|
+
* @avoid under a full-page table -- use TablePagination, which adds the
|
|
1897
|
+
* first/last steps, the range readout and the rows-per-page select.
|
|
1891
1898
|
* @tokens rounded-control, text-text-secondary, bg-brand-primaryAction, text-brand-onprimary, hover:bg-subtle, hover:text-text-primary, text-text-tertiary
|
|
1892
1899
|
* @dependencies lucide-react
|
|
1893
1900
|
* @a11y Page controls are buttons with their own aria-labels, and the current
|
|
@@ -1898,7 +1905,7 @@ interface PagerProps {
|
|
|
1898
1905
|
* <Pager page={page} totalPages={totalPages} onPage={setPage} />
|
|
1899
1906
|
* ```
|
|
1900
1907
|
*/
|
|
1901
|
-
declare function Pager({ page, totalPages, onPage }: PagerProps): react.JSX.Element;
|
|
1908
|
+
declare function Pager({ page, totalPages, onPage, disabled }: PagerProps): react.JSX.Element;
|
|
1902
1909
|
|
|
1903
1910
|
declare const SIZES$1: {
|
|
1904
1911
|
/** Matches a 15px lucide icon exactly, so a workspace name in a menu row
|
|
@@ -2058,14 +2065,22 @@ declare function Tag({ children, className }: TagProps): react.JSX.Element;
|
|
|
2058
2065
|
* @description Full table-footer pagination bar: a rows-per-page select, a
|
|
2059
2066
|
* first/prev/pages/next/last pager, and the resolved "1 – 25 of N results"
|
|
2060
2067
|
* range. Owns no state — the host page holds `page` and `perPage` so the
|
|
2061
|
-
* paged slice and the bar can't disagree.
|
|
2068
|
+
* paged slice and the bar can't disagree. Without `onPerPageChange` the
|
|
2069
|
+
* select is left out, and the range moves to the left of the pager.
|
|
2070
|
+
* @use under a full-page table: the results of a search or a list the user
|
|
2071
|
+
* works through, where the total and the page size matter.
|
|
2072
|
+
* @avoid in a card or a compact list -- use Pager, which is only the page
|
|
2073
|
+
* controls and fits the narrower space.
|
|
2062
2074
|
* @tokens border-border-strong, rounded-control, bg-input, text-text-primary, text-text-secondary, text-text-tertiary, bg-brand-primaryAction, text-brand-onprimary, hover:bg-subtle, hover:text-text-primary, focus:outline-border-focus
|
|
2063
2075
|
* @behavior The current page is filled with the brand action color (matching
|
|
2064
2076
|
* the Contacts pager). First/prev disable on page 1, next/last on the last
|
|
2065
2077
|
* page — disabled controls stay in the layout so the row never reflows.
|
|
2066
2078
|
* Changing the per-page count reports it and leaves the host to reset to page
|
|
2067
2079
|
* 1. With one page of results the pager still renders, so the bar's height
|
|
2068
|
-
* and the range readout don't come and go as filters narrow.
|
|
2080
|
+
* and the range readout don't come and go as filters narrow. `disabled`
|
|
2081
|
+
* disables every control (select and page buttons) while the table loads,
|
|
2082
|
+
* so a click can't request a second page on top of the first; the range
|
|
2083
|
+
* readout stays.
|
|
2069
2084
|
* @a11y A <nav aria-label="Pagination"> wrapping <button> controls, each with
|
|
2070
2085
|
* its own aria-label (Previous/Next/Last). The chevron icons are aria-
|
|
2071
2086
|
* hidden, so the labels are the only accessible names -- don't override
|
|
@@ -2082,14 +2097,17 @@ declare function Tag({ children, className }: TagProps): react.JSX.Element;
|
|
|
2082
2097
|
* />
|
|
2083
2098
|
* ```
|
|
2084
2099
|
*/
|
|
2085
|
-
declare function TablePagination({ page, perPage, totalItems, onPageChange, onPerPageChange, perPageOptions, itemLabel, className, testIdPrefix, }: {
|
|
2100
|
+
declare function TablePagination({ page, perPage, totalItems, onPageChange, onPerPageChange, perPageOptions, itemLabel, disabled, className, testIdPrefix, }: {
|
|
2086
2101
|
page: number;
|
|
2087
2102
|
perPage: number;
|
|
2088
2103
|
totalItems: number;
|
|
2089
2104
|
onPageChange: (page: number) => void;
|
|
2090
|
-
|
|
2105
|
+
/** Omit to hide the rows-per-page select, for a table with a fixed page size. */
|
|
2106
|
+
onPerPageChange?: (perPage: number) => void;
|
|
2091
2107
|
perPageOptions?: number[];
|
|
2092
2108
|
itemLabel?: string;
|
|
2109
|
+
/** Disables every control, e.g. while the table loads the next page. */
|
|
2110
|
+
disabled?: boolean;
|
|
2093
2111
|
className?: string;
|
|
2094
2112
|
/**
|
|
2095
2113
|
* Optional prefix for `data-testid` attributes on the bar (`testIdPrefix`
|
package/dist/index.js
CHANGED
|
@@ -3217,17 +3217,17 @@ function pageWindow(current, total) {
|
|
|
3217
3217
|
}
|
|
3218
3218
|
return out;
|
|
3219
3219
|
}
|
|
3220
|
-
function Pager({ page, totalPages, onPage }) {
|
|
3221
|
-
const btn = "flex h-8 min-w-8 items-center justify-center rounded-control px-2 text-[13px] transition-colors";
|
|
3220
|
+
function Pager({ page, totalPages, onPage, disabled = false }) {
|
|
3221
|
+
const btn = "flex h-8 min-w-8 items-center justify-center rounded-control px-2 text-[13px] transition-colors disabled:pointer-events-none disabled:opacity-30";
|
|
3222
3222
|
return /* @__PURE__ */ jsxs30("div", { className: "flex items-center gap-1", children: [
|
|
3223
3223
|
/* @__PURE__ */ jsx32(
|
|
3224
3224
|
"button",
|
|
3225
3225
|
{
|
|
3226
3226
|
type: "button",
|
|
3227
3227
|
onClick: () => onPage(page - 1),
|
|
3228
|
-
disabled: page === 1,
|
|
3228
|
+
disabled: disabled || page === 1,
|
|
3229
3229
|
"aria-label": "Previous page",
|
|
3230
|
-
className: cn(btn, "text-text-secondary hover:bg-subtle hover:text-text-primary
|
|
3230
|
+
className: cn(btn, "text-text-secondary hover:bg-subtle hover:text-text-primary"),
|
|
3231
3231
|
children: /* @__PURE__ */ jsx32(ChevronLeft3, { size: 16 })
|
|
3232
3232
|
}
|
|
3233
3233
|
),
|
|
@@ -3237,6 +3237,7 @@ function Pager({ page, totalPages, onPage }) {
|
|
|
3237
3237
|
{
|
|
3238
3238
|
type: "button",
|
|
3239
3239
|
onClick: () => onPage(p),
|
|
3240
|
+
disabled,
|
|
3240
3241
|
"aria-current": p === page ? "page" : void 0,
|
|
3241
3242
|
className: cn(
|
|
3242
3243
|
btn,
|
|
@@ -3252,9 +3253,9 @@ function Pager({ page, totalPages, onPage }) {
|
|
|
3252
3253
|
{
|
|
3253
3254
|
type: "button",
|
|
3254
3255
|
onClick: () => onPage(page + 1),
|
|
3255
|
-
disabled: page === totalPages,
|
|
3256
|
+
disabled: disabled || page === totalPages,
|
|
3256
3257
|
"aria-label": "Next page",
|
|
3257
|
-
className: cn(btn, "text-text-secondary hover:bg-subtle hover:text-text-primary
|
|
3258
|
+
className: cn(btn, "text-text-secondary hover:bg-subtle hover:text-text-primary"),
|
|
3258
3259
|
children: /* @__PURE__ */ jsx32(ChevronRight4, { size: 16 })
|
|
3259
3260
|
}
|
|
3260
3261
|
)
|
|
@@ -3398,6 +3399,7 @@ function TablePagination({
|
|
|
3398
3399
|
onPerPageChange,
|
|
3399
3400
|
perPageOptions = [25, 50, 100],
|
|
3400
3401
|
itemLabel = "results",
|
|
3402
|
+
disabled = false,
|
|
3401
3403
|
className,
|
|
3402
3404
|
testIdPrefix
|
|
3403
3405
|
}) {
|
|
@@ -3406,21 +3408,32 @@ function TablePagination({
|
|
|
3406
3408
|
const rangeStart = totalItems === 0 ? 0 : (current - 1) * perPage + 1;
|
|
3407
3409
|
const rangeEnd = Math.min(current * perPage, totalItems);
|
|
3408
3410
|
const btn = "flex h-8 min-w-8 items-center justify-center rounded-control px-2 text-[13px] transition-colors";
|
|
3409
|
-
const
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3411
|
+
const off = "disabled:pointer-events-none disabled:opacity-30";
|
|
3412
|
+
const stepBtn = cn(btn, "text-text-secondary hover:bg-subtle hover:text-text-primary", off);
|
|
3413
|
+
const range = /* @__PURE__ */ jsxs32("span", { className: "text-[13px] text-text-tertiary tabular-nums", children: [
|
|
3414
|
+
rangeStart.toLocaleString(),
|
|
3415
|
+
" \u2013 ",
|
|
3416
|
+
rangeEnd.toLocaleString(),
|
|
3417
|
+
" of ",
|
|
3418
|
+
totalItems.toLocaleString(),
|
|
3419
|
+
" ",
|
|
3420
|
+
itemLabel
|
|
3421
|
+
] });
|
|
3413
3422
|
return /* @__PURE__ */ jsxs32("div", { className: cn("flex flex-wrap items-center justify-between gap-x-4 gap-y-2", className), "data-testid": testIdPrefix, children: [
|
|
3414
|
-
/* @__PURE__ */ jsxs32("label", { className: "flex items-center gap-2 text-[13px] text-text-secondary", children: [
|
|
3423
|
+
onPerPageChange ? /* @__PURE__ */ jsxs32("label", { className: "flex items-center gap-2 text-[13px] text-text-secondary", children: [
|
|
3415
3424
|
/* @__PURE__ */ jsxs32("span", { className: "relative", children: [
|
|
3416
3425
|
/* @__PURE__ */ jsx36(
|
|
3417
3426
|
"select",
|
|
3418
3427
|
{
|
|
3419
3428
|
value: perPage,
|
|
3420
3429
|
onChange: (e) => onPerPageChange(Number(e.target.value)),
|
|
3430
|
+
disabled,
|
|
3421
3431
|
"aria-label": "Items per page",
|
|
3422
3432
|
"data-testid": testIdPrefix && `${testIdPrefix}-per-page`,
|
|
3423
|
-
className:
|
|
3433
|
+
className: cn(
|
|
3434
|
+
"appearance-none rounded-control border border-border-strong bg-input py-1 pl-2.5 pr-7 text-[13px] font-medium text-text-primary focus:outline focus:outline-2 focus:outline-border-focus",
|
|
3435
|
+
off
|
|
3436
|
+
),
|
|
3424
3437
|
children: perPageOptions.map((n) => /* @__PURE__ */ jsx36("option", { value: n, children: n }, n))
|
|
3425
3438
|
}
|
|
3426
3439
|
),
|
|
@@ -3434,14 +3447,14 @@ function TablePagination({
|
|
|
3434
3447
|
)
|
|
3435
3448
|
] }),
|
|
3436
3449
|
"items per page"
|
|
3437
|
-
] }),
|
|
3450
|
+
] }) : range,
|
|
3438
3451
|
/* @__PURE__ */ jsxs32("nav", { className: "flex items-center gap-1", "aria-label": "Pagination", children: [
|
|
3439
3452
|
/* @__PURE__ */ jsx36(
|
|
3440
3453
|
"button",
|
|
3441
3454
|
{
|
|
3442
3455
|
type: "button",
|
|
3443
3456
|
onClick: () => onPageChange(1),
|
|
3444
|
-
disabled: current === 1,
|
|
3457
|
+
disabled: disabled || current === 1,
|
|
3445
3458
|
"aria-label": "First page",
|
|
3446
3459
|
"data-testid": testIdPrefix && `${testIdPrefix}-first`,
|
|
3447
3460
|
className: stepBtn,
|
|
@@ -3453,7 +3466,7 @@ function TablePagination({
|
|
|
3453
3466
|
{
|
|
3454
3467
|
type: "button",
|
|
3455
3468
|
onClick: () => onPageChange(current - 1),
|
|
3456
|
-
disabled: current === 1,
|
|
3469
|
+
disabled: disabled || current === 1,
|
|
3457
3470
|
"aria-label": "Previous page",
|
|
3458
3471
|
"data-testid": testIdPrefix && `${testIdPrefix}-prev`,
|
|
3459
3472
|
className: stepBtn,
|
|
@@ -3467,9 +3480,11 @@ function TablePagination({
|
|
|
3467
3480
|
type: "button",
|
|
3468
3481
|
"data-testid": testIdPrefix && `${testIdPrefix}-page-${p}`,
|
|
3469
3482
|
onClick: () => onPageChange(p),
|
|
3483
|
+
disabled,
|
|
3470
3484
|
"aria-current": p === current ? "page" : void 0,
|
|
3471
3485
|
className: cn(
|
|
3472
3486
|
btn,
|
|
3487
|
+
off,
|
|
3473
3488
|
p === current ? "bg-brand-primaryAction font-semibold text-brand-onprimary" : "text-text-secondary hover:bg-subtle hover:text-text-primary"
|
|
3474
3489
|
),
|
|
3475
3490
|
children: p
|
|
@@ -3482,7 +3497,7 @@ function TablePagination({
|
|
|
3482
3497
|
{
|
|
3483
3498
|
type: "button",
|
|
3484
3499
|
onClick: () => onPageChange(current + 1),
|
|
3485
|
-
disabled: current === totalPages,
|
|
3500
|
+
disabled: disabled || current === totalPages,
|
|
3486
3501
|
"aria-label": "Next page",
|
|
3487
3502
|
"data-testid": testIdPrefix && `${testIdPrefix}-next`,
|
|
3488
3503
|
className: stepBtn,
|
|
@@ -3494,7 +3509,7 @@ function TablePagination({
|
|
|
3494
3509
|
{
|
|
3495
3510
|
type: "button",
|
|
3496
3511
|
onClick: () => onPageChange(totalPages),
|
|
3497
|
-
disabled: current === totalPages,
|
|
3512
|
+
disabled: disabled || current === totalPages,
|
|
3498
3513
|
"aria-label": "Last page",
|
|
3499
3514
|
"data-testid": testIdPrefix && `${testIdPrefix}-last`,
|
|
3500
3515
|
className: stepBtn,
|
|
@@ -3502,15 +3517,7 @@ function TablePagination({
|
|
|
3502
3517
|
}
|
|
3503
3518
|
)
|
|
3504
3519
|
] }),
|
|
3505
|
-
|
|
3506
|
-
rangeStart.toLocaleString(),
|
|
3507
|
-
" \u2013 ",
|
|
3508
|
-
rangeEnd.toLocaleString(),
|
|
3509
|
-
" of ",
|
|
3510
|
-
totalItems.toLocaleString(),
|
|
3511
|
-
" ",
|
|
3512
|
-
itemLabel
|
|
3513
|
-
] })
|
|
3520
|
+
onPerPageChange && range
|
|
3514
3521
|
] });
|
|
3515
3522
|
}
|
|
3516
3523
|
|