@navikt/ds-react 0.19.25 → 1.0.0-rc.3
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 +364 -520
- package/cjs/accordion/Accordion.js +2 -2
- package/cjs/accordion/AccordionContent.js +5 -9
- package/cjs/accordion/AccordionHeader.js +5 -10
- package/cjs/accordion/AccordionItem.js +3 -7
- package/cjs/alert/Alert.js +2 -2
- package/cjs/button/Button.js +9 -7
- 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 +3 -3
- 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 -4
- 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 +5 -7
- 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 +7 -11
- 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 +9 -12
- 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 +4 -4
- 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/AnimateHeight.js +204 -0
- 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.d.ts +0 -2
- package/esm/accordion/AccordionContent.js +5 -9
- package/esm/accordion/AccordionContent.js.map +1 -1
- package/esm/accordion/AccordionHeader.js +5 -10
- package/esm/accordion/AccordionHeader.js.map +1 -1
- package/esm/accordion/AccordionItem.d.ts +0 -8
- package/esm/accordion/AccordionItem.js +2 -6
- 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.d.ts +10 -1
- package/esm/button/Button.js +10 -8
- 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.d.ts +1 -1
- package/esm/form/ConfirmationPanel.js +3 -3
- 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.d.ts +1 -1
- package/esm/form/search/SearchButton.js +2 -4
- 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 +5 -7
- 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.d.ts +0 -5
- package/esm/read-more/ReadMore.js +7 -11
- 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 +7 -10
- 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 +5 -5
- 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/AnimateHeight.d.ts +10 -0
- package/esm/util/AnimateHeight.js +180 -0
- package/esm/util/AnimateHeight.js.map +1 -0
- 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 -15
- package/src/accordion/Accordion.tsx +1 -1
- package/src/accordion/AccordionContent.tsx +13 -19
- package/src/accordion/AccordionHeader.tsx +11 -18
- package/src/accordion/AccordionItem.tsx +2 -23
- package/src/accordion/accordion.stories.tsx +30 -31
- package/src/alert/Alert.tsx +2 -2
- package/src/alert/alert.stories.tsx +7 -0
- package/src/button/Button.tsx +39 -14
- package/src/button/button.stories.tsx +55 -28
- 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 +9 -4
- 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 +8 -4
- 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 +6 -8
- package/src/modal/ModalContent.tsx +1 -1
- package/src/pagination/Pagination.tsx +87 -72
- package/src/pagination/PaginationItem.tsx +56 -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 +19 -30
- package/src/read-more/readmore.stories.tsx +3 -10
- 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 +12 -13
- 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 +6 -19
- 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/AnimateHeight.tsx +240 -0
- 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
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import React, { forwardRef, HTMLAttributes } from "react";
|
|
2
|
+
import cl from "clsx";
|
|
3
|
+
import Bubble, { BubbleType } from "./Bubble";
|
|
4
|
+
import { BodyLong, BodyShort } from "..";
|
|
5
|
+
|
|
6
|
+
export interface ChatProps extends HTMLAttributes<HTMLDivElement> {
|
|
7
|
+
/**
|
|
8
|
+
* Children of type <Chat.Bubble />
|
|
9
|
+
*/
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* Chat-message name
|
|
13
|
+
*/
|
|
14
|
+
name: string;
|
|
15
|
+
/**
|
|
16
|
+
* Timestamp for sent message
|
|
17
|
+
*/
|
|
18
|
+
timestamp?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Avatar for messenger. Regular text for initials works to
|
|
21
|
+
*/
|
|
22
|
+
avatar: React.ReactNode;
|
|
23
|
+
/**
|
|
24
|
+
* Background color on bubbles
|
|
25
|
+
*/
|
|
26
|
+
backgroundColor?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Background color for avatar
|
|
29
|
+
*/
|
|
30
|
+
avatarBgColor?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Positions avatar and Bubbles
|
|
33
|
+
* @default "left"
|
|
34
|
+
*/
|
|
35
|
+
position?: "left" | "right";
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface ChatComponent
|
|
39
|
+
extends React.ForwardRefExoticComponent<
|
|
40
|
+
ChatProps & React.RefAttributes<HTMLDivElement>
|
|
41
|
+
> {
|
|
42
|
+
Bubble: BubbleType;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const Chat = forwardRef<HTMLDivElement, ChatProps>(
|
|
46
|
+
(
|
|
47
|
+
{
|
|
48
|
+
children,
|
|
49
|
+
className,
|
|
50
|
+
name,
|
|
51
|
+
timestamp,
|
|
52
|
+
avatar,
|
|
53
|
+
position = "left",
|
|
54
|
+
avatarBgColor,
|
|
55
|
+
backgroundColor,
|
|
56
|
+
...rest
|
|
57
|
+
},
|
|
58
|
+
ref
|
|
59
|
+
) => {
|
|
60
|
+
return (
|
|
61
|
+
<div
|
|
62
|
+
ref={ref}
|
|
63
|
+
className={cl("navds-chat", className, `navds-chat--${position}`)}
|
|
64
|
+
{...rest}
|
|
65
|
+
>
|
|
66
|
+
<BodyShort
|
|
67
|
+
as="div"
|
|
68
|
+
className="navds-chat__avatar"
|
|
69
|
+
style={{ backgroundColor: avatarBgColor }}
|
|
70
|
+
>
|
|
71
|
+
{avatar}
|
|
72
|
+
</BodyShort>
|
|
73
|
+
<ol className="navds-chat__bubble-wrapper">
|
|
74
|
+
{React.Children.map(children, (child, i) => {
|
|
75
|
+
if (React.isValidElement(child)) {
|
|
76
|
+
return (
|
|
77
|
+
<BodyLong as="li">
|
|
78
|
+
{React.cloneElement(child, {
|
|
79
|
+
name: name && i === 0 ? name : undefined,
|
|
80
|
+
timestamp: timestamp && i === 0 ? timestamp : undefined,
|
|
81
|
+
backgroundColor,
|
|
82
|
+
...child.props,
|
|
83
|
+
})}
|
|
84
|
+
</BodyLong>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
})}
|
|
88
|
+
</ol>
|
|
89
|
+
</div>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
) as ChatComponent;
|
|
93
|
+
|
|
94
|
+
Chat.Bubble = Bubble;
|
|
95
|
+
|
|
96
|
+
export default Chat;
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Chat } from "../index";
|
|
3
|
+
import { Meta } from "@storybook/react/types-6-0";
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: "ds-react/Chat",
|
|
7
|
+
component: Chat,
|
|
8
|
+
argTypes: {
|
|
9
|
+
backgroundColor: {
|
|
10
|
+
control: {
|
|
11
|
+
type: "text",
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
avatarBgColor: {
|
|
15
|
+
control: {
|
|
16
|
+
type: "text",
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
} as Meta;
|
|
21
|
+
|
|
22
|
+
export const Default = (props) => {
|
|
23
|
+
return (
|
|
24
|
+
<Chat
|
|
25
|
+
avatar={props?.avatar ?? "ON"}
|
|
26
|
+
name={props?.name ?? "Ola Normann"}
|
|
27
|
+
timestamp={props?.timestamp ?? "01.01.21 14:00"}
|
|
28
|
+
avatarBgColor={props?.avatarBgColor}
|
|
29
|
+
backgroundColor={props?.backgroundColor}
|
|
30
|
+
>
|
|
31
|
+
<Chat.Bubble>
|
|
32
|
+
Aute minim nisi sunt mollit duis sunt nulla minim non proident.
|
|
33
|
+
</Chat.Bubble>
|
|
34
|
+
<Chat.Bubble>Tempor fugiat amet eu sint in in ullamco.</Chat.Bubble>
|
|
35
|
+
<Chat.Bubble>
|
|
36
|
+
Adipisicing laborum est eu laborum est sit in commodo enim sint laboris
|
|
37
|
+
labore nisi ut.
|
|
38
|
+
</Chat.Bubble>
|
|
39
|
+
</Chat>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
Default.args = {
|
|
44
|
+
name: "Ola Normann",
|
|
45
|
+
timestamp: "01.01.21 14:00",
|
|
46
|
+
avatar: "ON",
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const Farger = () => {
|
|
50
|
+
return (
|
|
51
|
+
<Chat
|
|
52
|
+
avatar={"ON"}
|
|
53
|
+
name={"Ola Normann"}
|
|
54
|
+
timestamp={"01.01.21 14:00"}
|
|
55
|
+
avatarBgColor={"var(--navds-global-color-lightblue-200)"}
|
|
56
|
+
backgroundColor={"var(--navds-global-color-lightblue-100)"}
|
|
57
|
+
>
|
|
58
|
+
<Chat.Bubble>
|
|
59
|
+
Aute minim nisi sunt mollit duis sunt nulla minim non proident.
|
|
60
|
+
</Chat.Bubble>
|
|
61
|
+
<Chat.Bubble>Tempor fugiat amet eu sint in in ullamco.</Chat.Bubble>
|
|
62
|
+
<Chat.Bubble>
|
|
63
|
+
Adipisicing laborum est eu laborum est sit in commodo enim sint laboris
|
|
64
|
+
labore nisi ut.
|
|
65
|
+
</Chat.Bubble>
|
|
66
|
+
</Chat>
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const Position = () => {
|
|
71
|
+
return (
|
|
72
|
+
<div className="colgap">
|
|
73
|
+
<Chat
|
|
74
|
+
avatar={"ON"}
|
|
75
|
+
name={"Ola Normann"}
|
|
76
|
+
timestamp={"01.01.21 14:00"}
|
|
77
|
+
backgroundColor="rgba(255, 249, 240, 1)"
|
|
78
|
+
avatarBgColor="rgba(255, 236, 204, 1)"
|
|
79
|
+
>
|
|
80
|
+
<Chat.Bubble>
|
|
81
|
+
Adipisicing laborum est eu laborum est sit in commodo enim sint
|
|
82
|
+
laboris labore nisi ut.
|
|
83
|
+
</Chat.Bubble>
|
|
84
|
+
</Chat>
|
|
85
|
+
<Chat
|
|
86
|
+
avatar={"KH"}
|
|
87
|
+
name={"Kari Høyli"}
|
|
88
|
+
timestamp={"01.01.21 14:32"}
|
|
89
|
+
position="right"
|
|
90
|
+
backgroundColor="rgba(230, 240, 255, 1)"
|
|
91
|
+
avatarBgColor="rgba(204, 225, 255, 1)"
|
|
92
|
+
>
|
|
93
|
+
<Chat.Bubble>
|
|
94
|
+
Reprehenderit pariatur officia exercitation laboris.
|
|
95
|
+
</Chat.Bubble>
|
|
96
|
+
<Chat.Bubble>
|
|
97
|
+
Enim velit deserunt do quis. Eu fugiat magna esse dolore ad sunt sit
|
|
98
|
+
est dolore incididunt. Occaecat cupidatat magna.
|
|
99
|
+
</Chat.Bubble>
|
|
100
|
+
</Chat>
|
|
101
|
+
<Chat
|
|
102
|
+
avatar={"ON"}
|
|
103
|
+
name={"Ola Normann"}
|
|
104
|
+
timestamp={"01.01.21 15:00"}
|
|
105
|
+
backgroundColor="rgba(255, 249, 240, 1)"
|
|
106
|
+
avatarBgColor="rgba(255, 236, 204, 1)"
|
|
107
|
+
>
|
|
108
|
+
<Chat.Bubble>
|
|
109
|
+
Exercitation irure Lorem cupidatat culpa anim cillum esse ullamco qui
|
|
110
|
+
dolore laborum et Lorem. Labore sunt duis id Lorem voluptate commodo
|
|
111
|
+
ea esse. Dolore esse aliqua proident ea ad commodo ut dolore voluptate
|
|
112
|
+
labore sunt aute.
|
|
113
|
+
</Chat.Bubble>
|
|
114
|
+
</Chat>
|
|
115
|
+
</div>
|
|
116
|
+
);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export const Avatar = () => {
|
|
120
|
+
return (
|
|
121
|
+
<Chat
|
|
122
|
+
avatar={<Illustration />}
|
|
123
|
+
name={"Ola Normann"}
|
|
124
|
+
timestamp={"01.01.21 14:00"}
|
|
125
|
+
>
|
|
126
|
+
<Chat.Bubble>
|
|
127
|
+
Aute minim nisi sunt mollit duis sunt nulla minim non proident.
|
|
128
|
+
</Chat.Bubble>
|
|
129
|
+
<Chat.Bubble>Tempor fugiat amet eu sint in in ullamco.</Chat.Bubble>
|
|
130
|
+
<Chat.Bubble>
|
|
131
|
+
Adipisicing laborum est eu laborum est sit in commodo enim sint laboris
|
|
132
|
+
labore nisi ut.
|
|
133
|
+
</Chat.Bubble>
|
|
134
|
+
</Chat>
|
|
135
|
+
);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const Illustration = () => (
|
|
139
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 54 93">
|
|
140
|
+
<path
|
|
141
|
+
fill="#e7e5e2"
|
|
142
|
+
d="M14 50.7C15 52.3 17.9 81 26.5 81S39 51.8 39 50.3c-13.2-7.6-25 .4-25 .4z"
|
|
143
|
+
/>
|
|
144
|
+
<path
|
|
145
|
+
fill="#5c4378"
|
|
146
|
+
d="M38.7 50.2c6 2.9 15.3 10.9 15.3 18.3V93H0V68.5c0-7.1 8.5-14.8 14.5-18-.3.2-.5.3-.5.3 1 1.7 3.8 9.2 12.4 9.2C35 60 39 51.9 39 50.4c-.1-.1-.2-.2-.3-.2z"
|
|
147
|
+
/>
|
|
148
|
+
<path
|
|
149
|
+
fill="#d2242a"
|
|
150
|
+
d="M46.7 76H31.2c-.7 0-1.3-.6-1.2-1.3v-8.5c0-.7.6-1.3 1.3-1.3h15.5c.7 0 1.3.6 1.3 1.3v8.5c-.1.7-.7 1.3-1.4 1.3"
|
|
151
|
+
/>
|
|
152
|
+
<path
|
|
153
|
+
fill="#fff"
|
|
154
|
+
d="M42.9 71c0 2.1-1.7 3.8-3.8 3.8-2.1 0-3.8-1.7-3.8-3.8s1.7-3.8 3.8-3.8c2.1 0 3.8 1.7 3.8 3.8m-8.7 1.7h-.7l.8-1.9h.7l-.8 1.9zm9.3 0H43l.8-1.9h.5l-.8 1.9zm1.2 0h-.2l.8-1.9h.2l-.8 1.9z"
|
|
155
|
+
/>
|
|
156
|
+
<path
|
|
157
|
+
fill="#c52d35"
|
|
158
|
+
d="M36.2 72.7h.6s.1 0 .1-.1v-1.8s0-.1-.1-.1h-.6s-.1 0-.1.1l-.2.6v.1h.2l.1 1.2c0-.1 0 0 0 0"
|
|
159
|
+
/>
|
|
160
|
+
<path
|
|
161
|
+
fill="#c52d35"
|
|
162
|
+
d="M37.5 72.7h.6s.1 0 .1-.1v-1.8s0-.1-.1-.1h-.9s-.1 0-.1.1l-.2.6-.1.1h.5c.1 0 .2.1.2.2v1c-.1-.1-.1 0 0 0m2.6-1.9h-.6s-.1 0-.1.1v1.8s0 .1.1.1h.6s.1 0 .1-.1l.2-.6V72h-.2l-.1-1.2"
|
|
163
|
+
/>
|
|
164
|
+
<path
|
|
165
|
+
fill="#c52d35"
|
|
166
|
+
d="M37.7 72.7h.4s.1 0 .1-.1l.2-.6v-.1h-.2c0 .1-.5.8-.5.8zm3.9-1.9h.7s.1 0 0 .1l-.7 1.8H41l.6-1.9"
|
|
167
|
+
/>
|
|
168
|
+
<path
|
|
169
|
+
fill="#c52d35"
|
|
170
|
+
d="M40.8 70.8h-1c-.1 0 .3.1.3.1l.7 1.7s0 .1.1.1h.6l-.7-1.9m-1.3.6v.4s-.1-.4-.3-.4c-.3 0-.3.2-.3.3 0 .1.1.3.2.3h.5l-.3.7H39c-.2 0-.9-.3-.9-.9 0-.6.5-1 .9-1 .2-.1.5.2.5.6 0-.1 0-.1 0 0z"
|
|
171
|
+
/>
|
|
172
|
+
<path
|
|
173
|
+
fill="#5a1f57"
|
|
174
|
+
d="M39.9 66.7h-1.6c-.1 0-.2-.1-.2-.2v-.3c0-.1.1-.2.2-.2h1.6c.1 0 .2.1.2.2v.3c0 .2-.1.2-.2.2"
|
|
175
|
+
/>
|
|
176
|
+
<path fill="#c2b5cf" d="M38.7 66.5h.9V64h-.9v2.5z" />
|
|
177
|
+
<path
|
|
178
|
+
fill="#e7e5e2"
|
|
179
|
+
d="M47.2 35.3C44.7 45.6 36.6 53.1 27 53.1S9.3 45.6 6.8 35.3c-.2.1-.5.1-.8.1-1.1 0-2-.8-2-1.7v-7c0-1 .9-1.7 2-1.7h.2C7.7 13.1 16.4 4 27 4c10.6 0 19.3 9.1 20.8 21h.2c1.1 0 2 .8 2 1.7v7c0 1-.9 1.7-2 1.7-.3 0-.5 0-.8-.1z"
|
|
180
|
+
/>
|
|
181
|
+
<path
|
|
182
|
+
fill="#635e59"
|
|
183
|
+
d="M19 27.6c-1.4.1-1.9-2-1.4-3.4.1-.3.6-1.5 1.4-1.5.8 0 1.2.7 1.3.8.6 1.4.3 4-1.3 4.1m16.2 0c1.4.1 1.9-2 1.4-3.4-.1-.3-.6-1.5-1.4-1.5-.8 0-1.2.7-1.3.8-.6 1.4-.3 4 1.3 4.1"
|
|
184
|
+
/>
|
|
185
|
+
<path
|
|
186
|
+
fill="#d1bfa3"
|
|
187
|
+
d="M26.8 34.6c-.4 0-.7-.1-1-.2-.3-.1-.4-.4-.3-.7.1-.3.4-.4.7-.3.5.2 1.5.1 2.2-.4.7-.4 1.1-1 1.2-1.5.1-.4-.1-.9-.4-1.3-.2-.2-.8-.2-1.6-.1-.3 0-.5-.1-.6-.4 0-.3.1-.5.4-.6 1.2-.2 2.1 0 2.6.6.5.7.8 1.4.6 2.1-.1.8-.7 1.6-1.7 2.2-.6.3-1.4.6-2.1.6z"
|
|
188
|
+
/>
|
|
189
|
+
<path
|
|
190
|
+
fill="#593a32"
|
|
191
|
+
d="M27.1 42.1h-.3c-5.3-.2-7.3-4.1-7.4-4.3-.1-.3 0-.6.2-.7.2-.1.6 0 .7.2.1.1 1.9 3.6 6.6 3.8 4.7.2 6.4-3.7 6.4-3.7.1-.3.4-.4.7-.3.3.1.4.4.3.7-.1 0-2.1 4.3-7.2 4.3z"
|
|
192
|
+
/>
|
|
193
|
+
<path
|
|
194
|
+
fill="#f6b873"
|
|
195
|
+
d="M6.6 30.7c.1-.1.1-.2.1-.3v-2c-.1-5.6 1.8-8.1 3.4-10.1 0 0-1 4.3-.3 3.4 3.8-5 21.4-1.6 25-8.1.5 3.6-4.1 4.6-4.1 4.6 3.7.7 6.9-.8 7.7-2.5.3 1.4-.6 2.4-1.9 3.4 4.5-.9 4.6-4 4.6-4 .6 4.1 5.3 2.5 5.3 9.3v6c0 .3.2.6.5.6h.5c.3 0 .5-.3.5-.6V26c.3-15.6-8.5-26-20.6-26C15.9 0 5 10.4 5 24.1v6.3c0 .4.2.6.5.6h.6c.2 0 .3-.1.5-.3"
|
|
196
|
+
/>
|
|
197
|
+
<path
|
|
198
|
+
fill="#f6b873"
|
|
199
|
+
d="M25.9 43.4c-4.4 0-8-1.4-8-3.2s3.6-3.2 8-3.2 8 1.4 8 3.2c0 1.8-3.6 3.2-8 3.2m.8-9.4c-2.9 0-4.7.7-8.8 2.1-12.7 4.6-11.6-14-11.6-14C3.4 46 18.6 52 26.5 52c8.1 0 24.1-8.1 21-30 0 0 .4 17.1-12.9 13.8-3.7-.9-5-1.8-7.9-1.8z"
|
|
200
|
+
/>
|
|
201
|
+
</svg>
|
|
202
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Chat, ChatProps } from "./Chat";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import cl from "classnames";
|
|
2
1
|
import React, { forwardRef } from "react";
|
|
2
|
+
import cl from "clsx";
|
|
3
3
|
import { BodyLong, Checkbox, CheckboxProps, ErrorMessage } from "..";
|
|
4
4
|
import { useFormField } from "./useFormField";
|
|
5
5
|
|
|
@@ -27,7 +27,7 @@ export interface ConfirmationPanelProps
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
export const ConfirmationPanel = forwardRef<
|
|
30
|
-
|
|
30
|
+
HTMLInputElement,
|
|
31
31
|
ConfirmationPanelProps
|
|
32
32
|
>(({ className, children, label, ...props }, ref) => {
|
|
33
33
|
const { errorId, showErrorMsg, hasError, size, inputProps } = useFormField(
|
|
@@ -37,7 +37,6 @@ export const ConfirmationPanel = forwardRef<
|
|
|
37
37
|
|
|
38
38
|
return (
|
|
39
39
|
<div
|
|
40
|
-
ref={ref}
|
|
41
40
|
className={cl("navds-confirmation-panel", "navds-form-field", className, {
|
|
42
41
|
"navds-confirmation-panel--small": size === "small",
|
|
43
42
|
"navds-confirmation-panel--error": hasError,
|
|
@@ -53,7 +52,13 @@ export const ConfirmationPanel = forwardRef<
|
|
|
53
52
|
{children}
|
|
54
53
|
</BodyLong>
|
|
55
54
|
)}
|
|
56
|
-
<Checkbox
|
|
55
|
+
<Checkbox
|
|
56
|
+
ref={ref}
|
|
57
|
+
{...props}
|
|
58
|
+
{...inputProps}
|
|
59
|
+
error={hasError}
|
|
60
|
+
size={size}
|
|
61
|
+
>
|
|
57
62
|
{label}
|
|
58
63
|
</Checkbox>
|
|
59
64
|
</div>
|
package/src/form/Select.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { forwardRef, SelectHTMLAttributes } from "react";
|
|
2
|
-
import cl from "
|
|
2
|
+
import cl from "clsx";
|
|
3
3
|
import { Expand } from "@navikt/ds-icons";
|
|
4
4
|
import { BodyShort, Label, ErrorMessage, omit, Detail } from "..";
|
|
5
5
|
import { FormFieldProps, useFormField } from "./useFormField";
|
package/src/form/Switch.tsx
CHANGED
package/src/form/TextField.tsx
CHANGED
package/src/form/Textarea.tsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React, { forwardRef, useState } from "react";
|
|
2
|
-
import cl from "
|
|
3
|
-
import TextareaAutosize from "@material-ui/core/TextareaAutosize";
|
|
2
|
+
import cl from "clsx";
|
|
4
3
|
import { BodyShort, Label, ErrorMessage, omit, Detail } from "..";
|
|
5
4
|
import { FormFieldProps, useFormField } from "./useFormField";
|
|
6
5
|
import { useId } from "..";
|
|
6
|
+
import TextareaAutosize from "../util/TextareaAutoSize";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* TODO: Mulighet for lokalisering av sr-only/counter text
|
|
@@ -68,7 +68,7 @@ export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
|
68
68
|
...rest
|
|
69
69
|
} = props;
|
|
70
70
|
|
|
71
|
-
const maxLengthId =
|
|
71
|
+
const maxLengthId = useId();
|
|
72
72
|
const hasMaxLength = maxLength !== undefined && maxLength > 0;
|
|
73
73
|
|
|
74
74
|
const [controlledValue, setControlledValue] = useState<string>(
|
|
@@ -76,9 +76,9 @@ export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
|
76
76
|
);
|
|
77
77
|
|
|
78
78
|
const getMinRows = () => {
|
|
79
|
-
let rows = rest?.minRows
|
|
79
|
+
let rows = rest?.minRows ? rest?.minRows : 3;
|
|
80
80
|
if (size === "small") {
|
|
81
|
-
rows = rest?.minRows
|
|
81
|
+
rows = rest?.minRows ? rest?.minRows : 2;
|
|
82
82
|
}
|
|
83
83
|
return rows;
|
|
84
84
|
};
|
|
@@ -153,7 +153,7 @@ export const Textarea = forwardRef<HTMLTextAreaElement, TextareaProps>(
|
|
|
153
153
|
}
|
|
154
154
|
)}
|
|
155
155
|
aria-describedby={cl(inputProps["aria-describedby"], {
|
|
156
|
-
[maxLengthId]: hasMaxLength,
|
|
156
|
+
[maxLengthId ?? ""]: hasMaxLength,
|
|
157
157
|
})}
|
|
158
158
|
/>
|
|
159
159
|
{hasMaxLength && (
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { render, screen } from "@testing-library/react";
|
|
3
|
-
import userEvent from "@testing-library/user-event";
|
|
2
|
+
import { act, fireEvent, render, screen } from "@testing-library/react";
|
|
4
3
|
import faker from "faker";
|
|
5
4
|
import { Checkbox, CheckboxGroup } from ".";
|
|
6
5
|
|
|
@@ -15,9 +14,8 @@ test("checkbox group chains onChange calls", async () => {
|
|
|
15
14
|
const onChange = jest.fn();
|
|
16
15
|
const value = faker.datatype.string();
|
|
17
16
|
const label = faker.datatype.string();
|
|
18
|
-
const user = userEvent.setup();
|
|
19
17
|
|
|
20
|
-
render(
|
|
18
|
+
const { getByLabelText } = render(
|
|
21
19
|
<CheckboxGroup legend="legend" onChange={onGroupChange}>
|
|
22
20
|
<Checkbox onChange={onChange} value={value}>
|
|
23
21
|
{label}
|
|
@@ -25,7 +23,9 @@ test("checkbox group chains onChange calls", async () => {
|
|
|
25
23
|
</CheckboxGroup>
|
|
26
24
|
);
|
|
27
25
|
|
|
28
|
-
await
|
|
26
|
+
await act(async () => {
|
|
27
|
+
fireEvent.click(getByLabelText(label));
|
|
28
|
+
});
|
|
29
29
|
|
|
30
30
|
expect(onGroupChange).toBeCalledTimes(1);
|
|
31
31
|
expect(onGroupChange).toBeCalledWith([value]);
|
|
@@ -42,10 +42,14 @@ describe("Checkbox handles controlled-state correctly", () => {
|
|
|
42
42
|
);
|
|
43
43
|
|
|
44
44
|
test("Checkbox is still checked after click when controlled", async () => {
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
const { getByLabelText } = render(
|
|
46
|
+
<CheckboxComponent value={["value1", "value2"]} />
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
await act(async () => {
|
|
50
|
+
fireEvent.click(getByLabelText("label1"));
|
|
51
|
+
fireEvent.click(getByLabelText("label2"));
|
|
52
|
+
});
|
|
49
53
|
|
|
50
54
|
expect((screen.getByLabelText("label1") as HTMLInputElement).checked).toBe(
|
|
51
55
|
true
|
|
@@ -58,22 +62,21 @@ describe("Checkbox handles controlled-state correctly", () => {
|
|
|
58
62
|
|
|
59
63
|
test("onChange called with expected values", async () => {
|
|
60
64
|
const onGroupChange = jest.fn();
|
|
61
|
-
const user = userEvent.setup();
|
|
62
65
|
|
|
63
|
-
render(
|
|
66
|
+
const { getByLabelText } = render(
|
|
64
67
|
<CheckboxComponent
|
|
65
68
|
onChange={onGroupChange}
|
|
66
69
|
value={["value1", "value2"]}
|
|
67
70
|
/>
|
|
68
71
|
);
|
|
69
72
|
|
|
70
|
-
await
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
await user.click(screen.getByLabelText("label2"));
|
|
73
|
+
await act(async () => {
|
|
74
|
+
fireEvent.click(getByLabelText("label1"));
|
|
75
|
+
expect(onGroupChange).lastCalledWith(["value2"]);
|
|
75
76
|
|
|
76
|
-
|
|
77
|
+
fireEvent.click(getByLabelText("label2"));
|
|
78
|
+
expect(onGroupChange).lastCalledWith(["value1"]);
|
|
79
|
+
});
|
|
77
80
|
});
|
|
78
81
|
|
|
79
82
|
test("Checkboxes updates after value-prop change", () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { forwardRef, HTMLAttributes } from "react";
|
|
2
|
-
import cl from "
|
|
2
|
+
import cl from "clsx";
|
|
3
3
|
import { Heading, BodyShort } from "../..";
|
|
4
4
|
import ErrorSummaryItem, { ErrorSummaryItemType } from "./ErrorSummaryItem";
|
|
5
5
|
import { useId } from "../../util";
|
|
@@ -58,13 +58,13 @@ export const ErrorSummary = forwardRef<HTMLDivElement, ErrorSummaryProps>(
|
|
|
58
58
|
tabIndex={-1}
|
|
59
59
|
aria-live="polite"
|
|
60
60
|
aria-relevant="all"
|
|
61
|
-
aria-labelledby={
|
|
61
|
+
aria-labelledby={headingId}
|
|
62
62
|
>
|
|
63
63
|
<Heading
|
|
64
64
|
className="navds-error-summary__heading"
|
|
65
65
|
as={headingTag}
|
|
66
66
|
size="small"
|
|
67
|
-
id={
|
|
67
|
+
id={headingId}
|
|
68
68
|
>
|
|
69
69
|
{heading}
|
|
70
70
|
</Heading>
|
package/src/form/radio/Radio.tsx
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
import { Close, Search as SearchIcon } from "@navikt/ds-icons";
|
|
2
|
-
import cl from "
|
|
2
|
+
import cl from "clsx";
|
|
3
3
|
import React, {
|
|
4
4
|
forwardRef,
|
|
5
5
|
InputHTMLAttributes,
|
|
6
6
|
useCallback,
|
|
7
|
+
useMemo,
|
|
7
8
|
useRef,
|
|
8
9
|
useState,
|
|
9
10
|
} from "react";
|
|
10
|
-
import
|
|
11
|
-
|
|
11
|
+
import {
|
|
12
|
+
BodyShort,
|
|
13
|
+
ErrorMessage,
|
|
14
|
+
Label,
|
|
15
|
+
mergeRefs,
|
|
16
|
+
omit,
|
|
17
|
+
useEventListener,
|
|
18
|
+
} from "../..";
|
|
12
19
|
import { FormFieldProps, useFormField } from "../useFormField";
|
|
13
20
|
import SearchButton, { SearchButtonType } from "./SearchButton";
|
|
14
21
|
|
|
@@ -103,7 +110,7 @@ export const Search = forwardRef<HTMLInputElement, SearchProps>(
|
|
|
103
110
|
} = props;
|
|
104
111
|
|
|
105
112
|
const searchRef = useRef<HTMLInputElement | null>(null);
|
|
106
|
-
const mergedRef = mergeRefs([searchRef, ref]);
|
|
113
|
+
const mergedRef = useMemo(() => mergeRefs([searchRef, ref]), [ref]);
|
|
107
114
|
const [wrapperRef, setWrapperRef] = useState<HTMLDivElement | null>(null);
|
|
108
115
|
|
|
109
116
|
const [internalValue, setInternalValue] = useState(defaultValue ?? "");
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Search } from "@navikt/ds-icons";
|
|
2
|
-
import cl from "
|
|
2
|
+
import cl from "clsx";
|
|
3
3
|
import React, { forwardRef, useContext } from "react";
|
|
4
4
|
import { Button, ButtonProps } from "../..";
|
|
5
5
|
import { SearchContext } from "./Search";
|
|
@@ -7,7 +7,7 @@ import { SearchContext } from "./Search";
|
|
|
7
7
|
export interface SearchButtonProps
|
|
8
8
|
extends Omit<ButtonProps, "size" | "children" | "variant"> {
|
|
9
9
|
/**
|
|
10
|
-
* Text set
|
|
10
|
+
* Text set after <Search/> icon
|
|
11
11
|
*/
|
|
12
12
|
children?: React.ReactNode;
|
|
13
13
|
}
|
|
@@ -36,9 +36,13 @@ const SearchButton: SearchButtonType = forwardRef(
|
|
|
36
36
|
variant={variant === "secondary" ? "secondary" : "primary"}
|
|
37
37
|
className={cl("navds-search__button-search", className)}
|
|
38
38
|
disabled={context?.disabled ?? disabled}
|
|
39
|
+
icon={
|
|
40
|
+
<Search
|
|
41
|
+
{...(children ? { "aria-hidden": true } : { title: "Søk" })}
|
|
42
|
+
/>
|
|
43
|
+
}
|
|
39
44
|
>
|
|
40
|
-
|
|
41
|
-
{children ? children : <span className="navds-sr-only">Søk</span>}
|
|
45
|
+
{children}
|
|
42
46
|
</Button>
|
|
43
47
|
);
|
|
44
48
|
}
|
package/src/form/useFormField.ts
CHANGED
package/src/grid/Cell.tsx
CHANGED
package/src/grid/Grid.tsx
CHANGED