glints-aries 4.0.193 → 4.0.195

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.
Files changed (55) hide show
  1. package/es/@next/CurrencyInput/CurrencyInput.d.ts +4 -0
  2. package/es/@next/CurrencyInput/CurrencyInput.js +26 -4
  3. package/es/@next/Input/Input.js +31 -4
  4. package/es/@next/Input/InputStyle.d.ts +6 -1
  5. package/es/@next/Input/InputStyle.js +8 -3
  6. package/es/@next/Popover/popoverStoryHelper/SalarySelector.js +2 -0
  7. package/es/@next/Tooltip/Tooltip.d.ts +10 -0
  8. package/es/@next/Tooltip/Tooltip.js +133 -0
  9. package/es/@next/Tooltip/Tooltip.stories.d.ts +4 -0
  10. package/es/@next/Tooltip/TooltipAdaptiveBottom.stories.d.ts +6 -0
  11. package/es/@next/Tooltip/TooltipAdaptiveLeft.stories.d.ts +6 -0
  12. package/es/@next/Tooltip/TooltipAdaptiveRight.stories.d.ts +6 -0
  13. package/es/@next/Tooltip/TooltipAdaptiveTop.stories.d.ts +6 -0
  14. package/es/@next/Tooltip/TooltipStyle.d.ts +3 -0
  15. package/es/@next/Tooltip/TooltipStyle.js +22 -0
  16. package/es/@next/Tooltip/index.d.ts +1 -0
  17. package/es/@next/Tooltip/index.js +1 -0
  18. package/es/@next/Tooltip/positionResolver.d.ts +6 -0
  19. package/es/@next/Tooltip/positionResolver.js +181 -0
  20. package/es/@next/Tooltip/positionResolverHelper.d.ts +37 -0
  21. package/es/@next/Tooltip/positionResolverHelper.js +106 -0
  22. package/es/@next/index.d.ts +1 -0
  23. package/es/@next/index.js +1 -0
  24. package/es/helpers/viewPort.d.ts +4 -0
  25. package/es/helpers/viewPort.js +8 -0
  26. package/lib/@next/CurrencyInput/CurrencyInput.d.ts +4 -0
  27. package/lib/@next/CurrencyInput/CurrencyInput.js +26 -4
  28. package/lib/@next/Input/Input.js +33 -4
  29. package/lib/@next/Input/InputStyle.d.ts +6 -1
  30. package/lib/@next/Input/InputStyle.js +8 -3
  31. package/lib/@next/Popover/popoverStoryHelper/SalarySelector.js +2 -0
  32. package/lib/@next/Tooltip/Tooltip.d.ts +10 -0
  33. package/lib/@next/Tooltip/Tooltip.js +140 -0
  34. package/lib/@next/Tooltip/Tooltip.stories.d.ts +4 -0
  35. package/lib/@next/Tooltip/TooltipAdaptiveBottom.stories.d.ts +6 -0
  36. package/lib/@next/Tooltip/TooltipAdaptiveLeft.stories.d.ts +6 -0
  37. package/lib/@next/Tooltip/TooltipAdaptiveRight.stories.d.ts +6 -0
  38. package/lib/@next/Tooltip/TooltipAdaptiveTop.stories.d.ts +6 -0
  39. package/lib/@next/Tooltip/TooltipStyle.d.ts +3 -0
  40. package/lib/@next/Tooltip/TooltipStyle.js +32 -0
  41. package/lib/@next/Tooltip/index.d.ts +1 -0
  42. package/lib/@next/Tooltip/index.js +9 -0
  43. package/lib/@next/Tooltip/positionResolver.d.ts +6 -0
  44. package/lib/@next/Tooltip/positionResolver.js +189 -0
  45. package/lib/@next/Tooltip/positionResolverHelper.d.ts +37 -0
  46. package/lib/@next/Tooltip/positionResolverHelper.js +130 -0
  47. package/lib/@next/index.d.ts +1 -0
  48. package/lib/@next/index.js +5 -1
  49. package/lib/helpers/viewPort.d.ts +4 -0
  50. package/lib/helpers/viewPort.js +13 -0
  51. package/package.json +1 -1
  52. package/es/@next/CurrencyInput/CurrencyStyles.d.ts +0 -2
  53. package/es/@next/CurrencyInput/CurrencyStyles.js +0 -7
  54. package/lib/@next/CurrencyInput/CurrencyStyles.d.ts +0 -2
  55. package/lib/@next/CurrencyInput/CurrencyStyles.js +0 -13
@@ -4,9 +4,13 @@ export declare type CurrencyInputProps = Omit<InputProps, 'type' | 'prefix' | 'o
4
4
  locale?: string;
5
5
  value?: number;
6
6
  onChange?: (value: number) => void;
7
+ currencyCode: string;
8
+ currencySymbol?: string;
7
9
  };
8
10
  export declare const CurrencyInput: React.ForwardRefExoticComponent<Omit<InputProps, "type" | "value" | "prefix" | "onChange"> & {
9
11
  locale?: string;
10
12
  value?: number;
11
13
  onChange?: (value: number) => void;
14
+ currencyCode: string;
15
+ currencySymbol?: string;
12
16
  } & React.RefAttributes<HTMLInputElement>>;
@@ -1,14 +1,16 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
3
- var _excluded = ["locale", "value", "onChange"];
3
+ var _excluded = ["locale", "value", "onChange", "currencyCode", "currencySymbol"];
4
4
  import React, { useState } from 'react';
5
- import { StyledCurrency } from './CurrencyStyles';
5
+ import { Input } from '../Input/Input';
6
6
  export var CurrencyInput = /*#__PURE__*/React.forwardRef(function CurrencyInput(_ref, ref) {
7
7
  var _ref$locale = _ref.locale,
8
8
  locale = _ref$locale === void 0 ? 'en' : _ref$locale,
9
9
  _ref$value = _ref.value,
10
10
  value = _ref$value === void 0 ? 0 : _ref$value,
11
11
  onChange = _ref.onChange,
12
+ currencyCode = _ref.currencyCode,
13
+ currencySymbol = _ref.currencySymbol,
12
14
  props = _objectWithoutPropertiesLoose(_ref, _excluded);
13
15
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
14
16
  // @ts-ignore
@@ -28,6 +30,26 @@ export var CurrencyInput = /*#__PURE__*/React.forwardRef(function CurrencyInput(
28
30
  var cleanedValue = parseFloat(value.replace(new RegExp('\\' + thousandSeparator, 'g'), '').replace(new RegExp('\\' + decimalSeparator), '.'));
29
31
  return Number.isNaN(cleanedValue) ? 0 : cleanedValue;
30
32
  };
33
+ var getCurrencySymbol = function getCurrencySymbol(locale, currencyCode, currencySymbol) {
34
+ if (currencySymbol) {
35
+ return currencySymbol;
36
+ }
37
+ try {
38
+ var _parts$find;
39
+ var _formatter = new Intl.NumberFormat(locale, {
40
+ style: 'currency',
41
+ currency: currencyCode
42
+ });
43
+ var parts = _formatter.formatToParts(0);
44
+ var returnedCurrencySymbol = (_parts$find = parts.find(function (part) {
45
+ return part.type === 'currency';
46
+ })) == null ? void 0 : _parts$find.value;
47
+ return returnedCurrencySymbol;
48
+ } catch (e) {
49
+ console.warn("Currency code of " + currencyCode + " is unsupported, \"$\" will be used");
50
+ }
51
+ return '$';
52
+ };
31
53
  var _useState = useState(formatter.format(getRawNumber(value.toString()))),
32
54
  formattedValue = _useState[0],
33
55
  setFormattedValue = _useState[1];
@@ -36,10 +58,10 @@ export var CurrencyInput = /*#__PURE__*/React.forwardRef(function CurrencyInput(
36
58
  onChange(rawValue);
37
59
  setFormattedValue(formatter.format(rawValue));
38
60
  };
39
- return /*#__PURE__*/React.createElement(StyledCurrency, _extends({
61
+ return /*#__PURE__*/React.createElement(Input, _extends({
40
62
  ref: ref,
41
63
  type: "text",
42
- prefix: /*#__PURE__*/React.createElement("div", null, "$")
64
+ prefix: /*#__PURE__*/React.createElement("div", null, getCurrencySymbol(localeValue, currencyCode, currencySymbol))
43
65
  }, props, {
44
66
  value: formattedValue === '0' ? '' : formattedValue,
45
67
  onChange: handleChange
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
3
3
  var _excluded = ["error", "disabled", "prefix", "suffix"];
4
- import React from 'react';
4
+ import React, { useEffect, useRef } from 'react';
5
5
  import { StyledContainer, StyledInput, StyledPrefixContainer, StyledSuffixContainer } from './InputStyle';
6
6
  export var Input = /*#__PURE__*/React.forwardRef(function Input(_ref, ref) {
7
7
  var error = _ref.error,
@@ -11,17 +11,44 @@ export var Input = /*#__PURE__*/React.forwardRef(function Input(_ref, ref) {
11
11
  props = _objectWithoutPropertiesLoose(_ref, _excluded);
12
12
  var hasPrefix = !!prefix;
13
13
  var hasSuffix = !!suffix;
14
+ var prefixRef = useRef(null);
15
+ var suffixRef = useRef(null);
14
16
  var Prefix = function Prefix() {
15
- return hasPrefix ? /*#__PURE__*/React.createElement(StyledPrefixContainer, null, prefix) : null;
17
+ return hasPrefix ? /*#__PURE__*/React.createElement(StyledPrefixContainer, {
18
+ ref: prefixRef
19
+ }, prefix) : null;
16
20
  };
17
21
  var Suffix = function Suffix() {
18
- return hasSuffix ? /*#__PURE__*/React.createElement(StyledSuffixContainer, null, suffix) : null;
22
+ return hasSuffix ? /*#__PURE__*/React.createElement(StyledSuffixContainer, {
23
+ ref: suffixRef
24
+ }, suffix) : null;
19
25
  };
26
+ var _React$useState = React.useState(0),
27
+ prefixWidth = _React$useState[0],
28
+ setPrefixWidth = _React$useState[1];
29
+ var _React$useState2 = React.useState(0),
30
+ suffixWidth = _React$useState2[0],
31
+ setSuffixWidth = _React$useState2[1];
32
+ useEffect(function () {
33
+ if (hasPrefix) {
34
+ var _prefixWidth = prefixRef.current.getBoundingClientRect().width;
35
+ setPrefixWidth(_prefixWidth);
36
+ }
37
+ }, [hasPrefix, prefix]);
38
+ useEffect(function () {
39
+ if (hasSuffix) {
40
+ var _suffixWidth = suffixRef.current.getBoundingClientRect().width;
41
+ setSuffixWidth(_suffixWidth);
42
+ }
43
+ }, [hasSuffix, suffix]);
20
44
  return /*#__PURE__*/React.createElement(StyledContainer, {
21
45
  ref: ref,
22
46
  "data-prefix": hasPrefix,
47
+ "data-suffix": hasSuffix,
23
48
  "data-error": error,
24
- "data-disabled": disabled
49
+ "data-disabled": disabled,
50
+ prefixWidth: prefixWidth,
51
+ suffixWidth: suffixWidth
25
52
  }, /*#__PURE__*/React.createElement(Prefix, null), /*#__PURE__*/React.createElement(StyledInput, _extends({
26
53
  disabled: disabled
27
54
  }, props)), /*#__PURE__*/React.createElement(Suffix, null));
@@ -1,5 +1,10 @@
1
1
  import { InputProps } from './Input';
2
- export declare const StyledContainer: import("styled-components").StyledComponent<"div", any, InputProps, never>;
2
+ interface PreffixSuffixWidthProps {
3
+ prefixWidth: number;
4
+ suffixWidth: number;
5
+ }
6
+ export declare const StyledContainer: import("styled-components").StyledComponent<"div", any, InputProps & PreffixSuffixWidthProps, never>;
3
7
  export declare const StyledPrefixContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
4
8
  export declare const StyledSuffixContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
5
9
  export declare const StyledInput: import("styled-components").StyledComponent<"input", any, InputProps, never>;
10
+ export {};
@@ -1,18 +1,23 @@
1
1
  import styled from 'styled-components';
2
2
  import * as Breakpoints from '../utilities/breakpoints';
3
3
  import { Neutral, Red } from '../utilities/colors';
4
+ import { space12, space4, space8 } from '../utilities/spacing';
4
5
  export var StyledContainer = styled.div.withConfig({
5
6
  displayName: "InputStyle__StyledContainer",
6
7
  componentId: "sc-15z2mnd-0"
7
- })(["position:relative;display:flex;flex-direction:column;flex:1;flex-basis:100%;font-family:'Noto Sans',sans-serif;font-style:normal;font-weight:400;font-size:16px;line-height:150%;&[data-prefix='true'] input{padding-left:40px;}&[data-error='true'] input{border:1px solid ", ";}&[data-error='true'] input:focus{box-shadow:none;}&[data-disabled='true'] input{border:1px solid ", ";background:", ";color:", ";}&[data-disabled='true'] input::placeholder{color:", ";}&[data-disabled='true'] svg{fill:", ";}&[data-disabled='true'] div{color:", ";}"], Red.B93, Neutral.B85, Neutral.B95, Neutral.B85, Neutral.B85, Neutral.B85, Neutral.B85);
8
+ })(["position:relative;display:flex;flex-direction:column;flex:1;flex-basis:100%;font-family:'Noto Sans',sans-serif;font-style:normal;font-weight:400;font-size:16px;line-height:150%;&[data-prefix='true'] input{padding-left:", "px;}&[data-suffix='true'] input{padding-right:", "px;}&[data-error='true'] input{border:1px solid ", ";}&[data-error='true'] input:focus{box-shadow:none;}&[data-disabled='true'] input{border:1px solid ", ";background:", ";color:", ";}&[data-disabled='true'] input::placeholder{color:", ";}&[data-disabled='true'] svg{fill:", ";}&[data-disabled='true'] div{color:", ";}"], function (props) {
9
+ return props.prefixWidth;
10
+ }, function (props) {
11
+ return props.suffixWidth;
12
+ }, Red.B93, Neutral.B85, Neutral.B95, Neutral.B85, Neutral.B85, Neutral.B85, Neutral.B85);
8
13
  export var StyledPrefixContainer = styled.div.withConfig({
9
14
  displayName: "InputStyle__StyledPrefixContainer",
10
15
  componentId: "sc-15z2mnd-1"
11
- })(["position:absolute;padding:0;left:0;line-height:0;color:", ";svg{height:17px;width:17px;margin:10px 14px;fill:", ";}div{color:", ";margin:18px 12px;}"], Neutral.B40, Neutral.B40, Neutral.B40);
16
+ })(["position:absolute;left:0;color:", ";display:flex;align-items:center;height:36px;padding:0px ", " 0 ", ";svg{height:17px;width:17px;fill:", ";}"], Neutral.B40, space8, space12, Neutral.B40);
12
17
  export var StyledSuffixContainer = styled(StyledPrefixContainer).withConfig({
13
18
  displayName: "InputStyle__StyledSuffixContainer",
14
19
  componentId: "sc-15z2mnd-2"
15
- })(["left:auto;right:0;"]);
20
+ })(["left:auto;right:0;padding:0px ", " 0 ", ";"], space12, space4);
16
21
  export var StyledInput = styled.input.withConfig({
17
22
  displayName: "InputStyle__StyledInput",
18
23
  componentId: "sc-15z2mnd-3"
@@ -15,8 +15,10 @@ export var SalarySelector = function SalarySelector(_ref) {
15
15
  as: "div",
16
16
  variant: "caption"
17
17
  }, "IDR"), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(CurrencyInput, {
18
+ currencyCode: "USD",
18
19
  onChange: onFromChanged
19
20
  })), /*#__PURE__*/React.createElement("div", null, "-"), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(CurrencyInput, {
21
+ currencyCode: "USD",
20
22
  onChange: onToChanged
21
23
  }))));
22
24
  };
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ declare const allPositions: readonly ["top-center", "top-left", "top-right", "bottom-center", "bottom-left", "bottom-right", "right-middle", "right-top", "right-bottom", "left-middle", "left-top", "left-bottom"];
3
+ export declare type TooltipPosition = typeof allPositions[number];
4
+ export declare type TooltipProps = {
5
+ preferredPosition?: TooltipPosition;
6
+ children: React.ReactNode;
7
+ content: React.ReactNode;
8
+ };
9
+ export declare const Tooltip: ({ children, content, preferredPosition, }: TooltipProps) => JSX.Element;
10
+ export {};
@@ -0,0 +1,133 @@
1
+ import React, { useEffect, useRef, useState } from 'react';
2
+ import { Portal } from '../Portal/Portal';
3
+ import { Typography } from '../Typography';
4
+ import { bottomPositionResolver, leftPositionResolver, rightPositionResolver, topPositionResolver } from './positionResolver';
5
+ import { canAlignBottom, canAlignCenter, canAlignLeft, canAlignMiddle, canAlignRight, canAlignTop, horizontalBuffer, verticalBuffer } from './positionResolverHelper';
6
+ import { StyledTooltip, StyledTooltipArrow, StyledTooltipContainer } from './TooltipStyle';
7
+ var topPositions = ['top-center', 'top-left', 'top-right'];
8
+ var bottomPositions = ['bottom-center', 'bottom-left', 'bottom-right'];
9
+ var rightPositions = ['right-middle', 'right-top', 'right-bottom'];
10
+ var leftPositions = ['left-middle', 'left-top', 'left-bottom'];
11
+ var allPositions = [].concat(topPositions, bottomPositions, rightPositions, leftPositions);
12
+ var tooltipPositionResolvers = {
13
+ 'top-center': function topCenter(tooltipRect, elementRect) {
14
+ return topPositionResolver(tooltipRect, elementRect, [canAlignCenter, canAlignLeft, canAlignRight]);
15
+ },
16
+ 'top-left': function topLeft(tooltipRect, elementRect) {
17
+ return topPositionResolver(tooltipRect, elementRect, [canAlignLeft, canAlignCenter, canAlignRight]);
18
+ },
19
+ 'top-right': function topRight(tooltipRect, elementRect) {
20
+ return topPositionResolver(tooltipRect, elementRect, [canAlignRight, canAlignCenter, canAlignLeft]);
21
+ },
22
+ 'bottom-center': function bottomCenter(tooltipRect, elementRect) {
23
+ return bottomPositionResolver(tooltipRect, elementRect, [canAlignCenter, canAlignLeft, canAlignRight]);
24
+ },
25
+ 'bottom-left': function bottomLeft(tooltipRect, elementRect) {
26
+ return bottomPositionResolver(tooltipRect, elementRect, [canAlignLeft, canAlignCenter, canAlignRight]);
27
+ },
28
+ 'bottom-right': function bottomRight(tooltipRect, elementRect) {
29
+ return bottomPositionResolver(tooltipRect, elementRect, [canAlignRight, canAlignCenter, canAlignLeft]);
30
+ },
31
+ 'right-middle': function rightMiddle(tooltipRect, elementRect) {
32
+ return rightPositionResolver(tooltipRect, elementRect, [canAlignMiddle, canAlignTop, canAlignBottom]);
33
+ },
34
+ 'right-top': function rightTop(tooltipRect, elementRect) {
35
+ return rightPositionResolver(tooltipRect, elementRect, [canAlignTop, canAlignMiddle, canAlignBottom]);
36
+ },
37
+ 'right-bottom': function rightBottom(tooltipRect, elementRect) {
38
+ return rightPositionResolver(tooltipRect, elementRect, [canAlignBottom, canAlignMiddle, canAlignTop]);
39
+ },
40
+ 'left-middle': function leftMiddle(tooltipRect, elementRect) {
41
+ return leftPositionResolver(tooltipRect, elementRect, [canAlignMiddle, canAlignTop, canAlignBottom]);
42
+ },
43
+ 'left-top': function leftTop(tooltipRect, elementRect) {
44
+ return leftPositionResolver(tooltipRect, elementRect, [canAlignTop, canAlignMiddle, canAlignBottom]);
45
+ },
46
+ 'left-bottom': function leftBottom(tooltipRect, elementRect) {
47
+ return leftPositionResolver(tooltipRect, elementRect, [canAlignBottom, canAlignMiddle, canAlignTop]);
48
+ }
49
+ };
50
+ var defaultPosition = 'top-center';
51
+ export var Tooltip = function Tooltip(_ref) {
52
+ var children = _ref.children,
53
+ content = _ref.content,
54
+ _ref$preferredPositio = _ref.preferredPosition,
55
+ preferredPosition = _ref$preferredPositio === void 0 ? defaultPosition : _ref$preferredPositio;
56
+ var tooltipRef = useRef(null);
57
+ var elRef = useRef(null);
58
+ var tooltipPositionsHandlerRef = useRef(null);
59
+ var _useState = useState(null),
60
+ toolTipCoord = _useState[0],
61
+ setToolTipCoord = _useState[1];
62
+ var _useState2 = useState(false),
63
+ isActive = _useState2[0],
64
+ setIsActive = _useState2[1];
65
+ var _useState3 = useState(null),
66
+ overridePosition = _useState3[0],
67
+ setOverridePosition = _useState3[1];
68
+ if (!allPositions.includes(preferredPosition)) {
69
+ preferredPosition = defaultPosition;
70
+ console.warn("\"" + preferredPosition + "\" is not a valid tooltip positon, \"" + defaultPosition + "\" will be used instead");
71
+ }
72
+ var position = overridePosition || preferredPosition;
73
+ var handleTooltipPositions = function handleTooltipPositions(tooltipRect, elRect, currentPosition) {
74
+ var resolver = tooltipPositionResolvers[position] || tooltipPositionResolvers[defaultPosition];
75
+ var newLeft = 0;
76
+ var newTop = 0;
77
+ if (position.startsWith('top')) {
78
+ newTop = elRect.top - tooltipRect.height - verticalBuffer;
79
+ newLeft = elRect.left + elRect.width / 2;
80
+ }
81
+ if (position.startsWith('bottom')) {
82
+ newTop = elRect.top + elRect.height + verticalBuffer;
83
+ newLeft = elRect.left + elRect.width / 2;
84
+ }
85
+ if (position.startsWith('left')) {
86
+ newTop = elRect.top + elRect.height / 2;
87
+ newLeft = elRect.left - tooltipRect.width - horizontalBuffer;
88
+ }
89
+ if (position.startsWith('right')) {
90
+ newTop = elRect.top + elRect.height / 2;
91
+ newLeft = elRect.left + elRect.width + horizontalBuffer;
92
+ }
93
+ setToolTipCoord({
94
+ top: newTop,
95
+ left: newLeft
96
+ });
97
+ var tooltipRectNew = new DOMRect(newLeft, newTop, tooltipRect.width, tooltipRect.height);
98
+ var resolvedPosition = resolver(tooltipRectNew, elRect);
99
+ if (!overridePosition && resolvedPosition !== currentPosition) {
100
+ setOverridePosition(resolvedPosition);
101
+ }
102
+ };
103
+ tooltipPositionsHandlerRef.current = handleTooltipPositions;
104
+ useEffect(function () {
105
+ if (isActive) {
106
+ var _tooltipRef$current, _elRef$current;
107
+ tooltipPositionsHandlerRef.current(tooltipRef == null ? void 0 : (_tooltipRef$current = tooltipRef.current) == null ? void 0 : _tooltipRef$current.getClientRects()[0], elRef == null ? void 0 : (_elRef$current = elRef.current) == null ? void 0 : _elRef$current.getClientRects()[0], position);
108
+ }
109
+ }, [isActive, position]);
110
+ var contentMarkup = typeof content === 'string' ? /*#__PURE__*/React.createElement(Typography, {
111
+ as: "div",
112
+ variant: "body1"
113
+ }, content) : content;
114
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(StyledTooltipContainer, {
115
+ ref: elRef,
116
+ onMouseEnter: function onMouseEnter() {
117
+ return setIsActive(true);
118
+ },
119
+ onMouseLeave: function onMouseLeave() {
120
+ return setIsActive(false);
121
+ }
122
+ }, children), isActive && /*#__PURE__*/React.createElement(Portal, null, /*#__PURE__*/React.createElement(StyledTooltip, {
123
+ "data-position": position,
124
+ ref: tooltipRef,
125
+ style: {
126
+ top: (toolTipCoord == null ? void 0 : toolTipCoord.top) + 'px',
127
+ left: (toolTipCoord == null ? void 0 : toolTipCoord.left) + 'px',
128
+ visibility: toolTipCoord ? 'visible' : 'hidden'
129
+ }
130
+ }, /*#__PURE__*/React.createElement(StyledTooltipArrow, {
131
+ className: "arrow"
132
+ }), contentMarkup)));
133
+ };
@@ -0,0 +1,4 @@
1
+ import { Meta } from '@storybook/react';
2
+ declare const _default: Meta<import("@storybook/react").Args>;
3
+ export default _default;
4
+ export declare const Interactive: any;
@@ -0,0 +1,6 @@
1
+ import { Meta } from '@storybook/react';
2
+ declare const _default: Meta<import("@storybook/react").Args>;
3
+ export default _default;
4
+ export declare const AdaptiveBottomCenter: any;
5
+ export declare const AdaptiveBottomLeft: any;
6
+ export declare const AdaptiveBottomRight: any;
@@ -0,0 +1,6 @@
1
+ import { Meta } from '@storybook/react';
2
+ declare const _default: Meta<import("@storybook/react").Args>;
3
+ export default _default;
4
+ export declare const AdaptiveLeftMiddle: any;
5
+ export declare const AdaptiveLeftTop: any;
6
+ export declare const AdaptiveLeftBottom: any;
@@ -0,0 +1,6 @@
1
+ import { Meta } from '@storybook/react';
2
+ declare const _default: Meta<import("@storybook/react").Args>;
3
+ export default _default;
4
+ export declare const AdaptiveRightMiddle: any;
5
+ export declare const AdaptiveRightTop: any;
6
+ export declare const AdaptiveRightBottom: any;
@@ -0,0 +1,6 @@
1
+ import { Meta } from '@storybook/react';
2
+ declare const _default: Meta<import("@storybook/react").Args>;
3
+ export default _default;
4
+ export declare const AdaptiveTopCenter: any;
5
+ export declare const AdaptiveTopLeft: any;
6
+ export declare const AdaptiveTopRight: any;
@@ -0,0 +1,3 @@
1
+ export declare const StyledTooltipContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
2
+ export declare const StyledTooltip: import("styled-components").StyledComponent<"div", any, {}, never>;
3
+ export declare const StyledTooltipArrow: import("styled-components").StyledComponent<"div", any, {}, never>;
@@ -0,0 +1,22 @@
1
+ import styled from 'styled-components';
2
+ import * as Breakpoints from '../utilities/breakpoints';
3
+ import { borderRadius2 } from '../utilities/borderRadius';
4
+ import { Neutral } from '../utilities/colors';
5
+ import { space12, space8 } from '../utilities/spacing';
6
+ import { nonCenterArrowSpace, verticalBuffer } from './positionResolverHelper';
7
+ var verticalMargin = verticalBuffer + "px";
8
+ var arrowSize = '6px';
9
+ var nonCentralArrowMargin = nonCenterArrowSpace + "px";
10
+ var background = Neutral.B18;
11
+ export var StyledTooltipContainer = styled.div.withConfig({
12
+ displayName: "TooltipStyle__StyledTooltipContainer",
13
+ componentId: "sc-37e5z7-0"
14
+ })(["display:inline-block;position:relative;*{display:block;}"]);
15
+ export var StyledTooltip = styled.div.withConfig({
16
+ displayName: "TooltipStyle__StyledTooltip",
17
+ componentId: "sc-37e5z7-1"
18
+ })(["position:absolute;text-align:left;height:fit-content;width:fit-content;max-width:320px;border-radius:", ";gap:10px;left:50%;transform:translateX(-50%);padding:", " ", ";color:", ";background:", ";z-index:100;overflow-wrap:break-word;line-height:1;&[data-position='top-left'],&[data-position='bottom-left']{transform:translateX( calc(100% * -1 + ", " + ", ") );}&[data-position='top-right'],&[data-position='bottom-right']{transform:translateX(calc((", " + ", ") * -1));}&[data-position='right-middle']{transform:translateX(0) translateY(-50%);}&[data-position='left-bottom'],&[data-position='right-bottom']{transform:translateY(calc((", " + ", ") * -1));}&[data-position='left-top'],&[data-position='right-top']{transform:translateY( calc(100% * -1 + (", " + ", ")) );}&[data-position='bottom-center'],&[data-position='bottom-left'],&[data-position='bottom-right']{top:calc((100% + ", "));}&[data-position='left-middle']{transform:translateX(0) translateY(-50%);}&[data-position='top-center'] .arrow,&[data-position='top-left'] .arrow,&[data-position='top-right'] .arrow{top:100%;border-top-color:", ";}&[data-position='top-left'] .arrow,&[data-position='bottom-left'] .arrow{left:calc(100% - ", " - ", ");}&[data-position='top-right'] .arrow,&[data-position='bottom-right'] .arrow{left:calc(", " + ", ");}&[data-position='right-middle'] .arrow,&[data-position='right-top'] .arrow,&[data-position='right-bottom'] .arrow{top:50%;left:calc(", " * -1);border-right-color:", ";}&[data-position='right-middle'] .arrow{transform:translateX(0) translateY(-50%);}&[data-position='left-bottom'] .arrow,&[data-position='right-bottom'] .arrow{top:", ";}&[data-position='bottom-center'] .arrow,&[data-position='bottom-left'] .arrow,&[data-position='bottom-right'] .arrow{bottom:100%;border-bottom-color:", ";}&[data-position='left-middle'] .arrow,&[data-position='left-top'] .arrow,&[data-position='left-bottom'] .arrow{left:auto;right:calc(", " * -2);border-left-color:", ";}&[data-position='left-middle'] .arrow{top:50%;transform:translateX(0) translateY(-50%);}&[data-position='left-top'] .arrow,&[data-position='right-top'] .arrow{top:unset;bottom:", ";}@media (max-width:", "){min-width:69px;}"], borderRadius2, space8, space12, Neutral.B100, background, arrowSize, nonCentralArrowMargin, arrowSize, nonCentralArrowMargin, nonCentralArrowMargin, arrowSize, nonCentralArrowMargin, arrowSize, verticalMargin, background, arrowSize, nonCentralArrowMargin, arrowSize, nonCentralArrowMargin, arrowSize, background, nonCentralArrowMargin, background, arrowSize, background, nonCentralArrowMargin, Breakpoints.large);
19
+ export var StyledTooltipArrow = styled.div.withConfig({
20
+ displayName: "TooltipStyle__StyledTooltipArrow",
21
+ componentId: "sc-37e5z7-2"
22
+ })(["content:' ';left:50%;border:solid transparent;height:0;width:0;position:absolute;pointer-events:none;border-width:", ";margin-left:calc(", " * -1);"], arrowSize, arrowSize);
@@ -0,0 +1 @@
1
+ export * from './Tooltip';
@@ -0,0 +1 @@
1
+ export * from './Tooltip';
@@ -0,0 +1,6 @@
1
+ import { PreferredHorizontalAligmentFuncsType, PreferredVerticalAligmentFuncsType } from './positionResolverHelper';
2
+ import { TooltipPosition } from './Tooltip';
3
+ export declare const topPositionResolver: (tooltipRect: DOMRect, elRect: DOMRect, preferredAligmentFuncs: PreferredHorizontalAligmentFuncsType[]) => TooltipPosition;
4
+ export declare const bottomPositionResolver: (tooltipRect: DOMRect, elRect: DOMRect, preferredAligmentFuncs: PreferredHorizontalAligmentFuncsType[]) => TooltipPosition;
5
+ export declare const leftPositionResolver: (tooltipRect: DOMRect, elRect: DOMRect, preferredAligmentFuncs: PreferredVerticalAligmentFuncsType[]) => TooltipPosition;
6
+ export declare const rightPositionResolver: (tooltipRect: DOMRect, elRect: DOMRect, preferredAligmentFuncs: PreferredVerticalAligmentFuncsType[]) => TooltipPosition;
@@ -0,0 +1,181 @@
1
+ import { canAlignLeft, canAlignRight, canAlignCenter, canStayOnTop, canFitOnTheLeft, horizontalBuffer, canFitOnTheRight, canFitBelow, verticalBuffer, tryCalculateAligment, canAlignMiddle, canAlignTop, canAlignBottom, canStayOnBottom, canFitOnTheTop, canStayOnLeft, canStayOnRight } from './positionResolverHelper';
2
+ export var topPositionResolver = function topPositionResolver(tooltipRect, elRect, preferredAligmentFuncs) {
3
+ var horizontalPreferredAligmentFuncs = preferredAligmentFuncs;
4
+ var verticalPreferredAligmentFuncs = [canAlignMiddle, canAlignTop, canAlignBottom];
5
+ if (canStayOnTop(tooltipRect)) {
6
+ var alignResult = tryCalculateAligment({
7
+ preferredAlignmentFuncs: horizontalPreferredAligmentFuncs,
8
+ tooltipRect: tooltipRect,
9
+ elRect: elRect
10
+ });
11
+ if (alignResult) {
12
+ return "top-" + alignResult;
13
+ }
14
+ }
15
+ if (canFitOnTheLeft(tooltipRect, elRect, horizontalBuffer)) {
16
+ var _alignResult = tryCalculateAligment({
17
+ preferredAlignmentFuncs: verticalPreferredAligmentFuncs,
18
+ tooltipRect: tooltipRect,
19
+ elRect: elRect
20
+ });
21
+ if (_alignResult) {
22
+ return "left-" + _alignResult;
23
+ }
24
+ }
25
+ if (canFitOnTheRight(tooltipRect, elRect, horizontalBuffer)) {
26
+ var _alignResult2 = tryCalculateAligment({
27
+ preferredAlignmentFuncs: verticalPreferredAligmentFuncs,
28
+ tooltipRect: tooltipRect,
29
+ elRect: elRect
30
+ });
31
+ if (_alignResult2) {
32
+ return "right-" + _alignResult2;
33
+ }
34
+ }
35
+ if (canFitBelow(tooltipRect, elRect, verticalBuffer)) {
36
+ var _alignResult3 = tryCalculateAligment({
37
+ preferredAlignmentFuncs: horizontalPreferredAligmentFuncs,
38
+ tooltipRect: tooltipRect,
39
+ elRect: elRect
40
+ });
41
+ if (_alignResult3) {
42
+ return "bottom-" + _alignResult3;
43
+ }
44
+ }
45
+ return 'top-center';
46
+ };
47
+ export var bottomPositionResolver = function bottomPositionResolver(tooltipRect, elRect, preferredAligmentFuncs) {
48
+ var horizontalPreferredAligmentFuncs = preferredAligmentFuncs;
49
+ var verticalPreferredAligmentFuncs = [canAlignMiddle, canAlignTop, canAlignBottom];
50
+ if (canStayOnBottom(tooltipRect)) {
51
+ var alignResult = tryCalculateAligment({
52
+ preferredAlignmentFuncs: horizontalPreferredAligmentFuncs,
53
+ tooltipRect: tooltipRect,
54
+ elRect: elRect
55
+ });
56
+ if (alignResult) {
57
+ return "bottom-" + alignResult;
58
+ }
59
+ }
60
+ if (canFitOnTheLeft(tooltipRect, elRect, horizontalBuffer)) {
61
+ var _alignResult4 = tryCalculateAligment({
62
+ preferredAlignmentFuncs: verticalPreferredAligmentFuncs,
63
+ tooltipRect: tooltipRect,
64
+ elRect: elRect
65
+ });
66
+ if (_alignResult4) {
67
+ return "left-" + _alignResult4;
68
+ }
69
+ }
70
+ if (canFitOnTheRight(tooltipRect, elRect, horizontalBuffer)) {
71
+ var _alignResult5 = tryCalculateAligment({
72
+ preferredAlignmentFuncs: verticalPreferredAligmentFuncs,
73
+ tooltipRect: tooltipRect,
74
+ elRect: elRect
75
+ });
76
+ if (_alignResult5) {
77
+ return "right-" + _alignResult5;
78
+ }
79
+ }
80
+ if (canFitOnTheTop(tooltipRect, elRect, verticalBuffer)) {
81
+ var _alignResult6 = tryCalculateAligment({
82
+ preferredAlignmentFuncs: horizontalPreferredAligmentFuncs,
83
+ tooltipRect: tooltipRect,
84
+ elRect: elRect
85
+ });
86
+ if (_alignResult6) {
87
+ return "top-" + _alignResult6;
88
+ }
89
+ }
90
+ return 'bottom-center';
91
+ };
92
+ export var leftPositionResolver = function leftPositionResolver(tooltipRect, elRect, preferredAligmentFuncs) {
93
+ var horizontalPreferredAligmentFuncs = [canAlignCenter, canAlignLeft, canAlignRight];
94
+ var verticalPreferredAligmentFuncs = preferredAligmentFuncs;
95
+ if (canStayOnLeft(tooltipRect)) {
96
+ var alignResult = tryCalculateAligment({
97
+ preferredAlignmentFuncs: verticalPreferredAligmentFuncs,
98
+ tooltipRect: tooltipRect,
99
+ elRect: elRect
100
+ });
101
+ if (alignResult) {
102
+ return "left-" + alignResult;
103
+ }
104
+ }
105
+ if (canFitOnTheTop(tooltipRect, elRect, horizontalBuffer)) {
106
+ var _alignResult7 = tryCalculateAligment({
107
+ preferredAlignmentFuncs: horizontalPreferredAligmentFuncs,
108
+ tooltipRect: tooltipRect,
109
+ elRect: elRect
110
+ });
111
+ if (_alignResult7) {
112
+ return "top-" + _alignResult7;
113
+ }
114
+ }
115
+ if (canFitOnTheRight(tooltipRect, elRect, horizontalBuffer)) {
116
+ var _alignResult8 = tryCalculateAligment({
117
+ preferredAlignmentFuncs: verticalPreferredAligmentFuncs,
118
+ tooltipRect: tooltipRect,
119
+ elRect: elRect
120
+ });
121
+ if (_alignResult8) {
122
+ return "right-" + _alignResult8;
123
+ }
124
+ }
125
+ if (canFitBelow(tooltipRect, elRect, verticalBuffer)) {
126
+ var _alignResult9 = tryCalculateAligment({
127
+ preferredAlignmentFuncs: horizontalPreferredAligmentFuncs,
128
+ tooltipRect: tooltipRect,
129
+ elRect: elRect
130
+ });
131
+ if (_alignResult9) {
132
+ return "bottom-" + _alignResult9;
133
+ }
134
+ }
135
+ return 'left-middle';
136
+ };
137
+ export var rightPositionResolver = function rightPositionResolver(tooltipRect, elRect, preferredAligmentFuncs) {
138
+ var horizontalPreferredAligmentFuncs = [canAlignCenter, canAlignLeft, canAlignRight];
139
+ var verticalPreferredAligmentFuncs = preferredAligmentFuncs;
140
+ if (canStayOnRight(tooltipRect)) {
141
+ var alignResult = tryCalculateAligment({
142
+ preferredAlignmentFuncs: verticalPreferredAligmentFuncs,
143
+ tooltipRect: tooltipRect,
144
+ elRect: elRect
145
+ });
146
+ if (alignResult) {
147
+ return "right-" + alignResult;
148
+ }
149
+ }
150
+ if (canFitOnTheTop(tooltipRect, elRect, horizontalBuffer)) {
151
+ var _alignResult10 = tryCalculateAligment({
152
+ preferredAlignmentFuncs: horizontalPreferredAligmentFuncs,
153
+ tooltipRect: tooltipRect,
154
+ elRect: elRect
155
+ });
156
+ if (_alignResult10) {
157
+ return "top-" + _alignResult10;
158
+ }
159
+ }
160
+ if (canFitOnTheLeft(tooltipRect, elRect, horizontalBuffer)) {
161
+ var _alignResult11 = tryCalculateAligment({
162
+ preferredAlignmentFuncs: verticalPreferredAligmentFuncs,
163
+ tooltipRect: tooltipRect,
164
+ elRect: elRect
165
+ });
166
+ if (_alignResult11) {
167
+ return "left-" + _alignResult11;
168
+ }
169
+ }
170
+ if (canFitBelow(tooltipRect, elRect, verticalBuffer)) {
171
+ var _alignResult12 = tryCalculateAligment({
172
+ preferredAlignmentFuncs: horizontalPreferredAligmentFuncs,
173
+ tooltipRect: tooltipRect,
174
+ elRect: elRect
175
+ });
176
+ if (_alignResult12) {
177
+ return "bottom-" + _alignResult12;
178
+ }
179
+ }
180
+ return 'right-middle';
181
+ };
@@ -0,0 +1,37 @@
1
+ export declare const verticalBuffer = 8;
2
+ export declare const horizontalBuffer = 8;
3
+ export declare const nonCenterArrowSpace = 12;
4
+ export declare type HorizontalAlignmentType = 'center' | 'left' | 'right';
5
+ export declare type VerticalAlignmentType = 'middle' | 'top' | 'bottom';
6
+ export declare type HorizontalAlignmentCalculatorResult = {
7
+ type: HorizontalAlignmentType;
8
+ result: boolean;
9
+ };
10
+ export declare type VerticalAlignmentCalculatorResult = {
11
+ type: VerticalAlignmentType;
12
+ result: boolean;
13
+ };
14
+ export declare type PreferredHorizontalAligmentFuncsType = (tooltipRect: DOMRect, elRect: DOMRect) => HorizontalAlignmentCalculatorResult;
15
+ export declare type PreferredVerticalAligmentFuncsType = (tooltipRect: DOMRect, elRect: DOMRect) => VerticalAlignmentCalculatorResult;
16
+ export declare type TryCalculateAlignmentArgs<T extends HorizontalAlignmentType | VerticalAlignmentType> = {
17
+ preferredAlignmentFuncs: T extends HorizontalAlignmentType ? PreferredHorizontalAligmentFuncsType[] : PreferredVerticalAligmentFuncsType[];
18
+ tooltipRect: DOMRect;
19
+ elRect: DOMRect;
20
+ };
21
+ export declare const getElementCenterPosition: (elRect: DOMRect) => number;
22
+ export declare const getElementMiddlePosition: (elRect: DOMRect) => number;
23
+ export declare const canFitOnTheTop: (tooltipRect: DOMRect, elRect: DOMRect, verticalMargin: number) => boolean;
24
+ export declare const canFitBelow: (tooltipRect: DOMRect, elRect: DOMRect, verticalMargin: number) => boolean;
25
+ export declare const canFitOnTheLeft: (tooltipRect: DOMRect, elRect: DOMRect, horizontalMargin: number) => boolean;
26
+ export declare const canFitOnTheRight: (tooltipRect: DOMRect, elRect: DOMRect, horizontalMargin: number) => boolean;
27
+ export declare const canAlignLeft: (tooltipRect: DOMRect, elRect: DOMRect) => HorizontalAlignmentCalculatorResult;
28
+ export declare const canAlignRight: (tooltipRect: DOMRect, elRect: DOMRect) => HorizontalAlignmentCalculatorResult;
29
+ export declare const canAlignCenter: (tooltipRect: DOMRect, elRect: DOMRect) => HorizontalAlignmentCalculatorResult;
30
+ export declare const canAlignTop: (tooltipRect: DOMRect, elRect: DOMRect) => VerticalAlignmentCalculatorResult;
31
+ export declare const canAlignBottom: (tooltipRect: DOMRect, elRect: DOMRect) => VerticalAlignmentCalculatorResult;
32
+ export declare const canAlignMiddle: (tooltipRect: DOMRect, elRect: DOMRect) => VerticalAlignmentCalculatorResult;
33
+ export declare const canStayOnTop: (tooltipRect: DOMRect) => boolean;
34
+ export declare const canStayOnBottom: (tooltipRect: DOMRect) => boolean;
35
+ export declare const canStayOnLeft: (tooltipRect: DOMRect) => boolean;
36
+ export declare const canStayOnRight: (tooltipRect: DOMRect) => boolean;
37
+ export declare const tryCalculateAligment: <T extends HorizontalAlignmentType | VerticalAlignmentType>(args: TryCalculateAlignmentArgs<T>) => HorizontalAlignmentType | VerticalAlignmentType;