@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
|
@@ -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"),s=require("react"),h=require("../../utils/cn.cjs"),o=require("./Spotlight.const.cjs"),m=require("./Spotlight.utils.cjs"),U=N=>{const{actions:g,open:E,onOpenChange:x,placeholder:B=o.DEFAULT_PLACEHOLDER,shortcutKey:k=o.DEFAULT_SHORTCUT_KEY,shortcutMod:_=!0,nothingFoundMessage:T=o.DEFAULT_NOTHING_FOUND,highlightMatches:v=!0,limit:p=o.DEFAULT_LIMIT,filter:u,className:D,style:C,testId:I}=N,[L,A]=s.useState(!1),[b,S]=s.useState(""),[d,c]=s.useState(0),j=s.useRef(null),w=s.useRef(null),n=E??L,l=s.useCallback(e=>{A(e),x==null||x(e),e||(S(""),c(0))},[x]);s.useEffect(()=>{const e=a=>{(_?a.metaKey||a.ctrlKey:!0)&&a.key.toLowerCase()===k.toLowerCase()&&(a.preventDefault(),l(!n)),a.key==="Escape"&&n&&l(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[k,_,n,l]),s.useEffect(()=>{n&&setTimeout(()=>{var e;return(e=j.current)==null?void 0:e.focus()},o.FOCUS_DELAY)},[n]);const i=s.useMemo(()=>u?u(b,g).slice(0,p):b?g.filter(e=>m.matchAction(e,b)).slice(0,p):g.slice(0,p),[g,b,u,p]),M=s.useMemo(()=>{const e=new Map;return i.forEach(a=>{const t=a.group||"";e.has(t)||e.set(t,[]),e.get(t).push(a)}),e},[i]),O=s.useCallback(e=>{if(e.key==="ArrowDown")e.preventDefault(),c(a=>Math.min(a+1,i.length-1));else if(e.key==="ArrowUp")e.preventDefault(),c(a=>Math.max(a-1,0));else if(e.key==="Enter"&&i[d]){e.preventDefault();const a=i[d];a.disabled||(a.onTrigger(),l(!1))}},[i,d,l]);if(s.useEffect(()=>{const e=w.current;if(!e)return;const a=e.querySelector('[data-active="true"]');a==null||a.scrollIntoView({block:"nearest"})},[d]),!n)return null;let y=-1;return r.jsxs("div",{className:h.cn("Bear-Spotlight","bear-fixed bear-inset-0 bear-flex bear-items-start bear-justify-center bear-pt-[15vh]"),style:{zIndex:o.SPOTLIGHT_Z_INDEX},"data-testid":I,children:[r.jsx("div",{className:"Bear-Spotlight__backdrop bear-absolute bear-inset-0 bear-bg-black/50 dark:bear-bg-black/70 bear-backdrop-blur-sm",onClick:()=>l(!1),"aria-hidden":"true"}),r.jsxs("div",{className:h.cn("Bear-Spotlight__dialog","bear-relative bear-w-full bear-max-w-[560px] bear-mx-4","bear-bg-white dark:bear-bg-gray-900","bear-rounded-xl bear-shadow-2xl","bear-border bear-border-gray-200 dark:bear-border-gray-700","bear-overflow-hidden",D),style:C,role:"dialog","aria-label":"Search",children:[r.jsxs("div",{className:"Bear-Spotlight__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-gray-700",children:[r.jsxs("svg",{width:20,height:20,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,className:"bear-text-gray-400 dark:bear-text-gray-500 bear-shrink-0",children:[r.jsx("circle",{cx:"11",cy:"11",r:"8"}),r.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),r.jsx("input",{ref:j,type:"text",value:b,onChange:e=>{S(e.target.value),c(0)},onKeyDown:O,placeholder:B,className:h.cn("Bear-Spotlight__input","bear-flex-1 bear-bg-transparent bear-outline-none bear-text-base","bear-text-gray-900 dark:bear-text-white","placeholder:bear-text-gray-400 dark:placeholder:bear-text-gray-500"),autoComplete:"off",spellCheck:!1}),r.jsx("kbd",{className:"bear-hidden sm:bear-inline-flex bear-items-center bear-px-1.5 bear-py-0.5 bear-rounded bear-text-[10px] bear-font-mono bear-text-gray-400 dark:bear-text-gray-500 bear-bg-gray-100 dark:bear-bg-gray-800 bear-border bear-border-gray-200 dark:bear-border-gray-700",children:"ESC"})]}),r.jsxs("div",{ref:w,className:"Bear-Spotlight__results bear-max-h-[400px] bear-overflow-y-auto bear-py-2",role:"listbox",children:[i.length===0&&r.jsx("div",{className:"Bear-Spotlight__empty bear-px-4 bear-py-8 bear-text-center bear-text-gray-500 dark:bear-text-gray-400 bear-text-sm",children:T}),Array.from(M.entries()).map(([e,a])=>r.jsxs("div",{className:"Bear-Spotlight__group",children:[e&&r.jsx("div",{className:"Bear-Spotlight__group-title bear-px-4 bear-py-1.5 bear-text-xs bear-font-semibold bear-uppercase bear-tracking-wider bear-text-gray-400 dark:bear-text-gray-500",children:e}),a.map(t=>{y++;const f=y===d,R=y;return r.jsxs("button",{className:h.cn("Bear-Spotlight__action","bear-w-full bear-flex bear-items-center bear-gap-3 bear-px-4 bear-py-2.5 bear-text-left bear-cursor-pointer","bear-transition-colors bear-duration-100",f?"bear-bg-gray-100 dark:bear-bg-gray-800":"hover:bear-bg-gray-50 dark:hover:bear-bg-gray-800/50",t.disabled&&"bear-opacity-50 bear-cursor-not-allowed"),"data-active":f,onMouseEnter:()=>c(R),onClick:()=>{t.disabled||(t.onTrigger(),l(!1))},role:"option","aria-selected":f,"aria-disabled":t.disabled,children:[t.icon&&r.jsx("span",{className:"Bear-Spotlight__action-icon bear-text-gray-500 dark:bear-text-gray-400 bear-shrink-0",children:t.icon}),r.jsxs("div",{className:"Bear-Spotlight__action-body bear-flex-1 bear-min-w-0",children:[r.jsx("div",{className:"Bear-Spotlight__action-label bear-text-sm bear-font-medium bear-text-gray-900 dark:bear-text-white bear-truncate",children:v?m.highlightText(t.label,b):t.label}),t.description&&r.jsx("div",{className:"Bear-Spotlight__action-desc bear-text-xs bear-text-gray-500 dark:bear-text-gray-400 bear-truncate",children:v?m.highlightText(t.description,b):t.description})]}),t.rightSection&&r.jsx("span",{className:"Bear-Spotlight__action-right bear-shrink-0",children:t.rightSection})]},t.id)})]},e))]}),r.jsxs("div",{className:"Bear-Spotlight__footer bear-border-t bear-border-gray-200 dark:bear-border-gray-700 bear-px-4 bear-py-2 bear-flex bear-items-center bear-gap-4 bear-text-[11px] bear-text-gray-400 dark:bear-text-gray-500",children:[r.jsxs("span",{className:"bear-flex bear-items-center bear-gap-1",children:[r.jsx("kbd",{className:"bear-px-1 bear-rounded bear-bg-gray-100 dark:bear-bg-gray-800 bear-border bear-border-gray-200 dark:bear-border-gray-700",children:"↑↓"}),"navigate"]}),r.jsxs("span",{className:"bear-flex bear-items-center bear-gap-1",children:[r.jsx("kbd",{className:"bear-px-1 bear-rounded bear-bg-gray-100 dark:bear-bg-gray-800 bear-border bear-border-gray-200 dark:bear-border-gray-700",children:"↵"}),"select"]}),r.jsxs("span",{className:"bear-flex bear-items-center bear-gap-1",children:[r.jsx("kbd",{className:"bear-px-1 bear-rounded bear-bg-gray-100 dark:bear-bg-gray-800 bear-border bear-border-gray-200 dark:bear-border-gray-700",children:"esc"}),"close"]})]})]})]})};exports.Spotlight=U;
|
|
@@ -1,100 +1,89 @@
|
|
|
1
|
-
import { jsxs as b, jsx as t
|
|
2
|
-
import { useState as
|
|
3
|
-
import { cn as
|
|
4
|
-
import { DEFAULT_PLACEHOLDER as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const i = s.toLowerCase();
|
|
8
|
-
return !!(l.label.toLowerCase().includes(i) || (o = l.description) != null && o.toLowerCase().includes(i) || (u = l.keywords) != null && u.some((y) => y.toLowerCase().includes(i)));
|
|
9
|
-
}, I = (l, s) => {
|
|
10
|
-
if (!s) return l;
|
|
11
|
-
const i = l.toLowerCase().indexOf(s.toLowerCase());
|
|
12
|
-
return i === -1 ? l : /* @__PURE__ */ b(G, { children: [
|
|
13
|
-
l.slice(0, i),
|
|
14
|
-
/* @__PURE__ */ t("mark", { className: "Bear-Spotlight__highlight bear-bg-yellow-200 dark:bear-bg-yellow-800 bear-text-inherit bear-rounded-sm bear-px-0.5", children: l.slice(i, i + s.length) }),
|
|
15
|
-
l.slice(i + s.length)
|
|
16
|
-
] });
|
|
17
|
-
}, ee = (l) => {
|
|
1
|
+
import { jsxs as b, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useState as u, useRef as B, useCallback as E, useEffect as f, useMemo as D } from "react";
|
|
3
|
+
import { cn as h } from "../../utils/cn.js";
|
|
4
|
+
import { DEFAULT_PLACEHOLDER as q, DEFAULT_SHORTCUT_KEY as G, DEFAULT_NOTHING_FOUND as P, DEFAULT_LIMIT as Y, FOCUS_DELAY as z, SPOTLIGHT_Z_INDEX as Q } from "./Spotlight.const.js";
|
|
5
|
+
import { matchAction as V, highlightText as T } from "./Spotlight.utils.js";
|
|
6
|
+
const ee = (I) => {
|
|
18
7
|
const {
|
|
19
|
-
actions:
|
|
20
|
-
open:
|
|
21
|
-
onOpenChange:
|
|
22
|
-
placeholder:
|
|
23
|
-
shortcutKey:
|
|
24
|
-
shortcutMod:
|
|
25
|
-
nothingFoundMessage:
|
|
26
|
-
highlightMatches:
|
|
27
|
-
limit:
|
|
28
|
-
filter:
|
|
8
|
+
actions: c,
|
|
9
|
+
open: L,
|
|
10
|
+
onOpenChange: g,
|
|
11
|
+
placeholder: A = q,
|
|
12
|
+
shortcutKey: k = G,
|
|
13
|
+
shortcutMod: _ = !0,
|
|
14
|
+
nothingFoundMessage: C = P,
|
|
15
|
+
highlightMatches: v = !0,
|
|
16
|
+
limit: p = Y,
|
|
17
|
+
filter: y,
|
|
29
18
|
className: O,
|
|
30
19
|
style: M,
|
|
31
|
-
testId:
|
|
32
|
-
} =
|
|
20
|
+
testId: U
|
|
21
|
+
} = I, [F, K] = u(!1), [l, w] = u(""), [n, d] = u(0), N = B(null), S = B(null), o = L ?? F, s = E(
|
|
33
22
|
(e) => {
|
|
34
|
-
K(e),
|
|
23
|
+
K(e), g == null || g(e), e || (w(""), d(0));
|
|
35
24
|
},
|
|
36
|
-
[
|
|
25
|
+
[g]
|
|
37
26
|
);
|
|
38
|
-
|
|
27
|
+
f(() => {
|
|
39
28
|
const e = (r) => {
|
|
40
|
-
(
|
|
29
|
+
(_ ? r.metaKey || r.ctrlKey : !0) && r.key.toLowerCase() === k.toLowerCase() && (r.preventDefault(), s(!o)), r.key === "Escape" && o && s(!1);
|
|
41
30
|
};
|
|
42
31
|
return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
43
|
-
}, [
|
|
44
|
-
|
|
32
|
+
}, [k, _, o, s]), f(() => {
|
|
33
|
+
o && setTimeout(() => {
|
|
45
34
|
var e;
|
|
46
|
-
return (e =
|
|
47
|
-
},
|
|
48
|
-
}, [
|
|
49
|
-
const
|
|
35
|
+
return (e = N.current) == null ? void 0 : e.focus();
|
|
36
|
+
}, z);
|
|
37
|
+
}, [o]);
|
|
38
|
+
const i = D(() => y ? y(l, c).slice(0, p) : l ? c.filter((e) => V(e, l)).slice(0, p) : c.slice(0, p), [c, l, y, p]), R = D(() => {
|
|
50
39
|
const e = /* @__PURE__ */ new Map();
|
|
51
|
-
return
|
|
40
|
+
return i.forEach((r) => {
|
|
52
41
|
const a = r.group || "";
|
|
53
42
|
e.has(a) || e.set(a, []), e.get(a).push(r);
|
|
54
43
|
}), e;
|
|
55
|
-
}, [
|
|
44
|
+
}, [i]), H = E(
|
|
56
45
|
(e) => {
|
|
57
46
|
if (e.key === "ArrowDown")
|
|
58
|
-
e.preventDefault(),
|
|
47
|
+
e.preventDefault(), d((r) => Math.min(r + 1, i.length - 1));
|
|
59
48
|
else if (e.key === "ArrowUp")
|
|
60
|
-
e.preventDefault(),
|
|
61
|
-
else if (e.key === "Enter" &&
|
|
49
|
+
e.preventDefault(), d((r) => Math.max(r - 1, 0));
|
|
50
|
+
else if (e.key === "Enter" && i[n]) {
|
|
62
51
|
e.preventDefault();
|
|
63
|
-
const r =
|
|
64
|
-
r.disabled || (r.onTrigger(),
|
|
52
|
+
const r = i[n];
|
|
53
|
+
r.disabled || (r.onTrigger(), s(!1));
|
|
65
54
|
}
|
|
66
55
|
},
|
|
67
|
-
[
|
|
56
|
+
[i, n, s]
|
|
68
57
|
);
|
|
69
|
-
if (
|
|
70
|
-
const e =
|
|
58
|
+
if (f(() => {
|
|
59
|
+
const e = S.current;
|
|
71
60
|
if (!e) return;
|
|
72
61
|
const r = e.querySelector('[data-active="true"]');
|
|
73
62
|
r == null || r.scrollIntoView({ block: "nearest" });
|
|
74
|
-
}, [
|
|
75
|
-
let
|
|
63
|
+
}, [n]), !o) return null;
|
|
64
|
+
let x = -1;
|
|
76
65
|
return /* @__PURE__ */ b(
|
|
77
66
|
"div",
|
|
78
67
|
{
|
|
79
|
-
className:
|
|
68
|
+
className: h(
|
|
80
69
|
"Bear-Spotlight",
|
|
81
70
|
"bear-fixed bear-inset-0 bear-flex bear-items-start bear-justify-center bear-pt-[15vh]"
|
|
82
71
|
),
|
|
83
|
-
style: { zIndex:
|
|
84
|
-
"data-testid":
|
|
72
|
+
style: { zIndex: Q },
|
|
73
|
+
"data-testid": U,
|
|
85
74
|
children: [
|
|
86
75
|
/* @__PURE__ */ t(
|
|
87
76
|
"div",
|
|
88
77
|
{
|
|
89
78
|
className: "Bear-Spotlight__backdrop bear-absolute bear-inset-0 bear-bg-black/50 dark:bear-bg-black/70 bear-backdrop-blur-sm",
|
|
90
|
-
onClick: () =>
|
|
79
|
+
onClick: () => s(!1),
|
|
91
80
|
"aria-hidden": "true"
|
|
92
81
|
}
|
|
93
82
|
),
|
|
94
83
|
/* @__PURE__ */ b(
|
|
95
84
|
"div",
|
|
96
85
|
{
|
|
97
|
-
className:
|
|
86
|
+
className: h(
|
|
98
87
|
"Bear-Spotlight__dialog",
|
|
99
88
|
"bear-relative bear-w-full bear-max-w-[560px] bear-mx-4",
|
|
100
89
|
"bear-bg-white dark:bear-bg-gray-900",
|
|
@@ -127,15 +116,15 @@ const X = (l, s) => {
|
|
|
127
116
|
/* @__PURE__ */ t(
|
|
128
117
|
"input",
|
|
129
118
|
{
|
|
130
|
-
ref:
|
|
119
|
+
ref: N,
|
|
131
120
|
type: "text",
|
|
132
|
-
value:
|
|
121
|
+
value: l,
|
|
133
122
|
onChange: (e) => {
|
|
134
|
-
|
|
123
|
+
w(e.target.value), d(0);
|
|
135
124
|
},
|
|
136
125
|
onKeyDown: H,
|
|
137
|
-
placeholder:
|
|
138
|
-
className:
|
|
126
|
+
placeholder: A,
|
|
127
|
+
className: h(
|
|
139
128
|
"Bear-Spotlight__input",
|
|
140
129
|
"bear-flex-1 bear-bg-transparent bear-outline-none bear-text-base",
|
|
141
130
|
"bear-text-gray-900 dark:bear-text-white",
|
|
@@ -150,39 +139,39 @@ const X = (l, s) => {
|
|
|
150
139
|
/* @__PURE__ */ b(
|
|
151
140
|
"div",
|
|
152
141
|
{
|
|
153
|
-
ref:
|
|
142
|
+
ref: S,
|
|
154
143
|
className: "Bear-Spotlight__results bear-max-h-[400px] bear-overflow-y-auto bear-py-2",
|
|
155
144
|
role: "listbox",
|
|
156
145
|
children: [
|
|
157
|
-
|
|
146
|
+
i.length === 0 && /* @__PURE__ */ t("div", { className: "Bear-Spotlight__empty bear-px-4 bear-py-8 bear-text-center bear-text-gray-500 dark:bear-text-gray-400 bear-text-sm", children: C }),
|
|
158
147
|
Array.from(R.entries()).map(([e, r]) => /* @__PURE__ */ b("div", { className: "Bear-Spotlight__group", children: [
|
|
159
148
|
e && /* @__PURE__ */ t("div", { className: "Bear-Spotlight__group-title bear-px-4 bear-py-1.5 bear-text-xs bear-font-semibold bear-uppercase bear-tracking-wider bear-text-gray-400 dark:bear-text-gray-500", children: e }),
|
|
160
149
|
r.map((a) => {
|
|
161
|
-
|
|
162
|
-
const
|
|
150
|
+
x++;
|
|
151
|
+
const m = x === n, j = x;
|
|
163
152
|
return /* @__PURE__ */ b(
|
|
164
153
|
"button",
|
|
165
154
|
{
|
|
166
|
-
className:
|
|
155
|
+
className: h(
|
|
167
156
|
"Bear-Spotlight__action",
|
|
168
157
|
"bear-w-full bear-flex bear-items-center bear-gap-3 bear-px-4 bear-py-2.5 bear-text-left bear-cursor-pointer",
|
|
169
158
|
"bear-transition-colors bear-duration-100",
|
|
170
|
-
|
|
159
|
+
m ? "bear-bg-gray-100 dark:bear-bg-gray-800" : "hover:bear-bg-gray-50 dark:hover:bear-bg-gray-800/50",
|
|
171
160
|
a.disabled && "bear-opacity-50 bear-cursor-not-allowed"
|
|
172
161
|
),
|
|
173
|
-
"data-active":
|
|
174
|
-
onMouseEnter: () =>
|
|
162
|
+
"data-active": m,
|
|
163
|
+
onMouseEnter: () => d(j),
|
|
175
164
|
onClick: () => {
|
|
176
|
-
a.disabled || (a.onTrigger(),
|
|
165
|
+
a.disabled || (a.onTrigger(), s(!1));
|
|
177
166
|
},
|
|
178
167
|
role: "option",
|
|
179
|
-
"aria-selected":
|
|
168
|
+
"aria-selected": m,
|
|
180
169
|
"aria-disabled": a.disabled,
|
|
181
170
|
children: [
|
|
182
171
|
a.icon && /* @__PURE__ */ t("span", { className: "Bear-Spotlight__action-icon bear-text-gray-500 dark:bear-text-gray-400 bear-shrink-0", children: a.icon }),
|
|
183
172
|
/* @__PURE__ */ b("div", { className: "Bear-Spotlight__action-body bear-flex-1 bear-min-w-0", children: [
|
|
184
|
-
/* @__PURE__ */ t("div", { className: "Bear-Spotlight__action-label bear-text-sm bear-font-medium bear-text-gray-900 dark:bear-text-white bear-truncate", children:
|
|
185
|
-
a.description && /* @__PURE__ */ t("div", { className: "Bear-Spotlight__action-desc bear-text-xs bear-text-gray-500 dark:bear-text-gray-400 bear-truncate", children:
|
|
173
|
+
/* @__PURE__ */ t("div", { className: "Bear-Spotlight__action-label bear-text-sm bear-font-medium bear-text-gray-900 dark:bear-text-white bear-truncate", children: v ? T(a.label, l) : a.label }),
|
|
174
|
+
a.description && /* @__PURE__ */ t("div", { className: "Bear-Spotlight__action-desc bear-text-xs bear-text-gray-500 dark:bear-text-gray-400 bear-truncate", children: v ? T(a.description, l) : a.description })
|
|
186
175
|
] }),
|
|
187
176
|
a.rightSection && /* @__PURE__ */ t("span", { className: "Bear-Spotlight__action-right bear-shrink-0", children: a.rightSection })
|
|
188
177
|
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),l=(e,t)=>{var s,o;const r=t.toLowerCase();return!!(e.label.toLowerCase().includes(r)||(s=e.description)!=null&&s.toLowerCase().includes(r)||(o=e.keywords)!=null&&o.some(n=>n.toLowerCase().includes(r)))},a=(e,t)=>{if(!t)return e;const r=e.toLowerCase().indexOf(t.toLowerCase());return r===-1?e:i.jsxs(i.Fragment,{children:[e.slice(0,r),i.jsx("mark",{className:"Bear-Spotlight__highlight bear-bg-yellow-200 dark:bear-bg-yellow-800 bear-text-inherit bear-rounded-sm bear-px-0.5",children:e.slice(r,r+t.length)}),e.slice(r+t.length)]})};exports.highlightText=a;exports.matchAction=l;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsxs as n, Fragment as l, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
const h = (e, s) => {
|
|
3
|
+
var o, i;
|
|
4
|
+
const r = s.toLowerCase();
|
|
5
|
+
return !!(e.label.toLowerCase().includes(r) || (o = e.description) != null && o.toLowerCase().includes(r) || (i = e.keywords) != null && i.some((t) => t.toLowerCase().includes(r)));
|
|
6
|
+
}, d = (e, s) => {
|
|
7
|
+
if (!s) return e;
|
|
8
|
+
const r = e.toLowerCase().indexOf(s.toLowerCase());
|
|
9
|
+
return r === -1 ? e : /* @__PURE__ */ n(l, { children: [
|
|
10
|
+
e.slice(0, r),
|
|
11
|
+
/* @__PURE__ */ a("mark", { className: "Bear-Spotlight__highlight bear-bg-yellow-200 dark:bear-bg-yellow-800 bear-text-inherit bear-rounded-sm bear-px-0.5", children: e.slice(r, r + s.length) }),
|
|
12
|
+
e.slice(r + s.length)
|
|
13
|
+
] });
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
d as highlightText,
|
|
17
|
+
h as matchAction
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),l=require("react"),x=require("../../utils/cn.cjs"),C=require("../Dropdown/Dropdown.cjs"),j=require("../Icon/index.cjs"),q=require("./Tabs.cjs");function k(a){var o;return l.isValidElement(a)&&typeof a.type!="string"&&((o=a.props)==null?void 0:o.id)!=null}const E=({children:a,maxVisibleTabs:o,wrap:y=!1,className:f})=>{const u=l.useContext(q.TabsContext);if(!u)throw new Error("TabList must be used within Tabs");const{activeTab:s,setActiveTab:g,variant:t}=u,m=l.Children.toArray(a).filter(k),i=m.map(e=>({id:e.props.id,label:e.props.children,disabled:e.props.disabled})),b=s?[s,...i.map(e=>e.id).filter(e=>e!==s)]:i.map(e=>e.id),v=o??b.length,T=b.slice(0,v),c=b.slice(v),d=c.includes(s),h=x.cn("Bear-Tabs__list",`Bear-Tabs__list--${t}`,"bear-flex bear-gap-1",y&&"bear-flex-wrap",t==="line"&&"bear-border-b",t==="pills"&&"bear-p-1 bear-rounded-lg",t==="enclosed"&&"bear-border-b",f),w={...t==="line"||t==="enclosed"?{borderColor:"var(--bear-border-default)"}:{},...t==="pills"?{backgroundColor:"var(--bear-bg-tertiary)"}:{}};return n.jsxs("div",{role:"tablist",className:h,style:w,children:[o!=null?T.map(e=>{const r=m.find(p=>p.props.id===e);return r?l.cloneElement(r,{key:r.props.id}):null}):a,o!=null&&c.length>0&&n.jsx(C.Dropdown,{placement:"bottom-start",closeOnSelect:!0,trigger:n.jsx("button",{type:"button",role:"tab","aria-haspopup":"listbox","aria-label":"More tabs",className:x.cn("bear-flex bear-items-center bear-gap-2 bear-px-4 bear-py-2 bear-text-sm bear-font-medium bear-transition-colors bear-border-0 bear-cursor-pointer",t==="pills"&&"bear-rounded-md",d&&"bear-shadow-sm",!d&&"hover:bear-bg-[var(--bear-bg-tertiary)] hover:bear-text-[var(--bear-text-primary)]"),style:d?{backgroundColor:"var(--bear-bg-primary)",color:"var(--bear-text-primary)"}:{color:"var(--bear-text-muted)"},children:n.jsx(j.BearIcons.MoreHorizIcon,{size:18})}),items:c.map(e=>{const r=i.find(p=>p.id===e);return{key:e,label:(r==null?void 0:r.label)??e,disabled:r==null?void 0:r.disabled,onClick:()=>g(e)}})})]})};exports.TabList=E;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { jsxs as w, jsx as d } from "react/jsx-runtime";
|
|
2
|
+
import { useContext as T, Children as k, cloneElement as E, isValidElement as I } from "react";
|
|
3
|
+
import { cn as f } from "../../utils/cn.js";
|
|
4
|
+
import { Dropdown as _ } from "../Dropdown/Dropdown.js";
|
|
5
|
+
import { BearIcons as A } from "../Icon/index.js";
|
|
6
|
+
import { TabsContext as B } from "./Tabs.js";
|
|
7
|
+
function M(o) {
|
|
8
|
+
var a;
|
|
9
|
+
return I(o) && typeof o.type != "string" && ((a = o.props) == null ? void 0 : a.id) != null;
|
|
10
|
+
}
|
|
11
|
+
const H = ({ children: o, maxVisibleTabs: a, wrap: v = !1, className: y }) => {
|
|
12
|
+
const c = T(B);
|
|
13
|
+
if (!c) throw new Error("TabList must be used within Tabs");
|
|
14
|
+
const { activeTab: s, setActiveTab: g, variant: t } = c, m = k.toArray(o).filter(M), l = m.map((e) => ({ id: e.props.id, label: e.props.children, disabled: e.props.disabled })), n = s ? [s, ...l.map((e) => e.id).filter((e) => e !== s)] : l.map((e) => e.id), u = a ?? n.length, x = n.slice(0, u), b = n.slice(u), i = b.includes(s), h = f(
|
|
15
|
+
"Bear-Tabs__list",
|
|
16
|
+
`Bear-Tabs__list--${t}`,
|
|
17
|
+
"bear-flex bear-gap-1",
|
|
18
|
+
v && "bear-flex-wrap",
|
|
19
|
+
t === "line" && "bear-border-b",
|
|
20
|
+
t === "pills" && "bear-p-1 bear-rounded-lg",
|
|
21
|
+
t === "enclosed" && "bear-border-b",
|
|
22
|
+
y
|
|
23
|
+
), C = {
|
|
24
|
+
...t === "line" || t === "enclosed" ? { borderColor: "var(--bear-border-default)" } : {},
|
|
25
|
+
...t === "pills" ? { backgroundColor: "var(--bear-bg-tertiary)" } : {}
|
|
26
|
+
};
|
|
27
|
+
return /* @__PURE__ */ w("div", { role: "tablist", className: h, style: C, children: [
|
|
28
|
+
a != null ? x.map((e) => {
|
|
29
|
+
const r = m.find((p) => p.props.id === e);
|
|
30
|
+
return r ? E(r, { key: r.props.id }) : null;
|
|
31
|
+
}) : o,
|
|
32
|
+
a != null && b.length > 0 && /* @__PURE__ */ d(
|
|
33
|
+
_,
|
|
34
|
+
{
|
|
35
|
+
placement: "bottom-start",
|
|
36
|
+
closeOnSelect: !0,
|
|
37
|
+
trigger: /* @__PURE__ */ d(
|
|
38
|
+
"button",
|
|
39
|
+
{
|
|
40
|
+
type: "button",
|
|
41
|
+
role: "tab",
|
|
42
|
+
"aria-haspopup": "listbox",
|
|
43
|
+
"aria-label": "More tabs",
|
|
44
|
+
className: f(
|
|
45
|
+
"bear-flex bear-items-center bear-gap-2 bear-px-4 bear-py-2 bear-text-sm bear-font-medium bear-transition-colors bear-border-0 bear-cursor-pointer",
|
|
46
|
+
t === "pills" && "bear-rounded-md",
|
|
47
|
+
i && "bear-shadow-sm",
|
|
48
|
+
!i && "hover:bear-bg-[var(--bear-bg-tertiary)] hover:bear-text-[var(--bear-text-primary)]"
|
|
49
|
+
),
|
|
50
|
+
style: i ? { backgroundColor: "var(--bear-bg-primary)", color: "var(--bear-text-primary)" } : { color: "var(--bear-text-muted)" },
|
|
51
|
+
children: /* @__PURE__ */ d(A.MoreHorizIcon, { size: 18 })
|
|
52
|
+
}
|
|
53
|
+
),
|
|
54
|
+
items: b.map((e) => {
|
|
55
|
+
const r = l.find((p) => p.id === e);
|
|
56
|
+
return {
|
|
57
|
+
key: e,
|
|
58
|
+
label: (r == null ? void 0 : r.label) ?? e,
|
|
59
|
+
disabled: r == null ? void 0 : r.disabled,
|
|
60
|
+
onClick: () => g(e)
|
|
61
|
+
};
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
)
|
|
65
|
+
] });
|
|
66
|
+
};
|
|
67
|
+
export {
|
|
68
|
+
H as TabList
|
|
69
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),o=require("react"),c=require("../../utils/cn.cjs"),i=require("./Tabs.cjs"),u=({tabId:t,children:n,className:r})=>{const e=o.useContext(i.TabsContext);if(!e)throw new Error("TabPanel must be used within Tabs");const{activeTab:a}=e;return a!==t?null:s.jsx("div",{role:"tabpanel",className:c.cn("Bear-Tabs__panel bear-py-4",r),children:n})};exports.TabPanel=u;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { useContext as s } from "react";
|
|
3
|
+
import { cn as i } from "../../utils/cn.js";
|
|
4
|
+
import { TabsContext as m } from "./Tabs.js";
|
|
5
|
+
const f = ({ tabId: r, children: e, className: o }) => {
|
|
6
|
+
const t = s(m);
|
|
7
|
+
if (!t) throw new Error("TabPanel must be used within Tabs");
|
|
8
|
+
const { activeTab: a } = t;
|
|
9
|
+
return a !== r ? null : /* @__PURE__ */ n("div", { role: "tabpanel", className: i("Bear-Tabs__panel bear-py-4", o), children: e });
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
f as TabPanel
|
|
13
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),m=require("react"),b=require("../../utils/cn.cjs"),x=m.createContext(null),T=({children:o,value:n,defaultTab:e,variant:c="line",onChange:a,className:l,testId:d})=>{const[t,r]=m.useState(e),i=n!==void 0,v=i?n:t,u=p=>{i||r(p),a==null||a(p)};return s.jsx(x.Provider,{value:{activeTab:v,setActiveTab:u,variant:c},children:s.jsx("div",{className:b.cn("Bear-Tabs",l),"data-testid":d,children:o})})},y=({id:o,children:n,disabled:e=!1,icon:c})=>{const a=m.useContext(x);if(!a)throw new Error("Tab must be used within Tabs");const{activeTab:l,setActiveTab:d,variant:t}=a,r=l===o,i="bear-flex bear-items-center bear-gap-2 bear-px-4 bear-py-2 bear-text-sm bear-font-medium bear-transition-colors",v={line:b.cn("bear-border-b-2 bear--mb-px",r?"bear-border-pink-500 bear-text-pink-600 dark:bear-text-pink-400":"bear-border-transparent hover:bear-border-[var(--bear-border-default)]"),pills:b.cn("bear-rounded-md",r&&"bear-shadow-sm"),enclosed:b.cn("bear-rounded-t-lg bear-border bear-border-transparent",r&&"bear--mb-px")},u=e?void 0:r?t==="pills"?{backgroundColor:"var(--bear-bg-primary)",color:"var(--bear-text-primary)"}:t==="enclosed"?{backgroundColor:"var(--bear-bg-primary)",borderColor:"var(--bear-border-default)",borderBottomColor:"var(--bear-bg-primary)",color:"var(--bear-text-primary)"}:void 0:{color:"var(--bear-text-muted)"};return s.jsxs("button",{role:"tab","aria-selected":r,disabled:e,onClick:()=>!e&&d(o),className:b.cn("Bear-Tabs__tab",r&&"Bear-Tabs__tab--active",i,v[t],!r&&"hover:bear-bg-[var(--bear-bg-tertiary)] hover:bear-text-[var(--bear-text-primary)]",e&&"Bear-Tabs__tab--disabled bear-opacity-50 bear-cursor-not-allowed"),style:u,children:[c&&s.jsx("span",{className:"Bear-Tabs__tab-icon",children:c}),s.jsx("span",{className:"Bear-Tabs__tab-label",children:n})]})};exports.Tab=y;exports.Tabs=T;exports.TabsContext=x;
|
|
@@ -1,30 +1,5 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
* Tabs - Tabbed interface for organizing content
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```tsx
|
|
8
|
-
* <Tabs defaultTab="tab1" variant="line">
|
|
9
|
-
* <TabList>
|
|
10
|
-
* <Tab id="tab1">Tab 1</Tab>
|
|
11
|
-
* <Tab id="tab2">Tab 2</Tab>
|
|
12
|
-
* </TabList>
|
|
13
|
-
* <TabPanel tabId="tab1">Content 1</TabPanel>
|
|
14
|
-
* <TabPanel tabId="tab2">Content 2</TabPanel>
|
|
15
|
-
* </Tabs>
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
2
|
+
import { TabsContextValue, TabsProps, TabProps } from './Tabs.types';
|
|
3
|
+
export declare const TabsContext: import('react').Context<TabsContextValue | null>;
|
|
18
4
|
export declare const Tabs: FC<TabsProps>;
|
|
19
|
-
/**
|
|
20
|
-
* TabList - Container for tab buttons
|
|
21
|
-
*/
|
|
22
|
-
export declare const TabList: FC<TabListProps>;
|
|
23
|
-
/**
|
|
24
|
-
* Tab - Individual tab button
|
|
25
|
-
*/
|
|
26
5
|
export declare const Tab: FC<TabProps>;
|
|
27
|
-
/**
|
|
28
|
-
* TabPanel - Content panel for a tab
|
|
29
|
-
*/
|
|
30
|
-
export declare const TabPanel: FC<TabPanelProps>;
|
|
@@ -1,84 +1,66 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { cn as
|
|
4
|
-
const
|
|
5
|
-
children:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { jsxs as u, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as T, useContext as y, useState as f } from "react";
|
|
3
|
+
import { cn as b } from "../../utils/cn.js";
|
|
4
|
+
const x = T(null), C = ({
|
|
5
|
+
children: o,
|
|
6
|
+
value: s,
|
|
7
|
+
defaultTab: e,
|
|
8
|
+
variant: n = "line",
|
|
9
|
+
onChange: a,
|
|
10
|
+
className: c,
|
|
11
|
+
testId: d
|
|
11
12
|
}) => {
|
|
12
|
-
const [
|
|
13
|
-
|
|
13
|
+
const [t, r] = f(e), i = s !== void 0, m = i ? s : t, v = (p) => {
|
|
14
|
+
i || r(p), a == null || a(p);
|
|
14
15
|
};
|
|
15
|
-
return /* @__PURE__ */
|
|
16
|
-
},
|
|
17
|
-
const
|
|
18
|
-
if (!
|
|
19
|
-
const { variant:
|
|
20
|
-
|
|
21
|
-
"div",
|
|
22
|
-
{
|
|
23
|
-
role: "tablist",
|
|
24
|
-
className: s(
|
|
25
|
-
"Bear-Tabs__list",
|
|
26
|
-
`Bear-Tabs__list--${r}`,
|
|
27
|
-
"bear-flex bear-gap-1",
|
|
28
|
-
r === "line" && "bear-border-b bear-border-gray-200 dark:bear-border-gray-700",
|
|
29
|
-
r === "pills" && "bear-bg-gray-100 dark:bear-bg-gray-800 bear-p-1 bear-rounded-lg",
|
|
30
|
-
r === "enclosed" && "bear-border-b bear-border-gray-200 dark:bear-border-gray-700",
|
|
31
|
-
t
|
|
32
|
-
),
|
|
33
|
-
children: a
|
|
34
|
-
}
|
|
35
|
-
);
|
|
36
|
-
}, _ = ({ id: a, children: t, disabled: e = !1, icon: r }) => {
|
|
37
|
-
const o = g(d);
|
|
38
|
-
if (!o) throw new Error("Tab must be used within Tabs");
|
|
39
|
-
const { activeTab: c, setActiveTab: l, variant: x } = o, b = c === a, i = "bear-flex bear-items-center bear-gap-2 bear-px-4 bear-py-2 bear-text-sm bear-font-medium bear-transition-colors", y = {
|
|
40
|
-
line: s(
|
|
16
|
+
return /* @__PURE__ */ l(x.Provider, { value: { activeTab: m, setActiveTab: v, variant: n }, children: /* @__PURE__ */ l("div", { className: b("Bear-Tabs", c), "data-testid": d, children: o }) });
|
|
17
|
+
}, g = ({ id: o, children: s, disabled: e = !1, icon: n }) => {
|
|
18
|
+
const a = y(x);
|
|
19
|
+
if (!a) throw new Error("Tab must be used within Tabs");
|
|
20
|
+
const { activeTab: c, setActiveTab: d, variant: t } = a, r = c === o, i = "bear-flex bear-items-center bear-gap-2 bear-px-4 bear-py-2 bear-text-sm bear-font-medium bear-transition-colors", m = {
|
|
21
|
+
line: b(
|
|
41
22
|
"bear-border-b-2 bear--mb-px",
|
|
42
|
-
|
|
23
|
+
r ? "bear-border-pink-500 bear-text-pink-600 dark:bear-text-pink-400" : "bear-border-transparent hover:bear-border-[var(--bear-border-default)]"
|
|
43
24
|
),
|
|
44
|
-
pills:
|
|
25
|
+
pills: b(
|
|
45
26
|
"bear-rounded-md",
|
|
46
|
-
|
|
27
|
+
r && "bear-shadow-sm"
|
|
47
28
|
),
|
|
48
|
-
enclosed:
|
|
29
|
+
enclosed: b(
|
|
49
30
|
"bear-rounded-t-lg bear-border bear-border-transparent",
|
|
50
|
-
|
|
31
|
+
r && "bear--mb-px"
|
|
51
32
|
)
|
|
52
|
-
}
|
|
53
|
-
|
|
33
|
+
}, v = e ? void 0 : r ? t === "pills" ? { backgroundColor: "var(--bear-bg-primary)", color: "var(--bear-text-primary)" } : t === "enclosed" ? {
|
|
34
|
+
backgroundColor: "var(--bear-bg-primary)",
|
|
35
|
+
borderColor: "var(--bear-border-default)",
|
|
36
|
+
borderBottomColor: "var(--bear-bg-primary)",
|
|
37
|
+
color: "var(--bear-text-primary)"
|
|
38
|
+
} : void 0 : { color: "var(--bear-text-muted)" };
|
|
39
|
+
return /* @__PURE__ */ u(
|
|
54
40
|
"button",
|
|
55
41
|
{
|
|
56
42
|
role: "tab",
|
|
57
|
-
"aria-selected":
|
|
43
|
+
"aria-selected": r,
|
|
58
44
|
disabled: e,
|
|
59
|
-
onClick: () => !e &&
|
|
60
|
-
className:
|
|
45
|
+
onClick: () => !e && d(o),
|
|
46
|
+
className: b(
|
|
61
47
|
"Bear-Tabs__tab",
|
|
62
|
-
|
|
48
|
+
r && "Bear-Tabs__tab--active",
|
|
63
49
|
i,
|
|
64
|
-
|
|
50
|
+
m[t],
|
|
51
|
+
!r && "hover:bear-bg-[var(--bear-bg-tertiary)] hover:bear-text-[var(--bear-text-primary)]",
|
|
65
52
|
e && "Bear-Tabs__tab--disabled bear-opacity-50 bear-cursor-not-allowed"
|
|
66
53
|
),
|
|
54
|
+
style: v,
|
|
67
55
|
children: [
|
|
68
|
-
|
|
69
|
-
/* @__PURE__ */
|
|
56
|
+
n && /* @__PURE__ */ l("span", { className: "Bear-Tabs__tab-icon", children: n }),
|
|
57
|
+
/* @__PURE__ */ l("span", { className: "Bear-Tabs__tab-label", children: s })
|
|
70
58
|
]
|
|
71
59
|
}
|
|
72
60
|
);
|
|
73
|
-
}, f = ({ tabId: a, children: t, className: e }) => {
|
|
74
|
-
const r = g(d);
|
|
75
|
-
if (!r) throw new Error("TabPanel must be used within Tabs");
|
|
76
|
-
const { activeTab: o } = r;
|
|
77
|
-
return o !== a ? null : /* @__PURE__ */ n("div", { role: "tabpanel", className: s("Bear-Tabs__panel bear-py-4", e), children: t });
|
|
78
61
|
};
|
|
79
62
|
export {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
k as Tabs
|
|
63
|
+
g as Tab,
|
|
64
|
+
C as Tabs,
|
|
65
|
+
x as TabsContext
|
|
84
66
|
};
|
|
@@ -7,7 +7,9 @@ export interface TabsContextValue {
|
|
|
7
7
|
export interface TabsProps {
|
|
8
8
|
/** Tab panels */
|
|
9
9
|
children: ReactNode;
|
|
10
|
-
/**
|
|
10
|
+
/** Controlled active tab (when set, defaultTab is ignored) */
|
|
11
|
+
value?: string;
|
|
12
|
+
/** Default active tab (uncontrolled) */
|
|
11
13
|
defaultTab: string;
|
|
12
14
|
/** Visual variant */
|
|
13
15
|
variant?: 'line' | 'pills' | 'enclosed';
|
|
@@ -21,6 +23,10 @@ export interface TabsProps {
|
|
|
21
23
|
export interface TabListProps {
|
|
22
24
|
/** Tab buttons */
|
|
23
25
|
children: ReactNode;
|
|
26
|
+
/** Max number of visible tabs before overflow (e.g. 5); rest go in "..." dropdown. Selected tab is always shown first. */
|
|
27
|
+
maxVisibleTabs?: number;
|
|
28
|
+
/** Allow tabs to wrap to next line (flex-wrap), no breakpoints */
|
|
29
|
+
wrap?: boolean;
|
|
24
30
|
/** Custom class name */
|
|
25
31
|
className?: string;
|
|
26
32
|
}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
export { Tabs,
|
|
1
|
+
export { Tabs, Tab, TabsContext } from './Tabs';
|
|
2
|
+
export { TabList } from './TabList';
|
|
3
|
+
export { TabPanel } from './TabPanel';
|
|
2
4
|
export type { TabsProps, TabListProps, TabProps, TabPanelProps, TabsContextValue } from './Tabs.types';
|