@entur/button 2.10.5-beta.3 → 2.10.6
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.
|
@@ -35,32 +35,26 @@ function _extends() {
|
|
|
35
35
|
_extends = Object.assign || function (target) {
|
|
36
36
|
for (var i = 1; i < arguments.length; i++) {
|
|
37
37
|
var source = arguments[i];
|
|
38
|
-
|
|
39
38
|
for (var key in source) {
|
|
40
39
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
41
40
|
target[key] = source[key];
|
|
42
41
|
}
|
|
43
42
|
}
|
|
44
43
|
}
|
|
45
|
-
|
|
46
44
|
return target;
|
|
47
45
|
};
|
|
48
|
-
|
|
49
46
|
return _extends.apply(this, arguments);
|
|
50
47
|
}
|
|
51
|
-
|
|
52
48
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
53
49
|
if (source == null) return {};
|
|
54
50
|
var target = {};
|
|
55
51
|
var sourceKeys = Object.keys(source);
|
|
56
52
|
var key, i;
|
|
57
|
-
|
|
58
53
|
for (i = 0; i < sourceKeys.length; i++) {
|
|
59
54
|
key = sourceKeys[i];
|
|
60
55
|
if (excluded.indexOf(key) >= 0) continue;
|
|
61
56
|
target[key] = source[key];
|
|
62
57
|
}
|
|
63
|
-
|
|
64
58
|
return target;
|
|
65
59
|
}
|
|
66
60
|
|
|
@@ -68,21 +62,19 @@ var _excluded$4 = ["as", "variant", "size", "loading", "className", "children",
|
|
|
68
62
|
var defaultElement$a = 'button';
|
|
69
63
|
var Button = /*#__PURE__*/React__namespace.forwardRef(function (_ref, ref) {
|
|
70
64
|
var _cx;
|
|
71
|
-
|
|
72
65
|
var as = _ref.as,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
66
|
+
variant = _ref.variant,
|
|
67
|
+
_ref$size = _ref.size,
|
|
68
|
+
size = _ref$size === void 0 ? 'medium' : _ref$size,
|
|
69
|
+
loading = _ref.loading,
|
|
70
|
+
className = _ref.className,
|
|
71
|
+
children = _ref.children,
|
|
72
|
+
_ref$disabled = _ref.disabled,
|
|
73
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
74
|
+
_ref$width = _ref.width,
|
|
75
|
+
width = _ref$width === void 0 ? 'auto' : _ref$width,
|
|
76
|
+
ariaLabel = _ref['aria-label'],
|
|
77
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
86
78
|
var Element = as || defaultElement$a;
|
|
87
79
|
var childrenArray = React__namespace.Children.toArray(children);
|
|
88
80
|
var hasLeadingIcon = childrenArray.length > 1 && typeof childrenArray[0] !== 'string';
|
|
@@ -90,13 +82,11 @@ var Button = /*#__PURE__*/React__namespace.forwardRef(function (_ref, ref) {
|
|
|
90
82
|
var ariaLabelWhenLoading = childrenArray.filter(function (child) {
|
|
91
83
|
return typeof child === 'string';
|
|
92
84
|
}).join(' ');
|
|
93
|
-
|
|
94
85
|
var ariaLabelValue = function ariaLabelValue() {
|
|
95
86
|
if (ariaLabel) return ariaLabel;
|
|
96
87
|
if (loading) return ariaLabelWhenLoading;
|
|
97
88
|
return undefined;
|
|
98
89
|
};
|
|
99
|
-
|
|
100
90
|
return React__namespace.createElement(Element, _extends({
|
|
101
91
|
className: classNames__default["default"]('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),
|
|
102
92
|
ref: ref,
|
|
@@ -167,10 +157,9 @@ var TertiaryButton = /*#__PURE__*/React__default["default"].forwardRef(function
|
|
|
167
157
|
var _excluded$3 = ["as", "className"];
|
|
168
158
|
var ButtonGroup = function ButtonGroup(_ref) {
|
|
169
159
|
var _ref$as = _ref.as,
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
160
|
+
Element = _ref$as === void 0 ? 'div' : _ref$as,
|
|
161
|
+
className = _ref.className,
|
|
162
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
174
163
|
return React__default["default"].createElement(Element, _extends({
|
|
175
164
|
className: classNames__default["default"]('eds-button-group', className)
|
|
176
165
|
}, rest));
|
|
@@ -179,11 +168,10 @@ var ButtonGroup = function ButtonGroup(_ref) {
|
|
|
179
168
|
var _excluded$2 = ["className", "children", "size"];
|
|
180
169
|
var FloatingButton = function FloatingButton(_ref) {
|
|
181
170
|
var className = _ref.className,
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
171
|
+
children = _ref.children,
|
|
172
|
+
_ref$size = _ref.size,
|
|
173
|
+
size = _ref$size === void 0 ? 'medium' : _ref$size,
|
|
174
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
187
175
|
return React__default["default"].createElement("button", _extends({
|
|
188
176
|
className: classNames__default["default"]('eds-floating-button', {
|
|
189
177
|
'eds-floating-button--extended': React__default["default"].Children.count(children) > 1
|
|
@@ -193,7 +181,6 @@ var FloatingButton = function FloatingButton(_ref) {
|
|
|
193
181
|
type: "button"
|
|
194
182
|
}, rest), wrapStringsInSpans(children));
|
|
195
183
|
};
|
|
196
|
-
|
|
197
184
|
var wrapStringsInSpans = function wrapStringsInSpans(children) {
|
|
198
185
|
return React__default["default"].Children.map(children, function (child) {
|
|
199
186
|
return typeof child === 'string' ? React__default["default"].createElement("span", null, child) : child;
|
|
@@ -204,15 +191,14 @@ var _excluded$1 = ["children", "className", "variant", "disabled", "loading", "a
|
|
|
204
191
|
var defaultElement$4 = 'button';
|
|
205
192
|
var BaseSquareButton = /*#__PURE__*/React__namespace.forwardRef(function (_ref, ref) {
|
|
206
193
|
var children = _ref.children,
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
194
|
+
className = _ref.className,
|
|
195
|
+
variant = _ref.variant,
|
|
196
|
+
_ref$disabled = _ref.disabled,
|
|
197
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
198
|
+
_ref$loading = _ref.loading,
|
|
199
|
+
loading = _ref$loading === void 0 ? false : _ref$loading,
|
|
200
|
+
as = _ref.as,
|
|
201
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
216
202
|
var Element = as || defaultElement$4;
|
|
217
203
|
return React__namespace.createElement(Element, _extends({
|
|
218
204
|
className: classNames__default["default"]('eds-square-button', {
|
|
@@ -234,7 +220,6 @@ var BaseSquareButton = /*#__PURE__*/React__namespace.forwardRef(function (_ref,
|
|
|
234
220
|
className: "eds-square-button__label"
|
|
235
221
|
}, child);
|
|
236
222
|
}
|
|
237
|
-
|
|
238
223
|
return React__namespace.createElement("span", {
|
|
239
224
|
className: "eds-square-button__icon"
|
|
240
225
|
}, loading ? React__namespace.createElement(loader.LoadingDots, {
|
|
@@ -280,14 +265,13 @@ var _excluded = ["children", "className", "disabled", "size", "as", "loading"];
|
|
|
280
265
|
var defaultElement = 'button';
|
|
281
266
|
var IconButton = /*#__PURE__*/React__default["default"].forwardRef(function (_ref, ref) {
|
|
282
267
|
var children = _ref.children,
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
268
|
+
className = _ref.className,
|
|
269
|
+
_ref$disabled = _ref.disabled,
|
|
270
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
271
|
+
size = _ref.size,
|
|
272
|
+
as = _ref.as,
|
|
273
|
+
loading = _ref.loading,
|
|
274
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
291
275
|
var Element = as || defaultElement;
|
|
292
276
|
var iconButtonElement = React__default["default"].createElement(Element, _extends({
|
|
293
277
|
className: classNames__default["default"]('eds-icon-button', className, {
|
|
@@ -298,13 +282,11 @@ var IconButton = /*#__PURE__*/React__default["default"].forwardRef(function (_re
|
|
|
298
282
|
"aria-busy": loading,
|
|
299
283
|
ref: ref
|
|
300
284
|
}, rest), loading ? React__default["default"].createElement(loader.LoadingDots, null) : children);
|
|
301
|
-
|
|
302
285
|
if (disabled) {
|
|
303
286
|
return React__default["default"].createElement("div", {
|
|
304
287
|
className: "eds-icon-button--disabled__wrapper"
|
|
305
288
|
}, iconButtonElement);
|
|
306
289
|
}
|
|
307
|
-
|
|
308
290
|
return React__default["default"].createElement(React__default["default"].Fragment, null, iconButtonElement);
|
|
309
291
|
});
|
|
310
292
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.cjs.development.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/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 * Tekst som leses opp på skjermleser (nødvendig når knappetekst mangler)\n */\n 'aria-label'?: string;\n};\n\nconst defaultElement = 'button';\n\nexport type ButtonProps<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 'aria-label': ariaLabel,\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 const ariaLabelWhenLoading = childrenArray\n .filter(child => typeof child === 'string')\n .join(' ');\n\n const ariaLabelValue = () => {\n if (ariaLabel) return ariaLabel;\n if (loading) return ariaLabelWhenLoading;\n return undefined;\n };\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 aria-label={ariaLabelValue()}\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 /** Tekst som forklarer knappens handling. MÅ være satt hvis du ikke har en forklarende tooltip på knappen */\n 'aria-label'?: string;\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\n const iconButtonElement = (\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 aria-busy={loading}\n ref={ref}\n {...rest}\n >\n {loading ? <LoadingDots /> : children}\n </Element>\n );\n\n if (disabled) {\n return (\n <div className=\"eds-icon-button--disabled__wrapper\">\n {iconButtonElement}\n </div>\n );\n }\n return <>{iconButtonElement}</>;\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","ariaLabel","rest","Element","childrenArray","Children","toArray","hasLeadingIcon","length","hasTrailingIcon","ariaLabelWhenLoading","filter","child","join","ariaLabelValue","undefined","cx","LoadingDots","PrimaryButton","props","SecondaryButton","SuccessButton","NegativeButton","TertiaryButton","ButtonGroup","classNames","FloatingButton","count","type","wrapStringsInSpans","map","BaseSquareButton","SecondarySquareButton","SuccessSquareButton","TertiarySquareButton","IconButton","iconButtonElement","warnAboutMissingStyles"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,IAAMA,gBAAc,GAAG,QAAvB;IAKaC,MAAM,gBAGfC,gBAAK,CAACC,UAAN,CACF,gBAaEC,GAbF;;;MAEIC,UAAAA;MACAC,eAAAA;uBACAC;MAAAA,8BAAO;MACPC,eAAAA;MACAC,iBAAAA;MACAC,gBAAAA;2BACAC;MAAAA,sCAAW;wBACXC;MAAAA,gCAAQ;MACMC,iBAAd;MACGC;;AAIL,MAAMC,OAAO,GAAsBV,EAAE,IAAIL,gBAAzC;AACA,MAAMgB,aAAa,GAAGd,gBAAK,CAACe,QAAN,CAAeC,OAAf,CAAuBR,QAAvB,CAAtB;AACA,MAAMS,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,MAAME,oBAAoB,GAAGN,aAAa,CACvCO,MAD0B,CACnB,UAAAC,KAAK;AAAA,WAAI,OAAOA,KAAP,KAAiB,QAArB;AAAA,GADc,EAE1BC,IAF0B,CAErB,GAFqB,CAA7B;;AAIA,MAAMC,cAAc,GAAG,SAAjBA,cAAiB;AACrB,QAAIb,SAAJ,EAAe,OAAOA,SAAP;AACf,QAAIL,OAAJ,EAAa,OAAOc,oBAAP;AACb,WAAOK,SAAP;AACD,GAJD;;AAMA,SACEzB,8BAAA,CAACa,OAAD;AACEN,IAAAA,SAA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cjs.development.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/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 * Tekst som leses opp på skjermleser (nødvendig når knappetekst mangler)\n */\n 'aria-label'?: string;\n};\n\nconst defaultElement = 'button';\n\nexport type ButtonProps<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 'aria-label': ariaLabel,\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 const ariaLabelWhenLoading = childrenArray\n .filter(child => typeof child === 'string')\n .join(' ');\n\n const ariaLabelValue = () => {\n if (ariaLabel) return ariaLabel;\n if (loading) return ariaLabelWhenLoading;\n return undefined;\n };\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 aria-label={ariaLabelValue()}\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 /** Tekst som forklarer knappens handling. MÅ være satt hvis du ikke har en forklarende tooltip på knappen */\n 'aria-label'?: string;\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\n const iconButtonElement = (\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 aria-busy={loading}\n ref={ref}\n {...rest}\n >\n {loading ? <LoadingDots /> : children}\n </Element>\n );\n\n if (disabled) {\n return (\n <div className=\"eds-icon-button--disabled__wrapper\">\n {iconButtonElement}\n </div>\n );\n }\n return <>{iconButtonElement}</>;\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","ariaLabel","rest","Element","childrenArray","Children","toArray","hasLeadingIcon","length","hasTrailingIcon","ariaLabelWhenLoading","filter","child","join","ariaLabelValue","undefined","cx","LoadingDots","PrimaryButton","props","SecondaryButton","SuccessButton","NegativeButton","TertiaryButton","ButtonGroup","classNames","FloatingButton","count","type","wrapStringsInSpans","map","BaseSquareButton","SecondarySquareButton","SuccessSquareButton","TertiarySquareButton","IconButton","iconButtonElement","warnAboutMissingStyles"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,IAAMA,gBAAc,GAAG,QAAQ;IAKlBC,MAAM,gBAGfC,gBAAK,CAACC,UAAU,CAClB,gBAaEC,GAA4C;;MAX1CC,EAAE,QAAFA,EAAE;IACFC,OAAO,QAAPA,OAAO;IAAA,iBACPC,IAAI;IAAJA,IAAI,0BAAG,QAAQ;IACfC,OAAO,QAAPA,OAAO;IACPC,SAAS,QAATA,SAAS;IACTC,QAAQ,QAARA,QAAQ;IAAA,qBACRC,QAAQ;IAARA,QAAQ,8BAAG,KAAK;IA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AAQ;qBACHA,QAAQ;iBACZH,OAAO;IAClBJ,GAAG,EAAEA;KACDU,IAAI,GAEPN,OAAO,GAAGN,wCAAC2B,kBAAW,OAAG,GAAGnB,QAAQ,CAExC;EAED,IAAIC,QAAQ,EAAE;IACZ,OACET;MAAKO,SAAS,EAAC;OACZuC,iBAAiB,CACd;;EAGV,OAAO9C,kFAAG8C,iBAAiB,CAAI;AACjC,CAAC;;ACpFHC,4BAAsB,CAAC,QAAQ,CAAC;;;;;;;;;;;;;;;"}
|
|
@@ -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/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 * Tekst som leses opp på skjermleser (nødvendig når knappetekst mangler)\n */\n 'aria-label'?: string;\n};\n\nconst defaultElement = 'button';\n\nexport type ButtonProps<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 'aria-label': ariaLabel,\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 const ariaLabelWhenLoading = childrenArray\n .filter(child => typeof child === 'string')\n .join(' ');\n\n const ariaLabelValue = () => {\n if (ariaLabel) return ariaLabel;\n if (loading) return ariaLabelWhenLoading;\n return undefined;\n };\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 aria-label={ariaLabelValue()}\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 /** Tekst som forklarer knappens handling. MÅ være satt hvis du ikke har en forklarende tooltip på knappen */\n 'aria-label'?: string;\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\n const iconButtonElement = (\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 aria-busy={loading}\n ref={ref}\n {...rest}\n >\n {loading ? <LoadingDots /> : children}\n </Element>\n );\n\n if (disabled) {\n return (\n <div className=\"eds-icon-button--disabled__wrapper\">\n {iconButtonElement}\n </div>\n );\n }\n return <>{iconButtonElement}</>;\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","ariaLabel","rest","Element","childrenArray","Children","toArray","hasLeadingIcon","length","hasTrailingIcon","ariaLabelWhenLoading","filter","child","join","cx","LoadingDots","PrimaryButton","props","SecondaryButton","SuccessButton","NegativeButton","TertiaryButton","BaseSquareButton","classNames","map","SecondarySquareButton","SuccessSquareButton","TertiarySquareButton","IconButton","iconButtonElement","warnAboutMissingStyles","count","type","wrapStringsInSpans"],"mappings":"48BA4CaA,EAGTC,EAAMC,YACR,WAaEC,SAXEC,IAAAA,GACAC,IAAAA,YACAC,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MCnFdC,yBAAuB,+CCagC,oBACrDrC,GAAIU,aAAU,QACdN,IAAAA,UACGK,gBAGDZ,wBAACa,KAAQN,UAAW0B,UAAW,mBAAoB1B,IAAgBK,4BCFV,gBAC3DL,IAAAA,UACAC,IAAAA,aACAH,KAAAA,aAAO,WACJO,gBAGDZ,oCACEO,UAAW0B,UACT,sBACA,iCAAmCjC,UAAMe,SAAS0B,MAAMjC,GAAY,GACpE,8BAAyC,UAATH,GAChCE,GAEFmC,KAAK,UACD9B,GAOiB,SAACJ,UAC1BR,UAAMe,SAASmB,IAAI1B,GAAU,SAAAc,SACV,iBAAVA,EAAqBtB,oCAAOsB,GAAgBA,KAPhDqB,CAAmBnC"}
|
|
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 * Tekst som leses opp på skjermleser (nødvendig når knappetekst mangler)\n */\n 'aria-label'?: string;\n};\n\nconst defaultElement = 'button';\n\nexport type ButtonProps<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 'aria-label': ariaLabel,\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 const ariaLabelWhenLoading = childrenArray\n .filter(child => typeof child === 'string')\n .join(' ');\n\n const ariaLabelValue = () => {\n if (ariaLabel) return ariaLabel;\n if (loading) return ariaLabelWhenLoading;\n return undefined;\n };\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 aria-label={ariaLabelValue()}\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 /** Tekst som forklarer knappens handling. MÅ være satt hvis du ikke har en forklarende tooltip på knappen */\n 'aria-label'?: string;\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\n const iconButtonElement = (\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 aria-busy={loading}\n ref={ref}\n {...rest}\n >\n {loading ? <LoadingDots /> : children}\n </Element>\n );\n\n if (disabled) {\n return (\n <div className=\"eds-icon-button--disabled__wrapper\">\n {iconButtonElement}\n </div>\n );\n }\n return <>{iconButtonElement}</>;\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","_ref$size","size","loading","className","children","_ref$disabled","disabled","_ref$width","width","ariaLabel","rest","Element","childrenArray","Children","toArray","hasLeadingIcon","length","hasTrailingIcon","ariaLabelWhenLoading","filter","child","join","cx","LoadingDots","PrimaryButton","props","SecondaryButton","SuccessButton","NegativeButton","TertiaryButton","BaseSquareButton","_ref$loading","classNames","map","SecondarySquareButton","SuccessSquareButton","TertiarySquareButton","IconButton","iconButtonElement","warnAboutMissingStyles","count","type","wrapStringsInSpans"],"mappings":"48BA4CaA,EAGTC,EAAMC,YACR,WAaEC,SAXEC,IAAAA,GACAC,IAAAA,QAAOC,IACPC,KAAAA,aAAO,WACPC,IAAAA,QACAC,IAAAA,UACAC,IAAAA,SAAQC,IACRC,SAAAA,gBAAgBC,IAChBC,MAAAA,aAAQ,SACMC,IAAd,cACGC,SAICC,EAA6Bb,GAxBhB,SAyBbc,EAAgBjB,EAAMkB,SAASC,QAAQV,GACvCW,EACJH,EAAcI,OAAS,GAAiC,iBAArBJ,EAAc,GAC7CK,EACJL,EAAcI,OAAS,GAC4B,iBAA5CJ,EAAcA,EAAcI,OAAS,GAExCE,EAAuBN,EAC1BO,QAAO,SAAAC,GAAK,MAAqB,iBAAVA,KACvBC,KAAK,KAQR,OACE1B,gBAACgB,KACCR,UAAWmB,UACT,4CAE0BvB,GAAYA,wBACfE,GAASA,IAC9B,2BAAqC,UAAVO,IAC3B,uBAAuBN,IACvB,4BAA4Ba,IAC5B,6BAA6BE,KAE/Bd,GAEFN,IAAKA,cACMK,EACXI,SAAUA,kBACKA,eAtBbG,IACAP,EAAgBgB,OAApB,IAuBMR,GAEHR,EACCP,gBAAC4B,eAAYpB,UAAU,6BAEvBC,MCpEGoB,EAGT7B,UAAMC,YACR,SACE6B,EACA5B,GAGA,OAAOF,wBAACD,KAAOI,GADoB2B,EAAM3B,IAVtB,UAWa2B,GAAO5B,IAAKA,EAAKE,QAAQ,gBCThD2B,EAGT/B,UAAMC,YACR,SACE6B,EACA5B,GAGA,OAAOF,wBAACD,KAAOI,GADoB2B,EAAM3B,IAVtB,UAWa2B,GAAO5B,IAAKA,EAAKE,QAAQ,kBCThD4B,EAGThC,UAAMC,YACR,SACE6B,EACA5B,GAGA,OAAOF,wBAACD,KAAOI,GADoB2B,EAAM3B,IAVtB,UAWa2B,GAAO5B,IAAKA,EAAKE,QAAQ,gBCRhD6B,EAGTjC,UAAMC,YACR,SACE6B,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D,IAAAA,UAASE,IACTC,SAAAA,gBACAL,IAAAA,KACAH,IAAAA,GACAI,IAAAA,QACGQ,SAMC4B,EACJ3C,wBAHiCG,GAtBhB,YA0BfK,UAAW6B,UACT,kBACA7B,EACA,CACE,4BAA6BG,4BAENL,GAE3BK,SAAUA,kBACKA,cACJJ,EACXL,IAAKA,GACDa,GAEHR,EAAUP,wBAAC4B,oBAAiBnB,GAIjC,OAAIE,EAEAX,+BAAKQ,UAAU,sCACZmC,GAIA3C,gDAAG2C,MCnFdC,yBAAuB,+CCagC,oBACrDzC,GAAIa,aAAU,QACdR,IAAAA,UACGO,SAEH,OACEf,wBAACgB,KAAQR,UAAW6B,UAAW,mBAAoB7B,IAAgBO,4BCFV,gBAC3DP,IAAAA,UACAC,IAAAA,SAAQJ,IACRC,KAAAA,aAAO,WACJS,SAEH,OACEf,oCACEQ,UAAW6B,UACT,sBACA,CAAE,gCAAiCrC,UAAMkB,SAAS2B,MAAMpC,GAAY,GACpE,CAAE,6BAAuC,UAATH,GAChCE,GAEFsC,KAAK,UACD/B,GAOiB,SAACN,GAAyB,OACnDT,UAAMkB,SAASoB,IAAI7B,GAAU,SAAAgB,GAAK,MACf,iBAAVA,EAAqBzB,oCAAOyB,GAAgBA,KAPhDsB,CAAmBtC"}
|
package/dist/button.esm.js
CHANGED
|
@@ -8,32 +8,26 @@ function _extends() {
|
|
|
8
8
|
_extends = Object.assign || function (target) {
|
|
9
9
|
for (var i = 1; i < arguments.length; i++) {
|
|
10
10
|
var source = arguments[i];
|
|
11
|
-
|
|
12
11
|
for (var key in source) {
|
|
13
12
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
14
13
|
target[key] = source[key];
|
|
15
14
|
}
|
|
16
15
|
}
|
|
17
16
|
}
|
|
18
|
-
|
|
19
17
|
return target;
|
|
20
18
|
};
|
|
21
|
-
|
|
22
19
|
return _extends.apply(this, arguments);
|
|
23
20
|
}
|
|
24
|
-
|
|
25
21
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
26
22
|
if (source == null) return {};
|
|
27
23
|
var target = {};
|
|
28
24
|
var sourceKeys = Object.keys(source);
|
|
29
25
|
var key, i;
|
|
30
|
-
|
|
31
26
|
for (i = 0; i < sourceKeys.length; i++) {
|
|
32
27
|
key = sourceKeys[i];
|
|
33
28
|
if (excluded.indexOf(key) >= 0) continue;
|
|
34
29
|
target[key] = source[key];
|
|
35
30
|
}
|
|
36
|
-
|
|
37
31
|
return target;
|
|
38
32
|
}
|
|
39
33
|
|
|
@@ -41,21 +35,19 @@ var _excluded$4 = ["as", "variant", "size", "loading", "className", "children",
|
|
|
41
35
|
var defaultElement$a = 'button';
|
|
42
36
|
var Button = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
43
37
|
var _cx;
|
|
44
|
-
|
|
45
38
|
var as = _ref.as,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
39
|
+
variant = _ref.variant,
|
|
40
|
+
_ref$size = _ref.size,
|
|
41
|
+
size = _ref$size === void 0 ? 'medium' : _ref$size,
|
|
42
|
+
loading = _ref.loading,
|
|
43
|
+
className = _ref.className,
|
|
44
|
+
children = _ref.children,
|
|
45
|
+
_ref$disabled = _ref.disabled,
|
|
46
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
47
|
+
_ref$width = _ref.width,
|
|
48
|
+
width = _ref$width === void 0 ? 'auto' : _ref$width,
|
|
49
|
+
ariaLabel = _ref['aria-label'],
|
|
50
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
|
|
59
51
|
var Element = as || defaultElement$a;
|
|
60
52
|
var childrenArray = React.Children.toArray(children);
|
|
61
53
|
var hasLeadingIcon = childrenArray.length > 1 && typeof childrenArray[0] !== 'string';
|
|
@@ -63,13 +55,11 @@ var Button = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
63
55
|
var ariaLabelWhenLoading = childrenArray.filter(function (child) {
|
|
64
56
|
return typeof child === 'string';
|
|
65
57
|
}).join(' ');
|
|
66
|
-
|
|
67
58
|
var ariaLabelValue = function ariaLabelValue() {
|
|
68
59
|
if (ariaLabel) return ariaLabel;
|
|
69
60
|
if (loading) return ariaLabelWhenLoading;
|
|
70
61
|
return undefined;
|
|
71
62
|
};
|
|
72
|
-
|
|
73
63
|
return React.createElement(Element, _extends({
|
|
74
64
|
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),
|
|
75
65
|
ref: ref,
|
|
@@ -140,10 +130,9 @@ var TertiaryButton = /*#__PURE__*/React__default.forwardRef(function (props, ref
|
|
|
140
130
|
var _excluded$3 = ["as", "className"];
|
|
141
131
|
var ButtonGroup = function ButtonGroup(_ref) {
|
|
142
132
|
var _ref$as = _ref.as,
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
133
|
+
Element = _ref$as === void 0 ? 'div' : _ref$as,
|
|
134
|
+
className = _ref.className,
|
|
135
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
|
|
147
136
|
return React__default.createElement(Element, _extends({
|
|
148
137
|
className: classNames('eds-button-group', className)
|
|
149
138
|
}, rest));
|
|
@@ -152,11 +141,10 @@ var ButtonGroup = function ButtonGroup(_ref) {
|
|
|
152
141
|
var _excluded$2 = ["className", "children", "size"];
|
|
153
142
|
var FloatingButton = function FloatingButton(_ref) {
|
|
154
143
|
var className = _ref.className,
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
144
|
+
children = _ref.children,
|
|
145
|
+
_ref$size = _ref.size,
|
|
146
|
+
size = _ref$size === void 0 ? 'medium' : _ref$size,
|
|
147
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
|
|
160
148
|
return React__default.createElement("button", _extends({
|
|
161
149
|
className: classNames('eds-floating-button', {
|
|
162
150
|
'eds-floating-button--extended': React__default.Children.count(children) > 1
|
|
@@ -166,7 +154,6 @@ var FloatingButton = function FloatingButton(_ref) {
|
|
|
166
154
|
type: "button"
|
|
167
155
|
}, rest), wrapStringsInSpans(children));
|
|
168
156
|
};
|
|
169
|
-
|
|
170
157
|
var wrapStringsInSpans = function wrapStringsInSpans(children) {
|
|
171
158
|
return React__default.Children.map(children, function (child) {
|
|
172
159
|
return typeof child === 'string' ? React__default.createElement("span", null, child) : child;
|
|
@@ -177,15 +164,14 @@ var _excluded$1 = ["children", "className", "variant", "disabled", "loading", "a
|
|
|
177
164
|
var defaultElement$4 = 'button';
|
|
178
165
|
var BaseSquareButton = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
179
166
|
var children = _ref.children,
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
167
|
+
className = _ref.className,
|
|
168
|
+
variant = _ref.variant,
|
|
169
|
+
_ref$disabled = _ref.disabled,
|
|
170
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
171
|
+
_ref$loading = _ref.loading,
|
|
172
|
+
loading = _ref$loading === void 0 ? false : _ref$loading,
|
|
173
|
+
as = _ref.as,
|
|
174
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
|
|
189
175
|
var Element = as || defaultElement$4;
|
|
190
176
|
return React.createElement(Element, _extends({
|
|
191
177
|
className: classNames('eds-square-button', {
|
|
@@ -207,7 +193,6 @@ var BaseSquareButton = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
207
193
|
className: "eds-square-button__label"
|
|
208
194
|
}, child);
|
|
209
195
|
}
|
|
210
|
-
|
|
211
196
|
return React.createElement("span", {
|
|
212
197
|
className: "eds-square-button__icon"
|
|
213
198
|
}, loading ? React.createElement(LoadingDots, {
|
|
@@ -253,14 +238,13 @@ var _excluded = ["children", "className", "disabled", "size", "as", "loading"];
|
|
|
253
238
|
var defaultElement = 'button';
|
|
254
239
|
var IconButton = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
255
240
|
var children = _ref.children,
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
241
|
+
className = _ref.className,
|
|
242
|
+
_ref$disabled = _ref.disabled,
|
|
243
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
244
|
+
size = _ref.size,
|
|
245
|
+
as = _ref.as,
|
|
246
|
+
loading = _ref.loading,
|
|
247
|
+
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
264
248
|
var Element = as || defaultElement;
|
|
265
249
|
var iconButtonElement = React__default.createElement(Element, _extends({
|
|
266
250
|
className: classNames('eds-icon-button', className, {
|
|
@@ -271,13 +255,11 @@ var IconButton = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
|
271
255
|
"aria-busy": loading,
|
|
272
256
|
ref: ref
|
|
273
257
|
}, rest), loading ? React__default.createElement(LoadingDots, null) : children);
|
|
274
|
-
|
|
275
258
|
if (disabled) {
|
|
276
259
|
return React__default.createElement("div", {
|
|
277
260
|
className: "eds-icon-button--disabled__wrapper"
|
|
278
261
|
}, iconButtonElement);
|
|
279
262
|
}
|
|
280
|
-
|
|
281
263
|
return React__default.createElement(React__default.Fragment, null, iconButtonElement);
|
|
282
264
|
});
|
|
283
265
|
|
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/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 * Tekst som leses opp på skjermleser (nødvendig når knappetekst mangler)\n */\n 'aria-label'?: string;\n};\n\nconst defaultElement = 'button';\n\nexport type ButtonProps<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 'aria-label': ariaLabel,\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 const ariaLabelWhenLoading = childrenArray\n .filter(child => typeof child === 'string')\n .join(' ');\n\n const ariaLabelValue = () => {\n if (ariaLabel) return ariaLabel;\n if (loading) return ariaLabelWhenLoading;\n return undefined;\n };\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 aria-label={ariaLabelValue()}\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 /** Tekst som forklarer knappens handling. MÅ være satt hvis du ikke har en forklarende tooltip på knappen */\n 'aria-label'?: string;\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\n const iconButtonElement = (\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 aria-busy={loading}\n ref={ref}\n {...rest}\n >\n {loading ? <LoadingDots /> : children}\n </Element>\n );\n\n if (disabled) {\n return (\n <div className=\"eds-icon-button--disabled__wrapper\">\n {iconButtonElement}\n </div>\n );\n }\n return <>{iconButtonElement}</>;\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","ariaLabel","rest","Element","childrenArray","Children","toArray","hasLeadingIcon","length","hasTrailingIcon","ariaLabelWhenLoading","filter","child","join","ariaLabelValue","undefined","cx","LoadingDots","PrimaryButton","props","SecondaryButton","SuccessButton","NegativeButton","TertiaryButton","ButtonGroup","classNames","FloatingButton","count","type","wrapStringsInSpans","map","BaseSquareButton","SecondarySquareButton","SuccessSquareButton","TertiarySquareButton","IconButton","iconButtonElement","warnAboutMissingStyles"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,IAAMA,gBAAc,GAAG,QAAvB;IAKaC,MAAM,gBAGfC,KAAK,CAACC,UAAN,CACF,gBAaEC,GAbF;;;MAEIC,UAAAA;MACAC,eAAAA;uBACAC;MAAAA,8BAAO;MACPC,eAAAA;MACAC,iBAAAA;MACAC,gBAAAA;2BACAC;MAAAA,sCAAW;wBACXC;MAAAA,gCAAQ;MACMC,iBAAd;MACGC;;AAIL,MAAMC,OAAO,GAAsBV,EAAE,IAAIL,gBAAzC;AACA,MAAMgB,aAAa,GAAGd,KAAK,CAACe,QAAN,CAAeC,OAAf,CAAuBR,QAAvB,CAAtB;AACA,MAAMS,cAAc,GAClBH,aAA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E4B,UAAU,CACnB,iBADmB,EAEnB5B,SAFmB,EAGnB;AACE,mCAA6BE;AAD/B,KAHmB,6BAMMJ,IANN,CADvB;AASEI,IAAAA,QAAQ,EAAEA,QATZ;qBAUiBA,QAVjB;iBAWaH,OAXb;AAYEJ,IAAAA,GAAG,EAAEA;AAZP,KAaMU,IAbN,GAeGN,OAAO,GAAGN,4BAAA,CAAC2B,WAAD,MAAA,CAAH,GAAqBnB,QAf/B,CADF;;AAoBA,MAAIC,QAAJ,EAAc;AACZ,WACET,4BAAA,MAAA;AAAKO,MAAAA,SAAS,EAAC;KAAf,EACGuC,iBADH,CADF;AAKD;;AACD,SAAO9C,4BAAA,wBAAA,MAAA,EAAG8C,iBAAH,CAAP;AACD,CA3CC;;ACzCJC,sBAAsB,CAAC,QAAD,CAAtB;;;;"}
|
|
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/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 * Tekst som leses opp på skjermleser (nødvendig når knappetekst mangler)\n */\n 'aria-label'?: string;\n};\n\nconst defaultElement = 'button';\n\nexport type ButtonProps<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 'aria-label': ariaLabel,\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 const ariaLabelWhenLoading = childrenArray\n .filter(child => typeof child === 'string')\n .join(' ');\n\n const ariaLabelValue = () => {\n if (ariaLabel) return ariaLabel;\n if (loading) return ariaLabelWhenLoading;\n return undefined;\n };\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 aria-label={ariaLabelValue()}\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 /** Tekst som forklarer knappens handling. MÅ være satt hvis du ikke har en forklarende tooltip på knappen */\n 'aria-label'?: string;\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\n const iconButtonElement = (\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 aria-busy={loading}\n ref={ref}\n {...rest}\n >\n {loading ? <LoadingDots /> : children}\n </Element>\n );\n\n if (disabled) {\n return (\n <div className=\"eds-icon-button--disabled__wrapper\">\n {iconButtonElement}\n </div>\n );\n }\n return <>{iconButtonElement}</>;\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","ariaLabel","rest","Element","childrenArray","Children","toArray","hasLeadingIcon","length","hasTrailingIcon","ariaLabelWhenLoading","filter","child","join","ariaLabelValue","undefined","cx","LoadingDots","PrimaryButton","props","SecondaryButton","SuccessButton","NegativeButton","TertiaryButton","ButtonGroup","classNames","FloatingButton","count","type","wrapStringsInSpans","map","BaseSquareButton","SecondarySquareButton","SuccessSquareButton","TertiarySquareButton","IconButton","iconButtonElement","warnAboutMissingStyles"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,IAAMA,gBAAc,GAAG,QAAQ;IAKlBC,MAAM,gBAGfC,KAAK,CAACC,UAAU,CAClB,gBAaEC,GAA4C;;MAX1CC,EAAE,QAAFA,EAAE;IACFC,OAAO,QAAPA,OAAO;IAAA,iBACPC,IAAI;IAAJA,IAAI,0BAAG,QAAQ;IACfC,OAAO,QAAPA,OAAO;IACPC,SAAS,QAATA,SAAS;IACTC,QAAQ,QAARA,QAAQ;IAAA,qBACRC,QAAQ;IAARA,QAAQ,8BAAG,KAAK;IAAA,kBAChBC,KAAK;IAALA,KAAK,2BAAG,MAAM;IACAC,SAAS,QAAvB,YAAY;IACTC,IAAI;EAIT,IAAMC,OAAO,GAAsBV,EAAE,IAAIL,gBAAc;EACvD,IAAMgB,aAAa,GAAGd,KAAK,CAACe,QAAQ,CAACC,OAAO,CAACR,QAAQ,CAAC;EACtD,IAAMS,cAAc,GAClBH,aAAa,CAACI,MAAM,GAAG,CAAC,IAAI,OAAOJ,aAAa,CAAC,CAAC,CAAC,KAAK,QAAQ;EAClE,IAAMK,eAAe,GACnBL,aAAa,CAACI,MAAM,GAAG,CAAC,IACxB,OAAOJ,aAAa,CAACA,aAAa,CAACI,MAAM,GAAG,CAAC,CAAC,KAAK,QAAQ;EAE7D,IAAME,oBAAoB,GAAGN,aAAa,CACvCO,MAAM,CAAC,UAAAC,KAAK;IAAA,OAAI,OAAOA,KAAK,KAAK,QAAQ;IAAC,CAC1CC,IAAI,CAAC,GAAG,CAAC;EAEZ,IAAMC,cAAc,GAAG,SAAjBA,cAAc;IAClB,IAAIb,SAAS,EAAE,OAAOA,SAAS;IAC/B,IAAIL,OAAO,EAAE,OAAOc,oBAAoB;IACxC,OAAOK,SAAS;G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,UAAU,gBAGnB7C,cAAK,CAACC,UAAU,CAClB,gBAUEC,GAA4C;MAR1CM,QAAQ,QAARA,QAAQ;IACRD,SAAS,QAATA,SAAS;IAAA,qBACTE,QAAQ;IAARA,QAAQ,8BAAG,KAAK;IAChBJ,IAAI,QAAJA,IAAI;IACJF,EAAE,QAAFA,EAAE;IACFG,OAAO,QAAPA,OAAO;IACJM,IAAI;EAIT,IAAMC,OAAO,GAAsBV,EAAE,IAAIL,cAAc;EAEvD,IAAMgD,iBAAiB,GACrB9C,6BAACa,OAAO;IACNN,SAAS,EAAE4B,UAAU,CACnB,iBAAiB,EACjB5B,SAAS,EACT;MACE,2BAA2B,EAAEE;KAC9B,6BACwBJ,IAAI,CAC9B;IACDI,QAAQ,EAAEA,QAAQ;qBACHA,QAAQ;iBACZH,OAAO;IAClBJ,GAAG,EAAEA;KACDU,IAAI,GAEPN,OAAO,GAAGN,6BAAC2B,WAAW,OAAG,GAAGnB,QAAQ,CAExC;EAED,IAAIC,QAAQ,EAAE;IACZ,OACET;MAAKO,SAAS,EAAC;OACZuC,iBAAiB,CACd;;EAGV,OAAO9C,4DAAG8C,iBAAiB,CAAI;AACjC,CAAC;;ACpFHC,sBAAsB,CAAC,QAAQ,CAAC;;;;"}
|
package/dist/styles.css
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
--eds-button: 1;
|
|
3
3
|
}/* DO NOT CHANGE!*/
|
|
4
4
|
/* This file is automatically generated from @entur/tokens! Changes will be overwritten. */
|
|
5
|
+
.eds-button-group .eds-button {
|
|
6
|
+
margin-right: 0.75rem;
|
|
7
|
+
margin-bottom: 0.75rem;
|
|
8
|
+
}
|
|
9
|
+
.eds-button-group .eds-button:only-child {
|
|
10
|
+
margin: 0;
|
|
11
|
+
}/* DO NOT CHANGE!*/
|
|
12
|
+
/* This file is automatically generated from @entur/tokens! Changes will be overwritten. */
|
|
5
13
|
a.eds-button {
|
|
6
14
|
padding: 0.5rem 1rem;
|
|
7
15
|
}
|
|
@@ -217,6 +225,59 @@ a.eds-button--size-large {
|
|
|
217
225
|
color: #aeb7e2;
|
|
218
226
|
}/* DO NOT CHANGE!*/
|
|
219
227
|
/* This file is automatically generated from @entur/tokens! Changes will be overwritten. */
|
|
228
|
+
.eds-icon-button {
|
|
229
|
+
border: 0.0625rem solid transparent;
|
|
230
|
+
border-radius: 0.25rem;
|
|
231
|
+
background: none;
|
|
232
|
+
color: inherit;
|
|
233
|
+
cursor: pointer;
|
|
234
|
+
display: flex;
|
|
235
|
+
justify-content: center;
|
|
236
|
+
align-items: center;
|
|
237
|
+
font-size: 1rem;
|
|
238
|
+
padding: 0.5rem;
|
|
239
|
+
}
|
|
240
|
+
.eds-contrast .eds-icon-button > .eds-loading-dots .eds-loading-dots__dot {
|
|
241
|
+
background-color: #ffffff;
|
|
242
|
+
}
|
|
243
|
+
.eds-icon-button--size-small {
|
|
244
|
+
height: 1.5rem;
|
|
245
|
+
width: 1.5rem;
|
|
246
|
+
padding: 0;
|
|
247
|
+
}
|
|
248
|
+
.eds-icon-button--size-medium {
|
|
249
|
+
height: 2rem;
|
|
250
|
+
width: 2rem;
|
|
251
|
+
}
|
|
252
|
+
.eds-icon-button:hover {
|
|
253
|
+
background-color: #d1d4e3;
|
|
254
|
+
}
|
|
255
|
+
.eds-contrast .eds-icon-button:hover {
|
|
256
|
+
background-color: #393d79;
|
|
257
|
+
}
|
|
258
|
+
.eds-icon-button:active {
|
|
259
|
+
background: #babbcf;
|
|
260
|
+
}
|
|
261
|
+
.eds-contrast .eds-icon-button:active {
|
|
262
|
+
background: #292b6a;
|
|
263
|
+
}
|
|
264
|
+
.eds-icon-button:focus {
|
|
265
|
+
border: 0.0625rem solid #181c56;
|
|
266
|
+
outline: none;
|
|
267
|
+
}
|
|
268
|
+
.eds-contrast .eds-icon-button:focus {
|
|
269
|
+
border: 0.0625rem solid #ffffff;
|
|
270
|
+
}
|
|
271
|
+
.eds-icon-button--disabled {
|
|
272
|
+
opacity: 0.5;
|
|
273
|
+
pointer-events: none;
|
|
274
|
+
}
|
|
275
|
+
.eds-icon-button--disabled__wrapper {
|
|
276
|
+
cursor: not-allowed;
|
|
277
|
+
width: -moz-fit-content;
|
|
278
|
+
width: fit-content;
|
|
279
|
+
}/* DO NOT CHANGE!*/
|
|
280
|
+
/* This file is automatically generated from @entur/tokens! Changes will be overwritten. */
|
|
220
281
|
.eds-floating-button {
|
|
221
282
|
align-items: center;
|
|
222
283
|
-webkit-appearance: none;
|
|
@@ -290,68 +351,6 @@ a.eds-button--size-large {
|
|
|
290
351
|
margin-right: 0;
|
|
291
352
|
}/* DO NOT CHANGE!*/
|
|
292
353
|
/* This file is automatically generated from @entur/tokens! Changes will be overwritten. */
|
|
293
|
-
.eds-button-group .eds-button {
|
|
294
|
-
margin-right: 0.75rem;
|
|
295
|
-
margin-bottom: 0.75rem;
|
|
296
|
-
}
|
|
297
|
-
.eds-button-group .eds-button:only-child {
|
|
298
|
-
margin: 0;
|
|
299
|
-
}/* DO NOT CHANGE!*/
|
|
300
|
-
/* This file is automatically generated from @entur/tokens! Changes will be overwritten. */
|
|
301
|
-
.eds-icon-button {
|
|
302
|
-
border: 0.0625rem solid transparent;
|
|
303
|
-
border-radius: 0.25rem;
|
|
304
|
-
background: none;
|
|
305
|
-
color: inherit;
|
|
306
|
-
cursor: pointer;
|
|
307
|
-
display: flex;
|
|
308
|
-
justify-content: center;
|
|
309
|
-
align-items: center;
|
|
310
|
-
font-size: 1rem;
|
|
311
|
-
padding: 0.5rem;
|
|
312
|
-
}
|
|
313
|
-
.eds-contrast .eds-icon-button > .eds-loading-dots .eds-loading-dots__dot {
|
|
314
|
-
background-color: #ffffff;
|
|
315
|
-
}
|
|
316
|
-
.eds-icon-button--size-small {
|
|
317
|
-
height: 1.5rem;
|
|
318
|
-
width: 1.5rem;
|
|
319
|
-
padding: 0;
|
|
320
|
-
}
|
|
321
|
-
.eds-icon-button--size-medium {
|
|
322
|
-
height: 2rem;
|
|
323
|
-
width: 2rem;
|
|
324
|
-
}
|
|
325
|
-
.eds-icon-button:hover {
|
|
326
|
-
background-color: #d1d4e3;
|
|
327
|
-
}
|
|
328
|
-
.eds-contrast .eds-icon-button:hover {
|
|
329
|
-
background-color: #393d79;
|
|
330
|
-
}
|
|
331
|
-
.eds-icon-button:active {
|
|
332
|
-
background: #babbcf;
|
|
333
|
-
}
|
|
334
|
-
.eds-contrast .eds-icon-button:active {
|
|
335
|
-
background: #292b6a;
|
|
336
|
-
}
|
|
337
|
-
.eds-icon-button:focus {
|
|
338
|
-
border: 0.0625rem solid #181c56;
|
|
339
|
-
outline: none;
|
|
340
|
-
}
|
|
341
|
-
.eds-contrast .eds-icon-button:focus {
|
|
342
|
-
border: 0.0625rem solid #ffffff;
|
|
343
|
-
}
|
|
344
|
-
.eds-icon-button--disabled {
|
|
345
|
-
opacity: 0.5;
|
|
346
|
-
pointer-events: none;
|
|
347
|
-
}
|
|
348
|
-
.eds-icon-button--disabled__wrapper {
|
|
349
|
-
cursor: not-allowed;
|
|
350
|
-
width: -webkit-fit-content;
|
|
351
|
-
width: -moz-fit-content;
|
|
352
|
-
width: fit-content;
|
|
353
|
-
}/* DO NOT CHANGE!*/
|
|
354
|
-
/* This file is automatically generated from @entur/tokens! Changes will be overwritten. */
|
|
355
354
|
.eds-square-button {
|
|
356
355
|
--icon-color: var(--primary-text-color);
|
|
357
356
|
--icon-background: transparent;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@entur/button",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.6",
|
|
4
4
|
"license": "EUPL-1.2",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/button.esm.js",
|
|
@@ -27,15 +27,17 @@
|
|
|
27
27
|
"react-dom": ">=16.8.0"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@entur/loader": "^0.4.
|
|
31
|
-
"@entur/utils": "^0.4.
|
|
30
|
+
"@entur/loader": "^0.4.14",
|
|
31
|
+
"@entur/utils": "^0.4.7",
|
|
32
32
|
"classnames": "^2.3.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@entur/tokens": "^3.4.2
|
|
35
|
+
"@entur/tokens": "^3.4.2",
|
|
36
36
|
"dts-cli": "^1.1.6",
|
|
37
|
+
"jest": "^27.0.0",
|
|
37
38
|
"jest-watch-typeahead": "^2.2.0",
|
|
38
|
-
"ts-jest": "^27.0.0"
|
|
39
|
+
"ts-jest": "^27.0.0",
|
|
40
|
+
"typescript": "^4.8.0"
|
|
39
41
|
},
|
|
40
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "8915b1630bd936740ba9a4a88883f3432948a80e"
|
|
41
43
|
}
|