@helsenorge/designsystem-react 15.2.0 → 15.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +7 -7
- package/lib/Button.js.map +1 -1
- package/lib/CHANGELOG.md +23 -0
- package/lib/Checkbox.js +5 -5
- package/lib/Checkbox.js.map +1 -1
- package/lib/Checkbox2.js +2 -2
- package/lib/Checkbox2.js.map +1 -1
- package/lib/CheckboxMarker.js +2 -2
- package/lib/CheckboxMarker.js.map +1 -1
- package/lib/Chip.js +4 -4
- package/lib/Chip.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 +56 -39
- package/lib/Drawer.js.map +1 -1
- package/lib/DrawerNavigation.js +107 -8
- package/lib/DrawerNavigation.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 +8 -8
- package/lib/Expander.js.map +1 -1
- package/lib/FilterButton.js +2 -2
- package/lib/FilterButton.js.map +1 -1
- package/lib/FilterButtonAndChipsWrapper.js +2 -2
- package/lib/FilterButtonAndChipsWrapper.js.map +1 -1
- package/lib/FilterDrawer.js +0 -2
- package/lib/FilterDrawer.js.map +1 -1
- package/lib/FilterLinkList.js +4 -4
- package/lib/FilterLinkList.js.map +1 -1
- package/lib/FilterOverviewSearch.js +2 -2
- package/lib/FilterOverviewSearch.js.map +1 -1
- package/lib/FilterSearch.js +6 -6
- package/lib/FilterSearch.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 +12 -11
- package/lib/InfoTeaser.js.map +1 -1
- package/lib/Input.js +4 -4
- package/lib/Input.js.map +1 -1
- package/lib/LazyIcon.js +2 -0
- package/lib/LazyIcon.js.map +1 -1
- package/lib/LinkList.js +5 -5
- package/lib/LinkList.js.map +1 -1
- package/lib/List.js +2 -2
- package/lib/List.js.map +1 -1
- package/lib/ListEditMode.js +4 -4
- package/lib/ListEditMode.js.map +1 -1
- package/lib/MaxCharacters.js +2 -2
- package/lib/MaxCharacters.js.map +1 -1
- package/lib/PanelTitle.js +2 -2
- package/lib/PanelTitle.js.map +1 -1
- package/lib/PopOver.js +2 -2
- package/lib/PopOver.js.map +1 -1
- package/lib/Radio.js +2 -2
- package/lib/Radio.js.map +1 -1
- package/lib/RadioButton.js +4 -4
- package/lib/RadioButton.js.map +1 -1
- package/lib/RadioMarker.js +2 -2
- package/lib/RadioMarker.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/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/VisualCheckbox.js +3 -3
- package/lib/VisualCheckbox.js.map +1 -1
- package/lib/VisualRadio.js +3 -3
- package/lib/VisualRadio.js.map +1 -1
- package/lib/components/ArticleTeaser/index.js +4 -4
- package/lib/components/ArticleTeaser/index.js.map +1 -1
- package/lib/components/Drawer/Drawer.d.ts +6 -1
- package/lib/components/Drawer/DrawerHeaderContent.d.ts +22 -0
- package/lib/components/Drawer/DrawerHeaderContent.module.scss +51 -0
- package/lib/components/Drawer/DrawerHeaderContent.module.scss.d.ts +12 -0
- package/lib/components/Drawer/styles.module.scss +20 -10
- package/lib/components/Drawer/styles.module.scss.d.ts +3 -2
- 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/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 +6 -6
- package/lib/components/ExpanderList/index.js.map +1 -1
- package/lib/components/FavoriteButton/index.js +2 -2
- package/lib/components/FavoriteButton/index.js.map +1 -1
- package/lib/components/Filter/DrawerNavigation/styles.module.scss +15 -0
- package/lib/components/Filter/DrawerNavigation/styles.module.scss.d.ts +11 -0
- package/lib/components/Filter/FilterDrawer/styles.module.scss +0 -11
- package/lib/components/Filter/FilterDrawer/styles.module.scss.d.ts +0 -1
- package/lib/components/HelpBubble/index.js +3 -3
- package/lib/components/HelpBubble/index.js.map +1 -1
- package/lib/components/HelpDrawer/HelpDrawer.d.ts +1 -1
- package/lib/components/HelpDrawer/index.js +2 -1
- package/lib/components/HelpDrawer/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/Highlighter/styles.module.scss +1 -1
- package/lib/components/Icons/AdditionalIconInformation.d.ts +12 -0
- package/lib/components/Icons/AdditionalIconInformation.js +13 -1
- package/lib/components/Icons/AdditionalIconInformation.js.map +1 -1
- package/lib/components/Icons/IconNames.d.ts +1 -1
- package/lib/components/Icons/IconNames.js +2 -0
- package/lib/components/Icons/IconNames.js.map +1 -1
- package/lib/components/Icons/ThumbsDown.d.ts +4 -0
- package/lib/components/Icons/ThumbsDown.js +15 -0
- package/lib/components/Icons/ThumbsDown.js.map +1 -0
- package/lib/components/Icons/ThumbsUp.d.ts +4 -0
- package/lib/components/Icons/ThumbsUp.js +15 -0
- package/lib/components/Icons/ThumbsUp.js.map +1 -0
- package/lib/components/InfoTeaser/InfoTeaser.d.ts +4 -0
- package/lib/components/Loader/index.js +4 -4
- package/lib/components/Loader/index.js.map +1 -1
- package/lib/components/Modal/index.js +9 -9
- package/lib/components/Modal/index.js.map +1 -1
- package/lib/components/NotificationPanel/index.js +6 -6
- package/lib/components/NotificationPanel/index.js.map +1 -1
- package/lib/components/Panel/index.js +12 -12
- package/lib/components/Panel/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/PopMenu/index.js +3 -3
- package/lib/components/PopMenu/index.js.map +1 -1
- package/lib/components/Progressbar/index.js +2 -2
- package/lib/components/Progressbar/index.js.map +1 -1
- package/lib/components/PromoPanel/index.js +2 -2
- package/lib/components/PromoPanel/index.js.map +1 -1
- package/lib/components/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/Table/index.js +2 -2
- package/lib/components/Table/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/constants.d.ts +2 -1
- package/lib/components/Tag/index.js +3 -2
- package/lib/components/Tag/index.js.map +1 -1
- package/lib/components/Tag/styles.module.scss +5 -0
- package/lib/components/Tag/styles.module.scss.d.ts +1 -0
- package/lib/components/Tile/index.js +4 -4
- package/lib/components/Tile/index.js.map +1 -1
- package/lib/components/Toggle/index.js +7 -7
- 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/components/VisualCheckboxCloud/index.js +2 -2
- package/lib/components/VisualCheckboxCloud/index.js.map +1 -1
- package/lib/components/VisualCheckboxGroup/index.js +3 -3
- package/lib/components/VisualCheckboxGroup/index.js.map +1 -1
- package/lib/components/VisualContentgroupWithImage/index.js +2 -2
- package/lib/components/VisualContentgroupWithImage/index.js.map +1 -1
- package/lib/components/VisualRadioCloud/index.js +2 -2
- package/lib/components/VisualRadioCloud/index.js.map +1 -1
- package/lib/components/VisualRadioGroup/index.js +3 -3
- package/lib/components/VisualRadioGroup/index.js.map +1 -1
- package/lib/hooks/useFocusTrap.js +4 -2
- package/lib/hooks/useFocusTrap.js.map +1 -1
- package/lib/utils2.js +7 -7
- package/lib/utils2.js.map +1 -1
- package/package.json +1 -1
package/lib/ElementHeader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElementHeader.js","names":[],"sources":["../src/components/ElementHeader/utils.tsx","../src/components/ElementHeader/ElementHeader.tsx"],"sourcesContent":["import React from 'react';\n\nimport type { AvatarProps } from '../Avatar';\nimport type { BadgeProps } from '../Badge';\nimport type { StatusDotProps } from '../StatusDot';\n\nimport ElementHeader, { type ElementHeaderChildren, type ElementHeaderProps } from './ElementHeader';\nimport { ElementHeaderText, type ElementHeaderTextProps } from './ElementHeaderText';\nimport { StatusDotList, type StatusDotListProps } from './StatusDotList';\nimport { isComponent, isComponentWithChildren } from '../../utils/component';\nimport Avatar from '../Avatar';\nimport Badge from '../Badge';\nimport StatusDot from '../StatusDot';\n\ntype ChildrenMapper = (children: React.ReactNode, isJsxChild?: boolean) => ElementHeaderChildren | undefined;\n\nexport const mapChildren: ChildrenMapper = (children, isJsxChild = false) => {\n let avatarChild: React.ReactElement<AvatarProps> | undefined;\n const badgeChildren: React.ReactElement<BadgeProps>[] = [];\n const statusDotChildren: React.ReactElement<StatusDotProps>[] = [];\n let statusDotMCChild: React.ReactElement<StatusDotListProps> | undefined;\n const elementHeaderTextChildren: React.ReactElement<ElementHeaderTextProps>[] = [];\n const stringChildren: string[] = [];\n const remainingChildren: React.ReactNode[] = [];\n\n React.Children.forEach(children, child => {\n if (child === null || typeof child === 'undefined') return;\n if (isComponent<AvatarProps>(child, Avatar)) {\n avatarChild = child;\n } else if (isComponent<ElementHeaderTextProps>(child, ElementHeaderText)) {\n elementHeaderTextChildren.push(child);\n } else if (isComponent<BadgeProps>(child, Badge)) {\n badgeChildren.push(child);\n } else if (isComponent<StatusDotListProps>(child, StatusDotList)) {\n statusDotMCChild = child;\n } else if (isComponent<StatusDotProps>(child, StatusDot)) {\n statusDotChildren.push(child);\n } else if (typeof child === 'string') {\n stringChildren.push(child);\n } else {\n remainingChildren.push(child);\n }\n });\n\n // Dette og recursive mapChildren under(gjøres en gang) er for å passe på at jsx children også sjekkes for Avatar og liknende innhold.\n // Slik opprettholder vi stylingen i tilfeller hvor vertikaler har wrappet elementer i en parent span eller div.\n const hasSpecialChildren =\n avatarChild !== undefined ||\n elementHeaderTextChildren.length > 0 ||\n statusDotChildren.length > 0 ||\n statusDotMCChild !== undefined ||\n (badgeChildren !== undefined && stringChildren.length > 0);\n const noRemainingRecursiveChildren =\n remainingChildren.length === 0 ||\n (isComponentWithChildren(remainingChildren[0]) && typeof remainingChildren[0]?.props?.children === 'undefined');\n\n if (isJsxChild || hasSpecialChildren || noRemainingRecursiveChildren) {\n return {\n avatarChild,\n elementHeaderTextChildren: elementHeaderTextChildren,\n badgeChildren,\n statusDotChildren,\n statusDotMCChild,\n stringChildren,\n remainingChildren,\n };\n }\n\n if (isComponentWithChildren(remainingChildren[0])) {\n return mapChildren(remainingChildren[0]?.props?.children, true);\n }\n};\n\nexport const renderElementHeader = (\n element: React.ReactNode,\n options: Pick<\n ElementHeaderProps,\n 'titleHtmlMarkup' | 'isHovered' | 'size' | 'parentType' | 'chevronIcon' | 'icon' | 'highlightText' | 'closeButton'\n >\n): React.ReactElement | undefined => {\n const { titleHtmlMarkup, isHovered, size, parentType, chevronIcon, icon, highlightText, closeButton } = options;\n\n if (isComponent<ElementHeaderProps>(element, ElementHeader)) {\n return React.cloneElement(element, {\n chevronIcon,\n icon,\n isHovered,\n size,\n parentType,\n highlightText,\n closeButton,\n });\n }\n if (element) {\n return (\n <ElementHeader\n highlightText={highlightText}\n titleHtmlMarkup={titleHtmlMarkup}\n parentType={parentType}\n chevronIcon={chevronIcon}\n icon={icon}\n isHovered={isHovered}\n size={size}\n closeButton={closeButton}\n >\n {element}\n </ElementHeader>\n );\n }\n};\n","import React from 'react';\n\nimport cn from 'classnames';\n\nimport type { AvatarProps, AvatarType } from '../Avatar';\nimport type { BadgeProps, BadgeType } from '../Badge';\nimport type { IconProps, SvgIcon } from '../Icon';\nimport type { LazyIconProps } from '../LazyIcon';\nimport type { StatusDotProps, StatusDotType } from '../StatusDot';\nimport type { TitleTags } from '../Title';\nimport type { ElementHeaderTextProps, ElementHeaderTextType } from './ElementHeaderText/ElementHeaderText';\nimport type { StatusDotListProps, StatusDotListType } from './StatusDotList/StatusDotList';\n\nimport ElementHeaderText from './ElementHeaderText/ElementHeaderText';\nimport { Breakpoint, useBreakpoint } from '../../hooks/useBreakpoint';\nimport { isComponent } from '../../utils/component';\nimport { AvatarSize } from '../Avatar';\nimport Icon, { IconSize } from '../Icon';\nimport StatusDotList from './StatusDotList';\nimport Highlighter from '../Highlighter';\nimport LazyIcon from '../LazyIcon';\nimport { mapChildren } from './utils';\n\nimport styles from './styles.module.scss';\n\nexport type ElementHeaderSize = 'compact' | 'small' | 'medium' | 'large';\nexport type ParentType = 'linklist' | 'expanderlist';\n\nexport interface ElementHeaderType extends React.FC<ElementHeaderProps> {\n Avatar?: AvatarType;\n Badge?: BadgeType;\n ElementHeaderText?: ElementHeaderTextType;\n StatusDot?: StatusDotType;\n StatusDotList?: StatusDotListType;\n}\n\nexport interface ElementHeaderProps {\n /** Adds custom classes to the ElementHeader element. */\n className?: string;\n /** Chevron to render inside of the ElementHeader */\n chevronIcon?: SvgIcon;\n /** Close button to be rendered inside of ElementHeader. This renders in place of chevronIcon */\n closeButton?: React.ReactElement;\n /** Children to be rendered inside of ElementHeader */\n children: React.ReactNode;\n /** Changes the underlying element of the title. Default: h2*/\n titleHtmlMarkup?: TitleTags;\n /** icon to be rendered inside of ElementHeader */\n icon?: React.ReactElement;\n /** whether or not the parent is hovered */\n isHovered?: boolean;\n /** Adjusts styling based on parent */\n parentType?: ParentType;\n /** Changes size of the ElementHeader. */\n size?: ElementHeaderSize;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Highlights text in title. Used for search results */\n highlightText?: string;\n}\n\nexport interface ElementHeaderChildren {\n avatarChild?: React.ReactElement<AvatarProps>;\n elementHeaderTextChildren: React.ReactElement<ElementHeaderTextProps>[];\n badgeChildren?: React.ReactElement<BadgeProps>[];\n statusDotChildren?: React.ReactElement<StatusDotProps>[];\n statusDotMCChild?: React.ReactElement<StatusDotListProps>;\n elementChild?: React.ReactElement;\n stringChildren: string[];\n remainingChildren: React.ReactNode[];\n}\n\nexport const ElementHeaderRoot: ElementHeaderType = props => {\n const {\n className = '',\n titleHtmlMarkup = 'h2',\n parentType = 'linklist',\n chevronIcon,\n closeButton,\n children,\n icon,\n isHovered,\n size,\n testId,\n highlightText,\n } = props;\n const breakpoint = useBreakpoint();\n const showIcon = size !== 'small' && !!icon;\n const contentIsString = typeof children === 'string';\n const mappedChildren = mapChildren(children);\n const hasStatusDots = !!mappedChildren?.statusDotChildren?.length || !!mappedChildren?.statusDotMCChild;\n\n const listLabelClasses = cn(styles['element-header'], { [styles['element-header--compact']]: size === 'compact' }, className);\n const badgeContainerClasses = cn(styles['element-header__badge-container']);\n const badgeClasses = cn(styles['element-header__badge']);\n const statusdotContainerClasses = cn(styles['element-header__statusdot-container']);\n const chevronClasses = cn(styles['element-header__chevron']);\n const contentClasses = cn(styles['element-header__content'], {\n [styles['element-header__content--element']]: !contentIsString,\n [styles['element-header__content--compact']]: size === 'compact',\n });\n const iconClasses = cn(styles['element-header__icon'], { [styles['element-header__icon--with-statusdot']]: hasStatusDots });\n const avatarClasses = cn(styles['element-header__avatar'], {});\n const CustomTag = titleHtmlMarkup;\n const iconPropIsIconComponent = isComponent<IconProps>(icon, Icon);\n const iconPropIsLazyIconComponent = !iconPropIsIconComponent && isComponent<LazyIconProps>(icon, LazyIcon);\n\n let iconComponent;\n if (iconPropIsIconComponent) {\n iconComponent = React.cloneElement(icon as React.ReactElement<IconProps>, {\n size: breakpoint < Breakpoint.md ? IconSize.XSmall : IconSize.Small,\n isHovered,\n });\n } else if (iconPropIsLazyIconComponent) {\n iconComponent = React.cloneElement(icon as React.ReactElement<LazyIconProps>, {\n size: breakpoint < Breakpoint.md ? IconSize.XSmall : IconSize.Small,\n isHovered,\n });\n } else {\n iconComponent = icon;\n }\n\n return (\n <span data-testid={testId} className={listLabelClasses}>\n {showIcon && icon && <span className={iconClasses}>{iconComponent}</span>}\n {size !== 'small' && mappedChildren?.avatarChild && (\n <span className={avatarClasses}>{React.cloneElement(mappedChildren.avatarChild, { size: AvatarSize.xsmall })}</span>\n )}\n\n <span className={contentClasses} data-hasstatusdots={hasStatusDots}>\n {mappedChildren?.elementHeaderTextChildren}\n {!!mappedChildren?.stringChildren.length && (\n <CustomTag className={styles['element-header__title']}>\n <Highlighter searchText={highlightText}>{mappedChildren.stringChildren}</Highlighter>\n </CustomTag>\n )}\n <Highlighter searchText={highlightText}>{mappedChildren?.remainingChildren}</Highlighter>\n </span>\n\n {hasStatusDots && (\n <span className={statusdotContainerClasses}>\n {!!mappedChildren?.statusDotChildren && <StatusDotList>{mappedChildren.statusDotChildren}</StatusDotList>}\n {!!mappedChildren?.statusDotMCChild && mappedChildren?.statusDotMCChild}\n </span>\n )}\n\n <span className={badgeContainerClasses}>\n {mappedChildren?.badgeChildren &&\n mappedChildren.badgeChildren.map((badgeChild, index) => {\n return (\n <span key={index} className={badgeClasses} data-parenttype={parentType}>\n {badgeChild}\n </span>\n );\n })}\n </span>\n {chevronIcon && typeof closeButton === 'undefined' && (\n <span className={chevronClasses} data-parenttype={parentType}>\n <Icon svgIcon={chevronIcon} isHovered={isHovered} size={IconSize.XSmall} />\n </span>\n )}\n {closeButton && (\n <span className={chevronClasses} data-parenttype={parentType}>\n {closeButton}\n </span>\n )}\n </span>\n );\n};\n\ntype ElementHeaderComponent = typeof ElementHeaderRoot & {\n Text: React.FC<ElementHeaderTextProps>;\n StatusDotList: React.FC<StatusDotListProps>;\n};\nElementHeaderRoot.displayName = 'ElementHeader';\nconst ElementHeader = ElementHeaderRoot as ElementHeaderComponent;\nElementHeader.Text = ElementHeaderText;\nElementHeader.Text.displayName = 'ElementHeader.Text';\nElementHeader.StatusDotList = StatusDotList;\nElementHeader.StatusDotList.displayName = 'ElementHeader.StatusDotList';\n\nexport default ElementHeader;\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,IAAa,eAA+B,UAAU,aAAa,UAAU;CAC3E,IAAI;CACJ,MAAM,gBAAkD,CAAC;CACzD,MAAM,oBAA0D,CAAC;CACjE,IAAI;CACJ,MAAM,4BAA0E,CAAC;CACjF,MAAM,iBAA2B,CAAC;CAClC,MAAM,oBAAuC,CAAC;CAE9C,MAAM,SAAS,QAAQ,WAAU,UAAS;EACxC,IAAI,UAAU,QAAQ,OAAO,UAAU,aAAa;EACpD,IAAI,YAAyB,OAAO,cAAM,GACxC,cAAc;OACT,IAAI,YAAoC,OAAO,iBAAiB,GACrE,0BAA0B,KAAK,KAAK;OAC/B,IAAI,YAAwB,OAAO,aAAK,GAC7C,cAAc,KAAK,KAAK;OACnB,IAAI,YAAgC,OAAO,aAAa,GAC7D,mBAAmB;OACd,IAAI,YAA4B,OAAO,iBAAS,GACrD,kBAAkB,KAAK,KAAK;OACvB,IAAI,OAAO,UAAU,UAC1B,eAAe,KAAK,KAAK;OAEzB,kBAAkB,KAAK,KAAK;CAEhC,CAAC;CAID,MAAM,qBACJ,gBAAgB,KAAA,KAChB,0BAA0B,SAAS,KACnC,kBAAkB,SAAS,KAC3B,qBAAqB,KAAA,KACpB,kBAAkB,KAAA,KAAa,eAAe,SAAS;CA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B,gBAAgB,gBACnD;;GAGR,oBAAC,QAAD;IAAM,WAAW;cACd,gBAAgB,iBACf,eAAe,cAAc,KAAK,YAAY,UAAU;KACtD,OACE,oBAAC,QAAD;MAAkB,WAAW;MAAc,mBAAiB;gBACzD;KACG,GAFK,KAEL;IAEV,CAAC;GACC,CAAA;GACL,eAAe,OAAO,gBAAgB,eACrC,oBAAC,QAAD;IAAM,WAAW;IAAgB,mBAAiB;cAChD,oBAAC,cAAD;KAAM,SAAS;KAAwB;KAAW,MAAM,SAAS;IAAS,CAAA;GACtE,CAAA;GAEP,eACC,oBAAC,QAAD;IAAM,WAAW;IAAgB,mBAAiB;cAC/C;GACG,CAAA;EAEJ;;AAEV;AAMA,kBAAkB,cAAc;AAChC,IAAM,gBAAgB;AACtB,cAAc,OAAO;AACrB,cAAc,KAAK,cAAc;AACjC,cAAc,gBAAgB;AAC9B,cAAc,cAAc,cAAc"}
|
|
1
|
+
{"version":3,"file":"ElementHeader.js","names":[],"sources":["../src/components/ElementHeader/utils.tsx","../src/components/ElementHeader/ElementHeader.tsx"],"sourcesContent":["import React from 'react';\n\nimport type { AvatarProps } from '../Avatar';\nimport type { BadgeProps } from '../Badge';\nimport type { StatusDotProps } from '../StatusDot';\n\nimport ElementHeader, { type ElementHeaderChildren, type ElementHeaderProps } from './ElementHeader';\nimport { ElementHeaderText, type ElementHeaderTextProps } from './ElementHeaderText';\nimport { StatusDotList, type StatusDotListProps } from './StatusDotList';\nimport { isComponent, isComponentWithChildren } from '../../utils/component';\nimport Avatar from '../Avatar';\nimport Badge from '../Badge';\nimport StatusDot from '../StatusDot';\n\ntype ChildrenMapper = (children: React.ReactNode, isJsxChild?: boolean) => ElementHeaderChildren | undefined;\n\nexport const mapChildren: ChildrenMapper = (children, isJsxChild = false) => {\n let avatarChild: React.ReactElement<AvatarProps> | undefined;\n const badgeChildren: React.ReactElement<BadgeProps>[] = [];\n const statusDotChildren: React.ReactElement<StatusDotProps>[] = [];\n let statusDotMCChild: React.ReactElement<StatusDotListProps> | undefined;\n const elementHeaderTextChildren: React.ReactElement<ElementHeaderTextProps>[] = [];\n const stringChildren: string[] = [];\n const remainingChildren: React.ReactNode[] = [];\n\n React.Children.forEach(children, child => {\n if (child === null || typeof child === 'undefined') return;\n if (isComponent<AvatarProps>(child, Avatar)) {\n avatarChild = child;\n } else if (isComponent<ElementHeaderTextProps>(child, ElementHeaderText)) {\n elementHeaderTextChildren.push(child);\n } else if (isComponent<BadgeProps>(child, Badge)) {\n badgeChildren.push(child);\n } else if (isComponent<StatusDotListProps>(child, StatusDotList)) {\n statusDotMCChild = child;\n } else if (isComponent<StatusDotProps>(child, StatusDot)) {\n statusDotChildren.push(child);\n } else if (typeof child === 'string') {\n stringChildren.push(child);\n } else {\n remainingChildren.push(child);\n }\n });\n\n // Dette og recursive mapChildren under(gjøres en gang) er for å passe på at jsx children også sjekkes for Avatar og liknende innhold.\n // Slik opprettholder vi stylingen i tilfeller hvor vertikaler har wrappet elementer i en parent span eller div.\n const hasSpecialChildren =\n avatarChild !== undefined ||\n elementHeaderTextChildren.length > 0 ||\n statusDotChildren.length > 0 ||\n statusDotMCChild !== undefined ||\n (badgeChildren !== undefined && stringChildren.length > 0);\n const noRemainingRecursiveChildren =\n remainingChildren.length === 0 ||\n (isComponentWithChildren(remainingChildren[0]) && typeof remainingChildren[0]?.props?.children === 'undefined');\n\n if (isJsxChild || hasSpecialChildren || noRemainingRecursiveChildren) {\n return {\n avatarChild,\n elementHeaderTextChildren: elementHeaderTextChildren,\n badgeChildren,\n statusDotChildren,\n statusDotMCChild,\n stringChildren,\n remainingChildren,\n };\n }\n\n if (isComponentWithChildren(remainingChildren[0])) {\n return mapChildren(remainingChildren[0]?.props?.children, true);\n }\n};\n\nexport const renderElementHeader = (\n element: React.ReactNode,\n options: Pick<\n ElementHeaderProps,\n 'titleHtmlMarkup' | 'isHovered' | 'size' | 'parentType' | 'chevronIcon' | 'icon' | 'highlightText' | 'closeButton'\n >\n): React.ReactElement | undefined => {\n const { titleHtmlMarkup, isHovered, size, parentType, chevronIcon, icon, highlightText, closeButton } = options;\n\n if (isComponent<ElementHeaderProps>(element, ElementHeader)) {\n return React.cloneElement(element, {\n chevronIcon,\n icon,\n isHovered,\n size,\n parentType,\n highlightText,\n closeButton,\n });\n }\n if (element) {\n return (\n <ElementHeader\n highlightText={highlightText}\n titleHtmlMarkup={titleHtmlMarkup}\n parentType={parentType}\n chevronIcon={chevronIcon}\n icon={icon}\n isHovered={isHovered}\n size={size}\n closeButton={closeButton}\n >\n {element}\n </ElementHeader>\n );\n }\n};\n","import React from 'react';\n\nimport cn from 'classnames';\n\nimport type { AvatarProps, AvatarType } from '../Avatar';\nimport type { BadgeProps, BadgeType } from '../Badge';\nimport type { IconProps, SvgIcon } from '../Icon';\nimport type { LazyIconProps } from '../LazyIcon';\nimport type { StatusDotProps, StatusDotType } from '../StatusDot';\nimport type { TitleTags } from '../Title';\nimport type { ElementHeaderTextProps, ElementHeaderTextType } from './ElementHeaderText/ElementHeaderText';\nimport type { StatusDotListProps, StatusDotListType } from './StatusDotList/StatusDotList';\n\nimport ElementHeaderText from './ElementHeaderText/ElementHeaderText';\nimport { Breakpoint, useBreakpoint } from '../../hooks/useBreakpoint';\nimport { isComponent } from '../../utils/component';\nimport { AvatarSize } from '../Avatar';\nimport Icon, { IconSize } from '../Icon';\nimport StatusDotList from './StatusDotList';\nimport Highlighter from '../Highlighter';\nimport LazyIcon from '../LazyIcon';\nimport { mapChildren } from './utils';\n\nimport styles from './styles.module.scss';\n\nexport type ElementHeaderSize = 'compact' | 'small' | 'medium' | 'large';\nexport type ParentType = 'linklist' | 'expanderlist';\n\nexport interface ElementHeaderType extends React.FC<ElementHeaderProps> {\n Avatar?: AvatarType;\n Badge?: BadgeType;\n ElementHeaderText?: ElementHeaderTextType;\n StatusDot?: StatusDotType;\n StatusDotList?: StatusDotListType;\n}\n\nexport interface ElementHeaderProps {\n /** Adds custom classes to the ElementHeader element. */\n className?: string;\n /** Chevron to render inside of the ElementHeader */\n chevronIcon?: SvgIcon;\n /** Close button to be rendered inside of ElementHeader. This renders in place of chevronIcon */\n closeButton?: React.ReactElement;\n /** Children to be rendered inside of ElementHeader */\n children: React.ReactNode;\n /** Changes the underlying element of the title. Default: h2*/\n titleHtmlMarkup?: TitleTags;\n /** icon to be rendered inside of ElementHeader */\n icon?: React.ReactElement;\n /** whether or not the parent is hovered */\n isHovered?: boolean;\n /** Adjusts styling based on parent */\n parentType?: ParentType;\n /** Changes size of the ElementHeader. */\n size?: ElementHeaderSize;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Highlights text in title. Used for search results */\n highlightText?: string;\n}\n\nexport interface ElementHeaderChildren {\n avatarChild?: React.ReactElement<AvatarProps>;\n elementHeaderTextChildren: React.ReactElement<ElementHeaderTextProps>[];\n badgeChildren?: React.ReactElement<BadgeProps>[];\n statusDotChildren?: React.ReactElement<StatusDotProps>[];\n statusDotMCChild?: React.ReactElement<StatusDotListProps>;\n elementChild?: React.ReactElement;\n stringChildren: string[];\n remainingChildren: React.ReactNode[];\n}\n\nexport const ElementHeaderRoot: ElementHeaderType = props => {\n const {\n className = '',\n titleHtmlMarkup = 'h2',\n parentType = 'linklist',\n chevronIcon,\n closeButton,\n children,\n icon,\n isHovered,\n size,\n testId,\n highlightText,\n } = props;\n const breakpoint = useBreakpoint();\n const showIcon = size !== 'small' && !!icon;\n const contentIsString = typeof children === 'string';\n const mappedChildren = mapChildren(children);\n const hasStatusDots = !!mappedChildren?.statusDotChildren?.length || !!mappedChildren?.statusDotMCChild;\n\n const listLabelClasses = cn(styles['element-header'], { [styles['element-header--compact']]: size === 'compact' }, className);\n const badgeContainerClasses = cn(styles['element-header__badge-container']);\n const badgeClasses = cn(styles['element-header__badge']);\n const statusdotContainerClasses = cn(styles['element-header__statusdot-container']);\n const chevronClasses = cn(styles['element-header__chevron']);\n const contentClasses = cn(styles['element-header__content'], {\n [styles['element-header__content--element']]: !contentIsString,\n [styles['element-header__content--compact']]: size === 'compact',\n });\n const iconClasses = cn(styles['element-header__icon'], { [styles['element-header__icon--with-statusdot']]: hasStatusDots });\n const avatarClasses = cn(styles['element-header__avatar'], {});\n const CustomTag = titleHtmlMarkup;\n const iconPropIsIconComponent = isComponent<IconProps>(icon, Icon);\n const iconPropIsLazyIconComponent = !iconPropIsIconComponent && isComponent<LazyIconProps>(icon, LazyIcon);\n\n let iconComponent;\n if (iconPropIsIconComponent) {\n iconComponent = React.cloneElement(icon as React.ReactElement<IconProps>, {\n size: breakpoint < Breakpoint.md ? IconSize.XSmall : IconSize.Small,\n isHovered,\n });\n } else if (iconPropIsLazyIconComponent) {\n iconComponent = React.cloneElement(icon as React.ReactElement<LazyIconProps>, {\n size: breakpoint < Breakpoint.md ? IconSize.XSmall : IconSize.Small,\n isHovered,\n });\n } else {\n iconComponent = icon;\n }\n\n return (\n <span data-testid={testId} className={listLabelClasses}>\n {showIcon && icon && <span className={iconClasses}>{iconComponent}</span>}\n {size !== 'small' && mappedChildren?.avatarChild && (\n <span className={avatarClasses}>{React.cloneElement(mappedChildren.avatarChild, { size: AvatarSize.xsmall })}</span>\n )}\n\n <span className={contentClasses} data-hasstatusdots={hasStatusDots}>\n {mappedChildren?.elementHeaderTextChildren}\n {!!mappedChildren?.stringChildren.length && (\n <CustomTag className={styles['element-header__title']}>\n <Highlighter searchText={highlightText}>{mappedChildren.stringChildren}</Highlighter>\n </CustomTag>\n )}\n <Highlighter searchText={highlightText}>{mappedChildren?.remainingChildren}</Highlighter>\n </span>\n\n {hasStatusDots && (\n <span className={statusdotContainerClasses}>\n {!!mappedChildren?.statusDotChildren && <StatusDotList>{mappedChildren.statusDotChildren}</StatusDotList>}\n {!!mappedChildren?.statusDotMCChild && mappedChildren?.statusDotMCChild}\n </span>\n )}\n\n <span className={badgeContainerClasses}>\n {mappedChildren?.badgeChildren &&\n mappedChildren.badgeChildren.map((badgeChild, index) => {\n return (\n <span key={index} className={badgeClasses} data-parenttype={parentType}>\n {badgeChild}\n </span>\n );\n })}\n </span>\n {chevronIcon && typeof closeButton === 'undefined' && (\n <span className={chevronClasses} data-parenttype={parentType}>\n <Icon svgIcon={chevronIcon} isHovered={isHovered} size={IconSize.XSmall} />\n </span>\n )}\n {closeButton && (\n <span className={chevronClasses} data-parenttype={parentType}>\n {closeButton}\n </span>\n )}\n </span>\n );\n};\n\ntype ElementHeaderComponent = typeof ElementHeaderRoot & {\n Text: React.FC<ElementHeaderTextProps>;\n StatusDotList: React.FC<StatusDotListProps>;\n};\nElementHeaderRoot.displayName = 'ElementHeader';\nconst ElementHeader = ElementHeaderRoot as ElementHeaderComponent;\nElementHeader.Text = ElementHeaderText;\nElementHeader.Text.displayName = 'ElementHeader.Text';\nElementHeader.StatusDotList = StatusDotList;\nElementHeader.StatusDotList.displayName = 'ElementHeader.StatusDotList';\n\nexport default ElementHeader;\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,IAAa,eAA+B,UAAU,aAAa,UAAU;CAC3E,IAAI;CACJ,MAAM,gBAAkD,CAAC;CACzD,MAAM,oBAA0D,CAAC;CACjE,IAAI;CACJ,MAAM,4BAA0E,CAAC;CACjF,MAAM,iBAA2B,CAAC;CAClC,MAAM,oBAAuC,CAAC;CAE9C,MAAM,SAAS,QAAQ,WAAU,UAAS;EACxC,IAAI,UAAU,QAAQ,OAAO,UAAU,aAAa;EACpD,IAAI,YAAyB,OAAO,cAAM,GACxC,cAAc;OACT,IAAI,YAAoC,OAAO,iBAAiB,GACrE,0BAA0B,KAAK,KAAK;OAC/B,IAAI,YAAwB,OAAO,aAAK,GAC7C,cAAc,KAAK,KAAK;OACnB,IAAI,YAAgC,OAAO,aAAa,GAC7D,mBAAmB;OACd,IAAI,YAA4B,OAAO,iBAAS,GACrD,kBAAkB,KAAK,KAAK;OACvB,IAAI,OAAO,UAAU,UAC1B,eAAe,KAAK,KAAK;OAEzB,kBAAkB,KAAK,KAAK;CAEhC,CAAC;CAID,MAAM,qBACJ,gBAAgB,KAAA,KAChB,0BAA0B,SAAS,KACn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BAAC,uBAAD,EAAA,UAAgB,eAAe,kBAAiC,CAAA,GACvG,CAAC,CAAC,gBAAgB,oBAAoB,gBAAgB,gBACnD;;GAGR,oBAAC,QAAD;IAAM,WAAW;cACd,gBAAgB,iBACf,eAAe,cAAc,KAAK,YAAY,UAAU;KACtD,OACE,oBAAC,QAAD;MAAkB,WAAW;MAAc,mBAAiB;gBACzD;KACG,GAFK,KAEL;IAEV,CAAC;GACC,CAAA;GACL,eAAe,OAAO,gBAAgB,eACrC,oBAAC,QAAD;IAAM,WAAW;IAAgB,mBAAiB;cAChD,oBAAC,cAAD;KAAM,SAAS;KAAwB;KAAW,MAAM,SAAS;IAAS,CAAA;GACtE,CAAA;GAEP,eACC,oBAAC,QAAD;IAAM,WAAW;IAAgB,mBAAiB;cAC/C;GACG,CAAA;EAEJ;;AAEV;AAMA,kBAAkB,cAAc;AAChC,IAAM,gBAAgB;AACtB,cAAc,OAAO;AACrB,cAAc,KAAK,cAAc;AACjC,cAAc,gBAAgB;AAC9B,cAAc,cAAc,cAAc"}
|
package/lib/ElementHeaderText.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { t as Highlighter_default } from "./Highlighter.js";
|
|
2
|
-
import
|
|
2
|
+
import cn from "classnames";
|
|
3
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
4
|
import styles from "./components/ElementHeader/styles.module.scss";
|
|
5
5
|
//#region src/components/ElementHeader/ElementHeaderText/ElementHeaderText.tsx
|
|
6
6
|
var ElementHeaderText = (props) => {
|
|
7
7
|
const { firstText, firstTextEmphasised = false, secondText = void 0, secondTextEmphasised = false, subText = false, className = "", testId, titleHtmlMarkup = "span", highlightText } = props;
|
|
8
|
-
const headerTextWrapperClasses =
|
|
9
|
-
const firstHeaderTextSegmentClasses =
|
|
10
|
-
const secondHeaderTextSegmentClasses =
|
|
8
|
+
const headerTextWrapperClasses = cn(className, styles["text-wrapper"], { [styles["text-wrapper--sub-level"]]: subText });
|
|
9
|
+
const firstHeaderTextSegmentClasses = cn({ [styles["text-wrapper__text--emphasised"]]: firstTextEmphasised });
|
|
10
|
+
const secondHeaderTextSegmentClasses = cn({ [styles["text-wrapper__text--emphasised"]]: secondTextEmphasised });
|
|
11
11
|
return /* @__PURE__ */ jsx("span", {
|
|
12
12
|
"data-testid": testId,
|
|
13
13
|
className: headerTextWrapperClasses,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElementHeaderText.js","names":[],"sources":["../src/components/ElementHeader/ElementHeaderText/ElementHeaderText.tsx","../src/components/ElementHeader/ElementHeaderText/index.ts"],"sourcesContent":["import cn from 'classnames';\n\nimport type { TitleTags } from '../../Title';\n\nimport Highlighter from '../../Highlighter';\nimport styles from '../styles.module.scss';\n\nexport type ElementHeaderTextType = typeof ElementHeaderText;\n\nexport interface ElementHeaderTextProps {\n /** The first text in the ElementHeaderText Component */\n firstText: string;\n /** Will style the first text as bold */\n firstTextEmphasised?: boolean;\n /** The second text in the ElementHeaderText Component */\n secondText?: string;\n /** Will style the second text as bold */\n secondTextEmphasised?: boolean;\n /** Whether or not this ElementHeaderText is a sub text */\n subText?: boolean;\n /** Adds custom classes to the ElementHeaderText component. */\n className?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Changes the underlying element of the text. Default: span*/\n titleHtmlMarkup?: TitleTags;\n /** Highlights text. Used for search results */\n highlightText?: string;\n}\n\nexport const ElementHeaderText: React.FC<ElementHeaderTextProps> = props => {\n const {\n firstText,\n firstTextEmphasised = false,\n secondText = undefined,\n secondTextEmphasised = false,\n subText = false,\n className = '',\n testId,\n titleHtmlMarkup = 'span',\n highlightText,\n } = props;\n\n const headerTextWrapperClasses = cn(className, styles['text-wrapper'], {\n [styles['text-wrapper--sub-level']]: subText,\n });\n const firstHeaderTextSegmentClasses = cn({\n [styles['text-wrapper__text--emphasised']]: firstTextEmphasised,\n });\n const secondHeaderTextSegmentClasses = cn({\n [styles['text-wrapper__text--emphasised']]: secondTextEmphasised,\n });\n const CustomTag = titleHtmlMarkup;\n\n return (\n <span data-testid={testId} className={headerTextWrapperClasses}>\n <CustomTag className={styles['element-header__title']}>\n <Highlighter searchText={highlightText}>\n <span className={firstHeaderTextSegmentClasses}>{firstText}</span>\n {secondText && <span className={secondHeaderTextSegmentClasses}>{secondText}</span>}\n </Highlighter>\n </CustomTag>\n </span>\n );\n};\n\nexport default ElementHeaderText;\n","import ElementHeaderText from './ElementHeaderText';\nexport * from './ElementHeaderText';\nexport default ElementHeaderText;\n"],"mappings":";;;;;AA8BA,IAAa,qBAAsD,UAAS;CAC1E,MAAM,EACJ,WACA,sBAAsB,OACtB,aAAa,KAAA,GACb,uBAAuB,OACvB,UAAU,OACV,YAAY,IACZ,QACA,kBAAkB,QAClB,kBACE;CAEJ,MAAM,2BAA2B,
|
|
1
|
+
{"version":3,"file":"ElementHeaderText.js","names":[],"sources":["../src/components/ElementHeader/ElementHeaderText/ElementHeaderText.tsx","../src/components/ElementHeader/ElementHeaderText/index.ts"],"sourcesContent":["import cn from 'classnames';\n\nimport type { TitleTags } from '../../Title';\n\nimport Highlighter from '../../Highlighter';\nimport styles from '../styles.module.scss';\n\nexport type ElementHeaderTextType = typeof ElementHeaderText;\n\nexport interface ElementHeaderTextProps {\n /** The first text in the ElementHeaderText Component */\n firstText: string;\n /** Will style the first text as bold */\n firstTextEmphasised?: boolean;\n /** The second text in the ElementHeaderText Component */\n secondText?: string;\n /** Will style the second text as bold */\n secondTextEmphasised?: boolean;\n /** Whether or not this ElementHeaderText is a sub text */\n subText?: boolean;\n /** Adds custom classes to the ElementHeaderText component. */\n className?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Changes the underlying element of the text. Default: span*/\n titleHtmlMarkup?: TitleTags;\n /** Highlights text. Used for search results */\n highlightText?: string;\n}\n\nexport const ElementHeaderText: React.FC<ElementHeaderTextProps> = props => {\n const {\n firstText,\n firstTextEmphasised = false,\n secondText = undefined,\n secondTextEmphasised = false,\n subText = false,\n className = '',\n testId,\n titleHtmlMarkup = 'span',\n highlightText,\n } = props;\n\n const headerTextWrapperClasses = cn(className, styles['text-wrapper'], {\n [styles['text-wrapper--sub-level']]: subText,\n });\n const firstHeaderTextSegmentClasses = cn({\n [styles['text-wrapper__text--emphasised']]: firstTextEmphasised,\n });\n const secondHeaderTextSegmentClasses = cn({\n [styles['text-wrapper__text--emphasised']]: secondTextEmphasised,\n });\n const CustomTag = titleHtmlMarkup;\n\n return (\n <span data-testid={testId} className={headerTextWrapperClasses}>\n <CustomTag className={styles['element-header__title']}>\n <Highlighter searchText={highlightText}>\n <span className={firstHeaderTextSegmentClasses}>{firstText}</span>\n {secondText && <span className={secondHeaderTextSegmentClasses}>{secondText}</span>}\n </Highlighter>\n </CustomTag>\n </span>\n );\n};\n\nexport default ElementHeaderText;\n","import ElementHeaderText from './ElementHeaderText';\nexport * from './ElementHeaderText';\nexport default ElementHeaderText;\n"],"mappings":";;;;;AA8BA,IAAa,qBAAsD,UAAS;CAC1E,MAAM,EACJ,WACA,sBAAsB,OACtB,aAAa,KAAA,GACb,uBAAuB,OACvB,UAAU,OACV,YAAY,IACZ,QACA,kBAAkB,QAClB,kBACE;CAEJ,MAAM,2BAA2B,GAAG,WAAW,OAAO,iBAAiB,GACpE,OAAO,6BAA6B,QACvC,CAAC;CACD,MAAM,gCAAgC,GAAG,GACtC,OAAO,oCAAoC,oBAC9C,CAAC;CACD,MAAM,iCAAiC,GAAG,GACvC,OAAO,oCAAoC,qBAC9C,CAAC;CAGD,OACE,oBAAC,QAAD;EAAM,eAAa;EAAQ,WAAW;YACpC,oBAAC,iBAAD;GAAW,WAAW,OAAO;aAC3B,qBAAC,qBAAD;IAAa,YAAY;cAAzB,CACE,oBAAC,QAAD;KAAM,WAAW;eAAgC;IAAgB,CAAA,GAChE,cAAc,oBAAC,QAAD;KAAM,WAAW;eAAiC;IAAiB,CAAA,CACvE;;EACJ,CAAA;CACP,CAAA;AAEV;;;AC9DA,IAAA,4BAAe"}
|
package/lib/ErrorWrapper.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import cn from "classnames";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import styles from "./components/ErrorWrapper/styles.module.scss";
|
|
4
4
|
//#region src/components/ErrorWrapper/ErrorWrapper.tsx
|
|
5
5
|
var ErrorWrapper = (props) => {
|
|
6
6
|
const { renderError = true } = props;
|
|
7
7
|
return /* @__PURE__ */ jsxs("div", {
|
|
8
|
-
className:
|
|
8
|
+
className: cn(props.errorText && renderError && styles[`error-wrapper--with-error`], props.className),
|
|
9
9
|
"data-testid": props.testId,
|
|
10
10
|
children: [/* @__PURE__ */ jsx("span", {
|
|
11
11
|
ref: props.errorMessageRef,
|
package/lib/ErrorWrapper.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorWrapper.js","names":[],"sources":["../src/components/ErrorWrapper/ErrorWrapper.tsx","../src/components/ErrorWrapper/index.ts"],"sourcesContent":["import cn from 'classnames';\n\nimport styles from './styles.module.scss';\n\nexport interface ErrorWrapperClassNameProps {\n errorWrapperClassName?: string;\n}\n\nexport interface ErrorWrapperProps {\n /** Form component */\n children?: React.ReactNode;\n /** Error message */\n errorText?: string;\n /** Error text id */\n errorTextId?: string;\n /** Adds custom classes to the element. */\n className?: string;\n /** Adds a ref to the error message p tag */\n errorMessageRef?: React.Ref<HTMLDivElement>;\n /** Renders the error component (Default: true) */\n renderError?: boolean;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport const ErrorWrapper: React.FC<ErrorWrapperProps> = props => {\n const { renderError = true } = props;\n\n const errorWrapperClasses = cn(props.errorText && renderError && styles[`error-wrapper--with-error`], props.className);\n\n return (\n <div className={errorWrapperClasses} data-testid={props.testId}>\n <span ref={props.errorMessageRef} tabIndex={-1}>\n {props.errorText && (\n <p className={styles['error-wrapper__errors']} id={props.errorTextId}>\n {props.errorText}\n </p>\n )}\n </span>\n {props.children}\n </div>\n );\n};\n\nexport default ErrorWrapper;\n","import ErrorWrapper from './ErrorWrapper';\nexport * from './ErrorWrapper';\nexport default ErrorWrapper;\n"],"mappings":";;;;AAyBA,IAAa,gBAA4C,UAAS;CAChE,MAAM,EAAE,cAAc,SAAS;CAI/B,OACE,qBAAC,OAAD;EAAK,WAHqB,
|
|
1
|
+
{"version":3,"file":"ErrorWrapper.js","names":[],"sources":["../src/components/ErrorWrapper/ErrorWrapper.tsx","../src/components/ErrorWrapper/index.ts"],"sourcesContent":["import cn from 'classnames';\n\nimport styles from './styles.module.scss';\n\nexport interface ErrorWrapperClassNameProps {\n errorWrapperClassName?: string;\n}\n\nexport interface ErrorWrapperProps {\n /** Form component */\n children?: React.ReactNode;\n /** Error message */\n errorText?: string;\n /** Error text id */\n errorTextId?: string;\n /** Adds custom classes to the element. */\n className?: string;\n /** Adds a ref to the error message p tag */\n errorMessageRef?: React.Ref<HTMLDivElement>;\n /** Renders the error component (Default: true) */\n renderError?: boolean;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport const ErrorWrapper: React.FC<ErrorWrapperProps> = props => {\n const { renderError = true } = props;\n\n const errorWrapperClasses = cn(props.errorText && renderError && styles[`error-wrapper--with-error`], props.className);\n\n return (\n <div className={errorWrapperClasses} data-testid={props.testId}>\n <span ref={props.errorMessageRef} tabIndex={-1}>\n {props.errorText && (\n <p className={styles['error-wrapper__errors']} id={props.errorTextId}>\n {props.errorText}\n </p>\n )}\n </span>\n {props.children}\n </div>\n );\n};\n\nexport default ErrorWrapper;\n","import ErrorWrapper from './ErrorWrapper';\nexport * from './ErrorWrapper';\nexport default ErrorWrapper;\n"],"mappings":";;;;AAyBA,IAAa,gBAA4C,UAAS;CAChE,MAAM,EAAE,cAAc,SAAS;CAI/B,OACE,qBAAC,OAAD;EAAK,WAHqB,GAAG,MAAM,aAAa,eAAe,OAAO,8BAA8B,MAAM,SAG1F;EAAqB,eAAa,MAAM;YAAxD,CACE,oBAAC,QAAD;GAAM,KAAK,MAAM;GAAiB,UAAU;aACzC,MAAM,aACL,oBAAC,KAAD;IAAG,WAAW,OAAO;IAA0B,IAAI,MAAM;cACtD,MAAM;GACN,CAAA;EAED,CAAA,GACL,MAAM,QACJ;;AAET;;;ACxCA,IAAA,uBAAe"}
|
package/lib/Expander.js
CHANGED
|
@@ -7,7 +7,7 @@ import { useSize } from "./hooks/useSize.js";
|
|
|
7
7
|
import ChevronDown from "./components/Icons/ChevronDown.js";
|
|
8
8
|
import ChevronUp from "./components/Icons/ChevronUp.js";
|
|
9
9
|
import { useExpand } from "./hooks/useExpand.js";
|
|
10
|
-
import
|
|
10
|
+
import cn from "classnames";
|
|
11
11
|
import { useRef } from "react";
|
|
12
12
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
13
|
import styles from "./components/Expander/styles.module.scss";
|
|
@@ -29,14 +29,14 @@ var Expander = (props) => {
|
|
|
29
29
|
const triggerSize = useSize(triggerRef);
|
|
30
30
|
const isSticky = sticky && isExpanded;
|
|
31
31
|
const renderChevron = (align) => /* @__PURE__ */ jsx("span", {
|
|
32
|
-
className:
|
|
32
|
+
className: cn(styles["expander__icon"], styles[`expander__icon--${align}`]),
|
|
33
33
|
children: /* @__PURE__ */ jsx(Icon_default, {
|
|
34
34
|
svgIcon: isExpanded ? ChevronUp : ChevronDown,
|
|
35
35
|
size: IconSize.XSmall,
|
|
36
36
|
isHovered
|
|
37
37
|
})
|
|
38
38
|
});
|
|
39
|
-
const triggerClassName =
|
|
39
|
+
const triggerClassName = cn(styles["expander__trigger"], size === ExpanderSize.large && styles[`expander__trigger--${size}`], size === ExpanderSize.large && styles[`expander__trigger--${color || "neutral"}`], size === ExpanderSize.large && icon && styles["expander__trigger--icon"], isExpanded && styles["expander__trigger--expanded"], isSticky && styles["expander__trigger--sticky"]);
|
|
40
40
|
const renderTrigger = () => /* @__PURE__ */ jsxs("button", {
|
|
41
41
|
id: buttonId,
|
|
42
42
|
type: "button",
|
|
@@ -53,7 +53,7 @@ var Expander = (props) => {
|
|
|
53
53
|
children: [
|
|
54
54
|
size === ExpanderSize.small && renderChevron("left"),
|
|
55
55
|
icon && /* @__PURE__ */ jsx("span", {
|
|
56
|
-
className:
|
|
56
|
+
className: cn(styles["expander__icon"], styles["expander__icon--left"]),
|
|
57
57
|
children: typeof icon === "string" ? /* @__PURE__ */ jsx(LazyIcon_default, {
|
|
58
58
|
iconName: icon,
|
|
59
59
|
size: IconSize.XSmall,
|
|
@@ -68,13 +68,13 @@ var Expander = (props) => {
|
|
|
68
68
|
size === ExpanderSize.large && renderChevron("right")
|
|
69
69
|
]
|
|
70
70
|
});
|
|
71
|
-
const buttonClassName =
|
|
71
|
+
const buttonClassName = cn(styles["expander__button"], isExpanded && styles["expander__button--expanded"]);
|
|
72
72
|
const renderButton = () => /* @__PURE__ */ jsx("div", {
|
|
73
73
|
style: {
|
|
74
74
|
width: isSticky && triggerSize?.width ? `${triggerSize?.width}px` : void 0,
|
|
75
75
|
height: isSticky && triggerSize?.height ? `${triggerSize?.height}px` : void 0
|
|
76
76
|
},
|
|
77
|
-
className:
|
|
77
|
+
className: cn(styles["expander__button-container"], { [styles["expander__button-container--sticky"]]: isSticky }),
|
|
78
78
|
children: /* @__PURE__ */ jsxs(Button_default, {
|
|
79
79
|
id: buttonId,
|
|
80
80
|
variant: "borderless",
|
|
@@ -93,9 +93,9 @@ var Expander = (props) => {
|
|
|
93
93
|
});
|
|
94
94
|
const renderContent = () => {
|
|
95
95
|
if (!renderChildrenWhenClosed && !isExpanded) return null;
|
|
96
|
-
const contentClassName =
|
|
96
|
+
const contentClassName = cn(styles["expander__content"], styles[`expander__content--${size}`], size === ExpanderSize.large && styles[`expander__content--${color || "neutral"}`], size === ExpanderSize.large && icon && styles["expander__content--icon"], isExpanded && styles["expander__content--expanded"], size === ExpanderSize.small && !noNestedLine && styles["expander__content--nested-line--inner"], emphasized && styles["expander__content--emphasized"], { [styles["expander__content--sticky"]]: isSticky }, contentClassNames);
|
|
97
97
|
return /* @__PURE__ */ jsx("div", {
|
|
98
|
-
className:
|
|
98
|
+
className: cn(size === ExpanderSize.small && !emphasized && !noNestedLine && styles["expander__content--nested-line--outer"]),
|
|
99
99
|
children: /* @__PURE__ */ jsx("div", {
|
|
100
100
|
className: contentClassName,
|
|
101
101
|
children
|
package/lib/Expander.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Expander.js","names":[],"sources":["../src/components/Expander/constants.ts","../src/components/Expander/Expander.tsx","../src/components/Expander/index.ts"],"sourcesContent":["export enum ExpanderSize {\n small = 'small',\n large = 'large',\n}\n","import { useRef } from 'react';\n\nimport classNames from 'classnames';\n\nimport type { PaletteNames } from '../../theme/palette';\nimport type { SvgIcon } from '../Icon';\nimport type { IconName } from '../Icons/IconNames';\n\nimport { ExpanderSize } from './constants';\nimport { AnalyticsId } from '../../constants';\nimport { useExpand } from '../../hooks/useExpand';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { useSize } from '../../hooks/useSize';\nimport Button from '../Button';\nimport Icon, { IconSize } from '../Icon';\nimport ChevronDown from '../Icons/ChevronDown';\nimport ChevronUp from '../Icons/ChevronUp';\nimport LazyIcon from '../LazyIcon';\n\nimport styles from './styles.module.scss';\n\nexport type ExpanderColors = Extract<PaletteNames, 'banana' | 'blueberry' | 'cherry' | 'kiwi' | 'neutral' | 'plum' | 'white'>;\n\nexport interface ExpanderProps {\n buttonId?: string;\n /** Sets the trigger title */\n title: string;\n /** Sets the expanded content */\n children?: React.ReactNode;\n /** Sets classnames on the content area */\n contentClassNames?: string;\n /** Sets the size of the expander. Default: ExpanderSize.small */\n size?: ExpanderSize;\n /** Sets the background of the expander. Requires size=ExpanderSize.large. */\n color?: ExpanderColors;\n /** Adds an icon to the expander trigger. Requires size=ExpanderSize.large. */\n svgIcon?: SvgIcon | IconName;\n /** Opens or closes the expander */\n expanded?: boolean;\n /** Removes border to the left of the content. Requires size=ExpanderSize.small. */\n noNestedLine?: boolean;\n /** Emphasizes the content section. Intended for size=ExpanderSize.small. */\n emphasized?: boolean;\n /** Stick expander trigger to top of screen while scrolling down */\n sticky?: boolean;\n /** Called when expander is open/closed. */\n onExpand?: (isExpanded: boolean) => void;\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 on the expander button. */\n testId?: string;\n /** Overrides the default z-index of the expander header */\n zIndex?: number;\n}\n\nconst Expander: React.FC<ExpanderProps> = props => {\n const {\n buttonId,\n title,\n children,\n size = ExpanderSize.small,\n color,\n contentClassNames,\n svgIcon: icon,\n expanded = false,\n noNestedLine = false,\n emphasized = false,\n sticky = false,\n testId,\n onExpand,\n renderChildrenWhenClosed = false,\n zIndex,\n } = props;\n const [isExpanded, setIsExpanded] = useExpand(expanded, onExpand);\n const expanderRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const { isHovered } = usePseudoClasses(triggerRef);\n const contentSize = useSize(expanderRef);\n const triggerSize = useSize(triggerRef);\n\n const isSticky = sticky && isExpanded;\n\n const renderChevron = (align: 'left' | 'right'): React.ReactNode => (\n <span className={classNames(styles['expander__icon'], styles[`expander__icon--${align}`])}>\n <Icon svgIcon={isExpanded ? ChevronUp : ChevronDown} size={IconSize.XSmall} isHovered={isHovered} />\n </span>\n );\n\n const triggerClassName = classNames(\n styles['expander__trigger'],\n size === ExpanderSize.large && styles[`expander__trigger--${size}`],\n size === ExpanderSize.large && styles[`expander__trigger--${color || 'neutral'}`],\n size === ExpanderSize.large && icon && styles['expander__trigger--icon'],\n isExpanded && styles['expander__trigger--expanded'],\n isSticky && styles['expander__trigger--sticky']\n );\n\n const renderTrigger = (): React.ReactNode => (\n <button\n id={buttonId}\n type=\"button\"\n className={triggerClassName}\n style={{\n zIndex: isHovered || isSticky ? zIndex : undefined,\n width: isSticky && contentSize?.width ? `${contentSize.width}px` : undefined,\n }}\n aria-expanded={isExpanded}\n ref={triggerRef}\n onClick={(): void => setIsExpanded(!isExpanded)}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Expander}\n >\n {size === ExpanderSize.small && renderChevron('left')}\n {icon && (\n <span className={classNames(styles['expander__icon'], styles['expander__icon--left'])}>\n {typeof icon === 'string' ? (\n <LazyIcon iconName={icon} size={IconSize.XSmall} isHovered={isHovered} />\n ) : (\n <Icon svgIcon={icon} size={IconSize.XSmall} isHovered={isHovered} />\n )}\n </span>\n )}\n {title}\n {size === ExpanderSize.large && renderChevron('right')}\n </button>\n );\n\n const buttonClassName = classNames(styles['expander__button'], isExpanded && styles['expander__button--expanded']);\n\n const renderButton = (): React.ReactNode => (\n <div\n style={{\n width: isSticky && triggerSize?.width ? `${triggerSize?.width}px` : undefined,\n height: isSticky && triggerSize?.height ? `${triggerSize?.height}px` : undefined,\n }}\n className={classNames(styles['expander__button-container'], {\n [styles['expander__button-container--sticky']]: isSticky,\n })}\n >\n <Button\n id={buttonId}\n variant=\"borderless\"\n textClassName={styles['expander__button__text']}\n className={buttonClassName}\n aria-expanded={isExpanded}\n ref={triggerRef}\n onClick={(): void => setIsExpanded(!isExpanded)}\n testId={testId}\n data-analyticsid={AnalyticsId.Expander}\n >\n <Icon svgIcon={isExpanded ? ChevronUp : ChevronDown} size={IconSize.XSmall} />\n {title}\n </Button>\n </div>\n );\n\n const renderContent = (): React.ReactNode => {\n if (!renderChildrenWhenClosed && !isExpanded) {\n return null;\n }\n\n const contentClassName = classNames(\n styles['expander__content'],\n styles[`expander__content--${size}`],\n size === ExpanderSize.large && styles[`expander__content--${color || 'neutral'}`],\n size === ExpanderSize.large && icon && styles['expander__content--icon'],\n isExpanded && styles['expander__content--expanded'],\n size === ExpanderSize.small && !noNestedLine && styles['expander__content--nested-line--inner'],\n emphasized && styles['expander__content--emphasized'],\n { [styles['expander__content--sticky']]: isSticky },\n contentClassNames\n );\n const leftBorderClassName = classNames(\n size === ExpanderSize.small && !emphasized && !noNestedLine && styles['expander__content--nested-line--outer']\n );\n\n return (\n <div className={leftBorderClassName}>\n <div className={contentClassName}>{children}</div>\n </div>\n );\n };\n\n return (\n <div className={styles['expander']} ref={expanderRef}>\n {size === ExpanderSize.large ? renderTrigger() : renderButton()}\n {renderContent()}\n </div>\n );\n};\n\nexport default Expander;\n","import Expander from './Expander';\nexport { ExpanderSize } from './constants';\nexport * from './Expander';\nexport default Expander;\n"],"mappings":";;;;;;;;;;;;;;AAAA,IAAY,eAAL,yBAAA,cAAA;CACL,aAAA,WAAA;CACA,aAAA,WAAA;;AACF,EAAA,CAAA,CAAA;;;ACoDA,IAAM,YAAoC,UAAS;CACjD,MAAM,EACJ,UACA,OACA,UACA,OAAO,aAAa,OACpB,OACA,mBACA,SAAS,MACT,WAAW,OACX,eAAe,OACf,aAAa,OACb,SAAS,OACT,QACA,UACA,2BAA2B,OAC3B,WACE;CACJ,MAAM,CAAC,YAAY,iBAAiB,UAAU,UAAU,QAAQ;CAChE,MAAM,cAAc,OAAuB,IAAI;CAC/C,MAAM,aAAa,OAA0B,IAAI;CACjD,MAAM,EAAE,cAAc,iBAAiB,UAAU;CACjD,MAAM,cAAc,QAAQ,WAAW;CACvC,MAAM,cAAc,QAAQ,UAAU;CAEtC,MAAM,WAAW,UAAU;CAE3B,MAAM,iBAAiB,UACrB,oBAAC,QAAD;EAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"Expander.js","names":[],"sources":["../src/components/Expander/constants.ts","../src/components/Expander/Expander.tsx","../src/components/Expander/index.ts"],"sourcesContent":["export enum ExpanderSize {\n small = 'small',\n large = 'large',\n}\n","import { useRef } from 'react';\n\nimport classNames from 'classnames';\n\nimport type { PaletteNames } from '../../theme/palette';\nimport type { SvgIcon } from '../Icon';\nimport type { IconName } from '../Icons/IconNames';\n\nimport { ExpanderSize } from './constants';\nimport { AnalyticsId } from '../../constants';\nimport { useExpand } from '../../hooks/useExpand';\nimport { usePseudoClasses } from '../../hooks/usePseudoClasses';\nimport { useSize } from '../../hooks/useSize';\nimport Button from '../Button';\nimport Icon, { IconSize } from '../Icon';\nimport ChevronDown from '../Icons/ChevronDown';\nimport ChevronUp from '../Icons/ChevronUp';\nimport LazyIcon from '../LazyIcon';\n\nimport styles from './styles.module.scss';\n\nexport type ExpanderColors = Extract<PaletteNames, 'banana' | 'blueberry' | 'cherry' | 'kiwi' | 'neutral' | 'plum' | 'white'>;\n\nexport interface ExpanderProps {\n buttonId?: string;\n /** Sets the trigger title */\n title: string;\n /** Sets the expanded content */\n children?: React.ReactNode;\n /** Sets classnames on the content area */\n contentClassNames?: string;\n /** Sets the size of the expander. Default: ExpanderSize.small */\n size?: ExpanderSize;\n /** Sets the background of the expander. Requires size=ExpanderSize.large. */\n color?: ExpanderColors;\n /** Adds an icon to the expander trigger. Requires size=ExpanderSize.large. */\n svgIcon?: SvgIcon | IconName;\n /** Opens or closes the expander */\n expanded?: boolean;\n /** Removes border to the left of the content. Requires size=ExpanderSize.small. */\n noNestedLine?: boolean;\n /** Emphasizes the content section. Intended for size=ExpanderSize.small. */\n emphasized?: boolean;\n /** Stick expander trigger to top of screen while scrolling down */\n sticky?: boolean;\n /** Called when expander is open/closed. */\n onExpand?: (isExpanded: boolean) => void;\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 on the expander button. */\n testId?: string;\n /** Overrides the default z-index of the expander header */\n zIndex?: number;\n}\n\nconst Expander: React.FC<ExpanderProps> = props => {\n const {\n buttonId,\n title,\n children,\n size = ExpanderSize.small,\n color,\n contentClassNames,\n svgIcon: icon,\n expanded = false,\n noNestedLine = false,\n emphasized = false,\n sticky = false,\n testId,\n onExpand,\n renderChildrenWhenClosed = false,\n zIndex,\n } = props;\n const [isExpanded, setIsExpanded] = useExpand(expanded, onExpand);\n const expanderRef = useRef<HTMLDivElement>(null);\n const triggerRef = useRef<HTMLButtonElement>(null);\n const { isHovered } = usePseudoClasses(triggerRef);\n const contentSize = useSize(expanderRef);\n const triggerSize = useSize(triggerRef);\n\n const isSticky = sticky && isExpanded;\n\n const renderChevron = (align: 'left' | 'right'): React.ReactNode => (\n <span className={classNames(styles['expander__icon'], styles[`expander__icon--${align}`])}>\n <Icon svgIcon={isExpanded ? ChevronUp : ChevronDown} size={IconSize.XSmall} isHovered={isHovered} />\n </span>\n );\n\n const triggerClassName = classNames(\n styles['expander__trigger'],\n size === ExpanderSize.large && styles[`expander__trigger--${size}`],\n size === ExpanderSize.large && styles[`expander__trigger--${color || 'neutral'}`],\n size === ExpanderSize.large && icon && styles['expander__trigger--icon'],\n isExpanded && styles['expander__trigger--expanded'],\n isSticky && styles['expander__trigger--sticky']\n );\n\n const renderTrigger = (): React.ReactNode => (\n <button\n id={buttonId}\n type=\"button\"\n className={triggerClassName}\n style={{\n zIndex: isHovered || isSticky ? zIndex : undefined,\n width: isSticky && contentSize?.width ? `${contentSize.width}px` : undefined,\n }}\n aria-expanded={isExpanded}\n ref={triggerRef}\n onClick={(): void => setIsExpanded(!isExpanded)}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Expander}\n >\n {size === ExpanderSize.small && renderChevron('left')}\n {icon && (\n <span className={classNames(styles['expander__icon'], styles['expander__icon--left'])}>\n {typeof icon === 'string' ? (\n <LazyIcon iconName={icon} size={IconSize.XSmall} isHovered={isHovered} />\n ) : (\n <Icon svgIcon={icon} size={IconSize.XSmall} isHovered={isHovered} />\n )}\n </span>\n )}\n {title}\n {size === ExpanderSize.large && renderChevron('right')}\n </button>\n );\n\n const buttonClassName = classNames(styles['expander__button'], isExpanded && styles['expander__button--expanded']);\n\n const renderButton = (): React.ReactNode => (\n <div\n style={{\n width: isSticky && triggerSize?.width ? `${triggerSize?.width}px` : undefined,\n height: isSticky && triggerSize?.height ? `${triggerSize?.height}px` : undefined,\n }}\n className={classNames(styles['expander__button-container'], {\n [styles['expander__button-container--sticky']]: isSticky,\n })}\n >\n <Button\n id={buttonId}\n variant=\"borderless\"\n textClassName={styles['expander__button__text']}\n className={buttonClassName}\n aria-expanded={isExpanded}\n ref={triggerRef}\n onClick={(): void => setIsExpanded(!isExpanded)}\n testId={testId}\n data-analyticsid={AnalyticsId.Expander}\n >\n <Icon svgIcon={isExpanded ? ChevronUp : ChevronDown} size={IconSize.XSmall} />\n {title}\n </Button>\n </div>\n );\n\n const renderContent = (): React.ReactNode => {\n if (!renderChildrenWhenClosed && !isExpanded) {\n return null;\n }\n\n const contentClassName = classNames(\n styles['expander__content'],\n styles[`expander__content--${size}`],\n size === ExpanderSize.large && styles[`expander__content--${color || 'neutral'}`],\n size === ExpanderSize.large && icon && styles['expander__content--icon'],\n isExpanded && styles['expander__content--expanded'],\n size === ExpanderSize.small && !noNestedLine && styles['expander__content--nested-line--inner'],\n emphasized && styles['expander__content--emphasized'],\n { [styles['expander__content--sticky']]: isSticky },\n contentClassNames\n );\n const leftBorderClassName = classNames(\n size === ExpanderSize.small && !emphasized && !noNestedLine && styles['expander__content--nested-line--outer']\n );\n\n return (\n <div className={leftBorderClassName}>\n <div className={contentClassName}>{children}</div>\n </div>\n );\n };\n\n return (\n <div className={styles['expander']} ref={expanderRef}>\n {size === ExpanderSize.large ? renderTrigger() : renderButton()}\n {renderContent()}\n </div>\n );\n};\n\nexport default Expander;\n","import Expander from './Expander';\nexport { ExpanderSize } from './constants';\nexport * from './Expander';\nexport default Expander;\n"],"mappings":";;;;;;;;;;;;;;AAAA,IAAY,eAAL,yBAAA,cAAA;CACL,aAAA,WAAA;CACA,aAAA,WAAA;;AACF,EAAA,CAAA,CAAA;;;ACoDA,IAAM,YAAoC,UAAS;CACjD,MAAM,EACJ,UACA,OACA,UACA,OAAO,aAAa,OACpB,OACA,mBACA,SAAS,MACT,WAAW,OACX,eAAe,OACf,aAAa,OACb,SAAS,OACT,QACA,UACA,2BAA2B,OAC3B,WACE;CACJ,MAAM,CAAC,YAAY,iBAAiB,UAAU,UAAU,QAAQ;CAChE,MAAM,cAAc,OAAuB,IAAI;CAC/C,MAAM,aAAa,OAA0B,IAAI;CACjD,MAAM,EAAE,cAAc,iBAA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,MAAM,MAAM,KAAA;GACpE,QAAQ,YAAY,aAAa,SAAS,GAAG,aAAa,OAAO,MAAM,KAAA;EACzE;EACA,WAAW,GAAW,OAAO,+BAA+B,GACzD,OAAO,wCAAwC,SAClD,CAAC;YAED,qBAAC,gBAAD;GACE,IAAI;GACJ,SAAQ;GACR,eAAe,OAAO;GACtB,WAAW;GACX,iBAAe;GACf,KAAK;GACL,eAAqB,cAAc,CAAC,UAAU;GACtC;GACR,oBAAkB,YAAY;aAThC,CAWE,oBAAC,cAAD;IAAM,SAAS,aAAa,YAAY;IAAa,MAAM,SAAS;GAAS,CAAA,GAC5E,KACK;;CACL,CAAA;CAGP,MAAM,sBAAuC;EAC3C,IAAI,CAAC,4BAA4B,CAAC,YAChC,OAAO;EAGT,MAAM,mBAAmB,GACvB,OAAO,sBACP,OAAO,sBAAsB,SAC7B,SAAS,aAAa,SAAS,OAAO,sBAAsB,SAAS,cACrE,SAAS,aAAa,SAAS,QAAQ,OAAO,4BAC9C,cAAc,OAAO,gCACrB,SAAS,aAAa,SAAS,CAAC,gBAAgB,OAAO,0CACvD,cAAc,OAAO,kCACrB,GAAG,OAAO,+BAA+B,SAAS,GAClD,iBACF;EAKA,OACE,oBAAC,OAAD;GAAK,WALqB,GAC1B,SAAS,aAAa,SAAS,CAAC,cAAc,CAAC,gBAAgB,OAAO,wCAItD;aACd,oBAAC,OAAD;IAAK,WAAW;IAAmB;GAAc,CAAA;EAC9C,CAAA;CAET;CAEA,OACE,qBAAC,OAAD;EAAK,WAAW,OAAO;EAAa,KAAK;YAAzC,CACG,SAAS,aAAa,QAAQ,cAAc,IAAI,aAAa,GAC7D,cAAc,CACZ;;AAET;;;AC1LA,IAAA,mBAAe"}
|
package/lib/FilterButton.js
CHANGED
|
@@ -4,7 +4,7 @@ import { t as Icon_default } from "./Icon.js";
|
|
|
4
4
|
import { useLanguage } from "./hooks/useLanguage.js";
|
|
5
5
|
import Filter from "./components/Icons/Filter.js";
|
|
6
6
|
import { t as getResources } from "./resourceHelper.js";
|
|
7
|
-
import
|
|
7
|
+
import cn from "classnames";
|
|
8
8
|
import { useRef } from "react";
|
|
9
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
10
|
import styles from "./components/Filter/FilterButton/styles.module.scss";
|
|
@@ -23,7 +23,7 @@ var FilterButton = (props) => {
|
|
|
23
23
|
className: styles["filter-button"],
|
|
24
24
|
ref: buttonRef,
|
|
25
25
|
children: /* @__PURE__ */ jsxs("span", {
|
|
26
|
-
className:
|
|
26
|
+
className: cn(styles["filter-button__inner"], { [styles["filter-button__inner--hovered"]]: isHovered }),
|
|
27
27
|
children: [/* @__PURE__ */ jsx(Icon_default, {
|
|
28
28
|
svgIcon: Filter,
|
|
29
29
|
isHovered,
|
package/lib/FilterButton.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterButton.js","names":[],"sources":["../src/components/Filter/FilterButton/FilterButton.tsx","../src/components/Filter/FilterButton/index.ts"],"sourcesContent":["import { useRef } from 'react';\n\nimport classNames from 'classnames';\n\nimport type { HNDesignsystemFilter } from '../../../resources/Resources';\n\nimport { IconSize, LanguageLocales } from '../../../constants';\nimport { useLanguage } from '../../../hooks/useLanguage';\nimport { usePseudoClasses } from '../../../hooks/usePseudoClasses';\nimport Icon from '../../Icon';\nimport Filter from '../../Icons/Filter';\nimport { getResources } from '../resourceHelper';\n\nimport styles from './styles.module.scss';\n\nexport interface FilterButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n /** Texts if overriding SOT */\n resources?: Partial<HNDesignsystemFilter>;\n}\n\nconst FilterButton: React.FC<FilterButtonProps> = props => {\n const { resources } = props;\n\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n\n const mergedResources = {\n ...defaultResources,\n ...resources,\n };\n\n const buttonRef = useRef<HTMLButtonElement>(null);\n const { isHovered } = usePseudoClasses(buttonRef);\n\n return (\n <button {...props} className={styles['filter-button']} ref={buttonRef}>\n <span\n className={classNames(styles['filter-button__inner'], {\n [styles['filter-button__inner--hovered']]: isHovered,\n })}\n >\n <Icon svgIcon={Filter} isHovered={isHovered} size={IconSize.XSmall} />\n <span className={styles['filter-button__text']}>{mergedResources.filterButtonText}</span>\n </span>\n </button>\n );\n};\n\nexport default FilterButton;\n","import FilterButton from './FilterButton';\nexport * from './FilterButton';\nexport default FilterButton;\n"],"mappings":";;;;;;;;;;;AAoBA,IAAM,gBAA4C,UAAS;CACzD,MAAM,EAAE,cAAc;CAEtB,MAAM,EAAE,aAAa,YAA6B,gBAAgB,SAAS;CAG3E,MAAM,kBAAkB;EACtB,GAHuB,aAAa,QAGjC;EACH,GAAG;CACL;CAEA,MAAM,YAAY,OAA0B,IAAI;CAChD,MAAM,EAAE,cAAc,iBAAiB,SAAS;CAEhD,OACE,oBAAC,UAAD;EAAQ,GAAI;EAAO,WAAW,OAAO;EAAkB,KAAK;YAC1D,qBAAC,QAAD;GACE,WAAW,
|
|
1
|
+
{"version":3,"file":"FilterButton.js","names":[],"sources":["../src/components/Filter/FilterButton/FilterButton.tsx","../src/components/Filter/FilterButton/index.ts"],"sourcesContent":["import { useRef } from 'react';\n\nimport classNames from 'classnames';\n\nimport type { HNDesignsystemFilter } from '../../../resources/Resources';\n\nimport { IconSize, LanguageLocales } from '../../../constants';\nimport { useLanguage } from '../../../hooks/useLanguage';\nimport { usePseudoClasses } from '../../../hooks/usePseudoClasses';\nimport Icon from '../../Icon';\nimport Filter from '../../Icons/Filter';\nimport { getResources } from '../resourceHelper';\n\nimport styles from './styles.module.scss';\n\nexport interface FilterButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n /** Texts if overriding SOT */\n resources?: Partial<HNDesignsystemFilter>;\n}\n\nconst FilterButton: React.FC<FilterButtonProps> = props => {\n const { resources } = props;\n\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n\n const mergedResources = {\n ...defaultResources,\n ...resources,\n };\n\n const buttonRef = useRef<HTMLButtonElement>(null);\n const { isHovered } = usePseudoClasses(buttonRef);\n\n return (\n <button {...props} className={styles['filter-button']} ref={buttonRef}>\n <span\n className={classNames(styles['filter-button__inner'], {\n [styles['filter-button__inner--hovered']]: isHovered,\n })}\n >\n <Icon svgIcon={Filter} isHovered={isHovered} size={IconSize.XSmall} />\n <span className={styles['filter-button__text']}>{mergedResources.filterButtonText}</span>\n </span>\n </button>\n );\n};\n\nexport default FilterButton;\n","import FilterButton from './FilterButton';\nexport * from './FilterButton';\nexport default FilterButton;\n"],"mappings":";;;;;;;;;;;AAoBA,IAAM,gBAA4C,UAAS;CACzD,MAAM,EAAE,cAAc;CAEtB,MAAM,EAAE,aAAa,YAA6B,gBAAgB,SAAS;CAG3E,MAAM,kBAAkB;EACtB,GAHuB,aAAa,QAGjC;EACH,GAAG;CACL;CAEA,MAAM,YAAY,OAA0B,IAAI;CAChD,MAAM,EAAE,cAAc,iBAAiB,SAAS;CAEhD,OACE,oBAAC,UAAD;EAAQ,GAAI;EAAO,WAAW,OAAO;EAAkB,KAAK;YAC1D,qBAAC,QAAD;GACE,WAAW,GAAW,OAAO,yBAAyB,GACnD,OAAO,mCAAmC,UAC7C,CAAC;aAHH,CAKE,oBAAC,cAAD;IAAM,SAAS;IAAmB;IAAW,MAAM,SAAS;GAAS,CAAA,GACrE,oBAAC,QAAD;IAAM,WAAW,OAAO;cAAyB,gBAAgB;GAAuB,CAAA,CACpF;;CACA,CAAA;AAEZ;;;AC5CA,IAAA,uBAAe"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { LanguageLocales } from "./constants.js";
|
|
2
2
|
import { useLanguage } from "./hooks/useLanguage.js";
|
|
3
3
|
import { t as getResources } from "./resourceHelper.js";
|
|
4
|
-
import
|
|
4
|
+
import cn from "classnames";
|
|
5
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
import styles from "./components/Filter/FilterButtonAndChipsWrapper/styles.module.scss";
|
|
7
7
|
//#region src/components/Filter/FilterButtonAndChipsWrapper/FilterButtonAndChipsWrapper.tsx
|
|
@@ -12,7 +12,7 @@ var FilterButtonAndChipsWrapper = ({ filterButtonComponent, filterChips, testId,
|
|
|
12
12
|
...resources
|
|
13
13
|
};
|
|
14
14
|
return /* @__PURE__ */ jsxs("div", {
|
|
15
|
-
className:
|
|
15
|
+
className: cn(styles["filter-chip-bar"]),
|
|
16
16
|
"data-testid": testId,
|
|
17
17
|
children: [filterButtonComponent, /* @__PURE__ */ jsx("ul", {
|
|
18
18
|
"aria-label": mergedResources.activeFiltersListLabel,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterButtonAndChipsWrapper.js","names":[],"sources":["../src/components/Filter/FilterButtonAndChipsWrapper/FilterButtonAndChipsWrapper.tsx","../src/components/Filter/FilterButtonAndChipsWrapper/index.ts"],"sourcesContent":["import type React from 'react';\n\nimport classNames from 'classnames';\n\nimport type { HNDesignsystemFilter } from '../../../resources/Resources';\n\nimport { LanguageLocales } from '../../../constants';\nimport { useLanguage } from '../../../hooks/useLanguage';\nimport { getResources } from '../resourceHelper';\n\nimport styles from './styles.module.scss';\n\nexport interface FilterButtonAndChipsWrapperProps {\n /** FilterButton content area */\n filterButtonComponent: React.ReactNode;\n /** Content area for rendering filter chips */\n filterChips: React.ReactNode[];\n /** test id that is placed on the wrapper */\n testId?: string;\n /** Resources for the component */\n resources?: Partial<HNDesignsystemFilter>;\n}\n\nconst FilterButtonAndChipsWrapper: React.FC<FilterButtonAndChipsWrapperProps> = ({\n filterButtonComponent,\n filterChips,\n testId,\n resources,\n}) => {\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n\n const mergedResources = {\n ...defaultResources,\n ...resources,\n };\n return (\n <div className={classNames(styles['filter-chip-bar'])} data-testid={testId}>\n {filterButtonComponent}\n <ul aria-label={mergedResources.activeFiltersListLabel} className={styles['filter-chip-bar__list']}>\n {filterChips.map((activefilter, index) => (\n <li key={index}>{activefilter}</li>\n ))}\n </ul>\n </div>\n );\n};\n\nexport default FilterButtonAndChipsWrapper;\n","import FilterButtonAndChipsWrapper from './FilterButtonAndChipsWrapper';\nexport * from './FilterButtonAndChipsWrapper';\nexport default FilterButtonAndChipsWrapper;\n"],"mappings":";;;;;;;AAuBA,IAAM,+BAA2E,EAC/E,uBACA,aACA,QACA,gBACI;CACJ,MAAM,EAAE,aAAa,YAA6B,gBAAgB,SAAS;CAG3E,MAAM,kBAAkB;EACtB,GAHuB,aAAa,QAGjC;EACH,GAAG;CACL;CACA,OACE,qBAAC,OAAD;EAAK,WAAW,
|
|
1
|
+
{"version":3,"file":"FilterButtonAndChipsWrapper.js","names":[],"sources":["../src/components/Filter/FilterButtonAndChipsWrapper/FilterButtonAndChipsWrapper.tsx","../src/components/Filter/FilterButtonAndChipsWrapper/index.ts"],"sourcesContent":["import type React from 'react';\n\nimport classNames from 'classnames';\n\nimport type { HNDesignsystemFilter } from '../../../resources/Resources';\n\nimport { LanguageLocales } from '../../../constants';\nimport { useLanguage } from '../../../hooks/useLanguage';\nimport { getResources } from '../resourceHelper';\n\nimport styles from './styles.module.scss';\n\nexport interface FilterButtonAndChipsWrapperProps {\n /** FilterButton content area */\n filterButtonComponent: React.ReactNode;\n /** Content area for rendering filter chips */\n filterChips: React.ReactNode[];\n /** test id that is placed on the wrapper */\n testId?: string;\n /** Resources for the component */\n resources?: Partial<HNDesignsystemFilter>;\n}\n\nconst FilterButtonAndChipsWrapper: React.FC<FilterButtonAndChipsWrapperProps> = ({\n filterButtonComponent,\n filterChips,\n testId,\n resources,\n}) => {\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n\n const mergedResources = {\n ...defaultResources,\n ...resources,\n };\n return (\n <div className={classNames(styles['filter-chip-bar'])} data-testid={testId}>\n {filterButtonComponent}\n <ul aria-label={mergedResources.activeFiltersListLabel} className={styles['filter-chip-bar__list']}>\n {filterChips.map((activefilter, index) => (\n <li key={index}>{activefilter}</li>\n ))}\n </ul>\n </div>\n );\n};\n\nexport default FilterButtonAndChipsWrapper;\n","import FilterButtonAndChipsWrapper from './FilterButtonAndChipsWrapper';\nexport * from './FilterButtonAndChipsWrapper';\nexport default FilterButtonAndChipsWrapper;\n"],"mappings":";;;;;;;AAuBA,IAAM,+BAA2E,EAC/E,uBACA,aACA,QACA,gBACI;CACJ,MAAM,EAAE,aAAa,YAA6B,gBAAgB,SAAS;CAG3E,MAAM,kBAAkB;EACtB,GAHuB,aAAa,QAGjC;EACH,GAAG;CACL;CACA,OACE,qBAAC,OAAD;EAAK,WAAW,GAAW,OAAO,kBAAkB;EAAG,eAAa;YAApE,CACG,uBACD,oBAAC,MAAD;GAAI,cAAY,gBAAgB;GAAwB,WAAW,OAAO;aACvE,YAAY,KAAK,cAAc,UAC9B,oBAAC,MAAD,EAAA,UAAiB,aAAiB,GAAzB,KAAyB,CACnC;EACC,CAAA,CACD;;AAET;;;AC5CA,IAAA,sCAAe"}
|
package/lib/FilterDrawer.js
CHANGED
|
@@ -78,7 +78,6 @@ function FilterDrawer({ drawer, onClose, footer, isLoading, onReset, resultCount
|
|
|
78
78
|
home: true,
|
|
79
79
|
title: child.props.title,
|
|
80
80
|
children: child.props.children,
|
|
81
|
-
drawerContentClassname: styles["filter-drawer__view"],
|
|
82
81
|
footer: viewFooter
|
|
83
82
|
});
|
|
84
83
|
}
|
|
@@ -88,7 +87,6 @@ function FilterDrawer({ drawer, onClose, footer, isLoading, onReset, resultCount
|
|
|
88
87
|
id: child.props.id,
|
|
89
88
|
title: child.props.title,
|
|
90
89
|
children: child.props.children,
|
|
91
|
-
drawerContentClassname: styles["filter-drawer__view"],
|
|
92
90
|
footer: viewFooter
|
|
93
91
|
});
|
|
94
92
|
} else return child;
|
package/lib/FilterDrawer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterDrawer.js","names":[],"sources":["../src/components/Filter/FilterDrawer/FilterDrawer.tsx","../src/components/Filter/FilterDrawer/index.ts"],"sourcesContent":["import { Children, isValidElement } from 'react';\n\nimport type { HNDesignsystemFilter } from '../../../resources/Resources';\nimport type { UseFilterDrawerReturn } from '../useFilterDrawer';\n\nimport { LanguageLocales } from '../../../constants';\nimport { useLanguage } from '../../../hooks/useLanguage';\nimport { formatResource } from '../../../utils/resource';\nimport Button from '../../Button';\nimport DrawerNavigation, { type DrawerViewProps } from '../DrawerNavigation/DrawerNavigation';\nimport LoaderSpinner from '../LoaderSpinner/LoaderSpinner';\nimport { getResources } from '../resourceHelper';\n\nimport styles from './styles.module.scss';\n\nexport interface FilterDrawerProps<ViewId extends string = string> {\n /** The drawer state from useFilterDrawer */\n drawer: UseFilterDrawerReturn<ViewId>;\n /** Additional callback when the drawer closes (drawer.close() is always called automatically) */\n onClose?: () => void;\n /** Fully custom footer — overrides the default footer built from onReset/resultText */\n footer?: React.ReactNode;\n /** Shows LoaderSpinner in the footer when turned on */\n isLoading?: boolean;\n /** If provided, shows a \"Nullstill filter\" button in the default footer */\n onReset?: () => void;\n /** If provided, shows a result count in the footer */\n resultCount?: number;\n /** Resources for the component */\n resources?: Partial<HNDesignsystemFilter>;\n /** DrawerNavigation.View children defining the overview and filter views */\n children: React.ReactNode;\n}\n\nexport interface FilterDrawerViewProps extends DrawerViewProps {\n /** Hide reset button for view */\n noResetButton?: boolean;\n /** View specific close handler */\n onClose?: () => void;\n /** View specific reset handler */\n onReset?: () => void;\n}\n\n/**\n * Never rendered directly — FilterDrawer reads its props and creates a DrawerNavigation.View\n * with id=\"overview\" and home=true.\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nfunction FilterDrawerOverview(_props: Omit<DrawerViewProps, 'id' | 'home'>): React.ReactNode {\n return null;\n}\n\n/**\n * Never rendered directly — FilterDrawer reads its props and creates a FilterDrawerView\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nfunction FilterDrawerView(_props: FilterDrawerViewProps): React.ReactNode {\n // DrawerView is never rendered directly — DrawerNavigation reads its props\n return null;\n}\n\nfunction FilterDrawer<ViewId extends string>({\n drawer,\n onClose,\n footer,\n isLoading,\n onReset,\n resultCount,\n resources,\n children,\n}: FilterDrawerProps<ViewId>): React.ReactNode {\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n const mergedResources = {\n ...defaultResources,\n ...resources,\n };\n\n const handleClose = (): void => {\n if (onClose) {\n onClose();\n } else {\n drawer.close();\n }\n };\n\n const defaultResetButton = onReset && (\n <Button onClick={onReset} variant=\"borderless\">\n {mergedResources.resetButtonText}\n </Button>\n );\n const defaultShowResultsButton = <Button onClick={handleClose}>{mergedResources.showButtonText}</Button>;\n\n const resultText = resultCount !== undefined ? <span>{formatResource(mergedResources.resultsText, resultCount)}</span> : undefined;\n const resultContent = isLoading ? <LoaderSpinner resources={mergedResources} /> : resultText;\n\n const defaultFooterRight = (resultContent || defaultShowResultsButton) && (\n <div className={styles['filter-drawer__footer__right']}>\n {resultContent}\n {defaultShowResultsButton}\n </div>\n );\n\n const defaultFooter =\n onReset || resultContent ? (\n <div className={styles['filter-drawer__footer']}>\n {defaultResetButton}\n {defaultFooterRight}\n </div>\n ) : undefined;\n\n const fallbackFooter = footer ?? defaultFooter;\n\n const generateViewFooter = (viewOnReset?: () => void, viewOnClose?: () => void, noResetButton?: boolean): React.ReactNode => {\n if (!viewOnReset && !viewOnClose && !noResetButton) {\n return undefined;\n }\n\n const viewShowButton = viewOnClose ? <Button onClick={viewOnClose}>{mergedResources.showButtonText}</Button> : defaultShowResultsButton;\n\n return (\n <div className={styles['filter-drawer__footer']}>\n {!noResetButton &&\n (viewOnReset ? (\n <Button onClick={viewOnReset} variant=\"borderless\">\n {mergedResources.resetButtonText}\n </Button>\n ) : (\n defaultResetButton\n ))}\n {(resultContent || viewShowButton) && (\n <div className={styles['filter-drawer__footer__right']}>\n {resultContent}\n {viewShowButton}\n </div>\n )}\n </div>\n );\n };\n\n const processedChildren = Children.map(children, child => {\n if (isValidElement<Omit<FilterDrawerViewProps, 'id' | 'home'>>(child) && child.type === FilterDrawerOverview) {\n const viewDefaultFooter = generateViewFooter(child.props.onReset, child.props.onClose, child.props.noResetButton);\n const viewFooter = viewDefaultFooter ?? child.props.footer ?? fallbackFooter;\n return
|
|
1
|
+
{"version":3,"file":"FilterDrawer.js","names":[],"sources":["../src/components/Filter/FilterDrawer/FilterDrawer.tsx","../src/components/Filter/FilterDrawer/index.ts"],"sourcesContent":["import { Children, isValidElement } from 'react';\n\nimport type { HNDesignsystemFilter } from '../../../resources/Resources';\nimport type { UseFilterDrawerReturn } from '../useFilterDrawer';\n\nimport { LanguageLocales } from '../../../constants';\nimport { useLanguage } from '../../../hooks/useLanguage';\nimport { formatResource } from '../../../utils/resource';\nimport Button from '../../Button';\nimport DrawerNavigation, { type DrawerViewProps } from '../DrawerNavigation/DrawerNavigation';\nimport LoaderSpinner from '../LoaderSpinner/LoaderSpinner';\nimport { getResources } from '../resourceHelper';\n\nimport styles from './styles.module.scss';\n\nexport interface FilterDrawerProps<ViewId extends string = string> {\n /** The drawer state from useFilterDrawer */\n drawer: UseFilterDrawerReturn<ViewId>;\n /** Additional callback when the drawer closes (drawer.close() is always called automatically) */\n onClose?: () => void;\n /** Fully custom footer — overrides the default footer built from onReset/resultText */\n footer?: React.ReactNode;\n /** Shows LoaderSpinner in the footer when turned on */\n isLoading?: boolean;\n /** If provided, shows a \"Nullstill filter\" button in the default footer */\n onReset?: () => void;\n /** If provided, shows a result count in the footer */\n resultCount?: number;\n /** Resources for the component */\n resources?: Partial<HNDesignsystemFilter>;\n /** DrawerNavigation.View children defining the overview and filter views */\n children: React.ReactNode;\n}\n\nexport interface FilterDrawerViewProps extends DrawerViewProps {\n /** Hide reset button for view */\n noResetButton?: boolean;\n /** View specific close handler */\n onClose?: () => void;\n /** View specific reset handler */\n onReset?: () => void;\n}\n\n/**\n * Never rendered directly — FilterDrawer reads its props and creates a DrawerNavigation.View\n * with id=\"overview\" and home=true.\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nfunction FilterDrawerOverview(_props: Omit<DrawerViewProps, 'id' | 'home'>): React.ReactNode {\n return null;\n}\n\n/**\n * Never rendered directly — FilterDrawer reads its props and creates a FilterDrawerView\n */\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nfunction FilterDrawerView(_props: FilterDrawerViewProps): React.ReactNode {\n // DrawerView is never rendered directly — DrawerNavigation reads its props\n return null;\n}\n\nfunction FilterDrawer<ViewId extends string>({\n drawer,\n onClose,\n footer,\n isLoading,\n onReset,\n resultCount,\n resources,\n children,\n}: FilterDrawerProps<ViewId>): React.ReactNode {\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n const mergedResources = {\n ...defaultResources,\n ...resources,\n };\n\n const handleClose = (): void => {\n if (onClose) {\n onClose();\n } else {\n drawer.close();\n }\n };\n\n const defaultResetButton = onReset && (\n <Button onClick={onReset} variant=\"borderless\">\n {mergedResources.resetButtonText}\n </Button>\n );\n const defaultShowResultsButton = <Button onClick={handleClose}>{mergedResources.showButtonText}</Button>;\n\n const resultText = resultCount !== undefined ? <span>{formatResource(mergedResources.resultsText, resultCount)}</span> : undefined;\n const resultContent = isLoading ? <LoaderSpinner resources={mergedResources} /> : resultText;\n\n const defaultFooterRight = (resultContent || defaultShowResultsButton) && (\n <div className={styles['filter-drawer__footer__right']}>\n {resultContent}\n {defaultShowResultsButton}\n </div>\n );\n\n const defaultFooter =\n onReset || resultContent ? (\n <div className={styles['filter-drawer__footer']}>\n {defaultResetButton}\n {defaultFooterRight}\n </div>\n ) : undefined;\n\n const fallbackFooter = footer ?? defaultFooter;\n\n const generateViewFooter = (viewOnReset?: () => void, viewOnClose?: () => void, noResetButton?: boolean): React.ReactNode => {\n if (!viewOnReset && !viewOnClose && !noResetButton) {\n return undefined;\n }\n\n const viewShowButton = viewOnClose ? <Button onClick={viewOnClose}>{mergedResources.showButtonText}</Button> : defaultShowResultsButton;\n\n return (\n <div className={styles['filter-drawer__footer']}>\n {!noResetButton &&\n (viewOnReset ? (\n <Button onClick={viewOnReset} variant=\"borderless\">\n {mergedResources.resetButtonText}\n </Button>\n ) : (\n defaultResetButton\n ))}\n {(resultContent || viewShowButton) && (\n <div className={styles['filter-drawer__footer__right']}>\n {resultContent}\n {viewShowButton}\n </div>\n )}\n </div>\n );\n };\n\n const processedChildren = Children.map(children, child => {\n if (isValidElement<Omit<FilterDrawerViewProps, 'id' | 'home'>>(child) && child.type === FilterDrawerOverview) {\n const viewDefaultFooter = generateViewFooter(child.props.onReset, child.props.onClose, child.props.noResetButton);\n const viewFooter = viewDefaultFooter ?? child.props.footer ?? fallbackFooter;\n return <DrawerNavigation.View id=\"overview\" home title={child.props.title} children={child.props.children} footer={viewFooter} />;\n }\n if (isValidElement<FilterDrawerViewProps>(child)) {\n const viewDefaultFooter = generateViewFooter(child.props.onReset, child.props.onClose, child.props.noResetButton);\n const viewFooter = viewDefaultFooter ?? child.props.footer ?? fallbackFooter;\n return <DrawerNavigation.View id={child.props.id} title={child.props.title} children={child.props.children} footer={viewFooter} />;\n } else {\n return child;\n }\n });\n\n return (\n <DrawerNavigation isOpen={drawer.isOpen} initialView={drawer.initialView} onCloseButton={handleClose} footer={footer ?? defaultFooter}>\n {processedChildren}\n </DrawerNavigation>\n );\n}\n\nFilterDrawer.Overview = FilterDrawerOverview;\nFilterDrawer.View = FilterDrawerView;\n\nexport default FilterDrawer;\n","import FilterDrawer from './FilterDrawer';\nexport * from './FilterDrawer';\nexport default FilterDrawer;\n"],"mappings":";;;;;;;;;;;;;;;AAgDA,SAAS,qBAAqB,QAA+D;CAC3F,OAAO;AACT;;;;AAMA,SAAS,iBAAiB,QAAgD;CAExE,OAAO;AACT;AAEA,SAAS,aAAoC,EAC3C,QACA,SACA,QACA,WACA,SACA,aACA,WACA,YAC6C;CAC7C,MAAM,EAAE,aAAa,YAA6B,gBAAgB,SAAS;CA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oB,mBAAmB,MAAM,MAAM,SAAS,MAAM,MAAM,SAAS,MAAM,MAAM,aAChF,KAAqB,MAAM,MAAM,UAAU;GAC9D,OAAO,oBAAC,iBAAiB,MAAlB;IAAuB,IAAG;IAAW,MAAA;IAAK,OAAO,MAAM,MAAM;IAAO,UAAU,MAAM,MAAM;IAAU,QAAQ;GAAa,CAAA;EAClI;EACA,IAAI,eAAsC,KAAK,GAAG;GAEhD,MAAM,aADoB,mBAAmB,MAAM,MAAM,SAAS,MAAM,MAAM,SAAS,MAAM,MAAM,aAChF,KAAqB,MAAM,MAAM,UAAU;GAC9D,OAAO,oBAAC,iBAAiB,MAAlB;IAAuB,IAAI,MAAM,MAAM;IAAI,OAAO,MAAM,MAAM;IAAO,UAAU,MAAM,MAAM;IAAU,QAAQ;GAAa,CAAA;EACnI,OACE,OAAO;CAEX,CAAC;CAED,OACE,oBAAC,kBAAD;EAAkB,QAAQ,OAAO;EAAQ,aAAa,OAAO;EAAa,eAAe;EAAa,QAAQ,UAAU;YACrH;CACe,CAAA;AAEtB;AAEA,aAAa,WAAW;AACxB,aAAa,OAAO;;;ACjKpB,IAAA,uBAAe"}
|
package/lib/FilterLinkList.js
CHANGED
|
@@ -2,7 +2,7 @@ import { AnalyticsId, IconSize } from "./constants.js";
|
|
|
2
2
|
import { usePseudoClasses } from "./hooks/usePseudoClasses.js";
|
|
3
3
|
import { t as Icon_default } from "./Icon.js";
|
|
4
4
|
import ChevronRight from "./components/Icons/ChevronRight.js";
|
|
5
|
-
import
|
|
5
|
+
import cn from "classnames";
|
|
6
6
|
import React from "react";
|
|
7
7
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import styles from "./components/Filter/FilterLinkList/FilterLinkList.module.scss";
|
|
@@ -10,8 +10,8 @@ import styles from "./components/Filter/FilterLinkList/FilterLinkList.module.scs
|
|
|
10
10
|
var Link = (props) => {
|
|
11
11
|
const { children, title, chips, className = "", linkRef, testId, ref, ...restProps } = props;
|
|
12
12
|
const { refObject, isHovered } = usePseudoClasses(linkRef);
|
|
13
|
-
const liClasses =
|
|
14
|
-
const linkClasses =
|
|
13
|
+
const liClasses = cn(styles["link-list__item"]);
|
|
14
|
+
const linkClasses = cn(styles["link-list__button"], className);
|
|
15
15
|
return /* @__PURE__ */ jsx("li", {
|
|
16
16
|
className: liClasses,
|
|
17
17
|
ref,
|
|
@@ -45,7 +45,7 @@ var LinkListComponent = (props) => {
|
|
|
45
45
|
const { children, className = "", testId, ref } = props;
|
|
46
46
|
return /* @__PURE__ */ jsx("ul", {
|
|
47
47
|
ref,
|
|
48
|
-
className:
|
|
48
|
+
className: cn(styles["link-list"], className),
|
|
49
49
|
"data-testid": testId,
|
|
50
50
|
"data-analyticsid": AnalyticsId.LinkList,
|
|
51
51
|
children: React.Children.map(children, (child) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterLinkList.js","names":[],"sources":["../src/components/Filter/FilterLinkList/FilterLinkList.tsx"],"sourcesContent":["import React from 'react';\n\nimport cn from 'classnames';\n\nimport { AnalyticsId, IconSize } from '../../../constants';\nimport { usePseudoClasses } from '../../../hooks/usePseudoClasses';\nimport Icon from '../../Icon';\nimport ChevronRight from '../../Icons/ChevronRight';\n\nimport styles from './FilterLinkList.module.scss';\n\nexport type LinkType = React.FC<LinkProps>;\n\nexport interface CompoundComponent extends React.FC<LinkListProps> {\n Link: LinkType;\n}\n\nexport interface LinkListProps {\n /** Items in the LinkList */\n children: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Ref passed to the ul element */\n ref?: React.Ref<HTMLUListElement | null>;\n}\n\ntype Modify<T, R> = Omit<T, keyof R> & R;\n\nexport type LinkProps = Modify<\n React.HTMLAttributes<HTMLAnchorElement | HTMLButtonElement>,\n {\n /** If needed children will be content instead of title and chips. Use only in edge cases */\n children?: React.ReactNode;\n /** Title text on link element */\n title?: string;\n /** Texts rendered inside non-interactive chips on link element */\n chips?: string[];\n /** Aria label for the list of chips */\n chipsGroupAriaLabel?: string;\n /** Custom classname for link element */\n className?: string;\n /** Ref for button */\n linkRef?: React.RefObject<HTMLButtonElement | null>;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Ref passed to the list item element */\n ref?: React.Ref<HTMLLIElement | null>;\n }\n>;\n\nexport const Link: LinkType = (props: LinkProps) => {\n const { children, title, chips, className = '', linkRef, testId, ref, ...restProps } = props;\n const { refObject, isHovered } = usePseudoClasses<HTMLButtonElement | null>(linkRef);\n\n const liClasses = cn(styles['link-list__item']);\n const linkClasses = cn(styles['link-list__button'], className);\n\n return (\n <li className={liClasses} ref={ref} data-testid={testId} data-analyticsid={AnalyticsId.Link}>\n <button className={linkClasses} ref={refObject as React.RefObject<HTMLButtonElement>} type=\"button\" {...restProps}>\n <div className={styles['link-list__button__content']}>\n {title ? (\n <>\n <span>{title}</span>\n {chips && chips.length > 0 && (\n <ul className={styles['link-list__chip-list']} aria-label={props.chipsGroupAriaLabel}>\n {chips.map(chip => (\n <li className={styles['link-list__chip']} key={chip}>\n {chip}\n </li>\n ))}\n </ul>\n )}\n </>\n ) : (\n <>{children}</>\n )}\n </div>\n <Icon svgIcon={ChevronRight} isHovered={isHovered} size={IconSize.XSmall} color={'var(--color-action-graphics-onlight)'} />\n </button>\n </li>\n );\n};\n\nconst LinkListComponent: React.FC<LinkListProps> = (props: LinkListProps) => {\n const { children, className = '', testId, ref } = props;\n\n const listClassNames = cn(styles['link-list'], className);\n\n return (\n <ul ref={ref} className={listClassNames} data-testid={testId} data-analyticsid={AnalyticsId.LinkList}>\n {React.Children.map(children, (child: React.ReactNode) => {\n if (React.isValidElement<LinkProps>(child) && child.type === Link) {\n return React.cloneElement(child);\n }\n })}\n </ul>\n );\n};\n\nexport const FilterLinkList = LinkListComponent as CompoundComponent;\n\nFilterLinkList.displayName = 'FilterLinkList';\nFilterLinkList.Link = Link;\nLink.displayName = 'FilterLinkList.Link';\n\nexport default FilterLinkList;\n"],"mappings":";;;;;;;;;AAoDA,IAAa,QAAkB,UAAqB;CAClD,MAAM,EAAE,UAAU,OAAO,OAAO,YAAY,IAAI,SAAS,QAAQ,KAAK,GAAG,cAAc;CACvF,MAAM,EAAE,WAAW,cAAc,iBAA2C,OAAO;CAEnF,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"FilterLinkList.js","names":[],"sources":["../src/components/Filter/FilterLinkList/FilterLinkList.tsx"],"sourcesContent":["import React from 'react';\n\nimport cn from 'classnames';\n\nimport { AnalyticsId, IconSize } from '../../../constants';\nimport { usePseudoClasses } from '../../../hooks/usePseudoClasses';\nimport Icon from '../../Icon';\nimport ChevronRight from '../../Icons/ChevronRight';\n\nimport styles from './FilterLinkList.module.scss';\n\nexport type LinkType = React.FC<LinkProps>;\n\nexport interface CompoundComponent extends React.FC<LinkListProps> {\n Link: LinkType;\n}\n\nexport interface LinkListProps {\n /** Items in the LinkList */\n children: React.ReactNode;\n /** Adds custom classes to the element. */\n className?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Ref passed to the ul element */\n ref?: React.Ref<HTMLUListElement | null>;\n}\n\ntype Modify<T, R> = Omit<T, keyof R> & R;\n\nexport type LinkProps = Modify<\n React.HTMLAttributes<HTMLAnchorElement | HTMLButtonElement>,\n {\n /** If needed children will be content instead of title and chips. Use only in edge cases */\n children?: React.ReactNode;\n /** Title text on link element */\n title?: string;\n /** Texts rendered inside non-interactive chips on link element */\n chips?: string[];\n /** Aria label for the list of chips */\n chipsGroupAriaLabel?: string;\n /** Custom classname for link element */\n className?: string;\n /** Ref for button */\n linkRef?: React.RefObject<HTMLButtonElement | null>;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Ref passed to the list item element */\n ref?: React.Ref<HTMLLIElement | null>;\n }\n>;\n\nexport const Link: LinkType = (props: LinkProps) => {\n const { children, title, chips, className = '', linkRef, testId, ref, ...restProps } = props;\n const { refObject, isHovered } = usePseudoClasses<HTMLButtonElement | null>(linkRef);\n\n const liClasses = cn(styles['link-list__item']);\n const linkClasses = cn(styles['link-list__button'], className);\n\n return (\n <li className={liClasses} ref={ref} data-testid={testId} data-analyticsid={AnalyticsId.Link}>\n <button className={linkClasses} ref={refObject as React.RefObject<HTMLButtonElement>} type=\"button\" {...restProps}>\n <div className={styles['link-list__button__content']}>\n {title ? (\n <>\n <span>{title}</span>\n {chips && chips.length > 0 && (\n <ul className={styles['link-list__chip-list']} aria-label={props.chipsGroupAriaLabel}>\n {chips.map(chip => (\n <li className={styles['link-list__chip']} key={chip}>\n {chip}\n </li>\n ))}\n </ul>\n )}\n </>\n ) : (\n <>{children}</>\n )}\n </div>\n <Icon svgIcon={ChevronRight} isHovered={isHovered} size={IconSize.XSmall} color={'var(--color-action-graphics-onlight)'} />\n </button>\n </li>\n );\n};\n\nconst LinkListComponent: React.FC<LinkListProps> = (props: LinkListProps) => {\n const { children, className = '', testId, ref } = props;\n\n const listClassNames = cn(styles['link-list'], className);\n\n return (\n <ul ref={ref} className={listClassNames} data-testid={testId} data-analyticsid={AnalyticsId.LinkList}>\n {React.Children.map(children, (child: React.ReactNode) => {\n if (React.isValidElement<LinkProps>(child) && child.type === Link) {\n return React.cloneElement(child);\n }\n })}\n </ul>\n );\n};\n\nexport const FilterLinkList = LinkListComponent as CompoundComponent;\n\nFilterLinkList.displayName = 'FilterLinkList';\nFilterLinkList.Link = Link;\nLink.displayName = 'FilterLinkList.Link';\n\nexport default FilterLinkList;\n"],"mappings":";;;;;;;;;AAoDA,IAAa,QAAkB,UAAqB;CAClD,MAAM,EAAE,UAAU,OAAO,OAAO,YAAY,IAAI,SAAS,QAAQ,KAAK,GAAG,cAAc;CACvF,MAAM,EAAE,WAAW,cAAc,iBAA2C,OAAO;CAEnF,MAAM,YAAY,GAAG,OAAO,kBAAkB;CAC9C,MAAM,cAAc,GAAG,OAAO,sBAAsB,SAAS;CAE7D,OACE,oBAAC,MAAD;EAAI,WAAW;EAAgB;EAAK,eAAa;EAAQ,oBAAkB,YAAY;YACrF,qBAAC,UAAD;GAAQ,WAAW;GAAa,KAAK;GAAiD,MAAK;GAAS,GAAI;aAAxG,CACE,oBAAC,OAAD;IAAK,WAAW,OAAO;cACpB,QACC,qBAAA,UAAA,EAAA,UAAA,CACE,oBAAC,QAAD,EAAA,UAAO,MAAY,CAAA,GAClB,SAAS,MAAM,SAAS,KACvB,oBAAC,MAAD;KAAI,WAAW,OAAO;KAAyB,cAAY,MAAM;eAC9D,MAAM,KAAI,SACT,oBAAC,MAAD;MAAI,WAAW,OAAO;gBACnB;KACC,GAF2C,IAE3C,CACL;IACC,CAAA,CAEN,EAAA,CAAA,IAEF,oBAAA,UAAA,EAAG,SAAW,CAAA;GAEb,CAAA,GACL,oBAAC,cAAD;IAAM,SAAS;IAAyB;IAAW,MAAM,SAAS;IAAQ,OAAO;GAAyC,CAAA,CACpH;;CACN,CAAA;AAER;AAEA,IAAM,qBAA8C,UAAyB;CAC3E,MAAM,EAAE,UAAU,YAAY,IAAI,QAAQ,QAAQ;CAIlD,OACE,oBAAC,MAAD;EAAS;EAAK,WAHO,GAAG,OAAO,cAAc,SAGpB;EAAgB,eAAa;EAAQ,oBAAkB,YAAY;YACzF,MAAM,SAAS,IAAI,WAAW,UAA2B;GACxD,IAAI,MAAM,eAA0B,KAAK,KAAK,MAAM,SAAS,MAC3D,OAAO,MAAM,aAAa,KAAK;EAEnC,CAAC;CACC,CAAA;AAER;AAEA,IAAa,iBAAiB;AAE9B,eAAe,cAAc;AAC7B,eAAe,OAAO;AACtB,KAAK,cAAc"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { t as FilterSearch } from "./FilterSearch.js";
|
|
2
|
-
import
|
|
2
|
+
import cn from "classnames";
|
|
3
3
|
import { jsx } from "react/jsx-runtime";
|
|
4
4
|
import styles from "./components/Filter/FilterOverviewSearch/styles.module.scss";
|
|
5
5
|
//#region src/components/Filter/FilterOverviewSearch/FilterOverviewSearch.tsx
|
|
6
6
|
var FilterOverviewSearch = (props) => {
|
|
7
7
|
const { wrapperClassName, testId, ...filterSearchProps } = props;
|
|
8
8
|
return /* @__PURE__ */ jsx("div", {
|
|
9
|
-
className:
|
|
9
|
+
className: cn(styles["filter-overview-search"], wrapperClassName),
|
|
10
10
|
"data-testid": testId,
|
|
11
11
|
children: /* @__PURE__ */ jsx(FilterSearch, { ...filterSearchProps })
|
|
12
12
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterOverviewSearch.js","names":[],"sources":["../src/components/Filter/FilterOverviewSearch/FilterOverviewSearch.tsx","../src/components/Filter/FilterOverviewSearch/index.ts"],"sourcesContent":["import cn from 'classnames';\n\nimport type { FilterSearchProps } from '../FilterSearch/FilterSearch';\n\nimport FilterSearch from '../FilterSearch/FilterSearch';\n\nimport styles from './styles.module.scss';\n\nexport interface FilterOverviewSearchProps extends FilterSearchProps {\n /** Adds custom classes to the wrapper element. */\n wrapperClassName?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nconst FilterOverviewSearch: React.FC<FilterOverviewSearchProps> = props => {\n const { wrapperClassName, testId, ...filterSearchProps } = props;\n\n return (\n <div className={cn(styles['filter-overview-search'], wrapperClassName)} data-testid={testId}>\n <FilterSearch {...filterSearchProps} />\n </div>\n );\n};\n\nexport default FilterOverviewSearch;\n","import FilterOverviewSearch from './FilterOverviewSearch';\nexport * from './FilterOverviewSearch';\nexport default FilterOverviewSearch;\n"],"mappings":";;;;;AAeA,IAAM,wBAA4D,UAAS;CACzE,MAAM,EAAE,kBAAkB,QAAQ,GAAG,sBAAsB;CAE3D,OACE,oBAAC,OAAD;EAAK,WAAW,
|
|
1
|
+
{"version":3,"file":"FilterOverviewSearch.js","names":[],"sources":["../src/components/Filter/FilterOverviewSearch/FilterOverviewSearch.tsx","../src/components/Filter/FilterOverviewSearch/index.ts"],"sourcesContent":["import cn from 'classnames';\n\nimport type { FilterSearchProps } from '../FilterSearch/FilterSearch';\n\nimport FilterSearch from '../FilterSearch/FilterSearch';\n\nimport styles from './styles.module.scss';\n\nexport interface FilterOverviewSearchProps extends FilterSearchProps {\n /** Adds custom classes to the wrapper element. */\n wrapperClassName?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nconst FilterOverviewSearch: React.FC<FilterOverviewSearchProps> = props => {\n const { wrapperClassName, testId, ...filterSearchProps } = props;\n\n return (\n <div className={cn(styles['filter-overview-search'], wrapperClassName)} data-testid={testId}>\n <FilterSearch {...filterSearchProps} />\n </div>\n );\n};\n\nexport default FilterOverviewSearch;\n","import FilterOverviewSearch from './FilterOverviewSearch';\nexport * from './FilterOverviewSearch';\nexport default FilterOverviewSearch;\n"],"mappings":";;;;;AAeA,IAAM,wBAA4D,UAAS;CACzE,MAAM,EAAE,kBAAkB,QAAQ,GAAG,sBAAsB;CAE3D,OACE,oBAAC,OAAD;EAAK,WAAW,GAAG,OAAO,2BAA2B,gBAAgB;EAAG,eAAa;YACnF,oBAAC,cAAD,EAAc,GAAI,kBAAoB,CAAA;CACnC,CAAA;AAET;;;ACrBA,IAAA,+BAAe"}
|
package/lib/FilterSearch.js
CHANGED
|
@@ -7,7 +7,7 @@ import { useIsMobileBreakpoint } from "./hooks/useIsMobileBreakpoint.js";
|
|
|
7
7
|
import X from "./components/Icons/X.js";
|
|
8
8
|
import { t as getResources } from "./resourceHelper.js";
|
|
9
9
|
import Search from "./components/Icons/Search.js";
|
|
10
|
-
import
|
|
10
|
+
import cn from "classnames";
|
|
11
11
|
import { useRef } from "react";
|
|
12
12
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
13
|
import styles from "./components/Filter/FilterSearch/styles.module.scss";
|
|
@@ -29,7 +29,7 @@ var FilterSearch = (props) => {
|
|
|
29
29
|
};
|
|
30
30
|
const inputHasValue = !!value;
|
|
31
31
|
return /* @__PURE__ */ jsxs("div", {
|
|
32
|
-
className:
|
|
32
|
+
className: cn(styles["filter-search__wrapper"], className),
|
|
33
33
|
children: [
|
|
34
34
|
/* @__PURE__ */ jsxs("label", {
|
|
35
35
|
className: styles["filter-search__input-wrapper"],
|
|
@@ -42,7 +42,7 @@ var FilterSearch = (props) => {
|
|
|
42
42
|
ref: mergeRefs([inputRef, ref]),
|
|
43
43
|
value,
|
|
44
44
|
onChange,
|
|
45
|
-
className:
|
|
45
|
+
className: cn(styles["filter-search__input"], { [styles["filter-search__input--hovered"]]: isWrapperHovered }),
|
|
46
46
|
placeholder: mergedResources.searchPlaceholder
|
|
47
47
|
})]
|
|
48
48
|
}),
|
|
@@ -56,7 +56,7 @@ var FilterSearch = (props) => {
|
|
|
56
56
|
inputRef.current?.focus();
|
|
57
57
|
},
|
|
58
58
|
ref: clearButtonRef,
|
|
59
|
-
className:
|
|
59
|
+
className: cn(styles["filter-search__clear-button"], clearButtonProps?.className),
|
|
60
60
|
children: /* @__PURE__ */ jsx(Icon_default, {
|
|
61
61
|
svgIcon: X,
|
|
62
62
|
size: IconSize.XXSmall,
|
|
@@ -69,9 +69,9 @@ var FilterSearch = (props) => {
|
|
|
69
69
|
disabled: inputProps.disabled,
|
|
70
70
|
...buttonProps,
|
|
71
71
|
ref: buttonRef,
|
|
72
|
-
className:
|
|
72
|
+
className: cn(styles["filter-search__search-button"], buttonProps?.className),
|
|
73
73
|
children: /* @__PURE__ */ jsx("div", {
|
|
74
|
-
className:
|
|
74
|
+
className: cn(styles["filter-search__search-button--inner"]),
|
|
75
75
|
children: /* @__PURE__ */ jsx(Icon_default, {
|
|
76
76
|
svgIcon: Search,
|
|
77
77
|
size: isMobile ? IconSize.XXSmall : IconSize.XSmall,
|
package/lib/FilterSearch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterSearch.js","names":[],"sources":["../src/components/Filter/FilterSearch/FilterSearch.tsx"],"sourcesContent":["import { useRef } from 'react';\n\nimport classNames from 'classnames';\n\nimport type { HNDesignsystemFilter } from '../../../resources/Resources';\n\nimport { IconSize, LanguageLocales } from '../../../constants';\nimport { useIsMobileBreakpoint } from '../../../hooks/useIsMobileBreakpoint';\nimport { useLanguage } from '../../../hooks/useLanguage';\nimport { usePseudoClasses } from '../../../hooks/usePseudoClasses';\nimport { mergeRefs } from '../../../utils/refs';\nimport Icon from '../../Icon';\nimport Search from '../../Icons/Search';\nimport X from '../../Icons/X';\nimport { getResources } from '../resourceHelper';\n\nimport styles from './styles.module.scss';\n\nexport interface FilterSearchProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'className' | 'value' | 'onChange'> {\n /** Adds custom classes to the component */\n className?: string;\n /** The value given by the user in the input field */\n value: string | undefined;\n /** onChange handler for the input field */\n onChange?: React.ChangeEventHandler<HTMLInputElement>;\n /** Props for the search button */\n buttonProps?: React.ButtonHTMLAttributes<HTMLButtonElement>;\n /** Props for the clear button */\n clearButtonProps?: React.ButtonHTMLAttributes<HTMLButtonElement>;\n /** Texts if overriding SOT */\n resources?: Partial<HNDesignsystemFilter>;\n /** Ref passed to the input element */\n ref?: React.Ref<HTMLInputElement | null>;\n}\n\nconst FilterSearch: React.FC<FilterSearchProps> = props => {\n const { className, value, onChange, resources, buttonProps, clearButtonProps, ref, ...inputProps } = props;\n\n const inputRef = useRef<HTMLInputElement>(null);\n const inputWrapperRef = useRef<HTMLLabelElement>(null);\n const { isHovered: isWrapperHovered } = usePseudoClasses(inputWrapperRef);\n const buttonRef = useRef<HTMLButtonElement>(null);\n const { isHovered: isButtonHovered } = usePseudoClasses(buttonRef);\n const clearButtonRef = useRef<HTMLButtonElement>(null);\n const { isHovered: isClearButtonHovered } = usePseudoClasses(clearButtonRef);\n\n const isMobile = useIsMobileBreakpoint();\n\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n\n const mergedResources = {\n ...defaultResources,\n ...resources,\n };\n\n const inputHasValue = !!value;\n\n return (\n <div className={classNames(styles['filter-search__wrapper'], className)}>\n <label className={styles['filter-search__input-wrapper']} ref={inputWrapperRef}>\n <span className={styles['filter-search__input__label']}>{inputProps['aria-label'] ?? mergedResources.searchPlaceholder}</span>\n <input\n {...inputProps}\n ref={mergeRefs([inputRef, ref])}\n value={value}\n onChange={onChange}\n className={classNames(styles['filter-search__input'], {\n [styles['filter-search__input--hovered']]: isWrapperHovered,\n })}\n placeholder={mergedResources.searchPlaceholder}\n />\n </label>\n {inputHasValue && (\n <button\n type=\"button\"\n aria-label={mergedResources.searchClearButtonAriaLabel}\n disabled={inputProps.disabled}\n {...clearButtonProps}\n onClick={e => {\n clearButtonProps?.onClick?.(e);\n inputRef.current?.focus();\n }}\n ref={clearButtonRef}\n className={classNames(styles['filter-search__clear-button'], clearButtonProps?.className)}\n >\n <Icon svgIcon={X} size={IconSize.XXSmall} isHovered={!isMobile && isClearButtonHovered} />\n </button>\n )}\n <button\n type={'button'}\n aria-label={mergedResources.searchButtonAriaLabel}\n disabled={inputProps.disabled}\n {...buttonProps}\n ref={buttonRef}\n className={classNames(styles['filter-search__search-button'], buttonProps?.className)}\n >\n <div className={classNames(styles['filter-search__search-button--inner'])}>\n <Icon svgIcon={Search} size={isMobile ? IconSize.XXSmall : IconSize.XSmall} isHovered={!inputProps.disabled && isButtonHovered} />\n </div>\n </button>\n </div>\n );\n};\n\nexport default FilterSearch;\n"],"mappings":";;;;;;;;;;;;;;AAmCA,IAAM,gBAA4C,UAAS;CACzD,MAAM,EAAE,WAAW,OAAO,UAAU,WAAW,aAAa,kBAAkB,KAAK,GAAG,eAAe;CAErG,MAAM,WAAW,OAAyB,IAAI;CAC9C,MAAM,kBAAkB,OAAyB,IAAI;CACrD,MAAM,EAAE,WAAW,qBAAqB,iBAAiB,eAAe;CACxE,MAAM,YAAY,OAA0B,IAAI;CAChD,MAAM,EAAE,WAAW,oBAAoB,iBAAiB,SAAS;CACjE,MAAM,iBAAiB,OAA0B,IAAI;CACrD,MAAM,EAAE,WAAW,yBAAyB,iBAAiB,cAAc;CAE3E,MAAM,WAAW,sBAAsB;CAEvC,MAAM,EAAE,aAAa,YAA6B,gBAAgB,SAAS;CAG3E,MAAM,kBAAkB;EACtB,GAHuB,aAAa,QAGjC;EACH,GAAG;CACL;CAEA,MAAM,gBAAgB,CAAC,CAAC;CAExB,OACE,qBAAC,OAAD;EAAK,WAAW,
|
|
1
|
+
{"version":3,"file":"FilterSearch.js","names":[],"sources":["../src/components/Filter/FilterSearch/FilterSearch.tsx"],"sourcesContent":["import { useRef } from 'react';\n\nimport classNames from 'classnames';\n\nimport type { HNDesignsystemFilter } from '../../../resources/Resources';\n\nimport { IconSize, LanguageLocales } from '../../../constants';\nimport { useIsMobileBreakpoint } from '../../../hooks/useIsMobileBreakpoint';\nimport { useLanguage } from '../../../hooks/useLanguage';\nimport { usePseudoClasses } from '../../../hooks/usePseudoClasses';\nimport { mergeRefs } from '../../../utils/refs';\nimport Icon from '../../Icon';\nimport Search from '../../Icons/Search';\nimport X from '../../Icons/X';\nimport { getResources } from '../resourceHelper';\n\nimport styles from './styles.module.scss';\n\nexport interface FilterSearchProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'className' | 'value' | 'onChange'> {\n /** Adds custom classes to the component */\n className?: string;\n /** The value given by the user in the input field */\n value: string | undefined;\n /** onChange handler for the input field */\n onChange?: React.ChangeEventHandler<HTMLInputElement>;\n /** Props for the search button */\n buttonProps?: React.ButtonHTMLAttributes<HTMLButtonElement>;\n /** Props for the clear button */\n clearButtonProps?: React.ButtonHTMLAttributes<HTMLButtonElement>;\n /** Texts if overriding SOT */\n resources?: Partial<HNDesignsystemFilter>;\n /** Ref passed to the input element */\n ref?: React.Ref<HTMLInputElement | null>;\n}\n\nconst FilterSearch: React.FC<FilterSearchProps> = props => {\n const { className, value, onChange, resources, buttonProps, clearButtonProps, ref, ...inputProps } = props;\n\n const inputRef = useRef<HTMLInputElement>(null);\n const inputWrapperRef = useRef<HTMLLabelElement>(null);\n const { isHovered: isWrapperHovered } = usePseudoClasses(inputWrapperRef);\n const buttonRef = useRef<HTMLButtonElement>(null);\n const { isHovered: isButtonHovered } = usePseudoClasses(buttonRef);\n const clearButtonRef = useRef<HTMLButtonElement>(null);\n const { isHovered: isClearButtonHovered } = usePseudoClasses(clearButtonRef);\n\n const isMobile = useIsMobileBreakpoint();\n\n const { language } = useLanguage<LanguageLocales>(LanguageLocales.NORWEGIAN);\n const defaultResources = getResources(language);\n\n const mergedResources = {\n ...defaultResources,\n ...resources,\n };\n\n const inputHasValue = !!value;\n\n return (\n <div className={classNames(styles['filter-search__wrapper'], className)}>\n <label className={styles['filter-search__input-wrapper']} ref={inputWrapperRef}>\n <span className={styles['filter-search__input__label']}>{inputProps['aria-label'] ?? mergedResources.searchPlaceholder}</span>\n <input\n {...inputProps}\n ref={mergeRefs([inputRef, ref])}\n value={value}\n onChange={onChange}\n className={classNames(styles['filter-search__input'], {\n [styles['filter-search__input--hovered']]: isWrapperHovered,\n })}\n placeholder={mergedResources.searchPlaceholder}\n />\n </label>\n {inputHasValue && (\n <button\n type=\"button\"\n aria-label={mergedResources.searchClearButtonAriaLabel}\n disabled={inputProps.disabled}\n {...clearButtonProps}\n onClick={e => {\n clearButtonProps?.onClick?.(e);\n inputRef.current?.focus();\n }}\n ref={clearButtonRef}\n className={classNames(styles['filter-search__clear-button'], clearButtonProps?.className)}\n >\n <Icon svgIcon={X} size={IconSize.XXSmall} isHovered={!isMobile && isClearButtonHovered} />\n </button>\n )}\n <button\n type={'button'}\n aria-label={mergedResources.searchButtonAriaLabel}\n disabled={inputProps.disabled}\n {...buttonProps}\n ref={buttonRef}\n className={classNames(styles['filter-search__search-button'], buttonProps?.className)}\n >\n <div className={classNames(styles['filter-search__search-button--inner'])}>\n <Icon svgIcon={Search} size={isMobile ? IconSize.XXSmall : IconSize.XSmall} isHovered={!inputProps.disabled && isButtonHovered} />\n </div>\n </button>\n </div>\n );\n};\n\nexport default FilterSearch;\n"],"mappings":";;;;;;;;;;;;;;AAmCA,IAAM,gBAA4C,UAAS;CACzD,MAAM,EAAE,WAAW,OAAO,UAAU,WAAW,aAAa,kBAAkB,KAAK,GAAG,eAAe;CAErG,MA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,KAAK;IACL,WAAW,GAAW,OAAO,iCAAiC,aAAa,SAAS;cAEpF,oBAAC,OAAD;KAAK,WAAW,GAAW,OAAO,sCAAsC;eACtE,oBAAC,cAAD;MAAM,SAAS;MAAQ,MAAM,WAAW,SAAS,UAAU,SAAS;MAAQ,WAAW,CAAC,WAAW,YAAY;KAAkB,CAAA;IAC9H,CAAA;GACC,CAAA;EACL;;AAET"}
|
package/lib/FormFieldTag.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AnalyticsId, LanguageLocales } from "./constants.js";
|
|
2
2
|
import { useLanguage } from "./hooks/useLanguage.js";
|
|
3
|
-
import
|
|
3
|
+
import cn from "classnames";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
import styles from "./components/FormFieldTag/styles.module.scss";
|
|
6
6
|
var HN_Designsystem_FormFieldTag_en_GB_default = {
|
|
@@ -73,7 +73,7 @@ var FormFieldTag = (props) => {
|
|
|
73
73
|
id,
|
|
74
74
|
"data-testid": testId,
|
|
75
75
|
"data-analyticsid": AnalyticsId.FormFieldTag,
|
|
76
|
-
className:
|
|
76
|
+
className: cn(styles["form-field-tag"], { [styles["form-field-tag--optional"]]: isOptional }),
|
|
77
77
|
children: textMap[level]
|
|
78
78
|
});
|
|
79
79
|
};
|