@helsenorge/designsystem-react 13.0.0 → 13.0.2
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/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 +16 -1
- package/lib/Checkbox.js +6 -6
- package/lib/Checkbox.js.map +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 +5 -5
- package/lib/Drawer.js.map +1 -1
- package/lib/Duolist.js +5 -5
- package/lib/Duolist.js.map +1 -1
- package/lib/ElementHeader.js +9 -9
- 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 +7 -7
- package/lib/Expander.js.map +1 -1
- package/lib/FormFieldTag.js +2 -2
- package/lib/FormFieldTag.js.map +1 -1
- package/lib/FormGroup.js +5 -5
- package/lib/FormGroup.js.map +1 -1
- package/lib/FormLayout.js +3 -3
- package/lib/FormLayout.js.map +1 -1
- package/lib/HelpDetails.js +3 -3
- package/lib/HelpDetails.js.map +1 -1
- package/lib/HelpTriggerIcon.js +2 -2
- 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/InfoTeaser.js +3 -3
- package/lib/InfoTeaser.js.map +1 -1
- package/lib/Input.js +4 -4
- package/lib/Input.js.map +1 -1
- package/lib/Label.js +5 -5
- package/lib/Label.js.map +1 -1
- package/lib/LinkList.js +52 -25
- package/lib/LinkList.js.map +1 -1
- package/lib/List.js +2 -2
- package/lib/List.js.map +1 -1
- package/lib/ListEditMode.js +14 -10
- package/lib/ListEditMode.js.map +1 -1
- package/lib/MaxCharacters.js +2 -2
- package/lib/MaxCharacters.js.map +1 -1
- package/lib/Panel.js +12 -12
- package/lib/Panel.js.map +1 -1
- package/lib/PanelOld.js +14 -14
- package/lib/PanelOld.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 +5 -5
- package/lib/RadioButton.js.map +1 -1
- package/lib/Select.js +4 -4
- package/lib/Select.js.map +1 -1
- package/lib/SingleSelectItem.js +3 -3
- 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 +4 -4
- 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/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/Table.js +2 -2
- package/lib/Table.js.map +1 -1
- package/lib/TableBody.js +2 -2
- package/lib/TableBody.js.map +1 -1
- package/lib/TableCell.js +2 -2
- package/lib/TableCell.js.map +1 -1
- package/lib/TableExpandedRow.js +4 -4
- package/lib/TableExpandedRow.js.map +1 -1
- package/lib/TableExpanderCell.js +2 -2
- package/lib/TableExpanderCell.js.map +1 -1
- package/lib/TableHead.js +2 -2
- package/lib/TableHead.js.map +1 -1
- package/lib/TableHeadCell.js +3 -3
- package/lib/TableHeadCell.js.map +1 -1
- package/lib/TableRow.js +3 -3
- package/lib/TableRow.js.map +1 -1
- package/lib/Textarea.js +4 -4
- 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/Chip/index.js +2 -2
- package/lib/components/Chip/index.js.map +1 -1
- package/lib/components/Dropdown/index.js +5 -5
- 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/styles.module.scss +4 -0
- package/lib/components/EmptyState/index.js +2 -2
- package/lib/components/EmptyState/index.js.map +1 -1
- package/lib/components/ExpanderHierarchy/index.js +7 -7
- package/lib/components/ExpanderHierarchy/index.js.map +1 -1
- package/lib/components/ExpanderList/index.js +28 -25
- package/lib/components/ExpanderList/index.js.map +1 -1
- package/lib/components/ExpanderList/styles.module.scss +1 -0
- package/lib/components/FavoriteButton/index.js +2 -2
- package/lib/components/FavoriteButton/index.js.map +1 -1
- 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/HelpTriggerInline/index.js +2 -2
- package/lib/components/HelpTriggerInline/index.js.map +1 -1
- package/lib/components/LinkList/LinkList.d.ts +7 -0
- package/lib/components/LinkList/index.js +1 -0
- package/lib/components/LinkList/resourceHelper.d.ts +3 -0
- package/lib/components/LinkList/styles.module.scss +4 -0
- package/lib/components/ListEditMode/ListEditMode.d.ts +6 -1
- package/lib/components/ListEditMode/styles.module.scss +4 -8
- 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/PanelList/index.js +3 -3
- package/lib/components/PanelList/index.js.map +1 -1
- package/lib/components/PanelListOld/index.js +2 -2
- package/lib/components/PanelListOld/index.js.map +1 -1
- package/lib/components/PopMenu/index.js +4 -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/ServiceMessage/index.js +5 -5
- 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/Step/index.js +2 -2
- package/lib/components/Step/index.js.map +1 -1
- package/lib/components/Stepper/index.js +2 -2
- 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/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/Toggle/index.js +9 -9
- package/lib/components/Toggle/index.js.map +1 -1
- package/lib/components/Validation/index.js +2 -2
- package/lib/components/Validation/index.js.map +1 -1
- package/lib/designsystem-react.css +9 -2
- package/lib/resources/HN.Designsystem.LinkList.en-GB.json.d.ts +6 -0
- package/lib/resources/HN.Designsystem.LinkList.nb-NO.json.d.ts +6 -0
- package/lib/scss/supernova/styles/colors.css +9 -1
- package/package.json +1 -1
- package/scss/supernova/styles/colors.css +9 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Expander: ExpanderType","highlightTextChild: string | undefined"],"sources":["../../../src/components/ExpanderList/ExpanderList.tsx","../../../src/components/ExpanderList/index.ts"],"sourcesContent":["import React, { useEffect, useId, useRef, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\nimport { useExpand } from '../../hooks/useExpand';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { PaletteNames } from '../../theme/palette';\nimport { mergeRefs } from '../../utils/refs';\nimport { isElementInViewport } from '../../utils/viewport';\nimport { ElementHeaderType, renderElementHeader } from '../ElementHeader/ElementHeader';\nimport Highlighter from '../Highlighter';\nimport ChevronDown from '../Icons/ChevronDown';\nimport ChevronUp from '../Icons/ChevronUp';\nimport ListEditModeItem, { ListEditModeItemProps, listEditModeWrapperClassnames } from '../ListEditMode';\nimport { TitleTags } from '../Title';\n\nimport expanderListStyles from './styles.module.scss';\n\nexport type ExpanderListColors = Extract<PaletteNames, 'white' | 'blueberry' | 'cherry' | 'neutral'>;\nexport interface ExpanderType extends React.ForwardRefExoticComponent<ExpanderProps & React.RefAttributes<HTMLLIElement>> {\n ElementHeader?: ElementHeaderType;\n}\n\nexport interface ExpanderListCompound extends React.ForwardRefExoticComponent<ExpanderListProps & React.RefAttributes<HTMLUListElement>> {\n Expander: ExpanderType;\n}\n\nexport type ExpanderListVariant = 'line' | 'outline' | 'fill' | 'fill-negative';\n\nexport type ExpanderListStatus = 'none' | 'new';\n\ninterface ExpanderListProps {\n /** Toggles accordion functionality for the expanders. */\n accordion?: boolean;\n /** Items in the ExpanderList */\n children: React.ReactNode;\n /** Toggles padding of child elements */\n childPadding?: boolean;\n /** Adds custom classes to the element. */\n className?: string;\n /** Changes the colors of the list. */\n color?: ExpanderListColors;\n /** Changes the font size. */\n large?: boolean;\n /** Whether to render children when closed (in which case they are hidden with CSS). Default: false */\n renderChildrenWhenClosed?: boolean;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Sets visual priority */\n variant?: ExpanderListVariant;\n /** Overrides the default z-index of the expander header */\n zIndex?: number;\n /** Highlights text in title and content. Used for search results */\n highlightText?: string;\n /**\n * @experimental This prop is experimental and may change in the future.\n * Enables ListEditMode\n */\n editMode?: boolean;\n}\n\ntype Modify<T, R> = Omit<T, keyof R> & R;\n\ntype ExpanderProps = Modify<\n React.HTMLAttributes<HTMLButtonElement>,\n {\n id?: string;\n title: JSX.Element | string;\n /** Changes the underlying element of the title. Default: span*/\n titleHtmlMarkup?: TitleTags;\n children: React.ReactNode;\n className?: string;\n color?: ExpanderListColors;\n icon?: React.ReactElement;\n padding?: boolean;\n expanded?: boolean;\n large?: boolean;\n testId?: string;\n handleExpanderClick?: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void;\n /** Called when expander is open/closed. */\n onExpand?: (isExpanded: boolean) => void;\n /** Overrides the default z-index of the expander header */\n zIndex?: number;\n /** Highlights text in title and content. Override if different from list. */\n highlightText?: string;\n /** Displays a status on the left side: default none */\n status?: ExpanderListStatus;\n }\n> &\n Pick<ExpanderListProps, 'renderChildrenWhenClosed' | 'variant'> &\n ListEditModeItemProps;\n\nexport const Expander: ExpanderType = React.forwardRef<HTMLLIElement, ExpanderProps>((props, ref) => {\n const {\n id,\n children,\n padding = true,\n color = 'neutral',\n className = '',\n icon,\n large = false,\n title,\n titleHtmlMarkup = 'span',\n expanded = false,\n testId,\n handleExpanderClick,\n onExpand,\n renderChildrenWhenClosed,\n variant = 'line',\n zIndex = 0,\n highlightText,\n status = 'none',\n editMode = false,\n } = props;\n const [isExpanded] = useExpand(expanded, onExpand);\n const expanderRef = useRef<HTMLLIElement>(null);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const { isHovered, isFocused } = usePseudoClasses(triggerRef);\n\n const isFill = variant === 'fill';\n const isFillNegative = variant === 'fill-negative';\n const isOutline = variant === 'outline';\n const isLine = variant === 'line';\n\n const itemClasses = classNames(className, expanderListStyles['expander-list__item'], {\n [expanderListStyles[`expander-list__item--fill`]]: isFill,\n [expanderListStyles[`expander-list__item--fill--${color}`]]: isFill,\n [expanderListStyles[`expander-list__item--fill-negative`]]: isFillNegative,\n [expanderListStyles[`expander-list__item--fill-negative--${color}`]]: isFillNegative,\n [expanderListStyles['expander-list__item--outline']]: isOutline,\n [expanderListStyles[`expander-list__item--outline--${color}`]]: isOutline,\n [expanderListStyles['expander-list__item--line']]: isLine,\n [expanderListStyles[`expander-list__item--line--${color}`]]: isLine,\n [expanderListStyles[`expander-list__item--new`]]: status === 'new',\n });\n\n const expanderClasses = classNames(expanderListStyles['expander-list-link'], expanderListStyles[`expander-list-link--${color}`], {\n [expanderListStyles[`expander-list-link--fill--${color}`]]: isFill,\n [expanderListStyles[`expander-list-link--fill-negative`]]: isFillNegative,\n [expanderListStyles[`expander-list-link--fill-negative--${color}`]]: isFillNegative,\n [expanderListStyles['expander-list-link--outline']]: isOutline,\n [expanderListStyles[`expander-list-link--outline--${color}`]]: isOutline,\n [expanderListStyles[`expander-list-link--line--${color}`]]: isLine,\n [expanderListStyles['expander-list-link--open']]: isExpanded,\n [expanderListStyles['expander-list-link--large']]: large,\n [expanderListStyles[`expander-list-link--new`]]: status === 'new',\n });\n\n const renderContent = (): React.ReactNode => {\n if (!renderChildrenWhenClosed && !isExpanded) {\n return null;\n }\n\n const mainContentClasses = classNames(expanderListStyles['expander-list-link__main-content'], {\n [expanderListStyles['expander-list-link__main-content--expanded']]: isExpanded,\n [expanderListStyles['expander-list-link__main-content--padding']]: padding,\n [expanderListStyles[`expander-list-link__main-content--outline--${color}`]]: isOutline,\n [expanderListStyles[`expander-list-link__main-content--new`]]: status === 'new',\n });\n\n return (\n <div className={mainContentClasses} data-state={isExpanded ? 'open' : 'closed'}>\n <Highlighter searchText={highlightText}>{children}</Highlighter>\n </div>\n );\n };\n\n const statusMarkerClasses = classNames(expanderListStyles['expander-list__item__status-marker'], {\n [expanderListStyles['expander-list__item__status-marker--new']]: status === 'new',\n });\n\n return (\n <li className={itemClasses} ref={mergeRefs([ref, expanderRef])}>\n {status !== 'none' && <div className={statusMarkerClasses}></div>}\n {editMode ? (\n <div id={id} data-testid={testId} data-analyticsid={AnalyticsId.ExpanderListExpander} className={expanderClasses}>\n {renderElementHeader(title, {\n titleHtmlMarkup,\n isHovered: false,\n size: large ? 'large' : 'medium',\n parentType: 'expanderlist',\n chevronIcon: undefined,\n icon,\n highlightText,\n })}\n </div>\n ) : (\n <button\n type=\"button\"\n id={id}\n onClick={handleExpanderClick}\n data-testid={testId}\n data-analyticsid={AnalyticsId.ExpanderListExpander}\n className={expanderClasses}\n ref={triggerRef}\n aria-expanded={isExpanded}\n style={{\n zIndex: isFocused ? zIndex + 1 : zIndex,\n }}\n >\n {renderElementHeader(title, {\n titleHtmlMarkup,\n isHovered: isHovered || isFocused,\n size: large ? 'large' : 'medium',\n parentType: 'expanderlist',\n chevronIcon: isExpanded ? ChevronUp : ChevronDown,\n icon,\n highlightText,\n })}\n </button>\n )}\n {!editMode && renderContent()}\n </li>\n );\n});\n\ntype ActiveExpander = Record<string, boolean>;\n\nconst isExpanderComponent = (element: unknown | null | undefined): element is React.ReactElement<ExpanderProps> =>\n React.isValidElement<ExpanderProps>(element) && (element as React.ReactElement).type === Expander;\n\nexport const ExpanderList = React.forwardRef((props: ExpanderListProps, ref: React.Ref<HTMLUListElement>) => {\n const {\n children,\n childPadding = true,\n large,\n renderChildrenWhenClosed = false,\n color = 'white',\n className = '',\n accordion = false,\n testId,\n variant,\n zIndex,\n highlightText,\n editMode = false,\n } = props;\n const [activeExpander, setActiveExpander] = useState<ActiveExpander>();\n const [latestExpander, setLatestExpander] = useState<HTMLElement>();\n const expanderIdBase = useId();\n const expanderListClasses = classNames(expanderListStyles['expander-list'], className, {\n [expanderListStyles[`expander-list--outline--${color}`]]: variant === 'outline',\n [expanderListStyles[`expander-list--fill`]]: variant === 'fill' || variant === 'fill-negative',\n [listEditModeWrapperClassnames]: editMode,\n });\n\n function handleExpanderClick(event: React.MouseEvent<HTMLElement, MouseEvent>, id: string): void {\n setActiveExpander(prevState => (accordion ? { [id]: !prevState?.[id] } : { ...prevState, [id]: !prevState?.[id] }));\n setLatestExpander(event.currentTarget);\n }\n\n const getExpanderId = (index: number): string => `${expanderIdBase}-${index}`;\n\n useEffect(() => {\n if (accordion && latestExpander && !isElementInViewport(latestExpander)) {\n latestExpander.scrollIntoView();\n }\n }, [accordion, latestExpander]);\n\n useEffect(() => {\n const newActiveExpander = React.Children.map(children, child => {\n if (isExpanderComponent(child)) {\n return child;\n }\n })?.reduce((acc, child, index) => {\n // Expanded-status skal bare settes dersom prop er satt av den som bruker komponenten\n if (typeof child.props.expanded !== 'undefined') {\n acc[getExpanderId(index)] = child.props.expanded;\n }\n return acc;\n }, {} as ActiveExpander);\n\n setActiveExpander({ ...activeExpander, ...newActiveExpander });\n }, [children]);\n\n return (\n <ul className={expanderListClasses} ref={ref} data-testid={testId} data-analyticsid={AnalyticsId.ExpanderList}>\n {React.Children.map(children, (child, index) => {\n if (isExpanderComponent(child)) {\n const id = getExpanderId(index);\n const expanded = activeExpander?.[id];\n const highlightTextChild: string | undefined = child.props.highlightText || highlightText;\n\n if (editMode) {\n return (\n <ListEditModeItem color={color} variant={variant} onDelete={child.props.onDelete}>\n {React.cloneElement(child, {\n id,\n key: index,\n expanded,\n padding: childPadding,\n color,\n large,\n 'aria-expanded': false,\n className: expanderListStyles['expander-list__item'],\n renderChildrenWhenClosed: false,\n variant,\n zIndex: zIndex,\n highlightText: highlightTextChild,\n editMode: true,\n })}\n </ListEditModeItem>\n );\n } else {\n return React.cloneElement(child as React.ReactElement<ExpanderProps>, {\n id,\n key: index,\n expanded,\n padding: childPadding,\n color,\n large,\n 'aria-expanded': expanded,\n className: expanderListStyles['expander-list__item'],\n handleExpanderClick: (event: React.MouseEvent<HTMLElement>) => handleExpanderClick(event, `${expanderIdBase}-${index}`),\n renderChildrenWhenClosed,\n variant,\n zIndex: zIndex,\n highlightText: highlightTextChild,\n });\n }\n }\n return child;\n })}\n </ul>\n );\n}) as ExpanderListCompound;\n\nExpanderList.displayName = 'ExpanderList';\nExpanderList.Expander = Expander;\nExpander.displayName = 'ExpanderList.Expander';\n\nexport default ExpanderList;\n","import ExpanderList from './ExpanderList';\nexport * from './ExpanderList';\nexport default ExpanderList;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6FA,MAAaA,WAAyB,MAAM,YAA0C,OAAO,QAAQ;CACnG,MAAM,EACJ,IACA,UACA,UAAU,MACV,QAAQ,WACR,YAAY,IACZ,MACA,QAAQ,OACR,OACA,kBAAkB,QAClB,WAAW,OACX,QACA,qBACA,UACA,0BACA,UAAU,QACV,SAAS,GACT,eACA,SAAS,QACT,WAAW,UACT;CACJ,MAAM,CAAC,cAAc,UAAU,UAAU,SAAS;CAClD,MAAM,cAAc,OAAsB,KAAK;CAC/C,MAAM,aAAa,OAA0B,KAAK;CAClD,MAAM,EAAE,WAAW,cAAc,iBAAiB,WAAW;CAE7D,MAAM,SAAS,YAAY;CAC3B,MAAM,iBAAiB,YAAY;CACnC,MAAM,YAAY,YAAY;CAC9B,MAAM,SAAS,YAAY;CAE3B,MAAM,cAAc,GAAW,WAAW,mBAAmB,wBAAwB;GAClF,mBAAmB,+BAA+B;GAClD,mBAAmB,8BAA8B,WAAW;GAC5D,mBAAmB,wCAAwC;GAC3D,mBAAmB,uCAAuC,WAAW;GACrE,mBAAmB,kCAAkC;GACrD,mBAAmB,iCAAiC,WAAW;GAC/D,mBAAmB,+BAA+B;GAClD,mBAAmB,8BAA8B,WAAW;GAC5D,mBAAmB,8BAA8B,WAAW;EAC9D,CAAC;CAEF,MAAM,kBAAkB,GAAW,mBAAmB,uBAAuB,mBAAmB,uBAAuB,UAAU;GAC9H,mBAAmB,6BAA6B,WAAW;GAC3D,mBAAmB,uCAAuC;GAC1D,mBAAmB,sCAAsC,WAAW;GACpE,mBAAmB,iCAAiC;GACpD,mBAAmB,gCAAgC,WAAW;GAC9D,m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OAAO,UAAU;AAC9C,OAAI,oBAAoB,MAAM,EAAE;IAC9B,MAAM,KAAK,cAAc,MAAM;IAC/B,MAAM,WAAW,iBAAiB;IAClC,MAAMC,qBAAyC,MAAM,MAAM,iBAAiB;AAE5E,QAAI,SACF,QACE,oBAAC,sBAAA;KAAwB;KAAgB;KAAS,UAAU,MAAM,MAAM;eACrE,MAAM,aAAa,OAAO;MACzB;MACA,KAAK;MACL;MACA,SAAS;MACT;MACA;MACA,iBAAiB;MACjB,WAAW,mBAAmB;MAC9B,0BAA0B;MAC1B;MACQ;MACR,eAAe;MACf,UAAU;MACX,CAAC;MACe;QAGrB,QAAO,MAAM,aAAa,OAA4C;KACpE;KACA,KAAK;KACL;KACA,SAAS;KACT;KACA;KACA,iBAAiB;KACjB,WAAW,mBAAmB;KAC9B,sBAAsB,UAAyC,oBAAoB,OAAO,GAAG,eAAe,GAAG,QAAQ;KACvH;KACA;KACQ;KACR,eAAe;KAChB,CAAC;;AAGN,UAAO;IACP;GACC;EAEP;AAEF,aAAa,cAAc;AAC3B,aAAa,WAAW;AACxB,SAAS,cAAc;ACvUvB,IAAA,uBDyUe"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["Expander: ExpanderType","highlightTextChild: string | undefined"],"sources":["../../../src/components/ExpanderList/ExpanderList.tsx","../../../src/components/ExpanderList/index.ts"],"sourcesContent":["import React, { useEffect, useId, useRef, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\nimport { useExpand } from '../../hooks/useExpand';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { PaletteNames } from '../../theme/palette';\nimport { mergeRefs } from '../../utils/refs';\nimport { isElementInViewport } from '../../utils/viewport';\nimport { ElementHeaderType, renderElementHeader } from '../ElementHeader/ElementHeader';\nimport Highlighter from '../Highlighter';\nimport ChevronDown from '../Icons/ChevronDown';\nimport ChevronUp from '../Icons/ChevronUp';\nimport ListEditModeItem, { ListEditModeItemProps, listEditModeWrapperClassnames } from '../ListEditMode';\nimport { TitleTags } from '../Title';\n\nimport expanderListStyles from './styles.module.scss';\n\nexport type ExpanderListColors = Extract<PaletteNames, 'white' | 'blueberry' | 'cherry' | 'neutral'>;\nexport interface ExpanderType extends React.ForwardRefExoticComponent<ExpanderProps & React.RefAttributes<HTMLLIElement>> {\n ElementHeader?: ElementHeaderType;\n}\n\nexport interface ExpanderListCompound extends React.ForwardRefExoticComponent<ExpanderListProps & React.RefAttributes<HTMLUListElement>> {\n Expander: ExpanderType;\n}\n\nexport type ExpanderListVariant = 'line' | 'outline' | 'fill' | 'fill-negative';\n\nexport type ExpanderListStatus = 'none' | 'new';\n\ninterface ExpanderListProps {\n /** Toggles accordion functionality for the expanders. */\n accordion?: boolean;\n /** Items in the ExpanderList */\n children: React.ReactNode;\n /** Toggles padding of child elements */\n childPadding?: boolean;\n /** Adds custom classes to the element. */\n className?: string;\n /** Changes the colors of the list. */\n color?: ExpanderListColors;\n /** Changes the font size. */\n large?: boolean;\n /** Whether to render children when closed (in which case they are hidden with CSS). Default: false */\n renderChildrenWhenClosed?: boolean;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Sets visual priority */\n variant?: ExpanderListVariant;\n /** Overrides the default z-index of the expander header */\n zIndex?: number;\n /** Highlights text in title and content. Used for search results */\n highlightText?: string;\n /**\n * @experimental This prop is experimental and may change in the future.\n * Enables ListEditMode\n */\n editMode?: boolean;\n}\n\ntype Modify<T, R> = Omit<T, keyof R> & R;\n\ntype ExpanderProps = Modify<\n React.HTMLAttributes<HTMLButtonElement>,\n {\n id?: string;\n title: JSX.Element | string;\n /** Changes the underlying element of the title. Default: span*/\n titleHtmlMarkup?: TitleTags;\n children: React.ReactNode;\n className?: string;\n color?: ExpanderListColors;\n icon?: React.ReactElement;\n padding?: boolean;\n expanded?: boolean;\n large?: boolean;\n testId?: string;\n handleExpanderClick?: (event: React.MouseEvent<HTMLElement, MouseEvent>) => void;\n /** Called when expander is open/closed. */\n onExpand?: (isExpanded: boolean) => void;\n /** Overrides the default z-index of the expander header */\n zIndex?: number;\n /** Highlights text in title and content. Override if different from list. */\n highlightText?: string;\n /** Displays a status on the left side: default none */\n status?: ExpanderListStatus;\n }\n> &\n Pick<ExpanderListProps, 'renderChildrenWhenClosed' | 'variant'> &\n ListEditModeItemProps;\n\nexport const Expander: ExpanderType = React.forwardRef<HTMLLIElement, ExpanderProps>((props, ref) => {\n const {\n id,\n children,\n padding = true,\n color = 'neutral',\n className = '',\n icon,\n large = false,\n title,\n titleHtmlMarkup = 'span',\n expanded = false,\n testId,\n handleExpanderClick,\n onExpand,\n renderChildrenWhenClosed,\n variant = 'line',\n zIndex = 0,\n highlightText,\n status = 'none',\n editMode = false,\n } = props;\n const [isExpanded] = useExpand(expanded, onExpand);\n const expanderRef = useRef<HTMLLIElement>(null);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const { isHovered, isFocused } = usePseudoClasses(triggerRef);\n\n const isFill = variant === 'fill';\n const isFillNegative = variant === 'fill-negative';\n const isOutline = variant === 'outline';\n const isLine = variant === 'line';\n\n const itemClasses = classNames(className, expanderListStyles['expander-list__item'], {\n [expanderListStyles[`expander-list__item--fill`]]: isFill,\n [expanderListStyles[`expander-list__item--fill--${color}`]]: isFill,\n [expanderListStyles[`expander-list__item--fill-negative`]]: isFillNegative,\n [expanderListStyles[`expander-list__item--fill-negative--${color}`]]: isFillNegative,\n [expanderListStyles['expander-list__item--outline']]: isOutline,\n [expanderListStyles[`expander-list__item--outline--${color}`]]: isOutline,\n [expanderListStyles['expander-list__item--line']]: isLine,\n [expanderListStyles[`expander-list__item--line--${color}`]]: isLine,\n [expanderListStyles[`expander-list__item--new`]]: status === 'new',\n });\n\n const expanderClasses = classNames(expanderListStyles['expander-list-link'], expanderListStyles[`expander-list-link--${color}`], {\n [expanderListStyles[`expander-list-link--fill--${color}`]]: isFill,\n [expanderListStyles[`expander-list-link--fill-negative`]]: isFillNegative,\n [expanderListStyles[`expander-list-link--fill-negative--${color}`]]: isFillNegative,\n [expanderListStyles['expander-list-link--outline']]: isOutline,\n [expanderListStyles[`expander-list-link--outline--${color}`]]: isOutline,\n [expanderListStyles[`expander-list-link--line--${color}`]]: isLine,\n [expanderListStyles['expander-list-link--open']]: isExpanded,\n [expanderListStyles['expander-list-link--large']]: large,\n [expanderListStyles[`expander-list-link--new`]]: status === 'new',\n });\n\n const renderContent = (): React.ReactNode => {\n if (!renderChildrenWhenClosed && !isExpanded) {\n return null;\n }\n\n const mainContentClasses = classNames(expanderListStyles['expander-list-link__main-content'], {\n [expanderListStyles['expander-list-link__main-content--expanded']]: isExpanded,\n [expanderListStyles['expander-list-link__main-content--padding']]: padding,\n [expanderListStyles[`expander-list-link__main-content--outline--${color}`]]: isOutline,\n [expanderListStyles[`expander-list-link__main-content--new`]]: status === 'new',\n });\n\n return (\n <div className={mainContentClasses} data-state={isExpanded ? 'open' : 'closed'}>\n <Highlighter searchText={highlightText}>{children}</Highlighter>\n </div>\n );\n };\n\n const statusMarkerClasses = classNames(expanderListStyles['expander-list__item__status-marker'], {\n [expanderListStyles['expander-list__item__status-marker--new']]: status === 'new',\n });\n\n return (\n <>\n {editMode ? (\n <div className={itemClasses}>\n {status !== 'none' && <div className={statusMarkerClasses}></div>}\n <div id={id} data-testid={testId} data-analyticsid={AnalyticsId.ExpanderListExpander} className={expanderClasses}>\n {renderElementHeader(title, {\n titleHtmlMarkup,\n isHovered: false,\n size: large ? 'large' : 'medium',\n parentType: 'expanderlist',\n chevronIcon: undefined,\n icon,\n highlightText,\n })}\n </div>\n </div>\n ) : (\n <li className={itemClasses} ref={mergeRefs([ref, expanderRef])}>\n {status !== 'none' && <div className={statusMarkerClasses}></div>}\n <button\n type=\"button\"\n id={id}\n onClick={handleExpanderClick}\n data-testid={testId}\n data-analyticsid={AnalyticsId.ExpanderListExpander}\n className={expanderClasses}\n ref={triggerRef}\n aria-expanded={isExpanded}\n style={{\n zIndex: isFocused ? zIndex + 1 : zIndex,\n }}\n >\n {renderElementHeader(title, {\n titleHtmlMarkup,\n isHovered: isHovered || isFocused,\n size: large ? 'large' : 'medium',\n parentType: 'expanderlist',\n chevronIcon: isExpanded ? ChevronUp : ChevronDown,\n icon,\n highlightText,\n })}\n </button>\n {renderContent()}\n </li>\n )}\n </>\n );\n});\n\ntype ActiveExpander = Record<string, boolean>;\n\nconst isExpanderComponent = (element: unknown | null | undefined): element is React.ReactElement<ExpanderProps> =>\n React.isValidElement<ExpanderProps>(element) && (element as React.ReactElement).type === Expander;\n\nexport const ExpanderList = React.forwardRef((props: ExpanderListProps, ref: React.Ref<HTMLUListElement>) => {\n const {\n children,\n childPadding = true,\n large,\n renderChildrenWhenClosed = false,\n color = 'white',\n className = '',\n accordion = false,\n testId,\n variant,\n zIndex,\n highlightText,\n editMode = false,\n } = props;\n const [activeExpander, setActiveExpander] = useState<ActiveExpander>();\n const [latestExpander, setLatestExpander] = useState<HTMLElement>();\n const expanderIdBase = useId();\n const expanderListClasses = classNames(expanderListStyles['expander-list'], className, {\n [expanderListStyles[`expander-list--outline--${color}`]]: variant === 'outline',\n [expanderListStyles[`expander-list--fill`]]: variant === 'fill' || variant === 'fill-negative',\n [listEditModeWrapperClassnames]: editMode,\n });\n\n function handleExpanderClick(event: React.MouseEvent<HTMLElement, MouseEvent>, id: string): void {\n setActiveExpander(prevState => (accordion ? { [id]: !prevState?.[id] } : { ...prevState, [id]: !prevState?.[id] }));\n setLatestExpander(event.currentTarget);\n }\n\n const getExpanderId = (index: number): string => `${expanderIdBase}-${index}`;\n\n useEffect(() => {\n if (accordion && latestExpander && !isElementInViewport(latestExpander)) {\n latestExpander.scrollIntoView();\n }\n }, [accordion, latestExpander]);\n\n useEffect(() => {\n const newActiveExpander = React.Children.map(children, child => {\n if (isExpanderComponent(child)) {\n return child;\n }\n })?.reduce((acc, child, index) => {\n // Expanded-status skal bare settes dersom prop er satt av den som bruker komponenten\n if (typeof child.props.expanded !== 'undefined') {\n acc[getExpanderId(index)] = child.props.expanded;\n }\n return acc;\n }, {} as ActiveExpander);\n\n setActiveExpander({ ...activeExpander, ...newActiveExpander });\n }, [children]);\n\n return (\n <ul className={expanderListClasses} ref={ref} data-testid={testId} data-analyticsid={AnalyticsId.ExpanderList}>\n {React.Children.map(children, (child, index) => {\n if (isExpanderComponent(child)) {\n const id = getExpanderId(index);\n const expanded = activeExpander?.[id];\n const highlightTextChild: string | undefined = child.props.highlightText || highlightText;\n\n if (editMode) {\n return (\n <ListEditModeItem color={color} variant={variant} onDelete={child.props.onDelete}>\n {React.cloneElement(child, {\n id,\n key: index,\n expanded,\n padding: childPadding,\n color,\n large,\n 'aria-expanded': false,\n className: expanderListStyles['expander-list__item'],\n renderChildrenWhenClosed: false,\n variant,\n zIndex: zIndex,\n highlightText: highlightTextChild,\n editMode: true,\n })}\n </ListEditModeItem>\n );\n } else {\n return React.cloneElement(child as React.ReactElement<ExpanderProps>, {\n id,\n key: index,\n expanded,\n padding: childPadding,\n color,\n large,\n 'aria-expanded': expanded,\n className: expanderListStyles['expander-list__item'],\n handleExpanderClick: (event: React.MouseEvent<HTMLElement>) => handleExpanderClick(event, `${expanderIdBase}-${index}`),\n renderChildrenWhenClosed,\n variant,\n zIndex: zIndex,\n highlightText: highlightTextChild,\n });\n }\n }\n return child;\n })}\n </ul>\n );\n}) as ExpanderListCompound;\n\nExpanderList.displayName = 'ExpanderList';\nExpanderList.Expander = Expander;\nExpander.displayName = 'ExpanderList.Expander';\n\nexport default ExpanderList;\n","import ExpanderList from './ExpanderList';\nexport * from './ExpanderList';\nexport default ExpanderList;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6FA,MAAaA,WAAyB,MAAM,YAA0C,OAAO,QAAQ;CACnG,MAAM,EACJ,IACA,UACA,UAAU,MACV,QAAQ,WACR,YAAY,IACZ,MACA,QAAQ,OACR,OACA,kBAAkB,QAClB,WAAW,OACX,QACA,qBACA,UACA,0BACA,UAAU,QACV,SAAS,GACT,eACA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C9B,0BAA0B;MAC1B;MACQ;MACR,eAAe;MACf,UAAU;MACX,CAAC;MACe;QAGrB,QAAO,MAAM,aAAa,OAA4C;KACpE;KACA,KAAK;KACL;KACA,SAAS;KACT;KACA;KACA,iBAAiB;KACjB,WAAW,mBAAmB;KAC9B,sBAAsB,UAAyC,oBAAoB,OAAO,GAAG,eAAe,GAAG,QAAQ;KACvH;KACA;KACQ;KACR,eAAe;KAChB,CAAC;;AAGN,UAAO;IACP;GACC;EAEP;AAEF,aAAa,cAAc;AAC3B,aAAa,WAAW;AACxB,SAAS,cAAc;AC5UvB,IAAA,uBD8Ue"}
|
|
@@ -5,7 +5,7 @@ import { t as isMutableRefObject } from "../../refs.js";
|
|
|
5
5
|
import { r as useLanguage } from "../../language.js";
|
|
6
6
|
import { n as useBreakpoint, t as Breakpoint } from "../../useBreakpoint.js";
|
|
7
7
|
import React from "react";
|
|
8
|
-
import
|
|
8
|
+
import classNames from "classnames";
|
|
9
9
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
10
|
import styles from "./styles.module.scss";
|
|
11
11
|
var HN_Designsystem_FavoriteButton_nb_NO_default = { ariaLabel: "Favorittmarkering" };
|
|
@@ -99,7 +99,7 @@ const starIconHoverDesktop = (isChecked, isActive) => /* @__PURE__ */ jsxs(Fragm
|
|
|
99
99
|
})] });
|
|
100
100
|
const FavoriteButton = React.forwardRef(function FavoriteButtonForwardedRef(props, ref) {
|
|
101
101
|
const { checked, id, onClick, resources, tabIndex, testId, ...other } = props;
|
|
102
|
-
const buttonWrapperClasses =
|
|
102
|
+
const buttonWrapperClasses = classNames(styles.favoritebutton);
|
|
103
103
|
const { refObject, isHovered, isActive } = usePseudoClasses(isMutableRefObject(ref) ? ref : null);
|
|
104
104
|
const breakpoint = useBreakpoint();
|
|
105
105
|
const { language } = useLanguage(LanguageLocales.NORWEGIAN);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["mergedResources: HNDesignsystemFavoriteButton"],"sources":["../../../src/resources/HN.Designsystem.FavoriteButton.nb-NO.json","../../../src/components/FavoriteButton/resourceHelper.ts","../../../src/components/FavoriteButton/StarIcon.tsx","../../../src/components/FavoriteButton/FavoriteButton.tsx","../../../src/components/FavoriteButton/index.ts"],"sourcesContent":["{\n \"ariaLabel\": \"Favorittmarkering\"\n}\n","import { LanguageLocales } from '../../constants';\nimport nbNO from '../../resources/HN.Designsystem.FavoriteButton.nb-NO.json';\nimport { HNDesignsystemFavoriteButton } from '../../resources/Resources';\n\nexport const getResources = (language: LanguageLocales): HNDesignsystemFavoriteButton => {\n switch (language) {\n case LanguageLocales.NORWEGIAN:\n default:\n return nbNO;\n }\n};\n","import styles from './styles.module.scss';\n\nconst normalStroke = 'var(--color-action-graphics-onlight)';\nconst normalFill = 'transparent';\nconst hoverFill = '#126F8721'; // kan ikke bruke transparent token på svg\nconst hoverStroke = 'var(--color-action-graphics-onlight-hover)';\nconst activeStroke = 'var(--core-color-blueberry-800)';\n\nconst fillColor = (isChecked: boolean, isActive: boolean, isHovered: boolean): string => {\n if (isChecked) {\n if (isActive) {\n return activeStroke;\n } else {\n if (isHovered) {\n return hoverStroke;\n } else {\n return normalStroke;\n }\n }\n } else {\n if (isHovered) {\n return hoverFill;\n } else {\n return normalFill;\n }\n }\n};\n\nconst strokeColor = (isActive: boolean, isHovered: boolean): string => {\n if (isActive) {\n return activeStroke;\n } else {\n if (isHovered) {\n return hoverStroke;\n } else {\n return normalStroke;\n }\n }\n};\n\nexport const starIconNormalMobile = (isChecked: boolean, isActive: boolean): React.JSX.Element => {\n return (\n <>\n <path\n d=\"M20.1026 31.1787L13.4007 34.7023C10.833 36.0523 7.83185 33.8719 8.32233 31.0126L9.60261 23.5492L4.17653 18.2675C2.09656 16.2428 3.24317 12.712 6.11581 12.2956L13.5982 11.2112L16.9493 4.42107C18.2332 1.81969 21.9426 1.81969 23.2265 4.42107L26.5776 11.2112L34.06 12.2956C36.9326 12.712 38.0792 16.2428 35.9993 18.2675L30.5732 23.5492L31.852 31.0044C32.3428 33.8651 29.3386 36.0456 26.7708 34.6925L20.1026 31.1787Z\"\n stroke=\"black\"\n fill=\"transparent\"\n strokeWidth=\"3\"\n strokeLinecap=\"round\"\n className={styles['favoritebutton__star-icon--focus']}\n display=\"block\"\n />\n <path\n d=\"M20.0961 26.5515L12.6372 30.4731L14.0621 22.1671L8.01953 16.2853L16.3582 15.0768L20.0877 7.52002L23.8171 15.0768L32.1558 16.2853L26.1133 22.1671L27.5381 30.4731L20.0961 26.5515Z\"\n stroke={strokeColor(isActive, false)}\n fill={fillColor(isChecked, isActive, false)}\n strokeWidth=\"2.2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </>\n );\n};\n\nexport const starIconHoverMobile = (isChecked: boolean, isActive: boolean): React.JSX.Element => (\n <>\n <path\n d=\"M22.2128 31.4832L16.2246 36.117C13.9303 37.8924 10.5961 36.2662 10.5826 33.3653L10.5475 25.7929L4.28665 21.5336C1.88672 19.9009 2.40278 16.2246 5.15948 15.3158L12.3399 12.9486L14.461 5.67964C15.2736 2.89484 18.9267 2.2507 20.6428 4.58962L25.1221 10.6947L32.6791 10.4633C35.5804 10.3745 37.3227 13.6526 35.6259 16.0077L31.1994 22.1514L33.7534 29.2712C34.7335 32.0033 32.1536 34.6724 29.3898 33.7857L22.2128 31.4832Z\"\n stroke=\"black\"\n fill=\"transparent\"\n strokeWidth=\"3\"\n strokeLinecap=\"round\"\n className={styles['favoritebutton__star-icon--focus']}\n />\n <path\n d=\"M21.4079 26.8365L14.7433 31.9937L14.7041 23.5664L7.73204 18.8233L15.7342 16.1851L18.0947 8.09555L23.0798 14.8899L31.5016 14.6321L26.5722 21.4738L29.4178 29.4062L21.4079 26.8365Z\"\n stroke={strokeColor(isActive, true)}\n fill={fillColor(isChecked, isActive, true)}\n fillOpacity={isChecked ? '1' : '0.13'}\n strokeWidth=\"2.2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </>\n);\nexport const starIconNormalDesktop = (isChecked: boolean, isActive: boolean): React.JSX.Element => (\n <>\n <path\n d=\"M30.1061 44.1854L20.3139 49.3338C17.7461 50.6838 14.745 48.5034 15.2355 45.6441L17.1061 34.7394L9.17653 27.0207C7.09656 24.9961 8.24318 21.4653 11.1158 21.0489L22.053 19.4638L26.9493 9.54278C28.2331 6.9414 31.9426 6.94139 33.2265 9.54278L38.1227 19.4638L49.06 21.0489C51.9326 21.4653 53.0792 24.9961 50.9993 27.0207L43.0697 34.7394L44.9389 45.6359C45.4296 48.4966 42.4254 50.6772 39.8576 49.324L30.1061 44.1854Z\"\n stroke=\"black\"\n fill=\"transparent\"\n strokeWidth=\"3\"\n strokeLinecap=\"round\"\n className={styles['favoritebutton__star-icon--focus']}\n />\n <path\n d=\"M30.0998 39.4723L19.5927 44.9966L21.5998 33.2961L13.0879 25.0106L24.8343 23.3082L30.0879 12.6632L35.3414 23.3082L47.0879 25.0106L38.576 33.2961L40.5831 44.9966L30.0998 39.4723Z\"\n stroke={strokeColor(isActive, false)}\n fill={fillColor(isChecked, isActive, false)}\n strokeWidth=\"2.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </>\n);\n\nexport const starIconHoverDesktop = (isChecked: boolean, isActive: boolean): React.JSX.Element => (\n <>\n <path\n d=\"M33.1609 44.7458L24.4114 51.5164C22.1171 53.2918 18.783 51.6656 18.7695 48.7646L18.7181 37.7007L9.56864 31.4763C7.1687 29.8436 7.68476 26.1672 10.4415 25.2584L20.9373 21.7982L24.0364 11.1776C24.849 8.39281 28.5021 7.74867 30.2182 10.0876L36.7629 19.0077L47.8092 18.6695C50.7105 18.5807 52.4528 21.8588 50.756 24.2138L44.2872 33.1922L48.0201 43.5985C49.0002 46.3306 46.4203 48.9997 43.6565 48.113L33.1609 44.7458Z\"\n stroke=\"black\"\n fill=\"transparent\"\n strokeWidth=\"3\"\n strokeLinecap=\"round\"\n className={styles['favoritebutton__star-icon--focus']}\n />\n <path\n d=\"M32.3991 40.1029L23.0108 47.3678L22.9557 35.4965L13.1343 28.815L24.4067 25.0987L27.732 13.7031L34.7542 23.2741L46.6178 22.9109L39.674 32.5486L43.6823 43.7228L32.3991 40.1029Z\"\n stroke={strokeColor(isActive, true)}\n fill={fillColor(isChecked, isActive, true)}\n fillOpacity={isChecked ? '1' : '0.13'}\n strokeWidth=\"2.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </>\n);\n","import React, { AriaAttributes } from 'react';\n\nimport classNames from 'classnames';\n\nimport { getResources } from './resourceHelper';\nimport { starIconHoverDesktop, starIconHoverMobile, starIconNormalDesktop, starIconNormalMobile } from './StarIcon';\nimport { AnalyticsId, HTMLButtonProps, LanguageLocales } from '../../constants';\nimport { Breakpoint, useBreakpoint } from '../../hooks/useBreakpoint';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { HNDesignsystemFavoriteButton } from '../../resources/Resources';\nimport { useLanguage } from '../../utils/language';\nimport { isMutableRefObject } from '../../utils/refs';\n\nimport styles from './styles.module.scss';\n\nexport interface FavoriteButtonProps extends Omit<HTMLButtonProps, 'type'>, AriaAttributes {\n /** Determines if the FavoriteButton is checked */\n checked: boolean;\n /** Gives a unique id to the button */\n id?: string;\n /** Function that is called when clicked */\n onClick: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n /** Resources for component */\n resources?: Partial<HNDesignsystemFavoriteButton>;\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}\n\nexport const FavoriteButton = React.forwardRef(function FavoriteButtonForwardedRef(\n props: FavoriteButtonProps,\n ref: React.ForwardedRef<HTMLButtonElement>\n) {\n const { checked, id, onClick, resources, tabIndex, testId, ...other } = props;\n\n const buttonWrapperClasses = classNames(styles.favoritebutton);\n const { refObject, isHovered, isActive } = usePseudoClasses<HTMLButtonElement>(isMutableRefObject(ref) ? ref : null);\n const breakpoint = useBreakpoint();\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n\n const mergedResources: HNDesignsystemFavoriteButton = {\n ...defaultResources,\n ...resources,\n ariaLabel: other['aria-label'] || resources?.ariaLabel || defaultResources.ariaLabel,\n };\n\n const isMobile = breakpoint <= Breakpoint.sm;\n\n const starIcon = ((): React.JSX.Element => {\n if (isMobile) {\n if (isHovered) {\n return starIconHoverMobile(checked, isActive);\n } else {\n return starIconNormalMobile(checked, isActive);\n }\n } else {\n if (isHovered) {\n return starIconHoverDesktop(checked, isActive);\n } else {\n return starIconNormalDesktop(checked, isActive);\n }\n }\n })();\n\n return (\n <button\n id={id}\n onClick={onClick}\n data-testid={testId}\n data-analyticsid={AnalyticsId.FavoriteButton}\n className={buttonWrapperClasses}\n ref={refObject}\n tabIndex={tabIndex}\n role=\"switch\"\n aria-checked={checked}\n type=\"button\"\n aria-label={mergedResources.ariaLabel}\n {...other}\n >\n <svg focusable={false} overflow=\"visible\" role=\"presentation\" viewBox={isMobile ? '0 0 41 41' : '0 0 61 61'}>\n {starIcon}\n </svg>\n </button>\n );\n});\n\nFavoriteButton.displayName = 'FavoriteButton';\n\nexport default FavoriteButton;\n","export * from './FavoriteButton';\n\nimport { FavoriteButton } from './FavoriteButton';\nexport default FavoriteButton;\n"],"mappings":";;;;;;;;;;;ACIA,MAAa,gBAAgB,aAA4D;AACvF,SAAQ,UAAR;EACE,KAAK,gBAAgB;EACrB,QACE,QAAO;;;ACNb,IAAM,eAAe;AACrB,IAAM,aAAa;AACnB,IAAM,YAAY;AAClB,IAAM,cAAc;AACpB,IAAM,eAAe;AAErB,IAAM,aAAa,WAAoB,UAAmB,cAA+B;AACvF,KAAI,UACF,KAAI,SACF,QAAO;UAEH,UACF,QAAO;KAEP,QAAO;UAIP,UACF,QAAO;KAEP,QAAO;;AAKb,IAAM,eAAe,UAAmB,cAA+B;AACrE,KAAI,SACF,QAAO;UAEH,UACF,QAAO;KAEP,QAAO;;AAKb,MAA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YAAY,MAAM;CAC/B,aAAY;CACZ,eAAc;CACd,gBAAe;EACf,CAAA,EAAA,CACD;AC/FL,MAAa,iBAAiB,MAAM,WAAW,SAAS,2BACtD,OACA,KACA;CACA,MAAM,EAAE,SAAS,IAAI,SAAS,WAAW,UAAU,QAAQ,GAAG,UAAU;CAExE,MAAM,uBAAuB,GAAW,OAAO,eAAe;CAC9D,MAAM,EAAE,WAAW,WAAW,aAAa,iBAAoC,mBAAmB,IAAI,GAAG,MAAM,KAAK;CACpH,MAAM,aAAa,eAAe;CAClC,MAAM,EAAE,aAAa,YAA6B,gBAAgB,UAAU;CAC5E,MAAM,mBAAmB,aAAa,SAAS;CAE/C,MAAMA,kBAAgD;EACpD,GAAG;EACH,GAAG;EACH,WAAW,MAAM,iBAAiB,WAAW,aAAa,iBAAiB;EAC5E;CAED,MAAM,WAAW,cAAc,WAAW;CAE1C,MAAM,kBAAqC;AACzC,MAAI,SACF,KAAI,UACF,QAAO,oBAAoB,SAAS,SAAS;MAE7C,QAAO,qBAAqB,SAAS,SAAS;WAG5C,UACF,QAAO,qBAAqB,SAAS,SAAS;MAE9C,QAAO,sBAAsB,SAAS,SAAS;KAGjD;AAEJ,QACE,oBAAC,UAAA;EACK;EACK;EACT,eAAa;EACb,oBAAkB,YAAY;EAC9B,WAAW;EACX,KAAK;EACK;EACV,MAAK;EACL,gBAAc;EACd,MAAK;EACL,cAAY,gBAAgB;EAC5B,GAAI;YAEJ,oBAAC,OAAA;GAAI,WAAW;GAAO,UAAS;GAAU,MAAK;GAAe,SAAS,WAAW,cAAc;aAC7F;IACG;GACC;EAEX;AAEF,eAAe,cAAc;ACrF7B,IAAA,yBAAe"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["mergedResources: HNDesignsystemFavoriteButton"],"sources":["../../../src/resources/HN.Designsystem.FavoriteButton.nb-NO.json","../../../src/components/FavoriteButton/resourceHelper.ts","../../../src/components/FavoriteButton/StarIcon.tsx","../../../src/components/FavoriteButton/FavoriteButton.tsx","../../../src/components/FavoriteButton/index.ts"],"sourcesContent":["{\n \"ariaLabel\": \"Favorittmarkering\"\n}\n","import { LanguageLocales } from '../../constants';\nimport nbNO from '../../resources/HN.Designsystem.FavoriteButton.nb-NO.json';\nimport { HNDesignsystemFavoriteButton } from '../../resources/Resources';\n\nexport const getResources = (language: LanguageLocales): HNDesignsystemFavoriteButton => {\n switch (language) {\n case LanguageLocales.NORWEGIAN:\n default:\n return nbNO;\n }\n};\n","import styles from './styles.module.scss';\n\nconst normalStroke = 'var(--color-action-graphics-onlight)';\nconst normalFill = 'transparent';\nconst hoverFill = '#126F8721'; // kan ikke bruke transparent token på svg\nconst hoverStroke = 'var(--color-action-graphics-onlight-hover)';\nconst activeStroke = 'var(--core-color-blueberry-800)';\n\nconst fillColor = (isChecked: boolean, isActive: boolean, isHovered: boolean): string => {\n if (isChecked) {\n if (isActive) {\n return activeStroke;\n } else {\n if (isHovered) {\n return hoverStroke;\n } else {\n return normalStroke;\n }\n }\n } else {\n if (isHovered) {\n return hoverFill;\n } else {\n return normalFill;\n }\n }\n};\n\nconst strokeColor = (isActive: boolean, isHovered: boolean): string => {\n if (isActive) {\n return activeStroke;\n } else {\n if (isHovered) {\n return hoverStroke;\n } else {\n return normalStroke;\n }\n }\n};\n\nexport const starIconNormalMobile = (isChecked: boolean, isActive: boolean): React.JSX.Element => {\n return (\n <>\n <path\n d=\"M20.1026 31.1787L13.4007 34.7023C10.833 36.0523 7.83185 33.8719 8.32233 31.0126L9.60261 23.5492L4.17653 18.2675C2.09656 16.2428 3.24317 12.712 6.11581 12.2956L13.5982 11.2112L16.9493 4.42107C18.2332 1.81969 21.9426 1.81969 23.2265 4.42107L26.5776 11.2112L34.06 12.2956C36.9326 12.712 38.0792 16.2428 35.9993 18.2675L30.5732 23.5492L31.852 31.0044C32.3428 33.8651 29.3386 36.0456 26.7708 34.6925L20.1026 31.1787Z\"\n stroke=\"black\"\n fill=\"transparent\"\n strokeWidth=\"3\"\n strokeLinecap=\"round\"\n className={styles['favoritebutton__star-icon--focus']}\n display=\"block\"\n />\n <path\n d=\"M20.0961 26.5515L12.6372 30.4731L14.0621 22.1671L8.01953 16.2853L16.3582 15.0768L20.0877 7.52002L23.8171 15.0768L32.1558 16.2853L26.1133 22.1671L27.5381 30.4731L20.0961 26.5515Z\"\n stroke={strokeColor(isActive, false)}\n fill={fillColor(isChecked, isActive, false)}\n strokeWidth=\"2.2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </>\n );\n};\n\nexport const starIconHoverMobile = (isChecked: boolean, isActive: boolean): React.JSX.Element => (\n <>\n <path\n d=\"M22.2128 31.4832L16.2246 36.117C13.9303 37.8924 10.5961 36.2662 10.5826 33.3653L10.5475 25.7929L4.28665 21.5336C1.88672 19.9009 2.40278 16.2246 5.15948 15.3158L12.3399 12.9486L14.461 5.67964C15.2736 2.89484 18.9267 2.2507 20.6428 4.58962L25.1221 10.6947L32.6791 10.4633C35.5804 10.3745 37.3227 13.6526 35.6259 16.0077L31.1994 22.1514L33.7534 29.2712C34.7335 32.0033 32.1536 34.6724 29.3898 33.7857L22.2128 31.4832Z\"\n stroke=\"black\"\n fill=\"transparent\"\n strokeWidth=\"3\"\n strokeLinecap=\"round\"\n className={styles['favoritebutton__star-icon--focus']}\n />\n <path\n d=\"M21.4079 26.8365L14.7433 31.9937L14.7041 23.5664L7.73204 18.8233L15.7342 16.1851L18.0947 8.09555L23.0798 14.8899L31.5016 14.6321L26.5722 21.4738L29.4178 29.4062L21.4079 26.8365Z\"\n stroke={strokeColor(isActive, true)}\n fill={fillColor(isChecked, isActive, true)}\n fillOpacity={isChecked ? '1' : '0.13'}\n strokeWidth=\"2.2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </>\n);\nexport const starIconNormalDesktop = (isChecked: boolean, isActive: boolean): React.JSX.Element => (\n <>\n <path\n d=\"M30.1061 44.1854L20.3139 49.3338C17.7461 50.6838 14.745 48.5034 15.2355 45.6441L17.1061 34.7394L9.17653 27.0207C7.09656 24.9961 8.24318 21.4653 11.1158 21.0489L22.053 19.4638L26.9493 9.54278C28.2331 6.9414 31.9426 6.94139 33.2265 9.54278L38.1227 19.4638L49.06 21.0489C51.9326 21.4653 53.0792 24.9961 50.9993 27.0207L43.0697 34.7394L44.9389 45.6359C45.4296 48.4966 42.4254 50.6772 39.8576 49.324L30.1061 44.1854Z\"\n stroke=\"black\"\n fill=\"transparent\"\n strokeWidth=\"3\"\n strokeLinecap=\"round\"\n className={styles['favoritebutton__star-icon--focus']}\n />\n <path\n d=\"M30.0998 39.4723L19.5927 44.9966L21.5998 33.2961L13.0879 25.0106L24.8343 23.3082L30.0879 12.6632L35.3414 23.3082L47.0879 25.0106L38.576 33.2961L40.5831 44.9966L30.0998 39.4723Z\"\n stroke={strokeColor(isActive, false)}\n fill={fillColor(isChecked, isActive, false)}\n strokeWidth=\"2.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </>\n);\n\nexport const starIconHoverDesktop = (isChecked: boolean, isActive: boolean): React.JSX.Element => (\n <>\n <path\n d=\"M33.1609 44.7458L24.4114 51.5164C22.1171 53.2918 18.783 51.6656 18.7695 48.7646L18.7181 37.7007L9.56864 31.4763C7.1687 29.8436 7.68476 26.1672 10.4415 25.2584L20.9373 21.7982L24.0364 11.1776C24.849 8.39281 28.5021 7.74867 30.2182 10.0876L36.7629 19.0077L47.8092 18.6695C50.7105 18.5807 52.4528 21.8588 50.756 24.2138L44.2872 33.1922L48.0201 43.5985C49.0002 46.3306 46.4203 48.9997 43.6565 48.113L33.1609 44.7458Z\"\n stroke=\"black\"\n fill=\"transparent\"\n strokeWidth=\"3\"\n strokeLinecap=\"round\"\n className={styles['favoritebutton__star-icon--focus']}\n />\n <path\n d=\"M32.3991 40.1029L23.0108 47.3678L22.9557 35.4965L13.1343 28.815L24.4067 25.0987L27.732 13.7031L34.7542 23.2741L46.6178 22.9109L39.674 32.5486L43.6823 43.7228L32.3991 40.1029Z\"\n stroke={strokeColor(isActive, true)}\n fill={fillColor(isChecked, isActive, true)}\n fillOpacity={isChecked ? '1' : '0.13'}\n strokeWidth=\"2.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </>\n);\n","import React, { AriaAttributes } from 'react';\n\nimport classNames from 'classnames';\n\nimport { getResources } from './resourceHelper';\nimport { starIconHoverDesktop, starIconHoverMobile, starIconNormalDesktop, starIconNormalMobile } from './StarIcon';\nimport { AnalyticsId, HTMLButtonProps, LanguageLocales } from '../../constants';\nimport { Breakpoint, useBreakpoint } from '../../hooks/useBreakpoint';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { HNDesignsystemFavoriteButton } from '../../resources/Resources';\nimport { useLanguage } from '../../utils/language';\nimport { isMutableRefObject } from '../../utils/refs';\n\nimport styles from './styles.module.scss';\n\nexport interface FavoriteButtonProps extends Omit<HTMLButtonProps, 'type'>, AriaAttributes {\n /** Determines if the FavoriteButton is checked */\n checked: boolean;\n /** Gives a unique id to the button */\n id?: string;\n /** Function that is called when clicked */\n onClick: (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;\n /** Resources for component */\n resources?: Partial<HNDesignsystemFavoriteButton>;\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}\n\nexport const FavoriteButton = React.forwardRef(function FavoriteButtonForwardedRef(\n props: FavoriteButtonProps,\n ref: React.ForwardedRef<HTMLButtonElement>\n) {\n const { checked, id, onClick, resources, tabIndex, testId, ...other } = props;\n\n const buttonWrapperClasses = classNames(styles.favoritebutton);\n const { refObject, isHovered, isActive } = usePseudoClasses<HTMLButtonElement>(isMutableRefObject(ref) ? ref : null);\n const breakpoint = useBreakpoint();\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n\n const mergedResources: HNDesignsystemFavoriteButton = {\n ...defaultResources,\n ...resources,\n ariaLabel: other['aria-label'] || resources?.ariaLabel || defaultResources.ariaLabel,\n };\n\n const isMobile = breakpoint <= Breakpoint.sm;\n\n const starIcon = ((): React.JSX.Element => {\n if (isMobile) {\n if (isHovered) {\n return starIconHoverMobile(checked, isActive);\n } else {\n return starIconNormalMobile(checked, isActive);\n }\n } else {\n if (isHovered) {\n return starIconHoverDesktop(checked, isActive);\n } else {\n return starIconNormalDesktop(checked, isActive);\n }\n }\n })();\n\n return (\n <button\n id={id}\n onClick={onClick}\n data-testid={testId}\n data-analyticsid={AnalyticsId.FavoriteButton}\n className={buttonWrapperClasses}\n ref={refObject}\n tabIndex={tabIndex}\n role=\"switch\"\n aria-checked={checked}\n type=\"button\"\n aria-label={mergedResources.ariaLabel}\n {...other}\n >\n <svg focusable={false} overflow=\"visible\" role=\"presentation\" viewBox={isMobile ? '0 0 41 41' : '0 0 61 61'}>\n {starIcon}\n </svg>\n </button>\n );\n});\n\nFavoriteButton.displayName = 'FavoriteButton';\n\nexport default FavoriteButton;\n","export * from './FavoriteButton';\n\nimport { FavoriteButton } from './FavoriteButton';\nexport default FavoriteButton;\n"],"mappings":";;;;;;;;;;;ACIA,MAAa,gBAAgB,aAA4D;AACvF,SAAQ,UAAR;EACE,KAAK,gBAAgB;EACrB,QACE,QAAO;;;ACNb,IAAM,eAAe;AACrB,IAAM,aAAa;AACnB,IAAM,YAAY;AAClB,IAAM,cAAc;AACpB,IAAM,eAAe;AAErB,IAAM,aAAa,WAAoB,UAAmB,cAA+B;AACvF,KAAI,UACF,KAAI,SACF,QAAO;UAEH,UACF,QAAO;KAEP,QAAO;UAIP,UACF,QAAO;KAEP,QAAO;;AAKb,IAAM,eAAe,UAAmB,cAA+B;AACrE,KAAI,SACF,QAAO;UAEH,UACF,QAAO;KAEP,QAAO;;AAKb,MAAa,wBAAwB,WAAoB,aAAyC;AAChG,QACE,qBAAA,UAAA,EAAA,UAAA,CACE,oBAAC,QAAA;EACC,GAAE;EACF,QAAO;EACP,MAAK;EACL,aAAY;EACZ,eAAc;EACd,WA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E,SAAS,IAAI,SAAS,WAAW,UAAU,QAAQ,GAAG,UAAU;CAExE,MAAM,uBAAuB,WAAW,OAAO,eAAe;CAC9D,MAAM,EAAE,WAAW,WAAW,aAAa,iBAAoC,mBAAmB,IAAI,GAAG,MAAM,KAAK;CACpH,MAAM,aAAa,eAAe;CAClC,MAAM,EAAE,aAAa,YAA6B,gBAAgB,UAAU;CAC5E,MAAM,mBAAmB,aAAa,SAAS;CAE/C,MAAMA,kBAAgD;EACpD,GAAG;EACH,GAAG;EACH,WAAW,MAAM,iBAAiB,WAAW,aAAa,iBAAiB;EAC5E;CAED,MAAM,WAAW,cAAc,WAAW;CAE1C,MAAM,kBAAqC;AACzC,MAAI,SACF,KAAI,UACF,QAAO,oBAAoB,SAAS,SAAS;MAE7C,QAAO,qBAAqB,SAAS,SAAS;WAG5C,UACF,QAAO,qBAAqB,SAAS,SAAS;MAE9C,QAAO,sBAAsB,SAAS,SAAS;KAGjD;AAEJ,QACE,oBAAC,UAAA;EACK;EACK;EACT,eAAa;EACb,oBAAkB,YAAY;EAC9B,WAAW;EACX,KAAK;EACK;EACV,MAAK;EACL,gBAAc;EACd,MAAK;EACL,cAAY,gBAAgB;EAC5B,GAAI;YAEJ,oBAAC,OAAA;GAAI,WAAW;GAAO,UAAS;GAAU,MAAK;GAAe,SAAS,WAAW,cAAc;aAC7F;IACG;GACC;EAEX;AAEF,eAAe,cAAc;ACrF7B,IAAA,yBAAe"}
|
|
@@ -21,7 +21,7 @@ import { t as Close_default } from "../../Close.js";
|
|
|
21
21
|
import "../../floating-ui.react.js";
|
|
22
22
|
import { n as PopOverVariant, t as PopOver_default } from "../../PopOver.js";
|
|
23
23
|
import React from "react";
|
|
24
|
-
import
|
|
24
|
+
import classNames from "classnames";
|
|
25
25
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
26
26
|
import styles from "./styles.module.scss";
|
|
27
27
|
var HN_Designsystem_HelpBubble_nb_NO_default = { ariaLabel: "Hjelpetekst" };
|
|
@@ -42,8 +42,8 @@ var HelpBubble = React.forwardRef((props, ref) => {
|
|
|
42
42
|
...resources,
|
|
43
43
|
ariaLabel: props.ariaLabel ?? resources?.ariaLabel ?? defaultResources.ariaLabel
|
|
44
44
|
};
|
|
45
|
-
const helpBubbleClasses =
|
|
46
|
-
const contentClasses =
|
|
45
|
+
const helpBubbleClasses = classNames(styles.helpbubble, className);
|
|
46
|
+
const contentClasses = classNames(styles.helpbubble__content);
|
|
47
47
|
const renderLink = () => {
|
|
48
48
|
if (onLinkClick && linkText) return /* @__PURE__ */ jsx("button", {
|
|
49
49
|
className: styles.helpbubble__link,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["mergedResources: HNDesignsystemHelpBubble"],"sources":["../../../src/resources/HN.Designsystem.HelpBubble.nb-NO.json","../../../src/components/HelpBubble/resourceHelper.ts","../../../src/components/HelpBubble/HelpBubble.tsx","../../../src/components/HelpBubble/index.ts"],"sourcesContent":["{\n \"ariaLabel\": \"Hjelpetekst\"\n}\n","import { LanguageLocales } from '../../constants';\nimport nbNO from '../../resources/HN.Designsystem.HelpBubble.nb-NO.json';\nimport { HNDesignsystemHelpBubble } from '../../resources/Resources';\n\nexport const getResources = (language: LanguageLocales): HNDesignsystemHelpBubble => {\n switch (language) {\n case LanguageLocales.NORWEGIAN:\n default:\n return nbNO;\n }\n};\n","import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, LanguageLocales } from '../../constants';\nimport { HNDesignsystemHelpBubble } from '../../resources/Resources';\nimport { useLanguage } from '../../utils/language';\nimport AnchorLink, { AnchorLinkTargets } from '../AnchorLink';\nimport Close from '../Close';\nimport PopOver, { PopOverProps, PopOverVariant } from '../PopOver';\nimport { getResources } from './resourceHelper';\n\nimport styles from './styles.module.scss';\n\nexport const HelpBubbleVariant = PopOverVariant;\n\nexport interface HelpBubbleProps extends Pick<PopOverProps, 'children' | 'variant' | 'controllerRef' | 'role'> {\n /** Sets aria-label of the bubble. */\n ariaLabel?: string;\n /** Sets aria-labelledby of the bubble. */\n ariaLabelledById?: string;\n /** Id of the HelpBubble */\n helpBubbleId?: string;\n /** Content shown inside HelpBubble. */\n children: React.ReactNode;\n /** Ref for the element the HelpBubble is placed upon */\n controllerRef: React.RefObject<HTMLElement | SVGSVGElement>;\n /** Adds custom classes to the element. */\n className?: string;\n /** Determines the placement of the helpbubble. Default: automatic positioning. */\n variant?: keyof typeof HelpBubbleVariant;\n /** Show the bubble. Default: false. */\n showBubble?: boolean;\n /** Hide the close button in the bubble. */\n noCloseButton?: boolean;\n /** Visible text on the link. */\n linkText?: string;\n /** Url the link leads to */\n linkUrl?: string;\n /** Sets the target type of the link. _blank adds an arrow icon at the end of the link */\n linkTarget?: AnchorLinkTargets;\n /** Function is called when link is clicked */\n onLinkClick?: () => void;\n /** Function is called when user clicks the button */\n onClose?: () => void;\n /** aria-label to be passed onto Close */\n closeAriaLabel?: string;\n /** Resources for the component */\n resources?: Partial<HNDesignsystemHelpBubble>;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nconst HelpBubble = React.forwardRef<HTMLDivElement | SVGSVGElement, HelpBubbleProps>((props, ref) => {\n const {\n ariaLabelledById,\n children,\n className = '',\n noCloseButton,\n linkText = 'Mer hjelp',\n linkUrl,\n linkTarget,\n onLinkClick,\n onClose,\n closeAriaLabel,\n // Props passed on to PopOver\n showBubble,\n helpBubbleId,\n variant,\n controllerRef,\n resources,\n testId,\n } = props;\n\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n\n if (!showBubble) {\n return null;\n }\n\n const defaultResources = getResources(language);\n const mergedResources: HNDesignsystemHelpBubble = {\n ...defaultResources,\n ...resources,\n ariaLabel: props.ariaLabel ?? resources?.ariaLabel ?? defaultResources.ariaLabel,\n };\n\n const helpBubbleClasses = classNames(styles.helpbubble, className);\n const contentClasses = classNames(styles.helpbubble__content);\n\n const renderLink = (): JSX.Element | undefined => {\n if (onLinkClick && linkText) {\n return (\n <button className={styles.helpbubble__link} onClick={onLinkClick} type=\"button\">\n {linkText}\n </button>\n );\n } else if (linkUrl && linkText) {\n return (\n <AnchorLink href={linkUrl} target={linkTarget}>\n {linkText}\n </AnchorLink>\n );\n }\n };\n\n const renderCloseButton = (): JSX.Element | undefined => {\n if (noCloseButton) {\n return;\n }\n return <Close small color=\"plum\" onClick={onClose} ariaLabel={closeAriaLabel} className={styles.helpbubble__close} />;\n };\n\n return (\n <PopOver\n ariaLabel={mergedResources.ariaLabel}\n ariaLabelledById={ariaLabelledById}\n id={helpBubbleId}\n variant={variant}\n controllerRef={controllerRef}\n role=\"dialog\"\n ref={ref}\n show={showBubble}\n testId={testId}\n >\n <div className={helpBubbleClasses} data-analyticsid={AnalyticsId.HelpBubble}>\n {renderCloseButton()}\n <div className={contentClasses}>\n {children}\n {renderLink()}\n </div>\n </div>\n </PopOver>\n );\n});\n\nHelpBubble.displayName = 'HelpBubble';\n\nexport default HelpBubble;\n","import HelpBubble from './HelpBubble';\nexport * from './HelpBubble';\nexport default HelpBubble;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;ACIA,MAAa,gBAAgB,aAAwD;AACnF,SAAQ,UAAR;EACE,KAAK,gBAAgB;EACrB,QACE,QAAO;;;ACMb,MAAa,oBAAoB;AAuCjC,IAAM,aAAa,MAAM,YAA6D,OAAO,QAAQ;CACnG,MAAM,EACJ,kBACA,UACA,YAAY,IACZ,eACA,WAAW,aACX,SACA,YACA,aACA,SACA,gBAEA,YACA,cACA,SACA,eACA,WACA,WACE;CAEJ,MAAM,EAAE,aAAa,YAA6B,gBAAgB,UAAU;AAE5E,KAAI,CAAC,WACH,QAAO;CAGT,MAAM,mBAAmB,aAAa,SAAS;CAC/C,MAAMA,kBAA4C;EAChD,GAAG;EACH,GAAG;EACH,WAAW,MAAM,aAAa,WAAW,aAAa,iBAAiB;EACxE;CAED,MAAM,oBAAoB,
|
|
1
|
+
{"version":3,"file":"index.js","names":["mergedResources: HNDesignsystemHelpBubble"],"sources":["../../../src/resources/HN.Designsystem.HelpBubble.nb-NO.json","../../../src/components/HelpBubble/resourceHelper.ts","../../../src/components/HelpBubble/HelpBubble.tsx","../../../src/components/HelpBubble/index.ts"],"sourcesContent":["{\n \"ariaLabel\": \"Hjelpetekst\"\n}\n","import { LanguageLocales } from '../../constants';\nimport nbNO from '../../resources/HN.Designsystem.HelpBubble.nb-NO.json';\nimport { HNDesignsystemHelpBubble } from '../../resources/Resources';\n\nexport const getResources = (language: LanguageLocales): HNDesignsystemHelpBubble => {\n switch (language) {\n case LanguageLocales.NORWEGIAN:\n default:\n return nbNO;\n }\n};\n","import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, LanguageLocales } from '../../constants';\nimport { HNDesignsystemHelpBubble } from '../../resources/Resources';\nimport { useLanguage } from '../../utils/language';\nimport AnchorLink, { AnchorLinkTargets } from '../AnchorLink';\nimport Close from '../Close';\nimport PopOver, { PopOverProps, PopOverVariant } from '../PopOver';\nimport { getResources } from './resourceHelper';\n\nimport styles from './styles.module.scss';\n\nexport const HelpBubbleVariant = PopOverVariant;\n\nexport interface HelpBubbleProps extends Pick<PopOverProps, 'children' | 'variant' | 'controllerRef' | 'role'> {\n /** Sets aria-label of the bubble. */\n ariaLabel?: string;\n /** Sets aria-labelledby of the bubble. */\n ariaLabelledById?: string;\n /** Id of the HelpBubble */\n helpBubbleId?: string;\n /** Content shown inside HelpBubble. */\n children: React.ReactNode;\n /** Ref for the element the HelpBubble is placed upon */\n controllerRef: React.RefObject<HTMLElement | SVGSVGElement>;\n /** Adds custom classes to the element. */\n className?: string;\n /** Determines the placement of the helpbubble. Default: automatic positioning. */\n variant?: keyof typeof HelpBubbleVariant;\n /** Show the bubble. Default: false. */\n showBubble?: boolean;\n /** Hide the close button in the bubble. */\n noCloseButton?: boolean;\n /** Visible text on the link. */\n linkText?: string;\n /** Url the link leads to */\n linkUrl?: string;\n /** Sets the target type of the link. _blank adds an arrow icon at the end of the link */\n linkTarget?: AnchorLinkTargets;\n /** Function is called when link is clicked */\n onLinkClick?: () => void;\n /** Function is called when user clicks the button */\n onClose?: () => void;\n /** aria-label to be passed onto Close */\n closeAriaLabel?: string;\n /** Resources for the component */\n resources?: Partial<HNDesignsystemHelpBubble>;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nconst HelpBubble = React.forwardRef<HTMLDivElement | SVGSVGElement, HelpBubbleProps>((props, ref) => {\n const {\n ariaLabelledById,\n children,\n className = '',\n noCloseButton,\n linkText = 'Mer hjelp',\n linkUrl,\n linkTarget,\n onLinkClick,\n onClose,\n closeAriaLabel,\n // Props passed on to PopOver\n showBubble,\n helpBubbleId,\n variant,\n controllerRef,\n resources,\n testId,\n } = props;\n\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n\n if (!showBubble) {\n return null;\n }\n\n const defaultResources = getResources(language);\n const mergedResources: HNDesignsystemHelpBubble = {\n ...defaultResources,\n ...resources,\n ariaLabel: props.ariaLabel ?? resources?.ariaLabel ?? defaultResources.ariaLabel,\n };\n\n const helpBubbleClasses = classNames(styles.helpbubble, className);\n const contentClasses = classNames(styles.helpbubble__content);\n\n const renderLink = (): JSX.Element | undefined => {\n if (onLinkClick && linkText) {\n return (\n <button className={styles.helpbubble__link} onClick={onLinkClick} type=\"button\">\n {linkText}\n </button>\n );\n } else if (linkUrl && linkText) {\n return (\n <AnchorLink href={linkUrl} target={linkTarget}>\n {linkText}\n </AnchorLink>\n );\n }\n };\n\n const renderCloseButton = (): JSX.Element | undefined => {\n if (noCloseButton) {\n return;\n }\n return <Close small color=\"plum\" onClick={onClose} ariaLabel={closeAriaLabel} className={styles.helpbubble__close} />;\n };\n\n return (\n <PopOver\n ariaLabel={mergedResources.ariaLabel}\n ariaLabelledById={ariaLabelledById}\n id={helpBubbleId}\n variant={variant}\n controllerRef={controllerRef}\n role=\"dialog\"\n ref={ref}\n show={showBubble}\n testId={testId}\n >\n <div className={helpBubbleClasses} data-analyticsid={AnalyticsId.HelpBubble}>\n {renderCloseButton()}\n <div className={contentClasses}>\n {children}\n {renderLink()}\n </div>\n </div>\n </PopOver>\n );\n});\n\nHelpBubble.displayName = 'HelpBubble';\n\nexport default HelpBubble;\n","import HelpBubble from './HelpBubble';\nexport * from './HelpBubble';\nexport default HelpBubble;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;ACIA,MAAa,gBAAgB,aAAwD;AACnF,SAAQ,UAAR;EACE,KAAK,gBAAgB;EACrB,QACE,QAAO;;;ACMb,MAAa,oBAAoB;AAuCjC,IAAM,aAAa,MAAM,YAA6D,OAAO,QAAQ;CACnG,MAAM,EACJ,kBACA,UACA,YAAY,IACZ,eACA,WAAW,aACX,SACA,YACA,aACA,SACA,gBAEA,YACA,cACA,SACA,eACA,WACA,WACE;CAEJ,MAAM,EAAE,aAAa,YAA6B,gBAAgB,UAAU;AAE5E,KAAI,CAAC,WACH,QAAO;CAGT,MAAM,mBAAmB,aAAa,SAAS;CAC/C,MAAMA,kBAA4C;EAChD,GAAG;EACH,GAAG;EACH,WAAW,MAAM,aAAa,WAAW,aAAa,iBAAiB;EACxE;CAED,MAAM,oBAAoB,WAAW,OAAO,YAAY,UAAU;CAClE,MAAM,iBAAiB,WAAW,OAAO,oBAAoB;CAE7D,MAAM,mBAA4C;AAChD,MAAI,eAAe,SACjB,QACE,oBAAC,UAAA;GAAO,WAAW,OAAO;GAAkB,SAAS;GAAa,MAAK;aACpE;IACM;WAEF,WAAW,SACpB,QACE,oBAAC,oBAAA;GAAW,MAAM;GAAS,QAAQ;aAChC;IACU;;CAKnB,MAAM,0BAAmD;AACvD,MAAI,cACF;AAEF,SAAO,oBAAC,eAAA;GAAM,OAAA;GAAM,OAAM;GAAO,SAAS;GAAS,WAAW;GAAgB,WAAW,OAAO;IAAqB;;AAGvH,QACE,oBAAC,iBAAA;EACC,WAAW,gBAAgB;EACT;EAClB,IAAI;EACK;EACM;EACf,MAAK;EACA;EACL,MAAM;EACE;YAER,qBAAC,OAAA;GAAI,WAAW;GAAmB,oBAAkB,YAAY;cAC9D,mBAAmB,EACpB,qBAAC,OAAA;IAAI,WAAW;eACb,UACA,YAAY,CAAA;KACT,CAAA;IACF;GACE;EAEZ;AAEF,WAAW,cAAc;ACtIzB,IAAA,qBDwIe"}
|
|
@@ -33,12 +33,12 @@ import "../../Title2.js";
|
|
|
33
33
|
import { t as HighlightPanel_default } from "../../HighlightPanel.js";
|
|
34
34
|
import { t as HandWaving_default } from "../../HandWaving.js";
|
|
35
35
|
import React from "react";
|
|
36
|
-
import
|
|
36
|
+
import classNames from "classnames";
|
|
37
37
|
import { jsx } from "react/jsx-runtime";
|
|
38
38
|
import styles from "./styles.module.scss";
|
|
39
39
|
var HelpPanel = ({ className, variant = "normal", testId, children, title }) => {
|
|
40
40
|
return /* @__PURE__ */ jsx(HighlightPanel_default, {
|
|
41
|
-
className:
|
|
41
|
+
className: classNames([styles["help-panel"]], className),
|
|
42
42
|
testId,
|
|
43
43
|
svgIcon: HandWaving_default,
|
|
44
44
|
title,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["HelpPanel: React.FC<HelpPanelProps>"],"sources":["../../../src/components/HelpPanel/HelpPanel.tsx","../../../src/components/HelpPanel/index.ts"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport HighlightPanel from '../HighlightPanel';\nimport HandWaving from '../Icons/HandWaving';\n\nimport styles from './styles.module.scss';\n\nexport type HelpPanelVariants = 'normal' | 'compact';\n\nexport interface HelpPanelProps {\n /** What's in the box? */\n children: React.ReactNode;\n /** If set the compact styling will be used */\n variant?: HelpPanelVariants;\n /** Adds custom classes to the element. */\n className?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Sets title if needed */\n title?: string;\n}\n\nconst HelpPanel: React.FC<HelpPanelProps> = ({ className, variant = 'normal', testId, children, title }) => {\n return (\n <HighlightPanel\n className={classNames([styles['help-panel']], className)}\n testId={testId}\n svgIcon={HandWaving}\n title={title}\n variant={variant}\n >\n {children}\n </HighlightPanel>\n );\n};\n\nexport default HelpPanel;\n","import HelpPanel from './HelpPanel';\nexport * from './HelpPanel';\nexport default HelpPanel;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,IAAMA,aAAuC,EAAE,WAAW,UAAU,UAAU,QAAQ,UAAU,YAAY;AAC1G,QACE,oBAAC,wBAAA;EACC,WAAW,
|
|
1
|
+
{"version":3,"file":"index.js","names":["HelpPanel: React.FC<HelpPanelProps>"],"sources":["../../../src/components/HelpPanel/HelpPanel.tsx","../../../src/components/HelpPanel/index.ts"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport HighlightPanel from '../HighlightPanel';\nimport HandWaving from '../Icons/HandWaving';\n\nimport styles from './styles.module.scss';\n\nexport type HelpPanelVariants = 'normal' | 'compact';\n\nexport interface HelpPanelProps {\n /** What's in the box? */\n children: React.ReactNode;\n /** If set the compact styling will be used */\n variant?: HelpPanelVariants;\n /** Adds custom classes to the element. */\n className?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Sets title if needed */\n title?: string;\n}\n\nconst HelpPanel: React.FC<HelpPanelProps> = ({ className, variant = 'normal', testId, children, title }) => {\n return (\n <HighlightPanel\n className={classNames([styles['help-panel']], className)}\n testId={testId}\n svgIcon={HandWaving}\n title={title}\n variant={variant}\n >\n {children}\n </HighlightPanel>\n );\n};\n\nexport default HelpPanel;\n","import HelpPanel from './HelpPanel';\nexport * from './HelpPanel';\nexport default HelpPanel;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,IAAMA,aAAuC,EAAE,WAAW,UAAU,UAAU,QAAQ,UAAU,YAAY;AAC1G,QACE,oBAAC,wBAAA;EACC,WAAW,WAAW,CAAC,OAAO,cAAc,EAAE,UAAU;EAChD;EACR,SAAS;EACF;EACE;EAER;GACc;;AChCrB,IAAA,oBDoCe"}
|
|
@@ -4,7 +4,7 @@ import { n as mergeRefs } from "../../refs.js";
|
|
|
4
4
|
import { n as getAriaLabelAttributes } from "../../accessibility.js";
|
|
5
5
|
import { n as HelpTriggerIconInternal } from "../../HelpTriggerIcon.js";
|
|
6
6
|
import React from "react";
|
|
7
|
-
import
|
|
7
|
+
import classNames from "classnames";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import styles from "./styles.module.scss";
|
|
10
10
|
var HelpTriggerInline = React.forwardRef(({ ariaLabel, ariaLabelledById, children, className, testId, weight = "normal", ...rest }, ref) => {
|
|
@@ -12,7 +12,7 @@ var HelpTriggerInline = React.forwardRef(({ ariaLabel, ariaLabelledById, childre
|
|
|
12
12
|
label: ariaLabel,
|
|
13
13
|
id: ariaLabelledById
|
|
14
14
|
});
|
|
15
|
-
const helpTriggerInlineStyles =
|
|
15
|
+
const helpTriggerInlineStyles = classNames(styles["help-trigger-inline"], className);
|
|
16
16
|
const { refObject, isHovered } = usePseudoClasses(ref);
|
|
17
17
|
return /* @__PURE__ */ jsxs("button", {
|
|
18
18
|
"aria-label": ariaLabel,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/HelpTriggerInline/HelpTriggerInline.tsx","../../../src/components/HelpTriggerInline/index.ts"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { getAriaLabelAttributes } from '../../utils/accessibility';\nimport { mergeRefs } from '../../utils/refs';\nimport { HelpTriggerIconInternal, HelpTriggerWeights } from '../HelpTriggerIcon';\n\nimport styles from './styles.module.scss';\n\nexport interface HelpTriggerInlineProps\n extends Pick<React.InputHTMLAttributes<HTMLButtonElement>, 'onClick' | 'aria-haspopup' | 'aria-controls' | 'aria-expanded'> {\n /**\n * Sets aria-label of the trigger. ariaLabel or ariaLabelledById MUST be set!\n */\n ariaLabel?: string;\n /**\n * Sets aria-labelledby of the trigger. ariaLabel or ariaLabelledById MUST be set!\n */\n ariaLabelledById?: string;\n /** Sets the text content of the HelpTriggerInline. */\n children: string;\n /**\n * Sets the colors of the help trigger. Default: normal.\n */\n weight?: HelpTriggerWeights;\n /**\n * Classname will be applied to the button element.\n */\n className?: string;\n /**\n * Optional test id.\n */\n testId?: string;\n}\n\nconst HelpTriggerInline = React.forwardRef<HTMLButtonElement, HelpTriggerInlineProps>(\n ({ ariaLabel, ariaLabelledById, children, className, testId, weight = 'normal', ...rest }, ref) => {\n const ariaLabelAttributes = getAriaLabelAttributes({ label: ariaLabel, id: ariaLabelledById });\n const helpTriggerInlineStyles = classNames(styles['help-trigger-inline'], className);\n const { refObject, isHovered } = usePseudoClasses<HTMLButtonElement>(ref as React.RefObject<HTMLButtonElement>);\n\n return (\n <button\n aria-label={ariaLabel}\n type=\"button\"\n data-testid={testId}\n data-analyticsid={AnalyticsId.HelpTriggerInline}\n className={helpTriggerInlineStyles}\n ref={mergeRefs([refObject, ref])}\n {...ariaLabelAttributes}\n {...rest}\n >\n <span className={styles['help-trigger-inline__text']}>{children}</span>\n <HelpTriggerIconInternal weight={weight} size={'inherit'} htmlMarkup={'span'} isHovered={isHovered} />\n </button>\n );\n }\n);\n\nHelpTriggerInline.displayName = 'HelpTriggerInline';\n\nexport default HelpTriggerInline;\n","import HelpTriggerInline from './HelpTriggerInline';\nexport * from './HelpTriggerInline';\nexport default HelpTriggerInline;\n"],"mappings":";;;;;;;;;AAsCA,IAAM,oBAAoB,MAAM,YAC7B,EAAE,WAAW,kBAAkB,UAAU,WAAW,QAAQ,SAAS,UAAU,GAAG,QAAQ,QAAQ;CACjG,MAAM,sBAAsB,uBAAuB;EAAE,OAAO;EAAW,IAAI;EAAkB,CAAC;CAC9F,MAAM,0BAA0B,
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/components/HelpTriggerInline/HelpTriggerInline.tsx","../../../src/components/HelpTriggerInline/index.ts"],"sourcesContent":["import React from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { getAriaLabelAttributes } from '../../utils/accessibility';\nimport { mergeRefs } from '../../utils/refs';\nimport { HelpTriggerIconInternal, HelpTriggerWeights } from '../HelpTriggerIcon';\n\nimport styles from './styles.module.scss';\n\nexport interface HelpTriggerInlineProps\n extends Pick<React.InputHTMLAttributes<HTMLButtonElement>, 'onClick' | 'aria-haspopup' | 'aria-controls' | 'aria-expanded'> {\n /**\n * Sets aria-label of the trigger. ariaLabel or ariaLabelledById MUST be set!\n */\n ariaLabel?: string;\n /**\n * Sets aria-labelledby of the trigger. ariaLabel or ariaLabelledById MUST be set!\n */\n ariaLabelledById?: string;\n /** Sets the text content of the HelpTriggerInline. */\n children: string;\n /**\n * Sets the colors of the help trigger. Default: normal.\n */\n weight?: HelpTriggerWeights;\n /**\n * Classname will be applied to the button element.\n */\n className?: string;\n /**\n * Optional test id.\n */\n testId?: string;\n}\n\nconst HelpTriggerInline = React.forwardRef<HTMLButtonElement, HelpTriggerInlineProps>(\n ({ ariaLabel, ariaLabelledById, children, className, testId, weight = 'normal', ...rest }, ref) => {\n const ariaLabelAttributes = getAriaLabelAttributes({ label: ariaLabel, id: ariaLabelledById });\n const helpTriggerInlineStyles = classNames(styles['help-trigger-inline'], className);\n const { refObject, isHovered } = usePseudoClasses<HTMLButtonElement>(ref as React.RefObject<HTMLButtonElement>);\n\n return (\n <button\n aria-label={ariaLabel}\n type=\"button\"\n data-testid={testId}\n data-analyticsid={AnalyticsId.HelpTriggerInline}\n className={helpTriggerInlineStyles}\n ref={mergeRefs([refObject, ref])}\n {...ariaLabelAttributes}\n {...rest}\n >\n <span className={styles['help-trigger-inline__text']}>{children}</span>\n <HelpTriggerIconInternal weight={weight} size={'inherit'} htmlMarkup={'span'} isHovered={isHovered} />\n </button>\n );\n }\n);\n\nHelpTriggerInline.displayName = 'HelpTriggerInline';\n\nexport default HelpTriggerInline;\n","import HelpTriggerInline from './HelpTriggerInline';\nexport * from './HelpTriggerInline';\nexport default HelpTriggerInline;\n"],"mappings":";;;;;;;;;AAsCA,IAAM,oBAAoB,MAAM,YAC7B,EAAE,WAAW,kBAAkB,UAAU,WAAW,QAAQ,SAAS,UAAU,GAAG,QAAQ,QAAQ;CACjG,MAAM,sBAAsB,uBAAuB;EAAE,OAAO;EAAW,IAAI;EAAkB,CAAC;CAC9F,MAAM,0BAA0B,WAAW,OAAO,wBAAwB,UAAU;CACpF,MAAM,EAAE,WAAW,cAAc,iBAAoC,IAA0C;AAE/G,QACE,qBAAC,UAAA;EACC,cAAY;EACZ,MAAK;EACL,eAAa;EACb,oBAAkB,YAAY;EAC9B,WAAW;EACX,KAAK,UAAU,CAAC,WAAW,IAAI,CAAC;EAChC,GAAI;EACJ,GAAI;aAEJ,oBAAC,QAAA;GAAK,WAAW,OAAO;GAA+B;IAAgB,EACvE,oBAAC,yBAAA;GAAgC;GAAQ,MAAM;GAAW,YAAY;GAAmB;IAAa,CAAA;GAC/F;EAGd;AAED,kBAAkB,cAAc;AC5DhC,IAAA,4BD8De"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
+
import { HNDesignsystemLinkList } from '../../resources/Resources';
|
|
2
3
|
import { PaletteNames } from '../../theme/palette';
|
|
3
4
|
import { ElementHeaderType } from '../ElementHeader/ElementHeader';
|
|
4
5
|
import { ListEditModeItemProps } from '../ListEditMode';
|
|
@@ -36,6 +37,8 @@ export interface LinkListProps {
|
|
|
36
37
|
* Enables ListEditMode
|
|
37
38
|
*/
|
|
38
39
|
editMode?: boolean;
|
|
40
|
+
/** Resources for component */
|
|
41
|
+
resources?: Partial<HNDesignsystemLinkList>;
|
|
39
42
|
}
|
|
40
43
|
type Modify<T, R> = Omit<T, keyof R> & R;
|
|
41
44
|
export type LinkProps = Modify<React.HTMLAttributes<HTMLAnchorElement | HTMLButtonElement>, {
|
|
@@ -59,6 +62,10 @@ export type LinkProps = Modify<React.HTMLAttributes<HTMLAnchorElement | HTMLButt
|
|
|
59
62
|
testId?: string;
|
|
60
63
|
/** Highlights text. Override if different from list */
|
|
61
64
|
highlightText?: string;
|
|
65
|
+
/** Resources for component */
|
|
66
|
+
resources?: Partial<HNDesignsystemLinkList>;
|
|
67
|
+
/** @experimental id for content (only used in edit mode for aria-describedby) */
|
|
68
|
+
contentId?: string;
|
|
62
69
|
}> & Pick<LinkListProps, 'color' | 'size' | 'variant'> & ListEditModeItemProps;
|
|
63
70
|
export declare const Link: LinkType;
|
|
64
71
|
export declare const LinkList: CompoundComponent;
|
|
@@ -9,18 +9,23 @@ export interface ListEditModeProps extends ListEditModeItemProps {
|
|
|
9
9
|
variant?: LinkListVariant | ExpanderListVariant;
|
|
10
10
|
/** Sets color */
|
|
11
11
|
color?: LinkListColors | ExpanderListColors;
|
|
12
|
+
/** Aria label for delete button */
|
|
13
|
+
deleteButtonAriaLabel?: string;
|
|
12
14
|
}
|
|
13
15
|
export interface ListEditModeItemProps {
|
|
14
16
|
/** Enables ListEditMode */
|
|
15
17
|
editMode?: boolean;
|
|
16
18
|
/** Callback for delete button */
|
|
17
19
|
onDelete?: (e?: React.MouseEvent<HTMLElement, MouseEvent>) => void;
|
|
20
|
+
contentId?: string;
|
|
18
21
|
}
|
|
19
22
|
export declare const listEditModeWrapperClassnames: string;
|
|
20
|
-
export declare const IconButton: ({ icon, color, onClick, }: {
|
|
23
|
+
export declare const IconButton: ({ icon, color, onClick, ariaLabel, ariaDescribedby, }: {
|
|
21
24
|
icon: SvgIcon;
|
|
22
25
|
color: "red" | "blue";
|
|
23
26
|
onClick?: (e?: React.MouseEvent<HTMLElement, MouseEvent>) => void;
|
|
27
|
+
ariaLabel?: string;
|
|
28
|
+
ariaDescribedby?: string;
|
|
24
29
|
}) => React.JSX.Element;
|
|
25
30
|
export declare const ListEditModeItem: {
|
|
26
31
|
(props: ListEditModeProps): React.JSX.Element;
|
|
@@ -31,10 +31,6 @@
|
|
|
31
31
|
width: 100%;
|
|
32
32
|
align-items: center;
|
|
33
33
|
|
|
34
|
-
li {
|
|
35
|
-
width: 100%;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
34
|
&--neutral,
|
|
39
35
|
&--white {
|
|
40
36
|
border-bottom: 1px solid var(--color-base-border-onlight);
|
|
@@ -61,15 +57,15 @@
|
|
|
61
57
|
}
|
|
62
58
|
|
|
63
59
|
&--line {
|
|
64
|
-
|
|
60
|
+
> * {
|
|
65
61
|
border: none !important;
|
|
66
62
|
}
|
|
67
63
|
}
|
|
68
64
|
|
|
69
65
|
&--fill {
|
|
70
|
-
|
|
71
|
-
margin-top: 8px;
|
|
72
|
-
margin-bottom: 8px;
|
|
66
|
+
> * {
|
|
67
|
+
margin-top: 8px !important;
|
|
68
|
+
margin-bottom: 8px !important;
|
|
73
69
|
}
|
|
74
70
|
}
|
|
75
71
|
|
|
@@ -2,7 +2,7 @@ import { t as uuid } from "../../uuid.js";
|
|
|
2
2
|
import "../../environment.js";
|
|
3
3
|
import { c as ZIndex, n as AnalyticsId } from "../../constants2.js";
|
|
4
4
|
import React, { useEffect, useRef, useState } from "react";
|
|
5
|
-
import
|
|
5
|
+
import classNames from "classnames";
|
|
6
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
import loaderStyles from "./styles.module.scss";
|
|
8
8
|
let Overlay = /* @__PURE__ */ function(Overlay$1) {
|
|
@@ -21,19 +21,19 @@ var Loader = (props) => {
|
|
|
21
21
|
const isSmall = size === "small";
|
|
22
22
|
const isMedium = size === "medium";
|
|
23
23
|
const isLarge = size === "large";
|
|
24
|
-
const loaderWrapperClasses =
|
|
24
|
+
const loaderWrapperClasses = classNames({
|
|
25
25
|
[loaderStyles["loader-wrapper--center"]]: center,
|
|
26
26
|
[loaderStyles["loader-wrapper--overlay"]]: overlay,
|
|
27
27
|
[loaderStyles["loader-wrapper--overlay-screen"]]: overlay === Overlay.screen,
|
|
28
28
|
[loaderStyles["loader-wrapper--overlay-parent"]]: overlay === Overlay.parent && display,
|
|
29
29
|
[loaderStyles["loader-wrapper--inline"]]: inline && display
|
|
30
30
|
});
|
|
31
|
-
const loaderClasses =
|
|
31
|
+
const loaderClasses = classNames(loaderStyles.loader, {
|
|
32
32
|
[loaderStyles["loader--small"]]: isSmall,
|
|
33
33
|
[loaderStyles["loader--medium"]]: isMedium,
|
|
34
34
|
[loaderStyles["loader--large"]]: isLarge
|
|
35
35
|
}, className);
|
|
36
|
-
const loaderDotClasses =
|
|
36
|
+
const loaderDotClasses = classNames(loaderStyles.loader__dot, {
|
|
37
37
|
[loaderStyles["loader__dot--small"]]: isSmall,
|
|
38
38
|
[loaderStyles["loader__dot--medium"]]: isMedium,
|
|
39
39
|
[loaderStyles["loader__dot--large"]]: isLarge,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Loader: React.FC<LoaderProps>"],"sources":["../../../src/components/Loader/Loader.tsx","../../../src/components/Loader/index.ts"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, ZIndex } from '../../constants';\nimport { PaletteNames } from '../../theme/palette';\nimport { uuid } from '../../utils/uuid';\n\nimport loaderStyles from './styles.module.scss';\n\nexport type LoaderColors = PaletteNames;\nexport type LoaderSizes = 'tiny' | 'small' | 'medium' | 'large';\nexport enum Overlay {\n screen = 'screen',\n parent = 'parent',\n}\n\nexport interface LoaderProps {\n /** Sets the color of the loader. If overlay is used, the color will always be white. */\n color?: LoaderColors;\n /**\tAdds custom classes to the element. */\n className?: string;\n /** Changes the size of the loader. */\n size?: LoaderSizes;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** id of the label */\n labelId?: string;\n /** Centers the loader in a container */\n center?: boolean;\n /** Inline the loader so it can be used in a span or paragraph */\n inline?: boolean;\n /** Loader is displayed with grey background covering the entire screen */\n overlay?: keyof typeof Overlay;\n /** Individual id for loading icon (aria-labelledby). */\n ariaLabelledById?: string;\n /** String that labels the current loading element */\n ariaLabel?: string;\n}\n\nconst Loader: React.FC<LoaderProps> = props => {\n const {\n overlay,\n size = 'small',\n className = '',\n labelId = uuid(),\n testId,\n center,\n inline,\n ariaLabelledById,\n ariaLabel = 'Laster inn',\n } = props;\n const color = props.overlay ? 'white' : props.color || 'neutral';\n\n const showLoader = (): boolean => {\n if (overlay === Overlay.parent || inline) {\n return false;\n }\n\n return true;\n };\n\n const [display, setDisplay] = useState(showLoader());\n\n const isSmall = size === 'small';\n const isMedium = size === 'medium';\n const isLarge = size === 'large';\n\n const loaderWrapperClasses = classNames({\n [loaderStyles['loader-wrapper--center']]: center,\n [loaderStyles['loader-wrapper--overlay']]: overlay,\n [loaderStyles['loader-wrapper--overlay-screen']]: overlay === Overlay.screen,\n [loaderStyles['loader-wrapper--overlay-parent']]: overlay === Overlay.parent && display,\n [loaderStyles['loader-wrapper--inline']]: inline && display,\n });\n const loaderClasses = classNames(\n loaderStyles.loader,\n {\n [loaderStyles['loader--small']]: isSmall,\n [loaderStyles['loader--medium']]: isMedium,\n [loaderStyles['loader--large']]: isLarge,\n },\n className\n );\n const loaderDotClasses = classNames(loaderStyles.loader__dot, {\n [loaderStyles['loader__dot--small']]: isSmall,\n [loaderStyles['loader__dot--medium']]: isMedium,\n [loaderStyles['loader__dot--large']]: isLarge,\n [loaderStyles['loader__dot--banana']]: color === 'banana',\n [loaderStyles['loader__dot--cherry']]: color === 'cherry',\n [loaderStyles['loader__dot--kiwi']]: color === 'kiwi',\n [loaderStyles['loader__dot--neutral']]: color === 'neutral',\n [loaderStyles['loader__dot--plum']]: color === 'plum',\n [loaderStyles['loader__dot--black']]: color === 'black',\n [loaderStyles['loader__dot--white']]: color === 'white',\n });\n\n const wrapperRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (overlay === Overlay.parent && wrapperRef.current?.parentElement?.style) {\n wrapperRef.current.parentElement.style.position = 'relative';\n setDisplay(true);\n }\n\n if (inline && wrapperRef.current?.parentElement?.style) {\n wrapperRef.current.parentElement.style.display = 'flex';\n setDisplay(true);\n }\n }, []);\n\n return (\n <div className={loaderWrapperClasses} ref={wrapperRef} style={overlay === Overlay.screen ? { zIndex: ZIndex.OverlayScreen } : {}}>\n {display && (\n <div\n data-testid={testId}\n data-analyticsid={AnalyticsId.Loader}\n role=\"progressbar\"\n aria-labelledby={ariaLabelledById || labelId}\n className={loaderClasses}\n >\n <div className={loaderDotClasses} />\n <div className={loaderDotClasses} />\n <div className={loaderDotClasses} />\n <div className={loaderDotClasses} />\n {!ariaLabelledById && (\n <span id={labelId} className={loaderStyles['loader__hidden-text']}>\n {ariaLabel}\n </span>\n )}\n </div>\n )}\n </div>\n );\n};\n\nexport default Loader;\n","import Loader from './Loader';\nexport * from './Loader';\nexport default Loader;\n"],"mappings":";;;;;;;AAYA,IAAY,UAAA,yBAAA,WAAL;AACL,WAAA,YAAA;AACA,WAAA,YAAA;;;AA0BF,IAAMA,UAAgC,UAAS;CAC7C,MAAM,EACJ,SACA,OAAO,SACP,YAAY,IACZ,UAAU,MAAM,EAChB,QACA,QACA,QACA,kBACA,YAAY,iBACV;CACJ,MAAM,QAAQ,MAAM,UAAU,UAAU,MAAM,SAAS;CAEvD,MAAM,mBAA4B;AAChC,MAAI,YAAY,QAAQ,UAAU,OAChC,QAAO;AAGT,SAAO;;CAGT,MAAM,CAAC,SAAS,cAAc,SAAS,YAAY,CAAC;CAEpD,MAAM,UAAU,SAAS;CACzB,MAAM,WAAW,SAAS;CAC1B,MAAM,UAAU,SAAS;CAEzB,MAAM,uBAAuB,
|
|
1
|
+
{"version":3,"file":"index.js","names":["Loader: React.FC<LoaderProps>"],"sources":["../../../src/components/Loader/Loader.tsx","../../../src/components/Loader/index.ts"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId, ZIndex } from '../../constants';\nimport { PaletteNames } from '../../theme/palette';\nimport { uuid } from '../../utils/uuid';\n\nimport loaderStyles from './styles.module.scss';\n\nexport type LoaderColors = PaletteNames;\nexport type LoaderSizes = 'tiny' | 'small' | 'medium' | 'large';\nexport enum Overlay {\n screen = 'screen',\n parent = 'parent',\n}\n\nexport interface LoaderProps {\n /** Sets the color of the loader. If overlay is used, the color will always be white. */\n color?: LoaderColors;\n /**\tAdds custom classes to the element. */\n className?: string;\n /** Changes the size of the loader. */\n size?: LoaderSizes;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** id of the label */\n labelId?: string;\n /** Centers the loader in a container */\n center?: boolean;\n /** Inline the loader so it can be used in a span or paragraph */\n inline?: boolean;\n /** Loader is displayed with grey background covering the entire screen */\n overlay?: keyof typeof Overlay;\n /** Individual id for loading icon (aria-labelledby). */\n ariaLabelledById?: string;\n /** String that labels the current loading element */\n ariaLabel?: string;\n}\n\nconst Loader: React.FC<LoaderProps> = props => {\n const {\n overlay,\n size = 'small',\n className = '',\n labelId = uuid(),\n testId,\n center,\n inline,\n ariaLabelledById,\n ariaLabel = 'Laster inn',\n } = props;\n const color = props.overlay ? 'white' : props.color || 'neutral';\n\n const showLoader = (): boolean => {\n if (overlay === Overlay.parent || inline) {\n return false;\n }\n\n return true;\n };\n\n const [display, setDisplay] = useState(showLoader());\n\n const isSmall = size === 'small';\n const isMedium = size === 'medium';\n const isLarge = size === 'large';\n\n const loaderWrapperClasses = classNames({\n [loaderStyles['loader-wrapper--center']]: center,\n [loaderStyles['loader-wrapper--overlay']]: overlay,\n [loaderStyles['loader-wrapper--overlay-screen']]: overlay === Overlay.screen,\n [loaderStyles['loader-wrapper--overlay-parent']]: overlay === Overlay.parent && display,\n [loaderStyles['loader-wrapper--inline']]: inline && display,\n });\n const loaderClasses = classNames(\n loaderStyles.loader,\n {\n [loaderStyles['loader--small']]: isSmall,\n [loaderStyles['loader--medium']]: isMedium,\n [loaderStyles['loader--large']]: isLarge,\n },\n className\n );\n const loaderDotClasses = classNames(loaderStyles.loader__dot, {\n [loaderStyles['loader__dot--small']]: isSmall,\n [loaderStyles['loader__dot--medium']]: isMedium,\n [loaderStyles['loader__dot--large']]: isLarge,\n [loaderStyles['loader__dot--banana']]: color === 'banana',\n [loaderStyles['loader__dot--cherry']]: color === 'cherry',\n [loaderStyles['loader__dot--kiwi']]: color === 'kiwi',\n [loaderStyles['loader__dot--neutral']]: color === 'neutral',\n [loaderStyles['loader__dot--plum']]: color === 'plum',\n [loaderStyles['loader__dot--black']]: color === 'black',\n [loaderStyles['loader__dot--white']]: color === 'white',\n });\n\n const wrapperRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (overlay === Overlay.parent && wrapperRef.current?.parentElement?.style) {\n wrapperRef.current.parentElement.style.position = 'relative';\n setDisplay(true);\n }\n\n if (inline && wrapperRef.current?.parentElement?.style) {\n wrapperRef.current.parentElement.style.display = 'flex';\n setDisplay(true);\n }\n }, []);\n\n return (\n <div className={loaderWrapperClasses} ref={wrapperRef} style={overlay === Overlay.screen ? { zIndex: ZIndex.OverlayScreen } : {}}>\n {display && (\n <div\n data-testid={testId}\n data-analyticsid={AnalyticsId.Loader}\n role=\"progressbar\"\n aria-labelledby={ariaLabelledById || labelId}\n className={loaderClasses}\n >\n <div className={loaderDotClasses} />\n <div className={loaderDotClasses} />\n <div className={loaderDotClasses} />\n <div className={loaderDotClasses} />\n {!ariaLabelledById && (\n <span id={labelId} className={loaderStyles['loader__hidden-text']}>\n {ariaLabel}\n </span>\n )}\n </div>\n )}\n </div>\n );\n};\n\nexport default Loader;\n","import Loader from './Loader';\nexport * from './Loader';\nexport default Loader;\n"],"mappings":";;;;;;;AAYA,IAAY,UAAA,yBAAA,WAAL;AACL,WAAA,YAAA;AACA,WAAA,YAAA;;;AA0BF,IAAMA,UAAgC,UAAS;CAC7C,MAAM,EACJ,SACA,OAAO,SACP,YAAY,IACZ,UAAU,MAAM,EAChB,QACA,QACA,QACA,kBACA,YAAY,iBACV;CACJ,MAAM,QAAQ,MAAM,UAAU,UAAU,MAAM,SAAS;CAEvD,MAAM,mBAA4B;AA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AAK;GACL,mBAAiB,oBAAoB;GACrC,WAAW;;IAEX,oBAAC,OAAA,EAAI,WAAW,kBAAA,CAAoB;IACpC,oBAAC,OAAA,EAAI,WAAW,kBAAA,CAAoB;IACpC,oBAAC,OAAA,EAAI,WAAW,kBAAA,CAAoB;IACpC,oBAAC,OAAA,EAAI,WAAW,kBAAA,CAAoB;IACnC,CAAC,oBACA,oBAAC,QAAA;KAAK,IAAI;KAAS,WAAW,aAAa;eACxC;MACI;;IAEL;GAEJ;;AClIV,IAAA,iBDsIe"}
|
|
@@ -36,7 +36,7 @@ import { t as AlertSignStroke_default } from "../../AlertSignStroke.js";
|
|
|
36
36
|
import { t as CheckOutline_default } from "../../CheckOutline.js";
|
|
37
37
|
import { t as Portal } from "../../Portal.js";
|
|
38
38
|
import React, { useEffect } from "react";
|
|
39
|
-
import
|
|
39
|
+
import classNames from "classnames";
|
|
40
40
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
41
41
|
import styles from "./styles.module.scss";
|
|
42
42
|
let ModalVariants = /* @__PURE__ */ function(ModalVariants$1) {
|
|
@@ -129,8 +129,8 @@ var Modal = (props) => {
|
|
|
129
129
|
useEffect(() => {
|
|
130
130
|
dialogRef.current?.focus();
|
|
131
131
|
}, []);
|
|
132
|
-
const dialogClasses =
|
|
133
|
-
const titleClasses =
|
|
132
|
+
const dialogClasses = classNames(className, styles.modal, variant && styles[`modal--${variant}`], size && styles[`modal--${size}`], contentIsScrollable && !showActions && styles["modal--no-actions"]);
|
|
133
|
+
const titleClasses = classNames({
|
|
134
134
|
[styles["modal__title--error"]]: variant === ModalVariants.error,
|
|
135
135
|
[styles["modal__title--success"]]: variant === ModalVariants.success
|
|
136
136
|
});
|
|
@@ -152,9 +152,9 @@ var Modal = (props) => {
|
|
|
152
152
|
...ariaLabelAttributes,
|
|
153
153
|
ref: dialogRef,
|
|
154
154
|
children: [
|
|
155
|
-
/* @__PURE__ */ jsx("div", { className:
|
|
155
|
+
/* @__PURE__ */ jsx("div", { className: classNames(styles["modal__shadow"], styles["modal__shadow--top"], { [styles["modal__shadow--show"]]: !topContentVisible && contentIsScrollable }) }),
|
|
156
156
|
/* @__PURE__ */ jsxs("div", {
|
|
157
|
-
className:
|
|
157
|
+
className: classNames(styles.modal__contentWrapper),
|
|
158
158
|
tabIndex: contentIsScrollable ? 0 : void 0,
|
|
159
159
|
role: contentIsScrollable ? "region" : void 0,
|
|
160
160
|
...contentIsScrollable ? ariaLabelAttributes : {},
|
|
@@ -162,14 +162,14 @@ var Modal = (props) => {
|
|
|
162
162
|
children: [!props.noCloseButton && /* @__PURE__ */ jsx("div", {
|
|
163
163
|
className: styles.modal__closeWrapper,
|
|
164
164
|
children: /* @__PURE__ */ jsx("div", {
|
|
165
|
-
className:
|
|
165
|
+
className: classNames(styles.modal__closeWrapper__close),
|
|
166
166
|
children: /* @__PURE__ */ jsx(Close_default, {
|
|
167
167
|
onClick: props.onClose,
|
|
168
168
|
ariaLabel: props.ariaLabelCloseBtn
|
|
169
169
|
})
|
|
170
170
|
})
|
|
171
171
|
}), /* @__PURE__ */ jsxs("div", {
|
|
172
|
-
className:
|
|
172
|
+
className: classNames(size && styles[`modal__contentWrapper__scroll--${size}`]),
|
|
173
173
|
children: [
|
|
174
174
|
/* @__PURE__ */ jsx("div", { ref: topContent }),
|
|
175
175
|
/* @__PURE__ */ jsxs("div", {
|
|
@@ -198,9 +198,9 @@ var Modal = (props) => {
|
|
|
198
198
|
]
|
|
199
199
|
})]
|
|
200
200
|
}),
|
|
201
|
-
/* @__PURE__ */ jsx("div", { className:
|
|
201
|
+
/* @__PURE__ */ jsx("div", { className: classNames(styles["modal__shadow"], styles["modal__shadow--bottom"], { [styles["modal__shadow--show"]]: !bottomContentVisible && contentIsScrollable }) }),
|
|
202
202
|
showActions && /* @__PURE__ */ jsxs("div", {
|
|
203
|
-
className:
|
|
203
|
+
className: classNames(styles["modal__call-to-action"], size && styles[`modal__call-to-action--${size}`]),
|
|
204
204
|
children: [
|
|
205
205
|
props.onSuccess && primaryButtonText && /* @__PURE__ */ jsx(Button_default, {
|
|
206
206
|
onClick: props.onSuccess,
|