@pixpilot/shadcn 1.2.0 → 1.2.2

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.
@@ -1,48 +1,48 @@
1
1
  import * as React from "react";
2
- import * as react_jsx_runtime12 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime8 from "react/jsx-runtime";
3
3
  import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog";
4
4
 
5
5
  //#region src/components/ui/alert-dialog.d.ts
6
6
  declare function AlertDialog({
7
7
  ...props
8
- }: React.ComponentProps<typeof AlertDialogPrimitive.Root>): react_jsx_runtime12.JSX.Element;
8
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Root>): react_jsx_runtime8.JSX.Element;
9
9
  declare function AlertDialogTrigger({
10
10
  ...props
11
- }: React.ComponentProps<typeof AlertDialogPrimitive.Trigger>): react_jsx_runtime12.JSX.Element;
11
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Trigger>): react_jsx_runtime8.JSX.Element;
12
12
  declare function AlertDialogPortal({
13
13
  ...props
14
- }: React.ComponentProps<typeof AlertDialogPrimitive.Portal>): react_jsx_runtime12.JSX.Element;
14
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Portal>): react_jsx_runtime8.JSX.Element;
15
15
  declare function AlertDialogOverlay({
16
16
  className,
17
17
  ...props
18
- }: React.ComponentProps<typeof AlertDialogPrimitive.Overlay>): react_jsx_runtime12.JSX.Element;
18
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Overlay>): react_jsx_runtime8.JSX.Element;
19
19
  declare function AlertDialogContent({
20
20
  className,
21
21
  ...props
22
- }: React.ComponentProps<typeof AlertDialogPrimitive.Content>): react_jsx_runtime12.JSX.Element;
22
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Content>): react_jsx_runtime8.JSX.Element;
23
23
  declare function AlertDialogHeader({
24
24
  className,
25
25
  ...props
26
- }: React.ComponentProps<'div'>): react_jsx_runtime12.JSX.Element;
26
+ }: React.ComponentProps<'div'>): react_jsx_runtime8.JSX.Element;
27
27
  declare function AlertDialogFooter({
28
28
  className,
29
29
  ...props
30
- }: React.ComponentProps<'div'>): react_jsx_runtime12.JSX.Element;
30
+ }: React.ComponentProps<'div'>): react_jsx_runtime8.JSX.Element;
31
31
  declare function AlertDialogTitle({
32
32
  className,
33
33
  ...props
34
- }: React.ComponentProps<typeof AlertDialogPrimitive.Title>): react_jsx_runtime12.JSX.Element;
34
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Title>): react_jsx_runtime8.JSX.Element;
35
35
  declare function AlertDialogDescription({
36
36
  className,
37
37
  ...props
38
- }: React.ComponentProps<typeof AlertDialogPrimitive.Description>): react_jsx_runtime12.JSX.Element;
38
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Description>): react_jsx_runtime8.JSX.Element;
39
39
  declare function AlertDialogAction({
40
40
  className,
41
41
  ...props
42
- }: React.ComponentProps<typeof AlertDialogPrimitive.Action>): react_jsx_runtime12.JSX.Element;
42
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Action>): react_jsx_runtime8.JSX.Element;
43
43
  declare function AlertDialogCancel({
44
44
  className,
45
45
  ...props
46
- }: React.ComponentProps<typeof AlertDialogPrimitive.Cancel>): react_jsx_runtime12.JSX.Element;
46
+ }: React.ComponentProps<typeof AlertDialogPrimitive.Cancel>): react_jsx_runtime8.JSX.Element;
47
47
  //#endregion
48
48
  export { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger };
@@ -1,6 +1,6 @@
1
1
  import { VariantProps } from "class-variance-authority";
2
2
  import * as React from "react";
3
- import * as react_jsx_runtime9 from "react/jsx-runtime";
3
+ import * as react_jsx_runtime5 from "react/jsx-runtime";
4
4
  import * as class_variance_authority_types0 from "class-variance-authority/types";
5
5
 
6
6
  //#region src/components/ui/alert.d.ts
@@ -11,14 +11,14 @@ declare function Alert({
11
11
  className,
12
12
  variant,
13
13
  ...props
14
- }: React.ComponentProps<'div'> & VariantProps<typeof alertVariants>): react_jsx_runtime9.JSX.Element;
14
+ }: React.ComponentProps<'div'> & VariantProps<typeof alertVariants>): react_jsx_runtime5.JSX.Element;
15
15
  declare function AlertTitle({
16
16
  className,
17
17
  ...props
18
- }: React.ComponentProps<'div'>): react_jsx_runtime9.JSX.Element;
18
+ }: React.ComponentProps<'div'>): react_jsx_runtime5.JSX.Element;
19
19
  declare function AlertDescription({
20
20
  className,
21
21
  ...props
22
- }: React.ComponentProps<'div'>): react_jsx_runtime9.JSX.Element;
22
+ }: React.ComponentProps<'div'>): react_jsx_runtime5.JSX.Element;
23
23
  //#endregion
24
24
  export { Alert, AlertDescription, AlertTitle };
@@ -1,19 +1,19 @@
1
1
  import * as React from "react";
2
- import * as react_jsx_runtime23 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime19 from "react/jsx-runtime";
3
3
  import * as AvatarPrimitive from "@radix-ui/react-avatar";
4
4
 
5
5
  //#region src/components/ui/avatar.d.ts
6
6
  declare function Avatar({
7
7
  className,
8
8
  ...props
9
- }: React.ComponentProps<typeof AvatarPrimitive.Root>): react_jsx_runtime23.JSX.Element;
9
+ }: React.ComponentProps<typeof AvatarPrimitive.Root>): react_jsx_runtime19.JSX.Element;
10
10
  declare function AvatarImage({
11
11
  className,
12
12
  ...props
13
- }: React.ComponentProps<typeof AvatarPrimitive.Image>): react_jsx_runtime23.JSX.Element;
13
+ }: React.ComponentProps<typeof AvatarPrimitive.Image>): react_jsx_runtime19.JSX.Element;
14
14
  declare function AvatarFallback({
15
15
  className,
16
16
  ...props
17
- }: React.ComponentProps<typeof AvatarPrimitive.Fallback>): react_jsx_runtime23.JSX.Element;
17
+ }: React.ComponentProps<typeof AvatarPrimitive.Fallback>): react_jsx_runtime19.JSX.Element;
18
18
  //#endregion
19
19
  export { Avatar, AvatarFallback, AvatarImage };
@@ -27,6 +27,14 @@ interface FileUploadRootProps extends Omit<React.ComponentProps<'div'>, 'default
27
27
  message: string;
28
28
  }>) => void;
29
29
  onFileValidate?: (file: File) => string | null | undefined;
30
+ /**
31
+ * Optional async transform applied to each accepted file before it enters
32
+ * the store. Return the same file to leave it unchanged, or return a new
33
+ * `File` (e.g. after EXIF stripping) to replace it. All subsequent
34
+ * callbacks — `onProgress`, `onSuccess`, `onError` — will reference the
35
+ * returned file.
36
+ */
37
+ transformFile?: (file: File) => Promise<File> | File;
30
38
  onUpload?: (files: File[], options: {
31
39
  onProgress: (file: File, progress: number) => void;
32
40
  onSuccess: (file: File) => void;
@@ -182,7 +182,7 @@ function useFileUploadContext(consumerName) {
182
182
  return context;
183
183
  }
184
184
  function FileUploadRoot(props) {
185
- const { value, defaultValue, onValueChange, onAccept, onFileAccept, onFileReject, onFilesReject, onFileValidate, onUpload, accept, maxFiles, maxSize, dir: dirProp, label, name, asChild, disabled = false, invalid = false, multiple = false, required = false, children, className,...rootProps } = props;
185
+ const { value, defaultValue, onValueChange, onAccept, onFileAccept, onFileReject, onFilesReject, onFileValidate, transformFile, onUpload, accept, maxFiles, maxSize, dir: dirProp, label, name, asChild, disabled = false, invalid = false, multiple = false, required = false, children, className,...rootProps } = props;
186
186
  const inputId = React.useId();
187
187
  const dropzoneId = React.useId();
188
188
  const listId = React.useId();
@@ -190,6 +190,7 @@ function FileUploadRoot(props) {
190
190
  const dir = useDirection(dirProp);
191
191
  const listeners = useLazyRef(() => /* @__PURE__ */ new Set()).current;
192
192
  const files = useLazyRef(() => /* @__PURE__ */ new Map()).current;
193
+ const progressFrames = useLazyRef(() => /* @__PURE__ */ new Map()).current;
193
194
  const urlCache = useLazyRef(() => /* @__PURE__ */ new WeakMap()).current;
194
195
  const inputRef = React.useRef(null);
195
196
  const isControlled = value !== void 0;
@@ -201,18 +202,24 @@ function FileUploadRoot(props) {
201
202
  urlCache
202
203
  ]);
203
204
  const acceptTypes = React.useMemo(() => accept?.split(",").map((t) => t.trim()) ?? null, [accept]);
205
+ const cancelPendingProgress = React.useCallback((file) => {
206
+ const frameId = progressFrames.get(file);
207
+ if (frameId === void 0) return;
208
+ cancelAnimationFrame(frameId);
209
+ progressFrames.delete(file);
210
+ }, [progressFrames]);
204
211
  const onProgress = useLazyRef(() => {
205
- let frame = 0;
206
212
  return (file, progress) => {
207
- if (frame) return;
208
- frame = requestAnimationFrame(() => {
209
- frame = 0;
213
+ cancelPendingProgress(file);
214
+ const frameId = requestAnimationFrame(() => {
215
+ progressFrames.delete(file);
210
216
  store.dispatch({
211
217
  type: "SET_PROGRESS",
212
218
  file,
213
219
  progress: Math.min(Math.max(0, progress), 100)
214
220
  });
215
221
  });
222
+ progressFrames.set(file, frameId);
216
223
  };
217
224
  }).current;
218
225
  React.useEffect(() => {
@@ -232,12 +239,18 @@ function FileUploadRoot(props) {
232
239
  ]);
233
240
  React.useEffect(() => {
234
241
  return () => {
242
+ for (const frameId of progressFrames.values()) cancelAnimationFrame(frameId);
243
+ progressFrames.clear();
235
244
  for (const file of files.keys()) {
236
245
  const cachedUrl = urlCache.get(file);
237
246
  if (cachedUrl) URL.revokeObjectURL(cachedUrl);
238
247
  }
239
248
  };
240
- }, [files, urlCache]);
249
+ }, [
250
+ files,
251
+ progressFrames,
252
+ urlCache
253
+ ]);
241
254
  const onFilesUpload = React.useCallback(async (files$1) => {
242
255
  try {
243
256
  for (const file of files$1) store.dispatch({
@@ -248,12 +261,14 @@ function FileUploadRoot(props) {
248
261
  if (onUpload) await onUpload(files$1, {
249
262
  onProgress,
250
263
  onSuccess: (file) => {
264
+ cancelPendingProgress(file);
251
265
  store.dispatch({
252
266
  type: "SET_SUCCESS",
253
267
  file
254
268
  });
255
269
  },
256
270
  onError: (file, error) => {
271
+ cancelPendingProgress(file);
257
272
  store.dispatch({
258
273
  type: "SET_ERROR",
259
274
  file,
@@ -261,19 +276,26 @@ function FileUploadRoot(props) {
261
276
  });
262
277
  }
263
278
  });
264
- else for (const file of files$1) store.dispatch({
265
- type: "SET_SUCCESS",
266
- file
267
- });
279
+ else for (const file of files$1) {
280
+ cancelPendingProgress(file);
281
+ store.dispatch({
282
+ type: "SET_SUCCESS",
283
+ file
284
+ });
285
+ }
268
286
  } catch (error) {
269
287
  const errorMessage = error instanceof Error ? error.message : "Upload failed";
270
- for (const file of files$1) store.dispatch({
271
- type: "SET_ERROR",
272
- file,
273
- error: errorMessage
274
- });
288
+ for (const file of files$1) {
289
+ cancelPendingProgress(file);
290
+ store.dispatch({
291
+ type: "SET_ERROR",
292
+ file,
293
+ error: errorMessage
294
+ });
295
+ }
275
296
  }
276
297
  }, [
298
+ cancelPendingProgress,
277
299
  store,
278
300
  onUpload,
279
301
  onProgress
@@ -355,18 +377,19 @@ function FileUploadRoot(props) {
355
377
  }, 2e3);
356
378
  }
357
379
  if (allRejectedFiles.length > 0) onFilesReject?.(allRejectedFiles);
358
- if (acceptedFiles.length > 0) {
380
+ if (acceptedFiles.length > 0) (async () => {
381
+ const finalFiles = transformFile ? await Promise.all(acceptedFiles.map(async (file) => transformFile(file))) : acceptedFiles;
359
382
  store.dispatch({
360
383
  type: "ADD_FILES",
361
- files: acceptedFiles
384
+ files: finalFiles
362
385
  });
363
386
  if (isControlled && onValueChange) onValueChange([...Array.from(store.getState().files.values()).map((f) => f.file)]);
364
- if (onAccept) onAccept(acceptedFiles);
365
- for (const file of acceptedFiles) onFileAccept?.(file);
387
+ if (onAccept) onAccept(finalFiles);
388
+ for (const file of finalFiles) onFileAccept?.(file);
366
389
  if (onUpload) requestAnimationFrame(() => {
367
- onFilesUpload(acceptedFiles);
390
+ onFilesUpload(finalFiles);
368
391
  });
369
- }
392
+ })();
370
393
  }, [
371
394
  store,
372
395
  isControlled,
@@ -375,6 +398,7 @@ function FileUploadRoot(props) {
375
398
  onFileAccept,
376
399
  onUpload,
377
400
  onFilesUpload,
401
+ transformFile,
378
402
  maxFiles,
379
403
  onFileValidate,
380
404
  onFileReject,
@@ -1,23 +1,23 @@
1
1
  import * as React from "react";
2
- import * as react_jsx_runtime5 from "react/jsx-runtime";
2
+ import * as react_jsx_runtime22 from "react/jsx-runtime";
3
3
  import * as TooltipPrimitive from "@radix-ui/react-tooltip";
4
4
 
5
5
  //#region src/components/ui/tooltip.d.ts
6
6
  declare function TooltipProvider({
7
7
  delayDuration,
8
8
  ...props
9
- }: React.ComponentProps<typeof TooltipPrimitive.Provider>): react_jsx_runtime5.JSX.Element;
9
+ }: React.ComponentProps<typeof TooltipPrimitive.Provider>): react_jsx_runtime22.JSX.Element;
10
10
  declare function Tooltip({
11
11
  ...props
12
- }: React.ComponentProps<typeof TooltipPrimitive.Root>): react_jsx_runtime5.JSX.Element;
12
+ }: React.ComponentProps<typeof TooltipPrimitive.Root>): react_jsx_runtime22.JSX.Element;
13
13
  declare function TooltipTrigger({
14
14
  ...props
15
- }: React.ComponentProps<typeof TooltipPrimitive.Trigger>): react_jsx_runtime5.JSX.Element;
15
+ }: React.ComponentProps<typeof TooltipPrimitive.Trigger>): react_jsx_runtime22.JSX.Element;
16
16
  declare function TooltipContent({
17
17
  className,
18
18
  sideOffset,
19
19
  children,
20
20
  ...props
21
- }: React.ComponentProps<typeof TooltipPrimitive.Content>): react_jsx_runtime5.JSX.Element;
21
+ }: React.ComponentProps<typeof TooltipPrimitive.Content>): react_jsx_runtime22.JSX.Element;
22
22
  //#endregion
23
23
  export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pixpilot/shadcn",
3
3
  "type": "module",
4
- "version": "1.2.0",
4
+ "version": "1.2.2",
5
5
  "description": "A collection of reusable UI components built with shadcn/ui and Radix UI primitives.",
6
6
  "author": "m.doaie <m.doaie@hotmail.com>",
7
7
  "license": "MIT",