@object-ui/plugin-list 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.
- package/CHANGELOG.md +34 -0
- package/README.md +21 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +30492 -38346
- package/dist/index.umd.cjs +30 -38
- package/dist/{src → packages/plugin-list/src}/ListView.d.ts +17 -1
- package/dist/packages/plugin-list/src/ListView.d.ts.map +1 -0
- package/dist/packages/plugin-list/src/ListView.stories.d.ts.map +1 -0
- package/dist/packages/plugin-list/src/ObjectGallery.d.ts.map +1 -0
- package/dist/packages/plugin-list/src/UserFilters.d.ts.map +1 -0
- package/dist/packages/plugin-list/src/ViewSwitcher.d.ts.map +1 -0
- package/dist/packages/plugin-list/src/components/TabBar.d.ts.map +1 -0
- package/dist/{src → packages/plugin-list/src}/index.d.ts +1 -1
- package/dist/packages/plugin-list/src/index.d.ts.map +1 -0
- package/dist/plugin-list.css +1 -2
- package/package.json +35 -13
- package/.turbo/turbo-build.log +0 -24
- package/dist/src/ListView.d.ts.map +0 -1
- package/dist/src/ListView.stories.d.ts.map +0 -1
- package/dist/src/ObjectGallery.d.ts.map +0 -1
- package/dist/src/UserFilters.d.ts.map +0 -1
- package/dist/src/ViewSwitcher.d.ts.map +0 -1
- package/dist/src/components/TabBar.d.ts.map +0 -1
- package/dist/src/index.d.ts.map +0 -1
- package/src/ListView.stories.tsx +0 -64
- package/src/ListView.tsx +0 -1688
- package/src/ObjectGallery.tsx +0 -308
- package/src/UserFilters.tsx +0 -453
- package/src/ViewSwitcher.tsx +0 -113
- package/src/__tests__/ConditionalFormatting.test.ts +0 -285
- package/src/__tests__/DataFetch.test.tsx +0 -253
- package/src/__tests__/Export.test.tsx +0 -175
- package/src/__tests__/FilterNormalization.test.ts +0 -162
- package/src/__tests__/GalleryGrouping.test.tsx +0 -237
- package/src/__tests__/GalleryTimelineSpecConfig.test.tsx +0 -203
- package/src/__tests__/ListView.test.tsx +0 -2151
- package/src/__tests__/ListViewGroupingPropagation.test.tsx +0 -250
- package/src/__tests__/ListViewPersistence.test.tsx +0 -129
- package/src/__tests__/ObjectGallery.test.tsx +0 -208
- package/src/__tests__/TabBar.test.tsx +0 -199
- package/src/__tests__/UserFilters.test.tsx +0 -486
- package/src/components/TabBar.tsx +0 -120
- package/src/index.tsx +0 -78
- package/tsconfig.json +0 -18
- package/vite.config.ts +0 -56
- package/vitest.config.ts +0 -12
- package/vitest.setup.ts +0 -1
- /package/dist/{src → packages/plugin-list/src}/ListView.stories.d.ts +0 -0
- /package/dist/{src → packages/plugin-list/src}/ObjectGallery.d.ts +0 -0
- /package/dist/{src → packages/plugin-list/src}/UserFilters.d.ts +0 -0
- /package/dist/{src → packages/plugin-list/src}/ViewSwitcher.d.ts +0 -0
- /package/dist/{src → packages/plugin-list/src}/components/TabBar.d.ts +0 -0
|
@@ -1,203 +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 type { ListViewSchema } from '@object-ui/types';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Tests for Gallery/Timeline spec config propagation through ListView's
|
|
14
|
-
* buildViewSchema. We test the internal logic by checking that the
|
|
15
|
-
* ListViewSchema types accept spec config and that the config values are correct.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
describe('Gallery/Timeline Spec Config Types', () => {
|
|
19
|
-
describe('GalleryConfig on ListViewSchema', () => {
|
|
20
|
-
it('accepts spec gallery config with coverField', () => {
|
|
21
|
-
const schema: ListViewSchema = {
|
|
22
|
-
type: 'list-view',
|
|
23
|
-
objectName: 'products',
|
|
24
|
-
viewType: 'gallery',
|
|
25
|
-
fields: ['name', 'photo'],
|
|
26
|
-
gallery: {
|
|
27
|
-
coverField: 'photo',
|
|
28
|
-
coverFit: 'contain',
|
|
29
|
-
cardSize: 'large',
|
|
30
|
-
titleField: 'name',
|
|
31
|
-
visibleFields: ['status', 'price'],
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
expect(schema.gallery?.coverField).toBe('photo');
|
|
36
|
-
expect(schema.gallery?.coverFit).toBe('contain');
|
|
37
|
-
expect(schema.gallery?.cardSize).toBe('large');
|
|
38
|
-
expect(schema.gallery?.titleField).toBe('name');
|
|
39
|
-
expect(schema.gallery?.visibleFields).toEqual(['status', 'price']);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('accepts all cardSize values', () => {
|
|
43
|
-
const sizes = ['small', 'medium', 'large'] as const;
|
|
44
|
-
sizes.forEach((cardSize) => {
|
|
45
|
-
const schema: ListViewSchema = {
|
|
46
|
-
type: 'list-view',
|
|
47
|
-
objectName: 'products',
|
|
48
|
-
viewType: 'gallery',
|
|
49
|
-
fields: ['name'],
|
|
50
|
-
gallery: { cardSize },
|
|
51
|
-
};
|
|
52
|
-
expect(schema.gallery?.cardSize).toBe(cardSize);
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it('accepts all coverFit values', () => {
|
|
57
|
-
const fits = ['cover', 'contain', 'fill'] as const;
|
|
58
|
-
fits.forEach((coverFit) => {
|
|
59
|
-
const schema: ListViewSchema = {
|
|
60
|
-
type: 'list-view',
|
|
61
|
-
objectName: 'products',
|
|
62
|
-
viewType: 'gallery',
|
|
63
|
-
fields: ['name'],
|
|
64
|
-
gallery: { coverFit },
|
|
65
|
-
};
|
|
66
|
-
expect(schema.gallery?.coverFit).toBe(coverFit);
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it('accepts legacy imageField and subtitleField alongside spec fields', () => {
|
|
71
|
-
const schema: ListViewSchema = {
|
|
72
|
-
type: 'list-view',
|
|
73
|
-
objectName: 'products',
|
|
74
|
-
viewType: 'gallery',
|
|
75
|
-
fields: ['name'],
|
|
76
|
-
gallery: {
|
|
77
|
-
coverField: 'photo',
|
|
78
|
-
imageField: 'legacyImg',
|
|
79
|
-
subtitleField: 'description',
|
|
80
|
-
},
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
expect(schema.gallery?.coverField).toBe('photo');
|
|
84
|
-
expect(schema.gallery?.imageField).toBe('legacyImg');
|
|
85
|
-
expect(schema.gallery?.subtitleField).toBe('description');
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it('accepts gallery config from legacy options as fallback', () => {
|
|
89
|
-
const schema: ListViewSchema = {
|
|
90
|
-
type: 'list-view',
|
|
91
|
-
objectName: 'products',
|
|
92
|
-
viewType: 'gallery',
|
|
93
|
-
fields: ['name'],
|
|
94
|
-
options: {
|
|
95
|
-
gallery: { imageField: 'oldImg', titleField: 'label' },
|
|
96
|
-
},
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
expect(schema.options?.gallery?.imageField).toBe('oldImg');
|
|
100
|
-
expect(schema.options?.gallery?.titleField).toBe('label');
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
describe('TimelineConfig on ListViewSchema', () => {
|
|
105
|
-
it('accepts spec timeline config with all fields', () => {
|
|
106
|
-
const schema: ListViewSchema = {
|
|
107
|
-
type: 'list-view',
|
|
108
|
-
objectName: 'events',
|
|
109
|
-
viewType: 'timeline',
|
|
110
|
-
fields: ['name', 'date'],
|
|
111
|
-
timeline: {
|
|
112
|
-
startDateField: 'start_date',
|
|
113
|
-
endDateField: 'end_date',
|
|
114
|
-
titleField: 'event_name',
|
|
115
|
-
groupByField: 'category',
|
|
116
|
-
colorField: 'priority_color',
|
|
117
|
-
scale: 'month',
|
|
118
|
-
},
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
expect(schema.timeline?.startDateField).toBe('start_date');
|
|
122
|
-
expect(schema.timeline?.endDateField).toBe('end_date');
|
|
123
|
-
expect(schema.timeline?.titleField).toBe('event_name');
|
|
124
|
-
expect(schema.timeline?.groupByField).toBe('category');
|
|
125
|
-
expect(schema.timeline?.colorField).toBe('priority_color');
|
|
126
|
-
expect(schema.timeline?.scale).toBe('month');
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
it('accepts legacy dateField for backward compatibility', () => {
|
|
130
|
-
const schema: ListViewSchema = {
|
|
131
|
-
type: 'list-view',
|
|
132
|
-
objectName: 'events',
|
|
133
|
-
viewType: 'timeline',
|
|
134
|
-
fields: ['name'],
|
|
135
|
-
timeline: {
|
|
136
|
-
startDateField: 'created_at',
|
|
137
|
-
titleField: 'name',
|
|
138
|
-
dateField: 'legacy_date',
|
|
139
|
-
},
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
expect(schema.timeline?.startDateField).toBe('created_at');
|
|
143
|
-
expect(schema.timeline?.dateField).toBe('legacy_date');
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
it('supports all scale values', () => {
|
|
147
|
-
const scales = ['hour', 'day', 'week', 'month', 'quarter', 'year'] as const;
|
|
148
|
-
scales.forEach((scale) => {
|
|
149
|
-
const schema: ListViewSchema = {
|
|
150
|
-
type: 'list-view',
|
|
151
|
-
objectName: 'events',
|
|
152
|
-
viewType: 'timeline',
|
|
153
|
-
fields: ['name'],
|
|
154
|
-
timeline: { startDateField: 'date', titleField: 'name', scale },
|
|
155
|
-
};
|
|
156
|
-
expect(schema.timeline?.scale).toBe(scale);
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
it('accepts timeline config from legacy options as fallback', () => {
|
|
161
|
-
const schema: ListViewSchema = {
|
|
162
|
-
type: 'list-view',
|
|
163
|
-
objectName: 'events',
|
|
164
|
-
viewType: 'timeline',
|
|
165
|
-
fields: ['name'],
|
|
166
|
-
options: {
|
|
167
|
-
timeline: { dateField: 'created_at', titleField: 'name' },
|
|
168
|
-
},
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
expect(schema.options?.timeline?.dateField).toBe('created_at');
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
describe('spec config co-existence', () => {
|
|
176
|
-
it('gallery and timeline configs can coexist on the same ListViewSchema', () => {
|
|
177
|
-
const schema: ListViewSchema = {
|
|
178
|
-
type: 'list-view',
|
|
179
|
-
objectName: 'projects',
|
|
180
|
-
viewType: 'grid',
|
|
181
|
-
fields: ['name', 'date', 'photo'],
|
|
182
|
-
gallery: {
|
|
183
|
-
coverField: 'photo',
|
|
184
|
-
cardSize: 'medium',
|
|
185
|
-
titleField: 'name',
|
|
186
|
-
visibleFields: ['status'],
|
|
187
|
-
},
|
|
188
|
-
timeline: {
|
|
189
|
-
startDateField: 'start_date',
|
|
190
|
-
titleField: 'name',
|
|
191
|
-
scale: 'quarter',
|
|
192
|
-
groupByField: 'team',
|
|
193
|
-
},
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
expect(schema.gallery?.coverField).toBe('photo');
|
|
197
|
-
expect(schema.gallery?.cardSize).toBe('medium');
|
|
198
|
-
expect(schema.timeline?.startDateField).toBe('start_date');
|
|
199
|
-
expect(schema.timeline?.scale).toBe('quarter');
|
|
200
|
-
expect(schema.timeline?.groupByField).toBe('team');
|
|
201
|
-
});
|
|
202
|
-
});
|
|
203
|
-
});
|