@skopon-cool/form-sdk 0.5.2 → 0.6.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.
Files changed (35) hide show
  1. package/README.md +34 -3
  2. package/dist/adapter/a2uiAdapter.d.ts.map +1 -1
  3. package/dist/adapter/formSchema.d.ts.map +1 -1
  4. package/dist/catalog/a2uiCustomCatalog.d.ts.map +1 -1
  5. package/dist/catalog/fileUploadStatusContext.d.ts +12 -0
  6. package/dist/catalog/fileUploadStatusContext.d.ts.map +1 -0
  7. package/dist/client/authStorage.d.ts +9 -0
  8. package/dist/client/authStorage.d.ts.map +1 -1
  9. package/dist/client/uploadClient.d.ts +17 -0
  10. package/dist/client/uploadClient.d.ts.map +1 -0
  11. package/dist/components/AskUserFormCard.d.ts.map +1 -1
  12. package/dist/components/SkoponA2uiStreamRenderer.d.ts.map +1 -1
  13. package/dist/components/SkoponFormRenderer.d.ts +2 -0
  14. package/dist/components/SkoponFormRenderer.d.ts.map +1 -1
  15. package/dist/index.d.ts +1 -1
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +1565 -1376
  18. package/package.json +1 -1
  19. package/src/adapter/a2uiAdapter.test.ts +19 -0
  20. package/src/adapter/a2uiAdapter.ts +1 -0
  21. package/src/adapter/formSchema.test.ts +34 -0
  22. package/src/adapter/formSchema.ts +12 -9
  23. package/src/catalog/a2uiCustomCatalog.tsx +187 -35
  24. package/src/catalog/fileUploadPreview.test.tsx +177 -0
  25. package/src/catalog/fileUploadStatusContext.tsx +64 -0
  26. package/src/client/authStorage.test.ts +67 -1
  27. package/src/client/authStorage.ts +67 -0
  28. package/src/client/uploadClient.test.ts +143 -0
  29. package/src/client/uploadClient.ts +72 -0
  30. package/src/components/AskUserFormCard.tsx +8 -1
  31. package/src/components/AskUserFormCard.upload.test.tsx +91 -0
  32. package/src/components/SkoponA2uiStreamRenderer.tsx +14 -11
  33. package/src/components/SkoponFormRenderer.tsx +24 -16
  34. package/src/index.ts +3 -0
  35. package/src/submit/submit.test.ts +25 -0
@@ -822,4 +822,29 @@ describe('validateFormSubmitValues', () => {
822
822
  '请填写「简历」',
823
823
  )
824
824
  })
825
+
826
+ it('enforces file minCount at submit time', () => {
827
+ const blocks = [
828
+ {
829
+ id: 'file-1',
830
+ type: 'file' as const,
831
+ name: 'attachments',
832
+ label: '附件',
833
+ fileMinCount: 2,
834
+ },
835
+ ]
836
+ expect(validateFormSubmitValues(blocks, { attachments: [] })).toBeNull()
837
+ expect(
838
+ validateFormSubmitValues(blocks, { attachments: ['https://cdn.example.com/a.pdf'] })
839
+ ?.message,
840
+ ).toBe('「附件」至少需要 2 个文件')
841
+ expect(
842
+ validateFormSubmitValues(blocks, {
843
+ attachments: [
844
+ 'https://cdn.example.com/a.pdf',
845
+ 'https://cdn.example.com/b.pdf',
846
+ ],
847
+ }),
848
+ ).toBeNull()
849
+ })
825
850
  })