@kadoui/react 1.4.10 → 1.5.12

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.
Files changed (141) hide show
  1. package/package.json +4 -8
  2. package/dist/components/AccessNavigation/AccessNavigation.jsx +0 -26
  3. package/dist/components/Accordion/AccordionBody.jsx +0 -14
  4. package/dist/components/Accordion/AccordionRoot.jsx +0 -9
  5. package/dist/components/Accordion/AccordionToggle.jsx +0 -11
  6. package/dist/components/Affix/Affix.jsx +0 -35
  7. package/dist/components/Breadcrumbs/BreadcrumbsItem.jsx +0 -10
  8. package/dist/components/Breadcrumbs/BreadcrumbsRoot.jsx +0 -7
  9. package/dist/components/Carousel/CarouselContainer.jsx +0 -9
  10. package/dist/components/Carousel/CarouselLeftFade.jsx +0 -10
  11. package/dist/components/Carousel/CarouselRightFade.jsx +0 -10
  12. package/dist/components/Carousel/CarouselRoot.jsx +0 -40
  13. package/dist/components/ClientOnly/ClientOnly.jsx +0 -6
  14. package/dist/components/Clipboard/Clipboard.jsx +0 -12
  15. package/dist/components/ContextMenu/ContextMenuContent.jsx +0 -29
  16. package/dist/components/ContextMenu/ContextMenuRoot.jsx +0 -56
  17. package/dist/components/Drawer/DrawerBody.jsx +0 -38
  18. package/dist/components/Drawer/DrawerPortal.jsx +0 -19
  19. package/dist/components/Drawer/DrawerRoot.jsx +0 -35
  20. package/dist/components/Drawer/DrawerToggle.jsx +0 -10
  21. package/dist/components/Dropdown/Dropdown.d.ts +0 -8
  22. package/dist/components/Dropdown/Dropdown.d.ts.map +0 -1
  23. package/dist/components/Dropdown/Dropdown.js +0 -7
  24. package/dist/components/Dropdown/DropdownContext.d.ts +0 -9
  25. package/dist/components/Dropdown/DropdownContext.d.ts.map +0 -1
  26. package/dist/components/Dropdown/DropdownContext.js +0 -2
  27. package/dist/components/Dropdown/DropdownMenu.d.ts +0 -6
  28. package/dist/components/Dropdown/DropdownMenu.d.ts.map +0 -1
  29. package/dist/components/Dropdown/DropdownMenu.jsx +0 -12
  30. package/dist/components/Dropdown/DropdownRoot.d.ts +0 -6
  31. package/dist/components/Dropdown/DropdownRoot.d.ts.map +0 -1
  32. package/dist/components/Dropdown/DropdownRoot.jsx +0 -63
  33. package/dist/components/Dropdown/DropdownToggle.d.ts +0 -4
  34. package/dist/components/Dropdown/DropdownToggle.d.ts.map +0 -1
  35. package/dist/components/Dropdown/DropdownToggle.jsx +0 -11
  36. package/dist/components/LoaderLink/LoaderLink.jsx +0 -6
  37. package/dist/components/Modal/ModalBody.jsx +0 -21
  38. package/dist/components/Modal/ModalContent.jsx +0 -3
  39. package/dist/components/Modal/ModalHeader.jsx +0 -3
  40. package/dist/components/Modal/ModalPortal.jsx +0 -19
  41. package/dist/components/Modal/ModalRoot.jsx +0 -35
  42. package/dist/components/Modal/ModalTrigger.jsx +0 -10
  43. package/dist/components/Otp/OtpHiddenInput.jsx +0 -7
  44. package/dist/components/Otp/OtpInputs.jsx +0 -54
  45. package/dist/components/Otp/OtpRoot.jsx +0 -15
  46. package/dist/components/Pagination/PaginationContext.jsx +0 -2
  47. package/dist/components/Pagination/PaginationCounts.jsx +0 -9
  48. package/dist/components/Pagination/PaginationNextBtn.jsx +0 -10
  49. package/dist/components/Pagination/PaginationPrevBtn.jsx +0 -10
  50. package/dist/components/Pagination/PaginationSearchParamsRoot.jsx +0 -30
  51. package/dist/components/Pagination/PaginationStateRoot.jsx +0 -11
  52. package/dist/components/PasswordInput/PasswordInputContext.jsx +0 -2
  53. package/dist/components/PasswordInput/PasswordInputField.jsx +0 -7
  54. package/dist/components/PasswordInput/PasswordInputRoot.jsx +0 -9
  55. package/dist/components/PasswordInput/PasswordInputToggle.jsx +0 -12
  56. package/dist/components/Popover/PopoverBody.jsx +0 -12
  57. package/dist/components/Popover/PopoverMenu.d.ts +0 -6
  58. package/dist/components/Popover/PopoverMenu.d.ts.map +0 -1
  59. package/dist/components/Popover/PopoverMenu.jsx +0 -12
  60. package/dist/components/Popover/PopoverRoot.jsx +0 -75
  61. package/dist/components/Popover/PopoverToggle.jsx +0 -13
  62. package/dist/components/Portal/Portal.jsx +0 -7
  63. package/dist/components/Progress/ProgressBar.jsx +0 -11
  64. package/dist/components/Progress/ProgressRoot.jsx +0 -7
  65. package/dist/components/QrCode/QrCode.jsx +0 -14
  66. package/dist/components/Rating/RatingItems.jsx +0 -14
  67. package/dist/components/Rating/RatingRoot.jsx +0 -9
  68. package/dist/components/Sheet/SheetBody.jsx +0 -20
  69. package/dist/components/Sheet/SheetContent.jsx +0 -3
  70. package/dist/components/Sheet/SheetHeader.jsx +0 -10
  71. package/dist/components/Sheet/SheetPortal.jsx +0 -16
  72. package/dist/components/Sheet/SheetRoot.jsx +0 -36
  73. package/dist/components/Sheet/SheetToggle.jsx +0 -10
  74. package/dist/components/ShowMore/ShowMoreContent.jsx +0 -20
  75. package/dist/components/ShowMore/ShowMoreFade.jsx +0 -7
  76. package/dist/components/ShowMore/ShowMoreRoot.jsx +0 -22
  77. package/dist/components/ShowMore/ShowMoreTrigger.jsx +0 -13
  78. package/dist/components/Slide/Slide.d.ts +0 -12
  79. package/dist/components/Slide/Slide.d.ts.map +0 -1
  80. package/dist/components/Slide/Slide.js +0 -11
  81. package/dist/components/Slide/SlideBody.d.ts +0 -4
  82. package/dist/components/Slide/SlideBody.d.ts.map +0 -1
  83. package/dist/components/Slide/SlideBody.jsx +0 -3
  84. package/dist/components/Slide/SlideContext.d.ts +0 -7
  85. package/dist/components/Slide/SlideContext.d.ts.map +0 -1
  86. package/dist/components/Slide/SlideContext.js +0 -5
  87. package/dist/components/Slide/SlideHeader.d.ts +0 -4
  88. package/dist/components/Slide/SlideHeader.d.ts.map +0 -1
  89. package/dist/components/Slide/SlideHeader.jsx +0 -3
  90. package/dist/components/Slide/SlidePortal.d.ts +0 -4
  91. package/dist/components/Slide/SlidePortal.d.ts.map +0 -1
  92. package/dist/components/Slide/SlidePortal.jsx +0 -11
  93. package/dist/components/Slide/SlideRoot.d.ts +0 -6
  94. package/dist/components/Slide/SlideRoot.d.ts.map +0 -1
  95. package/dist/components/Slide/SlideRoot.jsx +0 -35
  96. package/dist/components/Slide/SlideToggle.d.ts +0 -4
  97. package/dist/components/Slide/SlideToggle.d.ts.map +0 -1
  98. package/dist/components/Slide/SlideToggle.jsx +0 -10
  99. package/dist/components/Spoiler/SpoilerBlur.jsx +0 -8
  100. package/dist/components/Spoiler/SpoilerRoot.jsx +0 -10
  101. package/dist/components/Steps/StepsContext.jsx +0 -2
  102. package/dist/components/Steps/StepsControls.d.ts +0 -4
  103. package/dist/components/Steps/StepsControls.d.ts.map +0 -1
  104. package/dist/components/Steps/StepsControls.jsx +0 -34
  105. package/dist/components/Steps/StepsIndexBtn.jsx +0 -10
  106. package/dist/components/Steps/StepsNextBtn.jsx +0 -10
  107. package/dist/components/Steps/StepsPrevBtn.jsx +0 -10
  108. package/dist/components/Steps/StepsRender.jsx +0 -7
  109. package/dist/components/Steps/StepsSearchParamsRoot.jsx +0 -30
  110. package/dist/components/Steps/StepsStateRoot.jsx +0 -11
  111. package/dist/components/Swap/SwapItem.jsx +0 -5
  112. package/dist/components/Swap/SwapRoot.jsx +0 -16
  113. package/dist/components/Swap/SwapTrigger.jsx +0 -16
  114. package/dist/components/Tabs/TabsList.jsx +0 -4
  115. package/dist/components/Tabs/TabsPanel.jsx +0 -8
  116. package/dist/components/Tabs/TabsRoot.jsx +0 -7
  117. package/dist/components/Tabs/TabsTab.jsx +0 -10
  118. package/dist/components/Toast/Toast.d.ts +0 -4
  119. package/dist/components/Toast/Toast.d.ts.map +0 -1
  120. package/dist/components/Toast/Toast.js +0 -3
  121. package/dist/components/Toast/ToastBox.d.ts +0 -6
  122. package/dist/components/Toast/ToastBox.d.ts.map +0 -1
  123. package/dist/components/Toast/ToastBox.jsx +0 -32
  124. package/dist/components/Toast/ToastRoot.d.ts +0 -15
  125. package/dist/components/Toast/ToastRoot.d.ts.map +0 -1
  126. package/dist/components/Toast/ToastRoot.jsx +0 -38
  127. package/dist/components/Toast/toastStore.d.ts +0 -11
  128. package/dist/components/Toast/toastStore.d.ts.map +0 -1
  129. package/dist/components/Toast/toastStore.js +0 -10
  130. package/dist/components/Toggle/Toggle.d.ts +0 -6
  131. package/dist/components/Toggle/Toggle.d.ts.map +0 -1
  132. package/dist/components/Toggle/Toggle.js +0 -5
  133. package/dist/components/Toggle/ToggleContext.d.ts +0 -8
  134. package/dist/components/Toggle/ToggleContext.d.ts.map +0 -1
  135. package/dist/components/Toggle/ToggleContext.js +0 -2
  136. package/dist/components/Toggle/ToggleRoot.d.ts +0 -8
  137. package/dist/components/Toggle/ToggleRoot.d.ts.map +0 -1
  138. package/dist/components/Toggle/ToggleRoot.jsx +0 -13
  139. package/dist/components/Toggle/ToggleSwitch.d.ts +0 -4
  140. package/dist/components/Toggle/ToggleSwitch.d.ts.map +0 -1
  141. package/dist/components/Toggle/ToggleSwitch.jsx +0 -23
@@ -1,19 +0,0 @@
1
- "use client";
2
- import { use } from "react";
3
- import { motion, AnimatePresence } from "framer-motion";
4
- import { Portal } from "../Portal/Portal";
5
- import { ModalContext } from "./ModalContext";
6
- import { ClientOnly } from "../ClientOnly/ClientOnly";
7
- export function ModalPortal({ onClick, ...p }) {
8
- const { isOpen, setOpen } = use(ModalContext);
9
- return (<ClientOnly>
10
- <Portal>
11
- <AnimatePresence>
12
- {isOpen ? (<motion.div initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }} onClick={ev => {
13
- onClick?.(ev);
14
- setOpen(false);
15
- }} {...p}/>) : null}
16
- </AnimatePresence>
17
- </Portal>
18
- </ClientOnly>);
19
- }
@@ -1,35 +0,0 @@
1
- "use client";
2
- import { useState, useEffect } from "react";
3
- import { getBrowserScrollbarWith } from "../../utils";
4
- import { ModalContext } from "./ModalContext";
5
- export function ModalRoot({ children, defaultOpen = false }) {
6
- const [isOpen, setOpen] = useState(defaultOpen);
7
- useEffect(() => {
8
- const handleEscape = (e) => {
9
- if (e.key === "Escape") {
10
- setOpen(false);
11
- }
12
- ;
13
- };
14
- document.addEventListener("keydown", handleEscape);
15
- return () => {
16
- document.removeEventListener("keydown", handleEscape);
17
- document.body.style.overflow = "unset";
18
- };
19
- }, []);
20
- useEffect(() => {
21
- const scrollbarWidth = getBrowserScrollbarWith();
22
- if (isOpen) {
23
- document.body.style.overflow = "hidden";
24
- document.body.style.paddingRight = `${scrollbarWidth}px`;
25
- }
26
- else {
27
- document.body.style.overflow = "unset";
28
- document.body.style.paddingRight = "0px";
29
- }
30
- ;
31
- }, [isOpen]);
32
- return (<ModalContext value={{ isOpen, setOpen }}>
33
- {children}
34
- </ModalContext>);
35
- }
@@ -1,10 +0,0 @@
1
- "use client";
2
- import { use } from "react";
3
- import { ModalContext } from "./ModalContext";
4
- export function ModalToggle({ onClick, ...props }) {
5
- const { setOpen } = use(ModalContext);
6
- return (<button onClick={(ev) => {
7
- onClick?.(ev);
8
- setOpen(prev => !prev);
9
- }} {...props}/>);
10
- }
@@ -1,7 +0,0 @@
1
- "use client";
2
- import { use } from "react";
3
- import { OtpContext } from "./OtpContext";
4
- export function OtpHiddenInput({ name, ...p }) {
5
- const { getInputsValue } = use(OtpContext);
6
- return (<input type="hidden" tabIndex={-1} name={name || "otp"} value={getInputsValue()} {...p}/>);
7
- }
@@ -1,54 +0,0 @@
1
- "use client";
2
- import { use } from "react";
3
- import { OtpContext } from "./OtpContext";
4
- export function OtpInputs({ name, length, onLastChange, ...props }) {
5
- const { inputs, getInputsValue } = use(OtpContext);
6
- const handlePaste = (ev, startIndex) => {
7
- ev.preventDefault();
8
- const pastedData = ev.clipboardData.getData("text").replace(/\s/g, ""); // Remove whitespace
9
- if (!pastedData)
10
- return;
11
- for (let i = 0; i < pastedData.length; i++) {
12
- const inputIndex = startIndex + i;
13
- if (inputIndex >= length)
14
- break; // Don't exceed OTP length
15
- const input = inputs?.current[inputIndex];
16
- const indexedPastedData = pastedData[i];
17
- if (input && indexedPastedData) {
18
- input.value = indexedPastedData;
19
- }
20
- }
21
- const nextIndex = Math.min(startIndex + pastedData.length, length - 1);
22
- inputs?.current[nextIndex]?.focus();
23
- const otpValue = getInputsValue();
24
- if (otpValue.length === length) {
25
- onLastChange?.(otpValue);
26
- }
27
- };
28
- const handleInputChange = (value, index) => {
29
- if (value) {
30
- const currentInput = inputs?.current[index];
31
- const currentValue = currentInput?.value[currentInput.value.length - 1];
32
- if (currentValue) {
33
- currentInput.value = currentValue;
34
- }
35
- const nextInput = inputs?.current[index + 1];
36
- if (nextInput) {
37
- nextInput.value = "";
38
- nextInput.focus();
39
- return;
40
- }
41
- onLastChange?.(getInputsValue());
42
- }
43
- };
44
- const handleBackspace = (e, index) => {
45
- if (e.key === "Backspace" && !e.currentTarget.value && index > 0) {
46
- inputs?.current[index - 1]?.focus();
47
- }
48
- };
49
- return Array.from({ length }).map((_, index) => (<input key={index} autoComplete="off" name={`${name || "otp"}-${index}`} onPaste={ev => handlePaste(ev, index)} onKeyDown={ev => handleBackspace(ev, index)} onChange={ev => handleInputChange(ev.target.value, index)} ref={el => {
50
- if (inputs) {
51
- inputs.current[index] = el;
52
- }
53
- }} {...props}/>));
54
- }
@@ -1,15 +0,0 @@
1
- "use client";
2
- import { useEffect, useRef } from "react";
3
- import { OtpContext } from "./OtpContext";
4
- export function OtpRoot(p) {
5
- const inputs = useRef([]);
6
- useEffect(() => {
7
- inputs.current[0]?.focus();
8
- }, []);
9
- const getInputsValue = () => {
10
- return inputs?.current.map(input => input?.value || "").join("") || "";
11
- };
12
- return (<OtpContext value={{ inputs, getInputsValue }}>
13
- <div {...p}/>
14
- </OtpContext>);
15
- }
@@ -1,2 +0,0 @@
1
- import { createContext } from 'react';
2
- export const PaginationContext = createContext({});
@@ -1,9 +0,0 @@
1
- "use client";
2
- import { use } from "react";
3
- import { PaginationContext } from "./PaginationContext";
4
- export function PaginationCounts(props) {
5
- const { page, pageLength } = use(PaginationContext);
6
- return (<p {...props}>
7
- Page {page} / {pageLength}
8
- </p>);
9
- }
@@ -1,10 +0,0 @@
1
- "use client";
2
- import { use } from "react";
3
- import { PaginationContext } from "./PaginationContext";
4
- export function PaginationNextBtn({ onClick, disabled, ...p }) {
5
- const { page, pageLength, nextPage } = use(PaginationContext);
6
- return (<button disabled={disabled || page === pageLength} onClick={ev => {
7
- onClick?.(ev);
8
- nextPage();
9
- }} {...p}/>);
10
- }
@@ -1,10 +0,0 @@
1
- "use client";
2
- import { use } from "react";
3
- import { PaginationContext } from "./PaginationContext";
4
- export function PaginationPrevBtn({ onClick, disabled, ...p }) {
5
- const { page, prevPage } = use(PaginationContext);
6
- return (<button disabled={disabled || page === 1} onClick={ev => {
7
- onClick?.(ev);
8
- prevPage();
9
- }} {...p}/>);
10
- }
@@ -1,30 +0,0 @@
1
- "use client";
2
- import { useRouter, useSearchParams } from "next/navigation";
3
- import { useEffect, useState } from "react";
4
- import { PaginationContext } from "./PaginationContext";
5
- export function PaginationSearchParamsRoot({ pageKey, pageLength, children }) {
6
- const router = useRouter();
7
- const searchParams = useSearchParams();
8
- const [currentPage, setCurrentPage] = useState(1);
9
- useEffect(() => {
10
- setCurrentPage(+(searchParams.get(pageKey || "page") || "1"));
11
- }, [pageKey, searchParams]);
12
- const pushRouter = (page) => {
13
- const params = new URLSearchParams(searchParams.toString());
14
- params.set(pageKey || "page", page.toString());
15
- router.push("?" + params.toString());
16
- };
17
- const nextPage = () => {
18
- if (currentPage < pageLength) {
19
- pushRouter(currentPage + 1);
20
- }
21
- };
22
- const prevPage = () => {
23
- if (currentPage > 1) {
24
- pushRouter(currentPage - 1);
25
- }
26
- };
27
- return (<PaginationContext.Provider value={{ page: currentPage, pageLength, nextPage, prevPage }}>
28
- {children}
29
- </PaginationContext.Provider>);
30
- }
@@ -1,11 +0,0 @@
1
- "use client";
2
- import { useState } from "react";
3
- import { PaginationContext } from "./PaginationContext";
4
- export function PaginationStateRoot({ pageLength, children }) {
5
- const [page, setPage] = useState(1);
6
- const nextPage = () => setPage(prev => prev < pageLength ? prev + 1 : prev);
7
- const prevPage = () => setPage(prev => prev > 1 ? prev - 1 : prev);
8
- return (<PaginationContext.Provider value={{ page, pageLength, nextPage, prevPage }}>
9
- {children}
10
- </PaginationContext.Provider>);
11
- }
@@ -1,2 +0,0 @@
1
- import { createContext } from "react";
2
- export const PasswordInputContext = createContext({});
@@ -1,7 +0,0 @@
1
- "use client";
2
- import { use } from "react";
3
- import { PasswordInputContext } from "./PasswordInputContext";
4
- export function PasswordInputField(props) {
5
- const { isVisible } = use(PasswordInputContext);
6
- return (<input type={isVisible ? "text" : "password"} {...props}/>);
7
- }
@@ -1,9 +0,0 @@
1
- "use client";
2
- import { useState } from "react";
3
- import { PasswordInputContext } from "./PasswordInputContext";
4
- export function PasswordInputRoot(props) {
5
- const [isVisible, setIsVisible] = useState(false);
6
- return (<PasswordInputContext value={{ isVisible, setIsVisible }}>
7
- <label {...props}/>
8
- </PasswordInputContext>);
9
- }
@@ -1,12 +0,0 @@
1
- "use client";
2
- import { use } from "react";
3
- import { PasswordInputContext } from "./PasswordInputContext";
4
- export function PasswordInputToggle({ visibleChildren, onClick, children, ...props }) {
5
- const { isVisible, setIsVisible } = use(PasswordInputContext);
6
- return (<button type="button" onClick={ev => {
7
- setIsVisible(prev => !prev);
8
- onClick?.(ev);
9
- }} {...props}>
10
- {isVisible ? visibleChildren : children}
11
- </button>);
12
- }
@@ -1,12 +0,0 @@
1
- "use client";
2
- import { use } from "react";
3
- import { PopoverContext } from "./PopoverContext";
4
- export function PopoverBody({ preventClose, onClick, ...p }) {
5
- const { bodyRef, isOpen } = use(PopoverContext);
6
- return (isOpen ? (<div ref={bodyRef} onClick={ev => {
7
- if (preventClose) {
8
- ev.stopPropagation();
9
- }
10
- onClick?.(ev);
11
- }} {...p}/>) : null);
12
- }
@@ -1,6 +0,0 @@
1
- import { HTMLAttributes } from "react";
2
- export type PopoverMenuPropsT = HTMLAttributes<HTMLDivElement> & {
3
- preventClose?: boolean;
4
- };
5
- export declare function PopoverMenu({ preventClose, onClick, ...p }: PopoverMenuPropsT): import("react").JSX.Element | null;
6
- //# sourceMappingURL=PopoverMenu.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PopoverMenu.d.ts","sourceRoot":"","sources":["../../../src/components/Popover/PopoverMenu.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAO,MAAM,OAAO,CAAC;AAI5C,MAAM,MAAM,iBAAiB,GAAG,cAAc,CAAC,cAAc,CAAC,GAAG;IAC/D,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAA;AAED,wBAAgB,WAAW,CAAC,EAAE,YAAY,EAAE,OAAO,EAAE,GAAG,CAAC,EAAE,EAAE,iBAAiB,sCAkB7E"}
@@ -1,12 +0,0 @@
1
- "use client";
2
- import { use } from "react";
3
- import { PopoverContext } from "./PopoverContext";
4
- export function PopoverMenu({ preventClose, onClick, ...p }) {
5
- const { menuRef, isOpen } = use(PopoverContext);
6
- return (isOpen ? (<div ref={menuRef} onClick={ev => {
7
- if (preventClose) {
8
- ev.stopPropagation();
9
- }
10
- onClick?.(ev);
11
- }} {...p}/>) : null);
12
- }
@@ -1,75 +0,0 @@
1
- "use client";
2
- import { useEffect, useRef, useState } from "react";
3
- import { PopoverContext } from "./PopoverContext";
4
- import { selectAccessibleChildren } from "../../utils";
5
- export function PopoverRoot({ mode = "click", accessHorizontalArrows, onKeyDown, onMouseEnter, onMouseLeave, ...p }) {
6
- const [isOpen, setOpen] = useState(false);
7
- const toggleRef = useRef(null);
8
- const bodyRef = useRef(null);
9
- useEffect(() => {
10
- const closeHandler = () => {
11
- setOpen(false);
12
- };
13
- window.addEventListener("click", closeHandler);
14
- return () => window.removeEventListener("click", closeHandler);
15
- }, []);
16
- useEffect(() => {
17
- if (isOpen) {
18
- selectFirstMenuChild();
19
- }
20
- }, [isOpen]);
21
- const selectFirstMenuChild = () => {
22
- if (!bodyRef.current) {
23
- return;
24
- }
25
- const children = selectAccessibleChildren(bodyRef.current);
26
- const firstChild = children[0];
27
- if (!firstChild) {
28
- return;
29
- }
30
- firstChild.focus();
31
- };
32
- const handleKeyDown = (ev) => {
33
- if (!accessHorizontalArrows) {
34
- return null;
35
- }
36
- if (ev.key === "ArrowRight") {
37
- if (accessHorizontalArrows === "ArrowRight") {
38
- setOpen(true);
39
- selectFirstMenuChild();
40
- }
41
- else {
42
- setOpen(false);
43
- toggleRef.current?.focus();
44
- }
45
- }
46
- if (ev.key === "ArrowLeft") {
47
- if (accessHorizontalArrows === "ArrowLeft") {
48
- setOpen(true);
49
- selectFirstMenuChild();
50
- }
51
- else {
52
- setOpen(false);
53
- toggleRef.current?.focus();
54
- }
55
- }
56
- };
57
- return (<PopoverContext value={{ isOpen, setOpen, toggleRef, bodyRef, mode }}>
58
- <div onKeyDown={ev => {
59
- onKeyDown?.(ev);
60
- handleKeyDown(ev);
61
- }} onMouseEnter={ev => {
62
- onMouseEnter?.(ev);
63
- if (["hover", "both"].includes(mode)) {
64
- ev.stopPropagation();
65
- setOpen(true);
66
- }
67
- }} onMouseLeave={ev => {
68
- onMouseLeave?.(ev);
69
- if (["hover", "both"].includes(mode)) {
70
- ev.stopPropagation();
71
- setOpen(false);
72
- }
73
- }} {...p}/>
74
- </PopoverContext>);
75
- }
@@ -1,13 +0,0 @@
1
- "use client";
2
- import { use } from "react";
3
- import { PopoverContext } from "./PopoverContext";
4
- export function PopoverToggle({ onClick, ...props }) {
5
- const { mode, toggleRef, setOpen } = use(PopoverContext);
6
- return (<button ref={toggleRef} onClick={ev => {
7
- onClick?.(ev);
8
- ev.stopPropagation();
9
- if (["click", "both"].includes(mode)) {
10
- setOpen(prev => !prev);
11
- }
12
- }} {...props}/>);
13
- }
@@ -1,7 +0,0 @@
1
- "use client";
2
- import { createPortal } from "react-dom";
3
- export function Portal({ children, container }) {
4
- return createPortal(<>
5
- {children}
6
- </>, container || document.body);
7
- }
@@ -1,11 +0,0 @@
1
- "use client";
2
- import { use } from "react";
3
- import { motion } from "framer-motion";
4
- import { ProgressContext } from "./ProgressContext";
5
- export function ProgressBar({ duration, children, ...p }) {
6
- const { value, maxValue } = use(ProgressContext);
7
- const percentage = Math.min(100, Math.max(0, (value / maxValue) * 100));
8
- return (<motion.div initial={{ width: 0 }} whileInView={{ width: `${percentage}%` }} transition={{ duration: duration || 3 }} {...p}>
9
- {children || <span className="text-xs">{percentage}%</span>}
10
- </motion.div>);
11
- }
@@ -1,7 +0,0 @@
1
- "use client";
2
- import { ProgressContext } from "./ProgressContext";
3
- export function ProgressRoot({ value, maxValue = 100, ...p }) {
4
- return (<ProgressContext value={{ value, maxValue }}>
5
- <div {...p}/>
6
- </ProgressContext>);
7
- }
@@ -1,14 +0,0 @@
1
- "use client";
2
- import QRCode from "qrcode";
3
- import React, { useEffect, useRef } from "react";
4
- export function QrCode({ value, options, ...props }) {
5
- const canvasRef = useRef(null);
6
- useEffect(() => {
7
- console.log(value);
8
- QRCode.toCanvas(canvasRef.current, value, options, function (error) {
9
- if (error)
10
- console.error(error);
11
- });
12
- }, [value, options]);
13
- return <canvas ref={canvasRef} {...props}/>;
14
- }
@@ -1,14 +0,0 @@
1
- "use client";
2
- import { use } from "react";
3
- import { RatingContext } from "./RatingContext";
4
- export function RatingItems({ count, value, onValueChange, element, activeElement, ...p }) {
5
- const { hoverValue, setHoverValue } = use(RatingContext);
6
- const displayValue = hoverValue !== null ? hoverValue : value;
7
- return (Array.from({ length: count }).map((_, index) => {
8
- const itemValue = index + 1;
9
- const isActive = itemValue <= displayValue;
10
- return (<button key={index} role="radio" type="button" aria-checked={itemValue === value} onClick={() => onValueChange(itemValue)} onMouseEnter={() => setHoverValue(itemValue)} aria-label={`${itemValue} out of ${count} stars`} {...p}>
11
- {isActive ? activeElement : element}
12
- </button>);
13
- }));
14
- }
@@ -1,9 +0,0 @@
1
- "use client";
2
- import { useState } from "react";
3
- import { RatingContext } from "./RatingContext";
4
- export const RatingRoot = (p) => {
5
- const [hoverValue, setHoverValue] = useState(null);
6
- return (<RatingContext value={{ hoverValue, setHoverValue }}>
7
- <div onMouseLeave={() => setHoverValue(null)} {...p}/>
8
- </RatingContext>);
9
- };
@@ -1,20 +0,0 @@
1
- "use client";
2
- import { use } from "react";
3
- import { motion } from "framer-motion";
4
- import { SheetContext } from "./SheetContext";
5
- export function SheetBody(p) {
6
- const { controls, y, closeHandler: handleClose } = use(SheetContext);
7
- return (<motion.div id="sheet" onClick={(ev) => ev.stopPropagation()} initial={{ y: "100%" }} animate={{ y: "0%" }} exit={{ y: "100%" }} style={{ y }} drag="y" dragControls={controls} dragListener={false} transition={{
8
- ease: "easeInOut",
9
- }} onDragEnd={() => {
10
- if ((y?.get() || 0) >= 100) {
11
- handleClose();
12
- }
13
- }} dragConstraints={{
14
- top: 0,
15
- bottom: 0,
16
- }} dragElastic={{
17
- top: 0,
18
- bottom: 0.5,
19
- }} {...p}/>);
20
- }
@@ -1,3 +0,0 @@
1
- export function SheetContent(p) {
2
- return <div {...p}/>;
3
- }
@@ -1,10 +0,0 @@
1
- "use client";
2
- import { use } from "react";
3
- import { SheetContext } from "./SheetContext";
4
- export function SheetHeader({ onPointerDown, ...p }) {
5
- const { controls } = use(SheetContext);
6
- return (<div onPointerDown={(ev) => {
7
- controls?.start(ev);
8
- onPointerDown?.(ev);
9
- }} {...p}/>);
10
- }
@@ -1,16 +0,0 @@
1
- "use client";
2
- import { use } from "react";
3
- import { AnimatePresence, motion } from "framer-motion";
4
- import { Portal } from "../Portal/Portal";
5
- import { SheetContext } from "./SheetContext";
6
- import { ClientOnly } from "../ClientOnly/ClientOnly";
7
- export function SheetPortal(p) {
8
- const { isOpen, closeHandler: handleClose, scope } = use(SheetContext);
9
- return (<ClientOnly>
10
- <Portal>
11
- <AnimatePresence>
12
- {isOpen ? (<motion.div ref={scope} onClick={handleClose} initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }} {...p}/>) : null}
13
- </AnimatePresence>
14
- </Portal>
15
- </ClientOnly>);
16
- }
@@ -1,36 +0,0 @@
1
- "use client";
2
- import { useEffect, useState } from "react";
3
- import { useDragControls, useMotionValue, useAnimate, } from "framer-motion";
4
- import { SheetContext } from "./SheetContext";
5
- export function SheetRoot({ children }) {
6
- const y = useMotionValue(0);
7
- const controls = useDragControls();
8
- const [scope, animate] = useAnimate();
9
- const [isOpen, setOpen] = useState(false);
10
- useEffect(() => {
11
- const bodyElem = document.body;
12
- const removeOverflow = () => {
13
- bodyElem.style.overflow = "unset";
14
- };
15
- if (isOpen) {
16
- bodyElem.style.overflow = "hidden";
17
- }
18
- else {
19
- removeOverflow();
20
- }
21
- return () => removeOverflow();
22
- }, [isOpen]);
23
- const closeHandler = async () => {
24
- animate(scope.current, {
25
- opacity: [1, 0],
26
- });
27
- const yStart = typeof y.get() === "number" ? y.get() : 0;
28
- await animate("#sheet", {
29
- y: [yStart, "100%"],
30
- });
31
- setOpen(false);
32
- };
33
- return (<SheetContext value={{ isOpen, setOpen, closeHandler, scope, controls, y }}>
34
- {children}
35
- </SheetContext>);
36
- }
@@ -1,10 +0,0 @@
1
- "use client";
2
- import { use } from "react";
3
- import { SheetContext } from "./SheetContext";
4
- export function SheetToggle({ onClick, ...props }) {
5
- const { setOpen } = use(SheetContext);
6
- return (<button onClick={ev => {
7
- onClick?.(ev);
8
- setOpen(prev => !prev);
9
- }} {...props}/>);
10
- }
@@ -1,20 +0,0 @@
1
- "use client";
2
- import { use } from "react";
3
- import { ShowMoreContext } from "./ShowMoreContext";
4
- export function ShowMoreContent({ children, style, ...props }) {
5
- const { contentRef, shouldShowMore, isShowMore, maxHeight } = use(ShowMoreContext);
6
- return (<div ref={contentRef} style={{
7
- overflow: "hidden",
8
- transition: "all 150ms ease",
9
- height: shouldShowMore
10
- ? isShowMore
11
- ? contentRef.current?.scrollHeight
12
- ? `${contentRef.current.scrollHeight}px`
13
- : "auto"
14
- : maxHeight
15
- : "auto",
16
- ...style
17
- }} {...props}>
18
- {children}
19
- </div>);
20
- }
@@ -1,7 +0,0 @@
1
- "use client";
2
- import { use } from "react";
3
- import { ShowMoreContext } from "./ShowMoreContext";
4
- export function ShowMoreFade(p) {
5
- const { shouldShowMore, isShowMore } = use(ShowMoreContext);
6
- return (shouldShowMore && !isShowMore ? (<div {...p}/>) : null);
7
- }
@@ -1,22 +0,0 @@
1
- "use client";
2
- import { useEffect, useRef, useState } from "react";
3
- import { ShowMoreContext } from "./ShowMoreContext";
4
- export function ShowMoreRoot({ maxLines, defaultExpanded = false, style, ...p }) {
5
- const [shouldShowMore, setShouldShowMore] = useState(false);
6
- const [isShowMore, setIsShowMore] = useState(defaultExpanded);
7
- const [maxHeight, setMaxHeight] = useState(0);
8
- const contentRef = useRef(null);
9
- useEffect(() => {
10
- if (contentRef.current) {
11
- const element = contentRef.current;
12
- const lineHeight = Number.parseInt(window.getComputedStyle(element).lineHeight);
13
- const maxHeight = lineHeight * (maxLines || 3);
14
- const actualHeight = element.scrollHeight;
15
- setMaxHeight(maxHeight);
16
- setShouldShowMore(actualHeight > maxHeight);
17
- }
18
- }, [maxLines]);
19
- return (<ShowMoreContext value={{ contentRef, isShowMore, setIsShowMore, maxHeight, shouldShowMore }}>
20
- <div style={{ position: "relative", ...style }} {...p}></div>
21
- </ShowMoreContext>);
22
- }
@@ -1,13 +0,0 @@
1
- "use client";
2
- import { use } from "react";
3
- import { ShowMoreContext } from "./ShowMoreContext";
4
- export function ShowMoreTrigger({ onClick, style, ...p }) {
5
- const { setIsShowMore } = use(ShowMoreContext);
6
- return (<button style={{
7
- position: "relative",
8
- ...style
9
- }} onClick={ev => {
10
- onClick?.(ev);
11
- setIsShowMore(prev => !prev);
12
- }} {...p}/>);
13
- }