anentrypoint-design 0.0.162 → 0.0.164

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "anentrypoint-design",
3
- "version": "0.0.162",
3
+ "version": "0.0.164",
4
4
  "description": "247420 design system SDK — webjsx + modified ripple-ui, single-file ESM bundle for reproducible use of the AnEntrypoint design.",
5
5
  "type": "module",
6
6
  "main": "./dist/247420.js",
@@ -140,8 +140,13 @@ export function ChatMessage({ role, who = 'them', avatar, text, parts, time, typ
140
140
  }
141
141
 
142
142
  export function ChatComposer({ value, onInput, onSend, onAttach, onEmoji, onMenu, placeholder = 'message…', disabled }) {
143
+ // Keep a handle to the live textarea so send() reads the actual DOM value
144
+ // (not the possibly-lagging `value` prop) and so we can sync the DOM value
145
+ // only when it genuinely differs — re-applying `value` on every parent
146
+ // re-render otherwise resets the caret and drops fast keystrokes.
147
+ let taEl = null;
143
148
  const send = () => {
144
- const v = (value || '').trim();
149
+ const v = ((taEl && taEl.value) || value || '').trim();
145
150
  if (!v || disabled) return;
146
151
  if (onSend) onSend(v);
147
152
  };
@@ -161,11 +166,16 @@ export function ChatComposer({ value, onInput, onSend, onAttach, onEmoji, onMenu
161
166
  };
162
167
  const taRef = (el) => {
163
168
  if (!el) return;
169
+ taEl = el;
170
+ // Sync the controlled value into the DOM only when it actually differs,
171
+ // so a re-render mid-type does not clobber the caret or pending input.
172
+ const next = value || '';
173
+ if (el.value !== next) el.value = next;
164
174
  el.style.height = 'auto';
165
175
  el.style.height = Math.min(el.scrollHeight, 200) + 'px';
166
176
  };
167
177
  return h('div', { class: 'chat-composer' },
168
- h('textarea', { ref: taRef, value: value || '', placeholder, rows: 1, 'aria-label': 'message input',
178
+ h('textarea', { ref: taRef, placeholder, rows: 1, 'aria-label': 'message input',
169
179
  oninput: autoGrow,
170
180
  onkeydown: (e) => {
171
181
  if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); send(); }
@@ -215,13 +225,16 @@ export function Chat({ title = 'chat', sub, messages = [], composer, header } =
215
225
  el.dataset.msgCount = String(messages.length);
216
226
  return () => obs.disconnect();
217
227
  };
228
+ const msgCount = messages.length;
218
229
  return h('div', { class: 'chat' },
219
230
  header || h('div', { class: 'chat-head', role: 'banner' },
220
231
  h('span', { class: 'dot', 'aria-hidden': 'true' }),
221
232
  h('h2', { class: 'ds-chat-title' }, title),
222
233
  sub ? h('span', { class: 'sub', 'aria-label': `subtitle: ${sub}` }, ' · ' + sub) : null,
223
234
  h('span', { class: 'spread' }),
224
- h('span', { class: 'sub', 'aria-live': 'polite' }, String(messages.length).padStart(2, '0') + ' msgs')
235
+ msgCount > 0
236
+ ? h('span', { class: 'sub', 'aria-live': 'polite' }, msgCount + (msgCount === 1 ? ' message' : ' messages'))
237
+ : null
225
238
  ),
226
239
  h('div', { class: 'chat-thread', ref: threadRef, role: 'log', 'aria-label': 'chat messages' },
227
240
  messages.length === 0
@@ -289,7 +302,9 @@ export function AICat({ name = 'aicat', messages = [], thinking, composer, statu
289
302
  h('h2', { class: 'ds-chat-title' }, name),
290
303
  h('span', { class: 'sub', 'aria-label': `status: ${status}` }, ' · ' + status),
291
304
  h('span', { class: 'spread' }),
292
- h('span', { class: 'sub', 'aria-live': 'polite' }, String(messages.length).padStart(2, '0') + ' turns')
305
+ messages.length > 0
306
+ ? h('span', { class: 'sub', 'aria-live': 'polite' }, messages.length + (messages.length === 1 ? ' turn' : ' turns'))
307
+ : null
293
308
  ),
294
309
  h('div', { class: 'chat-thread', ref: threadRef, role: 'log', 'aria-label': 'conversation turns' },
295
310
  ...all.map((m, i) => ChatMessage({ ...m, key: m.key != null ? m.key : i }))