@moontra/moonui-pro 2.26.17 → 2.26.19

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.mjs CHANGED
@@ -73508,97 +73508,68 @@ function DataTableQuickFilter({
73508
73508
  filter,
73509
73509
  data
73510
73510
  }) {
73511
- const [searchValue, setSearchValue] = useState("");
73512
- const column = table.getColumn(filter.column);
73513
- if (typeof window !== "undefined" && true) {
73514
- const allColumns = table.getAllColumns();
73515
- console.log(`QuickFilter: Looking for column '${filter.column}'`, {
73516
- availableColumns: allColumns.map((c2) => c2.id),
73517
- columnFound: !!column
73518
- });
73519
- }
73520
- if (!column) {
73521
- console.warn(`QuickFilter: Column '${filter.column}' not found in table`);
73522
- return null;
73523
- }
73524
- const columnDef = column.columnDef;
73525
- const filterValueAccessor = columnDef?.meta?.filterValueAccessor;
73526
- const filterOptions = columnDef?.meta?.filterOptions;
73527
- const getFilterValue = (row) => {
73528
- if (filterValueAccessor) {
73529
- return filterValueAccessor(row);
73530
- }
73531
- const value = row[filter.column];
73532
- if (value === void 0) {
73533
- const accessor = column.columnDef.accessorKey || column.columnDef.accessorFn;
73534
- if (typeof accessor === "function") {
73535
- return accessor(row);
73536
- } else if (accessor && typeof accessor === "string") {
73537
- const keys2 = accessor.split(".");
73538
- let nestedValue = row;
73539
- for (const key of keys2) {
73540
- nestedValue = nestedValue?.[key];
73541
- if (nestedValue === void 0)
73542
- break;
73543
- }
73544
- return nestedValue;
73545
- }
73511
+ const [open, setOpen] = useState(false);
73512
+ const column = t__default.useMemo(() => {
73513
+ let col = table.getColumn(filter.column);
73514
+ if (!col) {
73515
+ const allCols = table.getAllColumns();
73516
+ col = allCols.find(
73517
+ (c2) => c2.id === filter.column || c2.columnDef.accessorKey === filter.column
73518
+ );
73546
73519
  }
73547
- return value;
73548
- };
73520
+ return col;
73521
+ }, [table, filter.column]);
73549
73522
  const availableOptions = useMemo(() => {
73550
73523
  if (filter.options && filter.options !== "auto") {
73551
73524
  return filter.options;
73552
73525
  }
73553
- if (filterOptions) {
73554
- return filterOptions;
73555
- }
73556
73526
  const uniqueValues = /* @__PURE__ */ new Set();
73557
73527
  data.forEach((row) => {
73558
- const value = getFilterValue(row);
73528
+ let value = row[filter.column];
73529
+ if (value === void 0 && filter.column.includes(".")) {
73530
+ const keys2 = filter.column.split(".");
73531
+ value = row;
73532
+ for (const key of keys2) {
73533
+ value = value?.[key];
73534
+ }
73535
+ }
73559
73536
  if (value != null && value !== "") {
73560
73537
  uniqueValues.add(String(value));
73561
73538
  }
73562
73539
  });
73563
- const options = Array.from(uniqueValues).sort().slice(0, 50);
73564
- if (typeof window !== "undefined" && true) {
73565
- console.log(`QuickFilter Debug [${filter.column}]:`, {
73566
- dataLength: data.length,
73567
- uniqueValues: uniqueValues.size,
73568
- options,
73569
- filterOptions: filter.options,
73570
- sampleData: data.length > 0 ? data[0] : null,
73571
- columnExists: !!column,
73572
- columnDef: column?.columnDef
73573
- });
73574
- }
73575
- return options;
73576
- }, [data, filter.options, filterOptions, filter.column]);
73540
+ return Array.from(uniqueValues).sort();
73541
+ }, [data, filter.column, filter.options]);
73542
+ const filterValue = column?.getFilterValue();
73543
+ const selectedValues = useMemo(() => {
73544
+ if (!filterValue)
73545
+ return /* @__PURE__ */ new Set();
73546
+ if (Array.isArray(filterValue))
73547
+ return new Set(filterValue);
73548
+ return /* @__PURE__ */ new Set([String(filterValue)]);
73549
+ }, [filterValue]);
73577
73550
  const optionCounts = useMemo(() => {
73578
73551
  if (!filter.showCounts)
73579
73552
  return {};
73580
73553
  const counts = {};
73581
- availableOptions.forEach((option) => {
73582
- counts[option] = 0;
73583
- });
73584
73554
  data.forEach((row) => {
73585
- const value = getFilterValue(row);
73586
- if (value != null && counts[String(value)] !== void 0) {
73587
- counts[String(value)]++;
73555
+ let value = row[filter.column];
73556
+ if (value === void 0 && filter.column.includes(".")) {
73557
+ const keys2 = filter.column.split(".");
73558
+ value = row;
73559
+ for (const key of keys2) {
73560
+ value = value?.[key];
73561
+ }
73562
+ }
73563
+ if (value != null && value !== "") {
73564
+ const strValue = String(value);
73565
+ counts[strValue] = (counts[strValue] || 0) + 1;
73588
73566
  }
73589
73567
  });
73590
73568
  return counts;
73591
- }, [data, filter.showCounts, availableOptions]);
73592
- const filterValue = column.getFilterValue();
73593
- const selectedValues = useMemo(() => {
73594
- if (!filterValue)
73595
- return /* @__PURE__ */ new Set();
73596
- if (Array.isArray(filterValue))
73597
- return new Set(filterValue);
73598
- return /* @__PURE__ */ new Set([String(filterValue)]);
73599
- }, [filterValue]);
73600
- const label = filter.label || column.id;
73569
+ }, [data, filter.column, filter.showCounts]);
73601
73570
  const handleSelect = (value) => {
73571
+ if (!column)
73572
+ return;
73602
73573
  if (filter.multi) {
73603
73574
  const newValues = new Set(selectedValues);
73604
73575
  if (newValues.has(value)) {
@@ -73620,22 +73591,17 @@ function DataTableQuickFilter({
73620
73591
  }
73621
73592
  };
73622
73593
  const handleClear = () => {
73623
- column.setFilterValue(void 0);
73624
- setSearchValue("");
73594
+ column?.setFilterValue(void 0);
73625
73595
  };
73626
- const filteredOptions = useMemo(() => {
73627
- if (!searchValue)
73628
- return availableOptions;
73629
- return availableOptions.filter(
73630
- (option) => option.toLowerCase().includes(searchValue.toLowerCase())
73631
- );
73632
- }, [availableOptions, searchValue]);
73633
- return /* @__PURE__ */ jsxs(MoonUIPopoverPro, { children: [
73596
+ const label = filter.label || filter.column;
73597
+ const isDisabled = !column || availableOptions.length === 0;
73598
+ return /* @__PURE__ */ jsxs(MoonUIPopoverPro, { open, onOpenChange: setOpen, children: [
73634
73599
  /* @__PURE__ */ jsx(MoonUIPopoverTriggerPro, { asChild: true, children: /* @__PURE__ */ jsxs(
73635
73600
  MoonUIButtonPro,
73636
73601
  {
73637
73602
  variant: "outline",
73638
73603
  size: "sm",
73604
+ disabled: isDisabled,
73639
73605
  className: cn(
73640
73606
  "h-8 border-dashed",
73641
73607
  selectedValues.size > 0 && "border-solid"
@@ -73656,51 +73622,45 @@ function DataTableQuickFilter({
73656
73622
  ]
73657
73623
  }
73658
73624
  ) }),
73659
- /* @__PURE__ */ jsx(MoonUIPopoverContentPro, { className: "w-[250px] p-0", align: "start", children: /* @__PURE__ */ jsxs(MoonUICommandPro, { shouldFilter: false, children: [
73660
- /* @__PURE__ */ jsx(
73661
- MoonUICommandInputPro,
73662
- {
73663
- placeholder: `Search ${label.toLowerCase()}...`,
73664
- value: searchValue,
73665
- onValueChange: setSearchValue
73666
- }
73667
- ),
73668
- /* @__PURE__ */ jsx(MoonUICommandListPro, { children: filteredOptions.length === 0 ? /* @__PURE__ */ jsx(MoonUICommandEmptyPro, { children: "No results found" }) : /* @__PURE__ */ jsx(MoonUICommandGroupPro, { children: filteredOptions.map((option) => {
73625
+ /* @__PURE__ */ jsx(MoonUIPopoverContentPro, { className: "w-[250px] p-0", align: "start", children: /* @__PURE__ */ jsxs("div", { className: "p-2", children: [
73626
+ availableOptions.length === 0 ? /* @__PURE__ */ jsx("div", { className: "text-center text-sm text-muted-foreground py-4", children: "No options available" }) : /* @__PURE__ */ jsx("div", { className: "space-y-1", children: availableOptions.map((option) => {
73669
73627
  const isSelected = selectedValues.has(option);
73670
73628
  return /* @__PURE__ */ jsxs(
73671
- MoonUICommandItemPro,
73629
+ "button",
73672
73630
  {
73673
- value: option,
73674
- onSelect: () => handleSelect(option),
73631
+ onClick: () => handleSelect(option),
73632
+ className: cn(
73633
+ "flex w-full items-center justify-between rounded px-2 py-1.5 text-sm hover:bg-accent",
73634
+ isSelected && "bg-accent"
73635
+ ),
73675
73636
  children: [
73676
- /* @__PURE__ */ jsx(
73677
- "div",
73678
- {
73679
- className: cn(
73680
- "mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",
73681
- isSelected ? "bg-primary text-primary-foreground" : "opacity-50 [&_svg]:invisible"
73682
- ),
73683
- children: /* @__PURE__ */ jsx(Check, { className: cn("h-4 w-4") })
73684
- }
73685
- ),
73686
- /* @__PURE__ */ jsx("span", { className: "flex-1", children: option }),
73687
- filter.showCounts && optionCounts[option] !== void 0 && /* @__PURE__ */ jsx("span", { className: "ml-auto text-xs text-muted-foreground", children: optionCounts[option] })
73637
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
73638
+ /* @__PURE__ */ jsx(
73639
+ "div",
73640
+ {
73641
+ className: cn(
73642
+ "mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",
73643
+ isSelected ? "bg-primary text-primary-foreground" : "opacity-50 [&_svg]:invisible"
73644
+ ),
73645
+ children: /* @__PURE__ */ jsx(Check, { className: "h-4 w-4" })
73646
+ }
73647
+ ),
73648
+ /* @__PURE__ */ jsx("span", { children: option })
73649
+ ] }),
73650
+ filter.showCounts && optionCounts[option] !== void 0 && /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: optionCounts[option] })
73688
73651
  ]
73689
73652
  },
73690
73653
  option
73691
73654
  );
73692
- }) }) }),
73693
- selectedValues.size > 0 && /* @__PURE__ */ jsx("div", { className: "border-t p-2", children: /* @__PURE__ */ jsxs(
73655
+ }) }),
73656
+ selectedValues.size > 0 && /* @__PURE__ */ jsx("div", { className: "border-t mt-2 pt-2", children: /* @__PURE__ */ jsx(
73694
73657
  MoonUIButtonPro,
73695
73658
  {
73696
73659
  variant: "ghost",
73697
73660
  size: "sm",
73698
73661
  className: "w-full justify-center",
73699
73662
  onClick: handleClear,
73700
- children: [
73701
- /* @__PURE__ */ jsx(X, { className: "mr-2 h-4 w-4" }),
73702
- "Clear filter"
73703
- ]
73663
+ children: "Clear filter"
73704
73664
  }
73705
73665
  ) })
73706
73666
  ] }) })
@@ -74009,9 +73969,17 @@ function DataTable({
74009
73969
  }
74010
73970
  };
74011
73971
  };
73972
+ const processedColumns = t__default.useMemo(() => {
73973
+ return columns.map((col) => {
73974
+ if (!col.id && col.accessorKey) {
73975
+ return { ...col, id: col.accessorKey };
73976
+ }
73977
+ return col;
73978
+ });
73979
+ }, [columns]);
74012
73980
  const table = useReactTable({
74013
73981
  data: stableData,
74014
- columns,
73982
+ columns: processedColumns,
74015
73983
  onSortingChange: onSortingChange !== void 0 ? onSortingChange : setSorting,
74016
73984
  onColumnFiltersChange: onColumnFiltersChange !== void 0 ? onColumnFiltersChange : setColumnFilters,
74017
73985
  onPaginationChange: onPaginationChange !== void 0 ? onPaginationChange : setPaginationState,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moontra/moonui-pro",
3
- "version": "2.26.17",
3
+ "version": "2.26.19",
4
4
  "description": "Premium React components for MoonUI - Advanced UI library with 50+ pro components including performance, interactive, and gesture components",
5
5
  "type": "module",
6
6
  "main": "dist/index.mjs",