@mlw-packages/react-components 1.10.15 → 1.10.17

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.js CHANGED
@@ -38,12 +38,12 @@ var ContextMenuPrimitive = require('@radix-ui/react-context-menu');
38
38
  var reactSyntaxHighlighter = require('react-syntax-highlighter');
39
39
  var dateFns = require('date-fns');
40
40
  var locale = require('date-fns/locale');
41
- var ptBR3 = require('date-fns/locale/pt-BR');
42
41
  var core = require('@dnd-kit/core');
43
42
  var utilities = require('@dnd-kit/utilities');
44
43
  var reactRadioGroup = require('@radix-ui/react-radio-group');
45
44
  var recharts = require('recharts');
46
45
  var useEmblaCarousel = require('embla-carousel-react');
46
+ var reactVirtual = require('@tanstack/react-virtual');
47
47
 
48
48
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
49
49
 
@@ -84,7 +84,6 @@ var SeparatorPrimitive__namespace = /*#__PURE__*/_interopNamespace(SeparatorPrim
84
84
  var TabsPrimitive__namespace = /*#__PURE__*/_interopNamespace(TabsPrimitive);
85
85
  var NavigationMenuPrimitive__namespace = /*#__PURE__*/_interopNamespace(NavigationMenuPrimitive);
86
86
  var ContextMenuPrimitive__namespace = /*#__PURE__*/_interopNamespace(ContextMenuPrimitive);
87
- var ptBR3__default = /*#__PURE__*/_interopDefault(ptBR3);
88
87
  var useEmblaCarousel__default = /*#__PURE__*/_interopDefault(useEmblaCarousel);
89
88
 
90
89
  var __create = Object.create;
@@ -2556,7 +2555,7 @@ function Combobox({
2556
2555
  ] });
2557
2556
  }
2558
2557
  var badgeVariants = classVarianceAuthority.cva(
2559
- "inline-flex items-center justify-center rounded-md border text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",
2558
+ "inline-flex items-center justify-center rounded-md border text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden border-border",
2560
2559
  {
2561
2560
  variants: {
2562
2561
  size: {
@@ -8131,7 +8130,6 @@ function DateTimePicker({
8131
8130
  ] })
8132
8131
  ] });
8133
8132
  }
8134
- var dateFnsLocale = ptBR3__default.default?.default ?? ptBR3__default.default;
8135
8133
  function RangePicker({
8136
8134
  value,
8137
8135
  onChange,
@@ -8186,8 +8184,8 @@ function RangePicker({
8186
8184
  !range && "text-muted-foreground"
8187
8185
  ),
8188
8186
  children: range?.from && range?.to ? `${dateFns.format(range.from, "P", {
8189
- locale: dateFnsLocale
8190
- })} - ${dateFns.format(range.to, "P", { locale: dateFnsLocale })}` : "Selecione um intervalo"
8187
+ locale: locale.ptBR
8188
+ })} - ${dateFns.format(range.to, "P", { locale: locale.ptBR })}` : "Selecione um intervalo"
8191
8189
  }
8192
8190
  ),
8193
8191
  /* @__PURE__ */ jsxRuntime.jsx(framerMotion.motion.span, { className: "flex items-center", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-row gap-0 items-center ", children: [
@@ -8247,7 +8245,7 @@ function RangePicker({
8247
8245
  mode: "range",
8248
8246
  selected: range,
8249
8247
  onSelect: handleSelect,
8250
- locale: dateFnsLocale,
8248
+ locale: locale.ptBR,
8251
8249
  showOutsideDays: true,
8252
8250
  fixedWeeks: true,
8253
8251
  weekStartsOn: 1,
@@ -17712,15 +17710,10 @@ var renderInsideBarLabel = (color, valueFormatter) => {
17712
17710
  };
17713
17711
  };
17714
17712
 
17715
- // src/utils/calcDivision.ts
17716
- var calcDivision = (dividend, divisor) => {
17717
- return dividend / divisor;
17718
- };
17719
-
17720
17713
  // src/components/ui/charts/utils/formatters.ts
17721
17714
  function formatLinePercentage(value) {
17722
17715
  const numValue = typeof value === "number" ? value : typeof value === "string" ? parseFloat(value) : 0;
17723
- const percentage = calcDivision(numValue, 100);
17716
+ const percentage = numValue;
17724
17717
  const formattedPercentage = typeof percentage === "number" ? percentage.toFixed(1).replace(".", ",") : String(percentage).replace(".", ",");
17725
17718
  return `${formattedPercentage}%`;
17726
17719
  }
@@ -21523,6 +21516,676 @@ function processIntegrationData(integrations, targetSystemName) {
21523
21516
  connections
21524
21517
  };
21525
21518
  }
21519
+ function normalizeStr(s) {
21520
+ return s.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g, "");
21521
+ }
21522
+ function scoreMatch(item, query) {
21523
+ const q = normalizeStr(query);
21524
+ const label = normalizeStr(item.label);
21525
+ const desc = normalizeStr(item.description ?? "");
21526
+ const keywords = (item.keywords ?? []).map(normalizeStr);
21527
+ if (label === q) return 100;
21528
+ if (label.startsWith(q)) return 90;
21529
+ if (label.includes(q)) return 70;
21530
+ if (desc.includes(q)) return 50;
21531
+ if (keywords.some((k) => k.includes(q))) return 40;
21532
+ return -1;
21533
+ }
21534
+ function filterAndScore(groups, query) {
21535
+ if (!query.trim()) return groups;
21536
+ return groups.map((g) => ({
21537
+ ...g,
21538
+ items: g.items.map((item) => ({ item, score: scoreMatch(item, query) })).filter(({ score }) => score >= 0).sort((a, b) => b.score - a.score).map(({ item }) => item)
21539
+ })).filter((g) => g.items.length > 0).sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
21540
+ }
21541
+ function normaliseGroups(items = [], groups = []) {
21542
+ const result = [];
21543
+ if (items.length > 0) {
21544
+ result.push({ id: "__flat__", label: "", items });
21545
+ }
21546
+ result.push(...groups);
21547
+ return result;
21548
+ }
21549
+ function unionGroups(base, terms) {
21550
+ if (terms.length === 0) return base;
21551
+ const allMatchedIds = /* @__PURE__ */ new Set();
21552
+ terms.forEach((term) => {
21553
+ const filtered = filterAndScore(base, term);
21554
+ filtered.forEach((g) => g.items.forEach((i) => allMatchedIds.add(i.id)));
21555
+ });
21556
+ return base.map((group) => ({
21557
+ ...group,
21558
+ items: group.items.filter((item) => allMatchedIds.has(item.id))
21559
+ })).filter((group) => group.items.length > 0);
21560
+ }
21561
+ function createGroup(id, label, items, opts) {
21562
+ return { id, label, items, ...opts };
21563
+ }
21564
+ function createItem(item) {
21565
+ return item;
21566
+ }
21567
+ var STORAGE_KEY = "cmd:recents";
21568
+ var MAX_RECENTS = 5;
21569
+ function readStorage() {
21570
+ try {
21571
+ return JSON.parse(localStorage.getItem(STORAGE_KEY) ?? "[]");
21572
+ } catch {
21573
+ return [];
21574
+ }
21575
+ }
21576
+ function writeStorage(ids) {
21577
+ try {
21578
+ localStorage.setItem(STORAGE_KEY, JSON.stringify(ids));
21579
+ } catch {
21580
+ console.error("Failed to write to localStorage");
21581
+ }
21582
+ }
21583
+ function useRecents(allItems) {
21584
+ const [recentIds, setRecentIds] = React32.useState(readStorage);
21585
+ const push = React32.useCallback((item) => {
21586
+ setRecentIds((prev) => {
21587
+ const next = [item.id, ...prev.filter((id) => id !== item.id)].slice(
21588
+ 0,
21589
+ MAX_RECENTS
21590
+ );
21591
+ writeStorage(next);
21592
+ return next;
21593
+ });
21594
+ }, []);
21595
+ const clear = React32.useCallback(() => {
21596
+ setRecentIds([]);
21597
+ writeStorage([]);
21598
+ }, []);
21599
+ const items = recentIds.map((id) => allItems.find((i) => i.id === id)).filter(Boolean);
21600
+ return { items, push, clear };
21601
+ }
21602
+ function Kbd({ className, ...props }) {
21603
+ return /* @__PURE__ */ jsxRuntime.jsx(
21604
+ "kbd",
21605
+ {
21606
+ "data-slot": "kbd",
21607
+ className: cn(
21608
+ "bg-muted text-muted-foreground in-data-[slot=tooltip-content]:bg-background/20 in-data-[slot=tooltip-content]:text-background dark:in-data-[slot=tooltip-content]:bg-background/10 h-5 w-fit min-w-5 gap-1 rounded-sm px-1 font-sans text-xs font-medium [&_svg:not([class*='size-'])]:size-3 pointer-events-none inline-flex items-center justify-center select-none",
21609
+ className
21610
+ ),
21611
+ ...props
21612
+ }
21613
+ );
21614
+ }
21615
+ function KbdGroup({ className, ...props }) {
21616
+ return /* @__PURE__ */ jsxRuntime.jsx(
21617
+ "kbd",
21618
+ {
21619
+ "data-slot": "kbd-group",
21620
+ className: cn("gap-1 inline-flex items-center", className),
21621
+ ...props
21622
+ }
21623
+ );
21624
+ }
21625
+ function GroupLabel({ group }) {
21626
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 px-3 py-1.5 mb-1", children: [
21627
+ group.icon && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground w-3.5 h-3.5", children: group.icon }),
21628
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[11px] font-semibold text-muted-foreground uppercase tracking-widest", children: group.label })
21629
+ ] });
21630
+ }
21631
+ function mapBadgeVariantToColor(variant) {
21632
+ if (!variant) return void 0;
21633
+ switch (variant) {
21634
+ case "success":
21635
+ return "green";
21636
+ case "warning":
21637
+ return "yellow";
21638
+ case "danger":
21639
+ return "red";
21640
+ case "primary":
21641
+ return "blue";
21642
+ case "secondary":
21643
+ return "purple";
21644
+ case "destructive":
21645
+ return "red";
21646
+ case "muted":
21647
+ return "gray";
21648
+ case "default":
21649
+ return "gray";
21650
+ default:
21651
+ return void 0;
21652
+ }
21653
+ }
21654
+ function CommandItemRow({
21655
+ item,
21656
+ isActive,
21657
+ onSelect,
21658
+ onHover
21659
+ }) {
21660
+ return /* @__PURE__ */ jsxRuntime.jsxs(
21661
+ framerMotion.motion.button,
21662
+ {
21663
+ layout: true,
21664
+ onClick: onSelect,
21665
+ onMouseEnter: onHover,
21666
+ className: `
21667
+ w-full flex items-center gap-1 px-2 py-1 rounded-md text-left cursor-pointer
21668
+ transition-colors duration-75 group relative
21669
+ ${isActive ? "text-accent-foreground hover:bg-accent" : "hover:bg-accent hover:text-accent-foreground"}
21670
+ `,
21671
+ children: [
21672
+ item.icon && /* @__PURE__ */ jsxRuntime.jsx(
21673
+ "span",
21674
+ {
21675
+ className: `relative flex-shrink-0 w-8 h-8 flex items-center justify-center rounded-md text-base
21676
+ ${isActive ? "bg-primary/20 text-primary" : "bg-muted text-muted-foreground group-hover:text-foreground"}`,
21677
+ children: item.icon
21678
+ }
21679
+ ),
21680
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative flex-1 min-w-0 px-1", children: [
21681
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 flex-wrap", children: [
21682
+ /* @__PURE__ */ jsxRuntime.jsx(
21683
+ "span",
21684
+ {
21685
+ className: `text-sm font-medium truncate ${isActive ? "text-foreground" : "text-foreground/80"}`,
21686
+ children: item.label
21687
+ }
21688
+ ),
21689
+ item.badge && /* @__PURE__ */ jsxRuntime.jsx(Badge, { color: mapBadgeVariantToColor(item.badgeVariant), children: item.badge.toUpperCase() })
21690
+ ] }),
21691
+ item.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground truncate", children: item.description })
21692
+ ] }),
21693
+ item.shortcut && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative hidden sm:flex items-center gap-1 flex-shrink-0", children: item.shortcut.map((k, i) => /* @__PURE__ */ jsxRuntime.jsx(Kbd, { children: k }, i)) }),
21694
+ isActive && /* @__PURE__ */ jsxRuntime.jsx(
21695
+ react.CaretRightIcon,
21696
+ {
21697
+ className: "relative w-4 h-4 text-primary flex-shrink-0",
21698
+ weight: "bold"
21699
+ }
21700
+ )
21701
+ ]
21702
+ }
21703
+ );
21704
+ }
21705
+ var PAGE_SIZE = 8;
21706
+ function useCommandPalette({
21707
+ items = [],
21708
+ groups = [],
21709
+ open,
21710
+ onOpenChange,
21711
+ recentItems = [],
21712
+ onRecentItemsChange,
21713
+ maxRecentItems = 5,
21714
+ multiSearch = false
21715
+ }) {
21716
+ const [query, setQuery] = React32__namespace.useState("");
21717
+ const [activeIndex, setActiveIndex] = React32__namespace.useState(0);
21718
+ const [page, setPage] = React32__namespace.useState(0);
21719
+ const baseGroups = React32__namespace.useMemo(
21720
+ () => normaliseGroups(items, groups),
21721
+ [items, groups]
21722
+ );
21723
+ React32__namespace.useEffect(() => {
21724
+ if (open) {
21725
+ setQuery("");
21726
+ setActiveIndex(0);
21727
+ setPage(0);
21728
+ }
21729
+ }, [open]);
21730
+ const searchTerms = React32__namespace.useMemo(() => {
21731
+ const parts = query.split(",");
21732
+ if (parts.length <= 1 && !multiSearch) return [];
21733
+ return parts.map((t) => t.trim().toLowerCase()).filter(Boolean);
21734
+ }, [query, multiSearch]);
21735
+ const allMatchedGroups = React32__namespace.useMemo(() => {
21736
+ if (!query.trim()) {
21737
+ if (recentItems.length > 0) {
21738
+ return [
21739
+ {
21740
+ id: "__recent__",
21741
+ label: "Recent",
21742
+ icon: React32__namespace.createElement(react.ClockCounterClockwiseIcon),
21743
+ items: recentItems,
21744
+ priority: 999
21745
+ },
21746
+ ...baseGroups
21747
+ ];
21748
+ }
21749
+ return baseGroups;
21750
+ }
21751
+ if (searchTerms.length > 1 || multiSearch && searchTerms.length > 0) {
21752
+ return unionGroups(baseGroups, searchTerms);
21753
+ }
21754
+ return filterAndScore(baseGroups, query);
21755
+ }, [query, baseGroups, recentItems, multiSearch, searchTerms]);
21756
+ const allFlatItems = React32.useMemo(
21757
+ () => allMatchedGroups.flatMap((g) => g.items),
21758
+ [allMatchedGroups]
21759
+ );
21760
+ const totalItems = allFlatItems.length;
21761
+ const totalPages = Math.max(1, Math.ceil(totalItems / PAGE_SIZE));
21762
+ React32.useEffect(() => {
21763
+ setPage(0);
21764
+ setActiveIndex(0);
21765
+ }, [query]);
21766
+ React32.useEffect(() => {
21767
+ setActiveIndex(0);
21768
+ }, [page]);
21769
+ const displayedGroups = React32__namespace.useMemo(() => {
21770
+ const start = page * PAGE_SIZE;
21771
+ const end = start + PAGE_SIZE;
21772
+ let count = 0;
21773
+ const result = [];
21774
+ for (const group of allMatchedGroups) {
21775
+ const slicedItems = [];
21776
+ for (const item of group.items) {
21777
+ if (count >= start && count < end) slicedItems.push(item);
21778
+ count++;
21779
+ if (count >= end) break;
21780
+ }
21781
+ if (slicedItems.length > 0) {
21782
+ result.push({ ...group, items: slicedItems });
21783
+ }
21784
+ if (count >= end) break;
21785
+ }
21786
+ return result;
21787
+ }, [allMatchedGroups, page]);
21788
+ const flatItems = React32__namespace.useMemo(
21789
+ () => displayedGroups.flatMap((g) => g.items),
21790
+ [displayedGroups]
21791
+ );
21792
+ const pageItemCount = flatItems.length;
21793
+ React32__namespace.useEffect(() => {
21794
+ setActiveIndex((i) => Math.min(i, Math.max(pageItemCount - 1, 0)));
21795
+ }, [pageItemCount]);
21796
+ function handleSelect(item) {
21797
+ if (!item) return;
21798
+ item.onSelect();
21799
+ onOpenChange?.(false);
21800
+ if (onRecentItemsChange) {
21801
+ const next = [item, ...recentItems.filter((r) => r.id !== item.id)].slice(
21802
+ 0,
21803
+ maxRecentItems
21804
+ );
21805
+ onRecentItemsChange(next);
21806
+ }
21807
+ }
21808
+ React32.useEffect(() => {
21809
+ if (!open) return;
21810
+ const handler = (e) => {
21811
+ if (e.key === "ArrowDown") {
21812
+ e.preventDefault();
21813
+ if (activeIndex === pageItemCount - 1 && page < totalPages - 1) {
21814
+ setPage((p) => p + 1);
21815
+ } else {
21816
+ setActiveIndex((i) => (i + 1) % Math.max(pageItemCount, 1));
21817
+ }
21818
+ } else if (e.key === "ArrowUp") {
21819
+ e.preventDefault();
21820
+ if (activeIndex === 0 && page > 0) {
21821
+ setPage((p) => p - 1);
21822
+ setActiveIndex(PAGE_SIZE - 1);
21823
+ } else {
21824
+ setActiveIndex(
21825
+ (i) => (i - 1 + Math.max(pageItemCount, 1)) % Math.max(pageItemCount, 1)
21826
+ );
21827
+ }
21828
+ } else if (e.key === "Enter") {
21829
+ e.preventDefault();
21830
+ handleSelect(flatItems[activeIndex]);
21831
+ }
21832
+ };
21833
+ document.addEventListener("keydown", handler);
21834
+ return () => document.removeEventListener("keydown", handler);
21835
+ }, [open, flatItems, activeIndex, pageItemCount, page, totalPages]);
21836
+ return {
21837
+ query,
21838
+ setQuery,
21839
+ activeIndex,
21840
+ setActiveIndex,
21841
+ page,
21842
+ setPage,
21843
+ searchTerms,
21844
+ allMatchedGroups,
21845
+ allFlatItems,
21846
+ displayedGroups,
21847
+ flatItems,
21848
+ totalItems,
21849
+ totalPages,
21850
+ handleSelect,
21851
+ isEmpty: totalItems === 0 && query.trim().length > 0,
21852
+ showList: query.trim() !== "" || recentItems.length > 0
21853
+ };
21854
+ }
21855
+ function useKeyboardShortcut(key, callback, options = {}) {
21856
+ React32.useEffect(() => {
21857
+ const handleKeyDown = (event) => {
21858
+ const { ctrl, meta, shift, alt } = options;
21859
+ const isKeyMatch = event.key.toLowerCase() === key.toLowerCase();
21860
+ const isCtrlMatch = ctrl === void 0 || event.ctrlKey === ctrl;
21861
+ const isMetaMatch = meta === void 0 || event.metaKey === meta;
21862
+ const isShiftMatch = shift === void 0 || event.shiftKey === shift;
21863
+ const isAltMatch = alt === void 0 || event.altKey === alt;
21864
+ if (isKeyMatch && isCtrlMatch && isMetaMatch && isShiftMatch && isAltMatch) {
21865
+ event.preventDefault();
21866
+ callback();
21867
+ }
21868
+ };
21869
+ window.addEventListener("keydown", handleKeyDown);
21870
+ return () => window.removeEventListener("keydown", handleKeyDown);
21871
+ }, [key, callback, options]);
21872
+ }
21873
+ var ITEM_HEIGHT2 = 40;
21874
+ var LABEL_HEIGHT = 28;
21875
+ var LIST_MAX_HEIGHT = 460;
21876
+ var ANIMATION = {
21877
+ overlay: { duration: 0.18 },
21878
+ panel: { duration: 0.2, ease: [0.16, 1, 0.3, 1] },
21879
+ mobilePanel: { duration: 0.18, ease: [0.16, 1, 0.3, 1] },
21880
+ empty: { initial: { opacity: 0, y: 8 }, animate: { opacity: 1, y: 0 } }
21881
+ };
21882
+ var SearchBadges = React32.memo(({ terms }) => {
21883
+ if (terms.length === 0) return null;
21884
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-1.5 px-4 py-1.5 border-b border-border flex-wrap", children: terms.map((term, i) => /* @__PURE__ */ jsxRuntime.jsx(Badge, { children: term }, i)) });
21885
+ });
21886
+ SearchBadges.displayName = "SearchBadges";
21887
+ var EmptyState = React32.memo(({ message }) => /* @__PURE__ */ jsxRuntime.jsxs(
21888
+ framerMotion.motion.div,
21889
+ {
21890
+ ...ANIMATION.empty,
21891
+ className: "flex flex-col items-center justify-center py-14 text-center gap-3",
21892
+ children: [
21893
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-12 h-12 rounded-md bg-muted flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(react.MagnifyingGlassIcon, { className: "w-6 h-6 text-muted-foreground" }) }),
21894
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
21895
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium text-muted-foreground", children: message }),
21896
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground/60 mt-1", children: "Try a different search term" })
21897
+ ] })
21898
+ ]
21899
+ }
21900
+ ));
21901
+ EmptyState.displayName = "EmptyState";
21902
+ var VirtualResultList = React32.memo(
21903
+ ({
21904
+ listRef,
21905
+ isEmpty,
21906
+ emptyMessage,
21907
+ displayedGroups,
21908
+ flatItems,
21909
+ activeIndex,
21910
+ onHover,
21911
+ onSelect
21912
+ }) => {
21913
+ const rows = React32.useMemo(() => {
21914
+ const acc = [];
21915
+ for (const group of displayedGroups) {
21916
+ if (group.label) acc.push({ kind: "label", group });
21917
+ for (const item of group.items) {
21918
+ const globalIdx = flatItems.findIndex((f) => f.id === item.id);
21919
+ acc.push({ kind: "item", item, globalIdx });
21920
+ }
21921
+ }
21922
+ return acc;
21923
+ }, [displayedGroups, flatItems]);
21924
+ const virtualizer = reactVirtual.useVirtualizer({
21925
+ count: rows.length,
21926
+ getScrollElement: () => listRef.current,
21927
+ estimateSize: (i) => rows[i].kind === "label" ? LABEL_HEIGHT : ITEM_HEIGHT2,
21928
+ overscan: 8
21929
+ });
21930
+ const virtualItems = virtualizer.getVirtualItems();
21931
+ const totalSize = virtualizer.getTotalSize();
21932
+ if (isEmpty) {
21933
+ return /* @__PURE__ */ jsxRuntime.jsx(
21934
+ "div",
21935
+ {
21936
+ ref: listRef,
21937
+ className: "overflow-y-auto overscroll-contain px-2 py-1",
21938
+ style: { maxHeight: `min(${LIST_MAX_HEIGHT}px, 60vh)` },
21939
+ children: /* @__PURE__ */ jsxRuntime.jsx(EmptyState, { message: emptyMessage })
21940
+ }
21941
+ );
21942
+ }
21943
+ return /* @__PURE__ */ jsxRuntime.jsx(
21944
+ "div",
21945
+ {
21946
+ ref: listRef,
21947
+ className: "overflow-y-auto overscroll-contain px-2 py-1 [&::-webkit-scrollbar]:w-1.5 [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar-thumb]:bg-muted-foreground/30 [&::-webkit-scrollbar-thumb]:rounded-full hover:[&::-webkit-scrollbar-thumb]:bg-muted-foreground/50 transition-colors",
21948
+ style: { maxHeight: `min(${LIST_MAX_HEIGHT}px, 60vh)` },
21949
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { style: { height: totalSize, position: "relative" }, children: virtualItems.map((vItem) => {
21950
+ const row = rows[vItem.index];
21951
+ return /* @__PURE__ */ jsxRuntime.jsx(
21952
+ "div",
21953
+ {
21954
+ "data-index": vItem.index,
21955
+ ref: virtualizer.measureElement,
21956
+ style: {
21957
+ position: "absolute",
21958
+ top: vItem.start,
21959
+ left: 0,
21960
+ right: 0
21961
+ },
21962
+ children: row.kind === "label" ? /* @__PURE__ */ jsxRuntime.jsx(GroupLabel, { group: row.group }) : /* @__PURE__ */ jsxRuntime.jsx("div", { "data-active": row.globalIdx === activeIndex, children: /* @__PURE__ */ jsxRuntime.jsx(
21963
+ CommandItemRow,
21964
+ {
21965
+ item: row.item,
21966
+ isActive: row.globalIdx === activeIndex,
21967
+ onHover: () => onHover(row.globalIdx),
21968
+ onSelect: () => onSelect(row.item)
21969
+ }
21970
+ ) })
21971
+ },
21972
+ vItem.key
21973
+ );
21974
+ }) })
21975
+ }
21976
+ );
21977
+ }
21978
+ );
21979
+ VirtualResultList.displayName = "VirtualResultList";
21980
+ var FooterBar = React32.memo(({ footer, totalItems }) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between px-4 py-2 border-t border-border bg-muted/30", children: [
21981
+ footer ?? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-4 text-[11px] text-muted-foreground", children: [
21982
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-1.5", children: [
21983
+ /* @__PURE__ */ jsxRuntime.jsx(react.ArrowElbowDownRightIcon, { className: "w-3 h-3" }),
21984
+ "Selecionar"
21985
+ ] }),
21986
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-1.5", children: [
21987
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-mono", children: "\u2191\u2193" }),
21988
+ "Navegar"
21989
+ ] }),
21990
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-1.5", children: [
21991
+ /* @__PURE__ */ jsxRuntime.jsx(react.ArrowBendUpLeftIcon, { className: "w-3 h-3" }),
21992
+ "Fechar"
21993
+ ] })
21994
+ ] }),
21995
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5 text-[11px] text-muted-foreground", children: [
21996
+ /* @__PURE__ */ jsxRuntime.jsx(react.CommandIcon, { className: "w-3 h-3" }),
21997
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
21998
+ totalItems,
21999
+ " resultado",
22000
+ totalItems !== 1 ? "s" : ""
22001
+ ] })
22002
+ ] })
22003
+ ] }));
22004
+ FooterBar.displayName = "FooterBar";
22005
+ function CommandPalette(props) {
22006
+ const {
22007
+ placeholder = "Buscar comandos\u2026",
22008
+ open,
22009
+ onOpenChange,
22010
+ footer,
22011
+ debounceDelay = 300,
22012
+ multiSearch = false,
22013
+ emptyMessage = "Nenhum resultado encontrado.",
22014
+ shortcut = { key: "k", ctrl: true }
22015
+ } = props;
22016
+ const inputRef = React32.useRef(null);
22017
+ const listRef = React32.useRef(null);
22018
+ const isMobile = useIsMobile();
22019
+ const {
22020
+ query,
22021
+ setQuery,
22022
+ activeIndex,
22023
+ setActiveIndex,
22024
+ searchTerms,
22025
+ displayedGroups,
22026
+ flatItems,
22027
+ totalItems,
22028
+ handleSelect,
22029
+ isEmpty,
22030
+ showList
22031
+ } = useCommandPalette({
22032
+ ...props,
22033
+ open: isMobile ? true : props.open
22034
+ });
22035
+ useKeyboardShortcut(shortcut.key, () => onOpenChange(!open), {
22036
+ ctrl: shortcut.ctrl,
22037
+ meta: shortcut.meta,
22038
+ shift: shortcut.shift,
22039
+ alt: shortcut.alt
22040
+ });
22041
+ React32.useEffect(() => {
22042
+ if (!open) return;
22043
+ const handleEscape = (e) => {
22044
+ if (e.key === "Escape") onOpenChange(false);
22045
+ };
22046
+ document.addEventListener("keydown", handleEscape);
22047
+ return () => document.removeEventListener("keydown", handleEscape);
22048
+ }, [open, onOpenChange]);
22049
+ React32.useEffect(() => {
22050
+ if (!open) return;
22051
+ const timer = setTimeout(() => inputRef.current?.focus(), 50);
22052
+ return () => clearTimeout(timer);
22053
+ }, [open]);
22054
+ React32.useEffect(() => {
22055
+ const el = listRef.current?.querySelector(
22056
+ `[data-active="true"]`
22057
+ );
22058
+ el?.scrollIntoView({ block: "nearest" });
22059
+ }, [activeIndex]);
22060
+ const handleQueryChange = React32.useCallback(
22061
+ (val) => {
22062
+ setQuery(val);
22063
+ setActiveIndex(0);
22064
+ },
22065
+ [setQuery, setActiveIndex]
22066
+ );
22067
+ const handleQueryChangeMobile = React32.useCallback(
22068
+ (val) => {
22069
+ setQuery(val);
22070
+ setActiveIndex(0);
22071
+ if (!open && val.trim() !== "") onOpenChange(true);
22072
+ },
22073
+ [setQuery, setActiveIndex, open, onOpenChange]
22074
+ );
22075
+ const handleClose = React32.useCallback(() => onOpenChange(false), [onOpenChange]);
22076
+ const handleClearQuery = React32.useCallback(() => setQuery(""), [setQuery]);
22077
+ const searchPlaceholder = multiSearch ? "Buscar\u2026 (separe termos por v\xEDrgula)" : placeholder;
22078
+ const sharedListProps = {
22079
+ listRef,
22080
+ isEmpty,
22081
+ emptyMessage,
22082
+ displayedGroups,
22083
+ flatItems,
22084
+ activeIndex,
22085
+ onHover: setActiveIndex,
22086
+ onSelect: handleSelect
22087
+ };
22088
+ if (isMobile) {
22089
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
22090
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "fixed top-0 left-0 right-0 z-[100] px-3 py-2 bg-background", children: /* @__PURE__ */ jsxRuntime.jsx(
22091
+ DebouncedInput,
22092
+ {
22093
+ ref: inputRef,
22094
+ value: query,
22095
+ debounce: debounceDelay,
22096
+ onChange: handleQueryChangeMobile,
22097
+ placeholder: searchPlaceholder
22098
+ }
22099
+ ) }),
22100
+ /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { children: showList && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
22101
+ /* @__PURE__ */ jsxRuntime.jsx(
22102
+ framerMotion.motion.div,
22103
+ {
22104
+ initial: { opacity: 0 },
22105
+ animate: { opacity: 1 },
22106
+ exit: { opacity: 0 },
22107
+ transition: ANIMATION.overlay,
22108
+ className: "fixed inset-0 z-[98] bg-background/60 backdrop-blur-[2px]",
22109
+ onClick: handleClose
22110
+ }
22111
+ ),
22112
+ /* @__PURE__ */ jsxRuntime.jsxs(
22113
+ framerMotion.motion.div,
22114
+ {
22115
+ initial: { opacity: 0, y: -6 },
22116
+ animate: { opacity: 1, y: 0 },
22117
+ exit: { opacity: 0, y: -6 },
22118
+ transition: ANIMATION.mobilePanel,
22119
+ className: "fixed left-3 right-3 z-[99] bg-popover border border-border rounded-lg shadow-2xl shadow-black/20 dark:shadow-black/50 overflow-hidden top-14",
22120
+ children: [
22121
+ /* @__PURE__ */ jsxRuntime.jsx(SearchBadges, { terms: searchTerms }),
22122
+ /* @__PURE__ */ jsxRuntime.jsx(VirtualResultList, { ...sharedListProps })
22123
+ ]
22124
+ }
22125
+ )
22126
+ ] }) })
22127
+ ] });
22128
+ }
22129
+ return /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { children: open && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
22130
+ /* @__PURE__ */ jsxRuntime.jsx(
22131
+ framerMotion.motion.div,
22132
+ {
22133
+ initial: { opacity: 0 },
22134
+ animate: { opacity: 1 },
22135
+ exit: { opacity: 0 },
22136
+ transition: ANIMATION.overlay,
22137
+ className: "fixed inset-0 z-[100] bg-background/80 backdrop-blur-sm",
22138
+ onClick: handleClose
22139
+ }
22140
+ ),
22141
+ /* @__PURE__ */ jsxRuntime.jsxs(
22142
+ framerMotion.motion.div,
22143
+ {
22144
+ initial: { opacity: 0, scale: 0.96, y: -8 },
22145
+ animate: { opacity: 1, scale: 1, y: 0 },
22146
+ exit: { opacity: 0, scale: 0.96, y: -8 },
22147
+ transition: ANIMATION.panel,
22148
+ className: "fixed z-[100] top-12 -translate-x-1/2 -translate-y-1/2 w-full max-w-xl rounded-xl border border-border overflow-hidden shadow-2xl shadow-black/20 dark:shadow-black/60 bg-popover/95 backdrop-blur-xl",
22149
+ style: { maxHeight: "min(600px, 80vh)" },
22150
+ children: [
22151
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 px-4 py-2 border-b border-border", children: [
22152
+ /* @__PURE__ */ jsxRuntime.jsx(
22153
+ react.MagnifyingGlassIcon,
22154
+ {
22155
+ className: "w-4 h-4 text-muted-foreground flex-shrink-0",
22156
+ weight: "bold"
22157
+ }
22158
+ ),
22159
+ /* @__PURE__ */ jsxRuntime.jsx(
22160
+ DebouncedInput,
22161
+ {
22162
+ ref: inputRef,
22163
+ value: query,
22164
+ debounce: debounceDelay,
22165
+ onChange: handleQueryChange,
22166
+ placeholder: searchPlaceholder,
22167
+ rightIcon: query ? /* @__PURE__ */ jsxRuntime.jsx(
22168
+ ButtonBase,
22169
+ {
22170
+ variant: "ghost",
22171
+ size: "icon",
22172
+ onClick: handleClearQuery,
22173
+ className: "text-muted-foreground hover:text-red-500 hover:bg-transparent transition-colors",
22174
+ children: /* @__PURE__ */ jsxRuntime.jsx(react.XIcon, { className: "w-4 h-4" })
22175
+ }
22176
+ ) : void 0,
22177
+ className: "flex-1 bg-transparent border-none focus-visible:ring-0 outline-none shadow-none px-0 h-7 text-sm caret-primary"
22178
+ }
22179
+ )
22180
+ ] }),
22181
+ /* @__PURE__ */ jsxRuntime.jsx(SearchBadges, { terms: searchTerms }),
22182
+ showList && /* @__PURE__ */ jsxRuntime.jsx(VirtualResultList, { ...sharedListProps }),
22183
+ /* @__PURE__ */ jsxRuntime.jsx(FooterBar, { footer, totalItems })
22184
+ ]
22185
+ }
22186
+ )
22187
+ ] }) });
22188
+ }
21526
22189
 
21527
22190
  exports.AddButton = AddButton;
21528
22191
  exports.Agenda = Agenda;
@@ -21590,7 +22253,9 @@ exports.CommandEmptyBase = CommandEmptyBase;
21590
22253
  exports.CommandGroupBase = CommandGroupBase;
21591
22254
  exports.CommandInputBase = CommandInputBase;
21592
22255
  exports.CommandItemBase = CommandItemBase;
22256
+ exports.CommandItemRow = CommandItemRow;
21593
22257
  exports.CommandListBase = CommandListBase;
22258
+ exports.CommandPalette = CommandPalette;
21594
22259
  exports.CommandSeparatorBase = CommandSeparatorBase;
21595
22260
  exports.CommandShortcutBase = CommandShortcutBase;
21596
22261
  exports.ContextMenuBase = ContextMenuBase;
@@ -21678,6 +22343,7 @@ exports.FavoriteButton = FavoriteButton;
21678
22343
  exports.FileAccept = FileAccept;
21679
22344
  exports.FileUploader = FileUploader;
21680
22345
  exports.FilterButton = FilterButton;
22346
+ exports.GroupLabel = GroupLabel;
21681
22347
  exports.HideButton = HideButton;
21682
22348
  exports.Highlights = Highlights_default;
21683
22349
  exports.HorizontalChart = HorizontalChart_default;
@@ -21692,6 +22358,8 @@ exports.InputOTPGroupBase = InputOTPGroupBase;
21692
22358
  exports.InputOTPSeparatorBase = InputOTPSeparatorBase;
21693
22359
  exports.InputOTPSlotBase = InputOTPSlotBase;
21694
22360
  exports.IntegrationModal = IntegrationModal_default;
22361
+ exports.Kbd = Kbd;
22362
+ exports.KbdGroup = KbdGroup;
21695
22363
  exports.LabelBase = LabelBase_default;
21696
22364
  exports.Leaderboard = Leaderboard;
21697
22365
  exports.LikeButton = LikeButton;
@@ -21851,11 +22519,14 @@ exports.computeChartWidth = computeChartWidth;
21851
22519
  exports.computeNiceMax = computeNiceMax;
21852
22520
  exports.computeYAxisTickWidth = computeYAxisTickWidth;
21853
22521
  exports.convert12HourTo24Hour = convert12HourTo24Hour;
22522
+ exports.createGroup = createGroup;
22523
+ exports.createItem = createItem;
21854
22524
  exports.createValueFormatter = createValueFormatter;
21855
22525
  exports.createYTickFormatter = createYTickFormatter;
21856
22526
  exports.detectDataFields = detectDataFields;
21857
22527
  exports.detectXAxis = detectXAxis;
21858
22528
  exports.display12HourValue = display12HourValue;
22529
+ exports.filterAndScore = filterAndScore;
21859
22530
  exports.formatDurationAgenda = formatDurationAgenda;
21860
22531
  exports.formatDurationAgendaDays = formatDurationAgendaDays;
21861
22532
  exports.formatFieldName = formatFieldName;
@@ -21896,13 +22567,16 @@ exports.isValid12Hour = isValid12Hour;
21896
22567
  exports.isValidHour = isValidHour;
21897
22568
  exports.isValidMinuteOrSecond = isValidMinuteOrSecond;
21898
22569
  exports.niceCeil = niceCeil;
22570
+ exports.normaliseGroups = normaliseGroups;
21899
22571
  exports.normalizeAttendDate = normalizeAttendDate;
22572
+ exports.normalizeStr = normalizeStr;
21900
22573
  exports.processIntegrationData = processIntegrationData;
21901
22574
  exports.processNeo4jData = processNeo4jData;
21902
22575
  exports.renderInsideBarLabel = renderInsideBarLabel;
21903
22576
  exports.renderPillLabel = pillLabelRenderer_default;
21904
22577
  exports.resolveChartMargins = resolveChartMargins;
21905
22578
  exports.resolveContainerPaddingLeft = resolveContainerPaddingLeft;
22579
+ exports.scoreMatch = scoreMatch;
21906
22580
  exports.set12Hours = set12Hours;
21907
22581
  exports.setDateByType = setDateByType;
21908
22582
  exports.setHours = setHours;
@@ -21912,6 +22586,7 @@ exports.sortEvents = sortEvents;
21912
22586
  exports.sortEventsAgenda = sortEventsAgenda;
21913
22587
  exports.startOfLocalDay = startOfLocalDay;
21914
22588
  exports.toast = toast;
22589
+ exports.unionGroups = unionGroups;
21915
22590
  exports.useBiaxial = useBiaxial;
21916
22591
  exports.useCalendarDnd = useCalendarDnd;
21917
22592
  exports.useCalendarDndAgenda = useCalendarDndAgenda;
@@ -21921,6 +22596,7 @@ exports.useChartHighlights = useChartHighlights;
21921
22596
  exports.useChartLayout = useChartLayout;
21922
22597
  exports.useChartMinMax = useChartMinMax;
21923
22598
  exports.useChartTooltips = useChartTooltips;
22599
+ exports.useCommandPalette = useCommandPalette;
21924
22600
  exports.useCurrentTimeIndicator = useCurrentTimeIndicator;
21925
22601
  exports.useCurrentTimeIndicatorAgenda = useCurrentTimeIndicatorAgenda;
21926
22602
  exports.useDrag = useDrag;
@@ -21930,6 +22606,7 @@ exports.useIsMobile = useIsMobile;
21930
22606
  exports.useIsTruncated = useIsTruncated;
21931
22607
  exports.useOpenTooltipForPeriod = useOpenTooltipForPeriod;
21932
22608
  exports.useProcessedData = useProcessedData;
22609
+ exports.useRecents = useRecents;
21933
22610
  exports.useSeriesOpacity = useSeriesOpacity;
21934
22611
  exports.useTheme = useTheme;
21935
22612
  exports.useTimeSeriesRange = useTimeSeriesRange;