qstd 0.3.45 → 0.3.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/README.md +27 -7
- package/dist/block/tooltip.d.ts.map +1 -1
- package/dist/preset/index.cjs +1 -5
- package/dist/preset/index.d.ts.map +1 -1
- package/dist/preset/index.js +1 -5
- package/dist/react/index.cjs +166 -167
- package/dist/react/index.css +0 -1
- package/dist/react/index.js +162 -163
- package/package.json +1 -1
- package/styled-system/styles.css +0 -1
package/dist/react/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./index.css";
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
2
|
+
import * as React3 from 'react';
|
|
3
|
+
import React3__default, { forwardRef, useMemo, createElement } from 'react';
|
|
4
4
|
import { createPortal } from 'react-dom';
|
|
5
5
|
import { motion, MotionConfig, LayoutGroup, AnimatePresence, useDragControls, useMotionValue } from 'framer-motion';
|
|
6
6
|
import { useFloating, offset, flip, shift, hide, autoUpdate, FloatingPortal, arrow, useHover, safePolygon, useFocus, useDismiss, useRole, useInteractions } from '@floating-ui/react';
|
|
@@ -608,14 +608,14 @@ function Menu(props) {
|
|
|
608
608
|
trigger,
|
|
609
609
|
...rest
|
|
610
610
|
} = props;
|
|
611
|
-
const hoverTimeoutRef =
|
|
612
|
-
const [isOpen, setOpen] =
|
|
611
|
+
const hoverTimeoutRef = React3__default.useRef(null);
|
|
612
|
+
const [isOpen, setOpen] = React3__default.useState(isOpenControlled ?? false);
|
|
613
613
|
const onOpenChange = (open) => {
|
|
614
614
|
const newOpenState = typeof open === "function" ? open(isOpen) : open;
|
|
615
615
|
props.onOpenOrClose?.(newOpenState);
|
|
616
616
|
setOpen(newOpenState);
|
|
617
617
|
};
|
|
618
|
-
|
|
618
|
+
React3__default.useEffect(() => {
|
|
619
619
|
if (typeof isOpenControlled !== "boolean") return;
|
|
620
620
|
setOpen(isOpenControlled);
|
|
621
621
|
}, [isOpenControlled]);
|
|
@@ -690,11 +690,11 @@ function Menu(props) {
|
|
|
690
690
|
},
|
|
691
691
|
isOpen
|
|
692
692
|
);
|
|
693
|
-
|
|
693
|
+
React3__default.useEffect(() => {
|
|
694
694
|
if (!hideData?.referenceHidden) return;
|
|
695
695
|
closeMenuImmediate();
|
|
696
696
|
}, [hideData, closeMenuImmediate]);
|
|
697
|
-
|
|
697
|
+
React3__default.useEffect(() => {
|
|
698
698
|
return () => {
|
|
699
699
|
if (hoverTimeoutRef.current) clearTimeout(hoverTimeoutRef.current);
|
|
700
700
|
};
|
|
@@ -720,10 +720,10 @@ function Menu(props) {
|
|
|
720
720
|
onMouseLeave: handleMenuMouseLeave
|
|
721
721
|
} : {};
|
|
722
722
|
const transformOrigin = floatingContext.placement.startsWith("top") ? "bottom left" : "top left";
|
|
723
|
-
const childArray =
|
|
723
|
+
const childArray = React3__default.Children.toArray(children);
|
|
724
724
|
let customContainerEl = null;
|
|
725
725
|
for (const c of childArray) {
|
|
726
|
-
if (
|
|
726
|
+
if (React3__default.isValidElement(c)) {
|
|
727
727
|
const anyType = c.type;
|
|
728
728
|
if (c.props?.["data-menu-container"] || anyType?.isBlockMenuContainer) {
|
|
729
729
|
customContainerEl = c;
|
|
@@ -752,7 +752,7 @@ function Menu(props) {
|
|
|
752
752
|
...restStyle || {}
|
|
753
753
|
};
|
|
754
754
|
const mergedClassName = [defaultsClassName, childProps.className].filter(Boolean).join(" ");
|
|
755
|
-
const contentNode =
|
|
755
|
+
const contentNode = React3__default.cloneElement(
|
|
756
756
|
customContainerEl,
|
|
757
757
|
{
|
|
758
758
|
// Defaults are now in mergedClassName via css()
|
|
@@ -838,7 +838,7 @@ function Menu(props) {
|
|
|
838
838
|
);
|
|
839
839
|
}
|
|
840
840
|
function useOutsideClick(ref, handler, enabled = true) {
|
|
841
|
-
|
|
841
|
+
React3__default.useEffect(() => {
|
|
842
842
|
if (!enabled) return;
|
|
843
843
|
const listener = (event) => {
|
|
844
844
|
if (!ref.current || ref.current.contains(event.target)) {
|
|
@@ -948,9 +948,9 @@ var prepareFiles = async (acceptedFiles) => {
|
|
|
948
948
|
);
|
|
949
949
|
};
|
|
950
950
|
var findChildrenByDisplayName = (children, displayName2) => {
|
|
951
|
-
return
|
|
951
|
+
return React3__default.Children.toArray(children).find(
|
|
952
952
|
(child) => {
|
|
953
|
-
if (
|
|
953
|
+
if (React3__default.isValidElement(child)) {
|
|
954
954
|
const childType = child.type;
|
|
955
955
|
return childType.displayName === displayName2;
|
|
956
956
|
} else {
|
|
@@ -1130,7 +1130,7 @@ function getIcon(position, Icon2, props) {
|
|
|
1130
1130
|
if (loadingIcons.includes(chosen)) {
|
|
1131
1131
|
const Cmp = loadingIconsMap[chosen];
|
|
1132
1132
|
const sizePx = typeof loadingIconSize === "number" ? `${loadingIconSize}px` : "12px";
|
|
1133
|
-
return
|
|
1133
|
+
return React3__default.createElement(Cmp, {
|
|
1134
1134
|
width: sizePx,
|
|
1135
1135
|
height: sizePx
|
|
1136
1136
|
});
|
|
@@ -1145,11 +1145,11 @@ function getIcon(position, Icon2, props) {
|
|
|
1145
1145
|
spin: props.spin
|
|
1146
1146
|
}
|
|
1147
1147
|
);
|
|
1148
|
-
} else if (
|
|
1148
|
+
} else if (React3__default.isValidElement(chosen)) {
|
|
1149
1149
|
return chosen;
|
|
1150
1150
|
} else if (typeof chosen === "function") {
|
|
1151
1151
|
const iconProps = typeof loadingIconSize === "number" || typeof loadingIconSize === "string" ? { size: loadingIconSize } : void 0;
|
|
1152
|
-
return
|
|
1152
|
+
return React3__default.createElement(chosen, iconProps);
|
|
1153
1153
|
} else if (typeof chosen === "object" && chosen !== null && "iconName" in chosen) {
|
|
1154
1154
|
return /* @__PURE__ */ jsx(
|
|
1155
1155
|
FontAwesomeIcon,
|
|
@@ -1199,8 +1199,8 @@ function getIcon(position, Icon2, props) {
|
|
|
1199
1199
|
}
|
|
1200
1200
|
);
|
|
1201
1201
|
} else if (typeof Icon2 === "function") {
|
|
1202
|
-
return
|
|
1203
|
-
} else if (
|
|
1202
|
+
return React3__default.createElement(Icon2);
|
|
1203
|
+
} else if (React3__default.isValidElement(Icon2)) {
|
|
1204
1204
|
return Icon2;
|
|
1205
1205
|
} else return null;
|
|
1206
1206
|
}
|
|
@@ -1245,9 +1245,9 @@ var TrackNameKey = "Track";
|
|
|
1245
1245
|
var ThumbNameKey = "Thumb";
|
|
1246
1246
|
var Button = motionTags.button;
|
|
1247
1247
|
var Base = motionTags.div;
|
|
1248
|
-
var SwitchContext =
|
|
1248
|
+
var SwitchContext = React3__default.createContext(null);
|
|
1249
1249
|
var useSwitchContext = () => {
|
|
1250
|
-
const context2 =
|
|
1250
|
+
const context2 = React3__default.useContext(SwitchContext);
|
|
1251
1251
|
if (!context2) {
|
|
1252
1252
|
throw new Error("Switch compound components must be used within Switch");
|
|
1253
1253
|
}
|
|
@@ -1266,9 +1266,9 @@ function Switch(props) {
|
|
|
1266
1266
|
_motion,
|
|
1267
1267
|
...rest
|
|
1268
1268
|
} = props;
|
|
1269
|
-
const [x, setX] =
|
|
1270
|
-
const [pressed, setPressed] =
|
|
1271
|
-
const [growThumb, setGrowThumb] =
|
|
1269
|
+
const [x, setX] = React3__default.useState(0);
|
|
1270
|
+
const [pressed, setPressed] = React3__default.useState(false);
|
|
1271
|
+
const [growThumb, setGrowThumb] = React3__default.useState(false);
|
|
1272
1272
|
const borderWidth = 4;
|
|
1273
1273
|
const trackWidth = thumbSize * 1.5;
|
|
1274
1274
|
const borderRadius = thumbSize * 2.5;
|
|
@@ -1279,7 +1279,7 @@ function Switch(props) {
|
|
|
1279
1279
|
start: stopwatchStart,
|
|
1280
1280
|
clear: stopwatchClear
|
|
1281
1281
|
} = useStopwatch();
|
|
1282
|
-
|
|
1282
|
+
React3__default.useEffect(() => {
|
|
1283
1283
|
if (pressed && !disabled) {
|
|
1284
1284
|
stopwatchStart();
|
|
1285
1285
|
} else {
|
|
@@ -1287,12 +1287,12 @@ function Switch(props) {
|
|
|
1287
1287
|
stopwatchClear();
|
|
1288
1288
|
}
|
|
1289
1289
|
}, [pressed, disabled, stopwatchStart, stopwatchClear]);
|
|
1290
|
-
|
|
1290
|
+
React3__default.useEffect(() => {
|
|
1291
1291
|
if (stopwatchTime > 200) {
|
|
1292
1292
|
setGrowThumb(true);
|
|
1293
1293
|
}
|
|
1294
1294
|
}, [stopwatchTime]);
|
|
1295
|
-
|
|
1295
|
+
React3__default.useEffect(() => {
|
|
1296
1296
|
setX(checked ? checkedPosition : 0);
|
|
1297
1297
|
}, [checked, checkedPosition]);
|
|
1298
1298
|
const toggle = () => {
|
|
@@ -1357,10 +1357,10 @@ function Switch(props) {
|
|
|
1357
1357
|
children,
|
|
1358
1358
|
ThumbNameKey
|
|
1359
1359
|
);
|
|
1360
|
-
const trackElement = track ?
|
|
1360
|
+
const trackElement = track ? React3__default.cloneElement(track, {
|
|
1361
1361
|
_motion,
|
|
1362
|
-
children: thumb ?
|
|
1363
|
-
}) : /* @__PURE__ */ jsx(Track, { _motion, children: thumb ?
|
|
1362
|
+
children: thumb ? React3__default.cloneElement(thumb, { _motion }) : /* @__PURE__ */ jsx(Thumb, { _motion })
|
|
1363
|
+
}) : /* @__PURE__ */ jsx(Track, { _motion, children: thumb ? React3__default.cloneElement(thumb, { _motion }) : /* @__PURE__ */ jsx(Thumb, { _motion }) });
|
|
1364
1364
|
return /* @__PURE__ */ jsx(SwitchContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(MotionConfig, { transition: _motion, children: /* @__PURE__ */ jsx(
|
|
1365
1365
|
Button,
|
|
1366
1366
|
{
|
|
@@ -1486,10 +1486,10 @@ function Thumb(props) {
|
|
|
1486
1486
|
Track.displayName = TrackNameKey;
|
|
1487
1487
|
Thumb.displayName = ThumbNameKey;
|
|
1488
1488
|
function useStopwatch(props = {}) {
|
|
1489
|
-
const [active, setActive] =
|
|
1490
|
-
const [time, setTime] =
|
|
1489
|
+
const [active, setActive] = React3__default.useState(false);
|
|
1490
|
+
const [time, setTime] = React3__default.useState(0);
|
|
1491
1491
|
const timeInterval = props?.interval ?? 10;
|
|
1492
|
-
|
|
1492
|
+
React3__default.useEffect(() => {
|
|
1493
1493
|
let interval = null;
|
|
1494
1494
|
if (active) {
|
|
1495
1495
|
interval = setInterval(() => {
|
|
@@ -1500,19 +1500,19 @@ function useStopwatch(props = {}) {
|
|
|
1500
1500
|
}
|
|
1501
1501
|
return () => clearInterval(interval);
|
|
1502
1502
|
}, [active, timeInterval]);
|
|
1503
|
-
const start =
|
|
1504
|
-
const stop =
|
|
1505
|
-
const clear =
|
|
1503
|
+
const start = React3__default.useCallback(() => setActive(true), []);
|
|
1504
|
+
const stop = React3__default.useCallback(() => setActive(false), []);
|
|
1505
|
+
const clear = React3__default.useCallback(() => {
|
|
1506
1506
|
setActive(false);
|
|
1507
1507
|
setTime(0);
|
|
1508
1508
|
}, []);
|
|
1509
|
-
return
|
|
1509
|
+
return React3__default.useMemo(
|
|
1510
1510
|
() => ({ time, start, stop, clear }),
|
|
1511
1511
|
[time, start, stop, clear]
|
|
1512
1512
|
);
|
|
1513
1513
|
}
|
|
1514
1514
|
var switch_default = Switch;
|
|
1515
|
-
var RadioContext =
|
|
1515
|
+
var RadioContext = React3__default.createContext(null);
|
|
1516
1516
|
var Base2 = base;
|
|
1517
1517
|
var MotionDiv2 = motionTags.div;
|
|
1518
1518
|
function Radio(props) {
|
|
@@ -1529,14 +1529,14 @@ function Radio(props) {
|
|
|
1529
1529
|
onAnimationComplete: _onAnimationComplete,
|
|
1530
1530
|
...rest
|
|
1531
1531
|
} = props;
|
|
1532
|
-
const groupId =
|
|
1532
|
+
const groupId = React3__default.useId();
|
|
1533
1533
|
const isControlled = controlledValue !== void 0;
|
|
1534
|
-
const [uncontrolled, setUncontrolled] =
|
|
1534
|
+
const [uncontrolled, setUncontrolled] = React3__default.useState(
|
|
1535
1535
|
defaultValue
|
|
1536
1536
|
);
|
|
1537
1537
|
const selectedValue = isControlled ? controlledValue ?? null : uncontrolled;
|
|
1538
|
-
const itemsRef =
|
|
1539
|
-
const [activeId, setActiveId] =
|
|
1538
|
+
const itemsRef = React3__default.useRef([]);
|
|
1539
|
+
const [activeId, setActiveId] = React3__default.useState("");
|
|
1540
1540
|
const setSelectedValue = (val) => {
|
|
1541
1541
|
if (!isControlled) setUncontrolled(val);
|
|
1542
1542
|
onChange?.(val);
|
|
@@ -1589,7 +1589,7 @@ function Radio(props) {
|
|
|
1589
1589
|
setActiveId(found.id);
|
|
1590
1590
|
}
|
|
1591
1591
|
};
|
|
1592
|
-
|
|
1592
|
+
React3__default.useEffect(() => {
|
|
1593
1593
|
if (!selectedValue) return;
|
|
1594
1594
|
const selected = itemsRef.current.find((x) => x.value === selectedValue);
|
|
1595
1595
|
if (selected && !selected.disabled) setActiveId(selected.id);
|
|
@@ -1630,7 +1630,7 @@ function Radio(props) {
|
|
|
1630
1630
|
},
|
|
1631
1631
|
children: [
|
|
1632
1632
|
(options ?? []).map(
|
|
1633
|
-
(opt) => renderOption ? /* @__PURE__ */ jsx(
|
|
1633
|
+
(opt) => renderOption ? /* @__PURE__ */ jsx(React3__default.Fragment, { children: renderOption(opt) }, opt.value) : /* @__PURE__ */ jsx(
|
|
1634
1634
|
Item,
|
|
1635
1635
|
{
|
|
1636
1636
|
value: opt.value,
|
|
@@ -1662,16 +1662,16 @@ function Item(props) {
|
|
|
1662
1662
|
onAnimationComplete: _onAnimationComplete,
|
|
1663
1663
|
...rest
|
|
1664
1664
|
} = props;
|
|
1665
|
-
const ctx =
|
|
1666
|
-
const ref =
|
|
1667
|
-
const [isFocused, setIsFocused] =
|
|
1665
|
+
const ctx = React3__default.useContext(RadioContext);
|
|
1666
|
+
const ref = React3__default.useRef(null);
|
|
1667
|
+
const [isFocused, setIsFocused] = React3__default.useState(false);
|
|
1668
1668
|
const groupDisabled = ctx?.disabled;
|
|
1669
1669
|
const disabled = !!(groupDisabled || itemDisabled);
|
|
1670
1670
|
const groupId = ctx?.groupId ?? "";
|
|
1671
1671
|
const id = `radio-item-${groupId}-${value}`;
|
|
1672
1672
|
const registerItem = ctx?.registerItem;
|
|
1673
1673
|
const unregisterItem = ctx?.unregisterItem;
|
|
1674
|
-
|
|
1674
|
+
React3__default.useEffect(() => {
|
|
1675
1675
|
if (!registerItem || !unregisterItem) return;
|
|
1676
1676
|
registerItem({ id, value, disabled, ref });
|
|
1677
1677
|
return () => unregisterItem(id);
|
|
@@ -1687,12 +1687,12 @@ function Item(props) {
|
|
|
1687
1687
|
const isActive = isActiveId(id);
|
|
1688
1688
|
const shouldUseGrid = gridProp || !!colsProp;
|
|
1689
1689
|
const renderLabel = () => {
|
|
1690
|
-
const onlyChild =
|
|
1690
|
+
const onlyChild = React3__default.Children.count(children) === 1 ? React3__default.Children.toArray(children)[0] : null;
|
|
1691
1691
|
if (typeof onlyChild === "string") {
|
|
1692
1692
|
return /* @__PURE__ */ jsx(Base2, { "data-radio-label": true, children: onlyChild });
|
|
1693
1693
|
}
|
|
1694
|
-
if (
|
|
1695
|
-
return
|
|
1694
|
+
if (React3__default.isValidElement(onlyChild)) {
|
|
1695
|
+
return React3__default.cloneElement(
|
|
1696
1696
|
onlyChild,
|
|
1697
1697
|
{ "data-radio-label": true }
|
|
1698
1698
|
);
|
|
@@ -1809,7 +1809,7 @@ function Item(props) {
|
|
|
1809
1809
|
var LabelNameKey = "Label";
|
|
1810
1810
|
var Base3 = base;
|
|
1811
1811
|
var isBrowser = typeof window !== "undefined";
|
|
1812
|
-
var useIsomorphicLayoutEffect = isBrowser ?
|
|
1812
|
+
var useIsomorphicLayoutEffect = isBrowser ? React3__default.useLayoutEffect : React3__default.useEffect;
|
|
1813
1813
|
function pick(props, obj) {
|
|
1814
1814
|
return props.reduce((acc, prop) => {
|
|
1815
1815
|
acc[prop] = obj[prop];
|
|
@@ -1940,21 +1940,21 @@ function Textarea(props) {
|
|
|
1940
1940
|
...rest
|
|
1941
1941
|
} = props;
|
|
1942
1942
|
const isControlled = props.value !== void 0;
|
|
1943
|
-
const libRef =
|
|
1943
|
+
const libRef = React3__default.useRef(null);
|
|
1944
1944
|
const ref = assignRefs(libRef, userRef);
|
|
1945
|
-
const heightRef =
|
|
1946
|
-
const [_value, _setValue] =
|
|
1945
|
+
const heightRef = React3__default.useRef(0);
|
|
1946
|
+
const [_value, _setValue] = React3__default.useState("");
|
|
1947
1947
|
const value = props.value ?? _value;
|
|
1948
1948
|
const label = findChildrenByDisplayName(
|
|
1949
1949
|
children,
|
|
1950
1950
|
LabelNameKey
|
|
1951
1951
|
);
|
|
1952
|
-
const labelWithProps = label ?
|
|
1952
|
+
const labelWithProps = label ? React3__default.cloneElement(label, {
|
|
1953
1953
|
required: props.required,
|
|
1954
1954
|
value: props.value,
|
|
1955
1955
|
error
|
|
1956
1956
|
}) : null;
|
|
1957
|
-
const resizeTextarea =
|
|
1957
|
+
const resizeTextarea = React3__default.useCallback(() => {
|
|
1958
1958
|
const node = libRef.current;
|
|
1959
1959
|
if (!node) return;
|
|
1960
1960
|
const nodeSizingData = getSizingData(node);
|
|
@@ -1980,20 +1980,20 @@ function Textarea(props) {
|
|
|
1980
1980
|
useIsomorphicLayoutEffect(() => {
|
|
1981
1981
|
resizeTextarea();
|
|
1982
1982
|
}, [rest.value, rest.placeholder, resizeTextarea]);
|
|
1983
|
-
|
|
1983
|
+
React3__default.useEffect(() => {
|
|
1984
1984
|
if (!isBrowser) return;
|
|
1985
1985
|
const onResize = () => resizeTextarea();
|
|
1986
1986
|
window.addEventListener("resize", onResize);
|
|
1987
1987
|
return () => window.removeEventListener("resize", onResize);
|
|
1988
1988
|
}, [rest.placeholder, rest.value, resizeTextarea]);
|
|
1989
|
-
|
|
1989
|
+
React3__default.useEffect(() => {
|
|
1990
1990
|
const fonts = isBrowser ? document.fonts : void 0;
|
|
1991
1991
|
if (!fonts || typeof fonts.addEventListener !== "function") return;
|
|
1992
1992
|
const onFontsLoaded = () => resizeTextarea();
|
|
1993
1993
|
fonts.addEventListener("loadingdone", onFontsLoaded);
|
|
1994
1994
|
return () => fonts.removeEventListener("loadingdone", onFontsLoaded);
|
|
1995
1995
|
}, [rest.placeholder, rest.value, resizeTextarea]);
|
|
1996
|
-
|
|
1996
|
+
React3__default.useEffect(() => {
|
|
1997
1997
|
const node = libRef.current;
|
|
1998
1998
|
const form = node?.form;
|
|
1999
1999
|
if (!node || !form || isControlled) return;
|
|
@@ -2135,8 +2135,8 @@ function Icon(props) {
|
|
|
2135
2135
|
}
|
|
2136
2136
|
);
|
|
2137
2137
|
} else if (typeof IconComp === "function") {
|
|
2138
|
-
return
|
|
2139
|
-
} else if (
|
|
2138
|
+
return React3__default.createElement(IconComp);
|
|
2139
|
+
} else if (React3__default.isValidElement(IconComp)) {
|
|
2140
2140
|
return IconComp;
|
|
2141
2141
|
}
|
|
2142
2142
|
return null;
|
|
@@ -2165,13 +2165,13 @@ function Input(props) {
|
|
|
2165
2165
|
children,
|
|
2166
2166
|
RightSideNameKey
|
|
2167
2167
|
);
|
|
2168
|
-
const labelWithProps = label ?
|
|
2168
|
+
const labelWithProps = label ? React3__default.cloneElement(label, {
|
|
2169
2169
|
hasLeftIcon: !!leftIcon,
|
|
2170
2170
|
required: props.required,
|
|
2171
2171
|
value: props.value,
|
|
2172
2172
|
error
|
|
2173
2173
|
}) : null;
|
|
2174
|
-
const rightSideWithProps = rightSide ?
|
|
2174
|
+
const rightSideWithProps = rightSide ? React3__default.cloneElement(rightSide, {
|
|
2175
2175
|
onChange: props.onChange,
|
|
2176
2176
|
value: props.value
|
|
2177
2177
|
}) : null;
|
|
@@ -2316,29 +2316,29 @@ function Label2(props) {
|
|
|
2316
2316
|
Label2.displayName = LabelNameKey2;
|
|
2317
2317
|
function useResizeObserver(opts = {}) {
|
|
2318
2318
|
const onResize = opts.onResize;
|
|
2319
|
-
const onResizeRef =
|
|
2320
|
-
|
|
2319
|
+
const onResizeRef = React3__default.useRef(void 0);
|
|
2320
|
+
React3__default.useLayoutEffect(() => {
|
|
2321
2321
|
onResizeRef.current = onResize;
|
|
2322
2322
|
}, [onResize]);
|
|
2323
2323
|
const round = opts.round || Math.round;
|
|
2324
|
-
const resizeObserverRef =
|
|
2325
|
-
const [size, setSize] =
|
|
2324
|
+
const resizeObserverRef = React3__default.useRef(null);
|
|
2325
|
+
const [size, setSize] = React3__default.useState({
|
|
2326
2326
|
width: void 0,
|
|
2327
2327
|
height: void 0
|
|
2328
2328
|
});
|
|
2329
|
-
const didUnmount =
|
|
2330
|
-
|
|
2329
|
+
const didUnmount = React3__default.useRef(false);
|
|
2330
|
+
React3__default.useEffect(() => {
|
|
2331
2331
|
didUnmount.current = false;
|
|
2332
2332
|
return () => {
|
|
2333
2333
|
didUnmount.current = true;
|
|
2334
2334
|
};
|
|
2335
2335
|
}, []);
|
|
2336
|
-
const previous =
|
|
2336
|
+
const previous = React3__default.useRef({
|
|
2337
2337
|
width: void 0,
|
|
2338
2338
|
height: void 0
|
|
2339
2339
|
});
|
|
2340
2340
|
const refCallback = useResolvedElement(
|
|
2341
|
-
|
|
2341
|
+
React3__default.useCallback(
|
|
2342
2342
|
(element) => {
|
|
2343
2343
|
if (!resizeObserverRef.current || resizeObserverRef.current.box !== opts.box || resizeObserverRef.current.round !== round) {
|
|
2344
2344
|
resizeObserverRef.current = {
|
|
@@ -2378,7 +2378,7 @@ function useResizeObserver(opts = {}) {
|
|
|
2378
2378
|
),
|
|
2379
2379
|
opts.ref
|
|
2380
2380
|
);
|
|
2381
|
-
return
|
|
2381
|
+
return React3__default.useMemo(
|
|
2382
2382
|
() => ({
|
|
2383
2383
|
ref: refCallback,
|
|
2384
2384
|
width: size.width,
|
|
@@ -2390,12 +2390,12 @@ function useResizeObserver(opts = {}) {
|
|
|
2390
2390
|
);
|
|
2391
2391
|
}
|
|
2392
2392
|
function useResolvedElement(subscriber, refOrElement) {
|
|
2393
|
-
const lastReportRef =
|
|
2394
|
-
const refOrElementRef =
|
|
2395
|
-
|
|
2393
|
+
const lastReportRef = React3__default.useRef(null);
|
|
2394
|
+
const refOrElementRef = React3__default.useRef(null);
|
|
2395
|
+
React3__default.useLayoutEffect(() => {
|
|
2396
2396
|
refOrElementRef.current = refOrElement;
|
|
2397
2397
|
}, [refOrElement]);
|
|
2398
|
-
const cbElementRef =
|
|
2398
|
+
const cbElementRef = React3__default.useRef(null);
|
|
2399
2399
|
const evaluateSubscription = () => {
|
|
2400
2400
|
const cbElement = cbElementRef.current;
|
|
2401
2401
|
const refOrElement2 = refOrElementRef.current;
|
|
@@ -2414,10 +2414,10 @@ function useResolvedElement(subscriber, refOrElement) {
|
|
|
2414
2414
|
cleanup: element ? subscriber(element) : void 0
|
|
2415
2415
|
};
|
|
2416
2416
|
};
|
|
2417
|
-
|
|
2417
|
+
React3__default.useEffect(() => {
|
|
2418
2418
|
evaluateSubscription();
|
|
2419
2419
|
});
|
|
2420
|
-
|
|
2420
|
+
React3__default.useEffect(() => {
|
|
2421
2421
|
return () => {
|
|
2422
2422
|
if (lastReportRef.current && lastReportRef.current.cleanup) {
|
|
2423
2423
|
lastReportRef.current.cleanup();
|
|
@@ -2443,7 +2443,7 @@ var use_resize_observer_default = useResizeObserver;
|
|
|
2443
2443
|
var MotionDiv3 = motionTags.div;
|
|
2444
2444
|
var MotionBtn = motionTags.button;
|
|
2445
2445
|
var displayName = "AccordionItem";
|
|
2446
|
-
var AccordionContext =
|
|
2446
|
+
var AccordionContext = React3__default.createContext({});
|
|
2447
2447
|
function AccordionProvider(props) {
|
|
2448
2448
|
const [state, setState] = useImmer({
|
|
2449
2449
|
allowMultiple: false,
|
|
@@ -2453,7 +2453,7 @@ function AccordionProvider(props) {
|
|
|
2453
2453
|
return /* @__PURE__ */ jsx(AccordionContext.Provider, { value: { setState, state }, children: props.children });
|
|
2454
2454
|
}
|
|
2455
2455
|
function useAccordion() {
|
|
2456
|
-
const context2 =
|
|
2456
|
+
const context2 = React3__default.useContext(AccordionContext);
|
|
2457
2457
|
if (context2 === void 0) {
|
|
2458
2458
|
throw new Error("useAccordion must be used within a AccordionProvider");
|
|
2459
2459
|
}
|
|
@@ -2462,23 +2462,23 @@ function useAccordion() {
|
|
|
2462
2462
|
function AccordionComponent(props) {
|
|
2463
2463
|
const accordion = useAccordion();
|
|
2464
2464
|
const accordionState = accordion.state;
|
|
2465
|
-
|
|
2465
|
+
React3__default.useEffect(() => {
|
|
2466
2466
|
accordion.setState((draft) => {
|
|
2467
2467
|
draft.allowMultiple = !!props.allowMultiple;
|
|
2468
2468
|
draft.allowToggle = !!props.allowToggle;
|
|
2469
2469
|
});
|
|
2470
2470
|
}, [props.allowMultiple, props.allowToggle]);
|
|
2471
|
-
|
|
2471
|
+
React3__default.Children.forEach(props.children, (x) => {
|
|
2472
2472
|
if (typeof x.type === "function" && "displayName" in x.type && x.type.displayName !== displayName) {
|
|
2473
2473
|
throw new Error("Accordion can only have AccordionItems as children");
|
|
2474
2474
|
}
|
|
2475
2475
|
});
|
|
2476
|
-
const children =
|
|
2477
|
-
if (!
|
|
2478
|
-
return
|
|
2476
|
+
const children = React3__default.Children.map(props.children, (child, i) => {
|
|
2477
|
+
if (!React3__default.isValidElement(child)) return child;
|
|
2478
|
+
return React3__default.cloneElement(child, { idx: i });
|
|
2479
2479
|
});
|
|
2480
2480
|
const defaultOpenIdxList = JSON.stringify(props.defaultOpenIdx ?? []);
|
|
2481
|
-
|
|
2481
|
+
React3__default.useEffect(
|
|
2482
2482
|
() => {
|
|
2483
2483
|
if (accordionState.open.length === children.length) return;
|
|
2484
2484
|
const defaultOpenIdx = props.defaultOpenIdx;
|
|
@@ -2585,16 +2585,16 @@ var MotionDiv4 = motionTags.div;
|
|
|
2585
2585
|
var MotionBtn2 = motionTags.button;
|
|
2586
2586
|
var breakpoint = ["(min-width: 600px)"];
|
|
2587
2587
|
function DrawerComponent(props) {
|
|
2588
|
-
const ref =
|
|
2589
|
-
const dragHandleRef =
|
|
2588
|
+
const ref = React3__default.useRef(null);
|
|
2589
|
+
const dragHandleRef = React3__default.useRef(null);
|
|
2590
2590
|
const [isDesktop] = useMatchMedia(breakpoint);
|
|
2591
|
-
const closeFnRef =
|
|
2592
|
-
const prevOpenRef =
|
|
2591
|
+
const closeFnRef = React3__default.useRef(null);
|
|
2592
|
+
const prevOpenRef = React3__default.useRef(null);
|
|
2593
2593
|
const dragControls = useDragControls();
|
|
2594
2594
|
const { open, setOpen } = useDrawer();
|
|
2595
2595
|
const { onClose, onExitComplete, ...rest } = props;
|
|
2596
|
-
const [mounted, setMounted] =
|
|
2597
|
-
|
|
2596
|
+
const [mounted, setMounted] = React3__default.useState(false);
|
|
2597
|
+
React3__default.useEffect(() => {
|
|
2598
2598
|
setMounted(true);
|
|
2599
2599
|
}, []);
|
|
2600
2600
|
const y = useMotionValue(0);
|
|
@@ -2607,7 +2607,7 @@ function DrawerComponent(props) {
|
|
|
2607
2607
|
y.stop();
|
|
2608
2608
|
setOpen(false);
|
|
2609
2609
|
};
|
|
2610
|
-
|
|
2610
|
+
React3__default.useEffect(() => {
|
|
2611
2611
|
closeFnRef.current = () => {
|
|
2612
2612
|
closeDrawer();
|
|
2613
2613
|
onClose?.();
|
|
@@ -2627,7 +2627,7 @@ function DrawerComponent(props) {
|
|
|
2627
2627
|
);
|
|
2628
2628
|
}
|
|
2629
2629
|
};
|
|
2630
|
-
|
|
2630
|
+
React3__default.useLayoutEffect(() => {
|
|
2631
2631
|
const wasOpen = prevOpenRef.current;
|
|
2632
2632
|
const isOpen = props.open;
|
|
2633
2633
|
if (isOpen) {
|
|
@@ -2637,7 +2637,7 @@ function DrawerComponent(props) {
|
|
|
2637
2637
|
}
|
|
2638
2638
|
prevOpenRef.current = isOpen;
|
|
2639
2639
|
}, [props.open]);
|
|
2640
|
-
|
|
2640
|
+
React3__default.useEffect(() => {
|
|
2641
2641
|
const container = ref.current;
|
|
2642
2642
|
if (!open || !container) return;
|
|
2643
2643
|
container.setAttribute("tabindex", "0");
|
|
@@ -2659,7 +2659,7 @@ function DrawerComponent(props) {
|
|
|
2659
2659
|
document.body.style.overflow = "auto";
|
|
2660
2660
|
};
|
|
2661
2661
|
}, [open, props.closeOnEsc]);
|
|
2662
|
-
|
|
2662
|
+
React3__default.useEffect(() => {
|
|
2663
2663
|
if (!props.open) return;
|
|
2664
2664
|
const unsubscribeY = y.on("change", (latestY) => {
|
|
2665
2665
|
if (latestY > 150) {
|
|
@@ -2828,19 +2828,19 @@ function DrawerComponent(props) {
|
|
|
2828
2828
|
document.getElementById("portal")
|
|
2829
2829
|
);
|
|
2830
2830
|
}
|
|
2831
|
-
var DrawerContext =
|
|
2831
|
+
var DrawerContext = React3__default.createContext({
|
|
2832
2832
|
open: false,
|
|
2833
2833
|
setOpen: () => {
|
|
2834
2834
|
return;
|
|
2835
2835
|
}
|
|
2836
2836
|
});
|
|
2837
2837
|
function DrawerProvider(props) {
|
|
2838
|
-
const [open, setOpen] =
|
|
2838
|
+
const [open, setOpen] = React3__default.useState(false);
|
|
2839
2839
|
const value = { open, setOpen };
|
|
2840
2840
|
return /* @__PURE__ */ jsx(DrawerContext.Provider, { value, children: props.children });
|
|
2841
2841
|
}
|
|
2842
2842
|
function useDrawer() {
|
|
2843
|
-
const context2 =
|
|
2843
|
+
const context2 = React3__default.useContext(DrawerContext);
|
|
2844
2844
|
if (context2 === void 0) {
|
|
2845
2845
|
throw new Error("useDrawer must be used within a DrawerProvider");
|
|
2846
2846
|
}
|
|
@@ -2853,7 +2853,7 @@ function BtnGroup(props) {
|
|
|
2853
2853
|
const [isDesktop] = useMatchMedia(breakpoint);
|
|
2854
2854
|
const { children, ...rest } = props;
|
|
2855
2855
|
if (isDesktop) {
|
|
2856
|
-
return /* @__PURE__ */ jsx(MotionDiv4, { flex: true, alignI: true, gap: 4, ...rest, children:
|
|
2856
|
+
return /* @__PURE__ */ jsx(MotionDiv4, { flex: true, alignI: true, gap: 4, ...rest, children: React3__default.Children.toArray(children).toReversed() });
|
|
2857
2857
|
} else {
|
|
2858
2858
|
return /* @__PURE__ */ jsx(MotionDiv4, { grid: true, rowG: 14, ...props });
|
|
2859
2859
|
}
|
|
@@ -2906,7 +2906,7 @@ function CloseBtn(props) {
|
|
|
2906
2906
|
}
|
|
2907
2907
|
}
|
|
2908
2908
|
function Backdrop(props) {
|
|
2909
|
-
const allowOutsideClickRef =
|
|
2909
|
+
const allowOutsideClickRef = React3__default.useRef(true);
|
|
2910
2910
|
const [isDesktop] = useMatchMedia(breakpoint);
|
|
2911
2911
|
return /* @__PURE__ */ jsx(
|
|
2912
2912
|
MotionDiv4,
|
|
@@ -2937,11 +2937,11 @@ function Backdrop(props) {
|
|
|
2937
2937
|
}
|
|
2938
2938
|
function useMatchMedia(queries) {
|
|
2939
2939
|
const isClient = typeof window !== "undefined";
|
|
2940
|
-
const [value, setValue] =
|
|
2940
|
+
const [value, setValue] = React3__default.useState(() => {
|
|
2941
2941
|
if (!isClient) return queries.map(() => false);
|
|
2942
2942
|
return queries.map((q) => window.matchMedia(q).matches);
|
|
2943
2943
|
});
|
|
2944
|
-
|
|
2944
|
+
React3__default.useLayoutEffect(() => {
|
|
2945
2945
|
if (!isClient) return;
|
|
2946
2946
|
const mediaQueryLists = queries.map((q) => window.matchMedia(q));
|
|
2947
2947
|
const handler = () => {
|
|
@@ -2960,9 +2960,9 @@ var TrackBgNameKey = "TrackBg";
|
|
|
2960
2960
|
var TrackFillNameKey = "TrackFill";
|
|
2961
2961
|
function Progress(props) {
|
|
2962
2962
|
const { children, steps, value, max: maxProp, ...rest } = props;
|
|
2963
|
-
const [progress, setProgress] =
|
|
2963
|
+
const [progress, setProgress] = React3__default.useState(0);
|
|
2964
2964
|
const max = maxProp ?? 100;
|
|
2965
|
-
|
|
2965
|
+
React3__default.useEffect(() => {
|
|
2966
2966
|
setProgress(Math.min((value ?? 0) / max, 1) * 100);
|
|
2967
2967
|
}, [value, max]);
|
|
2968
2968
|
const width = `${progress}%`;
|
|
@@ -3002,7 +3002,7 @@ function Progress(props) {
|
|
|
3002
3002
|
TrackFillNameKey
|
|
3003
3003
|
);
|
|
3004
3004
|
const barHeight = rest.h ?? 8;
|
|
3005
|
-
const bgEl = trackBgChild ?
|
|
3005
|
+
const bgEl = trackBgChild ? React3__default.cloneElement(trackBgChild, {
|
|
3006
3006
|
gridArea: "1 / 1",
|
|
3007
3007
|
h: barHeight,
|
|
3008
3008
|
w: trackBgChild.props.w ?? true
|
|
@@ -3017,7 +3017,7 @@ function Progress(props) {
|
|
|
3017
3017
|
bg: { base: "neutral.200", _dark: "neutral.700" }
|
|
3018
3018
|
}
|
|
3019
3019
|
);
|
|
3020
|
-
const fillEl = trackFillChild ?
|
|
3020
|
+
const fillEl = trackFillChild ? React3__default.cloneElement(trackFillChild, {
|
|
3021
3021
|
gridArea: "1 / 1",
|
|
3022
3022
|
h: barHeight,
|
|
3023
3023
|
roundedLeft: 9999,
|
|
@@ -3091,9 +3091,9 @@ var MotionDiv6 = motionTags.div;
|
|
|
3091
3091
|
var TrackNameKey2 = "SliderTrack";
|
|
3092
3092
|
var FillNameKey = "SliderFill";
|
|
3093
3093
|
var ThumbNameKey2 = "SliderThumb";
|
|
3094
|
-
var SliderContext =
|
|
3094
|
+
var SliderContext = React3__default.createContext(null);
|
|
3095
3095
|
var useSliderContext = () => {
|
|
3096
|
-
const context2 =
|
|
3096
|
+
const context2 = React3__default.useContext(SliderContext);
|
|
3097
3097
|
if (!context2) {
|
|
3098
3098
|
throw new Error("Slider compound components must be used within Slider");
|
|
3099
3099
|
}
|
|
@@ -3113,15 +3113,15 @@ function Slider(props) {
|
|
|
3113
3113
|
...rest
|
|
3114
3114
|
} = props;
|
|
3115
3115
|
const isControlled = controlledValue !== void 0;
|
|
3116
|
-
const [internalValue, setInternalValue] =
|
|
3116
|
+
const [internalValue, setInternalValue] = React3__default.useState(defaultValue);
|
|
3117
3117
|
const value = isControlled ? controlledValue : internalValue;
|
|
3118
|
-
const [isDragging, setIsDragging] =
|
|
3119
|
-
const trackRef =
|
|
3118
|
+
const [isDragging, setIsDragging] = React3__default.useState(false);
|
|
3119
|
+
const trackRef = React3__default.useRef(null);
|
|
3120
3120
|
const percent = Math.min(
|
|
3121
3121
|
100,
|
|
3122
3122
|
Math.max(0, (value - min) / (max - min) * 100)
|
|
3123
3123
|
);
|
|
3124
|
-
const clampValue =
|
|
3124
|
+
const clampValue = React3__default.useCallback(
|
|
3125
3125
|
(rawValue) => {
|
|
3126
3126
|
let clamped = Math.max(min, Math.min(max, rawValue));
|
|
3127
3127
|
if (step !== void 0 && step > 0) {
|
|
@@ -3132,7 +3132,7 @@ function Slider(props) {
|
|
|
3132
3132
|
},
|
|
3133
3133
|
[min, max, step]
|
|
3134
3134
|
);
|
|
3135
|
-
const getValueFromClientX =
|
|
3135
|
+
const getValueFromClientX = React3__default.useCallback(
|
|
3136
3136
|
(clientX) => {
|
|
3137
3137
|
const track = trackRef.current;
|
|
3138
3138
|
if (!track) return value;
|
|
@@ -3144,7 +3144,7 @@ function Slider(props) {
|
|
|
3144
3144
|
},
|
|
3145
3145
|
[min, max, value, clampValue]
|
|
3146
3146
|
);
|
|
3147
|
-
const updateValue =
|
|
3147
|
+
const updateValue = React3__default.useCallback(
|
|
3148
3148
|
(newValue) => {
|
|
3149
3149
|
if (disabled) return;
|
|
3150
3150
|
if (!isControlled) {
|
|
@@ -3161,7 +3161,7 @@ function Slider(props) {
|
|
|
3161
3161
|
const newValue = getValueFromClientX(e.clientX);
|
|
3162
3162
|
updateValue(newValue);
|
|
3163
3163
|
};
|
|
3164
|
-
|
|
3164
|
+
React3__default.useEffect(() => {
|
|
3165
3165
|
if (!isDragging) return;
|
|
3166
3166
|
const controller = new AbortController();
|
|
3167
3167
|
const handleMove = (e) => {
|
|
@@ -3231,19 +3231,19 @@ function Slider(props) {
|
|
|
3231
3231
|
trackRef
|
|
3232
3232
|
};
|
|
3233
3233
|
const height = rest.h ?? 8;
|
|
3234
|
-
const trackEl = trackChild ?
|
|
3234
|
+
const trackEl = trackChild ? React3__default.cloneElement(trackChild, {
|
|
3235
3235
|
sliderPercent: percent,
|
|
3236
3236
|
sliderValue: value,
|
|
3237
3237
|
sliderMin: min,
|
|
3238
3238
|
sliderMax: max
|
|
3239
3239
|
}) : /* @__PURE__ */ jsx(SliderTrack, {});
|
|
3240
|
-
const fillEl = fillChild ?
|
|
3240
|
+
const fillEl = fillChild ? React3__default.cloneElement(fillChild, {
|
|
3241
3241
|
sliderPercent: percent,
|
|
3242
3242
|
sliderValue: value,
|
|
3243
3243
|
sliderMin: min,
|
|
3244
3244
|
sliderMax: max
|
|
3245
3245
|
}) : /* @__PURE__ */ jsx(SliderFill, {});
|
|
3246
|
-
const thumbEl = thumbChild ?
|
|
3246
|
+
const thumbEl = thumbChild ? React3__default.cloneElement(thumbChild, {
|
|
3247
3247
|
sliderPercent: percent,
|
|
3248
3248
|
sliderValue: value,
|
|
3249
3249
|
sliderMin: min,
|
|
@@ -3379,12 +3379,12 @@ function Checkbox(props) {
|
|
|
3379
3379
|
onAnimationComplete: _onAnimationComplete,
|
|
3380
3380
|
...rest
|
|
3381
3381
|
} = props;
|
|
3382
|
-
const [checked, setChecked] =
|
|
3383
|
-
const [indeterminate, setIndeterminate] =
|
|
3384
|
-
|
|
3382
|
+
const [checked, setChecked] = React3__default.useState(false);
|
|
3383
|
+
const [indeterminate, setIndeterminate] = React3__default.useState(false);
|
|
3384
|
+
React3__default.useEffect(() => {
|
|
3385
3385
|
setChecked(!!rest.checked);
|
|
3386
3386
|
}, [rest.checked]);
|
|
3387
|
-
|
|
3387
|
+
React3__default.useEffect(() => {
|
|
3388
3388
|
setIndeterminate(!!rest.indeterminate);
|
|
3389
3389
|
}, [rest.indeterminate]);
|
|
3390
3390
|
const isIndeterminate = typeof rest.indeterminate === "boolean";
|
|
@@ -3489,15 +3489,15 @@ function Tooltip(props) {
|
|
|
3489
3489
|
delay = 80,
|
|
3490
3490
|
className
|
|
3491
3491
|
} = props;
|
|
3492
|
-
const referenceRef =
|
|
3493
|
-
const arrowRef =
|
|
3494
|
-
const closeTimerRef =
|
|
3492
|
+
const referenceRef = React3__default.useRef(null);
|
|
3493
|
+
const arrowRef = React3__default.useRef(null);
|
|
3494
|
+
const closeTimerRef = React3__default.useRef(
|
|
3495
3495
|
null
|
|
3496
3496
|
);
|
|
3497
|
-
const containerRef =
|
|
3498
|
-
const [open, setOpen] =
|
|
3499
|
-
const [isMounted, setIsMounted] =
|
|
3500
|
-
const [containerBg, setContainerBg] =
|
|
3497
|
+
const containerRef = React3__default.useRef(null);
|
|
3498
|
+
const [open, setOpen] = React3__default.useState(false);
|
|
3499
|
+
const [isMounted, setIsMounted] = React3__default.useState(false);
|
|
3500
|
+
const [containerBg, setContainerBg] = React3__default.useState();
|
|
3501
3501
|
const { x, y, refs, strategy, middlewareData, context: context2 } = useFloating({
|
|
3502
3502
|
open,
|
|
3503
3503
|
onOpenChange: setOpen,
|
|
@@ -3527,7 +3527,7 @@ function Tooltip(props) {
|
|
|
3527
3527
|
role
|
|
3528
3528
|
]);
|
|
3529
3529
|
const referenceProps = getReferenceProps({});
|
|
3530
|
-
|
|
3530
|
+
React3__default.useEffect(() => {
|
|
3531
3531
|
if (closeTimerRef.current) {
|
|
3532
3532
|
clearTimeout(closeTimerRef.current);
|
|
3533
3533
|
closeTimerRef.current = null;
|
|
@@ -3547,7 +3547,7 @@ function Tooltip(props) {
|
|
|
3547
3547
|
}
|
|
3548
3548
|
};
|
|
3549
3549
|
}, [open]);
|
|
3550
|
-
|
|
3550
|
+
React3__default.useEffect(() => {
|
|
3551
3551
|
if (!follow || !referenceRef.current) return;
|
|
3552
3552
|
const el = referenceRef.current;
|
|
3553
3553
|
const onMove = (e) => {
|
|
@@ -3562,7 +3562,7 @@ function Tooltip(props) {
|
|
|
3562
3562
|
el.removeEventListener("pointermove", onMove);
|
|
3563
3563
|
};
|
|
3564
3564
|
}, [follow, refs]);
|
|
3565
|
-
|
|
3565
|
+
React3__default.useEffect(() => {
|
|
3566
3566
|
if (!(open || isMounted)) return;
|
|
3567
3567
|
const el = containerRef.current;
|
|
3568
3568
|
if (!el) return;
|
|
@@ -3585,14 +3585,14 @@ function Tooltip(props) {
|
|
|
3585
3585
|
const arrowAnchorStyle = side.startsWith("top") ? { bottom: -anchorOffset } : side.startsWith("bottom") ? { top: -anchorOffset } : side.startsWith("left") ? { right: -anchorOffset } : { left: -anchorOffset };
|
|
3586
3586
|
const arrowStyle = side.startsWith("top") || side.startsWith("bottom") ? { left: arrowX || void 0, ...arrowAnchorStyle } : { top: arrowY || void 0, ...arrowAnchorStyle };
|
|
3587
3587
|
const transformOrigin = side.startsWith("top") ? "center bottom" : side.startsWith("bottom") ? "center top" : side.startsWith("left") ? "right center" : side.startsWith("right") ? "left center" : "center";
|
|
3588
|
-
const childrenArray =
|
|
3588
|
+
const childrenArray = React3__default.Children.toArray(children);
|
|
3589
3589
|
const hasMultipleChildren = childrenArray.length > 1;
|
|
3590
3590
|
let child;
|
|
3591
3591
|
if (hasMultipleChildren) {
|
|
3592
3592
|
child = /* @__PURE__ */ jsx("div", { style: { display: "inline-block" }, children });
|
|
3593
3593
|
} else {
|
|
3594
|
-
const only =
|
|
3595
|
-
const isDomElement =
|
|
3594
|
+
const only = React3__default.Children.only(children);
|
|
3595
|
+
const isDomElement = React3__default.isValidElement(only) && typeof only.type === "string";
|
|
3596
3596
|
child = isDomElement ? only : (
|
|
3597
3597
|
// Ensure the wrapper reliably captures mouseenter/pointerenter and can contain block elements
|
|
3598
3598
|
/* @__PURE__ */ jsx("div", { style: { display: "inline-block" }, children: only })
|
|
@@ -3611,7 +3611,7 @@ function Tooltip(props) {
|
|
|
3611
3611
|
originalRef.current = node;
|
|
3612
3612
|
}
|
|
3613
3613
|
};
|
|
3614
|
-
const cloned =
|
|
3614
|
+
const cloned = React3__default.cloneElement(
|
|
3615
3615
|
child,
|
|
3616
3616
|
// eslint-disable-next-line react-hooks/refs -- ref callback is invoked after render, not during
|
|
3617
3617
|
{
|
|
@@ -3624,14 +3624,14 @@ function Tooltip(props) {
|
|
|
3624
3624
|
let arrowEl = null;
|
|
3625
3625
|
let floatingNode = null;
|
|
3626
3626
|
const findRoleTooltipElement = (node) => {
|
|
3627
|
-
if (!
|
|
3627
|
+
if (!React3__default.isValidElement(node)) return null;
|
|
3628
3628
|
const el = node;
|
|
3629
3629
|
if (el.props?.role === "tooltip") return el;
|
|
3630
3630
|
const kids = el.props?.children;
|
|
3631
3631
|
if (!kids) return null;
|
|
3632
|
-
const arr =
|
|
3632
|
+
const arr = React3__default.Children.toArray(kids);
|
|
3633
3633
|
for (const c of arr) {
|
|
3634
|
-
if (
|
|
3634
|
+
if (React3__default.isValidElement(c)) {
|
|
3635
3635
|
const childEl = c;
|
|
3636
3636
|
if (childEl.props?.role === "tooltip") {
|
|
3637
3637
|
return childEl;
|
|
@@ -3640,9 +3640,8 @@ function Tooltip(props) {
|
|
|
3640
3640
|
}
|
|
3641
3641
|
return null;
|
|
3642
3642
|
};
|
|
3643
|
-
const
|
|
3644
|
-
|
|
3645
|
-
if (isCustomTooltip) {
|
|
3643
|
+
const customEl = findRoleTooltipElement(content);
|
|
3644
|
+
if (customEl) {
|
|
3646
3645
|
const el = customEl;
|
|
3647
3646
|
const childProps = el.props || {};
|
|
3648
3647
|
const floatingProps = getFloatingProps({});
|
|
@@ -3739,7 +3738,7 @@ function Tooltip(props) {
|
|
|
3739
3738
|
originalChildRef.current = node;
|
|
3740
3739
|
}
|
|
3741
3740
|
};
|
|
3742
|
-
return
|
|
3741
|
+
return React3__default.cloneElement(
|
|
3743
3742
|
el,
|
|
3744
3743
|
// eslint-disable-next-line react-hooks/refs -- ref callback is invoked after render, not during
|
|
3745
3744
|
{
|
|
@@ -3843,7 +3842,7 @@ function Block(props) {
|
|
|
3843
3842
|
tooltip,
|
|
3844
3843
|
...rest
|
|
3845
3844
|
} = anyProps;
|
|
3846
|
-
const fileInputRef =
|
|
3845
|
+
const fileInputRef = React3.useRef(null);
|
|
3847
3846
|
const isLoading = anyProps.isLoading;
|
|
3848
3847
|
const multiple = anyProps.multiple;
|
|
3849
3848
|
const is = anyProps.is;
|
|
@@ -3880,7 +3879,7 @@ function Block(props) {
|
|
|
3880
3879
|
...anyProps
|
|
3881
3880
|
}
|
|
3882
3881
|
) : extract.filepickerAllowed ? /* @__PURE__ */ jsxs("div", { onClick: () => fileInputRef.current?.click(), children: [
|
|
3883
|
-
|
|
3882
|
+
React3.createElement(
|
|
3884
3883
|
Comp,
|
|
3885
3884
|
{
|
|
3886
3885
|
cursor: "pointer",
|
|
@@ -3915,11 +3914,11 @@ function Block(props) {
|
|
|
3915
3914
|
value: ""
|
|
3916
3915
|
}
|
|
3917
3916
|
)
|
|
3918
|
-
] }) : extract.isVoidElement ?
|
|
3917
|
+
] }) : extract.isVoidElement ? React3.createElement(Comp, {
|
|
3919
3918
|
...isLoading && { "data-loading": isLoading },
|
|
3920
3919
|
onContextMenu: (e) => e.preventDefault(),
|
|
3921
3920
|
...initialStyles
|
|
3922
|
-
}) :
|
|
3921
|
+
}) : React3.createElement(
|
|
3923
3922
|
Comp,
|
|
3924
3923
|
{
|
|
3925
3924
|
...isLoading && { "data-loading": isLoading },
|
|
@@ -4019,22 +4018,22 @@ var saveTheme = (theme) => {
|
|
|
4019
4018
|
}
|
|
4020
4019
|
};
|
|
4021
4020
|
function useTheme() {
|
|
4022
|
-
const [value, setValue] =
|
|
4021
|
+
const [value, setValue] = React3__default.useState(() => {
|
|
4023
4022
|
return getDomTheme() ?? getStoredTheme() ?? "light";
|
|
4024
4023
|
});
|
|
4025
|
-
const valueRef =
|
|
4026
|
-
const isInternalRef =
|
|
4027
|
-
|
|
4024
|
+
const valueRef = React3__default.useRef(value);
|
|
4025
|
+
const isInternalRef = React3__default.useRef(false);
|
|
4026
|
+
React3__default.useEffect(() => {
|
|
4028
4027
|
valueRef.current = value;
|
|
4029
4028
|
}, [value]);
|
|
4030
|
-
|
|
4029
|
+
React3__default.useLayoutEffect(() => {
|
|
4031
4030
|
const domTheme = getDomTheme();
|
|
4032
4031
|
if (domTheme && domTheme !== valueRef.current) {
|
|
4033
4032
|
valueRef.current = domTheme;
|
|
4034
4033
|
setValue(domTheme);
|
|
4035
4034
|
}
|
|
4036
4035
|
}, []);
|
|
4037
|
-
|
|
4036
|
+
React3__default.useEffect(() => {
|
|
4038
4037
|
const ac = new AbortController();
|
|
4039
4038
|
window.addEventListener(
|
|
4040
4039
|
"storage",
|
|
@@ -4066,7 +4065,7 @@ function useTheme() {
|
|
|
4066
4065
|
);
|
|
4067
4066
|
return () => ac.abort();
|
|
4068
4067
|
}, []);
|
|
4069
|
-
const toggle =
|
|
4068
|
+
const toggle = React3__default.useCallback((theme) => {
|
|
4070
4069
|
const next = theme ?? (valueRef.current === "light" ? "dark" : "light");
|
|
4071
4070
|
valueRef.current = next;
|
|
4072
4071
|
setValue(next);
|
|
@@ -4079,8 +4078,8 @@ function useTheme() {
|
|
|
4079
4078
|
|
|
4080
4079
|
// src/react/index.ts
|
|
4081
4080
|
function useDebounce(value, delay = 500) {
|
|
4082
|
-
const [debouncedValue, setDebouncedValue] =
|
|
4083
|
-
|
|
4081
|
+
const [debouncedValue, setDebouncedValue] = React3__default.useState(value);
|
|
4082
|
+
React3__default.useEffect(() => {
|
|
4084
4083
|
const handler = setTimeout(() => {
|
|
4085
4084
|
setDebouncedValue(value);
|
|
4086
4085
|
}, delay);
|
|
@@ -4091,10 +4090,10 @@ function useDebounce(value, delay = 500) {
|
|
|
4091
4090
|
return debouncedValue;
|
|
4092
4091
|
}
|
|
4093
4092
|
function useThrottle(value, interval = 500) {
|
|
4094
|
-
const [throttledValue, setThrottledValue] =
|
|
4095
|
-
const lastUpdate =
|
|
4096
|
-
const timeoutRef =
|
|
4097
|
-
|
|
4093
|
+
const [throttledValue, setThrottledValue] = React3__default.useState(value);
|
|
4094
|
+
const lastUpdate = React3__default.useRef(0);
|
|
4095
|
+
const timeoutRef = React3__default.useRef(null);
|
|
4096
|
+
React3__default.useEffect(() => {
|
|
4098
4097
|
const now = Date.now();
|
|
4099
4098
|
const timeSinceLastUpdate = now - lastUpdate.current;
|
|
4100
4099
|
if (timeSinceLastUpdate >= interval) {
|
|
@@ -4120,11 +4119,11 @@ function useThrottle(value, interval = 500) {
|
|
|
4120
4119
|
function useMatchMedia2(queries, defaultValues = []) {
|
|
4121
4120
|
const initialValues = defaultValues.length ? defaultValues : Array(queries.length).fill(false);
|
|
4122
4121
|
const isClient = typeof window !== "undefined";
|
|
4123
|
-
const [value, setValue] =
|
|
4122
|
+
const [value, setValue] = React3__default.useState(() => {
|
|
4124
4123
|
if (!isClient) return initialValues;
|
|
4125
4124
|
return queries.map((q) => window.matchMedia(q).matches);
|
|
4126
4125
|
});
|
|
4127
|
-
|
|
4126
|
+
React3__default.useLayoutEffect(() => {
|
|
4128
4127
|
if (!isClient) return;
|
|
4129
4128
|
const mediaQueryLists = queries.map((q) => window.matchMedia(q));
|
|
4130
4129
|
const handler = () => {
|