@helsenorge/designsystem-react 5.9.1 → 5.10.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/Button.js +1 -1
- package/Button.js.map +1 -1
- package/CHANGELOG.md +14 -0
- package/Input.js +1 -1
- package/Input.js.map +1 -1
- package/Textarea.js +1 -1
- package/Textarea.js.map +1 -1
- package/components/Button/Button.d.ts +2 -0
- package/components/Button/Button.d.ts.map +1 -1
- package/components/Button/componentdata.json +1 -1
- package/components/Slider/Slider.d.ts +0 -1
- package/components/Slider/Slider.d.ts.map +1 -1
- package/components/Slider/index.js +1 -1
- package/components/Slider/index.js.map +1 -1
- package/package.json +1 -1
package/Button.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e,{useRef as
|
|
1
|
+
import e,{useRef as it,useEffect as ct}from"react";import w from"classnames";import{Icon as ut}from"./components/Icons/Icon.js";import{AnalyticsId as U,IconSize as v}from"./constants.js";import{useBreakpoint as mt}from"./hooks/useBreakpoint.js";import{useHover as V}from"./hooks/useHover.js";import{useIcons as pt}from"./hooks/useIcons.js";import{useSize as dt}from"./hooks/useSize.js";import{getColor as i}from"./theme/currys/color.js";import{breakpoints as bt}from"./theme/grid.js";import{isTest as ft,isProd as ht}from"./utils/environment.js";import gt from"./components/Icons/ArrowRight.js";import t from"./components/Button/styles.module.scss";const wt=(o,n,a,p,s,C)=>C&&a?!s||o?i("neutral",n?500:700):i("white"):a?!s||o?i("neutral",500):`${i("white")}b3`:o&&!s||!o&&s?"white":p==="normal"?i("blueberry",600):i("cherry",500),B=(o,n)=>n&&o?v.Small:o?v.Medium:v.XSmall,Ct=(o,n,a)=>{if(a&&o&&(n===void 0||n===""))throw new Error("Fyll inn ariaLabel prop på Button uten tekst for å opprettholde UU krav")},It=e.forwardRef(function(n,a){const{ariaLabel:p,id:s,children:C,wrapperClassName:j,className:q,arrow:N=!1,concept:R="normal",disabled:d=!1,ellipsis:S=!1,fluid:D=!1,htmlMarkup:I="button",mode:X="onlight",onBlur:z,onClick:E,size:G="medium",variant:_="fill",href:J,tabIndex:M,testId:x,target:A,type:K="button",...F}=n,[b,f,W]=pt(e.Children.toArray(C)),{hoverRef:$,isHovered:Q}=I==="button"?V(a):V(a),H=it(null),c=dt(H),l=!!(b||f)&&!W,Y=b&&(f||N)&&!l,y=X==="ondark",h=mt()<bt.md,L=R==="destructive"&&!d,Z=_==="outline",u=_==="borderless",tt=wt(_==="fill",u,d,R,y,h),O=N&&!u,m=G==="large"&&!L&&!u,et={...F},P=w(t["button-wrapper"],{[t["button-wrapper--fluid"]]:D||S},j),ot=w(t.button,{[t["button--destructive"]]:L,[t["button--normal"]]:!m,[t["button--large"]]:m,[t["button--outline"]]:Z,[t["button--borderless"]]:u,[t["button--left-icon"]]:b&&!l,[t["button--right-icon"]]:f&&!l,[t["button--both-icons"]]:Y,[t["button--only-icon"]]:l,[t["button--arrow"]]:O,[t["button--on-dark"]]:y},q),rt=w(t.button__text,{[t["button__text--ellipsis"]]:S}),nt=w(t.diagonal,{[t["diagonal--on-dark"]]:y});ct(()=>{Ct(l,p,!ft()&&!ht())},[]);const k=(r,g,st)=>{const lt=r&&r.props&&r.props.color?r.props.color:tt;return r&&Object.keys(r).length>0?e.cloneElement(r,{size:g,color:lt,isHovered:Q,className:st}):null},at=()=>{let r,g;return c&&(r=Math.atan2(c.height,c.width),g=Math.sqrt(Math.pow(c.width,2)+Math.pow(c.height,2))),e.createElement("span",{className:rt,ref:H},d&&u&&e.createElement("span",{className:nt},e.createElement("span",{style:{transform:`rotate(${r}rad)`,width:g},className:t.diagonal__line})),e.createElement("span",null,l?p:W))},T=()=>e.createElement("span",{className:ot},k(b,B(m,h),l?void 0:t["button__left-icon"]),at(),O?k(e.createElement(ut,{svgIcon:gt}),B(m,h),t.button__arrow):k(f,B(m,h),t["button__right-icon"]));return e.createElement(e.Fragment,null,I==="button"&&e.createElement("button",{id:s,onBlur:z,onClick:E,disabled:d,"data-testid":x,"data-analyticsid":U.Button,className:P,ref:$,tabIndex:M,type:K,...et},T()),I==="a"&&e.createElement("a",{id:s,onBlur:z,onClick:E,"data-testid":x,"data-analyticsid":U.Button,className:P,href:J,target:A,rel:A==="_blank"?"noopener noreferrer":n.rel,ref:$,tabIndex:M,...F},T()))}),Wt=It;export{Wt as B};
|
|
2
2
|
//# sourceMappingURL=Button.js.map
|
package/Button.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.js","sources":["../src/components/Button/Button.tsx"],"sourcesContent":["import React, { AriaAttributes, useEffect, useRef } from 'react';\n\nimport classNames from 'classnames';\n\nimport Icon, { IconProps, IconSize } from './../Icons/';\nimport { HTMLButtonProps, HTMLAnchorProps, AnalyticsId } from '../../constants';\nimport { useBreakpoint } from '../../hooks/useBreakpoint';\nimport { useHover } from '../../hooks/useHover';\nimport { useIcons } from '../../hooks/useIcons';\nimport { useSize } from '../../hooks/useSize';\nimport { getColor } from '../../theme/currys/color';\nimport { breakpoints } from '../../theme/grid';\nimport { isTest, isProd } from '../../utils/environment';\nimport ArrowRight from '../Icons/ArrowRight';\n\nimport buttonStyles from './styles.module.scss';\n\nexport type ButtonConcept = 'normal' | 'destructive';\nexport type ButtonVariant = 'fill' | 'outline' | 'borderless';\nexport type ButtonSize = 'medium' | 'large';\nexport type ButtonMode = 'onlight' | 'ondark';\nexport type ButtonTags = 'button' | 'a';\n\nexport interface ButtonProps extends HTMLButtonProps, HTMLAnchorProps, AriaAttributes {\n /** Sets the aria-label of the button, use when the button only includes an icon */\n ariaLabel?: string;\n /** Gives a unique id to the button */\n id?: string;\n /** Sets the content of the button. */\n children: React.ReactNode;\n /** Adds custom classes to the wrapper element. */\n wrapperClassName?: string;\n /** Adds custom classes to the element. */\n className?: string;\n /** Enables an arrow icon to the right inside the button (Not available in borderless variant) */\n arrow?: boolean;\n /** Changes the intent of the button. Mostly changes the color profile. */\n concept?: ButtonConcept;\n /** Disables text wrapping and enables ellipsis. */\n ellipsis?: boolean;\n /** Makes the button scale to full width of its parent element. */\n fluid?: boolean;\n /** Changes the underlying element of the button. */\n htmlMarkup?: ButtonTags;\n /** Changes the button colors for different backgrounds. */\n mode?: ButtonMode;\n /** Function that is called when clicked */\n onClick?: (e?: React.MouseEvent<HTMLElement, MouseEvent> | React.FormEvent<{}> | React.KeyboardEvent<HTMLUListElement> | null) => void;\n /** Changes the button colors for different backgrounds. (Large not available in borderless variant) */\n size?: ButtonSize;\n /** Changes the visual representation of the button. */\n variant?: ButtonVariant;\n /** Specifies the focus order relative to the other buttons or controls on the page */\n tabIndex?: number;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Button type. Default: button */\n type?: React.ButtonHTMLAttributes<HTMLButtonElement>['type'];\n}\n\nconst getIconColor = (\n fill: boolean,\n borderless: boolean,\n disabled: boolean,\n concept: ButtonConcept,\n ondark: boolean,\n mobile: boolean\n): string => {\n if (mobile && disabled) {\n return !ondark || fill ? getColor('neutral', !borderless ? 700 : 500) : getColor('white');\n }\n if (disabled) {\n return !ondark || fill ? getColor('neutral', 500) : `${getColor('white')}b3`;\n }\n if ((fill && !ondark) || (!fill && ondark)) {\n return 'white';\n }\n\n return concept === 'normal' ? getColor('blueberry', 600) : getColor('cherry', 500);\n};\nconst getLargeIconSize = (large: boolean, mobile: boolean): IconSize => {\n if (mobile && large) return IconSize.Small;\n if (large) return IconSize.Medium;\n return IconSize.XSmall;\n};\n\nconst checkOnlyIconAria = (onlyIcon: boolean, ariaLabel: string | undefined, devEnv: boolean) => {\n if (devEnv && onlyIcon && (ariaLabel === undefined || ariaLabel === '')) {\n throw new Error('Fyll inn ariaLabel prop på Button uten tekst for å opprettholde UU krav');\n }\n};\n\nconst Button = React.forwardRef(function ButtonForwardedRef(\n props: ButtonProps,\n ref: React.ForwardedRef<HTMLButtonElement | HTMLAnchorElement>\n) {\n const {\n ariaLabel,\n id,\n children,\n wrapperClassName,\n className,\n arrow = false,\n concept = 'normal',\n disabled = false,\n ellipsis = false,\n fluid = false,\n htmlMarkup = 'button',\n mode = 'onlight',\n onClick,\n size = 'medium',\n variant = 'fill',\n href,\n tabIndex,\n testId,\n target,\n type = 'button',\n ...restProps\n } = props;\n\n const [leftIcon, rightIcon, restChildren] = useIcons(React.Children.toArray(children));\n const { hoverRef, isHovered } =\n htmlMarkup === 'button'\n ? useHover<HTMLButtonElement>(ref as React.RefObject<HTMLButtonElement>)\n : useHover<HTMLAnchorElement>(ref as React.RefObject<HTMLAnchorElement>);\n const buttonContentRef = useRef<HTMLDivElement>(null);\n const buttonContentSize = useSize(buttonContentRef);\n const onlyIcon = !!(leftIcon || rightIcon) && !restChildren;\n const bothIcons = leftIcon && (rightIcon || arrow) && !onlyIcon;\n const onDark = mode === 'ondark';\n const breakpoint = useBreakpoint();\n const mobile = breakpoint < breakpoints.md;\n const destructive = concept === 'destructive' && !disabled;\n const outlineVariant = variant === 'outline';\n const borderlessVariant = variant === 'borderless';\n const iconColor = getIconColor(variant === 'fill', borderlessVariant, disabled, concept, onDark, mobile);\n const hasArrow = arrow && !borderlessVariant;\n const large = size === 'large' && !destructive && !borderlessVariant;\n const rest = { ...restProps };\n\n const buttonWrapperClasses = classNames(\n buttonStyles['button-wrapper'],\n { [buttonStyles['button-wrapper--fluid']]: fluid || ellipsis },\n wrapperClassName\n );\n const buttonClasses = classNames(\n buttonStyles.button,\n {\n [buttonStyles['button--destructive']]: destructive,\n [buttonStyles['button--normal']]: !large,\n [buttonStyles['button--large']]: large,\n [buttonStyles['button--outline']]: outlineVariant,\n [buttonStyles['button--borderless']]: borderlessVariant,\n [buttonStyles['button--left-icon']]: leftIcon && !onlyIcon,\n [buttonStyles['button--right-icon']]: rightIcon && !onlyIcon,\n [buttonStyles['button--both-icons']]: bothIcons,\n [buttonStyles['button--only-icon']]: onlyIcon,\n [buttonStyles['button--arrow']]: hasArrow,\n [buttonStyles['button--on-dark']]: onDark,\n },\n className\n );\n const buttonTextClasses = classNames(buttonStyles['button__text'], {\n [buttonStyles['button__text--ellipsis']]: ellipsis,\n });\n const diagonalClasses = classNames(buttonStyles['diagonal'], {\n [buttonStyles['diagonal--on-dark']]: onDark,\n });\n\n useEffect(() => {\n checkOnlyIconAria(onlyIcon, ariaLabel, !isTest() && !isProd());\n }, []);\n\n const renderIcon = (\n iconElement: React.ReactElement<IconProps> | {} | undefined | null,\n iconSize: number,\n iconClassName?: string\n ): React.ReactElement<IconProps> | React.Component<IconProps> | null => {\n const color =\n iconElement && (iconElement as React.ReactElement<IconProps>).props && (iconElement as React.ReactElement<IconProps>).props.color\n ? (iconElement as React.ReactElement<IconProps>).props.color\n : iconColor;\n return iconElement && Object.keys(iconElement).length > 0\n ? React.cloneElement(iconElement as React.ReactElement<IconProps>, { size: iconSize, color, isHovered, className: iconClassName })\n : null;\n };\n\n const renderButtonContent = (): JSX.Element => {\n let angle;\n let diagonalWidth;\n if (buttonContentSize) {\n angle = Math.atan2(buttonContentSize.height, buttonContentSize.width);\n diagonalWidth = Math.sqrt(Math.pow(buttonContentSize.width, 2) + Math.pow(buttonContentSize.height, 2));\n }\n\n return (\n <span className={buttonTextClasses} ref={buttonContentRef}>\n {disabled && borderlessVariant && (\n <span className={diagonalClasses}>\n <span style={{ transform: `rotate(${angle}rad)`, width: diagonalWidth }} className={buttonStyles['diagonal__line']} />\n </span>\n )}\n <span>{onlyIcon ? ariaLabel : restChildren}</span>\n </span>\n );\n };\n\n const renderbuttonContentWrapper = (): JSX.Element => (\n <span className={buttonClasses}>\n {renderIcon(leftIcon, getLargeIconSize(large, mobile), !onlyIcon ? buttonStyles['button__left-icon'] : undefined)}\n {renderButtonContent()}\n {hasArrow\n ? renderIcon(<Icon svgIcon={ArrowRight} />, getLargeIconSize(large, mobile), buttonStyles['button__arrow'])\n : renderIcon(rightIcon, getLargeIconSize(large, mobile), buttonStyles['button__right-icon'])}\n </span>\n );\n\n return (\n <>\n {htmlMarkup === 'button' && (\n <button\n id={id}\n onClick={onClick}\n disabled={disabled}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Button}\n className={buttonWrapperClasses}\n ref={hoverRef as React.ForwardedRef<HTMLButtonElement>}\n tabIndex={tabIndex}\n type={type}\n {...rest}\n >\n {renderbuttonContentWrapper()}\n </button>\n )}\n {htmlMarkup === 'a' && (\n <a\n id={id}\n onClick={onClick}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Button}\n className={buttonWrapperClasses}\n href={href}\n target={target}\n rel={target === '_blank' ? 'noopener noreferrer' : props.rel}\n ref={hoverRef as React.ForwardedRef<HTMLAnchorElement>}\n tabIndex={tabIndex}\n {...restProps}\n >\n {renderbuttonContentWrapper()}\n </a>\n )}\n </>\n );\n});\n\nexport default Button;\n"],"names":["getIconColor","fill","borderless","disabled","concept","ondark","mobile","getColor","getLargeIconSize","large","IconSize","checkOnlyIconAria","onlyIcon","ariaLabel","devEnv","Button","React","props","ref","id","children","wrapperClassName","className","arrow","ellipsis","fluid","htmlMarkup","mode","onClick","size","variant","href","tabIndex","testId","target","type","restProps","leftIcon","rightIcon","restChildren","useIcons","hoverRef","isHovered","useHover","buttonContentRef","useRef","buttonContentSize","useSize","bothIcons","onDark","useBreakpoint","breakpoints","destructive","outlineVariant","borderlessVariant","iconColor","hasArrow","rest","buttonWrapperClasses","classNames","buttonStyles","buttonClasses","buttonTextClasses","diagonalClasses","useEffect","isTest","isProd","renderIcon","iconElement","iconSize","iconClassName","color","renderButtonContent","angle","diagonalWidth","renderbuttonContentWrapper","Icon","ArrowRight","AnalyticsId","Button$1"],"mappings":"yoBA4DA,MAAMA,GAAe,CACnBC,EACAC,EACAC,EACAC,EACAC,EACAC,IAEIA,GAAUH,EACL,CAACE,GAAUJ,EAAOM,EAAS,UAAYL,EAAmB,IAAN,GAAS,EAAIK,EAAS,OAAO,EAEtFJ,EACK,CAACE,GAAUJ,EAAOM,EAAS,UAAW,GAAG,EAAI,GAAGA,EAAS,OAAO,CAAC,KAErEN,GAAQ,CAACI,GAAY,CAACJ,GAAQI,EAC1B,QAGFD,IAAY,SAA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C,IAAA,CACC,GAAAG,EACA,QAAAS,EACA,cAAaK,EACb,mBAAkB6C,EAAY,OAC9B,UAAWpB,EACX,KAAA3B,EACA,OAAAG,EACA,IAAKA,IAAW,SAAW,sBAAwBjB,EAAM,IACzD,IAAKwB,EACL,SAAAT,EACC,GAAGI,CAAA,EAEHuC,EAA2B,CAAA,CAGlC,CAEJ,CAAC,EAEDI,GAAehE"}
|
|
1
|
+
{"version":3,"file":"Button.js","sources":["../src/components/Button/Button.tsx"],"sourcesContent":["import React, { AriaAttributes, useEffect, useRef } from 'react';\n\nimport classNames from 'classnames';\n\nimport Icon, { IconProps, IconSize } from './../Icons/';\nimport { HTMLButtonProps, HTMLAnchorProps, AnalyticsId } from '../../constants';\nimport { useBreakpoint } from '../../hooks/useBreakpoint';\nimport { useHover } from '../../hooks/useHover';\nimport { useIcons } from '../../hooks/useIcons';\nimport { useSize } from '../../hooks/useSize';\nimport { getColor } from '../../theme/currys/color';\nimport { breakpoints } from '../../theme/grid';\nimport { isTest, isProd } from '../../utils/environment';\nimport ArrowRight from '../Icons/ArrowRight';\n\nimport buttonStyles from './styles.module.scss';\n\nexport type ButtonConcept = 'normal' | 'destructive';\nexport type ButtonVariant = 'fill' | 'outline' | 'borderless';\nexport type ButtonSize = 'medium' | 'large';\nexport type ButtonMode = 'onlight' | 'ondark';\nexport type ButtonTags = 'button' | 'a';\n\nexport interface ButtonProps extends HTMLButtonProps, HTMLAnchorProps, AriaAttributes {\n /** Sets the aria-label of the button, use when the button only includes an icon */\n ariaLabel?: string;\n /** Gives a unique id to the button */\n id?: string;\n /** Sets the content of the button. */\n children: React.ReactNode;\n /** Adds custom classes to the wrapper element. */\n wrapperClassName?: string;\n /** Adds custom classes to the element. */\n className?: string;\n /** Enables an arrow icon to the right inside the button (Not available in borderless variant) */\n arrow?: boolean;\n /** Changes the intent of the button. Mostly changes the color profile. */\n concept?: ButtonConcept;\n /** Disables text wrapping and enables ellipsis. */\n ellipsis?: boolean;\n /** Makes the button scale to full width of its parent element. */\n fluid?: boolean;\n /** Changes the underlying element of the button. */\n htmlMarkup?: ButtonTags;\n /** Changes the button colors for different backgrounds. */\n mode?: ButtonMode;\n /** Function that is called when the Button loses focus */\n onBlur?: () => void;\n /** Function that is called when clicked */\n onClick?: (e?: React.MouseEvent<HTMLElement, MouseEvent> | React.FormEvent<{}> | React.KeyboardEvent<HTMLUListElement> | null) => void;\n /** Changes the button colors for different backgrounds. (Large not available in borderless variant) */\n size?: ButtonSize;\n /** Changes the visual representation of the button. */\n variant?: ButtonVariant;\n /** Specifies the focus order relative to the other buttons or controls on the page */\n tabIndex?: number;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Button type. Default: button */\n type?: React.ButtonHTMLAttributes<HTMLButtonElement>['type'];\n}\n\nconst getIconColor = (\n fill: boolean,\n borderless: boolean,\n disabled: boolean,\n concept: ButtonConcept,\n ondark: boolean,\n mobile: boolean\n): string => {\n if (mobile && disabled) {\n return !ondark || fill ? getColor('neutral', !borderless ? 700 : 500) : getColor('white');\n }\n if (disabled) {\n return !ondark || fill ? getColor('neutral', 500) : `${getColor('white')}b3`;\n }\n if ((fill && !ondark) || (!fill && ondark)) {\n return 'white';\n }\n\n return concept === 'normal' ? getColor('blueberry', 600) : getColor('cherry', 500);\n};\nconst getLargeIconSize = (large: boolean, mobile: boolean): IconSize => {\n if (mobile && large) return IconSize.Small;\n if (large) return IconSize.Medium;\n return IconSize.XSmall;\n};\n\nconst checkOnlyIconAria = (onlyIcon: boolean, ariaLabel: string | undefined, devEnv: boolean) => {\n if (devEnv && onlyIcon && (ariaLabel === undefined || ariaLabel === '')) {\n throw new Error('Fyll inn ariaLabel prop på Button uten tekst for å opprettholde UU krav');\n }\n};\n\nconst Button = React.forwardRef(function ButtonForwardedRef(\n props: ButtonProps,\n ref: React.ForwardedRef<HTMLButtonElement | HTMLAnchorElement>\n) {\n const {\n ariaLabel,\n id,\n children,\n wrapperClassName,\n className,\n arrow = false,\n concept = 'normal',\n disabled = false,\n ellipsis = false,\n fluid = false,\n htmlMarkup = 'button',\n mode = 'onlight',\n onBlur,\n onClick,\n size = 'medium',\n variant = 'fill',\n href,\n tabIndex,\n testId,\n target,\n type = 'button',\n ...restProps\n } = props;\n\n const [leftIcon, rightIcon, restChildren] = useIcons(React.Children.toArray(children));\n const { hoverRef, isHovered } =\n htmlMarkup === 'button'\n ? useHover<HTMLButtonElement>(ref as React.RefObject<HTMLButtonElement>)\n : useHover<HTMLAnchorElement>(ref as React.RefObject<HTMLAnchorElement>);\n const buttonContentRef = useRef<HTMLDivElement>(null);\n const buttonContentSize = useSize(buttonContentRef);\n const onlyIcon = !!(leftIcon || rightIcon) && !restChildren;\n const bothIcons = leftIcon && (rightIcon || arrow) && !onlyIcon;\n const onDark = mode === 'ondark';\n const breakpoint = useBreakpoint();\n const mobile = breakpoint < breakpoints.md;\n const destructive = concept === 'destructive' && !disabled;\n const outlineVariant = variant === 'outline';\n const borderlessVariant = variant === 'borderless';\n const iconColor = getIconColor(variant === 'fill', borderlessVariant, disabled, concept, onDark, mobile);\n const hasArrow = arrow && !borderlessVariant;\n const large = size === 'large' && !destructive && !borderlessVariant;\n const rest = { ...restProps };\n\n const buttonWrapperClasses = classNames(\n buttonStyles['button-wrapper'],\n { [buttonStyles['button-wrapper--fluid']]: fluid || ellipsis },\n wrapperClassName\n );\n const buttonClasses = classNames(\n buttonStyles.button,\n {\n [buttonStyles['button--destructive']]: destructive,\n [buttonStyles['button--normal']]: !large,\n [buttonStyles['button--large']]: large,\n [buttonStyles['button--outline']]: outlineVariant,\n [buttonStyles['button--borderless']]: borderlessVariant,\n [buttonStyles['button--left-icon']]: leftIcon && !onlyIcon,\n [buttonStyles['button--right-icon']]: rightIcon && !onlyIcon,\n [buttonStyles['button--both-icons']]: bothIcons,\n [buttonStyles['button--only-icon']]: onlyIcon,\n [buttonStyles['button--arrow']]: hasArrow,\n [buttonStyles['button--on-dark']]: onDark,\n },\n className\n );\n const buttonTextClasses = classNames(buttonStyles['button__text'], {\n [buttonStyles['button__text--ellipsis']]: ellipsis,\n });\n const diagonalClasses = classNames(buttonStyles['diagonal'], {\n [buttonStyles['diagonal--on-dark']]: onDark,\n });\n\n useEffect(() => {\n checkOnlyIconAria(onlyIcon, ariaLabel, !isTest() && !isProd());\n }, []);\n\n const renderIcon = (\n iconElement: React.ReactElement<IconProps> | {} | undefined | null,\n iconSize: number,\n iconClassName?: string\n ): React.ReactElement<IconProps> | React.Component<IconProps> | null => {\n const color =\n iconElement && (iconElement as React.ReactElement<IconProps>).props && (iconElement as React.ReactElement<IconProps>).props.color\n ? (iconElement as React.ReactElement<IconProps>).props.color\n : iconColor;\n return iconElement && Object.keys(iconElement).length > 0\n ? React.cloneElement(iconElement as React.ReactElement<IconProps>, { size: iconSize, color, isHovered, className: iconClassName })\n : null;\n };\n\n const renderButtonContent = (): JSX.Element => {\n let angle;\n let diagonalWidth;\n if (buttonContentSize) {\n angle = Math.atan2(buttonContentSize.height, buttonContentSize.width);\n diagonalWidth = Math.sqrt(Math.pow(buttonContentSize.width, 2) + Math.pow(buttonContentSize.height, 2));\n }\n\n return (\n <span className={buttonTextClasses} ref={buttonContentRef}>\n {disabled && borderlessVariant && (\n <span className={diagonalClasses}>\n <span style={{ transform: `rotate(${angle}rad)`, width: diagonalWidth }} className={buttonStyles['diagonal__line']} />\n </span>\n )}\n <span>{onlyIcon ? ariaLabel : restChildren}</span>\n </span>\n );\n };\n\n const renderbuttonContentWrapper = (): JSX.Element => (\n <span className={buttonClasses}>\n {renderIcon(leftIcon, getLargeIconSize(large, mobile), !onlyIcon ? buttonStyles['button__left-icon'] : undefined)}\n {renderButtonContent()}\n {hasArrow\n ? renderIcon(<Icon svgIcon={ArrowRight} />, getLargeIconSize(large, mobile), buttonStyles['button__arrow'])\n : renderIcon(rightIcon, getLargeIconSize(large, mobile), buttonStyles['button__right-icon'])}\n </span>\n );\n\n return (\n <>\n {htmlMarkup === 'button' && (\n <button\n id={id}\n onBlur={onBlur}\n onClick={onClick}\n disabled={disabled}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Button}\n className={buttonWrapperClasses}\n ref={hoverRef as React.ForwardedRef<HTMLButtonElement>}\n tabIndex={tabIndex}\n type={type}\n {...rest}\n >\n {renderbuttonContentWrapper()}\n </button>\n )}\n {htmlMarkup === 'a' && (\n <a\n id={id}\n onBlur={onBlur}\n onClick={onClick}\n data-testid={testId}\n data-analyticsid={AnalyticsId.Button}\n className={buttonWrapperClasses}\n href={href}\n target={target}\n rel={target === '_blank' ? 'noopener noreferrer' : props.rel}\n ref={hoverRef as React.ForwardedRef<HTMLAnchorElement>}\n tabIndex={tabIndex}\n {...restProps}\n >\n {renderbuttonContentWrapper()}\n </a>\n )}\n </>\n );\n});\n\nexport default Button;\n"],"names":["getIconColor","fill","borderless","disabled","concept","ondark","mobile","getColor","getLargeIconSize","large","IconSize","checkOnlyIconAria","onlyIcon","ariaLabel","devEnv","Button","React","props","ref","id","children","wrapperClassName","className","arrow","ellipsis","fluid","htmlMarkup","mode","onBlur","onClick","size","variant","href","tabIndex","testId","target","type","restProps","leftIcon","rightIcon","restChildren","useIcons","hoverRef","isHovered","useHover","buttonContentRef","useRef","buttonContentSize","useSize","bothIcons","onDark","useBreakpoint","breakpoints","destructive","outlineVariant","borderlessVariant","iconColor","hasArrow","rest","buttonWrapperClasses","classNames","buttonStyles","buttonClasses","buttonTextClasses","diagonalClasses","useEffect","isTest","isProd","renderIcon","iconElement","iconSize","iconClassName","color","renderButtonContent","angle","diagonalWidth","renderbuttonContentWrapper","Icon","ArrowRight","AnalyticsId","Button$1"],"mappings":"yoBA8DA,MAAMA,GAAe,CACnBC,EACAC,EACAC,EACAC,EACAC,EACAC,IAEIA,GAAUH,EACL,CAACE,GAAUJ,EAAOM,EAAS,UAAYL,EAAmB,IAAN,GAAS,EAAIK,EAAS,OAAO,EAEtFJ,EACK,CAACE,GAAUJ,EAAOM,EAAS,UAAW,GAAG,EAAI,GAAGA,EAAS,OAAO,CAAC,KAErEN,GAAQ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G,EACC,GAAGsB,EAAA,EAEHkB,EAA2B,CAAA,EAG/BlD,IAAe,KACdV,EAAA,cAAC,IAAA,CACC,GAAAG,EACA,OAAAS,EACA,QAAAC,EACA,cAAaK,EACb,mBAAkB6C,EAAY,OAC9B,UAAWpB,EACX,KAAA3B,EACA,OAAAG,EACA,IAAKA,IAAW,SAAW,sBAAwBlB,EAAM,IACzD,IAAKyB,EACL,SAAAT,EACC,GAAGI,CAAA,EAEHuC,EAA2B,CAAA,CAGlC,CAEJ,CAAC,EAEDI,GAAejE"}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [5.9.2](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv5.9.1&targetVersion=GTv5.9.2) (2023-12-12)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
- slider forenklet emojirendring ([9df0d90](https://github.com/helsenorge/designsystem/commit/9df0d90e58c16f0609ce2c0de6c770f10420e7eb)),
|
|
6
|
+
closes [#313810](https://github.com/helsenorge/designsystem/issues/313810)
|
|
7
|
+
|
|
8
|
+
## [5.9.1](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv5.9.0&targetVersion=GTv5.9.1) (2023-12-11)
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
- promopanel har position=relative ([360a762](https://github.com/helsenorge/designsystem/commit/360a762ec3ce63cfe870f6cd7300af9fb9b83a5e)),
|
|
13
|
+
closes [#315387](https://github.com/helsenorge/designsystem/issues/315387)
|
|
14
|
+
|
|
1
15
|
## [5.9.0](https://github.com/helsenorge/designsystem/branchCompare?baseVersion=GTv5.8.0&targetVersion=GTv5.9.0) (2023-12-11)
|
|
2
16
|
|
|
3
17
|
### Features
|
package/Input.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import r,{useRef as A,useState as K,useEffect as he}from"react";import x from"classnames";import{FormMode as l,FormVariant as ge,IconSize as D,AnalyticsId as ve,AVERAGE_CHARACTER_WIDTH_PX as Ce}from"./constants.js";import{useBreakpoint as xe,Breakpoint as _e}from"./hooks/useBreakpoint.js";import{useUuid as Ee}from"./hooks/useUuid.js";import{getColor as F}from"./theme/currys/color.js";import{E as ye}from"./ErrorWrapper.js";import{Icon as ke}from"./components/Icons/Icon.js";import{a as we}from"./Label.js";import{M as Ie}from"./MaxCharacters.js";import t from"./components/Input/styles.module.scss";var Ne=(e=>(e.text="text",e.number="number",e.email="email",e.password="password",e.search="search",e.tel="tel",e.url="url",e.date="date",e.time="time",e))(Ne||{});const Re=(e,u,f)=>{const o=u?"1.5rem":"2rem",b=u?`${f}px`:"0px",d="4px";return`calc(${e*Ce}px + ${o} + ${b} + ${d})`},M=r.forwardRef((e,u)=>{const{className:f,defaultValue:o
|
|
1
|
+
import r,{useRef as A,useState as K,useEffect as he}from"react";import x from"classnames";import{FormMode as l,FormVariant as ge,IconSize as D,AnalyticsId as ve,AVERAGE_CHARACTER_WIDTH_PX as Ce}from"./constants.js";import{useBreakpoint as xe,Breakpoint as _e}from"./hooks/useBreakpoint.js";import{useUuid as Ee}from"./hooks/useUuid.js";import{getColor as F}from"./theme/currys/color.js";import{E as ye}from"./ErrorWrapper.js";import{Icon as ke}from"./components/Icons/Icon.js";import{a as we}from"./Label.js";import{M as Ie}from"./MaxCharacters.js";import t from"./components/Input/styles.module.scss";var Ne=(e=>(e.text="text",e.number="number",e.email="email",e.password="password",e.search="search",e.tel="tel",e.url="url",e.date="date",e.time="time",e))(Ne||{});const Re=(e,u,f)=>{const o=u?"1.5rem":"2rem",b=u?`${f}px`:"0px",d="4px";return`calc(${e*Ce}px + ${o} + ${b} + ${d})`},M=r.forwardRef((e,u)=>{const{className:f,defaultValue:o,placeholder:b,type:d="text",name:z,transparent:B=!1,icon:c,iconRight:h,inputId:P,inputWrapperRef:U,mode:i=l.onwhite,baseIncrementValue:_,variant:H,label:O,error:X,errorText:E,testId:q,disabled:s,readOnly:G,autoComplete:L,afterInputChildren:j,rightOfInput:J,width:y,required:Q,onChange:k,onKeyDown:w,autoFocus:Y,maxCharacters:m,maxText:Z,...T}=e,ee=xe(),p=A(null),I=Ee(P),[N,R]=K(o||""),[te,ne]=K(void 0),g=A(!1),W=/^[0-9]$/;he(()=>{R(o||"")},[o]);const re=i===l.ondark,ae=i===l.onblueberry,oe=!!m&&N.toString().length>m,v=i===l.oninvalid||!!E||!!X||oe,C=H===ge.bigform,ie=B&&i!==l.ondark&&!v,ce=x(t["input-wrapper"],f),se=x(t["input-container"],{[t["input-container--transparent"]]:ie,[t["input-container--on-blueberry"]]:ae,[t["input-container--on-dark"]]:re,[t["input-container--invalid"]]:v,[t["input-container--bigform"]]:C,[t["input-container--disabled"]]:s,[t["input-container--with-icon"]]:c}),le=x(t["input-container__input"],{[t["input-container__input--bigform"]]:C,[t["input-container__input--disabled"]]:s}),ue=s?F("neutral",500):F("black"),S=ee===_e.xs||!C?D.XSmall:D.Small,V=()=>c!==void 0?r.createElement(ke,{className:t["input-container__input__icon"],color:ue,size:S,svgIcon:c}):null,de=n=>{if(p&&p.current&&c){const a=h?0:1;p.current.children[a].focus(),e.onClick&&e.onClick(n)}},me=n=>{const a=pe(n);k&&k(n),R(a),ne(a)},pe=n=>{if(typeof _>"u"||d!=="number")return n.target.value;const a=Number(n.target.value);return!te&&!g.current&&(a===1||a===-1)&&(n.target.value=_+""),n.target.value},fe=n=>{W.test(n.key)&&(g.current=!0),w&&w(n)},be=n=>{W.test(n.key)&&(g.current=!1)},$=y?Re(y,!!c,S):void 0;return r.createElement(ye,{errorText:E},r.createElement("div",{"data-testid":q,"data-analyticsid":ve.Input,className:ce,ref:U},we(O,I,i,s),r.createElement("div",{className:t["content-wrapper"]},r.createElement("div",{onClick:de,ref:p,className:se,style:{maxWidth:$}},!h&&V(),r.createElement("input",{onChange:me,onKeyDown:fe,onKeyUp:be,name:z,type:d,defaultValue:o,id:I,className:le,ref:u,"aria-labelledby":e["aria-labelledby"]??void 0,"aria-describedby":e["aria-describedby"]??void 0,"aria-invalid":!!v,disabled:s,placeholder:b,readOnly:G,autoComplete:L||"off",required:Q,autoFocus:Y,...T}),h&&V()),r.createElement("div",{className:t["content-wrapper__right-of-input"]},J)),m&&r.createElement(Ie,{maxCharacters:m,length:N.toString().length,maxText:Z,mode:i,maxWidth:$}),j))});M.displayName="Input";const Ue=M;export{Ue as I,Ne as a};
|
|
2
2
|
//# sourceMappingURL=Input.js.map
|
package/Input.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.js","sources":["../src/components/Input/Input.tsx"],"sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\n\nimport cn from 'classnames';\n\nimport { FormMode, FormVariant, AnalyticsId, AVERAGE_CHARACTER_WIDTH_PX } from '../../constants';\nimport { Breakpoint, useBreakpoint } from '../../hooks/useBreakpoint';\nimport { useUuid } from '../../hooks/useUuid';\nimport { getColor } from '../../theme/currys';\nimport ErrorWrapper from '../ErrorWrapper';\nimport Icon, { IconSize, SvgIcon } from '../Icons';\nimport { renderLabel } from '../Label';\nimport MaxCharacters from '../MaxCharacters/MaxCharacters';\n\nimport styles from './styles.module.scss';\n\nexport interface InputProps\n extends Pick<\n React.InputHTMLAttributes<HTMLInputElement>,\n | 'disabled'\n | 'readOnly'\n | 'autoComplete'\n | 'name'\n | 'placeholder'\n | 'defaultValue'\n | 'required'\n | 'value'\n | 'min'\n | 'max'\n | 'aria-describedby'\n | 'aria-labelledby'\n | 'onBlur'\n | 'onClick'\n | 'onChange'\n | 'onFocus'\n | 'onKeyDown'\n | 'autoFocus'\n > {\n /** The number at which the input field starts when you increment or decrement it */\n baseIncrementValue?: number;\n /** Adds custom classes to the element. */\n className?: string;\n /** HMTL Input type */\n type?: keyof typeof InputTypes;\n /** input id */\n inputId?: string;\n /** Width of input field in characters (approximate) */\n width?: number;\n /** If true, the component will be transparent. */\n transparent?: boolean;\n /** Icon to be displayed next to the input field */\n icon?: SvgIcon;\n /** Places the icon to the right */\n iconRight?: boolean;\n /** Ref that is placed on the inputWrapper */\n inputWrapperRef?: React.RefObject<HTMLDivElement>;\n /** Changes the color profile of the input */\n mode?: keyof typeof FormMode;\n /** Changes the visuals of the input */\n variant?: keyof typeof FormVariant;\n /** Label of the input */\n label?: React.ReactNode;\n /** Activates Error style for the input */\n error?: boolean;\n /** Error text to show above the component */\n errorText?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Component shown after input */\n afterInputChildren?: React.ReactNode;\n /** Component shown to the right of input */\n rightOfInput?: React.ReactNode;\n /** max character limit in input */\n maxCharacters?: number;\n /** The text is displayed in the end of the text-counter */\n maxText?: string;\n}\n\nexport enum InputTypes {\n text = 'text',\n number = 'number',\n email = 'email',\n password = 'password',\n search = 'search',\n tel = 'tel',\n url = 'url',\n date = 'date',\n time = 'time',\n}\n\nconst getInputMaxWidth = (characters: number, hasIcon: boolean, iconSize: number): string => {\n const paddingWidth = hasIcon ? '1.5rem' : '2rem';\n const iconWidth = hasIcon ? `${iconSize}px` : '0px';\n const borderWidth = '4px';\n\n return `calc(${characters * AVERAGE_CHARACTER_WIDTH_PX}px + ${paddingWidth} + ${iconWidth} + ${borderWidth})`;\n};\n\nconst Input = React.forwardRef((props: InputProps, ref: React.Ref<HTMLInputElement>) => {\n const {\n className,\n defaultValue = '',\n placeholder,\n type = InputTypes.text,\n name,\n transparent = false,\n icon,\n iconRight,\n inputId,\n inputWrapperRef,\n mode = FormMode.onwhite,\n baseIncrementValue,\n variant,\n label,\n error,\n errorText,\n testId,\n disabled,\n readOnly,\n autoComplete,\n afterInputChildren,\n rightOfInput,\n width,\n required,\n onChange,\n onKeyDown,\n autoFocus,\n maxCharacters,\n maxText,\n ...rest\n } = props;\n const breakpoint = useBreakpoint();\n const inputContainerRef = useRef<HTMLDivElement>(null);\n const inputIdState = useUuid(inputId);\n const [input, setInput] = useState(defaultValue);\n const [prevValue, setPrevValue] = useState<string | number | undefined>(undefined);\n const numKeyPressed = useRef<boolean>(false);\n const numRegex = /^[0-9]$/;\n\n useEffect(() => {\n setInput(defaultValue);\n }, [defaultValue]);\n\n const onDark = mode === FormMode.ondark;\n const onBlueberry = mode === FormMode.onblueberry;\n const maxCharactersExceeded = !!maxCharacters && input.toString().length > maxCharacters;\n const onError = mode === FormMode.oninvalid || !!errorText || !!error || maxCharactersExceeded;\n const bigForm = variant === FormVariant.bigform;\n const isTransparent = transparent && mode !== FormMode.ondark && !onError;\n\n const inputWrapperClass = cn(styles['input-wrapper'], className);\n\n const inputContainer = cn(styles['input-container'], {\n [styles['input-container--transparent']]: isTransparent,\n [styles['input-container--on-blueberry']]: onBlueberry,\n [styles['input-container--on-dark']]: onDark,\n [styles['input-container--invalid']]: onError,\n [styles['input-container--bigform']]: bigForm,\n [styles['input-container--disabled']]: disabled,\n [styles['input-container--with-icon']]: icon,\n });\n\n const inputClass = cn(styles['input-container__input'], {\n [styles['input-container__input--bigform']]: bigForm,\n [styles['input-container__input--disabled']]: disabled,\n });\n\n const iconColor = disabled ? getColor('neutral', 500) : getColor('black');\n const iconSize = breakpoint === Breakpoint.xs || !bigForm ? IconSize.XSmall : IconSize.Small;\n\n const renderIcon = (): React.ReactNode => {\n return icon !== undefined ? (\n <Icon className={styles['input-container__input__icon']} color={iconColor} size={iconSize} svgIcon={icon} />\n ) : null;\n };\n\n // eslint-disable-next-line\n const handleClick = (e: React.MouseEvent<any>): void => {\n if (inputContainerRef && inputContainerRef.current && icon) {\n const selectedChild = iconRight ? 0 : 1;\n const input = inputContainerRef.current.children[selectedChild] as HTMLInputElement;\n input.focus();\n\n props.onClick && props.onClick(e);\n }\n };\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>): void => {\n const newValue = getIncrementValue(e);\n\n if (onChange) {\n onChange(e);\n }\n\n setInput(newValue);\n setPrevValue(newValue);\n };\n\n // Hvis bruker endrer number value med 1 og det skal startes på en annen verdi enn 0\n const getIncrementValue = (e: React.ChangeEvent<HTMLInputElement>): string => {\n if (typeof baseIncrementValue === 'undefined' || type !== 'number') return e.target.value;\n\n const valueAsNumber = Number(e.target.value);\n\n if (!prevValue && !numKeyPressed.current && (valueAsNumber === 1 || valueAsNumber === -1)) {\n e.target.value = baseIncrementValue + '';\n }\n\n return e.target.value;\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>): void => {\n if (numRegex.test(e.key)) {\n numKeyPressed.current = true;\n }\n onKeyDown && onKeyDown(e);\n };\n\n const handleKeyUp = (e: React.KeyboardEvent<HTMLInputElement>): void => {\n if (numRegex.test(e.key)) {\n numKeyPressed.current = false;\n }\n };\n\n const maxWidth = width ? getInputMaxWidth(width, !!icon, iconSize) : undefined;\n\n return (\n <ErrorWrapper errorText={errorText}>\n <div data-testid={testId} data-analyticsid={AnalyticsId.Input} className={inputWrapperClass} ref={inputWrapperRef}>\n {renderLabel(label, inputIdState, mode as FormMode, disabled)}\n {/* input-elementet tillater keyboard-interaksjon */}\n <div className={styles['content-wrapper']}>\n {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */}\n <div onClick={handleClick} ref={inputContainerRef} className={inputContainer} style={{ maxWidth }}>\n {!iconRight && renderIcon()}\n <input\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n onKeyUp={handleKeyUp}\n name={name}\n type={type}\n defaultValue={defaultValue}\n id={inputIdState}\n className={inputClass}\n ref={ref}\n aria-labelledby={props['aria-labelledby'] ?? undefined}\n aria-describedby={props['aria-describedby'] ?? undefined}\n aria-invalid={!!onError}\n disabled={disabled}\n placeholder={placeholder}\n readOnly={readOnly}\n autoComplete={autoComplete || 'off'}\n required={required}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={autoFocus}\n {...rest}\n />\n {iconRight && renderIcon()}\n </div>\n <div className={styles['content-wrapper__right-of-input']}>{rightOfInput}</div>\n </div>\n {maxCharacters && (\n <MaxCharacters maxCharacters={maxCharacters} length={input.toString().length} maxText={maxText} mode={mode} maxWidth={maxWidth} />\n )}\n {afterInputChildren}\n </div>\n </ErrorWrapper>\n );\n});\n\nInput.displayName = 'Input';\n\nexport default Input;\n"],"names":["InputTypes","getInputMaxWidth","characters","hasIcon","iconSize","paddingWidth","iconWidth","borderWidth","AVERAGE_CHARACTER_WIDTH_PX","Input","React","props","ref","className","defaultValue","placeholder","type","name","transparent","icon","iconRight","inputId","inputWrapperRef","mode","FormMode","baseIncrementValue","variant","label","error","errorText","testId","disabled","readOnly","autoComplete","afterInputChildren","rightOfInput","width","required","onChange","onKeyDown","autoFocus","maxCharacters","maxText","rest","breakpoint","useBreakpoint","inputContainerRef","useRef","inputIdState","useUuid","input","setInput","useState","prevValue","setPrevValue","numKeyPressed","numRegex","useEffect","onDark","onBlueberry","maxCharactersExceeded","onError","bigForm","FormVariant","isTransparent","inputWrapperClass","cn","styles","inputContainer","inputClass","iconColor","getColor","Breakpoint","IconSize","renderIcon","Icon","handleClick","e","selectedChild","handleChange","newValue","getIncrementValue","valueAsNumber","handleKeyDown","handleKeyUp","maxWidth","ErrorWrapper","AnalyticsId","renderLabel","MaxCharacters","Input$1"],"mappings":"0lBA6EY,IAAAA,IAAAA,IACVA,EAAA,KAAO,OACPA,EAAA,OAAS,SACTA,EAAA,MAAQ,QACRA,EAAA,SAAW,WACXA,EAAA,OAAS,SACTA,EAAA,IAAM,MACNA,EAAA,IAAM,MACNA,EAAA,KAAO,OACPA,EAAA,KAAO,OATGA,IAAAA,IAAA,CAAA,CAAA,EAYZ,MAAMC,GAAmB,CAACC,EAAoBC,EAAkBC,IAA6B,CACrF,MAAAC,EAAeF,EAAU,SAAW,OACpCG,EAAYH,EAAU,GAAGC,CAAQ,KAAO,MACxCG,EAAc,MAEb,MAAA,QAAQL,EAAaM,EAA0B,QAAQH,CAAY,MAAMC,CAAS,MAAMC,CAAW,GAC5G,EAEME,EAAQC,EAAM,WAAW,CAACC,EAAmBC,IAAqC,CAChF,KAAA,CACJ,UAAAC,EACA,aAAAC,EAAe,GACf,YAAAC,EACA,KA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import React, { useEffect, useRef, useState } from 'react';\n\nimport cn from 'classnames';\n\nimport { FormMode, FormVariant, AnalyticsId, AVERAGE_CHARACTER_WIDTH_PX } from '../../constants';\nimport { Breakpoint, useBreakpoint } from '../../hooks/useBreakpoint';\nimport { useUuid } from '../../hooks/useUuid';\nimport { getColor } from '../../theme/currys';\nimport ErrorWrapper from '../ErrorWrapper';\nimport Icon, { IconSize, SvgIcon } from '../Icons';\nimport { renderLabel } from '../Label';\nimport MaxCharacters from '../MaxCharacters/MaxCharacters';\n\nimport styles from './styles.module.scss';\n\nexport interface InputProps\n extends Pick<\n React.InputHTMLAttributes<HTMLInputElement>,\n | 'disabled'\n | 'readOnly'\n | 'autoComplete'\n | 'name'\n | 'placeholder'\n | 'defaultValue'\n | 'required'\n | 'value'\n | 'min'\n | 'max'\n | 'aria-describedby'\n | 'aria-labelledby'\n | 'onBlur'\n | 'onClick'\n | 'onChange'\n | 'onFocus'\n | 'onKeyDown'\n | 'autoFocus'\n > {\n /** The number at which the input field starts when you increment or decrement it */\n baseIncrementValue?: number;\n /** Adds custom classes to the element. */\n className?: string;\n /** HMTL Input type */\n type?: keyof typeof InputTypes;\n /** input id */\n inputId?: string;\n /** Width of input field in characters (approximate) */\n width?: number;\n /** If true, the component will be transparent. */\n transparent?: boolean;\n /** Icon to be displayed next to the input field */\n icon?: SvgIcon;\n /** Places the icon to the right */\n iconRight?: boolean;\n /** Ref that is placed on the inputWrapper */\n inputWrapperRef?: React.RefObject<HTMLDivElement>;\n /** Changes the color profile of the input */\n mode?: keyof typeof FormMode;\n /** Changes the visuals of the input */\n variant?: keyof typeof FormVariant;\n /** Label of the input */\n label?: React.ReactNode;\n /** Activates Error style for the input */\n error?: boolean;\n /** Error text to show above the component */\n errorText?: string;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** Component shown after input */\n afterInputChildren?: React.ReactNode;\n /** Component shown to the right of input */\n rightOfInput?: React.ReactNode;\n /** max character limit in input */\n maxCharacters?: number;\n /** The text is displayed in the end of the text-counter */\n maxText?: string;\n}\n\nexport enum InputTypes {\n text = 'text',\n number = 'number',\n email = 'email',\n password = 'password',\n search = 'search',\n tel = 'tel',\n url = 'url',\n date = 'date',\n time = 'time',\n}\n\nconst getInputMaxWidth = (characters: number, hasIcon: boolean, iconSize: number): string => {\n const paddingWidth = hasIcon ? '1.5rem' : '2rem';\n const iconWidth = hasIcon ? `${iconSize}px` : '0px';\n const borderWidth = '4px';\n\n return `calc(${characters * AVERAGE_CHARACTER_WIDTH_PX}px + ${paddingWidth} + ${iconWidth} + ${borderWidth})`;\n};\n\nconst Input = React.forwardRef((props: InputProps, ref: React.Ref<HTMLInputElement>) => {\n const {\n className,\n defaultValue,\n placeholder,\n type = InputTypes.text,\n name,\n transparent = false,\n icon,\n iconRight,\n inputId,\n inputWrapperRef,\n mode = FormMode.onwhite,\n baseIncrementValue,\n variant,\n label,\n error,\n errorText,\n testId,\n disabled,\n readOnly,\n autoComplete,\n afterInputChildren,\n rightOfInput,\n width,\n required,\n onChange,\n onKeyDown,\n autoFocus,\n maxCharacters,\n maxText,\n ...rest\n } = props;\n const breakpoint = useBreakpoint();\n const inputContainerRef = useRef<HTMLDivElement>(null);\n const inputIdState = useUuid(inputId);\n const [input, setInput] = useState(defaultValue || '');\n const [prevValue, setPrevValue] = useState<string | number | undefined>(undefined);\n const numKeyPressed = useRef<boolean>(false);\n const numRegex = /^[0-9]$/;\n\n useEffect(() => {\n setInput(defaultValue || '');\n }, [defaultValue]);\n\n const onDark = mode === FormMode.ondark;\n const onBlueberry = mode === FormMode.onblueberry;\n const maxCharactersExceeded = !!maxCharacters && input.toString().length > maxCharacters;\n const onError = mode === FormMode.oninvalid || !!errorText || !!error || maxCharactersExceeded;\n const bigForm = variant === FormVariant.bigform;\n const isTransparent = transparent && mode !== FormMode.ondark && !onError;\n\n const inputWrapperClass = cn(styles['input-wrapper'], className);\n\n const inputContainer = cn(styles['input-container'], {\n [styles['input-container--transparent']]: isTransparent,\n [styles['input-container--on-blueberry']]: onBlueberry,\n [styles['input-container--on-dark']]: onDark,\n [styles['input-container--invalid']]: onError,\n [styles['input-container--bigform']]: bigForm,\n [styles['input-container--disabled']]: disabled,\n [styles['input-container--with-icon']]: icon,\n });\n\n const inputClass = cn(styles['input-container__input'], {\n [styles['input-container__input--bigform']]: bigForm,\n [styles['input-container__input--disabled']]: disabled,\n });\n\n const iconColor = disabled ? getColor('neutral', 500) : getColor('black');\n const iconSize = breakpoint === Breakpoint.xs || !bigForm ? IconSize.XSmall : IconSize.Small;\n\n const renderIcon = (): React.ReactNode => {\n return icon !== undefined ? (\n <Icon className={styles['input-container__input__icon']} color={iconColor} size={iconSize} svgIcon={icon} />\n ) : null;\n };\n\n // eslint-disable-next-line\n const handleClick = (e: React.MouseEvent<any>): void => {\n if (inputContainerRef && inputContainerRef.current && icon) {\n const selectedChild = iconRight ? 0 : 1;\n const input = inputContainerRef.current.children[selectedChild] as HTMLInputElement;\n input.focus();\n\n props.onClick && props.onClick(e);\n }\n };\n\n const handleChange = (e: React.ChangeEvent<HTMLInputElement>): void => {\n const newValue = getIncrementValue(e);\n\n if (onChange) {\n onChange(e);\n }\n\n setInput(newValue);\n setPrevValue(newValue);\n };\n\n // Hvis bruker endrer number value med 1 og det skal startes på en annen verdi enn 0\n const getIncrementValue = (e: React.ChangeEvent<HTMLInputElement>): string => {\n if (typeof baseIncrementValue === 'undefined' || type !== 'number') return e.target.value;\n\n const valueAsNumber = Number(e.target.value);\n\n if (!prevValue && !numKeyPressed.current && (valueAsNumber === 1 || valueAsNumber === -1)) {\n e.target.value = baseIncrementValue + '';\n }\n\n return e.target.value;\n };\n\n const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>): void => {\n if (numRegex.test(e.key)) {\n numKeyPressed.current = true;\n }\n onKeyDown && onKeyDown(e);\n };\n\n const handleKeyUp = (e: React.KeyboardEvent<HTMLInputElement>): void => {\n if (numRegex.test(e.key)) {\n numKeyPressed.current = false;\n }\n };\n\n const maxWidth = width ? getInputMaxWidth(width, !!icon, iconSize) : undefined;\n\n return (\n <ErrorWrapper errorText={errorText}>\n <div data-testid={testId} data-analyticsid={AnalyticsId.Input} className={inputWrapperClass} ref={inputWrapperRef}>\n {renderLabel(label, inputIdState, mode as FormMode, disabled)}\n {/* input-elementet tillater keyboard-interaksjon */}\n <div className={styles['content-wrapper']}>\n {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */}\n <div onClick={handleClick} ref={inputContainerRef} className={inputContainer} style={{ maxWidth }}>\n {!iconRight && renderIcon()}\n <input\n onChange={handleChange}\n onKeyDown={handleKeyDown}\n onKeyUp={handleKeyUp}\n name={name}\n type={type}\n defaultValue={defaultValue}\n id={inputIdState}\n className={inputClass}\n ref={ref}\n aria-labelledby={props['aria-labelledby'] ?? undefined}\n aria-describedby={props['aria-describedby'] ?? undefined}\n aria-invalid={!!onError}\n disabled={disabled}\n placeholder={placeholder}\n readOnly={readOnly}\n autoComplete={autoComplete || 'off'}\n required={required}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={autoFocus}\n {...rest}\n />\n {iconRight && renderIcon()}\n </div>\n <div className={styles['content-wrapper__right-of-input']}>{rightOfInput}</div>\n </div>\n {maxCharacters && (\n <MaxCharacters maxCharacters={maxCharacters} length={input.toString().length} maxText={maxText} mode={mode} maxWidth={maxWidth} />\n )}\n {afterInputChildren}\n </div>\n </ErrorWrapper>\n );\n});\n\nInput.displayName = 'Input';\n\nexport default Input;\n"],"names":["InputTypes","getInputMaxWidth","characters","hasIcon","iconSize","paddingWidth","iconWidth","borderWidth","AVERAGE_CHARACTER_WIDTH_PX","Input","React","props","ref","className","defaultValue","placeholder","type","name","transparent","icon","iconRight","inputId","inputWrapperRef","mode","FormMode","baseIncrementValue","variant","label","error","errorText","testId","disabled","readOnly","autoComplete","afterInputChildren","rightOfInput","width","required","onChange","onKeyDown","autoFocus","maxCharacters","maxText","rest","breakpoint","useBreakpoint","inputContainerRef","useRef","inputIdState","useUuid","input","setInput","useState","prevValue","setPrevValue","numKeyPressed","numRegex","useEffect","onDark","onBlueberry","maxCharactersExceeded","onError","bigForm","FormVariant","isTransparent","inputWrapperClass","cn","styles","inputContainer","inputClass","iconColor","getColor","Breakpoint","IconSize","renderIcon","Icon","handleClick","e","selectedChild","handleChange","newValue","getIncrementValue","valueAsNumber","handleKeyDown","handleKeyUp","maxWidth","ErrorWrapper","AnalyticsId","renderLabel","MaxCharacters","Input$1"],"mappings":"0lBA6EY,IAAAA,IAAAA,IACVA,EAAA,KAAO,OACPA,EAAA,OAAS,SACTA,EAAA,MAAQ,QACRA,EAAA,SAAW,WACXA,EAAA,OAAS,SACTA,EAAA,IAAM,MACNA,EAAA,IAAM,MACNA,EAAA,KAAO,OACPA,EAAA,KAAO,OATGA,IAAAA,IAAA,CAAA,CAAA,EAYZ,MAAMC,GAAmB,CAACC,EAAoBC,EAAkBC,IAA6B,CACrF,MAAAC,EAAeF,EAAU,SAAW,OACpCG,EAAYH,EAAU,GAAGC,CAAQ,KAAO,MACxCG,EAAc,MAEb,MAAA,QAAQL,EAAaM,EAA0B,QAAQH,CAAY,MAAMC,CAAS,MAAMC,CAAW,GAC5G,EAEME,EAAQC,EAAM,WAAW,CAACC,EAAmBC,IAAqC,CAChF,KAAA,CACJ,UAAAC,EACA,aAAAC,EACA,YAAAC,EACA,KAAAC,EAAO,OACP,KAAAC,EACA,YAAAC,EAAc,GACd,KAAAC,EACA,UAAAC,EACA,QAAAC,EACA,gBAAAC,EACA,KAAAC,EAAOC,EAAS,QAChB,mBAAAC,EACA,QAAAC,EACA,MAAAC,EACA,MAAAC,EACA,UAAAC,EACA,OAAAC,EACA,SAAAC,EACA,SAAAC,EACA,aAAAC,EACA,mBAAAC,EACA,aAAAC,EACA,MAAAC,EACA,SAAAC,EACA,SAAAC,EACA,UAAAC,EACA,UAAAC,EACA,cAAAC,EACA,QAAAC,EACA,GAAGC,CACD,EAAAhC,EACEiC,GAAaC,KACbC,EAAoBC,EAA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AAA,cAAA,MAAA,CAAI,QAASkE,GAAa,IAAK9B,EAAmB,UAAWsB,GAAgB,MAAO,CAAE,SAAAiB,IACpF,CAACjE,GAAasD,EACf,EAAAhE,EAAA,cAAC,QAAA,CACC,SAAUqE,GACV,UAAWI,GACX,QAASC,GACT,KAAAnE,EACA,KAAAD,EACA,aAAAF,EACA,GAAIkC,EACJ,UAAWqB,GACX,IAAAzD,EACA,kBAAiBD,EAAM,iBAAiB,GAAK,OAC7C,mBAAkBA,EAAM,kBAAkB,GAAK,OAC/C,eAAc,CAAC,CAACkD,EAChB,SAAA9B,EACA,YAAAhB,EACA,SAAAiB,EACA,aAAcC,GAAgB,MAC9B,SAAAI,EAEA,UAAAG,EACC,GAAGG,CAAA,CAEL,EAAAvB,GAAasD,EAAW,CAC3B,EACAhE,EAAA,cAAC,MAAI,CAAA,UAAWyD,EAAO,iCAAiC,CAAI,EAAAhC,CAAa,CAC3E,EACCM,GACC/B,EAAA,cAAC+E,GAAc,CAAA,cAAAhD,EAA8B,OAAQS,EAAM,SAAS,EAAE,OAAQ,QAAAR,EAAkB,KAAAnB,EAAY,SAAA8D,CAAoB,CAAA,EAEjInD,CACH,CACF,CAEJ,CAAC,EAEDzB,EAAM,YAAc,QAEpB,MAAAiF,GAAejF"}
|
package/Textarea.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import o,{useState as A,useRef as Y,useEffect as M}from"react";import h from"classnames";import{FormMode as m,AnalyticsId as Z,AVERAGE_CHARACTER_WIDTH_PX as ee}from"./constants.js";import{u as te}from"./uuid.js";import{E as ae}from"./ErrorWrapper.js";import{a as re}from"./Label.js";import{M as ne}from"./MaxCharacters.js";import t from"./components/Textarea/styles.module.scss";const oe=r=>{const u="2rem",n="16px",p="4px";return`calc(${r*ee}px + ${u} + ${n} + ${p})`},N=o.forwardRef((r,u)=>{const{maxCharacters:n,maxText:p,width:f,testId:$,defaultValue:i
|
|
1
|
+
import o,{useState as A,useRef as Y,useEffect as M}from"react";import h from"classnames";import{FormMode as m,AnalyticsId as Z,AVERAGE_CHARACTER_WIDTH_PX as ee}from"./constants.js";import{u as te}from"./uuid.js";import{E as ae}from"./ErrorWrapper.js";import{a as re}from"./Label.js";import{M as ne}from"./MaxCharacters.js";import t from"./components/Textarea/styles.module.scss";const oe=r=>{const u="2rem",n="16px",p="4px";return`calc(${r*ee}px + ${u} + ${n} + ${p})`},N=o.forwardRef((r,u)=>{const{maxCharacters:n,maxText:p,width:f,testId:$,defaultValue:i,marginBottom:B,transparent:k,mode:s=m.onwhite,label:L,textareaId:b=te(),minRows:g=3,maxRows:c=10,grow:w,errorText:C,autoFocus:S,disabled:E,name:D,autoComplete:T,placeholder:F,readOnly:V,required:q,onChange:y,...z}=r,[G,R]=A(g),[v,W]=A(i||""),l=Y(null);M(()=>{W(i||"")},[i]);const _=e=>{const d=e.rows;e.rows=g;const a=Math.floor((e.scrollHeight-16)/28);a===d&&(e.rows=a),a>=c&&(e.rows=c,e.scrollTop=e.scrollHeight),a<c?R(a):R(c)},O=s===m.ondark,P=s===m.onblueberry,X=!!n&&v.toString().length>n,H=s===m.oninvalid||!!C||X,j=h(t.textarea,{[t["textarea--gutterBottom"]]:B}),J=h(t["input-container"],{[t["input-container--transparent"]]:k,[t["input-container--on-blueberry"]]:P,[t["input-container--on-dark"]]:O,[t["input-container--invalid"]]:H,[t["input-container--disabled"]]:r.disabled}),K=h(t["input-container__input"],{[t["input-container__input--disabled"]]:r.disabled});M(()=>{var e,x,d;if(w&&((e=l.current)!=null&&e.children)&&((x=l.current)!=null&&x.children[0])){const a=(d=l.current)==null?void 0:d.children[0];_(a)}},[]);const Q=e=>{w&&_(e.target),W(e.target.value)},U=e=>{y&&y(e),Q(e)},I=f?oe(f):void 0;return o.createElement(ae,{errorText:C},o.createElement("div",{"data-testid":$,"data-analyticsid":Z.Textarea,className:j},re(L,b,s,E),o.createElement("div",{className:J,ref:l,style:{maxWidth:I}},o.createElement("textarea",{rows:G,defaultValue:i,id:b,className:K,ref:u,"aria-describedby":r["aria-describedby"]??void 0,"aria-invalid":!!H,autoFocus:S,disabled:E,name:D,autoComplete:T||void 0,placeholder:F,readOnly:V,required:q,onChange:U,...z})),n&&o.createElement(ne,{maxCharacters:n,length:v.toString().length,maxText:p,mode:s,maxWidth:I})))});N.displayName="Textarea";const xe=N;export{xe as T};
|
|
2
2
|
//# sourceMappingURL=Textarea.js.map
|
package/Textarea.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Textarea.js","sources":["../src/components/Textarea/Textarea.tsx"],"sourcesContent":["import React, { useState, useRef, useEffect } from 'react';\n\nimport cn from 'classnames';\n\nimport { AnalyticsId, AVERAGE_CHARACTER_WIDTH_PX, FormMode } from '../../constants';\nimport { uuid } from '../../utils/uuid';\nimport ErrorWrapper from '../ErrorWrapper';\nimport { renderLabel } from '../Label';\nimport MaxCharacters from '../MaxCharacters/MaxCharacters';\n\nimport styles from './styles.module.scss';\n\ninterface TextareaProps\n extends Pick<\n React.InputHTMLAttributes<HTMLTextAreaElement>,\n | 'aria-describedby'\n | 'autoFocus'\n | 'disabled'\n | 'name'\n | 'autoComplete'\n | 'placeholder'\n | 'readOnly'\n | 'required'\n | 'defaultValue'\n | 'onChange'\n > {\n /** max character limit in textarea */\n maxCharacters?: number;\n /** The text is displayed in the end of the text-counter */\n maxText?: string;\n /** Width of textarea in characters (approximate) */\n width?: number;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** If true, the component will have a bottom margin. */\n marginBottom?: boolean;\n /** If true, the component will be transparent. */\n transparent?: boolean;\n /** Changes the visuals of the textarea */\n mode?: keyof typeof FormMode;\n /** Label of the input */\n label?: React.ReactNode;\n /** id of the textarea */\n textareaId?: string;\n /** max rows */\n maxRows?: number;\n /** min rows */\n minRows?: number;\n /** auto-grows until maxRows */\n grow?: boolean;\n /** Error text to show above the component */\n errorText?: string;\n}\n\nconst getTextareaMaxWidth = (characters: number): string => {\n const paddingWidth = '2rem';\n const scrollbarWidth = '16px';\n const borderWidth = '4px';\n\n return `calc(${characters * AVERAGE_CHARACTER_WIDTH_PX}px + ${paddingWidth} + ${scrollbarWidth} + ${borderWidth})`;\n};\n\nconst Textarea = React.forwardRef((props: TextareaProps, ref: React.Ref<HTMLTextAreaElement>) => {\n const {\n maxCharacters,\n maxText,\n width,\n testId,\n defaultValue
|
|
1
|
+
{"version":3,"file":"Textarea.js","sources":["../src/components/Textarea/Textarea.tsx"],"sourcesContent":["import React, { useState, useRef, useEffect } from 'react';\n\nimport cn from 'classnames';\n\nimport { AnalyticsId, AVERAGE_CHARACTER_WIDTH_PX, FormMode } from '../../constants';\nimport { uuid } from '../../utils/uuid';\nimport ErrorWrapper from '../ErrorWrapper';\nimport { renderLabel } from '../Label';\nimport MaxCharacters from '../MaxCharacters/MaxCharacters';\n\nimport styles from './styles.module.scss';\n\ninterface TextareaProps\n extends Pick<\n React.InputHTMLAttributes<HTMLTextAreaElement>,\n | 'aria-describedby'\n | 'autoFocus'\n | 'disabled'\n | 'name'\n | 'autoComplete'\n | 'placeholder'\n | 'readOnly'\n | 'required'\n | 'defaultValue'\n | 'onChange'\n > {\n /** max character limit in textarea */\n maxCharacters?: number;\n /** The text is displayed in the end of the text-counter */\n maxText?: string;\n /** Width of textarea in characters (approximate) */\n width?: number;\n /** Sets the data-testid attribute. */\n testId?: string;\n /** If true, the component will have a bottom margin. */\n marginBottom?: boolean;\n /** If true, the component will be transparent. */\n transparent?: boolean;\n /** Changes the visuals of the textarea */\n mode?: keyof typeof FormMode;\n /** Label of the input */\n label?: React.ReactNode;\n /** id of the textarea */\n textareaId?: string;\n /** max rows */\n maxRows?: number;\n /** min rows */\n minRows?: number;\n /** auto-grows until maxRows */\n grow?: boolean;\n /** Error text to show above the component */\n errorText?: string;\n}\n\nconst getTextareaMaxWidth = (characters: number): string => {\n const paddingWidth = '2rem';\n const scrollbarWidth = '16px';\n const borderWidth = '4px';\n\n return `calc(${characters * AVERAGE_CHARACTER_WIDTH_PX}px + ${paddingWidth} + ${scrollbarWidth} + ${borderWidth})`;\n};\n\nconst Textarea = React.forwardRef((props: TextareaProps, ref: React.Ref<HTMLTextAreaElement>) => {\n const {\n maxCharacters,\n maxText,\n width,\n testId,\n defaultValue,\n marginBottom: gutterBottom,\n transparent,\n mode = FormMode.onwhite,\n label,\n textareaId = uuid(),\n minRows = 3,\n maxRows = 10,\n grow,\n errorText,\n autoFocus,\n disabled,\n name,\n autoComplete,\n placeholder,\n readOnly,\n required,\n onChange,\n ...rest\n } = props;\n\n const [rows, setRows] = useState(minRows);\n const [textareaInput, setTextareaInput] = useState(defaultValue || '');\n const referanse = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n setTextareaInput(defaultValue || '');\n }, [defaultValue]);\n\n const resizeHeight = (target: HTMLTextAreaElement): void => {\n const textareaLineHeight = 28;\n\n const previousRows = target.rows;\n target.rows = minRows; // reset number of rows in textarea\n\n const currentRows = Math.floor((target.scrollHeight - 16) / textareaLineHeight); // scrollHeight - 16px of padding to calculate the rows\n\n if (currentRows === previousRows) {\n target.rows = currentRows;\n }\n\n if (currentRows >= maxRows) {\n target.rows = maxRows;\n target.scrollTop = target.scrollHeight;\n }\n\n if (currentRows < maxRows) {\n setRows(currentRows);\n } else {\n setRows(maxRows);\n }\n };\n\n const onDark = mode === FormMode.ondark;\n const onBlueberry = mode === FormMode.onblueberry;\n const maxCharactersExceeded = !!maxCharacters && textareaInput.toString().length > maxCharacters;\n const onError = mode === FormMode.oninvalid || !!errorText || maxCharactersExceeded;\n\n const textareaWrapperClass = cn(styles.textarea, {\n [styles['textarea--gutterBottom']]: gutterBottom,\n });\n\n const contentWrapperClass = cn(styles['input-container'], {\n [styles['input-container--transparent']]: transparent,\n [styles['input-container--on-blueberry']]: onBlueberry,\n [styles['input-container--on-dark']]: onDark,\n [styles['input-container--invalid']]: onError,\n [styles['input-container--disabled']]: props.disabled,\n });\n\n const textareaClass = cn(styles['input-container__input'], {\n [styles[`input-container__input--disabled`]]: props.disabled,\n });\n\n useEffect(() => {\n if (grow && referanse.current?.children && referanse.current?.children[0]) {\n const textarea = referanse.current?.children[0] as HTMLTextAreaElement;\n resizeHeight(textarea);\n }\n }, []);\n\n const handleChange = (e: React.ChangeEvent<HTMLTextAreaElement>): void => {\n if (grow) {\n resizeHeight(e.target);\n }\n setTextareaInput(e.target.value);\n };\n\n const onChangeHandler = (e: React.ChangeEvent<HTMLTextAreaElement>): void => {\n if (onChange) {\n onChange(e);\n }\n handleChange(e);\n };\n\n const maxWidth = width ? getTextareaMaxWidth(width) : undefined;\n\n return (\n <ErrorWrapper errorText={errorText}>\n <div data-testid={testId} data-analyticsid={AnalyticsId.Textarea} className={textareaWrapperClass}>\n {renderLabel(label, textareaId, mode as FormMode, disabled)}\n <div className={contentWrapperClass} ref={referanse} style={{ maxWidth }}>\n <textarea\n rows={rows}\n defaultValue={defaultValue}\n id={textareaId}\n className={textareaClass}\n ref={ref}\n aria-describedby={props['aria-describedby'] ?? undefined}\n aria-invalid={!!onError}\n // eslint-disable-next-line jsx-a11y/no-autofocus\n autoFocus={autoFocus}\n disabled={disabled}\n name={name}\n autoComplete={autoComplete ? autoComplete : undefined}\n placeholder={placeholder}\n readOnly={readOnly}\n required={required}\n onChange={onChangeHandler}\n {...rest}\n />\n </div>\n {maxCharacters && (\n <MaxCharacters\n maxCharacters={maxCharacters}\n length={textareaInput.toString().length}\n maxText={maxText}\n mode={mode}\n maxWidth={maxWidth}\n />\n )}\n </div>\n </ErrorWrapper>\n );\n});\n\nTextarea.displayName = 'Textarea';\n\nexport default Textarea;\n"],"names":["getTextareaMaxWidth","characters","paddingWidth","scrollbarWidth","borderWidth","AVERAGE_CHARACTER_WIDTH_PX","Textarea","React","props","ref","maxCharacters","maxText","width","testId","defaultValue","gutterBottom","transparent","mode","FormMode","label","textareaId","uuid","minRows","maxRows","grow","errorText","autoFocus","disabled","name","autoComplete","placeholder","readOnly","required","onChange","rest","rows","setRows","useState","textareaInput","setTextareaInput","referanse","useRef","useEffect","resizeHeight","target","previousRows","currentRows","onDark","onBlueberry","maxCharactersExceeded","onError","textareaWrapperClass","cn","styles","contentWrapperClass","textareaClass","_a","_b","textarea","_c","handleChange","onChangeHandler","maxWidth","ErrorWrapper","AnalyticsId","renderLabel","MaxCharacters","Textarea$1"],"mappings":"2XAsDA,MAAMA,GAAuBC,GAA+B,CAC1D,MAAMC,EAAe,OACfC,EAAiB,OACjBC,EAAc,MAEb,MAAA,QAAQH,EAAaI,EAA0B,QAAQH,CAAY,MAAMC,CAAc,MAAMC,CAAW,GACjH,EAEME,EAAWC,EAAM,WAAW,CAACC,EAAsBC,IAAwC,CACzF,KAAA,CACJ,cAAAC,EACA,QAAAC,EACA,MAAAC,EACA,OAAAC,EACA,aAAAC,EACA,aAAcC,EACd,YAAAC,EACA,KAAAC,EAAOC,EAAS,QAChB,MAAAC,EACA,WAAAC,EAAaC,GAAK,EAClB,QAAAC,EAAU,EACV,QAAAC,EAAU,GACV,KAAAC,EACA,UAAAC,EACA,UAAAC,EACA,SAAAC,EACA,KAAAC,EACA,aAAAC,EACA,YAAAC,EACA,SAAAC,EACA,SAAAC,EACA,SAAAC,EACA,GAAGC,CACD,EAAA1B,EAEE,CAAC2B,EAAMC,CAAO,EAAIC,EAASf,CAAO,EAClC,CAACgB,EAAeC,CAAgB,EAAIF,EAASvB,GAAgB,EAAE,EAC/D0B,EAAYC,EAAuB,IAAI,EAE7CC,EAAU,IAAM,CACdH,EAAiBzB,GAAgB,EAAE,CAAA,EAClC,CAACA,CAAY,CAAC,EAEX,MAAA6B,EAAgBC,GAAsC,CAG1D,MAAMC,EAAeD,EAAO,KAC5BA,EAAO,KAAOtB,EAEd,MAAMwB,EAAc,KAAK,OAAOF,EAAO,aAAe,IAAM,EAAkB,EAE1EE,IAAgBD,IAClBD,EAAO,KAAOE,GAGZA,GAAevB,IACjBqB,EAAO,KAAOrB,EACdqB,EAAO,UAAYA,EAAO,cAGxBE,EAAcvB,EAChBa,EAAQU,CAAW,EAEnBV,EA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AAY,SAAU,UAAWb,GAC1Ec,GAAY9C,EAAOC,EAAYH,EAAkBU,CAAQ,EAC1DpB,EAAA,cAAC,MAAI,CAAA,UAAW+C,EAAqB,IAAKd,EAAW,MAAO,CAAE,SAAAsB,CAC5D,CAAA,EAAAvD,EAAA,cAAC,WAAA,CACC,KAAA4B,EACA,aAAArB,EACA,GAAIM,EACJ,UAAWmC,EACX,IAAA9C,EACA,mBAAkBD,EAAM,kBAAkB,GAAK,OAC/C,eAAc,CAAC,CAAC0C,EAEhB,UAAAxB,EACA,SAAAC,EACA,KAAAC,EACA,aAAcC,GAA8B,OAC5C,YAAAC,EACA,SAAAC,EACA,SAAAC,EACA,SAAU6B,EACT,GAAG3B,CAAA,CAAA,CAER,EACCxB,GACCH,EAAA,cAAC2D,GAAA,CACC,cAAAxD,EACA,OAAQ4B,EAAc,SAAA,EAAW,OACjC,QAAA3B,EACA,KAAAM,EACA,SAAA6C,CAAA,CAGN,CAAA,CACF,CAEJ,CAAC,EAEDxD,EAAS,YAAc,WAEvB,MAAA6D,GAAe7D"}
|
|
@@ -28,6 +28,8 @@ export interface ButtonProps extends HTMLButtonProps, HTMLAnchorProps, AriaAttri
|
|
|
28
28
|
htmlMarkup?: ButtonTags;
|
|
29
29
|
/** Changes the button colors for different backgrounds. */
|
|
30
30
|
mode?: ButtonMode;
|
|
31
|
+
/** Function that is called when the Button loses focus */
|
|
32
|
+
onBlur?: () => void;
|
|
31
33
|
/** Function that is called when clicked */
|
|
32
34
|
onClick?: (e?: React.MouseEvent<HTMLElement, MouseEvent> | React.FormEvent<{}> | React.KeyboardEvent<HTMLUListElement> | null) => void;
|
|
33
35
|
/** Changes the button colors for different backgrounds. (Large not available in borderless variant) */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/components/Button/Button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,cAAc,EAAqB,MAAM,OAAO,CAAC;AAKj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AC,EAAE,aAAa,CAAC;IACxB,mDAAmD;IACnD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kEAAkE;IAClE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,oDAAoD;IACpD,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,2DAA2D;IAC3D,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,0DAA0D;IAC1D,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,2CAA2C;IAC3C,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,EAAE,UAAU,CAAC,GAAG,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,aAAa,CAAC,gBAAgB,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC;IACvI,uGAAuG;IACvG,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,uDAAuD;IACvD,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,uFAAuF;IACvF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,mCAAmC;IACnC,IAAI,CAAC,EAAE,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;CAC9D;AAkCD,QAAA,MAAM,MAAM,2GAqKV,CAAC;AAEH,eAAe,MAAM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"props":{"ariaLabel":{"defaultValue":null,"description":"Sets the aria-label of the button, use when the button only includes an icon","name":"ariaLabel","parent":{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"},"declarations":[{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"}],"required":false,"type":{"name":"string"}},"id":{"defaultValue":null,"description":"Gives a unique id to the button","name":"id","parent":{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"},"declarations":[{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"}],"required":false,"type":{"name":"string"}},"children":{"defaultValue":null,"description":"Sets the content of the button.","name":"children","parent":{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"},"declarations":[{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"}],"required":true,"type":{"name":"ReactNode"}},"wrapperClassName":{"defaultValue":null,"description":"Adds custom classes to the wrapper element.","name":"wrapperClassName","parent":{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"},"declarations":[{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"}],"required":false,"type":{"name":"string"}},"className":{"defaultValue":null,"description":"Adds custom classes to the element.","name":"className","parent":{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"},"declarations":[{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"}],"required":false,"type":{"name":"string"}},"arrow":{"defaultValue":null,"description":"Enables an arrow icon to the right inside the button (Not available in borderless variant)","name":"arrow","parent":{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"},"declarations":[{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"}],"required":false,"type":{"name":"boolean"}},"concept":{"defaultValue":null,"description":"Changes the intent of the button. Mostly changes the color profile.","name":"concept","parent":{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"},"declarations":[{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"}],"required":false,"type":{"name":"enum","raw":"ButtonConcept","value":[{"value":"\"normal\""},{"value":"\"destructive\""}]}},"ellipsis":{"defaultValue":null,"description":"Disables text wrapping and enables ellipsis.","name":"ellipsis","parent":{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"},"declarations":[{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"}],"required":false,"type":{"name":"boolean"}},"fluid":{"defaultValue":null,"description":"Makes the button scale to full width of its parent element.","name":"fluid","parent":{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"},"declarations":[{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"}],"required":false,"type":{"name":"boolean"}},"htmlMarkup":{"defaultValue":null,"description":"Changes the underlying element of the button.","name":"htmlMarkup","parent":{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"},"declarations":[{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"}],"required":false,"type":{"name":"enum","raw":"ButtonTags","value":[{"value":"\"button\""},{"value":"\"a\""}]}},"mode":{"defaultValue":null,"description":"Changes the button colors for different backgrounds.","name":"mode","parent":{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"},"declarations":[{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"}],"required":false,"type":{"name":"enum","raw":"ButtonMode","value":[{"value":"\"onlight\""},{"value":"\"ondark\""}]}},"onClick":{"defaultValue":null,"description":"Function that is called when clicked","name":"onClick","parent":{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"},"declarations":[{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"}],"required":false,"type":{"name":"((e?: MouseEvent<HTMLElement, MouseEvent> | FormEvent<{}> | KeyboardEvent<HTMLUListElement> | null) => void)"}},"size":{"defaultValue":null,"description":"Changes the button colors for different backgrounds. (Large not available in borderless variant)","name":"size","parent":{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"},"declarations":[{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"}],"required":false,"type":{"name":"enum","raw":"ButtonSize","value":[{"value":"\"medium\""},{"value":"\"large\""}]}},"variant":{"defaultValue":null,"description":"Changes the visual representation of the button.","name":"variant","parent":{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"},"declarations":[{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"}],"required":false,"type":{"name":"enum","raw":"ButtonVariant","value":[{"value":"\"fill\""},{"value":"\"outline\""},{"value":"\"borderless\""}]}},"tabIndex":{"defaultValue":null,"description":"Specifies the focus order relative to the other buttons or controls on the page","name":"tabIndex","parent":{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"},"declarations":[{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"}],"required":false,"type":{"name":"number"}},"testId":{"defaultValue":null,"description":"Sets the data-testid attribute.","name":"testId","parent":{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"},"declarations":[{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"}],"required":false,"type":{"name":"string"}},"type":{"defaultValue":null,"description":"Button type. Default: button","name":"type","parent":{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"},"declarations":[{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"}],"required":false,"type":{"name":"enum","raw":"\"button\" | \"submit\" | \"reset\"","value":[{"value":"\"button\""},{"value":"\"submit\""},{"value":"\"reset\""}]}},"autoFocus":{"defaultValue":null,"description":"","name":"autoFocus","parent":{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"},"declarations":[{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"}],"required":false,"type":{"name":"boolean"}},"disabled":{"defaultValue":null,"description":"","name":"disabled","parent":{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"},"declarations":[{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"}],"required":false,"type":{"name":"boolean"}},"form":{"defaultValue":null,"description":"","name":"form","parent":{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"},"declarations":[{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"}],"required":false,"type":{"name":"string"}},"formAction":{"defaultValue":null,"description":"","name":"formAction","parent":{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"},"declarations":[{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"}],"required":false,"type":{"name":"string"}},"formEncType":{"defaultValue":null,"description":"","name":"formEncType","parent":{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"},"declarations":[{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"}],"required":false,"type":{"name":"string"}},"formMethod":{"defaultValue":null,"description":"","name":"formMethod","parent":{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"},"declarations":[{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"}],"required":false,"type":{"name":"string"}},"formNoValidate":{"defaultValue":null,"description":"","name":"formNoValidate","parent":{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"},"declarations":[{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"}],"required":false,"type":{"name":"boolean"}},"formTarget":{"defaultValue":null,"description":"","name":"formTarget","parent":{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"},"declarations":[{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"}],"required":false,"type":{"name":"string"}},"name":{"defaultValue":null,"description":"","name":"name","parent":{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"},"declarations":[{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"}],"required":false,"type":{"name":"string"}},"value":{"defaultValue":null,"description":"","name":"value","parent":{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"},"declarations":[{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"}],"required":false,"type":{"name":"string | number | string[]"}},"download":{"defaultValue":null,"description":"","name":"download","parent":{"fileName":"designsystem/src/constants.ts","name":"HTMLAnchorProps"},"declarations":[{"fileName":"designsystem/src/constants.ts","name":"HTMLAnchorProps"}],"required":false,"type":{"name":"string"}},"href":{"defaultValue":null,"description":"","name":"href","parent":{"fileName":"designsystem/src/constants.ts","name":"HTMLAnchorProps"},"declarations":[{"fileName":"designsystem/src/constants.ts","name":"HTMLAnchorProps"}],"required":false,"type":{"name":"string"}},"hrefLang":{"defaultValue":null,"description":"","name":"hrefLang","parent":{"fileName":"designsystem/src/constants.ts","name":"HTMLAnchorProps"},"declarations":[{"fileName":"designsystem/src/constants.ts","name":"HTMLAnchorProps"}],"required":false,"type":{"name":"string"}},"media":{"defaultValue":null,"description":"","name":"media","parent":{"fileName":"designsystem/src/constants.ts","name":"HTMLAnchorProps"},"declarations":[{"fileName":"designsystem/src/constants.ts","name":"HTMLAnchorProps"}],"required":false,"type":{"name":"string"}},"ping":{"defaultValue":null,"description":"","name":"ping","parent":{"fileName":"designsystem/src/constants.ts","name":"HTMLAnchorProps"},"declarations":[{"fileName":"designsystem/src/constants.ts","name":"HTMLAnchorProps"}],"required":false,"type":{"name":"string"}},"rel":{"defaultValue":null,"description":"","name":"rel","parent":{"fileName":"designsystem/src/constants.ts","name":"HTMLAnchorProps"},"declarations":[{"fileName":"designsystem/src/constants.ts","name":"HTMLAnchorProps"}],"required":false,"type":{"name":"enum","raw":"AnchorTarget","value":[{"value":"\"_self\""},{"value":"\"_blank\""},{"value":"\"_parent\""},{"value":"\"_top\""}]}},"target":{"defaultValue":null,"description":"","name":"target","parent":{"fileName":"designsystem/src/constants.ts","name":"HTMLAnchorProps"},"declarations":[{"fileName":"designsystem/src/constants.ts","name":"HTMLAnchorProps"}],"required":false,"type":{"name":"string"}},"referrerPolicy":{"defaultValue":null,"description":"","name":"referrerPolicy","parent":{"fileName":"designsystem/src/constants.ts","name":"HTMLAnchorProps"},"declarations":[{"fileName":"designsystem/src/constants.ts","name":"HTMLAnchorProps"}],"required":false,"type":{"name":"enum","raw":"\"\" | \"same-origin\" | \"no-referrer\" | \"no-referrer-when-downgrade\" | \"origin\" | \"origin-when-cross-origin\" | \"strict-origin\" | \"strict-origin-when-cross-origin\" | \"unsafe-url\"","value":[{"value":"\"\""},{"value":"\"same-origin\""},{"value":"\"no-referrer\""},{"value":"\"no-referrer-when-downgrade\""},{"value":"\"origin\""},{"value":"\"origin-when-cross-origin\""},{"value":"\"strict-origin\""},{"value":"\"strict-origin-when-cross-origin\""},{"value":"\"unsafe-url\""}]}},"aria-activedescendant":{"defaultValue":null,"description":"Identifies the currently active element when DOM focus is on a composite widget, textbox, group, or application.","name":"aria-activedescendant","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"string"}},"aria-atomic":{"defaultValue":null,"description":"Indicates whether assistive technologies will present all, or only parts of, the changed region based on the change notifications defined by the aria-relevant attribute.","name":"aria-atomic","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"Booleanish"}},"aria-autocomplete":{"defaultValue":null,"description":"Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be\npresented if they are made.","name":"aria-autocomplete","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"enum","raw":"\"none\" | \"inline\" | \"list\" | \"both\"","value":[{"value":"\"none\""},{"value":"\"inline\""},{"value":"\"list\""},{"value":"\"both\""}]}},"aria-busy":{"defaultValue":null,"description":"Indicates an element is being modified and that assistive technologies MAY want to wait until the modifications are complete before exposing them to the user.","name":"aria-busy","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"Booleanish"}},"aria-checked":{"defaultValue":null,"description":"Indicates the current \"checked\" state of checkboxes, radio buttons, and other widgets.\n@see aria-pressed\n@see aria-selected.","name":"aria-checked","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"boolean | \"true\" | \"false\" | \"mixed\""}},"aria-colcount":{"defaultValue":null,"description":"Defines the total number of columns in a table, grid, or treegrid.\n@see aria-colindex.","name":"aria-colcount","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"number"}},"aria-colindex":{"defaultValue":null,"description":"Defines an element's column index or position with respect to the total number of columns within a table, grid, or treegrid.\n@see aria-colcount\n@see aria-colspan.","name":"aria-colindex","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"number"}},"aria-colspan":{"defaultValue":null,"description":"Defines the number of columns spanned by a cell or gridcell within a table, grid, or treegrid.\n@see aria-colindex\n@see aria-rowspan.","name":"aria-colspan","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"number"}},"aria-controls":{"defaultValue":null,"description":"Identifies the element (or elements) whose contents or presence are controlled by the current element.\n@see aria-owns.","name":"aria-controls","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"string"}},"aria-current":{"defaultValue":null,"description":"Indicates the element that represents the current item within a container or set of related elements.","name":"aria-current","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"boolean | \"true\" | \"false\" | \"page\" | \"step\" | \"location\" | \"date\" | \"time\""}},"aria-describedby":{"defaultValue":null,"description":"Identifies the element (or elements) that describes the object.\n@see aria-labelledby","name":"aria-describedby","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"string"}},"aria-details":{"defaultValue":null,"description":"Identifies the element that provides a detailed, extended description for the object.\n@see aria-describedby.","name":"aria-details","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"string"}},"aria-disabled":{"defaultValue":null,"description":"Indicates that the element is perceivable but disabled, so it is not editable or otherwise operable.\n@see aria-hidden\n@see aria-readonly.","name":"aria-disabled","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"Booleanish"}},"aria-dropeffect":{"defaultValue":null,"description":"Indicates what functions can be performed when a dragged object is released on the drop target.\n@deprecated in ARIA 1.1","name":"aria-dropeffect","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"enum","raw":"\"none\" | \"copy\" | \"execute\" | \"link\" | \"move\" | \"popup\"","value":[{"value":"\"none\""},{"value":"\"copy\""},{"value":"\"execute\""},{"value":"\"link\""},{"value":"\"move\""},{"value":"\"popup\""}]}},"aria-errormessage":{"defaultValue":null,"description":"Identifies the element that provides an error message for the object.\n@see aria-invalid\n@see aria-describedby.","name":"aria-errormessage","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"string"}},"aria-expanded":{"defaultValue":null,"description":"Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed.","name":"aria-expanded","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"Booleanish"}},"aria-flowto":{"defaultValue":null,"description":"Identifies the next element (or elements) in an alternate reading order of content which, at the user's discretion,\nallows assistive technology to override the general default of reading in document source order.","name":"aria-flowto","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"string"}},"aria-grabbed":{"defaultValue":null,"description":"Indicates an element's \"grabbed\" state in a drag-and-drop operation.\n@deprecated in ARIA 1.1","name":"aria-grabbed","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"Booleanish"}},"aria-haspopup":{"defaultValue":null,"description":"Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element.","name":"aria-haspopup","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"boolean | \"true\" | \"false\" | \"menu\" | \"listbox\" | \"tree\" | \"grid\" | \"dialog\""}},"aria-hidden":{"defaultValue":null,"description":"Indicates whether the element is exposed to an accessibility API.\n@see aria-disabled.","name":"aria-hidden","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"Booleanish"}},"aria-invalid":{"defaultValue":null,"description":"Indicates the entered value does not conform to the format expected by the application.\n@see aria-errormessage.","name":"aria-invalid","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"boolean | \"true\" | \"false\" | \"grammar\" | \"spelling\""}},"aria-keyshortcuts":{"defaultValue":null,"description":"Indicates keyboard shortcuts that an author has implemented to activate or give focus to an element.","name":"aria-keyshortcuts","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"string"}},"aria-label":{"defaultValue":null,"description":"Defines a string value that labels the current element.\n@see aria-labelledby.","name":"aria-label","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"string"}},"aria-labelledby":{"defaultValue":null,"description":"Identifies the element (or elements) that labels the current element.\n@see aria-describedby.","name":"aria-labelledby","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"string"}},"aria-level":{"defaultValue":null,"description":"Defines the hierarchical level of an element within a structure.","name":"aria-level","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"number"}},"aria-live":{"defaultValue":null,"description":"Indicates that an element will be updated, and describes the types of updates the user agents, assistive technologies, and user can expect from the live region.","name":"aria-live","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"enum","raw":"\"off\" | \"assertive\" | \"polite\"","value":[{"value":"\"off\""},{"value":"\"assertive\""},{"value":"\"polite\""}]}},"aria-modal":{"defaultValue":null,"description":"Indicates whether an element is modal when displayed.","name":"aria-modal","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"Booleanish"}},"aria-multiline":{"defaultValue":null,"description":"Indicates whether a text box accepts multiple lines of input or only a single line.","name":"aria-multiline","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"Booleanish"}},"aria-multiselectable":{"defaultValue":null,"description":"Indicates that the user may select more than one item from the current selectable descendants.","name":"aria-multiselectable","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"Booleanish"}},"aria-orientation":{"defaultValue":null,"description":"Indicates whether the element's orientation is horizontal, vertical, or unknown/ambiguous.","name":"aria-orientation","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"enum","raw":"\"horizontal\" | \"vertical\"","value":[{"value":"\"horizontal\""},{"value":"\"vertical\""}]}},"aria-owns":{"defaultValue":null,"description":"Identifies an element (or elements) in order to define a visual, functional, or contextual parent/child relationship\nbetween DOM elements where the DOM hierarchy cannot be used to represent the relationship.\n@see aria-controls.","name":"aria-owns","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"string"}},"aria-placeholder":{"defaultValue":null,"description":"Defines a short hint (a word or short phrase) intended to aid the user with data entry when the control has no value.\nA hint could be a sample value or a brief description of the expected format.","name":"aria-placeholder","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"string"}},"aria-posinset":{"defaultValue":null,"description":"Defines an element's number or position in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM.\n@see aria-setsize.","name":"aria-posinset","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"number"}},"aria-pressed":{"defaultValue":null,"description":"Indicates the current \"pressed\" state of toggle buttons.\n@see aria-checked\n@see aria-selected.","name":"aria-pressed","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"boolean | \"true\" | \"false\" | \"mixed\""}},"aria-readonly":{"defaultValue":null,"description":"Indicates that the element is not editable, but is otherwise operable.\n@see aria-disabled.","name":"aria-readonly","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"Booleanish"}},"aria-relevant":{"defaultValue":null,"description":"Indicates what notifications the user agent will trigger when the accessibility tree within a live region is modified.\n@see aria-atomic.","name":"aria-relevant","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"enum","raw":"\"additions\" | \"additions removals\" | \"additions text\" | \"all\" | \"removals\" | \"removals additions\" | \"removals text\" | \"text\" | \"text additions\" | \"text removals\"","value":[{"value":"\"additions\""},{"value":"\"additions removals\""},{"value":"\"additions text\""},{"value":"\"all\""},{"value":"\"removals\""},{"value":"\"removals additions\""},{"value":"\"removals text\""},{"value":"\"text\""},{"value":"\"text additions\""},{"value":"\"text removals\""}]}},"aria-required":{"defaultValue":null,"description":"Indicates that user input is required on the element before a form may be submitted.","name":"aria-required","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"Booleanish"}},"aria-roledescription":{"defaultValue":null,"description":"Defines a human-readable, author-localized description for the role of an element.","name":"aria-roledescription","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"string"}},"aria-rowcount":{"defaultValue":null,"description":"Defines the total number of rows in a table, grid, or treegrid.\n@see aria-rowindex.","name":"aria-rowcount","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"number"}},"aria-rowindex":{"defaultValue":null,"description":"Defines an element's row index or position with respect to the total number of rows within a table, grid, or treegrid.\n@see aria-rowcount\n@see aria-rowspan.","name":"aria-rowindex","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"number"}},"aria-rowspan":{"defaultValue":null,"description":"Defines the number of rows spanned by a cell or gridcell within a table, grid, or treegrid.\n@see aria-rowindex\n@see aria-colspan.","name":"aria-rowspan","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"number"}},"aria-selected":{"defaultValue":null,"description":"Indicates the current \"selected\" state of various widgets.\n@see aria-checked\n@see aria-pressed.","name":"aria-selected","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"Booleanish"}},"aria-setsize":{"defaultValue":null,"description":"Defines the number of items in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM.\n@see aria-posinset.","name":"aria-setsize","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"number"}},"aria-sort":{"defaultValue":null,"description":"Indicates if items in a table or grid are sorted in ascending or descending order.","name":"aria-sort","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"enum","raw":"\"none\" | \"ascending\" | \"descending\" | \"other\"","value":[{"value":"\"none\""},{"value":"\"ascending\""},{"value":"\"descending\""},{"value":"\"other\""}]}},"aria-valuemax":{"defaultValue":null,"description":"Defines the maximum allowed value for a range widget.","name":"aria-valuemax","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"number"}},"aria-valuemin":{"defaultValue":null,"description":"Defines the minimum allowed value for a range widget.","name":"aria-valuemin","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"number"}},"aria-valuenow":{"defaultValue":null,"description":"Defines the current value for a range widget.\n@see aria-valuetext.","name":"aria-valuenow","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"number"}},"aria-valuetext":{"defaultValue":null,"description":"Defines the human readable text alternative of aria-valuenow for a range widget.","name":"aria-valuetext","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"string"}}}}
|
|
1
|
+
{"props":{"ariaLabel":{"defaultValue":null,"description":"Sets the aria-label of the button, use when the button only includes an icon","name":"ariaLabel","parent":{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"},"declarations":[{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"}],"required":false,"type":{"name":"string"}},"id":{"defaultValue":null,"description":"Gives a unique id to the button","name":"id","parent":{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"},"declarations":[{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"}],"required":false,"type":{"name":"string"}},"children":{"defaultValue":null,"description":"Sets the content of the button.","name":"children","parent":{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"},"declarations":[{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"}],"required":true,"type":{"name":"ReactNode"}},"wrapperClassName":{"defaultValue":null,"description":"Adds custom classes to the wrapper element.","name":"wrapperClassName","parent":{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"},"declarations":[{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"}],"required":false,"type":{"name":"string"}},"className":{"defaultValue":null,"description":"Adds custom classes to the element.","name":"className","parent":{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"},"declarations":[{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"}],"required":false,"type":{"name":"string"}},"arrow":{"defaultValue":null,"description":"Enables an arrow icon to the right inside the button (Not available in borderless variant)","name":"arrow","parent":{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"},"declarations":[{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"}],"required":false,"type":{"name":"boolean"}},"concept":{"defaultValue":null,"description":"Changes the intent of the button. Mostly changes the color profile.","name":"concept","parent":{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"},"declarations":[{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"}],"required":false,"type":{"name":"enum","raw":"ButtonConcept","value":[{"value":"\"normal\""},{"value":"\"destructive\""}]}},"ellipsis":{"defaultValue":null,"description":"Disables text wrapping and enables ellipsis.","name":"ellipsis","parent":{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"},"declarations":[{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"}],"required":false,"type":{"name":"boolean"}},"fluid":{"defaultValue":null,"description":"Makes the button scale to full width of its parent element.","name":"fluid","parent":{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"},"declarations":[{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"}],"required":false,"type":{"name":"boolean"}},"htmlMarkup":{"defaultValue":null,"description":"Changes the underlying element of the button.","name":"htmlMarkup","parent":{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"},"declarations":[{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"}],"required":false,"type":{"name":"enum","raw":"ButtonTags","value":[{"value":"\"button\""},{"value":"\"a\""}]}},"mode":{"defaultValue":null,"description":"Changes the button colors for different backgrounds.","name":"mode","parent":{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"},"declarations":[{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"}],"required":false,"type":{"name":"enum","raw":"ButtonMode","value":[{"value":"\"onlight\""},{"value":"\"ondark\""}]}},"onBlur":{"defaultValue":null,"description":"Function that is called when the Button loses focus","name":"onBlur","parent":{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"},"declarations":[{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"}],"required":false,"type":{"name":"(() => void)"}},"onClick":{"defaultValue":null,"description":"Function that is called when clicked","name":"onClick","parent":{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"},"declarations":[{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"}],"required":false,"type":{"name":"((e?: MouseEvent<HTMLElement, MouseEvent> | FormEvent<{}> | KeyboardEvent<HTMLUListElement> | null) => void)"}},"size":{"defaultValue":null,"description":"Changes the button colors for different backgrounds. (Large not available in borderless variant)","name":"size","parent":{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"},"declarations":[{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"}],"required":false,"type":{"name":"enum","raw":"ButtonSize","value":[{"value":"\"medium\""},{"value":"\"large\""}]}},"variant":{"defaultValue":null,"description":"Changes the visual representation of the button.","name":"variant","parent":{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"},"declarations":[{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"}],"required":false,"type":{"name":"enum","raw":"ButtonVariant","value":[{"value":"\"fill\""},{"value":"\"outline\""},{"value":"\"borderless\""}]}},"tabIndex":{"defaultValue":null,"description":"Specifies the focus order relative to the other buttons or controls on the page","name":"tabIndex","parent":{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"},"declarations":[{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"}],"required":false,"type":{"name":"number"}},"testId":{"defaultValue":null,"description":"Sets the data-testid attribute.","name":"testId","parent":{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"},"declarations":[{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"}],"required":false,"type":{"name":"string"}},"type":{"defaultValue":null,"description":"Button type. Default: button","name":"type","parent":{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"},"declarations":[{"fileName":"src/components/Button/Button.tsx","name":"ButtonProps"}],"required":false,"type":{"name":"enum","raw":"\"button\" | \"submit\" | \"reset\"","value":[{"value":"\"button\""},{"value":"\"submit\""},{"value":"\"reset\""}]}},"autoFocus":{"defaultValue":null,"description":"","name":"autoFocus","parent":{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"},"declarations":[{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"}],"required":false,"type":{"name":"boolean"}},"disabled":{"defaultValue":null,"description":"","name":"disabled","parent":{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"},"declarations":[{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"}],"required":false,"type":{"name":"boolean"}},"form":{"defaultValue":null,"description":"","name":"form","parent":{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"},"declarations":[{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"}],"required":false,"type":{"name":"string"}},"formAction":{"defaultValue":null,"description":"","name":"formAction","parent":{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"},"declarations":[{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"}],"required":false,"type":{"name":"string"}},"formEncType":{"defaultValue":null,"description":"","name":"formEncType","parent":{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"},"declarations":[{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"}],"required":false,"type":{"name":"string"}},"formMethod":{"defaultValue":null,"description":"","name":"formMethod","parent":{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"},"declarations":[{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"}],"required":false,"type":{"name":"string"}},"formNoValidate":{"defaultValue":null,"description":"","name":"formNoValidate","parent":{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"},"declarations":[{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"}],"required":false,"type":{"name":"boolean"}},"formTarget":{"defaultValue":null,"description":"","name":"formTarget","parent":{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"},"declarations":[{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"}],"required":false,"type":{"name":"string"}},"name":{"defaultValue":null,"description":"","name":"name","parent":{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"},"declarations":[{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"}],"required":false,"type":{"name":"string"}},"value":{"defaultValue":null,"description":"","name":"value","parent":{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"},"declarations":[{"fileName":"designsystem/src/constants.ts","name":"HTMLButtonProps"}],"required":false,"type":{"name":"string | number | string[]"}},"download":{"defaultValue":null,"description":"","name":"download","parent":{"fileName":"designsystem/src/constants.ts","name":"HTMLAnchorProps"},"declarations":[{"fileName":"designsystem/src/constants.ts","name":"HTMLAnchorProps"}],"required":false,"type":{"name":"string"}},"href":{"defaultValue":null,"description":"","name":"href","parent":{"fileName":"designsystem/src/constants.ts","name":"HTMLAnchorProps"},"declarations":[{"fileName":"designsystem/src/constants.ts","name":"HTMLAnchorProps"}],"required":false,"type":{"name":"string"}},"hrefLang":{"defaultValue":null,"description":"","name":"hrefLang","parent":{"fileName":"designsystem/src/constants.ts","name":"HTMLAnchorProps"},"declarations":[{"fileName":"designsystem/src/constants.ts","name":"HTMLAnchorProps"}],"required":false,"type":{"name":"string"}},"media":{"defaultValue":null,"description":"","name":"media","parent":{"fileName":"designsystem/src/constants.ts","name":"HTMLAnchorProps"},"declarations":[{"fileName":"designsystem/src/constants.ts","name":"HTMLAnchorProps"}],"required":false,"type":{"name":"string"}},"ping":{"defaultValue":null,"description":"","name":"ping","parent":{"fileName":"designsystem/src/constants.ts","name":"HTMLAnchorProps"},"declarations":[{"fileName":"designsystem/src/constants.ts","name":"HTMLAnchorProps"}],"required":false,"type":{"name":"string"}},"rel":{"defaultValue":null,"description":"","name":"rel","parent":{"fileName":"designsystem/src/constants.ts","name":"HTMLAnchorProps"},"declarations":[{"fileName":"designsystem/src/constants.ts","name":"HTMLAnchorProps"}],"required":false,"type":{"name":"enum","raw":"AnchorTarget","value":[{"value":"\"_self\""},{"value":"\"_blank\""},{"value":"\"_parent\""},{"value":"\"_top\""}]}},"target":{"defaultValue":null,"description":"","name":"target","parent":{"fileName":"designsystem/src/constants.ts","name":"HTMLAnchorProps"},"declarations":[{"fileName":"designsystem/src/constants.ts","name":"HTMLAnchorProps"}],"required":false,"type":{"name":"string"}},"referrerPolicy":{"defaultValue":null,"description":"","name":"referrerPolicy","parent":{"fileName":"designsystem/src/constants.ts","name":"HTMLAnchorProps"},"declarations":[{"fileName":"designsystem/src/constants.ts","name":"HTMLAnchorProps"}],"required":false,"type":{"name":"enum","raw":"\"\" | \"same-origin\" | \"no-referrer\" | \"no-referrer-when-downgrade\" | \"origin\" | \"origin-when-cross-origin\" | \"strict-origin\" | \"strict-origin-when-cross-origin\" | \"unsafe-url\"","value":[{"value":"\"\""},{"value":"\"same-origin\""},{"value":"\"no-referrer\""},{"value":"\"no-referrer-when-downgrade\""},{"value":"\"origin\""},{"value":"\"origin-when-cross-origin\""},{"value":"\"strict-origin\""},{"value":"\"strict-origin-when-cross-origin\""},{"value":"\"unsafe-url\""}]}},"aria-activedescendant":{"defaultValue":null,"description":"Identifies the currently active element when DOM focus is on a composite widget, textbox, group, or application.","name":"aria-activedescendant","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"string"}},"aria-atomic":{"defaultValue":null,"description":"Indicates whether assistive technologies will present all, or only parts of, the changed region based on the change notifications defined by the aria-relevant attribute.","name":"aria-atomic","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"Booleanish"}},"aria-autocomplete":{"defaultValue":null,"description":"Indicates whether inputting text could trigger display of one or more predictions of the user's intended value for an input and specifies how predictions would be\npresented if they are made.","name":"aria-autocomplete","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"enum","raw":"\"none\" | \"inline\" | \"list\" | \"both\"","value":[{"value":"\"none\""},{"value":"\"inline\""},{"value":"\"list\""},{"value":"\"both\""}]}},"aria-busy":{"defaultValue":null,"description":"Indicates an element is being modified and that assistive technologies MAY want to wait until the modifications are complete before exposing them to the user.","name":"aria-busy","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"Booleanish"}},"aria-checked":{"defaultValue":null,"description":"Indicates the current \"checked\" state of checkboxes, radio buttons, and other widgets.\n@see aria-pressed\n@see aria-selected.","name":"aria-checked","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"boolean | \"true\" | \"false\" | \"mixed\""}},"aria-colcount":{"defaultValue":null,"description":"Defines the total number of columns in a table, grid, or treegrid.\n@see aria-colindex.","name":"aria-colcount","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"number"}},"aria-colindex":{"defaultValue":null,"description":"Defines an element's column index or position with respect to the total number of columns within a table, grid, or treegrid.\n@see aria-colcount\n@see aria-colspan.","name":"aria-colindex","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"number"}},"aria-colspan":{"defaultValue":null,"description":"Defines the number of columns spanned by a cell or gridcell within a table, grid, or treegrid.\n@see aria-colindex\n@see aria-rowspan.","name":"aria-colspan","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"number"}},"aria-controls":{"defaultValue":null,"description":"Identifies the element (or elements) whose contents or presence are controlled by the current element.\n@see aria-owns.","name":"aria-controls","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"string"}},"aria-current":{"defaultValue":null,"description":"Indicates the element that represents the current item within a container or set of related elements.","name":"aria-current","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"boolean | \"true\" | \"false\" | \"page\" | \"step\" | \"location\" | \"date\" | \"time\""}},"aria-describedby":{"defaultValue":null,"description":"Identifies the element (or elements) that describes the object.\n@see aria-labelledby","name":"aria-describedby","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"string"}},"aria-details":{"defaultValue":null,"description":"Identifies the element that provides a detailed, extended description for the object.\n@see aria-describedby.","name":"aria-details","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"string"}},"aria-disabled":{"defaultValue":null,"description":"Indicates that the element is perceivable but disabled, so it is not editable or otherwise operable.\n@see aria-hidden\n@see aria-readonly.","name":"aria-disabled","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"Booleanish"}},"aria-dropeffect":{"defaultValue":null,"description":"Indicates what functions can be performed when a dragged object is released on the drop target.\n@deprecated in ARIA 1.1","name":"aria-dropeffect","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"enum","raw":"\"none\" | \"copy\" | \"execute\" | \"link\" | \"move\" | \"popup\"","value":[{"value":"\"none\""},{"value":"\"copy\""},{"value":"\"execute\""},{"value":"\"link\""},{"value":"\"move\""},{"value":"\"popup\""}]}},"aria-errormessage":{"defaultValue":null,"description":"Identifies the element that provides an error message for the object.\n@see aria-invalid\n@see aria-describedby.","name":"aria-errormessage","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"string"}},"aria-expanded":{"defaultValue":null,"description":"Indicates whether the element, or another grouping element it controls, is currently expanded or collapsed.","name":"aria-expanded","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"Booleanish"}},"aria-flowto":{"defaultValue":null,"description":"Identifies the next element (or elements) in an alternate reading order of content which, at the user's discretion,\nallows assistive technology to override the general default of reading in document source order.","name":"aria-flowto","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"string"}},"aria-grabbed":{"defaultValue":null,"description":"Indicates an element's \"grabbed\" state in a drag-and-drop operation.\n@deprecated in ARIA 1.1","name":"aria-grabbed","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"Booleanish"}},"aria-haspopup":{"defaultValue":null,"description":"Indicates the availability and type of interactive popup element, such as menu or dialog, that can be triggered by an element.","name":"aria-haspopup","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"boolean | \"true\" | \"false\" | \"menu\" | \"listbox\" | \"tree\" | \"grid\" | \"dialog\""}},"aria-hidden":{"defaultValue":null,"description":"Indicates whether the element is exposed to an accessibility API.\n@see aria-disabled.","name":"aria-hidden","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"Booleanish"}},"aria-invalid":{"defaultValue":null,"description":"Indicates the entered value does not conform to the format expected by the application.\n@see aria-errormessage.","name":"aria-invalid","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"boolean | \"true\" | \"false\" | \"grammar\" | \"spelling\""}},"aria-keyshortcuts":{"defaultValue":null,"description":"Indicates keyboard shortcuts that an author has implemented to activate or give focus to an element.","name":"aria-keyshortcuts","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"string"}},"aria-label":{"defaultValue":null,"description":"Defines a string value that labels the current element.\n@see aria-labelledby.","name":"aria-label","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"string"}},"aria-labelledby":{"defaultValue":null,"description":"Identifies the element (or elements) that labels the current element.\n@see aria-describedby.","name":"aria-labelledby","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"string"}},"aria-level":{"defaultValue":null,"description":"Defines the hierarchical level of an element within a structure.","name":"aria-level","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"number"}},"aria-live":{"defaultValue":null,"description":"Indicates that an element will be updated, and describes the types of updates the user agents, assistive technologies, and user can expect from the live region.","name":"aria-live","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"enum","raw":"\"off\" | \"assertive\" | \"polite\"","value":[{"value":"\"off\""},{"value":"\"assertive\""},{"value":"\"polite\""}]}},"aria-modal":{"defaultValue":null,"description":"Indicates whether an element is modal when displayed.","name":"aria-modal","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"Booleanish"}},"aria-multiline":{"defaultValue":null,"description":"Indicates whether a text box accepts multiple lines of input or only a single line.","name":"aria-multiline","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"Booleanish"}},"aria-multiselectable":{"defaultValue":null,"description":"Indicates that the user may select more than one item from the current selectable descendants.","name":"aria-multiselectable","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"Booleanish"}},"aria-orientation":{"defaultValue":null,"description":"Indicates whether the element's orientation is horizontal, vertical, or unknown/ambiguous.","name":"aria-orientation","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"enum","raw":"\"horizontal\" | \"vertical\"","value":[{"value":"\"horizontal\""},{"value":"\"vertical\""}]}},"aria-owns":{"defaultValue":null,"description":"Identifies an element (or elements) in order to define a visual, functional, or contextual parent/child relationship\nbetween DOM elements where the DOM hierarchy cannot be used to represent the relationship.\n@see aria-controls.","name":"aria-owns","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"string"}},"aria-placeholder":{"defaultValue":null,"description":"Defines a short hint (a word or short phrase) intended to aid the user with data entry when the control has no value.\nA hint could be a sample value or a brief description of the expected format.","name":"aria-placeholder","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"string"}},"aria-posinset":{"defaultValue":null,"description":"Defines an element's number or position in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM.\n@see aria-setsize.","name":"aria-posinset","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"number"}},"aria-pressed":{"defaultValue":null,"description":"Indicates the current \"pressed\" state of toggle buttons.\n@see aria-checked\n@see aria-selected.","name":"aria-pressed","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"boolean | \"true\" | \"false\" | \"mixed\""}},"aria-readonly":{"defaultValue":null,"description":"Indicates that the element is not editable, but is otherwise operable.\n@see aria-disabled.","name":"aria-readonly","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"Booleanish"}},"aria-relevant":{"defaultValue":null,"description":"Indicates what notifications the user agent will trigger when the accessibility tree within a live region is modified.\n@see aria-atomic.","name":"aria-relevant","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"enum","raw":"\"additions\" | \"additions removals\" | \"additions text\" | \"all\" | \"removals\" | \"removals additions\" | \"removals text\" | \"text\" | \"text additions\" | \"text removals\"","value":[{"value":"\"additions\""},{"value":"\"additions removals\""},{"value":"\"additions text\""},{"value":"\"all\""},{"value":"\"removals\""},{"value":"\"removals additions\""},{"value":"\"removals text\""},{"value":"\"text\""},{"value":"\"text additions\""},{"value":"\"text removals\""}]}},"aria-required":{"defaultValue":null,"description":"Indicates that user input is required on the element before a form may be submitted.","name":"aria-required","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"Booleanish"}},"aria-roledescription":{"defaultValue":null,"description":"Defines a human-readable, author-localized description for the role of an element.","name":"aria-roledescription","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"string"}},"aria-rowcount":{"defaultValue":null,"description":"Defines the total number of rows in a table, grid, or treegrid.\n@see aria-rowindex.","name":"aria-rowcount","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"number"}},"aria-rowindex":{"defaultValue":null,"description":"Defines an element's row index or position with respect to the total number of rows within a table, grid, or treegrid.\n@see aria-rowcount\n@see aria-rowspan.","name":"aria-rowindex","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"number"}},"aria-rowspan":{"defaultValue":null,"description":"Defines the number of rows spanned by a cell or gridcell within a table, grid, or treegrid.\n@see aria-rowindex\n@see aria-colspan.","name":"aria-rowspan","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"number"}},"aria-selected":{"defaultValue":null,"description":"Indicates the current \"selected\" state of various widgets.\n@see aria-checked\n@see aria-pressed.","name":"aria-selected","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"Booleanish"}},"aria-setsize":{"defaultValue":null,"description":"Defines the number of items in the current set of listitems or treeitems. Not required if all elements in the set are present in the DOM.\n@see aria-posinset.","name":"aria-setsize","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"number"}},"aria-sort":{"defaultValue":null,"description":"Indicates if items in a table or grid are sorted in ascending or descending order.","name":"aria-sort","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"enum","raw":"\"none\" | \"ascending\" | \"descending\" | \"other\"","value":[{"value":"\"none\""},{"value":"\"ascending\""},{"value":"\"descending\""},{"value":"\"other\""}]}},"aria-valuemax":{"defaultValue":null,"description":"Defines the maximum allowed value for a range widget.","name":"aria-valuemax","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"number"}},"aria-valuemin":{"defaultValue":null,"description":"Defines the minimum allowed value for a range widget.","name":"aria-valuemin","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"number"}},"aria-valuenow":{"defaultValue":null,"description":"Defines the current value for a range widget.\n@see aria-valuetext.","name":"aria-valuenow","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"number"}},"aria-valuetext":{"defaultValue":null,"description":"Defines the human readable text alternative of aria-valuenow for a range widget.","name":"aria-valuetext","parent":{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"},"declarations":[{"fileName":"designsystem/node_modules/@types/react/index.d.ts","name":"AriaAttributes"}],"required":false,"type":{"name":"string"}}}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Slider.d.ts","sourceRoot":"","sources":["../../../src/components/Slider/Slider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAgC3D,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,
|
|
1
|
+
{"version":3,"file":"Slider.d.ts","sourceRoot":"","sources":["../../../src/components/Slider/Slider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAgC3D,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,UAAU,WAAW;IACnB,oCAAoC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gDAAgD;IAChD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,qCAAqC;IACrC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mCAAmC;IACnC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,iHAAiH;IACjH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iHAAiH;IACjH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,wCAAwC;IACxC,KAAK,CAAC,EAAE,UAAU,EAAE,CAAC;IACrB,oDAAoD;IACpD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,sCAAsC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CA4QxC,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import a,{useState as
|
|
1
|
+
import a,{useState as R,useRef as U,useEffect as h}from"react";import S from"classnames";import{AnalyticsId as F}from"../../constants.js";import{useSize as G}from"../../hooks/useSize.js";import{useUuid as j}from"../../hooks/useUuid.js";import{getAriaLabelAttributes as J}from"../../utils/accessibility.js";import{T as Q}from"../../Title.js";import o from"./styles.module.scss";import"../../utils/debounce.js";import"../../uuid.js";import"../../utils/environment.js";import"../Title/styles.module.scss";const Y=(u,f,l)=>{const[v,n]=R(u),E=t=>{t>l?n(l):t<f?n(f):n(t)};return h(()=>{n((l-f)/2+f)},[f,l]),[v,E]},Z=({title:u,ariaLabel:f,labelLeft:l,labelRight:v,disabled:n=!1,onChange:E,steps:t,step:_=1,minValue:i=0,maxValue:s=t?t.length-1:100,testId:$})=>{const[A,I]=R(!1),[d,m]=Y((s-i)/2+i,i,s),k=j(),y=j(),w=j(),N=U(null),b=U(null),{width:M}=G(N)||{width:0},C=s/10;h(()=>{const r=()=>{I(!1)};return document.addEventListener("pointerup",r),()=>{document.removeEventListener("pointerup",r)}},[]);const D=r=>{var L;const e=((L=N.current)==null?void 0:L.getBoundingClientRect().x)??0,c=(r-e)/M,p=s-i;let g=c*p+i;return g=Math.round(g/_)*_,g=Math.max(i,Math.min(s,g)),g};h(()=>{const r=e=>{if(!n&&A){const c=D(e.clientX);m(c)}};return document.addEventListener("pointermove",r),()=>{document.removeEventListener("pointermove",r)}},[A]),h(()=>{!n&&E&&E(d)},[d]);const B=r=>{if(n)return;let e=!1;switch(r.key){case"ArrowLeft":case"ArrowDown":m(d-_),e=!0;break;case"PageDown":m(d-C),e=!0;break;case"ArrowRight":case"ArrowUp":m(d+_),e=!0;break;case"PageUp":m(d+C),e=!0;break;case"Home":m(i),e=!0;break;case"End":m(s),e=!0;break}e&&(r.preventDefault(),r.stopPropagation())},T=r=>{var c;if(n)return;const e=D(r.clientX);m(e),(c=b.current)==null||c.focus()},X=r=>{var e;n||(I(!0),r.preventDefault(),r.stopPropagation(),(e=b.current)==null||e.focus())},z=s!==i?M/(s-i)*(d-i):0,K=()=>{const r=t?Math.round((d-i)/_):null;if(t&&r!==null&&r>=0&&r<t.length){const e=t[r],c=e.emojiUniCode,p=typeof e.label<"u"?e.label.toString():void 0;return c&&p?`${c} ${p}`:c||p}},H=J({label:f,id:(()=>{if(u&&l&&v)return[k,y,w].join(" ");if(u&&l)return[k,y].join(" ");if(u&&v)return[k,w].join(" ");if(u)return k})(),prefer:"label"}),P=(r,e)=>({left:`${r/(e-1)*100}%`}),O=()=>a.createElement("div",{className:o["slider__emoji-container"]},t==null?void 0:t.map((r,e)=>r.emojiUniCode&&a.createElement("div",{"aria-hidden":!0,key:"emoji"+e,className:o.slider__emoji,style:P(e,t.length)},r.emojiUniCode))),W=()=>t==null?void 0:t.map((r,e)=>a.createElement("div",{key:"step"+e,className:o.slider__track__step,style:P(e,t.length)})),q=()=>a.createElement("div",{className:o["slider__value-container"]},t==null?void 0:t.map((r,e)=>typeof r.label<"u"&&a.createElement("div",{"aria-hidden":!0,key:"label"+e,className:o.slider__value,style:P(e,t.length)},r.label)));return a.createElement("div",{className:o.slider,"data-testid":$,"data-analyticsid":F.Slider},u&&a.createElement(Q,{className:o.slider__title,htmlMarkup:"h3",margin:0,appearance:"title3",id:k},u),a.createElement("div",{className:o["slider__content-container"]},O(),a.createElement("div",{ref:N,className:S(o["slider__track-wrapper"],n&&o["slider__track-wrapper--disabled"]),onClick:T,onPointerDown:X},a.createElement("div",{className:S(o.slider__track,n&&o["slider__track--disabled"])},W()),a.createElement("div",{role:n?void 0:"slider",ref:b,className:S(o.slider__marker,n&&o["slider__marker--disabled"]),style:{left:`${z}px`},onKeyDown:B,"aria-valuenow":d,"aria-valuetext":K(),"aria-valuemin":i,"aria-valuemax":s,tabIndex:n?void 0:0,"aria-disabled":n,...H})),q()),(l||v)&&a.createElement("span",{className:o.slider__options},a.createElement("span",{id:y},l),a.createElement("span",{id:w},v)))},me=Z;export{Z as Slider,me as default};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/Slider/Slider.tsx"],"sourcesContent":["import React, { useEffect, useState, useRef } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\nimport { useSize } from '../../hooks/useSize';\nimport { useUuid } from '../../hooks/useUuid';\nimport { getAriaLabelAttributes } from '../../utils/accessibility';\nimport Title from '../Title';\n\nimport styles from './styles.module.scss';\n\nconst useSafeNumberValue = (initial: number, min: number, max: number): [number, (value: number) => void] => {\n const [value, setValue] = useState(initial);\n\n const setSafeValue = (newValue: number): void => {\n if (newValue > max) {\n setValue(max);\n } else if (newValue < min) {\n setValue(min);\n } else {\n setValue(newValue);\n }\n };\n\n useEffect(() => {\n setValue((max - min) / 2 + min);\n }, [min, max]);\n\n return [value, setSafeValue];\n};\n\nexport type SliderStep = {\n label?: number | string;\n /** Start emojicode with &# - otherwise it will render as a regular string */\n emojiUniCode?: string;\n};\n\ninterface SliderProps {\n /**\tSets the title of the slider. */\n title?: string;\n /** Adds the left hand label to the element. */\n labelLeft?: string;\n /** Adds the right hand label to the element. */\n labelRight?: string;\n /**\tSets aria-label of the slider. */\n ariaLabel?: string;\n /** Disables the slider element. */\n disabled?: boolean;\n /** Sets the minimum allowed value on the slider - this overrides the use of steps prop for minValue/maxValue. */\n minValue?: number;\n /** Sets the maximum allowed value on the slider - this overrides the use of steps prop for minValue/maxValue. */\n maxValue?: number;\n /** Function to be called when the value state has changed. */\n onChange?: (value: number) => void;\n /** Sets the steps data for the slider*/\n steps?: SliderStep[];\n /** Sets the step to move per point in the slider */\n step?: number;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport const Slider: React.FC<SliderProps> = ({\n title,\n ariaLabel,\n labelLeft,\n labelRight,\n disabled = false,\n onChange,\n steps,\n step = 1,\n minValue = 0,\n maxValue = steps ? steps.length - 1 : 100,\n testId,\n}) => {\n const [isMoving, setIsMoving] = useState(false);\n const [value, setValue] = useSafeNumberValue((maxValue - minValue) / 2 + minValue, minValue, maxValue);\n\n const titleId = useUuid();\n const labelLeftId = useUuid();\n const labelRightId = useUuid();\n const trackRef = useRef<HTMLDivElement>(null);\n const markerRef = useRef<HTMLDivElement>(null);\n const { width: trackWidth } = useSize(trackRef) || { width: 0 };\n const largeStep = maxValue / 10;\n\n useEffect(() => {\n const handlePointerUp = (): void => {\n setIsMoving(false);\n };\n\n document.addEventListener('pointerup', handlePointerUp);\n\n return () => {\n document.removeEventListener('pointerup', handlePointerUp);\n };\n }, []);\n\n const getValueBasedOnMarkerPosition = (markerPosition: number): number => {\n const trackPosition = trackRef.current?.getBoundingClientRect().x ?? 0;\n\n // Calculate the normalized position (0 to 1) of the marker along the track\n const normalizedPosition = (markerPosition - trackPosition) / trackWidth;\n const valueRange = maxValue - minValue;\n // Calculate the value without considering the step\n let value = normalizedPosition * valueRange + minValue;\n // Adjust the value to account for the step increment\n const stepCount = Math.round(value / step);\n value = stepCount * step;\n value = Math.max(minValue, Math.min(maxValue, value));\n\n return value;\n };\n\n useEffect(() => {\n const handlePointerMove = (e: PointerEvent): void => {\n if (!disabled && isMoving) {\n const newValue = getValueBasedOnMarkerPosition(e.clientX);\n setValue(newValue);\n }\n };\n\n document.addEventListener('pointermove', handlePointerMove);\n\n return () => {\n document.removeEventListener('pointermove', handlePointerMove);\n };\n }, [isMoving]);\n\n useEffect(() => {\n if (!disabled && onChange) {\n onChange(value);\n }\n }, [value]);\n\n const handleKeyDown: React.KeyboardEventHandler<HTMLDivElement> = e => {\n if (disabled) return;\n\n let flag = false;\n\n switch (e.key) {\n case 'ArrowLeft':\n case 'ArrowDown':\n setValue(value - step);\n flag = true;\n break;\n case 'PageDown':\n setValue(value - largeStep);\n flag = true;\n break;\n case 'ArrowRight':\n case 'ArrowUp':\n setValue(value + step);\n flag = true;\n break;\n case 'PageUp':\n setValue(value + largeStep);\n flag = true;\n break;\n case 'Home':\n setValue(minValue);\n flag = true;\n break;\n case 'End':\n setValue(maxValue);\n flag = true;\n break;\n default:\n break;\n }\n\n if (flag) {\n e.preventDefault();\n e.stopPropagation();\n }\n };\n\n const handleTrackClick: React.MouseEventHandler<HTMLDivElement> = e => {\n if (disabled) return;\n\n const newValue = getValueBasedOnMarkerPosition(e.clientX);\n setValue(newValue);\n markerRef.current?.focus();\n };\n\n const handlePointerDown: React.PointerEventHandler<HTMLDivElement> = e => {\n if (disabled) return;\n\n setIsMoving(true);\n\n e.preventDefault();\n e.stopPropagation();\n\n markerRef.current?.focus();\n };\n\n const markerXPos = maxValue !== minValue ? (trackWidth / (maxValue - minValue)) * (value - minValue) : 0;\n\n const getAriaValueText = (): string | undefined => {\n const stepIndex = steps ? Math.round((value - minValue) / step) : null;\n\n if (steps && stepIndex !== null && stepIndex >= 0 && stepIndex < steps.length) {\n const step = steps[stepIndex];\n const emojiCode = step.emojiUniCode;\n const emojiAsText = emojiCode ? safelyReturnEmoji(emojiCode) : undefined;\n const label = typeof step.label !== 'undefined' ? step.label.toString() : undefined;\n\n return emojiAsText && label ? `${emojiAsText} ${label}` : emojiAsText || label;\n }\n\n return undefined;\n };\n\n const getAriaLabeledById = (): string | undefined => {\n if (title && labelLeft && labelRight) {\n return [titleId, labelLeftId, labelRightId].join(' ');\n }\n if (title && labelLeft) {\n return [titleId, labelLeftId].join(' ');\n }\n if (title && labelRight) {\n return [titleId, labelRightId].join(' ');\n }\n if (title) {\n return titleId;\n }\n };\n\n const ariaLabelAttributes = getAriaLabelAttributes({\n label: ariaLabel,\n id: getAriaLabeledById(),\n prefer: 'label',\n });\n\n const getXPostionStyling = (index: number, stepsLength: number): { left: string } => {\n return { left: `${(index / (stepsLength - 1)) * 100}%` };\n };\n\n const safelyReturnEmoji = (code: string): string => {\n try {\n const regex = /^&#\\d+/;\n if (regex.test(code)) {\n const emojiWithoutRegex = code.replace(/^&#/, '');\n return String.fromCodePoint(parseInt(emojiWithoutRegex, 16));\n } else {\n return code;\n }\n } catch (e) {\n return code;\n }\n };\n\n const renderEmojies = (): React.ReactNode => {\n return (\n <div className={styles['slider__emoji-container']}>\n {steps?.map((step, index) => {\n return (\n step.emojiUniCode && (\n <div\n aria-hidden={true}\n key={'emoji' + index}\n className={styles['slider__emoji']}\n style={getXPostionStyling(index, steps.length)}\n >\n {safelyReturnEmoji(step.emojiUniCode)}\n </div>\n )\n );\n })}\n </div>\n );\n };\n\n const renderSteps = (): React.ReactNode => {\n return steps?.map((_step, index) => {\n return <div key={'step' + index} className={styles['slider__track__step']} style={getXPostionStyling(index, steps.length)} />;\n });\n };\n\n const renderStepLabels = (): React.ReactNode => {\n return (\n <div className={styles['slider__value-container']}>\n {steps?.map((step, index) => {\n return (\n typeof step.label !== 'undefined' && (\n <div\n aria-hidden={true}\n key={'label' + index}\n className={styles['slider__value']}\n style={getXPostionStyling(index, steps.length)}\n >\n {step.label}\n </div>\n )\n );\n })}\n </div>\n );\n };\n\n return (\n <div className={styles.slider} data-testid={testId} data-analyticsid={AnalyticsId.Slider}>\n {title && (\n <Title className={styles['slider__title']} htmlMarkup={'h3'} margin={0} appearance={'title3'} id={titleId}>\n {title}\n </Title>\n )}\n <div className={styles['slider__content-container']}>\n {renderEmojies()}\n {/* Komponenten er tilgjengelig for mus/keyboard gjennom bruk av slideren */}\n {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */}\n <div\n ref={trackRef}\n className={classNames(styles['slider__track-wrapper'], disabled && styles['slider__track-wrapper--disabled'])}\n onClick={handleTrackClick}\n onPointerDown={handlePointerDown}\n >\n <div className={classNames(styles.slider__track, disabled && styles['slider__track--disabled'])}>{renderSteps()}</div>\n <div\n role={disabled ? undefined : 'slider'}\n ref={markerRef}\n className={classNames(styles.slider__marker, disabled && styles['slider__marker--disabled'])}\n style={{\n left: `${markerXPos}px`,\n }}\n onKeyDown={handleKeyDown}\n aria-valuenow={value}\n aria-valuetext={getAriaValueText()}\n aria-valuemin={minValue}\n aria-valuemax={maxValue}\n tabIndex={disabled ? undefined : 0}\n aria-disabled={disabled}\n {...ariaLabelAttributes}\n />\n </div>\n {renderStepLabels()}\n </div>\n {(labelLeft || labelRight) && (\n <span className={styles.slider__options}>\n <span id={labelLeftId}>{labelLeft}</span>\n <span id={labelRightId}>{labelRight}</span>\n </span>\n )}\n </div>\n );\n};\n\nexport default Slider;\n"],"names":["useSafeNumberValue","initial","min","max","value","setValue","useState","setSafeValue","newValue","useEffect","Slider","title","ariaLabel","labelLeft","labelRight","disabled","onChange","steps","step","minValue","maxValue","testId","isMoving","setIsMoving","titleId","useUuid","labelLeftId","labelRightId","trackRef","useRef","markerRef","trackWidth","useSize","largeStep","handlePointerUp","getValueBasedOnMarkerPosition","markerPosition","trackPosition","_a","normalizedPosition","valueRange","handlePointerMove","e","handleKeyDown","flag","handleTrackClick","handlePointerDown","markerXPos","getAriaValueText","stepIndex","emojiCode","emojiAsText","safelyReturnEmoji","label","ariaLabelAttributes","getAriaLabelAttributes","getXPostionStyling","index","stepsLength","code","emojiWithoutRegex","renderEmojies","React","styles","renderSteps","_step","renderStepLabels","AnalyticsId","Title","classNames","Slider$1"],"mappings":"sfAYA,MAAMA,EAAqB,CAACC,E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AAAC,EAAA,CAAc,EAChHF,EAAA,cAAC,MAAA,CACC,KAAM/C,EAAW,OAAY,SAC7B,IAAKe,EACL,UAAWuC,EAAWN,EAAO,eAAgBhD,GAAYgD,EAAO,0BAA0B,CAAC,EAC3F,MAAO,CACL,KAAM,GAAGhB,CAAU,IACrB,EACA,UAAWJ,EACX,gBAAevC,EACf,iBAAgB4C,EAAiB,EACjC,gBAAe7B,EACf,gBAAeC,EACf,SAAUL,EAAW,OAAY,EACjC,gBAAeA,EACd,GAAGuC,CAAA,CACN,CACF,EACCY,GACH,GACErD,GAAaC,IACbgD,EAAA,cAAC,OAAK,CAAA,UAAWC,EAAO,eAAA,kBACrB,OAAK,CAAA,GAAIrC,CAAc,EAAAb,CAAU,EAClCiD,EAAA,cAAC,QAAK,GAAInC,CAAA,EAAeb,CAAW,CACtC,CAEJ,CAEJ,EAEAwD,GAAe5D"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/Slider/Slider.tsx"],"sourcesContent":["import React, { useEffect, useState, useRef } from 'react';\n\nimport classNames from 'classnames';\n\nimport { AnalyticsId } from '../../constants';\nimport { useSize } from '../../hooks/useSize';\nimport { useUuid } from '../../hooks/useUuid';\nimport { getAriaLabelAttributes } from '../../utils/accessibility';\nimport Title from '../Title';\n\nimport styles from './styles.module.scss';\n\nconst useSafeNumberValue = (initial: number, min: number, max: number): [number, (value: number) => void] => {\n const [value, setValue] = useState(initial);\n\n const setSafeValue = (newValue: number): void => {\n if (newValue > max) {\n setValue(max);\n } else if (newValue < min) {\n setValue(min);\n } else {\n setValue(newValue);\n }\n };\n\n useEffect(() => {\n setValue((max - min) / 2 + min);\n }, [min, max]);\n\n return [value, setSafeValue];\n};\n\nexport type SliderStep = {\n label?: number | string;\n emojiUniCode?: string;\n};\n\ninterface SliderProps {\n /**\tSets the title of the slider. */\n title?: string;\n /** Adds the left hand label to the element. */\n labelLeft?: string;\n /** Adds the right hand label to the element. */\n labelRight?: string;\n /**\tSets aria-label of the slider. */\n ariaLabel?: string;\n /** Disables the slider element. */\n disabled?: boolean;\n /** Sets the minimum allowed value on the slider - this overrides the use of steps prop for minValue/maxValue. */\n minValue?: number;\n /** Sets the maximum allowed value on the slider - this overrides the use of steps prop for minValue/maxValue. */\n maxValue?: number;\n /** Function to be called when the value state has changed. */\n onChange?: (value: number) => void;\n /** Sets the steps data for the slider*/\n steps?: SliderStep[];\n /** Sets the step to move per point in the slider */\n step?: number;\n /** Sets the data-testid attribute. */\n testId?: string;\n}\n\nexport const Slider: React.FC<SliderProps> = ({\n title,\n ariaLabel,\n labelLeft,\n labelRight,\n disabled = false,\n onChange,\n steps,\n step = 1,\n minValue = 0,\n maxValue = steps ? steps.length - 1 : 100,\n testId,\n}) => {\n const [isMoving, setIsMoving] = useState(false);\n const [value, setValue] = useSafeNumberValue((maxValue - minValue) / 2 + minValue, minValue, maxValue);\n\n const titleId = useUuid();\n const labelLeftId = useUuid();\n const labelRightId = useUuid();\n const trackRef = useRef<HTMLDivElement>(null);\n const markerRef = useRef<HTMLDivElement>(null);\n const { width: trackWidth } = useSize(trackRef) || { width: 0 };\n const largeStep = maxValue / 10;\n\n useEffect(() => {\n const handlePointerUp = (): void => {\n setIsMoving(false);\n };\n\n document.addEventListener('pointerup', handlePointerUp);\n\n return () => {\n document.removeEventListener('pointerup', handlePointerUp);\n };\n }, []);\n\n const getValueBasedOnMarkerPosition = (markerPosition: number): number => {\n const trackPosition = trackRef.current?.getBoundingClientRect().x ?? 0;\n\n // Calculate the normalized position (0 to 1) of the marker along the track\n const normalizedPosition = (markerPosition - trackPosition) / trackWidth;\n const valueRange = maxValue - minValue;\n // Calculate the value without considering the step\n let value = normalizedPosition * valueRange + minValue;\n // Adjust the value to account for the step increment\n const stepCount = Math.round(value / step);\n value = stepCount * step;\n value = Math.max(minValue, Math.min(maxValue, value));\n\n return value;\n };\n\n useEffect(() => {\n const handlePointerMove = (e: PointerEvent): void => {\n if (!disabled && isMoving) {\n const newValue = getValueBasedOnMarkerPosition(e.clientX);\n setValue(newValue);\n }\n };\n\n document.addEventListener('pointermove', handlePointerMove);\n\n return () => {\n document.removeEventListener('pointermove', handlePointerMove);\n };\n }, [isMoving]);\n\n useEffect(() => {\n if (!disabled && onChange) {\n onChange(value);\n }\n }, [value]);\n\n const handleKeyDown: React.KeyboardEventHandler<HTMLDivElement> = e => {\n if (disabled) return;\n\n let flag = false;\n\n switch (e.key) {\n case 'ArrowLeft':\n case 'ArrowDown':\n setValue(value - step);\n flag = true;\n break;\n case 'PageDown':\n setValue(value - largeStep);\n flag = true;\n break;\n case 'ArrowRight':\n case 'ArrowUp':\n setValue(value + step);\n flag = true;\n break;\n case 'PageUp':\n setValue(value + largeStep);\n flag = true;\n break;\n case 'Home':\n setValue(minValue);\n flag = true;\n break;\n case 'End':\n setValue(maxValue);\n flag = true;\n break;\n default:\n break;\n }\n\n if (flag) {\n e.preventDefault();\n e.stopPropagation();\n }\n };\n\n const handleTrackClick: React.MouseEventHandler<HTMLDivElement> = e => {\n if (disabled) return;\n\n const newValue = getValueBasedOnMarkerPosition(e.clientX);\n setValue(newValue);\n markerRef.current?.focus();\n };\n\n const handlePointerDown: React.PointerEventHandler<HTMLDivElement> = e => {\n if (disabled) return;\n\n setIsMoving(true);\n\n e.preventDefault();\n e.stopPropagation();\n\n markerRef.current?.focus();\n };\n\n const markerXPos = maxValue !== minValue ? (trackWidth / (maxValue - minValue)) * (value - minValue) : 0;\n\n const getAriaValueText = (): string | undefined => {\n const stepIndex = steps ? Math.round((value - minValue) / step) : null;\n\n if (steps && stepIndex !== null && stepIndex >= 0 && stepIndex < steps.length) {\n const step = steps[stepIndex];\n const emojiCode = step.emojiUniCode;\n const label = typeof step.label !== 'undefined' ? step.label.toString() : undefined;\n\n return emojiCode && label ? `${emojiCode} ${label}` : emojiCode || label;\n }\n\n return undefined;\n };\n\n const getAriaLabeledById = (): string | undefined => {\n if (title && labelLeft && labelRight) {\n return [titleId, labelLeftId, labelRightId].join(' ');\n }\n if (title && labelLeft) {\n return [titleId, labelLeftId].join(' ');\n }\n if (title && labelRight) {\n return [titleId, labelRightId].join(' ');\n }\n if (title) {\n return titleId;\n }\n };\n\n const ariaLabelAttributes = getAriaLabelAttributes({\n label: ariaLabel,\n id: getAriaLabeledById(),\n prefer: 'label',\n });\n\n const getXPostionStyling = (index: number, stepsLength: number): { left: string } => {\n return { left: `${(index / (stepsLength - 1)) * 100}%` };\n };\n\n const renderEmojies = (): React.ReactNode => {\n return (\n <div className={styles['slider__emoji-container']}>\n {steps?.map((step, index) => {\n return (\n step.emojiUniCode && (\n <div\n aria-hidden={true}\n key={'emoji' + index}\n className={styles['slider__emoji']}\n style={getXPostionStyling(index, steps.length)}\n >\n {step.emojiUniCode}\n </div>\n )\n );\n })}\n </div>\n );\n };\n\n const renderSteps = (): React.ReactNode => {\n return steps?.map((_step, index) => {\n return <div key={'step' + index} className={styles['slider__track__step']} style={getXPostionStyling(index, steps.length)} />;\n });\n };\n\n const renderStepLabels = (): React.ReactNode => {\n return (\n <div className={styles['slider__value-container']}>\n {steps?.map((step, index) => {\n return (\n typeof step.label !== 'undefined' && (\n <div\n aria-hidden={true}\n key={'label' + index}\n className={styles['slider__value']}\n style={getXPostionStyling(index, steps.length)}\n >\n {step.label}\n </div>\n )\n );\n })}\n </div>\n );\n };\n\n return (\n <div className={styles.slider} data-testid={testId} data-analyticsid={AnalyticsId.Slider}>\n {title && (\n <Title className={styles['slider__title']} htmlMarkup={'h3'} margin={0} appearance={'title3'} id={titleId}>\n {title}\n </Title>\n )}\n <div className={styles['slider__content-container']}>\n {renderEmojies()}\n {/* Komponenten er tilgjengelig for mus/keyboard gjennom bruk av slideren */}\n {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */}\n <div\n ref={trackRef}\n className={classNames(styles['slider__track-wrapper'], disabled && styles['slider__track-wrapper--disabled'])}\n onClick={handleTrackClick}\n onPointerDown={handlePointerDown}\n >\n <div className={classNames(styles.slider__track, disabled && styles['slider__track--disabled'])}>{renderSteps()}</div>\n <div\n role={disabled ? undefined : 'slider'}\n ref={markerRef}\n className={classNames(styles.slider__marker, disabled && styles['slider__marker--disabled'])}\n style={{\n left: `${markerXPos}px`,\n }}\n onKeyDown={handleKeyDown}\n aria-valuenow={value}\n aria-valuetext={getAriaValueText()}\n aria-valuemin={minValue}\n aria-valuemax={maxValue}\n tabIndex={disabled ? undefined : 0}\n aria-disabled={disabled}\n {...ariaLabelAttributes}\n />\n </div>\n {renderStepLabels()}\n </div>\n {(labelLeft || labelRight) && (\n <span className={styles.slider__options}>\n <span id={labelLeftId}>{labelLeft}</span>\n <span id={labelRightId}>{labelRight}</span>\n </span>\n )}\n </div>\n );\n};\n\nexport default Slider;\n"],"names":["useSafeNumberValue","initial","min","max","value","setValue","useState","setSafeValue","newValue","useEffect","Slider","title","ariaLabel","labelLeft","labelRight","disabled","onChange","steps","step","minValue","maxValue","testId","isMoving","setIsMoving","titleId","useUuid","labelLeftId","labelRightId","trackRef","useRef","markerRef","trackWidth","useSize","largeStep","handlePointerUp","getValueBasedOnMarkerPosition","markerPosition","trackPosition","_a","normalizedPosition","valueRange","handlePointerMove","handleKeyDown","e","flag","handleTrackClick","handlePointerDown","markerXPos","getAriaValueText","stepIndex","emojiCode","label","ariaLabelAttributes","getAriaLabelAttributes","getXPostionStyling","index","stepsLength","renderEmojies","React","styles","renderSteps","_step","renderStepLabels","AnalyticsId","Title","classNames","Slider$1"],"mappings":"sfAYA,MAAMA,EAAqB,CAACC,EAAiBC,EAAaC,IAAmD,CAC3G,KAAM,CAACC,EAAOC,CAAQ,EAAIC,EAASL,CAAO,EAEpCM,EAAgBC,GAA2B,CAC3CA,EAAWL,EACbE,EAASF,CAAG,EACHK,EAAWN,EACpBG,EAASH,CAAG,EAEZG,EAASG,CAAQ,CACnB,EAGF,OAAAC,EAAU,IAAM,CACJJ,GAAAF,EAAMD,GAAO,EAAIA,CAAG,CAAA,EAC7B,CAACA,EAAKC,CAAG,CAAC,EAEN,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