@toptal/picasso-lab 9.3.0 → 9.3.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/CHANGELOG.md +1385 -0
- package/{Calendar → dist-package/Calendar}/Calendar.d.ts +0 -0
- package/{Calendar → dist-package/Calendar}/Calendar.js +0 -0
- package/{Calendar → dist-package/Calendar}/Calendar.js.map +0 -0
- package/{Calendar → dist-package/Calendar}/index.d.ts +0 -0
- package/{Calendar → dist-package/Calendar}/index.js +0 -0
- package/{Calendar → dist-package/Calendar}/index.js.map +0 -0
- package/{Calendar → dist-package/Calendar}/styles.d.ts +0 -0
- package/{Calendar → dist-package/Calendar}/styles.js +0 -0
- package/{Calendar → dist-package/Calendar}/styles.js.map +0 -0
- package/{Calendar → dist-package/Calendar}/types.d.ts +0 -0
- package/{Calendar → dist-package/Calendar}/types.js +0 -0
- package/{Calendar → dist-package/Calendar}/types.js.map +0 -0
- package/{DatePicker → dist-package/DatePicker}/DatePicker.d.ts +0 -0
- package/{DatePicker → dist-package/DatePicker}/DatePicker.js +0 -0
- package/{DatePicker → dist-package/DatePicker}/DatePicker.js.map +0 -0
- package/{DatePicker → dist-package/DatePicker}/constants.d.ts +0 -0
- package/{DatePicker → dist-package/DatePicker}/constants.js +0 -0
- package/{DatePicker → dist-package/DatePicker}/constants.js.map +0 -0
- package/{DatePicker → dist-package/DatePicker}/index.d.ts +0 -0
- package/{DatePicker → dist-package/DatePicker}/index.js +0 -0
- package/{DatePicker → dist-package/DatePicker}/index.js.map +0 -0
- package/{DatePicker → dist-package/DatePicker}/styles.d.ts +0 -0
- package/{DatePicker → dist-package/DatePicker}/styles.js +0 -0
- package/{DatePicker → dist-package/DatePicker}/styles.js.map +0 -0
- package/{DatePicker → dist-package/DatePicker}/types.d.ts +0 -0
- package/{DatePicker → dist-package/DatePicker}/types.js +0 -0
- package/{DatePicker → dist-package/DatePicker}/types.js.map +0 -0
- package/{DatePicker → dist-package/DatePicker}/utils.d.ts +0 -0
- package/{DatePicker → dist-package/DatePicker}/utils.js +0 -0
- package/{DatePicker → dist-package/DatePicker}/utils.js.map +0 -0
- package/{Drawer → dist-package/Drawer}/Drawer.d.ts +0 -0
- package/{Drawer → dist-package/Drawer}/Drawer.js +0 -0
- package/{Drawer → dist-package/Drawer}/Drawer.js.map +0 -0
- package/{Drawer → dist-package/Drawer}/index.d.ts +0 -0
- package/{Drawer → dist-package/Drawer}/index.js +0 -0
- package/{Drawer → dist-package/Drawer}/index.js.map +0 -0
- package/{Drawer → dist-package/Drawer}/styles.d.ts +0 -0
- package/{Drawer → dist-package/Drawer}/styles.js +0 -0
- package/{Drawer → dist-package/Drawer}/styles.js.map +0 -0
- package/{DrawerTitle → dist-package/DrawerTitle}/DrawerTitle.d.ts +0 -0
- package/{DrawerTitle → dist-package/DrawerTitle}/DrawerTitle.js +0 -0
- package/{DrawerTitle → dist-package/DrawerTitle}/DrawerTitle.js.map +0 -0
- package/{DrawerTitle → dist-package/DrawerTitle}/index.d.ts +0 -0
- package/{DrawerTitle → dist-package/DrawerTitle}/index.js +0 -0
- package/{DrawerTitle → dist-package/DrawerTitle}/index.js.map +0 -0
- package/{DrawerTitle → dist-package/DrawerTitle}/styles.d.ts +0 -0
- package/{DrawerTitle → dist-package/DrawerTitle}/styles.js +0 -0
- package/{DrawerTitle → dist-package/DrawerTitle}/styles.js.map +0 -0
- package/{Dropzone → dist-package/Dropzone}/Dropzone.d.ts +0 -0
- package/{Dropzone → dist-package/Dropzone}/Dropzone.js +1 -1
- package/{Dropzone → dist-package/Dropzone}/Dropzone.js.map +1 -1
- package/{Dropzone → dist-package/Dropzone}/index.d.ts +0 -0
- package/{Dropzone → dist-package/Dropzone}/index.js +0 -0
- package/{Dropzone → dist-package/Dropzone}/index.js.map +0 -0
- package/{Dropzone → dist-package/Dropzone}/styles.d.ts +0 -0
- package/{Dropzone → dist-package/Dropzone}/styles.js +0 -0
- package/{Dropzone → dist-package/Dropzone}/styles.js.map +0 -0
- package/{Dropzone → dist-package/Dropzone}/types.d.ts +0 -0
- package/{Dropzone → dist-package/Dropzone}/types.js +0 -0
- package/{Dropzone → dist-package/Dropzone}/types.js.map +0 -0
- package/{EmptyState → dist-package/EmptyState}/EmptyState.d.ts +0 -0
- package/{EmptyState → dist-package/EmptyState}/EmptyState.js +0 -0
- package/{EmptyState → dist-package/EmptyState}/EmptyState.js.map +0 -0
- package/{EmptyState → dist-package/EmptyState}/index.d.ts +0 -0
- package/{EmptyState → dist-package/EmptyState}/index.js +0 -0
- package/{EmptyState → dist-package/EmptyState}/index.js.map +0 -0
- package/{EmptyStateCollection → dist-package/EmptyStateCollection}/EmptyStateCollection.d.ts +0 -0
- package/{EmptyStateCollection → dist-package/EmptyStateCollection}/EmptyStateCollection.js +0 -0
- package/{EmptyStateCollection → dist-package/EmptyStateCollection}/EmptyStateCollection.js.map +0 -0
- package/{EmptyStateCollection → dist-package/EmptyStateCollection}/index.d.ts +0 -0
- package/{EmptyStateCollection → dist-package/EmptyStateCollection}/index.js +0 -0
- package/{EmptyStateCollection → dist-package/EmptyStateCollection}/index.js.map +0 -0
- package/{EmptyStateCollection → dist-package/EmptyStateCollection}/styles.d.ts +0 -0
- package/{EmptyStateCollection → dist-package/EmptyStateCollection}/styles.js +0 -0
- package/{EmptyStateCollection → dist-package/EmptyStateCollection}/styles.js.map +0 -0
- package/{EmptyStatePage → dist-package/EmptyStatePage}/EmptyStatePage.d.ts +0 -0
- package/{EmptyStatePage → dist-package/EmptyStatePage}/EmptyStatePage.js +0 -0
- package/{EmptyStatePage → dist-package/EmptyStatePage}/EmptyStatePage.js.map +0 -0
- package/{EmptyStatePage → dist-package/EmptyStatePage}/index.d.ts +0 -0
- package/{EmptyStatePage → dist-package/EmptyStatePage}/index.js +0 -0
- package/{EmptyStatePage → dist-package/EmptyStatePage}/index.js.map +0 -0
- package/{EmptyStatePage → dist-package/EmptyStatePage}/styles.d.ts +0 -0
- package/{EmptyStatePage → dist-package/EmptyStatePage}/styles.js +0 -0
- package/{EmptyStatePage → dist-package/EmptyStatePage}/styles.js.map +0 -0
- package/{Note → dist-package/Note}/Note.d.ts +0 -0
- package/{Note → dist-package/Note}/Note.js +0 -0
- package/{Note → dist-package/Note}/Note.js.map +0 -0
- package/{Note → dist-package/Note}/index.d.ts +0 -0
- package/{Note → dist-package/Note}/index.js +0 -0
- package/{Note → dist-package/Note}/index.js.map +0 -0
- package/{Note → dist-package/Note}/styles.d.ts +0 -0
- package/{Note → dist-package/Note}/styles.js +0 -0
- package/{Note → dist-package/Note}/styles.js.map +0 -0
- package/{NoteContent → dist-package/NoteContent}/NoteContent.d.ts +0 -0
- package/{NoteContent → dist-package/NoteContent}/NoteContent.js +0 -0
- package/{NoteContent → dist-package/NoteContent}/NoteContent.js.map +0 -0
- package/{NoteContent → dist-package/NoteContent}/index.d.ts +0 -0
- package/{NoteContent → dist-package/NoteContent}/index.js +0 -0
- package/{NoteContent → dist-package/NoteContent}/index.js.map +0 -0
- package/{NoteSubtitle → dist-package/NoteSubtitle}/NoteSubtitle.d.ts +0 -0
- package/{NoteSubtitle → dist-package/NoteSubtitle}/NoteSubtitle.js +0 -0
- package/{NoteSubtitle → dist-package/NoteSubtitle}/NoteSubtitle.js.map +0 -0
- package/{NoteSubtitle → dist-package/NoteSubtitle}/index.d.ts +0 -0
- package/{NoteSubtitle → dist-package/NoteSubtitle}/index.js +0 -0
- package/{NoteSubtitle → dist-package/NoteSubtitle}/index.js.map +0 -0
- package/{NoteTitle → dist-package/NoteTitle}/NoteTitle.d.ts +0 -0
- package/{NoteTitle → dist-package/NoteTitle}/NoteTitle.js +0 -0
- package/{NoteTitle → dist-package/NoteTitle}/NoteTitle.js.map +0 -0
- package/{NoteTitle → dist-package/NoteTitle}/index.d.ts +0 -0
- package/{NoteTitle → dist-package/NoteTitle}/index.js +0 -0
- package/{NoteTitle → dist-package/NoteTitle}/index.js.map +0 -0
- package/{NoteTitle → dist-package/NoteTitle}/styles.d.ts +0 -0
- package/{NoteTitle → dist-package/NoteTitle}/styles.js +0 -0
- package/{NoteTitle → dist-package/NoteTitle}/styles.js.map +0 -0
- package/{OverviewBlock → dist-package/OverviewBlock}/OverviewBlock.d.ts +0 -0
- package/{OverviewBlock → dist-package/OverviewBlock}/OverviewBlock.js +0 -0
- package/{OverviewBlock → dist-package/OverviewBlock}/OverviewBlock.js.map +0 -0
- package/{OverviewBlock → dist-package/OverviewBlock}/index.d.ts +0 -0
- package/{OverviewBlock → dist-package/OverviewBlock}/index.js +0 -0
- package/{OverviewBlock → dist-package/OverviewBlock}/index.js.map +0 -0
- package/{OverviewBlock → dist-package/OverviewBlock}/styles.d.ts +0 -0
- package/{OverviewBlock → dist-package/OverviewBlock}/styles.js +0 -0
- package/{OverviewBlock → dist-package/OverviewBlock}/styles.js.map +0 -0
- package/{OverviewBlockGroup → dist-package/OverviewBlockGroup}/OverviewBlockGroup.d.ts +0 -0
- package/{OverviewBlockGroup → dist-package/OverviewBlockGroup}/OverviewBlockGroup.js +0 -0
- package/{OverviewBlockGroup → dist-package/OverviewBlockGroup}/OverviewBlockGroup.js.map +0 -0
- package/{OverviewBlockGroup → dist-package/OverviewBlockGroup}/OverviewBlockGroupContext.d.ts +0 -0
- package/{OverviewBlockGroup → dist-package/OverviewBlockGroup}/OverviewBlockGroupContext.js +0 -0
- package/{OverviewBlockGroup → dist-package/OverviewBlockGroup}/OverviewBlockGroupContext.js.map +0 -0
- package/{OverviewBlockGroup → dist-package/OverviewBlockGroup}/index.d.ts +0 -0
- package/{OverviewBlockGroup → dist-package/OverviewBlockGroup}/index.js +0 -0
- package/{OverviewBlockGroup → dist-package/OverviewBlockGroup}/index.js.map +0 -0
- package/{OverviewBlockGroup → dist-package/OverviewBlockGroup}/settings.d.ts +0 -0
- package/{OverviewBlockGroup → dist-package/OverviewBlockGroup}/settings.js +0 -0
- package/{OverviewBlockGroup → dist-package/OverviewBlockGroup}/settings.js.map +0 -0
- package/{OverviewBlockRow → dist-package/OverviewBlockRow}/OverviewBlockRow.d.ts +0 -0
- package/{OverviewBlockRow → dist-package/OverviewBlockRow}/OverviewBlockRow.js +0 -0
- package/{OverviewBlockRow → dist-package/OverviewBlockRow}/OverviewBlockRow.js.map +0 -0
- package/{OverviewBlockRow → dist-package/OverviewBlockRow}/index.d.ts +0 -0
- package/{OverviewBlockRow → dist-package/OverviewBlockRow}/index.js +0 -0
- package/{OverviewBlockRow → dist-package/OverviewBlockRow}/index.js.map +0 -0
- package/{OverviewBlockRow → dist-package/OverviewBlockRow}/styles.d.ts +0 -0
- package/{OverviewBlockRow → dist-package/OverviewBlockRow}/styles.js +0 -0
- package/{OverviewBlockRow → dist-package/OverviewBlockRow}/styles.js.map +0 -0
- package/dist-package/README.md +26 -0
- package/{Section → dist-package/Section}/Section.d.ts +0 -0
- package/{Section → dist-package/Section}/Section.js +0 -0
- package/{Section → dist-package/Section}/Section.js.map +0 -0
- package/{Section → dist-package/Section}/index.d.ts +0 -0
- package/{Section → dist-package/Section}/index.js +0 -0
- package/{Section → dist-package/Section}/index.js.map +0 -0
- package/{Section → dist-package/Section}/styles.d.ts +0 -0
- package/{Section → dist-package/Section}/styles.js +0 -0
- package/{Section → dist-package/Section}/styles.js.map +0 -0
- package/{Timeline → dist-package/Timeline}/Timeline.d.ts +0 -0
- package/{Timeline → dist-package/Timeline}/Timeline.js +0 -0
- package/{Timeline → dist-package/Timeline}/Timeline.js.map +0 -0
- package/{Timeline → dist-package/Timeline}/index.d.ts +0 -0
- package/{Timeline → dist-package/Timeline}/index.js +0 -0
- package/{Timeline → dist-package/Timeline}/index.js.map +0 -0
- package/{TimelineRow → dist-package/TimelineRow}/TimelineRow.d.ts +0 -0
- package/{TimelineRow → dist-package/TimelineRow}/TimelineRow.js +0 -0
- package/{TimelineRow → dist-package/TimelineRow}/TimelineRow.js.map +0 -0
- package/{TimelineRow → dist-package/TimelineRow}/index.d.ts +0 -0
- package/{TimelineRow → dist-package/TimelineRow}/index.js +0 -0
- package/{TimelineRow → dist-package/TimelineRow}/index.js.map +0 -0
- package/{TimelineRow → dist-package/TimelineRow}/styles.d.ts +0 -0
- package/{TimelineRow → dist-package/TimelineRow}/styles.js +0 -0
- package/{TimelineRow → dist-package/TimelineRow}/styles.js.map +0 -0
- package/{TypographyOverflow → dist-package/TypographyOverflow}/TypographyOverflow.d.ts +0 -0
- package/{TypographyOverflow → dist-package/TypographyOverflow}/TypographyOverflow.js +0 -0
- package/{TypographyOverflow → dist-package/TypographyOverflow}/TypographyOverflow.js.map +0 -0
- package/{TypographyOverflow → dist-package/TypographyOverflow}/index.d.ts +0 -0
- package/{TypographyOverflow → dist-package/TypographyOverflow}/index.js +0 -0
- package/{TypographyOverflow → dist-package/TypographyOverflow}/index.js.map +0 -0
- package/{TypographyOverflow → dist-package/TypographyOverflow}/styles.d.ts +0 -0
- package/{TypographyOverflow → dist-package/TypographyOverflow}/styles.js +0 -0
- package/{TypographyOverflow → dist-package/TypographyOverflow}/styles.js.map +0 -0
- package/{index.d.ts → dist-package/index.d.ts} +0 -0
- package/{index.js → dist-package/index.js} +0 -0
- package/{index.js.map → dist-package/index.js.map} +0 -0
- package/dist-package/package.json +53 -0
- package/package.json +3 -4
- package/src/Calendar/Calendar.tsx +215 -0
- package/src/Calendar/__snapshots__/test.tsx.snap +447 -0
- package/src/Calendar/index.ts +2 -0
- package/src/Calendar/styles.ts +104 -0
- package/src/Calendar/test.tsx +20 -0
- package/src/Calendar/types.ts +42 -0
- package/src/DatePicker/DatePicker.tsx +366 -0
- package/src/DatePicker/__image_snapshots__/datepicker-full-width-snap.png +0 -0
- package/src/DatePicker/__image_snapshots__/datepicker-with-custom-day-rendering-snap.png +0 -0
- package/src/DatePicker/__snapshots__/test.tsx.snap +51 -0
- package/src/DatePicker/constants.ts +2 -0
- package/src/DatePicker/index.ts +5 -0
- package/src/DatePicker/story/AllowCustomValue.example.tsx +33 -0
- package/src/DatePicker/story/Autocomplete.example.tsx +47 -0
- package/src/DatePicker/story/Default.example.tsx +19 -0
- package/src/DatePicker/story/Error.example.tsx +26 -0
- package/src/DatePicker/story/Range.example.tsx +22 -0
- package/src/DatePicker/story/WithCustomDayRendering.example.tsx +47 -0
- package/src/DatePicker/story/WithInitialValue.example.tsx +19 -0
- package/src/DatePicker/story/WithInputProps.example.tsx +24 -0
- package/src/DatePicker/story/WithNoHideOnSelect.example.tsx +20 -0
- package/src/DatePicker/story/WithOnBlurHandler.example.tsx +22 -0
- package/src/DatePicker/story/WithSelectionLimits.example.tsx +32 -0
- package/src/DatePicker/story/WithTimezone.example.tsx +25 -0
- package/src/DatePicker/story/index.jsx +50 -0
- package/src/DatePicker/styles.ts +8 -0
- package/src/DatePicker/test.tsx +370 -0
- package/src/DatePicker/types.ts +13 -0
- package/src/DatePicker/utils.ts +123 -0
- package/src/Drawer/Drawer.tsx +105 -0
- package/src/Drawer/__image_snapshots__/drawer-custom-title-effect-1-snap.png +0 -0
- package/src/Drawer/__image_snapshots__/drawer-custom-title-snap.png +0 -0
- package/src/Drawer/__image_snapshots__/drawer-default-effect-1-snap.png +0 -0
- package/src/Drawer/__image_snapshots__/drawer-default-snap.png +0 -0
- package/src/Drawer/__image_snapshots__/drawer-width-effect-1-snap.png +0 -0
- package/src/Drawer/__image_snapshots__/drawer-width-effect-2-snap.png +0 -0
- package/src/Drawer/__image_snapshots__/drawer-width-effect-3-snap.png +0 -0
- package/src/Drawer/__image_snapshots__/drawer-width-effect-4-snap.png +0 -0
- package/src/Drawer/__image_snapshots__/drawer-width-effect-5-snap.png +0 -0
- package/src/Drawer/__image_snapshots__/drawer-width-snap.png +0 -0
- package/src/Drawer/__image_snapshots__/drawer-without-title-effect-1-snap.png +0 -0
- package/src/Drawer/__image_snapshots__/drawer-without-title-snap.png +0 -0
- package/src/Drawer/index.ts +6 -0
- package/src/Drawer/story/CustomTitle.example.tsx +32 -0
- package/src/Drawer/story/Default.example.tsx +29 -0
- package/src/Drawer/story/DrawerAndNotification.example.tsx +34 -0
- package/src/Drawer/story/Widths.example.tsx +46 -0
- package/src/Drawer/story/WithoutTitle.example.tsx +22 -0
- package/src/Drawer/story/index.jsx +80 -0
- package/src/Drawer/styles.ts +42 -0
- package/src/DrawerTitle/DrawerTitle.tsx +35 -0
- package/src/DrawerTitle/index.ts +1 -0
- package/src/DrawerTitle/styles.ts +12 -0
- package/src/Dropzone/Dropzone.tsx +146 -0
- package/src/Dropzone/__snapshots__/test.tsx.snap +40 -0
- package/src/Dropzone/index.ts +7 -0
- package/src/Dropzone/story/Default.example.tsx +8 -0
- package/src/Dropzone/story/Disabled.example.tsx +25 -0
- package/src/Dropzone/story/Error.example.tsx +16 -0
- package/src/Dropzone/story/Multiple.example.tsx +30 -0
- package/src/Dropzone/story/Uploader.example.tsx +116 -0
- package/src/Dropzone/story/Uploading.example.tsx +16 -0
- package/src/Dropzone/story/index.jsx +85 -0
- package/src/Dropzone/styles.ts +43 -0
- package/src/Dropzone/test.tsx +33 -0
- package/src/Dropzone/types.ts +56 -0
- package/src/EmptyState/EmptyState.tsx +7 -0
- package/src/EmptyState/index.tsx +1 -0
- package/src/EmptyState/story/index.jsx +13 -0
- package/src/EmptyStateCollection/EmptyStateCollection.tsx +56 -0
- package/src/EmptyStateCollection/__image_snapshots__/emptystate-collection-emptystatecollection-snap.png +0 -0
- package/src/EmptyStateCollection/index.tsx +1 -0
- package/src/EmptyStateCollection/story/Default.example.tsx +11 -0
- package/src/EmptyStateCollection/story/index.jsx +20 -0
- package/src/EmptyStateCollection/styles.ts +10 -0
- package/src/EmptyStatePage/EmptyStatePage.tsx +65 -0
- package/src/EmptyStatePage/__image_snapshots__/emptystate-page-emptystatepage-snap.png +0 -0
- package/src/EmptyStatePage/index.tsx +1 -0
- package/src/EmptyStatePage/story/Default.example.tsx +21 -0
- package/src/EmptyStatePage/story/index.jsx +21 -0
- package/src/EmptyStatePage/styles.ts +9 -0
- package/src/Note/Note.tsx +36 -0
- package/src/Note/__snapshots__/test.tsx.snap +37 -0
- package/src/Note/index.ts +6 -0
- package/src/Note/story/Default.example.tsx +14 -0
- package/src/Note/story/index.jsx +23 -0
- package/src/Note/styles.ts +27 -0
- package/src/Note/test.tsx +22 -0
- package/src/NoteContent/NoteContent.tsx +23 -0
- package/src/NoteContent/index.ts +1 -0
- package/src/NoteContent/story/index.jsx +12 -0
- package/src/NoteSubtitle/NoteSubtitle.tsx +25 -0
- package/src/NoteSubtitle/index.ts +1 -0
- package/src/NoteSubtitle/story/index.jsx +12 -0
- package/src/NoteTitle/NoteTitle.tsx +34 -0
- package/src/NoteTitle/index.ts +1 -0
- package/src/NoteTitle/story/index.jsx +12 -0
- package/src/NoteTitle/styles.ts +8 -0
- package/src/OverviewBlock/OverviewBlock.tsx +125 -0
- package/src/OverviewBlock/__image_snapshots__/overviewblock-default-snap.png +0 -0
- package/src/OverviewBlock/__image_snapshots__/overviewblock-multi-line-snap.png +0 -0
- package/src/OverviewBlock/__image_snapshots__/overviewblock-number-snap.png +0 -0
- package/src/OverviewBlock/__image_snapshots__/overviewblock-routing-snap.png +0 -0
- package/src/OverviewBlock/__image_snapshots__/overviewblock-text-snap.png +0 -0
- package/src/OverviewBlock/index.ts +6 -0
- package/src/OverviewBlock/story/Default.example.tsx +35 -0
- package/src/OverviewBlock/story/Multiline.example.tsx +51 -0
- package/src/OverviewBlock/story/Number.example.tsx +20 -0
- package/src/OverviewBlock/story/Routing.example.tsx +40 -0
- package/src/OverviewBlock/story/Text.example.tsx +15 -0
- package/src/OverviewBlock/story/index.jsx +100 -0
- package/src/OverviewBlock/styles.ts +44 -0
- package/src/OverviewBlock/test.tsx +111 -0
- package/src/OverviewBlockGroup/OverviewBlockGroup.tsx +56 -0
- package/src/OverviewBlockGroup/OverviewBlockGroupContext.tsx +21 -0
- package/src/OverviewBlockGroup/__image_snapshots__/visual-variants-of-the-groups-block-width-snap.png +0 -0
- package/src/OverviewBlockGroup/__image_snapshots__/visual-variants-of-the-groups-center-aligned-snap.png +0 -0
- package/src/OverviewBlockGroup/index.ts +1 -0
- package/src/OverviewBlockGroup/settings.ts +2 -0
- package/src/OverviewBlockGroup/story/BlockWidth.example.tsx +38 -0
- package/src/OverviewBlockGroup/story/CenterAligned.example.tsx +17 -0
- package/src/OverviewBlockGroup/story/index.jsx +25 -0
- package/src/OverviewBlockGroup/test.tsx +17 -0
- package/src/OverviewBlockRow/OverviewBlockRow.tsx +22 -0
- package/src/OverviewBlockRow/index.ts +1 -0
- package/src/OverviewBlockRow/story/index.jsx +11 -0
- package/src/OverviewBlockRow/styles.ts +27 -0
- package/src/Section/Section.tsx +163 -0
- package/src/Section/__snapshots__/test.tsx.snap +186 -0
- package/src/Section/index.ts +6 -0
- package/src/Section/story/Actions.example.tsx +85 -0
- package/src/Section/story/Collapsible.example.tsx +113 -0
- package/src/Section/story/Default.example.tsx +77 -0
- package/src/Section/story/TitleSize.example.tsx +34 -0
- package/src/Section/story/Variant.example.tsx +108 -0
- package/src/Section/story/index.jsx +35 -0
- package/src/Section/styles.ts +65 -0
- package/src/Section/test.tsx +115 -0
- package/src/Timeline/Timeline.tsx +25 -0
- package/src/Timeline/__snapshots__/test.tsx.snap +332 -0
- package/src/Timeline/index.ts +6 -0
- package/src/Timeline/story/Dates.example.tsx +52 -0
- package/src/Timeline/story/Default.example.tsx +34 -0
- package/src/Timeline/story/TrimLastConnector.example.tsx +29 -0
- package/src/Timeline/story/index.jsx +27 -0
- package/src/Timeline/test.tsx +101 -0
- package/src/TimelineRow/TimelineRow.tsx +83 -0
- package/src/TimelineRow/index.ts +6 -0
- package/src/TimelineRow/story/index.jsx +11 -0
- package/src/TimelineRow/styles.ts +47 -0
- package/src/TypographyOverflow/TypographyOverflow.tsx +153 -0
- package/src/TypographyOverflow/__image_snapshots__/typographyoverflow-checkbox-label-effect-1-snap.png +0 -0
- package/src/TypographyOverflow/__image_snapshots__/typographyoverflow-checkbox-label-snap.png +0 -0
- package/src/TypographyOverflow/__image_snapshots__/typographyoverflow-custom-tooltip-content-effect-1-snap.png +0 -0
- package/src/TypographyOverflow/__image_snapshots__/typographyoverflow-custom-tooltip-content-snap.png +0 -0
- package/src/TypographyOverflow/__image_snapshots__/typographyoverflow-default-effect-1-snap.png +0 -0
- package/src/TypographyOverflow/__image_snapshots__/typographyoverflow-default-effect-2-snap.png +0 -0
- package/src/TypographyOverflow/__image_snapshots__/typographyoverflow-default-snap.png +0 -0
- package/src/TypographyOverflow/__image_snapshots__/typographyoverflow-delay-effect-1-snap.png +0 -0
- package/src/TypographyOverflow/__image_snapshots__/typographyoverflow-delay-effect-2-snap.png +0 -0
- package/src/TypographyOverflow/__image_snapshots__/typographyoverflow-delay-snap.png +0 -0
- package/src/TypographyOverflow/__image_snapshots__/typographyoverflow-light-tooltip-background-effect-1-snap.png +0 -0
- package/src/TypographyOverflow/__image_snapshots__/typographyoverflow-light-tooltip-background-effect-2-snap.png +0 -0
- package/src/TypographyOverflow/__image_snapshots__/typographyoverflow-light-tooltip-background-snap.png +0 -0
- package/src/TypographyOverflow/__image_snapshots__/typographyoverflow-multiline-effect-1-snap.png +0 -0
- package/src/TypographyOverflow/__image_snapshots__/typographyoverflow-multiline-effect-2-snap.png +0 -0
- package/src/TypographyOverflow/__image_snapshots__/typographyoverflow-multiline-effect-3-snap.png +0 -0
- package/src/TypographyOverflow/__image_snapshots__/typographyoverflow-multiline-snap.png +0 -0
- package/src/TypographyOverflow/index.ts +6 -0
- package/src/TypographyOverflow/story/CheckboxLabel.example.tsx +21 -0
- package/src/TypographyOverflow/story/CustomTooltip.example.tsx +22 -0
- package/src/TypographyOverflow/story/Default.example.tsx +32 -0
- package/src/TypographyOverflow/story/Delay.example.tsx +29 -0
- package/src/TypographyOverflow/story/GridWithControls.example.tsx +64 -0
- package/src/TypographyOverflow/story/Multiline.example.tsx +59 -0
- package/src/TypographyOverflow/story/TooltipVariants.example.tsx +23 -0
- package/src/TypographyOverflow/story/index.jsx +83 -0
- package/src/TypographyOverflow/styles.ts +29 -0
- package/src/TypographyOverflow/test.tsx +60 -0
- package/src/index.ts +35 -0
- package/src/story/index.jsx +10 -0
- package/tsconfig.build.json +7 -0
@@ -0,0 +1,146 @@
|
|
1
|
+
import React, { forwardRef } from 'react'
|
2
|
+
import { useDropzone } from 'react-dropzone'
|
3
|
+
import cx from 'classnames'
|
4
|
+
import { makeStyles, Theme } from '@material-ui/core/styles'
|
5
|
+
import { BaseProps } from '@toptal/picasso-shared'
|
6
|
+
import { Upload24 } from '@toptal/picasso/Icon'
|
7
|
+
import {
|
8
|
+
FormError,
|
9
|
+
Container,
|
10
|
+
FileList,
|
11
|
+
Typography,
|
12
|
+
FormHint
|
13
|
+
} from '@toptal/picasso'
|
14
|
+
|
15
|
+
import { FileUpload, DropzoneOptions } from './types'
|
16
|
+
import styles from './styles'
|
17
|
+
|
18
|
+
export interface Props extends BaseProps {
|
19
|
+
/**
|
20
|
+
* Set accepted file types. See https://github.com/okonet/attr-accept for more information.
|
21
|
+
*/
|
22
|
+
accept?: DropzoneOptions['accept']
|
23
|
+
/** Enable/disable the dropzone */
|
24
|
+
disabled?: boolean
|
25
|
+
/** Maximum file size (in bytes) */
|
26
|
+
maxSize?: number
|
27
|
+
/** Minimum file size (in bytes) */
|
28
|
+
minSize?: number
|
29
|
+
/** Allow drag 'n' drop (or selection from the file dialog) of multiple files */
|
30
|
+
multiple?: boolean
|
31
|
+
/** The text of the hint */
|
32
|
+
hint?: string
|
33
|
+
/** Callback invoked when a file item is removed */
|
34
|
+
onRemove?: (fileName: string, index: number) => void
|
35
|
+
/** Callback for when the drop event occurs */
|
36
|
+
onDropAccepted?: DropzoneOptions['onDropAccepted']
|
37
|
+
/** callback for when the drop event occurs */
|
38
|
+
onDropRejected?: DropzoneOptions['onDropRejected']
|
39
|
+
/** callback for when the drop event occurs */
|
40
|
+
onDrop?: DropzoneOptions['onDrop']
|
41
|
+
/** Custom validation function */
|
42
|
+
validator?: DropzoneOptions['validator']
|
43
|
+
/** Value uses the File interface. */
|
44
|
+
value?: FileUpload[]
|
45
|
+
/** Reasons why files couldn't be droped into dropzone */
|
46
|
+
errorMessages?: string[]
|
47
|
+
focused?: boolean
|
48
|
+
hovered?: boolean
|
49
|
+
}
|
50
|
+
|
51
|
+
const useStyles = makeStyles<Theme>(styles, { name: 'Dropzone' })
|
52
|
+
|
53
|
+
export const Dropzone = forwardRef<HTMLInputElement, Props>(function Dropzone(
|
54
|
+
props,
|
55
|
+
ref
|
56
|
+
) {
|
57
|
+
const {
|
58
|
+
hint,
|
59
|
+
onRemove,
|
60
|
+
value,
|
61
|
+
className,
|
62
|
+
errorMessages = [],
|
63
|
+
style,
|
64
|
+
'data-testid': dataTestId,
|
65
|
+
focused,
|
66
|
+
hovered,
|
67
|
+
|
68
|
+
// dropzoneOptions
|
69
|
+
accept,
|
70
|
+
minSize,
|
71
|
+
maxSize,
|
72
|
+
multiple,
|
73
|
+
disabled,
|
74
|
+
onDrop,
|
75
|
+
onDropAccepted,
|
76
|
+
onDropRejected,
|
77
|
+
validator
|
78
|
+
} = props
|
79
|
+
|
80
|
+
const { getRootProps, isDragActive, getInputProps } = useDropzone({
|
81
|
+
accept,
|
82
|
+
minSize,
|
83
|
+
maxSize,
|
84
|
+
multiple,
|
85
|
+
disabled,
|
86
|
+
onDrop,
|
87
|
+
onDropAccepted,
|
88
|
+
onDropRejected,
|
89
|
+
validator
|
90
|
+
})
|
91
|
+
|
92
|
+
const classes = useStyles()
|
93
|
+
|
94
|
+
return (
|
95
|
+
<Container style={style} ref={ref} className={className}>
|
96
|
+
<Container
|
97
|
+
flex
|
98
|
+
direction='column'
|
99
|
+
alignItems='center'
|
100
|
+
data-testid={dataTestId}
|
101
|
+
{...getRootProps({
|
102
|
+
className: cx(classes.root, {
|
103
|
+
[classes.dragActive]: isDragActive,
|
104
|
+
[classes.hovered]: hovered,
|
105
|
+
[classes.disabled]: disabled,
|
106
|
+
[classes.focused]: focused
|
107
|
+
})
|
108
|
+
})}
|
109
|
+
>
|
110
|
+
<input {...getInputProps({ className: classes.nativeInput })} />
|
111
|
+
<Upload24 color='darkGrey' />
|
112
|
+
<Typography size='medium' color='black' weight='semibold'>
|
113
|
+
Click or drag file to upload
|
114
|
+
</Typography>
|
115
|
+
{hint && errorMessages.length === 0 && (
|
116
|
+
<FormHint className={cx(classes.hint)}>{hint}</FormHint>
|
117
|
+
)}
|
118
|
+
{errorMessages.length > 0 &&
|
119
|
+
errorMessages.map((error, index) => (
|
120
|
+
<FormError
|
121
|
+
className={classes.error}
|
122
|
+
key={`${error}-${String(index)}`}
|
123
|
+
>
|
124
|
+
{error}
|
125
|
+
</FormError>
|
126
|
+
))}
|
127
|
+
</Container>
|
128
|
+
{value && value.length > 0 && (
|
129
|
+
<Container top='xsmall'>
|
130
|
+
<FileList files={value} onItemRemove={onRemove} />
|
131
|
+
</Container>
|
132
|
+
)}
|
133
|
+
</Container>
|
134
|
+
)
|
135
|
+
})
|
136
|
+
|
137
|
+
Dropzone.displayName = 'Dropzone'
|
138
|
+
|
139
|
+
Dropzone.defaultProps = {
|
140
|
+
disabled: false,
|
141
|
+
maxSize: Infinity,
|
142
|
+
minSize: 0,
|
143
|
+
multiple: true
|
144
|
+
}
|
145
|
+
|
146
|
+
export default Dropzone
|
@@ -0,0 +1,40 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`Dropzone renders 1`] = `
|
4
|
+
<div>
|
5
|
+
<div
|
6
|
+
class="Picasso-root"
|
7
|
+
>
|
8
|
+
<div
|
9
|
+
class=""
|
10
|
+
>
|
11
|
+
<div
|
12
|
+
class="PicassoContainer-centerAlignItems PicassoContainer-flex PicassoContainer-column Dropzone-root"
|
13
|
+
tabindex="0"
|
14
|
+
>
|
15
|
+
<input
|
16
|
+
autocomplete="off"
|
17
|
+
multiple=""
|
18
|
+
style="display: none;"
|
19
|
+
tabindex="-1"
|
20
|
+
type="file"
|
21
|
+
/>
|
22
|
+
<svg
|
23
|
+
class="PicassoSvgUpload24-root PicassoSvgUpload24-darkGrey"
|
24
|
+
style="min-width: 24px; min-height: 24px;"
|
25
|
+
viewBox="0 0 24 24"
|
26
|
+
>
|
27
|
+
<path
|
28
|
+
d="M2 18v3h19v-3h1v4H1v-4h1zm9.5-16.207L16.207 6.5l-.707.707-3.501-3.501V19H11l-.001-15.294L7.5 7.207 6.793 6.5 11.5 1.793z"
|
29
|
+
/>
|
30
|
+
</svg>
|
31
|
+
<p
|
32
|
+
class="MuiTypography-root PicassoTypography-bodyMedium PicassoTypography-black PicassoTypography-semibold MuiTypography-body1"
|
33
|
+
>
|
34
|
+
Click or drag file to upload
|
35
|
+
</p>
|
36
|
+
</div>
|
37
|
+
</div>
|
38
|
+
</div>
|
39
|
+
</div>
|
40
|
+
`;
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { Dropzone } from '@toptal/picasso-lab'
|
3
|
+
|
4
|
+
const value = [
|
5
|
+
{
|
6
|
+
uploading: false,
|
7
|
+
progress: 0,
|
8
|
+
file: new File(['resume.pdf'], 'resume.pdf')
|
9
|
+
}
|
10
|
+
]
|
11
|
+
|
12
|
+
const Example = () => {
|
13
|
+
return (
|
14
|
+
<Dropzone
|
15
|
+
disabled
|
16
|
+
value={value}
|
17
|
+
onDrop={() => alert('onDrop callback triggered')}
|
18
|
+
onRemove={() => alert('onRemove callback triggered')}
|
19
|
+
hint='Max file size: 25MB'
|
20
|
+
accept='image/*'
|
21
|
+
/>
|
22
|
+
)
|
23
|
+
}
|
24
|
+
|
25
|
+
export default Example
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { Dropzone } from '@toptal/picasso-lab'
|
3
|
+
|
4
|
+
const errorMessages = ['resume.pdf: File is too large']
|
5
|
+
|
6
|
+
const Example = () => {
|
7
|
+
return (
|
8
|
+
<Dropzone
|
9
|
+
hint='Max file size: 25MB'
|
10
|
+
accept='image/*'
|
11
|
+
errorMessages={errorMessages}
|
12
|
+
/>
|
13
|
+
)
|
14
|
+
}
|
15
|
+
|
16
|
+
export default Example
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { Dropzone } from '@toptal/picasso-lab'
|
3
|
+
|
4
|
+
const value = [
|
5
|
+
{
|
6
|
+
uploading: false,
|
7
|
+
progress: 0,
|
8
|
+
file: new File(['resume.pdf'], 'resume.pdf')
|
9
|
+
},
|
10
|
+
{
|
11
|
+
uploading: false,
|
12
|
+
progress: 0,
|
13
|
+
file: new File(['portfolio.pdf'], 'portfolio.pdf')
|
14
|
+
}
|
15
|
+
]
|
16
|
+
|
17
|
+
const Example = () => {
|
18
|
+
return (
|
19
|
+
<Dropzone
|
20
|
+
value={value}
|
21
|
+
onDrop={() => alert('onDrop callback triggered')}
|
22
|
+
onRemove={() => alert('onRemove callback triggered')}
|
23
|
+
hint='Files allowed: 2. Max file size: 25MB'
|
24
|
+
accept='image/*'
|
25
|
+
disabled
|
26
|
+
/>
|
27
|
+
)
|
28
|
+
}
|
29
|
+
|
30
|
+
export default Example
|
@@ -0,0 +1,116 @@
|
|
1
|
+
import React, { useEffect, useState } from 'react'
|
2
|
+
import {
|
3
|
+
Dropzone,
|
4
|
+
DropzoneErrorCode,
|
5
|
+
DropzoneFileUpload,
|
6
|
+
DropzoneFileError,
|
7
|
+
DropzoneFileRejection
|
8
|
+
} from '@toptal/picasso-lab'
|
9
|
+
|
10
|
+
const MAX_SIZE = 600 * 1000
|
11
|
+
|
12
|
+
const customSizeValidator = (file: File): DropzoneFileError[] | null => {
|
13
|
+
if (file.size > MAX_SIZE) {
|
14
|
+
return [
|
15
|
+
{
|
16
|
+
code: DropzoneErrorCode.FileTooLarge,
|
17
|
+
message: `File size exceeds the ${MAX_SIZE / 1000 / 1000}MB.`
|
18
|
+
}
|
19
|
+
]
|
20
|
+
}
|
21
|
+
|
22
|
+
return null
|
23
|
+
}
|
24
|
+
|
25
|
+
const useFiles = ({ maxFiles }: { maxFiles: number }) => {
|
26
|
+
const [files, setFiles] = useState<DropzoneFileUpload[]>([])
|
27
|
+
const [errorMessages, setError] = useState<string[]>([])
|
28
|
+
const [disabled, setDisabled] = useState<boolean>(false)
|
29
|
+
|
30
|
+
useEffect(() => {
|
31
|
+
if (files.length >= maxFiles) {
|
32
|
+
setDisabled(true)
|
33
|
+
} else {
|
34
|
+
setDisabled(false)
|
35
|
+
}
|
36
|
+
}, [maxFiles, files.length])
|
37
|
+
|
38
|
+
const addFiles = (
|
39
|
+
acceptedFiles: File[],
|
40
|
+
rejectedFiles: DropzoneFileRejection[]
|
41
|
+
): void => {
|
42
|
+
if (files.length + acceptedFiles.length + rejectedFiles.length > maxFiles) {
|
43
|
+
return setError(['Too many files'])
|
44
|
+
}
|
45
|
+
if (acceptedFiles.length > 0) {
|
46
|
+
const previousFiles = files
|
47
|
+
const newFiles = acceptedFiles.map(file => ({
|
48
|
+
file,
|
49
|
+
uploading: true
|
50
|
+
}))
|
51
|
+
|
52
|
+
setFiles([...previousFiles, ...newFiles])
|
53
|
+
let progress = 0
|
54
|
+
const interval = setInterval(() => {
|
55
|
+
if (progress === 100) {
|
56
|
+
setFiles([
|
57
|
+
...previousFiles,
|
58
|
+
...newFiles.map(file => ({ ...file, uploading: false }))
|
59
|
+
])
|
60
|
+
clearInterval(interval)
|
61
|
+
} else {
|
62
|
+
setFiles([
|
63
|
+
...previousFiles,
|
64
|
+
...newFiles.map(file => ({ ...file, progress }))
|
65
|
+
])
|
66
|
+
progress += 10
|
67
|
+
}
|
68
|
+
}, 250)
|
69
|
+
}
|
70
|
+
|
71
|
+
if (rejectedFiles.length) {
|
72
|
+
setError(
|
73
|
+
rejectedFiles.map(
|
74
|
+
({ errors, file }) =>
|
75
|
+
`${file.name}: ${errors.map(error => error.message).join(', ')}`
|
76
|
+
)
|
77
|
+
)
|
78
|
+
} else {
|
79
|
+
setError([])
|
80
|
+
}
|
81
|
+
}
|
82
|
+
|
83
|
+
const removeFile = (fileName: string, fileIndex: number) => {
|
84
|
+
const updatedFiles = files.filter((_, index) => index !== fileIndex)
|
85
|
+
|
86
|
+
setFiles(updatedFiles)
|
87
|
+
}
|
88
|
+
|
89
|
+
return {
|
90
|
+
files,
|
91
|
+
addFiles,
|
92
|
+
removeFile,
|
93
|
+
errorMessages,
|
94
|
+
disabled
|
95
|
+
}
|
96
|
+
}
|
97
|
+
const Example = () => {
|
98
|
+
const { files, addFiles, removeFile, errorMessages, disabled } = useFiles({
|
99
|
+
maxFiles: 2
|
100
|
+
})
|
101
|
+
|
102
|
+
return (
|
103
|
+
<Dropzone
|
104
|
+
value={files}
|
105
|
+
onDrop={addFiles}
|
106
|
+
onRemove={removeFile}
|
107
|
+
hint={`Files allowed 2. Max file size: ${MAX_SIZE / 1000}KB`}
|
108
|
+
accept='image/*'
|
109
|
+
validator={customSizeValidator}
|
110
|
+
errorMessages={errorMessages}
|
111
|
+
disabled={disabled}
|
112
|
+
/>
|
113
|
+
)
|
114
|
+
}
|
115
|
+
|
116
|
+
export default Example
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { Dropzone } from '@toptal/picasso-lab'
|
3
|
+
|
4
|
+
const value = [
|
5
|
+
{
|
6
|
+
uploading: true,
|
7
|
+
progress: 30,
|
8
|
+
file: new File(['resume.pdf'], 'resume.pdf')
|
9
|
+
}
|
10
|
+
]
|
11
|
+
|
12
|
+
const Example = () => {
|
13
|
+
return <Dropzone value={value} hint='Max file size: 25MB' accept='image/*' />
|
14
|
+
}
|
15
|
+
|
16
|
+
export default Example
|
@@ -0,0 +1,85 @@
|
|
1
|
+
import { Dropzone } from '../Dropzone'
|
2
|
+
import PicassoBook from '~/.storybook/components/PicassoBook'
|
3
|
+
|
4
|
+
const page = PicassoBook.section('Picasso Lab').createPage(
|
5
|
+
'Dropzone',
|
6
|
+
`
|
7
|
+
${PicassoBook.createBaseDocsLink(
|
8
|
+
'https://app.abstract.com/projects/1b06c884-06af-482a-bf12-a82f521a19a1/branches/master/commits/58ee1df911f7d6ca2d9214171088a69bdff23401/files/13531207-e094-44ec-ae1f-f27628c1aea5/layers/27C9F1FA-E469-4AA4-936C-DD752F77ADE3?mode=build&selected=root-8BD3C500-A858-4CC4-8CE8-02E0453C0C4D&sha=58ee1df911f7d6ca2d9214171088a69bdff23401'
|
9
|
+
)}
|
10
|
+
`
|
11
|
+
)
|
12
|
+
|
13
|
+
page.createTabChapter('Props').addComponentDocs({
|
14
|
+
component: Dropzone,
|
15
|
+
name: 'Dropzone',
|
16
|
+
additionalDocs: {
|
17
|
+
accept: {
|
18
|
+
name: 'accept',
|
19
|
+
type: 'string | string[]',
|
20
|
+
description:
|
21
|
+
'Set accepted file types. See https://github.com/okonet/attr-accept for more information. Keep in mind that mime type determination is not reliable across platforms. CSV files, for example, are reported as text/plain under macOS but as application/vnd.ms-excel under Windows. In some cases there might not be a mime type set at all. See: https://github.com/react-dropzone/react-dropzone/issues/276'
|
22
|
+
},
|
23
|
+
onDropAccepted: {
|
24
|
+
name: 'onDropAccepted',
|
25
|
+
type: {
|
26
|
+
name: 'function',
|
27
|
+
description: '(files: File[], event) => void'
|
28
|
+
},
|
29
|
+
description:
|
30
|
+
'Callback for when the drop event occurs. Note that if no files are accepted, this callback is not invoked.'
|
31
|
+
},
|
32
|
+
onDropRejected: {
|
33
|
+
name: 'onDropRejected',
|
34
|
+
type: {
|
35
|
+
name: 'function',
|
36
|
+
description: '(fileRejections: FileRejection[], event) => void'
|
37
|
+
},
|
38
|
+
description:
|
39
|
+
'Callback for when the drop event occurs. Note that if no files are rejected, this callback is not invoked.'
|
40
|
+
},
|
41
|
+
validator: {
|
42
|
+
name: 'validator',
|
43
|
+
type: {
|
44
|
+
name: 'function',
|
45
|
+
description: '(file:File) => FileError | FileError[] | null'
|
46
|
+
},
|
47
|
+
description: 'Custom validation function',
|
48
|
+
defaultvalue: 'null'
|
49
|
+
},
|
50
|
+
onDrop: {
|
51
|
+
name: 'onDrop',
|
52
|
+
type: {
|
53
|
+
name: 'function',
|
54
|
+
description:
|
55
|
+
'(acceptedFiles: File[], fileRejections: FileRejection[], event:DragEvent | Event) => void'
|
56
|
+
},
|
57
|
+
description: `
|
58
|
+
Callback for when the drop event occurs. Note that this callback is invoked after the getFilesFromEvent callback is done.
|
59
|
+
|
60
|
+
Files are accepted or rejected based on the accept, multiple, minSize and maxSize props. accept must be a valid MIME type according to input element specification or a valid file extension. If multiple is set to false and additional files are dropped, all files besides the first will be rejected. Any file which does not have a size in the minSize, maxSize range, will be rejected as well.
|
61
|
+
|
62
|
+
Note that the onDrop callback will always be invoked regardless if the dropped files were accepted or rejected. If you'd like to react to a specific scenario, use the onDropAccepted/onDropRejected props.
|
63
|
+
|
64
|
+
onDrop will provide you with an array of File objects which you can then process and send to a server. For example, with SuperAgent as a http/ajax library:
|
65
|
+
|
66
|
+
function onDrop(acceptedFiles) {
|
67
|
+
const req = request.post('/upload')
|
68
|
+
acceptedFiles.forEach(file => {
|
69
|
+
req.attach(file.name, file)
|
70
|
+
})
|
71
|
+
req.end(callback)
|
72
|
+
}
|
73
|
+
`
|
74
|
+
}
|
75
|
+
}
|
76
|
+
})
|
77
|
+
|
78
|
+
page
|
79
|
+
.createChapter()
|
80
|
+
.addExample('Dropzone/story/Default.example.tsx', 'Default') // picasso-skip-visuals
|
81
|
+
.addExample('Dropzone/story/Uploader.example.tsx', 'With upload') // picasso-skip-visuals
|
82
|
+
.addExample('Dropzone/story/Uploading.example.tsx', 'Uploading') // picasso-skip-visuals
|
83
|
+
.addExample('Dropzone/story/Disabled.example.tsx', 'Completed') // picasso-skip-visuals
|
84
|
+
.addExample('Dropzone/story/Multiple.example.tsx', 'Completed Multiple files') // picasso-skip-visuals
|
85
|
+
.addExample('Dropzone/story/Error.example.tsx', 'Upload Failed') // picasso-skip-visuals
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import { createStyles, Theme } from '@material-ui/core/styles'
|
2
|
+
|
3
|
+
export default ({ palette, sizes, transitions }: Theme) =>
|
4
|
+
createStyles({
|
5
|
+
root: {
|
6
|
+
padding: '20px',
|
7
|
+
borderWidth: sizes.borderWidth,
|
8
|
+
borderRadius: sizes.borderRadius.medium,
|
9
|
+
borderColor: palette.grey.light2,
|
10
|
+
borderStyle: 'dashed',
|
11
|
+
backgroundColor: palette.common.white,
|
12
|
+
color: palette.grey.dark,
|
13
|
+
outline: 'none',
|
14
|
+
transition: `all ${transitions.duration.short}ms ${transitions.easing.easeOut}`,
|
15
|
+
transitionProperty: 'border, background-color',
|
16
|
+
gap: '0.5rem',
|
17
|
+
'&:hover, &$hovered, &:focus, &$focused, &$dragActive': {
|
18
|
+
borderColor: palette.blue.main,
|
19
|
+
cursor: 'pointer'
|
20
|
+
},
|
21
|
+
'&$disabled': {
|
22
|
+
backgroundColor: palette.grey.lighter,
|
23
|
+
'&:hover': {
|
24
|
+
cursor: 'no-drop',
|
25
|
+
borderColor: palette.grey.light2
|
26
|
+
}
|
27
|
+
}
|
28
|
+
},
|
29
|
+
hint: {
|
30
|
+
margin: 0,
|
31
|
+
'& > *': {
|
32
|
+
lineHeight: '1rem'
|
33
|
+
}
|
34
|
+
},
|
35
|
+
completed: {},
|
36
|
+
error: {
|
37
|
+
margin: 0
|
38
|
+
},
|
39
|
+
dragActive: {},
|
40
|
+
hovered: {},
|
41
|
+
disabled: {},
|
42
|
+
focused: {}
|
43
|
+
})
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import { render } from '@toptal/picasso/test-utils'
|
3
|
+
import { OmitInternalProps } from '@toptal/picasso-shared'
|
4
|
+
|
5
|
+
import Dropzone, { Props } from './Dropzone'
|
6
|
+
|
7
|
+
const renderDropzone = (props: OmitInternalProps<Props>) =>
|
8
|
+
render(<Dropzone {...props} />)
|
9
|
+
|
10
|
+
describe('Dropzone', () => {
|
11
|
+
it('renders', () => {
|
12
|
+
const { queryByText, container } = renderDropzone({})
|
13
|
+
|
14
|
+
expect(queryByText('Click or drag file to upload')).toBeVisible()
|
15
|
+
expect(container).toMatchSnapshot()
|
16
|
+
})
|
17
|
+
|
18
|
+
it('shows error', () => {
|
19
|
+
const { queryByText } = renderDropzone({
|
20
|
+
errorMessages: ['error example'],
|
21
|
+
hint: 'hint example'
|
22
|
+
})
|
23
|
+
|
24
|
+
expect(queryByText('hint example')).not.toBeInTheDocument()
|
25
|
+
expect(queryByText('error example')).toBeVisible()
|
26
|
+
})
|
27
|
+
|
28
|
+
it('renders hint', () => {
|
29
|
+
const { queryByText } = renderDropzone({ hint: 'hint example' })
|
30
|
+
|
31
|
+
expect(queryByText('hint example')).toBeVisible()
|
32
|
+
})
|
33
|
+
})
|
@@ -0,0 +1,56 @@
|
|
1
|
+
export interface FileUpload {
|
2
|
+
uploading?: boolean
|
3
|
+
progress?: number
|
4
|
+
error?: string
|
5
|
+
file: File
|
6
|
+
}
|
7
|
+
|
8
|
+
export type DropzoneOptions = {
|
9
|
+
/**
|
10
|
+
* Set accepted file types. See https://github.com/okonet/attr-accept for more information.
|
11
|
+
*/
|
12
|
+
accept?: string | string[]
|
13
|
+
/** Enable/disable the dropzone */
|
14
|
+
disabled?: boolean
|
15
|
+
/** Maximum file size (in bytes) */
|
16
|
+
maxSize?: number
|
17
|
+
/** Minimum file size (in bytes) */
|
18
|
+
minSize?: number
|
19
|
+
/** Callback for when the drop event occurs */
|
20
|
+
onDrop?: <T extends File>(
|
21
|
+
acceptedFiles: T[],
|
22
|
+
fileRejections: FileRejection[],
|
23
|
+
event: DropEvent
|
24
|
+
) => void
|
25
|
+
/** Callback for when the drop event occurs */
|
26
|
+
onDropAccepted?: <T extends File>(files: T[], event: DropEvent) => void
|
27
|
+
/** Callback for when the drop event occurs */
|
28
|
+
onDropRejected?: (fileRejections: FileRejection[], event: DropEvent) => void
|
29
|
+
/** Custom validation function */
|
30
|
+
validator?: <T extends File>(file: T) => FileError | FileError[] | null
|
31
|
+
}
|
32
|
+
|
33
|
+
export type DropEvent =
|
34
|
+
| React.DragEvent<HTMLElement>
|
35
|
+
| React.ChangeEvent<HTMLInputElement>
|
36
|
+
| DragEvent
|
37
|
+
| Event
|
38
|
+
|
39
|
+
export const ErrorCode = {
|
40
|
+
FileInvalidType: 'file-invalid-type',
|
41
|
+
FileTooLarge: 'file-too-large',
|
42
|
+
FileTooSmall: 'file-too-small',
|
43
|
+
TooManyFiles: 'too-many-files'
|
44
|
+
} as const
|
45
|
+
|
46
|
+
type ErrorCodeType = typeof ErrorCode[keyof typeof ErrorCode]
|
47
|
+
|
48
|
+
export interface FileError {
|
49
|
+
message: string
|
50
|
+
code: ErrorCodeType | string
|
51
|
+
}
|
52
|
+
|
53
|
+
export interface FileRejection {
|
54
|
+
file: File
|
55
|
+
errors: FileError[]
|
56
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './EmptyState'
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import PicassoBook from '~/.storybook/components/PicassoBook'
|
2
|
+
import emptyStatePageStory from '../../EmptyStatePage/story'
|
3
|
+
import emptyStateCollectionStory from '../../EmptyStateCollection/story'
|
4
|
+
|
5
|
+
const page = PicassoBook.section('Picasso Lab').createPage('EmptyState')
|
6
|
+
|
7
|
+
page
|
8
|
+
.createTabChapter('Props')
|
9
|
+
.addComponentDocs(emptyStatePageStory.componentDocs)
|
10
|
+
.addComponentDocs(emptyStateCollectionStory.componentDocs)
|
11
|
+
|
12
|
+
page.connect(emptyStatePageStory.chapter)
|
13
|
+
page.connect(emptyStateCollectionStory.chapter)
|