@pareto-engineering/design-system 2.0.0-alpha.6 → 2.0.0-alpha.61
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/.env.scripts.example +4 -0
- package/.eslintrc.js +25 -1
- package/babel.config.js +1 -0
- package/dist/cjs/a/{GradientBackground/GradientBackground.js → Alert/Alert.js} +68 -67
- package/dist/cjs/{c/SiteFooter/common/Section → a/Alert}/index.js +3 -3
- package/dist/cjs/a/Alert/styles.scss +74 -0
- package/dist/cjs/{c/BlogContext → a/AppContext}/Context.js +0 -0
- package/dist/cjs/a/AppContext/ContextProvider.js +96 -0
- package/dist/cjs/{c/BlogContext → a/AppContext}/index.js +13 -5
- package/dist/cjs/{c/BlogContext/useBlog.js → a/AppContext/useApp.js} +0 -0
- package/dist/cjs/a/AppContext/useTheme.js +45 -0
- package/dist/cjs/{c/SiteFooter/common/Section/Section.js → a/BackgroundGradient/BackgroundGradient.js} +20 -38
- package/dist/cjs/a/BackgroundGradient/index.js +15 -0
- package/dist/cjs/a/BackgroundGradient/styles.scss +16 -0
- package/dist/cjs/{experimental/GradientBackground/GradientBackground.js → a/ColumnLabel/ColumnLabel.js} +32 -30
- package/dist/cjs/{c/SiteMission → a/ColumnLabel}/index.js +3 -3
- package/dist/cjs/a/ColumnLabel/styles.scss +22 -0
- package/dist/cjs/{c/TeamGallery/TeamGallery.js → a/ContentTree/ContentTree.js} +23 -20
- package/dist/cjs/a/ContentTree/common/Tree/Tree.js +116 -0
- package/dist/cjs/{c/BlogPostsList/common/Card → a/ContentTree/common/Tree}/index.js +3 -3
- package/dist/cjs/a/ContentTree/common/index.js +31 -0
- package/dist/cjs/a/ContentTree/common/useContentTree.js +82 -0
- package/dist/cjs/a/ContentTree/common/useFirstVisibleNode.js +65 -0
- package/dist/cjs/{c/SitePricing → a/ContentTree}/index.js +3 -3
- package/dist/cjs/a/ContentTree/styles.scss +33 -0
- package/dist/cjs/a/Conversation/Conversation.js +14 -8
- package/dist/cjs/a/Conversation/common/Message/Message.js +32 -6
- package/dist/cjs/a/Conversation/styles.scss +132 -33
- package/dist/cjs/{c/SiteFooter/SiteFooter.js → a/Label/Label.js} +28 -14
- package/dist/cjs/{f/fields/TextArea → a/Label}/index.js +3 -3
- package/dist/cjs/a/Label/styles.scss +34 -0
- package/dist/cjs/a/OvalIllustration/OvalIllustration.js +133 -0
- package/dist/cjs/a/OvalIllustration/index.js +15 -0
- package/dist/cjs/a/OvalIllustration/styles.scss +102 -0
- package/dist/cjs/{c/AcceptCookies/AcceptCookies.js → a/Popover/Popover.js} +57 -57
- package/dist/cjs/{c/BlogPost → a/Popover}/index.js +3 -3
- package/dist/cjs/a/Popover/styles.scss +33 -0
- package/dist/cjs/a/Shapes/Shapes.js +9 -1
- package/dist/cjs/a/Shapes/styles.scss +42 -9
- package/dist/cjs/{c/BlogPostsList/BlogPostsList.js → a/SnapScroller/SnapScroller.js} +15 -11
- package/dist/cjs/{c/SiteFooter → a/SnapScroller}/index.js +3 -3
- package/dist/cjs/a/SnapScroller/styles.scss +38 -0
- package/dist/cjs/a/index.js +65 -9
- package/dist/cjs/b/Button/Button.js +10 -4
- package/dist/cjs/b/Button/styles.scss +55 -10
- package/dist/cjs/b/Logo/Logo.js +41 -41
- package/dist/cjs/b/Logo/styles.scss +0 -138
- package/dist/cjs/b/Page/common/PageHelmet/PageHelmet.js +1 -1
- package/dist/cjs/b/Page/common/Section/Section.js +17 -3
- package/dist/cjs/b/SocialMediaButton/SocialMediaButton.js +4 -4
- package/dist/cjs/b/ThemeSelector/ThemeSelector.js +1 -1
- package/dist/cjs/c/ContentSlides/common/HorizontalMenu/HorizontalMenu.js +16 -9
- package/dist/cjs/c/ContentSlides/common/Navigator/Navigator.js +4 -3
- package/dist/cjs/c/ContentSlides/styles.scss +10 -4
- package/dist/cjs/c/{SiteHeaderCTA/SiteHeaderCTA.js → SocialMediaShareButton/SocialMediaShareButton.js} +46 -43
- package/dist/cjs/c/SocialMediaShareButton/index.js +15 -0
- package/dist/cjs/c/SocialMediaShareButton/styles.scss +39 -0
- package/dist/cjs/c/index.js +9 -1
- package/dist/cjs/f/FormInput/FormInput.js +26 -3
- package/dist/cjs/f/FormInput/styles.scss +11 -0
- package/dist/cjs/f/common/Debugger/Debugger.js +1 -1
- package/dist/cjs/f/common/Description/Description.js +20 -14
- package/dist/cjs/f/common/Label/Label.js +1 -1
- package/dist/cjs/f/common/Label/styles.scss +1 -1
- package/dist/cjs/f/fields/ChoicesInput/ChoicesInput.js +1 -1
- package/dist/cjs/f/fields/ChoicesInput/styles.scss +17 -2
- package/dist/cjs/f/fields/QueryCombobox/QueryCombobox.js +235 -0
- package/dist/cjs/f/fields/QueryCombobox/common/Combobox/Combobox.js +208 -0
- package/dist/cjs/f/fields/QueryCombobox/common/Combobox/index.js +15 -0
- package/dist/cjs/{c/BlogCategoryButton/BlogCategoryButton.js → f/fields/QueryCombobox/common/Menu/Menu.js} +39 -31
- package/dist/cjs/f/fields/QueryCombobox/common/Menu/index.js +15 -0
- package/dist/cjs/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.js +307 -0
- package/dist/cjs/f/fields/QueryCombobox/common/MultipleCombobox/index.js +15 -0
- package/dist/cjs/f/fields/QueryCombobox/common/index.js +29 -0
- package/dist/cjs/{c/AcceptCookies → f/fields/QueryCombobox}/index.js +3 -3
- package/dist/cjs/f/fields/QueryCombobox/styles.scss +90 -0
- package/dist/cjs/f/fields/QuerySelect/QuerySelect.js +201 -0
- package/dist/cjs/{c/TeamGallery → f/fields/QuerySelect}/index.js +3 -3
- package/dist/cjs/f/fields/RatingsInput/RatingsInput.js +39 -6
- package/dist/cjs/f/fields/RatingsInput/styles.scss +29 -20
- package/dist/cjs/f/fields/SelectInput/SelectInput.js +59 -14
- package/dist/cjs/f/fields/SelectInput/styles.scss +33 -13
- package/dist/cjs/f/fields/TaskRecommendationInput/TaskRecommendationInput.js +2 -2
- package/dist/cjs/f/fields/TaskRecommendationInput/styles.scss +0 -4
- package/dist/cjs/f/fields/TextInput/TextInput.js +50 -13
- package/dist/cjs/f/fields/TextInput/styles.scss +16 -7
- package/dist/cjs/f/fields/TextareaInput/TextareaInput.js +41 -15
- package/dist/cjs/f/fields/TextareaInput/styles.scss +19 -6
- package/dist/cjs/f/fields/index.js +15 -23
- package/dist/cjs/form-reset.scss +1 -1
- package/dist/cjs/index.js +26 -0
- package/dist/cjs/test/QueryLoader/QueryLoader.js +41 -0
- package/dist/cjs/test/QueryLoader/__generated__/QueryLoaderHelloQuery.graphql.js +71 -0
- package/dist/cjs/{c/BlogContext/ContextProvider.js → test/QueryLoader/common/PreloadedTestData/PreloadedTestData.js} +13 -27
- package/dist/cjs/test/QueryLoader/common/PreloadedTestData/index.js +15 -0
- package/dist/cjs/test/QueryLoader/common/index.js +13 -0
- package/dist/cjs/test/QueryLoader/index.js +15 -0
- package/dist/cjs/{c/TeamGallery/common → test}/index.js +3 -3
- package/dist/cjs/utils/hooks/index.js +23 -0
- package/dist/cjs/utils/hooks/useDynamicPosition.js +107 -0
- package/dist/cjs/utils/hooks/useWindowSize.js +39 -0
- package/dist/cjs/utils/index.js +19 -0
- package/dist/es/a/Alert/Alert.js +118 -0
- package/dist/es/{c/SiteFooter/common/Section → a/Alert}/index.js +1 -1
- package/dist/es/a/Alert/styles.scss +74 -0
- package/dist/es/{c/BlogContext → a/AppContext}/Context.js +0 -0
- package/dist/es/a/AppContext/ContextProvider.js +78 -0
- package/dist/es/a/AppContext/index.js +5 -0
- package/dist/es/{c/BlogContext/useBlog.js → a/AppContext/useApp.js} +0 -0
- package/dist/es/a/AppContext/useTheme.js +34 -0
- package/dist/es/{c/SiteFooter/SiteFooter.js → a/BackgroundGradient/BackgroundGradient.js} +14 -15
- package/dist/es/a/BackgroundGradient/index.js +2 -0
- package/dist/es/a/BackgroundGradient/styles.scss +16 -0
- package/dist/es/a/ColumnLabel/ColumnLabel.js +78 -0
- package/dist/es/a/ColumnLabel/index.js +2 -0
- package/dist/es/a/ColumnLabel/styles.scss +22 -0
- package/dist/es/a/ContentTree/ContentTree.js +67 -0
- package/dist/es/a/ContentTree/common/Tree/Tree.js +98 -0
- package/dist/es/{c/BlogPostsList/common/Card → a/ContentTree/common/Tree}/index.js +1 -1
- package/dist/es/a/ContentTree/common/index.js +3 -0
- package/dist/es/a/ContentTree/common/useContentTree.js +74 -0
- package/dist/es/a/ContentTree/common/useFirstVisibleNode.js +54 -0
- package/dist/es/a/ContentTree/index.js +2 -0
- package/dist/es/a/ContentTree/styles.scss +33 -0
- package/dist/es/a/Conversation/Conversation.js +14 -8
- package/dist/es/a/Conversation/common/Message/Message.js +32 -6
- package/dist/es/a/Conversation/styles.scss +132 -33
- package/dist/es/{c/TeamGallery/TeamGallery.js → a/Label/Label.js} +30 -23
- package/dist/es/{f/fields/TextArea → a/Label}/index.js +1 -1
- package/dist/es/a/Label/styles.scss +34 -0
- package/dist/es/a/OvalIllustration/OvalIllustration.js +111 -0
- package/dist/es/a/OvalIllustration/index.js +2 -0
- package/dist/es/a/OvalIllustration/styles.scss +102 -0
- package/dist/es/a/Popover/Popover.js +118 -0
- package/dist/es/{c/BlogPost → a/Popover}/index.js +1 -1
- package/dist/es/a/Popover/styles.scss +33 -0
- package/dist/es/a/Shapes/Shapes.js +9 -1
- package/dist/es/a/Shapes/styles.scss +42 -9
- package/dist/es/{c/BlogPostsList/BlogPostsList.js → a/SnapScroller/SnapScroller.js} +16 -11
- package/dist/es/a/SnapScroller/index.js +2 -0
- package/dist/es/a/SnapScroller/styles.scss +38 -0
- package/dist/es/a/index.js +9 -2
- package/dist/es/b/Button/Button.js +8 -2
- package/dist/es/b/Button/styles.scss +55 -10
- package/dist/es/b/Logo/Logo.js +41 -41
- package/dist/es/b/Logo/styles.scss +0 -138
- package/dist/es/b/Page/common/PageHelmet/PageHelmet.js +2 -2
- package/dist/es/b/Page/common/Section/Section.js +17 -3
- package/dist/es/b/SocialMediaButton/SocialMediaButton.js +5 -5
- package/dist/es/b/ThemeSelector/ThemeSelector.js +2 -2
- package/dist/es/c/ContentSlides/common/HorizontalMenu/HorizontalMenu.js +16 -9
- package/dist/es/c/ContentSlides/common/Navigator/Navigator.js +4 -3
- package/dist/es/c/ContentSlides/styles.scss +10 -4
- package/dist/es/c/SocialMediaShareButton/SocialMediaShareButton.js +95 -0
- package/dist/es/c/SocialMediaShareButton/index.js +2 -0
- package/dist/es/c/SocialMediaShareButton/styles.scss +39 -0
- package/dist/es/c/index.js +2 -1
- package/dist/es/f/FormInput/FormInput.js +26 -3
- package/dist/es/f/FormInput/styles.scss +11 -0
- package/dist/es/f/common/Debugger/Debugger.js +1 -1
- package/dist/es/f/common/Description/Description.js +19 -14
- package/dist/es/f/common/Label/Label.js +1 -1
- package/dist/es/f/common/Label/styles.scss +1 -1
- package/dist/es/f/fields/ChoicesInput/ChoicesInput.js +1 -1
- package/dist/es/f/fields/ChoicesInput/styles.scss +17 -2
- package/dist/es/f/fields/QueryCombobox/QueryCombobox.js +212 -0
- package/dist/es/f/fields/QueryCombobox/common/Combobox/Combobox.js +188 -0
- package/dist/es/f/fields/QueryCombobox/common/Combobox/index.js +2 -0
- package/dist/es/f/fields/QueryCombobox/common/Menu/Menu.js +77 -0
- package/dist/es/f/fields/QueryCombobox/common/Menu/index.js +2 -0
- package/dist/es/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.js +279 -0
- package/dist/es/f/fields/QueryCombobox/common/MultipleCombobox/index.js +2 -0
- package/dist/es/f/fields/QueryCombobox/common/index.js +3 -0
- package/dist/es/f/fields/QueryCombobox/index.js +2 -0
- package/dist/es/f/fields/QueryCombobox/styles.scss +90 -0
- package/dist/es/f/fields/QuerySelect/QuerySelect.js +179 -0
- package/dist/es/f/fields/QuerySelect/index.js +2 -0
- package/dist/es/f/fields/RatingsInput/RatingsInput.js +38 -6
- package/dist/es/f/fields/RatingsInput/styles.scss +29 -20
- package/dist/es/f/fields/SelectInput/SelectInput.js +58 -14
- package/dist/es/f/fields/SelectInput/styles.scss +33 -13
- package/dist/es/f/fields/TaskRecommendationInput/TaskRecommendationInput.js +2 -2
- package/dist/es/f/fields/TaskRecommendationInput/styles.scss +0 -4
- package/dist/es/f/fields/TextInput/TextInput.js +50 -13
- package/dist/es/f/fields/TextInput/styles.scss +16 -7
- package/dist/es/f/fields/TextareaInput/TextareaInput.js +41 -15
- package/dist/es/f/fields/TextareaInput/styles.scss +19 -6
- package/dist/es/f/fields/index.js +3 -4
- package/dist/es/form-reset.scss +1 -1
- package/dist/es/index.js +3 -1
- package/dist/es/test/QueryLoader/QueryLoader.js +29 -0
- package/dist/es/test/QueryLoader/__generated__/QueryLoaderHelloQuery.graphql.js +71 -0
- package/dist/es/test/QueryLoader/common/PreloadedTestData/PreloadedTestData.js +31 -0
- package/dist/es/test/QueryLoader/common/PreloadedTestData/index.js +2 -0
- package/dist/es/test/QueryLoader/common/index.js +1 -0
- package/dist/es/test/QueryLoader/index.js +2 -0
- package/dist/es/test/index.js +1 -0
- package/dist/es/utils/hooks/index.js +2 -0
- package/dist/es/utils/hooks/useDynamicPosition.js +93 -0
- package/dist/es/utils/hooks/useWindowSize.js +27 -0
- package/dist/es/utils/index.js +1 -0
- package/package.json +18 -4
- package/relay.config.js +12 -0
- package/schema.graphql +4075 -0
- package/scripts/fetchSchema.js +74 -0
- package/src/__snapshots__/Storyshots.test.js.snap +12174 -7164
- package/src/local.scss +4 -2
- package/src/stories/StyleGuide/Sprites.stories.mdx +25 -0
- package/src/stories/StyleGuide/helpers.js +16 -0
- package/src/stories/a/Alert.stories.jsx +75 -0
- package/src/stories/a/{SiteContext.stories.jsx → AppContext.stories.jsx} +8 -8
- package/src/stories/a/BackgroundGradient.stories.jsx +38 -0
- package/src/stories/a/ContentTree.stories.jsx +662 -0
- package/src/stories/a/Conversation.stories.jsx +78 -1
- package/src/stories/a/DotInfo.stories.jsx +14 -13
- package/src/stories/a/Label.stories.jsx +49 -0
- package/src/stories/a/OvalIllustration.stories.jsx +59 -0
- package/src/stories/a/Popover.stories.jsx +106 -0
- package/src/stories/a/ProgressBar.stories.jsx +16 -7
- package/src/stories/a/Shapes.stories.jsx +18 -0
- package/src/stories/a/SnapScroller.stories.jsx +98 -0
- package/src/stories/a/Timestamp.stories.jsx +35 -39
- package/src/stories/b/Button.stories.jsx +27 -4
- package/src/stories/b/Logo.stories.jsx +23 -14
- package/src/stories/b/Page.stories.jsx +25 -1
- package/src/stories/b/QuestionDropdown.stories.jsx +20 -30
- package/src/stories/b/SocialMediaButton.stories.jsx +36 -53
- package/src/stories/b/ThemeSelector.stories.jsx +5 -5
- package/src/stories/b/Title.stories.jsx +13 -15
- package/src/stories/c/ContentSlides.stories.jsx +35 -151
- package/src/stories/c/Shortener.stories.jsx +9 -3
- package/src/stories/c/SocialMediaShareButton.stories.jsx +33 -0
- package/src/stories/f/ChoicesInput.stories.jsx +66 -130
- package/src/stories/f/Description.stories.jsx +22 -4
- package/src/stories/f/FormInput.stories.jsx +259 -0
- package/src/stories/f/QueryCombobox.stories.jsx +273 -0
- package/src/stories/f/QuerySelect.stories.jsx +135 -0
- package/src/stories/f/RatingsInput.stories.jsx +29 -22
- package/src/stories/f/SelectInput.stories.jsx +41 -49
- package/src/stories/f/TextInput.stories.jsx +63 -43
- package/src/stories/f/TextareaInput.stories.jsx +63 -19
- package/src/stories/f/__generated__/FormInputAllTaskStatusesQuery.graphql.js +122 -0
- package/src/stories/f/__generated__/FormInputAllTeamsQuery.graphql.js +139 -0
- package/src/stories/f/__generated__/QueryComboboxAllTeamsQuery.graphql.js +139 -0
- package/src/stories/f/__generated__/QuerySelectAllTaskStatusesQuery.graphql.js +122 -0
- package/src/stories/test/QueryLoader.stories.jsx +36 -0
- package/src/stories/utils/generateNodeId.js +12 -0
- package/src/stories/utils/lorem.js +15 -0
- package/src/stories/utils/relay/EnvironmentProvider.jsx +14 -0
- package/src/stories/utils/relay/environment.js +5 -0
- package/src/stories/utils/relay/index.js +4 -0
- package/src/stories/utils/relay/mockRelayOperation.js +14 -0
- package/src/stories/utils/relay/mockResolvers.js +299 -0
- package/src/stories/utils/testData.js +63 -0
- package/src/ui/a/Alert/Alert.jsx +144 -0
- package/src/ui/a/Alert/index.js +2 -0
- package/src/ui/a/Alert/styles.scss +74 -0
- package/src/ui/a/{SiteContext → AppContext}/Context.js +0 -0
- package/src/ui/a/{SiteContext → AppContext}/ContextProvider.jsx +8 -7
- package/src/ui/a/AppContext/index.js +5 -0
- package/src/ui/a/{SiteContext/useSite.js → AppContext/useApp.js} +0 -0
- package/src/ui/a/{SiteContext → AppContext}/useTheme.js +0 -0
- package/src/ui/a/BackgroundGradient/BackgroundGradient.jsx +76 -0
- package/src/ui/a/BackgroundGradient/index.js +2 -0
- package/src/ui/a/BackgroundGradient/styles.scss +16 -0
- package/src/ui/a/ContentTree/ContentTree.jsx +88 -0
- package/src/ui/a/ContentTree/common/Tree/Tree.jsx +138 -0
- package/src/ui/a/ContentTree/common/Tree/index.js +2 -0
- package/src/ui/a/ContentTree/common/index.js +3 -0
- package/src/ui/a/ContentTree/common/useContentTree.js +83 -0
- package/src/ui/a/ContentTree/common/useFirstVisibleNode.js +59 -0
- package/src/ui/a/ContentTree/index.js +2 -0
- package/src/ui/a/ContentTree/styles.scss +33 -0
- package/src/ui/a/Conversation/Conversation.jsx +15 -7
- package/src/ui/a/Conversation/common/Message/Message.jsx +38 -6
- package/src/ui/a/Conversation/styles.scss +132 -33
- package/src/ui/a/Label/Label.jsx +93 -0
- package/src/ui/a/Label/index.js +2 -0
- package/src/ui/a/Label/styles.scss +34 -0
- package/src/ui/a/OvalIllustration/OvalIllustration.jsx +134 -0
- package/src/ui/a/OvalIllustration/index.js +2 -0
- package/src/ui/a/OvalIllustration/styles.scss +102 -0
- package/src/ui/a/Popover/Popover.jsx +157 -0
- package/src/ui/a/Popover/index.js +2 -0
- package/src/ui/a/Popover/styles.scss +33 -0
- package/src/ui/a/Shapes/Shapes.jsx +10 -0
- package/src/ui/a/Shapes/styles.scss +42 -9
- package/src/ui/a/SnapScroller/SnapScroller.jsx +83 -0
- package/src/ui/a/SnapScroller/index.js +2 -0
- package/src/ui/a/SnapScroller/styles.scss +38 -0
- package/src/ui/a/index.js +11 -4
- package/src/ui/b/Button/Button.jsx +9 -1
- package/src/ui/b/Button/styles.scss +55 -10
- package/src/ui/b/Logo/Logo.jsx +41 -41
- package/src/ui/b/Logo/styles.scss +0 -138
- package/src/ui/b/Page/common/PageHelmet/PageHelmet.jsx +2 -2
- package/src/ui/b/Page/common/Section/Section.jsx +19 -2
- package/src/ui/b/SocialMediaButton/SocialMediaButton.jsx +4 -4
- package/src/ui/b/ThemeSelector/ThemeSelector.jsx +2 -2
- package/src/ui/c/ContentSlides/common/HorizontalMenu/HorizontalMenu.jsx +12 -5
- package/src/ui/c/ContentSlides/common/Navigator/Navigator.jsx +3 -2
- package/src/ui/c/ContentSlides/styles.scss +10 -4
- package/src/ui/c/SocialMediaShareButton/SocialMediaShareButton.jsx +121 -0
- package/src/ui/c/SocialMediaShareButton/index.js +2 -0
- package/src/ui/c/SocialMediaShareButton/styles.scss +39 -0
- package/src/ui/c/index.js +1 -0
- package/src/ui/f/FormInput/FormInput.jsx +38 -1
- package/src/ui/f/FormInput/styles.scss +11 -0
- package/src/ui/f/common/Debugger/Debugger.jsx +1 -1
- package/src/ui/f/common/Description/Description.jsx +34 -29
- package/src/ui/f/common/Label/Label.jsx +1 -1
- package/src/ui/f/common/Label/styles.scss +1 -1
- package/src/ui/f/fields/ChoicesInput/ChoicesInput.jsx +1 -1
- package/src/ui/f/fields/ChoicesInput/styles.scss +17 -2
- package/src/ui/f/fields/QueryCombobox/QueryCombobox.jsx +227 -0
- package/src/ui/f/fields/QueryCombobox/common/Combobox/Combobox.jsx +218 -0
- package/src/ui/f/fields/QueryCombobox/common/Combobox/index.js +2 -0
- package/src/ui/f/fields/QueryCombobox/common/Menu/Menu.jsx +103 -0
- package/src/ui/f/fields/QueryCombobox/common/Menu/index.js +2 -0
- package/src/ui/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.jsx +314 -0
- package/src/ui/f/fields/QueryCombobox/common/MultipleCombobox/index.js +2 -0
- package/src/ui/f/fields/QueryCombobox/common/index.js +3 -0
- package/src/ui/f/fields/QueryCombobox/index.js +2 -0
- package/src/ui/f/fields/QueryCombobox/styles.scss +90 -0
- package/src/ui/f/fields/QuerySelect/QuerySelect.jsx +200 -0
- package/src/ui/f/fields/QuerySelect/index.js +2 -0
- package/src/ui/f/fields/RatingsInput/RatingsInput.jsx +54 -19
- package/src/ui/f/fields/RatingsInput/styles.scss +29 -20
- package/src/ui/f/fields/SelectInput/SelectInput.jsx +66 -8
- package/src/ui/f/fields/SelectInput/styles.scss +33 -13
- package/src/ui/f/fields/TextInput/TextInput.jsx +44 -10
- package/src/ui/f/fields/TextInput/styles.scss +16 -7
- package/src/ui/f/fields/TextareaInput/TextareaInput.jsx +42 -21
- package/src/ui/f/fields/TextareaInput/styles.scss +19 -6
- package/src/ui/f/fields/index.js +2 -3
- package/src/ui/form-reset.scss +1 -1
- package/src/ui/index.js +2 -0
- package/src/ui/test/QueryLoader/QueryLoader.jsx +41 -0
- package/src/ui/test/QueryLoader/__generated__/QueryLoaderHelloQuery.graphql.js +68 -0
- package/src/ui/test/QueryLoader/common/PreloadedTestData/PreloadedTestData.jsx +51 -0
- package/src/ui/test/QueryLoader/common/PreloadedTestData/index.js +2 -0
- package/src/ui/test/QueryLoader/common/index.js +1 -0
- package/src/ui/test/QueryLoader/index.js +2 -0
- package/src/ui/test/index.js +1 -0
- package/src/ui/utils/hooks/index.js +2 -0
- package/src/ui/utils/hooks/useDynamicPosition.js +104 -0
- package/src/ui/utils/hooks/useWindowSize.js +32 -0
- package/src/ui/utils/index.js +1 -0
- package/stylelint.config.js +13 -13
- package/dist/cjs/a/GradientBackground/index.js +0 -15
- package/dist/cjs/a/GradientBackground/styles.scss +0 -191
- package/dist/cjs/c/AcceptCookies/styles.scss +0 -49
- package/dist/cjs/c/BlogCategoryButton/index.js +0 -15
- package/dist/cjs/c/BlogContext/BlogContextProvider.js +0 -63
- package/dist/cjs/c/BlogPost/BlogPost.js +0 -147
- package/dist/cjs/c/BlogPost/styles.scss +0 -33
- package/dist/cjs/c/BlogPostsList/common/Card/Card.js +0 -170
- package/dist/cjs/c/BlogPostsList/common/index.js +0 -13
- package/dist/cjs/c/BlogPostsList/index.js +0 -15
- package/dist/cjs/c/BlogPostsList/styles.scss +0 -72
- package/dist/cjs/c/SiteFooter/common/index.js +0 -13
- package/dist/cjs/c/SiteFooter/styles.scss +0 -34
- package/dist/cjs/c/SiteHeaderCTA/index.js +0 -15
- package/dist/cjs/c/SiteHeaderCTA/styles.scss +0 -44
- package/dist/cjs/c/SiteMission/SiteMission.js +0 -113
- package/dist/cjs/c/SiteMission/styles.scss +0 -30
- package/dist/cjs/c/SiteNavigation/SiteNavigation.js +0 -130
- package/dist/cjs/c/SiteNavigation/index.js +0 -15
- package/dist/cjs/c/SiteNavigation/styles.scss +0 -118
- package/dist/cjs/c/SiteOnboardingStep/SiteOnboardingStep.js +0 -98
- package/dist/cjs/c/SiteOnboardingStep/index.js +0 -15
- package/dist/cjs/c/SiteOnboardingStep/styles.scss +0 -51
- package/dist/cjs/c/SitePricing/SitePricing.js +0 -108
- package/dist/cjs/c/SitePricing/styles.scss +0 -73
- package/dist/cjs/c/SiteServices/SiteServices.js +0 -211
- package/dist/cjs/c/SiteServices/index.js +0 -15
- package/dist/cjs/c/SiteServices/styles.scss +0 -138
- package/dist/cjs/c/TeamGallery/common/PersonCard/PersonCard.js +0 -84
- package/dist/cjs/c/TeamGallery/common/PersonCard/index.js +0 -15
- package/dist/cjs/c/TeamGallery/styles.scss +0 -100
- package/dist/cjs/c/Testimonials/Testimonials.js +0 -119
- package/dist/cjs/c/Testimonials/index.js +0 -15
- package/dist/cjs/c/Testimonials/styles.scss +0 -112
- package/dist/cjs/experimental/GradientBackground/index.js +0 -15
- package/dist/cjs/experimental/GradientBackground/styles.scss +0 -64
- package/dist/cjs/experimental/index.js +0 -13
- package/dist/cjs/f/fields/TaskRecommendation/TaskRecommendation.js +0 -129
- package/dist/cjs/f/fields/TaskRecommendation/index.js +0 -15
- package/dist/cjs/f/fields/TaskRecommendation/styles.scss +0 -37
- package/dist/cjs/f/fields/TextArea/TextArea.js +0 -141
- package/dist/cjs/f/fields/TextArea/styles.scss +0 -19
- package/dist/es/a/GradientBackground/GradientBackground.js +0 -118
- package/dist/es/a/GradientBackground/index.js +0 -2
- package/dist/es/a/GradientBackground/styles.scss +0 -191
- package/dist/es/c/AcceptCookies/AcceptCookies.js +0 -117
- package/dist/es/c/AcceptCookies/index.js +0 -2
- package/dist/es/c/AcceptCookies/styles.scss +0 -49
- package/dist/es/c/BlogCategoryButton/BlogCategoryButton.js +0 -68
- package/dist/es/c/BlogCategoryButton/index.js +0 -2
- package/dist/es/c/BlogContext/BlogContextProvider.js +0 -45
- package/dist/es/c/BlogContext/ContextProvider.js +0 -45
- package/dist/es/c/BlogContext/index.js +0 -4
- package/dist/es/c/BlogPost/BlogPost.js +0 -128
- package/dist/es/c/BlogPost/styles.scss +0 -33
- package/dist/es/c/BlogPostsList/common/Card/Card.js +0 -143
- package/dist/es/c/BlogPostsList/common/index.js +0 -1
- package/dist/es/c/BlogPostsList/index.js +0 -2
- package/dist/es/c/BlogPostsList/styles.scss +0 -72
- package/dist/es/c/SiteFooter/common/Section/Section.js +0 -73
- package/dist/es/c/SiteFooter/common/index.js +0 -1
- package/dist/es/c/SiteFooter/index.js +0 -2
- package/dist/es/c/SiteFooter/styles.scss +0 -34
- package/dist/es/c/SiteHeaderCTA/SiteHeaderCTA.js +0 -92
- package/dist/es/c/SiteHeaderCTA/index.js +0 -2
- package/dist/es/c/SiteHeaderCTA/styles.scss +0 -44
- package/dist/es/c/SiteMission/SiteMission.js +0 -96
- package/dist/es/c/SiteMission/index.js +0 -2
- package/dist/es/c/SiteMission/styles.scss +0 -30
- package/dist/es/c/SiteNavigation/SiteNavigation.js +0 -111
- package/dist/es/c/SiteNavigation/index.js +0 -2
- package/dist/es/c/SiteNavigation/styles.scss +0 -118
- package/dist/es/c/SiteOnboardingStep/SiteOnboardingStep.js +0 -81
- package/dist/es/c/SiteOnboardingStep/index.js +0 -2
- package/dist/es/c/SiteOnboardingStep/styles.scss +0 -51
- package/dist/es/c/SitePricing/SitePricing.js +0 -91
- package/dist/es/c/SitePricing/index.js +0 -2
- package/dist/es/c/SitePricing/styles.scss +0 -73
- package/dist/es/c/SiteServices/SiteServices.js +0 -195
- package/dist/es/c/SiteServices/index.js +0 -2
- package/dist/es/c/SiteServices/styles.scss +0 -138
- package/dist/es/c/TeamGallery/common/PersonCard/PersonCard.js +0 -64
- package/dist/es/c/TeamGallery/common/PersonCard/index.js +0 -2
- package/dist/es/c/TeamGallery/common/index.js +0 -1
- package/dist/es/c/TeamGallery/index.js +0 -2
- package/dist/es/c/TeamGallery/styles.scss +0 -100
- package/dist/es/c/Testimonials/Testimonials.js +0 -99
- package/dist/es/c/Testimonials/index.js +0 -2
- package/dist/es/c/Testimonials/styles.scss +0 -112
- package/dist/es/experimental/GradientBackground/GradientBackground.js +0 -76
- package/dist/es/experimental/GradientBackground/index.js +0 -2
- package/dist/es/experimental/GradientBackground/styles.scss +0 -64
- package/dist/es/experimental/index.js +0 -1
- package/dist/es/f/fields/TaskRecommendation/TaskRecommendation.js +0 -111
- package/dist/es/f/fields/TaskRecommendation/index.js +0 -2
- package/dist/es/f/fields/TaskRecommendation/styles.scss +0 -37
- package/dist/es/f/fields/TextArea/TextArea.js +0 -124
- package/dist/es/f/fields/TextArea/styles.scss +0 -19
- package/src/stories/f/CheckboxInput.stories.jsx +0 -37
- package/src/stories/f/RadioInput.stories.jsx +0 -37
- package/src/stories/f/TaskRecommendationInput.stories.jsx +0 -38
- package/src/ui/a/SiteContext/index.js +0 -5
- package/src/ui/f/fields/CheckboxInput/CheckboxInput.jsx +0 -107
- package/src/ui/f/fields/CheckboxInput/index.js +0 -2
- package/src/ui/f/fields/CheckboxInput/styles.scss +0 -28
- package/src/ui/f/fields/RadioInput/RadioInput.jsx +0 -112
- package/src/ui/f/fields/RadioInput/index.js +0 -2
- package/src/ui/f/fields/RadioInput/styles.scss +0 -26
- package/src/ui/f/fields/TaskRecommendationInput/TaskRecommendationInput.jsx +0 -130
- package/src/ui/f/fields/TaskRecommendationInput/index.js +0 -2
- package/src/ui/f/fields/TaskRecommendationInput/styles.scss +0 -41
|
@@ -3,6 +3,8 @@ import * as React from 'react'
|
|
|
3
3
|
|
|
4
4
|
import { useLayoutEffect } from 'react'
|
|
5
5
|
|
|
6
|
+
import { useField } from 'formik'
|
|
7
|
+
|
|
6
8
|
import PropTypes from 'prop-types'
|
|
7
9
|
|
|
8
10
|
import styleNames from '@pareto-engineering/bem'
|
|
@@ -20,8 +22,8 @@ const Description = ({
|
|
|
20
22
|
id,
|
|
21
23
|
className:userClassName,
|
|
22
24
|
style,
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
description,
|
|
26
|
+
name,
|
|
25
27
|
color,
|
|
26
28
|
// ...otherProps
|
|
27
29
|
}) => {
|
|
@@ -29,25 +31,27 @@ const Description = ({
|
|
|
29
31
|
import('./styles.scss')
|
|
30
32
|
}, [])
|
|
31
33
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
34
|
+
const [field, meta] = useField(name)
|
|
35
|
+
|
|
36
|
+
if (description || ((meta.touched || field.value) && meta.error)) {
|
|
37
|
+
return (
|
|
38
|
+
<div
|
|
39
|
+
id={id}
|
|
40
|
+
className={[
|
|
41
|
+
baseClassName,
|
|
42
|
+
componentClassName,
|
|
43
|
+
userClassName,
|
|
44
|
+
meta.error ? 'x-error' : `x-${color}`,
|
|
45
|
+
]
|
|
46
|
+
.filter((e) => e)
|
|
47
|
+
.join(' ')}
|
|
48
|
+
style={style}
|
|
49
|
+
>
|
|
50
|
+
{ meta.error || description}
|
|
51
|
+
</div>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
return null
|
|
51
55
|
}
|
|
52
56
|
|
|
53
57
|
Description.propTypes = {
|
|
@@ -67,22 +71,23 @@ Description.propTypes = {
|
|
|
67
71
|
style:PropTypes.objectOf(PropTypes.string),
|
|
68
72
|
|
|
69
73
|
/**
|
|
70
|
-
*
|
|
74
|
+
* The base color for the description
|
|
71
75
|
*/
|
|
72
|
-
|
|
76
|
+
color:PropTypes.string,
|
|
77
|
+
|
|
73
78
|
/**
|
|
74
|
-
*
|
|
79
|
+
* Input description - extra description to guide a use in filling the input
|
|
75
80
|
*/
|
|
76
|
-
|
|
81
|
+
description:PropTypes.string,
|
|
82
|
+
|
|
77
83
|
/**
|
|
78
|
-
*
|
|
84
|
+
* The input name (html - and Formik state)
|
|
79
85
|
*/
|
|
80
|
-
|
|
86
|
+
name:PropTypes.string.isRequired,
|
|
81
87
|
}
|
|
82
88
|
|
|
83
89
|
Description.defaultProps = {
|
|
84
|
-
|
|
85
|
-
color :'metadata',
|
|
90
|
+
color:'metadata',
|
|
86
91
|
}
|
|
87
92
|
|
|
88
93
|
export default Description
|
|
@@ -29,10 +29,21 @@ $default-transition:all .3s;
|
|
|
29
29
|
z-index: -1;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
input:disabled + label {
|
|
33
|
+
background-color: var(--dark-x);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
input:not(:disabled) + label {
|
|
37
|
+
&:hover {
|
|
38
|
+
border-color: var(--light-y);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
32
42
|
label {
|
|
33
|
-
|
|
34
|
-
|
|
43
|
+
border: var(--theme-border-style) var(--dark-x);
|
|
44
|
+
background: var(--light-x);
|
|
35
45
|
color: var(--on-x);
|
|
46
|
+
border-radius: var(--theme-border-radius);
|
|
36
47
|
display: block;
|
|
37
48
|
height: 100%;
|
|
38
49
|
padding: $default-padding;
|
|
@@ -44,6 +55,10 @@ $default-transition:all .3s;
|
|
|
44
55
|
input:checked + label {
|
|
45
56
|
background: var(--y);
|
|
46
57
|
color: var(--on-y);
|
|
58
|
+
|
|
59
|
+
&:hover {
|
|
60
|
+
border-color: var(--y);
|
|
61
|
+
}
|
|
47
62
|
}
|
|
48
63
|
}
|
|
49
64
|
}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
2
|
+
import * as React from 'react'
|
|
3
|
+
|
|
4
|
+
import { useState, useLayoutEffect } from 'react'
|
|
5
|
+
|
|
6
|
+
import { useField } from 'formik'
|
|
7
|
+
|
|
8
|
+
import { useRelayEnvironment, fetchQuery } from 'react-relay'
|
|
9
|
+
|
|
10
|
+
import PropTypes from 'prop-types'
|
|
11
|
+
|
|
12
|
+
// Local Definitions
|
|
13
|
+
|
|
14
|
+
import { Combobox, MultipleCombobox } from './common'
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* This is the component description.
|
|
18
|
+
*/
|
|
19
|
+
const QueryCombobox = ({
|
|
20
|
+
id,
|
|
21
|
+
style,
|
|
22
|
+
className,
|
|
23
|
+
query,
|
|
24
|
+
multiple,
|
|
25
|
+
name,
|
|
26
|
+
label,
|
|
27
|
+
color,
|
|
28
|
+
description,
|
|
29
|
+
disabled,
|
|
30
|
+
debounceMs,
|
|
31
|
+
searchVariable,
|
|
32
|
+
extraVariables,
|
|
33
|
+
optionsKeyMap,
|
|
34
|
+
minLength,
|
|
35
|
+
transformSearch,
|
|
36
|
+
// ...otherProps
|
|
37
|
+
}) => {
|
|
38
|
+
useLayoutEffect(() => {
|
|
39
|
+
import('./styles.scss')
|
|
40
|
+
}, [])
|
|
41
|
+
|
|
42
|
+
const [, meta, helpers] = useField(name)
|
|
43
|
+
|
|
44
|
+
const { setValue, setError } = helpers
|
|
45
|
+
|
|
46
|
+
const { value } = meta
|
|
47
|
+
|
|
48
|
+
const environment = useRelayEnvironment()
|
|
49
|
+
|
|
50
|
+
const [isFetching, setIsFetching] = useState(false)
|
|
51
|
+
|
|
52
|
+
const [options, setOptions] = useState([])
|
|
53
|
+
|
|
54
|
+
const { graphql, accessor } = query
|
|
55
|
+
|
|
56
|
+
const getOptions = (inputValue) => {
|
|
57
|
+
if (isFetching) return
|
|
58
|
+
|
|
59
|
+
let variables = { [searchVariable]: inputValue }
|
|
60
|
+
|
|
61
|
+
if (extraVariables) {
|
|
62
|
+
variables = {
|
|
63
|
+
...variables,
|
|
64
|
+
...extraVariables,
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
fetchQuery(
|
|
69
|
+
environment,
|
|
70
|
+
graphql,
|
|
71
|
+
variables,
|
|
72
|
+
)
|
|
73
|
+
.subscribe({
|
|
74
|
+
start:() => {
|
|
75
|
+
setIsFetching(true)
|
|
76
|
+
},
|
|
77
|
+
complete:() => {
|
|
78
|
+
setIsFetching(false)
|
|
79
|
+
},
|
|
80
|
+
error:(fetchError) => {
|
|
81
|
+
setIsFetching(false)
|
|
82
|
+
if (setError)setError(fetchError.message)
|
|
83
|
+
},
|
|
84
|
+
next:(data) => {
|
|
85
|
+
setOptions(data[accessor].edges.map(({ node }) => ({
|
|
86
|
+
value:node[optionsKeyMap.value],
|
|
87
|
+
label:optionsKeyMap.getLabel(node),
|
|
88
|
+
})))
|
|
89
|
+
},
|
|
90
|
+
})
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const comboboxProps = {
|
|
94
|
+
id,
|
|
95
|
+
style,
|
|
96
|
+
options,
|
|
97
|
+
getOptions,
|
|
98
|
+
debounceMs,
|
|
99
|
+
disabled,
|
|
100
|
+
name,
|
|
101
|
+
label,
|
|
102
|
+
description,
|
|
103
|
+
setValue,
|
|
104
|
+
value,
|
|
105
|
+
color,
|
|
106
|
+
isFetching,
|
|
107
|
+
className,
|
|
108
|
+
minLength,
|
|
109
|
+
transformSearch,
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const Input = multiple ? MultipleCombobox : Combobox
|
|
113
|
+
|
|
114
|
+
return <Input {...comboboxProps} />
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
QueryCombobox.propTypes = {
|
|
118
|
+
/**
|
|
119
|
+
* The HTML id for this element
|
|
120
|
+
*/
|
|
121
|
+
id:PropTypes.string,
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* The HTML class names for this element
|
|
125
|
+
*/
|
|
126
|
+
className:PropTypes.string,
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* The React-written, css properties for this element.
|
|
130
|
+
*/
|
|
131
|
+
style:PropTypes.objectOf(PropTypes.string),
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* The name of the custom select input
|
|
135
|
+
*/
|
|
136
|
+
name:PropTypes.string,
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* The label of the custom select input
|
|
140
|
+
*/
|
|
141
|
+
label:PropTypes.string,
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* The custom select input description
|
|
145
|
+
*/
|
|
146
|
+
description:PropTypes.string,
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Whether the input should be disabled
|
|
150
|
+
*/
|
|
151
|
+
disabled:PropTypes.bool,
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* The base color of the custom select input
|
|
155
|
+
*/
|
|
156
|
+
color:PropTypes.string,
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* The debounce time in milliseconds
|
|
160
|
+
*/
|
|
161
|
+
debounceMs:PropTypes.number,
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* The graphql query to fetch the options and the accessor to destructure the results from
|
|
165
|
+
*/
|
|
166
|
+
query:PropTypes.shape({
|
|
167
|
+
accessor:PropTypes.string,
|
|
168
|
+
graphql :PropTypes.oneOfType([
|
|
169
|
+
PropTypes.string,
|
|
170
|
+
PropTypes.object,
|
|
171
|
+
]).isRequired,
|
|
172
|
+
}),
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* The extra variables required to be used in the query.
|
|
176
|
+
*/
|
|
177
|
+
extraVariables:PropTypes.objectOf(PropTypes.string),
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* The select option keys to be used to map the data to the select options.
|
|
181
|
+
* i.e `{ value: 'id', label: 'name' }`
|
|
182
|
+
*/
|
|
183
|
+
optionsKeyMap:PropTypes.shape({
|
|
184
|
+
value :PropTypes.string.isRequired,
|
|
185
|
+
getLabel:PropTypes.func.isRequired,
|
|
186
|
+
}),
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Whether to allow multiple items selection
|
|
190
|
+
*/
|
|
191
|
+
multiple:PropTypes.bool,
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* The graphql node to be used to destructure the fetched data
|
|
195
|
+
*/
|
|
196
|
+
graphQlNode:PropTypes.string.isRequired,
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* The variable to be used to search the data
|
|
200
|
+
*/
|
|
201
|
+
searchVariable:PropTypes.string,
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* The minimum length of the search input to start fetching the options
|
|
205
|
+
*/
|
|
206
|
+
minLength:PropTypes.number,
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* The function to transform the search input
|
|
210
|
+
*/
|
|
211
|
+
transformSearch:PropTypes.func,
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
QueryCombobox.defaultProps = {
|
|
215
|
+
optionsKeyMap:{
|
|
216
|
+
value :'id',
|
|
217
|
+
getLabel:(node) => node.name,
|
|
218
|
+
},
|
|
219
|
+
multiple :false,
|
|
220
|
+
color :'background2',
|
|
221
|
+
searchVariable :'search',
|
|
222
|
+
transformSearch:(search) => search,
|
|
223
|
+
minLength :2,
|
|
224
|
+
disabled :false,
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export default QueryCombobox
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
2
|
+
import * as React from 'react'
|
|
3
|
+
|
|
4
|
+
import { useEffect, useRef } from 'react'
|
|
5
|
+
|
|
6
|
+
import PropTypes from 'prop-types'
|
|
7
|
+
|
|
8
|
+
import { useCombobox } from 'downshift'
|
|
9
|
+
|
|
10
|
+
import styleNames from '@pareto-engineering/bem'
|
|
11
|
+
|
|
12
|
+
import { FormLabel, FormDescription } from 'ui/f'
|
|
13
|
+
|
|
14
|
+
import { Popover, LoadingCircle } from 'ui/a'
|
|
15
|
+
|
|
16
|
+
// Local Definitions
|
|
17
|
+
|
|
18
|
+
import { Menu } from '../Menu'
|
|
19
|
+
|
|
20
|
+
const baseClassName = styleNames.base
|
|
21
|
+
|
|
22
|
+
const componentClassName = 'combobox'
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* This is the component description.
|
|
26
|
+
*/
|
|
27
|
+
const Combobox = ({
|
|
28
|
+
id,
|
|
29
|
+
className:userClassName,
|
|
30
|
+
style,
|
|
31
|
+
label,
|
|
32
|
+
name,
|
|
33
|
+
options:items,
|
|
34
|
+
getOptions,
|
|
35
|
+
setValue,
|
|
36
|
+
description,
|
|
37
|
+
value,
|
|
38
|
+
color,
|
|
39
|
+
minLength,
|
|
40
|
+
isFetching,
|
|
41
|
+
transformSearch,
|
|
42
|
+
disabled,
|
|
43
|
+
// ...otherProps
|
|
44
|
+
}) => {
|
|
45
|
+
const {
|
|
46
|
+
isOpen,
|
|
47
|
+
selectItem,
|
|
48
|
+
selectedItem,
|
|
49
|
+
getLabelProps,
|
|
50
|
+
getMenuProps,
|
|
51
|
+
getInputProps,
|
|
52
|
+
highlightedIndex,
|
|
53
|
+
getComboboxProps,
|
|
54
|
+
getItemProps,
|
|
55
|
+
} = useCombobox({
|
|
56
|
+
items,
|
|
57
|
+
initialSelectedItem:value,
|
|
58
|
+
itemToString :(item) => (item ? item.label : ''),
|
|
59
|
+
onInputValueChange :({ inputValue }) => {
|
|
60
|
+
const transformedInput = transformSearch(inputValue)
|
|
61
|
+
if (transformedInput.length > minLength) {
|
|
62
|
+
getOptions(transformedInput)
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
// If the user has selected an item, we'll set the value of the field
|
|
68
|
+
// or if the combobox state has a selected item, we'll set the value to the formik state
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
if (selectedItem) {
|
|
71
|
+
setValue(selectedItem)
|
|
72
|
+
}
|
|
73
|
+
}, [selectedItem])
|
|
74
|
+
|
|
75
|
+
// If the formik state has a value, we'll set the selected item to the combobox state
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (value?.value !== selectedItem?.value) {
|
|
78
|
+
selectItem(value)
|
|
79
|
+
}
|
|
80
|
+
}, [value])
|
|
81
|
+
|
|
82
|
+
const parentRef = useRef(null)
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<div
|
|
86
|
+
id={id}
|
|
87
|
+
className={[
|
|
88
|
+
|
|
89
|
+
baseClassName,
|
|
90
|
+
|
|
91
|
+
componentClassName,
|
|
92
|
+
userClassName,
|
|
93
|
+
`y-${color}`,
|
|
94
|
+
]
|
|
95
|
+
.filter((e) => e)
|
|
96
|
+
.join(' ')}
|
|
97
|
+
style={style}
|
|
98
|
+
ref={parentRef}
|
|
99
|
+
>
|
|
100
|
+
<FormLabel {...getLabelProps()} name={name}>
|
|
101
|
+
{label}
|
|
102
|
+
</FormLabel>
|
|
103
|
+
|
|
104
|
+
<div {...getComboboxProps()} className="input-wrapper">
|
|
105
|
+
<input {...getInputProps()} className="input" disabled={disabled} />
|
|
106
|
+
{isFetching && (
|
|
107
|
+
<LoadingCircle className="x-main2" />
|
|
108
|
+
)}
|
|
109
|
+
</div>
|
|
110
|
+
|
|
111
|
+
<Popover
|
|
112
|
+
isOpen={isOpen}
|
|
113
|
+
parentRef={parentRef}
|
|
114
|
+
>
|
|
115
|
+
<Menu
|
|
116
|
+
isOpen={isOpen}
|
|
117
|
+
getItemProps={getItemProps}
|
|
118
|
+
highlightedIndex={highlightedIndex}
|
|
119
|
+
items={items}
|
|
120
|
+
{...getMenuProps()}
|
|
121
|
+
/>
|
|
122
|
+
</Popover>
|
|
123
|
+
|
|
124
|
+
<FormDescription className="v50 mt-v s-1" description={description} name={name} />
|
|
125
|
+
</div>
|
|
126
|
+
)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
Combobox.propTypes = {
|
|
130
|
+
/**
|
|
131
|
+
* The HTML id for this element
|
|
132
|
+
*/
|
|
133
|
+
id:PropTypes.string,
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* The HTML class names for this element
|
|
137
|
+
*/
|
|
138
|
+
className:PropTypes.string,
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* The React-written, css properties for this element.
|
|
142
|
+
*/
|
|
143
|
+
style:PropTypes.objectOf(PropTypes.string),
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* The label of the custom select input
|
|
147
|
+
*/
|
|
148
|
+
label:PropTypes.string,
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* The custom select input options from the backend
|
|
152
|
+
*/
|
|
153
|
+
options:PropTypes.arrayOf(
|
|
154
|
+
PropTypes.shape({
|
|
155
|
+
value:PropTypes.string,
|
|
156
|
+
label:PropTypes.string,
|
|
157
|
+
}),
|
|
158
|
+
),
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* The name of the custom select input
|
|
162
|
+
*/
|
|
163
|
+
name:PropTypes.string,
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* The function to fetch the options from the backend
|
|
167
|
+
*/
|
|
168
|
+
getOptions:PropTypes.func,
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* The function to set the value of the custom select input
|
|
172
|
+
*/
|
|
173
|
+
setValue:PropTypes.func.isRequired,
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* The custom select input description
|
|
177
|
+
*/
|
|
178
|
+
description:PropTypes.string,
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* The value of the custom select input
|
|
182
|
+
*/
|
|
183
|
+
value:PropTypes.shape({
|
|
184
|
+
value:PropTypes.string,
|
|
185
|
+
label:PropTypes.string,
|
|
186
|
+
}),
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* The base color of the combobox custom select input
|
|
190
|
+
*/
|
|
191
|
+
color:PropTypes.string,
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Whether the query getting the combobox options is inFlight
|
|
195
|
+
*/
|
|
196
|
+
isFetching:PropTypes.bool.isRequired,
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* The minimum length of the search input to start fetching the options
|
|
200
|
+
*/
|
|
201
|
+
minLength:PropTypes.number,
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* The function to transform the search input
|
|
205
|
+
*/
|
|
206
|
+
transformSearch:PropTypes.func,
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Whether the input filed shpuld be disabled
|
|
210
|
+
*/
|
|
211
|
+
disabled:PropTypes.bool,
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
Combobox.defaultProps = {
|
|
215
|
+
// someProp: false
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export default Combobox
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
2
|
+
import * as React from 'react'
|
|
3
|
+
|
|
4
|
+
import PropTypes from 'prop-types'
|
|
5
|
+
|
|
6
|
+
import styleNames from '@pareto-engineering/bem'
|
|
7
|
+
|
|
8
|
+
// Local Definitions
|
|
9
|
+
|
|
10
|
+
const baseClassName = styleNames.base
|
|
11
|
+
|
|
12
|
+
const componentClassName = 'menu'
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* This is the component description.
|
|
16
|
+
*/
|
|
17
|
+
const Menu = React.forwardRef(({
|
|
18
|
+
id,
|
|
19
|
+
className:userClassName,
|
|
20
|
+
style,
|
|
21
|
+
items,
|
|
22
|
+
isOpen,
|
|
23
|
+
highlightedIndex,
|
|
24
|
+
getItemProps,
|
|
25
|
+
...otherProps
|
|
26
|
+
}, ref) => (
|
|
27
|
+
<ul
|
|
28
|
+
id={id}
|
|
29
|
+
className={[
|
|
30
|
+
|
|
31
|
+
baseClassName,
|
|
32
|
+
|
|
33
|
+
componentClassName,
|
|
34
|
+
userClassName,
|
|
35
|
+
]
|
|
36
|
+
.filter((e) => e)
|
|
37
|
+
.join(' ')}
|
|
38
|
+
style={style}
|
|
39
|
+
ref={ref}
|
|
40
|
+
{...otherProps}
|
|
41
|
+
>
|
|
42
|
+
{isOpen && items.map((item, index) => (
|
|
43
|
+
<li
|
|
44
|
+
key={item.label}
|
|
45
|
+
{...getItemProps({ item, index })}
|
|
46
|
+
className={[
|
|
47
|
+
'item',
|
|
48
|
+
highlightedIndex === index && styleNames.modifierActive,
|
|
49
|
+
].filter(Boolean)
|
|
50
|
+
.join(' ')}
|
|
51
|
+
>
|
|
52
|
+
<p>
|
|
53
|
+
{item.label}
|
|
54
|
+
</p>
|
|
55
|
+
</li>
|
|
56
|
+
))}
|
|
57
|
+
</ul>
|
|
58
|
+
))
|
|
59
|
+
Menu.propTypes = {
|
|
60
|
+
/**
|
|
61
|
+
* The HTML id for this element
|
|
62
|
+
*/
|
|
63
|
+
id:PropTypes.string,
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* The HTML class names for this element
|
|
67
|
+
*/
|
|
68
|
+
className:PropTypes.string,
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The React-written, css properties for this element.
|
|
72
|
+
*/
|
|
73
|
+
style:PropTypes.objectOf(PropTypes.string),
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The items to be displayed in the menu
|
|
77
|
+
*/
|
|
78
|
+
items:PropTypes.arrayOf(PropTypes.shape({
|
|
79
|
+
value:PropTypes.string,
|
|
80
|
+
label:PropTypes.string,
|
|
81
|
+
})),
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Whether or not the menu is open
|
|
85
|
+
*/
|
|
86
|
+
isOpen:PropTypes.bool,
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* The index of the highlighted item
|
|
90
|
+
*/
|
|
91
|
+
highlightedIndex:PropTypes.number,
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* The function to get the item props
|
|
95
|
+
*/
|
|
96
|
+
getItemProps:PropTypes.func,
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
Menu.defaultProps = {
|
|
100
|
+
// someProp:false
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export default Menu
|