@nearform/quantum 1.7.1 → 1.7.3

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.d.mts CHANGED
@@ -198,6 +198,10 @@ declare const _default: {
198
198
  DEFAULT: string;
199
199
  dark: string;
200
200
  };
201
+ surface: {
202
+ DEFAULT: string;
203
+ dark: string;
204
+ };
201
205
  inverse: {
202
206
  DEFAULT: string;
203
207
  dark: string;
package/dist/index.d.ts CHANGED
@@ -198,6 +198,10 @@ declare const _default: {
198
198
  DEFAULT: string;
199
199
  dark: string;
200
200
  };
201
+ surface: {
202
+ DEFAULT: string;
203
+ dark: string;
204
+ };
201
205
  inverse: {
202
206
  DEFAULT: string;
203
207
  dark: string;
package/dist/index.js CHANGED
@@ -364,6 +364,26 @@ var background = {
364
364
  DEFAULT: colors.grey["50"],
365
365
  dark: colors.grey["800"]
366
366
  },
367
+ /**
368
+ * The resting fill of a container that sits on the page: a card, a popover,
369
+ * a table body, a dialog panel.
370
+ *
371
+ * It exists because `background` cannot play that role in both modes. In
372
+ * light the page is `background-alt` and `background` is a step off it, so a
373
+ * surface painted `background` reads as raised (1.10:1). In dark the page is
374
+ * `background` itself, so the same class paints the surface the colour of
375
+ * the page it sits on - 1.00:1, a container that is only a container because
376
+ * of its border.
377
+ *
378
+ * So the light value is `background`'s, unchanged, and the dark value is one
379
+ * step up from the page. That keeps the step `subtle` adds for a header or a
380
+ * zebra stripe (1.21:1 above this, against light's 1.05:1) and leaves `alt`
381
+ * free for the selected row, which would otherwise collide with the stripes.
382
+ */
383
+ surface: {
384
+ DEFAULT: "#FFF",
385
+ dark: colors.grey["900"]
386
+ },
367
387
  inverse: {
368
388
  DEFAULT: colors.grey["900"],
369
389
  dark: "#FFF"
@@ -1794,9 +1814,9 @@ var cardVariants = (0, import_class_variance_authority11.cva)(
1794
1814
  variants: {
1795
1815
  variant: {
1796
1816
  outline: [
1797
- "bg-background",
1817
+ "bg-background-surface",
1798
1818
  "border-border",
1799
- "dark:bg-grey-900",
1819
+ "dark:bg-background-surface-dark",
1800
1820
  "dark:border-grey-700"
1801
1821
  ],
1802
1822
  filled: [
@@ -3448,7 +3468,7 @@ var ModalContent = React23.forwardRef((_a, ref) => {
3448
3468
  __spreadProps(__spreadValues({
3449
3469
  ref,
3450
3470
  className: cn(
3451
- "fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-6 shadow-lg bg-background dark:bg-foreground duration-200 sm:rounded-lg",
3471
+ "fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-6 shadow-lg bg-background-surface dark:bg-background-surface-dark duration-200 sm:rounded-lg",
3452
3472
  className
3453
3473
  )
3454
3474
  }, props), {
@@ -3585,7 +3605,7 @@ var PageHeaderContext = React24.createContext("md");
3585
3605
  var pageHeaderVariants = (0, import_class_variance_authority20.cva)(
3586
3606
  [
3587
3607
  "flex flex-wrap items-center justify-between gap-x-6 gap-y-2",
3588
- "rounded-lg bg-background dark:bg-background-dark",
3608
+ "rounded-lg bg-background-surface dark:bg-background-surface-dark",
3589
3609
  "text-foreground dark:text-foreground-dark"
3590
3610
  ],
3591
3611
  {
@@ -3694,6 +3714,44 @@ var StepButtonStyles = (0, import_class_variance_authority21.cva)([
3694
3714
  "disabled:text-foreground-subtle",
3695
3715
  "dark:disabled:text-foreground-subtle-dark"
3696
3716
  ]);
3717
+ var noOfSiblings = 1;
3718
+ var noOfPagesShown = noOfSiblings * 2 + 5;
3719
+ var range = (from, to) => Array.from({ length: Math.max(0, to - from + 1) }, (_, i) => from + i);
3720
+ var pageWindow = (currentPage, totalPages) => {
3721
+ if (totalPages <= noOfPagesShown) {
3722
+ return {
3723
+ pageNumbers: range(1, totalPages),
3724
+ showLeftDots: false,
3725
+ showRightDots: false
3726
+ };
3727
+ }
3728
+ if (currentPage <= noOfPagesShown - 3) {
3729
+ return {
3730
+ pageNumbers: [...range(1, noOfPagesShown - 2), totalPages],
3731
+ showLeftDots: false,
3732
+ showRightDots: true
3733
+ };
3734
+ }
3735
+ if (currentPage < totalPages - 3) {
3736
+ return {
3737
+ pageNumbers: [
3738
+ 1,
3739
+ ...range(
3740
+ Math.max(2, currentPage - noOfSiblings),
3741
+ Math.min(totalPages - 1, currentPage + noOfSiblings)
3742
+ ),
3743
+ totalPages
3744
+ ],
3745
+ showLeftDots: true,
3746
+ showRightDots: true
3747
+ };
3748
+ }
3749
+ return {
3750
+ pageNumbers: [1, ...range(totalPages - noOfPagesShown + 3, totalPages)],
3751
+ showLeftDots: true,
3752
+ showRightDots: false
3753
+ };
3754
+ };
3697
3755
  var Pagination = import_react7.default.forwardRef(
3698
3756
  (_a, ref) => {
3699
3757
  var _b = _a, {
@@ -3723,42 +3781,10 @@ var Pagination = import_react7.default.forwardRef(
3723
3781
  currentRowsLength > 0 ? currentRowsLength / numberOfItemsPerPage : 0
3724
3782
  );
3725
3783
  }, [currentRowsLength, numberOfItemsPerPage]);
3726
- const allPages = [...Array(totalPages + 1).keys()].slice(1);
3727
- const [pageNumbers, setPageNumbers] = (0, import_react7.useState)(allPages);
3728
- const [showLeftDots, setShowLeftDots] = (0, import_react7.useState)(false);
3729
- const [showRightDots, setShowRightDots] = (0, import_react7.useState)(false);
3730
- const noOfSiblings = 1;
3731
- const noOfPagesShown = noOfSiblings * 2 + 5;
3732
- (0, import_react7.useEffect)(() => {
3733
- if (totalPages <= noOfPagesShown) {
3734
- setPageNumbers(allPages);
3735
- setShowRightDots(false);
3736
- setShowLeftDots(false);
3737
- } else if (currentPage <= noOfPagesShown - 3) {
3738
- const pages = allPages.slice(0, noOfPagesShown - 2);
3739
- pages.push(totalPages);
3740
- setPageNumbers(pages);
3741
- setShowRightDots(true);
3742
- setShowLeftDots(false);
3743
- } else if (noOfPagesShown - 3 < currentPage && currentPage < totalPages - 3) {
3744
- const pages = [1];
3745
- const start = Math.max(2, currentPage - noOfSiblings);
3746
- const end = Math.min(totalPages - 1, currentPage + noOfSiblings);
3747
- for (let i = start; i <= end; i++) {
3748
- pages.push(i);
3749
- }
3750
- pages.push(totalPages);
3751
- setPageNumbers(pages);
3752
- setShowRightDots(true);
3753
- setShowLeftDots(true);
3754
- } else if (currentPage >= totalPages - 3) {
3755
- const pages = allPages.slice(-noOfPagesShown + 2);
3756
- pages.unshift(1);
3757
- setPageNumbers(pages);
3758
- setShowRightDots(false);
3759
- setShowLeftDots(true);
3760
- }
3761
- }, [currentPage, totalPages]);
3784
+ const { pageNumbers, showLeftDots, showRightDots } = import_react7.default.useMemo(
3785
+ () => pageWindow(currentPage, totalPages),
3786
+ [currentPage, totalPages]
3787
+ );
3762
3788
  const goToNextPage = () => {
3763
3789
  if (currentPage !== totalPages) setCurrentPage(currentPage + 1);
3764
3790
  };
@@ -3975,7 +4001,7 @@ var popoverVariants = (0, import_class_variance_authority23.cva)([
3975
4001
  "z-50",
3976
4002
  "border border-2 border-border-subtle dark:border-border-dark",
3977
4003
  "rounded-lg",
3978
- "bg-background dark:bg-background-dark",
4004
+ "bg-background-surface dark:bg-background-surface-dark",
3979
4005
  "text-foreground text-sm font-normal dark:text-white",
3980
4006
  "shadow",
3981
4007
  "outline-hidden",
@@ -4310,7 +4336,7 @@ var contentVariants = (0, import_class_variance_authority25.cva)([
4310
4336
  "relative",
4311
4337
  "z-50",
4312
4338
  "min-w-[8rem]",
4313
- "bg-background",
4339
+ "bg-background-surface",
4314
4340
  "rounded-lg",
4315
4341
  "border border-[2px]",
4316
4342
  "border-border-subtle",
@@ -4320,7 +4346,7 @@ var contentVariants = (0, import_class_variance_authority25.cva)([
4320
4346
  "data-[side=left]:slide-in-from-right-2",
4321
4347
  "data-[side=right]:slide-in-from-left-2",
4322
4348
  "data-[side=top]:slide-in-from-bottom-2",
4323
- "dark:bg-background-dark",
4349
+ "dark:bg-background-surface-dark",
4324
4350
  "dark:border-border-subtle-dark",
4325
4351
  "dark:text-foreground-dark"
4326
4352
  ]);
@@ -4440,7 +4466,7 @@ var SortAndShow = React31.forwardRef((_a, ref) => {
4440
4466
  ref,
4441
4467
  className: cn(
4442
4468
  "flex flex-wrap items-center gap-x-6 gap-y-2 px-4 py-3",
4443
- "rounded-lg bg-background dark:bg-background-dark",
4469
+ "rounded-lg bg-background-surface dark:bg-background-surface-dark",
4444
4470
  className
4445
4471
  )
4446
4472
  }, props)
@@ -4631,13 +4657,13 @@ var splitButtonMenuVariants = (0, import_class_variance_authority26.cva)([
4631
4657
  "rounded-lg",
4632
4658
  "border-2",
4633
4659
  "border-border-subtle",
4634
- "bg-background",
4660
+ "bg-background-surface",
4635
4661
  "text-sm",
4636
4662
  "text-foreground",
4637
4663
  "shadow",
4638
4664
  "outline-hidden",
4639
4665
  "dark:border-border-dark",
4640
- "dark:bg-background-dark",
4666
+ "dark:bg-background-surface-dark",
4641
4667
  "dark:text-foreground-dark"
4642
4668
  ]);
4643
4669
  var splitButtonItemVariants = (0, import_class_variance_authority26.cva)([
@@ -5141,7 +5167,7 @@ var Subnav = React36.forwardRef(
5141
5167
  "aria-labelledby": ariaLabelledBy != null ? ariaLabelledBy : ariaLabel ? void 0 : headingId,
5142
5168
  className: cn(
5143
5169
  "flex flex-col gap-4",
5144
- "bg-background dark:bg-background-dark",
5170
+ "bg-background-surface dark:bg-background-surface-dark",
5145
5171
  "text-foreground dark:text-foreground-dark",
5146
5172
  className
5147
5173
  )
@@ -5228,16 +5254,19 @@ SubnavLink.displayName = "SubnavLink";
5228
5254
  var React37 = __toESM(require("react"));
5229
5255
  var import_class_variance_authority30 = require("class-variance-authority");
5230
5256
  var import_jsx_runtime40 = require("react/jsx-runtime");
5231
- var tableBodyVariants = (0, import_class_variance_authority30.cva)("bg-background dark:bg-background-dark", {
5232
- variants: {
5233
- variant: {
5234
- zebra: [
5235
- "[:where(&>*:nth-child(even))]:bg-background-subtle",
5236
- "dark:[:where(&>*:nth-child(even))]:bg-background-subtle-dark"
5237
- ]
5257
+ var tableBodyVariants = (0, import_class_variance_authority30.cva)(
5258
+ "bg-background-surface dark:bg-background-surface-dark",
5259
+ {
5260
+ variants: {
5261
+ variant: {
5262
+ zebra: [
5263
+ "[:where(&>*:nth-child(even))]:bg-background-subtle",
5264
+ "dark:[:where(&>*:nth-child(even))]:bg-background-subtle-dark"
5265
+ ]
5266
+ }
5238
5267
  }
5239
5268
  }
5240
- });
5269
+ );
5241
5270
  var alignVariants2 = (0, import_class_variance_authority30.cva)("", {
5242
5271
  variants: {
5243
5272
  align: {