qstd 0.2.21 → 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/accordion.d.ts +1 -1
- package/dist/block/accordion.d.ts.map +1 -1
- package/dist/block/fns.d.ts +2 -1
- 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 +26 -6
- package/dist/block/types.d.ts.map +1 -1
- package/dist/react/index.cjs +432 -143
- package/dist/react/index.css +25 -6
- package/dist/react/index.js +428 -139
- package/package.json +1 -1
- package/styled-system/styles.css +33 -8
package/dist/react/index.cjs
CHANGED
|
@@ -3,7 +3,7 @@ require("./index.css");
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var React13 = require('react');
|
|
7
7
|
var reactDom = require('react-dom');
|
|
8
8
|
var framerMotion = require('framer-motion');
|
|
9
9
|
var react = require('@floating-ui/react');
|
|
@@ -36,7 +36,7 @@ function _interopNamespace(e) {
|
|
|
36
36
|
return Object.freeze(n);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
var
|
|
39
|
+
var React13__namespace = /*#__PURE__*/_interopNamespace(React13);
|
|
40
40
|
|
|
41
41
|
// src/react/index.ts
|
|
42
42
|
|
|
@@ -444,10 +444,10 @@ function styledFn(Dynamic, configOrCva = {}, options = {}) {
|
|
|
444
444
|
const __cvaFn__ = composeCvaFn(Dynamic.__cva__, cvaFn);
|
|
445
445
|
const __shouldForwardProps__ = composeShouldForwardProps(Dynamic, shouldForwardProp);
|
|
446
446
|
const __base__ = Dynamic.__base__ || Dynamic;
|
|
447
|
-
const StyledComponent = /* @__PURE__ */
|
|
447
|
+
const StyledComponent = /* @__PURE__ */ React13.forwardRef(function StyledComponent2(props, ref) {
|
|
448
448
|
const { as: Element2 = __base__, unstyled, children, ...restProps } = props;
|
|
449
|
-
const combinedProps =
|
|
450
|
-
const [htmlProps2, forwardedProps, variantProps, styleProps, elementProps] =
|
|
449
|
+
const combinedProps = React13.useMemo(() => Object.assign({}, defaultProps, restProps), [restProps]);
|
|
450
|
+
const [htmlProps2, forwardedProps, variantProps, styleProps, elementProps] = React13.useMemo(() => {
|
|
451
451
|
return splitProps(combinedProps, normalizeHTMLProps.keys, __shouldForwardProps__, __cvaFn__.variantKeys, isCssProperty);
|
|
452
452
|
}, [combinedProps]);
|
|
453
453
|
function recipeClass() {
|
|
@@ -467,7 +467,7 @@ function styledFn(Dynamic, configOrCva = {}, options = {}) {
|
|
|
467
467
|
}
|
|
468
468
|
return configOrCva.__recipe__ ? recipeClass() : cvaClass();
|
|
469
469
|
};
|
|
470
|
-
return
|
|
470
|
+
return React13.createElement(Element2, {
|
|
471
471
|
ref,
|
|
472
472
|
...forwardedProps,
|
|
473
473
|
...elementProps,
|
|
@@ -630,14 +630,14 @@ function Menu(props) {
|
|
|
630
630
|
trigger,
|
|
631
631
|
...rest
|
|
632
632
|
} = props;
|
|
633
|
-
const hoverTimeoutRef =
|
|
634
|
-
const [isOpen, setOpen] =
|
|
633
|
+
const hoverTimeoutRef = React13__namespace.default.useRef(null);
|
|
634
|
+
const [isOpen, setOpen] = React13__namespace.default.useState(isOpenControlled ?? false);
|
|
635
635
|
const onOpenChange = (open) => {
|
|
636
636
|
const newOpenState = typeof open === "function" ? open(isOpen) : open;
|
|
637
637
|
props.onOpenOrClose?.(newOpenState);
|
|
638
638
|
setOpen(newOpenState);
|
|
639
639
|
};
|
|
640
|
-
|
|
640
|
+
React13__namespace.default.useEffect(() => {
|
|
641
641
|
if (typeof isOpenControlled !== "boolean") return;
|
|
642
642
|
setOpen(isOpenControlled);
|
|
643
643
|
}, [isOpenControlled]);
|
|
@@ -712,11 +712,11 @@ function Menu(props) {
|
|
|
712
712
|
},
|
|
713
713
|
isOpen
|
|
714
714
|
);
|
|
715
|
-
|
|
715
|
+
React13__namespace.default.useEffect(() => {
|
|
716
716
|
if (!hideData?.referenceHidden) return;
|
|
717
717
|
closeMenuImmediate();
|
|
718
718
|
}, [hideData, closeMenuImmediate]);
|
|
719
|
-
|
|
719
|
+
React13__namespace.default.useEffect(() => {
|
|
720
720
|
return () => {
|
|
721
721
|
if (hoverTimeoutRef.current) clearTimeout(hoverTimeoutRef.current);
|
|
722
722
|
};
|
|
@@ -742,10 +742,10 @@ function Menu(props) {
|
|
|
742
742
|
onMouseLeave: handleMenuMouseLeave
|
|
743
743
|
} : {};
|
|
744
744
|
const transformOrigin = floatingContext.placement.startsWith("top") ? "bottom left" : "top left";
|
|
745
|
-
const childArray =
|
|
745
|
+
const childArray = React13__namespace.default.Children.toArray(children);
|
|
746
746
|
let customContainerEl = null;
|
|
747
747
|
for (const c of childArray) {
|
|
748
|
-
if (
|
|
748
|
+
if (React13__namespace.default.isValidElement(c)) {
|
|
749
749
|
const anyType = c.type;
|
|
750
750
|
if (c.props?.["data-menu-container"] || anyType?.isBlockMenuContainer) {
|
|
751
751
|
customContainerEl = c;
|
|
@@ -774,7 +774,7 @@ function Menu(props) {
|
|
|
774
774
|
...restStyle || {}
|
|
775
775
|
};
|
|
776
776
|
const mergedClassName = [defaultsClassName, childProps.className].filter(Boolean).join(" ");
|
|
777
|
-
const contentNode =
|
|
777
|
+
const contentNode = React13__namespace.default.cloneElement(
|
|
778
778
|
customContainerEl,
|
|
779
779
|
{
|
|
780
780
|
// Defaults are now in mergedClassName via css()
|
|
@@ -860,7 +860,7 @@ function Menu(props) {
|
|
|
860
860
|
);
|
|
861
861
|
}
|
|
862
862
|
function useOutsideClick(ref, handler, enabled = true) {
|
|
863
|
-
|
|
863
|
+
React13__namespace.default.useEffect(() => {
|
|
864
864
|
if (!enabled) return;
|
|
865
865
|
const listener = (event) => {
|
|
866
866
|
if (!ref.current || ref.current.contains(event.target)) {
|
|
@@ -967,9 +967,9 @@ var prepareFiles = async (acceptedFiles) => {
|
|
|
967
967
|
);
|
|
968
968
|
};
|
|
969
969
|
var findChildrenByDisplayName = (children, displayName2) => {
|
|
970
|
-
return
|
|
970
|
+
return React13__namespace.default.Children.toArray(children).find(
|
|
971
971
|
(child) => {
|
|
972
|
-
if (
|
|
972
|
+
if (React13__namespace.default.isValidElement(child)) {
|
|
973
973
|
const childType = child.type;
|
|
974
974
|
return childType.displayName === displayName2;
|
|
975
975
|
} else {
|
|
@@ -996,6 +996,7 @@ var extractElType = (is, props) => {
|
|
|
996
996
|
else if (is === "blockquote") el = "blockquote";
|
|
997
997
|
else if (is === "pre") el = "pre";
|
|
998
998
|
else if (is === "progress") el = "progress";
|
|
999
|
+
else if (is === "slider") el = "div";
|
|
999
1000
|
else if (is === "drawer") el = "div";
|
|
1000
1001
|
else if (is === "menu") el = "div";
|
|
1001
1002
|
else if (is === "form") el = "form";
|
|
@@ -1010,6 +1011,7 @@ var extractElType = (is, props) => {
|
|
|
1010
1011
|
const isRadio = is === "radio";
|
|
1011
1012
|
const isDrawer = is === "drawer";
|
|
1012
1013
|
const isSwitch = is === "switch";
|
|
1014
|
+
const isSlider = is === "slider";
|
|
1013
1015
|
const isSkeleton = is === "skeleton";
|
|
1014
1016
|
const isCheckbox = is === "checkbox";
|
|
1015
1017
|
const isTextarea = is === "textarea";
|
|
@@ -1026,6 +1028,7 @@ var extractElType = (is, props) => {
|
|
|
1026
1028
|
isInput,
|
|
1027
1029
|
isRadio,
|
|
1028
1030
|
isSwitch,
|
|
1031
|
+
isSlider,
|
|
1029
1032
|
isBtnLike,
|
|
1030
1033
|
isAccordion,
|
|
1031
1034
|
filepickerAllowed,
|
|
@@ -1111,7 +1114,7 @@ function getIcon(position, Icon2, props) {
|
|
|
1111
1114
|
const Cmp = loadingIconsMap[chosen];
|
|
1112
1115
|
const sizePx = typeof loadingIconSize === "number" ? `${loadingIconSize}px` : "12px";
|
|
1113
1116
|
return Cmp({ width: sizePx, height: sizePx });
|
|
1114
|
-
} else if (
|
|
1117
|
+
} else if (React13__namespace.default.isValidElement(chosen)) {
|
|
1115
1118
|
return chosen;
|
|
1116
1119
|
} else if (typeof chosen === "function") {
|
|
1117
1120
|
return chosen();
|
|
@@ -1208,9 +1211,9 @@ var TrackNameKey = "Track";
|
|
|
1208
1211
|
var ThumbNameKey = "Thumb";
|
|
1209
1212
|
var Button = motionTags.button;
|
|
1210
1213
|
var Base = motionTags.div;
|
|
1211
|
-
var SwitchContext =
|
|
1214
|
+
var SwitchContext = React13__namespace.default.createContext(null);
|
|
1212
1215
|
var useSwitchContext = () => {
|
|
1213
|
-
const context2 =
|
|
1216
|
+
const context2 = React13__namespace.default.useContext(SwitchContext);
|
|
1214
1217
|
if (!context2) {
|
|
1215
1218
|
throw new Error("Switch compound components must be used within Switch");
|
|
1216
1219
|
}
|
|
@@ -1226,16 +1229,16 @@ function Switch(props) {
|
|
|
1226
1229
|
_motion,
|
|
1227
1230
|
...rest
|
|
1228
1231
|
} = props;
|
|
1229
|
-
const [x, setX] =
|
|
1230
|
-
const [pressed, setPressed] =
|
|
1231
|
-
const [growThumb, setGrowThumb] =
|
|
1232
|
+
const [x, setX] = React13__namespace.default.useState(0);
|
|
1233
|
+
const [pressed, setPressed] = React13__namespace.default.useState(false);
|
|
1234
|
+
const [growThumb, setGrowThumb] = React13__namespace.default.useState(false);
|
|
1232
1235
|
const borderWidth = 4;
|
|
1233
1236
|
const trackWidth = thumbSize * 1.5;
|
|
1234
1237
|
const borderRadius = thumbSize * 2.5;
|
|
1235
1238
|
const xWhileOn = thumbSize;
|
|
1236
1239
|
const checkedPosition = xWhileOn * 0.5;
|
|
1237
1240
|
const stopwatch = useStopwatch();
|
|
1238
|
-
|
|
1241
|
+
React13__namespace.default.useEffect(() => {
|
|
1239
1242
|
if (pressed && !disabled) {
|
|
1240
1243
|
stopwatch.start();
|
|
1241
1244
|
} else {
|
|
@@ -1243,12 +1246,12 @@ function Switch(props) {
|
|
|
1243
1246
|
stopwatch.clear();
|
|
1244
1247
|
}
|
|
1245
1248
|
}, [pressed, disabled]);
|
|
1246
|
-
|
|
1249
|
+
React13__namespace.default.useEffect(() => {
|
|
1247
1250
|
if (stopwatch.time > 200) {
|
|
1248
1251
|
setGrowThumb(true);
|
|
1249
1252
|
}
|
|
1250
1253
|
}, [stopwatch.time]);
|
|
1251
|
-
|
|
1254
|
+
React13__namespace.default.useEffect(() => {
|
|
1252
1255
|
setX(checked ? checkedPosition : 0);
|
|
1253
1256
|
}, [checked, checkedPosition]);
|
|
1254
1257
|
const toggle = () => {
|
|
@@ -1313,10 +1316,10 @@ function Switch(props) {
|
|
|
1313
1316
|
children,
|
|
1314
1317
|
ThumbNameKey
|
|
1315
1318
|
);
|
|
1316
|
-
const trackElement = track ?
|
|
1319
|
+
const trackElement = track ? React13__namespace.default.cloneElement(track, {
|
|
1317
1320
|
_motion,
|
|
1318
|
-
children: thumb ?
|
|
1319
|
-
}) : /* @__PURE__ */ jsxRuntime.jsx(Track, { _motion, children: thumb ?
|
|
1321
|
+
children: thumb ? React13__namespace.default.cloneElement(thumb, { _motion }) : /* @__PURE__ */ jsxRuntime.jsx(Thumb, { _motion })
|
|
1322
|
+
}) : /* @__PURE__ */ jsxRuntime.jsx(Track, { _motion, children: thumb ? React13__namespace.default.cloneElement(thumb, { _motion }) : /* @__PURE__ */ jsxRuntime.jsx(Thumb, { _motion }) });
|
|
1320
1323
|
return /* @__PURE__ */ jsxRuntime.jsx(SwitchContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsx(framerMotion.MotionConfig, { transition: _motion, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1321
1324
|
Button,
|
|
1322
1325
|
{
|
|
@@ -1441,10 +1444,10 @@ function Thumb(props) {
|
|
|
1441
1444
|
Track.displayName = TrackNameKey;
|
|
1442
1445
|
Thumb.displayName = ThumbNameKey;
|
|
1443
1446
|
function useStopwatch(props = {}) {
|
|
1444
|
-
const [active, setActive] =
|
|
1445
|
-
const [time, setTime] =
|
|
1447
|
+
const [active, setActive] = React13__namespace.default.useState(false);
|
|
1448
|
+
const [time, setTime] = React13__namespace.default.useState(0);
|
|
1446
1449
|
const timeInterval = props?.interval ?? 10;
|
|
1447
|
-
|
|
1450
|
+
React13__namespace.default.useEffect(() => {
|
|
1448
1451
|
let interval = null;
|
|
1449
1452
|
if (active) {
|
|
1450
1453
|
interval = setInterval(() => {
|
|
@@ -1464,7 +1467,7 @@ function useStopwatch(props = {}) {
|
|
|
1464
1467
|
return { time, start, stop, clear };
|
|
1465
1468
|
}
|
|
1466
1469
|
var switch_default = Switch;
|
|
1467
|
-
var RadioContext =
|
|
1470
|
+
var RadioContext = React13__namespace.default.createContext(null);
|
|
1468
1471
|
var Base2 = base;
|
|
1469
1472
|
var MotionDiv2 = motionTags.div;
|
|
1470
1473
|
function Radio(props) {
|
|
@@ -1479,14 +1482,14 @@ function Radio(props) {
|
|
|
1479
1482
|
onKeyDown: onKeyDownProp,
|
|
1480
1483
|
...rest
|
|
1481
1484
|
} = props;
|
|
1482
|
-
const groupId =
|
|
1485
|
+
const groupId = React13__namespace.default.useId();
|
|
1483
1486
|
const isControlled = controlledValue !== void 0;
|
|
1484
|
-
const [uncontrolled, setUncontrolled] =
|
|
1487
|
+
const [uncontrolled, setUncontrolled] = React13__namespace.default.useState(
|
|
1485
1488
|
defaultValue
|
|
1486
1489
|
);
|
|
1487
1490
|
const selectedValue = isControlled ? controlledValue : uncontrolled;
|
|
1488
|
-
const itemsRef =
|
|
1489
|
-
const [activeId, setActiveId] =
|
|
1491
|
+
const itemsRef = React13__namespace.default.useRef([]);
|
|
1492
|
+
const [activeId, setActiveId] = React13__namespace.default.useState("");
|
|
1490
1493
|
const setSelectedValue = (val) => {
|
|
1491
1494
|
if (!isControlled) setUncontrolled(val);
|
|
1492
1495
|
onChange?.(val);
|
|
@@ -1539,7 +1542,7 @@ function Radio(props) {
|
|
|
1539
1542
|
setActiveId(found.id);
|
|
1540
1543
|
}
|
|
1541
1544
|
};
|
|
1542
|
-
|
|
1545
|
+
React13__namespace.default.useEffect(() => {
|
|
1543
1546
|
if (!selectedValue) return;
|
|
1544
1547
|
const selected = itemsRef.current.find((x) => x.value === selectedValue);
|
|
1545
1548
|
if (selected && !selected.disabled) setActiveId(selected.id);
|
|
@@ -1580,7 +1583,7 @@ function Radio(props) {
|
|
|
1580
1583
|
},
|
|
1581
1584
|
children: [
|
|
1582
1585
|
(options ?? []).map(
|
|
1583
|
-
(opt) => renderOption ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1586
|
+
(opt) => renderOption ? /* @__PURE__ */ jsxRuntime.jsx(React13__namespace.default.Fragment, { children: renderOption(opt) }, opt.value) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
1584
1587
|
Item,
|
|
1585
1588
|
{
|
|
1586
1589
|
value: opt.value,
|
|
@@ -1610,7 +1613,7 @@ function Item(props) {
|
|
|
1610
1613
|
onBlur: onBlurProp,
|
|
1611
1614
|
...rest
|
|
1612
1615
|
} = props;
|
|
1613
|
-
const ctx =
|
|
1616
|
+
const ctx = React13__namespace.default.useContext(RadioContext);
|
|
1614
1617
|
if (!ctx) {
|
|
1615
1618
|
return /* @__PURE__ */ jsxRuntime.jsxs(Base2, { flex: true, alignI: true, cursor: "pointer", ...rest, children: [
|
|
1616
1619
|
/* @__PURE__ */ jsxRuntime.jsx(Base2, { "data-radio-circle": true, w: 24, h: 24, br: 9999, mr: 8 }),
|
|
@@ -1629,22 +1632,22 @@ function Item(props) {
|
|
|
1629
1632
|
} = ctx;
|
|
1630
1633
|
const disabled = !!(groupDisabled || itemDisabled);
|
|
1631
1634
|
const id = `radio-item-${groupId}-${value}`;
|
|
1632
|
-
const ref =
|
|
1633
|
-
|
|
1635
|
+
const ref = React13__namespace.default.useRef(null);
|
|
1636
|
+
React13__namespace.default.useEffect(() => {
|
|
1634
1637
|
registerItem({ id, value, disabled, ref });
|
|
1635
1638
|
return () => unregisterItem(id);
|
|
1636
1639
|
}, [id, value, disabled]);
|
|
1637
1640
|
const isSelected = selectedValue === value;
|
|
1638
1641
|
const isActive = isActiveId(id);
|
|
1639
|
-
const [isFocused, setIsFocused] =
|
|
1642
|
+
const [isFocused, setIsFocused] = React13__namespace.default.useState(false);
|
|
1640
1643
|
const shouldUseGrid = gridProp || !!colsProp;
|
|
1641
1644
|
const renderLabel = () => {
|
|
1642
|
-
const onlyChild =
|
|
1645
|
+
const onlyChild = React13__namespace.default.Children.count(children) === 1 ? React13__namespace.default.Children.toArray(children)[0] : null;
|
|
1643
1646
|
if (typeof onlyChild === "string") {
|
|
1644
1647
|
return /* @__PURE__ */ jsxRuntime.jsx(Base2, { "data-radio-label": true, children: onlyChild });
|
|
1645
1648
|
}
|
|
1646
|
-
if (
|
|
1647
|
-
return
|
|
1649
|
+
if (React13__namespace.default.isValidElement(onlyChild)) {
|
|
1650
|
+
return React13__namespace.default.cloneElement(
|
|
1648
1651
|
onlyChild,
|
|
1649
1652
|
{
|
|
1650
1653
|
...onlyChild.props || {},
|
|
@@ -1764,7 +1767,7 @@ function Item(props) {
|
|
|
1764
1767
|
var LabelNameKey = "Label";
|
|
1765
1768
|
var Base3 = base;
|
|
1766
1769
|
var isBrowser = typeof window !== "undefined";
|
|
1767
|
-
var useIsomorphicLayoutEffect = isBrowser ?
|
|
1770
|
+
var useIsomorphicLayoutEffect = isBrowser ? React13__namespace.default.useLayoutEffect : React13__namespace.default.useEffect;
|
|
1768
1771
|
function pick(props, obj) {
|
|
1769
1772
|
return props.reduce(
|
|
1770
1773
|
(acc, prop) => {
|
|
@@ -1896,16 +1899,16 @@ function Textarea(props) {
|
|
|
1896
1899
|
...rest
|
|
1897
1900
|
} = props;
|
|
1898
1901
|
const isControlled = rest.value !== void 0;
|
|
1899
|
-
const libRef =
|
|
1902
|
+
const libRef = React13__namespace.default.useRef(null);
|
|
1900
1903
|
const ref = assignRefs(libRef, userRef);
|
|
1901
|
-
const heightRef =
|
|
1902
|
-
const [_value, _setValue] =
|
|
1904
|
+
const heightRef = React13__namespace.default.useRef(0);
|
|
1905
|
+
const [_value, _setValue] = React13__namespace.default.useState("");
|
|
1903
1906
|
const value = props.value ?? _value;
|
|
1904
1907
|
const label = findChildrenByDisplayName(
|
|
1905
1908
|
children,
|
|
1906
1909
|
LabelNameKey
|
|
1907
1910
|
);
|
|
1908
|
-
const labelWithProps = label ?
|
|
1911
|
+
const labelWithProps = label ? React13__namespace.default.cloneElement(label, {
|
|
1909
1912
|
required: props.required,
|
|
1910
1913
|
value: props.value,
|
|
1911
1914
|
error
|
|
@@ -1936,20 +1939,20 @@ function Textarea(props) {
|
|
|
1936
1939
|
useIsomorphicLayoutEffect(() => {
|
|
1937
1940
|
resizeTextarea();
|
|
1938
1941
|
}, [rest.value, rest.placeholder, minRows, maxRows]);
|
|
1939
|
-
|
|
1942
|
+
React13__namespace.default.useEffect(() => {
|
|
1940
1943
|
if (!isBrowser) return;
|
|
1941
1944
|
const onResize = () => resizeTextarea();
|
|
1942
1945
|
window.addEventListener("resize", onResize);
|
|
1943
1946
|
return () => window.removeEventListener("resize", onResize);
|
|
1944
1947
|
}, [minRows, maxRows, rest.placeholder, rest.value]);
|
|
1945
|
-
|
|
1948
|
+
React13__namespace.default.useEffect(() => {
|
|
1946
1949
|
const fonts = isBrowser ? document.fonts : void 0;
|
|
1947
1950
|
if (!fonts || typeof fonts.addEventListener !== "function") return;
|
|
1948
1951
|
const onFontsLoaded = () => resizeTextarea();
|
|
1949
1952
|
fonts.addEventListener("loadingdone", onFontsLoaded);
|
|
1950
1953
|
return () => fonts.removeEventListener("loadingdone", onFontsLoaded);
|
|
1951
1954
|
}, [minRows, maxRows, rest.placeholder, rest.value]);
|
|
1952
|
-
|
|
1955
|
+
React13__namespace.default.useEffect(() => {
|
|
1953
1956
|
const node = libRef.current;
|
|
1954
1957
|
const form = node?.form;
|
|
1955
1958
|
if (!node || !form || isControlled) return;
|
|
@@ -2101,13 +2104,13 @@ function Input(props) {
|
|
|
2101
2104
|
children,
|
|
2102
2105
|
RightSideNameKey
|
|
2103
2106
|
);
|
|
2104
|
-
const labelWithProps = label ?
|
|
2107
|
+
const labelWithProps = label ? React13__namespace.default.cloneElement(label, {
|
|
2105
2108
|
hasLeftIcon: !!leftIcon,
|
|
2106
2109
|
required: props.required,
|
|
2107
2110
|
value: props.value,
|
|
2108
2111
|
error
|
|
2109
2112
|
}) : null;
|
|
2110
|
-
const rightSideWithProps = rightSide ?
|
|
2113
|
+
const rightSideWithProps = rightSide ? React13__namespace.default.cloneElement(rightSide, {
|
|
2111
2114
|
onChange: props.onChange,
|
|
2112
2115
|
value: props.value
|
|
2113
2116
|
}) : null;
|
|
@@ -2232,29 +2235,29 @@ function Label2(props) {
|
|
|
2232
2235
|
Label2.displayName = LabelNameKey2;
|
|
2233
2236
|
function useResizeObserver(opts = {}) {
|
|
2234
2237
|
const onResize = opts.onResize;
|
|
2235
|
-
const onResizeRef =
|
|
2236
|
-
|
|
2238
|
+
const onResizeRef = React13__namespace.default.useRef(void 0);
|
|
2239
|
+
React13__namespace.default.useLayoutEffect(() => {
|
|
2237
2240
|
onResizeRef.current = onResize;
|
|
2238
2241
|
}, [onResize]);
|
|
2239
2242
|
const round = opts.round || Math.round;
|
|
2240
|
-
const resizeObserverRef =
|
|
2241
|
-
const [size, setSize] =
|
|
2243
|
+
const resizeObserverRef = React13__namespace.default.useRef(null);
|
|
2244
|
+
const [size, setSize] = React13__namespace.default.useState({
|
|
2242
2245
|
width: void 0,
|
|
2243
2246
|
height: void 0
|
|
2244
2247
|
});
|
|
2245
|
-
const didUnmount =
|
|
2246
|
-
|
|
2248
|
+
const didUnmount = React13__namespace.default.useRef(false);
|
|
2249
|
+
React13__namespace.default.useEffect(() => {
|
|
2247
2250
|
didUnmount.current = false;
|
|
2248
2251
|
return () => {
|
|
2249
2252
|
didUnmount.current = true;
|
|
2250
2253
|
};
|
|
2251
2254
|
}, []);
|
|
2252
|
-
const previous =
|
|
2255
|
+
const previous = React13__namespace.default.useRef({
|
|
2253
2256
|
width: void 0,
|
|
2254
2257
|
height: void 0
|
|
2255
2258
|
});
|
|
2256
2259
|
const refCallback = useResolvedElement(
|
|
2257
|
-
|
|
2260
|
+
React13__namespace.default.useCallback(
|
|
2258
2261
|
(element) => {
|
|
2259
2262
|
if (!resizeObserverRef.current || resizeObserverRef.current.box !== opts.box || resizeObserverRef.current.round !== round) {
|
|
2260
2263
|
resizeObserverRef.current = {
|
|
@@ -2294,7 +2297,7 @@ function useResizeObserver(opts = {}) {
|
|
|
2294
2297
|
),
|
|
2295
2298
|
opts.ref
|
|
2296
2299
|
);
|
|
2297
|
-
return
|
|
2300
|
+
return React13__namespace.default.useMemo(
|
|
2298
2301
|
() => ({
|
|
2299
2302
|
ref: refCallback,
|
|
2300
2303
|
width: size.width,
|
|
@@ -2306,12 +2309,12 @@ function useResizeObserver(opts = {}) {
|
|
|
2306
2309
|
);
|
|
2307
2310
|
}
|
|
2308
2311
|
function useResolvedElement(subscriber, refOrElement) {
|
|
2309
|
-
const lastReportRef =
|
|
2310
|
-
const refOrElementRef =
|
|
2311
|
-
|
|
2312
|
+
const lastReportRef = React13__namespace.default.useRef(null);
|
|
2313
|
+
const refOrElementRef = React13__namespace.default.useRef(null);
|
|
2314
|
+
React13__namespace.default.useLayoutEffect(() => {
|
|
2312
2315
|
refOrElementRef.current = refOrElement;
|
|
2313
2316
|
}, [refOrElement]);
|
|
2314
|
-
const cbElementRef =
|
|
2317
|
+
const cbElementRef = React13__namespace.default.useRef(null);
|
|
2315
2318
|
const evaluateSubscription = () => {
|
|
2316
2319
|
const cbElement = cbElementRef.current;
|
|
2317
2320
|
const refOrElement2 = refOrElementRef.current;
|
|
@@ -2330,10 +2333,10 @@ function useResolvedElement(subscriber, refOrElement) {
|
|
|
2330
2333
|
cleanup: element ? subscriber(element) : void 0
|
|
2331
2334
|
};
|
|
2332
2335
|
};
|
|
2333
|
-
|
|
2336
|
+
React13__namespace.default.useEffect(() => {
|
|
2334
2337
|
evaluateSubscription();
|
|
2335
2338
|
});
|
|
2336
|
-
|
|
2339
|
+
React13__namespace.default.useEffect(() => {
|
|
2337
2340
|
return () => {
|
|
2338
2341
|
if (lastReportRef.current && lastReportRef.current.cleanup) {
|
|
2339
2342
|
lastReportRef.current.cleanup();
|
|
@@ -2359,7 +2362,7 @@ var use_resize_observer_default = useResizeObserver;
|
|
|
2359
2362
|
var MotionDiv3 = motionTags.div;
|
|
2360
2363
|
var MotionBtn = motionTags.button;
|
|
2361
2364
|
var displayName = "AccordionItem";
|
|
2362
|
-
var AccordionContext =
|
|
2365
|
+
var AccordionContext = React13__namespace.default.createContext({});
|
|
2363
2366
|
function AccordionProvider(props) {
|
|
2364
2367
|
const [state, setState] = useImmer.useImmer({
|
|
2365
2368
|
allowMultiple: false,
|
|
@@ -2369,7 +2372,7 @@ function AccordionProvider(props) {
|
|
|
2369
2372
|
return /* @__PURE__ */ jsxRuntime.jsx(AccordionContext.Provider, { value: { setState, state }, children: props.children });
|
|
2370
2373
|
}
|
|
2371
2374
|
function useAccordion() {
|
|
2372
|
-
const context2 =
|
|
2375
|
+
const context2 = React13__namespace.default.useContext(AccordionContext);
|
|
2373
2376
|
if (context2 === void 0) {
|
|
2374
2377
|
throw new Error("useAccordion must be used within a AccordionProvider");
|
|
2375
2378
|
}
|
|
@@ -2378,23 +2381,23 @@ function useAccordion() {
|
|
|
2378
2381
|
function AccordionComponent(props) {
|
|
2379
2382
|
const accordion = useAccordion();
|
|
2380
2383
|
const accordionState = accordion.state;
|
|
2381
|
-
|
|
2384
|
+
React13__namespace.default.useEffect(() => {
|
|
2382
2385
|
accordion.setState((draft) => {
|
|
2383
2386
|
draft.allowMultiple = !!props.allowMultiple;
|
|
2384
2387
|
draft.allowToggle = !!props.allowToggle;
|
|
2385
2388
|
});
|
|
2386
2389
|
}, [props.allowMultiple, props.allowToggle]);
|
|
2387
|
-
|
|
2390
|
+
React13__namespace.default.Children.forEach(props.children, (x) => {
|
|
2388
2391
|
if (typeof x.type === "function" && "displayName" in x.type && x.type.displayName !== displayName) {
|
|
2389
2392
|
throw new Error("Accordion can only have AccordionItems as children");
|
|
2390
2393
|
}
|
|
2391
2394
|
});
|
|
2392
|
-
const children =
|
|
2393
|
-
if (!
|
|
2394
|
-
return
|
|
2395
|
+
const children = React13__namespace.default.Children.map(props.children, (child, i) => {
|
|
2396
|
+
if (!React13__namespace.default.isValidElement(child)) return child;
|
|
2397
|
+
return React13__namespace.default.cloneElement(child, { idx: i });
|
|
2395
2398
|
});
|
|
2396
2399
|
const defaultOpenIdxList = JSON.stringify(props.defaultOpenIdx ?? []);
|
|
2397
|
-
|
|
2400
|
+
React13__namespace.default.useEffect(
|
|
2398
2401
|
() => {
|
|
2399
2402
|
if (accordionState.open.length === children.length) return;
|
|
2400
2403
|
const defaultOpenIdx = props.defaultOpenIdx;
|
|
@@ -2501,14 +2504,14 @@ var MotionDiv4 = motionTags.div;
|
|
|
2501
2504
|
var MotionBtn2 = motionTags.button;
|
|
2502
2505
|
var breakpoint = ["(min-width: 600px)"];
|
|
2503
2506
|
function DrawerComponent(props) {
|
|
2504
|
-
const ref =
|
|
2505
|
-
const dragHandleRef =
|
|
2507
|
+
const ref = React13__namespace.default.useRef(null);
|
|
2508
|
+
const dragHandleRef = React13__namespace.default.useRef(null);
|
|
2506
2509
|
const [isDesktop] = useMatchMedia(breakpoint);
|
|
2507
|
-
const closeFnRef =
|
|
2508
|
-
const prevOpenRef =
|
|
2510
|
+
const closeFnRef = React13__namespace.default.useRef(null);
|
|
2511
|
+
const prevOpenRef = React13__namespace.default.useRef(null);
|
|
2509
2512
|
const dragControls = framerMotion.useDragControls();
|
|
2510
2513
|
const { open, setOpen } = useDrawer();
|
|
2511
|
-
const { onClose, ...rest } = props;
|
|
2514
|
+
const { onClose, onExitComplete, ...rest } = props;
|
|
2512
2515
|
const y = framerMotion.useMotionValue(0);
|
|
2513
2516
|
const openDrawer = () => {
|
|
2514
2517
|
y.stop();
|
|
@@ -2519,7 +2522,7 @@ function DrawerComponent(props) {
|
|
|
2519
2522
|
y.stop();
|
|
2520
2523
|
setOpen(false);
|
|
2521
2524
|
};
|
|
2522
|
-
|
|
2525
|
+
React13__namespace.default.useEffect(() => {
|
|
2523
2526
|
closeFnRef.current = () => {
|
|
2524
2527
|
closeDrawer();
|
|
2525
2528
|
onClose?.();
|
|
@@ -2539,7 +2542,7 @@ function DrawerComponent(props) {
|
|
|
2539
2542
|
);
|
|
2540
2543
|
}
|
|
2541
2544
|
};
|
|
2542
|
-
|
|
2545
|
+
React13__namespace.default.useLayoutEffect(() => {
|
|
2543
2546
|
const wasOpen = prevOpenRef.current;
|
|
2544
2547
|
const isOpen = props.open;
|
|
2545
2548
|
if (isOpen) {
|
|
@@ -2549,7 +2552,7 @@ function DrawerComponent(props) {
|
|
|
2549
2552
|
}
|
|
2550
2553
|
prevOpenRef.current = isOpen;
|
|
2551
2554
|
}, [props.open]);
|
|
2552
|
-
|
|
2555
|
+
React13__namespace.default.useEffect(() => {
|
|
2553
2556
|
const container = ref.current;
|
|
2554
2557
|
if (!open || !container) return;
|
|
2555
2558
|
container.setAttribute("tabindex", "0");
|
|
@@ -2571,7 +2574,7 @@ function DrawerComponent(props) {
|
|
|
2571
2574
|
document.body.style.overflow = "auto";
|
|
2572
2575
|
};
|
|
2573
2576
|
}, [open, props.closeOnEsc]);
|
|
2574
|
-
|
|
2577
|
+
React13__namespace.default.useEffect(() => {
|
|
2575
2578
|
if (!props.open) return;
|
|
2576
2579
|
const unsubscribeY = y.on("change", (latestY) => {
|
|
2577
2580
|
if (latestY > 150) {
|
|
@@ -2591,7 +2594,7 @@ function DrawerComponent(props) {
|
|
|
2591
2594
|
closeFnRef.current?.();
|
|
2592
2595
|
};
|
|
2593
2596
|
return reactDom.createPortal(
|
|
2594
|
-
/* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { initial: false, mode: "wait", children: open && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2597
|
+
/* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { initial: false, mode: "wait", onExitComplete, children: open && /* @__PURE__ */ jsxRuntime.jsx(
|
|
2595
2598
|
Backdrop,
|
|
2596
2599
|
{
|
|
2597
2600
|
onClick: () => onBackdropClick(),
|
|
@@ -2731,19 +2734,19 @@ function DrawerComponent(props) {
|
|
|
2731
2734
|
document.getElementById("portal")
|
|
2732
2735
|
);
|
|
2733
2736
|
}
|
|
2734
|
-
var DrawerContext =
|
|
2737
|
+
var DrawerContext = React13__namespace.default.createContext({
|
|
2735
2738
|
open: false,
|
|
2736
2739
|
setOpen: () => {
|
|
2737
2740
|
return;
|
|
2738
2741
|
}
|
|
2739
2742
|
});
|
|
2740
2743
|
function DrawerProvider(props) {
|
|
2741
|
-
const [open, setOpen] =
|
|
2744
|
+
const [open, setOpen] = React13__namespace.default.useState(false);
|
|
2742
2745
|
const value = { open, setOpen };
|
|
2743
2746
|
return /* @__PURE__ */ jsxRuntime.jsx(DrawerContext.Provider, { value, children: props.children });
|
|
2744
2747
|
}
|
|
2745
2748
|
function useDrawer() {
|
|
2746
|
-
const context2 =
|
|
2749
|
+
const context2 = React13__namespace.default.useContext(DrawerContext);
|
|
2747
2750
|
if (context2 === void 0) {
|
|
2748
2751
|
throw new Error("useDrawer must be used within a DrawerProvider");
|
|
2749
2752
|
}
|
|
@@ -2756,7 +2759,7 @@ function BtnGroup(props) {
|
|
|
2756
2759
|
const [isDesktop] = useMatchMedia(breakpoint);
|
|
2757
2760
|
const { children, ...rest } = props;
|
|
2758
2761
|
if (isDesktop) {
|
|
2759
|
-
return /* @__PURE__ */ jsxRuntime.jsx(MotionDiv4, { flex: true, alignI: true, gap: 4, ...rest, children:
|
|
2762
|
+
return /* @__PURE__ */ jsxRuntime.jsx(MotionDiv4, { flex: true, alignI: true, gap: 4, ...rest, children: React13__namespace.default.Children.toArray(children).toReversed() });
|
|
2760
2763
|
} else {
|
|
2761
2764
|
return /* @__PURE__ */ jsxRuntime.jsx(MotionDiv4, { grid: true, rowG: 14, ...props });
|
|
2762
2765
|
}
|
|
@@ -2809,7 +2812,7 @@ function CloseBtn(props) {
|
|
|
2809
2812
|
}
|
|
2810
2813
|
}
|
|
2811
2814
|
function Backdrop(props) {
|
|
2812
|
-
const allowOutsideClickRef =
|
|
2815
|
+
const allowOutsideClickRef = React13__namespace.default.useRef(true);
|
|
2813
2816
|
const [isDesktop] = useMatchMedia(breakpoint);
|
|
2814
2817
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2815
2818
|
MotionDiv4,
|
|
@@ -2839,10 +2842,10 @@ function Backdrop(props) {
|
|
|
2839
2842
|
);
|
|
2840
2843
|
}
|
|
2841
2844
|
function useMatchMedia(queries) {
|
|
2842
|
-
const [value, setValue] =
|
|
2845
|
+
const [value, setValue] = React13__namespace.default.useState(() => {
|
|
2843
2846
|
return queries.map((q) => window.matchMedia(q).matches);
|
|
2844
2847
|
});
|
|
2845
|
-
|
|
2848
|
+
React13__namespace.default.useLayoutEffect(() => {
|
|
2846
2849
|
const mediaQueryLists = queries.map((q) => window.matchMedia(q));
|
|
2847
2850
|
const handler = () => {
|
|
2848
2851
|
setValue(mediaQueryLists.map((mql) => mql.matches));
|
|
@@ -2860,9 +2863,9 @@ var TrackBgNameKey = "TrackBg";
|
|
|
2860
2863
|
var TrackFillNameKey = "TrackFill";
|
|
2861
2864
|
function Progress(props) {
|
|
2862
2865
|
const { children, steps, value, max: maxProp, ...rest } = props;
|
|
2863
|
-
const [progress, setProgress] =
|
|
2866
|
+
const [progress, setProgress] = React13__namespace.default.useState(0);
|
|
2864
2867
|
const max = maxProp ?? 100;
|
|
2865
|
-
|
|
2868
|
+
React13__namespace.default.useEffect(() => {
|
|
2866
2869
|
setProgress(Math.min((value ?? 0) / max, 1) * 100);
|
|
2867
2870
|
}, [value, max]);
|
|
2868
2871
|
const width = `${progress}%`;
|
|
@@ -2902,7 +2905,7 @@ function Progress(props) {
|
|
|
2902
2905
|
TrackFillNameKey
|
|
2903
2906
|
);
|
|
2904
2907
|
const barHeight = rest.h ?? 8;
|
|
2905
|
-
const bgEl = trackBgChild ?
|
|
2908
|
+
const bgEl = trackBgChild ? React13__namespace.default.cloneElement(trackBgChild, {
|
|
2906
2909
|
gridArea: "1 / 1",
|
|
2907
2910
|
h: barHeight,
|
|
2908
2911
|
w: trackBgChild.props.w ?? true
|
|
@@ -2917,7 +2920,7 @@ function Progress(props) {
|
|
|
2917
2920
|
bg: { base: "neutral.200", _dark: "neutral.700" }
|
|
2918
2921
|
}
|
|
2919
2922
|
);
|
|
2920
|
-
const fillEl = trackFillChild ?
|
|
2923
|
+
const fillEl = trackFillChild ? React13__namespace.default.cloneElement(trackFillChild, {
|
|
2921
2924
|
gridArea: "1 / 1",
|
|
2922
2925
|
h: barHeight,
|
|
2923
2926
|
roundedLeft: 9999,
|
|
@@ -2987,8 +2990,288 @@ function TrackFill(props) {
|
|
|
2987
2990
|
);
|
|
2988
2991
|
}
|
|
2989
2992
|
TrackFill.displayName = TrackFillNameKey;
|
|
2993
|
+
var MotionDiv6 = motionTags.div;
|
|
2994
|
+
var TrackNameKey2 = "SliderTrack";
|
|
2995
|
+
var FillNameKey = "SliderFill";
|
|
2996
|
+
var ThumbNameKey2 = "SliderThumb";
|
|
2997
|
+
var SliderContext = React13__namespace.default.createContext(null);
|
|
2998
|
+
var useSliderContext = () => {
|
|
2999
|
+
const context2 = React13__namespace.default.useContext(SliderContext);
|
|
3000
|
+
if (!context2) {
|
|
3001
|
+
throw new Error("Slider compound components must be used within Slider");
|
|
3002
|
+
}
|
|
3003
|
+
return context2;
|
|
3004
|
+
};
|
|
3005
|
+
function Slider(props) {
|
|
3006
|
+
const {
|
|
3007
|
+
value: controlledValue,
|
|
3008
|
+
defaultValue = 0,
|
|
3009
|
+
min = 0,
|
|
3010
|
+
max = 100,
|
|
3011
|
+
step,
|
|
3012
|
+
disabled = false,
|
|
3013
|
+
onChange,
|
|
3014
|
+
children,
|
|
3015
|
+
_motion,
|
|
3016
|
+
...rest
|
|
3017
|
+
} = props;
|
|
3018
|
+
const isControlled = controlledValue !== void 0;
|
|
3019
|
+
const [internalValue, setInternalValue] = React13__namespace.default.useState(defaultValue);
|
|
3020
|
+
const value = isControlled ? controlledValue : internalValue;
|
|
3021
|
+
const [isDragging, setIsDragging] = React13__namespace.default.useState(false);
|
|
3022
|
+
const trackRef = React13__namespace.default.useRef(null);
|
|
3023
|
+
const percent = Math.min(
|
|
3024
|
+
100,
|
|
3025
|
+
Math.max(0, (value - min) / (max - min) * 100)
|
|
3026
|
+
);
|
|
3027
|
+
const clampValue = React13__namespace.default.useCallback(
|
|
3028
|
+
(rawValue) => {
|
|
3029
|
+
let clamped = Math.max(min, Math.min(max, rawValue));
|
|
3030
|
+
if (step !== void 0 && step > 0) {
|
|
3031
|
+
clamped = Math.round((clamped - min) / step) * step + min;
|
|
3032
|
+
clamped = Math.max(min, Math.min(max, clamped));
|
|
3033
|
+
}
|
|
3034
|
+
return clamped;
|
|
3035
|
+
},
|
|
3036
|
+
[min, max, step]
|
|
3037
|
+
);
|
|
3038
|
+
const getValueFromClientX = React13__namespace.default.useCallback(
|
|
3039
|
+
(clientX) => {
|
|
3040
|
+
const track = trackRef.current;
|
|
3041
|
+
if (!track) return value;
|
|
3042
|
+
const rect = track.getBoundingClientRect();
|
|
3043
|
+
const x = clientX - rect.left;
|
|
3044
|
+
const rawPercent = Math.max(0, Math.min(1, x / rect.width));
|
|
3045
|
+
const rawValue = min + rawPercent * (max - min);
|
|
3046
|
+
return clampValue(rawValue);
|
|
3047
|
+
},
|
|
3048
|
+
[min, max, value, clampValue]
|
|
3049
|
+
);
|
|
3050
|
+
const updateValue = React13__namespace.default.useCallback(
|
|
3051
|
+
(newValue) => {
|
|
3052
|
+
if (disabled) return;
|
|
3053
|
+
if (!isControlled) {
|
|
3054
|
+
setInternalValue(newValue);
|
|
3055
|
+
}
|
|
3056
|
+
onChange?.(newValue);
|
|
3057
|
+
},
|
|
3058
|
+
[disabled, isControlled, onChange]
|
|
3059
|
+
);
|
|
3060
|
+
const handleTrackPointerDown = (e) => {
|
|
3061
|
+
if (disabled) return;
|
|
3062
|
+
e.preventDefault();
|
|
3063
|
+
setIsDragging(true);
|
|
3064
|
+
const newValue = getValueFromClientX(e.clientX);
|
|
3065
|
+
updateValue(newValue);
|
|
3066
|
+
};
|
|
3067
|
+
React13__namespace.default.useEffect(() => {
|
|
3068
|
+
if (!isDragging) return;
|
|
3069
|
+
const controller = new AbortController();
|
|
3070
|
+
const handleMove = (e) => {
|
|
3071
|
+
const newValue = getValueFromClientX(e.clientX);
|
|
3072
|
+
updateValue(newValue);
|
|
3073
|
+
};
|
|
3074
|
+
const handleUp = () => {
|
|
3075
|
+
setIsDragging(false);
|
|
3076
|
+
};
|
|
3077
|
+
const signal = controller.signal;
|
|
3078
|
+
window.addEventListener("pointermove", handleMove, { signal });
|
|
3079
|
+
window.addEventListener("pointerup", handleUp, { signal });
|
|
3080
|
+
window.addEventListener("pointercancel", handleUp, { signal });
|
|
3081
|
+
return () => controller.abort();
|
|
3082
|
+
}, [isDragging, getValueFromClientX, updateValue]);
|
|
3083
|
+
const handleKeyDown = (e) => {
|
|
3084
|
+
if (disabled) return;
|
|
3085
|
+
const stepAmount = step ?? (max - min) / 100;
|
|
3086
|
+
const largeStep = (max - min) / 10;
|
|
3087
|
+
let newValue = value;
|
|
3088
|
+
switch (e.key) {
|
|
3089
|
+
case "ArrowRight":
|
|
3090
|
+
case "ArrowUp":
|
|
3091
|
+
newValue = clampValue(value + stepAmount);
|
|
3092
|
+
break;
|
|
3093
|
+
case "ArrowLeft":
|
|
3094
|
+
case "ArrowDown":
|
|
3095
|
+
newValue = clampValue(value - stepAmount);
|
|
3096
|
+
break;
|
|
3097
|
+
case "PageUp":
|
|
3098
|
+
newValue = clampValue(value + largeStep);
|
|
3099
|
+
break;
|
|
3100
|
+
case "PageDown":
|
|
3101
|
+
newValue = clampValue(value - largeStep);
|
|
3102
|
+
break;
|
|
3103
|
+
case "Home":
|
|
3104
|
+
newValue = min;
|
|
3105
|
+
break;
|
|
3106
|
+
case "End":
|
|
3107
|
+
newValue = max;
|
|
3108
|
+
break;
|
|
3109
|
+
default:
|
|
3110
|
+
return;
|
|
3111
|
+
}
|
|
3112
|
+
e.preventDefault();
|
|
3113
|
+
updateValue(newValue);
|
|
3114
|
+
};
|
|
3115
|
+
const trackChild = findChildrenByDisplayName(
|
|
3116
|
+
children,
|
|
3117
|
+
TrackNameKey2
|
|
3118
|
+
);
|
|
3119
|
+
const fillChild = findChildrenByDisplayName(
|
|
3120
|
+
children,
|
|
3121
|
+
FillNameKey
|
|
3122
|
+
);
|
|
3123
|
+
const thumbChild = findChildrenByDisplayName(
|
|
3124
|
+
children,
|
|
3125
|
+
ThumbNameKey2
|
|
3126
|
+
);
|
|
3127
|
+
const contextValue = {
|
|
3128
|
+
value,
|
|
3129
|
+
min,
|
|
3130
|
+
max,
|
|
3131
|
+
percent,
|
|
3132
|
+
disabled,
|
|
3133
|
+
isDragging,
|
|
3134
|
+
trackRef
|
|
3135
|
+
};
|
|
3136
|
+
const height = rest.h ?? 8;
|
|
3137
|
+
const trackEl = trackChild ? React13__namespace.default.cloneElement(trackChild, {
|
|
3138
|
+
sliderPercent: percent,
|
|
3139
|
+
sliderValue: value,
|
|
3140
|
+
sliderMin: min,
|
|
3141
|
+
sliderMax: max
|
|
3142
|
+
}) : /* @__PURE__ */ jsxRuntime.jsx(SliderTrack, {});
|
|
3143
|
+
const fillEl = fillChild ? React13__namespace.default.cloneElement(fillChild, {
|
|
3144
|
+
sliderPercent: percent,
|
|
3145
|
+
sliderValue: value,
|
|
3146
|
+
sliderMin: min,
|
|
3147
|
+
sliderMax: max
|
|
3148
|
+
}) : /* @__PURE__ */ jsxRuntime.jsx(SliderFill, {});
|
|
3149
|
+
const thumbEl = thumbChild ? React13__namespace.default.cloneElement(thumbChild, {
|
|
3150
|
+
sliderPercent: percent,
|
|
3151
|
+
sliderValue: value,
|
|
3152
|
+
sliderMin: min,
|
|
3153
|
+
sliderMax: max
|
|
3154
|
+
}) : /* @__PURE__ */ jsxRuntime.jsx(SliderThumb, {});
|
|
3155
|
+
return /* @__PURE__ */ jsxRuntime.jsx(SliderContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsx(framerMotion.MotionConfig, { transition: _motion, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3156
|
+
MotionDiv6,
|
|
3157
|
+
{
|
|
3158
|
+
ref: trackRef,
|
|
3159
|
+
role: "slider",
|
|
3160
|
+
"aria-valuemin": min,
|
|
3161
|
+
"aria-valuemax": max,
|
|
3162
|
+
"aria-valuenow": value,
|
|
3163
|
+
"aria-disabled": disabled,
|
|
3164
|
+
tabIndex: disabled ? -1 : 0,
|
|
3165
|
+
grid: true,
|
|
3166
|
+
cols: "1",
|
|
3167
|
+
rows: "1",
|
|
3168
|
+
alignItems: "center",
|
|
3169
|
+
position: "relative",
|
|
3170
|
+
w: true,
|
|
3171
|
+
h: height,
|
|
3172
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
3173
|
+
opacity: disabled ? 0.5 : 1,
|
|
3174
|
+
onPointerDown: handleTrackPointerDown,
|
|
3175
|
+
onKeyDown: handleKeyDown,
|
|
3176
|
+
userSelect: "none",
|
|
3177
|
+
touchAction: "none",
|
|
3178
|
+
...rest,
|
|
3179
|
+
children: [
|
|
3180
|
+
trackEl,
|
|
3181
|
+
fillEl,
|
|
3182
|
+
thumbEl
|
|
3183
|
+
]
|
|
3184
|
+
}
|
|
3185
|
+
) }) });
|
|
3186
|
+
}
|
|
3187
|
+
function SliderTrack(props) {
|
|
3188
|
+
const {
|
|
3189
|
+
sliderPercent: _,
|
|
3190
|
+
sliderValue: _v,
|
|
3191
|
+
sliderMin: _min,
|
|
3192
|
+
sliderMax: _max,
|
|
3193
|
+
...rest
|
|
3194
|
+
} = props;
|
|
3195
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3196
|
+
MotionDiv6,
|
|
3197
|
+
{
|
|
3198
|
+
"data-slider-track": true,
|
|
3199
|
+
gridArea: "1 / 1",
|
|
3200
|
+
w: true,
|
|
3201
|
+
h: "100%",
|
|
3202
|
+
br: 9999,
|
|
3203
|
+
bg: { base: "neutral.200", _dark: "neutral.700" },
|
|
3204
|
+
...rest
|
|
3205
|
+
}
|
|
3206
|
+
);
|
|
3207
|
+
}
|
|
3208
|
+
SliderTrack.displayName = TrackNameKey2;
|
|
3209
|
+
function SliderFill(props) {
|
|
3210
|
+
const {
|
|
3211
|
+
sliderPercent,
|
|
3212
|
+
sliderValue: _v,
|
|
3213
|
+
sliderMin: _min,
|
|
3214
|
+
sliderMax: _max,
|
|
3215
|
+
style,
|
|
3216
|
+
...rest
|
|
3217
|
+
} = props;
|
|
3218
|
+
const { percent } = useSliderContext();
|
|
3219
|
+
const width = `${sliderPercent ?? percent}%`;
|
|
3220
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3221
|
+
MotionDiv6,
|
|
3222
|
+
{
|
|
3223
|
+
"data-slider-fill": true,
|
|
3224
|
+
gridArea: "1 / 1",
|
|
3225
|
+
h: "100%",
|
|
3226
|
+
br: 9999,
|
|
3227
|
+
bg: { base: "blue.500", _dark: "blue.400" },
|
|
3228
|
+
style: { ...style, width },
|
|
3229
|
+
pointerEvents: "none",
|
|
3230
|
+
...rest
|
|
3231
|
+
}
|
|
3232
|
+
);
|
|
3233
|
+
}
|
|
3234
|
+
SliderFill.displayName = FillNameKey;
|
|
3235
|
+
function SliderThumb(props) {
|
|
3236
|
+
const {
|
|
3237
|
+
sliderPercent,
|
|
3238
|
+
sliderValue: _v,
|
|
3239
|
+
sliderMin: _min,
|
|
3240
|
+
sliderMax: _max,
|
|
3241
|
+
style,
|
|
3242
|
+
...rest
|
|
3243
|
+
} = props;
|
|
3244
|
+
const { percent, isDragging, disabled } = useSliderContext();
|
|
3245
|
+
const left = `${sliderPercent ?? percent}%`;
|
|
3246
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3247
|
+
MotionDiv6,
|
|
3248
|
+
{
|
|
3249
|
+
"data-slider-thumb": true,
|
|
3250
|
+
gridArea: "1 / 1",
|
|
3251
|
+
position: "absolute",
|
|
3252
|
+
top: "50%",
|
|
3253
|
+
size: 24,
|
|
3254
|
+
rounded: true,
|
|
3255
|
+
bg: "white",
|
|
3256
|
+
boxShadow: "0 2px 8px rgba(0,0,0,0.25)",
|
|
3257
|
+
cursor: disabled ? "not-allowed" : "grab",
|
|
3258
|
+
pointerEvents: "none",
|
|
3259
|
+
style: {
|
|
3260
|
+
...style,
|
|
3261
|
+
left,
|
|
3262
|
+
transform: "translate(-50%, -50%)"
|
|
3263
|
+
},
|
|
3264
|
+
initial: false,
|
|
3265
|
+
animate: {
|
|
3266
|
+
scale: isDragging ? 1.1 : 1
|
|
3267
|
+
},
|
|
3268
|
+
...rest
|
|
3269
|
+
}
|
|
3270
|
+
);
|
|
3271
|
+
}
|
|
3272
|
+
SliderThumb.displayName = ThumbNameKey2;
|
|
2990
3273
|
var Base5 = base;
|
|
2991
|
-
var TooltipContainer =
|
|
3274
|
+
var TooltipContainer = React13__namespace.default.forwardRef(function TooltipContainer2(props, ref) {
|
|
2992
3275
|
const { children, className, style, ...rest } = props;
|
|
2993
3276
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2994
3277
|
Base5,
|
|
@@ -3015,9 +3298,9 @@ function Tooltip(props) {
|
|
|
3015
3298
|
delay = 80,
|
|
3016
3299
|
className
|
|
3017
3300
|
} = props;
|
|
3018
|
-
const referenceRef =
|
|
3019
|
-
const arrowRef =
|
|
3020
|
-
const [open, setOpen] =
|
|
3301
|
+
const referenceRef = React13__namespace.default.useRef(null);
|
|
3302
|
+
const arrowRef = React13__namespace.default.useRef(null);
|
|
3303
|
+
const [open, setOpen] = React13__namespace.default.useState(false);
|
|
3021
3304
|
const { x, y, refs, strategy, middlewareData, context: context2 } = react.useFloating({
|
|
3022
3305
|
open,
|
|
3023
3306
|
onOpenChange: setOpen,
|
|
@@ -3046,7 +3329,7 @@ function Tooltip(props) {
|
|
|
3046
3329
|
role
|
|
3047
3330
|
]);
|
|
3048
3331
|
const referenceProps = getReferenceProps({});
|
|
3049
|
-
|
|
3332
|
+
React13__namespace.default.useEffect(() => {
|
|
3050
3333
|
if (!follow || !referenceRef.current) return;
|
|
3051
3334
|
const el = referenceRef.current;
|
|
3052
3335
|
const onMove = (e) => {
|
|
@@ -3069,14 +3352,14 @@ function Tooltip(props) {
|
|
|
3069
3352
|
const arrowAnchorStyle = side.startsWith("top") ? { bottom: -anchorOffset } : side.startsWith("bottom") ? { top: -anchorOffset } : side.startsWith("left") ? { right: -anchorOffset } : { left: -anchorOffset };
|
|
3070
3353
|
const arrowStyle = side.startsWith("top") || side.startsWith("bottom") ? { left: arrowX || void 0, ...arrowAnchorStyle } : { top: arrowY || void 0, ...arrowAnchorStyle };
|
|
3071
3354
|
const transformOrigin = side.startsWith("top") ? "center bottom" : side.startsWith("bottom") ? "center top" : side.startsWith("left") ? "right center" : side.startsWith("right") ? "left center" : "center";
|
|
3072
|
-
const childrenArray =
|
|
3355
|
+
const childrenArray = React13__namespace.default.Children.toArray(children);
|
|
3073
3356
|
const hasMultipleChildren = childrenArray.length > 1;
|
|
3074
3357
|
let child;
|
|
3075
3358
|
if (hasMultipleChildren) {
|
|
3076
3359
|
child = /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "inline-block" }, children });
|
|
3077
3360
|
} else {
|
|
3078
|
-
const only =
|
|
3079
|
-
const isDomElement =
|
|
3361
|
+
const only = React13__namespace.default.Children.only(children);
|
|
3362
|
+
const isDomElement = React13__namespace.default.isValidElement(only) && typeof only.type === "string";
|
|
3080
3363
|
child = isDomElement ? only : (
|
|
3081
3364
|
// Ensure the wrapper reliably captures mouseenter/pointerenter and can contain block elements
|
|
3082
3365
|
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "inline-block" }, children: only })
|
|
@@ -3094,7 +3377,7 @@ function Tooltip(props) {
|
|
|
3094
3377
|
originalRef.current = node;
|
|
3095
3378
|
};
|
|
3096
3379
|
const refAttrs = referenceProps;
|
|
3097
|
-
const cloned =
|
|
3380
|
+
const cloned = React13__namespace.default.cloneElement(
|
|
3098
3381
|
child,
|
|
3099
3382
|
{
|
|
3100
3383
|
...refAttrs,
|
|
@@ -3103,11 +3386,11 @@ function Tooltip(props) {
|
|
|
3103
3386
|
}
|
|
3104
3387
|
);
|
|
3105
3388
|
if (disabled) return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: cloned });
|
|
3106
|
-
const [isMounted, setIsMounted] =
|
|
3107
|
-
const closeTimerRef =
|
|
3389
|
+
const [isMounted, setIsMounted] = React13__namespace.default.useState(false);
|
|
3390
|
+
const closeTimerRef = React13__namespace.default.useRef(
|
|
3108
3391
|
null
|
|
3109
3392
|
);
|
|
3110
|
-
|
|
3393
|
+
React13__namespace.default.useEffect(() => {
|
|
3111
3394
|
if (closeTimerRef.current) {
|
|
3112
3395
|
clearTimeout(closeTimerRef.current);
|
|
3113
3396
|
closeTimerRef.current = null;
|
|
@@ -3130,24 +3413,24 @@ function Tooltip(props) {
|
|
|
3130
3413
|
let arrowEl = null;
|
|
3131
3414
|
let floatingNode = null;
|
|
3132
3415
|
const findRoleTooltipElement = (node) => {
|
|
3133
|
-
if (!
|
|
3416
|
+
if (!React13__namespace.default.isValidElement(node)) return null;
|
|
3134
3417
|
const el = node;
|
|
3135
3418
|
if (el.props?.role === "tooltip") return el;
|
|
3136
3419
|
const kids = el.props?.children;
|
|
3137
3420
|
if (!kids) return null;
|
|
3138
|
-
const arr =
|
|
3421
|
+
const arr = React13__namespace.default.Children.toArray(kids);
|
|
3139
3422
|
for (const c of arr) {
|
|
3140
|
-
if (
|
|
3423
|
+
if (React13__namespace.default.isValidElement(c) && c.props?.role === "tooltip") {
|
|
3141
3424
|
return c;
|
|
3142
3425
|
}
|
|
3143
3426
|
}
|
|
3144
3427
|
return null;
|
|
3145
3428
|
};
|
|
3146
|
-
const isCustomTooltip =
|
|
3429
|
+
const isCustomTooltip = React13__namespace.default.isValidElement(content) && !!(content.type && content.type.isBlockTooltipContainer);
|
|
3147
3430
|
const customEl = isCustomTooltip ? content : findRoleTooltipElement(content);
|
|
3148
|
-
const containerRef =
|
|
3149
|
-
const [containerBg, setContainerBg] =
|
|
3150
|
-
|
|
3431
|
+
const containerRef = React13__namespace.default.useRef(null);
|
|
3432
|
+
const [containerBg, setContainerBg] = React13__namespace.default.useState();
|
|
3433
|
+
React13__namespace.default.useEffect(() => {
|
|
3151
3434
|
if (!(open || isMounted)) return;
|
|
3152
3435
|
const el = containerRef.current;
|
|
3153
3436
|
if (!el) return;
|
|
@@ -3255,7 +3538,7 @@ function Tooltip(props) {
|
|
|
3255
3538
|
else if (originalChildRef && typeof originalChildRef === "object")
|
|
3256
3539
|
originalChildRef.current = node;
|
|
3257
3540
|
};
|
|
3258
|
-
return
|
|
3541
|
+
return React13__namespace.default.cloneElement(
|
|
3259
3542
|
el,
|
|
3260
3543
|
{
|
|
3261
3544
|
// Spread childProps first
|
|
@@ -3352,12 +3635,12 @@ var Svg = motionTags.svg;
|
|
|
3352
3635
|
var CheckboxBtn = motionTags.button;
|
|
3353
3636
|
function Checkbox(props) {
|
|
3354
3637
|
const { children, onClick, ...rest } = props;
|
|
3355
|
-
const [checked, setChecked] =
|
|
3356
|
-
const [indeterminate, setIndeterminate] =
|
|
3357
|
-
|
|
3638
|
+
const [checked, setChecked] = React13__namespace.default.useState(false);
|
|
3639
|
+
const [indeterminate, setIndeterminate] = React13__namespace.default.useState(false);
|
|
3640
|
+
React13__namespace.default.useEffect(() => {
|
|
3358
3641
|
setChecked(!!rest.checked);
|
|
3359
3642
|
}, [rest.checked]);
|
|
3360
|
-
|
|
3643
|
+
React13__namespace.default.useEffect(() => {
|
|
3361
3644
|
setIndeterminate(!!rest.indeterminate);
|
|
3362
3645
|
}, [rest.indeterminate]);
|
|
3363
3646
|
const isIndeterminate = typeof rest.indeterminate === "boolean";
|
|
@@ -3449,14 +3732,14 @@ function Block(props) {
|
|
|
3449
3732
|
tooltip,
|
|
3450
3733
|
...rest
|
|
3451
3734
|
} = anyProps;
|
|
3452
|
-
const fileInputRef =
|
|
3735
|
+
const fileInputRef = React13__namespace.useRef(null);
|
|
3453
3736
|
const isLoading = anyProps.isLoading;
|
|
3454
3737
|
const multiple = anyProps.multiple;
|
|
3455
3738
|
const is = anyProps.is;
|
|
3456
3739
|
const extract = extractElType(is, anyProps);
|
|
3457
3740
|
const [Comp, initialStyles] = extractElAndStyles(extract, props);
|
|
3458
3741
|
const icons = getIcons(extract, props);
|
|
3459
|
-
let component = /* @__PURE__ */ jsxRuntime.jsx(framerMotion.MotionConfig, { transition: _motion, children: extract.isHr ? /* @__PURE__ */ jsxRuntime.jsx(Hr, { w: true, py: 2, color: "neutral.300", ...anyProps }) : extract.isProgress ? /* @__PURE__ */ jsxRuntime.jsx(Progress, { ...anyProps }) : extract.isDrawer ? /* @__PURE__ */ jsxRuntime.jsx(Drawer, { ...anyProps }) : extract.isAccordion ? /* @__PURE__ */ jsxRuntime.jsx(accordion_default, { ...anyProps }) : extract.isMenu ? /* @__PURE__ */ jsxRuntime.jsx(Menu, { ...anyProps }) : extract.isSwitch ? /* @__PURE__ */ jsxRuntime.jsx(switch_default, { ...anyProps }) : extract.isRadio ? /* @__PURE__ */ jsxRuntime.jsx(Radio, { ...anyProps }) : extract.isInput ? /* @__PURE__ */ jsxRuntime.jsx(Input, { ...anyProps }) : extract.isTextarea ? /* @__PURE__ */ jsxRuntime.jsx(Textarea, { ...anyProps }) : extract.isCheckbox ? /* @__PURE__ */ jsxRuntime.jsx(Checkbox, { ...anyProps }) : extract.isSkeleton ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3742
|
+
let component = /* @__PURE__ */ jsxRuntime.jsx(framerMotion.MotionConfig, { transition: _motion, children: extract.isHr ? /* @__PURE__ */ jsxRuntime.jsx(Hr, { w: true, py: 2, color: "neutral.300", ...anyProps }) : extract.isProgress ? /* @__PURE__ */ jsxRuntime.jsx(Progress, { ...anyProps }) : extract.isSlider ? /* @__PURE__ */ jsxRuntime.jsx(Slider, { ...anyProps }) : extract.isDrawer ? /* @__PURE__ */ jsxRuntime.jsx(Drawer, { ...anyProps }) : extract.isAccordion ? /* @__PURE__ */ jsxRuntime.jsx(accordion_default, { ...anyProps }) : extract.isMenu ? /* @__PURE__ */ jsxRuntime.jsx(Menu, { ...anyProps }) : extract.isSwitch ? /* @__PURE__ */ jsxRuntime.jsx(switch_default, { ...anyProps }) : extract.isRadio ? /* @__PURE__ */ jsxRuntime.jsx(Radio, { ...anyProps }) : extract.isInput ? /* @__PURE__ */ jsxRuntime.jsx(Input, { ...anyProps }) : extract.isTextarea ? /* @__PURE__ */ jsxRuntime.jsx(Textarea, { ...anyProps }) : extract.isCheckbox ? /* @__PURE__ */ jsxRuntime.jsx(Checkbox, { ...anyProps }) : extract.isSkeleton ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3460
3743
|
Skeleton,
|
|
3461
3744
|
{
|
|
3462
3745
|
...anyProps.as === "circle" ? { br: "50%", size: 40 } : {
|
|
@@ -3486,7 +3769,7 @@ function Block(props) {
|
|
|
3486
3769
|
...anyProps
|
|
3487
3770
|
}
|
|
3488
3771
|
) : extract.filepickerAllowed ? /* @__PURE__ */ jsxRuntime.jsxs("div", { onClick: () => fileInputRef.current?.click(), children: [
|
|
3489
|
-
|
|
3772
|
+
React13__namespace.createElement(
|
|
3490
3773
|
Comp,
|
|
3491
3774
|
{
|
|
3492
3775
|
cursor: "pointer",
|
|
@@ -3521,11 +3804,11 @@ function Block(props) {
|
|
|
3521
3804
|
value: ""
|
|
3522
3805
|
}
|
|
3523
3806
|
)
|
|
3524
|
-
] }) : extract.isVoidElement ?
|
|
3807
|
+
] }) : extract.isVoidElement ? React13__namespace.createElement(Comp, {
|
|
3525
3808
|
...isLoading && { "data-loading": isLoading },
|
|
3526
3809
|
onContextMenu: (e) => e.preventDefault(),
|
|
3527
3810
|
...initialStyles
|
|
3528
|
-
}) :
|
|
3811
|
+
}) : React13__namespace.createElement(
|
|
3529
3812
|
Comp,
|
|
3530
3813
|
{
|
|
3531
3814
|
...isLoading && { "data-loading": isLoading },
|
|
@@ -3581,9 +3864,15 @@ var ProgressNamespace = {
|
|
|
3581
3864
|
TrackFill,
|
|
3582
3865
|
TrackBg
|
|
3583
3866
|
};
|
|
3867
|
+
var SliderNamespace = {
|
|
3868
|
+
Track: SliderTrack,
|
|
3869
|
+
Fill: SliderFill,
|
|
3870
|
+
Thumb: SliderThumb
|
|
3871
|
+
};
|
|
3584
3872
|
var CompoundBlock = Object.assign(Block, {
|
|
3585
3873
|
Accordion: AccordionNamespace,
|
|
3586
3874
|
Progress: ProgressNamespace,
|
|
3875
|
+
Slider: SliderNamespace,
|
|
3587
3876
|
Textarea: TextareaNamespace,
|
|
3588
3877
|
Tooltip: TooltipNamespace,
|
|
3589
3878
|
Switch: SwitchNamespace,
|
|
@@ -3634,16 +3923,16 @@ var saveStore = (store) => {
|
|
|
3634
3923
|
|
|
3635
3924
|
// src/react/use-theme/index.ts
|
|
3636
3925
|
function useTheme() {
|
|
3637
|
-
const [store, setStore] =
|
|
3638
|
-
const storeRef =
|
|
3639
|
-
const isInternalUpdateRef =
|
|
3640
|
-
|
|
3926
|
+
const [store, setStore] = React13__namespace.default.useState(getInitialStore);
|
|
3927
|
+
const storeRef = React13__namespace.default.useRef(store);
|
|
3928
|
+
const isInternalUpdateRef = React13__namespace.default.useRef(false);
|
|
3929
|
+
React13__namespace.default.useEffect(() => {
|
|
3641
3930
|
storeRef.current = store;
|
|
3642
3931
|
}, [store]);
|
|
3643
|
-
|
|
3932
|
+
React13__namespace.default.useEffect(() => {
|
|
3644
3933
|
document.documentElement.setAttribute("data-theme", store.value);
|
|
3645
3934
|
}, [store.value]);
|
|
3646
|
-
|
|
3935
|
+
React13__namespace.default.useEffect(() => {
|
|
3647
3936
|
const handleStorageChange = (e) => {
|
|
3648
3937
|
if (e.key === THEME_STORAGE_KEY || e.key === THEME_STORE_STORAGE_KEY) {
|
|
3649
3938
|
setStore(getInitialStore());
|
|
@@ -3686,8 +3975,8 @@ function useTheme() {
|
|
|
3686
3975
|
|
|
3687
3976
|
// src/react/index.ts
|
|
3688
3977
|
function useDebounce(value, delay = 500) {
|
|
3689
|
-
const [debouncedValue, setDebouncedValue] =
|
|
3690
|
-
|
|
3978
|
+
const [debouncedValue, setDebouncedValue] = React13__namespace.default.useState(value);
|
|
3979
|
+
React13__namespace.default.useEffect(() => {
|
|
3691
3980
|
const handler = setTimeout(() => {
|
|
3692
3981
|
setDebouncedValue(value);
|
|
3693
3982
|
}, delay);
|
|
@@ -3698,10 +3987,10 @@ function useDebounce(value, delay = 500) {
|
|
|
3698
3987
|
return debouncedValue;
|
|
3699
3988
|
}
|
|
3700
3989
|
function useThrottle(value, interval = 500) {
|
|
3701
|
-
const [throttledValue, setThrottledValue] =
|
|
3702
|
-
const lastUpdate =
|
|
3703
|
-
const timeoutRef =
|
|
3704
|
-
|
|
3990
|
+
const [throttledValue, setThrottledValue] = React13__namespace.default.useState(value);
|
|
3991
|
+
const lastUpdate = React13__namespace.default.useRef(0);
|
|
3992
|
+
const timeoutRef = React13__namespace.default.useRef(null);
|
|
3993
|
+
React13__namespace.default.useEffect(() => {
|
|
3705
3994
|
const now = Date.now();
|
|
3706
3995
|
const timeSinceLastUpdate = now - lastUpdate.current;
|
|
3707
3996
|
if (timeSinceLastUpdate >= interval) {
|
|
@@ -3731,8 +4020,8 @@ function useMatchMedia2(queries, defaultValues = []) {
|
|
|
3731
4020
|
const matchedQueries = mediaQueryLists.map((mql) => mql.matches);
|
|
3732
4021
|
return matchedQueries;
|
|
3733
4022
|
};
|
|
3734
|
-
const [value, setValue] =
|
|
3735
|
-
|
|
4023
|
+
const [value, setValue] = React13__namespace.default.useState(getValue);
|
|
4024
|
+
React13__namespace.default.useLayoutEffect(() => {
|
|
3736
4025
|
const handler = () => setValue(getValue);
|
|
3737
4026
|
mediaQueryLists.forEach((mql) => mql.addListener(handler));
|
|
3738
4027
|
return () => mediaQueryLists.forEach((mql) => mql.removeListener(handler));
|