@startlibs/components 1.1.5 → 1.2.0-rc.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 (123) hide show
  1. package/lib/BasicBulletList.mjs +1 -1
  2. package/lib/BasicBulletList.mjs.map +1 -1
  3. package/lib/Button.mjs +3 -3
  4. package/lib/Button.mjs.map +1 -1
  5. package/lib/ContextMenu.mjs +22 -6
  6. package/lib/ContextMenu.mjs.map +1 -1
  7. package/lib/Dialog.mjs +60 -24
  8. package/lib/Dialog.mjs.map +1 -1
  9. package/lib/Icon.mjs +10 -4
  10. package/lib/Icon.mjs.map +1 -1
  11. package/lib/Loading.mjs +26 -3
  12. package/lib/Loading.mjs.map +1 -1
  13. package/lib/PageLoader.mjs +2 -2
  14. package/lib/PageLoader.mjs.map +1 -1
  15. package/lib/PersistentNotifications.mjs +1 -1
  16. package/lib/PersistentNotifications.mjs.map +1 -1
  17. package/lib/SplitColumnsContainer.mjs +77 -6
  18. package/lib/SplitColumnsContainer.mjs.map +1 -1
  19. package/lib/TextButton.mjs +1 -1
  20. package/lib/TextButton.mjs.map +1 -1
  21. package/lib/ToastNotifications.mjs +16 -14
  22. package/lib/ToastNotifications.mjs.map +1 -1
  23. package/lib/alt/dialogs/DialogWithImageHeader.mjs +1 -1
  24. package/lib/alt/dialogs/DialogWithImageHeader.mjs.map +1 -1
  25. package/lib/alt/dialogs/DialogWithSidebar.mjs +7 -3
  26. package/lib/alt/dialogs/DialogWithSidebar.mjs.map +1 -1
  27. package/lib/alt/dialogs/MobileBubbleDialog.mjs +1 -1
  28. package/lib/alt/dialogs/MobileBubbleDialog.mjs.map +1 -1
  29. package/lib/containers/DialogContainer.mjs +29 -10
  30. package/lib/containers/DialogContainer.mjs.map +1 -1
  31. package/lib/index.cjs +286 -93
  32. package/lib/index.cjs.map +1 -1
  33. package/lib/willUseIsSticky.mjs +23 -2
  34. package/lib/willUseIsSticky.mjs.map +1 -1
  35. package/lib-yak/BasicBulletList.mjs +27 -0
  36. package/lib-yak/BasicBulletList.mjs.map +1 -0
  37. package/lib-yak/Button.mjs +374 -0
  38. package/lib-yak/Button.mjs.map +1 -0
  39. package/lib-yak/ContextMenu.mjs +642 -0
  40. package/lib-yak/ContextMenu.mjs.map +1 -0
  41. package/lib-yak/Dialog.mjs +469 -0
  42. package/lib-yak/Dialog.mjs.map +1 -0
  43. package/lib-yak/Draggable.mjs +892 -0
  44. package/lib-yak/Draggable.mjs.map +1 -0
  45. package/lib-yak/ErrorBoundary.mjs +108 -0
  46. package/lib-yak/ErrorBoundary.mjs.map +1 -0
  47. package/lib-yak/FillLastLineResizer.mjs +238 -0
  48. package/lib-yak/FillLastLineResizer.mjs.map +1 -0
  49. package/lib-yak/Flip.mjs +644 -0
  50. package/lib-yak/Flip.mjs.map +1 -0
  51. package/lib-yak/FlipList.mjs +186 -0
  52. package/lib-yak/FlipList.mjs.map +1 -0
  53. package/lib-yak/FormatDate.mjs +25 -0
  54. package/lib-yak/FormatDate.mjs.map +1 -0
  55. package/lib-yak/Icon.mjs +74 -0
  56. package/lib-yak/Icon.mjs.map +1 -0
  57. package/lib-yak/Image.mjs +41 -0
  58. package/lib-yak/Image.mjs.map +1 -0
  59. package/lib-yak/Link.mjs +116 -0
  60. package/lib-yak/Link.mjs.map +1 -0
  61. package/lib-yak/Loading.mjs +54 -0
  62. package/lib-yak/Loading.mjs.map +1 -0
  63. package/lib-yak/LoadingDiv.mjs +82 -0
  64. package/lib-yak/LoadingDiv.mjs.map +1 -0
  65. package/lib-yak/Notifications.mjs +99 -0
  66. package/lib-yak/Notifications.mjs.map +1 -0
  67. package/lib-yak/PageLoader.mjs +61 -0
  68. package/lib-yak/PageLoader.mjs.map +1 -0
  69. package/lib-yak/PersistentNotifications.mjs +209 -0
  70. package/lib-yak/PersistentNotifications.mjs.map +1 -0
  71. package/lib-yak/Popup.mjs +66 -0
  72. package/lib-yak/Popup.mjs.map +1 -0
  73. package/lib-yak/SplitColumnsContainer.mjs +140 -0
  74. package/lib-yak/SplitColumnsContainer.mjs.map +1 -0
  75. package/lib-yak/SwitchDiv.mjs +60 -0
  76. package/lib-yak/SwitchDiv.mjs.map +1 -0
  77. package/lib-yak/TextButton.mjs +61 -0
  78. package/lib-yak/TextButton.mjs.map +1 -0
  79. package/lib-yak/ToastNotifications.mjs +316 -0
  80. package/lib-yak/ToastNotifications.mjs.map +1 -0
  81. package/lib-yak/Tooltip.mjs +176 -0
  82. package/lib-yak/Tooltip.mjs.map +1 -0
  83. package/lib-yak/TransitionDiv.mjs +59 -0
  84. package/lib-yak/TransitionDiv.mjs.map +1 -0
  85. package/lib-yak/WarningDialog.mjs +107 -0
  86. package/lib-yak/WarningDialog.mjs.map +1 -0
  87. package/lib-yak/alt/buttons/OnClickLoadingButton.mjs +36 -0
  88. package/lib-yak/alt/buttons/OnClickLoadingButton.mjs.map +1 -0
  89. package/lib-yak/alt/dialogs/DialogWithImageHeader.mjs +50 -0
  90. package/lib-yak/alt/dialogs/DialogWithImageHeader.mjs.map +1 -0
  91. package/lib-yak/alt/dialogs/DialogWithSidebar.mjs +193 -0
  92. package/lib-yak/alt/dialogs/DialogWithSidebar.mjs.map +1 -0
  93. package/lib-yak/alt/dialogs/MobileBubbleDialog.mjs +82 -0
  94. package/lib-yak/alt/dialogs/MobileBubbleDialog.mjs.map +1 -0
  95. package/lib-yak/containers/DialogContainer.mjs +482 -0
  96. package/lib-yak/containers/DialogContainer.mjs.map +1 -0
  97. package/lib-yak/containers/Reposition.mjs +35 -0
  98. package/lib-yak/containers/Reposition.mjs.map +1 -0
  99. package/lib-yak/containers/usePositioning.mjs +311 -0
  100. package/lib-yak/containers/usePositioning.mjs.map +1 -0
  101. package/lib-yak/index.mjs +37 -0
  102. package/lib-yak/index.mjs.map +1 -0
  103. package/lib-yak/useDialogWithToggle.mjs +18 -0
  104. package/lib-yak/useDialogWithToggle.mjs.map +1 -0
  105. package/lib-yak/willUseIsSticky.mjs +147 -0
  106. package/lib-yak/willUseIsSticky.mjs.map +1 -0
  107. package/package.json +12 -3
  108. package/src/BasicBulletList.jsx +1 -1
  109. package/src/Button.jsx +36 -30
  110. package/src/ContextMenu.jsx +21 -7
  111. package/src/Dialog.jsx +31 -12
  112. package/src/Icon.jsx +5 -4
  113. package/src/Loading.jsx +19 -5
  114. package/src/PageLoader.jsx +3 -3
  115. package/src/PersistentNotifications.jsx +2 -2
  116. package/src/SplitColumnsContainer.jsx +89 -30
  117. package/src/TextButton.jsx +1 -1
  118. package/src/ToastNotifications.jsx +15 -8
  119. package/src/alt/dialogs/DialogWithImageHeader.jsx +2 -2
  120. package/src/alt/dialogs/DialogWithSidebar.jsx +6 -5
  121. package/src/alt/dialogs/MobileBubbleDialog.jsx +1 -1
  122. package/src/containers/DialogContainer.jsx +11 -4
  123. package/src/willUseIsSticky.jsx +22 -2
@@ -0,0 +1,311 @@
1
+ import _isFunction from 'lodash/fp/isFunction';
2
+ import { yakDomTag } from '@startlibs/utils/yakDomTag';
3
+ import React, { useRef, useState, useLayoutEffect, useEffect } from 'react';
4
+ import { styled } from '@yak/react';
5
+ import { getClosestOffsetScroll } from '@startlibs/utils';
6
+ import { useEnsureRef } from '@startlibs/core';
7
+ import { getDialogLayersSize } from './DialogContainer.mjs';
8
+
9
+ const Placeholder = styled(yakDomTag("span"))`
10
+ top:0;
11
+ left:0;
12
+ padding: 0 !important;
13
+ position: absolute;
14
+ `;
15
+ /*
16
+ type Alignment = 'top left' | 'top center' | 'top right' |
17
+ 'center left' | 'center center' | 'center right' |
18
+ 'bottom left' | 'bottom center' | 'bottom right'
19
+
20
+ type Collision = 'fit fit' | 'fit flip' | 'fit fitflip' | 'fit none' |
21
+ 'flip fit' | 'flip flip' | 'flip fitflip' | 'flip none' |
22
+ 'flipfit fit' | 'flipfit flip' | 'flipfit fitflip' | 'flipfit none' |
23
+ 'none fit' | 'none flip' | 'none fitflip' | 'none none'
24
+ */
25
+
26
+ const HORIZONTAL_MAPPING = ['left', 'center', 'right'];
27
+ const VERTICAL_MAPPING = ['top', 'center', 'bottom'];
28
+ const ARROW_KEY_POSITIONS = {
29
+ left: '0',
30
+ right: '-0',
31
+ top: '0',
32
+ bottom: '-0'
33
+ };
34
+ const POSITIONING_BOUNDS = {
35
+ left: 0,
36
+ top: 0,
37
+ right: 0,
38
+ bottom: 0
39
+ };
40
+ const addPositioningBound = (key, value) => {
41
+ POSITIONING_BOUNDS[key] += value;
42
+ return () => POSITIONING_BOUNDS[key] -= value;
43
+ };
44
+ function getPosition(origin, offset, max, originSize, selfSize, originalAlignment, selfAlignment, onCollision, mapping, boundMargin) {
45
+ // 0 pra left ou top, 1/2 pra center, 1 pra right ou bottom
46
+ const originDiff = originSize * (mapping.indexOf(originalAlignment) / 2);
47
+ // 0 pra left ou top, -1/2 pra center, -1 pra right ou bottom
48
+ const selfDiff = -(selfSize * (mapping.indexOf(selfAlignment) / 2));
49
+ const respectingBounds = boundMargin !== false;
50
+ const upperBound = respectingBounds ? POSITIONING_BOUNDS[mapping[0]] + boundMargin : Number.MIN_SAFE_INTEGER;
51
+ const lowerBound = respectingBounds ? POSITIONING_BOUNDS[mapping[2]] + boundMargin : 0;
52
+ const newPosition = Math.max(upperBound, origin + selfDiff + originDiff + offset);
53
+ const collision = Math.max(-newPosition, newPosition + selfSize - max + lowerBound);
54
+ if (collision > 0 && onCollision !== 'none') {
55
+ if (onCollision.indexOf('flip') >= 0) {
56
+ const flippedPosition = getPosition(origin, -offset, max, originSize, selfSize, originalAlignment, selfAlignment, onCollision.indexOf('fit') >= 0 ? 'fit' : 'none', mapping.slice().reverse(), boundMargin);
57
+ const flippedCollision = Math.max(-flippedPosition[0], flippedPosition[0] + selfSize - max);
58
+ if (collision > 0 && flippedCollision > 0 || flippedPosition[0] < upperBound) {
59
+ return getPosition(origin, offset, max, originSize, selfSize, originalAlignment, selfAlignment, 'fit', mapping, boundMargin);
60
+ }
61
+ return collision < flippedCollision ? [newPosition, 'none'] : [flippedPosition[0], flippedPosition[1] === 'fit' ? 'flipfit' : 'flip'];
62
+ } else {
63
+ const minBound = respectingBounds ? upperBound : 0;
64
+ const fittedPosition = Math.max(minBound, Math.min(newPosition, max - selfSize - lowerBound));
65
+ return [fittedPosition, fittedPosition !== newPosition ? 'fit' : 'none'];
66
+ }
67
+ } else {
68
+ return [newPosition, 'none'];
69
+ }
70
+ }
71
+ const arrowShadow = {
72
+ top: '-1px -1px 2px -1px rgba(0,0,0,.25)',
73
+ right: '1px -1px 2px -1px rgba(0,0,0,.25)',
74
+ bottom: '1px 1px 2px -1px rgba(0,0,0,.25)',
75
+ left: '-1px 1px 2px -1px rgba(0,0,0,.25)'
76
+ };
77
+ const translate = (position, offset) => (position === 'left' ? '-50%' : position === 'right' ? '50%' : offset) + ',' + (position === 'top' ? '-50%' : position === 'bottom' ? '50%' : offset);
78
+ const ARROW_DEFAULT_SIZE = 14;
79
+ const DefaultArrow = styled(yakDomTag("div")).attrs({
80
+ className: "styled-default-arrow"
81
+ })`
82
+ background-color: #fff;
83
+ position: absolute;
84
+ width: ${ARROW_DEFAULT_SIZE}px;
85
+ height: ${ARROW_DEFAULT_SIZE}px;
86
+ transform: translate(-50%,50%) rotate(45deg);
87
+ bottom: 0;
88
+ left: 50%;
89
+ box-shadow: ${arrowShadow.bottom};
90
+ `;
91
+ const usePositioning = (element, _ref, arrowRefOpt) => {
92
+ let {
93
+ my = 'top right',
94
+ offset = '0 0',
95
+ // x y
96
+ at = 'bottom right',
97
+ onCollision = 'flip flip',
98
+ arrow,
99
+ arrowPadding = 10,
100
+ fill,
101
+ useLayers = true,
102
+ fixed,
103
+ bottom: onBottom,
104
+ left: onLeft,
105
+ right: onRight,
106
+ top: onTop,
107
+ keepWidth = true,
108
+ boundMargin = 6,
109
+ respectBounds,
110
+ respectOffsetScroll,
111
+ on,
112
+ placeholderAs
113
+ } = _ref;
114
+ const placeholder = useRef();
115
+ const arrowRef = useEnsureRef(arrowRefOpt);
116
+ const [positionInfo, setPositionInfo] = useState();
117
+ const setPosition = function () {
118
+ var _element$current, _placeholder$current, _placeholder$current2, _placeholder$current3, _placeholder$current4;
119
+ let retry = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
120
+ if (retry > 10) {
121
+ return;
122
+ }
123
+ if (!((_element$current = element.current) !== null && _element$current !== void 0 && _element$current.style) || !((_placeholder$current = placeholder.current) !== null && _placeholder$current !== void 0 && _placeholder$current.offsetParent || (_placeholder$current2 = placeholder.current) !== null && _placeholder$current2 !== void 0 && (_placeholder$current2 = _placeholder$current2.parentNode) !== null && _placeholder$current2 !== void 0 && _placeholder$current2.offsetParent)) {
124
+ setTimeout(() => setPosition(retry + 1), 100);
125
+ return;
126
+ }
127
+ // Limpar a largura para medir pode encurtar o conteúdo (itens deixam de quebrar linha)
128
+ // e o browser corta o scrollTop; guarda para restaurar depois de reaplicar a largura.
129
+ const previousScrollTop = element.current.scrollTop;
130
+ if (keepWidth) {
131
+ element.current.style.width = '';
132
+ } else {
133
+ element.current.style.maxWidth = '';
134
+ }
135
+ const placeholderOffsetParent = ((_placeholder$current3 = placeholder.current) === null || _placeholder$current3 === void 0 ? void 0 : _placeholder$current3.offsetParent) || ((_placeholder$current4 = placeholder.current) === null || _placeholder$current4 === void 0 || (_placeholder$current4 = _placeholder$current4.parentNode) === null || _placeholder$current4 === void 0 ? void 0 : _placeholder$current4.offsetParent);
136
+ const usingLayer = respectOffsetScroll || useLayers && getDialogLayersSize() > 0;
137
+ const scrollOwner = usingLayer ? _isFunction(respectOffsetScroll) ? respectOffsetScroll(element.current.offsetParent) : getClosestOffsetScroll(element.current.offsetParent) : {
138
+ scrollTop: window.pageYOffset,
139
+ scrollLeft: window.pageXOffset
140
+ };
141
+
142
+ // console.log({scrollOwner,scrollTop:scrollOwner.scrollTop,pageYOffset:window.pageYOffset})
143
+
144
+ const scrollY = !isNaN(scrollOwner.scrollTop) ? scrollOwner.scrollTop : window.pageYOffset;
145
+ const scrollX = !isNaN(scrollOwner.scrollLeft) ? scrollOwner.scrollLeft : window.pageXOffset;
146
+ const getRespectOffsetScrollTopLeft = () => {
147
+ const {
148
+ top,
149
+ left
150
+ } = placeholder.current.getBoundingClientRect();
151
+ const {
152
+ top: scrollOwnerTop,
153
+ left: scrollOwnerLeft
154
+ } = scrollOwner.getBoundingClientRect();
155
+ return {
156
+ top: top - scrollOwnerTop,
157
+ left: left - scrollOwnerLeft
158
+ };
159
+ };
160
+ const {
161
+ left: leftPlusBorder,
162
+ top: topPlusBorder
163
+ } = respectOffsetScroll ? getRespectOffsetScrollTopLeft() : placeholder.current.getBoundingClientRect();
164
+ const {
165
+ borderLeftWidth,
166
+ borderTopWidth
167
+ } = window.getComputedStyle(placeholderOffsetParent);
168
+ const left = leftPlusBorder - parseInt(borderLeftWidth, 10);
169
+ const top = topPlusBorder - parseInt(borderTopWidth, 10);
170
+ const {
171
+ offsetWidth: parentOffsetWidth,
172
+ offsetHeight: parentOffsetHeight
173
+ } = placeholderOffsetParent;
174
+ const {
175
+ offsetWidth: popupOffsetWidth,
176
+ offsetHeight: popupOffsetHeight
177
+ } = element.current;
178
+ const {
179
+ width: popupCurrentWidth
180
+ } = element.current.getBoundingClientRect();
181
+ const [offsetX, offsetY] = [].concat(offset).join(' ').split(' ').map(_ => Number(_ || 0));
182
+ const simplePositioning = [onTop, onRight, onBottom, onLeft].map(_ => _ === true ? 'center' : _);
183
+ const simplePositioningIndex = simplePositioning.findIndex(_ => _);
184
+ const bodyWidth = document.body.offsetWidth - (usingLayer ? parseInt(getComputedStyle(document.body).paddingRight, 10) : 0);
185
+ // Barra fixa inferior (footer mobile) registrada em POSITIONING_BOUNDS conta como
186
+ // borda da tela: sem isso o popup se posiciona atrás dela. Com respectBounds o
187
+ // desconto já vem do lowerBound em getPosition, não descontar duas vezes.
188
+ const windowHeight = window.innerHeight - (respectBounds ? 0 : POSITIONING_BOUNDS.bottom);
189
+ const [verticalCollision, horizontalCollision] = onCollision.split(' ');
190
+ const [verticalMy, horizontalMy] = [my, 'bottom $', '$ left', 'top $', '$ right'][simplePositioningIndex + 1].replace('$', simplePositioning[simplePositioningIndex]).split(' ');
191
+ const [verticalAt, horizontalAt] = [at, 'top $', '$ right', 'bottom $', '$ left'][simplePositioningIndex + 1].replace('$', simplePositioning[simplePositioningIndex]).split(' ');
192
+ const [processedLeft, collisionH] = getPosition(left, offsetX, bodyWidth, parentOffsetWidth, fill ? parentOffsetWidth : popupOffsetWidth, horizontalAt, horizontalMy, horizontalCollision, HORIZONTAL_MAPPING, !!respectBounds && boundMargin);
193
+ const [processedTop, collisionV] = getPosition(top, offsetY, windowHeight, parentOffsetHeight, popupOffsetHeight, verticalAt, verticalMy, verticalCollision, VERTICAL_MAPPING, !!respectBounds && boundMargin);
194
+ const flippedV = collisionV.indexOf('flip') >= 0;
195
+ const flippedH = collisionH.indexOf('flip') >= 0;
196
+
197
+ //arrow
198
+ const arrowSide = Math.abs(VERTICAL_MAPPING.indexOf(verticalMy) - VERTICAL_MAPPING.indexOf(verticalAt)) === 2 ? flippedV ? verticalAt : verticalMy : Math.abs(HORIZONTAL_MAPPING.indexOf(horizontalMy) - HORIZONTAL_MAPPING.indexOf(horizontalAt)) === 2 ? flippedH ? horizontalAt : horizontalMy : '';
199
+ const arrowElement = arrowRef.current;
200
+ const arrowOnVerticalSide = arrowSide === 'left' || arrowSide === 'right';
201
+ const arrowSize = arrowElement ? arrowElement.getBoundingClientRect()[arrowOnVerticalSide ? 'height' : 'width'] : ARROW_DEFAULT_SIZE * Math.sqrt(2);
202
+ const [arrowOffset, popupArrowOffset] = arrowOnVerticalSide ? processArrow(ARROW_KEY_POSITIONS[arrow] || arrow, arrowSize, arrowOnVerticalSide, parentOffsetHeight, popupOffsetHeight, processedTop - top, flippedV) : processArrow(ARROW_KEY_POSITIONS[arrow] || arrow, arrowSize, arrowOnVerticalSide, parentOffsetWidth, popupOffsetWidth, processedLeft - left, flippedV);
203
+ const maxHeight = window.innerHeight - (POSITIONING_BOUNDS.top + POSITIONING_BOUNDS.bottom) - (respectBounds ? boundMargin * 2 : 0);
204
+ const maxWidth = window.innerWidth - (POSITIONING_BOUNDS.left + POSITIONING_BOUNDS.right) - (respectBounds ? boundMargin * 2 : 0);
205
+ element.current.style.maxHeight = '';
206
+ if (parseInt(window.getComputedStyle(element.current).maxHeight) > maxHeight) {
207
+ element.current.style.maxHeight = maxHeight + 'px';
208
+ }
209
+ if (keepWidth) {
210
+ element.current.style.width = Math.ceil(popupCurrentWidth) + "px";
211
+ } else {
212
+ element.current.style.maxWidth = maxWidth + 'px';
213
+ }
214
+ // console.log({processedTop,top,offsetY,scrollY})
215
+
216
+ element.current.style.top = processedTop + (arrowOnVerticalSide ? popupArrowOffset : 0) + (fixed ? 0 : scrollY) + 'px';
217
+ element.current.style.left = processedLeft + (arrowOnVerticalSide ? 0 : popupArrowOffset) + (fixed ? 0 : scrollX) + 'px';
218
+ const arrowStyle = {
219
+ transform: `translate(${translate(arrowSide, arrowOffset[0] === 'top' || arrowOffset[0] === 'left' ? '-50%' : '50%')}) rotate(45deg)`,
220
+ bottom: "auto",
221
+ left: "auto",
222
+ [arrowSide]: '0',
223
+ boxShadow: arrowShadow[arrowSide],
224
+ [arrowOffset[0]]: arrowOffset[1] + 'px'
225
+ };
226
+ if (arrowRef.current) {
227
+ Object.assign(arrowRef.current.style, arrowStyle);
228
+ }
229
+ setPositionInfo({
230
+ atTop: verticalAt === 'top' && !flippedV || verticalAt === 'bottom' && flippedV,
231
+ atBottom: verticalAt === 'bottom' && !flippedV || verticalAt === 'top' && flippedV,
232
+ atLeft: horizontalAt === 'left' && !flippedH || verticalAt === 'right' && flippedH,
233
+ atRight: horizontalAt === 'right' && !flippedH || verticalAt === 'left' && flippedH,
234
+ fullHeight: popupOffsetHeight > maxHeight,
235
+ fullWidth: popupOffsetWidth > maxWidth,
236
+ arrowSide,
237
+ arrowOffset,
238
+ arrowStyle
239
+ });
240
+ if (fill) {
241
+ element.current.style.width = parentOffsetWidth + 'px';
242
+ }
243
+ if (fixed) {
244
+ element.current.style.position = 'fixed';
245
+ }
246
+ if (element.current.scrollTop !== previousScrollTop) {
247
+ element.current.scrollTop = previousScrollTop;
248
+ }
249
+ };
250
+ useLayoutEffect(setPosition, [on]);
251
+ useEffect(() => {
252
+ window.addEventListener('portalReposition', setPosition);
253
+ window.addEventListener('stepResize', setPosition);
254
+ window.addEventListener('scroll', setPosition, {
255
+ passive: true
256
+ });
257
+ return () => {
258
+ window.removeEventListener('portalReposition', setPosition);
259
+ window.removeEventListener('stepResize', setPosition);
260
+ window.removeEventListener('scroll', setPosition);
261
+ };
262
+ }, []);
263
+ const processArrow = (arrow, arrowSize, onVerticalSide, arrowContainerWidth, popupSize, deltaPopupPosition, flipped) => {
264
+ if (!arrow) {
265
+ return ['', 0];
266
+ }
267
+ const margin = arrowPadding + arrowSize / 2;
268
+ const [invertDirection, percent, px] = (arrow === true ? '50%' : arrow).replace(/(-)?(\d+%)?\s?(-?\d+)?/, '$1:$2:$3').split(':');
269
+ const invertAndFlipDirection = flipped ? !invertDirection : invertDirection;
270
+ const arrowPosition = onVerticalSide ? invertAndFlipDirection ? 'bottom' : 'top' : invertAndFlipDirection ? 'right' : 'left';
271
+ const fromOriginCorner = arrowPosition === 'left' || arrowPosition === 'top';
272
+ const popupOffset = fromOriginCorner ? deltaPopupPosition : arrowContainerWidth - deltaPopupPosition - popupSize;
273
+
274
+ /* ____________________________
275
+ | arrow container |
276
+ |___________________________|
277
+ ..../\_______
278
+ | popup |
279
+ |____________|
280
+ |-------| = delta popup position (popupOffset)
281
+ .... = arrowPadding prop, applies to both sides, moves popup or does nothing
282
+ arrow prop = invert percent px // relative to arrow container
283
+ invert = -?
284
+ percent = (\d+%)?
285
+ px = (-?\d+)?
286
+ procedure:
287
+ 1- position arrow according to container - arrowInitialPos
288
+ 2- constrain position inside container - constrainedArrowPosition
289
+ 3- move popup according to arrowPadding (margin) - popupDelta
290
+ 4- final arrow position, relative to final popup position - finalArrowPosition
291
+ */
292
+
293
+ const arrowInitialPos = parseInt(percent || 0, 10) * arrowContainerWidth / 100 + parseInt(px || 0, 10);
294
+ const constrainedArrowPosition = Math.min(Math.max(arrowInitialPos, 0), arrowContainerWidth);
295
+ const arrowPositionRelativeToPopup = fromOriginCorner ? constrainedArrowPosition - popupOffset : arrowContainerWidth - popupOffset - constrainedArrowPosition;
296
+ const popupDelta = arrowPositionRelativeToPopup < margin ? arrowPositionRelativeToPopup - margin : arrowPositionRelativeToPopup > popupSize - margin ? margin + arrowPositionRelativeToPopup - popupSize : 0;
297
+ const finalPopupPosition = fromOriginCorner ? popupOffset + popupDelta : arrowContainerWidth - popupOffset - popupDelta - popupSize;
298
+ return [[arrowPosition, constrainedArrowPosition - finalPopupPosition], popupDelta];
299
+ };
300
+ const arrowElement = arrow && /*#__PURE__*/React.createElement(DefaultArrow, {
301
+ ref: arrowRef
302
+ });
303
+ const placeholderElement = /*#__PURE__*/React.createElement(Placeholder, {
304
+ as: placeholderAs,
305
+ ref: placeholder
306
+ });
307
+ return [positionInfo, placeholderElement, arrowElement];
308
+ };
309
+
310
+ export { DefaultArrow, addPositioningBound, usePositioning };
311
+ //# sourceMappingURL=usePositioning.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePositioning.mjs","sources":["../../src/containers/usePositioning.jsx"],"sourcesContent":["import React, {useEffect, useLayoutEffect, useRef, useState} from 'react'\nimport _ from 'lodash/fp'\nimport styled from 'styled-components'\nimport {getClosestOffsetScroll} from '@startlibs/utils'\nimport {useEnsureRef} from '@startlibs/core'\nimport {getDialogLayersSize} from './DialogContainer'\n\nconst Placeholder = styled.span`\n top:0;\n left:0;\n padding: 0 !important;\n position: absolute;\n`\n/*\ntype Alignment = 'top left' | 'top center' | 'top right' |\n 'center left' | 'center center' | 'center right' |\n 'bottom left' | 'bottom center' | 'bottom right'\n\ntype Collision = 'fit fit' | 'fit flip' | 'fit fitflip' | 'fit none' |\n 'flip fit' | 'flip flip' | 'flip fitflip' | 'flip none' |\n 'flipfit fit' | 'flipfit flip' | 'flipfit fitflip' | 'flipfit none' |\n 'none fit' | 'none flip' | 'none fitflip' | 'none none'\n*/\n\nconst HORIZONTAL_MAPPING = ['left', 'center', 'right']\nconst VERTICAL_MAPPING = ['top', 'center', 'bottom']\nconst ARROW_KEY_POSITIONS = {left: '0', right: '-0', top: '0', bottom: '-0'}\n\nconst POSITIONING_BOUNDS = {left:0,top:0,right:0,bottom:0}\nexport const addPositioningBound = (key,value) => {\n POSITIONING_BOUNDS[key] += value\n return () => POSITIONING_BOUNDS[key] -= value\n}\n\nfunction getPosition(origin, offset, max, originSize, selfSize, originalAlignment, selfAlignment, onCollision, mapping, boundMargin) {\n\n // 0 pra left ou top, 1/2 pra center, 1 pra right ou bottom\n const originDiff = originSize * (mapping.indexOf(originalAlignment) / 2)\n // 0 pra left ou top, -1/2 pra center, -1 pra right ou bottom\n const selfDiff = -(selfSize * (mapping.indexOf(selfAlignment) / 2))\n\n const respectingBounds = boundMargin !== false\n const upperBound = respectingBounds ? (POSITIONING_BOUNDS[mapping[0]] + boundMargin) : Number.MIN_SAFE_INTEGER\n const lowerBound = respectingBounds ? (POSITIONING_BOUNDS[mapping[2]] + boundMargin) : 0\n const newPosition = Math.max(upperBound, origin + selfDiff + originDiff + offset)\n\n const collision = Math.max(-newPosition, newPosition + selfSize - max + lowerBound)\n if (collision > 0 && onCollision !== 'none') {\n if (onCollision.indexOf('flip') >= 0) {\n const flippedPosition = getPosition(origin, -offset, max, originSize, selfSize, originalAlignment, selfAlignment, onCollision.indexOf('fit') >= 0 ? 'fit' : 'none', mapping.slice().reverse(), boundMargin)\n const flippedCollision = Math.max(-flippedPosition[0], flippedPosition[0] + selfSize - max)\n if ((collision > 0 && flippedCollision > 0) || flippedPosition[0] < upperBound) {\n return getPosition(origin, offset, max, originSize, selfSize, originalAlignment, selfAlignment, 'fit', mapping, boundMargin)\n }\n return collision < flippedCollision ? [newPosition, 'none'] : [flippedPosition[0], flippedPosition[1] === 'fit' ? 'flipfit' : 'flip']\n } else {\n const minBound = respectingBounds ? upperBound : 0\n const fittedPosition = Math.max(minBound, Math.min(newPosition, max - selfSize - lowerBound))\n return [fittedPosition, fittedPosition !== newPosition ? 'fit' : 'none']\n }\n } else {\n return [newPosition, 'none']\n }\n}\n\nconst arrowShadow = {\n top: '-1px -1px 2px -1px rgba(0,0,0,.25)',\n right: '1px -1px 2px -1px rgba(0,0,0,.25)',\n bottom: '1px 1px 2px -1px rgba(0,0,0,.25)',\n left: '-1px 1px 2px -1px rgba(0,0,0,.25)'\n}\n\nconst translate = (position, offset) => (position === 'left' ? '-50%' : position === 'right' ? '50%' : offset) + ',' +\n (position === 'top' ? '-50%' : position === 'bottom' ? '50%' : offset)\n\nconst ARROW_DEFAULT_SIZE = 14\n\nexport const DefaultArrow = styled.div`\n background-color: #fff;\n position: absolute;\n width: ${ARROW_DEFAULT_SIZE}px;\n height: ${ARROW_DEFAULT_SIZE}px;\n transform: translate(-50%,50%) rotate(45deg);\n bottom: 0;\n left: 50%;\n box-shadow: ${arrowShadow.bottom};\n`\n\nexport const usePositioning = (\n element,\n {\n my = 'top right',\n offset = '0 0', // x y\n at = 'bottom right',\n onCollision = 'flip flip',\n arrow,\n arrowPadding = 10,\n fill,\n useLayers = true,\n fixed,\n bottom: onBottom,\n left: onLeft,\n right: onRight,\n top: onTop,\n keepWidth = true,\n boundMargin = 6,\n respectBounds,\n respectOffsetScroll,\n on,\n placeholderAs\n },\n arrowRefOpt\n) => {\n const placeholder = useRef()\n const arrowRef = useEnsureRef(arrowRefOpt)\n const [positionInfo, setPositionInfo] = useState()\n\n const setPosition = (retry=0) => {\n if (retry>10) { return }\n if (!element.current?.style || !(placeholder.current?.offsetParent || placeholder.current?.parentNode?.offsetParent)) {\n setTimeout(()=>setPosition(retry+1),100)\n return\n }\n // Limpar a largura para medir pode encurtar o conteúdo (itens deixam de quebrar linha)\n // e o browser corta o scrollTop; guarda para restaurar depois de reaplicar a largura.\n const previousScrollTop = element.current.scrollTop\n if (keepWidth) {\n element.current.style.width = ''\n } else {\n element.current.style.maxWidth = ''\n }\n const placeholderOffsetParent = (placeholder.current?.offsetParent || placeholder.current?.parentNode?.offsetParent)\n const usingLayer = respectOffsetScroll || useLayers && getDialogLayersSize() > 0\n const scrollOwner =\n usingLayer\n ? (_.isFunction(respectOffsetScroll) ? respectOffsetScroll(element.current.offsetParent) : getClosestOffsetScroll(element.current.offsetParent))\n : {scrollTop: window.pageYOffset, scrollLeft: window.pageXOffset}\n\n // console.log({scrollOwner,scrollTop:scrollOwner.scrollTop,pageYOffset:window.pageYOffset})\n\n const scrollY = !isNaN(scrollOwner.scrollTop) ? scrollOwner.scrollTop : window.pageYOffset\n const scrollX = !isNaN(scrollOwner.scrollLeft) ? scrollOwner.scrollLeft : window.pageXOffset\n const getRespectOffsetScrollTopLeft = () => {\n const {top,left} = placeholder.current.getBoundingClientRect()\n const {top:scrollOwnerTop, left: scrollOwnerLeft} = scrollOwner.getBoundingClientRect()\n return {top: top-scrollOwnerTop,left: left-scrollOwnerLeft}\n }\n const {left: leftPlusBorder, top: topPlusBorder} =\n respectOffsetScroll\n ? getRespectOffsetScrollTopLeft()\n :placeholder.current.getBoundingClientRect()\n\n const {borderLeftWidth, borderTopWidth} = window.getComputedStyle(placeholderOffsetParent)\n const left = leftPlusBorder - parseInt(borderLeftWidth, 10)\n const top = topPlusBorder - parseInt(borderTopWidth, 10)\n const {offsetWidth: parentOffsetWidth, offsetHeight: parentOffsetHeight} = (placeholderOffsetParent)\n const {offsetWidth: popupOffsetWidth, offsetHeight: popupOffsetHeight} = element.current\n const {width:popupCurrentWidth} = element.current.getBoundingClientRect()\n const [offsetX, offsetY] = [].concat(offset).join(' ').split(' ').map(_ => Number(_ || 0))\n const simplePositioning = [onTop, onRight, onBottom, onLeft].map(_ => _ === true ? 'center' : _)\n const simplePositioningIndex = simplePositioning.findIndex(_ => _)\n const bodyWidth = document.body.offsetWidth - (usingLayer ? parseInt(getComputedStyle(document.body).paddingRight, 10) : 0)\n // Barra fixa inferior (footer mobile) registrada em POSITIONING_BOUNDS conta como\n // borda da tela: sem isso o popup se posiciona atrás dela. Com respectBounds o\n // desconto já vem do lowerBound em getPosition, não descontar duas vezes.\n const windowHeight = window.innerHeight - (respectBounds ? 0 : POSITIONING_BOUNDS.bottom)\n\n const [verticalCollision, horizontalCollision] = onCollision.split(' ')\n const [verticalMy, horizontalMy] = [my, 'bottom $', '$ left', 'top $', '$ right'][simplePositioningIndex + 1].replace('$', simplePositioning[simplePositioningIndex]).split(' ')\n const [verticalAt, horizontalAt] = [at, 'top $', '$ right', 'bottom $', '$ left'][simplePositioningIndex + 1].replace('$', simplePositioning[simplePositioningIndex]).split(' ')\n\n const [processedLeft, collisionH] = getPosition(left, offsetX, bodyWidth, parentOffsetWidth, fill ? parentOffsetWidth : popupOffsetWidth, horizontalAt, horizontalMy, horizontalCollision, HORIZONTAL_MAPPING,!!respectBounds && boundMargin)\n const [processedTop, collisionV] = getPosition(top, offsetY, windowHeight, parentOffsetHeight, popupOffsetHeight, verticalAt, verticalMy, verticalCollision, VERTICAL_MAPPING,!!respectBounds && boundMargin)\n\n\n const flippedV = collisionV.indexOf('flip') >= 0\n const flippedH = collisionH.indexOf('flip') >= 0\n\n\n //arrow\n const arrowSide = Math.abs(VERTICAL_MAPPING.indexOf(verticalMy) - VERTICAL_MAPPING.indexOf(verticalAt)) === 2 ? (flippedV ? verticalAt : verticalMy) :\n Math.abs(HORIZONTAL_MAPPING.indexOf(horizontalMy) - HORIZONTAL_MAPPING.indexOf(horizontalAt)) === 2 ? (flippedH ? horizontalAt : horizontalMy) : ''\n const arrowElement = arrowRef.current\n const arrowOnVerticalSide = arrowSide === 'left' || arrowSide === 'right'\n const arrowSize = arrowElement ? arrowElement.getBoundingClientRect()[arrowOnVerticalSide ? 'height' : 'width'] : (ARROW_DEFAULT_SIZE * Math.sqrt(2))\n const [arrowOffset, popupArrowOffset] = arrowOnVerticalSide ?\n processArrow(ARROW_KEY_POSITIONS[arrow] || arrow, arrowSize, arrowOnVerticalSide, parentOffsetHeight, popupOffsetHeight, processedTop - top, flippedV) :\n processArrow(ARROW_KEY_POSITIONS[arrow] || arrow, arrowSize, arrowOnVerticalSide, parentOffsetWidth, popupOffsetWidth, processedLeft - left, flippedV)\n\n\n const maxHeight = window.innerHeight - (POSITIONING_BOUNDS.top + POSITIONING_BOUNDS.bottom) - (respectBounds ? boundMargin*2 : 0)\n const maxWidth = window.innerWidth - (POSITIONING_BOUNDS.left + POSITIONING_BOUNDS.right) - (respectBounds ? boundMargin*2 : 0)\n\n element.current.style.maxHeight = ''\n if (parseInt(window.getComputedStyle(element.current).maxHeight) > maxHeight) {\n element.current.style.maxHeight = maxHeight+'px'\n }\n if (keepWidth) {\n element.current.style.width = Math.ceil(popupCurrentWidth)+\"px\"\n } else {\n element.current.style.maxWidth = maxWidth+'px'\n }\n // console.log({processedTop,top,offsetY,scrollY})\n\n\n element.current.style.top = (processedTop + (arrowOnVerticalSide ? popupArrowOffset : 0) + (fixed ? 0 : scrollY)) + 'px'\n element.current.style.left = (processedLeft + (arrowOnVerticalSide ? 0 : popupArrowOffset) + (fixed ? 0 : scrollX)) + 'px'\n\n const arrowStyle = {\n transform: `translate(${translate(arrowSide, arrowOffset[0] === 'top' || arrowOffset[0] === 'left' ? '-50%' : '50%')}) rotate(45deg)`,\n bottom:\"auto\",\n left:\"auto\",\n [arrowSide]: '0',\n boxShadow: arrowShadow[arrowSide],\n [arrowOffset[0]]: arrowOffset[1]+'px'\n }\n if (arrowRef.current) {\n Object.assign(arrowRef.current.style,arrowStyle)\n }\n\n setPositionInfo({\n atTop: (verticalAt === 'top' && !flippedV) || (verticalAt === 'bottom' && flippedV),\n atBottom: (verticalAt === 'bottom' && !flippedV) || (verticalAt === 'top' && flippedV),\n atLeft: (horizontalAt === 'left' && !flippedH) || (verticalAt === 'right' && flippedH),\n atRight: (horizontalAt === 'right' && !flippedH) || (verticalAt === 'left' && flippedH),\n fullHeight: popupOffsetHeight > maxHeight,\n fullWidth: popupOffsetWidth > maxWidth,\n arrowSide,\n arrowOffset,\n arrowStyle\n })\n\n if (fill) {\n element.current.style.width = parentOffsetWidth + 'px'\n }\n if (fixed) {\n element.current.style.position = 'fixed'\n }\n if (element.current.scrollTop !== previousScrollTop) {\n element.current.scrollTop = previousScrollTop\n }\n }\n\n useLayoutEffect(setPosition, [on])\n\n\n useEffect(() => {\n window.addEventListener('portalReposition', setPosition)\n window.addEventListener('stepResize', setPosition)\n window.addEventListener('scroll', setPosition, {passive:true})\n return () => {\n window.removeEventListener('portalReposition', setPosition)\n window.removeEventListener('stepResize', setPosition)\n window.removeEventListener('scroll', setPosition)\n }\n }, []\n )\n\n\n const processArrow = (arrow, arrowSize, onVerticalSide, arrowContainerWidth, popupSize, deltaPopupPosition, flipped) => {\n if (!arrow) {\n return ['', 0]\n }\n const margin = arrowPadding + (arrowSize / 2)\n const [invertDirection, percent, px] = (arrow === true ? '50%' : arrow).replace(/(-)?(\\d+%)?\\s?(-?\\d+)?/, '$1:$2:$3').split(':')\n const invertAndFlipDirection = flipped ? !invertDirection : invertDirection\n const arrowPosition = onVerticalSide ? (invertAndFlipDirection ? 'bottom' : 'top') : (invertAndFlipDirection ? 'right' : 'left')\n const fromOriginCorner = arrowPosition === 'left' || arrowPosition === 'top'\n\n const popupOffset = fromOriginCorner ? deltaPopupPosition : (arrowContainerWidth - deltaPopupPosition - popupSize)\n\n /* ____________________________\n | arrow container |\n |___________________________|\n ..../\\_______\n | popup |\n |____________|\n\n |-------| = delta popup position (popupOffset)\n\n .... = arrowPadding prop, applies to both sides, moves popup or does nothing\n\n arrow prop = invert percent px // relative to arrow container\n invert = -?\n percent = (\\d+%)?\n px = (-?\\d+)?\n\n procedure:\n 1- position arrow according to container - arrowInitialPos\n 2- constrain position inside container - constrainedArrowPosition\n 3- move popup according to arrowPadding (margin) - popupDelta\n 4- final arrow position, relative to final popup position - finalArrowPosition\n */\n\n const arrowInitialPos = (parseInt(percent || 0, 10) * arrowContainerWidth / 100) + parseInt(px || 0, 10)\n const constrainedArrowPosition = (Math.min(Math.max(arrowInitialPos, 0), arrowContainerWidth))\n const arrowPositionRelativeToPopup = fromOriginCorner ? constrainedArrowPosition - popupOffset : (arrowContainerWidth - popupOffset - constrainedArrowPosition)\n const popupDelta = arrowPositionRelativeToPopup < margin ?\n (arrowPositionRelativeToPopup - margin) :\n arrowPositionRelativeToPopup > (popupSize - margin) ?\n (margin + arrowPositionRelativeToPopup - popupSize) :\n 0\n const finalPopupPosition = fromOriginCorner ? popupOffset + popupDelta : (arrowContainerWidth - popupOffset - popupDelta - popupSize)\n return [[arrowPosition,(constrainedArrowPosition - finalPopupPosition)], popupDelta]\n }\n\n const arrowElement = arrow && <DefaultArrow ref={arrowRef} />\n\n const placeholderElement = <Placeholder as={placeholderAs} ref={placeholder}/>\n return [positionInfo,placeholderElement,arrowElement]\n}"],"names":["Placeholder","styled","yakDomTag","HORIZONTAL_MAPPING","VERTICAL_MAPPING","ARROW_KEY_POSITIONS","left","right","top","bottom","POSITIONING_BOUNDS","addPositioningBound","key","value","getPosition","origin","offset","max","originSize","selfSize","originalAlignment","selfAlignment","onCollision","mapping","boundMargin","originDiff","indexOf","selfDiff","respectingBounds","upperBound","Number","MIN_SAFE_INTEGER","lowerBound","newPosition","Math","collision","flippedPosition","slice","reverse","flippedCollision","minBound","fittedPosition","min","arrowShadow","translate","position","ARROW_DEFAULT_SIZE","DefaultArrow","attrs","className","usePositioning","element","_ref","arrowRefOpt","my","at","arrow","arrowPadding","fill","useLayers","fixed","onBottom","onLeft","onRight","onTop","keepWidth","respectBounds","respectOffsetScroll","on","placeholderAs","placeholder","useRef","arrowRef","useEnsureRef","positionInfo","setPositionInfo","useState","setPosition","_element$current","_placeholder$current","_placeholder$current2","_placeholder$current3","_placeholder$current4","retry","arguments","length","undefined","current","style","offsetParent","parentNode","setTimeout","previousScrollTop","scrollTop","width","maxWidth","placeholderOffsetParent","usingLayer","getDialogLayersSize","scrollOwner","_isFunction","getClosestOffsetScroll","window","pageYOffset","scrollLeft","pageXOffset","scrollY","isNaN","scrollX","getRespectOffsetScrollTopLeft","getBoundingClientRect","scrollOwnerTop","scrollOwnerLeft","leftPlusBorder","topPlusBorder","borderLeftWidth","borderTopWidth","getComputedStyle","parseInt","offsetWidth","parentOffsetWidth","offsetHeight","parentOffsetHeight","popupOffsetWidth","popupOffsetHeight","popupCurrentWidth","offsetX","offsetY","concat","join","split","map","_","simplePositioning","simplePositioningIndex","findIndex","bodyWidth","document","body","paddingRight","windowHeight","innerHeight","verticalCollision","horizontalCollision","verticalMy","horizontalMy","replace","verticalAt","horizontalAt","processedLeft","collisionH","processedTop","collisionV","flippedV","flippedH","arrowSide","abs","arrowElement","arrowOnVerticalSide","arrowSize","sqrt","arrowOffset","popupArrowOffset","processArrow","maxHeight","innerWidth","ceil","arrowStyle","transform","boxShadow","Object","assign","atTop","atBottom","atLeft","atRight","fullHeight","fullWidth","useLayoutEffect","useEffect","addEventListener","passive","removeEventListener","onVerticalSide","arrowContainerWidth","popupSize","deltaPopupPosition","flipped","margin","invertDirection","percent","px","invertAndFlipDirection","arrowPosition","fromOriginCorner","popupOffset","arrowInitialPos","constrainedArrowPosition","arrowPositionRelativeToPopup","popupDelta","finalPopupPosition","React","createElement","ref","placeholderElement","as"],"mappings":";;;;;;;;AAOA,MAAMA,WAAW,GAAGC,MAAA,CAAAC,SAAA,CAAA,MAAA,CAAA,CAAA,CAAA;AACpB;AACA;AACA;AACA;AACA,CAAC,CAAA;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAMC,kBAAkB,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAA;AACtD,MAAMC,gBAAgB,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;AACpD,MAAMC,mBAAmB,GAAG;AAACC,EAAAA,IAAI,EAAE,GAAG;AAAEC,EAAAA,KAAK,EAAE,IAAI;AAAEC,EAAAA,GAAG,EAAE,GAAG;AAAEC,EAAAA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,0 +1,37 @@
1
+ export { Icon } from './Icon.mjs';
2
+ export { Loading } from './Loading.mjs';
3
+ export { Button, DropdownIcon } from './Button.mjs';
4
+ export { OnClickLoadingButton } from './alt/buttons/OnClickLoadingButton.mjs';
5
+ export { TextButton } from './TextButton.mjs';
6
+ export { LoadingDiv } from './LoadingDiv.mjs';
7
+ export { CloseIcon, ConfirmDialog, DefaultConfirmDialog, Dialog, DialogContent, DialogContentWrapper, DialogError, DialogErrorContent, DialogFooter, DialogIcon, DialogTitle, FooterAuxiliaryContainer } from './Dialog.mjs';
8
+ export { useDialog, useDialogWithToggle } from './useDialogWithToggle.mjs';
9
+ export { DefaultWarningDialog, WarningDialog, WarningDialogIcon, WarningDialogTitle, setWarningDialog, useWarningDialog } from './WarningDialog.mjs';
10
+ export { Notifications, setNotification, useNotification, useNotificationRef, willSetNotification } from './Notifications.mjs';
11
+ export { ToastNotifications, createToastNotification, useToastNotificationToggle, useToastNotifications, willShowToastNotification } from './ToastNotifications.mjs';
12
+ export { PersistentNotification, PersistentNotificationActions, PersistentNotificationCloseIcon, PersistentNotificationContent, PersistentNotificationIcon, PersistentNotifications, hidePersistentNotifications, openPersistentNotification, useIsHiddenPersistentNotifications } from './PersistentNotifications.mjs';
13
+ export { DefaultArrow, addPositioningBound, usePositioning } from './containers/usePositioning.mjs';
14
+ export { Reposition } from './containers/Reposition.mjs';
15
+ export { AnimatedModal, DialogContainer, Modal, ModalContainer, dialogFadeInDown, dialogModalIn, dialogModalOut, getDialogLayersSize, isFakeScrolled, preventDialogPop, removeWindowScroll, useDialogLayers, waitForPop } from './containers/DialogContainer.mjs';
16
+ export { DraggableContainer, DraggableItem, DroppableContainer } from './Draggable.mjs';
17
+ export { Popup } from './Popup.mjs';
18
+ export { Tooltip } from './Tooltip.mjs';
19
+ export { SplitColumnsContainer, fixDoubledLastMarginBottom } from './SplitColumnsContainer.mjs';
20
+ export { ContextListMenu, ContextMenu, ContextMenuComponent, Li, ListHeading, ListItem, ListMenu, ListSeparator, SimpleLi, StickyContainer, contextMenuLayersQuantity } from './ContextMenu.mjs';
21
+ export { ErrorBoundary } from './ErrorBoundary.mjs';
22
+ export { LoadingBar, PageLoader, SuspenseLoadingBar } from './PageLoader.mjs';
23
+ export { FillLastLineResizer } from './FillLastLineResizer.mjs';
24
+ export { defaultAnimationMaker, formatAnimation, getClientRectAnimation, morph, toPosition, useFlip, useFlipAnimation, useFlipEnter, useFlipLeave, willUseFlip, willUseFlipSwitch } from './Flip.mjs';
25
+ export { FlipList } from './FlipList.mjs';
26
+ export { AnimationBlockContainer, TransitionDiv } from './TransitionDiv.mjs';
27
+ export { SwitchDiv } from './SwitchDiv.mjs';
28
+ export { willUseIsSticky } from './willUseIsSticky.mjs';
29
+ export { FormatDate } from './FormatDate.mjs';
30
+ export { Image } from './Image.mjs';
31
+ export { DialogWithImageHeader } from './alt/dialogs/DialogWithImageHeader.mjs';
32
+ export { DialogTabMenu, DialogWithSidebar, DialogWithSidebarPresentation, MENU_TAB, SideMenu } from './alt/dialogs/DialogWithSidebar.mjs';
33
+ export { MobileBubbleDialog } from './alt/dialogs/MobileBubbleDialog.mjs';
34
+ export { HistoryLink, Link, Navigate, Route, Router, Routes, useAbsoluteLocation, useAbsolutePath, useLocation, useNavigate, useParams, useSearchParams } from './Link.mjs';
35
+ export { BasicBulletList } from './BasicBulletList.mjs';
36
+ export { useBrowserLocation } from 'wouter/use-browser-location';
37
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,18 @@
1
+ import { useToggle, useFill } from '@startlibs/core';
2
+
3
+ const useDialog = function (dialog) {
4
+ let args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
5
+ let toggleCallback = arguments.length > 2 ? arguments[2] : undefined;
6
+ const toggle = useToggle(false, toggleCallback);
7
+ useFill("Dialog", toggle.isOpen !== false && dialog(toggle.close), [toggle.isOpen, ...args]);
8
+ return toggle.open;
9
+ };
10
+ const useDialogWithToggle = function (dialog) {
11
+ let args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
12
+ const toggle = useToggle();
13
+ useFill("Dialog", toggle.isOpen !== false && dialog(toggle), [toggle.isOpen, ...args]);
14
+ return toggle;
15
+ };
16
+
17
+ export { useDialog, useDialogWithToggle };
18
+ //# sourceMappingURL=useDialogWithToggle.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDialogWithToggle.mjs","sources":["../src/useDialogWithToggle.jsx"],"sourcesContent":["import {useToggle,useFill} from '@startlibs/core'\n\nexport const useDialog = (dialog, args = [], toggleCallback) => {\n const toggle = useToggle(false,toggleCallback)\n useFill(\"Dialog\", toggle.isOpen !== false && dialog(toggle.close), [toggle.isOpen, ...args])\n return toggle.open\n}\nexport const useDialogWithToggle = (dialog, args = []) => {\n const toggle = useToggle()\n useFill(\"Dialog\", toggle.isOpen !== false && dialog(toggle), [toggle.isOpen, ...args])\n return toggle\n}"],"names":["useDialog","dialog","args","arguments","length","undefined","toggleCallback","toggle","useToggle","useFill","isOpen","close","open","useDialogWithToggle"],"mappings":";;MAEaA,SAAS,GAAG,UAACC,MAAM,EAAgC;AAAA,EAAA,IAA9BC,IAAI,GAAAC,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAG,EAAE,CAAA;EAAA,IAAEG,cAAc,GAAAH,SAAA,CAAAC,MAAA,GAAAD,CAAAA,GAAAA,SAAA,MAAAE,SAAA,CAAA;AACzD,EAAA,MAAME,MAAM,GAAGC,SAAS,CAAC,KAAK,EAACF,cAAc,CAAC,CAAA;EAC9CG,OAAO,CAAC,QAAQ,EAAEF,MAAM,CAACG,MAAM,KAAK,KAAK,IAAIT,MAAM,CAACM,MAAM,CAACI,KAAK,CAAC,EAAE,CAACJ,MAAM,CAACG,MAAM,EAAE,GAAGR,IAAI,CAAC,CAAC,CAAA;EAC5F,OAAOK,MAAM,CAACK,IAAI,CAAA;AACpB,EAAC;MACYC,mBAAmB,GAAG,UAACZ,MAAM,EAAgB;AAAA,EAAA,IAAdC,IAAI,GAAAC,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAE,SAAA,GAAAF,SAAA,CAAA,CAAA,CAAA,GAAG,EAAE,CAAA;AACnD,EAAA,MAAMI,MAAM,GAAGC,SAAS,EAAE,CAAA;EAC1BC,OAAO,CAAC,QAAQ,EAAEF,MAAM,CAACG,MAAM,KAAK,KAAK,IAAIT,MAAM,CAACM,MAAM,CAAC,EAAE,CAACA,MAAM,CAACG,MAAM,EAAE,GAAGR,IAAI,CAAC,CAAC,CAAA;AACtF,EAAA,OAAOK,MAAM,CAAA;AACf;;;;"}
@@ -0,0 +1,147 @@
1
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
+ import _without from 'lodash/fp/without';
3
+ import _identity from 'lodash/fp/identity';
4
+ import { yakDomTag } from '@startlibs/utils/yakDomTag';
5
+ import React, { useState, useEffect } from 'react';
6
+ import { willUseSharedCallback, willUseSharedState, useEnsureRef } from '@startlibs/core';
7
+ import { styled } from '@yak/react';
8
+ import { callIfFunction } from '@startlibs/utils';
9
+
10
+ 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; }
11
+ 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; }
12
+ const TOP_TRIGGER = (posInfo, refInfo) => {
13
+ // Started sticking.
14
+ if (posInfo.bottom < refInfo.top) {
15
+ return true;
16
+ }
17
+ // Stopped sticking.
18
+ if (posInfo.bottom >= refInfo.top && posInfo.bottom < refInfo.bottom) {
19
+ return false;
20
+ }
21
+ };
22
+ const BOTTOM_TRIGGER = (posInfo, refInfo) => {
23
+ // Started sticking.
24
+ if (posInfo.top > refInfo.bottom) {
25
+ return true;
26
+ }
27
+ if (posInfo.top <= refInfo.bottom && posInfo.top > refInfo.top) {
28
+ return false;
29
+ }
30
+ };
31
+ const SentinelStyle = styled(yakDomTag("div"))`
32
+ position:absolute;
33
+ visibility: hidden;
34
+ height:1px;
35
+ width: 1px;
36
+ `;
37
+
38
+ // addCss é texto livre de declarações CSS (ex.: Combobox.jsx em @startlibs/form passa
39
+ // "margin-top:-3px;"), decidido em tempo de execução pelo chamador — não dá pra virar
40
+ // `css\`\`` (precisaria do texto na hora do build) nem ficar como interpolação solta no
41
+ // template (R14: o yak ignora em silêncio uma função que devolve texto livre numa posição de
42
+ // declaração). Vira `style` inline nos dois modos: mesmo resultado visual, sem CSS-in-JS aqui.
43
+ const cssTextToStyle = text => {
44
+ const style = {};
45
+ for (const declaration of (text || '').split(';')) {
46
+ const colonIndex = declaration.indexOf(':');
47
+ if (colonIndex === -1) continue;
48
+ const property = declaration.slice(0, colonIndex).trim();
49
+ const value = declaration.slice(colonIndex + 1).trim();
50
+ if (!property || !value) continue;
51
+ // Custom property (--foo) mantém o nome; o resto vira camelCase (margin-top -> marginTop),
52
+ // igual ao que o React espera num objeto de `style`.
53
+ const camelProperty = property.startsWith('--') ? property : property.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
54
+ style[camelProperty] = value;
55
+ }
56
+ return Object.keys(style).length ? style : undefined;
57
+ };
58
+ const willUseIsSticky = function () {
59
+ let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
60
+ const [useRegister, onChange] = willUseSharedCallback();
61
+ const [useSharedIsSticky,, setSharedIsSticky] = willUseSharedState();
62
+ const createObserver = root => window.IntersectionObserver ? new window.IntersectionObserver((records, observer) => {
63
+ for (const record of records) {
64
+ const targetInfo = record.boundingClientRect;
65
+ const rootBoundsInfo = record.rootBounds;
66
+ if (!rootBoundsInfo) {
67
+ return;
68
+ }
69
+ onChange(targetInfo, rootBoundsInfo, record.target, record.isIntersecting);
70
+ }
71
+ }, _objectSpread({
72
+ root
73
+ }, options)) : {
74
+ observe: _identity,
75
+ unobserve: _identity
76
+ };
77
+ const observerMap = new Map();
78
+ const getObserver = function () {
79
+ let root = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
80
+ const result = observerMap.get(root);
81
+ if (result) {
82
+ return result;
83
+ }
84
+ const observer = createObserver(root);
85
+ observerMap.set(root, observer);
86
+ return observer;
87
+ };
88
+ let activeObserved = [];
89
+ const resetObservers = function () {
90
+ let root = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
91
+ const observer = getObserver(root);
92
+ activeObserved.forEach(observed => {
93
+ observer.unobserve(observed);
94
+ observer.observe(observed);
95
+ });
96
+ };
97
+ const WithIsSticky = /*#__PURE__*/React.forwardRef((_ref, ref) => {
98
+ let {
99
+ className,
100
+ id,
101
+ css,
102
+ children,
103
+ bottom,
104
+ root,
105
+ intersection,
106
+ onChange
107
+ } = _ref;
108
+ const ensuredRef = useEnsureRef(ref);
109
+ const [isSticky, setIsSticky] = useState(false);
110
+ useRegister((posInfo, refInfo, target, isIntersecting) => {
111
+ if (ensuredRef.current === target) {
112
+ const value = intersection ? isIntersecting : bottom ? BOTTOM_TRIGGER(posInfo, refInfo) : TOP_TRIGGER(posInfo, refInfo);
113
+ if (value !== undefined) {
114
+ setIsSticky(value);
115
+ callIfFunction(onChange, value);
116
+ if (!id) {
117
+ setSharedIsSticky(value);
118
+ } else if (value) {
119
+ setSharedIsSticky(id);
120
+ }
121
+ }
122
+ }
123
+ });
124
+ useEffect(() => {
125
+ setIsSticky(false);
126
+ getObserver(callIfFunction(root)).observe(ensuredRef.current);
127
+ activeObserved = activeObserved.concat(ensuredRef.current);
128
+ return () => {
129
+ // observer.unobserve(ref.current)
130
+ activeObserved = _without([ensuredRef.current], activeObserved);
131
+ };
132
+ }, []);
133
+ const renderSentinel = function () {
134
+ let css = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
135
+ return /*#__PURE__*/React.createElement(SentinelStyle, {
136
+ style: cssTextToStyle(css),
137
+ className: className,
138
+ ref: ensuredRef
139
+ });
140
+ };
141
+ return children ? children(renderSentinel, isSticky) : renderSentinel(css);
142
+ });
143
+ return [WithIsSticky, useSharedIsSticky, resetObservers];
144
+ };
145
+
146
+ export { willUseIsSticky };
147
+ //# sourceMappingURL=willUseIsSticky.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"willUseIsSticky.mjs","sources":["../src/willUseIsSticky.jsx"],"sourcesContent":["import React, {useEffect, useState} from 'react'\nimport {useEnsureRef, willUseSharedState, willUseSharedCallback} from '@startlibs/core'\nimport styled from 'styled-components'\nimport _ from 'lodash/fp'\nimport {callIfFunction} from '@startlibs/utils'\n\n\nconst TOP_TRIGGER = (posInfo,refInfo) => {\n // Started sticking.\n if (posInfo.bottom < refInfo.top) {\n return true\n }\n // Stopped sticking.\n if (posInfo.bottom >= refInfo.top &&\n posInfo.bottom < refInfo.bottom) {\n return false\n }\n}\nconst BOTTOM_TRIGGER = (posInfo,refInfo) => {\n // Started sticking.\n if (posInfo.top > refInfo.bottom) {\n return true\n }\n if (posInfo.top <= refInfo.bottom &&\n posInfo.top > refInfo.top) {\n return false\n }\n}\n\nconst SentinelStyle = styled.div`\n position:absolute;\n visibility: hidden;\n height:1px;\n width: 1px;\n`\n\n// addCss é texto livre de declarações CSS (ex.: Combobox.jsx em @startlibs/form passa\n// \"margin-top:-3px;\"), decidido em tempo de execução pelo chamador — não dá pra virar\n// `css\\`\\`` (precisaria do texto na hora do build) nem ficar como interpolação solta no\n// template (R14: o yak ignora em silêncio uma função que devolve texto livre numa posição de\n// declaração). Vira `style` inline nos dois modos: mesmo resultado visual, sem CSS-in-JS aqui.\nconst cssTextToStyle = (text) => {\n const style = {}\n for (const declaration of (text || '').split(';')) {\n const colonIndex = declaration.indexOf(':')\n if (colonIndex === -1) continue\n const property = declaration.slice(0, colonIndex).trim()\n const value = declaration.slice(colonIndex + 1).trim()\n if (!property || !value) continue\n // Custom property (--foo) mantém o nome; o resto vira camelCase (margin-top -> marginTop),\n // igual ao que o React espera num objeto de `style`.\n const camelProperty = property.startsWith('--') ? property : property.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase())\n style[camelProperty] = value\n }\n return Object.keys(style).length ? style : undefined\n}\n\nexport const willUseIsSticky = (options = {}) => {\n\n const [useRegister, onChange] = willUseSharedCallback()\n const [useSharedIsSticky,, setSharedIsSticky] = willUseSharedState()\n\n const createObserver = (root) => window.IntersectionObserver ? new window.IntersectionObserver((records, observer) => {\n for (const record of records) {\n const targetInfo = record.boundingClientRect\n const rootBoundsInfo = record.rootBounds\n if (!rootBoundsInfo) {\n return\n }\n onChange(targetInfo,rootBoundsInfo, record.target, record.isIntersecting)\n }\n },{root,...options}) : {observe:_.identity,unobserve:_.identity}\n\n const observerMap = new Map()\n const getObserver = (root = null) => {\n const result = observerMap.get(root)\n if (result) {\n return result\n }\n const observer = createObserver(root)\n observerMap.set(root,observer)\n return observer\n }\n \n let activeObserved = []\n const resetObservers = (root = null) => {\n const observer = getObserver(root)\n activeObserved.forEach((observed) => {\n observer.unobserve(observed)\n observer.observe(observed)\n })\n }\n\n const WithIsSticky = React.forwardRef(({className, id, css, children,bottom, root, intersection,onChange},ref) => {\n const ensuredRef = useEnsureRef(ref)\n const [isSticky,setIsSticky] = useState(false)\n\n useRegister((posInfo,refInfo,target, isIntersecting) => {\n if (ensuredRef.current === target) {\n const value = intersection ? isIntersecting : (bottom ? BOTTOM_TRIGGER(posInfo,refInfo) : TOP_TRIGGER(posInfo,refInfo))\n if (value!==undefined) {\n setIsSticky(value)\n callIfFunction(onChange,value)\n if (!id) {\n setSharedIsSticky(value)\n } else if (value) {\n setSharedIsSticky(id)\n }\n }\n }\n })\n\n useEffect(() => {\n setIsSticky(false)\n getObserver(callIfFunction(root)).observe(ensuredRef.current)\n activeObserved = activeObserved.concat(ensuredRef.current)\n return () => {\n // observer.unobserve(ref.current)\n activeObserved = _.without([ensuredRef.current],activeObserved)\n }\n },[])\n\n const renderSentinel = (css = \"\") => <SentinelStyle style={cssTextToStyle(css)} className={className} ref={ensuredRef} />\n\n return children\n ? children(renderSentinel,isSticky)\n : renderSentinel(css)\n\n })\n\n\n return [WithIsSticky, useSharedIsSticky, resetObservers]\n}"],"names":["TOP_TRIGGER","posInfo","refInfo","bottom","top","BOTTOM_TRIGGER","SentinelStyle","styled","yakDomTag","cssTextToStyle","text","style","declaration","split","colonIndex","indexOf","property","slice","trim","value","camelProperty","startsWith","replace","_","letter","toUpperCase","Object","keys","length","undefined","willUseIsSticky","options","arguments","useRegister","onChange","willUseSharedCallback","useSharedIsSticky","setSharedIsSticky","willUseSharedState","createObserver","root","window","IntersectionObserver","records","observer","record","targetInfo","boundingClientRect","rootBoundsInfo","rootBounds","target","isIntersecting","_objectSpread","observe","_identity","unobserve","observerMap","Map","getObserver","result","get","set","activeObserved","resetObservers","forEach","observed","WithIsSticky","React","forwardRef","_ref","ref","className","id","css","children","intersection","ensuredRef","useEnsureRef","isSticky","setIsSticky","useState","current","callIfFunction","useEffect","concat","_without","renderSentinel","createElement"],"mappings":";;;;;;;;;;;AAOA,MAAMA,WAAW,GAAGA,CAACC,OAAO,EAACC,OAAO,KAAK;AACvC;AACA,EAAA,IAAID,OAAO,CAACE,MAAM,GAAGD,OAAO,CAACE,GAAG,EAAE;AAChC,IAAA,OAAO,IAAI,CAAA;AACb,GAAA;AACA;AACA,EAAA,IAAIH,OAAO,CAACE,MAAM,IAAID,OAAO,CAACE,GAAG,IAC/BH,OA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