@bwp-web/components 0.11.5 → 0.11.7

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.js CHANGED
@@ -480,7 +480,7 @@ import {
480
480
  DropdownChevronUpIcon
481
481
  } from "@bwp-web/assets";
482
482
  import { flexRender } from "@tanstack/react-table";
483
- import { useCallback, useEffect as useEffect2, useRef as useRef2 } from "react";
483
+ import { useRef as useRef2 } from "react";
484
484
 
485
485
  // src/BiampTable/BiampTableEmptyState.tsx
486
486
  import { NoResultsIcon } from "@bwp-web/assets";
@@ -590,22 +590,6 @@ function BiampTable({
590
590
  enableRowSelection ? 48 : 0
591
591
  );
592
592
  const containerRef = useRef2(null);
593
- const lastScrollLeftRef = useRef2(null);
594
- const onContainerScroll = useCallback((target) => {
595
- const { scrollLeft, scrollWidth, clientWidth } = target;
596
- if (!containerRef.current || lastScrollLeftRef.current === scrollLeft)
597
- return;
598
- containerRef.current.dataset["rightShadow"] = scrollWidth - clientWidth > scrollLeft ? "true" : "false";
599
- lastScrollLeftRef.current = scrollLeft;
600
- }, []);
601
- useEffect2(() => {
602
- if (!containerRef.current) return;
603
- const observer = new ResizeObserver(
604
- ([{ target }]) => onContainerScroll(target)
605
- );
606
- observer.observe(containerRef.current);
607
- return () => observer.disconnect();
608
- }, [onContainerScroll]);
609
593
  const showLoading = useLoadingDelay(!!loading);
610
594
  const rows = table.getRowModel().rows;
611
595
  const showError = !!error && !loading;
@@ -616,7 +600,6 @@ function BiampTable({
616
600
  component: Box3,
617
601
  ...boxProps,
618
602
  ref: containerRef,
619
- onScroll: (e) => onContainerScroll(e.currentTarget),
620
603
  sx: {
621
604
  display: "flex",
622
605
  flexDirection: "column",
@@ -624,12 +607,6 @@ function BiampTable({
624
607
  overflow: "auto",
625
608
  overscrollBehavior: "none",
626
609
  position: "relative",
627
- '& [data-sticky="right"]': {
628
- transition: "box-shadow .2s"
629
- },
630
- '&[data-right-shadow="true"] [data-sticky="right"]': {
631
- boxShadow: ({ palette }) => `-16px 0px 12px -2px ${palette.background.default}`
632
- },
633
610
  ...sx
634
611
  },
635
612
  children: [
@@ -656,6 +633,7 @@ function BiampTable({
656
633
  checked: table.getIsAllPageRowsSelected(),
657
634
  indeterminate: table.getIsSomePageRowsSelected(),
658
635
  onChange: table.getToggleAllPageRowsSelectedHandler(),
636
+ sx: rows.length === 0 ? { visibility: "hidden" } : void 0,
659
637
  slotProps: { input: { "aria-label": "Select all rows" } }
660
638
  }
661
639
  )
@@ -672,11 +650,14 @@ function BiampTable({
672
650
  "aria-sort": header.column.getIsSorted() ? header.column.getIsSorted() === "asc" ? "ascending" : "descending" : "none"
673
651
  },
674
652
  sx: {
675
- minWidth: header.column.columnDef.meta?.minWidth ?? 40,
653
+ minWidth: sticky ? void 0 : header.column.columnDef.meta?.minWidth ?? 40,
676
654
  ...sticky && {
677
655
  position: "sticky",
678
656
  [sticky]: 0,
679
657
  zIndex: 3,
658
+ width: 0,
659
+ whiteSpace: "nowrap",
660
+ textAlign: "center",
680
661
  bgcolor: "background.paper"
681
662
  }
682
663
  },
@@ -741,6 +722,7 @@ function BiampTable({
741
722
  disabled: !row.getCanSelect(),
742
723
  onChange: row.getToggleSelectedHandler(),
743
724
  onClick: (e) => e.stopPropagation(),
725
+ sx: !row.getCanSelect() ? { visibility: "hidden" } : void 0,
744
726
  slotProps: {
745
727
  input: {
746
728
  "aria-label": getRowLabel ? `Select ${getRowLabel(row.original)}` : `Select row ${row.index + 1}`
@@ -757,11 +739,14 @@ function BiampTable({
757
739
  {
758
740
  "data-sticky": sticky || void 0,
759
741
  sx: {
760
- minWidth: cell.column.columnDef.meta?.minWidth ?? 40,
742
+ minWidth: sticky ? void 0 : cell.column.columnDef.meta?.minWidth ?? 40,
761
743
  ...sticky && {
762
744
  position: "sticky",
763
745
  [sticky]: 0,
764
746
  zIndex: 2,
747
+ width: 0,
748
+ whiteSpace: "nowrap",
749
+ textAlign: "center",
765
750
  bgcolor: "background.paper",
766
751
  ".MuiTableRow-hover:hover > &, .Mui-selected > &": {
767
752
  bgcolor: ({ palette }) => palette.mode === "dark" ? palette.grey[800] : palette.grey[100]
@@ -1110,8 +1095,7 @@ function BiampTablePagination({
1110
1095
  if (!loading && pageIndex > maxPage) {
1111
1096
  table.setPageIndex(maxPage);
1112
1097
  }
1113
- if (autoHide && !loading && (!stableCount || stableCount <= pageSize))
1114
- return null;
1098
+ if (autoHide && (!stableCount || stableCount <= pageSize)) return null;
1115
1099
  return /* @__PURE__ */ jsx13(
1116
1100
  TablePagination,
1117
1101
  {
@@ -1176,7 +1160,18 @@ function BiampTableToolbarActions({
1176
1160
  children,
1177
1161
  ...props
1178
1162
  }) {
1179
- return /* @__PURE__ */ jsx15(Box6, { display: "flex", alignItems: "center", gap: 1, ml: "auto", ...props, children });
1163
+ return /* @__PURE__ */ jsx15(
1164
+ Box6,
1165
+ {
1166
+ display: "flex",
1167
+ alignItems: "center",
1168
+ ml: "auto",
1169
+ gap: { xs: 0, md: 1 },
1170
+ mr: { xs: 1, md: 0 },
1171
+ ...props,
1172
+ children
1173
+ }
1174
+ );
1180
1175
  }
1181
1176
 
1182
1177
  // src/BiampTable/BiampTableToolbarExport.tsx
@@ -1349,24 +1344,26 @@ import {
1349
1344
  Collapse,
1350
1345
  IconButton as IconButton4,
1351
1346
  InputAdornment as InputAdornment2,
1352
- TextField as TextField2
1347
+ InputBase,
1348
+ TextField as TextField2,
1349
+ useMediaQuery
1353
1350
  } from "@mui/material";
1354
1351
  import { CloseIcon as CloseIcon2, SearchIcon as SearchIcon2 } from "@bwp-web/assets";
1355
- import { useEffect as useEffect4, useState as useState4 } from "react";
1352
+ import { useEffect as useEffect3, useState as useState4 } from "react";
1356
1353
 
1357
1354
  // src/BiampTable/useDebouncedCallback.ts
1358
- import { useCallback as useCallback2, useEffect as useEffect3, useRef as useRef4 } from "react";
1355
+ import { useCallback, useEffect as useEffect2, useRef as useRef4 } from "react";
1359
1356
  var BIAMP_TABLE_DEBOUNCE_DELAY = 300;
1360
1357
  function useDebouncedCallback(callback, delay = BIAMP_TABLE_DEBOUNCE_DELAY) {
1361
1358
  const timeoutRef = useRef4(null);
1362
1359
  const callbackRef = useRef4(callback);
1363
1360
  callbackRef.current = callback;
1364
- useEffect3(() => {
1361
+ useEffect2(() => {
1365
1362
  return () => {
1366
1363
  if (timeoutRef.current !== null) clearTimeout(timeoutRef.current);
1367
1364
  };
1368
1365
  }, []);
1369
- return useCallback2(
1366
+ return useCallback(
1370
1367
  (...args) => {
1371
1368
  if (timeoutRef.current !== null) clearTimeout(timeoutRef.current);
1372
1369
  timeoutRef.current = setTimeout(
@@ -1399,13 +1396,15 @@ function BiampTableToolbarSearch({
1399
1396
  clearLabel = "Clear search",
1400
1397
  expandable = false,
1401
1398
  expandLabel,
1399
+ enableMobileView = true,
1402
1400
  sx,
1403
1401
  ...textFieldProps
1404
1402
  }) {
1403
+ const isMobile = useMediaQuery((t) => t.breakpoints.down("md"));
1405
1404
  const [inputValue, setInputValue] = useState4(defaultValue);
1406
1405
  const [isExpanded, setIsExpanded] = useState4(false);
1407
1406
  const debouncedOnChange = useDebouncedCallback(onChange, debounceDelay);
1408
- useEffect4(() => {
1407
+ useEffect3(() => {
1409
1408
  setInputValue(defaultValue);
1410
1409
  }, [defaultValue]);
1411
1410
  const handleChange = (e) => {
@@ -1465,6 +1464,30 @@ function BiampTableToolbarSearch({
1465
1464
  ...textFieldProps
1466
1465
  }
1467
1466
  );
1467
+ if (isMobile && enableMobileView) {
1468
+ return /* @__PURE__ */ jsxs9(Box8, { display: "flex", alignItems: "center", width: "100%", pr: 1, gap: 1, children: [
1469
+ /* @__PURE__ */ jsx18(SearchIcon2, { sx: { width: 16, height: 16 } }),
1470
+ /* @__PURE__ */ jsx18(
1471
+ InputBase,
1472
+ {
1473
+ name: "search",
1474
+ type: "text",
1475
+ placeholder,
1476
+ inputProps: { maxLength, "aria-label": "Search" },
1477
+ fullWidth: true,
1478
+ value: inputValue,
1479
+ sx: {
1480
+ paddingLeft: 1,
1481
+ height: "36px !important",
1482
+ minHeight: "36px !important",
1483
+ fontSize: (t) => t.typography.body2.fontSize
1484
+ },
1485
+ onChange: handleChange,
1486
+ endAdornment: clearButton
1487
+ }
1488
+ )
1489
+ ] });
1490
+ }
1468
1491
  if (expandable) {
1469
1492
  return /* @__PURE__ */ jsxs9(Box8, { display: "flex", alignItems: "center", minWidth: 28, children: [
1470
1493
  /* @__PURE__ */ jsx18(