@upbound/monarch-blocks 0.7.3 → 0.8.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.
@@ -2455,6 +2455,21 @@ function getColumnFilterCount(filterValue, filter) {
2455
2455
  return 0;
2456
2456
  }
2457
2457
 
2458
+ // src/lib/search-input.ts
2459
+ var SEARCH_INPUT_PROPS = {
2460
+ type: "search",
2461
+ autoComplete: "off",
2462
+ "data-1p-ignore": true,
2463
+ // 1Password
2464
+ "data-lpignore": "true",
2465
+ // LastPass
2466
+ "data-bwignore": true,
2467
+ // Bitwarden
2468
+ "data-form-type": "other"
2469
+ // Dashlane
2470
+ };
2471
+ var SEARCH_INPUT_CLASS = "[&::-webkit-search-cancel-button]:appearance-none";
2472
+
2458
2473
  // src/hooks/use-table-column-resizing.ts
2459
2474
  import { useCallback as useCallback4, useEffect as useEffect3, useRef as useRef3, useState as useState5 } from "react";
2460
2475
  var RESIZE_MIN = 40;
@@ -2995,8 +3010,7 @@ function DataTableEmptyView({
2995
3010
  emptyView,
2996
3011
  tableState,
2997
3012
  filterCount,
2998
- resetFilters,
2999
- className
3013
+ resetFilters
3000
3014
  }) {
3001
3015
  var _a, _b, _c, _d, _e, _f, _g;
3002
3016
  const isFilteredEmpty = tableState === "empty" && filterCount > 0;
@@ -3006,9 +3020,7 @@ function DataTableEmptyView({
3006
3020
  /* @__PURE__ */ jsx6(Icon4, { name: "xmark" }),
3007
3021
  "Clear filters"
3008
3022
  ] }) : null;
3009
- return /* @__PURE__ */ jsx6("div", { className: cn("flex size-full flex-col justify-center p-6", wrapperClassName, className), children: config && // The error state ignores its own config's `className` for outer
3010
- // padding, matching the source's forced `pt-0` on that branch.
3011
- /* @__PURE__ */ jsxs5(Empty, { className: tableState === "error" ? "pt-0" : config.className, children: [
3023
+ return /* @__PURE__ */ jsx6("div", { className: cn("flex size-full flex-col justify-center", wrapperClassName), children: config && /* @__PURE__ */ jsxs5(Empty, { className: cn("border border-dashed", config.className), children: [
3012
3024
  /* @__PURE__ */ jsxs5(EmptyHeader, { children: [
3013
3025
  config.icon && /* @__PURE__ */ jsx6(EmptyMedia, { children: /* @__PURE__ */ jsx6(IconTile, { variant: "branded", children: /* @__PURE__ */ jsx6(Icon4, { name: config.icon }) }) }),
3014
3026
  config.header && /* @__PURE__ */ jsx6(EmptyTitle, { children: config.header }),
@@ -3219,7 +3231,7 @@ import { Fragment as Fragment5, jsx as jsx9, jsxs as jsxs8 } from "react/jsx-run
3219
3231
  var HEADER_SURFACE_BG = "bg-[color-mix(in_oklch,var(--muted)_50%,var(--card))]";
3220
3232
  var TABLE_HEAD_CLASSES = "text-body-sm text-muted-foreground h-10 px-4 text-left align-middle font-medium whitespace-nowrap has-[[role=checkbox]]:pr-0";
3221
3233
  var TABLE_CELL_CLASSES = "px-4 py-2 align-middle whitespace-nowrap has-[[role=checkbox]]:pr-0";
3222
- var TABLE_ROW_CLASSES = "hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted border-b motion-safe:transition-colors";
3234
+ var TABLE_ROW_CLASSES = "hover:bg-muted/50 has-[[aria-haspopup][aria-expanded=true]]:bg-muted/50 data-[state=selected]:bg-muted border-b motion-safe:transition-colors";
3223
3235
  function DataTableRoot({
3224
3236
  layout = "auto",
3225
3237
  gridTemplateColumns,
@@ -3683,18 +3695,19 @@ function DataTableBody({
3683
3695
  );
3684
3696
  }
3685
3697
  const rows = tableRows.map((row) => {
3686
- var _a, _b, _c, _d;
3698
+ var _a, _b, _c, _d, _e;
3687
3699
  if ((_a = row.getIsGrouped) == null ? void 0 : _a.call(row)) {
3688
3700
  const groupLabel = (_c = row.groupingValue) != null ? _c : row.groupingColumnId ? (_b = row.getGroupingValue) == null ? void 0 : _b.call(row, row.groupingColumnId) : void 0;
3689
3701
  return /* @__PURE__ */ jsx9(DataTableGroupRow, { groupLabel: String(groupLabel != null ? groupLabel : ""), colSpan, layout }, row.id);
3690
3702
  }
3691
- const isExpanded = !!(renderExpandedRow && ((_d = row.getIsExpanded) == null ? void 0 : _d.call(row)));
3692
- const expandedRow = renderExpandedRow ? renderExpandedRow(row.original) : null;
3703
+ const isExpanded = !!(((_d = row.getCanExpand) == null ? void 0 : _d.call(row)) && ((_e = row.getIsExpanded) == null ? void 0 : _e.call(row)));
3704
+ const expandedRow = renderExpandedRow && isExpanded ? renderExpandedRow(row.original) : null;
3693
3705
  return /* @__PURE__ */ jsxs8(React6.Fragment, { children: [
3694
3706
  /* @__PURE__ */ jsx9(
3695
3707
  DataTableRow,
3696
- __spreadProps(__spreadValues({}, onRowRender ? onRowRender(row.original) : {}), {
3708
+ __spreadProps(__spreadValues({}, onRowRender ? onRowRender(row.original, row) : {}), {
3697
3709
  "data-expanded": isExpanded || void 0,
3710
+ "data-depth": row.depth || void 0,
3698
3711
  layout,
3699
3712
  children: row.getVisibleCells().filter((cell) => !isFilterOnlyColumn(cell.column)).map((cell) => /* @__PURE__ */ jsx9(
3700
3713
  DataTableCell,
@@ -3710,7 +3723,7 @@ function DataTableBody({
3710
3723
  ))
3711
3724
  })
3712
3725
  ),
3713
- /* @__PURE__ */ jsx9(DataTableExpandedRow, { colSpan, show: isExpanded, layout, children: expandedRow })
3726
+ /* @__PURE__ */ jsx9(DataTableExpandedRow, { colSpan, show: expandedRow != null, layout, children: expandedRow })
3714
3727
  ] }, row.id);
3715
3728
  });
3716
3729
  if (isGrid) {
@@ -4423,7 +4436,8 @@ function DataTable({
4423
4436
  renderExpandedRow,
4424
4437
  expanded: parentExpanded,
4425
4438
  onExpandedChange: parentOnExpandedChange,
4426
- disableSearch = false,
4439
+ disableSearch: deprecatedDisableSearch = false,
4440
+ search,
4427
4441
  disableFilters = false,
4428
4442
  disableSorting = false,
4429
4443
  paginationConfig = true,
@@ -4458,8 +4472,9 @@ function DataTable({
4458
4472
  celFilterConfig,
4459
4473
  filterVisibility
4460
4474
  }) {
4461
- var _a, _b, _c, _d, _e, _f;
4475
+ var _a, _b, _c, _d, _e, _f, _g, _h;
4462
4476
  const isGrid = layout === "grid";
4477
+ const searchInputId = `table-search-${React9.useId()}`;
4463
4478
  const tableBodyScrollRef = React9.useRef(null);
4464
4479
  const [innerGlobalFilter, setInnerGlobalFilter] = React9.useState("");
4465
4480
  const [innerColumnOrdering, setInnerColumnOrdering] = React9.useState([]);
@@ -4532,23 +4547,24 @@ function DataTable({
4532
4547
  const grouping = parentGrouping != null ? parentGrouping : innerGrouping;
4533
4548
  const setGrouping = parentSetGrouping != null ? parentSetGrouping : setInnerGrouping;
4534
4549
  const hasGrouping = grouping.length > 0;
4550
+ const hasSubRows = !!config.getSubRows;
4551
+ const hasExpansion = !!renderExpandedRow || hasSubRows;
4552
+ const disableSearch = (_f = search == null ? void 0 : search.disabled) != null ? _f : deprecatedDisableSearch;
4535
4553
  const hasExternalSearch = parentGlobalFilter !== void 0;
4536
4554
  const hasExternalFilters = parentColumnFilters !== void 0;
4537
4555
  const shouldDisableFiltersModels = !!disableFilters && !!disableSearch && !hasExternalSearch && !hasExternalFilters;
4538
- const table = useReactTable(__spreadProps(__spreadValues(__spreadProps(__spreadValues(__spreadProps(__spreadValues({}, config), {
4556
+ const table = useReactTable(__spreadProps(__spreadValues(__spreadProps(__spreadValues(__spreadValues(__spreadProps(__spreadValues({}, config), {
4539
4557
  getCoreRowModel: getCoreRowModel(),
4540
4558
  getSortedRowModel: !disableSorting ? getSortedRowModel() : void 0,
4541
4559
  getPaginationRowModel: !shouldDisablePagination ? getPaginationRowModel() : void 0,
4542
4560
  getFilteredRowModel: !shouldDisableFiltersModels ? getFilteredRowModel() : void 0,
4543
4561
  getFacetedRowModel: !shouldDisableFiltersModels ? getFacetedRowModel() : void 0,
4544
4562
  getFacetedUniqueValues: !shouldDisableFiltersModels ? getFacetedUniqueValues() : void 0
4545
- }), !!renderExpandedRow && {
4546
- getExpandedRowModel: getExpandedRowModel(),
4547
- getRowCanExpand: () => true,
4548
- paginateExpandedRows: false
4549
- }), {
4563
+ }), !!renderExpandedRow && { getRowCanExpand: () => true }), hasExpansion && { paginateExpandedRows: false }), {
4550
4564
  getGroupedRowModel: hasGrouping ? getGroupedRowModel() : void 0,
4551
- getExpandedRowModel: hasGrouping ? getExpandedRowModel() : void 0,
4565
+ // Only grouping and `getSubRows` put extra rows in the row model; `renderExpandedRow`
4566
+ // content renders outside it (see `DataTableBody`).
4567
+ getExpandedRowModel: hasGrouping || hasSubRows ? getExpandedRowModel() : void 0,
4552
4568
  groupedColumnMode: hasGrouping ? "reorder" : void 0,
4553
4569
  enableFilters: !shouldDisableFiltersModels,
4554
4570
  enableGlobalFilter: !shouldDisableFiltersModels,
@@ -4571,7 +4587,7 @@ function DataTable({
4571
4587
  columnVisibility: disableColumnVisibility ? {} : columnVisibility,
4572
4588
  columnSizing: disableColumnResizing ? {} : columnSizing,
4573
4589
  columnPinning: disableColumnPinning ? { left: [], right: [] } : columnPinning
4574
- }, !!renderExpandedRow && { expanded }), {
4590
+ }, hasExpansion && { expanded }), {
4575
4591
  grouping
4576
4592
  }), hasGrouping && { expanded: true }),
4577
4593
  manualSorting: serverSidePagination,
@@ -4585,7 +4601,7 @@ function DataTable({
4585
4601
  onColumnVisibilityChange: disableColumnVisibility ? noop : setColumnVisibility,
4586
4602
  onColumnSizingChange: disableColumnResizing ? noop : handleColumnSizingChange,
4587
4603
  onColumnPinningChange: disableColumnPinning ? noop : setColumnPinning
4588
- }), !!renderExpandedRow && {
4604
+ }), hasExpansion && {
4589
4605
  onExpandedChange: (updater) => setExpanded((prev) => typeof updater === "function" ? updater(prev) : updater)
4590
4606
  }), {
4591
4607
  onGroupingChange: setGrouping
@@ -4674,17 +4690,19 @@ function DataTable({
4674
4690
  }, [columnOrdering, disableColumnReordering, flatColumns, setColumnOrdering]);
4675
4691
  const showViewHeader = !!title || !!Actions;
4676
4692
  const showColumnOptions = !disableColumnReordering || !disableColumnVisibility;
4677
- const toolbarSearch = !disableSearch && /* @__PURE__ */ jsxs10(InputGroup2, { className: "w-70", children: [
4693
+ const toolbarSearch = !disableSearch && /* @__PURE__ */ jsxs10(InputGroup2, { className: cn("w-70", search == null ? void 0 : search.className), children: [
4678
4694
  /* @__PURE__ */ jsx13(InputGroupAddon2, { align: "inline-start", children: /* @__PURE__ */ jsx13(Icon9, { name: "magnifying-glass" }) }),
4679
4695
  /* @__PURE__ */ jsx13(
4680
4696
  InputGroupInput2,
4681
- {
4697
+ __spreadProps(__spreadValues({}, SEARCH_INPUT_PROPS), {
4698
+ id: searchInputId,
4699
+ className: SEARCH_INPUT_CLASS,
4682
4700
  "aria-label": "Search",
4683
- placeholder: "Search\u2026",
4701
+ placeholder: (_g = search == null ? void 0 : search.placeholder) != null ? _g : "Search\u2026",
4684
4702
  disabled: shouldDisable,
4685
4703
  value: globalFilter,
4686
4704
  onChange: (e) => setGlobalFilter(e.target.value)
4687
- }
4705
+ })
4688
4706
  )
4689
4707
  ] });
4690
4708
  const toolbarColumns = !!showColumnOptions && /* @__PURE__ */ jsx13(
@@ -4793,7 +4811,7 @@ function DataTable({
4793
4811
  DataTablePagination,
4794
4812
  {
4795
4813
  rowCount,
4796
- rowCountRelation: (_f = config.rowCountRelation) != null ? _f : "eq",
4814
+ rowCountRelation: (_h = config.rowCountRelation) != null ? _h : "eq",
4797
4815
  paginationConfig,
4798
4816
  pageSize: pagination.pageSize,
4799
4817
  pageIndex: pagination.pageIndex,