@moldable-ai/ui 0.2.7 → 0.2.9

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 (44) hide show
  1. package/dist/components/app-error-boundary.d.ts +26 -0
  2. package/dist/components/app-error-boundary.d.ts.map +1 -0
  3. package/dist/components/app-error-boundary.js +87 -0
  4. package/dist/components/chat/chat-input.d.ts +9 -1
  5. package/dist/components/chat/chat-input.d.ts.map +1 -1
  6. package/dist/components/chat/chat-input.js +13 -4
  7. package/dist/components/chat/chat-message.d.ts +6 -0
  8. package/dist/components/chat/chat-message.d.ts.map +1 -1
  9. package/dist/components/chat/chat-message.js +576 -157
  10. package/dist/components/chat/chat-messages.d.ts +2 -1
  11. package/dist/components/chat/chat-messages.d.ts.map +1 -1
  12. package/dist/components/chat/chat-messages.js +3 -3
  13. package/dist/components/chat/chat-panel.d.ts +25 -3
  14. package/dist/components/chat/chat-panel.d.ts.map +1 -1
  15. package/dist/components/chat/chat-panel.js +173 -49
  16. package/dist/components/chat/index.d.ts +3 -3
  17. package/dist/components/chat/index.d.ts.map +1 -1
  18. package/dist/components/chat/index.js +1 -1
  19. package/dist/components/chat/model-selector.d.ts.map +1 -1
  20. package/dist/components/chat/model-selector.js +1 -1
  21. package/dist/components/chat/tool-handlers.d.ts.map +1 -1
  22. package/dist/components/chat/tool-handlers.js +89 -1
  23. package/dist/components/markdown.d.ts.map +1 -1
  24. package/dist/components/markdown.js +18 -4
  25. package/dist/components/rich-media-player.d.ts +8 -0
  26. package/dist/components/rich-media-player.d.ts.map +1 -0
  27. package/dist/components/rich-media-player.js +99 -0
  28. package/dist/components/ui/command.d.ts +2 -1
  29. package/dist/components/ui/command.d.ts.map +1 -1
  30. package/dist/components/ui/command.js +2 -2
  31. package/dist/components/ui/resizable.d.ts +4 -1
  32. package/dist/components/ui/resizable.d.ts.map +1 -1
  33. package/dist/components/ui/resizable.js +1 -1
  34. package/dist/index.d.ts +3 -1
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +4 -1
  37. package/dist/lib/commands.d.ts +8 -0
  38. package/dist/lib/commands.d.ts.map +1 -1
  39. package/dist/lib/commands.js +18 -0
  40. package/package.json +17 -14
  41. package/src/styles/index.css +25 -0
  42. package/dist/lib/commands.test.d.ts +0 -2
  43. package/dist/lib/commands.test.d.ts.map +0 -1
  44. package/dist/lib/commands.test.js +0 -111
@@ -1,111 +0,0 @@
1
- import { afterEach, describe, expect, it } from 'vitest';
2
- // Re-implement isInMoldable for testing (since it accesses window)
3
- function isInMoldable() {
4
- if (typeof window === 'undefined')
5
- return false;
6
- return window.parent !== window;
7
- }
8
- describe('commands utilities', () => {
9
- describe('isInMoldable', () => {
10
- const originalWindow = global.window;
11
- afterEach(() => {
12
- // Restore original window
13
- if (originalWindow) {
14
- global.window = originalWindow;
15
- }
16
- });
17
- it('returns false when window is undefined (SSR)', () => {
18
- // @ts-expect-error - intentionally setting to undefined
19
- global.window = undefined;
20
- // Re-evaluate with undefined window
21
- const result = typeof window === 'undefined' ? false : window.parent !== window;
22
- expect(result).toBe(false);
23
- });
24
- it('returns false when parent equals window (not in iframe)', () => {
25
- // jsdom default: window.parent === window
26
- expect(isInMoldable()).toBe(false);
27
- });
28
- it('returns true when parent differs from window (in iframe)', () => {
29
- // Mock the iframe scenario
30
- const mockParent = {};
31
- const originalParent = window.parent;
32
- Object.defineProperty(window, 'parent', {
33
- value: mockParent,
34
- writable: true,
35
- configurable: true,
36
- });
37
- expect(isInMoldable()).toBe(true);
38
- // Restore
39
- Object.defineProperty(window, 'parent', {
40
- value: originalParent,
41
- writable: true,
42
- configurable: true,
43
- });
44
- });
45
- });
46
- describe('CommandAction types', () => {
47
- it('navigate action has path', () => {
48
- const action = { type: 'navigate', path: '/settings' };
49
- expect(action.type).toBe('navigate');
50
- expect(action.path).toBe('/settings');
51
- });
52
- it('message action has payload', () => {
53
- const action = { type: 'message', payload: { foo: 'bar' } };
54
- expect(action.type).toBe('message');
55
- expect(action.payload).toEqual({ foo: 'bar' });
56
- });
57
- it('focus action has target', () => {
58
- const action = { type: 'focus', target: 'input-field' };
59
- expect(action.type).toBe('focus');
60
- expect(action.target).toBe('input-field');
61
- });
62
- });
63
- describe('AppCommand structure', () => {
64
- it('accepts valid command definition', () => {
65
- const command = {
66
- id: 'add-todo',
67
- label: 'Add Todo',
68
- shortcut: 'a',
69
- icon: '➕',
70
- group: 'Tasks',
71
- action: { type: 'message', payload: {} },
72
- };
73
- expect(command.id).toBe('add-todo');
74
- expect(command.label).toBe('Add Todo');
75
- expect(command.shortcut).toBe('a');
76
- expect(command.icon).toBe('➕');
77
- expect(command.group).toBe('Tasks');
78
- });
79
- it('works with minimal required fields', () => {
80
- const command = {
81
- id: 'test',
82
- label: 'Test Command',
83
- action: { type: 'navigate', path: '/' },
84
- };
85
- expect(command.id).toBeDefined();
86
- expect(command.label).toBeDefined();
87
- expect(command.action).toBeDefined();
88
- });
89
- });
90
- describe('CommandMessage structure', () => {
91
- it('has correct type marker', () => {
92
- const message = {
93
- type: 'moldable:command',
94
- command: 'add-todo',
95
- payload: { text: 'Buy milk' },
96
- };
97
- expect(message.type).toBe('moldable:command');
98
- expect(message.command).toBe('add-todo');
99
- expect(message.payload).toEqual({ text: 'Buy milk' });
100
- });
101
- it('works without payload', () => {
102
- const message = {
103
- type: 'moldable:command',
104
- command: 'refresh',
105
- };
106
- expect(message.type).toBe('moldable:command');
107
- expect(message.command).toBe('refresh');
108
- expect(message.payload).toBeUndefined();
109
- });
110
- });
111
- });