@digigov/ui 0.21.2 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +39 -1
- package/admin/AutoComplete/AccesibleAutoComplete/index.d.ts +5 -0
- package/admin/AutoComplete/AccesibleAutoComplete/index.js +106 -0
- package/admin/AutoComplete/AutoComplete.stories.d.ts +13 -0
- package/admin/AutoComplete/AutoComplete.stories.js +115 -0
- package/admin/AutoComplete/Status/index.d.ts +40 -0
- package/admin/AutoComplete/Status/index.js +184 -0
- package/{app/CopyToClipboard → admin/AutoComplete}/__stories__/Default.d.ts +0 -0
- package/admin/AutoComplete/__stories__/Default.js +34 -0
- package/admin/AutoComplete/__stories__/WithAutoSelect.d.ts +3 -0
- package/admin/AutoComplete/__stories__/WithAutoSelect.js +35 -0
- package/admin/AutoComplete/__stories__/WithDefaultValue.d.ts +3 -0
- package/admin/AutoComplete/__stories__/WithDefaultValue.js +33 -0
- package/admin/AutoComplete/__stories__/WithInLine.d.ts +3 -0
- package/admin/AutoComplete/__stories__/WithInLine.js +33 -0
- package/admin/AutoComplete/__stories__/WithMinLength.d.ts +3 -0
- package/admin/AutoComplete/__stories__/WithMinLength.js +35 -0
- package/admin/AutoComplete/__stories__/WithPlaceHolder.d.ts +3 -0
- package/admin/AutoComplete/__stories__/WithPlaceHolder.js +33 -0
- package/admin/AutoComplete/__stories__/WithShowAllValues.d.ts +3 -0
- package/admin/AutoComplete/__stories__/WithShowAllValues.js +33 -0
- package/admin/AutoComplete/index.d.ts +101 -0
- package/admin/AutoComplete/index.js +744 -0
- package/admin/AutoComplete/index.mdx +46 -0
- package/admin/AutoComplete/utils.d.ts +1 -0
- package/admin/AutoComplete/utils.js +13 -0
- package/admin/CopyToClipboard/CopyToClipboard.stories.d.ts +9 -0
- package/admin/CopyToClipboard/CopyToClipboard.stories.js +58 -0
- package/admin/CopyToClipboard/__stories__/Banner.d.ts +3 -0
- package/admin/CopyToClipboard/__stories__/Banner.js +30 -0
- package/admin/CopyToClipboard/__stories__/Default.d.ts +3 -0
- package/admin/CopyToClipboard/__stories__/Default.js +32 -0
- package/admin/CopyToClipboard/__stories__/MultipleCopies.d.ts +3 -0
- package/{app/CopyToClipboard/__stories__/Default.js → admin/CopyToClipboard/__stories__/MultipleCopies.js} +20 -18
- package/admin/CopyToClipboard/index.d.ts +1 -1
- package/admin/CopyToClipboard/index.js +3 -2
- package/admin/CopyToClipboard/index.mdx +22 -0
- package/admin/Drawer/__stories__/Default.js +1 -1
- package/admin/Drawer/index.mdx +12 -0
- package/admin/Dropdown/Dropdown.stories.d.ts +9 -0
- package/admin/Dropdown/Dropdown.stories.js +60 -0
- package/admin/Dropdown/__stories__/AlignRight.d.ts +3 -0
- package/admin/Dropdown/__stories__/AlignRight.js +83 -0
- package/admin/Dropdown/__stories__/Default.d.ts +3 -0
- package/admin/Dropdown/__stories__/Default.js +75 -0
- package/admin/Dropdown/__stories__/PlacementTop.d.ts +3 -0
- package/admin/Dropdown/__stories__/PlacementTop.js +83 -0
- package/admin/Dropdown/index.d.ts +7 -1
- package/admin/Dropdown/index.js +29 -1
- package/admin/Dropdown/index.mdx +29 -0
- package/admin/FilterSection/index.d.ts +1 -0
- package/admin/FilterSection/index.js +14 -0
- package/admin/Modal/Modal.stories.d.ts +8 -0
- package/admin/Modal/Modal.stories.js +44 -0
- package/admin/Modal/__stories__/AlertDialog.d.ts +3 -0
- package/admin/Modal/__stories__/AlertDialog.js +80 -0
- package/admin/Modal/__stories__/Default.d.ts +3 -0
- package/admin/Modal/__stories__/Default.js +79 -0
- package/admin/Modal/index.mdx +26 -0
- package/admin/Pagination/__stories__/Default.js +57 -16
- package/admin/Pagination/index.mdx +12 -0
- package/admin/index.d.ts +2 -1
- package/admin/index.js +17 -4
- package/api/fetchAPI.js +6 -4
- package/api/index.spec.js +18 -19
- package/api/useResource.js +6 -4
- package/api/useResourceAction.js +6 -4
- package/api/useResourceQuery.js +7 -4
- package/api/utils.js +8 -6
- package/app/Confirmation/Confirmation.mdx +9 -0
- package/app/Footer/Footer.mdx +27 -0
- package/app/Header/index.mdx +18 -0
- package/app/I18nText.js +7 -7
- package/app/NotFound/index.mdx +12 -0
- package/app/PhaseBannerHeader/index.mdx +12 -0
- package/core/Accordion/__stories__/Default.js +17 -1
- package/core/Accordion/__stories__/WithHints.js +17 -1
- package/core/Accordion/index.mdx +16 -84
- package/core/BackLink/index.mdx +16 -0
- package/core/Blockquote/index.mdx +17 -2
- package/core/Breadcrumbs/__stories__/Default.js +13 -1
- package/core/Breadcrumbs/breadcrumbs.mdx +22 -0
- package/core/Button/Button.stories.d.ts +5 -0
- package/core/Button/Button.stories.js +72 -0
- package/core/Button/__stories__/Back.d.ts +4 -0
- package/core/Button/__stories__/Back.js +26 -0
- package/core/Button/__stories__/ButtonLinkButton.d.ts +6 -0
- package/core/Button/__stories__/ButtonLinkButton.js +30 -0
- package/core/Button/__stories__/CallToActionButton.d.ts +6 -0
- package/core/Button/__stories__/CallToActionButton.js +30 -0
- package/core/Button/__stories__/Disabled.d.ts +6 -0
- package/core/Button/__stories__/Disabled.js +27 -0
- package/core/Button/__stories__/GroupingButtonsAndLinks.js +3 -1
- package/core/Button/__stories__/Primary.js +3 -1
- package/core/Button/__stories__/Secondary.js +3 -2
- package/core/Button/__stories__/Warning.js +2 -1
- package/core/Button/__stories__/WithVariantLink.d.ts +6 -0
- package/core/Button/__stories__/WithVariantLink.js +29 -0
- package/core/Button/index.mdx +97 -0
- package/core/Card/Card.stories.d.ts +1 -0
- package/core/Card/Card.stories.js +14 -0
- package/core/Card/__stories__/WithClickableLink.js +1 -3
- package/core/Card/__stories__/WithGroupButton.d.ts +3 -0
- package/core/Card/__stories__/WithGroupButton.js +32 -0
- package/core/Card/card.mdx +78 -0
- package/core/Checkboxes/Checkbox.stories.d.ts +1 -0
- package/core/Checkboxes/Checkbox.stories.js +14 -0
- package/core/Checkboxes/__stories__/ConditionalReveal.js +5 -1
- package/core/Checkboxes/__stories__/Default.js +5 -1
- package/core/Checkboxes/__stories__/MultipleQuestions.js +6 -2
- package/core/Checkboxes/__stories__/NoneAnswer.js +5 -1
- package/core/Checkboxes/__stories__/NoneAnswerWithError.d.ts +3 -0
- package/core/Checkboxes/__stories__/NoneAnswerWithError.js +57 -0
- package/core/Checkboxes/__stories__/WithErrorMessage.js +7 -1
- package/core/Checkboxes/__stories__/WithHint.js +5 -1
- package/core/Checkboxes/checkboxes.mdx +54 -0
- package/core/Confirmation/confirmation.mdx +19 -0
- package/core/DateInput/DateInput.stories.d.ts +1 -0
- package/core/DateInput/DateInput.stories.js +14 -0
- package/core/DateInput/__stories__/Default.js +3 -1
- package/core/DateInput/__stories__/MultipleQuestions.d.ts +3 -0
- package/core/DateInput/__stories__/MultipleQuestions.js +41 -0
- package/core/DateInput/index.mdx +34 -0
- package/core/Details/index.mdx +9 -25
- package/core/ErrorMessage/__stories__/Default.js +1 -1
- package/core/ErrorMessage/index.mdx +21 -0
- package/core/ErrorSummary/__stories__/LinkedToCheckbox.js +1 -1
- package/core/ErrorSummary/index.mdx +21 -38
- package/core/FileUpload/__stories__/Default.d.ts +1 -0
- package/core/FileUpload/__stories__/Default.js +4 -2
- package/core/FileUpload/index.mdx +22 -0
- package/core/Link/__stories__/DarkBackground.js +4 -2
- package/core/Link/__stories__/DarkBackgroundNoUnderline.js +4 -2
- package/core/Link/__stories__/Default.js +3 -1
- package/core/Link/__stories__/NoUnderline.js +3 -1
- package/core/Link/link.mdx +34 -0
- package/core/List/index.mdx +22 -3
- package/core/Masthead/masthead.mdx +14 -0
- package/core/NavList/NavList.d.ts +1 -14
- package/core/NavList/NavList.js +14 -71
- package/core/NavList/NavList.stories.d.ts +8 -0
- package/core/NavList/NavList.stories.js +44 -0
- package/core/NavList/NavListBase.d.ts +4 -0
- package/core/NavList/NavListBase.js +76 -0
- package/core/NavList/NavListItem.d.ts +1 -0
- package/core/NavList/NavListItem.js +3 -1
- package/core/NavList/NavListItemBase.d.ts +1 -0
- package/core/NavList/NavListItemBase.js +7 -3
- package/core/NavList/NavListSubMenu.d.ts +1 -1
- package/core/NavList/NavListSubMenu.js +2 -2
- package/core/NavList/__stories__/Default.d.ts +3 -0
- package/core/NavList/__stories__/Default.js +69 -0
- package/core/NavList/__stories__/NavHorizontalLayout.d.ts +3 -0
- package/core/NavList/__stories__/NavHorizontalLayout.js +67 -0
- package/core/NavList/index.mdx +22 -1
- package/core/NavList/types.d.ts +14 -0
- package/core/NavList/types.js +5 -0
- package/core/NotificationBanner/index.mdx +13 -60
- package/core/PhaseBanner/PhaseBanner.stories.d.ts +1 -0
- package/core/PhaseBanner/PhaseBanner.stories.js +14 -0
- package/core/PhaseBanner/__stories__/Underlined.d.ts +3 -0
- package/{admin/CopyToClipboardMessage/index.js → core/PhaseBanner/__stories__/Underlined.js} +21 -17
- package/core/PhaseBanner/index.mdx +24 -0
- package/core/Radios/__stories__/ConditionalReveal.js +5 -1
- package/core/Radios/__stories__/Default.js +1 -3
- package/core/Radios/__stories__/Inline.js +5 -1
- package/core/Radios/__stories__/MultipleQuestions.js +7 -3
- package/core/Radios/__stories__/WithErrorMessage.js +7 -1
- package/core/Radios/__stories__/WithHints.js +17 -7
- package/core/Radios/index.mdx +56 -0
- package/core/Select/Select.stories.d.ts +1 -0
- package/core/Select/Select.stories.js +14 -0
- package/core/Select/__stories__/Default.js +2 -2
- package/core/Select/__stories__/DisabledInput.js +3 -1
- package/core/Select/__stories__/WithHint.d.ts +3 -0
- package/core/Select/__stories__/WithHint.js +45 -0
- package/core/Select/index.mdx +42 -0
- package/core/SummaryList/SummaryList.stories.d.ts +2 -2
- package/core/SummaryList/SummaryList.stories.js +8 -8
- package/core/SummaryList/__stories__/Default.js +1 -1
- package/core/SummaryList/__stories__/WithActions.d.ts +3 -0
- package/core/SummaryList/__stories__/{SummaryListWithActions.js → WithActions.js} +10 -12
- package/core/SummaryList/__stories__/WithoutBorders.d.ts +3 -0
- package/core/SummaryList/__stories__/{SummaryListWithoutBorders.js → WithoutBorders.js} +5 -5
- package/core/SummaryList/index.mdx +17 -65
- package/core/Table/Table.stories.d.ts +1 -0
- package/core/Table/Table.stories.js +14 -0
- package/core/Table/TableFloatingScroll.d.ts +3 -0
- package/core/Table/TableFloatingScroll.js +105 -0
- package/core/Table/__stories__/DarkVariant.js +1 -1
- package/core/Table/__stories__/Default.js +1 -1
- package/core/Table/__stories__/NoData.js +3 -1
- package/core/Table/__stories__/TableCaptions.d.ts +3 -0
- package/core/Table/__stories__/TableCaptions.js +30 -0
- package/core/Table/__stories__/WithLoader.js +16 -12
- package/core/Table/index.d.ts +1 -0
- package/core/Table/index.js +13 -0
- package/core/Table/index.mdx +59 -0
- package/core/Tabs/__stories__/Default.d.ts +1 -0
- package/core/Tabs/__stories__/Default.js +6 -2
- package/core/Tabs/index.mdx +10 -2
- package/core/TextArea/index.mdx +50 -0
- package/core/TextInput/index.mdx +59 -0
- package/core/VisuallyHidden/__stories__/Default.js +14 -2
- package/core/VisuallyHidden/index.mdx +17 -0
- package/core/WarningText/index.mdx +10 -35
- package/es/admin/AutoComplete/AccesibleAutoComplete/index.js +87 -0
- package/es/admin/AutoComplete/AutoComplete.stories.js +13 -0
- package/es/admin/AutoComplete/Status/index.js +153 -0
- package/es/admin/AutoComplete/__stories__/Default.js +19 -0
- package/es/admin/AutoComplete/__stories__/WithAutoSelect.js +20 -0
- package/es/admin/AutoComplete/__stories__/WithDefaultValue.js +18 -0
- package/es/admin/AutoComplete/__stories__/WithInLine.js +18 -0
- package/es/admin/AutoComplete/__stories__/WithMinLength.js +19 -0
- package/es/admin/AutoComplete/__stories__/WithPlaceHolder.js +18 -0
- package/es/admin/AutoComplete/__stories__/WithShowAllValues.js +18 -0
- package/es/admin/AutoComplete/index.js +676 -0
- package/es/admin/AutoComplete/index.mdx +46 -0
- package/es/admin/AutoComplete/utils.js +6 -0
- package/es/admin/CopyToClipboard/CopyToClipboard.stories.js +8 -0
- package/es/admin/CopyToClipboard/__stories__/Banner.js +16 -0
- package/es/admin/CopyToClipboard/__stories__/Default.js +18 -0
- package/{esm/app/CopyToClipboard/__stories__/Default.js → es/admin/CopyToClipboard/__stories__/MultipleCopies.js} +10 -8
- package/es/admin/CopyToClipboard/index.js +3 -2
- package/es/admin/CopyToClipboard/index.mdx +22 -0
- package/es/admin/Drawer/__stories__/Default.js +1 -1
- package/es/admin/Drawer/index.mdx +12 -0
- package/es/admin/Dropdown/Dropdown.stories.js +9 -0
- package/es/admin/Dropdown/__stories__/AlignRight.js +56 -0
- package/es/admin/Dropdown/__stories__/Default.js +48 -0
- package/es/admin/Dropdown/__stories__/PlacementTop.js +56 -0
- package/es/admin/Dropdown/index.js +28 -1
- package/es/admin/Dropdown/index.mdx +29 -0
- package/es/admin/FilterSection/index.js +1 -0
- package/es/admin/Modal/Modal.stories.js +7 -0
- package/es/admin/Modal/__stories__/AlertDialog.js +58 -0
- package/es/admin/Modal/__stories__/Default.js +56 -0
- package/es/admin/Modal/index.mdx +26 -0
- package/es/admin/Pagination/__stories__/Default.js +56 -16
- package/es/admin/Pagination/index.mdx +12 -0
- package/es/admin/index.js +3 -2
- package/es/api/fetchAPI.js +6 -3
- package/es/api/index.spec.js +19 -17
- package/es/api/useResource.js +6 -3
- package/es/api/useResourceAction.js +6 -3
- package/es/api/useResourceQuery.js +6 -3
- package/es/api/utils.js +8 -5
- package/es/app/Confirmation/Confirmation.mdx +9 -0
- package/es/app/Footer/Footer.mdx +27 -0
- package/es/app/Header/index.mdx +18 -0
- package/es/app/I18nText.js +7 -6
- package/es/app/NotFound/index.mdx +12 -0
- package/es/app/PhaseBannerHeader/index.mdx +12 -0
- package/es/core/Accordion/__stories__/Default.js +17 -1
- package/es/core/Accordion/__stories__/WithHints.js +17 -1
- package/es/core/Accordion/index.mdx +16 -84
- package/es/core/BackLink/index.mdx +16 -0
- package/es/core/Blockquote/index.mdx +17 -2
- package/es/core/Breadcrumbs/__stories__/Default.js +13 -1
- package/es/core/Breadcrumbs/breadcrumbs.mdx +22 -0
- package/es/core/Button/Button.stories.js +7 -1
- package/es/core/Button/__stories__/Back.js +13 -0
- package/es/core/Button/__stories__/ButtonLinkButton.js +17 -0
- package/es/core/Button/__stories__/CallToActionButton.js +17 -0
- package/es/core/Button/__stories__/Disabled.js +14 -0
- package/es/core/Button/__stories__/GroupingButtonsAndLinks.js +3 -1
- package/es/core/Button/__stories__/Primary.js +3 -1
- package/es/core/Button/__stories__/Secondary.js +3 -2
- package/es/core/Button/__stories__/Warning.js +2 -1
- package/es/core/Button/__stories__/WithVariantLink.js +16 -0
- package/es/core/Button/index.mdx +97 -0
- package/es/core/Card/Card.stories.js +2 -1
- package/es/core/Card/__stories__/WithClickableLink.js +2 -3
- package/es/core/Card/__stories__/WithGroupButton.js +11 -0
- package/es/core/Card/card.mdx +78 -0
- package/es/core/Checkboxes/Checkbox.stories.js +1 -0
- package/es/core/Checkboxes/__stories__/ConditionalReveal.js +5 -1
- package/es/core/Checkboxes/__stories__/Default.js +5 -1
- package/es/core/Checkboxes/__stories__/MultipleQuestions.js +6 -2
- package/es/core/Checkboxes/__stories__/NoneAnswer.js +5 -1
- package/es/core/Checkboxes/__stories__/NoneAnswerWithError.js +34 -0
- package/es/core/Checkboxes/__stories__/WithErrorMessage.js +7 -1
- package/es/core/Checkboxes/__stories__/WithHint.js +5 -1
- package/es/core/Checkboxes/checkboxes.mdx +54 -0
- package/es/core/Confirmation/confirmation.mdx +19 -0
- package/es/core/DateInput/DateInput.stories.js +1 -0
- package/es/core/DateInput/__stories__/Default.js +3 -1
- package/es/core/DateInput/__stories__/MultipleQuestions.js +20 -0
- package/es/core/DateInput/index.mdx +34 -0
- package/es/core/Details/index.mdx +9 -25
- package/es/core/ErrorMessage/__stories__/Default.js +1 -1
- package/es/core/ErrorMessage/index.mdx +21 -0
- package/es/core/ErrorSummary/__stories__/LinkedToCheckbox.js +1 -1
- package/es/core/ErrorSummary/index.mdx +21 -38
- package/es/core/FileUpload/__stories__/Default.js +2 -1
- package/es/core/FileUpload/index.mdx +22 -0
- package/es/core/Link/__stories__/DarkBackground.js +7 -5
- package/es/core/Link/__stories__/DarkBackgroundNoUnderline.js +7 -5
- package/es/core/Link/__stories__/Default.js +5 -3
- package/es/core/Link/__stories__/NoUnderline.js +5 -3
- package/es/core/Link/link.mdx +34 -0
- package/es/core/List/index.mdx +22 -3
- package/es/core/Masthead/masthead.mdx +14 -0
- package/es/core/NavList/NavList.js +11 -64
- package/es/core/NavList/NavList.stories.js +7 -0
- package/es/core/NavList/NavListBase.js +60 -0
- package/es/core/NavList/NavListItem.js +3 -1
- package/es/core/NavList/NavListItemBase.js +7 -3
- package/es/core/NavList/NavListSubMenu.js +1 -1
- package/es/core/NavList/__stories__/Default.js +48 -0
- package/es/core/NavList/__stories__/NavHorizontalLayout.js +46 -0
- package/es/core/NavList/index.mdx +22 -1
- package/es/core/NavList/types.js +1 -0
- package/es/core/NotificationBanner/index.mdx +13 -60
- package/es/core/PhaseBanner/PhaseBanner.stories.js +2 -1
- package/es/core/PhaseBanner/__stories__/Underlined.js +14 -0
- package/es/core/PhaseBanner/index.mdx +24 -0
- package/es/core/Radios/__stories__/ConditionalReveal.js +5 -1
- package/es/core/Radios/__stories__/Default.js +1 -2
- package/es/core/Radios/__stories__/Inline.js +5 -1
- package/es/core/Radios/__stories__/MultipleQuestions.js +7 -3
- package/es/core/Radios/__stories__/WithErrorMessage.js +7 -1
- package/es/core/Radios/__stories__/WithHints.js +17 -7
- package/es/core/Radios/index.mdx +56 -0
- package/es/core/Select/Select.stories.js +2 -1
- package/es/core/Select/__stories__/Default.js +5 -4
- package/es/core/Select/__stories__/DisabledInput.js +5 -3
- package/es/core/Select/__stories__/WithHint.js +23 -0
- package/es/core/Select/index.mdx +42 -0
- package/es/core/SummaryList/SummaryList.stories.js +2 -2
- package/es/core/SummaryList/__stories__/Default.js +1 -1
- package/es/core/SummaryList/__stories__/WithActions.js +20 -0
- package/es/core/SummaryList/__stories__/WithoutBorders.js +11 -0
- package/es/core/SummaryList/index.mdx +17 -65
- package/es/core/Table/Table.stories.js +1 -0
- package/es/core/Table/TableFloatingScroll.js +85 -0
- package/es/core/Table/__stories__/DarkVariant.js +1 -1
- package/es/core/Table/__stories__/Default.js +1 -1
- package/es/core/Table/__stories__/NoData.js +3 -1
- package/es/core/Table/__stories__/TableCaptions.js +17 -0
- package/es/core/Table/__stories__/WithLoader.js +12 -10
- package/es/core/Table/index.js +2 -1
- package/es/core/Table/index.mdx +59 -0
- package/es/core/Tabs/__stories__/Default.js +3 -2
- package/es/core/Tabs/index.mdx +10 -2
- package/es/core/TextArea/index.mdx +50 -0
- package/es/core/TextInput/index.mdx +59 -0
- package/es/core/VisuallyHidden/__stories__/Default.js +9 -5
- package/es/core/VisuallyHidden/index.mdx +17 -0
- package/es/core/WarningText/index.mdx +10 -35
- package/es/govgr/Footer/index.mdx +4 -4
- package/es/introduction.md +4 -1
- package/es/layouts/Basic/Content/index.mdx +0 -12
- package/es/layouts/Basic/Main/index.mdx +0 -10
- package/es/layouts/Basic/Masthead/index.mdx +0 -12
- package/es/layouts/Basic/Side/index.mdx +0 -12
- package/es/layouts/Basic/Top/index.mdx +0 -12
- package/es/layouts/Basic/index.mdx +1 -15
- package/es/layouts/Grid/Grid.stories.js +2 -1
- package/es/layouts/Grid/__stories__/Default.js +26 -6
- package/es/layouts/Grid/__stories__/Inline.js +75 -0
- package/es/layouts/Grid/index.js +1 -0
- package/es/layouts/index.js +2 -0
- package/es/registry.js +66 -30
- package/es/test-utils/delay.js +6 -3
- package/es/typography/Caption/index.mdx +16 -0
- package/es/typography/Hint/index.mdx +16 -0
- package/es/typography/NormalText/index.mdx +26 -0
- package/es/typography/Paragraph/index.mdx +30 -0
- package/es/typography/Title/index.mdx +12 -0
- package/esm/admin/AutoComplete/AccesibleAutoComplete/index.js +87 -0
- package/esm/admin/AutoComplete/AutoComplete.stories.js +13 -0
- package/esm/admin/AutoComplete/Status/index.js +153 -0
- package/esm/admin/AutoComplete/__stories__/Default.js +19 -0
- package/esm/admin/AutoComplete/__stories__/WithAutoSelect.js +20 -0
- package/esm/admin/AutoComplete/__stories__/WithDefaultValue.js +18 -0
- package/esm/admin/AutoComplete/__stories__/WithInLine.js +18 -0
- package/esm/admin/AutoComplete/__stories__/WithMinLength.js +19 -0
- package/esm/admin/AutoComplete/__stories__/WithPlaceHolder.js +18 -0
- package/esm/admin/AutoComplete/__stories__/WithShowAllValues.js +18 -0
- package/esm/admin/AutoComplete/index.js +676 -0
- package/esm/admin/AutoComplete/index.mdx +46 -0
- package/esm/admin/AutoComplete/utils.js +6 -0
- package/esm/admin/CopyToClipboard/CopyToClipboard.stories.js +8 -0
- package/esm/admin/CopyToClipboard/__stories__/Banner.js +16 -0
- package/esm/admin/CopyToClipboard/__stories__/Default.js +18 -0
- package/{es/app/CopyToClipboard/__stories__/Default.js → esm/admin/CopyToClipboard/__stories__/MultipleCopies.js} +10 -8
- package/esm/admin/CopyToClipboard/index.js +3 -2
- package/esm/admin/CopyToClipboard/index.mdx +22 -0
- package/esm/admin/Drawer/__stories__/Default.js +1 -1
- package/esm/admin/Drawer/index.mdx +12 -0
- package/esm/admin/Dropdown/Dropdown.stories.js +9 -0
- package/esm/admin/Dropdown/__stories__/AlignRight.js +56 -0
- package/esm/admin/Dropdown/__stories__/Default.js +48 -0
- package/esm/admin/Dropdown/__stories__/PlacementTop.js +56 -0
- package/esm/admin/Dropdown/index.js +28 -1
- package/esm/admin/Dropdown/index.mdx +29 -0
- package/esm/admin/FilterSection/index.js +1 -0
- package/esm/admin/Modal/Modal.stories.js +7 -0
- package/esm/admin/Modal/__stories__/AlertDialog.js +58 -0
- package/esm/admin/Modal/__stories__/Default.js +56 -0
- package/esm/admin/Modal/index.mdx +26 -0
- package/esm/admin/Pagination/__stories__/Default.js +56 -16
- package/esm/admin/Pagination/index.mdx +12 -0
- package/esm/admin/index.js +3 -2
- package/esm/api/fetchAPI.js +6 -3
- package/esm/api/index.spec.js +19 -17
- package/esm/api/useResource.js +6 -3
- package/esm/api/useResourceAction.js +6 -3
- package/esm/api/useResourceQuery.js +6 -3
- package/esm/api/utils.js +8 -5
- package/esm/app/Confirmation/Confirmation.mdx +9 -0
- package/esm/app/Footer/Footer.mdx +27 -0
- package/esm/app/Header/index.mdx +18 -0
- package/esm/app/I18nText.js +7 -6
- package/esm/app/NotFound/index.mdx +12 -0
- package/esm/app/PhaseBannerHeader/index.mdx +12 -0
- package/esm/core/Accordion/__stories__/Default.js +17 -1
- package/esm/core/Accordion/__stories__/WithHints.js +17 -1
- package/esm/core/Accordion/index.mdx +16 -84
- package/esm/core/BackLink/index.mdx +16 -0
- package/esm/core/Blockquote/index.mdx +17 -2
- package/esm/core/Breadcrumbs/__stories__/Default.js +13 -1
- package/esm/core/Breadcrumbs/breadcrumbs.mdx +22 -0
- package/esm/core/Button/Button.stories.js +7 -1
- package/esm/core/Button/__stories__/Back.js +13 -0
- package/esm/core/Button/__stories__/ButtonLinkButton.js +17 -0
- package/esm/core/Button/__stories__/CallToActionButton.js +17 -0
- package/esm/core/Button/__stories__/Disabled.js +14 -0
- package/esm/core/Button/__stories__/GroupingButtonsAndLinks.js +3 -1
- package/esm/core/Button/__stories__/Primary.js +3 -1
- package/esm/core/Button/__stories__/Secondary.js +3 -2
- package/esm/core/Button/__stories__/Warning.js +2 -1
- package/esm/core/Button/__stories__/WithVariantLink.js +16 -0
- package/esm/core/Button/index.mdx +97 -0
- package/esm/core/Card/Card.stories.js +2 -1
- package/esm/core/Card/__stories__/WithClickableLink.js +2 -3
- package/esm/core/Card/__stories__/WithGroupButton.js +11 -0
- package/esm/core/Card/card.mdx +78 -0
- package/esm/core/Checkboxes/Checkbox.stories.js +1 -0
- package/esm/core/Checkboxes/__stories__/ConditionalReveal.js +5 -1
- package/esm/core/Checkboxes/__stories__/Default.js +5 -1
- package/esm/core/Checkboxes/__stories__/MultipleQuestions.js +6 -2
- package/esm/core/Checkboxes/__stories__/NoneAnswer.js +5 -1
- package/esm/core/Checkboxes/__stories__/NoneAnswerWithError.js +34 -0
- package/esm/core/Checkboxes/__stories__/WithErrorMessage.js +7 -1
- package/esm/core/Checkboxes/__stories__/WithHint.js +5 -1
- package/esm/core/Checkboxes/checkboxes.mdx +54 -0
- package/esm/core/Confirmation/confirmation.mdx +19 -0
- package/esm/core/DateInput/DateInput.stories.js +1 -0
- package/esm/core/DateInput/__stories__/Default.js +3 -1
- package/esm/core/DateInput/__stories__/MultipleQuestions.js +20 -0
- package/esm/core/DateInput/index.mdx +34 -0
- package/esm/core/Details/index.mdx +9 -25
- package/esm/core/ErrorMessage/__stories__/Default.js +1 -1
- package/esm/core/ErrorMessage/index.mdx +21 -0
- package/esm/core/ErrorSummary/__stories__/LinkedToCheckbox.js +1 -1
- package/esm/core/ErrorSummary/index.mdx +21 -38
- package/esm/core/FileUpload/__stories__/Default.js +2 -1
- package/esm/core/FileUpload/index.mdx +22 -0
- package/esm/core/Link/__stories__/DarkBackground.js +7 -5
- package/esm/core/Link/__stories__/DarkBackgroundNoUnderline.js +7 -5
- package/esm/core/Link/__stories__/Default.js +5 -3
- package/esm/core/Link/__stories__/NoUnderline.js +5 -3
- package/esm/core/Link/link.mdx +34 -0
- package/esm/core/List/index.mdx +22 -3
- package/esm/core/Masthead/masthead.mdx +14 -0
- package/esm/core/NavList/NavList.js +11 -64
- package/esm/core/NavList/NavList.stories.js +7 -0
- package/esm/core/NavList/NavListBase.js +60 -0
- package/esm/core/NavList/NavListItem.js +3 -1
- package/esm/core/NavList/NavListItemBase.js +7 -3
- package/esm/core/NavList/NavListSubMenu.js +1 -1
- package/esm/core/NavList/__stories__/Default.js +48 -0
- package/esm/core/NavList/__stories__/NavHorizontalLayout.js +46 -0
- package/esm/core/NavList/index.mdx +22 -1
- package/esm/core/NavList/types.js +1 -0
- package/esm/core/NotificationBanner/index.mdx +13 -60
- package/esm/core/PhaseBanner/PhaseBanner.stories.js +2 -1
- package/esm/core/PhaseBanner/__stories__/Underlined.js +14 -0
- package/esm/core/PhaseBanner/index.mdx +24 -0
- package/esm/core/Radios/__stories__/ConditionalReveal.js +5 -1
- package/esm/core/Radios/__stories__/Default.js +1 -2
- package/esm/core/Radios/__stories__/Inline.js +5 -1
- package/esm/core/Radios/__stories__/MultipleQuestions.js +7 -3
- package/esm/core/Radios/__stories__/WithErrorMessage.js +7 -1
- package/esm/core/Radios/__stories__/WithHints.js +17 -7
- package/esm/core/Radios/index.mdx +56 -0
- package/esm/core/Select/Select.stories.js +2 -1
- package/esm/core/Select/__stories__/Default.js +5 -4
- package/esm/core/Select/__stories__/DisabledInput.js +5 -3
- package/esm/core/Select/__stories__/WithHint.js +23 -0
- package/esm/core/Select/index.mdx +42 -0
- package/esm/core/SummaryList/SummaryList.stories.js +2 -2
- package/esm/core/SummaryList/__stories__/Default.js +1 -1
- package/esm/core/SummaryList/__stories__/WithActions.js +20 -0
- package/esm/core/SummaryList/__stories__/WithoutBorders.js +11 -0
- package/esm/core/SummaryList/index.mdx +17 -65
- package/esm/core/Table/Table.stories.js +1 -0
- package/esm/core/Table/TableFloatingScroll.js +85 -0
- package/esm/core/Table/__stories__/DarkVariant.js +1 -1
- package/esm/core/Table/__stories__/Default.js +1 -1
- package/esm/core/Table/__stories__/NoData.js +3 -1
- package/esm/core/Table/__stories__/TableCaptions.js +17 -0
- package/esm/core/Table/__stories__/WithLoader.js +12 -10
- package/esm/core/Table/index.js +2 -1
- package/esm/core/Table/index.mdx +59 -0
- package/esm/core/Tabs/__stories__/Default.js +3 -2
- package/esm/core/Tabs/index.mdx +10 -2
- package/esm/core/TextArea/index.mdx +50 -0
- package/esm/core/TextInput/index.mdx +59 -0
- package/esm/core/VisuallyHidden/__stories__/Default.js +9 -5
- package/esm/core/VisuallyHidden/index.mdx +17 -0
- package/esm/core/WarningText/index.mdx +10 -35
- package/esm/govgr/Footer/index.mdx +4 -4
- package/esm/index.js +1 -1
- package/esm/introduction.md +4 -1
- package/esm/layouts/Basic/Content/index.mdx +0 -12
- package/esm/layouts/Basic/Main/index.mdx +0 -10
- package/esm/layouts/Basic/Masthead/index.mdx +0 -12
- package/esm/layouts/Basic/Side/index.mdx +0 -12
- package/esm/layouts/Basic/Top/index.mdx +0 -12
- package/esm/layouts/Basic/index.mdx +1 -15
- package/esm/layouts/Grid/Grid.stories.js +2 -1
- package/esm/layouts/Grid/__stories__/Default.js +26 -6
- package/esm/layouts/Grid/__stories__/Inline.js +75 -0
- package/esm/layouts/Grid/index.js +1 -0
- package/esm/layouts/index.js +2 -0
- package/esm/registry.js +66 -30
- package/esm/test-utils/delay.js +6 -3
- package/esm/typography/Caption/index.mdx +16 -0
- package/esm/typography/Hint/index.mdx +16 -0
- package/esm/typography/NormalText/index.mdx +26 -0
- package/esm/typography/Paragraph/index.mdx +30 -0
- package/esm/typography/Title/index.mdx +12 -0
- package/govgr/Footer/index.mdx +4 -4
- package/introduction.md +4 -1
- package/layouts/Basic/Content/index.mdx +0 -12
- package/layouts/Basic/Main/index.mdx +0 -10
- package/layouts/Basic/Masthead/index.mdx +0 -12
- package/layouts/Basic/Side/index.mdx +0 -12
- package/layouts/Basic/Top/index.mdx +0 -12
- package/layouts/Basic/index.mdx +1 -15
- package/layouts/Grid/Grid.stories.d.ts +1 -0
- package/layouts/Grid/Grid.stories.js +14 -0
- package/layouts/Grid/__stories__/Default.js +26 -6
- package/layouts/Grid/__stories__/Inline.d.ts +3 -0
- package/layouts/Grid/__stories__/Inline.js +88 -0
- package/layouts/Grid/index.d.ts +1 -0
- package/layouts/Grid/index.js +6 -0
- package/layouts/index.d.ts +2 -0
- package/layouts/index.js +22 -1
- package/package.json +3 -3
- package/registry.d.ts +33 -15
- package/registry.js +99 -45
- package/test-utils/delay.js +5 -3
- package/typography/Caption/index.mdx +16 -0
- package/typography/Hint/index.mdx +16 -0
- package/typography/NormalText/index.mdx +26 -0
- package/typography/Paragraph/index.mdx +30 -0
- package/typography/Title/index.mdx +12 -0
- package/admin/CopyToClipboardMessage/index.d.ts +0 -3
- package/app/CopyToClipboard/CopyToClipboard.stories.d.ts +0 -7
- package/app/CopyToClipboard/CopyToClipboard.stories.js +0 -30
- package/app/CopyToClipboard/index.d.ts +0 -9
- package/app/CopyToClipboard/index.js +0 -69
- package/app/NotFound/NotFound.mdx +0 -5
- package/app/QrCodeScanner/index.mdx +0 -7
- package/core/Button/Button.mdx +0 -55
- package/core/SummaryList/__stories__/SummaryListWithActions.d.ts +0 -3
- package/core/SummaryList/__stories__/SummaryListWithoutBorders.d.ts +0 -3
- package/es/admin/CopyToClipboardMessage/index.js +0 -3
- package/es/app/CopyToClipboard/CopyToClipboard.stories.js +0 -6
- package/es/app/CopyToClipboard/index.js +0 -45
- package/es/app/NotFound/NotFound.mdx +0 -5
- package/es/app/QrCodeScanner/index.mdx +0 -7
- package/es/core/Button/Button.mdx +0 -55
- package/es/core/SummaryList/__stories__/SummaryListWithActions.js +0 -21
- package/es/core/SummaryList/__stories__/SummaryListWithoutBorders.js +0 -11
- package/esm/admin/CopyToClipboardMessage/index.js +0 -3
- package/esm/app/CopyToClipboard/CopyToClipboard.stories.js +0 -6
- package/esm/app/CopyToClipboard/index.js +0 -45
- package/esm/app/NotFound/NotFound.mdx +0 -5
- package/esm/app/QrCodeScanner/index.mdx +0 -7
- package/esm/core/Button/Button.mdx +0 -55
- package/esm/core/SummaryList/__stories__/SummaryListWithActions.js +0 -21
- package/esm/core/SummaryList/__stories__/SummaryListWithoutBorders.js +0 -11
|
@@ -0,0 +1,744 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
Object.defineProperty(exports, "AutoCompleteAssistiveHint", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function get() {
|
|
13
|
+
return _AutoCompleteAssistiveHint["default"];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
Object.defineProperty(exports, "AutoCompleteInput", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function get() {
|
|
19
|
+
return _AutoCompleteInput["default"];
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
Object.defineProperty(exports, "AutoCompleteInputTypeahead", {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function get() {
|
|
25
|
+
return _AutoCompleteInputTypeahead["default"];
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports, "AutoCompleteNoResult", {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
get: function get() {
|
|
31
|
+
return _AutoCompleteNoResult["default"];
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
Object.defineProperty(exports, "AutoCompleteResultList", {
|
|
35
|
+
enumerable: true,
|
|
36
|
+
get: function get() {
|
|
37
|
+
return _AutoCompleteResultList["default"];
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
Object.defineProperty(exports, "AutoCompleteResultListItem", {
|
|
41
|
+
enumerable: true,
|
|
42
|
+
get: function get() {
|
|
43
|
+
return _AutoCompleteResultListItem["default"];
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
Object.defineProperty(exports, "AutoCompleteWrapper", {
|
|
47
|
+
enumerable: true,
|
|
48
|
+
get: function get() {
|
|
49
|
+
return _AutoCompleteWrapper["default"];
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
exports["default"] = void 0;
|
|
53
|
+
|
|
54
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
55
|
+
|
|
56
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
57
|
+
|
|
58
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
59
|
+
|
|
60
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
61
|
+
|
|
62
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
63
|
+
|
|
64
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
65
|
+
|
|
66
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
67
|
+
|
|
68
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
69
|
+
|
|
70
|
+
var _AutoCompleteInput = _interopRequireDefault(require("@digigov/react-extensions/admin/AutoCompleteInput"));
|
|
71
|
+
|
|
72
|
+
var _AutoCompleteInputTypeahead = _interopRequireDefault(require("@digigov/react-extensions/admin/AutoCompleteInputTypeahead"));
|
|
73
|
+
|
|
74
|
+
var _AutoCompleteNoResult = _interopRequireDefault(require("@digigov/react-extensions/admin/AutoCompleteNoResult"));
|
|
75
|
+
|
|
76
|
+
var _AutoCompleteResultList = _interopRequireDefault(require("@digigov/react-extensions/admin/AutoCompleteResultList"));
|
|
77
|
+
|
|
78
|
+
var _AutoCompleteResultListItem = _interopRequireDefault(require("@digigov/react-extensions/admin/AutoCompleteResultListItem"));
|
|
79
|
+
|
|
80
|
+
var _AutoCompleteWrapper = _interopRequireDefault(require("@digigov/react-extensions/admin/AutoCompleteWrapper"));
|
|
81
|
+
|
|
82
|
+
var _AutoCompleteAssistiveHint = _interopRequireDefault(require("@digigov/react-extensions/admin/AutoCompleteAssistiveHint"));
|
|
83
|
+
|
|
84
|
+
var _Status = _interopRequireDefault(require("@digigov/ui/admin/AutoComplete/Status"));
|
|
85
|
+
|
|
86
|
+
var _DropdownArrowDown = _interopRequireDefault(require("@digigov/react-extensions/admin/DropdownArrowDown"));
|
|
87
|
+
|
|
88
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
89
|
+
|
|
90
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
91
|
+
|
|
92
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
93
|
+
|
|
94
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
95
|
+
|
|
96
|
+
/* const IS_PREACT = process.env.COMPONENT_LIBRARY === 'PREACT'; */
|
|
97
|
+
|
|
98
|
+
/* const IS_REACT = process.env.COMPONENT_LIBRARY === 'REACT'; */
|
|
99
|
+
var keyCodes = {
|
|
100
|
+
13: 'enter',
|
|
101
|
+
27: 'escape',
|
|
102
|
+
32: 'space',
|
|
103
|
+
38: 'up',
|
|
104
|
+
40: 'down'
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
function isIosDevice() {
|
|
108
|
+
return typeof navigator !== 'undefined' && !!(navigator.userAgent.match(/(iPod|iPhone|iPad)/g) && navigator.userAgent.match(/AppleWebKit/g));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function isPrintableKeyCode(keyCode) {
|
|
112
|
+
return keyCode > 47 && keyCode < 58 || // number keys
|
|
113
|
+
keyCode === 32 || keyCode === 8 || // spacebar or backspace
|
|
114
|
+
keyCode > 64 && keyCode < 91 || // letter keys
|
|
115
|
+
keyCode > 95 && keyCode < 112 || // numpad keys
|
|
116
|
+
keyCode > 185 && keyCode < 193 || // ;=,-./` (in order)
|
|
117
|
+
keyCode > 218 && keyCode < 223 // [\]' (in order)
|
|
118
|
+
;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
var AutoComplete = /*#__PURE__*/function (_Component) {
|
|
122
|
+
(0, _inherits2["default"])(AutoComplete, _Component);
|
|
123
|
+
|
|
124
|
+
var _super = _createSuper(AutoComplete);
|
|
125
|
+
|
|
126
|
+
function AutoComplete(props) {
|
|
127
|
+
var _this;
|
|
128
|
+
|
|
129
|
+
(0, _classCallCheck2["default"])(this, AutoComplete);
|
|
130
|
+
_this = _super.call(this, props);
|
|
131
|
+
_this.elementReferences = {};
|
|
132
|
+
_this.$pollInput = void 0;
|
|
133
|
+
_this.state = {
|
|
134
|
+
focused: null,
|
|
135
|
+
hovered: null,
|
|
136
|
+
menuOpen: false,
|
|
137
|
+
options: props.defaultValue ? [props.defaultValue] : [],
|
|
138
|
+
query: props.defaultValue,
|
|
139
|
+
validChoiceMade: false,
|
|
140
|
+
selected: null,
|
|
141
|
+
ariaHint: true
|
|
142
|
+
};
|
|
143
|
+
_this.handleComponentBlur = _this.handleComponentBlur.bind((0, _assertThisInitialized2["default"])(_this));
|
|
144
|
+
_this.handleKeyDown = _this.handleKeyDown.bind((0, _assertThisInitialized2["default"])(_this));
|
|
145
|
+
_this.handleUpArrow = _this.handleUpArrow.bind((0, _assertThisInitialized2["default"])(_this));
|
|
146
|
+
_this.handleDownArrow = _this.handleDownArrow.bind((0, _assertThisInitialized2["default"])(_this));
|
|
147
|
+
_this.handleEnter = _this.handleEnter.bind((0, _assertThisInitialized2["default"])(_this));
|
|
148
|
+
_this.handlePrintableKey = _this.handlePrintableKey.bind((0, _assertThisInitialized2["default"])(_this));
|
|
149
|
+
_this.handleListMouseLeave = _this.handleListMouseLeave.bind((0, _assertThisInitialized2["default"])(_this));
|
|
150
|
+
_this.handleOptionBlur = _this.handleOptionBlur.bind((0, _assertThisInitialized2["default"])(_this));
|
|
151
|
+
_this.handleOptionClick = _this.handleOptionClick.bind((0, _assertThisInitialized2["default"])(_this));
|
|
152
|
+
_this.handleOptionFocus = _this.handleOptionFocus.bind((0, _assertThisInitialized2["default"])(_this));
|
|
153
|
+
_this.handleOptionMouseDown = _this.handleOptionMouseDown.bind((0, _assertThisInitialized2["default"])(_this));
|
|
154
|
+
_this.handleOptionMouseEnter = _this.handleOptionMouseEnter.bind((0, _assertThisInitialized2["default"])(_this));
|
|
155
|
+
_this.handleInputBlur = _this.handleInputBlur.bind((0, _assertThisInitialized2["default"])(_this));
|
|
156
|
+
_this.handleInputChange = _this.handleInputChange.bind((0, _assertThisInitialized2["default"])(_this));
|
|
157
|
+
_this.handleInputFocus = _this.handleInputFocus.bind((0, _assertThisInitialized2["default"])(_this));
|
|
158
|
+
_this.pollInputElement = _this.pollInputElement.bind((0, _assertThisInitialized2["default"])(_this));
|
|
159
|
+
_this.getDirectInputChanges = _this.getDirectInputChanges.bind((0, _assertThisInitialized2["default"])(_this));
|
|
160
|
+
return _this;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
(0, _createClass2["default"])(AutoComplete, [{
|
|
164
|
+
key: "isQueryAnOption",
|
|
165
|
+
value: function isQueryAnOption(query, options) {
|
|
166
|
+
var _this2 = this;
|
|
167
|
+
|
|
168
|
+
return options.map(function (entry) {
|
|
169
|
+
return _this2.templateInputValue(entry).toLowerCase();
|
|
170
|
+
}).indexOf(query.toLowerCase()) !== -1;
|
|
171
|
+
}
|
|
172
|
+
}, {
|
|
173
|
+
key: "componentDidMount",
|
|
174
|
+
value: function componentDidMount() {
|
|
175
|
+
this.pollInputElement();
|
|
176
|
+
}
|
|
177
|
+
}, {
|
|
178
|
+
key: "componentWillUnmount",
|
|
179
|
+
value: function componentWillUnmount() {
|
|
180
|
+
clearTimeout(this.$pollInput);
|
|
181
|
+
} // Applications like Dragon NaturallySpeaking will modify the
|
|
182
|
+
// `input` field by directly changing its `.value`. These events
|
|
183
|
+
// don't trigger our JavaScript event listeners, so we need to poll
|
|
184
|
+
// to handle when and if they occur.
|
|
185
|
+
|
|
186
|
+
}, {
|
|
187
|
+
key: "pollInputElement",
|
|
188
|
+
value: function pollInputElement() {
|
|
189
|
+
var _this3 = this;
|
|
190
|
+
|
|
191
|
+
this.getDirectInputChanges();
|
|
192
|
+
this.$pollInput = setTimeout(function () {
|
|
193
|
+
_this3.pollInputElement();
|
|
194
|
+
}, 100);
|
|
195
|
+
}
|
|
196
|
+
}, {
|
|
197
|
+
key: "getDirectInputChanges",
|
|
198
|
+
value: function getDirectInputChanges() {
|
|
199
|
+
var inputReference = this.elementReferences[-1];
|
|
200
|
+
var queryHasChanged = inputReference && inputReference.value !== this.state.query;
|
|
201
|
+
|
|
202
|
+
if (queryHasChanged) {
|
|
203
|
+
this.handleInputChange({
|
|
204
|
+
target: {
|
|
205
|
+
value: inputReference.value
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}, {
|
|
211
|
+
key: "componentDidUpdate",
|
|
212
|
+
value: function componentDidUpdate(prevState) {
|
|
213
|
+
var focused = this.state.focused;
|
|
214
|
+
var componentLostFocus = focused === null;
|
|
215
|
+
var focusedChanged = prevState.focused !== focused;
|
|
216
|
+
var focusDifferentElement = focusedChanged && !componentLostFocus;
|
|
217
|
+
|
|
218
|
+
if (focusDifferentElement) {
|
|
219
|
+
this.elementReferences[focused].focus();
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
var focusedInput = focused === -1;
|
|
223
|
+
var componentGainedFocus = focusedChanged && prevState.focused === null;
|
|
224
|
+
var selectAllText = focusedInput && componentGainedFocus;
|
|
225
|
+
|
|
226
|
+
if (selectAllText) {
|
|
227
|
+
var inputElement = this.elementReferences[focused];
|
|
228
|
+
inputElement.setSelectionRange(0, inputElement.value.length);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}, {
|
|
232
|
+
key: "hasAutoselect",
|
|
233
|
+
value: function hasAutoselect() {
|
|
234
|
+
return isIosDevice() ? false : this.props.autoselect;
|
|
235
|
+
} // This template is used when converting from a state.options object into a state.query.
|
|
236
|
+
|
|
237
|
+
}, {
|
|
238
|
+
key: "templateInputValue",
|
|
239
|
+
value: function templateInputValue(value) {
|
|
240
|
+
var inputValueTemplate = this.props.templates && this.props.templates.inputValue;
|
|
241
|
+
return inputValueTemplate ? inputValueTemplate(value) : value;
|
|
242
|
+
} // This template is used when displaying results / suggestions.
|
|
243
|
+
|
|
244
|
+
}, {
|
|
245
|
+
key: "templateSuggestion",
|
|
246
|
+
value: function templateSuggestion(value) {
|
|
247
|
+
var suggestionTemplate = this.props.templates && this.props.templates.suggestion;
|
|
248
|
+
return suggestionTemplate ? suggestionTemplate(value) : value;
|
|
249
|
+
}
|
|
250
|
+
}, {
|
|
251
|
+
key: "handleComponentBlur",
|
|
252
|
+
value: function handleComponentBlur(newState) {
|
|
253
|
+
var _this$state = this.state,
|
|
254
|
+
options = _this$state.options,
|
|
255
|
+
query = _this$state.query,
|
|
256
|
+
selected = _this$state.selected;
|
|
257
|
+
var newQuery;
|
|
258
|
+
|
|
259
|
+
if (this.props.confirmOnBlur) {
|
|
260
|
+
var _this$props$onConfirm, _this$props;
|
|
261
|
+
|
|
262
|
+
newQuery = newState.query || query;
|
|
263
|
+
(_this$props$onConfirm = (_this$props = this.props).onConfirm) === null || _this$props$onConfirm === void 0 ? void 0 : _this$props$onConfirm.call(_this$props, options[selected]);
|
|
264
|
+
} else {
|
|
265
|
+
newQuery = query;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
this.setState({
|
|
269
|
+
focused: null,
|
|
270
|
+
menuOpen: newState.menuOpen || false,
|
|
271
|
+
query: newQuery,
|
|
272
|
+
selected: null,
|
|
273
|
+
validChoiceMade: this.isQueryAnOption(newQuery, options)
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
}, {
|
|
277
|
+
key: "handleListMouseLeave",
|
|
278
|
+
value: function handleListMouseLeave() {
|
|
279
|
+
this.setState({
|
|
280
|
+
hovered: null
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
}, {
|
|
284
|
+
key: "handleOptionBlur",
|
|
285
|
+
value: function handleOptionBlur(event, index) {
|
|
286
|
+
var _this$state2 = this.state,
|
|
287
|
+
focused = _this$state2.focused,
|
|
288
|
+
menuOpen = _this$state2.menuOpen,
|
|
289
|
+
options = _this$state2.options,
|
|
290
|
+
selected = _this$state2.selected;
|
|
291
|
+
var focusingOutsideComponent = event.relatedTarget === null;
|
|
292
|
+
var focusingInput = event.relatedTarget === this.elementReferences[-1];
|
|
293
|
+
var focusingAnotherOption = focused !== index && focused !== -1;
|
|
294
|
+
var blurComponent = !focusingAnotherOption && focusingOutsideComponent || !(focusingAnotherOption || focusingInput);
|
|
295
|
+
|
|
296
|
+
if (blurComponent) {
|
|
297
|
+
var keepMenuOpen = menuOpen && isIosDevice();
|
|
298
|
+
this.handleComponentBlur({
|
|
299
|
+
menuOpen: keepMenuOpen,
|
|
300
|
+
query: this.templateInputValue(options[selected])
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}, {
|
|
305
|
+
key: "handleInputBlur",
|
|
306
|
+
value: function handleInputBlur() {
|
|
307
|
+
var _this$state3 = this.state,
|
|
308
|
+
focused = _this$state3.focused,
|
|
309
|
+
menuOpen = _this$state3.menuOpen,
|
|
310
|
+
options = _this$state3.options,
|
|
311
|
+
query = _this$state3.query,
|
|
312
|
+
selected = _this$state3.selected;
|
|
313
|
+
var focusingAnOption = focused !== -1;
|
|
314
|
+
|
|
315
|
+
if (!focusingAnOption) {
|
|
316
|
+
var keepMenuOpen = menuOpen && isIosDevice();
|
|
317
|
+
var newQuery = isIosDevice() ? query : this.templateInputValue(options[selected]);
|
|
318
|
+
this.handleComponentBlur({
|
|
319
|
+
menuOpen: keepMenuOpen,
|
|
320
|
+
query: newQuery
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}, {
|
|
325
|
+
key: "handleInputChange",
|
|
326
|
+
value: function handleInputChange(event) {
|
|
327
|
+
var _this4 = this;
|
|
328
|
+
|
|
329
|
+
var _this$props2 = this.props,
|
|
330
|
+
minLength = _this$props2.minLength,
|
|
331
|
+
source = _this$props2.source,
|
|
332
|
+
showAllValues = _this$props2.showAllValues;
|
|
333
|
+
var autoselect = this.hasAutoselect();
|
|
334
|
+
var query = event.target.value;
|
|
335
|
+
var queryEmpty = query.length === 0;
|
|
336
|
+
var queryChanged = this.state.query.length !== query.length;
|
|
337
|
+
var queryLongEnough = query.length >= minLength;
|
|
338
|
+
this.setState({
|
|
339
|
+
query: query,
|
|
340
|
+
ariaHint: queryEmpty
|
|
341
|
+
});
|
|
342
|
+
var searchForOptions = showAllValues || !queryEmpty && queryChanged && queryLongEnough;
|
|
343
|
+
|
|
344
|
+
if (searchForOptions) {
|
|
345
|
+
source(query, function (options) {
|
|
346
|
+
var optionsAvailable = options.length > 0;
|
|
347
|
+
|
|
348
|
+
_this4.setState({
|
|
349
|
+
menuOpen: optionsAvailable,
|
|
350
|
+
options: options,
|
|
351
|
+
selected: autoselect && optionsAvailable ? 0 : -1,
|
|
352
|
+
validChoiceMade: false
|
|
353
|
+
});
|
|
354
|
+
});
|
|
355
|
+
} else if (queryEmpty || !queryLongEnough) {
|
|
356
|
+
this.setState({
|
|
357
|
+
menuOpen: false,
|
|
358
|
+
options: []
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
}, {
|
|
363
|
+
key: "handleInputClick",
|
|
364
|
+
value: function handleInputClick(event) {
|
|
365
|
+
this.handleInputChange(event);
|
|
366
|
+
}
|
|
367
|
+
}, {
|
|
368
|
+
key: "handleInputFocus",
|
|
369
|
+
value: function handleInputFocus() {
|
|
370
|
+
var _this$state4 = this.state,
|
|
371
|
+
query = _this$state4.query,
|
|
372
|
+
validChoiceMade = _this$state4.validChoiceMade,
|
|
373
|
+
options = _this$state4.options;
|
|
374
|
+
var minLength = this.props.minLength;
|
|
375
|
+
var shouldReopenMenu = !validChoiceMade && query.length >= minLength && options.length > 0;
|
|
376
|
+
|
|
377
|
+
if (shouldReopenMenu) {
|
|
378
|
+
this.setState(function (_ref) {
|
|
379
|
+
var menuOpen = _ref.menuOpen;
|
|
380
|
+
return {
|
|
381
|
+
focused: -1,
|
|
382
|
+
menuOpen: shouldReopenMenu || menuOpen,
|
|
383
|
+
selected: -1
|
|
384
|
+
};
|
|
385
|
+
});
|
|
386
|
+
} else {
|
|
387
|
+
this.setState({
|
|
388
|
+
focused: -1
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
}, {
|
|
393
|
+
key: "handleOptionFocus",
|
|
394
|
+
value: function handleOptionFocus(index) {
|
|
395
|
+
this.setState({
|
|
396
|
+
focused: index,
|
|
397
|
+
hovered: null,
|
|
398
|
+
selected: index
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
}, {
|
|
402
|
+
key: "handleOptionMouseEnter",
|
|
403
|
+
value: function handleOptionMouseEnter(index) {
|
|
404
|
+
// iOS Safari prevents click event if mouseenter adds hover background colour
|
|
405
|
+
// See: https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariWebContent/HandlingEvents/HandlingEvents.html#//apple_ref/doc/uid/TP40006511-SW4
|
|
406
|
+
if (!isIosDevice()) {
|
|
407
|
+
this.setState({
|
|
408
|
+
hovered: index
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
}, {
|
|
413
|
+
key: "handleOptionClick",
|
|
414
|
+
value: function handleOptionClick(index) {
|
|
415
|
+
var _this$props$onConfirm2, _this$props3;
|
|
416
|
+
|
|
417
|
+
var selectedOption = this.state.options[index];
|
|
418
|
+
var newQuery = this.templateInputValue(selectedOption);
|
|
419
|
+
(_this$props$onConfirm2 = (_this$props3 = this.props).onConfirm) === null || _this$props$onConfirm2 === void 0 ? void 0 : _this$props$onConfirm2.call(_this$props3, selectedOption);
|
|
420
|
+
this.setState({
|
|
421
|
+
focused: -1,
|
|
422
|
+
hovered: null,
|
|
423
|
+
menuOpen: false,
|
|
424
|
+
query: newQuery,
|
|
425
|
+
selected: -1,
|
|
426
|
+
validChoiceMade: true
|
|
427
|
+
});
|
|
428
|
+
this.forceUpdate();
|
|
429
|
+
}
|
|
430
|
+
}, {
|
|
431
|
+
key: "handleOptionMouseDown",
|
|
432
|
+
value: function handleOptionMouseDown(event) {
|
|
433
|
+
// Safari triggers focusOut before click, but if you
|
|
434
|
+
// preventDefault on mouseDown, you can stop that from happening.
|
|
435
|
+
// If this is removed, clicking on an option in Safari will trigger
|
|
436
|
+
// `handleOptionBlur`, which closes the menu, and the click will
|
|
437
|
+
// trigger on the element underneath instead.
|
|
438
|
+
// See: http://stackoverflow.com/questions/7621711/how-to-prevent-blur-running-when-clicking-a-link-in-jquery
|
|
439
|
+
event.preventDefault();
|
|
440
|
+
}
|
|
441
|
+
}, {
|
|
442
|
+
key: "handleUpArrow",
|
|
443
|
+
value: function handleUpArrow(event) {
|
|
444
|
+
event.preventDefault();
|
|
445
|
+
var _this$state5 = this.state,
|
|
446
|
+
menuOpen = _this$state5.menuOpen,
|
|
447
|
+
selected = _this$state5.selected;
|
|
448
|
+
var isNotAtTop = selected !== -1;
|
|
449
|
+
var allowMoveUp = isNotAtTop && menuOpen;
|
|
450
|
+
|
|
451
|
+
if (allowMoveUp) {
|
|
452
|
+
this.handleOptionFocus(selected - 1);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}, {
|
|
456
|
+
key: "handleDownArrow",
|
|
457
|
+
value: function handleDownArrow(event) {
|
|
458
|
+
var _this5 = this;
|
|
459
|
+
|
|
460
|
+
event.preventDefault(); // if not open, open
|
|
461
|
+
|
|
462
|
+
if (this.props.showAllValues && this.state.menuOpen === false) {
|
|
463
|
+
event.preventDefault();
|
|
464
|
+
this.props.source('', function (options) {
|
|
465
|
+
_this5.setState({
|
|
466
|
+
menuOpen: true,
|
|
467
|
+
options: options,
|
|
468
|
+
selected: 0,
|
|
469
|
+
focused: 0,
|
|
470
|
+
hovered: null
|
|
471
|
+
});
|
|
472
|
+
});
|
|
473
|
+
} else if (this.state.menuOpen === true) {
|
|
474
|
+
var _this$state6 = this.state,
|
|
475
|
+
menuOpen = _this$state6.menuOpen,
|
|
476
|
+
_options = _this$state6.options,
|
|
477
|
+
selected = _this$state6.selected;
|
|
478
|
+
var isNotAtBottom = selected !== _options.length - 1;
|
|
479
|
+
var allowMoveDown = isNotAtBottom && menuOpen;
|
|
480
|
+
|
|
481
|
+
if (allowMoveDown) {
|
|
482
|
+
this.handleOptionFocus(selected + 1);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}, {
|
|
487
|
+
key: "handleSpace",
|
|
488
|
+
value: function handleSpace(event) {
|
|
489
|
+
var _this6 = this;
|
|
490
|
+
|
|
491
|
+
// if not open, open
|
|
492
|
+
if (this.props.showAllValues && this.state.menuOpen === false && this.state.query === '') {
|
|
493
|
+
event.preventDefault();
|
|
494
|
+
this.props.source('', function (options) {
|
|
495
|
+
_this6.setState({
|
|
496
|
+
menuOpen: true,
|
|
497
|
+
options: options
|
|
498
|
+
});
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
var focusIsOnOption = this.state.focused !== -1;
|
|
503
|
+
|
|
504
|
+
if (focusIsOnOption) {
|
|
505
|
+
event.preventDefault();
|
|
506
|
+
this.handleOptionClick(this.state.focused);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}, {
|
|
510
|
+
key: "handleEnter",
|
|
511
|
+
value: function handleEnter(event) {
|
|
512
|
+
if (this.state.menuOpen) {
|
|
513
|
+
event.preventDefault();
|
|
514
|
+
var hasSelectedOption = this.state.selected >= 0;
|
|
515
|
+
|
|
516
|
+
if (hasSelectedOption) {
|
|
517
|
+
this.handleOptionClick(this.state.selected);
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
}, {
|
|
522
|
+
key: "handlePrintableKey",
|
|
523
|
+
value: function handlePrintableKey(event) {
|
|
524
|
+
var inputElement = this.elementReferences[-1];
|
|
525
|
+
var eventIsOnInput = event.target === inputElement;
|
|
526
|
+
|
|
527
|
+
if (!eventIsOnInput) {
|
|
528
|
+
// FIXME: This would be better if it was in componentDidUpdate,
|
|
529
|
+
// but using setState to trigger that seems to not work correctly
|
|
530
|
+
// in preact@8.1.0.
|
|
531
|
+
inputElement.focus();
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
}, {
|
|
535
|
+
key: "handleKeyDown",
|
|
536
|
+
value: function handleKeyDown(event) {
|
|
537
|
+
switch (keyCodes[event.keyCode]) {
|
|
538
|
+
case 'up':
|
|
539
|
+
this.handleUpArrow(event);
|
|
540
|
+
break;
|
|
541
|
+
|
|
542
|
+
case 'down':
|
|
543
|
+
this.handleDownArrow(event);
|
|
544
|
+
break;
|
|
545
|
+
|
|
546
|
+
case 'space':
|
|
547
|
+
this.handleSpace(event);
|
|
548
|
+
break;
|
|
549
|
+
|
|
550
|
+
case 'enter':
|
|
551
|
+
this.handleEnter(event);
|
|
552
|
+
break;
|
|
553
|
+
|
|
554
|
+
case 'escape':
|
|
555
|
+
this.handleComponentBlur({
|
|
556
|
+
query: this.state.query
|
|
557
|
+
});
|
|
558
|
+
break;
|
|
559
|
+
|
|
560
|
+
default:
|
|
561
|
+
if (isPrintableKeyCode(event.keyCode)) {
|
|
562
|
+
this.handlePrintableKey(event);
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
break;
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
}, {
|
|
569
|
+
key: "render",
|
|
570
|
+
value: function render() {
|
|
571
|
+
var _this7 = this;
|
|
572
|
+
|
|
573
|
+
var _this$props4 = this.props,
|
|
574
|
+
id = _this$props4.id,
|
|
575
|
+
cellWidth = _this$props4.cellWidth,
|
|
576
|
+
displayMenu = _this$props4.displayMenu,
|
|
577
|
+
minLength = _this$props4.minLength,
|
|
578
|
+
name = _this$props4.name,
|
|
579
|
+
placeholder = _this$props4.placeholder,
|
|
580
|
+
required = _this$props4.required,
|
|
581
|
+
showAllValues = _this$props4.showAllValues,
|
|
582
|
+
tNoResults = _this$props4.tNoResults,
|
|
583
|
+
tStatusQueryTooShort = _this$props4.tStatusQueryTooShort,
|
|
584
|
+
tStatusNoResults = _this$props4.tStatusNoResults,
|
|
585
|
+
tStatusSelectedOption = _this$props4.tStatusSelectedOption,
|
|
586
|
+
tStatusResults = _this$props4.tStatusResults,
|
|
587
|
+
tAssistiveHint = _this$props4.tAssistiveHint,
|
|
588
|
+
dropdownArrowFactory = _this$props4.dropdownArrow;
|
|
589
|
+
var _this$state7 = this.state,
|
|
590
|
+
focused = _this$state7.focused,
|
|
591
|
+
hovered = _this$state7.hovered,
|
|
592
|
+
menuOpen = _this$state7.menuOpen,
|
|
593
|
+
options = _this$state7.options,
|
|
594
|
+
query = _this$state7.query,
|
|
595
|
+
selected = _this$state7.selected,
|
|
596
|
+
ariaHint = _this$state7.ariaHint,
|
|
597
|
+
validChoiceMade = _this$state7.validChoiceMade;
|
|
598
|
+
var autoselect = this.hasAutoselect();
|
|
599
|
+
var inputFocused = focused === -1;
|
|
600
|
+
var noOptionsAvailable = options.length === 0;
|
|
601
|
+
var queryNotEmpty = query.length !== 0;
|
|
602
|
+
var queryLongEnough = query.length >= minLength;
|
|
603
|
+
var showNoOptionsFound = this.props.showNoOptionsFound && inputFocused && noOptionsAvailable && queryNotEmpty && queryLongEnough;
|
|
604
|
+
var componentIsFocused = focused !== null;
|
|
605
|
+
var dropdownArrowClassName = "govgr-autocomplete__dropdown-arrow-down";
|
|
606
|
+
var optionFocused = focused !== -1 && focused !== null;
|
|
607
|
+
var menuIsVisible = menuOpen || showNoOptionsFound;
|
|
608
|
+
var selectedOptionText = this.templateInputValue(options[selected]);
|
|
609
|
+
var optionBeginsWithQuery = selectedOptionText && selectedOptionText.toLowerCase().indexOf(query.toLowerCase()) === 0;
|
|
610
|
+
var hintValue = optionBeginsWithQuery && autoselect ? query + selectedOptionText.substr(query.length) : '';
|
|
611
|
+
var assistiveHintID = id + '__assistiveHint';
|
|
612
|
+
var ariaDescribedProp = ariaHint ? {
|
|
613
|
+
'aria-describedby': assistiveHintID
|
|
614
|
+
} : null;
|
|
615
|
+
var dropdownArrow; // we only need a dropdown arrow if showAllValues is set to a truthy value
|
|
616
|
+
|
|
617
|
+
if (showAllValues) {
|
|
618
|
+
dropdownArrow = dropdownArrowFactory({
|
|
619
|
+
className: dropdownArrowClassName
|
|
620
|
+
}); // if the factory returns a string we'll render this as HTML (usage w/o (P)React)
|
|
621
|
+
|
|
622
|
+
if (typeof dropdownArrow === 'string') {
|
|
623
|
+
dropdownArrow = /*#__PURE__*/_react["default"].createElement("div", {
|
|
624
|
+
className: "autocomplete__dropdown-arrow-down-wrapper",
|
|
625
|
+
dangerouslySetInnerHTML: {
|
|
626
|
+
__html: dropdownArrow
|
|
627
|
+
}
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
|
|
632
|
+
return /*#__PURE__*/_react["default"].createElement(_AutoCompleteWrapper["default"], {
|
|
633
|
+
onKeyDown: this.handleKeyDown,
|
|
634
|
+
cellWidth: cellWidth
|
|
635
|
+
}, /*#__PURE__*/_react["default"].createElement(_Status["default"], {
|
|
636
|
+
id: id,
|
|
637
|
+
length: options.length,
|
|
638
|
+
queryLength: query.length,
|
|
639
|
+
minQueryLength: minLength,
|
|
640
|
+
selectedOption: this.templateInputValue(options[selected]),
|
|
641
|
+
selectedOptionIndex: selected,
|
|
642
|
+
validChoiceMade: validChoiceMade,
|
|
643
|
+
isInFocus: this.state.focused !== null,
|
|
644
|
+
tQueryTooShort: tStatusQueryTooShort,
|
|
645
|
+
tNoResults: tStatusNoResults,
|
|
646
|
+
tSelectedOption: tStatusSelectedOption,
|
|
647
|
+
tResults: tStatusResults
|
|
648
|
+
}), hintValue && /*#__PURE__*/_react["default"].createElement(_AutoCompleteInputTypeahead["default"], {
|
|
649
|
+
value: hintValue
|
|
650
|
+
}), /*#__PURE__*/_react["default"].createElement(_AutoCompleteInput["default"], (0, _extends2["default"])({
|
|
651
|
+
"aria-expanded": menuOpen ? 'true' : 'false',
|
|
652
|
+
"aria-activedescendant": optionFocused ? "".concat(id, "__option--").concat(focused) : '',
|
|
653
|
+
"aria-owns": "".concat(id, "__listbox"),
|
|
654
|
+
"aria-autocomplete": this.hasAutoselect() ? 'both' : 'list'
|
|
655
|
+
}, ariaDescribedProp, {
|
|
656
|
+
autoComplete: "off",
|
|
657
|
+
isFocused: componentIsFocused,
|
|
658
|
+
showAllValues: this.props.showAllValues,
|
|
659
|
+
id: id,
|
|
660
|
+
onClick: function onClick(event) {
|
|
661
|
+
return _this7.handleInputClick(event);
|
|
662
|
+
},
|
|
663
|
+
onBlur: this.handleInputBlur,
|
|
664
|
+
onChange: this.handleInputChange,
|
|
665
|
+
onFocus: this.handleInputFocus,
|
|
666
|
+
name: name,
|
|
667
|
+
placeholder: placeholder,
|
|
668
|
+
ref: function ref(inputElement) {
|
|
669
|
+
_this7.elementReferences[-1] = inputElement;
|
|
670
|
+
},
|
|
671
|
+
role: "combobox",
|
|
672
|
+
required: required,
|
|
673
|
+
value: query
|
|
674
|
+
})), dropdownArrow, /*#__PURE__*/_react["default"].createElement(_AutoCompleteResultList["default"], {
|
|
675
|
+
displayMenu: displayMenu,
|
|
676
|
+
isVisible: menuIsVisible,
|
|
677
|
+
onMouseLeave: function onMouseLeave() {
|
|
678
|
+
return _this7.handleListMouseLeave();
|
|
679
|
+
},
|
|
680
|
+
id: "".concat(id, "__listbox"),
|
|
681
|
+
role: "listbox"
|
|
682
|
+
}, options.map(function (option, index) {
|
|
683
|
+
var showFocused = focused === -1 ? selected === index : focused === index;
|
|
684
|
+
var iosPosinsetHtml = isIosDevice() ? "<span id=".concat(id, "__option-suffix--").concat(index, " style=\"border:0;clip:rect(0 0 0 0);height:1px;") + 'marginBottom:-1px;marginRight:-1px;overflow:hidden;padding:0;position:absolute;' + 'whiteSpace:nowrap;width:1px">' + " ".concat(index + 1, " of ").concat(options.length, "</span>") : '';
|
|
685
|
+
return /*#__PURE__*/_react["default"].createElement(_AutoCompleteResultListItem["default"], {
|
|
686
|
+
isFocused: showFocused,
|
|
687
|
+
isHovered: hovered,
|
|
688
|
+
index: index,
|
|
689
|
+
"aria-selected": focused === index ? 'true' : 'false',
|
|
690
|
+
dangerouslySetInnerHTML: {
|
|
691
|
+
__html: _this7.templateSuggestion(option) + iosPosinsetHtml
|
|
692
|
+
},
|
|
693
|
+
id: "".concat(id, "__option--").concat(index),
|
|
694
|
+
key: index,
|
|
695
|
+
onBlur: function onBlur(event) {
|
|
696
|
+
return _this7.handleOptionBlur(event, index);
|
|
697
|
+
},
|
|
698
|
+
onClick: function onClick() {
|
|
699
|
+
return _this7.handleOptionClick(index);
|
|
700
|
+
},
|
|
701
|
+
onMouseDown: _this7.handleOptionMouseDown,
|
|
702
|
+
onMouseEnter: function onMouseEnter() {
|
|
703
|
+
return _this7.handleOptionMouseEnter(index);
|
|
704
|
+
},
|
|
705
|
+
ref: function ref(optionEl) {
|
|
706
|
+
_this7.elementReferences[index] = optionEl;
|
|
707
|
+
},
|
|
708
|
+
role: "option",
|
|
709
|
+
tabIndex: -1,
|
|
710
|
+
"aria-posinset": index + 1,
|
|
711
|
+
"aria-setsize": options.length
|
|
712
|
+
});
|
|
713
|
+
}), showNoOptionsFound && /*#__PURE__*/_react["default"].createElement(_AutoCompleteNoResult["default"], null, tNoResults === null || tNoResults === void 0 ? void 0 : tNoResults())), /*#__PURE__*/_react["default"].createElement(_AutoCompleteAssistiveHint["default"], {
|
|
714
|
+
id: assistiveHintID
|
|
715
|
+
}, tAssistiveHint === null || tAssistiveHint === void 0 ? void 0 : tAssistiveHint()));
|
|
716
|
+
}
|
|
717
|
+
}]);
|
|
718
|
+
return AutoComplete;
|
|
719
|
+
}(_react.Component);
|
|
720
|
+
|
|
721
|
+
exports["default"] = AutoComplete;
|
|
722
|
+
AutoComplete.defaultProps = {
|
|
723
|
+
cellWidth: 'one-third',
|
|
724
|
+
autoselect: false,
|
|
725
|
+
defaultValue: '',
|
|
726
|
+
displayMenu: 'overlay',
|
|
727
|
+
minLength: 0,
|
|
728
|
+
name: 'govgr-input-autocomplete',
|
|
729
|
+
placeholder: '',
|
|
730
|
+
onConfirm: function onConfirm() {
|
|
731
|
+
return;
|
|
732
|
+
},
|
|
733
|
+
confirmOnBlur: false,
|
|
734
|
+
showNoOptionsFound: true,
|
|
735
|
+
showAllValues: false,
|
|
736
|
+
required: false,
|
|
737
|
+
tNoResults: function tNoResults() {
|
|
738
|
+
return 'No results found';
|
|
739
|
+
},
|
|
740
|
+
tAssistiveHint: function tAssistiveHint() {
|
|
741
|
+
return 'When autocomplete results are available use up and down arrows to review and enter to select. Touch device users, explore by touch or with swipe gestures.';
|
|
742
|
+
},
|
|
743
|
+
dropdownArrow: _DropdownArrowDown["default"]
|
|
744
|
+
};
|