@mediaradar/design-components 0.21.0 → 0.22.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/index.cjs CHANGED
@@ -786,7 +786,7 @@ function slug2(value) {
786
786
  return value.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/(^-|-$)/g, "");
787
787
  }
788
788
  function DateRangeFilter({
789
- caption = "Date Range",
789
+ caption = "Date range",
790
790
  defaultValue,
791
791
  value: controlledValue,
792
792
  range: controlledRange,
@@ -924,9 +924,9 @@ function DateRangeFilter({
924
924
  )) }),
925
925
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex flex-col p-4", children: [
926
926
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex items-end gap-3", children: [
927
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Field, { label: "Start Date", value: start ? fmt(start) : "\u2014" }),
927
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Field, { label: "Start date", value: start ? fmt(start) : "\u2014" }),
928
928
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "pb-2.5 text-text-tertiary", children: "\u2014" }),
929
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Field, { label: "End Date", value: end ? fmt(end) : start ? fmt(start) : "\u2014" })
929
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Field, { label: "End date", value: end ? fmt(end) : start ? fmt(start) : "\u2014" })
930
930
  ] }),
931
931
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "my-4 border-t border-border-default" }),
932
932
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "flex gap-8", children: [0, 1].map((offset) => {
@@ -3301,17 +3301,17 @@ function pageWindow(current, total) {
3301
3301
  }
3302
3302
  return out;
3303
3303
  }
3304
- function Pager({ page, totalPages, onPage }) {
3305
- const btn = "flex h-8 min-w-8 items-center justify-center rounded-control px-2 text-[13px] transition-colors";
3304
+ function Pager({ page, totalPages, onPage, disabled = false }) {
3305
+ 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";
3306
3306
  return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("div", { className: "flex items-center gap-1", children: [
3307
3307
  /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
3308
3308
  "button",
3309
3309
  {
3310
3310
  type: "button",
3311
3311
  onClick: () => onPage(page - 1),
3312
- disabled: page === 1,
3312
+ disabled: disabled || page === 1,
3313
3313
  "aria-label": "Previous page",
3314
- className: cn(btn, "text-text-secondary hover:bg-subtle hover:text-text-primary disabled:pointer-events-none disabled:opacity-30"),
3314
+ className: cn(btn, "text-text-secondary hover:bg-subtle hover:text-text-primary"),
3315
3315
  children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_lucide_react19.ChevronLeft, { size: 16 })
3316
3316
  }
3317
3317
  ),
@@ -3321,6 +3321,7 @@ function Pager({ page, totalPages, onPage }) {
3321
3321
  {
3322
3322
  type: "button",
3323
3323
  onClick: () => onPage(p),
3324
+ disabled,
3324
3325
  "aria-current": p === page ? "page" : void 0,
3325
3326
  className: cn(
3326
3327
  btn,
@@ -3336,9 +3337,9 @@ function Pager({ page, totalPages, onPage }) {
3336
3337
  {
3337
3338
  type: "button",
3338
3339
  onClick: () => onPage(page + 1),
3339
- disabled: page === totalPages,
3340
+ disabled: disabled || page === totalPages,
3340
3341
  "aria-label": "Next page",
3341
- className: cn(btn, "text-text-secondary hover:bg-subtle hover:text-text-primary disabled:pointer-events-none disabled:opacity-30"),
3342
+ className: cn(btn, "text-text-secondary hover:bg-subtle hover:text-text-primary"),
3342
3343
  children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_lucide_react19.ChevronRight, { size: 16 })
3343
3344
  }
3344
3345
  )
@@ -3482,6 +3483,7 @@ function TablePagination({
3482
3483
  onPerPageChange,
3483
3484
  perPageOptions = [25, 50, 100],
3484
3485
  itemLabel = "results",
3486
+ disabled = false,
3485
3487
  className,
3486
3488
  testIdPrefix
3487
3489
  }) {
@@ -3490,21 +3492,32 @@ function TablePagination({
3490
3492
  const rangeStart = totalItems === 0 ? 0 : (current - 1) * perPage + 1;
3491
3493
  const rangeEnd = Math.min(current * perPage, totalItems);
3492
3494
  const btn = "flex h-8 min-w-8 items-center justify-center rounded-control px-2 text-[13px] transition-colors";
3493
- const stepBtn = cn(
3494
- btn,
3495
- "text-text-secondary hover:bg-subtle hover:text-text-primary disabled:pointer-events-none disabled:opacity-30"
3496
- );
3495
+ const off = "disabled:pointer-events-none disabled:opacity-30";
3496
+ const stepBtn = cn(btn, "text-text-secondary hover:bg-subtle hover:text-text-primary", off);
3497
+ const range = /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("span", { className: "text-[13px] text-text-tertiary tabular-nums", children: [
3498
+ rangeStart.toLocaleString(),
3499
+ " \u2013 ",
3500
+ rangeEnd.toLocaleString(),
3501
+ " of ",
3502
+ totalItems.toLocaleString(),
3503
+ " ",
3504
+ itemLabel
3505
+ ] });
3497
3506
  return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: cn("flex flex-wrap items-center justify-between gap-x-4 gap-y-2", className), "data-testid": testIdPrefix, children: [
3498
- /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("label", { className: "flex items-center gap-2 text-[13px] text-text-secondary", children: [
3507
+ onPerPageChange ? /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("label", { className: "flex items-center gap-2 text-[13px] text-text-secondary", children: [
3499
3508
  /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("span", { className: "relative", children: [
3500
3509
  /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3501
3510
  "select",
3502
3511
  {
3503
3512
  value: perPage,
3504
3513
  onChange: (e) => onPerPageChange(Number(e.target.value)),
3514
+ disabled,
3505
3515
  "aria-label": "Items per page",
3506
3516
  "data-testid": testIdPrefix && `${testIdPrefix}-per-page`,
3507
- className: "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",
3517
+ className: cn(
3518
+ "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",
3519
+ off
3520
+ ),
3508
3521
  children: perPageOptions.map((n) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("option", { value: n, children: n }, n))
3509
3522
  }
3510
3523
  ),
@@ -3518,14 +3531,14 @@ function TablePagination({
3518
3531
  )
3519
3532
  ] }),
3520
3533
  "items per page"
3521
- ] }),
3534
+ ] }) : range,
3522
3535
  /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("nav", { className: "flex items-center gap-1", "aria-label": "Pagination", children: [
3523
3536
  /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
3524
3537
  "button",
3525
3538
  {
3526
3539
  type: "button",
3527
3540
  onClick: () => onPageChange(1),
3528
- disabled: current === 1,
3541
+ disabled: disabled || current === 1,
3529
3542
  "aria-label": "First page",
3530
3543
  "data-testid": testIdPrefix && `${testIdPrefix}-first`,
3531
3544
  className: stepBtn,
@@ -3537,7 +3550,7 @@ function TablePagination({
3537
3550
  {
3538
3551
  type: "button",
3539
3552
  onClick: () => onPageChange(current - 1),
3540
- disabled: current === 1,
3553
+ disabled: disabled || current === 1,
3541
3554
  "aria-label": "Previous page",
3542
3555
  "data-testid": testIdPrefix && `${testIdPrefix}-prev`,
3543
3556
  className: stepBtn,
@@ -3551,9 +3564,11 @@ function TablePagination({
3551
3564
  type: "button",
3552
3565
  "data-testid": testIdPrefix && `${testIdPrefix}-page-${p}`,
3553
3566
  onClick: () => onPageChange(p),
3567
+ disabled,
3554
3568
  "aria-current": p === current ? "page" : void 0,
3555
3569
  className: cn(
3556
3570
  btn,
3571
+ off,
3557
3572
  p === current ? "bg-brand-primaryAction font-semibold text-brand-onprimary" : "text-text-secondary hover:bg-subtle hover:text-text-primary"
3558
3573
  ),
3559
3574
  children: p
@@ -3566,7 +3581,7 @@ function TablePagination({
3566
3581
  {
3567
3582
  type: "button",
3568
3583
  onClick: () => onPageChange(current + 1),
3569
- disabled: current === totalPages,
3584
+ disabled: disabled || current === totalPages,
3570
3585
  "aria-label": "Next page",
3571
3586
  "data-testid": testIdPrefix && `${testIdPrefix}-next`,
3572
3587
  className: stepBtn,
@@ -3578,7 +3593,7 @@ function TablePagination({
3578
3593
  {
3579
3594
  type: "button",
3580
3595
  onClick: () => onPageChange(totalPages),
3581
- disabled: current === totalPages,
3596
+ disabled: disabled || current === totalPages,
3582
3597
  "aria-label": "Last page",
3583
3598
  "data-testid": testIdPrefix && `${testIdPrefix}-last`,
3584
3599
  className: stepBtn,
@@ -3586,15 +3601,7 @@ function TablePagination({
3586
3601
  }
3587
3602
  )
3588
3603
  ] }),
3589
- /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("span", { className: "text-[13px] text-text-tertiary tabular-nums", children: [
3590
- rangeStart.toLocaleString(),
3591
- " \u2013 ",
3592
- rangeEnd.toLocaleString(),
3593
- " of ",
3594
- totalItems.toLocaleString(),
3595
- " ",
3596
- itemLabel
3597
- ] })
3604
+ onPerPageChange && range
3598
3605
  ] });
3599
3606
  }
3600
3607
 
@@ -3737,7 +3744,7 @@ function DateRangePicker({
3737
3744
  p
3738
3745
  )),
3739
3746
  /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "mt-1 border-t border-border-default px-3 pb-2 pt-2", children: [
3740
- /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "text-[13px] font-semibold text-text-primary", children: "Custom Range" }),
3747
+ /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "text-[13px] font-semibold text-text-primary", children: "Custom range" }),
3741
3748
  /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "mt-2 flex flex-col gap-2", children: [
3742
3749
  /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("label", { className: "flex items-center justify-between gap-2 text-[12px] text-text-secondary", children: [
3743
3750
  "From",