@entur/button 2.7.4 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/BaseSquareButton.d.ts +1 -1
- package/dist/TertiarySquareButton.d.ts +20 -0
- package/dist/button.cjs.development.js +122 -64
- package/dist/button.cjs.development.js.map +1 -1
- package/dist/button.cjs.production.min.js +1 -1
- package/dist/button.cjs.production.min.js.map +1 -1
- package/dist/button.esm.js +82 -45
- package/dist/button.esm.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/styles.css +92 -48
- package/package.json +9 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.cjs.production.min.js","sources":["../src/Button.tsx","../src/PrimaryButton.tsx","../src/SecondaryButton.tsx","../src/SuccessButton.tsx","../src/NegativeButton.tsx","../src/TertiaryButton.tsx","../src/BaseSquareButton.tsx","../src/SecondarySquareButton.tsx","../src/SuccessSquareButton.tsx","../src/IconButton.tsx","../src/index.tsx","../src/ButtonGroup.tsx","../src/FloatingButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport cx from 'classnames';\nimport {\n PolymorphicPropsWithoutRef,\n PolymorphicForwardRefExoticComponent,\n PolymorphicPropsWithRef,\n} from '@entur/utils';\nimport { LoadingDots } from '@entur/loader';\nimport './Button.scss';\n\ntype ButtonBaseProps = {\n /** Farge og uttrykk på knappen */\n variant: 'primary' | 'secondary' | 'success' | 'negative' | 'tertiary';\n /** Størrelsen på knappen\n * @default 'medium'\n */\n size?: 'medium' | 'large';\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n /** Ekstra klassenavn */\n className?: string;\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** Bredden på knappen.\n * @default 'auto'\n */\n width?: 'fluid' | 'auto';\n /** Innholdet i knappen */\n children: React.ReactNode;\n};\n\nconst defaultElement = 'button';\n\nexport type ButtonProps<\n T extends React.ElementType = typeof defaultElement\n> = PolymorphicPropsWithRef<ButtonBaseProps, T>;\n\nexport const Button: PolymorphicForwardRefExoticComponent<\n ButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <T extends React.ElementType = typeof defaultElement>(\n {\n as,\n variant,\n size = 'medium',\n loading,\n className,\n children,\n disabled = false,\n width = 'auto',\n ...rest\n }: PolymorphicPropsWithoutRef<ButtonBaseProps, T>,\n ref: React.ForwardedRef<React.ElementRef<T>>,\n ) => {\n const Element: React.ElementType = as || defaultElement;\n const childrenArray = React.Children.toArray(children);\n const hasLeadingIcon =\n childrenArray.length > 1 && typeof childrenArray[0] !== 'string';\n const hasTrailingIcon =\n childrenArray.length > 1 &&\n typeof childrenArray[childrenArray.length - 1] !== 'string';\n\n return (\n <Element\n className={cx(\n 'eds-button',\n {\n [`eds-button--variant-${variant}`]: variant,\n [`eds-button--size-${size}`]: size,\n 'eds-button--width-fluid': width === 'fluid',\n 'eds-button--loading': loading,\n 'eds-button--leading-icon': hasLeadingIcon,\n 'eds-button--trailing-icon': hasTrailingIcon,\n },\n className,\n )}\n ref={ref}\n aria-busy={loading}\n disabled={disabled}\n aria-disabled={disabled}\n {...rest}\n >\n {loading ? (\n <LoadingDots className=\"eds-button__loading-dots\" />\n ) : (\n children\n )}\n </Element>\n );\n },\n);\n","import React from 'react';\nimport { Button } from './Button';\nimport {\n PolymorphicPropsWithoutRef,\n PolymorphicForwardRefExoticComponent,\n PolymorphicPropsWithRef,\n} from '@entur/utils';\n\nexport type PrimaryButtonBaseProps = {\n /** Størrelsen på knappen\n * @default 'medium'\n */\n size?: 'medium' | 'large';\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n /** Ekstra klassenavn */\n className?: string;\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** Bredden på knappen.\n * @default 'auto'\n */\n width?: 'fluid' | 'auto';\n /** Innholdet i knappen */\n children: React.ReactNode;\n};\n\nexport type PrimaryButtonProps<\n T extends React.ElementType = typeof defaultElement\n> = PolymorphicPropsWithRef<PrimaryButtonBaseProps, T>;\n\nconst defaultElement = 'button';\n\nexport const PrimaryButton: PolymorphicForwardRefExoticComponent<\n PrimaryButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <T extends React.ElementType = typeof defaultElement>(\n props: PolymorphicPropsWithoutRef<PrimaryButtonBaseProps, T>,\n ref: React.ForwardedRef<React.ElementRef<T>>,\n ) => {\n const Element: React.ElementType = props.as || defaultElement;\n return <Button as={Element} {...props} ref={ref} variant=\"primary\" />;\n },\n);\n","import React from 'react';\nimport { Button } from './Button';\nimport {\n PolymorphicForwardRefExoticComponent,\n PolymorphicPropsWithRef,\n PolymorphicPropsWithoutRef,\n} from '@entur/utils';\n\nexport type SecondaryButtonBaseProps = {\n /** Størrelsen på knappen\n * @default 'medium'\n */\n size?: 'medium' | 'large';\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n /** Ekstra klassenavn */\n className?: string;\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** Bredden på knappen\n * @default 'auto'\n */\n width?: 'fluid' | 'auto';\n /** Innholdet i knappen */\n children: React.ReactNode;\n};\n\nexport type SecondaryButtonProps<\n T extends React.ElementType = typeof defaultElement\n> = PolymorphicPropsWithRef<SecondaryButtonBaseProps, T>;\n\nconst defaultElement = 'button';\n\nexport const SecondaryButton: PolymorphicForwardRefExoticComponent<\n SecondaryButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <T extends React.ElementType = typeof defaultElement>(\n props: PolymorphicPropsWithoutRef<SecondaryButtonBaseProps, T>,\n ref: React.ForwardedRef<React.ElementRef<T>>,\n ) => {\n const Element: React.ElementType = props.as || defaultElement;\n return <Button as={Element} {...props} ref={ref} variant=\"secondary\" />;\n },\n);\n","import React from 'react';\nimport { Button } from './Button';\nimport {\n PolymorphicPropsWithoutRef,\n PolymorphicForwardRefExoticComponent,\n PolymorphicPropsWithRef,\n} from '@entur/utils';\n\ntype SuccessButtonBaseProps = {\n /** Størrelsen på knappen\n * @default 'medium'\n */\n size?: 'medium' | 'large';\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n /** Ekstra klassenavn */\n className?: string;\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** Bredden på knappen\n * @default 'auto'\n */\n width?: 'fluid' | 'auto';\n /** Innholdet i knappen */\n children: React.ReactNode;\n};\n\nexport type SuccessButtonProps<\n E extends React.ElementType = typeof defaultElement\n> = PolymorphicPropsWithRef<SuccessButtonBaseProps, E>;\n\nconst defaultElement = 'button';\n\nexport const SuccessButton: PolymorphicForwardRefExoticComponent<\n SuccessButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <T extends React.ElementType = typeof defaultElement>(\n props: PolymorphicPropsWithoutRef<SuccessButtonBaseProps, T>,\n ref: React.ForwardedRef<React.ElementRef<T>>,\n ) => {\n const Element: React.ElementType = props.as || defaultElement;\n return <Button as={Element} {...props} ref={ref} variant=\"success\" />;\n },\n);\n","import React from 'react';\nimport { Button } from './Button';\nimport {\n PolymorphicPropsWithoutRef,\n PolymorphicPropsWithRef,\n PolymorphicForwardRefExoticComponent,\n} from '@entur/utils';\n\nexport type NegativeButtonBaseProps = {\n /** Størrelsen på knappen\n * @default 'medium'\n */\n size?: 'medium' | 'large';\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n /** Ekstra klassenavn */\n className?: string;\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** Bredden på knappen.\n * @default 'auto'\n */\n width?: 'fluid' | 'auto';\n /** Innholdet i knappen */\n children: React.ReactNode;\n as?: 'button' | React.ElementType;\n};\n\nexport type NegativeButtonProps<\n T extends React.ElementType = typeof defaultElement\n> = PolymorphicPropsWithRef<NegativeButtonBaseProps, T>;\n\nconst defaultElement = 'button';\n\nexport const NegativeButton: PolymorphicForwardRefExoticComponent<\n NegativeButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <T extends React.ElementType = typeof defaultElement>(\n props: PolymorphicPropsWithoutRef<NegativeButtonBaseProps, T>,\n ref: React.ForwardedRef<React.ElementRef<T>>,\n ) => {\n const Element: React.ElementType = props.as || defaultElement;\n return <Button as={Element} {...props} ref={ref} variant=\"negative\" />;\n },\n);\n","import React from 'react';\nimport { Button } from './Button';\nimport {\n PolymorphicPropsWithoutRef,\n PolymorphicPropsWithRef,\n PolymorphicForwardRefExoticComponent,\n} from '@entur/utils';\n\nexport type TertiaryButtonBaseProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n /** Innholdet i knappen */\n children: React.ReactNode;\n};\n\nexport type TertiaryButtonProps<\n E extends React.ElementType = typeof defaultElement\n> = PolymorphicPropsWithRef<TertiaryButtonBaseProps, E>;\n\nconst defaultElement = 'button';\n\nexport const TertiaryButton: PolymorphicForwardRefExoticComponent<\n TertiaryButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <T extends React.ElementType = typeof defaultElement>(\n props: PolymorphicPropsWithoutRef<TertiaryButtonBaseProps, T>,\n ref: React.ForwardedRef<React.ElementRef<T>>,\n ) => {\n const Element: React.ElementType = props.as || defaultElement;\n return <Button as={Element} {...props} ref={ref} variant=\"tertiary\" />;\n },\n);\n","import * as React from 'react';\nimport classNames from 'classnames';\nimport {\n PolymorphicPropsWithoutRef,\n PolymorphicForwardRefExoticComponent,\n PolymorphicPropsWithRef,\n} from '@entur/utils';\nimport { LoadingDots } from '@entur/loader';\nimport './BaseSquareButton.scss';\n\nexport type BaseSquareButtonBaseProps = {\n /** Tekst og ikon */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** En type knapp */\n variant: 'success' | 'secondary';\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n};\n\nexport type BaseSquareButtonProps<\n T extends React.ElementType = typeof defaultElement\n> = PolymorphicPropsWithRef<BaseSquareButtonBaseProps, T>;\n\nconst defaultElement = 'button';\n\nexport const BaseSquareButton: PolymorphicForwardRefExoticComponent<\n BaseSquareButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <T extends React.ElementType = typeof defaultElement>(\n {\n children,\n className,\n variant,\n disabled = false,\n loading = false,\n as,\n ...rest\n }: PolymorphicPropsWithoutRef<BaseSquareButtonBaseProps, T>,\n ref: React.ForwardedRef<React.ElementRef<T>>,\n ) => {\n const Element: React.ElementType = as || defaultElement;\n return (\n <Element\n className={classNames(\n 'eds-square-button',\n { 'eds-square-button--success': variant === 'success' },\n { 'eds-square-button--secondary': variant === 'secondary' },\n { 'eds-square-button--loading': loading },\n className,\n )}\n aria-busy={loading}\n disabled={disabled}\n aria-disabled={disabled}\n ref={ref}\n {...rest}\n >\n {React.Children.map(children, child => {\n if (typeof child === 'string') {\n return <span className=\"eds-square-button__label\">{child}</span>;\n }\n return (\n <span className=\"eds-square-button__icon\">\n {loading ? (\n <LoadingDots className=\"eds-square-button__loading-dots\" />\n ) : (\n child\n )}\n </span>\n );\n })}\n </Element>\n );\n },\n);\n","import React from 'react';\nimport { BaseSquareButton } from './BaseSquareButton';\nimport {\n PolymorphicForwardRefExoticComponent,\n PolymorphicPropsWithoutRef,\n PolymorphicPropsWithRef,\n} from '@entur/utils';\n\nexport type SecondarySquareButtonBaseProps = {\n /** Tekst og ikon, ikon og tekst, eller bare ikon */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n};\n\nexport type SecondarySquareButtonProps<\n E extends React.ElementType = typeof defaultElement\n> = PolymorphicPropsWithRef<SecondarySquareButtonBaseProps, E>;\n\nconst defaultElement = 'button';\n\nexport const SecondarySquareButton: PolymorphicForwardRefExoticComponent<\n SecondarySquareButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <T extends React.ElementType = typeof defaultElement>(\n props: PolymorphicPropsWithoutRef<SecondarySquareButtonBaseProps, T>,\n ref: React.ForwardedRef<React.ElementRef<T>>,\n ) => {\n const Element: React.ElementType = props.as || defaultElement;\n return (\n <BaseSquareButton as={Element} ref={ref} {...props} variant=\"secondary\" />\n );\n },\n);\n","import React from 'react';\nimport { BaseSquareButton } from './BaseSquareButton';\nimport {\n PolymorphicForwardRefExoticComponent,\n PolymorphicPropsWithRef,\n PolymorphicPropsWithoutRef,\n} from '@entur/utils';\n\ntype SuccessSquareButtonBaseProps = {\n /** Tekst og ikon, ikon og tekst, eller bare ikon */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n};\n\nexport type SuccessSquareButtonProps<\n E extends React.ElementType = typeof defaultElement\n> = PolymorphicPropsWithRef<SuccessSquareButtonBaseProps, E>;\n\nconst defaultElement = 'button';\n\nexport const SuccessSquareButton: PolymorphicForwardRefExoticComponent<\n SuccessSquareButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <T extends React.ElementType = typeof defaultElement>(\n props: PolymorphicPropsWithoutRef<SuccessSquareButtonBaseProps, T>,\n ref: React.ForwardedRef<React.ElementRef<T>>,\n ) => {\n const Element: React.ElementType = props.as || defaultElement;\n return (\n <BaseSquareButton as={Element} ref={ref} {...props} variant=\"success\" />\n );\n },\n);\n","import React from 'react';\nimport classNames from 'classnames';\nimport {\n PolymorphicPropsWithoutRef,\n PolymorphicForwardRefExoticComponent,\n PolymorphicPropsWithRef,\n} from '@entur/utils';\nimport { LoadingDots } from '@entur/loader';\nimport './IconButton.scss';\n\nexport type IconButtonBaseProps = {\n /** Ikonet som du vil ha inne i knappen */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** HTML-elementet eller React-komponenten som lager knappen\n * @default 'button'\n */\n as?: React.ElementType;\n /**Størrelsen på knappen\n * @default \"medium\"\n */\n size?: 'small' | 'medium';\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n};\n\nconst defaultElement = 'button';\n\nexport type IconButtonProps<\n E extends React.ElementType = typeof defaultElement\n> = PolymorphicPropsWithRef<IconButtonBaseProps, E>;\n\nexport const IconButton: PolymorphicForwardRefExoticComponent<\n IconButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <E extends React.ElementType = typeof defaultElement>(\n {\n children,\n className,\n disabled = false,\n size,\n as,\n loading,\n ...rest\n }: PolymorphicPropsWithoutRef<IconButtonBaseProps, E>,\n ref: React.ForwardedRef<React.ElementRef<E>>,\n ) => {\n const Element: React.ElementType = as || defaultElement;\n return (\n <Element\n className={classNames(\n 'eds-icon-button',\n className,\n {\n 'eds-icon-button--disabled': disabled,\n },\n `eds-icon-button--size-${size}`,\n )}\n disabled={disabled}\n aria-disabled={disabled}\n ref={ref}\n {...rest}\n >\n {loading ? <LoadingDots /> : children}\n </Element>\n );\n },\n);\n","import { warnAboutMissingStyles } from '@entur/utils';\nimport './index.scss';\n\nwarnAboutMissingStyles('button');\n\nexport * from './Button';\nexport * from './PrimaryButton';\nexport * from './SecondaryButton';\nexport * from './SuccessButton';\nexport * from './NegativeButton';\nexport * from './TertiaryButton';\nexport * from './ButtonGroup';\nexport * from './FloatingButton';\nexport * from './SecondarySquareButton';\nexport * from './SuccessSquareButton';\nexport * from './IconButton';\n","import React from 'react';\nimport classNames from 'classnames';\nimport './ButtonGroup.scss';\n\nexport type ButtonGroupProps = {\n /** To eller flere Button-komponenter */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** HTML-elementet eller React-komponenten som lages\n * @default \"div\"\n */\n as?: string | React.ElementType;\n [key: string]: any;\n};\n\nexport const ButtonGroup: React.FC<ButtonGroupProps> = ({\n as: Element = 'div',\n className,\n ...rest\n}) => {\n return (\n <Element className={classNames('eds-button-group', className)} {...rest} />\n );\n};\n","import React from 'react';\nimport classNames from 'classnames';\nimport './FloatingButton.scss';\n\nexport type FloatingButtonProps = {\n /** Beskrivende tekst for skjermlesere */\n 'aria-label': string;\n /** Ikon eller ikon-og-tekst */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Callback når knappen klikkes */\n onClick: (e: React.MouseEvent<HTMLButtonElement>) => void;\n /** Størrelse på knappen\n * @default \"medium\"\n */\n size?: 'medium' | 'small';\n [key: string]: any;\n} & React.ButtonHTMLAttributes<HTMLButtonElement>;\n\nexport const FloatingButton: React.FC<FloatingButtonProps> = ({\n className,\n children,\n size = 'medium',\n ...rest\n}) => {\n return (\n <button\n className={classNames(\n 'eds-floating-button',\n { 'eds-floating-button--extended': React.Children.count(children) > 1 },\n { 'eds-floating-button--small': size === 'small' },\n className,\n )}\n type=\"button\"\n {...rest}\n >\n {wrapStringsInSpans(children)}\n </button>\n );\n};\n\nconst wrapStringsInSpans = (children: React.ReactNode) =>\n React.Children.map(children, child =>\n typeof child === 'string' ? <span>{child}</span> : child,\n );\n"],"names":["Button","React","ref","as","variant","size","loading","className","children","disabled","width","rest","Element","childrenArray","toArray","hasLeadingIcon","length","hasTrailingIcon","cx","LoadingDots","PrimaryButton","forwardRef","props","SecondaryButton","SuccessButton","NegativeButton","TertiaryButton","BaseSquareButton","classNames","map","child","SecondarySquareButton","SuccessSquareButton","IconButton","warnAboutMissingStyles","Children","count","type","wrapStringsInSpans"],"mappings":"4XAmCA,IAMaA,EAGTC,cACF,WAYEC,SAVEC,IAAAA,GACAC,IAAAA,YACAC,KAAAA,aAAO,WAC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GAAU,SAAAsB,SACV,iBAAVA,EAAqB7B,4BAAO6B,GAAgBA,KAPhDQ,CAAmB9B"}
|
|
1
|
+
{"version":3,"file":"button.cjs.production.min.js","sources":["../src/Button.tsx","../src/PrimaryButton.tsx","../src/SecondaryButton.tsx","../src/SuccessButton.tsx","../src/NegativeButton.tsx","../src/TertiaryButton.tsx","../src/BaseSquareButton.tsx","../src/SecondarySquareButton.tsx","../src/SuccessSquareButton.tsx","../src/TertiarySquareButton.tsx","../src/IconButton.tsx","../src/index.tsx","../src/ButtonGroup.tsx","../src/FloatingButton.tsx"],"sourcesContent":["import * as React from 'react';\nimport cx from 'classnames';\nimport {\n PolymorphicPropsWithoutRef,\n PolymorphicForwardRefExoticComponent,\n PolymorphicPropsWithRef,\n} from '@entur/utils';\nimport { LoadingDots } from '@entur/loader';\nimport './Button.scss';\n\ntype ButtonBaseProps = {\n /** Farge og uttrykk på knappen */\n variant: 'primary' | 'secondary' | 'success' | 'negative' | 'tertiary';\n /** Størrelsen på knappen\n * @default 'medium'\n */\n size?: 'medium' | 'large';\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n /** Ekstra klassenavn */\n className?: string;\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** Bredden på knappen.\n * @default 'auto'\n */\n width?: 'fluid' | 'auto';\n /** Innholdet i knappen */\n children: React.ReactNode;\n};\n\nconst defaultElement = 'button';\n\nexport type ButtonProps<\n T extends React.ElementType = typeof defaultElement\n> = PolymorphicPropsWithRef<ButtonBaseProps, T>;\n\nexport const Button: PolymorphicForwardRefExoticComponent<\n ButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <T extends React.ElementType = typeof defaultElement>(\n {\n as,\n variant,\n size = 'medium',\n loading,\n className,\n children,\n disabled = false,\n width = 'auto',\n ...rest\n }: PolymorphicPropsWithoutRef<ButtonBaseProps, T>,\n ref: React.ForwardedRef<React.ElementRef<T>>,\n ) => {\n const Element: React.ElementType = as || defaultElement;\n const childrenArray = React.Children.toArray(children);\n const hasLeadingIcon =\n childrenArray.length > 1 && typeof childrenArray[0] !== 'string';\n const hasTrailingIcon =\n childrenArray.length > 1 &&\n typeof childrenArray[childrenArray.length - 1] !== 'string';\n\n return (\n <Element\n className={cx(\n 'eds-button',\n {\n [`eds-button--variant-${variant}`]: variant,\n [`eds-button--size-${size}`]: size,\n 'eds-button--width-fluid': width === 'fluid',\n 'eds-button--loading': loading,\n 'eds-button--leading-icon': hasLeadingIcon,\n 'eds-button--trailing-icon': hasTrailingIcon,\n },\n className,\n )}\n ref={ref}\n aria-busy={loading}\n disabled={disabled}\n aria-disabled={disabled}\n {...rest}\n >\n {loading ? (\n <LoadingDots className=\"eds-button__loading-dots\" />\n ) : (\n children\n )}\n </Element>\n );\n },\n);\n","import React from 'react';\nimport { Button } from './Button';\nimport {\n PolymorphicPropsWithoutRef,\n PolymorphicForwardRefExoticComponent,\n PolymorphicPropsWithRef,\n} from '@entur/utils';\n\nexport type PrimaryButtonBaseProps = {\n /** Størrelsen på knappen\n * @default 'medium'\n */\n size?: 'medium' | 'large';\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n /** Ekstra klassenavn */\n className?: string;\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** Bredden på knappen.\n * @default 'auto'\n */\n width?: 'fluid' | 'auto';\n /** Innholdet i knappen */\n children: React.ReactNode;\n};\n\nexport type PrimaryButtonProps<\n T extends React.ElementType = typeof defaultElement\n> = PolymorphicPropsWithRef<PrimaryButtonBaseProps, T>;\n\nconst defaultElement = 'button';\n\nexport const PrimaryButton: PolymorphicForwardRefExoticComponent<\n PrimaryButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <T extends React.ElementType = typeof defaultElement>(\n props: PolymorphicPropsWithoutRef<PrimaryButtonBaseProps, T>,\n ref: React.ForwardedRef<React.ElementRef<T>>,\n ) => {\n const Element: React.ElementType = props.as || defaultElement;\n return <Button as={Element} {...props} ref={ref} variant=\"primary\" />;\n },\n);\n","import React from 'react';\nimport { Button } from './Button';\nimport {\n PolymorphicForwardRefExoticComponent,\n PolymorphicPropsWithRef,\n PolymorphicPropsWithoutRef,\n} from '@entur/utils';\n\nexport type SecondaryButtonBaseProps = {\n /** Størrelsen på knappen\n * @default 'medium'\n */\n size?: 'medium' | 'large';\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n /** Ekstra klassenavn */\n className?: string;\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** Bredden på knappen\n * @default 'auto'\n */\n width?: 'fluid' | 'auto';\n /** Innholdet i knappen */\n children: React.ReactNode;\n};\n\nexport type SecondaryButtonProps<\n T extends React.ElementType = typeof defaultElement\n> = PolymorphicPropsWithRef<SecondaryButtonBaseProps, T>;\n\nconst defaultElement = 'button';\n\nexport const SecondaryButton: PolymorphicForwardRefExoticComponent<\n SecondaryButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <T extends React.ElementType = typeof defaultElement>(\n props: PolymorphicPropsWithoutRef<SecondaryButtonBaseProps, T>,\n ref: React.ForwardedRef<React.ElementRef<T>>,\n ) => {\n const Element: React.ElementType = props.as || defaultElement;\n return <Button as={Element} {...props} ref={ref} variant=\"secondary\" />;\n },\n);\n","import React from 'react';\nimport { Button } from './Button';\nimport {\n PolymorphicPropsWithoutRef,\n PolymorphicForwardRefExoticComponent,\n PolymorphicPropsWithRef,\n} from '@entur/utils';\n\ntype SuccessButtonBaseProps = {\n /** Størrelsen på knappen\n * @default 'medium'\n */\n size?: 'medium' | 'large';\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n /** Ekstra klassenavn */\n className?: string;\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** Bredden på knappen\n * @default 'auto'\n */\n width?: 'fluid' | 'auto';\n /** Innholdet i knappen */\n children: React.ReactNode;\n};\n\nexport type SuccessButtonProps<\n E extends React.ElementType = typeof defaultElement\n> = PolymorphicPropsWithRef<SuccessButtonBaseProps, E>;\n\nconst defaultElement = 'button';\n\nexport const SuccessButton: PolymorphicForwardRefExoticComponent<\n SuccessButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <T extends React.ElementType = typeof defaultElement>(\n props: PolymorphicPropsWithoutRef<SuccessButtonBaseProps, T>,\n ref: React.ForwardedRef<React.ElementRef<T>>,\n ) => {\n const Element: React.ElementType = props.as || defaultElement;\n return <Button as={Element} {...props} ref={ref} variant=\"success\" />;\n },\n);\n","import React from 'react';\nimport { Button } from './Button';\nimport {\n PolymorphicPropsWithoutRef,\n PolymorphicPropsWithRef,\n PolymorphicForwardRefExoticComponent,\n} from '@entur/utils';\n\nexport type NegativeButtonBaseProps = {\n /** Størrelsen på knappen\n * @default 'medium'\n */\n size?: 'medium' | 'large';\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n /** Ekstra klassenavn */\n className?: string;\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** Bredden på knappen.\n * @default 'auto'\n */\n width?: 'fluid' | 'auto';\n /** Innholdet i knappen */\n children: React.ReactNode;\n as?: 'button' | React.ElementType;\n};\n\nexport type NegativeButtonProps<\n T extends React.ElementType = typeof defaultElement\n> = PolymorphicPropsWithRef<NegativeButtonBaseProps, T>;\n\nconst defaultElement = 'button';\n\nexport const NegativeButton: PolymorphicForwardRefExoticComponent<\n NegativeButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <T extends React.ElementType = typeof defaultElement>(\n props: PolymorphicPropsWithoutRef<NegativeButtonBaseProps, T>,\n ref: React.ForwardedRef<React.ElementRef<T>>,\n ) => {\n const Element: React.ElementType = props.as || defaultElement;\n return <Button as={Element} {...props} ref={ref} variant=\"negative\" />;\n },\n);\n","import React from 'react';\nimport { Button } from './Button';\nimport {\n PolymorphicPropsWithoutRef,\n PolymorphicPropsWithRef,\n PolymorphicForwardRefExoticComponent,\n} from '@entur/utils';\n\nexport type TertiaryButtonBaseProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n /** Innholdet i knappen */\n children: React.ReactNode;\n};\n\nexport type TertiaryButtonProps<\n E extends React.ElementType = typeof defaultElement\n> = PolymorphicPropsWithRef<TertiaryButtonBaseProps, E>;\n\nconst defaultElement = 'button';\n\nexport const TertiaryButton: PolymorphicForwardRefExoticComponent<\n TertiaryButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <T extends React.ElementType = typeof defaultElement>(\n props: PolymorphicPropsWithoutRef<TertiaryButtonBaseProps, T>,\n ref: React.ForwardedRef<React.ElementRef<T>>,\n ) => {\n const Element: React.ElementType = props.as || defaultElement;\n return <Button as={Element} {...props} ref={ref} variant=\"tertiary\" />;\n },\n);\n","import * as React from 'react';\nimport classNames from 'classnames';\nimport {\n PolymorphicPropsWithoutRef,\n PolymorphicForwardRefExoticComponent,\n PolymorphicPropsWithRef,\n} from '@entur/utils';\nimport { LoadingDots } from '@entur/loader';\nimport './BaseSquareButton.scss';\n\nexport type BaseSquareButtonBaseProps = {\n /** Tekst og ikon */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** En type knapp */\n variant: 'success' | 'secondary' | 'tertiary';\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n};\n\nexport type BaseSquareButtonProps<\n T extends React.ElementType = typeof defaultElement,\n> = PolymorphicPropsWithRef<BaseSquareButtonBaseProps, T>;\n\nconst defaultElement = 'button';\n\nexport const BaseSquareButton: PolymorphicForwardRefExoticComponent<\n BaseSquareButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <T extends React.ElementType = typeof defaultElement>(\n {\n children,\n className,\n variant,\n disabled = false,\n loading = false,\n as,\n ...rest\n }: PolymorphicPropsWithoutRef<BaseSquareButtonBaseProps, T>,\n ref: React.ForwardedRef<React.ElementRef<T>>,\n ) => {\n const Element: React.ElementType = as || defaultElement;\n return (\n <Element\n className={classNames(\n 'eds-square-button',\n { 'eds-square-button--success': variant === 'success' },\n { 'eds-square-button--secondary': variant === 'secondary' },\n { 'eds-square-button--tertiary': variant === 'tertiary' },\n { 'eds-square-button--loading': loading },\n className,\n )}\n aria-busy={loading}\n disabled={disabled}\n aria-disabled={disabled}\n ref={ref}\n {...rest}\n >\n {React.Children.map(children, child => {\n if (typeof child === 'string') {\n return <span className=\"eds-square-button__label\">{child}</span>;\n }\n return (\n <span className=\"eds-square-button__icon\">\n {loading ? (\n <LoadingDots className=\"eds-square-button__loading-dots\" />\n ) : (\n child\n )}\n </span>\n );\n })}\n </Element>\n );\n },\n);\n","import React from 'react';\nimport { BaseSquareButton } from './BaseSquareButton';\nimport {\n PolymorphicForwardRefExoticComponent,\n PolymorphicPropsWithoutRef,\n PolymorphicPropsWithRef,\n} from '@entur/utils';\n\nexport type SecondarySquareButtonBaseProps = {\n /** Tekst og ikon, ikon og tekst, eller bare ikon */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n};\n\nexport type SecondarySquareButtonProps<\n E extends React.ElementType = typeof defaultElement\n> = PolymorphicPropsWithRef<SecondarySquareButtonBaseProps, E>;\n\nconst defaultElement = 'button';\n\nexport const SecondarySquareButton: PolymorphicForwardRefExoticComponent<\n SecondarySquareButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <T extends React.ElementType = typeof defaultElement>(\n props: PolymorphicPropsWithoutRef<SecondarySquareButtonBaseProps, T>,\n ref: React.ForwardedRef<React.ElementRef<T>>,\n ) => {\n const Element: React.ElementType = props.as || defaultElement;\n return (\n <BaseSquareButton as={Element} ref={ref} {...props} variant=\"secondary\" />\n );\n },\n);\n","import React from 'react';\nimport { BaseSquareButton } from './BaseSquareButton';\nimport {\n PolymorphicForwardRefExoticComponent,\n PolymorphicPropsWithRef,\n PolymorphicPropsWithoutRef,\n} from '@entur/utils';\n\ntype SuccessSquareButtonBaseProps = {\n /** Tekst og ikon, ikon og tekst, eller bare ikon */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n};\n\nexport type SuccessSquareButtonProps<\n E extends React.ElementType = typeof defaultElement\n> = PolymorphicPropsWithRef<SuccessSquareButtonBaseProps, E>;\n\nconst defaultElement = 'button';\n\nexport const SuccessSquareButton: PolymorphicForwardRefExoticComponent<\n SuccessSquareButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <T extends React.ElementType = typeof defaultElement>(\n props: PolymorphicPropsWithoutRef<SuccessSquareButtonBaseProps, T>,\n ref: React.ForwardedRef<React.ElementRef<T>>,\n ) => {\n const Element: React.ElementType = props.as || defaultElement;\n return (\n <BaseSquareButton as={Element} ref={ref} {...props} variant=\"success\" />\n );\n },\n);\n","import React from 'react';\nimport { BaseSquareButton } from './BaseSquareButton';\nimport {\n PolymorphicForwardRefExoticComponent,\n PolymorphicPropsWithoutRef,\n PolymorphicPropsWithRef,\n} from '@entur/utils';\n\nexport type TertiarySquareButtonBaseProps = {\n /** Tekst og ikon, ikon og tekst, eller bare ikon */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n};\n\nexport type TertiarySquareButtonProps<\n E extends React.ElementType = typeof defaultElement,\n> = PolymorphicPropsWithRef<TertiarySquareButtonBaseProps, E>;\n\nconst defaultElement = 'button';\n\nexport const TertiarySquareButton: PolymorphicForwardRefExoticComponent<\n TertiarySquareButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <T extends React.ElementType = typeof defaultElement>(\n props: PolymorphicPropsWithoutRef<TertiarySquareButtonBaseProps, T>,\n ref: React.ForwardedRef<React.ElementRef<T>>,\n ) => {\n const Element: React.ElementType = props.as || defaultElement;\n return (\n <BaseSquareButton as={Element} ref={ref} {...props} variant=\"tertiary\" />\n );\n },\n);\n","import React from 'react';\nimport classNames from 'classnames';\nimport {\n PolymorphicPropsWithoutRef,\n PolymorphicForwardRefExoticComponent,\n PolymorphicPropsWithRef,\n} from '@entur/utils';\nimport { LoadingDots } from '@entur/loader';\nimport './IconButton.scss';\n\nexport type IconButtonBaseProps = {\n /** Ikonet som du vil ha inne i knappen */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** HTML-elementet eller React-komponenten som lager knappen\n * @default 'button'\n */\n as?: React.ElementType;\n /**Størrelsen på knappen\n * @default \"medium\"\n */\n size?: 'small' | 'medium';\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n};\n\nconst defaultElement = 'button';\n\nexport type IconButtonProps<\n E extends React.ElementType = typeof defaultElement\n> = PolymorphicPropsWithRef<IconButtonBaseProps, E>;\n\nexport const IconButton: PolymorphicForwardRefExoticComponent<\n IconButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <E extends React.ElementType = typeof defaultElement>(\n {\n children,\n className,\n disabled = false,\n size,\n as,\n loading,\n ...rest\n }: PolymorphicPropsWithoutRef<IconButtonBaseProps, E>,\n ref: React.ForwardedRef<React.ElementRef<E>>,\n ) => {\n const Element: React.ElementType = as || defaultElement;\n return (\n <Element\n className={classNames(\n 'eds-icon-button',\n className,\n {\n 'eds-icon-button--disabled': disabled,\n },\n `eds-icon-button--size-${size}`,\n )}\n disabled={disabled}\n aria-disabled={disabled}\n ref={ref}\n {...rest}\n >\n {loading ? <LoadingDots /> : children}\n </Element>\n );\n },\n);\n","import { warnAboutMissingStyles } from '@entur/utils';\nimport './index.scss';\n\nwarnAboutMissingStyles('button');\n\nexport * from './Button';\nexport * from './PrimaryButton';\nexport * from './SecondaryButton';\nexport * from './SuccessButton';\nexport * from './NegativeButton';\nexport * from './TertiaryButton';\nexport * from './ButtonGroup';\nexport * from './FloatingButton';\nexport * from './SecondarySquareButton';\nexport * from './SuccessSquareButton';\nexport * from './TertiarySquareButton';\nexport * from './IconButton';\n","import React from 'react';\nimport classNames from 'classnames';\nimport './ButtonGroup.scss';\n\nexport type ButtonGroupProps = {\n /** To eller flere Button-komponenter */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** HTML-elementet eller React-komponenten som lages\n * @default \"div\"\n */\n as?: string | React.ElementType;\n [key: string]: any;\n};\n\nexport const ButtonGroup: React.FC<ButtonGroupProps> = ({\n as: Element = 'div',\n className,\n ...rest\n}) => {\n return (\n <Element className={classNames('eds-button-group', className)} {...rest} />\n );\n};\n","import React from 'react';\nimport classNames from 'classnames';\nimport './FloatingButton.scss';\n\nexport type FloatingButtonProps = {\n /** Beskrivende tekst for skjermlesere */\n 'aria-label': string;\n /** Ikon eller ikon-og-tekst */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Callback når knappen klikkes */\n onClick: (e: React.MouseEvent<HTMLButtonElement>) => void;\n /** Størrelse på knappen\n * @default \"medium\"\n */\n size?: 'medium' | 'small';\n [key: string]: any;\n} & React.ButtonHTMLAttributes<HTMLButtonElement>;\n\nexport const FloatingButton: React.FC<FloatingButtonProps> = ({\n className,\n children,\n size = 'medium',\n ...rest\n}) => {\n return (\n <button\n className={classNames(\n 'eds-floating-button',\n { 'eds-floating-button--extended': React.Children.count(children) > 1 },\n { 'eds-floating-button--small': size === 'small' },\n className,\n )}\n type=\"button\"\n {...rest}\n >\n {wrapStringsInSpans(children)}\n </button>\n );\n};\n\nconst wrapStringsInSpans = (children: React.ReactNode) =>\n React.Children.map(children, child =>\n typeof child === 'string' ? <span>{child}</span> : child,\n );\n"],"names":["Button","React","forwardRef","ref","as","variant","size","loading","className","children","disabled","width","rest","Element","childrenArray","Children","toArray","hasLeadingIcon","length","hasTrailingIcon","cx","LoadingDots","PrimaryButton","props","SecondaryButton","SuccessButton","NegativeButton","TertiaryButton","BaseSquareButton","classNames","map","child","SecondarySquareButton","SuccessSquareButton","TertiarySquareButton","IconButton","warnAboutMissingStyles","count","type","wrapStringsInSpans"],"mappings":"+7BAyCaA,EAGTC,EAAMC,YACR,WAYEC,SAVEC,IAAAA,GACAC,IAAAA,YACAC,KAAAA,aAAO,WACPC,IAAAA,QACAC,IAAAA,UACAC,IAAAA,aACAC,SAAAA,oBACAC,MAAAA,aAAQ,SACLC,SAICC,EAA6BT,GAxBhB,SAyBbU,EAAgBb,EAAMc,SAASC,QAAQP,GACvCQ,EACJH,EAAcI,OAAS,GAAiC,iBAArBJ,EAAc,GAC7CK,EACJL,EAAcI,OAAS,GAC4B,iBAA5CJ,EAAcA,EAAcI,OAAS,UAG5CjB,gBAACY,KACCL,UAAWY,UACT,4CAE0Bf,GAAYA,wBACfC,GAASA,IAC9B,2BAAqC,UAAVK,IAC3B,uBAAuBJ,IACvB,4BAA4BU,IAC5B,6BAA6BE,KAE/BX,GAEFL,IAAKA,cACMI,EACXG,SAAUA,kBACKA,GACXE,GAEHL,EACCN,gBAACoB,eAAYb,UAAU,6BAEvBC,MCrDGa,EAGTrB,UAAMC,YACR,SACEqB,EACApB,UAGOF,wBAACD,KAAOI,GADoBmB,EAAMnB,IAVtB,UAWamB,GAAOpB,IAAKA,EAAKE,QAAQ,gBCThDmB,EAGTvB,UAAMC,YACR,SACEqB,EACApB,UAGOF,wBAACD,KAAOI,GADoBmB,EAAMnB,IAVtB,UAWamB,GAAOpB,IAAKA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GAASoB,GAAOlB,QAAQ,6ECArD8B,EAGTlC,UAAMC,YACR,WAUEC,OAREM,IAAAA,SACAD,IAAAA,cACAE,SAAAA,gBACAJ,IAAAA,KACAF,IAAAA,GACAG,IAAAA,QACGK,gBAMHX,wBAFiCG,GAtBhB,YAyBfI,UAAWqB,UACT,kBACArB,EACA,6BAC+BE,4BAENJ,GAE3BI,SAAUA,kBACKA,EACfP,IAAKA,GACDS,GAEHL,EAAUN,wBAACoB,oBAAiBZ,MCpErC2B,yBAAuB,+CCagC,oBACrDhC,GAAIS,aAAU,QACdL,IAAAA,UACGI,gBAGDX,wBAACY,KAAQL,UAAWqB,UAAW,mBAAoBrB,IAAgBI,4BCFV,gBAC3DJ,IAAAA,UACAC,IAAAA,aACAH,KAAAA,aAAO,WACJM,gBAGDX,oCACEO,UAAWqB,UACT,sBACA,iCAAmC5B,UAAMc,SAASsB,MAAM5B,GAAY,GACpE,8BAAyC,UAATH,GAChCE,GAEF8B,KAAK,UACD1B,GAOiB,SAACH,UAC1BR,UAAMc,SAASe,IAAIrB,GAAU,SAAAsB,SACV,iBAAVA,EAAqB9B,oCAAO8B,GAAgBA,KAPhDQ,CAAmB9B"}
|
package/dist/button.esm.js
CHANGED
|
@@ -1,8 +1,27 @@
|
|
|
1
1
|
import { warnAboutMissingStyles } from '@entur/utils';
|
|
2
|
-
import
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import React__default from 'react';
|
|
3
4
|
import classNames from 'classnames';
|
|
4
5
|
import { LoadingDots } from '@entur/loader';
|
|
5
6
|
|
|
7
|
+
function _extends() {
|
|
8
|
+
_extends = Object.assign || function (target) {
|
|
9
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
10
|
+
var source = arguments[i];
|
|
11
|
+
|
|
12
|
+
for (var key in source) {
|
|
13
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
14
|
+
target[key] = source[key];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return target;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
return _extends.apply(this, arguments);
|
|
23
|
+
}
|
|
24
|
+
|
|
6
25
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
7
26
|
if (source == null) return {};
|
|
8
27
|
var target = {};
|
|
@@ -18,8 +37,9 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
18
37
|
return target;
|
|
19
38
|
}
|
|
20
39
|
|
|
21
|
-
var
|
|
22
|
-
var
|
|
40
|
+
var _excluded$4 = ["as", "variant", "size", "loading", "className", "children", "disabled", "width"];
|
|
41
|
+
var defaultElement$a = 'button';
|
|
42
|
+
var Button = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
23
43
|
var _cx;
|
|
24
44
|
|
|
25
45
|
var as = _ref.as,
|
|
@@ -33,27 +53,27 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
33
53
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
34
54
|
_ref$width = _ref.width,
|
|
35
55
|
width = _ref$width === void 0 ? 'auto' : _ref$width,
|
|
36
|
-
rest = _objectWithoutPropertiesLoose(_ref,
|
|
56
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
37
57
|
|
|
38
|
-
var Element = as || defaultElement;
|
|
39
|
-
var childrenArray = Children.toArray(children);
|
|
58
|
+
var Element = as || defaultElement$a;
|
|
59
|
+
var childrenArray = React.Children.toArray(children);
|
|
40
60
|
var hasLeadingIcon = childrenArray.length > 1 && typeof childrenArray[0] !== 'string';
|
|
41
61
|
var hasTrailingIcon = childrenArray.length > 1 && typeof childrenArray[childrenArray.length - 1] !== 'string';
|
|
42
|
-
return createElement(Element,
|
|
62
|
+
return React.createElement(Element, _extends({
|
|
43
63
|
className: classNames('eds-button', (_cx = {}, _cx["eds-button--variant-" + variant] = variant, _cx["eds-button--size-" + size] = size, _cx['eds-button--width-fluid'] = width === 'fluid', _cx['eds-button--loading'] = loading, _cx['eds-button--leading-icon'] = hasLeadingIcon, _cx['eds-button--trailing-icon'] = hasTrailingIcon, _cx), className),
|
|
44
64
|
ref: ref,
|
|
45
65
|
"aria-busy": loading,
|
|
46
66
|
disabled: disabled,
|
|
47
67
|
"aria-disabled": disabled
|
|
48
|
-
}, rest), loading ? createElement(LoadingDots, {
|
|
68
|
+
}, rest), loading ? React.createElement(LoadingDots, {
|
|
49
69
|
className: "eds-button__loading-dots"
|
|
50
70
|
}) : children);
|
|
51
71
|
});
|
|
52
72
|
|
|
53
|
-
var defaultElement$
|
|
73
|
+
var defaultElement$9 = 'button';
|
|
54
74
|
var PrimaryButton = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
55
|
-
var Element = props.as || defaultElement$
|
|
56
|
-
return React__default.createElement(Button,
|
|
75
|
+
var Element = props.as || defaultElement$9;
|
|
76
|
+
return React__default.createElement(Button, _extends({
|
|
57
77
|
as: Element
|
|
58
78
|
}, props, {
|
|
59
79
|
ref: ref,
|
|
@@ -61,10 +81,10 @@ var PrimaryButton = /*#__PURE__*/React__default.forwardRef(function (props, ref)
|
|
|
61
81
|
}));
|
|
62
82
|
});
|
|
63
83
|
|
|
64
|
-
var defaultElement$
|
|
84
|
+
var defaultElement$8 = 'button';
|
|
65
85
|
var SecondaryButton = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
66
|
-
var Element = props.as || defaultElement$
|
|
67
|
-
return React__default.createElement(Button,
|
|
86
|
+
var Element = props.as || defaultElement$8;
|
|
87
|
+
return React__default.createElement(Button, _extends({
|
|
68
88
|
as: Element
|
|
69
89
|
}, props, {
|
|
70
90
|
ref: ref,
|
|
@@ -72,10 +92,10 @@ var SecondaryButton = /*#__PURE__*/React__default.forwardRef(function (props, re
|
|
|
72
92
|
}));
|
|
73
93
|
});
|
|
74
94
|
|
|
75
|
-
var defaultElement$
|
|
95
|
+
var defaultElement$7 = 'button';
|
|
76
96
|
var SuccessButton = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
77
|
-
var Element = props.as || defaultElement$
|
|
78
|
-
return React__default.createElement(Button,
|
|
97
|
+
var Element = props.as || defaultElement$7;
|
|
98
|
+
return React__default.createElement(Button, _extends({
|
|
79
99
|
as: Element
|
|
80
100
|
}, props, {
|
|
81
101
|
ref: ref,
|
|
@@ -83,10 +103,10 @@ var SuccessButton = /*#__PURE__*/React__default.forwardRef(function (props, ref)
|
|
|
83
103
|
}));
|
|
84
104
|
});
|
|
85
105
|
|
|
86
|
-
var defaultElement$
|
|
106
|
+
var defaultElement$6 = 'button';
|
|
87
107
|
var NegativeButton = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
88
|
-
var Element = props.as || defaultElement$
|
|
89
|
-
return React__default.createElement(Button,
|
|
108
|
+
var Element = props.as || defaultElement$6;
|
|
109
|
+
return React__default.createElement(Button, _extends({
|
|
90
110
|
as: Element
|
|
91
111
|
}, props, {
|
|
92
112
|
ref: ref,
|
|
@@ -97,7 +117,7 @@ var NegativeButton = /*#__PURE__*/React__default.forwardRef(function (props, ref
|
|
|
97
117
|
var defaultElement$5 = 'button';
|
|
98
118
|
var TertiaryButton = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
99
119
|
var Element = props.as || defaultElement$5;
|
|
100
|
-
return React__default.createElement(Button,
|
|
120
|
+
return React__default.createElement(Button, _extends({
|
|
101
121
|
as: Element
|
|
102
122
|
}, props, {
|
|
103
123
|
ref: ref,
|
|
@@ -105,25 +125,27 @@ var TertiaryButton = /*#__PURE__*/React__default.forwardRef(function (props, ref
|
|
|
105
125
|
}));
|
|
106
126
|
});
|
|
107
127
|
|
|
128
|
+
var _excluded$3 = ["as", "className"];
|
|
108
129
|
var ButtonGroup = function ButtonGroup(_ref) {
|
|
109
130
|
var _ref$as = _ref.as,
|
|
110
131
|
Element = _ref$as === void 0 ? 'div' : _ref$as,
|
|
111
132
|
className = _ref.className,
|
|
112
|
-
rest = _objectWithoutPropertiesLoose(_ref,
|
|
133
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
113
134
|
|
|
114
|
-
return React__default.createElement(Element,
|
|
135
|
+
return React__default.createElement(Element, _extends({
|
|
115
136
|
className: classNames('eds-button-group', className)
|
|
116
137
|
}, rest));
|
|
117
138
|
};
|
|
118
139
|
|
|
140
|
+
var _excluded$2 = ["className", "children", "size"];
|
|
119
141
|
var FloatingButton = function FloatingButton(_ref) {
|
|
120
142
|
var className = _ref.className,
|
|
121
143
|
children = _ref.children,
|
|
122
144
|
_ref$size = _ref.size,
|
|
123
145
|
size = _ref$size === void 0 ? 'medium' : _ref$size,
|
|
124
|
-
rest = _objectWithoutPropertiesLoose(_ref,
|
|
146
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
125
147
|
|
|
126
|
-
return React__default.createElement("button",
|
|
148
|
+
return React__default.createElement("button", _extends({
|
|
127
149
|
className: classNames('eds-floating-button', {
|
|
128
150
|
'eds-floating-button--extended': React__default.Children.count(children) > 1
|
|
129
151
|
}, {
|
|
@@ -139,8 +161,9 @@ var wrapStringsInSpans = function wrapStringsInSpans(children) {
|
|
|
139
161
|
});
|
|
140
162
|
};
|
|
141
163
|
|
|
142
|
-
var
|
|
143
|
-
var
|
|
164
|
+
var _excluded$1 = ["children", "className", "variant", "disabled", "loading", "as"];
|
|
165
|
+
var defaultElement$4 = 'button';
|
|
166
|
+
var BaseSquareButton = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
144
167
|
var children = _ref.children,
|
|
145
168
|
className = _ref.className,
|
|
146
169
|
variant = _ref.variant,
|
|
@@ -149,14 +172,16 @@ var BaseSquareButton = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
149
172
|
_ref$loading = _ref.loading,
|
|
150
173
|
loading = _ref$loading === void 0 ? false : _ref$loading,
|
|
151
174
|
as = _ref.as,
|
|
152
|
-
rest = _objectWithoutPropertiesLoose(_ref,
|
|
175
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
153
176
|
|
|
154
|
-
var Element = as || defaultElement$
|
|
155
|
-
return createElement(Element,
|
|
177
|
+
var Element = as || defaultElement$4;
|
|
178
|
+
return React.createElement(Element, _extends({
|
|
156
179
|
className: classNames('eds-square-button', {
|
|
157
180
|
'eds-square-button--success': variant === 'success'
|
|
158
181
|
}, {
|
|
159
182
|
'eds-square-button--secondary': variant === 'secondary'
|
|
183
|
+
}, {
|
|
184
|
+
'eds-square-button--tertiary': variant === 'tertiary'
|
|
160
185
|
}, {
|
|
161
186
|
'eds-square-button--loading': loading
|
|
162
187
|
}, className),
|
|
@@ -164,25 +189,25 @@ var BaseSquareButton = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
164
189
|
disabled: disabled,
|
|
165
190
|
"aria-disabled": disabled,
|
|
166
191
|
ref: ref
|
|
167
|
-
}, rest), Children.map(children, function (child) {
|
|
192
|
+
}, rest), React.Children.map(children, function (child) {
|
|
168
193
|
if (typeof child === 'string') {
|
|
169
|
-
return createElement("span", {
|
|
194
|
+
return React.createElement("span", {
|
|
170
195
|
className: "eds-square-button__label"
|
|
171
196
|
}, child);
|
|
172
197
|
}
|
|
173
198
|
|
|
174
|
-
return createElement("span", {
|
|
199
|
+
return React.createElement("span", {
|
|
175
200
|
className: "eds-square-button__icon"
|
|
176
|
-
}, loading ? createElement(LoadingDots, {
|
|
201
|
+
}, loading ? React.createElement(LoadingDots, {
|
|
177
202
|
className: "eds-square-button__loading-dots"
|
|
178
203
|
}) : child);
|
|
179
204
|
}));
|
|
180
205
|
});
|
|
181
206
|
|
|
182
|
-
var defaultElement$
|
|
207
|
+
var defaultElement$3 = 'button';
|
|
183
208
|
var SecondarySquareButton = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
184
|
-
var Element = props.as || defaultElement$
|
|
185
|
-
return React__default.createElement(BaseSquareButton,
|
|
209
|
+
var Element = props.as || defaultElement$3;
|
|
210
|
+
return React__default.createElement(BaseSquareButton, _extends({
|
|
186
211
|
as: Element,
|
|
187
212
|
ref: ref
|
|
188
213
|
}, props, {
|
|
@@ -190,10 +215,10 @@ var SecondarySquareButton = /*#__PURE__*/React__default.forwardRef(function (pro
|
|
|
190
215
|
}));
|
|
191
216
|
});
|
|
192
217
|
|
|
193
|
-
var defaultElement$
|
|
218
|
+
var defaultElement$2 = 'button';
|
|
194
219
|
var SuccessSquareButton = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
195
|
-
var Element = props.as || defaultElement$
|
|
196
|
-
return React__default.createElement(BaseSquareButton,
|
|
220
|
+
var Element = props.as || defaultElement$2;
|
|
221
|
+
return React__default.createElement(BaseSquareButton, _extends({
|
|
197
222
|
as: Element,
|
|
198
223
|
ref: ref
|
|
199
224
|
}, props, {
|
|
@@ -201,7 +226,19 @@ var SuccessSquareButton = /*#__PURE__*/React__default.forwardRef(function (props
|
|
|
201
226
|
}));
|
|
202
227
|
});
|
|
203
228
|
|
|
204
|
-
var defaultElement$
|
|
229
|
+
var defaultElement$1 = 'button';
|
|
230
|
+
var TertiarySquareButton = /*#__PURE__*/React__default.forwardRef(function (props, ref) {
|
|
231
|
+
var Element = props.as || defaultElement$1;
|
|
232
|
+
return React__default.createElement(BaseSquareButton, _extends({
|
|
233
|
+
as: Element,
|
|
234
|
+
ref: ref
|
|
235
|
+
}, props, {
|
|
236
|
+
variant: "tertiary"
|
|
237
|
+
}));
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
var _excluded = ["children", "className", "disabled", "size", "as", "loading"];
|
|
241
|
+
var defaultElement = 'button';
|
|
205
242
|
var IconButton = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
206
243
|
var children = _ref.children,
|
|
207
244
|
className = _ref.className,
|
|
@@ -210,10 +247,10 @@ var IconButton = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
|
210
247
|
size = _ref.size,
|
|
211
248
|
as = _ref.as,
|
|
212
249
|
loading = _ref.loading,
|
|
213
|
-
rest = _objectWithoutPropertiesLoose(_ref,
|
|
250
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
214
251
|
|
|
215
|
-
var Element = as || defaultElement
|
|
216
|
-
return React__default.createElement(Element,
|
|
252
|
+
var Element = as || defaultElement;
|
|
253
|
+
return React__default.createElement(Element, _extends({
|
|
217
254
|
className: classNames('eds-icon-button', className, {
|
|
218
255
|
'eds-icon-button--disabled': disabled
|
|
219
256
|
}, "eds-icon-button--size-" + size),
|
|
@@ -225,5 +262,5 @@ var IconButton = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
|
225
262
|
|
|
226
263
|
warnAboutMissingStyles('button');
|
|
227
264
|
|
|
228
|
-
export { Button, ButtonGroup, FloatingButton, IconButton, NegativeButton, PrimaryButton, SecondaryButton, SecondarySquareButton, SuccessButton, SuccessSquareButton, TertiaryButton };
|
|
265
|
+
export { Button, ButtonGroup, FloatingButton, IconButton, NegativeButton, PrimaryButton, SecondaryButton, SecondarySquareButton, SuccessButton, SuccessSquareButton, TertiaryButton, TertiarySquareButton };
|
|
229
266
|
//# sourceMappingURL=button.esm.js.map
|
package/dist/button.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.esm.js","sources":["../src/Button.tsx","../src/PrimaryButton.tsx","../src/SecondaryButton.tsx","../src/SuccessButton.tsx","../src/NegativeButton.tsx","../src/TertiaryButton.tsx","../src/ButtonGroup.tsx","../src/FloatingButton.tsx","../src/BaseSquareButton.tsx","../src/SecondarySquareButton.tsx","../src/SuccessSquareButton.tsx","../src/IconButton.tsx","../src/index.tsx"],"sourcesContent":["import * as React from 'react';\nimport cx from 'classnames';\nimport {\n PolymorphicPropsWithoutRef,\n PolymorphicForwardRefExoticComponent,\n PolymorphicPropsWithRef,\n} from '@entur/utils';\nimport { LoadingDots } from '@entur/loader';\nimport './Button.scss';\n\ntype ButtonBaseProps = {\n /** Farge og uttrykk på knappen */\n variant: 'primary' | 'secondary' | 'success' | 'negative' | 'tertiary';\n /** Størrelsen på knappen\n * @default 'medium'\n */\n size?: 'medium' | 'large';\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n /** Ekstra klassenavn */\n className?: string;\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** Bredden på knappen.\n * @default 'auto'\n */\n width?: 'fluid' | 'auto';\n /** Innholdet i knappen */\n children: React.ReactNode;\n};\n\nconst defaultElement = 'button';\n\nexport type ButtonProps<\n T extends React.ElementType = typeof defaultElement\n> = PolymorphicPropsWithRef<ButtonBaseProps, T>;\n\nexport const Button: PolymorphicForwardRefExoticComponent<\n ButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <T extends React.ElementType = typeof defaultElement>(\n {\n as,\n variant,\n size = 'medium',\n loading,\n className,\n children,\n disabled = false,\n width = 'auto',\n ...rest\n }: PolymorphicPropsWithoutRef<ButtonBaseProps, T>,\n ref: React.ForwardedRef<React.ElementRef<T>>,\n ) => {\n const Element: React.ElementType = as || defaultElement;\n const childrenArray = React.Children.toArray(children);\n const hasLeadingIcon =\n childrenArray.length > 1 && typeof childrenArray[0] !== 'string';\n const hasTrailingIcon =\n childrenArray.length > 1 &&\n typeof childrenArray[childrenArray.length - 1] !== 'string';\n\n return (\n <Element\n className={cx(\n 'eds-button',\n {\n [`eds-button--variant-${variant}`]: variant,\n [`eds-button--size-${size}`]: size,\n 'eds-button--width-fluid': width === 'fluid',\n 'eds-button--loading': loading,\n 'eds-button--leading-icon': hasLeadingIcon,\n 'eds-button--trailing-icon': hasTrailingIcon,\n },\n className,\n )}\n ref={ref}\n aria-busy={loading}\n disabled={disabled}\n aria-disabled={disabled}\n {...rest}\n >\n {loading ? (\n <LoadingDots className=\"eds-button__loading-dots\" />\n ) : (\n children\n )}\n </Element>\n );\n },\n);\n","import React from 'react';\nimport { Button } from './Button';\nimport {\n PolymorphicPropsWithoutRef,\n PolymorphicForwardRefExoticComponent,\n PolymorphicPropsWithRef,\n} from '@entur/utils';\n\nexport type PrimaryButtonBaseProps = {\n /** Størrelsen på knappen\n * @default 'medium'\n */\n size?: 'medium' | 'large';\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n /** Ekstra klassenavn */\n className?: string;\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** Bredden på knappen.\n * @default 'auto'\n */\n width?: 'fluid' | 'auto';\n /** Innholdet i knappen */\n children: React.ReactNode;\n};\n\nexport type PrimaryButtonProps<\n T extends React.ElementType = typeof defaultElement\n> = PolymorphicPropsWithRef<PrimaryButtonBaseProps, T>;\n\nconst defaultElement = 'button';\n\nexport const PrimaryButton: PolymorphicForwardRefExoticComponent<\n PrimaryButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <T extends React.ElementType = typeof defaultElement>(\n props: PolymorphicPropsWithoutRef<PrimaryButtonBaseProps, T>,\n ref: React.ForwardedRef<React.ElementRef<T>>,\n ) => {\n const Element: React.ElementType = props.as || defaultElement;\n return <Button as={Element} {...props} ref={ref} variant=\"primary\" />;\n },\n);\n","import React from 'react';\nimport { Button } from './Button';\nimport {\n PolymorphicForwardRefExoticComponent,\n PolymorphicPropsWithRef,\n PolymorphicPropsWithoutRef,\n} from '@entur/utils';\n\nexport type SecondaryButtonBaseProps = {\n /** Størrelsen på knappen\n * @default 'medium'\n */\n size?: 'medium' | 'large';\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n /** Ekstra klassenavn */\n className?: string;\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** Bredden på knappen\n * @default 'auto'\n */\n width?: 'fluid' | 'auto';\n /** Innholdet i knappen */\n children: React.ReactNode;\n};\n\nexport type SecondaryButtonProps<\n T extends React.ElementType = typeof defaultElement\n> = PolymorphicPropsWithRef<SecondaryButtonBaseProps, T>;\n\nconst defaultElement = 'button';\n\nexport const SecondaryButton: PolymorphicForwardRefExoticComponent<\n SecondaryButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <T extends React.ElementType = typeof defaultElement>(\n props: PolymorphicPropsWithoutRef<SecondaryButtonBaseProps, T>,\n ref: React.ForwardedRef<React.ElementRef<T>>,\n ) => {\n const Element: React.ElementType = props.as || defaultElement;\n return <Button as={Element} {...props} ref={ref} variant=\"secondary\" />;\n },\n);\n","import React from 'react';\nimport { Button } from './Button';\nimport {\n PolymorphicPropsWithoutRef,\n PolymorphicForwardRefExoticComponent,\n PolymorphicPropsWithRef,\n} from '@entur/utils';\n\ntype SuccessButtonBaseProps = {\n /** Størrelsen på knappen\n * @default 'medium'\n */\n size?: 'medium' | 'large';\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n /** Ekstra klassenavn */\n className?: string;\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** Bredden på knappen\n * @default 'auto'\n */\n width?: 'fluid' | 'auto';\n /** Innholdet i knappen */\n children: React.ReactNode;\n};\n\nexport type SuccessButtonProps<\n E extends React.ElementType = typeof defaultElement\n> = PolymorphicPropsWithRef<SuccessButtonBaseProps, E>;\n\nconst defaultElement = 'button';\n\nexport const SuccessButton: PolymorphicForwardRefExoticComponent<\n SuccessButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <T extends React.ElementType = typeof defaultElement>(\n props: PolymorphicPropsWithoutRef<SuccessButtonBaseProps, T>,\n ref: React.ForwardedRef<React.ElementRef<T>>,\n ) => {\n const Element: React.ElementType = props.as || defaultElement;\n return <Button as={Element} {...props} ref={ref} variant=\"success\" />;\n },\n);\n","import React from 'react';\nimport { Button } from './Button';\nimport {\n PolymorphicPropsWithoutRef,\n PolymorphicPropsWithRef,\n PolymorphicForwardRefExoticComponent,\n} from '@entur/utils';\n\nexport type NegativeButtonBaseProps = {\n /** Størrelsen på knappen\n * @default 'medium'\n */\n size?: 'medium' | 'large';\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n /** Ekstra klassenavn */\n className?: string;\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** Bredden på knappen.\n * @default 'auto'\n */\n width?: 'fluid' | 'auto';\n /** Innholdet i knappen */\n children: React.ReactNode;\n as?: 'button' | React.ElementType;\n};\n\nexport type NegativeButtonProps<\n T extends React.ElementType = typeof defaultElement\n> = PolymorphicPropsWithRef<NegativeButtonBaseProps, T>;\n\nconst defaultElement = 'button';\n\nexport const NegativeButton: PolymorphicForwardRefExoticComponent<\n NegativeButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <T extends React.ElementType = typeof defaultElement>(\n props: PolymorphicPropsWithoutRef<NegativeButtonBaseProps, T>,\n ref: React.ForwardedRef<React.ElementRef<T>>,\n ) => {\n const Element: React.ElementType = props.as || defaultElement;\n return <Button as={Element} {...props} ref={ref} variant=\"negative\" />;\n },\n);\n","import React from 'react';\nimport { Button } from './Button';\nimport {\n PolymorphicPropsWithoutRef,\n PolymorphicPropsWithRef,\n PolymorphicForwardRefExoticComponent,\n} from '@entur/utils';\n\nexport type TertiaryButtonBaseProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n /** Innholdet i knappen */\n children: React.ReactNode;\n};\n\nexport type TertiaryButtonProps<\n E extends React.ElementType = typeof defaultElement\n> = PolymorphicPropsWithRef<TertiaryButtonBaseProps, E>;\n\nconst defaultElement = 'button';\n\nexport const TertiaryButton: PolymorphicForwardRefExoticComponent<\n TertiaryButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <T extends React.ElementType = typeof defaultElement>(\n props: PolymorphicPropsWithoutRef<TertiaryButtonBaseProps, T>,\n ref: React.ForwardedRef<React.ElementRef<T>>,\n ) => {\n const Element: React.ElementType = props.as || defaultElement;\n return <Button as={Element} {...props} ref={ref} variant=\"tertiary\" />;\n },\n);\n","import React from 'react';\nimport classNames from 'classnames';\nimport './ButtonGroup.scss';\n\nexport type ButtonGroupProps = {\n /** To eller flere Button-komponenter */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** HTML-elementet eller React-komponenten som lages\n * @default \"div\"\n */\n as?: string | React.ElementType;\n [key: string]: any;\n};\n\nexport const ButtonGroup: React.FC<ButtonGroupProps> = ({\n as: Element = 'div',\n className,\n ...rest\n}) => {\n return (\n <Element className={classNames('eds-button-group', className)} {...rest} />\n );\n};\n","import React from 'react';\nimport classNames from 'classnames';\nimport './FloatingButton.scss';\n\nexport type FloatingButtonProps = {\n /** Beskrivende tekst for skjermlesere */\n 'aria-label': string;\n /** Ikon eller ikon-og-tekst */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Callback når knappen klikkes */\n onClick: (e: React.MouseEvent<HTMLButtonElement>) => void;\n /** Størrelse på knappen\n * @default \"medium\"\n */\n size?: 'medium' | 'small';\n [key: string]: any;\n} & React.ButtonHTMLAttributes<HTMLButtonElement>;\n\nexport const FloatingButton: React.FC<FloatingButtonProps> = ({\n className,\n children,\n size = 'medium',\n ...rest\n}) => {\n return (\n <button\n className={classNames(\n 'eds-floating-button',\n { 'eds-floating-button--extended': React.Children.count(children) > 1 },\n { 'eds-floating-button--small': size === 'small' },\n className,\n )}\n type=\"button\"\n {...rest}\n >\n {wrapStringsInSpans(children)}\n </button>\n );\n};\n\nconst wrapStringsInSpans = (children: React.ReactNode) =>\n React.Children.map(children, child =>\n typeof child === 'string' ? <span>{child}</span> : child,\n );\n","import * as React from 'react';\nimport classNames from 'classnames';\nimport {\n PolymorphicPropsWithoutRef,\n PolymorphicForwardRefExoticComponent,\n PolymorphicPropsWithRef,\n} from '@entur/utils';\nimport { LoadingDots } from '@entur/loader';\nimport './BaseSquareButton.scss';\n\nexport type BaseSquareButtonBaseProps = {\n /** Tekst og ikon */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** En type knapp */\n variant: 'success' | 'secondary';\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n};\n\nexport type BaseSquareButtonProps<\n T extends React.ElementType = typeof defaultElement\n> = PolymorphicPropsWithRef<BaseSquareButtonBaseProps, T>;\n\nconst defaultElement = 'button';\n\nexport const BaseSquareButton: PolymorphicForwardRefExoticComponent<\n BaseSquareButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <T extends React.ElementType = typeof defaultElement>(\n {\n children,\n className,\n variant,\n disabled = false,\n loading = false,\n as,\n ...rest\n }: PolymorphicPropsWithoutRef<BaseSquareButtonBaseProps, T>,\n ref: React.ForwardedRef<React.ElementRef<T>>,\n ) => {\n const Element: React.ElementType = as || defaultElement;\n return (\n <Element\n className={classNames(\n 'eds-square-button',\n { 'eds-square-button--success': variant === 'success' },\n { 'eds-square-button--secondary': variant === 'secondary' },\n { 'eds-square-button--loading': loading },\n className,\n )}\n aria-busy={loading}\n disabled={disabled}\n aria-disabled={disabled}\n ref={ref}\n {...rest}\n >\n {React.Children.map(children, child => {\n if (typeof child === 'string') {\n return <span className=\"eds-square-button__label\">{child}</span>;\n }\n return (\n <span className=\"eds-square-button__icon\">\n {loading ? (\n <LoadingDots className=\"eds-square-button__loading-dots\" />\n ) : (\n child\n )}\n </span>\n );\n })}\n </Element>\n );\n },\n);\n","import React from 'react';\nimport { BaseSquareButton } from './BaseSquareButton';\nimport {\n PolymorphicForwardRefExoticComponent,\n PolymorphicPropsWithoutRef,\n PolymorphicPropsWithRef,\n} from '@entur/utils';\n\nexport type SecondarySquareButtonBaseProps = {\n /** Tekst og ikon, ikon og tekst, eller bare ikon */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n};\n\nexport type SecondarySquareButtonProps<\n E extends React.ElementType = typeof defaultElement\n> = PolymorphicPropsWithRef<SecondarySquareButtonBaseProps, E>;\n\nconst defaultElement = 'button';\n\nexport const SecondarySquareButton: PolymorphicForwardRefExoticComponent<\n SecondarySquareButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <T extends React.ElementType = typeof defaultElement>(\n props: PolymorphicPropsWithoutRef<SecondarySquareButtonBaseProps, T>,\n ref: React.ForwardedRef<React.ElementRef<T>>,\n ) => {\n const Element: React.ElementType = props.as || defaultElement;\n return (\n <BaseSquareButton as={Element} ref={ref} {...props} variant=\"secondary\" />\n );\n },\n);\n","import React from 'react';\nimport { BaseSquareButton } from './BaseSquareButton';\nimport {\n PolymorphicForwardRefExoticComponent,\n PolymorphicPropsWithRef,\n PolymorphicPropsWithoutRef,\n} from '@entur/utils';\n\ntype SuccessSquareButtonBaseProps = {\n /** Tekst og ikon, ikon og tekst, eller bare ikon */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n};\n\nexport type SuccessSquareButtonProps<\n E extends React.ElementType = typeof defaultElement\n> = PolymorphicPropsWithRef<SuccessSquareButtonBaseProps, E>;\n\nconst defaultElement = 'button';\n\nexport const SuccessSquareButton: PolymorphicForwardRefExoticComponent<\n SuccessSquareButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <T extends React.ElementType = typeof defaultElement>(\n props: PolymorphicPropsWithoutRef<SuccessSquareButtonBaseProps, T>,\n ref: React.ForwardedRef<React.ElementRef<T>>,\n ) => {\n const Element: React.ElementType = props.as || defaultElement;\n return (\n <BaseSquareButton as={Element} ref={ref} {...props} variant=\"success\" />\n );\n },\n);\n","import React from 'react';\nimport classNames from 'classnames';\nimport {\n PolymorphicPropsWithoutRef,\n PolymorphicForwardRefExoticComponent,\n PolymorphicPropsWithRef,\n} from '@entur/utils';\nimport { LoadingDots } from '@entur/loader';\nimport './IconButton.scss';\n\nexport type IconButtonBaseProps = {\n /** Ikonet som du vil ha inne i knappen */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** HTML-elementet eller React-komponenten som lager knappen\n * @default 'button'\n */\n as?: React.ElementType;\n /**Størrelsen på knappen\n * @default \"medium\"\n */\n size?: 'small' | 'medium';\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n};\n\nconst defaultElement = 'button';\n\nexport type IconButtonProps<\n E extends React.ElementType = typeof defaultElement\n> = PolymorphicPropsWithRef<IconButtonBaseProps, E>;\n\nexport const IconButton: PolymorphicForwardRefExoticComponent<\n IconButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <E extends React.ElementType = typeof defaultElement>(\n {\n children,\n className,\n disabled = false,\n size,\n as,\n loading,\n ...rest\n }: PolymorphicPropsWithoutRef<IconButtonBaseProps, E>,\n ref: React.ForwardedRef<React.ElementRef<E>>,\n ) => {\n const Element: React.ElementType = as || defaultElement;\n return (\n <Element\n className={classNames(\n 'eds-icon-button',\n className,\n {\n 'eds-icon-button--disabled': disabled,\n },\n `eds-icon-button--size-${size}`,\n )}\n disabled={disabled}\n aria-disabled={disabled}\n ref={ref}\n {...rest}\n >\n {loading ? <LoadingDots /> : children}\n </Element>\n );\n },\n);\n","import { warnAboutMissingStyles } from '@entur/utils';\nimport './index.scss';\n\nwarnAboutMissingStyles('button');\n\nexport * from './Button';\nexport * from './PrimaryButton';\nexport * from './SecondaryButton';\nexport * from './SuccessButton';\nexport * from './NegativeButton';\nexport * from './TertiaryButton';\nexport * from './ButtonGroup';\nexport * from './FloatingButton';\nexport * from './SecondarySquareButton';\nexport * from './SuccessSquareButton';\nexport * from './IconButton';\n"],"names":["defaultElement","Button","React","ref","as","variant","size","loading","className","children","disabled","width","rest","Element","childrenArray","toArray","hasLeadingIcon","length","hasTrailingIcon","cx","LoadingDots","PrimaryButton","forwardRef","props","SecondaryButton","SuccessButton","NegativeButton","TertiaryButton","ButtonGroup","classNames","FloatingButton","Children","count","type","wrapStringsInSpans","map","child","BaseSquareButton","SecondarySquareButton","SuccessSquareButton","IconButton","warnAboutMissingStyles"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmCA,IAAMA,cAAc,GAAG,QAAvB;IAMaC,MAAM,gBAGfC,UAAA,CACF,gBAYEC,GAZF;;;MAEIC,UAAAA;MACAC,eAAAA;uBACAC;MAAAA,8BAAO;MACPC,eAAAA;MACAC,iBAAAA;MACAC,gBAAAA;2BACAC;MAAAA,sCAAW;wBACXC;MAAAA,gCAAQ;MACLC;;AAIL,MAAMC,OAAO,GAAsBT,EAAE,IAAIJ,cAAzC;AACA,MAAMc,aAAa,GAAGZ,QAAA,CAAea,OAAf,CAAuBN,QAAvB,CAAtB;AACA,MAAMO,cAAc,GAClBF,aAAa,CAACG,MAAd,GAAuB,CAAvB,IAA4B,OAAOH,aAAa,CAAC,CAAD,CAApB,KAA4B,QAD1D;AAEA,MAAMI,eAAe,GACnBJ,aAAa,CAACG,MAAd,GAAuB,CAAvB,IACA,OAAOH,aAAa,CAACA,aAAa,CAACG,MAAd,GAAuB,CAAxB,CAApB,KAAmD,QAFrD;AAIA,SACEf,aAAA,CAACW,OAAD;AACEL,IAAAA,SAAS,EAAEW,UAAE,CACX,YADW,0CAGed,OAHf,IAG2BA,OAH3B,4BAIYC,IAJZ,IAIqBA,IAJrB,MAKT,yBALS,IAKkBK,KAAK,KAAK,OAL5B,MAMT,qBANS,IAMcJ,OANd,MAOT,0BAPS,IAOmBS,cAPnB,MAQT,2BARS,IAQoBE,eARpB,QAUXV,SAVW;AAYbL,IAAAA,GAAG,EAAEA;iBACMI;AACXG,IAAAA,QAAQ,EAAEA;qBACKA;KACXE,KAjBN,EAmBGL,OAAO,GACNL,aAAA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../src/Button.tsx","../src/PrimaryButton.tsx","../src/SecondaryButton.tsx","../src/SuccessButton.tsx","../src/NegativeButton.tsx","../src/TertiaryButton.tsx","../src/ButtonGroup.tsx","../src/FloatingButton.tsx","../src/BaseSquareButton.tsx","../src/SecondarySquareButton.tsx","../src/SuccessSquareButton.tsx","../src/TertiarySquareButton.tsx","../src/IconButton.tsx","../src/index.tsx"],"sourcesContent":["import * as React from 'react';\nimport cx from 'classnames';\nimport {\n PolymorphicPropsWithoutRef,\n PolymorphicForwardRefExoticComponent,\n PolymorphicPropsWithRef,\n} from '@entur/utils';\nimport { LoadingDots } from '@entur/loader';\nimport './Button.scss';\n\ntype ButtonBaseProps = {\n /** Farge og uttrykk på knappen */\n variant: 'primary' | 'secondary' | 'success' | 'negative' | 'tertiary';\n /** Størrelsen på knappen\n * @default 'medium'\n */\n size?: 'medium' | 'large';\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n /** Ekstra klassenavn */\n className?: string;\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** Bredden på knappen.\n * @default 'auto'\n */\n width?: 'fluid' | 'auto';\n /** Innholdet i knappen */\n children: React.ReactNode;\n};\n\nconst defaultElement = 'button';\n\nexport type ButtonProps<\n T extends React.ElementType = typeof defaultElement\n> = PolymorphicPropsWithRef<ButtonBaseProps, T>;\n\nexport const Button: PolymorphicForwardRefExoticComponent<\n ButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <T extends React.ElementType = typeof defaultElement>(\n {\n as,\n variant,\n size = 'medium',\n loading,\n className,\n children,\n disabled = false,\n width = 'auto',\n ...rest\n }: PolymorphicPropsWithoutRef<ButtonBaseProps, T>,\n ref: React.ForwardedRef<React.ElementRef<T>>,\n ) => {\n const Element: React.ElementType = as || defaultElement;\n const childrenArray = React.Children.toArray(children);\n const hasLeadingIcon =\n childrenArray.length > 1 && typeof childrenArray[0] !== 'string';\n const hasTrailingIcon =\n childrenArray.length > 1 &&\n typeof childrenArray[childrenArray.length - 1] !== 'string';\n\n return (\n <Element\n className={cx(\n 'eds-button',\n {\n [`eds-button--variant-${variant}`]: variant,\n [`eds-button--size-${size}`]: size,\n 'eds-button--width-fluid': width === 'fluid',\n 'eds-button--loading': loading,\n 'eds-button--leading-icon': hasLeadingIcon,\n 'eds-button--trailing-icon': hasTrailingIcon,\n },\n className,\n )}\n ref={ref}\n aria-busy={loading}\n disabled={disabled}\n aria-disabled={disabled}\n {...rest}\n >\n {loading ? (\n <LoadingDots className=\"eds-button__loading-dots\" />\n ) : (\n children\n )}\n </Element>\n );\n },\n);\n","import React from 'react';\nimport { Button } from './Button';\nimport {\n PolymorphicPropsWithoutRef,\n PolymorphicForwardRefExoticComponent,\n PolymorphicPropsWithRef,\n} from '@entur/utils';\n\nexport type PrimaryButtonBaseProps = {\n /** Størrelsen på knappen\n * @default 'medium'\n */\n size?: 'medium' | 'large';\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n /** Ekstra klassenavn */\n className?: string;\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** Bredden på knappen.\n * @default 'auto'\n */\n width?: 'fluid' | 'auto';\n /** Innholdet i knappen */\n children: React.ReactNode;\n};\n\nexport type PrimaryButtonProps<\n T extends React.ElementType = typeof defaultElement\n> = PolymorphicPropsWithRef<PrimaryButtonBaseProps, T>;\n\nconst defaultElement = 'button';\n\nexport const PrimaryButton: PolymorphicForwardRefExoticComponent<\n PrimaryButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <T extends React.ElementType = typeof defaultElement>(\n props: PolymorphicPropsWithoutRef<PrimaryButtonBaseProps, T>,\n ref: React.ForwardedRef<React.ElementRef<T>>,\n ) => {\n const Element: React.ElementType = props.as || defaultElement;\n return <Button as={Element} {...props} ref={ref} variant=\"primary\" />;\n },\n);\n","import React from 'react';\nimport { Button } from './Button';\nimport {\n PolymorphicForwardRefExoticComponent,\n PolymorphicPropsWithRef,\n PolymorphicPropsWithoutRef,\n} from '@entur/utils';\n\nexport type SecondaryButtonBaseProps = {\n /** Størrelsen på knappen\n * @default 'medium'\n */\n size?: 'medium' | 'large';\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n /** Ekstra klassenavn */\n className?: string;\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** Bredden på knappen\n * @default 'auto'\n */\n width?: 'fluid' | 'auto';\n /** Innholdet i knappen */\n children: React.ReactNode;\n};\n\nexport type SecondaryButtonProps<\n T extends React.ElementType = typeof defaultElement\n> = PolymorphicPropsWithRef<SecondaryButtonBaseProps, T>;\n\nconst defaultElement = 'button';\n\nexport const SecondaryButton: PolymorphicForwardRefExoticComponent<\n SecondaryButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <T extends React.ElementType = typeof defaultElement>(\n props: PolymorphicPropsWithoutRef<SecondaryButtonBaseProps, T>,\n ref: React.ForwardedRef<React.ElementRef<T>>,\n ) => {\n const Element: React.ElementType = props.as || defaultElement;\n return <Button as={Element} {...props} ref={ref} variant=\"secondary\" />;\n },\n);\n","import React from 'react';\nimport { Button } from './Button';\nimport {\n PolymorphicPropsWithoutRef,\n PolymorphicForwardRefExoticComponent,\n PolymorphicPropsWithRef,\n} from '@entur/utils';\n\ntype SuccessButtonBaseProps = {\n /** Størrelsen på knappen\n * @default 'medium'\n */\n size?: 'medium' | 'large';\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n /** Ekstra klassenavn */\n className?: string;\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** Bredden på knappen\n * @default 'auto'\n */\n width?: 'fluid' | 'auto';\n /** Innholdet i knappen */\n children: React.ReactNode;\n};\n\nexport type SuccessButtonProps<\n E extends React.ElementType = typeof defaultElement\n> = PolymorphicPropsWithRef<SuccessButtonBaseProps, E>;\n\nconst defaultElement = 'button';\n\nexport const SuccessButton: PolymorphicForwardRefExoticComponent<\n SuccessButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <T extends React.ElementType = typeof defaultElement>(\n props: PolymorphicPropsWithoutRef<SuccessButtonBaseProps, T>,\n ref: React.ForwardedRef<React.ElementRef<T>>,\n ) => {\n const Element: React.ElementType = props.as || defaultElement;\n return <Button as={Element} {...props} ref={ref} variant=\"success\" />;\n },\n);\n","import React from 'react';\nimport { Button } from './Button';\nimport {\n PolymorphicPropsWithoutRef,\n PolymorphicPropsWithRef,\n PolymorphicForwardRefExoticComponent,\n} from '@entur/utils';\n\nexport type NegativeButtonBaseProps = {\n /** Størrelsen på knappen\n * @default 'medium'\n */\n size?: 'medium' | 'large';\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n /** Ekstra klassenavn */\n className?: string;\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** Bredden på knappen.\n * @default 'auto'\n */\n width?: 'fluid' | 'auto';\n /** Innholdet i knappen */\n children: React.ReactNode;\n as?: 'button' | React.ElementType;\n};\n\nexport type NegativeButtonProps<\n T extends React.ElementType = typeof defaultElement\n> = PolymorphicPropsWithRef<NegativeButtonBaseProps, T>;\n\nconst defaultElement = 'button';\n\nexport const NegativeButton: PolymorphicForwardRefExoticComponent<\n NegativeButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <T extends React.ElementType = typeof defaultElement>(\n props: PolymorphicPropsWithoutRef<NegativeButtonBaseProps, T>,\n ref: React.ForwardedRef<React.ElementRef<T>>,\n ) => {\n const Element: React.ElementType = props.as || defaultElement;\n return <Button as={Element} {...props} ref={ref} variant=\"negative\" />;\n },\n);\n","import React from 'react';\nimport { Button } from './Button';\nimport {\n PolymorphicPropsWithoutRef,\n PolymorphicPropsWithRef,\n PolymorphicForwardRefExoticComponent,\n} from '@entur/utils';\n\nexport type TertiaryButtonBaseProps = {\n /** Ekstra klassenavn */\n className?: string;\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n /** Innholdet i knappen */\n children: React.ReactNode;\n};\n\nexport type TertiaryButtonProps<\n E extends React.ElementType = typeof defaultElement\n> = PolymorphicPropsWithRef<TertiaryButtonBaseProps, E>;\n\nconst defaultElement = 'button';\n\nexport const TertiaryButton: PolymorphicForwardRefExoticComponent<\n TertiaryButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <T extends React.ElementType = typeof defaultElement>(\n props: PolymorphicPropsWithoutRef<TertiaryButtonBaseProps, T>,\n ref: React.ForwardedRef<React.ElementRef<T>>,\n ) => {\n const Element: React.ElementType = props.as || defaultElement;\n return <Button as={Element} {...props} ref={ref} variant=\"tertiary\" />;\n },\n);\n","import React from 'react';\nimport classNames from 'classnames';\nimport './ButtonGroup.scss';\n\nexport type ButtonGroupProps = {\n /** To eller flere Button-komponenter */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** HTML-elementet eller React-komponenten som lages\n * @default \"div\"\n */\n as?: string | React.ElementType;\n [key: string]: any;\n};\n\nexport const ButtonGroup: React.FC<ButtonGroupProps> = ({\n as: Element = 'div',\n className,\n ...rest\n}) => {\n return (\n <Element className={classNames('eds-button-group', className)} {...rest} />\n );\n};\n","import React from 'react';\nimport classNames from 'classnames';\nimport './FloatingButton.scss';\n\nexport type FloatingButtonProps = {\n /** Beskrivende tekst for skjermlesere */\n 'aria-label': string;\n /** Ikon eller ikon-og-tekst */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Callback når knappen klikkes */\n onClick: (e: React.MouseEvent<HTMLButtonElement>) => void;\n /** Størrelse på knappen\n * @default \"medium\"\n */\n size?: 'medium' | 'small';\n [key: string]: any;\n} & React.ButtonHTMLAttributes<HTMLButtonElement>;\n\nexport const FloatingButton: React.FC<FloatingButtonProps> = ({\n className,\n children,\n size = 'medium',\n ...rest\n}) => {\n return (\n <button\n className={classNames(\n 'eds-floating-button',\n { 'eds-floating-button--extended': React.Children.count(children) > 1 },\n { 'eds-floating-button--small': size === 'small' },\n className,\n )}\n type=\"button\"\n {...rest}\n >\n {wrapStringsInSpans(children)}\n </button>\n );\n};\n\nconst wrapStringsInSpans = (children: React.ReactNode) =>\n React.Children.map(children, child =>\n typeof child === 'string' ? <span>{child}</span> : child,\n );\n","import * as React from 'react';\nimport classNames from 'classnames';\nimport {\n PolymorphicPropsWithoutRef,\n PolymorphicForwardRefExoticComponent,\n PolymorphicPropsWithRef,\n} from '@entur/utils';\nimport { LoadingDots } from '@entur/loader';\nimport './BaseSquareButton.scss';\n\nexport type BaseSquareButtonBaseProps = {\n /** Tekst og ikon */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** En type knapp */\n variant: 'success' | 'secondary' | 'tertiary';\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n};\n\nexport type BaseSquareButtonProps<\n T extends React.ElementType = typeof defaultElement,\n> = PolymorphicPropsWithRef<BaseSquareButtonBaseProps, T>;\n\nconst defaultElement = 'button';\n\nexport const BaseSquareButton: PolymorphicForwardRefExoticComponent<\n BaseSquareButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <T extends React.ElementType = typeof defaultElement>(\n {\n children,\n className,\n variant,\n disabled = false,\n loading = false,\n as,\n ...rest\n }: PolymorphicPropsWithoutRef<BaseSquareButtonBaseProps, T>,\n ref: React.ForwardedRef<React.ElementRef<T>>,\n ) => {\n const Element: React.ElementType = as || defaultElement;\n return (\n <Element\n className={classNames(\n 'eds-square-button',\n { 'eds-square-button--success': variant === 'success' },\n { 'eds-square-button--secondary': variant === 'secondary' },\n { 'eds-square-button--tertiary': variant === 'tertiary' },\n { 'eds-square-button--loading': loading },\n className,\n )}\n aria-busy={loading}\n disabled={disabled}\n aria-disabled={disabled}\n ref={ref}\n {...rest}\n >\n {React.Children.map(children, child => {\n if (typeof child === 'string') {\n return <span className=\"eds-square-button__label\">{child}</span>;\n }\n return (\n <span className=\"eds-square-button__icon\">\n {loading ? (\n <LoadingDots className=\"eds-square-button__loading-dots\" />\n ) : (\n child\n )}\n </span>\n );\n })}\n </Element>\n );\n },\n);\n","import React from 'react';\nimport { BaseSquareButton } from './BaseSquareButton';\nimport {\n PolymorphicForwardRefExoticComponent,\n PolymorphicPropsWithoutRef,\n PolymorphicPropsWithRef,\n} from '@entur/utils';\n\nexport type SecondarySquareButtonBaseProps = {\n /** Tekst og ikon, ikon og tekst, eller bare ikon */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n};\n\nexport type SecondarySquareButtonProps<\n E extends React.ElementType = typeof defaultElement\n> = PolymorphicPropsWithRef<SecondarySquareButtonBaseProps, E>;\n\nconst defaultElement = 'button';\n\nexport const SecondarySquareButton: PolymorphicForwardRefExoticComponent<\n SecondarySquareButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <T extends React.ElementType = typeof defaultElement>(\n props: PolymorphicPropsWithoutRef<SecondarySquareButtonBaseProps, T>,\n ref: React.ForwardedRef<React.ElementRef<T>>,\n ) => {\n const Element: React.ElementType = props.as || defaultElement;\n return (\n <BaseSquareButton as={Element} ref={ref} {...props} variant=\"secondary\" />\n );\n },\n);\n","import React from 'react';\nimport { BaseSquareButton } from './BaseSquareButton';\nimport {\n PolymorphicForwardRefExoticComponent,\n PolymorphicPropsWithRef,\n PolymorphicPropsWithoutRef,\n} from '@entur/utils';\n\ntype SuccessSquareButtonBaseProps = {\n /** Tekst og ikon, ikon og tekst, eller bare ikon */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n};\n\nexport type SuccessSquareButtonProps<\n E extends React.ElementType = typeof defaultElement\n> = PolymorphicPropsWithRef<SuccessSquareButtonBaseProps, E>;\n\nconst defaultElement = 'button';\n\nexport const SuccessSquareButton: PolymorphicForwardRefExoticComponent<\n SuccessSquareButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <T extends React.ElementType = typeof defaultElement>(\n props: PolymorphicPropsWithoutRef<SuccessSquareButtonBaseProps, T>,\n ref: React.ForwardedRef<React.ElementRef<T>>,\n ) => {\n const Element: React.ElementType = props.as || defaultElement;\n return (\n <BaseSquareButton as={Element} ref={ref} {...props} variant=\"success\" />\n );\n },\n);\n","import React from 'react';\nimport { BaseSquareButton } from './BaseSquareButton';\nimport {\n PolymorphicForwardRefExoticComponent,\n PolymorphicPropsWithoutRef,\n PolymorphicPropsWithRef,\n} from '@entur/utils';\n\nexport type TertiarySquareButtonBaseProps = {\n /** Tekst og ikon, ikon og tekst, eller bare ikon */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n};\n\nexport type TertiarySquareButtonProps<\n E extends React.ElementType = typeof defaultElement,\n> = PolymorphicPropsWithRef<TertiarySquareButtonBaseProps, E>;\n\nconst defaultElement = 'button';\n\nexport const TertiarySquareButton: PolymorphicForwardRefExoticComponent<\n TertiarySquareButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <T extends React.ElementType = typeof defaultElement>(\n props: PolymorphicPropsWithoutRef<TertiarySquareButtonBaseProps, T>,\n ref: React.ForwardedRef<React.ElementRef<T>>,\n ) => {\n const Element: React.ElementType = props.as || defaultElement;\n return (\n <BaseSquareButton as={Element} ref={ref} {...props} variant=\"tertiary\" />\n );\n },\n);\n","import React from 'react';\nimport classNames from 'classnames';\nimport {\n PolymorphicPropsWithoutRef,\n PolymorphicForwardRefExoticComponent,\n PolymorphicPropsWithRef,\n} from '@entur/utils';\nimport { LoadingDots } from '@entur/loader';\nimport './IconButton.scss';\n\nexport type IconButtonBaseProps = {\n /** Ikonet som du vil ha inne i knappen */\n children: React.ReactNode;\n /** Ekstra klassenavn */\n className?: string;\n /** Deaktivering av knappen\n * @default false\n */\n disabled?: boolean;\n /** HTML-elementet eller React-komponenten som lager knappen\n * @default 'button'\n */\n as?: React.ElementType;\n /**Størrelsen på knappen\n * @default \"medium\"\n */\n size?: 'small' | 'medium';\n /** Om knappen er opptatt, f.eks. med å lagre eller å kjøpe\n * @default false\n */\n loading?: boolean;\n};\n\nconst defaultElement = 'button';\n\nexport type IconButtonProps<\n E extends React.ElementType = typeof defaultElement\n> = PolymorphicPropsWithRef<IconButtonBaseProps, E>;\n\nexport const IconButton: PolymorphicForwardRefExoticComponent<\n IconButtonBaseProps,\n typeof defaultElement\n> = React.forwardRef(\n <E extends React.ElementType = typeof defaultElement>(\n {\n children,\n className,\n disabled = false,\n size,\n as,\n loading,\n ...rest\n }: PolymorphicPropsWithoutRef<IconButtonBaseProps, E>,\n ref: React.ForwardedRef<React.ElementRef<E>>,\n ) => {\n const Element: React.ElementType = as || defaultElement;\n return (\n <Element\n className={classNames(\n 'eds-icon-button',\n className,\n {\n 'eds-icon-button--disabled': disabled,\n },\n `eds-icon-button--size-${size}`,\n )}\n disabled={disabled}\n aria-disabled={disabled}\n ref={ref}\n {...rest}\n >\n {loading ? <LoadingDots /> : children}\n </Element>\n );\n },\n);\n","import { warnAboutMissingStyles } from '@entur/utils';\nimport './index.scss';\n\nwarnAboutMissingStyles('button');\n\nexport * from './Button';\nexport * from './PrimaryButton';\nexport * from './SecondaryButton';\nexport * from './SuccessButton';\nexport * from './NegativeButton';\nexport * from './TertiaryButton';\nexport * from './ButtonGroup';\nexport * from './FloatingButton';\nexport * from './SecondarySquareButton';\nexport * from './SuccessSquareButton';\nexport * from './TertiarySquareButton';\nexport * from './IconButton';\n"],"names":["defaultElement","Button","React","forwardRef","ref","as","variant","size","loading","className","children","disabled","width","rest","Element","childrenArray","Children","toArray","hasLeadingIcon","length","hasTrailingIcon","cx","LoadingDots","PrimaryButton","props","SecondaryButton","SuccessButton","NegativeButton","TertiaryButton","ButtonGroup","classNames","FloatingButton","count","type","wrapStringsInSpans","map","child","BaseSquareButton","SecondarySquareButton","SuccessSquareButton","TertiarySquareButton","IconButton","warnAboutMissingStyles"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,IAAMA,gBAAc,GAAG,QAAvB;IAMaC,MAAM,gBAGfC,KAAK,CAACC,UAAN,CACF,gBAYEC,GAZF;;;MAEIC,UAAAA;MACAC,eAAAA;uBACAC;MAAAA,8BAAO;MACPC,eAAAA;MACAC,iBAAAA;MACAC,gBAAAA;2BACAC;MAAAA,sCAAW;wBACXC;MAAAA,gCAAQ;MACLC;;AAIL,MAAMC,OAAO,GAAsBT,EAAE,IAAIL,gBAAzC;AACA,MAAMe,aAAa,GAAGb,KAAK,CAACc,QAAN,CAAeC,OAAf,CAAuBP,QAAvB,CAAtB;AACA,MAAMQ,cAAc,GAClBH,aAAa,CAACI,MAAd,GAAuB,CAAvB,IAA4B,OAAOJ,aAAa,CAAC,CAAD,CAApB,KAA4B,QAD1D;AAEA,MAAMK,eAAe,GACnBL,aAAa,CAACI,MAAd,GAAuB,CAAvB,IACA,OAAOJ,aAAa,CAACA,aAAa,CAACI,MAAd,GAAuB,CAAxB,CAApB,KAAmD,QAFrD;AAIA,SACEjB,mBAAA,CAACY,OAAD;AACEL,IAAAA,SAAS,EAAEY,UAAE,CACX,YADW,0CAGef,OAHf,IAG2BA,OAH3B,4BAIYC,IAJZ,IAIqBA,IAJrB,MAKT,yBALS,IAKkBK,KAAK,KAAK,OAL5B,MAMT,qBANS,IAMcJ,OANd,MAOT,0BAPS,IAOmBU,cAPnB,MAQT,2BARS,IAQoB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