@carlonicora/nextjs-jsonapi 1.140.2 → 1.141.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.
@@ -48,7 +48,7 @@ import {
48
48
  TabsList,
49
49
  TabsTrigger,
50
50
  useCurrentUserContext
51
- } from "../chunk-LB5B5KYF.mjs";
51
+ } from "../chunk-7TKD4SMQ.mjs";
52
52
  import {
53
53
  getRoleId,
54
54
  getStripePublishableKey
@@ -9842,7 +9842,10 @@ import {
9842
9842
  useRef as useRef16,
9843
9843
  useState as useState24
9844
9844
  } from "react";
9845
- import { useDropzone } from "react-dropzone";
9845
+ import {
9846
+ ErrorCode,
9847
+ useDropzone
9848
+ } from "react-dropzone";
9846
9849
  import { jsx as jsx85, jsxs as jsxs50 } from "react/jsx-runtime";
9847
9850
  var FileUploaderContext = createContext11(null);
9848
9851
  var useFileUpload = /* @__PURE__ */ __name(() => {
@@ -9853,7 +9856,18 @@ var useFileUpload = /* @__PURE__ */ __name(() => {
9853
9856
  return context;
9854
9857
  }, "useFileUpload");
9855
9858
  var FileUploader = forwardRef6(
9856
- ({ className, dropzoneOptions, value, onValueChange, reSelect, orientation = "vertical", children, dir, ...props }, ref) => {
9859
+ ({
9860
+ className,
9861
+ dropzoneOptions,
9862
+ value,
9863
+ onValueChange,
9864
+ reSelect,
9865
+ orientation = "vertical",
9866
+ children,
9867
+ dir,
9868
+ onFilesRejected,
9869
+ ...props
9870
+ }, ref) => {
9857
9871
  const [isFileTooBig, setIsFileTooBig] = useState24(false);
9858
9872
  const [isLOF, setIsLOF] = useState24(false);
9859
9873
  const [activeIndex, setActiveIndex] = useState24(-1);
@@ -9920,12 +9934,20 @@ var FileUploader = forwardRef6(
9920
9934
  if (reSelectAll) {
9921
9935
  newValues.splice(0, newValues.length);
9922
9936
  }
9923
- files.forEach((file) => {
9924
- if (newValues.length < maxFiles) {
9925
- newValues.push(file);
9926
- }
9927
- });
9937
+ const remaining = Math.max(0, maxFiles - newValues.length);
9938
+ const admitted = files.slice(0, remaining);
9939
+ const overflow = files.slice(remaining);
9940
+ admitted.forEach((file) => newValues.push(file));
9928
9941
  onValueChange(newValues);
9942
+ if (onFilesRejected) {
9943
+ const overflowRejections = overflow.map((file) => ({
9944
+ file,
9945
+ errors: [{ code: ErrorCode.TooManyFiles, message: `Too many files. Only ${maxFiles} allowed.` }]
9946
+ }));
9947
+ const allRejections = [...rejectedFiles, ...overflowRejections];
9948
+ if (allRejections.length > 0) onFilesRejected(allRejections);
9949
+ return;
9950
+ }
9929
9951
  if (rejectedFiles.length > 0) {
9930
9952
  for (let i = 0; i < rejectedFiles.length; i++) {
9931
9953
  if (rejectedFiles[i].errors[0]?.code === "file-too-large") {
@@ -9943,7 +9965,7 @@ var FileUploader = forwardRef6(
9943
9965
  }
9944
9966
  }
9945
9967
  },
9946
- [reSelectAll, value]
9968
+ [reSelectAll, value, maxFiles, maxSize, onValueChange, onFilesRejected, t]
9947
9969
  );
9948
9970
  useEffect19(() => {
9949
9971
  if (!value) return;
@@ -10131,7 +10153,7 @@ import { useRef as useRef17 } from "react";
10131
10153
  import dynamic from "next/dynamic";
10132
10154
  import React17 from "react";
10133
10155
  import { jsx as jsx86 } from "react/jsx-runtime";
10134
- var BlockNoteEditor = dynamic(() => import("./BlockNoteEditor-5ZEC7GOM.mjs"), {
10156
+ var BlockNoteEditor = dynamic(() => import("./BlockNoteEditor-UNYOBY7K.mjs"), {
10135
10157
  ssr: false
10136
10158
  });
10137
10159
  var BlockNoteEditorContainer = React17.memo(/* @__PURE__ */ __name(function EditorContainer(props) {
@@ -23917,4 +23939,4 @@ export {
23917
23939
  useOAuthClients,
23918
23940
  useOAuthClient
23919
23941
  };
23920
- //# sourceMappingURL=chunk-LB5B5KYF.mjs.map
23942
+ //# sourceMappingURL=chunk-7TKD4SMQ.mjs.map