@navikt/ds-react 0.19.16 → 1.0.0-rc.1
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/_docs.json +354 -453
- 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 +11 -10
- 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.d.ts +1 -1
- package/esm/form/search/Search.js +10 -9
- 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 +29 -9
- package/src/form/search/SearchButton.tsx +1 -1
- package/src/form/search/search.stories.tsx +21 -0
- 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/form/search/useSearch.js +0 -31
- 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/form/search/useSearch.d.ts +0 -10
- package/esm/form/search/useSearch.js +0 -25
- package/esm/form/search/useSearch.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/form/search/useSearch.ts +0 -31
- 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
package/src/tooltip/Tooltip.tsx
CHANGED
|
@@ -1,26 +1,28 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {
|
|
2
|
+
arrow as flArrow,
|
|
3
|
+
autoUpdate,
|
|
4
|
+
flip,
|
|
5
|
+
FloatingPortal,
|
|
6
|
+
offset,
|
|
7
|
+
safePolygon,
|
|
8
|
+
shift,
|
|
9
|
+
useDismiss,
|
|
10
|
+
useFloating,
|
|
11
|
+
useFocus,
|
|
12
|
+
useHover,
|
|
13
|
+
useInteractions,
|
|
14
|
+
} from "@floating-ui/react-dom-interactions";
|
|
15
|
+
import cl from "clsx";
|
|
2
16
|
import React, {
|
|
3
17
|
cloneElement,
|
|
4
18
|
forwardRef,
|
|
5
19
|
HTMLAttributes,
|
|
6
|
-
useCallback,
|
|
7
|
-
useEffect,
|
|
8
20
|
useMemo,
|
|
9
21
|
useRef,
|
|
10
22
|
useState,
|
|
11
23
|
} from "react";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
useFloating,
|
|
15
|
-
arrow as flArrow,
|
|
16
|
-
shift,
|
|
17
|
-
autoUpdate,
|
|
18
|
-
flip,
|
|
19
|
-
hide,
|
|
20
|
-
} from "@floating-ui/react-dom";
|
|
21
|
-
import mergeRefs from "react-merge-refs";
|
|
22
|
-
import Portal from "./portal";
|
|
23
|
-
import { useId } from "../util";
|
|
24
|
+
import { Detail } from "..";
|
|
25
|
+
import { mergeRefs, useId } from "../util";
|
|
24
26
|
|
|
25
27
|
export interface TooltipProps extends HTMLAttributes<HTMLDivElement> {
|
|
26
28
|
/**
|
|
@@ -80,7 +82,7 @@ export const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(
|
|
|
80
82
|
className,
|
|
81
83
|
arrow: _arrow = true,
|
|
82
84
|
placement: _placement = "top",
|
|
83
|
-
open,
|
|
85
|
+
open: userOpen,
|
|
84
86
|
defaultOpen = false,
|
|
85
87
|
offset: _offset,
|
|
86
88
|
content,
|
|
@@ -92,88 +94,49 @@ export const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(
|
|
|
92
94
|
},
|
|
93
95
|
ref
|
|
94
96
|
) => {
|
|
97
|
+
const [open, setOpen] = useState(defaultOpen);
|
|
95
98
|
const arrowRef = useRef<HTMLDivElement | null>(null);
|
|
96
|
-
const [isOpen, setIsOpen] = useState(defaultOpen);
|
|
97
|
-
const openTimerRef = useRef(0);
|
|
98
|
-
const leaveTimerRef = useRef(0);
|
|
99
|
-
const isMouseDownRef = useRef(false);
|
|
100
|
-
|
|
101
|
-
const ariaId = useId(id);
|
|
102
99
|
|
|
103
100
|
const {
|
|
104
101
|
x,
|
|
105
102
|
y,
|
|
106
|
-
|
|
103
|
+
reference,
|
|
104
|
+
floating,
|
|
105
|
+
strategy,
|
|
106
|
+
context,
|
|
107
107
|
placement,
|
|
108
|
-
refs,
|
|
109
108
|
middlewareData: {
|
|
110
109
|
arrow: { x: arrowX, y: arrowY } = {},
|
|
111
110
|
hide: { referenceHidden } = {},
|
|
112
111
|
},
|
|
113
112
|
} = useFloating({
|
|
114
113
|
placement: _placement,
|
|
114
|
+
open: userOpen ?? open,
|
|
115
|
+
onOpenChange: setOpen,
|
|
115
116
|
middleware: [
|
|
117
|
+
offset(_offset ? _offset : _arrow ? 10 : 2),
|
|
116
118
|
shift(),
|
|
117
119
|
flip({ padding: 5, fallbackPlacements: ["bottom", "top"] }),
|
|
118
120
|
flArrow({ element: arrowRef, padding: 5 }),
|
|
119
|
-
hide(),
|
|
120
121
|
],
|
|
122
|
+
whileElementsMounted: autoUpdate,
|
|
121
123
|
});
|
|
122
124
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
// Only call this when the floating element is rendered
|
|
130
|
-
return autoUpdate(refs.reference.current, refs.floating.current, update);
|
|
131
|
-
}, [refs.reference, refs.floating, update, open, isOpen]);
|
|
125
|
+
const { getReferenceProps, getFloatingProps } = useInteractions([
|
|
126
|
+
useHover(context, { handleClose: safePolygon(), restMs: delay }),
|
|
127
|
+
useFocus(context),
|
|
128
|
+
useDismiss(context),
|
|
129
|
+
]);
|
|
132
130
|
|
|
133
|
-
const
|
|
134
|
-
window.clearTimeout(openTimerRef.current);
|
|
135
|
-
window.clearTimeout(leaveTimerRef.current);
|
|
136
|
-
setIsOpen(true);
|
|
137
|
-
}, [setIsOpen]);
|
|
138
|
-
|
|
139
|
-
const handleDelayedOpen = useCallback(() => {
|
|
140
|
-
window.clearTimeout(openTimerRef.current);
|
|
141
|
-
window.clearTimeout(leaveTimerRef.current);
|
|
142
|
-
openTimerRef.current = window.setTimeout(() => {
|
|
143
|
-
setIsOpen(true);
|
|
144
|
-
}, delay);
|
|
145
|
-
}, [delay, setIsOpen]);
|
|
146
|
-
|
|
147
|
-
const handleClose = useCallback(() => {
|
|
148
|
-
window.clearTimeout(openTimerRef.current);
|
|
149
|
-
leaveTimerRef.current = window.setTimeout(() => {
|
|
150
|
-
setIsOpen(false);
|
|
151
|
-
}, 50);
|
|
152
|
-
}, [setIsOpen]);
|
|
153
|
-
|
|
154
|
-
const handleMouseUp = useCallback(
|
|
155
|
-
() => (isMouseDownRef.current = false),
|
|
156
|
-
[]
|
|
157
|
-
);
|
|
158
|
-
|
|
159
|
-
useEffect(() => {
|
|
160
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
161
|
-
return () => window.clearTimeout(openTimerRef.current);
|
|
162
|
-
}, []);
|
|
163
|
-
|
|
164
|
-
useEffect(() => {
|
|
165
|
-
return () => document.removeEventListener("mouseup", handleMouseUp);
|
|
166
|
-
}, [handleMouseUp]);
|
|
131
|
+
const ariaId = useId(id);
|
|
167
132
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
133
|
+
const mergedRef = useMemo(
|
|
134
|
+
() => mergeRefs([ref, floating]),
|
|
135
|
+
[floating, ref]
|
|
171
136
|
);
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
() => mergeRefs([ref, refs.floating]),
|
|
176
|
-
[ref, refs.floating]
|
|
137
|
+
const childMergedRef = useMemo(
|
|
138
|
+
() => mergeRefs([(children as any).ref, reference]),
|
|
139
|
+
[children, reference]
|
|
177
140
|
);
|
|
178
141
|
|
|
179
142
|
if (
|
|
@@ -196,107 +159,77 @@ export const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(
|
|
|
196
159
|
|
|
197
160
|
return (
|
|
198
161
|
<>
|
|
199
|
-
{cloneElement(
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
handleClose
|
|
213
|
-
),
|
|
214
|
-
onMouseDown: composeEventHandlers(children.props.onMouseDown, () => {
|
|
215
|
-
isMouseDownRef.current = true;
|
|
216
|
-
document &&
|
|
217
|
-
document.addEventListener("mouseup", handleMouseUp, {
|
|
218
|
-
once: true,
|
|
219
|
-
});
|
|
220
|
-
}),
|
|
221
|
-
onFocus: composeEventHandlers(
|
|
222
|
-
children.props.onFocus,
|
|
223
|
-
() => !isMouseDownRef.current && handleOpen()
|
|
224
|
-
),
|
|
225
|
-
onBlur: composeEventHandlers(children.props.onBlur, handleClose),
|
|
226
|
-
})}
|
|
227
|
-
{(open ?? isOpen) && (
|
|
228
|
-
<Portal>
|
|
162
|
+
{cloneElement(
|
|
163
|
+
children,
|
|
164
|
+
getReferenceProps({
|
|
165
|
+
...children.props,
|
|
166
|
+
ref: childMergedRef,
|
|
167
|
+
"aria-describedby":
|
|
168
|
+
userOpen ?? open
|
|
169
|
+
? cl(ariaId, children?.props["aria-describedby"])
|
|
170
|
+
: children?.props["aria-describedby"],
|
|
171
|
+
})
|
|
172
|
+
)}
|
|
173
|
+
<FloatingPortal>
|
|
174
|
+
{(userOpen ?? open) && (
|
|
229
175
|
<div
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
176
|
+
{...getFloatingProps({
|
|
177
|
+
...rest,
|
|
178
|
+
ref: mergedRef,
|
|
179
|
+
style: {
|
|
180
|
+
position: strategy,
|
|
181
|
+
top: y ?? 0,
|
|
182
|
+
left: x ?? 0,
|
|
183
|
+
visibility: referenceHidden ? "hidden" : "visible",
|
|
184
|
+
},
|
|
185
|
+
role: "tooltip",
|
|
186
|
+
id: ariaId,
|
|
187
|
+
className: cl(
|
|
188
|
+
"navds-tooltip",
|
|
189
|
+
"navds-detail navds-detail--small",
|
|
190
|
+
className
|
|
191
|
+
),
|
|
192
|
+
})}
|
|
242
193
|
data-side={placement}
|
|
243
|
-
className={cl(
|
|
244
|
-
"navds-tooltip",
|
|
245
|
-
"navds-detail navds-detail--small",
|
|
246
|
-
className
|
|
247
|
-
)}
|
|
248
194
|
>
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
right: "",
|
|
285
|
-
bottom: "",
|
|
286
|
-
|
|
287
|
-
[{
|
|
288
|
-
top: "bottom",
|
|
289
|
-
right: "left",
|
|
290
|
-
bottom: "top",
|
|
291
|
-
left: "right",
|
|
292
|
-
}[placement]]: "-3.5px",
|
|
293
|
-
}}
|
|
294
|
-
/>
|
|
295
|
-
)}
|
|
296
|
-
</div>
|
|
195
|
+
{content}
|
|
196
|
+
{keys && (
|
|
197
|
+
<span className="navds-tooltip__keys">
|
|
198
|
+
{keys.map((key) => (
|
|
199
|
+
<Detail
|
|
200
|
+
size="small"
|
|
201
|
+
as="kbd"
|
|
202
|
+
key={key}
|
|
203
|
+
className="navds-tooltip__key"
|
|
204
|
+
>
|
|
205
|
+
{key}
|
|
206
|
+
</Detail>
|
|
207
|
+
))}
|
|
208
|
+
</span>
|
|
209
|
+
)}
|
|
210
|
+
{_arrow && (
|
|
211
|
+
<div
|
|
212
|
+
ref={(node) => {
|
|
213
|
+
arrowRef.current = node;
|
|
214
|
+
}}
|
|
215
|
+
className="navds-tooltip__arrow"
|
|
216
|
+
style={{
|
|
217
|
+
left: arrowX != null ? `${arrowX}px` : "",
|
|
218
|
+
top: arrowY != null ? `${arrowY}px` : "",
|
|
219
|
+
right: "",
|
|
220
|
+
bottom: "",
|
|
221
|
+
[{
|
|
222
|
+
top: "bottom",
|
|
223
|
+
right: "left",
|
|
224
|
+
bottom: "top",
|
|
225
|
+
left: "right",
|
|
226
|
+
}[placement]]: "-3.5px",
|
|
227
|
+
}}
|
|
228
|
+
/>
|
|
229
|
+
)}
|
|
297
230
|
</div>
|
|
298
|
-
|
|
299
|
-
|
|
231
|
+
)}
|
|
232
|
+
</FloatingPortal>
|
|
300
233
|
</>
|
|
301
234
|
);
|
|
302
235
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Meta } from "@storybook/react/types-6-0";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { Button } from "../..";
|
|
3
|
+
import { Alert, Button, Search } from "../..";
|
|
4
4
|
import { Tooltip } from "../index";
|
|
5
5
|
|
|
6
6
|
export default {
|
|
@@ -29,6 +29,20 @@ export default {
|
|
|
29
29
|
},
|
|
30
30
|
} as Meta;
|
|
31
31
|
|
|
32
|
+
export const Demo = () => (
|
|
33
|
+
<div>
|
|
34
|
+
<Tooltip content="Tooltip example" placement="top">
|
|
35
|
+
<Alert variant="info">test</Alert>
|
|
36
|
+
</Tooltip>
|
|
37
|
+
<Tooltip content="Tooltip example" placement="top">
|
|
38
|
+
<Search label="søk" />
|
|
39
|
+
</Tooltip>
|
|
40
|
+
<Tooltip content="Tooltip example" placement="top">
|
|
41
|
+
<Button aria-describedby="test123">Tooltip</Button>
|
|
42
|
+
</Tooltip>
|
|
43
|
+
</div>
|
|
44
|
+
);
|
|
45
|
+
|
|
32
46
|
export const Default = (props) => {
|
|
33
47
|
return (
|
|
34
48
|
<Tooltip
|
package/src/typography/Label.tsx
CHANGED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/* https://github.com/mui/material-ui/blob/master/packages/mui-base/src/TextareaAutosize/TextareaAutosize.js */
|
|
2
|
+
import React, {
|
|
3
|
+
forwardRef,
|
|
4
|
+
useCallback,
|
|
5
|
+
useEffect,
|
|
6
|
+
useMemo,
|
|
7
|
+
useRef,
|
|
8
|
+
useState,
|
|
9
|
+
} from "react";
|
|
10
|
+
import { debounce, mergeRefs, useClientLayoutEffect } from "..";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* https://github.com/mui/material-ui/blob/master/packages/mui-utils/src/ownerDocument.ts
|
|
14
|
+
* https://github.com/mui/material-ui/blob/master/packages/mui-utils/src/ownerWindow.ts
|
|
15
|
+
*/
|
|
16
|
+
const ownerWindow = (node: Node | null): Window => {
|
|
17
|
+
const doc = (node && node.ownerDocument) || document;
|
|
18
|
+
return doc.defaultView || window;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
function getStyleValue(computedStyle, property) {
|
|
22
|
+
return parseInt(computedStyle[property], 10) || 0;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface TextareaAutosizeProps
|
|
26
|
+
extends Omit<
|
|
27
|
+
React.TextareaHTMLAttributes<HTMLTextAreaElement>,
|
|
28
|
+
"children" | "rows"
|
|
29
|
+
> {
|
|
30
|
+
/**
|
|
31
|
+
* Maximum number of rows to display.
|
|
32
|
+
*/
|
|
33
|
+
maxRows?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Minimum number of rows to display.
|
|
36
|
+
* @default 1
|
|
37
|
+
*/
|
|
38
|
+
minRows?: number;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const TextareaAutosize = forwardRef<HTMLTextAreaElement, TextareaAutosizeProps>(
|
|
42
|
+
(
|
|
43
|
+
{ className, onChange, maxRows, minRows = 1, style, value, ...other },
|
|
44
|
+
ref
|
|
45
|
+
) => {
|
|
46
|
+
const { current: isControlled } = useRef(value != null);
|
|
47
|
+
const inputRef = useRef<HTMLTextAreaElement | null>(null);
|
|
48
|
+
const handleRef = useMemo(() => mergeRefs([inputRef, ref]), [ref]);
|
|
49
|
+
const shadowRef = useRef<HTMLTextAreaElement | null>(null);
|
|
50
|
+
const renders = useRef(0);
|
|
51
|
+
const [state, setState] = useState<any>({});
|
|
52
|
+
|
|
53
|
+
const syncHeight = useCallback(() => {
|
|
54
|
+
if (!inputRef.current || !shadowRef.current) return;
|
|
55
|
+
const input = inputRef.current;
|
|
56
|
+
const containerWindow = ownerWindow(input);
|
|
57
|
+
const computedStyle = containerWindow.getComputedStyle(input);
|
|
58
|
+
|
|
59
|
+
// If input's width is shrunk and it's not visible, don't sync height.
|
|
60
|
+
if (computedStyle.width === "0px") {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const inputShallow = shadowRef.current;
|
|
65
|
+
inputShallow.style.width = computedStyle.width;
|
|
66
|
+
inputShallow.value = input.value || other?.placeholder || "x";
|
|
67
|
+
if (inputShallow.value.slice(-1) === "\n") {
|
|
68
|
+
// Certain fonts which overflow the line height will cause the textarea
|
|
69
|
+
// to report a different scrollHeight depending on whether the last line
|
|
70
|
+
// is empty. Make it non-empty to avoid this issue.
|
|
71
|
+
inputShallow.value += " ";
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const boxSizing = computedStyle["box-sizing"];
|
|
75
|
+
const padding =
|
|
76
|
+
getStyleValue(computedStyle, "padding-bottom") +
|
|
77
|
+
getStyleValue(computedStyle, "padding-top");
|
|
78
|
+
const border =
|
|
79
|
+
getStyleValue(computedStyle, "border-bottom-width") +
|
|
80
|
+
getStyleValue(computedStyle, "border-top-width");
|
|
81
|
+
|
|
82
|
+
// The height of the inner content
|
|
83
|
+
const innerHeight = inputShallow.scrollHeight - padding;
|
|
84
|
+
|
|
85
|
+
// Measure height of a textarea with a single row
|
|
86
|
+
inputShallow.value = "x";
|
|
87
|
+
const singleRowHeight = inputShallow.scrollHeight - padding;
|
|
88
|
+
|
|
89
|
+
// The height of the outer content
|
|
90
|
+
let outerHeight = innerHeight;
|
|
91
|
+
|
|
92
|
+
if (minRows) {
|
|
93
|
+
outerHeight = Math.max(Number(minRows) * singleRowHeight, outerHeight);
|
|
94
|
+
}
|
|
95
|
+
if (maxRows) {
|
|
96
|
+
outerHeight = Math.min(Number(maxRows) * singleRowHeight, outerHeight);
|
|
97
|
+
}
|
|
98
|
+
outerHeight = Math.max(outerHeight, singleRowHeight);
|
|
99
|
+
|
|
100
|
+
// Take the box sizing into account for applying this value as a style.
|
|
101
|
+
const outerHeightStyle =
|
|
102
|
+
outerHeight + (boxSizing === "border-box" ? padding + border : 0);
|
|
103
|
+
const overflow = Math.abs(outerHeight - innerHeight) <= 1;
|
|
104
|
+
|
|
105
|
+
setState((prevState) => {
|
|
106
|
+
// Need a large enough difference to update the height.
|
|
107
|
+
// This prevents infinite rendering loop.
|
|
108
|
+
if (
|
|
109
|
+
renders.current < 20 &&
|
|
110
|
+
((outerHeightStyle > 0 &&
|
|
111
|
+
Math.abs((prevState.outerHeightStyle || 0) - outerHeightStyle) >
|
|
112
|
+
1) ||
|
|
113
|
+
prevState.overflow !== overflow)
|
|
114
|
+
) {
|
|
115
|
+
renders.current += 1;
|
|
116
|
+
return {
|
|
117
|
+
overflow,
|
|
118
|
+
outerHeightStyle,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (process.env.NODE_ENV !== "production") {
|
|
123
|
+
if (renders.current === 20) {
|
|
124
|
+
console.error(
|
|
125
|
+
[
|
|
126
|
+
"MUI: Too many re-renders. The layout is unstable.",
|
|
127
|
+
"TextareaAutosize limits the number of renders to prevent an infinite loop.",
|
|
128
|
+
].join("\n")
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return prevState;
|
|
134
|
+
});
|
|
135
|
+
}, [maxRows, minRows, other?.placeholder]);
|
|
136
|
+
|
|
137
|
+
useEffect(() => {
|
|
138
|
+
const handleResize = debounce(() => {
|
|
139
|
+
renders.current = 0;
|
|
140
|
+
syncHeight();
|
|
141
|
+
});
|
|
142
|
+
const containerWindow = ownerWindow(inputRef.current);
|
|
143
|
+
containerWindow.addEventListener("resize", handleResize);
|
|
144
|
+
let resizeObserver;
|
|
145
|
+
|
|
146
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
147
|
+
resizeObserver = new ResizeObserver(handleResize);
|
|
148
|
+
resizeObserver.observe(inputRef.current);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return () => {
|
|
152
|
+
handleResize.clear();
|
|
153
|
+
containerWindow.removeEventListener("resize", handleResize);
|
|
154
|
+
if (resizeObserver) {
|
|
155
|
+
resizeObserver.disconnect();
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
}, [syncHeight]);
|
|
159
|
+
|
|
160
|
+
useClientLayoutEffect(() => {
|
|
161
|
+
syncHeight();
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
useEffect(() => {
|
|
165
|
+
renders.current = 0;
|
|
166
|
+
}, [value]);
|
|
167
|
+
|
|
168
|
+
const handleChange = (event) => {
|
|
169
|
+
renders.current = 0;
|
|
170
|
+
|
|
171
|
+
if (!isControlled) {
|
|
172
|
+
syncHeight();
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (onChange) {
|
|
176
|
+
onChange(event);
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
return (
|
|
181
|
+
<>
|
|
182
|
+
<textarea
|
|
183
|
+
value={value}
|
|
184
|
+
onChange={handleChange}
|
|
185
|
+
ref={handleRef}
|
|
186
|
+
// Apply the rows prop to get a "correct" first SSR paint
|
|
187
|
+
rows={minRows}
|
|
188
|
+
style={{
|
|
189
|
+
height: state.outerHeightStyle,
|
|
190
|
+
// Need a large enough difference to allow scrolling.
|
|
191
|
+
// This prevents infinite rendering loop.
|
|
192
|
+
...(state.overflow ? { overflow: "hidden" } : {}),
|
|
193
|
+
...style,
|
|
194
|
+
}}
|
|
195
|
+
{...other}
|
|
196
|
+
className={className}
|
|
197
|
+
/>
|
|
198
|
+
<textarea
|
|
199
|
+
aria-hidden
|
|
200
|
+
className={className}
|
|
201
|
+
readOnly
|
|
202
|
+
ref={shadowRef}
|
|
203
|
+
tabIndex={-1}
|
|
204
|
+
style={{
|
|
205
|
+
// Visibility needed to hide the extra text area on iPads
|
|
206
|
+
visibility: "hidden",
|
|
207
|
+
// Remove from the content flow
|
|
208
|
+
position: "absolute",
|
|
209
|
+
// Ignore the scrollbar width
|
|
210
|
+
overflow: "hidden",
|
|
211
|
+
height: 0,
|
|
212
|
+
top: 0,
|
|
213
|
+
left: 0,
|
|
214
|
+
// Create a new layer, increase the isolation of the computed values
|
|
215
|
+
transform: "translateZ(0)",
|
|
216
|
+
...style,
|
|
217
|
+
}}
|
|
218
|
+
/>
|
|
219
|
+
</>
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
export default TextareaAutosize;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// https://github.com/mui/material-ui/blob/master/packages/mui-utils/src/debounce.js
|
|
2
|
+
export default function debounce(func, wait = 166) {
|
|
3
|
+
let timeout;
|
|
4
|
+
function debounced(this: any, ...args) {
|
|
5
|
+
const later = () => {
|
|
6
|
+
func.apply(this, args);
|
|
7
|
+
};
|
|
8
|
+
clearTimeout(timeout);
|
|
9
|
+
timeout = setTimeout(later, wait);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
debounced.clear = () => {
|
|
13
|
+
clearTimeout(timeout);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
return debounced;
|
|
17
|
+
}
|