@kronor/dtv 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.
- package/.editorconfig +12 -0
- package/.github/copilot-instructions.md +64 -0
- package/.github/workflows/ci.yml +51 -0
- package/.husky/pre-commit +8 -0
- package/README.md +63 -0
- package/docs/api/README.md +32 -0
- package/docs/api/cell-renderers.md +121 -0
- package/docs/api/no-rows-component.md +71 -0
- package/docs/api/runtime.md +78 -0
- package/e2e/app.spec.ts +6 -0
- package/e2e/cell-renderer-setfilterstate.spec.ts +63 -0
- package/e2e/filter-sharing.spec.ts +113 -0
- package/e2e/filter-url-persistence.spec.ts +36 -0
- package/e2e/graphqlMock.ts +144 -0
- package/e2e/multi-field-filters.spec.ts +95 -0
- package/e2e/pagination.spec.ts +38 -0
- package/e2e/payment-request-email-filter.spec.ts +67 -0
- package/e2e/save-filter-splitbutton.spec.ts +68 -0
- package/e2e/simple-view-email-filter.spec.ts +67 -0
- package/e2e/simple-view-transforms.spec.ts +171 -0
- package/e2e/simple-view.spec.ts +104 -0
- package/e2e/transform-regression.spec.ts +108 -0
- package/eslint.config.js +30 -0
- package/index.html +17 -0
- package/jest.config.js +10 -0
- package/package.json +45 -0
- package/playwright.config.ts +54 -0
- package/public/vite.svg +1 -0
- package/src/App.externalRuntime.test.ts +190 -0
- package/src/App.tsx +540 -0
- package/src/assets/react.svg +1 -0
- package/src/components/AIAssistantForm.tsx +241 -0
- package/src/components/FilterForm.test.ts +82 -0
- package/src/components/FilterForm.tsx +375 -0
- package/src/components/PhoneNumberFilter.tsx +102 -0
- package/src/components/SavedFilterList.tsx +181 -0
- package/src/components/SpeechInput.tsx +67 -0
- package/src/components/Table.tsx +119 -0
- package/src/components/TablePagination.tsx +40 -0
- package/src/components/aiAssistant.test.ts +270 -0
- package/src/components/aiAssistant.ts +291 -0
- package/src/framework/cell-renderer-components/CurrencyAmount.tsx +30 -0
- package/src/framework/cell-renderer-components/LayoutHelpers.tsx +74 -0
- package/src/framework/cell-renderer-components/Link.tsx +28 -0
- package/src/framework/cell-renderer-components/Mapping.tsx +11 -0
- package/src/framework/cell-renderer-components.test.ts +353 -0
- package/src/framework/column-definition.tsx +85 -0
- package/src/framework/currency.test.ts +46 -0
- package/src/framework/currency.ts +62 -0
- package/src/framework/data.staticConditions.test.ts +46 -0
- package/src/framework/data.test.ts +167 -0
- package/src/framework/data.ts +162 -0
- package/src/framework/filter-form-state.test.ts +189 -0
- package/src/framework/filter-form-state.ts +185 -0
- package/src/framework/filter-sharing.test.ts +135 -0
- package/src/framework/filter-sharing.ts +118 -0
- package/src/framework/filters.ts +194 -0
- package/src/framework/graphql.buildHasuraConditions.test.ts +473 -0
- package/src/framework/graphql.paginationKey.test.ts +29 -0
- package/src/framework/graphql.test.ts +286 -0
- package/src/framework/graphql.ts +462 -0
- package/src/framework/native-runtime/index.tsx +33 -0
- package/src/framework/native-runtime/nativeComponents.test.ts +108 -0
- package/src/framework/runtime-reference.test.ts +172 -0
- package/src/framework/runtime.ts +15 -0
- package/src/framework/saved-filters.test.ts +422 -0
- package/src/framework/saved-filters.ts +293 -0
- package/src/framework/state.test.ts +86 -0
- package/src/framework/state.ts +148 -0
- package/src/framework/transform.test.ts +51 -0
- package/src/framework/view-parser-initialvalues.test.ts +228 -0
- package/src/framework/view-parser.ts +714 -0
- package/src/framework/view.test.ts +1805 -0
- package/src/framework/view.ts +38 -0
- package/src/index.css +6 -0
- package/src/main.tsx +99 -0
- package/src/views/index.ts +12 -0
- package/src/views/payment-requests/components/NoRowsExtendDateRange.tsx +37 -0
- package/src/views/payment-requests/components/PaymentMethod.tsx +184 -0
- package/src/views/payment-requests/components/PaymentStatusTag.tsx +61 -0
- package/src/views/payment-requests/index.ts +1 -0
- package/src/views/payment-requests/runtime.tsx +145 -0
- package/src/views/payment-requests/view.json +692 -0
- package/src/views/payment-requests-initial-values.test.ts +73 -0
- package/src/views/request-log/index.ts +2 -0
- package/src/views/request-log/runtime.tsx +47 -0
- package/src/views/request-log/view.json +123 -0
- package/src/views/simple-test-view/index.ts +3 -0
- package/src/views/simple-test-view/runtime.tsx +85 -0
- package/src/views/simple-test-view/view.json +191 -0
- package/src/vite-env.d.ts +1 -0
- package/tailwind.config.js +7 -0
- package/tsconfig.app.json +26 -0
- package/tsconfig.jest.json +6 -0
- package/tsconfig.json +7 -0
- package/tsconfig.node.json +24 -0
- package/vite.config.ts +11 -0
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { parseFilterControlJson, parseInitialValue } from './view-parser';
|
|
2
|
+
import type { Runtime } from './runtime';
|
|
3
|
+
|
|
4
|
+
describe('FilterControlJson initialValue runtime reference parsing', () => {
|
|
5
|
+
const testRuntime: Runtime = {
|
|
6
|
+
cellRenderers: {},
|
|
7
|
+
queryTransforms: {},
|
|
8
|
+
noRowsComponents: {},
|
|
9
|
+
customFilterComponents: {},
|
|
10
|
+
initialValues: {
|
|
11
|
+
defaultEmail: 'admin@example.com',
|
|
12
|
+
defaultAge: 25,
|
|
13
|
+
defaultTags: ['admin', 'user'],
|
|
14
|
+
defaultConfig: { theme: 'dark', layout: 'grid' }
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const externalRuntime: Runtime = {
|
|
19
|
+
cellRenderers: {},
|
|
20
|
+
queryTransforms: {},
|
|
21
|
+
noRowsComponents: {},
|
|
22
|
+
customFilterComponents: {},
|
|
23
|
+
initialValues: {
|
|
24
|
+
defaultEmail: 'external@example.com', // Should override built-in runtime
|
|
25
|
+
externalValue: 'external-only'
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
describe('parseInitialValue', () => {
|
|
30
|
+
it('should return primitive values as-is', () => {
|
|
31
|
+
expect(parseInitialValue('test', testRuntime)).toBe('test');
|
|
32
|
+
expect(parseInitialValue(42, testRuntime)).toBe(42);
|
|
33
|
+
expect(parseInitialValue(true, testRuntime)).toBe(true);
|
|
34
|
+
expect(parseInitialValue(null, testRuntime)).toBe(null);
|
|
35
|
+
expect(parseInitialValue(undefined, testRuntime)).toBe(undefined);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('should return regular objects as-is', () => {
|
|
39
|
+
const obj = { name: 'test', value: 123 };
|
|
40
|
+
expect(parseInitialValue(obj, testRuntime)).toBe(obj);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('should resolve runtime references from initialValues section', () => {
|
|
44
|
+
const ref = { section: 'initialValues', key: 'defaultEmail' };
|
|
45
|
+
expect(parseInitialValue(ref, testRuntime)).toBe('admin@example.com');
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('should resolve complex values from runtime references', () => {
|
|
49
|
+
const ref = { section: 'initialValues', key: 'defaultTags' };
|
|
50
|
+
expect(parseInitialValue(ref, testRuntime)).toEqual(['admin', 'user']);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('should prefer external runtime over built-in runtime', () => {
|
|
54
|
+
const ref = { section: 'initialValues', key: 'defaultEmail' };
|
|
55
|
+
expect(parseInitialValue(ref, testRuntime, externalRuntime)).toBe('external@example.com');
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('should resolve from external runtime when key only exists there', () => {
|
|
59
|
+
const ref = { section: 'initialValues', key: 'externalValue' };
|
|
60
|
+
expect(parseInitialValue(ref, testRuntime, externalRuntime)).toBe('external-only');
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('should throw error for non-existent runtime reference keys', () => {
|
|
64
|
+
const ref = { section: 'initialValues', key: 'nonexistent' };
|
|
65
|
+
|
|
66
|
+
expect(() => parseInitialValue(ref, testRuntime)).toThrow(
|
|
67
|
+
'Reference "nonexistent" not found in initialValues'
|
|
68
|
+
);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('should return runtime references with non-initialValues sections as-is', () => {
|
|
72
|
+
const ref = { section: 'cellRenderers', key: 'someRenderer' };
|
|
73
|
+
expect(parseInitialValue(ref, testRuntime)).toBe(ref);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('should handle objects that look like runtime references but fail parsing', () => {
|
|
77
|
+
const notARef = { section: 123, key: 'test' }; // Invalid section type
|
|
78
|
+
expect(parseInitialValue(notARef, testRuntime)).toBe(notARef);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
describe('parseFilterControlJson with initialValue runtime references', () => {
|
|
83
|
+
it('should parse text control with runtime reference initialValue', () => {
|
|
84
|
+
const json = {
|
|
85
|
+
type: 'text',
|
|
86
|
+
label: 'Email',
|
|
87
|
+
initialValue: { section: 'initialValues', key: 'defaultEmail' }
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const result = parseFilterControlJson(json, testRuntime);
|
|
91
|
+
expect(result).toEqual({
|
|
92
|
+
type: 'text',
|
|
93
|
+
label: 'Email',
|
|
94
|
+
initialValue: 'admin@example.com'
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('should parse dropdown control with runtime reference initialValue', () => {
|
|
99
|
+
const json = {
|
|
100
|
+
type: 'dropdown',
|
|
101
|
+
label: 'Age',
|
|
102
|
+
items: [
|
|
103
|
+
{ label: '18-25', value: 25 },
|
|
104
|
+
{ label: '26-35', value: 30 }
|
|
105
|
+
],
|
|
106
|
+
initialValue: { section: 'initialValues', key: 'defaultAge' }
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const result = parseFilterControlJson(json, testRuntime);
|
|
110
|
+
expect(result).toEqual({
|
|
111
|
+
type: 'dropdown',
|
|
112
|
+
label: 'Age',
|
|
113
|
+
items: [
|
|
114
|
+
{ label: '18-25', value: 25 },
|
|
115
|
+
{ label: '26-35', value: 30 }
|
|
116
|
+
],
|
|
117
|
+
initialValue: 25
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('should parse multiselect control with array runtime reference initialValue', () => {
|
|
122
|
+
const json = {
|
|
123
|
+
type: 'multiselect',
|
|
124
|
+
label: 'Tags',
|
|
125
|
+
items: [
|
|
126
|
+
{ label: 'Admin', value: 'admin' },
|
|
127
|
+
{ label: 'User', value: 'user' }
|
|
128
|
+
],
|
|
129
|
+
initialValue: { section: 'initialValues', key: 'defaultTags' }
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
const result = parseFilterControlJson(json, testRuntime);
|
|
133
|
+
expect(result).toEqual({
|
|
134
|
+
type: 'multiselect',
|
|
135
|
+
label: 'Tags',
|
|
136
|
+
items: [
|
|
137
|
+
{ label: 'Admin', value: 'admin' },
|
|
138
|
+
{ label: 'User', value: 'user' }
|
|
139
|
+
],
|
|
140
|
+
initialValue: ['admin', 'user']
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('should parse customOperator control with runtime reference initialValue', () => {
|
|
145
|
+
const json = {
|
|
146
|
+
type: 'customOperator',
|
|
147
|
+
operators: [{ label: 'Equals', value: 'eq' }],
|
|
148
|
+
valueControl: { type: 'text' },
|
|
149
|
+
initialValue: { section: 'initialValues', key: 'defaultConfig' }
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const result = parseFilterControlJson(json, testRuntime);
|
|
153
|
+
expect(result).toEqual({
|
|
154
|
+
type: 'customOperator',
|
|
155
|
+
operators: [{ label: 'Equals', value: 'eq' }],
|
|
156
|
+
valueControl: { type: 'text', initialValue: undefined },
|
|
157
|
+
initialValue: { theme: 'dark', layout: 'grid' }
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it('should handle nested customOperator with runtime references in valueControl', () => {
|
|
162
|
+
const json = {
|
|
163
|
+
type: 'customOperator',
|
|
164
|
+
operators: [{ label: 'Equals', value: 'eq' }],
|
|
165
|
+
valueControl: {
|
|
166
|
+
type: 'text',
|
|
167
|
+
initialValue: { section: 'initialValues', key: 'defaultEmail' }
|
|
168
|
+
},
|
|
169
|
+
initialValue: { section: 'initialValues', key: 'defaultAge' }
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
const result = parseFilterControlJson(json, testRuntime);
|
|
173
|
+
expect(result).toEqual({
|
|
174
|
+
type: 'customOperator',
|
|
175
|
+
operators: [{ label: 'Equals', value: 'eq' }],
|
|
176
|
+
valueControl: {
|
|
177
|
+
type: 'text',
|
|
178
|
+
initialValue: 'admin@example.com'
|
|
179
|
+
},
|
|
180
|
+
initialValue: 25
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it('should preserve non-runtime-reference initialValues', () => {
|
|
185
|
+
const json = {
|
|
186
|
+
type: 'text',
|
|
187
|
+
label: 'Name',
|
|
188
|
+
initialValue: 'static value'
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
const result = parseFilterControlJson(json, testRuntime);
|
|
192
|
+
expect(result).toEqual({
|
|
193
|
+
type: 'text',
|
|
194
|
+
label: 'Name',
|
|
195
|
+
initialValue: 'static value'
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it('should handle missing initialValue', () => {
|
|
200
|
+
const json = {
|
|
201
|
+
type: 'text',
|
|
202
|
+
label: 'Name'
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
const result = parseFilterControlJson(json, testRuntime);
|
|
206
|
+
expect(result).toEqual({
|
|
207
|
+
type: 'text',
|
|
208
|
+
label: 'Name',
|
|
209
|
+
initialValue: undefined
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
it('should prefer external runtime for initialValue resolution', () => {
|
|
214
|
+
const json = {
|
|
215
|
+
type: 'text',
|
|
216
|
+
label: 'Email',
|
|
217
|
+
initialValue: { section: 'initialValues', key: 'defaultEmail' }
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
const result = parseFilterControlJson(json, testRuntime, externalRuntime);
|
|
221
|
+
expect(result).toEqual({
|
|
222
|
+
type: 'text',
|
|
223
|
+
label: 'Email',
|
|
224
|
+
initialValue: 'external@example.com'
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
});
|