@helsenorge/designsystem-react 14.0.0-beta.3 → 14.0.0-beta.7
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/lib/AnchorLink.js +2 -2
- package/lib/AnchorLink.js.map +1 -1
- package/lib/Avatar.js +2 -2
- package/lib/Avatar.js.map +1 -1
- package/lib/BabyMobileMedium.js +1 -1
- package/lib/Badge.js +2 -2
- package/lib/Badge.js.map +1 -1
- package/lib/Button.js +6 -6
- package/lib/Button.js.map +1 -1
- package/lib/CHANGELOG.md +58 -2
- package/lib/Checkbox.js +17 -7
- package/lib/Checkbox.js.map +1 -1
- package/lib/ChildMedium.js +1 -1
- package/lib/Close.js +3 -3
- package/lib/Close.js.map +1 -1
- package/lib/DictionaryTrigger.js +2 -2
- package/lib/DictionaryTrigger.js.map +1 -1
- package/lib/Drawer.js +29 -29
- package/lib/Drawer.js.map +1 -1
- package/lib/Duolist.js +5 -5
- package/lib/Duolist.js.map +1 -1
- package/lib/ElementHeader.js +10 -10
- package/lib/ElementHeader.js.map +1 -1
- package/lib/ElementHeaderText.js +4 -4
- package/lib/ElementHeaderText.js.map +1 -1
- package/lib/ErrorWrapper.js +2 -2
- package/lib/ErrorWrapper.js.map +1 -1
- package/lib/Expander.js +12 -8
- package/lib/Expander.js.map +1 -1
- package/lib/FacialRecognitionFingerprintMedium.js +1 -1
- package/lib/FormFieldTag.js +2 -2
- package/lib/FormFieldTag.js.map +1 -1
- package/lib/FormGroup.js +10 -20
- package/lib/FormGroup.js.map +1 -1
- package/lib/FormLayout.js +3 -3
- package/lib/FormLayout.js.map +1 -1
- package/lib/GiveBabyFoodMedium.js +1 -1
- package/lib/HelpDetails.js +3 -3
- package/lib/HelpDetails.js.map +1 -1
- package/lib/HelpTriggerIcon.js +119 -44
- package/lib/HelpTriggerIcon.js.map +1 -1
- package/lib/HelpTriggerStandalone.js +2 -2
- package/lib/HelpTriggerStandalone.js.map +1 -1
- package/lib/HighlightPanel.js +3 -3
- package/lib/HighlightPanel.js.map +1 -1
- package/lib/HorizontalScroll.js +4 -4
- package/lib/HorizontalScroll.js.map +1 -1
- package/lib/Icon.js +2 -2
- package/lib/Icon.js.map +1 -1
- package/lib/Illustration.js +1 -1
- package/lib/Illustration.js.map +1 -1
- package/lib/InfoTeaser.js +5 -4
- package/lib/InfoTeaser.js.map +1 -1
- package/lib/Input.js +9 -5
- package/lib/Input.js.map +1 -1
- package/lib/Label.js +3 -90
- package/lib/Label.js.map +1 -1
- package/lib/LazyIcon.js +18 -10
- package/lib/LazyIcon.js.map +1 -1
- package/lib/LazyIllustration.js +1 -1
- package/lib/LinkList.js +7 -8
- package/lib/LinkList.js.map +1 -1
- package/lib/List.js +2 -2
- package/lib/List.js.map +1 -1
- package/lib/ListEditMode.js +7 -5
- package/lib/ListEditMode.js.map +1 -1
- package/lib/MaxCharacters.js +2 -2
- package/lib/MaxCharacters.js.map +1 -1
- package/lib/PanelTitle.js +2 -2
- package/lib/PanelTitle.js.map +1 -1
- package/lib/PopOver.js +2 -2
- package/lib/PopOver.js.map +1 -1
- package/lib/RadioButton.js +3 -80
- package/lib/RadioButton.js.map +1 -1
- package/lib/ReadLettersMedium.js +1 -1
- package/lib/Select.js +9 -5
- package/lib/Select.js.map +1 -1
- package/lib/SingleSelectItem.js +4 -4
- package/lib/SingleSelectItem.js.map +1 -1
- package/lib/Slider.js +4 -4
- package/lib/Slider.js.map +1 -1
- package/lib/Spacer.js +2 -2
- package/lib/Spacer.js.map +1 -1
- package/lib/StatusDot.js +25 -20
- package/lib/StatusDot.js.map +1 -1
- package/lib/StatusDotList.js +2 -2
- package/lib/StatusDotList.js.map +1 -1
- package/lib/StepButtons.js +5 -5
- package/lib/StepButtons.js.map +1 -1
- package/lib/StrollerMedium.js +1 -1
- package/lib/Support2Medium.js +1 -1
- package/lib/TabList.js +8 -8
- package/lib/TabList.js.map +1 -1
- package/lib/TabPanel.js +2 -2
- package/lib/TabPanel.js.map +1 -1
- package/lib/TableBody.js +4 -4
- package/lib/TableBody.js.map +1 -1
- package/lib/TableCell.js +3 -3
- package/lib/TableCell.js.map +1 -1
- package/lib/TableExpandedRow.js +5 -5
- package/lib/TableExpandedRow.js.map +1 -1
- package/lib/TableExpanderCell.js +3 -3
- package/lib/TableExpanderCell.js.map +1 -1
- package/lib/TableHead.js +4 -4
- package/lib/TableHead.js.map +1 -1
- package/lib/TableHeadCell.js +4 -4
- package/lib/TableHeadCell.js.map +1 -1
- package/lib/TableRow.js +5 -5
- package/lib/TableRow.js.map +1 -1
- package/lib/Textarea.js +9 -5
- package/lib/Textarea.js.map +1 -1
- package/lib/Title.js +2 -2
- package/lib/Title.js.map +1 -1
- package/lib/Toast.js +3 -3
- package/lib/Toast.js.map +1 -1
- package/lib/components/ArticleTeaser/index.js +4 -4
- package/lib/components/ArticleTeaser/index.js.map +1 -1
- package/lib/components/Checkbox/styles.module.scss +4 -0
- package/lib/components/Checkbox/styles.module.scss.d.ts +1 -0
- package/lib/components/Chip/index.js +2 -2
- package/lib/components/Chip/index.js.map +1 -1
- package/lib/components/Drawer/styles.module.scss +6 -0
- package/lib/components/Dropdown/SingleSelect/index.d.ts +1 -0
- package/lib/components/Dropdown/SingleSelect/index.js +2 -2
- package/lib/components/Dropdown/SingleSelect/index.js.map +1 -1
- package/lib/components/Dropdown/index.js +6 -6
- package/lib/components/Dropdown/index.js.map +1 -1
- package/lib/components/DropdownOld/index.js +3 -3
- package/lib/components/DropdownOld/index.js.map +1 -1
- package/lib/components/ElementHeader/index.d.ts +1 -0
- package/lib/components/ElementHeader/index.js +2 -2
- package/lib/components/ElementHeader/index.js.map +1 -1
- package/lib/components/EmptyState/index.js +2 -2
- package/lib/components/EmptyState/index.js.map +1 -1
- package/lib/components/Expander/styles.module.scss +16 -7
- package/lib/components/Expander/styles.module.scss.d.ts +2 -1
- package/lib/components/ExpanderHierarchy/Expander.d.ts +2 -0
- package/lib/components/ExpanderHierarchy/index.d.ts +1 -0
- package/lib/components/ExpanderHierarchy/index.js +10 -9
- package/lib/components/ExpanderHierarchy/index.js.map +1 -1
- package/lib/components/ExpanderList/index.js +8 -9
- package/lib/components/ExpanderList/index.js.map +1 -1
- package/lib/components/FavoriteButton/index.js +2 -2
- package/lib/components/FavoriteButton/index.js.map +1 -1
- package/lib/components/FormGroup/FormGroup.d.ts +5 -0
- package/lib/components/HelpBubble/index.js +3 -3
- package/lib/components/HelpBubble/index.js.map +1 -1
- package/lib/components/HelpPanel/index.js +2 -2
- package/lib/components/HelpPanel/index.js.map +1 -1
- package/lib/components/HelpTeaser/HelpTeaser.d.ts +2 -0
- package/lib/components/HelpTeaser/index.js +2 -1
- package/lib/components/HelpTeaser/index.js.map +1 -1
- package/lib/components/HelpTriggerIcon/HelpSign.d.ts +3 -1
- package/lib/components/HelpTriggerInline/index.js +2 -2
- package/lib/components/HelpTriggerInline/index.js.map +1 -1
- package/lib/components/Icon/index.d.ts +1 -0
- package/lib/components/Icon/index.js +2 -1
- package/lib/components/Icons/AdditionalIconInformation.d.ts +41 -5
- package/lib/components/Icons/AdditionalIconInformation.js +41 -5
- package/lib/components/Icons/AdditionalIconInformation.js.map +1 -1
- package/lib/components/Icons/Attachment.js +1 -11
- package/lib/components/Icons/Attachment.js.map +1 -1
- package/lib/components/Icons/Change.js +2 -6
- package/lib/components/Icons/Change.js.map +1 -1
- package/lib/components/Icons/DotAttachment.d.ts +3 -0
- package/lib/components/Icons/DotAttachment.js +22 -0
- package/lib/components/Icons/DotAttachment.js.map +1 -0
- package/lib/components/Icons/DotCheckmark.d.ts +3 -0
- package/lib/components/Icons/{DotSuccess.js → DotCheckmark.js} +4 -4
- package/lib/components/Icons/DotCheckmark.js.map +1 -0
- package/lib/components/Icons/DotCircleArrows.d.ts +3 -0
- package/lib/components/Icons/DotCircleArrows.js +18 -0
- package/lib/components/Icons/DotCircleArrows.js.map +1 -0
- package/lib/components/Icons/DotDot.d.ts +3 -0
- package/lib/components/Icons/{DotPending.js → DotDot.js} +4 -4
- package/lib/components/Icons/DotDot.js.map +1 -0
- package/lib/components/Icons/DotExclamationMark.d.ts +3 -0
- package/lib/components/Icons/{DotAlert.js → DotExclamationMark.js} +4 -4
- package/lib/components/Icons/DotExclamationMark.js.map +1 -0
- package/lib/components/Icons/DotFill.d.ts +3 -0
- package/lib/components/Icons/{DotActive.js → DotFill.js} +4 -4
- package/lib/components/Icons/DotFill.js.map +1 -0
- package/lib/components/Icons/DotGroup.d.ts +3 -0
- package/lib/components/Icons/DotGroup.js +22 -0
- package/lib/components/Icons/DotGroup.js.map +1 -0
- package/lib/components/Icons/DotLogin.d.ts +3 -0
- package/lib/components/Icons/DotLogin.js +14 -0
- package/lib/components/Icons/DotLogin.js.map +1 -0
- package/lib/components/Icons/DotNoAccess.d.ts +3 -0
- package/lib/components/Icons/DotNoAccess.js +30 -0
- package/lib/components/Icons/DotNoAccess.js.map +1 -0
- package/lib/components/Icons/DotNoEye.d.ts +3 -0
- package/lib/components/Icons/DotNoEye.js +14 -0
- package/lib/components/Icons/DotNoEye.js.map +1 -0
- package/lib/components/Icons/DotOutline.d.ts +3 -0
- package/lib/components/Icons/{DotInactive.js → DotOutline.js} +4 -4
- package/lib/components/Icons/DotOutline.js.map +1 -0
- package/lib/components/Icons/DotPencil.d.ts +3 -0
- package/lib/components/Icons/DotPencil.js +22 -0
- package/lib/components/Icons/DotPencil.js.map +1 -0
- package/lib/components/Icons/DotTriangle.d.ts +3 -0
- package/lib/components/Icons/{DotWarningTriangle.js → DotTriangle.js} +4 -4
- package/lib/components/Icons/DotTriangle.js.map +1 -0
- package/lib/components/Icons/DotX.d.ts +3 -0
- package/lib/components/Icons/{DotCancelled.js → DotX.js} +4 -4
- package/lib/components/Icons/DotX.js.map +1 -0
- package/lib/components/Icons/Group.js +2 -2
- package/lib/components/Icons/Group.js.map +1 -1
- package/lib/components/Icons/IconNames.d.ts +1 -1
- package/lib/components/Icons/IconNames.js +14 -8
- package/lib/components/Icons/IconNames.js.map +1 -1
- package/lib/components/Icons/Login.js +1 -3
- package/lib/components/Icons/Login.js.map +1 -1
- package/lib/components/Icons/NoAccess.js +7 -15
- package/lib/components/Icons/NoAccess.js.map +1 -1
- package/lib/components/Icons/NoEye.js +10 -2
- package/lib/components/Icons/NoEye.js.map +1 -1
- package/lib/components/Icons/Pencil.js +1 -11
- package/lib/components/Icons/Pencil.js.map +1 -1
- package/lib/components/Illustration/index.d.ts +1 -0
- package/lib/components/Illustration/index.js +2 -1
- package/lib/components/Illustrations/BabyMobile.js +1 -1
- package/lib/components/Illustrations/Child.js +1 -1
- package/lib/components/Illustrations/Doctor.js +1 -1
- package/lib/components/Illustrations/FacialRecognitionFingerprint.js +1 -1
- package/lib/components/Illustrations/GiveBabyFood.js +1 -1
- package/lib/components/Illustrations/HealthcarePersonnel.js +1 -1
- package/lib/components/Illustrations/ReadLetters.js +1 -1
- package/lib/components/Illustrations/Stroller.js +1 -1
- package/lib/components/Illustrations/Support2.js +1 -1
- package/lib/components/InfoTeaser/InfoTeaser.d.ts +2 -0
- package/lib/components/InfoTeaser/styles.module.scss +0 -2
- package/lib/components/Label/Label.d.ts +2 -0
- package/lib/components/Label/index.d.ts +1 -0
- package/lib/components/Label/index.js +3 -3
- package/lib/components/Label/styles.module.scss +1 -1
- package/lib/components/Label/utils.d.ts +21 -2
- package/lib/components/LazyIcon/index.d.ts +1 -0
- package/lib/components/LazyIcon/index.js +2 -2
- package/lib/components/ListEditMode/index.d.ts +1 -0
- package/lib/components/ListEditMode/index.js +2 -2
- package/lib/components/Loader/index.js +4 -4
- package/lib/components/Loader/index.js.map +1 -1
- package/lib/components/Modal/index.js +9 -9
- package/lib/components/Modal/index.js.map +1 -1
- package/lib/components/NotificationPanel/index.js +6 -6
- package/lib/components/NotificationPanel/index.js.map +1 -1
- package/lib/components/Panel/index.js +13 -13
- package/lib/components/Panel/index.js.map +1 -1
- package/lib/components/PanelList/index.d.ts +1 -0
- package/lib/components/PanelList/index.js +5 -5
- package/lib/components/PanelList/index.js.map +1 -1
- package/lib/components/PopMenu/index.js +3 -3
- package/lib/components/PopMenu/index.js.map +1 -1
- package/lib/components/Progressbar/index.js +2 -2
- package/lib/components/Progressbar/index.js.map +1 -1
- package/lib/components/PromoPanel/index.js +2 -2
- package/lib/components/PromoPanel/index.js.map +1 -1
- package/lib/components/RadioButton/index.d.ts +1 -0
- package/lib/components/RadioButton/index.js +3 -3
- package/lib/components/RadioButton/styles.module.scss +4 -0
- package/lib/components/RadioButton/styles.module.scss.d.ts +1 -0
- package/lib/components/Select/styles.module.scss +2 -0
- package/lib/components/ServiceMessage/index.js +6 -6
- package/lib/components/ServiceMessage/index.js.map +1 -1
- package/lib/components/SharingStatus/index.js +4 -4
- package/lib/components/SharingStatus/index.js.map +1 -1
- package/lib/components/StatusDot/constants.d.ts +2 -1
- package/lib/components/StatusDot/styles.module.scss +4 -2
- package/lib/components/StatusDot/styles.module.scss.d.ts +1 -0
- package/lib/components/Step/index.js +2 -2
- package/lib/components/Step/index.js.map +1 -1
- package/lib/components/Stepper/index.d.ts +1 -0
- package/lib/components/Stepper/index.js +4 -3
- package/lib/components/Stepper/index.js.map +1 -1
- package/lib/components/StickyNote/index.js +8 -8
- package/lib/components/StickyNote/index.js.map +1 -1
- package/lib/components/Table/index.d.ts +1 -0
- package/lib/components/Table/index.js +5 -5
- package/lib/components/Table/index.js.map +1 -1
- package/lib/components/Table/styles.module.scss +1 -1
- package/lib/components/Tabs/index.js +4 -4
- package/lib/components/Tabs/index.js.map +1 -1
- package/lib/components/Tag/index.js +2 -2
- package/lib/components/Tag/index.js.map +1 -1
- package/lib/components/Tile/index.js +4 -4
- package/lib/components/Tile/index.js.map +1 -1
- package/lib/components/Title/styles.module.scss +0 -1
- package/lib/components/Toggle/index.js +18 -18
- package/lib/components/Toggle/index.js.map +1 -1
- package/lib/components/Validation/index.js +4 -4
- package/lib/components/Validation/index.js.map +1 -1
- package/lib/constants3.js +44 -4
- package/lib/constants3.js.map +1 -1
- package/lib/floating-ui.react.js +7 -3
- package/lib/floating-ui.react.js.map +1 -1
- package/lib/scss/_font-mixins.scss +2 -0
- package/lib/scss/_print.scss +3 -3
- package/lib/scss/_radio-reset.scss +1 -1
- package/lib/scss/_screen-reader.scss +7 -10
- package/lib/useElementList.js +15 -2
- package/lib/useElementList.js.map +1 -1
- package/lib/utils2.js +121 -33
- package/lib/utils2.js.map +1 -1
- package/lib/utils3.js +98 -10
- package/lib/utils3.js.map +1 -1
- package/lib/utils4.js +11 -28
- package/lib/utils4.js.map +1 -1
- package/lib/utils5.js +28 -58
- package/lib/utils5.js.map +1 -1
- package/lib/utils6.js +60 -0
- package/lib/utils6.js.map +1 -0
- package/package.json +3 -3
- package/scss/_font-mixins.scss +2 -0
- package/scss/_print.scss +3 -3
- package/scss/_radio-reset.scss +1 -1
- package/scss/_screen-reader.scss +7 -10
- package/lib/Label2.js +0 -5
- package/lib/Label2.js.map +0 -1
- package/lib/RadioButton2.js +0 -5
- package/lib/RadioButton2.js.map +0 -1
- package/lib/components/Icons/DotActive.d.ts +0 -3
- package/lib/components/Icons/DotActive.js.map +0 -1
- package/lib/components/Icons/DotAlert.d.ts +0 -3
- package/lib/components/Icons/DotAlert.js.map +0 -1
- package/lib/components/Icons/DotCancelled.d.ts +0 -3
- package/lib/components/Icons/DotCancelled.js.map +0 -1
- package/lib/components/Icons/DotInactive.d.ts +0 -3
- package/lib/components/Icons/DotInactive.js.map +0 -1
- package/lib/components/Icons/DotPending.d.ts +0 -3
- package/lib/components/Icons/DotPending.js.map +0 -1
- package/lib/components/Icons/DotSuccess.d.ts +0 -3
- package/lib/components/Icons/DotSuccess.js.map +0 -1
- package/lib/components/Icons/DotTransparent.d.ts +0 -3
- package/lib/components/Icons/DotTransparent.js +0 -22
- package/lib/components/Icons/DotTransparent.js.map +0 -1
- package/lib/components/Icons/DotWarningTriangle.d.ts +0 -3
- package/lib/components/Icons/DotWarningTriangle.js.map +0 -1
- package/lib/constants4.js +0 -46
- package/lib/constants4.js.map +0 -1
- package/lib/scss/_figma-tokens.scss +0 -68
- package/scss/_figma-tokens.scss +0 -68
package/lib/AnchorLink.js
CHANGED
|
@@ -4,14 +4,14 @@ import { t as getColor } from "./color.js";
|
|
|
4
4
|
import { t as AsChildSlot_default } from "./AsChildSlot.js";
|
|
5
5
|
import { t as Icon_default } from "./Icon.js";
|
|
6
6
|
import { t as ArrowUpRight_default } from "./ArrowUpRight.js";
|
|
7
|
-
import
|
|
7
|
+
import cn from "classnames";
|
|
8
8
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import AnchorLinkStyles from "./components/AnchorLink/styles.module.scss";
|
|
10
10
|
var AnchorLink = (props) => {
|
|
11
11
|
const { asChild, id, href, children, className, target = "_self", htmlMarkup = "a", onClick, testId, ref } = props;
|
|
12
12
|
const external = target === "_blank";
|
|
13
13
|
const { refObject, isHovered } = usePseudoClasses(ref);
|
|
14
|
-
const anchorClasses =
|
|
14
|
+
const anchorClasses = cn(AnchorLinkStyles.anchorlink, className);
|
|
15
15
|
const commonProps = {
|
|
16
16
|
id,
|
|
17
17
|
["data-testid"]: testId,
|
package/lib/AnchorLink.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnchorLink.js","names":["AnchorLink: React.FC<AnchorLinkProps>"],"sources":["../src/components/AnchorLink/AnchorLink.tsx","../src/components/AnchorLink/index.ts"],"sourcesContent":["import classNames from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { getColor } from '../../theme/currys';\nimport AsChildSlot from '../AsChildSlot';\nimport Icon, { IconSize } from '../Icon';\nimport ArrowUpRight from '../Icons/ArrowUpRight';\n\nimport AnchorLinkStyles from './styles.module.scss';\n\nexport type AnchorLinkTargets = '_self' | '_blank' | '_parent';\n\nexport type AnchorLinkTags = 'a' | 'button';\n\nexport type AnchorLinkOnClickEvent =\n | React.MouseEvent<HTMLElement, MouseEvent>\n | React.FormEvent<unknown>\n | React.KeyboardEvent<HTMLUListElement>\n | null;\n\nexport interface AnchorLinkProps {\n /** When true, onclick and keyboard events will be passed to the child. */\n asChild?: boolean;\n /** Sets the content of the <a> tag */\n children: React.ReactNode;\n /** URL to link to */\n href?: string;\n /** Gives a unique id to the anchor-link :) */\n id?: string;\n /** Adds custom classes to the element. */\n className?: string;\n /** Sets the target type of the <a> tag. _blank adds an arrow icon at the end of the link */\n target?: AnchorLinkTargets;\n /** HTML markup for anchor link. Default: a */\n htmlMarkup?: AnchorLinkTags;\n /** Function that is called when clicked */\n onClick?: (e?: AnchorLinkOnClickEvent) => void;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Ref that is passed to the component */\n ref?: React.Ref<HTMLAnchorElement | HTMLButtonElement | null>;\n}\n\nconst AnchorLink: React.FC<AnchorLinkProps> = props => {\n const { asChild, id, href, children, className, target = '_self', htmlMarkup = 'a', onClick, testId, ref } = props;\n const external = target === '_blank';\n const { refObject, isHovered } = usePseudoClasses<HTMLButtonElement | HTMLAnchorElement>(\n ref as React.RefObject<HTMLButtonElement | HTMLAnchorElement>\n );\n const anchorClasses = classNames(AnchorLinkStyles.anchorlink, className);\n\n const commonProps = {\n id,\n ['data-testid']: testId,\n ['data-analyticsid']: AnalyticsId.AnchorLink,\n onClick,\n };\n\n const renderContent = (): React.ReactElement => (\n <>\n {children}\n {external && (\n <Icon\n className={AnchorLinkStyles.anchorlink__icon}\n svgIcon={ArrowUpRight}\n color={getColor('blueberry', 600)}\n hoverColor={getColor('blueberry', 700)}\n size={IconSize.XSmall}\n isHovered={isHovered}\n />\n )}\n </>\n );\n\n if (asChild) {\n return (\n <AsChildSlot content={<span className={anchorClasses} />} className={AnchorLinkStyles['anchorlink-wrapper']} elementRef={refObject}>\n {children}\n </AsChildSlot>\n );\n }\n\n if (htmlMarkup === 'a') {\n return (\n <a\n href={href}\n target={target}\n className={anchorClasses}\n rel={external ? 'noopener noreferrer' : undefined}\n ref={refObject as React.RefObject<HTMLAnchorElement>}\n {...commonProps}\n >\n {renderContent()}\n </a>\n );\n }\n\n return (\n <button\n type=\"button\"\n className={AnchorLinkStyles['anchorlink-wrapper']}\n ref={refObject as React.RefObject<HTMLButtonElement>}\n {...commonProps}\n >\n <span className={anchorClasses}>{renderContent()}</span>\n </button>\n );\n};\n\nexport default AnchorLink;\n","import AnchorLink from './AnchorLink';\nexport * from './AnchorLink';\nexport default AnchorLink;\n"],"mappings":";;;;;;;;;AA4CA,IAAMA,cAAwC,UAAS;CACrD,MAAM,EAAE,SAAS,IAAI,MAAM,UAAU,WAAW,SAAS,SAAS,aAAa,KAAK,SAAS,QAAQ,QAAQ;CAC7G,MAAM,WAAW,WAAW;CAC5B,MAAM,EAAE,WAAW,cAAc,iBAC/B,IACD;CACD,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"AnchorLink.js","names":["AnchorLink: React.FC<AnchorLinkProps>"],"sources":["../src/components/AnchorLink/AnchorLink.tsx","../src/components/AnchorLink/index.ts"],"sourcesContent":["import classNames from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { getColor } from '../../theme/currys';\nimport AsChildSlot from '../AsChildSlot';\nimport Icon, { IconSize } from '../Icon';\nimport ArrowUpRight from '../Icons/ArrowUpRight';\n\nimport AnchorLinkStyles from './styles.module.scss';\n\nexport type AnchorLinkTargets = '_self' | '_blank' | '_parent';\n\nexport type AnchorLinkTags = 'a' | 'button';\n\nexport type AnchorLinkOnClickEvent =\n | React.MouseEvent<HTMLElement, MouseEvent>\n | React.FormEvent<unknown>\n | React.KeyboardEvent<HTMLUListElement>\n | null;\n\nexport interface AnchorLinkProps {\n /** When true, onclick and keyboard events will be passed to the child. */\n asChild?: boolean;\n /** Sets the content of the <a> tag */\n children: React.ReactNode;\n /** URL to link to */\n href?: string;\n /** Gives a unique id to the anchor-link :) */\n id?: string;\n /** Adds custom classes to the element. */\n className?: string;\n /** Sets the target type of the <a> tag. _blank adds an arrow icon at the end of the link */\n target?: AnchorLinkTargets;\n /** HTML markup for anchor link. Default: a */\n htmlMarkup?: AnchorLinkTags;\n /** Function that is called when clicked */\n onClick?: (e?: AnchorLinkOnClickEvent) => void;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Ref that is passed to the component */\n ref?: React.Ref<HTMLAnchorElement | HTMLButtonElement | null>;\n}\n\nconst AnchorLink: React.FC<AnchorLinkProps> = props => {\n const { asChild, id, href, children, className, target = '_self', htmlMarkup = 'a', onClick, testId, ref } = props;\n const external = target === '_blank';\n const { refObject, isHovered } = usePseudoClasses<HTMLButtonElement | HTMLAnchorElement>(\n ref as React.RefObject<HTMLButtonElement | HTMLAnchorElement>\n );\n const anchorClasses = classNames(AnchorLinkStyles.anchorlink, className);\n\n const commonProps = {\n id,\n ['data-testid']: testId,\n ['data-analyticsid']: AnalyticsId.AnchorLink,\n onClick,\n };\n\n const renderContent = (): React.ReactElement => (\n <>\n {children}\n {external && (\n <Icon\n className={AnchorLinkStyles.anchorlink__icon}\n svgIcon={ArrowUpRight}\n color={getColor('blueberry', 600)}\n hoverColor={getColor('blueberry', 700)}\n size={IconSize.XSmall}\n isHovered={isHovered}\n />\n )}\n </>\n );\n\n if (asChild) {\n return (\n <AsChildSlot content={<span className={anchorClasses} />} className={AnchorLinkStyles['anchorlink-wrapper']} elementRef={refObject}>\n {children}\n </AsChildSlot>\n );\n }\n\n if (htmlMarkup === 'a') {\n return (\n <a\n href={href}\n target={target}\n className={anchorClasses}\n rel={external ? 'noopener noreferrer' : undefined}\n ref={refObject as React.RefObject<HTMLAnchorElement>}\n {...commonProps}\n >\n {renderContent()}\n </a>\n );\n }\n\n return (\n <button\n type=\"button\"\n className={AnchorLinkStyles['anchorlink-wrapper']}\n ref={refObject as React.RefObject<HTMLButtonElement>}\n {...commonProps}\n >\n <span className={anchorClasses}>{renderContent()}</span>\n </button>\n );\n};\n\nexport default AnchorLink;\n","import AnchorLink from './AnchorLink';\nexport * from './AnchorLink';\nexport default AnchorLink;\n"],"mappings":";;;;;;;;;AA4CA,IAAMA,cAAwC,UAAS;CACrD,MAAM,EAAE,SAAS,IAAI,MAAM,UAAU,WAAW,SAAS,SAAS,aAAa,KAAK,SAAS,QAAQ,QAAQ;CAC7G,MAAM,WAAW,WAAW;CAC5B,MAAM,EAAE,WAAW,cAAc,iBAC/B,IACD;CACD,MAAM,gBAAgB,GAAW,iBAAiB,YAAY,UAAU;CAExE,MAAM,cAAc;EAClB;GACC,gBAAgB;GAChB,qBAAqB,YAAY;EAClC;EACD;CAED,MAAM,sBACJ,qBAAA,UAAA,EAAA,UAAA,CACG,UACA,YACC,oBAAC,cAAA;EACC,WAAW,iBAAiB;EAC5B,SAAS;EACT,OAAO,SAAS,aAAa,IAAI;EACjC,YAAY,SAAS,aAAa,IAAI;EACtC,MAAM,SAAS;EACJ;GACX,CAAA,EAAA,CAEH;AAGL,KAAI,QACF,QACE,oBAAC,qBAAA;EAAY,SAAS,oBAAC,QAAA,EAAK,WAAW,eAAA,CAAiB;EAAE,WAAW,iBAAiB;EAAuB,YAAY;EACtH;GACW;AAIlB,KAAI,eAAe,IACjB,QACE,oBAAC,KAAA;EACO;EACE;EACR,WAAW;EACX,KAAK,WAAW,wBAAwB,KAAA;EACxC,KAAK;EACL,GAAI;YAEH,eAAe;GACd;AAIR,QACE,oBAAC,UAAA;EACC,MAAK;EACL,WAAW,iBAAiB;EAC5B,KAAK;EACL,GAAI;YAEJ,oBAAC,QAAA;GAAK,WAAW;aAAgB,eAAe;IAAQ;GACjD;;ACxGb,IAAA,uBD4Ge"}
|
package/lib/Avatar.js
CHANGED
|
@@ -2,7 +2,7 @@ import { a as IconSize, n as AnalyticsId } from "./constants2.js";
|
|
|
2
2
|
import { t as palette } from "./palette.js";
|
|
3
3
|
import { t as Icon_default } from "./Icon.js";
|
|
4
4
|
import { t as Check_default } from "./Check.js";
|
|
5
|
-
import
|
|
5
|
+
import cn from "classnames";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
7
|
import styles from "./components/Avatar/styles.module.scss";
|
|
8
8
|
let AvatarSize = /* @__PURE__ */ function(AvatarSize$1) {
|
|
@@ -14,7 +14,7 @@ var Avatar = (props) => {
|
|
|
14
14
|
const { children, className = "", selected = false, color = "blueberry", variant = "square", size = AvatarSize.small, testId, ref } = props;
|
|
15
15
|
const truncatedName = children.charAt(0).toLocaleUpperCase() + children.substring(1, 2);
|
|
16
16
|
return /* @__PURE__ */ jsx("span", {
|
|
17
|
-
className:
|
|
17
|
+
className: cn(styles.avatar, selected && styles["avatar--selected"], color === "black" && styles["avatar--black"], variant === "circle" && styles["avatar--circle"], size === AvatarSize.xsmall && styles["avatar--xsmall"], size === AvatarSize.small && styles["avatar--small"], className),
|
|
18
18
|
ref,
|
|
19
19
|
"data-testid": testId,
|
|
20
20
|
"data-analyticsid": AnalyticsId.Avatar,
|
package/lib/Avatar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Avatar.js","names":["Avatar: React.FC<AvatarProps>"],"sources":["../src/components/Avatar/constants.ts","../src/components/Avatar/Avatar.tsx","../src/components/Avatar/index.ts"],"sourcesContent":["export enum AvatarSize {\n xsmall = 'xsmall',\n small = 'small',\n}\n","import cn from 'classnames';\n\nimport { AvatarSize } from './constants';\nimport { AnalyticsId } from '../../constants';\nimport { palette } from '../../theme/palette';\nimport Icon, { IconSize } from '../Icon';\nimport Check from '../Icons/Check';\n\nimport styles from './styles.module.scss';\n\nexport interface AvatarProps {\n /** Name to display in the avatar. Will be truncated to the first two characters. */\n children: string;\n /** Displays a check icon to indicated the selected state. */\n selected?: boolean;\n /** Sets blue or black color on avatar. */\n color?: 'blueberry' | 'black';\n /** Square or circle variant of avatar. The circle should only be used for representation of someone else. NB: This is temporary and will be renamed in v10 */\n variant?: 'square' | 'circle';\n /** Avatar size. Default: small */\n size?: keyof typeof AvatarSize;\n /** Adds custom classes to the element. */\n className?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Ref passed to the root element */\n ref?: React.Ref<HTMLElement | null>;\n}\nexport type AvatarType = typeof Avatar;\nconst Avatar: React.FC<AvatarProps> = (props: AvatarProps) => {\n const {\n children,\n className = '',\n selected = false,\n color = 'blueberry',\n variant = 'square',\n size = AvatarSize.small,\n testId,\n ref,\n } = props;\n const truncatedName = children.charAt(0).toLocaleUpperCase() + children.substring(1, 2);\n return (\n <span\n className={cn(\n styles.avatar,\n selected && styles['avatar--selected'],\n color === 'black' && styles['avatar--black'],\n variant === 'circle' && styles['avatar--circle'],\n size === AvatarSize.xsmall && styles['avatar--xsmall'],\n size === AvatarSize.small && styles['avatar--small'],\n className\n )}\n ref={ref}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Avatar}\n >\n {selected ? (\n <Icon svgIcon={Check} size={IconSize.Small} color={color === 'black' ? palette.neutral900 : palette.blueberry600} />\n ) : (\n truncatedName\n )}\n </span>\n );\n};\n\nexport default Avatar;\n","import Avatar from './Avatar';\nexport { AvatarSize } from './constants';\nexport * from './Avatar';\nexport default Avatar;\n"],"mappings":";;;;;;;AAAA,IAAY,aAAA,yBAAA,cAAL;AACL,cAAA,YAAA;AACA,cAAA,WAAA;;;AC2BF,IAAMA,UAAiC,UAAuB;CAC5D,MAAM,EACJ,UACA,YAAY,IACZ,WAAW,OACX,QAAQ,aACR,UAAU,UACV,OAAO,WAAW,OAClB,QACA,QACE;CACJ,MAAM,gBAAgB,SAAS,OAAO,EAAE,CAAC,mBAAmB,GAAG,SAAS,UAAU,GAAG,EAAE;AACvF,QACE,oBAAC,QAAA;EACC,WAAW,
|
|
1
|
+
{"version":3,"file":"Avatar.js","names":["Avatar: React.FC<AvatarProps>"],"sources":["../src/components/Avatar/constants.ts","../src/components/Avatar/Avatar.tsx","../src/components/Avatar/index.ts"],"sourcesContent":["export enum AvatarSize {\n xsmall = 'xsmall',\n small = 'small',\n}\n","import cn from 'classnames';\n\nimport { AvatarSize } from './constants';\nimport { AnalyticsId } from '../../constants';\nimport { palette } from '../../theme/palette';\nimport Icon, { IconSize } from '../Icon';\nimport Check from '../Icons/Check';\n\nimport styles from './styles.module.scss';\n\nexport interface AvatarProps {\n /** Name to display in the avatar. Will be truncated to the first two characters. */\n children: string;\n /** Displays a check icon to indicated the selected state. */\n selected?: boolean;\n /** Sets blue or black color on avatar. */\n color?: 'blueberry' | 'black';\n /** Square or circle variant of avatar. The circle should only be used for representation of someone else. NB: This is temporary and will be renamed in v10 */\n variant?: 'square' | 'circle';\n /** Avatar size. Default: small */\n size?: keyof typeof AvatarSize;\n /** Adds custom classes to the element. */\n className?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Ref passed to the root element */\n ref?: React.Ref<HTMLElement | null>;\n}\nexport type AvatarType = typeof Avatar;\nconst Avatar: React.FC<AvatarProps> = (props: AvatarProps) => {\n const {\n children,\n className = '',\n selected = false,\n color = 'blueberry',\n variant = 'square',\n size = AvatarSize.small,\n testId,\n ref,\n } = props;\n const truncatedName = children.charAt(0).toLocaleUpperCase() + children.substring(1, 2);\n return (\n <span\n className={cn(\n styles.avatar,\n selected && styles['avatar--selected'],\n color === 'black' && styles['avatar--black'],\n variant === 'circle' && styles['avatar--circle'],\n size === AvatarSize.xsmall && styles['avatar--xsmall'],\n size === AvatarSize.small && styles['avatar--small'],\n className\n )}\n ref={ref}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Avatar}\n >\n {selected ? (\n <Icon svgIcon={Check} size={IconSize.Small} color={color === 'black' ? palette.neutral900 : palette.blueberry600} />\n ) : (\n truncatedName\n )}\n </span>\n );\n};\n\nexport default Avatar;\n","import Avatar from './Avatar';\nexport { AvatarSize } from './constants';\nexport * from './Avatar';\nexport default Avatar;\n"],"mappings":";;;;;;;AAAA,IAAY,aAAA,yBAAA,cAAL;AACL,cAAA,YAAA;AACA,cAAA,WAAA;;;AC2BF,IAAMA,UAAiC,UAAuB;CAC5D,MAAM,EACJ,UACA,YAAY,IACZ,WAAW,OACX,QAAQ,aACR,UAAU,UACV,OAAO,WAAW,OAClB,QACA,QACE;CACJ,MAAM,gBAAgB,SAAS,OAAO,EAAE,CAAC,mBAAmB,GAAG,SAAS,UAAU,GAAG,EAAE;AACvF,QACE,oBAAC,QAAA;EACC,WAAW,GACT,OAAO,QACP,YAAY,OAAO,qBACnB,UAAU,WAAW,OAAO,kBAC5B,YAAY,YAAY,OAAO,mBAC/B,SAAS,WAAW,UAAU,OAAO,mBACrC,SAAS,WAAW,SAAS,OAAO,kBACpC,UACD;EACI;EACL,eAAa;EACb,oBAAkB,YAAY;YAE7B,WACC,oBAAC,cAAA;GAAK,SAAS;GAAO,MAAM,SAAS;GAAO,OAAO,UAAU,UAAU,QAAQ,aAAa,QAAQ;IAAgB,GAEpH;GAEG;;AC1DX,IAAA,mBD8De"}
|
package/lib/BabyMobileMedium.js
CHANGED
package/lib/Badge.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { a as IconSize, n as AnalyticsId } from "./constants2.js";
|
|
2
2
|
import { t as NotificationBadge_default } from "./NotificationBadge.js";
|
|
3
|
-
import
|
|
3
|
+
import cn from "classnames";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
import badgeStyles from "./components/Badge/styles.module.scss";
|
|
6
6
|
var Badge = (props) => {
|
|
7
7
|
const { children, className = "", color = "blueberry", testId, type = "string", notificationVariant = "info", ref } = props;
|
|
8
|
-
const badgeClasses =
|
|
8
|
+
const badgeClasses = cn(badgeStyles.badge, {
|
|
9
9
|
[badgeStyles["badge--blueberry"]]: color === "blueberry",
|
|
10
10
|
[badgeStyles["badge--cherry"]]: color === "cherry",
|
|
11
11
|
[badgeStyles["badge--neutral"]]: color === "neutral"
|
package/lib/Badge.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Badge.js","names":["Badge: React.FC<BadgeProps>"],"sources":["../src/components/Badge/Badge.tsx","../src/components/Badge/index.ts"],"sourcesContent":["import classNames from 'classnames';\n\nimport type { BadgeNotificationVariant } from './NotificationBadge';\nimport type { PaletteNames } from '../../theme/palette';\n\nimport NotificationBadge from './NotificationBadge';\nimport { AnalyticsId, IconSize } from '../../constants';\n\nimport badgeStyles from './styles.module.scss';\n\nexport type BadgeColors = Extract<PaletteNames, 'blueberry' | 'cherry' | 'neutral'>;\nexport type BadgeChildren = string | number;\nexport type BadgeVariant = 'string' | 'notification';\n\nexport interface BadgeProps {\n /** Sets the content of the badge. */\n children?: BadgeChildren;\n /** Adds custom classes to the element. */\n className?: string;\n /** Changes the badge background color. */\n color?: BadgeColors;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Changes the type of the badge. Default: string */\n type?: BadgeVariant;\n /** Type of notification badge. Only works if type is 'notification'. */\n notificationVariant?: BadgeNotificationVariant;\n /** Ref passed to the root element */\n ref?: React.Ref<HTMLElement | null>;\n}\n\nexport type BadgeType = typeof Badge;\nconst Badge: React.FC<BadgeProps> = (props: BadgeProps) => {\n const { children, className = '', color = 'blueberry', testId, type = 'string', notificationVariant = 'info', ref } = props;\n const badgeClasses = classNames(\n badgeStyles.badge,\n {\n [badgeStyles['badge--blueberry']]: color === 'blueberry',\n [badgeStyles['badge--cherry']]: color === 'cherry',\n [badgeStyles['badge--neutral']]: color === 'neutral',\n },\n className\n );\n\n if (type === 'notification' && notificationVariant !== undefined) {\n return (\n <NotificationBadge\n variant={notificationVariant}\n size={IconSize.XSmall}\n className={className}\n testId={testId}\n data-analyticsid={AnalyticsId.Badge}\n />\n );\n }\n\n return (\n <span className={badgeClasses} ref={ref} data-testid={testId} data-analyticsid={AnalyticsId.Badge}>\n {children}\n </span>\n );\n};\n\nexport default Badge;\n","import Badge from './Badge';\nexport * from './Badge';\nexport default Badge;\n"],"mappings":";;;;;AAgCA,IAAMA,SAA+B,UAAsB;CACzD,MAAM,EAAE,UAAU,YAAY,IAAI,QAAQ,aAAa,QAAQ,OAAO,UAAU,sBAAsB,QAAQ,QAAQ;CACtH,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"Badge.js","names":["Badge: React.FC<BadgeProps>"],"sources":["../src/components/Badge/Badge.tsx","../src/components/Badge/index.ts"],"sourcesContent":["import classNames from 'classnames';\n\nimport type { BadgeNotificationVariant } from './NotificationBadge';\nimport type { PaletteNames } from '../../theme/palette';\n\nimport NotificationBadge from './NotificationBadge';\nimport { AnalyticsId, IconSize } from '../../constants';\n\nimport badgeStyles from './styles.module.scss';\n\nexport type BadgeColors = Extract<PaletteNames, 'blueberry' | 'cherry' | 'neutral'>;\nexport type BadgeChildren = string | number;\nexport type BadgeVariant = 'string' | 'notification';\n\nexport interface BadgeProps {\n /** Sets the content of the badge. */\n children?: BadgeChildren;\n /** Adds custom classes to the element. */\n className?: string;\n /** Changes the badge background color. */\n color?: BadgeColors;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Changes the type of the badge. Default: string */\n type?: BadgeVariant;\n /** Type of notification badge. Only works if type is 'notification'. */\n notificationVariant?: BadgeNotificationVariant;\n /** Ref passed to the root element */\n ref?: React.Ref<HTMLElement | null>;\n}\n\nexport type BadgeType = typeof Badge;\nconst Badge: React.FC<BadgeProps> = (props: BadgeProps) => {\n const { children, className = '', color = 'blueberry', testId, type = 'string', notificationVariant = 'info', ref } = props;\n const badgeClasses = classNames(\n badgeStyles.badge,\n {\n [badgeStyles['badge--blueberry']]: color === 'blueberry',\n [badgeStyles['badge--cherry']]: color === 'cherry',\n [badgeStyles['badge--neutral']]: color === 'neutral',\n },\n className\n );\n\n if (type === 'notification' && notificationVariant !== undefined) {\n return (\n <NotificationBadge\n variant={notificationVariant}\n size={IconSize.XSmall}\n className={className}\n testId={testId}\n data-analyticsid={AnalyticsId.Badge}\n />\n );\n }\n\n return (\n <span className={badgeClasses} ref={ref} data-testid={testId} data-analyticsid={AnalyticsId.Badge}>\n {children}\n </span>\n );\n};\n\nexport default Badge;\n","import Badge from './Badge';\nexport * from './Badge';\nexport default Badge;\n"],"mappings":";;;;;AAgCA,IAAMA,SAA+B,UAAsB;CACzD,MAAM,EAAE,UAAU,YAAY,IAAI,QAAQ,aAAa,QAAQ,OAAO,UAAU,sBAAsB,QAAQ,QAAQ;CACtH,MAAM,eAAe,GACnB,YAAY,OACZ;GACG,YAAY,sBAAsB,UAAU;GAC5C,YAAY,mBAAmB,UAAU;GACzC,YAAY,oBAAoB,UAAU;EAC5C,EACD,UACD;AAED,KAAI,SAAS,kBAAkB,wBAAwB,KAAA,EACrD,QACE,oBAAC,2BAAA;EACC,SAAS;EACT,MAAM,SAAS;EACJ;EACH;EACR,oBAAkB,YAAY;GAC9B;AAIN,QACE,oBAAC,QAAA;EAAK,WAAW;EAAmB;EAAK,eAAa;EAAQ,oBAAkB,YAAY;EACzF;GACI;;ACzDX,IAAA,kBD6De"}
|
package/lib/Button.js
CHANGED
|
@@ -6,7 +6,7 @@ import { t as Icon_default } from "./Icon.js";
|
|
|
6
6
|
import { t as useIcons } from "./useIcons.js";
|
|
7
7
|
import { t as useIsMobileBreakpoint } from "./useIsMobileBreakpoint.js";
|
|
8
8
|
import { t as ArrowRight_default } from "./ArrowRight.js";
|
|
9
|
-
import
|
|
9
|
+
import cn from "classnames";
|
|
10
10
|
import React, { useEffect, useRef } from "react";
|
|
11
11
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
12
12
|
import buttonStyles from "./components/Button/styles.module.scss";
|
|
@@ -41,8 +41,8 @@ var Button = (props) => {
|
|
|
41
41
|
const large = size === "large" && !destructive && !borderlessVariant;
|
|
42
42
|
const hasUURightArrow = arrow === "accessibility-character" && !fluid && !leftIcon && !rightIcon && !hasArrow && borderlessVariant;
|
|
43
43
|
const rest = { ...restProps };
|
|
44
|
-
const buttonWrapperClasses =
|
|
45
|
-
const buttonClasses =
|
|
44
|
+
const buttonWrapperClasses = cn(buttonStyles["button-wrapper"], { [buttonStyles["button-wrapper--fluid"]]: fluid || ellipsis }, wrapperClassName);
|
|
45
|
+
const buttonClasses = cn(buttonStyles.button, {
|
|
46
46
|
[buttonStyles["button--destructive"]]: destructive,
|
|
47
47
|
[buttonStyles["button--normal"]]: !large,
|
|
48
48
|
[buttonStyles["button--large"]]: large,
|
|
@@ -55,11 +55,11 @@ var Button = (props) => {
|
|
|
55
55
|
[buttonStyles["button--arrow"]]: hasArrow,
|
|
56
56
|
[buttonStyles["button--on-dark"]]: onDark
|
|
57
57
|
}, className);
|
|
58
|
-
const buttonTextClasses =
|
|
58
|
+
const buttonTextClasses = cn(buttonStyles["button__text"], {
|
|
59
59
|
[buttonStyles["button__text--ellipsis"]]: ellipsis,
|
|
60
60
|
[buttonStyles["button__text--centered"]]: fluid && textPosition === "centered"
|
|
61
61
|
}, textClassName);
|
|
62
|
-
const diagonalClasses =
|
|
62
|
+
const diagonalClasses = cn(buttonStyles["diagonal"], { [buttonStyles["diagonal--on-dark"]]: onDark });
|
|
63
63
|
useEffect(() => {
|
|
64
64
|
checkOnlyIconAria(onlyIcon, ariaLabel, !isTest() && !isProd());
|
|
65
65
|
}, []);
|
|
@@ -86,7 +86,7 @@ var Button = (props) => {
|
|
|
86
86
|
children: [
|
|
87
87
|
renderIcon(leftIcon, getLargeIconSize(large, isMobile), !onlyIcon ? buttonStyles["button__left-icon"] : void 0),
|
|
88
88
|
renderButtonContent(),
|
|
89
|
-
hasArrow ? renderIcon(/* @__PURE__ */ jsx(Icon_default, { svgIcon: ArrowRight_default }), getLargeIconSize(large, isMobile),
|
|
89
|
+
hasArrow ? renderIcon(/* @__PURE__ */ jsx(Icon_default, { svgIcon: ArrowRight_default }), getLargeIconSize(large, isMobile), cn(buttonStyles["button__arrow"], { [buttonStyles["button__arrow--both-icons"]]: bothIcons })) : renderIcon(rightIcon, getLargeIconSize(large, isMobile), buttonStyles["button__right-icon"]),
|
|
90
90
|
hasUURightArrow && /* @__PURE__ */ jsx("span", {
|
|
91
91
|
style: { color: iconColor },
|
|
92
92
|
className: buttonStyles["button__right-unicode-arrow"],
|
package/lib/Button.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","names":["Button: React.FC<ButtonProps>"],"sources":["../src/components/Button/Button.tsx","../src/components/Button/index.ts"],"sourcesContent":["import React, { type AriaAttributes, useEffect, useRef } from 'react';\n\nimport classNames from 'classnames';\n\nimport Icon, { IconSize } from './../Icon';\nimport { type HTMLButtonProps, type HTMLAnchorProps, AnalyticsId } from '../../constants';\nimport { type BaseIconElement, useIcons } from '../../hooks/useIcons';\nimport { useIsMobileBreakpoint } from '../../hooks/useIsMobileBreakpoint';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { getColor } from '../../theme/currys/color';\nimport { isTest, isProd } from '../../utils/environment';\nimport ArrowRight from '../Icons/ArrowRight';\n\nimport buttonStyles from './styles.module.scss';\n\nexport type ButtonConcept = 'normal' | 'destructive';\nexport type ButtonVariant = 'fill' | 'outline' | 'borderless';\nexport type ButtonSize = 'medium' | 'large';\nexport type ButtonOnColor = 'onlight' | 'ondark';\nexport type ButtonTags = 'button' | 'a';\nexport type ButtonArrows = 'icon' | 'accessibility-character';\nexport type ButtonTextPosition = 'left' | 'centered';\n\nexport interface ButtonProps extends Omit<HTMLButtonProps, 'onClick' | 'type'>, Omit<HTMLAnchorProps, 'onClick'>, AriaAttributes {\n /** Sets the aria-label of the button, use when the button only includes an icon */\n ariaLabel?: string;\n /** Gives a unique id to the button */\n id?: string;\n /** Sets the content of the button. */\n children: React.ReactNode;\n /** Adds custom classes to the wrapper element. */\n wrapperClassName?: string;\n /** Adds custom classes to the element. */\n className?: string;\n /** Enables an arrow icon to the right inside the button (Not available in borderless variant) */\n arrow?: ButtonArrows;\n /** Changes the intent of the button. Mostly changes the color profile. */\n concept?: ButtonConcept;\n /** Disables text wrapping and enables ellipsis. */\n ellipsis?: boolean;\n /** Makes the button scale to full width of its parent element. */\n fluid?: boolean;\n /** Changes the underlying element of the button. */\n htmlMarkup?: ButtonTags;\n /** Changes the button colors for different backgrounds. */\n onColor?: ButtonOnColor;\n /** Function that is called when the Button loses focus */\n onBlur?: () => void;\n /** Function that is called when clicked */\n onClick?: (\n e?: React.MouseEvent<HTMLElement, MouseEvent> | React.FormEvent<unknown> | React.KeyboardEvent<HTMLUListElement> | null\n ) => void;\n /** Changes the button colors for different backgrounds. (Large not available in borderless variant) */\n size?: ButtonSize;\n /** Changes the visual representation of the button. */\n variant?: ButtonVariant;\n /** Specifies the focus order relative to the other buttons or controls on the page */\n tabIndex?: number;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Adds custom classes to the text */\n textClassName?: string;\n /** Sets the position of the text in the button - only applies when button is fluid */\n textPosition?: ButtonTextPosition;\n /** Button type. Default: button */\n type?: React.ButtonHTMLAttributes<HTMLButtonElement>['type'];\n /** Ref that is passed to the component */\n ref?: React.RefObject<HTMLButtonElement | HTMLAnchorElement | null>;\n}\n\nconst getIconColor = (\n fill: boolean,\n borderless: boolean,\n disabled: boolean,\n concept: ButtonConcept,\n ondark: boolean,\n mobile: boolean\n): string => {\n if (mobile && disabled) {\n return !ondark || fill ? getColor('neutral', !borderless ? 700 : 500) : getColor('white');\n }\n if (disabled) {\n return !ondark || fill ? getColor('neutral', 500) : `${getColor('white')}b3`;\n }\n if ((fill && !ondark) || (!fill && ondark)) {\n return 'white';\n }\n\n return concept === 'normal' ? getColor('blueberry', 600) : getColor('cherry', 500);\n};\nconst getLargeIconSize = (large: boolean, mobile: boolean): IconSize => {\n if (mobile && large) return IconSize.Small;\n if (large) return IconSize.Medium;\n return IconSize.XSmall;\n};\n\nconst checkOnlyIconAria = (onlyIcon: boolean, ariaLabel: string | undefined, devEnv: boolean): void => {\n if (devEnv && onlyIcon && (ariaLabel === undefined || ariaLabel === '')) {\n throw new Error('Fyll inn ariaLabel prop på Button uten tekst for å opprettholde UU krav');\n }\n};\n\nconst Button: React.FC<ButtonProps> = props => {\n const {\n ariaLabel,\n id,\n children,\n wrapperClassName,\n className,\n arrow,\n concept = 'normal',\n disabled = false,\n ellipsis = false,\n fluid = false,\n htmlMarkup = 'button',\n onColor = 'onlight',\n onBlur,\n onClick,\n size = 'medium',\n variant = 'fill',\n href,\n tabIndex,\n testId,\n target,\n type = 'button',\n textClassName,\n textPosition = 'left',\n ref,\n ...restProps\n } = props;\n const [leftIcon, rightIcon, restChildren] = useIcons(React.Children.toArray(children));\n const { refObject, isHovered } = usePseudoClasses<HTMLButtonElement | HTMLAnchorElement | null>(ref);\n const buttonContentRef = useRef<HTMLDivElement>(null);\n const onlyIcon = !!(leftIcon || rightIcon) && !restChildren;\n const bothIcons = leftIcon && (rightIcon || arrow) && !onlyIcon;\n const onDark = onColor === 'ondark';\n const isMobile = useIsMobileBreakpoint();\n const destructive = concept === 'destructive' && !disabled;\n const outlineVariant = variant === 'outline';\n const borderlessVariant = variant === 'borderless';\n const iconColor = getIconColor(variant === 'fill', borderlessVariant, disabled, concept, onDark, isMobile);\n const hasArrow = arrow === 'icon' && !borderlessVariant;\n const large = size === 'large' && !destructive && !borderlessVariant;\n const hasUURightArrow = arrow === 'accessibility-character' && !fluid && !leftIcon && !rightIcon && !hasArrow && borderlessVariant;\n const rest = { ...restProps };\n\n const buttonWrapperClasses = classNames(\n buttonStyles['button-wrapper'],\n { [buttonStyles['button-wrapper--fluid']]: fluid || ellipsis },\n wrapperClassName\n );\n const buttonClasses = classNames(\n buttonStyles.button,\n {\n [buttonStyles['button--destructive']]: destructive,\n [buttonStyles['button--normal']]: !large,\n [buttonStyles['button--large']]: large,\n [buttonStyles['button--outline']]: outlineVariant,\n [buttonStyles['button--borderless']]: borderlessVariant,\n [buttonStyles['button--left-icon']]: leftIcon && !onlyIcon,\n [buttonStyles['button--right-icon']]: rightIcon && !onlyIcon,\n [buttonStyles['button--both-icons']]: bothIcons,\n [buttonStyles['button--only-icon']]: onlyIcon,\n [buttonStyles['button--arrow']]: hasArrow,\n [buttonStyles['button--on-dark']]: onDark,\n },\n className\n );\n const buttonTextClasses = classNames(\n buttonStyles['button__text'],\n {\n [buttonStyles['button__text--ellipsis']]: ellipsis,\n [buttonStyles['button__text--centered']]: fluid && textPosition === 'centered',\n },\n textClassName\n );\n const diagonalClasses = classNames(buttonStyles['diagonal'], {\n [buttonStyles['diagonal--on-dark']]: onDark,\n });\n\n useEffect(() => {\n checkOnlyIconAria(onlyIcon, ariaLabel, !isTest() && !isProd());\n }, []);\n\n const renderIcon = (iconElement: BaseIconElement | null, iconSize: number, iconClassName?: string): BaseIconElement | null => {\n return iconElement\n ? React.cloneElement(iconElement, {\n size: iconSize,\n color: iconElement?.props.color && !disabled ? iconElement.props.color : iconColor,\n isHovered: iconElement.props.isHovered === undefined ? !disabled && isHovered : iconElement.props.isHovered,\n className: iconClassName,\n })\n : null;\n };\n\n const renderButtonContent = (): React.ReactNode => {\n return (\n <span className={buttonTextClasses} ref={buttonContentRef}>\n {disabled && borderlessVariant && (\n <span className={diagonalClasses}>\n <span className={buttonStyles['diagonal__line']} />\n </span>\n )}\n <span>{onlyIcon ? ariaLabel : restChildren}</span>\n </span>\n );\n };\n\n const renderbuttonContentWrapper = (): React.ReactNode => (\n <span className={buttonClasses}>\n {renderIcon(leftIcon, getLargeIconSize(large, isMobile), !onlyIcon ? buttonStyles['button__left-icon'] : undefined)}\n {renderButtonContent()}\n {hasArrow\n ? renderIcon(\n <Icon svgIcon={ArrowRight} />,\n getLargeIconSize(large, isMobile),\n classNames(buttonStyles['button__arrow'], { [buttonStyles['button__arrow--both-icons']]: bothIcons })\n )\n : renderIcon(rightIcon, getLargeIconSize(large, isMobile), buttonStyles['button__right-icon'])}\n {hasUURightArrow && (\n <span style={{ color: iconColor }} className={buttonStyles['button__right-unicode-arrow']} aria-hidden>\n {' →'}\n </span>\n )}\n </span>\n );\n\n return (\n <>\n {htmlMarkup === 'button' && (\n <button\n id={id}\n onBlur={onBlur}\n onClick={onClick}\n disabled={disabled}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Button}\n className={buttonWrapperClasses}\n ref={refObject as React.RefObject<HTMLButtonElement>}\n tabIndex={tabIndex}\n type={type}\n {...rest}\n >\n {renderbuttonContentWrapper()}\n </button>\n )}\n {htmlMarkup === 'a' && (\n <a\n id={id}\n onBlur={onBlur}\n onClick={onClick}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Button}\n className={buttonWrapperClasses}\n href={href}\n target={target}\n rel={target === '_blank' ? 'noopener noreferrer' : props.rel}\n ref={refObject as React.RefObject<HTMLAnchorElement>}\n tabIndex={tabIndex}\n {...restProps}\n >\n {renderbuttonContentWrapper()}\n </a>\n )}\n </>\n );\n};\n\nexport default Button;\n","import Button from './Button';\nexport * from './Button';\nexport default Button;\n"],"mappings":";;;;;;;;;;;;AAsEA,IAAM,gBACJ,MACA,YACA,UACA,SACA,QACA,WACW;AACX,KAAI,UAAU,SACZ,QAAO,CAAC,UAAU,OAAO,SAAS,WAAW,CAAC,aAAa,MAAM,IAAI,GAAG,SAAS,QAAQ;AAE3F,KAAI,SACF,QAAO,CAAC,UAAU,OAAO,SAAS,WAAW,IAAI,GAAG,GAAG,SAAS,QAAQ,CAAC;AAE3E,KAAK,QAAQ,CAAC,UAAY,CAAC,QAAQ,OACjC,QAAO;AAGT,QAAO,YAAY,WAAW,SAAS,aAAa,IAAI,GAAG,SAAS,UAAU,IAAI;;AAEpF,IAAM,oBAAoB,OAAgB,WAA8B;AACtE,KAAI,UAAU,MAAO,QAAO,SAAS;AACrC,KAAI,MAAO,QAAO,SAAS;AAC3B,QAAO,SAAS;;AAGlB,IAAM,qBAAqB,UAAmB,WAA+B,WAA0B;AACrG,KAAI,UAAU,aAAa,cAAc,KAAA,KAAa,cAAc,IAClE,OAAM,IAAI,MAAM,0EAA0E;;AAI9F,IAAMA,UAAgC,UAAS;CAC7C,MAAM,EACJ,WACA,IACA,UACA,kBACA,WACA,OACA,UAAU,UACV,WAAW,OACX,WAAW,OACX,QAAQ,OACR,aAAa,UACb,UAAU,WACV,QACA,SACA,OAAO,UACP,UAAU,QACV,MACA,UACA,QACA,QACA,OAAO,UACP,eACA,eAAe,QACf,KACA,GAAG,cACD;CACJ,MAAM,CAAC,UAAU,WAAW,gBAAgB,SAAS,MAAM,SAAS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,oBAAkB,YAAY;EAC9B,WAAW;EACL;EACE;EACR,KAAK,WAAW,WAAW,wBAAwB,MAAM;EACzD,KAAK;EACK;EACV,GAAI;YAEH,4BAA4B;GAC3B,CAAA,EAAA,CAEL;;ACtQP,IAAA,mBD0Qe"}
|
|
1
|
+
{"version":3,"file":"Button.js","names":["Button: React.FC<ButtonProps>"],"sources":["../src/components/Button/Button.tsx","../src/components/Button/index.ts"],"sourcesContent":["import React, { type AriaAttributes, useEffect, useRef } from 'react';\n\nimport classNames from 'classnames';\n\nimport Icon, { IconSize } from './../Icon';\nimport { type HTMLButtonProps, type HTMLAnchorProps, AnalyticsId } from '../../constants';\nimport { type BaseIconElement, useIcons } from '../../hooks/useIcons';\nimport { useIsMobileBreakpoint } from '../../hooks/useIsMobileBreakpoint';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { getColor } from '../../theme/currys/color';\nimport { isTest, isProd } from '../../utils/environment';\nimport ArrowRight from '../Icons/ArrowRight';\n\nimport buttonStyles from './styles.module.scss';\n\nexport type ButtonConcept = 'normal' | 'destructive';\nexport type ButtonVariant = 'fill' | 'outline' | 'borderless';\nexport type ButtonSize = 'medium' | 'large';\nexport type ButtonOnColor = 'onlight' | 'ondark';\nexport type ButtonTags = 'button' | 'a';\nexport type ButtonArrows = 'icon' | 'accessibility-character';\nexport type ButtonTextPosition = 'left' | 'centered';\n\nexport interface ButtonProps extends Omit<HTMLButtonProps, 'onClick' | 'type'>, Omit<HTMLAnchorProps, 'onClick'>, AriaAttributes {\n /** Sets the aria-label of the button, use when the button only includes an icon */\n ariaLabel?: string;\n /** Gives a unique id to the button */\n id?: string;\n /** Sets the content of the button. */\n children: React.ReactNode;\n /** Adds custom classes to the wrapper element. */\n wrapperClassName?: string;\n /** Adds custom classes to the element. */\n className?: string;\n /** Enables an arrow icon to the right inside the button (Not available in borderless variant) */\n arrow?: ButtonArrows;\n /** Changes the intent of the button. Mostly changes the color profile. */\n concept?: ButtonConcept;\n /** Disables text wrapping and enables ellipsis. */\n ellipsis?: boolean;\n /** Makes the button scale to full width of its parent element. */\n fluid?: boolean;\n /** Changes the underlying element of the button. */\n htmlMarkup?: ButtonTags;\n /** Changes the button colors for different backgrounds. */\n onColor?: ButtonOnColor;\n /** Function that is called when the Button loses focus */\n onBlur?: () => void;\n /** Function that is called when clicked */\n onClick?: (\n e?: React.MouseEvent<HTMLElement, MouseEvent> | React.FormEvent<unknown> | React.KeyboardEvent<HTMLUListElement> | null\n ) => void;\n /** Changes the button colors for different backgrounds. (Large not available in borderless variant) */\n size?: ButtonSize;\n /** Changes the visual representation of the button. */\n variant?: ButtonVariant;\n /** Specifies the focus order relative to the other buttons or controls on the page */\n tabIndex?: number;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Adds custom classes to the text */\n textClassName?: string;\n /** Sets the position of the text in the button - only applies when button is fluid */\n textPosition?: ButtonTextPosition;\n /** Button type. Default: button */\n type?: React.ButtonHTMLAttributes<HTMLButtonElement>['type'];\n /** Ref that is passed to the component */\n ref?: React.RefObject<HTMLButtonElement | HTMLAnchorElement | null>;\n}\n\nconst getIconColor = (\n fill: boolean,\n borderless: boolean,\n disabled: boolean,\n concept: ButtonConcept,\n ondark: boolean,\n mobile: boolean\n): string => {\n if (mobile && disabled) {\n return !ondark || fill ? getColor('neutral', !borderless ? 700 : 500) : getColor('white');\n }\n if (disabled) {\n return !ondark || fill ? getColor('neutral', 500) : `${getColor('white')}b3`;\n }\n if ((fill && !ondark) || (!fill && ondark)) {\n return 'white';\n }\n\n return concept === 'normal' ? getColor('blueberry', 600) : getColor('cherry', 500);\n};\nconst getLargeIconSize = (large: boolean, mobile: boolean): IconSize => {\n if (mobile && large) return IconSize.Small;\n if (large) return IconSize.Medium;\n return IconSize.XSmall;\n};\n\nconst checkOnlyIconAria = (onlyIcon: boolean, ariaLabel: string | undefined, devEnv: boolean): void => {\n if (devEnv && onlyIcon && (ariaLabel === undefined || ariaLabel === '')) {\n throw new Error('Fyll inn ariaLabel prop på Button uten tekst for å opprettholde UU krav');\n }\n};\n\nconst Button: React.FC<ButtonProps> = props => {\n const {\n ariaLabel,\n id,\n children,\n wrapperClassName,\n className,\n arrow,\n concept = 'normal',\n disabled = false,\n ellipsis = false,\n fluid = false,\n htmlMarkup = 'button',\n onColor = 'onlight',\n onBlur,\n onClick,\n size = 'medium',\n variant = 'fill',\n href,\n tabIndex,\n testId,\n target,\n type = 'button',\n textClassName,\n textPosition = 'left',\n ref,\n ...restProps\n } = props;\n const [leftIcon, rightIcon, restChildren] = useIcons(React.Children.toArray(children));\n const { refObject, isHovered } = usePseudoClasses<HTMLButtonElement | HTMLAnchorElement | null>(ref);\n const buttonContentRef = useRef<HTMLDivElement>(null);\n const onlyIcon = !!(leftIcon || rightIcon) && !restChildren;\n const bothIcons = leftIcon && (rightIcon || arrow) && !onlyIcon;\n const onDark = onColor === 'ondark';\n const isMobile = useIsMobileBreakpoint();\n const destructive = concept === 'destructive' && !disabled;\n const outlineVariant = variant === 'outline';\n const borderlessVariant = variant === 'borderless';\n const iconColor = getIconColor(variant === 'fill', borderlessVariant, disabled, concept, onDark, isMobile);\n const hasArrow = arrow === 'icon' && !borderlessVariant;\n const large = size === 'large' && !destructive && !borderlessVariant;\n const hasUURightArrow = arrow === 'accessibility-character' && !fluid && !leftIcon && !rightIcon && !hasArrow && borderlessVariant;\n const rest = { ...restProps };\n\n const buttonWrapperClasses = classNames(\n buttonStyles['button-wrapper'],\n { [buttonStyles['button-wrapper--fluid']]: fluid || ellipsis },\n wrapperClassName\n );\n const buttonClasses = classNames(\n buttonStyles.button,\n {\n [buttonStyles['button--destructive']]: destructive,\n [buttonStyles['button--normal']]: !large,\n [buttonStyles['button--large']]: large,\n [buttonStyles['button--outline']]: outlineVariant,\n [buttonStyles['button--borderless']]: borderlessVariant,\n [buttonStyles['button--left-icon']]: leftIcon && !onlyIcon,\n [buttonStyles['button--right-icon']]: rightIcon && !onlyIcon,\n [buttonStyles['button--both-icons']]: bothIcons,\n [buttonStyles['button--only-icon']]: onlyIcon,\n [buttonStyles['button--arrow']]: hasArrow,\n [buttonStyles['button--on-dark']]: onDark,\n },\n className\n );\n const buttonTextClasses = classNames(\n buttonStyles['button__text'],\n {\n [buttonStyles['button__text--ellipsis']]: ellipsis,\n [buttonStyles['button__text--centered']]: fluid && textPosition === 'centered',\n },\n textClassName\n );\n const diagonalClasses = classNames(buttonStyles['diagonal'], {\n [buttonStyles['diagonal--on-dark']]: onDark,\n });\n\n useEffect(() => {\n checkOnlyIconAria(onlyIcon, ariaLabel, !isTest() && !isProd());\n }, []);\n\n const renderIcon = (iconElement: BaseIconElement | null, iconSize: number, iconClassName?: string): BaseIconElement | null => {\n return iconElement\n ? React.cloneElement(iconElement, {\n size: iconSize,\n color: iconElement?.props.color && !disabled ? iconElement.props.color : iconColor,\n isHovered: iconElement.props.isHovered === undefined ? !disabled && isHovered : iconElement.props.isHovered,\n className: iconClassName,\n })\n : null;\n };\n\n const renderButtonContent = (): React.ReactNode => {\n return (\n <span className={buttonTextClasses} ref={buttonContentRef}>\n {disabled && borderlessVariant && (\n <span className={diagonalClasses}>\n <span className={buttonStyles['diagonal__line']} />\n </span>\n )}\n <span>{onlyIcon ? ariaLabel : restChildren}</span>\n </span>\n );\n };\n\n const renderbuttonContentWrapper = (): React.ReactNode => (\n <span className={buttonClasses}>\n {renderIcon(leftIcon, getLargeIconSize(large, isMobile), !onlyIcon ? buttonStyles['button__left-icon'] : undefined)}\n {renderButtonContent()}\n {hasArrow\n ? renderIcon(\n <Icon svgIcon={ArrowRight} />,\n getLargeIconSize(large, isMobile),\n classNames(buttonStyles['button__arrow'], { [buttonStyles['button__arrow--both-icons']]: bothIcons })\n )\n : renderIcon(rightIcon, getLargeIconSize(large, isMobile), buttonStyles['button__right-icon'])}\n {hasUURightArrow && (\n <span style={{ color: iconColor }} className={buttonStyles['button__right-unicode-arrow']} aria-hidden>\n {' →'}\n </span>\n )}\n </span>\n );\n\n return (\n <>\n {htmlMarkup === 'button' && (\n <button\n id={id}\n onBlur={onBlur}\n onClick={onClick}\n disabled={disabled}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Button}\n className={buttonWrapperClasses}\n ref={refObject as React.RefObject<HTMLButtonElement>}\n tabIndex={tabIndex}\n type={type}\n {...rest}\n >\n {renderbuttonContentWrapper()}\n </button>\n )}\n {htmlMarkup === 'a' && (\n <a\n id={id}\n onBlur={onBlur}\n onClick={onClick}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Button}\n className={buttonWrapperClasses}\n href={href}\n target={target}\n rel={target === '_blank' ? 'noopener noreferrer' : props.rel}\n ref={refObject as React.RefObject<HTMLAnchorElement>}\n tabIndex={tabIndex}\n {...restProps}\n >\n {renderbuttonContentWrapper()}\n </a>\n )}\n </>\n );\n};\n\nexport default Button;\n","import Button from './Button';\nexport * from './Button';\nexport default Button;\n"],"mappings":";;;;;;;;;;;;AAsEA,IAAM,gBACJ,MACA,YACA,UACA,SACA,QACA,WACW;AACX,KAAI,UAAU,SACZ,QAAO,CAAC,UAAU,OAAO,SAAS,WAAW,CAAC,aAAa,MAAM,IAAI,GAAG,SAAS,QAAQ;AAE3F,KAAI,SACF,QAAO,CAAC,UAAU,OAAO,SAAS,WAAW,IAAI,GAAG,GAAG,SAAS,QAAQ,CAAC;AAE3E,KAAK,QAAQ,CAAC,UAAY,CAAC,QAAQ,OACjC,QAAO;AAGT,QAAO,YAAY,WAAW,SAAS,aAAa,IAAI,GAAG,SAAS,UAAU,IAAI;;AAEpF,IAAM,oBAAoB,OAAgB,WAA8B;AACtE,KAAI,UAAU,MAAO,QAAO,SAAS;AACrC,KAAI,MAAO,QAAO,SAAS;AAC3B,QAAO,SAAS;;AAGlB,IAAM,qBAAqB,UAAmB,WAA+B,WAA0B;AACrG,KAAI,UAAU,aAAa,cAAc,KAAA,KAAa,cAAc,IAClE,OAAM,IAAI,MAAM,0EAA0E;;AAI9F,IAAMA,UAAgC,UAAS;CAC7C,MAAM,EACJ,WACA,IACA,UACA,kBACA,WACA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AAA,EAAA,UAAA,CACG,eAAe,YACd,oBAAC,UAAA;EACK;EACI;EACC;EACC;EACV,eAAa;EACb,oBAAkB,YAAY;EAC9B,WAAW;EACX,KAAK;EACK;EACJ;EACN,GAAI;YAEH,4BAA4B;GACtB,EAEV,eAAe,OACd,oBAAC,KAAA;EACK;EACI;EACC;EACT,eAAa;EACb,oBAAkB,YAAY;EAC9B,WAAW;EACL;EACE;EACR,KAAK,WAAW,WAAW,wBAAwB,MAAM;EACzD,KAAK;EACK;EACV,GAAI;YAEH,4BAA4B;GAC3B,CAAA,EAAA,CAEL;;ACtQP,IAAA,mBD0Qe"}
|
package/lib/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
## 14.0.0-beta.7 (2026-02-24)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* copyfiles script feiler ([939034a](https://github.com/helsenorge/designsystem/commit/939034a10788a3e06d96046c9fb8596c8b52144d)), closes [#372259](https://github.com/helsenorge/designsystem/issues/372259)
|
|
6
|
+
## 14.0.0-beta.6 (2026-02-24)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* diverse typecheck feil ([584cd1f](https://github.com/helsenorge/designsystem/commit/584cd1f862e26acf790ed00a547b34910bd13db0)), closes [#368142](https://github.com/helsenorge/designsystem/issues/368142)
|
|
11
|
+
## 14.0.0-beta.5 (2026-02-24)
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* **statusdot:** ny statusdot ready og nye navn på ikoner ([e6e5692](https://github.com/helsenorge/designsystem/commit/e6e569285789a20fcda822835aff5c169813a093)), closes [#369981](https://github.com/helsenorge/designsystem/issues/369981)
|
|
16
|
+
## 14.0.0-beta.4 (2026-02-10)
|
|
17
|
+
|
|
18
|
+
### Bug Fixes
|
|
19
|
+
|
|
20
|
+
* constants og utils fra komponenter skal eksporteres ([ae3e5af](https://github.com/helsenorge/designsystem/commit/ae3e5af25436b79b7b52cef5f78668742cecb356)), closes [#368469](https://github.com/helsenorge/designsystem/issues/368469) [#368806](https://github.com/helsenorge/designsystem/issues/368806)
|
|
1
21
|
## 14.0.0-beta.3 (2026-02-10)
|
|
2
22
|
|
|
3
23
|
### Features
|
|
@@ -18,7 +38,6 @@
|
|
|
18
38
|
* fjern støttefunksjoner for gamle ios-versjoner ([14cc9ff](https://github.com/helsenorge/designsystem/commit/14cc9ff50199b3e71c64a1fd81a0135350762a0d)), closes [#368687](https://github.com/helsenorge/designsystem/issues/368687)
|
|
19
39
|
* oppdatert til react 19 ([2333a1c](https://github.com/helsenorge/designsystem/commit/2333a1c55b9ea8571e4ec6a8a1d0c83c341b5381)), closes [#360074](https://github.com/helsenorge/designsystem/issues/360074) [#368806](https://github.com/helsenorge/designsystem/issues/368806)
|
|
20
40
|
* panelold og panellistold slettes ([dadd608](https://github.com/helsenorge/designsystem/commit/dadd6083282230117a473a3a13b3809ed5d831a1)), closes [#363596](https://github.com/helsenorge/designsystem/issues/363596)
|
|
21
|
-
* **datepicker:** ny komponent for input av tid ([592b6e4](https://github.com/helsenorge/designsystem/commit/592b6e4eabe9f718c142957a041084050e47c71f)), closes [#367381](https://github.com/helsenorge/designsystem/issues/367381)
|
|
22
41
|
* **helpdrawer:** fjern arialabel prop ([6d755e5](https://github.com/helsenorge/designsystem/commit/6d755e54013c8dded186a6b12022bb07d9995490))
|
|
23
42
|
|
|
24
43
|
### Bug Fixes
|
|
@@ -28,9 +47,46 @@
|
|
|
28
47
|
* fiks eslint feil ([446b850](https://github.com/helsenorge/designsystem/commit/446b850273dd1f4b748d1fa3af6084ae2eba2ae9))
|
|
29
48
|
* oppdater med react 19 endringer for nye komponenter ([14dc0d3](https://github.com/helsenorge/designsystem/commit/14dc0d3c427d60caef55af0b13bce9f76f05e1a3))
|
|
30
49
|
* ts feilmeldinger under bygg og runtime ([0688fb9](https://github.com/helsenorge/designsystem/commit/0688fb98634de41b75c3c172831634e6b57b2901)), closes [#368806](https://github.com/helsenorge/designsystem/issues/368806)
|
|
31
|
-
* **datepicker:** ikke sett default legend for ny datepicker ([f2230cb](https://github.com/helsenorge/designsystem/commit/f2230cbaff99f7e89320a8b10073c7420614d4ee)), closes [#345238](https://github.com/helsenorge/designsystem/issues/345238)
|
|
32
50
|
* **panel:** fiks feil import ([b952624](https://github.com/helsenorge/designsystem/commit/b952624923ef37e2f0b88efe659a8a0117c94201))
|
|
51
|
+
## [13.8.0](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv13.7.0&targetVersion=GTv13.8.0) (2026-02-24)
|
|
52
|
+
|
|
53
|
+
### Features
|
|
54
|
+
|
|
55
|
+
* **expanderhierarchy:** expander har fått ref prop ([74783f1](https://github.com/helsenorge/designsystem/commit/74783f17d93334b39d7c07f7b17ed8bb2b38340c)), closes [#371787](https://github.com/helsenorge/designsystem/issues/371787)
|
|
56
|
+
* **label:** flytt afterLabelChildren til topp og knyttet til hovedlabel ([c7db421](https://github.com/helsenorge/designsystem/commit/c7db421b5196399c8d976567071e97056e92d286)), closes [#366134](https://github.com/helsenorge/designsystem/issues/366134)
|
|
57
|
+
|
|
58
|
+
### Bug Fixes
|
|
59
|
+
|
|
60
|
+
* **helptriggericon:** bruk riktig svg for str xl på desktop og mobil ([d51ce49](https://github.com/helsenorge/designsystem/commit/d51ce49ae6e6b159bcb34e3f864e72fd5c027ded)), closes [#371659](https://github.com/helsenorge/designsystem/issues/371659)
|
|
61
|
+
## [13.7.0](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv13.6.0&targetVersion=GTv13.7.0) (2026-02-16)
|
|
62
|
+
|
|
63
|
+
### Features
|
|
64
|
+
|
|
65
|
+
* **lightbox:** lagt til språkhåndtering ([db207d6](https://github.com/helsenorge/designsystem/commit/db207d67b23816235e588f6bf82436799e6a39f4)), closes [#365604](https://github.com/helsenorge/designsystem/issues/365604)
|
|
66
|
+
|
|
67
|
+
### Bug Fixes
|
|
68
|
+
|
|
69
|
+
* **uselementlist:** ekstra sjekk for å hindre mange rerenders av komponent ([3cbfcca](https://github.com/helsenorge/designsystem/commit/3cbfcca5569bf4cd308d4dd021a5e1726f21f58d)), closes [#367282](https://github.com/helsenorge/designsystem/issues/367282)
|
|
70
|
+
## [13.6.0](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv13.5.0&targetVersion=GTv13.6.0) (2026-02-11)
|
|
71
|
+
|
|
72
|
+
### Features
|
|
73
|
+
|
|
74
|
+
* oppdatert til motion 12 ([af5eb81](https://github.com/helsenorge/designsystem/commit/af5eb8141c74b5b1179f90b838606ae6d41b751d)), closes [#371272](https://github.com/helsenorge/designsystem/issues/371272)
|
|
75
|
+
* **datepicker:** ny komponent for input av tid ([592b6e4](https://github.com/helsenorge/designsystem/commit/592b6e4eabe9f718c142957a041084050e47c71f)), closes [#367381](https://github.com/helsenorge/designsystem/issues/367381)
|
|
76
|
+
* **duolist:** lagt til prop for testid på hver duolistgroup ([004ae83](https://github.com/helsenorge/designsystem/commit/004ae83bdfaa5ba47b70d07c4337d9238d06b774)), closes [#370261](https://github.com/helsenorge/designsystem/issues/370261)
|
|
77
|
+
* **formgroup:** åpne for flere tags for legend og title ([0cbc280](https://github.com/helsenorge/designsystem/commit/0cbc2801b654d8adaa4f610452dfd5043900e53f)), closes [#368142](https://github.com/helsenorge/designsystem/issues/368142)
|
|
78
|
+
* **infoteaser:** legg til prop for å sette høyde på collapsed teaser ([3681d3f](https://github.com/helsenorge/designsystem/commit/3681d3f7ebd16aacf9b4114b48ba7fd0d2ee1e29))
|
|
79
|
+
|
|
80
|
+
### Bug Fixes
|
|
81
|
+
|
|
82
|
+
* **datepicker:** ikke sett default legend for ny datepicker ([f2230cb](https://github.com/helsenorge/designsystem/commit/f2230cbaff99f7e89320a8b10073c7420614d4ee)), closes [#345238](https://github.com/helsenorge/designsystem/issues/345238)
|
|
83
|
+
* **drawer:** legg på padding så ikke footer-knapper kuttes på iphone ([3616eff](https://github.com/helsenorge/designsystem/commit/3616eff6cfa040ef5d814458978f5dc7f023d470)), closes [#369303](https://github.com/helsenorge/designsystem/issues/369303)
|
|
84
|
+
* **expander:** behold bredde på innhold på desktop ([8ab0315](https://github.com/helsenorge/designsystem/commit/8ab03150ede607ace77d40dc89865f0b0e574858)), closes [#361764](https://github.com/helsenorge/designsystem/issues/361764)
|
|
33
85
|
* **panellist:** gjør panellist sin styling av panel mer robust ([b1c28dc](https://github.com/helsenorge/designsystem/commit/b1c28dc6f31ec44a64e022da653a880347d7a530)), closes [#369909](https://github.com/helsenorge/designsystem/issues/369909)
|
|
86
|
+
* **select:** skjul overflow tekst og vis ellipsis ([a56be99](https://github.com/helsenorge/designsystem/commit/a56be9933ae7dbd6d03441f94384e1b6dd3f69e1)), closes [#370560](https://github.com/helsenorge/designsystem/issues/370560)
|
|
87
|
+
* **toggle:** ariadescribedby settes til undefined ([c6b8e64](https://github.com/helsenorge/designsystem/commit/c6b8e6417e96091b087eb7af7892e54733e5a8a0)), closes [#370572](https://github.com/helsenorge/designsystem/issues/370572)
|
|
88
|
+
* **unsafe_datepicker:** ikke sett aria-controls om popup er lukket ([79349e8](https://github.com/helsenorge/designsystem/commit/79349e8d93018d3274a8af2ae5d8ed201f738601)), closes [#371062](https://github.com/helsenorge/designsystem/issues/371062)
|
|
89
|
+
* **unsafe_datepicker:** lukk kalender med escape på kalender knapp og fjern manglende IDer ([c7d2b09](https://github.com/helsenorge/designsystem/commit/c7d2b09df068719ad3f9ce7be8e54653a5691fae)), closes [#371061](https://github.com/helsenorge/designsystem/issues/371061) [#371062](https://github.com/helsenorge/designsystem/issues/371062)
|
|
34
90
|
## [13.5.0](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv13.4.0&targetVersion=GTv13.5.0) (2026-01-21)
|
|
35
91
|
|
|
36
92
|
### Features
|
package/lib/Checkbox.js
CHANGED
|
@@ -9,7 +9,7 @@ import { t as useIdWithFallback } from "./useIdWithFallback.js";
|
|
|
9
9
|
import { t as getAriaDescribedBy } from "./accessibility.js";
|
|
10
10
|
import { t as ErrorWrapper_default } from "./ErrorWrapper.js";
|
|
11
11
|
import { r as renderLabelAsParent, t as getLabelText } from "./utils2.js";
|
|
12
|
-
import
|
|
12
|
+
import cn from "classnames";
|
|
13
13
|
import { useEffect, useState } from "react";
|
|
14
14
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
15
15
|
import checkboxStyles from "./components/Checkbox/styles.module.scss";
|
|
@@ -25,8 +25,8 @@ const Checkbox = (props) => {
|
|
|
25
25
|
const large = size === FormSize.large;
|
|
26
26
|
const { refObject, isFocused } = usePseudoClasses(isMutableRefObject(ref) ? ref : null);
|
|
27
27
|
const mergedRefs = mergeRefs([ref, refObject]);
|
|
28
|
-
const checkboxWrapperClasses =
|
|
29
|
-
const checkboxLabelClasses =
|
|
28
|
+
const checkboxWrapperClasses = cn(checkboxStyles["checkbox-wrapper"], { [checkboxStyles["checkbox-wrapper--large"]]: large });
|
|
29
|
+
const checkboxLabelClasses = cn(checkboxStyles["checkbox-label"], {
|
|
30
30
|
[checkboxStyles["checkbox-label--disabled"]]: disabled,
|
|
31
31
|
[checkboxStyles["checkbox-label--on-dark"]]: onDark,
|
|
32
32
|
[checkboxStyles["checkbox-label--large"]]: large,
|
|
@@ -38,8 +38,8 @@ const Checkbox = (props) => {
|
|
|
38
38
|
[checkboxStyles["checkbox-label__large--on-invalid"]]: large && onInvalid,
|
|
39
39
|
[checkboxStyles["checkbox-label__large--disabled"]]: large && disabled
|
|
40
40
|
});
|
|
41
|
-
const checkboxClasses =
|
|
42
|
-
const checkboxIconWrapperClasses =
|
|
41
|
+
const checkboxClasses = cn(checkboxStyles.checkbox, className);
|
|
42
|
+
const checkboxIconWrapperClasses = cn(checkboxStyles["checkbox__icon-wrapper"], {
|
|
43
43
|
[checkboxStyles["checkbox__icon-wrapper--on-white"]]: onWhite,
|
|
44
44
|
[checkboxStyles["checkbox__icon-wrapper--on-grey"]]: onGrey,
|
|
45
45
|
[checkboxStyles["checkbox__icon-wrapper--on-invalid"]]: onInvalid,
|
|
@@ -57,7 +57,7 @@ const Checkbox = (props) => {
|
|
|
57
57
|
[checkboxStyles["checkbox__icon-wrapper__large--checked--invalid"]]: large && isChecked && onInvalid,
|
|
58
58
|
[checkboxStyles["checkbox__icon-wrapper__large--checked--disabled"]]: disabled && large && isChecked
|
|
59
59
|
});
|
|
60
|
-
const labelTextClasses =
|
|
60
|
+
const labelTextClasses = cn(checkboxStyles["checkbox-label__text"], {
|
|
61
61
|
[checkboxStyles["checkbox-label__text__large--checked"]]: large && isChecked,
|
|
62
62
|
[checkboxStyles["checkbox-label__text__large--invalid"]]: large && isChecked && onInvalid,
|
|
63
63
|
[checkboxStyles["checkbox-label__text--on-dark"]]: onDark,
|
|
@@ -106,7 +106,17 @@ const Checkbox = (props) => {
|
|
|
106
106
|
"data-testid": testId,
|
|
107
107
|
"data-analyticsid": AnalyticsId.Checkbox,
|
|
108
108
|
className: checkboxWrapperClasses,
|
|
109
|
-
children: renderLabelAsParent(
|
|
109
|
+
children: renderLabelAsParent({
|
|
110
|
+
label,
|
|
111
|
+
children: getLabelContent(),
|
|
112
|
+
inputId,
|
|
113
|
+
onColor,
|
|
114
|
+
labelClassName: checkboxLabelClasses,
|
|
115
|
+
labelTextClassName: labelTextClasses,
|
|
116
|
+
sublabelWrapperClassName: checkboxStyles["checkbox-sublabel-wrapper"],
|
|
117
|
+
large,
|
|
118
|
+
afterLabelChildrenClassName: checkboxStyles["checkbox-afterlabelchildren-wrapper"]
|
|
119
|
+
})
|
|
110
120
|
})
|
|
111
121
|
});
|
|
112
122
|
};
|
package/lib/Checkbox.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkbox.js","names":["Checkbox: React.FC<CheckboxProps>"],"sources":["../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport type { ErrorWrapperClassNameProps } from '../ErrorWrapper';\n\nimport { AnalyticsId, FormOnColor, FormSize, IconSize } from '../../constants';\nimport { useIdWithFallback } from '../../hooks/useIdWithFallback';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { getColor } from '../../theme/currys/color';\nimport { getAriaDescribedBy } from '../../utils/accessibility';\nimport { isMutableRefObject, mergeRefs } from '../../utils/refs';\nimport { uuid } from '../../utils/uuid';\nimport ErrorWrapper from '../ErrorWrapper';\nimport Icon from '../Icon';\nimport Check from '../Icons/Check';\nimport { getLabelText, renderLabelAsParent } from '../Label/utils';\n\nimport checkboxStyles from './styles.module.scss';\n\nexport interface CheckboxProps\n extends\n ErrorWrapperClassNameProps,\n Pick<\n React.InputHTMLAttributes<HTMLInputElement>,\n 'aria-describedby' | 'name' | 'value' | 'disabled' | 'checked' | 'required' | 'onChange'\n > {\n /** Adds custom classes to the element. */\n className?: string;\n /** The <Label/> next to the checkbox - sublabels kan ikke kombineres med large variant */\n label: React.ReactNode;\n /** input id of the checkbox */\n inputId?: string;\n /** Changes the visuals of the checkbox */\n onColor?: keyof typeof FormOnColor;\n /** Changes the visuals of the checkbox */\n size?: keyof typeof FormSize;\n /** Activates Error style for the checkbox - This is can be true while errorText is empty, when in a FormGroup */\n error?: boolean;\n /** Error text to show above the component */\n errorText?: string;\n /** Error text id */\n errorTextId?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Ref that is passed to the component */\n ref?: React.Ref<HTMLInputElement | null>;\n}\n\nexport const Checkbox: React.FC<CheckboxProps> = props => {\n const {\n className,\n checked = false,\n disabled,\n label,\n inputId = uuid(),\n onColor = FormOnColor.onwhite,\n name = inputId,\n size,\n errorText,\n error = !!errorText,\n errorTextId: errorTextIdProp,\n errorWrapperClassName,\n value = getLabelText(label),\n testId,\n required,\n onChange,\n ref,\n } = props;\n const [isChecked, setIsChecked] = useState(checked);\n const errorTextId = useIdWithFallback(errorTextIdProp);\n const onWhite = onColor === FormOnColor.onwhite;\n const onGrey = onColor === FormOnColor.ongrey;\n const onBlueberry = onColor === FormOnColor.onblueberry;\n const onInvalid = error || onColor === FormOnColor.oninvalid;\n const onDark = onColor === FormOnColor.ondark;\n const large = size === FormSize.large;\n const { refObject, isFocused } = usePseudoClasses<HTMLInputElement>(isMutableRefObject(ref) ? ref : null);\n const mergedRefs = mergeRefs([ref, refObject]);\n\n const checkboxWrapperClasses = classNames(checkboxStyles['checkbox-wrapper'], {\n [checkboxStyles['checkbox-wrapper--large']]: large,\n });\n const checkboxLabelClasses = classNames(checkboxStyles['checkbox-label'], {\n [checkboxStyles['checkbox-label--disabled']]: disabled,\n [checkboxStyles['checkbox-label--on-dark']]: onDark,\n [checkboxStyles['checkbox-label--large']]: large,\n [checkboxStyles['checkbox-label__large--checked']]: large && isChecked,\n [checkboxStyles['checkbox-label__large--focus']]: large && isFocused,\n [checkboxStyles['checkbox-label__large--on-white']]: large && onWhite,\n [checkboxStyles['checkbox-label__large--on-grey']]: large && onGrey,\n [checkboxStyles['checkbox-label__large--on-blueberry']]: large && onBlueberry,\n [checkboxStyles['checkbox-label__large--on-invalid']]: large && onInvalid,\n [checkboxStyles['checkbox-label__large--disabled']]: large && disabled,\n });\n const checkboxClasses = classNames(checkboxStyles.checkbox, className);\n const checkboxIconWrapperClasses = classNames(checkboxStyles['checkbox__icon-wrapper'], {\n [checkboxStyles['checkbox__icon-wrapper--on-white']]: onWhite,\n [checkboxStyles['checkbox__icon-wrapper--on-grey']]: onGrey,\n [checkboxStyles['checkbox__icon-wrapper--on-invalid']]: onInvalid,\n [checkboxStyles['checkbox__icon-wrapper--disabled']]: disabled,\n [checkboxStyles['checkbox__icon-wrapper__regular--checked']]: !large && isChecked,\n [checkboxStyles['checkbox__icon-wrapper__regular--invalid']]: !large && isChecked && onInvalid,\n [checkboxStyles['checkbox__icon-wrapper__regular--on-dark']]: !large && isChecked && onDark,\n [checkboxStyles['checkbox__icon-wrapper__large--checked']]: large && isChecked,\n [checkboxStyles['checkbox__icon-wrapper__large--invalid']]: large && onInvalid,\n [checkboxStyles['checkbox__icon-wrapper--on-dark']]: onDark,\n [checkboxStyles['checkbox__icon-wrapper--on-blueberry']]: onBlueberry,\n [checkboxStyles['checkbox__icon-wrapper--invalid']]: onInvalid,\n [checkboxStyles['checkbox__icon-wrapper__large--invalid']]: large && isChecked && onInvalid,\n [checkboxStyles['checkbox__icon-wrapper__large--disabled']]: disabled && large && isChecked,\n [checkboxStyles['checkbox__icon-wrapper__large--checked--invalid']]: large && isChecked && onInvalid,\n [checkboxStyles['checkbox__icon-wrapper__large--checked--disabled']]: disabled && large && isChecked,\n });\n const labelTextClasses = classNames(checkboxStyles['checkbox-label__text'], {\n [checkboxStyles['checkbox-label__text__large--checked']]: large && isChecked,\n [checkboxStyles['checkbox-label__text__large--invalid']]: large && isChecked && onInvalid,\n [checkboxStyles['checkbox-label__text--on-dark']]: onDark,\n [checkboxStyles['checkbox-label__text--disabled']]: disabled,\n });\n\n let iconColor = getColor('white');\n if (onDark || (large && isChecked)) iconColor = getColor('blueberry', 900);\n if (onInvalid && large && isChecked) iconColor = getColor('white');\n if (disabled) iconColor = getColor('neutral', 700);\n\n useEffect(() => {\n setIsChecked(checked);\n }, [checked]);\n\n const onChangeHandler = (e: React.ChangeEvent<HTMLInputElement>): void => {\n if (onChange) {\n onChange(e);\n }\n\n setIsChecked(!isChecked);\n };\n\n const getLabelContent = (): React.ReactNode => {\n return (\n <>\n <input\n id={inputId}\n name={name}\n className={checkboxClasses}\n type=\"checkbox\"\n checked={isChecked}\n disabled={disabled}\n value={value}\n ref={mergedRefs}\n aria-describedby={getAriaDescribedBy(props, errorTextId)}\n aria-invalid={error}\n required={required}\n onChange={onChangeHandler}\n />\n <span className={checkboxIconWrapperClasses}>\n {isChecked && <Icon color={iconColor} className={checkboxStyles['checkbox__icon']} svgIcon={Check} size={IconSize.XSmall} />}\n </span>\n </>\n );\n };\n\n return (\n <ErrorWrapper className={errorWrapperClassName} errorText={errorText} errorTextId={errorTextId}>\n <div data-testid={testId} data-analyticsid={AnalyticsId.Checkbox} className={checkboxWrapperClasses}>\n {renderLabelAsParent(\n label,\n getLabelContent(),\n inputId,\n onColor as FormOnColor,\n checkboxLabelClasses,\n labelTextClasses,\n checkboxStyles['checkbox-sublabel-wrapper'],\n large\n )}\n </div>\n </ErrorWrapper>\n );\n};\n\nexport default Checkbox;\n"],"mappings":";;;;;;;;;;;;;;;AAiDA,MAAaA,YAAoC,UAAS;CACxD,MAAM,EACJ,WACA,UAAU,OACV,UACA,OACA,UAAU,MAAM,EAChB,UAAU,YAAY,SACtB,OAAO,SACP,MACA,WACA,QAAQ,CAAC,CAAC,WACV,aAAa,iBACb,uBACA,QAAQ,aAAa,MAAM,EAC3B,QACA,UACA,UACA,QACE;CACJ,MAAM,CAAC,WAAW,gBAAgB,SAAS,QAAQ;CACnD,MAAM,cAAc,kBAAkB,gBAAgB;CACtD,MAAM,UAAU,YAAY,YAAY;CACxC,MAAM,SAAS,YAAY,YAAY;CACvC,MAAM,cAAc,YAAY,YAAY;CAC5C,MAAM,YAAY,SAAS,YAAY,YAAY;CACnD,MAAM,SAAS,YAAY,YAAY;CACvC,MAAM,QAAQ,SAAS,SAAS;CAChC,MAAM,EAAE,WAAW,cAAc,iBAAmC,mBAAmB,IAAI,GAAG,MAAM,KAAK;CACzG,MAAM,aAAa,UAAU,CAAC,KAAK,UAAU,CAAC;CAE9C,MAAM,yBAAyB,WAAW,eAAe,qBAAqB,GAC3E,eAAe,6BAA6B,OAC9C,CAAC;CACF,MAAM,uBAAuB,WAAW,eAAe,mBAAmB;GACvE,eAAe,8BAA8B;GAC7C,eAAe,6BAA6B;GAC5C,eAAe,2BAA2B;GAC1C,eAAe,oCAAoC,SAAS;GAC5D,eAAe,kCAAkC,SAAS;GAC1D,eAAe,qCAAqC,SAAS;GAC7D,eAAe,oCAAoC,SAAS;GAC5D,eAAe,yCAAyC,SAAS;GACjE,eAAe,uCAAuC,SAAS;GAC/D,eAAe,qCAAqC,SAAS;EAC/D,CAAC;CACF,MAAM,kBAAk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aACd,aAAa,oBAAC,cAAA;IAAK,OAAO;IAAW,WAAW,eAAe;IAAmB,SAAS;IAAO,MAAM,SAAS;KAAU;IACvH,CAAA,EAAA,CACN;;AAIP,QACE,oBAAC,sBAAA;EAAa,WAAW;EAAkC;EAAwB;YACjF,oBAAC,OAAA;GAAI,eAAa;GAAQ,oBAAkB,YAAY;GAAU,WAAW;aAC1E,oBACC,OACA,iBAAiB,EACjB,SACA,SACA,sBACA,kBACA,eAAe,8BACf,MACD;IACG;GACO;;AAInB,IAAA,mBAAe"}
|
|
1
|
+
{"version":3,"file":"Checkbox.js","names":["Checkbox: React.FC<CheckboxProps>"],"sources":["../src/components/Checkbox/Checkbox.tsx"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport type { ErrorWrapperClassNameProps } from '../ErrorWrapper';\n\nimport { AnalyticsId, FormOnColor, FormSize, IconSize } from '../../constants';\nimport { useIdWithFallback } from '../../hooks/useIdWithFallback';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { getColor } from '../../theme/currys/color';\nimport { getAriaDescribedBy } from '../../utils/accessibility';\nimport { isMutableRefObject, mergeRefs } from '../../utils/refs';\nimport { uuid } from '../../utils/uuid';\nimport ErrorWrapper from '../ErrorWrapper';\nimport Icon from '../Icon';\nimport Check from '../Icons/Check';\nimport { getLabelText, renderLabelAsParent } from '../Label/utils';\n\nimport checkboxStyles from './styles.module.scss';\n\nexport interface CheckboxProps\n extends\n ErrorWrapperClassNameProps,\n Pick<\n React.InputHTMLAttributes<HTMLInputElement>,\n 'aria-describedby' | 'name' | 'value' | 'disabled' | 'checked' | 'required' | 'onChange'\n > {\n /** Adds custom classes to the element. */\n className?: string;\n /** The <Label/> next to the checkbox - sublabels kan ikke kombineres med large variant */\n label: React.ReactNode;\n /** input id of the checkbox */\n inputId?: string;\n /** Changes the visuals of the checkbox */\n onColor?: keyof typeof FormOnColor;\n /** Changes the visuals of the checkbox */\n size?: keyof typeof FormSize;\n /** Activates Error style for the checkbox - This is can be true while errorText is empty, when in a FormGroup */\n error?: boolean;\n /** Error text to show above the component */\n errorText?: string;\n /** Error text id */\n errorTextId?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Ref that is passed to the component */\n ref?: React.Ref<HTMLInputElement | null>;\n}\n\nexport const Checkbox: React.FC<CheckboxProps> = props => {\n const {\n className,\n checked = false,\n disabled,\n label,\n inputId = uuid(),\n onColor = FormOnColor.onwhite,\n name = inputId,\n size,\n errorText,\n error = !!errorText,\n errorTextId: errorTextIdProp,\n errorWrapperClassName,\n value = getLabelText(label),\n testId,\n required,\n onChange,\n ref,\n } = props;\n const [isChecked, setIsChecked] = useState(checked);\n const errorTextId = useIdWithFallback(errorTextIdProp);\n const onWhite = onColor === FormOnColor.onwhite;\n const onGrey = onColor === FormOnColor.ongrey;\n const onBlueberry = onColor === FormOnColor.onblueberry;\n const onInvalid = error || onColor === FormOnColor.oninvalid;\n const onDark = onColor === FormOnColor.ondark;\n const large = size === FormSize.large;\n const { refObject, isFocused } = usePseudoClasses<HTMLInputElement>(isMutableRefObject(ref) ? ref : null);\n const mergedRefs = mergeRefs([ref, refObject]);\n\n const checkboxWrapperClasses = classNames(checkboxStyles['checkbox-wrapper'], {\n [checkboxStyles['checkbox-wrapper--large']]: large,\n });\n const checkboxLabelClasses = classNames(checkboxStyles['checkbox-label'], {\n [checkboxStyles['checkbox-label--disabled']]: disabled,\n [checkboxStyles['checkbox-label--on-dark']]: onDark,\n [checkboxStyles['checkbox-label--large']]: large,\n [checkboxStyles['checkbox-label__large--checked']]: large && isChecked,\n [checkboxStyles['checkbox-label__large--focus']]: large && isFocused,\n [checkboxStyles['checkbox-label__large--on-white']]: large && onWhite,\n [checkboxStyles['checkbox-label__large--on-grey']]: large && onGrey,\n [checkboxStyles['checkbox-label__large--on-blueberry']]: large && onBlueberry,\n [checkboxStyles['checkbox-label__large--on-invalid']]: large && onInvalid,\n [checkboxStyles['checkbox-label__large--disabled']]: large && disabled,\n });\n const checkboxClasses = classNames(checkboxStyles.checkbox, className);\n const checkboxIconWrapperClasses = classNames(checkboxStyles['checkbox__icon-wrapper'], {\n [checkboxStyles['checkbox__icon-wrapper--on-white']]: onWhite,\n [checkboxStyles['checkbox__icon-wrapper--on-grey']]: onGrey,\n [checkboxStyles['checkbox__icon-wrapper--on-invalid']]: onInvalid,\n [checkboxStyles['checkbox__icon-wrapper--disabled']]: disabled,\n [checkboxStyles['checkbox__icon-wrapper__regular--checked']]: !large && isChecked,\n [checkboxStyles['checkbox__icon-wrapper__regular--invalid']]: !large && isChecked && onInvalid,\n [checkboxStyles['checkbox__icon-wrapper__regular--on-dark']]: !large && isChecked && onDark,\n [checkboxStyles['checkbox__icon-wrapper__large--checked']]: large && isChecked,\n [checkboxStyles['checkbox__icon-wrapper__large--invalid']]: large && onInvalid,\n [checkboxStyles['checkbox__icon-wrapper--on-dark']]: onDark,\n [checkboxStyles['checkbox__icon-wrapper--on-blueberry']]: onBlueberry,\n [checkboxStyles['checkbox__icon-wrapper--invalid']]: onInvalid,\n [checkboxStyles['checkbox__icon-wrapper__large--invalid']]: large && isChecked && onInvalid,\n [checkboxStyles['checkbox__icon-wrapper__large--disabled']]: disabled && large && isChecked,\n [checkboxStyles['checkbox__icon-wrapper__large--checked--invalid']]: large && isChecked && onInvalid,\n [checkboxStyles['checkbox__icon-wrapper__large--checked--disabled']]: disabled && large && isChecked,\n });\n const labelTextClasses = classNames(checkboxStyles['checkbox-label__text'], {\n [checkboxStyles['checkbox-label__text__large--checked']]: large && isChecked,\n [checkboxStyles['checkbox-label__text__large--invalid']]: large && isChecked && onInvalid,\n [checkboxStyles['checkbox-label__text--on-dark']]: onDark,\n [checkboxStyles['checkbox-label__text--disabled']]: disabled,\n });\n\n let iconColor = getColor('white');\n if (onDark || (large && isChecked)) iconColor = getColor('blueberry', 900);\n if (onInvalid && large && isChecked) iconColor = getColor('white');\n if (disabled) iconColor = getColor('neutral', 700);\n\n useEffect(() => {\n setIsChecked(checked);\n }, [checked]);\n\n const onChangeHandler = (e: React.ChangeEvent<HTMLInputElement>): void => {\n if (onChange) {\n onChange(e);\n }\n\n setIsChecked(!isChecked);\n };\n\n const getLabelContent = (): React.ReactNode => {\n return (\n <>\n <input\n id={inputId}\n name={name}\n className={checkboxClasses}\n type=\"checkbox\"\n checked={isChecked}\n disabled={disabled}\n value={value}\n ref={mergedRefs}\n aria-describedby={getAriaDescribedBy(props, errorTextId)}\n aria-invalid={error}\n required={required}\n onChange={onChangeHandler}\n />\n <span className={checkboxIconWrapperClasses}>\n {isChecked && <Icon color={iconColor} className={checkboxStyles['checkbox__icon']} svgIcon={Check} size={IconSize.XSmall} />}\n </span>\n </>\n );\n };\n\n return (\n <ErrorWrapper className={errorWrapperClassName} errorText={errorText} errorTextId={errorTextId}>\n <div data-testid={testId} data-analyticsid={AnalyticsId.Checkbox} className={checkboxWrapperClasses}>\n {renderLabelAsParent({\n label: label,\n children: getLabelContent(),\n inputId: inputId,\n onColor: onColor as FormOnColor,\n labelClassName: checkboxLabelClasses,\n labelTextClassName: labelTextClasses,\n sublabelWrapperClassName: checkboxStyles['checkbox-sublabel-wrapper'],\n large: large,\n afterLabelChildrenClassName: checkboxStyles['checkbox-afterlabelchildren-wrapper'],\n })}\n </div>\n </ErrorWrapper>\n );\n};\n\nexport default Checkbox;\n"],"mappings":";;;;;;;;;;;;;;;AAiDA,MAAaA,YAAoC,UAAS;CACxD,MAAM,EACJ,WACA,UAAU,OACV,UACA,OACA,UAAU,MAAM,EAChB,UAAU,YAAY,SACtB,OAAO,SACP,MACA,WACA,QAAQ,CAAC,CAAC,WACV,aAAa,iBACb,uBACA,QAAQ,aAAa,MAAM,EAC3B,QACA,UACA,UACA,QACE;CACJ,MAAM,CAAC,WAAW,gBAAgB,SAAS,QAAQ;CACnD,MAAM,cAAc,kBAAkB,gBAAgB;CACtD,MAAM,UAAU,YAAY,YAAY;CACxC,MAAM,SAAS,YAAY,YAAY;CACvC,MAAM,cAAc,YAAY,Y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AS,aAAa;GAC/E,eAAe,mCAAmC;GAClD,eAAe,oCAAoC;EACrD,CAAC;CAEF,IAAI,YAAY,SAAS,QAAQ;AACjC,KAAI,UAAW,SAAS,UAAY,aAAY,SAAS,aAAa,IAAI;AAC1E,KAAI,aAAa,SAAS,UAAW,aAAY,SAAS,QAAQ;AAClE,KAAI,SAAU,aAAY,SAAS,WAAW,IAAI;AAElD,iBAAgB;AACd,eAAa,QAAQ;IACpB,CAAC,QAAQ,CAAC;CAEb,MAAM,mBAAmB,MAAiD;AACxE,MAAI,SACF,UAAS,EAAE;AAGb,eAAa,CAAC,UAAU;;CAG1B,MAAM,wBAAyC;AAC7C,SACE,qBAAA,UAAA,EAAA,UAAA,CACE,oBAAC,SAAA;GACC,IAAI;GACE;GACN,WAAW;GACX,MAAK;GACL,SAAS;GACC;GACH;GACP,KAAK;GACL,oBAAkB,mBAAmB,OAAO,YAAY;GACxD,gBAAc;GACJ;GACV,UAAU;IACV,EACF,oBAAC,QAAA;GAAK,WAAW;aACd,aAAa,oBAAC,cAAA;IAAK,OAAO;IAAW,WAAW,eAAe;IAAmB,SAAS;IAAO,MAAM,SAAS;KAAU;IACvH,CAAA,EAAA,CACN;;AAIP,QACE,oBAAC,sBAAA;EAAa,WAAW;EAAkC;EAAwB;YACjF,oBAAC,OAAA;GAAI,eAAa;GAAQ,oBAAkB,YAAY;GAAU,WAAW;aAC1E,oBAAoB;IACZ;IACP,UAAU,iBAAiB;IAClB;IACA;IACT,gBAAgB;IAChB,oBAAoB;IACpB,0BAA0B,eAAe;IAClC;IACP,6BAA6B,eAAe;IAC7C,CAAC;IACE;GACO;;AAInB,IAAA,mBAAe"}
|
package/lib/ChildMedium.js
CHANGED
package/lib/Close.js
CHANGED
|
@@ -4,7 +4,7 @@ import { n as mergeRefs } from "./refs.js";
|
|
|
4
4
|
import { t as Icon_default } from "./Icon.js";
|
|
5
5
|
import { t as useIsMobileBreakpoint } from "./useIsMobileBreakpoint.js";
|
|
6
6
|
import { t as X_default } from "./X.js";
|
|
7
|
-
import
|
|
7
|
+
import cn from "classnames";
|
|
8
8
|
import { jsx } from "react/jsx-runtime";
|
|
9
9
|
import styles from "./components/Close/styles.module.scss";
|
|
10
10
|
var Close = (props) => {
|
|
@@ -15,7 +15,7 @@ var Close = (props) => {
|
|
|
15
15
|
if (color === "black") iconColor = "black";
|
|
16
16
|
else if (color === "plum") iconColor = "var(--core-color-plum-700)";
|
|
17
17
|
else iconColor = "var(--color-action-graphics-onlight)";
|
|
18
|
-
const closeClasses =
|
|
18
|
+
const closeClasses = cn(styles.close, { [styles["close--small"]]: small }, className);
|
|
19
19
|
return /* @__PURE__ */ jsx("button", {
|
|
20
20
|
ref: mergeRefs([ref, refObject]),
|
|
21
21
|
"data-testid": testId,
|
|
@@ -25,7 +25,7 @@ var Close = (props) => {
|
|
|
25
25
|
onClick,
|
|
26
26
|
type: "button",
|
|
27
27
|
children: /* @__PURE__ */ jsx("span", {
|
|
28
|
-
className:
|
|
28
|
+
className: cn(styles["close__inner-container"], {
|
|
29
29
|
[styles["close__inner-container--small"]]: small,
|
|
30
30
|
[styles["close__inner-container--plum"]]: color == "plum"
|
|
31
31
|
}),
|
package/lib/Close.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Close.js","names":["Close: React.FC<CloseProps>"],"sources":["../src/components/Close/Close.tsx","../src/components/Close/index.ts"],"sourcesContent":["import classNames from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\nimport { useIsMobileBreakpoint } from '../../hooks/useIsMobileBreakpoint';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { mergeRefs } from '../../utils/refs';\nimport Icon from '../Icon';\nimport X from '../Icons/X';\n\nimport styles from './styles.module.scss';\n\nexport interface CloseProps {\n /** Keeps the icon small for all screen sizes */\n small?: boolean;\n /** Function is called when user clicks the button */\n onClick?: (e?: React.MouseEvent<HTMLElement, MouseEvent>) => void;\n /** Sets the aria-label of the button */\n ariaLabel?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Adds custom classes to the element. */\n className?: string;\n /** Gives color to the svg */\n color?: 'blueberry' | 'black' | 'plum';\n /** Ref that is passed to the component */\n ref?: React.Ref<HTMLButtonElement | null>;\n}\n\nconst Close: React.FC<CloseProps> = props => {\n const { small, testId, ariaLabel = 'Lukk', onClick, className, color = 'blueberry', ref } = props;\n const { refObject, isHovered } = usePseudoClasses();\n\n const iconSize = useIsMobileBreakpoint() || small ? 38 : 48;\n\n let iconColor;\n if (color === 'black') {\n iconColor = 'black';\n } else if (color === 'plum') {\n iconColor = 'var(--core-color-plum-700)';\n } else {\n iconColor = 'var(--color-action-graphics-onlight)';\n }\n\n const closeClasses = classNames(styles.close, { [styles['close--small']]: small }, className);\n\n return (\n <button\n ref={mergeRefs([ref, refObject])}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Close}\n className={closeClasses}\n aria-label={ariaLabel}\n onClick={onClick}\n type=\"button\"\n >\n <span\n className={classNames(styles['close__inner-container'], {\n [styles['close__inner-container--small']]: small,\n [styles['close__inner-container--plum']]: color == 'plum',\n })}\n >\n <Icon svgIcon={X} color={iconColor} size={iconSize} isHovered={isHovered} />\n </span>\n </button>\n );\n};\n\nexport default Close;\n","import Close from './Close';\nexport * from './Close';\nexport default Close;\n"],"mappings":";;;;;;;;;AA4BA,IAAMA,SAA8B,UAAS;CAC3C,MAAM,EAAE,OAAO,QAAQ,YAAY,QAAQ,SAAS,WAAW,QAAQ,aAAa,QAAQ;CAC5F,MAAM,EAAE,WAAW,cAAc,kBAAkB;CAEnD,MAAM,WAAW,uBAAuB,IAAI,QAAQ,KAAK;CAEzD,IAAI;AACJ,KAAI,UAAU,QACZ,aAAY;UACH,UAAU,OACnB,aAAY;KAEZ,aAAY;CAGd,MAAM,eAAe,
|
|
1
|
+
{"version":3,"file":"Close.js","names":["Close: React.FC<CloseProps>"],"sources":["../src/components/Close/Close.tsx","../src/components/Close/index.ts"],"sourcesContent":["import classNames from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\nimport { useIsMobileBreakpoint } from '../../hooks/useIsMobileBreakpoint';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { mergeRefs } from '../../utils/refs';\nimport Icon from '../Icon';\nimport X from '../Icons/X';\n\nimport styles from './styles.module.scss';\n\nexport interface CloseProps {\n /** Keeps the icon small for all screen sizes */\n small?: boolean;\n /** Function is called when user clicks the button */\n onClick?: (e?: React.MouseEvent<HTMLElement, MouseEvent>) => void;\n /** Sets the aria-label of the button */\n ariaLabel?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Adds custom classes to the element. */\n className?: string;\n /** Gives color to the svg */\n color?: 'blueberry' | 'black' | 'plum';\n /** Ref that is passed to the component */\n ref?: React.Ref<HTMLButtonElement | null>;\n}\n\nconst Close: React.FC<CloseProps> = props => {\n const { small, testId, ariaLabel = 'Lukk', onClick, className, color = 'blueberry', ref } = props;\n const { refObject, isHovered } = usePseudoClasses();\n\n const iconSize = useIsMobileBreakpoint() || small ? 38 : 48;\n\n let iconColor;\n if (color === 'black') {\n iconColor = 'black';\n } else if (color === 'plum') {\n iconColor = 'var(--core-color-plum-700)';\n } else {\n iconColor = 'var(--color-action-graphics-onlight)';\n }\n\n const closeClasses = classNames(styles.close, { [styles['close--small']]: small }, className);\n\n return (\n <button\n ref={mergeRefs([ref, refObject])}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Close}\n className={closeClasses}\n aria-label={ariaLabel}\n onClick={onClick}\n type=\"button\"\n >\n <span\n className={classNames(styles['close__inner-container'], {\n [styles['close__inner-container--small']]: small,\n [styles['close__inner-container--plum']]: color == 'plum',\n })}\n >\n <Icon svgIcon={X} color={iconColor} size={iconSize} isHovered={isHovered} />\n </span>\n </button>\n );\n};\n\nexport default Close;\n","import Close from './Close';\nexport * from './Close';\nexport default Close;\n"],"mappings":";;;;;;;;;AA4BA,IAAMA,SAA8B,UAAS;CAC3C,MAAM,EAAE,OAAO,QAAQ,YAAY,QAAQ,SAAS,WAAW,QAAQ,aAAa,QAAQ;CAC5F,MAAM,EAAE,WAAW,cAAc,kBAAkB;CAEnD,MAAM,WAAW,uBAAuB,IAAI,QAAQ,KAAK;CAEzD,IAAI;AACJ,KAAI,UAAU,QACZ,aAAY;UACH,UAAU,OACnB,aAAY;KAEZ,aAAY;CAGd,MAAM,eAAe,GAAW,OAAO,OAAO,GAAG,OAAO,kBAAkB,OAAO,EAAE,UAAU;AAE7F,QACE,oBAAC,UAAA;EACC,KAAK,UAAU,CAAC,KAAK,UAAU,CAAC;EAChC,eAAa;EACb,oBAAkB,YAAY;EAC9B,WAAW;EACX,cAAY;EACH;EACT,MAAK;YAEL,oBAAC,QAAA;GACC,WAAW,GAAW,OAAO,2BAA2B;KACrD,OAAO,mCAAmC;KAC1C,OAAO,kCAAkC,SAAS;IACpD,CAAC;aAEF,oBAAC,cAAA;IAAK,SAAS;IAAG,OAAO;IAAW,MAAM;IAAqB;KAAa;IACvE;GACA;;AC7Db,IAAA,kBDiEe"}
|
package/lib/DictionaryTrigger.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { n as AnalyticsId } from "./constants2.js";
|
|
2
|
-
import
|
|
2
|
+
import cn from "classnames";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
import styles from "./components/DictionaryTrigger/styles.module.scss";
|
|
5
5
|
var DictionaryTrigger = (props) => {
|
|
6
6
|
const { children, selected = false, className, testId, ref, ...rest } = props;
|
|
7
|
-
const triggerClasses =
|
|
7
|
+
const triggerClasses = cn(styles.dictionarytrigger, className);
|
|
8
8
|
return /* @__PURE__ */ jsx("button", {
|
|
9
9
|
type: "button",
|
|
10
10
|
"data-testid": testId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DictionaryTrigger.js","names":["DictionaryTrigger: React.FC<DictionaryTriggerProps>"],"sources":["../src/components/DictionaryTrigger/DictionaryTrigger.tsx","../src/components/DictionaryTrigger/index.ts"],"sourcesContent":["import classNames from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\n\nimport styles from './styles.module.scss';\n\nexport interface DictionaryTriggerProps extends Pick<React.InputHTMLAttributes<HTMLButtonElement>, 'onClick' | 'onFocus' | 'onBlur'> {\n /**\n * Sets the content of the trigger.\n */\n children: React.ReactNode;\n /**\n * Indicates that the trigger is in use.\n */\n selected?: boolean;\n /**\n * Classname will be applied to the button element.\n */\n className?: string;\n /**\n * Sets the data-testid attribute.\n */\n testId?: string;\n /**\n * ref that is passed to the component\n */\n ref?: React.Ref<HTMLButtonElement | null>;\n}\n\nconst DictionaryTrigger: React.FC<DictionaryTriggerProps> = (props: DictionaryTriggerProps) => {\n const { children, selected = false, className, testId, ref, ...rest } = props;\n const triggerClasses = classNames(styles.dictionarytrigger, className);\n\n return (\n <button\n type=\"button\"\n data-testid={testId}\n data-analyticsid={AnalyticsId.DictionaryTrigger}\n className={triggerClasses}\n aria-expanded={selected}\n ref={ref}\n {...rest}\n >\n {children}\n </button>\n );\n};\n\nDictionaryTrigger.displayName = 'DictionaryTrigger';\n\nexport default DictionaryTrigger;\n","import DictionaryTrigger from './DictionaryTrigger';\nexport * from './DictionaryTrigger';\nexport default DictionaryTrigger;\n"],"mappings":";;;;AA6BA,IAAMA,qBAAuD,UAAkC;CAC7F,MAAM,EAAE,UAAU,WAAW,OAAO,WAAW,QAAQ,KAAK,GAAG,SAAS;CACxE,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"DictionaryTrigger.js","names":["DictionaryTrigger: React.FC<DictionaryTriggerProps>"],"sources":["../src/components/DictionaryTrigger/DictionaryTrigger.tsx","../src/components/DictionaryTrigger/index.ts"],"sourcesContent":["import classNames from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\n\nimport styles from './styles.module.scss';\n\nexport interface DictionaryTriggerProps extends Pick<React.InputHTMLAttributes<HTMLButtonElement>, 'onClick' | 'onFocus' | 'onBlur'> {\n /**\n * Sets the content of the trigger.\n */\n children: React.ReactNode;\n /**\n * Indicates that the trigger is in use.\n */\n selected?: boolean;\n /**\n * Classname will be applied to the button element.\n */\n className?: string;\n /**\n * Sets the data-testid attribute.\n */\n testId?: string;\n /**\n * ref that is passed to the component\n */\n ref?: React.Ref<HTMLButtonElement | null>;\n}\n\nconst DictionaryTrigger: React.FC<DictionaryTriggerProps> = (props: DictionaryTriggerProps) => {\n const { children, selected = false, className, testId, ref, ...rest } = props;\n const triggerClasses = classNames(styles.dictionarytrigger, className);\n\n return (\n <button\n type=\"button\"\n data-testid={testId}\n data-analyticsid={AnalyticsId.DictionaryTrigger}\n className={triggerClasses}\n aria-expanded={selected}\n ref={ref}\n {...rest}\n >\n {children}\n </button>\n );\n};\n\nDictionaryTrigger.displayName = 'DictionaryTrigger';\n\nexport default DictionaryTrigger;\n","import DictionaryTrigger from './DictionaryTrigger';\nexport * from './DictionaryTrigger';\nexport default DictionaryTrigger;\n"],"mappings":";;;;AA6BA,IAAMA,qBAAuD,UAAkC;CAC7F,MAAM,EAAE,UAAU,WAAW,OAAO,WAAW,QAAQ,KAAK,GAAG,SAAS;CACxE,MAAM,iBAAiB,GAAW,OAAO,mBAAmB,UAAU;AAEtE,QACE,oBAAC,UAAA;EACC,MAAK;EACL,eAAa;EACb,oBAAkB,YAAY;EAC9B,WAAW;EACX,iBAAe;EACV;EACL,GAAI;EAEH;GACM;;AAIb,kBAAkB,cAAc;AC9ChC,IAAA,8BDgDe"}
|