reshaped 3.9.0-canary.9 → 3.9.1-canary.2
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/dist/bundle.css +1 -1
- package/dist/bundle.d.ts +2 -0
- package/dist/bundle.js +2 -2
- package/dist/components/Accordion/AccordionControlled.js +0 -1
- package/dist/components/Actionable/Actionable.d.ts +8 -3
- package/dist/components/Actionable/Actionable.js +17 -70
- package/dist/components/Actionable/Actionable.module.css +1 -1
- package/dist/components/Actionable/Actionable.types.d.ts +2 -36
- package/dist/components/Actionable/index.d.ts +2 -1
- package/dist/components/Badge/Badge.js +2 -2
- package/dist/components/Badge/Badge.module.css +1 -1
- package/dist/components/Badge/Badge.types.d.ts +1 -1
- package/dist/components/Button/Button.module.css +1 -1
- package/dist/components/Calendar/Calendar.module.css +1 -1
- package/dist/components/Calendar/Calendar.utils.js +6 -7
- package/dist/components/Card/Card.d.ts +2 -2
- package/dist/components/Card/Card.types.d.ts +5 -5
- package/dist/components/Carousel/Carousel.js +0 -1
- package/dist/components/Flyout/Flyout.constants.d.ts +1 -0
- package/dist/components/Flyout/Flyout.constants.js +1 -0
- package/dist/components/Flyout/Flyout.module.css +1 -1
- package/dist/components/Flyout/Flyout.types.d.ts +10 -8
- package/dist/components/Flyout/FlyoutContent.js +4 -49
- package/dist/components/Flyout/FlyoutControlled.js +94 -76
- package/dist/components/Flyout/FlyoutTrigger.js +3 -3
- package/dist/components/Flyout/useFlyout.d.ts +3 -4
- package/dist/components/Flyout/useFlyout.js +70 -88
- package/dist/components/Flyout/utilities/safeArea.d.ts +10 -0
- package/dist/components/Flyout/utilities/safeArea.js +100 -0
- package/dist/components/Grid/Grid.types.d.ts +4 -4
- package/dist/components/HiddenInput/HiddenInput.js +2 -3
- package/dist/components/Image/Image.js +1 -1
- package/dist/components/Modal/Modal.js +0 -3
- package/dist/components/Popover/Popover.module.css +1 -1
- package/dist/components/Reshaped/Reshaped.css +1 -1
- package/dist/components/ScrollArea/ScrollArea.js +6 -6
- package/dist/components/Select/Select.js +1 -1
- package/dist/components/Select/SelectCustomControlled.js +0 -1
- package/dist/components/Slider/SliderControlled.js +5 -4
- package/dist/components/Tabs/Tabs.module.css +1 -1
- package/dist/components/Tabs/Tabs.types.d.ts +3 -1
- package/dist/components/Tabs/TabsContext.d.ts +1 -0
- package/dist/components/Tabs/TabsControlled.js +2 -2
- package/dist/components/Tabs/TabsItem.js +2 -2
- package/dist/components/Tabs/TabsList.js +9 -5
- package/dist/components/Tabs/TabsPanel.js +1 -1
- package/dist/components/Text/Text.d.ts +1 -1
- package/dist/components/Text/Text.types.d.ts +3 -3
- package/dist/components/Toast/ToastContainer.js +0 -1
- package/dist/components/Tooltip/Tooltip.js +2 -2
- package/dist/components/Tooltip/Tooltip.module.css +1 -1
- package/dist/components/Tooltip/Tooltip.types.d.ts +1 -1
- package/dist/components/View/View.types.d.ts +4 -4
- package/dist/components/_private/Expandable/Expandable.js +1 -3
- package/dist/components/_private/Portal/Portal.js +0 -3
- package/dist/core/Actionable/Actionable.d.ts +4 -0
- package/dist/core/Actionable/Actionable.js +73 -0
- package/dist/core/Actionable/Actionable.types.d.ts +34 -0
- package/dist/core/Actionable/Actionable.types.js +1 -0
- package/dist/core/Actionable/index.d.ts +2 -0
- package/dist/core/Actionable/index.js +1 -0
- package/dist/hooks/_private/useDrag.js +0 -3
- package/dist/hooks/_private/usePrevious.js +0 -1
- package/dist/hooks/useOnClickOutside.js +8 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1 -0
- package/dist/types/global.d.ts +1 -1
- package/dist/utilities/a11y/TrapFocus.js +9 -3
- package/dist/utilities/dom/index.d.ts +0 -2
- package/dist/utilities/dom/index.js +0 -2
- package/dist/utilities/scroll/disable.js +4 -2
- package/package.json +7 -99
- package/README.md +0 -24
- package/dist/components/Flyout/utilities/calculatePosition.d.ts +0 -31
- package/dist/components/Flyout/utilities/calculatePosition.js +0 -178
- package/dist/components/Flyout/utilities/flyout.d.ts +0 -11
- package/dist/components/Flyout/utilities/flyout.js +0 -87
- package/dist/components/Flyout/utilities/getPositionFallbacks.d.ts +0 -3
- package/dist/components/Flyout/utilities/getPositionFallbacks.js +0 -39
- package/dist/components/Flyout/utilities/helpers.d.ts +0 -7
- package/dist/components/Flyout/utilities/helpers.js +0 -14
- package/dist/components/Flyout/utilities/isFullyVisible.d.ts +0 -12
- package/dist/components/Flyout/utilities/isFullyVisible.js +0 -22
- package/dist/utilities/dom/flyout.d.ts +0 -2
- package/dist/utilities/dom/flyout.js +0 -14
- package/dist/utilities/dom/userSelect.d.ts +0 -2
- package/dist/utilities/dom/userSelect.js +0 -6
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type * as T from "../Flyout.types";
|
|
2
|
-
import type * as G from "../../../types/global";
|
|
3
|
-
/**
|
|
4
|
-
* Set position of the target element to fit on the screen
|
|
5
|
-
*/
|
|
6
|
-
declare const flyout: (args: T.Options & {
|
|
7
|
-
flyoutEl: HTMLElement;
|
|
8
|
-
triggerEl: HTMLElement | null;
|
|
9
|
-
triggerBounds?: DOMRect | G.Coordinates | null;
|
|
10
|
-
}) => T.FlyoutData | undefined;
|
|
11
|
-
export default flyout;
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { getRectFromCoordinates, getShadowRoot, findClosestPositionContainer } from "../../../utilities/dom/index.js";
|
|
2
|
-
import { resetStyles } from "../Flyout.constants.js";
|
|
3
|
-
import calculatePosition from "./calculatePosition.js";
|
|
4
|
-
import getPositionFallbacks from "./getPositionFallbacks.js";
|
|
5
|
-
import isFullyVisible from "./isFullyVisible.js";
|
|
6
|
-
/**
|
|
7
|
-
* Set position of the target element to fit on the screen
|
|
8
|
-
*/
|
|
9
|
-
const flyout = (args) => {
|
|
10
|
-
const { triggerEl, flyoutEl, triggerBounds: passedTriggerBounds, contentShift = 0, contentGap = 0, position, fallbackPositions, fallbackAdjustLayout, fallbackMinWidth, fallbackMinHeight, width, container: passedContainer, lastUsedPosition, onPositionChoose, rtl, } = args;
|
|
11
|
-
const targetClone = flyoutEl.cloneNode(true);
|
|
12
|
-
const baseUnit = getComputedStyle(flyoutEl).getPropertyValue("--rs-unit-x1");
|
|
13
|
-
const unitModifier = baseUnit ? parseInt(baseUnit) : 4;
|
|
14
|
-
const triggerBounds = passedTriggerBounds || triggerEl?.getBoundingClientRect();
|
|
15
|
-
if (!triggerBounds)
|
|
16
|
-
return;
|
|
17
|
-
const resolvedTriggerBounds = getRectFromCoordinates(triggerBounds);
|
|
18
|
-
// Reset all styles applied on the previous hook execution
|
|
19
|
-
targetClone.style.cssText = "";
|
|
20
|
-
Object.keys(resetStyles).forEach((key) => {
|
|
21
|
-
const value = resetStyles[key];
|
|
22
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
23
|
-
// @ts-ignore
|
|
24
|
-
if (value)
|
|
25
|
-
targetClone.style[key] = value.toString();
|
|
26
|
-
});
|
|
27
|
-
if (width === "trigger") {
|
|
28
|
-
targetClone.style.width = `${resolvedTriggerBounds.width}px`;
|
|
29
|
-
}
|
|
30
|
-
else if (width && width !== "full") {
|
|
31
|
-
targetClone.style.width = width;
|
|
32
|
-
}
|
|
33
|
-
const shadowRoot = triggerEl && getShadowRoot(triggerEl);
|
|
34
|
-
// Insert inside shadow root if possible to make sure styles are applied correctly
|
|
35
|
-
(shadowRoot || document.body).appendChild(targetClone);
|
|
36
|
-
const cloneRect = targetClone.getBoundingClientRect();
|
|
37
|
-
const flyoutBounds = { width: cloneRect.width, height: cloneRect.height };
|
|
38
|
-
const closestFixedContainer = !passedContainer && triggerEl ? findClosestPositionContainer({ el: triggerEl }) : undefined;
|
|
39
|
-
const container = passedContainer ||
|
|
40
|
-
// Render inside fixed position container automatically to keep their position synced on scroll
|
|
41
|
-
closestFixedContainer ||
|
|
42
|
-
document.body;
|
|
43
|
-
const renderContainerBounds = container.getBoundingClientRect();
|
|
44
|
-
const visualContainerBounds = (passedContainer || document.body).getBoundingClientRect();
|
|
45
|
-
const applyPosition = (position) => {
|
|
46
|
-
return calculatePosition({
|
|
47
|
-
triggerBounds: resolvedTriggerBounds,
|
|
48
|
-
flyoutBounds,
|
|
49
|
-
containerBounds: renderContainerBounds,
|
|
50
|
-
position,
|
|
51
|
-
contentGap: contentGap * unitModifier,
|
|
52
|
-
contentShift: contentShift * unitModifier,
|
|
53
|
-
rtl,
|
|
54
|
-
width,
|
|
55
|
-
passedContainer: passedContainer ||
|
|
56
|
-
(closestFixedContainer !== document.body ? closestFixedContainer : undefined),
|
|
57
|
-
fallbackAdjustLayout,
|
|
58
|
-
fallbackMinWidth,
|
|
59
|
-
fallbackMinHeight,
|
|
60
|
-
});
|
|
61
|
-
};
|
|
62
|
-
const testVisibility = (calculated) => {
|
|
63
|
-
return isFullyVisible({
|
|
64
|
-
flyoutBounds: calculated.boundaries,
|
|
65
|
-
visualContainerBounds,
|
|
66
|
-
renderContainerBounds,
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
let calculated = null;
|
|
70
|
-
const testOrder = getPositionFallbacks(position, fallbackPositions);
|
|
71
|
-
testOrder.some((currentPosition) => {
|
|
72
|
-
const tested = applyPosition(currentPosition);
|
|
73
|
-
const visible = testVisibility(tested);
|
|
74
|
-
if (visible)
|
|
75
|
-
calculated = tested;
|
|
76
|
-
return visible;
|
|
77
|
-
});
|
|
78
|
-
if (!calculated)
|
|
79
|
-
calculated = applyPosition(lastUsedPosition);
|
|
80
|
-
onPositionChoose(calculated.position);
|
|
81
|
-
targetClone.parentNode?.removeChild(targetClone);
|
|
82
|
-
Object.entries(calculated.styles).forEach(([key, value]) => {
|
|
83
|
-
flyoutEl.style.setProperty(key, value);
|
|
84
|
-
});
|
|
85
|
-
return { position: calculated.position };
|
|
86
|
-
};
|
|
87
|
-
export default flyout;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
// All available positions for each side
|
|
2
|
-
const positions = {
|
|
3
|
-
top: ["top-start", "top-end", "top"],
|
|
4
|
-
bottom: ["bottom-start", "bottom-end", "bottom"],
|
|
5
|
-
start: ["start-top", "start-bottom", "start"],
|
|
6
|
-
end: ["end-top", "end-bottom", "end"],
|
|
7
|
-
};
|
|
8
|
-
// Order of sides to try depending on the starting side
|
|
9
|
-
const fallbackOrder = {
|
|
10
|
-
top: ["bottom", "start", "end"],
|
|
11
|
-
bottom: ["top", "end", "start"],
|
|
12
|
-
start: ["end", "top", "bottom"],
|
|
13
|
-
end: ["start", "bottom", "top"],
|
|
14
|
-
};
|
|
15
|
-
// Get an order of positions to try to fit flyout on the screen based on its starting position
|
|
16
|
-
const getPositionFallbacks = (position, availableFallbacks) => {
|
|
17
|
-
const result = new Set([position]);
|
|
18
|
-
const chunks = position.split("-");
|
|
19
|
-
const [firstChunk] = chunks;
|
|
20
|
-
const passedPositionOrder = positions[firstChunk];
|
|
21
|
-
const startingFallbackIndex = passedPositionOrder.indexOf(position);
|
|
22
|
-
const fallbackIndexOrder = [startingFallbackIndex];
|
|
23
|
-
passedPositionOrder.forEach((_, index) => {
|
|
24
|
-
if (index === startingFallbackIndex)
|
|
25
|
-
return;
|
|
26
|
-
fallbackIndexOrder.push(index);
|
|
27
|
-
});
|
|
28
|
-
[firstChunk, ...fallbackOrder[firstChunk]].forEach((fallbackSide) => {
|
|
29
|
-
const fallbackOrder = positions[fallbackSide];
|
|
30
|
-
fallbackIndexOrder.forEach((index) => {
|
|
31
|
-
const position = fallbackOrder[index];
|
|
32
|
-
if (availableFallbacks?.indexOf(position) === -1)
|
|
33
|
-
return;
|
|
34
|
-
result.add(position);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
return Array.from(result);
|
|
38
|
-
};
|
|
39
|
-
export default getPositionFallbacks;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type * as T from "../Flyout.types";
|
|
2
|
-
/** Mirror the position for RTL */
|
|
3
|
-
export declare const getRTLPosition: (position: T.Position) => T.Position;
|
|
4
|
-
/**
|
|
5
|
-
* Get a position value which centers 2 elements vertically or horizontally
|
|
6
|
-
*/
|
|
7
|
-
export declare const centerBySize: (originSize: number, targetSize: number) => number;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/** Mirror the position for RTL */
|
|
2
|
-
export const getRTLPosition = (position) => {
|
|
3
|
-
if (position.includes("start"))
|
|
4
|
-
return position.replace("start", "end");
|
|
5
|
-
if (position.includes("end"))
|
|
6
|
-
return position.replace("end", "start");
|
|
7
|
-
return position;
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* Get a position value which centers 2 elements vertically or horizontally
|
|
11
|
-
*/
|
|
12
|
-
export const centerBySize = (originSize, targetSize) => {
|
|
13
|
-
return Math.floor(originSize / 2 - targetSize / 2);
|
|
14
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Check if element visually fits within its render container
|
|
3
|
-
*/
|
|
4
|
-
declare const isFullyVisible: (args: {
|
|
5
|
-
/** Bounds of the flyout content */
|
|
6
|
-
flyoutBounds: Pick<DOMRect, "left" | "top" | "width" | "height">;
|
|
7
|
-
/** Bounds of the container where the flyout content should fit */
|
|
8
|
-
visualContainerBounds: DOMRect;
|
|
9
|
-
/** Bounds of the container where flyout content is rendered */
|
|
10
|
-
renderContainerBounds: DOMRect;
|
|
11
|
-
}) => boolean;
|
|
12
|
-
export default isFullyVisible;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Check if element visually fits within its render container
|
|
3
|
-
*/
|
|
4
|
-
const isFullyVisible = (args) => {
|
|
5
|
-
const { flyoutBounds, visualContainerBounds, renderContainerBounds } = args;
|
|
6
|
-
if (renderContainerBounds.left + flyoutBounds.left < visualContainerBounds.left) {
|
|
7
|
-
return false;
|
|
8
|
-
}
|
|
9
|
-
if (renderContainerBounds.top + flyoutBounds.top < visualContainerBounds.top) {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
if (renderContainerBounds.left + flyoutBounds.left + flyoutBounds.width >
|
|
13
|
-
visualContainerBounds.right) {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
if (renderContainerBounds.top + flyoutBounds.top + flyoutBounds.height >
|
|
17
|
-
visualContainerBounds.bottom) {
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
return true;
|
|
21
|
-
};
|
|
22
|
-
export default isFullyVisible;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export const getRectFromCoordinates = (coordinates) => {
|
|
2
|
-
if ("width" in coordinates && coordinates.width !== undefined)
|
|
3
|
-
return coordinates;
|
|
4
|
-
return {
|
|
5
|
-
...coordinates,
|
|
6
|
-
width: 0,
|
|
7
|
-
height: 0,
|
|
8
|
-
left: coordinates.x,
|
|
9
|
-
right: coordinates.x,
|
|
10
|
-
top: coordinates.y,
|
|
11
|
-
bottom: coordinates.y,
|
|
12
|
-
toJSON: () => { },
|
|
13
|
-
};
|
|
14
|
-
};
|