@pega/cosmos-react-demos 2.1.0 → 2.1.4
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/jsx/build/AppShell/AppShell.stories.d.ts.map +1 -1
- package/jsx/build/AppShell/AppShell.stories.jsx +4 -4
- package/jsx/build/AppShell/AppShell.stories.jsx.map +1 -1
- package/jsx/core/Avatar/Avatar.stories.d.ts.map +1 -1
- package/jsx/core/Avatar/Avatar.stories.jsx +2 -2
- package/jsx/core/Avatar/Avatar.stories.jsx.map +1 -1
- package/jsx/core/Banner/Banner.mocks.d.ts +18 -0
- package/jsx/core/Banner/Banner.mocks.d.ts.map +1 -0
- package/jsx/core/Banner/Banner.mocks.jsx +41 -0
- package/jsx/core/Banner/Banner.mocks.jsx.map +1 -0
- package/jsx/core/Banner/Banner.stories.d.ts.map +1 -1
- package/jsx/core/Banner/Banner.stories.jsx +1 -39
- package/jsx/core/Banner/Banner.stories.jsx.map +1 -1
- package/jsx/core/Button/Button.stories.d.ts.map +1 -1
- package/jsx/core/Button/Button.stories.jsx +3 -3
- package/jsx/core/Button/Button.stories.jsx.map +1 -1
- package/jsx/core/Configuration/Configuration.stories.jsx +1 -1
- package/jsx/core/Configuration/Configuration.stories.jsx.map +1 -1
- package/jsx/core/DateTime/DateTimeDisplay.stories.jsx +1 -0
- package/jsx/core/DateTime/DateTimeDisplay.stories.jsx.map +1 -1
- package/jsx/core/ExpandCollapse/ExpandCollapse.styles.d.ts.map +1 -1
- package/jsx/core/ExpandCollapse/ExpandCollapse.styles.js +5 -0
- package/jsx/core/ExpandCollapse/ExpandCollapse.styles.js.map +1 -1
- package/jsx/core/FieldGroup/FieldGroupList.mocks.d.ts +21 -0
- package/jsx/core/FieldGroup/FieldGroupList.mocks.d.ts.map +1 -0
- package/jsx/core/FieldGroup/FieldGroupList.mocks.jsx +36 -0
- package/jsx/core/FieldGroup/FieldGroupList.mocks.jsx.map +1 -0
- package/jsx/core/FieldGroup/FieldGroupList.stories.d.ts.map +1 -1
- package/jsx/core/FieldGroup/FieldGroupList.stories.jsx +1 -34
- package/jsx/core/FieldGroup/FieldGroupList.stories.jsx.map +1 -1
- package/jsx/core/File/FileDisplay.stories.d.ts +8 -1
- package/jsx/core/File/FileDisplay.stories.d.ts.map +1 -1
- package/jsx/core/File/FileDisplay.stories.jsx +37 -2
- package/jsx/core/File/FileDisplay.stories.jsx.map +1 -1
- package/jsx/core/Flex/Flex.styles.d.ts +2 -2
- package/jsx/core/Flex/Flex.styles.d.ts.map +1 -1
- package/jsx/core/Flex/Flex.styles.js +17 -17
- package/jsx/core/Flex/Flex.styles.js.map +1 -1
- package/jsx/core/Flex/FlexContainer.stories.d.ts +2 -0
- package/jsx/core/Flex/FlexContainer.stories.d.ts.map +1 -1
- package/jsx/core/Flex/FlexContainer.stories.jsx +45 -32
- package/jsx/core/Flex/FlexContainer.stories.jsx.map +1 -1
- package/jsx/core/Flex/FlexItem.stories.jsx +13 -13
- package/jsx/core/Flex/FlexItem.stories.jsx.map +1 -1
- package/jsx/core/Form/Form.mocks.d.ts +8 -0
- package/jsx/core/Form/Form.mocks.d.ts.map +1 -0
- package/jsx/core/Form/Form.mocks.jsx +138 -0
- package/jsx/core/Form/Form.mocks.jsx.map +1 -0
- package/jsx/core/Form/Form.stories.d.ts +0 -7
- package/jsx/core/Form/Form.stories.d.ts.map +1 -1
- package/jsx/core/Form/Form.stories.jsx +3 -137
- package/jsx/core/Form/Form.stories.jsx.map +1 -1
- package/jsx/core/Grid/Grid.styles.d.ts +2 -2
- package/jsx/core/Grid/Grid.styles.d.ts.map +1 -1
- package/jsx/core/Grid/Grid.styles.js +4 -4
- package/jsx/core/Grid/Grid.styles.js.map +1 -1
- package/jsx/core/Grid/GridContainer.stories.d.ts +6 -5
- package/jsx/core/Grid/GridContainer.stories.d.ts.map +1 -1
- package/jsx/core/Grid/GridContainer.stories.jsx +51 -44
- package/jsx/core/Grid/GridContainer.stories.jsx.map +1 -1
- package/jsx/core/Grid/GridItem.stories.d.ts +2 -2
- package/jsx/core/Grid/GridItem.stories.d.ts.map +1 -1
- package/jsx/core/Grid/GridItem.stories.jsx +28 -28
- package/jsx/core/Grid/GridItem.stories.jsx.map +1 -1
- package/jsx/core/Icon/Icon.mocks.d.ts +3 -0
- package/jsx/core/Icon/Icon.mocks.d.ts.map +1 -0
- package/jsx/core/Icon/Icon.mocks.jsx +9 -0
- package/jsx/core/Icon/Icon.mocks.jsx.map +1 -0
- package/jsx/core/Icon/Icon.stories.d.ts +1 -0
- package/jsx/core/Icon/Icon.stories.d.ts.map +1 -1
- package/jsx/core/Icon/Icon.stories.jsx +7 -1
- package/jsx/core/Icon/Icon.stories.jsx.map +1 -1
- package/jsx/core/IconPicker/IconPicker.stories.d.ts.map +1 -1
- package/jsx/core/IconPicker/IconPicker.stories.jsx +0 -1
- package/jsx/core/IconPicker/IconPicker.stories.jsx.map +1 -1
- package/jsx/core/Lightbox/Lightbox.mocks.d.ts +15 -0
- package/jsx/core/Lightbox/Lightbox.mocks.d.ts.map +1 -0
- package/jsx/core/Lightbox/Lightbox.mocks.js +59 -0
- package/jsx/core/Lightbox/Lightbox.mocks.js.map +1 -0
- package/jsx/core/Lightbox/Lightbox.stories.d.ts +7 -6
- package/jsx/core/Lightbox/Lightbox.stories.d.ts.map +1 -1
- package/jsx/core/Lightbox/Lightbox.stories.jsx +14 -65
- package/jsx/core/Lightbox/Lightbox.stories.jsx.map +1 -1
- package/jsx/core/Link/Link.stories.d.ts +11 -1
- package/jsx/core/Link/Link.stories.d.ts.map +1 -1
- package/jsx/core/Link/Link.stories.jsx +22 -5
- package/jsx/core/Link/Link.stories.jsx.map +1 -1
- package/jsx/core/List/CommaSeparatedList.stories.d.ts.map +1 -1
- package/jsx/core/List/CommaSeparatedList.stories.jsx +17 -19
- package/jsx/core/List/CommaSeparatedList.stories.jsx.map +1 -1
- package/jsx/core/List/OrderedList.stories.d.ts.map +1 -1
- package/jsx/core/List/OrderedList.stories.jsx +10 -10
- package/jsx/core/List/OrderedList.stories.jsx.map +1 -1
- package/jsx/core/List/UnorderedList.stories.d.ts.map +1 -1
- package/jsx/core/List/UnorderedList.stories.jsx +10 -10
- package/jsx/core/List/UnorderedList.stories.jsx.map +1 -1
- package/jsx/core/Menu/Menu.stories.d.ts +3 -3
- package/jsx/core/Menu/Menu.stories.d.ts.map +1 -1
- package/jsx/core/Menu/Menu.stories.jsx +8 -12
- package/jsx/core/Menu/Menu.stories.jsx.map +1 -1
- package/jsx/core/Modal/Modal.mocks.jsx +1 -1
- package/jsx/core/Modal/Modal.mocks.jsx.map +1 -1
- package/jsx/core/Number/Number.stories.jsx +1 -1
- package/jsx/core/Number/Number.stories.jsx.map +1 -1
- package/jsx/core/PageTemplates/PageTemplates.stories.d.ts +5 -2
- package/jsx/core/PageTemplates/PageTemplates.stories.d.ts.map +1 -1
- package/jsx/core/PageTemplates/PageTemplates.stories.jsx +3 -3
- package/jsx/core/PageTemplates/PageTemplates.stories.jsx.map +1 -1
- package/jsx/core/Paragraph/ParagraphDisplay.stories.jsx +3 -0
- package/jsx/core/Paragraph/ParagraphDisplay.stories.jsx.map +1 -1
- package/jsx/core/Popover/Popover.stories.d.ts +1 -2
- package/jsx/core/Popover/Popover.stories.d.ts.map +1 -1
- package/jsx/core/Popover/Popover.stories.jsx +35 -37
- package/jsx/core/Popover/Popover.stories.jsx.map +1 -1
- package/jsx/core/Rating/Rating.stories.d.ts +4 -1
- package/jsx/core/Rating/Rating.stories.d.ts.map +1 -1
- package/jsx/core/Rating/Rating.stories.jsx +3 -3
- package/jsx/core/Rating/Rating.stories.jsx.map +1 -1
- package/jsx/core/Sentiment/Sentiment.stories.d.ts.map +1 -1
- package/jsx/core/Sentiment/Sentiment.stories.jsx +6 -6
- package/jsx/core/Sentiment/Sentiment.stories.jsx.map +1 -1
- package/jsx/core/SummaryList/SummaryList.stories.jsx +1 -1
- package/jsx/core/SummaryList/SummaryList.stories.jsx.map +1 -1
- package/jsx/core/Toaster/Toaster.stories.d.ts.map +1 -1
- package/jsx/core/Toaster/Toaster.stories.jsx +8 -3
- package/jsx/core/Toaster/Toaster.stories.jsx.map +1 -1
- package/jsx/rte/Editor/Editor.stories.d.ts +3 -3
- package/jsx/rte/Editor/Editor.stories.d.ts.map +1 -1
- package/jsx/rte/Editor/Editor.stories.jsx +21 -23
- package/jsx/rte/Editor/Editor.stories.jsx.map +1 -1
- package/jsx/rte/RichTextEditor/RichTextEditor.stories.jsx +1 -1
- package/jsx/rte/RichTextEditor/RichTextEditor.stories.jsx.map +1 -1
- package/jsx/rte/RichTextEditor/RichTextViewer.stories.d.ts +1 -0
- package/jsx/rte/RichTextEditor/RichTextViewer.stories.d.ts.map +1 -1
- package/jsx/rte/RichTextEditor/RichTextViewer.stories.jsx +19 -2
- package/jsx/rte/RichTextEditor/RichTextViewer.stories.jsx.map +1 -1
- package/jsx/social/Chat/Chat.stories.d.ts +31 -22
- package/jsx/social/Chat/Chat.stories.d.ts.map +1 -1
- package/jsx/social/Chat/Chat.stories.jsx +106 -153
- package/jsx/social/Chat/Chat.stories.jsx.map +1 -1
- package/jsx/social/Feed/FeedNewPost.stories.jsx +1 -1
- package/jsx/social/Feed/FeedNewPost.stories.jsx.map +1 -1
- package/jsx/social/Feed/FeedPost.stories.jsx +1 -1
- package/jsx/social/Feed/FeedPost.stories.jsx.map +1 -1
- package/jsx/work/AppAnnouncement/AppAnnouncement.stories.d.ts.map +1 -1
- package/jsx/work/AppAnnouncement/AppAnnouncement.stories.jsx +6 -7
- package/jsx/work/AppAnnouncement/AppAnnouncement.stories.jsx.map +1 -1
- package/jsx/work/CaseView/FileService.mock.d.ts.map +1 -1
- package/jsx/work/CaseView/FileService.mock.jsx +6 -2
- package/jsx/work/CaseView/FileService.mock.jsx.map +1 -1
- package/jsx/work/Confirmation/Confirmation.stories.d.ts +1 -1
- package/jsx/work/Confirmation/Confirmation.stories.d.ts.map +1 -1
- package/jsx/work/Confirmation/Confirmation.stories.jsx +14 -3
- package/jsx/work/Confirmation/Confirmation.stories.jsx.map +1 -1
- package/jsx/work/Confirmation/Confirmation.styles.d.ts +2 -0
- package/jsx/work/Confirmation/Confirmation.styles.d.ts.map +1 -0
- package/jsx/work/Confirmation/Confirmation.styles.js +7 -0
- package/jsx/work/Confirmation/Confirmation.styles.js.map +1 -0
- package/jsx/work/SearchResults/SearchResults.stories.d.ts.map +1 -1
- package/jsx/work/SearchResults/SearchResults.stories.jsx +3 -9
- package/jsx/work/SearchResults/SearchResults.stories.jsx.map +1 -1
- package/jsx/work/SearchResults/SearchResults.styles.d.ts +5 -0
- package/jsx/work/SearchResults/SearchResults.styles.d.ts.map +1 -0
- package/jsx/work/SearchResults/SearchResults.styles.js +12 -0
- package/jsx/work/SearchResults/SearchResults.styles.js.map +1 -0
- package/jsx/work/Stakeholders/Stakeholders.mocks.d.ts +17 -0
- package/jsx/work/Stakeholders/Stakeholders.mocks.d.ts.map +1 -0
- package/jsx/work/Stakeholders/Stakeholders.mocks.jsx +32 -0
- package/jsx/work/Stakeholders/Stakeholders.mocks.jsx.map +1 -0
- package/jsx/work/Stakeholders/Stakeholders.stories.d.ts +2 -5
- package/jsx/work/Stakeholders/Stakeholders.stories.d.ts.map +1 -1
- package/jsx/work/Stakeholders/Stakeholders.stories.jsx +2 -30
- package/jsx/work/Stakeholders/Stakeholders.stories.jsx.map +1 -1
- package/jsx/work/Timeline/Timeline.stories.d.ts.map +1 -1
- package/jsx/work/Timeline/Timeline.stories.jsx +2 -2
- package/jsx/work/Timeline/Timeline.stories.jsx.map +1 -1
- package/lib/build/AppShell/AppShell.stories.d.ts.map +1 -1
- package/lib/build/AppShell/AppShell.stories.js +4 -4
- package/lib/build/AppShell/AppShell.stories.js.map +1 -1
- package/lib/core/Avatar/Avatar.stories.d.ts.map +1 -1
- package/lib/core/Avatar/Avatar.stories.js +2 -2
- package/lib/core/Avatar/Avatar.stories.js.map +1 -1
- package/lib/core/Banner/Banner.mocks.d.ts +18 -0
- package/lib/core/Banner/Banner.mocks.d.ts.map +1 -0
- package/lib/core/Banner/Banner.mocks.js +36 -0
- package/lib/core/Banner/Banner.mocks.js.map +1 -0
- package/lib/core/Banner/Banner.stories.d.ts.map +1 -1
- package/lib/core/Banner/Banner.stories.js +4 -33
- package/lib/core/Banner/Banner.stories.js.map +1 -1
- package/lib/core/Button/Button.stories.d.ts.map +1 -1
- package/lib/core/Button/Button.stories.js +2 -2
- package/lib/core/Button/Button.stories.js.map +1 -1
- package/lib/core/Configuration/Configuration.stories.js +1 -1
- package/lib/core/Configuration/Configuration.stories.js.map +1 -1
- package/lib/core/DateTime/DateTimeDisplay.stories.js +1 -0
- package/lib/core/DateTime/DateTimeDisplay.stories.js.map +1 -1
- package/lib/core/ExpandCollapse/ExpandCollapse.styles.d.ts.map +1 -1
- package/lib/core/ExpandCollapse/ExpandCollapse.styles.js +5 -0
- package/lib/core/ExpandCollapse/ExpandCollapse.styles.js.map +1 -1
- package/lib/core/FieldGroup/FieldGroupList.mocks.d.ts +21 -0
- package/lib/core/FieldGroup/FieldGroupList.mocks.d.ts.map +1 -0
- package/lib/core/FieldGroup/FieldGroupList.mocks.js +38 -0
- package/lib/core/FieldGroup/FieldGroupList.mocks.js.map +1 -0
- package/lib/core/FieldGroup/FieldGroupList.stories.d.ts.map +1 -1
- package/lib/core/FieldGroup/FieldGroupList.stories.js +1 -35
- package/lib/core/FieldGroup/FieldGroupList.stories.js.map +1 -1
- package/lib/core/File/FileDisplay.stories.d.ts +8 -1
- package/lib/core/File/FileDisplay.stories.d.ts.map +1 -1
- package/lib/core/File/FileDisplay.stories.js +32 -2
- package/lib/core/File/FileDisplay.stories.js.map +1 -1
- package/lib/core/Flex/Flex.styles.d.ts +2 -2
- package/lib/core/Flex/Flex.styles.d.ts.map +1 -1
- package/lib/core/Flex/Flex.styles.js +17 -17
- package/lib/core/Flex/Flex.styles.js.map +1 -1
- package/lib/core/Flex/FlexContainer.stories.d.ts +2 -0
- package/lib/core/Flex/FlexContainer.stories.d.ts.map +1 -1
- package/lib/core/Flex/FlexContainer.stories.js +10 -7
- package/lib/core/Flex/FlexContainer.stories.js.map +1 -1
- package/lib/core/Flex/FlexItem.stories.js +4 -4
- package/lib/core/Flex/FlexItem.stories.js.map +1 -1
- package/lib/core/Form/Form.mocks.d.ts +8 -0
- package/lib/core/Form/Form.mocks.d.ts.map +1 -0
- package/lib/core/Form/Form.mocks.js +97 -0
- package/lib/core/Form/Form.mocks.js.map +1 -0
- package/lib/core/Form/Form.stories.d.ts +0 -7
- package/lib/core/Form/Form.stories.d.ts.map +1 -1
- package/lib/core/Form/Form.stories.js +3 -95
- package/lib/core/Form/Form.stories.js.map +1 -1
- package/lib/core/Grid/Grid.styles.d.ts +2 -2
- package/lib/core/Grid/Grid.styles.d.ts.map +1 -1
- package/lib/core/Grid/Grid.styles.js +4 -4
- package/lib/core/Grid/Grid.styles.js.map +1 -1
- package/lib/core/Grid/GridContainer.stories.d.ts +6 -5
- package/lib/core/Grid/GridContainer.stories.d.ts.map +1 -1
- package/lib/core/Grid/GridContainer.stories.js +27 -24
- package/lib/core/Grid/GridContainer.stories.js.map +1 -1
- package/lib/core/Grid/GridItem.stories.d.ts +2 -2
- package/lib/core/Grid/GridItem.stories.d.ts.map +1 -1
- package/lib/core/Grid/GridItem.stories.js +10 -10
- package/lib/core/Grid/GridItem.stories.js.map +1 -1
- package/lib/core/Icon/Icon.mocks.d.ts +3 -0
- package/lib/core/Icon/Icon.mocks.d.ts.map +1 -0
- package/lib/core/Icon/Icon.mocks.js +10 -0
- package/lib/core/Icon/Icon.mocks.js.map +1 -0
- package/lib/core/Icon/Icon.stories.d.ts +1 -0
- package/lib/core/Icon/Icon.stories.d.ts.map +1 -1
- package/lib/core/Icon/Icon.stories.js +7 -1
- package/lib/core/Icon/Icon.stories.js.map +1 -1
- package/lib/core/IconPicker/IconPicker.stories.d.ts.map +1 -1
- package/lib/core/IconPicker/IconPicker.stories.js +0 -1
- package/lib/core/IconPicker/IconPicker.stories.js.map +1 -1
- package/lib/core/Lightbox/Lightbox.mocks.d.ts +15 -0
- package/lib/core/Lightbox/Lightbox.mocks.d.ts.map +1 -0
- package/lib/core/Lightbox/Lightbox.mocks.js +67 -0
- package/lib/core/Lightbox/Lightbox.mocks.js.map +1 -0
- package/lib/core/Lightbox/Lightbox.stories.d.ts +7 -6
- package/lib/core/Lightbox/Lightbox.stories.d.ts.map +1 -1
- package/lib/core/Lightbox/Lightbox.stories.js +14 -73
- package/lib/core/Lightbox/Lightbox.stories.js.map +1 -1
- package/lib/core/Link/Link.stories.d.ts +11 -1
- package/lib/core/Link/Link.stories.d.ts.map +1 -1
- package/lib/core/Link/Link.stories.js +7 -4
- package/lib/core/Link/Link.stories.js.map +1 -1
- package/lib/core/List/CommaSeparatedList.stories.d.ts.map +1 -1
- package/lib/core/List/CommaSeparatedList.stories.js +17 -17
- package/lib/core/List/CommaSeparatedList.stories.js.map +1 -1
- package/lib/core/List/OrderedList.stories.d.ts.map +1 -1
- package/lib/core/List/OrderedList.stories.js +10 -10
- package/lib/core/List/OrderedList.stories.js.map +1 -1
- package/lib/core/List/UnorderedList.stories.d.ts.map +1 -1
- package/lib/core/List/UnorderedList.stories.js +10 -10
- package/lib/core/List/UnorderedList.stories.js.map +1 -1
- package/lib/core/Menu/Menu.stories.d.ts +3 -3
- package/lib/core/Menu/Menu.stories.d.ts.map +1 -1
- package/lib/core/Menu/Menu.stories.js +8 -12
- package/lib/core/Menu/Menu.stories.js.map +1 -1
- package/lib/core/Modal/Modal.mocks.js +1 -1
- package/lib/core/Modal/Modal.mocks.js.map +1 -1
- package/lib/core/Number/Number.stories.js +1 -1
- package/lib/core/Number/Number.stories.js.map +1 -1
- package/lib/core/PageTemplates/PageTemplates.stories.d.ts +5 -2
- package/lib/core/PageTemplates/PageTemplates.stories.d.ts.map +1 -1
- package/lib/core/PageTemplates/PageTemplates.stories.js +3 -3
- package/lib/core/PageTemplates/PageTemplates.stories.js.map +1 -1
- package/lib/core/Paragraph/ParagraphDisplay.stories.js +3 -0
- package/lib/core/Paragraph/ParagraphDisplay.stories.js.map +1 -1
- package/lib/core/Popover/Popover.stories.d.ts +1 -2
- package/lib/core/Popover/Popover.stories.d.ts.map +1 -1
- package/lib/core/Popover/Popover.stories.js +24 -25
- package/lib/core/Popover/Popover.stories.js.map +1 -1
- package/lib/core/Rating/Rating.stories.d.ts +4 -1
- package/lib/core/Rating/Rating.stories.d.ts.map +1 -1
- package/lib/core/Rating/Rating.stories.js +3 -3
- package/lib/core/Rating/Rating.stories.js.map +1 -1
- package/lib/core/Sentiment/Sentiment.stories.d.ts.map +1 -1
- package/lib/core/Sentiment/Sentiment.stories.js +6 -6
- package/lib/core/Sentiment/Sentiment.stories.js.map +1 -1
- package/lib/core/SummaryList/SummaryList.stories.js +1 -1
- package/lib/core/SummaryList/SummaryList.stories.js.map +1 -1
- package/lib/core/Toaster/Toaster.stories.d.ts.map +1 -1
- package/lib/core/Toaster/Toaster.stories.js +8 -3
- package/lib/core/Toaster/Toaster.stories.js.map +1 -1
- package/lib/rte/Editor/Editor.stories.d.ts +3 -3
- package/lib/rte/Editor/Editor.stories.d.ts.map +1 -1
- package/lib/rte/Editor/Editor.stories.js +21 -23
- package/lib/rte/Editor/Editor.stories.js.map +1 -1
- package/lib/rte/RichTextEditor/RichTextEditor.stories.js +1 -1
- package/lib/rte/RichTextEditor/RichTextEditor.stories.js.map +1 -1
- package/lib/rte/RichTextEditor/RichTextViewer.stories.d.ts +1 -0
- package/lib/rte/RichTextEditor/RichTextViewer.stories.d.ts.map +1 -1
- package/lib/rte/RichTextEditor/RichTextViewer.stories.js +15 -2
- package/lib/rte/RichTextEditor/RichTextViewer.stories.js.map +1 -1
- package/lib/social/Chat/Chat.stories.d.ts +33 -22
- package/lib/social/Chat/Chat.stories.d.ts.map +1 -1
- package/lib/social/Chat/Chat.stories.js +102 -158
- package/lib/social/Chat/Chat.stories.js.map +1 -1
- package/lib/social/Feed/FeedNewPost.stories.js +1 -1
- package/lib/social/Feed/FeedNewPost.stories.js.map +1 -1
- package/lib/social/Feed/FeedPost.stories.js +1 -1
- package/lib/social/Feed/FeedPost.stories.js.map +1 -1
- package/lib/work/AppAnnouncement/AppAnnouncement.stories.d.ts.map +1 -1
- package/lib/work/AppAnnouncement/AppAnnouncement.stories.js +6 -7
- package/lib/work/AppAnnouncement/AppAnnouncement.stories.js.map +1 -1
- package/lib/work/CaseView/FileService.mock.d.ts.map +1 -1
- package/lib/work/CaseView/FileService.mock.js +6 -2
- package/lib/work/CaseView/FileService.mock.js.map +1 -1
- package/lib/work/Confirmation/Confirmation.stories.d.ts +1 -1
- package/lib/work/Confirmation/Confirmation.stories.d.ts.map +1 -1
- package/lib/work/Confirmation/Confirmation.stories.js +12 -4
- package/lib/work/Confirmation/Confirmation.stories.js.map +1 -1
- package/lib/work/Confirmation/Confirmation.styles.d.ts +2 -0
- package/lib/work/Confirmation/Confirmation.styles.d.ts.map +1 -0
- package/lib/work/Confirmation/Confirmation.styles.js +7 -0
- package/lib/work/Confirmation/Confirmation.styles.js.map +1 -0
- package/lib/work/SearchResults/SearchResults.stories.d.ts.map +1 -1
- package/lib/work/SearchResults/SearchResults.stories.js +3 -9
- package/lib/work/SearchResults/SearchResults.stories.js.map +1 -1
- package/lib/work/SearchResults/SearchResults.styles.d.ts +5 -0
- package/lib/work/SearchResults/SearchResults.styles.d.ts.map +1 -0
- package/lib/work/SearchResults/SearchResults.styles.js +12 -0
- package/lib/work/SearchResults/SearchResults.styles.js.map +1 -0
- package/lib/work/Stakeholders/Stakeholders.mocks.d.ts +22 -0
- package/lib/work/Stakeholders/Stakeholders.mocks.d.ts.map +1 -0
- package/lib/work/Stakeholders/Stakeholders.mocks.js +36 -0
- package/lib/work/Stakeholders/Stakeholders.mocks.js.map +1 -0
- package/lib/work/Stakeholders/Stakeholders.stories.d.ts +2 -5
- package/lib/work/Stakeholders/Stakeholders.stories.d.ts.map +1 -1
- package/lib/work/Stakeholders/Stakeholders.stories.js +3 -34
- package/lib/work/Stakeholders/Stakeholders.stories.js.map +1 -1
- package/lib/work/Timeline/Timeline.stories.d.ts.map +1 -1
- package/lib/work/Timeline/Timeline.stories.js +2 -2
- package/lib/work/Timeline/Timeline.stories.js.map +1 -1
- package/package.json +9 -9
|
@@ -1,16 +1,24 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { Button, Flex } from '@pega/cosmos-react-core';
|
|
2
4
|
import { Confirmation } from '@pega/cosmos-react-work';
|
|
3
5
|
import { FieldValueListDemo } from '@pega/cosmos-react-demos/lib/core/FieldValueList/FieldValueList.stories';
|
|
4
6
|
import { TaskListDemo } from '@pega/cosmos-react-demos/lib/work/Tasks/TaskList.stories';
|
|
7
|
+
import { StyledFlex } from './Confirmation.styles';
|
|
5
8
|
export default {
|
|
6
9
|
title: 'Work/Confirmation',
|
|
7
10
|
component: Confirmation
|
|
8
11
|
};
|
|
9
|
-
export const ConfirmationDemo = (
|
|
10
|
-
|
|
12
|
+
export const ConfirmationDemo = (args) => {
|
|
13
|
+
const [showConfirmation, setShowConfirmation] = useState(true);
|
|
14
|
+
return (_jsxs(Flex, { as: StyledFlex, container: { justify: 'center', alignItems: 'center' }, children: [showConfirmation && (_jsx(Confirmation, { title: args.title, details: _jsx(FieldValueListDemo, { name: 'Project', value: 'Pega Cosmos', fields: [] }, void 0), whatsNext: [
|
|
15
|
+
'Send references',
|
|
16
|
+
'Collect information on the case',
|
|
17
|
+
'Prepare a demonstration'
|
|
18
|
+
], tasks: _jsx(TaskListDemo, {}, void 0), onClose: () => setShowConfirmation(false) }, void 0)), !showConfirmation && (_jsx(Button, { onClick: () => setShowConfirmation(true), children: "Show confirmation" }, void 0))] }, void 0));
|
|
11
19
|
};
|
|
12
20
|
ConfirmationDemo.args = {
|
|
13
|
-
title: 'US-
|
|
21
|
+
title: 'US-1337 confirmation'
|
|
14
22
|
};
|
|
15
23
|
ConfirmationDemo.argTypes = {
|
|
16
24
|
title: { control: { type: 'text' } }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Confirmation.stories.js","sourceRoot":"","sources":["../../../src/work/Confirmation/Confirmation.stories.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"Confirmation.stories.js","sourceRoot":"","sources":["../../../src/work/Confirmation/Confirmation.stories.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGjC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAqB,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yEAAyE,CAAC;AAC7G,OAAO,EAAE,YAAY,EAAE,MAAM,0DAA0D,CAAC;AAExF,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,eAAe;IACb,KAAK,EAAE,mBAAmB;IAC1B,SAAS,EAAE,YAAY;CAChB,CAAC;AAMV,MAAM,CAAC,MAAM,gBAAgB,GAAkC,CAAC,IAA4B,EAAE,EAAE;IAC9F,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAE/D,OAAO,CACL,MAAC,IAAI,IAAC,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,aACzE,gBAAgB,IAAI,CACnB,KAAC,YAAY,IACX,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,OAAO,EAAE,KAAC,kBAAkB,IAAC,IAAI,EAAC,SAAS,EAAC,KAAK,EAAC,aAAa,EAAC,MAAM,EAAE,EAAE,WAAI,EAC9E,SAAS,EAAE;oBACT,iBAAiB;oBACjB,iCAAiC;oBACjC,yBAAyB;iBAC1B,EACD,KAAK,EAAE,KAAC,YAAY,aAAG,EACvB,OAAO,EAAE,GAAG,EAAE,CAAC,mBAAmB,CAAC,KAAK,CAAC,WACzC,CACH,EACA,CAAC,gBAAgB,IAAI,CACpB,KAAC,MAAM,IAAC,OAAO,EAAE,GAAG,EAAE,CAAC,mBAAmB,CAAC,IAAI,CAAC,0CAA4B,CAC7E,YACI,CACR,CAAC;AACJ,CAAC,CAAC;AAEF,gBAAgB,CAAC,IAAI,GAAG;IACtB,KAAK,EAAE,sBAAsB;CAC9B,CAAC;AAEF,gBAAgB,CAAC,QAAQ,GAAG;IAC1B,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE;CACrC,CAAC","sourcesContent":["import { useState } from 'react';\nimport { Meta, Story } from '@storybook/react';\n\nimport { Button, Flex } from '@pega/cosmos-react-core';\nimport { Confirmation, ConfirmationProps } from '@pega/cosmos-react-work';\nimport { FieldValueListDemo } from '@pega/cosmos-react-demos/lib/core/FieldValueList/FieldValueList.stories';\nimport { TaskListDemo } from '@pega/cosmos-react-demos/lib/work/Tasks/TaskList.stories';\n\nimport { StyledFlex } from './Confirmation.styles';\n\nexport default {\n title: 'Work/Confirmation',\n component: Confirmation\n} as Meta;\n\ninterface ConfirmationStoryProps {\n title: ConfirmationProps['title'];\n}\n\nexport const ConfirmationDemo: Story<ConfirmationStoryProps> = (args: ConfirmationStoryProps) => {\n const [showConfirmation, setShowConfirmation] = useState(true);\n\n return (\n <Flex as={StyledFlex} container={{ justify: 'center', alignItems: 'center' }}>\n {showConfirmation && (\n <Confirmation\n title={args.title}\n details={<FieldValueListDemo name='Project' value='Pega Cosmos' fields={[]} />}\n whatsNext={[\n 'Send references',\n 'Collect information on the case',\n 'Prepare a demonstration'\n ]}\n tasks={<TaskListDemo />}\n onClose={() => setShowConfirmation(false)}\n />\n )}\n {!showConfirmation && (\n <Button onClick={() => setShowConfirmation(true)}>Show confirmation</Button>\n )}\n </Flex>\n );\n};\n\nConfirmationDemo.args = {\n title: 'US-1337 confirmation'\n};\n\nConfirmationDemo.argTypes = {\n title: { control: { type: 'text' } }\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Confirmation.styles.d.ts","sourceRoot":"","sources":["../../../src/work/Confirmation/Confirmation.styles.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,yGAItB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Confirmation.styles.js","sourceRoot":"","sources":["../../../src/work/Confirmation/Confirmation.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAEvC,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAA;;;;CAInC,CAAC","sourcesContent":["import styled from 'styled-components';\n\nexport const StyledFlex = styled.div`\n article {\n width: 100%;\n }\n`;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchResults.stories.d.ts","sourceRoot":"","sources":["../../../src/work/SearchResults/SearchResults.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;;
|
|
1
|
+
{"version":3,"file":"SearchResults.stories.d.ts","sourceRoot":"","sources":["../../../src/work/SearchResults/SearchResults.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;;AAgB/C,wBAMU;AAIV,UAAU,uBAAuB;IAC/B,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,uBAAuB,CA8O5D,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useState, useMemo } from 'react';
|
|
3
|
-
import
|
|
4
|
-
import { Status, OneColumnPage, Text, Flex, defaultThemeProp } from '@pega/cosmos-react-core';
|
|
3
|
+
import { Status, OneColumnPage, Text, Flex } from '@pega/cosmos-react-core';
|
|
5
4
|
import { CasePreview, SearchResults } from '@pega/cosmos-react-work';
|
|
6
5
|
import { AppShellDemo } from '@pega/cosmos-react-demos/lib/core/AppShell/AppShell.stories';
|
|
7
6
|
import { getInitialResults, initialFilters } from './SearchResults.mocks';
|
|
7
|
+
import { ColoredText, StyledSearchResults } from './SearchResults.styles';
|
|
8
8
|
export default {
|
|
9
9
|
title: 'Work/SearchResults',
|
|
10
10
|
component: SearchResults,
|
|
@@ -12,12 +12,6 @@ export default {
|
|
|
12
12
|
layout: 'fullscreen'
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
|
-
const ColoredText = styled.span(({ colorVariant, theme: { base: { palette } } }) => {
|
|
16
|
-
return css `
|
|
17
|
-
color: ${palette[colorVariant]};
|
|
18
|
-
`;
|
|
19
|
-
});
|
|
20
|
-
ColoredText.defaultProps = defaultThemeProp;
|
|
21
15
|
export const SearchResultsDemo = (args) => {
|
|
22
16
|
const [preview, setPreview] = useState();
|
|
23
17
|
const [previewTabId, setPreviewTabId] = useState();
|
|
@@ -178,7 +172,7 @@ export const SearchResultsDemo = (args) => {
|
|
|
178
172
|
return result;
|
|
179
173
|
});
|
|
180
174
|
};
|
|
181
|
-
const searchResults = (_jsxs(_Fragment, { children: [_jsx(OneColumnPage, { title: 'Search results', a: _jsx(SearchResults, { results: limit < results.length
|
|
175
|
+
const searchResults = (_jsxs(_Fragment, { children: [_jsx(OneColumnPage, { as: StyledSearchResults, title: 'Search results', a: _jsx(SearchResults, { results: limit < results.length
|
|
182
176
|
? renderForDisplay(results.slice(0, limit))
|
|
183
177
|
: renderForDisplay(results), searchInputProps: { value: search, onSearchChange: setSearch }, count: results.length, filters: filters, onFilterChange: handleFilterChange, onClearAllFilters: clearAllFilters, onClearFilter: handleClearFilter, onShowMore: limit < results.length ? handleShowMore : undefined }, void 0) }, void 0), _jsx(CasePreview, { open: !!preview, caseId: preview?.id || '', heading: preview?.title || '', tabs: {
|
|
184
178
|
items: [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchResults.stories.js","sourceRoot":"","sources":["../../../src/work/SearchResults/SearchResults.stories.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EACL,MAAM,EAEN,aAAa,EACb,IAAI,EACJ,IAAI,EACJ,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,WAAW,EACX,aAAa,EAId,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,6DAA6D,CAAC;AAE3F,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE1E,eAAe;IACb,KAAK,EAAE,oBAAoB;IAC3B,SAAS,EAAE,aAAa;IACxB,UAAU,EAAE;QACV,MAAM,EAAE,YAAY;KACrB;CACM,CAAC;AAQV,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAC7B,CAAC,EACC,YAAY,EACZ,KAAK,EAAE,EACL,IAAI,EAAE,EAAE,OAAO,EAAE,EAClB,EACF,EAAE,EAAE;IACH,OAAO,GAAG,CAAA;eACC,OAAO,CAAC,YAAY,CAAC;KAC/B,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,WAAW,CAAC,YAAY,GAAG,gBAAgB,CAAC;AAE5C,MAAM,CAAC,MAAM,iBAAiB,GAAmC,CAC/D,IAA6B,EAC7B,EAAE;IACF,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,EAA0B,CAAC;IACjE,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,EAAsB,CAAC;IACvE,MAAM,cAAc,GAAG,OAAO,C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AAC;AAEF,iBAAiB,CAAC,QAAQ,GAAG;IAC3B,YAAY,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE;CAC/C,CAAC","sourcesContent":["import { Meta, Story } from '@storybook/react';\nimport { useEffect, useState, useMemo } from 'react';\nimport styled, { css } from 'styled-components';\n\nimport {\n Status,\n OmitStrict,\n OneColumnPage,\n Text,\n Flex,\n defaultThemeProp\n} from '@pega/cosmos-react-core';\nimport {\n CasePreview,\n SearchResults,\n SearchResultsProps,\n FilterEvent,\n SearchResultProps\n} from '@pega/cosmos-react-work';\nimport { AppShellDemo } from '@pega/cosmos-react-demos/lib/core/AppShell/AppShell.stories';\n\nimport { getInitialResults, initialFilters } from './SearchResults.mocks';\n\nexport default {\n title: 'Work/SearchResults',\n component: SearchResults,\n parameters: {\n layout: 'fullscreen'\n }\n} as Meta;\n\ntype ResultMeta = OmitStrict<SearchResultProps, 'link'>;\n\ninterface SearchResultsStoryProps {\n withAppShell?: boolean;\n}\n\nconst ColoredText = styled.span<{ colorVariant: 'warn' | 'urgent' }>(\n ({\n colorVariant,\n theme: {\n base: { palette }\n }\n }) => {\n return css`\n color: ${palette[colorVariant]};\n `;\n }\n);\n\nColoredText.defaultProps = defaultThemeProp;\n\nexport const SearchResultsDemo: Story<SearchResultsStoryProps> = (\n args: SearchResultsStoryProps\n) => {\n const [preview, setPreview] = useState<undefined | ResultMeta>();\n const [previewTabId, setPreviewTabId] = useState<undefined | string>();\n const initialResults = useMemo(() => getInitialResults(setPreview, setPreviewTabId), []);\n const [results, setResults] = useState(initialResults);\n const [filters, setFilters] = useState(initialFilters);\n const [search, setSearch] = useState('');\n const [limit, setLimit] = useState(2);\n\n useEffect(() => {\n const activeFilters = filters.flatMap(group => {\n if (group.type === 'select') {\n return group.items.flatMap(item => {\n if (item.checked) {\n return {\n id: item.id,\n name: item.name,\n groupName: group.name\n };\n }\n return [];\n });\n }\n return [];\n });\n\n if (activeFilters.length > 0 || search !== '') {\n setResults(() => {\n const filteredResults = initialResults.filter(result => {\n const statusFilterActive = activeFilters.findIndex(x => x.groupName === 'Status') !== -1;\n const lastUpdatedFilterActive =\n activeFilters.findIndex(x => x.groupName === 'Last updated') !== -1;\n\n let matchesStatusFilter = !statusFilterActive;\n let matchesLastUpdatedFilter = !lastUpdatedFilterActive;\n\n activeFilters.forEach(filter => {\n result.meta?.forEach(tag => {\n if (tag) {\n if (!matchesStatusFilter && filter.groupName === 'Status' && tag === filter.name) {\n matchesStatusFilter = true;\n }\n if (\n !matchesLastUpdatedFilter &&\n filter.groupName === 'Last updated' &&\n typeof tag === 'string' &&\n ((filter.name === 'Today' && Date.parse(tag) >= Date.parse('01/01/21')) ||\n (filter.name === 'Yesterday' && Date.parse(tag) >= Date.parse('12/31/20')) ||\n (filter.name === 'Last 7 days' && Date.parse(tag) >= Date.parse('12/25/20')) ||\n (filter.name === 'Last 30 days' && Date.parse(tag) >= Date.parse('12/01/20')))\n ) {\n matchesLastUpdatedFilter = true;\n }\n }\n });\n });\n\n return matchesStatusFilter && matchesLastUpdatedFilter;\n });\n\n return filteredResults.filter(result => {\n if (\n result &&\n (result.description?.toLowerCase().includes(search.toLowerCase()) ||\n result.title.toLowerCase().includes(search.toLowerCase()) ||\n result.id.toLowerCase().includes(search.toLowerCase()))\n ) {\n return true;\n }\n\n return false;\n });\n });\n } else {\n setResults([]);\n }\n }, [search, filters]);\n\n const handleFilterChange = (changeEvent: FilterEvent) => {\n setFilters(curr => {\n return curr.map(filter => {\n const newFilter = { ...filter };\n if (\n newFilter.name === changeEvent.name &&\n changeEvent.type === 'select' &&\n newFilter.type === 'select'\n ) {\n newFilter.items = newFilter.items.map(item => {\n const newItem = { ...item };\n if (item.id === changeEvent.value.id) newItem.checked = changeEvent.value.checked;\n else if (newFilter.selectType === 'single-select') newItem.checked = false;\n return newItem;\n });\n }\n return newFilter;\n });\n });\n };\n\n const clearAllFilters = () => {\n setFilters(curr => {\n return curr.map(filter => {\n if (filter.type === 'select') {\n filter.items = filter.items.map(item => {\n item.checked = false;\n return item;\n });\n }\n return filter;\n });\n });\n };\n\n const handleClearFilter = (filterName: string) => {\n setFilters(curr => {\n return curr.map(filter => {\n if (filter.name === filterName && filter.type === 'select') {\n filter.items = filter.items.map(item => {\n item.checked = false;\n return item;\n });\n }\n return filter;\n });\n });\n };\n\n const handleShowMore = () => {\n if (limit < results.length) setLimit(curr => curr + 2);\n };\n\n const renderForDisplay = (\n resultsToDisplay: SearchResultsProps['results']\n ): SearchResultsProps['results'] => {\n return resultsToDisplay.map(result => {\n if (result.meta) {\n const metaValues = [...result.meta];\n const renderedMeta = metaValues.map(item => {\n if (!Number.isNaN(Date.parse(item as string))) {\n if (\n Date.parse(item as string) >= Date.parse('12/01/20') &&\n Date.parse(item as string) < Date.parse('12/25/20')\n )\n return 'Updated 1 month ago';\n if (\n Date.parse(item as string) >= Date.parse('12/25/20') &&\n Date.parse(item as string) < Date.parse('12/31/20')\n )\n return 'Updated 1 week ago';\n if (\n Date.parse(item as string) >= Date.parse('12/31/20') &&\n Date.parse(item as string) < Date.parse('01/01/21')\n )\n return 'Updated yesterday';\n if (\n Date.parse(item as string) >= Date.parse('01/01/21') &&\n Date.parse(item as string) < Date.parse('01/01/21 07:00:00')\n )\n return 'Updated today';\n return 'Updated just now';\n }\n switch (item) {\n case 'Completed':\n return <Status variant='success'>Completed</Status>;\n case 'Ready':\n return <Status variant='info'>Ready</Status>;\n case 'Pending':\n return <Status variant='pending'>Pending</Status>;\n case 'Blocked':\n return <Status variant='urgent'>Blocked</Status>;\n case 'Low priority':\n return <Text variant='secondary'>Low priority</Text>;\n case 'Medium priority':\n return (\n <Text as={ColoredText} colorVariant='warn' variant='secondary'>\n Medium priority\n </Text>\n );\n case 'High priority':\n return (\n <Text as={ColoredText} colorVariant='urgent' variant='secondary'>\n High priority\n </Text>\n );\n default:\n return item;\n }\n });\n return { ...result, meta: renderedMeta };\n }\n return result;\n });\n };\n\n const searchResults = (\n <>\n <OneColumnPage\n title='Search results'\n a={\n <SearchResults\n results={\n limit < results.length\n ? renderForDisplay(results.slice(0, limit))\n : renderForDisplay(results)\n }\n searchInputProps={{ value: search, onSearchChange: setSearch }}\n count={results.length}\n filters={filters}\n onFilterChange={handleFilterChange}\n onClearAllFilters={clearAllFilters}\n onClearFilter={handleClearFilter}\n onShowMore={limit < results.length ? handleShowMore : undefined}\n />\n }\n />\n\n <CasePreview\n open={!!preview}\n caseId={preview?.id || ''}\n heading={preview?.title || ''}\n tabs={{\n items: [],\n currentTabId: previewTabId || '',\n onClick: (id: string) => setPreviewTabId(id)\n }}\n followed\n summary={preview && <Flex container={{ pad: 2 }}>{preview.description}</Flex>}\n onBeforeClose={() => {\n setPreview(undefined);\n }}\n />\n </>\n );\n\n return args.withAppShell ? <AppShellDemo appHeader main={searchResults} /> : searchResults;\n};\n\nSearchResultsDemo.args = {\n withAppShell: false\n};\n\nSearchResultsDemo.argTypes = {\n withAppShell: { control: { type: 'boolean' } }\n};\n"]}
|
|
1
|
+
{"version":3,"file":"SearchResults.stories.js","sourceRoot":"","sources":["../../../src/work/SearchResults/SearchResults.stories.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAErD,OAAO,EAAE,MAAM,EAAc,aAAa,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AACxF,OAAO,EACL,WAAW,EACX,aAAa,EAId,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,6DAA6D,CAAC;AAE3F,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC1E,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAE1E,eAAe;IACb,KAAK,EAAE,oBAAoB;IAC3B,SAAS,EAAE,aAAa;IACxB,UAAU,EAAE;QACV,MAAM,EAAE,YAAY;KACrB;CACM,CAA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,CAAC,CAAC;gBACxB,CAAC,WACD,YACD,CACJ,CAAC;IAEF,OAAO,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,KAAC,YAAY,IAAC,SAAS,QAAC,IAAI,EAAE,aAAa,WAAI,CAAC,CAAC,CAAC,aAAa,CAAC;AAC7F,CAAC,CAAC;AAEF,iBAAiB,CAAC,IAAI,GAAG;IACvB,YAAY,EAAE,KAAK;CACpB,CAAC;AAEF,iBAAiB,CAAC,QAAQ,GAAG;IAC3B,YAAY,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE;CAC/C,CAAC","sourcesContent":["import { Meta, Story } from '@storybook/react';\nimport { useEffect, useState, useMemo } from 'react';\n\nimport { Status, OmitStrict, OneColumnPage, Text, Flex } from '@pega/cosmos-react-core';\nimport {\n CasePreview,\n SearchResults,\n SearchResultsProps,\n FilterEvent,\n SearchResultProps\n} from '@pega/cosmos-react-work';\nimport { AppShellDemo } from '@pega/cosmos-react-demos/lib/core/AppShell/AppShell.stories';\n\nimport { getInitialResults, initialFilters } from './SearchResults.mocks';\nimport { ColoredText, StyledSearchResults } from './SearchResults.styles';\n\nexport default {\n title: 'Work/SearchResults',\n component: SearchResults,\n parameters: {\n layout: 'fullscreen'\n }\n} as Meta;\n\ntype ResultMeta = OmitStrict<SearchResultProps, 'link'>;\n\ninterface SearchResultsStoryProps {\n withAppShell?: boolean;\n}\n\nexport const SearchResultsDemo: Story<SearchResultsStoryProps> = (\n args: SearchResultsStoryProps\n) => {\n const [preview, setPreview] = useState<undefined | ResultMeta>();\n const [previewTabId, setPreviewTabId] = useState<undefined | string>();\n const initialResults = useMemo(() => getInitialResults(setPreview, setPreviewTabId), []);\n const [results, setResults] = useState(initialResults);\n const [filters, setFilters] = useState(initialFilters);\n const [search, setSearch] = useState('');\n const [limit, setLimit] = useState(2);\n\n useEffect(() => {\n const activeFilters = filters.flatMap(group => {\n if (group.type === 'select') {\n return group.items.flatMap(item => {\n if (item.checked) {\n return {\n id: item.id,\n name: item.name,\n groupName: group.name\n };\n }\n return [];\n });\n }\n return [];\n });\n\n if (activeFilters.length > 0 || search !== '') {\n setResults(() => {\n const filteredResults = initialResults.filter(result => {\n const statusFilterActive = activeFilters.findIndex(x => x.groupName === 'Status') !== -1;\n const lastUpdatedFilterActive =\n activeFilters.findIndex(x => x.groupName === 'Last updated') !== -1;\n\n let matchesStatusFilter = !statusFilterActive;\n let matchesLastUpdatedFilter = !lastUpdatedFilterActive;\n\n activeFilters.forEach(filter => {\n result.meta?.forEach(tag => {\n if (tag) {\n if (!matchesStatusFilter && filter.groupName === 'Status' && tag === filter.name) {\n matchesStatusFilter = true;\n }\n if (\n !matchesLastUpdatedFilter &&\n filter.groupName === 'Last updated' &&\n typeof tag === 'string' &&\n ((filter.name === 'Today' && Date.parse(tag) >= Date.parse('01/01/21')) ||\n (filter.name === 'Yesterday' && Date.parse(tag) >= Date.parse('12/31/20')) ||\n (filter.name === 'Last 7 days' && Date.parse(tag) >= Date.parse('12/25/20')) ||\n (filter.name === 'Last 30 days' && Date.parse(tag) >= Date.parse('12/01/20')))\n ) {\n matchesLastUpdatedFilter = true;\n }\n }\n });\n });\n\n return matchesStatusFilter && matchesLastUpdatedFilter;\n });\n\n return filteredResults.filter(result => {\n if (\n result &&\n (result.description?.toLowerCase().includes(search.toLowerCase()) ||\n result.title.toLowerCase().includes(search.toLowerCase()) ||\n result.id.toLowerCase().includes(search.toLowerCase()))\n ) {\n return true;\n }\n\n return false;\n });\n });\n } else {\n setResults([]);\n }\n }, [search, filters]);\n\n const handleFilterChange = (changeEvent: FilterEvent) => {\n setFilters(curr => {\n return curr.map(filter => {\n const newFilter = { ...filter };\n if (\n newFilter.name === changeEvent.name &&\n changeEvent.type === 'select' &&\n newFilter.type === 'select'\n ) {\n newFilter.items = newFilter.items.map(item => {\n const newItem = { ...item };\n if (item.id === changeEvent.value.id) newItem.checked = changeEvent.value.checked;\n else if (newFilter.selectType === 'single-select') newItem.checked = false;\n return newItem;\n });\n }\n return newFilter;\n });\n });\n };\n\n const clearAllFilters = () => {\n setFilters(curr => {\n return curr.map(filter => {\n if (filter.type === 'select') {\n filter.items = filter.items.map(item => {\n item.checked = false;\n return item;\n });\n }\n return filter;\n });\n });\n };\n\n const handleClearFilter = (filterName: string) => {\n setFilters(curr => {\n return curr.map(filter => {\n if (filter.name === filterName && filter.type === 'select') {\n filter.items = filter.items.map(item => {\n item.checked = false;\n return item;\n });\n }\n return filter;\n });\n });\n };\n\n const handleShowMore = () => {\n if (limit < results.length) setLimit(curr => curr + 2);\n };\n\n const renderForDisplay = (\n resultsToDisplay: SearchResultsProps['results']\n ): SearchResultsProps['results'] => {\n return resultsToDisplay.map(result => {\n if (result.meta) {\n const metaValues = [...result.meta];\n const renderedMeta = metaValues.map(item => {\n if (!Number.isNaN(Date.parse(item as string))) {\n if (\n Date.parse(item as string) >= Date.parse('12/01/20') &&\n Date.parse(item as string) < Date.parse('12/25/20')\n )\n return 'Updated 1 month ago';\n if (\n Date.parse(item as string) >= Date.parse('12/25/20') &&\n Date.parse(item as string) < Date.parse('12/31/20')\n )\n return 'Updated 1 week ago';\n if (\n Date.parse(item as string) >= Date.parse('12/31/20') &&\n Date.parse(item as string) < Date.parse('01/01/21')\n )\n return 'Updated yesterday';\n if (\n Date.parse(item as string) >= Date.parse('01/01/21') &&\n Date.parse(item as string) < Date.parse('01/01/21 07:00:00')\n )\n return 'Updated today';\n return 'Updated just now';\n }\n switch (item) {\n case 'Completed':\n return <Status variant='success'>Completed</Status>;\n case 'Ready':\n return <Status variant='info'>Ready</Status>;\n case 'Pending':\n return <Status variant='pending'>Pending</Status>;\n case 'Blocked':\n return <Status variant='urgent'>Blocked</Status>;\n case 'Low priority':\n return <Text variant='secondary'>Low priority</Text>;\n case 'Medium priority':\n return (\n <Text as={ColoredText} colorVariant='warn' variant='secondary'>\n Medium priority\n </Text>\n );\n case 'High priority':\n return (\n <Text as={ColoredText} colorVariant='urgent' variant='secondary'>\n High priority\n </Text>\n );\n default:\n return item;\n }\n });\n return { ...result, meta: renderedMeta };\n }\n return result;\n });\n };\n\n const searchResults = (\n <>\n <OneColumnPage\n as={StyledSearchResults}\n title='Search results'\n a={\n <SearchResults\n results={\n limit < results.length\n ? renderForDisplay(results.slice(0, limit))\n : renderForDisplay(results)\n }\n searchInputProps={{ value: search, onSearchChange: setSearch }}\n count={results.length}\n filters={filters}\n onFilterChange={handleFilterChange}\n onClearAllFilters={clearAllFilters}\n onClearFilter={handleClearFilter}\n onShowMore={limit < results.length ? handleShowMore : undefined}\n />\n }\n />\n\n <CasePreview\n open={!!preview}\n caseId={preview?.id || ''}\n heading={preview?.title || ''}\n tabs={{\n items: [],\n currentTabId: previewTabId || '',\n onClick: (id: string) => setPreviewTabId(id)\n }}\n followed\n summary={preview && <Flex container={{ pad: 2 }}>{preview.description}</Flex>}\n onBeforeClose={() => {\n setPreview(undefined);\n }}\n />\n </>\n );\n\n return args.withAppShell ? <AppShellDemo appHeader main={searchResults} /> : searchResults;\n};\n\nSearchResultsDemo.args = {\n withAppShell: false\n};\n\nSearchResultsDemo.argTypes = {\n withAppShell: { control: { type: 'boolean' } }\n};\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const StyledSearchResults: import("styled-components").StyledComponent<"div", import("styled-components").DefaultTheme, {}, never>;
|
|
2
|
+
export declare const ColoredText: import("styled-components").StyledComponent<"span", import("styled-components").DefaultTheme, {
|
|
3
|
+
colorVariant: 'warn' | 'urgent';
|
|
4
|
+
}, never>;
|
|
5
|
+
//# sourceMappingURL=SearchResults.styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchResults.styles.d.ts","sourceRoot":"","sources":["../../../src/work/SearchResults/SearchResults.styles.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,mBAAmB,yGAE/B,CAAC;AAEF,eAAO,MAAM,WAAW;kBAA+B,MAAM,GAAG,QAAQ;SAWvE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components';
|
|
2
|
+
import { defaultThemeProp } from '@pega/cosmos-react-core';
|
|
3
|
+
export const StyledSearchResults = styled.div `
|
|
4
|
+
height: 100vh;
|
|
5
|
+
`;
|
|
6
|
+
export const ColoredText = styled.span(({ colorVariant, theme: { base: { palette } } }) => {
|
|
7
|
+
return css `
|
|
8
|
+
color: ${palette[colorVariant]};
|
|
9
|
+
`;
|
|
10
|
+
});
|
|
11
|
+
ColoredText.defaultProps = defaultThemeProp;
|
|
12
|
+
//# sourceMappingURL=SearchResults.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchResults.styles.js","sourceRoot":"","sources":["../../../src/work/SearchResults/SearchResults.styles.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,GAAG,CAAA;;CAE5C,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CACpC,CAAC,EACC,YAAY,EACZ,KAAK,EAAE,EACL,IAAI,EAAE,EAAE,OAAO,EAAE,EAClB,EACF,EAAE,EAAE;IACH,OAAO,GAAG,CAAA;eACC,OAAO,CAAC,YAAY,CAAC;KAC/B,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,WAAW,CAAC,YAAY,GAAG,gBAAgB,CAAC","sourcesContent":["import styled, { css } from 'styled-components';\n\nimport { defaultThemeProp } from '@pega/cosmos-react-core';\n\nexport const StyledSearchResults = styled.div`\n height: 100vh;\n`;\n\nexport const ColoredText = styled.span<{ colorVariant: 'warn' | 'urgent' }>(\n ({\n colorVariant,\n theme: {\n base: { palette }\n }\n }) => {\n return css`\n color: ${palette[colorVariant]};\n `;\n }\n);\n\nColoredText.defaultProps = defaultThemeProp;\n"]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
2
|
+
import { Role, StakeholdersProps, Stakeholder } from '@pega/cosmos-react-work';
|
|
3
|
+
interface MockStakeholderObject extends Stakeholder {
|
|
4
|
+
role?: Role;
|
|
5
|
+
data?: StakeholdersProps['form']['rendererProps'];
|
|
6
|
+
}
|
|
7
|
+
export declare const mockNetworkReq: () => Promise<unknown>;
|
|
8
|
+
export declare const mockRoles: NonNullable<StakeholdersProps['form']>['roles'];
|
|
9
|
+
/**
|
|
10
|
+
* A component that will be rendered internally by Stakeholders when adding or editing.
|
|
11
|
+
* If roles exists, the component will be passed the selected role as a prop.
|
|
12
|
+
* The return content of this will likely be a dynamically rendered view.
|
|
13
|
+
*/
|
|
14
|
+
export declare const AddAndEditForm: ({ selectedRoleName, firstName, lastName, email }: {
|
|
15
|
+
selectedRoleName?: string | undefined;
|
|
16
|
+
firstName?: string | undefined;
|
|
17
|
+
lastName?: string | undefined;
|
|
18
|
+
email?: string | undefined;
|
|
19
|
+
}) => JSX.Element;
|
|
20
|
+
export declare const useMockStakeholders: (cb: () => void) => [MockStakeholderObject[], Dispatch<SetStateAction<MockStakeholderObject[]>>];
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=Stakeholders.mocks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Stakeholders.mocks.d.ts","sourceRoot":"","sources":["../../../src/work/Stakeholders/Stakeholders.mocks.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAY,MAAM,OAAO,CAAC;AAG3D,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAG/E,UAAU,qBAAsB,SAAQ,WAAW;IACjD,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,IAAI,CAAC,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC,eAAe,CAAC,CAAC;CACnD;AAED,eAAO,MAAM,cAAc,wBAA0D,CAAC;AAMtF,eAAO,MAAM,SAAS,EAAE,WAAW,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAQrE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc;;;;;iBA2B1B,CAAC;AAEF,eAAO,MAAM,mBAAmB,OAC1B,MAAM,IAAI,KACb,CAAC,qBAAqB,EAAE,EAAE,SAAS,eAAe,qBAAqB,EAAE,CAAC,CAAC,CAiB7E,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { Input, Grid, FieldGroup } from '@pega/cosmos-react-core';
|
|
4
|
+
import { useMockListData } from '@pega/cosmos-react-demos/lib/core/SummaryList/SummaryList.mocks';
|
|
5
|
+
export const mockNetworkReq = () => new Promise(resolve => setTimeout(resolve, 2000));
|
|
6
|
+
// Mock total count of Stakeholder resource.
|
|
7
|
+
const count = Math.floor(Math.random() * 50) + 1;
|
|
8
|
+
// Mock stakeholder roles.
|
|
9
|
+
export const mockRoles = Array.from({ length: 3 }, (_, i) => ({
|
|
10
|
+
name: `Role-${i + 1}`,
|
|
11
|
+
description: `This is a description of Role-${i + 1}. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam sit amet dolor a mauris imperdiet convallis.`
|
|
12
|
+
}));
|
|
13
|
+
/**
|
|
14
|
+
* A component that will be rendered internally by Stakeholders when adding or editing.
|
|
15
|
+
* If roles exists, the component will be passed the selected role as a prop.
|
|
16
|
+
* The return content of this will likely be a dynamically rendered view.
|
|
17
|
+
*/
|
|
18
|
+
export const AddAndEditForm = ({ selectedRoleName, firstName, lastName, email }) => {
|
|
19
|
+
const inputs = (_jsxs(Grid, { container: { cols: '1fr', gap: 2 }, children: [_jsx(Input, { label: 'First name', required: true, defaultValue: firstName }, void 0), _jsx(Input, { label: 'Last name', required: true, defaultValue: lastName }, void 0), _jsx(Input, { type: 'email', label: 'Email', required: true, defaultValue: email }, void 0), _jsx(Input, { label: 'Job title', defaultValue: firstName ? 'Vice president' : undefined }, void 0)] }, void 0));
|
|
20
|
+
return selectedRoleName ? (_jsx(FieldGroup, { name: `Fields for: ${selectedRoleName}`, children: inputs }, void 0)) : (inputs);
|
|
21
|
+
};
|
|
22
|
+
export const useMockStakeholders = (cb) => {
|
|
23
|
+
const [mockStakeholders, setMockStakeholders] = useState([]);
|
|
24
|
+
// Grab some mock data...
|
|
25
|
+
const [mockListData] = useMockListData(() => {
|
|
26
|
+
setMockStakeholders(mockListData);
|
|
27
|
+
cb();
|
|
28
|
+
}, { count });
|
|
29
|
+
return [
|
|
30
|
+
mockStakeholders.map(stakeholder => {
|
|
31
|
+
return { ...stakeholder, role: stakeholder.role ?? mockRoles[0] };
|
|
32
|
+
}),
|
|
33
|
+
setMockStakeholders
|
|
34
|
+
];
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=Stakeholders.mocks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Stakeholders.mocks.js","sourceRoot":"","sources":["../../../src/work/Stakeholders/Stakeholders.mocks.tsx"],"names":[],"mappings":";AAAA,OAAO,EAA4B,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE3D,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAElE,OAAO,EAAE,eAAe,EAAE,MAAM,iEAAiE,CAAC;AAOlG,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,EAAE,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;AAEtF,4CAA4C;AAC5C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,GA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,mBAAmB,CAAC,GAAG,QAAQ,CAA0B,EAAE,CAAC,CAAC;IACtF,yBAAyB;IACzB,MAAM,CAAC,YAAY,CAAC,GAAG,eAAe,CACpC,GAAG,EAAE;QACH,mBAAmB,CAAC,YAAY,CAAC,CAAC;QAClC,EAAE,EAAE,CAAC;IACP,CAAC,EACD,EAAE,KAAK,EAAE,CACV,CAAC;IAEF,OAAO;QACL,gBAAgB,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE;YACjC,OAAO,EAAE,GAAG,WAAW,EAAE,IAAI,EAAE,WAAW,CAAC,IAAI,IAAI,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;QACpE,CAAC,CAAC;QACF,mBAAmB;KACpB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { Dispatch, SetStateAction, useState } from 'react';\n\nimport { Input, Grid, FieldGroup } from '@pega/cosmos-react-core';\nimport { Role, StakeholdersProps, Stakeholder } from '@pega/cosmos-react-work';\nimport { useMockListData } from '@pega/cosmos-react-demos/lib/core/SummaryList/SummaryList.mocks';\n\ninterface MockStakeholderObject extends Stakeholder {\n role?: Role;\n data?: StakeholdersProps['form']['rendererProps'];\n}\n\nexport const mockNetworkReq = () => new Promise(resolve => setTimeout(resolve, 2000));\n\n// Mock total count of Stakeholder resource.\nconst count = Math.floor(Math.random() * 50) + 1;\n\n// Mock stakeholder roles.\nexport const mockRoles: NonNullable<StakeholdersProps['form']>['roles'] = Array.from(\n { length: 3 },\n (_, i) => ({\n name: `Role-${i + 1}`,\n description: `This is a description of Role-${\n i + 1\n }. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam sit amet dolor a mauris imperdiet convallis.`\n })\n);\n\n/**\n * A component that will be rendered internally by Stakeholders when adding or editing.\n * If roles exists, the component will be passed the selected role as a prop.\n * The return content of this will likely be a dynamically rendered view.\n */\nexport const AddAndEditForm = ({\n selectedRoleName,\n firstName,\n lastName,\n email\n}: {\n // Cosmos will pass the selectedRoleName\n selectedRoleName?: Role['name'];\n // Any prop passed to rendererProps will be forwarded here\n firstName?: string;\n lastName?: string;\n email?: string;\n}) => {\n const inputs = (\n <Grid container={{ cols: '1fr', gap: 2 }}>\n <Input label='First name' required defaultValue={firstName} />\n <Input label='Last name' required defaultValue={lastName} />\n <Input type='email' label='Email' required defaultValue={email} />\n <Input label='Job title' defaultValue={firstName ? 'Vice president' : undefined} />\n </Grid>\n );\n\n return selectedRoleName ? (\n <FieldGroup name={`Fields for: ${selectedRoleName}`}>{inputs}</FieldGroup>\n ) : (\n inputs\n );\n};\n\nexport const useMockStakeholders = (\n cb: () => void\n): [MockStakeholderObject[], Dispatch<SetStateAction<MockStakeholderObject[]>>] => {\n const [mockStakeholders, setMockStakeholders] = useState<MockStakeholderObject[]>([]);\n // Grab some mock data...\n const [mockListData] = useMockListData(\n () => {\n setMockStakeholders(mockListData);\n cb();\n },\n { count }\n );\n\n return [\n mockStakeholders.map(stakeholder => {\n return { ...stakeholder, role: stakeholder.role ?? mockRoles[0] };\n }),\n setMockStakeholders\n ];\n};\n"]}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
3
|
-
declare const _default:
|
|
4
|
-
title: string;
|
|
5
|
-
component: import("react").FunctionComponent<StakeholdersProps & import("@pega/cosmos-react-core").ForwardProps>;
|
|
6
|
-
};
|
|
2
|
+
import { Meta } from '@storybook/react';
|
|
3
|
+
declare const _default: Meta<import("@storybook/react").Args>;
|
|
7
4
|
export default _default;
|
|
8
5
|
export declare const StakeHoldersDemo: () => JSX.Element;
|
|
9
6
|
//# sourceMappingURL=Stakeholders.stories.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Stakeholders.stories.d.ts","sourceRoot":"","sources":["../../../src/work/Stakeholders/Stakeholders.stories.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"Stakeholders.stories.d.ts","sourceRoot":"","sources":["../../../src/work/Stakeholders/Stakeholders.stories.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;;AAYxC,wBAGU;AAEV,eAAO,MAAM,gBAAgB,mBA8H5B,CAAC"}
|
|
@@ -1,44 +1,13 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
3
3
|
import { action } from '@storybook/addon-actions';
|
|
4
|
-
import {
|
|
4
|
+
import { createStringMatcher } from '@pega/cosmos-react-core';
|
|
5
5
|
import { Stakeholders } from '@pega/cosmos-react-work';
|
|
6
|
-
import {
|
|
6
|
+
import { AddAndEditForm, mockNetworkReq, mockRoles, useMockStakeholders } from './Stakeholders.mocks';
|
|
7
7
|
export default {
|
|
8
8
|
title: 'Work/Stakeholders',
|
|
9
9
|
component: Stakeholders
|
|
10
10
|
};
|
|
11
|
-
const mockNetworkReq = () => new Promise(resolve => setTimeout(resolve, 2000));
|
|
12
|
-
// Mock total count of Stakeholder resource.
|
|
13
|
-
const count = Math.floor(Math.random() * 50) + 1;
|
|
14
|
-
// Mock stakeholder roles.
|
|
15
|
-
const mockRoles = Array.from({ length: 3 }, (_, i) => ({
|
|
16
|
-
name: `Role-${i + 1}`,
|
|
17
|
-
description: `This is a description of Role-${i + 1}. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam sit amet dolor a mauris imperdiet convallis.`
|
|
18
|
-
}));
|
|
19
|
-
/**
|
|
20
|
-
* A component that will be rendered internally by Stakeholders when adding or editing.
|
|
21
|
-
* If roles exists, the component will be passed the selected role as a prop.
|
|
22
|
-
* The return content of this will likely be a dynamically rendered view.
|
|
23
|
-
*/
|
|
24
|
-
const AddAndEditForm = ({ selectedRoleName, firstName, lastName, email }) => {
|
|
25
|
-
const inputs = (_jsxs(Grid, { container: { cols: '1fr', gap: 2 }, children: [_jsx(Input, { label: 'First name', required: true, defaultValue: firstName }, void 0), _jsx(Input, { label: 'Last name', required: true, defaultValue: lastName }, void 0), _jsx(Input, { type: 'email', label: 'Email', required: true, defaultValue: email }, void 0), _jsx(Input, { label: 'Job title', defaultValue: firstName ? 'Vice president' : undefined }, void 0)] }, void 0));
|
|
26
|
-
return selectedRoleName ? (_jsx(FieldGroup, { name: `Fields for: ${selectedRoleName}`, children: inputs }, void 0)) : (inputs);
|
|
27
|
-
};
|
|
28
|
-
const useMockStakeholders = (cb) => {
|
|
29
|
-
const [mockStakeholders, setMockStakeholders] = useState([]);
|
|
30
|
-
// Grab some mock data...
|
|
31
|
-
const [mockListData] = useMockListData(() => {
|
|
32
|
-
setMockStakeholders(mockListData);
|
|
33
|
-
cb();
|
|
34
|
-
}, { count });
|
|
35
|
-
return [
|
|
36
|
-
mockStakeholders.map(stakeholder => {
|
|
37
|
-
return { ...stakeholder, role: stakeholder.role ?? mockRoles[0] };
|
|
38
|
-
}),
|
|
39
|
-
setMockStakeholders
|
|
40
|
-
];
|
|
41
|
-
};
|
|
42
11
|
export const StakeHoldersDemo = () => {
|
|
43
12
|
const [loading, setLoading] = useState(true);
|
|
44
13
|
const [mode, setMode] = useState();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Stakeholders.stories.js","sourceRoot":"","sources":["../../../src/work/Stakeholders/Stakeholders.stories.tsx"],"names":[],"mappings":";AAAA,OAAO,EAA4B,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5F,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAElD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AACvF,OAAO,EAAE,YAAY,EAAwC,MAAM,yBAAyB,CAAC;AAC7F,OAAO,EAAE,eAAe,EAAE,MAAM,iEAAiE,CAAC;AAElG,eAAe;IACb,KAAK,EAAE,mBAAmB;IAC1B,SAAS,EAAE,YAAY;CACxB,CAAC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,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;QACxD,CAAC,EACD,OAAO,EAAE,OAAO,WAChB,CACH,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { Dispatch, SetStateAction, useCallback, useEffect, useMemo, useState } from 'react';\nimport { action } from '@storybook/addon-actions';\n\nimport { Input, Grid, FieldGroup, createStringMatcher } from '@pega/cosmos-react-core';\nimport { Stakeholders, StakeholdersProps, Role, Stakeholder } from '@pega/cosmos-react-work';\nimport { useMockListData } from '@pega/cosmos-react-demos/lib/core/SummaryList/SummaryList.mocks';\n\nexport default {\n title: 'Work/Stakeholders',\n component: Stakeholders\n};\n\ninterface MockStakeholderObject extends Stakeholder {\n role?: Role;\n data?: StakeholdersProps['form']['rendererProps'];\n}\n\nconst mockNetworkReq = () => new Promise(resolve => setTimeout(resolve, 2000));\n\n// Mock total count of Stakeholder resource.\nconst count = Math.floor(Math.random() * 50) + 1;\n\n// Mock stakeholder roles.\nconst mockRoles: NonNullable<StakeholdersProps['form']>['roles'] = Array.from(\n { length: 3 },\n (_, i) => ({\n name: `Role-${i + 1}`,\n description: `This is a description of Role-${\n i + 1\n }. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam sit amet dolor a mauris imperdiet convallis.`\n })\n);\n\n/**\n * A component that will be rendered internally by Stakeholders when adding or editing.\n * If roles exists, the component will be passed the selected role as a prop.\n * The return content of this will likely be a dynamically rendered view.\n */\nconst AddAndEditForm = ({\n selectedRoleName,\n firstName,\n lastName,\n email\n}: {\n // Cosmos will pass the selectedRoleName\n selectedRoleName?: Role['name'];\n // Any prop passed to rendererProps will be forwarded here\n firstName?: string;\n lastName?: string;\n email?: string;\n}) => {\n const inputs = (\n <Grid container={{ cols: '1fr', gap: 2 }}>\n <Input label='First name' required defaultValue={firstName} />\n <Input label='Last name' required defaultValue={lastName} />\n <Input type='email' label='Email' required defaultValue={email} />\n <Input label='Job title' defaultValue={firstName ? 'Vice president' : undefined} />\n </Grid>\n );\n\n return selectedRoleName ? (\n <FieldGroup name={`Fields for: ${selectedRoleName}`}>{inputs}</FieldGroup>\n ) : (\n inputs\n );\n};\n\nconst useMockStakeholders = (\n cb: () => void\n): [MockStakeholderObject[], Dispatch<SetStateAction<MockStakeholderObject[]>>] => {\n const [mockStakeholders, setMockStakeholders] = useState<MockStakeholderObject[]>([]);\n // Grab some mock data...\n const [mockListData] = useMockListData(\n () => {\n setMockStakeholders(mockListData);\n cb();\n },\n { count }\n );\n\n return [\n mockStakeholders.map(stakeholder => {\n return { ...stakeholder, role: stakeholder.role ?? mockRoles[0] };\n }),\n setMockStakeholders\n ];\n};\n\nexport const StakeHoldersDemo = () => {\n const [loading, setLoading] = useState(true);\n const [mode, setMode] = useState<undefined | 'add' | 'viewAll'>();\n const [editing, setEditing] = useState<Stakeholder['id'] | null>(null);\n const [formLoading, setFormLoading] = useState(false);\n const [viewAllLoading, setViewAllLoading] = useState(false);\n const [viewAllSearchValue, setViewAllSearchValue] = useState('');\n\n // Grab some mock data...\n const [mockStakeholders, setMockStakeholders] = useMockStakeholders(() => {\n setLoading(false);\n });\n\n const [editData, setEditData] = useState<\n StakeholdersProps['form']['rendererProps'] | undefined\n >();\n\n // Merges built-in available actions with stakeholder objects.\n const addActions = useCallback(\n (items: Stakeholder[]) => {\n return items.map(stakeholder => {\n return {\n ...stakeholder,\n onEdit: () => {\n setFormLoading(true);\n setEditing(stakeholder.id);\n setEditData(mockStakeholders.find(ms => ms.id === stakeholder.id)?.data);\n mockNetworkReq().then(() => setFormLoading(false));\n },\n onRemove: () => {\n setMockStakeholders(cur => cur.filter(({ id }) => id !== stakeholder.id));\n }\n };\n });\n },\n [mockStakeholders]\n );\n\n const form: StakeholdersProps['form'] = useMemo(() => {\n return {\n // Set this to true when fetching view metadata for the form or during submit validation.\n loading: formLoading,\n // Represents \"available\" roles for a stakeholder. Set to undefined when choosing not to present them as options.\n roles: mode === 'add' ? mockRoles : undefined,\n // Represents the current role of a stakeholder if they have one. When undefined the first role in the roles array with be selected in the UI.\n currentRole: editing ? mockStakeholders.find(({ id }) => id === editing)?.role : undefined,\n /**\n * A function that will be invoked by React's createElement. If only a simple function is needed then an inline arrow is ok.\n * If local state(hooks) is desired best to define a stable component definition outside of the parent component's function body.\n */\n renderer: AddAndEditForm,\n rendererProps: editData,\n onSubmit: ({ selectedRoleName, closeForm }) => {\n setFormLoading(true);\n action(`The selected role is: ${selectedRoleName}`);\n // Create or update the stakeholder resource.\n mockNetworkReq().then(closeForm);\n },\n onDismiss: ({ closeForm }) => {\n closeForm();\n },\n onAfterClose: () => {\n // Clean up loading state when the form is closed.\n setFormLoading(false);\n setEditing(null);\n setEditData(undefined);\n setMode(undefined);\n }\n };\n }, [mode, formLoading, mockRoles, editing, editData]);\n\n const viewAll: StakeholdersProps['viewAll'] = useMemo(() => {\n let viewAllItems = mockStakeholders;\n\n // When the user has entered a search value we can filter the array or api request.\n if (viewAllSearchValue) {\n // For client side searches cosmos offers utils such as createStringMatcher for creating RegExp with params.\n const filterRegex = createStringMatcher(viewAllSearchValue, 'boundary');\n // Asserting as string since, in this demo, primary is a string. But type is a non nullable ReactNode.\n viewAllItems = mockStakeholders.filter(({ primary }) => filterRegex.test(primary as string));\n }\n\n return {\n // Set this to true when fetching data for the view all modal.\n loading: viewAllLoading,\n // Even when loading is true this must be an array, empty or not.\n items: addActions(viewAllItems),\n // The search string will be handed back as the arg, pass a state setter and filter off of that.\n onSearch: setViewAllSearchValue,\n onAfterClose: () => {\n // Clean up loading state when the modal is closed.\n if (viewAllLoading) setViewAllLoading(false);\n }\n };\n }, [viewAllLoading, mockStakeholders, viewAllSearchValue, addActions]);\n\n useEffect(() => {\n // Orchestrate based on mode state if needed.\n }, [mode]);\n\n useEffect(() => {\n // Orchestrate based on editing state if needed.\n }, [editing]);\n\n return (\n <Stakeholders\n loading={loading}\n items={useMemo(\n () => addActions(mockStakeholders.slice(0, 3)),\n [addActions, mockStakeholders]\n )}\n count={loading ? undefined : mockStakeholders.length}\n onAddNew={() => {\n setMode('add');\n setFormLoading(true);\n mockNetworkReq().then(() => setFormLoading(false));\n }}\n form={form}\n onViewAll={() => {\n setMode('viewAll');\n setViewAllLoading(true);\n mockNetworkReq().then(() => setViewAllLoading(false));\n }}\n viewAll={viewAll}\n />\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"Stakeholders.stories.js","sourceRoot":"","sources":["../../../src/work/Stakeholders/Stakeholders.stories.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAGlD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAkC,MAAM,yBAAyB,CAAC;AAEvF,OAAO,EACL,cAAc,EACd,cAAc,EACd,SAAS,EACT,mBAAmB,EACpB,MAAM,sBAAsB,CAAC;AAE9B,eAAe;IACb,KAAK,EAAE,mBAAmB;IAC1B,SAAS,EAAE,YAAY;CAChB,CAAC;AAEV,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,EAAE;IACnC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC7C,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,EAAiC,CAAC;IAClE,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAA2B,IAAI,CAAC,CAAC;IACvE,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACtD,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC5D,MAAM,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IAE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ACxB,cAAc,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;QACxD,CAAC,EACD,OAAO,EAAE,OAAO,WAChB,CACH,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { useCallback, useEffect, useMemo, useState } from 'react';\nimport { action } from '@storybook/addon-actions';\nimport { Meta } from '@storybook/react';\n\nimport { createStringMatcher } from '@pega/cosmos-react-core';\nimport { Stakeholders, StakeholdersProps, Stakeholder } from '@pega/cosmos-react-work';\n\nimport {\n AddAndEditForm,\n mockNetworkReq,\n mockRoles,\n useMockStakeholders\n} from './Stakeholders.mocks';\n\nexport default {\n title: 'Work/Stakeholders',\n component: Stakeholders\n} as Meta;\n\nexport const StakeHoldersDemo = () => {\n const [loading, setLoading] = useState(true);\n const [mode, setMode] = useState<undefined | 'add' | 'viewAll'>();\n const [editing, setEditing] = useState<Stakeholder['id'] | null>(null);\n const [formLoading, setFormLoading] = useState(false);\n const [viewAllLoading, setViewAllLoading] = useState(false);\n const [viewAllSearchValue, setViewAllSearchValue] = useState('');\n\n // Grab some mock data...\n const [mockStakeholders, setMockStakeholders] = useMockStakeholders(() => {\n setLoading(false);\n });\n\n const [editData, setEditData] = useState<\n StakeholdersProps['form']['rendererProps'] | undefined\n >();\n\n // Merges built-in available actions with stakeholder objects.\n const addActions = useCallback(\n (items: Stakeholder[]) => {\n return items.map(stakeholder => {\n return {\n ...stakeholder,\n onEdit: () => {\n setFormLoading(true);\n setEditing(stakeholder.id);\n setEditData(mockStakeholders.find(ms => ms.id === stakeholder.id)?.data);\n mockNetworkReq().then(() => setFormLoading(false));\n },\n onRemove: () => {\n setMockStakeholders(cur => cur.filter(({ id }) => id !== stakeholder.id));\n }\n };\n });\n },\n [mockStakeholders]\n );\n\n const form: StakeholdersProps['form'] = useMemo(() => {\n return {\n // Set this to true when fetching view metadata for the form or during submit validation.\n loading: formLoading,\n // Represents \"available\" roles for a stakeholder. Set to undefined when choosing not to present them as options.\n roles: mode === 'add' ? mockRoles : undefined,\n // Represents the current role of a stakeholder if they have one. When undefined the first role in the roles array with be selected in the UI.\n currentRole: editing ? mockStakeholders.find(({ id }) => id === editing)?.role : undefined,\n /**\n * A function that will be invoked by React's createElement. If only a simple function is needed then an inline arrow is ok.\n * If local state(hooks) is desired best to define a stable component definition outside of the parent component's function body.\n */\n renderer: AddAndEditForm,\n rendererProps: editData,\n onSubmit: ({ selectedRoleName, closeForm }) => {\n setFormLoading(true);\n action(`The selected role is: ${selectedRoleName}`);\n // Create or update the stakeholder resource.\n mockNetworkReq().then(closeForm);\n },\n onDismiss: ({ closeForm }) => {\n closeForm();\n },\n onAfterClose: () => {\n // Clean up loading state when the form is closed.\n setFormLoading(false);\n setEditing(null);\n setEditData(undefined);\n setMode(undefined);\n }\n };\n }, [mode, formLoading, mockRoles, editing, editData]);\n\n const viewAll: StakeholdersProps['viewAll'] = useMemo(() => {\n let viewAllItems = mockStakeholders;\n\n // When the user has entered a search value we can filter the array or api request.\n if (viewAllSearchValue) {\n // For client side searches cosmos offers utils such as createStringMatcher for creating RegExp with params.\n const filterRegex = createStringMatcher(viewAllSearchValue, 'boundary');\n // Asserting as string since, in this demo, primary is a string. But type is a non nullable ReactNode.\n viewAllItems = mockStakeholders.filter(({ primary }) => filterRegex.test(primary as string));\n }\n\n return {\n // Set this to true when fetching data for the view all modal.\n loading: viewAllLoading,\n // Even when loading is true this must be an array, empty or not.\n items: addActions(viewAllItems),\n // The search string will be handed back as the arg, pass a state setter and filter off of that.\n onSearch: setViewAllSearchValue,\n onAfterClose: () => {\n // Clean up loading state when the modal is closed.\n if (viewAllLoading) setViewAllLoading(false);\n }\n };\n }, [viewAllLoading, mockStakeholders, viewAllSearchValue, addActions]);\n\n useEffect(() => {\n // Orchestrate based on mode state if needed.\n }, [mode]);\n\n useEffect(() => {\n // Orchestrate based on editing state if needed.\n }, [editing]);\n\n return (\n <Stakeholders\n loading={loading}\n items={useMemo(\n () => addActions(mockStakeholders.slice(0, 3)),\n [addActions, mockStakeholders]\n )}\n count={loading ? undefined : mockStakeholders.length}\n onAddNew={() => {\n setMode('add');\n setFormLoading(true);\n mockNetworkReq().then(() => setFormLoading(false));\n }}\n form={form}\n onViewAll={() => {\n setMode('viewAll');\n setViewAllLoading(true);\n mockNetworkReq().then(() => setViewAllLoading(false));\n }}\n viewAll={viewAll}\n />\n );\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Timeline.stories.d.ts","sourceRoot":"","sources":["../../../src/work/Timeline/Timeline.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAG/C,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAY,aAAa,EAAE,MAAM,yBAAyB,CAAC;;AAIlE,wBAGU;
|
|
1
|
+
{"version":3,"file":"Timeline.stories.d.ts","sourceRoot":"","sources":["../../../src/work/Timeline/Timeline.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAG/C,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAY,aAAa,EAAE,MAAM,yBAAyB,CAAC;;AAIlE,wBAGU;AAEV,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,UAAU,CAAC,aAAa,EAAE,UAAU,GAAG,aAAa,CAAC,CA6CrF,CAAC"}
|
|
@@ -6,9 +6,9 @@ export default {
|
|
|
6
6
|
title: 'Work/Timeline',
|
|
7
7
|
component: Timeline
|
|
8
8
|
};
|
|
9
|
-
const INITIAL_CHUNK_SIZE = 7;
|
|
10
|
-
const APPEND_CHUNK_SIZE = 3;
|
|
11
9
|
export const TimelineDemo = (args) => {
|
|
10
|
+
const INITIAL_CHUNK_SIZE = 7;
|
|
11
|
+
const APPEND_CHUNK_SIZE = 3;
|
|
12
12
|
const [loading, setLoading] = useState(false);
|
|
13
13
|
const [hasMore, setHasMore] = useState(true);
|
|
14
14
|
const [items, setItems] = useState(() => activity.slice(0, INITIAL_CHUNK_SIZE));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Timeline.stories.js","sourceRoot":"","sources":["../../../src/work/Timeline/Timeline.stories.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAG9C,OAAO,EAAE,QAAQ,EAAiB,MAAM,yBAAyB,CAAC;AAElE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,eAAe;IACb,KAAK,EAAE,eAAe;IACtB,SAAS,EAAE,QAAQ;CACZ,CAAC;AAEV,MAAM,
|
|
1
|
+
{"version":3,"file":"Timeline.stories.js","sourceRoot":"","sources":["../../../src/work/Timeline/Timeline.stories.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAG9C,OAAO,EAAE,QAAQ,EAAiB,MAAM,yBAAyB,CAAC;AAElE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,eAAe;IACb,KAAK,EAAE,eAAe;IACtB,SAAS,EAAE,QAAQ;CACZ,CAAC;AAEV,MAAM,CAAC,MAAM,YAAY,GAAiE,CACxF,IAA2D,EAC3D,EAAE;IACF,MAAM,kBAAkB,GAAG,CAAC,CAAC;IAC7B,MAAM,iBAAiB,GAAG,CAAC,CAAC;IAE5B,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9C,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC7C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAA4B,GAAG,EAAE,CACjE,QAAQ,CAAC,KAAK,CAAC,CAAC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;QACP,OAAO,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,CAAC;QAC7D,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;KAC5B;CACF,CAAC","sourcesContent":["import { Meta, Story } from '@storybook/react';\nimport { useCallback, useState } from 'react';\n\nimport { OmitStrict } from '@pega/cosmos-react-core';\nimport { Timeline, TimelineProps } from '@pega/cosmos-react-work';\n\nimport { activity } from './Timeline.mocks';\n\nexport default {\n title: 'Work/Timeline',\n component: Timeline\n} as Meta;\n\nexport const TimelineDemo: Story<OmitStrict<TimelineProps, 'activity' | 'currentTime'>> = (\n args: OmitStrict<TimelineProps, 'activity' | 'currentTime'>\n) => {\n const INITIAL_CHUNK_SIZE = 7;\n const APPEND_CHUNK_SIZE = 3;\n\n const [loading, setLoading] = useState(false);\n const [hasMore, setHasMore] = useState(true);\n const [items, setItems] = useState<TimelineProps['activity']>(() =>\n activity.slice(0, INITIAL_CHUNK_SIZE)\n );\n\n const loadMore = useCallback(() => {\n if (!loading) {\n setLoading(true);\n setTimeout(() => {\n setLoading(false);\n\n setItems(prevItems => {\n const previousItemsLength = prevItems.length;\n const newItems = activity.slice(\n previousItemsLength,\n previousItemsLength + APPEND_CHUNK_SIZE\n );\n\n if (newItems.length === 0) {\n setHasMore(false);\n }\n\n return [...prevItems, ...newItems];\n });\n }, 2000);\n }\n }, [loading]);\n\n return (\n <Timeline\n activity={items}\n currentTime={new Date()}\n sortOrder={args.sortOrder}\n groupBy={args.groupBy}\n loading={loading}\n loadMore={hasMore ? loadMore : undefined}\n />\n );\n};\n\nTimelineDemo.args = {\n sortOrder: 'descending',\n groupBy: 'date'\n};\n\nTimelineDemo.argTypes = {\n sortOrder: { options: ['ascending', 'descending'], control: { type: 'select' } },\n groupBy: {\n options: ['date', 'monthyear', 'quarteryear', 'year', 'none'],\n control: { type: 'select' }\n }\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pega/cosmos-react-demos",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.4",
|
|
4
4
|
"author": "Pegasystems",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"repository": {
|
|
@@ -20,14 +20,14 @@
|
|
|
20
20
|
"build": "tsc -b"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@pega/cosmos-react-build": "2.1.
|
|
24
|
-
"@pega/cosmos-react-condition-builder": "2.1.
|
|
25
|
-
"@pega/cosmos-react-core": "2.1.
|
|
26
|
-
"@pega/cosmos-react-cs": "2.1.
|
|
27
|
-
"@pega/cosmos-react-dnd": "2.1.
|
|
28
|
-
"@pega/cosmos-react-rte": "2.1.
|
|
29
|
-
"@pega/cosmos-react-social": "2.1.
|
|
30
|
-
"@pega/cosmos-react-work": "2.1.
|
|
23
|
+
"@pega/cosmos-react-build": "2.1.4",
|
|
24
|
+
"@pega/cosmos-react-condition-builder": "2.1.4",
|
|
25
|
+
"@pega/cosmos-react-core": "2.1.4",
|
|
26
|
+
"@pega/cosmos-react-cs": "2.1.4",
|
|
27
|
+
"@pega/cosmos-react-dnd": "2.1.4",
|
|
28
|
+
"@pega/cosmos-react-rte": "2.1.4",
|
|
29
|
+
"@pega/cosmos-react-social": "2.1.4",
|
|
30
|
+
"@pega/cosmos-react-work": "2.1.4",
|
|
31
31
|
"emoji-mart": "^3.0.1",
|
|
32
32
|
"polished": "^4.1.0",
|
|
33
33
|
"react": "^16.14.0 || ^17.0.0",
|