@object-ui/plugin-detail 3.1.5 → 3.3.1

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 (209) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +21 -1
  3. package/dist/AddressField-LgHnO2Lk.js +98 -0
  4. package/dist/AutoNumberField-xZCrU0eW.js +14 -0
  5. package/dist/{AvatarField-YGj51ozd.js → AvatarField-Dy2XGlPz.js} +16 -15
  6. package/dist/{BooleanField-CaA898Tk.js → BooleanField-C0Clfka5.js} +11 -10
  7. package/dist/CodeField-CHUa07B6.js +23 -0
  8. package/dist/ColorField-vxHqEhcS.js +38 -0
  9. package/dist/CurrencyField-DiWjYWDo.js +49 -0
  10. package/dist/DateField-DGaRPM4P.js +22 -0
  11. package/dist/DateTimeField-8QnpsI_h.js +30 -0
  12. package/dist/EmailField-CkVgMbpI.js +26 -0
  13. package/dist/FileField-5UPV7uek.js +149 -0
  14. package/dist/FormulaField-BUgt6-Pi.js +17 -0
  15. package/dist/GeolocationField-D9T_jgG6.js +118 -0
  16. package/dist/GridField-DE_HwiIN.js +49 -0
  17. package/dist/ImageField-Dswnqtzf.js +73 -0
  18. package/dist/LocationField-gjqbE6na.js +36 -0
  19. package/dist/LookupField-BcS3LRKc.js +901 -0
  20. package/dist/{MasterDetailField-I1A9oEGC.js → MasterDetailField-BF6_-X3A.js} +20 -19
  21. package/dist/NumberField-Dj2rYmrS.js +27 -0
  22. package/dist/ObjectField-BymIojwd.js +50 -0
  23. package/dist/{PasswordField-DBtluGJ1.js → PasswordField-ED_Xgqz-.js} +8 -7
  24. package/dist/PercentField-D-JKOxKC.js +61 -0
  25. package/dist/PhoneField-DSCaGYq7.js +26 -0
  26. package/dist/QRCodeField-CtcOUapi.js +73 -0
  27. package/dist/{RatingField-B_Mnr63i.js → RatingField-BDnyQFWy.js} +10 -9
  28. package/dist/RichTextField-CH6LVZQA.js +33 -0
  29. package/dist/SelectField-DE4dpkMV.js +36 -0
  30. package/dist/{SignatureField-CddhEK9u.js → SignatureField-B1wh3f5A.js} +18 -17
  31. package/dist/{SliderField-Df5hMzNc.js → SliderField-zoTCKh9n.js} +2 -1
  32. package/dist/SummaryField-BeBVT6VN.js +22 -0
  33. package/dist/TextAreaField-rfUGrRxh.js +37 -0
  34. package/dist/TextField-C_yM7ATQ.js +30 -0
  35. package/dist/TimeField-BcQmBZi9.js +22 -0
  36. package/dist/UrlField-BakaF6NI.js +31 -0
  37. package/dist/UserField-zS7y3eKb.js +76 -0
  38. package/dist/VectorField-CTZ4myDM.js +34 -0
  39. package/dist/index.d.ts +1 -1
  40. package/dist/index.js +1741 -1504
  41. package/dist/index.umd.cjs +43 -51
  42. package/dist/packages/plugin-detail/src/ActivityTimeline.d.ts.map +1 -0
  43. package/dist/packages/plugin-detail/src/CommentAttachment.d.ts.map +1 -0
  44. package/dist/packages/plugin-detail/src/CommentInput.d.ts.map +1 -0
  45. package/dist/packages/plugin-detail/src/DetailSection.d.ts.map +1 -0
  46. package/dist/packages/plugin-detail/src/DetailTabs.d.ts.map +1 -0
  47. package/dist/packages/plugin-detail/src/DetailView.d.ts +47 -0
  48. package/dist/packages/plugin-detail/src/DetailView.d.ts.map +1 -0
  49. package/dist/packages/plugin-detail/src/DetailView.stories.d.ts.map +1 -0
  50. package/dist/packages/plugin-detail/src/DiffView.d.ts.map +1 -0
  51. package/dist/packages/plugin-detail/src/FieldChangeItem.d.ts.map +1 -0
  52. package/dist/packages/plugin-detail/src/HeaderHighlight.d.ts.map +1 -0
  53. package/dist/packages/plugin-detail/src/InlineCreateRelated.d.ts.map +1 -0
  54. package/dist/packages/plugin-detail/src/MentionAutocomplete.d.ts.map +1 -0
  55. package/dist/packages/plugin-detail/src/PointInTimeRestore.d.ts.map +1 -0
  56. package/dist/packages/plugin-detail/src/ReactionPicker.d.ts.map +1 -0
  57. package/dist/packages/plugin-detail/src/RecordActivityTimeline.d.ts.map +1 -0
  58. package/dist/packages/plugin-detail/src/RecordChatterPanel.d.ts.map +1 -0
  59. package/dist/packages/plugin-detail/src/RecordComments.d.ts.map +1 -0
  60. package/dist/packages/plugin-detail/src/RecordNavigationEnhanced.d.ts.map +1 -0
  61. package/dist/{src → packages/plugin-detail/src}/RelatedList.d.ts +8 -0
  62. package/dist/packages/plugin-detail/src/RelatedList.d.ts.map +1 -0
  63. package/dist/packages/plugin-detail/src/RelationshipGraph.d.ts.map +1 -0
  64. package/dist/packages/plugin-detail/src/RichTextCommentInput.d.ts.map +1 -0
  65. package/dist/packages/plugin-detail/src/SectionGroup.d.ts.map +1 -0
  66. package/dist/packages/plugin-detail/src/SubscriptionToggle.d.ts.map +1 -0
  67. package/dist/packages/plugin-detail/src/ThreadedReplies.d.ts.map +1 -0
  68. package/dist/packages/plugin-detail/src/autoLayout.d.ts.map +1 -0
  69. package/dist/packages/plugin-detail/src/index.d.ts.map +1 -0
  70. package/dist/packages/plugin-detail/src/useDetailTranslation.d.ts.map +1 -0
  71. package/dist/plugin-detail.css +1 -2
  72. package/dist/rolldown-runtime-DnwLefa7.js +23 -0
  73. package/dist/{src-CXr1-vVl.js → src-DyUKLvMN.js} +29788 -37711
  74. package/dist/useFieldTranslation-BRgjC1oq.js +9 -0
  75. package/package.json +34 -12
  76. package/.turbo/turbo-build.log +0 -61
  77. package/dist/AddressField-DBkEyMcG.js +0 -93
  78. package/dist/AutoNumberField-Baa191z-.js +0 -14
  79. package/dist/CodeField-BU51nl1L.js +0 -22
  80. package/dist/ColorField-Cnf6ZM7c.js +0 -37
  81. package/dist/CurrencyField-Wg-XOId2.js +0 -51
  82. package/dist/DateField-Cth1ky_m.js +0 -21
  83. package/dist/DateTimeField-B0m6FhHL.js +0 -32
  84. package/dist/EmailField-Do7qT_L_.js +0 -28
  85. package/dist/FileField-aRJAdbQb.js +0 -151
  86. package/dist/FormulaField-DTMkagFx.js +0 -14
  87. package/dist/GeolocationField-RqpHWTEv.js +0 -113
  88. package/dist/GridField-D4IH0cpo.js +0 -51
  89. package/dist/ImageField-BYCFajjr.js +0 -75
  90. package/dist/LocationField-Bi_ew9sd.js +0 -35
  91. package/dist/LookupField-BjwlDPtt.js +0 -902
  92. package/dist/NumberField-D_NucQlp.js +0 -26
  93. package/dist/ObjectField-CG-LaM65.js +0 -52
  94. package/dist/PercentField-B6sO_J3i.js +0 -63
  95. package/dist/PhoneField-CcQAWwR6.js +0 -28
  96. package/dist/QRCodeField-CEjWs-J5.js +0 -72
  97. package/dist/RichTextField-qOEJl5Ai.js +0 -32
  98. package/dist/SelectField-C8hWu3gm.js +0 -30
  99. package/dist/SummaryField-DgiFm-Cr.js +0 -19
  100. package/dist/TextAreaField-DuriTqsD.js +0 -36
  101. package/dist/TextField-CGNSl7RU.js +0 -29
  102. package/dist/TimeField-YO58ctFg.js +0 -21
  103. package/dist/UrlField-1-BMM1jn.js +0 -33
  104. package/dist/UserField-B6GqxP_S.js +0 -78
  105. package/dist/VectorField-BkEjbSt0.js +0 -36
  106. package/dist/src/ActivityTimeline.d.ts.map +0 -1
  107. package/dist/src/CommentAttachment.d.ts.map +0 -1
  108. package/dist/src/CommentInput.d.ts.map +0 -1
  109. package/dist/src/DetailSection.d.ts.map +0 -1
  110. package/dist/src/DetailTabs.d.ts.map +0 -1
  111. package/dist/src/DetailView.d.ts +0 -23
  112. package/dist/src/DetailView.d.ts.map +0 -1
  113. package/dist/src/DetailView.stories.d.ts.map +0 -1
  114. package/dist/src/DiffView.d.ts.map +0 -1
  115. package/dist/src/FieldChangeItem.d.ts.map +0 -1
  116. package/dist/src/HeaderHighlight.d.ts.map +0 -1
  117. package/dist/src/InlineCreateRelated.d.ts.map +0 -1
  118. package/dist/src/MentionAutocomplete.d.ts.map +0 -1
  119. package/dist/src/PointInTimeRestore.d.ts.map +0 -1
  120. package/dist/src/ReactionPicker.d.ts.map +0 -1
  121. package/dist/src/RecordActivityTimeline.d.ts.map +0 -1
  122. package/dist/src/RecordChatterPanel.d.ts.map +0 -1
  123. package/dist/src/RecordComments.d.ts.map +0 -1
  124. package/dist/src/RecordNavigationEnhanced.d.ts.map +0 -1
  125. package/dist/src/RelatedList.d.ts.map +0 -1
  126. package/dist/src/RelationshipGraph.d.ts.map +0 -1
  127. package/dist/src/RichTextCommentInput.d.ts.map +0 -1
  128. package/dist/src/SectionGroup.d.ts.map +0 -1
  129. package/dist/src/SubscriptionToggle.d.ts.map +0 -1
  130. package/dist/src/ThreadedReplies.d.ts.map +0 -1
  131. package/dist/src/autoLayout.d.ts.map +0 -1
  132. package/dist/src/index.d.ts.map +0 -1
  133. package/dist/src/useDetailTranslation.d.ts.map +0 -1
  134. package/src/ActivityTimeline.tsx +0 -184
  135. package/src/CommentAttachment.tsx +0 -192
  136. package/src/CommentInput.tsx +0 -81
  137. package/src/DetailSection.tsx +0 -340
  138. package/src/DetailTabs.tsx +0 -73
  139. package/src/DetailView.stories.tsx +0 -334
  140. package/src/DetailView.tsx +0 -823
  141. package/src/DiffView.tsx +0 -231
  142. package/src/FieldChangeItem.tsx +0 -46
  143. package/src/HeaderHighlight.tsx +0 -88
  144. package/src/InlineCreateRelated.tsx +0 -291
  145. package/src/MentionAutocomplete.tsx +0 -123
  146. package/src/PointInTimeRestore.tsx +0 -261
  147. package/src/ReactionPicker.tsx +0 -106
  148. package/src/RecordActivityTimeline.tsx +0 -429
  149. package/src/RecordChatterPanel.tsx +0 -207
  150. package/src/RecordComments.tsx +0 -215
  151. package/src/RecordNavigationEnhanced.tsx +0 -211
  152. package/src/RelatedList.tsx +0 -413
  153. package/src/RelationshipGraph.tsx +0 -286
  154. package/src/RichTextCommentInput.tsx +0 -348
  155. package/src/SectionGroup.tsx +0 -101
  156. package/src/SubscriptionToggle.tsx +0 -60
  157. package/src/ThreadedReplies.tsx +0 -161
  158. package/src/__tests__/ActivityTimeline.test.tsx +0 -119
  159. package/src/__tests__/ActivityTimelineFiltering.test.tsx +0 -143
  160. package/src/__tests__/CommentInput.test.tsx +0 -57
  161. package/src/__tests__/DetailSection.test.tsx +0 -490
  162. package/src/__tests__/DetailView.test.tsx +0 -694
  163. package/src/__tests__/FieldChangeItem.test.tsx +0 -119
  164. package/src/__tests__/HeaderHighlight.test.tsx +0 -213
  165. package/src/__tests__/MentionAutocomplete.test.tsx +0 -97
  166. package/src/__tests__/ReactionPicker.test.tsx +0 -113
  167. package/src/__tests__/RecordActivityTimeline.test.tsx +0 -395
  168. package/src/__tests__/RecordChatterPanel.test.tsx +0 -265
  169. package/src/__tests__/RecordComments.test.tsx +0 -96
  170. package/src/__tests__/RecordCommentsPinSearch.test.tsx +0 -133
  171. package/src/__tests__/RelatedList.test.tsx +0 -160
  172. package/src/__tests__/SectionGroup.test.tsx +0 -101
  173. package/src/__tests__/SubscriptionToggle.test.tsx +0 -84
  174. package/src/__tests__/ThreadedReplies.test.tsx +0 -212
  175. package/src/__tests__/autoLayout.test.ts +0 -228
  176. package/src/__tests__/phase12-features.test.tsx +0 -583
  177. package/src/__tests__/roadmap-features.test.tsx +0 -478
  178. package/src/autoLayout.ts +0 -128
  179. package/src/index.tsx +0 -149
  180. package/src/useDetailTranslation.ts +0 -114
  181. package/tsconfig.json +0 -18
  182. package/vite.config.ts +0 -56
  183. package/vitest.config.ts +0 -13
  184. package/vitest.setup.ts +0 -1
  185. /package/dist/{src → packages/plugin-detail/src}/ActivityTimeline.d.ts +0 -0
  186. /package/dist/{src → packages/plugin-detail/src}/CommentAttachment.d.ts +0 -0
  187. /package/dist/{src → packages/plugin-detail/src}/CommentInput.d.ts +0 -0
  188. /package/dist/{src → packages/plugin-detail/src}/DetailSection.d.ts +0 -0
  189. /package/dist/{src → packages/plugin-detail/src}/DetailTabs.d.ts +0 -0
  190. /package/dist/{src → packages/plugin-detail/src}/DetailView.stories.d.ts +0 -0
  191. /package/dist/{src → packages/plugin-detail/src}/DiffView.d.ts +0 -0
  192. /package/dist/{src → packages/plugin-detail/src}/FieldChangeItem.d.ts +0 -0
  193. /package/dist/{src → packages/plugin-detail/src}/HeaderHighlight.d.ts +0 -0
  194. /package/dist/{src → packages/plugin-detail/src}/InlineCreateRelated.d.ts +0 -0
  195. /package/dist/{src → packages/plugin-detail/src}/MentionAutocomplete.d.ts +0 -0
  196. /package/dist/{src → packages/plugin-detail/src}/PointInTimeRestore.d.ts +0 -0
  197. /package/dist/{src → packages/plugin-detail/src}/ReactionPicker.d.ts +0 -0
  198. /package/dist/{src → packages/plugin-detail/src}/RecordActivityTimeline.d.ts +0 -0
  199. /package/dist/{src → packages/plugin-detail/src}/RecordChatterPanel.d.ts +0 -0
  200. /package/dist/{src → packages/plugin-detail/src}/RecordComments.d.ts +0 -0
  201. /package/dist/{src → packages/plugin-detail/src}/RecordNavigationEnhanced.d.ts +0 -0
  202. /package/dist/{src → packages/plugin-detail/src}/RelationshipGraph.d.ts +0 -0
  203. /package/dist/{src → packages/plugin-detail/src}/RichTextCommentInput.d.ts +0 -0
  204. /package/dist/{src → packages/plugin-detail/src}/SectionGroup.d.ts +0 -0
  205. /package/dist/{src → packages/plugin-detail/src}/SubscriptionToggle.d.ts +0 -0
  206. /package/dist/{src → packages/plugin-detail/src}/ThreadedReplies.d.ts +0 -0
  207. /package/dist/{src → packages/plugin-detail/src}/autoLayout.d.ts +0 -0
  208. /package/dist/{src → packages/plugin-detail/src}/index.d.ts +0 -0
  209. /package/dist/{src → packages/plugin-detail/src}/useDetailTranslation.d.ts +0 -0
@@ -1,212 +0,0 @@
1
- /**
2
- * ObjectUI
3
- * Copyright (c) 2024-present ObjectStack Inc.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- */
8
-
9
- import { describe, it, expect, vi } from 'vitest';
10
- import { render, screen, fireEvent } from '@testing-library/react';
11
- import '@testing-library/jest-dom';
12
- import { ThreadedReplies } from '../ThreadedReplies';
13
- import type { FeedItem } from '@object-ui/types';
14
-
15
- const parentItem: FeedItem = {
16
- id: 'p1',
17
- type: 'comment',
18
- actor: 'Alice',
19
- body: 'Parent comment',
20
- createdAt: '2026-02-20T10:00:00Z',
21
- replyCount: 2,
22
- };
23
-
24
- const mockReplies: FeedItem[] = [
25
- {
26
- id: 'r1',
27
- type: 'comment',
28
- actor: 'Bob',
29
- body: 'First reply',
30
- createdAt: '2026-02-20T11:00:00Z',
31
- parentId: 'p1',
32
- },
33
- {
34
- id: 'r2',
35
- type: 'comment',
36
- actor: 'Charlie',
37
- body: 'Second reply',
38
- createdAt: '2026-02-20T12:00:00Z',
39
- parentId: 'p1',
40
- },
41
- ];
42
-
43
- describe('ThreadedReplies', () => {
44
- it('should render reply count toggle', () => {
45
- render(
46
- <ThreadedReplies parentItem={parentItem} replies={mockReplies} />,
47
- );
48
- expect(screen.getByText('2 replies')).toBeInTheDocument();
49
- });
50
-
51
- it('should use singular "reply" for one reply', () => {
52
- render(
53
- <ThreadedReplies parentItem={parentItem} replies={[mockReplies[0]]} />,
54
- );
55
- expect(screen.getByText('1 reply')).toBeInTheDocument();
56
- });
57
-
58
- it('should not render replies by default (collapsed)', () => {
59
- render(
60
- <ThreadedReplies parentItem={parentItem} replies={mockReplies} />,
61
- );
62
- expect(screen.queryByText('First reply')).not.toBeInTheDocument();
63
- });
64
-
65
- it('should expand replies when toggle is clicked', () => {
66
- render(
67
- <ThreadedReplies parentItem={parentItem} replies={mockReplies} />,
68
- );
69
- fireEvent.click(screen.getByText('2 replies'));
70
- expect(screen.getByText('First reply')).toBeInTheDocument();
71
- expect(screen.getByText('Second reply')).toBeInTheDocument();
72
- });
73
-
74
- it('should show reply authors', () => {
75
- render(
76
- <ThreadedReplies parentItem={parentItem} replies={mockReplies} />,
77
- );
78
- fireEvent.click(screen.getByText('2 replies'));
79
- expect(screen.getByText('Bob')).toBeInTheDocument();
80
- expect(screen.getByText('Charlie')).toBeInTheDocument();
81
- });
82
-
83
- it('should show reply input when onAddReply and showReplyInput', () => {
84
- const onAdd = vi.fn();
85
- render(
86
- <ThreadedReplies parentItem={parentItem} replies={[]} onAddReply={onAdd} showReplyInput />,
87
- );
88
- expect(screen.getByPlaceholderText('Reply…')).toBeInTheDocument();
89
- });
90
-
91
- it('should call onAddReply with parentId and text', () => {
92
- const onAdd = vi.fn().mockResolvedValue(undefined);
93
- render(
94
- <ThreadedReplies parentItem={parentItem} replies={[]} onAddReply={onAdd} showReplyInput />,
95
- );
96
- const input = screen.getByPlaceholderText('Reply…');
97
- fireEvent.change(input, { target: { value: 'My reply' } });
98
- fireEvent.click(screen.getByLabelText('Send reply'));
99
- expect(onAdd).toHaveBeenCalledWith('p1', 'My reply');
100
- });
101
-
102
- it('should return null when no replies and no reply input', () => {
103
- const { container } = render(
104
- <ThreadedReplies parentItem={parentItem} replies={[]} showReplyInput={false} />,
105
- );
106
- expect(container.firstChild).toBeNull();
107
- });
108
-
109
- it('should have aria-expanded=false when collapsed', () => {
110
- render(
111
- <ThreadedReplies parentItem={parentItem} replies={mockReplies} />,
112
- );
113
- const toggle = screen.getByText('2 replies').closest('button');
114
- expect(toggle).toHaveAttribute('aria-expanded', 'false');
115
- });
116
-
117
- it('should have aria-expanded=true when expanded', () => {
118
- render(
119
- <ThreadedReplies parentItem={parentItem} replies={mockReplies} />,
120
- );
121
- fireEvent.click(screen.getByText('2 replies'));
122
- const toggle = screen.getByText('2 replies').closest('button');
123
- expect(toggle).toHaveAttribute('aria-expanded', 'true');
124
- });
125
-
126
- it('should render avatarUrl when provided on reply', () => {
127
- const repliesWithAvatar: FeedItem[] = [
128
- {
129
- id: 'r1',
130
- type: 'comment',
131
- actor: 'Bob',
132
- actorAvatarUrl: 'https://example.com/bob.png',
133
- body: 'With avatar',
134
- createdAt: '2026-02-20T11:00:00Z',
135
- parentId: 'p1',
136
- },
137
- ];
138
- render(
139
- <ThreadedReplies parentItem={parentItem} replies={repliesWithAvatar} />,
140
- );
141
- fireEvent.click(screen.getByText('1 reply'));
142
- const img = screen.getByAltText('Bob');
143
- expect(img).toHaveAttribute('src', 'https://example.com/bob.png');
144
- });
145
-
146
- it('should render first-letter avatar fallback', () => {
147
- render(
148
- <ThreadedReplies parentItem={parentItem} replies={mockReplies} />,
149
- );
150
- fireEvent.click(screen.getByText('2 replies'));
151
- // Bob should show 'B' as fallback initial
152
- expect(screen.getByText('B')).toBeInTheDocument();
153
- });
154
-
155
- it('should submit reply via Ctrl+Enter', () => {
156
- const onAdd = vi.fn().mockResolvedValue(undefined);
157
- render(
158
- <ThreadedReplies parentItem={parentItem} replies={[]} onAddReply={onAdd} showReplyInput />,
159
- );
160
- const input = screen.getByPlaceholderText('Reply…');
161
- fireEvent.change(input, { target: { value: 'Ctrl reply' } });
162
- fireEvent.keyDown(input, { key: 'Enter', ctrlKey: true });
163
- expect(onAdd).toHaveBeenCalledWith('p1', 'Ctrl reply');
164
- });
165
-
166
- it('should disable Send button when input is empty', () => {
167
- const onAdd = vi.fn();
168
- render(
169
- <ThreadedReplies parentItem={parentItem} replies={[]} onAddReply={onAdd} showReplyInput />,
170
- );
171
- expect(screen.getByLabelText('Send reply')).toBeDisabled();
172
- });
173
-
174
- it('should disable input and button during reply submission', async () => {
175
- let resolveReply: () => void;
176
- const onAdd = vi.fn(() => new Promise<void>((r) => { resolveReply = r; }));
177
- render(
178
- <ThreadedReplies parentItem={parentItem} replies={[]} onAddReply={onAdd} showReplyInput />,
179
- );
180
- const input = screen.getByPlaceholderText('Reply…') as HTMLInputElement;
181
- fireEvent.change(input, { target: { value: 'submitting reply' } });
182
- fireEvent.click(screen.getByLabelText('Send reply'));
183
- expect(input).toBeDisabled();
184
- expect(screen.getByLabelText('Send reply')).toBeDisabled();
185
- resolveReply!();
186
- await vi.waitFor(() => {
187
- expect(input).not.toBeDisabled();
188
- });
189
- });
190
-
191
- it('should clear input after successful reply submission', async () => {
192
- const onAdd = vi.fn().mockResolvedValue(undefined);
193
- render(
194
- <ThreadedReplies parentItem={parentItem} replies={[]} onAddReply={onAdd} showReplyInput />,
195
- );
196
- const input = screen.getByPlaceholderText('Reply…') as HTMLInputElement;
197
- fireEvent.change(input, { target: { value: 'reply text' } });
198
- fireEvent.click(screen.getByLabelText('Send reply'));
199
- await vi.waitFor(() => {
200
- expect(input.value).toBe('');
201
- });
202
- });
203
-
204
- it('should render reply body and timestamp when expanded', () => {
205
- render(
206
- <ThreadedReplies parentItem={parentItem} replies={mockReplies} />,
207
- );
208
- fireEvent.click(screen.getByText('2 replies'));
209
- expect(screen.getByText('First reply')).toBeInTheDocument();
210
- expect(screen.getByText('Second reply')).toBeInTheDocument();
211
- });
212
- });
@@ -1,228 +0,0 @@
1
- /**
2
- * ObjectUI
3
- * Copyright (c) 2024-present ObjectStack Inc.
4
- *
5
- * This source code is licensed under the MIT license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- */
8
-
9
- import { describe, it, expect } from 'vitest';
10
- import {
11
- inferDetailColumns,
12
- isWideFieldType,
13
- applyAutoSpan,
14
- applyDetailAutoLayout,
15
- } from '../autoLayout';
16
-
17
- describe('Detail Auto-Layout', () => {
18
- describe('inferDetailColumns', () => {
19
- it('should return 1 column for 0 fields', () => {
20
- expect(inferDetailColumns(0)).toBe(1);
21
- });
22
-
23
- it('should return 1 column for 1-3 fields', () => {
24
- expect(inferDetailColumns(1)).toBe(1);
25
- expect(inferDetailColumns(2)).toBe(1);
26
- expect(inferDetailColumns(3)).toBe(1);
27
- });
28
-
29
- it('should return 2 columns for 4-10 fields', () => {
30
- expect(inferDetailColumns(4)).toBe(2);
31
- expect(inferDetailColumns(7)).toBe(2);
32
- expect(inferDetailColumns(10)).toBe(2);
33
- });
34
-
35
- it('should return 3 columns for 11+ fields', () => {
36
- expect(inferDetailColumns(11)).toBe(3);
37
- expect(inferDetailColumns(15)).toBe(3);
38
- expect(inferDetailColumns(50)).toBe(3);
39
- });
40
-
41
- it('should cap to 1 column when containerWidth < 640', () => {
42
- expect(inferDetailColumns(15, 500)).toBe(1);
43
- expect(inferDetailColumns(5, 639)).toBe(1);
44
- });
45
-
46
- it('should cap to 2 columns when containerWidth < 900', () => {
47
- expect(inferDetailColumns(15, 800)).toBe(2);
48
- expect(inferDetailColumns(15, 640)).toBe(2);
49
- expect(inferDetailColumns(5, 899)).toBe(2);
50
- });
51
-
52
- it('should not cap columns when containerWidth >= 900', () => {
53
- expect(inferDetailColumns(15, 900)).toBe(3);
54
- expect(inferDetailColumns(15, 1200)).toBe(3);
55
- });
56
-
57
- it('should not cap below field-count inference', () => {
58
- // 2 fields → 1 column, containerWidth 800 would cap at 2, but inference says 1
59
- expect(inferDetailColumns(2, 800)).toBe(1);
60
- });
61
-
62
- it('should still work without containerWidth (backward compatible)', () => {
63
- expect(inferDetailColumns(15)).toBe(3);
64
- expect(inferDetailColumns(5)).toBe(2);
65
- expect(inferDetailColumns(2)).toBe(1);
66
- });
67
- });
68
-
69
- describe('isWideFieldType', () => {
70
- it('should identify textarea as wide', () => {
71
- expect(isWideFieldType('textarea')).toBe(true);
72
- expect(isWideFieldType('field:textarea')).toBe(true);
73
- });
74
-
75
- it('should identify markdown as wide', () => {
76
- expect(isWideFieldType('markdown')).toBe(true);
77
- expect(isWideFieldType('field:markdown')).toBe(true);
78
- });
79
-
80
- it('should identify html as wide', () => {
81
- expect(isWideFieldType('html')).toBe(true);
82
- expect(isWideFieldType('field:html')).toBe(true);
83
- });
84
-
85
- it('should identify grid as wide', () => {
86
- expect(isWideFieldType('grid')).toBe(true);
87
- expect(isWideFieldType('field:grid')).toBe(true);
88
- });
89
-
90
- it('should identify rich-text as wide', () => {
91
- expect(isWideFieldType('rich-text')).toBe(true);
92
- expect(isWideFieldType('field:rich-text')).toBe(true);
93
- });
94
-
95
- it('should NOT identify regular types as wide', () => {
96
- expect(isWideFieldType('text')).toBe(false);
97
- expect(isWideFieldType('number')).toBe(false);
98
- expect(isWideFieldType('date')).toBe(false);
99
- expect(isWideFieldType('select')).toBe(false);
100
- });
101
- });
102
-
103
- describe('applyAutoSpan', () => {
104
- it('should return fields unchanged when columns <= 1', () => {
105
- const fields = [
106
- { name: 'desc', label: 'Description', type: 'textarea' },
107
- ];
108
- const result = applyAutoSpan(fields, 1);
109
- expect(result).toEqual(fields);
110
- });
111
-
112
- it('should set span on wide fields in multi-column layout', () => {
113
- const fields = [
114
- { name: 'name', label: 'Name', type: 'text' },
115
- { name: 'desc', label: 'Description', type: 'textarea' },
116
- ];
117
- const result = applyAutoSpan(fields, 2);
118
- expect(result[0].span).toBeUndefined();
119
- expect(result[1].span).toBe(2);
120
- });
121
-
122
- it('should NOT override user-defined span', () => {
123
- const fields = [
124
- { name: 'desc', label: 'Description', type: 'textarea', span: 1 },
125
- ];
126
- const result = applyAutoSpan(fields, 2);
127
- expect(result[0].span).toBe(1);
128
- });
129
-
130
- it('should handle fields without type', () => {
131
- const fields = [
132
- { name: 'name', label: 'Name' },
133
- ];
134
- const result = applyAutoSpan(fields, 2);
135
- expect(result[0].span).toBeUndefined();
136
- });
137
- });
138
-
139
- describe('applyDetailAutoLayout', () => {
140
- it('should infer 1 column for 3 fields', () => {
141
- const fields = [
142
- { name: 'a', label: 'A' },
143
- { name: 'b', label: 'B' },
144
- { name: 'c', label: 'C' },
145
- ];
146
- const result = applyDetailAutoLayout(fields, undefined);
147
- expect(result.columns).toBe(1);
148
- });
149
-
150
- it('should infer 2 columns for 5 fields', () => {
151
- const fields = Array.from({ length: 5 }, (_, i) => ({
152
- name: `f${i}`, label: `F${i}`,
153
- }));
154
- const result = applyDetailAutoLayout(fields, undefined);
155
- expect(result.columns).toBe(2);
156
- });
157
-
158
- it('should infer 3 columns for 15 fields', () => {
159
- const fields = Array.from({ length: 15 }, (_, i) => ({
160
- name: `f${i}`, label: `F${i}`,
161
- }));
162
- const result = applyDetailAutoLayout(fields, undefined);
163
- expect(result.columns).toBe(3);
164
- });
165
-
166
- it('should respect explicit columns and still apply auto-span', () => {
167
- const fields = [
168
- { name: 'name', label: 'Name', type: 'text' },
169
- { name: 'desc', label: 'Description', type: 'textarea' },
170
- ];
171
- const result = applyDetailAutoLayout(fields, 2);
172
- expect(result.columns).toBe(2);
173
- // Wide field gets auto-span
174
- expect(result.fields[1].span).toBe(2);
175
- });
176
-
177
- it('should not mutate original fields', () => {
178
- const fields = [
179
- { name: 'name', label: 'Name', type: 'text' },
180
- { name: 'desc', label: 'Description', type: 'textarea' },
181
- ];
182
- const original = fields.map(f => ({ ...f }));
183
- applyDetailAutoLayout(fields, undefined);
184
- expect(fields).toEqual(original);
185
- });
186
-
187
- it('should auto-span wide fields in inferred multi-column layout', () => {
188
- const fields = [
189
- { name: 'name', label: 'Name', type: 'text' },
190
- { name: 'email', label: 'Email', type: 'text' },
191
- { name: 'phone', label: 'Phone', type: 'text' },
192
- { name: 'addr', label: 'Address', type: 'text' },
193
- { name: 'notes', label: 'Notes', type: 'textarea' },
194
- ];
195
- const result = applyDetailAutoLayout(fields, undefined);
196
- expect(result.columns).toBe(2);
197
- // textarea field should span full row
198
- expect(result.fields[4].span).toBe(2);
199
- });
200
-
201
- it('should infer columns correctly when schemaColumns is undefined (no regression)', () => {
202
- // Ensure that removing explicit columns: 2 from RecordDetailView still gives good defaults
203
- const fields = Array.from({ length: 8 }, (_, i) => ({
204
- name: `f${i}`, label: `F${i}`, type: 'text',
205
- }));
206
- const result = applyDetailAutoLayout(fields, undefined);
207
- expect(result.columns).toBe(2);
208
- expect(result.fields.length).toBe(8);
209
- });
210
-
211
- it('should cap columns based on containerWidth when provided', () => {
212
- const fields = Array.from({ length: 15 }, (_, i) => ({
213
- name: `f${i}`, label: `F${i}`, type: 'text',
214
- }));
215
- // Narrow container: should cap to 1
216
- const result = applyDetailAutoLayout(fields, undefined, 500);
217
- expect(result.columns).toBe(1);
218
- });
219
-
220
- it('should still respect explicit schemaColumns regardless of containerWidth', () => {
221
- const fields = Array.from({ length: 15 }, (_, i) => ({
222
- name: `f${i}`, label: `F${i}`, type: 'text',
223
- }));
224
- const result = applyDetailAutoLayout(fields, 3, 500);
225
- expect(result.columns).toBe(3);
226
- });
227
- });
228
- });