qstd 0.2.22 → 0.2.23
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/block/fns.d.ts +1 -0
- package/dist/block/fns.d.ts.map +1 -1
- package/dist/block/index.d.ts +7 -0
- package/dist/block/index.d.ts.map +1 -1
- package/dist/block/slider.d.ts +22 -0
- package/dist/block/slider.d.ts.map +1 -0
- package/dist/block/types.d.ts +18 -0
- package/dist/block/types.d.ts.map +1 -1
- package/dist/react/index.cjs +430 -141
- package/dist/react/index.css +25 -6
- package/dist/react/index.js +426 -137
- package/package.json +1 -1
- package/styled-system/styles.css +33 -8
package/dist/react/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./index.css";
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
2
|
+
import * as React13 from 'react';
|
|
3
|
+
import React13__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';
|
|
@@ -607,14 +607,14 @@ function Menu(props) {
|
|
|
607
607
|
trigger,
|
|
608
608
|
...rest
|
|
609
609
|
} = props;
|
|
610
|
-
const hoverTimeoutRef =
|
|
611
|
-
const [isOpen, setOpen] =
|
|
610
|
+
const hoverTimeoutRef = React13__default.useRef(null);
|
|
611
|
+
const [isOpen, setOpen] = React13__default.useState(isOpenControlled ?? false);
|
|
612
612
|
const onOpenChange = (open) => {
|
|
613
613
|
const newOpenState = typeof open === "function" ? open(isOpen) : open;
|
|
614
614
|
props.onOpenOrClose?.(newOpenState);
|
|
615
615
|
setOpen(newOpenState);
|
|
616
616
|
};
|
|
617
|
-
|
|
617
|
+
React13__default.useEffect(() => {
|
|
618
618
|
if (typeof isOpenControlled !== "boolean") return;
|
|
619
619
|
setOpen(isOpenControlled);
|
|
620
620
|
}, [isOpenControlled]);
|
|
@@ -689,11 +689,11 @@ function Menu(props) {
|
|
|
689
689
|
},
|
|
690
690
|
isOpen
|
|
691
691
|
);
|
|
692
|
-
|
|
692
|
+
React13__default.useEffect(() => {
|
|
693
693
|
if (!hideData?.referenceHidden) return;
|
|
694
694
|
closeMenuImmediate();
|
|
695
695
|
}, [hideData, closeMenuImmediate]);
|
|
696
|
-
|
|
696
|
+
React13__default.useEffect(() => {
|
|
697
697
|
return () => {
|
|
698
698
|
if (hoverTimeoutRef.current) clearTimeout(hoverTimeoutRef.current);
|
|
699
699
|
};
|
|
@@ -719,10 +719,10 @@ function Menu(props) {
|
|
|
719
719
|
onMouseLeave: handleMenuMouseLeave
|
|
720
720
|
} : {};
|
|
721
721
|
const transformOrigin = floatingContext.placement.startsWith("top") ? "bottom left" : "top left";
|
|
722
|
-
const childArray =
|
|
722
|
+
const childArray = React13__default.Children.toArray(children);
|
|
723
723
|
let customContainerEl = null;
|
|
724
724
|
for (const c of childArray) {
|
|
725
|
-
if (
|
|
725
|
+
if (React13__default.isValidElement(c)) {
|
|
726
726
|
const anyType = c.type;
|
|
727
727
|
if (c.props?.["data-menu-container"] || anyType?.isBlockMenuContainer) {
|
|
728
728
|
customContainerEl = c;
|
|
@@ -751,7 +751,7 @@ function Menu(props) {
|
|
|
751
751
|
...restStyle || {}
|
|
752
752
|
};
|
|
753
753
|
const mergedClassName = [defaultsClassName, childProps.className].filter(Boolean).join(" ");
|
|
754
|
-
const contentNode =
|
|
754
|
+
const contentNode = React13__default.cloneElement(
|
|
755
755
|
customContainerEl,
|
|
756
756
|
{
|
|
757
757
|
// Defaults are now in mergedClassName via css()
|
|
@@ -837,7 +837,7 @@ function Menu(props) {
|
|
|
837
837
|
);
|
|
838
838
|
}
|
|
839
839
|
function useOutsideClick(ref, handler, enabled = true) {
|
|
840
|
-
|
|
840
|
+
React13__default.useEffect(() => {
|
|
841
841
|
if (!enabled) return;
|
|
842
842
|
const listener = (event) => {
|
|
843
843
|
if (!ref.current || ref.current.contains(event.target)) {
|
|
@@ -944,9 +944,9 @@ var prepareFiles = async (acceptedFiles) => {
|
|
|
944
944
|
);
|
|
945
945
|
};
|
|
946
946
|
var findChildrenByDisplayName = (children, displayName2) => {
|
|
947
|
-
return
|
|
947
|
+
return React13__default.Children.toArray(children).find(
|
|
948
948
|
(child) => {
|
|
949
|
-
if (
|
|
949
|
+
if (React13__default.isValidElement(child)) {
|
|
950
950
|
const childType = child.type;
|
|
951
951
|
return childType.displayName === displayName2;
|
|
952
952
|
} else {
|
|
@@ -973,6 +973,7 @@ var extractElType = (is, props) => {
|
|
|
973
973
|
else if (is === "blockquote") el = "blockquote";
|
|
974
974
|
else if (is === "pre") el = "pre";
|
|
975
975
|
else if (is === "progress") el = "progress";
|
|
976
|
+
else if (is === "slider") el = "div";
|
|
976
977
|
else if (is === "drawer") el = "div";
|
|
977
978
|
else if (is === "menu") el = "div";
|
|
978
979
|
else if (is === "form") el = "form";
|
|
@@ -987,6 +988,7 @@ var extractElType = (is, props) => {
|
|
|
987
988
|
const isRadio = is === "radio";
|
|
988
989
|
const isDrawer = is === "drawer";
|
|
989
990
|
const isSwitch = is === "switch";
|
|
991
|
+
const isSlider = is === "slider";
|
|
990
992
|
const isSkeleton = is === "skeleton";
|
|
991
993
|
const isCheckbox = is === "checkbox";
|
|
992
994
|
const isTextarea = is === "textarea";
|
|
@@ -1003,6 +1005,7 @@ var extractElType = (is, props) => {
|
|
|
1003
1005
|
isInput,
|
|
1004
1006
|
isRadio,
|
|
1005
1007
|
isSwitch,
|
|
1008
|
+
isSlider,
|
|
1006
1009
|
isBtnLike,
|
|
1007
1010
|
isAccordion,
|
|
1008
1011
|
filepickerAllowed,
|
|
@@ -1088,7 +1091,7 @@ function getIcon(position, Icon2, props) {
|
|
|
1088
1091
|
const Cmp = loadingIconsMap[chosen];
|
|
1089
1092
|
const sizePx = typeof loadingIconSize === "number" ? `${loadingIconSize}px` : "12px";
|
|
1090
1093
|
return Cmp({ width: sizePx, height: sizePx });
|
|
1091
|
-
} else if (
|
|
1094
|
+
} else if (React13__default.isValidElement(chosen)) {
|
|
1092
1095
|
return chosen;
|
|
1093
1096
|
} else if (typeof chosen === "function") {
|
|
1094
1097
|
return chosen();
|
|
@@ -1185,9 +1188,9 @@ var TrackNameKey = "Track";
|
|
|
1185
1188
|
var ThumbNameKey = "Thumb";
|
|
1186
1189
|
var Button = motionTags.button;
|
|
1187
1190
|
var Base = motionTags.div;
|
|
1188
|
-
var SwitchContext =
|
|
1191
|
+
var SwitchContext = React13__default.createContext(null);
|
|
1189
1192
|
var useSwitchContext = () => {
|
|
1190
|
-
const context2 =
|
|
1193
|
+
const context2 = React13__default.useContext(SwitchContext);
|
|
1191
1194
|
if (!context2) {
|
|
1192
1195
|
throw new Error("Switch compound components must be used within Switch");
|
|
1193
1196
|
}
|
|
@@ -1203,16 +1206,16 @@ function Switch(props) {
|
|
|
1203
1206
|
_motion,
|
|
1204
1207
|
...rest
|
|
1205
1208
|
} = props;
|
|
1206
|
-
const [x, setX] =
|
|
1207
|
-
const [pressed, setPressed] =
|
|
1208
|
-
const [growThumb, setGrowThumb] =
|
|
1209
|
+
const [x, setX] = React13__default.useState(0);
|
|
1210
|
+
const [pressed, setPressed] = React13__default.useState(false);
|
|
1211
|
+
const [growThumb, setGrowThumb] = React13__default.useState(false);
|
|
1209
1212
|
const borderWidth = 4;
|
|
1210
1213
|
const trackWidth = thumbSize * 1.5;
|
|
1211
1214
|
const borderRadius = thumbSize * 2.5;
|
|
1212
1215
|
const xWhileOn = thumbSize;
|
|
1213
1216
|
const checkedPosition = xWhileOn * 0.5;
|
|
1214
1217
|
const stopwatch = useStopwatch();
|
|
1215
|
-
|
|
1218
|
+
React13__default.useEffect(() => {
|
|
1216
1219
|
if (pressed && !disabled) {
|
|
1217
1220
|
stopwatch.start();
|
|
1218
1221
|
} else {
|
|
@@ -1220,12 +1223,12 @@ function Switch(props) {
|
|
|
1220
1223
|
stopwatch.clear();
|
|
1221
1224
|
}
|
|
1222
1225
|
}, [pressed, disabled]);
|
|
1223
|
-
|
|
1226
|
+
React13__default.useEffect(() => {
|
|
1224
1227
|
if (stopwatch.time > 200) {
|
|
1225
1228
|
setGrowThumb(true);
|
|
1226
1229
|
}
|
|
1227
1230
|
}, [stopwatch.time]);
|
|
1228
|
-
|
|
1231
|
+
React13__default.useEffect(() => {
|
|
1229
1232
|
setX(checked ? checkedPosition : 0);
|
|
1230
1233
|
}, [checked, checkedPosition]);
|
|
1231
1234
|
const toggle = () => {
|
|
@@ -1290,10 +1293,10 @@ function Switch(props) {
|
|
|
1290
1293
|
children,
|
|
1291
1294
|
ThumbNameKey
|
|
1292
1295
|
);
|
|
1293
|
-
const trackElement = track ?
|
|
1296
|
+
const trackElement = track ? React13__default.cloneElement(track, {
|
|
1294
1297
|
_motion,
|
|
1295
|
-
children: thumb ?
|
|
1296
|
-
}) : /* @__PURE__ */ jsx(Track, { _motion, children: thumb ?
|
|
1298
|
+
children: thumb ? React13__default.cloneElement(thumb, { _motion }) : /* @__PURE__ */ jsx(Thumb, { _motion })
|
|
1299
|
+
}) : /* @__PURE__ */ jsx(Track, { _motion, children: thumb ? React13__default.cloneElement(thumb, { _motion }) : /* @__PURE__ */ jsx(Thumb, { _motion }) });
|
|
1297
1300
|
return /* @__PURE__ */ jsx(SwitchContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(MotionConfig, { transition: _motion, children: /* @__PURE__ */ jsx(
|
|
1298
1301
|
Button,
|
|
1299
1302
|
{
|
|
@@ -1418,10 +1421,10 @@ function Thumb(props) {
|
|
|
1418
1421
|
Track.displayName = TrackNameKey;
|
|
1419
1422
|
Thumb.displayName = ThumbNameKey;
|
|
1420
1423
|
function useStopwatch(props = {}) {
|
|
1421
|
-
const [active, setActive] =
|
|
1422
|
-
const [time, setTime] =
|
|
1424
|
+
const [active, setActive] = React13__default.useState(false);
|
|
1425
|
+
const [time, setTime] = React13__default.useState(0);
|
|
1423
1426
|
const timeInterval = props?.interval ?? 10;
|
|
1424
|
-
|
|
1427
|
+
React13__default.useEffect(() => {
|
|
1425
1428
|
let interval = null;
|
|
1426
1429
|
if (active) {
|
|
1427
1430
|
interval = setInterval(() => {
|
|
@@ -1441,7 +1444,7 @@ function useStopwatch(props = {}) {
|
|
|
1441
1444
|
return { time, start, stop, clear };
|
|
1442
1445
|
}
|
|
1443
1446
|
var switch_default = Switch;
|
|
1444
|
-
var RadioContext =
|
|
1447
|
+
var RadioContext = React13__default.createContext(null);
|
|
1445
1448
|
var Base2 = base;
|
|
1446
1449
|
var MotionDiv2 = motionTags.div;
|
|
1447
1450
|
function Radio(props) {
|
|
@@ -1456,14 +1459,14 @@ function Radio(props) {
|
|
|
1456
1459
|
onKeyDown: onKeyDownProp,
|
|
1457
1460
|
...rest
|
|
1458
1461
|
} = props;
|
|
1459
|
-
const groupId =
|
|
1462
|
+
const groupId = React13__default.useId();
|
|
1460
1463
|
const isControlled = controlledValue !== void 0;
|
|
1461
|
-
const [uncontrolled, setUncontrolled] =
|
|
1464
|
+
const [uncontrolled, setUncontrolled] = React13__default.useState(
|
|
1462
1465
|
defaultValue
|
|
1463
1466
|
);
|
|
1464
1467
|
const selectedValue = isControlled ? controlledValue : uncontrolled;
|
|
1465
|
-
const itemsRef =
|
|
1466
|
-
const [activeId, setActiveId] =
|
|
1468
|
+
const itemsRef = React13__default.useRef([]);
|
|
1469
|
+
const [activeId, setActiveId] = React13__default.useState("");
|
|
1467
1470
|
const setSelectedValue = (val) => {
|
|
1468
1471
|
if (!isControlled) setUncontrolled(val);
|
|
1469
1472
|
onChange?.(val);
|
|
@@ -1516,7 +1519,7 @@ function Radio(props) {
|
|
|
1516
1519
|
setActiveId(found.id);
|
|
1517
1520
|
}
|
|
1518
1521
|
};
|
|
1519
|
-
|
|
1522
|
+
React13__default.useEffect(() => {
|
|
1520
1523
|
if (!selectedValue) return;
|
|
1521
1524
|
const selected = itemsRef.current.find((x) => x.value === selectedValue);
|
|
1522
1525
|
if (selected && !selected.disabled) setActiveId(selected.id);
|
|
@@ -1557,7 +1560,7 @@ function Radio(props) {
|
|
|
1557
1560
|
},
|
|
1558
1561
|
children: [
|
|
1559
1562
|
(options ?? []).map(
|
|
1560
|
-
(opt) => renderOption ? /* @__PURE__ */ jsx(
|
|
1563
|
+
(opt) => renderOption ? /* @__PURE__ */ jsx(React13__default.Fragment, { children: renderOption(opt) }, opt.value) : /* @__PURE__ */ jsx(
|
|
1561
1564
|
Item,
|
|
1562
1565
|
{
|
|
1563
1566
|
value: opt.value,
|
|
@@ -1587,7 +1590,7 @@ function Item(props) {
|
|
|
1587
1590
|
onBlur: onBlurProp,
|
|
1588
1591
|
...rest
|
|
1589
1592
|
} = props;
|
|
1590
|
-
const ctx =
|
|
1593
|
+
const ctx = React13__default.useContext(RadioContext);
|
|
1591
1594
|
if (!ctx) {
|
|
1592
1595
|
return /* @__PURE__ */ jsxs(Base2, { flex: true, alignI: true, cursor: "pointer", ...rest, children: [
|
|
1593
1596
|
/* @__PURE__ */ jsx(Base2, { "data-radio-circle": true, w: 24, h: 24, br: 9999, mr: 8 }),
|
|
@@ -1606,22 +1609,22 @@ function Item(props) {
|
|
|
1606
1609
|
} = ctx;
|
|
1607
1610
|
const disabled = !!(groupDisabled || itemDisabled);
|
|
1608
1611
|
const id = `radio-item-${groupId}-${value}`;
|
|
1609
|
-
const ref =
|
|
1610
|
-
|
|
1612
|
+
const ref = React13__default.useRef(null);
|
|
1613
|
+
React13__default.useEffect(() => {
|
|
1611
1614
|
registerItem({ id, value, disabled, ref });
|
|
1612
1615
|
return () => unregisterItem(id);
|
|
1613
1616
|
}, [id, value, disabled]);
|
|
1614
1617
|
const isSelected = selectedValue === value;
|
|
1615
1618
|
const isActive = isActiveId(id);
|
|
1616
|
-
const [isFocused, setIsFocused] =
|
|
1619
|
+
const [isFocused, setIsFocused] = React13__default.useState(false);
|
|
1617
1620
|
const shouldUseGrid = gridProp || !!colsProp;
|
|
1618
1621
|
const renderLabel = () => {
|
|
1619
|
-
const onlyChild =
|
|
1622
|
+
const onlyChild = React13__default.Children.count(children) === 1 ? React13__default.Children.toArray(children)[0] : null;
|
|
1620
1623
|
if (typeof onlyChild === "string") {
|
|
1621
1624
|
return /* @__PURE__ */ jsx(Base2, { "data-radio-label": true, children: onlyChild });
|
|
1622
1625
|
}
|
|
1623
|
-
if (
|
|
1624
|
-
return
|
|
1626
|
+
if (React13__default.isValidElement(onlyChild)) {
|
|
1627
|
+
return React13__default.cloneElement(
|
|
1625
1628
|
onlyChild,
|
|
1626
1629
|
{
|
|
1627
1630
|
...onlyChild.props || {},
|
|
@@ -1741,7 +1744,7 @@ function Item(props) {
|
|
|
1741
1744
|
var LabelNameKey = "Label";
|
|
1742
1745
|
var Base3 = base;
|
|
1743
1746
|
var isBrowser = typeof window !== "undefined";
|
|
1744
|
-
var useIsomorphicLayoutEffect = isBrowser ?
|
|
1747
|
+
var useIsomorphicLayoutEffect = isBrowser ? React13__default.useLayoutEffect : React13__default.useEffect;
|
|
1745
1748
|
function pick(props, obj) {
|
|
1746
1749
|
return props.reduce(
|
|
1747
1750
|
(acc, prop) => {
|
|
@@ -1873,16 +1876,16 @@ function Textarea(props) {
|
|
|
1873
1876
|
...rest
|
|
1874
1877
|
} = props;
|
|
1875
1878
|
const isControlled = rest.value !== void 0;
|
|
1876
|
-
const libRef =
|
|
1879
|
+
const libRef = React13__default.useRef(null);
|
|
1877
1880
|
const ref = assignRefs(libRef, userRef);
|
|
1878
|
-
const heightRef =
|
|
1879
|
-
const [_value, _setValue] =
|
|
1881
|
+
const heightRef = React13__default.useRef(0);
|
|
1882
|
+
const [_value, _setValue] = React13__default.useState("");
|
|
1880
1883
|
const value = props.value ?? _value;
|
|
1881
1884
|
const label = findChildrenByDisplayName(
|
|
1882
1885
|
children,
|
|
1883
1886
|
LabelNameKey
|
|
1884
1887
|
);
|
|
1885
|
-
const labelWithProps = label ?
|
|
1888
|
+
const labelWithProps = label ? React13__default.cloneElement(label, {
|
|
1886
1889
|
required: props.required,
|
|
1887
1890
|
value: props.value,
|
|
1888
1891
|
error
|
|
@@ -1913,20 +1916,20 @@ function Textarea(props) {
|
|
|
1913
1916
|
useIsomorphicLayoutEffect(() => {
|
|
1914
1917
|
resizeTextarea();
|
|
1915
1918
|
}, [rest.value, rest.placeholder, minRows, maxRows]);
|
|
1916
|
-
|
|
1919
|
+
React13__default.useEffect(() => {
|
|
1917
1920
|
if (!isBrowser) return;
|
|
1918
1921
|
const onResize = () => resizeTextarea();
|
|
1919
1922
|
window.addEventListener("resize", onResize);
|
|
1920
1923
|
return () => window.removeEventListener("resize", onResize);
|
|
1921
1924
|
}, [minRows, maxRows, rest.placeholder, rest.value]);
|
|
1922
|
-
|
|
1925
|
+
React13__default.useEffect(() => {
|
|
1923
1926
|
const fonts = isBrowser ? document.fonts : void 0;
|
|
1924
1927
|
if (!fonts || typeof fonts.addEventListener !== "function") return;
|
|
1925
1928
|
const onFontsLoaded = () => resizeTextarea();
|
|
1926
1929
|
fonts.addEventListener("loadingdone", onFontsLoaded);
|
|
1927
1930
|
return () => fonts.removeEventListener("loadingdone", onFontsLoaded);
|
|
1928
1931
|
}, [minRows, maxRows, rest.placeholder, rest.value]);
|
|
1929
|
-
|
|
1932
|
+
React13__default.useEffect(() => {
|
|
1930
1933
|
const node = libRef.current;
|
|
1931
1934
|
const form = node?.form;
|
|
1932
1935
|
if (!node || !form || isControlled) return;
|
|
@@ -2078,13 +2081,13 @@ function Input(props) {
|
|
|
2078
2081
|
children,
|
|
2079
2082
|
RightSideNameKey
|
|
2080
2083
|
);
|
|
2081
|
-
const labelWithProps = label ?
|
|
2084
|
+
const labelWithProps = label ? React13__default.cloneElement(label, {
|
|
2082
2085
|
hasLeftIcon: !!leftIcon,
|
|
2083
2086
|
required: props.required,
|
|
2084
2087
|
value: props.value,
|
|
2085
2088
|
error
|
|
2086
2089
|
}) : null;
|
|
2087
|
-
const rightSideWithProps = rightSide ?
|
|
2090
|
+
const rightSideWithProps = rightSide ? React13__default.cloneElement(rightSide, {
|
|
2088
2091
|
onChange: props.onChange,
|
|
2089
2092
|
value: props.value
|
|
2090
2093
|
}) : null;
|
|
@@ -2209,29 +2212,29 @@ function Label2(props) {
|
|
|
2209
2212
|
Label2.displayName = LabelNameKey2;
|
|
2210
2213
|
function useResizeObserver(opts = {}) {
|
|
2211
2214
|
const onResize = opts.onResize;
|
|
2212
|
-
const onResizeRef =
|
|
2213
|
-
|
|
2215
|
+
const onResizeRef = React13__default.useRef(void 0);
|
|
2216
|
+
React13__default.useLayoutEffect(() => {
|
|
2214
2217
|
onResizeRef.current = onResize;
|
|
2215
2218
|
}, [onResize]);
|
|
2216
2219
|
const round = opts.round || Math.round;
|
|
2217
|
-
const resizeObserverRef =
|
|
2218
|
-
const [size, setSize] =
|
|
2220
|
+
const resizeObserverRef = React13__default.useRef(null);
|
|
2221
|
+
const [size, setSize] = React13__default.useState({
|
|
2219
2222
|
width: void 0,
|
|
2220
2223
|
height: void 0
|
|
2221
2224
|
});
|
|
2222
|
-
const didUnmount =
|
|
2223
|
-
|
|
2225
|
+
const didUnmount = React13__default.useRef(false);
|
|
2226
|
+
React13__default.useEffect(() => {
|
|
2224
2227
|
didUnmount.current = false;
|
|
2225
2228
|
return () => {
|
|
2226
2229
|
didUnmount.current = true;
|
|
2227
2230
|
};
|
|
2228
2231
|
}, []);
|
|
2229
|
-
const previous =
|
|
2232
|
+
const previous = React13__default.useRef({
|
|
2230
2233
|
width: void 0,
|
|
2231
2234
|
height: void 0
|
|
2232
2235
|
});
|
|
2233
2236
|
const refCallback = useResolvedElement(
|
|
2234
|
-
|
|
2237
|
+
React13__default.useCallback(
|
|
2235
2238
|
(element) => {
|
|
2236
2239
|
if (!resizeObserverRef.current || resizeObserverRef.current.box !== opts.box || resizeObserverRef.current.round !== round) {
|
|
2237
2240
|
resizeObserverRef.current = {
|
|
@@ -2271,7 +2274,7 @@ function useResizeObserver(opts = {}) {
|
|
|
2271
2274
|
),
|
|
2272
2275
|
opts.ref
|
|
2273
2276
|
);
|
|
2274
|
-
return
|
|
2277
|
+
return React13__default.useMemo(
|
|
2275
2278
|
() => ({
|
|
2276
2279
|
ref: refCallback,
|
|
2277
2280
|
width: size.width,
|
|
@@ -2283,12 +2286,12 @@ function useResizeObserver(opts = {}) {
|
|
|
2283
2286
|
);
|
|
2284
2287
|
}
|
|
2285
2288
|
function useResolvedElement(subscriber, refOrElement) {
|
|
2286
|
-
const lastReportRef =
|
|
2287
|
-
const refOrElementRef =
|
|
2288
|
-
|
|
2289
|
+
const lastReportRef = React13__default.useRef(null);
|
|
2290
|
+
const refOrElementRef = React13__default.useRef(null);
|
|
2291
|
+
React13__default.useLayoutEffect(() => {
|
|
2289
2292
|
refOrElementRef.current = refOrElement;
|
|
2290
2293
|
}, [refOrElement]);
|
|
2291
|
-
const cbElementRef =
|
|
2294
|
+
const cbElementRef = React13__default.useRef(null);
|
|
2292
2295
|
const evaluateSubscription = () => {
|
|
2293
2296
|
const cbElement = cbElementRef.current;
|
|
2294
2297
|
const refOrElement2 = refOrElementRef.current;
|
|
@@ -2307,10 +2310,10 @@ function useResolvedElement(subscriber, refOrElement) {
|
|
|
2307
2310
|
cleanup: element ? subscriber(element) : void 0
|
|
2308
2311
|
};
|
|
2309
2312
|
};
|
|
2310
|
-
|
|
2313
|
+
React13__default.useEffect(() => {
|
|
2311
2314
|
evaluateSubscription();
|
|
2312
2315
|
});
|
|
2313
|
-
|
|
2316
|
+
React13__default.useEffect(() => {
|
|
2314
2317
|
return () => {
|
|
2315
2318
|
if (lastReportRef.current && lastReportRef.current.cleanup) {
|
|
2316
2319
|
lastReportRef.current.cleanup();
|
|
@@ -2336,7 +2339,7 @@ var use_resize_observer_default = useResizeObserver;
|
|
|
2336
2339
|
var MotionDiv3 = motionTags.div;
|
|
2337
2340
|
var MotionBtn = motionTags.button;
|
|
2338
2341
|
var displayName = "AccordionItem";
|
|
2339
|
-
var AccordionContext =
|
|
2342
|
+
var AccordionContext = React13__default.createContext({});
|
|
2340
2343
|
function AccordionProvider(props) {
|
|
2341
2344
|
const [state, setState] = useImmer({
|
|
2342
2345
|
allowMultiple: false,
|
|
@@ -2346,7 +2349,7 @@ function AccordionProvider(props) {
|
|
|
2346
2349
|
return /* @__PURE__ */ jsx(AccordionContext.Provider, { value: { setState, state }, children: props.children });
|
|
2347
2350
|
}
|
|
2348
2351
|
function useAccordion() {
|
|
2349
|
-
const context2 =
|
|
2352
|
+
const context2 = React13__default.useContext(AccordionContext);
|
|
2350
2353
|
if (context2 === void 0) {
|
|
2351
2354
|
throw new Error("useAccordion must be used within a AccordionProvider");
|
|
2352
2355
|
}
|
|
@@ -2355,23 +2358,23 @@ function useAccordion() {
|
|
|
2355
2358
|
function AccordionComponent(props) {
|
|
2356
2359
|
const accordion = useAccordion();
|
|
2357
2360
|
const accordionState = accordion.state;
|
|
2358
|
-
|
|
2361
|
+
React13__default.useEffect(() => {
|
|
2359
2362
|
accordion.setState((draft) => {
|
|
2360
2363
|
draft.allowMultiple = !!props.allowMultiple;
|
|
2361
2364
|
draft.allowToggle = !!props.allowToggle;
|
|
2362
2365
|
});
|
|
2363
2366
|
}, [props.allowMultiple, props.allowToggle]);
|
|
2364
|
-
|
|
2367
|
+
React13__default.Children.forEach(props.children, (x) => {
|
|
2365
2368
|
if (typeof x.type === "function" && "displayName" in x.type && x.type.displayName !== displayName) {
|
|
2366
2369
|
throw new Error("Accordion can only have AccordionItems as children");
|
|
2367
2370
|
}
|
|
2368
2371
|
});
|
|
2369
|
-
const children =
|
|
2370
|
-
if (!
|
|
2371
|
-
return
|
|
2372
|
+
const children = React13__default.Children.map(props.children, (child, i) => {
|
|
2373
|
+
if (!React13__default.isValidElement(child)) return child;
|
|
2374
|
+
return React13__default.cloneElement(child, { idx: i });
|
|
2372
2375
|
});
|
|
2373
2376
|
const defaultOpenIdxList = JSON.stringify(props.defaultOpenIdx ?? []);
|
|
2374
|
-
|
|
2377
|
+
React13__default.useEffect(
|
|
2375
2378
|
() => {
|
|
2376
2379
|
if (accordionState.open.length === children.length) return;
|
|
2377
2380
|
const defaultOpenIdx = props.defaultOpenIdx;
|
|
@@ -2478,11 +2481,11 @@ var MotionDiv4 = motionTags.div;
|
|
|
2478
2481
|
var MotionBtn2 = motionTags.button;
|
|
2479
2482
|
var breakpoint = ["(min-width: 600px)"];
|
|
2480
2483
|
function DrawerComponent(props) {
|
|
2481
|
-
const ref =
|
|
2482
|
-
const dragHandleRef =
|
|
2484
|
+
const ref = React13__default.useRef(null);
|
|
2485
|
+
const dragHandleRef = React13__default.useRef(null);
|
|
2483
2486
|
const [isDesktop] = useMatchMedia(breakpoint);
|
|
2484
|
-
const closeFnRef =
|
|
2485
|
-
const prevOpenRef =
|
|
2487
|
+
const closeFnRef = React13__default.useRef(null);
|
|
2488
|
+
const prevOpenRef = React13__default.useRef(null);
|
|
2486
2489
|
const dragControls = useDragControls();
|
|
2487
2490
|
const { open, setOpen } = useDrawer();
|
|
2488
2491
|
const { onClose, onExitComplete, ...rest } = props;
|
|
@@ -2496,7 +2499,7 @@ function DrawerComponent(props) {
|
|
|
2496
2499
|
y.stop();
|
|
2497
2500
|
setOpen(false);
|
|
2498
2501
|
};
|
|
2499
|
-
|
|
2502
|
+
React13__default.useEffect(() => {
|
|
2500
2503
|
closeFnRef.current = () => {
|
|
2501
2504
|
closeDrawer();
|
|
2502
2505
|
onClose?.();
|
|
@@ -2516,7 +2519,7 @@ function DrawerComponent(props) {
|
|
|
2516
2519
|
);
|
|
2517
2520
|
}
|
|
2518
2521
|
};
|
|
2519
|
-
|
|
2522
|
+
React13__default.useLayoutEffect(() => {
|
|
2520
2523
|
const wasOpen = prevOpenRef.current;
|
|
2521
2524
|
const isOpen = props.open;
|
|
2522
2525
|
if (isOpen) {
|
|
@@ -2526,7 +2529,7 @@ function DrawerComponent(props) {
|
|
|
2526
2529
|
}
|
|
2527
2530
|
prevOpenRef.current = isOpen;
|
|
2528
2531
|
}, [props.open]);
|
|
2529
|
-
|
|
2532
|
+
React13__default.useEffect(() => {
|
|
2530
2533
|
const container = ref.current;
|
|
2531
2534
|
if (!open || !container) return;
|
|
2532
2535
|
container.setAttribute("tabindex", "0");
|
|
@@ -2548,7 +2551,7 @@ function DrawerComponent(props) {
|
|
|
2548
2551
|
document.body.style.overflow = "auto";
|
|
2549
2552
|
};
|
|
2550
2553
|
}, [open, props.closeOnEsc]);
|
|
2551
|
-
|
|
2554
|
+
React13__default.useEffect(() => {
|
|
2552
2555
|
if (!props.open) return;
|
|
2553
2556
|
const unsubscribeY = y.on("change", (latestY) => {
|
|
2554
2557
|
if (latestY > 150) {
|
|
@@ -2708,19 +2711,19 @@ function DrawerComponent(props) {
|
|
|
2708
2711
|
document.getElementById("portal")
|
|
2709
2712
|
);
|
|
2710
2713
|
}
|
|
2711
|
-
var DrawerContext =
|
|
2714
|
+
var DrawerContext = React13__default.createContext({
|
|
2712
2715
|
open: false,
|
|
2713
2716
|
setOpen: () => {
|
|
2714
2717
|
return;
|
|
2715
2718
|
}
|
|
2716
2719
|
});
|
|
2717
2720
|
function DrawerProvider(props) {
|
|
2718
|
-
const [open, setOpen] =
|
|
2721
|
+
const [open, setOpen] = React13__default.useState(false);
|
|
2719
2722
|
const value = { open, setOpen };
|
|
2720
2723
|
return /* @__PURE__ */ jsx(DrawerContext.Provider, { value, children: props.children });
|
|
2721
2724
|
}
|
|
2722
2725
|
function useDrawer() {
|
|
2723
|
-
const context2 =
|
|
2726
|
+
const context2 = React13__default.useContext(DrawerContext);
|
|
2724
2727
|
if (context2 === void 0) {
|
|
2725
2728
|
throw new Error("useDrawer must be used within a DrawerProvider");
|
|
2726
2729
|
}
|
|
@@ -2733,7 +2736,7 @@ function BtnGroup(props) {
|
|
|
2733
2736
|
const [isDesktop] = useMatchMedia(breakpoint);
|
|
2734
2737
|
const { children, ...rest } = props;
|
|
2735
2738
|
if (isDesktop) {
|
|
2736
|
-
return /* @__PURE__ */ jsx(MotionDiv4, { flex: true, alignI: true, gap: 4, ...rest, children:
|
|
2739
|
+
return /* @__PURE__ */ jsx(MotionDiv4, { flex: true, alignI: true, gap: 4, ...rest, children: React13__default.Children.toArray(children).toReversed() });
|
|
2737
2740
|
} else {
|
|
2738
2741
|
return /* @__PURE__ */ jsx(MotionDiv4, { grid: true, rowG: 14, ...props });
|
|
2739
2742
|
}
|
|
@@ -2786,7 +2789,7 @@ function CloseBtn(props) {
|
|
|
2786
2789
|
}
|
|
2787
2790
|
}
|
|
2788
2791
|
function Backdrop(props) {
|
|
2789
|
-
const allowOutsideClickRef =
|
|
2792
|
+
const allowOutsideClickRef = React13__default.useRef(true);
|
|
2790
2793
|
const [isDesktop] = useMatchMedia(breakpoint);
|
|
2791
2794
|
return /* @__PURE__ */ jsx(
|
|
2792
2795
|
MotionDiv4,
|
|
@@ -2816,10 +2819,10 @@ function Backdrop(props) {
|
|
|
2816
2819
|
);
|
|
2817
2820
|
}
|
|
2818
2821
|
function useMatchMedia(queries) {
|
|
2819
|
-
const [value, setValue] =
|
|
2822
|
+
const [value, setValue] = React13__default.useState(() => {
|
|
2820
2823
|
return queries.map((q) => window.matchMedia(q).matches);
|
|
2821
2824
|
});
|
|
2822
|
-
|
|
2825
|
+
React13__default.useLayoutEffect(() => {
|
|
2823
2826
|
const mediaQueryLists = queries.map((q) => window.matchMedia(q));
|
|
2824
2827
|
const handler = () => {
|
|
2825
2828
|
setValue(mediaQueryLists.map((mql) => mql.matches));
|
|
@@ -2837,9 +2840,9 @@ var TrackBgNameKey = "TrackBg";
|
|
|
2837
2840
|
var TrackFillNameKey = "TrackFill";
|
|
2838
2841
|
function Progress(props) {
|
|
2839
2842
|
const { children, steps, value, max: maxProp, ...rest } = props;
|
|
2840
|
-
const [progress, setProgress] =
|
|
2843
|
+
const [progress, setProgress] = React13__default.useState(0);
|
|
2841
2844
|
const max = maxProp ?? 100;
|
|
2842
|
-
|
|
2845
|
+
React13__default.useEffect(() => {
|
|
2843
2846
|
setProgress(Math.min((value ?? 0) / max, 1) * 100);
|
|
2844
2847
|
}, [value, max]);
|
|
2845
2848
|
const width = `${progress}%`;
|
|
@@ -2879,7 +2882,7 @@ function Progress(props) {
|
|
|
2879
2882
|
TrackFillNameKey
|
|
2880
2883
|
);
|
|
2881
2884
|
const barHeight = rest.h ?? 8;
|
|
2882
|
-
const bgEl = trackBgChild ?
|
|
2885
|
+
const bgEl = trackBgChild ? React13__default.cloneElement(trackBgChild, {
|
|
2883
2886
|
gridArea: "1 / 1",
|
|
2884
2887
|
h: barHeight,
|
|
2885
2888
|
w: trackBgChild.props.w ?? true
|
|
@@ -2894,7 +2897,7 @@ function Progress(props) {
|
|
|
2894
2897
|
bg: { base: "neutral.200", _dark: "neutral.700" }
|
|
2895
2898
|
}
|
|
2896
2899
|
);
|
|
2897
|
-
const fillEl = trackFillChild ?
|
|
2900
|
+
const fillEl = trackFillChild ? React13__default.cloneElement(trackFillChild, {
|
|
2898
2901
|
gridArea: "1 / 1",
|
|
2899
2902
|
h: barHeight,
|
|
2900
2903
|
roundedLeft: 9999,
|
|
@@ -2964,8 +2967,288 @@ function TrackFill(props) {
|
|
|
2964
2967
|
);
|
|
2965
2968
|
}
|
|
2966
2969
|
TrackFill.displayName = TrackFillNameKey;
|
|
2970
|
+
var MotionDiv6 = motionTags.div;
|
|
2971
|
+
var TrackNameKey2 = "SliderTrack";
|
|
2972
|
+
var FillNameKey = "SliderFill";
|
|
2973
|
+
var ThumbNameKey2 = "SliderThumb";
|
|
2974
|
+
var SliderContext = React13__default.createContext(null);
|
|
2975
|
+
var useSliderContext = () => {
|
|
2976
|
+
const context2 = React13__default.useContext(SliderContext);
|
|
2977
|
+
if (!context2) {
|
|
2978
|
+
throw new Error("Slider compound components must be used within Slider");
|
|
2979
|
+
}
|
|
2980
|
+
return context2;
|
|
2981
|
+
};
|
|
2982
|
+
function Slider(props) {
|
|
2983
|
+
const {
|
|
2984
|
+
value: controlledValue,
|
|
2985
|
+
defaultValue = 0,
|
|
2986
|
+
min = 0,
|
|
2987
|
+
max = 100,
|
|
2988
|
+
step,
|
|
2989
|
+
disabled = false,
|
|
2990
|
+
onChange,
|
|
2991
|
+
children,
|
|
2992
|
+
_motion,
|
|
2993
|
+
...rest
|
|
2994
|
+
} = props;
|
|
2995
|
+
const isControlled = controlledValue !== void 0;
|
|
2996
|
+
const [internalValue, setInternalValue] = React13__default.useState(defaultValue);
|
|
2997
|
+
const value = isControlled ? controlledValue : internalValue;
|
|
2998
|
+
const [isDragging, setIsDragging] = React13__default.useState(false);
|
|
2999
|
+
const trackRef = React13__default.useRef(null);
|
|
3000
|
+
const percent = Math.min(
|
|
3001
|
+
100,
|
|
3002
|
+
Math.max(0, (value - min) / (max - min) * 100)
|
|
3003
|
+
);
|
|
3004
|
+
const clampValue = React13__default.useCallback(
|
|
3005
|
+
(rawValue) => {
|
|
3006
|
+
let clamped = Math.max(min, Math.min(max, rawValue));
|
|
3007
|
+
if (step !== void 0 && step > 0) {
|
|
3008
|
+
clamped = Math.round((clamped - min) / step) * step + min;
|
|
3009
|
+
clamped = Math.max(min, Math.min(max, clamped));
|
|
3010
|
+
}
|
|
3011
|
+
return clamped;
|
|
3012
|
+
},
|
|
3013
|
+
[min, max, step]
|
|
3014
|
+
);
|
|
3015
|
+
const getValueFromClientX = React13__default.useCallback(
|
|
3016
|
+
(clientX) => {
|
|
3017
|
+
const track = trackRef.current;
|
|
3018
|
+
if (!track) return value;
|
|
3019
|
+
const rect = track.getBoundingClientRect();
|
|
3020
|
+
const x = clientX - rect.left;
|
|
3021
|
+
const rawPercent = Math.max(0, Math.min(1, x / rect.width));
|
|
3022
|
+
const rawValue = min + rawPercent * (max - min);
|
|
3023
|
+
return clampValue(rawValue);
|
|
3024
|
+
},
|
|
3025
|
+
[min, max, value, clampValue]
|
|
3026
|
+
);
|
|
3027
|
+
const updateValue = React13__default.useCallback(
|
|
3028
|
+
(newValue) => {
|
|
3029
|
+
if (disabled) return;
|
|
3030
|
+
if (!isControlled) {
|
|
3031
|
+
setInternalValue(newValue);
|
|
3032
|
+
}
|
|
3033
|
+
onChange?.(newValue);
|
|
3034
|
+
},
|
|
3035
|
+
[disabled, isControlled, onChange]
|
|
3036
|
+
);
|
|
3037
|
+
const handleTrackPointerDown = (e) => {
|
|
3038
|
+
if (disabled) return;
|
|
3039
|
+
e.preventDefault();
|
|
3040
|
+
setIsDragging(true);
|
|
3041
|
+
const newValue = getValueFromClientX(e.clientX);
|
|
3042
|
+
updateValue(newValue);
|
|
3043
|
+
};
|
|
3044
|
+
React13__default.useEffect(() => {
|
|
3045
|
+
if (!isDragging) return;
|
|
3046
|
+
const controller = new AbortController();
|
|
3047
|
+
const handleMove = (e) => {
|
|
3048
|
+
const newValue = getValueFromClientX(e.clientX);
|
|
3049
|
+
updateValue(newValue);
|
|
3050
|
+
};
|
|
3051
|
+
const handleUp = () => {
|
|
3052
|
+
setIsDragging(false);
|
|
3053
|
+
};
|
|
3054
|
+
const signal = controller.signal;
|
|
3055
|
+
window.addEventListener("pointermove", handleMove, { signal });
|
|
3056
|
+
window.addEventListener("pointerup", handleUp, { signal });
|
|
3057
|
+
window.addEventListener("pointercancel", handleUp, { signal });
|
|
3058
|
+
return () => controller.abort();
|
|
3059
|
+
}, [isDragging, getValueFromClientX, updateValue]);
|
|
3060
|
+
const handleKeyDown = (e) => {
|
|
3061
|
+
if (disabled) return;
|
|
3062
|
+
const stepAmount = step ?? (max - min) / 100;
|
|
3063
|
+
const largeStep = (max - min) / 10;
|
|
3064
|
+
let newValue = value;
|
|
3065
|
+
switch (e.key) {
|
|
3066
|
+
case "ArrowRight":
|
|
3067
|
+
case "ArrowUp":
|
|
3068
|
+
newValue = clampValue(value + stepAmount);
|
|
3069
|
+
break;
|
|
3070
|
+
case "ArrowLeft":
|
|
3071
|
+
case "ArrowDown":
|
|
3072
|
+
newValue = clampValue(value - stepAmount);
|
|
3073
|
+
break;
|
|
3074
|
+
case "PageUp":
|
|
3075
|
+
newValue = clampValue(value + largeStep);
|
|
3076
|
+
break;
|
|
3077
|
+
case "PageDown":
|
|
3078
|
+
newValue = clampValue(value - largeStep);
|
|
3079
|
+
break;
|
|
3080
|
+
case "Home":
|
|
3081
|
+
newValue = min;
|
|
3082
|
+
break;
|
|
3083
|
+
case "End":
|
|
3084
|
+
newValue = max;
|
|
3085
|
+
break;
|
|
3086
|
+
default:
|
|
3087
|
+
return;
|
|
3088
|
+
}
|
|
3089
|
+
e.preventDefault();
|
|
3090
|
+
updateValue(newValue);
|
|
3091
|
+
};
|
|
3092
|
+
const trackChild = findChildrenByDisplayName(
|
|
3093
|
+
children,
|
|
3094
|
+
TrackNameKey2
|
|
3095
|
+
);
|
|
3096
|
+
const fillChild = findChildrenByDisplayName(
|
|
3097
|
+
children,
|
|
3098
|
+
FillNameKey
|
|
3099
|
+
);
|
|
3100
|
+
const thumbChild = findChildrenByDisplayName(
|
|
3101
|
+
children,
|
|
3102
|
+
ThumbNameKey2
|
|
3103
|
+
);
|
|
3104
|
+
const contextValue = {
|
|
3105
|
+
value,
|
|
3106
|
+
min,
|
|
3107
|
+
max,
|
|
3108
|
+
percent,
|
|
3109
|
+
disabled,
|
|
3110
|
+
isDragging,
|
|
3111
|
+
trackRef
|
|
3112
|
+
};
|
|
3113
|
+
const height = rest.h ?? 8;
|
|
3114
|
+
const trackEl = trackChild ? React13__default.cloneElement(trackChild, {
|
|
3115
|
+
sliderPercent: percent,
|
|
3116
|
+
sliderValue: value,
|
|
3117
|
+
sliderMin: min,
|
|
3118
|
+
sliderMax: max
|
|
3119
|
+
}) : /* @__PURE__ */ jsx(SliderTrack, {});
|
|
3120
|
+
const fillEl = fillChild ? React13__default.cloneElement(fillChild, {
|
|
3121
|
+
sliderPercent: percent,
|
|
3122
|
+
sliderValue: value,
|
|
3123
|
+
sliderMin: min,
|
|
3124
|
+
sliderMax: max
|
|
3125
|
+
}) : /* @__PURE__ */ jsx(SliderFill, {});
|
|
3126
|
+
const thumbEl = thumbChild ? React13__default.cloneElement(thumbChild, {
|
|
3127
|
+
sliderPercent: percent,
|
|
3128
|
+
sliderValue: value,
|
|
3129
|
+
sliderMin: min,
|
|
3130
|
+
sliderMax: max
|
|
3131
|
+
}) : /* @__PURE__ */ jsx(SliderThumb, {});
|
|
3132
|
+
return /* @__PURE__ */ jsx(SliderContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx(MotionConfig, { transition: _motion, children: /* @__PURE__ */ jsxs(
|
|
3133
|
+
MotionDiv6,
|
|
3134
|
+
{
|
|
3135
|
+
ref: trackRef,
|
|
3136
|
+
role: "slider",
|
|
3137
|
+
"aria-valuemin": min,
|
|
3138
|
+
"aria-valuemax": max,
|
|
3139
|
+
"aria-valuenow": value,
|
|
3140
|
+
"aria-disabled": disabled,
|
|
3141
|
+
tabIndex: disabled ? -1 : 0,
|
|
3142
|
+
grid: true,
|
|
3143
|
+
cols: "1",
|
|
3144
|
+
rows: "1",
|
|
3145
|
+
alignItems: "center",
|
|
3146
|
+
position: "relative",
|
|
3147
|
+
w: true,
|
|
3148
|
+
h: height,
|
|
3149
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
3150
|
+
opacity: disabled ? 0.5 : 1,
|
|
3151
|
+
onPointerDown: handleTrackPointerDown,
|
|
3152
|
+
onKeyDown: handleKeyDown,
|
|
3153
|
+
userSelect: "none",
|
|
3154
|
+
touchAction: "none",
|
|
3155
|
+
...rest,
|
|
3156
|
+
children: [
|
|
3157
|
+
trackEl,
|
|
3158
|
+
fillEl,
|
|
3159
|
+
thumbEl
|
|
3160
|
+
]
|
|
3161
|
+
}
|
|
3162
|
+
) }) });
|
|
3163
|
+
}
|
|
3164
|
+
function SliderTrack(props) {
|
|
3165
|
+
const {
|
|
3166
|
+
sliderPercent: _,
|
|
3167
|
+
sliderValue: _v,
|
|
3168
|
+
sliderMin: _min,
|
|
3169
|
+
sliderMax: _max,
|
|
3170
|
+
...rest
|
|
3171
|
+
} = props;
|
|
3172
|
+
return /* @__PURE__ */ jsx(
|
|
3173
|
+
MotionDiv6,
|
|
3174
|
+
{
|
|
3175
|
+
"data-slider-track": true,
|
|
3176
|
+
gridArea: "1 / 1",
|
|
3177
|
+
w: true,
|
|
3178
|
+
h: "100%",
|
|
3179
|
+
br: 9999,
|
|
3180
|
+
bg: { base: "neutral.200", _dark: "neutral.700" },
|
|
3181
|
+
...rest
|
|
3182
|
+
}
|
|
3183
|
+
);
|
|
3184
|
+
}
|
|
3185
|
+
SliderTrack.displayName = TrackNameKey2;
|
|
3186
|
+
function SliderFill(props) {
|
|
3187
|
+
const {
|
|
3188
|
+
sliderPercent,
|
|
3189
|
+
sliderValue: _v,
|
|
3190
|
+
sliderMin: _min,
|
|
3191
|
+
sliderMax: _max,
|
|
3192
|
+
style,
|
|
3193
|
+
...rest
|
|
3194
|
+
} = props;
|
|
3195
|
+
const { percent } = useSliderContext();
|
|
3196
|
+
const width = `${sliderPercent ?? percent}%`;
|
|
3197
|
+
return /* @__PURE__ */ jsx(
|
|
3198
|
+
MotionDiv6,
|
|
3199
|
+
{
|
|
3200
|
+
"data-slider-fill": true,
|
|
3201
|
+
gridArea: "1 / 1",
|
|
3202
|
+
h: "100%",
|
|
3203
|
+
br: 9999,
|
|
3204
|
+
bg: { base: "blue.500", _dark: "blue.400" },
|
|
3205
|
+
style: { ...style, width },
|
|
3206
|
+
pointerEvents: "none",
|
|
3207
|
+
...rest
|
|
3208
|
+
}
|
|
3209
|
+
);
|
|
3210
|
+
}
|
|
3211
|
+
SliderFill.displayName = FillNameKey;
|
|
3212
|
+
function SliderThumb(props) {
|
|
3213
|
+
const {
|
|
3214
|
+
sliderPercent,
|
|
3215
|
+
sliderValue: _v,
|
|
3216
|
+
sliderMin: _min,
|
|
3217
|
+
sliderMax: _max,
|
|
3218
|
+
style,
|
|
3219
|
+
...rest
|
|
3220
|
+
} = props;
|
|
3221
|
+
const { percent, isDragging, disabled } = useSliderContext();
|
|
3222
|
+
const left = `${sliderPercent ?? percent}%`;
|
|
3223
|
+
return /* @__PURE__ */ jsx(
|
|
3224
|
+
MotionDiv6,
|
|
3225
|
+
{
|
|
3226
|
+
"data-slider-thumb": true,
|
|
3227
|
+
gridArea: "1 / 1",
|
|
3228
|
+
position: "absolute",
|
|
3229
|
+
top: "50%",
|
|
3230
|
+
size: 24,
|
|
3231
|
+
rounded: true,
|
|
3232
|
+
bg: "white",
|
|
3233
|
+
boxShadow: "0 2px 8px rgba(0,0,0,0.25)",
|
|
3234
|
+
cursor: disabled ? "not-allowed" : "grab",
|
|
3235
|
+
pointerEvents: "none",
|
|
3236
|
+
style: {
|
|
3237
|
+
...style,
|
|
3238
|
+
left,
|
|
3239
|
+
transform: "translate(-50%, -50%)"
|
|
3240
|
+
},
|
|
3241
|
+
initial: false,
|
|
3242
|
+
animate: {
|
|
3243
|
+
scale: isDragging ? 1.1 : 1
|
|
3244
|
+
},
|
|
3245
|
+
...rest
|
|
3246
|
+
}
|
|
3247
|
+
);
|
|
3248
|
+
}
|
|
3249
|
+
SliderThumb.displayName = ThumbNameKey2;
|
|
2967
3250
|
var Base5 = base;
|
|
2968
|
-
var TooltipContainer =
|
|
3251
|
+
var TooltipContainer = React13__default.forwardRef(function TooltipContainer2(props, ref) {
|
|
2969
3252
|
const { children, className, style, ...rest } = props;
|
|
2970
3253
|
return /* @__PURE__ */ jsx(
|
|
2971
3254
|
Base5,
|
|
@@ -2992,9 +3275,9 @@ function Tooltip(props) {
|
|
|
2992
3275
|
delay = 80,
|
|
2993
3276
|
className
|
|
2994
3277
|
} = props;
|
|
2995
|
-
const referenceRef =
|
|
2996
|
-
const arrowRef =
|
|
2997
|
-
const [open, setOpen] =
|
|
3278
|
+
const referenceRef = React13__default.useRef(null);
|
|
3279
|
+
const arrowRef = React13__default.useRef(null);
|
|
3280
|
+
const [open, setOpen] = React13__default.useState(false);
|
|
2998
3281
|
const { x, y, refs, strategy, middlewareData, context: context2 } = useFloating({
|
|
2999
3282
|
open,
|
|
3000
3283
|
onOpenChange: setOpen,
|
|
@@ -3023,7 +3306,7 @@ function Tooltip(props) {
|
|
|
3023
3306
|
role
|
|
3024
3307
|
]);
|
|
3025
3308
|
const referenceProps = getReferenceProps({});
|
|
3026
|
-
|
|
3309
|
+
React13__default.useEffect(() => {
|
|
3027
3310
|
if (!follow || !referenceRef.current) return;
|
|
3028
3311
|
const el = referenceRef.current;
|
|
3029
3312
|
const onMove = (e) => {
|
|
@@ -3046,14 +3329,14 @@ function Tooltip(props) {
|
|
|
3046
3329
|
const arrowAnchorStyle = side.startsWith("top") ? { bottom: -anchorOffset } : side.startsWith("bottom") ? { top: -anchorOffset } : side.startsWith("left") ? { right: -anchorOffset } : { left: -anchorOffset };
|
|
3047
3330
|
const arrowStyle = side.startsWith("top") || side.startsWith("bottom") ? { left: arrowX || void 0, ...arrowAnchorStyle } : { top: arrowY || void 0, ...arrowAnchorStyle };
|
|
3048
3331
|
const transformOrigin = side.startsWith("top") ? "center bottom" : side.startsWith("bottom") ? "center top" : side.startsWith("left") ? "right center" : side.startsWith("right") ? "left center" : "center";
|
|
3049
|
-
const childrenArray =
|
|
3332
|
+
const childrenArray = React13__default.Children.toArray(children);
|
|
3050
3333
|
const hasMultipleChildren = childrenArray.length > 1;
|
|
3051
3334
|
let child;
|
|
3052
3335
|
if (hasMultipleChildren) {
|
|
3053
3336
|
child = /* @__PURE__ */ jsx("div", { style: { display: "inline-block" }, children });
|
|
3054
3337
|
} else {
|
|
3055
|
-
const only =
|
|
3056
|
-
const isDomElement =
|
|
3338
|
+
const only = React13__default.Children.only(children);
|
|
3339
|
+
const isDomElement = React13__default.isValidElement(only) && typeof only.type === "string";
|
|
3057
3340
|
child = isDomElement ? only : (
|
|
3058
3341
|
// Ensure the wrapper reliably captures mouseenter/pointerenter and can contain block elements
|
|
3059
3342
|
/* @__PURE__ */ jsx("div", { style: { display: "inline-block" }, children: only })
|
|
@@ -3071,7 +3354,7 @@ function Tooltip(props) {
|
|
|
3071
3354
|
originalRef.current = node;
|
|
3072
3355
|
};
|
|
3073
3356
|
const refAttrs = referenceProps;
|
|
3074
|
-
const cloned =
|
|
3357
|
+
const cloned = React13__default.cloneElement(
|
|
3075
3358
|
child,
|
|
3076
3359
|
{
|
|
3077
3360
|
...refAttrs,
|
|
@@ -3080,11 +3363,11 @@ function Tooltip(props) {
|
|
|
3080
3363
|
}
|
|
3081
3364
|
);
|
|
3082
3365
|
if (disabled) return /* @__PURE__ */ jsx(Fragment, { children: cloned });
|
|
3083
|
-
const [isMounted, setIsMounted] =
|
|
3084
|
-
const closeTimerRef =
|
|
3366
|
+
const [isMounted, setIsMounted] = React13__default.useState(false);
|
|
3367
|
+
const closeTimerRef = React13__default.useRef(
|
|
3085
3368
|
null
|
|
3086
3369
|
);
|
|
3087
|
-
|
|
3370
|
+
React13__default.useEffect(() => {
|
|
3088
3371
|
if (closeTimerRef.current) {
|
|
3089
3372
|
clearTimeout(closeTimerRef.current);
|
|
3090
3373
|
closeTimerRef.current = null;
|
|
@@ -3107,24 +3390,24 @@ function Tooltip(props) {
|
|
|
3107
3390
|
let arrowEl = null;
|
|
3108
3391
|
let floatingNode = null;
|
|
3109
3392
|
const findRoleTooltipElement = (node) => {
|
|
3110
|
-
if (!
|
|
3393
|
+
if (!React13__default.isValidElement(node)) return null;
|
|
3111
3394
|
const el = node;
|
|
3112
3395
|
if (el.props?.role === "tooltip") return el;
|
|
3113
3396
|
const kids = el.props?.children;
|
|
3114
3397
|
if (!kids) return null;
|
|
3115
|
-
const arr =
|
|
3398
|
+
const arr = React13__default.Children.toArray(kids);
|
|
3116
3399
|
for (const c of arr) {
|
|
3117
|
-
if (
|
|
3400
|
+
if (React13__default.isValidElement(c) && c.props?.role === "tooltip") {
|
|
3118
3401
|
return c;
|
|
3119
3402
|
}
|
|
3120
3403
|
}
|
|
3121
3404
|
return null;
|
|
3122
3405
|
};
|
|
3123
|
-
const isCustomTooltip =
|
|
3406
|
+
const isCustomTooltip = React13__default.isValidElement(content) && !!(content.type && content.type.isBlockTooltipContainer);
|
|
3124
3407
|
const customEl = isCustomTooltip ? content : findRoleTooltipElement(content);
|
|
3125
|
-
const containerRef =
|
|
3126
|
-
const [containerBg, setContainerBg] =
|
|
3127
|
-
|
|
3408
|
+
const containerRef = React13__default.useRef(null);
|
|
3409
|
+
const [containerBg, setContainerBg] = React13__default.useState();
|
|
3410
|
+
React13__default.useEffect(() => {
|
|
3128
3411
|
if (!(open || isMounted)) return;
|
|
3129
3412
|
const el = containerRef.current;
|
|
3130
3413
|
if (!el) return;
|
|
@@ -3232,7 +3515,7 @@ function Tooltip(props) {
|
|
|
3232
3515
|
else if (originalChildRef && typeof originalChildRef === "object")
|
|
3233
3516
|
originalChildRef.current = node;
|
|
3234
3517
|
};
|
|
3235
|
-
return
|
|
3518
|
+
return React13__default.cloneElement(
|
|
3236
3519
|
el,
|
|
3237
3520
|
{
|
|
3238
3521
|
// Spread childProps first
|
|
@@ -3329,12 +3612,12 @@ var Svg = motionTags.svg;
|
|
|
3329
3612
|
var CheckboxBtn = motionTags.button;
|
|
3330
3613
|
function Checkbox(props) {
|
|
3331
3614
|
const { children, onClick, ...rest } = props;
|
|
3332
|
-
const [checked, setChecked] =
|
|
3333
|
-
const [indeterminate, setIndeterminate] =
|
|
3334
|
-
|
|
3615
|
+
const [checked, setChecked] = React13__default.useState(false);
|
|
3616
|
+
const [indeterminate, setIndeterminate] = React13__default.useState(false);
|
|
3617
|
+
React13__default.useEffect(() => {
|
|
3335
3618
|
setChecked(!!rest.checked);
|
|
3336
3619
|
}, [rest.checked]);
|
|
3337
|
-
|
|
3620
|
+
React13__default.useEffect(() => {
|
|
3338
3621
|
setIndeterminate(!!rest.indeterminate);
|
|
3339
3622
|
}, [rest.indeterminate]);
|
|
3340
3623
|
const isIndeterminate = typeof rest.indeterminate === "boolean";
|
|
@@ -3426,14 +3709,14 @@ function Block(props) {
|
|
|
3426
3709
|
tooltip,
|
|
3427
3710
|
...rest
|
|
3428
3711
|
} = anyProps;
|
|
3429
|
-
const fileInputRef =
|
|
3712
|
+
const fileInputRef = React13.useRef(null);
|
|
3430
3713
|
const isLoading = anyProps.isLoading;
|
|
3431
3714
|
const multiple = anyProps.multiple;
|
|
3432
3715
|
const is = anyProps.is;
|
|
3433
3716
|
const extract = extractElType(is, anyProps);
|
|
3434
3717
|
const [Comp, initialStyles] = extractElAndStyles(extract, props);
|
|
3435
3718
|
const icons = getIcons(extract, props);
|
|
3436
|
-
let component = /* @__PURE__ */ jsx(MotionConfig, { transition: _motion, children: extract.isHr ? /* @__PURE__ */ jsx(Hr, { w: true, py: 2, color: "neutral.300", ...anyProps }) : extract.isProgress ? /* @__PURE__ */ jsx(Progress, { ...anyProps }) : extract.isDrawer ? /* @__PURE__ */ jsx(Drawer, { ...anyProps }) : extract.isAccordion ? /* @__PURE__ */ jsx(accordion_default, { ...anyProps }) : extract.isMenu ? /* @__PURE__ */ jsx(Menu, { ...anyProps }) : extract.isSwitch ? /* @__PURE__ */ jsx(switch_default, { ...anyProps }) : extract.isRadio ? /* @__PURE__ */ jsx(Radio, { ...anyProps }) : extract.isInput ? /* @__PURE__ */ jsx(Input, { ...anyProps }) : extract.isTextarea ? /* @__PURE__ */ jsx(Textarea, { ...anyProps }) : extract.isCheckbox ? /* @__PURE__ */ jsx(Checkbox, { ...anyProps }) : extract.isSkeleton ? /* @__PURE__ */ jsx(
|
|
3719
|
+
let component = /* @__PURE__ */ jsx(MotionConfig, { transition: _motion, children: extract.isHr ? /* @__PURE__ */ jsx(Hr, { w: true, py: 2, color: "neutral.300", ...anyProps }) : extract.isProgress ? /* @__PURE__ */ jsx(Progress, { ...anyProps }) : extract.isSlider ? /* @__PURE__ */ jsx(Slider, { ...anyProps }) : extract.isDrawer ? /* @__PURE__ */ jsx(Drawer, { ...anyProps }) : extract.isAccordion ? /* @__PURE__ */ jsx(accordion_default, { ...anyProps }) : extract.isMenu ? /* @__PURE__ */ jsx(Menu, { ...anyProps }) : extract.isSwitch ? /* @__PURE__ */ jsx(switch_default, { ...anyProps }) : extract.isRadio ? /* @__PURE__ */ jsx(Radio, { ...anyProps }) : extract.isInput ? /* @__PURE__ */ jsx(Input, { ...anyProps }) : extract.isTextarea ? /* @__PURE__ */ jsx(Textarea, { ...anyProps }) : extract.isCheckbox ? /* @__PURE__ */ jsx(Checkbox, { ...anyProps }) : extract.isSkeleton ? /* @__PURE__ */ jsx(
|
|
3437
3720
|
Skeleton,
|
|
3438
3721
|
{
|
|
3439
3722
|
...anyProps.as === "circle" ? { br: "50%", size: 40 } : {
|
|
@@ -3463,7 +3746,7 @@ function Block(props) {
|
|
|
3463
3746
|
...anyProps
|
|
3464
3747
|
}
|
|
3465
3748
|
) : extract.filepickerAllowed ? /* @__PURE__ */ jsxs("div", { onClick: () => fileInputRef.current?.click(), children: [
|
|
3466
|
-
|
|
3749
|
+
React13.createElement(
|
|
3467
3750
|
Comp,
|
|
3468
3751
|
{
|
|
3469
3752
|
cursor: "pointer",
|
|
@@ -3498,11 +3781,11 @@ function Block(props) {
|
|
|
3498
3781
|
value: ""
|
|
3499
3782
|
}
|
|
3500
3783
|
)
|
|
3501
|
-
] }) : extract.isVoidElement ?
|
|
3784
|
+
] }) : extract.isVoidElement ? React13.createElement(Comp, {
|
|
3502
3785
|
...isLoading && { "data-loading": isLoading },
|
|
3503
3786
|
onContextMenu: (e) => e.preventDefault(),
|
|
3504
3787
|
...initialStyles
|
|
3505
|
-
}) :
|
|
3788
|
+
}) : React13.createElement(
|
|
3506
3789
|
Comp,
|
|
3507
3790
|
{
|
|
3508
3791
|
...isLoading && { "data-loading": isLoading },
|
|
@@ -3558,9 +3841,15 @@ var ProgressNamespace = {
|
|
|
3558
3841
|
TrackFill,
|
|
3559
3842
|
TrackBg
|
|
3560
3843
|
};
|
|
3844
|
+
var SliderNamespace = {
|
|
3845
|
+
Track: SliderTrack,
|
|
3846
|
+
Fill: SliderFill,
|
|
3847
|
+
Thumb: SliderThumb
|
|
3848
|
+
};
|
|
3561
3849
|
var CompoundBlock = Object.assign(Block, {
|
|
3562
3850
|
Accordion: AccordionNamespace,
|
|
3563
3851
|
Progress: ProgressNamespace,
|
|
3852
|
+
Slider: SliderNamespace,
|
|
3564
3853
|
Textarea: TextareaNamespace,
|
|
3565
3854
|
Tooltip: TooltipNamespace,
|
|
3566
3855
|
Switch: SwitchNamespace,
|
|
@@ -3611,16 +3900,16 @@ var saveStore = (store) => {
|
|
|
3611
3900
|
|
|
3612
3901
|
// src/react/use-theme/index.ts
|
|
3613
3902
|
function useTheme() {
|
|
3614
|
-
const [store, setStore] =
|
|
3615
|
-
const storeRef =
|
|
3616
|
-
const isInternalUpdateRef =
|
|
3617
|
-
|
|
3903
|
+
const [store, setStore] = React13__default.useState(getInitialStore);
|
|
3904
|
+
const storeRef = React13__default.useRef(store);
|
|
3905
|
+
const isInternalUpdateRef = React13__default.useRef(false);
|
|
3906
|
+
React13__default.useEffect(() => {
|
|
3618
3907
|
storeRef.current = store;
|
|
3619
3908
|
}, [store]);
|
|
3620
|
-
|
|
3909
|
+
React13__default.useEffect(() => {
|
|
3621
3910
|
document.documentElement.setAttribute("data-theme", store.value);
|
|
3622
3911
|
}, [store.value]);
|
|
3623
|
-
|
|
3912
|
+
React13__default.useEffect(() => {
|
|
3624
3913
|
const handleStorageChange = (e) => {
|
|
3625
3914
|
if (e.key === THEME_STORAGE_KEY || e.key === THEME_STORE_STORAGE_KEY) {
|
|
3626
3915
|
setStore(getInitialStore());
|
|
@@ -3663,8 +3952,8 @@ function useTheme() {
|
|
|
3663
3952
|
|
|
3664
3953
|
// src/react/index.ts
|
|
3665
3954
|
function useDebounce(value, delay = 500) {
|
|
3666
|
-
const [debouncedValue, setDebouncedValue] =
|
|
3667
|
-
|
|
3955
|
+
const [debouncedValue, setDebouncedValue] = React13__default.useState(value);
|
|
3956
|
+
React13__default.useEffect(() => {
|
|
3668
3957
|
const handler = setTimeout(() => {
|
|
3669
3958
|
setDebouncedValue(value);
|
|
3670
3959
|
}, delay);
|
|
@@ -3675,10 +3964,10 @@ function useDebounce(value, delay = 500) {
|
|
|
3675
3964
|
return debouncedValue;
|
|
3676
3965
|
}
|
|
3677
3966
|
function useThrottle(value, interval = 500) {
|
|
3678
|
-
const [throttledValue, setThrottledValue] =
|
|
3679
|
-
const lastUpdate =
|
|
3680
|
-
const timeoutRef =
|
|
3681
|
-
|
|
3967
|
+
const [throttledValue, setThrottledValue] = React13__default.useState(value);
|
|
3968
|
+
const lastUpdate = React13__default.useRef(0);
|
|
3969
|
+
const timeoutRef = React13__default.useRef(null);
|
|
3970
|
+
React13__default.useEffect(() => {
|
|
3682
3971
|
const now = Date.now();
|
|
3683
3972
|
const timeSinceLastUpdate = now - lastUpdate.current;
|
|
3684
3973
|
if (timeSinceLastUpdate >= interval) {
|
|
@@ -3708,8 +3997,8 @@ function useMatchMedia2(queries, defaultValues = []) {
|
|
|
3708
3997
|
const matchedQueries = mediaQueryLists.map((mql) => mql.matches);
|
|
3709
3998
|
return matchedQueries;
|
|
3710
3999
|
};
|
|
3711
|
-
const [value, setValue] =
|
|
3712
|
-
|
|
4000
|
+
const [value, setValue] = React13__default.useState(getValue);
|
|
4001
|
+
React13__default.useLayoutEffect(() => {
|
|
3713
4002
|
const handler = () => setValue(getValue);
|
|
3714
4003
|
mediaQueryLists.forEach((mql) => mql.addListener(handler));
|
|
3715
4004
|
return () => mediaQueryLists.forEach((mql) => mql.removeListener(handler));
|