@dnb/eufemia 9.17.2 → 9.18.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 +14 -0
- package/cjs/components/Tag.d.ts +14 -0
- package/cjs/components/Tag.js +52 -0
- package/cjs/components/accordion/Accordion.d.ts +7 -7
- package/cjs/components/autocomplete/Autocomplete.d.ts +13 -13
- package/cjs/components/button/Button.d.ts +7 -7
- package/cjs/components/button/Button.js +6 -4
- package/cjs/components/checkbox/Checkbox.d.ts +3 -3
- package/cjs/components/date-picker/DatePicker.d.ts +14 -14
- package/cjs/components/date-picker/DatePickerAddon.d.ts +1 -1
- package/cjs/components/date-picker/DatePickerCalendar.d.ts +1 -1
- package/cjs/components/date-picker/DatePickerInput.d.ts +1 -1
- package/cjs/components/dropdown/Dropdown.d.ts +9 -9
- package/cjs/components/form-row/FormRow.d.ts +4 -4
- package/cjs/components/form-set/FormSet.d.ts +5 -5
- package/cjs/components/global-error/GlobalError.d.ts +1 -1
- package/cjs/components/global-status/GlobalStatus.d.ts +5 -5
- package/cjs/components/heading/Heading.d.ts +2 -2
- package/cjs/components/heading/HeadingProvider.d.ts +2 -2
- package/cjs/components/icon/Icon.d.ts +1 -1
- package/cjs/components/icon-primary/IconPrimary.d.ts +1 -1
- package/cjs/components/index.d.ts +2 -0
- package/cjs/components/index.js +8 -0
- package/cjs/components/input/Input.d.ts +9 -9
- package/cjs/components/input-masked/InputMasked.d.ts +11 -11
- package/cjs/components/input-masked/InputMasked.js +6 -3
- package/cjs/components/input-masked/InputMaskedHooks.js +26 -34
- package/cjs/components/input-masked/InputMaskedUtils.js +9 -20
- package/cjs/components/lib.js +9 -0
- package/cjs/components/modal/Modal.js +123 -271
- package/cjs/components/modal/ModalContent.js +145 -243
- package/cjs/components/modal/ModalRoot.js +194 -0
- package/cjs/components/modal/components/CloseButton.js +125 -0
- package/cjs/components/modal/components/ModalHeader.js +124 -0
- package/cjs/components/modal/{ModalHeader.js → components/ModalHeaderBar.js} +50 -162
- package/cjs/components/modal/{ModalInner.js → components/ModalInner.js} +11 -19
- package/cjs/components/modal/helpers.js +80 -0
- package/cjs/components/modal/types.js +1 -0
- package/cjs/components/number-format/NumberFormat.d.ts +8 -8
- package/cjs/components/pagination/Pagination.d.ts +30 -30
- package/cjs/components/pagination/PaginationProvider.d.ts +2 -2
- package/cjs/components/radio/Radio.d.ts +4 -4
- package/cjs/components/radio/RadioGroup.d.ts +3 -3
- package/cjs/components/section/Section.d.ts +3 -2
- package/cjs/components/skeleton/Skeleton.d.ts +2 -2
- package/cjs/components/slider/Slider.d.ts +4 -4
- package/cjs/components/step-indicator/StepIndicator.d.ts +5 -5
- package/cjs/components/step-indicator/StepIndicatorContext.d.ts +1 -1
- package/cjs/components/step-indicator/StepIndicatorItem.d.ts +2 -2
- package/cjs/components/step-indicator/StepIndicatorItem.js +1 -0
- package/cjs/components/step-indicator/StepIndicatorSidebar.d.ts +3 -3
- package/cjs/components/step-indicator/StepIndicatorTriggerButton.d.ts +1 -1
- package/cjs/components/switch/Switch.d.ts +5 -5
- package/cjs/components/tabs/Tabs.d.ts +4 -4
- package/cjs/components/tabs/TabsContentWrapper.d.ts +1 -1
- package/cjs/components/tag/Tag.js +97 -0
- package/cjs/components/tag/index.d.ts +8 -0
- package/cjs/components/tag/index.js +52 -0
- package/cjs/components/tag/style/_tag.scss +26 -0
- package/cjs/components/tag/style/dnb-tag.css +109 -0
- package/cjs/components/tag/style/dnb-tag.min.css +1 -0
- package/cjs/components/tag/style/dnb-tag.scss +12 -0
- package/cjs/components/tag/style/index.d.ts +6 -0
- package/cjs/components/tag/style/index.js +3 -0
- package/cjs/components/tag/style.js +3 -0
- package/cjs/components/textarea/Textarea.d.ts +4 -4
- package/cjs/components/toggle-button/ToggleButton.d.ts +6 -6
- package/cjs/components/toggle-button/ToggleButtonGroup.d.ts +3 -3
- package/cjs/components/tooltip/Tooltip.d.ts +5 -5
- package/cjs/components/tooltip/TooltipContainer.d.ts +3 -3
- package/cjs/components/tooltip/TooltipPortal.d.ts +1 -1
- package/cjs/components/tooltip/TooltipWithEvents.d.ts +1 -1
- package/cjs/fragments/scroll-view/ScrollView.js +7 -16
- package/cjs/index.d.ts +2 -0
- package/cjs/index.js +8 -0
- package/cjs/shared/Context.js +2 -1
- package/cjs/style/core/helper-classes/skip-link.scss +1 -1
- package/cjs/style/dnb-ui-components.css +40 -0
- package/cjs/style/dnb-ui-components.min.css +1 -1
- package/cjs/style/dnb-ui-components.scss +1 -0
- package/components/Tag.d.ts +14 -0
- package/components/Tag.js +3 -0
- package/components/accordion/Accordion.d.ts +7 -7
- package/components/autocomplete/Autocomplete.d.ts +13 -13
- package/components/button/Button.d.ts +7 -7
- package/components/button/Button.js +6 -4
- package/components/checkbox/Checkbox.d.ts +3 -3
- package/components/date-picker/DatePicker.d.ts +14 -14
- package/components/date-picker/DatePickerAddon.d.ts +1 -1
- package/components/date-picker/DatePickerCalendar.d.ts +1 -1
- package/components/date-picker/DatePickerInput.d.ts +1 -1
- package/components/dropdown/Dropdown.d.ts +9 -9
- package/components/form-row/FormRow.d.ts +4 -4
- package/components/form-set/FormSet.d.ts +5 -5
- package/components/global-error/GlobalError.d.ts +1 -1
- package/components/global-status/GlobalStatus.d.ts +5 -5
- package/components/heading/Heading.d.ts +2 -2
- package/components/heading/HeadingProvider.d.ts +2 -2
- package/components/icon/Icon.d.ts +1 -1
- package/components/index.d.ts +2 -0
- package/components/index.js +2 -1
- package/components/input/Input.d.ts +9 -9
- package/components/input-masked/InputMasked.d.ts +11 -11
- package/components/input-masked/InputMasked.js +6 -4
- package/components/input-masked/InputMaskedHooks.js +24 -28
- package/components/input-masked/InputMaskedUtils.js +9 -20
- package/components/lib.js +3 -1
- package/components/modal/Modal.js +112 -250
- package/components/modal/Modal.tsx +524 -0
- package/components/modal/ModalContent.js +137 -224
- package/components/modal/ModalContent.tsx +515 -0
- package/components/modal/ModalContext.tsx +10 -0
- package/components/modal/ModalRoot.js +145 -0
- package/components/modal/ModalRoot.tsx +131 -0
- package/components/modal/components/CloseButton.js +72 -0
- package/components/modal/components/CloseButton.tsx +56 -0
- package/components/modal/components/ModalHeader.js +70 -0
- package/components/modal/components/ModalHeader.tsx +79 -0
- package/components/modal/components/ModalHeaderBar.js +122 -0
- package/components/modal/components/ModalHeaderBar.tsx +118 -0
- package/components/modal/{ModalInner.js → components/ModalInner.js} +11 -17
- package/components/modal/components/ModalInner.tsx +45 -0
- package/components/modal/helpers.js +64 -0
- package/components/modal/helpers.ts +63 -0
- package/components/modal/types.js +1 -0
- package/{cjs/components/modal/Modal.d.ts → components/modal/types.ts} +124 -182
- package/components/number-format/NumberFormat.d.ts +8 -8
- package/components/pagination/Pagination.d.ts +30 -30
- package/components/pagination/PaginationProvider.d.ts +2 -2
- package/components/radio/Radio.d.ts +4 -4
- package/components/radio/RadioGroup.d.ts +3 -3
- package/components/section/Section.d.ts +3 -1
- package/components/skeleton/Skeleton.d.ts +2 -2
- package/components/slider/Slider.d.ts +4 -4
- package/components/step-indicator/StepIndicator.d.ts +5 -5
- package/components/step-indicator/StepIndicatorContext.d.ts +1 -1
- package/components/step-indicator/StepIndicatorItem.d.ts +2 -2
- package/components/step-indicator/StepIndicatorItem.js +1 -0
- package/components/step-indicator/StepIndicatorSidebar.d.ts +3 -3
- package/components/step-indicator/StepIndicatorTriggerButton.d.ts +1 -1
- package/components/switch/Switch.d.ts +5 -5
- package/components/tabs/Tabs.d.ts +4 -4
- package/components/tabs/TabsContentWrapper.d.ts +1 -1
- package/components/tag/Tag.js +63 -0
- package/components/tag/Tag.tsx +95 -0
- package/components/tag/index.d.ts +8 -0
- package/components/tag/index.js +3 -0
- package/components/tag/style/_tag.scss +26 -0
- package/components/tag/style/dnb-tag.css +109 -0
- package/components/tag/style/dnb-tag.min.css +1 -0
- package/components/tag/style/dnb-tag.scss +12 -0
- package/components/tag/style/index.d.ts +6 -0
- package/components/tag/style/index.js +1 -0
- package/components/tag/style.js +1 -0
- package/components/textarea/Textarea.d.ts +4 -4
- package/components/toggle-button/ToggleButton.d.ts +6 -6
- package/components/toggle-button/ToggleButtonGroup.d.ts +3 -3
- package/components/tooltip/Tooltip.d.ts +5 -5
- package/components/tooltip/TooltipContainer.d.ts +3 -3
- package/components/tooltip/TooltipPortal.d.ts +1 -1
- package/components/tooltip/TooltipWithEvents.d.ts +1 -1
- package/es/components/Tag.d.ts +14 -0
- package/es/components/Tag.js +3 -0
- package/es/components/accordion/Accordion.d.ts +7 -7
- package/es/components/autocomplete/Autocomplete.d.ts +13 -13
- package/es/components/button/Button.d.ts +7 -7
- package/es/components/button/Button.js +6 -4
- package/es/components/checkbox/Checkbox.d.ts +3 -3
- package/es/components/date-picker/DatePicker.d.ts +14 -14
- package/es/components/date-picker/DatePickerAddon.d.ts +1 -1
- package/es/components/date-picker/DatePickerCalendar.d.ts +1 -1
- package/es/components/date-picker/DatePickerInput.d.ts +1 -1
- package/es/components/dropdown/Dropdown.d.ts +9 -9
- package/es/components/form-row/FormRow.d.ts +4 -4
- package/es/components/form-set/FormSet.d.ts +5 -5
- package/es/components/global-error/GlobalError.d.ts +1 -1
- package/es/components/global-status/GlobalStatus.d.ts +5 -5
- package/es/components/heading/Heading.d.ts +2 -2
- package/es/components/heading/HeadingProvider.d.ts +2 -2
- package/es/components/icon/Icon.d.ts +1 -1
- package/es/components/icon-primary/IconPrimary.d.ts +1 -1
- package/es/components/index.d.ts +2 -0
- package/es/components/index.js +2 -1
- package/es/components/input/Input.d.ts +9 -9
- package/es/components/input-masked/InputMasked.d.ts +11 -11
- package/es/components/input-masked/InputMasked.js +6 -4
- package/es/components/input-masked/InputMaskedHooks.js +14 -18
- package/es/components/input-masked/InputMaskedUtils.js +7 -18
- package/es/components/lib.js +3 -1
- package/es/components/modal/Modal.js +97 -227
- package/es/components/modal/Modal.tsx +524 -0
- package/es/components/modal/ModalContent.js +95 -186
- package/es/components/modal/ModalContent.tsx +515 -0
- package/es/components/modal/ModalContext.tsx +10 -0
- package/es/components/modal/ModalRoot.js +108 -0
- package/es/components/modal/ModalRoot.tsx +131 -0
- package/es/components/modal/components/CloseButton.js +41 -0
- package/es/components/modal/components/CloseButton.tsx +56 -0
- package/es/components/modal/components/ModalHeader.js +40 -0
- package/es/components/modal/components/ModalHeader.tsx +79 -0
- package/es/components/modal/components/ModalHeaderBar.js +88 -0
- package/es/components/modal/components/ModalHeaderBar.tsx +118 -0
- package/es/components/modal/{ModalInner.js → components/ModalInner.js} +8 -18
- package/es/components/modal/components/ModalInner.tsx +45 -0
- package/es/components/modal/helpers.js +60 -0
- package/es/components/modal/helpers.ts +63 -0
- package/es/components/modal/types.js +1 -0
- package/es/components/modal/{Modal.d.ts → types.ts} +124 -182
- package/es/components/number-format/NumberFormat.d.ts +8 -8
- package/es/components/pagination/Pagination.d.ts +30 -30
- package/es/components/pagination/PaginationProvider.d.ts +2 -2
- package/es/components/radio/Radio.d.ts +4 -4
- package/es/components/radio/RadioGroup.d.ts +3 -3
- package/es/components/section/Section.d.ts +3 -2
- package/es/components/skeleton/Skeleton.d.ts +2 -2
- package/es/components/slider/Slider.d.ts +4 -4
- package/es/components/step-indicator/StepIndicator.d.ts +5 -5
- package/es/components/step-indicator/StepIndicatorContext.d.ts +1 -1
- package/es/components/step-indicator/StepIndicatorItem.d.ts +2 -2
- package/es/components/step-indicator/StepIndicatorItem.js +1 -0
- package/es/components/step-indicator/StepIndicatorSidebar.d.ts +3 -3
- package/es/components/step-indicator/StepIndicatorTriggerButton.d.ts +1 -1
- package/es/components/switch/Switch.d.ts +5 -5
- package/es/components/tabs/Tabs.d.ts +4 -4
- package/es/components/tabs/TabsContentWrapper.d.ts +1 -1
- package/es/components/tag/Tag.js +58 -0
- package/es/components/tag/Tag.tsx +95 -0
- package/es/components/tag/index.d.ts +8 -0
- package/es/components/tag/index.js +3 -0
- package/es/components/tag/style/_tag.scss +26 -0
- package/es/components/tag/style/dnb-tag.css +109 -0
- package/es/components/tag/style/dnb-tag.min.css +1 -0
- package/es/components/tag/style/dnb-tag.scss +12 -0
- package/es/components/tag/style/index.d.ts +6 -0
- package/es/components/tag/style/index.js +1 -0
- package/es/components/tag/style.js +1 -0
- package/es/components/textarea/Textarea.d.ts +4 -4
- package/es/components/toggle-button/ToggleButton.d.ts +6 -6
- package/es/components/toggle-button/ToggleButtonGroup.d.ts +3 -3
- package/es/components/tooltip/Tooltip.d.ts +5 -5
- package/es/components/tooltip/TooltipContainer.d.ts +3 -3
- package/es/components/tooltip/TooltipPortal.d.ts +1 -1
- package/es/components/tooltip/TooltipWithEvents.d.ts +1 -1
- package/es/fragments/scroll-view/ScrollView.js +7 -15
- package/es/fragments/scroll-view/ScrollView.tsx +92 -0
- package/es/index.d.ts +2 -0
- package/es/index.js +2 -1
- package/es/shared/Context.js +2 -1
- package/es/style/core/helper-classes/skip-link.scss +1 -1
- package/es/style/dnb-ui-components.css +40 -0
- package/es/style/dnb-ui-components.min.css +1 -1
- package/es/style/dnb-ui-components.scss +1 -0
- package/esm/components/Tag.d.ts +14 -0
- package/esm/components/Tag.js +3 -0
- package/esm/components/accordion/Accordion.d.ts +7 -7
- package/esm/components/autocomplete/Autocomplete.d.ts +13 -13
- package/esm/components/button/Button.d.ts +7 -7
- package/esm/components/button/Button.js +6 -4
- package/esm/components/checkbox/Checkbox.d.ts +3 -3
- package/esm/components/date-picker/DatePicker.d.ts +14 -14
- package/esm/components/date-picker/DatePickerAddon.d.ts +1 -1
- package/esm/components/date-picker/DatePickerCalendar.d.ts +1 -1
- package/esm/components/date-picker/DatePickerInput.d.ts +1 -1
- package/esm/components/dropdown/Dropdown.d.ts +9 -9
- package/esm/components/form-row/FormRow.d.ts +4 -4
- package/esm/components/form-set/FormSet.d.ts +5 -5
- package/esm/components/global-error/GlobalError.d.ts +1 -1
- package/esm/components/global-status/GlobalStatus.d.ts +5 -5
- package/esm/components/heading/Heading.d.ts +2 -2
- package/esm/components/heading/HeadingProvider.d.ts +2 -2
- package/esm/components/icon/Icon.d.ts +1 -1
- package/esm/components/index.d.ts +2 -0
- package/esm/components/index.js +2 -1
- package/esm/components/input/Input.d.ts +9 -9
- package/esm/components/input-masked/InputMasked.d.ts +11 -11
- package/esm/components/input-masked/InputMasked.js +6 -4
- package/esm/components/input-masked/InputMaskedHooks.js +24 -28
- package/esm/components/input-masked/InputMaskedUtils.js +9 -20
- package/esm/components/lib.js +3 -1
- package/esm/components/modal/Modal.js +112 -250
- package/esm/components/modal/Modal.tsx +524 -0
- package/esm/components/modal/ModalContent.js +137 -224
- package/esm/components/modal/ModalContent.tsx +515 -0
- package/esm/components/modal/ModalContext.tsx +10 -0
- package/esm/components/modal/ModalRoot.js +145 -0
- package/esm/components/modal/ModalRoot.tsx +131 -0
- package/esm/components/modal/components/CloseButton.js +72 -0
- package/esm/components/modal/components/CloseButton.tsx +56 -0
- package/esm/components/modal/components/ModalHeader.js +70 -0
- package/esm/components/modal/components/ModalHeader.tsx +79 -0
- package/esm/components/modal/components/ModalHeaderBar.js +122 -0
- package/esm/components/modal/components/ModalHeaderBar.tsx +118 -0
- package/esm/components/modal/{ModalInner.js → components/ModalInner.js} +11 -17
- package/esm/components/modal/components/ModalInner.tsx +45 -0
- package/esm/components/modal/helpers.js +64 -0
- package/esm/components/modal/helpers.ts +63 -0
- package/esm/components/modal/types.js +1 -0
- package/esm/components/modal/{Modal.d.ts → types.ts} +124 -182
- package/esm/components/number-format/NumberFormat.d.ts +8 -8
- package/esm/components/pagination/Pagination.d.ts +30 -30
- package/esm/components/pagination/PaginationProvider.d.ts +2 -2
- package/esm/components/radio/Radio.d.ts +4 -4
- package/esm/components/radio/RadioGroup.d.ts +3 -3
- package/esm/components/section/Section.d.ts +3 -1
- package/esm/components/skeleton/Skeleton.d.ts +2 -2
- package/esm/components/slider/Slider.d.ts +4 -4
- package/esm/components/step-indicator/StepIndicator.d.ts +5 -5
- package/esm/components/step-indicator/StepIndicatorContext.d.ts +1 -1
- package/esm/components/step-indicator/StepIndicatorItem.d.ts +2 -2
- package/esm/components/step-indicator/StepIndicatorItem.js +1 -0
- package/esm/components/step-indicator/StepIndicatorSidebar.d.ts +3 -3
- package/esm/components/step-indicator/StepIndicatorTriggerButton.d.ts +1 -1
- package/esm/components/switch/Switch.d.ts +5 -5
- package/esm/components/tabs/Tabs.d.ts +4 -4
- package/esm/components/tabs/TabsContentWrapper.d.ts +1 -1
- package/esm/components/tag/Tag.js +63 -0
- package/esm/components/tag/Tag.tsx +95 -0
- package/esm/components/tag/index.d.ts +8 -0
- package/esm/components/tag/index.js +3 -0
- package/esm/components/tag/style/_tag.scss +26 -0
- package/esm/components/tag/style/dnb-tag.css +109 -0
- package/esm/components/tag/style/dnb-tag.min.css +1 -0
- package/esm/components/tag/style/dnb-tag.scss +12 -0
- package/esm/components/tag/style/index.d.ts +6 -0
- package/esm/components/tag/style/index.js +1 -0
- package/esm/components/tag/style.js +1 -0
- package/esm/components/textarea/Textarea.d.ts +4 -4
- package/esm/components/toggle-button/ToggleButton.d.ts +6 -6
- package/esm/components/toggle-button/ToggleButtonGroup.d.ts +3 -3
- package/esm/components/tooltip/Tooltip.d.ts +5 -5
- package/esm/components/tooltip/TooltipContainer.d.ts +3 -3
- package/esm/components/tooltip/TooltipPortal.d.ts +1 -1
- package/esm/components/tooltip/TooltipWithEvents.d.ts +1 -1
- package/esm/dnb-ui-components.min.mjs +1 -1
- package/esm/dnb-ui-elements.min.mjs +1 -1
- package/esm/dnb-ui-extensions.min.mjs +1 -1
- package/esm/dnb-ui-lib.min.mjs +2 -2
- package/esm/dnb-ui-web-components.min.mjs +2 -2
- package/esm/fragments/scroll-view/ScrollView.js +10 -16
- package/esm/fragments/scroll-view/ScrollView.tsx +92 -0
- package/esm/index.d.ts +2 -0
- package/esm/index.js +2 -1
- package/esm/shared/Context.js +2 -1
- package/esm/style/core/helper-classes/skip-link.scss +1 -1
- package/esm/style/dnb-ui-components.css +40 -0
- package/esm/style/dnb-ui-components.min.css +1 -1
- package/esm/style/dnb-ui-components.scss +1 -0
- package/fragments/scroll-view/ScrollView.js +10 -16
- package/fragments/scroll-view/ScrollView.tsx +92 -0
- package/index.d.ts +2 -0
- package/index.js +2 -1
- package/package.json +1 -1
- package/shared/Context.js +2 -1
- package/style/core/helper-classes/skip-link.scss +1 -1
- package/style/dnb-ui-components.css +40 -0
- package/style/dnb-ui-components.min.css +1 -1
- package/style/dnb-ui-components.scss +1 -0
- package/umd/dnb-ui-components.min.js +5 -5
- package/umd/dnb-ui-elements.min.js +1 -1
- package/umd/dnb-ui-extensions.min.js +1 -1
- package/umd/dnb-ui-lib.min.js +4 -4
- package/umd/dnb-ui-web-components.min.js +2 -2
- package/cjs/components/modal/ModalContent.d.ts +0 -168
- package/cjs/components/modal/ModalHeader.d.ts +0 -73
- package/cjs/components/modal/ModalInner.d.ts +0 -20
- package/cjs/fragments/scroll-view/ScrollView.d.ts +0 -1
- package/components/modal/Modal.d.ts +0 -329
- package/components/modal/ModalContent.d.ts +0 -168
- package/components/modal/ModalHeader.d.ts +0 -73
- package/components/modal/ModalHeader.js +0 -224
- package/components/modal/ModalInner.d.ts +0 -20
- package/es/components/modal/ModalContent.d.ts +0 -168
- package/es/components/modal/ModalHeader.d.ts +0 -73
- package/es/components/modal/ModalHeader.js +0 -166
- package/es/components/modal/ModalInner.d.ts +0 -20
- package/es/fragments/scroll-view/ScrollView.d.ts +0 -1
- package/esm/components/modal/ModalContent.d.ts +0 -168
- package/esm/components/modal/ModalHeader.d.ts +0 -73
- package/esm/components/modal/ModalHeader.js +0 -224
- package/esm/components/modal/ModalInner.d.ts +0 -20
- package/esm/fragments/scroll-view/ScrollView.d.ts +0 -1
- package/fragments/scroll-view/ScrollView.d.ts +0 -1
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import ReactDOM from 'react-dom'
|
|
3
|
+
import { warn, isTrue } from '../../shared/component-helper'
|
|
4
|
+
import ModalContent from './ModalContent'
|
|
5
|
+
import { ModalContentProps } from './types'
|
|
6
|
+
|
|
7
|
+
declare global {
|
|
8
|
+
interface Window {
|
|
9
|
+
__modalRoot: HTMLElement
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface ModalRootProps extends ModalContentProps {
|
|
14
|
+
/**
|
|
15
|
+
* The id used internal in the modal/drawer root element. Defaults to `root`, so the element id will be `dnb-modal-root`.
|
|
16
|
+
*/
|
|
17
|
+
id?: string
|
|
18
|
+
root_id?: string
|
|
19
|
+
direct_dom_return?: string | boolean
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The content which will appear when triggering the modal/drawer.
|
|
23
|
+
*/
|
|
24
|
+
children?: string | React.ReactNode | ((...args: any[]) => any)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface ModalRootState {
|
|
28
|
+
isMounted: boolean
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default class ModalRoot extends React.PureComponent<
|
|
32
|
+
ModalRootProps,
|
|
33
|
+
ModalRootState
|
|
34
|
+
> {
|
|
35
|
+
portalElem: HTMLDivElement | null
|
|
36
|
+
static defaultProps = {
|
|
37
|
+
id: null,
|
|
38
|
+
root_id: 'root',
|
|
39
|
+
direct_dom_return: false,
|
|
40
|
+
children: null,
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
state = {
|
|
44
|
+
isMounted: false,
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
static insertModalRoot(id) {
|
|
48
|
+
if (typeof window === 'undefined') {
|
|
49
|
+
return false
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
try {
|
|
53
|
+
id = `dnb-modal-${id || 'root'}`
|
|
54
|
+
window.__modalRoot = document.getElementById(id)
|
|
55
|
+
if (!window.__modalRoot) {
|
|
56
|
+
window.__modalRoot = document.createElement('div')
|
|
57
|
+
window.__modalRoot.setAttribute('id', id)
|
|
58
|
+
document.body.insertBefore(
|
|
59
|
+
window.__modalRoot,
|
|
60
|
+
document.body.firstChild
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
} catch (e) {
|
|
64
|
+
warn('Modal: Could not insert dnb-modal-root', e)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return window.__modalRoot
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
componentDidMount() {
|
|
71
|
+
const { direct_dom_return = false, root_id = 'root' } = this.props
|
|
72
|
+
if (!isTrue(direct_dom_return)) {
|
|
73
|
+
ModalRoot.insertModalRoot(root_id)
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
if (!this.portalElem) {
|
|
77
|
+
this.portalElem = document.createElement('div')
|
|
78
|
+
this.portalElem.className = 'dnb-modal-root__inner'
|
|
79
|
+
}
|
|
80
|
+
if (
|
|
81
|
+
this.portalElem &&
|
|
82
|
+
typeof window !== 'undefined' &&
|
|
83
|
+
window.__modalRoot
|
|
84
|
+
) {
|
|
85
|
+
window.__modalRoot.appendChild(this.portalElem)
|
|
86
|
+
}
|
|
87
|
+
} catch (e) {
|
|
88
|
+
warn(e)
|
|
89
|
+
}
|
|
90
|
+
this.setState({ isMounted: true })
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
componentWillUnmount() {
|
|
95
|
+
try {
|
|
96
|
+
if (
|
|
97
|
+
this.portalElem &&
|
|
98
|
+
typeof window !== 'undefined' &&
|
|
99
|
+
window.__modalRoot &&
|
|
100
|
+
window.__modalRoot.removeChild
|
|
101
|
+
) {
|
|
102
|
+
window.__modalRoot.removeChild(this.portalElem)
|
|
103
|
+
this.portalElem = null
|
|
104
|
+
}
|
|
105
|
+
} catch (e) {
|
|
106
|
+
warn(e)
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
render() {
|
|
111
|
+
const { children, direct_dom_return, ...props } = this.props
|
|
112
|
+
|
|
113
|
+
if (isTrue(direct_dom_return)) {
|
|
114
|
+
return <ModalContent {...props}>{children}</ModalContent>
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (
|
|
118
|
+
this.portalElem &&
|
|
119
|
+
typeof window !== 'undefined' &&
|
|
120
|
+
window.__modalRoot &&
|
|
121
|
+
this.state.isMounted
|
|
122
|
+
) {
|
|
123
|
+
return ReactDOM.createPortal(
|
|
124
|
+
<ModalContent {...props}>{children}</ModalContent>,
|
|
125
|
+
this.portalElem
|
|
126
|
+
)
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return null
|
|
130
|
+
}
|
|
131
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import "core-js/modules/es.object.to-string.js";
|
|
2
|
+
import "core-js/modules/es.reflect.construct.js";
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
6
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
7
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
8
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
9
|
+
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
10
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
11
|
+
var _excluded = ["close_title", "size", "icon_position", "className"];
|
|
12
|
+
|
|
13
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
14
|
+
|
|
15
|
+
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; } }
|
|
16
|
+
|
|
17
|
+
import React from 'react';
|
|
18
|
+
import classnames from 'classnames';
|
|
19
|
+
import { extendPropsWithContext } from '../../../shared/component-helper';
|
|
20
|
+
import Button from '../../button/Button';
|
|
21
|
+
import Context from '../../../shared/Context';
|
|
22
|
+
|
|
23
|
+
var CloseButton = function (_React$PureComponent) {
|
|
24
|
+
_inherits(CloseButton, _React$PureComponent);
|
|
25
|
+
|
|
26
|
+
var _super = _createSuper(CloseButton);
|
|
27
|
+
|
|
28
|
+
function CloseButton() {
|
|
29
|
+
_classCallCheck(this, CloseButton);
|
|
30
|
+
|
|
31
|
+
return _super.apply(this, arguments);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
_createClass(CloseButton, [{
|
|
35
|
+
key: "render",
|
|
36
|
+
value: function render() {
|
|
37
|
+
var _extendPropsWithConte = extendPropsWithContext(this.props, CloseButton.defaultProps, this.context.getTranslation(this.props).Modal),
|
|
38
|
+
_extendPropsWithConte2 = _extendPropsWithConte.close_title,
|
|
39
|
+
close_title = _extendPropsWithConte2 === void 0 ? null : _extendPropsWithConte2,
|
|
40
|
+
_extendPropsWithConte3 = _extendPropsWithConte.size,
|
|
41
|
+
size = _extendPropsWithConte3 === void 0 ? 'large' : _extendPropsWithConte3,
|
|
42
|
+
_extendPropsWithConte4 = _extendPropsWithConte.icon_position,
|
|
43
|
+
icon_position = _extendPropsWithConte4 === void 0 ? 'left' : _extendPropsWithConte4,
|
|
44
|
+
_extendPropsWithConte5 = _extendPropsWithConte.className,
|
|
45
|
+
className = _extendPropsWithConte5 === void 0 ? null : _extendPropsWithConte5,
|
|
46
|
+
button_props = _objectWithoutProperties(_extendPropsWithConte, _excluded);
|
|
47
|
+
|
|
48
|
+
return React.createElement(Button, _extends({
|
|
49
|
+
type: "button",
|
|
50
|
+
variant: "tertiary",
|
|
51
|
+
icon: "close",
|
|
52
|
+
text: close_title,
|
|
53
|
+
size: size,
|
|
54
|
+
icon_position: icon_position,
|
|
55
|
+
className: classnames('dnb-modal__close-button', className)
|
|
56
|
+
}, button_props));
|
|
57
|
+
}
|
|
58
|
+
}]);
|
|
59
|
+
|
|
60
|
+
return CloseButton;
|
|
61
|
+
}(React.PureComponent);
|
|
62
|
+
|
|
63
|
+
_defineProperty(CloseButton, "contextType", Context);
|
|
64
|
+
|
|
65
|
+
_defineProperty(CloseButton, "defaultProps", {
|
|
66
|
+
close_title: null,
|
|
67
|
+
size: 'large',
|
|
68
|
+
icon_position: 'left',
|
|
69
|
+
className: null
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
export { CloseButton as default };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Web Modal Component
|
|
3
|
+
*
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import React from 'react'
|
|
7
|
+
import classnames from 'classnames'
|
|
8
|
+
import { extendPropsWithContext } from '../../../shared/component-helper'
|
|
9
|
+
import Button from '../../button/Button'
|
|
10
|
+
import Context from '../../../shared/Context'
|
|
11
|
+
import { ButtonProps } from '../../button'
|
|
12
|
+
|
|
13
|
+
export interface CloseButtonProps extends ButtonProps {
|
|
14
|
+
/**
|
|
15
|
+
* The title of the close button. Defaults to <em>Close</em> or <em>Lukk</em>.
|
|
16
|
+
*/
|
|
17
|
+
close_title?: string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default class CloseButton extends React.PureComponent<CloseButtonProps> {
|
|
21
|
+
static contextType = Context
|
|
22
|
+
static defaultProps = {
|
|
23
|
+
close_title: null,
|
|
24
|
+
size: 'large',
|
|
25
|
+
icon_position: 'left',
|
|
26
|
+
className: null,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
render() {
|
|
30
|
+
// use only the props from context, who are available here anyway
|
|
31
|
+
const {
|
|
32
|
+
close_title = null,
|
|
33
|
+
size = 'large',
|
|
34
|
+
icon_position = 'left',
|
|
35
|
+
className = null,
|
|
36
|
+
...button_props
|
|
37
|
+
} = extendPropsWithContext(
|
|
38
|
+
this.props,
|
|
39
|
+
CloseButton.defaultProps,
|
|
40
|
+
this.context.getTranslation(this.props).Modal
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<Button
|
|
45
|
+
type="button"
|
|
46
|
+
variant="tertiary"
|
|
47
|
+
icon="close"
|
|
48
|
+
text={close_title}
|
|
49
|
+
size={size}
|
|
50
|
+
icon_position={icon_position}
|
|
51
|
+
className={classnames('dnb-modal__close-button', className)}
|
|
52
|
+
{...button_props}
|
|
53
|
+
/>
|
|
54
|
+
)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import "core-js/modules/es.object.to-string.js";
|
|
2
|
+
import "core-js/modules/es.reflect.construct.js";
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
6
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
7
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
8
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
9
|
+
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
10
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
11
|
+
var _excluded = ["title", "className", "children", "ref"];
|
|
12
|
+
|
|
13
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
14
|
+
|
|
15
|
+
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; } }
|
|
16
|
+
|
|
17
|
+
import React from 'react';
|
|
18
|
+
import classnames from 'classnames';
|
|
19
|
+
import { findElementInChildren } from '../../../shared/component-helper';
|
|
20
|
+
import Section from '../../section/Section';
|
|
21
|
+
import ModalContext from '../ModalContext';
|
|
22
|
+
import H1 from '../../../elements/H1';
|
|
23
|
+
|
|
24
|
+
var ModalHeader = function (_React$PureComponent) {
|
|
25
|
+
_inherits(ModalHeader, _React$PureComponent);
|
|
26
|
+
|
|
27
|
+
var _super = _createSuper(ModalHeader);
|
|
28
|
+
|
|
29
|
+
function ModalHeader() {
|
|
30
|
+
_classCallCheck(this, ModalHeader);
|
|
31
|
+
|
|
32
|
+
return _super.apply(this, arguments);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
_createClass(ModalHeader, [{
|
|
36
|
+
key: "render",
|
|
37
|
+
value: function render() {
|
|
38
|
+
var _this$props = this.props,
|
|
39
|
+
_this$props$title = _this$props.title,
|
|
40
|
+
title = _this$props$title === void 0 ? null : _this$props$title,
|
|
41
|
+
_this$props$className = _this$props.className,
|
|
42
|
+
className = _this$props$className === void 0 ? null : _this$props$className,
|
|
43
|
+
_this$props$children = _this$props.children,
|
|
44
|
+
children = _this$props$children === void 0 ? null : _this$props$children,
|
|
45
|
+
ref = _this$props.ref,
|
|
46
|
+
props = _objectWithoutProperties(_this$props, _excluded);
|
|
47
|
+
|
|
48
|
+
var customHeader = findElementInChildren(children, function (cur) {
|
|
49
|
+
return cur.type === 'h1' || cur.type === H1;
|
|
50
|
+
});
|
|
51
|
+
var usedTitle = title || this.context.title;
|
|
52
|
+
var showTitle = !customHeader && usedTitle;
|
|
53
|
+
return React.createElement(Section, _extends({
|
|
54
|
+
style_type: "white",
|
|
55
|
+
className: classnames('dnb-modal__header', className),
|
|
56
|
+
id: showTitle ? 'dnb-modal-' + this.context.id + '-title' : undefined
|
|
57
|
+
}, props), showTitle && React.createElement("h1", {
|
|
58
|
+
className: "dnb-modal__title dnb-space__top--zero dnb-space__bottom--small " + (this.context.mode === 'drawer' ? 'dnb-h--x-large' : 'dnb-h--large')
|
|
59
|
+
}, usedTitle), React.createElement("div", {
|
|
60
|
+
className: "dnb-modal__header__inner"
|
|
61
|
+
}, children));
|
|
62
|
+
}
|
|
63
|
+
}]);
|
|
64
|
+
|
|
65
|
+
return ModalHeader;
|
|
66
|
+
}(React.PureComponent);
|
|
67
|
+
|
|
68
|
+
_defineProperty(ModalHeader, "contextType", ModalContext);
|
|
69
|
+
|
|
70
|
+
export { ModalHeader as default };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Web Modal Component
|
|
3
|
+
*
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import React from 'react'
|
|
7
|
+
import classnames from 'classnames'
|
|
8
|
+
import { findElementInChildren } from '../../../shared/component-helper'
|
|
9
|
+
import Section from '../../section/Section'
|
|
10
|
+
import { SectionProps } from '../../section'
|
|
11
|
+
import ModalContext from '../ModalContext'
|
|
12
|
+
import H1 from '../../../elements/H1'
|
|
13
|
+
import { ReactChildType } from '../types'
|
|
14
|
+
|
|
15
|
+
interface ModalHeaderProps {
|
|
16
|
+
/**
|
|
17
|
+
* The content which will appear when triggering the modal/drawer.
|
|
18
|
+
*/
|
|
19
|
+
children?: ReactChildType
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The modal/drawer title. Displays on the very top of the content.
|
|
23
|
+
*/
|
|
24
|
+
title?: React.ReactNode | string
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Give the inner content wrapper a class name (maps to `dnb-modal__content__inner`).
|
|
28
|
+
*/
|
|
29
|
+
className?: string
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default class ModalHeader extends React.PureComponent<
|
|
33
|
+
ModalHeaderProps & SectionProps
|
|
34
|
+
> {
|
|
35
|
+
static contextType = ModalContext
|
|
36
|
+
render() {
|
|
37
|
+
const {
|
|
38
|
+
title = null,
|
|
39
|
+
className = null,
|
|
40
|
+
children = null,
|
|
41
|
+
ref, // eslint-disable-line
|
|
42
|
+
...props
|
|
43
|
+
} = this.props
|
|
44
|
+
|
|
45
|
+
const customHeader = findElementInChildren(children, (cur) => {
|
|
46
|
+
return cur.type === 'h1' || cur.type === H1
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
const usedTitle = title || this.context.title
|
|
50
|
+
const showTitle = !customHeader && usedTitle
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<Section
|
|
54
|
+
style_type="white"
|
|
55
|
+
className={classnames('dnb-modal__header', className)}
|
|
56
|
+
id={
|
|
57
|
+
showTitle ? 'dnb-modal-' + this.context.id + '-title' : undefined
|
|
58
|
+
}
|
|
59
|
+
{...props}
|
|
60
|
+
>
|
|
61
|
+
{showTitle && (
|
|
62
|
+
<h1
|
|
63
|
+
className={classnames(
|
|
64
|
+
'dnb-modal__title',
|
|
65
|
+
'dnb-space__top--zero',
|
|
66
|
+
'dnb-space__bottom--small',
|
|
67
|
+
this.context.mode === 'drawer'
|
|
68
|
+
? 'dnb-h--x-large'
|
|
69
|
+
: 'dnb-h--large'
|
|
70
|
+
)}
|
|
71
|
+
>
|
|
72
|
+
{usedTitle}
|
|
73
|
+
</h1>
|
|
74
|
+
)}
|
|
75
|
+
<div className="dnb-modal__header__inner">{children}</div>
|
|
76
|
+
</Section>
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import "core-js/modules/es.object.to-string.js";
|
|
2
|
+
import "core-js/modules/es.reflect.construct.js";
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
5
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
6
|
+
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
7
|
+
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
8
|
+
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
|
|
9
|
+
import _inherits from "@babel/runtime/helpers/esm/inherits";
|
|
10
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
|
|
11
|
+
import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
|
|
12
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
13
|
+
var _excluded = ["className", "children", "ref"];
|
|
14
|
+
|
|
15
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
16
|
+
|
|
17
|
+
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; } }
|
|
18
|
+
|
|
19
|
+
import React from 'react';
|
|
20
|
+
import classnames from 'classnames';
|
|
21
|
+
import { isTrue } from '../../../shared/component-helper';
|
|
22
|
+
import Section from '../../section/Section';
|
|
23
|
+
import ModalContext from '../ModalContext';
|
|
24
|
+
import CloseButton from './CloseButton';
|
|
25
|
+
|
|
26
|
+
var ModalHeaderBar = function (_React$PureComponent) {
|
|
27
|
+
_inherits(ModalHeaderBar, _React$PureComponent);
|
|
28
|
+
|
|
29
|
+
var _super = _createSuper(ModalHeaderBar);
|
|
30
|
+
|
|
31
|
+
function ModalHeaderBar(props) {
|
|
32
|
+
var _this;
|
|
33
|
+
|
|
34
|
+
_classCallCheck(this, ModalHeaderBar);
|
|
35
|
+
|
|
36
|
+
_this = _super.call(this, props);
|
|
37
|
+
|
|
38
|
+
_defineProperty(_assertThisInitialized(_this), "_ref", void 0);
|
|
39
|
+
|
|
40
|
+
_defineProperty(_assertThisInitialized(_this), "intersectionObserver", void 0);
|
|
41
|
+
|
|
42
|
+
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
43
|
+
showShadow: false
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
_this._ref = React.createRef();
|
|
47
|
+
return _this;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
_createClass(ModalHeaderBar, [{
|
|
51
|
+
key: "componentDidMount",
|
|
52
|
+
value: function componentDidMount() {
|
|
53
|
+
var _this2 = this;
|
|
54
|
+
|
|
55
|
+
if (typeof window !== 'undefined' && typeof IntersectionObserver !== 'undefined' && this._ref.current) {
|
|
56
|
+
var marginTop = -this._ref.current.clientHeight;
|
|
57
|
+
this.intersectionObserver = new IntersectionObserver(function (entries) {
|
|
58
|
+
var _entries = _slicedToArray(entries, 1),
|
|
59
|
+
entry = _entries[0];
|
|
60
|
+
|
|
61
|
+
_this2.setState({
|
|
62
|
+
showShadow: !entry.isIntersecting
|
|
63
|
+
});
|
|
64
|
+
}, {
|
|
65
|
+
rootMargin: "".concat(marginTop, "px 0px 0px 0px"),
|
|
66
|
+
threshold: 0.001
|
|
67
|
+
});
|
|
68
|
+
this.intersectionObserver.observe(this._ref.current);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}, {
|
|
72
|
+
key: "componentWillUnmount",
|
|
73
|
+
value: function componentWillUnmount() {
|
|
74
|
+
var _this$intersectionObs;
|
|
75
|
+
|
|
76
|
+
(_this$intersectionObs = this.intersectionObserver) === null || _this$intersectionObs === void 0 ? void 0 : _this$intersectionObs.disconnect();
|
|
77
|
+
}
|
|
78
|
+
}, {
|
|
79
|
+
key: "render",
|
|
80
|
+
value: function render() {
|
|
81
|
+
var _this$props = this.props,
|
|
82
|
+
_this$props$className = _this$props.className,
|
|
83
|
+
className = _this$props$className === void 0 ? null : _this$props$className,
|
|
84
|
+
_this$props$children = _this$props.children,
|
|
85
|
+
children = _this$props$children === void 0 ? null : _this$props$children,
|
|
86
|
+
ref = _this$props.ref,
|
|
87
|
+
props = _objectWithoutProperties(_this$props, _excluded);
|
|
88
|
+
|
|
89
|
+
var showShadow = this.state.showShadow;
|
|
90
|
+
var _this$context = this.context,
|
|
91
|
+
title = _this$context.title,
|
|
92
|
+
_this$context$hide_cl = _this$context.hide_close_button,
|
|
93
|
+
hide_close_button = _this$context$hide_cl === void 0 ? false : _this$context$hide_cl,
|
|
94
|
+
close_button_attributes = _this$context.close_button_attributes,
|
|
95
|
+
onCloseClickHandler = _this$context.onCloseClickHandler,
|
|
96
|
+
close_title = _this$context.close_title;
|
|
97
|
+
|
|
98
|
+
if (!title && isTrue(hide_close_button) && !this._ref.current) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return React.createElement(Section, _extends({
|
|
103
|
+
style_type: "white",
|
|
104
|
+
className: classnames('dnb-modal__header__bar', className, showShadow && 'dnb-modal__header__bar--sticky'),
|
|
105
|
+
inner_ref: this._ref
|
|
106
|
+
}, props), React.createElement("div", {
|
|
107
|
+
className: "dnb-modal__header__bar__inner"
|
|
108
|
+
}, children), !isTrue(hide_close_button) && React.createElement("div", {
|
|
109
|
+
className: "dnb-modal__header__bar__close"
|
|
110
|
+
}, React.createElement(CloseButton, _extends({
|
|
111
|
+
on_click: onCloseClickHandler,
|
|
112
|
+
close_title: close_title
|
|
113
|
+
}, close_button_attributes))));
|
|
114
|
+
}
|
|
115
|
+
}]);
|
|
116
|
+
|
|
117
|
+
return ModalHeaderBar;
|
|
118
|
+
}(React.PureComponent);
|
|
119
|
+
|
|
120
|
+
_defineProperty(ModalHeaderBar, "contextType", ModalContext);
|
|
121
|
+
|
|
122
|
+
export { ModalHeaderBar as default };
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Web Modal Component
|
|
3
|
+
*
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import React from 'react'
|
|
7
|
+
import classnames from 'classnames'
|
|
8
|
+
import { isTrue } from '../../../shared/component-helper'
|
|
9
|
+
import Section from '../../section/Section'
|
|
10
|
+
import ModalContext from '../ModalContext'
|
|
11
|
+
import CloseButton from './CloseButton'
|
|
12
|
+
import { SectionProps } from '../../Section'
|
|
13
|
+
|
|
14
|
+
export interface ModalHeaderBarProps extends SectionProps {
|
|
15
|
+
/**
|
|
16
|
+
* The content which will appear when triggering the modal/drawer.
|
|
17
|
+
*/
|
|
18
|
+
children?: React.ReactNode
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Give the inner content wrapper a class name (maps to `dnb-modal__content__inner`).
|
|
22
|
+
*/
|
|
23
|
+
className?: string
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface ModalHeaderBarState {
|
|
27
|
+
showShadow: boolean
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export default class ModalHeaderBar extends React.PureComponent<
|
|
31
|
+
ModalHeaderBarProps,
|
|
32
|
+
ModalHeaderBarState
|
|
33
|
+
> {
|
|
34
|
+
static contextType = ModalContext
|
|
35
|
+
_ref: React.RefObject<any>
|
|
36
|
+
intersectionObserver: IntersectionObserver
|
|
37
|
+
|
|
38
|
+
constructor(props) {
|
|
39
|
+
super(props)
|
|
40
|
+
this._ref = React.createRef()
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
state = { showShadow: false }
|
|
44
|
+
|
|
45
|
+
componentDidMount() {
|
|
46
|
+
if (
|
|
47
|
+
typeof window !== 'undefined' &&
|
|
48
|
+
typeof IntersectionObserver !== 'undefined' &&
|
|
49
|
+
this._ref.current
|
|
50
|
+
) {
|
|
51
|
+
const marginTop = -this._ref.current.clientHeight
|
|
52
|
+
this.intersectionObserver = new IntersectionObserver(
|
|
53
|
+
(entries) => {
|
|
54
|
+
const [entry] = entries
|
|
55
|
+
this.setState({
|
|
56
|
+
showShadow: !entry.isIntersecting,
|
|
57
|
+
})
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
rootMargin: `${marginTop}px 0px 0px 0px`,
|
|
61
|
+
threshold: 0.001,
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
this.intersectionObserver.observe(this._ref.current)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
componentWillUnmount() {
|
|
70
|
+
this.intersectionObserver?.disconnect()
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
render() {
|
|
74
|
+
const {
|
|
75
|
+
className = null,
|
|
76
|
+
children = null,
|
|
77
|
+
ref, //eslint-disable-line
|
|
78
|
+
...props
|
|
79
|
+
} = this.props
|
|
80
|
+
const { showShadow } = this.state
|
|
81
|
+
const {
|
|
82
|
+
title,
|
|
83
|
+
hide_close_button = false,
|
|
84
|
+
close_button_attributes,
|
|
85
|
+
onCloseClickHandler,
|
|
86
|
+
close_title,
|
|
87
|
+
} = this.context
|
|
88
|
+
|
|
89
|
+
if (!title && isTrue(hide_close_button) && !this._ref.current) {
|
|
90
|
+
return null
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<Section
|
|
95
|
+
style_type="white"
|
|
96
|
+
className={classnames(
|
|
97
|
+
'dnb-modal__header__bar',
|
|
98
|
+
showShadow && 'dnb-modal__header__bar--sticky',
|
|
99
|
+
className
|
|
100
|
+
)}
|
|
101
|
+
inner_ref={this._ref}
|
|
102
|
+
{...props}
|
|
103
|
+
>
|
|
104
|
+
<div className="dnb-modal__header__bar__inner">{children}</div>
|
|
105
|
+
|
|
106
|
+
{!isTrue(hide_close_button) && (
|
|
107
|
+
<div className="dnb-modal__header__bar__close">
|
|
108
|
+
<CloseButton
|
|
109
|
+
on_click={onCloseClickHandler}
|
|
110
|
+
close_title={close_title}
|
|
111
|
+
{...close_button_attributes}
|
|
112
|
+
/>
|
|
113
|
+
</div>
|
|
114
|
+
)}
|
|
115
|
+
</Section>
|
|
116
|
+
)
|
|
117
|
+
}
|
|
118
|
+
}
|