@forgedevstack/bear 1.2.4 → 1.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (107) hide show
  1. package/README.md +15 -0
  2. package/dist/components/AppBar/AppBar.cjs +1 -1
  3. package/dist/components/AppBar/AppBar.const.cjs +1 -0
  4. package/dist/components/AppBar/AppBar.const.d.ts +36 -1
  5. package/dist/components/AppBar/AppBar.const.js +39 -0
  6. package/dist/components/AppBar/AppBar.js +65 -42
  7. package/dist/components/AppBar/AppBar.types.d.ts +9 -3
  8. package/dist/components/Backdrop/Backdrop.cjs +1 -0
  9. package/dist/components/Backdrop/Backdrop.const.cjs +1 -0
  10. package/dist/components/Backdrop/Backdrop.const.d.ts +7 -0
  11. package/dist/components/Backdrop/Backdrop.const.js +10 -0
  12. package/dist/components/Backdrop/Backdrop.d.ts +3 -0
  13. package/dist/components/Backdrop/Backdrop.js +43 -0
  14. package/dist/components/Backdrop/Backdrop.types.d.ts +12 -0
  15. package/dist/components/Backdrop/index.d.ts +2 -0
  16. package/dist/components/BottomNavigation/BottomNavigation.cjs +1 -1
  17. package/dist/components/BottomNavigation/BottomNavigation.const.cjs +1 -0
  18. package/dist/components/BottomNavigation/BottomNavigation.const.d.ts +8 -1
  19. package/dist/components/BottomNavigation/BottomNavigation.const.js +11 -0
  20. package/dist/components/BottomNavigation/BottomNavigation.js +64 -46
  21. package/dist/components/Breadcrumbs/Breadcrumbs.cjs +1 -1
  22. package/dist/components/Breadcrumbs/Breadcrumbs.js +65 -64
  23. package/dist/components/Card/Card.types.d.ts +1 -2
  24. package/dist/components/Chat/Chat.const.cjs +1 -1
  25. package/dist/components/Chat/Chat.const.d.ts +1 -1
  26. package/dist/components/Chat/Chat.const.js +1 -1
  27. package/dist/components/Chip/Chip.cjs +1 -1
  28. package/dist/components/Chip/Chip.const.cjs +1 -0
  29. package/dist/components/Chip/Chip.const.d.ts +39 -0
  30. package/dist/components/Chip/Chip.const.js +43 -0
  31. package/dist/components/Chip/Chip.js +44 -65
  32. package/dist/components/ChipGroup/ChipGroup.cjs +1 -0
  33. package/dist/components/ChipGroup/ChipGroup.const.cjs +1 -0
  34. package/dist/components/ChipGroup/ChipGroup.const.d.ts +8 -0
  35. package/dist/components/ChipGroup/ChipGroup.const.js +11 -0
  36. package/dist/components/ChipGroup/ChipGroup.d.ts +3 -0
  37. package/dist/components/ChipGroup/ChipGroup.js +41 -0
  38. package/dist/components/ChipGroup/ChipGroup.types.d.ts +9 -0
  39. package/dist/components/ChipGroup/index.d.ts +2 -0
  40. package/dist/components/ColorSwatch/ColorSwatch.cjs +1 -1
  41. package/dist/components/ColorSwatch/ColorSwatch.js +8 -8
  42. package/dist/components/CommandPalette/CommandPalette.cjs +1 -1
  43. package/dist/components/CommandPalette/CommandPalette.js +71 -71
  44. package/dist/components/DiffSquares/DiffSquares.cjs +1 -1
  45. package/dist/components/DiffSquares/DiffSquares.js +11 -11
  46. package/dist/components/Drawer/Drawer.cjs +1 -1
  47. package/dist/components/Drawer/Drawer.js +57 -56
  48. package/dist/components/Input/Input.cjs +1 -1
  49. package/dist/components/Input/Input.js +63 -62
  50. package/dist/components/List/List.cjs +1 -1
  51. package/dist/components/List/List.js +133 -123
  52. package/dist/components/List/List.types.d.ts +2 -0
  53. package/dist/components/MentionsInput/MentionsInput.cjs +1 -1
  54. package/dist/components/MentionsInput/MentionsInput.js +114 -92
  55. package/dist/components/MentionsInput/MentionsInput.types.d.ts +4 -0
  56. package/dist/components/MessageList/MessageList.cjs +1 -0
  57. package/dist/components/MessageList/MessageList.const.cjs +1 -0
  58. package/dist/components/MessageList/MessageList.const.d.ts +29 -0
  59. package/dist/components/MessageList/MessageList.const.js +36 -0
  60. package/dist/components/MessageList/MessageList.d.ts +3 -0
  61. package/dist/components/MessageList/MessageList.js +194 -0
  62. package/dist/components/MessageList/MessageList.types.d.ts +74 -0
  63. package/dist/components/MessageList/MessageList.utils.cjs +1 -0
  64. package/dist/components/MessageList/MessageList.utils.d.ts +13 -0
  65. package/dist/components/MessageList/MessageList.utils.js +54 -0
  66. package/dist/components/MessageList/index.d.ts +2 -0
  67. package/dist/components/Progress/Progress.cjs +1 -1
  68. package/dist/components/Progress/Progress.const.cjs +1 -0
  69. package/dist/components/Progress/Progress.const.d.ts +16 -1
  70. package/dist/components/Progress/Progress.const.js +19 -0
  71. package/dist/components/Progress/Progress.d.ts +0 -10
  72. package/dist/components/Progress/Progress.js +81 -71
  73. package/dist/components/Progress/Progress.types.d.ts +2 -11
  74. package/dist/components/PropsPlayground/PropsPlayground.cjs +1 -1
  75. package/dist/components/PropsPlayground/PropsPlayground.js +40 -40
  76. package/dist/components/Select/Select.cjs +1 -1
  77. package/dist/components/Select/Select.const.cjs +1 -0
  78. package/dist/components/Select/Select.const.d.ts +9 -0
  79. package/dist/components/Select/Select.const.js +13 -0
  80. package/dist/components/Select/Select.js +144 -68
  81. package/dist/components/Stepper/Stepper.cjs +1 -1
  82. package/dist/components/Stepper/Stepper.js +89 -83
  83. package/dist/components/Toast/Toast.cjs +1 -1
  84. package/dist/components/Toast/Toast.const.cjs +1 -0
  85. package/dist/components/Toast/Toast.const.d.ts +4 -0
  86. package/dist/components/Toast/Toast.const.js +17 -0
  87. package/dist/components/Toast/Toast.d.ts +3 -7
  88. package/dist/components/Toast/Toast.js +101 -89
  89. package/dist/components/Toast/Toast.types.d.ts +9 -0
  90. package/dist/components/Toast/index.d.ts +1 -1
  91. package/dist/components/TreeSelect/TreeSelect.cjs +1 -1
  92. package/dist/components/TreeSelect/TreeSelect.js +22 -22
  93. package/dist/components/index.cjs +1 -1
  94. package/dist/components/index.d.ts +7 -1
  95. package/dist/components/index.js +284 -278
  96. package/dist/context/BearProvider.cjs +1 -1
  97. package/dist/context/BearProvider.d.ts +8 -0
  98. package/dist/context/BearProvider.js +149 -139
  99. package/dist/context/index.cjs +1 -1
  100. package/dist/context/index.d.ts +1 -1
  101. package/dist/context/index.js +12 -10
  102. package/dist/index.cjs +1 -1
  103. package/dist/index.js +392 -384
  104. package/dist/styles/_message-list.css +42 -0
  105. package/dist/styles/main.css +1 -0
  106. package/dist/styles.css +114 -19
  107. package/package.json +15 -2
@@ -1,195 +1,205 @@
1
- import { jsx as b, jsxs as f } from "react/jsx-runtime";
2
- import { createContext as k, forwardRef as p, useContext as w } from "react";
3
- import { cn as n } from "../../utils/cn.js";
4
- import { LIST_VARIANT_CLASSES as A, LIST_SIZE_CLASSES as E, LIST_PADDING_CLASSES as _, LIST_BASE_CLASSES as D } from "./List.const.js";
5
- const v = k({}), T = () => w(v), P = p((r, e) => {
1
+ import { jsx as s, jsxs as y } from "react/jsx-runtime";
2
+ import { createContext as w, forwardRef as v, useContext as A } from "react";
3
+ import { cn as i } from "../../utils/cn.js";
4
+ import { LIST_VARIANT_CLASSES as D, LIST_SIZE_CLASSES as E, LIST_PADDING_CLASSES as B, LIST_BASE_CLASSES as T } from "./List.const.js";
5
+ const L = w({}), P = () => A(L), K = v((a, e) => {
6
6
  const {
7
- variant: s = "default",
8
- size: a = "md",
9
- hoverable: i = !1,
10
- dense: t = !1,
11
- disablePadding: x = !1,
12
- className: o,
13
- children: c,
14
- testId: l,
15
- ...m
16
- } = r;
17
- return /* @__PURE__ */ b(v.Provider, { value: { dense: t, hoverable: i }, children: /* @__PURE__ */ b(
7
+ variant: t = "default",
8
+ size: r = "md",
9
+ hoverable: o = !1,
10
+ dense: n = !1,
11
+ disablePadding: b = !1,
12
+ className: l,
13
+ children: m,
14
+ testId: g,
15
+ ...c
16
+ } = a;
17
+ return /* @__PURE__ */ s(L.Provider, { value: { dense: n, hoverable: o }, children: /* @__PURE__ */ s(
18
18
  "ul",
19
19
  {
20
20
  ref: e,
21
21
  role: "list",
22
- className: n(
23
- D,
24
- !x && _,
25
- E[a],
26
- A[s],
27
- o
22
+ className: i(
23
+ T,
24
+ !b && B,
25
+ E[r],
26
+ D[t],
27
+ l
28
28
  ),
29
- "data-testid": l,
30
- ...m,
31
- children: c
29
+ "data-testid": g,
30
+ ...c,
31
+ children: m
32
32
  }
33
33
  ) });
34
34
  });
35
- P.displayName = "List";
36
- const j = p(({
37
- primary: r,
35
+ K.displayName = "List";
36
+ const j = v(({
37
+ primary: a,
38
38
  secondary: e,
39
- leading: s,
40
- trailing: a,
41
- selected: i = !1,
42
- disabled: t = !1,
43
- clickable: x = !1,
44
- divider: o = !1,
45
- dense: c,
46
- onClick: l,
47
- className: m,
48
- children: h,
49
- testId: u,
39
+ leading: t,
40
+ trailing: r,
41
+ secondaryAction: o,
42
+ selected: n = !1,
43
+ disabled: b = !1,
44
+ clickable: l = !1,
45
+ divider: m = !1,
46
+ dense: g,
47
+ onClick: c,
48
+ className: h,
49
+ children: u,
50
+ testId: I,
50
51
  ...N
51
52
  }, S) => {
52
- const { dense: L, hoverable: I } = T(), g = c ?? L, d = x || !!l;
53
- return /* @__PURE__ */ f(
53
+ const { dense: k, hoverable: _ } = P(), p = g ?? k, x = l || !!c, f = o ?? r;
54
+ return /* @__PURE__ */ y(
54
55
  "li",
55
56
  {
56
57
  ref: S,
57
- role: d ? "button" : "listitem",
58
- tabIndex: d && !t ? 0 : void 0,
59
- "aria-selected": i,
60
- "aria-disabled": t,
61
- onClick: t ? void 0 : l,
62
- onKeyDown: (y) => {
63
- !t && (y.key === "Enter" || y.key === " ") && (y.preventDefault(), l == null || l());
58
+ role: x ? "button" : "listitem",
59
+ tabIndex: x && !b ? 0 : void 0,
60
+ "aria-selected": n,
61
+ "aria-disabled": b,
62
+ onClick: b ? void 0 : c,
63
+ onKeyDown: (d) => {
64
+ !b && (d.key === "Enter" || d.key === " ") && (d.preventDefault(), c == null || c());
64
65
  },
65
- className: n(
66
+ className: i(
67
+ "Bear-ListItem",
66
68
  "bear-flex bear-items-center bear-gap-3",
67
- g ? "bear-py-1 bear-px-3" : "bear-py-2 bear-px-4",
68
- d && !t && "bear-cursor-pointer",
69
- (I || d) && !t && "hover:bear-bg-gray-100 dark:hover:bear-bg-gray-800",
70
- i && "bear-bg-primary-50 dark:bear-bg-primary-900/20",
71
- t && "bear-opacity-50 bear-cursor-not-allowed",
72
- o && "bear-border-b bear-border-gray-200 dark:bear-border-gray-700",
73
- m
69
+ p ? "bear-py-1 bear-px-3" : "bear-py-2 bear-px-4",
70
+ x && !b && "bear-cursor-pointer",
71
+ (_ || x) && !b && "hover:bear-bg-gray-100 dark:hover:bear-bg-gray-800",
72
+ n && "bear-bg-primary-50 dark:bear-bg-primary-900/20",
73
+ b && "bear-opacity-50 bear-cursor-not-allowed",
74
+ m && "bear-border-b bear-border-gray-200 dark:bear-border-gray-700",
75
+ h
74
76
  ),
75
- "data-testid": u,
77
+ "data-testid": I,
76
78
  ...N,
77
79
  children: [
78
- s && /* @__PURE__ */ b("div", { className: "bear-flex-shrink-0 bear-text-gray-500 dark:bear-text-gray-400", children: s }),
79
- r || e ? /* @__PURE__ */ f("div", { className: "bear-flex-1 bear-min-w-0", children: [
80
- r && /* @__PURE__ */ b("div", { className: "bear-text-gray-900 dark:bear-text-gray-100 bear-truncate", children: r }),
81
- e && /* @__PURE__ */ b("div", { className: n(
80
+ t && /* @__PURE__ */ s("div", { className: "Bear-ListItem__leading bear-flex-shrink-0 bear-text-gray-500 dark:bear-text-gray-400", children: t }),
81
+ a || e ? /* @__PURE__ */ y("div", { className: "Bear-ListItem__content bear-flex-1 bear-min-w-0", children: [
82
+ a && /* @__PURE__ */ s("div", { className: "bear-text-gray-900 dark:bear-text-gray-100 bear-truncate", children: a }),
83
+ e && /* @__PURE__ */ s("div", { className: i(
82
84
  "bear-text-gray-500 dark:bear-text-gray-400 bear-truncate",
83
- g ? "bear-text-xs" : "bear-text-sm"
85
+ p ? "bear-text-xs" : "bear-text-sm"
84
86
  ), children: e })
85
- ] }) : /* @__PURE__ */ b("div", { className: "bear-flex-1 bear-min-w-0", children: h }),
86
- a && /* @__PURE__ */ b("div", { className: "bear-flex-shrink-0 bear-text-gray-500 dark:bear-text-gray-400", children: a })
87
+ ] }) : /* @__PURE__ */ s("div", { className: "Bear-ListItem__content bear-flex-1 bear-min-w-0", children: u }),
88
+ f && /* @__PURE__ */ s(
89
+ "div",
90
+ {
91
+ className: "Bear-ListItem__secondary-action bear-flex-shrink-0 bear-text-gray-500 dark:bear-text-gray-400",
92
+ onClick: (d) => d.stopPropagation(),
93
+ onKeyDown: (d) => d.stopPropagation(),
94
+ children: f
95
+ }
96
+ )
87
97
  ]
88
98
  }
89
99
  );
90
100
  });
91
101
  j.displayName = "ListItem";
92
- const G = ({
93
- sticky: r = !1,
102
+ const V = ({
103
+ sticky: a = !1,
94
104
  inset: e = !1,
95
- className: s,
96
- children: a,
97
- testId: i,
98
- ...t
99
- }) => /* @__PURE__ */ b(
105
+ className: t,
106
+ children: r,
107
+ testId: o,
108
+ ...n
109
+ }) => /* @__PURE__ */ s(
100
110
  "li",
101
111
  {
102
112
  role: "presentation",
103
- className: n(
113
+ className: i(
104
114
  "bear-py-2 bear-px-4 bear-text-xs bear-font-semibold bear-uppercase bear-tracking-wider",
105
115
  "bear-text-gray-500 dark:bear-text-gray-400",
106
116
  "bear-bg-gray-50 dark:bear-bg-gray-800/50",
107
- r && "bear-sticky bear-top-0 bear-z-10",
117
+ a && "bear-sticky bear-top-0 bear-z-10",
108
118
  e && "bear-pl-12",
109
- s
119
+ t
110
120
  ),
111
- "data-testid": i,
112
- ...t,
113
- children: a
121
+ "data-testid": o,
122
+ ...n,
123
+ children: r
114
124
  }
115
- ), V = ({
116
- primary: r,
125
+ ), Z = ({
126
+ primary: a,
117
127
  secondary: e,
118
- inset: s = !1,
119
- dense: a = !1,
120
- className: i,
121
- ...t
122
- }) => /* @__PURE__ */ f(
128
+ inset: t = !1,
129
+ dense: r = !1,
130
+ className: o,
131
+ ...n
132
+ }) => /* @__PURE__ */ y(
123
133
  "div",
124
134
  {
125
- className: n(
135
+ className: i(
126
136
  "bear-flex-1 bear-min-w-0",
127
- s && "bear-pl-9",
128
- i
137
+ t && "bear-pl-9",
138
+ o
129
139
  ),
130
- ...t,
140
+ ...n,
131
141
  children: [
132
- r && /* @__PURE__ */ b("div", { className: "bear-text-gray-900 dark:bear-text-gray-100", children: r }),
133
- e && /* @__PURE__ */ b("div", { className: n(
142
+ a && /* @__PURE__ */ s("div", { className: "bear-text-gray-900 dark:bear-text-gray-100", children: a }),
143
+ e && /* @__PURE__ */ s("div", { className: i(
134
144
  "bear-text-gray-500 dark:bear-text-gray-400",
135
- a ? "bear-text-xs" : "bear-text-sm"
145
+ r ? "bear-text-xs" : "bear-text-sm"
136
146
  ), children: e })
137
147
  ]
138
148
  }
139
- ), Z = ({
140
- align: r = "center",
149
+ ), q = ({
150
+ align: a = "center",
141
151
  className: e,
142
- children: s,
143
- ...a
144
- }) => /* @__PURE__ */ b(
152
+ children: t,
153
+ ...r
154
+ }) => /* @__PURE__ */ s(
145
155
  "div",
146
156
  {
147
- className: n(
157
+ className: i(
148
158
  "bear-flex-shrink-0 bear-min-w-[36px]",
149
159
  "bear-text-gray-500 dark:bear-text-gray-400",
150
- r === "top" && "bear-self-start bear-mt-1",
160
+ a === "top" && "bear-self-start bear-mt-1",
151
161
  e
152
162
  ),
153
- ...a,
154
- children: s
163
+ ...r,
164
+ children: t
155
165
  }
156
- ), q = ({
157
- selected: r = !1,
166
+ ), F = ({
167
+ selected: a = !1,
158
168
  disabled: e = !1,
159
- dense: s = !1,
160
- onClick: a,
161
- className: i,
162
- children: t,
163
- ...x
164
- }) => /* @__PURE__ */ b(
169
+ dense: t = !1,
170
+ onClick: r,
171
+ className: o,
172
+ children: n,
173
+ ...b
174
+ }) => /* @__PURE__ */ s(
165
175
  "div",
166
176
  {
167
177
  role: "button",
168
178
  tabIndex: e ? -1 : 0,
169
- "aria-selected": r,
179
+ "aria-selected": a,
170
180
  "aria-disabled": e,
171
- onClick: e ? void 0 : a,
172
- onKeyDown: (o) => {
173
- !e && (o.key === "Enter" || o.key === " ") && (o.preventDefault(), a == null || a());
181
+ onClick: e ? void 0 : r,
182
+ onKeyDown: (l) => {
183
+ !e && (l.key === "Enter" || l.key === " ") && (l.preventDefault(), r == null || r());
174
184
  },
175
- className: n(
185
+ className: i(
176
186
  "bear-flex bear-items-center bear-gap-3 bear-w-full bear-text-left",
177
- s ? "bear-py-1 bear-px-3" : "bear-py-2 bear-px-4",
187
+ t ? "bear-py-1 bear-px-3" : "bear-py-2 bear-px-4",
178
188
  "bear-cursor-pointer bear-transition-colors",
179
189
  "hover:bear-bg-gray-100 dark:hover:bear-bg-gray-800",
180
- r && "bear-bg-primary-50 dark:bear-bg-primary-900/20",
190
+ a && "bear-bg-primary-50 dark:bear-bg-primary-900/20",
181
191
  e && "bear-opacity-50 bear-cursor-not-allowed bear-pointer-events-none",
182
- i
192
+ o
183
193
  ),
184
- ...x,
185
- children: t
194
+ ...b,
195
+ children: n
186
196
  }
187
197
  );
188
198
  export {
189
- P as List,
199
+ K as List,
190
200
  j as ListItem,
191
- q as ListItemButton,
192
- Z as ListItemIcon,
193
- V as ListItemText,
194
- G as ListSubheader
201
+ F as ListItemButton,
202
+ q as ListItemIcon,
203
+ Z as ListItemText,
204
+ V as ListSubheader
195
205
  };
@@ -24,6 +24,8 @@ export interface ListItemProps extends HTMLAttributes<HTMLLIElement> {
24
24
  leading?: ReactNode;
25
25
  /** Trailing content (icon, button, badge) */
26
26
  trailing?: ReactNode;
27
+ /** Secondary action rendered after content; clicks do not trigger the row onClick */
28
+ secondaryAction?: ReactNode;
27
29
  /** Whether item is selected */
28
30
  selected?: boolean;
29
31
  /** Whether item is disabled */
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),r=require("react"),k=require("../../utils/cn.cjs"),W=require("../Portal/Portal.cjs"),Z=require("./MentionsInput.utils.cjs"),G=1e4,J={sm:"bear-h-8 bear-text-sm bear-px-3",md:"bear-h-10 bear-text-base bear-px-4",lg:"bear-h-12 bear-text-lg bear-px-5"},X=({value:x,defaultValue:L="",onChange:o,onMentionSelect:w,options:O,trigger:l="@",placeholder:P="Type @ to mention...",disabled:E=!1,maxSuggestions:D=5,filterOptions:T=Z.defaultFilter,size:A="md",fullWidth:_=!1,className:$})=>{const[B,I]=r.useState(L),[d,K]=r.useState(""),[Q,f]=r.useState(!1),[u,h]=r.useState(0),[p,F]=r.useState(null),q=r.useRef(null),g=r.useRef(null),m=r.useRef(null),z=r.useRef(null),[v,H]=r.useState({top:0,left:0,width:0}),i=x??B,b=T(O,d).slice(0,D),R=Q&&d.length>=0,y=R&&b.length>0,j=r.useCallback(()=>{const e=i.lastIndexOf(l);if(e===-1)return{query:"",start:null};const t=i.slice(e+l.length),n=t.indexOf(" ");return{query:n===-1?t:t.slice(0,n),start:e}},[i,l]);r.useEffect(()=>{const{query:e,start:t}=j();K(e),F(t),f(t!==null&&!e.includes(" "))},[i,j]),r.useEffect(()=>{h(0)},[d]),r.useEffect(()=>{if(u>=0&&m.current){const e=m.current.children[u];e==null||e.scrollIntoView({block:"nearest"})}},[u]),r.useEffect(()=>{if(!y)return;const e=()=>{var n;const t=(n=g.current)==null?void 0:n.getBoundingClientRect();t&&H({top:t.bottom+4,left:Math.max(8,Math.min(t.left,window.innerWidth-t.width-8)),width:t.width})};return e(),window.addEventListener("resize",e),window.addEventListener("scroll",e,!0),()=>{window.removeEventListener("resize",e),window.removeEventListener("scroll",e,!0)}},[y]),r.useEffect(()=>{const e=t=>{var s,c;const n=t.target;(s=q.current)!=null&&s.contains(n)||(c=z.current)!=null&&c.contains(n)||f(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const M=e=>{const t=new RegExp(`${l}(\\w+)`,"g"),n=[];let s;for(;(s=t.exec(e))!==null;)n.push(s[1]);return[...new Set(n)]},U=e=>{const t=e.target.value;x===void 0&&I(t),o==null||o(t,M(t))},N=e=>{var S;if(p==null)return;const t=i.slice(0,p),n=i.slice(p+l.length+d.length),s=`${l}${e.value}`,c=t+s+" "+n;x===void 0&&I(c),o==null||o(c,M(c)),w==null||w(e),f(!1),(S=g.current)==null||S.focus()},V=e=>{if(!(!R||b.length===0)){if(e.key==="ArrowDown"){e.preventDefault(),h(t=>Math.min(t+1,b.length-1));return}if(e.key==="ArrowUp"){e.preventDefault(),h(t=>Math.max(t-1,0));return}if(e.key==="Enter"||e.key==="Tab"){e.preventDefault();const t=b[u];t&&N(t);return}e.key==="Escape"&&f(!1)}};return a.jsxs("div",{ref:q,className:k.cn("Bear-MentionsInput bear-relative",_&&"bear-w-full",$),children:[a.jsx("input",{ref:g,type:"text",value:i,onChange:U,onKeyDown:V,placeholder:P,disabled:E,className:k.cn("bear-w-full bear-rounded-lg bear-border bear-border-gray-300 dark:bear-border-zinc-600 bear-bg-white dark:bear-bg-zinc-900 bear-text-gray-900 dark:bear-text-white placeholder:bear-text-gray-500 dark:placeholder:bear-text-zinc-500 bear-outline-none bear-transition-colors focus:bear-border-bear-500 focus:bear-ring-2 focus:bear-ring-bear-500/20",E&&"bear-opacity-50 bear-cursor-not-allowed",J[A])}),y&&a.jsx(W.Portal,{children:a.jsx("div",{ref:z,className:"bear-fixed bear-rounded-lg bear-border bear-border-gray-200 dark:bear-border-zinc-600 bear-bg-white dark:bear-bg-zinc-800 bear-shadow-lg",style:{top:v.top,left:v.left,width:v.width,zIndex:G},children:a.jsx("div",{ref:m,className:"bear-max-h-48 bear-overflow-auto bear-py-1",children:b.map((e,t)=>a.jsxs("button",{type:"button",className:k.cn("bear-w-full bear-flex bear-items-center bear-gap-2 bear-px-3 bear-py-2 bear-text-left bear-text-gray-800 dark:bear-text-zinc-200 hover:bear-bg-gray-100 dark:hover:bear-bg-zinc-700 bear-transition-colors",t===u&&"bear-bg-gray-100 dark:bear-bg-zinc-700"),onMouseEnter:()=>h(t),onClick:()=>N(e),children:[e.avatar&&a.jsx("span",{className:"bear-shrink-0",children:e.avatar}),a.jsx("span",{children:e.label})]},e.value))})})})]})};exports.MentionsInput=X;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),t=require("react"),w=require("../../utils/cn.cjs"),C=require("../Portal/Portal.cjs"),G=require("./MentionsInput.utils.cjs"),J=1e4,X=3,Y={sm:"bear-h-8 bear-text-sm bear-px-3",md:"bear-h-10 bear-text-base bear-px-4",lg:"bear-h-12 bear-text-lg bear-px-5"},ee={sm:"bear-text-sm bear-px-3 bear-py-2",md:"bear-text-base bear-px-4 bear-py-2",lg:"bear-text-lg bear-px-5 bear-py-3"},re=({value:g,defaultValue:T="",onChange:i,onMentionSelect:y,options:_,trigger:l="@",placeholder:z="Type @ to mention...",disabled:d=!1,maxSuggestions:A=5,filterOptions:K=G.defaultFilter,size:I="md",fullWidth:U=!1,className:$,multiline:B=!1,rows:F=X})=>{const[Q,R]=t.useState(T),[f,W]=t.useState(""),[H,x]=t.useState(!1),[b,h]=t.useState(0),[m,V]=t.useState(null),q=t.useRef(null),p=t.useRef(null),v=t.useRef(null),j=t.useRef(null),[k,Z]=t.useState({top:0,left:0,width:0}),s=g??Q,u=K(_,f).slice(0,A),L=H&&f.length>=0,E=L&&u.length>0,M=t.useCallback(()=>{const e=s.lastIndexOf(l);if(e===-1)return{query:"",start:null};const r=s.slice(e+l.length),a=r.indexOf(" ");return{query:a===-1?r:r.slice(0,a),start:e}},[s,l]);t.useEffect(()=>{const{query:e,start:r}=M();W(e),V(r),x(r!==null&&!e.includes(" "))},[s,M]),t.useEffect(()=>{h(0)},[f]),t.useEffect(()=>{if(b>=0&&v.current){const e=v.current.children[b];e==null||e.scrollIntoView({block:"nearest"})}},[b]),t.useEffect(()=>{if(!E)return;const e=()=>{var a;const r=(a=p.current)==null?void 0:a.getBoundingClientRect();r&&Z({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)}},[E]),t.useEffect(()=>{const e=r=>{var o,c;const a=r.target;(o=q.current)!=null&&o.contains(a)||(c=j.current)!=null&&c.contains(a)||x(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const N=e=>{const r=new RegExp(`${l}(\\w+)`,"g"),a=[];let o;for(;(o=r.exec(e))!==null;)a.push(o[1]);return[...new Set(a)]},S=e=>{const r=e.target.value;g===void 0&&R(r),i==null||i(r,N(r))},O=e=>{var P;if(m==null)return;const r=s.slice(0,m),a=s.slice(m+l.length+f.length),o=`${l}${e.value}`,c=r+o+" "+a;g===void 0&&R(c),i==null||i(c,N(c)),y==null||y(e),x(!1),(P=p.current)==null||P.focus()},D=e=>{if(!(!L||u.length===0)){if(e.key==="ArrowDown"){e.preventDefault(),h(r=>Math.min(r+1,u.length-1));return}if(e.key==="ArrowUp"){e.preventDefault(),h(r=>Math.max(r-1,0));return}if(e.key==="Enter"||e.key==="Tab"){e.preventDefault();const r=u[b];r&&O(r);return}e.key==="Escape"&&x(!1)}};return n.jsxs("div",{ref:q,className:w.cn("Bear-MentionsInput bear-relative",U&&"bear-w-full",$),children:[B?n.jsx("textarea",{ref:p,value:s,rows:F,onChange:S,onKeyDown:D,placeholder:z,disabled:d,className:w.cn("bear-w-full bear-rounded-lg bear-border bear-border-gray-300 dark:bear-border-zinc-600 bear-bg-white dark:bear-bg-zinc-900 bear-text-gray-900 dark:bear-text-white placeholder:bear-text-gray-500 dark:placeholder:bear-text-zinc-500 bear-outline-none bear-transition-colors focus:bear-border-bear-500 focus:bear-ring-2 focus:bear-ring-bear-500/20 bear-resize-none",d&&"bear-opacity-50 bear-cursor-not-allowed",ee[I])}):n.jsx("input",{ref:p,type:"text",value:s,onChange:S,onKeyDown:D,placeholder:z,disabled:d,className:w.cn("bear-w-full bear-rounded-lg bear-border bear-border-gray-300 dark:bear-border-zinc-600 bear-bg-white dark:bear-bg-zinc-900 bear-text-gray-900 dark:bear-text-white placeholder:bear-text-gray-500 dark:placeholder:bear-text-zinc-500 bear-outline-none bear-transition-colors focus:bear-border-bear-500 focus:bear-ring-2 focus:bear-ring-bear-500/20",d&&"bear-opacity-50 bear-cursor-not-allowed",Y[I])}),E&&n.jsx(C.Portal,{children:n.jsx("div",{ref:j,className:"bear-fixed bear-rounded-lg bear-border bear-border-gray-200 dark:bear-border-zinc-600 bear-bg-white dark:bear-bg-zinc-800 bear-shadow-lg",style:{top:k.top,left:k.left,width:k.width,zIndex:J},children:n.jsx("div",{ref:v,className:"bear-max-h-48 bear-overflow-auto bear-py-1",children:u.map((e,r)=>n.jsxs("button",{type:"button",className:w.cn("bear-w-full bear-flex bear-items-center bear-gap-2 bear-px-3 bear-py-2 bear-text-left bear-text-gray-800 dark:bear-text-zinc-200 hover:bear-bg-gray-100 dark:hover:bear-bg-zinc-700 bear-transition-colors",r===b&&"bear-bg-gray-100 dark:bear-bg-zinc-700"),onMouseEnter:()=>h(r),onClick:()=>O(e),children:[e.avatar&&n.jsx("span",{className:"bear-shrink-0",children:e.avatar}),n.jsx("span",{children:e.label})]},e.value))})})})]})};exports.MentionsInput=re;
@@ -1,149 +1,171 @@
1
- import { jsxs as T, jsx as l } from "react/jsx-runtime";
2
- import { useState as c, useRef as p, useCallback as J, useEffect as d } from "react";
3
- import { cn as z } from "../../utils/cn.js";
4
- import { Portal as X } from "../Portal/Portal.js";
5
- import { defaultFilter as Y } from "./MentionsInput.utils.js";
6
- const C = 1e4, ee = {
1
+ import { jsxs as K, jsx as s } from "react/jsx-runtime";
2
+ import { useState as b, useRef as w, useCallback as X, useEffect as d } from "react";
3
+ import { cn as g } from "../../utils/cn.js";
4
+ import { Portal as Y } from "../Portal/Portal.js";
5
+ import { defaultFilter as ee } from "./MentionsInput.utils.js";
6
+ const re = 1e4, te = 3, ae = {
7
7
  sm: "bear-h-8 bear-text-sm bear-px-3",
8
8
  md: "bear-h-10 bear-text-base bear-px-4",
9
9
  lg: "bear-h-12 bear-text-lg bear-px-5"
10
- }, oe = ({
11
- value: w,
12
- defaultValue: A = "",
13
- onChange: s,
14
- onMentionSelect: x,
10
+ }, ne = {
11
+ sm: "bear-text-sm bear-px-3 bear-py-2",
12
+ md: "bear-text-base bear-px-4 bear-py-2",
13
+ lg: "bear-text-lg bear-px-5 bear-py-3"
14
+ }, ce = ({
15
+ value: y,
16
+ defaultValue: U = "",
17
+ onChange: o,
18
+ onMentionSelect: v,
15
19
  options: $,
16
- trigger: o = "@",
17
- placeholder: j = "Type @ to mention...",
18
- disabled: I = !1,
19
- maxSuggestions: B = 5,
20
- filterOptions: K = Y,
21
- size: Q = "md",
22
- fullWidth: S = !1,
23
- className: _
20
+ trigger: i = "@",
21
+ placeholder: L = "Type @ to mention...",
22
+ disabled: f = !1,
23
+ maxSuggestions: j = 5,
24
+ filterOptions: B = ee,
25
+ size: N = "md",
26
+ fullWidth: F = !1,
27
+ className: Q,
28
+ multiline: W = !1,
29
+ rows: H = te
24
30
  }) => {
25
- const [F, N] = c(A), [f, H] = c(""), [U, h] = c(!1), [u, m] = c(0), [g, V] = c(null), L = p(null), v = p(null), y = p(null), q = p(null), [k, W] = c({ top: 0, left: 0, width: 0 }), a = w ?? F, b = K($, f).slice(0, B), M = U && f.length >= 0, E = M && b.length > 0, O = J(() => {
26
- const e = a.lastIndexOf(o);
31
+ const [V, D] = b(U), [h, Z] = b(""), [C, p] = b(!1), [c, x] = b(0), [k, G] = b(null), M = w(null), m = w(null), z = w(null), O = w(null), [E, J] = b({ top: 0, left: 0, width: 0 }), a = y ?? V, u = B($, h).slice(0, j), R = C && h.length >= 0, I = R && u.length > 0, q = X(() => {
32
+ const e = a.lastIndexOf(i);
27
33
  if (e === -1) return { query: "", start: null };
28
- const t = a.slice(e + o.length), r = t.indexOf(" ");
29
- return { query: r === -1 ? t : t.slice(0, r), start: e };
30
- }, [a, o]);
34
+ const r = a.slice(e + i.length), t = r.indexOf(" ");
35
+ return { query: t === -1 ? r : r.slice(0, t), start: e };
36
+ }, [a, i]);
31
37
  d(() => {
32
- const { query: e, start: t } = O();
33
- H(e), V(t), h(t !== null && !e.includes(" "));
34
- }, [a, O]), d(() => {
35
- m(0);
36
- }, [f]), d(() => {
37
- if (u >= 0 && y.current) {
38
- const e = y.current.children[u];
38
+ const { query: e, start: r } = q();
39
+ Z(e), G(r), p(r !== null && !e.includes(" "));
40
+ }, [a, q]), d(() => {
41
+ x(0);
42
+ }, [h]), d(() => {
43
+ if (c >= 0 && z.current) {
44
+ const e = z.current.children[c];
39
45
  e == null || e.scrollIntoView({ block: "nearest" });
40
46
  }
41
- }, [u]), d(() => {
42
- if (!E) return;
47
+ }, [c]), d(() => {
48
+ if (!I) return;
43
49
  const e = () => {
44
- var r;
45
- const t = (r = v.current) == null ? void 0 : r.getBoundingClientRect();
46
- t && W({
47
- top: t.bottom + 4,
48
- left: Math.max(8, Math.min(t.left, window.innerWidth - t.width - 8)),
49
- width: t.width
50
+ var t;
51
+ const r = (t = m.current) == null ? void 0 : t.getBoundingClientRect();
52
+ r && J({
53
+ top: r.bottom + 4,
54
+ left: Math.max(8, Math.min(r.left, window.innerWidth - r.width - 8)),
55
+ width: r.width
50
56
  });
51
57
  };
52
58
  return e(), window.addEventListener("resize", e), window.addEventListener("scroll", e, !0), () => {
53
59
  window.removeEventListener("resize", e), window.removeEventListener("scroll", e, !0);
54
60
  };
55
- }, [E]), d(() => {
56
- const e = (t) => {
57
- var n, i;
58
- const r = t.target;
59
- (n = L.current) != null && n.contains(r) || (i = q.current) != null && i.contains(r) || h(!1);
61
+ }, [I]), d(() => {
62
+ const e = (r) => {
63
+ var n, l;
64
+ const t = r.target;
65
+ (n = M.current) != null && n.contains(t) || (l = O.current) != null && l.contains(t) || p(!1);
60
66
  };
61
67
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
62
68
  }, []);
63
- const R = (e) => {
64
- const t = new RegExp(`${o}(\\w+)`, "g"), r = [];
69
+ const P = (e) => {
70
+ const r = new RegExp(`${i}(\\w+)`, "g"), t = [];
65
71
  let n;
66
- for (; (n = t.exec(e)) !== null; )
67
- r.push(n[1]);
68
- return [...new Set(r)];
69
- }, Z = (e) => {
70
- const t = e.target.value;
71
- w === void 0 && N(t), s == null || s(t, R(t));
72
- }, D = (e) => {
73
- var P;
74
- if (g == null) return;
75
- const t = a.slice(0, g), r = a.slice(g + o.length + f.length), n = `${o}${e.value}`, i = t + n + " " + r;
76
- w === void 0 && N(i), s == null || s(i, R(i)), x == null || x(e), h(!1), (P = v.current) == null || P.focus();
77
- }, G = (e) => {
78
- if (!(!M || b.length === 0)) {
72
+ for (; (n = r.exec(e)) !== null; )
73
+ t.push(n[1]);
74
+ return [...new Set(t)];
75
+ }, T = (e) => {
76
+ const r = e.target.value;
77
+ y === void 0 && D(r), o == null || o(r, P(r));
78
+ }, A = (e) => {
79
+ var _;
80
+ if (k == null) return;
81
+ const r = a.slice(0, k), t = a.slice(k + i.length + h.length), n = `${i}${e.value}`, l = r + n + " " + t;
82
+ y === void 0 && D(l), o == null || o(l, P(l)), v == null || v(e), p(!1), (_ = m.current) == null || _.focus();
83
+ }, S = (e) => {
84
+ if (!(!R || u.length === 0)) {
79
85
  if (e.key === "ArrowDown") {
80
- e.preventDefault(), m((t) => Math.min(t + 1, b.length - 1));
86
+ e.preventDefault(), x((r) => Math.min(r + 1, u.length - 1));
81
87
  return;
82
88
  }
83
89
  if (e.key === "ArrowUp") {
84
- e.preventDefault(), m((t) => Math.max(t - 1, 0));
90
+ e.preventDefault(), x((r) => Math.max(r - 1, 0));
85
91
  return;
86
92
  }
87
93
  if (e.key === "Enter" || e.key === "Tab") {
88
94
  e.preventDefault();
89
- const t = b[u];
90
- t && D(t);
95
+ const r = u[c];
96
+ r && A(r);
91
97
  return;
92
98
  }
93
- e.key === "Escape" && h(!1);
99
+ e.key === "Escape" && p(!1);
94
100
  }
95
101
  };
96
- return /* @__PURE__ */ T(
102
+ return /* @__PURE__ */ K(
97
103
  "div",
98
104
  {
99
- ref: L,
100
- className: z(
105
+ ref: M,
106
+ className: g(
101
107
  "Bear-MentionsInput bear-relative",
102
- S && "bear-w-full",
103
- _
108
+ F && "bear-w-full",
109
+ Q
104
110
  ),
105
111
  children: [
106
- /* @__PURE__ */ l(
112
+ W ? /* @__PURE__ */ s(
113
+ "textarea",
114
+ {
115
+ ref: m,
116
+ value: a,
117
+ rows: H,
118
+ onChange: T,
119
+ onKeyDown: S,
120
+ placeholder: L,
121
+ disabled: f,
122
+ className: g(
123
+ "bear-w-full bear-rounded-lg bear-border bear-border-gray-300 dark:bear-border-zinc-600 bear-bg-white dark:bear-bg-zinc-900 bear-text-gray-900 dark:bear-text-white placeholder:bear-text-gray-500 dark:placeholder:bear-text-zinc-500 bear-outline-none bear-transition-colors focus:bear-border-bear-500 focus:bear-ring-2 focus:bear-ring-bear-500/20 bear-resize-none",
124
+ f && "bear-opacity-50 bear-cursor-not-allowed",
125
+ ne[N]
126
+ )
127
+ }
128
+ ) : /* @__PURE__ */ s(
107
129
  "input",
108
130
  {
109
- ref: v,
131
+ ref: m,
110
132
  type: "text",
111
133
  value: a,
112
- onChange: Z,
113
- onKeyDown: G,
114
- placeholder: j,
115
- disabled: I,
116
- className: z(
134
+ onChange: T,
135
+ onKeyDown: S,
136
+ placeholder: L,
137
+ disabled: f,
138
+ className: g(
117
139
  "bear-w-full bear-rounded-lg bear-border bear-border-gray-300 dark:bear-border-zinc-600 bear-bg-white dark:bear-bg-zinc-900 bear-text-gray-900 dark:bear-text-white placeholder:bear-text-gray-500 dark:placeholder:bear-text-zinc-500 bear-outline-none bear-transition-colors focus:bear-border-bear-500 focus:bear-ring-2 focus:bear-ring-bear-500/20",
118
- I && "bear-opacity-50 bear-cursor-not-allowed",
119
- ee[Q]
140
+ f && "bear-opacity-50 bear-cursor-not-allowed",
141
+ ae[N]
120
142
  )
121
143
  }
122
144
  ),
123
- E && /* @__PURE__ */ l(X, { children: /* @__PURE__ */ l(
145
+ I && /* @__PURE__ */ s(Y, { children: /* @__PURE__ */ s(
124
146
  "div",
125
147
  {
126
- ref: q,
148
+ ref: O,
127
149
  className: "bear-fixed bear-rounded-lg bear-border bear-border-gray-200 dark:bear-border-zinc-600 bear-bg-white dark:bear-bg-zinc-800 bear-shadow-lg",
128
150
  style: {
129
- top: k.top,
130
- left: k.left,
131
- width: k.width,
132
- zIndex: C
151
+ top: E.top,
152
+ left: E.left,
153
+ width: E.width,
154
+ zIndex: re
133
155
  },
134
- children: /* @__PURE__ */ l("div", { ref: y, className: "bear-max-h-48 bear-overflow-auto bear-py-1", children: b.map((e, t) => /* @__PURE__ */ T(
156
+ children: /* @__PURE__ */ s("div", { ref: z, className: "bear-max-h-48 bear-overflow-auto bear-py-1", children: u.map((e, r) => /* @__PURE__ */ K(
135
157
  "button",
136
158
  {
137
159
  type: "button",
138
- className: z(
160
+ className: g(
139
161
  "bear-w-full bear-flex bear-items-center bear-gap-2 bear-px-3 bear-py-2 bear-text-left bear-text-gray-800 dark:bear-text-zinc-200 hover:bear-bg-gray-100 dark:hover:bear-bg-zinc-700 bear-transition-colors",
140
- t === u && "bear-bg-gray-100 dark:bear-bg-zinc-700"
162
+ r === c && "bear-bg-gray-100 dark:bear-bg-zinc-700"
141
163
  ),
142
- onMouseEnter: () => m(t),
143
- onClick: () => D(e),
164
+ onMouseEnter: () => x(r),
165
+ onClick: () => A(e),
144
166
  children: [
145
- e.avatar && /* @__PURE__ */ l("span", { className: "bear-shrink-0", children: e.avatar }),
146
- /* @__PURE__ */ l("span", { children: e.label })
167
+ e.avatar && /* @__PURE__ */ s("span", { className: "bear-shrink-0", children: e.avatar }),
168
+ /* @__PURE__ */ s("span", { children: e.label })
147
169
  ]
148
170
  },
149
171
  e.value
@@ -155,5 +177,5 @@ const C = 1e4, ee = {
155
177
  );
156
178
  };
157
179
  export {
158
- oe as MentionsInput
180
+ ce as MentionsInput
159
181
  };