@forgedevstack/bear 1.2.4 → 1.2.6
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 +15 -0
- package/dist/components/AppBar/AppBar.cjs +1 -1
- package/dist/components/AppBar/AppBar.const.cjs +1 -0
- package/dist/components/AppBar/AppBar.const.d.ts +36 -1
- package/dist/components/AppBar/AppBar.const.js +39 -0
- package/dist/components/AppBar/AppBar.js +65 -42
- package/dist/components/AppBar/AppBar.types.d.ts +9 -3
- package/dist/components/Backdrop/Backdrop.cjs +1 -0
- package/dist/components/Backdrop/Backdrop.const.cjs +1 -0
- package/dist/components/Backdrop/Backdrop.const.d.ts +7 -0
- package/dist/components/Backdrop/Backdrop.const.js +10 -0
- package/dist/components/Backdrop/Backdrop.d.ts +3 -0
- package/dist/components/Backdrop/Backdrop.js +43 -0
- package/dist/components/Backdrop/Backdrop.types.d.ts +12 -0
- package/dist/components/Backdrop/index.d.ts +2 -0
- package/dist/components/BottomNavigation/BottomNavigation.cjs +1 -1
- package/dist/components/BottomNavigation/BottomNavigation.const.cjs +1 -0
- package/dist/components/BottomNavigation/BottomNavigation.const.d.ts +8 -1
- package/dist/components/BottomNavigation/BottomNavigation.const.js +11 -0
- package/dist/components/BottomNavigation/BottomNavigation.js +64 -46
- package/dist/components/Breadcrumbs/Breadcrumbs.cjs +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.js +65 -64
- package/dist/components/Card/Card.types.d.ts +1 -2
- package/dist/components/Chat/Chat.const.cjs +1 -1
- package/dist/components/Chat/Chat.const.d.ts +1 -1
- package/dist/components/Chat/Chat.const.js +1 -1
- package/dist/components/Chip/Chip.cjs +1 -1
- package/dist/components/Chip/Chip.const.cjs +1 -0
- package/dist/components/Chip/Chip.const.d.ts +39 -0
- package/dist/components/Chip/Chip.const.js +43 -0
- package/dist/components/Chip/Chip.js +44 -65
- package/dist/components/ChipGroup/ChipGroup.cjs +1 -0
- package/dist/components/ChipGroup/ChipGroup.const.cjs +1 -0
- package/dist/components/ChipGroup/ChipGroup.const.d.ts +8 -0
- package/dist/components/ChipGroup/ChipGroup.const.js +11 -0
- package/dist/components/ChipGroup/ChipGroup.d.ts +3 -0
- package/dist/components/ChipGroup/ChipGroup.js +41 -0
- package/dist/components/ChipGroup/ChipGroup.types.d.ts +9 -0
- package/dist/components/ChipGroup/index.d.ts +2 -0
- package/dist/components/ColorSwatch/ColorSwatch.cjs +1 -1
- package/dist/components/ColorSwatch/ColorSwatch.js +8 -8
- package/dist/components/CommandPalette/CommandPalette.cjs +1 -1
- package/dist/components/CommandPalette/CommandPalette.js +71 -71
- package/dist/components/DiffSquares/DiffSquares.cjs +1 -1
- package/dist/components/DiffSquares/DiffSquares.js +11 -11
- package/dist/components/Drawer/Drawer.cjs +1 -1
- package/dist/components/Drawer/Drawer.js +57 -56
- package/dist/components/Input/Input.cjs +1 -1
- package/dist/components/Input/Input.js +63 -62
- package/dist/components/List/List.cjs +1 -1
- package/dist/components/List/List.js +133 -123
- package/dist/components/List/List.types.d.ts +2 -0
- package/dist/components/MentionsInput/MentionsInput.cjs +1 -1
- package/dist/components/MentionsInput/MentionsInput.js +114 -92
- package/dist/components/MentionsInput/MentionsInput.types.d.ts +4 -0
- package/dist/components/MessageList/MessageList.cjs +1 -0
- package/dist/components/MessageList/MessageList.const.cjs +1 -0
- package/dist/components/MessageList/MessageList.const.d.ts +29 -0
- package/dist/components/MessageList/MessageList.const.js +36 -0
- package/dist/components/MessageList/MessageList.d.ts +3 -0
- package/dist/components/MessageList/MessageList.js +194 -0
- package/dist/components/MessageList/MessageList.types.d.ts +74 -0
- package/dist/components/MessageList/MessageList.utils.cjs +1 -0
- package/dist/components/MessageList/MessageList.utils.d.ts +13 -0
- package/dist/components/MessageList/MessageList.utils.js +54 -0
- package/dist/components/MessageList/index.d.ts +2 -0
- package/dist/components/Progress/Progress.cjs +1 -1
- package/dist/components/Progress/Progress.const.cjs +1 -0
- package/dist/components/Progress/Progress.const.d.ts +16 -1
- package/dist/components/Progress/Progress.const.js +19 -0
- package/dist/components/Progress/Progress.d.ts +0 -10
- package/dist/components/Progress/Progress.js +81 -71
- package/dist/components/Progress/Progress.types.d.ts +2 -11
- package/dist/components/PropsPlayground/PropsPlayground.cjs +1 -1
- package/dist/components/PropsPlayground/PropsPlayground.js +40 -40
- package/dist/components/Select/Select.cjs +1 -1
- package/dist/components/Select/Select.const.cjs +1 -0
- package/dist/components/Select/Select.const.d.ts +9 -0
- package/dist/components/Select/Select.const.js +13 -0
- package/dist/components/Select/Select.js +144 -68
- package/dist/components/Stepper/Stepper.cjs +1 -1
- package/dist/components/Stepper/Stepper.js +89 -83
- package/dist/components/Toast/Toast.cjs +1 -1
- package/dist/components/Toast/Toast.const.cjs +1 -0
- package/dist/components/Toast/Toast.const.d.ts +4 -0
- package/dist/components/Toast/Toast.const.js +17 -0
- package/dist/components/Toast/Toast.d.ts +3 -7
- package/dist/components/Toast/Toast.js +101 -89
- package/dist/components/Toast/Toast.types.d.ts +9 -0
- package/dist/components/Toast/index.d.ts +1 -1
- package/dist/components/TreeSelect/TreeSelect.cjs +1 -1
- package/dist/components/TreeSelect/TreeSelect.js +22 -22
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.d.ts +7 -1
- package/dist/components/index.js +284 -278
- package/dist/context/BearProvider.cjs +1 -1
- package/dist/context/BearProvider.d.ts +8 -0
- package/dist/context/BearProvider.js +149 -139
- package/dist/context/index.cjs +1 -1
- package/dist/context/index.d.ts +1 -1
- package/dist/context/index.js +12 -10
- package/dist/index.cjs +1 -1
- package/dist/index.js +392 -384
- package/dist/styles/_message-list.css +42 -0
- package/dist/styles/main.css +1 -0
- package/dist/styles.css +114 -19
- package/package.json +15 -2
|
@@ -12,7 +12,7 @@ const N = ({
|
|
|
12
12
|
onClick: n,
|
|
13
13
|
className: A,
|
|
14
14
|
testId: S,
|
|
15
|
-
...
|
|
15
|
+
...f
|
|
16
16
|
}) => {
|
|
17
17
|
const i = u[r], o = G(a), m = Math.max(12, i * 0.4);
|
|
18
18
|
return /* @__PURE__ */ C("div", { className: "bear-inline-flex bear-flex-col bear-items-center", children: [
|
|
@@ -32,7 +32,7 @@ const N = ({
|
|
|
32
32
|
"aria-selected": t,
|
|
33
33
|
"aria-label": l ?? a,
|
|
34
34
|
"data-testid": S,
|
|
35
|
-
...
|
|
35
|
+
...f,
|
|
36
36
|
children: t && /* @__PURE__ */ s("svg", { className: L(o ? x : T), width: m, height: m, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 3, strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ s("polyline", { points: "20 6 9 17 4 12" }) })
|
|
37
37
|
}
|
|
38
38
|
),
|
|
@@ -47,18 +47,18 @@ const N = ({
|
|
|
47
47
|
rounded: n = !0,
|
|
48
48
|
gap: A = W,
|
|
49
49
|
columns: S,
|
|
50
|
-
showLabel:
|
|
50
|
+
showLabel: f = !1,
|
|
51
51
|
className: i,
|
|
52
52
|
testId: o,
|
|
53
53
|
...m
|
|
54
54
|
}) => {
|
|
55
|
-
const
|
|
55
|
+
const E = _(() => t ? new Set(Array.isArray(t) ? t : [t]) : /* @__PURE__ */ new Set(), [t]), p = h((e) => {
|
|
56
56
|
if (d) {
|
|
57
|
-
const c = new Set(
|
|
57
|
+
const c = new Set(E);
|
|
58
58
|
c.has(e) ? c.delete(e) : c.add(e), r == null || r(Array.from(c));
|
|
59
59
|
} else
|
|
60
60
|
r == null || r(e);
|
|
61
|
-
}, [d,
|
|
61
|
+
}, [d, E, r]);
|
|
62
62
|
return /* @__PURE__ */ s(
|
|
63
63
|
"div",
|
|
64
64
|
{
|
|
@@ -75,10 +75,10 @@ const N = ({
|
|
|
75
75
|
N,
|
|
76
76
|
{
|
|
77
77
|
color: e,
|
|
78
|
-
selected:
|
|
78
|
+
selected: E.has(e),
|
|
79
79
|
size: l,
|
|
80
80
|
rounded: n,
|
|
81
|
-
label:
|
|
81
|
+
label: f ? e : void 0,
|
|
82
82
|
onClick: () => p(e)
|
|
83
83
|
},
|
|
84
84
|
e
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),t=require("react"),Q=require("react-dom"),L=require("../../utils/cn.cjs"),v=require("./CommandPalette.const.cjs"),E=require("./CommandPalette.utils.cjs"),z=({command:s,isHighlighted:j,onSelect:m})=>r.jsxs("button",{type:"button",onClick:m,disabled:s.disabled,className:L.cn("Bear-CommandPalette__item bear-w-full bear-flex bear-items-center bear-gap-3 bear-px-4 bear-py-2.5 bear-text-left bear-transition-colors",j?"bear-bg-primary-500/20 bear-text-primary-400":"bear-text-gray-700 dark:bear-text-zinc-300 hover:bear-bg-gray-100 dark:hover:bear-bg-zinc-700",s.disabled&&"bear-opacity-50 bear-cursor-not-allowed"),children:[s.icon&&r.jsx("span",{className:"Bear-CommandPalette__item-icon bear-text-gray-500 dark:bear-text-zinc-400 bear-shrink-0",children:s.icon}),r.jsxs("div",{className:"Bear-CommandPalette__item-content bear-flex-1 bear-min-w-0",children:[r.jsx("div",{className:"Bear-CommandPalette__item-label bear-text-sm bear-font-medium bear-truncate",children:s.label}),s.description&&r.jsx("div",{className:"Bear-CommandPalette__item-description bear-text-xs bear-text-gray-500 dark:bear-text-zinc-500 bear-truncate",children:s.description})]}),s.shortcut&&r.jsx("div",{className:"Bear-CommandPalette__item-shortcut bear-flex bear-gap-1 bear-shrink-0",children:E.formatShortcut(s.shortcut).map((C,f)=>r.jsx("kbd",{className:"bear-px-1.5 bear-py-0.5 bear-text-xs bear-font-mono bear-bg-gray-200 bear-text-gray-600 dark:bear-bg-zinc-700 dark:bear-text-zinc-400 bear-rounded",children:C},f))})]}),V=({commands:s,open:j,onOpenChange:m,placeholder:C,showRecent:f=!0,maxRecent:h=v.COMMAND_PALETTE_MAX_RECENT,recentIds:q,onRecentChange:g,groupByCategory:N=!1,filterFn:B=E.defaultFilterFn,triggerKey:D=v.COMMAND_PALETTE_TRIGGER_KEY,className:O,testId:R,translations:I,icon:K,footer:M})=>{const[H,F]=t.useState(!1),[l,A]=t.useState(""),[n,k]=t.useState(0),[G,U]=t.useState([]),S=t.useRef(null),P=t.useRef(null),u=j??H,i=t.useCallback(e=>{m==null||m(e),F(e)},[m]),b=q??G,T=t.useCallback(e=>{g==null||g(e),U(e)},[g]),y=t.useMemo(()=>({...v.COMMAND_PALETTE_DEFAULT_TRANSLATIONS,...I}),[I]),x=t.useMemo(()=>l.trim()?s.filter(e=>B(e,l)):s,[s,l,B]),d=t.useMemo(()=>!f||l.trim()?[]:b.slice(0,h).map(e=>s.find(a=>a.id===e)).filter(Boolean),[f,l,b,h,s]),_=t.useMemo(()=>N?E.groupCommandsByCategory(x):null,[x,N]),c=t.useMemo(()=>{const e=[];return d.length>0&&e.push(...d),e.push(...x.filter(a=>!b.includes(a.id))),e},[d,x,b]);t.useEffect(()=>{const e=a=>{(a.metaKey||a.ctrlKey)&&a.key.toLowerCase()===D&&(a.preventDefault(),i(!u)),a.key==="Escape"&&u&&(a.preventDefault(),i(!1))};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[u,D,i]),t.useEffect(()=>{u&&(A(""),k(0),setTimeout(()=>{var e;return(e=S.current)==null?void 0:e.focus()},50))},[u]),t.useEffect(()=>{if(n>=0&&P.current){const a=P.current.querySelectorAll("[data-command-item]")[n];a&&a.scrollIntoView({block:"nearest"})}},[n]);const p=t.useCallback(e=>{const a=[e.id,...b.filter(o=>o!==e.id)].slice(0,h);T(a),i(!1),e.onSelect()},[b,h,T,i]),X=t.useCallback(e=>{switch(e.key){case"ArrowDown":e.preventDefault(),k(a=>a<c.length-1?a+1:0);break;case"ArrowUp":e.preventDefault(),k(a=>a>0?a-1:c.length-1);break;case"Enter":e.preventDefault(),c[n]&&!c[n].disabled&&p(c[n]);break;case"Escape":e.preventDefault(),i(!1);break}},[c,n,p,i]);return u&&typeof document<"u"?Q.createPortal(r.jsxs("div",{className:L.cn("Bear-CommandPalette bear-fixed bear-inset-0 bear-flex bear-items-start bear-justify-center bear-pt-[15vh]",O),style:{zIndex:v.COMMAND_PALETTE_Z_INDEX},"data-testid":R,children:[r.jsx("div",{className:"Bear-CommandPalette__backdrop bear-absolute bear-inset-0 bear-bg-black/50 bear-backdrop-blur-sm",onClick:()=>i(!1)}),r.jsxs("div",{className:"Bear-CommandPalette__content bear-relative bear-w-full bear-max-w-xl bear-bg-white dark:bear-bg-zinc-800 bear-border bear-border-gray-200 dark:bear-border-zinc-700 bear-rounded-xl bear-shadow-2xl bear-overflow-hidden",children:[r.jsxs("div",{className:"Bear-CommandPalette__search bear-flex bear-items-center bear-gap-3 bear-px-4 bear-py-3 bear-border-b bear-border-gray-200 dark:bear-border-zinc-700",children:[K??r.jsx("svg",{className:"bear-w-5 bear-h-5 bear-text-gray-500 dark:bear-text-zinc-400 bear-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),r.jsx("input",{ref:S,type:"text",value:l,onChange:e=>{A(e.target.value),k(0)},onKeyDown:X,placeholder:C||y.placeholder,className:"Bear-CommandPalette__input bear-flex-1 bear-bg-transparent bear-border-0 bear-outline-none bear-text-gray-900 dark:bear-text-white placeholder:bear-text-gray-400 dark:placeholder:bear-text-zinc-500"}),r.jsx("kbd",{className:"bear-px-2 bear-py-1 bear-text-xs bear-font-mono bear-bg-gray-200 bear-text-gray-600 dark:bear-bg-zinc-700 dark:bear-text-zinc-400 bear-rounded",children:"esc"})]}),r.jsx("div",{ref:P,className:"Bear-CommandPalette__list bear-max-h-[60vh] bear-overflow-y-auto",children:c.length===0?r.jsx("div",{className:"Bear-CommandPalette__empty bear-px-4 bear-py-8 bear-text-center bear-text-sm bear-text-gray-500 dark:bear-text-zinc-500",children:y.noResults}):r.jsxs(r.Fragment,{children:[d.length>0&&!l.trim()&&r.jsxs("div",{className:"Bear-CommandPalette__group",children:[r.jsx("div",{className:"Bear-CommandPalette__group-header bear-px-4 bear-py-2 bear-text-xs bear-font-medium bear-text-gray-500 dark:bear-text-zinc-500 bear-uppercase bear-tracking-wider bear-bg-gray-50 dark:bear-bg-zinc-800/50",children:y.recentCommands}),d.map((e,a)=>r.jsx("div",{"data-command-item":!0,children:r.jsx(z,{command:e,isHighlighted:n===a,onSelect:()=>p(e)})},`recent-${e.id}`))]}),N&&_?_.map(e=>{const a=d.length+_.slice(0,_.indexOf(e)).reduce((o,w)=>o+w.commands.length,0);return r.jsxs("div",{className:"Bear-CommandPalette__group",children:[r.jsx("div",{className:"Bear-CommandPalette__group-header bear-px-4 bear-py-2 bear-text-xs bear-font-medium bear-text-gray-500 dark:bear-text-zinc-500 bear-uppercase bear-tracking-wider bear-bg-gray-50 dark:bear-bg-zinc-800/50",children:e.name}),e.commands.map((o,w)=>r.jsx("div",{"data-command-item":!0,children:r.jsx(z,{command:o,isHighlighted:n===a+w,onSelect:()=>p(o)})},o.id))]},e.name)}):r.jsxs("div",{className:"Bear-CommandPalette__group",children:[!l.trim()&&d.length>0&&r.jsx("div",{className:"Bear-CommandPalette__group-header bear-px-4 bear-py-2 bear-text-xs bear-font-medium bear-text-gray-500 dark:bear-text-zinc-500 bear-uppercase bear-tracking-wider bear-bg-gray-50 dark:bear-bg-zinc-800/50",children:y.allCommands}),x.filter(e=>!b.includes(e.id)||l.trim()).map((e,a)=>r.jsx("div",{"data-command-item":!0,children:r.jsx(z,{command:e,isHighlighted:n===d.length+a,onSelect:()=>p(e)})},e.id))]})]})}),M&&r.jsx("div",{className:"Bear-CommandPalette__footer bear-px-4 bear-py-2 bear-border-t bear-border-gray-200 dark:bear-border-zinc-700 bear-text-xs bear-text-gray-500 dark:bear-text-zinc-500",children:M})]})]}),document.body):null};exports.CommandPalette=V;
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import { jsxs as l, jsx as
|
|
2
|
-
import { useState as
|
|
1
|
+
import { jsxs as l, jsx as a, Fragment as Y } from "react/jsx-runtime";
|
|
2
|
+
import { useState as N, useRef as j, useCallback as C, useMemo as f, useEffect as I } from "react";
|
|
3
3
|
import { createPortal as Z } from "react-dom";
|
|
4
4
|
import { cn as H } from "../../utils/cn.js";
|
|
5
5
|
import { COMMAND_PALETTE_DEFAULT_TRANSLATIONS as $, COMMAND_PALETTE_MAX_RECENT as J, COMMAND_PALETTE_TRIGGER_KEY as ee, COMMAND_PALETTE_Z_INDEX as re } from "./CommandPalette.const.js";
|
|
6
|
-
import { defaultFilterFn as
|
|
6
|
+
import { defaultFilterFn as ae, groupCommandsByCategory as te, formatShortcut as ne } from "./CommandPalette.utils.js";
|
|
7
7
|
const D = ({
|
|
8
|
-
command:
|
|
9
|
-
isHighlighted:
|
|
8
|
+
command: t,
|
|
9
|
+
isHighlighted: w,
|
|
10
10
|
onSelect: m
|
|
11
11
|
}) => /* @__PURE__ */ l(
|
|
12
12
|
"button",
|
|
13
13
|
{
|
|
14
14
|
type: "button",
|
|
15
15
|
onClick: m,
|
|
16
|
-
disabled:
|
|
16
|
+
disabled: t.disabled,
|
|
17
17
|
className: H(
|
|
18
18
|
"Bear-CommandPalette__item bear-w-full bear-flex bear-items-center bear-gap-3 bear-px-4 bear-py-2.5 bear-text-left bear-transition-colors",
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
w ? "bear-bg-primary-500/20 bear-text-primary-400" : "bear-text-gray-700 dark:bear-text-zinc-300 hover:bear-bg-gray-100 dark:hover:bear-bg-zinc-700",
|
|
20
|
+
t.disabled && "bear-opacity-50 bear-cursor-not-allowed"
|
|
21
21
|
),
|
|
22
22
|
children: [
|
|
23
|
-
|
|
23
|
+
t.icon && /* @__PURE__ */ a("span", { className: "Bear-CommandPalette__item-icon bear-text-gray-500 dark:bear-text-zinc-400 bear-shrink-0", children: t.icon }),
|
|
24
24
|
/* @__PURE__ */ l("div", { className: "Bear-CommandPalette__item-content bear-flex-1 bear-min-w-0", children: [
|
|
25
|
-
/* @__PURE__ */
|
|
26
|
-
|
|
25
|
+
/* @__PURE__ */ a("div", { className: "Bear-CommandPalette__item-label bear-text-sm bear-font-medium bear-truncate", children: t.label }),
|
|
26
|
+
t.description && /* @__PURE__ */ a("div", { className: "Bear-CommandPalette__item-description bear-text-xs bear-text-gray-500 dark:bear-text-zinc-500 bear-truncate", children: t.description })
|
|
27
27
|
] }),
|
|
28
|
-
|
|
28
|
+
t.shortcut && /* @__PURE__ */ a("div", { className: "Bear-CommandPalette__item-shortcut bear-flex bear-gap-1 bear-shrink-0", children: ne(t.shortcut).map((P, h) => /* @__PURE__ */ a(
|
|
29
29
|
"kbd",
|
|
30
30
|
{
|
|
31
|
-
className: "bear-px-1.5 bear-py-0.5 bear-text-xs bear-font-mono bear-bg-
|
|
32
|
-
children:
|
|
31
|
+
className: "bear-px-1.5 bear-py-0.5 bear-text-xs bear-font-mono bear-bg-gray-200 bear-text-gray-600 dark:bear-bg-zinc-700 dark:bear-text-zinc-400 bear-rounded",
|
|
32
|
+
children: P
|
|
33
33
|
},
|
|
34
|
-
|
|
34
|
+
h
|
|
35
35
|
)) })
|
|
36
36
|
]
|
|
37
37
|
}
|
|
38
|
-
),
|
|
39
|
-
commands:
|
|
40
|
-
open:
|
|
38
|
+
), ce = ({
|
|
39
|
+
commands: t,
|
|
40
|
+
open: w,
|
|
41
41
|
onOpenChange: m,
|
|
42
|
-
placeholder:
|
|
43
|
-
showRecent:
|
|
44
|
-
maxRecent:
|
|
42
|
+
placeholder: P,
|
|
43
|
+
showRecent: h = !0,
|
|
44
|
+
maxRecent: g = J,
|
|
45
45
|
recentIds: F,
|
|
46
|
-
onRecentChange:
|
|
46
|
+
onRecentChange: y,
|
|
47
47
|
groupByCategory: z = !1,
|
|
48
|
-
filterFn: A =
|
|
48
|
+
filterFn: A = ae,
|
|
49
49
|
triggerKey: T = ee,
|
|
50
50
|
className: R,
|
|
51
51
|
testId: q,
|
|
@@ -53,24 +53,24 @@ const D = ({
|
|
|
53
53
|
icon: G,
|
|
54
54
|
footer: M
|
|
55
55
|
}) => {
|
|
56
|
-
const [U, X] =
|
|
56
|
+
const [U, X] = N(!1), [i, S] = N(""), [n, k] = N(0), [Q, V] = N([]), K = j(null), B = j(null), u = w ?? U, d = C((e) => {
|
|
57
57
|
m == null || m(e), X(e);
|
|
58
|
-
}, [m]),
|
|
59
|
-
|
|
60
|
-
}, [
|
|
58
|
+
}, [m]), s = F ?? Q, O = C((e) => {
|
|
59
|
+
y == null || y(e), V(e);
|
|
60
|
+
}, [y]), _ = f(() => ({
|
|
61
61
|
...$,
|
|
62
62
|
...L
|
|
63
|
-
}), [L]), p =
|
|
63
|
+
}), [L]), p = f(() => i.trim() ? t.filter((e) => A(e, i)) : t, [t, i, A]), b = f(() => !h || i.trim() ? [] : s.slice(0, g).map((e) => t.find((r) => r.id === e)).filter(Boolean), [h, i, s, g, t]), v = f(() => z ? te(p) : null, [p, z]), o = f(() => {
|
|
64
64
|
const e = [];
|
|
65
|
-
return
|
|
66
|
-
}, [
|
|
65
|
+
return b.length > 0 && e.push(...b), e.push(...p.filter((r) => !s.includes(r.id))), e;
|
|
66
|
+
}, [b, p, s]);
|
|
67
67
|
I(() => {
|
|
68
68
|
const e = (r) => {
|
|
69
|
-
(r.metaKey || r.ctrlKey) && r.key.toLowerCase() === T && (r.preventDefault(),
|
|
69
|
+
(r.metaKey || r.ctrlKey) && r.key.toLowerCase() === T && (r.preventDefault(), d(!u)), r.key === "Escape" && u && (r.preventDefault(), d(!1));
|
|
70
70
|
};
|
|
71
71
|
return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
|
|
72
|
-
}, [u, T,
|
|
73
|
-
u && (S(""),
|
|
72
|
+
}, [u, T, d]), I(() => {
|
|
73
|
+
u && (S(""), k(0), setTimeout(() => {
|
|
74
74
|
var e;
|
|
75
75
|
return (e = K.current) == null ? void 0 : e.focus();
|
|
76
76
|
}, 50));
|
|
@@ -80,25 +80,25 @@ const D = ({
|
|
|
80
80
|
r && r.scrollIntoView({ block: "nearest" });
|
|
81
81
|
}
|
|
82
82
|
}, [n]);
|
|
83
|
-
const
|
|
84
|
-
const r = [e.id, ...
|
|
85
|
-
O(r),
|
|
86
|
-
}, [
|
|
83
|
+
const x = C((e) => {
|
|
84
|
+
const r = [e.id, ...s.filter((c) => c !== e.id)].slice(0, g);
|
|
85
|
+
O(r), d(!1), e.onSelect();
|
|
86
|
+
}, [s, g, O, d]), W = C((e) => {
|
|
87
87
|
switch (e.key) {
|
|
88
88
|
case "ArrowDown":
|
|
89
|
-
e.preventDefault(),
|
|
89
|
+
e.preventDefault(), k((r) => r < o.length - 1 ? r + 1 : 0);
|
|
90
90
|
break;
|
|
91
91
|
case "ArrowUp":
|
|
92
|
-
e.preventDefault(),
|
|
92
|
+
e.preventDefault(), k((r) => r > 0 ? r - 1 : o.length - 1);
|
|
93
93
|
break;
|
|
94
94
|
case "Enter":
|
|
95
|
-
e.preventDefault(), o[n] && !o[n].disabled &&
|
|
95
|
+
e.preventDefault(), o[n] && !o[n].disabled && x(o[n]);
|
|
96
96
|
break;
|
|
97
97
|
case "Escape":
|
|
98
|
-
e.preventDefault(),
|
|
98
|
+
e.preventDefault(), d(!1);
|
|
99
99
|
break;
|
|
100
100
|
}
|
|
101
|
-
}, [o, n,
|
|
101
|
+
}, [o, n, x, d]);
|
|
102
102
|
return u && typeof document < "u" ? Z(
|
|
103
103
|
/* @__PURE__ */ l(
|
|
104
104
|
"div",
|
|
@@ -107,77 +107,77 @@ const D = ({
|
|
|
107
107
|
style: { zIndex: re },
|
|
108
108
|
"data-testid": q,
|
|
109
109
|
children: [
|
|
110
|
-
/* @__PURE__ */
|
|
110
|
+
/* @__PURE__ */ a(
|
|
111
111
|
"div",
|
|
112
112
|
{
|
|
113
113
|
className: "Bear-CommandPalette__backdrop bear-absolute bear-inset-0 bear-bg-black/50 bear-backdrop-blur-sm",
|
|
114
|
-
onClick: () =>
|
|
114
|
+
onClick: () => d(!1)
|
|
115
115
|
}
|
|
116
116
|
),
|
|
117
|
-
/* @__PURE__ */ l("div", { className: "Bear-CommandPalette__content bear-relative bear-w-full bear-max-w-xl bear-bg-zinc-800 bear-border bear-border-zinc-700 bear-rounded-xl bear-shadow-2xl bear-overflow-hidden", children: [
|
|
118
|
-
/* @__PURE__ */ l("div", { className: "Bear-CommandPalette__search bear-flex bear-items-center bear-gap-3 bear-px-4 bear-py-3 bear-border-b bear-border-zinc-700", children: [
|
|
119
|
-
G ?? /* @__PURE__ */
|
|
120
|
-
/* @__PURE__ */
|
|
117
|
+
/* @__PURE__ */ l("div", { className: "Bear-CommandPalette__content bear-relative bear-w-full bear-max-w-xl bear-bg-white dark:bear-bg-zinc-800 bear-border bear-border-gray-200 dark:bear-border-zinc-700 bear-rounded-xl bear-shadow-2xl bear-overflow-hidden", children: [
|
|
118
|
+
/* @__PURE__ */ l("div", { className: "Bear-CommandPalette__search bear-flex bear-items-center bear-gap-3 bear-px-4 bear-py-3 bear-border-b bear-border-gray-200 dark:bear-border-zinc-700", children: [
|
|
119
|
+
G ?? /* @__PURE__ */ a("svg", { className: "bear-w-5 bear-h-5 bear-text-gray-500 dark:bear-text-zinc-400 bear-shrink-0", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ a("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" }) }),
|
|
120
|
+
/* @__PURE__ */ a(
|
|
121
121
|
"input",
|
|
122
122
|
{
|
|
123
123
|
ref: K,
|
|
124
124
|
type: "text",
|
|
125
125
|
value: i,
|
|
126
126
|
onChange: (e) => {
|
|
127
|
-
S(e.target.value),
|
|
127
|
+
S(e.target.value), k(0);
|
|
128
128
|
},
|
|
129
129
|
onKeyDown: W,
|
|
130
|
-
placeholder:
|
|
131
|
-
className: "Bear-CommandPalette__input bear-flex-1 bear-bg-transparent bear-border-0 bear-outline-none bear-text-white placeholder:bear-text-zinc-500"
|
|
130
|
+
placeholder: P || _.placeholder,
|
|
131
|
+
className: "Bear-CommandPalette__input bear-flex-1 bear-bg-transparent bear-border-0 bear-outline-none bear-text-gray-900 dark:bear-text-white placeholder:bear-text-gray-400 dark:placeholder:bear-text-zinc-500"
|
|
132
132
|
}
|
|
133
133
|
),
|
|
134
|
-
/* @__PURE__ */
|
|
134
|
+
/* @__PURE__ */ a("kbd", { className: "bear-px-2 bear-py-1 bear-text-xs bear-font-mono bear-bg-gray-200 bear-text-gray-600 dark:bear-bg-zinc-700 dark:bear-text-zinc-400 bear-rounded", children: "esc" })
|
|
135
135
|
] }),
|
|
136
|
-
/* @__PURE__ */
|
|
136
|
+
/* @__PURE__ */ a(
|
|
137
137
|
"div",
|
|
138
138
|
{
|
|
139
139
|
ref: B,
|
|
140
140
|
className: "Bear-CommandPalette__list bear-max-h-[60vh] bear-overflow-y-auto",
|
|
141
|
-
children: o.length === 0 ? /* @__PURE__ */
|
|
142
|
-
|
|
143
|
-
/* @__PURE__ */
|
|
144
|
-
|
|
141
|
+
children: o.length === 0 ? /* @__PURE__ */ a("div", { className: "Bear-CommandPalette__empty bear-px-4 bear-py-8 bear-text-center bear-text-sm bear-text-gray-500 dark:bear-text-zinc-500", children: _.noResults }) : /* @__PURE__ */ l(Y, { children: [
|
|
142
|
+
b.length > 0 && !i.trim() && /* @__PURE__ */ l("div", { className: "Bear-CommandPalette__group", children: [
|
|
143
|
+
/* @__PURE__ */ a("div", { className: "Bear-CommandPalette__group-header bear-px-4 bear-py-2 bear-text-xs bear-font-medium bear-text-gray-500 dark:bear-text-zinc-500 bear-uppercase bear-tracking-wider bear-bg-gray-50 dark:bear-bg-zinc-800/50", children: _.recentCommands }),
|
|
144
|
+
b.map((e, r) => /* @__PURE__ */ a("div", { "data-command-item": !0, children: /* @__PURE__ */ a(
|
|
145
145
|
D,
|
|
146
146
|
{
|
|
147
147
|
command: e,
|
|
148
148
|
isHighlighted: n === r,
|
|
149
|
-
onSelect: () =>
|
|
149
|
+
onSelect: () => x(e)
|
|
150
150
|
}
|
|
151
151
|
) }, `recent-${e.id}`))
|
|
152
152
|
] }),
|
|
153
|
-
z &&
|
|
154
|
-
const r =
|
|
153
|
+
z && v ? v.map((e) => {
|
|
154
|
+
const r = b.length + v.slice(0, v.indexOf(e)).reduce((c, E) => c + E.commands.length, 0);
|
|
155
155
|
return /* @__PURE__ */ l("div", { className: "Bear-CommandPalette__group", children: [
|
|
156
|
-
/* @__PURE__ */
|
|
157
|
-
e.commands.map((
|
|
156
|
+
/* @__PURE__ */ a("div", { className: "Bear-CommandPalette__group-header bear-px-4 bear-py-2 bear-text-xs bear-font-medium bear-text-gray-500 dark:bear-text-zinc-500 bear-uppercase bear-tracking-wider bear-bg-gray-50 dark:bear-bg-zinc-800/50", children: e.name }),
|
|
157
|
+
e.commands.map((c, E) => /* @__PURE__ */ a("div", { "data-command-item": !0, children: /* @__PURE__ */ a(
|
|
158
158
|
D,
|
|
159
159
|
{
|
|
160
|
-
command:
|
|
160
|
+
command: c,
|
|
161
161
|
isHighlighted: n === r + E,
|
|
162
|
-
onSelect: () =>
|
|
162
|
+
onSelect: () => x(c)
|
|
163
163
|
}
|
|
164
|
-
) },
|
|
164
|
+
) }, c.id))
|
|
165
165
|
] }, e.name);
|
|
166
166
|
}) : /* @__PURE__ */ l("div", { className: "Bear-CommandPalette__group", children: [
|
|
167
|
-
!i.trim() &&
|
|
168
|
-
p.filter((e) => !
|
|
167
|
+
!i.trim() && b.length > 0 && /* @__PURE__ */ a("div", { className: "Bear-CommandPalette__group-header bear-px-4 bear-py-2 bear-text-xs bear-font-medium bear-text-gray-500 dark:bear-text-zinc-500 bear-uppercase bear-tracking-wider bear-bg-gray-50 dark:bear-bg-zinc-800/50", children: _.allCommands }),
|
|
168
|
+
p.filter((e) => !s.includes(e.id) || i.trim()).map((e, r) => /* @__PURE__ */ a("div", { "data-command-item": !0, children: /* @__PURE__ */ a(
|
|
169
169
|
D,
|
|
170
170
|
{
|
|
171
171
|
command: e,
|
|
172
|
-
isHighlighted: n ===
|
|
173
|
-
onSelect: () =>
|
|
172
|
+
isHighlighted: n === b.length + r,
|
|
173
|
+
onSelect: () => x(e)
|
|
174
174
|
}
|
|
175
175
|
) }, e.id))
|
|
176
176
|
] })
|
|
177
177
|
] })
|
|
178
178
|
}
|
|
179
179
|
),
|
|
180
|
-
M && /* @__PURE__ */
|
|
180
|
+
M && /* @__PURE__ */ a("div", { className: "Bear-CommandPalette__footer bear-px-4 bear-py-2 bear-border-t bear-border-gray-200 dark:bear-border-zinc-700 bear-text-xs bear-text-gray-500 dark:bear-text-zinc-500", children: M })
|
|
181
181
|
] })
|
|
182
182
|
]
|
|
183
183
|
}
|
|
@@ -186,5 +186,5 @@ const D = ({
|
|
|
186
186
|
) : null;
|
|
187
187
|
};
|
|
188
188
|
export {
|
|
189
|
-
|
|
189
|
+
ce as CommandPalette
|
|
190
190
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),A=require("react"),D=require("../../utils/cn.cjs"),F=require("../Typography/Typography.cjs"),S=require("./DiffSquares.const.cjs"),E=require("./DiffSquares.utils.cjs"),N=({additionsText:n,deletionsText:t,cubeCount:c=S.DIFF_SQUARES_DEFAULT_COUNT,cubes:r,additionColor:m="var(--bear-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),A=require("react"),D=require("../../utils/cn.cjs"),F=require("../Typography/Typography.cjs"),S=require("./DiffSquares.const.cjs"),E=require("./DiffSquares.utils.cjs"),N=({additionsText:n,deletionsText:t,cubeCount:c=S.DIFF_SQUARES_DEFAULT_COUNT,cubes:r,additionColor:m="var(--bear-success-500, #22c55e)",deletionColor:q="var(--bear-danger-500, #ef4444)",gap:_=S.DIFF_SQUARES_GAP,summaryTypographyProps:s,onCubeClick:i,onCubeHover:e,className:h,testId:j,...x})=>{const d=A.useMemo(()=>r!=null&&r.length?r:Array.from({length:c},()=>({fill:"full"})),[r,c]),g={variant:"body2",component:"span",...s,className:D.cn("bear-flex bear-shrink-0 bear-items-baseline bear-gap-1.5 bear-font-mono bear-font-semibold",s==null?void 0:s.className)};return l.jsxs("div",{className:D.cn("Bear-DiffSquares bear-inline-flex bear-min-w-0 bear-max-w-full bear-items-center bear-gap-2",h),"data-testid":j,...x,children:[(n!=null||t!=null)&&l.jsxs(F.Typography,{...g,children:[n!=null&&l.jsx("span",{style:{color:m},children:n}),t!=null&&l.jsx("span",{style:{color:q},children:t})]}),l.jsx("span",{className:"bear-inline-flex bear-items-center bear-flex-shrink-0",style:{gap:_},role:"img","aria-label":"Change density",children:d.map((a,f)=>l.jsx("span",{className:S.DIFF_SQUARES_CUBE_CLASS,style:E.getDiffCubeStyle(a,m,q),"aria-hidden":!(a!=null&&a.ariaLabel),title:a==null?void 0:a.ariaLabel,onMouseEnter:()=>e==null?void 0:e(a,f),onMouseLeave:()=>e==null?void 0:e(null,null),onClick:()=>i==null?void 0:i(a,f)},f))})]})};exports.DiffSquares=N;
|
|
@@ -4,16 +4,16 @@ import { cn as A } from "../../utils/cn.js";
|
|
|
4
4
|
import { Typography as g } from "../Typography/Typography.js";
|
|
5
5
|
import { DIFF_SQUARES_DEFAULT_COUNT as p, DIFF_SQUARES_GAP as x, DIFF_SQUARES_CUBE_CLASS as I } from "./DiffSquares.const.js";
|
|
6
6
|
import { getDiffCubeStyle as M } from "./DiffSquares.utils.js";
|
|
7
|
-
const
|
|
8
|
-
additionsText:
|
|
9
|
-
deletionsText:
|
|
7
|
+
const G = ({
|
|
8
|
+
additionsText: t,
|
|
9
|
+
deletionsText: i,
|
|
10
10
|
cubeCount: m = p,
|
|
11
11
|
cubes: r,
|
|
12
|
-
additionColor: S = "var(--bear-
|
|
13
|
-
deletionColor: _ = "var(--bear-
|
|
12
|
+
additionColor: S = "var(--bear-success-500, #22c55e)",
|
|
13
|
+
deletionColor: _ = "var(--bear-danger-500, #ef4444)",
|
|
14
14
|
gap: D = x,
|
|
15
15
|
summaryTypographyProps: n,
|
|
16
|
-
onCubeClick:
|
|
16
|
+
onCubeClick: s,
|
|
17
17
|
onCubeHover: l,
|
|
18
18
|
className: F,
|
|
19
19
|
testId: E,
|
|
@@ -35,9 +35,9 @@ const B = ({
|
|
|
35
35
|
"data-testid": E,
|
|
36
36
|
...N,
|
|
37
37
|
children: [
|
|
38
|
-
(
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
(t != null || i != null) && /* @__PURE__ */ h(g, { ...d, children: [
|
|
39
|
+
t != null && /* @__PURE__ */ e("span", { style: { color: S }, children: t }),
|
|
40
|
+
i != null && /* @__PURE__ */ e("span", { style: { color: _ }, children: i })
|
|
41
41
|
] }),
|
|
42
42
|
/* @__PURE__ */ e(
|
|
43
43
|
"span",
|
|
@@ -55,7 +55,7 @@ const B = ({
|
|
|
55
55
|
title: a == null ? void 0 : a.ariaLabel,
|
|
56
56
|
onMouseEnter: () => l == null ? void 0 : l(a, f),
|
|
57
57
|
onMouseLeave: () => l == null ? void 0 : l(null, null),
|
|
58
|
-
onClick: () =>
|
|
58
|
+
onClick: () => s == null ? void 0 : s(a, f)
|
|
59
59
|
},
|
|
60
60
|
f
|
|
61
61
|
))
|
|
@@ -66,5 +66,5 @@ const B = ({
|
|
|
66
66
|
);
|
|
67
67
|
};
|
|
68
68
|
export {
|
|
69
|
-
|
|
69
|
+
G as DiffSquares
|
|
70
70
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("react"),D=require("react-dom"),R=require("../../context/BearProvider.cjs"),S=require("../../utils/cn.cjs"),p=require("../Icon/index.cjs"),r=require("./Drawer.const.cjs"),M=require("./Drawer.utils.cjs"),j=({isOpen:d,onClose:o,title:i,children:k,side:w="right",anchor:y,variant:O="temporary",size:N="md",showCloseButton:u=!0,closeOnBackdrop:_=!0,closeOnEscape:m=!0,className:A,container:E,id:q,testId:T})=>{const{direction:f}=R.useBearDirectionOptional(),l=y??w,n=f==="rtl"&&(l==="left"||l==="right")?l==="left"?"right":"left":l,[s,x]=t.useState(d),[v,c]=t.useState(!1),[g,h]=t.useState(!1);t.useEffect(()=>{if(d){x(!0),c(!1);const a=requestAnimationFrame(()=>h(!0));return()=>cancelAnimationFrame(a)}if(s){h(!1),c(!0);const a=setTimeout(()=>{x(!1),c(!1)},r.DRAWER_ANIMATION_MS);return()=>clearTimeout(a)}},[d,s]);const b=t.useCallback(a=>{m&&a.key==="Escape"&&o()},[m,o]);if(t.useEffect(()=>{if(s){document.addEventListener("keydown",b);const a=M.lockBodyScroll();return()=>{document.removeEventListener("keydown",b),a()}}return()=>{document.removeEventListener("keydown",b)}},[s,b]),!s)return null;const I=e.jsxs("div",{className:"bear-fixed bear-inset-0 bear-z-[11000]",children:[e.jsx("div",{className:S.cn("bear-absolute bear-inset-0 bear-bg-black/60 bear-backdrop-blur-sm bear-transition-opacity",v?"bear-opacity-0":"bear-opacity-100"),style:{transitionDuration:`${r.DRAWER_ANIMATION_MS}ms`},onClick:_?o:void 0,"aria-hidden":"true"}),e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":i?"drawer-title":void 0,className:S.cn("bear-absolute bear-bg-white dark:bear-bg-neutral-900 bear-shadow-2xl","bear-border-neutral-200 dark:bear-border-neutral-700","bear-flex bear-flex-col bear-overflow-hidden","bear-transform bear-transition-transform",r.BORDER_SIDE_MAP[n],r.POSITION_CLASSES[n],r.SIZE_CLASSES[n][N],g&&!v?r.TRANSFORM_OPEN[n]:r.TRANSFORM_CLOSED[n],A),style:{transitionDuration:`${r.DRAWER_ANIMATION_MS}ms`},children:[(i||u)&&e.jsxs("div",{className:"bear-flex bear-items-center bear-justify-between bear-px-4 bear-py-3 bear-border-b bear-border-neutral-200 dark:bear-border-neutral-700 bear-shrink-0",dir:f,children:[i&&e.jsx("h2",{id:"drawer-title",className:"bear-text-lg bear-font-semibold bear-text-neutral-900 dark:bear-text-white",children:i}),u&&e.jsx("button",{onClick:o,className:"bear-p-1 bear-rounded-lg bear-text-neutral-500 dark:bear-text-neutral-400 hover:bear-text-neutral-900 dark:hover:bear-text-white hover:bear-bg-neutral-100 dark:hover:bear-bg-neutral-700 bear-transition-colors","aria-label":"Close drawer",children:e.jsx(p.XIcon,{className:"bear-w-5 bear-h-5"})})]}),e.jsx("div",{className:"bear-flex-1 bear-min-h-0 bear-overflow-y-auto bear-overscroll-contain bear-p-4 bear-text-neutral-700 dark:bear-text-neutral-300",children:k})]})]});return D.createPortal(I,E??document.body)};exports.Drawer=j;
|
|
@@ -1,93 +1,94 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
1
|
+
import { jsxs as d, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useState as c, useEffect as x, useCallback as O } from "react";
|
|
3
3
|
import { createPortal as R } from "react-dom";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
import { useBearDirectionOptional as M } from "../../context/BearProvider.js";
|
|
5
|
+
import { cn as S } from "../../utils/cn.js";
|
|
6
|
+
import { XIcon as C } from "../Icon/index.js";
|
|
7
|
+
import { DRAWER_ANIMATION_MS as u, TRANSFORM_OPEN as L, TRANSFORM_CLOSED as T, SIZE_CLASSES as F, POSITION_CLASSES as P, BORDER_SIDE_MAP as j } from "./Drawer.const.js";
|
|
8
|
+
import { lockBodyScroll as B } from "./Drawer.utils.js";
|
|
9
|
+
const U = ({
|
|
10
|
+
isOpen: s,
|
|
10
11
|
onClose: o,
|
|
11
12
|
title: n,
|
|
12
|
-
children:
|
|
13
|
+
children: w,
|
|
13
14
|
side: y = "right",
|
|
14
|
-
anchor:
|
|
15
|
-
variant:
|
|
16
|
-
size:
|
|
17
|
-
showCloseButton:
|
|
18
|
-
closeOnBackdrop:
|
|
19
|
-
closeOnEscape:
|
|
20
|
-
className:
|
|
21
|
-
container:
|
|
22
|
-
id:
|
|
23
|
-
testId:
|
|
15
|
+
anchor: N,
|
|
16
|
+
variant: $ = "temporary",
|
|
17
|
+
size: g = "md",
|
|
18
|
+
showCloseButton: m = !0,
|
|
19
|
+
closeOnBackdrop: E = !0,
|
|
20
|
+
closeOnEscape: f = !0,
|
|
21
|
+
className: I,
|
|
22
|
+
container: _,
|
|
23
|
+
id: q,
|
|
24
|
+
testId: z
|
|
24
25
|
}) => {
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
if (
|
|
28
|
-
|
|
29
|
-
const e = requestAnimationFrame(() =>
|
|
26
|
+
const { direction: h } = M(), i = N ?? y, r = h === "rtl" && (i === "left" || i === "right") ? i === "left" ? "right" : "left" : i, [a, v] = c(s), [k, b] = c(!1), [A, p] = c(!1);
|
|
27
|
+
x(() => {
|
|
28
|
+
if (s) {
|
|
29
|
+
v(!0), b(!1);
|
|
30
|
+
const e = requestAnimationFrame(() => p(!0));
|
|
30
31
|
return () => cancelAnimationFrame(e);
|
|
31
32
|
}
|
|
32
33
|
if (a) {
|
|
33
|
-
|
|
34
|
+
p(!1), b(!0);
|
|
34
35
|
const e = setTimeout(() => {
|
|
35
|
-
|
|
36
|
-
},
|
|
36
|
+
v(!1), b(!1);
|
|
37
|
+
}, u);
|
|
37
38
|
return () => clearTimeout(e);
|
|
38
39
|
}
|
|
39
|
-
}, [
|
|
40
|
-
const
|
|
40
|
+
}, [s, a]);
|
|
41
|
+
const l = O(
|
|
41
42
|
(e) => {
|
|
42
|
-
|
|
43
|
+
f && e.key === "Escape" && o();
|
|
43
44
|
},
|
|
44
|
-
[
|
|
45
|
+
[f, o]
|
|
45
46
|
);
|
|
46
|
-
if (
|
|
47
|
+
if (x(() => {
|
|
47
48
|
if (a) {
|
|
48
|
-
document.addEventListener("keydown",
|
|
49
|
-
const e =
|
|
49
|
+
document.addEventListener("keydown", l);
|
|
50
|
+
const e = B();
|
|
50
51
|
return () => {
|
|
51
|
-
document.removeEventListener("keydown",
|
|
52
|
+
document.removeEventListener("keydown", l), e();
|
|
52
53
|
};
|
|
53
54
|
}
|
|
54
55
|
return () => {
|
|
55
|
-
document.removeEventListener("keydown",
|
|
56
|
+
document.removeEventListener("keydown", l);
|
|
56
57
|
};
|
|
57
|
-
}, [a,
|
|
58
|
-
const
|
|
58
|
+
}, [a, l]), !a) return null;
|
|
59
|
+
const D = /* @__PURE__ */ d("div", { className: "bear-fixed bear-inset-0 bear-z-[11000]", children: [
|
|
59
60
|
/* @__PURE__ */ t(
|
|
60
61
|
"div",
|
|
61
62
|
{
|
|
62
|
-
className:
|
|
63
|
+
className: S(
|
|
63
64
|
"bear-absolute bear-inset-0 bear-bg-black/60 bear-backdrop-blur-sm bear-transition-opacity",
|
|
64
|
-
|
|
65
|
+
k ? "bear-opacity-0" : "bear-opacity-100"
|
|
65
66
|
),
|
|
66
|
-
style: { transitionDuration: `${
|
|
67
|
-
onClick:
|
|
67
|
+
style: { transitionDuration: `${u}ms` },
|
|
68
|
+
onClick: E ? o : void 0,
|
|
68
69
|
"aria-hidden": "true"
|
|
69
70
|
}
|
|
70
71
|
),
|
|
71
|
-
/* @__PURE__ */
|
|
72
|
+
/* @__PURE__ */ d(
|
|
72
73
|
"div",
|
|
73
74
|
{
|
|
74
75
|
role: "dialog",
|
|
75
76
|
"aria-modal": "true",
|
|
76
77
|
"aria-labelledby": n ? "drawer-title" : void 0,
|
|
77
|
-
className:
|
|
78
|
+
className: S(
|
|
78
79
|
"bear-absolute bear-bg-white dark:bear-bg-neutral-900 bear-shadow-2xl",
|
|
79
80
|
"bear-border-neutral-200 dark:bear-border-neutral-700",
|
|
80
81
|
"bear-flex bear-flex-col bear-overflow-hidden",
|
|
81
82
|
"bear-transform bear-transition-transform",
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
j[r],
|
|
84
|
+
P[r],
|
|
85
|
+
F[r][g],
|
|
86
|
+
A && !k ? L[r] : T[r],
|
|
87
|
+
I
|
|
87
88
|
),
|
|
88
|
-
style: { transitionDuration: `${
|
|
89
|
+
style: { transitionDuration: `${u}ms` },
|
|
89
90
|
children: [
|
|
90
|
-
(n ||
|
|
91
|
+
(n || m) && /* @__PURE__ */ d("div", { className: "bear-flex bear-items-center bear-justify-between bear-px-4 bear-py-3 bear-border-b bear-border-neutral-200 dark:bear-border-neutral-700 bear-shrink-0", dir: h, children: [
|
|
91
92
|
n && /* @__PURE__ */ t(
|
|
92
93
|
"h2",
|
|
93
94
|
{
|
|
@@ -96,23 +97,23 @@ const G = ({
|
|
|
96
97
|
children: n
|
|
97
98
|
}
|
|
98
99
|
),
|
|
99
|
-
|
|
100
|
+
m && /* @__PURE__ */ t(
|
|
100
101
|
"button",
|
|
101
102
|
{
|
|
102
103
|
onClick: o,
|
|
103
104
|
className: "bear-p-1 bear-rounded-lg bear-text-neutral-500 dark:bear-text-neutral-400 hover:bear-text-neutral-900 dark:hover:bear-text-white hover:bear-bg-neutral-100 dark:hover:bear-bg-neutral-700 bear-transition-colors",
|
|
104
105
|
"aria-label": "Close drawer",
|
|
105
|
-
children: /* @__PURE__ */ t(
|
|
106
|
+
children: /* @__PURE__ */ t(C, { className: "bear-w-5 bear-h-5" })
|
|
106
107
|
}
|
|
107
108
|
)
|
|
108
109
|
] }),
|
|
109
|
-
/* @__PURE__ */ t("div", { className: "bear-flex-1 bear-min-h-0 bear-overflow-y-auto bear-overscroll-contain bear-p-4 bear-text-neutral-700 dark:bear-text-neutral-300", children:
|
|
110
|
+
/* @__PURE__ */ t("div", { className: "bear-flex-1 bear-min-h-0 bear-overflow-y-auto bear-overscroll-contain bear-p-4 bear-text-neutral-700 dark:bear-text-neutral-300", children: w })
|
|
110
111
|
]
|
|
111
112
|
}
|
|
112
113
|
)
|
|
113
114
|
] });
|
|
114
|
-
return R(
|
|
115
|
+
return R(D, _ ?? document.body);
|
|
115
116
|
};
|
|
116
117
|
export {
|
|
117
|
-
|
|
118
|
+
U as Drawer
|
|
118
119
|
};
|