@upbound/monarch-blocks 0.8.0 → 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;
@@ -3216,7 +3231,7 @@ import { Fragment as Fragment5, jsx as jsx9, jsxs as jsxs8 } from "react/jsx-run
3216
3231
  var HEADER_SURFACE_BG = "bg-[color-mix(in_oklch,var(--muted)_50%,var(--card))]";
3217
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";
3218
3233
  var TABLE_CELL_CLASSES = "px-4 py-2 align-middle whitespace-nowrap has-[[role=checkbox]]:pr-0";
3219
- 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";
3220
3235
  function DataTableRoot({
3221
3236
  layout = "auto",
3222
3237
  gridTemplateColumns,
@@ -3680,18 +3695,19 @@ function DataTableBody({
3680
3695
  );
3681
3696
  }
3682
3697
  const rows = tableRows.map((row) => {
3683
- var _a, _b, _c, _d;
3698
+ var _a, _b, _c, _d, _e;
3684
3699
  if ((_a = row.getIsGrouped) == null ? void 0 : _a.call(row)) {
3685
3700
  const groupLabel = (_c = row.groupingValue) != null ? _c : row.groupingColumnId ? (_b = row.getGroupingValue) == null ? void 0 : _b.call(row, row.groupingColumnId) : void 0;
3686
3701
  return /* @__PURE__ */ jsx9(DataTableGroupRow, { groupLabel: String(groupLabel != null ? groupLabel : ""), colSpan, layout }, row.id);
3687
3702
  }
3688
- const isExpanded = !!(renderExpandedRow && ((_d = row.getIsExpanded) == null ? void 0 : _d.call(row)));
3689
- 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;
3690
3705
  return /* @__PURE__ */ jsxs8(React6.Fragment, { children: [
3691
3706
  /* @__PURE__ */ jsx9(
3692
3707
  DataTableRow,
3693
- __spreadProps(__spreadValues({}, onRowRender ? onRowRender(row.original) : {}), {
3708
+ __spreadProps(__spreadValues({}, onRowRender ? onRowRender(row.original, row) : {}), {
3694
3709
  "data-expanded": isExpanded || void 0,
3710
+ "data-depth": row.depth || void 0,
3695
3711
  layout,
3696
3712
  children: row.getVisibleCells().filter((cell) => !isFilterOnlyColumn(cell.column)).map((cell) => /* @__PURE__ */ jsx9(
3697
3713
  DataTableCell,
@@ -3707,7 +3723,7 @@ function DataTableBody({
3707
3723
  ))
3708
3724
  })
3709
3725
  ),
3710
- /* @__PURE__ */ jsx9(DataTableExpandedRow, { colSpan, show: isExpanded, layout, children: expandedRow })
3726
+ /* @__PURE__ */ jsx9(DataTableExpandedRow, { colSpan, show: expandedRow != null, layout, children: expandedRow })
3711
3727
  ] }, row.id);
3712
3728
  });
3713
3729
  if (isGrid) {
@@ -4420,7 +4436,8 @@ function DataTable({
4420
4436
  renderExpandedRow,
4421
4437
  expanded: parentExpanded,
4422
4438
  onExpandedChange: parentOnExpandedChange,
4423
- disableSearch = false,
4439
+ disableSearch: deprecatedDisableSearch = false,
4440
+ search,
4424
4441
  disableFilters = false,
4425
4442
  disableSorting = false,
4426
4443
  paginationConfig = true,
@@ -4455,8 +4472,9 @@ function DataTable({
4455
4472
  celFilterConfig,
4456
4473
  filterVisibility
4457
4474
  }) {
4458
- var _a, _b, _c, _d, _e, _f;
4475
+ var _a, _b, _c, _d, _e, _f, _g, _h;
4459
4476
  const isGrid = layout === "grid";
4477
+ const searchInputId = `table-search-${React9.useId()}`;
4460
4478
  const tableBodyScrollRef = React9.useRef(null);
4461
4479
  const [innerGlobalFilter, setInnerGlobalFilter] = React9.useState("");
4462
4480
  const [innerColumnOrdering, setInnerColumnOrdering] = React9.useState([]);
@@ -4529,23 +4547,24 @@ function DataTable({
4529
4547
  const grouping = parentGrouping != null ? parentGrouping : innerGrouping;
4530
4548
  const setGrouping = parentSetGrouping != null ? parentSetGrouping : setInnerGrouping;
4531
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;
4532
4553
  const hasExternalSearch = parentGlobalFilter !== void 0;
4533
4554
  const hasExternalFilters = parentColumnFilters !== void 0;
4534
4555
  const shouldDisableFiltersModels = !!disableFilters && !!disableSearch && !hasExternalSearch && !hasExternalFilters;
4535
- const table = useReactTable(__spreadProps(__spreadValues(__spreadProps(__spreadValues(__spreadProps(__spreadValues({}, config), {
4556
+ const table = useReactTable(__spreadProps(__spreadValues(__spreadProps(__spreadValues(__spreadValues(__spreadProps(__spreadValues({}, config), {
4536
4557
  getCoreRowModel: getCoreRowModel(),
4537
4558
  getSortedRowModel: !disableSorting ? getSortedRowModel() : void 0,
4538
4559
  getPaginationRowModel: !shouldDisablePagination ? getPaginationRowModel() : void 0,
4539
4560
  getFilteredRowModel: !shouldDisableFiltersModels ? getFilteredRowModel() : void 0,
4540
4561
  getFacetedRowModel: !shouldDisableFiltersModels ? getFacetedRowModel() : void 0,
4541
4562
  getFacetedUniqueValues: !shouldDisableFiltersModels ? getFacetedUniqueValues() : void 0
4542
- }), !!renderExpandedRow && {
4543
- getExpandedRowModel: getExpandedRowModel(),
4544
- getRowCanExpand: () => true,
4545
- paginateExpandedRows: false
4546
- }), {
4563
+ }), !!renderExpandedRow && { getRowCanExpand: () => true }), hasExpansion && { paginateExpandedRows: false }), {
4547
4564
  getGroupedRowModel: hasGrouping ? getGroupedRowModel() : void 0,
4548
- 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,
4549
4568
  groupedColumnMode: hasGrouping ? "reorder" : void 0,
4550
4569
  enableFilters: !shouldDisableFiltersModels,
4551
4570
  enableGlobalFilter: !shouldDisableFiltersModels,
@@ -4568,7 +4587,7 @@ function DataTable({
4568
4587
  columnVisibility: disableColumnVisibility ? {} : columnVisibility,
4569
4588
  columnSizing: disableColumnResizing ? {} : columnSizing,
4570
4589
  columnPinning: disableColumnPinning ? { left: [], right: [] } : columnPinning
4571
- }, !!renderExpandedRow && { expanded }), {
4590
+ }, hasExpansion && { expanded }), {
4572
4591
  grouping
4573
4592
  }), hasGrouping && { expanded: true }),
4574
4593
  manualSorting: serverSidePagination,
@@ -4582,7 +4601,7 @@ function DataTable({
4582
4601
  onColumnVisibilityChange: disableColumnVisibility ? noop : setColumnVisibility,
4583
4602
  onColumnSizingChange: disableColumnResizing ? noop : handleColumnSizingChange,
4584
4603
  onColumnPinningChange: disableColumnPinning ? noop : setColumnPinning
4585
- }), !!renderExpandedRow && {
4604
+ }), hasExpansion && {
4586
4605
  onExpandedChange: (updater) => setExpanded((prev) => typeof updater === "function" ? updater(prev) : updater)
4587
4606
  }), {
4588
4607
  onGroupingChange: setGrouping
@@ -4671,17 +4690,19 @@ function DataTable({
4671
4690
  }, [columnOrdering, disableColumnReordering, flatColumns, setColumnOrdering]);
4672
4691
  const showViewHeader = !!title || !!Actions;
4673
4692
  const showColumnOptions = !disableColumnReordering || !disableColumnVisibility;
4674
- 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: [
4675
4694
  /* @__PURE__ */ jsx13(InputGroupAddon2, { align: "inline-start", children: /* @__PURE__ */ jsx13(Icon9, { name: "magnifying-glass" }) }),
4676
4695
  /* @__PURE__ */ jsx13(
4677
4696
  InputGroupInput2,
4678
- {
4697
+ __spreadProps(__spreadValues({}, SEARCH_INPUT_PROPS), {
4698
+ id: searchInputId,
4699
+ className: SEARCH_INPUT_CLASS,
4679
4700
  "aria-label": "Search",
4680
- placeholder: "Search\u2026",
4701
+ placeholder: (_g = search == null ? void 0 : search.placeholder) != null ? _g : "Search\u2026",
4681
4702
  disabled: shouldDisable,
4682
4703
  value: globalFilter,
4683
4704
  onChange: (e) => setGlobalFilter(e.target.value)
4684
- }
4705
+ })
4685
4706
  )
4686
4707
  ] });
4687
4708
  const toolbarColumns = !!showColumnOptions && /* @__PURE__ */ jsx13(
@@ -4790,7 +4811,7 @@ function DataTable({
4790
4811
  DataTablePagination,
4791
4812
  {
4792
4813
  rowCount,
4793
- rowCountRelation: (_f = config.rowCountRelation) != null ? _f : "eq",
4814
+ rowCountRelation: (_h = config.rowCountRelation) != null ? _h : "eq",
4794
4815
  paginationConfig,
4795
4816
  pageSize: pagination.pageSize,
4796
4817
  pageIndex: pagination.pageIndex,