@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,26 @@
|
|
1
|
+
import React, { useState } from 'react'
|
2
|
+
import { Form } from '@toptal/picasso'
|
3
|
+
import { DatePicker } from '@toptal/picasso-lab'
|
4
|
+
|
5
|
+
const DefaultExample = () => {
|
6
|
+
const [datepickerValue, setDatepickerValue] = useState<Date>()
|
7
|
+
|
8
|
+
return (
|
9
|
+
<div style={{ height: '50vh' }}>
|
10
|
+
<Form>
|
11
|
+
<Form.Field>
|
12
|
+
<Form.Label>Failed validation</Form.Label>
|
13
|
+
<DatePicker
|
14
|
+
value={datepickerValue}
|
15
|
+
error
|
16
|
+
onChange={date => {
|
17
|
+
setDatepickerValue(date as Date)
|
18
|
+
}}
|
19
|
+
/>
|
20
|
+
</Form.Field>
|
21
|
+
</Form>
|
22
|
+
</div>
|
23
|
+
)
|
24
|
+
}
|
25
|
+
|
26
|
+
export default DefaultExample
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import React, { useState } from 'react'
|
2
|
+
import { DatePicker } from '@toptal/picasso-lab'
|
3
|
+
|
4
|
+
const RangeExample = () => {
|
5
|
+
const [value, setValue] = useState<[Date, Date]>()
|
6
|
+
|
7
|
+
return (
|
8
|
+
<div style={{ height: '50vh' }}>
|
9
|
+
<DatePicker
|
10
|
+
range
|
11
|
+
value={value}
|
12
|
+
onChange={dates => {
|
13
|
+
const [start, end] = dates as [Date, Date]
|
14
|
+
|
15
|
+
setValue([start, end])
|
16
|
+
}}
|
17
|
+
/>
|
18
|
+
</div>
|
19
|
+
)
|
20
|
+
}
|
21
|
+
|
22
|
+
export default RangeExample
|
@@ -0,0 +1,47 @@
|
|
1
|
+
import React, { useState } from 'react'
|
2
|
+
import { Tooltip } from '@toptal/picasso'
|
3
|
+
import { DatePicker } from '@toptal/picasso-lab'
|
4
|
+
import { isBefore, isWithinInterval } from 'date-fns'
|
5
|
+
|
6
|
+
const WithCustomDayRendering = () => {
|
7
|
+
const [datepickerValue, setDatepickerValue] = useState(new Date('2015-12-12'))
|
8
|
+
|
9
|
+
const minDate = new Date('2015-12-07')
|
10
|
+
|
11
|
+
const disabledIntervals = [
|
12
|
+
{ start: new Date('2015-12-20'), end: new Date('2015-12-30') }
|
13
|
+
]
|
14
|
+
|
15
|
+
return (
|
16
|
+
<div style={{ height: '50vh' }}>
|
17
|
+
<DatePicker
|
18
|
+
value={datepickerValue}
|
19
|
+
minDate={minDate}
|
20
|
+
disabledIntervals={disabledIntervals}
|
21
|
+
renderDay={({ date, children, isSelectable }) => {
|
22
|
+
const day = new Date(date)
|
23
|
+
|
24
|
+
if (!isSelectable) {
|
25
|
+
if (isBefore(day, minDate)) {
|
26
|
+
return <Tooltip content='It is vacation time'>{children}</Tooltip>
|
27
|
+
}
|
28
|
+
const isWithinDisabledInterval = disabledIntervals.some(interval =>
|
29
|
+
isWithinInterval(day, interval)
|
30
|
+
)
|
31
|
+
|
32
|
+
if (isWithinDisabledInterval) {
|
33
|
+
return <Tooltip content='In a meeting'>{children}</Tooltip>
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
return children
|
38
|
+
}}
|
39
|
+
onChange={date => {
|
40
|
+
setDatepickerValue(date as Date)
|
41
|
+
}}
|
42
|
+
/>
|
43
|
+
</div>
|
44
|
+
)
|
45
|
+
}
|
46
|
+
|
47
|
+
export default WithCustomDayRendering
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import React, { useState } from 'react'
|
2
|
+
import { DatePicker } from '@toptal/picasso-lab'
|
3
|
+
|
4
|
+
const WithInitialValueExample = () => {
|
5
|
+
const [datepickerValue, setDatepickerValue] = useState(new Date(2019, 10, 10))
|
6
|
+
|
7
|
+
return (
|
8
|
+
<div style={{ height: '50vh' }}>
|
9
|
+
<DatePicker
|
10
|
+
value={datepickerValue}
|
11
|
+
onChange={date => {
|
12
|
+
setDatepickerValue(date as Date)
|
13
|
+
}}
|
14
|
+
/>
|
15
|
+
</div>
|
16
|
+
)
|
17
|
+
}
|
18
|
+
|
19
|
+
export default WithInitialValueExample
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import React, { useState } from 'react'
|
2
|
+
import { DatePicker } from '@toptal/picasso-lab'
|
3
|
+
import { Search16 } from '@toptal/picasso'
|
4
|
+
|
5
|
+
const WithInputPropsExample = () => {
|
6
|
+
const [value, setValue] = useState<Date>()
|
7
|
+
|
8
|
+
return (
|
9
|
+
<div style={{ height: '50vh', width: '100%' }}>
|
10
|
+
<DatePicker
|
11
|
+
value={value}
|
12
|
+
icon={<Search16 />}
|
13
|
+
iconPosition='end'
|
14
|
+
width='full'
|
15
|
+
placeholder='Please select date...'
|
16
|
+
onChange={date => {
|
17
|
+
setValue(date as Date)
|
18
|
+
}}
|
19
|
+
/>
|
20
|
+
</div>
|
21
|
+
)
|
22
|
+
}
|
23
|
+
|
24
|
+
export default WithInputPropsExample
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import React, { useState } from 'react'
|
2
|
+
import { DatePicker, DatePickerValue } from '@toptal/picasso-lab'
|
3
|
+
|
4
|
+
const WithNoHideOnSelect = () => {
|
5
|
+
const [datepickerValue, setDatepickerValue] = useState<DatePickerValue>()
|
6
|
+
|
7
|
+
return (
|
8
|
+
<div style={{ height: '50vh' }}>
|
9
|
+
<DatePicker
|
10
|
+
value={datepickerValue}
|
11
|
+
hideOnSelect={false}
|
12
|
+
onChange={(date: DatePickerValue) => {
|
13
|
+
setDatepickerValue(date)
|
14
|
+
}}
|
15
|
+
/>
|
16
|
+
</div>
|
17
|
+
)
|
18
|
+
}
|
19
|
+
|
20
|
+
export default WithNoHideOnSelect
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import React, { useState } from 'react'
|
2
|
+
import { DatePicker, DatePickerValue } from '@toptal/picasso-lab'
|
3
|
+
|
4
|
+
const WithOnBlurHandlerExample = () => {
|
5
|
+
const [datepickerValue, setDatepickerValue] = useState<DatePickerValue>()
|
6
|
+
|
7
|
+
return (
|
8
|
+
<div style={{ height: '50vh' }}>
|
9
|
+
<DatePicker
|
10
|
+
value={datepickerValue}
|
11
|
+
onBlur={() => {
|
12
|
+
// handle on blur
|
13
|
+
}}
|
14
|
+
onChange={(date: DatePickerValue) => {
|
15
|
+
setDatepickerValue(date)
|
16
|
+
}}
|
17
|
+
/>
|
18
|
+
</div>
|
19
|
+
)
|
20
|
+
}
|
21
|
+
|
22
|
+
export default WithOnBlurHandlerExample
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import React, { useState } from 'react'
|
2
|
+
import { DatePicker } from '@toptal/picasso-lab'
|
3
|
+
import { Search16 } from '@toptal/picasso'
|
4
|
+
|
5
|
+
const WithSelectionLimitsExample = () => {
|
6
|
+
const [value, setValue] = useState(new Date('2015-12-12'))
|
7
|
+
const minDate = new Date('2015-12-01')
|
8
|
+
const maxDate = new Date('2015-12-30')
|
9
|
+
const disabledIntervals = [
|
10
|
+
{ start: new Date('2015-12-03'), end: new Date('2015-12-08') },
|
11
|
+
{ start: new Date('2015-12-20'), end: new Date('2015-12-30') }
|
12
|
+
]
|
13
|
+
|
14
|
+
return (
|
15
|
+
<div style={{ height: '50vh', width: '100%' }}>
|
16
|
+
<DatePicker
|
17
|
+
value={value}
|
18
|
+
minDate={minDate}
|
19
|
+
maxDate={maxDate}
|
20
|
+
icon={<Search16 />}
|
21
|
+
iconPosition='end'
|
22
|
+
placeholder='Please select date...'
|
23
|
+
disabledIntervals={disabledIntervals}
|
24
|
+
onChange={date => {
|
25
|
+
setValue(date as Date)
|
26
|
+
}}
|
27
|
+
/>
|
28
|
+
</div>
|
29
|
+
)
|
30
|
+
}
|
31
|
+
|
32
|
+
export default WithSelectionLimitsExample
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import React, { useState } from 'react'
|
2
|
+
import { DatePicker } from '@toptal/picasso-lab'
|
3
|
+
import { Search16 } from '@toptal/picasso'
|
4
|
+
|
5
|
+
const WithTimezoneExample = () => {
|
6
|
+
const timezone = 'Asia/Tokyo'
|
7
|
+
const [value, setValue] = useState(new Date('2015-12-12T16:00:00'))
|
8
|
+
|
9
|
+
return (
|
10
|
+
<div style={{ height: '50vh', width: '100%' }}>
|
11
|
+
<DatePicker
|
12
|
+
value={value}
|
13
|
+
timezone={timezone}
|
14
|
+
icon={<Search16 />}
|
15
|
+
iconPosition='end'
|
16
|
+
placeholder='Please select date...'
|
17
|
+
onChange={date => {
|
18
|
+
setValue(date as Date)
|
19
|
+
}}
|
20
|
+
/>
|
21
|
+
</div>
|
22
|
+
)
|
23
|
+
}
|
24
|
+
|
25
|
+
export default WithTimezoneExample
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import { DatePicker } from '../DatePicker'
|
2
|
+
import PicassoBook from '~/.storybook/components/PicassoBook'
|
3
|
+
|
4
|
+
const page = PicassoBook.section('Picasso Lab').createPage(
|
5
|
+
'DatePicker',
|
6
|
+
`
|
7
|
+
Date Picker component
|
8
|
+
|
9
|
+
${PicassoBook.createBaseDocsLink(
|
10
|
+
'https://share.goabstract.com/cc5f669e-ee2c-4375-946d-93b20db16ecc?collectionLayerId=10d3230f-5c9c-4fed-85b2-5cfda0bcd25f&mode=design&present=true'
|
11
|
+
)}
|
12
|
+
`
|
13
|
+
)
|
14
|
+
|
15
|
+
page
|
16
|
+
.createTabChapter('Props')
|
17
|
+
.addComponentDocs({ component: DatePicker, name: 'DatePicker' })
|
18
|
+
|
19
|
+
page
|
20
|
+
.createChapter()
|
21
|
+
.addExample('DatePicker/story/Default.example.tsx', 'Default') // picasso-skip-visuals
|
22
|
+
.addExample('DatePicker/story/Range.example.tsx', 'Range Mode') // picasso-skip-visuals
|
23
|
+
.addExample('DatePicker/story/WithOnBlurHandler.example.tsx', {
|
24
|
+
title: 'With onBlur handler',
|
25
|
+
description: 'Fire onBlur handler on click outside or navigate with tab'
|
26
|
+
}) // picasso-skip-visuals
|
27
|
+
.addExample('DatePicker/story/WithNoHideOnSelect.example.tsx', {
|
28
|
+
title: 'With no hideOnSelect',
|
29
|
+
description: 'Do not hide calendar on date select'
|
30
|
+
}) // picasso-skip-visuals
|
31
|
+
.addExample(
|
32
|
+
'DatePicker/story/WithInitialValue.example.tsx',
|
33
|
+
'With initial value specified'
|
34
|
+
) // picasso-skip-visuals
|
35
|
+
.addExample('DatePicker/story/WithInputProps.example.tsx', 'With Input Props') // picasso-skip-visuals
|
36
|
+
.addExample('DatePicker/story/Autocomplete.example.tsx', 'Autocomplete') // picasso-skip-visuals
|
37
|
+
.addExample('DatePicker/story/Error.example.tsx', 'Error') // picasso-skip-visuals
|
38
|
+
.addExample(
|
39
|
+
'DatePicker/story/WithSelectionLimits.example.tsx',
|
40
|
+
'With Selection Limits'
|
41
|
+
) // picasso-skip-visuals
|
42
|
+
.addExample(
|
43
|
+
'DatePicker/story/WithCustomDayRendering.example.tsx',
|
44
|
+
'With Custom Day rendering'
|
45
|
+
) // picasso-skip-visuals
|
46
|
+
.addExample('DatePicker/story/WithTimezone.example.tsx', 'With Timezone') // picasso-skip-visuals
|
47
|
+
.addExample(
|
48
|
+
'DatePicker/story/AllowCustomValue.example.tsx',
|
49
|
+
'With custom value'
|
50
|
+
) // picasso-skip-visuals
|
@@ -0,0 +1,370 @@
|
|
1
|
+
/* eslint-disable max-lines-per-function */
|
2
|
+
import { Tooltip } from '@toptal/picasso'
|
3
|
+
import { act, fireEvent, render } from '@toptal/picasso/test-utils'
|
4
|
+
import React, { useState } from 'react'
|
5
|
+
|
6
|
+
import { DateOrDateRangeType } from '../Calendar'
|
7
|
+
import DatePicker, { Props } from './DatePicker'
|
8
|
+
import {
|
9
|
+
datePickerParseDateString,
|
10
|
+
DEFAULT_DATE_PICKER_EDIT_DATE_FORMAT
|
11
|
+
} from './'
|
12
|
+
|
13
|
+
// eslint-disable-next-line max-lines-per-function
|
14
|
+
describe('DatePicker', () => {
|
15
|
+
beforeAll(() => {
|
16
|
+
jest.useFakeTimers()
|
17
|
+
})
|
18
|
+
|
19
|
+
afterAll(() => {
|
20
|
+
jest.useRealTimers()
|
21
|
+
})
|
22
|
+
|
23
|
+
it('renders', () => {
|
24
|
+
const date = new Date('12-12-2019')
|
25
|
+
|
26
|
+
const { container } = render(
|
27
|
+
<DatePicker value={date} onChange={() => {}} />
|
28
|
+
)
|
29
|
+
|
30
|
+
expect(container).toMatchSnapshot()
|
31
|
+
})
|
32
|
+
|
33
|
+
it('custom day rendering', () => {
|
34
|
+
const date = new Date('12-12-2019')
|
35
|
+
|
36
|
+
const { getByPlaceholderText, getByText } = render(
|
37
|
+
<DatePicker
|
38
|
+
placeholder='dateInput'
|
39
|
+
value={date}
|
40
|
+
onChange={() => {}}
|
41
|
+
renderDay={({ key, children }) => (
|
42
|
+
<Tooltip key={key} content='tooltip content'>
|
43
|
+
{children}
|
44
|
+
</Tooltip>
|
45
|
+
)}
|
46
|
+
/>
|
47
|
+
)
|
48
|
+
|
49
|
+
const input = getByPlaceholderText('dateInput')
|
50
|
+
|
51
|
+
fireEvent.click(input)
|
52
|
+
|
53
|
+
const day15 = getByText(/15/)
|
54
|
+
|
55
|
+
fireEvent.mouseOver(day15)
|
56
|
+
|
57
|
+
act(() => {
|
58
|
+
// wait for tooltip's "enterDelay"
|
59
|
+
jest.advanceTimersByTime(600)
|
60
|
+
})
|
61
|
+
|
62
|
+
const tooltip = getByText('tooltip content')
|
63
|
+
|
64
|
+
expect(tooltip).toBeInTheDocument()
|
65
|
+
})
|
66
|
+
|
67
|
+
describe('Input', () => {
|
68
|
+
it('should display date in default displayDateFormat', () => {
|
69
|
+
const { getByPlaceholderText } = renderDatePicker()
|
70
|
+
|
71
|
+
expect(getByPlaceholderText(defaultProps.placeholder)).toHaveAttribute(
|
72
|
+
'value',
|
73
|
+
'Dec 24, 2020'
|
74
|
+
)
|
75
|
+
})
|
76
|
+
|
77
|
+
it('should display date in given displayDateFormat', () => {
|
78
|
+
const { getByPlaceholderText } = renderDatePicker({
|
79
|
+
...defaultProps,
|
80
|
+
displayDateFormat: 'MMM|d|yyyy'
|
81
|
+
})
|
82
|
+
|
83
|
+
expect(getByPlaceholderText(defaultProps.placeholder)).toHaveAttribute(
|
84
|
+
'value',
|
85
|
+
'Dec|24|2020'
|
86
|
+
)
|
87
|
+
})
|
88
|
+
|
89
|
+
it('should display date range in default displayDateFormat', () => {
|
90
|
+
const { getByPlaceholderText } = renderDatePicker({
|
91
|
+
...defaultProps,
|
92
|
+
range: true,
|
93
|
+
value: [new Date(2020, 11, 24), new Date(2020, 11, 27)]
|
94
|
+
})
|
95
|
+
|
96
|
+
expect(getByPlaceholderText(defaultProps.placeholder)).toHaveAttribute(
|
97
|
+
'value',
|
98
|
+
'Dec 24, 2020 - Dec 27, 2020'
|
99
|
+
)
|
100
|
+
})
|
101
|
+
|
102
|
+
it('should display date range in given displayDateFormat', () => {
|
103
|
+
const { getByPlaceholderText } = renderDatePicker({
|
104
|
+
...defaultProps,
|
105
|
+
range: true,
|
106
|
+
value: [new Date(2020, 11, 24), new Date(2020, 11, 27)],
|
107
|
+
displayDateFormat: 'MMM|d|yyyy'
|
108
|
+
})
|
109
|
+
|
110
|
+
expect(getByPlaceholderText(defaultProps.placeholder)).toHaveAttribute(
|
111
|
+
'value',
|
112
|
+
'Dec|24|2020 - Dec|27|2020'
|
113
|
+
)
|
114
|
+
})
|
115
|
+
|
116
|
+
it('should display date in default editDateFormat', () => {
|
117
|
+
const { getByPlaceholderText } = renderDatePicker()
|
118
|
+
const input = getByPlaceholderText(defaultProps.placeholder)
|
119
|
+
|
120
|
+
fireEvent.focus(input)
|
121
|
+
|
122
|
+
expect(input).toHaveAttribute('value', '12-24-2020')
|
123
|
+
})
|
124
|
+
|
125
|
+
it('should display date in given editDateFormat', () => {
|
126
|
+
const { getByPlaceholderText } = renderDatePicker({
|
127
|
+
...defaultProps,
|
128
|
+
editDateFormat: 'MM|dd|yyyy'
|
129
|
+
})
|
130
|
+
const input = getByPlaceholderText(defaultProps.placeholder)
|
131
|
+
|
132
|
+
fireEvent.focus(input)
|
133
|
+
|
134
|
+
expect(input).toHaveAttribute('value', '12|24|2020')
|
135
|
+
})
|
136
|
+
|
137
|
+
it('should turn autoComplete off by default', () => {
|
138
|
+
const { getByPlaceholderText } = renderDatePicker()
|
139
|
+
|
140
|
+
expect(getByPlaceholderText(defaultProps.placeholder)).toHaveAttribute(
|
141
|
+
'autocomplete',
|
142
|
+
'off'
|
143
|
+
)
|
144
|
+
})
|
145
|
+
|
146
|
+
it('should turn autoComplete on', () => {
|
147
|
+
const { getByPlaceholderText } = renderDatePicker({
|
148
|
+
...defaultProps,
|
149
|
+
autoComplete: 'on'
|
150
|
+
})
|
151
|
+
|
152
|
+
expect(getByPlaceholderText(defaultProps.placeholder)).toHaveAttribute(
|
153
|
+
'autocomplete',
|
154
|
+
'on'
|
155
|
+
)
|
156
|
+
})
|
157
|
+
|
158
|
+
it('should display date in given timezone', () => {
|
159
|
+
const { getByPlaceholderText } = renderDatePicker({
|
160
|
+
...defaultProps,
|
161
|
+
timezone: FAR_EAST_TIMEZONE,
|
162
|
+
value: new Date(2020, 6, 24, 18)
|
163
|
+
})
|
164
|
+
|
165
|
+
expect(getByPlaceholderText(defaultProps.placeholder)).toHaveAttribute(
|
166
|
+
'value',
|
167
|
+
`Jul 25, 2020`
|
168
|
+
)
|
169
|
+
})
|
170
|
+
|
171
|
+
it('should work within interval', () => {
|
172
|
+
const MIN_DATE = new Date(2020, 6, 10)
|
173
|
+
const MAX_DATE = new Date(2020, 6, 25)
|
174
|
+
|
175
|
+
const handleChange = jest.fn()
|
176
|
+
|
177
|
+
const { getByPlaceholderText } = renderDatePicker({
|
178
|
+
...defaultProps,
|
179
|
+
minDate: MIN_DATE,
|
180
|
+
maxDate: MAX_DATE,
|
181
|
+
onChange: handleChange
|
182
|
+
})
|
183
|
+
|
184
|
+
const input = getByPlaceholderText(defaultProps.placeholder)
|
185
|
+
|
186
|
+
fireEvent.change(input, { target: { value: '07-09-2020' } })
|
187
|
+
expect(handleChange).not.toHaveBeenCalled()
|
188
|
+
|
189
|
+
fireEvent.change(input, { target: { value: '07-26-2020' } })
|
190
|
+
expect(handleChange).not.toHaveBeenCalled()
|
191
|
+
|
192
|
+
fireEvent.change(input, { target: { value: '07-22-2020' } })
|
193
|
+
expect(handleChange).toHaveBeenCalledWith(new Date(2020, 6, 22))
|
194
|
+
|
195
|
+
// check min edge
|
196
|
+
fireEvent.change(input, { target: { value: '07-10-2020' } })
|
197
|
+
expect(handleChange).toHaveBeenCalledWith(new Date(2020, 6, 10))
|
198
|
+
|
199
|
+
// check max edge
|
200
|
+
fireEvent.change(input, { target: { value: '07-25-2020' } })
|
201
|
+
expect(handleChange).toHaveBeenCalledWith(new Date(2020, 6, 25))
|
202
|
+
})
|
203
|
+
|
204
|
+
it('should work with minDate only', () => {
|
205
|
+
const MIN_DATE = new Date(2020, 6, 10)
|
206
|
+
|
207
|
+
const handleChange = jest.fn()
|
208
|
+
|
209
|
+
const { getByPlaceholderText } = renderDatePicker({
|
210
|
+
...defaultProps,
|
211
|
+
minDate: MIN_DATE,
|
212
|
+
onChange: handleChange
|
213
|
+
})
|
214
|
+
|
215
|
+
const input = getByPlaceholderText(defaultProps.placeholder)
|
216
|
+
|
217
|
+
fireEvent.change(input, { target: { value: '07-09-2020' } })
|
218
|
+
expect(handleChange).not.toHaveBeenCalled()
|
219
|
+
|
220
|
+
fireEvent.change(input, { target: { value: '07-22-2020' } })
|
221
|
+
expect(handleChange).toHaveBeenCalledWith(new Date(2020, 6, 22))
|
222
|
+
|
223
|
+
// check min edge
|
224
|
+
fireEvent.change(input, { target: { value: '07-10-2020' } })
|
225
|
+
expect(handleChange).toHaveBeenCalledWith(new Date(2020, 6, 10))
|
226
|
+
})
|
227
|
+
|
228
|
+
it('should work with maxDate', () => {
|
229
|
+
const MAX_DATE = new Date(2020, 6, 25)
|
230
|
+
|
231
|
+
const handleChange = jest.fn()
|
232
|
+
|
233
|
+
const { getByPlaceholderText } = renderDatePicker({
|
234
|
+
...defaultProps,
|
235
|
+
maxDate: MAX_DATE,
|
236
|
+
onChange: handleChange
|
237
|
+
})
|
238
|
+
|
239
|
+
const input = getByPlaceholderText(defaultProps.placeholder)
|
240
|
+
|
241
|
+
fireEvent.change(input, { target: { value: '07-26-2020' } })
|
242
|
+
expect(handleChange).not.toHaveBeenCalled()
|
243
|
+
|
244
|
+
fireEvent.change(input, { target: { value: '07-22-2020' } })
|
245
|
+
expect(handleChange).toHaveBeenCalledWith(new Date(2020, 6, 22))
|
246
|
+
|
247
|
+
// check max edge
|
248
|
+
fireEvent.change(input, { target: { value: '07-25-2020' } })
|
249
|
+
expect(handleChange).toHaveBeenCalledWith(new Date(2020, 6, 25))
|
250
|
+
})
|
251
|
+
|
252
|
+
describe('should work with overwritten `parseInputValue`', () => {
|
253
|
+
const parseInputValue = (value: string) => {
|
254
|
+
const result = datePickerParseDateString(value, {
|
255
|
+
dateFormat: DEFAULT_DATE_PICKER_EDIT_DATE_FORMAT
|
256
|
+
})
|
257
|
+
|
258
|
+
return result ?? value
|
259
|
+
}
|
260
|
+
|
261
|
+
it('emits `string` if value is not a valid date', () => {
|
262
|
+
const handleChange = jest.fn()
|
263
|
+
|
264
|
+
const { getByPlaceholderText } = renderDatePicker({
|
265
|
+
...defaultProps,
|
266
|
+
parseInputValue,
|
267
|
+
onChange: handleChange
|
268
|
+
})
|
269
|
+
|
270
|
+
const input = getByPlaceholderText(defaultProps.placeholder)
|
271
|
+
|
272
|
+
fireEvent.change(input, { target: { value: 'some random text' } })
|
273
|
+
expect(handleChange).toHaveBeenCalledWith('some random text')
|
274
|
+
})
|
275
|
+
|
276
|
+
it('emits `Date` if value is a valid date', () => {
|
277
|
+
const handleChange = jest.fn()
|
278
|
+
|
279
|
+
const { getByPlaceholderText } = renderDatePicker({
|
280
|
+
...defaultProps,
|
281
|
+
parseInputValue,
|
282
|
+
onChange: handleChange
|
283
|
+
})
|
284
|
+
|
285
|
+
const input = getByPlaceholderText(defaultProps.placeholder)
|
286
|
+
|
287
|
+
fireEvent.change(input, { target: { value: '07-25-2020' } })
|
288
|
+
expect(handleChange).toHaveBeenCalledWith(new Date(2020, 6, 25))
|
289
|
+
})
|
290
|
+
|
291
|
+
it('opens `Calendar` on `Input` focus with invalid date', () => {
|
292
|
+
const handleChange = jest.fn()
|
293
|
+
|
294
|
+
const { getByPlaceholderText, getByTestId } = renderDatePicker({
|
295
|
+
...defaultProps,
|
296
|
+
parseInputValue,
|
297
|
+
value: 'some random text',
|
298
|
+
onChange: handleChange
|
299
|
+
})
|
300
|
+
|
301
|
+
const input = getByPlaceholderText(defaultProps.placeholder)
|
302
|
+
|
303
|
+
fireEvent.focus(input)
|
304
|
+
|
305
|
+
expect(getByTestId('calendar')).toBeInTheDocument()
|
306
|
+
})
|
307
|
+
|
308
|
+
it("doesn't clear `Input` after `blur` with invalid date", () => {
|
309
|
+
const placeholder = 'Pick a date'
|
310
|
+
const TestComponent = () => {
|
311
|
+
const [value, setValue] = useState<
|
312
|
+
string | DateOrDateRangeType | null
|
313
|
+
>(new Date(2020, 6, 25))
|
314
|
+
|
315
|
+
return (
|
316
|
+
<DatePicker
|
317
|
+
placeholder={placeholder}
|
318
|
+
parseInputValue={parseInputValue}
|
319
|
+
value={value}
|
320
|
+
onChange={setValue}
|
321
|
+
/>
|
322
|
+
)
|
323
|
+
}
|
324
|
+
|
325
|
+
const renderTestComponentPicker = () => render(<TestComponent />)
|
326
|
+
|
327
|
+
const { getByPlaceholderText } = renderTestComponentPicker()
|
328
|
+
|
329
|
+
const input = getByPlaceholderText(placeholder)
|
330
|
+
|
331
|
+
fireEvent.focus(input)
|
332
|
+
|
333
|
+
fireEvent.change(input, { target: { value: 'some random text' } })
|
334
|
+
|
335
|
+
fireEvent.blur(input)
|
336
|
+
|
337
|
+
expect(getByPlaceholderText(placeholder)).toHaveAttribute(
|
338
|
+
'value',
|
339
|
+
`some random text`
|
340
|
+
)
|
341
|
+
})
|
342
|
+
})
|
343
|
+
})
|
344
|
+
|
345
|
+
describe('Calendar', () => {
|
346
|
+
it('should display date in given timezone', () => {
|
347
|
+
const { getByPlaceholderText, getByTestId } = renderDatePicker({
|
348
|
+
...defaultProps,
|
349
|
+
timezone: FAR_EAST_TIMEZONE,
|
350
|
+
value: new Date(2020, 6, 24, 18)
|
351
|
+
})
|
352
|
+
|
353
|
+
fireEvent.focus(getByPlaceholderText(defaultProps.placeholder))
|
354
|
+
|
355
|
+
expect(getByTestId('day-button-selected')).toHaveTextContent('25')
|
356
|
+
})
|
357
|
+
})
|
358
|
+
|
359
|
+
const FAR_EAST_TIMEZONE = 'Asia/Tokyo'
|
360
|
+
|
361
|
+
const defaultProps = {
|
362
|
+
onChange: () => {},
|
363
|
+
value: new Date(2020, 11, 24),
|
364
|
+
placeholder: 'Pick a date'
|
365
|
+
}
|
366
|
+
|
367
|
+
const renderDatePicker = (props: Props = defaultProps) => {
|
368
|
+
return render(<DatePicker {...props} />)
|
369
|
+
}
|
370
|
+
})
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { DateOrDateRangeType } from '../Calendar'
|
2
|
+
|
3
|
+
export type DatePickerValue = DateOrDateRangeType | string | null
|
4
|
+
|
5
|
+
export type DatePickerStringParser = (
|
6
|
+
value: string,
|
7
|
+
params: {
|
8
|
+
dateFormat: string
|
9
|
+
timezone?: string
|
10
|
+
minDate?: Date
|
11
|
+
maxDate?: Date
|
12
|
+
}
|
13
|
+
) => DateOrDateRangeType | string | undefined
|