@forgedevstack/bear 1.0.5 → 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.
- package/dist/components/BottomSheet/BottomSheet.cjs +1 -0
- package/dist/components/BottomSheet/BottomSheet.d.ts +3 -0
- package/dist/components/BottomSheet/BottomSheet.js +102 -0
- package/dist/components/BottomSheet/BottomSheet.types.d.ts +13 -0
- package/dist/components/BottomSheet/index.d.ts +2 -0
- package/dist/components/Button/Button.cjs +1 -1
- package/dist/components/Button/Button.js +40 -38
- package/dist/components/Button/Button.types.d.ts +4 -0
- package/dist/components/Calendar/Calendar.cjs +1 -1
- package/dist/components/Calendar/Calendar.const.cjs +1 -1
- package/dist/components/Calendar/Calendar.const.d.ts +1 -0
- package/dist/components/Calendar/Calendar.const.js +6 -5
- package/dist/components/Calendar/Calendar.helpers.cjs +1 -1
- package/dist/components/Calendar/Calendar.helpers.js +4 -4
- package/dist/components/Calendar/Calendar.js +128 -128
- package/dist/components/Cascader/Cascader.cjs +1 -0
- package/dist/components/Cascader/Cascader.const.cjs +1 -0
- package/dist/components/Cascader/Cascader.const.d.ts +33 -0
- package/dist/components/Cascader/Cascader.const.js +21 -0
- package/dist/components/Cascader/Cascader.d.ts +17 -0
- package/dist/components/Cascader/Cascader.js +227 -0
- package/dist/components/Cascader/Cascader.types.d.ts +94 -0
- package/dist/components/Cascader/index.d.ts +2 -0
- package/dist/components/CommandPalette/CommandPalette.cjs +1 -0
- package/dist/components/CommandPalette/CommandPalette.const.cjs +1 -0
- package/dist/components/CommandPalette/CommandPalette.const.d.ts +25 -0
- package/dist/components/CommandPalette/CommandPalette.const.js +13 -0
- package/dist/components/CommandPalette/CommandPalette.d.ts +18 -0
- package/dist/components/CommandPalette/CommandPalette.js +190 -0
- package/dist/components/CommandPalette/CommandPalette.types.d.ts +90 -0
- package/dist/components/CommandPalette/CommandPalette.utils.cjs +1 -0
- package/dist/components/CommandPalette/CommandPalette.utils.d.ts +17 -0
- package/dist/components/CommandPalette/CommandPalette.utils.js +63 -0
- package/dist/components/CommandPalette/index.d.ts +2 -0
- package/dist/components/CreditInput/CreditInput.cjs +1 -0
- package/dist/components/CreditInput/CreditInput.const.cjs +1 -0
- package/dist/components/CreditInput/CreditInput.const.d.ts +37 -0
- package/dist/components/CreditInput/CreditInput.const.js +66 -0
- package/dist/components/CreditInput/CreditInput.d.ts +15 -0
- package/dist/components/CreditInput/CreditInput.js +214 -0
- package/dist/components/CreditInput/CreditInput.types.d.ts +93 -0
- package/dist/components/CreditInput/CreditInput.utils.cjs +1 -0
- package/dist/components/CreditInput/CreditInput.utils.d.ts +48 -0
- package/dist/components/CreditInput/CreditInput.utils.js +79 -0
- package/dist/components/CreditInput/index.d.ts +2 -0
- package/dist/components/DatePicker/DatePicker.cjs +1 -1
- package/dist/components/DatePicker/DatePicker.js +108 -84
- package/dist/components/DatePicker/DatePicker.types.d.ts +2 -1
- package/dist/components/Drawer/Drawer.cjs +1 -1
- package/dist/components/Drawer/Drawer.js +75 -44
- package/dist/components/EmojiPicker/EmojiPicker.cjs +1 -0
- package/dist/components/EmojiPicker/EmojiPicker.const.cjs +1 -0
- package/dist/components/EmojiPicker/EmojiPicker.const.d.ts +5 -0
- package/dist/components/EmojiPicker/EmojiPicker.const.js +10 -0
- package/dist/components/EmojiPicker/EmojiPicker.d.ts +3 -0
- package/dist/components/EmojiPicker/EmojiPicker.js +63 -0
- package/dist/components/EmojiPicker/EmojiPicker.types.d.ts +6 -0
- package/dist/components/EmojiPicker/index.d.ts +3 -0
- package/dist/components/Form/Form.cjs +1 -0
- package/dist/components/Form/Form.const.cjs +1 -0
- package/dist/components/Form/Form.const.d.ts +33 -0
- package/dist/components/Form/Form.const.js +27 -0
- package/dist/components/Form/Form.context.cjs +1 -0
- package/dist/components/Form/Form.context.d.ts +13 -0
- package/dist/components/Form/Form.context.js +12 -0
- package/dist/components/Form/Form.d.ts +18 -0
- package/dist/components/Form/Form.js +230 -0
- package/dist/components/Form/Form.types.d.ts +166 -0
- package/dist/components/Form/Form.utils.cjs +1 -0
- package/dist/components/Form/Form.utils.d.ts +17 -0
- package/dist/components/Form/Form.utils.js +31 -0
- package/dist/components/Form/index.d.ts +3 -0
- package/dist/components/Kanban/Kanban.cjs +1 -0
- package/dist/components/Kanban/Kanban.d.ts +3 -0
- package/dist/components/Kanban/Kanban.js +90 -0
- package/dist/components/Kanban/Kanban.types.d.ts +21 -0
- package/dist/components/Kanban/index.d.ts +2 -0
- package/dist/components/MentionsInput/MentionsInput.cjs +1 -0
- package/dist/components/MentionsInput/MentionsInput.d.ts +3 -0
- package/dist/components/MentionsInput/MentionsInput.js +140 -0
- package/dist/components/MentionsInput/MentionsInput.types.d.ts +21 -0
- package/dist/components/MentionsInput/index.d.ts +2 -0
- package/dist/components/NotificationCenter/NotificationCenter.cjs +1 -0
- package/dist/components/NotificationCenter/NotificationCenter.const.cjs +1 -0
- package/dist/components/NotificationCenter/NotificationCenter.const.d.ts +25 -0
- package/dist/components/NotificationCenter/NotificationCenter.const.js +28 -0
- package/dist/components/NotificationCenter/NotificationCenter.d.ts +15 -0
- package/dist/components/NotificationCenter/NotificationCenter.js +223 -0
- package/dist/components/NotificationCenter/NotificationCenter.types.d.ts +117 -0
- package/dist/components/NotificationCenter/NotificationCenter.utils.cjs +1 -0
- package/dist/components/NotificationCenter/NotificationCenter.utils.d.ts +11 -0
- package/dist/components/NotificationCenter/NotificationCenter.utils.js +19 -0
- package/dist/components/NotificationCenter/index.d.ts +2 -0
- package/dist/components/PhoneInput/PhoneInput.cjs +1 -0
- package/dist/components/PhoneInput/PhoneInput.const.cjs +1 -0
- package/dist/components/PhoneInput/PhoneInput.const.d.ts +33 -0
- package/dist/components/PhoneInput/PhoneInput.const.js +82 -0
- package/dist/components/PhoneInput/PhoneInput.d.ts +16 -0
- package/dist/components/PhoneInput/PhoneInput.js +194 -0
- package/dist/components/PhoneInput/PhoneInput.types.d.ts +108 -0
- package/dist/components/PhoneInput/PhoneInput.utils.cjs +1 -0
- package/dist/components/PhoneInput/PhoneInput.utils.d.ts +25 -0
- package/dist/components/PhoneInput/PhoneInput.utils.js +39 -0
- package/dist/components/PhoneInput/index.d.ts +2 -0
- package/dist/components/RichEditor/RichEditor.cjs +1 -1
- package/dist/components/RichEditor/RichEditor.const.cjs +2 -2
- package/dist/components/RichEditor/RichEditor.const.d.ts +4 -1
- package/dist/components/RichEditor/RichEditor.const.js +51 -18
- package/dist/components/RichEditor/RichEditor.js +106 -105
- package/dist/components/RichEditor/components/ToolbarColorPicker/ToolbarColorPicker.cjs +1 -1
- package/dist/components/RichEditor/components/ToolbarColorPicker/ToolbarColorPicker.js +105 -95
- package/dist/components/RichEditor/components/ToolbarMore/ToolbarMore.cjs +1 -1
- package/dist/components/RichEditor/components/ToolbarMore/ToolbarMore.d.ts +2 -0
- package/dist/components/RichEditor/components/ToolbarMore/ToolbarMore.js +47 -29
- package/dist/components/SegmentedControl/SegmentedControl.cjs +1 -0
- package/dist/components/SegmentedControl/SegmentedControl.d.ts +3 -0
- package/dist/components/SegmentedControl/SegmentedControl.js +58 -0
- package/dist/components/SegmentedControl/SegmentedControl.types.d.ts +16 -0
- package/dist/components/SegmentedControl/index.d.ts +2 -0
- package/dist/components/SignPad/SignPad.cjs +1 -1
- package/dist/components/SignPad/SignPad.js +94 -86
- package/dist/components/SliderRange/SliderRange.cjs +1 -0
- package/dist/components/SliderRange/SliderRange.d.ts +3 -0
- package/dist/components/SliderRange/SliderRange.js +142 -0
- package/dist/components/SliderRange/SliderRange.types.d.ts +17 -0
- package/dist/components/SliderRange/index.d.ts +2 -0
- package/dist/components/TagsInput/TagsInput.cjs +1 -0
- package/dist/components/TagsInput/TagsInput.d.ts +3 -0
- package/dist/components/TagsInput/TagsInput.js +100 -0
- package/dist/components/TagsInput/TagsInput.types.d.ts +16 -0
- package/dist/components/TagsInput/index.d.ts +2 -0
- package/dist/components/TimePicker/TimePicker.cjs +1 -1
- package/dist/components/TimePicker/TimePicker.constants.cjs +1 -1
- package/dist/components/TimePicker/TimePicker.constants.d.ts +22 -1
- package/dist/components/TimePicker/TimePicker.constants.js +36 -19
- package/dist/components/TimePicker/TimePicker.js +97 -131
- package/dist/components/TimePicker/TimePicker.types.d.ts +47 -6
- package/dist/components/TimePicker/components/TimePickerColumnsDropdown/TimePickerColumnsDropdown.cjs +1 -0
- package/dist/components/TimePicker/components/TimePickerColumnsDropdown/TimePickerColumnsDropdown.d.ts +3 -0
- package/dist/components/TimePicker/components/TimePickerColumnsDropdown/TimePickerColumnsDropdown.js +81 -0
- package/dist/components/TimePicker/components/TimePickerColumnsDropdown/index.d.ts +1 -0
- package/dist/components/TimePicker/components/TimePickerDialDropdown/TimePickerDialDropdown.cjs +1 -0
- package/dist/components/TimePicker/components/TimePickerDialDropdown/TimePickerDialDropdown.d.ts +3 -0
- package/dist/components/TimePicker/components/TimePickerDialDropdown/TimePickerDialDropdown.js +84 -0
- package/dist/components/TimePicker/components/TimePickerDialDropdown/index.d.ts +1 -0
- package/dist/components/TimePicker/helpers/ClockFaceSvg.cjs +1 -0
- package/dist/components/TimePicker/helpers/ClockFaceSvg.d.ts +18 -0
- package/dist/components/TimePicker/helpers/ClockFaceSvg.js +67 -0
- package/dist/components/TimePicker/helpers/index.d.ts +2 -0
- package/dist/components/TimePicker/index.d.ts +1 -1
- package/dist/components/VirtualList/VirtualList.cjs +1 -0
- package/dist/components/VirtualList/VirtualList.d.ts +3 -0
- package/dist/components/VirtualList/VirtualList.js +68 -0
- package/dist/components/VirtualList/VirtualList.types.d.ts +10 -0
- package/dist/components/VirtualList/index.d.ts +2 -0
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.d.ts +28 -2
- package/dist/components/index.js +177 -146
- package/dist/hooks/index.cjs +1 -1
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/index.js +36 -32
- package/dist/hooks/useDragDrop/index.d.ts +2 -0
- package/dist/hooks/useDragDrop/useDragDrop.cjs +1 -0
- package/dist/hooks/useDragDrop/useDragDrop.d.ts +22 -0
- package/dist/hooks/useDragDrop/useDragDrop.js +56 -0
- package/dist/hooks/useDragDrop/useDragDrop.types.d.ts +55 -0
- package/dist/hooks/useLazyLoad/index.d.ts +2 -0
- package/dist/hooks/useLazyLoad/useLazyLoad.cjs +1 -0
- package/dist/hooks/useLazyLoad/useLazyLoad.d.ts +26 -0
- package/dist/hooks/useLazyLoad/useLazyLoad.js +27 -0
- package/dist/hooks/useLazyLoad/useLazyLoad.types.d.ts +25 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +290 -255
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/dist/components/DateTimePicker/DateTimePicker.cjs +0 -1
- package/dist/components/DateTimePicker/DateTimePicker.d.ts +0 -3
- package/dist/components/DateTimePicker/DateTimePicker.js +0 -178
- package/dist/components/DateTimePicker/DateTimePicker.types.d.ts +0 -26
- package/dist/components/DateTimePicker/DateTimePicker.utils.cjs +0 -1
- package/dist/components/DateTimePicker/DateTimePicker.utils.d.ts +0 -2
- package/dist/components/DateTimePicker/DateTimePicker.utils.js +0 -16
- package/dist/components/DateTimePicker/index.d.ts +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),
|
|
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 {
|
|
2
|
-
import { useState as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
/* @__PURE__ */ e("
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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",
|
|
15
|
-
}, []),
|
|
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:
|
|
22
|
-
onClick: () =>
|
|
23
|
-
className:
|
|
45
|
+
disabled: l,
|
|
46
|
+
onClick: () => s(!r),
|
|
47
|
+
className: _(
|
|
24
48
|
"Bear-RichEditor__more-trigger",
|
|
25
|
-
|
|
26
|
-
|
|
49
|
+
w,
|
|
50
|
+
v,
|
|
27
51
|
"flex items-center justify-center",
|
|
28
52
|
r && "bg-pink-500 text-white",
|
|
29
|
-
|
|
53
|
+
l && `Bear-RichEditor__more-trigger--disabled ${R}`
|
|
30
54
|
),
|
|
31
|
-
children: /* @__PURE__ */ e(
|
|
55
|
+
children: /* @__PURE__ */ e(B, {})
|
|
32
56
|
}
|
|
33
57
|
),
|
|
34
|
-
r &&
|
|
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
|
-
|
|
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,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
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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
|
|
2
|
-
import { useRef as J, useState as m, useEffect as
|
|
3
|
-
import { cn as
|
|
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
|
|
6
|
-
const
|
|
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:
|
|
8
|
+
onChange: o,
|
|
9
9
|
width: S = q,
|
|
10
|
-
height:
|
|
10
|
+
height: h = Z,
|
|
11
11
|
strokeColor: B,
|
|
12
|
-
strokeWidth:
|
|
12
|
+
strokeWidth: N = $,
|
|
13
13
|
backgroundColor: M,
|
|
14
|
-
placeholder: F =
|
|
15
|
-
disabled:
|
|
14
|
+
placeholder: F = ee,
|
|
15
|
+
disabled: r = !1,
|
|
16
16
|
readOnly: a = !1,
|
|
17
|
-
showClear:
|
|
18
|
-
showSave:
|
|
17
|
+
showClear: I = !0,
|
|
18
|
+
showSave: b = !1,
|
|
19
19
|
clearText: H = "Clear",
|
|
20
20
|
saveText: K = "Save",
|
|
21
|
-
outputFormat:
|
|
22
|
-
outputQuality:
|
|
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), [D,
|
|
28
|
-
|
|
29
|
-
const
|
|
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
30
|
const n = document.documentElement.classList.contains("dark");
|
|
31
31
|
j(n);
|
|
32
32
|
};
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
return
|
|
33
|
+
e();
|
|
34
|
+
const t = new MutationObserver(e);
|
|
35
|
+
return t.observe(document.documentElement, { attributes: !0, attributeFilter: ["class"] }), () => t.disconnect();
|
|
36
36
|
}, []);
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
if (!
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
}, [S,
|
|
44
|
-
const g = 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
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
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: (
|
|
52
|
-
y: (
|
|
58
|
+
x: (y.clientX - n.left) * i,
|
|
59
|
+
y: (y.clientY - n.top) * x
|
|
53
60
|
};
|
|
54
61
|
}
|
|
55
62
|
return {
|
|
56
|
-
x: (
|
|
57
|
-
y: (
|
|
63
|
+
x: (e.clientX - n.left) * i,
|
|
64
|
+
y: (e.clientY - n.top) * x
|
|
58
65
|
};
|
|
59
|
-
}, []),
|
|
60
|
-
if (
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
}, [
|
|
64
|
-
if (!D ||
|
|
65
|
-
const
|
|
66
|
-
if (!
|
|
67
|
-
const i =
|
|
68
|
-
n.beginPath(), n.moveTo(
|
|
69
|
-
}, [D,
|
|
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(() => {
|
|
70
77
|
if (D && c) {
|
|
71
|
-
const
|
|
72
|
-
if (
|
|
73
|
-
const
|
|
74
|
-
|
|
78
|
+
const e = s.current;
|
|
79
|
+
if (e && o) {
|
|
80
|
+
const t = e.toDataURL(f, A);
|
|
81
|
+
o(t);
|
|
75
82
|
}
|
|
76
83
|
}
|
|
77
|
-
|
|
78
|
-
}, [D, c,
|
|
79
|
-
const
|
|
80
|
-
!
|
|
81
|
-
}, [
|
|
82
|
-
const
|
|
83
|
-
if (!
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
}, [c,
|
|
87
|
-
return /* @__PURE__ */
|
|
84
|
+
C(!1), E(null);
|
|
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:
|
|
93
|
-
"Bear-SignPad",
|
|
94
|
-
|
|
95
|
-
|
|
99
|
+
className: d(
|
|
100
|
+
"Bear-SignPad bear-max-w-full bear-w-full",
|
|
101
|
+
Se,
|
|
102
|
+
r && "Bear-SignPad--disabled bear-opacity-50",
|
|
96
103
|
a && "Bear-SignPad--readonly",
|
|
97
104
|
W
|
|
98
105
|
),
|
|
99
106
|
...V,
|
|
100
107
|
children: [
|
|
101
|
-
/* @__PURE__ */
|
|
108
|
+
/* @__PURE__ */ p(
|
|
102
109
|
"div",
|
|
103
110
|
{
|
|
104
|
-
className:
|
|
105
|
-
"Bear-SignPad__canvas-wrapper",
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
111
|
+
className: d(
|
|
112
|
+
"Bear-SignPad__canvas-wrapper bear-max-w-full bear-overflow-hidden",
|
|
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",
|
|
117
|
-
style: { width: S, height:
|
|
118
|
-
onMouseDown:
|
|
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,
|
|
119
127
|
onMouseMove: k,
|
|
120
128
|
onMouseUp: T,
|
|
121
129
|
onMouseLeave: T,
|
|
122
|
-
onTouchStart:
|
|
130
|
+
onTouchStart: G,
|
|
123
131
|
onTouchMove: k,
|
|
124
132
|
onTouchEnd: T
|
|
125
133
|
}
|
|
126
134
|
),
|
|
127
|
-
!c && /* @__PURE__ */ l("div", { className:
|
|
128
|
-
/* @__PURE__ */ l("div", { className:
|
|
129
|
-
/* @__PURE__ */ l("span", { className:
|
|
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
|
-
(
|
|
134
|
-
|
|
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:
|
|
148
|
+
disabled: r || !c,
|
|
141
149
|
children: H
|
|
142
150
|
}
|
|
143
151
|
),
|
|
144
|
-
|
|
152
|
+
b && /* @__PURE__ */ l(
|
|
145
153
|
O,
|
|
146
154
|
{
|
|
147
155
|
size: "sm",
|
|
148
156
|
variant: "primary",
|
|
149
157
|
onClick: Q,
|
|
150
|
-
disabled:
|
|
158
|
+
disabled: r || !c,
|
|
151
159
|
children: K
|
|
152
160
|
}
|
|
153
161
|
)
|
|
@@ -157,5 +165,5 @@ const gt = (U) => {
|
|
|
157
165
|
);
|
|
158
166
|
};
|
|
159
167
|
export {
|
|
160
|
-
|
|
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;
|