@tpzdsp/next-toolkit 2.5.1 → 3.1.0
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/package.json +21 -12
- package/src/assets/styles/globals.css +75 -95
- package/src/assets/styles/ol.css +57 -16
- package/src/assets/styles/utils.css +80 -0
- package/src/components/Accordion/Accordion.css +85 -0
- package/src/components/Accordion/Accordion.stories.tsx +264 -0
- package/src/components/Accordion/Accordion.tsx +98 -0
- package/src/components/Alert/Alert.css +129 -0
- package/src/components/Alert/Alert.stories.tsx +291 -0
- package/src/components/Alert/Alert.tsx +76 -0
- package/src/components/BackLink/BackLink.css +12 -0
- package/src/components/BackLink/BackLink.stories.tsx +52 -0
- package/src/components/BackLink/BackLink.tsx +44 -0
- package/src/components/BackToTop/BackToTop.css +23 -0
- package/src/components/BackToTop/BackToTop.stories.tsx +41 -0
- package/src/components/BackToTop/BackToTop.tsx +48 -0
- package/src/components/Breadcrumb/Breadcrumb.css +42 -0
- package/src/components/Breadcrumb/Breadcrumb.stories.tsx +94 -0
- package/src/components/Breadcrumb/Breadcrumb.tsx +135 -0
- package/src/components/Button/Button.css +229 -0
- package/src/components/Button/Button.stories.tsx +140 -20
- package/src/components/Button/Button.tsx +53 -28
- package/src/components/Button/ButtonSkeleton.stories.tsx +50 -0
- package/src/components/Button/ButtonSkeleton.tsx +14 -0
- package/src/components/ButtonGroup/ButtonGroup.css +52 -0
- package/src/components/ButtonGroup/ButtonGroup.stories.tsx +156 -0
- package/src/components/ButtonGroup/ButtonGroup.tsx +50 -0
- package/src/components/ButtonLink/ButtonLink.css +114 -0
- package/src/components/ButtonLink/ButtonLink.stories.tsx +38 -51
- package/src/components/ButtonLink/ButtonLink.tsx +54 -23
- package/src/components/Card/Card.css +13 -0
- package/src/components/Card/Card.stories.tsx +98 -57
- package/src/components/Card/Card.tsx +4 -13
- package/src/components/CardGroup/CardGroup.css +10 -0
- package/src/components/CardGroup/CardGroup.stories.tsx +81 -0
- package/src/components/CardGroup/CardGroup.tsx +9 -0
- package/src/components/Checkbox/Checkbox.css +49 -0
- package/src/components/Checkbox/Checkbox.stories.tsx +86 -0
- package/src/components/Checkbox/Checkbox.tsx +32 -0
- package/src/components/Chip/Chip.css +54 -0
- package/src/components/Chip/Chip.stories.tsx +94 -0
- package/src/components/Chip/Chip.tsx +34 -0
- package/src/components/CookieBanner/CookieBanner.css +19 -0
- package/src/components/CookieBanner/CookieBanner.stories.tsx +52 -0
- package/src/components/CookieBanner/CookieBanner.tsx +55 -0
- package/src/components/CopyButton/CopyButton.stories.tsx +28 -0
- package/src/components/CopyButton/CopyButton.tsx +65 -0
- package/src/components/DateInput/DateInput.css +13 -0
- package/src/components/DateInput/DateInput.stories.tsx +131 -0
- package/src/components/DateInput/DateInput.test.tsx +21 -0
- package/src/components/DateInput/DateInput.tsx +98 -0
- package/src/components/Details/Details.css +28 -0
- package/src/components/Details/Details.stories.tsx +48 -0
- package/src/components/Details/Details.tsx +41 -0
- package/src/components/Dropdown/Dropdown.css +81 -0
- package/src/components/Dropdown/Dropdown.stories.tsx +131 -0
- package/src/components/Dropdown/Dropdown.tsx +69 -0
- package/src/components/ErrorBoundary/ErrorBoundary.stories.tsx +4 -39
- package/src/components/ErrorBoundary/ErrorBoundary.tsx +7 -4
- package/src/components/ErrorBoundary/ErrorFallback.tsx +32 -66
- package/src/components/ErrorModal/ErrorModal.css +34 -0
- package/src/components/ErrorModal/ErrorModal.stories.tsx +100 -0
- package/src/components/ErrorModal/ErrorModal.tsx +123 -0
- package/src/components/ErrorText/ErrorText.css +22 -0
- package/src/components/ErrorText/ErrorText.stories.tsx +42 -27
- package/src/components/ErrorText/ErrorText.tsx +10 -8
- package/src/components/ExternalLink/ExternalLink.css +12 -0
- package/src/components/ExternalLink/ExternalLink.stories.tsx +43 -0
- package/src/components/ExternalLink/ExternalLink.tsx +43 -0
- package/src/components/Fieldset/Fieldset.css +103 -0
- package/src/components/Fieldset/Fieldset.stories.tsx +304 -0
- package/src/components/Fieldset/Fieldset.tsx +38 -0
- package/src/components/FileUpload/FileUpload.css +85 -0
- package/src/components/FileUpload/FileUpload.stories.tsx +106 -0
- package/src/components/FileUpload/FileUpload.tsx +99 -0
- package/src/components/{layout/footer → Footer}/Copyright.tsx +3 -2
- package/src/components/Footer/Footer.stories.tsx +27 -0
- package/src/components/Footer/Footer.tsx +46 -0
- package/src/components/Footer/Licence.tsx +18 -0
- package/src/components/Footer/MetaLinks.tsx +47 -0
- package/src/components/Footer/Small/SmallFooter.stories.tsx +3 -0
- package/src/components/Footer/Small/SmallFooter.tsx +53 -41
- package/src/components/Form/FormGroup.css +18 -0
- package/src/components/Form/FormGroup.stories.tsx +87 -0
- package/src/components/Form/FormGroup.tsx +16 -0
- package/src/components/{layout/header → Header}/Header.stories.tsx +26 -12
- package/src/components/Header/Header.test.tsx +87 -0
- package/src/components/Header/Header.tsx +304 -0
- package/src/components/Header/HeaderAppContent.tsx +120 -0
- package/src/components/Heading/Heading.css +40 -0
- package/src/components/Heading/Heading.stories.tsx +15 -5
- package/src/components/Heading/Heading.tsx +21 -44
- package/src/components/Heading/HeadingSkeleton.stories.tsx +30 -0
- package/src/components/Heading/HeadingSkeleton.tsx +14 -0
- package/src/components/Hero/Hero.css +19 -0
- package/src/components/Hero/Hero.stories.tsx +41 -0
- package/src/components/Hero/Hero.tsx +14 -0
- package/src/components/HintText/HintText.css +5 -0
- package/src/components/HintText/HintText.stories.tsx +29 -0
- package/src/components/HintText/HintText.tsx +13 -0
- package/src/components/InfoBox/InfoBox.css +38 -0
- package/src/components/InfoBox/InfoBox.stories.tsx +51 -403
- package/src/components/InfoBox/InfoBox.tsx +31 -158
- package/src/components/Input/Input.css +77 -0
- package/src/components/Input/Input.stories.tsx +123 -0
- package/src/components/Input/Input.tsx +74 -0
- package/src/components/InputGroup/InputGroup.css +140 -0
- package/src/components/InputGroup/InputGroup.stories.tsx +125 -0
- package/src/components/InputGroup/InputGroup.tsx +47 -0
- package/src/components/InsetText/InsetText.css +5 -0
- package/src/components/InsetText/InsetText.stories.tsx +30 -0
- package/src/components/InsetText/InsetText.tsx +9 -0
- package/src/components/Keyboard/Keyboard.css +9 -0
- package/src/components/Keyboard/Keyboard.stories.tsx +63 -0
- package/src/components/Keyboard/Keyboard.tsx +30 -0
- package/src/components/Label/Label.css +27 -0
- package/src/components/Label/Label.stories.tsx +40 -0
- package/src/components/Label/Label.tsx +17 -0
- package/src/components/LayerSwitcher/LayerSwitcher.css +59 -0
- package/src/components/LayerSwitcher/LayerSwitcher.stories.tsx +112 -0
- package/src/components/LayerSwitcher/LayerSwitcher.tsx +61 -0
- package/src/components/Layout/401/401.stories.tsx +23 -0
- package/src/components/Layout/401/401.tsx +1 -0
- package/src/components/Layout/403/403.stories.tsx +23 -0
- package/src/components/Layout/403/403.tsx +21 -0
- package/src/components/Layout/404/404.stories.tsx +23 -0
- package/src/components/Layout/404/404.tsx +28 -0
- package/src/components/Layout/500/500.stories.tsx +56 -0
- package/src/components/Layout/500/500.tsx +63 -0
- package/src/components/Layout/ButtonGroup/ButtonGroup.css +52 -0
- package/src/components/Layout/ButtonGroup/ButtonGroup.stories.tsx +156 -0
- package/src/components/Layout/ButtonGroup/ButtonGroup.tsx +50 -0
- package/src/components/Layout/HeadingGroup/HeadingGroup.css +21 -0
- package/src/components/Layout/HeadingGroup/HeadingGroup.stories.tsx +84 -0
- package/src/components/Layout/HeadingGroup/HeadingGroup.tsx +9 -0
- package/src/components/Layout/MainWrapper/MainWrapper.css +12 -0
- package/src/components/Layout/MainWrapper/MainWrapper.stories.tsx +36 -0
- package/src/components/Layout/MainWrapper/MainWrapper.tsx +14 -0
- package/src/components/Layout/PageShell/PageShell.css +42 -0
- package/src/components/Layout/PageShell/PageShell.stories.tsx +108 -0
- package/src/components/Layout/PageShell/PageShell.tsx +31 -0
- package/src/components/Layout/ParagraphGroup/ParagraphGroup.css +5 -0
- package/src/components/Layout/ParagraphGroup/ParagraphGroup.stories.tsx +34 -0
- package/src/components/Layout/ParagraphGroup/ParagraphGroup.tsx +9 -0
- package/src/components/Layout/Stack/Stack.css +29 -0
- package/src/components/Layout/Stack/Stack.stories.tsx +83 -0
- package/src/components/Layout/Stack/Stack.tsx +19 -0
- package/src/components/Layout/WidthContainer/WidthContainer.css +17 -0
- package/src/components/Layout/WidthContainer/WidthContainer.stories.tsx +59 -0
- package/src/components/Layout/WidthContainer/WidthContainer.tsx +13 -0
- package/src/components/Legend/Legend.css +95 -0
- package/src/components/Legend/Legend.stories.tsx +81 -0
- package/src/components/Legend/Legend.tsx +32 -0
- package/src/components/Legend/LegendDot.tsx +15 -0
- package/src/components/Legend/LegendPanel.stories.tsx +101 -0
- package/src/components/Legend/LegendPanel.tsx +68 -0
- package/src/components/Legend/LegendSkeleton.stories.tsx +87 -0
- package/src/components/Legend/LegendSkeleton.tsx +73 -0
- package/src/components/LegendSelect/LegendSelect.css +8 -0
- package/src/components/LegendSelect/LegendSelect.stories.tsx +80 -0
- package/src/components/LegendSelect/LegendSelect.tsx +26 -0
- package/src/components/Link/Link.css +98 -0
- package/src/components/Link/Link.stories.tsx +70 -0
- package/src/components/Link/Link.tsx +52 -0
- package/src/components/LinkButton/LinkButton.css +67 -0
- package/src/components/LinkButton/LinkButton.stories.tsx +90 -42
- package/src/components/LinkButton/LinkButton.tsx +50 -63
- package/src/components/LinkList/LinkList.css +28 -0
- package/src/components/LinkList/LinkList.stories.tsx +46 -0
- package/src/components/LinkList/LinkList.tsx +23 -0
- package/src/components/List/Li.tsx +9 -0
- package/src/components/List/List.css +9 -0
- package/src/components/List/OrderedList.stories.tsx +36 -0
- package/src/components/List/OrderedList.tsx +9 -0
- package/src/components/List/UnorderedList.stories.tsx +36 -0
- package/src/components/List/UnorderedList.tsx +9 -0
- package/src/components/LoadingBox/LoadingBox.css +27 -0
- package/src/components/LoadingBox/LoadingBox.stories.tsx +66 -0
- package/src/components/LoadingBox/LoadingBox.tsx +40 -0
- package/src/components/Modal/Modal.css +111 -0
- package/src/components/Modal/Modal.stories.tsx +94 -155
- package/src/components/Modal/Modal.tsx +141 -75
- package/src/components/NoScriptBanner/NoScriptBanner.css +17 -0
- package/src/components/NoScriptBanner/NoScriptBanner.stories.tsx +46 -0
- package/src/components/NoScriptBanner/NoScriptBanner.tsx +26 -0
- package/src/components/Paragraph/Paragraph.css +22 -0
- package/src/components/Paragraph/Paragraph.stories.tsx +1 -42
- package/src/components/Paragraph/Paragraph.tsx +4 -3
- package/src/components/Paragraph/ParagraphSkeleton.stories.tsx +44 -0
- package/src/components/Paragraph/ParagraphSkeleton.tsx +33 -0
- package/src/components/PasswordInput/PasswordInput.css +3 -0
- package/src/components/PasswordInput/PasswordInput.stories.tsx +47 -0
- package/src/components/PasswordInput/PasswordInput.tsx +45 -0
- package/src/components/PhaseBanner/PhaseBanner.css +12 -0
- package/src/components/PhaseBanner/PhaseBanner.stories.tsx +61 -0
- package/src/components/PhaseBanner/PhaseBanner.tsx +17 -0
- package/src/components/Popover/Popover.css +43 -0
- package/src/components/Popover/Popover.stories.tsx +102 -0
- package/src/components/Popover/Popover.tsx +40 -0
- package/src/components/Radio/Radio.css +69 -0
- package/src/components/Radio/Radio.stories.tsx +169 -0
- package/src/components/Radio/Radio.tsx +56 -0
- package/src/components/Resizable/Resizable.css +86 -0
- package/src/components/Resizable/Resizable.stories.tsx +123 -0
- package/src/components/Resizable/Resizable.tsx +86 -0
- package/src/components/ScrollArea/ScrollArea.css +9 -0
- package/src/components/ScrollArea/ScrollArea.stories.tsx +42 -0
- package/src/components/ScrollArea/ScrollArea.tsx +11 -0
- package/src/components/SearchBox/SearchBox.stories.tsx +88 -0
- package/src/components/SearchBox/SearchBox.tsx +36 -0
- package/src/components/Select/AsyncSelect.stories.tsx +84 -0
- package/src/components/Select/AsyncSelect.tsx +41 -0
- package/src/components/Select/Select.css +202 -0
- package/src/components/Select/Select.stories.tsx +162 -0
- package/src/components/Select/Select.test.tsx +36 -0
- package/src/components/Select/Select.tsx +296 -0
- package/src/components/Select/SelectSkeleton.stories.tsx +51 -0
- package/src/components/Select/SelectSkeleton.tsx +23 -0
- package/src/components/Separator/Separator.css +41 -0
- package/src/components/Separator/Separator.stories.tsx +63 -0
- package/src/components/Separator/Separator.tsx +42 -0
- package/src/components/Sidebar/ResizableSidebar.tsx +118 -0
- package/src/components/Sidebar/Sidebar.css +203 -0
- package/src/components/Sidebar/Sidebar.stories.tsx +438 -0
- package/src/components/Sidebar/Sidebar.tsx +225 -0
- package/src/components/Skeleton/Skeleton.css +16 -0
- package/src/components/Skeleton/Skeleton.stories.tsx +39 -0
- package/src/components/Skeleton/Skeleton.tsx +12 -0
- package/src/components/SkipLink/SkipLink.css +16 -0
- package/src/components/SkipLink/SkipLink.stories.tsx +40 -0
- package/src/components/SkipLink/SkipLink.tsx +15 -0
- package/src/components/Spinner/Spinner.css +30 -0
- package/src/components/Spinner/Spinner.stories.tsx +36 -0
- package/src/components/Spinner/Spinner.tsx +45 -0
- package/src/components/StartButton/StartButton.css +13 -0
- package/src/components/StartButton/StartButton.stories.tsx +68 -0
- package/src/components/StartButton/StartButton.tsx +50 -0
- package/src/components/SubmitButton/SubmitButton.stories.tsx +31 -0
- package/src/components/SubmitButton/SubmitButton.tsx +14 -0
- package/src/components/SummaryList/SummaryList.css +71 -0
- package/src/components/SummaryList/SummaryList.stories.tsx +211 -0
- package/src/components/SummaryList/SummaryList.tsx +41 -0
- package/src/components/SummaryList/SummaryListSkeleton.stories.tsx +67 -0
- package/src/components/SummaryList/SummaryListSkeleton.tsx +40 -0
- package/src/components/Tabs/Tabs.css +84 -0
- package/src/components/Tabs/Tabs.stories.tsx +133 -0
- package/src/components/Tabs/Tabs.tsx +66 -0
- package/src/components/Tag/Tag.css +8 -0
- package/src/components/Tag/Tag.stories.tsx +96 -0
- package/src/components/Tag/Tag.tsx +34 -0
- package/src/components/Textarea/Textarea.css +38 -0
- package/src/components/Textarea/Textarea.stories.tsx +131 -0
- package/src/components/Textarea/Textarea.tsx +50 -0
- package/src/components/TextareaCount/TextareaCount.css +17 -0
- package/src/components/TextareaCount/TextareaCount.stories.tsx +131 -0
- package/src/components/TextareaCount/TextareaCount.tsx +108 -0
- package/src/components/Tooltip/Tooltip.css +43 -0
- package/src/components/Tooltip/Tooltip.stories.tsx +110 -0
- package/src/components/Tooltip/Tooltip.tsx +53 -0
- package/src/components/WarningText/WarningText.css +20 -0
- package/src/components/WarningText/WarningText.stories.tsx +29 -0
- package/src/components/WarningText/WarningText.tsx +17 -0
- package/src/components/index.ts +343 -61
- package/src/errors/errorDisplay.ts +70 -0
- package/src/errors/index.ts +1 -0
- package/src/http/constants.ts +2 -0
- package/src/http/fetch.ts +7 -3
- package/src/map/LayerSwitcherPanel.tsx +2 -173
- package/src/map/LegendShim.tsx +2 -0
- package/src/map/MapComponent.tsx +7 -17
- package/src/map/MapControlsOverlay.tsx +68 -175
- package/src/map/Popup.tsx +71 -24
- package/src/map/geocoder/Geocoder.test.tsx +46 -3
- package/src/map/geocoder/Geocoder.tsx +155 -278
- package/src/map/index.ts +1 -1
- package/src/types/utils.ts +0 -10
- package/src/utils/components.ts +96 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/utils.ts +0 -12
- package/src/assets/images/defra-logo.svg +0 -51
- package/src/assets/images/ea-logo.svg +0 -58
- package/src/assets/images/ogl.svg +0 -1
- package/src/components/Button/Button.test.tsx +0 -53
- package/src/components/ButtonLink/ButtonLink.test.tsx +0 -154
- package/src/components/Card/Card.test.tsx +0 -51
- package/src/components/ErrorBoundary/ErrorBoundary.test.tsx +0 -75
- package/src/components/ErrorBoundary/ErrorFallback.test.tsx +0 -107
- package/src/components/ErrorText/ErrorText.test.tsx +0 -33
- package/src/components/Heading/Heading.test.tsx +0 -22
- package/src/components/Hint/Hint.stories.tsx +0 -58
- package/src/components/Hint/Hint.test.tsx +0 -33
- package/src/components/Hint/Hint.tsx +0 -12
- package/src/components/InfoBox/InfoBox.test.tsx +0 -330
- package/src/components/InfoBox/types.ts +0 -6
- package/src/components/LinkButton/LinkButton.test.tsx +0 -177
- package/src/components/Modal/Modal.test.tsx +0 -246
- package/src/components/NotificationBanner/NotificationBanner.stories.tsx +0 -45
- package/src/components/NotificationBanner/NotificationBanner.test.tsx +0 -58
- package/src/components/NotificationBanner/NotificationBanner.tsx +0 -45
- package/src/components/Paragraph/Paragraph.test.tsx +0 -10
- package/src/components/SlidingPanel/SlidingPanel.stories.tsx +0 -129
- package/src/components/SlidingPanel/SlidingPanel.test.tsx +0 -83
- package/src/components/SlidingPanel/SlidingPanel.tsx +0 -258
- package/src/components/accordion/Accordion.stories.tsx +0 -234
- package/src/components/accordion/Accordion.test.tsx +0 -192
- package/src/components/accordion/Accordion.tsx +0 -73
- package/src/components/backToTop/BackToTop.stories.tsx +0 -407
- package/src/components/backToTop/BackToTop.test.tsx +0 -57
- package/src/components/backToTop/BackToTop.tsx +0 -134
- package/src/components/chip/Chip.stories.tsx +0 -61
- package/src/components/chip/Chip.test.tsx +0 -31
- package/src/components/chip/Chip.tsx +0 -23
- package/src/components/container/Container.tsx +0 -42
- package/src/components/cookieBanner/CookieBanner.stories.tsx +0 -257
- package/src/components/cookieBanner/CookieBanner.test.tsx +0 -68
- package/src/components/cookieBanner/CookieBanner.tsx +0 -73
- package/src/components/divider/RuleDivider.stories.tsx +0 -254
- package/src/components/divider/RuleDivider.test.tsx +0 -164
- package/src/components/divider/RuleDivider.tsx +0 -23
- package/src/components/dropdown/DropdownMenu.test.tsx +0 -211
- package/src/components/dropdown/DropdownMenu.tsx +0 -108
- package/src/components/dropdown/useDropdownMenu.ts +0 -249
- package/src/components/form/Input.stories.tsx +0 -435
- package/src/components/form/Input.test.tsx +0 -206
- package/src/components/form/Input.tsx +0 -23
- package/src/components/form/TextArea.stories.tsx +0 -464
- package/src/components/form/TextArea.test.tsx +0 -232
- package/src/components/form/TextArea.tsx +0 -23
- package/src/components/layout/footer/Footer.tsx +0 -26
- package/src/components/layout/footer/Licence.tsx +0 -19
- package/src/components/layout/footer/MetaLinks.tsx +0 -36
- package/src/components/layout/header/Header.test.tsx +0 -36
- package/src/components/layout/header/Header.tsx +0 -90
- package/src/components/layout/header/HeaderAuthClient.test.tsx +0 -45
- package/src/components/layout/header/HeaderAuthClient.tsx +0 -40
- package/src/components/layout/header/HeaderNavClient.test.tsx +0 -44
- package/src/components/layout/header/HeaderNavClient.tsx +0 -67
- package/src/components/link/ExternalLink.test.tsx +0 -102
- package/src/components/link/ExternalLink.tsx +0 -29
- package/src/components/link/Link.tsx +0 -26
- package/src/components/select/Select.stories.tsx +0 -336
- package/src/components/select/Select.test.tsx +0 -474
- package/src/components/select/Select.tsx +0 -125
- package/src/components/select/SelectSkeleton.stories.tsx +0 -194
- package/src/components/select/SelectSkeleton.test.tsx +0 -104
- package/src/components/select/SelectSkeleton.tsx +0 -23
- package/src/components/select/common.ts +0 -3
- package/src/components/select/index.ts +0 -18
- package/src/components/skipLink/SkipLink.stories.tsx +0 -346
- package/src/components/skipLink/SkipLink.test.tsx +0 -22
- package/src/components/skipLink/SkipLink.tsx +0 -49
- package/src/map/LegendPanel.tsx +0 -85
- /package/src/{components → assets}/images/DefraLogo.tsx +0 -0
- /package/src/{components → assets}/images/EaLogo.tsx +0 -0
- /package/src/{components → assets}/images/OglLogo.tsx +0 -0
- /package/src/components/{googleAnalytics → GoogleAnalytics}/GlobalVars.tsx +0 -0
- /package/src/components/{googleAnalytics → GoogleAnalytics}/GoogleAnalytics.tsx +0 -0
|
@@ -1,336 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import { fn } from 'storybook/test';
|
|
4
|
-
|
|
5
|
-
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
6
|
-
|
|
7
|
-
import { Select } from './Select';
|
|
8
|
-
|
|
9
|
-
const meta = {
|
|
10
|
-
title: 'Components/Select',
|
|
11
|
-
component: Select,
|
|
12
|
-
parameters: {
|
|
13
|
-
layout: 'centered',
|
|
14
|
-
},
|
|
15
|
-
tags: ['autodocs'],
|
|
16
|
-
args: {
|
|
17
|
-
onChange: fn(),
|
|
18
|
-
},
|
|
19
|
-
} satisfies Meta<typeof Select>;
|
|
20
|
-
|
|
21
|
-
export default meta;
|
|
22
|
-
type Story = StoryObj<typeof meta>;
|
|
23
|
-
|
|
24
|
-
const OPTIONS = [
|
|
25
|
-
{ value: 'chocolate', label: 'Chocolate' },
|
|
26
|
-
{ value: 'strawberry', label: 'Strawberry' },
|
|
27
|
-
{ value: 'vanilla', label: 'Vanilla' },
|
|
28
|
-
{ value: 'mint', label: 'Mint' },
|
|
29
|
-
{ value: 'cookies', label: 'Cookies & Cream' },
|
|
30
|
-
] as const;
|
|
31
|
-
|
|
32
|
-
const GROUPED_OPTIONS = [
|
|
33
|
-
{
|
|
34
|
-
label: 'Fruits',
|
|
35
|
-
options: [
|
|
36
|
-
{ value: 'apple', label: 'Apple' },
|
|
37
|
-
{ value: 'banana', label: 'Banana' },
|
|
38
|
-
{ value: 'orange', label: 'Orange' },
|
|
39
|
-
],
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
label: 'Vegetables',
|
|
43
|
-
options: [
|
|
44
|
-
{ value: 'carrot', label: 'Carrot' },
|
|
45
|
-
{ value: 'broccoli', label: 'Broccoli' },
|
|
46
|
-
{ value: 'spinach', label: 'Spinach' },
|
|
47
|
-
],
|
|
48
|
-
},
|
|
49
|
-
] as const;
|
|
50
|
-
|
|
51
|
-
const USERS = [
|
|
52
|
-
{ value: 'john', label: 'John Doe', email: 'john@example.com' },
|
|
53
|
-
{ value: 'jane', label: 'Jane Smith', email: 'jane@example.com' },
|
|
54
|
-
{ value: 'bob', label: 'Bob Johnson', email: 'bob@example.com' },
|
|
55
|
-
] as const;
|
|
56
|
-
|
|
57
|
-
const FLAVOUR_PLACEHOLDER_TEXT = 'Select a flavour...' as const;
|
|
58
|
-
const FLAVOUR_MULTI_PLACEHOLDER_TEXT = 'Select multiple flavours...' as const;
|
|
59
|
-
|
|
60
|
-
export const Default: Story = {
|
|
61
|
-
args: {
|
|
62
|
-
options: OPTIONS,
|
|
63
|
-
placeholder: FLAVOUR_PLACEHOLDER_TEXT,
|
|
64
|
-
},
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export const WithDefaultValue: Story = {
|
|
68
|
-
args: {
|
|
69
|
-
options: OPTIONS,
|
|
70
|
-
defaultValue: OPTIONS[0],
|
|
71
|
-
placeholder: FLAVOUR_PLACEHOLDER_TEXT,
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export const Clearable: Story = {
|
|
76
|
-
args: {
|
|
77
|
-
options: OPTIONS,
|
|
78
|
-
defaultValue: OPTIONS[1],
|
|
79
|
-
isClearable: true,
|
|
80
|
-
placeholder: FLAVOUR_PLACEHOLDER_TEXT,
|
|
81
|
-
},
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export const Searchable: Story = {
|
|
85
|
-
args: {
|
|
86
|
-
options: OPTIONS,
|
|
87
|
-
isSearchable: true,
|
|
88
|
-
placeholder: 'Search and select...',
|
|
89
|
-
},
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
export const MultiSelect: Story = {
|
|
93
|
-
args: {
|
|
94
|
-
options: OPTIONS,
|
|
95
|
-
isMulti: true,
|
|
96
|
-
placeholder: FLAVOUR_MULTI_PLACEHOLDER_TEXT,
|
|
97
|
-
},
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
export const MultiSelectWithValues: Story = {
|
|
101
|
-
args: {
|
|
102
|
-
options: OPTIONS,
|
|
103
|
-
isMulti: true,
|
|
104
|
-
defaultValue: [OPTIONS[0], OPTIONS[2]],
|
|
105
|
-
placeholder: FLAVOUR_MULTI_PLACEHOLDER_TEXT,
|
|
106
|
-
},
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
export const MultiSelectClearable: Story = {
|
|
110
|
-
args: {
|
|
111
|
-
options: OPTIONS,
|
|
112
|
-
isMulti: true,
|
|
113
|
-
isClearable: true,
|
|
114
|
-
defaultValue: [OPTIONS[0], OPTIONS[1]],
|
|
115
|
-
placeholder: FLAVOUR_MULTI_PLACEHOLDER_TEXT,
|
|
116
|
-
},
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
export const Disabled: Story = {
|
|
120
|
-
args: {
|
|
121
|
-
options: OPTIONS,
|
|
122
|
-
isDisabled: true,
|
|
123
|
-
defaultValue: OPTIONS[0],
|
|
124
|
-
placeholder: 'This select is disabled',
|
|
125
|
-
},
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
export const Loading: Story = {
|
|
129
|
-
args: {
|
|
130
|
-
options: OPTIONS,
|
|
131
|
-
isLoading: true,
|
|
132
|
-
placeholder: 'Loading...',
|
|
133
|
-
},
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
export const GroupedOptions: Story = {
|
|
137
|
-
args: {
|
|
138
|
-
options: GROUPED_OPTIONS,
|
|
139
|
-
placeholder: 'Select a food item...',
|
|
140
|
-
},
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
export const NoOptionsMessage: Story = {
|
|
144
|
-
args: {
|
|
145
|
-
options: [],
|
|
146
|
-
placeholder: 'No options available',
|
|
147
|
-
noOptionsMessage: () => 'No options found',
|
|
148
|
-
},
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
export const CustomFormatOptionLabel: Story = {
|
|
152
|
-
args: {
|
|
153
|
-
options: USERS,
|
|
154
|
-
placeholder: 'Select a user...',
|
|
155
|
-
formatOptionLabel: (data: unknown) => {
|
|
156
|
-
const option = data as { value: string; label: string; email: string };
|
|
157
|
-
|
|
158
|
-
return (
|
|
159
|
-
<div>
|
|
160
|
-
<div className="font-medium">{option.label}</div>
|
|
161
|
-
|
|
162
|
-
<div className="text-sm text-gray-500">{option.email}</div>
|
|
163
|
-
</div>
|
|
164
|
-
);
|
|
165
|
-
},
|
|
166
|
-
},
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
export const CustomClassNames: Story = {
|
|
170
|
-
args: {
|
|
171
|
-
options: OPTIONS,
|
|
172
|
-
placeholder: 'Custom styled select...',
|
|
173
|
-
classNames: {
|
|
174
|
-
control: () => 'border-2 border-purple-500 rounded-lg',
|
|
175
|
-
option: (state) =>
|
|
176
|
-
// eslint-disable-next-line sonarjs/no-nested-conditional
|
|
177
|
-
state.isSelected ? 'bg-purple-500 text-white' : state.isFocused ? 'bg-purple-100' : '',
|
|
178
|
-
menu: () => 'border-purple-500',
|
|
179
|
-
},
|
|
180
|
-
},
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
export const SmallSize: Story = {
|
|
184
|
-
args: {
|
|
185
|
-
options: OPTIONS,
|
|
186
|
-
placeholder: 'Small select...',
|
|
187
|
-
classNames: {
|
|
188
|
-
control: () => 'min-h-8 text-sm',
|
|
189
|
-
option: () => 'px-2 py-1 text-sm',
|
|
190
|
-
},
|
|
191
|
-
},
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
export const LargeSize: Story = {
|
|
195
|
-
args: {
|
|
196
|
-
options: OPTIONS,
|
|
197
|
-
placeholder: 'Large select...',
|
|
198
|
-
classNames: {
|
|
199
|
-
control: () => 'min-h-12 text-lg',
|
|
200
|
-
option: () => 'px-6 py-3 text-lg',
|
|
201
|
-
},
|
|
202
|
-
},
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
export const ControlledComponent: Story = {
|
|
206
|
-
render: () => {
|
|
207
|
-
const [value, setValue] = useState<{ value: string; label: string } | null>(OPTIONS[0]);
|
|
208
|
-
|
|
209
|
-
return (
|
|
210
|
-
<div className="space-y-4">
|
|
211
|
-
<Select
|
|
212
|
-
options={OPTIONS}
|
|
213
|
-
value={value}
|
|
214
|
-
onChange={(newValue) => setValue(newValue)}
|
|
215
|
-
placeholder="Controlled select..."
|
|
216
|
-
/>
|
|
217
|
-
|
|
218
|
-
<div className="text-sm text-gray-600">Selected: {value ? value.label : 'None'}</div>
|
|
219
|
-
|
|
220
|
-
<button
|
|
221
|
-
onClick={() => setValue(OPTIONS[2])}
|
|
222
|
-
className="px-3 py-1 bg-blue-500 text-white rounded text-sm"
|
|
223
|
-
>
|
|
224
|
-
Set to Vanilla
|
|
225
|
-
</button>
|
|
226
|
-
</div>
|
|
227
|
-
);
|
|
228
|
-
},
|
|
229
|
-
};
|
|
230
|
-
export const WithLongOptions: Story = {
|
|
231
|
-
args: {
|
|
232
|
-
options: [
|
|
233
|
-
{ value: 'short', label: 'Short' },
|
|
234
|
-
{
|
|
235
|
-
value: 'long',
|
|
236
|
-
label: 'This is a very long option that might overflow and needs to be handled properly',
|
|
237
|
-
},
|
|
238
|
-
{
|
|
239
|
-
value: 'medium',
|
|
240
|
-
label: 'Medium length option text',
|
|
241
|
-
},
|
|
242
|
-
],
|
|
243
|
-
placeholder: 'Select an option...',
|
|
244
|
-
},
|
|
245
|
-
};
|
|
246
|
-
|
|
247
|
-
export const Async: Story = {
|
|
248
|
-
render: () => {
|
|
249
|
-
const [options, setOptions] = useState<{ value: string; label: string }[]>([]);
|
|
250
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
251
|
-
|
|
252
|
-
const loadOptions = () => {
|
|
253
|
-
setIsLoading(true);
|
|
254
|
-
// Simulate API call
|
|
255
|
-
setTimeout(() => {
|
|
256
|
-
setOptions([
|
|
257
|
-
{ value: 'async1', label: 'Async Option 1' },
|
|
258
|
-
{ value: 'async2', label: 'Async Option 2' },
|
|
259
|
-
{ value: 'async3', label: 'Async Option 3' },
|
|
260
|
-
]);
|
|
261
|
-
setIsLoading(false);
|
|
262
|
-
}, 1000);
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
useEffect(() => {
|
|
266
|
-
loadOptions();
|
|
267
|
-
}, []);
|
|
268
|
-
|
|
269
|
-
return (
|
|
270
|
-
<div className="space-y-4">
|
|
271
|
-
<Select options={options} isLoading={isLoading} placeholder="Loading async options..." />
|
|
272
|
-
|
|
273
|
-
<button onClick={loadOptions} className="px-3 py-1 bg-green-500 text-white rounded text-sm">
|
|
274
|
-
Reload Options
|
|
275
|
-
</button>
|
|
276
|
-
</div>
|
|
277
|
-
);
|
|
278
|
-
},
|
|
279
|
-
};
|
|
280
|
-
|
|
281
|
-
export const FormIntegration: Story = {
|
|
282
|
-
render: () => {
|
|
283
|
-
const [formData, setFormData] = useState<{
|
|
284
|
-
flavour: { value: string; label: string } | null;
|
|
285
|
-
toppings: { value: string; label: string }[];
|
|
286
|
-
}>({
|
|
287
|
-
flavour: null,
|
|
288
|
-
toppings: [],
|
|
289
|
-
});
|
|
290
|
-
|
|
291
|
-
return (
|
|
292
|
-
<form className="space-y-4 p-4 border rounded">
|
|
293
|
-
<div>
|
|
294
|
-
<label htmlFor="flavour" className="block text-sm font-medium mb-1">
|
|
295
|
-
Flavour
|
|
296
|
-
</label>
|
|
297
|
-
|
|
298
|
-
<Select
|
|
299
|
-
id="flavour"
|
|
300
|
-
options={OPTIONS}
|
|
301
|
-
value={formData.flavour}
|
|
302
|
-
onChange={(value) => setFormData({ ...formData, flavour: value })}
|
|
303
|
-
placeholder="Select a flavour..."
|
|
304
|
-
isClearable
|
|
305
|
-
/>
|
|
306
|
-
</div>
|
|
307
|
-
|
|
308
|
-
<div>
|
|
309
|
-
<label htmlFor="toppings" className="block text-sm font-medium mb-1">
|
|
310
|
-
Toppings
|
|
311
|
-
</label>
|
|
312
|
-
|
|
313
|
-
<Select
|
|
314
|
-
id="toppings"
|
|
315
|
-
options={[
|
|
316
|
-
{ value: 'sprinkles', label: 'Sprinkles' },
|
|
317
|
-
{ value: 'nuts', label: 'Nuts' },
|
|
318
|
-
{ value: 'chocolate-chips', label: 'Chocolate Chips' },
|
|
319
|
-
{ value: 'cherry', label: 'Cherry' },
|
|
320
|
-
]}
|
|
321
|
-
value={formData.toppings}
|
|
322
|
-
onChange={(value) =>
|
|
323
|
-
setFormData({ ...formData, toppings: Array.isArray(value) ? [...value] : [] })
|
|
324
|
-
}
|
|
325
|
-
placeholder="Select toppings..."
|
|
326
|
-
isMulti
|
|
327
|
-
/>
|
|
328
|
-
</div>
|
|
329
|
-
|
|
330
|
-
<div className="text-sm text-gray-600">
|
|
331
|
-
<pre>{JSON.stringify(formData, null, 2)}</pre>
|
|
332
|
-
</div>
|
|
333
|
-
</form>
|
|
334
|
-
);
|
|
335
|
-
},
|
|
336
|
-
};
|