@semcore/base-components 17.0.0-prerelease.36 → 17.0.0-prerelease.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -2
- package/lib/cjs/components/popper/Popper.js +3 -2
- package/lib/cjs/components/popper/Popper.js.map +1 -1
- package/lib/cjs/components/scroll-area/ScrollBar.js +8 -0
- package/lib/cjs/components/scroll-area/ScrollBar.js.map +1 -1
- package/lib/es6/components/popper/Popper.js +2 -1
- package/lib/es6/components/popper/Popper.js.map +1 -1
- package/lib/es6/components/scroll-area/ScrollBar.js +8 -0
- package/lib/es6/components/scroll-area/ScrollBar.js.map +1 -1
- package/lib/esm/components/animation/Animation.mjs +2 -2
- package/lib/esm/components/animation/Collapse.mjs +1 -2
- package/lib/esm/components/animation/FadeInOut.mjs +1 -2
- package/lib/esm/components/animation/Scale.mjs +1 -2
- package/lib/esm/components/animation/Slide.mjs +1 -2
- package/lib/esm/components/animation/Transform.mjs +1 -2
- package/lib/esm/components/animation/index.mjs +15 -0
- package/lib/esm/components/ellipsis/Ellipsis.mjs +6 -6
- package/lib/esm/components/ellipsis/EllipsisManager.mjs +20 -24
- package/lib/esm/components/ellipsis/Queue.mjs +2 -3
- package/lib/esm/components/ellipsis/index.mjs +4 -0
- package/lib/esm/components/flex-box/Box/useBox.mjs +0 -1
- package/lib/esm/components/flex-box/Flex/useFlex.mjs +0 -1
- package/lib/esm/components/flex-box/index.mjs +14 -0
- package/lib/esm/components/flex-box/invalid-state-box/InvalidStateBox.mjs +4 -3
- package/lib/esm/components/flex-box/screen-reader-only-box/ScreenReaderOnlyBox.mjs +4 -3
- package/lib/esm/components/grid/Grid.mjs +2 -2
- package/lib/esm/components/hint/Hint.mjs +6 -7
- package/lib/esm/components/hint/index.mjs +4 -0
- package/lib/esm/components/neighbor-location/NeighborLocation.mjs +2 -2
- package/lib/esm/components/neighbor-location/index.mjs +6 -0
- package/lib/esm/components/outside-click/OutsideClick.mjs +9 -9
- package/lib/esm/components/outside-click/index.mjs +4 -0
- package/lib/esm/components/popper/Popper.mjs +28 -31
- package/lib/esm/components/popper/arrowOffset.mjs +1 -2
- package/lib/esm/components/popper/createPopper.mjs +1 -1
- package/lib/esm/components/popper/index.mjs +5 -0
- package/lib/esm/components/popper/modifiers/applyMaxSize.mjs +1 -1
- package/lib/esm/components/popper/modifiers/cursorAnchoring.mjs +2 -3
- package/lib/esm/components/portal/Portal.mjs +2 -2
- package/lib/esm/components/portal/index.mjs +6 -0
- package/lib/esm/components/scroll-area/ScrollArea.mjs +13 -16
- package/lib/esm/components/scroll-area/ScrollBar.mjs +8 -5
- package/lib/esm/components/scroll-area/index.mjs +7 -0
- package/lib/esm/index.mjs +33 -24
- package/package.json +4 -4
|
@@ -31,11 +31,10 @@ class EllipsisManager {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
addEllipsis(ellipsis) {
|
|
34
|
-
var _a;
|
|
35
34
|
const element = ellipsis.element;
|
|
36
35
|
if (!this.ellipsisEntities.has(element)) {
|
|
37
36
|
this.ellipsisEntities.set(element, ellipsis);
|
|
38
|
-
|
|
37
|
+
this.io?.observe(element);
|
|
39
38
|
if (ellipsis.observeChildrenMutations && canUseDOM()) {
|
|
40
39
|
const mo = new MutationObserver(this.handleMutationObserver);
|
|
41
40
|
mo.observe(element, {
|
|
@@ -54,14 +53,13 @@ class EllipsisManager {
|
|
|
54
53
|
}
|
|
55
54
|
}
|
|
56
55
|
removeEllipsis(ellipsis) {
|
|
57
|
-
var _a, _b, _c;
|
|
58
56
|
const element = ellipsis.element;
|
|
59
57
|
if (this.ellipsisEntities.has(element)) {
|
|
60
58
|
this.ellipsisEntities.delete(element);
|
|
61
59
|
this.handledElements.delete(element);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
this.io?.unobserve(element);
|
|
61
|
+
this.ro?.unobserve(element);
|
|
62
|
+
this.ellipsisMutationObservers.get(element)?.disconnect();
|
|
65
63
|
this.ellipsisMutationObservers.delete(element);
|
|
66
64
|
}
|
|
67
65
|
if (ellipsis.containerElement) {
|
|
@@ -121,31 +119,30 @@ class EllipsisManager {
|
|
|
121
119
|
text = addedNodes[0];
|
|
122
120
|
}
|
|
123
121
|
}
|
|
124
|
-
const parent = text
|
|
122
|
+
const parent = text?.parentElement;
|
|
125
123
|
if (text && parent instanceof HTMLElement) {
|
|
126
124
|
const ellipsis = this.ellipsisEntities.get(parent);
|
|
127
125
|
if (ellipsis) {
|
|
128
126
|
ellipsis.textContent = text.wholeText;
|
|
129
|
-
ellipsis
|
|
127
|
+
ellipsis?.scheduler.schedule(ellipsis?.handleChanges);
|
|
130
128
|
}
|
|
131
129
|
}
|
|
132
130
|
}
|
|
133
131
|
}
|
|
134
132
|
handleIntersectionObserver(entries) {
|
|
135
133
|
entries.forEach((entry) => {
|
|
136
|
-
var _a, _b, _c, _d;
|
|
137
134
|
const target = entry.target;
|
|
138
135
|
if (target instanceof HTMLElement) {
|
|
139
136
|
if (entry.isIntersecting === true && !this.handledElements.has(target)) {
|
|
140
137
|
const ellipsis = this.ellipsisEntities.get(target);
|
|
141
|
-
if (
|
|
142
|
-
|
|
138
|
+
if (ellipsis?.containerElement !== void 0) {
|
|
139
|
+
this.ro?.observe(ellipsis?.containerElement);
|
|
143
140
|
if (ellipsis.cropPosition === "middle") {
|
|
144
141
|
this.setApproximateSize(target, ellipsis);
|
|
145
142
|
}
|
|
146
143
|
this.queue.add(ellipsis.handleChanges);
|
|
147
144
|
} else {
|
|
148
|
-
|
|
145
|
+
this.ro?.observe(target);
|
|
149
146
|
}
|
|
150
147
|
this.handledElements.add(target);
|
|
151
148
|
} else if (entry.isIntersecting === false && this.handledElements.has(target)) {
|
|
@@ -154,8 +151,8 @@ class EllipsisManager {
|
|
|
154
151
|
this.queue.delete(ellipsis.handleChanges);
|
|
155
152
|
}
|
|
156
153
|
this.handledElements.delete(target);
|
|
157
|
-
|
|
158
|
-
|
|
154
|
+
this.ro?.unobserve(target);
|
|
155
|
+
this.ellipsisMutationObservers.get(target)?.disconnect();
|
|
159
156
|
}
|
|
160
157
|
}
|
|
161
158
|
});
|
|
@@ -163,11 +160,10 @@ class EllipsisManager {
|
|
|
163
160
|
setApproximateSize(container, ellipsis) {
|
|
164
161
|
const approximateSize = this.containersApproximateSizeMap.get(container);
|
|
165
162
|
if (approximateSize && ellipsis.textContent.length > approximateSize[0] + approximateSize[1]) {
|
|
166
|
-
ellipsis.element.textContent =
|
|
163
|
+
ellipsis.element.textContent = ellipsis?.textContent.slice(0, approximateSize[0]) + "..." + ellipsis?.textContent.slice(-1 * approximateSize[1]);
|
|
167
164
|
}
|
|
168
165
|
}
|
|
169
166
|
handleCopy(event) {
|
|
170
|
-
var _a, _b, _c;
|
|
171
167
|
if (event instanceof ClipboardEvent && event.target instanceof HTMLElement && event.target.parentElement instanceof HTMLElement) {
|
|
172
168
|
const selection = window.getSelection();
|
|
173
169
|
let ellipsis = this.ellipsisEntities.get(event.target);
|
|
@@ -179,17 +175,17 @@ class EllipsisManager {
|
|
|
179
175
|
const croppedSpan = ellipsisSpans[0];
|
|
180
176
|
const lastSpan = ellipsisSpans[ellipsisSpans.length - 2];
|
|
181
177
|
const fullSpan = ellipsisSpans[ellipsisSpans.length - 1];
|
|
182
|
-
const croppedLength =
|
|
183
|
-
const lastLength =
|
|
184
|
-
const anchorInCropped = selection.anchorNode ===
|
|
185
|
-
const anchorInLast = selection.anchorNode ===
|
|
186
|
-
const focusInCropped = selection.focusNode ===
|
|
187
|
-
const focusInLast = selection.focusNode ===
|
|
178
|
+
const croppedLength = croppedSpan?.textContent?.length;
|
|
179
|
+
const lastLength = lastSpan?.textContent?.length;
|
|
180
|
+
const anchorInCropped = selection.anchorNode === croppedSpan?.childNodes[0];
|
|
181
|
+
const anchorInLast = selection.anchorNode === lastSpan?.childNodes[0];
|
|
182
|
+
const focusInCropped = selection.focusNode === croppedSpan?.childNodes[0];
|
|
183
|
+
const focusInLast = selection.focusNode === lastSpan?.childNodes[0];
|
|
188
184
|
const anchorOffset = selection.anchorOffset;
|
|
189
185
|
const focusOffset = selection.focusOffset;
|
|
190
186
|
const isCroppedSelected = anchorInCropped && focusOffset === croppedLength || anchorInLast && anchorOffset === lastLength && focusInCropped && focusOffset === 0 || focusInLast && focusOffset === lastLength;
|
|
191
|
-
const isFullSelected = selection.focusNode ===
|
|
192
|
-
if (
|
|
187
|
+
const isFullSelected = selection.focusNode === fullSpan?.childNodes[0] && focusOffset === fullSpan?.textContent?.length;
|
|
188
|
+
if (fullSpan?.textContent && (!(selection.focusNode instanceof Text) || isCroppedSelected || isFullSelected)) {
|
|
193
189
|
event.preventDefault();
|
|
194
190
|
navigator.clipboard.writeText(fullSpan.textContent);
|
|
195
191
|
}
|
|
@@ -5,7 +5,7 @@ class Queue {
|
|
|
5
5
|
_defineProperty(this, "queue", /* @__PURE__ */ new Set());
|
|
6
6
|
_defineProperty(this, "queueTimeout", 0);
|
|
7
7
|
_defineProperty(this, "processQueueTick", null);
|
|
8
|
-
if (options
|
|
8
|
+
if (options?.queueTimeout) {
|
|
9
9
|
this.queueTimeout = options.queueTimeout;
|
|
10
10
|
}
|
|
11
11
|
this.processQueue = this.processQueue.bind(this);
|
|
@@ -21,7 +21,6 @@ class Queue {
|
|
|
21
21
|
this.queue.delete(task);
|
|
22
22
|
}
|
|
23
23
|
processQueue() {
|
|
24
|
-
var _a;
|
|
25
24
|
const nextTask = this.queue.values().next().value;
|
|
26
25
|
if (nextTask) {
|
|
27
26
|
this.queue.delete(nextTask);
|
|
@@ -29,7 +28,7 @@ class Queue {
|
|
|
29
28
|
this.processQueueTick = new Scheduler();
|
|
30
29
|
this.processQueueTick.schedule(this.processQueue, this.queueTimeout === 0 ? void 0 : this.queueTimeout);
|
|
31
30
|
} else {
|
|
32
|
-
|
|
31
|
+
this.processQueueTick?.cancel();
|
|
33
32
|
this.processQueueTick = null;
|
|
34
33
|
}
|
|
35
34
|
}
|
|
@@ -3,7 +3,6 @@ import { removeUndefinedKeys, getAutoOrScaleIndent, getSize } from "@semcore/cor
|
|
|
3
3
|
import propsForElement from "@semcore/core/lib/utils/propsForElement";
|
|
4
4
|
import cn from "classnames";
|
|
5
5
|
import React from "react";
|
|
6
|
-
/*!__reshadow-styles__:"../style/use-box.shadow.css"*/
|
|
7
6
|
const style = (
|
|
8
7
|
/*__reshadow_css_start__*/
|
|
9
8
|
(sstyled.insert(
|
|
@@ -3,7 +3,6 @@ import { removeUndefinedKeys, getAutoOrScaleIndent } from "@semcore/core/lib/uti
|
|
|
3
3
|
import cn from "classnames";
|
|
4
4
|
import React from "react";
|
|
5
5
|
import useBox from "../Box/useBox.mjs";
|
|
6
|
-
/*!__reshadow-styles__:"../style/use-flex.shadow.css"*/
|
|
7
6
|
const style = (
|
|
8
7
|
/*__reshadow_css_start__*/
|
|
9
8
|
(sstyled.insert(
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { default as default2 } from "./Box/index.mjs";
|
|
2
|
+
import { default as default3 } from "./Box/useBox.mjs";
|
|
3
|
+
import { default as default4 } from "./Flex/index.mjs";
|
|
4
|
+
import { default as default5 } from "./Flex/useFlex.mjs";
|
|
5
|
+
import { InvalidStateBox } from "./invalid-state-box/InvalidStateBox.mjs";
|
|
6
|
+
import { ScreenReaderOnly } from "./screen-reader-only-box/ScreenReaderOnlyBox.mjs";
|
|
7
|
+
export {
|
|
8
|
+
default2 as Box,
|
|
9
|
+
default4 as Flex,
|
|
10
|
+
InvalidStateBox,
|
|
11
|
+
ScreenReaderOnly,
|
|
12
|
+
default3 as useBox,
|
|
13
|
+
default5 as useFlex
|
|
14
|
+
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { sstyled, assignProps, createComponent } from "@semcore/core";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import Box from "../Box/index.mjs";
|
|
4
|
-
/*!__reshadow-styles__:"./invalidStateBox.shadow.css"*/
|
|
5
4
|
const style = (
|
|
6
5
|
/*__reshadow_css_start__*/
|
|
7
6
|
(sstyled.insert(
|
|
@@ -21,7 +20,9 @@ function InvalidStatePatternComponent() {
|
|
|
21
20
|
...assignProps({}, _ref)
|
|
22
21
|
}));
|
|
23
22
|
}
|
|
23
|
+
;
|
|
24
24
|
const InvalidStateBox = createComponent(InvalidStatePatternComponent);
|
|
25
25
|
export {
|
|
26
|
-
InvalidStateBox
|
|
26
|
+
InvalidStateBox,
|
|
27
|
+
InvalidStateBox as default
|
|
27
28
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { sstyled, assignProps, createComponent } from "@semcore/core";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import Box from "../Box/index.mjs";
|
|
4
|
-
/*!__reshadow-styles__:"./screenReaderOnlyBox.shadow.css"*/
|
|
5
4
|
const style = (
|
|
6
5
|
/*__reshadow_css_start__*/
|
|
7
6
|
(sstyled.insert(
|
|
@@ -23,7 +22,9 @@ function ScreenReaderOnlyComponent() {
|
|
|
23
22
|
}, _ref)
|
|
24
23
|
}));
|
|
25
24
|
}
|
|
25
|
+
;
|
|
26
26
|
const ScreenReaderOnly = createComponent(ScreenReaderOnlyComponent);
|
|
27
27
|
export {
|
|
28
|
-
ScreenReaderOnly
|
|
28
|
+
ScreenReaderOnly,
|
|
29
|
+
ScreenReaderOnly as default
|
|
29
30
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import {
|
|
2
|
+
import { sstyled, Component, assignProps, createComponent } from "@semcore/core";
|
|
3
3
|
import React from "react";
|
|
4
|
+
import "../flex-box/index.mjs";
|
|
4
5
|
import Flex from "../flex-box/Flex/index.mjs";
|
|
5
6
|
import Box from "../flex-box/Box/index.mjs";
|
|
6
|
-
/*!__reshadow-styles__:"./style/grid.shadow.css"*/
|
|
7
7
|
const style = (
|
|
8
8
|
/*__reshadow_css_start__*/
|
|
9
9
|
(sstyled.insert(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import {
|
|
2
|
+
import { sstyled, Component, lastInteraction, assignProps, createComponent } from "@semcore/core";
|
|
3
3
|
import { offset, flip, shift, computePosition } from "@floating-ui/dom";
|
|
4
4
|
import canUseDOM from "@semcore/core/lib/utils/canUseDOM";
|
|
5
5
|
import { getAccessibleName } from "@semcore/core/lib/utils/getAccessibleName";
|
|
@@ -7,9 +7,10 @@ import { cssVariableEnhance } from "@semcore/core/lib/utils/useCssVariable";
|
|
|
7
7
|
import { zIndexStackingEnhance } from "@semcore/core/lib/utils/zIndexStacking";
|
|
8
8
|
import React from "react";
|
|
9
9
|
import { Middleware } from "./Middleware.mjs";
|
|
10
|
-
import
|
|
10
|
+
import "../flex-box/index.mjs";
|
|
11
|
+
import "../portal/index.mjs";
|
|
11
12
|
import Box from "../flex-box/Box/index.mjs";
|
|
12
|
-
|
|
13
|
+
import Portal from "../portal/Portal.mjs";
|
|
13
14
|
const keyframes = (
|
|
14
15
|
/*__reshadow_css_start__*/
|
|
15
16
|
(sstyled.insert(
|
|
@@ -48,7 +49,6 @@ const keyframes = (
|
|
|
48
49
|
"@transform-exit": "transform-exit_1ns4f"
|
|
49
50
|
})
|
|
50
51
|
);
|
|
51
|
-
/*!__reshadow-styles__:"./style/hint.shadow.css"*/
|
|
52
52
|
const styles = (
|
|
53
53
|
/*__reshadow_css_start__*/
|
|
54
54
|
(sstyled.insert(
|
|
@@ -273,14 +273,13 @@ class HintPopperRoot extends Component {
|
|
|
273
273
|
children
|
|
274
274
|
} = this.asProps;
|
|
275
275
|
requestAnimationFrame(() => {
|
|
276
|
-
var _a, _b;
|
|
277
276
|
const trigger = triggerRef.current;
|
|
278
277
|
if (trigger) {
|
|
279
278
|
const textContent = trigger.textContent;
|
|
280
279
|
const ariaLabel = getAccessibleName(trigger);
|
|
281
280
|
if (!textContent && !ariaLabel) {
|
|
282
|
-
const label = typeof children === "string" || typeof children === "number" ? children.toString() :
|
|
283
|
-
|
|
281
|
+
const label = typeof children === "string" || typeof children === "number" ? children.toString() : this.hintRef.current?.textContent ?? "";
|
|
282
|
+
triggerRef.current?.setAttribute("aria-label", label);
|
|
284
283
|
}
|
|
285
284
|
}
|
|
286
285
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import {
|
|
2
|
+
import { register, Component, assignProps, createComponent } from "@semcore/core";
|
|
3
3
|
import getOriginChildren from "@semcore/core/lib/utils/getOriginChildren";
|
|
4
4
|
import isNode from "@semcore/core/lib/utils/isNode";
|
|
5
5
|
import React from "react";
|
|
@@ -86,7 +86,7 @@ function useNeighborLocationDetect(index) {
|
|
|
86
86
|
const {
|
|
87
87
|
controlsLengthRef
|
|
88
88
|
} = React.useContext(Context);
|
|
89
|
-
if (
|
|
89
|
+
if (controlsLengthRef?.current === null || controlsLengthRef?.current === void 0) return false;
|
|
90
90
|
return calculateNeighborLocation(controlsLengthRef.current, index);
|
|
91
91
|
}
|
|
92
92
|
const NeighborLocation = createComponent(NeighborLocationRoot, {
|
|
@@ -20,17 +20,17 @@ function OutsideClickRoot(props) {
|
|
|
20
20
|
const mouseDownInside = React.useRef(false);
|
|
21
21
|
const handleRef = useForkRef(children ? children.ref : null, nodeRef, forwardRef);
|
|
22
22
|
const handleOutsideClick = useEventCallback((event) => {
|
|
23
|
-
const nodesToCheck = [...excludeRefs, nodeRef].map((ref) => ref
|
|
23
|
+
const nodesToCheck = [...excludeRefs, nodeRef].map((ref) => ref?.current);
|
|
24
24
|
const eventTarget = getEventTarget(event);
|
|
25
|
-
const isTargetEvent = nodesToCheck.some((node) => mouseDownInside.current ||
|
|
25
|
+
const isTargetEvent = nodesToCheck.some((node) => mouseDownInside.current || node?.contains(eventTarget));
|
|
26
26
|
if (!isTargetEvent) {
|
|
27
|
-
onOutsideClick
|
|
27
|
+
onOutsideClick?.(event);
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
30
|
const handleMouseDown = useEventCallback((event) => {
|
|
31
|
-
const nodesToCheck = [...excludeRefs, nodeRef].map((ref) => ref
|
|
31
|
+
const nodesToCheck = [...excludeRefs, nodeRef].map((ref) => ref?.current);
|
|
32
32
|
const eventTarget = getEventTarget(event);
|
|
33
|
-
mouseDownInside.current = nodesToCheck.some((node) => node
|
|
33
|
+
mouseDownInside.current = nodesToCheck.some((node) => node?.contains(eventTarget));
|
|
34
34
|
});
|
|
35
35
|
const toggleEvents = (status, outsideRoot) => {
|
|
36
36
|
const isModalRoot = outsideRoot instanceof HTMLElement && outsideRoot.dataset.uiName === "Modal.Overlay";
|
|
@@ -47,8 +47,8 @@ function OutsideClickRoot(props) {
|
|
|
47
47
|
React.useEffect(() => {
|
|
48
48
|
const outsideRoot = root ? root.current : ownerDocument(nodeRef.current);
|
|
49
49
|
toggleEvents(false, outsideRoot);
|
|
50
|
-
outsideRoot
|
|
51
|
-
outsideRoot
|
|
50
|
+
outsideRoot?.addEventListener("mouseup", handleOutsideClick, true);
|
|
51
|
+
outsideRoot?.addEventListener("mousedown", handleMouseDown, true);
|
|
52
52
|
if (outsideRoot) {
|
|
53
53
|
OutsideClickRoot.eventsMap.push([outsideRoot, {
|
|
54
54
|
mouseup: handleOutsideClick,
|
|
@@ -59,8 +59,8 @@ function OutsideClickRoot(props) {
|
|
|
59
59
|
if (outsideRoot) {
|
|
60
60
|
OutsideClickRoot.eventsMap.pop();
|
|
61
61
|
}
|
|
62
|
-
outsideRoot
|
|
63
|
-
outsideRoot
|
|
62
|
+
outsideRoot?.removeEventListener("mouseup", handleOutsideClick, true);
|
|
63
|
+
outsideRoot?.removeEventListener("mousedown", handleMouseDown, true);
|
|
64
64
|
toggleEvents(true, outsideRoot);
|
|
65
65
|
};
|
|
66
66
|
}, [root]);
|
|
@@ -1,25 +1,30 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import {
|
|
2
|
+
import { sstyled, Component, lastInteraction, assignProps, createComponent } from "@semcore/core";
|
|
3
3
|
import { callAllEventHandlers } from "@semcore/core/lib/utils/assignProps";
|
|
4
4
|
import canUseDOM from "@semcore/core/lib/utils/canUseDOM";
|
|
5
5
|
import { hasParent } from "@semcore/core/lib/utils/hasParent";
|
|
6
6
|
import logger from "@semcore/core/lib/utils/logger";
|
|
7
7
|
import pick from "@semcore/core/lib/utils/pick";
|
|
8
|
-
import {
|
|
8
|
+
import { forkRef } from "@semcore/core/lib/utils/ref";
|
|
9
|
+
import setRef from "@semcore/core/lib/utils/setRef";
|
|
9
10
|
import { useContextTheme } from "@semcore/core/lib/utils/ThemeProvider";
|
|
10
11
|
import uniqueIDEnhancement from "@semcore/core/lib/utils/uniqueID";
|
|
11
|
-
import {
|
|
12
|
+
import { isFocusInside, setFocus, makeFocusLockSyntheticEvent, useFocusLock } from "@semcore/core/lib/utils/use/useFocusLock";
|
|
12
13
|
import { cssVariableEnhance } from "@semcore/core/lib/utils/useCssVariable";
|
|
13
14
|
import { useZIndexStacking, ZIndexStackingContextProvider } from "@semcore/core/lib/utils/zIndexStacking";
|
|
14
15
|
import React from "react";
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
16
|
+
import "../animation/index.mjs";
|
|
17
|
+
import "../flex-box/index.mjs";
|
|
18
|
+
import "../neighbor-location/index.mjs";
|
|
19
|
+
import "../outside-click/index.mjs";
|
|
20
|
+
import "../portal/index.mjs";
|
|
18
21
|
import createPopper from "./createPopper.mjs";
|
|
19
|
-
import {
|
|
20
|
-
import Scale from "../animation/Scale.mjs";
|
|
22
|
+
import { OutsideClick } from "../outside-click/OutsideClick.mjs";
|
|
21
23
|
import Box from "../flex-box/Box/index.mjs";
|
|
22
|
-
|
|
24
|
+
import Scale from "../animation/Scale.mjs";
|
|
25
|
+
import { animationContext } from "../animation/Animation.mjs";
|
|
26
|
+
import Portal, { PortalProvider } from "../portal/Portal.mjs";
|
|
27
|
+
import { NeighborLocation } from "../neighbor-location/NeighborLocation.mjs";
|
|
23
28
|
const style = (
|
|
24
29
|
/*__reshadow_css_start__*/
|
|
25
30
|
(sstyled.insert(
|
|
@@ -46,19 +51,17 @@ function someArray(arr1, arr2) {
|
|
|
46
51
|
const useUpdatePopperEveryFrame = (popperRef) => {
|
|
47
52
|
const nextAnimationFrameRef = React.useRef(-1);
|
|
48
53
|
const handleAnimationFrame = React.useCallback((until) => {
|
|
49
|
-
var _a;
|
|
50
54
|
if (until < Date.now()) return;
|
|
51
|
-
|
|
55
|
+
popperRef.current?.update();
|
|
52
56
|
nextAnimationFrameRef.current = requestAnimationFrame(() => handleAnimationFrame(until));
|
|
53
57
|
}, []);
|
|
54
58
|
React.useEffect(() => () => cancelAnimationFrame(nextAnimationFrameRef.current), []);
|
|
55
59
|
return handleAnimationFrame;
|
|
56
60
|
};
|
|
57
61
|
const isInputTriggerTag = (tag) => {
|
|
58
|
-
var _a;
|
|
59
62
|
if (typeof tag === "string") return tag.toLowerCase().includes("input");
|
|
60
63
|
if (typeof tag === "object" && tag !== null && typeof tag.displayName === "string") return tag.displayName.toLowerCase().includes("input");
|
|
61
|
-
if (typeof tag === "object" && tag !== null && typeof
|
|
64
|
+
if (typeof tag === "object" && tag !== null && typeof tag.render?.displayName === "string") return tag.render.displayName.toLowerCase().includes("input");
|
|
62
65
|
return false;
|
|
63
66
|
};
|
|
64
67
|
let mouseMoveListenerAdded = false;
|
|
@@ -162,15 +165,14 @@ class PopperRoot extends Component {
|
|
|
162
165
|
placement,
|
|
163
166
|
strategy,
|
|
164
167
|
onFirstUpdate: callAllEventHandlers(onFirstUpdate, () => {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
(_b = this.observer) == null ? void 0 : _b.observe(this.popperRef.current);
|
|
168
|
+
this.observer?.observe(this.triggerRef.current);
|
|
169
|
+
this.observer?.observe(this.popperRef.current);
|
|
168
170
|
if (this.asProps.disablePortal) return;
|
|
169
|
-
let parent =
|
|
171
|
+
let parent = this.popperRef.current?.parentElement;
|
|
170
172
|
const traversingLimit = 10;
|
|
171
173
|
for (let i = 0; i < traversingLimit; i++) {
|
|
172
174
|
if (!parent) break;
|
|
173
|
-
|
|
175
|
+
this.observer?.observe(parent);
|
|
174
176
|
if (parent === document.body) break;
|
|
175
177
|
parent = parent.parentElement;
|
|
176
178
|
}
|
|
@@ -203,7 +205,7 @@ class PopperRoot extends Component {
|
|
|
203
205
|
}
|
|
204
206
|
if (component === "trigger" && action === "onClick" && e.target instanceof HTMLElement) {
|
|
205
207
|
const triggerClick = hasParent(e.target, trigger);
|
|
206
|
-
const associatedLabels = [...
|
|
208
|
+
const associatedLabels = [...trigger?.labels || []];
|
|
207
209
|
const popperInsideOfLabel = associatedLabels.some((label) => hasParent(this.popperRef.current, label));
|
|
208
210
|
if (triggerClick && popperInsideOfLabel && Date.now() - this.lastPopperClick < 100) {
|
|
209
211
|
return;
|
|
@@ -223,12 +225,12 @@ class PopperRoot extends Component {
|
|
|
223
225
|
if (!visible) {
|
|
224
226
|
setTimeout(() => {
|
|
225
227
|
const node = this.popperRef.current;
|
|
226
|
-
if (
|
|
228
|
+
if (node?.getAttribute("tabindex") === "0") {
|
|
227
229
|
node.setAttribute("tabindex", "-1");
|
|
228
230
|
}
|
|
229
231
|
}, 0);
|
|
230
232
|
}
|
|
231
|
-
const target = e
|
|
233
|
+
const target = e?.currentTarget;
|
|
232
234
|
if (component === "trigger" && target && target instanceof HTMLElement) {
|
|
233
235
|
this.lastPopperReference = target;
|
|
234
236
|
}
|
|
@@ -282,8 +284,7 @@ class PopperRoot extends Component {
|
|
|
282
284
|
if (canUseDOM()) {
|
|
283
285
|
this.observer = new ResizeObserver(() => {
|
|
284
286
|
requestAnimationFrame(() => {
|
|
285
|
-
|
|
286
|
-
(_a = this.popper.current) == null ? void 0 : _a.update();
|
|
287
|
+
this.popper.current?.update();
|
|
287
288
|
});
|
|
288
289
|
});
|
|
289
290
|
}
|
|
@@ -294,10 +295,9 @@ class PopperRoot extends Component {
|
|
|
294
295
|
};
|
|
295
296
|
}
|
|
296
297
|
createPopper() {
|
|
297
|
-
var _a;
|
|
298
298
|
if (!this.triggerRef.current || !this.popperRef.current) return;
|
|
299
299
|
if (this.asProps.__disablePopper) return;
|
|
300
|
-
const lastPopperReferenceMounted = Boolean(
|
|
300
|
+
const lastPopperReferenceMounted = Boolean(this.lastPopperReference?.parentElement);
|
|
301
301
|
this.popper.current = createPopper(lastPopperReferenceMounted ? this.lastPopperReference : this.triggerRef.current, this.popperRef.current, this.getPopperOptions());
|
|
302
302
|
}
|
|
303
303
|
componentDidMount() {
|
|
@@ -318,10 +318,9 @@ class PopperRoot extends Component {
|
|
|
318
318
|
}
|
|
319
319
|
}
|
|
320
320
|
destroyPopper() {
|
|
321
|
-
var _a;
|
|
322
321
|
clearTimeout(this.timer);
|
|
323
322
|
clearTimeout(this.timerMultiTrigger);
|
|
324
|
-
|
|
323
|
+
this.observer?.disconnect();
|
|
325
324
|
if (this.popper.current) {
|
|
326
325
|
this.popper.current.destroy();
|
|
327
326
|
this.popper.current = null;
|
|
@@ -512,9 +511,8 @@ function PopperPopper(props) {
|
|
|
512
511
|
event.stopPropagation();
|
|
513
512
|
}, []);
|
|
514
513
|
const propagateFocusLockSyntheticEvent = React.useCallback((event) => {
|
|
515
|
-
var _a;
|
|
516
514
|
event.stopPropagation();
|
|
517
|
-
|
|
515
|
+
ref.current?.dispatchEvent(makeFocusLockSyntheticEvent(event));
|
|
518
516
|
}, []);
|
|
519
517
|
const [portalMounted, setPortalMounted] = React.useState(disablePortal);
|
|
520
518
|
useFocusLock(ref, autoFocus ?? false, triggerRef, !visible || disableEnforceFocus || !portalMounted, focusMaster, handleFocusOut);
|
|
@@ -526,8 +524,7 @@ function PopperPopper(props) {
|
|
|
526
524
|
}
|
|
527
525
|
}, [updatePopperEveryFrame]);
|
|
528
526
|
const handleAnimationEnd = React.useCallback(() => {
|
|
529
|
-
|
|
530
|
-
(_a = popper.current) == null ? void 0 : _a.update();
|
|
527
|
+
popper.current?.update();
|
|
531
528
|
}, []);
|
|
532
529
|
const animationCtx = React.useContext(animationContext);
|
|
533
530
|
React.useEffect(() => {
|
|
@@ -15,12 +15,11 @@ function isEmpty(obj) {
|
|
|
15
15
|
function arrowOffset({
|
|
16
16
|
state
|
|
17
17
|
}) {
|
|
18
|
-
var _a;
|
|
19
18
|
if (isEmpty(state.modifiersData["arrow"]) || isEmpty(state.modifiersData["popperOffsets"])) return;
|
|
20
19
|
const [position, align] = state.placement.split("-");
|
|
21
20
|
const offset = MAP_OFFSET[position];
|
|
22
21
|
const coordinate = MAP_COORDINATE[offset];
|
|
23
|
-
const padding =
|
|
22
|
+
const padding = state.options.modifiers.find((mod) => mod.name === "arrow")?.options.padding || 0;
|
|
24
23
|
if (align === "start" && state.modifiersData.arrow) {
|
|
25
24
|
const lenRef = state.rects.reference[offset];
|
|
26
25
|
state.modifiersData.arrow[coordinate] = padding;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { eventListeners, popperOffsets, computeStyles, applyStyles, offset, flip, preventOverflow, arrow, hide, popperGenerator } from "@popperjs/core";
|
|
2
2
|
import maxSize from "popper-max-size-modifier";
|
|
3
3
|
import ArrowOffsetModifier from "./arrowOffset.mjs";
|
|
4
4
|
import { applyMaxSize } from "./modifiers/applyMaxSize.mjs";
|
|
@@ -18,7 +18,6 @@ const cursorAnchoringModifier = {
|
|
|
18
18
|
state,
|
|
19
19
|
options
|
|
20
20
|
}) => {
|
|
21
|
-
var _a, _b;
|
|
22
21
|
const {
|
|
23
22
|
placement
|
|
24
23
|
} = state.options;
|
|
@@ -35,7 +34,7 @@ const cursorAnchoringModifier = {
|
|
|
35
34
|
if (verticalPlacement) {
|
|
36
35
|
const offsetParent = getOffsetParent(elements.popper);
|
|
37
36
|
const offsetParentRect = offsetParent === window ? getWindowRect() : offsetParent.getBoundingClientRect();
|
|
38
|
-
const mouseX =
|
|
37
|
+
const mouseX = mouseEnterCursorPositionRef?.current?.x;
|
|
39
38
|
if (mouseX === void 0) return;
|
|
40
39
|
const width = Math.min(rects.reference.width, rects.popper.width);
|
|
41
40
|
const x = clamp(mouseX - offsetParentRect.x - width / 2, rects.reference.x, rects.reference.x + rects.reference.width - width);
|
|
@@ -44,7 +43,7 @@ const cursorAnchoringModifier = {
|
|
|
44
43
|
} else {
|
|
45
44
|
const offsetParent = getOffsetParent(elements.popper);
|
|
46
45
|
const offsetParentRect = offsetParent === window ? getWindowRect() : offsetParent.getBoundingClientRect();
|
|
47
|
-
const mouseY =
|
|
46
|
+
const mouseY = mouseEnterCursorPositionRef?.current?.y;
|
|
48
47
|
if (mouseY === void 0) return;
|
|
49
48
|
const height = Math.min(rects.reference.height, rects.popper.height);
|
|
50
49
|
const y = clamp(mouseY - offsetParentRect.y - height / 2, rects.reference.y, rects.reference.y + rects.reference.height - height);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { register, createComponent } from "@semcore/core";
|
|
2
2
|
import canUseDOM from "@semcore/core/lib/utils/canUseDOM";
|
|
3
3
|
import React from "react";
|
|
4
4
|
import { createPortal } from "react-dom";
|
|
@@ -15,7 +15,7 @@ function Portal(props) {
|
|
|
15
15
|
const [mountNode, setMountNode] = React.useState(null);
|
|
16
16
|
React.useEffect(() => {
|
|
17
17
|
if (disablePortal) return;
|
|
18
|
-
onMount
|
|
18
|
+
onMount?.(true);
|
|
19
19
|
if (ignorePortalsStacking) {
|
|
20
20
|
setMountNode(canUseDOM() ? document.body : null);
|
|
21
21
|
return;
|