smartsell-ui-kit 0.1.6 → 0.1.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.d.cts CHANGED
@@ -320,6 +320,11 @@ interface SharedTableProps<TItem> {
320
320
  actions?: TableActionSource<TItem>;
321
321
  stickyActionsColumn?: boolean;
322
322
  maxInlineActions?: number;
323
+ /**
324
+ * Viewport width (in px) below which the table switches from the desktop
325
+ * table layout to the stacked mobile card layout. Defaults to 768 so the
326
+ * table collapses in sync with the host app's mobile breakpoint.
327
+ */
323
328
  collapseBelow?: number;
324
329
  searchable?: boolean;
325
330
  showSearch?: boolean;
package/dist/index.d.ts CHANGED
@@ -320,6 +320,11 @@ interface SharedTableProps<TItem> {
320
320
  actions?: TableActionSource<TItem>;
321
321
  stickyActionsColumn?: boolean;
322
322
  maxInlineActions?: number;
323
+ /**
324
+ * Viewport width (in px) below which the table switches from the desktop
325
+ * table layout to the stacked mobile card layout. Defaults to 768 so the
326
+ * table collapses in sync with the host app's mobile breakpoint.
327
+ */
323
328
  collapseBelow?: number;
324
329
  searchable?: boolean;
325
330
  showSearch?: boolean;
package/dist/index.js CHANGED
@@ -3804,7 +3804,7 @@ import { useEffect as useEffect8, useId as useId4, useRef as useRef6, useState a
3804
3804
 
3805
3805
  // src/componentsBase/table/utils.ts
3806
3806
  import { isValidElement as isValidElement3 } from "react";
3807
- var DEFAULT_COLLAPSE_BELOW = 420;
3807
+ var DEFAULT_COLLAPSE_BELOW = 768;
3808
3808
  var DEFAULT_MAX_INLINE_ACTIONS = 2;
3809
3809
  var DEFAULT_PAGE_SIZE = 10;
3810
3810
  var DEFAULT_PAGE_SIZE_OPTIONS = [10, 20, 50];
@@ -4327,7 +4327,7 @@ function TableBase({
4327
4327
  const alternateSurfaceColor = theme.colors.background;
4328
4328
  const scrollRegionId = useId4().replace(/:/g, "");
4329
4329
  const containerRef = useRef6(null);
4330
- const [containerWidth, setContainerWidth] = useState7(null);
4330
+ const [viewportWidth, setViewportWidth] = useState7(null);
4331
4331
  const [isSettingsModalOpen, setIsSettingsModalOpen] = useState7(false);
4332
4332
  const resolvedLabels = mergeTableLabels({
4333
4333
  ...labels != null ? labels : {},
@@ -4335,8 +4335,8 @@ function TableBase({
4335
4335
  });
4336
4336
  const normalizedPage = clampPage(page, totalPages);
4337
4337
  const normalizedPageSizeOptions = sanitizePageSizeOptions(pageSizeOptions, pageSize);
4338
- const isCollapsed = containerWidth !== null ? containerWidth < collapseBelow : false;
4339
- const mobileGridColumnCount = containerWidth !== null && containerWidth < 520 ? 1 : 2;
4338
+ const isCollapsed = viewportWidth !== null ? viewportWidth < collapseBelow : false;
4339
+ const mobileGridColumnCount = viewportWidth !== null && viewportWidth < 520 ? 1 : 2;
4340
4340
  const canGoToPreviousPage = normalizedPage > 1;
4341
4341
  const canGoToNextPage = normalizedPage < Math.max(1, totalPages);
4342
4342
  const canGoToFirstPage = canGoToPreviousPage;
@@ -4371,31 +4371,16 @@ function TableBase({
4371
4371
  borderLeft: `1px solid ${softBorderColor}`
4372
4372
  });
4373
4373
  useEffect8(() => {
4374
- const element = containerRef.current;
4375
- if (!element) {
4374
+ if (typeof window === "undefined") {
4376
4375
  return;
4377
4376
  }
4378
- const setWidthFromElement = (nextWidth) => {
4379
- const measuredWidth = nextWidth != null ? nextWidth : element.getBoundingClientRect().width;
4380
- setContainerWidth(measuredWidth > 0 ? measuredWidth : null);
4377
+ const updateViewportWidth = () => {
4378
+ setViewportWidth(window.innerWidth);
4381
4379
  };
4382
- setWidthFromElement();
4383
- if (typeof ResizeObserver === "undefined") {
4384
- const handleResize = () => {
4385
- setWidthFromElement(window.innerWidth);
4386
- };
4387
- window.addEventListener("resize", handleResize);
4388
- return () => {
4389
- window.removeEventListener("resize", handleResize);
4390
- };
4391
- }
4392
- const observer = new ResizeObserver((entries) => {
4393
- const [entry] = entries;
4394
- setWidthFromElement(entry == null ? void 0 : entry.contentRect.width);
4395
- });
4396
- observer.observe(element);
4380
+ updateViewportWidth();
4381
+ window.addEventListener("resize", updateViewportWidth);
4397
4382
  return () => {
4398
- observer.disconnect();
4383
+ window.removeEventListener("resize", updateViewportWidth);
4399
4384
  };
4400
4385
  }, []);
4401
4386
  const actionButtonBaseStyle = (tone, disabled, iconOnly) => ({
@@ -4652,7 +4637,7 @@ function TableBase({
4652
4637
  !hasRows && (!loading || error) ? renderEmptyState() : null,
4653
4638
  hasRows ? isCollapsed ? /* @__PURE__ */ jsx13("div", { role: "list", "aria-label": ariaLabel, className: "flex flex-col gap-3.5", children: items.map((item, rowIndex) => {
4654
4639
  const rowActions = renderActions(item, rowIndex);
4655
- const rowBackgroundColor = rowIndex % 2 === 0 ? theme.colors.surface : alternateSurfaceColor;
4640
+ const rowBackgroundColor = theme.colors.surface;
4656
4641
  return /* @__PURE__ */ jsxs11(
4657
4642
  "article",
4658
4643
  {
@@ -4824,7 +4809,7 @@ function TableBase({
4824
4809
  width: column.width,
4825
4810
  minWidth: column.minWidth
4826
4811
  },
4827
- children: column.label
4812
+ children: !column.hideLabel ? column.label : null
4828
4813
  },
4829
4814
  getColumnKey(column, columnIndex)
4830
4815
  );