@telefonica/mistica 12.4.0 → 12.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/tooltip.d.ts CHANGED
@@ -2,12 +2,14 @@ import * as React from 'react';
2
2
  declare type Position = 'top' | 'bottom' | 'left' | 'right';
3
3
  declare type Props = {
4
4
  children?: React.ReactNode;
5
+ extra?: React.ReactNode;
5
6
  description?: string;
6
7
  target: React.ReactNode;
7
8
  title?: string;
8
9
  position?: Position;
9
10
  width?: number;
10
11
  targetLabel: string;
12
+ delay?: boolean;
11
13
  };
12
14
  declare const Tooltip: React.FC<Props>;
13
15
  export default Tooltip;
package/dist/tooltip.js CHANGED
@@ -6,11 +6,14 @@ exports.default = void 0;
6
6
  var _jsxRuntime = require("react/jsx-runtime");
7
7
  var React = _interopRequireWildcard(require("react"));
8
8
  var _classnames = _interopRequireDefault(require("classnames"));
9
+ var _reactTransitionGroup = require("react-transition-group");
9
10
  var _hooks = require("./hooks");
10
11
  var _portal = require("./portal");
11
12
  var _overlay = _interopRequireDefault(require("./overlay"));
13
+ var _text = require("./text");
12
14
  var key = _interopRequireWildcard(require("./utils/key-codes"));
13
15
  var _jss = require("./jss");
16
+ var _stack = _interopRequireDefault(require("./stack"));
14
17
  function _interopRequireDefault(obj) {
15
18
  return obj && obj.__esModule ? obj : {
16
19
  default: obj
@@ -142,11 +145,16 @@ function _unsupportedIterableToArray(o, minLen) {
142
145
  var defaultPositionDesktop = "bottom";
143
146
  var defaultPositionMobile = "top";
144
147
  var arrowSize = 12;
145
- var distanceToTarget = 8 + arrowSize;
148
+ var distanceToTarget = 4 + arrowSize;
146
149
  var marginLeftRightMobile = 16;
147
150
  var defaultWidthDesktop = 340;
148
151
  var arrowWrapperWidth = arrowSize * 2;
149
152
  var arrowWrapperHeight = arrowSize;
153
+ var transitionDurationMs = 500;
154
+ var animationMovement = 12;
155
+ var animationTiming = "cubic-bezier(0.215, 0.61, 0.355, 1)";
156
+ var defaultShowTooltipDelayMs = 500;
157
+ var noOp = function noOp() {};
150
158
  var useStyles = (0, _jss).createUseStyles(function(theme) {
151
159
  var shadowAlpha = theme.isDarkMode ? 1 : 0.2;
152
160
  return {
@@ -158,7 +166,7 @@ var useStyles = (0, _jss).createUseStyles(function(theme) {
158
166
  top: 0,
159
167
  left: "50%",
160
168
  transform: "translate(-50%, -50%) rotate(45deg)",
161
- border: "1px solid ".concat(theme.colors.divider),
169
+ border: "1px solid ".concat(theme.colors.border),
162
170
  borderRadius: 2
163
171
  },
164
172
  arrowTop: {
@@ -207,42 +215,142 @@ var useStyles = (0, _jss).createUseStyles(function(theme) {
207
215
  left: 16,
208
216
  width: "auto",
209
217
  boxShadow: "0 2px 4px 0 rgba(0, 0, 0, ".concat(shadowAlpha, ")"),
210
- padding: 16,
218
+ padding: 8,
211
219
  backgroundColor: theme.colors.backgroundContainer,
212
- zIndex: 12,
213
- border: "1px solid ".concat(theme.colors.divider),
220
+ zIndex: 50,
221
+ border: "1px solid ".concat(theme.colors.border),
214
222
  borderRadius: 8
223
+ }
224
+ };
225
+ });
226
+ var useAnimationStyles = (0, _jss).createUseStyles(function() {
227
+ return {
228
+ enter: {
229
+ transform: function transform(param) {
230
+ var position = param.position;
231
+ if (position === "bottom") {
232
+ return "translateY(".concat(animationMovement, "px)");
233
+ }
234
+ if (position === "top") {
235
+ return "translateY(calc(-100% - ".concat(animationMovement, "px))");
236
+ }
237
+ if (position === "right") {
238
+ return "translateX(".concat(animationMovement, "px) translateY(-50%)");
239
+ }
240
+ if (position === "left") {
241
+ return "translateX(-".concat(animationMovement, "px) translateY(-50%)");
242
+ }
243
+ return "translateY(-".concat(animationMovement, "px)");
244
+ }
245
+ },
246
+ enterActive: {
247
+ animationName: function animationName(param) {
248
+ var position = param.position;
249
+ if (position === "top") return "$fadeInTop";
250
+ if (position === "bottom") return "$fadeInBottom";
251
+ return "$fadeInX";
252
+ },
253
+ animationFillMode: "both",
254
+ animationDuration: "".concat(transitionDurationMs, "ms"),
255
+ animationTimingFunction: animationTiming
256
+ },
257
+ enterDone: {
258
+ transform: function transform(param) {
259
+ var position = param.position;
260
+ if (position === "top") return "translateY(-100%)";
261
+ if (position === "bottom") return "translateY(0)";
262
+ return "translateY(-50%)";
263
+ }
215
264
  },
216
- title: {
217
- margin: 0,
218
- marginBottom: 12,
219
- color: theme.colors.textPrimary,
220
- lineHeight: 1.42857142,
221
- fontSize: 14
265
+ exit: {
266
+ transform: function transform(param) {
267
+ var position = param.position;
268
+ if (position === "bottom") {
269
+ return "translateY(0)";
270
+ }
271
+ if (position === "top") {
272
+ return "translateY(-100%)";
273
+ }
274
+ if (position === "right") {
275
+ return "translateX(0px) translateY(-50%)";
276
+ }
277
+ if (position === "left") {
278
+ return "translateX(0px) translateY(-50%)";
279
+ }
280
+ return "translateY(0px)";
281
+ },
282
+ opacity: 1,
283
+ transition: "opacity 0.3s ".concat(animationTiming)
284
+ },
285
+ exitActive: {
286
+ animation: "$fadeOut 0.3s ".concat(animationTiming, " both")
222
287
  },
223
- description: {
224
- margin: 0,
225
- color: theme.colors.textPrimary,
226
- lineHeight: 1.42857142,
227
- fontSize: 14
288
+ "@keyframes fadeInBottom": {
289
+ from: {
290
+ opacity: 0
291
+ },
292
+ "40%": {
293
+ opacity: 1
294
+ },
295
+ to: {
296
+ opacity: 1,
297
+ transform: "translateY(0)"
298
+ }
299
+ },
300
+ "@keyframes fadeInTop": {
301
+ from: {
302
+ opacity: 0
303
+ },
304
+ "40%": {
305
+ opacity: 1
306
+ },
307
+ to: {
308
+ opacity: 1,
309
+ transform: "translateY(-100%)"
310
+ }
311
+ },
312
+ "@keyframes fadeInX": {
313
+ from: {
314
+ opacity: 0
315
+ },
316
+ "40%": {
317
+ opacity: 1
318
+ },
319
+ to: {
320
+ opacity: 1,
321
+ transform: "translateX(0) translateY(-50%)"
322
+ }
323
+ },
324
+ "@keyframes fadeOut": {
325
+ from: {
326
+ opacity: 1
327
+ },
328
+ to: {
329
+ opacity: 0
330
+ }
228
331
  }
229
332
  };
230
333
  });
231
334
  var getWidthDesktop = function getWidthDesktop(customWidth) {
232
335
  return customWidth ? customWidth : defaultWidthDesktop;
233
336
  };
234
- var EVENT_THROTTLE_TIME = process.env.NODE_ENV === "test" ? 0 : 200;
235
337
  var Tooltip = function Tooltip(_param) {
236
- var children = _param.children, description = _param.description, target = _param.target, title = _param.title, targetLabel = _param.targetLabel, rest = _objectWithoutProperties(_param, [
338
+ var children = _param.children, extra = _param.extra, description = _param.description, target = _param.target, title = _param.title, targetLabel = _param.targetLabel, _delay = _param.delay, delay = _delay === void 0 ? true : _delay, rest = _objectWithoutProperties(_param, [
237
339
  "children",
340
+ "extra",
238
341
  "description",
239
342
  "target",
240
343
  "title",
241
- "targetLabel"
344
+ "targetLabel",
345
+ "delay"
242
346
  ]);
243
347
  var ref = _slicedToArray(React.useState(false), 2), isVisible = ref[0], setIsVisible = ref[1];
244
348
  var isTabletOrSmaller = (0, _hooks).useScreenSize().isTabletOrSmaller;
245
349
  var ariaId = (0, _hooks).useAriaId();
350
+ var isPointerOver = React.useRef(false);
351
+ var closeTooltipTimeoutId = React.useRef(null);
352
+ var showTooltipTimeoutId = React.useRef(null);
353
+ var targetRef = React.useRef(null);
246
354
  var targetBoundingClientRect = React.useRef({
247
355
  top: 0,
248
356
  right: 0,
@@ -251,10 +359,16 @@ var Tooltip = function Tooltip(_param) {
251
359
  width: 0,
252
360
  height: 0
253
361
  });
254
- // This property is needed because safari is making a mess with the events (it has problems
255
- // when the overlay layer appears and disappears). This way we ensure that events don't get handled twice
256
- var lastChangeTime = React.useRef(0);
362
+ var getPosition = function getPosition() {
363
+ var position = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : defaultPositionDesktop;
364
+ return isTabletOrSmaller && (position === "left" || position === "right") ? defaultPositionMobile : position;
365
+ };
366
+ var position1 = getPosition(rest.position);
257
367
  var classes = useStyles();
368
+ var animationClasses = useAnimationStyles({
369
+ position: position1
370
+ });
371
+ var isTouchableDevice = typeof window !== "undefined" ? window.matchMedia("(pointer: coarse)").matches : false;
258
372
  var closeTooltip = function closeTooltip() {
259
373
  if (isVisible) {
260
374
  setIsVisible(false);
@@ -267,23 +381,16 @@ var Tooltip = function Tooltip(_param) {
267
381
  };
268
382
  });
269
383
  var handleClickOutside = function handleClickOutside() {
270
- if (Date.now() - lastChangeTime.current < EVENT_THROTTLE_TIME) {
271
- return;
272
- }
273
- lastChangeTime.current = Date.now();
274
384
  setIsVisible(false);
275
385
  };
276
- var toggleVisibility = function toggleVisibility(e) {
277
- if (Date.now() - lastChangeTime.current < EVENT_THROTTLE_TIME) {
278
- return;
279
- }
280
- lastChangeTime.current = Date.now();
281
- targetBoundingClientRect.current = e.currentTarget.getBoundingClientRect();
386
+ var toggleVisibility = function toggleVisibility() {
387
+ if (!targetRef.current) return;
388
+ targetBoundingClientRect.current = targetRef.current.getBoundingClientRect();
282
389
  setIsVisible(!isVisible);
283
390
  };
284
- var handleFocus = function handleFocus(e) {
391
+ var handleFocus = function handleFocus() {
285
392
  if (!isVisible) {
286
- toggleVisibility(e);
393
+ toggleVisibility();
287
394
  }
288
395
  };
289
396
  var handleKeyDown = function handleKeyDown(event) {
@@ -292,22 +399,19 @@ var Tooltip = function Tooltip(_param) {
292
399
  }
293
400
  };
294
401
  var getContainerPosition = function getContainerPosition(position, width) {
402
+ if (typeof window === "undefined") {
403
+ return {};
404
+ }
295
405
  var containerPos = {
296
406
  right: {
297
407
  left: targetBoundingClientRect.current.right + distanceToTarget,
298
- top: window.pageYOffset + targetBoundingClientRect.current.top + targetBoundingClientRect.current.height / 2,
299
- transform: "translateY(-50%)",
300
- WebKitTransform: "translateY(-50%)"
408
+ top: window.pageYOffset + targetBoundingClientRect.current.top + targetBoundingClientRect.current.height / 2
301
409
  },
302
410
  left: {
303
411
  left: targetBoundingClientRect.current.left - width - distanceToTarget,
304
- top: window.pageYOffset + targetBoundingClientRect.current.top + targetBoundingClientRect.current.height / 2,
305
- transform: "translateY(-50%)",
306
- WebKitTransform: "translateY(-50%)"
412
+ top: window.pageYOffset + targetBoundingClientRect.current.top + targetBoundingClientRect.current.height / 2
307
413
  },
308
414
  top: {
309
- transform: "translateY(-100%)",
310
- WebKitTransform: "translateY(-100%)",
311
415
  top: window.pageYOffset + targetBoundingClientRect.current.top - distanceToTarget,
312
416
  left: isTabletOrSmaller ? marginLeftRightMobile : window.pageXOffset + targetBoundingClientRect.current.left + targetBoundingClientRect.current.width / 2 - width / 2
313
417
  },
@@ -318,10 +422,6 @@ var Tooltip = function Tooltip(_param) {
318
422
  };
319
423
  return containerPos[position];
320
424
  };
321
- var getPosition = function getPosition() {
322
- var position = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : defaultPositionDesktop;
323
- return isTabletOrSmaller && (position === "left" || position === "right") ? defaultPositionMobile : position;
324
- };
325
425
  var getCustomStylesForMobile = function getCustomStylesForMobile() {
326
426
  return isTabletOrSmaller ? {
327
427
  left: targetBoundingClientRect.current.left + targetBoundingClientRect.current.width / 2 - marginLeftRightMobile
@@ -330,7 +430,6 @@ var Tooltip = function Tooltip(_param) {
330
430
  var getWidth = function getWidth() {
331
431
  return isTabletOrSmaller ? window.innerWidth - marginLeftRightMobile * 2 : getWidthDesktop(rest.width);
332
432
  };
333
- var position1 = getPosition(rest.position);
334
433
  var width1 = getWidth();
335
434
  var classNameByPosition = {
336
435
  top: classes.arrowTop,
@@ -341,8 +440,38 @@ var Tooltip = function Tooltip(_param) {
341
440
  return /*#__PURE__*/ (0, _jsxRuntime).jsxs(_jsxRuntime.Fragment, {
342
441
  children: [
343
442
  /*#__PURE__*/ (0, _jsxRuntime).jsx("div", {
443
+ ref: targetRef,
344
444
  className: classes.wrapper,
345
- onPointerDown: toggleVisibility,
445
+ onPointerOver: function onPointerOver() {
446
+ if (closeTooltipTimeoutId.current) {
447
+ clearTimeout(closeTooltipTimeoutId.current);
448
+ closeTooltipTimeoutId.current = null;
449
+ }
450
+ if (isPointerOver.current) return;
451
+ isPointerOver.current = true;
452
+ if (delay) {
453
+ showTooltipTimeoutId.current = setTimeout(function() {
454
+ showTooltipTimeoutId.current = null;
455
+ toggleVisibility();
456
+ }, defaultShowTooltipDelayMs);
457
+ } else {
458
+ toggleVisibility();
459
+ }
460
+ },
461
+ onPointerLeave: isTouchableDevice ? noOp : function() {
462
+ if (showTooltipTimeoutId.current) {
463
+ clearTimeout(showTooltipTimeoutId.current);
464
+ showTooltipTimeoutId.current = null;
465
+ isPointerOver.current = false;
466
+ return;
467
+ }
468
+ closeTooltipTimeoutId.current = setTimeout(function() {
469
+ if (!isPointerOver.current) return;
470
+ closeTooltipTimeoutId.current = null;
471
+ isPointerOver.current = false;
472
+ toggleVisibility();
473
+ }, 100);
474
+ },
346
475
  onFocus: handleFocus,
347
476
  onKeyDown: handleKeyDown,
348
477
  "touch-action": "auto" // Prop needed for Pointer Events Polyfill to work properly
@@ -354,40 +483,67 @@ var Tooltip = function Tooltip(_param) {
354
483
  "aria-label": targetLabel,
355
484
  children: target
356
485
  }),
357
- isVisible && /*#__PURE__*/ (0, _jsxRuntime).jsxs(_portal.Portal, {
486
+ /*#__PURE__*/ (0, _jsxRuntime).jsxs(_portal.Portal, {
358
487
  children: [
359
- /*#__PURE__*/ (0, _jsxRuntime).jsx(_overlay.default, {
488
+ isVisible && isTouchableDevice && /*#__PURE__*/ (0, _jsxRuntime).jsx(_overlay.default, {
360
489
  onPress: handleClickOutside
361
490
  }),
362
- /*#__PURE__*/ (0, _jsxRuntime).jsxs("div", {
363
- role: "tooltip",
364
- id: ariaId,
365
- className: classes.container,
366
- style: _objectSpread({
367
- width: width1
368
- }, getContainerPosition(position1, width1)),
369
- children: [
370
- /*#__PURE__*/ (0, _jsxRuntime).jsx("div", {
371
- className: (0, _classnames).default(classes.arrowWrapper, classNameByPosition[position1]),
372
- style: getCustomStylesForMobile(),
373
- children: /*#__PURE__*/ (0, _jsxRuntime).jsx("div", {
374
- className: classes.arrow
375
- })
376
- }),
377
- (title || description) && /*#__PURE__*/ (0, _jsxRuntime).jsxs(_jsxRuntime.Fragment, {
378
- children: [
379
- title && /*#__PURE__*/ (0, _jsxRuntime).jsx("p", {
380
- className: classes.title,
381
- children: title
382
- }),
383
- description && /*#__PURE__*/ (0, _jsxRuntime).jsx("p", {
384
- className: classes.description,
385
- children: description
491
+ /*#__PURE__*/ (0, _jsxRuntime).jsx(_reactTransitionGroup.CSSTransition, {
492
+ in: isVisible,
493
+ timeout: transitionDurationMs,
494
+ classNames: {
495
+ enter: animationClasses.enter,
496
+ enterActive: animationClasses.enterActive,
497
+ enterDone: animationClasses.enterDone,
498
+ exit: animationClasses.exit,
499
+ exitActive: animationClasses.exitActive
500
+ },
501
+ unmountOnExit: true,
502
+ children: /*#__PURE__*/ (0, _jsxRuntime).jsxs("div", {
503
+ role: "tooltip",
504
+ id: ariaId,
505
+ className: classes.container,
506
+ style: _objectSpread({
507
+ width: width1
508
+ }, getContainerPosition(position1, width1)),
509
+ onPointerOver: function onPointerOver() {
510
+ if (closeTooltipTimeoutId.current) {
511
+ clearTimeout(closeTooltipTimeoutId.current);
512
+ closeTooltipTimeoutId.current = null;
513
+ }
514
+ },
515
+ onPointerLeave: isTouchableDevice ? noOp : function() {
516
+ closeTooltipTimeoutId.current = setTimeout(function() {
517
+ if (!isPointerOver.current) return;
518
+ closeTooltipTimeoutId.current = null;
519
+ isPointerOver.current = false;
520
+ toggleVisibility();
521
+ }, 100);
522
+ },
523
+ children: [
524
+ /*#__PURE__*/ (0, _jsxRuntime).jsx("div", {
525
+ className: (0, _classnames).default(classes.arrowWrapper, classNameByPosition[position1]),
526
+ style: getCustomStylesForMobile(),
527
+ children: /*#__PURE__*/ (0, _jsxRuntime).jsx("div", {
528
+ className: classes.arrow
386
529
  })
387
- ]
388
- }),
389
- children
390
- ]
530
+ }),
531
+ (title || description) && /*#__PURE__*/ (0, _jsxRuntime).jsxs(_stack.default, {
532
+ space: 4,
533
+ children: [
534
+ title && /*#__PURE__*/ (0, _jsxRuntime).jsx(_text.Text2, {
535
+ medium: true,
536
+ children: title
537
+ }),
538
+ description && /*#__PURE__*/ (0, _jsxRuntime).jsx(_text.Text2, {
539
+ regular: true,
540
+ children: description
541
+ })
542
+ ]
543
+ }),
544
+ extra || children
545
+ ]
546
+ })
391
547
  })
392
548
  ]
393
549
  })
@@ -4,12 +4,14 @@ import * as React from "react";
4
4
  declare type Position = "top" | "bottom" | "left" | "right";
5
5
  declare type Props = {
6
6
  children?: React.Node,
7
+ extra?: React.Node,
7
8
  description?: string,
8
9
  target: React.Node,
9
10
  title?: string,
10
11
  position?: Position,
11
12
  width?: number,
12
13
  targetLabel: string,
14
+ delay?: boolean,
13
15
  };
14
16
  declare var Tooltip: React.ComponentType<Props>;
15
17
  declare export default typeof Tooltip;
@@ -21,6 +21,7 @@ interface CommonProps {
21
21
  role?: string;
22
22
  type?: 'button' | 'submit';
23
23
  tabIndex?: number;
24
+ as?: 'a';
24
25
  }
25
26
  export interface PropsHref extends CommonProps {
26
27
  href: string;
@@ -66,5 +67,6 @@ export interface PropsMaybeOnPress extends CommonProps {
66
67
  formId?: string;
67
68
  }
68
69
  export declare type Props = PropsHref | PropsTo | PropsOnPress | PropsMaybeHref | PropsMaybeTo | PropsMaybeOnPress;
69
- declare const Touchable: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLAnchorElement | HTMLDivElement | HTMLButtonElement>>;
70
+ export declare type TouchableElement = HTMLDivElement | HTMLAnchorElement | HTMLButtonElement;
71
+ declare const Touchable: React.ForwardRefExoticComponent<Props & React.RefAttributes<TouchableElement>>;
70
72
  export default Touchable;
package/dist/touchable.js CHANGED
@@ -237,7 +237,12 @@ var Touchable = /*#__PURE__*/ React.forwardRef(function(props, ref) {
237
237
  }));
238
238
  }
239
239
  if (props.onPress) {
240
- return /*#__PURE__*/ (0, _jsxRuntime).jsx("button", _objectSpread({}, commonProps, {
240
+ var _as;
241
+ var elementType = (_as = props.as) !== null && _as !== void 0 ? _as : "button";
242
+ var _role;
243
+ var role = (_role = commonProps.role) !== null && _role !== void 0 ? _role : props.as === "a" ? "button" : undefined;
244
+ return /*#__PURE__*/ React.createElement(elementType, _objectSpread({}, commonProps, {
245
+ role: role,
241
246
  // this "form" attribute is useful when the form's submit button
242
247
  // is located outside the <form> element, for example if you use
243
248
  // a ButtonFixedFooter layout inside a form with the submit
@@ -26,6 +26,7 @@ declare type CommonProps = {
26
26
  role?: string,
27
27
  type?: "button" | "submit",
28
28
  tabIndex?: number,
29
+ as?: "a",
29
30
  };
30
31
  export type PropsHref = {
31
32
  ...$Exact<CommonProps>,
@@ -71,7 +72,11 @@ export type Props =
71
72
  | PropsMaybeHref
72
73
  | PropsMaybeTo
73
74
  | PropsMaybeOnPress;
74
- declare var Touchable: React.AbstractComponent<Props, HTMLAnchorElement | HTMLDivElement | HTMLButtonElement>;
75
+ export type TouchableElement =
76
+ | HTMLDivElement
77
+ | HTMLAnchorElement
78
+ | HTMLButtonElement;
79
+ declare var Touchable: React.AbstractComponent<Props, TouchableElement>;
75
80
  declare export default typeof Touchable;
76
81
 
77
82
  import { type CssStyle } from "./__css_types__.js.flow";
package/dist-es/button.js CHANGED
@@ -313,9 +313,9 @@ var renderButtonContent = function(param) {
313
313
  });
314
314
  return resultChildrenArr;
315
315
  };
316
- var Button = function(props) {
316
+ var Button = /*#__PURE__*/ React.forwardRef(function(props, ref) {
317
317
  var eventFormat = useTrackingConfig().eventFormat;
318
- var ref = useForm(), formStatus = ref.formStatus, formId = ref.formId;
318
+ var _$ref = useForm(), formStatus = _$ref.formStatus, formId = _$ref.formId;
319
319
  var isInverse = useIsInverseVariant();
320
320
  var classes = props.classes, loadingText = props.loadingText;
321
321
  var isSubmitButton = !!props.submit;
@@ -325,7 +325,7 @@ var Button = function(props) {
325
325
  // specially in iPhone). But we want the spinner to be visible during the show/hide animation.
326
326
  // * When showSpinner prop is true, state is changed immediately.
327
327
  // * When the transition ends this state is updated again if needed
328
- var ref1 = _slicedToArray(React.useState(!!showSpinner), 2), shouldRenderSpinner = ref1[0], setShouldRenderSpinner = ref1[1];
328
+ var _$ref1 = _slicedToArray(React.useState(!!showSpinner), 2), shouldRenderSpinner = _$ref1[0], setShouldRenderSpinner = _$ref1[1];
329
329
  React.useEffect(function() {
330
330
  if (showSpinner && !shouldRenderSpinner) {
331
331
  setShouldRenderSpinner(true);
@@ -372,6 +372,7 @@ var Button = function(props) {
372
372
  var _trackingEvent;
373
373
  var _obj;
374
374
  var commonProps = {
375
+ ref: ref,
375
376
  className: classnames(classes.button, props.className, (_obj = {}, _defineProperty(_obj, classes.small, props.small), _defineProperty(_obj, classes.inverse, isInverse), _defineProperty(_obj, classes.light, !isInverse), _defineProperty(_obj, classes.isLoading, showSpinner), _obj)),
376
377
  style: _objectSpread({
377
378
  cursor: props.fake ? "pointer" : undefined
@@ -485,7 +486,7 @@ var Button = function(props) {
485
486
  throw Error("Bad button props");
486
487
  }
487
488
  return null;
488
- };
489
+ });
489
490
  var useButtonLinkStyles = createUseStyles(function(theme) {
490
491
  var paddingY = 6;
491
492
  var paddingX = 12;
@@ -611,24 +612,27 @@ export var ButtonLink = /*#__PURE__*/ React.forwardRef(function(props, ref) {
611
612
  }
612
613
  return null;
613
614
  });
614
- export var ButtonPrimary = function(props) {
615
+ export var ButtonPrimary = /*#__PURE__*/ React.forwardRef(function(props, ref) {
615
616
  var classes = usePrimaryButtonStyles();
616
617
  return /*#__PURE__*/ _jsx(Button, _objectSpread({}, props, {
618
+ ref: ref,
617
619
  classes: classes,
618
620
  type: "primary"
619
621
  }));
620
- };
621
- export var ButtonSecondary = function(props) {
622
+ });
623
+ export var ButtonSecondary = /*#__PURE__*/ React.forwardRef(function(props, ref) {
622
624
  var classes = useSecondaryButtonStyles();
623
625
  return /*#__PURE__*/ _jsx(Button, _objectSpread({}, props, {
626
+ ref: ref,
624
627
  classes: classes,
625
628
  type: "secondary"
626
629
  }));
627
- };
628
- export var ButtonDanger = function(props) {
630
+ });
631
+ export var ButtonDanger = /*#__PURE__*/ React.forwardRef(function(props, ref) {
629
632
  var classes = useDangerButtonStyles();
630
633
  return /*#__PURE__*/ _jsx(Button, _objectSpread({}, props, {
634
+ ref: ref,
631
635
  classes: classes,
632
636
  type: "danger"
633
637
  }));
634
- };
638
+ });