@uselets/ui 1.20.4 → 2.0.1
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 +309 -426
- package/dist/as-child-Dxg3Xo1G.d.ts +41 -0
- package/dist/cli/uselets.mjs +5 -4
- package/dist/cli/uselets.mjs.map +1 -1
- package/dist/components/accordion.d.ts +12 -8
- package/dist/components/accordion.js +1 -1
- package/dist/components/accordion.js.map +1 -1
- package/dist/components/alert-dialog.d.ts +22 -15
- package/dist/components/alert-dialog.js +1 -1
- package/dist/components/alert-dialog.js.map +1 -1
- package/dist/components/alert.d.ts +1 -1
- package/dist/components/anchor.d.ts +3 -5
- package/dist/components/anchor.js +1 -1
- package/dist/components/anchor.js.map +1 -1
- package/dist/components/area-chart.d.ts +54 -0
- package/dist/components/area-chart.js +1 -1
- package/dist/components/area-chart.js.map +1 -1
- package/dist/components/avatar.d.ts +12 -7
- package/dist/components/avatar.js +1 -1
- package/dist/components/avatar.js.map +1 -1
- package/dist/components/badge.d.ts +3 -5
- package/dist/components/badge.js +1 -1
- package/dist/components/badge.js.map +1 -1
- package/dist/components/bar-chart.d.ts +48 -0
- package/dist/components/bar-chart.js +1 -1
- package/dist/components/bar-chart.js.map +1 -1
- package/dist/components/bottom-nav.d.ts +7 -3
- package/dist/components/bottom-nav.js +1 -1
- package/dist/components/bottom-nav.js.map +1 -1
- package/dist/components/breadcrumb.d.ts +3 -4
- package/dist/components/breadcrumb.js +1 -1
- package/dist/components/breadcrumb.js.map +1 -1
- package/dist/components/button-group.d.ts +3 -4
- package/dist/components/button-group.js +1 -1
- package/dist/components/button-group.js.map +1 -1
- package/dist/components/button.d.ts +8 -4
- package/dist/components/button.js +1 -1
- package/dist/components/button.js.map +1 -1
- package/dist/components/calendar.d.ts +4 -0
- package/dist/components/calendar.js +1 -1
- package/dist/components/calendar.js.map +1 -1
- package/dist/components/card.d.ts +4 -0
- package/dist/components/card.js.map +1 -1
- package/dist/components/carousel.d.ts +11 -3
- package/dist/components/carousel.js +1 -1
- package/dist/components/carousel.js.map +1 -1
- package/dist/components/center.d.ts +1 -1
- package/dist/components/chart.js +4 -4
- package/dist/components/checkbox.d.ts +14 -4
- package/dist/components/checkbox.js +1 -1
- package/dist/components/checkbox.js.map +1 -1
- package/dist/components/collapsible.d.ts +8 -7
- package/dist/components/collapsible.js +1 -1
- package/dist/components/collapsible.js.map +1 -1
- package/dist/components/combobox.d.ts +48 -26
- package/dist/components/combobox.js +1 -1
- package/dist/components/combobox.js.map +1 -1
- package/dist/components/command.d.ts +16 -2
- package/dist/components/command.js +1 -1
- package/dist/components/command.js.map +1 -1
- package/dist/components/container.d.ts +1 -1
- package/dist/components/data-table.d.ts +39 -0
- package/dist/components/data-table.js +1 -1
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/date-range-picker.d.ts +24 -2
- package/dist/components/date-range-picker.js +1 -1
- package/dist/components/date-range-picker.js.map +1 -1
- package/dist/components/dialog.d.ts +35 -15
- package/dist/components/dialog.js +1 -1
- package/dist/components/dialog.js.map +1 -1
- package/dist/components/direction.d.ts +7 -0
- package/dist/components/direction.js +1 -0
- package/dist/components/donut-chart.d.ts +12 -0
- package/dist/components/donut-chart.js +1 -1
- package/dist/components/donut-chart.js.map +1 -1
- package/dist/components/drawer.d.ts +33 -15
- package/dist/components/drawer.js +1 -1
- package/dist/components/drawer.js.map +1 -1
- package/dist/components/dropdown-menu.d.ts +36 -26
- package/dist/components/dropdown-menu.js +1 -1
- package/dist/components/dropdown-menu.js.map +1 -1
- package/dist/components/dropzone.d.ts +19 -0
- package/dist/components/dropzone.js +1 -1
- package/dist/components/dropzone.js.map +1 -1
- package/dist/components/field.d.ts +16 -4
- package/dist/components/field.js +1 -1
- package/dist/components/field.js.map +1 -1
- package/dist/components/flex.d.ts +1 -1
- package/dist/components/grid.d.ts +13 -0
- package/dist/components/grid.js.map +1 -1
- package/dist/components/group.d.ts +1 -1
- package/dist/components/heading.d.ts +3 -5
- package/dist/components/heading.js +1 -1
- package/dist/components/heading.js.map +1 -1
- package/dist/components/hover-card.d.ts +7 -6
- package/dist/components/hover-card.js +1 -1
- package/dist/components/hover-card.js.map +1 -1
- package/dist/components/input-group.d.ts +2 -2
- package/dist/components/input-group.js +1 -1
- package/dist/components/input-group.js.map +1 -1
- package/dist/components/input-otp.d.ts +4 -2
- package/dist/components/input-otp.js +1 -1
- package/dist/components/input-otp.js.map +1 -1
- package/dist/components/input.d.ts +1 -1
- package/dist/components/input.js +1 -1
- package/dist/components/input.js.map +1 -1
- package/dist/components/label.d.ts +3 -4
- package/dist/components/label.js +1 -1
- package/dist/components/label.js.map +1 -1
- package/dist/components/list.d.ts +8 -5
- package/dist/components/list.js +1 -1
- package/dist/components/list.js.map +1 -1
- package/dist/components/logo.d.ts +113 -0
- package/dist/components/marker.d.ts +4 -5
- package/dist/components/marker.js +1 -1
- package/dist/components/marker.js.map +1 -1
- package/dist/components/mask-input.d.ts +6 -0
- package/dist/components/mask-input.js.map +1 -1
- package/dist/components/native-select.d.ts +5 -1
- package/dist/components/native-select.js +1 -1
- package/dist/components/native-select.js.map +1 -1
- package/dist/components/navigation-menu.d.ts +19 -20
- package/dist/components/navigation-menu.js +1 -1
- package/dist/components/navigation-menu.js.map +1 -1
- package/dist/components/number-field.d.ts +18 -13
- package/dist/components/number-field.js +1 -1
- package/dist/components/number-field.js.map +1 -1
- package/dist/components/pagination.d.ts +9 -0
- package/dist/components/pagination.js +1 -1
- package/dist/components/pagination.js.map +1 -1
- package/dist/components/phone-input.d.ts +3 -0
- package/dist/components/phone-input.js +1 -1
- package/dist/components/phone-input.js.map +1 -1
- package/dist/components/pie-chart.d.ts +53 -0
- package/dist/components/pie-chart.js +1 -1
- package/dist/components/pie-chart.js.map +1 -1
- package/dist/components/popover.d.ts +13 -12
- package/dist/components/popover.js +1 -1
- package/dist/components/popover.js.map +1 -1
- package/dist/components/progress.d.ts +9 -3
- package/dist/components/progress.js +1 -1
- package/dist/components/progress.js.map +1 -1
- package/dist/components/radio-group.d.ts +20 -6
- package/dist/components/radio-group.js +1 -1
- package/dist/components/radio-group.js.map +1 -1
- package/dist/components/resizable.d.ts +1 -0
- package/dist/components/resizable.js.map +1 -1
- package/dist/components/ring-progress.d.ts +9 -1
- package/dist/components/ring-progress.js.map +1 -1
- package/dist/components/scroll-area.d.ts +3 -3
- package/dist/components/scroll-area.js +1 -1
- package/dist/components/scroll-area.js.map +1 -1
- package/dist/components/select.d.ts +25 -20
- package/dist/components/select.js +1 -1
- package/dist/components/select.js.map +1 -1
- package/dist/components/separator.d.ts +9 -4
- package/dist/components/separator.js +1 -1
- package/dist/components/separator.js.map +1 -1
- package/dist/components/sidebar.d.ts +63 -18
- package/dist/components/sidebar.js +1 -1
- package/dist/components/sidebar.js.map +1 -1
- package/dist/components/simple-grid.d.ts +7 -0
- package/dist/components/simple-grid.js +1 -1
- package/dist/components/simple-grid.js.map +1 -1
- package/dist/components/skeleton.d.ts +4 -0
- package/dist/components/skeleton.js.map +1 -1
- package/dist/components/slider.d.ts +2 -2
- package/dist/components/slider.js +1 -1
- package/dist/components/slider.js.map +1 -1
- package/dist/components/spinner.d.ts +1 -1
- package/dist/components/stack.d.ts +1 -1
- package/dist/components/stepper.d.ts +46 -25
- package/dist/components/stepper.js +1 -1
- package/dist/components/stepper.js.map +1 -1
- package/dist/components/switch.d.ts +17 -3
- package/dist/components/switch.js +1 -1
- package/dist/components/switch.js.map +1 -1
- package/dist/components/table.d.ts +10 -1
- package/dist/components/table.js +1 -1
- package/dist/components/table.js.map +1 -1
- package/dist/components/tabs.d.ts +14 -10
- package/dist/components/tabs.js +1 -1
- package/dist/components/tabs.js.map +1 -1
- package/dist/components/text.d.ts +3 -5
- package/dist/components/text.js +1 -1
- package/dist/components/text.js.map +1 -1
- package/dist/components/textarea.d.ts +1 -1
- package/dist/components/textarea.js +1 -1
- package/dist/components/textarea.js.map +1 -1
- package/dist/components/theme.d.ts +12 -0
- package/dist/components/theme.js +1 -1
- package/dist/components/theme.js.map +1 -1
- package/dist/components/timeline.d.ts +25 -1
- package/dist/components/timeline.js +1 -1
- package/dist/components/timeline.js.map +1 -1
- package/dist/components/toggle-group.d.ts +16 -6
- package/dist/components/toggle-group.js +1 -1
- package/dist/components/toggle-group.js.map +1 -1
- package/dist/components/toggle.d.ts +4 -4
- package/dist/components/toggle.js +1 -1
- package/dist/components/toggle.js.map +1 -1
- package/dist/components/tooltip.d.ts +15 -8
- package/dist/components/tooltip.js +1 -1
- package/dist/components/tooltip.js.map +1 -1
- package/dist/components/unstyled-button.d.ts +3 -5
- package/dist/components/unstyled-button.js +1 -1
- package/dist/components/unstyled-button.js.map +1 -1
- package/dist/components/visibility.d.ts +2 -0
- package/dist/components/visibility.js +1 -1
- package/dist/components/visibility.js.map +1 -1
- package/dist/hooks/use-breakpoint-value.d.ts +1 -0
- package/dist/hooks/use-breakpoint-value.js.map +1 -1
- package/dist/hooks/use-breakpoint.d.ts +1 -0
- package/dist/hooks/use-breakpoint.js.map +1 -1
- package/dist/hooks/use-disclosure.d.ts +3 -0
- package/dist/hooks/use-disclosure.js +1 -1
- package/dist/hooks/use-disclosure.js.map +1 -1
- package/dist/hooks/use-document-visibility.d.ts +1 -0
- package/dist/hooks/use-document-visibility.js.map +1 -1
- package/dist/hooks/use-hotkeys.d.ts +1 -1
- package/dist/hooks/use-idle.d.ts +9 -0
- package/dist/hooks/use-idle.js.map +1 -1
- package/dist/hooks/use-interval.d.ts +1 -0
- package/dist/hooks/use-interval.js.map +1 -1
- package/dist/hooks/use-local-storage.d.ts +6 -0
- package/dist/hooks/use-local-storage.js +1 -1
- package/dist/hooks/use-local-storage.js.map +1 -1
- package/dist/hooks/use-mask.d.ts +1 -0
- package/dist/hooks/use-mask.js.map +1 -1
- package/dist/hooks/use-mobile.d.ts +1 -0
- package/dist/hooks/use-mobile.js.map +1 -1
- package/dist/index.d.ts +7 -5
- package/dist/index.js +1 -1
- package/dist/lib/as-child.d.ts +2 -0
- package/dist/lib/as-child.js +2 -0
- package/dist/lib/as-child.js.map +1 -0
- package/dist/lib/utils.d.ts +1 -1
- package/dist/logo--R3_XDgA.js.map +1 -1
- package/dist/resolve-class-name-BurP8ngI.js +2 -0
- package/dist/resolve-class-name-BurP8ngI.js.map +1 -0
- package/dist/skills/uselets-ui/SKILL.md +8 -3
- package/dist/skills/uselets-ui/references/component-catalog.md +32 -17
- package/dist/skills/uselets-ui/references/migration-v1-to-v2.md +599 -0
- package/dist/skills/uselets-ui/references/package-guide.md +7 -7
- package/dist/styles/base.css +21 -0
- package/dist/{use-hotkeys-DOjcX9Tt.d.ts → use-hotkeys-D1_TEIwN.d.ts} +2 -1
- package/dist/use-hotkeys-YDJmGWX6.js.map +1 -1
- package/package.json +16 -17
- package/skills/uselets-ui/SKILL.md +8 -3
- package/skills/uselets-ui/references/component-catalog.md +32 -17
- package/skills/uselets-ui/references/migration-v1-to-v2.md +599 -0
- package/skills/uselets-ui/references/package-guide.md +7 -7
|
@@ -39,16 +39,33 @@ export type DropzoneValidation = {
|
|
|
39
39
|
maxFiles?: number;
|
|
40
40
|
};
|
|
41
41
|
export type UseDropzoneProps<TUploadResult, TUploadError = string> = {
|
|
42
|
+
/** Uploads one file. Resolve to `{ status: 'success', result }` or `{ status: 'error', error }`. */
|
|
42
43
|
onDropFile: (file: File) => Promise<DropzoneUploadResult<TUploadResult, TUploadError>>;
|
|
44
|
+
/** Called when a file is removed, with its id. */
|
|
43
45
|
onRemoveFile?: (id: string) => void | Promise<void>;
|
|
46
|
+
/** Called with the result of each successful upload. */
|
|
44
47
|
onFileUploaded?: (result: TUploadResult) => void;
|
|
48
|
+
/** Called with the error of each failed upload. */
|
|
45
49
|
onFileUploadError?: (error: TUploadError) => void;
|
|
50
|
+
/** Called when every pending upload has finished. */
|
|
46
51
|
onAllUploaded?: () => void;
|
|
52
|
+
/** Called with the validation message when dropped files are rejected, or `undefined` when cleared. */
|
|
47
53
|
onRootError?: (error: string | undefined) => void;
|
|
54
|
+
/** Turns an upload error into the message shown for the file. */
|
|
48
55
|
shapeUploadError?: (error: TUploadError) => string | undefined;
|
|
56
|
+
/** Maximum number of retries per file. Unlimited when omitted. */
|
|
49
57
|
maxRetryCount?: number;
|
|
58
|
+
/**
|
|
59
|
+
* Retries failed uploads automatically, up to `maxRetryCount`.
|
|
60
|
+
* @default false
|
|
61
|
+
*/
|
|
50
62
|
autoRetry?: boolean;
|
|
63
|
+
/** File rules: `accept`, `minSize`, `maxSize` (bytes) and `maxFiles`. */
|
|
51
64
|
validation?: DropzoneValidation;
|
|
65
|
+
/**
|
|
66
|
+
* Removes the oldest files when new ones exceed `maxFiles`, instead of rejecting them.
|
|
67
|
+
* @default false
|
|
68
|
+
*/
|
|
52
69
|
shiftOnMaxFiles?: boolean;
|
|
53
70
|
};
|
|
54
71
|
export interface UseDropzoneReturn<TUploadResult, TUploadError> {
|
|
@@ -72,6 +89,7 @@ export type DropzoneAreaProps = React.ComponentProps<'div'>;
|
|
|
72
89
|
export type DropzoneDescriptionProps = React.ComponentProps<'p'>;
|
|
73
90
|
export type DropzoneFileListProps = React.ComponentProps<'ol'>;
|
|
74
91
|
export type DropzoneFileListItemProps<TUploadResult, TUploadError> = React.ComponentProps<'li'> & {
|
|
92
|
+
/** File status from `fileStatuses`, used by the parts inside the item. */
|
|
75
93
|
file: DropzoneFileStatus<TUploadResult, TUploadError>;
|
|
76
94
|
};
|
|
77
95
|
export type DropzoneFileMessageProps = React.ComponentProps<'p'>;
|
|
@@ -80,6 +98,7 @@ export type DropzoneRemoveFileProps = ButtonProps;
|
|
|
80
98
|
export type DropzoneRetryFileProps = ButtonProps;
|
|
81
99
|
export type DropzoneTriggerProps = ButtonProps;
|
|
82
100
|
export type InfiniteProgressProps = React.ComponentProps<'div'> & {
|
|
101
|
+
/** Upload status shown by the bar. */
|
|
83
102
|
status: 'pending' | 'success' | 'error';
|
|
84
103
|
};
|
|
85
104
|
declare function useDropzone<TUploadResult, TUploadError = string>(props: UseDropzoneProps<TUploadResult, TUploadError>): UseDropzoneReturn<TUploadResult, TUploadError>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../rolldown-runtime-BhWHdk3m.js";import{cn as e}from"../lib/utils.js";import{Button as t}from"./button.js";import{composeRefs as n}from"../lib/compose-refs.js";import{jsx as
|
|
1
|
+
import"../rolldown-runtime-BhWHdk3m.js";import{cn as e}from"../lib/utils.js";import{Button as t}from"./button.js";import{composeRefs as n}from"../lib/compose-refs.js";import*as r from"react";import{jsx as i,jsxs as a}from"react/jsx-runtime";import{ErrorCode as o,useDropzone as s}from"react-dropzone";const c=[o.FileInvalidType,o.FileTooLarge,o.FileTooSmall,o.TooManyFiles],l=new Set(c),u={pending:`indeterminate`,success:`100%`,error:`error`},d=r.createContext(null),f=r.createContext(null);function fileStatusReducer(e,t){switch(t.type){case`add`:return[...e,{id:t.id,fileName:t.fileName,file:t.file,status:`pending`,tries:1}];case`remove`:return e.filter(e=>e.id!==t.id);case`update-status`:return e.map(e=>e.id===t.id?t.status===`pending`?{...e,status:`pending`,error:void 0,message:void 0,result:void 0,tries:e.tries+1}:t.status===`error`?{...e,status:`error`,error:t.error,message:t.message,result:void 0}:{...e,status:`success`,result:t.result,error:void 0,message:void 0}:e)}}function formatAcceptedTypes(e){if(!e)return;let t=Object.entries(e).flatMap(([e,t])=>t.length>0?t:[e]);return t.length>0?t.join(`, `):void 0}function getDropzoneErrorCodes(e){let t=e.flatMap(e=>e.errors.map(e=>e.code).filter(e=>l.has(e)));return Array.from(new Set(t))}function getRootError(e,t){let n=e.flatMap(e=>{switch(e){case`file-invalid-type`:{let e=formatAcceptedTypes(t.accept);return e?[`only ${e} files are allowed`]:[`this file type is not allowed`]}case`file-too-large`:return t.maxSize?[`max size is ${(t.maxSize/1048576).toFixed(2)} MB`]:[`this file is too large`];case`file-too-small`:return t.minSize?[`min size is ${(t.minSize/1048576).toFixed(2)} MB`]:[`this file is too small`];case`too-many-files`:return t.maxFiles?[`max ${t.maxFiles} files`]:[`too many files`];default:return[]}});if(n.length===0)return`Unable to add the selected files`;let[r,...i]=n;return`${r.charAt(0).toUpperCase()}${r.slice(1)}${i.length>0?`, ${i.join(`, `)}`:``}`}function getRejectionMessage(e,t){let n=getDropzoneErrorCodes(e);return n.length>0?getRootError(n,t):e[0]?.errors[0]?.message??`Unable to add the selected files`}function getUploadErrorMessage(e,t){if(t){let n=t(e);if(n!==void 0)return n}if(typeof e==`string`)return e;if(e instanceof Error)return e.message}function useDropzoneContext(){let e=r.useContext(d);if(!e)throw Error(`Dropzone components must be used within a Dropzone.`);return e}function useDropzoneFileListContext(){let e=r.useContext(f);if(!e)throw Error(`Dropzone file actions must be used within a DropzoneFileListItem.`);return e}function useDropzone(e){let{onDropFile:t,onRemoveFile:n,shapeUploadError:i,onFileUploaded:a,onFileUploadError:c,onAllUploaded:l,onRootError:u,maxRetryCount:d,autoRetry:f=!1,validation:p,shiftOnMaxFiles:m=!1}=e,h=r.useId(),g=`${h}-message`,_=`${h}-description`,[v,y]=r.useState(void 0),b=r.useCallback(e=>{y(e),u?.(e)},[u]),[x,S]=r.useReducer(fileStatusReducer,[]),C=r.useCallback(e=>`${h}-${e}-message`,[h]),w=r.useMemo(()=>v!==void 0||x.some(e=>e.status===`error`),[x,v]),T=r.useCallback(async(e,n,r=0)=>{try{let o=await t(e);if(o.status===`error`){if(f&&r<(d??1/0))return S({type:`update-status`,id:n,status:`pending`}),T(e,n,r+1);S({type:`update-status`,id:n,status:`error`,error:o.error,message:getUploadErrorMessage(o.error,i)}),c?.(o.error);return}S({type:`update-status`,id:n,status:`success`,result:o.result}),a?.(o.result)}catch(e){let t=e;S({type:`update-status`,id:n,status:`error`,error:t,message:getUploadErrorMessage(t,i)}),c?.(t)}},[f,t,d,c,a,i]),E=r.useCallback(async e=>{await n?.(e),S({type:`remove`,id:e})},[n]),D=r.useCallback(e=>{let t=x.find(t=>t.id===e);return t?.status===`error`&&t.tries<=(d??1/0)},[x,d]),O=r.useCallback(async e=>{if(!D(e))return;let t=x.find(t=>t.id===e);t?.status===`error`&&(S({type:`update-status`,id:e,status:`pending`}),await T(t.file,e))},[D,x,T]),k=s({accept:p?.accept,minSize:p?.minSize,maxSize:p?.maxSize,maxFiles:p?.maxFiles,noClick:!0,noKeyboard:!0,onDropAccepted:async e=>{b(void 0);let t=e,n=p?.maxFiles??1/0,r=Number.isFinite(n)?Math.max(x.length+e.length-n,0):0;if(r>0){if(m){let n=x.slice(0,Math.min(r,x.length));await Promise.all(n.map(e=>E(e.id)));let i=r-n.length;i>0&&(t=e.slice(i))}else{b(getRootError([o.TooManyFiles],p??{}));let r=Math.max(n-x.length,0);t=e.slice(0,r)}}t.length!==0&&(await Promise.all(t.map(async e=>{let t=crypto.randomUUID();S({type:`add`,id:t,fileName:e.name,file:e}),await T(e,t)})),l?.())},onDropRejected:e=>{b(getRejectionMessage(e,p??{}))}});return{getRootProps:k.getRootProps,getInputProps:k.getInputProps,open:k.open,onRemoveFile:E,onRetry:O,canRetry:D,fileStatuses:x,isInvalid:w,isDragActive:k.isDragActive,rootError:v,inputId:h,rootMessageId:g,rootDescriptionId:_,getFileMessageId:C}}function Dropzone({children:e,...t}){return/* @__PURE__ */ i(d.Provider,{value:t,children:e})}const p=r.forwardRef(({className:t,children:r,...o},s)=>{let c=useDropzoneContext(),l=[c.rootDescriptionId,c.isInvalid?c.rootMessageId:void 0].filter(Boolean).join(` `)||void 0,{ref:u,...d}=c.getRootProps({...o,"data-slot":`dropzone-area`,"aria-describedby":l,"aria-invalid":c.isInvalid||void 0,className:e(`flex min-h-44 flex-col items-center justify-center gap-4 rounded-xl border border-dashed border-input bg-muted/20 px-6 py-8 text-center transition-colors`,c.isDragActive&&`border-primary bg-primary/5`,c.isInvalid&&`border-destructive bg-destructive/5`,t)}),f=c.getInputProps({id:c.inputId,className:`sr-only`,"aria-describedby":l,"aria-invalid":c.isInvalid,tabIndex:-1});return/* @__PURE__ */ a(`div`,{...d,ref:n(s,u),children:[/* @__PURE__ */ i(`input`,{...f}),r]})}),m=r.forwardRef(({className:t,...n},r)=>{let a=useDropzoneContext();return/* @__PURE__ */ i(`p`,{ref:r,id:a.rootDescriptionId,"data-slot":`dropzone-description`,className:e(`text-sm text-muted-foreground`,t),...n})}),h=r.forwardRef(({className:t,...n},r)=>(useDropzoneContext(),/* @__PURE__ */ i(`ol`,{ref:r,"data-slot":`dropzone-file-list`,className:e(`space-y-3`,t),...n}))),g=r.forwardRef(({className:t,file:n,children:a,...o},s)=>{let c=useDropzoneContext(),l=c.getFileMessageId(n.id),u=n.status===`error`,d=c.canRetry(n.id),p=r.useMemo(()=>({onRemoveFile:()=>c.onRemoveFile(n.id),onRetry:()=>c.onRetry(n.id),fileStatus:n,canRetry:d,dropzoneId:c.inputId,messageId:l}),[d,c,n,l]);return/* @__PURE__ */ i(f.Provider,{value:p,children:/* @__PURE__ */ i(`li`,{ref:s,"data-slot":`dropzone-file-item`,"data-status":n.status,"aria-describedby":u?l:void 0,className:e(`rounded-xl border bg-card px-4 py-3 shadow-xs`,n.status===`error`&&`border-destructive/50`,t),...o,children:a})})}),_=r.forwardRef(({className:t,children:n,...r},a)=>{let o=useDropzoneFileListContext(),s=o.fileStatus.status===`error`?o.fileStatus.message??String(o.fileStatus.error):n;return/* @__PURE__ */ i(`p`,{ref:a,id:o.messageId,"data-slot":`dropzone-file-message`,className:e(`min-h-5 text-[0.8rem] font-medium`,o.fileStatus.status===`error`&&`text-destructive`,t),...r,children:s})}),v=r.forwardRef(({className:t,children:n,...r},a)=>{let o=useDropzoneContext(),s=o.rootError??n;return/* @__PURE__ */ i(`p`,{ref:a,id:o.rootMessageId,"data-slot":`dropzone-message`,className:e(`min-h-5 text-[0.8rem] font-medium text-destructive`,t),...r,children:s})}),y=r.forwardRef(({className:n,onClick:a,size:o=`icon-sm`,type:s=`button`,variant:c=`ghost`,...l},u)=>{let d=useDropzoneFileListContext(),f=r.useCallback(e=>{a?.(e),!e.defaultPrevented&&d.onRemoveFile()},[d,a]);return/* @__PURE__ */ i(t,{ref:u,"data-slot":`dropzone-remove-file`,className:e(n),onClick:f,size:o,type:s,variant:c,...l})}),b=r.forwardRef(({className:n,disabled:a,onClick:o,size:s=`icon-sm`,type:c=`button`,variant:l=`ghost`,...u},d)=>{let f=useDropzoneFileListContext(),p=a||!f.canRetry,m=r.useCallback(e=>{o?.(e),!(e.defaultPrevented||p)&&f.onRetry()},[f,p,o]);return/* @__PURE__ */ i(t,{ref:d,"data-slot":`dropzone-retry-file`,className:e(n),disabled:p,onClick:m,size:s,type:c,variant:l,...u})}),x=r.forwardRef(({className:n,onClick:a,size:o=`sm`,type:s=`button`,variant:c=`subtle`,...l},u)=>{let d=useDropzoneContext(),f=[d.rootDescriptionId,d.isInvalid?d.rootMessageId:void 0].filter(Boolean).join(` `)||void 0,p=r.useCallback(e=>{a?.(e),!e.defaultPrevented&&d.open()},[d,a]);return/* @__PURE__ */ i(t,{ref:u,"aria-controls":d.inputId,"aria-describedby":f,"aria-invalid":d.isInvalid||void 0,"data-slot":`dropzone-trigger`,className:e(n),onClick:p,size:o,type:s,variant:c,...l})}),S=r.forwardRef(({className:t,status:n,...r},a)=>{let o=n===`success`||n===`error`,s=n===`error`;return/* @__PURE__ */ i(`div`,{ref:a,"aria-valuemax":100,"aria-valuemin":0,"aria-valuetext":u[n],"data-slot":`dropzone-progress`,"data-status":n,role:`progressbar`,className:e(`relative h-2 w-full overflow-hidden rounded-full bg-muted`,t),...r,children:/* @__PURE__ */ i(`div`,{className:e(`h-full w-full rounded-full bg-primary transition-transform`,o?`translate-x-0`:`animate-infinite-progress`,s&&`bg-destructive`)})})});Dropzone.displayName=`Dropzone`,p.displayName=`DropzoneArea`,m.displayName=`DropzoneDescription`,h.displayName=`DropzoneFileList`,g.displayName=`DropzoneFileListItem`,_.displayName=`DropzoneFileMessage`,v.displayName=`DropzoneMessage`,y.displayName=`DropzoneRemoveFile`,b.displayName=`DropzoneRetryFile`,x.displayName=`DropzoneTrigger`,S.displayName=`InfiniteProgress`;export{Dropzone,p as DropzoneArea,m as DropzoneDescription,h as DropzoneFileList,g as DropzoneFileListItem,_ as DropzoneFileMessage,v as DropzoneMessage,y as DropzoneRemoveFile,b as DropzoneRetryFile,x as DropzoneTrigger,o as ErrorCode,S as InfiniteProgress,useDropzone};
|
|
2
2
|
//# sourceMappingURL=dropzone.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropzone.js","names":["useReactDropzone","React","useDropzone$1","dropzoneErrorCodes","ErrorCode","dropzoneErrorCodeSet","valueTextMap","DropzoneContext","DropzoneFileListContext","action","state","fileStatus","accept","acceptedTypes","mimeType","extensions","errorCodes","fileRejections","rejection","error","errorCode","errors","limits","firstError","restErrors","shapeUploadError","message","context","handleDropFile","handleRemoveFile","props","inputId","rootMessageId","rootDescriptionId","rootError","setRootErrorState","setRootError","onRootError","fileStatuses","dispatch","getFileMessageId","id","isInvalid","uploadFile","result","file","autoRetry","retryCount","maxRetryCount","onFileUploadError","onFileUploaded","uploadError","onRemoveFile","canRetry","item","onRetry","dropzone","validation","nextFiles","acceptedFiles","maxFiles","overflow","shiftOnMaxFiles","filesToRemove","remainingOverflow","availableSlots","onAllUploaded","DropzoneArea","describedBy","rootRef","rootProps","cn","className","inputProps","composeRefs","forwardedRef","children","DropzoneDescription","DropzoneFileList","DropzoneFileListItem","messageId","value","DropzoneFileMessage","body","DropzoneMessage","DropzoneRemoveFile","handleClick","onClick","event","Button","DropzoneRetryFile","isDisabled","disabled","DropzoneTrigger","InfiniteProgress","done","status","isError"],"sources":["../../src/components/dropzone.tsx"],"sourcesContent":["import * as React from 'react'\nimport {\n type Accept,\n ErrorCode,\n type FileError,\n type FileRejection,\n useDropzone as useReactDropzone\n} from 'react-dropzone'\n\nimport { composeRefs } from '../lib/compose-refs'\nimport { cn } from '../lib/utils'\nimport { Button, type ButtonProps } from './button'\n\nconst dropzoneErrorCodes = [\n ErrorCode.FileInvalidType,\n ErrorCode.FileTooLarge,\n ErrorCode.FileTooSmall,\n ErrorCode.TooManyFiles\n]\n\ntype DropzoneAction<TUploadResult, TUploadError> =\n | {\n type: 'add'\n id: string\n fileName: string\n file: File\n }\n | {\n type: 'remove'\n id: string\n }\n | {\n type: 'update-status'\n id: string\n status: 'pending'\n }\n | {\n type: 'update-status'\n id: string\n status: 'error'\n error: TUploadError\n message?: string\n }\n | {\n type: 'update-status'\n id: string\n status: 'success'\n result: TUploadResult\n }\n\nexport type DropzoneUploadResult<TUploadResult, TUploadError> =\n | {\n status: 'error'\n error: TUploadError\n }\n | {\n status: 'success'\n result: TUploadResult\n }\n\nexport type DropzoneFileStatus<TUploadResult, TUploadError> = {\n id: string\n fileName: string\n file: File\n tries: number\n} & (\n | {\n status: 'pending'\n error?: undefined\n message?: undefined\n result?: undefined\n }\n | {\n status: 'error'\n error: TUploadError\n message?: string\n result?: undefined\n }\n | {\n status: 'success'\n result: TUploadResult\n error?: undefined\n message?: undefined\n }\n)\n\nexport type FileStatus<TUploadResult, TUploadError> = DropzoneFileStatus<TUploadResult, TUploadError>\n\nexport type DropzoneValidation = {\n accept?: Accept\n minSize?: number\n maxSize?: number\n maxFiles?: number\n}\n\nexport type UseDropzoneProps<TUploadResult, TUploadError = string> = {\n onDropFile: (file: File) => Promise<DropzoneUploadResult<TUploadResult, TUploadError>>\n onRemoveFile?: (id: string) => void | Promise<void>\n onFileUploaded?: (result: TUploadResult) => void\n onFileUploadError?: (error: TUploadError) => void\n onAllUploaded?: () => void\n onRootError?: (error: string | undefined) => void\n shapeUploadError?: (error: TUploadError) => string | undefined\n maxRetryCount?: number\n autoRetry?: boolean\n validation?: DropzoneValidation\n shiftOnMaxFiles?: boolean\n}\n\nexport interface UseDropzoneReturn<TUploadResult, TUploadError> {\n getRootProps: ReturnType<typeof useReactDropzone>['getRootProps']\n getInputProps: ReturnType<typeof useReactDropzone>['getInputProps']\n open: () => void\n onRemoveFile: (id: string) => Promise<void>\n onRetry: (id: string) => Promise<void>\n canRetry: (id: string) => boolean\n fileStatuses: DropzoneFileStatus<TUploadResult, TUploadError>[]\n isInvalid: boolean\n isDragActive: boolean\n rootError: string | undefined\n inputId: string\n rootMessageId: string\n rootDescriptionId: string\n getFileMessageId: (id: string) => string\n}\n\nexport type DropzoneProps<TUploadResult, TUploadError> = React.PropsWithChildren<\n UseDropzoneReturn<TUploadResult, TUploadError>\n>\n\nexport type DropzoneAreaProps = React.ComponentProps<'div'>\n\nexport type DropzoneDescriptionProps = React.ComponentProps<'p'>\n\nexport type DropzoneFileListProps = React.ComponentProps<'ol'>\n\nexport type DropzoneFileListItemProps<TUploadResult, TUploadError> = React.ComponentProps<'li'> & {\n file: DropzoneFileStatus<TUploadResult, TUploadError>\n}\n\nexport type DropzoneFileMessageProps = React.ComponentProps<'p'>\n\nexport type DropzoneMessageProps = React.ComponentProps<'p'>\n\nexport type DropzoneRemoveFileProps = ButtonProps\n\nexport type DropzoneRetryFileProps = ButtonProps\n\nexport type DropzoneTriggerProps = ButtonProps\n\nexport type InfiniteProgressProps = React.ComponentProps<'div'> & {\n status: 'pending' | 'success' | 'error'\n}\n\ntype DropzoneFileListContextValue<TUploadResult, TUploadError> = {\n onRemoveFile: () => Promise<void>\n onRetry: () => Promise<void>\n fileStatus: DropzoneFileStatus<TUploadResult, TUploadError>\n canRetry: boolean\n dropzoneId: string\n messageId: string\n}\n\nconst dropzoneErrorCodeSet = new Set<ErrorCode>(dropzoneErrorCodes)\n\nconst valueTextMap = {\n pending: 'indeterminate',\n success: '100%',\n error: 'error'\n} as const\n\nconst DropzoneContext = React.createContext<UseDropzoneReturn<unknown, unknown> | null>(null)\n\nconst DropzoneFileListContext = React.createContext<DropzoneFileListContextValue<unknown, unknown> | null>(null)\n\nfunction fileStatusReducer<TUploadResult, TUploadError>(\n state: DropzoneFileStatus<TUploadResult, TUploadError>[],\n action: DropzoneAction<TUploadResult, TUploadError>\n): DropzoneFileStatus<TUploadResult, TUploadError>[] {\n switch (action.type) {\n case 'add':\n return [\n ...state,\n {\n id: action.id,\n fileName: action.fileName,\n file: action.file,\n status: 'pending',\n tries: 1\n }\n ]\n case 'remove':\n return state.filter((fileStatus) => fileStatus.id !== action.id)\n case 'update-status':\n return state.map((fileStatus) => {\n if (fileStatus.id !== action.id) {\n return fileStatus\n }\n\n if (action.status === 'pending') {\n return {\n ...fileStatus,\n status: 'pending',\n error: undefined,\n message: undefined,\n result: undefined,\n tries: fileStatus.tries + 1\n }\n }\n\n if (action.status === 'error') {\n return {\n ...fileStatus,\n status: 'error',\n error: action.error,\n message: action.message,\n result: undefined\n }\n }\n\n return {\n ...fileStatus,\n status: 'success',\n result: action.result,\n error: undefined,\n message: undefined\n }\n })\n }\n}\n\nfunction formatAcceptedTypes(accept?: Accept) {\n if (!accept) {\n return undefined\n }\n\n const acceptedTypes = Object.entries(accept).flatMap(([mimeType, extensions]) => {\n return extensions.length > 0 ? extensions : [mimeType]\n })\n\n return acceptedTypes.length > 0 ? acceptedTypes.join(', ') : undefined\n}\n\nfunction getDropzoneErrorCodes(fileRejections: FileRejection[]) {\n const errorCodes = fileRejections.flatMap((rejection) =>\n rejection.errors.map((error) => error.code as ErrorCode).filter((errorCode) => dropzoneErrorCodeSet.has(errorCode))\n )\n\n return Array.from(new Set(errorCodes))\n}\n\nfunction getRootError(errorCodes: ErrorCode[], limits: DropzoneValidation) {\n const errors = errorCodes.flatMap((errorCode) => {\n switch (errorCode) {\n case 'file-invalid-type': {\n const acceptedTypes = formatAcceptedTypes(limits.accept)\n return acceptedTypes ? [`only ${acceptedTypes} files are allowed`] : ['this file type is not allowed']\n }\n case 'file-too-large': {\n if (!limits.maxSize) {\n return ['this file is too large']\n }\n\n return [`max size is ${(limits.maxSize / (1024 * 1024)).toFixed(2)} MB`]\n }\n case 'file-too-small': {\n if (!limits.minSize) {\n return ['this file is too small']\n }\n\n return [`min size is ${(limits.minSize / (1024 * 1024)).toFixed(2)} MB`]\n }\n case 'too-many-files':\n return limits.maxFiles ? [`max ${limits.maxFiles} files`] : ['too many files']\n default:\n return []\n }\n })\n\n if (errors.length === 0) {\n return 'Unable to add the selected files'\n }\n\n const [firstError, ...restErrors] = errors as [string, ...string[]]\n return `${firstError.charAt(0).toUpperCase()}${firstError.slice(1)}${restErrors.length > 0 ? `, ${restErrors.join(', ')}` : ''}`\n}\n\nfunction getRejectionMessage(fileRejections: FileRejection[], limits: DropzoneValidation) {\n const errorCodes = getDropzoneErrorCodes(fileRejections)\n\n if (errorCodes.length > 0) {\n return getRootError(errorCodes, limits)\n }\n\n return fileRejections[0]?.errors[0]?.message ?? 'Unable to add the selected files'\n}\n\nfunction getUploadErrorMessage<TUploadError>(\n error: TUploadError,\n shapeUploadError?: (error: TUploadError) => string | undefined\n) {\n if (shapeUploadError) {\n const message = shapeUploadError(error)\n if (message !== undefined) {\n return message\n }\n }\n\n if (typeof error === 'string') {\n return error\n }\n\n if (error instanceof Error) {\n return error.message\n }\n\n return undefined\n}\n\nfunction useDropzoneContext<TUploadResult, TUploadError>() {\n const context = React.useContext(DropzoneContext)\n\n if (!context) {\n throw new Error('Dropzone components must be used within a Dropzone.')\n }\n\n return context as UseDropzoneReturn<TUploadResult, TUploadError>\n}\n\nfunction useDropzoneFileListContext<TUploadResult, TUploadError>() {\n const context = React.useContext(DropzoneFileListContext)\n\n if (!context) {\n throw new Error('Dropzone file actions must be used within a DropzoneFileListItem.')\n }\n\n return context as DropzoneFileListContextValue<TUploadResult, TUploadError>\n}\n\nfunction useDropzone<TUploadResult, TUploadError = string>(\n props: UseDropzoneProps<TUploadResult, TUploadError>\n): UseDropzoneReturn<TUploadResult, TUploadError> {\n const {\n onDropFile: handleDropFile,\n onRemoveFile: handleRemoveFile,\n shapeUploadError,\n onFileUploaded,\n onFileUploadError,\n onAllUploaded,\n onRootError,\n maxRetryCount,\n autoRetry = false,\n validation,\n shiftOnMaxFiles = false\n } = props\n\n const inputId = React.useId()\n const rootMessageId = `${inputId}-message`\n const rootDescriptionId = `${inputId}-description`\n const [rootError, setRootErrorState] = React.useState<string | undefined>(undefined)\n\n const setRootError = React.useCallback(\n (error: string | undefined) => {\n setRootErrorState(error)\n onRootError?.(error)\n },\n [onRootError]\n )\n\n const [fileStatuses, dispatch] = React.useReducer(\n fileStatusReducer<TUploadResult, TUploadError>,\n [] as DropzoneFileStatus<TUploadResult, TUploadError>[]\n )\n\n const getFileMessageId = React.useCallback((id: string) => `${inputId}-${id}-message`, [inputId])\n\n const isInvalid = React.useMemo(() => {\n return rootError !== undefined || fileStatuses.some((fileStatus) => fileStatus.status === 'error')\n }, [fileStatuses, rootError])\n\n const uploadFile = React.useCallback(\n async (file: File, id: string, retryCount = 0) => {\n try {\n const result = await handleDropFile(file)\n\n if (result.status === 'error') {\n if (autoRetry && retryCount < (maxRetryCount ?? Number.POSITIVE_INFINITY)) {\n dispatch({ type: 'update-status', id, status: 'pending' })\n return uploadFile(file, id, retryCount + 1)\n }\n\n dispatch({\n type: 'update-status',\n id,\n status: 'error',\n error: result.error,\n message: getUploadErrorMessage(result.error, shapeUploadError)\n })\n onFileUploadError?.(result.error)\n return\n }\n\n dispatch({\n type: 'update-status',\n id,\n status: 'success',\n result: result.result\n })\n onFileUploaded?.(result.result)\n } catch (error) {\n const uploadError = error as TUploadError\n\n dispatch({\n type: 'update-status',\n id,\n status: 'error',\n error: uploadError,\n message: getUploadErrorMessage(uploadError, shapeUploadError)\n })\n onFileUploadError?.(uploadError)\n }\n },\n [autoRetry, handleDropFile, maxRetryCount, onFileUploadError, onFileUploaded, shapeUploadError]\n )\n\n const onRemoveFile = React.useCallback(\n async (id: string) => {\n await handleRemoveFile?.(id)\n dispatch({ type: 'remove', id })\n },\n [handleRemoveFile]\n )\n\n const canRetry = React.useCallback(\n (id: string) => {\n const fileStatus = fileStatuses.find((item) => item.id === id)\n\n return fileStatus?.status === 'error' && fileStatus.tries <= (maxRetryCount ?? Number.POSITIVE_INFINITY)\n },\n [fileStatuses, maxRetryCount]\n )\n\n const onRetry = React.useCallback(\n async (id: string) => {\n if (!canRetry(id)) {\n return\n }\n\n const fileStatus = fileStatuses.find((item) => item.id === id)\n\n if (fileStatus?.status !== 'error') {\n return\n }\n\n dispatch({ type: 'update-status', id, status: 'pending' })\n await uploadFile(fileStatus.file, id)\n },\n [canRetry, fileStatuses, uploadFile]\n )\n\n const dropzone = useReactDropzone({\n accept: validation?.accept,\n minSize: validation?.minSize,\n maxSize: validation?.maxSize,\n maxFiles: validation?.maxFiles,\n noClick: true,\n noKeyboard: true,\n onDropAccepted: async (acceptedFiles) => {\n setRootError(undefined)\n\n let nextFiles = acceptedFiles\n const maxFiles = validation?.maxFiles ?? Number.POSITIVE_INFINITY\n const overflow = Number.isFinite(maxFiles)\n ? Math.max(fileStatuses.length + acceptedFiles.length - maxFiles, 0)\n : 0\n\n if (overflow > 0) {\n if (shiftOnMaxFiles) {\n const filesToRemove = fileStatuses.slice(0, Math.min(overflow, fileStatuses.length))\n\n await Promise.all(filesToRemove.map((fileStatus) => onRemoveFile(fileStatus.id)))\n\n const remainingOverflow = overflow - filesToRemove.length\n if (remainingOverflow > 0) {\n nextFiles = acceptedFiles.slice(remainingOverflow)\n }\n } else {\n setRootError(getRootError([ErrorCode.TooManyFiles], validation ?? {}))\n const availableSlots = Math.max(maxFiles - fileStatuses.length, 0)\n nextFiles = acceptedFiles.slice(0, availableSlots)\n }\n }\n\n if (nextFiles.length === 0) {\n return\n }\n\n await Promise.all(\n nextFiles.map(async (file) => {\n const id = crypto.randomUUID()\n dispatch({ type: 'add', id, fileName: file.name, file })\n await uploadFile(file, id)\n })\n )\n\n onAllUploaded?.()\n },\n onDropRejected: (fileRejections) => {\n setRootError(getRejectionMessage(fileRejections, validation ?? {}))\n }\n })\n\n return {\n getRootProps: dropzone.getRootProps,\n getInputProps: dropzone.getInputProps,\n open: dropzone.open,\n onRemoveFile,\n onRetry,\n canRetry,\n fileStatuses,\n isInvalid,\n isDragActive: dropzone.isDragActive,\n rootError,\n inputId,\n rootMessageId,\n rootDescriptionId,\n getFileMessageId\n }\n}\n\nfunction Dropzone<TUploadResult, TUploadError>({ children, ...dropzone }: DropzoneProps<TUploadResult, TUploadError>) {\n return <DropzoneContext.Provider value={dropzone}>{children}</DropzoneContext.Provider>\n}\n\nconst DropzoneArea = React.forwardRef<HTMLDivElement, DropzoneAreaProps>(\n ({ className, children, ...props }, forwardedRef) => {\n const context = useDropzoneContext()\n const describedBy =\n [context.rootDescriptionId, context.isInvalid ? context.rootMessageId : undefined].filter(Boolean).join(' ') ||\n undefined\n\n const { ref: rootRef, ...rootProps } = context.getRootProps({\n ...props,\n 'data-slot': 'dropzone-area',\n 'aria-describedby': describedBy,\n 'aria-invalid': context.isInvalid || undefined,\n className: cn(\n 'flex min-h-44 flex-col items-center justify-center gap-4 rounded-xl border border-dashed border-input bg-muted/20 px-6 py-8 text-center transition-colors',\n context.isDragActive && 'border-primary bg-primary/5',\n context.isInvalid && 'border-destructive bg-destructive/5',\n className\n )\n }) as React.HTMLAttributes<HTMLDivElement> & {\n ref?: React.Ref<HTMLDivElement>\n }\n\n const inputProps = context.getInputProps({\n id: context.inputId,\n className: 'sr-only',\n 'aria-describedby': describedBy,\n 'aria-invalid': context.isInvalid,\n tabIndex: -1\n })\n\n return (\n <div {...rootProps} ref={composeRefs(forwardedRef, rootRef)}>\n <input {...inputProps} />\n {children}\n </div>\n )\n }\n)\n\nconst DropzoneDescription = React.forwardRef<HTMLParagraphElement, DropzoneDescriptionProps>(\n ({ className, ...props }, ref) => {\n const context = useDropzoneContext()\n\n return (\n <p\n ref={ref}\n id={context.rootDescriptionId}\n data-slot=\"dropzone-description\"\n className={cn('text-sm text-muted-foreground', className)}\n {...props}\n />\n )\n }\n)\n\nconst DropzoneFileList = React.forwardRef<HTMLOListElement, DropzoneFileListProps>(({ className, ...props }, ref) => {\n useDropzoneContext()\n\n return <ol ref={ref} data-slot=\"dropzone-file-list\" className={cn('space-y-3', className)} {...props} />\n})\n\nconst DropzoneFileListItem = React.forwardRef<HTMLLIElement, DropzoneFileListItemProps<unknown, unknown>>(\n ({ className, file, children, ...props }, ref) => {\n const context = useDropzoneContext()\n const messageId = context.getFileMessageId(file.id)\n const isInvalid = file.status === 'error'\n const canRetry = context.canRetry(file.id)\n\n const value = React.useMemo<DropzoneFileListContextValue<unknown, unknown>>(\n () => ({\n onRemoveFile: () => context.onRemoveFile(file.id),\n onRetry: () => context.onRetry(file.id),\n fileStatus: file,\n canRetry,\n dropzoneId: context.inputId,\n messageId\n }),\n [canRetry, context, file, messageId]\n )\n\n return (\n <DropzoneFileListContext.Provider value={value}>\n <li\n ref={ref}\n data-slot=\"dropzone-file-item\"\n data-status={file.status}\n aria-describedby={isInvalid ? messageId : undefined}\n className={cn(\n 'rounded-xl border bg-card px-4 py-3 shadow-xs',\n file.status === 'error' && 'border-destructive/50',\n className\n )}\n {...props}\n >\n {children}\n </li>\n </DropzoneFileListContext.Provider>\n )\n }\n)\n\nconst DropzoneFileMessage = React.forwardRef<HTMLParagraphElement, DropzoneFileMessageProps>(\n ({ className, children, ...props }, ref) => {\n const context = useDropzoneFileListContext()\n const body =\n context.fileStatus.status === 'error'\n ? (context.fileStatus.message ?? String(context.fileStatus.error))\n : children\n\n return (\n <p\n ref={ref}\n id={context.messageId}\n data-slot=\"dropzone-file-message\"\n className={cn(\n 'min-h-5 text-[0.8rem] font-medium',\n context.fileStatus.status === 'error' && 'text-destructive',\n className\n )}\n {...props}\n >\n {body}\n </p>\n )\n }\n)\n\nconst DropzoneMessage = React.forwardRef<HTMLParagraphElement, DropzoneMessageProps>(\n ({ className, children, ...props }, ref) => {\n const context = useDropzoneContext()\n const body = context.rootError ?? children\n\n return (\n <p\n ref={ref}\n id={context.rootMessageId}\n data-slot=\"dropzone-message\"\n className={cn('min-h-5 text-[0.8rem] font-medium text-destructive', className)}\n {...props}\n >\n {body}\n </p>\n )\n }\n)\n\nconst DropzoneRemoveFile = React.forwardRef<HTMLButtonElement, DropzoneRemoveFileProps>(\n ({ className, onClick, size = 'icon-sm', type = 'button', variant = 'ghost', ...props }, ref) => {\n const context = useDropzoneFileListContext()\n\n const handleClick = React.useCallback<React.MouseEventHandler<HTMLButtonElement>>(\n (event) => {\n onClick?.(event)\n if (event.defaultPrevented) {\n return\n }\n\n void context.onRemoveFile()\n },\n [context, onClick]\n )\n\n return (\n <Button\n ref={ref}\n data-slot=\"dropzone-remove-file\"\n className={cn(className)}\n onClick={handleClick}\n size={size}\n type={type}\n variant={variant}\n {...props}\n />\n )\n }\n)\n\nconst DropzoneRetryFile = React.forwardRef<HTMLButtonElement, DropzoneRetryFileProps>(\n ({ className, disabled, onClick, size = 'icon-sm', type = 'button', variant = 'ghost', ...props }, ref) => {\n const context = useDropzoneFileListContext()\n const isDisabled = disabled || !context.canRetry\n\n const handleClick = React.useCallback<React.MouseEventHandler<HTMLButtonElement>>(\n (event) => {\n onClick?.(event)\n if (event.defaultPrevented || isDisabled) {\n return\n }\n\n void context.onRetry()\n },\n [context, isDisabled, onClick]\n )\n\n return (\n <Button\n ref={ref}\n data-slot=\"dropzone-retry-file\"\n className={cn(className)}\n disabled={isDisabled}\n onClick={handleClick}\n size={size}\n type={type}\n variant={variant}\n {...props}\n />\n )\n }\n)\n\nconst DropzoneTrigger = React.forwardRef<HTMLButtonElement, DropzoneTriggerProps>(\n ({ className, onClick, size = 'sm', type = 'button', variant = 'subtle', ...props }, ref) => {\n const context = useDropzoneContext()\n const describedBy =\n [context.rootDescriptionId, context.isInvalid ? context.rootMessageId : undefined].filter(Boolean).join(' ') ||\n undefined\n\n const handleClick = React.useCallback<React.MouseEventHandler<HTMLButtonElement>>(\n (event) => {\n onClick?.(event)\n if (event.defaultPrevented) {\n return\n }\n\n context.open()\n },\n [context, onClick]\n )\n\n return (\n <Button\n ref={ref}\n aria-controls={context.inputId}\n aria-describedby={describedBy}\n aria-invalid={context.isInvalid || undefined}\n data-slot=\"dropzone-trigger\"\n className={cn(className)}\n onClick={handleClick}\n size={size}\n type={type}\n variant={variant}\n {...props}\n />\n )\n }\n)\n\nconst InfiniteProgress = React.forwardRef<HTMLDivElement, InfiniteProgressProps>(\n ({ className, status, ...props }, ref) => {\n const done = status === 'success' || status === 'error'\n const isError = status === 'error'\n\n return (\n <div\n ref={ref}\n aria-valuemax={100}\n aria-valuemin={0}\n aria-valuetext={valueTextMap[status]}\n data-slot=\"dropzone-progress\"\n data-status={status}\n role=\"progressbar\"\n className={cn('relative h-2 w-full overflow-hidden rounded-full bg-muted', className)}\n {...props}\n >\n <div\n className={cn(\n 'h-full w-full rounded-full bg-primary transition-transform',\n done ? 'translate-x-0' : 'animate-infinite-progress',\n isError && 'bg-destructive'\n )}\n />\n </div>\n )\n }\n)\n\nDropzone.displayName = 'Dropzone'\nDropzoneArea.displayName = 'DropzoneArea'\nDropzoneDescription.displayName = 'DropzoneDescription'\nDropzoneFileList.displayName = 'DropzoneFileList'\nDropzoneFileListItem.displayName = 'DropzoneFileListItem'\nDropzoneFileMessage.displayName = 'DropzoneFileMessage'\nDropzoneMessage.displayName = 'DropzoneMessage'\nDropzoneRemoveFile.displayName = 'DropzoneRemoveFile'\nDropzoneRetryFile.displayName = 'DropzoneRetryFile'\nDropzoneTrigger.displayName = 'DropzoneTrigger'\nInfiniteProgress.displayName = 'InfiniteProgress'\n\nexport {\n Dropzone,\n DropzoneArea,\n DropzoneDescription,\n DropzoneFileList,\n DropzoneFileListItem,\n DropzoneFileMessage,\n DropzoneMessage,\n DropzoneRemoveFile,\n DropzoneRetryFile,\n DropzoneTrigger,\n ErrorCode,\n type FileError,\n InfiniteProgress,\n useDropzone\n}\n"],"mappings":"6SAaA,MAAMG,EAAqB,CACzBC,EAAU,gBACVA,EAAU,aACVA,EAAU,aACVA,EAAU,YACZ,EAiJMC,EAAuB,IAAI,IAAeF,CAAkB,EAE5DG,EAAe,CACnB,QAAS,gBACT,QAAS,OACT,MAAO,OACT,EAEMC,EAAkBN,EAAM,cAA0D,IAAI,EAEtFO,EAA0BP,EAAM,cAAqE,IAAI,EAE/G,SAAS,kBACP,EACA,EACmD,CACnD,OAAQQ,EAAO,KAAf,CACE,IAAK,MACH,MAAO,CACL,GAAGC,EACH,CAC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AU,mBACV,UAAW4C,EAAGC,CAAS,EACvB,QAASc,EACH,OACA,OACG,UACT,GAAIxD,CACL,CAAA,CAEL,CACF,EAEMgE,EAAmB7F,EAAM,YAC5B,CAAE,YAAW,SAAQ,GAAG6B,GAAS,IAAQ,CACxC,IAAMiE,EAAOC,IAAW,WAAaA,IAAW,QAC1CC,EAAUD,IAAW,QAE3B,MACE,kBAAC,MAAD,CACO,MACL,gBAAe,IACf,gBAAe,EACf,iBAAgB1F,EAAa0F,GAC7B,YAAU,oBACV,cAAaA,EACb,KAAK,cACL,UAAWzB,EAAG,4DAA6DC,CAAS,EACpF,GAAI1C,EAEJ,SAAA,kBAAC,MAAD,CACE,UAAWyC,EACT,6DACAwB,EAAO,gBAAkB,4BACzBE,GAAW,gBACb,CACD,CAAA,CACE,CAAA,CAET,CACF,EAEA,SAAS,YAAc,WACvB,EAAa,YAAc,eAC3B,EAAoB,YAAc,sBAClC,EAAiB,YAAc,mBAC/B,EAAqB,YAAc,uBACnC,EAAoB,YAAc,sBAClC,EAAgB,YAAc,kBAC9B,EAAmB,YAAc,qBACjC,EAAkB,YAAc,oBAChC,EAAgB,YAAc,kBAC9B,EAAiB,YAAc"}
|
|
1
|
+
{"version":3,"file":"dropzone.js","names":["useReactDropzone","React","useDropzone$1","dropzoneErrorCodes","ErrorCode","dropzoneErrorCodeSet","valueTextMap","DropzoneContext","DropzoneFileListContext","action","state","fileStatus","accept","acceptedTypes","mimeType","extensions","errorCodes","fileRejections","rejection","error","errorCode","errors","limits","firstError","restErrors","shapeUploadError","message","context","handleDropFile","handleRemoveFile","props","inputId","rootMessageId","rootDescriptionId","rootError","setRootErrorState","setRootError","onRootError","fileStatuses","dispatch","getFileMessageId","id","isInvalid","uploadFile","result","file","autoRetry","retryCount","maxRetryCount","onFileUploadError","onFileUploaded","uploadError","onRemoveFile","canRetry","item","onRetry","dropzone","validation","nextFiles","acceptedFiles","maxFiles","overflow","shiftOnMaxFiles","filesToRemove","remainingOverflow","availableSlots","onAllUploaded","DropzoneArea","describedBy","rootRef","rootProps","cn","className","inputProps","composeRefs","forwardedRef","children","DropzoneDescription","DropzoneFileList","DropzoneFileListItem","messageId","value","DropzoneFileMessage","body","DropzoneMessage","DropzoneRemoveFile","handleClick","onClick","event","Button","DropzoneRetryFile","isDisabled","disabled","DropzoneTrigger","InfiniteProgress","done","status","isError"],"sources":["../../src/components/dropzone.tsx"],"sourcesContent":["import * as React from 'react'\nimport {\n type Accept,\n ErrorCode,\n type FileError,\n type FileRejection,\n useDropzone as useReactDropzone\n} from 'react-dropzone'\n\nimport { composeRefs } from '../lib/compose-refs'\nimport { cn } from '../lib/utils'\nimport { Button, type ButtonProps } from './button'\n\nconst dropzoneErrorCodes = [\n ErrorCode.FileInvalidType,\n ErrorCode.FileTooLarge,\n ErrorCode.FileTooSmall,\n ErrorCode.TooManyFiles\n]\n\ntype DropzoneAction<TUploadResult, TUploadError> =\n | {\n type: 'add'\n id: string\n fileName: string\n file: File\n }\n | {\n type: 'remove'\n id: string\n }\n | {\n type: 'update-status'\n id: string\n status: 'pending'\n }\n | {\n type: 'update-status'\n id: string\n status: 'error'\n error: TUploadError\n message?: string\n }\n | {\n type: 'update-status'\n id: string\n status: 'success'\n result: TUploadResult\n }\n\nexport type DropzoneUploadResult<TUploadResult, TUploadError> =\n | {\n status: 'error'\n error: TUploadError\n }\n | {\n status: 'success'\n result: TUploadResult\n }\n\nexport type DropzoneFileStatus<TUploadResult, TUploadError> = {\n id: string\n fileName: string\n file: File\n tries: number\n} & (\n | {\n status: 'pending'\n error?: undefined\n message?: undefined\n result?: undefined\n }\n | {\n status: 'error'\n error: TUploadError\n message?: string\n result?: undefined\n }\n | {\n status: 'success'\n result: TUploadResult\n error?: undefined\n message?: undefined\n }\n)\n\nexport type FileStatus<TUploadResult, TUploadError> = DropzoneFileStatus<TUploadResult, TUploadError>\n\nexport type DropzoneValidation = {\n accept?: Accept\n minSize?: number\n maxSize?: number\n maxFiles?: number\n}\n\nexport type UseDropzoneProps<TUploadResult, TUploadError = string> = {\n /** Uploads one file. Resolve to `{ status: 'success', result }` or `{ status: 'error', error }`. */\n onDropFile: (file: File) => Promise<DropzoneUploadResult<TUploadResult, TUploadError>>\n /** Called when a file is removed, with its id. */\n onRemoveFile?: (id: string) => void | Promise<void>\n /** Called with the result of each successful upload. */\n onFileUploaded?: (result: TUploadResult) => void\n /** Called with the error of each failed upload. */\n onFileUploadError?: (error: TUploadError) => void\n /** Called when every pending upload has finished. */\n onAllUploaded?: () => void\n /** Called with the validation message when dropped files are rejected, or `undefined` when cleared. */\n onRootError?: (error: string | undefined) => void\n /** Turns an upload error into the message shown for the file. */\n shapeUploadError?: (error: TUploadError) => string | undefined\n /** Maximum number of retries per file. Unlimited when omitted. */\n maxRetryCount?: number\n /**\n * Retries failed uploads automatically, up to `maxRetryCount`.\n * @default false\n */\n autoRetry?: boolean\n /** File rules: `accept`, `minSize`, `maxSize` (bytes) and `maxFiles`. */\n validation?: DropzoneValidation\n /**\n * Removes the oldest files when new ones exceed `maxFiles`, instead of rejecting them.\n * @default false\n */\n shiftOnMaxFiles?: boolean\n}\n\nexport interface UseDropzoneReturn<TUploadResult, TUploadError> {\n getRootProps: ReturnType<typeof useReactDropzone>['getRootProps']\n getInputProps: ReturnType<typeof useReactDropzone>['getInputProps']\n open: () => void\n onRemoveFile: (id: string) => Promise<void>\n onRetry: (id: string) => Promise<void>\n canRetry: (id: string) => boolean\n fileStatuses: DropzoneFileStatus<TUploadResult, TUploadError>[]\n isInvalid: boolean\n isDragActive: boolean\n rootError: string | undefined\n inputId: string\n rootMessageId: string\n rootDescriptionId: string\n getFileMessageId: (id: string) => string\n}\n\nexport type DropzoneProps<TUploadResult, TUploadError> = React.PropsWithChildren<\n UseDropzoneReturn<TUploadResult, TUploadError>\n>\n\nexport type DropzoneAreaProps = React.ComponentProps<'div'>\n\nexport type DropzoneDescriptionProps = React.ComponentProps<'p'>\n\nexport type DropzoneFileListProps = React.ComponentProps<'ol'>\n\nexport type DropzoneFileListItemProps<TUploadResult, TUploadError> = React.ComponentProps<'li'> & {\n /** File status from `fileStatuses`, used by the parts inside the item. */\n file: DropzoneFileStatus<TUploadResult, TUploadError>\n}\n\nexport type DropzoneFileMessageProps = React.ComponentProps<'p'>\n\nexport type DropzoneMessageProps = React.ComponentProps<'p'>\n\nexport type DropzoneRemoveFileProps = ButtonProps\n\nexport type DropzoneRetryFileProps = ButtonProps\n\nexport type DropzoneTriggerProps = ButtonProps\n\nexport type InfiniteProgressProps = React.ComponentProps<'div'> & {\n /** Upload status shown by the bar. */\n status: 'pending' | 'success' | 'error'\n}\n\ntype DropzoneFileListContextValue<TUploadResult, TUploadError> = {\n onRemoveFile: () => Promise<void>\n onRetry: () => Promise<void>\n fileStatus: DropzoneFileStatus<TUploadResult, TUploadError>\n canRetry: boolean\n dropzoneId: string\n messageId: string\n}\n\nconst dropzoneErrorCodeSet = new Set<ErrorCode>(dropzoneErrorCodes)\n\nconst valueTextMap = {\n pending: 'indeterminate',\n success: '100%',\n error: 'error'\n} as const\n\nconst DropzoneContext = React.createContext<UseDropzoneReturn<unknown, unknown> | null>(null)\n\nconst DropzoneFileListContext = React.createContext<DropzoneFileListContextValue<unknown, unknown> | null>(null)\n\nfunction fileStatusReducer<TUploadResult, TUploadError>(\n state: DropzoneFileStatus<TUploadResult, TUploadError>[],\n action: DropzoneAction<TUploadResult, TUploadError>\n): DropzoneFileStatus<TUploadResult, TUploadError>[] {\n switch (action.type) {\n case 'add':\n return [\n ...state,\n {\n id: action.id,\n fileName: action.fileName,\n file: action.file,\n status: 'pending',\n tries: 1\n }\n ]\n case 'remove':\n return state.filter((fileStatus) => fileStatus.id !== action.id)\n case 'update-status':\n return state.map((fileStatus) => {\n if (fileStatus.id !== action.id) {\n return fileStatus\n }\n\n if (action.status === 'pending') {\n return {\n ...fileStatus,\n status: 'pending',\n error: undefined,\n message: undefined,\n result: undefined,\n tries: fileStatus.tries + 1\n }\n }\n\n if (action.status === 'error') {\n return {\n ...fileStatus,\n status: 'error',\n error: action.error,\n message: action.message,\n result: undefined\n }\n }\n\n return {\n ...fileStatus,\n status: 'success',\n result: action.result,\n error: undefined,\n message: undefined\n }\n })\n }\n}\n\nfunction formatAcceptedTypes(accept?: Accept) {\n if (!accept) {\n return undefined\n }\n\n const acceptedTypes = Object.entries(accept).flatMap(([mimeType, extensions]) => {\n return extensions.length > 0 ? extensions : [mimeType]\n })\n\n return acceptedTypes.length > 0 ? acceptedTypes.join(', ') : undefined\n}\n\nfunction getDropzoneErrorCodes(fileRejections: FileRejection[]) {\n const errorCodes = fileRejections.flatMap((rejection) =>\n rejection.errors.map((error) => error.code as ErrorCode).filter((errorCode) => dropzoneErrorCodeSet.has(errorCode))\n )\n\n return Array.from(new Set(errorCodes))\n}\n\nfunction getRootError(errorCodes: ErrorCode[], limits: DropzoneValidation) {\n const errors = errorCodes.flatMap((errorCode) => {\n switch (errorCode) {\n case 'file-invalid-type': {\n const acceptedTypes = formatAcceptedTypes(limits.accept)\n return acceptedTypes ? [`only ${acceptedTypes} files are allowed`] : ['this file type is not allowed']\n }\n case 'file-too-large': {\n if (!limits.maxSize) {\n return ['this file is too large']\n }\n\n return [`max size is ${(limits.maxSize / (1024 * 1024)).toFixed(2)} MB`]\n }\n case 'file-too-small': {\n if (!limits.minSize) {\n return ['this file is too small']\n }\n\n return [`min size is ${(limits.minSize / (1024 * 1024)).toFixed(2)} MB`]\n }\n case 'too-many-files':\n return limits.maxFiles ? [`max ${limits.maxFiles} files`] : ['too many files']\n default:\n return []\n }\n })\n\n if (errors.length === 0) {\n return 'Unable to add the selected files'\n }\n\n const [firstError, ...restErrors] = errors as [string, ...string[]]\n return `${firstError.charAt(0).toUpperCase()}${firstError.slice(1)}${restErrors.length > 0 ? `, ${restErrors.join(', ')}` : ''}`\n}\n\nfunction getRejectionMessage(fileRejections: FileRejection[], limits: DropzoneValidation) {\n const errorCodes = getDropzoneErrorCodes(fileRejections)\n\n if (errorCodes.length > 0) {\n return getRootError(errorCodes, limits)\n }\n\n return fileRejections[0]?.errors[0]?.message ?? 'Unable to add the selected files'\n}\n\nfunction getUploadErrorMessage<TUploadError>(\n error: TUploadError,\n shapeUploadError?: (error: TUploadError) => string | undefined\n) {\n if (shapeUploadError) {\n const message = shapeUploadError(error)\n if (message !== undefined) {\n return message\n }\n }\n\n if (typeof error === 'string') {\n return error\n }\n\n if (error instanceof Error) {\n return error.message\n }\n\n return undefined\n}\n\nfunction useDropzoneContext<TUploadResult, TUploadError>() {\n const context = React.useContext(DropzoneContext)\n\n if (!context) {\n throw new Error('Dropzone components must be used within a Dropzone.')\n }\n\n return context as UseDropzoneReturn<TUploadResult, TUploadError>\n}\n\nfunction useDropzoneFileListContext<TUploadResult, TUploadError>() {\n const context = React.useContext(DropzoneFileListContext)\n\n if (!context) {\n throw new Error('Dropzone file actions must be used within a DropzoneFileListItem.')\n }\n\n return context as DropzoneFileListContextValue<TUploadResult, TUploadError>\n}\n\nfunction useDropzone<TUploadResult, TUploadError = string>(\n props: UseDropzoneProps<TUploadResult, TUploadError>\n): UseDropzoneReturn<TUploadResult, TUploadError> {\n const {\n onDropFile: handleDropFile,\n onRemoveFile: handleRemoveFile,\n shapeUploadError,\n onFileUploaded,\n onFileUploadError,\n onAllUploaded,\n onRootError,\n maxRetryCount,\n autoRetry = false,\n validation,\n shiftOnMaxFiles = false\n } = props\n\n const inputId = React.useId()\n const rootMessageId = `${inputId}-message`\n const rootDescriptionId = `${inputId}-description`\n const [rootError, setRootErrorState] = React.useState<string | undefined>(undefined)\n\n const setRootError = React.useCallback(\n (error: string | undefined) => {\n setRootErrorState(error)\n onRootError?.(error)\n },\n [onRootError]\n )\n\n const [fileStatuses, dispatch] = React.useReducer(\n fileStatusReducer<TUploadResult, TUploadError>,\n [] as DropzoneFileStatus<TUploadResult, TUploadError>[]\n )\n\n const getFileMessageId = React.useCallback((id: string) => `${inputId}-${id}-message`, [inputId])\n\n const isInvalid = React.useMemo(() => {\n return rootError !== undefined || fileStatuses.some((fileStatus) => fileStatus.status === 'error')\n }, [fileStatuses, rootError])\n\n const uploadFile = React.useCallback(\n async (file: File, id: string, retryCount = 0) => {\n try {\n const result = await handleDropFile(file)\n\n if (result.status === 'error') {\n if (autoRetry && retryCount < (maxRetryCount ?? Number.POSITIVE_INFINITY)) {\n dispatch({ type: 'update-status', id, status: 'pending' })\n return uploadFile(file, id, retryCount + 1)\n }\n\n dispatch({\n type: 'update-status',\n id,\n status: 'error',\n error: result.error,\n message: getUploadErrorMessage(result.error, shapeUploadError)\n })\n onFileUploadError?.(result.error)\n return\n }\n\n dispatch({\n type: 'update-status',\n id,\n status: 'success',\n result: result.result\n })\n onFileUploaded?.(result.result)\n } catch (error) {\n const uploadError = error as TUploadError\n\n dispatch({\n type: 'update-status',\n id,\n status: 'error',\n error: uploadError,\n message: getUploadErrorMessage(uploadError, shapeUploadError)\n })\n onFileUploadError?.(uploadError)\n }\n },\n [autoRetry, handleDropFile, maxRetryCount, onFileUploadError, onFileUploaded, shapeUploadError]\n )\n\n const onRemoveFile = React.useCallback(\n async (id: string) => {\n await handleRemoveFile?.(id)\n dispatch({ type: 'remove', id })\n },\n [handleRemoveFile]\n )\n\n const canRetry = React.useCallback(\n (id: string) => {\n const fileStatus = fileStatuses.find((item) => item.id === id)\n\n return fileStatus?.status === 'error' && fileStatus.tries <= (maxRetryCount ?? Number.POSITIVE_INFINITY)\n },\n [fileStatuses, maxRetryCount]\n )\n\n const onRetry = React.useCallback(\n async (id: string) => {\n if (!canRetry(id)) {\n return\n }\n\n const fileStatus = fileStatuses.find((item) => item.id === id)\n\n if (fileStatus?.status !== 'error') {\n return\n }\n\n dispatch({ type: 'update-status', id, status: 'pending' })\n await uploadFile(fileStatus.file, id)\n },\n [canRetry, fileStatuses, uploadFile]\n )\n\n const dropzone = useReactDropzone({\n accept: validation?.accept,\n minSize: validation?.minSize,\n maxSize: validation?.maxSize,\n maxFiles: validation?.maxFiles,\n noClick: true,\n noKeyboard: true,\n onDropAccepted: async (acceptedFiles) => {\n setRootError(undefined)\n\n let nextFiles = acceptedFiles\n const maxFiles = validation?.maxFiles ?? Number.POSITIVE_INFINITY\n const overflow = Number.isFinite(maxFiles)\n ? Math.max(fileStatuses.length + acceptedFiles.length - maxFiles, 0)\n : 0\n\n if (overflow > 0) {\n if (shiftOnMaxFiles) {\n const filesToRemove = fileStatuses.slice(0, Math.min(overflow, fileStatuses.length))\n\n await Promise.all(filesToRemove.map((fileStatus) => onRemoveFile(fileStatus.id)))\n\n const remainingOverflow = overflow - filesToRemove.length\n if (remainingOverflow > 0) {\n nextFiles = acceptedFiles.slice(remainingOverflow)\n }\n } else {\n setRootError(getRootError([ErrorCode.TooManyFiles], validation ?? {}))\n const availableSlots = Math.max(maxFiles - fileStatuses.length, 0)\n nextFiles = acceptedFiles.slice(0, availableSlots)\n }\n }\n\n if (nextFiles.length === 0) {\n return\n }\n\n await Promise.all(\n nextFiles.map(async (file) => {\n const id = crypto.randomUUID()\n dispatch({ type: 'add', id, fileName: file.name, file })\n await uploadFile(file, id)\n })\n )\n\n onAllUploaded?.()\n },\n onDropRejected: (fileRejections) => {\n setRootError(getRejectionMessage(fileRejections, validation ?? {}))\n }\n })\n\n return {\n getRootProps: dropzone.getRootProps,\n getInputProps: dropzone.getInputProps,\n open: dropzone.open,\n onRemoveFile,\n onRetry,\n canRetry,\n fileStatuses,\n isInvalid,\n isDragActive: dropzone.isDragActive,\n rootError,\n inputId,\n rootMessageId,\n rootDescriptionId,\n getFileMessageId\n }\n}\n\nfunction Dropzone<TUploadResult, TUploadError>({ children, ...dropzone }: DropzoneProps<TUploadResult, TUploadError>) {\n return <DropzoneContext.Provider value={dropzone}>{children}</DropzoneContext.Provider>\n}\n\nconst DropzoneArea = React.forwardRef<HTMLDivElement, DropzoneAreaProps>(\n ({ className, children, ...props }, forwardedRef) => {\n const context = useDropzoneContext()\n const describedBy =\n [context.rootDescriptionId, context.isInvalid ? context.rootMessageId : undefined].filter(Boolean).join(' ') ||\n undefined\n\n const { ref: rootRef, ...rootProps } = context.getRootProps({\n ...props,\n 'data-slot': 'dropzone-area',\n 'aria-describedby': describedBy,\n 'aria-invalid': context.isInvalid || undefined,\n className: cn(\n 'flex min-h-44 flex-col items-center justify-center gap-4 rounded-xl border border-dashed border-input bg-muted/20 px-6 py-8 text-center transition-colors',\n context.isDragActive && 'border-primary bg-primary/5',\n context.isInvalid && 'border-destructive bg-destructive/5',\n className\n )\n }) as React.HTMLAttributes<HTMLDivElement> & {\n ref?: React.Ref<HTMLDivElement>\n }\n\n const inputProps = context.getInputProps({\n id: context.inputId,\n className: 'sr-only',\n 'aria-describedby': describedBy,\n 'aria-invalid': context.isInvalid,\n tabIndex: -1\n })\n\n return (\n <div {...rootProps} ref={composeRefs(forwardedRef, rootRef)}>\n <input {...inputProps} />\n {children}\n </div>\n )\n }\n)\n\nconst DropzoneDescription = React.forwardRef<HTMLParagraphElement, DropzoneDescriptionProps>(\n ({ className, ...props }, ref) => {\n const context = useDropzoneContext()\n\n return (\n <p\n ref={ref}\n id={context.rootDescriptionId}\n data-slot=\"dropzone-description\"\n className={cn('text-sm text-muted-foreground', className)}\n {...props}\n />\n )\n }\n)\n\nconst DropzoneFileList = React.forwardRef<HTMLOListElement, DropzoneFileListProps>(({ className, ...props }, ref) => {\n useDropzoneContext()\n\n return <ol ref={ref} data-slot=\"dropzone-file-list\" className={cn('space-y-3', className)} {...props} />\n})\n\nconst DropzoneFileListItem = React.forwardRef<HTMLLIElement, DropzoneFileListItemProps<unknown, unknown>>(\n ({ className, file, children, ...props }, ref) => {\n const context = useDropzoneContext()\n const messageId = context.getFileMessageId(file.id)\n const isInvalid = file.status === 'error'\n const canRetry = context.canRetry(file.id)\n\n const value = React.useMemo<DropzoneFileListContextValue<unknown, unknown>>(\n () => ({\n onRemoveFile: () => context.onRemoveFile(file.id),\n onRetry: () => context.onRetry(file.id),\n fileStatus: file,\n canRetry,\n dropzoneId: context.inputId,\n messageId\n }),\n [canRetry, context, file, messageId]\n )\n\n return (\n <DropzoneFileListContext.Provider value={value}>\n <li\n ref={ref}\n data-slot=\"dropzone-file-item\"\n data-status={file.status}\n aria-describedby={isInvalid ? messageId : undefined}\n className={cn(\n 'rounded-xl border bg-card px-4 py-3 shadow-xs',\n file.status === 'error' && 'border-destructive/50',\n className\n )}\n {...props}\n >\n {children}\n </li>\n </DropzoneFileListContext.Provider>\n )\n }\n)\n\nconst DropzoneFileMessage = React.forwardRef<HTMLParagraphElement, DropzoneFileMessageProps>(\n ({ className, children, ...props }, ref) => {\n const context = useDropzoneFileListContext()\n const body =\n context.fileStatus.status === 'error'\n ? (context.fileStatus.message ?? String(context.fileStatus.error))\n : children\n\n return (\n <p\n ref={ref}\n id={context.messageId}\n data-slot=\"dropzone-file-message\"\n className={cn(\n 'min-h-5 text-[0.8rem] font-medium',\n context.fileStatus.status === 'error' && 'text-destructive',\n className\n )}\n {...props}\n >\n {body}\n </p>\n )\n }\n)\n\nconst DropzoneMessage = React.forwardRef<HTMLParagraphElement, DropzoneMessageProps>(\n ({ className, children, ...props }, ref) => {\n const context = useDropzoneContext()\n const body = context.rootError ?? children\n\n return (\n <p\n ref={ref}\n id={context.rootMessageId}\n data-slot=\"dropzone-message\"\n className={cn('min-h-5 text-[0.8rem] font-medium text-destructive', className)}\n {...props}\n >\n {body}\n </p>\n )\n }\n)\n\nconst DropzoneRemoveFile = React.forwardRef<HTMLButtonElement, DropzoneRemoveFileProps>(\n ({ className, onClick, size = 'icon-sm', type = 'button', variant = 'ghost', ...props }, ref) => {\n const context = useDropzoneFileListContext()\n\n const handleClick = React.useCallback<React.MouseEventHandler<HTMLButtonElement>>(\n (event) => {\n onClick?.(event)\n if (event.defaultPrevented) {\n return\n }\n\n void context.onRemoveFile()\n },\n [context, onClick]\n )\n\n return (\n <Button\n ref={ref}\n data-slot=\"dropzone-remove-file\"\n className={cn(className)}\n onClick={handleClick}\n size={size}\n type={type}\n variant={variant}\n {...props}\n />\n )\n }\n)\n\nconst DropzoneRetryFile = React.forwardRef<HTMLButtonElement, DropzoneRetryFileProps>(\n ({ className, disabled, onClick, size = 'icon-sm', type = 'button', variant = 'ghost', ...props }, ref) => {\n const context = useDropzoneFileListContext()\n const isDisabled = disabled || !context.canRetry\n\n const handleClick = React.useCallback<React.MouseEventHandler<HTMLButtonElement>>(\n (event) => {\n onClick?.(event)\n if (event.defaultPrevented || isDisabled) {\n return\n }\n\n void context.onRetry()\n },\n [context, isDisabled, onClick]\n )\n\n return (\n <Button\n ref={ref}\n data-slot=\"dropzone-retry-file\"\n className={cn(className)}\n disabled={isDisabled}\n onClick={handleClick}\n size={size}\n type={type}\n variant={variant}\n {...props}\n />\n )\n }\n)\n\nconst DropzoneTrigger = React.forwardRef<HTMLButtonElement, DropzoneTriggerProps>(\n ({ className, onClick, size = 'sm', type = 'button', variant = 'subtle', ...props }, ref) => {\n const context = useDropzoneContext()\n const describedBy =\n [context.rootDescriptionId, context.isInvalid ? context.rootMessageId : undefined].filter(Boolean).join(' ') ||\n undefined\n\n const handleClick = React.useCallback<React.MouseEventHandler<HTMLButtonElement>>(\n (event) => {\n onClick?.(event)\n if (event.defaultPrevented) {\n return\n }\n\n context.open()\n },\n [context, onClick]\n )\n\n return (\n <Button\n ref={ref}\n aria-controls={context.inputId}\n aria-describedby={describedBy}\n aria-invalid={context.isInvalid || undefined}\n data-slot=\"dropzone-trigger\"\n className={cn(className)}\n onClick={handleClick}\n size={size}\n type={type}\n variant={variant}\n {...props}\n />\n )\n }\n)\n\nconst InfiniteProgress = React.forwardRef<HTMLDivElement, InfiniteProgressProps>(\n ({ className, status, ...props }, ref) => {\n const done = status === 'success' || status === 'error'\n const isError = status === 'error'\n\n return (\n <div\n ref={ref}\n aria-valuemax={100}\n aria-valuemin={0}\n aria-valuetext={valueTextMap[status]}\n data-slot=\"dropzone-progress\"\n data-status={status}\n role=\"progressbar\"\n className={cn('relative h-2 w-full overflow-hidden rounded-full bg-muted', className)}\n {...props}\n >\n <div\n className={cn(\n 'h-full w-full rounded-full bg-primary transition-transform',\n done ? 'translate-x-0' : 'animate-infinite-progress',\n isError && 'bg-destructive'\n )}\n />\n </div>\n )\n }\n)\n\nDropzone.displayName = 'Dropzone'\nDropzoneArea.displayName = 'DropzoneArea'\nDropzoneDescription.displayName = 'DropzoneDescription'\nDropzoneFileList.displayName = 'DropzoneFileList'\nDropzoneFileListItem.displayName = 'DropzoneFileListItem'\nDropzoneFileMessage.displayName = 'DropzoneFileMessage'\nDropzoneMessage.displayName = 'DropzoneMessage'\nDropzoneRemoveFile.displayName = 'DropzoneRemoveFile'\nDropzoneRetryFile.displayName = 'DropzoneRetryFile'\nDropzoneTrigger.displayName = 'DropzoneTrigger'\nInfiniteProgress.displayName = 'InfiniteProgress'\n\nexport {\n Dropzone,\n DropzoneArea,\n DropzoneDescription,\n DropzoneFileList,\n DropzoneFileListItem,\n DropzoneFileMessage,\n DropzoneMessage,\n DropzoneRemoveFile,\n DropzoneRetryFile,\n DropzoneTrigger,\n ErrorCode,\n type FileError,\n InfiniteProgress,\n useDropzone\n}\n"],"mappings":"6SAaA,MAAMG,EAAqB,CACzBC,EAAU,gBACVA,EAAU,aACVA,EAAU,aACVA,EAAU,YACZ,EAoKMC,EAAuB,IAAI,IAAeF,CAAkB,EAE5DG,EAAe,CACnB,QAAS,gBACT,QAAS,OACT,MAAO,OACT,EAEMC,EAAkBN,EAAM,cAA0D,IAAI,EAEtFO,EAA0BP,EAAM,cAAqE,IAAI,EAE/G,SAAS,kBACP,EACA,EACmD,CACnD,OAAQQ,EAAO,KAAf,CACE,IAAK,MACH,MAAO,CACL,GAAGC,EACH,CACE,GAAID,EAAO,GACX,SAAUA,EAAO,SACjB,KAAMA,EAAO,KACb,OAAQ,UACR,MAAO,CACT,CACF,EACF,IAAK,SACH,OAAOC,EAAM,OAAQ,GAAeC,EAAW,KAAOF,EAAO,EAAE,EACjE,IAAK,gBACH,OAAOC,EAAM,IAAK,GACZC,EAAW,KAAOF,EAAO,GAIzBA,EAAO,SAAW,UACb,CACL,GAAGE,EACH,OAA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,gBAAe,IACf,gBAAe,EACf,iBAAgB1F,EAAa0F,GAC7B,YAAU,oBACV,cAAaA,EACb,KAAK,cACL,UAAWzB,EAAG,4DAA6DC,CAAS,EACpF,GAAI1C,EAEJ,SAAA,kBAAC,MAAD,CACE,UAAWyC,EACT,6DACAwB,EAAO,gBAAkB,4BACzBE,GAAW,gBACb,CACD,CAAA,CACE,CAAA,CAET,CACF,EAEA,SAAS,YAAc,WACvB,EAAa,YAAc,eAC3B,EAAoB,YAAc,sBAClC,EAAiB,YAAc,mBAC/B,EAAqB,YAAc,uBACnC,EAAoB,YAAc,sBAClC,EAAgB,YAAc,kBAC9B,EAAmB,YAAc,qBACjC,EAAkB,YAAc,oBAChC,EAAgB,YAAc,kBAC9B,EAAiB,YAAc"}
|
|
@@ -4,6 +4,10 @@ import { VariantProps } from "class-variance-authority";
|
|
|
4
4
|
//#region src/components/field.d.ts
|
|
5
5
|
export type FieldSetProps = React.ComponentProps<'fieldset'>;
|
|
6
6
|
export type FieldLegendProps = React.ComponentProps<'legend'> & {
|
|
7
|
+
/**
|
|
8
|
+
* `label` renders the legend at the size of a field label.
|
|
9
|
+
* @default 'legend'
|
|
10
|
+
*/
|
|
7
11
|
variant?: 'legend' | 'label';
|
|
8
12
|
};
|
|
9
13
|
export type FieldGroupProps = React.ComponentProps<'div'>;
|
|
@@ -15,25 +19,33 @@ export type FieldSeparatorProps = React.ComponentProps<'div'> & {
|
|
|
15
19
|
children?: React.ReactNode;
|
|
16
20
|
};
|
|
17
21
|
export type FieldErrorProps = React.ComponentProps<'div'> & {
|
|
22
|
+
/** Errors to show. Each `message` is rendered; duplicates are removed. Ignored when `children` is passed. */
|
|
18
23
|
errors?: Array<{
|
|
19
24
|
message?: string;
|
|
20
25
|
} | undefined>;
|
|
21
26
|
};
|
|
22
27
|
declare function useFieldControlId(id?: string): string | undefined;
|
|
28
|
+
declare function useFieldLabelId(): string | undefined;
|
|
29
|
+
declare function useFieldInvalid(ariaInvalid?: React.AriaAttributes['aria-invalid']): "false" | "grammar" | "spelling" | "true" | boolean | undefined;
|
|
23
30
|
declare function FieldSet({ className, ...props }: FieldSetProps): import("react").JSX.Element;
|
|
24
31
|
declare function FieldLegend({ className, variant, ...props }: FieldLegendProps): import("react").JSX.Element;
|
|
25
32
|
declare function FieldGroup({ className, ...props }: FieldGroupProps): import("react").JSX.Element;
|
|
26
33
|
declare const fieldVariants: (props?: ({
|
|
27
34
|
orientation?: "horizontal" | "responsive" | "vertical" | null | undefined;
|
|
28
35
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
29
|
-
export type FieldProps = React.ComponentProps<'div'> & VariantProps<typeof fieldVariants
|
|
30
|
-
|
|
36
|
+
export type FieldProps = React.ComponentProps<'div'> & VariantProps<typeof fieldVariants> & {
|
|
37
|
+
/** Marks the field and the control inside it as invalid. */
|
|
38
|
+
invalid?: boolean;
|
|
39
|
+
/** Same as `invalid`, for form libraries that set the attribute directly. */
|
|
40
|
+
'data-invalid'?: boolean | 'true' | 'false';
|
|
41
|
+
};
|
|
42
|
+
declare function Field({ className, orientation, invalid, 'data-invalid': dataInvalid, ...props }: FieldProps): import("react").JSX.Element;
|
|
31
43
|
declare function FieldContent({ className, ...props }: FieldContentProps): import("react").JSX.Element;
|
|
32
|
-
declare function FieldLabel({ className, htmlFor, ...props }: FieldLabelProps): import("react").JSX.Element;
|
|
44
|
+
declare function FieldLabel({ className, htmlFor, id, ...props }: FieldLabelProps): import("react").JSX.Element;
|
|
33
45
|
declare function FieldTitle({ className, ...props }: FieldTitleProps): import("react").JSX.Element;
|
|
34
46
|
declare function FieldDescription({ className, ...props }: FieldDescriptionProps): import("react").JSX.Element;
|
|
35
47
|
declare function FieldSeparator({ children, className, ...props }: FieldSeparatorProps): import("react").JSX.Element;
|
|
36
48
|
declare function FieldError({ className, children, errors, ...props }: FieldErrorProps): import("react").JSX.Element | null;
|
|
37
49
|
//#endregion
|
|
38
|
-
export { Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle, useFieldControlId };
|
|
50
|
+
export { Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle, useFieldControlId, useFieldInvalid, useFieldLabelId };
|
|
39
51
|
//# sourceMappingURL=field.d.ts.map
|
package/dist/components/field.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../rolldown-runtime-BhWHdk3m.js";import{cn as e}from"../lib/utils.js";import{Separator as t}from"./separator.js";import{Label as n}from"./label.js";import{
|
|
1
|
+
import"../rolldown-runtime-BhWHdk3m.js";import{cn as e}from"../lib/utils.js";import{Separator as t}from"./separator.js";import{Label as n}from"./label.js";import{createContext as r,useContext as i,useId as a,useMemo as o}from"react";import{jsx as s,jsxs as c}from"react/jsx-runtime";import{cva as l}from"class-variance-authority";const u=r(null);function useFieldControlId(e){let t=i(u);return e??t?.controlId}function useFieldLabelId(){return i(u)?.labelId}function useFieldInvalid(e){let t=i(u)?.invalid;return e??(t?!0:void 0)}function FieldSet({className:t,...n}){return/* @__PURE__ */ s(`fieldset`,{"data-slot":`field-set`,className:e(`flex flex-col gap-4`,`has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3`,t),...n})}function FieldLegend({className:t,variant:n=`legend`,...r}){return/* @__PURE__ */ s(`legend`,{"data-slot":`field-legend`,"data-variant":n,className:e(`mb-1.5 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base`,t),...r})}function FieldGroup({className:t,...n}){return/* @__PURE__ */ s(`div`,{"data-slot":`field-group`,className:e(`group/field-group @container/field-group flex w-full flex-col gap-5`,`data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4`,t),...n})}const d=l(`data-[invalid=true]:text-destructive gap-1 group/field flex w-full`,{variants:{orientation:{vertical:`flex-col *:w-full [&>.sr-only]:w-auto`,horizontal:`flex-row items-center *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px`,responsive:`flex-col *:w-full [&>.sr-only]:w-auto @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:*:data-[slot=field-label]:flex-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px`}},defaultVariants:{orientation:`vertical`}});function Field({className:t,orientation:n=`vertical`,invalid:r,"data-invalid":i,...c}){let l=a(),f=a(),p=r??(i===!0||i===`true`),m=o(()=>({controlId:l,labelId:f,invalid:p}),[l,f,p]);return/* @__PURE__ */ s(u.Provider,{value:m,children:/* @__PURE__ */ s(`div`,{"data-slot":`field`,"data-orientation":n,"data-invalid":p?`true`:void 0,className:e(d({orientation:n}),t),...c})})}function FieldContent({className:t,...n}){return/* @__PURE__ */ s(`div`,{"data-slot":`field-content`,className:e(`gap-0.5 group/field-content flex flex-1 flex-col leading-snug`,t),...n})}function FieldLabel({className:t,htmlFor:r,id:i,...a}){let o=useFieldControlId(r),c=useFieldLabelId();return/* @__PURE__ */ s(n,{"data-slot":`field-label`,id:i??c,htmlFor:o,className:e(`group/field-label peer/field-label flex w-fit gap-2 leading-snug`,`has-data-checked:bg-primary/5 has-data-checked:border-primary/30 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10`,`has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border *:data-[slot=field]:p-2.5`,`group-data-[disabled=true]/field:opacity-50`,t),...a})}function FieldTitle({className:t,...n}){return/* @__PURE__ */ s(`div`,{"data-slot":`field-label`,className:e(`gap-2 text-sm font-medium group-data-[disabled=true]/field:opacity-50 flex w-fit items-center leading-snug`,t),...n})}function FieldDescription({className:t,...n}){return/* @__PURE__ */ s(`p`,{"data-slot":`field-description`,className:e(`text-muted-foreground text-left text-xs leading-normal font-normal`,`[[data-variant=legend]+&]:-mt-1.5 group-has-data-horizontal/field:text-balance last:mt-0 nth-last-2:-mt-1`,`[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary`,t),...n})}function FieldSeparator({children:n,className:r,...i}){return/* @__PURE__ */ c(`div`,{"data-slot":`field-separator`,"data-content":!!n,className:e(`-my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2 relative`,r),...i,children:[/* @__PURE__ */ s(t,{className:`absolute inset-0 top-1/2`}),n&&/* @__PURE__ */ s(`span`,{className:`text-muted-foreground px-2 bg-background relative mx-auto block w-fit`,"data-slot":`field-separator-content`,children:n})]})}function FieldError({className:t,children:n,errors:r,...i}){let a=o(()=>{if(n)return n;if(!r?.length)return null;let e=[...new Map(r.map(e=>[e?.message,e])).values()];return e?.length===1?e[0]?.message:/* @__PURE__ */ s(`ul`,{className:`ml-4 flex list-disc flex-col gap-1`,children:e.map(e=>e?.message&&/* @__PURE__ */ s(`li`,{children:e.message},e.message))})},[n,r]);return a?/* @__PURE__ */ s(`div`,{role:`alert`,"data-slot":`field-error`,className:e(`text-destructive text-sm font-normal`,t),...i,children:a}):null}export{Field,FieldContent,FieldDescription,FieldError,FieldGroup,FieldLabel,FieldLegend,FieldSeparator,FieldSet,FieldTitle,useFieldControlId,useFieldInvalid,useFieldLabelId};
|
|
2
2
|
//# sourceMappingURL=field.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"field.js","names":["FieldContext","createContext","context","useContext","id","props","cn","className","variant","fieldVariants","cva","controlId","useId","contextValue","useMemo","orientation","fieldControlId","htmlFor","Label","children","Separator","content","errors","uniqueErrors","error"],"sources":["../../src/components/field.tsx"],"sourcesContent":["import { createContext, useContext, useId, useMemo } from 'react'\n\nimport { cva, type VariantProps } from 'class-variance-authority'\n\nimport { cn } from '../lib/utils'\nimport { Label } from './label'\nimport { Separator } from './separator'\n\nexport type FieldSetProps = React.ComponentProps<'fieldset'>\n\nexport type FieldLegendProps = React.ComponentProps<'legend'> & { variant?: 'legend' | 'label' }\n\nexport type FieldGroupProps = React.ComponentProps<'div'>\n\nexport type FieldContentProps = React.ComponentProps<'div'>\n\nexport type FieldLabelProps = React.ComponentProps<typeof Label>\n\nexport type FieldTitleProps = React.ComponentProps<'div'>\n\nexport type FieldDescriptionProps = React.ComponentProps<'p'>\n\nexport type FieldSeparatorProps = React.ComponentProps<'div'> & {\n children?: React.ReactNode\n}\n\nexport type FieldErrorProps = React.ComponentProps<'div'> & {\n errors?: Array<{ message?: string } | undefined>\n}\n\ntype FieldContextValue = {\n controlId: string\n}\n\nconst FieldContext = createContext<FieldContextValue | null>(null)\n\nfunction useFieldControlId(id?: string) {\n const context = useContext(FieldContext)\n\n return id ?? context?.controlId\n}\n\nfunction FieldSet({ className, ...props }: FieldSetProps) {\n return (\n <fieldset\n data-slot=\"field-set\"\n className={cn(\n 'flex flex-col gap-4',\n 'has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3',\n className\n )}\n {...props}\n />\n )\n}\n\nfunction FieldLegend({ className, variant = 'legend', ...props }: FieldLegendProps) {\n return (\n <legend\n data-slot=\"field-legend\"\n data-variant={variant}\n className={cn('mb-1.5 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base', className)}\n {...props}\n />\n )\n}\n\nfunction FieldGroup({ className, ...props }: FieldGroupProps) {\n return (\n <div\n data-slot=\"field-group\"\n className={cn(\n 'group/field-group @container/field-group flex w-full flex-col gap-5',\n 'data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4',\n className\n )}\n {...props}\n />\n )\n}\n\nconst fieldVariants = cva('data-[invalid=true]:text-destructive gap-1 group/field flex w-full', {\n variants: {\n orientation: {\n vertical: 'flex-col *:w-full [&>.sr-only]:w-auto',\n horizontal:\n 'flex-row items-center *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px',\n responsive:\n 'flex-col *:w-full [&>.sr-only]:w-auto @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:*:data-[slot=field-label]:flex-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px'\n }\n },\n defaultVariants: {\n orientation: 'vertical'\n }\n})\n\nexport type FieldProps = React.ComponentProps<'div'> & VariantProps<typeof fieldVariants>\n\nfunction Field({ className, orientation = 'vertical', ...props }: FieldProps) {\n const controlId = useId()\n const contextValue = useMemo(() => ({ controlId }), [controlId])\n\n return (\n <FieldContext.Provider value={contextValue}>\n <div\n data-slot=\"field\"\n data-orientation={orientation}\n className={cn(fieldVariants({ orientation }), className)}\n {...props}\n />\n </FieldContext.Provider>\n )\n}\n\nfunction FieldContent({ className, ...props }: FieldContentProps) {\n return (\n <div\n data-slot=\"field-content\"\n className={cn('gap-0.5 group/field-content flex flex-1 flex-col leading-snug', className)}\n {...props}\n />\n )\n}\n\nfunction FieldLabel({ className, htmlFor, ...props }: FieldLabelProps) {\n const fieldControlId = useFieldControlId(htmlFor)\n\n return (\n <Label\n data-slot=\"field-label\"\n htmlFor={fieldControlId}\n className={cn(\n 'group/field-label peer/field-label flex w-fit gap-2 leading-snug',\n 'has-data-checked:bg-primary/5 has-data-checked:border-primary/30 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10',\n 'has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border *:data-[slot=field]:p-2.5',\n 'group-data-[disabled=true]/field:opacity-50',\n className\n )}\n {...props}\n />\n )\n}\n\nfunction FieldTitle({ className, ...props }: FieldTitleProps) {\n return (\n <div\n data-slot=\"field-label\"\n className={cn(\n 'gap-2 text-sm font-medium group-data-[disabled=true]/field:opacity-50 flex w-fit items-center leading-snug',\n className\n )}\n {...props}\n />\n )\n}\n\nfunction FieldDescription({ className, ...props }: FieldDescriptionProps) {\n return (\n <p\n data-slot=\"field-description\"\n className={cn(\n 'text-muted-foreground text-left text-xs leading-normal font-normal',\n '[[data-variant=legend]+&]:-mt-1.5 group-has-data-horizontal/field:text-balance last:mt-0 nth-last-2:-mt-1',\n '[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary',\n className\n )}\n {...props}\n />\n )\n}\n\nfunction FieldSeparator({ children, className, ...props }: FieldSeparatorProps) {\n return (\n <div\n data-slot=\"field-separator\"\n data-content={!!children}\n className={cn('-my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2 relative', className)}\n {...props}\n >\n <Separator className=\"absolute inset-0 top-1/2\" />\n {children && (\n <span\n className=\"text-muted-foreground px-2 bg-background relative mx-auto block w-fit\"\n data-slot=\"field-separator-content\"\n >\n {children}\n </span>\n )}\n </div>\n )\n}\n\nfunction FieldError({ className, children, errors, ...props }: FieldErrorProps) {\n const content = useMemo(() => {\n if (children) {\n return children\n }\n\n if (!errors?.length) {\n return null\n }\n\n const uniqueErrors = [...new Map(errors.map((error) => [error?.message, error])).values()]\n\n if (uniqueErrors?.length === 1) {\n return uniqueErrors[0]?.message\n }\n\n return (\n <ul className=\"ml-4 flex list-disc flex-col gap-1\">\n {uniqueErrors.map((error) => error?.message && <li key={error.message}>{error.message}</li>)}\n </ul>\n )\n }, [children, errors])\n\n if (!content) {\n return null\n }\n\n return (\n <div\n role=\"alert\"\n data-slot=\"field-error\"\n className={cn('text-destructive text-sm font-normal', className)}\n {...props}\n >\n {content}\n </div>\n )\n}\n\nexport {\n Field,\n FieldContent,\n FieldDescription,\n FieldError,\n FieldGroup,\n FieldLabel,\n FieldLegend,\n FieldSeparator,\n FieldSet,\n FieldTitle,\n useFieldControlId\n}\n"],"mappings":"0UAkCA,MAAMA,EAAeC,EAAwC,IAAI,EAEjE,SAAS,kBAAkB,EAAa,CACtC,IAAMC,EAAUC,EAAWH,CAAY,EAEvC,OAAOI,GAAMF,GAAS,SACxB,CAEA,SAAS,SAAS,CAAE,YAA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EAEH,SAAAgB,CACE,CAAA,EAXE,IAaX"}
|
|
1
|
+
{"version":3,"file":"field.js","names":["FieldContext","createContext","context","useContext","id","invalid","ariaInvalid","props","cn","className","variant","fieldVariants","cva","dataInvalid","controlId","useId","labelId","isInvalid","contextValue","useMemo","orientation","fieldControlId","htmlFor","fieldLabelId","Label","children","Separator","content","errors","uniqueErrors","error"],"sources":["../../src/components/field.tsx"],"sourcesContent":["import { createContext, useContext, useId, useMemo } from 'react'\n\nimport { cva, type VariantProps } from 'class-variance-authority'\n\nimport { cn } from '../lib/utils'\nimport { Label } from './label'\nimport { Separator } from './separator'\n\nexport type FieldSetProps = React.ComponentProps<'fieldset'>\n\nexport type FieldLegendProps = React.ComponentProps<'legend'> & {\n /**\n * `label` renders the legend at the size of a field label.\n * @default 'legend'\n */\n variant?: 'legend' | 'label'\n}\n\nexport type FieldGroupProps = React.ComponentProps<'div'>\n\nexport type FieldContentProps = React.ComponentProps<'div'>\n\nexport type FieldLabelProps = React.ComponentProps<typeof Label>\n\nexport type FieldTitleProps = React.ComponentProps<'div'>\n\nexport type FieldDescriptionProps = React.ComponentProps<'p'>\n\nexport type FieldSeparatorProps = React.ComponentProps<'div'> & {\n children?: React.ReactNode\n}\n\nexport type FieldErrorProps = React.ComponentProps<'div'> & {\n /** Errors to show. Each `message` is rendered; duplicates are removed. Ignored when `children` is passed. */\n errors?: Array<{ message?: string } | undefined>\n}\n\ntype FieldContextValue = {\n controlId: string\n labelId: string\n invalid: boolean\n}\n\nconst FieldContext = createContext<FieldContextValue | null>(null)\n\nfunction useFieldControlId(id?: string) {\n const context = useContext(FieldContext)\n\n return id ?? context?.controlId\n}\n\nfunction useFieldLabelId() {\n return useContext(FieldContext)?.labelId\n}\n\n// The control's own `aria-invalid` always wins (including `false`); otherwise an invalid `Field` marks it invalid.\nfunction useFieldInvalid(ariaInvalid?: React.AriaAttributes['aria-invalid']) {\n const invalid = useContext(FieldContext)?.invalid\n\n return ariaInvalid ?? (invalid ? true : undefined)\n}\n\nfunction FieldSet({ className, ...props }: FieldSetProps) {\n return (\n <fieldset\n data-slot=\"field-set\"\n className={cn(\n 'flex flex-col gap-4',\n 'has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3',\n className\n )}\n {...props}\n />\n )\n}\n\nfunction FieldLegend({ className, variant = 'legend', ...props }: FieldLegendProps) {\n return (\n <legend\n data-slot=\"field-legend\"\n data-variant={variant}\n className={cn('mb-1.5 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base', className)}\n {...props}\n />\n )\n}\n\nfunction FieldGroup({ className, ...props }: FieldGroupProps) {\n return (\n <div\n data-slot=\"field-group\"\n className={cn(\n 'group/field-group @container/field-group flex w-full flex-col gap-5',\n 'data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4',\n className\n )}\n {...props}\n />\n )\n}\n\nconst fieldVariants = cva('data-[invalid=true]:text-destructive gap-1 group/field flex w-full', {\n variants: {\n orientation: {\n vertical: 'flex-col *:w-full [&>.sr-only]:w-auto',\n horizontal:\n 'flex-row items-center *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:items-start has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px',\n responsive:\n 'flex-col *:w-full [&>.sr-only]:w-auto @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:*:data-[slot=field-label]:flex-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px'\n }\n },\n defaultVariants: {\n orientation: 'vertical'\n }\n})\n\nexport type FieldProps = React.ComponentProps<'div'> &\n VariantProps<typeof fieldVariants> & {\n /** Marks the field and the control inside it as invalid. */\n invalid?: boolean\n /** Same as `invalid`, for form libraries that set the attribute directly. */\n 'data-invalid'?: boolean | 'true' | 'false'\n }\n\nfunction Field({ className, orientation = 'vertical', invalid, 'data-invalid': dataInvalid, ...props }: FieldProps) {\n const controlId = useId()\n const labelId = useId()\n const isInvalid = invalid ?? (dataInvalid === true || dataInvalid === 'true')\n const contextValue = useMemo(() => ({ controlId, labelId, invalid: isInvalid }), [controlId, labelId, isInvalid])\n\n return (\n <FieldContext.Provider value={contextValue}>\n <div\n data-slot=\"field\"\n data-orientation={orientation}\n data-invalid={isInvalid ? 'true' : undefined}\n className={cn(fieldVariants({ orientation }), className)}\n {...props}\n />\n </FieldContext.Provider>\n )\n}\n\nfunction FieldContent({ className, ...props }: FieldContentProps) {\n return (\n <div\n data-slot=\"field-content\"\n className={cn('gap-0.5 group/field-content flex flex-1 flex-col leading-snug', className)}\n {...props}\n />\n )\n}\n\nfunction FieldLabel({ className, htmlFor, id, ...props }: FieldLabelProps) {\n const fieldControlId = useFieldControlId(htmlFor)\n const fieldLabelId = useFieldLabelId()\n\n return (\n <Label\n data-slot=\"field-label\"\n id={id ?? fieldLabelId}\n htmlFor={fieldControlId}\n className={cn(\n 'group/field-label peer/field-label flex w-fit gap-2 leading-snug',\n 'has-data-checked:bg-primary/5 has-data-checked:border-primary/30 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10',\n 'has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border *:data-[slot=field]:p-2.5',\n 'group-data-[disabled=true]/field:opacity-50',\n className\n )}\n {...props}\n />\n )\n}\n\nfunction FieldTitle({ className, ...props }: FieldTitleProps) {\n return (\n <div\n data-slot=\"field-label\"\n className={cn(\n 'gap-2 text-sm font-medium group-data-[disabled=true]/field:opacity-50 flex w-fit items-center leading-snug',\n className\n )}\n {...props}\n />\n )\n}\n\nfunction FieldDescription({ className, ...props }: FieldDescriptionProps) {\n return (\n <p\n data-slot=\"field-description\"\n className={cn(\n 'text-muted-foreground text-left text-xs leading-normal font-normal',\n '[[data-variant=legend]+&]:-mt-1.5 group-has-data-horizontal/field:text-balance last:mt-0 nth-last-2:-mt-1',\n '[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary',\n className\n )}\n {...props}\n />\n )\n}\n\nfunction FieldSeparator({ children, className, ...props }: FieldSeparatorProps) {\n return (\n <div\n data-slot=\"field-separator\"\n data-content={!!children}\n className={cn('-my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2 relative', className)}\n {...props}\n >\n <Separator className=\"absolute inset-0 top-1/2\" />\n {children && (\n <span\n className=\"text-muted-foreground px-2 bg-background relative mx-auto block w-fit\"\n data-slot=\"field-separator-content\"\n >\n {children}\n </span>\n )}\n </div>\n )\n}\n\nfunction FieldError({ className, children, errors, ...props }: FieldErrorProps) {\n const content = useMemo(() => {\n if (children) {\n return children\n }\n\n if (!errors?.length) {\n return null\n }\n\n const uniqueErrors = [...new Map(errors.map((error) => [error?.message, error])).values()]\n\n if (uniqueErrors?.length === 1) {\n return uniqueErrors[0]?.message\n }\n\n return (\n <ul className=\"ml-4 flex list-disc flex-col gap-1\">\n {uniqueErrors.map((error) => error?.message && <li key={error.message}>{error.message}</li>)}\n </ul>\n )\n }, [children, errors])\n\n if (!content) {\n return null\n }\n\n return (\n <div\n role=\"alert\"\n data-slot=\"field-error\"\n className={cn('text-destructive text-sm font-normal', className)}\n {...props}\n >\n {content}\n </div>\n )\n}\n\nexport {\n Field,\n FieldContent,\n FieldDescription,\n FieldError,\n FieldGroup,\n FieldLabel,\n FieldLegend,\n FieldSeparator,\n FieldSet,\n FieldTitle,\n useFieldControlId,\n useFieldInvalid,\n useFieldLabelId\n}\n"],"mappings":"0UA2CA,MAAMA,EAAeC,EAAwC,IAAI,EAEjE,SAAS,kBAAkB,EAAa,CACtC,IAAMC,EAAUC,EAAWH,CAAY,EAEvC,OAAOI,GAAMF,GAAS,SACxB,CAEA,SAAS,iBAAkB,CACzB,OAAOC,EAAWH,CAAY,CAAC,EAAE,OACnC,CAGA,SAAS,gBAAgB,EAAoD,CAC3E,IAAMK,EAAUF,EAAWH,CAAY,CAAC,EAAE,QAE1C,OAAOM,IAAgBD,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,SAAAA,EAAa,IAAK,GAAUC,GAAO,SAAW,kBAAC,KAAD,CAAA,SAAyBA,EAAM,OAAY,EAAlCA,EAAM,OAA4B,CAAC,CACzF,CAAA,CAER,EAAG,CAACL,EAAUG,CAAM,CAAC,EAMrB,OAJKD,EAKH,kBAAC,MAAD,CACE,KAAK,QACL,YAAU,cACV,UAAWnB,EAAG,uCAAwCC,CAAS,EAC/D,GAAIF,EAEH,SAAAoB,CACE,CAAA,EAXE,IAaX"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as __name } from "../rolldown-runtime-BhWHdk3m.js";
|
|
2
|
-
import { VariantProps } from "class-variance-authority";
|
|
3
2
|
import * as React from "react";
|
|
3
|
+
import { VariantProps } from "class-variance-authority";
|
|
4
4
|
//#region src/components/flex.d.ts
|
|
5
5
|
declare const flexVariants: (props?: ({
|
|
6
6
|
direction?: "column" | "column-reverse" | "row" | "row-reverse" | null | undefined;
|
|
@@ -3,15 +3,28 @@ import * as React from "react";
|
|
|
3
3
|
//#region src/components/grid.d.ts
|
|
4
4
|
type GridSpacing = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
5
5
|
export type GridProps = React.ComponentProps<'div'> & {
|
|
6
|
+
/** Space between rows and columns. */
|
|
6
7
|
gap?: GridSpacing;
|
|
8
|
+
/** Space between rows. Overrides `gap`. */
|
|
7
9
|
rowGap?: GridSpacing;
|
|
10
|
+
/** Space between columns. Overrides `gap`. */
|
|
8
11
|
columnGap?: GridSpacing;
|
|
12
|
+
/** CSS `grid-template-rows` value. */
|
|
9
13
|
templateRows?: string;
|
|
14
|
+
/**
|
|
15
|
+
* CSS `grid-template-columns` value.
|
|
16
|
+
* @default 'repeat(12, minmax(0, 1fr))'
|
|
17
|
+
*/
|
|
10
18
|
templateColumns?: string;
|
|
11
19
|
};
|
|
12
20
|
declare function Grid({ className, gap, rowGap, columnGap, templateRows, templateColumns, style, ...props }: GridProps): React.JSX.Element;
|
|
13
21
|
export type GridItemProps = React.ComponentProps<'div'> & {
|
|
22
|
+
/** Number of rows the item spans. */
|
|
14
23
|
rowSpan?: number;
|
|
24
|
+
/**
|
|
25
|
+
* Number of columns the item spans.
|
|
26
|
+
* @default 12
|
|
27
|
+
*/
|
|
15
28
|
colSpan?: number;
|
|
16
29
|
};
|
|
17
30
|
declare function GridItem({ className, rowSpan, colSpan, style, ...props }: GridItemProps): React.JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grid.js","names":["spacingScale","spacing","props","cn","className","templateColumns","templateRows","gap","rowGap","columnGap","style","colSpan","rowSpan"],"sources":["../../src/components/grid.tsx"],"sourcesContent":["import type * as React from 'react'\n\nimport { cn } from '../lib/utils'\n\ntype GridSpacing = 'xs' | 'sm' | 'md' | 'lg' | 'xl'\n\nconst spacingScale: Record<GridSpacing, number> = {\n xs: 1,\n sm: 2,\n md: 4,\n lg: 6,\n xl: 8\n}\n\nfunction toSpacingValue(spacing: GridSpacing) {\n return `calc(var(--spacing) * ${spacingScale[spacing]})`\n}\n\nexport type GridProps = React.ComponentProps<'div'> & {\n gap?: GridSpacing\n rowGap?: GridSpacing\n columnGap?: GridSpacing\n templateRows?: string\n templateColumns?: string\n}\n\nfunction Grid({\n className,\n gap,\n rowGap,\n columnGap,\n templateRows,\n templateColumns = 'repeat(12, minmax(0, 1fr))',\n style,\n ...props\n}: GridProps) {\n return (\n <div\n data-slot=\"grid\"\n className={cn(\n 'grid min-w-0',\n 'grid-cols-(--grid-template-columns) grid-rows-(--grid-template-rows)',\n 'gap-(--grid-gap) gap-y-(--grid-row-gap) gap-x-(--grid-column-gap)',\n className\n )}\n style={\n {\n '--grid-template-columns': templateColumns,\n '--grid-template-rows': templateRows,\n '--grid-gap': gap ? toSpacingValue(gap) : '0px',\n '--grid-row-gap': rowGap ? toSpacingValue(rowGap) : 'var(--grid-gap)',\n '--grid-column-gap': columnGap ? toSpacingValue(columnGap) : 'var(--grid-gap)',\n ...style\n } as React.CSSProperties\n }\n {...props}\n />\n )\n}\n\nexport type GridItemProps = React.ComponentProps<'div'> & {\n rowSpan?: number\n colSpan?: number\n}\n\nfunction GridItem({ className, rowSpan, colSpan = 12, style, ...props }: GridItemProps) {\n return (\n <div\n data-slot=\"grid-item\"\n className={cn(\n 'min-w-0',\n 'col-[span_var(--grid-item-col-span)/span_var(--grid-item-col-span)]',\n 'row-[span_var(--grid-item-row-span)/span_var(--grid-item-row-span)]',\n className\n )}\n style={\n {\n '--grid-item-col-span': colSpan,\n '--grid-item-row-span': rowSpan,\n ...style\n } as React.CSSProperties\n }\n {...props}\n />\n )\n}\n\nexport { Grid, GridItem }\n"],"mappings":"qHAMA,MAAMA,EAA4C,CAChD,GAAI,EACJ,GAAI,EACJ,GAAI,EACJ,GAAI,EACJ,GAAI,CACN,EAEA,SAAS,eAAe,EAAsB,CAC5C,MAAO,yBAAyBA,EAAaC,GAAS,EACxD,
|
|
1
|
+
{"version":3,"file":"grid.js","names":["spacingScale","spacing","props","cn","className","templateColumns","templateRows","gap","rowGap","columnGap","style","colSpan","rowSpan"],"sources":["../../src/components/grid.tsx"],"sourcesContent":["import type * as React from 'react'\n\nimport { cn } from '../lib/utils'\n\ntype GridSpacing = 'xs' | 'sm' | 'md' | 'lg' | 'xl'\n\nconst spacingScale: Record<GridSpacing, number> = {\n xs: 1,\n sm: 2,\n md: 4,\n lg: 6,\n xl: 8\n}\n\nfunction toSpacingValue(spacing: GridSpacing) {\n return `calc(var(--spacing) * ${spacingScale[spacing]})`\n}\n\nexport type GridProps = React.ComponentProps<'div'> & {\n /** Space between rows and columns. */\n gap?: GridSpacing\n /** Space between rows. Overrides `gap`. */\n rowGap?: GridSpacing\n /** Space between columns. Overrides `gap`. */\n columnGap?: GridSpacing\n /** CSS `grid-template-rows` value. */\n templateRows?: string\n /**\n * CSS `grid-template-columns` value.\n * @default 'repeat(12, minmax(0, 1fr))'\n */\n templateColumns?: string\n}\n\nfunction Grid({\n className,\n gap,\n rowGap,\n columnGap,\n templateRows,\n templateColumns = 'repeat(12, minmax(0, 1fr))',\n style,\n ...props\n}: GridProps) {\n return (\n <div\n data-slot=\"grid\"\n className={cn(\n 'grid min-w-0',\n 'grid-cols-(--grid-template-columns) grid-rows-(--grid-template-rows)',\n 'gap-(--grid-gap) gap-y-(--grid-row-gap) gap-x-(--grid-column-gap)',\n className\n )}\n style={\n {\n '--grid-template-columns': templateColumns,\n '--grid-template-rows': templateRows,\n '--grid-gap': gap ? toSpacingValue(gap) : '0px',\n '--grid-row-gap': rowGap ? toSpacingValue(rowGap) : 'var(--grid-gap)',\n '--grid-column-gap': columnGap ? toSpacingValue(columnGap) : 'var(--grid-gap)',\n ...style\n } as React.CSSProperties\n }\n {...props}\n />\n )\n}\n\nexport type GridItemProps = React.ComponentProps<'div'> & {\n /** Number of rows the item spans. */\n rowSpan?: number\n /**\n * Number of columns the item spans.\n * @default 12\n */\n colSpan?: number\n}\n\nfunction GridItem({ className, rowSpan, colSpan = 12, style, ...props }: GridItemProps) {\n return (\n <div\n data-slot=\"grid-item\"\n className={cn(\n 'min-w-0',\n 'col-[span_var(--grid-item-col-span)/span_var(--grid-item-col-span)]',\n 'row-[span_var(--grid-item-row-span)/span_var(--grid-item-row-span)]',\n className\n )}\n style={\n {\n '--grid-item-col-span': colSpan,\n '--grid-item-row-span': rowSpan,\n ...style\n } as React.CSSProperties\n }\n {...props}\n />\n )\n}\n\nexport { Grid, GridItem }\n"],"mappings":"qHAMA,MAAMA,EAA4C,CAChD,GAAI,EACJ,GAAI,EACJ,GAAI,EACJ,GAAI,EACJ,GAAI,CACN,EAEA,SAAS,eAAe,EAAsB,CAC5C,MAAO,yBAAyBA,EAAaC,GAAS,EACxD,CAkBA,SAAS,KAAK,CACZ,YACA,MACA,SACA,YACA,eACA,kBAAkB,6BAClB,QACA,GAAGC,GACS,CACZ,MACE,kBAAC,MAAD,CACE,YAAU,OACV,UAAWC,EACT,eACA,uEACA,oEACAC,CACF,EACA,MACE,CACE,0BAA2BC,EAC3B,uBAAwBC,EACxB,aAAcC,EAAM,eAAeA,CAAG,EAAI,MAC1C,iBAAkBC,EAAS,eAAeA,CAAM,EAAI,kBACpD,oBAAqBC,EAAY,eAAeA,CAAS,EAAI,kBAC7D,GAAGC,CACL,EAEF,GAAIR,CACL,CAAA,CAEL,CAYA,SAAS,SAAS,CAAE,YAAW,UAAS,UAAU,GAAI,QAAO,GAAGA,GAAwB,CACtF,MACE,kBAAC,MAAD,CACE,YAAU,YACV,UAAWC,EACT,UACA,sEACA,sEACAC,CACF,EACA,MACE,CACE,uBAAwBO,EACxB,uBAAwBC,EACxB,GAAGF,CACL,EAEF,GAAIR,CACL,CAAA,CAEL"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as __name } from "../rolldown-runtime-BhWHdk3m.js";
|
|
2
|
-
import { VariantProps } from "class-variance-authority";
|
|
3
2
|
import * as React from "react";
|
|
3
|
+
import { VariantProps } from "class-variance-authority";
|
|
4
4
|
//#region src/components/group.d.ts
|
|
5
5
|
declare const groupVariants: (props?: ({
|
|
6
6
|
align?: "baseline" | "center" | "end" | "start" | "stretch" | null | undefined;
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { t as __name } from "../rolldown-runtime-BhWHdk3m.js";
|
|
2
|
+
import { n as AsChildProps } from "../as-child-Dxg3Xo1G.js";
|
|
2
3
|
import { VariantProps } from "class-variance-authority";
|
|
3
|
-
import * as React from "react";
|
|
4
4
|
//#region src/components/heading.d.ts
|
|
5
5
|
declare const headingVariants: (props?: ({
|
|
6
6
|
size?: "lg" | "md" | "sm" | "xl" | "xs" | null | undefined;
|
|
7
7
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
8
|
-
export type HeadingProps =
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
declare function Heading({ className, size, asChild, ...props }: HeadingProps): React.JSX.Element;
|
|
8
|
+
export type HeadingProps = AsChildProps<'h2'> & VariantProps<typeof headingVariants>;
|
|
9
|
+
declare function Heading({ className, size, ...props }: HeadingProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
12
10
|
//#endregion
|
|
13
11
|
export { Heading, headingVariants };
|
|
14
12
|
//# sourceMappingURL=heading.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../rolldown-runtime-BhWHdk3m.js";import{
|
|
1
|
+
import"../rolldown-runtime-BhWHdk3m.js";import{useAsChild as e}from"../lib/as-child.js";import{cn as t}from"../lib/utils.js";import{cva as n}from"class-variance-authority";const r=n(`text-foreground font-semibold tracking-tight`,{variants:{size:{xs:`text-lg`,sm:`text-xl`,md:`text-2xl`,lg:`text-3xl`,xl:`text-4xl`}},defaultVariants:{size:`md`}});function Heading({className:n,size:i=`md`,...a}){return e(`h2`,{"data-slot":`heading`,"data-size":i,className:t(r({size:i}),n),...a})}export{Heading,r as headingVariants};
|
|
2
2
|
//# sourceMappingURL=heading.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heading.js","names":["headingVariants","cva","props","
|
|
1
|
+
{"version":3,"file":"heading.js","names":["headingVariants","cva","props","useAsChild","size","cn","className"],"sources":["../../src/components/heading.tsx"],"sourcesContent":["import { cva, type VariantProps } from 'class-variance-authority'\n\nimport { type AsChildProps, useAsChild } from '../lib/as-child'\nimport { cn } from '../lib/utils'\n\nconst headingVariants = cva('text-foreground font-semibold tracking-tight', {\n variants: {\n size: {\n xs: 'text-lg',\n sm: 'text-xl',\n md: 'text-2xl',\n lg: 'text-3xl',\n xl: 'text-4xl'\n }\n },\n defaultVariants: {\n size: 'md'\n }\n})\n\nexport type HeadingProps = AsChildProps<'h2'> & VariantProps<typeof headingVariants>\n\nfunction Heading({ className, size = 'md', ...props }: HeadingProps) {\n return useAsChild('h2', {\n 'data-slot': 'heading',\n 'data-size': size,\n className: cn(headingVariants({ size }), className),\n ...props\n })\n}\n\nexport { Heading, headingVariants }\n"],"mappings":"4KAKA,MAAMA,EAAkBC,EAAI,+CAAgD,CAC1E,SAAU,CACR,KAAM,CACJ,GAAI,UACJ,GAAI,UACJ,GAAI,WACJ,GAAI,WACJ,GAAI,UACN,CACF,EACA,gBAAiB,CACf,KAAM,IACR,CACF,CAAC,EAID,SAAS,QAAQ,CAAE,YAAW,OAAO,KAAM,GAAGC,GAAuB,CACnE,OAAOC,EAAW,KAAM,CACtB,YAAa,UACb,YAAaC,EACb,UAAWC,EAAGL,EAAgB,CAAE,MAAK,CAAC,EAAGM,CAAS,EAClD,GAAGJ,CACL,CAAC,CACH"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { t as __name } from "../rolldown-runtime-BhWHdk3m.js";
|
|
2
|
-
import {
|
|
2
|
+
import { t as AsChildPrimitiveProps } from "../as-child-Dxg3Xo1G.js";
|
|
3
3
|
import * as React from "react";
|
|
4
|
+
import { PreviewCard } from "@base-ui/react/preview-card";
|
|
4
5
|
//#region src/components/hover-card.d.ts
|
|
5
|
-
export type HoverCardProps = React.ComponentProps<typeof
|
|
6
|
-
export type HoverCardTriggerProps =
|
|
7
|
-
export type HoverCardContentProps = React.ComponentProps<typeof
|
|
6
|
+
export type HoverCardProps = React.ComponentProps<typeof PreviewCard.Root>;
|
|
7
|
+
export type HoverCardTriggerProps = AsChildPrimitiveProps<typeof PreviewCard.Trigger>;
|
|
8
|
+
export type HoverCardContentProps = AsChildPrimitiveProps<typeof PreviewCard.Popup> & Pick<React.ComponentProps<typeof PreviewCard.Positioner>, 'side' | 'sideOffset' | 'align' | 'alignOffset' | 'sticky'> & Pick<React.ComponentProps<typeof PreviewCard.Portal>, 'keepMounted'>;
|
|
8
9
|
declare function HoverCard({ ...props }: HoverCardProps): React.JSX.Element;
|
|
9
|
-
declare function HoverCardTrigger({ ...props }: HoverCardTriggerProps): React.JSX.Element;
|
|
10
|
-
declare function HoverCardContent({ className,
|
|
10
|
+
declare function HoverCardTrigger({ asChild, children, delay, closeDelay, ...props }: HoverCardTriggerProps): React.JSX.Element;
|
|
11
|
+
declare function HoverCardContent({ className, side, sideOffset, align, alignOffset, sticky, keepMounted, asChild, children, ...props }: HoverCardContentProps): React.JSX.Element;
|
|
11
12
|
//#endregion
|
|
12
13
|
export { HoverCard, HoverCardContent, HoverCardTrigger };
|
|
13
14
|
//# sourceMappingURL=hover-card.d.ts.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../rolldown-runtime-BhWHdk3m.js";import{
|
|
1
|
+
import"../rolldown-runtime-BhWHdk3m.js";import{toAsChildRenderProps as e}from"../lib/as-child.js";import{cn as t}from"../lib/utils.js";import{t as n}from"../resolve-class-name-BurP8ngI.js";import{jsx as r}from"react/jsx-runtime";import{PreviewCard as i}from"@base-ui/react/preview-card";function HoverCard({...e}){return/* @__PURE__ */ r(i.Root,{"data-slot":`hover-card`,...e})}function HoverCardTrigger({asChild:t,children:n,delay:a=700,closeDelay:o=300,...s}){return/* @__PURE__ */ r(i.Trigger,{"data-slot":`hover-card-trigger`,delay:a,closeDelay:o,...s,...e(t,n)})}function HoverCardContent({className:a,side:o=`bottom`,sideOffset:s=4,align:c=`center`,alignOffset:l=0,sticky:u,keepMounted:d,asChild:f,children:p,...m}){return/* @__PURE__ */ r(i.Portal,{"data-slot":`hover-card-portal`,keepMounted:d,children:/* @__PURE__ */ r(i.Positioner,{side:o,sideOffset:s,align:c,alignOffset:l,sticky:u,className:`isolate z-50`,children:/* @__PURE__ */ r(i.Popup,{"data-slot":`hover-card-content`,className:e=>t(`z-50 w-64 origin-(--transform-origin) rounded-lg bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,n(a,e)),...m,...e(f,p)})})})}export{HoverCard,HoverCardContent,HoverCardTrigger};
|
|
2
2
|
//# sourceMappingURL=hover-card.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hover-card.js","names":["HoverCardPrimitive","
|
|
1
|
+
{"version":3,"file":"hover-card.js","names":["HoverCardPrimitive","resolveClassName","props","PreviewCard","toAsChildRenderProps","asChild","children","cn","className","state"],"sources":["../../src/components/hover-card.tsx"],"sourcesContent":["import type * as React from 'react'\n\nimport { PreviewCard as HoverCardPrimitive } from '@base-ui/react/preview-card'\n\nimport { type AsChildPrimitiveProps, toAsChildRenderProps } from '../lib/as-child'\nimport { cn } from '../lib/utils'\nimport { resolveClassName } from '../utils/resolve-class-name'\n\nexport type HoverCardProps = React.ComponentProps<typeof HoverCardPrimitive.Root>\n\nexport type HoverCardTriggerProps = AsChildPrimitiveProps<typeof HoverCardPrimitive.Trigger>\n\nexport type HoverCardContentProps = AsChildPrimitiveProps<typeof HoverCardPrimitive.Popup> &\n Pick<\n React.ComponentProps<typeof HoverCardPrimitive.Positioner>,\n 'side' | 'sideOffset' | 'align' | 'alignOffset' | 'sticky'\n > &\n Pick<React.ComponentProps<typeof HoverCardPrimitive.Portal>, 'keepMounted'>\n\nfunction HoverCard({ ...props }: HoverCardProps) {\n return <HoverCardPrimitive.Root data-slot=\"hover-card\" {...props} />\n}\n\nfunction HoverCardTrigger({ asChild, children, delay = 700, closeDelay = 300, ...props }: HoverCardTriggerProps) {\n return (\n <HoverCardPrimitive.Trigger\n data-slot=\"hover-card-trigger\"\n delay={delay}\n closeDelay={closeDelay}\n {...props}\n {...toAsChildRenderProps(asChild, children)}\n />\n )\n}\n\nfunction HoverCardContent({\n className,\n side = 'bottom',\n sideOffset = 4,\n align = 'center',\n alignOffset = 0,\n sticky,\n keepMounted,\n asChild,\n children,\n ...props\n}: HoverCardContentProps) {\n return (\n <HoverCardPrimitive.Portal data-slot=\"hover-card-portal\" keepMounted={keepMounted}>\n <HoverCardPrimitive.Positioner\n side={side}\n sideOffset={sideOffset}\n align={align}\n alignOffset={alignOffset}\n sticky={sticky}\n className=\"isolate z-50\"\n >\n <HoverCardPrimitive.Popup\n data-slot=\"hover-card-content\"\n className={(state) =>\n cn(\n 'z-50 w-64 origin-(--transform-origin) rounded-lg bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95',\n resolveClassName(className, state)\n )\n }\n {...props}\n {...toAsChildRenderProps(asChild, children)}\n />\n </HoverCardPrimitive.Positioner>\n </HoverCardPrimitive.Portal>\n )\n}\n\nexport { HoverCard, HoverCardContent, HoverCardTrigger }\n"],"mappings":"+RAmBA,SAAS,UAAU,CAAE,GAAGE,GAAyB,CAC/C,MAAO,kBAACF,EAAmB,KAApB,CAAyB,YAAU,aAAa,GAAIE,CAAQ,CAAA,CACrE,CAEA,SAAS,iBAAiB,CAAE,UAAS,WAAU,QAAQ,IAAK,aAAa,IAAK,GAAGA,GAAgC,CAC/G,MACE,kBAACF,EAAmB,QAApB,CACE,YAAU,qBACH,QACK,aACZ,GAAIE,EACJ,GAAIE,EAAqBC,EAASC,CAAQ,CAC3C,CAAA,CAEL,CAEA,SAAS,iBAAiB,CACxB,YACA,OAAO,SACP,aAAa,EACb,QAAQ,SACR,cAAc,EACd,SACA,cACA,UACA,WACA,GAAGJ,GACqB,CACxB,MACE,kBAACF,EAAmB,OAApB,CAA2B,YAAU,oBAAiC,cACpE,SAAA,kBAACA,EAAmB,WAApB,CACQ,OACM,aACL,QACM,cACL,SACR,UAAU,eAEV,SAAA,kBAACA,EAAmB,MAApB,CACE,YAAU,qBACV,UAAY,GACVO,EACE,qcACAN,EAAiBO,EAAWC,CAAK,CACnC,EAEF,GAAIP,EACJ,GAAIE,EAAqBC,EAASC,CAAQ,CAC3C,CAAA,CAC4B,CAAA,CACN,CAAA,CAE/B"}
|