@moontra/moonui-pro 2.25.6 → 2.25.8
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.d.ts +11 -1
- package/dist/index.global.js +140 -132
- package/dist/index.global.js.map +1 -1
- package/dist/index.mjs +471 -5
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { twMerge } from 'tailwind-merge';
|
|
|
4
4
|
import * as t from 'react';
|
|
5
5
|
import t__default, { useState, useMemo, useCallback, useRef, useEffect, forwardRef, createContext, useContext, useLayoutEffect, useDebugValue, Component } from 'react';
|
|
6
6
|
import * as AccordionPrimitive2 from '@radix-ui/react-accordion';
|
|
7
|
-
import { Loader2, Play, ExternalLink, ChevronDown, Info, AlertCircle, AlertTriangle, Check, X, MoreHorizontal, Minus, Clock, ChevronUp, Search, Mic, MicOff, Settings, RefreshCw, Zap, ChevronRight, Crown, Circle, ChevronLeft, Plus, Lock, Sparkles, ZoomOut, ZoomIn, Pause, VolumeX, Volume2, Download, Maximize2, Filter, Image as Image$1, Video, RotateCw, Minimize2, BarChart3, Menu, Bell, CheckCheck, CheckCircle, Palette, User, Settings2, LogOut, Edit3, LayoutGrid, Upload, Share2, Save, Phone, Globe, Eye, CheckCircle2, RotateCcw, Copy, Share, Trash2, CreditCard, XCircle, HelpCircle, Bold as Bold$1, Italic as Italic$1, Underline as Underline$1, Strikethrough, AlignLeft, AlignCenter, AlignRight, AlignJustify, List, ListOrdered, Quote, Code as Code$1, Link as Link$1, Undo, Redo, Edit, GripVertical, Type, Heading1, Heading2, Heading3, CheckSquare, Highlighter, Link2, Table as Table$1, Wand2, Maximize, FileText, Briefcase, MessageSquare, Heart, GraduationCap, Languages, Lightbulb, MoreVertical, TrendingUp, Activity, BellOff, Target, ArrowUpRight, ArrowDownRight, CalendarIcon, MapPin, Navigation, ArrowUp, ArrowDown, ArrowUpDown, Calendar as Calendar$1, DollarSign, Users, Map as Map$1, Music, Archive, File, FileSpreadsheet, FileJson, FileDown, ChevronsLeft, ChevronsRight, Star, Shield, Award, Gem, Flame, Repeat, Move, EyeOff, Timer, Square, Cpu, GitBranch, ArrowRight, Trash, MessageCircle, Paperclip, Printer, TrendingDown, Grip, Unlock, Github, Server, Monitor, MemoryStick, HardDrive, Network, Columns, Pin, Sun, Moon, Send, Tag, Flag, Trophy, GitFork, Package } from 'lucide-react';
|
|
7
|
+
import { Loader2, Play, ExternalLink, ChevronDown, Info, AlertCircle, AlertTriangle, Check, X, MoreHorizontal, Minus, Clock, ChevronUp, Search, Mic, MicOff, Settings, RefreshCw, Zap, ChevronRight, Crown, Circle, ChevronLeft, Plus, Lock, Sparkles, ZoomOut, ZoomIn, Pause, VolumeX, Volume2, Download, Maximize2, Filter, Image as Image$1, Video, RotateCw, Minimize2, BarChart3, Menu, Bell, CheckCheck, CheckCircle, Palette, User, Settings2, LogOut, Edit3, LayoutGrid, Upload, Share2, Save, Phone, Globe, Eye, CheckCircle2, RotateCcw, Copy, Share, Trash2, CreditCard, XCircle, HelpCircle, Bold as Bold$1, Italic as Italic$1, Underline as Underline$1, Strikethrough, AlignLeft, AlignCenter, AlignRight, AlignJustify, List, ListOrdered, Quote, Code as Code$1, Link as Link$1, Undo, Redo, Edit, GripVertical, Type, Heading1, Heading2, Heading3, CheckSquare, Highlighter, Link2, Table as Table$1, Wand2, Maximize, FileText, Briefcase, MessageSquare, Heart, GraduationCap, Languages, Lightbulb, MoreVertical, TrendingUp, Activity, BellOff, Target, ArrowUpRight, ArrowDownRight, CalendarIcon, MapPin, Navigation, ArrowUp, ArrowDown, ArrowUpDown, Calendar as Calendar$1, DollarSign, Users, Map as Map$1, Music, Archive, File, FileSpreadsheet, FileJson, FileDown, ChevronsLeft, ChevronsRight, Star, Shield, Award, Gem, Flame, Repeat, Move, EyeOff, Timer, Square, Cpu, GitBranch, ArrowRight, Trash, MessageCircle, Paperclip, Printer, TrendingDown, Grip, Unlock, Github, Server, Monitor, MemoryStick, HardDrive, Network, Columns, PlusCircle, Pin, Sun, Moon, Send, Tag, Flag, Trophy, GitFork, Package } from 'lucide-react';
|
|
8
8
|
import { cva } from 'class-variance-authority';
|
|
9
9
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
10
10
|
import * as AvatarPrimitive from '@radix-ui/react-avatar';
|
|
@@ -73197,8 +73197,19 @@ function FilterConditionRow({
|
|
|
73197
73197
|
const selectedColumn = columns.find((col) => col.id === filter.column);
|
|
73198
73198
|
const columnDef = selectedColumn?.columnDef;
|
|
73199
73199
|
const columnType = columnDef?.meta?.filterType || "string";
|
|
73200
|
+
const filterOptions = columnDef?.meta?.filterOptions;
|
|
73201
|
+
columnDef?.meta?.filterValueAccessor;
|
|
73200
73202
|
const availableOperators = getOperatorsForColumnType(columnType);
|
|
73201
73203
|
const needsValue = filter.operator !== "isNull" && filter.operator !== "isNotNull";
|
|
73204
|
+
const needsMultiValue = filter.operator === "in" || filter.operator === "notIn";
|
|
73205
|
+
const enumOptions = t__default.useMemo(() => {
|
|
73206
|
+
if (columnType !== "select" && !filterOptions)
|
|
73207
|
+
return null;
|
|
73208
|
+
if (filterOptions) {
|
|
73209
|
+
return filterOptions;
|
|
73210
|
+
}
|
|
73211
|
+
return null;
|
|
73212
|
+
}, [columnType, filterOptions]);
|
|
73202
73213
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-2 p-3 border rounded-lg bg-muted/30", children: [
|
|
73203
73214
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
73204
73215
|
/* @__PURE__ */ jsxs(
|
|
@@ -73208,7 +73219,7 @@ function FilterConditionRow({
|
|
|
73208
73219
|
onValueChange: (value) => onUpdate({ column: value }),
|
|
73209
73220
|
children: [
|
|
73210
73221
|
/* @__PURE__ */ jsx(MoonUISelectTriggerPro, { className: "flex-1", children: /* @__PURE__ */ jsx(MoonUISelectValuePro, {}) }),
|
|
73211
|
-
/* @__PURE__ */ jsx(MoonUISelectContentPro, { children: columns.map((column) => {
|
|
73222
|
+
/* @__PURE__ */ jsx(MoonUISelectContentPro, { style: { zIndex: 1e4 }, children: columns.map((column) => {
|
|
73212
73223
|
const header = column.columnDef.header;
|
|
73213
73224
|
const label = typeof header === "function" ? column.id : header || column.id;
|
|
73214
73225
|
return /* @__PURE__ */ jsx(MoonUISelectItemPro, { value: column.id, children: label }, column.id);
|
|
@@ -73234,7 +73245,7 @@ function FilterConditionRow({
|
|
|
73234
73245
|
onValueChange: (value) => onUpdate({ operator: value }),
|
|
73235
73246
|
children: [
|
|
73236
73247
|
/* @__PURE__ */ jsx(MoonUISelectTriggerPro, { children: /* @__PURE__ */ jsx(MoonUISelectValuePro, {}) }),
|
|
73237
|
-
/* @__PURE__ */ jsx(MoonUISelectContentPro, { children: availableOperators.map((operator2) => /* @__PURE__ */ jsx(MoonUISelectItemPro, { value: operator2, children: operatorLabels[operator2] }, operator2)) })
|
|
73248
|
+
/* @__PURE__ */ jsx(MoonUISelectContentPro, { style: { zIndex: 1e4 }, children: availableOperators.map((operator2) => /* @__PURE__ */ jsx(MoonUISelectItemPro, { value: operator2, children: operatorLabels[operator2] }, operator2)) })
|
|
73238
73249
|
]
|
|
73239
73250
|
}
|
|
73240
73251
|
),
|
|
@@ -73245,12 +73256,56 @@ function FilterConditionRow({
|
|
|
73245
73256
|
onValueChange: (value) => onUpdate({ value: value === "true" }),
|
|
73246
73257
|
children: [
|
|
73247
73258
|
/* @__PURE__ */ jsx(MoonUISelectTriggerPro, { children: /* @__PURE__ */ jsx(MoonUISelectValuePro, {}) }),
|
|
73248
|
-
/* @__PURE__ */ jsxs(MoonUISelectContentPro, { children: [
|
|
73259
|
+
/* @__PURE__ */ jsxs(MoonUISelectContentPro, { style: { zIndex: 1e4 }, children: [
|
|
73249
73260
|
/* @__PURE__ */ jsx(MoonUISelectItemPro, { value: "true", children: "True" }),
|
|
73250
73261
|
/* @__PURE__ */ jsx(MoonUISelectItemPro, { value: "false", children: "False" })
|
|
73251
73262
|
] })
|
|
73252
73263
|
]
|
|
73253
73264
|
}
|
|
73265
|
+
) : (columnType === "select" || enumOptions) && !needsMultiValue ? (
|
|
73266
|
+
// Single select dropdown for enum values
|
|
73267
|
+
/* @__PURE__ */ jsxs(
|
|
73268
|
+
MoonUISelectPro,
|
|
73269
|
+
{
|
|
73270
|
+
value: filter.value || "",
|
|
73271
|
+
onValueChange: (value) => onUpdate({ value }),
|
|
73272
|
+
children: [
|
|
73273
|
+
/* @__PURE__ */ jsx(MoonUISelectTriggerPro, { children: /* @__PURE__ */ jsx(MoonUISelectValuePro, { placeholder: "Select value..." }) }),
|
|
73274
|
+
/* @__PURE__ */ jsx(MoonUISelectContentPro, { style: { zIndex: 1e4 }, children: enumOptions?.map((option) => /* @__PURE__ */ jsx(MoonUISelectItemPro, { value: option, children: option }, option)) })
|
|
73275
|
+
]
|
|
73276
|
+
}
|
|
73277
|
+
)
|
|
73278
|
+
) : (columnType === "select" || enumOptions) && needsMultiValue ? (
|
|
73279
|
+
// Multi-select for 'in' and 'notIn' operators
|
|
73280
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
|
|
73281
|
+
/* @__PURE__ */ jsx("div", { className: "text-xs text-muted-foreground", children: "Select multiple values:" }),
|
|
73282
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-1 max-h-32 overflow-y-auto border rounded-md p-2", children: enumOptions?.map((option) => {
|
|
73283
|
+
const values = Array.isArray(filter.value) ? filter.value : [];
|
|
73284
|
+
const isSelected = values.includes(option);
|
|
73285
|
+
return /* @__PURE__ */ jsxs(
|
|
73286
|
+
"label",
|
|
73287
|
+
{
|
|
73288
|
+
className: "flex items-center gap-2 cursor-pointer hover:bg-muted/50 p-1 rounded",
|
|
73289
|
+
children: [
|
|
73290
|
+
/* @__PURE__ */ jsx(
|
|
73291
|
+
"input",
|
|
73292
|
+
{
|
|
73293
|
+
type: "checkbox",
|
|
73294
|
+
checked: isSelected,
|
|
73295
|
+
onChange: (e) => {
|
|
73296
|
+
const newValues = e.target.checked ? [...values, option] : values.filter((v) => v !== option);
|
|
73297
|
+
onUpdate({ value: newValues });
|
|
73298
|
+
},
|
|
73299
|
+
className: "rounded border-gray-300"
|
|
73300
|
+
}
|
|
73301
|
+
),
|
|
73302
|
+
/* @__PURE__ */ jsx("span", { className: "text-sm", children: option })
|
|
73303
|
+
]
|
|
73304
|
+
},
|
|
73305
|
+
option
|
|
73306
|
+
);
|
|
73307
|
+
}) })
|
|
73308
|
+
] })
|
|
73254
73309
|
) : columnType === "number" ? /* @__PURE__ */ jsx(
|
|
73255
73310
|
MoonUIInputPro,
|
|
73256
73311
|
{
|
|
@@ -73259,6 +73314,16 @@ function FilterConditionRow({
|
|
|
73259
73314
|
onChange: (e) => onUpdate({ value: e.target.value }),
|
|
73260
73315
|
placeholder: "Enter value..."
|
|
73261
73316
|
}
|
|
73317
|
+
) : needsMultiValue ? (
|
|
73318
|
+
// Text input for comma-separated values
|
|
73319
|
+
/* @__PURE__ */ jsx(
|
|
73320
|
+
MoonUIInputPro,
|
|
73321
|
+
{
|
|
73322
|
+
value: Array.isArray(filter.value) ? filter.value.join(", ") : filter.value || "",
|
|
73323
|
+
onChange: (e) => onUpdate({ value: e.target.value }),
|
|
73324
|
+
placeholder: "Enter values separated by comma..."
|
|
73325
|
+
}
|
|
73326
|
+
)
|
|
73262
73327
|
) : /* @__PURE__ */ jsx(
|
|
73263
73328
|
MoonUIInputPro,
|
|
73264
73329
|
{
|
|
@@ -73269,6 +73334,366 @@ function FilterConditionRow({
|
|
|
73269
73334
|
) })
|
|
73270
73335
|
] });
|
|
73271
73336
|
}
|
|
73337
|
+
function DataTableQuickFilter({
|
|
73338
|
+
table,
|
|
73339
|
+
filter,
|
|
73340
|
+
data
|
|
73341
|
+
}) {
|
|
73342
|
+
const column = table.getColumn(filter.column);
|
|
73343
|
+
if (!column) {
|
|
73344
|
+
return null;
|
|
73345
|
+
}
|
|
73346
|
+
const columnDef = column.columnDef;
|
|
73347
|
+
const filterValueAccessor = columnDef?.meta?.filterValueAccessor;
|
|
73348
|
+
const filterOptions = columnDef?.meta?.filterOptions;
|
|
73349
|
+
const getFilterValue = (row) => {
|
|
73350
|
+
if (filterValueAccessor) {
|
|
73351
|
+
return filterValueAccessor(row);
|
|
73352
|
+
}
|
|
73353
|
+
const value = row[filter.column];
|
|
73354
|
+
return value;
|
|
73355
|
+
};
|
|
73356
|
+
const availableOptions = useMemo(() => {
|
|
73357
|
+
if (filter.options && filter.options !== "auto") {
|
|
73358
|
+
return filter.options;
|
|
73359
|
+
}
|
|
73360
|
+
if (filterOptions) {
|
|
73361
|
+
return filterOptions;
|
|
73362
|
+
}
|
|
73363
|
+
const uniqueValues = /* @__PURE__ */ new Set();
|
|
73364
|
+
data.forEach((row) => {
|
|
73365
|
+
const value = getFilterValue(row);
|
|
73366
|
+
if (value != null && value !== "") {
|
|
73367
|
+
uniqueValues.add(String(value));
|
|
73368
|
+
}
|
|
73369
|
+
});
|
|
73370
|
+
return Array.from(uniqueValues).sort().slice(0, 50);
|
|
73371
|
+
}, [data, filter.options, filterOptions]);
|
|
73372
|
+
const optionCounts = useMemo(() => {
|
|
73373
|
+
if (!filter.showCounts)
|
|
73374
|
+
return {};
|
|
73375
|
+
const counts = {};
|
|
73376
|
+
availableOptions.forEach((option) => {
|
|
73377
|
+
counts[option] = 0;
|
|
73378
|
+
});
|
|
73379
|
+
data.forEach((row) => {
|
|
73380
|
+
const value = getFilterValue(row);
|
|
73381
|
+
if (value != null && counts[String(value)] !== void 0) {
|
|
73382
|
+
counts[String(value)]++;
|
|
73383
|
+
}
|
|
73384
|
+
});
|
|
73385
|
+
return counts;
|
|
73386
|
+
}, [data, filter.showCounts, availableOptions]);
|
|
73387
|
+
const filterValue = column.getFilterValue();
|
|
73388
|
+
const selectedValues = useMemo(() => {
|
|
73389
|
+
if (!filterValue)
|
|
73390
|
+
return /* @__PURE__ */ new Set();
|
|
73391
|
+
if (Array.isArray(filterValue))
|
|
73392
|
+
return new Set(filterValue);
|
|
73393
|
+
return /* @__PURE__ */ new Set([String(filterValue)]);
|
|
73394
|
+
}, [filterValue]);
|
|
73395
|
+
const label = filter.label || column.id;
|
|
73396
|
+
const handleSelect = (value) => {
|
|
73397
|
+
if (filter.multi) {
|
|
73398
|
+
const newValues = new Set(selectedValues);
|
|
73399
|
+
if (newValues.has(value)) {
|
|
73400
|
+
newValues.delete(value);
|
|
73401
|
+
} else {
|
|
73402
|
+
newValues.add(value);
|
|
73403
|
+
}
|
|
73404
|
+
if (newValues.size === 0) {
|
|
73405
|
+
column.setFilterValue(void 0);
|
|
73406
|
+
} else {
|
|
73407
|
+
column.setFilterValue(Array.from(newValues));
|
|
73408
|
+
}
|
|
73409
|
+
} else {
|
|
73410
|
+
if (selectedValues.has(value)) {
|
|
73411
|
+
column.setFilterValue(void 0);
|
|
73412
|
+
} else {
|
|
73413
|
+
column.setFilterValue(value);
|
|
73414
|
+
}
|
|
73415
|
+
}
|
|
73416
|
+
};
|
|
73417
|
+
const handleClear = () => {
|
|
73418
|
+
column.setFilterValue(void 0);
|
|
73419
|
+
};
|
|
73420
|
+
return /* @__PURE__ */ jsxs(MoonUIPopoverPro, { children: [
|
|
73421
|
+
/* @__PURE__ */ jsx(MoonUIPopoverTriggerPro, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
73422
|
+
MoonUIButtonPro,
|
|
73423
|
+
{
|
|
73424
|
+
variant: "outline",
|
|
73425
|
+
size: "sm",
|
|
73426
|
+
className: cn(
|
|
73427
|
+
"h-8 border-dashed",
|
|
73428
|
+
selectedValues.size > 0 && "border-solid"
|
|
73429
|
+
),
|
|
73430
|
+
children: [
|
|
73431
|
+
label,
|
|
73432
|
+
selectedValues.size > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
73433
|
+
/* @__PURE__ */ jsx("span", { className: "mx-2 h-4 w-px bg-border" }),
|
|
73434
|
+
/* @__PURE__ */ jsx(
|
|
73435
|
+
MoonUIBadgePro,
|
|
73436
|
+
{
|
|
73437
|
+
variant: "secondary",
|
|
73438
|
+
className: "rounded-sm px-1 font-normal",
|
|
73439
|
+
children: selectedValues.size
|
|
73440
|
+
}
|
|
73441
|
+
)
|
|
73442
|
+
] })
|
|
73443
|
+
]
|
|
73444
|
+
}
|
|
73445
|
+
) }),
|
|
73446
|
+
/* @__PURE__ */ jsx(MoonUIPopoverContentPro, { className: "w-[250px] p-0", align: "start", children: /* @__PURE__ */ jsxs(MoonUICommandPro, { children: [
|
|
73447
|
+
/* @__PURE__ */ jsx(MoonUICommandInputPro, { placeholder: `Search ${label.toLowerCase()}...` }),
|
|
73448
|
+
/* @__PURE__ */ jsxs(MoonUICommandListPro, { children: [
|
|
73449
|
+
/* @__PURE__ */ jsx(MoonUICommandEmptyPro, { children: "No results found." }),
|
|
73450
|
+
/* @__PURE__ */ jsx(MoonUICommandGroupPro, { children: availableOptions.map((option) => {
|
|
73451
|
+
const isSelected = selectedValues.has(option);
|
|
73452
|
+
return /* @__PURE__ */ jsxs(
|
|
73453
|
+
MoonUICommandItemPro,
|
|
73454
|
+
{
|
|
73455
|
+
onSelect: () => handleSelect(option),
|
|
73456
|
+
children: [
|
|
73457
|
+
/* @__PURE__ */ jsx(
|
|
73458
|
+
"div",
|
|
73459
|
+
{
|
|
73460
|
+
className: cn(
|
|
73461
|
+
"mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",
|
|
73462
|
+
isSelected ? "bg-primary text-primary-foreground" : "opacity-50 [&_svg]:invisible"
|
|
73463
|
+
),
|
|
73464
|
+
children: /* @__PURE__ */ jsx(Check, { className: cn("h-4 w-4") })
|
|
73465
|
+
}
|
|
73466
|
+
),
|
|
73467
|
+
/* @__PURE__ */ jsx("span", { className: "flex-1", children: option }),
|
|
73468
|
+
filter.showCounts && optionCounts[option] !== void 0 && /* @__PURE__ */ jsx("span", { className: "ml-auto text-xs text-muted-foreground", children: optionCounts[option] })
|
|
73469
|
+
]
|
|
73470
|
+
},
|
|
73471
|
+
option
|
|
73472
|
+
);
|
|
73473
|
+
}) })
|
|
73474
|
+
] }),
|
|
73475
|
+
selectedValues.size > 0 && /* @__PURE__ */ jsx("div", { className: "border-t p-2", children: /* @__PURE__ */ jsxs(
|
|
73476
|
+
MoonUIButtonPro,
|
|
73477
|
+
{
|
|
73478
|
+
variant: "ghost",
|
|
73479
|
+
size: "sm",
|
|
73480
|
+
className: "w-full justify-center",
|
|
73481
|
+
onClick: handleClear,
|
|
73482
|
+
children: [
|
|
73483
|
+
/* @__PURE__ */ jsx(X, { className: "mr-2 h-4 w-4" }),
|
|
73484
|
+
"Clear filter"
|
|
73485
|
+
]
|
|
73486
|
+
}
|
|
73487
|
+
) })
|
|
73488
|
+
] }) })
|
|
73489
|
+
] });
|
|
73490
|
+
}
|
|
73491
|
+
function DataTableFacetedFilter({
|
|
73492
|
+
table,
|
|
73493
|
+
column: columnId,
|
|
73494
|
+
title,
|
|
73495
|
+
options = "auto",
|
|
73496
|
+
data
|
|
73497
|
+
}) {
|
|
73498
|
+
const column = table.getColumn(columnId);
|
|
73499
|
+
const [searchQuery, setSearchQuery] = useState("");
|
|
73500
|
+
if (!column) {
|
|
73501
|
+
return null;
|
|
73502
|
+
}
|
|
73503
|
+
const columnDef = column.columnDef;
|
|
73504
|
+
const filterValueAccessor = columnDef?.meta?.filterValueAccessor;
|
|
73505
|
+
const filterOptions = columnDef?.meta?.filterOptions;
|
|
73506
|
+
const getFilterValue = (row) => {
|
|
73507
|
+
if (filterValueAccessor) {
|
|
73508
|
+
return filterValueAccessor(row);
|
|
73509
|
+
}
|
|
73510
|
+
const value = row[columnId];
|
|
73511
|
+
return value;
|
|
73512
|
+
};
|
|
73513
|
+
const { availableOptions, optionCounts } = useMemo(() => {
|
|
73514
|
+
const counts = {};
|
|
73515
|
+
const uniqueValues = /* @__PURE__ */ new Set();
|
|
73516
|
+
data.forEach((row) => {
|
|
73517
|
+
const value = getFilterValue(row);
|
|
73518
|
+
if (value != null && value !== "") {
|
|
73519
|
+
const strValue = String(value);
|
|
73520
|
+
uniqueValues.add(strValue);
|
|
73521
|
+
counts[strValue] = (counts[strValue] || 0) + 1;
|
|
73522
|
+
}
|
|
73523
|
+
});
|
|
73524
|
+
let finalOptions = [];
|
|
73525
|
+
if (options !== "auto") {
|
|
73526
|
+
finalOptions = options;
|
|
73527
|
+
} else if (filterOptions) {
|
|
73528
|
+
finalOptions = filterOptions.map((opt) => ({ value: opt, label: opt }));
|
|
73529
|
+
} else {
|
|
73530
|
+
finalOptions = Array.from(uniqueValues).sort().slice(0, 50).map((value) => ({ value, label: value }));
|
|
73531
|
+
}
|
|
73532
|
+
return { availableOptions: finalOptions, optionCounts: counts };
|
|
73533
|
+
}, [data, options, filterOptions]);
|
|
73534
|
+
const filterValue = column.getFilterValue();
|
|
73535
|
+
const selectedValues = new Set(filterValue || []);
|
|
73536
|
+
const filteredOptions = useMemo(() => {
|
|
73537
|
+
if (!searchQuery)
|
|
73538
|
+
return availableOptions;
|
|
73539
|
+
return availableOptions.filter((option) => {
|
|
73540
|
+
const label = option.label || option.value;
|
|
73541
|
+
return label.toLowerCase().includes(searchQuery.toLowerCase());
|
|
73542
|
+
});
|
|
73543
|
+
}, [availableOptions, searchQuery]);
|
|
73544
|
+
const displayTitle = title || columnId;
|
|
73545
|
+
const handleSelect = (value) => {
|
|
73546
|
+
const newValues = new Set(selectedValues);
|
|
73547
|
+
if (newValues.has(value)) {
|
|
73548
|
+
newValues.delete(value);
|
|
73549
|
+
} else {
|
|
73550
|
+
newValues.add(value);
|
|
73551
|
+
}
|
|
73552
|
+
if (newValues.size === 0) {
|
|
73553
|
+
column.setFilterValue(void 0);
|
|
73554
|
+
} else {
|
|
73555
|
+
column.setFilterValue(Array.from(newValues));
|
|
73556
|
+
}
|
|
73557
|
+
};
|
|
73558
|
+
const handleClearAll = () => {
|
|
73559
|
+
column.setFilterValue(void 0);
|
|
73560
|
+
setSearchQuery("");
|
|
73561
|
+
};
|
|
73562
|
+
const handleSelectAll = () => {
|
|
73563
|
+
const allValues = filteredOptions.map((opt) => opt.value);
|
|
73564
|
+
column.setFilterValue(allValues);
|
|
73565
|
+
};
|
|
73566
|
+
return /* @__PURE__ */ jsxs(MoonUIPopoverPro, { children: [
|
|
73567
|
+
/* @__PURE__ */ jsx(MoonUIPopoverTriggerPro, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
73568
|
+
MoonUIButtonPro,
|
|
73569
|
+
{
|
|
73570
|
+
variant: "outline",
|
|
73571
|
+
size: "sm",
|
|
73572
|
+
className: cn(
|
|
73573
|
+
"h-8 border-dashed",
|
|
73574
|
+
selectedValues.size > 0 && "border-solid"
|
|
73575
|
+
),
|
|
73576
|
+
children: [
|
|
73577
|
+
/* @__PURE__ */ jsx(PlusCircle, { className: "mr-2 h-4 w-4" }),
|
|
73578
|
+
displayTitle,
|
|
73579
|
+
selectedValues.size > 0 && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
73580
|
+
/* @__PURE__ */ jsx(MoonUISeparatorPro, { orientation: "vertical", className: "mx-2 h-4" }),
|
|
73581
|
+
/* @__PURE__ */ jsx(
|
|
73582
|
+
MoonUIBadgePro,
|
|
73583
|
+
{
|
|
73584
|
+
variant: "secondary",
|
|
73585
|
+
className: "rounded-sm px-1 font-normal lg:hidden",
|
|
73586
|
+
children: selectedValues.size
|
|
73587
|
+
}
|
|
73588
|
+
),
|
|
73589
|
+
/* @__PURE__ */ jsx("div", { className: "hidden space-x-1 lg:flex", children: selectedValues.size > 2 ? /* @__PURE__ */ jsxs(
|
|
73590
|
+
MoonUIBadgePro,
|
|
73591
|
+
{
|
|
73592
|
+
variant: "secondary",
|
|
73593
|
+
className: "rounded-sm px-1 font-normal",
|
|
73594
|
+
children: [
|
|
73595
|
+
selectedValues.size,
|
|
73596
|
+
" selected"
|
|
73597
|
+
]
|
|
73598
|
+
}
|
|
73599
|
+
) : Array.from(selectedValues).slice(0, 2).map((value) => {
|
|
73600
|
+
const option = availableOptions.find((opt) => opt.value === value);
|
|
73601
|
+
return /* @__PURE__ */ jsx(
|
|
73602
|
+
MoonUIBadgePro,
|
|
73603
|
+
{
|
|
73604
|
+
variant: "secondary",
|
|
73605
|
+
className: "rounded-sm px-1 font-normal",
|
|
73606
|
+
children: option?.label || value
|
|
73607
|
+
},
|
|
73608
|
+
value
|
|
73609
|
+
);
|
|
73610
|
+
}) })
|
|
73611
|
+
] })
|
|
73612
|
+
]
|
|
73613
|
+
}
|
|
73614
|
+
) }),
|
|
73615
|
+
/* @__PURE__ */ jsxs(MoonUIPopoverContentPro, { className: "w-[300px] p-0", align: "start", children: [
|
|
73616
|
+
/* @__PURE__ */ jsx("div", { className: "p-3", children: /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
73617
|
+
/* @__PURE__ */ jsx(Search, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
|
|
73618
|
+
/* @__PURE__ */ jsx(
|
|
73619
|
+
MoonUIInputPro,
|
|
73620
|
+
{
|
|
73621
|
+
placeholder: `Search ${displayTitle.toLowerCase()}...`,
|
|
73622
|
+
value: searchQuery,
|
|
73623
|
+
onChange: (e) => setSearchQuery(e.target.value),
|
|
73624
|
+
className: "h-8 pl-8"
|
|
73625
|
+
}
|
|
73626
|
+
)
|
|
73627
|
+
] }) }),
|
|
73628
|
+
/* @__PURE__ */ jsx(MoonUISeparatorPro, {}),
|
|
73629
|
+
/* @__PURE__ */ jsx("div", { className: "max-h-[300px] overflow-y-auto", children: filteredOptions.length === 0 ? /* @__PURE__ */ jsx("div", { className: "p-4 text-center text-sm text-muted-foreground", children: "No results found" }) : /* @__PURE__ */ jsx("div", { className: "p-2", children: filteredOptions.map((option) => {
|
|
73630
|
+
const isSelected = selectedValues.has(option.value);
|
|
73631
|
+
const count4 = optionCounts[option.value] || 0;
|
|
73632
|
+
return /* @__PURE__ */ jsxs(
|
|
73633
|
+
MoonUIButtonPro,
|
|
73634
|
+
{
|
|
73635
|
+
variant: "ghost",
|
|
73636
|
+
size: "sm",
|
|
73637
|
+
className: "w-full justify-start font-normal",
|
|
73638
|
+
onClick: () => handleSelect(option.value),
|
|
73639
|
+
children: [
|
|
73640
|
+
/* @__PURE__ */ jsx(
|
|
73641
|
+
"div",
|
|
73642
|
+
{
|
|
73643
|
+
className: cn(
|
|
73644
|
+
"mr-2 flex h-4 w-4 items-center justify-center rounded-sm border border-primary",
|
|
73645
|
+
isSelected ? "bg-primary text-primary-foreground" : "opacity-50 [&_svg]:invisible"
|
|
73646
|
+
),
|
|
73647
|
+
children: /* @__PURE__ */ jsx(Check, { className: cn("h-4 w-4") })
|
|
73648
|
+
}
|
|
73649
|
+
),
|
|
73650
|
+
option.icon && /* @__PURE__ */ jsx("span", { className: "mr-2", children: option.icon }),
|
|
73651
|
+
/* @__PURE__ */ jsx("span", { className: "flex-1 text-left", children: option.label || option.value }),
|
|
73652
|
+
count4 > 0 && /* @__PURE__ */ jsx("span", { className: "ml-auto text-xs text-muted-foreground", children: count4 })
|
|
73653
|
+
]
|
|
73654
|
+
},
|
|
73655
|
+
option.value
|
|
73656
|
+
);
|
|
73657
|
+
}) }) }),
|
|
73658
|
+
(selectedValues.size > 0 || filteredOptions.length > 0) && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
73659
|
+
/* @__PURE__ */ jsx(MoonUISeparatorPro, {}),
|
|
73660
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between p-2", children: [
|
|
73661
|
+
selectedValues.size > 0 ? /* @__PURE__ */ jsxs(
|
|
73662
|
+
MoonUIButtonPro,
|
|
73663
|
+
{
|
|
73664
|
+
variant: "ghost",
|
|
73665
|
+
size: "sm",
|
|
73666
|
+
onClick: handleClearAll,
|
|
73667
|
+
className: "h-8 px-2 lg:px-3",
|
|
73668
|
+
children: [
|
|
73669
|
+
"Clear",
|
|
73670
|
+
/* @__PURE__ */ jsx(X, { className: "ml-2 h-4 w-4" })
|
|
73671
|
+
]
|
|
73672
|
+
}
|
|
73673
|
+
) : /* @__PURE__ */ jsxs(
|
|
73674
|
+
MoonUIButtonPro,
|
|
73675
|
+
{
|
|
73676
|
+
variant: "ghost",
|
|
73677
|
+
size: "sm",
|
|
73678
|
+
onClick: handleSelectAll,
|
|
73679
|
+
className: "h-8 px-2 lg:px-3",
|
|
73680
|
+
children: [
|
|
73681
|
+
"Select all",
|
|
73682
|
+
/* @__PURE__ */ jsx(Check, { className: "ml-2 h-4 w-4" })
|
|
73683
|
+
]
|
|
73684
|
+
}
|
|
73685
|
+
),
|
|
73686
|
+
/* @__PURE__ */ jsxs("span", { className: "text-xs text-muted-foreground", children: [
|
|
73687
|
+
selectedValues.size,
|
|
73688
|
+
" of ",
|
|
73689
|
+
availableOptions.length,
|
|
73690
|
+
" selected"
|
|
73691
|
+
] })
|
|
73692
|
+
] })
|
|
73693
|
+
] })
|
|
73694
|
+
] })
|
|
73695
|
+
] });
|
|
73696
|
+
}
|
|
73272
73697
|
function DataTable({
|
|
73273
73698
|
columns: originalColumns,
|
|
73274
73699
|
data,
|
|
@@ -73286,6 +73711,8 @@ function DataTable({
|
|
|
73286
73711
|
expandedRows: controlledExpandedRows,
|
|
73287
73712
|
onRowExpandChange,
|
|
73288
73713
|
bulkActions = [],
|
|
73714
|
+
quickFilters = [],
|
|
73715
|
+
facetedFilters = [],
|
|
73289
73716
|
features = {},
|
|
73290
73717
|
theme = {},
|
|
73291
73718
|
texts = {},
|
|
@@ -73381,12 +73808,29 @@ function DataTable({
|
|
|
73381
73808
|
globalFilterFn: "includesString",
|
|
73382
73809
|
filterFns: {
|
|
73383
73810
|
custom: (row, columnId, filterValue) => {
|
|
73811
|
+
if (Array.isArray(filterValue)) {
|
|
73812
|
+
const column = table.getColumn(columnId);
|
|
73813
|
+
const columnDef = column?.columnDef;
|
|
73814
|
+
const filterValueAccessor = columnDef?.meta?.filterValueAccessor;
|
|
73815
|
+
const cellValue = filterValueAccessor ? filterValueAccessor(row.original) : row.getValue(columnId);
|
|
73816
|
+
return filterValue.includes(String(cellValue));
|
|
73817
|
+
}
|
|
73818
|
+
if (typeof filterValue === "string" || typeof filterValue === "number" || typeof filterValue === "boolean") {
|
|
73819
|
+
const column = table.getColumn(columnId);
|
|
73820
|
+
const columnDef = column?.columnDef;
|
|
73821
|
+
const filterValueAccessor = columnDef?.meta?.filterValueAccessor;
|
|
73822
|
+
const cellValue = filterValueAccessor ? filterValueAccessor(row.original) : row.getValue(columnId);
|
|
73823
|
+
return String(cellValue) === String(filterValue);
|
|
73824
|
+
}
|
|
73384
73825
|
if (!filterValue?.custom || !filterValue?.filters)
|
|
73385
73826
|
return true;
|
|
73386
73827
|
const filters = filterValue.filters;
|
|
73387
73828
|
const matchAll = filterValue.matchAll !== void 0 ? filterValue.matchAll : true;
|
|
73388
73829
|
const allFilterResults = filters.map((filterCondition) => {
|
|
73389
|
-
const
|
|
73830
|
+
const column = table.getColumn(filterCondition.column);
|
|
73831
|
+
const columnDef = column?.columnDef;
|
|
73832
|
+
const filterValueAccessor = columnDef?.meta?.filterValueAccessor;
|
|
73833
|
+
const cellValue = filterValueAccessor ? filterValueAccessor(row.original) : row.getValue(filterCondition.column);
|
|
73390
73834
|
const filterVal = filterCondition.value;
|
|
73391
73835
|
switch (filterCondition.operator) {
|
|
73392
73836
|
case "equals":
|
|
@@ -73409,6 +73853,10 @@ function DataTable({
|
|
|
73409
73853
|
return Number(cellValue) >= Number(filterVal);
|
|
73410
73854
|
case "lessThanOrEqual":
|
|
73411
73855
|
return Number(cellValue) <= Number(filterVal);
|
|
73856
|
+
case "in":
|
|
73857
|
+
return Array.isArray(filterVal) ? filterVal.includes(cellValue) : String(filterVal).split(",").map((v) => v.trim()).includes(String(cellValue));
|
|
73858
|
+
case "notIn":
|
|
73859
|
+
return Array.isArray(filterVal) ? !filterVal.includes(cellValue) : !String(filterVal).split(",").map((v) => v.trim()).includes(String(cellValue));
|
|
73412
73860
|
case "isNull":
|
|
73413
73861
|
return cellValue == null || cellValue === "";
|
|
73414
73862
|
case "isNotNull":
|
|
@@ -73519,6 +73967,24 @@ function DataTable({
|
|
|
73519
73967
|
}
|
|
73520
73968
|
)
|
|
73521
73969
|
] }),
|
|
73970
|
+
quickFilters.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: quickFilters.map((filter, index2) => /* @__PURE__ */ jsx(
|
|
73971
|
+
DataTableQuickFilter,
|
|
73972
|
+
{
|
|
73973
|
+
table,
|
|
73974
|
+
filter,
|
|
73975
|
+
data
|
|
73976
|
+
},
|
|
73977
|
+
`quick-${filter.column}-${index2}`
|
|
73978
|
+
)) }),
|
|
73979
|
+
facetedFilters.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: facetedFilters.map((columnId) => /* @__PURE__ */ jsx(
|
|
73980
|
+
DataTableFacetedFilter,
|
|
73981
|
+
{
|
|
73982
|
+
table,
|
|
73983
|
+
column: columnId,
|
|
73984
|
+
data
|
|
73985
|
+
},
|
|
73986
|
+
`faceted-${columnId}`
|
|
73987
|
+
)) }),
|
|
73522
73988
|
filterable && /* @__PURE__ */ jsxs(
|
|
73523
73989
|
MoonUIButtonPro,
|
|
73524
73990
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moontra/moonui-pro",
|
|
3
|
-
"version": "2.25.
|
|
3
|
+
"version": "2.25.8",
|
|
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",
|