@forgedevstack/bear 1.2.0 → 1.2.1
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 +4 -0
- package/dist/components/Autocomplete/Autocomplete.cjs +1 -1
- package/dist/components/Autocomplete/Autocomplete.const.cjs +1 -0
- package/dist/components/Autocomplete/Autocomplete.const.d.ts +1 -0
- package/dist/components/Autocomplete/Autocomplete.const.js +4 -0
- package/dist/components/Autocomplete/Autocomplete.js +110 -72
- package/dist/components/BottomSheet/BottomSheet.cjs +1 -1
- package/dist/components/BottomSheet/BottomSheet.js +74 -53
- package/dist/components/BottomSheet/BottomSheet.types.d.ts +2 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.cjs +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.js +126 -46
- package/dist/components/Breadcrumbs/Breadcrumbs.types.d.ts +11 -4
- package/dist/components/Breadcrumbs/index.d.ts +1 -1
- package/dist/components/Cascader/Cascader.cjs +1 -1
- package/dist/components/Cascader/Cascader.const.cjs +1 -1
- package/dist/components/Cascader/Cascader.const.d.ts +1 -1
- package/dist/components/Cascader/Cascader.const.js +1 -1
- package/dist/components/Cascader/Cascader.js +109 -146
- package/dist/components/Cascader/components/CascaderPanel/CascaderPanel.cjs +1 -0
- package/dist/components/Cascader/components/CascaderPanel/CascaderPanel.d.ts +3 -0
- package/dist/components/Cascader/components/CascaderPanel/CascaderPanel.js +50 -0
- package/dist/components/Cascader/components/CascaderPanel/index.d.ts +1 -0
- package/dist/components/Chart/BarChart.cjs +1 -0
- package/dist/components/Chart/BarChart.d.ts +3 -0
- package/dist/components/Chart/BarChart.js +65 -0
- package/dist/components/Chart/Chart.cjs +1 -1
- package/dist/components/Chart/Chart.const.cjs +1 -1
- package/dist/components/Chart/Chart.const.d.ts +7 -0
- package/dist/components/Chart/Chart.const.js +12 -2
- package/dist/components/Chart/Chart.d.ts +1 -13
- package/dist/components/Chart/Chart.js +18 -204
- package/dist/components/Chart/Chart.types.d.ts +7 -1
- package/dist/components/Chart/LineChart.cjs +1 -0
- package/dist/components/Chart/LineChart.d.ts +3 -0
- package/dist/components/Chart/LineChart.js +73 -0
- package/dist/components/Chart/PieChart.cjs +1 -0
- package/dist/components/Chart/PieChart.d.ts +3 -0
- package/dist/components/Chart/PieChart.js +110 -0
- package/dist/components/Chart/index.d.ts +4 -1
- package/dist/components/ColorPicker/ColorPicker.cjs +1 -1
- package/dist/components/ColorPicker/ColorPicker.const.cjs +1 -1
- package/dist/components/ColorPicker/ColorPicker.const.d.ts +4 -2
- package/dist/components/ColorPicker/ColorPicker.const.js +8 -6
- package/dist/components/ColorPicker/ColorPicker.js +135 -73
- package/dist/components/ColorPicker/ColorPicker.utils.cjs +1 -0
- package/dist/components/ColorPicker/ColorPicker.utils.d.ts +17 -0
- package/dist/components/ColorPicker/ColorPicker.utils.js +43 -0
- package/dist/components/CountdownTimer/CountdownTimer.cjs +1 -1
- package/dist/components/CountdownTimer/CountdownTimer.const.cjs +1 -1
- package/dist/components/CountdownTimer/CountdownTimer.const.d.ts +2 -0
- package/dist/components/CountdownTimer/CountdownTimer.const.js +29 -17
- package/dist/components/CountdownTimer/CountdownTimer.js +91 -61
- package/dist/components/CountdownTimer/CountdownTimer.types.d.ts +11 -2
- package/dist/components/CreditInput/CreditInput.cjs +1 -1
- package/dist/components/CreditInput/CreditInput.js +80 -78
- package/dist/components/DateRangePicker/DateRangePicker.cjs +1 -1
- package/dist/components/DateRangePicker/DateRangePicker.js +89 -84
- package/dist/components/DiffSquares/DiffSquares.cjs +1 -0
- package/dist/components/DiffSquares/DiffSquares.const.cjs +1 -0
- package/dist/components/DiffSquares/DiffSquares.const.d.ts +3 -0
- package/dist/components/DiffSquares/DiffSquares.const.js +6 -0
- package/dist/components/DiffSquares/DiffSquares.d.ts +3 -0
- package/dist/components/DiffSquares/DiffSquares.js +70 -0
- package/dist/components/DiffSquares/DiffSquares.types.d.ts +23 -0
- package/dist/components/DiffSquares/DiffSquares.utils.cjs +1 -0
- package/dist/components/DiffSquares/DiffSquares.utils.d.ts +3 -0
- package/dist/components/DiffSquares/DiffSquares.utils.js +12 -0
- package/dist/components/DiffSquares/index.d.ts +2 -0
- package/dist/components/Drawer/Drawer.cjs +1 -1
- package/dist/components/Drawer/Drawer.js +41 -41
- package/dist/components/Dropdown/Dropdown.cjs +1 -1
- package/dist/components/Dropdown/Dropdown.const.cjs +1 -0
- package/dist/components/Dropdown/Dropdown.const.d.ts +7 -0
- package/dist/components/Dropdown/Dropdown.const.js +10 -0
- package/dist/components/Dropdown/Dropdown.d.ts +0 -1
- package/dist/components/Dropdown/Dropdown.js +102 -92
- package/dist/components/Dropdown/Dropdown.types.d.ts +2 -0
- package/dist/components/Gauge/Gauge.cjs +1 -1
- package/dist/components/Gauge/Gauge.js +61 -50
- package/dist/components/Gauge/Gauge.types.d.ts +2 -0
- package/dist/components/HoverCard/HoverCard.cjs +6 -6
- package/dist/components/HoverCard/HoverCard.js +72 -54
- package/dist/components/Icon/icons/status.js +1 -1
- package/dist/components/MentionsInput/MentionsInput.cjs +1 -1
- package/dist/components/MentionsInput/MentionsInput.js +106 -83
- package/dist/components/Menu/Menu.cjs +1 -1
- package/dist/components/Menu/Menu.js +91 -80
- package/dist/components/Modal/Modal.cjs +1 -1
- package/dist/components/Modal/Modal.const.cjs +1 -1
- package/dist/components/Modal/Modal.const.d.ts +1 -1
- package/dist/components/Modal/Modal.const.js +1 -1
- package/dist/components/Modal/Modal.js +50 -44
- package/dist/components/Modal/Modal.types.d.ts +6 -0
- package/dist/components/MultiSelect/MultiSelect.cjs +1 -1
- package/dist/components/MultiSelect/MultiSelect.js +123 -78
- package/dist/components/NavigableSelect/NavigableSelect.cjs +1 -1
- package/dist/components/NavigableSelect/NavigableSelect.const.cjs +1 -1
- package/dist/components/NavigableSelect/NavigableSelect.const.d.ts +1 -1
- package/dist/components/NavigableSelect/NavigableSelect.const.js +1 -1
- package/dist/components/NavigableSelect/NavigableSelect.js +167 -143
- package/dist/components/NotificationCenter/NotificationCenter.cjs +1 -1
- package/dist/components/NotificationCenter/NotificationCenter.const.cjs +1 -1
- package/dist/components/NotificationCenter/NotificationCenter.const.d.ts +1 -1
- package/dist/components/NotificationCenter/NotificationCenter.const.js +1 -1
- package/dist/components/NotificationCenter/NotificationCenter.js +87 -81
- package/dist/components/OTPInput/OTPInput.cjs +1 -1
- package/dist/components/OTPInput/OTPInput.const.cjs +1 -0
- package/dist/components/OTPInput/OTPInput.const.d.ts +6 -0
- package/dist/components/OTPInput/OTPInput.const.js +14 -0
- package/dist/components/OTPInput/OTPInput.js +99 -65
- package/dist/components/OTPInput/OTPInput.types.d.ts +7 -0
- package/dist/components/PhoneInput/PhoneInput.cjs +1 -1
- package/dist/components/PhoneInput/PhoneInput.const.cjs +1 -1
- package/dist/components/PhoneInput/PhoneInput.const.d.ts +1 -1
- package/dist/components/PhoneInput/PhoneInput.const.js +1 -1
- package/dist/components/PhoneInput/PhoneInput.js +88 -83
- package/dist/components/Popconfirm/Popconfirm.cjs +1 -1
- package/dist/components/Popconfirm/Popconfirm.const.cjs +1 -1
- package/dist/components/Popconfirm/Popconfirm.const.d.ts +1 -3
- package/dist/components/Popconfirm/Popconfirm.const.js +12 -18
- package/dist/components/Popconfirm/Popconfirm.js +71 -51
- package/dist/components/Popover/Popover.cjs +1 -1
- package/dist/components/Popover/Popover.js +36 -31
- package/dist/components/Portal/Portal.cjs +1 -1
- package/dist/components/Portal/Portal.d.ts +0 -3
- package/dist/components/Portal/Portal.js +4 -10
- package/dist/components/Select/Select.cjs +1 -1
- package/dist/components/Select/Select.js +71 -51
- package/dist/components/Stepper/Stepper.cjs +1 -1
- package/dist/components/Stepper/Stepper.const.cjs +1 -1
- package/dist/components/Stepper/Stepper.const.d.ts +3 -2
- package/dist/components/Stepper/Stepper.const.js +15 -14
- package/dist/components/Stepper/Stepper.d.ts +0 -7
- package/dist/components/Stepper/Stepper.js +164 -117
- package/dist/components/Stepper/Stepper.types.d.ts +3 -0
- package/dist/components/Tabs/TabList.cjs +1 -1
- package/dist/components/Tabs/TabList.js +72 -57
- package/dist/components/Tabs/Tabs.types.d.ts +4 -2
- package/dist/components/Tabs/index.d.ts +2 -2
- package/dist/components/TimePicker/components/TimePickerDialDropdown/TimePickerDialDropdown.cjs +1 -1
- package/dist/components/TimePicker/components/TimePickerDialDropdown/TimePickerDialDropdown.js +26 -26
- package/dist/components/TimePicker/helpers/ClockFaceSvg.cjs +1 -1
- package/dist/components/TimePicker/helpers/ClockFaceSvg.js +17 -17
- package/dist/components/Toast/Toast.cjs +1 -1
- package/dist/components/Toast/Toast.js +86 -82
- package/dist/components/Toast/Toast.types.d.ts +2 -0
- package/dist/components/Tooltip/Tooltip.cjs +1 -1
- package/dist/components/Tooltip/Tooltip.js +52 -44
- package/dist/components/TreeSelect/TreeSelect.cjs +1 -1
- package/dist/components/TreeSelect/TreeSelect.const.cjs +1 -1
- package/dist/components/TreeSelect/TreeSelect.const.d.ts +1 -1
- package/dist/components/TreeSelect/TreeSelect.const.js +3 -3
- package/dist/components/TreeSelect/TreeSelect.js +120 -88
- package/dist/components/Watermark/Watermark.cjs +1 -1
- package/dist/components/Watermark/Watermark.const.cjs +1 -1
- package/dist/components/Watermark/Watermark.const.d.ts +6 -3
- package/dist/components/Watermark/Watermark.const.js +13 -11
- package/dist/components/Watermark/Watermark.js +87 -61
- package/dist/components/Watermark/Watermark.types.d.ts +2 -0
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.d.ts +5 -3
- package/dist/components/index.js +292 -286
- package/dist/hooks/index.cjs +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.js +55 -54
- package/dist/hooks/useClickOutside.cjs +1 -1
- package/dist/hooks/useClickOutside.d.ts +4 -11
- package/dist/hooks/useClickOutside.js +26 -7
- package/dist/index.cjs +1 -1
- package/dist/index.js +386 -379
- package/dist/styles/_effects.css +17 -0
- package/dist/styles.css +1 -1
- package/dist/utils/maxVisible.utils.cjs +1 -0
- package/dist/utils/maxVisible.utils.d.ts +12 -0
- package/dist/utils/maxVisible.utils.js +15 -0
- package/package.json +1 -1
- package/dist/components/HoverCard/HoverCard.utils.cjs +0 -1
- package/dist/components/HoverCard/HoverCard.utils.js +0 -23
package/README.md
CHANGED
|
@@ -6,6 +6,10 @@ Strong, reliable React UI components. Tailwind-powered, zero config required. Th
|
|
|
6
6
|
|
|
7
7
|
Visit the [Bear UI Portal](https://bearui.com/) to explore all components, view live examples, and browse the documentation.
|
|
8
8
|
|
|
9
|
+
## Changelog
|
|
10
|
+
|
|
11
|
+
**Current release: 1.2.1** — Portaled overlays (Dropdown, Select, NavigableSelect, Menu, Autocomplete, MultiSelect, MentionsInput, TreeSelect, Popconfirm) use fixed positioning tied to the trigger, **z-index 10000**, and scroll/resize updates where applicable so panels are not clipped by parent `overflow` or stacking contexts. **Popover** and **Tooltip** also reposition on scroll/resize. **`useClickOutsideMultiple`** is available from `@forgedevstack/bear/hooks` for trigger + floating-root outside detection. Details: [CHANGELOG.md](./CHANGELOG.md).
|
|
12
|
+
|
|
9
13
|
## Features
|
|
10
14
|
|
|
11
15
|
- **Tailwind-Powered**: Built with Tailwind CSS, zero config required
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),a=require("react"),x=require("../../utils/cn.cjs"),D=require("../Portal/Portal.cjs"),V=require("./Autocomplete.utils.cjs"),M=require("./Autocomplete.const.cjs"),C=({options:z,value:b="",onChange:i,onSelect:g,placeholder:I="Start typing...",label:k,helperText:v,error:u,disabled:f=!1,freeSolo:j=!1,loading:E=!1,filterOptions:q=V.defaultFilter,className:_,testId:B})=>{const[c,s]=a.useState(!1),[n,m]=a.useState(-1),[l,T]=a.useState({top:0,left:0,width:0}),N=a.useRef(null),P=a.useRef(null),h=a.useRef(null),A=a.useRef(null),w=a.useRef(null),o=q(z,b),y=c&&!f&&o.length>0,p=c&&!f&&o.length===0&&!!b&&!E;a.useEffect(()=>{if(!y&&!p)return;const e=()=>{var d;const r=(d=P.current)==null?void 0:d.getBoundingClientRect();r&&T({top:r.bottom+4,left:Math.max(8,Math.min(r.left,window.innerWidth-r.width-8)),width:r.width})};return e(),window.addEventListener("resize",e),window.addEventListener("scroll",e,!0),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",e,!0)}},[y,p]),a.useEffect(()=>{if(!c)return;const e=r=>{var R,O;const d=r.target;(R=N.current)!=null&&R.contains(d)||(O=h.current)!=null&&O.contains(d)||s(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[c]),a.useEffect(()=>{m(-1)},[b]),a.useEffect(()=>{if(n>=0&&w.current){const e=w.current.children[n];e&&e.scrollIntoView({block:"nearest"})}},[n]);const U=e=>{const r=e.target.value;i==null||i(r),s(!0)},L=e=>{var r;i==null||i(e.label),g==null||g(e),s(!1),(r=A.current)==null||r.blur()},W=e=>{if(!c){(e.key==="ArrowDown"||e.key==="ArrowUp")&&(s(!0),e.preventDefault());return}switch(e.key){case"ArrowDown":e.preventDefault(),m(r=>r<o.length-1?r+1:0);break;case"ArrowUp":e.preventDefault(),m(r=>r>0?r-1:o.length-1);break;case"Enter":e.preventDefault(),n>=0&&o[n]?L(o[n]):j&&b&&s(!1);break;case"Escape":s(!1);break}};return t.jsxs("div",{className:x.cn("bear-w-full bear-relative",_),ref:N,"data-testid":B,children:[k&&t.jsx("label",{className:"bear-block bear-text-sm bear-font-medium bear-text-gray-700 dark:bear-text-gray-200 bear-mb-1.5",children:k}),t.jsxs("div",{className:"bear-relative",ref:P,children:[t.jsx("input",{ref:A,type:"text",value:b,onChange:U,onFocus:()=>s(!0),onKeyDown:W,placeholder:I,disabled:f,className:x.cn("bear-w-full bear-px-4 bear-py-2.5 bear-pr-10 bear-rounded-lg bear-border","bear-bg-white dark:bear-bg-gray-900","bear-text-sm bear-text-gray-900 dark:bear-text-white","placeholder:bear-text-gray-400","bear-transition-colors bear-outline-none",u?"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-amber-500 focus:bear-ring-2 focus:bear-ring-amber-500/20",f&&"bear-opacity-50 bear-cursor-not-allowed bear-bg-gray-100 dark:bear-bg-gray-800")}),t.jsx("div",{className:"bear-absolute bear-right-3 bear-top-1/2 bear-transform bear--translate-y-1/2",children:E?t.jsxs("svg",{className:"bear-animate-spin bear-w-4 bear-h-4 bear-text-gray-400",viewBox:"0 0 24 24",fill:"none",children:[t.jsx("circle",{className:"bear-opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"bear-opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}):t.jsx("svg",{className:"bear-w-4 bear-h-4 bear-text-gray-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})})]}),y&&t.jsx(D.Portal,{children:t.jsx("div",{ref:h,className:"bear-fixed bear-rounded-lg bear-border bear-border-gray-200 dark:bear-border-gray-700 bear-shadow-lg bear-bg-white dark:bear-bg-gray-800",style:{top:l.top,left:l.left,width:l.width,zIndex:M.AUTOCOMPLETE_PANEL_Z},children:t.jsx("div",{ref:w,className:"bear-max-h-60 bear-overflow-auto bear-py-1",children:o.map((e,r)=>t.jsxs("button",{type:"button",disabled:e.disabled,onClick:()=>L(e),className:x.cn("bear-w-full bear-px-4 bear-py-2 bear-text-left bear-text-sm bear-transition-colors","bear-text-gray-900 dark:bear-text-white",r===n?"bear-bg-amber-50 dark:bear-bg-amber-900/20":"hover:bear-bg-gray-50 dark:hover:bear-bg-gray-700",e.disabled&&"bear-opacity-50 bear-cursor-not-allowed"),children:[t.jsx("div",{className:"bear-font-medium",children:e.label}),e.description&&t.jsx("div",{className:"bear-text-xs bear-text-gray-500 dark:bear-text-gray-400 bear-mt-0.5",children:e.description})]},e.value))})})}),p&&t.jsx(D.Portal,{children:t.jsx("div",{ref:h,className:"bear-fixed bear-py-3 bear-px-4 bear-bg-white dark:bear-bg-gray-800 bear-border bear-border-gray-200 dark:bear-border-gray-700 bear-rounded-lg bear-shadow-lg bear-text-sm bear-text-gray-500",style:{top:l.top,left:l.left,width:l.width,zIndex:M.AUTOCOMPLETE_PANEL_Z},children:j?"Press Enter to use this value":"No results found"})}),(v||u)&&t.jsx("p",{className:x.cn("bear-mt-1.5 bear-text-xs",u?"bear-text-red-500":"bear-text-gray-500 dark:bear-text-gray-400"),children:u||v})]})};exports.Autocomplete=C;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=11e3;exports.AUTOCOMPLETE_PANEL_Z=e;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const AUTOCOMPLETE_PANEL_Z = 11000;
|
|
@@ -1,130 +1,168 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { cn as
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
import { jsxs as m, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useState as N, useRef as c, useEffect as h } from "react";
|
|
3
|
+
import { cn as g } from "../../utils/cn.js";
|
|
4
|
+
import { Portal as B } from "../Portal/Portal.js";
|
|
5
|
+
import { defaultFilter as T } from "./Autocomplete.utils.js";
|
|
6
|
+
import { AUTOCOMPLETE_PANEL_Z as W } from "./Autocomplete.const.js";
|
|
7
|
+
const Y = ({
|
|
8
|
+
options: j,
|
|
9
|
+
value: b = "",
|
|
10
|
+
onChange: o,
|
|
11
|
+
onSelect: w,
|
|
12
|
+
placeholder: U = "Start typing...",
|
|
13
|
+
label: E,
|
|
14
|
+
helperText: L,
|
|
15
|
+
error: u,
|
|
16
|
+
disabled: f = !1,
|
|
17
|
+
freeSolo: P = !1,
|
|
18
|
+
loading: A = !1,
|
|
19
|
+
filterOptions: V = T,
|
|
20
|
+
className: F,
|
|
21
|
+
testId: H
|
|
20
22
|
}) => {
|
|
21
|
-
const [
|
|
22
|
-
|
|
23
|
+
const [l, a] = N(!1), [n, p] = N(-1), [i, K] = N({ top: 0, left: 0, width: 0 }), D = c(null), z = c(null), y = c(null), I = c(null), x = c(null), s = V(j, b), k = l && !f && s.length > 0, v = l && !f && s.length === 0 && !!b && !A;
|
|
24
|
+
h(() => {
|
|
25
|
+
if (!k && !v) return;
|
|
26
|
+
const e = () => {
|
|
27
|
+
var d;
|
|
28
|
+
const r = (d = z.current) == null ? void 0 : d.getBoundingClientRect();
|
|
29
|
+
r && K({
|
|
30
|
+
top: r.bottom + 4,
|
|
31
|
+
left: Math.max(8, Math.min(r.left, window.innerWidth - r.width - 8)),
|
|
32
|
+
width: r.width
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
return e(), window.addEventListener("resize", e), window.addEventListener("scroll", e, !0), () => {
|
|
36
|
+
window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0);
|
|
37
|
+
};
|
|
38
|
+
}, [k, v]), h(() => {
|
|
39
|
+
if (!l) return;
|
|
23
40
|
const e = (r) => {
|
|
24
|
-
|
|
41
|
+
var M, O;
|
|
42
|
+
const d = r.target;
|
|
43
|
+
(M = D.current) != null && M.contains(d) || (O = y.current) != null && O.contains(d) || a(!1);
|
|
25
44
|
};
|
|
26
45
|
return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
|
|
27
|
-
}, []),
|
|
28
|
-
|
|
29
|
-
}, [
|
|
30
|
-
if (
|
|
31
|
-
const e =
|
|
46
|
+
}, [l]), h(() => {
|
|
47
|
+
p(-1);
|
|
48
|
+
}, [b]), h(() => {
|
|
49
|
+
if (n >= 0 && x.current) {
|
|
50
|
+
const e = x.current.children[n];
|
|
32
51
|
e && e.scrollIntoView({ block: "nearest" });
|
|
33
52
|
}
|
|
34
|
-
}, [
|
|
35
|
-
const
|
|
53
|
+
}, [n]);
|
|
54
|
+
const _ = (e) => {
|
|
36
55
|
const r = e.target.value;
|
|
37
|
-
|
|
38
|
-
},
|
|
56
|
+
o == null || o(r), a(!0);
|
|
57
|
+
}, R = (e) => {
|
|
39
58
|
var r;
|
|
40
|
-
|
|
41
|
-
},
|
|
42
|
-
if (!
|
|
43
|
-
(e.key === "ArrowDown" || e.key === "ArrowUp") && (
|
|
59
|
+
o == null || o(e.label), w == null || w(e), a(!1), (r = I.current) == null || r.blur();
|
|
60
|
+
}, C = (e) => {
|
|
61
|
+
if (!l) {
|
|
62
|
+
(e.key === "ArrowDown" || e.key === "ArrowUp") && (a(!0), e.preventDefault());
|
|
44
63
|
return;
|
|
45
64
|
}
|
|
46
65
|
switch (e.key) {
|
|
47
66
|
case "ArrowDown":
|
|
48
|
-
e.preventDefault(),
|
|
67
|
+
e.preventDefault(), p(
|
|
49
68
|
(r) => r < s.length - 1 ? r + 1 : 0
|
|
50
69
|
);
|
|
51
70
|
break;
|
|
52
71
|
case "ArrowUp":
|
|
53
|
-
e.preventDefault(),
|
|
72
|
+
e.preventDefault(), p(
|
|
54
73
|
(r) => r > 0 ? r - 1 : s.length - 1
|
|
55
74
|
);
|
|
56
75
|
break;
|
|
57
76
|
case "Enter":
|
|
58
|
-
e.preventDefault(),
|
|
77
|
+
e.preventDefault(), n >= 0 && s[n] ? R(s[n]) : P && b && a(!1);
|
|
59
78
|
break;
|
|
60
79
|
case "Escape":
|
|
61
|
-
|
|
80
|
+
a(!1);
|
|
62
81
|
break;
|
|
63
82
|
}
|
|
64
83
|
};
|
|
65
|
-
return /* @__PURE__ */
|
|
66
|
-
|
|
67
|
-
/* @__PURE__ */
|
|
68
|
-
/* @__PURE__ */
|
|
84
|
+
return /* @__PURE__ */ m("div", { className: g("bear-w-full bear-relative", F), ref: D, "data-testid": H, children: [
|
|
85
|
+
E && /* @__PURE__ */ t("label", { className: "bear-block bear-text-sm bear-font-medium bear-text-gray-700 dark:bear-text-gray-200 bear-mb-1.5", children: E }),
|
|
86
|
+
/* @__PURE__ */ m("div", { className: "bear-relative", ref: z, children: [
|
|
87
|
+
/* @__PURE__ */ t(
|
|
69
88
|
"input",
|
|
70
89
|
{
|
|
71
|
-
ref:
|
|
90
|
+
ref: I,
|
|
72
91
|
type: "text",
|
|
73
|
-
value:
|
|
74
|
-
onChange:
|
|
75
|
-
onFocus: () =>
|
|
76
|
-
onKeyDown:
|
|
77
|
-
placeholder:
|
|
78
|
-
disabled:
|
|
79
|
-
className:
|
|
92
|
+
value: b,
|
|
93
|
+
onChange: _,
|
|
94
|
+
onFocus: () => a(!0),
|
|
95
|
+
onKeyDown: C,
|
|
96
|
+
placeholder: U,
|
|
97
|
+
disabled: f,
|
|
98
|
+
className: g(
|
|
80
99
|
"bear-w-full bear-px-4 bear-py-2.5 bear-pr-10 bear-rounded-lg bear-border",
|
|
81
100
|
"bear-bg-white dark:bear-bg-gray-900",
|
|
82
101
|
"bear-text-sm bear-text-gray-900 dark:bear-text-white",
|
|
83
102
|
"placeholder:bear-text-gray-400",
|
|
84
103
|
"bear-transition-colors bear-outline-none",
|
|
85
|
-
|
|
86
|
-
|
|
104
|
+
u ? "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-amber-500 focus:bear-ring-2 focus:bear-ring-amber-500/20",
|
|
105
|
+
f && "bear-opacity-50 bear-cursor-not-allowed bear-bg-gray-100 dark:bear-bg-gray-800"
|
|
87
106
|
)
|
|
88
107
|
}
|
|
89
108
|
),
|
|
90
|
-
/* @__PURE__ */
|
|
91
|
-
/* @__PURE__ */
|
|
92
|
-
/* @__PURE__ */
|
|
93
|
-
] }) : /* @__PURE__ */
|
|
109
|
+
/* @__PURE__ */ t("div", { className: "bear-absolute bear-right-3 bear-top-1/2 bear-transform bear--translate-y-1/2", children: A ? /* @__PURE__ */ m("svg", { className: "bear-animate-spin bear-w-4 bear-h-4 bear-text-gray-400", viewBox: "0 0 24 24", fill: "none", children: [
|
|
110
|
+
/* @__PURE__ */ t("circle", { className: "bear-opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
|
|
111
|
+
/* @__PURE__ */ t("path", { className: "bear-opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })
|
|
112
|
+
] }) : /* @__PURE__ */ t("svg", { className: "bear-w-4 bear-h-4 bear-text-gray-400", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ t("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" }) }) })
|
|
94
113
|
] }),
|
|
95
|
-
|
|
114
|
+
k && /* @__PURE__ */ t(B, { children: /* @__PURE__ */ t(
|
|
96
115
|
"div",
|
|
97
116
|
{
|
|
98
117
|
ref: y,
|
|
99
|
-
className: "bear-
|
|
100
|
-
|
|
118
|
+
className: "bear-fixed bear-rounded-lg bear-border bear-border-gray-200 dark:bear-border-gray-700 bear-shadow-lg bear-bg-white dark:bear-bg-gray-800",
|
|
119
|
+
style: {
|
|
120
|
+
top: i.top,
|
|
121
|
+
left: i.left,
|
|
122
|
+
width: i.width,
|
|
123
|
+
zIndex: W
|
|
124
|
+
},
|
|
125
|
+
children: /* @__PURE__ */ t("div", { ref: x, className: "bear-max-h-60 bear-overflow-auto bear-py-1", children: s.map((e, r) => /* @__PURE__ */ m(
|
|
101
126
|
"button",
|
|
102
127
|
{
|
|
103
128
|
type: "button",
|
|
104
129
|
disabled: e.disabled,
|
|
105
|
-
onClick: () =>
|
|
106
|
-
className:
|
|
130
|
+
onClick: () => R(e),
|
|
131
|
+
className: g(
|
|
107
132
|
"bear-w-full bear-px-4 bear-py-2 bear-text-left bear-text-sm bear-transition-colors",
|
|
108
133
|
"bear-text-gray-900 dark:bear-text-white",
|
|
109
|
-
r ===
|
|
134
|
+
r === n ? "bear-bg-amber-50 dark:bear-bg-amber-900/20" : "hover:bear-bg-gray-50 dark:hover:bear-bg-gray-700",
|
|
110
135
|
e.disabled && "bear-opacity-50 bear-cursor-not-allowed"
|
|
111
136
|
),
|
|
112
137
|
children: [
|
|
113
|
-
/* @__PURE__ */
|
|
114
|
-
e.description && /* @__PURE__ */
|
|
138
|
+
/* @__PURE__ */ t("div", { className: "bear-font-medium", children: e.label }),
|
|
139
|
+
e.description && /* @__PURE__ */ t("div", { className: "bear-text-xs bear-text-gray-500 dark:bear-text-gray-400 bear-mt-0.5", children: e.description })
|
|
115
140
|
]
|
|
116
141
|
},
|
|
117
142
|
e.value
|
|
118
|
-
))
|
|
143
|
+
)) })
|
|
144
|
+
}
|
|
145
|
+
) }),
|
|
146
|
+
v && /* @__PURE__ */ t(B, { children: /* @__PURE__ */ t(
|
|
147
|
+
"div",
|
|
148
|
+
{
|
|
149
|
+
ref: y,
|
|
150
|
+
className: "bear-fixed bear-py-3 bear-px-4 bear-bg-white dark:bear-bg-gray-800 bear-border bear-border-gray-200 dark:bear-border-gray-700 bear-rounded-lg bear-shadow-lg bear-text-sm bear-text-gray-500",
|
|
151
|
+
style: {
|
|
152
|
+
top: i.top,
|
|
153
|
+
left: i.left,
|
|
154
|
+
width: i.width,
|
|
155
|
+
zIndex: W
|
|
156
|
+
},
|
|
157
|
+
children: P ? "Press Enter to use this value" : "No results found"
|
|
119
158
|
}
|
|
120
|
-
),
|
|
121
|
-
|
|
122
|
-
(w || n) && /* @__PURE__ */ a("p", { className: c(
|
|
159
|
+
) }),
|
|
160
|
+
(L || u) && /* @__PURE__ */ t("p", { className: g(
|
|
123
161
|
"bear-mt-1.5 bear-text-xs",
|
|
124
|
-
|
|
125
|
-
), children:
|
|
162
|
+
u ? "bear-text-red-500" : "bear-text-gray-500 dark:bear-text-gray-400"
|
|
163
|
+
), children: u || L })
|
|
126
164
|
] });
|
|
127
165
|
};
|
|
128
166
|
export {
|
|
129
|
-
|
|
167
|
+
Y as Autocomplete
|
|
130
168
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("react"),S=require("react-dom"),s=require("../../utils/cn.cjs"),q=require("../Icon/index.cjs"),h=300,E={sm:"bear-max-h-[40%]",md:"bear-max-h-[60%]",lg:"bear-max-h-[80%]",full:"bear-max-h-[95%]"},I=({isOpen:l,onClose:b,title:n,children:x,size:v="md",showCloseButton:d=!0,closeOnBackdrop:y=!0,closeOnEscape:u=!0,showHandle:k=!0,enableScroll:g=!0,isSticky:j=!1,className:w})=>{const[a,c]=r.useState(l),[m,o]=r.useState(!1),[p,f]=r.useState(!1);r.useEffect(()=>{if(l){c(!0),o(!1);const t=requestAnimationFrame(()=>f(!0));return()=>cancelAnimationFrame(t)}if(a){f(!1),o(!0);const t=setTimeout(()=>{c(!1),o(!1)},h);return()=>clearTimeout(t)}},[l,a]);const i=r.useCallback(t=>{u&&t.key==="Escape"&&b()},[u,b]);if(r.useEffect(()=>(a&&(document.addEventListener("keydown",i),document.body.style.overflow="hidden"),()=>{document.removeEventListener("keydown",i),document.body.style.overflow=""}),[a,i]),!a)return null;const N=e.jsxs("div",{className:"bear-fixed bear-inset-0 bear-z-[11000] bear-flex bear-items-end bear-justify-center",children:[e.jsx("div",{className:s.cn("bear-absolute bear-inset-0 bear-bg-black/60 bear-backdrop-blur-sm bear-transition-opacity",m?"bear-opacity-0":"bear-opacity-100"),style:{transitionDuration:`${h}ms`},onClick:y?b:void 0,"aria-hidden":"true"}),e.jsxs("div",{role:"dialog","aria-modal":"true","aria-labelledby":n?"bottom-sheet-title":void 0,className:s.cn("Bear-BottomSheet bear-relative bear-w-full bear-rounded-t-2xl bear-shadow-2xl bear-transition-transform bear-duration-300","bear-flex bear-flex-col bear-min-h-0 bear-overflow-hidden","bear-bg-white dark:bear-bg-neutral-900 bear-border-t bear-border-neutral-200 dark:bear-border-neutral-700",E[v],p&&!m?"bear-translate-y-0":"bear-translate-y-full",w),children:[k&&e.jsx("div",{className:"bear-flex bear-justify-center bear-pt-2 bear-pb-1",children:e.jsx("div",{className:"bear-w-12 bear-h-1 bear-rounded-full bear-bg-neutral-300 dark:bear-bg-neutral-600","aria-hidden":!0})}),(n||d)&&e.jsxs("div",{className:s.cn("bear-flex bear-items-center bear-justify-between bear-px-4 bear-py-3 bear-border-b bear-border-neutral-200 dark:bear-border-neutral-700 bear-shrink-0",j&&"bear-sticky bear-top-0 bear-z-10 bear-bg-white dark:bear-bg-neutral-900"),children:[n&&e.jsx("h2",{id:"bottom-sheet-title",className:"bear-text-lg bear-font-semibold bear-text-neutral-900 dark:bear-text-white",children:n}),d&&e.jsx("button",{onClick:b,className:"bear-p-1 bear-rounded-lg bear-text-neutral-500 dark:bear-text-neutral-400 hover:bear-text-neutral-900 dark:hover:bear-text-white hover:bear-bg-neutral-100 dark:hover:bear-bg-neutral-700 bear-transition-colors","aria-label":"Close",children:e.jsx(q.XIcon,{className:"bear-w-5 bear-h-5"})})]}),e.jsx("div",{className:s.cn("bear-flex-1 bear-min-h-0 bear-p-4 bear-text-neutral-700 dark:bear-text-neutral-300",g?"bear-overflow-y-auto":"bear-overflow-hidden"),children:x})]})]});return S.createPortal(N,document.body)};exports.BottomSheet=I;
|
|
@@ -1,103 +1,124 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { createPortal as
|
|
4
|
-
import { cn as
|
|
5
|
-
import { XIcon as
|
|
6
|
-
const v = 300,
|
|
1
|
+
import { jsxs as i, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { useState as d, useEffect as x, useCallback as E } from "react";
|
|
3
|
+
import { createPortal as M } from "react-dom";
|
|
4
|
+
import { cn as n } from "../../utils/cn.js";
|
|
5
|
+
import { XIcon as S } from "../Icon/index.js";
|
|
6
|
+
const v = 300, z = {
|
|
7
7
|
sm: "bear-max-h-[40%]",
|
|
8
8
|
md: "bear-max-h-[60%]",
|
|
9
9
|
lg: "bear-max-h-[80%]",
|
|
10
10
|
full: "bear-max-h-[95%]"
|
|
11
|
-
},
|
|
11
|
+
}, q = ({
|
|
12
12
|
isOpen: o,
|
|
13
13
|
onClose: t,
|
|
14
14
|
title: b,
|
|
15
15
|
children: y,
|
|
16
16
|
size: k = "md",
|
|
17
|
-
showCloseButton:
|
|
17
|
+
showCloseButton: u = !0,
|
|
18
18
|
closeOnBackdrop: p = !0,
|
|
19
|
-
closeOnEscape:
|
|
19
|
+
closeOnEscape: c = !0,
|
|
20
20
|
showHandle: g = !0,
|
|
21
|
-
|
|
21
|
+
enableScroll: w = !0,
|
|
22
|
+
isSticky: N = !1,
|
|
23
|
+
className: j
|
|
22
24
|
}) => {
|
|
23
|
-
const [r,
|
|
24
|
-
|
|
25
|
+
const [r, m] = d(o), [f, l] = d(!1), [I, h] = d(!1);
|
|
26
|
+
x(() => {
|
|
25
27
|
if (o) {
|
|
26
|
-
|
|
27
|
-
const a = requestAnimationFrame(() =>
|
|
28
|
+
m(!0), l(!1);
|
|
29
|
+
const a = requestAnimationFrame(() => h(!0));
|
|
28
30
|
return () => cancelAnimationFrame(a);
|
|
29
31
|
}
|
|
30
32
|
if (r) {
|
|
31
|
-
|
|
33
|
+
h(!1), l(!0);
|
|
32
34
|
const a = setTimeout(() => {
|
|
33
|
-
|
|
35
|
+
m(!1), l(!1);
|
|
34
36
|
}, v);
|
|
35
37
|
return () => clearTimeout(a);
|
|
36
38
|
}
|
|
37
39
|
}, [o, r]);
|
|
38
|
-
const
|
|
40
|
+
const s = E(
|
|
39
41
|
(a) => {
|
|
40
|
-
|
|
42
|
+
c && a.key === "Escape" && t();
|
|
41
43
|
},
|
|
42
|
-
[
|
|
44
|
+
[c, t]
|
|
43
45
|
);
|
|
44
|
-
if (
|
|
45
|
-
document.removeEventListener("keydown",
|
|
46
|
-
}), [r,
|
|
47
|
-
const
|
|
46
|
+
if (x(() => (r && (document.addEventListener("keydown", s), document.body.style.overflow = "hidden"), () => {
|
|
47
|
+
document.removeEventListener("keydown", s), document.body.style.overflow = "";
|
|
48
|
+
}), [r, s]), !r) return null;
|
|
49
|
+
const A = /* @__PURE__ */ i("div", { className: "bear-fixed bear-inset-0 bear-z-[11000] bear-flex bear-items-end bear-justify-center", children: [
|
|
48
50
|
/* @__PURE__ */ e(
|
|
49
51
|
"div",
|
|
50
52
|
{
|
|
51
|
-
className:
|
|
53
|
+
className: n(
|
|
52
54
|
"bear-absolute bear-inset-0 bear-bg-black/60 bear-backdrop-blur-sm bear-transition-opacity",
|
|
53
|
-
|
|
55
|
+
f ? "bear-opacity-0" : "bear-opacity-100"
|
|
54
56
|
),
|
|
55
57
|
style: { transitionDuration: `${v}ms` },
|
|
56
58
|
onClick: p ? t : void 0,
|
|
57
59
|
"aria-hidden": "true"
|
|
58
60
|
}
|
|
59
61
|
),
|
|
60
|
-
/* @__PURE__ */
|
|
62
|
+
/* @__PURE__ */ i(
|
|
61
63
|
"div",
|
|
62
64
|
{
|
|
63
65
|
role: "dialog",
|
|
64
66
|
"aria-modal": "true",
|
|
65
67
|
"aria-labelledby": b ? "bottom-sheet-title" : void 0,
|
|
66
|
-
className:
|
|
67
|
-
"Bear-BottomSheet bear-relative bear-w-full bear-rounded-t-2xl bear-shadow-2xl bear-
|
|
68
|
+
className: n(
|
|
69
|
+
"Bear-BottomSheet bear-relative bear-w-full bear-rounded-t-2xl bear-shadow-2xl bear-transition-transform bear-duration-300",
|
|
70
|
+
"bear-flex bear-flex-col bear-min-h-0 bear-overflow-hidden",
|
|
68
71
|
"bear-bg-white dark:bear-bg-neutral-900 bear-border-t bear-border-neutral-200 dark:bear-border-neutral-700",
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
+
z[k],
|
|
73
|
+
I && !f ? "bear-translate-y-0" : "bear-translate-y-full",
|
|
74
|
+
j
|
|
72
75
|
),
|
|
73
76
|
children: [
|
|
74
77
|
g && /* @__PURE__ */ e("div", { className: "bear-flex bear-justify-center bear-pt-2 bear-pb-1", children: /* @__PURE__ */ e("div", { className: "bear-w-12 bear-h-1 bear-rounded-full bear-bg-neutral-300 dark:bear-bg-neutral-600", "aria-hidden": !0 }) }),
|
|
75
|
-
(b ||
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
78
|
+
(b || u) && /* @__PURE__ */ i(
|
|
79
|
+
"div",
|
|
80
|
+
{
|
|
81
|
+
className: n(
|
|
82
|
+
"bear-flex bear-items-center bear-justify-between bear-px-4 bear-py-3 bear-border-b bear-border-neutral-200 dark:bear-border-neutral-700 bear-shrink-0",
|
|
83
|
+
N && "bear-sticky bear-top-0 bear-z-10 bear-bg-white dark:bear-bg-neutral-900"
|
|
84
|
+
),
|
|
85
|
+
children: [
|
|
86
|
+
b && /* @__PURE__ */ e(
|
|
87
|
+
"h2",
|
|
88
|
+
{
|
|
89
|
+
id: "bottom-sheet-title",
|
|
90
|
+
className: "bear-text-lg bear-font-semibold bear-text-neutral-900 dark:bear-text-white",
|
|
91
|
+
children: b
|
|
92
|
+
}
|
|
93
|
+
),
|
|
94
|
+
u && /* @__PURE__ */ e(
|
|
95
|
+
"button",
|
|
96
|
+
{
|
|
97
|
+
onClick: t,
|
|
98
|
+
className: "bear-p-1 bear-rounded-lg bear-text-neutral-500 dark:bear-text-neutral-400 hover:bear-text-neutral-900 dark:hover:bear-text-white hover:bear-bg-neutral-100 dark:hover:bear-bg-neutral-700 bear-transition-colors",
|
|
99
|
+
"aria-label": "Close",
|
|
100
|
+
children: /* @__PURE__ */ e(S, { className: "bear-w-5 bear-h-5" })
|
|
101
|
+
}
|
|
102
|
+
)
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
),
|
|
106
|
+
/* @__PURE__ */ e(
|
|
107
|
+
"div",
|
|
108
|
+
{
|
|
109
|
+
className: n(
|
|
110
|
+
"bear-flex-1 bear-min-h-0 bear-p-4 bear-text-neutral-700 dark:bear-text-neutral-300",
|
|
111
|
+
w ? "bear-overflow-y-auto" : "bear-overflow-hidden"
|
|
112
|
+
),
|
|
113
|
+
children: y
|
|
114
|
+
}
|
|
115
|
+
)
|
|
95
116
|
]
|
|
96
117
|
}
|
|
97
118
|
)
|
|
98
119
|
] });
|
|
99
|
-
return A
|
|
120
|
+
return M(A, document.body);
|
|
100
121
|
};
|
|
101
122
|
export {
|
|
102
|
-
|
|
123
|
+
q as BottomSheet
|
|
103
124
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),b=require("react"),H=require("../../context/BearProvider.cjs"),Z=require("../../utils/maxVisible.utils.cjs"),g=require("../../utils/cn.cjs"),R=require("../Dropdown/Dropdown.cjs"),u=require("../Icon/index.cjs"),c=require("./Breadcrumbs.const.cjs"),V=v=>{const{items:n,separator:N,maxItems:p,itemsBeforeCollapse:x=c.BREADCRUMBS_DEFAULTS.ITEMS_BEFORE_COLLAPSE,itemsAfterCollapse:m=c.BREADCRUMBS_DEFAULTS.ITEMS_AFTER_COLLAPSE,className:D,size:h=c.BREADCRUMBS_DEFAULTS.SIZE,showHomeIcon:_=c.BREADCRUMBS_DEFAULTS.SHOW_HOME_ICON,testId:A,id:z,"aria-label":M="Breadcrumb"}=v,w=H.useBearThemeOptional(),[i,f]=b.useState(null),[O,E]=b.useState({}),[I,U]=b.useState(()=>typeof window<"u"?window.innerWidth:1200);b.useEffect(()=>{const e=()=>U(window.innerWidth);return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]),b.useEffect(()=>{f(null),E({})},[n]);const S=b.useMemo(()=>p==null?void 0:Z.resolveMaxVisible(p,{width:I,theme:w}),[p,I,w]),L=()=>N||r.jsx(u.BearIcons.ChevronRightIcon,{className:g.cn(c.BREADCRUMBS_ICON_SIZE[h],"bear-text-zinc-500 bear-mx-2")}),B=(e,s,a)=>{const t=r.jsxs("span",{className:"bear-flex bear-items-center bear-gap-1 bear-max-w-[12rem] bear-truncate md:bear-max-w-none",children:[s===0&&_&&r.jsx(u.BearIcons.HomeIcon,{className:c.BREADCRUMBS_ICON_SIZE[h]}),e.icon,e.label]}),o=a?r.jsx("span",{className:"bear-text-zinc-300 bear-font-medium","aria-current":"page",children:t}):e.href?r.jsx("a",{href:e.href,className:"bear-text-zinc-400 hover:bear-text-pink-400 bear-transition-colors bear-truncate",children:t}):e.onClick?r.jsx("button",{type:"button",onClick:e.onClick,className:"bear-text-zinc-400 hover:bear-text-pink-400 bear-transition-colors bear-truncate",children:t}):r.jsx("span",{className:"bear-text-zinc-400 bear-truncate",children:t});if(e.dropdownItems&&e.dropdownItems.length>0&&!a){const d=O[s],k=e.dropdownItems.find(l=>l.key===d);return r.jsx(R.Dropdown,{placement:"bottom-start",closeOnSelect:!0,trigger:r.jsxs("button",{type:"button",className:"bear-inline-flex bear-items-center bear-gap-1 bear-text-zinc-400 hover:bear-text-pink-400 bear-transition-colors","aria-haspopup":"true",children:[t,k&&r.jsx("span",{className:"bear-ml-1 bear-max-w-[8rem] bear-truncate bear-text-xs bear-text-zinc-300",children:k.label}),r.jsx(u.BearIcons.ChevronDownIcon,{size:14})]}),items:e.dropdownItems.map(l=>({key:l.key,label:l.label,disabled:l.disabled,selected:d===l.key,onClick:()=>{var y;E(F=>({...F,[s]:l.key})),(y=l.onClick)==null||y.call(l)}}))})}return o},T=S!=null&&n.length>S,C=x,P=n.length-m;let j=n.map((e,s)=>({type:"item",item:e,index:s}));if(T){const e=n.slice(0,x),s=n.slice(-m),a=n.slice(x,n.length-m);j=[...e.map((t,o)=>({type:"item",item:t,index:o})),...a.length?[{type:"ellipsis",hidden:a}]:[],...s.map((t,o)=>({type:"item",item:t,index:n.length-m+o}))]}const q=i!=null&&i>=C&&i<P;return r.jsx("nav",{id:z,"data-testid":A,className:g.cn("bear-flex bear-min-w-0 bear-items-center bear-flex-wrap",c.BREADCRUMBS_SIZE[h],D),"aria-label":M,children:r.jsx("ol",{className:"bear-flex bear-min-w-0 bear-items-center bear-flex-wrap bear-list-none bear-p-0 bear-m-0",children:j.map((e,s)=>r.jsxs("li",{className:"bear-flex bear-min-w-0 bear-items-center",children:[s>0&&r.jsx("span",{"aria-hidden":"true",children:L()}),e.type==="ellipsis"?r.jsxs("span",{className:"bear-inline-flex bear-min-w-0 bear-max-w-full bear-items-center bear-gap-1",children:[r.jsx(R.Dropdown,{placement:"bottom-start",closeOnSelect:!0,trigger:r.jsx("button",{type:"button",className:"bear-inline-flex bear-items-center bear-justify-center bear-rounded bear-px-2 bear-py-1 bear-text-zinc-400 hover:bear-bg-[var(--bear-bg-tertiary)] hover:bear-text-pink-400 bear-transition-colors","aria-label":"Hidden breadcrumbs",children:r.jsx(u.BearIcons.MoreHorizIcon,{size:18})}),items:e.hidden.map((a,t)=>{const o=C+t;return{key:`${a.label}-${t}`,label:a.label,onClick:()=>{var d;f(o),(d=a.onClick)==null||d.call(a)}}})}),q&&i!=null&&r.jsx("span",{className:"bear-min-w-0 bear-max-w-[12rem] bear-truncate md:bear-max-w-none bear-inline-flex bear-items-center",children:B(n[i],i,i===n.length-1)})]}):B(e.item,e.index,e.index===n.length-1)]},s))})})};exports.Breadcrumbs=V;
|