Skip to content

Commit

Permalink
fix: updated zag file upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Pagebakers committed Mar 11, 2024
1 parent 4bfb5a3 commit 8279132
Show file tree
Hide file tree
Showing 7 changed files with 679 additions and 665 deletions.
5 changes: 5 additions & 0 deletions .changeset/late-feet-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@saas-ui/file-upload': patch
---

Updated zag.js
2 changes: 1 addition & 1 deletion apps/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@ark-ui/react": "^1.3.0",
"@ark-ui/react": "^2.2.3",
"@chakra-ui/icons": "^2.1.1",
"@chakra-ui/next-js": "^2.2.0",
"@chakra-ui/props-docs": "^2.2.1",
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@
"react": "18.2.0",
"@emotion/react": "11.11.1",
"@emotion/styled": "11.11.0",
"@zag-js/store": "^0.30.0"
"@zag-js/core": "^0.38.1",
"@zag-js/store": "^0.38.1",
"@zag-js/file-upload": "^0.38.1"
},
"packageManager": "yarn@4.1.0"
}
4 changes: 2 additions & 2 deletions packages/saas-ui-file-upload/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
"@chakra-ui/styled-system": "^2.9.2",
"@chakra-ui/theme-tools": "^2.1.2",
"@chakra-ui/utils": "^2.0.15",
"@zag-js/file-upload": "^0.38.0",
"@zag-js/react": "^0.38.0"
"@zag-js/file-upload": "^0.38.1",
"@zag-js/react": "^0.38.1"
},
"peerDependencies": {
"@chakra-ui/react": ">=2.4.6",
Expand Down
22 changes: 11 additions & 11 deletions packages/saas-ui-file-upload/src/file-upload-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ export type FileUploadRenderContext = Pick<
export const useFileUpload = (props: FileUploadOptions) => {
const { isDisabled, ...rest } = props

const [state, send] = useMachine(
fileUpload.machine({
id: useId(),
disabled: isDisabled,
...rest,
})
)
const initialContext: fileUpload.Context = {
id: useId(),
disabled: isDisabled,
...rest,
}

const [state, send] = useMachine(fileUpload.machine(initialContext), {
context: {
...initialContext,
},
})

const api = fileUpload.connect(state, send, normalizeProps)
// @todo temporary workaround
api.clearFiles = () => {
api.files?.forEach((file) => api.deleteFile(file))
}

api.dropzoneProps = omit(api.dropzoneProps, ['onClick'])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const OnFileAccept = {
return (
<FileUpload
maxFileSize={1024}
maxFiles={10}
maxFiles={1}
accept="image/*"
onFileAccept={(details) => {
console.log('accept', details)
Expand Down
Loading

0 comments on commit 8279132

Please sign in to comment.