@forgedevstack/bear 1.1.4 → 1.1.9
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/README.md +21 -2
- package/dist/components/Anchor/Anchor.cjs +1 -1
- package/dist/components/Anchor/Anchor.js +37 -45
- package/dist/components/Anchor/Anchor.utils.cjs +1 -0
- package/dist/components/Anchor/Anchor.utils.d.ts +2 -0
- package/dist/components/Anchor/Anchor.utils.js +12 -0
- package/dist/components/Autocomplete/Autocomplete.cjs +1 -1
- package/dist/components/Autocomplete/Autocomplete.js +60 -67
- package/dist/components/Autocomplete/Autocomplete.utils.cjs +1 -0
- package/dist/components/Autocomplete/Autocomplete.utils.d.ts +2 -0
- package/dist/components/Autocomplete/Autocomplete.utils.js +12 -0
- package/dist/components/BackTop/BackTop.cjs +1 -1
- package/dist/components/BackTop/BackTop.js +10 -11
- package/dist/components/BearLogo/BearLogo.d.ts +2 -7
- package/dist/components/BearLogo/BearLogo.types.d.ts +15 -0
- package/dist/components/BearLogo/EmberLogo.d.ts +1 -8
- package/dist/components/BearLogo/index.d.ts +1 -2
- package/dist/components/Biometric/Biometric.cjs +1 -0
- package/dist/components/Biometric/Biometric.d.ts +3 -0
- package/dist/components/Biometric/Biometric.js +123 -0
- package/dist/components/Biometric/Biometric.types.d.ts +35 -0
- package/dist/components/Biometric/BiometricIcon.cjs +1 -0
- package/dist/components/Biometric/BiometricIcon.d.ts +3 -0
- package/dist/components/Biometric/BiometricIcon.js +45 -0
- package/dist/components/Biometric/index.d.ts +3 -0
- package/dist/components/Biometric/useBiometric.cjs +1 -0
- package/dist/components/Biometric/useBiometric.d.ts +2 -0
- package/dist/components/Biometric/useBiometric.js +21 -0
- package/dist/components/Button/Button.cjs +1 -1
- package/dist/components/Button/Button.constants.cjs +2 -2
- package/dist/components/Button/Button.constants.d.ts +1 -0
- package/dist/components/Button/Button.constants.js +12 -5
- package/dist/components/Button/Button.d.ts +0 -27
- package/dist/components/Button/Button.js +93 -105
- package/dist/components/Button/Button.types.d.ts +1 -0
- package/dist/components/Button/Button.utils.cjs +1 -0
- package/dist/components/Button/Button.utils.d.ts +2 -0
- package/dist/components/Button/Button.utils.js +5 -0
- package/dist/components/Button/useSpotlight.cjs +1 -0
- package/dist/components/Button/useSpotlight.d.ts +21 -0
- package/dist/components/Button/useSpotlight.js +28 -0
- package/dist/components/Chart/Chart.cjs +1 -1
- package/dist/components/Chart/Chart.const.cjs +1 -0
- package/dist/components/Chart/Chart.const.js +21 -0
- package/dist/components/Chart/Chart.js +55 -71
- package/dist/components/Chart/Chart.utils.cjs +1 -0
- package/dist/components/Chart/Chart.utils.js +5 -0
- package/dist/components/Confetti/Confetti.cjs +1 -1
- package/dist/components/Confetti/Confetti.js +37 -34
- package/dist/components/ContextMenu/ContextMenu.cjs +1 -1
- package/dist/components/ContextMenu/ContextMenu.js +31 -30
- package/dist/components/ContextMenu/ContextMenu.utils.cjs +1 -0
- package/dist/components/ContextMenu/ContextMenu.utils.d.ts +5 -0
- package/dist/components/ContextMenu/ContextMenu.utils.js +4 -0
- package/dist/components/CountdownTimer/CountdownTimer.cjs +1 -1
- package/dist/components/CountdownTimer/CountdownTimer.js +62 -71
- package/dist/components/CountdownTimer/CountdownTimer.utils.cjs +1 -0
- package/dist/components/CountdownTimer/CountdownTimer.utils.d.ts +3 -0
- package/dist/components/CountdownTimer/CountdownTimer.utils.js +16 -0
- package/dist/components/DateRangePicker/DateRangePicker.cjs +1 -1
- package/dist/components/DateRangePicker/DateRangePicker.const.cjs +1 -1
- package/dist/components/DateRangePicker/DateRangePicker.const.js +12 -13
- package/dist/components/DateRangePicker/DateRangePicker.js +107 -81
- package/dist/components/Dock/Dock.cjs +1 -1
- package/dist/components/Dock/Dock.js +38 -43
- package/dist/components/Dock/Dock.utils.cjs +1 -0
- package/dist/components/Dock/Dock.utils.d.ts +1 -0
- package/dist/components/Dock/Dock.utils.js +10 -0
- package/dist/components/Dropdown/Dropdown.cjs +1 -1
- package/dist/components/Dropdown/Dropdown.js +77 -74
- package/dist/components/FileTree/FileTree.cjs +1 -1
- package/dist/components/FileTree/FileTree.js +20 -32
- package/dist/components/FileTree/FileTree.utils.cjs +1 -0
- package/dist/components/FileTree/FileTree.utils.d.ts +4 -0
- package/dist/components/FileTree/FileTree.utils.js +15 -0
- package/dist/components/GradientText/GradientText.cjs +1 -1
- package/dist/components/GradientText/GradientText.js +27 -29
- package/dist/components/Icon/icons/bear.cjs +1 -0
- package/dist/components/Icon/icons/bear.d.ts +12 -0
- package/dist/components/Icon/icons/bear.js +47 -0
- package/dist/components/Icon/index.cjs +1 -1
- package/dist/components/Icon/index.d.ts +18 -0
- package/dist/components/Icon/index.js +17 -15
- package/dist/components/InfiniteScroll/InfiniteScroll.cjs +1 -1
- package/dist/components/InfiniteScroll/InfiniteScroll.const.cjs +1 -1
- package/dist/components/InfiniteScroll/InfiniteScroll.const.js +6 -7
- package/dist/components/InfiniteScroll/InfiniteScroll.js +41 -41
- package/dist/components/Input/Input.cjs +1 -1
- package/dist/components/Input/Input.js +153 -101
- package/dist/components/Input/Input.types.d.ts +8 -2
- package/dist/components/Input/index.d.ts +1 -1
- package/dist/components/MentionsInput/MentionsInput.cjs +1 -1
- package/dist/components/MentionsInput/MentionsInput.js +64 -68
- package/dist/components/MentionsInput/MentionsInput.utils.cjs +1 -0
- package/dist/components/MentionsInput/MentionsInput.utils.d.ts +2 -0
- package/dist/components/MentionsInput/MentionsInput.utils.js +9 -0
- package/dist/components/PageNav/PageNav.cjs +1 -0
- package/dist/components/PageNav/PageNav.const.cjs +1 -0
- package/dist/components/PageNav/PageNav.const.d.ts +22 -0
- package/dist/components/PageNav/PageNav.const.js +42 -0
- package/dist/components/PageNav/PageNav.d.ts +3 -0
- package/dist/components/PageNav/PageNav.js +81 -0
- package/dist/components/PageNav/PageNav.types.d.ts +17 -0
- package/dist/components/PageNav/index.d.ts +2 -0
- package/dist/components/Popover/Popover.cjs +1 -1
- package/dist/components/Popover/Popover.js +76 -76
- package/dist/components/Progress/Progress.cjs +1 -1
- package/dist/components/Progress/Progress.js +6 -6
- package/dist/components/PropsPlayground/PropsPlayground.cjs +1 -0
- package/dist/components/PropsPlayground/PropsPlayground.const.cjs +1 -0
- package/dist/components/PropsPlayground/PropsPlayground.const.d.ts +11 -0
- package/dist/components/PropsPlayground/PropsPlayground.const.js +23 -0
- package/dist/components/PropsPlayground/PropsPlayground.d.ts +3 -0
- package/dist/components/PropsPlayground/PropsPlayground.js +221 -0
- package/dist/components/PropsPlayground/PropsPlayground.types.d.ts +29 -0
- package/dist/components/PropsPlayground/PropsPlayground.utils.cjs +1 -0
- package/dist/components/PropsPlayground/PropsPlayground.utils.d.ts +2 -0
- package/dist/components/PropsPlayground/PropsPlayground.utils.js +9 -0
- package/dist/components/PropsPlayground/index.d.ts +2 -0
- package/dist/components/Select/Select.cjs +1 -1
- package/dist/components/Select/Select.js +54 -53
- package/dist/components/SignPad/SignPad.cjs +1 -1
- package/dist/components/SignPad/SignPad.js +24 -24
- package/dist/components/Skeleton/Skeleton.cjs +1 -1
- package/dist/components/Skeleton/Skeleton.js +89 -94
- package/dist/components/Skeleton/Skeleton.utils.cjs +1 -0
- package/dist/components/Skeleton/Skeleton.utils.d.ts +1 -0
- package/dist/components/Skeleton/Skeleton.utils.js +10 -0
- package/dist/components/SliderRange/SliderRange.cjs +1 -1
- package/dist/components/SliderRange/SliderRange.js +61 -63
- package/dist/components/SliderRange/SliderRange.utils.cjs +1 -0
- package/dist/components/SliderRange/SliderRange.utils.d.ts +1 -0
- package/dist/components/SliderRange/SliderRange.utils.js +7 -0
- package/dist/components/Spotlight/Spotlight.cjs +1 -1
- package/dist/components/Spotlight/Spotlight.js +62 -73
- package/dist/components/Spotlight/Spotlight.utils.cjs +1 -0
- package/dist/components/Spotlight/Spotlight.utils.d.ts +3 -0
- package/dist/components/Spotlight/Spotlight.utils.js +18 -0
- package/dist/components/Tabs/TabList.cjs +1 -0
- package/dist/components/Tabs/TabList.d.ts +3 -0
- package/dist/components/Tabs/TabList.js +69 -0
- package/dist/components/Tabs/TabPanel.cjs +1 -0
- package/dist/components/Tabs/TabPanel.d.ts +3 -0
- package/dist/components/Tabs/TabPanel.js +13 -0
- package/dist/components/Tabs/Tabs.cjs +1 -1
- package/dist/components/Tabs/Tabs.d.ts +2 -27
- package/dist/components/Tabs/Tabs.js +43 -61
- package/dist/components/Tabs/Tabs.types.d.ts +7 -1
- package/dist/components/Tabs/index.d.ts +3 -1
- package/dist/components/Toast/Toast.cjs +1 -1
- package/dist/components/Toast/Toast.js +18 -17
- package/dist/components/Toast/Toast.utils.cjs +1 -0
- package/dist/components/Toast/Toast.utils.d.ts +1 -0
- package/dist/components/Toast/Toast.utils.js +4 -0
- package/dist/components/Tooltip/Tooltip.cjs +1 -1
- package/dist/components/Tooltip/Tooltip.js +10 -11
- package/dist/components/Tour/Tour.cjs +1 -1
- package/dist/components/Tour/Tour.js +1 -2
- package/dist/components/VirtualList/VirtualList.cjs +1 -1
- package/dist/components/VirtualList/VirtualList.js +38 -43
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.d.ts +9 -2
- package/dist/components/index.js +311 -300
- package/dist/hooks/index.cjs +1 -1
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +60 -58
- package/dist/hooks/useResizeObserver/index.d.ts +2 -0
- package/dist/hooks/useResizeObserver/useResizeObserver.cjs +1 -0
- package/dist/hooks/useResizeObserver/useResizeObserver.d.ts +3 -0
- package/dist/hooks/useResizeObserver/useResizeObserver.js +20 -0
- package/dist/hooks/useResizeObserver/useResizeObserver.types.d.ts +8 -0
- package/dist/icons.cjs +1 -0
- package/dist/icons.d.ts +2 -0
- package/dist/icons.js +6 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +397 -384
- package/dist/styles/_base.css +7 -3
- package/dist/styles.css +1 -1
- package/package.json +6 -1
|
@@ -6,20 +6,20 @@ const f = {
|
|
|
6
6
|
md: "bear-h-2.5",
|
|
7
7
|
lg: "bear-h-4"
|
|
8
8
|
}, h = {
|
|
9
|
-
default: "bear-bg-
|
|
9
|
+
default: "bear-bg-bear-500",
|
|
10
10
|
success: "bear-bg-green-500",
|
|
11
|
-
warning: "bear-bg-
|
|
11
|
+
warning: "bear-bg-amber-500",
|
|
12
12
|
danger: "bear-bg-red-500",
|
|
13
13
|
info: "bear-bg-blue-500"
|
|
14
14
|
}, y = ({
|
|
15
15
|
value: n,
|
|
16
16
|
max: l = 100,
|
|
17
17
|
size: d = "md",
|
|
18
|
-
color:
|
|
18
|
+
color: m = "default",
|
|
19
19
|
showLabel: i = !1,
|
|
20
20
|
labelPosition: o = "outside",
|
|
21
21
|
striped: r = !1,
|
|
22
|
-
animated:
|
|
22
|
+
animated: g = !1,
|
|
23
23
|
indeterminate: e = !1,
|
|
24
24
|
className: c,
|
|
25
25
|
testId: u
|
|
@@ -46,9 +46,9 @@ const f = {
|
|
|
46
46
|
className: b(
|
|
47
47
|
"bear-h-full bear-rounded-full bear-transition-all bear-duration-300 bear-ease-out",
|
|
48
48
|
"bear-flex bear-items-center bear-justify-center",
|
|
49
|
-
h[
|
|
49
|
+
h[m],
|
|
50
50
|
r && "bear-bg-stripes",
|
|
51
|
-
|
|
51
|
+
g && "bear-animate-stripes",
|
|
52
52
|
e && "bear-animate-indeterminate"
|
|
53
53
|
),
|
|
54
54
|
style: {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("react"),n=require("../../utils/cn.cjs"),j=require("../Icon/Icon.cjs"),l=require("./PropsPlayground.const.cjs"),_=require("./PropsPlayground.utils.cjs"),$=({size:b})=>e.jsx(j.Icon,{size:b,children:e.jsx("polyline",{points:"6 9 12 15 18 9"})}),q=({size:b})=>e.jsx(j.Icon,{size:b,children:e.jsx("polyline",{points:"9 18 15 12 9 6"})}),I=({size:b})=>e.jsxs(j.Icon,{size:b,children:[e.jsx("line",{x1:"4",y1:"21",x2:"4",y2:"14"}),e.jsx("line",{x1:"4",y1:"10",x2:"4",y2:"3"}),e.jsx("line",{x1:"12",y1:"21",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"3"}),e.jsx("line",{x1:"20",y1:"21",x2:"20",y2:"16"}),e.jsx("line",{x1:"20",y1:"12",x2:"20",y2:"3"}),e.jsx("line",{x1:"1",y1:"14",x2:"7",y2:"14"}),e.jsx("line",{x1:"9",y1:"8",x2:"15",y2:"8"}),e.jsx("line",{x1:"17",y1:"16",x2:"23",y2:"16"})]}),O=({config:b,render:z,title:y="Props",size:S="md",defaultCollapsed:C=!1,showReset:w=!0,columns:P=3,className:L,testId:k})=>{const u=c.useMemo(()=>_.getDefaults(b),[b]),[g,f]=c.useState(u),[p,E]=c.useState(C),o=c.useCallback((r,s)=>{f(i=>({...i,[r]:s}))},[]),A=c.useCallback(()=>{f(u)},[u]),t=l.SIZE_CLASSES[S],N=Object.keys(b).length,m=n.cn("bear-w-full bear-rounded-md bear-border bear-border-zinc-700","bear-bg-zinc-800 bear-text-zinc-100","placeholder:bear-text-zinc-500","focus:bear-outline-none focus:bear-ring-2 focus:bear-ring-pink-500/30 focus:bear-border-pink-500","bear-transition-colors",t.input);return e.jsxs("div",{"data-testid":k,className:n.cn(l.ROOT_CLASS,"bear-rounded-lg bear-border bear-border-zinc-700 bear-overflow-hidden",L),children:[e.jsxs("button",{type:"button",onClick:()=>E(r=>!r),className:n.cn("bear-w-full bear-flex bear-items-center bear-gap-2 bear-text-left bear-font-medium bear-transition-colors","bear-bg-zinc-800/60 hover:bear-bg-zinc-800","bear-text-zinc-200 bear-border-b bear-border-zinc-700","bear-px-4 bear-py-3",t.text),children:[e.jsx("span",{className:"bear-text-pink-500",children:p?e.jsx(q,{size:12}):e.jsx($,{size:12})}),e.jsx("span",{className:"bear-text-pink-500",children:e.jsx(I,{size:14})}),e.jsx("span",{className:"bear-font-semibold",children:y}),e.jsxs("span",{className:"bear-ml-auto bear-flex bear-items-center bear-gap-2",children:[e.jsxs("span",{className:"bear-text-[10px] bear-font-medium bear-text-zinc-500",children:[N," ",N===1?"control":"controls"]}),w&&!p&&e.jsx("button",{type:"button",onClick:r=>{r.stopPropagation(),A()},className:"bear-text-[10px] bear-font-semibold bear-text-pink-500 hover:bear-text-pink-400 hover:bear-underline",children:"Reset"})]})]}),!p&&e.jsx("div",{className:n.cn("bear-bg-zinc-900/50",t.padding),children:e.jsx("div",{className:n.cn("bear-grid",t.gap,l.COLUMN_CLASSES[P]),children:Object.entries(b).map(([r,s])=>{const i=g[r],d=r.replace(/([A-Z])/g," $1").replace(/^./,a=>a.toUpperCase()).trim();if(s.type==="boolean"){const a=i===!0;return e.jsxs("div",{className:"bear-rounded-lg bear-border bear-border-zinc-700/60 bear-bg-zinc-800/30 bear-p-3",children:[e.jsx("span",{className:n.cn("bear-block bear-font-semibold bear-uppercase bear-tracking-wider bear-text-pink-500 bear-mb-2",t.label),children:l.TYPE_LABELS.boolean}),e.jsxs("label",{className:"bear-flex bear-items-center bear-gap-2.5 bear-cursor-pointer",children:[e.jsx("button",{type:"button",role:"switch","aria-checked":a,onClick:()=>o(r,!a),className:n.cn("bear-relative bear-inline-flex bear-h-5 bear-w-9 bear-flex-shrink-0 bear-rounded-full bear-border-2 bear-border-transparent bear-transition-colors",a?"bear-bg-pink-500":"bear-bg-zinc-600"),children:e.jsx("span",{className:n.cn("bear-pointer-events-none bear-inline-block bear-h-4 bear-w-4 bear-transform bear-rounded-full bear-bg-white bear-shadow bear-transition",a?"bear-translate-x-4":"bear-translate-x-0")})}),e.jsx("span",{className:n.cn("bear-font-medium bear-text-zinc-200 bear-truncate",t.text),children:d})]})]},r)}if(s.type==="select"&&s.options)return e.jsxs("div",{className:"bear-rounded-lg bear-border bear-border-zinc-700/60 bear-bg-zinc-800/30 bear-p-3",children:[e.jsxs("div",{className:"bear-flex bear-items-center bear-justify-between bear-mb-1.5",children:[e.jsx("label",{htmlFor:`pp-${r}`,className:n.cn("bear-font-medium bear-text-zinc-300 bear-truncate",t.label),children:d}),e.jsx("span",{className:n.cn("bear-font-semibold bear-uppercase bear-tracking-wider bear-text-pink-500",t.label),children:l.TYPE_LABELS.select})]}),e.jsx("select",{id:`pp-${r}`,value:String(i),onChange:a=>{const x=s.options.find(h=>String(h.value)===a.target.value);o(r,x?x.value:a.target.value)},className:n.cn(m,"bear-cursor-pointer bear-appearance-none"),children:s.options.map(a=>e.jsx("option",{value:String(a.value),children:a.label},String(a.value)))})]},r);if(s.type==="number"){const a=Number(i),x=Number.isNaN(a)?s.default:a;return e.jsxs("div",{className:"bear-rounded-lg bear-border bear-border-zinc-700/60 bear-bg-zinc-800/30 bear-p-3",children:[e.jsxs("div",{className:"bear-flex bear-items-center bear-justify-between bear-mb-1.5",children:[e.jsx("label",{htmlFor:`pp-${r}`,className:n.cn("bear-font-medium bear-text-zinc-300 bear-truncate",t.label),children:d}),e.jsx("span",{className:n.cn("bear-font-semibold bear-uppercase bear-tracking-wider bear-text-pink-500",t.label),children:l.TYPE_LABELS.number})]}),e.jsx("input",{id:`pp-${r}`,type:"number",value:x,min:s.min,max:s.max,step:s.step,onChange:h=>{const v=h.target.valueAsNumber;o(r,Number.isNaN(v)?s.default:v)},className:m})]},r)}return e.jsxs("div",{className:"bear-rounded-lg bear-border bear-border-zinc-700/60 bear-bg-zinc-800/30 bear-p-3",children:[e.jsxs("div",{className:"bear-flex bear-items-center bear-justify-between bear-mb-1.5",children:[e.jsx("label",{htmlFor:`pp-${r}`,className:n.cn("bear-font-medium bear-text-zinc-300 bear-truncate",t.label),children:d}),e.jsx("span",{className:n.cn("bear-font-semibold bear-uppercase bear-tracking-wider bear-text-pink-500",t.label),children:l.TYPE_LABELS.string})]}),e.jsx("input",{id:`pp-${r}`,type:"text",value:String(i??""),onChange:a=>o(r,a.target.value),placeholder:s.placeholder,className:m})]},r)})})}),e.jsx("div",{className:"bear-border-t bear-border-zinc-700 bear-p-6 bear-bg-zinc-900 bear-flex bear-items-center bear-justify-center bear-min-h-[180px]",children:e.jsx("div",{className:"bear-w-full",children:z(g)})})]})};exports.PropsPlayground=O;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="Bear-PropsPlayground",a={xs:{padding:"bear-p-2",text:"bear-text-[10px]",gap:"bear-gap-2",label:"bear-text-[9px]",input:"bear-px-1.5 bear-py-0.5 bear-text-[10px]"},sm:{padding:"bear-p-3",text:"bear-text-xs",gap:"bear-gap-2",label:"bear-text-[10px]",input:"bear-px-2 bear-py-1 bear-text-xs"},md:{padding:"bear-p-4",text:"bear-text-sm",gap:"bear-gap-3",label:"bear-text-[11px]",input:"bear-px-2.5 bear-py-1.5 bear-text-xs"},lg:{padding:"bear-p-5",text:"bear-text-sm",gap:"bear-gap-3",label:"bear-text-xs",input:"bear-px-3 bear-py-2 bear-text-sm"},xl:{padding:"bear-p-6",text:"bear-text-base",gap:"bear-gap-4",label:"bear-text-sm",input:"bear-px-3.5 bear-py-2.5 bear-text-base"}},t={1:"bear-grid-cols-1",2:"bear-grid-cols-2",3:"bear-grid-cols-3",4:"bear-grid-cols-4"},r={boolean:"bool",select:"select",number:"num",string:"str"};exports.COLUMN_CLASSES=t;exports.ROOT_CLASS=e;exports.SIZE_CLASSES=a;exports.TYPE_LABELS=r;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BearSize } from '../../types';
|
|
2
|
+
export declare const ROOT_CLASS = "Bear-PropsPlayground";
|
|
3
|
+
export declare const SIZE_CLASSES: Record<BearSize, {
|
|
4
|
+
padding: string;
|
|
5
|
+
text: string;
|
|
6
|
+
gap: string;
|
|
7
|
+
label: string;
|
|
8
|
+
input: string;
|
|
9
|
+
}>;
|
|
10
|
+
export declare const COLUMN_CLASSES: Record<number, string>;
|
|
11
|
+
export declare const TYPE_LABELS: Record<string, string>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const e = "Bear-PropsPlayground", a = {
|
|
2
|
+
xs: { padding: "bear-p-2", text: "bear-text-[10px]", gap: "bear-gap-2", label: "bear-text-[9px]", input: "bear-px-1.5 bear-py-0.5 bear-text-[10px]" },
|
|
3
|
+
sm: { padding: "bear-p-3", text: "bear-text-xs", gap: "bear-gap-2", label: "bear-text-[10px]", input: "bear-px-2 bear-py-1 bear-text-xs" },
|
|
4
|
+
md: { padding: "bear-p-4", text: "bear-text-sm", gap: "bear-gap-3", label: "bear-text-[11px]", input: "bear-px-2.5 bear-py-1.5 bear-text-xs" },
|
|
5
|
+
lg: { padding: "bear-p-5", text: "bear-text-sm", gap: "bear-gap-3", label: "bear-text-xs", input: "bear-px-3 bear-py-2 bear-text-sm" },
|
|
6
|
+
xl: { padding: "bear-p-6", text: "bear-text-base", gap: "bear-gap-4", label: "bear-text-sm", input: "bear-px-3.5 bear-py-2.5 bear-text-base" }
|
|
7
|
+
}, t = {
|
|
8
|
+
1: "bear-grid-cols-1",
|
|
9
|
+
2: "bear-grid-cols-2",
|
|
10
|
+
3: "bear-grid-cols-3",
|
|
11
|
+
4: "bear-grid-cols-4"
|
|
12
|
+
}, r = {
|
|
13
|
+
boolean: "bool",
|
|
14
|
+
select: "select",
|
|
15
|
+
number: "num",
|
|
16
|
+
string: "str"
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
t as COLUMN_CLASSES,
|
|
20
|
+
e as ROOT_CLASS,
|
|
21
|
+
a as SIZE_CLASSES,
|
|
22
|
+
r as TYPE_LABELS
|
|
23
|
+
};
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
import { jsxs as b, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as R, useState as y, useCallback as C } from "react";
|
|
3
|
+
import { cn as n } from "../../utils/cn.js";
|
|
4
|
+
import { Icon as f } from "../Icon/Icon.js";
|
|
5
|
+
import { SIZE_CLASSES as _, TYPE_LABELS as m, COLUMN_CLASSES as F, ROOT_CLASS as I } from "./PropsPlayground.const.js";
|
|
6
|
+
import { getDefaults as V } from "./PropsPlayground.utils.js";
|
|
7
|
+
const D = ({ size: i }) => /* @__PURE__ */ e(f, { size: i, children: /* @__PURE__ */ e("polyline", { points: "6 9 12 15 18 9" }) }), M = ({ size: i }) => /* @__PURE__ */ e(f, { size: i, children: /* @__PURE__ */ e("polyline", { points: "9 18 15 12 9 6" }) }), T = ({ size: i }) => /* @__PURE__ */ b(f, { size: i, children: [
|
|
8
|
+
/* @__PURE__ */ e("line", { x1: "4", y1: "21", x2: "4", y2: "14" }),
|
|
9
|
+
/* @__PURE__ */ e("line", { x1: "4", y1: "10", x2: "4", y2: "3" }),
|
|
10
|
+
/* @__PURE__ */ e("line", { x1: "12", y1: "21", x2: "12", y2: "12" }),
|
|
11
|
+
/* @__PURE__ */ e("line", { x1: "12", y1: "8", x2: "12", y2: "3" }),
|
|
12
|
+
/* @__PURE__ */ e("line", { x1: "20", y1: "21", x2: "20", y2: "16" }),
|
|
13
|
+
/* @__PURE__ */ e("line", { x1: "20", y1: "12", x2: "20", y2: "3" }),
|
|
14
|
+
/* @__PURE__ */ e("line", { x1: "1", y1: "14", x2: "7", y2: "14" }),
|
|
15
|
+
/* @__PURE__ */ e("line", { x1: "9", y1: "8", x2: "15", y2: "8" }),
|
|
16
|
+
/* @__PURE__ */ e("line", { x1: "17", y1: "16", x2: "23", y2: "16" })
|
|
17
|
+
] }), H = ({
|
|
18
|
+
config: i,
|
|
19
|
+
render: w,
|
|
20
|
+
title: S = "Props",
|
|
21
|
+
size: k = "md",
|
|
22
|
+
defaultCollapsed: j = !1,
|
|
23
|
+
showReset: $ = !0,
|
|
24
|
+
columns: A = 3,
|
|
25
|
+
className: L,
|
|
26
|
+
testId: E
|
|
27
|
+
}) => {
|
|
28
|
+
const p = R(() => V(i), [i]), [g, N] = y(p), [u, O] = y(j), o = C(
|
|
29
|
+
(r, t) => {
|
|
30
|
+
N((s) => ({ ...s, [r]: t }));
|
|
31
|
+
},
|
|
32
|
+
[]
|
|
33
|
+
), P = C(() => {
|
|
34
|
+
N(p);
|
|
35
|
+
}, [p]), l = _[k], v = Object.keys(i).length, h = n(
|
|
36
|
+
"bear-w-full bear-rounded-md bear-border bear-border-zinc-700",
|
|
37
|
+
"bear-bg-zinc-800 bear-text-zinc-100",
|
|
38
|
+
"placeholder:bear-text-zinc-500",
|
|
39
|
+
"focus:bear-outline-none focus:bear-ring-2 focus:bear-ring-pink-500/30 focus:bear-border-pink-500",
|
|
40
|
+
"bear-transition-colors",
|
|
41
|
+
l.input
|
|
42
|
+
);
|
|
43
|
+
return /* @__PURE__ */ b(
|
|
44
|
+
"div",
|
|
45
|
+
{
|
|
46
|
+
"data-testid": E,
|
|
47
|
+
className: n(
|
|
48
|
+
I,
|
|
49
|
+
"bear-rounded-lg bear-border bear-border-zinc-700 bear-overflow-hidden",
|
|
50
|
+
L
|
|
51
|
+
),
|
|
52
|
+
children: [
|
|
53
|
+
/* @__PURE__ */ b(
|
|
54
|
+
"button",
|
|
55
|
+
{
|
|
56
|
+
type: "button",
|
|
57
|
+
onClick: () => O((r) => !r),
|
|
58
|
+
className: n(
|
|
59
|
+
"bear-w-full bear-flex bear-items-center bear-gap-2 bear-text-left bear-font-medium bear-transition-colors",
|
|
60
|
+
"bear-bg-zinc-800/60 hover:bear-bg-zinc-800",
|
|
61
|
+
"bear-text-zinc-200 bear-border-b bear-border-zinc-700",
|
|
62
|
+
"bear-px-4 bear-py-3",
|
|
63
|
+
l.text
|
|
64
|
+
),
|
|
65
|
+
children: [
|
|
66
|
+
/* @__PURE__ */ e("span", { className: "bear-text-pink-500", children: u ? /* @__PURE__ */ e(M, { size: 12 }) : /* @__PURE__ */ e(D, { size: 12 }) }),
|
|
67
|
+
/* @__PURE__ */ e("span", { className: "bear-text-pink-500", children: /* @__PURE__ */ e(T, { size: 14 }) }),
|
|
68
|
+
/* @__PURE__ */ e("span", { className: "bear-font-semibold", children: S }),
|
|
69
|
+
/* @__PURE__ */ b("span", { className: "bear-ml-auto bear-flex bear-items-center bear-gap-2", children: [
|
|
70
|
+
/* @__PURE__ */ b("span", { className: "bear-text-[10px] bear-font-medium bear-text-zinc-500", children: [
|
|
71
|
+
v,
|
|
72
|
+
" ",
|
|
73
|
+
v === 1 ? "control" : "controls"
|
|
74
|
+
] }),
|
|
75
|
+
$ && !u && /* @__PURE__ */ e(
|
|
76
|
+
"button",
|
|
77
|
+
{
|
|
78
|
+
type: "button",
|
|
79
|
+
onClick: (r) => {
|
|
80
|
+
r.stopPropagation(), P();
|
|
81
|
+
},
|
|
82
|
+
className: "bear-text-[10px] bear-font-semibold bear-text-pink-500 hover:bear-text-pink-400 hover:bear-underline",
|
|
83
|
+
children: "Reset"
|
|
84
|
+
}
|
|
85
|
+
)
|
|
86
|
+
] })
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
),
|
|
90
|
+
!u && /* @__PURE__ */ e("div", { className: n("bear-bg-zinc-900/50", l.padding), children: /* @__PURE__ */ e("div", { className: n("bear-grid", l.gap, F[A]), children: Object.entries(i).map(([r, t]) => {
|
|
91
|
+
const s = g[r], c = r.replace(/([A-Z])/g, " $1").replace(/^./, (a) => a.toUpperCase()).trim();
|
|
92
|
+
if (t.type === "boolean") {
|
|
93
|
+
const a = s === !0;
|
|
94
|
+
return /* @__PURE__ */ b(
|
|
95
|
+
"div",
|
|
96
|
+
{
|
|
97
|
+
className: "bear-rounded-lg bear-border bear-border-zinc-700/60 bear-bg-zinc-800/30 bear-p-3",
|
|
98
|
+
children: [
|
|
99
|
+
/* @__PURE__ */ e("span", { className: n("bear-block bear-font-semibold bear-uppercase bear-tracking-wider bear-text-pink-500 bear-mb-2", l.label), children: m.boolean }),
|
|
100
|
+
/* @__PURE__ */ b("label", { className: "bear-flex bear-items-center bear-gap-2.5 bear-cursor-pointer", children: [
|
|
101
|
+
/* @__PURE__ */ e(
|
|
102
|
+
"button",
|
|
103
|
+
{
|
|
104
|
+
type: "button",
|
|
105
|
+
role: "switch",
|
|
106
|
+
"aria-checked": a,
|
|
107
|
+
onClick: () => o(r, !a),
|
|
108
|
+
className: n(
|
|
109
|
+
"bear-relative bear-inline-flex bear-h-5 bear-w-9 bear-flex-shrink-0 bear-rounded-full bear-border-2 bear-border-transparent bear-transition-colors",
|
|
110
|
+
a ? "bear-bg-pink-500" : "bear-bg-zinc-600"
|
|
111
|
+
),
|
|
112
|
+
children: /* @__PURE__ */ e(
|
|
113
|
+
"span",
|
|
114
|
+
{
|
|
115
|
+
className: n(
|
|
116
|
+
"bear-pointer-events-none bear-inline-block bear-h-4 bear-w-4 bear-transform bear-rounded-full bear-bg-white bear-shadow bear-transition",
|
|
117
|
+
a ? "bear-translate-x-4" : "bear-translate-x-0"
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
),
|
|
123
|
+
/* @__PURE__ */ e("span", { className: n("bear-font-medium bear-text-zinc-200 bear-truncate", l.text), children: c })
|
|
124
|
+
] })
|
|
125
|
+
]
|
|
126
|
+
},
|
|
127
|
+
r
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
if (t.type === "select" && t.options)
|
|
131
|
+
return /* @__PURE__ */ b(
|
|
132
|
+
"div",
|
|
133
|
+
{
|
|
134
|
+
className: "bear-rounded-lg bear-border bear-border-zinc-700/60 bear-bg-zinc-800/30 bear-p-3",
|
|
135
|
+
children: [
|
|
136
|
+
/* @__PURE__ */ b("div", { className: "bear-flex bear-items-center bear-justify-between bear-mb-1.5", children: [
|
|
137
|
+
/* @__PURE__ */ e("label", { htmlFor: `pp-${r}`, className: n("bear-font-medium bear-text-zinc-300 bear-truncate", l.label), children: c }),
|
|
138
|
+
/* @__PURE__ */ e("span", { className: n("bear-font-semibold bear-uppercase bear-tracking-wider bear-text-pink-500", l.label), children: m.select })
|
|
139
|
+
] }),
|
|
140
|
+
/* @__PURE__ */ e(
|
|
141
|
+
"select",
|
|
142
|
+
{
|
|
143
|
+
id: `pp-${r}`,
|
|
144
|
+
value: String(s),
|
|
145
|
+
onChange: (a) => {
|
|
146
|
+
const d = t.options.find((x) => String(x.value) === a.target.value);
|
|
147
|
+
o(r, d ? d.value : a.target.value);
|
|
148
|
+
},
|
|
149
|
+
className: n(h, "bear-cursor-pointer bear-appearance-none"),
|
|
150
|
+
children: t.options.map((a) => /* @__PURE__ */ e("option", { value: String(a.value), children: a.label }, String(a.value)))
|
|
151
|
+
}
|
|
152
|
+
)
|
|
153
|
+
]
|
|
154
|
+
},
|
|
155
|
+
r
|
|
156
|
+
);
|
|
157
|
+
if (t.type === "number") {
|
|
158
|
+
const a = Number(s), d = Number.isNaN(a) ? t.default : a;
|
|
159
|
+
return /* @__PURE__ */ b(
|
|
160
|
+
"div",
|
|
161
|
+
{
|
|
162
|
+
className: "bear-rounded-lg bear-border bear-border-zinc-700/60 bear-bg-zinc-800/30 bear-p-3",
|
|
163
|
+
children: [
|
|
164
|
+
/* @__PURE__ */ b("div", { className: "bear-flex bear-items-center bear-justify-between bear-mb-1.5", children: [
|
|
165
|
+
/* @__PURE__ */ e("label", { htmlFor: `pp-${r}`, className: n("bear-font-medium bear-text-zinc-300 bear-truncate", l.label), children: c }),
|
|
166
|
+
/* @__PURE__ */ e("span", { className: n("bear-font-semibold bear-uppercase bear-tracking-wider bear-text-pink-500", l.label), children: m.number })
|
|
167
|
+
] }),
|
|
168
|
+
/* @__PURE__ */ e(
|
|
169
|
+
"input",
|
|
170
|
+
{
|
|
171
|
+
id: `pp-${r}`,
|
|
172
|
+
type: "number",
|
|
173
|
+
value: d,
|
|
174
|
+
min: t.min,
|
|
175
|
+
max: t.max,
|
|
176
|
+
step: t.step,
|
|
177
|
+
onChange: (x) => {
|
|
178
|
+
const z = x.target.valueAsNumber;
|
|
179
|
+
o(r, Number.isNaN(z) ? t.default : z);
|
|
180
|
+
},
|
|
181
|
+
className: h
|
|
182
|
+
}
|
|
183
|
+
)
|
|
184
|
+
]
|
|
185
|
+
},
|
|
186
|
+
r
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
return /* @__PURE__ */ b(
|
|
190
|
+
"div",
|
|
191
|
+
{
|
|
192
|
+
className: "bear-rounded-lg bear-border bear-border-zinc-700/60 bear-bg-zinc-800/30 bear-p-3",
|
|
193
|
+
children: [
|
|
194
|
+
/* @__PURE__ */ b("div", { className: "bear-flex bear-items-center bear-justify-between bear-mb-1.5", children: [
|
|
195
|
+
/* @__PURE__ */ e("label", { htmlFor: `pp-${r}`, className: n("bear-font-medium bear-text-zinc-300 bear-truncate", l.label), children: c }),
|
|
196
|
+
/* @__PURE__ */ e("span", { className: n("bear-font-semibold bear-uppercase bear-tracking-wider bear-text-pink-500", l.label), children: m.string })
|
|
197
|
+
] }),
|
|
198
|
+
/* @__PURE__ */ e(
|
|
199
|
+
"input",
|
|
200
|
+
{
|
|
201
|
+
id: `pp-${r}`,
|
|
202
|
+
type: "text",
|
|
203
|
+
value: String(s ?? ""),
|
|
204
|
+
onChange: (a) => o(r, a.target.value),
|
|
205
|
+
placeholder: t.placeholder,
|
|
206
|
+
className: h
|
|
207
|
+
}
|
|
208
|
+
)
|
|
209
|
+
]
|
|
210
|
+
},
|
|
211
|
+
r
|
|
212
|
+
);
|
|
213
|
+
}) }) }),
|
|
214
|
+
/* @__PURE__ */ e("div", { className: "bear-border-t bear-border-zinc-700 bear-p-6 bear-bg-zinc-900 bear-flex bear-items-center bear-justify-center bear-min-h-[180px]", children: /* @__PURE__ */ e("div", { className: "bear-w-full", children: w(g) }) })
|
|
215
|
+
]
|
|
216
|
+
}
|
|
217
|
+
);
|
|
218
|
+
};
|
|
219
|
+
export {
|
|
220
|
+
H as PropsPlayground
|
|
221
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { BearSize } from '../../types';
|
|
3
|
+
export type PropControlType = 'boolean' | 'string' | 'number' | 'select';
|
|
4
|
+
export interface PropControlOption {
|
|
5
|
+
label: string;
|
|
6
|
+
value: string | number | boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface PropControlConfig {
|
|
9
|
+
type: PropControlType;
|
|
10
|
+
default: string | number | boolean;
|
|
11
|
+
options?: PropControlOption[];
|
|
12
|
+
min?: number;
|
|
13
|
+
max?: number;
|
|
14
|
+
step?: number;
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
}
|
|
17
|
+
export type PropsConfig = Record<string, PropControlConfig>;
|
|
18
|
+
export type PropValues = Record<string, string | number | boolean>;
|
|
19
|
+
export interface PropsPlaygroundProps {
|
|
20
|
+
config: PropsConfig;
|
|
21
|
+
render: (values: PropValues) => ReactNode;
|
|
22
|
+
title?: string;
|
|
23
|
+
size?: BearSize;
|
|
24
|
+
defaultCollapsed?: boolean;
|
|
25
|
+
showReset?: boolean;
|
|
26
|
+
columns?: 1 | 2 | 3 | 4;
|
|
27
|
+
className?: string;
|
|
28
|
+
testId?: string;
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function n(t){const e={};for(const[o,u]of Object.entries(t))e[o]=u.default;return e}exports.getDefaults=n;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),n=require("react"),s=require("../../utils/cn.cjs"),j=require("../../hooks/useClickOutside.cjs");require("../../context/BearProvider.cjs");require("../../hooks/useBearComponent/useBearComponent.cjs");const m=require("../Icon/index.cjs"),p={sm:"bear-h-8 bear-text-sm bear-px-3",md:"bear-h-10 bear-text-base bear-px-4",lg:"bear-h-12 bear-text-lg bear-px-5"},N=({options:u,value:a,onChange:t,placeholder:v="Select an option",label:i,error:l,disabled:o=!1,size:y="md",fullWidth:g=!1,className:h})=>{const[c,d]=n.useState(!1),f=n.useRef(null),x=!!l,b=u.find(e=>e.value===a),k=n.useCallback(()=>d(!1),[]);j.useClickOutside(f,k);const w=e=>{t==null||t(e),d(!1)};return r.jsxs("div",{ref:f,className:s.cn("bear-relative bear-flex bear-flex-col bear-gap-1.5",g&&"bear-w-full"),children:[i&&r.jsx("label",{className:"bear-text-sm bear-font-medium",style:{color:"var(--bear-text-secondary)"},children:i}),r.jsxs("button",{type:"button",disabled:o,onClick:()=>!o&&d(!c),className:s.cn("bear-flex bear-items-center bear-justify-between bear-w-full","bear-rounded-lg bear-border bear-text-left bear-outline-none bear-transition-all bear-duration-200","focus:bear-ring-2 focus:bear-ring-offset-2 focus:bear-ring-offset-[var(--bear-bg-primary)]",x?"bear-border-red-500 focus:bear-ring-red-500":"focus:bear-border-bear-500 focus:bear-ring-bear-500 dark:focus:bear-border-bear-500 dark:focus:bear-ring-bear-500",o&&"bear-opacity-50 bear-cursor-not-allowed",p[y],h),style:{backgroundColor:"var(--bear-bg-primary)",borderColor:x?void 0:"var(--bear-border-default)",color:b?"var(--bear-text-primary)":"var(--bear-text-muted)"},children:[r.jsx("span",{children:(b==null?void 0:b.label)||v}),r.jsx(m.ChevronDownIcon,{className:s.cn("bear-w-4 bear-h-4 bear-shrink-0 bear-transition-transform",c&&"bear-rotate-180"),style:{color:"var(--bear-text-muted)"}})]}),c&&r.jsx("div",{className:"bear-absolute bear-z-50 bear-w-full bear-mt-1 bear-rounded-lg bear-border bear-shadow-lg bear-overflow-hidden bear-top-full",style:{backgroundColor:"var(--bear-bg-primary)",borderColor:"var(--bear-border-default)"},children:r.jsx("div",{className:"bear-max-h-60 bear-overflow-y-auto",children:u.map(e=>r.jsxs("button",{type:"button",disabled:e.disabled,onClick:()=>!e.disabled&&w(e.value),className:s.cn("bear-flex bear-items-center bear-justify-between bear-w-full bear-px-4 bear-py-2","bear-text-left bear-transition-colors",e.disabled&&"bear-cursor-not-allowed",e.value===a&&"bear-bg-bear-100 bear-text-bear-700 dark:bear-bg-bear-600/20 dark:bear-text-bear-300",!e.disabled&&e.value!==a&&"hover:bear-bg-[var(--bear-bg-tertiary)]"),style:e.disabled?{color:"var(--bear-text-muted)"}:e.value===a?void 0:{color:"var(--bear-text-secondary)"},children:[e.label,e.value===a&&r.jsx(m.CheckIcon,{className:"bear-w-4 bear-h-4 bear-shrink-0 bear-text-bear-600 dark:bear-text-bear-400"})]},e.value))})}),l&&r.jsx("p",{className:"bear-text-sm bear-text-red-500",children:l})]})};exports.Select=N;
|
|
@@ -1,66 +1,65 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { cn as
|
|
4
|
-
import {
|
|
5
|
-
|
|
1
|
+
import { jsxs as n, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { useState as w, useRef as k, useCallback as N } from "react";
|
|
3
|
+
import { cn as t } from "../../utils/cn.js";
|
|
4
|
+
import { useClickOutside as C } from "../../hooks/useClickOutside.js";
|
|
5
|
+
import "../../context/BearProvider.js";
|
|
6
|
+
import "../../hooks/useBearComponent/useBearComponent.js";
|
|
7
|
+
import { ChevronDownIcon as j, CheckIcon as S } from "../Icon/index.js";
|
|
8
|
+
const I = {
|
|
6
9
|
sm: "bear-h-8 bear-text-sm bear-px-3",
|
|
7
10
|
md: "bear-h-10 bear-text-base bear-px-4",
|
|
8
11
|
lg: "bear-h-12 bear-text-lg bear-px-5"
|
|
9
|
-
},
|
|
10
|
-
options:
|
|
11
|
-
value:
|
|
12
|
-
onChange:
|
|
13
|
-
placeholder:
|
|
14
|
-
label:
|
|
15
|
-
error:
|
|
12
|
+
}, A = ({
|
|
13
|
+
options: i,
|
|
14
|
+
value: a,
|
|
15
|
+
onChange: l,
|
|
16
|
+
placeholder: x = "Select an option",
|
|
17
|
+
label: f,
|
|
18
|
+
error: s,
|
|
16
19
|
disabled: o = !1,
|
|
17
|
-
size:
|
|
18
|
-
fullWidth:
|
|
20
|
+
size: v = "md",
|
|
21
|
+
fullWidth: h = !1,
|
|
19
22
|
className: y
|
|
20
23
|
}) => {
|
|
21
|
-
const [d,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
};
|
|
26
|
-
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
27
|
-
}, []);
|
|
28
|
-
const k = (e) => {
|
|
29
|
-
s == null || s(e), n(!1);
|
|
24
|
+
const [d, c] = w(!1), u = k(null), m = !!s, b = i.find((e) => e.value === a), g = N(() => c(!1), []);
|
|
25
|
+
C(u, g);
|
|
26
|
+
const p = (e) => {
|
|
27
|
+
l == null || l(e), c(!1);
|
|
30
28
|
};
|
|
31
|
-
return /* @__PURE__ */
|
|
29
|
+
return /* @__PURE__ */ n(
|
|
32
30
|
"div",
|
|
33
31
|
{
|
|
34
|
-
ref:
|
|
35
|
-
className:
|
|
32
|
+
ref: u,
|
|
33
|
+
className: t("bear-relative bear-flex bear-flex-col bear-gap-1.5", h && "bear-w-full"),
|
|
36
34
|
children: [
|
|
37
|
-
|
|
38
|
-
/* @__PURE__ */
|
|
35
|
+
f && /* @__PURE__ */ r("label", { className: "bear-text-sm bear-font-medium", style: { color: "var(--bear-text-secondary)" }, children: f }),
|
|
36
|
+
/* @__PURE__ */ n(
|
|
39
37
|
"button",
|
|
40
38
|
{
|
|
41
39
|
type: "button",
|
|
42
40
|
disabled: o,
|
|
43
|
-
onClick: () => !o &&
|
|
44
|
-
className:
|
|
41
|
+
onClick: () => !o && c(!d),
|
|
42
|
+
className: t(
|
|
45
43
|
"bear-flex bear-items-center bear-justify-between bear-w-full",
|
|
46
44
|
"bear-rounded-lg bear-border bear-text-left bear-outline-none bear-transition-all bear-duration-200",
|
|
47
|
-
"bear-
|
|
48
|
-
"focus:bear-ring-
|
|
49
|
-
"dark:bear-bg-gray-800 dark:bear-text-white dark:bear-border-gray-600 dark:focus:bear-ring-offset-gray-900",
|
|
50
|
-
h ? "bear-border-red-500 focus:bear-ring-red-500" : "focus:bear-border-bear-500 focus:bear-ring-bear-500 dark:focus:bear-border-bear-500 dark:focus:bear-ring-bear-500",
|
|
45
|
+
"focus:bear-ring-2 focus:bear-ring-offset-2 focus:bear-ring-offset-[var(--bear-bg-primary)]",
|
|
46
|
+
m ? "bear-border-red-500 focus:bear-ring-red-500" : "focus:bear-border-bear-500 focus:bear-ring-bear-500 dark:focus:bear-border-bear-500 dark:focus:bear-ring-bear-500",
|
|
51
47
|
o && "bear-opacity-50 bear-cursor-not-allowed",
|
|
52
|
-
|
|
48
|
+
I[v],
|
|
53
49
|
y
|
|
54
50
|
),
|
|
51
|
+
style: {
|
|
52
|
+
backgroundColor: "var(--bear-bg-primary)",
|
|
53
|
+
borderColor: m ? void 0 : "var(--bear-border-default)",
|
|
54
|
+
color: b ? "var(--bear-text-primary)" : "var(--bear-text-muted)"
|
|
55
|
+
},
|
|
55
56
|
children: [
|
|
56
|
-
/* @__PURE__ */ r("span", {
|
|
57
|
+
/* @__PURE__ */ r("span", { children: (b == null ? void 0 : b.label) || x }),
|
|
57
58
|
/* @__PURE__ */ r(
|
|
58
59
|
j,
|
|
59
60
|
{
|
|
60
|
-
className:
|
|
61
|
-
|
|
62
|
-
d && "bear-rotate-180"
|
|
63
|
-
)
|
|
61
|
+
className: t("bear-w-4 bear-h-4 bear-shrink-0 bear-transition-transform", d && "bear-rotate-180"),
|
|
62
|
+
style: { color: "var(--bear-text-muted)" }
|
|
64
63
|
}
|
|
65
64
|
)
|
|
66
65
|
]
|
|
@@ -69,37 +68,39 @@ const S = {
|
|
|
69
68
|
d && /* @__PURE__ */ r(
|
|
70
69
|
"div",
|
|
71
70
|
{
|
|
72
|
-
className:
|
|
73
|
-
|
|
74
|
-
"bear-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
children: /* @__PURE__ */ r("div", { className: "bear-max-h-60 bear-overflow-y-auto", children:
|
|
71
|
+
className: "bear-absolute bear-z-50 bear-w-full bear-mt-1 bear-rounded-lg bear-border bear-shadow-lg bear-overflow-hidden bear-top-full",
|
|
72
|
+
style: {
|
|
73
|
+
backgroundColor: "var(--bear-bg-primary)",
|
|
74
|
+
borderColor: "var(--bear-border-default)"
|
|
75
|
+
},
|
|
76
|
+
children: /* @__PURE__ */ r("div", { className: "bear-max-h-60 bear-overflow-y-auto", children: i.map((e) => /* @__PURE__ */ n(
|
|
78
77
|
"button",
|
|
79
78
|
{
|
|
80
79
|
type: "button",
|
|
81
80
|
disabled: e.disabled,
|
|
82
|
-
onClick: () => !e.disabled &&
|
|
83
|
-
className:
|
|
81
|
+
onClick: () => !e.disabled && p(e.value),
|
|
82
|
+
className: t(
|
|
84
83
|
"bear-flex bear-items-center bear-justify-between bear-w-full bear-px-4 bear-py-2",
|
|
85
84
|
"bear-text-left bear-transition-colors",
|
|
86
|
-
e.disabled
|
|
87
|
-
e.value ===
|
|
85
|
+
e.disabled && "bear-cursor-not-allowed",
|
|
86
|
+
e.value === a && "bear-bg-bear-100 bear-text-bear-700 dark:bear-bg-bear-600/20 dark:bear-text-bear-300",
|
|
87
|
+
!e.disabled && e.value !== a && "hover:bear-bg-[var(--bear-bg-tertiary)]"
|
|
88
88
|
),
|
|
89
|
+
style: e.disabled ? { color: "var(--bear-text-muted)" } : e.value === a ? void 0 : { color: "var(--bear-text-secondary)" },
|
|
89
90
|
children: [
|
|
90
91
|
e.label,
|
|
91
|
-
e.value ===
|
|
92
|
+
e.value === a && /* @__PURE__ */ r(S, { className: "bear-w-4 bear-h-4 bear-shrink-0 bear-text-bear-600 dark:bear-text-bear-400" })
|
|
92
93
|
]
|
|
93
94
|
},
|
|
94
95
|
e.value
|
|
95
96
|
)) })
|
|
96
97
|
}
|
|
97
98
|
),
|
|
98
|
-
|
|
99
|
+
s && /* @__PURE__ */ r("p", { className: "bear-text-sm bear-text-red-500", children: s })
|
|
99
100
|
]
|
|
100
101
|
}
|
|
101
102
|
);
|
|
102
103
|
};
|
|
103
104
|
export {
|
|
104
|
-
|
|
105
|
+
A as Select
|
|
105
106
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),r=require("react"),S=require("../../utils/cn.cjs"),y=require("../Button/Button.cjs"),s=require("./SignPad.const.cjs"),V=B=>{const{onChange:
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),r=require("react"),S=require("../../utils/cn.cjs"),y=require("../Button/Button.cjs"),s=require("./SignPad.const.cjs"),V=B=>{const{onChange:o,width:p,height:D=s.SIGN_PAD_DEFAULT_HEIGHT,strokeColor:O,strokeWidth:T=s.SIGN_PAD_DEFAULT_STROKE_WIDTH,backgroundColor:M,placeholder:U=s.SIGN_PAD_DEFAULT_PLACEHOLDER,disabled:a=!1,readOnly:c=!1,showClear:N=!0,showSave:m=!1,clearText:j="Clear",saveText:F="Save",outputFormat:P=s.SIGN_PAD_DEFAULT_OUTPUT_FORMAT,outputQuality:v=s.SIGN_PAD_DEFAULT_OUTPUT_QUALITY,className:H,testId:K,id:q,...W}=B,i=r.useRef(null),w=r.useRef(null),A=r.useRef(null),g=r.useRef(!1),[h,L]=r.useState(!1),[E,z]=r.useState(!1);r.useEffect(()=>{const e=()=>{z(document.documentElement.classList.contains("dark"))};e();const t=new MutationObserver(e);return t.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>t.disconnect()},[]);const k=O||(E?s.SIGN_PAD_STROKE_DARK:s.SIGN_PAD_STROKE_LIGHT),C=M||(E?s.SIGN_PAD_BG_DARK:s.SIGN_PAD_BG_LIGHT),_=r.useCallback(()=>{const e=i.current,t=e==null?void 0:e.getContext("2d");!e||!t||(t.fillStyle=C==="transparent"?"rgba(0,0,0,0)":C,t.fillRect(0,0,e.width,e.height))},[C]);r.useEffect(()=>{const e=i.current,t=w.current;if(!e||!t)return;const n=()=>{const d=t.getBoundingClientRect(),f=p??Math.round(d.width),G=D;(e.width!==f||e.height!==G)&&(e.width=f,e.height=G,_())};n();const l=new ResizeObserver(n);return l.observe(t),()=>l.disconnect()},[p,D,_]),r.useEffect(()=>{_()},[_,E]),r.useEffect(()=>{const e=i.current;if(!e||a||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)}},[a,c]);const b=r.useCallback(e=>{const t=i.current;if(!t)return{x:0,y:0};const n=t.getBoundingClientRect(),l=t.width/n.width,d=t.height/n.height;if("touches"in e){const f=e.touches[0];return{x:(f.clientX-n.left)*l,y:(f.clientY-n.top)*d}}return{x:(e.clientX-n.left)*l,y:(e.clientY-n.top)*d}},[]),I=r.useCallback(e=>{if(a||c)return;const t=b(e);g.current=!0,A.current=t},[a,c,b]),x=r.useCallback(e=>{if(!g.current||a||c)return;const t=i.current,n=t==null?void 0:t.getContext("2d"),l=A.current;if(!t||!n||!l)return;const d=b(e);n.beginPath(),n.moveTo(l.x,l.y),n.lineTo(d.x,d.y),n.strokeStyle=k,n.lineWidth=T,n.lineCap="round",n.lineJoin="round",n.stroke(),A.current=d,L(!0)},[a,c,k,T,b]),R=r.useCallback(()=>{if(g.current){const e=i.current;if(e&&o){const t=e.toDataURL(P,v);o(t)}}g.current=!1,A.current=null},[o,P,v]),X=r.useCallback(()=>{const e=i.current,t=e==null?void 0:e.getContext("2d");!e||!t||(t.clearRect(0,0,e.width,e.height),_(),L(!1),o==null||o(null))},[_,o]),Y=r.useCallback(()=>{const e=i.current;if(!e||!h)return;const t=e.toDataURL(P,v);o==null||o(t)},[h,o,P,v]);return u.jsxs("div",{id:q,"data-testid":K,className:S.cn("Bear-SignPad bear-w-full",s.SIGN_PAD_ROOT_CLASSES,a&&"Bear-SignPad--disabled bear-opacity-50",c&&"Bear-SignPad--readonly",H),...W,children:[u.jsxs("div",{ref:w,className:S.cn("Bear-SignPad__canvas-wrapper bear-w-full bear-overflow-hidden","bear-touch-none",s.SIGN_PAD_CANVAS_WRAPPER_CLASSES,!a&&!c&&s.SIGN_PAD_CANVAS_WRAPPER_HOVER,a&&"bear-cursor-not-allowed",!a&&!c&&"bear-cursor-crosshair"),children:[u.jsx("canvas",{ref:i,className:"Bear-SignPad__canvas bear-block bear-rounded-lg bear-w-full bear-touch-none",style:{height:D},onMouseDown:I,onMouseMove:x,onMouseUp:R,onMouseLeave:R,onTouchStart:I,onTouchMove:x,onTouchEnd:R}),!h&&u.jsx("div",{className:S.cn("Bear-SignPad__placeholder",s.SIGN_PAD_PLACEHOLDER_CLASSES),children:U}),u.jsx("div",{className:S.cn("Bear-SignPad__line",s.SIGN_PAD_LINE_CLASSES)}),u.jsx("span",{className:S.cn("Bear-SignPad__x-mark",s.SIGN_PAD_X_MARK_CLASSES),children:"×"})]}),(N||m)&&u.jsxs("div",{className:S.cn("Bear-SignPad__actions",s.SIGN_PAD_ACTIONS_CLASSES),children:[N&&u.jsx(y.Button,{size:"sm",variant:"ghost",onClick:X,disabled:a||!h,children:j}),m&&u.jsx(y.Button,{size:"sm",variant:"primary",onClick:Y,disabled:a||!h,children:F})]})]})};exports.SignPad=V;
|