@andreagiugni/tailwind-dashboard-ui 1.0.22 → 1.0.24
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 +277 -25
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +47 -1
- package/dist/index.d.ts +47 -1
- package/dist/index.js +277 -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,50 @@ 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
|
+
type PollResultsTextSize = React.CSSProperties["fontSize"];
|
|
426
|
+
type PollResultsTextColor = React.CSSProperties["color"];
|
|
427
|
+
type PollResultsTextWeight = React.CSSProperties["fontWeight"];
|
|
428
|
+
interface PollResultsSeries {
|
|
429
|
+
label?: React.ReactNode;
|
|
430
|
+
value: number;
|
|
431
|
+
color?: PollResultsColor;
|
|
432
|
+
fillColor?: string;
|
|
433
|
+
ariaLabel?: string;
|
|
434
|
+
}
|
|
435
|
+
interface PollResultsOption {
|
|
436
|
+
label: React.ReactNode;
|
|
437
|
+
value?: number;
|
|
438
|
+
color?: PollResultsColor;
|
|
439
|
+
fillColor?: string;
|
|
440
|
+
ariaLabel?: string;
|
|
441
|
+
series?: PollResultsSeries[];
|
|
442
|
+
}
|
|
443
|
+
interface PollResultsProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "color">, ColorOverrideProps {
|
|
444
|
+
options: PollResultsOption[];
|
|
445
|
+
maxValue?: number;
|
|
446
|
+
size?: PollResultsSize;
|
|
447
|
+
color?: PollResultsColor;
|
|
448
|
+
trackColor?: string;
|
|
449
|
+
showValueLabel?: boolean;
|
|
450
|
+
showSeriesLabels?: boolean;
|
|
451
|
+
valueFormatter?: (value: number, percent: number) => React.ReactNode;
|
|
452
|
+
labelTextSize?: PollResultsTextSize;
|
|
453
|
+
labelTextColor?: PollResultsTextColor;
|
|
454
|
+
labelTextWeight?: PollResultsTextWeight;
|
|
455
|
+
valueTextSize?: PollResultsTextSize;
|
|
456
|
+
valueTextColor?: PollResultsTextColor;
|
|
457
|
+
valueTextWeight?: PollResultsTextWeight;
|
|
458
|
+
seriesLabelTextSize?: PollResultsTextSize;
|
|
459
|
+
seriesLabelTextColor?: PollResultsTextColor;
|
|
460
|
+
seriesLabelTextWeight?: PollResultsTextWeight;
|
|
461
|
+
seriesValueTextSize?: PollResultsTextSize;
|
|
462
|
+
seriesValueTextColor?: PollResultsTextColor;
|
|
463
|
+
seriesValueTextWeight?: PollResultsTextWeight;
|
|
464
|
+
}
|
|
465
|
+
declare const PollResults: React.FC<PollResultsProps>;
|
|
466
|
+
|
|
421
467
|
type SpinnerColor = "primary" | "success" | "error" | "warning" | "info" | "light" | "dark";
|
|
422
468
|
type SpinnerSize = "sm" | "md" | "lg";
|
|
423
469
|
interface SpinnerProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, "color">, ColorOverrideProps {
|
|
@@ -636,4 +682,4 @@ interface SliderProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>,
|
|
|
636
682
|
}
|
|
637
683
|
declare const Slider: React.FC<SliderProps>;
|
|
638
684
|
|
|
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 };
|
|
685
|
+
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, type PollResultsTextColor, type PollResultsTextSize, type PollResultsTextWeight, 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,50 @@ 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
|
+
type PollResultsTextSize = React.CSSProperties["fontSize"];
|
|
426
|
+
type PollResultsTextColor = React.CSSProperties["color"];
|
|
427
|
+
type PollResultsTextWeight = React.CSSProperties["fontWeight"];
|
|
428
|
+
interface PollResultsSeries {
|
|
429
|
+
label?: React.ReactNode;
|
|
430
|
+
value: number;
|
|
431
|
+
color?: PollResultsColor;
|
|
432
|
+
fillColor?: string;
|
|
433
|
+
ariaLabel?: string;
|
|
434
|
+
}
|
|
435
|
+
interface PollResultsOption {
|
|
436
|
+
label: React.ReactNode;
|
|
437
|
+
value?: number;
|
|
438
|
+
color?: PollResultsColor;
|
|
439
|
+
fillColor?: string;
|
|
440
|
+
ariaLabel?: string;
|
|
441
|
+
series?: PollResultsSeries[];
|
|
442
|
+
}
|
|
443
|
+
interface PollResultsProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "color">, ColorOverrideProps {
|
|
444
|
+
options: PollResultsOption[];
|
|
445
|
+
maxValue?: number;
|
|
446
|
+
size?: PollResultsSize;
|
|
447
|
+
color?: PollResultsColor;
|
|
448
|
+
trackColor?: string;
|
|
449
|
+
showValueLabel?: boolean;
|
|
450
|
+
showSeriesLabels?: boolean;
|
|
451
|
+
valueFormatter?: (value: number, percent: number) => React.ReactNode;
|
|
452
|
+
labelTextSize?: PollResultsTextSize;
|
|
453
|
+
labelTextColor?: PollResultsTextColor;
|
|
454
|
+
labelTextWeight?: PollResultsTextWeight;
|
|
455
|
+
valueTextSize?: PollResultsTextSize;
|
|
456
|
+
valueTextColor?: PollResultsTextColor;
|
|
457
|
+
valueTextWeight?: PollResultsTextWeight;
|
|
458
|
+
seriesLabelTextSize?: PollResultsTextSize;
|
|
459
|
+
seriesLabelTextColor?: PollResultsTextColor;
|
|
460
|
+
seriesLabelTextWeight?: PollResultsTextWeight;
|
|
461
|
+
seriesValueTextSize?: PollResultsTextSize;
|
|
462
|
+
seriesValueTextColor?: PollResultsTextColor;
|
|
463
|
+
seriesValueTextWeight?: PollResultsTextWeight;
|
|
464
|
+
}
|
|
465
|
+
declare const PollResults: React.FC<PollResultsProps>;
|
|
466
|
+
|
|
421
467
|
type SpinnerColor = "primary" | "success" | "error" | "warning" | "info" | "light" | "dark";
|
|
422
468
|
type SpinnerSize = "sm" | "md" | "lg";
|
|
423
469
|
interface SpinnerProps extends Omit<React.HTMLAttributes<HTMLSpanElement>, "color">, ColorOverrideProps {
|
|
@@ -636,4 +682,4 @@ interface SliderProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>,
|
|
|
636
682
|
}
|
|
637
683
|
declare const Slider: React.FC<SliderProps>;
|
|
638
684
|
|
|
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 };
|
|
685
|
+
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, type PollResultsTextColor, type PollResultsTextSize, type PollResultsTextWeight, 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,203 @@ 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 textStyle = ({
|
|
1912
|
+
size,
|
|
1913
|
+
color,
|
|
1914
|
+
weight
|
|
1915
|
+
}) => ({
|
|
1916
|
+
...size ? { fontSize: size } : {},
|
|
1917
|
+
...color ? { color } : {},
|
|
1918
|
+
...weight ? { fontWeight: weight } : {}
|
|
1919
|
+
});
|
|
1920
|
+
var PollResults = ({
|
|
1921
|
+
options,
|
|
1922
|
+
maxValue = 100,
|
|
1923
|
+
size = "md",
|
|
1924
|
+
color = "primary",
|
|
1925
|
+
trackColor,
|
|
1926
|
+
showValueLabel = true,
|
|
1927
|
+
showSeriesLabels = true,
|
|
1928
|
+
valueFormatter = defaultValueFormatter,
|
|
1929
|
+
labelTextSize,
|
|
1930
|
+
labelTextColor,
|
|
1931
|
+
labelTextWeight,
|
|
1932
|
+
valueTextSize,
|
|
1933
|
+
valueTextColor,
|
|
1934
|
+
valueTextWeight,
|
|
1935
|
+
seriesLabelTextSize,
|
|
1936
|
+
seriesLabelTextColor,
|
|
1937
|
+
seriesLabelTextWeight,
|
|
1938
|
+
seriesValueTextSize,
|
|
1939
|
+
seriesValueTextColor,
|
|
1940
|
+
seriesValueTextWeight,
|
|
1941
|
+
className,
|
|
1942
|
+
bgColor,
|
|
1943
|
+
textColor,
|
|
1944
|
+
borderColor,
|
|
1945
|
+
style,
|
|
1946
|
+
...rest
|
|
1947
|
+
}) => {
|
|
1948
|
+
const safeMax = maxValue <= 0 ? 100 : maxValue;
|
|
1949
|
+
const optionLabelStyle = textStyle({
|
|
1950
|
+
size: labelTextSize,
|
|
1951
|
+
color: labelTextColor,
|
|
1952
|
+
weight: labelTextWeight
|
|
1953
|
+
});
|
|
1954
|
+
const optionValueStyle = textStyle({
|
|
1955
|
+
size: valueTextSize,
|
|
1956
|
+
color: valueTextColor,
|
|
1957
|
+
weight: valueTextWeight
|
|
1958
|
+
});
|
|
1959
|
+
const groupedLabelStyle = textStyle({
|
|
1960
|
+
size: seriesLabelTextSize,
|
|
1961
|
+
color: seriesLabelTextColor,
|
|
1962
|
+
weight: seriesLabelTextWeight
|
|
1963
|
+
});
|
|
1964
|
+
const groupedValueStyle = textStyle({
|
|
1965
|
+
size: seriesValueTextSize ?? valueTextSize,
|
|
1966
|
+
color: seriesValueTextColor ?? valueTextColor,
|
|
1967
|
+
weight: seriesValueTextWeight ?? valueTextWeight
|
|
1968
|
+
});
|
|
1969
|
+
return /* @__PURE__ */ jsx(
|
|
1970
|
+
"div",
|
|
1971
|
+
{
|
|
1972
|
+
className: cn("w-full space-y-7 text-gray-800 dark:text-white/90", className),
|
|
1973
|
+
style: { ...styleOverride({ bgColor, textColor, borderColor }), ...style },
|
|
1974
|
+
...rest,
|
|
1975
|
+
children: options.map((option, optionIndex) => {
|
|
1976
|
+
const optionText = nodeToLabel(option.label);
|
|
1977
|
+
const series = option.series?.length ? option.series : [
|
|
1978
|
+
{
|
|
1979
|
+
value: option.value ?? 0,
|
|
1980
|
+
color: option.color ?? defaultColorCycle[optionIndex % defaultColorCycle.length] ?? color,
|
|
1981
|
+
fillColor: option.fillColor,
|
|
1982
|
+
ariaLabel: option.ariaLabel
|
|
1983
|
+
}
|
|
1984
|
+
];
|
|
1985
|
+
const isGrouped = series.length > 1;
|
|
1986
|
+
const singlePercent = toPercent(series[0]?.value ?? 0, safeMax);
|
|
1987
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
1988
|
+
/* @__PURE__ */ jsxs("div", { className: "mb-3 flex items-center justify-between gap-4", children: [
|
|
1989
|
+
/* @__PURE__ */ jsx(
|
|
1990
|
+
"span",
|
|
1991
|
+
{
|
|
1992
|
+
className: "min-w-0 break-words text-xl font-semibold leading-snug text-gray-800 dark:text-white/90",
|
|
1993
|
+
style: optionLabelStyle,
|
|
1994
|
+
children: option.label
|
|
1995
|
+
}
|
|
1996
|
+
),
|
|
1997
|
+
!isGrouped && showValueLabel && /* @__PURE__ */ jsx(
|
|
1998
|
+
"span",
|
|
1999
|
+
{
|
|
2000
|
+
className: "shrink-0 text-xl font-semibold leading-snug text-gray-600 dark:text-gray-300",
|
|
2001
|
+
style: optionValueStyle,
|
|
2002
|
+
children: valueFormatter(series[0]?.value ?? 0, singlePercent)
|
|
2003
|
+
}
|
|
2004
|
+
)
|
|
2005
|
+
] }),
|
|
2006
|
+
/* @__PURE__ */ jsx("div", { className: cn("flex flex-col", isGrouped ? "gap-3" : "gap-0"), children: series.map((entry, seriesIndex) => {
|
|
2007
|
+
const percent = toPercent(entry.value, safeMax);
|
|
2008
|
+
const fillColor = entry.fillColor;
|
|
2009
|
+
const entryColor = entry.color ?? (isGrouped ? defaultSeriesColorCycle[seriesIndex % defaultSeriesColorCycle.length] : option.color ?? defaultColorCycle[optionIndex % defaultColorCycle.length]) ?? color;
|
|
2010
|
+
const entryLabel = nodeToLabel(entry.label);
|
|
2011
|
+
const ariaLabel = entry.ariaLabel ?? [optionText, isGrouped ? entryLabel : void 0].filter(Boolean).join(" ");
|
|
2012
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
2013
|
+
isGrouped && (showSeriesLabels || showValueLabel) && /* @__PURE__ */ jsxs("div", { className: "mb-1.5 flex items-center justify-between gap-3", children: [
|
|
2014
|
+
showSeriesLabels ? /* @__PURE__ */ jsx(
|
|
2015
|
+
"span",
|
|
2016
|
+
{
|
|
2017
|
+
className: "min-w-0 break-words text-xs font-medium text-gray-500 dark:text-gray-400",
|
|
2018
|
+
style: groupedLabelStyle,
|
|
2019
|
+
children: entry.label
|
|
2020
|
+
}
|
|
2021
|
+
) : /* @__PURE__ */ jsx("span", {}),
|
|
2022
|
+
showValueLabel && /* @__PURE__ */ jsx(
|
|
2023
|
+
"span",
|
|
2024
|
+
{
|
|
2025
|
+
className: "shrink-0 text-xs font-semibold text-gray-600 dark:text-gray-300",
|
|
2026
|
+
style: groupedValueStyle,
|
|
2027
|
+
children: valueFormatter(entry.value, percent)
|
|
2028
|
+
}
|
|
2029
|
+
)
|
|
2030
|
+
] }),
|
|
2031
|
+
/* @__PURE__ */ jsx(
|
|
2032
|
+
"div",
|
|
2033
|
+
{
|
|
2034
|
+
role: "progressbar",
|
|
2035
|
+
"aria-label": ariaLabel || void 0,
|
|
2036
|
+
"aria-valuemin": 0,
|
|
2037
|
+
"aria-valuemax": safeMax,
|
|
2038
|
+
"aria-valuenow": clampValue(entry.value, safeMax),
|
|
2039
|
+
className: cn(
|
|
2040
|
+
"relative w-full overflow-hidden rounded-full bg-gray-100 dark:bg-gray-800",
|
|
2041
|
+
trackSizes[size]
|
|
2042
|
+
),
|
|
2043
|
+
style: trackColor ? { backgroundColor: trackColor } : void 0,
|
|
2044
|
+
children: /* @__PURE__ */ jsx(
|
|
2045
|
+
"div",
|
|
2046
|
+
{
|
|
2047
|
+
className: cn(
|
|
2048
|
+
"h-full rounded-full transition-all duration-300",
|
|
2049
|
+
fillColor ? void 0 : colorStyles[entryColor]
|
|
2050
|
+
),
|
|
2051
|
+
style: {
|
|
2052
|
+
width: `${percent}%`,
|
|
2053
|
+
...fillColor ? { backgroundColor: fillColor } : {}
|
|
2054
|
+
}
|
|
2055
|
+
}
|
|
2056
|
+
)
|
|
2057
|
+
}
|
|
2058
|
+
)
|
|
2059
|
+
] }, `${entryLabel ?? "series"}-${seriesIndex}`);
|
|
2060
|
+
}) })
|
|
2061
|
+
] }, `${optionText ?? "poll-option"}-${optionIndex}`);
|
|
2062
|
+
})
|
|
2063
|
+
}
|
|
2064
|
+
);
|
|
2065
|
+
};
|
|
1815
2066
|
var sizeStyles4 = {
|
|
1816
2067
|
sm: "h-4 w-4 border-2",
|
|
1817
2068
|
md: "h-6 w-6 border-2",
|
|
1818
2069
|
lg: "h-8 w-8 border-[3px]"
|
|
1819
2070
|
};
|
|
1820
|
-
var
|
|
2071
|
+
var colorStyles2 = {
|
|
1821
2072
|
primary: "text-brand-500",
|
|
1822
2073
|
success: "text-success-500",
|
|
1823
2074
|
error: "text-error-500",
|
|
@@ -1854,7 +2105,7 @@ var Spinner = ({
|
|
|
1854
2105
|
className: cn(
|
|
1855
2106
|
"inline-block animate-spin rounded-full border-current border-t-transparent",
|
|
1856
2107
|
sizeStyles4[size],
|
|
1857
|
-
!textColor &&
|
|
2108
|
+
!textColor && colorStyles2[color]
|
|
1858
2109
|
),
|
|
1859
2110
|
style: textColor ? { color: textColor } : void 0
|
|
1860
2111
|
}
|
|
@@ -2680,7 +2931,7 @@ var DatePicker = ({
|
|
|
2680
2931
|
useEffect(() => {
|
|
2681
2932
|
const flatPickr = flatpickr(`#${id}`, {
|
|
2682
2933
|
mode: mode || "single",
|
|
2683
|
-
|
|
2934
|
+
appendTo: document.body,
|
|
2684
2935
|
monthSelectorType: "static",
|
|
2685
2936
|
dateFormat: "Y-m-d",
|
|
2686
2937
|
defaultDate,
|
|
@@ -2736,7 +2987,7 @@ var DateTimePicker = ({
|
|
|
2736
2987
|
useEffect(() => {
|
|
2737
2988
|
const flatPickr = flatpickr(`#${id}-date`, {
|
|
2738
2989
|
mode: "single",
|
|
2739
|
-
|
|
2990
|
+
appendTo: document.body,
|
|
2740
2991
|
monthSelectorType: "static",
|
|
2741
2992
|
dateFormat: "Y-m-d",
|
|
2742
2993
|
defaultDate,
|
|
@@ -2945,6 +3196,6 @@ var Slider = ({
|
|
|
2945
3196
|
] });
|
|
2946
3197
|
};
|
|
2947
3198
|
|
|
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 };
|
|
3199
|
+
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
3200
|
//# sourceMappingURL=index.js.map
|
|
2950
3201
|
//# sourceMappingURL=index.js.map
|