Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(input-file-upload): add droppable and indicator support #574

Merged
merged 4 commits into from
Jan 28, 2025

Conversation

kiaking
Copy link
Member

@kiaking kiaking commented Jan 27, 2025

Add droppable file selection and individual item state support to <SinputFileUpload>.

In order to keep the backward compatibility, the model value accepts both File[] and the new FileObject[], and must define :model-type="object" when using FileObject[] as model value.

<script setup lang="ts>
const { data } = useData({
  files: [
    { file: File, indicatorType: 'running', canRemove: false }
  ]
})

const rules = {
  maxFileSize: maxFileSize('1mb')
}
</script>

<template>
  <SInputFIleUpload
    model-type="object"
    :v-model="data.files"
    :rules="rules"
  />
</template>

Screenshot 2025-01-27 at 16 46 00

@kiaking kiaking self-assigned this Jan 27, 2025
@kiaking kiaking requested a review from brc-dd as a code owner January 27, 2025 07:57
Copy link

netlify bot commented Jan 27, 2025

Deploy Preview for sefirot-docs ready!

Name Link
🔨 Latest commit f093d19
🔍 Latest deploy log https://app.netlify.com/sites/sefirot-docs/deploys/679831b1bebcf30008dcb10a
😎 Deploy Preview https://deploy-preview-574--sefirot-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@kiaking
Copy link
Member Author

kiaking commented Jan 27, 2025

@brc-dd
Could you take a look on types especially. It is working but I'm using generics here and maybe there are room for improvements. I don't know 🤔

Copy link

netlify bot commented Jan 27, 2025

Deploy Preview for sefirot-story ready!

Name Link
🔨 Latest commit f093d19
🔍 Latest deploy log https://app.netlify.com/sites/sefirot-story/deploys/679831b037a5760008f49094
😎 Deploy Preview https://deploy-preview-574--sefirot-story.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@brc-dd
Copy link
Member

brc-dd commented Jan 27, 2025

appears weird in some cases (repro: update a prop after a file is selected, might be histoire only):

image

@kiaking
Copy link
Member Author

kiaking commented Jan 27, 2025

@brc-dd
Yeah it happens on HMR, but can't reproduce on normal data modification. How did you do it? Does it happen outside HMR? Like adding a button to push/remove items or update indicator states works 👀

// These works.
function addItem() {
  data.value.files.push({
    file: new File([''], `000iii111jjjjjjj.txt`, { type: 'text/plain' }),
    indicatorState: 'completed',
    canRemove: true
  })
}

function update(){
  data.value.files[1].indicatorState = null
}

@brc-dd
Copy link
Member

brc-dd commented Jan 27, 2025

Screen.Recording.2025-01-27.at.2.01.59.PM.mov

@kiaking
Copy link
Member Author

kiaking commented Jan 27, 2025

Ahhhh

@kiaking
Copy link
Member Author

kiaking commented Jan 27, 2025

Yeah this must be Histoire issue... When ever updating props, the file object becomes empty object for some reason 🤔 No idea why it happens.

// before
[File [object, object]]

// when any props gets updated
[{}]

@brc-dd
Copy link
Member

brc-dd commented Jan 27, 2025

yeah

brc-dd
brc-dd previously approved these changes Jan 27, 2025
@kiaking kiaking merged commit 026e358 into main Jan 28, 2025
9 checks passed
@kiaking kiaking deleted the input-file-upload-droppable-and-indicator branch January 28, 2025 01:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants