@startlibs/components 1.0.4 → 1.1.1

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 (115) hide show
  1. package/lib/BasicBulletList.mjs +9 -0
  2. package/lib/BasicBulletList.mjs.map +1 -0
  3. package/lib/Button.mjs +95 -0
  4. package/lib/Button.mjs.map +1 -0
  5. package/lib/ContextMenu.mjs +452 -0
  6. package/lib/ContextMenu.mjs.map +1 -0
  7. package/lib/Dialog.mjs +232 -0
  8. package/lib/Dialog.mjs.map +1 -0
  9. package/lib/Draggable.mjs +880 -0
  10. package/lib/Draggable.mjs.map +1 -0
  11. package/lib/ErrorBoundary.mjs +108 -0
  12. package/lib/ErrorBoundary.mjs.map +1 -0
  13. package/lib/FillLastLineResizer.mjs +238 -0
  14. package/lib/FillLastLineResizer.mjs.map +1 -0
  15. package/lib/Flip.mjs +604 -0
  16. package/lib/Flip.mjs.map +1 -0
  17. package/lib/FlipList.mjs +186 -0
  18. package/lib/FlipList.mjs.map +1 -0
  19. package/lib/FormatDate.mjs +25 -0
  20. package/lib/FormatDate.mjs.map +1 -0
  21. package/lib/Icon.mjs +50 -0
  22. package/lib/Icon.mjs.map +1 -0
  23. package/lib/Image.mjs +41 -0
  24. package/lib/Image.mjs.map +1 -0
  25. package/lib/Link.mjs +116 -0
  26. package/lib/Link.mjs.map +1 -0
  27. package/lib/Loading.mjs +10 -0
  28. package/lib/Loading.mjs.map +1 -0
  29. package/lib/LoadingDiv.mjs +83 -0
  30. package/lib/LoadingDiv.mjs.map +1 -0
  31. package/lib/Notifications.mjs +63 -0
  32. package/lib/Notifications.mjs.map +1 -0
  33. package/lib/PageLoader.mjs +42 -0
  34. package/lib/PageLoader.mjs.map +1 -0
  35. package/lib/PersistentNotifications.mjs +130 -0
  36. package/lib/PersistentNotifications.mjs.map +1 -0
  37. package/lib/Popup.mjs +49 -0
  38. package/lib/Popup.mjs.map +1 -0
  39. package/lib/SplitColumnsContainer.mjs +43 -0
  40. package/lib/SplitColumnsContainer.mjs.map +1 -0
  41. package/lib/SwitchDiv.mjs +61 -0
  42. package/lib/SwitchDiv.mjs.map +1 -0
  43. package/lib/TextButton.mjs +41 -0
  44. package/lib/TextButton.mjs.map +1 -0
  45. package/lib/ToastNotifications.mjs +215 -0
  46. package/lib/ToastNotifications.mjs.map +1 -0
  47. package/lib/Tooltip.mjs +160 -0
  48. package/lib/Tooltip.mjs.map +1 -0
  49. package/lib/TransitionDiv.mjs +56 -0
  50. package/lib/TransitionDiv.mjs.map +1 -0
  51. package/lib/WarningDialog.mjs +84 -0
  52. package/lib/WarningDialog.mjs.map +1 -0
  53. package/lib/alt/buttons/OnClickLoadingButton.mjs +36 -0
  54. package/lib/alt/buttons/OnClickLoadingButton.mjs.map +1 -0
  55. package/lib/alt/dialogs/DialogWithImageHeader.mjs +14 -0
  56. package/lib/alt/dialogs/DialogWithImageHeader.mjs.map +1 -0
  57. package/lib/alt/dialogs/DialogWithSidebar.mjs +106 -0
  58. package/lib/alt/dialogs/DialogWithSidebar.mjs.map +1 -0
  59. package/lib/alt/dialogs/MobileBubbleDialog.mjs +49 -0
  60. package/lib/alt/dialogs/MobileBubbleDialog.mjs.map +1 -0
  61. package/lib/containers/DialogContainer.mjs +413 -0
  62. package/lib/containers/DialogContainer.mjs.map +1 -0
  63. package/lib/containers/Reposition.mjs +35 -0
  64. package/lib/containers/Reposition.mjs.map +1 -0
  65. package/lib/containers/usePositioning.mjs +294 -0
  66. package/lib/containers/usePositioning.mjs.map +1 -0
  67. package/lib/index.cjs +5000 -0
  68. package/lib/index.cjs.map +1 -0
  69. package/lib/index.mjs +37 -0
  70. package/lib/index.mjs.map +1 -0
  71. package/lib/useDialogWithToggle.mjs +18 -0
  72. package/lib/useDialogWithToggle.mjs.map +1 -0
  73. package/lib/willUseIsSticky.mjs +123 -0
  74. package/lib/willUseIsSticky.mjs.map +1 -0
  75. package/package.json +47 -30
  76. package/src/BasicBulletList.jsx +21 -0
  77. package/src/Button.jsx +288 -0
  78. package/src/ContextMenu.jsx +621 -0
  79. package/src/Dialog.jsx +413 -0
  80. package/src/Draggable.jsx +801 -0
  81. package/src/ErrorBoundary.jsx +75 -0
  82. package/src/FillLastLineResizer.jsx +226 -0
  83. package/src/Flip.jsx +560 -0
  84. package/src/FlipList.jsx +136 -0
  85. package/src/FormatDate.jsx +9 -0
  86. package/src/Icon.jsx +49 -0
  87. package/src/Image.jsx +23 -0
  88. package/src/Link.jsx +68 -0
  89. package/src/Loading.jsx +29 -0
  90. package/src/LoadingDiv.jsx +75 -0
  91. package/src/Notifications.jsx +89 -0
  92. package/src/PageLoader.jsx +48 -0
  93. package/src/PersistentNotifications.jsx +182 -0
  94. package/src/Popup.jsx +49 -0
  95. package/src/SplitColumnsContainer.jsx +63 -0
  96. package/src/SwitchDiv.jsx +30 -0
  97. package/src/TextButton.jsx +34 -0
  98. package/src/ToastNotifications.jsx +298 -0
  99. package/src/Tooltip.jsx +158 -0
  100. package/src/TransitionDiv.jsx +34 -0
  101. package/src/WarningDialog.jsx +70 -0
  102. package/src/alt/buttons/OnClickLoadingButton.jsx +16 -0
  103. package/src/alt/dialogs/DialogWithImageHeader.jsx +42 -0
  104. package/src/alt/dialogs/DialogWithSidebar.jsx +135 -0
  105. package/src/alt/dialogs/MobileBubbleDialog.jsx +56 -0
  106. package/src/containers/DialogContainer.jsx +423 -0
  107. package/src/containers/Reposition.jsx +24 -0
  108. package/src/containers/usePositioning.jsx +305 -0
  109. package/src/index.js +35 -0
  110. package/src/useDialogWithToggle.jsx +12 -0
  111. package/src/willUseIsSticky.jsx +113 -0
  112. package/.babelrc +0 -27
  113. package/lib/index.js +0 -5429
  114. package/rollup.config.js +0 -52
  115. package/yarn-error.log +0 -3724
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SwitchDiv.mjs","sources":["../src/SwitchDiv.jsx"],"sourcesContent":["import React, {useRef} from 'react'\nimport styled from 'styled-components'\nimport {oneWayAnimation} from '@startlibs/utils'\nimport {willUseFlipSwitch} from './Flip'\nimport {useLazyConstant} from '@startlibs/core'\nimport {callIfFunction, twoWayAnimation} from '@startlibs/utils'\n\n\nconst BlockContainer = styled.div`\nposition:relative;\n`\n\nconst [fadeIn, relativeFadeout] = twoWayAnimation('opacity: 0;','opacity: 0;', 'opacity: 1;')\nconst absoluteOnLeave = oneWayAnimation('position: absolute;', 'position: absolute;')\nconst fadeOut = [absoluteOnLeave,relativeFadeout]\n\nexport const SwitchDiv = styled(({children, className,enterAnimation = fadeIn, effect, leaveAnimation = fadeOut, skipChromeFix, on,...rest}) => {\n const switchAnimation = useLazyConstant(willUseFlipSwitch)\n\n return <SwitchContainer enterAnimation={enterAnimation} effect={effect} className={className} leaveAnimation={leaveAnimation} key={on + \"\"} switchAnimation={switchAnimation} children={children} />\n})``\n\nconst SwitchContainer = ({children,switchAnimation, className, effect ,enterAnimation,leaveAnimation}) => {\n const contentRef = useRef()\n switchAnimation(contentRef,enterAnimation,leaveAnimation, {effect})\n\n return <BlockContainer ref={contentRef} className={className}>\n {callIfFunction(children)}\n </BlockContainer>\n}\n"],"names":["BlockContainer","styled","div","withConfig","displayName","componentId","fadeIn","relativeFadeout","twoWayAnimation","absoluteOnLeave","oneWayAnimation","fadeOut","SwitchDiv","_ref","children","className","enterAnimation","effect","leaveAnimation","skipChromeFix","on","rest","_objectWithoutProperties","_excluded","switchAnimation","useLazyConstant","willUseFlipSwitch","React","createElement","SwitchContainer","key","_ref2","contentRef","useRef","ref","callIfFunction"],"mappings":";;;;;;;;AAQA,MAAMA,cAAc,gBAAGC,MAAM,CAACC,GAAG,CAAAC,UAAA,CAAA;EAAAC,WAAA,EAAA,2BAAA;EAAAC,WAAA,EAAA,aAAA;AAAA,CAEhC,CAAA,CAAA,CAAA,oBAAA,CAAA,CAAA,CAAA;AAED,MAAM,CAACC,MAAM,EAAEC,eAAe,CAAC,GAAGC,eAAe,CAAC,aAAa,EAAC,aAAa,EAAE,aAAa,CAAC,CAAA;AAC7F,MAAMC,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AAAA;AAAM,GAAC,CAAC,CAAA;AAEnE,EAAA,oBAAOU,KAAA,CAAAC,aAAA,CAAC5B,cAAc,EAAA;AAACkC,IAAAA,GAAG,EAAEF,UAAW;AAACjB,IAAAA,SAAS,EAAEA,SAAAA;AAAU,GAAA,EAC1DoB,cAAc,CAACrB,QAAQ,CACV,CAAC,CAAA;AACnB,CAAC;;;;"}
@@ -0,0 +1,41 @@
1
+ import _extends from '@babel/runtime/helpers/extends';
2
+ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
3
+ import React from 'react';
4
+ import styled from 'styled-components';
5
+ import { darken } from 'polished';
6
+ import { getColor } from '@startlibs/utils';
7
+ import { Link } from './Link.mjs';
8
+ import { Loading } from './Loading.mjs';
9
+
10
+ const _excluded = ["className", "isLoading", "alert", "fontSize", "children", "innerAs"];
11
+ const TextButton = /*#__PURE__*/styled(_ref => {
12
+ let {
13
+ className,
14
+ isLoading,
15
+ alert,
16
+ fontSize,
17
+ children,
18
+ innerAs: Wrapper = 'div'
19
+ } = _ref,
20
+ props = _objectWithoutProperties(_ref, _excluded);
21
+ return /*#__PURE__*/React.createElement(Wrapper, _extends({
22
+ className: className
23
+ }, props), children, " ", isLoading && /*#__PURE__*/React.createElement(Loading, {
24
+ size: 14,
25
+ borderWidth: 3
26
+ }));
27
+ }).withConfig({
28
+ displayName: "TextButton",
29
+ componentId: "sc-1eydmhc-0"
30
+ })(["display:inline-block;font-weight:600;font-size:", "px;color:", ";cursor:pointer;text-decoration:none;:hover,:active{color:", ";}", "{display:inline-block;margin-left:0.25rem;vertical-align:-3px;}", " & ~ &{margin-left:1rem;}"], props => props.fontSize ? fontSize : "14", props => props.alert ? getColor('alert') : getColor('main'), props => props.alert ? darken(0.1, getColor("alert")(props)) : darken(0.1, getColor("main")(props)), Loading, props => props.nowrap && "\n white-space: nowrap;\n ");
31
+ TextButton.a = props => /*#__PURE__*/React.createElement(TextButton, _extends({}, props, {
32
+ className: props.className,
33
+ innerAs: "a"
34
+ }));
35
+ TextButton.Link = props => /*#__PURE__*/React.createElement(TextButton, _extends({}, props, {
36
+ className: props.className,
37
+ innerAs: Link
38
+ }));
39
+
40
+ export { TextButton };
41
+ //# sourceMappingURL=TextButton.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TextButton.mjs","sources":["../src/TextButton.jsx"],"sourcesContent":["import React from 'react'\nimport styled from 'styled-components';\nimport {darken} from 'polished'\nimport { getColor } from '@startlibs/utils';\nimport {Link} from './Link'\nimport {Loading} from './Loading'\n\nexport const TextButton = styled(({className,isLoading,alert, fontSize, children, innerAs: Wrapper = 'div', ...props}) => <Wrapper className={className} {...props}>\n {children} {isLoading && <Loading size={14} borderWidth={3} />}\n</Wrapper>)`\n display: inline-block;\n font-weight: 600;\n font-size: ${props => props.fontSize ? fontSize : \"14\"}px;\n color: ${props => props.alert ? getColor('alert') : getColor('main')};\n cursor: pointer;\n text-decoration: none;\n :hover, :active {\n color: ${props => props.alert ? darken(0.1, getColor(\"alert\")(props)) : darken(0.1, getColor(\"main\")(props))};\n }\n ${Loading} {\n display: inline-block;\n margin-left: 0.25rem;\n vertical-align: -3px;\n }\n ${props => props.nowrap && `\n white-space: nowrap;\n `}\n & ~ & {\n margin-left: 1rem;\n }\n`\n\nTextButton.a = (props) => <TextButton {...props} className={props.className} innerAs=\"a\"/>\nTextButton.Link = (props) => <TextButton {...props} className={props.className} innerAs={Link}/>"],"names":["TextButton","styled","_ref","className","isLoading","alert","fontSize","children","innerAs","Wrapper","props","_objectWithoutProperties","_excluded","React","createElement","_extends","Loading","size","borderWidth","withConfig","displayName","componentId","getColor","darken","nowrap","a","Link"],"mappings":";;;;;;;;;;AAOaA,MAAAA,UAAU,gBAAGC,MAAM,CAACC,IAAA,IAAA;EAAA,IAAC;MAACC,SAAS;MAACC,SAAS;MAACC,KAAK;MAAEC,QAAQ;MAAEC,QAAQ;MAAEC,OAAO,EAAEC,OAAO,GAAG,KAAA;AAAe,KAAC,GAAAP,IAAA;AA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C,CAAA;AAC1FR,UAAU,CAAC0B,IAAI,GAAIhB,KAAK,iBAAKG,KAAA,CAAAC,aAAA,CAACd,UAAU,EAAAe,QAAA,KAAKL,KAAK,EAAA;EAAEP,SAAS,EAAEO,KAAK,CAACP,SAAU;AAACK,EAAAA,OAAO,EAAEkB,IAAAA;AAAK,CAAA,CAAC,CAAC;;;;"}
@@ -0,0 +1,215 @@
1
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
+ import _taggedTemplateLiteral from '@babel/runtime/helpers/taggedTemplateLiteral';
3
+ import styled, { css } from 'styled-components';
4
+ import _map from 'lodash/fp/map';
5
+ import _concat from 'lodash/fp/concat';
6
+ import _differenceBy from 'lodash/fp/differenceBy';
7
+ import _isObject from 'lodash/fp/isObject';
8
+ import React, { useMemo, useEffect, useRef } from 'react';
9
+ import { media, getColor, ifUndefined, getUID, oneWayAnimation, callIfFunction, constrainEvent } from '@startlibs/utils';
10
+ import { rgba } from 'polished';
11
+ import { willUseSharedState, useToggle, Fill } from '@startlibs/core';
12
+ import { FlipList } from './FlipList.mjs';
13
+ import { Icon } from './Icon.mjs';
14
+ import { Loading } from './Loading.mjs';
15
+ import { SwitchDiv } from './SwitchDiv.mjs';
16
+
17
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8;
18
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
19
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
20
+ const NotificationContainer = /*#__PURE__*/styled.div.withConfig({
21
+ displayName: "ToastNotifications__NotificationContainer",
22
+ componentId: "sc-inycsj-0"
23
+ })(["position:fixed;bottom:0;max-height:100%;z-index:999999;display:flex;flex-direction:column-reverse;align-items:flex-end;overflow-y:auto;right:1.5rem;", " ", " ::-webkit-scrollbar{width:21px;height:21px;}::-webkit-scrollbar-thumb{pointer-events:all;background:rgba(0,0,0,0.4);border-radius:100px;background-clip:padding-box;border:6px solid transparent;min-height:30px;min-width:30px;&:hover{background:rgba(0,0,0,0.5);background-clip:padding-box;border:6px solid transparent;}}::-webkit-scrollbar-corner{background:transparent;}", " ", ""], media.desktop(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding-bottom: 1.5rem;\n "]))), media.mobile(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n padding-bottom: 0.75rem;\n "]))), media.desktop(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n &.JS-dialog-open {\n right: 2.75rem;\n }\n "]))), media.mobile(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n left: 0.75rem;\n right: 0.75rem;\n "]))));
24
+ const ToastBox = /*#__PURE__*/styled.div.withConfig({
25
+ displayName: "ToastNotifications__ToastBox",
26
+ componentId: "sc-inycsj-1"
27
+ })(["color:white;font-size:14px;font-weight:500;border-radius:12px;flex-shrink:0;margin-top:0.5rem;overflow:hidden;transition:0.3s background ease,0.4s opacity 1.5s;", " ", " ", ""], media.desktop(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n background: ", ";\n max-width: 300px;\n "])), props => rgba(getColor(props.type)(props), ifUndefined(props.opacity, 0.7))), media.mobile(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n background: ", ";\n "])), props => rgba(getColor(props.type)(props), ifUndefined(props.opacity, 0.8))), props => css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["background: ", ";"])), getColor(props.type)));
28
+ const NotificationTitleContainer = /*#__PURE__*/styled.div.withConfig({
29
+ displayName: "ToastNotifications__NotificationTitleContainer",
30
+ componentId: "sc-inycsj-2"
31
+ })(["background:rgba(0,0,0,0.1);padding:0.5rem 2.25rem 0.5rem 0.75rem;border-radius:12px 12px 0 0;position:relative;min-height:30px;font-size:13px;display:flex;align-items:center;font-weight:400;", ""], props => props.onClick && "cursor: pointer;");
32
+ const NotificationTitle = /*#__PURE__*/styled.div.withConfig({
33
+ displayName: "ToastNotifications__NotificationTitle",
34
+ componentId: "sc-inycsj-3"
35
+ })(["text-overflow:ellipsis;white-space:nowrap;overflow:hidden;"]);
36
+ const NotificationContent = /*#__PURE__*/styled.div.withConfig({
37
+ displayName: "ToastNotifications__NotificationContent",
38
+ componentId: "sc-inycsj-4"
39
+ })(["display:flex;align-items:center;text-align:left;padding:1rem 1.5rem;", ""], media.mobile(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n justify-content: center;\n "]))));
40
+ const NotificationIconWrapper = /*#__PURE__*/styled.div.withConfig({
41
+ displayName: "ToastNotifications__NotificationIconWrapper",
42
+ componentId: "sc-inycsj-5"
43
+ })(["margin-right:1rem;position:relative;width:36px;text-align:center;flex-shrink:0;", "{font-size:", "px;}"], Icon, props => props.isLoading ? 22 : props.iconFontSize || 40);
44
+ const CloseIcon = /*#__PURE__*/styled(Icon).attrs({
45
+ icon: 'x'
46
+ }).withConfig({
47
+ displayName: "ToastNotifications__CloseIcon",
48
+ componentId: "sc-inycsj-6"
49
+ })(["font-size:20px;cursor:pointer;width:2rem;height:2rem;line-height:2rem;text-align:center;position:absolute;top:50%;right:0.25rem;transform:translateY(-50%);border-radius:100px;opacity:0.8;:hover,:active{background:rgba(0,0,0,0.1);opacity:1;}"]);
50
+ const NotificationDetails = /*#__PURE__*/styled.div.withConfig({
51
+ displayName: "ToastNotifications__NotificationDetails",
52
+ componentId: "sc-inycsj-7"
53
+ })(["background:rgba(0,0,0,0.1);border-radius:8px;padding:1rem;margin:0 1rem 1rem;font-weight:400;font-size:13px;"]);
54
+ const [useToastNotifications, _useToastNotificationsRef, setToastNotifications] = willUseSharedState([]);
55
+ const formatNotification = (notification, extra) => _isObject(notification) ? _objectSpread(_objectSpread(_objectSpread({}, notification), extra), {}, {
56
+ _key: getUID()
57
+ }) : _objectSpread(_objectSpread({
58
+ type: "success",
59
+ content: notification
60
+ }, extra), {}, {
61
+ _key: getUID()
62
+ });
63
+ const createToastNotification = (notification, timeout, closeCallback) => {
64
+ const uid = getUID();
65
+ let currentTimer = -1;
66
+ let hasClosed = false;
67
+ const close = () => {
68
+ clearTimeout(currentTimer);
69
+ if (hasClosed) return;
70
+ setToastNotifications(_differenceBy('uid', _differenceBy.placeholder, [{
71
+ uid
72
+ }]));
73
+ hasClosed = true;
74
+ callIfFunction(closeCallback);
75
+ };
76
+ const notificationObj = formatNotification(notification, {
77
+ uid,
78
+ close
79
+ });
80
+ setToastNotifications(_concat(notificationObj));
81
+ if (timeout > 0) {
82
+ currentTimer = setTimeout(close, timeout);
83
+ }
84
+ return {
85
+ close,
86
+ openWith: (obj, timeout) => {
87
+ clearTimeout(currentTimer);
88
+ if (timeout > 0) {
89
+ currentTimer = setTimeout(close, timeout);
90
+ }
91
+ const notificationObj = formatNotification(obj, {
92
+ uid,
93
+ close
94
+ });
95
+ if (hasClosed) {
96
+ hasClosed = false;
97
+ setToastNotifications(_concat(notificationObj));
98
+ } else {
99
+ setToastNotifications(_map(n => n.uid === uid ? _objectSpread(_objectSpread({}, notificationObj), {}, {
100
+ _key: n._key
101
+ }) : n));
102
+ }
103
+ }
104
+ };
105
+ };
106
+ const useToastNotificationToggle = (notification, timeout) => {
107
+ const toggle = useToggle();
108
+ const extraProps = useMemo(() => notification.content || notification.element ? {} : notification, []);
109
+ const make = (notification, timeout) => notification && createToastNotification(formatNotification(notification, extraProps), timeout, () => toggle.close());
110
+ useEffect(() => {
111
+ if (notification.content || notification.element) {
112
+ toggle.openWith(make(notification));
113
+ }
114
+ }, []);
115
+ return useMemo(() => ({
116
+ close: () => {
117
+ var _toggle$get;
118
+ return (_toggle$get = toggle.get()) === null || _toggle$get === void 0 ? void 0 : _toggle$get.close();
119
+ },
120
+ openWith: (notification, timeout) => toggle.get() ? toggle.get().openWith(formatNotification(notification, extraProps), timeout) : toggle.openWith(make(notification, timeout)),
121
+ open: () => toggle.get() ? toggle.get().openWith(formatNotification(notification, extraProps), timeout) : toggle.openWith(make(notification, timeout))
122
+ }), [toggle.isOpen]);
123
+ };
124
+ const willShowToastNotification = str => () => showToastNotification(str);
125
+ const EXIT_ANIMATION_MS = 300;
126
+ const TOAST_EASING = 'cubic-bezier(0.22, 0.61, 0.36, 1)';
127
+ const TOAST_TIMING = "".concat(EXIT_ANIMATION_MS, "ms ").concat(TOAST_EASING);
128
+ const animation = oneWayAnimation('transform: translateY(0); opacity: 1;', 'transform: translateY(0.25rem); opacity: 1;', 'transform: translateY(1rem); opacity: 0;');
129
+ const removeAnimationReinsertPosition = e => e.style.position = '';
130
+ const ToastNotifications = () => {
131
+ const [notifications, setNotifications] = useToastNotifications();
132
+ const containerRef = useRef(null);
133
+ const {
134
+ lockWidth,
135
+ unlockWidth
136
+ } = useNotificationContainerWidthLock(containerRef);
137
+ return /*#__PURE__*/React.createElement(Fill, {
138
+ name: "Notifications"
139
+ }, /*#__PURE__*/React.createElement(NotificationContainer, {
140
+ ref: containerRef,
141
+ className: "JS-on-open-dialog"
142
+ }, /*#__PURE__*/React.createElement(FlipList, {
143
+ animation: animation,
144
+ timing: TOAST_TIMING,
145
+ onReinsert: removeAnimationReinsertPosition,
146
+ skipParentMorph: true,
147
+ anchoredDownList: true
148
+ }, notifications.map(notification => {
149
+ const closeWithLock = () => {
150
+ lockWidth();
151
+ notification.close();
152
+ setTimeout(unlockWidth, EXIT_ANIMATION_MS);
153
+ };
154
+ return callIfFunction(notification.element, closeWithLock) || /*#__PURE__*/React.createElement(ToastBox, {
155
+ key: "toast-".concat(notification.uid),
156
+ type: notification.type,
157
+ onClick: notification.onClick,
158
+ opacity: notification.opacity
159
+ }, notification.title ? /*#__PURE__*/React.createElement(NotificationTitleContainer, {
160
+ onClick: notification.onClickTitle ? e => notification.onClickTitle(e, closeWithLock) : undefined
161
+ }, /*#__PURE__*/React.createElement(NotificationTitle, null, notification.title), notification.closeOnX && /*#__PURE__*/React.createElement(CloseIcon, {
162
+ onClick: constrainEvent(closeWithLock)
163
+ })) : notification.closeOnX && /*#__PURE__*/React.createElement(CloseIcon, {
164
+ onClick: closeWithLock
165
+ }), /*#__PURE__*/React.createElement(SwitchDiv, {
166
+ on: notification._key
167
+ }, /*#__PURE__*/React.createElement(NotificationContent, null, notification.icon && /*#__PURE__*/React.createElement(NotificationIconWrapper, {
168
+ isLoading: notification.isLoading,
169
+ iconFontSize: notification.iconFontSize
170
+ }, /*#__PURE__*/React.createElement(Icon, {
171
+ icon: notification.icon
172
+ }), notification.isLoading && /*#__PURE__*/React.createElement(Loading, {
173
+ size: 36,
174
+ white: true,
175
+ absolute: true
176
+ })), /*#__PURE__*/React.createElement(_StyledDiv, null, callIfFunction(notification.content, closeWithLock))), notification.details && /*#__PURE__*/React.createElement(NotificationDetails, {
177
+ onClick: constrainEvent()
178
+ }, notification.details)));
179
+ }))));
180
+ };
181
+ const useNotificationContainerWidthLock = containerRef => {
182
+ const lockCountRef = useRef(0);
183
+ const prevWidthRef = useRef(null);
184
+ const lockWidth = () => {
185
+ const el = containerRef.current;
186
+ if (!el) return;
187
+ if (lockCountRef.current === 0) {
188
+ prevWidthRef.current = el.style.width;
189
+ const measured = el.getBoundingClientRect().width;
190
+ el.style.width = measured + 'px';
191
+ }
192
+ lockCountRef.current = lockCountRef.current + 1;
193
+ };
194
+ const unlockWidth = () => {
195
+ const el = containerRef.current;
196
+ if (!el) return;
197
+ const next = Math.max(0, lockCountRef.current - 1);
198
+ lockCountRef.current = next;
199
+ if (next === 0) {
200
+ el.style.width = prevWidthRef.current || '';
201
+ prevWidthRef.current = null;
202
+ }
203
+ };
204
+ return {
205
+ lockWidth,
206
+ unlockWidth
207
+ };
208
+ };
209
+ var _StyledDiv = /*#__PURE__*/styled("div").withConfig({
210
+ displayName: "ToastNotifications___StyledDiv",
211
+ componentId: "sc-inycsj-8"
212
+ })(["min-width:0;"]);
213
+
214
+ export { ToastNotifications, createToastNotification, useToastNotificationToggle, useToastNotifications, willShowToastNotification };
215
+ //# sourceMappingURL=ToastNotifications.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ToastNotifications.mjs","sources":["../src/ToastNotifications.jsx"],"sourcesContent":["import React, {useEffect, useMemo, useRef} from 'react'\nimport {oneWayAnimation, constrainEvent} from '@startlibs/utils'\nimport _ from 'lodash/fp'\nimport styled from 'styled-components'\nimport {rgba} from 'polished'\nimport {Fill, useToggle, willUseSharedState} from '@startlibs/core'\nimport {getUID, ifUndefined, media, callIfFunction, getColor} from '@startlibs/utils'\nimport {css} from \"styled-components/macro\";\nimport {FlipList} from './FlipList'\nimport {Icon} from './Icon'\nimport {Loading} from './Loading'\nimport {SwitchDiv} from './SwitchDiv'\n\nconst NotificationContainer = styled.div `\n position: fixed;\n bottom: 0;\n max-height: 100%;\n z-index: 999999; \n display: flex;\n flex-direction: column-reverse;\n align-items: flex-end;\n overflow-y: auto;\n right: 1.5rem;\n ${media.desktop`\n padding-bottom: 1.5rem;\n `}\n ${media.mobile`\n padding-bottom: 0.75rem;\n `}\n ::-webkit-scrollbar {\n width: 21px;\n height: 21px;\n }\n ::-webkit-scrollbar-thumb {\n pointer-events: all;\n background: rgba(0,0,0,0.4);\n border-radius: 100px;\n background-clip: padding-box;\n border: 6px solid transparent;\n min-height: 30px;\n min-width: 30px;\n &:hover {\n background: rgba(0,0,0,0.5);\n background-clip: padding-box;\n border: 6px solid transparent;\n }\n }\n ::-webkit-scrollbar-corner {\n background: transparent;\n }\n ${media.desktop`\n &.JS-dialog-open {\n right: 2.75rem;\n }\n `}\n ${media.mobile`\n left: 0.75rem;\n right: 0.75rem;\n `}\n`\n\nconst ToastBox = styled.div`\n color: white;\n font-size: 14px;\n font-weight: 500;\n border-radius: 12px;\n flex-shrink: 0;\n margin-top: 0.5rem;\n overflow: hidden;\n transition: 0.3s background ease, 0.4s opacity 1.5s;\n ${media.desktop`\n background: ${props => rgba(getColor(props.type)(props),ifUndefined(props.opacity,0.7))};\n max-width: 300px;\n `}\n ${media.mobile`\n background: ${props => rgba(getColor(props.type)(props),ifUndefined(props.opacity,0.8))};\n `}\n ${props => css`background: ${getColor(props.type)};`}\n`\nconst NotificationTitleContainer = styled.div`\n background: rgba(0,0,0,0.1);\n padding: 0.5rem 2.25rem 0.5rem 0.75rem;\n border-radius: 12px 12px 0 0;\n position: relative;\n min-height: 30px;\n font-size: 13px;\n display: flex;\n align-items: center;\n font-weight: 400;\n ${props => props.onClick && \"cursor: pointer;\"}\n`\nconst NotificationTitle = styled.div`\n text-overflow: ellipsis;\n white-space: nowrap;\n overflow: hidden;\n`\nconst NotificationContent = styled.div`\n display: flex;\n align-items: center;\n text-align: left;\n padding: 1rem 1.5rem;\n ${media.mobile`\n justify-content: center;\n `}\n`\nconst NotificationIconWrapper = styled.div`\n margin-right: 1rem;\n position: relative;\n width: 36px;\n text-align: center;\n flex-shrink: 0;\n ${Icon} {\n font-size: ${props => (props.isLoading ? 22 : (props.iconFontSize || 40))}px;\n }\n`\nconst CloseIcon = styled(Icon).attrs({icon: 'x'})`\n font-size: 20px;\n cursor: pointer;\n width: 2rem;\n height: 2rem;\n line-height: 2rem;\n text-align: center;\n position: absolute;\n top: 50%;\n right: 0.25rem;\n transform: translateY(-50%);\n border-radius: 100px;\n opacity: 0.8;\n :hover, :active {\n background: rgba(0,0,0,0.1);\n opacity: 1;\n }\n`\nconst NotificationDetails = styled.div`\n background: rgba(0,0,0,0.1);\n border-radius: 8px;\n padding: 1rem;\n margin: 0 1rem 1rem;\n font-weight: 400;\n font-size: 13px;\n`\n\nconst [useToastNotifications, _useToastNotificationsRef,setToastNotifications] = willUseSharedState([])\nexport {useToastNotifications}\nconst formatNotification = (notification,extra) =>\n _.isObject(notification)\n ? {...notification,...extra, _key: getUID()}\n : {type:\"success\",content:notification,...extra, _key: getUID()}\n\nexport const createToastNotification = (notification,timeout, closeCallback) => {\n const uid = getUID()\n let currentTimer = -1;\n let hasClosed = false;\n const close = () => {\n clearTimeout(currentTimer);\n if (hasClosed) return\n setToastNotifications(_.differenceBy('uid',_, [{uid}]))\n hasClosed = true\n callIfFunction(closeCallback)\n }\n const notificationObj = formatNotification(notification,{uid,close})\n setToastNotifications(_.concat(notificationObj))\n if (timeout>0) {\n currentTimer = setTimeout(close,timeout)\n }\n return {\n close,\n openWith:(obj,timeout) => {\n clearTimeout(currentTimer);\n if (timeout > 0) {\n currentTimer = setTimeout(close,timeout)\n }\n const notificationObj = formatNotification(obj,{uid,close})\n if (hasClosed) {\n hasClosed = false\n setToastNotifications(_.concat(notificationObj))\n } else {\n setToastNotifications(_.map(n => n.uid === uid ? {...notificationObj, _key: n._key} : n))\n }\n }\n }\n}\nexport const useToastNotificationToggle = (notification,timeout) => {\n const toggle = useToggle()\n const extraProps = useMemo(() => notification.content || notification.element ? {} : notification,[])\n const make = (notification,timeout) => notification && createToastNotification(formatNotification(notification,extraProps),timeout,() => toggle.close())\n useEffect(() => {\n if (notification.content || notification.element) {\n toggle.openWith(make(notification))\n }\n },[])\n\n return useMemo(() => ({\n close: () => toggle.get()?.close(),\n openWith: (notification,timeout) => toggle.get() ? toggle.get().openWith(formatNotification(notification,extraProps),timeout) : toggle.openWith(make(notification,timeout)),\n open: () => toggle.get() ? toggle.get().openWith(formatNotification(notification,extraProps),timeout) : toggle.openWith(make(notification,timeout))\n }),[toggle.isOpen])\n}\nexport const willShowToastNotification = (str) => () => showToastNotification(str)\n\nconst EXIT_ANIMATION_MS = 300\nconst TOAST_EASING = 'cubic-bezier(0.22, 0.61, 0.36, 1)'\nconst TOAST_TIMING = `${EXIT_ANIMATION_MS}ms ${TOAST_EASING}`\n\nconst animation = oneWayAnimation(\n 'transform: translateY(0); opacity: 1;',\n 'transform: translateY(0.25rem); opacity: 1;',\n 'transform: translateY(1rem); opacity: 0;'\n)\nconst removeAnimationReinsertPosition = e => e.style.position=''\nexport const ToastNotifications = () => {\n const [notifications,setNotifications] = useToastNotifications()\n const containerRef = useRef(null)\n const {lockWidth, unlockWidth} = useNotificationContainerWidthLock(containerRef)\n\n return (<Fill name=\"Notifications\">\n <NotificationContainer ref={containerRef} className=\"JS-on-open-dialog\">\n <FlipList animation={animation} timing={TOAST_TIMING} onReinsert={removeAnimationReinsertPosition} skipParentMorph anchoredDownList>\n {\n notifications.map(notification => {\n const closeWithLock = () => {\n lockWidth()\n notification.close()\n setTimeout(unlockWidth, EXIT_ANIMATION_MS)\n }\n\n return (\n callIfFunction(notification.element,closeWithLock) ||\n <ToastBox\n key={`toast-${notification.uid}`}\n type={notification.type}\n onClick={notification.onClick}\n opacity={notification.opacity}\n >\n {notification.title ? \n <NotificationTitleContainer onClick={notification.onClickTitle ? (e) => notification.onClickTitle(e,closeWithLock) : undefined}>\n <NotificationTitle>{notification.title}</NotificationTitle>\n {notification.closeOnX && <CloseIcon onClick={constrainEvent(closeWithLock)}/>}\n </NotificationTitleContainer>\n :\n notification.closeOnX && <CloseIcon onClick={closeWithLock}/>\n }\n <SwitchDiv on={notification._key}>\n <NotificationContent>\n {notification.icon &&\n <NotificationIconWrapper\n isLoading={notification.isLoading}\n iconFontSize={notification.iconFontSize}\n >\n <Icon icon={notification.icon}/>\n {notification.isLoading && <Loading size={36} white absolute/>}\n </NotificationIconWrapper>\n }\n <div css=\"min-width: 0;\">{callIfFunction(notification.content,closeWithLock)}</div>\n </NotificationContent>\n {notification.details &&\n <NotificationDetails onClick={constrainEvent()}>\n {notification.details}\n </NotificationDetails>\n }\n </SwitchDiv>\n </ToastBox>\n )\n })\n }\n </FlipList>\n </NotificationContainer>\n </Fill>)\n}\n\nconst useNotificationContainerWidthLock = (containerRef) => {\n const lockCountRef = useRef(0)\n const prevWidthRef = useRef(null)\n\n const lockWidth = () => {\n const el = containerRef.current\n if (!el) return\n if (lockCountRef.current === 0) {\n prevWidthRef.current = el.style.width\n const measured = el.getBoundingClientRect().width\n el.style.width = measured + 'px'\n }\n lockCountRef.current = lockCountRef.current + 1\n }\n\n const unlockWidth = () => {\n const el = containerRef.current\n if (!el) return\n const next = Math.max(0, lockCountRef.current - 1)\n lockCountRef.current = next\n if (next === 0) {\n el.style.width = prevWidthRef.current || ''\n prevWidthRef.current = null\n }\n }\n\n return {lockWidth, unlockWidth}\n}"],"names":["NotificationContainer","styled","div","withConfig","displayName","componentId","media","desktop","_templateObject","_taggedTemplateLiteral","mobile","_templateObject2","_templateObject3","_templateObject4","ToastBox","_templateObject5","props","rgba","getColor","type","ifUndefined","opacity","_templateObject6","css","_templateObject7","NotificationTitleContainer","onClick","NotificationTitle","NotificationContent","_templateObject8","NotificationIconWrapper","Icon","isLoading","iconFontSize","CloseIcon","attrs","icon","NotificationDetails","useToastNotifications","_useToastNotificationsRef","setToastNotifications","willUseSharedState","formatNotification","notification","extra","_isObject","_objectSpread","_key","getUID","content","createToastNotification","timeout","closeCallback","uid","currentTimer","hasClosed","close","clearTimeout","_differenceBy","placeholder","callIfFunction","notificationObj","_concat","setTimeout","openWith","obj","_map","n","useToastNotificationToggle","toggle","useToggle","extraProps","useMemo","element","make","useEffect","_toggle$get","get","open","isOpen","willShowToastNotification","str","showToastNotification","EXIT_ANIMATION_MS","TOAST_EASING","TOAST_TIMING","concat","animation","oneWayAnimation","removeAnimationReinsertPosition","e","style","position","ToastNotifications","notifications","setNotifications","containerRef","useRef","lockWidth","unlockWidth","useNotificationContainerWidthLock","React","createElement","Fill","name","ref","className","FlipList","timing","onReinsert","skipParentMorph","anchoredDownList","map","closeWithLock","key","title","onClickTitle","undefined","closeOnX","constrainEvent","SwitchDiv","on","Loading","size","white","absolute","_StyledDiv","details","lockCountRef","prevWidthRef","el","current","width","measured","getBoundingClientRect","next","Math","max"],"mappings":";;;;;;;;;;;;;;;;;;;AAaA,MAAMA,q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dL,EAAE,CAACvC,KAAK,CAACyC,KAAK,GAAGH,YAAY,CAACE,OAAO,IAAI,EAAE,CAAA;MAC3CF,YAAY,CAACE,OAAO,GAAG,IAAI,CAAA;AAC7B,KAAA;GACD,CAAA;EAED,OAAO;IAACjC,SAAS;AAAEC,IAAAA,WAAAA;GAAY,CAAA;AACjC,CAAC,CAAA;AAAA,IAAA2B,UAAA,gBAAA7H,MAAA,CAAA,KAAA,CAAA,CAAAE,UAAA,CAAA;EAAAC,WAAA,EAAA,gCAAA;EAAAC,WAAA,EAAA,aAAA;AAAA,CAAA,CAAA,CAAA,CAAA,cAAA,CAAA,CAAA;;;;"}
@@ -0,0 +1,160 @@
1
+ import _extends from '@babel/runtime/helpers/extends';
2
+ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
3
+ import _isFunction from 'lodash/fp/isFunction';
4
+ import React, { useEffect } from 'react';
5
+ import styled, { css } from 'styled-components';
6
+ import { Popup } from './Popup.mjs';
7
+ import { useToggle, useRefState } from '@startlibs/core';
8
+ import { customTheme, twoWayAnimation } from '@startlibs/utils';
9
+
10
+ const _excluded = ["children", "delay", "instant", "whenEllipsis", "content", "showOnClick", "showOnMount", "clickTimeout"];
11
+ const TooltipContainer = /*#__PURE__*/styled.div.withConfig({
12
+ displayName: "Tooltip__TooltipContainer",
13
+ componentId: "sc-hhprhj-0"
14
+ })(["display:inline-block;", " "], props => props.isWrapper ? "position:relative;" : css(["position:absolute;top:0;left:0;bottom:0;right:0;", ""], props => props.isOpen && 'pointer-events: none;'));
15
+ const TooltipPopup = /*#__PURE__*/styled(Popup).withConfig({
16
+ displayName: "Tooltip__TooltipPopup",
17
+ componentId: "sc-hhprhj-1"
18
+ })(["font-size:12px;pointer-events:none;background-color:rgba(0,0,0,0.6);box-shadow:none;color:white;padding:0.25rem 1rem;border-radius:100px;", ""], customTheme('Tooltip'));
19
+ const [fadeIn, fadeOut] = twoWayAnimation("opacity:0;", "opacity:1;");
20
+ const isEllipsis = event => event.currentTarget.firstChild && event.currentTarget.firstChild.offsetWidth < event.currentTarget.firstChild.scrollWidth;
21
+ const RECENTLY_CLOSED_TIMEOUT = 200;
22
+ let recentlyClosed = false;
23
+ const openRef = {
24
+ current: null
25
+ };
26
+ const Tooltip = _ref => {
27
+ let {
28
+ children,
29
+ delay = 400,
30
+ instant,
31
+ whenEllipsis,
32
+ content,
33
+ showOnClick,
34
+ showOnMount,
35
+ clickTimeout = 3000
36
+ } = _ref,
37
+ rest = _objectWithoutProperties(_ref, _excluded);
38
+ const tooltip = useToggle();
39
+ const timeout = useRefState(-1);
40
+
41
+ // showOnMount (ms): abre sozinho ao montar (hint) e some após o tempo dado. O
42
+ // hover continua normal — se o usuário passa o mouse durante a janela, o open
43
+ // cancela o closeAfter (clearClosing) e o tooltip fica até o mouseleave.
44
+ useEffect(() => {
45
+ if (!showOnMount) return;
46
+ tooltip.open();
47
+ tooltip.closeAfter(showOnMount);
48
+ // Dispensa o hint na primeira interação do usuário: clique em qualquer lugar
49
+ // (o popup tem pointer-events:none, então todo clique é "fora") ou scroll.
50
+ // O assentamento da página é resize (não scroll), então não dispara isso.
51
+ const dismiss = () => tooltip.close();
52
+ document.addEventListener('click', dismiss, {
53
+ once: true
54
+ });
55
+ window.addEventListener('scroll', dismiss, {
56
+ once: true,
57
+ passive: true
58
+ });
59
+ // O conteúdo da página pode assentar depois do mount (imagens/dados async),
60
+ // mudando a posição do âncora — mas o popup fixed só reposiciona em scroll/
61
+ // resize, então ficava travado no lugar antigo. Enquanto o hint está visível,
62
+ // observa o crescimento da página e reposiciona (portalReposition → setPosition).
63
+ const ro = new ResizeObserver(() => window.dispatchEvent(new CustomEvent('portalReposition')));
64
+ ro.observe(document.body);
65
+ const stopRO = setTimeout(() => ro.disconnect(), showOnMount);
66
+ return () => {
67
+ document.removeEventListener('click', dismiss);
68
+ window.removeEventListener('scroll', dismiss);
69
+ ro.disconnect();
70
+ clearTimeout(stopRO);
71
+ };
72
+ }, []);
73
+
74
+ // Modo clique: abre no clique e some sozinho após clickTimeout (closeAfter é
75
+ // à prova de unmount). Não borbulha stopPropagation — quem usa decide isso.
76
+ const openOnClick = () => {
77
+ tooltip.open();
78
+ tooltip.closeAfter(clickTimeout);
79
+ };
80
+
81
+ // Long-press no mobile: hover não existe e "segurar" não dispara mouseenter, então
82
+ // sem isso o tooltip não reaparece no toque. touchstart arma um timer; se segurou
83
+ // além do delay, reusa o openOnClick. Se o press disparou, preventDefault no touchend
84
+ // suprime o clique sintético (segurar espia, não aciona).
85
+ const touchTimer = useRefState(-1);
86
+ const didLongPress = useRefState(false);
87
+ const onTouchStart = () => {
88
+ didLongPress.set(false);
89
+ touchTimer.set(setTimeout(() => {
90
+ didLongPress.set(true);
91
+ openOnClick();
92
+ // Dispensa no scroll em QUALQUER lugar (como o hint do showOnMount): o touchmove do
93
+ // container só pegaria scroll com o dedo ainda no alvo — soltar e rolar não fecharia.
94
+ // tooltip.close é estável (useMemo []) e no-op após unmount; {once} se auto-remove.
95
+ window.addEventListener('scroll', tooltip.close, {
96
+ once: true,
97
+ passive: true
98
+ });
99
+ }, delay));
100
+ };
101
+ const onTouchEnd = e => {
102
+ clearTimeout(touchTimer.get());
103
+ if (didLongPress.get()) e.preventDefault();
104
+ };
105
+ // Só cancela o press pendente — não abrir no meio de um scroll iniciado sobre o alvo.
106
+ const onTouchMove = () => clearTimeout(touchTimer.get());
107
+
108
+ // Remove o listener de scroll pendente se desmontar antes de rolar (evita leak da closure).
109
+ useEffect(() => () => window.removeEventListener('scroll', tooltip.close), []);
110
+ const mouseEnter = e => {
111
+ if (!whenEllipsis || (_isFunction(whenEllipsis) ? whenEllipsis : isEllipsis)(e)) {
112
+ timeout.set(setTimeout(() => {
113
+ tooltip.open();
114
+ if (recentlyClosed && openRef.current) {
115
+ openRef.current.remove();
116
+ }
117
+ }, instant || recentlyClosed ? 0 : delay));
118
+ !children && e.currentTarget.parentNode.addEventListener('mouseleave', onMouseLeave);
119
+ }
120
+ };
121
+ const onMouseLeave = e => {
122
+ clearTimeout(timeout.get());
123
+ if (tooltip.get()) {
124
+ timeout.set(false);
125
+ !children && e.currentTarget.removeEventListener('mouseleave', onMouseLeave);
126
+ const currentlyClosed = recentlyClosed = setTimeout(() => {
127
+ recentlyClosed = recentlyClosed === currentlyClosed ? false : recentlyClosed;
128
+ }, RECENTLY_CLOSED_TIMEOUT);
129
+ tooltip.close();
130
+ }
131
+ };
132
+ const getAnimation = () => {
133
+ if (recentlyClosed && timeout.get() !== false) {
134
+ return '';
135
+ } else {
136
+ return fadeIn;
137
+ }
138
+ };
139
+ const canLongPress = content && !showOnClick;
140
+ return /*#__PURE__*/React.createElement(TooltipContainer, {
141
+ isOpen: tooltip.isOpen,
142
+ isWrapper: !!children,
143
+ onMouseUp: showOnClick ? undefined : onMouseLeave,
144
+ onMouseLeave: children && !showOnClick ? onMouseLeave : undefined,
145
+ onMouseEnter: showOnClick ? undefined : mouseEnter,
146
+ onTouchStart: canLongPress ? onTouchStart : undefined,
147
+ onTouchEnd: canLongPress ? onTouchEnd : undefined,
148
+ onTouchMove: canLongPress ? onTouchMove : undefined,
149
+ onClick: showOnClick ? openOnClick : undefined
150
+ }, tooltip.isOpen && content && /*#__PURE__*/React.createElement(TooltipPopup, _extends({
151
+ animation: getAnimation,
152
+ animationOptions: {
153
+ ref: openRef
154
+ },
155
+ top: !(rest.bottom || rest.left || rest.right || rest.at || rest.my)
156
+ }, rest), content), children);
157
+ };
158
+
159
+ export { Tooltip };
160
+ //# sourceMappingURL=Tooltip.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tooltip.mjs","sources":["../src/Tooltip.jsx"],"sourcesContent":["import React, {useEffect, useMemo} from 'react'\nimport _ from 'lodash/fp'\nimport styled, {css} from 'styled-components'\nimport {Popup} from './Popup'\nimport {useRefState, useToggle} from '@startlibs/core'\nimport {customTheme,twoWayAnimation} from '@startlibs/utils'\n\nconst TooltipContainer = styled.div`\n display: inline-block;\n ${props => props.isWrapper ?\n `position:relative;` :\n css`\n position:absolute;\n top:0;\n left:0;\n bottom:0;\n right:0;\n ${props => props.isOpen && 'pointer-events: none;'}\n `} \n`\nconst TooltipPopup = styled(Popup)`\n font-size: 12px;\n pointer-events: none;\n background-color: rgba(0,0,0,0.6);\n box-shadow: none;\n color: white;\n padding: 0.25rem 1rem;\n border-radius: 100px;\n ${customTheme('Tooltip')}\n`\n\nconst [fadeIn, fadeOut] = twoWayAnimation(`opacity:0;`, `opacity:1;`)\n\nconst isEllipsis = (event) => event.currentTarget.firstChild && event.currentTarget.firstChild.offsetWidth < event.currentTarget.firstChild.scrollWidth\n\nconst RECENTLY_CLOSED_TIMEOUT = 200\nlet recentlyClosed = false\nconst openRef = {current:null}\n\nexport const Tooltip = ({children, delay = 400, instant, whenEllipsis, content, showOnClick, showOnMount, clickTimeout = 3000, ...rest}) => {\n\n const tooltip = useToggle()\n const timeout = useRefState(-1)\n\n // showOnMount (ms): abre sozinho ao montar (hint) e some após o tempo dado. O\n // hover continua normal — se o usuário passa o mouse durante a janela, o open\n // cancela o closeAfter (clearClosing) e o tooltip fica até o mouseleave.\n useEffect(() => {\n if (!showOnMount) return\n tooltip.open()\n tooltip.closeAfter(showOnMount)\n // Dispensa o hint na primeira interação do usuário: clique em qualquer lugar\n // (o popup tem pointer-events:none, então todo clique é \"fora\") ou scroll.\n // O assentamento da página é resize (não scroll), então não dispara isso.\n const dismiss = () => tooltip.close()\n document.addEventListener('click', dismiss, {once: true})\n window.addEventListener('scroll', dismiss, {once: true, passive: true})\n // O conteúdo da página pode assentar depois do mount (imagens/dados async),\n // mudando a posição do âncora — mas o popup fixed só reposiciona em scroll/\n // resize, então ficava travado no lugar antigo. Enquanto o hint está visível,\n // observa o crescimento da página e reposiciona (portalReposition → setPosition).\n const ro = new ResizeObserver(() => window.dispatchEvent(new CustomEvent('portalReposition')))\n ro.observe(document.body)\n const stopRO = setTimeout(() => ro.disconnect(), showOnMount)\n return () => {\n document.removeEventListener('click', dismiss)\n window.removeEventListener('scroll', dismiss)\n ro.disconnect()\n clearTimeout(stopRO)\n }\n }, [])\n\n // Modo clique: abre no clique e some sozinho após clickTimeout (closeAfter é\n // à prova de unmount). Não borbulha stopPropagation — quem usa decide isso.\n const openOnClick = () => {\n tooltip.open()\n tooltip.closeAfter(clickTimeout)\n }\n\n // Long-press no mobile: hover não existe e \"segurar\" não dispara mouseenter, então\n // sem isso o tooltip não reaparece no toque. touchstart arma um timer; se segurou\n // além do delay, reusa o openOnClick. Se o press disparou, preventDefault no touchend\n // suprime o clique sintético (segurar espia, não aciona).\n const touchTimer = useRefState(-1)\n const didLongPress = useRefState(false)\n const onTouchStart = () => {\n didLongPress.set(false)\n touchTimer.set(setTimeout(() => {\n didLongPress.set(true)\n openOnClick()\n // Dispensa no scroll em QUALQUER lugar (como o hint do showOnMount): o touchmove do\n // container só pegaria scroll com o dedo ainda no alvo — soltar e rolar não fecharia.\n // tooltip.close é estável (useMemo []) e no-op após unmount; {once} se auto-remove.\n window.addEventListener('scroll', tooltip.close, {once: true, passive: true})\n }, delay))\n }\n const onTouchEnd = (e) => {\n clearTimeout(touchTimer.get())\n if (didLongPress.get()) e.preventDefault()\n }\n // Só cancela o press pendente — não abrir no meio de um scroll iniciado sobre o alvo.\n const onTouchMove = () => clearTimeout(touchTimer.get())\n\n // Remove o listener de scroll pendente se desmontar antes de rolar (evita leak da closure).\n useEffect(() => () => window.removeEventListener('scroll', tooltip.close), [])\n\n const mouseEnter = (e) => {\n if (!whenEllipsis || (_.isFunction(whenEllipsis) ? whenEllipsis : isEllipsis)(e)) {\n timeout.set(setTimeout(() => {\n\n tooltip.open()\n if (recentlyClosed && openRef.current) {\n openRef.current.remove()\n }\n },(instant || recentlyClosed) ? 0 : delay))\n !children && e.currentTarget.parentNode.addEventListener('mouseleave', onMouseLeave)\n }\n }\n\n const onMouseLeave = (e) => {\n clearTimeout(timeout.get())\n if (tooltip.get()) {\n timeout.set(false)\n !children && e.currentTarget.removeEventListener('mouseleave', onMouseLeave)\n const currentlyClosed = recentlyClosed = setTimeout(() => {\n recentlyClosed = recentlyClosed === currentlyClosed ? false : recentlyClosed\n },RECENTLY_CLOSED_TIMEOUT)\n tooltip.close()\n }\n }\n\n const getAnimation = () => {\n if (recentlyClosed && timeout.get()!==false) {\n return ''\n } else {\n return fadeIn\n }\n }\n\n const canLongPress = content && !showOnClick\n\n return <TooltipContainer isOpen={tooltip.isOpen} isWrapper={!!children}\n onMouseUp={showOnClick ? undefined : onMouseLeave}\n onMouseLeave={(children && !showOnClick) ? onMouseLeave : undefined}\n onMouseEnter={showOnClick ? undefined : mouseEnter}\n onTouchStart={canLongPress ? onTouchStart : undefined}\n onTouchEnd={canLongPress ? onTouchEnd : undefined}\n onTouchMove={canLongPress ? onTouchMove : undefined}\n onClick={showOnClick ? openOnClick : undefined}>\n {\n tooltip.isOpen && content &&\n <TooltipPopup animation={getAnimation} animationOptions={{ref:openRef}} top={!(rest.bottom || rest.left || rest.right || rest.at || rest.my)} {...rest}>\n {content}\n </TooltipPopup>\n }\n {children}\n </TooltipContainer>\n}\n"],"names":["TooltipContainer","styled","div","withConfig","displayName","componentId","props","isWrapper","css","isOpen","TooltipPopup","Popup","customTheme","fadeIn","fadeOut","twoWayAnimation","isEllipsis","event","currentTarget","firstChild","offsetWidth","scrollWidth","RECENTLY_CLOSED_TIMEOUT","recentlyClosed","openRef","current","Tooltip","_ref","children","delay","instant","whenEllipsis","content","showOnClick","showOnMount","clickTimeout","rest","_objectWithoutProperties","_excluded","tooltip","useToggle","timeout","useRefState","useEffect","open","closeAfter","dismiss","close","document","addEventListener","once","window","passive","ro","ResizeObserver","dispatchEvent","CustomEvent","observe","body","stopRO","setTimeout","disconnect","removeEventListener","clearTimeout","openOnClick","touchTimer","didLongPress","onTouchStart","set","onTouchEnd","e","get","preventDefault","onTouchMove","mouseEnter","_isFunction","remove","parentNode","onMouseLeave","currentlyClosed","getAnimation","canLongPress","React","createElement","onMouseUp","undefined","onMouseEnter","onClick","_extends","animation","animationOptions","ref","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AI5D,IAAI,CAAC6D,EAAE,CAAA;AAAE,GAAA,EAAK7D,IAAI,CACrJJ,EAAAA,OACW,CAAC,EAEhBJ,QACe,CAAC,CAAA;AACrB;;;;"}
@@ -0,0 +1,56 @@
1
+ import _extends from '@babel/runtime/helpers/extends';
2
+ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
3
+ import React, { useRef } from 'react';
4
+ import styled from 'styled-components';
5
+ import { FlipList } from './FlipList.mjs';
6
+ import { oneWayAnimation } from '@startlibs/utils';
7
+
8
+ const _excluded = ["children", "animation", "skipChromeFix", "className", "block", "inline"];
9
+ const DEFAULT_ANIMATION = oneWayAnimation("opacity: 1;", "opacity: 0;");
10
+ const AnimationBlockContainer = /*#__PURE__*/styled.div.withConfig({
11
+ displayName: "TransitionDiv__AnimationBlockContainer",
12
+ componentId: "sc-1sh2xah-0"
13
+ })(["", " position:relative;"], props => props.inline ? 'display: inline-block; ' : '');
14
+ const TransitionDiv = _ref => {
15
+ let {
16
+ children,
17
+ animation,
18
+ skipChromeFix,
19
+ className,
20
+ block,
21
+ inline
22
+ } = _ref,
23
+ rest = _objectWithoutProperties(_ref, _excluded);
24
+ const blockRef = useRef();
25
+ const overflowEffect = () => {
26
+ if (blockRef.current) {
27
+ const prevOverflow = blockRef.current.style.overflow;
28
+ blockRef.current.style.overflow = 'hidden';
29
+ return () => {
30
+ blockRef.current.style.overflow = prevOverflow;
31
+ };
32
+ }
33
+ };
34
+ const content = children ? /*#__PURE__*/React.createElement(FlipList, _extends({
35
+ smallJumpFix: inline && -3,
36
+ effect: overflowEffect,
37
+ skipChromeFix: skipChromeFix,
38
+ animation: animation || DEFAULT_ANIMATION
39
+ }, rest), [/*#__PURE__*/React.createElement("div", {
40
+ className: block || inline ? "" : className,
41
+ key: "first"
42
+ }, children)]) : /*#__PURE__*/React.createElement(FlipList, _extends({
43
+ smallJumpFix: inline && -3,
44
+ effect: overflowEffect,
45
+ skipChromeFix: skipChromeFix,
46
+ animation: animation || DEFAULT_ANIMATION
47
+ }, rest), []);
48
+ return block || inline ? /*#__PURE__*/React.createElement(AnimationBlockContainer, {
49
+ inline: inline,
50
+ ref: blockRef,
51
+ className: className
52
+ }, content) : content;
53
+ };
54
+
55
+ export { AnimationBlockContainer, TransitionDiv };
56
+ //# sourceMappingURL=TransitionDiv.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TransitionDiv.mjs","sources":["../src/TransitionDiv.jsx"],"sourcesContent":["import React, {useRef} from 'react'\nimport styled from 'styled-components'\nimport {FlipList} from './FlipList'\nimport {oneWayAnimation} from '@startlibs/utils'\n\n\nconst DEFAULT_ANIMATION = oneWayAnimation(`opacity: 1;`, `opacity: 0;`)\n\nexport const AnimationBlockContainer = styled.div`\n ${props => props.inline ? 'display: inline-block; ' : ''}\n position:relative;\n`\n\n\nexport const TransitionDiv = ({children,animation, skipChromeFix, className, block, inline,...rest}) => {\n\n const blockRef = useRef()\n\n const overflowEffect = () => {\n if (blockRef.current) {\n const prevOverflow = blockRef.current.style.overflow\n blockRef.current.style.overflow = 'hidden'\n return () => {\n blockRef.current.style.overflow = prevOverflow\n }\n }\n }\n\n const content = children\n ? <FlipList smallJumpFix={inline && -3} effect={overflowEffect} skipChromeFix={skipChromeFix} animation={animation || DEFAULT_ANIMATION} {...rest}>{[<div className={(block || inline) ? \"\" : className} key=\"first\">{children}</div>]}</FlipList>\n : <FlipList smallJumpFix={inline && -3} effect={overflowEffect} skipChromeFix={skipChromeFix} animation={animation || DEFAULT_ANIMATION} {...rest}>{[]}</FlipList>\n\n return (block || inline) ? <AnimationBlockContainer inline={inline} ref={blockRef} className={className}>{content}</AnimationBlockContainer> : content\n}"],"names":["DEFAULT_ANIMATION","oneWayAnimation","AnimationBlockContainer","styled","div","withConfig","displayName","componentId","props","inline","TransitionDiv","_ref","children","animation","skipChromeFix","className","block","rest","_objectWithoutProperties","_excluded","blockRef","useRef","overflowEffect","current","prevOverflow","style","overflow","content","React","createElement","FlipList","_extends","smallJum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