@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.
- package/README.md +15 -0
- package/dist/components/AppBar/AppBar.cjs +1 -1
- package/dist/components/AppBar/AppBar.const.cjs +1 -0
- package/dist/components/AppBar/AppBar.const.d.ts +36 -1
- package/dist/components/AppBar/AppBar.const.js +39 -0
- package/dist/components/AppBar/AppBar.js +65 -42
- package/dist/components/AppBar/AppBar.types.d.ts +9 -3
- package/dist/components/Backdrop/Backdrop.cjs +1 -0
- package/dist/components/Backdrop/Backdrop.const.cjs +1 -0
- package/dist/components/Backdrop/Backdrop.const.d.ts +7 -0
- package/dist/components/Backdrop/Backdrop.const.js +10 -0
- package/dist/components/Backdrop/Backdrop.d.ts +3 -0
- package/dist/components/Backdrop/Backdrop.js +43 -0
- package/dist/components/Backdrop/Backdrop.types.d.ts +12 -0
- package/dist/components/Backdrop/index.d.ts +2 -0
- package/dist/components/BottomNavigation/BottomNavigation.cjs +1 -1
- package/dist/components/BottomNavigation/BottomNavigation.const.cjs +1 -0
- package/dist/components/BottomNavigation/BottomNavigation.const.d.ts +8 -1
- package/dist/components/BottomNavigation/BottomNavigation.const.js +11 -0
- package/dist/components/BottomNavigation/BottomNavigation.js +64 -46
- package/dist/components/Breadcrumbs/Breadcrumbs.cjs +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.js +65 -64
- package/dist/components/Card/Card.types.d.ts +1 -2
- package/dist/components/Chat/Chat.const.cjs +1 -1
- package/dist/components/Chat/Chat.const.d.ts +1 -1
- package/dist/components/Chat/Chat.const.js +1 -1
- package/dist/components/Chip/Chip.cjs +1 -1
- package/dist/components/Chip/Chip.const.cjs +1 -0
- package/dist/components/Chip/Chip.const.d.ts +39 -0
- package/dist/components/Chip/Chip.const.js +43 -0
- package/dist/components/Chip/Chip.js +44 -65
- package/dist/components/ChipGroup/ChipGroup.cjs +1 -0
- package/dist/components/ChipGroup/ChipGroup.const.cjs +1 -0
- package/dist/components/ChipGroup/ChipGroup.const.d.ts +8 -0
- package/dist/components/ChipGroup/ChipGroup.const.js +11 -0
- package/dist/components/ChipGroup/ChipGroup.d.ts +3 -0
- package/dist/components/ChipGroup/ChipGroup.js +41 -0
- package/dist/components/ChipGroup/ChipGroup.types.d.ts +9 -0
- package/dist/components/ChipGroup/index.d.ts +2 -0
- package/dist/components/ColorSwatch/ColorSwatch.cjs +1 -1
- package/dist/components/ColorSwatch/ColorSwatch.js +8 -8
- package/dist/components/CommandPalette/CommandPalette.cjs +1 -1
- package/dist/components/CommandPalette/CommandPalette.js +71 -71
- package/dist/components/DiffSquares/DiffSquares.cjs +1 -1
- package/dist/components/DiffSquares/DiffSquares.js +11 -11
- package/dist/components/Drawer/Drawer.cjs +1 -1
- package/dist/components/Drawer/Drawer.js +57 -56
- package/dist/components/Input/Input.cjs +1 -1
- package/dist/components/Input/Input.js +63 -62
- package/dist/components/List/List.cjs +1 -1
- package/dist/components/List/List.js +133 -123
- package/dist/components/List/List.types.d.ts +2 -0
- package/dist/components/MentionsInput/MentionsInput.cjs +1 -1
- package/dist/components/MentionsInput/MentionsInput.js +114 -92
- package/dist/components/MentionsInput/MentionsInput.types.d.ts +4 -0
- package/dist/components/MessageList/MessageList.cjs +1 -0
- package/dist/components/MessageList/MessageList.const.cjs +1 -0
- package/dist/components/MessageList/MessageList.const.d.ts +29 -0
- package/dist/components/MessageList/MessageList.const.js +36 -0
- package/dist/components/MessageList/MessageList.d.ts +3 -0
- package/dist/components/MessageList/MessageList.js +194 -0
- package/dist/components/MessageList/MessageList.types.d.ts +74 -0
- package/dist/components/MessageList/MessageList.utils.cjs +1 -0
- package/dist/components/MessageList/MessageList.utils.d.ts +13 -0
- package/dist/components/MessageList/MessageList.utils.js +54 -0
- package/dist/components/MessageList/index.d.ts +2 -0
- package/dist/components/Progress/Progress.cjs +1 -1
- package/dist/components/Progress/Progress.const.cjs +1 -0
- package/dist/components/Progress/Progress.const.d.ts +16 -1
- package/dist/components/Progress/Progress.const.js +19 -0
- package/dist/components/Progress/Progress.d.ts +0 -10
- package/dist/components/Progress/Progress.js +81 -71
- package/dist/components/Progress/Progress.types.d.ts +2 -11
- package/dist/components/PropsPlayground/PropsPlayground.cjs +1 -1
- package/dist/components/PropsPlayground/PropsPlayground.js +40 -40
- package/dist/components/Select/Select.cjs +1 -1
- package/dist/components/Select/Select.const.cjs +1 -0
- package/dist/components/Select/Select.const.d.ts +9 -0
- package/dist/components/Select/Select.const.js +13 -0
- package/dist/components/Select/Select.js +144 -68
- package/dist/components/Stepper/Stepper.cjs +1 -1
- package/dist/components/Stepper/Stepper.js +89 -83
- package/dist/components/Toast/Toast.cjs +1 -1
- package/dist/components/Toast/Toast.const.cjs +1 -0
- package/dist/components/Toast/Toast.const.d.ts +4 -0
- package/dist/components/Toast/Toast.const.js +17 -0
- package/dist/components/Toast/Toast.d.ts +3 -7
- package/dist/components/Toast/Toast.js +101 -89
- package/dist/components/Toast/Toast.types.d.ts +9 -0
- package/dist/components/Toast/index.d.ts +1 -1
- package/dist/components/TreeSelect/TreeSelect.cjs +1 -1
- package/dist/components/TreeSelect/TreeSelect.js +22 -22
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.d.ts +7 -1
- package/dist/components/index.js +284 -278
- package/dist/context/BearProvider.cjs +1 -1
- package/dist/context/BearProvider.d.ts +8 -0
- package/dist/context/BearProvider.js +149 -139
- package/dist/context/index.cjs +1 -1
- package/dist/context/index.d.ts +1 -1
- package/dist/context/index.js +12 -10
- package/dist/index.cjs +1 -1
- package/dist/index.js +392 -384
- package/dist/styles/_message-list.css +42 -0
- package/dist/styles/main.css +1 -0
- package/dist/styles.css +114 -19
- package/package.json +15 -2
|
@@ -1,195 +1,205 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { cn as
|
|
4
|
-
import { LIST_VARIANT_CLASSES as
|
|
5
|
-
const
|
|
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:
|
|
8
|
-
size:
|
|
9
|
-
hoverable:
|
|
10
|
-
dense:
|
|
11
|
-
disablePadding:
|
|
12
|
-
className:
|
|
13
|
-
children:
|
|
14
|
-
testId:
|
|
15
|
-
...
|
|
16
|
-
} =
|
|
17
|
-
return /* @__PURE__ */
|
|
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:
|
|
23
|
-
|
|
24
|
-
!
|
|
25
|
-
E[
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
className: i(
|
|
23
|
+
T,
|
|
24
|
+
!b && B,
|
|
25
|
+
E[r],
|
|
26
|
+
D[t],
|
|
27
|
+
l
|
|
28
28
|
),
|
|
29
|
-
"data-testid":
|
|
30
|
-
...
|
|
31
|
-
children:
|
|
29
|
+
"data-testid": g,
|
|
30
|
+
...c,
|
|
31
|
+
children: m
|
|
32
32
|
}
|
|
33
33
|
) });
|
|
34
34
|
});
|
|
35
|
-
|
|
36
|
-
const j =
|
|
37
|
-
primary:
|
|
35
|
+
K.displayName = "List";
|
|
36
|
+
const j = v(({
|
|
37
|
+
primary: a,
|
|
38
38
|
secondary: e,
|
|
39
|
-
leading:
|
|
40
|
-
trailing:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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:
|
|
53
|
-
return /* @__PURE__ */
|
|
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:
|
|
58
|
-
tabIndex:
|
|
59
|
-
"aria-selected":
|
|
60
|
-
"aria-disabled":
|
|
61
|
-
onClick:
|
|
62
|
-
onKeyDown: (
|
|
63
|
-
!
|
|
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:
|
|
66
|
+
className: i(
|
|
67
|
+
"Bear-ListItem",
|
|
66
68
|
"bear-flex bear-items-center bear-gap-3",
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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":
|
|
77
|
+
"data-testid": I,
|
|
76
78
|
...N,
|
|
77
79
|
children: [
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
e && /* @__PURE__ */
|
|
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
|
-
|
|
85
|
+
p ? "bear-text-xs" : "bear-text-sm"
|
|
84
86
|
), children: e })
|
|
85
|
-
] }) : /* @__PURE__ */
|
|
86
|
-
|
|
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
|
|
93
|
-
sticky:
|
|
102
|
+
const V = ({
|
|
103
|
+
sticky: a = !1,
|
|
94
104
|
inset: e = !1,
|
|
95
|
-
className:
|
|
96
|
-
children:
|
|
97
|
-
testId:
|
|
98
|
-
...
|
|
99
|
-
}) => /* @__PURE__ */
|
|
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:
|
|
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
|
-
|
|
117
|
+
a && "bear-sticky bear-top-0 bear-z-10",
|
|
108
118
|
e && "bear-pl-12",
|
|
109
|
-
|
|
119
|
+
t
|
|
110
120
|
),
|
|
111
|
-
"data-testid":
|
|
112
|
-
...
|
|
113
|
-
children:
|
|
121
|
+
"data-testid": o,
|
|
122
|
+
...n,
|
|
123
|
+
children: r
|
|
114
124
|
}
|
|
115
|
-
),
|
|
116
|
-
primary:
|
|
125
|
+
), Z = ({
|
|
126
|
+
primary: a,
|
|
117
127
|
secondary: e,
|
|
118
|
-
inset:
|
|
119
|
-
dense:
|
|
120
|
-
className:
|
|
121
|
-
...
|
|
122
|
-
}) => /* @__PURE__ */
|
|
128
|
+
inset: t = !1,
|
|
129
|
+
dense: r = !1,
|
|
130
|
+
className: o,
|
|
131
|
+
...n
|
|
132
|
+
}) => /* @__PURE__ */ y(
|
|
123
133
|
"div",
|
|
124
134
|
{
|
|
125
|
-
className:
|
|
135
|
+
className: i(
|
|
126
136
|
"bear-flex-1 bear-min-w-0",
|
|
127
|
-
|
|
128
|
-
|
|
137
|
+
t && "bear-pl-9",
|
|
138
|
+
o
|
|
129
139
|
),
|
|
130
|
-
...
|
|
140
|
+
...n,
|
|
131
141
|
children: [
|
|
132
|
-
|
|
133
|
-
e && /* @__PURE__ */
|
|
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
|
-
|
|
145
|
+
r ? "bear-text-xs" : "bear-text-sm"
|
|
136
146
|
), children: e })
|
|
137
147
|
]
|
|
138
148
|
}
|
|
139
|
-
),
|
|
140
|
-
align:
|
|
149
|
+
), q = ({
|
|
150
|
+
align: a = "center",
|
|
141
151
|
className: e,
|
|
142
|
-
children:
|
|
143
|
-
...
|
|
144
|
-
}) => /* @__PURE__ */
|
|
152
|
+
children: t,
|
|
153
|
+
...r
|
|
154
|
+
}) => /* @__PURE__ */ s(
|
|
145
155
|
"div",
|
|
146
156
|
{
|
|
147
|
-
className:
|
|
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
|
-
|
|
160
|
+
a === "top" && "bear-self-start bear-mt-1",
|
|
151
161
|
e
|
|
152
162
|
),
|
|
153
|
-
...
|
|
154
|
-
children:
|
|
163
|
+
...r,
|
|
164
|
+
children: t
|
|
155
165
|
}
|
|
156
|
-
),
|
|
157
|
-
selected:
|
|
166
|
+
), F = ({
|
|
167
|
+
selected: a = !1,
|
|
158
168
|
disabled: e = !1,
|
|
159
|
-
dense:
|
|
160
|
-
onClick:
|
|
161
|
-
className:
|
|
162
|
-
children:
|
|
163
|
-
...
|
|
164
|
-
}) => /* @__PURE__ */
|
|
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":
|
|
179
|
+
"aria-selected": a,
|
|
170
180
|
"aria-disabled": e,
|
|
171
|
-
onClick: e ? void 0 :
|
|
172
|
-
onKeyDown: (
|
|
173
|
-
!e && (
|
|
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:
|
|
185
|
+
className: i(
|
|
176
186
|
"bear-flex bear-items-center bear-gap-3 bear-w-full bear-text-left",
|
|
177
|
-
|
|
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
|
-
|
|
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
|
-
|
|
192
|
+
o
|
|
183
193
|
),
|
|
184
|
-
...
|
|
185
|
-
children:
|
|
194
|
+
...b,
|
|
195
|
+
children: n
|
|
186
196
|
}
|
|
187
197
|
);
|
|
188
198
|
export {
|
|
189
|
-
|
|
199
|
+
K as List,
|
|
190
200
|
j as ListItem,
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
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
|
|
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
|
|
2
|
-
import { useState as
|
|
3
|
-
import { cn as
|
|
4
|
-
import { Portal as
|
|
5
|
-
import { defaultFilter as
|
|
6
|
-
const
|
|
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
|
-
},
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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:
|
|
17
|
-
placeholder:
|
|
18
|
-
disabled:
|
|
19
|
-
maxSuggestions:
|
|
20
|
-
filterOptions:
|
|
21
|
-
size:
|
|
22
|
-
fullWidth:
|
|
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 [
|
|
26
|
-
const e = a.lastIndexOf(
|
|
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
|
|
29
|
-
return { query:
|
|
30
|
-
}, [a,
|
|
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:
|
|
33
|
-
|
|
34
|
-
}, [a,
|
|
35
|
-
|
|
36
|
-
}, [
|
|
37
|
-
if (
|
|
38
|
-
const e =
|
|
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
|
-
}, [
|
|
42
|
-
if (!
|
|
47
|
+
}, [c]), d(() => {
|
|
48
|
+
if (!I) return;
|
|
43
49
|
const e = () => {
|
|
44
|
-
var
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
top:
|
|
48
|
-
left: Math.max(8, Math.min(
|
|
49
|
-
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
|
-
}, [
|
|
56
|
-
const e = (
|
|
57
|
-
var n,
|
|
58
|
-
const
|
|
59
|
-
(n =
|
|
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
|
|
64
|
-
const
|
|
69
|
+
const P = (e) => {
|
|
70
|
+
const r = new RegExp(`${i}(\\w+)`, "g"), t = [];
|
|
65
71
|
let n;
|
|
66
|
-
for (; (n =
|
|
67
|
-
|
|
68
|
-
return [...new Set(
|
|
69
|
-
},
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
},
|
|
73
|
-
var
|
|
74
|
-
if (
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
},
|
|
78
|
-
if (!(!
|
|
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(),
|
|
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(),
|
|
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
|
|
90
|
-
|
|
95
|
+
const r = u[c];
|
|
96
|
+
r && A(r);
|
|
91
97
|
return;
|
|
92
98
|
}
|
|
93
|
-
e.key === "Escape" &&
|
|
99
|
+
e.key === "Escape" && p(!1);
|
|
94
100
|
}
|
|
95
101
|
};
|
|
96
|
-
return /* @__PURE__ */
|
|
102
|
+
return /* @__PURE__ */ K(
|
|
97
103
|
"div",
|
|
98
104
|
{
|
|
99
|
-
ref:
|
|
100
|
-
className:
|
|
105
|
+
ref: M,
|
|
106
|
+
className: g(
|
|
101
107
|
"Bear-MentionsInput bear-relative",
|
|
102
|
-
|
|
103
|
-
|
|
108
|
+
F && "bear-w-full",
|
|
109
|
+
Q
|
|
104
110
|
),
|
|
105
111
|
children: [
|
|
106
|
-
/* @__PURE__ */
|
|
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:
|
|
131
|
+
ref: m,
|
|
110
132
|
type: "text",
|
|
111
133
|
value: a,
|
|
112
|
-
onChange:
|
|
113
|
-
onKeyDown:
|
|
114
|
-
placeholder:
|
|
115
|
-
disabled:
|
|
116
|
-
className:
|
|
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
|
-
|
|
119
|
-
|
|
140
|
+
f && "bear-opacity-50 bear-cursor-not-allowed",
|
|
141
|
+
ae[N]
|
|
120
142
|
)
|
|
121
143
|
}
|
|
122
144
|
),
|
|
123
|
-
|
|
145
|
+
I && /* @__PURE__ */ s(Y, { children: /* @__PURE__ */ s(
|
|
124
146
|
"div",
|
|
125
147
|
{
|
|
126
|
-
ref:
|
|
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:
|
|
130
|
-
left:
|
|
131
|
-
width:
|
|
132
|
-
zIndex:
|
|
151
|
+
top: E.top,
|
|
152
|
+
left: E.left,
|
|
153
|
+
width: E.width,
|
|
154
|
+
zIndex: re
|
|
133
155
|
},
|
|
134
|
-
children: /* @__PURE__ */
|
|
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:
|
|
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
|
-
|
|
162
|
+
r === c && "bear-bg-gray-100 dark:bear-bg-zinc-700"
|
|
141
163
|
),
|
|
142
|
-
onMouseEnter: () =>
|
|
143
|
-
onClick: () =>
|
|
164
|
+
onMouseEnter: () => x(r),
|
|
165
|
+
onClick: () => A(e),
|
|
144
166
|
children: [
|
|
145
|
-
e.avatar && /* @__PURE__ */
|
|
146
|
-
/* @__PURE__ */
|
|
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
|
-
|
|
180
|
+
ce as MentionsInput
|
|
159
181
|
};
|