@intlayer/design-system 5.3.13 → 5.4.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.
Files changed (100) hide show
  1. package/dist/.vite/manifest.json +74 -60
  2. package/dist/components/Button/Button.d.ts +2 -2
  3. package/dist/components/ClickOutsideDiv/index.cjs +1 -1
  4. package/dist/components/ClickOutsideDiv/index.cjs.map +1 -1
  5. package/dist/components/ClickOutsideDiv/index.d.ts +1 -1
  6. package/dist/components/ClickOutsideDiv/index.d.ts.map +1 -1
  7. package/dist/components/ClickOutsideDiv/index.mjs +1 -1
  8. package/dist/components/ClickOutsideDiv/index.mjs.map +1 -1
  9. package/dist/components/Container/index.d.ts +2 -2
  10. package/dist/components/DropDown/index.cjs +16 -0
  11. package/dist/components/DropDown/index.cjs.map +1 -1
  12. package/dist/components/DropDown/index.d.ts.map +1 -1
  13. package/dist/components/DropDown/index.mjs +16 -0
  14. package/dist/components/DropDown/index.mjs.map +1 -1
  15. package/dist/components/Headers/SectionScroller.cjs +1 -1
  16. package/dist/components/Headers/SectionScroller.cjs.map +1 -1
  17. package/dist/components/Headers/SectionScroller.mjs +1 -1
  18. package/dist/components/Headers/SectionScroller.mjs.map +1 -1
  19. package/dist/components/HeightResizer/index.cjs +96 -0
  20. package/dist/components/HeightResizer/index.cjs.map +1 -0
  21. package/dist/components/HeightResizer/index.d.ts +9 -0
  22. package/dist/components/HeightResizer/index.d.ts.map +1 -0
  23. package/dist/components/HeightResizer/index.mjs +96 -0
  24. package/dist/components/HeightResizer/index.mjs.map +1 -0
  25. package/dist/components/Input/Checkbox.d.ts +1 -1
  26. package/dist/components/Link/Link.d.ts +1 -1
  27. package/dist/components/Navbar/useNavigation.cjs +1 -1
  28. package/dist/components/Navbar/useNavigation.cjs.map +1 -1
  29. package/dist/components/Navbar/useNavigation.mjs +1 -1
  30. package/dist/components/Navbar/useNavigation.mjs.map +1 -1
  31. package/dist/components/PressableSpan/PressableSpan.cjs.map +1 -1
  32. package/dist/components/PressableSpan/PressableSpan.d.ts.map +1 -1
  33. package/dist/components/PressableSpan/PressableSpan.mjs.map +1 -1
  34. package/dist/components/RightDrawer/RightDrawer.cjs.map +1 -1
  35. package/dist/components/RightDrawer/RightDrawer.d.ts +1 -1
  36. package/dist/components/RightDrawer/RightDrawer.d.ts.map +1 -1
  37. package/dist/components/RightDrawer/RightDrawer.mjs.map +1 -1
  38. package/dist/components/Tag/index.d.ts +1 -1
  39. package/dist/components/TextArea/AutoSizeTextArea.cjs +8 -11
  40. package/dist/components/TextArea/AutoSizeTextArea.cjs.map +1 -1
  41. package/dist/components/TextArea/AutoSizeTextArea.d.ts.map +1 -1
  42. package/dist/components/TextArea/AutoSizeTextArea.mjs +9 -12
  43. package/dist/components/TextArea/AutoSizeTextArea.mjs.map +1 -1
  44. package/dist/components/WithResizer/index.cjs +2 -2
  45. package/dist/components/WithResizer/index.cjs.map +1 -1
  46. package/dist/components/WithResizer/index.d.ts +1 -1
  47. package/dist/components/WithResizer/index.d.ts.map +1 -1
  48. package/dist/components/WithResizer/index.mjs +2 -2
  49. package/dist/components/WithResizer/index.mjs.map +1 -1
  50. package/dist/components/index.cjs +137 -135
  51. package/dist/components/index.cjs.map +1 -1
  52. package/dist/components/index.d.ts +37 -36
  53. package/dist/components/index.d.ts.map +1 -1
  54. package/dist/components/index.mjs +62 -60
  55. package/dist/components/index.mjs.map +1 -1
  56. package/dist/hooks/index.cjs +5 -0
  57. package/dist/hooks/index.cjs.map +1 -1
  58. package/dist/hooks/index.mjs +6 -1
  59. package/dist/hooks/intlayerAPIHooks.cjs +1 -1
  60. package/dist/hooks/intlayerAPIHooks.cjs.map +1 -1
  61. package/dist/hooks/intlayerAPIHooks.d.ts +1 -1
  62. package/dist/hooks/intlayerAPIHooks.d.ts.map +1 -1
  63. package/dist/hooks/intlayerAPIHooks.mjs +1 -1
  64. package/dist/hooks/intlayerAPIHooks.mjs.map +1 -1
  65. package/dist/hooks/useAsync/useAsync.cjs +1 -0
  66. package/dist/hooks/useAsync/useAsync.cjs.map +1 -1
  67. package/dist/hooks/useAsync/useAsync.d.ts.map +1 -1
  68. package/dist/hooks/useAsync/useAsync.mjs +1 -0
  69. package/dist/hooks/useAsync/useAsync.mjs.map +1 -1
  70. package/dist/hooks/useDevice.cjs +15 -2
  71. package/dist/hooks/useDevice.cjs.map +1 -1
  72. package/dist/hooks/useDevice.d.ts +9 -0
  73. package/dist/hooks/useDevice.d.ts.map +1 -1
  74. package/dist/hooks/useDevice.mjs +15 -2
  75. package/dist/hooks/useDevice.mjs.map +1 -1
  76. package/dist/hooks/useIntlayerAPI.d.ts +1 -1
  77. package/dist/hooks/useIntlayerAPI.d.ts.map +1 -1
  78. package/dist/hooks/useItemSelector.cjs +6 -2
  79. package/dist/hooks/useItemSelector.cjs.map +1 -1
  80. package/dist/hooks/useItemSelector.d.ts.map +1 -1
  81. package/dist/hooks/useItemSelector.mjs +6 -2
  82. package/dist/hooks/useItemSelector.mjs.map +1 -1
  83. package/dist/hooks/useKeyboardDetector.cjs +3 -1
  84. package/dist/hooks/useKeyboardDetector.cjs.map +1 -1
  85. package/dist/hooks/useKeyboardDetector.d.ts.map +1 -1
  86. package/dist/hooks/useKeyboardDetector.mjs +3 -1
  87. package/dist/hooks/useKeyboardDetector.mjs.map +1 -1
  88. package/dist/hooks/usePersistedStore.cjs +10 -1
  89. package/dist/hooks/usePersistedStore.cjs.map +1 -1
  90. package/dist/hooks/usePersistedStore.d.ts +2 -2
  91. package/dist/hooks/usePersistedStore.d.ts.map +1 -1
  92. package/dist/hooks/usePersistedStore.mjs +10 -1
  93. package/dist/hooks/usePersistedStore.mjs.map +1 -1
  94. package/dist/hooks/useScrollDetection.cjs +4 -2
  95. package/dist/hooks/useScrollDetection.cjs.map +1 -1
  96. package/dist/hooks/useScrollDetection.d.ts.map +1 -1
  97. package/dist/hooks/useScrollDetection.mjs +4 -2
  98. package/dist/hooks/useScrollDetection.mjs.map +1 -1
  99. package/dist/tailwind.css +1 -1
  100. package/package.json +19 -19
@@ -0,0 +1,96 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { useRef, useState, useCallback, useEffect } from "react";
4
+ import { cn } from "../../utils/cn.mjs";
5
+ const HeightResizer = ({
6
+ initialHeight,
7
+ maxHeight,
8
+ minHeight = 0,
9
+ children,
10
+ className,
11
+ ...props
12
+ }) => {
13
+ const containerRef = useRef(null);
14
+ const [height, setHeight] = useState(initialHeight);
15
+ const [isResizing, setIsResizing] = useState(false);
16
+ const startResizing = useCallback(
17
+ (mouseDownEvent) => {
18
+ setIsResizing(true);
19
+ mouseDownEvent.preventDefault();
20
+ },
21
+ []
22
+ );
23
+ const stopResizing = useCallback(() => {
24
+ setIsResizing(false);
25
+ }, []);
26
+ const resize = useCallback(
27
+ (mouseMoveEvent) => {
28
+ const container = containerRef.current;
29
+ if (isResizing && container && parent) {
30
+ const { height: containerHeight, top: containerTop } = container.getBoundingClientRect();
31
+ let clientY = 0;
32
+ if (mouseMoveEvent instanceof MouseEvent) {
33
+ clientY = mouseMoveEvent.clientY;
34
+ } else if (mouseMoveEvent instanceof TouchEvent) {
35
+ clientY = mouseMoveEvent.touches[0].clientY;
36
+ }
37
+ const resizeDifference = clientY - containerTop;
38
+ const newHeight = containerHeight - resizeDifference;
39
+ const correctedHeight = Math.max(newHeight, 0);
40
+ setHeight(correctedHeight);
41
+ }
42
+ },
43
+ [isResizing]
44
+ );
45
+ useEffect(() => {
46
+ window.addEventListener("mousemove", resize, { passive: true });
47
+ window.addEventListener("mouseup", stopResizing);
48
+ window.addEventListener("touchmove", resize, { passive: true });
49
+ window.addEventListener("touchend", stopResizing);
50
+ return () => {
51
+ window.removeEventListener("mousemove", resize);
52
+ window.removeEventListener("mouseup", stopResizing);
53
+ window.removeEventListener("touchmove", resize);
54
+ window.removeEventListener("touchend", stopResizing);
55
+ };
56
+ }, [resize, stopResizing]);
57
+ return /* @__PURE__ */ jsx(
58
+ "div",
59
+ {
60
+ className: cn(
61
+ minHeight && `max-w-[${maxHeight}px]`,
62
+ maxHeight && `min-w-[${minHeight}px]`,
63
+ "relative h-full w-full max-h-[80%] cursor-ns-resize border-t-[2px] border-neutral-200 transition dark:border-neutral-950",
64
+ 'before:absolute before:top-0 before:z-10 before:left-1/2 before:block before:w-10 before:h-2 before:-translate-y-1/2 before:-translate-x-1/2 before:transform before:cursor-ns-resize before:rounded-full before:bg-neutral-200 before:transition before:content-[""] dark:before:bg-neutral-950',
65
+ "active:border-neutral-400 active:before:bg-neutral-400 dark:active:border-neutral-600 active:dark:before:bg-neutral-600",
66
+ className
67
+ ),
68
+ style: {
69
+ height: `${height}px`
70
+ },
71
+ ref: containerRef,
72
+ onMouseDown: startResizing,
73
+ onTouchStart: startResizing,
74
+ "aria-valuemin": minHeight,
75
+ "aria-valuemax": maxHeight,
76
+ "aria-valuenow": height,
77
+ "aria-label": "Resizable component",
78
+ role: "slider",
79
+ tabIndex: 0,
80
+ ...props,
81
+ children: /* @__PURE__ */ jsx(
82
+ "div",
83
+ {
84
+ className: "absolute left-0 top-0 size-full cursor-default overflow-hidden",
85
+ onMouseDown: (e) => e.stopPropagation(),
86
+ onTouchStart: (e) => e.stopPropagation(),
87
+ children
88
+ }
89
+ )
90
+ }
91
+ );
92
+ };
93
+ export {
94
+ HeightResizer
95
+ };
96
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["../../../src/components/HeightResizer/index.tsx"],"sourcesContent":["'use client';\n\nimport React, {\n DetailedHTMLProps,\n HTMLAttributes,\n useCallback,\n useEffect,\n useRef,\n useState,\n type FC,\n type PropsWithChildren,\n} from 'react';\nimport { cn } from '../../utils/cn';\n\ntype HeightResizerProps = {\n initialHeight: number;\n maxHeight?: number;\n minHeight?: number;\n} & DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>;\n\nexport const HeightResizer: FC<PropsWithChildren<HeightResizerProps>> = ({\n initialHeight,\n maxHeight,\n minHeight = 0,\n children,\n className,\n ...props\n}) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const [height, setHeight] = useState(initialHeight);\n const [isResizing, setIsResizing] = useState(false);\n\n // Handler to start resizing\n const startResizing = useCallback(\n (\n mouseDownEvent:\n | React.MouseEvent<HTMLDivElement>\n | React.TouchEvent<HTMLDivElement>\n ) => {\n setIsResizing(true);\n mouseDownEvent.preventDefault();\n },\n []\n );\n\n // Handler to stop resizing\n const stopResizing = useCallback(() => {\n setIsResizing(false);\n }, []);\n\n // Handler to resize the div\n const resize = useCallback(\n (mouseMoveEvent: MouseEvent | TouchEvent) => {\n const container = containerRef.current;\n if (isResizing && container && parent) {\n const { height: containerHeight, top: containerTop } =\n container.getBoundingClientRect();\n\n let clientY = 0;\n if (mouseMoveEvent instanceof MouseEvent) {\n clientY = mouseMoveEvent.clientY;\n } else if (mouseMoveEvent instanceof TouchEvent) {\n clientY = mouseMoveEvent.touches[0].clientY;\n }\n\n const resizeDifference = clientY - containerTop;\n const newHeight = containerHeight - resizeDifference;\n const correctedHeight = Math.max(newHeight, 0);\n\n setHeight(correctedHeight);\n }\n },\n [isResizing]\n );\n\n // Add event listeners for mouse move and mouse up\n useEffect(() => {\n window.addEventListener('mousemove', resize, { passive: true });\n window.addEventListener('mouseup', stopResizing);\n window.addEventListener('touchmove', resize, { passive: true });\n window.addEventListener('touchend', stopResizing);\n\n return () => {\n window.removeEventListener('mousemove', resize);\n window.removeEventListener('mouseup', stopResizing);\n window.removeEventListener('touchmove', resize);\n window.removeEventListener('touchend', stopResizing);\n };\n }, [resize, stopResizing]);\n\n return (\n <div\n className={cn(\n minHeight && `max-w-[${maxHeight}px]`,\n maxHeight && `min-w-[${minHeight}px]`,\n 'relative h-full w-full max-h-[80%] cursor-ns-resize border-t-[2px] border-neutral-200 transition dark:border-neutral-950',\n 'before:absolute before:top-0 before:z-10 before:left-1/2 before:block before:w-10 before:h-2 before:-translate-y-1/2 before:-translate-x-1/2 before:transform before:cursor-ns-resize before:rounded-full before:bg-neutral-200 before:transition before:content-[\"\"] dark:before:bg-neutral-950',\n 'active:border-neutral-400 active:before:bg-neutral-400 dark:active:border-neutral-600 active:dark:before:bg-neutral-600',\n className\n )}\n style={{\n height: `${height}px`,\n }}\n ref={containerRef}\n onMouseDown={startResizing}\n onTouchStart={startResizing}\n aria-valuemin={minHeight}\n aria-valuemax={maxHeight}\n aria-valuenow={height}\n aria-label=\"Resizable component\"\n role=\"slider\"\n tabIndex={0}\n {...props}\n >\n <div\n className=\"absolute left-0 top-0 size-full cursor-default overflow-hidden\"\n onMouseDown={(e) => e.stopPropagation()}\n onTouchStart={(e) => e.stopPropagation()}\n >\n {children}\n </div>\n </div>\n );\n};\n"],"names":[],"mappings":";;;;AAoBO,MAAM,gBAA2D,CAAC;AAAA,EACvE;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACE,QAAA,eAAe,OAAuB,IAAI;AAChD,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAS,aAAa;AAClD,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,KAAK;AAGlD,QAAM,gBAAgB;AAAA,IACpB,CACE,mBAGG;AACH,oBAAc,IAAI;AAClB,qBAAe,eAAe;AAAA,IAChC;AAAA,IACA,CAAA;AAAA,EACF;AAGM,QAAA,eAAe,YAAY,MAAM;AACrC,kBAAc,KAAK;AAAA,EACrB,GAAG,EAAE;AAGL,QAAM,SAAS;AAAA,IACb,CAAC,mBAA4C;AAC3C,YAAM,YAAY,aAAa;AAC3B,UAAA,cAAc,aAAa,QAAQ;AACrC,cAAM,EAAE,QAAQ,iBAAiB,KAAK,aAAa,IACjD,UAAU,sBAAsB;AAElC,YAAI,UAAU;AACd,YAAI,0BAA0B,YAAY;AACxC,oBAAU,eAAe;AAAA,QAAA,WAChB,0BAA0B,YAAY;AACrC,oBAAA,eAAe,QAAQ,CAAC,EAAE;AAAA,QAAA;AAGtC,cAAM,mBAA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  export declare const checkboxVariants: (props?: ({
4
4
  variant?: "default" | null | undefined;
5
5
  size?: "sm" | "md" | "lg" | null | undefined;
6
- color?: "text" | "error" | "primary" | "secondary" | "destructive" | "neutral" | "light" | "dark" | "success" | "custom" | null | undefined;
6
+ color?: "text" | "primary" | "secondary" | "destructive" | "neutral" | "light" | "dark" | "error" | "success" | "custom" | null | undefined;
7
7
  validationStyleEnabled?: "disabled" | "enabled" | null | undefined;
8
8
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
9
9
  export type CheckboxProps = Omit<DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, 'size'> & {
@@ -3,7 +3,7 @@ import { VariantProps } from 'class-variance-authority';
3
3
  import { DetailedHTMLProps, AnchorHTMLAttributes, FC } from 'react';
4
4
  export declare const linkVariants: (props?: ({
5
5
  variant?: "default" | "button" | "invisible-link" | "hoverable" | "button-outlined" | null | undefined;
6
- color?: "text" | "error" | "primary" | "secondary" | "destructive" | "neutral" | "light" | "dark" | "text-inverse" | "success" | "custom" | null | undefined;
6
+ color?: "text" | "primary" | "secondary" | "destructive" | "neutral" | "light" | "dark" | "text-inverse" | "error" | "success" | "custom" | null | undefined;
7
7
  underlined?: boolean | "default" | null | undefined;
8
8
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
9
9
  export type LinkProps = DetailedHTMLProps<AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement> & VariantProps<typeof linkVariants> & {
@@ -23,7 +23,7 @@ const useNavActions = () => {
23
23
  }
24
24
  };
25
25
  ReactExports.useEffect(() => {
26
- window.addEventListener("scroll", detectActiveSection);
26
+ window.addEventListener("scroll", detectActiveSection, { passive: true });
27
27
  return () => {
28
28
  window.removeEventListener("scroll", detectActiveSection);
29
29
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useNavigation.cjs","sources":["../../../src/components/Navbar/useNavigation.ts"],"sourcesContent":["'use client';\n\nimport { useEffect, useState } from 'react';\n\ninterface SectionData {\n id: string;\n offsetTop: number;\n offsetHeight: number;\n}\n\nexport const useNavActions = () => {\n const [activeSection, setActiveSection] = useState<string | null>(null);\n\n const detectActiveSection = () => {\n const scrollY = window.scrollY;\n const sections = document.querySelectorAll('section');\n const sectionsData: SectionData[] = [];\n\n sections.forEach((section) =>\n sectionsData.push({\n id: section.id,\n offsetTop: section.offsetTop,\n offsetHeight: section.offsetHeight,\n })\n );\n\n const currentSection = sectionsData.find(\n (section) =>\n section.offsetTop <= scrollY + window.screen.height / 4 &&\n section.offsetTop + section.offsetHeight >\n scrollY + window.screen.height / 4\n );\n\n if (currentSection) {\n setActiveSection(currentSection.id);\n }\n };\n\n useEffect(() => {\n window.addEventListener('scroll', detectActiveSection);\n\n return () => {\n window.removeEventListener('scroll', detectActiveSection);\n };\n }, []);\n\n const onClickLogo = (onClick: (url: string) => void) => {\n setActiveSection(null);\n\n if (window.location.pathname === '/') {\n window.scrollTo({ top: 0, behavior: 'smooth' });\n } else {\n onClick('/');\n }\n };\n\n const onClickSection = (\n sectionId: string,\n url?: string,\n onClick?: () => void\n ) => {\n setActiveSection(sectionId);\n\n if (window.location.pathname === url) {\n const sectionEl = document.getElementById(sectionId);\n\n if (sectionEl) {\n sectionEl.scrollIntoView({\n behavior: 'smooth',\n block: 'center',\n inline: 'nearest',\n });\n }\n } else {\n onClick?.();\n }\n };\n\n return { activeSection, onClickLogo, onClickSection };\n};\n"],"names":["useState","useEffect"],"mappings":";;;;AAUO,MAAM,gBAAgB,MAAM;AACjC,QAAM,CAAC,eAAe,gBAAgB,IAAIA,aAAAA,SAAwB,IAAI;AAEtE,QAAM,sBAAsB,MAAM;AAChC,UAAM,UAAU,OAAO;AACjB,UAAA,WAAW,SAAS,iBAAiB,SAAS;AACpD,UAAM,eAA8B,CAAC;AAE5B,aAAA;AAAA,MAAQ,CAAC,YAChB,aAAa,KAAK;AAAA,QAChB,IAAI,QAAQ;AAAA,QACZ,WAAW,QAAQ;AAAA,QACnB,cAAc,QAAQ;AAAA,MACvB,CAAA;AAAA,IACH;AAEA,UAAM,iBAAiB,aAAa;AAAA,MAClC,CAAC,YACC,QAAQ,aAAa,UAAU,OAAO,OAAO,SAAS,KACtD,QAAQ,YAAY,QAAQ,eAC1B,UAAU,OAAO,OAAO,SAAS;AAAA,IACvC;AAEA,QAAI,gBAAgB;AAClB,uBAAiB,eAAe,EAAE;AAAA,IAAA;AAAA,EAEtC;AAEAC,eAAAA,UAAU,MAAM;AACP,WAAA,iBAAiB,UAAU,mBAAmB;AAErD,WAAO,MAAM;AACJ,aAAA,oBAAoB,UAAU,mBAAmB;AAAA,IAC1D;AAAA,EACF,GAAG,EAAE;AAEC,QAAA,cAAc,CAAC,YAAmC;AACtD,qBAAiB,IAAI;AAEjB,QAAA,OAAO,SAAS,aAAa,KAAK;AACpC,aAAO,SAAS,EAAE,KAAK,GAAG,UAAU,UAAU;AAAA,IAAA,OACzC;AACL,cAAQ,GAAG;AAAA,IAAA;AAAA,EAEf;AAEA,QAAM,iBAAiB,CACrB,WACA,KACA,YACG;AACH,qBAAiB,SAAS;AAEtB,QAAA,OAAO,SAAS,aAAa,KAAK;AAC9B,YAAA,YAAY,SAAS,eAAe,SAAS;AAEnD,UAAI,WAAW;AACb,kBAAU,eAAe;AAAA,UACvB,UAAU;AAAA,UACV,OAAO;AAAA,UACP,QAAQ;AAAA,QAAA,CACT;AAAA,MAAA;AAAA,IACH,OACK;AACK,gBAAA;AAAA,IAAA;AAAA,EAEd;AAEO,SAAA,EAAE,eAAe,aAAa,eAAe;AACtD;;"}
1
+ {"version":3,"file":"useNavigation.cjs","sources":["../../../src/components/Navbar/useNavigation.ts"],"sourcesContent":["'use client';\n\nimport { useEffect, useState } from 'react';\n\ninterface SectionData {\n id: string;\n offsetTop: number;\n offsetHeight: number;\n}\n\nexport const useNavActions = () => {\n const [activeSection, setActiveSection] = useState<string | null>(null);\n\n const detectActiveSection = () => {\n const scrollY = window.scrollY;\n const sections = document.querySelectorAll('section');\n const sectionsData: SectionData[] = [];\n\n sections.forEach((section) =>\n sectionsData.push({\n id: section.id,\n offsetTop: section.offsetTop,\n offsetHeight: section.offsetHeight,\n })\n );\n\n const currentSection = sectionsData.find(\n (section) =>\n section.offsetTop <= scrollY + window.screen.height / 4 &&\n section.offsetTop + section.offsetHeight >\n scrollY + window.screen.height / 4\n );\n\n if (currentSection) {\n setActiveSection(currentSection.id);\n }\n };\n\n useEffect(() => {\n window.addEventListener('scroll', detectActiveSection, { passive: true });\n\n return () => {\n window.removeEventListener('scroll', detectActiveSection);\n };\n }, []);\n\n const onClickLogo = (onClick: (url: string) => void) => {\n setActiveSection(null);\n\n if (window.location.pathname === '/') {\n window.scrollTo({ top: 0, behavior: 'smooth' });\n } else {\n onClick('/');\n }\n };\n\n const onClickSection = (\n sectionId: string,\n url?: string,\n onClick?: () => void\n ) => {\n setActiveSection(sectionId);\n\n if (window.location.pathname === url) {\n const sectionEl = document.getElementById(sectionId);\n\n if (sectionEl) {\n sectionEl.scrollIntoView({\n behavior: 'smooth',\n block: 'center',\n inline: 'nearest',\n });\n }\n } else {\n onClick?.();\n }\n };\n\n return { activeSection, onClickLogo, onClickSection };\n};\n"],"names":["useState","useEffect"],"mappings":";;;;AAUO,MAAM,gBAAgB,MAAM;AACjC,QAAM,CAAC,eAAe,gBAAgB,IAAIA,aAAAA,SAAwB,IAAI;AAEtE,QAAM,sBAAsB,MAAM;AAChC,UAAM,UAAU,OAAO;AACjB,UAAA,WAAW,SAAS,iBAAiB,SAAS;AACpD,UAAM,eAA8B,CAAC;AAE5B,aAAA;AAAA,MAAQ,CAAC,YAChB,aAAa,KAAK;AAAA,QAChB,IAAI,QAAQ;AAAA,QACZ,WAAW,QAAQ;AAAA,QACnB,cAAc,QAAQ;AAAA,MACvB,CAAA;AAAA,IACH;AAEA,UAAM,iBAAiB,aAAa;AAAA,MAClC,CAAC,YACC,QAAQ,aAAa,UAAU,OAAO,OAAO,SAAS,KACtD,QAAQ,YAAY,QAAQ,eAC1B,UAAU,OAAO,OAAO,SAAS;AAAA,IACvC;AAEA,QAAI,gBAAgB;AAClB,uBAAiB,eAAe,EAAE;AAAA,IAAA;AAAA,EAEtC;AAEAC,eAAAA,UAAU,MAAM;AACd,WAAO,iBAAiB,UAAU,qBAAqB,EAAE,SAAS,MAAM;AAExE,WAAO,MAAM;AACJ,aAAA,oBAAoB,UAAU,mBAAmB;AAAA,IAC1D;AAAA,EACF,GAAG,EAAE;AAEC,QAAA,cAAc,CAAC,YAAmC;AACtD,qBAAiB,IAAI;AAEjB,QAAA,OAAO,SAAS,aAAa,KAAK;AACpC,aAAO,SAAS,EAAE,KAAK,GAAG,UAAU,UAAU;AAAA,IAAA,OACzC;AACL,cAAQ,GAAG;AAAA,IAAA;AAAA,EAEf;AAEA,QAAM,iBAAiB,CACrB,WACA,KACA,YACG;AACH,qBAAiB,SAAS;AAEtB,QAAA,OAAO,SAAS,aAAa,KAAK;AAC9B,YAAA,YAAY,SAAS,eAAe,SAAS;AAEnD,UAAI,WAAW;AACb,kBAAU,eAAe;AAAA,UACvB,UAAU;AAAA,UACV,OAAO;AAAA,UACP,QAAQ;AAAA,QAAA,CACT;AAAA,MAAA;AAAA,IACH,OACK;AACK,gBAAA;AAAA,IAAA;AAAA,EAEd;AAEO,SAAA,EAAE,eAAe,aAAa,eAAe;AACtD;;"}
@@ -21,7 +21,7 @@ const useNavActions = () => {
21
21
  }
22
22
  };
23
23
  useEffect(() => {
24
- window.addEventListener("scroll", detectActiveSection);
24
+ window.addEventListener("scroll", detectActiveSection, { passive: true });
25
25
  return () => {
26
26
  window.removeEventListener("scroll", detectActiveSection);
27
27
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useNavigation.mjs","sources":["../../../src/components/Navbar/useNavigation.ts"],"sourcesContent":["'use client';\n\nimport { useEffect, useState } from 'react';\n\ninterface SectionData {\n id: string;\n offsetTop: number;\n offsetHeight: number;\n}\n\nexport const useNavActions = () => {\n const [activeSection, setActiveSection] = useState<string | null>(null);\n\n const detectActiveSection = () => {\n const scrollY = window.scrollY;\n const sections = document.querySelectorAll('section');\n const sectionsData: SectionData[] = [];\n\n sections.forEach((section) =>\n sectionsData.push({\n id: section.id,\n offsetTop: section.offsetTop,\n offsetHeight: section.offsetHeight,\n })\n );\n\n const currentSection = sectionsData.find(\n (section) =>\n section.offsetTop <= scrollY + window.screen.height / 4 &&\n section.offsetTop + section.offsetHeight >\n scrollY + window.screen.height / 4\n );\n\n if (currentSection) {\n setActiveSection(currentSection.id);\n }\n };\n\n useEffect(() => {\n window.addEventListener('scroll', detectActiveSection);\n\n return () => {\n window.removeEventListener('scroll', detectActiveSection);\n };\n }, []);\n\n const onClickLogo = (onClick: (url: string) => void) => {\n setActiveSection(null);\n\n if (window.location.pathname === '/') {\n window.scrollTo({ top: 0, behavior: 'smooth' });\n } else {\n onClick('/');\n }\n };\n\n const onClickSection = (\n sectionId: string,\n url?: string,\n onClick?: () => void\n ) => {\n setActiveSection(sectionId);\n\n if (window.location.pathname === url) {\n const sectionEl = document.getElementById(sectionId);\n\n if (sectionEl) {\n sectionEl.scrollIntoView({\n behavior: 'smooth',\n block: 'center',\n inline: 'nearest',\n });\n }\n } else {\n onClick?.();\n }\n };\n\n return { activeSection, onClickLogo, onClickSection };\n};\n"],"names":[],"mappings":";;AAUO,MAAM,gBAAgB,MAAM;AACjC,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAwB,IAAI;AAEtE,QAAM,sBAAsB,MAAM;AAChC,UAAM,UAAU,OAAO;AACjB,UAAA,WAAW,SAAS,iBAAiB,SAAS;AACpD,UAAM,eAA8B,CAAC;AAE5B,aAAA;AAAA,MAAQ,CAAC,YAChB,aAAa,KAAK;AAAA,QAChB,IAAI,QAAQ;AAAA,QACZ,WAAW,QAAQ;AAAA,QACnB,cAAc,QAAQ;AAAA,MACvB,CAAA;AAAA,IACH;AAEA,UAAM,iBAAiB,aAAa;AAAA,MAClC,CAAC,YACC,QAAQ,aAAa,UAAU,OAAO,OAAO,SAAS,KACtD,QAAQ,YAAY,QAAQ,eAC1B,UAAU,OAAO,OAAO,SAAS;AAAA,IACvC;AAEA,QAAI,gBAAgB;AAClB,uBAAiB,eAAe,EAAE;AAAA,IAAA;AAAA,EAEtC;AAEA,YAAU,MAAM;AACP,WAAA,iBAAiB,UAAU,mBAAmB;AAErD,WAAO,MAAM;AACJ,aAAA,oBAAoB,UAAU,mBAAmB;AAAA,IAC1D;AAAA,EACF,GAAG,EAAE;AAEC,QAAA,cAAc,CAAC,YAAmC;AACtD,qBAAiB,IAAI;AAEjB,QAAA,OAAO,SAAS,aAAa,KAAK;AACpC,aAAO,SAAS,EAAE,KAAK,GAAG,UAAU,UAAU;AAAA,IAAA,OACzC;AACL,cAAQ,GAAG;AAAA,IAAA;AAAA,EAEf;AAEA,QAAM,iBAAiB,CACrB,WACA,KACA,YACG;AACH,qBAAiB,SAAS;AAEtB,QAAA,OAAO,SAAS,aAAa,KAAK;AAC9B,YAAA,YAAY,SAAS,eAAe,SAAS;AAEnD,UAAI,WAAW;AACb,kBAAU,eAAe;AAAA,UACvB,UAAU;AAAA,UACV,OAAO;AAAA,UACP,QAAQ;AAAA,QAAA,CACT;AAAA,MAAA;AAAA,IACH,OACK;AACK,gBAAA;AAAA,IAAA;AAAA,EAEd;AAEO,SAAA,EAAE,eAAe,aAAa,eAAe;AACtD;"}
1
+ {"version":3,"file":"useNavigation.mjs","sources":["../../../src/components/Navbar/useNavigation.ts"],"sourcesContent":["'use client';\n\nimport { useEffect, useState } from 'react';\n\ninterface SectionData {\n id: string;\n offsetTop: number;\n offsetHeight: number;\n}\n\nexport const useNavActions = () => {\n const [activeSection, setActiveSection] = useState<string | null>(null);\n\n const detectActiveSection = () => {\n const scrollY = window.scrollY;\n const sections = document.querySelectorAll('section');\n const sectionsData: SectionData[] = [];\n\n sections.forEach((section) =>\n sectionsData.push({\n id: section.id,\n offsetTop: section.offsetTop,\n offsetHeight: section.offsetHeight,\n })\n );\n\n const currentSection = sectionsData.find(\n (section) =>\n section.offsetTop <= scrollY + window.screen.height / 4 &&\n section.offsetTop + section.offsetHeight >\n scrollY + window.screen.height / 4\n );\n\n if (currentSection) {\n setActiveSection(currentSection.id);\n }\n };\n\n useEffect(() => {\n window.addEventListener('scroll', detectActiveSection, { passive: true });\n\n return () => {\n window.removeEventListener('scroll', detectActiveSection);\n };\n }, []);\n\n const onClickLogo = (onClick: (url: string) => void) => {\n setActiveSection(null);\n\n if (window.location.pathname === '/') {\n window.scrollTo({ top: 0, behavior: 'smooth' });\n } else {\n onClick('/');\n }\n };\n\n const onClickSection = (\n sectionId: string,\n url?: string,\n onClick?: () => void\n ) => {\n setActiveSection(sectionId);\n\n if (window.location.pathname === url) {\n const sectionEl = document.getElementById(sectionId);\n\n if (sectionEl) {\n sectionEl.scrollIntoView({\n behavior: 'smooth',\n block: 'center',\n inline: 'nearest',\n });\n }\n } else {\n onClick?.();\n }\n };\n\n return { activeSection, onClickLogo, onClickSection };\n};\n"],"names":[],"mappings":";;AAUO,MAAM,gBAAgB,MAAM;AACjC,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAAwB,IAAI;AAEtE,QAAM,sBAAsB,MAAM;AAChC,UAAM,UAAU,OAAO;AACjB,UAAA,WAAW,SAAS,iBAAiB,SAAS;AACpD,UAAM,eAA8B,CAAC;AAE5B,aAAA;AAAA,MAAQ,CAAC,YAChB,aAAa,KAAK;AAAA,QAChB,IAAI,QAAQ;AAAA,QACZ,WAAW,QAAQ;AAAA,QACnB,cAAc,QAAQ;AAAA,MACvB,CAAA;AAAA,IACH;AAEA,UAAM,iBAAiB,aAAa;AAAA,MAClC,CAAC,YACC,QAAQ,aAAa,UAAU,OAAO,OAAO,SAAS,KACtD,QAAQ,YAAY,QAAQ,eAC1B,UAAU,OAAO,OAAO,SAAS;AAAA,IACvC;AAEA,QAAI,gBAAgB;AAClB,uBAAiB,eAAe,EAAE;AAAA,IAAA;AAAA,EAEtC;AAEA,YAAU,MAAM;AACd,WAAO,iBAAiB,UAAU,qBAAqB,EAAE,SAAS,MAAM;AAExE,WAAO,MAAM;AACJ,aAAA,oBAAoB,UAAU,mBAAmB;AAAA,IAC1D;AAAA,EACF,GAAG,EAAE;AAEC,QAAA,cAAc,CAAC,YAAmC;AACtD,qBAAiB,IAAI;AAEjB,QAAA,OAAO,SAAS,aAAa,KAAK;AACpC,aAAO,SAAS,EAAE,KAAK,GAAG,UAAU,UAAU;AAAA,IAAA,OACzC;AACL,cAAQ,GAAG;AAAA,IAAA;AAAA,EAEf;AAEA,QAAM,iBAAiB,CACrB,WACA,KACA,YACG;AACH,qBAAiB,SAAS;AAEtB,QAAA,OAAO,SAAS,aAAa,KAAK;AAC9B,YAAA,YAAY,SAAS,eAAe,SAAS;AAEnD,UAAI,WAAW;AACb,kBAAU,eAAe;AAAA,UACvB,UAAU;AAAA,UACV,OAAO;AAAA,UACP,QAAQ;AAAA,QAAA,CACT;AAAA,MAAA;AAAA,IACH,OACK;AACK,gBAAA;AAAA,IAAA;AAAA,EAEd;AAEO,SAAA,EAAE,eAAe,aAAa,eAAe;AACtD;"}
@@ -1 +1 @@
1
- {"version":3,"file":"PressableSpan.cjs","sources":["../../../src/components/PressableSpan/PressableSpan.tsx"],"sourcesContent":["'use client';\n\nimport {\n useEffect,\n useState,\n useRef,\n useCallback,\n type FC,\n type MouseEventHandler,\n type HTMLAttributes,\n} from 'react';\nimport { cn } from '../../utils/cn';\n\nconst DEFAULT_PRESS_DETECT_DURATION = 400;\n\ntype PressableDivProps = {\n onPress: () => void;\n onClickOutside?: () => void;\n pressDuration?: number;\n isSelecting?: boolean;\n} & HTMLAttributes<HTMLDivElement>;\n\nexport const PressableSpan: FC<PressableDivProps> = ({\n children,\n onPress: onSelect,\n onClickOutside: onUnselect,\n pressDuration = DEFAULT_PRESS_DETECT_DURATION,\n isSelecting: isSelectingProp,\n ...props\n}) => {\n const divRef = useRef<HTMLDivElement>(null);\n const [isSelectingState, setIsSelectingState] = useState(isSelectingProp);\n const pressTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const handleOnLongPress = () => {\n setIsSelectingState(true);\n onSelect();\n };\n\n const startPressTimer = () => {\n pressTimerRef.current = setTimeout(() => {\n handleOnLongPress();\n }, pressDuration);\n };\n\n const clearPressTimer = () => {\n if (pressTimerRef.current) {\n clearTimeout(pressTimerRef.current);\n pressTimerRef.current = null;\n }\n };\n\n const handleMouseDown = () => {\n clearPressTimer(); // Ensure any previous timer is cleared\n startPressTimer();\n };\n\n const handleMouseUp = () => {\n clearPressTimer();\n };\n\n // Use useCallback to ensure the function identity remains stable\n const handleClickOutside = useCallback(\n (event: MouseEvent) => {\n if (divRef.current && !divRef.current.contains(event.target as Node)) {\n setIsSelectingState(false);\n onUnselect?.();\n }\n },\n [onUnselect]\n );\n\n useEffect(() => {\n // Attach click outside listener\n document.addEventListener('mousedown', handleClickOutside);\n\n return () => {\n // Cleanup\n document.removeEventListener('mousedown', handleClickOutside);\n // clearPressTimer(); // Ensure to clear the timer when component unmounts\n };\n }, [handleClickOutside]);\n\n const handleOnClick: MouseEventHandler<HTMLDivElement> = (e) => {\n if (isSelectingState) {\n e.preventDefault();\n e.stopPropagation();\n }\n };\n\n const handleOnBlur = () => {\n // Stop editing when the element loses focus\n setIsSelectingState(false);\n };\n\n return (\n <span\n className={cn(\n 'inline cursor-pointer select-none rounded-md outline outline-2 outline-offset-4 outline-transparent transition-all delay-100 duration-200',\n (isSelectingProp ?? isSelectingState)\n ? 'outline-inherit'\n : 'hover:outline-inherit'\n )}\n role=\"button\"\n tabIndex={0}\n onKeyUp={() => null}\n onClick={handleOnClick}\n onMouseDown={handleMouseDown}\n onMouseUp={handleMouseUp}\n onMouseLeave={handleMouseUp}\n onTouchStart={handleMouseDown}\n onTouchEnd={handleMouseUp}\n onTouchCancel={handleMouseUp}\n onBlur={handleOnBlur}\n ref={divRef}\n {...props}\n >\n {children}\n </span>\n );\n};\n"],"names":["useRef","useState","useCallback","useEffect","jsx","cn"],"mappings":";;;;;;AAaA,MAAM,gCAAgC;AAS/B,MA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SAAAC,2BAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWC,SAAA;AAAA,QACT;AAAA,QACC,mBAAmB,mBAChB,oBACA;AAAA,MACN;AAAA,MACA,MAAK;AAAA,MACL,UAAU;AAAA,MACV,SAAS,MAAM;AAAA,MACf,SAAS;AAAA,MACT,aAAa;AAAA,MACb,WAAW;AAAA,MACX,cAAc;AAAA,MACd,cAAc;AAAA,MACd,YAAY;AAAA,MACZ,eAAe;AAAA,MACf,QAAQ;AAAA,MACR,KAAK;AAAA,MACJ,GAAG;AAAA,MAEH;AAAA,IAAA;AAAA,EACH;AAEJ;;"}
1
+ {"version":3,"file":"PressableSpan.cjs","sources":["../../../src/components/PressableSpan/PressableSpan.tsx"],"sourcesContent":["'use client';\n\nimport {\n useCallback,\n useEffect,\n useRef,\n useState,\n type FC,\n type HTMLAttributes,\n type MouseEventHandler,\n} from 'react';\nimport { cn } from '../../utils/cn';\n\nconst DEFAULT_PRESS_DETECT_DURATION = 400;\n\ntype PressableDivProps = {\n onPress: () => void;\n onClickOutside?: () => void;\n pressDuration?: number;\n isSelecting?: boolean;\n} & HTMLAttributes<HTMLDivElement>;\n\nexport const PressableSpan: FC<PressableDivProps> = ({\n children,\n onPress: onSelect,\n onClickOutside: onUnselect,\n pressDuration = DEFAULT_PRESS_DETECT_DURATION,\n isSelecting: isSelectingProp,\n ...props\n}) => {\n const divRef = useRef<HTMLDivElement>(null);\n const [isSelectingState, setIsSelectingState] = useState(isSelectingProp);\n const pressTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const handleOnLongPress = () => {\n setIsSelectingState(true);\n onSelect();\n };\n\n const startPressTimer = () => {\n pressTimerRef.current = setTimeout(() => {\n handleOnLongPress();\n }, pressDuration);\n };\n\n const clearPressTimer = () => {\n if (pressTimerRef.current) {\n clearTimeout(pressTimerRef.current);\n pressTimerRef.current = null;\n }\n };\n\n const handleMouseDown = () => {\n clearPressTimer(); // Ensure any previous timer is cleared\n startPressTimer();\n };\n\n const handleMouseUp = () => {\n clearPressTimer();\n };\n\n // Use useCallback to ensure the function identity remains stable\n const handleClickOutside = useCallback(\n (event: MouseEvent) => {\n if (divRef.current && !divRef.current.contains(event.target as Node)) {\n setIsSelectingState(false);\n onUnselect?.();\n }\n },\n [onUnselect]\n );\n\n useEffect(() => {\n // Attach click outside listener\n document.addEventListener('mousedown', handleClickOutside);\n\n return () => {\n // Cleanup\n document.removeEventListener('mousedown', handleClickOutside);\n // clearPressTimer(); // Ensure to clear the timer when component unmounts\n };\n }, [handleClickOutside]);\n\n const handleOnClick: MouseEventHandler<HTMLDivElement> = (e) => {\n if (isSelectingState) {\n e.preventDefault();\n e.stopPropagation();\n }\n };\n\n const handleOnBlur = () => {\n // Stop editing when the element loses focus\n setIsSelectingState(false);\n };\n\n return (\n <span\n className={cn(\n 'inline cursor-pointer select-none rounded-md outline outline-2 outline-offset-4 outline-transparent transition-all delay-100 duration-200',\n (isSelectingProp ?? isSelectingState)\n ? 'outline-inherit'\n : 'hover:outline-inherit'\n )}\n role=\"button\"\n tabIndex={0}\n onKeyUp={() => null}\n onClick={handleOnClick}\n onMouseDown={handleMouseDown}\n onMouseUp={handleMouseUp}\n onMouseLeave={handleMouseUp}\n onTouchStart={handleMouseDown}\n onTouchEnd={handleMouseUp}\n onTouchCancel={handleMouseUp}\n onBlur={handleOnBlur}\n ref={divRef}\n {...props}\n >\n {children}\n </span>\n );\n};\n"],"names":["useRef","useState","useCallback","useEffect","jsx","cn"],"mappings":";;;;;;AAaA,MAAM,gCAAgC;AAS/B,MAAM,gBAAuC,CAAC;AAAA,EACnD;AAAA,EACA,SAAS;AAAA,EACT,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,aAAa;AAAA,EACb,GAAG;AACL,MAAM;AACE,QAAA,SAASA,oBAAuB,IAAI;AAC1C,QAAM,CAAC,kBAAkB,mBAAmB,IAAIC,aAAAA,SAAS,eAAe;AAClE,QAAA,gBAAgBD,oBAA6C,IAAI;AAE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d,YAAY;AAAA,MACZ,eAAe;AAAA,MACf,QAAQ;AAAA,MACR,KAAK;AAAA,MACJ,GAAG;AAAA,MAEH;AAAA,IAAA;AAAA,EACH;AAEJ;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"PressableSpan.d.ts","sourceRoot":"","sources":["../../../src/components/PressableSpan/PressableSpan.tsx"],"names":[],"mappings":"AAEA,OAAO,EAKL,KAAK,EAAE,EAEP,KAAK,cAAc,EACpB,MAAM,OAAO,CAAC;AAKf,KAAK,iBAAiB,GAAG;IACvB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,GAAG,cAAc,CAAC,cAAc,CAAC,CAAC;AAEnC,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC,iBAAiB,CAkG/C,CAAC"}
1
+ {"version":3,"file":"PressableSpan.d.ts","sourceRoot":"","sources":["../../../src/components/PressableSpan/PressableSpan.tsx"],"names":[],"mappings":"AAEA,OAAO,EAKL,KAAK,EAAE,EACP,KAAK,cAAc,EAEpB,MAAM,OAAO,CAAC;AAKf,KAAK,iBAAiB,GAAG;IACvB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,GAAG,cAAc,CAAC,cAAc,CAAC,CAAC;AAEnC,eAAO,MAAM,aAAa,EAAE,EAAE,CAAC,iBAAiB,CAkG/C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"PressableSpan.mjs","sources":["../../../src/components/PressableSpan/PressableSpan.tsx"],"sourcesContent":["'use client';\n\nimport {\n useEffect,\n useState,\n useRef,\n useCallback,\n type FC,\n type MouseEventHandler,\n type HTMLAttributes,\n} from 'react';\nimport { cn } from '../../utils/cn';\n\nconst DEFAULT_PRESS_DETECT_DURATION = 400;\n\ntype PressableDivProps = {\n onPress: () => void;\n onClickOutside?: () => void;\n pressDuration?: number;\n isSelecting?: boolean;\n} & HTMLAttributes<HTMLDivElement>;\n\nexport const PressableSpan: FC<PressableDivProps> = ({\n children,\n onPress: onSelect,\n onClickOutside: onUnselect,\n pressDuration = DEFAULT_PRESS_DETECT_DURATION,\n isSelecting: isSelectingProp,\n ...props\n}) => {\n const divRef = useRef<HTMLDivElement>(null);\n const [isSelectingState, setIsSelectingState] = useState(isSelectingProp);\n const pressTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const handleOnLongPress = () => {\n setIsSelectingState(true);\n onSelect();\n };\n\n const startPressTimer = () => {\n pressTimerRef.current = setTimeout(() => {\n handleOnLongPress();\n }, pressDuration);\n };\n\n const clearPressTimer = () => {\n if (pressTimerRef.current) {\n clearTimeout(pressTimerRef.current);\n pressTimerRef.current = null;\n }\n };\n\n const handleMouseDown = () => {\n clearPressTimer(); // Ensure any previous timer is cleared\n startPressTimer();\n };\n\n const handleMouseUp = () => {\n clearPressTimer();\n };\n\n // Use useCallback to ensure the function identity remains stable\n const handleClickOutside = useCallback(\n (event: MouseEvent) => {\n if (divRef.current && !divRef.current.contains(event.target as Node)) {\n setIsSelectingState(false);\n onUnselect?.();\n }\n },\n [onUnselect]\n );\n\n useEffect(() => {\n // Attach click outside listener\n document.addEventListener('mousedown', handleClickOutside);\n\n return () => {\n // Cleanup\n document.removeEventListener('mousedown', handleClickOutside);\n // clearPressTimer(); // Ensure to clear the timer when component unmounts\n };\n }, [handleClickOutside]);\n\n const handleOnClick: MouseEventHandler<HTMLDivElement> = (e) => {\n if (isSelectingState) {\n e.preventDefault();\n e.stopPropagation();\n }\n };\n\n const handleOnBlur = () => {\n // Stop editing when the element loses focus\n setIsSelectingState(false);\n };\n\n return (\n <span\n className={cn(\n 'inline cursor-pointer select-none rounded-md outline outline-2 outline-offset-4 outline-transparent transition-all delay-100 duration-200',\n (isSelectingProp ?? isSelectingState)\n ? 'outline-inherit'\n : 'hover:outline-inherit'\n )}\n role=\"button\"\n tabIndex={0}\n onKeyUp={() => null}\n onClick={handleOnClick}\n onMouseDown={handleMouseDown}\n onMouseUp={handleMouseUp}\n onMouseLeave={handleMouseUp}\n onTouchStart={handleMouseDown}\n onTouchEnd={handleMouseUp}\n onTouchCancel={handleMouseUp}\n onBlur={handleOnBlur}\n ref={divRef}\n {...props}\n >\n {children}\n </span>\n );\n};\n"],"names":[],"mappings":";;;;AAaA,MAAM,gCAAgC;AAS/B,MAAM,gBAAuC,CAAC;AAAA,EACnD;AAAA,EACA,SAAS;AAAA,EACT,gBAAgB;AAAA,EAChB,gBAAgB;AAAA,EAChB,aAAa;AAAA,EACb,GAAG;AACL,MAAM;AACE,QAAA,SAAS,OAAuB,IAAI;AAC1C,QAAM,CAAC,kBAAkB,mBAAmB,IAAI,SAAS,eAAe;AAClE,QAAA,gBAAgB,OAA6C,IAAI;AAEvE,QAAM,oBAAoB,MAAM;AAC9B,wBAAoB,IAAI;AACf,aAAA;AAAA,EACX;AAEA,QAAM,kBAAkB,MAAM;AACd,kBAAA,UAAU,WAAW,MAAM;AACrB,wBAAA;AAAA,OACjB,aAAa;AAAA,EAClB;AAEA,QAAM,kBAAkB,MAAM;AAC5B,QAAI,cAAc,SAAS;AACzB,mBAAa,cAAc,OAAO;AAClC,oBAAc,UAAU;AAAA,IAAA;AAAA,EAE5B;AAEA,QAAM,kBAAkB,MAAM;AACZ,oBAAA;AACA,oBAAA;AAAA,EAClB;AAEA,QAAM,gBAAgB,MAAM;AACV,oBAAA;AAAA,EAClB;AAGA,QAAM,qBAAqB;AAAA,IACzB,CAAC,UAAsB;AACjB,UAAA,OAAO,WAAW,CAAC,OAAO,QAAQ,SAAS,MAAM,MAAc,GAAG;AACpE,4BAAoB,KAAK;AACZ,qBAAA;AAAA,MAAA;AAAA,IAEjB;AAAA,IACA,CAAC,UAAU;AAAA,EACb;AAEA,YAAU,MAAM;AAEL,aAAA,iBAAiB,aAAa,kBAAkB;AAEzD,WAAO,MAAM;AAEF,eAAA,oBAAoB,aAAa,kBAAkB;AAAA,IAE9D;AAAA,EAAA,GACC,CAAC,kBAAkB,CAAC;AAEjB,QAAA,gBAAmD,CAAC,MAAM;AAC9D,QAAI,kBAAkB;AACpB,QAAE,eAAe;AACjB,QAAE,gBAAgB;AAAA,IAAA;AAAA,EAEtB;AAEA,QAAM,eAAe,MAAM;AAEzB,wBAAoB,KAAK;AAAA,EAC3B;AAGE,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACC,mBAAmB,mBAChB,oBACA;AAAA,MACN;AAAA,MACA,MAAK;AAAA,MACL,UAAU;AAAA,MACV,SAAS,MAAM;AAAA,MACf,SAAS;AAAA,MACT,aAAa;AAAA,MACb,WAAW;AAAA,MACX,cAAc;AAAA,MACd,cAAc;AAAA,MACd,YAAY;AAAA,MACZ,eAAe;AAAA,MACf,QAAQ;AAAA,MACR,KAAK;AAAA,MACJ,GAAG;AAAA,MAEH;AAAA,IAAA;AAAA,EACH;AAEJ;"}
1
+ {"version":3,"file":"PressableSpan.mjs","sources":["../../../src/components/PressableSpan/PressableSpan.tsx"],"sourcesContent":["'use client';\n\nimport {\n useCallback,\n useEffect,\n useRef,\n useState,\n type FC,\n type HTMLAttributes,\n type MouseEventHandler,\n} from 'react';\nimport { cn } from '../../utils/cn';\n\nconst DEFAULT_PRESS_DETECT_DURATION = 400;\n\ntype PressableDivProps = {\n onPress: () => void;\n onClickOutside?: () => void;\n pressDuration?: number;\n isSelecting?: boolean;\n} & HTMLAttributes<HTMLDivElement>;\n\nexport const PressableSpan: FC<PressableDivProps> = ({\n children,\n onPress: onSelect,\n onClickOutside: onUnselect,\n pressDuration = DEFAULT_PRESS_DETECT_DURATION,\n isSelecting: isSelectingProp,\n ...props\n}) => {\n const divRef = useRef<HTMLDivElement>(null);\n const [isSelectingState, setIsSelectingState] = useState(isSelectingProp);\n const pressTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const handleOnLongPress = () => {\n setIsSelectingState(true);\n onSelect();\n };\n\n const startPressTimer = () => {\n pressTimerRef.current = setTimeout(() => {\n handleOnLongPress();\n }, pressDuration);\n };\n\n const clearPressTimer = () => {\n if (pressTimerRef.current) {\n clearTimeout(pressTimerRef.current);\n pressTimerRef.current = null;\n }\n };\n\n const handleMouseDown = () => {\n clearPressTimer(); // Ensure any previous timer is cleared\n startPressTimer();\n };\n\n const handleMouseUp = () => {\n clearPressTimer();\n };\n\n // Use useCallback to ensure the function identity remains stable\n const handleClickOutside = useCallback(\n (event: MouseEvent) => {\n if (divRef.current && !divRef.current.contains(event.target as Node)) {\n setIsSelectingState(false);\n onUnselect?.();\n }\n },\n [onUnselect]\n );\n\n useEffect(() => {\n // Attach click outside listener\n document.addEventListener('mousedown', handleClickOutside);\n\n return () => {\n // Cleanup\n document.removeEventListener('mousedown', handleClickOutside);\n // clearPressTimer(); // Ensure to clear the timer when component unmounts\n };\n }, [handleClickOutside]);\n\n const handleOnClick: MouseEventHandler<HTMLDivElement> = (e) => {\n if (isSelectingState) {\n e.preventDefault();\n e.stopPropagation();\n }\n };\n\n const handleOnBlur = () => {\n // Stop editing when the element loses focus\n setIsSelectingState(false);\n };\n\n return (\n <span\n className={cn(\n 'inline cursor-pointer select-none rounded-md outline outline-2 outline-offset-4 outline-transparent transition-all delay-100 duration-200',\n (isSelectingProp ?? isSelectingState)\n ? 'outline-inherit'\n : 'hover:outline-inherit'\n )}\n role=\"button\"\n tabIndex={0}\n onKeyUp={() => null}\n onClick={handleOnClick}\n onMouseDown={handleMouseDown}\n onMouseUp={handleMouseUp}\n onMouseLeave={handleMouseUp}\n onTouchStart={handleMouseDown}\n onTouchEnd={handleMouseUp}\n onTouchCancel={handleMouseUp}\n onBlur={handleOnBlur}\n ref={divRef}\n {...props}\n >\n {children}\n </span>\n );\n};\n"],"names":[],"mappings":";;;;AAa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AAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACC,mBAAmB,mBAChB,oBACA;AAAA,MACN;AAAA,MACA,MAAK;AAAA,MACL,UAAU;AAAA,MACV,SAAS,MAAM;AAAA,MACf,SAAS;AAAA,MACT,aAAa;AAAA,MACb,WAAW;AAAA,MACX,cAAc;AAAA,MACd,cAAc;AAAA,MACd,YAAY;AAAA,MACZ,eAAe;AAAA,MACf,QAAQ;AAAA,MACR,KAAK;AAAA,MACJ,GAAG;AAAA,MAEH;AAAA,IAAA;AAAA,EACH;AAEJ;"}
@@ -1 +1 @@
1
- {"version":3,"file":"RightDrawer.cjs","sources":["../../../src/components/RightDrawer/RightDrawer.tsx"],"sourcesContent":["/* eslint-disable jsx-a11y/no-static-element-interactions */\n/* eslint-disable jsx-a11y/click-events-have-key-events */\n'use client';\n\nimport { ChevronLeft, X } from 'lucide-react';\nimport {\n type ReactNode,\n type FC,\n type MouseEventHandler,\n useEffect,\n useRef,\n} from 'react';\nimport { useShallow } from 'zustand/react/shallow';\nimport { useDevice } from '../../hooks/useDevice';\nimport { useScrollBlockage } from '../../hooks/useScrollBlockage';\nimport { isElementAtTopAndNotCovered } from '../../utils/isElementAtTopAndNotCovered';\nimport { Button } from '../Button';\nimport { Container } from '../Container';\nimport { MaxWidthSmoother } from '../MaxWidthSmoother/index';\nimport { useRightDrawerStore } from './useRightDrawerStore';\n\ntype BackButtonProps = {\n onBack: () => void;\n text?: string;\n};\n\ntype RightDrawerProps = {\n title?: ReactNode;\n identifier: string;\n children?: ReactNode;\n header?: ReactNode;\n closeOnOutsideClick?: boolean;\n backButton?: BackButtonProps;\n isOpen?: boolean;\n onClose?: () => void;\n};\n\nexport const RightDrawer: FC<RightDrawerProps> = ({\n title,\n identifier,\n children,\n header,\n closeOnOutsideClick = true,\n backButton,\n isOpen: isOpenProp,\n onClose,\n}) => {\n const { isMobile } = useDevice('md');\n const panelRef = useRef<HTMLDivElement>(null);\n const childrenContainerRef = useRef<HTMLDivElement>(null);\n const { close, open, isOpen } = useRightDrawerStore(\n useShallow((s) => ({\n close: () => s.close(identifier),\n open: () => s.open(identifier),\n isOpen: s.isOpen(identifier),\n }))\n );\n\n useScrollBlockage({\n disableScroll: isOpen,\n key: identifier ? `right_drawer_${identifier}` : 'right_drawer',\n });\n\n useEffect(() => {\n const handleClickOutside = (event: MouseEvent) => {\n try {\n if (!panelRef.current) return;\n\n // Check if drawer is open and click outside is enabled\n const isClickAble = isOpen && closeOnOutsideClick;\n\n // Check if click is outside the drawer panel\n const isClickOutside =\n event.target && !panelRef.current.contains(event.target as Node);\n\n // Check if event propagation has been stopped\n const isAtTopAndVisible = isElementAtTopAndNotCovered(panelRef.current);\n\n if (\n (isClickAble && isClickOutside && isAtTopAndVisible) ||\n !event.target\n ) {\n close();\n onClose?.();\n }\n } catch (_e) {\n close();\n onClose?.();\n }\n };\n\n window.addEventListener('mousedown', handleClickOutside);\n return () => window.removeEventListener('mousedown', handleClickOutside);\n }, [isOpen, close, onClose, closeOnOutsideClick, identifier]); // Make sure the effect runs only if isOpen or close changes\n\n useEffect(() => {\n if (isOpenProp !== undefined) {\n if (isOpenProp) {\n open();\n } else {\n close();\n onClose?.();\n }\n }\n }, [close, open, onClose, isOpenProp, identifier]);\n\n const handleSpareSpaceClick: MouseEventHandler<HTMLDivElement> = (e) => {\n // Check if the click trigger the background\n if (e.target !== e.currentTarget) {\n return;\n }\n\n if (isMobile) {\n close();\n onClose?.();\n }\n };\n\n return (\n <div className=\"fixed right-0 top-0 z-50 flex h-full justify-end\">\n <MaxWidthSmoother isHidden={!isOpen} align=\"right\">\n <Container\n className=\"text-text relative flex h-screen w-screen flex-col md:w-[400px]\"\n ref={panelRef}\n roundedSize=\"none\"\n >\n <div className=\"flex flex-col gap-3 p-6\">\n <div className=\"flex justify-between gap-3\">\n <div>\n {backButton && (\n <Button\n variant=\"hoverable\"\n color=\"text\"\n label={backButton.text ?? 'Go back'}\n onClick={backButton.onBack}\n Icon={ChevronLeft}\n >\n {backButton?.text}\n </Button>\n )}\n </div>\n <div>\n <Button\n variant=\"hoverable\"\n color=\"text\"\n label=\"Close\"\n className=\"ml-auto\"\n onClick={close}\n Icon={X}\n size=\"icon-md\"\n />\n </div>\n </div>\n {title && (\n <h2 className=\"flex items-center justify-center text-lg font-bold\">\n {title}\n </h2>\n )}\n {header}\n </div>\n\n <div className=\"flex h-full flex-col overflow-y-auto p-2\">\n <div\n className=\"flex flex-1 flex-col\"\n onClick={handleSpareSpaceClick}\n ref={childrenContainerRef}\n >\n {children}\n </div>\n </div>\n </Container>\n </MaxWidthSmoother>\n </div>\n );\n};\n"],"names":["useDevice","useRef","useRightDrawerStore","useShallow","useScrollBlockage","useEffect","isElementAtTopAndNotCovered","jsx","MaxWidthSmoother","jsxs","Container","Button","ChevronLeft","X"],"mappings":";;;;;;;;;;;;;AAqCO,MAAM,cAAoC,CAAC;AAAA,EAChD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,sBAAsB;AAAA,EACtB;AAAA,EACA,QAAQ;AAAA,EACR;AACF,MAAM;AACJ,QAAM,EAAE,SAAA,IAAaA,gBAAA,UAAU,IAAI;AAC7B,QAAA,WAAWC,oBAAuB,IAAI;AACtC,QAAA,uBAAuBA,oBAAuB,IAAI;AACxD,QAAM,EAAE,OAAO,MAAM,OAAW,IAAAC,2CAAA;AAAA,IAC9BC,8BAAA,WAAW,CAAC,OAAO;AAAA,MACjB,OAAO,MAAM,EAAE,MAAM,UAAU;AAAA,MAC/B,MAAM,MAAM,EAAE,KAAK,UAAU;AAAA,MAC7B,QAAQ,EAAE,OAAO,UAAU;AAAA,IAAA,EAC3B;AAAA,EACJ;AAEkBC,kDAAA;AAAA,IAChB,eAAe;AAAA,IACf,KAAK,aAAa,gBAAgB,UAAU,KAAK;AAAA,EAAA,CAClD;AAEDC,eAAAA,UAAU,MAAM;AACR,UAAA,qBAAqB,CAAC,UAAsB;AAC5C,UAAA;AACE,YAAA,CAAC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AA;AAAA,gBACC,SAAQ;AAAA,gBACR,OAAM;AAAA,gBACN,OAAO,WAAW,QAAQ;AAAA,gBAC1B,SAAS,WAAW;AAAA,gBACpB,MAAMC,YAAA;AAAA,gBAEL,UAAY,YAAA;AAAA,cAAA;AAAA,YAAA,GAGnB;AAAA,2CACC,OACC,EAAA,UAAAL,2BAAA;AAAA,cAACI,yBAAA;AAAA,cAAA;AAAA,gBACC,SAAQ;AAAA,gBACR,OAAM;AAAA,gBACN,OAAM;AAAA,gBACN,WAAU;AAAA,gBACV,SAAS;AAAA,gBACT,MAAME,YAAA;AAAA,gBACN,MAAK;AAAA,cAAA;AAAA,YAAA,EAET,CAAA;AAAA,UAAA,GACF;AAAA,UACC,SACCN,2BAAA,IAAC,MAAG,EAAA,WAAU,sDACX,UACH,OAAA;AAAA,UAED;AAAA,QAAA,GACH;AAAA,QAEAA,2BAAAA,IAAC,OAAI,EAAA,WAAU,4CACb,UAAAA,2BAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAU;AAAA,YACV,SAAS;AAAA,YACT,KAAK;AAAA,YAEJ;AAAA,UAAA;AAAA,QAAA,EAEL,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,KAEJ,EACF,CAAA;AAEJ;;"}
1
+ {"version":3,"file":"RightDrawer.cjs","sources":["../../../src/components/RightDrawer/RightDrawer.tsx"],"sourcesContent":["'use client';\n\nimport { ChevronLeft, X } from 'lucide-react';\nimport {\n type FC,\n type MouseEventHandler,\n type ReactNode,\n useEffect,\n useRef,\n} from 'react';\nimport { useShallow } from 'zustand/react/shallow';\nimport { useDevice } from '../../hooks/useDevice';\nimport { useScrollBlockage } from '../../hooks/useScrollBlockage';\nimport { isElementAtTopAndNotCovered } from '../../utils/isElementAtTopAndNotCovered';\nimport { Button } from '../Button';\nimport { Container } from '../Container';\nimport { MaxWidthSmoother } from '../MaxWidthSmoother/index';\nimport { useRightDrawerStore } from './useRightDrawerStore';\n\ntype BackButtonProps = {\n onBack: () => void;\n text?: string;\n};\n\ntype RightDrawerProps = {\n title?: ReactNode;\n identifier: string;\n children?: ReactNode;\n header?: ReactNode;\n closeOnOutsideClick?: boolean;\n backButton?: BackButtonProps;\n isOpen?: boolean;\n onClose?: () => void;\n};\n\nexport const RightDrawer: FC<RightDrawerProps> = ({\n title,\n identifier,\n children,\n header,\n closeOnOutsideClick = true,\n backButton,\n isOpen: isOpenProp,\n onClose,\n}) => {\n const { isMobile } = useDevice('md');\n const panelRef = useRef<HTMLDivElement>(null);\n const childrenContainerRef = useRef<HTMLDivElement>(null);\n const { close, open, isOpen } = useRightDrawerStore(\n useShallow((s) => ({\n close: () => s.close(identifier),\n open: () => s.open(identifier),\n isOpen: s.isOpen(identifier),\n }))\n );\n\n useScrollBlockage({\n disableScroll: isOpen,\n key: identifier ? `right_drawer_${identifier}` : 'right_drawer',\n });\n\n useEffect(() => {\n const handleClickOutside = (event: MouseEvent) => {\n try {\n if (!panelRef.current) return;\n\n // Check if drawer is open and click outside is enabled\n const isClickAble = isOpen && closeOnOutsideClick;\n\n // Check if click is outside the drawer panel\n const isClickOutside =\n event.target && !panelRef.current.contains(event.target as Node);\n\n // Check if event propagation has been stopped\n const isAtTopAndVisible = isElementAtTopAndNotCovered(panelRef.current);\n\n if (\n (isClickAble && isClickOutside && isAtTopAndVisible) ||\n !event.target\n ) {\n close();\n onClose?.();\n }\n } catch (_e) {\n close();\n onClose?.();\n }\n };\n\n window.addEventListener('mousedown', handleClickOutside);\n return () => window.removeEventListener('mousedown', handleClickOutside);\n }, [isOpen, close, onClose, closeOnOutsideClick, identifier]); // Make sure the effect runs only if isOpen or close changes\n\n useEffect(() => {\n if (isOpenProp !== undefined) {\n if (isOpenProp) {\n open();\n } else {\n close();\n onClose?.();\n }\n }\n }, [close, open, onClose, isOpenProp, identifier]);\n\n const handleSpareSpaceClick: MouseEventHandler<HTMLDivElement> = (e) => {\n // Check if the click trigger the background\n if (e.target !== e.currentTarget) {\n return;\n }\n\n if (isMobile) {\n close();\n onClose?.();\n }\n };\n\n return (\n <div className=\"fixed right-0 top-0 z-50 flex h-full justify-end\">\n <MaxWidthSmoother isHidden={!isOpen} align=\"right\">\n <Container\n className=\"text-text relative flex h-screen w-screen flex-col md:w-[400px]\"\n ref={panelRef}\n roundedSize=\"none\"\n >\n <div className=\"flex flex-col gap-3 p-6\">\n <div className=\"flex justify-between gap-3\">\n <div>\n {backButton && (\n <Button\n variant=\"hoverable\"\n color=\"text\"\n label={backButton.text ?? 'Go back'}\n onClick={backButton.onBack}\n Icon={ChevronLeft}\n >\n {backButton?.text}\n </Button>\n )}\n </div>\n <div>\n <Button\n variant=\"hoverable\"\n color=\"text\"\n label=\"Close\"\n className=\"ml-auto\"\n onClick={close}\n Icon={X}\n size=\"icon-md\"\n />\n </div>\n </div>\n {title && (\n <h2 className=\"flex items-center justify-center text-lg font-bold\">\n {title}\n </h2>\n )}\n {header}\n </div>\n\n <div className=\"flex h-full flex-col overflow-y-auto p-2\">\n <div\n className=\"flex flex-1 flex-col\"\n onClick={handleSpareSpaceClick}\n ref={childrenContainerRef}\n >\n {children}\n </div>\n </div>\n </Container>\n </MaxWidthSmoother>\n </div>\n );\n};\n"],"names":["useDevice","useRef","useRightDrawerStore","useShallow","useScrollBlockage","useEffect","isElementAtTopAndNotCovered","jsx","MaxWidthSmoother","jsxs","Container","Button","ChevronLeft","X"],"mappings":";;;;;;;;;;;;;AAmCO,MAAM,cAAoC,CAAC;AAAA,EAChD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,sBAAsB;AAAA,EACtB;AAAA,EACA,QAAQ;AAAA,EACR;AACF,MAAM;AACJ,QAAM,EAAE,SAAA,IAAaA,gBAAA,UAAU,IAAI;AAC7B,QAAA,WAAWC,oBAAuB,IAAI;AACtC,QAAA,uBAAuBA,oBAAuB,IAAI;AACxD,QAAM,EAAE,OAAO,MAAM,OAAW,IAAAC,2CAAA;AAAA,IAC9BC,8BAAA,WAAW,CAAC,OAAO;AAAA,MACjB,OA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Q,OAAM,SACzC,UAAAC,2BAAA;AAAA,IAACC,2BAAA;AAAA,IAAA;AAAA,MACC,WAAU;AAAA,MACV,KAAK;AAAA,MACL,aAAY;AAAA,MAEZ,UAAA;AAAA,QAACD,2BAAAA,KAAA,OAAA,EAAI,WAAU,2BACb,UAAA;AAAA,UAACA,2BAAAA,KAAA,OAAA,EAAI,WAAU,8BACb,UAAA;AAAA,YAAAF,2BAAAA,IAAC,SACE,UACC,cAAAA,2BAAA;AAAA,cAACI,yBAAA;AAAA,cAAA;AAAA,gBACC,SAAQ;AAAA,gBACR,OAAM;AAAA,gBACN,OAAO,WAAW,QAAQ;AAAA,gBAC1B,SAAS,WAAW;AAAA,gBACpB,MAAMC,YAAA;AAAA,gBAEL,UAAY,YAAA;AAAA,cAAA;AAAA,YAAA,GAGnB;AAAA,2CACC,OACC,EAAA,UAAAL,2BAAA;AAAA,cAACI,yBAAA;AAAA,cAAA;AAAA,gBACC,SAAQ;AAAA,gBACR,OAAM;AAAA,gBACN,OAAM;AAAA,gBACN,WAAU;AAAA,gBACV,SAAS;AAAA,gBACT,MAAME,YAAA;AAAA,gBACN,MAAK;AAAA,cAAA;AAAA,YAAA,EAET,CAAA;AAAA,UAAA,GACF;AAAA,UACC,SACCN,2BAAA,IAAC,MAAG,EAAA,WAAU,sDACX,UACH,OAAA;AAAA,UAED;AAAA,QAAA,GACH;AAAA,QAEAA,2BAAAA,IAAC,OAAI,EAAA,WAAU,4CACb,UAAAA,2BAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAU;AAAA,YACV,SAAS;AAAA,YACT,KAAK;AAAA,YAEJ;AAAA,UAAA;AAAA,QAAA,EAEL,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,KAEJ,EACF,CAAA;AAEJ;;"}
@@ -1,4 +1,4 @@
1
- import { ReactNode, FC } from 'react';
1
+ import { FC, ReactNode } from 'react';
2
2
  type BackButtonProps = {
3
3
  onBack: () => void;
4
4
  text?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"RightDrawer.d.ts","sourceRoot":"","sources":["../../../src/components/RightDrawer/RightDrawer.tsx"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,EAAE,EAIR,MAAM,OAAO,CAAC;AAUf,KAAK,eAAe,GAAG;IACrB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,KAAK,gBAAgB,GAAG;IACtB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,UAAU,CAAC,EAAE,eAAe,CAAC;IAC7B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CAyI5C,CAAC"}
1
+ {"version":3,"file":"RightDrawer.d.ts","sourceRoot":"","sources":["../../../src/components/RightDrawer/RightDrawer.tsx"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,EAAE,EAEP,KAAK,SAAS,EAGf,MAAM,OAAO,CAAC;AAUf,KAAK,eAAe,GAAG;IACrB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,KAAK,gBAAgB,GAAG;IACtB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,UAAU,CAAC,EAAE,eAAe,CAAC;IAC7B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CAyI5C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"RightDrawer.mjs","sources":["../../../src/components/RightDrawer/RightDrawer.tsx"],"sourcesContent":["/* eslint-disable jsx-a11y/no-static-element-interactions */\n/* eslint-disable jsx-a11y/click-events-have-key-events */\n'use client';\n\nimport { ChevronLeft, X } from 'lucide-react';\nimport {\n type ReactNode,\n type FC,\n type MouseEventHandler,\n useEffect,\n useRef,\n} from 'react';\nimport { useShallow } from 'zustand/react/shallow';\nimport { useDevice } from '../../hooks/useDevice';\nimport { useScrollBlockage } from '../../hooks/useScrollBlockage';\nimport { isElementAtTopAndNotCovered } from '../../utils/isElementAtTopAndNotCovered';\nimport { Button } from '../Button';\nimport { Container } from '../Container';\nimport { MaxWidthSmoother } from '../MaxWidthSmoother/index';\nimport { useRightDrawerStore } from './useRightDrawerStore';\n\ntype BackButtonProps = {\n onBack: () => void;\n text?: string;\n};\n\ntype RightDrawerProps = {\n title?: ReactNode;\n identifier: string;\n children?: ReactNode;\n header?: ReactNode;\n closeOnOutsideClick?: boolean;\n backButton?: BackButtonProps;\n isOpen?: boolean;\n onClose?: () => void;\n};\n\nexport const RightDrawer: FC<RightDrawerProps> = ({\n title,\n identifier,\n children,\n header,\n closeOnOutsideClick = true,\n backButton,\n isOpen: isOpenProp,\n onClose,\n}) => {\n const { isMobile } = useDevice('md');\n const panelRef = useRef<HTMLDivElement>(null);\n const childrenContainerRef = useRef<HTMLDivElement>(null);\n const { close, open, isOpen } = useRightDrawerStore(\n useShallow((s) => ({\n close: () => s.close(identifier),\n open: () => s.open(identifier),\n isOpen: s.isOpen(identifier),\n }))\n );\n\n useScrollBlockage({\n disableScroll: isOpen,\n key: identifier ? `right_drawer_${identifier}` : 'right_drawer',\n });\n\n useEffect(() => {\n const handleClickOutside = (event: MouseEvent) => {\n try {\n if (!panelRef.current) return;\n\n // Check if drawer is open and click outside is enabled\n const isClickAble = isOpen && closeOnOutsideClick;\n\n // Check if click is outside the drawer panel\n const isClickOutside =\n event.target && !panelRef.current.contains(event.target as Node);\n\n // Check if event propagation has been stopped\n const isAtTopAndVisible = isElementAtTopAndNotCovered(panelRef.current);\n\n if (\n (isClickAble && isClickOutside && isAtTopAndVisible) ||\n !event.target\n ) {\n close();\n onClose?.();\n }\n } catch (_e) {\n close();\n onClose?.();\n }\n };\n\n window.addEventListener('mousedown', handleClickOutside);\n return () => window.removeEventListener('mousedown', handleClickOutside);\n }, [isOpen, close, onClose, closeOnOutsideClick, identifier]); // Make sure the effect runs only if isOpen or close changes\n\n useEffect(() => {\n if (isOpenProp !== undefined) {\n if (isOpenProp) {\n open();\n } else {\n close();\n onClose?.();\n }\n }\n }, [close, open, onClose, isOpenProp, identifier]);\n\n const handleSpareSpaceClick: MouseEventHandler<HTMLDivElement> = (e) => {\n // Check if the click trigger the background\n if (e.target !== e.currentTarget) {\n return;\n }\n\n if (isMobile) {\n close();\n onClose?.();\n }\n };\n\n return (\n <div className=\"fixed right-0 top-0 z-50 flex h-full justify-end\">\n <MaxWidthSmoother isHidden={!isOpen} align=\"right\">\n <Container\n className=\"text-text relative flex h-screen w-screen flex-col md:w-[400px]\"\n ref={panelRef}\n roundedSize=\"none\"\n >\n <div className=\"flex flex-col gap-3 p-6\">\n <div className=\"flex justify-between gap-3\">\n <div>\n {backButton && (\n <Button\n variant=\"hoverable\"\n color=\"text\"\n label={backButton.text ?? 'Go back'}\n onClick={backButton.onBack}\n Icon={ChevronLeft}\n >\n {backButton?.text}\n </Button>\n )}\n </div>\n <div>\n <Button\n variant=\"hoverable\"\n color=\"text\"\n label=\"Close\"\n className=\"ml-auto\"\n onClick={close}\n Icon={X}\n size=\"icon-md\"\n />\n </div>\n </div>\n {title && (\n <h2 className=\"flex items-center justify-center text-lg font-bold\">\n {title}\n </h2>\n )}\n {header}\n </div>\n\n <div className=\"flex h-full flex-col overflow-y-auto p-2\">\n <div\n className=\"flex flex-1 flex-col\"\n onClick={handleSpareSpaceClick}\n ref={childrenContainerRef}\n >\n {children}\n </div>\n </div>\n </Container>\n </MaxWidthSmoother>\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;AAqCO,MAAM,cAAoC,CAAC;AAAA,EAChD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,sBAAsB;AAAA,EACtB;AAAA,EACA,QAAQ;AAAA,EACR;AACF,MAAM;AACJ,QAAM,EAAE,SAAA,IAAa,UAAU,IAAI;AAC7B,QAAA,WAAW,OAAuB,IAAI;AACtC,QAAA,uBAAuB,OAAuB,IAAI;AACxD,QAAM,EAAE,OAAO,MAAM,OAAW,IAAA;AAAA,IAC9B,WAAW,CAAC,OAAO;AAAA,MACjB,OAAO,MAAM,EAAE,MAAM,UAAU;AAAA,MAC/B,MAAM,MAAM,EAAE,KAAK,UAAU;AAAA,MAC7B,QAAQ,EAAE,OAAO,UAAU;AAAA,IAAA,EAC3B;AAAA,EACJ;AAEkB,oBAAA;AAAA,IAChB,eAAe;AAAA,IACf,KAAK,aAAa,gBAAgB,UAAU,KAAK;AAAA,EAAA,CAClD;AAED,YAAU,MAAM;AACR,UAAA,qBAAqB,CAAC,UAAsB;AAC5C,UAAA;AACE,YAAA,CAAC,SAAS,QAAS;AAGvB,cAAM,cAAc,UAAU;AAGxB,cAAA,iBACJ,MAAM,UAAU,CAAC,SAAS,QAAQ,SAAS,MAAM,MAAc;AAG3D,cAAA,oBAAoB,4BAA4B,SAAS,OAAO;AAEtE,YACG,eAAe,kBAAkB,qBAClC,CAAC,MAAM,QACP;AACM,gBAAA;AACI,oBAAA;AAAA,QAAA;AAAA,eAEL,IAAI;AACL,cAAA;AACI,kBAAA;AAAA,MAAA;AAAA,IAEd;AAEO,WAAA,iBAAiB,aAAa,kBAAkB;AACvD,WAAO,MAAM,OAAO,oBAAoB,aAAa,kBAAkB;AAAA,EAAA,GACtE,CAAC,QAAQ,O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oBAAC,OAAI,EAAA,WAAU,4CACb,UAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAU;AAAA,YACV,SAAS;AAAA,YACT,KAAK;AAAA,YAEJ;AAAA,UAAA;AAAA,QAAA,EAEL,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,KAEJ,EACF,CAAA;AAEJ;"}
1
+ {"version":3,"file":"RightDrawer.mjs","sources":["../../../src/components/RightDrawer/RightDrawer.tsx"],"sourcesContent":["'use client';\n\nimport { ChevronLeft, X } from 'lucide-react';\nimport {\n type FC,\n type MouseEventHandler,\n type ReactNode,\n useEffect,\n useRef,\n} from 'react';\nimport { useShallow } from 'zustand/react/shallow';\nimport { useDevice } from '../../hooks/useDevice';\nimport { useScrollBlockage } from '../../hooks/useScrollBlockage';\nimport { isElementAtTopAndNotCovered } from '../../utils/isElementAtTopAndNotCovered';\nimport { Button } from '../Button';\nimport { Container } from '../Container';\nimport { MaxWidthSmoother } from '../MaxWidthSmoother/index';\nimport { useRightDrawerStore } from './useRightDrawerStore';\n\ntype BackButtonProps = {\n onBack: () => void;\n text?: string;\n};\n\ntype RightDrawerProps = {\n title?: ReactNode;\n identifier: string;\n children?: ReactNode;\n header?: ReactNode;\n closeOnOutsideClick?: boolean;\n backButton?: BackButtonProps;\n isOpen?: boolean;\n onClose?: () => void;\n};\n\nexport const RightDrawer: FC<RightDrawerProps> = ({\n title,\n identifier,\n children,\n header,\n closeOnOutsideClick = true,\n backButton,\n isOpen: isOpenProp,\n onClose,\n}) => {\n const { isMobile } = useDevice('md');\n const panelRef = useRef<HTMLDivElement>(null);\n const childrenContainerRef = useRef<HTMLDivElement>(null);\n const { close, open, isOpen } = useRightDrawerStore(\n useShallow((s) => ({\n close: () => s.close(identifier),\n open: () => s.open(identifier),\n isOpen: s.isOpen(identifier),\n }))\n );\n\n useScrollBlockage({\n disableScroll: isOpen,\n key: identifier ? `right_drawer_${identifier}` : 'right_drawer',\n });\n\n useEffect(() => {\n const handleClickOutside = (event: MouseEvent) => {\n try {\n if (!panelRef.current) return;\n\n // Check if drawer is open and click outside is enabled\n const isClickAble = isOpen && closeOnOutsideClick;\n\n // Check if click is outside the drawer panel\n const isClickOutside =\n event.target && !panelRef.current.contains(event.target as Node);\n\n // Check if event propagation has been stopped\n const isAtTopAndVisible = isElementAtTopAndNotCovered(panelRef.current);\n\n if (\n (isClickAble && isClickOutside && isAtTopAndVisible) ||\n !event.target\n ) {\n close();\n onClose?.();\n }\n } catch (_e) {\n close();\n onClose?.();\n }\n };\n\n window.addEventListener('mousedown', handleClickOutside);\n return () => window.removeEventListener('mousedown', handleClickOutside);\n }, [isOpen, close, onClose, closeOnOutsideClick, identifier]); // Make sure the effect runs only if isOpen or close changes\n\n useEffect(() => {\n if (isOpenProp !== undefined) {\n if (isOpenProp) {\n open();\n } else {\n close();\n onClose?.();\n }\n }\n }, [close, open, onClose, isOpenProp, identifier]);\n\n const handleSpareSpaceClick: MouseEventHandler<HTMLDivElement> = (e) => {\n // Check if the click trigger the background\n if (e.target !== e.currentTarget) {\n return;\n }\n\n if (isMobile) {\n close();\n onClose?.();\n }\n };\n\n return (\n <div className=\"fixed right-0 top-0 z-50 flex h-full justify-end\">\n <MaxWidthSmoother isHidden={!isOpen} align=\"right\">\n <Container\n className=\"text-text relative flex h-screen w-screen flex-col md:w-[400px]\"\n ref={panelRef}\n roundedSize=\"none\"\n >\n <div className=\"flex flex-col gap-3 p-6\">\n <div className=\"flex justify-between gap-3\">\n <div>\n {backButton && (\n <Button\n variant=\"hoverable\"\n color=\"text\"\n label={backButton.text ?? 'Go back'}\n onClick={backButton.onBack}\n Icon={ChevronLeft}\n >\n {backButton?.text}\n </Button>\n )}\n </div>\n <div>\n <Button\n variant=\"hoverable\"\n color=\"text\"\n label=\"Close\"\n className=\"ml-auto\"\n onClick={close}\n Icon={X}\n size=\"icon-md\"\n />\n </div>\n </div>\n {title && (\n <h2 className=\"flex items-center justify-center text-lg font-bold\">\n {title}\n </h2>\n )}\n {header}\n </div>\n\n <div className=\"flex h-full flex-col overflow-y-auto p-2\">\n <div\n className=\"flex flex-1 flex-col\"\n onClick={handleSpareSpaceClick}\n ref={childrenContainerRef}\n >\n {children}\n </div>\n </div>\n </Container>\n </MaxWidthSmoother>\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;AAmCO,MAAM,cAAoC,CAAC;AAAA,EAChD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,sBAAsB;AAAA,EACtB;AAAA,EACA,QAAQ;AAAA,EACR;AACF,MAAM;AACJ,QAAM,EAAE,SAAA,IAAa,UAAU,IAAI;AAC7B,QAAA,WAAW,OAAuB,IAAI;AACtC,QAAA,uBAAuB,OAAuB,IAAI;AACxD,QAAM,EAAE,OAAO,MAAM,OAAW,IAAA;AAAA,IAC9B,WAAW,CAAC,OAAO;AAAA,MACjB,OAAO,MAAM,EAAE,MAAM,UAAU;AAAA,MAC/B,MAAM,MAAM,EAAE,KAAK,UAAU;AAAA,MAC7B,QAAQ,EAAE,OAAO,UAAU;AAAA,IAAA,EAC3B;AAAA,EACJ;AAEkB,oBAAA;AAAA,IAChB,eAAe;AAAA,IACf,KAAK,aAAa,gBAAgB,UAAU,KAAK;AAAA,EAAA,CAClD;AAED,YAAU,MAAM;AACR,UAAA,qBAAqB,CAAC,UAAsB;AAC5C,UAAA;AACE,YAAA,CAAC,SAAS,QAAS;AAGvB,cAAM,cAAc,UAAU;AAGxB,cAAA,iBACJ,MAAM,UAAU,CAAC,SAAS,QAAQ,SAAS,MAAM,MAAc;AAG3D,cAAA,oBAAoB,4BAA4B,SAAS,OAAO;AAEtE,YACG,eAAe,kBAAkB,qBAClC,CAAC,MAAM,QACP;AACM,gBAAA;AACI,oBAAA;AAAA,QAAA;AAAA,eAEL,IAAI;AACL,cAAA;AACI,kBAAA;AAAA,MAAA;AAAA,IAEd;AAEO,WAAA,iBAAiB,aAAa,kBAAkB;AACvD,WAAO,MAAM,OAAO,oBAAoB,aAAa,kBAAkB;A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ED;AAAA,QAAA,GACH;AAAA,QAEA,oBAAC,OAAI,EAAA,WAAU,4CACb,UAAA;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,WAAU;AAAA,YACV,SAAS;AAAA,YACT,KAAK;AAAA,YAEJ;AAAA,UAAA;AAAA,QAAA,EAEL,CAAA;AAAA,MAAA;AAAA,IAAA;AAAA,KAEJ,EACF,CAAA;AAEJ;"}
@@ -3,7 +3,7 @@ import { FC, HTMLAttributes, PropsWithChildren } from 'react';
3
3
  type TagProps = PropsWithChildren<VariantProps<typeof containerVariants>> & HTMLAttributes<HTMLDivElement>;
4
4
  declare const containerVariants: (props?: ({
5
5
  roundedSize?: "none" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "full" | null | undefined;
6
- color?: "text" | "error" | "neutral" | "success" | "warning" | null | undefined;
6
+ color?: "text" | "neutral" | "error" | "success" | "warning" | null | undefined;
7
7
  size?: "sm" | "md" | "lg" | "xl" | "xs" | null | undefined;
8
8
  border?: "none" | "with" | null | undefined;
9
9
  background?: "none" | "with" | null | undefined;
@@ -17,7 +17,7 @@ const AutoSizedTextArea = ({
17
17
  }) => {
18
18
  const textAreaRef = ReactExports.useRef(null);
19
19
  ReactExports.useImperativeHandle(ref, () => textAreaRef.current);
20
- const adjustHeight = ReactExports.useCallback(() => {
20
+ const adjustHeight = () => {
21
21
  const textAreaEl = textAreaRef.current;
22
22
  if (!textAreaEl || !autoSize) return;
23
23
  const textAreaStyle = textAreaEl.style;
@@ -26,7 +26,7 @@ const AutoSizedTextArea = ({
26
26
  const maxHeight = LINE_HEIGHT * maxRows + LINE_PADDING;
27
27
  const minHeight = LINE_HEIGHT + LINE_PADDING;
28
28
  textAreaStyle.height = Math.max(Math.min(scrollHeight, maxHeight), minHeight) + "px";
29
- }, [autoSize, maxRows]);
29
+ };
30
30
  ReactExports.useEffect(() => {
31
31
  adjustHeight();
32
32
  }, [props.value, props.defaultValue, adjustHeight]);
@@ -34,15 +34,12 @@ const AutoSizedTextArea = ({
34
34
  onChange?.(e);
35
35
  adjustHeight();
36
36
  };
37
- const setRef = ReactExports.useCallback(
38
- (el) => {
39
- textAreaRef.current = el;
40
- if (el) {
41
- adjustHeight();
42
- }
43
- },
44
- [adjustHeight]
45
- );
37
+ const setRef = (el) => {
38
+ textAreaRef.current = el;
39
+ if (el) {
40
+ adjustHeight();
41
+ }
42
+ };
46
43
  return /* @__PURE__ */ jsxRuntime.jsx(
47
44
  components_TextArea_TextArea.TextArea,
48
45
  {
@@ -1 +1 @@
1
- {"version":3,"file":"AutoSizeTextArea.cjs","sources":["../../../src/components/TextArea/AutoSizeTextArea.tsx"],"sourcesContent":["'use client';\n\nimport {\n type FC,\n useRef,\n useEffect,\n type ChangeEventHandler,\n useImperativeHandle,\n useCallback,\n} from 'react';\nimport { cn } from '../../utils/cn';\nimport { type TextAreaProps, TextArea } from './TextArea';\n\nexport type AutoSizedTextAreaProps = TextAreaProps & {\n autoSize?: boolean;\n maxRows?: number;\n};\n\nconst LINE_HEIGHT = 24; // px\nconst LINE_PADDING = 12; // px\n\nexport const AutoSizedTextArea: FC<AutoSizedTextAreaProps> = ({\n className,\n autoSize = true,\n onChange,\n maxRows = 999,\n ref,\n ...props\n}) => {\n const textAreaRef = useRef<HTMLTextAreaElement | null>(null);\n\n useImperativeHandle(ref, () => textAreaRef.current!);\n\n const adjustHeight = useCallback(() => {\n const textAreaEl = textAreaRef.current;\n\n if (!textAreaEl || !autoSize) return;\n\n const textAreaStyle = textAreaEl.style;\n\n // Reset height to get accurate scrollHeight\n textAreaStyle.height = 'auto';\n const scrollHeight = textAreaEl.scrollHeight;\n const maxHeight = LINE_HEIGHT * maxRows + LINE_PADDING;\n const minHeight = LINE_HEIGHT + LINE_PADDING;\n\n // Set the new height\n textAreaStyle.height =\n Math.max(Math.min(scrollHeight, maxHeight), minHeight) + 'px';\n }, [autoSize, maxRows]);\n\n useEffect(() => {\n adjustHeight();\n }, [props.value, props.defaultValue, adjustHeight]);\n\n const handleChange: ChangeEventHandler<HTMLTextAreaElement> = (e) => {\n onChange?.(e);\n adjustHeight();\n };\n\n const setRef = useCallback(\n (el: HTMLTextAreaElement | null) => {\n textAreaRef.current = el;\n if (el) {\n adjustHeight();\n }\n },\n [adjustHeight]\n );\n\n return (\n <TextArea\n ref={setRef}\n onChange={handleChange}\n className={cn(\n 'overflow-y-scroll',\n autoSize ? 'resize-none' : '',\n className\n )}\n {...props}\n />\n );\n};\n"],"names":["useRef","useImperativeHandle","useCallback","useEffect","jsx","TextArea","cn"],"mappings":";;;;;;;AAkBA,MAAM,cAAc;AACpB,MAAM,eAAe;AAEd,MAAM,oBAAgD,CAAC;AAAA,EAC5D;AAAA,EACA,WAAW;AAAA,EACX;AAAA,EACA,UAAU;AAAA,EACV;AAAA,EACA,GAAG;AACL,MAAM;AACE,QAAA,cAAcA,oBAAmC,IAAI;AAEvCC,eAAAA,oBAAA,KAAK,MAAM,YAAY,OAAQ;AAE7C,QAAA,eAAeC,aAAAA,YAAY,MAAM;AACrC,UAAM,aAAa,YAAY;AAE3B,QAAA,CAAC,cAAc,CAAC,SAAU;AAE9B,UAAM,gBAAgB,WAAW;AAGjC,kBAAc,SAAS;AACvB,UAAM,eAAe,WAAW;AAC1B,UAAA,YAAY,cAAc,UAAU;AAC1C,UAAM,YAAY,cAAc;AAGlB,kBAAA,SACZ,KAAK,IAAI,KAAK,IAAI,cAAc,SAAS,GAAG,SAAS,IAAI;AAAA,EAAA,GAC1D,CAAC,UAAU,OAAO,CAAC;AAEtBC,eAAAA,UAAU,MAAM;AACD,iBAAA;AAAA,EAAA,GACZ,CAAC,MAAM,OAAO,MAAM,cAAc,YAAY,CAAC;AAE5C,QAAA,eAAwD,CAAC,MAAM;AACnE,eAAW,CAAC;AACC,iBAAA;AAAA,EACf;AAEA,QAAM,SAASD,aAAA;AAAA,IACb,CAAC,OAAmC;AAClC,kBAAY,UAAU;AACtB,UAAI,IAAI;AACO,qBAAA;AAAA,MAAA;AAAA,IAEjB;AAAA,IACA,CAAC,YAAY;AAAA,EACf;AAGE,SAAAE,2BAAA;AAAA,IAACC,6BAAA;AAAA,IAAA;AAAA,MACC,KAAK;AAAA,MACL,UAAU;AAAA,MACV,WAAWC,SAAA;AAAA,QACT;AAAA,QACA,WAAW,gBAAgB;AAAA,QAC3B;AAAA,MACF;AAAA,MACC,GAAG;AAAA,IAAA;AAAA,EACN;AAEJ;;"}
1
+ {"version":3,"file":"AutoSizeTextArea.cjs","sources":["../../../src/components/TextArea/AutoSizeTextArea.tsx"],"sourcesContent":["'use client';\n\nimport {\n type ChangeEventHandler,\n type FC,\n useEffect,\n useImperativeHandle,\n useRef,\n} from 'react';\nimport { cn } from '../../utils/cn';\nimport { type TextAreaProps, TextArea } from './TextArea';\n\nexport type AutoSizedTextAreaProps = TextAreaProps & {\n autoSize?: boolean;\n maxRows?: number;\n};\n\nconst LINE_HEIGHT = 24; // px\nconst LINE_PADDING = 12; // px\n\nexport const AutoSizedTextArea: FC<AutoSizedTextAreaProps> = ({\n className,\n autoSize = true,\n onChange,\n maxRows = 999,\n ref,\n ...props\n}) => {\n const textAreaRef = useRef<HTMLTextAreaElement | null>(null);\n\n useImperativeHandle(ref, () => textAreaRef.current!);\n\n const adjustHeight = () => {\n const textAreaEl = textAreaRef.current;\n\n if (!textAreaEl || !autoSize) return;\n\n const textAreaStyle = textAreaEl.style;\n\n // Reset height to get accurate scrollHeight\n textAreaStyle.height = 'auto';\n const scrollHeight = textAreaEl.scrollHeight;\n const maxHeight = LINE_HEIGHT * maxRows + LINE_PADDING;\n const minHeight = LINE_HEIGHT + LINE_PADDING;\n\n // Set the new height\n textAreaStyle.height =\n Math.max(Math.min(scrollHeight, maxHeight), minHeight) + 'px';\n };\n\n useEffect(() => {\n adjustHeight();\n }, [props.value, props.defaultValue, adjustHeight]);\n\n const handleChange: ChangeEventHandler<HTMLTextAreaElement> = (e) => {\n onChange?.(e);\n adjustHeight();\n };\n\n const setRef = (el: HTMLTextAreaElement | null) => {\n textAreaRef.current = el;\n if (el) {\n adjustHeight();\n }\n };\n\n return (\n <TextArea\n ref={setRef}\n onChange={handleChange}\n className={cn(\n 'overflow-y-scroll',\n autoSize ? 'resize-none' : '',\n className\n )}\n {...props}\n />\n );\n};\n"],"names":["useRef","useImperativeHandle","useEffect","jsx","TextArea","cn"],"mappings":";;;;;;;AAiBA,MAAM,cAAc;AACpB,MAAM,eAAe;AAEd,MAAM,oBAAgD,CAAC;AAAA,EAC5D;AAAA,EACA,WAAW;AAAA,EACX;AAAA,EACA,UAAU;AAAA,EACV;AAAA,EACA,GAAG;AACL,MAAM;AACE,QAAA,cAAcA,oBAAmC,IAAI;AAEvCC,eAAAA,oBAAA,KAAK,MAAM,YAAY,OAAQ;AAEnD,QAAM,eAAe,MAAM;AACzB,UAAM,aAAa,YAAY;AAE3B,QAAA,CAAC,cAAc,CAAC,SAAU;AAE9B,UAAM,gBAAgB,WAAW;AAGjC,kBAAc,SAAS;AACvB,UAAM,eAAe,WAAW;AAC1B,UAAA,YAAY,cAAc,UAAU;AAC1C,UAAM,YAAY,cAAc;AAGlB,kBAAA,SACZ,KAAK,IAAI,KAAK,IAAI,cAAc,SAAS,GAAG,SAAS,IAAI;AAAA,EAC7D;AAEAC,eAAAA,UAAU,MAAM;AACD,iBAAA;AAAA,EAAA,GACZ,CAAC,MAAM,OAAO,MAAM,cAAc,YAAY,CAAC;AAE5C,QAAA,eAAwD,CAAC,MAAM;AACnE,eAAW,CAAC;AACC,iBAAA;AAAA,EACf;AAEM,QAAA,SAAS,CAAC,OAAmC;AACjD,gBAAY,UAAU;AACtB,QAAI,IAAI;AACO,mBAAA;AAAA,IAAA;AAAA,EAEjB;AAGE,SAAAC,2BAAA;AAAA,IAACC,6BAAA;AAAA,IAAA;AAAA,MACC,KAAK;AAAA,MACL,UAAU;AAAA,MACV,WAAWC,SAAA;AAAA,QACT;AAAA,QACA,WAAW,gBAAgB;AAAA,QAC3B;AAAA,MACF;AAAA,MACC,GAAG;AAAA,IAAA;AAAA,EACN;AAEJ;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"AutoSizeTextArea.d.ts","sourceRoot":"","sources":["../../../src/components/TextArea/AutoSizeTextArea.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,EAAE,EAMR,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,KAAK,aAAa,EAAY,MAAM,YAAY,CAAC;AAE1D,MAAM,MAAM,sBAAsB,GAAG,aAAa,GAAG;IACnD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAKF,eAAO,MAAM,iBAAiB,EAAE,EAAE,CAAC,sBAAsB,CA6DxD,CAAC"}
1
+ {"version":3,"file":"AutoSizeTextArea.d.ts","sourceRoot":"","sources":["../../../src/components/TextArea/AutoSizeTextArea.tsx"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,EAAE,EAIR,MAAM,OAAO,CAAC;AAEf,OAAO,EAAE,KAAK,aAAa,EAAY,MAAM,YAAY,CAAC;AAE1D,MAAM,MAAM,sBAAsB,GAAG,aAAa,GAAG;IACnD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAKF,eAAO,MAAM,iBAAiB,EAAE,EAAE,CAAC,sBAAsB,CA0DxD,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { jsx } from "react/jsx-runtime";
3
- import { useRef, useImperativeHandle, useCallback, useEffect } from "react";
3
+ import { useRef, useImperativeHandle, useEffect } from "react";
4
4
  import { cn } from "../../utils/cn.mjs";
5
5
  import { TextArea } from "./TextArea.mjs";
6
6
  const LINE_HEIGHT = 24;
@@ -15,7 +15,7 @@ const AutoSizedTextArea = ({
15
15
  }) => {
16
16
  const textAreaRef = useRef(null);
17
17
  useImperativeHandle(ref, () => textAreaRef.current);
18
- const adjustHeight = useCallback(() => {
18
+ const adjustHeight = () => {
19
19
  const textAreaEl = textAreaRef.current;
20
20
  if (!textAreaEl || !autoSize) return;
21
21
  const textAreaStyle = textAreaEl.style;
@@ -24,7 +24,7 @@ const AutoSizedTextArea = ({
24
24
  const maxHeight = LINE_HEIGHT * maxRows + LINE_PADDING;
25
25
  const minHeight = LINE_HEIGHT + LINE_PADDING;
26
26
  textAreaStyle.height = Math.max(Math.min(scrollHeight, maxHeight), minHeight) + "px";
27
- }, [autoSize, maxRows]);
27
+ };
28
28
  useEffect(() => {
29
29
  adjustHeight();
30
30
  }, [props.value, props.defaultValue, adjustHeight]);
@@ -32,15 +32,12 @@ const AutoSizedTextArea = ({
32
32
  onChange?.(e);
33
33
  adjustHeight();
34
34
  };
35
- const setRef = useCallback(
36
- (el) => {
37
- textAreaRef.current = el;
38
- if (el) {
39
- adjustHeight();
40
- }
41
- },
42
- [adjustHeight]
43
- );
35
+ const setRef = (el) => {
36
+ textAreaRef.current = el;
37
+ if (el) {
38
+ adjustHeight();
39
+ }
40
+ };
44
41
  return /* @__PURE__ */ jsx(
45
42
  TextArea,
46
43
  {
@@ -1 +1 @@
1
- {"version":3,"file":"AutoSizeTextArea.mjs","sources":["../../../src/components/TextArea/AutoSizeTextArea.tsx"],"sourcesContent":["'use client';\n\nimport {\n type FC,\n useRef,\n useEffect,\n type ChangeEventHandler,\n useImperativeHandle,\n useCallback,\n} from 'react';\nimport { cn } from '../../utils/cn';\nimport { type TextAreaProps, TextArea } from './TextArea';\n\nexport type AutoSizedTextAreaProps = TextAreaProps & {\n autoSize?: boolean;\n maxRows?: number;\n};\n\nconst LINE_HEIGHT = 24; // px\nconst LINE_PADDING = 12; // px\n\nexport const AutoSizedTextArea: FC<AutoSizedTextAreaProps> = ({\n className,\n autoSize = true,\n onChange,\n maxRows = 999,\n ref,\n ...props\n}) => {\n const textAreaRef = useRef<HTMLTextAreaElement | null>(null);\n\n useImperativeHandle(ref, () => textAreaRef.current!);\n\n const adjustHeight = useCallback(() => {\n const textAreaEl = textAreaRef.current;\n\n if (!textAreaEl || !autoSize) return;\n\n const textAreaStyle = textAreaEl.style;\n\n // Reset height to get accurate scrollHeight\n textAreaStyle.height = 'auto';\n const scrollHeight = textAreaEl.scrollHeight;\n const maxHeight = LINE_HEIGHT * maxRows + LINE_PADDING;\n const minHeight = LINE_HEIGHT + LINE_PADDING;\n\n // Set the new height\n textAreaStyle.height =\n Math.max(Math.min(scrollHeight, maxHeight), minHeight) + 'px';\n }, [autoSize, maxRows]);\n\n useEffect(() => {\n adjustHeight();\n }, [props.value, props.defaultValue, adjustHeight]);\n\n const handleChange: ChangeEventHandler<HTMLTextAreaElement> = (e) => {\n onChange?.(e);\n adjustHeight();\n };\n\n const setRef = useCallback(\n (el: HTMLTextAreaElement | null) => {\n textAreaRef.current = el;\n if (el) {\n adjustHeight();\n }\n },\n [adjustHeight]\n );\n\n return (\n <TextArea\n ref={setRef}\n onChange={handleChange}\n className={cn(\n 'overflow-y-scroll',\n autoSize ? 'resize-none' : '',\n className\n )}\n {...props}\n />\n );\n};\n"],"names":[],"mappings":";;;;;AAkBA,MAAM,cAAc;AACpB,MAAM,eAAe;AAEd,MAAM,oBAAgD,CAAC;AAAA,EAC5D;AAAA,EACA,WAAW;AAAA,EACX;AAAA,EACA,UAAU;AAAA,EACV;AAAA,EACA,GAAG;AACL,MAAM;AACE,QAAA,cAAc,OAAmC,IAAI;AAEvC,sBAAA,KAAK,MAAM,YAAY,OAAQ;AAE7C,QAAA,eAAe,YAAY,MAAM;AACrC,UAAM,aAAa,YAAY;AAE3B,QAAA,CAAC,cAAc,CAAC,SAAU;AAE9B,UAAM,gBAAgB,WAAW;AAGjC,kBAAc,SAAS;AACvB,UAAM,eAAe,WAAW;AAC1B,UAAA,YAAY,cAAc,UAAU;AAC1C,UAAM,YAAY,cAAc;AAGlB,kBAAA,SACZ,KAAK,IAAI,KAAK,IAAI,cAAc,SAAS,GAAG,SAAS,IAAI;AAAA,EAAA,GAC1D,CAAC,UAAU,OAAO,CAAC;AAEtB,YAAU,MAAM;AACD,iBAAA;AAAA,EAAA,GACZ,CAAC,MAAM,OAAO,MAAM,cAAc,YAAY,CAAC;AAE5C,QAAA,eAAwD,CAAC,MAAM;AACnE,eAAW,CAAC;AACC,iBAAA;AAAA,EACf;AAEA,QAAM,SAAS;AAAA,IACb,CAAC,OAAmC;AAClC,kBAAY,UAAU;AACtB,UAAI,IAAI;AACO,qBAAA;AAAA,MAAA;AAAA,IAEjB;AAAA,IACA,CAAC,YAAY;AAAA,EACf;AAGE,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAK;AAAA,MACL,UAAU;AAAA,MACV,WAAW;AAAA,QACT;AAAA,QACA,WAAW,gBAAgB;AAAA,QAC3B;AAAA,MACF;AAAA,MACC,GAAG;AAAA,IAAA;AAAA,EACN;AAEJ;"}
1
+ {"version":3,"file":"AutoSizeTextArea.mjs","sources":["../../../src/components/TextArea/AutoSizeTextArea.tsx"],"sourcesContent":["'use client';\n\nimport {\n type ChangeEventHandler,\n type FC,\n useEffect,\n useImperativeHandle,\n useRef,\n} from 'react';\nimport { cn } from '../../utils/cn';\nimport { type TextAreaProps, TextArea } from './TextArea';\n\nexport type AutoSizedTextAreaProps = TextAreaProps & {\n autoSize?: boolean;\n maxRows?: number;\n};\n\nconst LINE_HEIGHT = 24; // px\nconst LINE_PADDING = 12; // px\n\nexport const AutoSizedTextArea: FC<AutoSizedTextAreaProps> = ({\n className,\n autoSize = true,\n onChange,\n maxRows = 999,\n ref,\n ...props\n}) => {\n const textAreaRef = useRef<HTMLTextAreaElement | null>(null);\n\n useImperativeHandle(ref, () => textAreaRef.current!);\n\n const adjustHeight = () => {\n const textAreaEl = textAreaRef.current;\n\n if (!textAreaEl || !autoSize) return;\n\n const textAreaStyle = textAreaEl.style;\n\n // Reset height to get accurate scrollHeight\n textAreaStyle.height = 'auto';\n const scrollHeight = textAreaEl.scrollHeight;\n const maxHeight = LINE_HEIGHT * maxRows + LINE_PADDING;\n const minHeight = LINE_HEIGHT + LINE_PADDING;\n\n // Set the new height\n textAreaStyle.height =\n Math.max(Math.min(scrollHeight, maxHeight), minHeight) + 'px';\n };\n\n useEffect(() => {\n adjustHeight();\n }, [props.value, props.defaultValue, adjustHeight]);\n\n const handleChange: ChangeEventHandler<HTMLTextAreaElement> = (e) => {\n onChange?.(e);\n adjustHeight();\n };\n\n const setRef = (el: HTMLTextAreaElement | null) => {\n textAreaRef.current = el;\n if (el) {\n adjustHeight();\n }\n };\n\n return (\n <TextArea\n ref={setRef}\n onChange={handleChange}\n className={cn(\n 'overflow-y-scroll',\n autoSize ? 'resize-none' : '',\n className\n )}\n {...props}\n />\n );\n};\n"],"names":[],"mappings":";;;;;AAiBA,MAAM,cAAc;AACpB,MAAM,eAAe;AAEd,MAAM,oBAAgD,CAAC;AAAA,EAC5D;AAAA,EACA,WAAW;AAAA,EACX;AAAA,EACA,UAAU;AAAA,EACV;AAAA,EACA,GAAG;AACL,MAAM;AACE,QAAA,cAAc,OAAmC,IAAI;AAEvC,sBAAA,KAAK,MAAM,YAAY,OAAQ;AAEnD,QAAM,eAAe,MAAM;AACzB,UAAM,aAAa,YAAY;AAE3B,QAAA,CAAC,cAAc,CAAC,SAAU;AAE9B,UAAM,gBAAgB,WAAW;AAGjC,kBAAc,SAAS;AACvB,UAAM,eAAe,WAAW;AAC1B,UAAA,YAAY,cAAc,UAAU;AAC1C,UAAM,YAAY,cAAc;AAGlB,kBAAA,SACZ,KAAK,IAAI,KAAK,IAAI,cAAc,SAAS,GAAG,SAAS,IAAI;AAAA,EAC7D;AAEA,YAAU,MAAM;AACD,iBAAA;AAAA,EAAA,GACZ,CAAC,MAAM,OAAO,MAAM,cAAc,YAAY,CAAC;AAE5C,QAAA,eAAwD,CAAC,MAAM;AACnE,eAAW,CAAC;AACC,iBAAA;AAAA,EACf;AAEM,QAAA,SAAS,CAAC,OAAmC;AACjD,gBAAY,UAAU;AACtB,QAAI,IAAI;AACO,mBAAA;AAAA,IAAA;AAAA,EAEjB;AAGE,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAK;AAAA,MACL,UAAU;AAAA,MACV,WAAW;AAAA,QACT;AAAA,QACA,WAAW,gBAAgB;AAAA,QAC3B;AAAA,MACF;AAAA,MACC,GAAG;AAAA,IAAA;AAAA,EACN;AAEJ;"}
@@ -42,9 +42,9 @@ const WithResizer = ({
42
42
  [isResizing]
43
43
  );
44
44
  ReactExports.useEffect(() => {
45
- window.addEventListener("mousemove", resize);
45
+ window.addEventListener("mousemove", resize, { passive: true });
46
46
  window.addEventListener("mouseup", stopResizing);
47
- window.addEventListener("touchmove", resize);
47
+ window.addEventListener("touchmove", resize, { passive: true });
48
48
  window.addEventListener("touchend", stopResizing);
49
49
  return () => {
50
50
  window.removeEventListener("mousemove", resize);
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../src/components/WithResizer/index.tsx"],"sourcesContent":["/* eslint-disable jsx-a11y/no-static-element-interactions */\n'use client';\n\nimport React, {\n useState,\n useCallback,\n type PropsWithChildren,\n useEffect,\n type FC,\n useRef,\n} from 'react';\nimport { cn } from '../../utils/cn';\n\ntype WithResizerProps = {\n initialWidth: number;\n maxWidth?: number;\n minWidth?: number;\n};\n\nexport const WithResizer: FC<PropsWithChildren<WithResizerProps>> = ({\n initialWidth,\n maxWidth,\n minWidth = 0,\n children,\n}) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const [width, setWidth] = useState(initialWidth);\n const [isResizing, setIsResizing] = useState(false);\n\n // Handler to start resizing\n const startResizing = useCallback(\n (\n mouseDownEvent:\n | React.MouseEvent<HTMLDivElement>\n | React.TouchEvent<HTMLDivElement>\n ) => {\n setIsResizing(true);\n mouseDownEvent.preventDefault();\n },\n []\n );\n\n // Handler to stop resizing\n const stopResizing = useCallback(() => {\n setIsResizing(false);\n }, []);\n\n // Handler to resize the div\n const resize = useCallback(\n (mouseMoveEvent: MouseEvent | TouchEvent) => {\n const container = containerRef.current;\n if (isResizing && container && parent) {\n const { left: containerLeft } = container.getBoundingClientRect();\n\n let clientX = 0;\n if (mouseMoveEvent instanceof MouseEvent) {\n clientX = mouseMoveEvent.clientX;\n } else if (mouseMoveEvent instanceof TouchEvent) {\n clientX = mouseMoveEvent.touches[0].clientX;\n }\n\n const newWidth = clientX - containerLeft;\n const correctedWidth = Math.max(newWidth, 0);\n\n setWidth(correctedWidth);\n }\n },\n [isResizing]\n );\n\n // Add event listeners for mouse move and mouse up\n useEffect(() => {\n window.addEventListener('mousemove', resize);\n window.addEventListener('mouseup', stopResizing);\n window.addEventListener('touchmove', resize);\n window.addEventListener('touchend', stopResizing);\n\n return () => {\n window.removeEventListener('mousemove', resize);\n window.removeEventListener('mouseup', stopResizing);\n window.removeEventListener('touchmove', resize);\n window.removeEventListener('touchend', stopResizing);\n };\n }, [resize, stopResizing]);\n\n return (\n <div\n className={cn(\n minWidth && `max-w-[${maxWidth}px]`,\n maxWidth && `min-w-[${minWidth}px]`,\n 'relative h-full w-full max-w-[80%] cursor-ew-resize border-r-[2px] border-neutral-200 transition dark:border-neutral-950',\n 'after:absolute after:right-0 after:top-1/2 after:block after:h-10 after:w-2 after:-translate-y-1/2 after:translate-x-1/2 after:transform after:cursor-ew-resize after:rounded-full after:bg-neutral-200 after:transition after:content-[\"\"] dark:after:bg-neutral-950',\n 'active:border-neutral-400 active:after:bg-neutral-400 dark:active:border-neutral-600 active:dark:after:bg-neutral-600'\n )}\n style={{\n width: `${width}px`,\n }}\n ref={containerRef}\n onMouseDown={startResizing}\n onTouchStart={startResizing}\n aria-valuemin={minWidth}\n aria-valuemax={maxWidth}\n aria-valuenow={width}\n aria-label=\"Resizable component\"\n role=\"slider\"\n tabIndex={0}\n >\n <div\n className=\"absolute left-0 top-0 size-full cursor-default overflow-hidden\"\n onMouseDown={(e) => e.stopPropagation()}\n onTouchStart={(e) => e.stopPropagation()}\n >\n {children}\n </div>\n </div>\n );\n};\n"],"names":["useRef","useState","useCallback","useEffect","jsx","cn"],"mappings":";;;;;;AAmBO,MAAM,cAAuD,CAAC;AAAA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B,SAAAC,2BAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWC,SAAA;AAAA,QACT,YAAY,UAAU,QAAQ;AAAA,QAC9B,YAAY,UAAU,QAAQ;AAAA,QAC9B;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MACA,OAAO;AAAA,QACL,OAAO,GAAG,KAAK;AAAA,MACjB;AAAA,MACA,KAAK;AAAA,MACL,aAAa;AAAA,MACb,cAAc;AAAA,MACd,iBAAe;AAAA,MACf,iBAAe;AAAA,MACf,iBAAe;AAAA,MACf,cAAW;AAAA,MACX,MAAK;AAAA,MACL,UAAU;AAAA,MAEV,UAAAD,2BAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAU;AAAA,UACV,aAAa,CAAC,MAAM,EAAE,gBAAgB;AAAA,UACtC,cAAc,CAAC,MAAM,EAAE,gBAAgB;AAAA,UAEtC;AAAA,QAAA;AAAA,MAAA;AAAA,IACH;AAAA,EACF;AAEJ;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../../../src/components/WithResizer/index.tsx"],"sourcesContent":["'use client';\n\nimport React, {\n useCallback,\n useEffect,\n useRef,\n useState,\n type FC,\n type PropsWithChildren,\n} from 'react';\nimport { cn } from '../../utils/cn';\n\ntype WithResizerProps = {\n initialWidth: number;\n maxWidth?: number;\n minWidth?: number;\n};\n\nexport const WithResizer: FC<PropsWithChildren<WithResizerProps>> = ({\n initialWidth,\n maxWidth,\n minWidth = 0,\n children,\n}) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const [width, setWidth] = useState(initialWidth);\n const [isResizing, setIsResizing] = useState(false);\n\n // Handler to start resizing\n const startResizing = useCallback(\n (\n mouseDownEvent:\n | React.MouseEvent<HTMLDivElement>\n | React.TouchEvent<HTMLDivElement>\n ) => {\n setIsResizing(true);\n mouseDownEvent.preventDefault();\n },\n []\n );\n\n // Handler to stop resizing\n const stopResizing = useCallback(() => {\n setIsResizing(false);\n }, []);\n\n // Handler to resize the div\n const resize = useCallback(\n (mouseMoveEvent: MouseEvent | TouchEvent) => {\n const container = containerRef.current;\n if (isResizing && container && parent) {\n const { left: containerLeft } = container.getBoundingClientRect();\n\n let clientX = 0;\n if (mouseMoveEvent instanceof MouseEvent) {\n clientX = mouseMoveEvent.clientX;\n } else if (mouseMoveEvent instanceof TouchEvent) {\n clientX = mouseMoveEvent.touches[0].clientX;\n }\n\n const newWidth = clientX - containerLeft;\n const correctedWidth = Math.max(newWidth, 0);\n\n setWidth(correctedWidth);\n }\n },\n [isResizing]\n );\n\n // Add event listeners for mouse move and mouse up\n useEffect(() => {\n window.addEventListener('mousemove', resize, { passive: true });\n window.addEventListener('mouseup', stopResizing);\n window.addEventListener('touchmove', resize, { passive: true });\n window.addEventListener('touchend', stopResizing);\n\n return () => {\n window.removeEventListener('mousemove', resize);\n window.removeEventListener('mouseup', stopResizing);\n window.removeEventListener('touchmove', resize);\n window.removeEventListener('touchend', stopResizing);\n };\n }, [resize, stopResizing]);\n\n return (\n <div\n className={cn(\n minWidth && `max-w-[${maxWidth}px]`,\n maxWidth && `min-w-[${minWidth}px]`,\n 'relative h-full w-full max-w-[80%] cursor-ew-resize border-r-[2px] border-neutral-200 transition dark:border-neutral-950',\n 'after:absolute after:right-0 after:top-1/2 after:block after:h-10 after:w-2 after:-translate-y-1/2 after:translate-x-1/2 after:transform after:cursor-ew-resize after:rounded-full after:bg-neutral-200 after:transition after:content-[\"\"] dark:after:bg-neutral-950',\n 'active:border-neutral-400 active:after:bg-neutral-400 dark:active:border-neutral-600 active:dark:after:bg-neutral-600'\n )}\n style={{\n width: `${width}px`,\n }}\n ref={containerRef}\n onMouseDown={startResizing}\n onTouchStart={startResizing}\n aria-valuemin={minWidth}\n aria-valuemax={maxWidth}\n aria-valuenow={width}\n aria-label=\"Resizable component\"\n role=\"slider\"\n tabIndex={0}\n >\n <div\n className=\"absolute left-0 top-0 size-full cursor-default overflow-hidden\"\n onMouseDown={(e) => e.stopPropagation()}\n onTouchStart={(e) => e.st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AM;AACvC,aAAA,oBAAoB,WAAW,YAAY;AAC3C,aAAA,oBAAoB,aAAa,MAAM;AACvC,aAAA,oBAAoB,YAAY,YAAY;AAAA,IACrD;AAAA,EAAA,GACC,CAAC,QAAQ,YAAY,CAAC;AAGvB,SAAAC,2BAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAWC,SAAA;AAAA,QACT,YAAY,UAAU,QAAQ;AAAA,QAC9B,YAAY,UAAU,QAAQ;AAAA,QAC9B;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MACA,OAAO;AAAA,QACL,OAAO,GAAG,KAAK;AAAA,MACjB;AAAA,MACA,KAAK;AAAA,MACL,aAAa;AAAA,MACb,cAAc;AAAA,MACd,iBAAe;AAAA,MACf,iBAAe;AAAA,MACf,iBAAe;AAAA,MACf,cAAW;AAAA,MACX,MAAK;AAAA,MACL,UAAU;AAAA,MAEV,UAAAD,2BAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAU;AAAA,UACV,aAAa,CAAC,MAAM,EAAE,gBAAgB;AAAA,UACtC,cAAc,CAAC,MAAM,EAAE,gBAAgB;AAAA,UAEtC;AAAA,QAAA;AAAA,MAAA;AAAA,IACH;AAAA,EACF;AAEJ;;"}
@@ -1,4 +1,4 @@
1
- import { PropsWithChildren, FC } from 'react';
1
+ import { FC, PropsWithChildren } from 'react';
2
2
  type WithResizerProps = {
3
3
  initialWidth: number;
4
4
  maxWidth?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/WithResizer/index.tsx"],"names":[],"mappings":"AAGA,OAAc,EAGZ,KAAK,iBAAiB,EAEtB,KAAK,EAAE,EAER,MAAM,OAAO,CAAC;AAGf,KAAK,gBAAgB,GAAG;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAiG/D,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/WithResizer/index.tsx"],"names":[],"mappings":"AAEA,OAAc,EAKZ,KAAK,EAAE,EACP,KAAK,iBAAiB,EACvB,MAAM,OAAO,CAAC;AAGf,KAAK,gBAAgB,GAAG;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAiG/D,CAAC"}
@@ -40,9 +40,9 @@ const WithResizer = ({
40
40
  [isResizing]
41
41
  );
42
42
  useEffect(() => {
43
- window.addEventListener("mousemove", resize);
43
+ window.addEventListener("mousemove", resize, { passive: true });
44
44
  window.addEventListener("mouseup", stopResizing);
45
- window.addEventListener("touchmove", resize);
45
+ window.addEventListener("touchmove", resize, { passive: true });
46
46
  window.addEventListener("touchend", stopResizing);
47
47
  return () => {
48
48
  window.removeEventListener("mousemove", resize);
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../../src/components/WithResizer/index.tsx"],"sourcesContent":["/* eslint-disable jsx-a11y/no-static-element-interactions */\n'use client';\n\nimport React, {\n useState,\n useCallback,\n type PropsWithChildren,\n useEffect,\n type FC,\n useRef,\n} from 'react';\nimport { cn } from '../../utils/cn';\n\ntype WithResizerProps = {\n initialWidth: number;\n maxWidth?: number;\n minWidth?: number;\n};\n\nexport const WithResizer: FC<PropsWithChildren<WithResizerProps>> = ({\n initialWidth,\n maxWidth,\n minWidth = 0,\n children,\n}) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const [width, setWidth] = useState(initialWidth);\n const [isResizing, setIsResizing] = useState(false);\n\n // Handler to start resizing\n const startResizing = useCallback(\n (\n mouseDownEvent:\n | React.MouseEvent<HTMLDivElement>\n | React.TouchEvent<HTMLDivElement>\n ) => {\n setIsResizing(true);\n mouseDownEvent.preventDefault();\n },\n []\n );\n\n // Handler to stop resizing\n const stopResizing = useCallback(() => {\n setIsResizing(false);\n }, []);\n\n // Handler to resize the div\n const resize = useCallback(\n (mouseMoveEvent: MouseEvent | TouchEvent) => {\n const container = containerRef.current;\n if (isResizing && container && parent) {\n const { left: containerLeft } = container.getBoundingClientRect();\n\n let clientX = 0;\n if (mouseMoveEvent instanceof MouseEvent) {\n clientX = mouseMoveEvent.clientX;\n } else if (mouseMoveEvent instanceof TouchEvent) {\n clientX = mouseMoveEvent.touches[0].clientX;\n }\n\n const newWidth = clientX - containerLeft;\n const correctedWidth = Math.max(newWidth, 0);\n\n setWidth(correctedWidth);\n }\n },\n [isResizing]\n );\n\n // Add event listeners for mouse move and mouse up\n useEffect(() => {\n window.addEventListener('mousemove', resize);\n window.addEventListener('mouseup', stopResizing);\n window.addEventListener('touchmove', resize);\n window.addEventListener('touchend', stopResizing);\n\n return () => {\n window.removeEventListener('mousemove', resize);\n window.removeEventListener('mouseup', stopResizing);\n window.removeEventListener('touchmove', resize);\n window.removeEventListener('touchend', stopResizing);\n };\n }, [resize, stopResizing]);\n\n return (\n <div\n className={cn(\n minWidth && `max-w-[${maxWidth}px]`,\n maxWidth && `min-w-[${minWidth}px]`,\n 'relative h-full w-full max-w-[80%] cursor-ew-resize border-r-[2px] border-neutral-200 transition dark:border-neutral-950',\n 'after:absolute after:right-0 after:top-1/2 after:block after:h-10 after:w-2 after:-translate-y-1/2 after:translate-x-1/2 after:transform after:cursor-ew-resize after:rounded-full after:bg-neutral-200 after:transition after:content-[\"\"] dark:after:bg-neutral-950',\n 'active:border-neutral-400 active:after:bg-neutral-400 dark:active:border-neutral-600 active:dark:after:bg-neutral-600'\n )}\n style={{\n width: `${width}px`,\n }}\n ref={containerRef}\n onMouseDown={startResizing}\n onTouchStart={startResizing}\n aria-valuemin={minWidth}\n aria-valuemax={maxWidth}\n aria-valuenow={width}\n aria-label=\"Resizable component\"\n role=\"slider\"\n tabIndex={0}\n >\n <div\n className=\"absolute left-0 top-0 size-full cursor-default overflow-hidden\"\n onMouseDown={(e) => e.stopPropagation()}\n onTouchStart={(e) => e.stopPropagation()}\n >\n {children}\n </div>\n </div>\n );\n};\n"],"names":[],"mappings":";;;;AAmBO,MAAM,cAAuD,CAAC;AAAA,EACnE;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX;AACF,MAAM;AACE,QAAA,eAAe,OAAuB,IAAI;AAChD,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAS,YAAY;AAC/C,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,KAAK;AAGlD,QAAM,gBAAgB;AAAA,IACpB,CACE,mBAGG;AACH,oBAAc,IAAI;AAClB,qBAAe,eAAe;AAAA,IAChC;AAAA,IACA,CAAA;AAAA,EACF;AAGM,QAAA,eAAe,YAAY,MAAM;AACrC,kBAAc,KAAK;AAAA,EACrB,GAAG,EAAE;AAGL,QAAM,SAAS;AAAA,IACb,CAAC,mBAA4C;AAC3C,YAAM,YAAY,aAAa;AAC3B,UAAA,cAAc,aAAa,QAAQ;AACrC,cAAM,EAAE,MAAM,kBAAkB,UAAU,sBAAsB;AAEhE,YAAI,UAAU;AACd,YAAI,0BAA0B,YAAY;AACxC,oBAAU,eAAe;AAAA,QAAA,WAChB,0BAA0B,YAAY;AACrC,oBAAA,eAAe,QAAQ,CAAC,EAAE;AAAA,QAAA;AAGtC,cAAM,WAAW,UAAU;AAC3B,cAAM,iBAAiB,KAAK,IAAI,UAAU,CAAC;AAE3C,iBAAS,cAAc;AAAA,MAAA;AAAA,IAE3B;AAAA,IACA,CAAC,UAAU;AAAA,EACb;AAGA,YAAU,MAAM;AACP,WAAA,iBAAiB,aAAa,MAAM;AACpC,WAAA,iBAAiB,WAAW,YAAY;AACxC,WAAA,iBAAiB,aAAa,MAAM;AACpC,WAAA,iBAAiB,YAAY,YAAY;AAEhD,WAAO,MAAM;AACJ,aAAA,oBAAoB,aAAa,MAAM;AACvC,aAAA,oBAAoB,WAAW,YAAY;AAC3C,aAAA,oBAAoB,aAAa,MAAM;AACvC,aAAA,oBAAoB,YAAY,YAAY;AAAA,IACrD;AAAA,EAAA,GACC,CAAC,QAAQ,YAAY,CAAC;AAGvB,SAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WAAW;AAAA,QACT,YAAY,UAAU,QAAQ;AAAA,QAC9B,YAAY,UAAU,QAAQ;AAAA,QAC9B;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MACA,OAAO;AAAA,QACL,OAAO,GAAG,KAAK;AAAA,MACjB;AAAA,MACA,KAAK;AAAA,MACL,aAAa;AAAA,MACb,cAAc;AAAA,MACd,iBAAe;AAAA,MACf,iBAAe;AAAA,MACf,iBAAe;AAAA,MACf,cAAW;AAAA,MACX,MAAK;AAAA,MACL,UAAU;AAAA,MAEV,UAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAU;AAAA,UACV,aAAa,CAAC,MAAM,EAAE,gBAAgB;AAAA,UACtC,cAAc,CAAC,MAAM,EAAE,gBAAgB;AAAA,UAEtC;AAAA,QAAA;AAAA,MAAA;AAAA,IACH;AAAA,EACF;AAEJ;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../../src/components/WithResizer/index.tsx"],"sourcesContent":["'use client';\n\nimport React, {\n useCallback,\n useEffect,\n useRef,\n useState,\n type FC,\n type PropsWithChildren,\n} from 'react';\nimport { cn } from '../../utils/cn';\n\ntype WithResizerProps = {\n initialWidth: number;\n maxWidth?: number;\n minWidth?: number;\n};\n\nexport const WithResizer: FC<PropsWithChildren<WithResizerProps>> = ({\n initialWidth,\n maxWidth,\n minWidth = 0,\n children,\n}) => {\n const containerRef = useRef<HTMLDivElement>(null);\n const [width, setWidth] = useState(initialWidth);\n const [isResizing, setIsResizing] = useState(false);\n\n // Handler to start resizing\n const startResizing = useCallback(\n (\n mouseDownEvent:\n | React.MouseEvent<HTMLDivElement>\n | React.TouchEvent<HTMLDivElement>\n ) => {\n setIsResizing(true);\n mouseDownEvent.preventDefault();\n },\n []\n );\n\n // Handler to stop resizing\n const stopResizing = useCallback(() => {\n setIsResizing(false);\n }, []);\n\n // Handler to resize the div\n const resize = useCallback(\n (mouseMoveEvent: MouseEvent | TouchEvent) => {\n const container = containerRef.current;\n if (isResizing && container && parent) {\n const { left: containerLeft } = container.getBoundingClientRect();\n\n let clientX = 0;\n if (mouseMoveEvent instanceof MouseEvent) {\n clientX = mouseMoveEvent.clientX;\n } else if (mouseMoveEvent instanceof TouchEvent) {\n clientX = mouseMoveEvent.touches[0].clientX;\n }\n\n const newWidth = clientX - containerLeft;\n const correctedWidth = Math.max(newWidth, 0);\n\n setWidth(correctedWidth);\n }\n },\n [isResizing]\n );\n\n // Add event listeners for mouse move and mouse up\n useEffect(() => {\n window.addEventListener('mousemove', resize, { passive: true });\n window.addEventListener('mouseup', stopResizing);\n window.addEventListener('touchmove', resize, { passive: true });\n window.addEventListener('touchend', stopResizing);\n\n return () => {\n window.removeEventListener('mousemove', resize);\n window.removeEventListener('mouseup', stopResizing);\n window.removeEventListener('touchmove', resize);\n window.removeEventListener('touchend', stopResizing);\n };\n }, [resize, stopResizing]);\n\n return (\n <div\n className={cn(\n minWidth && `max-w-[${maxWidth}px]`,\n maxWidth && `min-w-[${minWidth}px]`,\n 'relative h-full w-full max-w-[80%] cursor-ew-resize border-r-[2px] border-neutral-200 transition dark:border-neutral-950',\n 'after:absolute after:right-0 after:top-1/2 after:block after:h-10 after:w-2 after:-translate-y-1/2 after:translate-x-1/2 after:transform after:cursor-ew-resize after:rounded-full after:bg-neutral-200 after:transition after:content-[\"\"] dark:after:bg-neutral-950',\n 'active:border-neutral-400 active:after:bg-neutral-400 dark:active:border-neutral-600 active:dark:after:bg-neutral-600'\n )}\n style={{\n width: `${width}px`,\n }}\n ref={containerRef}\n onMouseDown={startResizing}\n onTouchStart={startResizing}\n aria-valuemin={minWidth}\n aria-valuemax={maxWidth}\n aria-valuenow={width}\n aria-label=\"Resizable component\"\n role=\"slider\"\n tabIndex={0}\n >\n <div\n className=\"absolute left-0 top-0 size-full cursor-default overflow-hidden\"\n onMouseDown={(e) => e.stopPropagation()}\n onTouchStart={(e) => e.stopPropagation()}\n >\n {children}\n </div>\n </div>\n );\n};\n"],"names":[],"mappings":";;;;AAkBO,MAAM,cAAuD,CAAC;AAAA,EACnE;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX;AACF,MAAM;AACE,QAAA,eAAe,OAAuB,IAAI;AAChD,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAS,YAAY;AAC/C,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,KAAK;AAGlD,QAAM,gBAAgB;AAAA,IACpB,CACE,mBAGG;AACH,oBAAc,IAAI;AAClB,qBAAe,eAAe;AAAA,IAChC;AAAA,IACA,CAAA;AAAA,EACF;AAGM,QAAA,eAAe,YAAY,MAAM;AACrC,kBAAc,KAAK;AAAA,EACrB,GAAG,EAAE;AAGL,QAAM,SAAS;AAAA,IACb,CAAC,mBAA4C;AAC3C,YAAM,YAAY,aAAa;AAC3B,UAAA,cAAc,aAAa,QAAQ;AACrC,cAAM,EAAE,MAAM,kBAAkB,UAAU,sBAAsB;AAEhE,YAAI,UAAU;AACd,YAAI,0BAA0B,YAAY;AACxC,oBAAU,eAAe;AAAA,QAAA,WAChB,0BAA0B,YAAY;AACrC,oBAAA,eAAe,QAAQ,CAAC,EAAE;AAAA,QAAA;AAGtC,cAAM,WAAW,UAAU;AAC3B,cAAM,iBAAiB,KAAK,IAAI,UAAU,CAAC;AAE3C,iBAAS,cAAc;AAAA,MAAA;AAAA,IAE3B;AAAA,IACA,CAAC,UAAU;AAAA,EACb;AAGA,YAAU,MAAM;AACd,WAAO,iBAAiB,aAAa,QAAQ,EAAE,SAAS,MAAM;AACvD,WAAA,iBAAiB,WAAW,YAAY;AAC/C,WAAO,iBAAiB,aAAa,QAAQ,EAAE,S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