@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 CHANGED
@@ -38,7 +38,6 @@ data-viz component:
38
38
  |---|---|
39
39
  | `BarChart`, `LineChart` | `apexcharts`, `react-apexcharts` |
40
40
  | `Calendar` | `@fullcalendar/core`, `@fullcalendar/react`, `@fullcalendar/daygrid`, `@fullcalendar/timegrid`, `@fullcalendar/list`, `@fullcalendar/interaction` |
41
- | `CountryMap` | `@react-jvectormap/core`, `@react-jvectormap/world` |
42
41
  | `Editor` (WYSIWYG) | `@tiptap/react`, `@tiptap/pm`, `@tiptap/starter-kit`, `@tiptap/extension-link`, `@tiptap/extension-placeholder`, `@tiptap/extension-superscript`, `@tiptap/extension-subscript` |
43
42
 
44
43
  Install only the ones for the components you use, e.g.:
@@ -124,7 +123,6 @@ import {
124
123
  BarChart,
125
124
  LineChart,
126
125
  Calendar,
127
- CountryMap,
128
126
  Editor,
129
127
  } from '@andreagiugni/tailwind-dashboard-ui';
130
128
  ```
@@ -167,7 +165,7 @@ Legend: **(+native)** = also extends the element's native HTML attributes.
167
165
  | `Alert` | `variant` (success/error/warning/info), `title`, `message`, `showLink`, `linkHref`, `linkText`, `icon?` (override icon), (+native div) |
168
166
  | `Avatar` | `src`, `alt`, `size` (xsmall…xxlarge), `status` (online/offline/busy/none), `statusColor?`, (+native img) |
169
167
  | `AvatarText` | `children`, `className`, (+native div) |
170
- | `Dropdown` | `isOpen`, `onClose`, `children`, `portal?` (default `true`, prevents clipping inside tables/overflow containers), (+native div) |
168
+ | `Dropdown` | `isOpen`, `onClose`, `children`, `portal?` (default `true`, prevents clipping inside cards/tables/overflow containers), `triggerRef?` (optional custom trigger anchor), (+native div) |
171
169
  | `DropdownItem` | `variant` (default/primary/outline, like Button), `icon?`, `bgColor`/`textColor`/`borderColor` overrides, `tag` (a/button), `href`, `onClick`, `onItemClick`, `baseClassName` (full override) |
172
170
  | `Modal` | `isOpen`, `onClose`, `title?` (wrapping header aligned with close button), `showCloseButton`, `isFullscreen`, `closeOnBackdrop?`, `closeOnEsc?`; **alert preset** → `variant` (`success`/`info`/`warning`/`danger`) + `title`, `description`, `actionText?`, `onAction?`; (+native div) |
173
171
  | `Table` (composable) | `TableHeader` / `TableBody` / `TableRow` / `TableCell` with `children`, `isHeader` (cell), (+native table elements; `onClick` / `onDoubleClick` on rows & cells) |
@@ -225,7 +223,6 @@ in [Peer dependencies](#peer-dependencies)).
225
223
  | `BarChart` | `series`, `categories`, `colors?`, `height?`, `options?` (merged over defaults) |
226
224
  | `LineChart` | `series`, `categories`, `colors?`, `height?`, `options?` |
227
225
  | `Calendar` | `events`, `onEventClick`, `onDateSelect`, `initialView` |
228
- | `CountryMap` | `markers`, `markerColor?`, `mapColor?` |
229
226
  | `Editor` (WYSIWYG) | `content`, `onChange(html)`, `placeholder?`, `editable?`, `toolbar?` — Tiptap-powered, customizable toolbar |
230
227
 
231
228
  > The data-viz components default their data to sensible demo values, so they render
package/dist/index.cjs CHANGED
@@ -4,7 +4,6 @@
4
4
  var chunk2C5QY3Z2_cjs = require('./chunk-2C5QY3Z2.cjs');
5
5
  var chunk3EE6CPHW_cjs = require('./chunk-3EE6CPHW.cjs');
6
6
  var chunkYSON6RJC_cjs = require('./chunk-YSON6RJC.cjs');
7
- var chunkHT7SQXRF_cjs = require('./chunk-HT7SQXRF.cjs');
8
7
  var chunkS4ADL5B7_cjs = require('./chunk-S4ADL5B7.cjs');
9
8
  var chunkH4UQ67RI_cjs = require('./chunk-H4UQ67RI.cjs');
10
9
  var chunkTF3G3E72_cjs = require('./chunk-TF3G3E72.cjs');
@@ -416,12 +415,20 @@ var AvatarText = ({
416
415
  }
417
416
  );
418
417
  };
418
+ function getTriggerElement(anchor, triggerRef) {
419
+ if (triggerRef?.current) return triggerRef.current;
420
+ if (!anchor) return null;
421
+ const previous = anchor.previousElementSibling;
422
+ const adjacentTrigger = previous?.matches(".dropdown-toggle, button, [aria-haspopup='menu']") ? previous : previous?.querySelector(".dropdown-toggle, button, [aria-haspopup='menu']");
423
+ return adjacentTrigger ?? anchor.parentElement?.querySelector(".dropdown-toggle");
424
+ }
419
425
  var Dropdown = ({
420
426
  isOpen,
421
427
  onClose,
422
428
  children,
423
429
  className,
424
430
  portal = true,
431
+ triggerRef,
425
432
  style,
426
433
  ...rest
427
434
  }) => {
@@ -430,7 +437,8 @@ var Dropdown = ({
430
437
  const [position, setPosition] = React5.useState();
431
438
  React5.useEffect(() => {
432
439
  const handleClickOutside = (event) => {
433
- if (dropdownRef.current && !dropdownRef.current.contains(event.target) && !event.target.closest(".dropdown-toggle")) {
440
+ const trigger = getTriggerElement(anchorRef.current, triggerRef);
441
+ if (dropdownRef.current && !dropdownRef.current.contains(event.target) && !trigger?.contains(event.target)) {
434
442
  onClose();
435
443
  }
436
444
  };
@@ -438,13 +446,13 @@ var Dropdown = ({
438
446
  return () => {
439
447
  document.removeEventListener("mousedown", handleClickOutside);
440
448
  };
441
- }, [onClose]);
449
+ }, [onClose, triggerRef]);
442
450
  React5.useLayoutEffect(() => {
443
451
  if (!isOpen || !portal) return;
444
452
  const updatePosition = () => {
445
453
  const anchor = anchorRef.current;
446
454
  const menu2 = dropdownRef.current;
447
- const trigger = anchor?.parentElement?.querySelector(".dropdown-toggle");
455
+ const trigger = getTriggerElement(anchor, triggerRef);
448
456
  if (!anchor || !menu2) return;
449
457
  const triggerRect = (trigger ?? anchor).getBoundingClientRect();
450
458
  const menuRect = menu2.getBoundingClientRect();
@@ -465,7 +473,7 @@ var Dropdown = ({
465
473
  window.removeEventListener("resize", updatePosition);
466
474
  window.removeEventListener("scroll", updatePosition, true);
467
475
  };
468
- }, [isOpen, portal]);
476
+ }, [isOpen, portal, triggerRef]);
469
477
  if (!isOpen) return null;
470
478
  const menu = /* @__PURE__ */ jsxRuntime.jsx(
471
479
  "div",
@@ -3311,10 +3319,6 @@ Object.defineProperty(exports, "Modal", {
3311
3319
  enumerable: true,
3312
3320
  get: function () { return chunkYSON6RJC_cjs.Modal; }
3313
3321
  });
3314
- Object.defineProperty(exports, "CountryMap", {
3315
- enumerable: true,
3316
- get: function () { return chunkHT7SQXRF_cjs.CountryMap; }
3317
- });
3318
3322
  Object.defineProperty(exports, "Editor", {
3319
3323
  enumerable: true,
3320
3324
  get: function () { return chunkS4ADL5B7_cjs.Editor; }