@octaviaflow/core 3.0.18-beta.46 → 3.0.18-beta.48
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/components/TimePicker/TimePicker.d.ts.map +1 -1
- package/dist/index.cjs +72 -17
- 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 +82 -27
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/utils/useAnchoredPopover.d.ts +33 -0
- package/dist/utils/useAnchoredPopover.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TimePicker.d.ts","sourceRoot":"","sources":["../../../src/components/TimePicker/TimePicker.tsx"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,wBAAwB,EAI7B,KAAK,SAAS,EAMf,MAAM,OAAO,CAAC;AAcf,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACtB;AAED,MAAM,MAAM,cAAc,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAEhD,KAAK,YAAY,GAAG,IAAI,CACtB,wBAAwB,CAAC,KAAK,CAAC,EAC/B,UAAU,GAAG,UAAU,GAAG,cAAc,CACzC,CAAC;AAEF,MAAM,WAAW,eAAgB,SAAQ,YAAY;IACnD,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,KAAK,EAAE,SAAS,CAAC;IACjB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;IACtC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC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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,43 @@ var import_react_dom9 = require("react-dom");
|
|
|
11900
11901
|
|
|
11901
11902
|
// src/utils/useAnchoredPopover.ts
|
|
11902
11903
|
var import_react56 = require("react");
|
|
11904
|
+
var useIsomorphicLayoutEffect = typeof document !== "undefined" ? import_react56.useLayoutEffect : import_react56.useEffect;
|
|
11905
|
+
function computeAnchoredPosition({
|
|
11906
|
+
anchor,
|
|
11907
|
+
viewport,
|
|
11908
|
+
popoverWidth,
|
|
11909
|
+
gap,
|
|
11910
|
+
margin,
|
|
11911
|
+
preferredMinHeight
|
|
11912
|
+
}) {
|
|
11913
|
+
const spaceBelow = viewport.height - anchor.bottom - gap - margin;
|
|
11914
|
+
const spaceAbove = anchor.top - gap - margin;
|
|
11915
|
+
const openUp = spaceBelow < preferredMinHeight && spaceAbove > spaceBelow;
|
|
11916
|
+
const maxHeight = Math.max(0, openUp ? spaceAbove : spaceBelow);
|
|
11917
|
+
const measured = popoverWidth && popoverWidth > 0 ? popoverWidth : 0;
|
|
11918
|
+
const renderW = Math.max(measured, anchor.width);
|
|
11919
|
+
const maxAvailW = viewport.width - 2 * margin;
|
|
11920
|
+
let effectiveW = renderW;
|
|
11921
|
+
let maxWidth;
|
|
11922
|
+
if (renderW > maxAvailW) {
|
|
11923
|
+
effectiveW = maxAvailW;
|
|
11924
|
+
maxWidth = maxAvailW;
|
|
11925
|
+
}
|
|
11926
|
+
const maxLeft = viewport.width - effectiveW - margin;
|
|
11927
|
+
let left = anchor.left;
|
|
11928
|
+
if (left > maxLeft) left = maxLeft;
|
|
11929
|
+
if (left < margin) left = margin;
|
|
11930
|
+
return {
|
|
11931
|
+
...openUp ? { bottom: viewport.height - anchor.top + gap } : { top: anchor.bottom + gap },
|
|
11932
|
+
left,
|
|
11933
|
+
width: anchor.width,
|
|
11934
|
+
...maxWidth !== void 0 ? { maxWidth } : {},
|
|
11935
|
+
maxHeight,
|
|
11936
|
+
direction: openUp ? "up" : "down"
|
|
11937
|
+
};
|
|
11938
|
+
}
|
|
11903
11939
|
function useAnchoredPopover(anchorRef, open, options = {}) {
|
|
11904
|
-
const { gap = 4, margin = 8, preferredMinHeight = 200 } = options;
|
|
11940
|
+
const { gap = 4, margin = 8, preferredMinHeight = 200, popoverRef } = options;
|
|
11905
11941
|
const [pos, setPos] = (0, import_react56.useState)({
|
|
11906
11942
|
top: -9999,
|
|
11907
11943
|
left: -9999,
|
|
@@ -11913,19 +11949,24 @@ function useAnchoredPopover(anchorRef, open, options = {}) {
|
|
|
11913
11949
|
const el = anchorRef.current;
|
|
11914
11950
|
if (!el) return;
|
|
11915
11951
|
const rect = el.getBoundingClientRect();
|
|
11916
|
-
const
|
|
11917
|
-
|
|
11918
|
-
|
|
11919
|
-
|
|
11920
|
-
|
|
11921
|
-
|
|
11922
|
-
|
|
11923
|
-
|
|
11924
|
-
|
|
11925
|
-
|
|
11926
|
-
|
|
11927
|
-
|
|
11928
|
-
|
|
11952
|
+
const popoverWidth = popoverRef?.current?.offsetWidth;
|
|
11953
|
+
setPos(
|
|
11954
|
+
computeAnchoredPosition({
|
|
11955
|
+
anchor: {
|
|
11956
|
+
top: rect.top,
|
|
11957
|
+
bottom: rect.bottom,
|
|
11958
|
+
left: rect.left,
|
|
11959
|
+
width: rect.width
|
|
11960
|
+
},
|
|
11961
|
+
viewport: { width: window.innerWidth, height: window.innerHeight },
|
|
11962
|
+
popoverWidth,
|
|
11963
|
+
gap,
|
|
11964
|
+
margin,
|
|
11965
|
+
preferredMinHeight
|
|
11966
|
+
})
|
|
11967
|
+
);
|
|
11968
|
+
}, [anchorRef, popoverRef, gap, margin, preferredMinHeight]);
|
|
11969
|
+
useIsomorphicLayoutEffect(() => {
|
|
11929
11970
|
if (!open) return;
|
|
11930
11971
|
update();
|
|
11931
11972
|
window.addEventListener("scroll", update, true);
|
|
@@ -11944,6 +11985,7 @@ function anchoredPopoverStyle(pos, extra) {
|
|
|
11944
11985
|
...pos.bottom !== void 0 ? { bottom: pos.bottom } : {},
|
|
11945
11986
|
left: pos.left,
|
|
11946
11987
|
minWidth: pos.width,
|
|
11988
|
+
...pos.maxWidth !== void 0 ? { maxWidth: pos.maxWidth } : {},
|
|
11947
11989
|
maxHeight: pos.maxHeight,
|
|
11948
11990
|
...extra
|
|
11949
11991
|
};
|
|
@@ -11986,7 +12028,7 @@ var DatePicker = (0, import_react57.forwardRef)(
|
|
|
11986
12028
|
const wrapRef = (0, import_react57.useRef)(null);
|
|
11987
12029
|
const triggerRef = (0, import_react57.useRef)(null);
|
|
11988
12030
|
const popoverRef = (0, import_react57.useRef)(null);
|
|
11989
|
-
const popoverPos = useAnchoredPopover(triggerRef, open);
|
|
12031
|
+
const popoverPos = useAnchoredPopover(triggerRef, open, { popoverRef });
|
|
11990
12032
|
(0, import_react57.useImperativeHandle)(forwardedRef, () => triggerRef.current);
|
|
11991
12033
|
const reactId = (0, import_react57.useId)();
|
|
11992
12034
|
const baseId = id ?? `ods-dp-${reactId}`;
|
|
@@ -27089,7 +27131,7 @@ var TimePicker = (0, import_react139.forwardRef)(
|
|
|
27089
27131
|
};
|
|
27090
27132
|
const triggerRef = (0, import_react139.useRef)(null);
|
|
27091
27133
|
const popoverRef = (0, import_react139.useRef)(null);
|
|
27092
|
-
const popoverPos = useAnchoredPopover(triggerRef, open);
|
|
27134
|
+
const popoverPos = useAnchoredPopover(triggerRef, open, { popoverRef });
|
|
27093
27135
|
const hoursRef = (0, import_react139.useRef)(null);
|
|
27094
27136
|
const minutesRef = (0, import_react139.useRef)(null);
|
|
27095
27137
|
const secondsRef = (0, import_react139.useRef)(null);
|
|
@@ -27174,8 +27216,20 @@ var TimePicker = (0, import_react139.forwardRef)(
|
|
|
27174
27216
|
setActiveSeg(null);
|
|
27175
27217
|
}
|
|
27176
27218
|
};
|
|
27219
|
+
const onKey = (e) => {
|
|
27220
|
+
if (e.key === "Escape") {
|
|
27221
|
+
flushDraft();
|
|
27222
|
+
setOpen(false);
|
|
27223
|
+
setActiveSeg(null);
|
|
27224
|
+
triggerRef.current?.focus();
|
|
27225
|
+
}
|
|
27226
|
+
};
|
|
27177
27227
|
document.addEventListener("mousedown", onDoc);
|
|
27178
|
-
|
|
27228
|
+
document.addEventListener("keydown", onKey);
|
|
27229
|
+
return () => {
|
|
27230
|
+
document.removeEventListener("mousedown", onDoc);
|
|
27231
|
+
document.removeEventListener("keydown", onKey);
|
|
27232
|
+
};
|
|
27179
27233
|
}, [open, flushDraft]);
|
|
27180
27234
|
const segOrder = () => showSeconds ? ["hours", "minutes", "seconds"] : ["hours", "minutes"];
|
|
27181
27235
|
const handleSegKey = (seg) => (e) => {
|
|
@@ -34729,6 +34783,7 @@ function applyVerticalLayout(nodes, edges) {
|
|
|
34729
34783
|
breakpointMinWidth,
|
|
34730
34784
|
cn,
|
|
34731
34785
|
codeToFlag,
|
|
34786
|
+
computeAnchoredPosition,
|
|
34732
34787
|
easeLinear,
|
|
34733
34788
|
easeOutCubic,
|
|
34734
34789
|
easeOutExpo,
|