@moontra/moonui-pro 2.26.18 → 2.26.20

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,104 +73508,69 @@ function DataTableQuickFilter({
73508
73508
  filter,
73509
73509
  data
73510
73510
  }) {
73511
+ const [open, setOpen] = useState(false);
73511
73512
  const [searchValue, setSearchValue] = useState("");
73512
- let column = table.getColumn(filter.column);
73513
- if (!column) {
73514
- const allColumns = table.getAllColumns();
73515
- column = allColumns.find((col) => {
73516
- const colDef = col.columnDef;
73517
- return colDef.accessorKey === filter.column || col.id === filter.column;
73518
- });
73519
- }
73520
- if (typeof window !== "undefined" && true) {
73521
- const allColumns = table.getAllColumns();
73522
- console.log(`QuickFilter: Looking for column '${filter.column}'`, {
73523
- availableColumns: allColumns.map((c2) => ({ id: c2.id, accessorKey: c2.columnDef.accessorKey })),
73524
- columnFound: !!column
73525
- });
73526
- }
73527
- if (!column) {
73528
- console.warn(`QuickFilter: Column '${filter.column}' not found in table`);
73529
- return null;
73530
- }
73531
- const columnDef = column.columnDef;
73532
- const filterValueAccessor = columnDef?.meta?.filterValueAccessor;
73533
- const filterOptions = columnDef?.meta?.filterOptions;
73534
- const getFilterValue = (row) => {
73535
- if (filterValueAccessor) {
73536
- return filterValueAccessor(row);
73537
- }
73538
- const value = row[filter.column];
73539
- if (value === void 0) {
73540
- const accessor = column.columnDef.accessorKey || column.columnDef.accessorFn;
73541
- if (typeof accessor === "function") {
73542
- return accessor(row);
73543
- } else if (accessor && typeof accessor === "string") {
73544
- const keys2 = accessor.split(".");
73545
- let nestedValue = row;
73546
- for (const key of keys2) {
73547
- nestedValue = nestedValue?.[key];
73548
- if (nestedValue === void 0)
73549
- break;
73550
- }
73551
- return nestedValue;
73552
- }
73513
+ const column = t__default.useMemo(() => {
73514
+ let col = table.getColumn(filter.column);
73515
+ if (!col) {
73516
+ const allCols = table.getAllColumns();
73517
+ col = allCols.find(
73518
+ (c2) => c2.id === filter.column || c2.columnDef.accessorKey === filter.column
73519
+ );
73553
73520
  }
73554
- return value;
73555
- };
73521
+ return col;
73522
+ }, [table, filter.column]);
73556
73523
  const availableOptions = useMemo(() => {
73557
73524
  if (filter.options && filter.options !== "auto") {
73558
73525
  return filter.options;
73559
73526
  }
73560
- if (filterOptions) {
73561
- return filterOptions;
73562
- }
73563
73527
  const uniqueValues = /* @__PURE__ */ new Set();
73564
73528
  data.forEach((row) => {
73565
- const value = getFilterValue(row);
73529
+ let value = row[filter.column];
73530
+ if (value === void 0 && filter.column.includes(".")) {
73531
+ const keys2 = filter.column.split(".");
73532
+ value = row;
73533
+ for (const key of keys2) {
73534
+ value = value?.[key];
73535
+ }
73536
+ }
73566
73537
  if (value != null && value !== "") {
73567
73538
  uniqueValues.add(String(value));
73568
73539
  }
73569
73540
  });
73570
- const options = Array.from(uniqueValues).sort().slice(0, 50);
73571
- if (typeof window !== "undefined" && true) {
73572
- console.log(`QuickFilter Debug [${filter.column}]:`, {
73573
- dataLength: data.length,
73574
- uniqueValues: uniqueValues.size,
73575
- options,
73576
- filterOptions: filter.options,
73577
- sampleData: data.length > 0 ? data[0] : null,
73578
- columnExists: !!column,
73579
- columnDef: column?.columnDef
73580
- });
73581
- }
73582
- return options;
73583
- }, [data, filter.options, filterOptions, filter.column]);
73541
+ return Array.from(uniqueValues).sort();
73542
+ }, [data, filter.column, filter.options]);
73543
+ const filterValue = column?.getFilterValue();
73544
+ const selectedValues = useMemo(() => {
73545
+ if (!filterValue)
73546
+ return /* @__PURE__ */ new Set();
73547
+ if (Array.isArray(filterValue))
73548
+ return new Set(filterValue);
73549
+ return /* @__PURE__ */ new Set([String(filterValue)]);
73550
+ }, [filterValue]);
73584
73551
  const optionCounts = useMemo(() => {
73585
73552
  if (!filter.showCounts)
73586
73553
  return {};
73587
73554
  const counts = {};
73588
- availableOptions.forEach((option) => {
73589
- counts[option] = 0;
73590
- });
73591
73555
  data.forEach((row) => {
73592
- const value = getFilterValue(row);
73593
- if (value != null && counts[String(value)] !== void 0) {
73594
- counts[String(value)]++;
73556
+ let value = row[filter.column];
73557
+ if (value === void 0 && filter.column.includes(".")) {
73558
+ const keys2 = filter.column.split(".");
73559
+ value = row;
73560
+ for (const key of keys2) {
73561
+ value = value?.[key];
73562
+ }
73563
+ }
73564
+ if (value != null && value !== "") {
73565
+ const strValue = String(value);
73566
+ counts[strValue] = (counts[strValue] || 0) + 1;
73595
73567
  }
73596
73568
  });
73597
73569
  return counts;
73598
- }, [data, filter.showCounts, availableOptions]);
73599
- const filterValue = column.getFilterValue();
73600
- const selectedValues = useMemo(() => {
73601
- if (!filterValue)
73602
- return /* @__PURE__ */ new Set();
73603
- if (Array.isArray(filterValue))
73604
- return new Set(filterValue);
73605
- return /* @__PURE__ */ new Set([String(filterValue)]);
73606
- }, [filterValue]);
73607
- const label = filter.label || column.id;
73570
+ }, [data, filter.column, filter.showCounts]);
73608
73571
  const handleSelect = (value) => {
73572
+ if (!column)
73573
+ return;
73609
73574
  if (filter.multi) {
73610
73575
  const newValues = new Set(selectedValues);
73611
73576
  if (newValues.has(value)) {
@@ -73627,9 +73592,10 @@ function DataTableQuickFilter({
73627
73592
  }
73628
73593
  };
73629
73594
  const handleClear = () => {
73630
- column.setFilterValue(void 0);
73595
+ column?.setFilterValue(void 0);
73631
73596
  setSearchValue("");
73632
73597
  };
73598
+ const label = filter.label || filter.column;
73633
73599
  const filteredOptions = useMemo(() => {
73634
73600
  if (!searchValue)
73635
73601
  return availableOptions;
@@ -73637,12 +73603,14 @@ function DataTableQuickFilter({
73637
73603
  (option) => option.toLowerCase().includes(searchValue.toLowerCase())
73638
73604
  );
73639
73605
  }, [availableOptions, searchValue]);
73640
- return /* @__PURE__ */ jsxs(MoonUIPopoverPro, { children: [
73606
+ const isDisabled = !column || availableOptions.length === 0;
73607
+ return /* @__PURE__ */ jsxs(MoonUIPopoverPro, { open, onOpenChange: setOpen, children: [
73641
73608
  /* @__PURE__ */ jsx(MoonUIPopoverTriggerPro, { asChild: true, children: /* @__PURE__ */ jsxs(
73642
73609
  MoonUIButtonPro,
73643
73610
  {
73644
73611
  variant: "outline",
73645
73612
  size: "sm",
73613
+ disabled: isDisabled,
73646
73614
  className: cn(
73647
73615
  "h-8 border-dashed",
73648
73616
  selectedValues.size > 0 && "border-solid"
@@ -73663,51 +73631,57 @@ function DataTableQuickFilter({
73663
73631
  ]
73664
73632
  }
73665
73633
  ) }),
73666
- /* @__PURE__ */ jsx(MoonUIPopoverContentPro, { className: "w-[250px] p-0", align: "start", children: /* @__PURE__ */ jsxs(MoonUICommandPro, { shouldFilter: false, children: [
73667
- /* @__PURE__ */ jsx(
73668
- MoonUICommandInputPro,
73669
- {
73670
- placeholder: `Search ${label.toLowerCase()}...`,
73671
- value: searchValue,
73672
- onValueChange: setSearchValue
73673
- }
73674
- ),
73675
- /* @__PURE__ */ jsx(MoonUICommandListPro, { children: filteredOptions.length === 0 ? /* @__PURE__ */ jsx(MoonUICommandEmptyPro, { children: "No results found" }) : /* @__PURE__ */ jsx(MoonUICommandGroupPro, { children: filteredOptions.map((option) => {
73634
+ /* @__PURE__ */ jsx(MoonUIPopoverContentPro, { className: "w-[250px] p-0", align: "start", children: /* @__PURE__ */ jsxs("div", { className: "p-2", children: [
73635
+ availableOptions.length > 0 && /* @__PURE__ */ jsx("div", { className: "pb-2", children: /* @__PURE__ */ jsxs("div", { className: "relative", children: [
73636
+ /* @__PURE__ */ jsx(Search, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
73637
+ /* @__PURE__ */ jsx(
73638
+ MoonUIInputPro,
73639
+ {
73640
+ placeholder: `Search ${label.toLowerCase()}...`,
73641
+ value: searchValue,
73642
+ onChange: (e) => setSearchValue(e.target.value),
73643
+ className: "h-8 w-full pl-8"
73644
+ }
73645
+ )
73646
+ ] }) }),
73647
+ availableOptions.length === 0 ? /* @__PURE__ */ jsx("div", { className: "text-center text-sm text-muted-foreground py-4", children: "No options available" }) : filteredOptions.length === 0 ? /* @__PURE__ */ jsx("div", { className: "text-center text-sm text-muted-foreground py-4", children: "No results found" }) : /* @__PURE__ */ jsx("div", { className: "space-y-1 max-h-[300px] overflow-y-auto", children: filteredOptions.map((option) => {
73676
73648
  const isSelected = selectedValues.has(option);
73677
73649
  return /* @__PURE__ */ jsxs(
73678
- MoonUICommandItemPro,
73650
+ "button",
73679
73651
  {
73680
- value: option,
73681
- onSelect: () => handleSelect(option),
73652
+ onClick: () => handleSelect(option),
73653
+ className: cn(
73654
+ "flex w-full items-center justify-between rounded px-2 py-1.5 text-sm hover:bg-accent",
73655
+ isSelected && "bg-accent"
73656
+ ),
73682
73657
  children: [
73683
- /* @__PURE__ */ jsx(
73684
- "div",
73685
- {
73686
- className: cn(
73687
- "mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",
73688
- isSelected ? "bg-primary text-primary-foreground" : "opacity-50 [&_svg]:invisible"
73689
- ),
73690
- children: /* @__PURE__ */ jsx(Check, { className: cn("h-4 w-4") })
73691
- }
73692
- ),
73693
- /* @__PURE__ */ jsx("span", { className: "flex-1", children: option }),
73694
- filter.showCounts && optionCounts[option] !== void 0 && /* @__PURE__ */ jsx("span", { className: "ml-auto text-xs text-muted-foreground", children: optionCounts[option] })
73658
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
73659
+ /* @__PURE__ */ jsx(
73660
+ "div",
73661
+ {
73662
+ className: cn(
73663
+ "mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",
73664
+ isSelected ? "bg-primary text-primary-foreground" : "opacity-50 [&_svg]:invisible"
73665
+ ),
73666
+ children: /* @__PURE__ */ jsx(Check, { className: "h-4 w-4" })
73667
+ }
73668
+ ),
73669
+ /* @__PURE__ */ jsx("span", { children: option })
73670
+ ] }),
73671
+ filter.showCounts && optionCounts[option] !== void 0 && /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: optionCounts[option] })
73695
73672
  ]
73696
73673
  },
73697
73674
  option
73698
73675
  );
73699
- }) }) }),
73700
- selectedValues.size > 0 && /* @__PURE__ */ jsx("div", { className: "border-t p-2", children: /* @__PURE__ */ jsxs(
73676
+ }) }),
73677
+ selectedValues.size > 0 && /* @__PURE__ */ jsx("div", { className: "border-t mt-2 pt-2", children: /* @__PURE__ */ jsx(
73701
73678
  MoonUIButtonPro,
73702
73679
  {
73703
73680
  variant: "ghost",
73704
73681
  size: "sm",
73705
73682
  className: "w-full justify-center",
73706
73683
  onClick: handleClear,
73707
- children: [
73708
- /* @__PURE__ */ jsx(X, { className: "mr-2 h-4 w-4" }),
73709
- "Clear filter"
73710
- ]
73684
+ children: "Clear filter"
73711
73685
  }
73712
73686
  ) })
73713
73687
  ] }) })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moontra/moonui-pro",
3
- "version": "2.26.18",
3
+ "version": "2.26.20",
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",