etudes 1.2.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/README.md +1 -1
  2. package/lib/Accordion.d.ts +80 -71
  3. package/lib/Accordion.js +173 -183
  4. package/lib/Accordion.js.map +1 -1
  5. package/lib/BurgerButton.d.ts +20 -7
  6. package/lib/BurgerButton.js +113 -20
  7. package/lib/BurgerButton.js.map +1 -1
  8. package/lib/Conditional.d.ts +2 -3
  9. package/lib/Conditional.js +0 -1
  10. package/lib/Conditional.js.map +1 -1
  11. package/lib/DebugConsole.d.ts +14 -23
  12. package/lib/DebugConsole.js +86 -87
  13. package/lib/DebugConsole.js.map +1 -1
  14. package/lib/Dial.d.ts +53 -16
  15. package/lib/Dial.js +121 -35
  16. package/lib/Dial.js.map +1 -1
  17. package/lib/Dropdown.d.ts +68 -83
  18. package/lib/Dropdown.js +226 -161
  19. package/lib/Dropdown.js.map +1 -1
  20. package/lib/Each.d.ts +2 -2
  21. package/lib/Each.js.map +1 -1
  22. package/lib/ExtractChild.d.ts +5 -4
  23. package/lib/ExtractChild.js +13 -11
  24. package/lib/ExtractChild.js.map +1 -1
  25. package/lib/ExtractChildren.d.ts +2 -2
  26. package/lib/ExtractChildren.js +7 -5
  27. package/lib/ExtractChildren.js.map +1 -1
  28. package/lib/FlatSVG.d.ts +30 -25
  29. package/lib/FlatSVG.js +28 -37
  30. package/lib/FlatSVG.js.map +1 -1
  31. package/lib/List.d.ts +97 -54
  32. package/lib/List.js +124 -63
  33. package/lib/List.js.map +1 -1
  34. package/lib/MasonryGrid.d.ts +27 -15
  35. package/lib/MasonryGrid.js +163 -148
  36. package/lib/MasonryGrid.js.map +1 -1
  37. package/lib/Panorama.d.ts +100 -21
  38. package/lib/Panorama.js +45 -44
  39. package/lib/Panorama.js.map +1 -1
  40. package/lib/PanoramaSlider.d.ts +65 -23
  41. package/lib/PanoramaSlider.js +150 -45
  42. package/lib/PanoramaSlider.js.map +1 -1
  43. package/lib/RangeSlider.d.ts +29 -89
  44. package/lib/RangeSlider.js +272 -286
  45. package/lib/RangeSlider.js.map +1 -1
  46. package/lib/Repeat.d.ts +4 -3
  47. package/lib/Repeat.js +3 -2
  48. package/lib/Repeat.js.map +1 -1
  49. package/lib/RotatingGallery.d.ts +38 -36
  50. package/lib/RotatingGallery.js +47 -17
  51. package/lib/RotatingGallery.js.map +1 -1
  52. package/lib/SelectableButton.d.ts +13 -4
  53. package/lib/SelectableButton.js +3 -14
  54. package/lib/SelectableButton.js.map +1 -1
  55. package/lib/Slider.d.ts +103 -41
  56. package/lib/Slider.js +182 -82
  57. package/lib/Slider.js.map +1 -1
  58. package/lib/StepwiseSlider.d.ts +146 -59
  59. package/lib/StepwiseSlider.js +248 -142
  60. package/lib/StepwiseSlider.js.map +1 -1
  61. package/lib/SwipeContainer.d.ts +13 -5
  62. package/lib/SwipeContainer.js +5 -15
  63. package/lib/SwipeContainer.js.map +1 -1
  64. package/lib/TextField.d.ts +1 -1
  65. package/lib/TextField.js +5 -15
  66. package/lib/TextField.js.map +1 -1
  67. package/lib/Video.d.ts +30 -51
  68. package/lib/Video.js +77 -119
  69. package/lib/Video.js.map +1 -1
  70. package/lib/WithTooltip.d.ts +16 -18
  71. package/lib/WithTooltip.js +167 -101
  72. package/lib/WithTooltip.js.map +1 -1
  73. package/lib/hooks/useDocumentTitle.d.ts +2 -1
  74. package/lib/hooks/useDocumentTitle.js +2 -1
  75. package/lib/hooks/useDocumentTitle.js.map +1 -1
  76. package/lib/hooks/useDragEffect.d.ts +25 -16
  77. package/lib/hooks/useDragEffect.js +30 -20
  78. package/lib/hooks/useDragEffect.js.map +1 -1
  79. package/lib/hooks/useElementRect.d.ts +2 -1
  80. package/lib/hooks/useElementRect.js +5 -4
  81. package/lib/hooks/useElementRect.js.map +1 -1
  82. package/lib/hooks/useInterval.d.ts +2 -2
  83. package/lib/hooks/useInterval.js +1 -1
  84. package/lib/hooks/useInterval.js.map +1 -1
  85. package/lib/hooks/useLoadImageEffect.d.ts +6 -6
  86. package/lib/hooks/useLoadImageEffect.js.map +1 -1
  87. package/lib/hooks/usePrevious.d.ts +6 -0
  88. package/lib/hooks/usePrevious.js +17 -0
  89. package/lib/hooks/usePrevious.js.map +1 -0
  90. package/lib/hooks/useResizeEffect.d.ts +2 -2
  91. package/lib/hooks/useResizeEffect.js +5 -8
  92. package/lib/hooks/useResizeEffect.js.map +1 -1
  93. package/lib/hooks/useSearchParamState.d.ts +10 -7
  94. package/lib/hooks/useSearchParamState.js +14 -10
  95. package/lib/hooks/useSearchParamState.js.map +1 -1
  96. package/lib/utils/asClassNameDict.d.ts +3 -0
  97. package/lib/utils/asClassNameDict.js +7 -0
  98. package/lib/utils/asClassNameDict.js.map +1 -0
  99. package/lib/utils/asComponentDict.d.ts +5 -0
  100. package/lib/utils/asComponentDict.js +23 -0
  101. package/lib/utils/asComponentDict.js.map +1 -0
  102. package/lib/utils/asStyleDict.d.ts +4 -0
  103. package/lib/utils/asStyleDict.js +7 -0
  104. package/lib/utils/asStyleDict.js.map +1 -0
  105. package/lib/utils/cloneStyledElement.d.ts +18 -0
  106. package/lib/utils/cloneStyledElement.js +63 -0
  107. package/lib/utils/cloneStyledElement.js.map +1 -0
  108. package/lib/utils/styles.d.ts +2 -0
  109. package/lib/utils/styles.js +22 -0
  110. package/lib/utils/styles.js.map +1 -0
  111. package/lib/utils/useDebug.d.ts +2 -0
  112. package/lib/utils/useDebug.js +46 -0
  113. package/lib/utils/useDebug.js.map +1 -0
  114. package/package.json +25 -33
  115. package/lib/AbstractSelectableCollection.d.ts +0 -94
  116. package/lib/AbstractSelectableCollection.js +0 -151
  117. package/lib/AbstractSelectableCollection.js.map +0 -1
  118. package/lib/types/index.d.ts +0 -7
  119. package/lib/types/index.js +0 -3
  120. package/lib/types/index.js.map +0 -1
@@ -1,8 +1,4 @@
1
1
  "use strict";
2
- var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
- if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
- return cooked;
5
- };
6
2
  var __assign = (this && this.__assign) || function () {
7
3
  __assign = Object.assign || function(t) {
8
4
  for (var s, i = 1, n = arguments.length; i < n; i++) {
@@ -37,53 +33,43 @@ var __importStar = (this && this.__importStar) || function (mod) {
37
33
  __setModuleDefault(result, mod);
38
34
  return result;
39
35
  };
40
- var __rest = (this && this.__rest) || function (s, e) {
41
- var t = {};
42
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
43
- t[p] = s[p];
44
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
45
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
46
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
47
- t[p[i]] = s[p[i]];
48
- }
49
- return t;
50
- };
51
- var __read = (this && this.__read) || function (o, n) {
52
- var m = typeof Symbol === "function" && o[Symbol.iterator];
53
- if (!m) return o;
54
- var i = m.call(o), r, ar = [], e;
55
- try {
56
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
57
- }
58
- catch (error) { e = { error: error }; }
59
- finally {
60
- try {
61
- if (r && !r.done && (m = i["return"])) m.call(i);
62
- }
63
- finally { if (e) throw e.error; }
64
- }
65
- return ar;
66
- };
67
36
  var __importDefault = (this && this.__importDefault) || function (mod) {
68
37
  return (mod && mod.__esModule) ? mod : { "default": mod };
69
38
  };
70
39
  Object.defineProperty(exports, "__esModule", { value: true });
40
+ var classnames_1 = __importDefault(require("classnames"));
71
41
  var react_1 = __importStar(require("react"));
72
42
  var spase_1 = require("spase");
73
- var styled_components_1 = __importStar(require("styled-components"));
74
43
  var ExtractChild_1 = __importDefault(require("./ExtractChild"));
75
44
  var useElementRect_1 = __importDefault(require("./hooks/useElementRect"));
76
45
  var useViewportSize_1 = __importDefault(require("./hooks/useViewportSize"));
46
+ var asStyleDict_1 = __importDefault(require("./utils/asStyleDict"));
47
+ var styles_1 = __importDefault(require("./utils/styles"));
77
48
  function WithTooltip(_a) {
78
- var _b = _a.arrowHeight, arrowHeight = _b === void 0 ? 8 : _b, _c = _a.backgroundColor, backgroundColor = _c === void 0 ? '#000' : _c, cssDialog = _a.cssDialog, _d = _a.disabledOnTouch, disabledOnTouch = _d === void 0 ? true : _d, hint = _a.hint, _e = _a.gap, gap = _e === void 0 ? 5 : _e, _f = _a.textColor, textColor = _f === void 0 ? '#fff' : _f, _g = _a.threshold, threshold = _g === void 0 ? 100 : _g, props = __rest(_a, ["arrowHeight", "backgroundColor", "cssDialog", "disabledOnTouch", "hint", "gap", "textColor", "threshold"]);
79
- var computeAlignment = function (target, threshold) {
49
+ var children = _a.children, className = _a.className, style = _a.style, _b = _a.arrowHeight, arrowHeight = _b === void 0 ? 8 : _b, _c = _a.backgroundColor, backgroundColor = _c === void 0 ? '#000' : _c, _d = _a.gap, gap = _d === void 0 ? 5 : _d, hint = _a.hint, _e = _a.maxTextWidth, maxTextWidth = _e === void 0 ? 200 : _e, _f = _a.threshold, threshold = _f === void 0 ? 100 : _f;
50
+ var createDialog = function () {
51
+ var dialog = document.createElement('div');
52
+ dialog.className = (0, classnames_1.default)(className);
53
+ Object.keys((0, styles_1.default)(style, fixedStyles.dialog)).forEach(function (rule) { return dialog.style[rule] = fixedStyles.dialog[rule]; });
54
+ var arrow = document.createElement('div');
55
+ Object.keys(fixedStyles.arrow).forEach(function (rule) { return arrow.style[rule] = fixedStyles.arrow[rule]; });
56
+ var content = document.createElement('div');
57
+ content.innerText = hint;
58
+ Object.keys(fixedStyles.content).forEach(function (rule) { return content.style[rule] = fixedStyles.content[rule]; });
59
+ dialog.appendChild(arrow);
60
+ dialog.appendChild(content);
61
+ return dialog;
62
+ };
63
+ var computeAlignment = function () {
64
+ if (!rootRef.current)
65
+ return 'bc';
80
66
  var vrect = spase_1.Rect.fromViewport();
81
- var rect = spase_1.Rect.intersecting(target);
82
- if (rect) {
83
- var leftBound = (rect.left - vrect.left) < threshold;
84
- var rightBound = (vrect.right - rect.right) < threshold;
85
- var topBound = (rect.top - vrect.top) < threshold;
86
- var bottomBound = (vrect.bottom - rect.bottom) < threshold;
67
+ var irect = spase_1.Rect.intersecting(rootRef.current);
68
+ if (irect) {
69
+ var leftBound = irect.left - vrect.left < threshold;
70
+ var rightBound = vrect.right - irect.right < threshold;
71
+ var topBound = irect.top - vrect.top < threshold;
72
+ var bottomBound = vrect.bottom - irect.bottom < threshold;
87
73
  if (leftBound && topBound)
88
74
  return 'br';
89
75
  if (leftBound && bottomBound)
@@ -101,10 +87,12 @@ function WithTooltip(_a) {
101
87
  }
102
88
  return 'bc';
103
89
  };
104
- var computeTextSize = function (target, threshold) {
105
- var computedStyle = window.getComputedStyle(target, '::after');
90
+ var computeTextSize = function () {
91
+ if (!dialogRef.current)
92
+ return new spase_1.Size();
93
+ var computedStyle = window.getComputedStyle(dialogRef.current);
106
94
  var div = document.createElement('div');
107
- div.innerHTML = hint;
95
+ div.innerText = hint;
108
96
  div.style.fontFamily = computedStyle.getPropertyValue('font-family');
109
97
  div.style.fontSize = computedStyle.getPropertyValue('font-size');
110
98
  div.style.fontStyle = computedStyle.getPropertyValue('font-style');
@@ -122,74 +110,152 @@ function WithTooltip(_a) {
122
110
  document.body.removeChild(div);
123
111
  return new spase_1.Size([width, height]);
124
112
  };
125
- var onMouseOver = function (event) {
126
- setAlignment(computeAlignment(event.currentTarget, threshold));
127
- setTextSize(computeTextSize(event.currentTarget, threshold));
113
+ var mouseEnterHandler = function (event) {
114
+ if (!dialogRef.current)
115
+ return;
116
+ dialogRef.current.style.opacity = '1';
117
+ };
118
+ var mouseLeaveHandler = function (event) {
119
+ if (!dialogRef.current)
120
+ return;
121
+ dialogRef.current.style.opacity = '0';
128
122
  };
129
- var _h = __read((0, react_1.useState)(new spase_1.Size()), 2), textSize = _h[0], setTextSize = _h[1];
130
- var _j = __read((0, react_1.useState)(undefined), 2), alignment = _j[0], setAlignment = _j[1];
131
- var childRef = (0, react_1.useRef)(null);
132
- var childRect = (0, useElementRect_1.default)(childRef);
123
+ var rootRef = (0, react_1.useRef)(null);
124
+ var dialogRef = (0, react_1.useRef)();
125
+ var rect = (0, useElementRect_1.default)(rootRef);
133
126
  var viewportSize = (0, useViewportSize_1.default)();
127
+ var alignment = computeAlignment();
128
+ var textSize = computeTextSize();
134
129
  (0, react_1.useEffect)(function () {
135
- var childNode = childRef.current;
136
- if (!childNode)
137
- return;
138
- setAlignment(computeAlignment(childNode, threshold));
139
- setTextSize(computeTextSize(childNode, threshold));
140
- }, [childRect, viewportSize]);
141
- return (react_1.default.createElement(StyledRoot, __assign({ arrowHeight: arrowHeight, backgroundColor: backgroundColor, ref: childRef, cssDialog: cssDialog, disabledOnTouch: disabledOnTouch, hint: hint, gap: gap, onMouseOver: function (event) { return onMouseOver(event); }, alignment: alignment, textColor: textColor, textSize: textSize }, props)));
130
+ var _a;
131
+ var dialogNode = createDialog();
132
+ (_a = rootRef.current) === null || _a === void 0 ? void 0 : _a.appendChild(dialogNode);
133
+ dialogRef.current = dialogNode;
134
+ return function () {
135
+ var _a;
136
+ (_a = rootRef.current) === null || _a === void 0 ? void 0 : _a.removeChild(dialogNode);
137
+ };
138
+ }, [rect, viewportSize]);
139
+ var fixedStyles = (0, asStyleDict_1.default)({
140
+ dialog: {
141
+ background: 'none',
142
+ boxSizing: 'border-box',
143
+ height: "".concat(rect.size.height, "px"),
144
+ left: '0',
145
+ margin: '0',
146
+ opacity: '0',
147
+ position: 'absolute',
148
+ top: '0',
149
+ width: "".concat(rect.size.width, "px"),
150
+ zIndex: '10000',
151
+ },
152
+ arrow: __assign(__assign({ borderStyle: 'solid', borderWidth: "".concat(arrowHeight, "px"), height: '0', pointerEvents: 'none', position: 'absolute', width: '0' }, makeDisplacementStyle(alignment, arrowHeight, gap)), makeArrowPositionStyle(alignment, arrowHeight, gap, backgroundColor)),
153
+ content: __assign(__assign({ background: backgroundColor, boxSizing: 'content-box', color: 'inherit', fontFamily: 'inherit', fontSize: 'inherit', fontWeight: 'inherit', letterSpacing: 'inherit', lineHeight: 'inherit', maxWidth: "".concat(maxTextWidth, "px"), overflow: 'hidden', padding: 'inherit', pointerEvents: 'none', position: 'absolute', textAlign: 'inherit', transition: 'inherit', width: textSize.width > 0 ? "".concat(textSize.width, "px") : 'auto' }, makeDisplacementStyle(alignment, arrowHeight, gap)), makeContentPositionStyle(alignment, arrowHeight, gap)),
154
+ });
155
+ return (react_1.default.createElement(ExtractChild_1.default, { children: children, ref: rootRef, onMouseEnter: mouseEnterHandler, onMouseLeave: mouseLeaveHandler }));
142
156
  }
143
157
  exports.default = WithTooltip;
144
- function makeDisplacementCSS(alignment, arrowHeight, gap) {
158
+ function makeDisplacementStyle(alignment, arrowHeight, gap) {
145
159
  switch (alignment) {
146
- case 'tl': return (0, styled_components_1.css)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["top: ", "px; left: calc(50% + ", "px);"], ["top: ", "px; left: calc(50% + ", "px);"])), -arrowHeight, arrowHeight * 2.5);
147
- case 'tc': return (0, styled_components_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["top: ", "px; left: 50%;"], ["top: ", "px; left: 50%;"])), -arrowHeight);
148
- case 'tr': return (0, styled_components_1.css)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["top: ", "px; right: calc(50% + ", "px);"], ["top: ", "px; right: calc(50% + ", "px);"])), -arrowHeight, arrowHeight * 2.5);
149
- case 'cl': return (0, styled_components_1.css)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["top: 50%; left: ", "px;"], ["top: 50%; left: ", "px;"])), -arrowHeight);
150
- case 'cr': return (0, styled_components_1.css)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["top: 50%; right: ", "px;"], ["top: 50%; right: ", "px;"])), -arrowHeight);
151
- case 'bl': return (0, styled_components_1.css)(templateObject_6 || (templateObject_6 = __makeTemplateObject(["bottom: ", "px; left: calc(50% + ", "px);"], ["bottom: ", "px; left: calc(50% + ", "px);"])), -arrowHeight, arrowHeight * 2.5);
152
- case 'bc': return (0, styled_components_1.css)(templateObject_7 || (templateObject_7 = __makeTemplateObject(["bottom: ", "px; left: 50%;"], ["bottom: ", "px; left: 50%;"])), -arrowHeight);
153
- case 'br': return (0, styled_components_1.css)(templateObject_8 || (templateObject_8 = __makeTemplateObject(["bottom: ", "px; right: calc(50% + ", "px);"], ["bottom: ", "px; right: calc(50% + ", "px);"])), -arrowHeight, arrowHeight * 2.5);
160
+ case 'tl': return {
161
+ top: "".concat(-arrowHeight, "px"),
162
+ left: "calc(50% + ".concat(arrowHeight * 2.5, "px)"),
163
+ };
164
+ case 'tc': return {
165
+ top: "".concat(-arrowHeight, "px"),
166
+ left: '50%',
167
+ };
168
+ case 'tr': return {
169
+ top: "".concat(-arrowHeight, "px"),
170
+ right: "calc(50% + ".concat(arrowHeight * 2.5, "px)"),
171
+ };
172
+ case 'cl': return {
173
+ top: '50%',
174
+ left: "".concat(-arrowHeight, "px"),
175
+ };
176
+ case 'cr': return {
177
+ top: '50%',
178
+ right: "".concat(-arrowHeight, "px"),
179
+ };
180
+ case 'bl': return {
181
+ bottom: "".concat(-arrowHeight, "px"),
182
+ left: "calc(50% + ".concat(arrowHeight * 2.5, "px)"),
183
+ };
184
+ case 'bc': return {
185
+ bottom: "".concat(-arrowHeight, "px"),
186
+ left: '50%',
187
+ };
188
+ case 'br': return {
189
+ bottom: "".concat(-arrowHeight, "px"),
190
+ right: "calc(50% + ".concat(arrowHeight * 2.5, "px)"),
191
+ };
192
+ default: return {};
154
193
  }
155
194
  }
156
- function makeDialogPositionCSS(alignment, arrowHeight, gap) {
195
+ function makeContentPositionStyle(alignment, arrowHeight, gap) {
157
196
  switch (alignment) {
158
- case 'tl': return (0, styled_components_1.css)(templateObject_9 || (templateObject_9 = __makeTemplateObject(["transform: translate3d(calc(-100% - ", "px), calc(-100% - ", "px), 0);"], ["transform: translate3d(calc(-100% - ", "px), calc(-100% - ", "px), 0);"])), gap, gap);
159
- case 'tc': return (0, styled_components_1.css)(templateObject_10 || (templateObject_10 = __makeTemplateObject(["transform: translate3d(-50%, calc(-100% - ", "px), 0);"], ["transform: translate3d(-50%, calc(-100% - ", "px), 0);"])), gap);
160
- case 'tr': return (0, styled_components_1.css)(templateObject_11 || (templateObject_11 = __makeTemplateObject(["transform: translate3d(calc(100% + ", "px), calc(-100% - ", "px), 0);"], ["transform: translate3d(calc(100% + ", "px), calc(-100% - ", "px), 0);"])), gap, gap);
161
- case 'cl': return (0, styled_components_1.css)(templateObject_12 || (templateObject_12 = __makeTemplateObject(["transform: translate3d(calc(-100% - ", "px), -50%, 0);"], ["transform: translate3d(calc(-100% - ", "px), -50%, 0);"])), gap);
162
- case 'cr': return (0, styled_components_1.css)(templateObject_13 || (templateObject_13 = __makeTemplateObject(["transform: translate3d(calc(100% + ", "px), -50%, 0);"], ["transform: translate3d(calc(100% + ", "px), -50%, 0);"])), gap);
163
- case 'bl': return (0, styled_components_1.css)(templateObject_14 || (templateObject_14 = __makeTemplateObject(["transform: translate3d(calc(-100% - ", "px), calc(100% + ", "px), 0);"], ["transform: translate3d(calc(-100% - ", "px), calc(100% + ", "px), 0);"])), gap, gap);
164
- case 'bc': return (0, styled_components_1.css)(templateObject_15 || (templateObject_15 = __makeTemplateObject(["transform: translate3d(-50%, calc(100% + ", "px), 0);"], ["transform: translate3d(-50%, calc(100% + ", "px), 0);"])), gap);
165
- case 'br': return (0, styled_components_1.css)(templateObject_16 || (templateObject_16 = __makeTemplateObject(["transform: translate3d(calc(100% + ", "px), calc(100% + ", "px), 0);"], ["transform: translate3d(calc(100% + ", "px), calc(100% + ", "px), 0);"])), gap, gap);
197
+ case 'tl': return {
198
+ transform: "translate3d(calc(-100% - ".concat(gap, "px), calc(-100% - ").concat(gap, "px), 0)"),
199
+ };
200
+ case 'tc': return {
201
+ transform: "translate3d(-50%, calc(-100% - ".concat(gap, "px), 0)"),
202
+ };
203
+ case 'tr': return {
204
+ transform: "translate3d(calc(100% + ".concat(gap, "px), calc(-100% - ").concat(gap, "px), 0)"),
205
+ };
206
+ case 'cl': return {
207
+ transform: "translate3d(calc(-100% - ".concat(gap, "px), -50%, 0)"),
208
+ };
209
+ case 'cr': return {
210
+ transform: "translate3d(calc(100% + ".concat(gap, "px), -50%, 0)"),
211
+ };
212
+ case 'bl': return {
213
+ transform: "translate3d(calc(-100% - ".concat(gap, "px), calc(100% + ").concat(gap, "px), 0)"),
214
+ };
215
+ case 'bc': return {
216
+ transform: "translate3d(-50%, calc(100% + ".concat(gap, "px), 0)"),
217
+ };
218
+ case 'br': return {
219
+ transform: "translate3d(calc(100% + ".concat(gap, "px), calc(100% + ").concat(gap, "px), 0)"),
220
+ };
221
+ default: return {};
166
222
  }
167
223
  }
168
- function makeArrowPositionCSS(alignment, arrowHeight, gap, color) {
169
- return (0, styled_components_1.css)(templateObject_33 || (templateObject_33 = __makeTemplateObject(["\n ", "\n\n ", "\n "], ["\n ", "\n\n ", "\n "])), function () {
170
- switch (alignment) {
171
- case 'tl': return (0, styled_components_1.css)(templateObject_17 || (templateObject_17 = __makeTemplateObject(["border-color: ", " transparent transparent transparent;"], ["border-color: ", " transparent transparent transparent;"])), color);
172
- case 'tc': return (0, styled_components_1.css)(templateObject_18 || (templateObject_18 = __makeTemplateObject(["border-color: ", " transparent transparent transparent;"], ["border-color: ", " transparent transparent transparent;"])), color);
173
- case 'tr': return (0, styled_components_1.css)(templateObject_19 || (templateObject_19 = __makeTemplateObject(["border-color: ", " transparent transparent transparent;"], ["border-color: ", " transparent transparent transparent;"])), color);
174
- case 'cl': return (0, styled_components_1.css)(templateObject_20 || (templateObject_20 = __makeTemplateObject(["border-color: transparent transparent transparent ", ";"], ["border-color: transparent transparent transparent ", ";"])), color);
175
- case 'cr': return (0, styled_components_1.css)(templateObject_21 || (templateObject_21 = __makeTemplateObject(["border-color: transparent ", " transparent transparent;"], ["border-color: transparent ", " transparent transparent;"])), color);
176
- case 'bl': return (0, styled_components_1.css)(templateObject_22 || (templateObject_22 = __makeTemplateObject(["border-color: transparent transparent ", " transparent;"], ["border-color: transparent transparent ", " transparent;"])), color);
177
- case 'bc': return (0, styled_components_1.css)(templateObject_23 || (templateObject_23 = __makeTemplateObject(["border-color: transparent transparent ", " transparent;"], ["border-color: transparent transparent ", " transparent;"])), color);
178
- case 'br': return (0, styled_components_1.css)(templateObject_24 || (templateObject_24 = __makeTemplateObject(["border-color: transparent transparent ", " transparent;"], ["border-color: transparent transparent ", " transparent;"])), color);
179
- }
180
- }, function () {
181
- switch (alignment) {
182
- case 'tl': return (0, styled_components_1.css)(templateObject_25 || (templateObject_25 = __makeTemplateObject(["transform: translate3d(calc(0% - ", "px - ", "px), calc(0% - ", "px), 0);"], ["transform: translate3d(calc(0% - ", "px - ", "px), calc(0% - ", "px), 0);"])), gap, arrowHeight * 3, gap);
183
- case 'tc': return (0, styled_components_1.css)(templateObject_26 || (templateObject_26 = __makeTemplateObject(["transform: translate3d(-50%, calc(0% - ", "px), 0);"], ["transform: translate3d(-50%, calc(0% - ", "px), 0);"])), gap);
184
- case 'tr': return (0, styled_components_1.css)(templateObject_27 || (templateObject_27 = __makeTemplateObject(["transform: translate3d(calc(100% + ", "px + ", "px), calc(0% - ", "px), 0);"], ["transform: translate3d(calc(100% + ", "px + ", "px), calc(0% - ", "px), 0);"])), gap, arrowHeight, gap);
185
- case 'cl': return (0, styled_components_1.css)(templateObject_28 || (templateObject_28 = __makeTemplateObject(["transform: translate3d(calc(0% - ", "px), -50%, 0);"], ["transform: translate3d(calc(0% - ", "px), -50%, 0);"])), gap);
186
- case 'cr': return (0, styled_components_1.css)(templateObject_29 || (templateObject_29 = __makeTemplateObject(["transform: translate3d(calc(0% + ", "px), -50%, 0);"], ["transform: translate3d(calc(0% + ", "px), -50%, 0);"])), gap);
187
- case 'bl': return (0, styled_components_1.css)(templateObject_30 || (templateObject_30 = __makeTemplateObject(["transform: translate3d(calc(0% - ", "px - ", "px), calc(0% + ", "px), 0);"], ["transform: translate3d(calc(0% - ", "px - ", "px), calc(0% + ", "px), 0);"])), gap, arrowHeight * 3, gap);
188
- case 'bc': return (0, styled_components_1.css)(templateObject_31 || (templateObject_31 = __makeTemplateObject(["transform: translate3d(-50%, calc(0% + ", "px), 0);"], ["transform: translate3d(-50%, calc(0% + ", "px), 0);"])), gap);
189
- case 'br': return (0, styled_components_1.css)(templateObject_32 || (templateObject_32 = __makeTemplateObject(["transform: translate3d(calc(100% + ", "px + ", "px), calc(0% + ", "px), 0);"], ["transform: translate3d(calc(100% + ", "px + ", "px), calc(0% + ", "px), 0);"])), gap, arrowHeight, gap);
190
- }
191
- });
224
+ function makeArrowPositionStyle(alignment, arrowHeight, gap, color) {
225
+ switch (alignment) {
226
+ case 'tl': return {
227
+ borderColor: "".concat(color, " transparent transparent transparent"),
228
+ transform: "translate3d(calc(0% - ".concat(gap, "px - ").concat(arrowHeight * 3, "px), calc(0% - ").concat(gap, "px), 0)"),
229
+ };
230
+ case 'tc': return {
231
+ borderColor: "".concat(color, " transparent transparent transparent"),
232
+ transform: "translate3d(-50%, calc(0% - ".concat(gap, "px), 0)"),
233
+ };
234
+ case 'tr': return {
235
+ borderColor: "".concat(color, " transparent transparent transparent"),
236
+ transform: "translate3d(calc(100% + ".concat(gap, "px + ").concat(arrowHeight, "px), calc(0% - ").concat(gap, "px), 0)"),
237
+ };
238
+ case 'cl': return {
239
+ borderColor: "transparent transparent transparent ".concat(color),
240
+ transform: "translate3d(calc(0% - ".concat(gap, "px), -50%, 0)"),
241
+ };
242
+ case 'cr': return {
243
+ borderColor: "transparent ".concat(color, " transparent transparent"),
244
+ transform: "translate3d(calc(0% + ".concat(gap, "px), -50%, 0)"),
245
+ };
246
+ case 'bl': return {
247
+ borderColor: "transparent transparent ".concat(color, " transparent"),
248
+ transform: "translate3d(calc(0% - ".concat(gap, "px - ").concat(arrowHeight * 3, "px), calc(0% + ").concat(gap, "px), 0)"),
249
+ };
250
+ case 'bc': return {
251
+ borderColor: "transparent transparent ".concat(color, " transparent"),
252
+ transform: "translate3d(-50%, calc(0% + ".concat(gap, "px), 0)"),
253
+ };
254
+ case 'br': return {
255
+ borderColor: "transparent transparent ".concat(color, " transparent"),
256
+ transform: "translate3d(calc(100% + ".concat(gap, "px + ").concat(arrowHeight, "px), calc(0% + ").concat(gap, "px), 0)"),
257
+ };
258
+ default: return {};
259
+ }
192
260
  }
193
- var StyledRoot = (0, styled_components_1.default)(ExtractChild_1.default)(templateObject_36 || (templateObject_36 = __makeTemplateObject(["\n cursor: pointer;\n position: relative;\n\n &::before {\n border-style: solid;\n border-width: ", "px;\n content: '';\n height: 0;\n opacity: 0;\n pointer-events: none;\n position: absolute;\n transition: opacity 200ms ease-out;\n width: 0;\n z-index: 10001;\n\n ", "\n }\n\n &::after {\n box-sizing: content-box;\n font-size: 12px;\n max-width: 200px;\n padding: 10px 14px;\n text-align: left;\n\n ", "\n\n background: ", ";\n color: ", ";\n content: '", "';\n opacity: 0;\n overflow: hidden;\n pointer-events: none;\n position: absolute;\n transform: translate3d(0, 0, 0);\n transition: opacity 200ms ease-out;\n z-index: 10000;\n\n ", "\n }\n\n ", " {\n &::before { opacity: 1; }\n &::after { opacity: 1; }\n }\n"], ["\n cursor: pointer;\n position: relative;\n\n &::before {\n border-style: solid;\n border-width: ", "px;\n content: '';\n height: 0;\n opacity: 0;\n pointer-events: none;\n position: absolute;\n transition: opacity 200ms ease-out;\n width: 0;\n z-index: 10001;\n\n ", "\n }\n\n &::after {\n box-sizing: content-box;\n font-size: 12px;\n max-width: 200px;\n padding: 10px 14px;\n text-align: left;\n\n ", "\n\n background: ", ";\n color: ", ";\n content: '", "';\n opacity: 0;\n overflow: hidden;\n pointer-events: none;\n position: absolute;\n transform: translate3d(0, 0, 0);\n transition: opacity 200ms ease-out;\n z-index: 10000;\n\n ", "\n }\n\n ", " {\n &::before { opacity: 1; }\n &::after { opacity: 1; }\n }\n"])), function (props) { return props.arrowHeight; }, function (props) { return props.alignment && props.textSize && (0, styled_components_1.css)(templateObject_34 || (templateObject_34 = __makeTemplateObject(["\n ", "\n ", "\n ", "\n "], ["\n ", "\n ", "\n ", "\n "])), makeDisplacementCSS(props.alignment, props.arrowHeight, props.gap), makeArrowPositionCSS(props.alignment, props.arrowHeight, props.gap, props.backgroundColor), props.disabledOnTouch ? 'html.touch & { display: none; }' : ''); }, function (props) { return props.cssDialog; }, function (props) { return props.backgroundColor; }, function (props) { return props.textColor; }, function (props) { return props.hint; }, function (props) { return props.alignment && props.textSize && (0, styled_components_1.css)(templateObject_35 || (templateObject_35 = __makeTemplateObject(["\n width: ", ";\n ", "\n ", "\n ", "\n "], ["\n width: ", ";\n ", "\n ", "\n ", "\n "])), props.textSize.width > 0 ? "".concat(props.textSize.width, "px") : 'auto', makeDisplacementCSS(props.alignment, props.arrowHeight, props.gap), makeDialogPositionCSS(props.alignment, props.arrowHeight, props.gap), props.disabledOnTouch ? 'html.touch & { display: none; }' : ''); }, function (props) { return props.disabledOnTouch ? 'html:not(.touch) &:hover' : '&:hover'; });
194
- var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12, templateObject_13, templateObject_14, templateObject_15, templateObject_16, templateObject_17, templateObject_18, templateObject_19, templateObject_20, templateObject_21, templateObject_22, templateObject_23, templateObject_24, templateObject_25, templateObject_26, templateObject_27, templateObject_28, templateObject_29, templateObject_30, templateObject_31, templateObject_32, templateObject_33, templateObject_34, templateObject_35, templateObject_36;
195
261
  //# sourceMappingURL=WithTooltip.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"WithTooltip.js","sourceRoot":"/","sources":["WithTooltip.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAiG;AACjG,+BAAkC;AAClC,qEAAwD;AACxD,gEAAyC;AACzC,0EAAmD;AACnD,4EA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,IAAI,OAAA,KAAK,CAAC,SAAS,EAAf,CAAe,EAEZ,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,eAAe,EAArB,CAAqB,EACnC,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,SAAS,EAAf,CAAe,EACrB,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,IAAI,EAAV,CAAU,EAS7B,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,SAAS,IAAI,KAAK,CAAC,QAAQ,QAAI,uBAAG,sIAAA,iBACxC,EAA+D,WACtE,EAAkE,UAClE,EAAoE,UACpE,EAA8D,QACjE,KAJU,KAAK,CAAC,QAAQ,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,UAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,OAAI,CAAC,CAAC,CAAC,MAAM,EACtE,mBAAmB,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,GAAG,CAAC,EAClE,qBAAqB,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,GAAG,CAAC,EACpE,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,iCAAiC,CAAC,CAAC,CAAC,EAAE,CACjE,EALU,CAKV,EAGD,UAAA,KAAK,IAAI,OAAA,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,0BAA0B,CAAC,CAAC,CAAC,SAAS,EAA9D,CAA8D,CAI1E,CAAA","sourcesContent":["import React, { HTMLAttributes, MouseEvent, RefObject, useEffect, useRef, useState } from 'react'\nimport { Rect, Size } from 'spase'\nimport styled, { css, CSSProp } from 'styled-components'\nimport ExtractChild from './ExtractChild'\nimport useElementRect from './hooks/useElementRect'\nimport useViewportSize from './hooks/useViewportSize'\n\nexport type Props = HTMLAttributes<HTMLElement> & {\n /**\n * The height of the arrow. The width (longest edge) of the arrow is always twice its height.\n */\n arrowHeight?: number\n\n /**\n * Color of the dialog background, same format as a CSS color string (i.e. '#000').\n */\n backgroundColor?: string\n\n /**\n * Specifies if the tooltip should be disabled in touch devices (i.e. `html` has class `.touch`).\n */\n disabledOnTouch?: boolean\n\n /**\n * The hint string to display in the tooltip.\n */\n hint: string\n\n /**\n * The gap (in pixels) between the target element and the tooltip, defaults to zero.\n */\n gap?: number\n\n /**\n * Color of the dialog text, same format as a CSS color string (i.e. '#000').\n */\n textColor?: string\n\n /**\n * The minimum space (in pixels) between the target element and the edge of the window required to\n * trigger an alignment change, defaults to `100px`.\n */\n threshold?: number\n\n /**\n * Custom CSS provided to the dialog. Not all CSS rules will take effect as they will be\n * overridden by internal rules.\n */\n cssDialog?: CSSProp<any>\n}\n\ntype Alignment = 'tl' | 'tc' | 'tr' | 'cl' | 'cr' | 'bl' | 'bc' | 'br'\n\nexport default function WithTooltip({\n arrowHeight = 8,\n backgroundColor = '#000',\n cssDialog,\n disabledOnTouch = true,\n hint,\n gap = 5,\n textColor = '#fff',\n threshold = 100,\n ...props\n}: Props) {\n const computeAlignment = (target: Element, threshold: number): Alignment => {\n const vrect = Rect.fromViewport()\n const rect = Rect.intersecting(target)\n\n if (rect) {\n const leftBound = (rect.left - vrect.left) < threshold\n const rightBound = (vrect.right - rect.right) < threshold\n const topBound = (rect.top - vrect.top) < threshold\n const bottomBound = (vrect.bottom - rect.bottom) < threshold\n\n if (leftBound && topBound) return 'br'\n if (leftBound && bottomBound) return 'tr'\n if (rightBound && topBound) return 'bl'\n if (rightBound && bottomBound) return 'tl'\n if (leftBound) return 'cr'\n if (rightBound) return 'cl'\n if (bottomBound) return 'tc'\n }\n\n return 'bc'\n }\n\n const computeTextSize = (target: Element, threshold: number): Size => {\n const computedStyle = window.getComputedStyle(target, '::after')\n const div = document.createElement('div')\n div.innerHTML = hint\n div.style.fontFamily = computedStyle.getPropertyValue('font-family')\n div.style.fontSize = computedStyle.getPropertyValue('font-size')\n div.style.fontStyle = computedStyle.getPropertyValue('font-style')\n div.style.fontVariant = computedStyle.getPropertyValue('font-variant')\n div.style.fontWeight = computedStyle.getPropertyValue('font-weight')\n div.style.left = '0'\n div.style.position = 'absolute'\n div.style.top = '0'\n div.style.visibility = 'hidden'\n div.style.whiteSpace = 'pre'\n\n document.body.appendChild(div)\n\n // Add 1px as buffer to mitigate precision discrepancies.\n const width = div.clientWidth + 1\n const height = div.clientHeight + 1\n\n document.body.removeChild(div)\n\n return new Size([width, height])\n }\n\n const onMouseOver = (event: MouseEvent) => {\n setAlignment(computeAlignment(event.currentTarget, threshold))\n setTextSize(computeTextSize(event.currentTarget, threshold))\n }\n\n const [textSize, setTextSize] = useState<Size | undefined>(new Size())\n const [alignment, setAlignment] = useState<Alignment | undefined>(undefined)\n const childRef = useRef<HTMLElement>(null)\n const childRect = useElementRect(childRef)\n const viewportSize = useViewportSize()\n\n useEffect(() => {\n const childNode = childRef.current\n if (!childNode) return\n setAlignment(computeAlignment(childNode, threshold))\n setTextSize(computeTextSize(childNode, threshold))\n }, [childRect, viewportSize])\n\n return (\n <StyledRoot\n arrowHeight={arrowHeight}\n backgroundColor={backgroundColor}\n ref={childRef}\n cssDialog={cssDialog}\n disabledOnTouch={disabledOnTouch}\n hint={hint}\n gap={gap}\n onMouseOver={event => onMouseOver(event)}\n alignment={alignment}\n textColor={textColor}\n textSize={textSize}\n {...props}\n />\n )\n}\n\nfunction makeDisplacementCSS(alignment: Alignment, arrowHeight: number, gap: number): CSSProp {\n switch (alignment) {\n case 'tl': return css`top: ${-arrowHeight}px; left: calc(50% + ${arrowHeight*2.5}px);`\n case 'tc': return css`top: ${-arrowHeight}px; left: 50%;`\n case 'tr': return css`top: ${-arrowHeight}px; right: calc(50% + ${arrowHeight*2.5}px);`\n case 'cl': return css`top: 50%; left: ${-arrowHeight}px;`\n case 'cr': return css`top: 50%; right: ${-arrowHeight}px;`\n case 'bl': return css`bottom: ${-arrowHeight}px; left: calc(50% + ${arrowHeight*2.5}px);`\n case 'bc': return css`bottom: ${-arrowHeight}px; left: 50%;`\n case 'br': return css`bottom: ${-arrowHeight}px; right: calc(50% + ${arrowHeight*2.5}px);`\n }\n}\n\nfunction makeDialogPositionCSS(alignment: Alignment, arrowHeight: number, gap: number): CSSProp {\n switch (alignment) {\n case 'tl': return css`transform: translate3d(calc(-100% - ${gap}px), calc(-100% - ${gap}px), 0);`\n case 'tc': return css`transform: translate3d(-50%, calc(-100% - ${gap}px), 0);`\n case 'tr': return css`transform: translate3d(calc(100% + ${gap}px), calc(-100% - ${gap}px), 0);`\n case 'cl': return css`transform: translate3d(calc(-100% - ${gap}px), -50%, 0);`\n case 'cr': return css`transform: translate3d(calc(100% + ${gap}px), -50%, 0);`\n case 'bl': return css`transform: translate3d(calc(-100% - ${gap}px), calc(100% + ${gap}px), 0);`\n case 'bc': return css`transform: translate3d(-50%, calc(100% + ${gap}px), 0);`\n case 'br': return css`transform: translate3d(calc(100% + ${gap}px), calc(100% + ${gap}px), 0);`\n }\n}\n\nfunction makeArrowPositionCSS(alignment: Alignment, arrowHeight: number, gap: number, color: string): CSSProp {\n return css`\n ${() => {\n switch (alignment) {\n case 'tl': return css`border-color: ${color} transparent transparent transparent;`\n case 'tc': return css`border-color: ${color} transparent transparent transparent;`\n case 'tr': return css`border-color: ${color} transparent transparent transparent;`\n case 'cl': return css`border-color: transparent transparent transparent ${color};`\n case 'cr': return css`border-color: transparent ${color} transparent transparent;`\n case 'bl': return css`border-color: transparent transparent ${color} transparent;`\n case 'bc': return css`border-color: transparent transparent ${color} transparent;`\n case 'br': return css`border-color: transparent transparent ${color} transparent;`\n }\n }}\n\n ${() => {\n switch (alignment) {\n case 'tl': return css`transform: translate3d(calc(0% - ${gap}px - ${arrowHeight*3}px), calc(0% - ${gap}px), 0);`\n case 'tc': return css`transform: translate3d(-50%, calc(0% - ${gap}px), 0);`\n case 'tr': return css`transform: translate3d(calc(100% + ${gap}px + ${arrowHeight}px), calc(0% - ${gap}px), 0);`\n case 'cl': return css`transform: translate3d(calc(0% - ${gap}px), -50%, 0);`\n case 'cr': return css`transform: translate3d(calc(0% + ${gap}px), -50%, 0);`\n case 'bl': return css`transform: translate3d(calc(0% - ${gap}px - ${arrowHeight*3}px), calc(0% + ${gap}px), 0);`\n case 'bc': return css`transform: translate3d(-50%, calc(0% + ${gap}px), 0);`\n case 'br': return css`transform: translate3d(calc(100% + ${gap}px + ${arrowHeight}px), calc(0% + ${gap}px), 0);`\n }\n }}\n `\n}\n\nconst StyledRoot = styled(ExtractChild)<{\n arrowHeight: number\n backgroundColor: string\n ref: RefObject<HTMLElement>\n cssDialog?: CSSProp\n disabledOnTouch: boolean\n hint: string\n gap: number\n alignment?: Alignment\n textColor: string\n textSize?: Size\n}>`\n cursor: pointer;\n position: relative;\n\n &::before {\n border-style: solid;\n border-width: ${props => props.arrowHeight}px;\n content: '';\n height: 0;\n opacity: 0;\n pointer-events: none;\n position: absolute;\n transition: opacity 200ms ease-out;\n width: 0;\n z-index: 10001;\n\n ${props => props.alignment && props.textSize && css`\n ${makeDisplacementCSS(props.alignment, props.arrowHeight, props.gap)}\n ${makeArrowPositionCSS(props.alignment, props.arrowHeight, props.gap, props.backgroundColor)}\n ${props.disabledOnTouch ? 'html.touch & { display: none; }' : ''}\n `}\n }\n\n &::after {\n box-sizing: content-box;\n font-size: 12px;\n max-width: 200px;\n padding: 10px 14px;\n text-align: left;\n\n ${props => props.cssDialog}\n\n background: ${props => props.backgroundColor};\n color: ${props => props.textColor};\n content: '${props => props.hint}';\n opacity: 0;\n overflow: hidden;\n pointer-events: none;\n position: absolute;\n transform: translate3d(0, 0, 0);\n transition: opacity 200ms ease-out;\n z-index: 10000;\n\n ${props => props.alignment && props.textSize && css`\n width: ${props.textSize.width > 0 ? `${props.textSize.width}px` : 'auto'};\n ${makeDisplacementCSS(props.alignment, props.arrowHeight, props.gap)}\n ${makeDialogPositionCSS(props.alignment, props.arrowHeight, props.gap)}\n ${props.disabledOnTouch ? 'html.touch & { display: none; }' : ''}\n `}\n }\n\n ${props => props.disabledOnTouch ? 'html:not(.touch) &:hover' : '&:hover'}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F,CAAA;QACD,OAAO,CAAC,CAAC,OAAO,EAEf,CAAA;KACF;AACH,CAAC","sourcesContent":["import classNames from 'classnames'\nimport React, { CSSProperties, HTMLAttributes, MouseEvent, PropsWithChildren, useEffect, useRef } from 'react'\nimport { Rect, Size } from 'spase'\nimport ExtractChild from './ExtractChild'\nimport useElementRect from './hooks/useElementRect'\nimport useViewportSize from './hooks/useViewportSize'\nimport asStyleDict from './utils/asStyleDict'\nimport styles from './utils/styles'\n\ntype Alignment = 'tl' | 'tc' | 'tr' | 'cl' | 'cr' | 'bl' | 'bc' | 'br'\n\nexport type WithToolTipProps = Pick<HTMLAttributes<HTMLElement>, 'className' | 'style'> & PropsWithChildren<{\n /**\n * The height of the arrow. The width (longest edge) of the arrow is always\n * twice its height.\n */\n arrowHeight?: number\n\n /**\n * Color of the dialog background, same format as a CSS color string (i.e.\n * '#000').\n */\n backgroundColor?: string\n\n /**\n * Specifies if the tooltip should be disabled in touch devices (i.e. `html`\n * has class `.touch`).\n */\n disabledOnTouch?: boolean\n\n /**\n * The hint string to display in the tooltip.\n */\n hint: string\n\n /**\n * The gap (in pixels) between the target element and the tooltip, defaults to\n * zero.\n */\n gap?: number\n\n /**\n * The maximum width (in pixels) of the hint text.\n */\n maxTextWidth?: number\n\n /**\n * The minimum space (in pixels) between the target element and the edge of\n * the window required to trigger an alignment change, defaults to `100px`.\n */\n threshold?: number\n}>\n\nexport default function WithTooltip({\n children,\n className,\n style,\n arrowHeight = 8,\n backgroundColor = '#000',\n gap = 5,\n hint,\n maxTextWidth = 200,\n threshold = 100,\n}: WithToolTipProps) {\n const createDialog = () => {\n const dialog = document.createElement('div')\n dialog.className = classNames(className)\n Object.keys(styles(style, fixedStyles.dialog)).forEach(rule => (dialog.style as any)[rule] = (fixedStyles.dialog as any)[rule])\n\n const arrow = document.createElement('div')\n Object.keys(fixedStyles.arrow).forEach(rule => (arrow.style as any)[rule] = (fixedStyles.arrow as any)[rule])\n\n const content = document.createElement('div')\n content.innerText = hint\n Object.keys(fixedStyles.content).forEach(rule => (content.style as any)[rule] = (fixedStyles.content as any)[rule])\n\n dialog.appendChild(arrow)\n dialog.appendChild(content)\n\n return dialog\n }\n\n const computeAlignment = () => {\n if (!rootRef.current) return 'bc'\n\n const vrect = Rect.fromViewport()\n const irect = Rect.intersecting(rootRef.current)\n\n if (irect) {\n const leftBound = irect.left - vrect.left < threshold\n const rightBound = vrect.right - irect.right < threshold\n const topBound = irect.top - vrect.top < threshold\n const bottomBound = vrect.bottom - irect.bottom < threshold\n\n if (leftBound && topBound) return 'br'\n if (leftBound && bottomBound) return 'tr'\n if (rightBound && topBound) return 'bl'\n if (rightBound && bottomBound) return 'tl'\n if (leftBound) return 'cr'\n if (rightBound) return 'cl'\n if (bottomBound) return 'tc'\n }\n\n return 'bc'\n }\n\n const computeTextSize = () => {\n if (!dialogRef.current) return new Size()\n\n const computedStyle = window.getComputedStyle(dialogRef.current)\n const div = document.createElement('div')\n div.innerText = hint\n div.style.fontFamily = computedStyle.getPropertyValue('font-family')\n div.style.fontSize = computedStyle.getPropertyValue('font-size')\n div.style.fontStyle = computedStyle.getPropertyValue('font-style')\n div.style.fontVariant = computedStyle.getPropertyValue('font-variant')\n div.style.fontWeight = computedStyle.getPropertyValue('font-weight')\n div.style.left = '0'\n div.style.position = 'absolute'\n div.style.top = '0'\n div.style.visibility = 'hidden'\n div.style.whiteSpace = 'pre'\n\n document.body.appendChild(div)\n\n // Add 1px as buffer to mitigate precision discrepancies.\n const width = div.clientWidth + 1\n const height = div.clientHeight + 1\n\n document.body.removeChild(div)\n\n return new Size([width, height])\n }\n\n const mouseEnterHandler = (event: MouseEvent) => {\n if (!dialogRef.current) return\n dialogRef.current.style.opacity = '1'\n }\n\n const mouseLeaveHandler = (event: MouseEvent) => {\n if (!dialogRef.current) return\n dialogRef.current.style.opacity = '0'\n }\n\n const rootRef = useRef<HTMLElement>(null)\n const dialogRef = useRef<HTMLDivElement>()\n const rect = useElementRect(rootRef)\n const viewportSize = useViewportSize()\n const alignment = computeAlignment()\n const textSize = computeTextSize()\n\n useEffect(() => {\n const dialogNode = createDialog()\n rootRef.current?.appendChild(dialogNode)\n\n dialogRef.current = dialogNode\n\n return () => {\n rootRef.current?.removeChild(dialogNode)\n }\n }, [rect, viewportSize])\n\n const fixedStyles = asStyleDict({\n dialog: {\n background: 'none',\n boxSizing: 'border-box',\n height: `${rect.size.height}px`,\n left: '0',\n margin: '0',\n opacity: '0',\n position: 'absolute',\n top: '0',\n width: `${rect.size.width}px`,\n zIndex: '10000',\n },\n arrow: {\n borderStyle: 'solid',\n borderWidth: `${arrowHeight}px`,\n height: '0',\n pointerEvents: 'none',\n position: 'absolute',\n width: '0',\n ...makeDisplacementStyle(alignment, arrowHeight, gap),\n ...makeArrowPositionStyle(alignment, arrowHeight, gap, backgroundColor),\n },\n content: {\n background: backgroundColor,\n boxSizing: 'content-box',\n color: 'inherit',\n fontFamily: 'inherit',\n fontSize: 'inherit',\n fontWeight: 'inherit',\n letterSpacing: 'inherit',\n lineHeight: 'inherit',\n maxWidth: `${maxTextWidth}px`,\n overflow: 'hidden',\n padding: 'inherit',\n pointerEvents: 'none',\n position: 'absolute',\n textAlign: 'inherit',\n transition: 'inherit',\n width: textSize.width > 0 ? `${textSize.width}px` : 'auto',\n ...makeDisplacementStyle(alignment, arrowHeight, gap),\n ...makeContentPositionStyle(alignment, arrowHeight, gap),\n },\n })\n\n return (\n <ExtractChild\n children={children}\n ref={rootRef}\n onMouseEnter={mouseEnterHandler}\n onMouseLeave={mouseLeaveHandler}\n />\n )\n}\n\nfunction makeDisplacementStyle(alignment: Alignment, arrowHeight: number, gap: number): CSSProperties {\n switch (alignment) {\n case 'tl': return {\n top: `${-arrowHeight}px`,\n left: `calc(50% + ${arrowHeight * 2.5}px)`,\n }\n case 'tc': return {\n top: `${-arrowHeight}px`,\n left: '50%',\n }\n case 'tr': return {\n top: `${-arrowHeight}px`,\n right: `calc(50% + ${arrowHeight * 2.5}px)`,\n }\n case 'cl': return {\n top: '50%',\n left: `${-arrowHeight}px`,\n }\n case 'cr': return {\n top: '50%',\n right: `${-arrowHeight}px`,\n }\n case 'bl': return {\n bottom: `${-arrowHeight}px`,\n left: `calc(50% + ${arrowHeight * 2.5}px)`,\n }\n case 'bc': return {\n bottom: `${-arrowHeight}px`,\n left: '50%',\n }\n case 'br': return {\n bottom: `${-arrowHeight}px`,\n right: `calc(50% + ${arrowHeight * 2.5}px)`,\n }\n default: return {\n\n }\n }\n}\n\nfunction makeContentPositionStyle(alignment: Alignment, arrowHeight: number, gap: number): CSSProperties {\n switch (alignment) {\n case 'tl': return {\n transform: `translate3d(calc(-100% - ${gap}px), calc(-100% - ${gap}px), 0)`,\n }\n case 'tc': return {\n transform: `translate3d(-50%, calc(-100% - ${gap}px), 0)`,\n }\n case 'tr': return {\n transform: `translate3d(calc(100% + ${gap}px), calc(-100% - ${gap}px), 0)`,\n }\n case 'cl': return {\n transform: `translate3d(calc(-100% - ${gap}px), -50%, 0)`,\n }\n case 'cr': return {\n transform: `translate3d(calc(100% + ${gap}px), -50%, 0)`,\n }\n case 'bl': return {\n transform: `translate3d(calc(-100% - ${gap}px), calc(100% + ${gap}px), 0)`,\n }\n case 'bc': return {\n transform: `translate3d(-50%, calc(100% + ${gap}px), 0)`,\n }\n case 'br': return {\n transform: `translate3d(calc(100% + ${gap}px), calc(100% + ${gap}px), 0)`,\n }\n default: return {\n\n }\n }\n}\n\nfunction makeArrowPositionStyle(alignment: Alignment, arrowHeight: number, gap: number, color: string): CSSProperties {\n switch (alignment) {\n case 'tl': return {\n borderColor: `${color} transparent transparent transparent`,\n transform: `translate3d(calc(0% - ${gap}px - ${arrowHeight * 3}px), calc(0% - ${gap}px), 0)`,\n }\n case 'tc': return {\n borderColor: `${color} transparent transparent transparent`,\n transform: `translate3d(-50%, calc(0% - ${gap}px), 0)`,\n }\n case 'tr': return {\n borderColor: `${color} transparent transparent transparent`,\n transform: `translate3d(calc(100% + ${gap}px + ${arrowHeight}px), calc(0% - ${gap}px), 0)`,\n }\n case 'cl': return {\n borderColor: `transparent transparent transparent ${color}`,\n transform: `translate3d(calc(0% - ${gap}px), -50%, 0)`,\n }\n case 'cr': return {\n borderColor: `transparent ${color} transparent transparent`,\n transform: `translate3d(calc(0% + ${gap}px), -50%, 0)`,\n }\n case 'bl': return {\n borderColor: `transparent transparent ${color} transparent`,\n transform: `translate3d(calc(0% - ${gap}px - ${arrowHeight * 3}px), calc(0% + ${gap}px), 0)`,\n }\n case 'bc': return {\n borderColor: `transparent transparent ${color} transparent`,\n transform: `translate3d(-50%, calc(0% + ${gap}px), 0)`,\n }\n case 'br': return {\n borderColor: `transparent transparent ${color} transparent`,\n transform: `translate3d(calc(100% + ${gap}px + ${arrowHeight}px), calc(0% + ${gap}px), 0)`,\n }\n default: return {\n\n }\n }\n}\n"]}
@@ -1,6 +1,7 @@
1
1
  import { DependencyList } from 'react';
2
2
  /**
3
- * Hook for adding document title. By default this hook is dependent on the `title` only.
3
+ * Hook for adding document title. By default this hook is dependent on the
4
+ * `title` only.
4
5
  *
5
6
  * @param title - The document title.
6
7
  * @param deps - Additional dependencies.
@@ -27,7 +27,8 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
27
27
  Object.defineProperty(exports, "__esModule", { value: true });
28
28
  var react_1 = require("react");
29
29
  /**
30
- * Hook for adding document title. By default this hook is dependent on the `title` only.
30
+ * Hook for adding document title. By default this hook is dependent on the
31
+ * `title` only.
31
32
  *
32
33
  * @param title - The document title.
33
34
  * @param deps - Additional dependencies.
@@ -1 +1 @@
1
- {"version":3,"file":"useDocumentTitle.js","sourceRoot":"/","sources":["hooks/useDocumentTitle.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAAiD;AAEjD;;;;;GAKG;AACH,SAAwB,gBAAgB,CAAC,KAAa,EAAE,IAAqB;IAC3E,IAAA,iBAAS,EAAC;QACR,QAAQ,CAAC,KAAK,GAAG,KAAK,CAAA;IACxB,CAAC,iBAAG,KAAK,UAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,UAAE,CAAA;AAClC,CAAC;AAJD,mCAIC","sourcesContent":["import { DependencyList, useEffect } from 'react'\n\n/**\n * Hook for adding document title. By default this hook is dependent on the `title` only.\n *\n * @param title - The document title.\n * @param deps - Additional dependencies.\n */\nexport default function useDocumentTitle(title: string, deps?: DependencyList) {\n useEffect(() => {\n document.title = title\n }, [title, ...deps ? deps : []])\n}\n"]}
1
+ {"version":3,"file":"useDocumentTitle.js","sourceRoot":"/","sources":["hooks/useDocumentTitle.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAAiD;AAEjD;;;;;;GAMG;AACH,SAAwB,gBAAgB,CAAC,KAAa,EAAE,IAAqB;IAC3E,IAAA,iBAAS,EAAC;QACR,QAAQ,CAAC,KAAK,GAAG,KAAK,CAAA;IACxB,CAAC,iBAAG,KAAK,UAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,UAAE,CAAA;AAClC,CAAC;AAJD,mCAIC","sourcesContent":["import { DependencyList, useEffect } from 'react'\n\n/**\n * Hook for adding document title. By default this hook is dependent on the\n * `title` only.\n *\n * @param title - The document title.\n * @param deps - Additional dependencies.\n */\nexport default function useDocumentTitle(title: string, deps?: DependencyList) {\n useEffect(() => {\n document.title = title\n }, [title, ...deps ? deps : []])\n}\n"]}
@@ -1,13 +1,28 @@
1
1
  import { DependencyList, Dispatch, RefObject, SetStateAction } from 'react';
2
2
  declare type ReturnedStates<T> = {
3
3
  isDragging: [boolean, Dispatch<SetStateAction<boolean>>];
4
+ isReleasing: [boolean, Dispatch<SetStateAction<boolean>>];
4
5
  value: [T, Dispatch<SetStateAction<T>>];
5
6
  };
6
- declare type Options<T> = Omit<Parameters<Interact.Interactable['draggable']>[0], 'onstart' | 'onmove' | 'onend'> & {
7
+ declare type InteractDraggableOptions = Parameters<Interact.Interactable['draggable']>[0];
8
+ declare type Options<T> = Omit<InteractDraggableOptions, 'onstart' | 'onmove' | 'onend'> & {
7
9
  /**
8
10
  * The initial associated value of this hook.
9
11
  */
10
12
  initialValue: T;
13
+ /**
14
+ * A function that transforms the drag move delta values to the associated
15
+ * value of this hook.
16
+ *
17
+ * @param currentValue - The current associated value.
18
+ * @param dx - The displacement on the x-axis (in pixels) since the last
19
+ * emitted drag move event.
20
+ * @param dy - The displacement on the y-axis (in pixels) since the last
21
+ * emitted drag move event.
22
+ *
23
+ * @returns The transformed value.
24
+ */
25
+ transform: (currentValue: T, dx: number, dy: number) => T;
11
26
  /**
12
27
  * Handler invoked when dragging starts.
13
28
  */
@@ -15,33 +30,27 @@ declare type Options<T> = Omit<Parameters<Interact.Interactable['draggable']>[0]
15
30
  /**
16
31
  * Handler invoked when dragging.
17
32
  *
18
- * @param dx - The displacement on the x-axis (in pixels) since the last emitted drag move event.
19
- * @param dy - The displacement on the y-axis (in pixels) since the last emitted drag move event.
33
+ * @param dx - The displacement on the x-axis (in pixels) since the last
34
+ * emitted drag move event.
35
+ * @param dy - The displacement on the y-axis (in pixels) since the last
36
+ * emitted drag move event.
20
37
  */
21
38
  onDragMove?: (dx: number, dy: number) => void;
22
39
  /**
23
40
  * Handler invoked when dragging ends.
24
41
  */
25
42
  onDragEnd?: () => void;
26
- /**
27
- * A function that transforms the drag move delta values to the associated value of this hook.
28
- *
29
- * @param currentValue - The current associated value.
30
- * @param dx - The displacement on the x-axis (in pixels) since the last emitted drag move event.
31
- * @param dy - The displacement on the y-axis (in pixels) since the last emitted drag move event.
32
- *
33
- * @returns The transformed value.
34
- */
35
- transform?: (currentValue: T, dx: number, dy: number) => T;
36
43
  };
37
44
  /**
38
45
  * Hook for adding effectful dragging interaction to an element.
39
46
  *
40
- * @param targetRef - The reference to the target element to add drag interaction to.
41
- * @param options - Additional options which include options for `module:interactjs.draggable`.
47
+ * @param targetRef - The reference to the target element to add drag
48
+ * interaction to.
49
+ * @param options - Additional options which include options for
50
+ * `module:interactjs.draggable`.
42
51
  * @param deps - Dependencies that trigger this effect.
43
52
  *
44
53
  * @returns The states created for this effect.
45
54
  */
46
- export default function useDragEffect<T = [number, number]>(targetRef: RefObject<HTMLElement>, { onDragStart, onDragMove, onDragEnd, initialValue, transform, ...options }: Options<T>, deps?: DependencyList): ReturnedStates<T>;
55
+ export default function useDragEffect<T = [number, number]>(targetRef: RefObject<HTMLElement>, { initialValue, transform, onDragStart, onDragMove, onDragEnd, ...options }: Options<T>, deps?: DependencyList): ReturnedStates<T>;
47
56
  export {};