@the12company/ui 0.1.2 → 0.1.3
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/README.md +24 -7
- package/dist/index.d.ts +132 -1
- package/dist/index.js +823 -126
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { clsx } from 'clsx';
|
|
|
2
2
|
import { twMerge } from 'tailwind-merge';
|
|
3
3
|
import * as React11 from 'react';
|
|
4
4
|
import * as AccordionPrimitive from '@radix-ui/react-accordion';
|
|
5
|
-
import { ChevronDown, X, PanelLeft, ArrowLeft, ArrowRight, Check, Search, ChevronRight, Circle, Dot, ChevronUp, MoreHorizontal, ChevronLeft, GripVertical, CircleX } from 'lucide-react';
|
|
5
|
+
import { ChevronDown, X, PanelLeft, ArrowLeft, ArrowRight, Check, Search, ChevronRight, Circle, Dot, ChevronUp, MoreHorizontal, ChevronLeft, GripVertical, ChevronsUpDown, Loader2, CircleX } from 'lucide-react';
|
|
6
6
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
7
7
|
import { cva } from 'class-variance-authority';
|
|
8
8
|
import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog';
|
|
@@ -398,40 +398,6 @@ var AlertDialogCancel = React11.forwardRef(({ className, ...props }, ref) => /*
|
|
|
398
398
|
}
|
|
399
399
|
));
|
|
400
400
|
AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;
|
|
401
|
-
function AppChromeHeader({
|
|
402
|
-
headerRef,
|
|
403
|
-
className,
|
|
404
|
-
start,
|
|
405
|
-
topBar,
|
|
406
|
-
children
|
|
407
|
-
}) {
|
|
408
|
-
return /* @__PURE__ */ jsx(
|
|
409
|
-
"header",
|
|
410
|
-
{
|
|
411
|
-
ref: headerRef,
|
|
412
|
-
className: cn(
|
|
413
|
-
"absolute left-3.5 right-3.5 top-3.5 z-30 max-w-full rounded-lg shadow-sm",
|
|
414
|
-
className
|
|
415
|
-
),
|
|
416
|
-
children: /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
417
|
-
/* @__PURE__ */ jsx(
|
|
418
|
-
"div",
|
|
419
|
-
{
|
|
420
|
-
className: "pointer-events-none absolute inset-0 rounded-lg bg-content-glass",
|
|
421
|
-
"aria-hidden": true
|
|
422
|
-
}
|
|
423
|
-
),
|
|
424
|
-
/* @__PURE__ */ jsxs("div", { className: "relative z-10 flex flex-col", children: [
|
|
425
|
-
/* @__PURE__ */ jsxs("div", { className: "flex min-h-14 items-center gap-3 rounded-lg border-b border-border/40 px-3 py-2 sm:gap-2 md:min-h-fit", children: [
|
|
426
|
-
start,
|
|
427
|
-
topBar
|
|
428
|
-
] }),
|
|
429
|
-
children
|
|
430
|
-
] })
|
|
431
|
-
] })
|
|
432
|
-
}
|
|
433
|
-
);
|
|
434
|
-
}
|
|
435
401
|
var inputVariants = cva(
|
|
436
402
|
"flex h-10 w-full shadow-[0_2px_6px_hsl(var(--foreground)/0.08)] dark:shadow-[0_1px_3px_-1px_rgba(0,0,0,0.28)] hover:shadow-[0_4px_10px_hsl(var(--foreground)/0.12)] dark:hover:shadow-[0_2px_6px_-2px_rgba(0,0,0,0.32)] focus-visible:shadow-lg rounded-md px-3 py-2 text-base outline-none transition-all duration-300 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-0 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
|
437
403
|
{
|
|
@@ -1191,6 +1157,76 @@ var SidebarMenuSubButton = React11.forwardRef(({ asChild = false, size = "md", i
|
|
|
1191
1157
|
);
|
|
1192
1158
|
});
|
|
1193
1159
|
SidebarMenuSubButton.displayName = "SidebarMenuSubButton";
|
|
1160
|
+
function AppChromeBrand({
|
|
1161
|
+
logo,
|
|
1162
|
+
title,
|
|
1163
|
+
subtitle,
|
|
1164
|
+
className,
|
|
1165
|
+
collapsed: collapsedProp
|
|
1166
|
+
}) {
|
|
1167
|
+
const { state, isMobile } = useSidebar();
|
|
1168
|
+
const collapsed = collapsedProp ?? (!isMobile && state === "collapsed");
|
|
1169
|
+
return /* @__PURE__ */ jsxs(
|
|
1170
|
+
"div",
|
|
1171
|
+
{
|
|
1172
|
+
className: cn(
|
|
1173
|
+
"flex min-w-0 items-center overflow-hidden transition-all duration-300",
|
|
1174
|
+
collapsed ? "justify-center px-2 py-4" : "gap-2.5 px-4 py-5",
|
|
1175
|
+
className
|
|
1176
|
+
),
|
|
1177
|
+
children: [
|
|
1178
|
+
logo ? /* @__PURE__ */ jsx(
|
|
1179
|
+
"div",
|
|
1180
|
+
{
|
|
1181
|
+
className: cn(
|
|
1182
|
+
"flex flex-shrink-0 items-center justify-center rounded-lg transition-all duration-500 hover:scale-105 hover:shadow-lg hover:shadow-sidebar-primary/20",
|
|
1183
|
+
collapsed ? "h-9 w-9" : "h-8 w-8"
|
|
1184
|
+
),
|
|
1185
|
+
children: logo
|
|
1186
|
+
}
|
|
1187
|
+
) : null,
|
|
1188
|
+
!collapsed && (title || subtitle) ? /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-1 flex-col overflow-hidden", children: [
|
|
1189
|
+
title ? /* @__PURE__ */ jsx("span", { className: "truncate whitespace-nowrap text-base font-bold tracking-tight text-sidebar-accent-foreground", children: title }) : null,
|
|
1190
|
+
subtitle ? /* @__PURE__ */ jsx("span", { className: "truncate whitespace-nowrap text-xs text-sidebar-foreground/60", children: subtitle }) : null
|
|
1191
|
+
] }) : null
|
|
1192
|
+
]
|
|
1193
|
+
}
|
|
1194
|
+
);
|
|
1195
|
+
}
|
|
1196
|
+
function AppChromeHeader({
|
|
1197
|
+
headerRef,
|
|
1198
|
+
className,
|
|
1199
|
+
start,
|
|
1200
|
+
topBar,
|
|
1201
|
+
children
|
|
1202
|
+
}) {
|
|
1203
|
+
return /* @__PURE__ */ jsx(
|
|
1204
|
+
"header",
|
|
1205
|
+
{
|
|
1206
|
+
ref: headerRef,
|
|
1207
|
+
className: cn(
|
|
1208
|
+
"absolute left-3.5 right-3.5 top-3.5 z-30 max-w-full rounded-lg shadow-sm",
|
|
1209
|
+
className
|
|
1210
|
+
),
|
|
1211
|
+
children: /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
1212
|
+
/* @__PURE__ */ jsx(
|
|
1213
|
+
"div",
|
|
1214
|
+
{
|
|
1215
|
+
className: "pointer-events-none absolute inset-0 rounded-lg bg-content-glass",
|
|
1216
|
+
"aria-hidden": true
|
|
1217
|
+
}
|
|
1218
|
+
),
|
|
1219
|
+
/* @__PURE__ */ jsxs("div", { className: "relative z-10 flex flex-col", children: [
|
|
1220
|
+
/* @__PURE__ */ jsxs("div", { className: "flex min-h-14 items-center gap-3 rounded-lg border-b border-border/40 px-3 py-2 sm:gap-2 md:min-h-fit", children: [
|
|
1221
|
+
start,
|
|
1222
|
+
topBar
|
|
1223
|
+
] }),
|
|
1224
|
+
children
|
|
1225
|
+
] })
|
|
1226
|
+
] })
|
|
1227
|
+
}
|
|
1228
|
+
);
|
|
1229
|
+
}
|
|
1194
1230
|
function AppChromeSidebar({
|
|
1195
1231
|
header,
|
|
1196
1232
|
children,
|
|
@@ -1903,6 +1939,49 @@ function getPayloadConfigFromPayload(config, payload, key) {
|
|
|
1903
1939
|
}
|
|
1904
1940
|
return configLabelKey in config ? config[configLabelKey] : config[key];
|
|
1905
1941
|
}
|
|
1942
|
+
function ChartCard({
|
|
1943
|
+
title,
|
|
1944
|
+
subtitle,
|
|
1945
|
+
children,
|
|
1946
|
+
action,
|
|
1947
|
+
titleInfo,
|
|
1948
|
+
titleClassName,
|
|
1949
|
+
glass = false,
|
|
1950
|
+
className
|
|
1951
|
+
}) {
|
|
1952
|
+
return /* @__PURE__ */ jsxs(
|
|
1953
|
+
"div",
|
|
1954
|
+
{
|
|
1955
|
+
className: cn(
|
|
1956
|
+
"rounded-lg p-4 shadow-md sm:p-5",
|
|
1957
|
+
className,
|
|
1958
|
+
glass ? "bg-content-glass" : "bg-card border border-border"
|
|
1959
|
+
),
|
|
1960
|
+
children: [
|
|
1961
|
+
/* @__PURE__ */ jsxs("div", { className: "mb-4 flex items-center justify-between gap-3", children: [
|
|
1962
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
1963
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-x-2 gap-y-1", children: [
|
|
1964
|
+
/* @__PURE__ */ jsx(
|
|
1965
|
+
"h3",
|
|
1966
|
+
{
|
|
1967
|
+
className: cn(
|
|
1968
|
+
"text-base font-semibold leading-snug text-foreground",
|
|
1969
|
+
titleClassName
|
|
1970
|
+
),
|
|
1971
|
+
children: title
|
|
1972
|
+
}
|
|
1973
|
+
),
|
|
1974
|
+
titleInfo ? /* @__PURE__ */ jsx("span", { className: "inline-flex shrink-0 -translate-y-0.5 items-center justify-center", children: titleInfo }) : null
|
|
1975
|
+
] }),
|
|
1976
|
+
subtitle ? /* @__PURE__ */ jsx("p", { className: "text-xs leading-snug text-muted-foreground", children: subtitle }) : null
|
|
1977
|
+
] }),
|
|
1978
|
+
action ? /* @__PURE__ */ jsx("div", { className: "flex shrink-0 items-center self-center", children: action }) : null
|
|
1979
|
+
] }),
|
|
1980
|
+
children
|
|
1981
|
+
]
|
|
1982
|
+
}
|
|
1983
|
+
);
|
|
1984
|
+
}
|
|
1906
1985
|
var Checkbox = React11.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
1907
1986
|
CheckboxPrimitive.Root,
|
|
1908
1987
|
{
|
|
@@ -2641,6 +2720,313 @@ var InputOTPSlot = React11.forwardRef(({ index, className, ...props }, ref) => {
|
|
|
2641
2720
|
InputOTPSlot.displayName = "InputOTPSlot";
|
|
2642
2721
|
var InputOTPSeparator = React11.forwardRef(({ ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, role: "separator", ...props, children: /* @__PURE__ */ jsx(Dot, {}) }));
|
|
2643
2722
|
InputOTPSeparator.displayName = "InputOTPSeparator";
|
|
2723
|
+
|
|
2724
|
+
// src/lib/pagination.ts
|
|
2725
|
+
function buildVisiblePages(current, totalPages) {
|
|
2726
|
+
if (totalPages <= 7) {
|
|
2727
|
+
return Array.from({ length: totalPages }, (_, i) => i + 1);
|
|
2728
|
+
}
|
|
2729
|
+
const pages = [1];
|
|
2730
|
+
if (current > 3) {
|
|
2731
|
+
pages.push("ellipsis");
|
|
2732
|
+
}
|
|
2733
|
+
const start = Math.max(2, current - 1);
|
|
2734
|
+
const end = Math.min(totalPages - 1, current + 1);
|
|
2735
|
+
for (let i = start; i <= end; i++) {
|
|
2736
|
+
pages.push(i);
|
|
2737
|
+
}
|
|
2738
|
+
if (current < totalPages - 2) {
|
|
2739
|
+
pages.push("ellipsis");
|
|
2740
|
+
}
|
|
2741
|
+
pages.push(totalPages);
|
|
2742
|
+
return pages;
|
|
2743
|
+
}
|
|
2744
|
+
function buildRangeLabel(page, pageSize, total, itemLabel = "itens", formatTotal = (n) => n.toLocaleString("pt-BR")) {
|
|
2745
|
+
if (total === 0) return `0 ${itemLabel}`;
|
|
2746
|
+
const from = (page - 1) * pageSize + 1;
|
|
2747
|
+
const to = Math.min(page * pageSize, total);
|
|
2748
|
+
return `${from.toLocaleString("pt-BR")} \u2013 ${to.toLocaleString("pt-BR")} de ${formatTotal(total)} ${itemLabel}`;
|
|
2749
|
+
}
|
|
2750
|
+
var Pagination = ({ className, ...props }) => /* @__PURE__ */ jsx(
|
|
2751
|
+
"nav",
|
|
2752
|
+
{
|
|
2753
|
+
role: "navigation",
|
|
2754
|
+
"aria-label": "pagination",
|
|
2755
|
+
className: cn("mx-auto flex w-full justify-center", className),
|
|
2756
|
+
...props
|
|
2757
|
+
}
|
|
2758
|
+
);
|
|
2759
|
+
Pagination.displayName = "Pagination";
|
|
2760
|
+
var PaginationContent = React11.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2761
|
+
"ul",
|
|
2762
|
+
{
|
|
2763
|
+
ref,
|
|
2764
|
+
className: cn("flex flex-row items-center gap-1", className),
|
|
2765
|
+
...props
|
|
2766
|
+
}
|
|
2767
|
+
));
|
|
2768
|
+
PaginationContent.displayName = "PaginationContent";
|
|
2769
|
+
var PaginationItem = React11.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("li", { ref, className: cn("", className), ...props }));
|
|
2770
|
+
PaginationItem.displayName = "PaginationItem";
|
|
2771
|
+
var PaginationLink = ({
|
|
2772
|
+
className,
|
|
2773
|
+
isActive,
|
|
2774
|
+
size = "icon",
|
|
2775
|
+
...props
|
|
2776
|
+
}) => /* @__PURE__ */ jsx(
|
|
2777
|
+
"a",
|
|
2778
|
+
{
|
|
2779
|
+
"aria-current": isActive ? "page" : void 0,
|
|
2780
|
+
className: cn(
|
|
2781
|
+
buttonVariants({
|
|
2782
|
+
variant: isActive ? "outline" : "ghost",
|
|
2783
|
+
size
|
|
2784
|
+
}),
|
|
2785
|
+
className
|
|
2786
|
+
),
|
|
2787
|
+
...props
|
|
2788
|
+
}
|
|
2789
|
+
);
|
|
2790
|
+
PaginationLink.displayName = "PaginationLink";
|
|
2791
|
+
var PaginationPrevious = ({
|
|
2792
|
+
className,
|
|
2793
|
+
...props
|
|
2794
|
+
}) => /* @__PURE__ */ jsxs(
|
|
2795
|
+
PaginationLink,
|
|
2796
|
+
{
|
|
2797
|
+
"aria-label": "Go to previous page",
|
|
2798
|
+
size: "default",
|
|
2799
|
+
className: cn("gap-1 pl-2.5", className),
|
|
2800
|
+
...props,
|
|
2801
|
+
children: [
|
|
2802
|
+
/* @__PURE__ */ jsx(ChevronLeft, { className: "h-4 w-4" }),
|
|
2803
|
+
/* @__PURE__ */ jsx("span", { children: "Previous" })
|
|
2804
|
+
]
|
|
2805
|
+
}
|
|
2806
|
+
);
|
|
2807
|
+
PaginationPrevious.displayName = "PaginationPrevious";
|
|
2808
|
+
var PaginationNext = ({
|
|
2809
|
+
className,
|
|
2810
|
+
...props
|
|
2811
|
+
}) => /* @__PURE__ */ jsxs(
|
|
2812
|
+
PaginationLink,
|
|
2813
|
+
{
|
|
2814
|
+
"aria-label": "Go to next page",
|
|
2815
|
+
size: "default",
|
|
2816
|
+
className: cn("gap-1 pr-2.5", className),
|
|
2817
|
+
...props,
|
|
2818
|
+
children: [
|
|
2819
|
+
/* @__PURE__ */ jsx("span", { children: "Next" }),
|
|
2820
|
+
/* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4" })
|
|
2821
|
+
]
|
|
2822
|
+
}
|
|
2823
|
+
);
|
|
2824
|
+
PaginationNext.displayName = "PaginationNext";
|
|
2825
|
+
var PaginationEllipsis = ({
|
|
2826
|
+
className,
|
|
2827
|
+
...props
|
|
2828
|
+
}) => /* @__PURE__ */ jsxs(
|
|
2829
|
+
"span",
|
|
2830
|
+
{
|
|
2831
|
+
"aria-hidden": true,
|
|
2832
|
+
className: cn("flex h-9 w-9 items-center justify-center", className),
|
|
2833
|
+
...props,
|
|
2834
|
+
children: [
|
|
2835
|
+
/* @__PURE__ */ jsx(MoreHorizontal, { className: "h-4 w-4" }),
|
|
2836
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: "More pages" })
|
|
2837
|
+
]
|
|
2838
|
+
}
|
|
2839
|
+
);
|
|
2840
|
+
PaginationEllipsis.displayName = "PaginationEllipsis";
|
|
2841
|
+
function MinimalPageNumbers({
|
|
2842
|
+
page,
|
|
2843
|
+
totalPages,
|
|
2844
|
+
disabled,
|
|
2845
|
+
onPageChange,
|
|
2846
|
+
pageAria
|
|
2847
|
+
}) {
|
|
2848
|
+
const visiblePages = buildVisiblePages(page, totalPages);
|
|
2849
|
+
return /* @__PURE__ */ jsx("div", { className: "flex items-center gap-3 tabular-nums", "aria-live": "polite", children: visiblePages.map(
|
|
2850
|
+
(item, index) => item === "ellipsis" ? /* @__PURE__ */ jsx(
|
|
2851
|
+
"span",
|
|
2852
|
+
{
|
|
2853
|
+
className: "select-none text-sm text-muted-foreground",
|
|
2854
|
+
"aria-hidden": true,
|
|
2855
|
+
children: "\u2026"
|
|
2856
|
+
},
|
|
2857
|
+
`ellipsis-${index}`
|
|
2858
|
+
) : /* @__PURE__ */ jsx(
|
|
2859
|
+
"button",
|
|
2860
|
+
{
|
|
2861
|
+
type: "button",
|
|
2862
|
+
disabled,
|
|
2863
|
+
"aria-label": pageAria(item),
|
|
2864
|
+
"aria-current": item === page ? "page" : void 0,
|
|
2865
|
+
onClick: () => {
|
|
2866
|
+
if (!disabled && item !== page) onPageChange(item);
|
|
2867
|
+
},
|
|
2868
|
+
className: cn(
|
|
2869
|
+
"min-w-[1.25rem] text-sm transition-colors",
|
|
2870
|
+
item === page ? "font-medium text-primary" : "text-muted-foreground hover:text-foreground",
|
|
2871
|
+
disabled && "pointer-events-none opacity-50"
|
|
2872
|
+
),
|
|
2873
|
+
children: item
|
|
2874
|
+
},
|
|
2875
|
+
item
|
|
2876
|
+
)
|
|
2877
|
+
) });
|
|
2878
|
+
}
|
|
2879
|
+
function ListingPagination({
|
|
2880
|
+
page,
|
|
2881
|
+
totalPages,
|
|
2882
|
+
total,
|
|
2883
|
+
pageSize,
|
|
2884
|
+
itemLabel,
|
|
2885
|
+
disabled = false,
|
|
2886
|
+
variant = "default",
|
|
2887
|
+
className,
|
|
2888
|
+
onPageChange,
|
|
2889
|
+
formatTotal,
|
|
2890
|
+
labels
|
|
2891
|
+
}) {
|
|
2892
|
+
if (totalPages <= 1) return null;
|
|
2893
|
+
const previous = labels?.previous ?? "Anterior";
|
|
2894
|
+
const next = labels?.next ?? "Pr\xF3xima";
|
|
2895
|
+
const previousAria = labels?.previousAria ?? "P\xE1gina anterior";
|
|
2896
|
+
const nextAria = labels?.nextAria ?? "Pr\xF3xima p\xE1gina";
|
|
2897
|
+
const pageAria = labels?.pageAria ?? ((p) => `P\xE1gina ${p}`);
|
|
2898
|
+
const rangeLabel = total != null && pageSize != null ? buildRangeLabel(page, pageSize, total, itemLabel, formatTotal) : `P\xE1gina ${page} de ${totalPages}`;
|
|
2899
|
+
if (variant === "minimal") {
|
|
2900
|
+
const canGoPrev = !disabled && page > 1;
|
|
2901
|
+
const canGoNext = !disabled && page < totalPages;
|
|
2902
|
+
return /* @__PURE__ */ jsxs(
|
|
2903
|
+
"div",
|
|
2904
|
+
{
|
|
2905
|
+
className: cn(
|
|
2906
|
+
"flex items-center justify-between gap-4 text-xs text-muted-foreground",
|
|
2907
|
+
className
|
|
2908
|
+
),
|
|
2909
|
+
children: [
|
|
2910
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
2911
|
+
/* @__PURE__ */ jsx(
|
|
2912
|
+
Button,
|
|
2913
|
+
{
|
|
2914
|
+
type: "button",
|
|
2915
|
+
variant: "ghost",
|
|
2916
|
+
size: "icon",
|
|
2917
|
+
className: "h-7 w-7 shrink-0 rounded-full text-foreground shadow-none hover:translate-y-0 hover:bg-muted hover:text-foreground hover:shadow-none disabled:opacity-40",
|
|
2918
|
+
"aria-label": previousAria,
|
|
2919
|
+
disabled: !canGoPrev,
|
|
2920
|
+
onClick: () => {
|
|
2921
|
+
if (canGoPrev) onPageChange(page - 1);
|
|
2922
|
+
},
|
|
2923
|
+
children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-4 w-4" })
|
|
2924
|
+
}
|
|
2925
|
+
),
|
|
2926
|
+
/* @__PURE__ */ jsx(
|
|
2927
|
+
MinimalPageNumbers,
|
|
2928
|
+
{
|
|
2929
|
+
page,
|
|
2930
|
+
totalPages,
|
|
2931
|
+
disabled,
|
|
2932
|
+
onPageChange,
|
|
2933
|
+
pageAria
|
|
2934
|
+
}
|
|
2935
|
+
),
|
|
2936
|
+
/* @__PURE__ */ jsx(
|
|
2937
|
+
Button,
|
|
2938
|
+
{
|
|
2939
|
+
type: "button",
|
|
2940
|
+
variant: "ghost",
|
|
2941
|
+
size: "icon",
|
|
2942
|
+
className: "h-7 w-7 shrink-0 rounded-full text-foreground shadow-none hover:translate-y-0 hover:bg-muted hover:text-foreground hover:shadow-none disabled:opacity-40",
|
|
2943
|
+
"aria-label": nextAria,
|
|
2944
|
+
disabled: !canGoNext,
|
|
2945
|
+
onClick: () => {
|
|
2946
|
+
if (canGoNext) onPageChange(page + 1);
|
|
2947
|
+
},
|
|
2948
|
+
children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4" })
|
|
2949
|
+
}
|
|
2950
|
+
)
|
|
2951
|
+
] }),
|
|
2952
|
+
/* @__PURE__ */ jsx("span", { className: "tabular-nums", children: rangeLabel })
|
|
2953
|
+
]
|
|
2954
|
+
}
|
|
2955
|
+
);
|
|
2956
|
+
}
|
|
2957
|
+
const visiblePages = buildVisiblePages(page, totalPages);
|
|
2958
|
+
return /* @__PURE__ */ jsxs(
|
|
2959
|
+
"div",
|
|
2960
|
+
{
|
|
2961
|
+
className: cn(
|
|
2962
|
+
"flex flex-col gap-3 rounded-lg border border-border bg-card px-3 py-2.5 sm:flex-row sm:items-center sm:justify-between",
|
|
2963
|
+
className
|
|
2964
|
+
),
|
|
2965
|
+
children: [
|
|
2966
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: rangeLabel }),
|
|
2967
|
+
/* @__PURE__ */ jsx(Pagination, { className: "mx-0 w-auto justify-end", children: /* @__PURE__ */ jsxs(PaginationContent, { children: [
|
|
2968
|
+
/* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsxs(
|
|
2969
|
+
PaginationLink,
|
|
2970
|
+
{
|
|
2971
|
+
href: "#",
|
|
2972
|
+
size: "default",
|
|
2973
|
+
"aria-label": previousAria,
|
|
2974
|
+
className: cn(
|
|
2975
|
+
"gap-1 pl-2.5",
|
|
2976
|
+
(disabled || page <= 1) && "pointer-events-none opacity-50"
|
|
2977
|
+
),
|
|
2978
|
+
onClick: (event) => {
|
|
2979
|
+
event.preventDefault();
|
|
2980
|
+
if (!disabled && page > 1) onPageChange(page - 1);
|
|
2981
|
+
},
|
|
2982
|
+
children: [
|
|
2983
|
+
/* @__PURE__ */ jsx(ChevronLeft, { className: "h-4 w-4" }),
|
|
2984
|
+
/* @__PURE__ */ jsx("span", { children: previous })
|
|
2985
|
+
]
|
|
2986
|
+
}
|
|
2987
|
+
) }),
|
|
2988
|
+
visiblePages.map(
|
|
2989
|
+
(item, index) => item === "ellipsis" ? /* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(PaginationEllipsis, {}) }, `ellipsis-${index}`) : /* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsx(
|
|
2990
|
+
PaginationLink,
|
|
2991
|
+
{
|
|
2992
|
+
href: "#",
|
|
2993
|
+
isActive: item === page,
|
|
2994
|
+
"aria-label": pageAria(item),
|
|
2995
|
+
"aria-current": item === page ? "page" : void 0,
|
|
2996
|
+
className: cn(disabled && "pointer-events-none opacity-50"),
|
|
2997
|
+
onClick: (event) => {
|
|
2998
|
+
event.preventDefault();
|
|
2999
|
+
if (!disabled && item !== page) onPageChange(item);
|
|
3000
|
+
},
|
|
3001
|
+
children: item
|
|
3002
|
+
}
|
|
3003
|
+
) }, item)
|
|
3004
|
+
),
|
|
3005
|
+
/* @__PURE__ */ jsx(PaginationItem, { children: /* @__PURE__ */ jsxs(
|
|
3006
|
+
PaginationLink,
|
|
3007
|
+
{
|
|
3008
|
+
href: "#",
|
|
3009
|
+
size: "default",
|
|
3010
|
+
"aria-label": nextAria,
|
|
3011
|
+
className: cn(
|
|
3012
|
+
"gap-1 pr-2.5",
|
|
3013
|
+
(disabled || page >= totalPages) && "pointer-events-none opacity-50"
|
|
3014
|
+
),
|
|
3015
|
+
onClick: (event) => {
|
|
3016
|
+
event.preventDefault();
|
|
3017
|
+
if (!disabled && page < totalPages) onPageChange(page + 1);
|
|
3018
|
+
},
|
|
3019
|
+
children: [
|
|
3020
|
+
/* @__PURE__ */ jsx("span", { children: next }),
|
|
3021
|
+
/* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4" })
|
|
3022
|
+
]
|
|
3023
|
+
}
|
|
3024
|
+
) })
|
|
3025
|
+
] }) })
|
|
3026
|
+
]
|
|
3027
|
+
}
|
|
3028
|
+
);
|
|
3029
|
+
}
|
|
2644
3030
|
var MenubarMenu = MenubarPrimitive.Menu;
|
|
2645
3031
|
var MenubarGroup = MenubarPrimitive.Group;
|
|
2646
3032
|
var MenubarPortal = MenubarPrimitive.Portal;
|
|
@@ -2890,97 +3276,84 @@ var NavigationMenuIndicator = React11.forwardRef(({ className, ...props }, ref)
|
|
|
2890
3276
|
}
|
|
2891
3277
|
));
|
|
2892
3278
|
NavigationMenuIndicator.displayName = NavigationMenuPrimitive.Indicator.displayName;
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
Pagination.displayName = "Pagination";
|
|
2903
|
-
var PaginationContent = React11.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
|
|
2904
|
-
"ul",
|
|
2905
|
-
{
|
|
2906
|
-
ref,
|
|
2907
|
-
className: cn("flex flex-row items-center gap-1", className),
|
|
2908
|
-
...props
|
|
2909
|
-
}
|
|
2910
|
-
));
|
|
2911
|
-
PaginationContent.displayName = "PaginationContent";
|
|
2912
|
-
var PaginationItem = React11.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx("li", { ref, className: cn("", className), ...props }));
|
|
2913
|
-
PaginationItem.displayName = "PaginationItem";
|
|
2914
|
-
var PaginationLink = ({
|
|
2915
|
-
className,
|
|
2916
|
-
isActive,
|
|
2917
|
-
size = "icon",
|
|
2918
|
-
...props
|
|
2919
|
-
}) => /* @__PURE__ */ jsx(
|
|
2920
|
-
"a",
|
|
2921
|
-
{
|
|
2922
|
-
"aria-current": isActive ? "page" : void 0,
|
|
2923
|
-
className: cn(
|
|
2924
|
-
buttonVariants({
|
|
2925
|
-
variant: isActive ? "outline" : "ghost",
|
|
2926
|
-
size
|
|
2927
|
-
}),
|
|
2928
|
-
className
|
|
2929
|
-
),
|
|
2930
|
-
...props
|
|
2931
|
-
}
|
|
2932
|
-
);
|
|
2933
|
-
PaginationLink.displayName = "PaginationLink";
|
|
2934
|
-
var PaginationPrevious = ({
|
|
2935
|
-
className,
|
|
2936
|
-
...props
|
|
2937
|
-
}) => /* @__PURE__ */ jsxs(
|
|
2938
|
-
PaginationLink,
|
|
2939
|
-
{
|
|
2940
|
-
"aria-label": "Go to previous page",
|
|
2941
|
-
size: "default",
|
|
2942
|
-
className: cn("gap-1 pl-2.5", className),
|
|
2943
|
-
...props,
|
|
2944
|
-
children: [
|
|
2945
|
-
/* @__PURE__ */ jsx(ChevronLeft, { className: "h-4 w-4" }),
|
|
2946
|
-
/* @__PURE__ */ jsx("span", { children: "Previous" })
|
|
2947
|
-
]
|
|
2948
|
-
}
|
|
2949
|
-
);
|
|
2950
|
-
PaginationPrevious.displayName = "PaginationPrevious";
|
|
2951
|
-
var PaginationNext = ({
|
|
2952
|
-
className,
|
|
2953
|
-
...props
|
|
2954
|
-
}) => /* @__PURE__ */ jsxs(
|
|
2955
|
-
PaginationLink,
|
|
2956
|
-
{
|
|
2957
|
-
"aria-label": "Go to next page",
|
|
2958
|
-
size: "default",
|
|
2959
|
-
className: cn("gap-1 pr-2.5", className),
|
|
2960
|
-
...props,
|
|
2961
|
-
children: [
|
|
2962
|
-
/* @__PURE__ */ jsx("span", { children: "Next" }),
|
|
2963
|
-
/* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4" })
|
|
2964
|
-
]
|
|
2965
|
-
}
|
|
2966
|
-
);
|
|
2967
|
-
PaginationNext.displayName = "PaginationNext";
|
|
2968
|
-
var PaginationEllipsis = ({
|
|
3279
|
+
function PageHeader({
|
|
3280
|
+
label,
|
|
3281
|
+
title,
|
|
3282
|
+
description,
|
|
3283
|
+
titleLoading = false,
|
|
3284
|
+
badge,
|
|
3285
|
+
meta,
|
|
3286
|
+
back,
|
|
3287
|
+
children,
|
|
2969
3288
|
className,
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
3289
|
+
titleClassName,
|
|
3290
|
+
descriptionClassName,
|
|
3291
|
+
titleSkeletonClassName
|
|
3292
|
+
}) {
|
|
3293
|
+
const titleBlock = titleLoading ? /* @__PURE__ */ jsx(
|
|
3294
|
+
Skeleton,
|
|
3295
|
+
{
|
|
3296
|
+
className: cn(
|
|
3297
|
+
"h-7 w-48 max-w-full",
|
|
3298
|
+
label && "mt-1",
|
|
3299
|
+
titleSkeletonClassName
|
|
3300
|
+
),
|
|
3301
|
+
"aria-label": "Loading"
|
|
3302
|
+
}
|
|
3303
|
+
) : /* @__PURE__ */ jsxs(
|
|
3304
|
+
"div",
|
|
3305
|
+
{
|
|
3306
|
+
className: cn(
|
|
3307
|
+
"flex min-w-0 flex-wrap items-center gap-x-2.5 gap-y-1",
|
|
3308
|
+
label && "mt-1"
|
|
3309
|
+
),
|
|
3310
|
+
children: [
|
|
3311
|
+
/* @__PURE__ */ jsx(
|
|
3312
|
+
"h1",
|
|
3313
|
+
{
|
|
3314
|
+
className: cn(
|
|
3315
|
+
"text-xl font-bold tracking-tight",
|
|
3316
|
+
titleClassName
|
|
3317
|
+
),
|
|
3318
|
+
children: title
|
|
3319
|
+
}
|
|
3320
|
+
),
|
|
3321
|
+
badge
|
|
3322
|
+
]
|
|
3323
|
+
}
|
|
3324
|
+
);
|
|
3325
|
+
const primary = /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
|
|
3326
|
+
back,
|
|
3327
|
+
label ? /* @__PURE__ */ jsx("p", { className: "text-xs font-medium uppercase tracking-wide text-muted-foreground", children: label }) : null,
|
|
3328
|
+
meta ? /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-4", children: [
|
|
3329
|
+
titleBlock,
|
|
3330
|
+
/* @__PURE__ */ jsx("div", { className: "shrink-0", children: meta })
|
|
3331
|
+
] }) : titleBlock,
|
|
3332
|
+
description ? /* @__PURE__ */ jsx(
|
|
3333
|
+
"p",
|
|
3334
|
+
{
|
|
3335
|
+
className: cn(
|
|
3336
|
+
"mt-1 max-w-2xl text-sm text-muted-foreground",
|
|
3337
|
+
descriptionClassName
|
|
3338
|
+
),
|
|
3339
|
+
children: description
|
|
3340
|
+
}
|
|
3341
|
+
) : null
|
|
3342
|
+
] });
|
|
3343
|
+
return /* @__PURE__ */ jsxs(
|
|
3344
|
+
"header",
|
|
3345
|
+
{
|
|
3346
|
+
className: cn(
|
|
3347
|
+
children ? "flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between" : "w-full",
|
|
3348
|
+
className
|
|
3349
|
+
),
|
|
3350
|
+
children: [
|
|
3351
|
+
primary,
|
|
3352
|
+
children ? /* @__PURE__ */ jsx("div", { className: "shrink-0", children }) : null
|
|
3353
|
+
]
|
|
3354
|
+
}
|
|
3355
|
+
);
|
|
3356
|
+
}
|
|
2984
3357
|
var Popover = PopoverPrimitive.Root;
|
|
2985
3358
|
var PopoverTrigger = PopoverPrimitive.Trigger;
|
|
2986
3359
|
var PopoverContent = React11.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx(
|
|
@@ -3108,6 +3481,330 @@ var ScrollBar = React11.forwardRef(({ className, orientation = "vertical", ...pr
|
|
|
3108
3481
|
}
|
|
3109
3482
|
));
|
|
3110
3483
|
ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName;
|
|
3484
|
+
function mergeItems(prev, next) {
|
|
3485
|
+
if (next.length === 0) return prev;
|
|
3486
|
+
const seen = new Set(prev.map((item) => item.id));
|
|
3487
|
+
const out = [...prev];
|
|
3488
|
+
for (const item of next) {
|
|
3489
|
+
if (seen.has(item.id)) continue;
|
|
3490
|
+
seen.add(item.id);
|
|
3491
|
+
out.push(item);
|
|
3492
|
+
}
|
|
3493
|
+
return out;
|
|
3494
|
+
}
|
|
3495
|
+
function SearchableSelect({
|
|
3496
|
+
value,
|
|
3497
|
+
onChange,
|
|
3498
|
+
allValue = "all",
|
|
3499
|
+
allLabel,
|
|
3500
|
+
searchPlaceholder,
|
|
3501
|
+
loadItems,
|
|
3502
|
+
resolveLabel,
|
|
3503
|
+
pageSize = 50,
|
|
3504
|
+
triggerClassName,
|
|
3505
|
+
icon,
|
|
3506
|
+
nestedInPopover = false,
|
|
3507
|
+
disabled = false,
|
|
3508
|
+
resetKey,
|
|
3509
|
+
emptyLabel = "Nenhum resultado.",
|
|
3510
|
+
loadingLabel = "Buscando\u2026",
|
|
3511
|
+
loadingMoreLabel = "Carregando...",
|
|
3512
|
+
debounceMs = 300
|
|
3513
|
+
}) {
|
|
3514
|
+
const [open, setOpen] = React11.useState(false);
|
|
3515
|
+
const [search, setSearch] = React11.useState("");
|
|
3516
|
+
const [debouncedSearch, setDebouncedSearch] = React11.useState("");
|
|
3517
|
+
const [items, setItems] = React11.useState([]);
|
|
3518
|
+
const [loading, setLoading] = React11.useState(false);
|
|
3519
|
+
const [loadingMore, setLoadingMore] = React11.useState(false);
|
|
3520
|
+
const [hasMore, setHasMore] = React11.useState(false);
|
|
3521
|
+
const [labelById, setLabelById] = React11.useState({});
|
|
3522
|
+
const listRef = React11.useRef(null);
|
|
3523
|
+
const loadMoreSentinelRef = React11.useRef(null);
|
|
3524
|
+
const fetchOffsetRef = React11.useRef(0);
|
|
3525
|
+
const loadMoreLockRef = React11.useRef(false);
|
|
3526
|
+
const loadItemsRef = React11.useRef(loadItems);
|
|
3527
|
+
const resolveLabelRef = React11.useRef(resolveLabel);
|
|
3528
|
+
React11.useEffect(() => {
|
|
3529
|
+
loadItemsRef.current = loadItems;
|
|
3530
|
+
}, [loadItems]);
|
|
3531
|
+
React11.useEffect(() => {
|
|
3532
|
+
resolveLabelRef.current = resolveLabel;
|
|
3533
|
+
}, [resolveLabel]);
|
|
3534
|
+
React11.useEffect(() => {
|
|
3535
|
+
const t = window.setTimeout(() => setDebouncedSearch(search), debounceMs);
|
|
3536
|
+
return () => window.clearTimeout(t);
|
|
3537
|
+
}, [search, debounceMs]);
|
|
3538
|
+
const loadInitialItems = React11.useCallback(async (q) => {
|
|
3539
|
+
setLoading(true);
|
|
3540
|
+
setHasMore(false);
|
|
3541
|
+
fetchOffsetRef.current = 0;
|
|
3542
|
+
loadMoreLockRef.current = false;
|
|
3543
|
+
try {
|
|
3544
|
+
const { items: list, hasMore: more } = await loadItemsRef.current({
|
|
3545
|
+
query: q,
|
|
3546
|
+
limit: pageSize,
|
|
3547
|
+
offset: 0
|
|
3548
|
+
});
|
|
3549
|
+
fetchOffsetRef.current = list.length;
|
|
3550
|
+
setItems(list);
|
|
3551
|
+
setHasMore(more);
|
|
3552
|
+
} finally {
|
|
3553
|
+
setLoading(false);
|
|
3554
|
+
}
|
|
3555
|
+
}, [pageSize]);
|
|
3556
|
+
const loadMoreItems = React11.useCallback(async () => {
|
|
3557
|
+
if (loadMoreLockRef.current || loading || loadingMore || !hasMore) return;
|
|
3558
|
+
loadMoreLockRef.current = true;
|
|
3559
|
+
setLoadingMore(true);
|
|
3560
|
+
try {
|
|
3561
|
+
const { items: next, hasMore: more } = await loadItemsRef.current({
|
|
3562
|
+
query: debouncedSearch,
|
|
3563
|
+
limit: pageSize,
|
|
3564
|
+
offset: fetchOffsetRef.current
|
|
3565
|
+
});
|
|
3566
|
+
setItems((prev) => {
|
|
3567
|
+
const merged = mergeItems(prev, next);
|
|
3568
|
+
fetchOffsetRef.current = merged.length;
|
|
3569
|
+
if (merged.length === prev.length) {
|
|
3570
|
+
setHasMore(false);
|
|
3571
|
+
} else {
|
|
3572
|
+
setHasMore(more);
|
|
3573
|
+
}
|
|
3574
|
+
return merged;
|
|
3575
|
+
});
|
|
3576
|
+
} finally {
|
|
3577
|
+
setLoadingMore(false);
|
|
3578
|
+
loadMoreLockRef.current = false;
|
|
3579
|
+
}
|
|
3580
|
+
}, [debouncedSearch, hasMore, loading, loadingMore, pageSize]);
|
|
3581
|
+
React11.useEffect(() => {
|
|
3582
|
+
if (!open) return;
|
|
3583
|
+
void loadInitialItems(debouncedSearch);
|
|
3584
|
+
}, [open, debouncedSearch, loadInitialItems]);
|
|
3585
|
+
React11.useEffect(() => {
|
|
3586
|
+
if (!open || loading || loadingMore || !hasMore) return;
|
|
3587
|
+
const root = listRef.current;
|
|
3588
|
+
const sentinel = loadMoreSentinelRef.current;
|
|
3589
|
+
if (!root || !sentinel) return;
|
|
3590
|
+
const observer = new IntersectionObserver(
|
|
3591
|
+
(entries) => {
|
|
3592
|
+
if (entries.some((entry) => entry.isIntersecting)) {
|
|
3593
|
+
void loadMoreItems();
|
|
3594
|
+
}
|
|
3595
|
+
},
|
|
3596
|
+
{ root, rootMargin: "64px" }
|
|
3597
|
+
);
|
|
3598
|
+
observer.observe(sentinel);
|
|
3599
|
+
return () => observer.disconnect();
|
|
3600
|
+
}, [open, loading, loadingMore, hasMore, loadMoreItems, items.length]);
|
|
3601
|
+
React11.useEffect(() => {
|
|
3602
|
+
if (!open || loading || loadingMore || !hasMore) return;
|
|
3603
|
+
const root = listRef.current;
|
|
3604
|
+
if (!root) return;
|
|
3605
|
+
const frame = requestAnimationFrame(() => {
|
|
3606
|
+
if (root.scrollHeight <= root.clientHeight + 8) {
|
|
3607
|
+
void loadMoreItems();
|
|
3608
|
+
}
|
|
3609
|
+
});
|
|
3610
|
+
return () => cancelAnimationFrame(frame);
|
|
3611
|
+
}, [open, loading, loadingMore, hasMore, loadMoreItems, items.length]);
|
|
3612
|
+
React11.useEffect(() => {
|
|
3613
|
+
setItems([]);
|
|
3614
|
+
setLabelById({});
|
|
3615
|
+
setSearch("");
|
|
3616
|
+
setDebouncedSearch("");
|
|
3617
|
+
}, [resetKey]);
|
|
3618
|
+
React11.useEffect(() => {
|
|
3619
|
+
if (value === allValue) return;
|
|
3620
|
+
let cancelled = false;
|
|
3621
|
+
void (async () => {
|
|
3622
|
+
const resolver = resolveLabelRef.current;
|
|
3623
|
+
if (resolver) {
|
|
3624
|
+
const label = await resolver(value);
|
|
3625
|
+
if (cancelled || !label) return;
|
|
3626
|
+
setLabelById(
|
|
3627
|
+
(prev) => prev[value] ? prev : { ...prev, [value]: label }
|
|
3628
|
+
);
|
|
3629
|
+
return;
|
|
3630
|
+
}
|
|
3631
|
+
const { items: list } = await loadItemsRef.current({
|
|
3632
|
+
query: value,
|
|
3633
|
+
limit: 30,
|
|
3634
|
+
offset: 0
|
|
3635
|
+
});
|
|
3636
|
+
if (cancelled) return;
|
|
3637
|
+
const hit = list.find((i) => i.id === value);
|
|
3638
|
+
if (hit?.label) {
|
|
3639
|
+
setLabelById(
|
|
3640
|
+
(prev) => prev[value] ? prev : { ...prev, [value]: hit.label }
|
|
3641
|
+
);
|
|
3642
|
+
}
|
|
3643
|
+
})();
|
|
3644
|
+
return () => {
|
|
3645
|
+
cancelled = true;
|
|
3646
|
+
};
|
|
3647
|
+
}, [value, allValue, resetKey]);
|
|
3648
|
+
const triggerLabel = React11.useMemo(() => {
|
|
3649
|
+
if (value === allValue) return allLabel;
|
|
3650
|
+
const fromCache = labelById[value];
|
|
3651
|
+
if (fromCache) return fromCache;
|
|
3652
|
+
const fromList = items.find((i) => i.id === value);
|
|
3653
|
+
if (fromList?.label) return fromList.label;
|
|
3654
|
+
return value;
|
|
3655
|
+
}, [value, allValue, allLabel, labelById, items]);
|
|
3656
|
+
const listRows = React11.useMemo(() => {
|
|
3657
|
+
if (value === allValue) return items;
|
|
3658
|
+
const has = items.some((i) => i.id === value);
|
|
3659
|
+
if (has) return items;
|
|
3660
|
+
const label = labelById[value] || value;
|
|
3661
|
+
return [{ id: value, label, secondary: value }, ...items];
|
|
3662
|
+
}, [items, value, allValue, labelById]);
|
|
3663
|
+
React11.useEffect(() => {
|
|
3664
|
+
if (disabled) setOpen(false);
|
|
3665
|
+
}, [disabled]);
|
|
3666
|
+
const isFiltered = value !== allValue && value.trim() !== "";
|
|
3667
|
+
return /* @__PURE__ */ jsxs(
|
|
3668
|
+
Popover,
|
|
3669
|
+
{
|
|
3670
|
+
modal: false,
|
|
3671
|
+
open: disabled ? false : open,
|
|
3672
|
+
onOpenChange: (v) => {
|
|
3673
|
+
if (disabled) return;
|
|
3674
|
+
setOpen(v);
|
|
3675
|
+
if (!v) setSearch("");
|
|
3676
|
+
},
|
|
3677
|
+
children: [
|
|
3678
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
|
|
3679
|
+
Dropdown,
|
|
3680
|
+
{
|
|
3681
|
+
open,
|
|
3682
|
+
isFiltered,
|
|
3683
|
+
disabled,
|
|
3684
|
+
className: cn(
|
|
3685
|
+
triggerClassName,
|
|
3686
|
+
disabled && "cursor-not-allowed opacity-50 hover:translate-y-0"
|
|
3687
|
+
),
|
|
3688
|
+
children: [
|
|
3689
|
+
/* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-1 items-center gap-2 text-[14px]", children: [
|
|
3690
|
+
icon ? /* @__PURE__ */ jsx(
|
|
3691
|
+
"span",
|
|
3692
|
+
{
|
|
3693
|
+
className: cn(
|
|
3694
|
+
"h-4 w-4 shrink-0",
|
|
3695
|
+
isFiltered ? "text-primary" : "text-muted-foreground"
|
|
3696
|
+
),
|
|
3697
|
+
"aria-hidden": true,
|
|
3698
|
+
children: icon
|
|
3699
|
+
}
|
|
3700
|
+
) : null,
|
|
3701
|
+
/* @__PURE__ */ jsx(
|
|
3702
|
+
"span",
|
|
3703
|
+
{
|
|
3704
|
+
className: cn("truncate", isFiltered && "text-foreground"),
|
|
3705
|
+
title: value !== allValue ? triggerLabel : void 0,
|
|
3706
|
+
children: triggerLabel
|
|
3707
|
+
}
|
|
3708
|
+
)
|
|
3709
|
+
] }),
|
|
3710
|
+
/* @__PURE__ */ jsx(ChevronsUpDown, { className: "h-3.5 w-3.5 shrink-0 opacity-50" })
|
|
3711
|
+
]
|
|
3712
|
+
}
|
|
3713
|
+
) }),
|
|
3714
|
+
/* @__PURE__ */ jsx(
|
|
3715
|
+
PopoverContent,
|
|
3716
|
+
{
|
|
3717
|
+
className: cn(
|
|
3718
|
+
"w-[max(var(--radix-popover-trigger-width),280px)] max-w-[min(90vw,420px)] p-0",
|
|
3719
|
+
nestedInPopover && "z-[100]"
|
|
3720
|
+
),
|
|
3721
|
+
align: "start",
|
|
3722
|
+
onOpenAutoFocus: nestedInPopover ? (e) => e.preventDefault() : void 0,
|
|
3723
|
+
children: /* @__PURE__ */ jsxs(Command, { shouldFilter: false, children: [
|
|
3724
|
+
/* @__PURE__ */ jsx(
|
|
3725
|
+
CommandInput,
|
|
3726
|
+
{
|
|
3727
|
+
placeholder: searchPlaceholder,
|
|
3728
|
+
value: search,
|
|
3729
|
+
onValueChange: setSearch,
|
|
3730
|
+
className: "h-9 text-xs"
|
|
3731
|
+
}
|
|
3732
|
+
),
|
|
3733
|
+
/* @__PURE__ */ jsx(CommandList, { ref: listRef, children: loading ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center gap-2 py-6 text-sm text-muted-foreground", children: [
|
|
3734
|
+
/* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin" }),
|
|
3735
|
+
loadingLabel
|
|
3736
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3737
|
+
/* @__PURE__ */ jsx(CommandEmpty, { className: "text-sm", children: emptyLabel }),
|
|
3738
|
+
/* @__PURE__ */ jsxs(CommandGroup, { children: [
|
|
3739
|
+
/* @__PURE__ */ jsxs(
|
|
3740
|
+
CommandItem,
|
|
3741
|
+
{
|
|
3742
|
+
value: "__all__",
|
|
3743
|
+
className: "text-xs",
|
|
3744
|
+
onSelect: () => {
|
|
3745
|
+
onChange(allValue);
|
|
3746
|
+
setOpen(false);
|
|
3747
|
+
},
|
|
3748
|
+
children: [
|
|
3749
|
+
value === allValue ? /* @__PURE__ */ jsx(Check, { className: "mr-1 h-3.5 w-3.5 shrink-0" }) : /* @__PURE__ */ jsx("span", { className: "mr-1 h-3.5 w-3.5 shrink-0" }),
|
|
3750
|
+
allLabel
|
|
3751
|
+
]
|
|
3752
|
+
}
|
|
3753
|
+
),
|
|
3754
|
+
listRows.map((item) => /* @__PURE__ */ jsxs(
|
|
3755
|
+
CommandItem,
|
|
3756
|
+
{
|
|
3757
|
+
value: `${item.id} ${item.label}`,
|
|
3758
|
+
className: cn(
|
|
3759
|
+
"mt-0.5 items-start gap-1.5 text-xs",
|
|
3760
|
+
value === item.id && "bg-primary/45"
|
|
3761
|
+
),
|
|
3762
|
+
onSelect: () => {
|
|
3763
|
+
onChange(item.id);
|
|
3764
|
+
setLabelById((prev) => ({
|
|
3765
|
+
...prev,
|
|
3766
|
+
[item.id]: item.label || item.id
|
|
3767
|
+
}));
|
|
3768
|
+
setOpen(false);
|
|
3769
|
+
},
|
|
3770
|
+
children: [
|
|
3771
|
+
value === item.id ? /* @__PURE__ */ jsx(Check, { className: "h-3.5 w-3.5 shrink-0" }) : /* @__PURE__ */ jsx("span", { className: "h-3.5 w-3.5 shrink-0" }),
|
|
3772
|
+
/* @__PURE__ */ jsx("div", { className: "flex min-w-0 flex-1 items-start gap-2", children: item.label ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3773
|
+
/* @__PURE__ */ jsx(
|
|
3774
|
+
"span",
|
|
3775
|
+
{
|
|
3776
|
+
className: "min-w-0 flex-1 break-words font-medium leading-snug",
|
|
3777
|
+
title: item.label,
|
|
3778
|
+
children: item.label
|
|
3779
|
+
}
|
|
3780
|
+
),
|
|
3781
|
+
item.secondary ?? item.id ? /* @__PURE__ */ jsx("span", { className: "shrink-0 self-start text-right font-mono text-[11px] opacity-80", children: item.secondary ?? item.id }) : null
|
|
3782
|
+
] }) : /* @__PURE__ */ jsx("span", { className: "font-mono", children: item.id }) })
|
|
3783
|
+
]
|
|
3784
|
+
},
|
|
3785
|
+
item.id
|
|
3786
|
+
)),
|
|
3787
|
+
hasMore ? /* @__PURE__ */ jsx(
|
|
3788
|
+
"div",
|
|
3789
|
+
{
|
|
3790
|
+
ref: loadMoreSentinelRef,
|
|
3791
|
+
className: "h-px w-full shrink-0",
|
|
3792
|
+
"aria-hidden": true
|
|
3793
|
+
}
|
|
3794
|
+
) : null,
|
|
3795
|
+
loadingMore ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center gap-2 py-3 text-xs text-muted-foreground", children: [
|
|
3796
|
+
/* @__PURE__ */ jsx(Loader2, { className: "h-3.5 w-3.5 animate-spin" }),
|
|
3797
|
+
loadingMoreLabel
|
|
3798
|
+
] }) : null
|
|
3799
|
+
] })
|
|
3800
|
+
] }) })
|
|
3801
|
+
] })
|
|
3802
|
+
}
|
|
3803
|
+
)
|
|
3804
|
+
]
|
|
3805
|
+
}
|
|
3806
|
+
);
|
|
3807
|
+
}
|
|
3111
3808
|
var Select = SelectPrimitive.Root;
|
|
3112
3809
|
var SelectGroup = SelectPrimitive.Group;
|
|
3113
3810
|
var SelectValue = SelectPrimitive.Value;
|
|
@@ -3618,6 +4315,6 @@ var ToggleGroupItem = React11.forwardRef(({ className, children, variant, size,
|
|
|
3618
4315
|
});
|
|
3619
4316
|
ToggleGroupItem.displayName = ToggleGroupPrimitive.Item.displayName;
|
|
3620
4317
|
|
|
3621
|
-
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AppChromeHeader, AppChromeSidebar, AspectRatio, Avatar, AvatarFallback, AvatarImage, Badge, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, Calendar, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, ChartContainer, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent, Checkbox, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, Dropdown, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, HoverCard, HoverCardContent, HoverCardTrigger, Input, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, Label3 as Label, Menubar, MenubarCheckboxItem, MenubarContent, MenubarGroup, MenubarItem, MenubarLabel, MenubarMenu, MenubarPortal, MenubarRadioGroup, MenubarRadioItem, MenubarSeparator, MenubarShortcut, MenubarSub, MenubarSubContent, MenubarSubTrigger, MenubarTrigger, NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, Popover, PopoverContent, PopoverTrigger, Progress, RadioGroup4 as RadioGroup, RadioGroupItem, ResizableHandle, ResizablePanel, ResizablePanelGroup, ScrollArea, ScrollBar, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, Slider, Toaster as SonnerToaster, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toast, ToastAction, ToastClose, ToastDescription, ToastProvider, ToastTitle, ToastViewport, Toaster2 as Toaster, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, badgeVariants, buttonVariants, cn, inputVariants, navigationMenuTriggerStyle, toast, toggleVariants, useFormField, useIsMobile, useSidebar, useToast };
|
|
4318
|
+
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertTitle, AppChromeBrand, AppChromeHeader, AppChromeSidebar, AspectRatio, Avatar, AvatarFallback, AvatarImage, Badge, Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, Button, Calendar, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, ChartCard, ChartContainer, ChartLegend, ChartLegendContent, ChartStyle, ChartTooltip, ChartTooltipContent, Checkbox, Collapsible, CollapsibleContent2 as CollapsibleContent, CollapsibleTrigger2 as CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerTitle, DrawerTrigger, Dropdown, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, HoverCard, HoverCardContent, HoverCardTrigger, Input, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, Label3 as Label, ListingPagination, Menubar, MenubarCheckboxItem, MenubarContent, MenubarGroup, MenubarItem, MenubarLabel, MenubarMenu, MenubarPortal, MenubarRadioGroup, MenubarRadioItem, MenubarSeparator, MenubarShortcut, MenubarSub, MenubarSubContent, MenubarSubTrigger, MenubarTrigger, NavigationMenu, NavigationMenuContent, NavigationMenuIndicator, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, NavigationMenuViewport, PageHeader, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, Popover, PopoverContent, PopoverTrigger, Progress, RadioGroup4 as RadioGroup, RadioGroupItem, ResizableHandle, ResizablePanel, ResizablePanelGroup, ScrollArea, ScrollBar, SearchableSelect, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetPortal, SheetTitle, SheetTrigger, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, Slider, Toaster as SonnerToaster, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toast, ToastAction, ToastClose, ToastDescription, ToastProvider, ToastTitle, ToastViewport, Toaster2 as Toaster, Toggle, ToggleGroup, ToggleGroupItem, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, badgeVariants, buildRangeLabel, buildVisiblePages, buttonVariants, cn, inputVariants, navigationMenuTriggerStyle, toast, toggleVariants, useFormField, useIsMobile, useSidebar, useToast };
|
|
3622
4319
|
//# sourceMappingURL=index.js.map
|
|
3623
4320
|
//# sourceMappingURL=index.js.map
|