@andreagiugni/tailwind-dashboard-ui 0.5.17 → 0.5.19
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 +1 -4
- package/dist/index.cjs +13 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +13 -5
- package/dist/index.js.map +1 -1
- package/package.json +22 -28
- package/src/theme.css +0 -17
- package/dist/chunk-HT7SQXRF.cjs +0 -85
- package/dist/chunk-HT7SQXRF.cjs.map +0 -1
- package/dist/chunk-R66LONPQ.js +0 -83
- package/dist/chunk-R66LONPQ.js.map +0 -1
- package/dist/components/Map/CountryMap.cjs +0 -13
- package/dist/components/Map/CountryMap.cjs.map +0 -1
- package/dist/components/Map/CountryMap.d.cts +0 -13
- package/dist/components/Map/CountryMap.d.ts +0 -13
- package/dist/components/Map/CountryMap.js +0 -4
- package/dist/components/Map/CountryMap.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -6,7 +6,6 @@ import flatpickr from 'flatpickr';
|
|
|
6
6
|
export { BarChart, BarChartProps } from './components/Charts/BarChart.cjs';
|
|
7
7
|
export { LineChart, LineChartProps } from './components/Charts/LineChart.cjs';
|
|
8
8
|
export { Calendar, CalendarProps } from './components/Calendar/Calendar.cjs';
|
|
9
|
-
export { CountryMap, CountryMapProps } from './components/Map/CountryMap.cjs';
|
|
10
9
|
export { ColorPicker, ColorPickerFormat, ColorPickerProps } from './components/ColorPicker/ColorPicker.cjs';
|
|
11
10
|
import '@tiptap/react';
|
|
12
11
|
import 'apexcharts';
|
|
@@ -83,6 +82,8 @@ interface DropdownProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
83
82
|
onClose: () => void;
|
|
84
83
|
/** Render under document.body so menus are not clipped by overflow containers. Default: true. */
|
|
85
84
|
portal?: boolean;
|
|
85
|
+
/** Optional ref to the trigger element. Useful when the trigger is not adjacent to the menu. */
|
|
86
|
+
triggerRef?: React.RefObject<HTMLElement | null>;
|
|
86
87
|
}
|
|
87
88
|
declare const Dropdown: React.FC<DropdownProps>;
|
|
88
89
|
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ import flatpickr from 'flatpickr';
|
|
|
6
6
|
export { BarChart, BarChartProps } from './components/Charts/BarChart.js';
|
|
7
7
|
export { LineChart, LineChartProps } from './components/Charts/LineChart.js';
|
|
8
8
|
export { Calendar, CalendarProps } from './components/Calendar/Calendar.js';
|
|
9
|
-
export { CountryMap, CountryMapProps } from './components/Map/CountryMap.js';
|
|
10
9
|
export { ColorPicker, ColorPickerFormat, ColorPickerProps } from './components/ColorPicker/ColorPicker.js';
|
|
11
10
|
import '@tiptap/react';
|
|
12
11
|
import 'apexcharts';
|
|
@@ -83,6 +82,8 @@ interface DropdownProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
83
82
|
onClose: () => void;
|
|
84
83
|
/** Render under document.body so menus are not clipped by overflow containers. Default: true. */
|
|
85
84
|
portal?: boolean;
|
|
85
|
+
/** Optional ref to the trigger element. Useful when the trigger is not adjacent to the menu. */
|
|
86
|
+
triggerRef?: React.RefObject<HTMLElement | null>;
|
|
86
87
|
}
|
|
87
88
|
declare const Dropdown: React.FC<DropdownProps>;
|
|
88
89
|
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
export { BarChart } from './chunk-YAKIMPXZ.js';
|
|
3
3
|
export { LineChart } from './chunk-NWIOJGF7.js';
|
|
4
4
|
export { Calendar, Modal } from './chunk-QGLKSM7S.js';
|
|
5
|
-
export { CountryMap } from './chunk-R66LONPQ.js';
|
|
6
5
|
export { Editor } from './chunk-DXUWFHPF.js';
|
|
7
6
|
export { ColorPicker } from './chunk-X3OP55FG.js';
|
|
8
7
|
import { layers } from './chunk-VX7S6VYG.js';
|
|
@@ -410,12 +409,20 @@ var AvatarText = ({
|
|
|
410
409
|
}
|
|
411
410
|
);
|
|
412
411
|
};
|
|
412
|
+
function getTriggerElement(anchor, triggerRef) {
|
|
413
|
+
if (triggerRef?.current) return triggerRef.current;
|
|
414
|
+
if (!anchor) return null;
|
|
415
|
+
const previous = anchor.previousElementSibling;
|
|
416
|
+
const adjacentTrigger = previous?.matches(".dropdown-toggle, button, [aria-haspopup='menu']") ? previous : previous?.querySelector(".dropdown-toggle, button, [aria-haspopup='menu']");
|
|
417
|
+
return adjacentTrigger ?? anchor.parentElement?.querySelector(".dropdown-toggle");
|
|
418
|
+
}
|
|
413
419
|
var Dropdown = ({
|
|
414
420
|
isOpen,
|
|
415
421
|
onClose,
|
|
416
422
|
children,
|
|
417
423
|
className,
|
|
418
424
|
portal = true,
|
|
425
|
+
triggerRef,
|
|
419
426
|
style,
|
|
420
427
|
...rest
|
|
421
428
|
}) => {
|
|
@@ -424,7 +431,8 @@ var Dropdown = ({
|
|
|
424
431
|
const [position, setPosition] = useState();
|
|
425
432
|
useEffect(() => {
|
|
426
433
|
const handleClickOutside = (event) => {
|
|
427
|
-
|
|
434
|
+
const trigger = getTriggerElement(anchorRef.current, triggerRef);
|
|
435
|
+
if (dropdownRef.current && !dropdownRef.current.contains(event.target) && !trigger?.contains(event.target)) {
|
|
428
436
|
onClose();
|
|
429
437
|
}
|
|
430
438
|
};
|
|
@@ -432,13 +440,13 @@ var Dropdown = ({
|
|
|
432
440
|
return () => {
|
|
433
441
|
document.removeEventListener("mousedown", handleClickOutside);
|
|
434
442
|
};
|
|
435
|
-
}, [onClose]);
|
|
443
|
+
}, [onClose, triggerRef]);
|
|
436
444
|
useLayoutEffect(() => {
|
|
437
445
|
if (!isOpen || !portal) return;
|
|
438
446
|
const updatePosition = () => {
|
|
439
447
|
const anchor = anchorRef.current;
|
|
440
448
|
const menu2 = dropdownRef.current;
|
|
441
|
-
const trigger = anchor
|
|
449
|
+
const trigger = getTriggerElement(anchor, triggerRef);
|
|
442
450
|
if (!anchor || !menu2) return;
|
|
443
451
|
const triggerRect = (trigger ?? anchor).getBoundingClientRect();
|
|
444
452
|
const menuRect = menu2.getBoundingClientRect();
|
|
@@ -459,7 +467,7 @@ var Dropdown = ({
|
|
|
459
467
|
window.removeEventListener("resize", updatePosition);
|
|
460
468
|
window.removeEventListener("scroll", updatePosition, true);
|
|
461
469
|
};
|
|
462
|
-
}, [isOpen, portal]);
|
|
470
|
+
}, [isOpen, portal, triggerRef]);
|
|
463
471
|
if (!isOpen) return null;
|
|
464
472
|
const menu = /* @__PURE__ */ jsx(
|
|
465
473
|
"div",
|