@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
package/components/Tabs/Tabs.js
CHANGED
|
@@ -1,19 +1,88 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
a
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import r, { useState as c, useRef as v, useEffect as x } from "react";
|
|
2
|
+
import y from "classnames";
|
|
3
|
+
import O from "./Tab.js";
|
|
4
|
+
import W from "./TabList/TabList.js";
|
|
5
|
+
import Z from "./TabPanel/TabPanel.js";
|
|
6
|
+
import { ZIndex as $ } from "../../constants.js";
|
|
7
|
+
import { useSticky as j } from "../../hooks/useSticky.js";
|
|
8
|
+
import { isMobileUA as q } from "../../utils/mobile.js";
|
|
9
|
+
import l from "../Tabs/styles.module.scss";
|
|
10
|
+
const B = 75, G = ({ activeTab: L, children: m, className: A, color: f = "white", sticky: C = !0, testId: M, type: u = "normal" }) => {
|
|
11
|
+
const w = L !== void 0, [N, g] = c(0), [d, k] = c(0), [p, D] = c(0), [I, a] = c(0), [P, h] = c(null), X = q(), n = v(null), s = v(null), S = v(null), T = (t, o) => {
|
|
12
|
+
w || (g(t), t > o ? (a(0), _()) : t < o && (a(0), U()));
|
|
13
|
+
}, U = () => {
|
|
14
|
+
X && h("right");
|
|
15
|
+
}, _ = () => {
|
|
16
|
+
X && h("left");
|
|
17
|
+
}, z = () => {
|
|
18
|
+
h(null);
|
|
19
|
+
}, e = w ? L : N;
|
|
20
|
+
x(() => {
|
|
21
|
+
const t = (i) => {
|
|
22
|
+
k(i.touches[0].clientX);
|
|
23
|
+
}, o = (i) => {
|
|
24
|
+
D(i.touches[0].clientX);
|
|
25
|
+
const b = i.touches[0].clientX - d;
|
|
26
|
+
e === 0 && b > 0 || e === r.Children.count(m) - 1 && b < 0 ? a(0) : a(b);
|
|
27
|
+
}, R = () => {
|
|
28
|
+
Math.abs(p - d) >= B && (p > d ? T(Math.max(0, e - 1), e) : T(Math.min(r.Children.count(m) - 1, e + 1), e)), a(0);
|
|
29
|
+
};
|
|
30
|
+
return n.current && (n.current.addEventListener("touchstart", t), n.current.addEventListener("touchmove", o), n.current.addEventListener("touchend", R)), () => {
|
|
31
|
+
n.current && (n.current.removeEventListener("touchstart", t), n.current.removeEventListener("touchmove", o), n.current.removeEventListener("touchend", R));
|
|
32
|
+
};
|
|
33
|
+
}, [d, p, e]), x(() => {
|
|
34
|
+
const t = () => {
|
|
35
|
+
z();
|
|
36
|
+
};
|
|
37
|
+
return s.current && s.current.addEventListener("animationend", t), () => {
|
|
38
|
+
s.current && s.current.removeEventListener("animationend", t);
|
|
39
|
+
};
|
|
40
|
+
}, []);
|
|
41
|
+
const { isOutsideWindow: F } = j(S, n);
|
|
42
|
+
return /* @__PURE__ */ r.createElement("div", { className: A, "data-testid": M }, /* @__PURE__ */ r.createElement(
|
|
43
|
+
"div",
|
|
44
|
+
{
|
|
45
|
+
ref: S,
|
|
46
|
+
className: y(l["tab-list-wrapper"], {
|
|
47
|
+
[l["tab-list-wrapper--sticky"]]: C && F
|
|
48
|
+
}),
|
|
49
|
+
style: { zIndex: $.TabsSticky }
|
|
50
|
+
},
|
|
51
|
+
/* @__PURE__ */ r.createElement(
|
|
52
|
+
W,
|
|
53
|
+
{
|
|
54
|
+
onTabListClick: (t) => T(t, e),
|
|
55
|
+
selectedTab: e,
|
|
56
|
+
color: f,
|
|
57
|
+
type: u
|
|
58
|
+
},
|
|
59
|
+
m
|
|
60
|
+
),
|
|
61
|
+
/* @__PURE__ */ r.createElement(
|
|
62
|
+
"div",
|
|
63
|
+
{
|
|
64
|
+
className: y(l["panel-wrapper"], l[`panel-wrapper--${f}`], {
|
|
65
|
+
[l["panel-wrapper--framed"]]: u == "framed"
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
)
|
|
69
|
+
), /* @__PURE__ */ r.createElement("div", { ref: n, style: { marginTop: u == "framed" ? "-40px" : "" } }, /* @__PURE__ */ r.createElement(
|
|
70
|
+
Z,
|
|
71
|
+
{
|
|
72
|
+
ref: s,
|
|
73
|
+
color: f,
|
|
74
|
+
type: u,
|
|
75
|
+
isFirst: e == 0,
|
|
76
|
+
translateX: I,
|
|
77
|
+
animate: P
|
|
78
|
+
},
|
|
79
|
+
r.Children.toArray(m)[e]
|
|
80
|
+
)));
|
|
81
|
+
}, E = G;
|
|
82
|
+
E.displayName = "Tabs";
|
|
83
|
+
E.Tab = O;
|
|
84
|
+
E.Tab.displayName = "Tabs.Tab";
|
|
16
85
|
export {
|
|
17
|
-
|
|
86
|
+
E as default
|
|
18
87
|
};
|
|
19
88
|
//# sourceMappingURL=Tabs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tabs.js","sources":["../../../src/components/Tabs/Tabs.tsx"],"sourcesContent":["import React, { useState } from 'react';\n\nimport Tab from './Tab';\nimport TabList from './TabList';\nimport TabPanel from './TabPanel';\nimport { PaletteNames } from '../../theme/palette';\nexport type { TabProps } from './Tab';\n\nimport styles from './styles.module.scss';\n\nexport type TabsColors = Extract<PaletteNames, 'blueberry' | 'neutral' | 'white'>;\n\nexport type TabsType = 'normal' | 'framed';\n\nexport interface TabsProps {\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Sets the color of the tabs. Default: white */\n color?: TabsColors;\n /** Sets the visual type of the tabs */\n type?: TabsType;\n /** Controlled state for Tabs component */\n activeTab?: number;\n}\n\nconst TabsRoot: React.FC<TabsProps> = ({ children, testId, color = 'white', type = 'normal', activeTab }) => {\n const isControlled = activeTab !== undefined;\n const [uncontrolledValue, setUncontrolledValue] = useState(0);\n\n const onValueChange = (newValue: number): void => {\n if (!isControlled) {\n setUncontrolledValue(newValue);\n }\n };\n\n const activeTabIndex = isControlled ? activeTab : uncontrolledValue;\n\n return (\n <div className={styles.tabs} data-testid={testId}>\n <TabList onTabListClick={(index: number) => onValueChange(index)} selectedTab={activeTabIndex} color={color} type={type}>\n {children}\n </TabList>\n <TabPanel color={color} type={type} isFirst={activeTabIndex == 0}>\n {React.Children.toArray(children)[activeTabIndex]}\n </TabPanel>\n </div>\n );\n};\n\ntype TabsComponent = typeof TabsRoot & {\n Tab: typeof Tab;\n};\nconst Tabs = TabsRoot as TabsComponent;\nTabs.displayName = 'Tabs';\nTabs.Tab = Tab;\nTabs.Tab.displayName = 'Tabs.Tab';\n\nexport default Tabs;\n"],"names":["TabsRoot","children","testId","color","type","activeTab","isControlled","uncontrolledValue","setUncontrolledValue","useState","onValueChange","newValue","activeTabIndex","React","styles","TabList","index","TabPanel","Tabs","Tab","Tabs$1"],"mappings":";;;;;AAyBA,MAAMA,IAAgC,CAAC,EAAE,UAAAC,GAAU,QAAAC,GAAQ,OAAAC,IAAQ,SAAS,MAAAC,IAAO,UAAU,WAAAC,QAAgB;AAC3G,QAAMC,IAAeD,MAAc,QAC7B,CAACE,GAAmBC,CAAoB,IAAIC,EAAS,CAAC,GAEtDC,IAAgB,CAACC,MAA2B;AAChD,IAAKL,KACHE,EAAqBG,CAAQ;AAAA,EAC/B,GAGIC,IAAiBN,IAAeD,IAAYE;AAElD,SACGM,gBAAAA,EAAA,cAAA,OAAA,EAAI,WAAWC,EAAO,MAAM,eAAaZ,EAAA,GACvCW,gBAAAA,EAAA,cAAAE,GAAA,EAAQ,gBAAgB,CAACC,MAAkBN,EAAcM,CAAK,GAAG,aAAaJ,GAAgB,OAAAT,GAAc,MAAAC,EAAA,GAC1GH,CACH,GACAY,gBAAAA,EAAA,cAACI,GAAS,EAAA,OAAAd,GAAc,MAAAC,GAAY,SAASQ,KAAkB,EAC5D,GAAAC,EAAM,SAAS,QAAQZ,CAAQ,EAAEW,CAAc,CAClD,CACF;AAEJ,GAKMM,IAAOlB;AACbkB,EAAK,cAAc;AACnBA,EAAK,MAAMC;AACXD,EAAK,IAAI,cAAc;AAEvB,MAAAE,IAAeF;"}
|
|
1
|
+
{"version":3,"file":"Tabs.js","sources":["../../../src/components/Tabs/Tabs.tsx"],"sourcesContent":["import React, { useState, useEffect, useRef } from 'react';\n\nimport classNames from 'classnames';\n\nimport Tab from './Tab';\nimport TabList from './TabList';\nimport TabPanel from './TabPanel';\nimport { ZIndex } from '../../constants';\nimport { useSticky } from '../../hooks/useSticky';\nimport { PaletteNames } from '../../theme/palette';\nimport { isMobileUA } from '../../utils/mobile';\n\nimport styles from './styles.module.scss';\n\nexport type { TabProps } from './Tab';\nexport type TabsColors = Extract<PaletteNames, 'blueberry' | 'neutral' | 'white'>;\nexport type TabsType = 'normal' | 'framed';\n\nexport interface TabsProps {\n /** Controlled state for Tabs component */\n activeTab?: number;\n /** Adds custom classes to the element. */\n className?: string;\n /** Sets the color of the tabs. Default: white */\n color?: TabsColors;\n /** Whether the tab list should be sticky */\n sticky?: boolean;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Sets the visual type of the tabs */\n type?: TabsType;\n}\n\nconst swipeDistanceThreshold = 75;\n\nconst TabsRoot: React.FC<TabsProps> = ({ activeTab, children, className, color = 'white', sticky = true, testId, type = 'normal' }) => {\n const isControlled = activeTab !== undefined;\n const [uncontrolledValue, setUncontrolledValue] = useState(0);\n const [touchStartX, setTouchStartX] = useState(0);\n const [touchEndX, setTouchEndX] = useState(0);\n const [translateX, setTranslateX] = useState(0);\n const [panelAnimation, setPanelAnimation] = useState<'left' | 'right' | null>(null);\n const mobile = isMobileUA();\n const tabsRef = useRef<HTMLDivElement>(null);\n const tabPanelRef = useRef<HTMLDivElement>(null);\n const tabListRef = useRef<HTMLDivElement>(null);\n\n const onValueChange = (newValue: number, oldValue: number): void => {\n if (!isControlled) {\n setUncontrolledValue(newValue);\n if (newValue > oldValue) {\n // make sure that the translateX is reset so the animation does not go outside the screen\n setTranslateX(0);\n onLeftSwipe();\n } else if (newValue < oldValue) {\n // make sure that the translateX is reset so the animation does not go outside the screen\n setTranslateX(0);\n onRightSwipe();\n }\n }\n };\n\n const onRightSwipe = (): void => {\n mobile && setPanelAnimation('right');\n };\n\n const onLeftSwipe = (): void => {\n mobile && setPanelAnimation('left');\n };\n\n const resetAnimation = (): void => {\n setPanelAnimation(null);\n };\n\n const activeTabIndex = isControlled ? activeTab : uncontrolledValue;\n\n useEffect(() => {\n const handleTouchStart = (event: TouchEvent): void => {\n setTouchStartX(event.touches[0].clientX);\n };\n\n const handleTouchMove = (event: TouchEvent): void => {\n setTouchEndX(event.touches[0].clientX);\n const newTranslateX = event.touches[0].clientX - touchStartX;\n\n if (activeTabIndex === 0 && newTranslateX > 0) {\n setTranslateX(0);\n } else if (activeTabIndex === React.Children.count(children) - 1 && newTranslateX < 0) {\n setTranslateX(0);\n } else {\n setTranslateX(newTranslateX);\n }\n };\n\n const handleTouchEnd = (): void => {\n const swipeDistance = Math.abs(touchEndX - touchStartX);\n if (swipeDistance >= swipeDistanceThreshold) {\n if (touchEndX > touchStartX) {\n // User swiped right\n onValueChange(Math.max(0, activeTabIndex - 1), activeTabIndex);\n } else {\n // User swiped left\n onValueChange(Math.min(React.Children.count(children) - 1, activeTabIndex + 1), activeTabIndex);\n }\n }\n setTranslateX(0);\n };\n\n if (tabsRef.current) {\n tabsRef.current.addEventListener('touchstart', handleTouchStart);\n tabsRef.current.addEventListener('touchmove', handleTouchMove);\n tabsRef.current.addEventListener('touchend', handleTouchEnd);\n }\n return () => {\n if (tabsRef.current) {\n tabsRef.current.removeEventListener('touchstart', handleTouchStart);\n tabsRef.current.removeEventListener('touchmove', handleTouchMove);\n tabsRef.current.removeEventListener('touchend', handleTouchEnd);\n }\n };\n }, [touchStartX, touchEndX, activeTabIndex]);\n\n useEffect(() => {\n const handleAnimationEnd = (): void => {\n resetAnimation();\n };\n\n if (tabPanelRef.current) {\n tabPanelRef.current.addEventListener('animationend', handleAnimationEnd);\n }\n\n return () => {\n if (tabPanelRef.current) {\n tabPanelRef.current.removeEventListener('animationend', handleAnimationEnd);\n }\n };\n }, []);\n\n const { isOutsideWindow } = useSticky(tabListRef, tabsRef);\n\n return (\n <div className={className} data-testid={testId}>\n <div\n ref={tabListRef}\n className={classNames(styles['tab-list-wrapper'], {\n [styles['tab-list-wrapper--sticky']]: sticky && isOutsideWindow,\n })}\n style={{ zIndex: ZIndex.TabsSticky }}\n >\n <TabList\n onTabListClick={(index: number) => onValueChange(index, activeTabIndex)}\n selectedTab={activeTabIndex}\n color={color}\n type={type}\n >\n {children}\n </TabList>\n <div\n className={classNames(styles['panel-wrapper'], styles[`panel-wrapper--${color}`], {\n [styles['panel-wrapper--framed']]: type == 'framed',\n })}\n ></div>\n </div>\n <div ref={tabsRef} style={{ marginTop: type == 'framed' ? '-40px' : '' }}>\n <TabPanel\n ref={tabPanelRef}\n color={color}\n type={type}\n isFirst={activeTabIndex == 0}\n translateX={translateX}\n animate={panelAnimation}\n >\n {React.Children.toArray(children)[activeTabIndex]}\n </TabPanel>\n </div>\n </div>\n );\n};\n\ntype TabsComponent = typeof TabsRoot & {\n Tab: typeof Tab;\n};\nconst Tabs = TabsRoot as TabsComponent;\nTabs.displayName = 'Tabs';\nTabs.Tab = Tab;\nTabs.Tab.displayName = 'Tabs.Tab';\n\nexport default Tabs;\n"],"names":["swipeDistanceThreshold","TabsRoot","activeTab","children","className","color","sticky","testId","type","isControlled","uncontrolledValue","setUncontrolledValue","useState","touchStartX","setTouchStartX","touchEndX","setTouchEndX","translateX","setTranslateX","panelAnimation","setPanelAnimation","mobile","isMobileUA","tabsRef","useRef","tabPanelRef","tabListRef","onValueChange","newValue","oldValue","onLeftSwipe","onRightSwipe","resetAnimation","activeTabIndex","useEffect","handleTouchStart","event","handleTouchMove","newTranslateX","React","handleTouchEnd","handleAnimationEnd","isOutsideWindow","useSticky","classNames","styles","ZIndex","TabList","index","TabPanel","Tabs","Tab"],"mappings":";;;;;;;;;AAiCA,MAAMA,IAAyB,IAEzBC,IAAgC,CAAC,EAAE,WAAAC,GAAW,UAAAC,GAAU,WAAAC,GAAW,OAAAC,IAAQ,SAAS,QAAAC,IAAS,IAAM,QAAAC,GAAQ,MAAAC,IAAO,eAAe;AACrI,QAAMC,IAAeP,MAAc,QAC7B,CAACQ,GAAmBC,CAAoB,IAAIC,EAAS,CAAC,GACtD,CAACC,GAAaC,CAAc,IAAIF,EAAS,CAAC,GAC1C,CAACG,GAAWC,CAAY,IAAIJ,EAAS,CAAC,GACtC,CAACK,GAAYC,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gBAAAA,EAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,WAAWK,EAAWC,EAAO,eAAe,GAAGA,EAAO,kBAAkBxC,CAAK,EAAE,GAAG;AAAA,UAChF,CAACwC,EAAO,uBAAuB,CAAC,GAAGrC,KAAQ;AAAA,QAAA,CAC5C;AAAA,MAAA;AAAA,IACF;AAAA,EAAA,GAEH+B,gBAAAA,EAAA,cAAC,OAAI,EAAA,KAAKhB,GAAS,OAAO,EAAE,WAAWf,KAAQ,WAAW,UAAU,GAClE,EAAA,GAAA+B,gBAAAA,EAAA;AAAA,IAACU;AAAA,IAAA;AAAA,MACC,KAAKxB;AAAA,MACL,OAAApB;AAAA,MACA,MAAAG;AAAA,MACA,SAASyB,KAAkB;AAAA,MAC3B,YAAAhB;AAAA,MACA,SAASE;AAAA,IAAA;AAAA,IAERoB,EAAM,SAAS,QAAQpC,CAAQ,EAAE8B,CAAc;AAAA,EAEpD,CAAA,CACF;AAEJ,GAKMiB,IAAOjD;AACbiD,EAAK,cAAc;AACnBA,EAAK,MAAMC;AACXD,EAAK,IAAI,cAAc;"}
|
|
@@ -1,3 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
@use 'sass:map';
|
|
2
|
+
@import '../../scss/supernova/styles/colors';
|
|
3
|
+
@import '../../scss/breakpoints';
|
|
4
|
+
|
|
5
|
+
.tab-list-wrapper {
|
|
6
|
+
position: relative;
|
|
7
|
+
|
|
8
|
+
&--sticky {
|
|
9
|
+
position: sticky;
|
|
10
|
+
top: 0;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.panel-wrapper {
|
|
15
|
+
$panel-wrapper: &;
|
|
16
|
+
$colors: 'blueberry', 'neutral', 'white';
|
|
17
|
+
|
|
18
|
+
border-top: 1px solid var(--color-action-border-onlight-focus);
|
|
19
|
+
position: relative;
|
|
20
|
+
width: 100%;
|
|
21
|
+
|
|
22
|
+
&--framed {
|
|
23
|
+
border-radius: 0;
|
|
24
|
+
height: 50px;
|
|
25
|
+
|
|
26
|
+
@media (min-width: map.get($grid-breakpoints, md)) {
|
|
27
|
+
border-radius: 0 0.5rem 0 0;
|
|
28
|
+
border-right: 1px solid var(--color-action-border-onlight-focus);
|
|
29
|
+
border-left: 1px solid var(--color-action-border-onlight-focus);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@each $color in $colors {
|
|
34
|
+
&--#{$color} {
|
|
35
|
+
background: linear-gradient(var(--color-base-background-#{$color}), #0000);
|
|
36
|
+
pointer-events: none;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
3
39
|
}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
export type Styles = {
|
|
2
|
-
|
|
2
|
+
'panel-wrapper': string;
|
|
3
|
+
'panel-wrapper--blueberry': string;
|
|
4
|
+
'panel-wrapper--framed': string;
|
|
5
|
+
'panel-wrapper--neutral': string;
|
|
6
|
+
'panel-wrapper--white': string;
|
|
7
|
+
'tab-list-wrapper': string;
|
|
8
|
+
'tab-list-wrapper--sticky': string;
|
|
3
9
|
};
|
|
4
10
|
|
|
5
11
|
export type ClassNames = keyof Styles;
|
package/components/Tag/Tag.js
CHANGED
|
@@ -6,7 +6,7 @@ import { palette as g } from "../../theme/palette.js";
|
|
|
6
6
|
import { Icon as v } from "../Icon/Icon.js";
|
|
7
7
|
import h from "../Icons/Undo.js";
|
|
8
8
|
import X from "../Icons/X.js";
|
|
9
|
-
import b from "../LazyIcon/LazyIcon.js";
|
|
9
|
+
import { LazyIcon as b } from "../LazyIcon/LazyIcon.js";
|
|
10
10
|
import t from "../Tag/styles.module.scss";
|
|
11
11
|
var z = /* @__PURE__ */ ((e) => (e.medium = "medium", e.large = "large", e))(z || {}), E = /* @__PURE__ */ ((e) => (e.remove = "remove", e.undo = "undo", e))(E || {}), N = /* @__PURE__ */ ((e) => (e.normal = "normal", e.oncolor = "oncolor", e.emphasised = "emphasised", e))(N || {});
|
|
12
12
|
const _ = (e) => {
|
|
@@ -33,12 +33,12 @@ const _ = (e) => {
|
|
|
33
33
|
isHovered: d
|
|
34
34
|
}
|
|
35
35
|
));
|
|
36
|
-
},
|
|
36
|
+
}, j = (e) => {
|
|
37
37
|
const { children: s, size: c = "medium", color: a = "blueberry", svgIcon: r, variant: o = "normal", action: m, onClick: l, testId: i } = e, d = p(t.tag, t[`tag--${c}`], t[`tag--${a}`], t[`tag--${o}`], {
|
|
38
38
|
[t["tag--has-icon"]]: r
|
|
39
39
|
});
|
|
40
40
|
return m && l ? /* @__PURE__ */ n.createElement(_, { size: c, color: a, variant: o, action: m, onClick: l, testId: i }, s) : /* @__PURE__ */ n.createElement("span", { className: d, "data-testid": i, "data-analyticsid": f.Tag }, r && (typeof r == "string" ? /* @__PURE__ */ n.createElement(b, { iconName: r, size: u.XXSmall, color: g[`${a}800`], className: t.tag__icon }) : /* @__PURE__ */ n.createElement(v, { svgIcon: r, size: u.XXSmall, color: g[`${a}800`], className: t.tag__icon })), s);
|
|
41
|
-
}
|
|
41
|
+
};
|
|
42
42
|
export {
|
|
43
43
|
E as TagAction,
|
|
44
44
|
z as TagSize,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tag.js","sources":["../../../src/components/Tag/Tag.tsx"],"sourcesContent":["import React from 'react';\n\nimport cn from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\nimport { useHover } from '../../hooks/useHover';\nimport { palette, PaletteNames } from '../../theme/palette';\nimport Icon, { IconSize, SvgIcon } from '../Icon';\nimport { IconName } from '../Icons/IconNames';\nimport Undo from '../Icons/Undo';\nimport X from '../Icons/X';\nimport LazyIcon from '../LazyIcon';\n\nimport styles from './styles.module.scss';\n\nexport enum TagSize {\n medium = 'medium',\n large = 'large',\n}\n\nexport enum TagAction {\n remove = 'remove',\n undo = 'undo',\n}\n\nexport enum TagVariant {\n normal = 'normal',\n oncolor = 'oncolor',\n emphasised = 'emphasised',\n}\n\nexport type TagColors = Extract<PaletteNames, 'blueberry' | 'neutral' | 'cherry' | 'banana' | 'kiwi' | 'plum'>;\n\nexport interface TagProps {\n /** Sets the text of the tag */\n children: string;\n /** Sets the size of the tag. Default: small */\n size?: keyof typeof TagSize;\n /** Sets the background of the tag. Not used if action is \"undo\". Default: blueberry */\n color?: TagColors;\n /** Adds an icon to the tag. Not shown if action is set. */\n svgIcon?: SvgIcon | IconName;\n /* Changes the appearance of the tag. Not used if action is \"undo\". Default: normal */\n variant?: keyof typeof TagVariant;\n /* Makes the tag a clickable button that performs an action. onClick must also be set. */\n action?: keyof typeof TagAction;\n /* Called when action is set and the tag is clicked on. action must also be set. */\n onClick?: () => void;\n /** Sets the data-testid attribute on the expander button. */\n testId?: string;\n}\n\ntype ActionTagProps = Required<Pick<TagProps, 'children' | 'size' | 'color' | 'variant' | 'action' | 'onClick'>> & Pick<TagProps, 'testId'>;\n\nconst ActionTag: React.FC<ActionTagProps> = props => {\n const { children, size, color, variant, action, onClick, testId } = props;\n\n const { hoverRef, isHovered } = useHover<HTMLButtonElement>();\n\n const tagClasses = cn(\n styles.tag,\n styles[`tag--${size}`],\n action === 'undo' && styles[`tag--${action}`],\n styles['tag--has-action'],\n action === 'remove' && [styles[`tag--${color}`], styles[`tag--${variant}`]]\n );\n\n const getActionIcon = (): SvgIcon => {\n switch (action) {\n case 'remove':\n return X;\n case 'undo':\n return Undo;\n }\n };\n\n return (\n <button className={tagClasses} onClick={onClick} ref={hoverRef} type=\"button\" data-testid={testId} data-analyticsid={AnalyticsId.Tag}>\n {children}\n <Icon\n svgIcon={getActionIcon()}\n size={IconSize.XXSmall}\n color={palette[`${action === 'undo' ? 'blueberry' : color}800`]}\n isHovered={isHovered}\n />\n </button>\n );\n};\n\nconst Tag: React.FC<TagProps> = props => {\n const { children, size = TagSize.medium, color = 'blueberry', svgIcon, variant = 'normal', action, onClick, testId } = props;\n\n const tagClasses = cn(styles.tag, styles[`tag--${size}`], styles[`tag--${color}`], styles[`tag--${variant}`], {\n [styles['tag--has-icon']]: svgIcon,\n });\n\n if (action && onClick) {\n return (\n <ActionTag size={size} color={color} variant={variant} action={action} onClick={onClick} testId={testId}>\n {children}\n </ActionTag>\n );\n }\n\n return (\n <span className={tagClasses} data-testid={testId} data-analyticsid={AnalyticsId.Tag}>\n {svgIcon &&\n (typeof svgIcon === 'string' ? (\n <LazyIcon iconName={svgIcon} size={IconSize.XXSmall} color={palette[`${color}800`]} className={styles.tag__icon} />\n ) : (\n <Icon svgIcon={svgIcon} size={IconSize.XXSmall} color={palette[`${color}800`]} className={styles.tag__icon} />\n ))}\n {children}\n </span>\n );\n};\n\nexport default Tag;\n"],"names":["TagSize","TagAction","TagVariant","ActionTag","props","children","size","color","variant","action","onClick","testId","hoverRef","isHovered","useHover","tagClasses","cn","styles","getActionIcon","Undo","React","AnalyticsId","Icon","IconSize","palette","Tag","svgIcon","LazyIcon"
|
|
1
|
+
{"version":3,"file":"Tag.js","sources":["../../../src/components/Tag/Tag.tsx"],"sourcesContent":["import React from 'react';\n\nimport cn from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\nimport { useHover } from '../../hooks/useHover';\nimport { palette, PaletteNames } from '../../theme/palette';\nimport Icon, { IconSize, SvgIcon } from '../Icon';\nimport { IconName } from '../Icons/IconNames';\nimport Undo from '../Icons/Undo';\nimport X from '../Icons/X';\nimport LazyIcon from '../LazyIcon';\n\nimport styles from './styles.module.scss';\n\nexport enum TagSize {\n medium = 'medium',\n large = 'large',\n}\n\nexport enum TagAction {\n remove = 'remove',\n undo = 'undo',\n}\n\nexport enum TagVariant {\n normal = 'normal',\n oncolor = 'oncolor',\n emphasised = 'emphasised',\n}\n\nexport type TagColors = Extract<PaletteNames, 'blueberry' | 'neutral' | 'cherry' | 'banana' | 'kiwi' | 'plum'>;\n\nexport interface TagProps {\n /** Sets the text of the tag */\n children: string;\n /** Sets the size of the tag. Default: small */\n size?: keyof typeof TagSize;\n /** Sets the background of the tag. Not used if action is \"undo\". Default: blueberry */\n color?: TagColors;\n /** Adds an icon to the tag. Not shown if action is set. */\n svgIcon?: SvgIcon | IconName;\n /* Changes the appearance of the tag. Not used if action is \"undo\". Default: normal */\n variant?: keyof typeof TagVariant;\n /* Makes the tag a clickable button that performs an action. onClick must also be set. */\n action?: keyof typeof TagAction;\n /* Called when action is set and the tag is clicked on. action must also be set. */\n onClick?: () => void;\n /** Sets the data-testid attribute on the expander button. */\n testId?: string;\n}\n\ntype ActionTagProps = Required<Pick<TagProps, 'children' | 'size' | 'color' | 'variant' | 'action' | 'onClick'>> & Pick<TagProps, 'testId'>;\n\nconst ActionTag: React.FC<ActionTagProps> = props => {\n const { children, size, color, variant, action, onClick, testId } = props;\n\n const { hoverRef, isHovered } = useHover<HTMLButtonElement>();\n\n const tagClasses = cn(\n styles.tag,\n styles[`tag--${size}`],\n action === 'undo' && styles[`tag--${action}`],\n styles['tag--has-action'],\n action === 'remove' && [styles[`tag--${color}`], styles[`tag--${variant}`]]\n );\n\n const getActionIcon = (): SvgIcon => {\n switch (action) {\n case 'remove':\n return X;\n case 'undo':\n return Undo;\n }\n };\n\n return (\n <button className={tagClasses} onClick={onClick} ref={hoverRef} type=\"button\" data-testid={testId} data-analyticsid={AnalyticsId.Tag}>\n {children}\n <Icon\n svgIcon={getActionIcon()}\n size={IconSize.XXSmall}\n color={palette[`${action === 'undo' ? 'blueberry' : color}800`]}\n isHovered={isHovered}\n />\n </button>\n );\n};\n\nconst Tag: React.FC<TagProps> = props => {\n const { children, size = TagSize.medium, color = 'blueberry', svgIcon, variant = 'normal', action, onClick, testId } = props;\n\n const tagClasses = cn(styles.tag, styles[`tag--${size}`], styles[`tag--${color}`], styles[`tag--${variant}`], {\n [styles['tag--has-icon']]: svgIcon,\n });\n\n if (action && onClick) {\n return (\n <ActionTag size={size} color={color} variant={variant} action={action} onClick={onClick} testId={testId}>\n {children}\n </ActionTag>\n );\n }\n\n return (\n <span className={tagClasses} data-testid={testId} data-analyticsid={AnalyticsId.Tag}>\n {svgIcon &&\n (typeof svgIcon === 'string' ? (\n <LazyIcon iconName={svgIcon} size={IconSize.XXSmall} color={palette[`${color}800`]} className={styles.tag__icon} />\n ) : (\n <Icon svgIcon={svgIcon} size={IconSize.XXSmall} color={palette[`${color}800`]} className={styles.tag__icon} />\n ))}\n {children}\n </span>\n );\n};\n\nexport default Tag;\n"],"names":["TagSize","TagAction","TagVariant","ActionTag","props","children","size","color","variant","action","onClick","testId","hoverRef","isHovered","useHover","tagClasses","cn","styles","getActionIcon","Undo","React","AnalyticsId","Icon","IconSize","palette","Tag","svgIcon","LazyIcon"],"mappings":";;;;;;;;;;AAeY,IAAAA,sBAAAA,OACVA,EAAA,SAAS,UACTA,EAAA,QAAQ,SAFEA,IAAAA,KAAA,CAAA,CAAA,GAKAC,sBAAAA,OACVA,EAAA,SAAS,UACTA,EAAA,OAAO,QAFGA,IAAAA,KAAA,CAAA,CAAA,GAKAC,sBAAAA,OACVA,EAAA,SAAS,UACTA,EAAA,UAAU,WACVA,EAAA,aAAa,cAHHA,IAAAA,KAAA,CAAA,CAAA;AA6BZ,MAAMC,IAAsC,CAASC,MAAA;AAC7C,QAAA,EAAE,UAAAC,GAAU,MAAAC,GAAM,OAAAC,GAAO,SAAAC,GAAS,QAAAC,GAAQ,SAAAC,GAAS,QAAAC,EAAW,IAAAP,GAE9D,EAAE,UAAAQ,GAAU,WAAAC,EAAU,IAAIC,EAA4B,GAEtDC,IAAaC;AAAAA,IACjBC,EAAO;AAAA,IACPA,EAAO,QAAQX,CAAI,EAAE;AAAA,IACrBG,MAAW,UAAUQ,EAAO,QAAQR,CAAM,EAAE;AAAA,IAC5CQ,EAAO,iBAAiB;AAAA,IACxBR,MAAW,YAAY,CAACQ,EAAO,QAAQV,CAAK,EAAE,GAAGU,EAAO,QAAQT,CAAO,EAAE,CAAC;AAAA,EAAA,GAGtEU,IAAgB,MAAe;AACnC,YAAQT,GAAQ;AAAA,MACd,KAAK;AACI,eAAA;AAAA,MACT,KAAK;AACI,eAAAU;AAAA,IACX;AAAA,EAAA;AAG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,UAAW,CAAA,IAE/GZ,CACH;AAEJ;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import t from "react";
|
|
2
2
|
import { AnalyticsId as l } from "../../constants.js";
|
|
3
3
|
import a from "../TagList/styles.module.scss";
|
|
4
|
-
const
|
|
4
|
+
const d = ({ children: e, testId: s }) => /* @__PURE__ */ t.createElement("ul", { className: a["tag-list"], "data-testid": s, "data-analyticsid": l.TagList }, t.Children.map(e, (i) => /* @__PURE__ */ t.createElement("li", { className: a["tag-list__item"] }, i)));
|
|
5
5
|
export {
|
|
6
6
|
d as default
|
|
7
7
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TagList.js","sources":["../../../src/components/TagList/TagList.tsx"],"sourcesContent":["import React from 'react';\n\nimport { AnalyticsId } from '../../constants';\n\nimport styles from './styles.module.scss';\n\nexport interface TagListPropsProps {\n /** Sets the data-testid attribute on the expander button. */\n testId?: string;\n}\n\nconst TagList: React.FC<TagListPropsProps> = ({ children, testId }) => {\n return (\n <ul className={styles['tag-list']} data-testid={testId} data-analyticsid={AnalyticsId.TagList}>\n {React.Children.map(children, child => (\n <li className={styles['tag-list__item']}>{child}</li>\n ))}\n </ul>\n );\n};\n\nexport default TagList;\n"],"names":["TagList","children","testId","React","styles","AnalyticsId","child"
|
|
1
|
+
{"version":3,"file":"TagList.js","sources":["../../../src/components/TagList/TagList.tsx"],"sourcesContent":["import React from 'react';\n\nimport { AnalyticsId } from '../../constants';\n\nimport styles from './styles.module.scss';\n\nexport interface TagListPropsProps {\n /** Sets the data-testid attribute on the expander button. */\n testId?: string;\n}\n\nconst TagList: React.FC<TagListPropsProps> = ({ children, testId }) => {\n return (\n <ul className={styles['tag-list']} data-testid={testId} data-analyticsid={AnalyticsId.TagList}>\n {React.Children.map(children, child => (\n <li className={styles['tag-list__item']}>{child}</li>\n ))}\n </ul>\n );\n};\n\nexport default TagList;\n"],"names":["TagList","children","testId","React","styles","AnalyticsId","child"],"mappings":";;;AAWA,MAAMA,IAAuC,CAAC,EAAE,UAAAC,GAAU,QAAAC,QAEtDC,gBAAAA,EAAA,cAAC,MAAG,EAAA,WAAWC,EAAO,UAAU,GAAG,eAAaF,GAAQ,oBAAkBG,EAAY,QACnF,GAAAF,EAAM,SAAS,IAAIF,GAAU,CAC5BK,MAAAH,gBAAAA,EAAA,cAAC,MAAG,EAAA,WAAWC,EAAO,gBAAgB,EAAA,GAAIE,CAAM,CACjD,CACH;"}
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import o, { useState as A, useRef as
|
|
1
|
+
import o, { useState as A, useRef as ee, useEffect as B } from "react";
|
|
2
2
|
import p from "classnames";
|
|
3
|
-
import { FormMode as m, AnalyticsId as
|
|
4
|
-
import { useUuid as
|
|
5
|
-
import { getAriaDescribedBy as
|
|
6
|
-
import { uuid as
|
|
7
|
-
import
|
|
8
|
-
import { renderLabel as
|
|
9
|
-
import
|
|
3
|
+
import { FormMode as m, AnalyticsId as te, AVERAGE_CHARACTER_WIDTH_PX as re } from "../../constants.js";
|
|
4
|
+
import { useUuid as ae } from "../../hooks/useUuid.js";
|
|
5
|
+
import { getAriaDescribedBy as oe } from "../../utils/accessibility.js";
|
|
6
|
+
import { uuid as ne } from "../../utils/uuid.js";
|
|
7
|
+
import { ErrorWrapper as ie } from "../ErrorWrapper/ErrorWrapper.js";
|
|
8
|
+
import { renderLabel as se } from "../Label/Label.js";
|
|
9
|
+
import ce from "../MaxCharacters/MaxCharacters.js";
|
|
10
10
|
import t from "../Textarea/styles.module.scss";
|
|
11
|
-
const
|
|
11
|
+
const de = (a) => `calc(${a * re}px + 2rem + 16px + 4px)`, le = o.forwardRef((a, x) => {
|
|
12
12
|
const {
|
|
13
13
|
maxCharacters: n,
|
|
14
14
|
maxText: h,
|
|
15
15
|
width: f,
|
|
16
|
-
testId:
|
|
16
|
+
testId: N,
|
|
17
17
|
defaultValue: s,
|
|
18
18
|
marginBottom: M,
|
|
19
|
-
transparent:
|
|
19
|
+
transparent: $,
|
|
20
20
|
mode: i = m.onwhite,
|
|
21
|
-
label:
|
|
22
|
-
textareaId: b =
|
|
21
|
+
label: k,
|
|
22
|
+
textareaId: b = ne(),
|
|
23
23
|
minRows: g = 3,
|
|
24
24
|
maxRows: c = 10,
|
|
25
25
|
grow: w,
|
|
26
|
-
error:
|
|
26
|
+
error: D,
|
|
27
27
|
errorText: C,
|
|
28
|
-
errorTextId:
|
|
29
|
-
autoFocus:
|
|
30
|
-
disabled:
|
|
31
|
-
name:
|
|
28
|
+
errorTextId: L,
|
|
29
|
+
autoFocus: S,
|
|
30
|
+
disabled: F,
|
|
31
|
+
name: U,
|
|
32
32
|
autoComplete: T = "off",
|
|
33
|
-
placeholder:
|
|
34
|
-
readOnly:
|
|
35
|
-
required:
|
|
33
|
+
placeholder: V,
|
|
34
|
+
readOnly: q,
|
|
35
|
+
required: z,
|
|
36
36
|
onChange: E,
|
|
37
|
-
...
|
|
38
|
-
} = a, [
|
|
37
|
+
...G
|
|
38
|
+
} = a, [O, W] = A(g), [y, R] = A(s || ""), d = ee(null), v = ae(L);
|
|
39
39
|
B(() => {
|
|
40
40
|
R(s || "");
|
|
41
41
|
}, [s]);
|
|
@@ -44,15 +44,15 @@ const le = (a) => `calc(${a * ae}px + 2rem + 16px + 4px)`, N = o.forwardRef((a,
|
|
|
44
44
|
e.rows = g;
|
|
45
45
|
const r = Math.floor((e.scrollHeight - 16) / 28);
|
|
46
46
|
r === l && (e.rows = r), r >= c && (e.rows = c, e.scrollTop = e.scrollHeight), r < c ? W(r) : W(c);
|
|
47
|
-
},
|
|
47
|
+
}, P = i === m.ondark, X = i === m.onblueberry, j = !!n && y.toString().length > n, H = i === m.oninvalid || !!C || !!D || j, J = p(t.textarea, {
|
|
48
48
|
[t["textarea--gutterBottom"]]: M
|
|
49
|
-
}),
|
|
50
|
-
[t["input-container--transparent"]]:
|
|
51
|
-
[t["input-container--on-blueberry"]]:
|
|
52
|
-
[t["input-container--on-dark"]]:
|
|
49
|
+
}), K = p(t["input-container"], {
|
|
50
|
+
[t["input-container--transparent"]]: $,
|
|
51
|
+
[t["input-container--on-blueberry"]]: X,
|
|
52
|
+
[t["input-container--on-dark"]]: P,
|
|
53
53
|
[t["input-container--invalid"]]: H,
|
|
54
54
|
[t["input-container--disabled"]]: a.disabled
|
|
55
|
-
}),
|
|
55
|
+
}), Q = p(t["input-container__input"], {
|
|
56
56
|
[t["input-container__input--disabled"]]: a.disabled
|
|
57
57
|
});
|
|
58
58
|
B(() => {
|
|
@@ -62,33 +62,33 @@ const le = (a) => `calc(${a * ae}px + 2rem + 16px + 4px)`, N = o.forwardRef((a,
|
|
|
62
62
|
_(r);
|
|
63
63
|
}
|
|
64
64
|
}, []);
|
|
65
|
-
const
|
|
65
|
+
const Y = (e) => {
|
|
66
66
|
w && _(e.target), R(e.target.value);
|
|
67
|
-
},
|
|
68
|
-
E && E(e),
|
|
69
|
-
}, I = f ?
|
|
70
|
-
return /* @__PURE__ */ o.createElement(
|
|
67
|
+
}, Z = (e) => {
|
|
68
|
+
E && E(e), Y(e);
|
|
69
|
+
}, I = f ? de(f) : void 0;
|
|
70
|
+
return /* @__PURE__ */ o.createElement(ie, { errorText: C, errorTextId: v }, /* @__PURE__ */ o.createElement("div", { "data-testid": N, "data-analyticsid": te.Textarea, className: J }, se(k, b, i), /* @__PURE__ */ o.createElement("div", { className: K, ref: d, style: { maxWidth: I } }, /* @__PURE__ */ o.createElement(
|
|
71
71
|
"textarea",
|
|
72
72
|
{
|
|
73
|
-
rows:
|
|
73
|
+
rows: O,
|
|
74
74
|
defaultValue: s,
|
|
75
75
|
id: b,
|
|
76
|
-
className:
|
|
76
|
+
className: Q,
|
|
77
77
|
ref: x,
|
|
78
|
-
"aria-describedby":
|
|
78
|
+
"aria-describedby": oe(a, v),
|
|
79
79
|
"aria-invalid": !!H,
|
|
80
|
-
autoFocus:
|
|
81
|
-
disabled:
|
|
82
|
-
name:
|
|
80
|
+
autoFocus: S,
|
|
81
|
+
disabled: F,
|
|
82
|
+
name: U,
|
|
83
83
|
autoComplete: T || void 0,
|
|
84
|
-
placeholder:
|
|
85
|
-
readOnly:
|
|
86
|
-
required:
|
|
87
|
-
onChange:
|
|
88
|
-
...
|
|
84
|
+
placeholder: V,
|
|
85
|
+
readOnly: q,
|
|
86
|
+
required: z,
|
|
87
|
+
onChange: Z,
|
|
88
|
+
...G
|
|
89
89
|
}
|
|
90
90
|
)), n && /* @__PURE__ */ o.createElement(
|
|
91
|
-
|
|
91
|
+
ce,
|
|
92
92
|
{
|
|
93
93
|
maxCharacters: n,
|
|
94
94
|
length: y.toString().length,
|
|
@@ -98,9 +98,8 @@ const le = (a) => `calc(${a * ae}px + 2rem + 16px + 4px)`, N = o.forwardRef((a,
|
|
|
98
98
|
}
|
|
99
99
|
)));
|
|
100
100
|
});
|
|
101
|
-
|
|
102
|
-
const Te = N;
|
|
101
|
+
le.displayName = "Textarea";
|
|
103
102
|
export {
|
|
104
|
-
|
|
103
|
+
le as default
|
|
105
104
|
};
|
|
106
105
|
//# sourceMappingURL=Textarea.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Textarea.js","sources":["../../../src/components/Textarea/Textarea.tsx"],"sourcesContent":["import React, { useState, useRef, useEffect } from 'react';\n\nimport cn from 'classnames';\n\nimport { AnalyticsId, AVERAGE_CHARACTER_WIDTH_PX, FormMode } from '../../constants';\nimport { useUuid } from '../../hooks/useUuid';\nimport { getAriaDescribedBy } from '../../utils/accessibility';\nimport { uuid } from '../../utils/uuid';\nimport ErrorWrapper from '../ErrorWrapper';\nimport { renderLabel } from '../Label';\nimport MaxCharacters from '../MaxCharacters/MaxCharacters';\n\nimport styles from './styles.module.scss';\n\nexport interface TextareaProps\n extends Pick<\n React.InputHTMLAttributes<HTMLTextAreaElement>,\n | 'aria-describedby'\n | 'autoFocus'\n | 'disabled'\n | 'name'\n | 'autoComplete'\n | 'placeholder'\n | 'readOnly'\n | 'required'\n | 'defaultValue'\n | 'onChange'\n > {\n /** max character limit in textarea */\n maxCharacters?: number;\n /** The text is displayed in the end of the text-counter */\n maxText?: string;\n /** Width of textarea in characters (approximate) */\n width?: number;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** If true, the component will have a bottom margin. */\n marginBottom?: boolean;\n /** If true, the component will be transparent. */\n transparent?: boolean;\n /** Changes the visuals of the textarea */\n mode?: keyof typeof FormMode;\n /** Label of the input */\n label?: React.ReactNode;\n /** id of the textarea */\n textareaId?: string;\n /** max rows */\n maxRows?: number;\n /** min rows */\n minRows?: number;\n /** auto-grows until maxRows */\n grow?: boolean;\n /** Activates Error style for the input */\n error?: boolean;\n /** Error text to show above the component */\n errorText?: string;\n /** Error text id */\n errorTextId?: string;\n}\n\nconst getTextareaMaxWidth = (characters: number): string => {\n const paddingWidth = '2rem';\n const scrollbarWidth = '16px';\n const borderWidth = '4px';\n\n return `calc(${characters * AVERAGE_CHARACTER_WIDTH_PX}px + ${paddingWidth} + ${scrollbarWidth} + ${borderWidth})`;\n};\n\nconst Textarea = React.forwardRef((props: TextareaProps, ref: React.Ref<HTMLTextAreaElement>) => {\n const {\n maxCharacters,\n maxText,\n width,\n testId,\n defaultValue,\n marginBottom: gutterBottom,\n transparent,\n mode = FormMode.onwhite,\n label,\n textareaId = uuid(),\n minRows = 3,\n maxRows = 10,\n grow,\n error,\n errorText,\n errorTextId,\n autoFocus,\n disabled,\n name,\n autoComplete = 'off',\n placeholder,\n readOnly,\n required,\n onChange,\n ...rest\n } = props;\n\n const [rows, setRows] = useState(minRows);\n const [textareaInput, setTextareaInput] = useState(defaultValue || '');\n const referanse = useRef<HTMLDivElement>(null);\n const errorTextUuid = useUuid(errorTextId);\n\n useEffect(() => {\n setTextareaInput(defaultValue || '');\n }, [defaultValue]);\n\n const resizeHeight = (target: HTMLTextAreaElement): void => {\n const textareaLineHeight = 28;\n\n const previousRows = target.rows;\n target.rows = minRows; // reset number of rows in textarea\n\n const currentRows = Math.floor((target.scrollHeight - 16) / textareaLineHeight); // scrollHeight - 16px of padding to calculate the rows\n\n if (currentRows === previousRows) {\n target.rows = currentRows;\n }\n\n if (currentRows >= maxRows) {\n target.rows = maxRows;\n target.scrollTop = target.scrollHeight;\n }\n\n if (currentRows < maxRows) {\n setRows(currentRows);\n } else {\n setRows(maxRows);\n }\n };\n\n const onDark = mode === FormMode.ondark;\n const onBlueberry = mode === FormMode.onblueberry;\n const maxCharactersExceeded = !!maxCharacters && textareaInput.toString().length > maxCharacters;\n const onError = mode === FormMode.oninvalid || !!errorText || !!error || maxCharactersExceeded;\n\n const textareaWrapperClass = cn(styles.textarea, {\n [styles['textarea--gutterBottom']]: gutterBottom,\n });\n\n const contentWrapperClass = cn(styles['input-container'], {\n [styles['input-container--transparent']]: transparent,\n [styles['input-container--on-blueberry']]: onBlueberry,\n [styles['input-container--on-dark']]: onDark,\n [styles['input-container--invalid']]: onError,\n [styles['input-container--disabled']]: props.disabled,\n });\n\n const textareaClass = cn(styles['input-container__input'], {\n [styles[`input-container__input--disabled`]]: props.disabled,\n });\n\n useEffect(() => {\n if (grow && referanse.current?.children && referanse.current?.children[0]) {\n const textarea = referanse.current?.children[0] as HTMLTextAreaElement;\n resizeHeight(textarea);\n }\n }, []);\n\n const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>): void => {\n if (grow) {\n resizeHeight(e.target);\n }\n setTextareaInput(e.target.value);\n };\n\n const onChangeHandler = (e: React.ChangeEvent<HTMLTextAreaElement>): void => {\n if (onChange) {\n onChange(e);\n }\n handleChange(e);\n };\n\n const maxWidth = width ? getTextareaMaxWidth(width) : undefined;\n\n return (\n <ErrorWrapper errorText={errorText} errorTextId={errorTextUuid}>\n <div data-testid={testId} data-analyticsid={AnalyticsId.Textarea} className={textareaWrapperClass}>\n {renderLabel(label, textareaId, mode as FormMode)}\n <div className={contentWrapperClass} ref={referanse} style={{ maxWidth }}>\n <textarea\n rows={rows}\n defaultValue={defaultValue}\n id={textareaId}\n className={textareaClass}\n ref={ref}\n aria-describedby={getAriaDescribedBy(props, errorTextUuid)}\n aria-invalid={!!onError}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={autoFocus}\n disabled={disabled}\n name={name}\n autoComplete={autoComplete ? autoComplete : undefined}\n placeholder={placeholder}\n readOnly={readOnly}\n required={required}\n onChange={onChangeHandler}\n {...rest}\n />\n </div>\n {maxCharacters && (\n <MaxCharacters\n maxCharacters={maxCharacters}\n length={textareaInput.toString().length}\n maxText={maxText}\n mode={mode}\n maxWidth={maxWidth}\n />\n )}\n </div>\n </ErrorWrapper>\n );\n});\n\nTextarea.displayName = 'Textarea';\n\nexport default Textarea;\n"],"names":["getTextareaMaxWidth","characters","AVERAGE_CHARACTER_WIDTH_PX","Textarea","React","props","ref","maxCharacters","maxText","width","testId","defaultValue","gutterBottom","transparent","mode","FormMode","label","textareaId","uuid","minRows","maxRows","grow","error","errorText","errorTextId","autoFocus","disabled","name","autoComplete","placeholder","readOnly","required","onChange","rest","rows","setRows","useState","textareaInput","setTextareaInput","referanse","useRef","errorTextUuid","useUuid","useEffect","resizeHeight","target","previousRows","currentRows","onDark","onBlueberry","maxCharactersExceeded","onError","textareaWrapperClass","cn","styles","contentWrapperClass","textareaClass","_a","_b","textarea","_c","handleChange","onChangeHandler","maxWidth","ErrorWrapper","AnalyticsId","renderLabel","getAriaDescribedBy","MaxCharacters","Textarea$1"],"mappings":";;;;;;;;;;AA4DA,MAAMA,KAAsB,CAACC,MAKpB,QAAQA,IAAaC,EAA0B,2BAGlDC,IAAWC,EAAM,WAAW,CAACC,GAAsBC,MAAwC;AACzF,QAAA;AAAA,IACJ,eAAAC;AAAA,IACA,SAAAC;AAAA,IACA,OAAAC;AAAA,IACA,QAAAC;AAAA,IACA,cAAAC;AAAA,IACA,cAAcC;AAAA,IACd,aAAAC;AAAA,IACA,MAAAC,IAAOC,EAAS;AAAA,IAChB,OAAAC;AAAA,IACA,YAAAC,IAAaC,GAAK;AAAA,IAClB,SAAAC,IAAU;AAAA,IACV,SAAAC,IAAU;AA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AAAA,MACA,cAAAvB;AAAA,MACA,IAAIM;AAAA,MACJ,WAAWuC;AAAA,MACX,KAAAlD;AAAA,MACA,oBAAkB6D,GAAmB9D,GAAOoC,CAAa;AAAA,MACzD,gBAAc,CAAC,CAACU;AAAA,MAEhB,WAAA1B;AAAA,MACA,UAAAC;AAAA,MACA,MAAAC;AAAA,MACA,cAAcC,KAA8B;AAAA,MAC5C,aAAAC;AAAA,MACA,UAAAC;AAAA,MACA,UAAAC;AAAA,MACA,UAAU+B;AAAA,MACT,GAAG7B;AAAA,IAAA;AAAA,EAAA,CAER,GACC1B,KACCH,gBAAAA,EAAA;AAAA,IAACgE;AAAA,IAAA;AAAA,MACC,eAAA7D;AAAA,MACA,QAAQ8B,EAAc,SAAA,EAAW;AAAA,MACjC,SAAA7B;AAAA,MACA,MAAAM;AAAA,MACA,UAAAiD;AAAA,IAAA;AAAA,EAGN,CAAA,CACF;AAEJ,CAAC;AAED5D,EAAS,cAAc;AAEvB,MAAAkE,KAAelE;"}
|
|
1
|
+
{"version":3,"file":"Textarea.js","sources":["../../../src/components/Textarea/Textarea.tsx"],"sourcesContent":["import React, { useState, useRef, useEffect } from 'react';\n\nimport cn from 'classnames';\n\nimport { AnalyticsId, AVERAGE_CHARACTER_WIDTH_PX, FormMode } from '../../constants';\nimport { useUuid } from '../../hooks/useUuid';\nimport { getAriaDescribedBy } from '../../utils/accessibility';\nimport { uuid } from '../../utils/uuid';\nimport ErrorWrapper from '../ErrorWrapper';\nimport { renderLabel } from '../Label';\nimport MaxCharacters from '../MaxCharacters/MaxCharacters';\n\nimport styles from './styles.module.scss';\n\nexport interface TextareaProps\n extends Pick<\n React.InputHTMLAttributes<HTMLTextAreaElement>,\n | 'aria-describedby'\n | 'autoFocus'\n | 'disabled'\n | 'name'\n | 'autoComplete'\n | 'placeholder'\n | 'readOnly'\n | 'required'\n | 'defaultValue'\n | 'onChange'\n > {\n /** max character limit in textarea */\n maxCharacters?: number;\n /** The text is displayed in the end of the text-counter */\n maxText?: string;\n /** Width of textarea in characters (approximate) */\n width?: number;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** If true, the component will have a bottom margin. */\n marginBottom?: boolean;\n /** If true, the component will be transparent. */\n transparent?: boolean;\n /** Changes the visuals of the textarea */\n mode?: keyof typeof FormMode;\n /** Label of the input */\n label?: React.ReactNode;\n /** id of the textarea */\n textareaId?: string;\n /** max rows */\n maxRows?: number;\n /** min rows */\n minRows?: number;\n /** auto-grows until maxRows */\n grow?: boolean;\n /** Activates Error style for the input */\n error?: boolean;\n /** Error text to show above the component */\n errorText?: string;\n /** Error text id */\n errorTextId?: string;\n}\n\nconst getTextareaMaxWidth = (characters: number): string => {\n const paddingWidth = '2rem';\n const scrollbarWidth = '16px';\n const borderWidth = '4px';\n\n return `calc(${characters * AVERAGE_CHARACTER_WIDTH_PX}px + ${paddingWidth} + ${scrollbarWidth} + ${borderWidth})`;\n};\n\nconst Textarea = React.forwardRef((props: TextareaProps, ref: React.Ref<HTMLTextAreaElement>) => {\n const {\n maxCharacters,\n maxText,\n width,\n testId,\n defaultValue,\n marginBottom: gutterBottom,\n transparent,\n mode = FormMode.onwhite,\n label,\n textareaId = uuid(),\n minRows = 3,\n maxRows = 10,\n grow,\n error,\n errorText,\n errorTextId,\n autoFocus,\n disabled,\n name,\n autoComplete = 'off',\n placeholder,\n readOnly,\n required,\n onChange,\n ...rest\n } = props;\n\n const [rows, setRows] = useState(minRows);\n const [textareaInput, setTextareaInput] = useState(defaultValue || '');\n const referanse = useRef<HTMLDivElement>(null);\n const errorTextUuid = useUuid(errorTextId);\n\n useEffect(() => {\n setTextareaInput(defaultValue || '');\n }, [defaultValue]);\n\n const resizeHeight = (target: HTMLTextAreaElement): void => {\n const textareaLineHeight = 28;\n\n const previousRows = target.rows;\n target.rows = minRows; // reset number of rows in textarea\n\n const currentRows = Math.floor((target.scrollHeight - 16) / textareaLineHeight); // scrollHeight - 16px of padding to calculate the rows\n\n if (currentRows === previousRows) {\n target.rows = currentRows;\n }\n\n if (currentRows >= maxRows) {\n target.rows = maxRows;\n target.scrollTop = target.scrollHeight;\n }\n\n if (currentRows < maxRows) {\n setRows(currentRows);\n } else {\n setRows(maxRows);\n }\n };\n\n const onDark = mode === FormMode.ondark;\n const onBlueberry = mode === FormMode.onblueberry;\n const maxCharactersExceeded = !!maxCharacters && textareaInput.toString().length > maxCharacters;\n const onError = mode === FormMode.oninvalid || !!errorText || !!error || maxCharactersExceeded;\n\n const textareaWrapperClass = cn(styles.textarea, {\n [styles['textarea--gutterBottom']]: gutterBottom,\n });\n\n const contentWrapperClass = cn(styles['input-container'], {\n [styles['input-container--transparent']]: transparent,\n [styles['input-container--on-blueberry']]: onBlueberry,\n [styles['input-container--on-dark']]: onDark,\n [styles['input-container--invalid']]: onError,\n [styles['input-container--disabled']]: props.disabled,\n });\n\n const textareaClass = cn(styles['input-container__input'], {\n [styles[`input-container__input--disabled`]]: props.disabled,\n });\n\n useEffect(() => {\n if (grow && referanse.current?.children && referanse.current?.children[0]) {\n const textarea = referanse.current?.children[0] as HTMLTextAreaElement;\n resizeHeight(textarea);\n }\n }, []);\n\n const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>): void => {\n if (grow) {\n resizeHeight(e.target);\n }\n setTextareaInput(e.target.value);\n };\n\n const onChangeHandler = (e: React.ChangeEvent<HTMLTextAreaElement>): void => {\n if (onChange) {\n onChange(e);\n }\n handleChange(e);\n };\n\n const maxWidth = width ? getTextareaMaxWidth(width) : undefined;\n\n return (\n <ErrorWrapper errorText={errorText} errorTextId={errorTextUuid}>\n <div data-testid={testId} data-analyticsid={AnalyticsId.Textarea} className={textareaWrapperClass}>\n {renderLabel(label, textareaId, mode as FormMode)}\n <div className={contentWrapperClass} ref={referanse} style={{ maxWidth }}>\n <textarea\n rows={rows}\n defaultValue={defaultValue}\n id={textareaId}\n className={textareaClass}\n ref={ref}\n aria-describedby={getAriaDescribedBy(props, errorTextUuid)}\n aria-invalid={!!onError}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={autoFocus}\n disabled={disabled}\n name={name}\n autoComplete={autoComplete ? autoComplete : undefined}\n placeholder={placeholder}\n readOnly={readOnly}\n required={required}\n onChange={onChangeHandler}\n {...rest}\n />\n </div>\n {maxCharacters && (\n <MaxCharacters\n maxCharacters={maxCharacters}\n length={textareaInput.toString().length}\n maxText={maxText}\n mode={mode}\n maxWidth={maxWidth}\n />\n )}\n </div>\n </ErrorWrapper>\n );\n});\n\nTextarea.displayName = 'Textarea';\n\nexport default Textarea;\n"],"names":["getTextareaMaxWidth","characters","AVERAGE_CHARACTER_WIDTH_PX","Textarea","React","props","ref","maxCharacters","maxText","width","testId","defaultValue","gutterBottom","transparent","mode","FormMode","label","textareaId","uuid","minRows","maxRows","grow","error","errorText","errorTextId","autoFocus","disabled","name","autoComplete","placeholder","readOnly","required","onChange","rest","rows","setRows","useState","textareaInput","setTextareaInput","referanse","useRef","errorTextUuid","useUuid","useEffect","resizeHeight","target","previousRows","currentRows","onDark","onBlueberry","maxCharactersExceeded","onError","textareaWrapperClass","cn","styles","contentWrapperClass","textareaClass","_a","_b","textarea","_c","handleChange","onChangeHandler","maxWidth","ErrorWrapper","AnalyticsId","renderLabel","getAriaDescribedBy","MaxCharacters"],"mappings":";;;;;;;;;;AA4DA,MAAMA,KAAsB,CAACC,MAKpB,QAAQA,IAAaC,EAA0B,2BAGlDC,KAAWC,EAAM,WAAW,CAACC,GAAsBC,MAAwC;AACzF,QAAA;AAAA,IACJ,eAAAC;AAAA,IACA,SAAAC;AAAA,IACA,OAAAC;AAAA,IACA,QAAAC;AAAA,IACA,cAAAC;AAAA,IACA,cAAcC;AAAA,IACd,aAAAC;AAAA,IACA,MAAAC,IAAOC,EAAS;AAAA,IAChB,OAAAC;AAAA,IACA,YAAAC,IAAaC,GAAK;AAAA,IAClB,SAAAC,IAAU;AAAA,IACV,SAAAC,IAAU;AAAA,IACV,MAAAC;AAAA,IACA,OAAAC;AAAA,IACA,WAAAC;AAAA,IACA,aA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ACX,KAAAlD;AAAA,MACA,oBAAkB6D,GAAmB9D,GAAOoC,CAAa;AAAA,MACzD,gBAAc,CAAC,CAACU;AAAA,MAEhB,WAAA1B;AAAA,MACA,UAAAC;AAAA,MACA,MAAAC;AAAA,MACA,cAAcC,KAA8B;AAAA,MAC5C,aAAAC;AAAA,MACA,UAAAC;AAAA,MACA,UAAAC;AAAA,MACA,UAAU+B;AAAA,MACT,GAAG7B;AAAA,IAAA;AAAA,EAAA,CAER,GACC1B,KACCH,gBAAAA,EAAA;AAAA,IAACgE;AAAA,IAAA;AAAA,MACC,eAAA7D;AAAA,MACA,QAAQ8B,EAAc,SAAA,EAAW;AAAA,MACjC,SAAA7B;AAAA,MACA,MAAAM;AAAA,MACA,UAAAiD;AAAA,IAAA;AAAA,EAGN,CAAA,CACF;AAEJ,CAAC;AAED5D,GAAS,cAAc;"}
|
package/components/Tile/Tile.js
CHANGED
|
@@ -4,7 +4,7 @@ import { AnalyticsId as C, IconSize as R } from "../../constants.js";
|
|
|
4
4
|
import { useHover as k } from "../../hooks/useHover.js";
|
|
5
5
|
import { mergeRefs as x } from "../../utils/refs.js";
|
|
6
6
|
import e from "../Tile/styles.module.scss";
|
|
7
|
-
const
|
|
7
|
+
const h = t.forwardRef((s, r) => {
|
|
8
8
|
const { children: a, className: c, htmlMarkup: o = "span", highlighted: m, compact: l } = s, n = p(
|
|
9
9
|
e.tile__title,
|
|
10
10
|
{
|
|
@@ -15,8 +15,8 @@ const _ = t.forwardRef((s, r) => {
|
|
|
15
15
|
), i = o;
|
|
16
16
|
return /* @__PURE__ */ t.createElement(i, { className: n, ref: r }, a);
|
|
17
17
|
});
|
|
18
|
-
|
|
19
|
-
const
|
|
18
|
+
h.displayName = "Title";
|
|
19
|
+
const _ = t.forwardRef((s, r) => {
|
|
20
20
|
const {
|
|
21
21
|
children: a,
|
|
22
22
|
icon: c,
|
|
@@ -26,10 +26,10 @@ const f = t.forwardRef((s, r) => {
|
|
|
26
26
|
fixed: n = !1,
|
|
27
27
|
highlighted: i = !1,
|
|
28
28
|
testId: g,
|
|
29
|
-
target:
|
|
29
|
+
target: f,
|
|
30
30
|
rel: N,
|
|
31
|
-
href:
|
|
32
|
-
onClick:
|
|
31
|
+
href: u,
|
|
32
|
+
onClick: T
|
|
33
33
|
} = s, { hoverRef: E, isHovered: v } = k(), d = !l, w = p(
|
|
34
34
|
e.tile,
|
|
35
35
|
{
|
|
@@ -45,24 +45,23 @@ const f = t.forwardRef((s, r) => {
|
|
|
45
45
|
"a",
|
|
46
46
|
{
|
|
47
47
|
ref: x([r, E]),
|
|
48
|
-
href:
|
|
49
|
-
target:
|
|
50
|
-
rel:
|
|
48
|
+
href: u,
|
|
49
|
+
target: f,
|
|
50
|
+
rel: f === "_blank" ? "noopener noreferrer" : N,
|
|
51
51
|
className: w,
|
|
52
52
|
"data-testid": g,
|
|
53
53
|
"data-analyticsid": C.Tile,
|
|
54
|
-
onClick:
|
|
54
|
+
onClick: T
|
|
55
55
|
},
|
|
56
56
|
/* @__PURE__ */ t.createElement("div", { className: y }, t.cloneElement(c, { size: R.Medium, isHovered: v, color: i ? "white" : "black" }), t.cloneElement(o, { highlighted: i, compact: d })),
|
|
57
57
|
l && /* @__PURE__ */ t.createElement("p", { className: e.tile__description }, l),
|
|
58
58
|
a && /* @__PURE__ */ t.createElement("div", { className: e.tile__children }, a)
|
|
59
59
|
);
|
|
60
60
|
});
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const A = f;
|
|
61
|
+
_.displayName = "Tile";
|
|
62
|
+
_.Title = h;
|
|
64
63
|
export {
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
_ as Tile,
|
|
65
|
+
_ as default
|
|
67
66
|
};
|
|
68
67
|
//# sourceMappingURL=Tile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tile.js","sources":["../../../src/components/Tile/Tile.tsx"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { TitleTags } from './../Title/Title';\nimport { AnalyticsId } from '../../constants';\nimport { useHover } from '../../hooks/useHover';\nimport { mergeRefs } from '../../utils/refs';\nimport { IconSize } from '../Icon';\n\nimport tileStyles from './styles.module.scss';\n\ninterface TileProps extends Pick<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'href' | 'target' | 'onClick' | 'rel'> {\n children?: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /**\tSets the icon to be displayed inside the tile. */\n icon: React.ReactElement;\n /**\tSets the title to be displayed inside the tile. */\n title: React.ReactElement;\n /** Toggles the highlighted style of the tile. */\n highlighted?: boolean;\n /** Sets the description to be displayed inside the tile. */\n description?: string;\n /** Sets a fixed max and min width for the tile. */\n fixed?: boolean;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\ninterface TileTitleProps {\n children: React.ReactNode;\n className?: string;\n htmlMarkup?: TitleTags;\n highlighted?: boolean;\n compact?: boolean;\n}\n\nexport interface TileCompound extends React.ForwardRefExoticComponent<TileProps & React.RefAttributes<HTMLAnchorElement>> {\n Title: React.ForwardRefExoticComponent<TileTitleProps & React.RefAttributes<HTMLHeadingElement>>;\n}\n\nconst Title = React.forwardRef<HTMLHeadingElement, TileTitleProps>((props, ref) => {\n const { children, className, htmlMarkup = 'span', highlighted, compact } = props;\n const titleClasses = classNames(\n tileStyles['tile__title'],\n {\n [tileStyles['tile__title--highlighted']]: highlighted,\n [tileStyles['tile__title--compact']]: compact,\n },\n className\n );\n const CustomTag = htmlMarkup;\n\n return (\n <CustomTag className={titleClasses} ref={ref}>\n {children}\n </CustomTag>\n );\n});\n\nTitle.displayName = 'Title';\n\nexport const Tile = React.forwardRef<HTMLAnchorElement, TileProps>((props, ref) => {\n const {\n children,\n icon,\n title,\n className = '',\n description,\n fixed = false,\n highlighted = false,\n testId,\n target,\n rel,\n href,\n onClick,\n } = props;\n const { hoverRef, isHovered } = useHover<HTMLAnchorElement>();\n const compact = !description;\n const tileClasses = classNames(\n tileStyles.tile,\n {\n [tileStyles['tile--fixed']]: fixed,\n [tileStyles['tile--compact']]: compact,\n [tileStyles['tile--highlighted']]: highlighted,\n },\n className\n );\n const tileTitleWrapperClasses = classNames(tileStyles['title-wrapper'], {\n [tileStyles['title-wrapper--compact']]: compact,\n });\n\n return (\n <a\n ref={mergeRefs([ref, hoverRef])}\n href={href}\n target={target}\n rel={target === '_blank' ? 'noopener noreferrer' : rel}\n className={tileClasses}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Tile}\n onClick={onClick}\n >\n <div className={tileTitleWrapperClasses}>\n {React.cloneElement(icon, { size: IconSize.Medium, isHovered, color: highlighted ? 'white' : 'black' })}\n {React.cloneElement(title, { highlighted: highlighted, compact: compact })}\n </div>\n {description && <p className={tileStyles.tile__description}>{description}</p>}\n {children && <div className={tileStyles.tile__children}>{children}</div>}\n </a>\n );\n}) as TileCompound;\n\nTile.displayName = 'Tile';\nTile.Title = Title;\n\nexport default Tile;\n"],"names":["Title","React","props","ref","children","className","htmlMarkup","highlighted","compact","titleClasses","classNames","tileStyles","CustomTag","Tile","icon","title","description","fixed","testId","target","rel","href","onClick","hoverRef","isHovered","useHover","tileClasses","tileTitleWrapperClasses","mergeRefs","AnalyticsId","IconSize"
|
|
1
|
+
{"version":3,"file":"Tile.js","sources":["../../../src/components/Tile/Tile.tsx"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { TitleTags } from './../Title/Title';\nimport { AnalyticsId } from '../../constants';\nimport { useHover } from '../../hooks/useHover';\nimport { mergeRefs } from '../../utils/refs';\nimport { IconSize } from '../Icon';\n\nimport tileStyles from './styles.module.scss';\n\ninterface TileProps extends Pick<React.AnchorHTMLAttributes<HTMLAnchorElement>, 'href' | 'target' | 'onClick' | 'rel'> {\n children?: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /**\tSets the icon to be displayed inside the tile. */\n icon: React.ReactElement;\n /**\tSets the title to be displayed inside the tile. */\n title: React.ReactElement;\n /** Toggles the highlighted style of the tile. */\n highlighted?: boolean;\n /** Sets the description to be displayed inside the tile. */\n description?: string;\n /** Sets a fixed max and min width for the tile. */\n fixed?: boolean;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\ninterface TileTitleProps {\n children: React.ReactNode;\n className?: string;\n htmlMarkup?: TitleTags;\n highlighted?: boolean;\n compact?: boolean;\n}\n\nexport interface TileCompound extends React.ForwardRefExoticComponent<TileProps & React.RefAttributes<HTMLAnchorElement>> {\n Title: React.ForwardRefExoticComponent<TileTitleProps & React.RefAttributes<HTMLHeadingElement>>;\n}\n\nconst Title = React.forwardRef<HTMLHeadingElement, TileTitleProps>((props, ref) => {\n const { children, className, htmlMarkup = 'span', highlighted, compact } = props;\n const titleClasses = classNames(\n tileStyles['tile__title'],\n {\n [tileStyles['tile__title--highlighted']]: highlighted,\n [tileStyles['tile__title--compact']]: compact,\n },\n className\n );\n const CustomTag = htmlMarkup;\n\n return (\n <CustomTag className={titleClasses} ref={ref}>\n {children}\n </CustomTag>\n );\n});\n\nTitle.displayName = 'Title';\n\nexport const Tile = React.forwardRef<HTMLAnchorElement, TileProps>((props, ref) => {\n const {\n children,\n icon,\n title,\n className = '',\n description,\n fixed = false,\n highlighted = false,\n testId,\n target,\n rel,\n href,\n onClick,\n } = props;\n const { hoverRef, isHovered } = useHover<HTMLAnchorElement>();\n const compact = !description;\n const tileClasses = classNames(\n tileStyles.tile,\n {\n [tileStyles['tile--fixed']]: fixed,\n [tileStyles['tile--compact']]: compact,\n [tileStyles['tile--highlighted']]: highlighted,\n },\n className\n );\n const tileTitleWrapperClasses = classNames(tileStyles['title-wrapper'], {\n [tileStyles['title-wrapper--compact']]: compact,\n });\n\n return (\n <a\n ref={mergeRefs([ref, hoverRef])}\n href={href}\n target={target}\n rel={target === '_blank' ? 'noopener noreferrer' : rel}\n className={tileClasses}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Tile}\n onClick={onClick}\n >\n <div className={tileTitleWrapperClasses}>\n {React.cloneElement(icon, { size: IconSize.Medium, isHovered, color: highlighted ? 'white' : 'black' })}\n {React.cloneElement(title, { highlighted: highlighted, compact: compact })}\n </div>\n {description && <p className={tileStyles.tile__description}>{description}</p>}\n {children && <div className={tileStyles.tile__children}>{children}</div>}\n </a>\n );\n}) as TileCompound;\n\nTile.displayName = 'Tile';\nTile.Title = Title;\n\nexport default Tile;\n"],"names":["Title","React","props","ref","children","className","htmlMarkup","highlighted","compact","titleClasses","classNames","tileStyles","CustomTag","Tile","icon","title","description","fixed","testId","target","rel","href","onClick","hoverRef","isHovered","useHover","tileClasses","tileTitleWrapperClasses","mergeRefs","AnalyticsId","IconSize"],"mappings":";;;;;;AA0CA,MAAMA,IAAQC,EAAM,WAA+C,CAACC,GAAOC,MAAQ;AACjF,QAAM,EAAE,UAAAC,GAAU,WAAAC,GAAW,YAAAC,IAAa,QAAQ,aAAAC,GAAa,SAAAC,EAAY,IAAAN,GACrEO,IAAeC;AAAA,IACnBC,EAAW;AAAA,IACX;AAAA,MACE,CAACA,EAAW,0BAA0B,CAAC,GAAGJ;AAAA,MAC1C,CAACI,EAAW,sBAAsB,CAAC,GAAGH;AAAA,IACxC;AAAA,IACAH;AAAA,EAAA,GAEIO,IAAYN;AAElB,SACGL,gBAAAA,EAAA,cAAAW,GAAA,EAAU,WAAWH,GAAc,KAAAN,KACjCC,CACH;AAEJ,CAAC;AAEDJ,EAAM,cAAc;AAEb,MAAMa,IAAOZ,EAAM,WAAyC,CAACC,GAAOC,MAAQ;AAC3E,QAAA;AAAA,IACJ,UAAAC;AAAA,IACA,MAAAU;AAAA,IACA,OAAAC;AAAA,IACA,WAAAV,IAAY;AAAA,IACZ,aAAAW;AAAA,IACA,OAAAC,IAAQ;AAAA,IACR,aAAAV,IAAc;AAAA,IACd,QAAAW;AAAA,IACA,QAAAC;AAAA,IACA,KAAAC;AAAA,IACA,MAAAC;AAAA,IACA,SAAAC;AAAA,EACE,IAAApB,GACE,EAAE,UAAAqB,GAAU,WAAAC,EAAU,IAAIC,EAA4B,GACtDjB,IAAU,CAACQ,GACXU,IAAchB;AAAA,IAClBC,EAAW;AAAA,IACX;AAAA,MACE,CAACA,EAAW,aAAa,CAAC,GAAGM;AAAA,MAC7B,CAACN,EAAW,eAAe,CAAC,GAAGH;AAAA,MAC/B,CAACG,EAAW,mBAAmB,CAAC,GAAGJ;AAAA,IACrC;AAAA,IACAF;AAAA,EAAA,GAEIsB,IAA0BjB,EAAWC,EAAW,eAAe,GAAG;AAAA,IACtE,CAACA,EAAW,wBAAwB,CAAC,GAAGH;AAAA,EAAA,CACzC;AAGC,SAAAP,gBAAAA,EAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAK2B,EAAU,CAACzB,GAAKoB,CAAQ,CAAC;AAAA,MAC9B,MAAAF;AAAA,MACA,QAAAF;AAAA,MACA,KAAKA,MAAW,WAAW,wBAAwBC;AAAA,MACnD,WAAWM;AAAA,MACX,eAAaR;AAAA,MACb,oBAAkBW,EAAY;AAAA,MAC9B,SAAAP;AAAA,IAAA;AAAA,IAEArB,gBAAAA,EAAA,cAAC,OAAI,EAAA,WAAW0B,EACb,GAAA1B,EAAM,aAAaa,GAAM,EAAE,MAAMgB,EAAS,QAAQ,WAAAN,GAAW,OAAOjB,IAAc,UAAU,QAAQ,CAAC,GACrGN,EAAM,aAAac,GAAO,EAAE,aAAAR,GAA0B,SAAAC,EAAkB,CAAA,CAC3E;AAAA,IACCQ,KAAgBf,gBAAAA,EAAA,cAAA,KAAA,EAAE,WAAWU,EAAW,qBAAoBK,CAAY;AAAA,IACxEZ,KAAaH,gBAAAA,EAAA,cAAA,OAAA,EAAI,WAAWU,EAAW,kBAAiBP,CAAS;AAAA,EAAA;AAGxE,CAAC;AAEDS,EAAK,cAAc;AACnBA,EAAK,QAAQb;"}
|
package/components/Tile/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|