@helsenorge/designsystem-react 7.12.0 → 7.13.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 +8 -0
- package/_virtual/dynamic-import-helper.js +11 -4
- package/_virtual/dynamic-import-helper.js.map +1 -1
- package/_virtual/index.js +2 -2
- package/components/AnchorLink/AnchorLink.js +16 -16
- package/components/AnchorLink/AnchorLink.js.map +1 -1
- package/components/Avatar/Avatar.js +9 -9
- package/components/Avatar/Avatar.js.map +1 -1
- package/components/Badge/Badge.js +7 -7
- package/components/Badge/Badge.js.map +1 -1
- package/components/Badge/NotificationBadge.js +5 -5
- package/components/Badge/NotificationBadge.js.map +1 -1
- package/components/Button/Button.js +23 -23
- package/components/Button/Button.js.map +1 -1
- package/components/ButtonWithModal/ButtonWithModal.js +5 -5
- package/components/ButtonWithModal/ButtonWithModal.js.map +1 -1
- package/components/Checkbox/Checkbox.js +41 -42
- package/components/Checkbox/Checkbox.js.map +1 -1
- package/components/Checkbox/index.js +2 -3
- package/components/Checkbox/index.js.map +1 -1
- package/components/Checkbox/styles.module.scss +2 -2
- package/components/Close/Close.js +9 -9
- package/components/Close/Close.js.map +1 -1
- package/components/DictionaryTrigger/DictionaryTrigger.js +14 -15
- package/components/DictionaryTrigger/DictionaryTrigger.js.map +1 -1
- package/components/DictionaryTrigger/styles.module.scss +1 -2
- package/components/Dropdown/Dropdown.js +24 -24
- package/components/Dropdown/Dropdown.js.map +1 -1
- package/components/Dropdown/styles.module.scss +1 -1
- package/components/Duolist/Duolist.d.ts +3 -0
- package/components/Duolist/Duolist.js +45 -36
- package/components/Duolist/Duolist.js.map +1 -1
- package/components/Duolist/index.js +5 -5
- package/components/Duolist/styles.module.scss +4 -0
- package/components/Duolist/styles.module.scss.d.ts +1 -0
- package/components/EmptyState/EmptyState.js +3 -3
- package/components/EmptyState/EmptyState.js.map +1 -1
- package/components/EmptyState/NobodyHome.js +3 -3
- package/components/EmptyState/NobodyHome.js.map +1 -1
- package/components/ErrorWrapper/ErrorWrapper.js +4 -4
- package/components/ErrorWrapper/ErrorWrapper.js.map +1 -1
- package/components/ErrorWrapper/index.js +2 -3
- package/components/ErrorWrapper/index.js.map +1 -1
- package/components/Expander/Expander.js +10 -10
- package/components/Expander/Expander.js.map +1 -1
- package/components/Expander/styles.module.scss +1 -1
- package/components/ExpanderHierarchy/Expander.js +5 -5
- package/components/ExpanderHierarchy/Expander.js.map +1 -1
- package/components/ExpanderHierarchy/ExpanderButton.js +7 -7
- package/components/ExpanderHierarchy/ExpanderButton.js.map +1 -1
- package/components/ExpanderHierarchy/ExpanderHierarchy.js +13 -14
- package/components/ExpanderHierarchy/ExpanderHierarchy.js.map +1 -1
- package/components/ExpanderHierarchy/expander.module.scss +2 -2
- package/components/ExpanderList/ExpanderList.js +34 -35
- package/components/ExpanderList/ExpanderList.js.map +1 -1
- package/components/ExpanderList/index.js +2 -3
- package/components/ExpanderList/index.js.map +1 -1
- package/components/ExpanderList/styles.module.scss +1 -1
- package/components/FormExample/FormExample.d.ts +0 -1
- package/components/FormExample/FormExample.js +12 -12
- package/components/FormExample/FormExample.js.map +1 -1
- package/components/FormExample/index.js +5 -5
- package/components/FormGroup/FormGroup.js +37 -38
- package/components/FormGroup/FormGroup.js.map +1 -1
- package/components/FormGroup/index.js +2 -3
- package/components/FormGroup/index.js.map +1 -1
- package/components/FormLayout/FormLayout.js +16 -17
- package/components/FormLayout/FormLayout.js.map +1 -1
- package/components/FormLayout/index.js +4 -4
- package/components/GridExample/GridExample.js +3 -3
- package/components/GridExample/GridExample.js.map +1 -1
- package/components/GridExample/index.js +3 -4
- package/components/GridExample/index.js.map +1 -1
- package/components/HelpBubble/HelpBubble.js +26 -27
- package/components/HelpBubble/HelpBubble.js.map +1 -1
- package/components/HelpBubble/styles.module.scss +1 -1
- package/components/HelpBubbleExample/HelpBubbleExample.js +3 -3
- package/components/HelpBubbleExample/HelpBubbleExample.js.map +1 -1
- package/components/HelpPanel/HelpPanel.js +11 -11
- package/components/HelpPanel/HelpPanel.js.map +1 -1
- package/components/HelpQuestion/HelpQuestion.js +16 -17
- package/components/HelpQuestion/HelpQuestion.js.map +1 -1
- package/components/HighlightBox/HighlightBox.js +16 -16
- package/components/HighlightBox/HighlightBox.js.map +1 -1
- package/components/HighlightBox/styles.module.scss +4 -4
- package/components/HorizontalScroll/HorizontalScroll.js +4 -4
- package/components/HorizontalScroll/HorizontalScroll.js.map +1 -1
- package/components/HorizontalScroll/index.js +2 -3
- package/components/HorizontalScroll/index.js.map +1 -1
- package/components/Illustration/Illustration.js +16 -17
- package/components/Illustration/Illustration.js.map +1 -1
- package/components/Illustration/index.js +5 -5
- package/components/Input/Input.js +65 -67
- package/components/Input/Input.js.map +1 -1
- package/components/Label/Label.js +16 -16
- package/components/Label/Label.js.map +1 -1
- package/components/LazyIcon/ErrorBoundary.js +7 -8
- package/components/LazyIcon/ErrorBoundary.js.map +1 -1
- package/components/LazyIcon/LazyIcon.js +4 -4
- package/components/LazyIcon/LazyIcon.js.map +1 -1
- package/components/LazyIcon/index.js +3 -3
- package/components/LazyIllustration/LazyIllustration.js +10 -10
- package/components/LazyIllustration/LazyIllustration.js.map +1 -1
- package/components/LazyIllustration/index.js +5 -5
- package/components/LinkList/LinkList.js +36 -37
- package/components/LinkList/LinkList.js.map +1 -1
- package/components/LinkList/index.js +2 -3
- package/components/LinkList/index.js.map +1 -1
- package/components/List/List.js +7 -8
- package/components/List/List.js.map +1 -1
- package/components/ListHeader/ListHeader.js +1 -1
- package/components/ListHeader/ListHeader.js.map +1 -1
- package/components/ListHeader/ListHeaderText/ListHeaderText.js +18 -19
- package/components/ListHeader/ListHeaderText/ListHeaderText.js.map +1 -1
- package/components/ListHeader/ListHeaderText/index.js +2 -3
- package/components/ListHeader/ListHeaderText/index.js.map +1 -1
- package/components/Loader/Loader.js +2 -2
- package/components/Loader/Loader.js.map +1 -1
- package/components/Logo/Logo.js +5 -5
- package/components/Logo/Logo.js.map +1 -1
- package/components/MaxCharacters/MaxCharacters.js +5 -5
- package/components/MaxCharacters/MaxCharacters.js.map +1 -1
- package/components/Modal/Modal.js +32 -33
- package/components/Modal/Modal.js.map +1 -1
- package/components/Modal/styles.module.scss +8 -8
- package/components/NotificationPanel/NotificationPanel.js +14 -14
- package/components/NotificationPanel/NotificationPanel.js.map +1 -1
- package/components/NotificationPanel/styles.module.scss +3 -3
- package/components/Panel/Panel.js +25 -25
- package/components/Panel/Panel.js.map +1 -1
- package/components/Panel/styles.module.scss +3 -3
- package/components/PanelList/PanelList.js +8 -8
- package/components/PanelList/PanelList.js.map +1 -1
- package/components/PopMenu/PopMenu.js +14 -14
- package/components/PopMenu/PopMenu.js.map +1 -1
- package/components/PopMenu/index.js +3 -3
- package/components/PopOver/PopOver.js +27 -28
- package/components/PopOver/PopOver.js.map +1 -1
- package/components/Portal/index.js.map +1 -1
- package/components/Progressbar/Progressbar.js +13 -13
- package/components/Progressbar/Progressbar.js.map +1 -1
- package/components/PromoPanel/PromoPanel.js +16 -16
- package/components/PromoPanel/PromoPanel.js.map +1 -1
- package/components/RadioButton/RadioButton.js +52 -53
- package/components/RadioButton/RadioButton.js.map +1 -1
- package/components/RadioButton/index.js +4 -4
- package/components/RadioButton/styles.module.scss +2 -2
- package/components/Select/Select.js +21 -21
- package/components/Select/Select.js.map +1 -1
- package/components/Select/index.js +2 -3
- package/components/Select/index.js.map +1 -1
- package/components/ServiceMessage/ServiceMessage.js +30 -30
- package/components/ServiceMessage/ServiceMessage.js.map +1 -1
- package/components/ServiceMessage/styles.module.scss +10 -10
- package/components/SharingStatus/SharingStatus.js +7 -7
- package/components/SharingStatus/SharingStatus.js.map +1 -1
- package/components/Slider/Slider.js +15 -17
- package/components/Slider/Slider.js.map +1 -1
- package/components/Slider/index.js +2 -3
- package/components/Slider/index.js.map +1 -1
- package/components/Spacer/Spacer.js +4 -4
- package/components/Spacer/Spacer.js.map +1 -1
- package/components/StatusDot/StatusDot.js +8 -8
- package/components/StatusDot/StatusDot.js.map +1 -1
- package/components/Step/Step.js +10 -10
- package/components/Step/Step.js.map +1 -1
- package/components/StepButtons/StepButtons.js +4 -4
- package/components/StepButtons/StepButtons.js.map +1 -1
- package/components/StepButtons/index.js +2 -3
- package/components/StepButtons/index.js.map +1 -1
- package/components/Stepper/Dot.js +3 -3
- package/components/Stepper/Dot.js.map +1 -1
- package/components/Stepper/DotList.js +4 -4
- package/components/Stepper/DotList.js.map +1 -1
- package/components/Stepper/Stepper.js +10 -10
- package/components/Stepper/Stepper.js.map +1 -1
- package/components/Table/Table.js +1 -1
- package/components/Table/TableBody/TableBody.js +3 -3
- package/components/Table/TableBody/TableBody.js.map +1 -1
- package/components/Table/TableBody/index.js +3 -4
- package/components/Table/TableBody/index.js.map +1 -1
- package/components/Table/TableCell/TableCell.js +10 -10
- package/components/Table/TableCell/TableCell.js.map +1 -1
- package/components/Table/TableCell/index.js +4 -4
- package/components/Table/TableExpandedRow/TableExpandedRow.js +8 -8
- package/components/Table/TableExpandedRow/TableExpandedRow.js.map +1 -1
- package/components/Table/TableExpandedRow/index.js +3 -4
- package/components/Table/TableExpandedRow/index.js.map +1 -1
- package/components/Table/TableExpanderCell/TableExpanderCell.js +3 -3
- package/components/Table/TableExpanderCell/TableExpanderCell.js.map +1 -1
- package/components/Table/TableExpanderCell/TableExpanderCellMobile.js +11 -11
- package/components/Table/TableExpanderCell/TableExpanderCellMobile.js.map +1 -1
- package/components/Table/TableExpanderCell/index.js +3 -4
- package/components/Table/TableExpanderCell/index.js.map +1 -1
- package/components/Table/TableHead/TableHead.js +9 -9
- package/components/Table/TableHead/TableHead.js.map +1 -1
- package/components/Table/TableHead/index.js +4 -4
- package/components/Table/TableHeadCell/TableHeadCell.js +15 -15
- package/components/Table/TableHeadCell/TableHeadCell.js.map +1 -1
- package/components/Table/TableHeadCell/index.js +4 -4
- package/components/Table/TableRow/TableRow.js +16 -16
- package/components/Table/TableRow/TableRow.js.map +1 -1
- package/components/Table/TableRow/index.js +3 -4
- package/components/Table/TableRow/index.js.map +1 -1
- package/components/Table/styles.module.scss +3 -3
- package/components/Table/utils.d.ts +1 -1
- package/components/Tabs/Tab.js +2 -2
- package/components/Tabs/Tab.js.map +1 -1
- package/components/Tabs/TabList/TabList.js +43 -38
- package/components/Tabs/TabList/TabList.js.map +1 -1
- package/components/Tabs/TabList/styles.module.scss +14 -4
- package/components/Tabs/TabPanel/TabPanel.d.ts +5 -1
- package/components/Tabs/TabPanel/TabPanel.js +13 -9
- package/components/Tabs/TabPanel/TabPanel.js.map +1 -1
- package/components/Tabs/TabPanel/styles.module.scss +48 -6
- package/components/Tabs/TabPanel/styles.module.scss.d.ts +4 -0
- package/components/Tabs/Tabs.d.ts +8 -4
- package/components/Tabs/Tabs.js +85 -16
- package/components/Tabs/Tabs.js.map +1 -1
- package/components/Tabs/styles.module.scss +38 -2
- package/components/Tabs/styles.module.scss.d.ts +7 -1
- package/components/Tag/Tag.js +3 -3
- package/components/Tag/Tag.js.map +1 -1
- package/components/TagList/TagList.js +1 -1
- package/components/TagList/TagList.js.map +1 -1
- package/components/Textarea/Textarea.js +48 -49
- package/components/Textarea/Textarea.js.map +1 -1
- package/components/Tile/Tile.js +14 -15
- package/components/Tile/Tile.js.map +1 -1
- package/components/Tile/index.js +2 -3
- package/components/Tile/index.js.map +1 -1
- package/components/Title/Title.js +10 -10
- package/components/Title/Title.js.map +1 -1
- package/components/Title/index.js +4 -4
- package/components/Tooltip/Tooltip.js +4 -4
- package/components/Tooltip/Tooltip.js.map +1 -1
- package/components/Tooltip/TooltipWord/TooltipWord.js +17 -18
- package/components/Tooltip/TooltipWord/TooltipWord.js.map +1 -1
- package/components/Tooltip/index.js +5 -5
- package/components/TooltipExample/TooltipExample.js +4 -4
- package/components/TooltipExample/TooltipExample.js.map +1 -1
- package/components/Trigger/HelpSign.js +3 -3
- package/components/Trigger/HelpSign.js.map +1 -1
- package/components/Trigger/Trigger.js +25 -26
- package/components/Trigger/Trigger.js.map +1 -1
- package/components/Validation/ErrorList.js +5 -5
- package/components/Validation/ErrorList.js.map +1 -1
- package/components/Validation/ErrorListItem.js +8 -8
- package/components/Validation/ErrorListItem.js.map +1 -1
- package/components/Validation/Validation.js +13 -14
- package/components/Validation/Validation.js.map +1 -1
- package/components/Validation/ValidationSummary.js +4 -4
- package/components/Validation/ValidationSummary.js.map +1 -1
- package/components/Validation/index.js +3 -4
- package/components/Validation/index.js.map +1 -1
- package/components/Validation/types.d.ts +0 -1
- package/constants.d.ts +2 -1
- package/constants.js +1 -1
- package/constants.js.map +1 -1
- package/hooks/useIcons.d.ts +0 -1
- package/hooks/useIcons.js +1 -1
- package/hooks/useLayoutEvent.js +1 -2
- package/hooks/useLayoutEvent.js.map +1 -1
- package/hooks/useSticky.d.ts +1 -1
- package/package.json +1 -1
- package/scss/_palette.scss +1 -0
- package/scss/typography.module.scss +1 -1
- package/scss/typography.module.scss.d.ts +1 -1
- package/scss/typography.stories.tsx +157 -0
- package/theme/currys/color.d.ts +1 -1
- package/utils/accessibility.d.ts +2 -1
- package/utils/accessibility.js +1 -1
- package/utils/accessibility.js.map +1 -1
- package/utils/component.d.ts +3 -3
- package/utils/refs.d.ts +1 -2
- package/_virtual/index2.js +0 -5
- package/_virtual/index2.js.map +0 -1
- package/_virtual/index3.js +0 -5
- package/_virtual/index3.js.map +0 -1
- package/components/AnchorLink/AnchorLink.stories.d.ts +0 -31
- package/components/Avatar/Avatar.stories.d.ts +0 -36
- package/components/Badge/Badge.stories.d.ts +0 -42
- package/components/Button/Button.stories.d.ts +0 -56
- package/components/Checkbox/Checkbox.stories.d.ts +0 -54
- package/components/Close/Close.stories.d.ts +0 -29
- package/components/DictionaryTrigger/DictionaryTrigger.stories.d.ts +0 -30
- package/components/Dropdown/Dropdown.stories.d.ts +0 -67
- package/components/Duolist/Duolist.stories.d.ts +0 -32
- package/components/EmptyState/EmptyState.stories.d.ts +0 -26
- package/components/Expander/Expander.stories.d.ts +0 -60
- package/components/ExpanderHierarchy/ExpanderHierarchy.stories.d.ts +0 -44
- package/components/ExpanderList/ExpanderList.stories.d.ts +0 -59
- package/components/FormGroup/FormGroup.stories.d.ts +0 -50
- package/components/FormLayout/FormLayout.stories.d.ts +0 -32
- package/components/HelpBubble/HelpBubble.stories.d.ts +0 -46
- package/components/HelpPanel/HelpPanel.stories.d.ts +0 -31
- package/components/HelpQuestion/HelpQuestion.stories.d.ts +0 -29
- package/components/HighlightBox/HighlightBox.stories.d.ts +0 -42
- package/components/Icon/Icon.stories.d.ts +0 -38
- package/components/Illustration/Illustration.stories.d.ts +0 -34
- package/components/Illustration/Illustrations.stories.d.ts +0 -41
- package/components/Input/Input.stories.d.ts +0 -94
- package/components/Label/Label.stories.d.ts +0 -25
- package/components/LazyIcon/LazyIcon.stories.d.ts +0 -25
- package/components/LazyIllustration/LazyIllustration.stories.d.ts +0 -38
- package/components/LinkList/LinkList.stories.d.ts +0 -49
- package/components/List/List.stories.d.ts +0 -52
- package/components/Loader/Loader.stories.d.ts +0 -31
- package/components/Logo/Logo.stories.d.ts +0 -37
- package/components/Modal/Modal.stories.d.ts +0 -76
- package/components/NotificationPanel/NotificationPanel.stories.d.ts +0 -60
- package/components/Panel/Panel.stories.d.ts +0 -89
- package/components/PanelList/PanelList.stories.d.ts +0 -27
- package/components/PopMenu/PopMenu.stories.d.ts +0 -39
- package/components/PopOver/PopOver.stories.d.ts +0 -38
- package/components/Progressbar/Progressbar.stories.d.ts +0 -43
- package/components/PromoPanel/PromoPanel.stories.d.ts +0 -45
- package/components/RadioButton/RadioButton.stories.d.ts +0 -57
- package/components/Select/Select.stories.d.ts +0 -38
- package/components/ServiceMessage/ServiceMessage.stories.d.ts +0 -71
- package/components/SharingStatus/SharingStatus.stories.d.ts +0 -31
- package/components/Slider/Slider.stories.d.ts +0 -52
- package/components/Spacer/Spacer.stories.d.ts +0 -17
- package/components/StatusDot/StatusDot.stories.d.ts +0 -31
- package/components/Step/Step.stories.d.ts +0 -32
- package/components/StepButtons/StepButtons.stories.d.ts +0 -19
- package/components/Stepper/Stepper.stories.d.ts +0 -38
- package/components/Table/Table.stories.d.ts +0 -90
- package/components/Tabs/Tabs.stories.d.ts +0 -50
- package/components/Tag/Tag.stories.d.ts +0 -48
- package/components/TagList/TagList.stories.d.ts +0 -17
- package/components/Textarea/Textarea.stories.d.ts +0 -94
- package/components/Tile/Tile.stories.d.ts +0 -65
- package/components/Title/Title.stories.d.ts +0 -40
- package/components/Tooltip/Tooltip.stories.d.ts +0 -34
- package/components/Trigger/Trigger.stories.d.ts +0 -52
- package/components/Validation/Validation.stories.d.ts +0 -37
- package/hoc/withBreakpoint/withBreakpoint.stories.d.ts +0 -17
- package/hooks/useBreakpoint.stories.d.ts +0 -16
- package/hooks/useDelayedState.stories.d.ts +0 -27
- package/hooks/useElementList.stories.d.ts +0 -16
- package/hooks/useFocusToggle.stories.d.ts +0 -16
- package/hooks/useFocusTrap.stories.d.ts +0 -16
- package/hooks/useFocusableElements.stories.d.ts +0 -16
- package/hooks/useHover.stories.d.ts +0 -16
- package/hooks/useIntersectionObserver.stories.d.ts +0 -16
- package/hooks/useInterval.stories.d.ts +0 -16
- package/hooks/useIsVisible.stories.d.ts +0 -27
- package/hooks/useKeyboardEvent.stories.d.ts +0 -16
- package/hooks/useLayoutEvent.stories.d.ts +0 -16
- package/hooks/useOutsideEvent.stories.d.ts +0 -16
- package/hooks/usePseudoClasses.stories.d.ts +0 -16
- package/hooks/useResizeObserver.stories.d.ts +0 -16
- package/hooks/useRovingFocus.stories.d.ts +0 -17
- package/hooks/useSize.stories.d.ts +0 -16
- package/hooks/useSticky.stories.d.ts +0 -16
- package/hooks/useUuid.stories.d.ts +0 -16
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormExample.js","sources":["../../../src/components/FormExample/FormExample.tsx"],"sourcesContent":["import React from 'react';\n\nimport { useForm } from 'react-hook-form';\n\nimport { FormSize } from '../../constants';\nimport { isTest } from '../../utils/environment';\nimport Button from '../Button';\nimport Checkbox from '../Checkbox';\nimport FormGroup from '../FormGroup/FormGroup';\nimport FormLayout, { FormLayoutColumns } from '../FormLayout';\nimport Hospital from '../Icons/Hospital';\nimport Input from '../Input';\nimport Label from '../Label';\nimport RadioButton from '../RadioButton';\nimport Select from '../Select';\nimport Spacer from '../Spacer';\nimport Textarea from '../Textarea';\nimport Validation from '../Validation';\n\nexport interface FormExampleProps {\n exampleType: FormExampleVariants;\n size?: keyof typeof FormSize;\n}\n\nexport enum FormExampleVariants {\n formgroup = 'formgroup',\n checkbox = 'checkbox',\n radiobutton = 'radiobutton',\n textarea = 'textarea',\n input = 'input',\n select = 'select',\n}\n\ninterface FormExampleData {\n colour: string;\n sizes: string[];\n positions: string;\n story: string;\n name: string;\n monster: string[];\n}\n\nexport const FormExample = (props: FormExampleProps): JSX.Element => {\n const { exampleType = FormExampleVariants.formgroup } = props;\n const {\n register,\n handleSubmit,\n formState: { errors },\n } = useForm<FormExampleData>();\n\n const defaultDate = new Date();\n defaultDate.setHours(0);\n defaultDate.setMinutes(0);\n defaultDate.setSeconds(0);\n const minDate = new Date();\n minDate.setDate(defaultDate.getDate() - 5);\n minDate.setHours(6);\n minDate.setMinutes(10);\n minDate.setSeconds(0);\n const maxDate = new Date();\n maxDate.setDate(defaultDate.getDate() + 5);\n maxDate.setHours(22);\n maxDate.setMinutes(0);\n maxDate.setSeconds(0);\n\n const colorErrorMessage = 'Du må velge minst én farge';\n const sizeErrorMessage = 'Du må velge minst to størrelser';\n const positionErrorMessage = 'Du må velge minst én plassering';\n const storyErrorMessage = 'Historien må være på maks 40 tegn';\n const nameErrorMessage = 'Navn må fylles ut';\n const monsterErrorMessage = 'Du må velge \"Frankenstein\"';\n\n const requireTwo = (value: Array<string>): true | string => {\n return value.length >= 2 || sizeErrorMessage;\n };\n\n const requireFrankenstein = (value: Array<string>): true | string => {\n return value.toString() === 'Frankenstein' || monsterErrorMessage;\n };\n\n const color = () => (\n <FormGroup\n title={'FormGroup-tittel'}\n legend={'Farge'}\n error={errors.colour ? errors.colour.message : undefined}\n errorTextId=\"error\"\n size={props.size}\n >\n <FormLayout maxColumns={FormLayoutColumns.two}>\n <Checkbox\n inputId=\"colour1\"\n label={<Label labelTexts={[{ text: 'Blueberry' }]} />}\n {...register('colour', { required: colorErrorMessage })}\n />\n <Checkbox\n inputId=\"colour2\"\n label={<Label labelTexts={[{ text: 'Cherry' }]} />}\n {...register('colour', { required: colorErrorMessage })}\n />\n <Checkbox\n inputId=\"colour3\"\n label={<Label labelTexts={[{ text: 'Neutral' }]} />}\n {...register('colour', { required: colorErrorMessage })}\n />\n </FormLayout>\n </FormGroup>\n );\n\n const size = () => (\n <FormGroup legend={'Størrelser'} error={errors.sizes ? errors.sizes.message : undefined} size={props.size} errorTextId=\"error1\">\n <Checkbox inputId=\"sizes1\" label={<Label labelTexts={[{ text: 'Small' }]} />} {...register('sizes', { validate: requireTwo })} />\n <Checkbox inputId=\"sizes2\" label={<Label labelTexts={[{ text: 'Medium' }]} />} {...register('sizes', { validate: requireTwo })} />\n <Checkbox inputId=\"sizes3\" label={<Label labelTexts={[{ text: 'Large' }]} />} {...register('sizes', { validate: requireTwo })} />\n </FormGroup>\n );\n\n const position = () => (\n <FormGroup\n legend={'Plassering'}\n error={errors.positions ? (errors.positions.message as string) : undefined}\n size={props.size}\n errorTextId=\"error2\"\n >\n <RadioButton\n inputId=\"positions1\"\n label={<Label labelTexts={[{ text: 'Venstre' }]} />}\n {...register('positions', { required: positionErrorMessage })}\n />\n <RadioButton\n inputId=\"positions2\"\n label={<Label labelTexts={[{ text: 'Høyre' }]} />}\n {...register('positions', { required: positionErrorMessage })}\n />\n <RadioButton\n inputId=\"positions3\"\n label={<Label labelTexts={[{ text: 'Midten' }]} />}\n {...register('positions', { required: positionErrorMessage })}\n />\n </FormGroup>\n );\n\n const story = () => (\n <FormGroup error={errors.story ? (errors.story.message as string) : undefined} errorTextId=\"error3\">\n <Textarea\n defaultValue={`Dette er en test \\n\\n Hello \\n\\n test \\n\\n test test`}\n grow\n maxCharacters={40}\n minRows={5}\n label={<Label labelTexts={[{ text: 'Historie', type: 'semibold' }]} />}\n textareaId=\"story\"\n {...register('story', { maxLength: { value: 40, message: storyErrorMessage } })}\n />\n </FormGroup>\n );\n\n const name = () => (\n <FormGroup size={props.size} error={errors.name ? (errors.name.message as string) : undefined} errorTextId=\"error4\">\n <Input\n label={<Label labelTexts={[{ text: 'Navn', type: 'semibold' }]} />}\n placeholder={'Skriv noe!'}\n icon={Hospital}\n inputId=\"name\"\n {...register('name', { required: nameErrorMessage })}\n />\n </FormGroup>\n );\n\n const monster = () => (\n <FormGroup size={props.size} error={errors.monster ? (errors.monster.message as string) : undefined} errorTextId=\"error5\">\n <Select\n selectId=\"monster\"\n label={<Label labelTexts={[{ text: 'Velg et monster', type: 'semibold' }]} />}\n {...register('monster', { validate: requireFrankenstein })}\n >\n <option value={'Troll'}>{'Troll'}</option>\n <option value={'Frankenstein'}>{'Frankenstein'}</option>\n </Select>\n </FormGroup>\n );\n\n const getFormExample = () => {\n if (exampleType === FormExampleVariants.formgroup) {\n return (\n <>\n {color()}\n {size()}\n {position()}\n {story()}\n {name()}\n {monster()}\n </>\n );\n } else if (exampleType === FormExampleVariants.checkbox) {\n return <>{color()}</>;\n } else if (exampleType === FormExampleVariants.radiobutton) {\n return <>{position()}</>;\n } else if (exampleType === FormExampleVariants.textarea) {\n return <>{story()}</>;\n } else if (exampleType === FormExampleVariants.input) {\n return <>{name()}</>;\n } else if (exampleType === FormExampleVariants.select) {\n return <>{monster()}</>;\n }\n };\n\n return (\n <form\n noValidate\n onSubmit={handleSubmit(data => {\n // eslint-disable-next-line no-console\n !isTest() && console.log(data);\n })}\n >\n <Validation size={props.size} errorTitle={'Sjekk at alt er riktig utfylt:'} errors={errors}>\n {getFormExample()}\n </Validation>\n <Spacer />\n <Button type=\"submit\">{'Send inn'}</Button>\n </form>\n );\n};\n\nexport default FormExample;\n"],"names":["FormExampleVariants","FormExample","props","exampleType","register","handleSubmit","errors","useForm","defaultDate","minDate","maxDate","colorErrorMessage","sizeErrorMessage","positionErrorMessage","storyErrorMessage","nameErrorMessage","monsterErrorMessage","requireTwo","value","requireFrankenstein","color","React","FormGroup","FormLayout","FormLayoutColumns","Checkbox","Label","size","position","RadioButton","story","Textarea","name","Input","Hospital","monster","Select","getFormExample","data","isTest","Validation","Spacer","Button","FormExample$1"],"mappings":";;;;;;;;;;;;;;;AAwBY,IAAAA,sBAAAA,OACVA,EAAA,YAAY,aACZA,EAAA,WAAW,YACXA,EAAA,cAAc,eACdA,EAAA,WAAW,YACXA,EAAA,QAAQ,SACRA,EAAA,SAAS,UANCA,IAAAA,KAAA,CAAA,CAAA;AAkBC,MAAAC,IAAc,CAACC,MAAyC;AAC7D,QAAA;AAAA,IAAE,aAAAC,IAAc;AAAA;AAAA,EAAkC,IAAAD,GAClD;AAAA,IACJ,UAAAE;AAAA,IACA,cAAAC;AAAA,IACA,WAAW,EAAE,QAAAC,EAAO;AAAA,MAClBC,EAAyB,GAEvBC,wBAAkB;AACxB,EAAAA,EAAY,SAAS,CAAC,GACtBA,EAAY,WAAW,CAAC,GACxBA,EAAY,WAAW,CAAC;AAClB,QAAAC,wBAAc;AACpB,EAAAA,EAAQ,QAAQD,EAAY,QAAQ,IAAI,CAAC,GACzCC,EAAQ,SAAS,CAAC,GAClBA,EAAQ,WAAW,EAAE,GACrBA,EAAQ,WAAW,CAAC;AACd,QAAAC,wBAAc;AACpB,EAAAA,EAAQ,QAAQF,EAAY,QAAQ,IAAI,CAAC,GACzCE,EAAQ,SAAS,EAAE,GACnBA,EAAQ,WAAW,CAAC,GACpBA,EAAQ,WAAW,CAAC;AAEpB,QAAMC,IAAoB,8BACpBC,IAAmB,mCACnBC,IAAuB,mCACvBC,IAAoB,qCACpBC,IAAmB,qBACnBC,IAAsB,8BAEtBC,IAAa,CAACC,MACXA,EAAM,UAAU,KAAKN,GAGxBO,IAAsB,CAACD,MACpBA,EAAM,eAAe,kBAAkBF,GAG1CI,IAAQ,MACZC,gBAA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AAGxC,GAEAC,KAAe1C;"}
|
|
1
|
+
{"version":3,"file":"FormExample.js","sources":["../../../src/components/FormExample/FormExample.tsx"],"sourcesContent":["import React from 'react';\n\nimport { useForm } from 'react-hook-form';\n\nimport { FormSize } from '../../constants';\nimport { isTest } from '../../utils/environment';\nimport Button from '../Button';\nimport Checkbox from '../Checkbox';\nimport FormGroup from '../FormGroup/FormGroup';\nimport FormLayout, { FormLayoutColumns } from '../FormLayout';\nimport Hospital from '../Icons/Hospital';\nimport Input from '../Input';\nimport Label from '../Label';\nimport RadioButton from '../RadioButton';\nimport Select from '../Select';\nimport Spacer from '../Spacer';\nimport Textarea from '../Textarea';\nimport Validation from '../Validation';\n\nexport interface FormExampleProps {\n exampleType: FormExampleVariants;\n size?: keyof typeof FormSize;\n}\n\nexport enum FormExampleVariants {\n formgroup = 'formgroup',\n checkbox = 'checkbox',\n radiobutton = 'radiobutton',\n textarea = 'textarea',\n input = 'input',\n select = 'select',\n}\n\ninterface FormExampleData {\n colour: string;\n sizes: string[];\n positions: string;\n story: string;\n name: string;\n monster: string[];\n}\n\nexport const FormExample = (props: FormExampleProps): JSX.Element => {\n const { exampleType = FormExampleVariants.formgroup } = props;\n const {\n register,\n handleSubmit,\n formState: { errors },\n } = useForm<FormExampleData>();\n\n const defaultDate = new Date();\n defaultDate.setHours(0);\n defaultDate.setMinutes(0);\n defaultDate.setSeconds(0);\n const minDate = new Date();\n minDate.setDate(defaultDate.getDate() - 5);\n minDate.setHours(6);\n minDate.setMinutes(10);\n minDate.setSeconds(0);\n const maxDate = new Date();\n maxDate.setDate(defaultDate.getDate() + 5);\n maxDate.setHours(22);\n maxDate.setMinutes(0);\n maxDate.setSeconds(0);\n\n const colorErrorMessage = 'Du må velge minst én farge';\n const sizeErrorMessage = 'Du må velge minst to størrelser';\n const positionErrorMessage = 'Du må velge minst én plassering';\n const storyErrorMessage = 'Historien må være på maks 40 tegn';\n const nameErrorMessage = 'Navn må fylles ut';\n const monsterErrorMessage = 'Du må velge \"Frankenstein\"';\n\n const requireTwo = (value: Array<string>): true | string => {\n return value.length >= 2 || sizeErrorMessage;\n };\n\n const requireFrankenstein = (value: Array<string>): true | string => {\n return value.toString() === 'Frankenstein' || monsterErrorMessage;\n };\n\n const color = () => (\n <FormGroup\n title={'FormGroup-tittel'}\n legend={'Farge'}\n error={errors.colour ? errors.colour.message : undefined}\n errorTextId=\"error\"\n size={props.size}\n >\n <FormLayout maxColumns={FormLayoutColumns.two}>\n <Checkbox\n inputId=\"colour1\"\n label={<Label labelTexts={[{ text: 'Blueberry' }]} />}\n {...register('colour', { required: colorErrorMessage })}\n />\n <Checkbox\n inputId=\"colour2\"\n label={<Label labelTexts={[{ text: 'Cherry' }]} />}\n {...register('colour', { required: colorErrorMessage })}\n />\n <Checkbox\n inputId=\"colour3\"\n label={<Label labelTexts={[{ text: 'Neutral' }]} />}\n {...register('colour', { required: colorErrorMessage })}\n />\n </FormLayout>\n </FormGroup>\n );\n\n const size = () => (\n <FormGroup legend={'Størrelser'} error={errors.sizes ? errors.sizes.message : undefined} size={props.size} errorTextId=\"error1\">\n <Checkbox inputId=\"sizes1\" label={<Label labelTexts={[{ text: 'Small' }]} />} {...register('sizes', { validate: requireTwo })} />\n <Checkbox inputId=\"sizes2\" label={<Label labelTexts={[{ text: 'Medium' }]} />} {...register('sizes', { validate: requireTwo })} />\n <Checkbox inputId=\"sizes3\" label={<Label labelTexts={[{ text: 'Large' }]} />} {...register('sizes', { validate: requireTwo })} />\n </FormGroup>\n );\n\n const position = () => (\n <FormGroup\n legend={'Plassering'}\n error={errors.positions ? (errors.positions.message as string) : undefined}\n size={props.size}\n errorTextId=\"error2\"\n >\n <RadioButton\n inputId=\"positions1\"\n label={<Label labelTexts={[{ text: 'Venstre' }]} />}\n {...register('positions', { required: positionErrorMessage })}\n />\n <RadioButton\n inputId=\"positions2\"\n label={<Label labelTexts={[{ text: 'Høyre' }]} />}\n {...register('positions', { required: positionErrorMessage })}\n />\n <RadioButton\n inputId=\"positions3\"\n label={<Label labelTexts={[{ text: 'Midten' }]} />}\n {...register('positions', { required: positionErrorMessage })}\n />\n </FormGroup>\n );\n\n const story = () => (\n <FormGroup error={errors.story ? (errors.story.message as string) : undefined} errorTextId=\"error3\">\n <Textarea\n defaultValue={`Dette er en test \\n\\n Hello \\n\\n test \\n\\n test test`}\n grow\n maxCharacters={40}\n minRows={5}\n label={<Label labelTexts={[{ text: 'Historie', type: 'semibold' }]} />}\n textareaId=\"story\"\n {...register('story', { maxLength: { value: 40, message: storyErrorMessage } })}\n />\n </FormGroup>\n );\n\n const name = () => (\n <FormGroup size={props.size} error={errors.name ? (errors.name.message as string) : undefined} errorTextId=\"error4\">\n <Input\n label={<Label labelTexts={[{ text: 'Navn', type: 'semibold' }]} />}\n placeholder={'Skriv noe!'}\n icon={Hospital}\n inputId=\"name\"\n {...register('name', { required: nameErrorMessage })}\n />\n </FormGroup>\n );\n\n const monster = () => (\n <FormGroup size={props.size} error={errors.monster ? (errors.monster.message as string) : undefined} errorTextId=\"error5\">\n <Select\n selectId=\"monster\"\n label={<Label labelTexts={[{ text: 'Velg et monster', type: 'semibold' }]} />}\n {...register('monster', { validate: requireFrankenstein })}\n >\n <option value={'Troll'}>{'Troll'}</option>\n <option value={'Frankenstein'}>{'Frankenstein'}</option>\n </Select>\n </FormGroup>\n );\n\n const getFormExample = () => {\n if (exampleType === FormExampleVariants.formgroup) {\n return (\n <>\n {color()}\n {size()}\n {position()}\n {story()}\n {name()}\n {monster()}\n </>\n );\n } else if (exampleType === FormExampleVariants.checkbox) {\n return <>{color()}</>;\n } else if (exampleType === FormExampleVariants.radiobutton) {\n return <>{position()}</>;\n } else if (exampleType === FormExampleVariants.textarea) {\n return <>{story()}</>;\n } else if (exampleType === FormExampleVariants.input) {\n return <>{name()}</>;\n } else if (exampleType === FormExampleVariants.select) {\n return <>{monster()}</>;\n }\n };\n\n return (\n <form\n noValidate\n onSubmit={handleSubmit(data => {\n // eslint-disable-next-line no-console\n !isTest() && console.log(data);\n })}\n >\n <Validation size={props.size} errorTitle={'Sjekk at alt er riktig utfylt:'} errors={errors}>\n {getFormExample()}\n </Validation>\n <Spacer />\n <Button type=\"submit\">{'Send inn'}</Button>\n </form>\n );\n};\n\nexport default FormExample;\n"],"names":["FormExampleVariants","FormExample","props","exampleType","register","handleSubmit","errors","useForm","defaultDate","minDate","maxDate","colorErrorMessage","sizeErrorMessage","positionErrorMessage","storyErrorMessage","nameErrorMessage","monsterErrorMessage","requireTwo","value","requireFrankenstein","color","React","FormGroup","FormLayout","FormLayoutColumns","Checkbox","Label","size","position","RadioButton","story","Textarea","name","Input","Hospital","monster","Select","getFormExample","data","isTest","Validation","Spacer","Button"],"mappings":";;;;;;;;;;;;;;;AAwBY,IAAAA,sBAAAA,OACVA,EAAA,YAAY,aACZA,EAAA,WAAW,YACXA,EAAA,cAAc,eACdA,EAAA,WAAW,YACXA,EAAA,QAAQ,SACRA,EAAA,SAAS,UANCA,IAAAA,KAAA,CAAA,CAAA;AAkBC,MAAAC,KAAc,CAACC,MAAyC;AAC7D,QAAA;AAAA,IAAE,aAAAC,IAAc;AAAA;AAAA,EAAkC,IAAAD,GAClD;AAAA,IACJ,UAAAE;AAAA,IACA,cAAAC;AAAA,IACA,WAAW,EAAE,QAAAC,EAAO;AAAA,MAClBC,EAAyB,GAEvBC,wBAAkB;AACxB,EAAAA,EAAY,SAAS,CAAC,GACtBA,EAAY,WAAW,CAAC,GACxBA,EAAY,WAAW,CAAC;AAClB,QAAAC,wBAAc;AACpB,EAAAA,EAAQ,QAAQD,EAAY,QAAQ,IAAI,CAAC,GACzCC,EAAQ,SAAS,CAAC,GAClBA,EAAQ,WAAW,EAAE,GACrBA,EAAQ,WAAW,CAAC;AACd,QAAAC,wBAAc;AACpB,EAAAA,EAAQ,QAAQF,EAAY,QAAQ,IAAI,CAAC,GACzCE,EAAQ,SAAS,EAAE,GACnBA,EAAQ,WAAW,CAAC,GACpBA,EAAQ,WAAW,CAAC;AAEpB,QAAMC,IAA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,gBAAAA,EAAA,cAACmB,KAAW,MAAMtC,EAAM,MAAM,YAAY,kCAAkC,QAAAI,EACzE,GAAA+B,EAAA,CACH;AAAA,oCACCI,GAAO,IAAA;AAAA,IACPpB,gBAAAA,EAAA,cAAAqB,GAAA,EAAO,MAAK,SAAA,GAAU,UAAW;AAAA,EAAA;AAGxC;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { FormExample as m } from "./FormExample.js";
|
|
2
|
+
import { FormExampleVariants as e } from "./FormExample.js";
|
|
3
3
|
export {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
m as FormExample,
|
|
5
|
+
e as FormExampleVariants,
|
|
6
|
+
m as default
|
|
7
7
|
};
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
import r, { useState as U } from "react";
|
|
2
2
|
import d from "classnames";
|
|
3
|
-
import { FormMode as
|
|
4
|
-
import { useUuid as
|
|
3
|
+
import { FormMode as x, FormSize as N, AnalyticsId as A } from "../../constants.js";
|
|
4
|
+
import { useUuid as T } from "../../hooks/useUuid.js";
|
|
5
5
|
import { isComponent as m } from "../../utils/component.js";
|
|
6
|
-
import D from "../Checkbox/Checkbox.js";
|
|
7
|
-
import H from "../ErrorWrapper/ErrorWrapper.js";
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
6
|
+
import { Checkbox as D } from "../Checkbox/Checkbox.js";
|
|
7
|
+
import { ErrorWrapper as H } from "../ErrorWrapper/ErrorWrapper.js";
|
|
8
|
+
import { FormLayout as j } from "../FormLayout/FormLayout.js";
|
|
9
|
+
import q from "../Input/Input.js";
|
|
10
|
+
import { RadioButton as J, getRadioLabelClasses as K } from "../RadioButton/RadioButton.js";
|
|
11
|
+
import { Select as O } from "../Select/Select.js";
|
|
12
|
+
import P from "../Textarea/Textarea.js";
|
|
13
|
+
import { Title as Q } from "../Title/Title.js";
|
|
14
14
|
import p from "../FormGroup/styles.module.scss";
|
|
15
|
-
const
|
|
15
|
+
const k = r.forwardRef((t, _) => {
|
|
16
16
|
const {
|
|
17
|
-
className:
|
|
18
|
-
fieldsetClassName:
|
|
19
|
-
mode: a =
|
|
20
|
-
size: s =
|
|
17
|
+
className: F,
|
|
18
|
+
fieldsetClassName: G,
|
|
19
|
+
mode: a = x.onwhite,
|
|
20
|
+
size: s = N.medium,
|
|
21
21
|
error: o,
|
|
22
22
|
errorTextId: y,
|
|
23
23
|
name: l,
|
|
24
|
-
htmlMarkup:
|
|
24
|
+
htmlMarkup: f = "fieldset",
|
|
25
25
|
renderError: R = !0,
|
|
26
26
|
errorWrapperClassName: b,
|
|
27
27
|
errorWrapperTestId: w
|
|
28
|
-
} = t, [S, W] = U(), v =
|
|
29
|
-
[p["form-group-wrapper__title--on-dark"]]:
|
|
30
|
-
}),
|
|
31
|
-
[p["field-set__legend--on-dark"]]:
|
|
32
|
-
}),
|
|
33
|
-
if (m(e,
|
|
28
|
+
} = t, [S, W] = U(), v = T(), n = T(y), u = a === x.ondark, L = s === N.large, M = d(p["form-group-wrapper"], F), z = d({
|
|
29
|
+
[p["form-group-wrapper__title--on-dark"]]: u && !o
|
|
30
|
+
}), c = d(p["field-set__legend"], {
|
|
31
|
+
[p["field-set__legend--on-dark"]]: u && !o
|
|
32
|
+
}), I = d(p["field-set"], G), i = (e, B) => {
|
|
33
|
+
if (m(e, j))
|
|
34
34
|
return r.cloneElement(e, {
|
|
35
35
|
size: s,
|
|
36
36
|
mapHelper: i
|
|
37
37
|
});
|
|
38
|
-
if (m(e,
|
|
38
|
+
if (m(e, k))
|
|
39
39
|
return r.cloneElement(e, {
|
|
40
40
|
mode: a,
|
|
41
41
|
size: s,
|
|
@@ -51,22 +51,22 @@ const f = r.forwardRef((t, F) => {
|
|
|
51
51
|
error: !!o,
|
|
52
52
|
errorTextId: n
|
|
53
53
|
});
|
|
54
|
-
if (m(e,
|
|
55
|
-
const
|
|
54
|
+
if (m(e, J)) {
|
|
55
|
+
const C = typeof e.props.inputId > "u" ? v + B : e.props.inputId;
|
|
56
56
|
return r.cloneElement(e, {
|
|
57
|
-
inputId:
|
|
57
|
+
inputId: C,
|
|
58
58
|
name: l ?? e.props.name,
|
|
59
59
|
mode: a,
|
|
60
60
|
size: s,
|
|
61
|
-
onChange: (
|
|
62
|
-
W(
|
|
61
|
+
onChange: (E) => {
|
|
62
|
+
W(E.target.id), e.props.onChange && e.props.onChange(E);
|
|
63
63
|
},
|
|
64
64
|
error: !!o,
|
|
65
65
|
errorTextId: n,
|
|
66
|
-
labelClassNames:
|
|
66
|
+
labelClassNames: K(C, a, L, S)
|
|
67
67
|
});
|
|
68
68
|
} else {
|
|
69
|
-
if (m(e,
|
|
69
|
+
if (m(e, q))
|
|
70
70
|
return r.cloneElement(e, {
|
|
71
71
|
name: l ?? e.props.name,
|
|
72
72
|
mode: a,
|
|
@@ -74,14 +74,14 @@ const f = r.forwardRef((t, F) => {
|
|
|
74
74
|
error: !!o,
|
|
75
75
|
errorTextId: n
|
|
76
76
|
});
|
|
77
|
-
if (m(e,
|
|
77
|
+
if (m(e, P))
|
|
78
78
|
return r.cloneElement(e, {
|
|
79
79
|
name: l ?? e.props.name,
|
|
80
80
|
mode: a,
|
|
81
81
|
error: !!o,
|
|
82
82
|
errorTextId: n
|
|
83
83
|
});
|
|
84
|
-
if (m(e,
|
|
84
|
+
if (m(e, O))
|
|
85
85
|
return r.cloneElement(e, {
|
|
86
86
|
name: l ?? e.props.name,
|
|
87
87
|
mode: a,
|
|
@@ -90,13 +90,12 @@ const f = r.forwardRef((t, F) => {
|
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
92
|
return e;
|
|
93
|
-
},
|
|
94
|
-
return /* @__PURE__ */ r.createElement("div", { "data-testid": t.testId, "data-analyticsid": A.FormGroup, className: M, ref:
|
|
93
|
+
}, g = () => /* @__PURE__ */ r.createElement("div", null, f === "div" && /* @__PURE__ */ r.createElement("div", { className: I }, t.legend && /* @__PURE__ */ r.createElement("h5", { className: c }, t.legend), r.Children.map(t.children, i)), f === "fieldset" && /* @__PURE__ */ r.createElement("fieldset", { name: t.fieldsetName, className: I }, t.legend && /* @__PURE__ */ r.createElement("legend", { className: c }, t.legend), r.Children.map(t.children, i)));
|
|
94
|
+
return /* @__PURE__ */ r.createElement("div", { "data-testid": t.testId, "data-analyticsid": A.FormGroup, className: M, ref: _, tabIndex: -1 }, t.title && /* @__PURE__ */ r.createElement(Q, { className: z, htmlMarkup: "h4", appearance: "title4", margin: { marginTop: 0, marginBottom: o ? 1 : 2 } }, t.title), R ? /* @__PURE__ */ r.createElement(H, { className: b, errorText: o, testId: w, errorTextId: n }, g()) : g());
|
|
95
95
|
});
|
|
96
|
-
|
|
97
|
-
const le = f;
|
|
96
|
+
k.displayName = "FormGroup";
|
|
98
97
|
export {
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
k as FormGroup,
|
|
99
|
+
k as default
|
|
101
100
|
};
|
|
102
101
|
//# sourceMappingURL=FormGroup.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormGroup.js","sources":["../../../src/components/FormGroup/FormGroup.tsx"],"sourcesContent":["import React, { useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, FormMode, FormSize } from '../../constants';\nimport { useUuid } from '../../hooks/useUuid';\nimport { isComponent } from '../../utils/component';\nimport Checkbox, { CheckboxProps } from '../Checkbox/Checkbox';\nimport ErrorWrapper from '../ErrorWrapper';\nimport FormLayout, { FormLayoutProps } from '../FormLayout';\nimport Input, { InputProps } from '../Input/Input';\nimport RadioButton, { RadioButtonProps, getRadioLabelClasses } from '../RadioButton/RadioButton';\nimport Select, { SelectProps } from '../Select';\nimport Textarea, { TextareaProps } from '../Textarea';\nimport Title from '../Title';\n\nimport formGroupStyles from './styles.module.scss';\n\nexport type FormGroupTags = 'fieldset' | 'div';\n\nexport interface FormGroupProps {\n /** title for the the fieldset */\n title?: string;\n /** text placed in the legend tag of the fieldset */\n legend?: string;\n /** Items in the FormGroup component */\n children?: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /** Adds custom classes to the errorWrapper. */\n errorWrapperClassName?: string;\n /** Adds custom classes to the fieldset element. */\n fieldsetClassName?: string;\n /** Changes the visuals of the formgroup */\n mode?: keyof typeof FormMode;\n /** Changes the visuals of the formgroup */\n size?: keyof typeof FormSize;\n /** Error message */\n error?: string;\n /** Error text id */\n errorTextId?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Sets the data-testid attribute for the error-wrapper. */\n errorWrapperTestId?: string;\n /** Unique name for the child input element */\n name?: string;\n /** Unique name for the fieldset */\n fieldsetName?: string;\n /** Sets div instead of fieldset tag */\n htmlMarkup?: FormGroupTags;\n /** Renders the error component (Default: true) */\n renderError?: boolean;\n}\n\nexport const FormGroup = React.forwardRef((props: FormGroupProps, ref: React.ForwardedRef<HTMLDivElement>) => {\n const {\n className,\n fieldsetClassName,\n mode = FormMode.onwhite,\n size = FormSize.medium,\n error,\n errorTextId,\n name,\n htmlMarkup = 'fieldset',\n renderError = true,\n errorWrapperClassName,\n errorWrapperTestId,\n } = props;\n const [checkedRadioId, setCheckedRadioId] = useState<string>();\n const radioGroupId = useUuid();\n const errorTextUuid = useUuid(errorTextId);\n const onDark = mode === FormMode.ondark;\n const isLarge = size === FormSize.large;\n const formGroupWrapperClasses = classNames(formGroupStyles['form-group-wrapper'], className);\n const titleClasses = classNames({\n [formGroupStyles['form-group-wrapper__title--on-dark']]: onDark && !error,\n });\n\n const legendClasses = classNames(formGroupStyles['field-set__legend'], {\n [formGroupStyles['field-set__legend--on-dark']]: onDark && !error,\n });\n\n const fieldsetClasses = classNames(formGroupStyles['field-set'], fieldsetClassName);\n\n const mapFormComponent = (child: React.ReactNode, index: number): React.ReactNode => {\n if (isComponent<FormLayoutProps>(child, FormLayout)) {\n return React.cloneElement(child, {\n size,\n mapHelper: mapFormComponent,\n });\n } else if (isComponent<FormGroupProps>(child, FormGroup)) {\n return React.cloneElement(child, {\n mode,\n size,\n error,\n renderError: false,\n errorTextId: errorTextUuid,\n });\n } else if (isComponent<CheckboxProps>(child, Checkbox)) {\n return React.cloneElement(child, {\n name: name ?? child.props.name,\n mode,\n size,\n error: !!error,\n errorTextId: errorTextUuid,\n });\n } else if (isComponent<RadioButtonProps>(child, RadioButton)) {\n const radioId = typeof child.props.inputId === 'undefined' ? radioGroupId + index : child.props.inputId;\n return React.cloneElement(child, {\n inputId: radioId,\n name: name ?? child.props.name,\n mode,\n size,\n onChange: (event: React.ChangeEvent<HTMLInputElement>) => {\n setCheckedRadioId(event.target.id);\n child.props.onChange && child.props.onChange(event);\n },\n error: !!error,\n errorTextId: errorTextUuid,\n labelClassNames: getRadioLabelClasses(radioId, mode as FormMode, isLarge, checkedRadioId),\n });\n } else if (isComponent<InputProps>(child, Input)) {\n return React.cloneElement(child, {\n name: name ?? child.props.name,\n mode,\n size,\n error: !!error,\n errorTextId: errorTextUuid,\n });\n } else if (isComponent<TextareaProps>(child, Textarea)) {\n return React.cloneElement(child, {\n name: name ?? child.props.name,\n mode,\n error: !!error,\n errorTextId: errorTextUuid,\n });\n } else if (isComponent<SelectProps>(child, Select)) {\n return React.cloneElement(child, {\n name: name ?? child.props.name,\n mode,\n error: !!error,\n errorTextId: errorTextUuid,\n });\n }\n return child;\n };\n\n const formGroupContent = (): React.ReactNode => {\n return (\n <div>\n {htmlMarkup === 'div' && (\n <div className={fieldsetClasses}>\n {props.legend && <h5 className={legendClasses}>{props.legend}</h5>}\n {React.Children.map(props.children, mapFormComponent)}\n </div>\n )}\n {htmlMarkup === 'fieldset' && (\n <fieldset name={props.fieldsetName} className={fieldsetClasses}>\n {props.legend && <legend className={legendClasses}>{props.legend}</legend>}\n {React.Children.map(props.children, mapFormComponent)}\n </fieldset>\n )}\n </div>\n );\n };\n\n return (\n <div data-testid={props.testId} data-analyticsid={AnalyticsId.FormGroup} className={formGroupWrapperClasses} ref={ref} tabIndex={-1}>\n {props.title && (\n <Title className={titleClasses} htmlMarkup={'h4'} appearance={'title4'} margin={{ marginTop: 0, marginBottom: error ? 1 : 2 }}>\n {props.title}\n </Title>\n )}\n {renderError ? (\n <ErrorWrapper className={errorWrapperClassName} errorText={error} testId={errorWrapperTestId} errorTextId={errorTextUuid}>\n {formGroupContent()}\n </ErrorWrapper>\n ) : (\n formGroupContent()\n )}\n </div>\n );\n});\n\nFormGroup.displayName = 'FormGroup';\n\nexport default FormGroup;\n"],"names":["FormGroup","React","props","ref","className","fieldsetClassName","mode","FormMode","size","FormSize","error","errorTextId","name","htmlMarkup","renderError","errorWrapperClassName","errorWrapperTestId","checkedRadioId","setCheckedRadioId","useState","radioGroupId","useUuid","errorTextUuid","onDark","isLarge","formGroupWrapperClasses","classNames","formGroupStyles","titleClasses","legendClasses","fieldsetClasses","mapFormComponent","child","index","isComponent","FormLayout","Checkbox","RadioButton","radioId","event","getRadioLabelClasses","Input","Textarea","Select","formGroupContent","AnalyticsId","Title","ErrorWrapper","FormGroup$1"],"mappings":";;;;;;;;;;;;;;AAuDO,MAAMA,IAAYC,EAAM,WAAW,CAACC,GAAuBC,MAA4C;AACtG,QAAA;AAAA,IACJ,WAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,MAAAC,IAAOC,EAAS;AAAA,IAChB,MAAAC,IAAOC,EAAS;AAAA,IAChB,OAAAC;AAAA,IACA,aAAAC;AAAA,IACA,MAAAC;AAAA,IACA,YAAAC,IAAa;AAAA,IACb,aAAAC,IAAc;AAAA,IACd,uBAAAC;AAAA,IACA,oBAAAC;AAAA,EACE,IAAAd,GACE,CAACe,GAAgBC,CAAiB,IAAIC,EAAiB,GACvDC,IAAeC,KACfC,IAAgBD,EAAQV,CAAW,GACnCY,IAASjB,MAASC,EAAS,QAC3BiB,IAAUhB,MAASC,EAAS,OAC5BgB,IAA0BC,EAAWC,EAAgB,oBAAoB,GAAGvB,CAA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CAAgB,CACtD,CAEJ;AAKF,SAAA9B,gBAAAA,EAAA,cAAC,SAAI,eAAaC,EAAM,QAAQ,oBAAkB2C,EAAY,WAAW,WAAWpB,GAAyB,KAAAtB,GAAU,UAAU,GAC9H,GAAAD,EAAM,SACLD,gBAAAA,EAAA,cAAC6C,GAAM,EAAA,WAAWlB,GAAc,YAAY,MAAM,YAAY,UAAU,QAAQ,EAAE,WAAW,GAAG,cAAclB,IAAQ,IAAI,OACvHR,EAAM,KACT,GAEDY,IACEb,gBAAAA,EAAA,cAAA8C,GAAA,EAAa,WAAWhC,GAAuB,WAAWL,GAAO,QAAQM,GAAoB,aAAaM,KACxGsB,EACH,CAAA,IAEAA,EAEJ,CAAA;AAEJ,CAAC;AAED5C,EAAU,cAAc;AAExB,MAAAgD,KAAehD;"}
|
|
1
|
+
{"version":3,"file":"FormGroup.js","sources":["../../../src/components/FormGroup/FormGroup.tsx"],"sourcesContent":["import React, { useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, FormMode, FormSize } from '../../constants';\nimport { useUuid } from '../../hooks/useUuid';\nimport { isComponent } from '../../utils/component';\nimport Checkbox, { CheckboxProps } from '../Checkbox/Checkbox';\nimport ErrorWrapper from '../ErrorWrapper';\nimport FormLayout, { FormLayoutProps } from '../FormLayout';\nimport Input, { InputProps } from '../Input/Input';\nimport RadioButton, { RadioButtonProps, getRadioLabelClasses } from '../RadioButton/RadioButton';\nimport Select, { SelectProps } from '../Select';\nimport Textarea, { TextareaProps } from '../Textarea';\nimport Title from '../Title';\n\nimport formGroupStyles from './styles.module.scss';\n\nexport type FormGroupTags = 'fieldset' | 'div';\n\nexport interface FormGroupProps {\n /** title for the the fieldset */\n title?: string;\n /** text placed in the legend tag of the fieldset */\n legend?: string;\n /** Items in the FormGroup component */\n children?: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /** Adds custom classes to the errorWrapper. */\n errorWrapperClassName?: string;\n /** Adds custom classes to the fieldset element. */\n fieldsetClassName?: string;\n /** Changes the visuals of the formgroup */\n mode?: keyof typeof FormMode;\n /** Changes the visuals of the formgroup */\n size?: keyof typeof FormSize;\n /** Error message */\n error?: string;\n /** Error text id */\n errorTextId?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Sets the data-testid attribute for the error-wrapper. */\n errorWrapperTestId?: string;\n /** Unique name for the child input element */\n name?: string;\n /** Unique name for the fieldset */\n fieldsetName?: string;\n /** Sets div instead of fieldset tag */\n htmlMarkup?: FormGroupTags;\n /** Renders the error component (Default: true) */\n renderError?: boolean;\n}\n\nexport const FormGroup = React.forwardRef((props: FormGroupProps, ref: React.ForwardedRef<HTMLDivElement>) => {\n const {\n className,\n fieldsetClassName,\n mode = FormMode.onwhite,\n size = FormSize.medium,\n error,\n errorTextId,\n name,\n htmlMarkup = 'fieldset',\n renderError = true,\n errorWrapperClassName,\n errorWrapperTestId,\n } = props;\n const [checkedRadioId, setCheckedRadioId] = useState<string>();\n const radioGroupId = useUuid();\n const errorTextUuid = useUuid(errorTextId);\n const onDark = mode === FormMode.ondark;\n const isLarge = size === FormSize.large;\n const formGroupWrapperClasses = classNames(formGroupStyles['form-group-wrapper'], className);\n const titleClasses = classNames({\n [formGroupStyles['form-group-wrapper__title--on-dark']]: onDark && !error,\n });\n\n const legendClasses = classNames(formGroupStyles['field-set__legend'], {\n [formGroupStyles['field-set__legend--on-dark']]: onDark && !error,\n });\n\n const fieldsetClasses = classNames(formGroupStyles['field-set'], fieldsetClassName);\n\n const mapFormComponent = (child: React.ReactNode, index: number): React.ReactNode => {\n if (isComponent<FormLayoutProps>(child, FormLayout)) {\n return React.cloneElement(child, {\n size,\n mapHelper: mapFormComponent,\n });\n } else if (isComponent<FormGroupProps>(child, FormGroup)) {\n return React.cloneElement(child, {\n mode,\n size,\n error,\n renderError: false,\n errorTextId: errorTextUuid,\n });\n } else if (isComponent<CheckboxProps>(child, Checkbox)) {\n return React.cloneElement(child, {\n name: name ?? child.props.name,\n mode,\n size,\n error: !!error,\n errorTextId: errorTextUuid,\n });\n } else if (isComponent<RadioButtonProps>(child, RadioButton)) {\n const radioId = typeof child.props.inputId === 'undefined' ? radioGroupId + index : child.props.inputId;\n return React.cloneElement(child, {\n inputId: radioId,\n name: name ?? child.props.name,\n mode,\n size,\n onChange: (event: React.ChangeEvent<HTMLInputElement>) => {\n setCheckedRadioId(event.target.id);\n child.props.onChange && child.props.onChange(event);\n },\n error: !!error,\n errorTextId: errorTextUuid,\n labelClassNames: getRadioLabelClasses(radioId, mode as FormMode, isLarge, checkedRadioId),\n });\n } else if (isComponent<InputProps>(child, Input)) {\n return React.cloneElement(child, {\n name: name ?? child.props.name,\n mode,\n size,\n error: !!error,\n errorTextId: errorTextUuid,\n });\n } else if (isComponent<TextareaProps>(child, Textarea)) {\n return React.cloneElement(child, {\n name: name ?? child.props.name,\n mode,\n error: !!error,\n errorTextId: errorTextUuid,\n });\n } else if (isComponent<SelectProps>(child, Select)) {\n return React.cloneElement(child, {\n name: name ?? child.props.name,\n mode,\n error: !!error,\n errorTextId: errorTextUuid,\n });\n }\n return child;\n };\n\n const formGroupContent = (): React.ReactNode => {\n return (\n <div>\n {htmlMarkup === 'div' && (\n <div className={fieldsetClasses}>\n {props.legend && <h5 className={legendClasses}>{props.legend}</h5>}\n {React.Children.map(props.children, mapFormComponent)}\n </div>\n )}\n {htmlMarkup === 'fieldset' && (\n <fieldset name={props.fieldsetName} className={fieldsetClasses}>\n {props.legend && <legend className={legendClasses}>{props.legend}</legend>}\n {React.Children.map(props.children, mapFormComponent)}\n </fieldset>\n )}\n </div>\n );\n };\n\n return (\n <div data-testid={props.testId} data-analyticsid={AnalyticsId.FormGroup} className={formGroupWrapperClasses} ref={ref} tabIndex={-1}>\n {props.title && (\n <Title className={titleClasses} htmlMarkup={'h4'} appearance={'title4'} margin={{ marginTop: 0, marginBottom: error ? 1 : 2 }}>\n {props.title}\n </Title>\n )}\n {renderError ? (\n <ErrorWrapper className={errorWrapperClassName} errorText={error} testId={errorWrapperTestId} errorTextId={errorTextUuid}>\n {formGroupContent()}\n </ErrorWrapper>\n ) : (\n formGroupContent()\n )}\n </div>\n );\n});\n\nFormGroup.displayName = 'FormGroup';\n\nexport default FormGroup;\n"],"names":["FormGroup","React","props","ref","className","fieldsetClassName","mode","FormMode","size","FormSize","error","errorTextId","name","htmlMarkup","renderError","errorWrapperClassName","errorWrapperTestId","checkedRadioId","setCheckedRadioId","useState","radioGroupId","useUuid","errorTextUuid","onDark","isLarge","formGroupWrapperClasses","classNames","formGroupStyles","titleClasses","legendClasses","fieldsetClasses","mapFormComponent","child","index","isComponent","FormLayout","Checkbox","RadioButton","radioId","event","getRadioLabelClasses","Input","Textarea","Select","formGroupContent","AnalyticsId","Title","ErrorWrapper"],"mappings":";;;;;;;;;;;;;;AAuDO,MAAMA,IAAYC,EAAM,WAAW,CAACC,GAAuBC,MAA4C;AACtG,QAAA;AAAA,IACJ,WAAAC;AAAA,IACA,mBAAAC;AAAA,IACA,MAAAC,IAAOC,EAAS;AAAA,IAChB,MAAAC,IAAOC,EAAS;AAAA,IAChB,OAAAC;AAAA,IACA,aAAAC;AAAA,IACA,MAAAC;AAAA,IACA,YAAAC,IAAa;AAAA,IACb,aAAAC,IAAc;AAAA,IACd,uBAAAC;AAAA,IACA,oBAAAC;AAAA,EACE,IAAAd,GACE,CAACe,GAAgBC,CAAiB,IAAIC,EAAiB,GACvDC,IAAeC,KACfC,IAAgBD,EAAQV,CAAW,GACnCY,IAASjB,MAASC,EAAS,QAC3BiB,IAAUhB,MAASC,EAAS,OAC5BgB,IAA0BC,EAAWC,EAAgB,oBAAoB,GAAGvB,CAAS,GACrFwB,IAAeF,EAAW;AAAA,IAC9B,CAACC,EAAgB,oCAAoC,CAAC,GAAGJ,KAAU,CAACb;AAAA,EAAA,CACrE,GAEKmB,IAAgBH,EAAWC,EAAgB,mBAAmB,GAAG;AAAA,IACrE,CAACA,EAAgB,4BAA4B,CAAC,GAAGJ,KAAU,CAACb;AAAA,EAAA,CAC7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M,YAAY,UAAU,QAAQ,EAAE,WAAW,GAAG,cAAclB,IAAQ,IAAI,OACvHR,EAAM,KACT,GAEDY,IACEb,gBAAAA,EAAA,cAAA8C,GAAA,EAAa,WAAWhC,GAAuB,WAAWL,GAAO,QAAQM,GAAoB,aAAaM,KACxGsB,EACH,CAAA,IAEAA,EAEJ,CAAA;AAEJ,CAAC;AAED5C,EAAU,cAAc;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import r from "react";
|
|
2
2
|
import i from "classnames";
|
|
3
|
-
import { FormSize as
|
|
3
|
+
import { FormSize as y, AnalyticsId as p } from "../../constants.js";
|
|
4
4
|
import t from "../FormLayout/styles.module.scss";
|
|
5
|
-
var
|
|
6
|
-
const
|
|
7
|
-
const { maxColumns: o = "one", colMinWidth:
|
|
5
|
+
var v = /* @__PURE__ */ ((e) => (e.one = "one", e.two = "two", e.three = "three", e.four = "four", e.five = "five", e))(v || {});
|
|
6
|
+
const w = r.forwardRef((e, m) => {
|
|
7
|
+
const { maxColumns: o = "one", colMinWidth: s = 300, size: f, className: c, mapHelper: a } = e, n = { "--min-col-width": `${s}px` }, d = i(
|
|
8
8
|
t["form-layout-container"],
|
|
9
9
|
{
|
|
10
|
-
[t["form-layout-container--large"]]: f ===
|
|
10
|
+
[t["form-layout-container--large"]]: f === y.large
|
|
11
11
|
},
|
|
12
|
-
|
|
13
|
-
),
|
|
12
|
+
c
|
|
13
|
+
), u = i(t["form-layout-child"], {
|
|
14
14
|
[t["form-layout-child--two"]]: o === "two",
|
|
15
15
|
[t["form-layout-child--three"]]: o === "three",
|
|
16
16
|
[t["form-layout-child--four"]]: o === "four",
|
|
@@ -21,19 +21,18 @@ const m = r.forwardRef((e, s) => {
|
|
|
21
21
|
"div",
|
|
22
22
|
{
|
|
23
23
|
"data-testid": e.testId,
|
|
24
|
-
"data-analyticsid":
|
|
25
|
-
style:
|
|
26
|
-
className:
|
|
27
|
-
ref:
|
|
24
|
+
"data-analyticsid": p.FormLayout,
|
|
25
|
+
style: n,
|
|
26
|
+
className: d,
|
|
27
|
+
ref: m
|
|
28
28
|
},
|
|
29
|
-
r.Children.map(e.children, (l, h) => /* @__PURE__ */ r.createElement("div", { className:
|
|
29
|
+
r.Children.map(e.children, (l, h) => /* @__PURE__ */ r.createElement("div", { className: u }, a ? a(l, h) : l))
|
|
30
30
|
);
|
|
31
31
|
});
|
|
32
|
-
|
|
33
|
-
const C = m;
|
|
32
|
+
w.displayName = "FormLayout";
|
|
34
33
|
export {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
w as FormLayout,
|
|
35
|
+
v as FormLayoutColumns,
|
|
36
|
+
w as default
|
|
38
37
|
};
|
|
39
38
|
//# sourceMappingURL=FormLayout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormLayout.js","sources":["../../../src/components/FormLayout/FormLayout.tsx"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, FormSize } from '../../constants';\n\nimport formGroupStyles from './styles.module.scss';\n\nexport enum FormLayoutColumns {\n one = 'one',\n two = 'two',\n three = 'three',\n four = 'four',\n five = 'five',\n}\n\nexport interface FormLayoutProps {\n /** The max number of columns that will exist if space is available */\n maxColumns?: keyof typeof FormLayoutColumns;\n /** Sets the minimum width for the columns in pixels - this determines how many will fit on a row */\n colMinWidth?: number;\n /** Items in the FormLayout component */\n children?: React.ReactNode;\n /** Changes the visuals of the formgroup */\n size?: keyof typeof FormSize;\n /** Adds custom classes to the element. */\n className?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Function that helps map the form children */\n mapHelper?: (child: React.ReactNode, index: number) => React.ReactNode;\n}\n\nexport const FormLayout = React.forwardRef((props: FormLayoutProps, ref: React.ForwardedRef<HTMLDivElement>) => {\n const { maxColumns: columns = FormLayoutColumns.one, colMinWidth = 300, size, className, mapHelper } = props;\n\n const cssVariable = { '--min-col-width': `${colMinWidth}px` } as React.CSSProperties;\n const formLayoutContainerClasses = classNames(\n formGroupStyles['form-layout-container'],\n {\n [formGroupStyles['form-layout-container--large']]: size === FormSize.large,\n },\n className\n );\n const formLayoutChildClasses = classNames(formGroupStyles['form-layout-child'], {\n [formGroupStyles['form-layout-child--two']]: columns === FormLayoutColumns.two,\n [formGroupStyles['form-layout-child--three']]: columns === FormLayoutColumns.three,\n [formGroupStyles['form-layout-child--four']]: columns === FormLayoutColumns.four,\n [formGroupStyles['form-layout-child--five']]: columns === FormLayoutColumns.five,\n });\n\n return (\n <div\n data-testid={props.testId}\n data-analyticsid={AnalyticsId.FormLayout}\n style={cssVariable}\n className={formLayoutContainerClasses}\n ref={ref}\n >\n {React.Children.map(props.children, (child: React.ReactNode, index: number) => {\n return <div className={formLayoutChildClasses}>{mapHelper ? mapHelper(child, index) : child}</div>;\n })}\n </div>\n );\n});\n\nFormLayout.displayName = 'FormLayout';\n\nexport default FormLayout;\n"],"names":["FormLayoutColumns","FormLayout","React","props","ref","columns","colMinWidth","size","className","mapHelper","cssVariable","formLayoutContainerClasses","classNames","formGroupStyles","FormSize","formLayoutChildClasses","AnalyticsId","child","index"
|
|
1
|
+
{"version":3,"file":"FormLayout.js","sources":["../../../src/components/FormLayout/FormLayout.tsx"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, FormSize } from '../../constants';\n\nimport formGroupStyles from './styles.module.scss';\n\nexport enum FormLayoutColumns {\n one = 'one',\n two = 'two',\n three = 'three',\n four = 'four',\n five = 'five',\n}\n\nexport interface FormLayoutProps {\n /** The max number of columns that will exist if space is available */\n maxColumns?: keyof typeof FormLayoutColumns;\n /** Sets the minimum width for the columns in pixels - this determines how many will fit on a row */\n colMinWidth?: number;\n /** Items in the FormLayout component */\n children?: React.ReactNode;\n /** Changes the visuals of the formgroup */\n size?: keyof typeof FormSize;\n /** Adds custom classes to the element. */\n className?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Function that helps map the form children */\n mapHelper?: (child: React.ReactNode, index: number) => React.ReactNode;\n}\n\nexport const FormLayout = React.forwardRef((props: FormLayoutProps, ref: React.ForwardedRef<HTMLDivElement>) => {\n const { maxColumns: columns = FormLayoutColumns.one, colMinWidth = 300, size, className, mapHelper } = props;\n\n const cssVariable = { '--min-col-width': `${colMinWidth}px` } as React.CSSProperties;\n const formLayoutContainerClasses = classNames(\n formGroupStyles['form-layout-container'],\n {\n [formGroupStyles['form-layout-container--large']]: size === FormSize.large,\n },\n className\n );\n const formLayoutChildClasses = classNames(formGroupStyles['form-layout-child'], {\n [formGroupStyles['form-layout-child--two']]: columns === FormLayoutColumns.two,\n [formGroupStyles['form-layout-child--three']]: columns === FormLayoutColumns.three,\n [formGroupStyles['form-layout-child--four']]: columns === FormLayoutColumns.four,\n [formGroupStyles['form-layout-child--five']]: columns === FormLayoutColumns.five,\n });\n\n return (\n <div\n data-testid={props.testId}\n data-analyticsid={AnalyticsId.FormLayout}\n style={cssVariable}\n className={formLayoutContainerClasses}\n ref={ref}\n >\n {React.Children.map(props.children, (child: React.ReactNode, index: number) => {\n return <div className={formLayoutChildClasses}>{mapHelper ? mapHelper(child, index) : child}</div>;\n })}\n </div>\n );\n});\n\nFormLayout.displayName = 'FormLayout';\n\nexport default FormLayout;\n"],"names":["FormLayoutColumns","FormLayout","React","props","ref","columns","colMinWidth","size","className","mapHelper","cssVariable","formLayoutContainerClasses","classNames","formGroupStyles","FormSize","formLayoutChildClasses","AnalyticsId","child","index"],"mappings":";;;;AAQY,IAAAA,sBAAAA,OACVA,EAAA,MAAM,OACNA,EAAA,MAAM,OACNA,EAAA,QAAQ,SACRA,EAAA,OAAO,QACPA,EAAA,OAAO,QALGA,IAAAA,KAAA,CAAA,CAAA;AAyBL,MAAMC,IAAaC,EAAM,WAAW,CAACC,GAAwBC,MAA4C;AACxG,QAAA,EAAE,YAAYC,IAAU,OAAuB,aAAAC,IAAc,KAAK,MAAAC,GAAM,WAAAC,GAAW,WAAAC,EAAc,IAAAN,GAEjGO,IAAc,EAAE,mBAAmB,GAAGJ,CAAW,QACjDK,IAA6BC;AAAA,IACjCC,EAAgB,uBAAuB;AAAA,IACvC;AAAA,MACE,CAACA,EAAgB,8BAA8B,CAAC,GAAGN,MAASO,EAAS;AAAA,IACvE;AAAA,IACAN;AAAA,EAAA,GAEIO,IAAyBH,EAAWC,EAAgB,mBAAmB,GAAG;AAAA,IAC9E,CAACA,EAAgB,wBAAwB,CAAC,GAAGR,MAAY;AAAA,IACzD,CAACQ,EAAgB,0BAA0B,CAAC,GAAGR,MAAY;AAAA,IAC3D,CAACQ,EAAgB,yBAAyB,CAAC,GAAGR,MAAY;AAAA,IAC1D,CAACQ,EAAgB,yBAAyB,CAAC,GAAGR,MAAY;AAAA;AAAA,EAAA,CAC3D;AAGC,SAAAH,gBAAAA,EAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,eAAaC,EAAM;AAAA,MACnB,oBAAkBa,EAAY;AAAA,MAC9B,OAAON;AAAA,MACP,WAAWC;AAAA,MACX,KAAAP;AAAA,IAAA;AAAA,IAECF,EAAM,SAAS,IAAIC,EAAM,UAAU,CAACc,GAAwBC,MACpDhB,gBAAAA,EAAA,cAAC,SAAI,WAAWa,EAAA,GAAyBN,IAAYA,EAAUQ,GAAOC,CAAK,IAAID,CAAM,CAC7F;AAAA,EAAA;AAGP,CAAC;AAEDhB,EAAW,cAAc;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import r from "./FormLayout.js";
|
|
2
|
-
import {
|
|
1
|
+
import { FormLayout as r } from "./FormLayout.js";
|
|
2
|
+
import { FormLayoutColumns as a } from "./FormLayout.js";
|
|
3
3
|
export {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
r as FormLayout,
|
|
5
|
+
a as FormLayoutColumns,
|
|
6
6
|
r as default
|
|
7
7
|
};
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import e from "react";
|
|
2
2
|
import { isSupernova as r } from "../../docs/index.js";
|
|
3
|
-
const
|
|
3
|
+
const l = ({ gridLayout: a = r(), children: t }) => r() || a === "padding" ? /* @__PURE__ */ e.createElement("div", { style: { padding: "0.5rem" } }, t) : a === "helsenorge" ? /* @__PURE__ */ e.createElement("div", { className: "container py-5" }, /* @__PURE__ */ e.createElement("div", { className: "row" }, /* @__PURE__ */ e.createElement("div", { className: "col" }, t))) : /* @__PURE__ */ e.createElement(e.Fragment, null, t);
|
|
4
4
|
export {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
l as GridExample,
|
|
6
|
+
l as default
|
|
7
7
|
};
|
|
8
8
|
//# sourceMappingURL=GridExample.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GridExample.js","sources":["../../../src/components/GridExample/GridExample.tsx"],"sourcesContent":["import React from 'react';\n\nimport { isSupernova } from '../../docs';\n\ntype GridLayout = 'helsenorge' | 'padding' | 'none';\n\ninterface GridExampleProps {\n gridLayout: GridLayout;\n}\n\nexport const GridExample: React.FC<GridExampleProps> = ({ gridLayout = isSupernova(), children }) => {\n if (isSupernova() || gridLayout === 'padding') {\n return <div style={{ padding: '0.5rem' }}>{children}</div>;\n }\n\n if (gridLayout === 'helsenorge') {\n return (\n <div className=\"container py-5\">\n <div className=\"row\">\n <div className=\"col\">{children}</div>\n </div>\n </div>\n );\n }\n\n return <>{children}</>;\n};\n\nexport default GridExample;\n"],"names":["GridExample","gridLayout","isSupernova","children","React"
|
|
1
|
+
{"version":3,"file":"GridExample.js","sources":["../../../src/components/GridExample/GridExample.tsx"],"sourcesContent":["import React from 'react';\n\nimport { isSupernova } from '../../docs';\n\ntype GridLayout = 'helsenorge' | 'padding' | 'none';\n\ninterface GridExampleProps {\n gridLayout: GridLayout;\n}\n\nexport const GridExample: React.FC<GridExampleProps> = ({ gridLayout = isSupernova(), children }) => {\n if (isSupernova() || gridLayout === 'padding') {\n return <div style={{ padding: '0.5rem' }}>{children}</div>;\n }\n\n if (gridLayout === 'helsenorge') {\n return (\n <div className=\"container py-5\">\n <div className=\"row\">\n <div className=\"col\">{children}</div>\n </div>\n </div>\n );\n }\n\n return <>{children}</>;\n};\n\nexport default GridExample;\n"],"names":["GridExample","gridLayout","isSupernova","children","React"],"mappings":";;AAUO,MAAMA,IAA0C,CAAC,EAAE,YAAAC,IAAaC,EAAY,GAAG,UAAAC,QAChFD,EAAA,KAAiBD,MAAe,4CAC1B,OAAI,EAAA,OAAO,EAAE,SAAS,SAAA,KAAaE,CAAS,IAGlDF,MAAe,eAEdG,gBAAAA,EAAA,cAAA,OAAA,EAAI,WAAU,oDACZ,OAAI,EAAA,WAAU,MACb,GAAAA,gBAAAA,EAAA,cAAC,OAAI,EAAA,WAAU,MAAO,GAAAD,CAAS,CACjC,CACF,sDAIMA,CAAS;"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { GridExample as p } from "./GridExample.js";
|
|
1
|
+
import { GridExample as a } from "./GridExample.js";
|
|
3
2
|
export {
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
a as GridExample,
|
|
4
|
+
a as default
|
|
6
5
|
};
|
|
7
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1,62 +1,61 @@
|
|
|
1
1
|
import e from "react";
|
|
2
2
|
import c from "classnames";
|
|
3
3
|
import { AnalyticsId as L } from "../../constants.js";
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
4
|
+
import H from "../AnchorLink/AnchorLink.js";
|
|
5
|
+
import w from "../Close/Close.js";
|
|
6
|
+
import A, { PopOverVariant as I } from "../PopOver/PopOver.js";
|
|
7
7
|
import t from "../HelpBubble/styles.module.scss";
|
|
8
|
-
const M =
|
|
8
|
+
const M = I, R = e.forwardRef((b, m) => {
|
|
9
9
|
const {
|
|
10
|
-
children:
|
|
11
|
-
className:
|
|
10
|
+
children: u,
|
|
11
|
+
className: p = "",
|
|
12
12
|
noCloseButton: n,
|
|
13
13
|
linkText: r = "Mer hjelp",
|
|
14
14
|
linkUrl: o,
|
|
15
|
-
linkTarget:
|
|
15
|
+
linkTarget: f,
|
|
16
16
|
onLinkClick: a,
|
|
17
|
-
onClose:
|
|
18
|
-
closeAriaLabel:
|
|
17
|
+
onClose: d,
|
|
18
|
+
closeAriaLabel: h,
|
|
19
19
|
// Props passed on to PopOver
|
|
20
20
|
showBubble: s,
|
|
21
|
-
helpBubbleId:
|
|
21
|
+
helpBubbleId: k,
|
|
22
22
|
variant: _,
|
|
23
|
-
controllerRef:
|
|
23
|
+
controllerRef: B,
|
|
24
24
|
role: i,
|
|
25
|
-
testId:
|
|
26
|
-
} =
|
|
25
|
+
testId: C
|
|
26
|
+
} = b, l = i === "tooltip";
|
|
27
27
|
if (!s && !l)
|
|
28
28
|
return null;
|
|
29
|
-
const
|
|
29
|
+
const E = c(t.helpbubble, p), N = c(t.helpbubble__content, {
|
|
30
30
|
[t["helpbubble__content--close"]]: !n && !l
|
|
31
|
-
}),
|
|
31
|
+
}), v = () => {
|
|
32
32
|
if (!l) {
|
|
33
33
|
if (a && r)
|
|
34
34
|
return /* @__PURE__ */ e.createElement("button", { className: t.helpbubble__link, onClick: a, type: "button" }, r);
|
|
35
35
|
if (o && r)
|
|
36
|
-
return /* @__PURE__ */ e.createElement(
|
|
36
|
+
return /* @__PURE__ */ e.createElement(H, { href: o, target: f }, r);
|
|
37
37
|
}
|
|
38
|
-
},
|
|
38
|
+
}, y = () => {
|
|
39
39
|
if (!(n || l))
|
|
40
|
-
return /* @__PURE__ */ e.createElement("div", { className: t.helpbubble__close }, /* @__PURE__ */ e.createElement(
|
|
40
|
+
return /* @__PURE__ */ e.createElement("div", { className: t.helpbubble__close }, /* @__PURE__ */ e.createElement(w, { small: !0, onClick: d, ariaLabel: h }));
|
|
41
41
|
};
|
|
42
42
|
return /* @__PURE__ */ e.createElement(
|
|
43
|
-
|
|
43
|
+
A,
|
|
44
44
|
{
|
|
45
|
-
id:
|
|
45
|
+
id: k,
|
|
46
46
|
variant: _,
|
|
47
|
-
controllerRef:
|
|
47
|
+
controllerRef: B,
|
|
48
48
|
role: i,
|
|
49
|
-
ref:
|
|
49
|
+
ref: m,
|
|
50
50
|
show: l && s,
|
|
51
|
-
testId:
|
|
51
|
+
testId: C
|
|
52
52
|
},
|
|
53
|
-
/* @__PURE__ */ e.createElement("div", { className:
|
|
53
|
+
/* @__PURE__ */ e.createElement("div", { className: E, "data-analyticsid": L.HelpBubble }, y(), /* @__PURE__ */ e.createElement("div", { className: N }, u, v()))
|
|
54
54
|
);
|
|
55
55
|
});
|
|
56
|
-
|
|
57
|
-
const U = b;
|
|
56
|
+
R.displayName = "HelpBubble";
|
|
58
57
|
export {
|
|
59
58
|
M as HelpBubbleVariant,
|
|
60
|
-
|
|
59
|
+
R as default
|
|
61
60
|
};
|
|
62
61
|
//# sourceMappingURL=HelpBubble.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HelpBubble.js","sources":["../../../src/components/HelpBubble/HelpBubble.tsx"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\nimport AnchorLink, { AnchorLinkTargets } from '../AnchorLink';\nimport Close from '../Close';\nimport PopOver, { PopOverProps, PopOverVariant } from '../PopOver';\n\nimport styles from './styles.module.scss';\n\nexport const HelpBubbleVariant = PopOverVariant;\n\ntype HelpBubbleRole = 'tooltip';\n\nexport interface HelpBubbleProps extends Pick<PopOverProps, 'children' | 'variant' | 'controllerRef' | 'role'> {\n /** Id of the HelpBubble */\n helpBubbleId?: string;\n /** Content shown inside HelpBubble. Note that if role=\"tooltip\", you must not include interactive/focusable elements. */\n children: React.ReactNode;\n /** Ref for the element the HelpBubble is placed upon */\n controllerRef: React.RefObject<HTMLElement | SVGSVGElement>;\n /** Adds custom classes to the element. */\n className?: string;\n /** Determines the placement of the helpbubble. Default: automatic positioning. */\n variant?: keyof typeof HelpBubbleVariant;\n /** Show the bubble. Default: false. */\n showBubble?: boolean;\n /** Hide the close button in the bubble. Close button is never rendered if role=\"tooltip\". */\n noCloseButton?: boolean;\n /** Visible text on the link. Link is never rendered if role=\"tooltip\". */\n linkText?: string;\n /** Url the link leads to */\n linkUrl?: string;\n /** Sets the target type of the link. _blank adds an arrow icon at the end of the link */\n linkTarget?: AnchorLinkTargets;\n /** Function is called when link is clicked */\n onLinkClick?: () => void;\n /** Function is called when user clicks the button */\n onClose?: () => void;\n /** aria-label to be passed onto Close */\n closeAriaLabel?: string;\n /** Sets role of the HelpBubble element. If set to \"tooltip\", */\n role?: HelpBubbleRole;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nconst HelpBubble = React.forwardRef<HTMLDivElement | SVGSVGElement, HelpBubbleProps>((props, ref) => {\n const {\n children,\n className = '',\n noCloseButton,\n linkText = 'Mer hjelp',\n linkUrl,\n linkTarget,\n onLinkClick,\n onClose,\n closeAriaLabel,\n // Props passed on to PopOver\n showBubble,\n helpBubbleId,\n variant,\n controllerRef,\n role,\n testId,\n } = props;\n\n const isTooltip = role === 'tooltip';\n\n if (!showBubble && !isTooltip) {\n return null;\n }\n\n const helpBubbleClasses = classNames(styles.helpbubble, className);\n\n const contentClasses = classNames(styles.helpbubble__content, {\n [styles['helpbubble__content--close']]: !noCloseButton && !isTooltip,\n });\n\n const renderLink = (): JSX.Element | undefined => {\n // Det er ikke tillatt med interaktive/fokuserbare elementer i role=\"tooltip\"\n if (isTooltip) {\n return;\n }\n if (onLinkClick && linkText) {\n return (\n <button className={styles.helpbubble__link} onClick={onLinkClick} type=\"button\">\n {linkText}\n </button>\n );\n } else if (linkUrl && linkText) {\n return (\n <AnchorLink href={linkUrl} target={linkTarget}>\n {linkText}\n </AnchorLink>\n );\n }\n };\n\n const renderCloseButton = (): JSX.Element | undefined => {\n if (noCloseButton || isTooltip) {\n return;\n }\n return (\n <div className={styles.helpbubble__close}>\n <Close small onClick={onClose} ariaLabel={closeAriaLabel} />\n </div>\n );\n };\n\n return (\n <PopOver\n id={helpBubbleId}\n variant={variant}\n controllerRef={controllerRef}\n role={role}\n ref={ref}\n show={isTooltip && showBubble}\n testId={testId}\n >\n <div className={helpBubbleClasses} data-analyticsid={AnalyticsId.HelpBubble}>\n {renderCloseButton()}\n <div className={contentClasses}>\n {children}\n {renderLink()}\n </div>\n </div>\n </PopOver>\n );\n});\n\nHelpBubble.displayName = 'HelpBubble';\n\nexport default HelpBubble;\n"],"names":["HelpBubbleVariant","PopOverVariant","HelpBubble","React","props","ref","children","className","noCloseButton","linkText","linkUrl","linkTarget","onLinkClick","onClose","closeAriaLabel","showBubble","helpBubbleId","variant","controllerRef","role","testId","isTooltip","helpBubbleClasses","classNames","styles","contentClasses","renderLink","AnchorLink","renderCloseButton","Close","PopOver","AnalyticsId"
|
|
1
|
+
{"version":3,"file":"HelpBubble.js","sources":["../../../src/components/HelpBubble/HelpBubble.tsx"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\nimport AnchorLink, { AnchorLinkTargets } from '../AnchorLink';\nimport Close from '../Close';\nimport PopOver, { PopOverProps, PopOverVariant } from '../PopOver';\n\nimport styles from './styles.module.scss';\n\nexport const HelpBubbleVariant = PopOverVariant;\n\ntype HelpBubbleRole = 'tooltip';\n\nexport interface HelpBubbleProps extends Pick<PopOverProps, 'children' | 'variant' | 'controllerRef' | 'role'> {\n /** Id of the HelpBubble */\n helpBubbleId?: string;\n /** Content shown inside HelpBubble. Note that if role=\"tooltip\", you must not include interactive/focusable elements. */\n children: React.ReactNode;\n /** Ref for the element the HelpBubble is placed upon */\n controllerRef: React.RefObject<HTMLElement | SVGSVGElement>;\n /** Adds custom classes to the element. */\n className?: string;\n /** Determines the placement of the helpbubble. Default: automatic positioning. */\n variant?: keyof typeof HelpBubbleVariant;\n /** Show the bubble. Default: false. */\n showBubble?: boolean;\n /** Hide the close button in the bubble. Close button is never rendered if role=\"tooltip\". */\n noCloseButton?: boolean;\n /** Visible text on the link. Link is never rendered if role=\"tooltip\". */\n linkText?: string;\n /** Url the link leads to */\n linkUrl?: string;\n /** Sets the target type of the link. _blank adds an arrow icon at the end of the link */\n linkTarget?: AnchorLinkTargets;\n /** Function is called when link is clicked */\n onLinkClick?: () => void;\n /** Function is called when user clicks the button */\n onClose?: () => void;\n /** aria-label to be passed onto Close */\n closeAriaLabel?: string;\n /** Sets role of the HelpBubble element. If set to \"tooltip\", */\n role?: HelpBubbleRole;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nconst HelpBubble = React.forwardRef<HTMLDivElement | SVGSVGElement, HelpBubbleProps>((props, ref) => {\n const {\n children,\n className = '',\n noCloseButton,\n linkText = 'Mer hjelp',\n linkUrl,\n linkTarget,\n onLinkClick,\n onClose,\n closeAriaLabel,\n // Props passed on to PopOver\n showBubble,\n helpBubbleId,\n variant,\n controllerRef,\n role,\n testId,\n } = props;\n\n const isTooltip = role === 'tooltip';\n\n if (!showBubble && !isTooltip) {\n return null;\n }\n\n const helpBubbleClasses = classNames(styles.helpbubble, className);\n\n const contentClasses = classNames(styles.helpbubble__content, {\n [styles['helpbubble__content--close']]: !noCloseButton && !isTooltip,\n });\n\n const renderLink = (): JSX.Element | undefined => {\n // Det er ikke tillatt med interaktive/fokuserbare elementer i role=\"tooltip\"\n if (isTooltip) {\n return;\n }\n if (onLinkClick && linkText) {\n return (\n <button className={styles.helpbubble__link} onClick={onLinkClick} type=\"button\">\n {linkText}\n </button>\n );\n } else if (linkUrl && linkText) {\n return (\n <AnchorLink href={linkUrl} target={linkTarget}>\n {linkText}\n </AnchorLink>\n );\n }\n };\n\n const renderCloseButton = (): JSX.Element | undefined => {\n if (noCloseButton || isTooltip) {\n return;\n }\n return (\n <div className={styles.helpbubble__close}>\n <Close small onClick={onClose} ariaLabel={closeAriaLabel} />\n </div>\n );\n };\n\n return (\n <PopOver\n id={helpBubbleId}\n variant={variant}\n controllerRef={controllerRef}\n role={role}\n ref={ref}\n show={isTooltip && showBubble}\n testId={testId}\n >\n <div className={helpBubbleClasses} data-analyticsid={AnalyticsId.HelpBubble}>\n {renderCloseButton()}\n <div className={contentClasses}>\n {children}\n {renderLink()}\n </div>\n </div>\n </PopOver>\n );\n});\n\nHelpBubble.displayName = 'HelpBubble';\n\nexport default HelpBubble;\n"],"names":["HelpBubbleVariant","PopOverVariant","HelpBubble","React","props","ref","children","className","noCloseButton","linkText","linkUrl","linkTarget","onLinkClick","onClose","closeAriaLabel","showBubble","helpBubbleId","variant","controllerRef","role","testId","isTooltip","helpBubbleClasses","classNames","styles","contentClasses","renderLink","AnchorLink","renderCloseButton","Close","PopOver","AnalyticsId"],"mappings":";;;;;;;AAWO,MAAMA,IAAoBC,GAqC3BC,IAAaC,EAAM,WAA4D,CAACC,GAAOC,MAAQ;AAC7F,QAAA;AAAA,IACJ,UAAAC;AAAA,IACA,WAAAC,IAAY;AAAA,IACZ,eAAAC;AAAA,IACA,UAAAC,IAAW;AAAA,IACX,SAAAC;AAAA,IACA,YAAAC;AAAA,IACA,aAAAC;AAAA,IACA,SAAAC;AAAA,IACA,gBAAAC;AAAA;AAAA,IAEA,YAAAC;AAAA,IACA,cAAAC;AAAA,IACA,SAAAC;AAAA,IACA,eAAAC;AAAA,IACA,MAAAC;AAAA,IACA,QAAAC;AAAA,EACE,IAAAhB,GAEEiB,IAAYF,MAAS;AAEvB,MAAA,CAACJ,KAAc,CAACM;AACX,WAAA;AAGT,QAAMC,IAAoBC,EAAWC,EAAO,YAAYjB,CAAS,GAE3DkB,IAAiBF,EAAWC,EAAO,qBAAqB;AAAA,IAC5D,CAACA,EAAO,4BAA4B,CAAC,GAAG,CAAChB,KAAiB,CAACa;AAAA,EAAA,CAC5D,GAEKK,IAAa,MAA+B;AAEhD,QAAI,CAAAL,GAGJ;AAAA,UAAIT,KAAeH;AAEf,eAAAN,gBAAAA,EAAA,cAAC,YAAO,WAAWqB,EAAO,kBAAkB,SAASZ,GAAa,MAAK,SAAA,GACpEH,CACH;AAEJ,UAAWC,KAAWD;AACpB,+CACGkB,GAAW,EAAA,MAAMjB,GAAS,QAAQC,KAChCF,CACH;AAAA;AAAA,EAEJ,GAGImB,IAAoB,MAA+B;AACvD,QAAI,EAAApB,KAAiBa;AAGrB,aACGlB,gBAAAA,EAAA,cAAA,OAAA,EAAI,WAAWqB,EAAO,kBACrB,GAAArB,gBAAAA,EAAA,cAAC0B,GAAM,EAAA,OAAK,IAAC,SAAShB,GAAS,WAAWC,EAAgB,CAAA,CAC5D;AAAA,EAAA;AAKF,SAAAX,gBAAAA,EAAA;AAAA,IAAC2B;AAAA,IAAA;AAAA,MACC,IAAId;AAAA,MACJ,SAAAC;AAAA,MACA,eAAAC;AAAA,MACA,MAAAC;AAAA,MACA,KAAAd;AAAA,MACA,MAAMgB,KAAaN;AAAA,MACnB,QAAAK;AAAA,IAAA;AAAA,oCAEC,OAAI,EAAA,WAAWE,GAAmB,oBAAkBS,EAAY,cAC9DH,EACD,GAAAzB,gBAAAA,EAAA,cAAC,SAAI,WAAWsB,KACbnB,GACAoB,EAAA,CACH,CACF;AAAA,EAAA;AAGN,CAAC;AAEDxB,EAAW,cAAc;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import e, { useRef as o } from "react";
|
|
2
2
|
import a from "../HelpBubble/HelpBubble.js";
|
|
3
|
-
const
|
|
3
|
+
const r = (i) => {
|
|
4
4
|
const t = o(null);
|
|
5
5
|
return /* @__PURE__ */ e.createElement("div", null, /* @__PURE__ */ e.createElement("span", null, "Consequat adipisicing nostrud non in labore sunt consequat mollit dolore quis voluptate eu veniam adipisicing. Dolor ipsum excepteur anim id ea dolore esse. Sint exercitation duis pariatur in qui ea reprehenderit consectetur sunt minim in ut cupidatat dolore. Eiusmod ut Lorem nostrud id adipisicing ullamco enim. Velit officia mollit laboris amet reprehenderit ad. Nisi cupidatat dolor voluptate officia mollit eu nostrud ipsum. Dolor labore ullamco nostrud consectetur dolor duis qui magna reprehenderit. Esse reprehenderit dolor fugiat sunt adipisicing est. Aliquip duis pariatur labore amet sit occaecat ea eiusmod cillum. Adipisicing magna aute officia cillum non."), /* @__PURE__ */ e.createElement("div", { style: { position: "relative", display: "inline" } }, /* @__PURE__ */ e.createElement("span", { ref: t, style: { display: "inline-block", color: "red" } }, "Jeg er en tooltip tekst."), /* @__PURE__ */ e.createElement(
|
|
6
6
|
a,
|
|
@@ -13,8 +13,8 @@ const l = (i) => {
|
|
|
13
13
|
},
|
|
14
14
|
i.children
|
|
15
15
|
)), /* @__PURE__ */ e.createElement("span", null, "Consequat adipisicing nostrud non in labore sunt consequat mollit dolore quis voluptate eu veniam adipisicing. Dolor ipsum excepteur anim id ea dolore esse. Sint exercitation duis pariatur in qui ea reprehenderit consectetur sunt minim in ut cupidatat dolore. Eiusmod ut Lorem nostrud id adipisicing ullamco enim. Velit officia mollit laboris amet reprehenderit ad. Nisi cupidatat dolor voluptate officia mollit eu nostrud ipsum. Dolor labore ullamco nostrud consectetur dolor duis qui magna reprehenderit. Esse reprehenderit dolor fugiat sunt adipisicing est. Aliquip duis pariatur labore amet sit occaecat ea eiusmod cillum. Adipisicing magna aute officia cillum non."));
|
|
16
|
-
}
|
|
16
|
+
};
|
|
17
17
|
export {
|
|
18
|
-
|
|
18
|
+
r as default
|
|
19
19
|
};
|
|
20
20
|
//# sourceMappingURL=HelpBubbleExample.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HelpBubbleExample.js","sources":["../../../src/components/HelpBubbleExample/HelpBubbleExample.tsx"],"sourcesContent":["import React, { useRef } from 'react';\n\nimport HelpBubble, { HelpBubbleProps } from '../HelpBubble/HelpBubble';\n\nconst HelpBubbleExample: React.FC<HelpBubbleProps> = props => {\n const controllerRef = useRef<HTMLSpanElement>(null);\n\n return (\n <div>\n <span>\n {\n 'Consequat adipisicing nostrud non in labore sunt consequat mollit dolore quis voluptate eu veniam adipisicing. Dolor ipsum excepteur anim id ea dolore esse. Sint exercitation duis pariatur in qui ea reprehenderit consectetur sunt minim in ut cupidatat dolore. Eiusmod ut Lorem nostrud id adipisicing ullamco enim. Velit officia mollit laboris amet reprehenderit ad. Nisi cupidatat dolor voluptate officia mollit eu nostrud ipsum. Dolor labore ullamco nostrud consectetur dolor duis qui magna reprehenderit. Esse reprehenderit dolor fugiat sunt adipisicing est. Aliquip duis pariatur labore amet sit occaecat ea eiusmod cillum. Adipisicing magna aute officia cillum non.'\n }\n </span>\n <div style={{ position: 'relative', display: 'inline' }}>\n <span ref={controllerRef} style={{ display: 'inline-block', color: 'red' }}>\n {'Jeg er en tooltip tekst.'}\n </span>\n <HelpBubble\n {...props}\n onClose={() => {\n alert('Bubble closed');\n }}\n controllerRef={controllerRef}\n >\n {props.children}\n </HelpBubble>\n </div>\n <span>\n {\n 'Consequat adipisicing nostrud non in labore sunt consequat mollit dolore quis voluptate eu veniam adipisicing. Dolor ipsum excepteur anim id ea dolore esse. Sint exercitation duis pariatur in qui ea reprehenderit consectetur sunt minim in ut cupidatat dolore. Eiusmod ut Lorem nostrud id adipisicing ullamco enim. Velit officia mollit laboris amet reprehenderit ad. Nisi cupidatat dolor voluptate officia mollit eu nostrud ipsum. Dolor labore ullamco nostrud consectetur dolor duis qui magna reprehenderit. Esse reprehenderit dolor fugiat sunt adipisicing est. Aliquip duis pariatur labore amet sit occaecat ea eiusmod cillum. Adipisicing magna aute officia cillum non.'\n }\n </span>\n </div>\n );\n};\n\nexport default HelpBubbleExample;\n"],"names":["HelpBubbleExample","props","controllerRef","useRef","React","HelpBubble"
|
|
1
|
+
{"version":3,"file":"HelpBubbleExample.js","sources":["../../../src/components/HelpBubbleExample/HelpBubbleExample.tsx"],"sourcesContent":["import React, { useRef } from 'react';\n\nimport HelpBubble, { HelpBubbleProps } from '../HelpBubble/HelpBubble';\n\nconst HelpBubbleExample: React.FC<HelpBubbleProps> = props => {\n const controllerRef = useRef<HTMLSpanElement>(null);\n\n return (\n <div>\n <span>\n {\n 'Consequat adipisicing nostrud non in labore sunt consequat mollit dolore quis voluptate eu veniam adipisicing. Dolor ipsum excepteur anim id ea dolore esse. Sint exercitation duis pariatur in qui ea reprehenderit consectetur sunt minim in ut cupidatat dolore. Eiusmod ut Lorem nostrud id adipisicing ullamco enim. Velit officia mollit laboris amet reprehenderit ad. Nisi cupidatat dolor voluptate officia mollit eu nostrud ipsum. Dolor labore ullamco nostrud consectetur dolor duis qui magna reprehenderit. Esse reprehenderit dolor fugiat sunt adipisicing est. Aliquip duis pariatur labore amet sit occaecat ea eiusmod cillum. Adipisicing magna aute officia cillum non.'\n }\n </span>\n <div style={{ position: 'relative', display: 'inline' }}>\n <span ref={controllerRef} style={{ display: 'inline-block', color: 'red' }}>\n {'Jeg er en tooltip tekst.'}\n </span>\n <HelpBubble\n {...props}\n onClose={() => {\n alert('Bubble closed');\n }}\n controllerRef={controllerRef}\n >\n {props.children}\n </HelpBubble>\n </div>\n <span>\n {\n 'Consequat adipisicing nostrud non in labore sunt consequat mollit dolore quis voluptate eu veniam adipisicing. Dolor ipsum excepteur anim id ea dolore esse. Sint exercitation duis pariatur in qui ea reprehenderit consectetur sunt minim in ut cupidatat dolore. Eiusmod ut Lorem nostrud id adipisicing ullamco enim. Velit officia mollit laboris amet reprehenderit ad. Nisi cupidatat dolor voluptate officia mollit eu nostrud ipsum. Dolor labore ullamco nostrud consectetur dolor duis qui magna reprehenderit. Esse reprehenderit dolor fugiat sunt adipisicing est. Aliquip duis pariatur labore amet sit occaecat ea eiusmod cillum. Adipisicing magna aute officia cillum non.'\n }\n </span>\n </div>\n );\n};\n\nexport default HelpBubbleExample;\n"],"names":["HelpBubbleExample","props","controllerRef","useRef","React","HelpBubble"],"mappings":";;AAIA,MAAMA,IAA+C,CAASC,MAAA;AACtD,QAAAC,IAAgBC,EAAwB,IAAI;AAGhD,SAAAC,gBAAAA,EAAA,cAAC,OACC,MAAAA,gBAAAA,EAAA,cAAC,QAEG,MAAA,+pBAEJ,GACAA,gBAAAA,EAAA,cAAC,OAAI,EAAA,OAAO,EAAE,UAAU,YAAY,SAAS,SAAS,EAAA,GACnDA,gBAAAA,EAAA,cAAA,QAAA,EAAK,KAAKF,GAAe,OAAO,EAAE,SAAS,gBAAgB,OAAO,MAChE,EAAA,GAAA,0BACH,GACAE,gBAAAA,EAAA;AAAA,IAACC;AAAA,IAAA;AAAA,MACE,GAAGJ;AAAA,MACJ,SAAS,MAAM;AACb,cAAM,eAAe;AAAA,MACvB;AAAA,MACA,eAAAC;AAAA,IAAA;AAAA,IAECD,EAAM;AAAA,EAAA,CAEX,GACCG,gBAAAA,EAAA,cAAA,QAAA,MAEG,+pBAEJ,CACF;AAEJ;"}
|