@carlonicora/nextjs-jsonapi 1.48.2 → 1.49.0

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.
@@ -93,7 +93,7 @@ var TableGeneratorRegistry = class _TableGeneratorRegistry {
93
93
  return _TableGeneratorRegistry.instance;
94
94
  }
95
95
  register(type, hook) {
96
- if (!this.registry.has(type)) this.registry.set(type, hook);
96
+ this.registry.set(type, hook);
97
97
  }
98
98
  get(type, params) {
99
99
  const hook = this.registry.get(type);
@@ -5120,7 +5120,7 @@ function TableRow({ className, ...props }) {
5120
5120
  "tr",
5121
5121
  {
5122
5122
  "data-slot": "table-row",
5123
- className: cn("hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors", className),
5123
+ className: cn("group hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors", className),
5124
5124
  ...props
5125
5125
  }
5126
5126
  );
@@ -6326,6 +6326,7 @@ MultiSelect.displayName = "MultiSelect";
6326
6326
  import { Command as CommandPrimitive2, useCommandState } from "cmdk";
6327
6327
  import { ChevronDownIcon as ChevronDownIcon5, X } from "lucide-react";
6328
6328
  import * as React12 from "react";
6329
+ import { createPortal as createPortal2 } from "react-dom";
6329
6330
  import { forwardRef as forwardRef5, useEffect as useEffect10 } from "react";
6330
6331
  import { Fragment as Fragment4, jsx as jsx51, jsxs as jsxs23 } from "react/jsx-runtime";
6331
6332
  function useDebounce2(value, delay) {
@@ -6419,13 +6420,16 @@ var MultipleSelector = React12.forwardRef(
6419
6420
  inputProps,
6420
6421
  hideClearAllButton = false,
6421
6422
  renderOption,
6422
- maxDisplayCount
6423
+ maxDisplayCount,
6424
+ usePortal = false
6423
6425
  }, ref) => {
6424
6426
  const inputRef = React12.useRef(null);
6427
+ const containerRef = React12.useRef(null);
6425
6428
  const [open, setOpen] = React12.useState(false);
6426
6429
  const [onScrollbar, setOnScrollbar] = React12.useState(false);
6427
6430
  const [isLoading, setIsLoading] = React12.useState(false);
6428
6431
  const dropdownRef = React12.useRef(null);
6432
+ const [dropdownPosition, setDropdownPosition] = React12.useState({ top: 0, left: 0, width: 0 });
6429
6433
  const [selected, setSelected] = React12.useState(value || []);
6430
6434
  const [options, setOptions] = React12.useState(transToGroupOption(arrayDefaultOptions, groupBy));
6431
6435
  const [inputValue, setInputValue] = React12.useState("");
@@ -6514,6 +6518,36 @@ var MultipleSelector = React12.forwardRef(
6514
6518
  }, "exec");
6515
6519
  void exec();
6516
6520
  }, [debouncedSearchTerm, groupBy, open, triggerSearchOnFocus, onSearchSync]);
6521
+ useEffect10(() => {
6522
+ if (!usePortal || !open || !containerRef.current) return;
6523
+ const updatePosition = /* @__PURE__ */ __name(() => {
6524
+ if (containerRef.current) {
6525
+ const rect = containerRef.current.getBoundingClientRect();
6526
+ setDropdownPosition({
6527
+ top: rect.bottom + window.scrollY + 4,
6528
+ left: rect.left + window.scrollX,
6529
+ width: rect.width
6530
+ });
6531
+ }
6532
+ }, "updatePosition");
6533
+ updatePosition();
6534
+ const handleScroll = /* @__PURE__ */ __name(() => {
6535
+ if (containerRef.current) {
6536
+ const rect = containerRef.current.getBoundingClientRect();
6537
+ if (rect.bottom < 0 || rect.top > window.innerHeight) {
6538
+ setOpen(false);
6539
+ } else {
6540
+ updatePosition();
6541
+ }
6542
+ }
6543
+ }, "handleScroll");
6544
+ window.addEventListener("scroll", handleScroll, true);
6545
+ window.addEventListener("resize", updatePosition);
6546
+ return () => {
6547
+ window.removeEventListener("scroll", handleScroll, true);
6548
+ window.removeEventListener("resize", updatePosition);
6549
+ };
6550
+ }, [usePortal, open]);
6517
6551
  useEffect10(() => {
6518
6552
  const doSearch = /* @__PURE__ */ __name(async () => {
6519
6553
  setIsLoading(true);
@@ -6604,6 +6638,7 @@ var MultipleSelector = React12.forwardRef(
6604
6638
  /* @__PURE__ */ jsxs23(
6605
6639
  "div",
6606
6640
  {
6641
+ ref: containerRef,
6607
6642
  className: cn(
6608
6643
  "flex min-h-10 items-start justify-between rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 md:text-sm",
6609
6644
  {
@@ -6712,7 +6747,7 @@ var MultipleSelector = React12.forwardRef(
6712
6747
  ]
6713
6748
  }
6714
6749
  ),
6715
- /* @__PURE__ */ jsx51("div", { className: "relative", children: open && /* @__PURE__ */ jsx51(
6750
+ !usePortal && /* @__PURE__ */ jsx51("div", { className: "relative", children: open && /* @__PURE__ */ jsx51(
6716
6751
  CommandList,
6717
6752
  {
6718
6753
  className: "absolute top-1 z-10 w-full rounded-md border bg-background text-foreground shadow-md outline-none animate-in",
@@ -6768,7 +6803,73 @@ var MultipleSelector = React12.forwardRef(
6768
6803
  ))
6769
6804
  ] })
6770
6805
  }
6771
- ) })
6806
+ ) }),
6807
+ usePortal && open && typeof window !== "undefined" && createPortal2(
6808
+ /* @__PURE__ */ jsx51(
6809
+ CommandList,
6810
+ {
6811
+ ref: dropdownRef,
6812
+ className: "fixed z-50 max-h-80 rounded-md border bg-background text-foreground shadow-md outline-none animate-in",
6813
+ style: {
6814
+ top: dropdownPosition.top,
6815
+ left: dropdownPosition.left,
6816
+ width: dropdownPosition.width
6817
+ },
6818
+ onMouseLeave: () => {
6819
+ setOnScrollbar(false);
6820
+ },
6821
+ onMouseEnter: () => {
6822
+ setOnScrollbar(true);
6823
+ },
6824
+ onMouseUp: () => {
6825
+ inputRef?.current?.focus();
6826
+ },
6827
+ children: isLoading ? /* @__PURE__ */ jsx51(Fragment4, { children: loadingIndicator }) : /* @__PURE__ */ jsxs23(Fragment4, { children: [
6828
+ EmptyItem(),
6829
+ CreatableItem(),
6830
+ !selectFirstItem && /* @__PURE__ */ jsx51(CommandItem, { value: "-", className: "hidden" }),
6831
+ Object.entries(selectables).map(([key, dropdowns]) => /* @__PURE__ */ jsx51(
6832
+ CommandGroup,
6833
+ {
6834
+ heading: key,
6835
+ className: "h-full overflow-auto [&_[cmdk-group-heading]]:border-b [&_[cmdk-group-heading]]:border-border/50 [&_[cmdk-group-heading]]:mb-1",
6836
+ children: /* @__PURE__ */ jsx51(Fragment4, { children: dropdowns.map((option) => {
6837
+ return /* @__PURE__ */ jsx51(
6838
+ CommandItem,
6839
+ {
6840
+ value: option.label,
6841
+ disabled: option.disable,
6842
+ onMouseDown: (e) => {
6843
+ e.preventDefault();
6844
+ e.stopPropagation();
6845
+ },
6846
+ onSelect: () => {
6847
+ if (selected.length >= maxSelected) {
6848
+ onMaxSelected?.(selected.length);
6849
+ return;
6850
+ }
6851
+ setInputValue("");
6852
+ const newOptions = [...selected, option];
6853
+ setSelected(newOptions);
6854
+ onChange?.(newOptions);
6855
+ },
6856
+ className: cn(
6857
+ "cursor-pointer bg-transparent hover:bg-accent data-selected:bg-transparent data-selected:hover:bg-accent",
6858
+ option.disable && "cursor-default text-muted-foreground"
6859
+ ),
6860
+ children: renderOption ? renderOption(option) : option.label
6861
+ },
6862
+ option.value
6863
+ );
6864
+ }) })
6865
+ },
6866
+ key
6867
+ ))
6868
+ ] })
6869
+ }
6870
+ ),
6871
+ document.body
6872
+ )
6772
6873
  ]
6773
6874
  }
6774
6875
  );
@@ -11160,7 +11261,7 @@ function ContentTitle({ module, type, element, functions, className, prioritizeF
11160
11261
  setClientFunctions(functions);
11161
11262
  }, [functions]);
11162
11263
  if (!element) return null;
11163
- return /* @__PURE__ */ jsxs67("div", { className: cn(`mb-4 flex items-center justify-between gap-x-4 w-full`, className), children: [
11264
+ return /* @__PURE__ */ jsxs67("div", { className: cn(`mb-4 flex items-start justify-between gap-x-4 w-full`, className), children: [
11164
11265
  /* @__PURE__ */ jsxs67("div", { className: cn("flex flex-col", prioritizeFunctions ? "min-w-0 shrink" : "w-full"), children: [
11165
11266
  type && /* @__PURE__ */ jsxs67(
11166
11267
  "div",
@@ -11447,7 +11548,7 @@ __name(AllowedUsersDetails, "AllowedUsersDetails");
11447
11548
  import dynamic from "next/dynamic";
11448
11549
  import React16 from "react";
11449
11550
  import { jsx as jsx128 } from "react/jsx-runtime";
11450
- var BlockNoteEditor = dynamic(() => import("./BlockNoteEditor-DM43MVV3.mjs"), {
11551
+ var BlockNoteEditor = dynamic(() => import("./BlockNoteEditor-WLS36QIF.mjs"), {
11451
11552
  ssr: false
11452
11553
  });
11453
11554
  var BlockNoteEditorContainer = React16.memo(/* @__PURE__ */ __name(function EditorContainer(props) {
@@ -17419,4 +17520,4 @@ export {
17419
17520
  useOAuthClients,
17420
17521
  useOAuthClient
17421
17522
  };
17422
- //# sourceMappingURL=chunk-PZGFGYEO.mjs.map
17523
+ //# sourceMappingURL=chunk-VQ35TGD7.mjs.map