@forgedevstack/bear 1.2.5 → 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 (87) 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/Chip/Chip.cjs +1 -1
  24. package/dist/components/Chip/Chip.const.cjs +1 -0
  25. package/dist/components/Chip/Chip.const.d.ts +39 -0
  26. package/dist/components/Chip/Chip.const.js +43 -0
  27. package/dist/components/Chip/Chip.js +44 -65
  28. package/dist/components/ChipGroup/ChipGroup.cjs +1 -0
  29. package/dist/components/ChipGroup/ChipGroup.const.cjs +1 -0
  30. package/dist/components/ChipGroup/ChipGroup.const.d.ts +8 -0
  31. package/dist/components/ChipGroup/ChipGroup.const.js +11 -0
  32. package/dist/components/ChipGroup/ChipGroup.d.ts +3 -0
  33. package/dist/components/ChipGroup/ChipGroup.js +41 -0
  34. package/dist/components/ChipGroup/ChipGroup.types.d.ts +9 -0
  35. package/dist/components/ChipGroup/index.d.ts +2 -0
  36. package/dist/components/Drawer/Drawer.cjs +1 -1
  37. package/dist/components/Drawer/Drawer.js +57 -56
  38. package/dist/components/Input/Input.cjs +1 -1
  39. package/dist/components/Input/Input.js +63 -62
  40. package/dist/components/List/List.cjs +1 -1
  41. package/dist/components/List/List.js +133 -123
  42. package/dist/components/List/List.types.d.ts +2 -0
  43. package/dist/components/MessageList/MessageList.cjs +1 -1
  44. package/dist/components/MessageList/MessageList.const.cjs +1 -1
  45. package/dist/components/MessageList/MessageList.const.d.ts +6 -0
  46. package/dist/components/MessageList/MessageList.const.js +26 -20
  47. package/dist/components/MessageList/MessageList.d.ts +0 -16
  48. package/dist/components/MessageList/MessageList.js +127 -115
  49. package/dist/components/MessageList/MessageList.types.d.ts +2 -0
  50. package/dist/components/MessageList/MessageList.utils.cjs +1 -1
  51. package/dist/components/MessageList/MessageList.utils.d.ts +7 -0
  52. package/dist/components/MessageList/MessageList.utils.js +47 -28
  53. package/dist/components/Progress/Progress.cjs +1 -1
  54. package/dist/components/Progress/Progress.const.cjs +1 -0
  55. package/dist/components/Progress/Progress.const.d.ts +16 -1
  56. package/dist/components/Progress/Progress.const.js +19 -0
  57. package/dist/components/Progress/Progress.d.ts +0 -10
  58. package/dist/components/Progress/Progress.js +81 -71
  59. package/dist/components/Progress/Progress.types.d.ts +2 -11
  60. package/dist/components/PropsPlayground/PropsPlayground.cjs +1 -1
  61. package/dist/components/PropsPlayground/PropsPlayground.js +40 -40
  62. package/dist/components/Select/Select.cjs +1 -1
  63. package/dist/components/Select/Select.const.cjs +1 -0
  64. package/dist/components/Select/Select.const.d.ts +9 -0
  65. package/dist/components/Select/Select.const.js +13 -0
  66. package/dist/components/Select/Select.js +144 -68
  67. package/dist/components/Stepper/Stepper.cjs +1 -1
  68. package/dist/components/Stepper/Stepper.js +89 -83
  69. package/dist/components/Toast/Toast.cjs +1 -1
  70. package/dist/components/Toast/Toast.const.cjs +1 -0
  71. package/dist/components/Toast/Toast.const.d.ts +4 -0
  72. package/dist/components/Toast/Toast.const.js +17 -0
  73. package/dist/components/Toast/Toast.d.ts +0 -1
  74. package/dist/components/Toast/Toast.js +90 -84
  75. package/dist/components/index.cjs +1 -1
  76. package/dist/components/index.d.ts +4 -0
  77. package/dist/components/index.js +277 -273
  78. package/dist/context/BearProvider.cjs +1 -1
  79. package/dist/context/BearProvider.d.ts +8 -0
  80. package/dist/context/BearProvider.js +149 -139
  81. package/dist/context/index.cjs +1 -1
  82. package/dist/context/index.d.ts +1 -1
  83. package/dist/context/index.js +12 -10
  84. package/dist/index.cjs +1 -1
  85. package/dist/index.js +385 -379
  86. package/dist/styles.css +67 -19
  87. package/package.json +1 -1
@@ -1,119 +1,126 @@
1
- import { jsxs as _, jsx as n } from "react/jsx-runtime";
2
- import { useRef as I, useState as j, useEffect as k } from "react";
3
- import { Avatar as z } from "../Avatar/Avatar.js";
4
- import { Typography as r } from "../Typography/Typography.js";
5
- import { MESSAGE_LIST_DEFAULT_HEIGHT as X, MESSAGE_LIST_DEFAULT_TRANSLATIONS as q, MESSAGE_LIST_EMPTY_CLASSES as J, MESSAGE_LIST_ROOT_CLASS as t, MESSAGE_LIST_DAY_LINE_CLASSES as N, MESSAGE_LIST_DAY_LABEL_CLASSES as K, MESSAGE_LIST_DAY_SEPARATOR_CLASSES as Q, MESSAGE_LIST_SCROLLER_CLASSES as V, MESSAGE_LIST_NEW_MESSAGES_CLASSES as Z, MESSAGE_LIST_BASE_CLASSES as g, MESSAGE_LIST_GROUP_WINDOW_MS as SS, MESSAGE_LIST_AUTHOR_CLASSES as tS, MESSAGE_LIST_TIMESTAMP_CLASSES as f, MESSAGE_LIST_META_CLASSES as eS, MESSAGE_LIST_BUBBLE_OWN_CLASSES as sS, MESSAGE_LIST_BUBBLE_CLASSES as nS, MESSAGE_LIST_GROUP_BODY_OWN_CLASSES as _S, MESSAGE_LIST_GROUP_BODY_CLASSES as aS, MESSAGE_LIST_GROUP_OWN_CLASSES as lS, MESSAGE_LIST_GROUP_CLASSES as rS, MESSAGE_LIST_BOTTOM_THRESHOLD_PX as cS } from "./MessageList.const.js";
6
- import { buildMessageListItems as oS, getDefaultDayLabel as ES, getDefaultTimestamp as iS } from "./MessageList.utils.js";
7
- import { cn as e } from "../../utils/cn.js";
8
- import { resolveBearId as AS } from "../../utils/generateBearId.utils.js";
9
- import { useBearId as LS } from "../../utils/useBearId.js";
10
- const OS = ({
11
- id: B,
12
- testId: R,
13
- messages: a,
14
- currentUserId: v,
15
- groupWindowMs: C = SS,
16
- showDaySeparators: $ = !0,
17
- showAvatars: b = !0,
18
- showTimestamps: h = !0,
19
- autoScroll: u = !0,
20
- height: c = X,
21
- renderMessage: o,
22
- emptyState: y,
23
- formatDayLabel: E,
24
- formatTimestamp: i,
25
- translations: U,
26
- onNewMessagesClick: A,
27
- className: H
1
+ import { jsxs as o, jsx as S } from "react/jsx-runtime";
2
+ import { useRef as u, useState as h, useEffect as b } from "react";
3
+ import { Avatar as et } from "../Avatar/Avatar.js";
4
+ import { Typography as E } from "../Typography/Typography.js";
5
+ import { MESSAGE_LIST_DEFAULT_HEIGHT as y, MESSAGE_LIST_VIRTUALIZE_THRESHOLD as st, MESSAGE_LIST_DEFAULT_TRANSLATIONS as St, MESSAGE_LIST_EMPTY_CLASSES as nt, MESSAGE_LIST_ROOT_CLASS as e, MESSAGE_LIST_SCROLLER_CLASSES as lt, MESSAGE_LIST_NEW_MESSAGES_CLASSES as _t, MESSAGE_LIST_BASE_CLASSES as rt, MESSAGE_LIST_GROUP_WINDOW_MS as ot, MESSAGE_LIST_OVERSCAN as at, MESSAGE_LIST_DAY_LINE_CLASSES as C, MESSAGE_LIST_DAY_LABEL_CLASSES as ct, MESSAGE_LIST_DAY_SEPARATOR_CLASSES as it, MESSAGE_LIST_BOTTOM_THRESHOLD_PX as Et, MESSAGE_LIST_AUTHOR_CLASSES as At, MESSAGE_LIST_TIMESTAMP_CLASSES as H, MESSAGE_LIST_META_CLASSES as dt, MESSAGE_LIST_BUBBLE_OWN_CLASSES as Lt, MESSAGE_LIST_BUBBLE_CLASSES as mt, MESSAGE_LIST_GROUP_BODY_OWN_CLASSES as Tt, MESSAGE_LIST_GROUP_BODY_CLASSES as It, MESSAGE_LIST_GROUP_OWN_CLASSES as pt, MESSAGE_LIST_GROUP_CLASSES as ut } from "./MessageList.const.js";
6
+ import { buildMessageListItems as ht, getMessageListWindow as Gt, getDefaultDayLabel as Mt, getDefaultTimestamp as Ot } from "./MessageList.utils.js";
7
+ import { cn as s } from "../../utils/cn.js";
8
+ import { resolveBearId as ft } from "../../utils/generateBearId.utils.js";
9
+ import { useBearId as Nt } from "../../utils/useBearId.js";
10
+ const Ut = ({
11
+ id: w,
12
+ testId: U,
13
+ messages: l,
14
+ currentUserId: D,
15
+ groupWindowMs: P = ot,
16
+ showDaySeparators: x = !0,
17
+ showAvatars: W = !0,
18
+ showTimestamps: G = !0,
19
+ autoScroll: M = !0,
20
+ virtualized: Y,
21
+ height: _ = y,
22
+ renderMessage: A,
23
+ emptyState: F,
24
+ formatDayLabel: d,
25
+ formatTimestamp: L,
26
+ translations: g,
27
+ onNewMessagesClick: m,
28
+ className: V
28
29
  }) => {
29
- const P = LS("MessageList"), w = AS(B, P), L = I(null), G = I(!0), d = I(null), [D, m] = j(!1), T = { ...q, ...U }, p = oS(a, v, C, $), W = (S) => (E == null ? void 0 : E(S)) ?? ES(S, T), M = (S) => (i == null ? void 0 : i(S)) ?? iS(S), O = (S) => {
30
- const s = L.current;
31
- s && s.scrollTo({ top: s.scrollHeight, behavior: S ? "smooth" : "auto" });
32
- }, Y = () => {
33
- const S = L.current;
34
- if (!S) return;
35
- const l = S.scrollHeight - S.scrollTop - S.clientHeight <= cS;
36
- G.current = l, l && m(!1);
30
+ const j = Nt("MessageList"), k = ft(w, j), a = u(null), O = u(!0), T = u(null), [z, I] = h(!1), [X, Z] = h(0), [q, f] = h(
31
+ typeof _ == "number" ? _ : y
32
+ ), p = { ...St, ...g }, c = ht(l, D, P, x), J = (t) => (d == null ? void 0 : d(t)) ?? Mt(t, p), N = (t) => (L == null ? void 0 : L(t)) ?? Ot(t), v = Y ?? l.length >= st, R = (t) => {
33
+ const n = a.current;
34
+ n && n.scrollTo({ top: n.scrollHeight, behavior: t ? "smooth" : "auto" });
35
+ }, K = () => {
36
+ const t = a.current;
37
+ if (!t) return;
38
+ Z(t.scrollTop), f(t.clientHeight);
39
+ const i = t.scrollHeight - t.scrollTop - t.clientHeight <= Et;
40
+ O.current = i, i && I(!1);
37
41
  };
38
- k(() => {
39
- const S = a.length > 0 ? a[a.length - 1].id : null, s = d.current === null, l = S !== null && S !== d.current;
40
- if (d.current = S, !!l) {
41
- if (s || u && G.current) {
42
- O(!s);
42
+ b(() => {
43
+ const t = a.current;
44
+ t && f(t.clientHeight);
45
+ }, [_]), b(() => {
46
+ const t = l.length > 0 ? l[l.length - 1].id : null, n = T.current === null, i = t !== null && t !== T.current;
47
+ if (T.current = t, !!i) {
48
+ if (n || M && O.current) {
49
+ R(!n);
43
50
  return;
44
51
  }
45
- m(!0);
52
+ I(!0);
46
53
  }
47
- }, [a, u]);
48
- const x = () => {
49
- O(!0), m(!1), A == null || A();
50
- }, F = (S) => /* @__PURE__ */ _(
54
+ }, [l, M]);
55
+ const Q = () => {
56
+ R(!0), I(!1), m == null || m();
57
+ }, tt = (t) => /* @__PURE__ */ o(
51
58
  "div",
52
59
  {
53
- className: e(
54
- `${t}__group`,
55
- rS,
56
- S.isOwn && lS
60
+ className: s(
61
+ `${e}__group`,
62
+ ut,
63
+ t.isOwn && pt
57
64
  ),
58
65
  children: [
59
- b && !S.isOwn && /* @__PURE__ */ n(
60
- z,
66
+ W && !t.isOwn && /* @__PURE__ */ S(
67
+ et,
61
68
  {
62
- src: S.author.avatar,
63
- initials: S.author.name[0],
69
+ src: t.author.avatar,
70
+ initials: t.author.name[0],
64
71
  size: "sm",
65
72
  className: "bear-flex-shrink-0"
66
73
  }
67
74
  ),
68
- /* @__PURE__ */ _(
75
+ /* @__PURE__ */ o(
69
76
  "div",
70
77
  {
71
- className: e(
72
- `${t}__group-body`,
73
- aS,
74
- S.isOwn && _S
78
+ className: s(
79
+ `${e}__group-body`,
80
+ It,
81
+ t.isOwn && Tt
75
82
  ),
76
83
  children: [
77
- !S.isOwn && /* @__PURE__ */ _("div", { className: e(`${t}__meta`, eS), children: [
78
- /* @__PURE__ */ n(
79
- r,
84
+ !t.isOwn && /* @__PURE__ */ o("div", { className: s(`${e}__meta`, dt), children: [
85
+ /* @__PURE__ */ S(
86
+ E,
80
87
  {
81
88
  variant: "caption",
82
89
  component: "span",
83
- className: e(`${t}__author`, tS),
84
- children: S.author.name
90
+ className: s(`${e}__author`, At),
91
+ children: t.author.name
85
92
  }
86
93
  ),
87
- h && /* @__PURE__ */ n(
88
- r,
94
+ G && /* @__PURE__ */ S(
95
+ E,
89
96
  {
90
97
  variant: "caption",
91
98
  component: "span",
92
- className: e(`${t}__timestamp`, f),
93
- children: M(S.messages[0].timestamp)
99
+ className: s(`${e}__timestamp`, H),
100
+ children: N(t.messages[0].timestamp)
94
101
  }
95
102
  )
96
103
  ] }),
97
- S.messages.map((s) => /* @__PURE__ */ n(
104
+ t.messages.map((n) => /* @__PURE__ */ S(
98
105
  "div",
99
106
  {
100
- className: e(
101
- `${t}__bubble`,
102
- nS,
103
- S.isOwn && `${t}__bubble--own`,
104
- S.isOwn && sS
107
+ className: s(
108
+ `${e}__bubble`,
109
+ mt,
110
+ t.isOwn && `${e}__bubble--own`,
111
+ t.isOwn && Lt
105
112
  ),
106
- children: (o == null ? void 0 : o(s)) ?? s.content
113
+ children: (A == null ? void 0 : A(n)) ?? n.content
107
114
  },
108
- s.id
115
+ n.id
109
116
  )),
110
- S.isOwn && h && /* @__PURE__ */ n(
111
- r,
117
+ t.isOwn && G && /* @__PURE__ */ S(
118
+ E,
112
119
  {
113
120
  variant: "caption",
114
121
  component: "span",
115
- className: e(`${t}__timestamp`, f),
116
- children: M(S.messages[S.messages.length - 1].timestamp)
122
+ className: s(`${e}__timestamp`, H),
123
+ children: N(t.messages[t.messages.length - 1].timestamp)
117
124
  }
118
125
  )
119
126
  ]
@@ -121,56 +128,61 @@ const OS = ({
121
128
  )
122
129
  ]
123
130
  },
124
- S.key
125
- );
126
- return /* @__PURE__ */ _(
131
+ t.key
132
+ ), B = (t) => t.kind === "day" ? /* @__PURE__ */ o(
133
+ "div",
134
+ {
135
+ className: s(
136
+ `${e}__day-separator`,
137
+ it
138
+ ),
139
+ children: [
140
+ /* @__PURE__ */ S("span", { className: s(`${e}__day-line`, C) }),
141
+ /* @__PURE__ */ S("span", { className: s(`${e}__day-label`, ct), children: J(t.date) }),
142
+ /* @__PURE__ */ S("span", { className: s(`${e}__day-line`, C) })
143
+ ]
144
+ },
145
+ t.key
146
+ ) : tt(t), r = v ? Gt(c, X, q, at) : null, $ = r === null ? c : c.slice(r.startIndex, r.endIndex + 1);
147
+ return /* @__PURE__ */ o(
127
148
  "div",
128
149
  {
129
- id: w,
130
- "data-testid": R,
131
- className: e(t, g, H),
132
- style: { height: typeof c == "number" ? `${c}px` : c },
150
+ id: k,
151
+ "data-testid": U,
152
+ className: s(e, rt, V),
153
+ style: { height: typeof _ == "number" ? `${_}px` : _ },
133
154
  children: [
134
- /* @__PURE__ */ _(
155
+ /* @__PURE__ */ o(
135
156
  "div",
136
157
  {
137
- ref: L,
138
- onScroll: Y,
139
- className: e(`${t}__scroller`, V),
158
+ ref: a,
159
+ onScroll: K,
160
+ className: s(`${e}__scroller`, lt),
140
161
  role: "log",
141
162
  "aria-live": "polite",
142
163
  children: [
143
- p.length === 0 && /* @__PURE__ */ n("div", { className: e(`${t}__empty`, J), children: y ?? /* @__PURE__ */ n(r, { variant: "body2", component: "span", children: T.emptyLabel }) }),
144
- p.map(
145
- (S) => S.kind === "day" ? /* @__PURE__ */ _(
146
- "div",
147
- {
148
- className: e(
149
- `${t}__day-separator`,
150
- Q
151
- ),
152
- children: [
153
- /* @__PURE__ */ n("span", { className: e(`${t}__day-line`, N) }),
154
- /* @__PURE__ */ n("span", { className: e(`${t}__day-label`, K), children: W(S.date) }),
155
- /* @__PURE__ */ n("span", { className: e(`${t}__day-line`, N) })
156
- ]
157
- },
158
- S.key
159
- ) : F(S)
160
- )
164
+ c.length === 0 && /* @__PURE__ */ S("div", { className: s(`${e}__empty`, nt), children: F ?? /* @__PURE__ */ S(E, { variant: "body2", component: "span", children: p.emptyLabel }) }),
165
+ v && r ? /* @__PURE__ */ S(
166
+ "div",
167
+ {
168
+ className: `${e}__virtual`,
169
+ style: { height: r.totalHeight, position: "relative" },
170
+ children: /* @__PURE__ */ S("div", { style: { transform: `translateY(${r.offsetTop}px)` }, children: $.map((t) => B(t)) })
171
+ }
172
+ ) : $.map((t) => B(t))
161
173
  ]
162
174
  }
163
175
  ),
164
- D && /* @__PURE__ */ n(
176
+ z && /* @__PURE__ */ S(
165
177
  "button",
166
178
  {
167
179
  type: "button",
168
- onClick: x,
169
- className: e(
170
- `${t}__new-messages`,
171
- Z
180
+ onClick: Q,
181
+ className: s(
182
+ `${e}__new-messages`,
183
+ _t
172
184
  ),
173
- children: T.newMessages
185
+ children: p.newMessages
174
186
  }
175
187
  )
176
188
  ]
@@ -178,5 +190,5 @@ const OS = ({
178
190
  );
179
191
  };
180
192
  export {
181
- OS as MessageList
193
+ Ut as MessageList
182
194
  };
@@ -53,6 +53,8 @@ export interface MessageListProps {
53
53
  showTimestamps?: boolean;
54
54
  /** Auto-scroll to bottom on new messages when already at the bottom */
55
55
  autoScroll?: boolean;
56
+ /** Enable windowed rendering for long conversations (auto when message count exceeds threshold) */
57
+ virtualized?: boolean;
56
58
  /** Height of the scrollable area */
57
59
  height?: number | string;
58
60
  /** Custom message content renderer */
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("./MessageList.const.cjs"),n=(e,s)=>e.getFullYear()===s.getFullYear()&&e.getMonth()===s.getMonth()&&e.getDate()===s.getDate(),u=e=>`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`,c=(e,s)=>{const o=new Date;if(n(e,o))return s.today;const g=new Date(o.getTime()-y.MESSAGE_LIST_MS_PER_DAY);return n(e,g)?s.yesterday:e.toLocaleDateString([],{year:"numeric",month:"long",day:"numeric"})},d=e=>e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),D=(e,s,o,g)=>{const i=[];let r=null;for(const t of e){const m=r===null||!n(r,t.timestamp);g&&m&&i.push({kind:"day",key:`day-${u(t.timestamp)}`,date:t.timestamp});const a=i[i.length-1],l=a!==void 0&&a.kind==="group"&&a.author.id===t.author.id&&t.timestamp.getTime()-a.messages[a.messages.length-1].timestamp.getTime()<=o;a!==void 0&&a.kind==="group"&&l?a.messages.push(t):i.push({kind:"group",key:`group-${t.id}`,author:t.author,isOwn:t.author.id===s,messages:[t]}),r=t.timestamp}return i};exports.buildMessageListItems=D;exports.getDayKey=u;exports.getDefaultDayLabel=c;exports.getDefaultTimestamp=d;exports.isSameDay=n;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./MessageList.const.cjs"),S=(e,i)=>e.getFullYear()===i.getFullYear()&&e.getMonth()===i.getMonth()&&e.getDate()===i.getDate(),h=e=>`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`,M=(e,i)=>{const o=new Date;if(S(e,o))return i.today;const r=new Date(o.getTime()-l.MESSAGE_LIST_MS_PER_DAY);return S(e,r)?i.yesterday:e.toLocaleDateString([],{year:"numeric",month:"long",day:"numeric"})},y=e=>e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),E=(e,i,o,r)=>{const t=[];let u=null;for(const s of e){const m=u===null||!S(u,s.timestamp);r&&m&&t.push({kind:"day",key:`day-${h(s.timestamp)}`,date:s.timestamp});const a=t[t.length-1],g=a!==void 0&&a.kind==="group"&&a.author.id===s.author.id&&s.timestamp.getTime()-a.messages[a.messages.length-1].timestamp.getTime()<=o;a!==void 0&&a.kind==="group"&&g?a.messages.push(s):t.push({kind:"group",key:`group-${s.id}`,author:s.author,isOwn:s.author.id===i,messages:[s]}),u=s.timestamp}return t},_=e=>e.kind==="day"?l.MESSAGE_LIST_DAY_ESTIMATE_PX+l.MESSAGE_LIST_ITEM_GAP_PX:l.MESSAGE_LIST_GROUP_BASE_ESTIMATE_PX+e.messages.length*l.MESSAGE_LIST_BUBBLE_ESTIMATE_PX+l.MESSAGE_LIST_ITEM_GAP_PX,T=(e,i,o,r)=>{const t=e.map(_),u=t.reduce((n,c)=>n+c,0);let s=0,m=0;for(let n=0;n<t.length;n+=1){if(s+t[n]>i){m=Math.max(0,n-r);break}s+=t[n]}let a=0;for(let n=0;n<m;n+=1)a+=t[n];let g=m,d=a;for(;g<t.length&&d<i+o;)d+=t[g],g+=1;return g=Math.min(t.length-1,g+r),{startIndex:m,endIndex:g,offsetTop:a,totalHeight:u}};exports.buildMessageListItems=E;exports.estimateMessageListItemHeight=_;exports.getDayKey=h;exports.getDefaultDayLabel=M;exports.getDefaultTimestamp=y;exports.getMessageListWindow=T;exports.isSameDay=S;
@@ -4,3 +4,10 @@ export declare const getDayKey: (date: Date) => string;
4
4
  export declare const getDefaultDayLabel: (date: Date, translations: MessageListTranslations) => string;
5
5
  export declare const getDefaultTimestamp: (date: Date) => string;
6
6
  export declare const buildMessageListItems: (messages: MessageListMessage[], currentUserId: string | undefined, groupWindowMs: number, showDaySeparators: boolean) => MessageListItem[];
7
+ export declare const estimateMessageListItemHeight: (item: MessageListItem) => number;
8
+ export declare const getMessageListWindow: (items: MessageListItem[], scrollTop: number, viewportHeight: number, overscan: number) => {
9
+ startIndex: number;
10
+ endIndex: number;
11
+ offsetTop: number;
12
+ totalHeight: number;
13
+ };
@@ -1,35 +1,54 @@
1
- import { MESSAGE_LIST_MS_PER_DAY as l } from "./MessageList.const.js";
2
- const g = (t, s) => t.getFullYear() === s.getFullYear() && t.getMonth() === s.getMonth() && t.getDate() === s.getDate(), c = (t) => `${t.getFullYear()}-${t.getMonth()}-${t.getDate()}`, d = (t, s) => {
3
- const i = /* @__PURE__ */ new Date();
4
- if (g(t, i))
5
- return s.today;
6
- const n = new Date(i.getTime() - l);
7
- return g(t, n) ? s.yesterday : t.toLocaleDateString([], { year: "numeric", month: "long", day: "numeric" });
8
- }, y = (t) => t.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }), h = (t, s, i, n) => {
9
- const o = [];
10
- let r = null;
11
- for (const e of t) {
12
- const m = r === null || !g(r, e.timestamp);
13
- n && m && o.push({
1
+ import { MESSAGE_LIST_DAY_ESTIMATE_PX as c, MESSAGE_LIST_ITEM_GAP_PX as d, MESSAGE_LIST_GROUP_BASE_ESTIMATE_PX as _, MESSAGE_LIST_BUBBLE_ESTIMATE_PX as E, MESSAGE_LIST_MS_PER_DAY as p } from "./MessageList.const.js";
2
+ const u = (e, a) => e.getFullYear() === a.getFullYear() && e.getMonth() === a.getMonth() && e.getDate() === a.getDate(), M = (e) => `${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`, T = (e, a) => {
3
+ const g = /* @__PURE__ */ new Date();
4
+ if (u(e, g))
5
+ return a.today;
6
+ const r = new Date(g.getTime() - p);
7
+ return u(e, r) ? a.yesterday : e.toLocaleDateString([], { year: "numeric", month: "long", day: "numeric" });
8
+ }, D = (e) => e.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }), I = (e, a, g, r) => {
9
+ const t = [];
10
+ let l = null;
11
+ for (const s of e) {
12
+ const m = l === null || !u(l, s.timestamp);
13
+ r && m && t.push({
14
14
  kind: "day",
15
- key: `day-${c(e.timestamp)}`,
16
- date: e.timestamp
15
+ key: `day-${M(s.timestamp)}`,
16
+ date: s.timestamp
17
17
  });
18
- const a = o[o.length - 1], u = a !== void 0 && a.kind === "group" && a.author.id === e.author.id && e.timestamp.getTime() - a.messages[a.messages.length - 1].timestamp.getTime() <= i;
19
- a !== void 0 && a.kind === "group" && u ? a.messages.push(e) : o.push({
18
+ const n = t[t.length - 1], o = n !== void 0 && n.kind === "group" && n.author.id === s.author.id && s.timestamp.getTime() - n.messages[n.messages.length - 1].timestamp.getTime() <= g;
19
+ n !== void 0 && n.kind === "group" && o ? n.messages.push(s) : t.push({
20
20
  kind: "group",
21
- key: `group-${e.id}`,
22
- author: e.author,
23
- isOwn: e.author.id === s,
24
- messages: [e]
25
- }), r = e.timestamp;
21
+ key: `group-${s.id}`,
22
+ author: s.author,
23
+ isOwn: s.author.id === a,
24
+ messages: [s]
25
+ }), l = s.timestamp;
26
26
  }
27
- return o;
27
+ return t;
28
+ }, f = (e) => e.kind === "day" ? c + d : _ + e.messages.length * E + d, A = (e, a, g, r) => {
29
+ const t = e.map(f), l = t.reduce((i, S) => i + S, 0);
30
+ let s = 0, m = 0;
31
+ for (let i = 0; i < t.length; i += 1) {
32
+ if (s + t[i] > a) {
33
+ m = Math.max(0, i - r);
34
+ break;
35
+ }
36
+ s += t[i];
37
+ }
38
+ let n = 0;
39
+ for (let i = 0; i < m; i += 1)
40
+ n += t[i];
41
+ let o = m, h = n;
42
+ for (; o < t.length && h < a + g; )
43
+ h += t[o], o += 1;
44
+ return o = Math.min(t.length - 1, o + r), { startIndex: m, endIndex: o, offsetTop: n, totalHeight: l };
28
45
  };
29
46
  export {
30
- h as buildMessageListItems,
31
- c as getDayKey,
32
- d as getDefaultDayLabel,
33
- y as getDefaultTimestamp,
34
- g as isSameDay
47
+ I as buildMessageListItems,
48
+ f as estimateMessageListItemHeight,
49
+ M as getDayKey,
50
+ T as getDefaultDayLabel,
51
+ D as getDefaultTimestamp,
52
+ A as getMessageListWindow,
53
+ u as isSameDay
35
54
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("../../utils/cn.cjs");require("react");const m={sm:"bear-h-1.5",md:"bear-h-2.5",lg:"bear-h-4"},f={default:"bear-bg-bear-500",success:"bear-bg-green-500",warning:"bear-bg-amber-500",danger:"bear-bg-red-500",info:"bear-bg-blue-500"},x=({value:b,max:n=100,size:l="md",color:o="default",showLabel:i=!1,labelPosition:d="outside",striped:r=!1,animated:c=!1,indeterminate:a=!1,className:g,testId:u})=>{const s=Math.min(100,Math.max(0,b/n*100));return e.jsxs("div",{className:t.cn("bear-w-full",g),"data-testid":u,children:[i&&d==="outside"&&e.jsxs("div",{className:"bear-flex bear-justify-between bear-mb-1",children:[e.jsx("span",{className:"bear-text-sm bear-font-medium bear-text-gray-700 dark:bear-text-gray-200",children:"Progress"}),e.jsxs("span",{className:"bear-text-sm bear-font-medium bear-text-gray-700 dark:bear-text-gray-200",children:[Math.round(s),"%"]})]}),e.jsx("div",{className:t.cn("bear-w-full bear-bg-gray-200 dark:bear-bg-gray-700 bear-rounded-full bear-overflow-hidden",m[l]),children:e.jsx("div",{className:t.cn("bear-h-full bear-rounded-full bear-transition-all bear-duration-300 bear-ease-out","bear-flex bear-items-center bear-justify-center",f[o],r&&"bear-bg-stripes",c&&"bear-animate-stripes",a&&"bear-animate-indeterminate"),style:{width:a?"50%":`${s}%`,backgroundSize:r?"1rem 1rem":void 0,backgroundImage:r?"linear-gradient(45deg, rgba(255,255,255,.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.15) 50%, rgba(255,255,255,.15) 75%, transparent 75%, transparent)":void 0},role:"progressbar","aria-valuenow":a?void 0:b,"aria-valuemin":0,"aria-valuemax":n,children:i&&d==="inside"&&l==="lg"&&!a&&e.jsxs("span",{className:"bear-text-xs bear-font-medium bear-text-white",children:[Math.round(s),"%"]})})})]})};exports.Progress=x;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),e=require("./Progress.const.cjs"),s=require("../../utils/cn.cjs");require("react");const E=require("../../utils/generateBearId.utils.cjs"),P=require("../../utils/useBearId.cjs"),v=m=>{const{id:_,value:l,max:n=100,bufferValue:d,size:b="md",color:R="default",showLabel:o=!1,label:u=e.PROGRESS_DEFAULT_LABEL,labelPosition:S="outside",striped:i=!1,animated:g=!1,indeterminate:r=!1,className:x,testId:f}=m,O=P.useBearId("Progress"),h=E.resolveBearId(_,O),t=Math.min(100,Math.max(0,l/n*100)),c=d==null?null:Math.min(100,Math.max(t,Math.max(0,d/n*100)));return a.jsxs("div",{id:h,className:s.cn(e.PROGRESS_ROOT_CLASS,"bear-w-full",x),"data-testid":f,children:[o&&S==="outside"&&a.jsxs("div",{className:`${e.PROGRESS_ROOT_CLASS}__label-row bear-flex bear-justify-between bear-mb-1`,children:[a.jsx("span",{className:"bear-text-sm bear-font-medium bear-text-gray-700 dark:bear-text-gray-200",children:u}),a.jsxs("span",{className:"bear-text-sm bear-font-medium bear-text-gray-700 dark:bear-text-gray-200",children:[Math.round(t),"%"]})]}),a.jsxs("div",{className:s.cn(`${e.PROGRESS_ROOT_CLASS}__track`,e.PROGRESS_TRACK_CLASSES,e.PROGRESS_SIZE_CLASSES[b]),children:[c!=null&&!r&&a.jsx("div",{className:s.cn(`${e.PROGRESS_ROOT_CLASS}__buffer`,"bear-absolute bear-inset-y-0 bear-left-0 bear-rounded-full",e.PROGRESS_BUFFER_CLASSES),style:{width:`${c}%`}}),a.jsx("div",{className:s.cn(`${e.PROGRESS_ROOT_CLASS}__bar`,"bear-relative bear-h-full bear-rounded-full bear-transition-all bear-duration-300 bear-ease-out","bear-flex bear-items-center bear-justify-center",e.PROGRESS_COLOR_CLASSES[R],i&&"bear-bg-stripes",g&&"bear-animate-stripes",r&&"bear-animate-indeterminate"),style:{width:r?"50%":`${t}%`,backgroundSize:i?"1rem 1rem":void 0,backgroundImage:i?"linear-gradient(45deg, rgba(255,255,255,.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.15) 50%, rgba(255,255,255,.15) 75%, transparent 75%, transparent)":void 0},role:"progressbar","aria-valuenow":r?void 0:l,"aria-valuemin":0,"aria-valuemax":n,"aria-label":u,children:o&&S==="inside"&&b==="lg"&&!r&&a.jsxs("span",{className:"bear-text-xs bear-font-medium bear-text-white",children:[Math.round(t),"%"]})})]})]})};exports.Progress=v;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S="Bear-Progress",e={sm:"bear-h-1.5",md:"bear-h-2.5",lg:"bear-h-4"},r={default:"bear-bg-bear-500",success:"bear-bg-green-500",warning:"bear-bg-amber-500",danger:"bear-bg-red-500",info:"bear-bg-blue-500"},b="bear-bg-bear-500/30 dark:bear-bg-bear-400/25",R="bear-w-full bear-bg-gray-200 dark:bear-bg-gray-700 bear-rounded-full bear-overflow-hidden bear-relative",a="Progress";exports.PROGRESS_BUFFER_CLASSES=b;exports.PROGRESS_COLOR_CLASSES=r;exports.PROGRESS_DEFAULT_LABEL=a;exports.PROGRESS_ROOT_CLASS=S;exports.PROGRESS_SIZE_CLASSES=e;exports.PROGRESS_TRACK_CLASSES=R;
@@ -1 +1,16 @@
1
- export declare const P_R_O_G_R_E_S_S_ROOT_CLASS = "Bear-Progress";
1
+ export declare const PROGRESS_ROOT_CLASS = "Bear-Progress";
2
+ export declare const PROGRESS_SIZE_CLASSES: {
3
+ readonly sm: "bear-h-1.5";
4
+ readonly md: "bear-h-2.5";
5
+ readonly lg: "bear-h-4";
6
+ };
7
+ export declare const PROGRESS_COLOR_CLASSES: {
8
+ readonly default: "bear-bg-bear-500";
9
+ readonly success: "bear-bg-green-500";
10
+ readonly warning: "bear-bg-amber-500";
11
+ readonly danger: "bear-bg-red-500";
12
+ readonly info: "bear-bg-blue-500";
13
+ };
14
+ export declare const PROGRESS_BUFFER_CLASSES = "bear-bg-bear-500/30 dark:bear-bg-bear-400/25";
15
+ export declare const PROGRESS_TRACK_CLASSES = "bear-w-full bear-bg-gray-200 dark:bear-bg-gray-700 bear-rounded-full bear-overflow-hidden bear-relative";
16
+ export declare const PROGRESS_DEFAULT_LABEL = "Progress";
@@ -0,0 +1,19 @@
1
+ const r = "Bear-Progress", e = {
2
+ sm: "bear-h-1.5",
3
+ md: "bear-h-2.5",
4
+ lg: "bear-h-4"
5
+ }, b = {
6
+ default: "bear-bg-bear-500",
7
+ success: "bear-bg-green-500",
8
+ warning: "bear-bg-amber-500",
9
+ danger: "bear-bg-red-500",
10
+ info: "bear-bg-blue-500"
11
+ }, a = "bear-bg-bear-500/30 dark:bear-bg-bear-400/25", S = "bear-w-full bear-bg-gray-200 dark:bear-bg-gray-700 bear-rounded-full bear-overflow-hidden bear-relative", g = "Progress";
12
+ export {
13
+ a as PROGRESS_BUFFER_CLASSES,
14
+ b as PROGRESS_COLOR_CLASSES,
15
+ g as PROGRESS_DEFAULT_LABEL,
16
+ r as PROGRESS_ROOT_CLASS,
17
+ e as PROGRESS_SIZE_CLASSES,
18
+ S as PROGRESS_TRACK_CLASSES
19
+ };
@@ -1,13 +1,3 @@
1
1
  import { FC } from 'react';
2
2
  import { ProgressProps } from './Progress.types';
3
- /**
4
- * Progress - Progress bar with multiple variants
5
- *
6
- * @example
7
- * ```tsx
8
- * <Progress value={75} showLabel />
9
- * <Progress value={50} color="success" striped animated />
10
- * <Progress indeterminate />
11
- * ```
12
- */
13
3
  export declare const Progress: FC<ProgressProps>;