@forgedevstack/bear 1.0.8 → 1.0.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/dist/components/ActivityItem/ActivityItem.cjs +1 -1
- package/dist/components/ActivityItem/ActivityItem.js +1 -0
- package/dist/components/Alert/Alert.const.cjs +1 -1
- package/dist/components/Alert/Alert.const.js +3 -2
- package/dist/components/AppBar/AppBar.cjs +1 -1
- package/dist/components/AppBar/AppBar.js +3 -2
- package/dist/components/Badge/Badge.cjs +1 -1
- package/dist/components/Badge/Badge.js +15 -14
- package/dist/components/BearLogo/EmberLogo.cjs +1 -1
- package/dist/components/BearLogo/EmberLogo.js +3 -2
- package/dist/components/BottomNavigation/BottomNavigation.cjs +1 -1
- package/dist/components/BottomNavigation/BottomNavigation.js +3 -2
- package/dist/components/Carousel/Carousel.cjs +1 -1
- package/dist/components/Carousel/Carousel.const.cjs +1 -0
- package/dist/components/Carousel/Carousel.const.d.ts +12 -0
- package/dist/components/Carousel/Carousel.const.js +9 -0
- package/dist/components/Carousel/Carousel.d.ts +14 -3
- package/dist/components/Carousel/Carousel.js +222 -75
- package/dist/components/Carousel/Carousel.types.d.ts +32 -2
- package/dist/components/Carousel/index.d.ts +1 -1
- package/dist/components/Chip/Chip.cjs +1 -1
- package/dist/components/Chip/Chip.js +3 -2
- package/dist/components/CodeEditor/CodeEditor.cjs +5 -0
- package/dist/components/CodeEditor/CodeEditor.const.cjs +1 -0
- package/dist/components/CodeEditor/CodeEditor.const.d.ts +21 -0
- package/dist/components/CodeEditor/CodeEditor.const.js +119 -0
- package/dist/components/CodeEditor/CodeEditor.d.ts +22 -0
- package/dist/components/CodeEditor/CodeEditor.js +250 -0
- package/dist/components/CodeEditor/CodeEditor.types.d.ts +80 -0
- package/dist/components/CodeEditor/CodeEditor.utils.cjs +1 -0
- package/dist/components/CodeEditor/CodeEditor.utils.d.ts +6 -0
- package/dist/components/CodeEditor/CodeEditor.utils.js +75 -0
- package/dist/components/CodeEditor/index.d.ts +2 -0
- package/dist/components/Columns/Columns.cjs +1 -1
- package/dist/components/Columns/Columns.js +9 -8
- package/dist/components/CountdownTimer/CountdownTimer.cjs +1 -0
- package/dist/components/CountdownTimer/CountdownTimer.const.cjs +1 -0
- package/dist/components/CountdownTimer/CountdownTimer.const.d.ts +27 -0
- package/dist/components/CountdownTimer/CountdownTimer.const.js +35 -0
- package/dist/components/CountdownTimer/CountdownTimer.d.ts +7 -0
- package/dist/components/CountdownTimer/CountdownTimer.js +115 -0
- package/dist/components/CountdownTimer/CountdownTimer.types.d.ts +56 -0
- package/dist/components/CountdownTimer/index.d.ts +2 -0
- package/dist/components/Cropper/Cropper.cjs +1 -0
- package/dist/components/Cropper/Cropper.const.cjs +1 -0
- package/dist/components/Cropper/Cropper.const.d.ts +31 -0
- package/dist/components/Cropper/Cropper.const.js +33 -0
- package/dist/components/Cropper/Cropper.d.ts +21 -0
- package/dist/components/Cropper/Cropper.js +362 -0
- package/dist/components/Cropper/Cropper.types.d.ts +72 -0
- package/dist/components/Cropper/index.d.ts +2 -0
- package/dist/components/DataTable/DataTable.cjs +1 -1
- package/dist/components/DataTable/DataTable.js +5 -4
- package/dist/components/Divider/Divider.cjs +1 -1
- package/dist/components/Divider/Divider.js +15 -14
- package/dist/components/Dock/Dock.cjs +1 -0
- package/dist/components/Dock/Dock.const.cjs +1 -0
- package/dist/components/Dock/Dock.const.d.ts +25 -0
- package/dist/components/Dock/Dock.const.js +22 -0
- package/dist/components/Dock/Dock.d.ts +7 -0
- package/dist/components/Dock/Dock.js +144 -0
- package/dist/components/Dock/Dock.types.d.ts +42 -0
- package/dist/components/Dock/index.d.ts +2 -0
- package/dist/components/EmptyState/EmptyState.cjs +1 -1
- package/dist/components/EmptyState/EmptyState.js +7 -6
- package/dist/components/GradientText/GradientText.cjs +1 -0
- package/dist/components/GradientText/GradientText.const.cjs +1 -0
- package/dist/components/GradientText/GradientText.const.d.ts +15 -0
- package/dist/components/GradientText/GradientText.const.js +36 -0
- package/dist/components/GradientText/GradientText.d.ts +7 -0
- package/dist/components/GradientText/GradientText.js +52 -0
- package/dist/components/GradientText/GradientText.types.d.ts +27 -0
- package/dist/components/GradientText/index.d.ts +2 -0
- package/dist/components/Highlight/Highlight.cjs +1 -1
- package/dist/components/Highlight/Highlight.const.cjs +1 -0
- package/dist/components/Highlight/Highlight.const.d.ts +8 -0
- package/dist/components/Highlight/Highlight.const.js +15 -0
- package/dist/components/Highlight/Highlight.d.ts +4 -0
- package/dist/components/Highlight/Highlight.js +32 -24
- package/dist/components/Highlight/Highlight.types.d.ts +9 -1
- package/dist/components/Highlight/index.d.ts +1 -1
- package/dist/components/Icon/Icon.cjs +1 -1
- package/dist/components/Icon/Icon.js +17 -16
- package/dist/components/Icon/index.cjs +1 -1
- package/dist/components/Icon/index.js +12 -11
- package/dist/components/Kbd/Kbd.cjs +1 -1
- package/dist/components/Kbd/Kbd.js +17 -16
- package/dist/components/Map/Map.cjs +1 -0
- package/dist/components/Map/Map.const.cjs +1 -0
- package/dist/components/Map/Map.const.d.ts +20 -0
- package/dist/components/Map/Map.const.js +26 -0
- package/dist/components/Map/Map.d.ts +20 -0
- package/dist/components/Map/Map.js +259 -0
- package/dist/components/Map/Map.types.d.ts +81 -0
- package/dist/components/Map/index.d.ts +2 -0
- package/dist/components/Marquee/Marquee.cjs +1 -0
- package/dist/components/Marquee/Marquee.const.cjs +1 -0
- package/dist/components/Marquee/Marquee.const.d.ts +11 -0
- package/dist/components/Marquee/Marquee.const.js +12 -0
- package/dist/components/Marquee/Marquee.d.ts +7 -0
- package/dist/components/Marquee/Marquee.js +106 -0
- package/dist/components/Marquee/Marquee.types.d.ts +32 -0
- package/dist/components/Marquee/index.d.ts +2 -0
- package/dist/components/Masonry/Masonry.cjs +1 -0
- package/dist/components/Masonry/Masonry.const.cjs +1 -0
- package/dist/components/Masonry/Masonry.const.d.ts +9 -0
- package/dist/components/Masonry/Masonry.const.js +9 -0
- package/dist/components/Masonry/Masonry.d.ts +7 -0
- package/dist/components/Masonry/Masonry.js +51 -0
- package/dist/components/Masonry/Masonry.types.d.ts +21 -0
- package/dist/components/Masonry/index.d.ts +2 -0
- package/dist/components/NavigableSelect/NavigableSelect.cjs +1 -0
- package/dist/components/NavigableSelect/NavigableSelect.const.cjs +1 -0
- package/dist/components/NavigableSelect/NavigableSelect.const.d.ts +23 -0
- package/dist/components/NavigableSelect/NavigableSelect.const.js +33 -0
- package/dist/components/NavigableSelect/NavigableSelect.d.ts +7 -0
- package/dist/components/NavigableSelect/NavigableSelect.js +361 -0
- package/dist/components/NavigableSelect/NavigableSelect.types.d.ts +56 -0
- package/dist/components/NavigableSelect/index.d.ts +2 -0
- package/dist/components/Progress/Progress.cjs +1 -1
- package/dist/components/Progress/Progress.js +3 -2
- package/dist/components/RichEditor/components/ToolbarButton/ToolbarButton.cjs +1 -1
- package/dist/components/RichEditor/components/ToolbarButton/ToolbarButton.js +3 -2
- package/dist/components/ScrollArea/ScrollArea.cjs +1 -1
- package/dist/components/ScrollArea/ScrollArea.js +3 -2
- package/dist/components/Sidebar/Sidebar.cjs +1 -1
- package/dist/components/Sidebar/Sidebar.js +13 -12
- package/dist/components/Spinner/Spinner.cjs +1 -1
- package/dist/components/Spinner/Spinner.js +3 -2
- package/dist/components/Spotlight/Spotlight.cjs +1 -0
- package/dist/components/Spotlight/Spotlight.const.cjs +1 -0
- package/dist/components/Spotlight/Spotlight.const.d.ts +18 -0
- package/dist/components/Spotlight/Spotlight.const.js +9 -0
- package/dist/components/Spotlight/Spotlight.d.ts +7 -0
- package/dist/components/Spotlight/Spotlight.js +220 -0
- package/dist/components/Spotlight/Spotlight.types.d.ts +51 -0
- package/dist/components/Spotlight/index.d.ts +2 -0
- package/dist/components/StatCard/StatCard.cjs +1 -1
- package/dist/components/StatCard/StatCard.js +9 -8
- package/dist/components/Statistic/Statistic.cjs +1 -1
- package/dist/components/Statistic/Statistic.js +7 -6
- package/dist/components/Switch/Switch.cjs +1 -1
- package/dist/components/Switch/Switch.js +11 -10
- package/dist/components/TimePicker/components/TimePickerColumnsDropdown/TimePickerColumnsDropdown.cjs +1 -1
- package/dist/components/TimePicker/components/TimePickerColumnsDropdown/TimePickerColumnsDropdown.js +16 -15
- package/dist/components/TimePicker/helpers/ClockFaceSvg.cjs +1 -1
- package/dist/components/TimePicker/helpers/ClockFaceSvg.js +13 -12
- package/dist/components/Transition/Transition.cjs +1 -0
- package/dist/components/Transition/Transition.const.cjs +1 -0
- package/dist/components/Transition/Transition.const.d.ts +15 -0
- package/dist/components/Transition/Transition.const.js +73 -0
- package/dist/components/Transition/Transition.d.ts +37 -0
- package/dist/components/Transition/Transition.js +107 -0
- package/dist/components/Transition/Transition.types.d.ts +69 -0
- package/dist/components/Transition/index.d.ts +2 -0
- package/dist/components/Typewriter/Typewriter.cjs +1 -0
- package/dist/components/Typewriter/Typewriter.const.cjs +1 -0
- package/dist/components/Typewriter/Typewriter.const.d.ts +22 -0
- package/dist/components/Typewriter/Typewriter.const.js +11 -0
- package/dist/components/Typewriter/Typewriter.d.ts +7 -0
- package/dist/components/Typewriter/Typewriter.js +88 -0
- package/dist/components/Typewriter/Typewriter.types.d.ts +32 -0
- package/dist/components/Typewriter/index.d.ts +2 -0
- package/dist/components/Watermark/Watermark.cjs +1 -0
- package/dist/components/Watermark/Watermark.const.cjs +1 -0
- package/dist/components/Watermark/Watermark.const.d.ts +30 -0
- package/dist/components/Watermark/Watermark.const.js +18 -0
- package/dist/components/Watermark/Watermark.d.ts +7 -0
- package/dist/components/Watermark/Watermark.js +96 -0
- package/dist/components/Watermark/Watermark.types.d.ts +35 -0
- package/dist/components/Watermark/index.d.ts +2 -0
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.d.ts +27 -1
- package/dist/components/index.js +231 -204
- package/dist/hooks/index.cjs +1 -1
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/index.js +24 -19
- package/dist/hooks/useAnimate.cjs +1 -0
- package/dist/hooks/useAnimate.d.ts +61 -0
- package/dist/hooks/useAnimate.js +125 -0
- package/dist/hooks/useResponsive.cjs +1 -0
- package/dist/hooks/useResponsive.d.ts +35 -0
- package/dist/hooks/useResponsive.js +74 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +324 -290
- package/dist/styles.css +1 -1
- package/dist/utils/createSlots.cjs +1 -0
- package/dist/utils/createSlots.d.ts +70 -0
- package/dist/utils/createSlots.js +65 -0
- package/dist/utils/index.cjs +1 -1
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +4 -2
- package/package.json +1 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export type MarqueeDirection = 'left' | 'right' | 'up' | 'down';
|
|
3
|
+
export interface MarqueeProps {
|
|
4
|
+
/** Content to scroll */
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
/** Scroll direction */
|
|
7
|
+
direction?: MarqueeDirection;
|
|
8
|
+
/** Speed in pixels per second */
|
|
9
|
+
speed?: number;
|
|
10
|
+
/** Pause on hover */
|
|
11
|
+
pauseOnHover?: boolean;
|
|
12
|
+
/** Pause on click */
|
|
13
|
+
pauseOnClick?: boolean;
|
|
14
|
+
/** Whether the marquee is playing */
|
|
15
|
+
play?: boolean;
|
|
16
|
+
/** Number of times to loop (0 = infinite) */
|
|
17
|
+
loop?: number;
|
|
18
|
+
/** Gradient fade on edges */
|
|
19
|
+
gradient?: boolean;
|
|
20
|
+
/** Gradient color (auto-detects dark/light) */
|
|
21
|
+
gradientColor?: string;
|
|
22
|
+
/** Gradient width in pixels */
|
|
23
|
+
gradientWidth?: number;
|
|
24
|
+
/** Gap between repeated items */
|
|
25
|
+
gap?: number;
|
|
26
|
+
/** Custom class name */
|
|
27
|
+
className?: string;
|
|
28
|
+
/** Custom style */
|
|
29
|
+
style?: React.CSSProperties;
|
|
30
|
+
/** Test ID */
|
|
31
|
+
testId?: string;
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),t=require("react"),L=require("../../utils/cn.cjs"),n=require("./Masonry.const.cjs"),_=m=>{const{children:a,columns:e=n.DEFAULT_COLUMNS,gap:i=n.DEFAULT_GAP,className:d,style:f,testId:y}=m,E=t.useRef(null),[l,r]=t.useState(typeof e=="number"?e:e.base??n.DEFAULT_COLUMNS),o=t.useCallback(()=>{if(typeof e=="number"){r(e);return}const s=window.innerWidth;e.xl&&s>=n.BREAKPOINT_XL?r(e.xl):e.lg&&s>=n.BREAKPOINT_LG?r(e.lg):e.md&&s>=n.BREAKPOINT_MD?r(e.md):e.sm&&s>=n.BREAKPOINT_SM?r(e.sm):r(e.base??n.DEFAULT_COLUMNS)},[e]);t.useEffect(()=>(o(),window.addEventListener("resize",o),()=>window.removeEventListener("resize",o)),[o]);const M=t.useMemo(()=>{const s=Array.from({length:l},()=>[]);return t.Children.forEach(a,(c,b)=>{s[b%l].push(c)}),s},[a,l]);return u.jsx("div",{ref:E,className:L.cn("Bear-Masonry","bear-flex",d),style:{gap:i,...f},"data-testid":y,children:M.map((s,c)=>u.jsx("div",{className:"Bear-Masonry__column bear-flex bear-flex-col bear-flex-1",style:{gap:i},children:s},c))})};exports.Masonry=_;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const A=3,T=16,t=1280,E=1024,_=768,O=640;exports.BREAKPOINT_LG=E;exports.BREAKPOINT_MD=_;exports.BREAKPOINT_SM=O;exports.BREAKPOINT_XL=t;exports.DEFAULT_COLUMNS=A;exports.DEFAULT_GAP=T;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Default number of columns */
|
|
2
|
+
export declare const DEFAULT_COLUMNS = 3;
|
|
3
|
+
/** Default gap in pixels */
|
|
4
|
+
export declare const DEFAULT_GAP = 16;
|
|
5
|
+
/** Breakpoint thresholds in pixels */
|
|
6
|
+
export declare const BREAKPOINT_XL = 1280;
|
|
7
|
+
export declare const BREAKPOINT_LG = 1024;
|
|
8
|
+
export declare const BREAKPOINT_MD = 768;
|
|
9
|
+
export declare const BREAKPOINT_SM = 640;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as y, useState as h, useCallback as v, useEffect as x, useMemo as A, Children as N } from "react";
|
|
3
|
+
import { cn as _ } from "../../utils/cn.js";
|
|
4
|
+
import { DEFAULT_COLUMNS as t, DEFAULT_GAP as w, BREAKPOINT_XL as L, BREAKPOINT_LG as M, BREAKPOINT_MD as R, BREAKPOINT_SM as B } from "./Masonry.const.js";
|
|
5
|
+
const O = (c) => {
|
|
6
|
+
const {
|
|
7
|
+
children: m,
|
|
8
|
+
columns: e = t,
|
|
9
|
+
gap: a = w,
|
|
10
|
+
className: f,
|
|
11
|
+
style: u,
|
|
12
|
+
testId: d
|
|
13
|
+
} = c, p = y(null), [n, r] = h(
|
|
14
|
+
typeof e == "number" ? e : e.base ?? t
|
|
15
|
+
), o = v(() => {
|
|
16
|
+
if (typeof e == "number") {
|
|
17
|
+
r(e);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const s = window.innerWidth;
|
|
21
|
+
e.xl && s >= L ? r(e.xl) : e.lg && s >= M ? r(e.lg) : e.md && s >= R ? r(e.md) : e.sm && s >= B ? r(e.sm) : r(e.base ?? t);
|
|
22
|
+
}, [e]);
|
|
23
|
+
x(() => (o(), window.addEventListener("resize", o), () => window.removeEventListener("resize", o)), [o]);
|
|
24
|
+
const E = A(() => {
|
|
25
|
+
const s = Array.from({ length: n }, () => []);
|
|
26
|
+
return N.forEach(m, (l, b) => {
|
|
27
|
+
s[b % n].push(l);
|
|
28
|
+
}), s;
|
|
29
|
+
}, [m, n]);
|
|
30
|
+
return /* @__PURE__ */ i(
|
|
31
|
+
"div",
|
|
32
|
+
{
|
|
33
|
+
ref: p,
|
|
34
|
+
className: _("Bear-Masonry", "bear-flex", f),
|
|
35
|
+
style: { gap: a, ...u },
|
|
36
|
+
"data-testid": d,
|
|
37
|
+
children: E.map((s, l) => /* @__PURE__ */ i(
|
|
38
|
+
"div",
|
|
39
|
+
{
|
|
40
|
+
className: "Bear-Masonry__column bear-flex bear-flex-col bear-flex-1",
|
|
41
|
+
style: { gap: a },
|
|
42
|
+
children: s
|
|
43
|
+
},
|
|
44
|
+
l
|
|
45
|
+
))
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
export {
|
|
50
|
+
O as Masonry
|
|
51
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export interface MasonryProps {
|
|
3
|
+
/** Items to render in masonry layout */
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
/** Number of columns */
|
|
6
|
+
columns?: number | {
|
|
7
|
+
base?: number;
|
|
8
|
+
sm?: number;
|
|
9
|
+
md?: number;
|
|
10
|
+
lg?: number;
|
|
11
|
+
xl?: number;
|
|
12
|
+
};
|
|
13
|
+
/** Gap between items in pixels */
|
|
14
|
+
gap?: number;
|
|
15
|
+
/** Custom class name */
|
|
16
|
+
className?: string;
|
|
17
|
+
/** Custom style */
|
|
18
|
+
style?: React.CSSProperties;
|
|
19
|
+
/** Test ID */
|
|
20
|
+
testId?: string;
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),s=require("react"),n=require("../../utils/cn.cjs"),c=require("./NavigableSelect.const.cjs"),oe=Z=>{const{options:_,value:R,defaultValue:G,onChange:i,multiple:b=!1,searchable:K=!0,placeholder:z=c.DEFAULT_PLACEHOLDER,label:O,helperText:M,error:S,disabled:p=!1,size:m="md",fullWidth:X=!1,maxVisible:Y=c.DEFAULT_MAX_VISIBLE,maxSelections:j,emptyText:$=c.DEFAULT_EMPTY_TEXT,className:J,style:Q,testId:ee}=Z,y=R!==void 0,V=e=>e===void 0?[]:Array.isArray(e)?e:[e],[re,P]=s.useState(V(G)),[g,w]=s.useState(!1),[d,o]=s.useState(-1),[x,B]=s.useState(""),E=s.useRef(null),C=s.useRef(null),q=s.useRef(null),H=s.useRef(null),l=y?V(R):re,h=s.useMemo(()=>{if(!x)return _;const e=x.toLowerCase();return _.filter(a=>{var t;return a.label.toLowerCase().includes(e)||((t=a.description)==null?void 0:t.toLowerCase().includes(e))})},[_,x]),ae=s.useMemo(()=>{const e=new Map;return h.forEach(a=>{const t=a.group||"";e.has(t)||e.set(t,[]),e.get(t).push(a)}),e},[h]),v=s.useMemo(()=>h.filter(e=>!e.disabled),[h]);s.useEffect(()=>{const e=a=>{E.current&&!E.current.contains(a.target)&&(w(!1),B(""))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),s.useEffect(()=>{if(!C.current||d<0)return;const e=C.current.querySelector('[data-active="true"]');e==null||e.scrollIntoView({block:c.SCROLL_BLOCK})},[d]);const L=s.useCallback(()=>{p||(w(!0),o(0),setTimeout(()=>{var e;return(e=q.current)==null?void 0:e.focus()},0))},[p]),k=s.useCallback(()=>{var e;w(!1),B(""),o(-1),(e=H.current)==null||e.focus()},[]),I=s.useCallback(e=>{let a;if(b)if(l.includes(e))a=l.filter(t=>t!==e);else{if(j&&l.length>=j)return;a=[...l,e]}else a=[e],k();y||P(a),i==null||i(b?a:a[0]??"")},[l,b,y,j,i,k]),D=s.useCallback(e=>{const a=l.filter(t=>t!==e);y||P(a),i==null||i(b?a:a[0]??"")},[l,b,y,i]),W=s.useCallback(e=>{if(!g){(e.key==="ArrowDown"||e.key==="ArrowUp"||e.key==="Enter"||e.key===" ")&&(e.preventDefault(),L());return}switch(e.key){case"ArrowDown":e.preventDefault(),o(a=>Math.min(a+1,v.length-1));break;case"ArrowUp":e.preventDefault(),o(a=>Math.max(a-1,0));break;case"Enter":case" ":e.preventDefault(),d>=0&&v[d]&&I(v[d].value);break;case"Escape":e.preventDefault(),k();break;case"Backspace":x===""&&b&&l.length>0&&D(l[l.length-1]);break;case"Home":e.preventDefault(),o(0);break;case"End":e.preventDefault(),o(v.length-1);break}},[g,d,v,I,k,L,x,b,l,D]),te=s.useCallback(e=>l.includes(e),[l]),u=l.map(e=>_.find(a=>a.value===e)).filter(Boolean),se=!!S,le=c.TRIGGER_SIZE_CLASSES[m],be=c.OPTION_SIZE_CLASSES[m],ne=c.TAG_SIZE_CLASSES[m],F=c.ICON_SIZE[m],ce=Y*c.OPTION_HEIGHT[m];let A=-1;return r.jsxs("div",{ref:E,className:n.cn("Bear-NavigableSelect","bear-relative bear-flex bear-flex-col bear-gap-1.5",X&&"bear-w-full",J),style:Q,"data-testid":ee,children:[O&&r.jsx("label",{className:"Bear-NavigableSelect__label bear-text-sm bear-font-medium bear-text-gray-700 dark:bear-text-gray-300",children:O}),r.jsxs("button",{ref:H,type:"button",disabled:p,onClick:()=>g?k():L(),onKeyDown:W,className:n.cn("Bear-NavigableSelect__trigger","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","bear-bg-white dark:bear-bg-gray-900","bear-text-gray-900 dark:bear-text-white",se?"bear-border-red-500 focus:bear-ring-2 focus:bear-ring-red-500/20":"bear-border-gray-300 dark:bear-border-gray-600 focus:bear-border-[var(--bear-primary-500)] focus:bear-ring-2 focus:bear-ring-[var(--bear-primary-500)]/20",p&&"bear-opacity-50 bear-cursor-not-allowed",le),"aria-haspopup":"listbox","aria-expanded":g,children:[r.jsxs("span",{className:"Bear-NavigableSelect__value bear-flex bear-items-center bear-gap-1.5 bear-flex-wrap bear-flex-1 bear-min-w-0 bear-overflow-hidden",children:[b&&u.length>0&&u.map(e=>r.jsxs("span",{className:n.cn("Bear-NavigableSelect__tag","bear-inline-flex bear-items-center bear-gap-1 bear-rounded-md","bear-bg-[var(--bear-primary-100,#fce7f3)] dark:bear-bg-[var(--bear-primary-900,#831843)]/30","bear-text-[var(--bear-primary-700,#be185d)] dark:bear-text-[var(--bear-primary-300,#f9a8d4)]",ne),children:[e.label,!p&&r.jsx("button",{type:"button",onClick:a=>{a.stopPropagation(),D(e.value)},className:"bear-ml-0.5 hover:bear-opacity-70","aria-label":`Remove ${e.label}`,children:"×"})]},e.value)),!b&&u.length>0&&r.jsxs("span",{className:"bear-truncate",children:[u[0].icon&&r.jsx("span",{className:"bear-mr-1.5",children:u[0].icon}),u[0].label]}),u.length===0&&r.jsx("span",{className:"bear-text-gray-400 dark:bear-text-gray-500",children:z})]}),r.jsx("svg",{className:n.cn(F,"bear-text-gray-400 dark:bear-text-gray-500 bear-transition-transform bear-shrink-0 bear-ml-2",g&&"bear-rotate-180"),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 9l-7 7-7-7"})})]}),g&&r.jsxs("div",{className:n.cn("Bear-NavigableSelect__dropdown","bear-absolute bear-top-full bear-left-0 bear-w-full bear-mt-1","bear-bg-white dark:bear-bg-gray-900","bear-border bear-border-gray-200 dark:bear-border-gray-700","bear-rounded-lg bear-shadow-lg bear-overflow-hidden"),style:{zIndex:c.DROPDOWN_Z_INDEX},children:[K&&r.jsxs("div",{className:"Bear-NavigableSelect__search bear-flex bear-items-center bear-gap-2 bear-px-3 bear-py-2 bear-border-b bear-border-gray-200 dark:bear-border-gray-700",children:[r.jsxs("svg",{className:"bear-w-4 bear-h-4 bear-text-gray-400 dark:bear-text-gray-500 bear-shrink-0",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,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:q,type:"text",value:x,onChange:e=>{B(e.target.value),o(0)},onKeyDown:W,placeholder:"Type to search...",className:n.cn("Bear-NavigableSelect__input","bear-flex-1 bear-bg-transparent bear-outline-none bear-text-sm","bear-text-gray-900 dark:bear-text-white","placeholder:bear-text-gray-400 dark:placeholder:bear-text-gray-500"),autoComplete:"off",spellCheck:!1})]}),r.jsxs("div",{ref:C,className:"Bear-NavigableSelect__list bear-overflow-y-auto bear-py-1",style:{maxHeight:ce},role:"listbox","aria-multiselectable":b,children:[h.length===0&&r.jsx("div",{className:"Bear-NavigableSelect__empty bear-px-3 bear-py-4 bear-text-center bear-text-sm bear-text-gray-500 dark:bear-text-gray-400",children:$}),Array.from(ae.entries()).map(([e,a])=>r.jsxs("div",{className:"Bear-NavigableSelect__group",children:[e&&r.jsx("div",{className:"Bear-NavigableSelect__group-title bear-px-3 bear-py-1 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=>{const N=t.disabled,U=!N;U&&A++;const T=A===d,f=te(t.value),ie=A;return r.jsxs("button",{type:"button",disabled:N,className:n.cn("Bear-NavigableSelect__option","bear-w-full bear-flex bear-items-center bear-gap-2.5 bear-text-left bear-cursor-pointer","bear-transition-colors bear-duration-100",be,T&&"bear-bg-gray-100 dark:bear-bg-gray-800",f&&!T&&"bear-bg-[var(--bear-primary-50,#fdf2f8)] dark:bear-bg-[var(--bear-primary-950,#500724)]/20",N&&"bear-opacity-40 bear-cursor-not-allowed"),"data-active":T,onMouseEnter:()=>{U&&o(ie)},onClick:()=>{N||I(t.value)},role:"option","aria-selected":f,"aria-disabled":N,children:[b&&r.jsx("span",{className:n.cn("Bear-NavigableSelect__checkbox","bear-flex bear-items-center bear-justify-center bear-w-4 bear-h-4 bear-rounded bear-border bear-shrink-0","bear-transition-colors",f?"bear-bg-[var(--bear-primary-500)] bear-border-[var(--bear-primary-500)] bear-text-white":"bear-border-gray-300 dark:bear-border-gray-600"),children:f&&r.jsx("svg",{className:"bear-w-3 bear-h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),t.icon&&r.jsx("span",{className:"Bear-NavigableSelect__option-icon bear-shrink-0 bear-text-gray-500 dark:bear-text-gray-400",children:t.icon}),r.jsxs("div",{className:"Bear-NavigableSelect__option-body bear-flex-1 bear-min-w-0",children:[r.jsx("div",{className:n.cn("Bear-NavigableSelect__option-label bear-truncate",f?"bear-text-[var(--bear-primary-700,#be185d)] dark:bear-text-[var(--bear-primary-300,#f9a8d4)] bear-font-medium":"bear-text-gray-900 dark:bear-text-white"),children:t.label}),t.description&&r.jsx("div",{className:"Bear-NavigableSelect__option-desc bear-text-xs bear-text-gray-500 dark:bear-text-gray-400 bear-truncate",children:t.description})]}),!b&&f&&r.jsx("svg",{className:n.cn(F,"bear-text-[var(--bear-primary-500)] bear-shrink-0"),fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:r.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})]},t.value)})]},e))]}),r.jsxs("div",{className:"Bear-NavigableSelect__footer bear-flex bear-items-center bear-gap-3 bear-px-3 bear-py-1.5 bear-border-t bear-border-gray-200 dark:bear-border-gray-700 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"]})]})]}),(M||S)&&r.jsx("p",{className:n.cn("Bear-NavigableSelect__helper bear-text-xs",S?"bear-text-red-500":"bear-text-gray-500 dark:bear-text-gray-400"),children:S||M})]})};exports.NavigableSelect=oe;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="Select an option...",a="No options found",r=8,t={sm:32,md:40,lg:48},b={sm:"bear-h-8 bear-text-sm bear-px-2.5",md:"bear-h-10 bear-text-sm bear-px-3",lg:"bear-h-12 bear-text-base bear-px-4"},E={sm:"bear-px-2.5 bear-py-1.5 bear-text-sm",md:"bear-px-3 bear-py-2 bear-text-sm",lg:"bear-px-4 bear-py-2.5 bear-text-base"},S={sm:"bear-text-xs bear-px-1.5 bear-py-0.5",md:"bear-text-xs bear-px-2 bear-py-0.5",lg:"bear-text-sm bear-px-2 bear-py-1"},_=50,s="nearest",I={sm:"bear-w-3.5 bear-h-3.5",md:"bear-w-4 bear-h-4",lg:"bear-w-5 bear-h-5"};exports.DEFAULT_EMPTY_TEXT=a;exports.DEFAULT_MAX_VISIBLE=r;exports.DEFAULT_PLACEHOLDER=e;exports.DROPDOWN_Z_INDEX=_;exports.ICON_SIZE=I;exports.OPTION_HEIGHT=t;exports.OPTION_SIZE_CLASSES=E;exports.SCROLL_BLOCK=s;exports.TAG_SIZE_CLASSES=S;exports.TRIGGER_SIZE_CLASSES=b;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { NavigableSelectSize } from './NavigableSelect.types';
|
|
2
|
+
/** Default placeholder */
|
|
3
|
+
export declare const DEFAULT_PLACEHOLDER = "Select an option...";
|
|
4
|
+
/** Default empty text */
|
|
5
|
+
export declare const DEFAULT_EMPTY_TEXT = "No options found";
|
|
6
|
+
/** Default max visible options */
|
|
7
|
+
export declare const DEFAULT_MAX_VISIBLE = 8;
|
|
8
|
+
/** Option height per size (approx pixels for scroll calculation) */
|
|
9
|
+
export declare const OPTION_HEIGHT: Record<NavigableSelectSize, number>;
|
|
10
|
+
/** Trigger button size classes */
|
|
11
|
+
export declare const TRIGGER_SIZE_CLASSES: Record<NavigableSelectSize, string>;
|
|
12
|
+
/** Option size classes */
|
|
13
|
+
export declare const OPTION_SIZE_CLASSES: Record<NavigableSelectSize, string>;
|
|
14
|
+
/** Tag size classes (multi-select chips) */
|
|
15
|
+
export declare const TAG_SIZE_CLASSES: Record<NavigableSelectSize, string>;
|
|
16
|
+
/** Dropdown z-index */
|
|
17
|
+
export declare const DROPDOWN_Z_INDEX = 50;
|
|
18
|
+
/** Search input debounce delay */
|
|
19
|
+
export declare const SEARCH_DEBOUNCE = 0;
|
|
20
|
+
/** Scroll into view block setting */
|
|
21
|
+
export declare const SCROLL_BLOCK: "nearest";
|
|
22
|
+
/** Icon size per component size */
|
|
23
|
+
export declare const ICON_SIZE: Record<NavigableSelectSize, string>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const e = "Select an option...", a = "No options found", b = 8, r = {
|
|
2
|
+
sm: 32,
|
|
3
|
+
md: 40,
|
|
4
|
+
lg: 48
|
|
5
|
+
}, t = {
|
|
6
|
+
sm: "bear-h-8 bear-text-sm bear-px-2.5",
|
|
7
|
+
md: "bear-h-10 bear-text-sm bear-px-3",
|
|
8
|
+
lg: "bear-h-12 bear-text-base bear-px-4"
|
|
9
|
+
}, s = {
|
|
10
|
+
sm: "bear-px-2.5 bear-py-1.5 bear-text-sm",
|
|
11
|
+
md: "bear-px-3 bear-py-2 bear-text-sm",
|
|
12
|
+
lg: "bear-px-4 bear-py-2.5 bear-text-base"
|
|
13
|
+
}, x = {
|
|
14
|
+
sm: "bear-text-xs bear-px-1.5 bear-py-0.5",
|
|
15
|
+
md: "bear-text-xs bear-px-2 bear-py-0.5",
|
|
16
|
+
lg: "bear-text-sm bear-px-2 bear-py-1"
|
|
17
|
+
}, p = 50, E = "nearest", o = {
|
|
18
|
+
sm: "bear-w-3.5 bear-h-3.5",
|
|
19
|
+
md: "bear-w-4 bear-h-4",
|
|
20
|
+
lg: "bear-w-5 bear-h-5"
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
a as DEFAULT_EMPTY_TEXT,
|
|
24
|
+
b as DEFAULT_MAX_VISIBLE,
|
|
25
|
+
e as DEFAULT_PLACEHOLDER,
|
|
26
|
+
p as DROPDOWN_Z_INDEX,
|
|
27
|
+
o as ICON_SIZE,
|
|
28
|
+
r as OPTION_HEIGHT,
|
|
29
|
+
s as OPTION_SIZE_CLASSES,
|
|
30
|
+
E as SCROLL_BLOCK,
|
|
31
|
+
x as TAG_SIZE_CLASSES,
|
|
32
|
+
t as TRIGGER_SIZE_CLASSES
|
|
33
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { NavigableSelectProps } from './NavigableSelect.types';
|
|
3
|
+
/**
|
|
4
|
+
* NavigableSelect - Keyboard-navigable select with single and multi-select.
|
|
5
|
+
* Arrow up/down navigation, Enter to select, type-ahead search, and theming via BearProvider.
|
|
6
|
+
*/
|
|
7
|
+
export declare const NavigableSelect: FC<NavigableSelectProps>;
|
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
import { jsxs as l, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { useState as S, useRef as B, useMemo as V, useEffect as X, useCallback as f } from "react";
|
|
3
|
+
import { cn as s } from "../../utils/cn.js";
|
|
4
|
+
import { DEFAULT_PLACEHOLDER as pe, DEFAULT_MAX_VISIBLE as fe, DEFAULT_EMPTY_TEXT as me, SCROLL_BLOCK as xe, TAG_SIZE_CLASSES as ye, ICON_SIZE as he, TRIGGER_SIZE_CLASSES as ve, DROPDOWN_Z_INDEX as ke, OPTION_SIZE_CLASSES as Ne, OPTION_HEIGHT as _e } from "./NavigableSelect.const.js";
|
|
5
|
+
const Le = (q) => {
|
|
6
|
+
const {
|
|
7
|
+
options: _,
|
|
8
|
+
value: j,
|
|
9
|
+
defaultValue: Y,
|
|
10
|
+
onChange: o,
|
|
11
|
+
multiple: n = !1,
|
|
12
|
+
searchable: $ = !0,
|
|
13
|
+
placeholder: J = pe,
|
|
14
|
+
label: H,
|
|
15
|
+
helperText: P,
|
|
16
|
+
error: w,
|
|
17
|
+
disabled: m = !1,
|
|
18
|
+
size: x = "md",
|
|
19
|
+
fullWidth: Q = !1,
|
|
20
|
+
maxVisible: ee = fe,
|
|
21
|
+
maxSelections: E,
|
|
22
|
+
emptyText: re = me,
|
|
23
|
+
className: ae,
|
|
24
|
+
style: te,
|
|
25
|
+
testId: le
|
|
26
|
+
} = q, y = j !== void 0, W = (e) => e === void 0 ? [] : Array.isArray(e) ? e : [e], [be, F] = S(W(Y)), [g, L] = S(!1), [c, i] = S(-1), [u, C] = S(""), I = B(null), D = B(null), U = B(null), Z = B(null), b = y ? W(j) : be, h = V(() => {
|
|
27
|
+
if (!u) return _;
|
|
28
|
+
const e = u.toLowerCase();
|
|
29
|
+
return _.filter(
|
|
30
|
+
(r) => {
|
|
31
|
+
var t;
|
|
32
|
+
return r.label.toLowerCase().includes(e) || ((t = r.description) == null ? void 0 : t.toLowerCase().includes(e));
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
}, [_, u]), ne = V(() => {
|
|
36
|
+
const e = /* @__PURE__ */ new Map();
|
|
37
|
+
return h.forEach((r) => {
|
|
38
|
+
const t = r.group || "";
|
|
39
|
+
e.has(t) || e.set(t, []), e.get(t).push(r);
|
|
40
|
+
}), e;
|
|
41
|
+
}, [h]), v = V(() => h.filter((e) => !e.disabled), [h]);
|
|
42
|
+
X(() => {
|
|
43
|
+
const e = (r) => {
|
|
44
|
+
I.current && !I.current.contains(r.target) && (L(!1), C(""));
|
|
45
|
+
};
|
|
46
|
+
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
47
|
+
}, []), X(() => {
|
|
48
|
+
if (!D.current || c < 0) return;
|
|
49
|
+
const e = D.current.querySelector('[data-active="true"]');
|
|
50
|
+
e == null || e.scrollIntoView({ block: xe });
|
|
51
|
+
}, [c]);
|
|
52
|
+
const A = f(() => {
|
|
53
|
+
m || (L(!0), i(0), setTimeout(() => {
|
|
54
|
+
var e;
|
|
55
|
+
return (e = U.current) == null ? void 0 : e.focus();
|
|
56
|
+
}, 0));
|
|
57
|
+
}, [m]), k = f(() => {
|
|
58
|
+
var e;
|
|
59
|
+
L(!1), C(""), i(-1), (e = Z.current) == null || e.focus();
|
|
60
|
+
}, []), T = f(
|
|
61
|
+
(e) => {
|
|
62
|
+
let r;
|
|
63
|
+
if (n)
|
|
64
|
+
if (b.includes(e))
|
|
65
|
+
r = b.filter((t) => t !== e);
|
|
66
|
+
else {
|
|
67
|
+
if (E && b.length >= E) return;
|
|
68
|
+
r = [...b, e];
|
|
69
|
+
}
|
|
70
|
+
else
|
|
71
|
+
r = [e], k();
|
|
72
|
+
y || F(r), o == null || o(n ? r : r[0] ?? "");
|
|
73
|
+
},
|
|
74
|
+
[b, n, y, E, o, k]
|
|
75
|
+
), O = f(
|
|
76
|
+
(e) => {
|
|
77
|
+
const r = b.filter((t) => t !== e);
|
|
78
|
+
y || F(r), o == null || o(n ? r : r[0] ?? "");
|
|
79
|
+
},
|
|
80
|
+
[b, n, y, o]
|
|
81
|
+
), G = f(
|
|
82
|
+
(e) => {
|
|
83
|
+
if (!g) {
|
|
84
|
+
(e.key === "ArrowDown" || e.key === "ArrowUp" || e.key === "Enter" || e.key === " ") && (e.preventDefault(), A());
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
switch (e.key) {
|
|
88
|
+
case "ArrowDown":
|
|
89
|
+
e.preventDefault(), i((r) => Math.min(r + 1, v.length - 1));
|
|
90
|
+
break;
|
|
91
|
+
case "ArrowUp":
|
|
92
|
+
e.preventDefault(), i((r) => Math.max(r - 1, 0));
|
|
93
|
+
break;
|
|
94
|
+
case "Enter":
|
|
95
|
+
case " ":
|
|
96
|
+
e.preventDefault(), c >= 0 && v[c] && T(v[c].value);
|
|
97
|
+
break;
|
|
98
|
+
case "Escape":
|
|
99
|
+
e.preventDefault(), k();
|
|
100
|
+
break;
|
|
101
|
+
case "Backspace":
|
|
102
|
+
u === "" && n && b.length > 0 && O(b[b.length - 1]);
|
|
103
|
+
break;
|
|
104
|
+
case "Home":
|
|
105
|
+
e.preventDefault(), i(0);
|
|
106
|
+
break;
|
|
107
|
+
case "End":
|
|
108
|
+
e.preventDefault(), i(v.length - 1);
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
[g, c, v, T, k, A, u, n, b, O]
|
|
113
|
+
), se = f((e) => b.includes(e), [b]), d = b.map((e) => _.find((r) => r.value === e)).filter(Boolean), oe = !!w, ie = ve[x], ce = Ne[x], de = ye[x], K = he[x], ge = ee * _e[x];
|
|
114
|
+
let R = -1;
|
|
115
|
+
return /* @__PURE__ */ l(
|
|
116
|
+
"div",
|
|
117
|
+
{
|
|
118
|
+
ref: I,
|
|
119
|
+
className: s(
|
|
120
|
+
"Bear-NavigableSelect",
|
|
121
|
+
"bear-relative bear-flex bear-flex-col bear-gap-1.5",
|
|
122
|
+
Q && "bear-w-full",
|
|
123
|
+
ae
|
|
124
|
+
),
|
|
125
|
+
style: te,
|
|
126
|
+
"data-testid": le,
|
|
127
|
+
children: [
|
|
128
|
+
H && /* @__PURE__ */ a("label", { className: "Bear-NavigableSelect__label bear-text-sm bear-font-medium bear-text-gray-700 dark:bear-text-gray-300", children: H }),
|
|
129
|
+
/* @__PURE__ */ l(
|
|
130
|
+
"button",
|
|
131
|
+
{
|
|
132
|
+
ref: Z,
|
|
133
|
+
type: "button",
|
|
134
|
+
disabled: m,
|
|
135
|
+
onClick: () => g ? k() : A(),
|
|
136
|
+
onKeyDown: G,
|
|
137
|
+
className: s(
|
|
138
|
+
"Bear-NavigableSelect__trigger",
|
|
139
|
+
"bear-flex bear-items-center bear-justify-between bear-w-full",
|
|
140
|
+
"bear-rounded-lg bear-border bear-text-left bear-outline-none",
|
|
141
|
+
"bear-transition-all bear-duration-200",
|
|
142
|
+
"bear-bg-white dark:bear-bg-gray-900",
|
|
143
|
+
"bear-text-gray-900 dark:bear-text-white",
|
|
144
|
+
oe ? "bear-border-red-500 focus:bear-ring-2 focus:bear-ring-red-500/20" : "bear-border-gray-300 dark:bear-border-gray-600 focus:bear-border-[var(--bear-primary-500)] focus:bear-ring-2 focus:bear-ring-[var(--bear-primary-500)]/20",
|
|
145
|
+
m && "bear-opacity-50 bear-cursor-not-allowed",
|
|
146
|
+
ie
|
|
147
|
+
),
|
|
148
|
+
"aria-haspopup": "listbox",
|
|
149
|
+
"aria-expanded": g,
|
|
150
|
+
children: [
|
|
151
|
+
/* @__PURE__ */ l("span", { className: "Bear-NavigableSelect__value bear-flex bear-items-center bear-gap-1.5 bear-flex-wrap bear-flex-1 bear-min-w-0 bear-overflow-hidden", children: [
|
|
152
|
+
n && d.length > 0 && d.map((e) => /* @__PURE__ */ l(
|
|
153
|
+
"span",
|
|
154
|
+
{
|
|
155
|
+
className: s(
|
|
156
|
+
"Bear-NavigableSelect__tag",
|
|
157
|
+
"bear-inline-flex bear-items-center bear-gap-1 bear-rounded-md",
|
|
158
|
+
"bear-bg-[var(--bear-primary-100,#fce7f3)] dark:bear-bg-[var(--bear-primary-900,#831843)]/30",
|
|
159
|
+
"bear-text-[var(--bear-primary-700,#be185d)] dark:bear-text-[var(--bear-primary-300,#f9a8d4)]",
|
|
160
|
+
de
|
|
161
|
+
),
|
|
162
|
+
children: [
|
|
163
|
+
e.label,
|
|
164
|
+
!m && /* @__PURE__ */ a(
|
|
165
|
+
"button",
|
|
166
|
+
{
|
|
167
|
+
type: "button",
|
|
168
|
+
onClick: (r) => {
|
|
169
|
+
r.stopPropagation(), O(e.value);
|
|
170
|
+
},
|
|
171
|
+
className: "bear-ml-0.5 hover:bear-opacity-70",
|
|
172
|
+
"aria-label": `Remove ${e.label}`,
|
|
173
|
+
children: "×"
|
|
174
|
+
}
|
|
175
|
+
)
|
|
176
|
+
]
|
|
177
|
+
},
|
|
178
|
+
e.value
|
|
179
|
+
)),
|
|
180
|
+
!n && d.length > 0 && /* @__PURE__ */ l("span", { className: "bear-truncate", children: [
|
|
181
|
+
d[0].icon && /* @__PURE__ */ a("span", { className: "bear-mr-1.5", children: d[0].icon }),
|
|
182
|
+
d[0].label
|
|
183
|
+
] }),
|
|
184
|
+
d.length === 0 && /* @__PURE__ */ a("span", { className: "bear-text-gray-400 dark:bear-text-gray-500", children: J })
|
|
185
|
+
] }),
|
|
186
|
+
/* @__PURE__ */ a(
|
|
187
|
+
"svg",
|
|
188
|
+
{
|
|
189
|
+
className: s(
|
|
190
|
+
K,
|
|
191
|
+
"bear-text-gray-400 dark:bear-text-gray-500 bear-transition-transform bear-shrink-0 bear-ml-2",
|
|
192
|
+
g && "bear-rotate-180"
|
|
193
|
+
),
|
|
194
|
+
fill: "none",
|
|
195
|
+
viewBox: "0 0 24 24",
|
|
196
|
+
stroke: "currentColor",
|
|
197
|
+
strokeWidth: 2,
|
|
198
|
+
children: /* @__PURE__ */ a("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19 9l-7 7-7-7" })
|
|
199
|
+
}
|
|
200
|
+
)
|
|
201
|
+
]
|
|
202
|
+
}
|
|
203
|
+
),
|
|
204
|
+
g && /* @__PURE__ */ l(
|
|
205
|
+
"div",
|
|
206
|
+
{
|
|
207
|
+
className: s(
|
|
208
|
+
"Bear-NavigableSelect__dropdown",
|
|
209
|
+
"bear-absolute bear-top-full bear-left-0 bear-w-full bear-mt-1",
|
|
210
|
+
"bear-bg-white dark:bear-bg-gray-900",
|
|
211
|
+
"bear-border bear-border-gray-200 dark:bear-border-gray-700",
|
|
212
|
+
"bear-rounded-lg bear-shadow-lg bear-overflow-hidden"
|
|
213
|
+
),
|
|
214
|
+
style: { zIndex: ke },
|
|
215
|
+
children: [
|
|
216
|
+
$ && /* @__PURE__ */ l("div", { className: "Bear-NavigableSelect__search bear-flex bear-items-center bear-gap-2 bear-px-3 bear-py-2 bear-border-b bear-border-gray-200 dark:bear-border-gray-700", children: [
|
|
217
|
+
/* @__PURE__ */ l(
|
|
218
|
+
"svg",
|
|
219
|
+
{
|
|
220
|
+
className: "bear-w-4 bear-h-4 bear-text-gray-400 dark:bear-text-gray-500 bear-shrink-0",
|
|
221
|
+
fill: "none",
|
|
222
|
+
viewBox: "0 0 24 24",
|
|
223
|
+
stroke: "currentColor",
|
|
224
|
+
strokeWidth: 2,
|
|
225
|
+
children: [
|
|
226
|
+
/* @__PURE__ */ a("circle", { cx: "11", cy: "11", r: "8" }),
|
|
227
|
+
/* @__PURE__ */ a("line", { x1: "21", y1: "21", x2: "16.65", y2: "16.65" })
|
|
228
|
+
]
|
|
229
|
+
}
|
|
230
|
+
),
|
|
231
|
+
/* @__PURE__ */ a(
|
|
232
|
+
"input",
|
|
233
|
+
{
|
|
234
|
+
ref: U,
|
|
235
|
+
type: "text",
|
|
236
|
+
value: u,
|
|
237
|
+
onChange: (e) => {
|
|
238
|
+
C(e.target.value), i(0);
|
|
239
|
+
},
|
|
240
|
+
onKeyDown: G,
|
|
241
|
+
placeholder: "Type to search...",
|
|
242
|
+
className: s(
|
|
243
|
+
"Bear-NavigableSelect__input",
|
|
244
|
+
"bear-flex-1 bear-bg-transparent bear-outline-none bear-text-sm",
|
|
245
|
+
"bear-text-gray-900 dark:bear-text-white",
|
|
246
|
+
"placeholder:bear-text-gray-400 dark:placeholder:bear-text-gray-500"
|
|
247
|
+
),
|
|
248
|
+
autoComplete: "off",
|
|
249
|
+
spellCheck: !1
|
|
250
|
+
}
|
|
251
|
+
)
|
|
252
|
+
] }),
|
|
253
|
+
/* @__PURE__ */ l(
|
|
254
|
+
"div",
|
|
255
|
+
{
|
|
256
|
+
ref: D,
|
|
257
|
+
className: "Bear-NavigableSelect__list bear-overflow-y-auto bear-py-1",
|
|
258
|
+
style: { maxHeight: ge },
|
|
259
|
+
role: "listbox",
|
|
260
|
+
"aria-multiselectable": n,
|
|
261
|
+
children: [
|
|
262
|
+
h.length === 0 && /* @__PURE__ */ a("div", { className: "Bear-NavigableSelect__empty bear-px-3 bear-py-4 bear-text-center bear-text-sm bear-text-gray-500 dark:bear-text-gray-400", children: re }),
|
|
263
|
+
Array.from(ne.entries()).map(([e, r]) => /* @__PURE__ */ l("div", { className: "Bear-NavigableSelect__group", children: [
|
|
264
|
+
e && /* @__PURE__ */ a("div", { className: "Bear-NavigableSelect__group-title bear-px-3 bear-py-1 bear-text-xs bear-font-semibold bear-uppercase bear-tracking-wider bear-text-gray-400 dark:bear-text-gray-500", children: e }),
|
|
265
|
+
r.map((t) => {
|
|
266
|
+
const N = t.disabled, z = !N;
|
|
267
|
+
z && R++;
|
|
268
|
+
const M = R === c, p = se(t.value), ue = R;
|
|
269
|
+
return /* @__PURE__ */ l(
|
|
270
|
+
"button",
|
|
271
|
+
{
|
|
272
|
+
type: "button",
|
|
273
|
+
disabled: N,
|
|
274
|
+
className: s(
|
|
275
|
+
"Bear-NavigableSelect__option",
|
|
276
|
+
"bear-w-full bear-flex bear-items-center bear-gap-2.5 bear-text-left bear-cursor-pointer",
|
|
277
|
+
"bear-transition-colors bear-duration-100",
|
|
278
|
+
ce,
|
|
279
|
+
M && "bear-bg-gray-100 dark:bear-bg-gray-800",
|
|
280
|
+
p && !M && "bear-bg-[var(--bear-primary-50,#fdf2f8)] dark:bear-bg-[var(--bear-primary-950,#500724)]/20",
|
|
281
|
+
N && "bear-opacity-40 bear-cursor-not-allowed"
|
|
282
|
+
),
|
|
283
|
+
"data-active": M,
|
|
284
|
+
onMouseEnter: () => {
|
|
285
|
+
z && i(ue);
|
|
286
|
+
},
|
|
287
|
+
onClick: () => {
|
|
288
|
+
N || T(t.value);
|
|
289
|
+
},
|
|
290
|
+
role: "option",
|
|
291
|
+
"aria-selected": p,
|
|
292
|
+
"aria-disabled": N,
|
|
293
|
+
children: [
|
|
294
|
+
n && /* @__PURE__ */ a(
|
|
295
|
+
"span",
|
|
296
|
+
{
|
|
297
|
+
className: s(
|
|
298
|
+
"Bear-NavigableSelect__checkbox",
|
|
299
|
+
"bear-flex bear-items-center bear-justify-center bear-w-4 bear-h-4 bear-rounded bear-border bear-shrink-0",
|
|
300
|
+
"bear-transition-colors",
|
|
301
|
+
p ? "bear-bg-[var(--bear-primary-500)] bear-border-[var(--bear-primary-500)] bear-text-white" : "bear-border-gray-300 dark:bear-border-gray-600"
|
|
302
|
+
),
|
|
303
|
+
children: p && /* @__PURE__ */ a("svg", { className: "bear-w-3 bear-h-3", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: 3, children: /* @__PURE__ */ a("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M5 13l4 4L19 7" }) })
|
|
304
|
+
}
|
|
305
|
+
),
|
|
306
|
+
t.icon && /* @__PURE__ */ a("span", { className: "Bear-NavigableSelect__option-icon bear-shrink-0 bear-text-gray-500 dark:bear-text-gray-400", children: t.icon }),
|
|
307
|
+
/* @__PURE__ */ l("div", { className: "Bear-NavigableSelect__option-body bear-flex-1 bear-min-w-0", children: [
|
|
308
|
+
/* @__PURE__ */ a("div", { className: s(
|
|
309
|
+
"Bear-NavigableSelect__option-label bear-truncate",
|
|
310
|
+
p ? "bear-text-[var(--bear-primary-700,#be185d)] dark:bear-text-[var(--bear-primary-300,#f9a8d4)] bear-font-medium" : "bear-text-gray-900 dark:bear-text-white"
|
|
311
|
+
), children: t.label }),
|
|
312
|
+
t.description && /* @__PURE__ */ a("div", { className: "Bear-NavigableSelect__option-desc bear-text-xs bear-text-gray-500 dark:bear-text-gray-400 bear-truncate", children: t.description })
|
|
313
|
+
] }),
|
|
314
|
+
!n && p && /* @__PURE__ */ a(
|
|
315
|
+
"svg",
|
|
316
|
+
{
|
|
317
|
+
className: s(K, "bear-text-[var(--bear-primary-500)] bear-shrink-0"),
|
|
318
|
+
fill: "none",
|
|
319
|
+
viewBox: "0 0 24 24",
|
|
320
|
+
stroke: "currentColor",
|
|
321
|
+
strokeWidth: 2,
|
|
322
|
+
children: /* @__PURE__ */ a("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M5 13l4 4L19 7" })
|
|
323
|
+
}
|
|
324
|
+
)
|
|
325
|
+
]
|
|
326
|
+
},
|
|
327
|
+
t.value
|
|
328
|
+
);
|
|
329
|
+
})
|
|
330
|
+
] }, e))
|
|
331
|
+
]
|
|
332
|
+
}
|
|
333
|
+
),
|
|
334
|
+
/* @__PURE__ */ l("div", { className: "Bear-NavigableSelect__footer bear-flex bear-items-center bear-gap-3 bear-px-3 bear-py-1.5 bear-border-t bear-border-gray-200 dark:bear-border-gray-700 bear-text-[11px] bear-text-gray-400 dark:bear-text-gray-500", children: [
|
|
335
|
+
/* @__PURE__ */ l("span", { className: "bear-flex bear-items-center bear-gap-1", children: [
|
|
336
|
+
/* @__PURE__ */ a("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: "↑↓" }),
|
|
337
|
+
"navigate"
|
|
338
|
+
] }),
|
|
339
|
+
/* @__PURE__ */ l("span", { className: "bear-flex bear-items-center bear-gap-1", children: [
|
|
340
|
+
/* @__PURE__ */ a("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: "↵" }),
|
|
341
|
+
"select"
|
|
342
|
+
] }),
|
|
343
|
+
/* @__PURE__ */ l("span", { className: "bear-flex bear-items-center bear-gap-1", children: [
|
|
344
|
+
/* @__PURE__ */ a("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" }),
|
|
345
|
+
"close"
|
|
346
|
+
] })
|
|
347
|
+
] })
|
|
348
|
+
]
|
|
349
|
+
}
|
|
350
|
+
),
|
|
351
|
+
(P || w) && /* @__PURE__ */ a("p", { className: s(
|
|
352
|
+
"Bear-NavigableSelect__helper bear-text-xs",
|
|
353
|
+
w ? "bear-text-red-500" : "bear-text-gray-500 dark:bear-text-gray-400"
|
|
354
|
+
), children: w || P })
|
|
355
|
+
]
|
|
356
|
+
}
|
|
357
|
+
);
|
|
358
|
+
};
|
|
359
|
+
export {
|
|
360
|
+
Le as NavigableSelect
|
|
361
|
+
};
|