@forgedevstack/bear 1.0.8 → 1.1.0
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 +11 -1
- 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/Button/Button.cjs +1 -1
- package/dist/components/Button/Button.js +56 -55
- package/dist/components/Button/Button.types.d.ts +7 -0
- 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/FileTree/FileTree.cjs +1 -0
- package/dist/components/FileTree/FileTree.d.ts +3 -0
- package/dist/components/FileTree/FileTree.js +46 -0
- package/dist/components/FileTree/FileTree.types.d.ts +30 -0
- package/dist/components/FileTree/index.d.ts +2 -0
- 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/ResizablePanel/ResizablePanel.cjs +1 -0
- package/dist/components/ResizablePanel/ResizablePanel.const.cjs +1 -0
- package/dist/components/ResizablePanel/ResizablePanel.const.d.ts +11 -0
- package/dist/components/ResizablePanel/ResizablePanel.const.js +11 -0
- package/dist/components/ResizablePanel/ResizablePanel.d.ts +17 -0
- package/dist/components/ResizablePanel/ResizablePanel.js +70 -0
- package/dist/components/ResizablePanel/ResizablePanel.types.d.ts +21 -0
- package/dist/components/ResizablePanel/ResizablePanel.utils.cjs +1 -0
- package/dist/components/ResizablePanel/ResizablePanel.utils.d.ts +10 -0
- package/dist/components/ResizablePanel/ResizablePanel.utils.js +11 -0
- package/dist/components/ResizablePanel/index.d.ts +2 -0
- package/dist/components/ResizableTextarea/ResizableTextarea.cjs +1 -0
- package/dist/components/ResizableTextarea/ResizableTextarea.const.cjs +1 -0
- package/dist/components/ResizableTextarea/ResizableTextarea.const.d.ts +2 -0
- package/dist/components/ResizableTextarea/ResizableTextarea.const.js +5 -0
- package/dist/components/ResizableTextarea/ResizableTextarea.d.ts +3 -0
- package/dist/components/ResizableTextarea/ResizableTextarea.js +60 -0
- package/dist/components/ResizableTextarea/ResizableTextarea.types.d.ts +15 -0
- package/dist/components/ResizableTextarea/index.d.ts +2 -0
- 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/Typography/Typography.cjs +1 -1
- package/dist/components/Typography/Typography.const.cjs +1 -0
- package/dist/components/Typography/Typography.const.d.ts +22 -0
- package/dist/components/Typography/Typography.const.js +91 -0
- package/dist/components/Typography/Typography.js +75 -138
- package/dist/components/Typography/Typography.types.d.ts +17 -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 +33 -1
- package/dist/components/index.js +270 -237
- 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 +335 -295
- 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 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export type NavigableSelectSize = 'sm' | 'md' | 'lg';
|
|
3
|
+
export interface NavigableSelectOption {
|
|
4
|
+
/** Unique option value */
|
|
5
|
+
value: string;
|
|
6
|
+
/** Display label */
|
|
7
|
+
label: string;
|
|
8
|
+
/** Optional description */
|
|
9
|
+
description?: string;
|
|
10
|
+
/** Optional icon */
|
|
11
|
+
icon?: ReactNode;
|
|
12
|
+
/** Whether option is disabled */
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
/** Optional group name */
|
|
15
|
+
group?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface NavigableSelectProps {
|
|
18
|
+
/** Available options */
|
|
19
|
+
options: NavigableSelectOption[];
|
|
20
|
+
/** Selected value(s) — string for single, string[] for multiple */
|
|
21
|
+
value?: string | string[];
|
|
22
|
+
/** Default value (uncontrolled) */
|
|
23
|
+
defaultValue?: string | string[];
|
|
24
|
+
/** Called when selection changes */
|
|
25
|
+
onChange?: (value: string | string[]) => void;
|
|
26
|
+
/** Allow multiple selections */
|
|
27
|
+
multiple?: boolean;
|
|
28
|
+
/** Enable search/filter */
|
|
29
|
+
searchable?: boolean;
|
|
30
|
+
/** Placeholder text */
|
|
31
|
+
placeholder?: string;
|
|
32
|
+
/** Label text */
|
|
33
|
+
label?: string;
|
|
34
|
+
/** Helper text */
|
|
35
|
+
helperText?: string;
|
|
36
|
+
/** Error message */
|
|
37
|
+
error?: string;
|
|
38
|
+
/** Whether select is disabled */
|
|
39
|
+
disabled?: boolean;
|
|
40
|
+
/** Component size */
|
|
41
|
+
size?: NavigableSelectSize;
|
|
42
|
+
/** Whether select is full width */
|
|
43
|
+
fullWidth?: boolean;
|
|
44
|
+
/** Maximum visible options before scrolling */
|
|
45
|
+
maxVisible?: number;
|
|
46
|
+
/** Maximum selections in multiple mode */
|
|
47
|
+
maxSelections?: number;
|
|
48
|
+
/** Empty state text */
|
|
49
|
+
emptyText?: string;
|
|
50
|
+
/** Custom class name */
|
|
51
|
+
className?: string;
|
|
52
|
+
/** Custom style */
|
|
53
|
+
style?: React.CSSProperties;
|
|
54
|
+
/** Test ID */
|
|
55
|
+
testId?: string;
|
|
56
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("../../utils/cn.cjs")
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("../../utils/cn.cjs");require("react");const m={sm:"bear-h-1.5",md:"bear-h-2.5",lg:"bear-h-4"},f={default:"bear-bg-pink-500",success:"bear-bg-green-500",warning:"bear-bg-yellow-500",danger:"bear-bg-red-500",info:"bear-bg-blue-500"},x=({value:n,max:b=100,size:l="md",color:o="default",showLabel:i=!1,labelPosition:d="outside",striped:r=!1,animated:c=!1,indeterminate:a=!1,className:g,testId:u})=>{const s=Math.min(100,Math.max(0,n/b*100));return e.jsxs("div",{className:t.cn("bear-w-full",g),"data-testid":u,children:[i&&d==="outside"&&e.jsxs("div",{className:"bear-flex bear-justify-between bear-mb-1",children:[e.jsx("span",{className:"bear-text-sm bear-font-medium bear-text-gray-700 dark:bear-text-gray-200",children:"Progress"}),e.jsxs("span",{className:"bear-text-sm bear-font-medium bear-text-gray-700 dark:bear-text-gray-200",children:[Math.round(s),"%"]})]}),e.jsx("div",{className:t.cn("bear-w-full bear-bg-gray-200 dark:bear-bg-gray-700 bear-rounded-full bear-overflow-hidden",m[l]),children:e.jsx("div",{className:t.cn("bear-h-full bear-rounded-full bear-transition-all bear-duration-300 bear-ease-out","bear-flex bear-items-center bear-justify-center",f[o],r&&"bear-bg-stripes",c&&"bear-animate-stripes",a&&"bear-animate-indeterminate"),style:{width:a?"50%":`${s}%`,backgroundSize:r?"1rem 1rem":void 0,backgroundImage:r?"linear-gradient(45deg, rgba(255,255,255,.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.15) 50%, rgba(255,255,255,.15) 75%, transparent 75%, transparent)":void 0},role:"progressbar","aria-valuenow":a?void 0:n,"aria-valuemin":0,"aria-valuemax":b,children:i&&d==="inside"&&l==="lg"&&!a&&e.jsxs("span",{className:"bear-text-xs bear-font-medium bear-text-white",children:[Math.round(s),"%"]})})})]})};exports.Progress=x;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsxs as a, jsx as t } from "react/jsx-runtime";
|
|
2
2
|
import { cn as b } from "../../utils/cn.js";
|
|
3
|
+
import "react";
|
|
3
4
|
const f = {
|
|
4
5
|
sm: "bear-h-1.5",
|
|
5
6
|
md: "bear-h-2.5",
|
|
@@ -10,7 +11,7 @@ const f = {
|
|
|
10
11
|
warning: "bear-bg-yellow-500",
|
|
11
12
|
danger: "bear-bg-red-500",
|
|
12
13
|
info: "bear-bg-blue-500"
|
|
13
|
-
},
|
|
14
|
+
}, y = ({
|
|
14
15
|
value: n,
|
|
15
16
|
max: l = 100,
|
|
16
17
|
size: d = "md",
|
|
@@ -70,5 +71,5 @@ const f = {
|
|
|
70
71
|
] });
|
|
71
72
|
};
|
|
72
73
|
export {
|
|
73
|
-
|
|
74
|
+
y as Progress
|
|
74
75
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),l=require("react"),e=require("./ResizablePanel.const.cjs"),v=require("./ResizablePanel.utils.cjs"),_=require("../../utils/cn.cjs"),L=P=>{const{first:I,second:N,direction:c=e.DEFAULT_DIRECTION,defaultSize:R=e.DEFAULT_FIRST_SIZE,minSize:d=e.MIN_SIZE,maxSize:b=e.MAX_SIZE,onResize:s,className:z,testId:T}=P,[t,g]=l.useState(R),u=l.useRef(null),h=l.useCallback(r=>v.clampSize(r,d,b),[d,b]),S=l.useCallback(r=>{var m;r.preventDefault();const n=r.target;(m=n.setPointerCapture)==null||m.call(n,r.pointerId);const E=i=>{if(!u.current)return;const D=u.current.getBoundingClientRect(),y=v.getResizePercentage(D,c,i.clientX,i.clientY),f=h(y);g(f),s==null||s(f)},w=()=>{var i;(i=n.releasePointerCapture)==null||i.call(n,r.pointerId),window.removeEventListener(e.EVENT_POINTER_MOVE,E),window.removeEventListener(e.EVENT_POINTER_UP,w)};window.addEventListener(e.EVENT_POINTER_MOVE,E),window.addEventListener(e.EVENT_POINTER_UP,w)},[c,h,s]),a=c==="horizontal",p=a?{width:`${t}%`,minWidth:0}:{height:`${t}%`,minHeight:0},x=a?{width:`${100-t}%`,minWidth:0}:{height:`${100-t}%`,minHeight:0};return o.jsxs("div",{ref:u,"data-testid":T,className:_.cn("Bear-ResizablePanel bear-flex bear-w-full bear-h-full bear-overflow-hidden",a?"bear-flex-row":"bear-flex-col",z),children:[o.jsx("div",{className:"bear-overflow-auto bear-shrink-0",style:p,children:I}),o.jsx("div",{role:"separator","aria-valuenow":t,"aria-valuemin":d,"aria-valuemax":b,tabIndex:0,onPointerDown:S,className:_.cn("Bear-ResizablePanel__handle bear-shrink-0 bear-bg-gray-200 dark:bear-bg-gray-700 hover:bear-bg-pink-500/30 bear-transition-colors bear-cursor-col-resize",a?"bear-w-1.5":"bear-h-1.5 bear-w-full bear-cursor-row-resize"),style:a?{width:e.HANDLE_WIDTH}:{height:e.HANDLE_WIDTH}}),o.jsx("div",{className:"bear-overflow-auto bear-shrink-0 bear-flex-1",style:x,children:N})]})};exports.ResizablePanel=L;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=50,_=10,T=90,I=6,o="horizontal",t="pointermove",N="pointerup",n=100;exports.DEFAULT_DIRECTION=o;exports.DEFAULT_FIRST_SIZE=E;exports.EVENT_POINTER_MOVE=t;exports.EVENT_POINTER_UP=N;exports.HANDLE_WIDTH=I;exports.MAX_SIZE=T;exports.MIN_SIZE=_;exports.PERCENTAGE_SCALE=n;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const DEFAULT_FIRST_SIZE = 50;
|
|
2
|
+
export declare const MIN_SIZE = 10;
|
|
3
|
+
export declare const MAX_SIZE = 90;
|
|
4
|
+
export declare const HANDLE_WIDTH = 6;
|
|
5
|
+
/** Default layout direction */
|
|
6
|
+
export declare const DEFAULT_DIRECTION = "horizontal";
|
|
7
|
+
/** DOM event names for resize listeners */
|
|
8
|
+
export declare const EVENT_POINTER_MOVE = "pointermove";
|
|
9
|
+
export declare const EVENT_POINTER_UP = "pointerup";
|
|
10
|
+
/** Percentage scale for size calculation */
|
|
11
|
+
export declare const PERCENTAGE_SCALE = 100;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const E = 50, o = 10, t = 90, n = 6, _ = "horizontal", I = "pointermove", T = "pointerup", c = 100;
|
|
2
|
+
export {
|
|
3
|
+
_ as DEFAULT_DIRECTION,
|
|
4
|
+
E as DEFAULT_FIRST_SIZE,
|
|
5
|
+
I as EVENT_POINTER_MOVE,
|
|
6
|
+
T as EVENT_POINTER_UP,
|
|
7
|
+
n as HANDLE_WIDTH,
|
|
8
|
+
t as MAX_SIZE,
|
|
9
|
+
o as MIN_SIZE,
|
|
10
|
+
c as PERCENTAGE_SCALE
|
|
11
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ResizablePanelProps } from './ResizablePanel.types';
|
|
3
|
+
/**
|
|
4
|
+
* Two-pane resizable layout with a draggable divider.
|
|
5
|
+
* Supports horizontal and vertical directions; respects min/max size and dark/light theme.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```tsx
|
|
9
|
+
* <ResizablePanel
|
|
10
|
+
* first={<Sidebar />}
|
|
11
|
+
* second={<Main />}
|
|
12
|
+
* direction="horizontal"
|
|
13
|
+
* defaultSize={30}
|
|
14
|
+
* />
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare const ResizablePanel: FC<ResizablePanelProps>;
|