@forgedevstack/bear 1.0.6 → 1.0.7

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 (78) hide show
  1. package/dist/components/BottomSheet/BottomSheet.cjs +1 -0
  2. package/dist/components/BottomSheet/BottomSheet.d.ts +3 -0
  3. package/dist/components/BottomSheet/BottomSheet.js +102 -0
  4. package/dist/components/BottomSheet/BottomSheet.types.d.ts +13 -0
  5. package/dist/components/BottomSheet/index.d.ts +2 -0
  6. package/dist/components/Button/Button.cjs +1 -1
  7. package/dist/components/Button/Button.js +40 -38
  8. package/dist/components/Button/Button.types.d.ts +4 -0
  9. package/dist/components/EmojiPicker/EmojiPicker.cjs +1 -0
  10. package/dist/components/EmojiPicker/EmojiPicker.const.cjs +1 -0
  11. package/dist/components/EmojiPicker/EmojiPicker.const.d.ts +5 -0
  12. package/dist/components/EmojiPicker/EmojiPicker.const.js +10 -0
  13. package/dist/components/EmojiPicker/EmojiPicker.d.ts +3 -0
  14. package/dist/components/EmojiPicker/EmojiPicker.js +63 -0
  15. package/dist/components/EmojiPicker/EmojiPicker.types.d.ts +6 -0
  16. package/dist/components/EmojiPicker/index.d.ts +3 -0
  17. package/dist/components/Kanban/Kanban.cjs +1 -0
  18. package/dist/components/Kanban/Kanban.d.ts +3 -0
  19. package/dist/components/Kanban/Kanban.js +90 -0
  20. package/dist/components/Kanban/Kanban.types.d.ts +21 -0
  21. package/dist/components/Kanban/index.d.ts +2 -0
  22. package/dist/components/MentionsInput/MentionsInput.cjs +1 -0
  23. package/dist/components/MentionsInput/MentionsInput.d.ts +3 -0
  24. package/dist/components/MentionsInput/MentionsInput.js +140 -0
  25. package/dist/components/MentionsInput/MentionsInput.types.d.ts +21 -0
  26. package/dist/components/MentionsInput/index.d.ts +2 -0
  27. package/dist/components/RichEditor/RichEditor.cjs +1 -1
  28. package/dist/components/RichEditor/RichEditor.const.cjs +2 -2
  29. package/dist/components/RichEditor/RichEditor.const.d.ts +4 -1
  30. package/dist/components/RichEditor/RichEditor.const.js +51 -18
  31. package/dist/components/RichEditor/RichEditor.js +106 -105
  32. package/dist/components/RichEditor/components/ToolbarColorPicker/ToolbarColorPicker.cjs +1 -1
  33. package/dist/components/RichEditor/components/ToolbarColorPicker/ToolbarColorPicker.js +105 -95
  34. package/dist/components/RichEditor/components/ToolbarMore/ToolbarMore.cjs +1 -1
  35. package/dist/components/RichEditor/components/ToolbarMore/ToolbarMore.d.ts +2 -0
  36. package/dist/components/RichEditor/components/ToolbarMore/ToolbarMore.js +47 -29
  37. package/dist/components/SegmentedControl/SegmentedControl.cjs +1 -0
  38. package/dist/components/SegmentedControl/SegmentedControl.d.ts +3 -0
  39. package/dist/components/SegmentedControl/SegmentedControl.js +58 -0
  40. package/dist/components/SegmentedControl/SegmentedControl.types.d.ts +16 -0
  41. package/dist/components/SegmentedControl/index.d.ts +2 -0
  42. package/dist/components/SignPad/SignPad.cjs +1 -1
  43. package/dist/components/SignPad/SignPad.js +98 -90
  44. package/dist/components/SliderRange/SliderRange.cjs +1 -0
  45. package/dist/components/SliderRange/SliderRange.d.ts +3 -0
  46. package/dist/components/SliderRange/SliderRange.js +142 -0
  47. package/dist/components/SliderRange/SliderRange.types.d.ts +17 -0
  48. package/dist/components/SliderRange/index.d.ts +2 -0
  49. package/dist/components/TagsInput/TagsInput.cjs +1 -0
  50. package/dist/components/TagsInput/TagsInput.d.ts +3 -0
  51. package/dist/components/TagsInput/TagsInput.js +100 -0
  52. package/dist/components/TagsInput/TagsInput.types.d.ts +16 -0
  53. package/dist/components/TagsInput/index.d.ts +2 -0
  54. package/dist/components/VirtualList/VirtualList.cjs +1 -0
  55. package/dist/components/VirtualList/VirtualList.d.ts +3 -0
  56. package/dist/components/VirtualList/VirtualList.js +68 -0
  57. package/dist/components/VirtualList/VirtualList.types.d.ts +10 -0
  58. package/dist/components/VirtualList/index.d.ts +2 -0
  59. package/dist/components/index.cjs +1 -1
  60. package/dist/components/index.d.ts +16 -0
  61. package/dist/components/index.js +124 -106
  62. package/dist/hooks/index.cjs +1 -1
  63. package/dist/hooks/index.d.ts +4 -0
  64. package/dist/hooks/index.js +36 -32
  65. package/dist/hooks/useDragDrop/index.d.ts +2 -0
  66. package/dist/hooks/useDragDrop/useDragDrop.cjs +1 -0
  67. package/dist/hooks/useDragDrop/useDragDrop.d.ts +22 -0
  68. package/dist/hooks/useDragDrop/useDragDrop.js +56 -0
  69. package/dist/hooks/useDragDrop/useDragDrop.types.d.ts +55 -0
  70. package/dist/hooks/useLazyLoad/index.d.ts +2 -0
  71. package/dist/hooks/useLazyLoad/useLazyLoad.cjs +1 -0
  72. package/dist/hooks/useLazyLoad/useLazyLoad.d.ts +26 -0
  73. package/dist/hooks/useLazyLoad/useLazyLoad.js +27 -0
  74. package/dist/hooks/useLazyLoad/useLazyLoad.types.d.ts +25 -0
  75. package/dist/index.cjs +1 -1
  76. package/dist/index.js +179 -157
  77. package/dist/styles.css +1 -1
  78. package/package.json +1 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("react"),d=require("../../../../utils/cn.cjs"),o=require("../../RichEditor.const.cjs"),u=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),e.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),_=({children:l,disabled:i})=>{const[r,s]=n.useState(!1),t=n.useRef(null);return n.useEffect(()=>{const c=a=>{t.current&&!t.current.contains(a.target)&&s(!1)};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[]),e.jsxs("div",{ref:t,className:"Bear-RichEditor__more relative",children:[e.jsx("button",{type:"button",title:"More options",disabled:i,onClick:()=>s(!r),className:d.cn("Bear-RichEditor__more-trigger",o.RICH_EDITOR_BUTTON_BASE_CLASSES,o.RICH_EDITOR_BUTTON_INACTIVE_CLASSES,"flex items-center justify-center",r&&"bg-pink-500 text-white",i&&`Bear-RichEditor__more-trigger--disabled ${o.RICH_EDITOR_BUTTON_DISABLED_CLASSES}`),children:e.jsx(u,{})}),r&&e.jsx("div",{className:"Bear-RichEditor__more-menu absolute top-full right-0 mt-1 p-2 bg-white dark:bg-zinc-800 border border-gray-200 dark:border-zinc-700 rounded-lg shadow-xl z-50 min-w-[200px]",children:e.jsx("div",{className:"flex flex-wrap items-center gap-0.5",children:l})})]})};exports.ToolbarMore=_;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),E=require("react-dom"),h=require("../../../../utils/cn.cjs"),l=require("../../RichEditor.const.cjs"),p=()=>e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("circle",{cx:"12",cy:"12",r:"1.5",fill:"currentColor"}),e.jsx("circle",{cx:"6",cy:"12",r:"1.5",fill:"currentColor"}),e.jsx("circle",{cx:"18",cy:"12",r:"1.5",fill:"currentColor"})]}),R=({children:_,disabled:u,isMobile:r})=>{const[o,d]=t.useState(!1),c=t.useRef(null),i=t.useRef(null),[a,g]=t.useState({top:0,left:0});t.useEffect(()=>{const n=m=>{var x;if(c.current&&!c.current.contains(m.target)){const s=m.target;(x=s.closest)!=null&&x.call(s,".Bear-RichEditor__more-menu")||d(!1)}};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[]),t.useEffect(()=>{if(o&&r&&i.current&&typeof document<"u"){const n=i.current.getBoundingClientRect();g({top:n.bottom+4,left:Math.max(8,n.right-220)})}},[o,r]);const f=e.jsx("div",{className:h.cn("Bear-RichEditor__more-menu p-2 bg-white dark:bg-zinc-800 border border-gray-200 dark:border-zinc-700 rounded-lg shadow-xl min-w-[200px] max-w-[min(90vw,280px)] max-h-[70vh] overflow-y-auto",r?"fixed z-[9999]":"absolute top-full right-0 mt-1 z-50"),style:r?{top:a.top,left:a.left}:void 0,children:e.jsx("div",{className:"flex flex-wrap items-center gap-0.5",children:_})});return e.jsxs("div",{ref:c,className:"Bear-RichEditor__more relative",children:[e.jsx("button",{ref:i,type:"button",title:"More options",disabled:u,onClick:()=>d(!o),className:h.cn("Bear-RichEditor__more-trigger",l.RICH_EDITOR_BUTTON_BASE_CLASSES,l.RICH_EDITOR_BUTTON_INACTIVE_CLASSES,"flex items-center justify-center",o&&"bg-pink-500 text-white",u&&`Bear-RichEditor__more-trigger--disabled ${l.RICH_EDITOR_BUTTON_DISABLED_CLASSES}`),children:e.jsx(p,{})}),o&&(r&&typeof document<"u"?E.createPortal(f,document.body):f)]})};exports.ToolbarMore=R;
@@ -2,6 +2,8 @@ import { FC, ReactNode } from 'react';
2
2
  export interface ToolbarMoreProps {
3
3
  children: ReactNode;
4
4
  disabled?: boolean;
5
+ /** When true, render menu via portal for mobile (avoids clipping) */
6
+ isMobile?: boolean;
5
7
  }
6
8
  export declare const ToolbarMore: FC<ToolbarMoreProps>;
7
9
  export default ToolbarMore;
@@ -1,45 +1,63 @@
1
- import { jsxs as s, jsx as e } from "react/jsx-runtime";
2
- import { useState as a, useRef as d, useEffect as m } from "react";
3
- import { cn as u } from "../../../../utils/cn.js";
4
- import { RICH_EDITOR_BUTTON_DISABLED_CLASSES as _, RICH_EDITOR_BUTTON_INACTIVE_CLASSES as f, RICH_EDITOR_BUTTON_BASE_CLASSES as h } from "../../RichEditor.const.js";
5
- const E = () => /* @__PURE__ */ s("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
6
- /* @__PURE__ */ e("line", { x1: "12", y1: "5", x2: "12", y2: "19" }),
7
- /* @__PURE__ */ e("line", { x1: "5", y1: "12", x2: "19", y2: "12" })
8
- ] }), S = ({ children: c, disabled: o }) => {
9
- const [r, i] = a(!1), t = d(null);
10
- return m(() => {
11
- const n = (l) => {
12
- t.current && !t.current.contains(l.target) && i(!1);
1
+ import { jsx as e, jsxs as g } from "react/jsx-runtime";
2
+ import { useState as f, useRef as p, useEffect as h } from "react";
3
+ import { createPortal as C } from "react-dom";
4
+ import { cn as _ } from "../../../../utils/cn.js";
5
+ import { RICH_EDITOR_BUTTON_DISABLED_CLASSES as R, RICH_EDITOR_BUTTON_INACTIVE_CLASSES as v, RICH_EDITOR_BUTTON_BASE_CLASSES as w } from "../../RichEditor.const.js";
6
+ const B = () => /* @__PURE__ */ g("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [
7
+ /* @__PURE__ */ e("circle", { cx: "12", cy: "12", r: "1.5", fill: "currentColor" }),
8
+ /* @__PURE__ */ e("circle", { cx: "6", cy: "12", r: "1.5", fill: "currentColor" }),
9
+ /* @__PURE__ */ e("circle", { cx: "18", cy: "12", r: "1.5", fill: "currentColor" })
10
+ ] }), b = ({ children: x, disabled: l, isMobile: t }) => {
11
+ const [r, s] = f(!1), n = p(null), i = p(null), [d, E] = f({ top: 0, left: 0 });
12
+ h(() => {
13
+ const o = (u) => {
14
+ var a;
15
+ if (n.current && !n.current.contains(u.target)) {
16
+ const c = u.target;
17
+ (a = c.closest) != null && a.call(c, ".Bear-RichEditor__more-menu") || s(!1);
18
+ }
13
19
  };
14
- return document.addEventListener("mousedown", n), () => document.removeEventListener("mousedown", n);
15
- }, []), /* @__PURE__ */ s("div", { ref: t, className: "Bear-RichEditor__more relative", children: [
20
+ return document.addEventListener("mousedown", o), () => document.removeEventListener("mousedown", o);
21
+ }, []), h(() => {
22
+ if (r && t && i.current && typeof document < "u") {
23
+ const o = i.current.getBoundingClientRect();
24
+ E({ top: o.bottom + 4, left: Math.max(8, o.right - 220) });
25
+ }
26
+ }, [r, t]);
27
+ const m = /* @__PURE__ */ e(
28
+ "div",
29
+ {
30
+ className: _(
31
+ "Bear-RichEditor__more-menu p-2 bg-white dark:bg-zinc-800 border border-gray-200 dark:border-zinc-700 rounded-lg shadow-xl min-w-[200px] max-w-[min(90vw,280px)] max-h-[70vh] overflow-y-auto",
32
+ t ? "fixed z-[9999]" : "absolute top-full right-0 mt-1 z-50"
33
+ ),
34
+ style: t ? { top: d.top, left: d.left } : void 0,
35
+ children: /* @__PURE__ */ e("div", { className: "flex flex-wrap items-center gap-0.5", children: x })
36
+ }
37
+ );
38
+ return /* @__PURE__ */ g("div", { ref: n, className: "Bear-RichEditor__more relative", children: [
16
39
  /* @__PURE__ */ e(
17
40
  "button",
18
41
  {
42
+ ref: i,
19
43
  type: "button",
20
44
  title: "More options",
21
- disabled: o,
22
- onClick: () => i(!r),
23
- className: u(
45
+ disabled: l,
46
+ onClick: () => s(!r),
47
+ className: _(
24
48
  "Bear-RichEditor__more-trigger",
25
- h,
26
- f,
49
+ w,
50
+ v,
27
51
  "flex items-center justify-center",
28
52
  r && "bg-pink-500 text-white",
29
- o && `Bear-RichEditor__more-trigger--disabled ${_}`
53
+ l && `Bear-RichEditor__more-trigger--disabled ${R}`
30
54
  ),
31
- children: /* @__PURE__ */ e(E, {})
55
+ children: /* @__PURE__ */ e(B, {})
32
56
  }
33
57
  ),
34
- r && /* @__PURE__ */ e(
35
- "div",
36
- {
37
- className: "Bear-RichEditor__more-menu absolute top-full right-0 mt-1 p-2 bg-white dark:bg-zinc-800 border border-gray-200 dark:border-zinc-700 rounded-lg shadow-xl z-50 min-w-[200px]",
38
- children: /* @__PURE__ */ e("div", { className: "flex flex-wrap items-center gap-0.5", children: c })
39
- }
40
- )
58
+ r && (t && typeof document < "u" ? C(m, document.body) : m)
41
59
  ] });
42
60
  };
43
61
  export {
44
- S as ToolbarMore
62
+ b as ToolbarMore
45
63
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),f=require("react"),i=require("../../utils/cn.cjs"),y={sm:"bear-h-8 bear-text-sm",md:"bear-h-10 bear-text-base",lg:"bear-h-12 bear-text-lg"},p=({items:t,value:b,defaultValue:d,onChange:a,size:c="md",fullWidth:l=!1,disabled:r=!1,className:u})=>{var o;const[x,g]=f.useState(d??((o=t[0])==null?void 0:o.value)??""),n=b??x,v=(e,m)=>{m||r||(b===void 0&&g(e),a==null||a(e))};return s.jsx("div",{role:"group","aria-label":"Segmented control",className:i.cn("Bear-SegmentedControl bear-relative bear-inline-flex bear-rounded-lg bear-bg-gray-200 dark:bear-bg-zinc-800 bear-p-1",l&&"bear-w-full",r&&"bear-opacity-50 bear-pointer-events-none",u),children:t.map(e=>s.jsx("button",{type:"button",role:"tab","aria-selected":e.value===n,"aria-disabled":e.disabled||r,disabled:e.disabled||r,onClick:()=>v(e.value,e.disabled),className:i.cn("Bear-SegmentedControl__item bear-relative bear-flex-1 bear-flex bear-items-center bear-justify-center bear-rounded-md bear-font-medium bear-transition-all bear-duration-200 bear-text-gray-600 dark:bear-text-zinc-400 hover:bear-text-gray-900 dark:hover:bear-text-zinc-200",e.value===n&&"bear-bg-white dark:bear-bg-zinc-700 bear-text-gray-900 dark:bear-text-white bear-shadow-sm",(e.disabled||r)&&"bear-cursor-not-allowed bear-opacity-50",y[c],l?"bear-min-w-0":"bear-px-4"),children:e.label},e.value))})};exports.SegmentedControl=p;
@@ -0,0 +1,3 @@
1
+ import { FC } from 'react';
2
+ import { SegmentedControlProps } from './SegmentedControl.types';
3
+ export declare const SegmentedControl: FC<SegmentedControlProps>;
@@ -0,0 +1,58 @@
1
+ import { jsx as s } from "react/jsx-runtime";
2
+ import { useState as g } from "react";
3
+ import { cn as d } from "../../utils/cn.js";
4
+ const p = {
5
+ sm: "bear-h-8 bear-text-sm",
6
+ md: "bear-h-10 bear-text-base",
7
+ lg: "bear-h-12 bear-text-lg"
8
+ }, w = ({
9
+ items: t,
10
+ value: b,
11
+ defaultValue: i,
12
+ onChange: r,
13
+ size: c = "md",
14
+ fullWidth: l = !1,
15
+ disabled: a = !1,
16
+ className: u
17
+ }) => {
18
+ var o;
19
+ const [m, x] = g(i ?? ((o = t[0]) == null ? void 0 : o.value) ?? ""), n = b ?? m, v = (e, f) => {
20
+ f || a || (b === void 0 && x(e), r == null || r(e));
21
+ };
22
+ return /* @__PURE__ */ s(
23
+ "div",
24
+ {
25
+ role: "group",
26
+ "aria-label": "Segmented control",
27
+ className: d(
28
+ "Bear-SegmentedControl bear-relative bear-inline-flex bear-rounded-lg bear-bg-gray-200 dark:bear-bg-zinc-800 bear-p-1",
29
+ l && "bear-w-full",
30
+ a && "bear-opacity-50 bear-pointer-events-none",
31
+ u
32
+ ),
33
+ children: t.map((e) => /* @__PURE__ */ s(
34
+ "button",
35
+ {
36
+ type: "button",
37
+ role: "tab",
38
+ "aria-selected": e.value === n,
39
+ "aria-disabled": e.disabled || a,
40
+ disabled: e.disabled || a,
41
+ onClick: () => v(e.value, e.disabled),
42
+ className: d(
43
+ "Bear-SegmentedControl__item bear-relative bear-flex-1 bear-flex bear-items-center bear-justify-center bear-rounded-md bear-font-medium bear-transition-all bear-duration-200 bear-text-gray-600 dark:bear-text-zinc-400 hover:bear-text-gray-900 dark:hover:bear-text-zinc-200",
44
+ e.value === n && "bear-bg-white dark:bear-bg-zinc-700 bear-text-gray-900 dark:bear-text-white bear-shadow-sm",
45
+ (e.disabled || a) && "bear-cursor-not-allowed bear-opacity-50",
46
+ p[c],
47
+ l ? "bear-min-w-0" : "bear-px-4"
48
+ ),
49
+ children: e.label
50
+ },
51
+ e.value
52
+ ))
53
+ }
54
+ );
55
+ };
56
+ export {
57
+ w as SegmentedControl
58
+ };
@@ -0,0 +1,16 @@
1
+ import { ReactNode } from 'react';
2
+ export interface SegmentedControlItem {
3
+ value: string;
4
+ label: ReactNode;
5
+ disabled?: boolean;
6
+ }
7
+ export interface SegmentedControlProps {
8
+ items: SegmentedControlItem[];
9
+ value?: string;
10
+ defaultValue?: string;
11
+ onChange?: (value: string) => void;
12
+ size?: 'sm' | 'md' | 'lg';
13
+ fullWidth?: boolean;
14
+ disabled?: boolean;
15
+ className?: string;
16
+ }
@@ -0,0 +1,2 @@
1
+ export { SegmentedControl } from './SegmentedControl';
2
+ export type { SegmentedControlProps, SegmentedControlItem } from './SegmentedControl.types';
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),s=require("react"),_=require("../../utils/cn.cjs"),p=require("../Button/Button.cjs"),a=require("./SignPad.const.cjs"),V=y=>{const{onChange:r,width:P=a.SIGN_PAD_DEFAULT_WIDTH,height:A=a.SIGN_PAD_DEFAULT_HEIGHT,strokeColor:B,strokeWidth:N=a.SIGN_PAD_DEFAULT_STROKE_WIDTH,backgroundColor:O,placeholder:U=a.SIGN_PAD_DEFAULT_PLACEHOLDER,disabled:o=!1,readOnly:l=!1,showClear:I=!0,showSave:v=!1,clearText:M="Clear",saveText:j="Save",outputFormat:h=a.SIGN_PAD_DEFAULT_OUTPUT_FORMAT,outputQuality:D=a.SIGN_PAD_DEFAULT_OUTPUT_QUALITY,className:F,testId:H,id:K,...W}=y,i=s.useRef(null),[f,x]=s.useState(!1),[u,m]=s.useState(!1),[g,C]=s.useState(null),[E,q]=s.useState(!1);s.useEffect(()=>{const e=()=>{const n=document.documentElement.classList.contains("dark");q(n)};e();const t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]);const k=B||(E?a.SIGN_PAD_STROKE_DARK:a.SIGN_PAD_STROKE_LIGHT),S=O||(E?a.SIGN_PAD_BG_DARK:a.SIGN_PAD_BG_LIGHT);s.useEffect(()=>{const e=i.current;if(!e)return;const t=e.getContext("2d");t&&(e.width=P,e.height=A,t.fillStyle=S,t.fillRect(0,0,P,A))},[P,A,S,E]);const b=s.useCallback(e=>{const t=i.current;if(!t)return{x:0,y:0};const n=t.getBoundingClientRect(),d=t.width/n.width,w=t.height/n.height;if("touches"in e){const G=e.touches[0];return{x:(G.clientX-n.left)*d,y:(G.clientY-n.top)*w}}return{x:(e.clientX-n.left)*d,y:(e.clientY-n.top)*w}},[]),L=s.useCallback(e=>{if(o||l)return;const t=b(e);x(!0),C(t)},[o,l,b]),R=s.useCallback(e=>{if(!f||o||l)return;const t=i.current,n=t==null?void 0:t.getContext("2d");if(!t||!n||!g)return;const d=b(e);n.beginPath(),n.moveTo(g.x,g.y),n.lineTo(d.x,d.y),n.strokeStyle=k,n.lineWidth=N,n.lineCap="round",n.lineJoin="round",n.stroke(),C(d),m(!0)},[f,o,l,g,k,N,b]),T=s.useCallback(()=>{if(f&&u){const e=i.current;if(e&&r){const t=e.toDataURL(h,D);r(t)}}x(!1),C(null)},[f,u,r,h,D]),X=s.useCallback(()=>{const e=i.current,t=e==null?void 0:e.getContext("2d");!e||!t||(t.fillStyle=S==="transparent"?"rgba(0,0,0,0)":S,t.clearRect(0,0,e.width,e.height),t.fillRect(0,0,e.width,e.height),m(!1),r==null||r(null))},[S,r]),Y=s.useCallback(()=>{const e=i.current;if(!e||!u)return;const t=e.toDataURL(h,D);r==null||r(t)},[u,r,h,D]);return c.jsxs("div",{id:K,"data-testid":H,className:_.cn("Bear-SignPad bear-max-w-full bear-w-full",a.SIGN_PAD_ROOT_CLASSES,o&&"Bear-SignPad--disabled bear-opacity-50",l&&"Bear-SignPad--readonly",F),...W,children:[c.jsxs("div",{className:_.cn("Bear-SignPad__canvas-wrapper bear-max-w-full bear-overflow-hidden",a.SIGN_PAD_CANVAS_WRAPPER_CLASSES,!o&&!l&&a.SIGN_PAD_CANVAS_WRAPPER_HOVER,o&&"bear-cursor-not-allowed",!o&&!l&&"bear-cursor-crosshair"),children:[c.jsx("canvas",{ref:i,className:"Bear-SignPad__canvas bear-block bear-rounded-lg bear-max-w-full",style:{width:P,height:A},onMouseDown:L,onMouseMove:R,onMouseUp:T,onMouseLeave:T,onTouchStart:L,onTouchMove:R,onTouchEnd:T}),!u&&c.jsx("div",{className:_.cn("Bear-SignPad__placeholder",a.SIGN_PAD_PLACEHOLDER_CLASSES),children:U}),c.jsx("div",{className:_.cn("Bear-SignPad__line",a.SIGN_PAD_LINE_CLASSES)}),c.jsx("span",{className:_.cn("Bear-SignPad__x-mark",a.SIGN_PAD_X_MARK_CLASSES),children:"×"})]}),(I||v)&&c.jsxs("div",{className:_.cn("Bear-SignPad__actions",a.SIGN_PAD_ACTIONS_CLASSES),children:[I&&c.jsx(p.Button,{size:"sm",variant:"ghost",onClick:X,disabled:o||!u,children:M}),v&&c.jsx(p.Button,{size:"sm",variant:"primary",onClick:Y,disabled:o||!u,children:j})]})]})};exports.SignPad=V;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),a=require("react"),_=require("../../utils/cn.cjs"),G=require("../Button/Button.cjs"),s=require("./SignPad.const.cjs"),V=y=>{const{onChange:o,width:h=s.SIGN_PAD_DEFAULT_WIDTH,height:f=s.SIGN_PAD_DEFAULT_HEIGHT,strokeColor:B,strokeWidth:m=s.SIGN_PAD_DEFAULT_STROKE_WIDTH,backgroundColor:O,placeholder:U=s.SIGN_PAD_DEFAULT_PLACEHOLDER,disabled:r=!1,readOnly:c=!1,showClear:C=!0,showSave:L=!1,clearText:M="Clear",saveText:j="Save",outputFormat:A=s.SIGN_PAD_DEFAULT_OUTPUT_FORMAT,outputQuality:P=s.SIGN_PAD_DEFAULT_OUTPUT_QUALITY,className:F,testId:H,id:K,...W}=y,l=a.useRef(null),[D,N]=a.useState(!1),[u,I]=a.useState(!1),[v,E]=a.useState(null),[b,q]=a.useState(!1);a.useEffect(()=>{const e=()=>{const n=document.documentElement.classList.contains("dark");q(n)};e();const t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]);const x=B||(b?s.SIGN_PAD_STROKE_DARK:s.SIGN_PAD_STROKE_LIGHT),S=O||(b?s.SIGN_PAD_BG_DARK:s.SIGN_PAD_BG_LIGHT);a.useEffect(()=>{const e=l.current;if(!e)return;const t=e.getContext("2d");t&&(e.width=h,e.height=f,t.fillStyle=S,t.fillRect(0,0,h,f))},[h,f,S,b]),a.useEffect(()=>{const e=l.current;if(!e||r||c)return;const t=n=>n.preventDefault();return e.addEventListener("touchstart",t,{passive:!1}),e.addEventListener("touchmove",t,{passive:!1}),()=>{e.removeEventListener("touchstart",t),e.removeEventListener("touchmove",t)}},[r,c]);const g=a.useCallback(e=>{const t=l.current;if(!t)return{x:0,y:0};const n=t.getBoundingClientRect(),d=t.width/n.width,p=t.height/n.height;if("touches"in e){const w=e.touches[0];return{x:(w.clientX-n.left)*d,y:(w.clientY-n.top)*p}}return{x:(e.clientX-n.left)*d,y:(e.clientY-n.top)*p}},[]),k=a.useCallback(e=>{if(r||c)return;const t=g(e);N(!0),E(t)},[r,c,g]),R=a.useCallback(e=>{if(!D||r||c)return;const t=l.current,n=t==null?void 0:t.getContext("2d");if(!t||!n||!v)return;const d=g(e);n.beginPath(),n.moveTo(v.x,v.y),n.lineTo(d.x,d.y),n.strokeStyle=x,n.lineWidth=m,n.lineCap="round",n.lineJoin="round",n.stroke(),E(d),I(!0)},[D,r,c,v,x,m,g]),T=a.useCallback(()=>{if(D&&u){const e=l.current;if(e&&o){const t=e.toDataURL(A,P);o(t)}}N(!1),E(null)},[D,u,o,A,P]),X=a.useCallback(()=>{const e=l.current,t=e==null?void 0:e.getContext("2d");!e||!t||(t.fillStyle=S==="transparent"?"rgba(0,0,0,0)":S,t.clearRect(0,0,e.width,e.height),t.fillRect(0,0,e.width,e.height),I(!1),o==null||o(null))},[S,o]),Y=a.useCallback(()=>{const e=l.current;if(!e||!u)return;const t=e.toDataURL(A,P);o==null||o(t)},[u,o,A,P]);return i.jsxs("div",{id:K,"data-testid":H,className:_.cn("Bear-SignPad bear-max-w-full bear-w-full",s.SIGN_PAD_ROOT_CLASSES,r&&"Bear-SignPad--disabled bear-opacity-50",c&&"Bear-SignPad--readonly",F),...W,children:[i.jsxs("div",{className:_.cn("Bear-SignPad__canvas-wrapper bear-max-w-full bear-overflow-hidden","touch-none",s.SIGN_PAD_CANVAS_WRAPPER_CLASSES,!r&&!c&&s.SIGN_PAD_CANVAS_WRAPPER_HOVER,r&&"bear-cursor-not-allowed",!r&&!c&&"bear-cursor-crosshair"),children:[i.jsx("canvas",{ref:l,className:"Bear-SignPad__canvas bear-block bear-rounded-lg bear-max-w-full touch-none",style:{width:h,height:f,touchAction:"none"},onMouseDown:k,onMouseMove:R,onMouseUp:T,onMouseLeave:T,onTouchStart:k,onTouchMove:R,onTouchEnd:T}),!u&&i.jsx("div",{className:_.cn("Bear-SignPad__placeholder",s.SIGN_PAD_PLACEHOLDER_CLASSES),children:U}),i.jsx("div",{className:_.cn("Bear-SignPad__line",s.SIGN_PAD_LINE_CLASSES)}),i.jsx("span",{className:_.cn("Bear-SignPad__x-mark",s.SIGN_PAD_X_MARK_CLASSES),children:"×"})]}),(C||L)&&i.jsxs("div",{className:_.cn("Bear-SignPad__actions",s.SIGN_PAD_ACTIONS_CLASSES),children:[C&&i.jsx(G.Button,{size:"sm",variant:"ghost",onClick:X,disabled:r||!u,children:M}),L&&i.jsx(G.Button,{size:"sm",variant:"primary",onClick:Y,disabled:r||!u,children:j})]})]})};exports.SignPad=V;
@@ -1,153 +1,161 @@
1
- import { jsxs as I, jsx as l } from "react/jsx-runtime";
2
- import { useRef as J, useState as g, useEffect as y, useCallback as d } from "react";
3
- import { cn as _ } from "../../utils/cn.js";
1
+ import { jsxs as p, jsx as l } from "react/jsx-runtime";
2
+ import { useRef as J, useState as m, useEffect as L, useCallback as u } from "react";
3
+ import { cn as d } from "../../utils/cn.js";
4
4
  import { Button as O } from "../Button/Button.js";
5
- import { SIGN_PAD_DEFAULT_WIDTH as q, SIGN_PAD_DEFAULT_HEIGHT as Z, SIGN_PAD_DEFAULT_STROKE_WIDTH as $, SIGN_PAD_DEFAULT_PLACEHOLDER as tt, SIGN_PAD_DEFAULT_OUTPUT_FORMAT as et, SIGN_PAD_DEFAULT_OUTPUT_QUALITY as rt, SIGN_PAD_BG_DARK as nt, SIGN_PAD_BG_LIGHT as at, SIGN_PAD_STROKE_DARK as ot, SIGN_PAD_STROKE_LIGHT as st, SIGN_PAD_PLACEHOLDER_CLASSES as ct, SIGN_PAD_LINE_CLASSES as it, SIGN_PAD_X_MARK_CLASSES as lt, SIGN_PAD_CANVAS_WRAPPER_HOVER as dt, SIGN_PAD_CANVAS_WRAPPER_CLASSES as _t, SIGN_PAD_ACTIONS_CLASSES as ut, SIGN_PAD_ROOT_CLASSES as St } from "./SignPad.const.js";
6
- const mt = (U) => {
5
+ import { SIGN_PAD_DEFAULT_WIDTH as q, SIGN_PAD_DEFAULT_HEIGHT as Z, SIGN_PAD_DEFAULT_STROKE_WIDTH as $, SIGN_PAD_DEFAULT_PLACEHOLDER as ee, SIGN_PAD_DEFAULT_OUTPUT_FORMAT as te, SIGN_PAD_DEFAULT_OUTPUT_QUALITY as ne, SIGN_PAD_BG_DARK as re, SIGN_PAD_BG_LIGHT as oe, SIGN_PAD_STROKE_DARK as ae, SIGN_PAD_STROKE_LIGHT as se, SIGN_PAD_PLACEHOLDER_CLASSES as ce, SIGN_PAD_LINE_CLASSES as ie, SIGN_PAD_X_MARK_CLASSES as le, SIGN_PAD_CANVAS_WRAPPER_HOVER as ue, SIGN_PAD_CANVAS_WRAPPER_CLASSES as de, SIGN_PAD_ACTIONS_CLASSES as _e, SIGN_PAD_ROOT_CLASSES as Se } from "./SignPad.const.js";
6
+ const ve = (U) => {
7
7
  const {
8
- onChange: n,
8
+ onChange: o,
9
9
  width: S = q,
10
- height: A = Z,
10
+ height: h = Z,
11
11
  strokeColor: B,
12
- strokeWidth: b = $,
12
+ strokeWidth: N = $,
13
13
  backgroundColor: M,
14
- placeholder: F = tt,
15
- disabled: a = !1,
16
- readOnly: o = !1,
17
- showClear: v = !0,
18
- showSave: p = !1,
14
+ placeholder: F = ee,
15
+ disabled: r = !1,
16
+ readOnly: a = !1,
17
+ showClear: I = !0,
18
+ showSave: b = !1,
19
19
  clearText: H = "Clear",
20
20
  saveText: K = "Save",
21
- outputFormat: h = et,
22
- outputQuality: P = rt,
21
+ outputFormat: f = te,
22
+ outputQuality: A = ne,
23
23
  className: W,
24
24
  testId: X,
25
25
  id: Y,
26
26
  ...V
27
- } = U, s = J(null), [f, C] = g(!1), [c, L] = g(!1), [D, E] = g(null), [N, j] = g(!1);
28
- y(() => {
29
- const t = () => {
30
- const r = document.documentElement.classList.contains("dark");
31
- j(r);
27
+ } = U, s = J(null), [D, C] = m(!1), [c, R] = m(!1), [P, E] = m(null), [g, j] = m(!1);
28
+ L(() => {
29
+ const e = () => {
30
+ const n = document.documentElement.classList.contains("dark");
31
+ j(n);
32
32
  };
33
- t();
34
- const e = new MutationObserver(t);
35
- return e.observe(document.documentElement, { attributes: !0, attributeFilter: ["class"] }), () => e.disconnect();
33
+ e();
34
+ const t = new MutationObserver(e);
35
+ return t.observe(document.documentElement, { attributes: !0, attributeFilter: ["class"] }), () => t.disconnect();
36
36
  }, []);
37
- const R = B || (N ? ot : st), u = M || (N ? nt : at);
38
- y(() => {
39
- const t = s.current;
40
- if (!t) return;
41
- const e = t.getContext("2d");
42
- e && (t.width = S, t.height = A, e.fillStyle = u, e.fillRect(0, 0, S, A));
43
- }, [S, A, u, N]);
44
- const m = d((t) => {
37
+ const w = B || (g ? ae : se), _ = M || (g ? re : oe);
38
+ L(() => {
39
+ const e = s.current;
40
+ if (!e) return;
41
+ const t = e.getContext("2d");
42
+ t && (e.width = S, e.height = h, t.fillStyle = _, t.fillRect(0, 0, S, h));
43
+ }, [S, h, _, g]), L(() => {
45
44
  const e = s.current;
46
- if (!e) return { x: 0, y: 0 };
47
- const r = e.getBoundingClientRect(), i = e.width / r.width, k = e.height / r.height;
48
- if ("touches" in t) {
49
- const x = t.touches[0];
45
+ if (!e || r || a) return;
46
+ const t = (n) => n.preventDefault();
47
+ return e.addEventListener("touchstart", t, { passive: !1 }), e.addEventListener("touchmove", t, { passive: !1 }), () => {
48
+ e.removeEventListener("touchstart", t), e.removeEventListener("touchmove", t);
49
+ };
50
+ }, [r, a]);
51
+ const v = u((e) => {
52
+ const t = s.current;
53
+ if (!t) return { x: 0, y: 0 };
54
+ const n = t.getBoundingClientRect(), i = t.width / n.width, x = t.height / n.height;
55
+ if ("touches" in e) {
56
+ const y = e.touches[0];
50
57
  return {
51
- x: (x.clientX - r.left) * i,
52
- y: (x.clientY - r.top) * k
58
+ x: (y.clientX - n.left) * i,
59
+ y: (y.clientY - n.top) * x
53
60
  };
54
61
  }
55
62
  return {
56
- x: (t.clientX - r.left) * i,
57
- y: (t.clientY - r.top) * k
63
+ x: (e.clientX - n.left) * i,
64
+ y: (e.clientY - n.top) * x
58
65
  };
59
- }, []), w = d((t) => {
60
- if (a || o) return;
61
- const e = m(t);
62
- C(!0), E(e);
63
- }, [a, o, m]), G = d((t) => {
64
- if (!f || a || o) return;
65
- const e = s.current, r = e == null ? void 0 : e.getContext("2d");
66
- if (!e || !r || !D) return;
67
- const i = m(t);
68
- r.beginPath(), r.moveTo(D.x, D.y), r.lineTo(i.x, i.y), r.strokeStyle = R, r.lineWidth = b, r.lineCap = "round", r.lineJoin = "round", r.stroke(), E(i), L(!0);
69
- }, [f, a, o, D, R, b, m]), T = d(() => {
70
- if (f && c) {
71
- const t = s.current;
72
- if (t && n) {
73
- const e = t.toDataURL(h, P);
74
- n(e);
66
+ }, []), G = u((e) => {
67
+ if (r || a) return;
68
+ const t = v(e);
69
+ C(!0), E(t);
70
+ }, [r, a, v]), k = u((e) => {
71
+ if (!D || r || a) return;
72
+ const t = s.current, n = t == null ? void 0 : t.getContext("2d");
73
+ if (!t || !n || !P) return;
74
+ const i = v(e);
75
+ n.beginPath(), n.moveTo(P.x, P.y), n.lineTo(i.x, i.y), n.strokeStyle = w, n.lineWidth = N, n.lineCap = "round", n.lineJoin = "round", n.stroke(), E(i), R(!0);
76
+ }, [D, r, a, P, w, N, v]), T = u(() => {
77
+ if (D && c) {
78
+ const e = s.current;
79
+ if (e && o) {
80
+ const t = e.toDataURL(f, A);
81
+ o(t);
75
82
  }
76
83
  }
77
84
  C(!1), E(null);
78
- }, [f, c, n, h, P]), z = d(() => {
79
- const t = s.current, e = t == null ? void 0 : t.getContext("2d");
80
- !t || !e || (e.fillStyle = u === "transparent" ? "rgba(0,0,0,0)" : u, e.clearRect(0, 0, t.width, t.height), e.fillRect(0, 0, t.width, t.height), L(!1), n == null || n(null));
81
- }, [u, n]), Q = d(() => {
82
- const t = s.current;
83
- if (!t || !c) return;
84
- const e = t.toDataURL(h, P);
85
- n == null || n(e);
86
- }, [c, n, h, P]);
87
- return /* @__PURE__ */ I(
85
+ }, [D, c, o, f, A]), z = u(() => {
86
+ const e = s.current, t = e == null ? void 0 : e.getContext("2d");
87
+ !e || !t || (t.fillStyle = _ === "transparent" ? "rgba(0,0,0,0)" : _, t.clearRect(0, 0, e.width, e.height), t.fillRect(0, 0, e.width, e.height), R(!1), o == null || o(null));
88
+ }, [_, o]), Q = u(() => {
89
+ const e = s.current;
90
+ if (!e || !c) return;
91
+ const t = e.toDataURL(f, A);
92
+ o == null || o(t);
93
+ }, [c, o, f, A]);
94
+ return /* @__PURE__ */ p(
88
95
  "div",
89
96
  {
90
97
  id: Y,
91
98
  "data-testid": X,
92
- className: _(
99
+ className: d(
93
100
  "Bear-SignPad bear-max-w-full bear-w-full",
94
- St,
95
- a && "Bear-SignPad--disabled bear-opacity-50",
96
- o && "Bear-SignPad--readonly",
101
+ Se,
102
+ r && "Bear-SignPad--disabled bear-opacity-50",
103
+ a && "Bear-SignPad--readonly",
97
104
  W
98
105
  ),
99
106
  ...V,
100
107
  children: [
101
- /* @__PURE__ */ I(
108
+ /* @__PURE__ */ p(
102
109
  "div",
103
110
  {
104
- className: _(
111
+ className: d(
105
112
  "Bear-SignPad__canvas-wrapper bear-max-w-full bear-overflow-hidden",
106
- _t,
107
- !a && !o && dt,
108
- a && "bear-cursor-not-allowed",
109
- !a && !o && "bear-cursor-crosshair"
113
+ "touch-none",
114
+ de,
115
+ !r && !a && ue,
116
+ r && "bear-cursor-not-allowed",
117
+ !r && !a && "bear-cursor-crosshair"
110
118
  ),
111
119
  children: [
112
120
  /* @__PURE__ */ l(
113
121
  "canvas",
114
122
  {
115
123
  ref: s,
116
- className: "Bear-SignPad__canvas bear-block bear-rounded-lg bear-max-w-full",
117
- style: { width: S, height: A },
118
- onMouseDown: w,
119
- onMouseMove: G,
124
+ className: "Bear-SignPad__canvas bear-block bear-rounded-lg bear-max-w-full touch-none",
125
+ style: { width: S, height: h, touchAction: "none" },
126
+ onMouseDown: G,
127
+ onMouseMove: k,
120
128
  onMouseUp: T,
121
129
  onMouseLeave: T,
122
- onTouchStart: w,
123
- onTouchMove: G,
130
+ onTouchStart: G,
131
+ onTouchMove: k,
124
132
  onTouchEnd: T
125
133
  }
126
134
  ),
127
- !c && /* @__PURE__ */ l("div", { className: _("Bear-SignPad__placeholder", ct), children: F }),
128
- /* @__PURE__ */ l("div", { className: _("Bear-SignPad__line", it) }),
129
- /* @__PURE__ */ l("span", { className: _("Bear-SignPad__x-mark", lt), children: "×" })
135
+ !c && /* @__PURE__ */ l("div", { className: d("Bear-SignPad__placeholder", ce), children: F }),
136
+ /* @__PURE__ */ l("div", { className: d("Bear-SignPad__line", ie) }),
137
+ /* @__PURE__ */ l("span", { className: d("Bear-SignPad__x-mark", le), children: "×" })
130
138
  ]
131
139
  }
132
140
  ),
133
- (v || p) && /* @__PURE__ */ I("div", { className: _("Bear-SignPad__actions", ut), children: [
134
- v && /* @__PURE__ */ l(
141
+ (I || b) && /* @__PURE__ */ p("div", { className: d("Bear-SignPad__actions", _e), children: [
142
+ I && /* @__PURE__ */ l(
135
143
  O,
136
144
  {
137
145
  size: "sm",
138
146
  variant: "ghost",
139
147
  onClick: z,
140
- disabled: a || !c,
148
+ disabled: r || !c,
141
149
  children: H
142
150
  }
143
151
  ),
144
- p && /* @__PURE__ */ l(
152
+ b && /* @__PURE__ */ l(
145
153
  O,
146
154
  {
147
155
  size: "sm",
148
156
  variant: "primary",
149
157
  onClick: Q,
150
- disabled: a || !c,
158
+ disabled: r || !c,
151
159
  children: K
152
160
  }
153
161
  )
@@ -157,5 +165,5 @@ const mt = (U) => {
157
165
  );
158
166
  };
159
167
  export {
160
- mt as SignPad
168
+ ve as SignPad
161
169
  };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),u=require("react"),d=require("../../utils/cn.cjs"),X={xs:{track:"bear-h-1",thumb:"bear-w-3 bear-h-3",height:"bear-h-6"},sm:{track:"bear-h-1.5",thumb:"bear-w-4 bear-h-4",height:"bear-h-8"},md:{track:"bear-h-2",thumb:"bear-w-5 bear-h-5",height:"bear-h-10"},lg:{track:"bear-h-2.5",thumb:"bear-w-6 bear-h-6",height:"bear-h-12"},xl:{track:"bear-h-3",thumb:"bear-w-7 bear-h-7",height:"bear-h-14"}},Y={primary:{track:"bear-bg-bear-500",thumb:"bear-bg-bear-500 bear-border-bear-600"},secondary:{track:"bear-bg-gray-500",thumb:"bear-bg-gray-500 bear-border-gray-600"},success:{track:"bear-bg-green-500",thumb:"bear-bg-green-500 bear-border-green-600"},warning:{track:"bear-bg-amber-500",thumb:"bear-bg-amber-500 bear-border-amber-600"},error:{track:"bear-bg-red-500",thumb:"bear-bg-red-500 bear-border-red-600"},danger:{track:"bear-bg-red-500",thumb:"bear-bg-red-500 bear-border-red-600"},info:{track:"bear-bg-blue-500",thumb:"bear-bg-blue-500 bear-border-blue-600"},ghost:{track:"bear-bg-gray-400",thumb:"bear-bg-gray-400 bear-border-gray-500"},outline:{track:"bear-bg-gray-600",thumb:"bear-bg-white dark:bear-bg-gray-200 bear-border-gray-600 dark:bear-border-gray-400"}},_=(c,f,e,r)=>{const l=Math.round(c/r)*r;return Math.max(f,Math.min(e,l))},A=({value:c,defaultValue:f=[20,80],min:e=0,max:r=100,step:l=1,size:$="md",color:q="primary",disabled:b=!1,onChange:s,onChangeCommitted:g,valueFormatter:B=w=>String(w),className:z,...O})=>{const[w,L]=u.useState(f),[t,E]=u.useState(null),y=u.useRef(null),k=c??w,[n,o]=k,x=(n-e)/(r-e)*100,j=(o-e)/(r-e)*100,m=X[$],M=Y[q],S=u.useCallback((a,v)=>{if(!y.current||b)return;const T=y.current.getBoundingClientRect(),P=Math.max(0,Math.min(1,(a-T.left)/T.width)),V=e+P*(r-e),D=_(V,e,r,l);if(v==="min"){const i=[Math.min(D,o-l),o];c===void 0&&L(i),s==null||s(i)}else{const I=Math.max(D,n+l),i=[n,I];c===void 0&&L(i),s==null||s(i)}},[e,r,l,n,o,b,c,s]),N=(a,v)=>{b||(a.preventDefault(),E(v),S(a.clientX,v))},p=u.useCallback(a=>{t&&S(a.clientX,t)},[t,S]),R=u.useCallback(()=>{t&&(E(null),g==null||g(k))},[t,k,g]);return u.useEffect(()=>{if(t)return document.addEventListener("mousemove",p),document.addEventListener("mouseup",R),()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",R)}},[t,p,R]),h.jsx("div",{className:d.cn("bear-relative bear-w-full bear-flex bear-items-center",m.height,b&&"bear-opacity-50 bear-cursor-not-allowed",z),"data-testid":"slider-range",...O,children:h.jsxs("div",{ref:y,className:d.cn("bear-relative bear-w-full bear-rounded-full bear-bg-gray-200 dark:bear-bg-gray-700",m.track,!b&&"bear-cursor-pointer"),children:[h.jsx("div",{className:d.cn("bear-absolute bear-inset-y-0 bear-left-0 bear-rounded-full",M.track),style:{left:`${x}%`,width:`${j-x}%`}}),h.jsx("div",{role:"slider",tabIndex:b?-1:0,"aria-valuemin":e,"aria-valuemax":r,"aria-valuenow":n,"aria-label":"Range minimum",className:d.cn("bear-absolute bear-top-1/2 bear--translate-y-1/2 bear--translate-x-1/2 bear-rounded-full bear-border-2 bear-shadow-md",m.thumb,M.thumb,!b&&"bear-cursor-grab active:bear-cursor-grabbing hover:bear-scale-110",t==="min"&&"bear-scale-125 bear-z-10"),style:{left:`${x}%`},onMouseDown:a=>N(a,"min")}),h.jsx("div",{role:"slider",tabIndex:b?-1:0,"aria-valuemin":e,"aria-valuemax":r,"aria-valuenow":o,"aria-label":"Range maximum",className:d.cn("bear-absolute bear-top-1/2 bear--translate-y-1/2 bear--translate-x-1/2 bear-rounded-full bear-border-2 bear-shadow-md",m.thumb,M.thumb,!b&&"bear-cursor-grab active:bear-cursor-grabbing hover:bear-scale-110",t==="max"&&"bear-scale-125 bear-z-10"),style:{left:`${j}%`},onMouseDown:a=>N(a,"max")})]})})};exports.SliderRange=A;
@@ -0,0 +1,3 @@
1
+ import { FC } from 'react';
2
+ import { SliderRangeProps } from './SliderRange.types';
3
+ export declare const SliderRange: FC<SliderRangeProps>;