@rufous/ui 0.3.22 → 0.3.24

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/main.cjs CHANGED
@@ -4619,6 +4619,54 @@ var RufousLogoLoader = ({ size = 80, sx, className }) => {
4619
4619
  // lib/DataGrid/DataGrid.tsx
4620
4620
  var import_react23 = __toESM(require("react"), 1);
4621
4621
  var import_lucide_react2 = require("lucide-react");
4622
+ function getAllGroupIds(rows, fields, getKey, depth = 0, parentId = "") {
4623
+ if (!fields.length || !rows.length) return [];
4624
+ const [field, ...rest] = fields;
4625
+ const buckets = /* @__PURE__ */ new Map();
4626
+ rows.forEach((row) => {
4627
+ const k = getKey(row, field) || "(Blank)";
4628
+ if (!buckets.has(k)) buckets.set(k, []);
4629
+ buckets.get(k).push(row);
4630
+ });
4631
+ const out = [];
4632
+ buckets.forEach((children, k) => {
4633
+ const id = `${parentId}::${field}::${k}`;
4634
+ out.push({ id, field, key: k, depth, count: children.length });
4635
+ if (rest.length) out.push(...getAllGroupIds(children, rest, getKey, depth + 1, id));
4636
+ });
4637
+ return out;
4638
+ }
4639
+ function buildFlatEntries(rows, fields, getKey, expanded, depth = 0, parentId = "") {
4640
+ if (!fields.length) return rows.map((row) => ({ kind: "data", row, depth }));
4641
+ const [field, ...rest] = fields;
4642
+ const buckets = /* @__PURE__ */ new Map();
4643
+ rows.forEach((row) => {
4644
+ const k = getKey(row, field) || "(Blank)";
4645
+ if (!buckets.has(k)) buckets.set(k, []);
4646
+ buckets.get(k).push(row);
4647
+ });
4648
+ const out = [];
4649
+ buckets.forEach((children, k) => {
4650
+ const id = `${parentId}::${field}::${k}`;
4651
+ out.push({ kind: "group", id, field, key: k, depth, leafCount: children.length });
4652
+ if (expanded.has(id)) {
4653
+ out.push(...buildFlatEntries(children, rest, getKey, expanded, depth + 1, id));
4654
+ }
4655
+ });
4656
+ return out;
4657
+ }
4658
+ function buildTreeEntries(rows, getChildren, expanded, depth = 0) {
4659
+ const out = [];
4660
+ rows.forEach((row) => {
4661
+ const children = getChildren(row) ?? [];
4662
+ const hasChildren = children.length > 0;
4663
+ out.push({ kind: "data", row, depth, hasChildren });
4664
+ if (hasChildren && expanded.has(row.id)) {
4665
+ out.push(...buildTreeEntries(children, getChildren, expanded, depth + 1));
4666
+ }
4667
+ });
4668
+ return out;
4669
+ }
4622
4670
  function FilterSelect({
4623
4671
  value,
4624
4672
  onChange,
@@ -4716,7 +4764,21 @@ function DataGrid({
4716
4764
  searchableColumns,
4717
4765
  onSearchChange,
4718
4766
  onFiltersChange,
4719
- hideTopExport = false
4767
+ initialFilters,
4768
+ toolbarOptions,
4769
+ customToolbar,
4770
+ customFooter,
4771
+ hideTopExport = false,
4772
+ rowGroupingModel,
4773
+ defaultRowGroupingModel,
4774
+ onRowGroupingModelChange,
4775
+ rowGroupingColumnMode = "single",
4776
+ groupingColDef,
4777
+ defaultGroupingExpansionDepth = 0,
4778
+ isGroupExpandedByDefault,
4779
+ disableRowGrouping = false,
4780
+ treeData = false,
4781
+ getChildRows
4720
4782
  }) {
4721
4783
  const sxClass = useSx(sx);
4722
4784
  const [editingCell, setEditingCell] = (0, import_react23.useState)(null);
@@ -4776,10 +4838,46 @@ function DataGrid({
4776
4838
  const [focusFilterIdx, setFocusFilterIdx] = (0, import_react23.useState)(-1);
4777
4839
  const filterableColumnsProp = initialColumnsProp.filter((c) => c.filterable !== false);
4778
4840
  const initialFilterCol = String(filterableColumnsProp[0]?.field || filterableColumnsProp[0]?.key || "");
4779
- const [advancedFilters, setAdvancedFilters] = (0, import_react23.useState)([
4780
- { column: initialFilterCol, operator: getDefaultOperator(filterableColumnsProp[0]?.type), value: "", logic: "AND" }
4781
- ]);
4841
+ const [advancedFilters, setAdvancedFilters] = (0, import_react23.useState)(() => {
4842
+ if (initialFilters && initialFilters.length > 0) return initialFilters;
4843
+ return [{ column: initialFilterCol, operator: getDefaultOperator(filterableColumnsProp[0]?.type), value: "", logic: "AND" }];
4844
+ });
4782
4845
  const [colSearch, setColSearch] = (0, import_react23.useState)("");
4846
+ const [internalGroupingModel, setInternalGroupingModel] = (0, import_react23.useState)(
4847
+ defaultRowGroupingModel ?? []
4848
+ );
4849
+ const activeGroupingModel = rowGroupingModel ?? internalGroupingModel;
4850
+ const isGroupingActive = activeGroupingModel.length > 0;
4851
+ const setGroupingModel = (model) => {
4852
+ if (!rowGroupingModel) setInternalGroupingModel(model);
4853
+ onRowGroupingModelChange?.(model);
4854
+ };
4855
+ const addToGrouping = (field) => {
4856
+ if (activeGroupingModel.includes(field)) return;
4857
+ setGroupingModel([...activeGroupingModel, field]);
4858
+ };
4859
+ const removeFromGrouping = (field) => {
4860
+ setGroupingModel(activeGroupingModel.filter((f) => f !== field));
4861
+ };
4862
+ const [expandedGroups, setExpandedGroups] = (0, import_react23.useState)(/* @__PURE__ */ new Set());
4863
+ const prevGroupModelKeyRef = (0, import_react23.useRef)("");
4864
+ const toggleGroup = (groupId) => {
4865
+ setExpandedGroups((prev) => {
4866
+ const next = new Set(prev);
4867
+ if (next.has(groupId)) next.delete(groupId);
4868
+ else next.add(groupId);
4869
+ return next;
4870
+ });
4871
+ };
4872
+ const [treeExpandedRows, setTreeExpandedRows] = (0, import_react23.useState)(/* @__PURE__ */ new Set());
4873
+ const toggleTreeRow = (id) => {
4874
+ setTreeExpandedRows((prev) => {
4875
+ const next = new Set(prev);
4876
+ if (next.has(id)) next.delete(id);
4877
+ else next.add(id);
4878
+ return next;
4879
+ });
4880
+ };
4783
4881
  (0, import_react23.useEffect)(() => {
4784
4882
  const handleMouseMove = (e) => {
4785
4883
  if (!resizingColumn) return;
@@ -4822,6 +4920,13 @@ function DataGrid({
4822
4920
  return next;
4823
4921
  });
4824
4922
  }, [initialColumnsProp]);
4923
+ const getGroupValue = (item, field) => {
4924
+ const col = resolvedColumns.find((c) => String(c.field) === field || String(c.key) === field);
4925
+ const raw = item[field];
4926
+ if (col?.groupingValueGetter) return String(col.groupingValueGetter(raw, item) ?? "");
4927
+ if (col?.valueGetter) return String(col.valueGetter({ value: raw, row: item, field }) ?? "");
4928
+ return raw == null ? "" : String(raw);
4929
+ };
4825
4930
  const onFiltersChangeRef = (0, import_react23.useRef)(onFiltersChange);
4826
4931
  (0, import_react23.useEffect)(() => {
4827
4932
  onFiltersChangeRef.current = onFiltersChange;
@@ -5009,14 +5114,36 @@ function DataGrid({
5009
5114
  return 0;
5010
5115
  });
5011
5116
  }, [filteredData, sortField, sortDirection, resolvedColumns]);
5117
+ (0, import_react23.useEffect)(() => {
5118
+ const key = activeGroupingModel.join("\0");
5119
+ if (key === prevGroupModelKeyRef.current) return;
5120
+ prevGroupModelKeyRef.current = key;
5121
+ if (!activeGroupingModel.length) {
5122
+ setExpandedGroups(/* @__PURE__ */ new Set());
5123
+ return;
5124
+ }
5125
+ const allGroups = getAllGroupIds(sortedData, activeGroupingModel, getGroupValue);
5126
+ setExpandedGroups(new Set(
5127
+ allGroups.filter((g) => isGroupExpandedByDefault ? isGroupExpandedByDefault({ id: g.id, field: g.field, key: g.key, depth: g.depth, count: g.count }) : defaultGroupingExpansionDepth === -1 || g.depth < defaultGroupingExpansionDepth).map((g) => g.id)
5128
+ ));
5129
+ }, [activeGroupingModel.join("\0")]);
5130
+ const resolveChildren = getChildRows ?? ((row) => row.children ?? null);
5131
+ const flatEntries = (0, import_react23.useMemo)(() => {
5132
+ if (treeData) {
5133
+ return buildTreeEntries(sortedData, resolveChildren, treeExpandedRows);
5134
+ }
5135
+ if (!isGroupingActive) return null;
5136
+ return buildFlatEntries(sortedData, activeGroupingModel, getGroupValue, expandedGroups);
5137
+ }, [treeData, isGroupingActive, sortedData, activeGroupingModel.join("\0"), expandedGroups, treeExpandedRows]);
5012
5138
  const isServer = paginationMode === "server";
5013
- const totalRows = isServer ? rowCount ?? data.length : filteredData.length;
5139
+ const totalRows = isServer ? rowCount ?? data.length : flatEntries ? flatEntries.length : filteredData.length;
5014
5140
  const totalPages = Math.max(1, Math.ceil(totalRows / activePageSize));
5015
- const paginatedData = (0, import_react23.useMemo)(() => {
5016
- if (isServer) return data;
5141
+ const displayRows = (0, import_react23.useMemo)(() => {
5142
+ if (isServer) return data.map((row) => ({ kind: "data", row, depth: 0 }));
5143
+ const source = flatEntries ?? sortedData.map((row) => ({ kind: "data", row, depth: 0 }));
5017
5144
  const start = (activePage - 1) * activePageSize;
5018
- return sortedData.slice(start, start + activePageSize);
5019
- }, [isServer, data, sortedData, activePage, activePageSize]);
5145
+ return source.slice(start, start + activePageSize);
5146
+ }, [isServer, data, flatEntries, sortedData, activePage, activePageSize]);
5020
5147
  const handleExport = () => {
5021
5148
  const exportableCols = resolvedColumns.filter((c) => !c.hidden && c.isExportable !== false);
5022
5149
  const headers = exportableCols.map((c) => c.headerName).join(",");
@@ -5066,8 +5193,57 @@ function DataGrid({
5066
5193
  const left = resolvedColumns.filter((c) => !c.hidden && c.pinned === "left");
5067
5194
  const mid = resolvedColumns.filter((c) => !c.hidden && !c.pinned);
5068
5195
  const right = resolvedColumns.filter((c) => !c.hidden && c.pinned === "right");
5069
- return [...left, ...mid, ...right];
5070
- }, [resolvedColumns]);
5196
+ const dataCols = [...left, ...mid, ...right];
5197
+ if (treeData) {
5198
+ const treeCol = {
5199
+ key: "__tree__",
5200
+ field: "__tree__",
5201
+ header: "",
5202
+ headerName: "",
5203
+ width: 44,
5204
+ sortable: false,
5205
+ filterable: false,
5206
+ disableColumnMenu: true,
5207
+ hideable: false
5208
+ };
5209
+ return [treeCol, ...dataCols];
5210
+ }
5211
+ if (!isGroupingActive) return dataCols;
5212
+ if (rowGroupingColumnMode === "multiple") {
5213
+ const groupCols = activeGroupingModel.map((gField, i) => {
5214
+ const src = resolvedColumns.find((c) => String(c.field) === gField || String(c.key) === gField);
5215
+ const def2 = typeof groupingColDef === "function" ? groupingColDef(gField) : groupingColDef;
5216
+ return {
5217
+ key: `__group_${i}__`,
5218
+ field: `__group_${i}__`,
5219
+ header: def2?.headerName ?? src?.header ?? src?.headerName ?? gField,
5220
+ headerName: def2?.headerName ?? src?.header ?? src?.headerName ?? gField,
5221
+ width: def2?.width ?? 160,
5222
+ sortable: false,
5223
+ filterable: false,
5224
+ disableColumnMenu: true,
5225
+ hideable: false,
5226
+ __groupField: gField,
5227
+ __groupIndex: i
5228
+ };
5229
+ });
5230
+ return [...groupCols, ...dataCols];
5231
+ }
5232
+ const def = typeof groupingColDef === "function" ? groupingColDef(activeGroupingModel[0]) : groupingColDef;
5233
+ const singleSrc = resolvedColumns.find((c) => String(c.field) === activeGroupingModel[0] || String(c.key) === activeGroupingModel[0]);
5234
+ const singleGroupCol = {
5235
+ key: "__group__",
5236
+ field: "__group__",
5237
+ header: def?.headerName ?? (activeGroupingModel.length === 1 ? singleSrc?.header ?? singleSrc?.headerName ?? "Group" : "Group"),
5238
+ headerName: def?.headerName ?? (activeGroupingModel.length === 1 ? singleSrc?.header ?? singleSrc?.headerName ?? "Group" : "Group"),
5239
+ width: def?.width ?? 200,
5240
+ sortable: false,
5241
+ filterable: false,
5242
+ disableColumnMenu: true,
5243
+ hideable: false
5244
+ };
5245
+ return [singleGroupCol, ...dataCols];
5246
+ }, [resolvedColumns, isGroupingActive, activeGroupingModel, rowGroupingColumnMode, groupingColDef]);
5071
5247
  const getLeftOffset = (col, idx) => {
5072
5248
  if (col.pinned !== "left") return void 0;
5073
5249
  let offset2 = 0;
@@ -5102,7 +5278,14 @@ function DataGrid({
5102
5278
  };
5103
5279
  const activeMenuCol = activeMenu ? resolvedColumns.find((c) => String(c.field) === activeMenu) : null;
5104
5280
  const alignClass = (align) => align === "center" ? "dg-slot--center" : align === "right" ? "dg-slot--right" : "dg-slot--left";
5105
- return /* @__PURE__ */ import_react23.default.createElement("div", { className: ["dg-root", sxClass, className].filter(Boolean).join(" ") }, /* @__PURE__ */ import_react23.default.createElement("div", { className: "dg-header" }, /* @__PURE__ */ import_react23.default.createElement("div", { className: "dg-header-info" }, /* @__PURE__ */ import_react23.default.createElement("h2", null, title), /* @__PURE__ */ import_react23.default.createElement("p", null, filteredData.length, " total records")), /* @__PURE__ */ import_react23.default.createElement("div", { className: "dg-header-actions" }, /* @__PURE__ */ import_react23.default.createElement("div", { className: "dg-search-wrap" }, /* @__PURE__ */ import_react23.default.createElement(import_lucide_react2.Search, { size: 15 }), /* @__PURE__ */ import_react23.default.createElement(
5281
+ const tOpts = toolbarOptions ?? {};
5282
+ const showSearch = !tOpts.hideSearch;
5283
+ const showFilterBtn = !tOpts.hideFilter;
5284
+ const showColumnsBtn = !tOpts.hideColumns;
5285
+ const showExportBtn = !tOpts.hideExport && !hideTopExport;
5286
+ const showTitle = !tOpts.hideTitle;
5287
+ const showRecordCount = !tOpts.hideRecordCount;
5288
+ return /* @__PURE__ */ import_react23.default.createElement("div", { className: ["dg-root", sxClass, className].filter(Boolean).join(" ") }, !tOpts.hideHeader && /* @__PURE__ */ import_react23.default.createElement("div", { className: `dg-header${customToolbar ? " dg-header--custom" : ""}` }, !customToolbar && (showTitle || showRecordCount) && /* @__PURE__ */ import_react23.default.createElement("div", { className: "dg-header-info" }, showTitle && /* @__PURE__ */ import_react23.default.createElement("h2", null, title), showRecordCount && /* @__PURE__ */ import_react23.default.createElement("p", null, filteredData.length, " total records")), /* @__PURE__ */ import_react23.default.createElement("div", { className: "dg-header-actions" }, customToolbar ?? /* @__PURE__ */ import_react23.default.createElement(import_react23.default.Fragment, null, showSearch && /* @__PURE__ */ import_react23.default.createElement("div", { className: "dg-search-wrap" }, /* @__PURE__ */ import_react23.default.createElement(import_lucide_react2.Search, { size: 15 }), /* @__PURE__ */ import_react23.default.createElement(
5106
5289
  "input",
5107
5290
  {
5108
5291
  className: "dg-search",
@@ -5113,23 +5296,35 @@ function DataGrid({
5113
5296
  setCurrentPage(1);
5114
5297
  }
5115
5298
  }
5116
- )), /* @__PURE__ */ import_react23.default.createElement(Tooltip, { title: "Filters", placement: "top" }, /* @__PURE__ */ import_react23.default.createElement(
5299
+ )), showFilterBtn && /* @__PURE__ */ import_react23.default.createElement(Tooltip, { title: "Filters", placement: "top" }, /* @__PURE__ */ import_react23.default.createElement(
5117
5300
  "button",
5118
5301
  {
5119
5302
  className: `dg-icon-btn ${hasActiveFilters ? "active" : ""}`,
5120
5303
  onClick: () => setShowAdvancedFilter(true)
5121
5304
  },
5122
5305
  /* @__PURE__ */ import_react23.default.createElement(import_lucide_react2.Filter, { size: 16 })
5123
- )), /* @__PURE__ */ import_react23.default.createElement(Tooltip, { title: "Manage Columns", placement: "top" }, /* @__PURE__ */ import_react23.default.createElement(
5306
+ )), showColumnsBtn && /* @__PURE__ */ import_react23.default.createElement(Tooltip, { title: "Manage Columns", placement: "top" }, /* @__PURE__ */ import_react23.default.createElement(
5124
5307
  "button",
5125
5308
  {
5126
5309
  className: "dg-icon-btn",
5127
5310
  onClick: () => setShowManageColumns(true)
5128
5311
  },
5129
5312
  /* @__PURE__ */ import_react23.default.createElement(import_lucide_react2.Columns, { size: 16 })
5130
- )), !hideTopExport && /* @__PURE__ */ import_react23.default.createElement("button", { className: "dg-action-btn", onClick: handleExport }, /* @__PURE__ */ import_react23.default.createElement(import_lucide_react2.Download, { size: 14 }), " Export CSV"), headerActions && /* @__PURE__ */ import_react23.default.createElement("div", { className: `dg-header-slot ${alignClass(headerActions.align)}` }, headerActions.content))), /* @__PURE__ */ import_react23.default.createElement("div", { className: `dg-toolbar ${alignClass(toolbarContent?.align)}` }, toolbarContent?.content || ""), /* @__PURE__ */ import_react23.default.createElement("div", { className: `dg-table-wrap${paginatedData.length === 0 && !loading ? " dg-table-wrap--empty" : ""}` }, loading && /* @__PURE__ */ import_react23.default.createElement("div", { className: "dg-loading-overlay" }, /* @__PURE__ */ import_react23.default.createElement("div", { className: "dg-loading-spinner" })), /* @__PURE__ */ import_react23.default.createElement("table", { className: "dg-table" }, /* @__PURE__ */ import_react23.default.createElement("thead", null, /* @__PURE__ */ import_react23.default.createElement("tr", null, visibleColumns.map((col, idx) => {
5313
+ )), showExportBtn && /* @__PURE__ */ import_react23.default.createElement("button", { className: "dg-action-btn", onClick: handleExport }, /* @__PURE__ */ import_react23.default.createElement(import_lucide_react2.Download, { size: 14 }), " Export CSV")), headerActions && /* @__PURE__ */ import_react23.default.createElement("div", { className: `dg-header-slot ${alignClass(headerActions.align)}` }, headerActions.content))), !tOpts.hideHeader && /* @__PURE__ */ import_react23.default.createElement("div", { className: `dg-toolbar ${alignClass(toolbarContent?.align)}` }, toolbarContent?.content || ""), isGroupingActive && /* @__PURE__ */ import_react23.default.createElement("div", { className: "dg-grouping-bar" }, /* @__PURE__ */ import_react23.default.createElement("span", { className: "dg-grouping-bar-label" }, "Grouped by"), activeGroupingModel.map((gField) => {
5314
+ const col = resolvedColumns.find((c) => String(c.field) === gField || String(c.key) === gField);
5315
+ return /* @__PURE__ */ import_react23.default.createElement("div", { key: gField, className: "dg-group-chip" }, /* @__PURE__ */ import_react23.default.createElement(import_lucide_react2.Layers, { size: 11 }), /* @__PURE__ */ import_react23.default.createElement("span", null, col?.header ?? col?.headerName ?? gField), !disableRowGrouping && /* @__PURE__ */ import_react23.default.createElement(
5316
+ "button",
5317
+ {
5318
+ className: "dg-group-chip-remove",
5319
+ onClick: () => removeFromGrouping(gField),
5320
+ title: `Remove grouping by ${col?.header ?? gField}`
5321
+ },
5322
+ /* @__PURE__ */ import_react23.default.createElement(import_lucide_react2.X, { size: 10 })
5323
+ ));
5324
+ })), /* @__PURE__ */ import_react23.default.createElement("div", { className: `dg-table-wrap${filteredData.length === 0 && !loading ? " dg-table-wrap--empty" : ""} ${tOpts.hideHeader ? "rm-top-border" : ""} ${tOpts.hideFooter ? "rm-bottom-border" : ""}` }, loading && /* @__PURE__ */ import_react23.default.createElement("div", { className: "dg-loading-overlay" }, /* @__PURE__ */ import_react23.default.createElement("div", { className: "dg-loading-spinner" })), /* @__PURE__ */ import_react23.default.createElement("table", { className: "dg-table" }, /* @__PURE__ */ import_react23.default.createElement("thead", null, /* @__PURE__ */ import_react23.default.createElement("tr", null, visibleColumns.map((col, idx) => {
5131
5325
  const colField = String(col.field);
5132
- const width = columnWidths[colField] || 200;
5326
+ const colNativeWidth = col.width ? typeof col.width === "number" ? col.width : parseInt(String(col.width)) : 200;
5327
+ const width = columnWidths[colField] || colNativeWidth;
5133
5328
  const leftOffset = getLeftOffset(col, idx);
5134
5329
  const rightOffset = getRightOffset(col, idx);
5135
5330
  const isSorted = sortField === col.field;
@@ -5180,79 +5375,150 @@ function DataGrid({
5180
5375
  }
5181
5376
  )))
5182
5377
  );
5183
- }), actions && /* @__PURE__ */ import_react23.default.createElement("th", { style: { width: 0, padding: 0 } }))), /* @__PURE__ */ import_react23.default.createElement("tbody", null, paginatedData.length > 0 && paginatedData.map((item) => /* @__PURE__ */ import_react23.default.createElement("tr", { key: item.id, className: "dg-tbody-row", onDoubleClick: () => onRowDoubleClick?.(item) }, visibleColumns.map((col, idx) => {
5184
- const colField = String(col.field);
5185
- const width = columnWidths[colField] || 200;
5186
- const leftOffset = getLeftOffset(col, idx);
5187
- const rightOffset = getRightOffset(col, idx);
5188
- return /* @__PURE__ */ import_react23.default.createElement(
5189
- "td",
5190
- {
5191
- key: `${item.id}-${colField}`,
5192
- className: `dg-td${col.pinned === "left" ? " pinned-left" : col.pinned === "right" ? " pinned-right" : ""}${col.editable ? " dg-td--editable" : ""} ${col.cellClassName || ""}`,
5193
- style: { width, minWidth: width, maxWidth: width, left: leftOffset, right: rightOffset, flex: col.flex },
5194
- onDoubleClick: () => onCellDoubleClick?.({ row: item, field: colField, value: item[col.field || ""] }),
5195
- onClick: col.editable ? () => {
5196
- const field = String(col.field);
5197
- const rawValue = item[col.field || ""];
5198
- const value = col.valueGetter ? col.valueGetter({ value: rawValue, row: item, field }) : rawValue;
5199
- setEditingCell({ rowId: item.id, field, value });
5200
- } : void 0
5201
- },
5202
- (() => {
5203
- const field = String(col.field);
5204
- const rawValue = item[col.field || ""];
5205
- let value = col.valueGetter ? col.valueGetter({ value: rawValue, row: item, field }) : rawValue;
5206
- if (col.editable && editingCell?.rowId === item.id && editingCell?.field === field) {
5207
- const inputType = col.type === "number" ? "number" : col.type === "date" ? "date" : "text";
5208
- const commit = (finalValue) => {
5209
- setEditingCell(null);
5210
- col.onEnter?.({ value: finalValue, row: item, field });
5211
- };
5212
- return /* @__PURE__ */ import_react23.default.createElement(
5213
- "input",
5378
+ }), actions && /* @__PURE__ */ import_react23.default.createElement("th", { style: { width: 0, padding: 0 } }))), /* @__PURE__ */ import_react23.default.createElement("tbody", null, displayRows.length > 0 && displayRows.map((entry) => {
5379
+ if (entry.kind === "group") {
5380
+ const isExpanded = expandedGroups.has(entry.id);
5381
+ const colDef = typeof groupingColDef === "function" ? groupingColDef(entry.field) : groupingColDef;
5382
+ const fieldLabel = resolvedColumns.find(
5383
+ (c) => String(c.field) === entry.field || String(c.key) === entry.field
5384
+ )?.header ?? entry.field;
5385
+ const totalCols = visibleColumns.length + (actions ? 1 : 0);
5386
+ return /* @__PURE__ */ import_react23.default.createElement("tr", { key: entry.id, className: "dg-group-row" }, /* @__PURE__ */ import_react23.default.createElement("td", { colSpan: totalCols, className: "dg-group-cell" }, /* @__PURE__ */ import_react23.default.createElement(
5387
+ "div",
5388
+ {
5389
+ className: "dg-group-cell-inner",
5390
+ style: { paddingLeft: entry.depth * 20 },
5391
+ onClick: () => toggleGroup(entry.id)
5392
+ },
5393
+ /* @__PURE__ */ import_react23.default.createElement("button", { className: "dg-group-toggle", onClick: (e) => {
5394
+ e.stopPropagation();
5395
+ toggleGroup(entry.id);
5396
+ } }, isExpanded ? /* @__PURE__ */ import_react23.default.createElement(import_lucide_react2.ChevronDown, { size: 15 }) : /* @__PURE__ */ import_react23.default.createElement(import_lucide_react2.ChevronRight, { size: 15 })),
5397
+ activeGroupingModel.length > 1 && /* @__PURE__ */ import_react23.default.createElement("span", { className: "dg-group-field-label" }, fieldLabel, ":"),
5398
+ colDef?.renderCell ? colDef.renderCell({ groupKey: entry.key, field: entry.field, depth: entry.depth, leafCount: entry.leafCount }) : /* @__PURE__ */ import_react23.default.createElement("span", { className: "dg-group-key" }, entry.key),
5399
+ !colDef?.hideDescendantCount && /* @__PURE__ */ import_react23.default.createElement("span", { className: "dg-group-count" }, entry.leafCount)
5400
+ )));
5401
+ }
5402
+ const item = entry.row;
5403
+ const rowDepth = entry.depth;
5404
+ return /* @__PURE__ */ import_react23.default.createElement("tr", { key: item.id, className: "dg-tbody-row", onDoubleClick: () => onRowDoubleClick?.(item) }, visibleColumns.map((col, idx) => {
5405
+ const colField = String(col.field);
5406
+ if (colField === "__tree__") {
5407
+ const treeColWidth = columnWidths["__tree__"] || 44;
5408
+ const isExpanded = treeExpandedRows.has(item.id);
5409
+ return /* @__PURE__ */ import_react23.default.createElement(
5410
+ "td",
5411
+ {
5412
+ key: `${item.id}-__tree__`,
5413
+ className: "dg-tree-cell",
5414
+ style: { width: treeColWidth, minWidth: treeColWidth, maxWidth: treeColWidth }
5415
+ },
5416
+ /* @__PURE__ */ import_react23.default.createElement("div", { className: "dg-tree-cell-inner", style: { paddingLeft: rowDepth * 20 } }, entry.hasChildren ? /* @__PURE__ */ import_react23.default.createElement(
5417
+ "button",
5214
5418
  {
5215
- className: "dg-cell-editor",
5216
- type: inputType,
5217
- autoFocus: true,
5218
- defaultValue: editingCell.value ?? "",
5219
- onClick: (e) => e.stopPropagation(),
5220
- onKeyDown: (e) => {
5221
- if (e.key === "Enter") commit(e.target.value);
5222
- if (e.key === "Escape") setEditingCell(null);
5223
- },
5224
- onBlur: (e) => {
5225
- const finalValue = e.target.value;
5226
- setEditingCell(null);
5227
- col.onBlur?.({ value: finalValue, row: item, field });
5419
+ className: "dg-group-toggle",
5420
+ onClick: (e) => {
5421
+ e.stopPropagation();
5422
+ toggleTreeRow(item.id);
5228
5423
  }
5229
- }
5230
- );
5231
- }
5232
- const formattedValue = col.valueFormatter ? col.valueFormatter({ value, row: item, field }) : value;
5233
- if (col.renderCell) {
5234
- return col.renderCell({ value, row: item, field });
5235
- }
5236
- if (col.render) {
5237
- return col.render(value, item);
5424
+ },
5425
+ isExpanded ? /* @__PURE__ */ import_react23.default.createElement(import_lucide_react2.ChevronDown, { size: 15 }) : /* @__PURE__ */ import_react23.default.createElement(import_lucide_react2.ChevronRight, { size: 15 })
5426
+ ) : /* @__PURE__ */ import_react23.default.createElement("span", { style: { display: "inline-block", width: 22 } }))
5427
+ );
5428
+ }
5429
+ if (colField === "__group__" || colField.startsWith("__group_")) {
5430
+ const colDef = typeof groupingColDef === "function" ? groupingColDef(colField) : groupingColDef;
5431
+ const leafField = colDef?.leafField;
5432
+ let leafContent = null;
5433
+ if (leafField) {
5434
+ const leafCol = resolvedColumns.find((c) => String(c.field) === leafField || String(c.key) === leafField);
5435
+ if (leafCol) {
5436
+ const raw = item[String(leafCol.field)];
5437
+ let val = leafCol.valueGetter ? leafCol.valueGetter({ value: raw, row: item, field: leafField }) : raw;
5438
+ if (leafCol.valueFormatter) val = leafCol.valueFormatter({ value: val, row: item, field: leafField });
5439
+ if (leafCol.renderCell) leafContent = leafCol.renderCell({ value: val, row: item, field: leafField });
5440
+ else leafContent = val == null ? "" : String(val);
5441
+ }
5238
5442
  }
5239
- return String(formattedValue ?? "");
5240
- })()
5241
- );
5242
- }), actions && /* @__PURE__ */ import_react23.default.createElement("td", { className: "dg-row-actions-cell" }, (() => {
5243
- const resolvedActions = typeof actions === "function" ? actions(item) : actions;
5244
- const visibleActions = resolvedActions.filter((a) => !a.show || a.show(item));
5245
- if (visibleActions.length === 0) return null;
5246
- return /* @__PURE__ */ import_react23.default.createElement("div", { className: "dg-row-actions" }, /* @__PURE__ */ import_react23.default.createElement("div", { className: "dg-action-group" }, visibleActions.map((action, i) => /* @__PURE__ */ import_react23.default.createElement(Tooltip, { key: i, title: action.label, placement: "top" }, /* @__PURE__ */ import_react23.default.createElement(
5247
- "button",
5248
- {
5249
- className: "dg-row-action-btn",
5250
- style: { color: action.color || "var(--text-secondary)" },
5251
- onClick: () => action.onClick(item)
5252
- },
5253
- action.icon
5254
- )))));
5255
- })()))))), paginatedData.length === 0 && /* @__PURE__ */ import_react23.default.createElement("div", { className: "dg-empty-state" }, /* @__PURE__ */ import_react23.default.createElement("svg", { className: "dg-empty-icon", viewBox: "0 0 200 160", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ import_react23.default.createElement("rect", { x: "20", y: "30", width: "160", height: "100", rx: "8", fill: "var(--hover-color)", stroke: "var(--border-color)", strokeWidth: "1.5" }), /* @__PURE__ */ import_react23.default.createElement("rect", { x: "20", y: "30", width: "160", height: "28", rx: "8", fill: "var(--border-color)", opacity: "0.5" }), /* @__PURE__ */ import_react23.default.createElement("rect", { x: "20", y: "50", width: "160", height: "8", rx: "0", fill: "var(--border-color)", opacity: "0.5" }), /* @__PURE__ */ import_react23.default.createElement("line", { x1: "72", y1: "30", x2: "72", y2: "130", stroke: "var(--border-color)", strokeWidth: "1" }), /* @__PURE__ */ import_react23.default.createElement("line", { x1: "128", y1: "30", x2: "128", y2: "130", stroke: "var(--border-color)", strokeWidth: "1" }), /* @__PURE__ */ import_react23.default.createElement("line", { x1: "20", y1: "78", x2: "180", y2: "78", stroke: "var(--border-color)", strokeWidth: "1" }), /* @__PURE__ */ import_react23.default.createElement("line", { x1: "20", y1: "104", x2: "180", y2: "104", stroke: "var(--border-color)", strokeWidth: "1" }), /* @__PURE__ */ import_react23.default.createElement("rect", { x: "32", y: "87", width: "28", height: "6", rx: "3", fill: "var(--border-color)", opacity: "0.4" }), /* @__PURE__ */ import_react23.default.createElement("rect", { x: "84", y: "87", width: "28", height: "6", rx: "3", fill: "var(--border-color)", opacity: "0.4" }), /* @__PURE__ */ import_react23.default.createElement("rect", { x: "140", y: "87", width: "28", height: "6", rx: "3", fill: "var(--border-color)", opacity: "0.4" }), /* @__PURE__ */ import_react23.default.createElement("rect", { x: "32", y: "113", width: "20", height: "6", rx: "3", fill: "var(--border-color)", opacity: "0.3" }), /* @__PURE__ */ import_react23.default.createElement("rect", { x: "84", y: "113", width: "32", height: "6", rx: "3", fill: "var(--border-color)", opacity: "0.3" }), /* @__PURE__ */ import_react23.default.createElement("rect", { x: "140", y: "113", width: "20", height: "6", rx: "3", fill: "var(--border-color)", opacity: "0.3" }), /* @__PURE__ */ import_react23.default.createElement("circle", { cx: "148", cy: "108", r: "26", fill: "var(--surface-color)", stroke: "var(--border-color)", strokeWidth: "1.5" }), /* @__PURE__ */ import_react23.default.createElement("circle", { cx: "145", cy: "105", r: "10", stroke: "var(--text-secondary)", strokeWidth: "2.5", opacity: "0.5" }), /* @__PURE__ */ import_react23.default.createElement("line", { x1: "152", y1: "113", x2: "161", y2: "122", stroke: "var(--text-secondary)", strokeWidth: "2.5", strokeLinecap: "round", opacity: "0.5" }), /* @__PURE__ */ import_react23.default.createElement("line", { x1: "141", y1: "101", x2: "149", y2: "109", stroke: "var(--text-secondary)", strokeWidth: "2", strokeLinecap: "round", opacity: "0.5" }), /* @__PURE__ */ import_react23.default.createElement("line", { x1: "149", y1: "101", x2: "141", y2: "109", stroke: "var(--text-secondary)", strokeWidth: "2", strokeLinecap: "round", opacity: "0.5" })), /* @__PURE__ */ import_react23.default.createElement("p", { className: "dg-empty-title" }, "No data found"), /* @__PURE__ */ import_react23.default.createElement("p", { className: "dg-empty-subtitle" }, filterText || hasActiveFilters ? "Try adjusting your search or filters" : "No records to display"))), pagination && /* @__PURE__ */ import_react23.default.createElement("div", { className: "dg-pagination" }, /* @__PURE__ */ import_react23.default.createElement("div", { className: "dg-page-info" }, /* @__PURE__ */ import_react23.default.createElement(Tooltip, { title: "Export CSV", placement: "top" }, /* @__PURE__ */ import_react23.default.createElement("button", { className: "dg-icon-btn", onClick: handleExport }, /* @__PURE__ */ import_react23.default.createElement(import_lucide_react2.Download, { size: 14 }))), /* @__PURE__ */ import_react23.default.createElement("div", { className: "dg-per-page" }, /* @__PURE__ */ import_react23.default.createElement("span", null, "Rows per page:"), /* @__PURE__ */ import_react23.default.createElement(
5443
+ const groupColWidth = columnWidths[colField] || 200;
5444
+ return /* @__PURE__ */ import_react23.default.createElement(
5445
+ "td",
5446
+ {
5447
+ key: `${item.id}-${colField}`,
5448
+ className: "dg-group-leaf-cell",
5449
+ style: { width: groupColWidth, minWidth: groupColWidth, maxWidth: groupColWidth, paddingLeft: rowDepth * 20 + 32 }
5450
+ },
5451
+ leafContent
5452
+ );
5453
+ }
5454
+ const width = columnWidths[colField] || 200;
5455
+ const leftOffset = getLeftOffset(col, idx);
5456
+ const rightOffset = getRightOffset(col, idx);
5457
+ return /* @__PURE__ */ import_react23.default.createElement(
5458
+ "td",
5459
+ {
5460
+ key: `${item.id}-${colField}`,
5461
+ className: `dg-td${col.pinned === "left" ? " pinned-left" : col.pinned === "right" ? " pinned-right" : ""}${col.editable ? " dg-td--editable" : ""} ${col.cellClassName || ""}`,
5462
+ style: { width, minWidth: width, maxWidth: width, left: leftOffset, right: rightOffset, flex: col.flex },
5463
+ onDoubleClick: () => onCellDoubleClick?.({ row: item, field: colField, value: item[col.field || ""] }),
5464
+ onClick: col.editable ? () => {
5465
+ const field = String(col.field);
5466
+ const rawValue = item[col.field || ""];
5467
+ const value = col.valueGetter ? col.valueGetter({ value: rawValue, row: item, field }) : rawValue;
5468
+ setEditingCell({ rowId: item.id, field, value });
5469
+ } : void 0
5470
+ },
5471
+ (() => {
5472
+ const field = String(col.field);
5473
+ const rawValue = item[col.field || ""];
5474
+ let value = col.valueGetter ? col.valueGetter({ value: rawValue, row: item, field }) : rawValue;
5475
+ if (col.editable && editingCell?.rowId === item.id && editingCell?.field === field) {
5476
+ const inputType = col.type === "number" ? "number" : col.type === "date" ? "date" : "text";
5477
+ const commit = (finalValue) => {
5478
+ setEditingCell(null);
5479
+ col.onEnter?.({ value: finalValue, row: item, field });
5480
+ };
5481
+ return /* @__PURE__ */ import_react23.default.createElement(
5482
+ "input",
5483
+ {
5484
+ className: "dg-cell-editor",
5485
+ type: inputType,
5486
+ autoFocus: true,
5487
+ defaultValue: editingCell.value ?? "",
5488
+ onClick: (e) => e.stopPropagation(),
5489
+ onKeyDown: (e) => {
5490
+ if (e.key === "Enter") commit(e.target.value);
5491
+ if (e.key === "Escape") setEditingCell(null);
5492
+ },
5493
+ onBlur: (e) => {
5494
+ const finalValue = e.target.value;
5495
+ setEditingCell(null);
5496
+ col.onBlur?.({ value: finalValue, row: item, field });
5497
+ }
5498
+ }
5499
+ );
5500
+ }
5501
+ const formattedValue = col.valueFormatter ? col.valueFormatter({ value, row: item, field }) : value;
5502
+ if (col.renderCell) return col.renderCell({ value, row: item, field });
5503
+ if (col.render) return col.render(value, item);
5504
+ return String(formattedValue ?? "");
5505
+ })()
5506
+ );
5507
+ }), actions && /* @__PURE__ */ import_react23.default.createElement("td", { className: "dg-row-actions-cell" }, (() => {
5508
+ const resolvedActions = typeof actions === "function" ? actions(item) : actions;
5509
+ const visibleActions = resolvedActions.filter((a) => !a.show || a.show(item));
5510
+ if (visibleActions.length === 0) return null;
5511
+ return /* @__PURE__ */ import_react23.default.createElement("div", { className: "dg-row-actions" }, /* @__PURE__ */ import_react23.default.createElement("div", { className: "dg-action-group" }, visibleActions.map((action, i) => /* @__PURE__ */ import_react23.default.createElement(Tooltip, { key: i, title: action.label, placement: "top" }, /* @__PURE__ */ import_react23.default.createElement(
5512
+ "button",
5513
+ {
5514
+ className: "dg-row-action-btn",
5515
+ style: { color: action.color || "var(--text-secondary)" },
5516
+ onClick: () => action.onClick(item)
5517
+ },
5518
+ action.icon
5519
+ )))));
5520
+ })()));
5521
+ }))), filteredData.length === 0 && /* @__PURE__ */ import_react23.default.createElement("div", { className: "dg-empty-state" }, /* @__PURE__ */ import_react23.default.createElement("svg", { className: "dg-empty-icon", viewBox: "0 0 200 160", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ import_react23.default.createElement("rect", { x: "20", y: "30", width: "160", height: "100", rx: "8", fill: "var(--hover-color)", stroke: "var(--border-color)", strokeWidth: "1.5" }), /* @__PURE__ */ import_react23.default.createElement("rect", { x: "20", y: "30", width: "160", height: "28", rx: "8", fill: "var(--border-color)", opacity: "0.5" }), /* @__PURE__ */ import_react23.default.createElement("rect", { x: "20", y: "50", width: "160", height: "8", rx: "0", fill: "var(--border-color)", opacity: "0.5" }), /* @__PURE__ */ import_react23.default.createElement("line", { x1: "72", y1: "30", x2: "72", y2: "130", stroke: "var(--border-color)", strokeWidth: "1" }), /* @__PURE__ */ import_react23.default.createElement("line", { x1: "128", y1: "30", x2: "128", y2: "130", stroke: "var(--border-color)", strokeWidth: "1" }), /* @__PURE__ */ import_react23.default.createElement("line", { x1: "20", y1: "78", x2: "180", y2: "78", stroke: "var(--border-color)", strokeWidth: "1" }), /* @__PURE__ */ import_react23.default.createElement("line", { x1: "20", y1: "104", x2: "180", y2: "104", stroke: "var(--border-color)", strokeWidth: "1" }), /* @__PURE__ */ import_react23.default.createElement("rect", { x: "32", y: "87", width: "28", height: "6", rx: "3", fill: "var(--border-color)", opacity: "0.4" }), /* @__PURE__ */ import_react23.default.createElement("rect", { x: "84", y: "87", width: "28", height: "6", rx: "3", fill: "var(--border-color)", opacity: "0.4" }), /* @__PURE__ */ import_react23.default.createElement("rect", { x: "140", y: "87", width: "28", height: "6", rx: "3", fill: "var(--border-color)", opacity: "0.4" }), /* @__PURE__ */ import_react23.default.createElement("rect", { x: "32", y: "113", width: "20", height: "6", rx: "3", fill: "var(--border-color)", opacity: "0.3" }), /* @__PURE__ */ import_react23.default.createElement("rect", { x: "84", y: "113", width: "32", height: "6", rx: "3", fill: "var(--border-color)", opacity: "0.3" }), /* @__PURE__ */ import_react23.default.createElement("rect", { x: "140", y: "113", width: "20", height: "6", rx: "3", fill: "var(--border-color)", opacity: "0.3" }), /* @__PURE__ */ import_react23.default.createElement("circle", { cx: "148", cy: "108", r: "26", fill: "var(--surface-color)", stroke: "var(--border-color)", strokeWidth: "1.5" }), /* @__PURE__ */ import_react23.default.createElement("circle", { cx: "145", cy: "105", r: "10", stroke: "var(--text-secondary)", strokeWidth: "2.5", opacity: "0.5" }), /* @__PURE__ */ import_react23.default.createElement("line", { x1: "152", y1: "113", x2: "161", y2: "122", stroke: "var(--text-secondary)", strokeWidth: "2.5", strokeLinecap: "round", opacity: "0.5" }), /* @__PURE__ */ import_react23.default.createElement("line", { x1: "141", y1: "101", x2: "149", y2: "109", stroke: "var(--text-secondary)", strokeWidth: "2", strokeLinecap: "round", opacity: "0.5" }), /* @__PURE__ */ import_react23.default.createElement("line", { x1: "149", y1: "101", x2: "141", y2: "109", stroke: "var(--text-secondary)", strokeWidth: "2", strokeLinecap: "round", opacity: "0.5" })), /* @__PURE__ */ import_react23.default.createElement("p", { className: "dg-empty-title" }, "No data found"), /* @__PURE__ */ import_react23.default.createElement("p", { className: "dg-empty-subtitle" }, filterText || hasActiveFilters ? "Try adjusting your search or filters" : "No records to display"))), customFooter ? /* @__PURE__ */ import_react23.default.createElement("div", { className: "dg-pagination dg-pagination--custom" }, customFooter) : pagination && !tOpts.hideFooter && /* @__PURE__ */ import_react23.default.createElement("div", { className: "dg-pagination" }, /* @__PURE__ */ import_react23.default.createElement("div", { className: "dg-page-info" }, /* @__PURE__ */ import_react23.default.createElement(Tooltip, { title: "Export CSV", placement: "top" }, /* @__PURE__ */ import_react23.default.createElement("button", { className: "dg-icon-btn", onClick: handleExport }, /* @__PURE__ */ import_react23.default.createElement(import_lucide_react2.Download, { size: 14 }))), /* @__PURE__ */ import_react23.default.createElement("div", { className: "dg-per-page" }, /* @__PURE__ */ import_react23.default.createElement("span", null, "Rows per page:"), /* @__PURE__ */ import_react23.default.createElement(
5256
5522
  FilterSelect,
5257
5523
  {
5258
5524
  placement: "top",
@@ -5293,6 +5559,17 @@ function DataGrid({
5293
5559
  setShowAdvancedFilter(true);
5294
5560
  setActiveMenu(null);
5295
5561
  } }, /* @__PURE__ */ import_react23.default.createElement(import_lucide_react2.Filter, { size: 14 }), " Filter\u2026"),
5562
+ !disableRowGrouping && activeMenuCol?.groupable !== false && (() => {
5563
+ const gField = String(activeMenuCol?.field ?? "");
5564
+ const isGrouped = activeGroupingModel.includes(gField);
5565
+ return isGrouped ? /* @__PURE__ */ import_react23.default.createElement("button", { className: "dg-menu-item", onClick: () => {
5566
+ removeFromGrouping(gField);
5567
+ setActiveMenu(null);
5568
+ } }, /* @__PURE__ */ import_react23.default.createElement(import_lucide_react2.Layers, { size: 14 }), " Ungroup") : /* @__PURE__ */ import_react23.default.createElement("button", { className: "dg-menu-item", onClick: () => {
5569
+ addToGrouping(gField);
5570
+ setActiveMenu(null);
5571
+ } }, /* @__PURE__ */ import_react23.default.createElement(import_lucide_react2.Layers, { size: 14 }), " Group by");
5572
+ })(),
5296
5573
  /* @__PURE__ */ import_react23.default.createElement("button", { className: "dg-menu-item", onClick: () => toggleHide(activeMenu) }, /* @__PURE__ */ import_react23.default.createElement(import_lucide_react2.EyeOff, { size: 14 }), " Hide column"),
5297
5574
  /* @__PURE__ */ import_react23.default.createElement("button", { className: "dg-menu-item", onClick: () => {
5298
5575
  setShowManageColumns(true);
@@ -9612,6 +9889,14 @@ function SmartSelect({
9612
9889
  (0, import_react51.useEffect)(() => () => {
9613
9890
  if (debounceTimer.current) clearTimeout(debounceTimer.current);
9614
9891
  }, []);
9892
+ const [inputValue, setInputValue] = (0, import_react51.useState)(
9893
+ () => !multiple && value != null ? getOptionLabel(value) : ""
9894
+ );
9895
+ (0, import_react51.useEffect)(() => {
9896
+ if (!multiple) {
9897
+ setInputValue(value != null ? getOptionLabel(value) : "");
9898
+ }
9899
+ }, [value, multiple, getOptionLabel]);
9615
9900
  const getValue = (0, import_react51.useCallback)(
9616
9901
  (o) => getOptionValue ? getOptionValue(o) : String(getOptionLabel(o)),
9617
9902
  [getOptionValue, getOptionLabel]
@@ -9642,14 +9927,15 @@ function SmartSelect({
9642
9927
  }
9643
9928
  return value != null ? /* @__PURE__ */ new Set([getValue(value)]) : /* @__PURE__ */ new Set();
9644
9929
  }, [multiple, value, getValue]);
9645
- const handleInputChange = (0, import_react51.useCallback)((_, inputValue) => {
9930
+ const handleInputChange = (0, import_react51.useCallback)((_, inputValue2) => {
9931
+ setInputValue(inputValue2);
9646
9932
  if (!onSearchChange) return;
9647
9933
  if (debounceTimer.current) clearTimeout(debounceTimer.current);
9648
- if (!inputValue) {
9934
+ if (!inputValue2) {
9649
9935
  onSearchChange("", 0);
9650
9936
  return;
9651
9937
  }
9652
- const q = inputValue.toLowerCase();
9938
+ const q = inputValue2.toLowerCase();
9653
9939
  let localCount = 0;
9654
9940
  for (const opt of flatOptionsList) {
9655
9941
  if (getOptionLabel(opt).toLowerCase().includes(q) || (getOptionSubLabel?.(opt) ?? "").toLowerCase().includes(q)) {
@@ -9660,10 +9946,10 @@ function SmartSelect({
9660
9946
  if (localCount >= searchThreshold) return;
9661
9947
  const needed = searchThreshold - localCount;
9662
9948
  if (debounceMs <= 0) {
9663
- onSearchChange(inputValue, needed);
9949
+ onSearchChange(inputValue2, needed);
9664
9950
  } else {
9665
9951
  debounceTimer.current = setTimeout(() => {
9666
- onSearchChange(inputValue, needed);
9952
+ onSearchChange(inputValue2, needed);
9667
9953
  }, debounceMs);
9668
9954
  }
9669
9955
  }, [onSearchChange, debounceMs, searchThreshold, flatOptionsList, getOptionLabel, getOptionSubLabel]);
@@ -9742,13 +10028,13 @@ function SmartSelect({
9742
10028
  /* @__PURE__ */ import_react51.default.createElement("span", { className: "rf-select__option-check", "aria-hidden": "true" }, /* @__PURE__ */ import_react51.default.createElement(CheckIcon3, null))
9743
10029
  );
9744
10030
  }, [depthMap, getValue, getOptionLabel, getOptionSubLabel, selectedKeys]);
9745
- const computedFilterOptions = (0, import_react51.useCallback)((opts, inputValue) => {
9746
- if (filterOptionsProp) return filterOptionsProp(opts, inputValue);
10031
+ const computedFilterOptions = (0, import_react51.useCallback)((opts, inputValue2) => {
10032
+ if (filterOptionsProp) return filterOptionsProp(opts, inputValue2);
9747
10033
  if (multiple) {
9748
10034
  const selected = opts.filter((o) => selectedKeys.has(getValue(o)));
9749
10035
  const unselected = opts.filter((o) => !selectedKeys.has(getValue(o)));
9750
- if (!inputValue) return [...selected, ...unselected];
9751
- const q2 = inputValue.toLowerCase();
10036
+ if (!inputValue2) return [...selected, ...unselected];
10037
+ const q2 = inputValue2.toLowerCase();
9752
10038
  const filteredUnselected = unselected.filter(
9753
10039
  (opt) => getOptionLabel(opt).toLowerCase().includes(q2) || (getOptionSubLabel?.(opt) ?? "").toLowerCase().includes(q2)
9754
10040
  ).slice(0, searchThreshold);
@@ -9756,7 +10042,7 @@ function SmartSelect({
9756
10042
  }
9757
10043
  if (value != null) {
9758
10044
  const selectedLabel = getOptionLabel(value);
9759
- if (inputValue === selectedLabel) {
10045
+ if (inputValue2 === selectedLabel) {
9760
10046
  const selectedKey = getValue(value);
9761
10047
  return [
9762
10048
  ...opts.filter((o) => getValue(o) === selectedKey),
@@ -9764,8 +10050,8 @@ function SmartSelect({
9764
10050
  ];
9765
10051
  }
9766
10052
  }
9767
- if (!inputValue) return opts;
9768
- const q = inputValue.toLowerCase();
10053
+ if (!inputValue2) return opts;
10054
+ const q = inputValue2.toLowerCase();
9769
10055
  return opts.filter(
9770
10056
  (opt) => getOptionLabel(opt).toLowerCase().includes(q) || (getOptionSubLabel?.(opt) ?? "").toLowerCase().includes(q)
9771
10057
  ).slice(0, searchThreshold);
@@ -9776,6 +10062,7 @@ function SmartSelect({
9776
10062
  options: displayOptions,
9777
10063
  value: value ?? (multiple ? [] : null),
9778
10064
  onChange: handleChange,
10065
+ inputValue: multiple ? void 0 : inputValue,
9779
10066
  onInputChange: handleInputChange,
9780
10067
  multiple,
9781
10068
  limitTags,