anentrypoint-design 0.0.25 → 0.0.26

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.25",
3
+ "version": "0.0.26",
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",
package/src/components.js CHANGED
@@ -276,6 +276,107 @@ export function HomeView({ state, onNav, onToggleWork, works, posts, manifesto,
276
276
  ];
277
277
  }
278
278
 
279
+ // ---------- chat ----------
280
+
281
+ export function ChatMessage({ who = 'them', avatar, text, time, typing, key, aicat }) {
282
+ const cls = 'chat-msg ' + who + (aicat && who === 'them' ? ' aicat' : '');
283
+ const av = h('span', { class: 'chat-avatar' }, avatar || (who === 'you' ? 'u' : '?'));
284
+ const body = typing
285
+ ? h('span', { class: 'chat-typing' }, h('span'), h('span'), h('span'))
286
+ : h('span', { class: 'chat-bubble' }, text);
287
+ const meta = time ? h('div', { class: 'chat-meta' }, time) : null;
288
+ const stack = h('div', {},
289
+ body,
290
+ meta
291
+ );
292
+ return h('div', { key, class: cls },
293
+ who === 'you' ? stack : av,
294
+ who === 'you' ? av : stack
295
+ );
296
+ }
297
+
298
+ export function ChatComposer({ value, onInput, onSend, placeholder = 'message…', disabled }) {
299
+ const send = () => {
300
+ const v = (value || '').trim();
301
+ if (!v || disabled) return;
302
+ if (onSend) onSend(v);
303
+ };
304
+ return h('div', { class: 'chat-composer' },
305
+ h('textarea', {
306
+ value: value || '',
307
+ placeholder,
308
+ rows: 1,
309
+ oninput: (e) => onInput && onInput(e.target.value),
310
+ onkeydown: (e) => {
311
+ if (e.key === 'Enter' && !e.shiftKey) {
312
+ e.preventDefault();
313
+ send();
314
+ }
315
+ }
316
+ }),
317
+ h('button', {
318
+ class: 'send',
319
+ disabled: disabled || !(value && value.trim()),
320
+ onclick: send
321
+ }, '↑')
322
+ );
323
+ }
324
+
325
+ export function Chat({ title = 'chat', sub, messages = [], composer, header } = {}) {
326
+ return h('div', { class: 'chat' },
327
+ header || h('div', { class: 'chat-head' },
328
+ h('span', { class: 'dot' }),
329
+ h('span', {}, title),
330
+ sub ? h('span', { class: 'sub' }, ' · ' + sub) : null,
331
+ h('span', { class: 'spread' }),
332
+ h('span', { class: 'sub' }, String(messages.length).padStart(2, '0') + ' msgs')
333
+ ),
334
+ h('div', { class: 'chat-thread' },
335
+ ...messages.map((m, i) => ChatMessage({ ...m, key: m.key != null ? m.key : i }))
336
+ ),
337
+ composer || null
338
+ );
339
+ }
340
+
341
+ const AICAT_FACE = ` /\\_/\\\n( o.o )\n > ^ <`;
342
+
343
+ export function AICatPortrait({ name = 'aicat', status = 'idle', face } = {}) {
344
+ return h('div', { class: 'aicat-portrait' },
345
+ h('pre', { class: 'aicat-face' }, face || AICAT_FACE),
346
+ h('div', { class: 'aicat-meta' },
347
+ h('span', { class: 'name' }, name),
348
+ h('span', { class: 'status' },
349
+ h('span', { class: 'dot' }, '● '),
350
+ status
351
+ )
352
+ )
353
+ );
354
+ }
355
+
356
+ export function AICat({ name = 'aicat', messages = [], thinking, composer, status = 'online · purring' } = {}) {
357
+ const annotated = messages.map((m) =>
358
+ m.who === 'them' ? { ...m, aicat: true, avatar: m.avatar || '=^.^=' } : m
359
+ );
360
+ const all = thinking
361
+ ? [...annotated, { who: 'them', aicat: true, avatar: '=^.^=', typing: true, key: '_thinking' }]
362
+ : annotated;
363
+ return h('div', { class: 'chat' },
364
+ h('div', { class: 'chat-head' },
365
+ h('span', { class: 'dot' }),
366
+ h('span', {}, name),
367
+ h('span', { class: 'sub' }, ' · ' + status),
368
+ h('span', { class: 'spread' }),
369
+ h('span', { class: 'sub' }, String(messages.length).padStart(2, '0') + ' turns')
370
+ ),
371
+ h('div', { class: 'chat-thread' },
372
+ ...all.map((m, i) => ChatMessage({ ...m, key: m.key != null ? m.key : i }))
373
+ ),
374
+ composer || null
375
+ );
376
+ }
377
+
378
+ export { AICAT_FACE };
379
+
279
380
  export function ProjectView({ project, copied, onCopy }) {
280
381
  return [
281
382
  Heading({ level: 1, children: project.name }),