@navikt/ds-react 0.19.17 → 1.0.0-rc.2
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/README.md +43 -0
- package/_docs.json +354 -491
- package/cjs/accordion/Accordion.js +2 -2
- package/cjs/accordion/AccordionContent.js +2 -2
- package/cjs/accordion/AccordionHeader.js +6 -5
- package/cjs/accordion/AccordionItem.js +2 -2
- package/cjs/alert/Alert.js +2 -2
- package/cjs/button/Button.js +3 -4
- package/cjs/{speech-bubble → chat}/Bubble.js +7 -4
- package/cjs/{speech-bubble/SpeechBubble.js → chat/Chat.js} +11 -10
- package/cjs/{menu → chat}/index.js +3 -3
- package/cjs/chat/package.json +6 -0
- package/cjs/form/ConfirmationPanel.js +2 -2
- package/cjs/form/Fieldset/Fieldset.js +6 -6
- package/cjs/form/Select.js +6 -6
- package/cjs/form/Switch.js +4 -4
- package/cjs/form/TextField.js +6 -6
- package/cjs/form/Textarea.js +14 -14
- package/cjs/form/checkbox/Checkbox.js +3 -3
- package/cjs/form/checkbox/CheckboxGroup.js +2 -2
- package/cjs/form/error-summary/ErrorSummary.js +3 -3
- package/cjs/form/error-summary/ErrorSummaryItem.js +2 -2
- package/cjs/form/radio/Radio.js +2 -2
- package/cjs/form/radio/RadioGroup.js +2 -2
- package/cjs/form/search/Search.js +6 -7
- package/cjs/form/search/SearchButton.js +2 -2
- package/cjs/form/useFormField.js +2 -2
- package/cjs/grid/Cell.js +2 -2
- package/cjs/grid/ContentContainer.js +2 -2
- package/cjs/grid/Grid.js +2 -2
- package/cjs/guide-panel/Guide.js +3 -3
- package/cjs/guide-panel/GuidePanel.js +2 -2
- package/cjs/help-text/HelpText.js +5 -5
- package/cjs/index.js +1 -6
- package/cjs/link/Link.js +2 -2
- package/cjs/link-panel/LinkPanel.js +2 -2
- package/cjs/link-panel/LinkPanelDescription.js +2 -2
- package/cjs/link-panel/LinkPanelTitle.js +2 -2
- package/cjs/loader/Loader.js +2 -2
- package/cjs/modal/Modal.js +4 -5
- package/cjs/modal/ModalContent.js +2 -2
- package/cjs/pagination/Pagination.js +18 -23
- package/cjs/{menu/MenuItem.js → pagination/PaginationItem.js} +5 -4
- package/cjs/panel/Panel.js +2 -2
- package/cjs/popover/Popover.js +55 -45
- package/cjs/popover/PopoverContent.js +2 -2
- package/cjs/read-more/ReadMore.js +2 -2
- package/cjs/stepper/Step.js +2 -2
- package/cjs/stepper/Stepper.js +3 -3
- package/cjs/table/Body.js +2 -2
- package/cjs/table/DataCell.js +2 -2
- package/cjs/table/ExpandableRow.js +4 -4
- package/cjs/table/Header.js +2 -2
- package/cjs/table/HeaderCell.js +2 -2
- package/cjs/table/Row.js +2 -2
- package/cjs/table/Table.js +2 -2
- package/cjs/tabs/Tab.js +3 -3
- package/cjs/tabs/TabList.js +8 -7
- package/cjs/tabs/TabPanel.js +2 -2
- package/cjs/tabs/Tabs.js +5 -3
- package/cjs/tag/Tag.js +2 -2
- package/cjs/toggle-group/ToggleGroup.js +5 -5
- package/cjs/toggle-group/ToggleItem.js +2 -2
- package/cjs/tooltip/Tooltip.js +45 -92
- package/cjs/typography/BodyLong.js +2 -2
- package/cjs/typography/BodyShort.js +2 -2
- package/cjs/typography/Detail.js +2 -2
- package/cjs/typography/ErrorMessage.js +2 -2
- package/cjs/typography/Heading.js +2 -2
- package/cjs/typography/Ingress.js +2 -2
- package/cjs/typography/Label.js +2 -2
- package/cjs/util/TextareaAutoSize.js +174 -0
- package/cjs/util/debounce.js +18 -0
- package/cjs/util/index.js +14 -1
- package/cjs/util/mergeRefs.js +16 -0
- package/cjs/util/useId.js +60 -17
- package/esm/accordion/Accordion.js +1 -1
- package/esm/accordion/Accordion.js.map +1 -1
- package/esm/accordion/AccordionContent.js +1 -1
- package/esm/accordion/AccordionContent.js.map +1 -1
- package/esm/accordion/AccordionHeader.js +3 -2
- package/esm/accordion/AccordionHeader.js.map +1 -1
- package/esm/accordion/AccordionItem.js +1 -1
- package/esm/accordion/AccordionItem.js.map +1 -1
- package/esm/alert/Alert.d.ts +1 -1
- package/esm/alert/Alert.js +1 -1
- package/esm/alert/Alert.js.map +1 -1
- package/esm/button/Button.js +4 -5
- package/esm/button/Button.js.map +1 -1
- package/esm/{speech-bubble → chat}/Bubble.d.ts +7 -3
- package/esm/{speech-bubble → chat}/Bubble.js +7 -4
- package/esm/chat/Bubble.js.map +1 -0
- package/esm/chat/Chat.d.ts +38 -0
- package/esm/chat/Chat.js +28 -0
- package/esm/chat/Chat.js.map +1 -0
- package/esm/chat/index.d.ts +1 -0
- package/esm/chat/index.js +2 -0
- package/esm/chat/index.js.map +1 -0
- package/esm/form/ConfirmationPanel.js +1 -1
- package/esm/form/ConfirmationPanel.js.map +1 -1
- package/esm/form/Fieldset/Fieldset.js +1 -1
- package/esm/form/Fieldset/Fieldset.js.map +1 -1
- package/esm/form/Select.js +1 -1
- package/esm/form/Select.js.map +1 -1
- package/esm/form/Switch.js +1 -1
- package/esm/form/Switch.js.map +1 -1
- package/esm/form/TextField.js +1 -1
- package/esm/form/TextField.js.map +1 -1
- package/esm/form/Textarea.js +6 -6
- package/esm/form/Textarea.js.map +1 -1
- package/esm/form/checkbox/Checkbox.js +1 -1
- package/esm/form/checkbox/Checkbox.js.map +1 -1
- package/esm/form/checkbox/CheckboxGroup.js +1 -1
- package/esm/form/checkbox/CheckboxGroup.js.map +1 -1
- package/esm/form/error-summary/ErrorSummary.js +3 -3
- package/esm/form/error-summary/ErrorSummary.js.map +1 -1
- package/esm/form/error-summary/ErrorSummaryItem.js +1 -1
- package/esm/form/error-summary/ErrorSummaryItem.js.map +1 -1
- package/esm/form/radio/Radio.js +1 -1
- package/esm/form/radio/Radio.js.map +1 -1
- package/esm/form/radio/RadioGroup.js +1 -1
- package/esm/form/radio/RadioGroup.js.map +1 -1
- package/esm/form/search/Search.js +4 -5
- package/esm/form/search/Search.js.map +1 -1
- package/esm/form/search/SearchButton.js +1 -1
- package/esm/form/search/SearchButton.js.map +1 -1
- package/esm/form/useFormField.js +1 -1
- package/esm/form/useFormField.js.map +1 -1
- package/esm/grid/Cell.js +1 -1
- package/esm/grid/Cell.js.map +1 -1
- package/esm/grid/ContentContainer.js +1 -1
- package/esm/grid/ContentContainer.js.map +1 -1
- package/esm/grid/Grid.js +1 -1
- package/esm/grid/Grid.js.map +1 -1
- package/esm/guide-panel/Guide.js +1 -1
- package/esm/guide-panel/Guide.js.map +1 -1
- package/esm/guide-panel/GuidePanel.js +1 -1
- package/esm/guide-panel/GuidePanel.js.map +1 -1
- package/esm/help-text/HelpText.d.ts +1 -2
- package/esm/help-text/HelpText.js +7 -7
- package/esm/help-text/HelpText.js.map +1 -1
- package/esm/index.d.ts +1 -5
- package/esm/index.js +1 -6
- package/esm/index.js.map +1 -1
- package/esm/link/Link.js +1 -1
- package/esm/link/Link.js.map +1 -1
- package/esm/link-panel/LinkPanel.js +1 -1
- package/esm/link-panel/LinkPanel.js.map +1 -1
- package/esm/link-panel/LinkPanelDescription.js +1 -1
- package/esm/link-panel/LinkPanelDescription.js.map +1 -1
- package/esm/link-panel/LinkPanelTitle.js +1 -1
- package/esm/link-panel/LinkPanelTitle.js.map +1 -1
- package/esm/loader/Loader.js +1 -1
- package/esm/loader/Loader.js.map +1 -1
- package/esm/modal/Modal.js +4 -5
- package/esm/modal/Modal.js.map +1 -1
- package/esm/modal/ModalContent.js +1 -1
- package/esm/modal/ModalContent.js.map +1 -1
- package/esm/pagination/Pagination.d.ts +12 -3
- package/esm/pagination/Pagination.js +17 -22
- package/esm/pagination/Pagination.js.map +1 -1
- package/esm/pagination/PaginationItem.d.ts +22 -0
- package/esm/{menu/MenuItem.js → pagination/PaginationItem.js} +6 -5
- package/esm/pagination/PaginationItem.js.map +1 -0
- package/esm/pagination/index.d.ts +1 -2
- package/esm/pagination/index.js.map +1 -1
- package/esm/panel/Panel.js +1 -1
- package/esm/panel/Panel.js.map +1 -1
- package/esm/popover/Popover.d.ts +2 -3
- package/esm/popover/Popover.js +56 -46
- package/esm/popover/Popover.js.map +1 -1
- package/esm/popover/PopoverContent.js +1 -1
- package/esm/popover/PopoverContent.js.map +1 -1
- package/esm/read-more/ReadMore.js +1 -1
- package/esm/read-more/ReadMore.js.map +1 -1
- package/esm/stepper/Step.js +1 -1
- package/esm/stepper/Step.js.map +1 -1
- package/esm/stepper/Stepper.js +1 -1
- package/esm/stepper/Stepper.js.map +1 -1
- package/esm/table/Body.js +1 -1
- package/esm/table/Body.js.map +1 -1
- package/esm/table/DataCell.js +1 -1
- package/esm/table/DataCell.js.map +1 -1
- package/esm/table/ExpandableRow.js +2 -2
- package/esm/table/ExpandableRow.js.map +1 -1
- package/esm/table/Header.js +1 -1
- package/esm/table/Header.js.map +1 -1
- package/esm/table/HeaderCell.js +1 -1
- package/esm/table/HeaderCell.js.map +1 -1
- package/esm/table/Row.js +1 -1
- package/esm/table/Row.js.map +1 -1
- package/esm/table/Table.js +1 -1
- package/esm/table/Table.js.map +1 -1
- package/esm/tabs/Tab.d.ts +0 -5
- package/esm/tabs/Tab.js +4 -4
- package/esm/tabs/Tab.js.map +1 -1
- package/esm/tabs/TabList.d.ts +0 -4
- package/esm/tabs/TabList.js +7 -6
- package/esm/tabs/TabList.js.map +1 -1
- package/esm/tabs/TabPanel.js +1 -1
- package/esm/tabs/TabPanel.js.map +1 -1
- package/esm/tabs/Tabs.d.ts +12 -0
- package/esm/tabs/Tabs.js +4 -2
- package/esm/tabs/Tabs.js.map +1 -1
- package/esm/tag/Tag.js +1 -1
- package/esm/tag/Tag.js.map +1 -1
- package/esm/toggle-group/ToggleGroup.js +3 -3
- package/esm/toggle-group/ToggleGroup.js.map +1 -1
- package/esm/toggle-group/ToggleItem.js +1 -1
- package/esm/toggle-group/ToggleItem.js.map +1 -1
- package/esm/tooltip/Tooltip.js +44 -91
- package/esm/tooltip/Tooltip.js.map +1 -1
- package/esm/typography/BodyLong.js +1 -1
- package/esm/typography/BodyLong.js.map +1 -1
- package/esm/typography/BodyShort.js +1 -1
- package/esm/typography/BodyShort.js.map +1 -1
- package/esm/typography/Detail.js +1 -1
- package/esm/typography/Detail.js.map +1 -1
- package/esm/typography/ErrorMessage.js +1 -1
- package/esm/typography/ErrorMessage.js.map +1 -1
- package/esm/typography/Heading.js +1 -1
- package/esm/typography/Heading.js.map +1 -1
- package/esm/typography/Ingress.js +1 -1
- package/esm/typography/Ingress.js.map +1 -1
- package/esm/typography/Label.js +1 -1
- package/esm/typography/Label.js.map +1 -1
- package/esm/util/TextareaAutoSize.d.ts +14 -0
- package/esm/util/TextareaAutoSize.js +150 -0
- package/esm/util/TextareaAutoSize.js.map +1 -0
- package/esm/util/debounce.d.ts +4 -0
- package/esm/util/debounce.js +16 -0
- package/esm/util/debounce.js.map +1 -0
- package/esm/util/index.d.ts +4 -0
- package/esm/util/index.js +9 -1
- package/esm/util/index.js.map +1 -1
- package/esm/util/mergeRefs.d.ts +2 -0
- package/esm/util/mergeRefs.js +14 -0
- package/esm/util/mergeRefs.js.map +1 -0
- package/esm/util/useId.d.ts +7 -3
- package/esm/util/useId.js +36 -16
- package/esm/util/useId.js.map +1 -1
- package/package.json +13 -14
- package/src/accordion/Accordion.tsx +1 -1
- package/src/accordion/AccordionContent.tsx +1 -1
- package/src/accordion/AccordionHeader.tsx +2 -2
- package/src/accordion/AccordionItem.tsx +1 -1
- package/src/alert/Alert.tsx +2 -2
- package/src/alert/alert.stories.tsx +7 -0
- package/src/button/Button.tsx +5 -5
- package/src/chat/Bubble.tsx +52 -0
- package/src/chat/Chat.tsx +96 -0
- package/src/chat/chat.stories.tsx +202 -0
- package/src/chat/index.ts +1 -0
- package/src/form/ConfirmationPanel.tsx +1 -1
- package/src/form/Fieldset/Fieldset.tsx +1 -1
- package/src/form/Select.tsx +1 -1
- package/src/form/Switch.tsx +1 -1
- package/src/form/TextField.tsx +1 -1
- package/src/form/Textarea.tsx +6 -6
- package/src/form/checkbox/Checkbox.test.tsx +20 -17
- package/src/form/checkbox/Checkbox.tsx +1 -1
- package/src/form/checkbox/CheckboxGroup.tsx +1 -1
- package/src/form/error-summary/ErrorSummary.tsx +3 -3
- package/src/form/error-summary/ErrorSummaryItem.tsx +1 -1
- package/src/form/radio/Radio.tsx +1 -1
- package/src/form/radio/RadioGroup.tsx +1 -1
- package/src/form/search/Search.tsx +11 -4
- package/src/form/search/SearchButton.tsx +1 -1
- package/src/form/useFormField.ts +1 -1
- package/src/grid/Cell.tsx +1 -1
- package/src/grid/ContentContainer.tsx +1 -1
- package/src/grid/Grid.tsx +1 -1
- package/src/grid/grid.stories.tsx +68 -0
- package/src/guide-panel/Guide.tsx +1 -1
- package/src/guide-panel/GuidePanel.tsx +1 -1
- package/src/help-text/HelpText.tsx +22 -8
- package/src/help-text/help-text.stories.tsx +12 -16
- package/src/index.ts +1 -7
- package/src/link/Link.tsx +1 -1
- package/src/link-panel/LinkPanel.tsx +1 -1
- package/src/link-panel/LinkPanelDescription.tsx +1 -1
- package/src/link-panel/LinkPanelTitle.tsx +1 -1
- package/src/loader/Loader.tsx +1 -1
- package/src/modal/Modal.tsx +4 -5
- package/src/modal/ModalContent.tsx +1 -1
- package/src/pagination/Pagination.tsx +84 -78
- package/src/pagination/PaginationItem.tsx +57 -0
- package/src/pagination/index.ts +1 -2
- package/src/pagination/pagination.stories.tsx +90 -16
- package/src/panel/Panel.tsx +1 -1
- package/src/popover/Popover.test.tsx +143 -0
- package/src/popover/Popover.tsx +107 -73
- package/src/popover/PopoverContent.tsx +1 -1
- package/src/popover/popover.stories.tsx +22 -27
- package/src/read-more/ReadMore.tsx +1 -1
- package/src/stepper/Step.tsx +1 -1
- package/src/stepper/Stepper.tsx +1 -1
- package/src/table/Body.tsx +1 -1
- package/src/table/DataCell.tsx +1 -1
- package/src/table/ExpandableRow.tsx +2 -2
- package/src/table/Header.tsx +1 -1
- package/src/table/HeaderCell.tsx +1 -1
- package/src/table/Row.tsx +1 -1
- package/src/table/Table.tsx +1 -1
- package/src/tabs/Tab.tsx +5 -10
- package/src/tabs/TabList.tsx +14 -9
- package/src/tabs/TabPanel.tsx +1 -1
- package/src/tabs/Tabs.stories.tsx +94 -117
- package/src/tabs/Tabs.tsx +17 -1
- package/src/tag/Tag.tsx +1 -1
- package/src/toggle-group/ToggleGroup.tsx +3 -3
- package/src/toggle-group/ToggleItem.tsx +1 -1
- package/src/tooltip/Tooltip.test.tsx +167 -0
- package/src/tooltip/Tooltip.tsx +106 -173
- package/src/tooltip/tooltip.stories.tsx +15 -1
- package/src/typography/BodyLong.tsx +1 -1
- package/src/typography/BodyShort.tsx +1 -1
- package/src/typography/Detail.tsx +1 -1
- package/src/typography/ErrorMessage.tsx +1 -1
- package/src/typography/Heading.tsx +1 -1
- package/src/typography/Ingress.tsx +1 -1
- package/src/typography/Label.tsx +1 -1
- package/src/util/TextareaAutoSize.tsx +224 -0
- package/src/util/debounce.ts +17 -0
- package/src/util/index.ts +14 -2
- package/src/util/mergeRefs.tsx +14 -0
- package/src/util/useId.ts +37 -20
- package/cjs/card/MicroCard.js +0 -47
- package/cjs/card/index.js +0 -8
- package/cjs/card/package.json +0 -6
- package/cjs/menu/Menu.js +0 -53
- package/cjs/menu/MenuCollapse.js +0 -65
- package/cjs/menu/MenuItems.js +0 -23
- package/cjs/menu/package.json +0 -6
- package/cjs/page-header/PageHeader.js +0 -51
- package/cjs/page-header/index.js +0 -8
- package/cjs/page-header/package.json +0 -6
- package/cjs/speech-bubble/index.js +0 -8
- package/cjs/speech-bubble/package.json +0 -6
- package/cjs/step-indicator/Step.js +0 -67
- package/cjs/step-indicator/StepIndicator.js +0 -80
- package/cjs/step-indicator/index.js +0 -8
- package/cjs/step-indicator/package.json +0 -6
- package/esm/card/MicroCard.d.ts +0 -10
- package/esm/card/MicroCard.js +0 -19
- package/esm/card/MicroCard.js.map +0 -1
- package/esm/card/index.d.ts +0 -2
- package/esm/card/index.js +0 -2
- package/esm/card/index.js.map +0 -1
- package/esm/menu/Menu.d.ts +0 -12
- package/esm/menu/Menu.js +0 -25
- package/esm/menu/Menu.js.map +0 -1
- package/esm/menu/MenuCollapse.d.ts +0 -12
- package/esm/menu/MenuCollapse.js +0 -37
- package/esm/menu/MenuCollapse.js.map +0 -1
- package/esm/menu/MenuItem.d.ts +0 -13
- package/esm/menu/MenuItem.js.map +0 -1
- package/esm/menu/MenuItems.d.ts +0 -6
- package/esm/menu/MenuItems.js +0 -19
- package/esm/menu/MenuItems.js.map +0 -1
- package/esm/menu/index.d.ts +0 -3
- package/esm/menu/index.js +0 -2
- package/esm/menu/index.js.map +0 -1
- package/esm/page-header/PageHeader.d.ts +0 -27
- package/esm/page-header/PageHeader.js +0 -24
- package/esm/page-header/PageHeader.js.map +0 -1
- package/esm/page-header/index.d.ts +0 -2
- package/esm/page-header/index.js +0 -2
- package/esm/page-header/index.js.map +0 -1
- package/esm/speech-bubble/Bubble.js.map +0 -1
- package/esm/speech-bubble/SpeechBubble.d.ts +0 -34
- package/esm/speech-bubble/SpeechBubble.js +0 -27
- package/esm/speech-bubble/SpeechBubble.js.map +0 -1
- package/esm/speech-bubble/index.d.ts +0 -1
- package/esm/speech-bubble/index.js +0 -2
- package/esm/speech-bubble/index.js.map +0 -1
- package/esm/step-indicator/Step.d.ts +0 -23
- package/esm/step-indicator/Step.js +0 -39
- package/esm/step-indicator/Step.js.map +0 -1
- package/esm/step-indicator/StepIndicator.d.ts +0 -41
- package/esm/step-indicator/StepIndicator.js +0 -52
- package/esm/step-indicator/StepIndicator.js.map +0 -1
- package/esm/step-indicator/index.d.ts +0 -1
- package/esm/step-indicator/index.js +0 -2
- package/esm/step-indicator/index.js.map +0 -1
- package/src/card/MicroCard.tsx +0 -32
- package/src/card/index.ts +0 -2
- package/src/card/stories/card.stories.mdx +0 -26
- package/src/card/stories/card.stories.tsx +0 -16
- package/src/grid/stories/grid.stories.mdx +0 -79
- package/src/grid/stories/grid.stories.tsx +0 -51
- package/src/grid/stories/styles.css +0 -21
- package/src/menu/Menu.tsx +0 -36
- package/src/menu/MenuCollapse.tsx +0 -80
- package/src/menu/MenuItem.tsx +0 -39
- package/src/menu/MenuItems.tsx +0 -21
- package/src/menu/index.ts +0 -3
- package/src/menu/stories/menu.stories.mdx +0 -93
- package/src/menu/stories/menu.stories.tsx +0 -139
- package/src/page-header/PageHeader.tsx +0 -72
- package/src/page-header/index.ts +0 -2
- package/src/page-header/stories/header.stories.mdx +0 -81
- package/src/page-header/stories/header.stories.tsx +0 -61
- package/src/page-header/stories/pictogram.tsx +0 -14
- package/src/speech-bubble/Bubble.tsx +0 -48
- package/src/speech-bubble/SpeechBubble.tsx +0 -93
- package/src/speech-bubble/index.ts +0 -1
- package/src/speech-bubble/stories/illustration.tsx +0 -66
- package/src/speech-bubble/stories/speechbubble.stories.mdx +0 -184
- package/src/speech-bubble/stories/speechbubble.stories.tsx +0 -104
- package/src/step-indicator/Step.tsx +0 -81
- package/src/step-indicator/StepIndicator.tsx +0 -148
- package/src/step-indicator/index.ts +0 -1
- package/src/step-indicator/stories/Example.tsx +0 -23
- package/src/step-indicator/stories/step-indicator.stories.mdx +0 -122
- package/src/step-indicator/stories/step-indicator.stories.tsx +0 -104
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef, useContext } from "react";
|
|
2
|
-
import cl from "classnames";
|
|
3
|
-
import { StepContext } from "./StepIndicator";
|
|
4
|
-
import { BodyShort, Label, OverridableComponent } from "..";
|
|
5
|
-
|
|
6
|
-
export interface StepIndicatorStepProps
|
|
7
|
-
extends React.HTMLAttributes<HTMLButtonElement> {
|
|
8
|
-
/**
|
|
9
|
-
* Text content under indicator
|
|
10
|
-
*/
|
|
11
|
-
children: React.ReactNode;
|
|
12
|
-
/**
|
|
13
|
-
* Disables interaction with element
|
|
14
|
-
* @note We recommend not using disabled if possible
|
|
15
|
-
*/
|
|
16
|
-
disabled?: boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Handled by StepIndicator
|
|
19
|
-
* @private
|
|
20
|
-
*/
|
|
21
|
-
index?: number;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface StepIndicatorStepType
|
|
25
|
-
extends OverridableComponent<StepIndicatorStepProps, HTMLButtonElement> {}
|
|
26
|
-
|
|
27
|
-
export const StepIndicatorStepComponent: OverridableComponent<
|
|
28
|
-
StepIndicatorStepProps,
|
|
29
|
-
HTMLButtonElement
|
|
30
|
-
> = forwardRef(
|
|
31
|
-
(
|
|
32
|
-
{ className, children, as: Component = "button", disabled, index, ...rest },
|
|
33
|
-
ref
|
|
34
|
-
) => {
|
|
35
|
-
const context = useContext(StepContext);
|
|
36
|
-
|
|
37
|
-
if (context === null) {
|
|
38
|
-
console.error(
|
|
39
|
-
"<StepIndicator.Step> has to be used within an <StepIndicator>"
|
|
40
|
-
);
|
|
41
|
-
return null;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const safeIndex = index ?? 0;
|
|
45
|
-
|
|
46
|
-
const Number = context.activeStep === safeIndex ? Label : BodyShort;
|
|
47
|
-
|
|
48
|
-
return (
|
|
49
|
-
<Component
|
|
50
|
-
{...rest}
|
|
51
|
-
disabled={disabled}
|
|
52
|
-
ref={ref}
|
|
53
|
-
className={cl("navds-step-indicator__step", className, {
|
|
54
|
-
"navds-step-indicator__step--disabled": disabled,
|
|
55
|
-
"navds-step-indicator__step--active":
|
|
56
|
-
context.activeStep === safeIndex,
|
|
57
|
-
"navds-step-indicator__step--finished":
|
|
58
|
-
context.activeStep > safeIndex,
|
|
59
|
-
})}
|
|
60
|
-
onClick={(e) => {
|
|
61
|
-
context.onStepChange(safeIndex);
|
|
62
|
-
rest.onClick && rest.onClick(e);
|
|
63
|
-
}}
|
|
64
|
-
>
|
|
65
|
-
<Number className="navds-step-indicator__step-number">
|
|
66
|
-
{safeIndex + 1}
|
|
67
|
-
</Number>
|
|
68
|
-
<div className={cl("navds-step-indicator__step-label")}>
|
|
69
|
-
{!context.hideLabels && children}
|
|
70
|
-
</div>
|
|
71
|
-
{safeIndex !== 0 && (
|
|
72
|
-
<span aria-hidden className="navds-step-indicator__step-line" />
|
|
73
|
-
)}
|
|
74
|
-
</Component>
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
const Step = StepIndicatorStepComponent as StepIndicatorStepType;
|
|
80
|
-
|
|
81
|
-
export default Step;
|
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
import cl from "classnames";
|
|
2
|
-
import React, {
|
|
3
|
-
createContext,
|
|
4
|
-
forwardRef,
|
|
5
|
-
useCallback,
|
|
6
|
-
useEffect,
|
|
7
|
-
useRef,
|
|
8
|
-
useState,
|
|
9
|
-
} from "react";
|
|
10
|
-
import mergeRefs from "react-merge-refs";
|
|
11
|
-
import StepIndicatorStep, {
|
|
12
|
-
StepIndicatorStepProps,
|
|
13
|
-
StepIndicatorStepType,
|
|
14
|
-
} from "./Step";
|
|
15
|
-
|
|
16
|
-
export interface StepIndicatorProps
|
|
17
|
-
extends React.HTMLAttributes<HTMLOListElement> {
|
|
18
|
-
/**
|
|
19
|
-
* <StepIndicator.Step /> elements
|
|
20
|
-
*/
|
|
21
|
-
children: React.ReactNode;
|
|
22
|
-
/**
|
|
23
|
-
* Adds classname to wrapper
|
|
24
|
-
*/
|
|
25
|
-
className?: string;
|
|
26
|
-
/**
|
|
27
|
-
* Current active step index
|
|
28
|
-
*/
|
|
29
|
-
activeStep: number;
|
|
30
|
-
/**
|
|
31
|
-
* Callback for clicked step index
|
|
32
|
-
*/
|
|
33
|
-
onStepChange?: (step: number) => void;
|
|
34
|
-
/**
|
|
35
|
-
* Hides labels for each step if true
|
|
36
|
-
* @default false
|
|
37
|
-
*/
|
|
38
|
-
hideLabels?: boolean;
|
|
39
|
-
/**
|
|
40
|
-
* enables `hideLabels` internally when steps start to overflow.
|
|
41
|
-
* @note declaring `hideLabels` overwrites this functionality
|
|
42
|
-
*/
|
|
43
|
-
responsive?: boolean;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
interface StepIndicatorComponent
|
|
47
|
-
extends React.ForwardRefExoticComponent<
|
|
48
|
-
StepIndicatorProps & React.RefAttributes<HTMLOListElement>
|
|
49
|
-
> {
|
|
50
|
-
Step: StepIndicatorStepType;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
interface StepContextProps {
|
|
54
|
-
activeStep: number;
|
|
55
|
-
onStepChange: (step: number) => void;
|
|
56
|
-
hideLabels: boolean;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export const StepContext = createContext<StepContextProps | null>(null);
|
|
60
|
-
|
|
61
|
-
export const StepIndicator: StepIndicatorComponent = forwardRef<
|
|
62
|
-
HTMLOListElement,
|
|
63
|
-
StepIndicatorProps
|
|
64
|
-
>(
|
|
65
|
-
(
|
|
66
|
-
{
|
|
67
|
-
children,
|
|
68
|
-
className,
|
|
69
|
-
activeStep,
|
|
70
|
-
hideLabels,
|
|
71
|
-
onStepChange = () => {},
|
|
72
|
-
responsive,
|
|
73
|
-
...rest
|
|
74
|
-
},
|
|
75
|
-
ref
|
|
76
|
-
) => {
|
|
77
|
-
const wrapperRef = useRef<HTMLOListElement | null>(null);
|
|
78
|
-
const mergedRef = mergeRefs([wrapperRef, ref]);
|
|
79
|
-
|
|
80
|
-
const [showLabels, setShowLabels] = useState(true);
|
|
81
|
-
|
|
82
|
-
const removeLabels = hideLabels ?? (!!responsive && !showLabels);
|
|
83
|
-
|
|
84
|
-
const stepsWithIndex = React.Children.map(children, (step, index) => {
|
|
85
|
-
return React.isValidElement<StepIndicatorStepProps>(step) ? (
|
|
86
|
-
<li
|
|
87
|
-
className={cl("navds-step-indicator__step-wrapper", {
|
|
88
|
-
"navds-step-indicator__step-wrapper--hidelabel": removeLabels,
|
|
89
|
-
})}
|
|
90
|
-
key={index}
|
|
91
|
-
aria-current={index === activeStep && "step"}
|
|
92
|
-
>
|
|
93
|
-
{React.cloneElement(step, {
|
|
94
|
-
...step.props,
|
|
95
|
-
index,
|
|
96
|
-
})}
|
|
97
|
-
</li>
|
|
98
|
-
) : (
|
|
99
|
-
step
|
|
100
|
-
);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
const canShowLabels = useCallback(() => {
|
|
104
|
-
const remSize = parseFloat(
|
|
105
|
-
String(getComputedStyle(document.documentElement).fontSize)
|
|
106
|
-
);
|
|
107
|
-
const childrenLength = React.Children.toArray(children).filter((child) =>
|
|
108
|
-
React.isValidElement(child)
|
|
109
|
-
).length;
|
|
110
|
-
|
|
111
|
-
wrapperRef.current &&
|
|
112
|
-
setShowLabels(
|
|
113
|
-
wrapperRef.current?.getBoundingClientRect().width >=
|
|
114
|
-
remSize * 10 * childrenLength
|
|
115
|
-
);
|
|
116
|
-
}, [children]);
|
|
117
|
-
|
|
118
|
-
useEffect(() => {
|
|
119
|
-
window.addEventListener("resize", canShowLabels);
|
|
120
|
-
canShowLabels();
|
|
121
|
-
return () => {
|
|
122
|
-
window.removeEventListener("resize", canShowLabels);
|
|
123
|
-
};
|
|
124
|
-
}, [canShowLabels]);
|
|
125
|
-
|
|
126
|
-
return (
|
|
127
|
-
<ol
|
|
128
|
-
ref={mergedRef}
|
|
129
|
-
className={cl(`navds-step-indicator`, className)}
|
|
130
|
-
{...rest}
|
|
131
|
-
>
|
|
132
|
-
<StepContext.Provider
|
|
133
|
-
value={{
|
|
134
|
-
activeStep,
|
|
135
|
-
onStepChange,
|
|
136
|
-
hideLabels: removeLabels,
|
|
137
|
-
}}
|
|
138
|
-
>
|
|
139
|
-
{stepsWithIndex}
|
|
140
|
-
</StepContext.Provider>
|
|
141
|
-
</ol>
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
|
-
) as StepIndicatorComponent;
|
|
145
|
-
|
|
146
|
-
StepIndicator.Step = StepIndicatorStep;
|
|
147
|
-
|
|
148
|
-
export default StepIndicator;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as StepIndicator, StepIndicatorProps } from "./StepIndicator";
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
2
|
-
import { StepIndicator } from "..";
|
|
3
|
-
|
|
4
|
-
export const Example = ({ ...props }) => {
|
|
5
|
-
const [active, setactive] = useState(1);
|
|
6
|
-
|
|
7
|
-
const { disabled, ...rest } = props;
|
|
8
|
-
|
|
9
|
-
return (
|
|
10
|
-
<StepIndicator {...rest} activeStep={active} onStepChange={setactive}>
|
|
11
|
-
<StepIndicator.Step>Start</StepIndicator.Step>
|
|
12
|
-
<StepIndicator.Step>
|
|
13
|
-
Sunt deserunt qui sit sunt culpa nisi
|
|
14
|
-
</StepIndicator.Step>
|
|
15
|
-
<StepIndicator.Step disabled={disabled}>
|
|
16
|
-
Nulla nisi pariatur nulla cupidatat elit.
|
|
17
|
-
</StepIndicator.Step>
|
|
18
|
-
<StepIndicator.Step>
|
|
19
|
-
Nulla laborum proident consequat laborum elit et dolore ut sunt.
|
|
20
|
-
</StepIndicator.Step>
|
|
21
|
-
</StepIndicator>
|
|
22
|
-
);
|
|
23
|
-
};
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { Meta, Canvas } from "@storybook/addon-docs";
|
|
2
|
-
import { StepIndicator } from "..";
|
|
3
|
-
import { Example } from "./Example";
|
|
4
|
-
|
|
5
|
-
<Meta title="ds-react(deprecated)/step-indicator/intro" />
|
|
6
|
-
|
|
7
|
-
# Hvordan ta i bruk StepIndicator
|
|
8
|
-
|
|
9
|
-
Vi flytter over Stegindikator til `ds-react` uten noen veldig store endringer i design.
|
|
10
|
-
Du må nå selv styre state med `activeStep` og `onStepChange`.
|
|
11
|
-
|
|
12
|
-
```jsx
|
|
13
|
-
<StepIndicator activeStep={activeStep} onStepChange={(x) => setActiveStep(x)}>
|
|
14
|
-
<StepIndicator.Step>Start</StepIndicator.Step>
|
|
15
|
-
<StepIndicator.Step>Sunt deserunt qui sit sunt culpa nisi</StepIndicator.Step>
|
|
16
|
-
<StepIndicator.Step>
|
|
17
|
-
Nulla nisi pariatur nulla cupidatat elit.
|
|
18
|
-
</StepIndicator.Step>
|
|
19
|
-
<StepIndicator.Step>
|
|
20
|
-
Nulla laborum proident consequat laborum elit et dolore ut sunt.
|
|
21
|
-
</StepIndicator.Step>
|
|
22
|
-
</StepIndicator>
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
<Canvas>
|
|
26
|
-
<Example />
|
|
27
|
-
</Canvas>
|
|
28
|
-
|
|
29
|
-
## responsive
|
|
30
|
-
|
|
31
|
-
Bruk `responsive`-prop for å skjule labels med en gang StepIndicator begynner å overflowe.
|
|
32
|
-
|
|
33
|
-
```jsx
|
|
34
|
-
<StepIndicator
|
|
35
|
-
responsive
|
|
36
|
-
activeStep={activeStep}
|
|
37
|
-
onStepChange={(x) => setActiveStep(x)}
|
|
38
|
-
>
|
|
39
|
-
<StepIndicator.Step>Start</StepIndicator.Step>
|
|
40
|
-
<StepIndicator.Step>Sunt deserunt qui sit sunt culpa nisi</StepIndicator.Step>
|
|
41
|
-
<StepIndicator.Step>
|
|
42
|
-
Nulla nisi pariatur nulla cupidatat elit.
|
|
43
|
-
</StepIndicator.Step>
|
|
44
|
-
<StepIndicator.Step>
|
|
45
|
-
Nulla laborum proident consequat laborum elit et dolore ut sunt.
|
|
46
|
-
</StepIndicator.Step>
|
|
47
|
-
</StepIndicator>
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
<Canvas>
|
|
51
|
-
<Example responsive />
|
|
52
|
-
</Canvas>
|
|
53
|
-
|
|
54
|
-
## hideLabels
|
|
55
|
-
|
|
56
|
-
Du kan gjemme labels fra hvert steg med `hideLabels`-prop
|
|
57
|
-
|
|
58
|
-
```jsx
|
|
59
|
-
<StepIndicator
|
|
60
|
-
hideLabels
|
|
61
|
-
activeStep={activeStep}
|
|
62
|
-
onStepChange={(x) => setActiveStep(x)}
|
|
63
|
-
>
|
|
64
|
-
<StepIndicator.Step>Start</StepIndicator.Step>
|
|
65
|
-
<StepIndicator.Step>Sunt deserunt qui sit sunt culpa nisi</StepIndicator.Step>
|
|
66
|
-
<StepIndicator.Step>
|
|
67
|
-
Nulla nisi pariatur nulla cupidatat elit.
|
|
68
|
-
</StepIndicator.Step>
|
|
69
|
-
<StepIndicator.Step>
|
|
70
|
-
Nulla laborum proident consequat laborum elit et dolore ut sunt.
|
|
71
|
-
</StepIndicator.Step>
|
|
72
|
-
</StepIndicator>
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
<Canvas>
|
|
76
|
-
<Example hideLabels />
|
|
77
|
-
</Canvas>
|
|
78
|
-
|
|
79
|
-
## disabled
|
|
80
|
-
|
|
81
|
-
```jsx
|
|
82
|
-
<StepIndicator activeStep={activeStep} onStepChange={(x) => setActiveStep(x)}>
|
|
83
|
-
<StepIndicator.Step>Start</StepIndicator.Step>
|
|
84
|
-
<StepIndicator.Step disabled>
|
|
85
|
-
Sunt deserunt qui sit sunt culpa nisi
|
|
86
|
-
</StepIndicator.Step>
|
|
87
|
-
<StepIndicator.Step disabled>
|
|
88
|
-
Nulla nisi pariatur nulla cupidatat elit.
|
|
89
|
-
</StepIndicator.Step>
|
|
90
|
-
<StepIndicator.Step>
|
|
91
|
-
Nulla laborum proident consequat laborum elit et dolore ut sunt.
|
|
92
|
-
</StepIndicator.Step>
|
|
93
|
-
</StepIndicator>
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
<Canvas>
|
|
97
|
-
<Example disabled />
|
|
98
|
-
</Canvas>
|
|
99
|
-
|
|
100
|
-
## Override tags
|
|
101
|
-
|
|
102
|
-
`StepIndicator.Step` er implementert med Overridable-component noe som gjør at du kan endre taggen til
|
|
103
|
-
det du selv ønsker ved å bruke `as`-prop
|
|
104
|
-
|
|
105
|
-
```jsx
|
|
106
|
-
<StepIndicator activeStep={activeStep} onStepChange={(x) => setActiveStep(x)}>
|
|
107
|
-
{/* Dette er default */}
|
|
108
|
-
<StepIndicator.Step as="button">Start</StepIndicator.Step>
|
|
109
|
-
<StepIndicator.Step as="a" href="#">
|
|
110
|
-
Sunt deserunt qui sit sunt culpa nisi
|
|
111
|
-
</StepIndicator.Step>
|
|
112
|
-
</StepIndicator>
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
<Canvas>
|
|
116
|
-
<StepIndicator activeStep={1} onStepChange={console.log}>
|
|
117
|
-
<StepIndicator.Step as="button">{`<button>`}</StepIndicator.Step>
|
|
118
|
-
<StepIndicator.Step as="a" href="#">
|
|
119
|
-
{`<a>`}
|
|
120
|
-
</StepIndicator.Step>
|
|
121
|
-
</StepIndicator>
|
|
122
|
-
</Canvas>
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
2
|
-
import StepIndicator from "../StepIndicator";
|
|
3
|
-
import { Meta } from "@storybook/react/types-6-0";
|
|
4
|
-
import { Link, HashRouter as Router, useLocation } from "react-router-dom";
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
title: "ds-react(deprecated)/step-indicator",
|
|
8
|
-
component: StepIndicator,
|
|
9
|
-
} as Meta;
|
|
10
|
-
|
|
11
|
-
export const All = () => {
|
|
12
|
-
const [activeStep, setActiveStep] = useState(1);
|
|
13
|
-
return (
|
|
14
|
-
<div>
|
|
15
|
-
<StepIndicator activeStep={1} onStepChange={console.log}>
|
|
16
|
-
<StepIndicator.Step>Steg nr 1</StepIndicator.Step>
|
|
17
|
-
<StepIndicator.Step>Laborum velit eu magna esse</StepIndicator.Step>
|
|
18
|
-
<StepIndicator.Step>test</StepIndicator.Step>
|
|
19
|
-
</StepIndicator>
|
|
20
|
-
<br />
|
|
21
|
-
|
|
22
|
-
<StepIndicator activeStep={1} onStepChange={console.log}>
|
|
23
|
-
<StepIndicator.Step href="#" as="a">
|
|
24
|
-
1
|
|
25
|
-
</StepIndicator.Step>
|
|
26
|
-
<StepIndicator.Step href="#" as="a">
|
|
27
|
-
2
|
|
28
|
-
</StepIndicator.Step>
|
|
29
|
-
<StepIndicator.Step href="#" as="a">
|
|
30
|
-
3
|
|
31
|
-
</StepIndicator.Step>
|
|
32
|
-
</StepIndicator>
|
|
33
|
-
<br />
|
|
34
|
-
<StepIndicator activeStep={activeStep} onStepChange={setActiveStep}>
|
|
35
|
-
<StepIndicator.Step disabled>
|
|
36
|
-
Pariatur pariatur adipisicing reprehenderit ad occaecat reprehenderit
|
|
37
|
-
ut dolore.
|
|
38
|
-
</StepIndicator.Step>
|
|
39
|
-
<StepIndicator.Step>Laborum velit eu magna esse</StepIndicator.Step>
|
|
40
|
-
<StepIndicator.Step disabled>
|
|
41
|
-
Cupidatat Lorem do nostrud ut eu.
|
|
42
|
-
</StepIndicator.Step>
|
|
43
|
-
<StepIndicator.Step>test</StepIndicator.Step>
|
|
44
|
-
<StepIndicator.Step>
|
|
45
|
-
Voluptate pariatur ut est voluptate elit officia excepteur laborum.
|
|
46
|
-
</StepIndicator.Step>
|
|
47
|
-
</StepIndicator>
|
|
48
|
-
<br />
|
|
49
|
-
<StepIndicator
|
|
50
|
-
activeStep={activeStep}
|
|
51
|
-
onStepChange={setActiveStep}
|
|
52
|
-
hideLabels
|
|
53
|
-
>
|
|
54
|
-
<StepIndicator.Step>
|
|
55
|
-
Pariatur pariatur adipisicing reprehenderit ad occaecat reprehenderit
|
|
56
|
-
ut dolore.
|
|
57
|
-
</StepIndicator.Step>
|
|
58
|
-
<StepIndicator.Step>Laborum velit eu magna esse</StepIndicator.Step>
|
|
59
|
-
<StepIndicator.Step disabled>
|
|
60
|
-
Cupidatat Lorem do nostrud ut eu.
|
|
61
|
-
</StepIndicator.Step>
|
|
62
|
-
<StepIndicator.Step>test</StepIndicator.Step>
|
|
63
|
-
<StepIndicator.Step>
|
|
64
|
-
Voluptate pariatur ut est voluptate elit officia excepteur laborum.
|
|
65
|
-
</StepIndicator.Step>
|
|
66
|
-
</StepIndicator>
|
|
67
|
-
</div>
|
|
68
|
-
);
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export const ReactRouter = () => {
|
|
72
|
-
const { pathname } = useLocation();
|
|
73
|
-
|
|
74
|
-
return (
|
|
75
|
-
<StepIndicator
|
|
76
|
-
activeStep={
|
|
77
|
-
{
|
|
78
|
-
"/": 0,
|
|
79
|
-
"/first": 0,
|
|
80
|
-
"/second": 1,
|
|
81
|
-
"/third": 2,
|
|
82
|
-
}[pathname]
|
|
83
|
-
}
|
|
84
|
-
>
|
|
85
|
-
<StepIndicator.Step as={Link} to="/first">
|
|
86
|
-
Steg nr 1
|
|
87
|
-
</StepIndicator.Step>
|
|
88
|
-
<StepIndicator.Step as={Link} to="/second">
|
|
89
|
-
Laborum velit eu magna esse
|
|
90
|
-
</StepIndicator.Step>
|
|
91
|
-
<StepIndicator.Step as={Link} to="/third">
|
|
92
|
-
test
|
|
93
|
-
</StepIndicator.Step>
|
|
94
|
-
</StepIndicator>
|
|
95
|
-
);
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
ReactRouter.decorators = [
|
|
99
|
-
(Story) => (
|
|
100
|
-
<Router>
|
|
101
|
-
<Story />
|
|
102
|
-
</Router>
|
|
103
|
-
),
|
|
104
|
-
];
|