@octaviaflow/core 3.0.18-beta.46 → 3.0.18-beta.47
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/index.cjs +46 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +45 -15
- package/dist/index.js.map +1 -1
- package/dist/utils/useAnchoredPopover.d.ts +30 -0
- package/dist/utils/useAnchoredPopover.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -206,6 +206,7 @@ __export(src_exports, {
|
|
|
206
206
|
breakpointMinWidth: () => breakpointMinWidth,
|
|
207
207
|
cn: () => cn,
|
|
208
208
|
codeToFlag: () => codeToFlag,
|
|
209
|
+
computeAnchoredPosition: () => computeAnchoredPosition,
|
|
209
210
|
easeLinear: () => easeLinear,
|
|
210
211
|
easeOutCubic: () => easeOutCubic,
|
|
211
212
|
easeOutExpo: () => easeOutExpo,
|
|
@@ -11900,8 +11901,32 @@ var import_react_dom9 = require("react-dom");
|
|
|
11900
11901
|
|
|
11901
11902
|
// src/utils/useAnchoredPopover.ts
|
|
11902
11903
|
var import_react56 = require("react");
|
|
11904
|
+
function computeAnchoredPosition({
|
|
11905
|
+
anchor,
|
|
11906
|
+
viewport,
|
|
11907
|
+
popoverWidth,
|
|
11908
|
+
gap,
|
|
11909
|
+
margin,
|
|
11910
|
+
preferredMinHeight
|
|
11911
|
+
}) {
|
|
11912
|
+
const spaceBelow = viewport.height - anchor.bottom - gap - margin;
|
|
11913
|
+
const spaceAbove = anchor.top - gap - margin;
|
|
11914
|
+
const openUp = spaceBelow < preferredMinHeight && spaceAbove > spaceBelow;
|
|
11915
|
+
const popW = popoverWidth && popoverWidth > 0 ? popoverWidth : anchor.width;
|
|
11916
|
+
const maxLeft = viewport.width - popW - margin;
|
|
11917
|
+
let left = anchor.left;
|
|
11918
|
+
if (left > maxLeft) left = maxLeft;
|
|
11919
|
+
if (left < margin) left = margin;
|
|
11920
|
+
return {
|
|
11921
|
+
...openUp ? { bottom: viewport.height - anchor.top + gap } : { top: anchor.bottom + gap },
|
|
11922
|
+
left,
|
|
11923
|
+
width: anchor.width,
|
|
11924
|
+
maxHeight: Math.max(120, openUp ? spaceAbove : spaceBelow),
|
|
11925
|
+
direction: openUp ? "up" : "down"
|
|
11926
|
+
};
|
|
11927
|
+
}
|
|
11903
11928
|
function useAnchoredPopover(anchorRef, open, options = {}) {
|
|
11904
|
-
const { gap = 4, margin = 8, preferredMinHeight = 200 } = options;
|
|
11929
|
+
const { gap = 4, margin = 8, preferredMinHeight = 200, popoverRef } = options;
|
|
11905
11930
|
const [pos, setPos] = (0, import_react56.useState)({
|
|
11906
11931
|
top: -9999,
|
|
11907
11932
|
left: -9999,
|
|
@@ -11913,18 +11938,23 @@ function useAnchoredPopover(anchorRef, open, options = {}) {
|
|
|
11913
11938
|
const el = anchorRef.current;
|
|
11914
11939
|
if (!el) return;
|
|
11915
11940
|
const rect = el.getBoundingClientRect();
|
|
11916
|
-
const
|
|
11917
|
-
|
|
11918
|
-
|
|
11919
|
-
|
|
11920
|
-
|
|
11921
|
-
|
|
11922
|
-
|
|
11923
|
-
|
|
11924
|
-
|
|
11925
|
-
|
|
11926
|
-
|
|
11927
|
-
|
|
11941
|
+
const popoverWidth = popoverRef?.current?.offsetWidth;
|
|
11942
|
+
setPos(
|
|
11943
|
+
computeAnchoredPosition({
|
|
11944
|
+
anchor: {
|
|
11945
|
+
top: rect.top,
|
|
11946
|
+
bottom: rect.bottom,
|
|
11947
|
+
left: rect.left,
|
|
11948
|
+
width: rect.width
|
|
11949
|
+
},
|
|
11950
|
+
viewport: { width: window.innerWidth, height: window.innerHeight },
|
|
11951
|
+
popoverWidth,
|
|
11952
|
+
gap,
|
|
11953
|
+
margin,
|
|
11954
|
+
preferredMinHeight
|
|
11955
|
+
})
|
|
11956
|
+
);
|
|
11957
|
+
}, [anchorRef, popoverRef, gap, margin, preferredMinHeight]);
|
|
11928
11958
|
(0, import_react56.useEffect)(() => {
|
|
11929
11959
|
if (!open) return;
|
|
11930
11960
|
update();
|
|
@@ -11986,7 +12016,7 @@ var DatePicker = (0, import_react57.forwardRef)(
|
|
|
11986
12016
|
const wrapRef = (0, import_react57.useRef)(null);
|
|
11987
12017
|
const triggerRef = (0, import_react57.useRef)(null);
|
|
11988
12018
|
const popoverRef = (0, import_react57.useRef)(null);
|
|
11989
|
-
const popoverPos = useAnchoredPopover(triggerRef, open);
|
|
12019
|
+
const popoverPos = useAnchoredPopover(triggerRef, open, { popoverRef });
|
|
11990
12020
|
(0, import_react57.useImperativeHandle)(forwardedRef, () => triggerRef.current);
|
|
11991
12021
|
const reactId = (0, import_react57.useId)();
|
|
11992
12022
|
const baseId = id ?? `ods-dp-${reactId}`;
|
|
@@ -27089,7 +27119,7 @@ var TimePicker = (0, import_react139.forwardRef)(
|
|
|
27089
27119
|
};
|
|
27090
27120
|
const triggerRef = (0, import_react139.useRef)(null);
|
|
27091
27121
|
const popoverRef = (0, import_react139.useRef)(null);
|
|
27092
|
-
const popoverPos = useAnchoredPopover(triggerRef, open);
|
|
27122
|
+
const popoverPos = useAnchoredPopover(triggerRef, open, { popoverRef });
|
|
27093
27123
|
const hoursRef = (0, import_react139.useRef)(null);
|
|
27094
27124
|
const minutesRef = (0, import_react139.useRef)(null);
|
|
27095
27125
|
const secondsRef = (0, import_react139.useRef)(null);
|
|
@@ -34729,6 +34759,7 @@ function applyVerticalLayout(nodes, edges) {
|
|
|
34729
34759
|
breakpointMinWidth,
|
|
34730
34760
|
cn,
|
|
34731
34761
|
codeToFlag,
|
|
34762
|
+
computeAnchoredPosition,
|
|
34732
34763
|
easeLinear,
|
|
34733
34764
|
easeOutCubic,
|
|
34734
34765
|
easeOutExpo,
|