@andreagiugni/tailwind-dashboard-ui 1.0.22 → 1.0.23
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 +5 -3
- package/dist/index.cjs +208 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +32 -1
- package/dist/index.d.ts +32 -1
- package/dist/index.js +208 -26
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -365,6 +365,8 @@ interface PopoverProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "conte
|
|
|
365
365
|
closeOnOutsideClick?: boolean;
|
|
366
366
|
/** Close when pressing Escape. */
|
|
367
367
|
closeOnEsc?: boolean;
|
|
368
|
+
/** Render panel under document.body to avoid clipping inside cards/overflow containers. */
|
|
369
|
+
portal?: boolean;
|
|
368
370
|
/** Panel content. */
|
|
369
371
|
children: React.ReactNode;
|
|
370
372
|
}
|
|
@@ -418,6 +420,35 @@ interface ProgressProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "colo
|
|
|
418
420
|
}
|
|
419
421
|
declare const Progress: React.FC<ProgressProps>;
|
|
420
422
|
|
|
423
|
+
type PollResultsColor = "primary" | "success" | "error" | "warning" | "info" | "light" | "dark";
|
|
424
|
+
type PollResultsSize = "sm" | "md" | "lg";
|
|
425
|
+
interface PollResultsSeries {
|
|
426
|
+
label?: React.ReactNode;
|
|
427
|
+
value: number;
|
|
428
|
+
color?: PollResultsColor;
|
|
429
|
+
fillColor?: string;
|
|
430
|
+
ariaLabel?: string;
|
|
431
|
+
}
|
|
432
|
+
interface PollResultsOption {
|
|
433
|
+
label: React.ReactNode;
|
|
434
|
+
value?: number;
|
|
435
|
+
color?: PollResultsColor;
|
|
436
|
+
fillColor?: string;
|
|
437
|
+
ariaLabel?: string;
|
|
438
|
+
series?: PollResultsSeries[];
|
|
439
|
+
}
|
|
440
|
+
interface PollResultsProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "color">, ColorOverrideProps {
|
|
441
|
+
options: PollResultsOption[];
|
|
442
|
+
maxValue?: number;
|
|
443
|
+
size?: PollResultsSize;
|
|
444
|
+
color?: PollResultsColor;
|
|
445
|
+
trackColor?: string;
|
|
446
|
+
showValueLabel?: boolean;
|
|
447
|
+
showSeriesLabels?: boolean;
|
|
448
|
+
valueFormatter?: (value: number, percent: number) => React.ReactNode;
|
|
449
|
+
}
|
|
450
|
+
declare const PollResults: React.FC<PollResultsProps>;
|
|
451
|
+
|
|
421
452
|
type SpinnerColor = "primary" | "success" | "error" | "warning" | "info" | "light" | "dark";
|
|
422
453
|
type SpinnerSize = "sm" | "md" | "lg";
|
|
423
454
|
interface SpinnerProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, "color">, ColorOverrideProps {
|
|
@@ -636,4 +667,4 @@ interface SliderProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>,
|
|
|
636
667
|
}
|
|
637
668
|
declare const Slider: React.FC<SliderProps>;
|
|
638
669
|
|
|
639
|
-
export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, type AccordionSelectionMode, Alert, type AlertProps, type AlertVariant, Avatar, type AvatarProps, type AvatarSize, type AvatarStatus, AvatarText, type AvatarTextProps, Badge, type BadgeColor, type BadgeProps, type BadgeSize, type BadgeVariant, Breadcrumb, type BreadcrumbItem, type BreadcrumbProps, Button, type ButtonProps, Card, type CardProps, Checkbox, type CheckboxProps, Chip, type ChipColor, type ChipProps, type ChipSize, type ChipVariant, Code, type CodeColor, type CodeProps, type CodeSize, ColorOverrideProps, DatePicker, type DatePickerProps, DateTimePicker, type DateTimePickerProps, Drawer, type DrawerPlacement, type DrawerProps, Dropdown, DropdownItem, type DropdownItemProps, type DropdownItemVariant, type DropdownProps, Dropzone, type DropzoneProps, FileInput, type FileInputProps, Form, type FormProps, Input, type InputProps, Label, type LabelProps, Modal, type ModalProps, type ModalVariant, MultiSelect, type MultiSelectProps, Pagination, type PaginationAlign, type PaginationProps, PasswordInput, type PasswordInputProps, Popover, type PopoverPlacement, type PopoverProps, Progress, type ProgressColor, type ProgressProps, type ProgressSize, Radio, type RadioProps, RadioSm, type RadioSmProps, Ribbon, type RibbonColor, type RibbonPosition, type RibbonProps, type RibbonVariant, Select, type SelectOption, type SelectProps, Skeleton, type SkeletonProps, Slider, type SliderColor, type SliderProps, Snippet, type SnippetProps, type SnippetSize, type SortDirection, Spinner, type SpinnerColor, type SpinnerProps, type SpinnerSize, Switch, type SwitchProps, Tab, type TabProps, Table, TableBody, TableCell, type TableCellProps, type TableColumn, TableHeader, type TableProps, TableRow, type TableRowProps, type TableSectionProps, Tabs, type TabsProps, type TabsVariant, TextArea, type TextAreaProps, ThemeToggleButton, type ThemeToggleButtonProps, Toast, type ToastProps, type ToastVariant, Tooltip, type TooltipPlacement, type TooltipProps, cn };
|
|
670
|
+
export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, type AccordionSelectionMode, Alert, type AlertProps, type AlertVariant, Avatar, type AvatarProps, type AvatarSize, type AvatarStatus, AvatarText, type AvatarTextProps, Badge, type BadgeColor, type BadgeProps, type BadgeSize, type BadgeVariant, Breadcrumb, type BreadcrumbItem, type BreadcrumbProps, Button, type ButtonProps, Card, type CardProps, Checkbox, type CheckboxProps, Chip, type ChipColor, type ChipProps, type ChipSize, type ChipVariant, Code, type CodeColor, type CodeProps, type CodeSize, ColorOverrideProps, DatePicker, type DatePickerProps, DateTimePicker, type DateTimePickerProps, Drawer, type DrawerPlacement, type DrawerProps, Dropdown, DropdownItem, type DropdownItemProps, type DropdownItemVariant, type DropdownProps, Dropzone, type DropzoneProps, FileInput, type FileInputProps, Form, type FormProps, Input, type InputProps, Label, type LabelProps, Modal, type ModalProps, type ModalVariant, MultiSelect, type MultiSelectProps, Pagination, type PaginationAlign, type PaginationProps, PasswordInput, type PasswordInputProps, PollResults, type PollResultsColor, type PollResultsOption, type PollResultsProps, type PollResultsSeries, type PollResultsSize, Popover, type PopoverPlacement, type PopoverProps, Progress, type ProgressColor, type ProgressProps, type ProgressSize, Radio, type RadioProps, RadioSm, type RadioSmProps, Ribbon, type RibbonColor, type RibbonPosition, type RibbonProps, type RibbonVariant, Select, type SelectOption, type SelectProps, Skeleton, type SkeletonProps, Slider, type SliderColor, type SliderProps, Snippet, type SnippetProps, type SnippetSize, type SortDirection, Spinner, type SpinnerColor, type SpinnerProps, type SpinnerSize, Switch, type SwitchProps, Tab, type TabProps, Table, TableBody, TableCell, type TableCellProps, type TableColumn, TableHeader, type TableProps, TableRow, type TableRowProps, type TableSectionProps, Tabs, type TabsProps, type TabsVariant, TextArea, type TextAreaProps, ThemeToggleButton, type ThemeToggleButtonProps, Toast, type ToastProps, type ToastVariant, Tooltip, type TooltipPlacement, type TooltipProps, cn };
|
package/dist/index.d.ts
CHANGED
|
@@ -365,6 +365,8 @@ interface PopoverProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "conte
|
|
|
365
365
|
closeOnOutsideClick?: boolean;
|
|
366
366
|
/** Close when pressing Escape. */
|
|
367
367
|
closeOnEsc?: boolean;
|
|
368
|
+
/** Render panel under document.body to avoid clipping inside cards/overflow containers. */
|
|
369
|
+
portal?: boolean;
|
|
368
370
|
/** Panel content. */
|
|
369
371
|
children: React.ReactNode;
|
|
370
372
|
}
|
|
@@ -418,6 +420,35 @@ interface ProgressProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "colo
|
|
|
418
420
|
}
|
|
419
421
|
declare const Progress: React.FC<ProgressProps>;
|
|
420
422
|
|
|
423
|
+
type PollResultsColor = "primary" | "success" | "error" | "warning" | "info" | "light" | "dark";
|
|
424
|
+
type PollResultsSize = "sm" | "md" | "lg";
|
|
425
|
+
interface PollResultsSeries {
|
|
426
|
+
label?: React.ReactNode;
|
|
427
|
+
value: number;
|
|
428
|
+
color?: PollResultsColor;
|
|
429
|
+
fillColor?: string;
|
|
430
|
+
ariaLabel?: string;
|
|
431
|
+
}
|
|
432
|
+
interface PollResultsOption {
|
|
433
|
+
label: React.ReactNode;
|
|
434
|
+
value?: number;
|
|
435
|
+
color?: PollResultsColor;
|
|
436
|
+
fillColor?: string;
|
|
437
|
+
ariaLabel?: string;
|
|
438
|
+
series?: PollResultsSeries[];
|
|
439
|
+
}
|
|
440
|
+
interface PollResultsProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "color">, ColorOverrideProps {
|
|
441
|
+
options: PollResultsOption[];
|
|
442
|
+
maxValue?: number;
|
|
443
|
+
size?: PollResultsSize;
|
|
444
|
+
color?: PollResultsColor;
|
|
445
|
+
trackColor?: string;
|
|
446
|
+
showValueLabel?: boolean;
|
|
447
|
+
showSeriesLabels?: boolean;
|
|
448
|
+
valueFormatter?: (value: number, percent: number) => React.ReactNode;
|
|
449
|
+
}
|
|
450
|
+
declare const PollResults: React.FC<PollResultsProps>;
|
|
451
|
+
|
|
421
452
|
type SpinnerColor = "primary" | "success" | "error" | "warning" | "info" | "light" | "dark";
|
|
422
453
|
type SpinnerSize = "sm" | "md" | "lg";
|
|
423
454
|
interface SpinnerProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, "color">, ColorOverrideProps {
|
|
@@ -636,4 +667,4 @@ interface SliderProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>,
|
|
|
636
667
|
}
|
|
637
668
|
declare const Slider: React.FC<SliderProps>;
|
|
638
669
|
|
|
639
|
-
export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, type AccordionSelectionMode, Alert, type AlertProps, type AlertVariant, Avatar, type AvatarProps, type AvatarSize, type AvatarStatus, AvatarText, type AvatarTextProps, Badge, type BadgeColor, type BadgeProps, type BadgeSize, type BadgeVariant, Breadcrumb, type BreadcrumbItem, type BreadcrumbProps, Button, type ButtonProps, Card, type CardProps, Checkbox, type CheckboxProps, Chip, type ChipColor, type ChipProps, type ChipSize, type ChipVariant, Code, type CodeColor, type CodeProps, type CodeSize, ColorOverrideProps, DatePicker, type DatePickerProps, DateTimePicker, type DateTimePickerProps, Drawer, type DrawerPlacement, type DrawerProps, Dropdown, DropdownItem, type DropdownItemProps, type DropdownItemVariant, type DropdownProps, Dropzone, type DropzoneProps, FileInput, type FileInputProps, Form, type FormProps, Input, type InputProps, Label, type LabelProps, Modal, type ModalProps, type ModalVariant, MultiSelect, type MultiSelectProps, Pagination, type PaginationAlign, type PaginationProps, PasswordInput, type PasswordInputProps, Popover, type PopoverPlacement, type PopoverProps, Progress, type ProgressColor, type ProgressProps, type ProgressSize, Radio, type RadioProps, RadioSm, type RadioSmProps, Ribbon, type RibbonColor, type RibbonPosition, type RibbonProps, type RibbonVariant, Select, type SelectOption, type SelectProps, Skeleton, type SkeletonProps, Slider, type SliderColor, type SliderProps, Snippet, type SnippetProps, type SnippetSize, type SortDirection, Spinner, type SpinnerColor, type SpinnerProps, type SpinnerSize, Switch, type SwitchProps, Tab, type TabProps, Table, TableBody, TableCell, type TableCellProps, type TableColumn, TableHeader, type TableProps, TableRow, type TableRowProps, type TableSectionProps, Tabs, type TabsProps, type TabsVariant, TextArea, type TextAreaProps, ThemeToggleButton, type ThemeToggleButtonProps, Toast, type ToastProps, type ToastVariant, Tooltip, type TooltipPlacement, type TooltipProps, cn };
|
|
670
|
+
export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, type AccordionSelectionMode, Alert, type AlertProps, type AlertVariant, Avatar, type AvatarProps, type AvatarSize, type AvatarStatus, AvatarText, type AvatarTextProps, Badge, type BadgeColor, type BadgeProps, type BadgeSize, type BadgeVariant, Breadcrumb, type BreadcrumbItem, type BreadcrumbProps, Button, type ButtonProps, Card, type CardProps, Checkbox, type CheckboxProps, Chip, type ChipColor, type ChipProps, type ChipSize, type ChipVariant, Code, type CodeColor, type CodeProps, type CodeSize, ColorOverrideProps, DatePicker, type DatePickerProps, DateTimePicker, type DateTimePickerProps, Drawer, type DrawerPlacement, type DrawerProps, Dropdown, DropdownItem, type DropdownItemProps, type DropdownItemVariant, type DropdownProps, Dropzone, type DropzoneProps, FileInput, type FileInputProps, Form, type FormProps, Input, type InputProps, Label, type LabelProps, Modal, type ModalProps, type ModalVariant, MultiSelect, type MultiSelectProps, Pagination, type PaginationAlign, type PaginationProps, PasswordInput, type PasswordInputProps, PollResults, type PollResultsColor, type PollResultsOption, type PollResultsProps, type PollResultsSeries, type PollResultsSize, Popover, type PopoverPlacement, type PopoverProps, Progress, type ProgressColor, type ProgressProps, type ProgressSize, Radio, type RadioProps, RadioSm, type RadioSmProps, Ribbon, type RibbonColor, type RibbonPosition, type RibbonProps, type RibbonVariant, Select, type SelectOption, type SelectProps, Skeleton, type SkeletonProps, Slider, type SliderColor, type SliderProps, Snippet, type SnippetProps, type SnippetSize, type SortDirection, Spinner, type SpinnerColor, type SpinnerProps, type SpinnerSize, Switch, type SwitchProps, Tab, type TabProps, Table, TableBody, TableCell, type TableCellProps, type TableColumn, TableHeader, type TableProps, TableRow, type TableRowProps, type TableSectionProps, Tabs, type TabsProps, type TabsVariant, TextArea, type TextAreaProps, ThemeToggleButton, type ThemeToggleButtonProps, Toast, type ToastProps, type ToastVariant, Tooltip, type TooltipPlacement, type TooltipProps, cn };
|
package/dist/index.js
CHANGED
|
@@ -1483,12 +1483,6 @@ var Tooltip = ({
|
|
|
1483
1483
|
}
|
|
1484
1484
|
);
|
|
1485
1485
|
};
|
|
1486
|
-
var placementClasses2 = {
|
|
1487
|
-
top: "bottom-full left-1/2 -translate-x-1/2 mb-2",
|
|
1488
|
-
right: "left-full top-1/2 -translate-y-1/2 ml-2",
|
|
1489
|
-
bottom: "top-full left-1/2 -translate-x-1/2 mt-2",
|
|
1490
|
-
left: "right-full top-1/2 -translate-y-1/2 mr-2"
|
|
1491
|
-
};
|
|
1492
1486
|
var Popover = ({
|
|
1493
1487
|
trigger,
|
|
1494
1488
|
placement = "bottom",
|
|
@@ -1497,14 +1491,17 @@ var Popover = ({
|
|
|
1497
1491
|
defaultOpen = false,
|
|
1498
1492
|
closeOnOutsideClick = true,
|
|
1499
1493
|
closeOnEsc = true,
|
|
1494
|
+
portal = true,
|
|
1500
1495
|
children,
|
|
1501
1496
|
className,
|
|
1502
1497
|
...rest
|
|
1503
1498
|
}) => {
|
|
1504
1499
|
const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);
|
|
1500
|
+
const [panelPosition, setPanelPosition] = useState();
|
|
1505
1501
|
const isControlled = controlledOpen !== void 0;
|
|
1506
1502
|
const open = isControlled ? controlledOpen : uncontrolledOpen;
|
|
1507
1503
|
const wrapperRef = useRef(null);
|
|
1504
|
+
const panelRef = useRef(null);
|
|
1508
1505
|
const setOpen = (next) => {
|
|
1509
1506
|
if (!isControlled) setUncontrolledOpen(next);
|
|
1510
1507
|
onOpenChange?.(next);
|
|
@@ -1512,7 +1509,7 @@ var Popover = ({
|
|
|
1512
1509
|
useEffect(() => {
|
|
1513
1510
|
if (!open) return;
|
|
1514
1511
|
const handleClickOutside = (event) => {
|
|
1515
|
-
if (closeOnOutsideClick && wrapperRef.current && !wrapperRef.current.contains(event.target)) {
|
|
1512
|
+
if (closeOnOutsideClick && wrapperRef.current && !wrapperRef.current.contains(event.target) && !panelRef.current?.contains(event.target)) {
|
|
1516
1513
|
setOpen(false);
|
|
1517
1514
|
}
|
|
1518
1515
|
};
|
|
@@ -1528,6 +1525,82 @@ var Popover = ({
|
|
|
1528
1525
|
document.removeEventListener("keydown", handleEscape);
|
|
1529
1526
|
};
|
|
1530
1527
|
}, [open, closeOnOutsideClick, closeOnEsc]);
|
|
1528
|
+
const updatePanelPosition = useCallback(() => {
|
|
1529
|
+
const trigger2 = wrapperRef.current;
|
|
1530
|
+
const panel2 = panelRef.current;
|
|
1531
|
+
if (!trigger2 || !panel2) return;
|
|
1532
|
+
const rect = trigger2.getBoundingClientRect();
|
|
1533
|
+
const panelWidth = panel2.offsetWidth;
|
|
1534
|
+
const panelHeight = panel2.offsetHeight;
|
|
1535
|
+
const viewportPadding = 8;
|
|
1536
|
+
const gap = 8;
|
|
1537
|
+
const centeredLeft = rect.left + rect.width / 2 - panelWidth / 2;
|
|
1538
|
+
const centeredTop = rect.top + rect.height / 2 - panelHeight / 2;
|
|
1539
|
+
const canFitAbove = rect.top - gap - panelHeight >= viewportPadding;
|
|
1540
|
+
const canFitBelow = rect.bottom + gap + panelHeight <= window.innerHeight - viewportPadding;
|
|
1541
|
+
const canFitLeft = rect.left - gap - panelWidth >= viewportPadding;
|
|
1542
|
+
const canFitRight = rect.right + gap + panelWidth <= window.innerWidth - viewportPadding;
|
|
1543
|
+
let effectivePlacement = placement;
|
|
1544
|
+
if (placement === "bottom" && !canFitBelow && canFitAbove) {
|
|
1545
|
+
effectivePlacement = "top";
|
|
1546
|
+
} else if (placement === "top" && !canFitAbove && canFitBelow) {
|
|
1547
|
+
effectivePlacement = "bottom";
|
|
1548
|
+
} else if (placement === "left" && !canFitLeft && canFitRight) {
|
|
1549
|
+
effectivePlacement = "right";
|
|
1550
|
+
} else if (placement === "right" && !canFitRight && canFitLeft) {
|
|
1551
|
+
effectivePlacement = "left";
|
|
1552
|
+
}
|
|
1553
|
+
let top = rect.bottom + gap;
|
|
1554
|
+
let left = centeredLeft;
|
|
1555
|
+
if (effectivePlacement === "top") {
|
|
1556
|
+
top = rect.top - gap - panelHeight;
|
|
1557
|
+
left = centeredLeft;
|
|
1558
|
+
} else if (effectivePlacement === "right") {
|
|
1559
|
+
top = centeredTop;
|
|
1560
|
+
left = rect.right + gap;
|
|
1561
|
+
} else if (effectivePlacement === "left") {
|
|
1562
|
+
top = centeredTop;
|
|
1563
|
+
left = rect.left - gap - panelWidth;
|
|
1564
|
+
}
|
|
1565
|
+
setPanelPosition({
|
|
1566
|
+
top: Math.min(
|
|
1567
|
+
Math.max(viewportPadding, top),
|
|
1568
|
+
window.innerHeight - panelHeight - viewportPadding
|
|
1569
|
+
),
|
|
1570
|
+
left: Math.min(
|
|
1571
|
+
Math.max(viewportPadding, left),
|
|
1572
|
+
window.innerWidth - panelWidth - viewportPadding
|
|
1573
|
+
)
|
|
1574
|
+
});
|
|
1575
|
+
}, [placement]);
|
|
1576
|
+
useLayoutEffect(() => {
|
|
1577
|
+
if (!open || !portal) return;
|
|
1578
|
+
updatePanelPosition();
|
|
1579
|
+
window.addEventListener("resize", updatePanelPosition);
|
|
1580
|
+
window.addEventListener("scroll", updatePanelPosition, true);
|
|
1581
|
+
return () => {
|
|
1582
|
+
window.removeEventListener("resize", updatePanelPosition);
|
|
1583
|
+
window.removeEventListener("scroll", updatePanelPosition, true);
|
|
1584
|
+
};
|
|
1585
|
+
}, [open, portal, updatePanelPosition]);
|
|
1586
|
+
const panel = open ? /* @__PURE__ */ jsx(
|
|
1587
|
+
"div",
|
|
1588
|
+
{
|
|
1589
|
+
ref: panelRef,
|
|
1590
|
+
role: "dialog",
|
|
1591
|
+
className: cn(
|
|
1592
|
+
"min-w-48 rounded-xl border border-gray-200 bg-white p-4 shadow-theme-lg dark:border-gray-700 dark:bg-gray-900 dark:text-white/90",
|
|
1593
|
+
portal ? cn("fixed", layers.portal) : cn("absolute top-full left-1/2 mt-2 -translate-x-1/2", layers.floating),
|
|
1594
|
+
className
|
|
1595
|
+
),
|
|
1596
|
+
style: {
|
|
1597
|
+
...portal && !panelPosition ? { visibility: "hidden" } : void 0,
|
|
1598
|
+
...portal ? panelPosition : void 0
|
|
1599
|
+
},
|
|
1600
|
+
...rest,
|
|
1601
|
+
children
|
|
1602
|
+
}
|
|
1603
|
+
) : null;
|
|
1531
1604
|
return /* @__PURE__ */ jsxs("div", { ref: wrapperRef, className: "relative inline-block", children: [
|
|
1532
1605
|
/* @__PURE__ */ jsx(
|
|
1533
1606
|
"span",
|
|
@@ -1539,20 +1612,7 @@ var Popover = ({
|
|
|
1539
1612
|
children: trigger
|
|
1540
1613
|
}
|
|
1541
1614
|
),
|
|
1542
|
-
|
|
1543
|
-
"div",
|
|
1544
|
-
{
|
|
1545
|
-
role: "dialog",
|
|
1546
|
-
className: cn(
|
|
1547
|
-
"absolute min-w-[12rem] rounded-xl border border-gray-200 bg-white p-4 shadow-theme-lg dark:border-gray-700 dark:bg-gray-900 dark:text-white/90",
|
|
1548
|
-
layers.floating,
|
|
1549
|
-
placementClasses2[placement],
|
|
1550
|
-
className
|
|
1551
|
-
),
|
|
1552
|
-
...rest,
|
|
1553
|
-
children
|
|
1554
|
-
}
|
|
1555
|
-
)
|
|
1615
|
+
portal && typeof document !== "undefined" ? panel && createPortal(panel, document.body) : panel
|
|
1556
1616
|
] });
|
|
1557
1617
|
};
|
|
1558
1618
|
var panelBaseByPlacement = {
|
|
@@ -1812,12 +1872,134 @@ var Progress = ({
|
|
|
1812
1872
|
)
|
|
1813
1873
|
] });
|
|
1814
1874
|
};
|
|
1875
|
+
var trackSizes = {
|
|
1876
|
+
sm: "h-2",
|
|
1877
|
+
md: "h-2.5",
|
|
1878
|
+
lg: "h-3.5"
|
|
1879
|
+
};
|
|
1880
|
+
var colorStyles = {
|
|
1881
|
+
primary: "bg-brand-500",
|
|
1882
|
+
success: "bg-success-500",
|
|
1883
|
+
error: "bg-error-500",
|
|
1884
|
+
warning: "bg-warning-500",
|
|
1885
|
+
info: "bg-blue-light-500",
|
|
1886
|
+
light: "bg-gray-400",
|
|
1887
|
+
dark: "bg-gray-700 dark:bg-gray-300"
|
|
1888
|
+
};
|
|
1889
|
+
var defaultColorCycle = [
|
|
1890
|
+
"primary",
|
|
1891
|
+
"success",
|
|
1892
|
+
"info",
|
|
1893
|
+
"warning",
|
|
1894
|
+
"error",
|
|
1895
|
+
"dark"
|
|
1896
|
+
];
|
|
1897
|
+
var defaultSeriesColorCycle = ["primary", "success"];
|
|
1898
|
+
var clampValue = (value, maxValue) => {
|
|
1899
|
+
return Math.min(Math.max(value, 0), maxValue);
|
|
1900
|
+
};
|
|
1901
|
+
var toPercent = (value, maxValue) => {
|
|
1902
|
+
return Math.round(clampValue(value, maxValue) / maxValue * 100);
|
|
1903
|
+
};
|
|
1904
|
+
var nodeToLabel = (node) => {
|
|
1905
|
+
if (typeof node === "string" || typeof node === "number") {
|
|
1906
|
+
return String(node);
|
|
1907
|
+
}
|
|
1908
|
+
return void 0;
|
|
1909
|
+
};
|
|
1910
|
+
var defaultValueFormatter = (_value, percent) => `${percent}%`;
|
|
1911
|
+
var PollResults = ({
|
|
1912
|
+
options,
|
|
1913
|
+
maxValue = 100,
|
|
1914
|
+
size = "md",
|
|
1915
|
+
color = "primary",
|
|
1916
|
+
trackColor,
|
|
1917
|
+
showValueLabel = true,
|
|
1918
|
+
showSeriesLabels = true,
|
|
1919
|
+
valueFormatter = defaultValueFormatter,
|
|
1920
|
+
className,
|
|
1921
|
+
bgColor,
|
|
1922
|
+
textColor,
|
|
1923
|
+
borderColor,
|
|
1924
|
+
style,
|
|
1925
|
+
...rest
|
|
1926
|
+
}) => {
|
|
1927
|
+
const safeMax = maxValue <= 0 ? 100 : maxValue;
|
|
1928
|
+
return /* @__PURE__ */ jsx(
|
|
1929
|
+
"div",
|
|
1930
|
+
{
|
|
1931
|
+
className: cn("w-full space-y-7 text-gray-800 dark:text-white/90", className),
|
|
1932
|
+
style: { ...styleOverride({ bgColor, textColor, borderColor }), ...style },
|
|
1933
|
+
...rest,
|
|
1934
|
+
children: options.map((option, optionIndex) => {
|
|
1935
|
+
const optionText = nodeToLabel(option.label);
|
|
1936
|
+
const series = option.series?.length ? option.series : [
|
|
1937
|
+
{
|
|
1938
|
+
value: option.value ?? 0,
|
|
1939
|
+
color: option.color ?? defaultColorCycle[optionIndex % defaultColorCycle.length] ?? color,
|
|
1940
|
+
fillColor: option.fillColor,
|
|
1941
|
+
ariaLabel: option.ariaLabel
|
|
1942
|
+
}
|
|
1943
|
+
];
|
|
1944
|
+
const isGrouped = series.length > 1;
|
|
1945
|
+
const singlePercent = toPercent(series[0]?.value ?? 0, safeMax);
|
|
1946
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
1947
|
+
/* @__PURE__ */ jsxs("div", { className: "mb-3 flex items-center justify-between gap-4", children: [
|
|
1948
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 break-words text-xl font-semibold leading-snug text-gray-800 dark:text-white/90", children: option.label }),
|
|
1949
|
+
!isGrouped && showValueLabel && /* @__PURE__ */ jsx("span", { className: "shrink-0 text-xl font-semibold leading-snug text-gray-600 dark:text-gray-300", children: valueFormatter(series[0]?.value ?? 0, singlePercent) })
|
|
1950
|
+
] }),
|
|
1951
|
+
/* @__PURE__ */ jsx("div", { className: cn("flex flex-col", isGrouped ? "gap-3" : "gap-0"), children: series.map((entry, seriesIndex) => {
|
|
1952
|
+
const percent = toPercent(entry.value, safeMax);
|
|
1953
|
+
const fillColor = entry.fillColor;
|
|
1954
|
+
const entryColor = entry.color ?? (isGrouped ? defaultSeriesColorCycle[seriesIndex % defaultSeriesColorCycle.length] : option.color ?? defaultColorCycle[optionIndex % defaultColorCycle.length]) ?? color;
|
|
1955
|
+
const entryLabel = nodeToLabel(entry.label);
|
|
1956
|
+
const ariaLabel = entry.ariaLabel ?? [optionText, isGrouped ? entryLabel : void 0].filter(Boolean).join(" ");
|
|
1957
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
1958
|
+
isGrouped && (showSeriesLabels || showValueLabel) && /* @__PURE__ */ jsxs("div", { className: "mb-1.5 flex items-center justify-between gap-3", children: [
|
|
1959
|
+
showSeriesLabels ? /* @__PURE__ */ jsx("span", { className: "min-w-0 break-words text-xs font-medium text-gray-500 dark:text-gray-400", children: entry.label }) : /* @__PURE__ */ jsx("span", {}),
|
|
1960
|
+
showValueLabel && /* @__PURE__ */ jsx("span", { className: "shrink-0 text-xs font-semibold text-gray-600 dark:text-gray-300", children: valueFormatter(entry.value, percent) })
|
|
1961
|
+
] }),
|
|
1962
|
+
/* @__PURE__ */ jsx(
|
|
1963
|
+
"div",
|
|
1964
|
+
{
|
|
1965
|
+
role: "progressbar",
|
|
1966
|
+
"aria-label": ariaLabel || void 0,
|
|
1967
|
+
"aria-valuemin": 0,
|
|
1968
|
+
"aria-valuemax": safeMax,
|
|
1969
|
+
"aria-valuenow": clampValue(entry.value, safeMax),
|
|
1970
|
+
className: cn(
|
|
1971
|
+
"relative w-full overflow-hidden rounded-full bg-gray-100 dark:bg-gray-800",
|
|
1972
|
+
trackSizes[size]
|
|
1973
|
+
),
|
|
1974
|
+
style: trackColor ? { backgroundColor: trackColor } : void 0,
|
|
1975
|
+
children: /* @__PURE__ */ jsx(
|
|
1976
|
+
"div",
|
|
1977
|
+
{
|
|
1978
|
+
className: cn(
|
|
1979
|
+
"h-full rounded-full transition-all duration-300",
|
|
1980
|
+
fillColor ? void 0 : colorStyles[entryColor]
|
|
1981
|
+
),
|
|
1982
|
+
style: {
|
|
1983
|
+
width: `${percent}%`,
|
|
1984
|
+
...fillColor ? { backgroundColor: fillColor } : {}
|
|
1985
|
+
}
|
|
1986
|
+
}
|
|
1987
|
+
)
|
|
1988
|
+
}
|
|
1989
|
+
)
|
|
1990
|
+
] }, `${entryLabel ?? "series"}-${seriesIndex}`);
|
|
1991
|
+
}) })
|
|
1992
|
+
] }, `${optionText ?? "poll-option"}-${optionIndex}`);
|
|
1993
|
+
})
|
|
1994
|
+
}
|
|
1995
|
+
);
|
|
1996
|
+
};
|
|
1815
1997
|
var sizeStyles4 = {
|
|
1816
1998
|
sm: "h-4 w-4 border-2",
|
|
1817
1999
|
md: "h-6 w-6 border-2",
|
|
1818
2000
|
lg: "h-8 w-8 border-[3px]"
|
|
1819
2001
|
};
|
|
1820
|
-
var
|
|
2002
|
+
var colorStyles2 = {
|
|
1821
2003
|
primary: "text-brand-500",
|
|
1822
2004
|
success: "text-success-500",
|
|
1823
2005
|
error: "text-error-500",
|
|
@@ -1854,7 +2036,7 @@ var Spinner = ({
|
|
|
1854
2036
|
className: cn(
|
|
1855
2037
|
"inline-block animate-spin rounded-full border-current border-t-transparent",
|
|
1856
2038
|
sizeStyles4[size],
|
|
1857
|
-
!textColor &&
|
|
2039
|
+
!textColor && colorStyles2[color]
|
|
1858
2040
|
),
|
|
1859
2041
|
style: textColor ? { color: textColor } : void 0
|
|
1860
2042
|
}
|
|
@@ -2680,7 +2862,7 @@ var DatePicker = ({
|
|
|
2680
2862
|
useEffect(() => {
|
|
2681
2863
|
const flatPickr = flatpickr(`#${id}`, {
|
|
2682
2864
|
mode: mode || "single",
|
|
2683
|
-
|
|
2865
|
+
appendTo: document.body,
|
|
2684
2866
|
monthSelectorType: "static",
|
|
2685
2867
|
dateFormat: "Y-m-d",
|
|
2686
2868
|
defaultDate,
|
|
@@ -2736,7 +2918,7 @@ var DateTimePicker = ({
|
|
|
2736
2918
|
useEffect(() => {
|
|
2737
2919
|
const flatPickr = flatpickr(`#${id}-date`, {
|
|
2738
2920
|
mode: "single",
|
|
2739
|
-
|
|
2921
|
+
appendTo: document.body,
|
|
2740
2922
|
monthSelectorType: "static",
|
|
2741
2923
|
dateFormat: "Y-m-d",
|
|
2742
2924
|
defaultDate,
|
|
@@ -2945,6 +3127,6 @@ var Slider = ({
|
|
|
2945
3127
|
] });
|
|
2946
3128
|
};
|
|
2947
3129
|
|
|
2948
|
-
export { Accordion, AccordionItem, Alert, Avatar, AvatarText, Badge, Breadcrumb, Button, Card, Checkbox, Chip, Code, DatePicker, DateTimePicker, Drawer, Dropdown, DropdownItem, Dropzone, FileInput, Form, Input, Label, MultiSelect, Pagination, PasswordInput, Popover, Progress, Radio, RadioSm, Ribbon, Select, Skeleton, Slider, Snippet, Spinner, Switch, Tab, Table, TableBody, TableCell, TableHeader, TableRow, Tabs, TextArea, ThemeToggleButton, Toast, Tooltip, styleOverride };
|
|
3130
|
+
export { Accordion, AccordionItem, Alert, Avatar, AvatarText, Badge, Breadcrumb, Button, Card, Checkbox, Chip, Code, DatePicker, DateTimePicker, Drawer, Dropdown, DropdownItem, Dropzone, FileInput, Form, Input, Label, MultiSelect, Pagination, PasswordInput, PollResults, Popover, Progress, Radio, RadioSm, Ribbon, Select, Skeleton, Slider, Snippet, Spinner, Switch, Tab, Table, TableBody, TableCell, TableHeader, TableRow, Tabs, TextArea, ThemeToggleButton, Toast, Tooltip, styleOverride };
|
|
2949
3131
|
//# sourceMappingURL=index.js.map
|
|
2950
3132
|
//# sourceMappingURL=index.js.map
|