@object-ui/plugin-detail 3.3.0 → 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 (134) hide show
  1. package/CHANGELOG.md +11 -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-Xuieq0ZI.js → AvatarField-Dy2XGlPz.js} +16 -15
  6. package/dist/{BooleanField-DwfMKknK.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-B0HTmmD7.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-DVTimsc3.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-rRi_P0N0.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-2CnhcWI0.js → SignatureField-B1wh3f5A.js} +18 -17
  31. package/dist/{SliderField-DEpMVXko.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.js +1912 -1728
  40. package/dist/index.umd.cjs +38 -47
  41. package/dist/packages/plugin-detail/src/DetailSection.d.ts.map +1 -1
  42. package/dist/packages/plugin-detail/src/DetailView.d.ts +24 -0
  43. package/dist/packages/plugin-detail/src/DetailView.d.ts.map +1 -1
  44. package/dist/packages/plugin-detail/src/RelatedList.d.ts +8 -0
  45. package/dist/packages/plugin-detail/src/RelatedList.d.ts.map +1 -1
  46. package/dist/packages/plugin-detail/src/useDetailTranslation.d.ts.map +1 -1
  47. package/dist/plugin-detail.css +1 -2
  48. package/dist/rolldown-runtime-DnwLefa7.js +23 -0
  49. package/dist/{src-C56Ly5uG.js → src-DyUKLvMN.js} +18271 -26636
  50. package/dist/{useFieldTranslation-CkxqyB82.js → useFieldTranslation-BRgjC1oq.js} +1 -1
  51. package/package.json +33 -11
  52. package/.turbo/turbo-build.log +0 -64
  53. package/dist/AddressField-CDLSeyNx.js +0 -93
  54. package/dist/AutoNumberField-CtE7suf5.js +0 -14
  55. package/dist/CodeField-CfwgRxx2.js +0 -22
  56. package/dist/ColorField-YKHA7dBD.js +0 -37
  57. package/dist/CurrencyField-tvS3fPAF.js +0 -51
  58. package/dist/DateField-BKqXpkOh.js +0 -21
  59. package/dist/DateTimeField-CR-nJCE7.js +0 -32
  60. package/dist/EmailField-CgvW1Qal.js +0 -28
  61. package/dist/FileField-BVAme2ML.js +0 -151
  62. package/dist/FormulaField-DamJ2VaG.js +0 -14
  63. package/dist/GeolocationField-C99z7ZBM.js +0 -113
  64. package/dist/GridField-C9JbpTx_.js +0 -51
  65. package/dist/ImageField-CDANtgVV.js +0 -75
  66. package/dist/LocationField-ZSyZ0O-h.js +0 -35
  67. package/dist/LookupField-B3hQJt95.js +0 -903
  68. package/dist/LookupField-D00z6gn_.js +0 -2
  69. package/dist/NumberField-DL2QAL7X.js +0 -26
  70. package/dist/ObjectField-JYvUnuRO.js +0 -52
  71. package/dist/PercentField-DjR6BSpw.js +0 -63
  72. package/dist/PhoneField-CX1JL-jp.js +0 -28
  73. package/dist/QRCodeField-CH_1pU6R.js +0 -72
  74. package/dist/RichTextField-CJqLWlrb.js +0 -32
  75. package/dist/SelectField-DGoDoRM_.js +0 -30
  76. package/dist/SelectField-XBVI50AD.js +0 -2
  77. package/dist/SummaryField-7ch9aqAu.js +0 -19
  78. package/dist/TextAreaField-Cmw1oXcw.js +0 -36
  79. package/dist/TextField-OTLa3p51.js +0 -29
  80. package/dist/TimeField-DKPoNWoR.js +0 -21
  81. package/dist/UrlField-CxbmzP9f.js +0 -33
  82. package/dist/UserField-ChvwUkMK.js +0 -78
  83. package/dist/VectorField-BVClL8Vw.js +0 -36
  84. package/src/ActivityTimeline.tsx +0 -184
  85. package/src/CommentAttachment.tsx +0 -194
  86. package/src/CommentInput.tsx +0 -81
  87. package/src/DetailSection.tsx +0 -340
  88. package/src/DetailTabs.tsx +0 -73
  89. package/src/DetailView.stories.tsx +0 -334
  90. package/src/DetailView.tsx +0 -823
  91. package/src/DiffView.tsx +0 -233
  92. package/src/FieldChangeItem.tsx +0 -46
  93. package/src/HeaderHighlight.tsx +0 -88
  94. package/src/InlineCreateRelated.tsx +0 -291
  95. package/src/MentionAutocomplete.tsx +0 -123
  96. package/src/PointInTimeRestore.tsx +0 -261
  97. package/src/ReactionPicker.tsx +0 -106
  98. package/src/RecordActivityTimeline.tsx +0 -433
  99. package/src/RecordChatterPanel.tsx +0 -209
  100. package/src/RecordComments.tsx +0 -217
  101. package/src/RecordNavigationEnhanced.tsx +0 -213
  102. package/src/RelatedList.tsx +0 -413
  103. package/src/RelationshipGraph.tsx +0 -286
  104. package/src/RichTextCommentInput.tsx +0 -350
  105. package/src/SectionGroup.tsx +0 -101
  106. package/src/SubscriptionToggle.tsx +0 -62
  107. package/src/ThreadedReplies.tsx +0 -163
  108. package/src/__tests__/ActivityTimeline.test.tsx +0 -119
  109. package/src/__tests__/ActivityTimelineFiltering.test.tsx +0 -143
  110. package/src/__tests__/CommentInput.test.tsx +0 -57
  111. package/src/__tests__/DetailSection.test.tsx +0 -490
  112. package/src/__tests__/DetailView.test.tsx +0 -694
  113. package/src/__tests__/FieldChangeItem.test.tsx +0 -119
  114. package/src/__tests__/HeaderHighlight.test.tsx +0 -213
  115. package/src/__tests__/MentionAutocomplete.test.tsx +0 -97
  116. package/src/__tests__/ReactionPicker.test.tsx +0 -113
  117. package/src/__tests__/RecordActivityTimeline.test.tsx +0 -395
  118. package/src/__tests__/RecordChatterPanel.test.tsx +0 -265
  119. package/src/__tests__/RecordComments.test.tsx +0 -96
  120. package/src/__tests__/RecordCommentsPinSearch.test.tsx +0 -133
  121. package/src/__tests__/RelatedList.test.tsx +0 -160
  122. package/src/__tests__/SectionGroup.test.tsx +0 -101
  123. package/src/__tests__/SubscriptionToggle.test.tsx +0 -84
  124. package/src/__tests__/ThreadedReplies.test.tsx +0 -212
  125. package/src/__tests__/autoLayout.test.ts +0 -228
  126. package/src/__tests__/phase12-features.test.tsx +0 -583
  127. package/src/__tests__/roadmap-features.test.tsx +0 -478
  128. package/src/autoLayout.ts +0 -128
  129. package/src/index.tsx +0 -149
  130. package/src/useDetailTranslation.ts +0 -183
  131. package/tsconfig.json +0 -18
  132. package/vite.config.ts +0 -57
  133. package/vitest.config.ts +0 -13
  134. package/vitest.setup.ts +0 -1
@@ -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
- });