@nori-ui/core 1.7.0 → 1.8.0
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/chunk-BOMPFNM4.js +165 -0
- package/dist/chunk-BOMPFNM4.js.map +1 -0
- package/dist/chunk-BVLOX4A3.js +256 -0
- package/dist/chunk-BVLOX4A3.js.map +1 -0
- package/dist/chunk-VFUV6XJR.js +257 -0
- package/dist/chunk-VFUV6XJR.js.map +1 -0
- package/dist/client.cjs +650 -0
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +3 -0
- package/dist/client.d.ts +3 -0
- package/dist/client.js +14 -11
- package/dist/client.js.map +1 -1
- package/dist/components/Carousel/index.cjs +297 -0
- package/dist/components/Carousel/index.cjs.map +1 -0
- package/dist/components/Carousel/index.d.cts +67 -0
- package/dist/components/Carousel/index.d.ts +67 -0
- package/dist/components/Carousel/index.js +5 -0
- package/dist/components/Carousel/index.js.map +1 -0
- package/dist/components/HoverCard/index.cjs +894 -0
- package/dist/components/HoverCard/index.cjs.map +1 -0
- package/dist/components/HoverCard/index.d.cts +66 -0
- package/dist/components/HoverCard/index.d.ts +66 -0
- package/dist/components/HoverCard/index.js +9 -0
- package/dist/components/HoverCard/index.js.map +1 -0
- package/dist/components/InputOTP/index.cjs +580 -0
- package/dist/components/InputOTP/index.cjs.map +1 -0
- package/dist/components/InputOTP/index.d.cts +49 -0
- package/dist/components/InputOTP/index.d.ts +49 -0
- package/dist/components/InputOTP/index.js +7 -0
- package/dist/components/InputOTP/index.js.map +1 -0
- package/dist/index.cjs +650 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +14 -11
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -6489,6 +6489,254 @@ var Card = Object.assign(CardRoot, {
|
|
|
6489
6489
|
Content: CardContent,
|
|
6490
6490
|
Footer: CardFooter
|
|
6491
6491
|
});
|
|
6492
|
+
var CarouselContext = React.createContext(null);
|
|
6493
|
+
function useCarouselContext(caller) {
|
|
6494
|
+
const ctx = React.useContext(CarouselContext);
|
|
6495
|
+
if (!ctx) {
|
|
6496
|
+
throw new Error(`<${caller}> must be rendered inside <Carousel>.`);
|
|
6497
|
+
}
|
|
6498
|
+
return ctx;
|
|
6499
|
+
}
|
|
6500
|
+
__name(useCarouselContext, "useCarouselContext");
|
|
6501
|
+
var CarouselRoot = /* @__PURE__ */ __name(({
|
|
6502
|
+
index: controlledIndex,
|
|
6503
|
+
defaultIndex = 0,
|
|
6504
|
+
onIndexChange,
|
|
6505
|
+
loop = false,
|
|
6506
|
+
orientation = "horizontal",
|
|
6507
|
+
children,
|
|
6508
|
+
className,
|
|
6509
|
+
testID
|
|
6510
|
+
}) => {
|
|
6511
|
+
const [inner, setInner] = React.useState(defaultIndex);
|
|
6512
|
+
const isControlled = controlledIndex !== void 0;
|
|
6513
|
+
const index = isControlled ? controlledIndex : inner;
|
|
6514
|
+
const [count, setCount] = React.useState(0);
|
|
6515
|
+
const listRef = React.useRef(null);
|
|
6516
|
+
const id = React.useId();
|
|
6517
|
+
const setIndex = React.useCallback(
|
|
6518
|
+
(next2) => {
|
|
6519
|
+
if (!isControlled) {
|
|
6520
|
+
setInner(next2);
|
|
6521
|
+
}
|
|
6522
|
+
onIndexChange?.(next2);
|
|
6523
|
+
},
|
|
6524
|
+
[isControlled, onIndexChange]
|
|
6525
|
+
);
|
|
6526
|
+
const scrollTo = React.useCallback(
|
|
6527
|
+
(idx) => {
|
|
6528
|
+
const list = listRef.current;
|
|
6529
|
+
if (!list) {
|
|
6530
|
+
return;
|
|
6531
|
+
}
|
|
6532
|
+
const item = list.children[idx];
|
|
6533
|
+
if (!item) {
|
|
6534
|
+
return;
|
|
6535
|
+
}
|
|
6536
|
+
item.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "nearest" });
|
|
6537
|
+
setIndex(idx);
|
|
6538
|
+
},
|
|
6539
|
+
[setIndex]
|
|
6540
|
+
);
|
|
6541
|
+
const next = React.useCallback(() => {
|
|
6542
|
+
if (count === 0) {
|
|
6543
|
+
return;
|
|
6544
|
+
}
|
|
6545
|
+
if (index < count - 1) {
|
|
6546
|
+
scrollTo(index + 1);
|
|
6547
|
+
} else if (loop) {
|
|
6548
|
+
scrollTo(0);
|
|
6549
|
+
}
|
|
6550
|
+
}, [index, count, loop, scrollTo]);
|
|
6551
|
+
const prev = React.useCallback(() => {
|
|
6552
|
+
if (count === 0) {
|
|
6553
|
+
return;
|
|
6554
|
+
}
|
|
6555
|
+
if (index > 0) {
|
|
6556
|
+
scrollTo(index - 1);
|
|
6557
|
+
} else if (loop) {
|
|
6558
|
+
scrollTo(count - 1);
|
|
6559
|
+
}
|
|
6560
|
+
}, [index, count, loop, scrollTo]);
|
|
6561
|
+
React.useEffect(() => {
|
|
6562
|
+
const list = listRef.current;
|
|
6563
|
+
if (!list) {
|
|
6564
|
+
return;
|
|
6565
|
+
}
|
|
6566
|
+
const handleScroll = /* @__PURE__ */ __name(() => {
|
|
6567
|
+
const { scrollLeft, scrollTop, offsetWidth, offsetHeight } = list;
|
|
6568
|
+
const pos = orientation === "horizontal" ? scrollLeft : scrollTop;
|
|
6569
|
+
const size = orientation === "horizontal" ? offsetWidth : offsetHeight;
|
|
6570
|
+
if (size === 0) {
|
|
6571
|
+
return;
|
|
6572
|
+
}
|
|
6573
|
+
const newIdx = Math.round(pos / size);
|
|
6574
|
+
if (newIdx !== index) {
|
|
6575
|
+
setIndex(newIdx);
|
|
6576
|
+
}
|
|
6577
|
+
}, "handleScroll");
|
|
6578
|
+
list.addEventListener("scroll", handleScroll, { passive: true });
|
|
6579
|
+
return () => list.removeEventListener("scroll", handleScroll);
|
|
6580
|
+
}, [orientation, index, setIndex]);
|
|
6581
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6582
|
+
CarouselContext.Provider,
|
|
6583
|
+
{
|
|
6584
|
+
value: { index, count, loop, orientation, scrollTo, next, prev, listRef, setCount, id },
|
|
6585
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
6586
|
+
"section",
|
|
6587
|
+
{
|
|
6588
|
+
"aria-label": testID ?? "Carousel",
|
|
6589
|
+
className: cn("relative overflow-hidden", className),
|
|
6590
|
+
"data-testid": testID,
|
|
6591
|
+
children
|
|
6592
|
+
}
|
|
6593
|
+
)
|
|
6594
|
+
}
|
|
6595
|
+
);
|
|
6596
|
+
}, "CarouselRoot");
|
|
6597
|
+
var CarouselContent = /* @__PURE__ */ __name(({ children, className, testID }) => {
|
|
6598
|
+
const ctx = useCarouselContext("Carousel.Content");
|
|
6599
|
+
const childCount = React.Children.count(children);
|
|
6600
|
+
React.useEffect(() => {
|
|
6601
|
+
ctx.setCount(childCount);
|
|
6602
|
+
}, [childCount, ctx.setCount]);
|
|
6603
|
+
const isHorizontal = ctx.orientation === "horizontal";
|
|
6604
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6605
|
+
"div",
|
|
6606
|
+
{
|
|
6607
|
+
ref: ctx.listRef,
|
|
6608
|
+
"data-testid": testID,
|
|
6609
|
+
className: cn(
|
|
6610
|
+
"flex",
|
|
6611
|
+
isHorizontal ? "flex-row overflow-x-auto overflow-y-hidden" : "flex-col overflow-y-auto overflow-x-hidden",
|
|
6612
|
+
className
|
|
6613
|
+
),
|
|
6614
|
+
style: {
|
|
6615
|
+
scrollSnapType: isHorizontal ? "x mandatory" : "y mandatory",
|
|
6616
|
+
scrollBehavior: "smooth",
|
|
6617
|
+
WebkitOverflowScrolling: "touch",
|
|
6618
|
+
// Hide scrollbar
|
|
6619
|
+
scrollbarWidth: "none",
|
|
6620
|
+
msOverflowStyle: "none"
|
|
6621
|
+
},
|
|
6622
|
+
children
|
|
6623
|
+
}
|
|
6624
|
+
);
|
|
6625
|
+
}, "CarouselContent");
|
|
6626
|
+
var CarouselItem = /* @__PURE__ */ __name(({ children, className, testID }) => {
|
|
6627
|
+
const ctx = useCarouselContext("Carousel.Item");
|
|
6628
|
+
const isHorizontal = ctx.orientation === "horizontal";
|
|
6629
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6630
|
+
"div",
|
|
6631
|
+
{
|
|
6632
|
+
"data-testid": testID,
|
|
6633
|
+
className: cn("shrink-0", isHorizontal ? "w-full" : "h-full", className),
|
|
6634
|
+
style: {
|
|
6635
|
+
scrollSnapAlign: "start",
|
|
6636
|
+
minWidth: isHorizontal ? "100%" : void 0,
|
|
6637
|
+
minHeight: !isHorizontal ? "100%" : void 0
|
|
6638
|
+
},
|
|
6639
|
+
children
|
|
6640
|
+
}
|
|
6641
|
+
);
|
|
6642
|
+
}, "CarouselItem");
|
|
6643
|
+
var CarouselPrevious = /* @__PURE__ */ __name(({ className, testID, children }) => {
|
|
6644
|
+
const ctx = useCarouselContext("Carousel.Previous");
|
|
6645
|
+
const disabled = !ctx.loop && ctx.index === 0;
|
|
6646
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6647
|
+
"button",
|
|
6648
|
+
{
|
|
6649
|
+
type: "button",
|
|
6650
|
+
"aria-label": "Previous slide",
|
|
6651
|
+
disabled,
|
|
6652
|
+
"data-testid": testID,
|
|
6653
|
+
onClick: ctx.prev,
|
|
6654
|
+
className: cn(
|
|
6655
|
+
"absolute left-2 top-1/2 z-10 flex h-8 w-8 -translate-y-1/2 items-center justify-center rounded-full bg-white/80 shadow hover:bg-white disabled:opacity-40",
|
|
6656
|
+
className
|
|
6657
|
+
),
|
|
6658
|
+
children: children ?? /* @__PURE__ */ jsxRuntime.jsx(
|
|
6659
|
+
"svg",
|
|
6660
|
+
{
|
|
6661
|
+
viewBox: "0 0 24 24",
|
|
6662
|
+
fill: "none",
|
|
6663
|
+
stroke: "currentColor",
|
|
6664
|
+
strokeWidth: 2,
|
|
6665
|
+
className: "h-4 w-4",
|
|
6666
|
+
"aria-hidden": "true",
|
|
6667
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M15 18l-6-6 6-6", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
6668
|
+
}
|
|
6669
|
+
)
|
|
6670
|
+
}
|
|
6671
|
+
);
|
|
6672
|
+
}, "CarouselPrevious");
|
|
6673
|
+
var CarouselNext = /* @__PURE__ */ __name(({ className, testID, children }) => {
|
|
6674
|
+
const ctx = useCarouselContext("Carousel.Next");
|
|
6675
|
+
const disabled = !ctx.loop && ctx.index >= ctx.count - 1;
|
|
6676
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6677
|
+
"button",
|
|
6678
|
+
{
|
|
6679
|
+
type: "button",
|
|
6680
|
+
"aria-label": "Next slide",
|
|
6681
|
+
disabled,
|
|
6682
|
+
"data-testid": testID,
|
|
6683
|
+
onClick: ctx.next,
|
|
6684
|
+
className: cn(
|
|
6685
|
+
"absolute right-2 top-1/2 z-10 flex h-8 w-8 -translate-y-1/2 items-center justify-center rounded-full bg-white/80 shadow hover:bg-white disabled:opacity-40",
|
|
6686
|
+
className
|
|
6687
|
+
),
|
|
6688
|
+
children: children ?? /* @__PURE__ */ jsxRuntime.jsx(
|
|
6689
|
+
"svg",
|
|
6690
|
+
{
|
|
6691
|
+
viewBox: "0 0 24 24",
|
|
6692
|
+
fill: "none",
|
|
6693
|
+
stroke: "currentColor",
|
|
6694
|
+
strokeWidth: 2,
|
|
6695
|
+
className: "h-4 w-4",
|
|
6696
|
+
"aria-hidden": "true",
|
|
6697
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M9 18l6-6-6-6", strokeLinecap: "round", strokeLinejoin: "round" })
|
|
6698
|
+
}
|
|
6699
|
+
)
|
|
6700
|
+
}
|
|
6701
|
+
);
|
|
6702
|
+
}, "CarouselNext");
|
|
6703
|
+
var CarouselDots = /* @__PURE__ */ __name(({ className, testID }) => {
|
|
6704
|
+
const ctx = useCarouselContext("Carousel.Dots");
|
|
6705
|
+
if (ctx.count === 0) {
|
|
6706
|
+
return null;
|
|
6707
|
+
}
|
|
6708
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
6709
|
+
"div",
|
|
6710
|
+
{
|
|
6711
|
+
role: "tablist",
|
|
6712
|
+
"aria-label": "Slide navigation",
|
|
6713
|
+
"data-testid": testID,
|
|
6714
|
+
className: cn("absolute bottom-3 left-0 right-0 flex items-center justify-center gap-1.5", className),
|
|
6715
|
+
children: Array.from({ length: ctx.count }, (_, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
6716
|
+
"button",
|
|
6717
|
+
{
|
|
6718
|
+
type: "button",
|
|
6719
|
+
role: "tab",
|
|
6720
|
+
"aria-selected": i === ctx.index,
|
|
6721
|
+
"aria-label": `Go to slide ${i + 1}`,
|
|
6722
|
+
onClick: () => ctx.scrollTo(i),
|
|
6723
|
+
className: cn(
|
|
6724
|
+
"h-1.5 w-1.5 rounded-full transition-all",
|
|
6725
|
+
i === ctx.index ? "w-3 bg-white" : "bg-white/50 hover:bg-white/75"
|
|
6726
|
+
)
|
|
6727
|
+
},
|
|
6728
|
+
i
|
|
6729
|
+
))
|
|
6730
|
+
}
|
|
6731
|
+
);
|
|
6732
|
+
}, "CarouselDots");
|
|
6733
|
+
var Carousel = Object.assign(CarouselRoot, {
|
|
6734
|
+
Content: CarouselContent,
|
|
6735
|
+
Item: CarouselItem,
|
|
6736
|
+
Previous: CarouselPrevious,
|
|
6737
|
+
Next: CarouselNext,
|
|
6738
|
+
Dots: CarouselDots
|
|
6739
|
+
});
|
|
6492
6740
|
var SemanticIconsContext = React.createContext(defaultSemanticIcons);
|
|
6493
6741
|
SemanticIconsContext.displayName = "SemanticIconsContext";
|
|
6494
6742
|
|
|
@@ -9377,6 +9625,161 @@ function withAlpha(color, alpha) {
|
|
|
9377
9625
|
return color;
|
|
9378
9626
|
}
|
|
9379
9627
|
__name(withAlpha, "withAlpha");
|
|
9628
|
+
var HoverCardContext = React.createContext(null);
|
|
9629
|
+
function useHoverCardContext(caller) {
|
|
9630
|
+
const ctx = React.useContext(HoverCardContext);
|
|
9631
|
+
if (!ctx) {
|
|
9632
|
+
throw new Error(`<${caller}> must be rendered inside <HoverCard>.`);
|
|
9633
|
+
}
|
|
9634
|
+
return ctx;
|
|
9635
|
+
}
|
|
9636
|
+
__name(useHoverCardContext, "useHoverCardContext");
|
|
9637
|
+
var DEFAULT_OPEN_DELAY = 300;
|
|
9638
|
+
var DEFAULT_CLOSE_DELAY = 200;
|
|
9639
|
+
var HoverCardRoot = /* @__PURE__ */ __name(({
|
|
9640
|
+
open: controlledOpen,
|
|
9641
|
+
defaultOpen = false,
|
|
9642
|
+
onOpenChange,
|
|
9643
|
+
openDelay = DEFAULT_OPEN_DELAY,
|
|
9644
|
+
closeDelay = DEFAULT_CLOSE_DELAY,
|
|
9645
|
+
children
|
|
9646
|
+
}) => {
|
|
9647
|
+
const [inner, setInner] = React.useState(defaultOpen);
|
|
9648
|
+
const isControlled = controlledOpen !== void 0;
|
|
9649
|
+
const open = isControlled ? controlledOpen : inner;
|
|
9650
|
+
const id = React.useId();
|
|
9651
|
+
const setOpen = React.useCallback(
|
|
9652
|
+
(next) => {
|
|
9653
|
+
if (!isControlled) {
|
|
9654
|
+
setInner(next);
|
|
9655
|
+
}
|
|
9656
|
+
onOpenChange?.(next);
|
|
9657
|
+
},
|
|
9658
|
+
[isControlled, onOpenChange]
|
|
9659
|
+
);
|
|
9660
|
+
const openTimer = React.useRef(null);
|
|
9661
|
+
const closeTimer = React.useRef(null);
|
|
9662
|
+
const cancelTimers = React.useCallback(() => {
|
|
9663
|
+
if (openTimer.current) {
|
|
9664
|
+
clearTimeout(openTimer.current);
|
|
9665
|
+
openTimer.current = null;
|
|
9666
|
+
}
|
|
9667
|
+
if (closeTimer.current) {
|
|
9668
|
+
clearTimeout(closeTimer.current);
|
|
9669
|
+
closeTimer.current = null;
|
|
9670
|
+
}
|
|
9671
|
+
}, []);
|
|
9672
|
+
const requestOpen = React.useCallback(() => {
|
|
9673
|
+
if (closeTimer.current) {
|
|
9674
|
+
clearTimeout(closeTimer.current);
|
|
9675
|
+
closeTimer.current = null;
|
|
9676
|
+
}
|
|
9677
|
+
if (openTimer.current) {
|
|
9678
|
+
return;
|
|
9679
|
+
}
|
|
9680
|
+
if (openDelay <= 0) {
|
|
9681
|
+
setOpen(true);
|
|
9682
|
+
return;
|
|
9683
|
+
}
|
|
9684
|
+
openTimer.current = setTimeout(() => {
|
|
9685
|
+
openTimer.current = null;
|
|
9686
|
+
setOpen(true);
|
|
9687
|
+
}, openDelay);
|
|
9688
|
+
}, [openDelay, setOpen]);
|
|
9689
|
+
const requestClose = React.useCallback(() => {
|
|
9690
|
+
if (openTimer.current) {
|
|
9691
|
+
clearTimeout(openTimer.current);
|
|
9692
|
+
openTimer.current = null;
|
|
9693
|
+
}
|
|
9694
|
+
if (closeTimer.current) {
|
|
9695
|
+
return;
|
|
9696
|
+
}
|
|
9697
|
+
if (closeDelay <= 0) {
|
|
9698
|
+
setOpen(false);
|
|
9699
|
+
return;
|
|
9700
|
+
}
|
|
9701
|
+
closeTimer.current = setTimeout(() => {
|
|
9702
|
+
closeTimer.current = null;
|
|
9703
|
+
setOpen(false);
|
|
9704
|
+
}, closeDelay);
|
|
9705
|
+
}, [closeDelay, setOpen]);
|
|
9706
|
+
React.useEffect(() => () => cancelTimers(), [cancelTimers]);
|
|
9707
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
9708
|
+
HoverCardContext.Provider,
|
|
9709
|
+
{
|
|
9710
|
+
value: { open, requestOpen, requestClose, cancelTimers, contentId: `hc-content-${id}` },
|
|
9711
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Popover, { open, onOpenChange: setOpen, children })
|
|
9712
|
+
}
|
|
9713
|
+
);
|
|
9714
|
+
}, "HoverCardRoot");
|
|
9715
|
+
var HoverCardTrigger = /* @__PURE__ */ __name(({ asChild = true, children, className, testID }) => {
|
|
9716
|
+
const ctx = useHoverCardContext("HoverCard.Trigger");
|
|
9717
|
+
const handleMouseEnter = React.useCallback(() => {
|
|
9718
|
+
ctx.cancelTimers();
|
|
9719
|
+
ctx.requestOpen();
|
|
9720
|
+
}, [ctx]);
|
|
9721
|
+
const handleMouseLeave = React.useCallback(() => {
|
|
9722
|
+
ctx.requestClose();
|
|
9723
|
+
}, [ctx]);
|
|
9724
|
+
const handlers = {
|
|
9725
|
+
onMouseEnter: handleMouseEnter,
|
|
9726
|
+
onMouseLeave: handleMouseLeave,
|
|
9727
|
+
"aria-haspopup": "dialog",
|
|
9728
|
+
"aria-expanded": ctx.open
|
|
9729
|
+
};
|
|
9730
|
+
if (asChild && React.isValidElement(children)) {
|
|
9731
|
+
const child = children;
|
|
9732
|
+
const compose = /* @__PURE__ */ __name((existing, next) => (event) => {
|
|
9733
|
+
existing?.(event);
|
|
9734
|
+
next(event);
|
|
9735
|
+
}, "compose");
|
|
9736
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
9737
|
+
Slot,
|
|
9738
|
+
{
|
|
9739
|
+
...handlers,
|
|
9740
|
+
onMouseEnter: compose(child.props.onMouseEnter, handleMouseEnter),
|
|
9741
|
+
onMouseLeave: compose(child.props.onMouseLeave, handleMouseLeave),
|
|
9742
|
+
...className !== void 0 ? { className } : {},
|
|
9743
|
+
...testID !== void 0 ? { "data-testid": testID } : {},
|
|
9744
|
+
children: child
|
|
9745
|
+
}
|
|
9746
|
+
);
|
|
9747
|
+
}
|
|
9748
|
+
return /* @__PURE__ */ jsxRuntime.jsx("span", { ...handlers, className, ...testID !== void 0 ? { "data-testid": testID } : {}, children });
|
|
9749
|
+
}, "HoverCardTrigger");
|
|
9750
|
+
var HoverCardContent = /* @__PURE__ */ __name(({ side = "bottom", align = "start", children, className, testID }) => {
|
|
9751
|
+
const ctx = useHoverCardContext("HoverCard.Content");
|
|
9752
|
+
const handleMouseEnter = React.useCallback(() => {
|
|
9753
|
+
ctx.cancelTimers();
|
|
9754
|
+
}, [ctx]);
|
|
9755
|
+
const handleMouseLeave = React.useCallback(() => {
|
|
9756
|
+
ctx.requestClose();
|
|
9757
|
+
}, [ctx]);
|
|
9758
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
9759
|
+
Popover.Content,
|
|
9760
|
+
{
|
|
9761
|
+
side,
|
|
9762
|
+
align,
|
|
9763
|
+
...className !== void 0 ? { className } : {},
|
|
9764
|
+
...testID !== void 0 ? { testID } : {},
|
|
9765
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
9766
|
+
"div",
|
|
9767
|
+
{
|
|
9768
|
+
id: ctx.contentId,
|
|
9769
|
+
role: "dialog",
|
|
9770
|
+
"aria-label": "Hover card",
|
|
9771
|
+
onMouseEnter: handleMouseEnter,
|
|
9772
|
+
onMouseLeave: handleMouseLeave,
|
|
9773
|
+
children
|
|
9774
|
+
}
|
|
9775
|
+
)
|
|
9776
|
+
}
|
|
9777
|
+
);
|
|
9778
|
+
}, "HoverCardContent");
|
|
9779
|
+
var HoverCard = Object.assign(HoverCardRoot, {
|
|
9780
|
+
Trigger: HoverCardTrigger,
|
|
9781
|
+
Content: HoverCardContent
|
|
9782
|
+
});
|
|
9380
9783
|
var ALIGN_CLASS = {
|
|
9381
9784
|
start: "items-start",
|
|
9382
9785
|
center: "items-center",
|
|
@@ -9749,6 +10152,250 @@ var InputGroup = Object.assign(InputGroupRoot, {
|
|
|
9749
10152
|
Addon: InputGroupAddon,
|
|
9750
10153
|
Input: InputGroupInput
|
|
9751
10154
|
});
|
|
10155
|
+
function isAllowed(char, pattern) {
|
|
10156
|
+
if (pattern === "numeric") {
|
|
10157
|
+
return /^\d$/.test(char);
|
|
10158
|
+
}
|
|
10159
|
+
return /^[a-zA-Z0-9]$/.test(char);
|
|
10160
|
+
}
|
|
10161
|
+
__name(isAllowed, "isAllowed");
|
|
10162
|
+
function filterValue(value, pattern, length) {
|
|
10163
|
+
return value.split("").filter((c) => isAllowed(c, pattern)).slice(0, length).join("");
|
|
10164
|
+
}
|
|
10165
|
+
__name(filterValue, "filterValue");
|
|
10166
|
+
var InputOTP = /* @__PURE__ */ __name(({
|
|
10167
|
+
value = "",
|
|
10168
|
+
onChange,
|
|
10169
|
+
onComplete,
|
|
10170
|
+
length = 6,
|
|
10171
|
+
placeholder = "\xB7",
|
|
10172
|
+
pattern = "numeric",
|
|
10173
|
+
disabled = false,
|
|
10174
|
+
autoFocus = false,
|
|
10175
|
+
id,
|
|
10176
|
+
name,
|
|
10177
|
+
"aria-label": ariaLabel = "One-time code",
|
|
10178
|
+
"aria-labelledby": ariaLabelledBy,
|
|
10179
|
+
"aria-describedby": ariaDescribedBy,
|
|
10180
|
+
"aria-invalid": ariaInvalid,
|
|
10181
|
+
className,
|
|
10182
|
+
testID
|
|
10183
|
+
}) => {
|
|
10184
|
+
const colors = useThemeColors();
|
|
10185
|
+
const [cells, setCells] = React.useState(() => {
|
|
10186
|
+
const filtered = filterValue(value, pattern, length);
|
|
10187
|
+
return Array.from({ length }, (_, i) => filtered[i] ?? "");
|
|
10188
|
+
});
|
|
10189
|
+
const prevValue = React.useRef(value);
|
|
10190
|
+
React.useEffect(() => {
|
|
10191
|
+
if (value !== prevValue.current) {
|
|
10192
|
+
prevValue.current = value;
|
|
10193
|
+
const filtered = filterValue(value, pattern, length);
|
|
10194
|
+
setCells(Array.from({ length }, (_, i) => filtered[i] ?? ""));
|
|
10195
|
+
}
|
|
10196
|
+
}, [value, pattern, length]);
|
|
10197
|
+
const inputRefs = React.useRef([]);
|
|
10198
|
+
const focusCell = React.useCallback(
|
|
10199
|
+
(idx) => {
|
|
10200
|
+
if (idx >= 0 && idx < length) {
|
|
10201
|
+
inputRefs.current[idx]?.focus();
|
|
10202
|
+
}
|
|
10203
|
+
},
|
|
10204
|
+
[length]
|
|
10205
|
+
);
|
|
10206
|
+
const updateCells = React.useCallback(
|
|
10207
|
+
(next) => {
|
|
10208
|
+
setCells(next);
|
|
10209
|
+
const joined = next.join("");
|
|
10210
|
+
onChange?.(joined);
|
|
10211
|
+
if (joined.length === length && !next.includes("")) {
|
|
10212
|
+
onComplete?.(joined);
|
|
10213
|
+
}
|
|
10214
|
+
},
|
|
10215
|
+
[onChange, onComplete, length]
|
|
10216
|
+
);
|
|
10217
|
+
const onContainerPaste = React.useCallback(
|
|
10218
|
+
(e) => {
|
|
10219
|
+
e.preventDefault();
|
|
10220
|
+
const text = e.clipboardData.getData("text/plain") ?? "";
|
|
10221
|
+
const filtered = filterValue(text, pattern, length);
|
|
10222
|
+
const next = Array.from({ length }, (_, i) => filtered[i] ?? "");
|
|
10223
|
+
updateCells(next);
|
|
10224
|
+
const nextEmpty = next.indexOf("");
|
|
10225
|
+
focusCell(nextEmpty === -1 ? length - 1 : nextEmpty);
|
|
10226
|
+
},
|
|
10227
|
+
[pattern, length, updateCells, focusCell]
|
|
10228
|
+
);
|
|
10229
|
+
const handleChangeText = React.useCallback(
|
|
10230
|
+
(text, idx) => {
|
|
10231
|
+
if (text.length > 1) {
|
|
10232
|
+
const filtered = filterValue(text, pattern, length);
|
|
10233
|
+
const next2 = Array.from({ length }, (_, i) => filtered[i] ?? "");
|
|
10234
|
+
updateCells(next2);
|
|
10235
|
+
const nextEmpty = next2.indexOf("");
|
|
10236
|
+
focusCell(nextEmpty === -1 ? length - 1 : nextEmpty);
|
|
10237
|
+
return;
|
|
10238
|
+
}
|
|
10239
|
+
const char = text.slice(-1);
|
|
10240
|
+
if (char && !isAllowed(char, pattern)) {
|
|
10241
|
+
return;
|
|
10242
|
+
}
|
|
10243
|
+
const next = [...cells];
|
|
10244
|
+
next[idx] = char;
|
|
10245
|
+
updateCells(next);
|
|
10246
|
+
if (char) {
|
|
10247
|
+
focusCell(idx + 1);
|
|
10248
|
+
}
|
|
10249
|
+
},
|
|
10250
|
+
[cells, pattern, length, updateCells, focusCell]
|
|
10251
|
+
);
|
|
10252
|
+
const handleWebKeyDown = React.useCallback(
|
|
10253
|
+
(e, idx) => {
|
|
10254
|
+
if (e.key === "Backspace") {
|
|
10255
|
+
if (cells[idx] !== "") {
|
|
10256
|
+
const next = [...cells];
|
|
10257
|
+
next[idx] = "";
|
|
10258
|
+
updateCells(next);
|
|
10259
|
+
} else {
|
|
10260
|
+
focusCell(idx - 1);
|
|
10261
|
+
}
|
|
10262
|
+
e.preventDefault();
|
|
10263
|
+
} else if (e.key === "ArrowLeft") {
|
|
10264
|
+
focusCell(idx - 1);
|
|
10265
|
+
e.preventDefault();
|
|
10266
|
+
} else if (e.key === "ArrowRight") {
|
|
10267
|
+
focusCell(idx + 1);
|
|
10268
|
+
e.preventDefault();
|
|
10269
|
+
} else if (e.key.length === 1 && isAllowed(e.key, pattern)) {
|
|
10270
|
+
const next = [...cells];
|
|
10271
|
+
next[idx] = e.key;
|
|
10272
|
+
updateCells(next);
|
|
10273
|
+
focusCell(idx + 1);
|
|
10274
|
+
e.preventDefault();
|
|
10275
|
+
}
|
|
10276
|
+
},
|
|
10277
|
+
[cells, pattern, focusCell, updateCells]
|
|
10278
|
+
);
|
|
10279
|
+
const handleNativeKeyPress = React.useCallback(
|
|
10280
|
+
(e, idx) => {
|
|
10281
|
+
if (e.nativeEvent.key === "Backspace") {
|
|
10282
|
+
if (cells[idx] !== "") {
|
|
10283
|
+
const next = [...cells];
|
|
10284
|
+
next[idx] = "";
|
|
10285
|
+
updateCells(next);
|
|
10286
|
+
} else {
|
|
10287
|
+
focusCell(idx - 1);
|
|
10288
|
+
}
|
|
10289
|
+
}
|
|
10290
|
+
},
|
|
10291
|
+
[cells, focusCell, updateCells]
|
|
10292
|
+
);
|
|
10293
|
+
const cellStyle = [
|
|
10294
|
+
styles2.cell,
|
|
10295
|
+
{
|
|
10296
|
+
width: px(48),
|
|
10297
|
+
height: px(56),
|
|
10298
|
+
borderRadius: px(colors.radius.md),
|
|
10299
|
+
borderColor: colors.semantic.border.default,
|
|
10300
|
+
backgroundColor: colors.semantic.background.elevated,
|
|
10301
|
+
color: colors.semantic.text.default,
|
|
10302
|
+
fontSize: px(colors.fontSize.xl),
|
|
10303
|
+
fontFamily: colors.fontFamily.body
|
|
10304
|
+
},
|
|
10305
|
+
disabled ? styles2.disabled : null,
|
|
10306
|
+
ariaInvalid === true || ariaInvalid === "true" ? { borderColor: colors.color.danger } : null
|
|
10307
|
+
];
|
|
10308
|
+
const isWeb3 = reactNative.Platform.OS === "web";
|
|
10309
|
+
const containerProps = isWeb3 ? {
|
|
10310
|
+
onPaste: onContainerPaste,
|
|
10311
|
+
role: "group",
|
|
10312
|
+
"aria-label": ariaLabel,
|
|
10313
|
+
"aria-labelledby": ariaLabelledBy,
|
|
10314
|
+
"aria-describedby": ariaDescribedBy
|
|
10315
|
+
} : {};
|
|
10316
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
10317
|
+
reactNative.View,
|
|
10318
|
+
{
|
|
10319
|
+
testID,
|
|
10320
|
+
...isWeb3 ? {} : { accessible: true, accessibilityLabel: ariaLabel },
|
|
10321
|
+
...containerProps,
|
|
10322
|
+
className: cn("flex-row items-center gap-2", className),
|
|
10323
|
+
style: styles2.container,
|
|
10324
|
+
children: [
|
|
10325
|
+
Array.from({ length }, (_, idx) => {
|
|
10326
|
+
const cellValue = cells[idx] ?? "";
|
|
10327
|
+
const cellRef = /* @__PURE__ */ __name((el) => {
|
|
10328
|
+
inputRefs.current[idx] = el;
|
|
10329
|
+
}, "cellRef");
|
|
10330
|
+
const webProps = isWeb3 ? {
|
|
10331
|
+
onKeyDown: /* @__PURE__ */ __name((e) => handleWebKeyDown(e, idx), "onKeyDown"),
|
|
10332
|
+
// id only on the first cell
|
|
10333
|
+
...idx === 0 && id ? { id, nativeID: id } : {},
|
|
10334
|
+
...idx === 0 && name ? { name } : {},
|
|
10335
|
+
...idx === 0 && ariaLabelledBy ? { "aria-labelledby": ariaLabelledBy } : {},
|
|
10336
|
+
...idx === 0 && ariaDescribedBy ? { "aria-describedby": ariaDescribedBy } : {},
|
|
10337
|
+
...idx === 0 && ariaInvalid !== void 0 ? { "aria-invalid": ariaInvalid } : {},
|
|
10338
|
+
inputMode: pattern === "numeric" ? "numeric" : "text"
|
|
10339
|
+
} : {};
|
|
10340
|
+
const nativeOnlyProps = isWeb3 ? {} : {
|
|
10341
|
+
keyboardType: pattern === "numeric" ? "number-pad" : "default",
|
|
10342
|
+
textAlign: "center",
|
|
10343
|
+
selectTextOnFocus: true,
|
|
10344
|
+
onKeyPress: /* @__PURE__ */ __name((e) => handleNativeKeyPress(e, idx), "onKeyPress")
|
|
10345
|
+
};
|
|
10346
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
10347
|
+
reactNative.TextInput,
|
|
10348
|
+
{
|
|
10349
|
+
ref: cellRef,
|
|
10350
|
+
value: cellValue,
|
|
10351
|
+
placeholder: placeholder,
|
|
10352
|
+
maxLength: 1,
|
|
10353
|
+
editable: !disabled,
|
|
10354
|
+
autoFocus: autoFocus && idx === 0,
|
|
10355
|
+
testID: testID ? `${testID}-cell-${idx}` : void 0,
|
|
10356
|
+
onChangeText: (text) => handleChangeText(text, idx),
|
|
10357
|
+
accessibilityLabel: `Digit ${idx + 1} of ${length}`,
|
|
10358
|
+
...nativeOnlyProps,
|
|
10359
|
+
...webProps,
|
|
10360
|
+
style: cellStyle
|
|
10361
|
+
},
|
|
10362
|
+
idx
|
|
10363
|
+
);
|
|
10364
|
+
}),
|
|
10365
|
+
isWeb3 && name ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
10366
|
+
reactNative.TextInput,
|
|
10367
|
+
{
|
|
10368
|
+
style: styles2.hidden,
|
|
10369
|
+
value: cells.join(""),
|
|
10370
|
+
"aria-hidden": true,
|
|
10371
|
+
tabIndex: -1,
|
|
10372
|
+
...{ name }
|
|
10373
|
+
}
|
|
10374
|
+
) : null
|
|
10375
|
+
]
|
|
10376
|
+
}
|
|
10377
|
+
);
|
|
10378
|
+
}, "InputOTP");
|
|
10379
|
+
var styles2 = reactNative.StyleSheet.create({
|
|
10380
|
+
container: {
|
|
10381
|
+
flexDirection: "row",
|
|
10382
|
+
alignItems: "center",
|
|
10383
|
+
gap: 8
|
|
10384
|
+
},
|
|
10385
|
+
cell: {
|
|
10386
|
+
borderWidth: 1,
|
|
10387
|
+
textAlign: "center"
|
|
10388
|
+
},
|
|
10389
|
+
disabled: {
|
|
10390
|
+
opacity: 0.6
|
|
10391
|
+
},
|
|
10392
|
+
hidden: {
|
|
10393
|
+
position: "absolute",
|
|
10394
|
+
width: 0,
|
|
10395
|
+
height: 0,
|
|
10396
|
+
opacity: 0
|
|
10397
|
+
}
|
|
10398
|
+
});
|
|
9752
10399
|
var Item = /* @__PURE__ */ __name(({
|
|
9753
10400
|
leading,
|
|
9754
10401
|
title,
|
|
@@ -14077,6 +14724,7 @@ exports.Button = Button;
|
|
|
14077
14724
|
exports.ButtonGroup = ButtonGroup;
|
|
14078
14725
|
exports.Calendar = Calendar;
|
|
14079
14726
|
exports.Card = Card;
|
|
14727
|
+
exports.Carousel = Carousel;
|
|
14080
14728
|
exports.Checkbox = Checkbox;
|
|
14081
14729
|
exports.Collapsible = Collapsible;
|
|
14082
14730
|
exports.Combobox = Combobox;
|
|
@@ -14090,8 +14738,10 @@ exports.Empty = Empty;
|
|
|
14090
14738
|
exports.Field = Field;
|
|
14091
14739
|
exports.FloatButton = FloatButton;
|
|
14092
14740
|
exports.HStack = HStack;
|
|
14741
|
+
exports.HoverCard = HoverCard;
|
|
14093
14742
|
exports.Icon = Icon;
|
|
14094
14743
|
exports.InputGroup = InputGroup;
|
|
14744
|
+
exports.InputOTP = InputOTP;
|
|
14095
14745
|
exports.Item = Item;
|
|
14096
14746
|
exports.Kbd = Kbd;
|
|
14097
14747
|
exports.Label = Label;
|