@truedat/qx 5.14.0 → 5.15.0

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 (120) hide show
  1. package/package.json +3 -3
  2. package/src/api.js +3 -2
  3. package/src/components/QxRoutes.js +4 -4
  4. package/src/components/common/ResourceSelector.js +80 -0
  5. package/src/components/common/TestFormWrapper.js +9 -6
  6. package/src/components/common/TypeSelector.js +3 -1
  7. package/src/components/common/__tests__/DescriptionInput.spec.js +48 -0
  8. package/src/components/common/__tests__/ResourceSelector.spec.js +124 -0
  9. package/src/components/common/__tests__/TypeSelector.spec.js +29 -0
  10. package/src/components/common/__tests__/__snapshots__/DescriptionInput.spec.js.snap +19 -0
  11. package/src/components/common/__tests__/__snapshots__/ResourceSelector.spec.js.snap +484 -0
  12. package/src/components/common/__tests__/__snapshots__/TypeSelector.spec.js.snap +230 -0
  13. package/src/components/common/expressions/Clauses.js +100 -0
  14. package/src/components/common/expressions/Condition.js +178 -0
  15. package/src/components/common/expressions/Expression.js +54 -0
  16. package/src/components/common/expressions/FieldSelector.js +66 -0
  17. package/src/components/{functions → common}/expressions/FunctionArgs.js +1 -0
  18. package/src/components/{functions → common}/expressions/FunctionSelector.js +24 -4
  19. package/src/components/{functions → common}/expressions/ParamSelector.js +3 -3
  20. package/src/components/{functions → common}/expressions/ShapeSelector.js +22 -6
  21. package/src/components/common/expressions/__tests__/Clauses.spec.js +53 -0
  22. package/src/components/common/expressions/__tests__/Condition.spec.js +33 -0
  23. package/src/components/{functions → common}/expressions/__tests__/ConstantSelector.spec.js +6 -1
  24. package/src/components/{functions → common}/expressions/__tests__/Expression.spec.js +7 -5
  25. package/src/components/common/expressions/__tests__/FieldSelector.spec.js +24 -0
  26. package/src/components/{functions → common}/expressions/__tests__/FunctionArgs.spec.js +20 -6
  27. package/src/components/{functions → common}/expressions/__tests__/FunctionSelector.spec.js +1 -1
  28. package/src/components/{functions → common}/expressions/__tests__/ParamSelector.spec.js +22 -10
  29. package/src/components/{functions → common}/expressions/__tests__/ShapeSelector.spec.js +3 -3
  30. package/src/components/common/expressions/__tests__/__snapshots__/Clauses.spec.js.snap +64 -0
  31. package/src/components/common/expressions/__tests__/__snapshots__/Condition.spec.js.snap +316 -0
  32. package/src/components/{functions → common}/expressions/__tests__/__snapshots__/ConstantSelector.spec.js.snap +1 -1
  33. package/src/components/common/expressions/__tests__/__snapshots__/Expression.spec.js.snap +939 -0
  34. package/src/components/common/expressions/__tests__/__snapshots__/FieldSelector.spec.js.snap +5 -0
  35. package/src/components/common/expressions/__tests__/__snapshots__/FunctionArgs.spec.js.snap +344 -0
  36. package/src/components/{functions → common}/expressions/__tests__/__snapshots__/ParamSelector.spec.js.snap +4 -4
  37. package/src/components/{functions → common}/expressions/__tests__/__snapshots__/ShapeSelector.spec.js.snap +17 -24
  38. package/src/components/common/expressions/constantInputs/AnySelector.js +44 -0
  39. package/src/components/{functions → common}/expressions/constantInputs/__tests__/AnySelector.spec.js +21 -14
  40. package/src/components/{functions → common}/expressions/constantInputs/__tests__/DefaultSelector.spec.js +5 -2
  41. package/src/components/{functions → common}/expressions/constantInputs/__tests__/__snapshots__/AnySelector.spec.js.snap +2 -2
  42. package/src/components/common/expressions/index.js +4 -0
  43. package/src/components/common/resourceSelectors/DataStructureSelector.js +63 -0
  44. package/src/components/common/resourceSelectors/DataViewSelector.js +65 -0
  45. package/src/components/common/resourceSelectors/ReferenceDatasetSelector.js +61 -0
  46. package/src/components/common/resourceSelectors/__tests__/DataStructureSelector.spec.js +31 -0
  47. package/src/components/common/resourceSelectors/__tests__/DataViewSelector.spec.js +133 -0
  48. package/src/components/common/resourceSelectors/__tests__/ReferenceDatasetSelector.spec.js +97 -0
  49. package/src/components/common/resourceSelectors/__tests__/__snapshots__/DataStructureSelector.spec.js.snap +105 -0
  50. package/src/components/common/resourceSelectors/__tests__/__snapshots__/DataViewSelector.spec.js.snap +50 -0
  51. package/src/components/common/resourceSelectors/__tests__/__snapshots__/ReferenceDatasetSelector.spec.js.snap +50 -0
  52. package/src/components/common/resourceSelectors/index.js +5 -0
  53. package/src/components/dataViews/DataViewEditor.js +170 -0
  54. package/src/components/dataViews/DataViewSelect.js +47 -0
  55. package/src/components/dataViews/DataViews.js +169 -0
  56. package/src/components/dataViews/Queryable.js +138 -0
  57. package/src/components/dataViews/Queryables.js +53 -0
  58. package/src/components/dataViews/__tests__/DataViewEditor.spec.js +293 -0
  59. package/src/components/dataViews/__tests__/DataViewSelect.spec.js +28 -0
  60. package/src/components/dataViews/__tests__/DataViews.spec.js +57 -0
  61. package/src/components/dataViews/__tests__/Queryable.spec.js +201 -0
  62. package/src/components/dataViews/__tests__/Queryables.spec.js +183 -0
  63. package/src/components/dataViews/__tests__/__snapshots__/DataViewEditor.spec.js.snap +1000 -0
  64. package/src/components/dataViews/__tests__/__snapshots__/DataViewSelect.spec.js.snap +55 -0
  65. package/src/components/dataViews/__tests__/__snapshots__/DataViews.spec.js.snap +77 -0
  66. package/src/components/dataViews/__tests__/__snapshots__/Queryable.spec.js.snap +874 -0
  67. package/src/components/dataViews/__tests__/__snapshots__/Queryables.spec.js.snap +911 -0
  68. package/src/components/dataViews/__tests__/queryableFunctions.spec.js +193 -0
  69. package/src/components/dataViews/queryableFunctions.js +80 -0
  70. package/src/components/dataViews/queryableProperties/From.js +15 -0
  71. package/src/components/dataViews/queryableProperties/GroupBy.js +124 -0
  72. package/src/components/dataViews/queryableProperties/Join.js +62 -0
  73. package/src/components/dataViews/queryableProperties/JoinTypeIcon.js +49 -0
  74. package/src/components/dataViews/queryableProperties/Select.js +76 -0
  75. package/src/components/dataViews/queryableProperties/SelectField.js +116 -0
  76. package/src/components/dataViews/queryableProperties/Where.js +15 -0
  77. package/src/components/dataViews/queryableProperties/__tests__/From.spec.js +30 -0
  78. package/src/components/dataViews/queryableProperties/__tests__/GroupBy.spec.js +75 -0
  79. package/src/components/dataViews/queryableProperties/__tests__/Join.spec.js +38 -0
  80. package/src/components/dataViews/queryableProperties/__tests__/JoinTypeIcon.spec.js +36 -0
  81. package/src/components/dataViews/queryableProperties/__tests__/Select.spec.js +144 -0
  82. package/src/components/dataViews/queryableProperties/__tests__/SelectField.spec.js +107 -0
  83. package/src/components/dataViews/queryableProperties/__tests__/Where.spec.js +27 -0
  84. package/src/components/dataViews/queryableProperties/__tests__/__snapshots__/From.spec.js.snap +75 -0
  85. package/src/components/dataViews/queryableProperties/__tests__/__snapshots__/GroupBy.spec.js.snap +276 -0
  86. package/src/components/dataViews/queryableProperties/__tests__/__snapshots__/Join.spec.js.snap +252 -0
  87. package/src/components/dataViews/queryableProperties/__tests__/__snapshots__/JoinTypeIcon.spec.js.snap +77 -0
  88. package/src/components/dataViews/queryableProperties/__tests__/__snapshots__/Select.spec.js.snap +411 -0
  89. package/src/components/dataViews/queryableProperties/__tests__/__snapshots__/SelectField.spec.js.snap +343 -0
  90. package/src/components/dataViews/queryableProperties/__tests__/__snapshots__/Where.spec.js.snap +22 -0
  91. package/src/components/dataViews/queryableProperties/index.js +7 -0
  92. package/src/components/functions/FunctionEditor.js +30 -29
  93. package/src/components/functions/Functions.js +3 -11
  94. package/src/components/functions/__tests__/FunctionEditor.spec.js +6 -0
  95. package/src/components/functions/__tests__/FunctionParams.spec.js +6 -0
  96. package/src/components/functions/__tests__/__snapshots__/FunctionEditor.spec.js.snap +490 -466
  97. package/src/components/functions/__tests__/__snapshots__/FunctionParams.spec.js.snap +1 -1
  98. package/src/hooks/__tests__/{useDataSets.spec.js → useDataViews.spec.js} +5 -5
  99. package/src/hooks/useDataViews.js +33 -0
  100. package/src/styles/Expression.less +150 -0
  101. package/src/types.js +11 -3
  102. package/src/components/DataSets.js +0 -64
  103. package/src/components/__tests__/DataSets.spec.js +0 -46
  104. package/src/components/__tests__/__snapshots__/DataSets.spec.js.snap +0 -82
  105. package/src/components/functions/expressions/Expression.js +0 -40
  106. package/src/components/functions/expressions/FieldSelector.js +0 -56
  107. package/src/components/functions/expressions/__tests__/__snapshots__/Expression.spec.js.snap +0 -904
  108. package/src/components/functions/expressions/__tests__/__snapshots__/FunctionArgs.spec.js.snap +0 -392
  109. package/src/components/functions/expressions/constantInputs/AnySelector.js +0 -29
  110. package/src/hooks/useDataSets.js +0 -8
  111. /package/src/components/{functions → common}/expressions/ConstantSelector.js +0 -0
  112. /package/src/components/{functions → common}/expressions/__tests__/__snapshots__/FunctionSelector.spec.js.snap +0 -0
  113. /package/src/components/{functions → common/expressions}/__tests__/useWatchParams.spec.js +0 -0
  114. /package/src/components/{functions → common}/expressions/constantInputs/BooleanSelector.js +0 -0
  115. /package/src/components/{functions → common}/expressions/constantInputs/DefaultSelector.js +0 -0
  116. /package/src/components/{functions → common}/expressions/constantInputs/__tests__/BooleanSelector.spec.js +0 -0
  117. /package/src/components/{functions → common}/expressions/constantInputs/__tests__/__snapshots__/BooleanSelector.spec.js.snap +0 -0
  118. /package/src/components/{functions → common}/expressions/constantInputs/__tests__/__snapshots__/DefaultSelector.spec.js.snap +0 -0
  119. /package/src/components/{functions → common}/expressions/constantInputs/index.js +0 -0
  120. /package/src/components/{functions → common/expressions}/useWatchParams.js +0 -0
@@ -0,0 +1,5 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`<FieldSelector /> matches the latest snapshot 1`] = `<div />`;
4
+
5
+ exports[`<FieldSelector /> matches the latest snapshot empty 1`] = `<div />`;
@@ -0,0 +1,344 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`<FunctionArgs /> matches the latest snapshot 1`] = `<div />`;
4
+
5
+ exports[`<FunctionArgs /> user interaction 1`] = `
6
+ <div>
7
+ <ul
8
+ class="function-tree"
9
+ style=""
10
+ >
11
+ <li>
12
+ <div
13
+ class="flex-column"
14
+ >
15
+ <div
16
+ class="param-label-header"
17
+ >
18
+ <div
19
+ class="ui large image label"
20
+ >
21
+ <i
22
+ aria-hidden="true"
23
+ class="teal adjust fitted icon"
24
+ />
25
+ <div
26
+ class="detail"
27
+ >
28
+ arg1
29
+ </div>
30
+ </div>
31
+ <div
32
+ class="param-label-description"
33
+ />
34
+ </div>
35
+ <div
36
+ class="ui grid"
37
+ >
38
+ <div
39
+ class="sixteen wide column"
40
+ >
41
+ <div
42
+ class="expression-container"
43
+ >
44
+ <div
45
+ aria-expanded="false"
46
+ class="ui top left pointing dropdown"
47
+ role="listbox"
48
+ tabindex="0"
49
+ >
50
+ <div
51
+ class="shape-selector-trigger"
52
+ >
53
+ [π]
54
+ </div>
55
+ <div
56
+ class="menu transition"
57
+ >
58
+ <div
59
+ aria-checked="true"
60
+ aria-selected="true"
61
+ class="active selected item"
62
+ role="option"
63
+ style="pointer-events: all;"
64
+ >
65
+ <div
66
+ class="text flex-center"
67
+ >
68
+ <small
69
+ style="margin-right: 5px;"
70
+ >
71
+ <b>
72
+ <code>
73
+ [π]
74
+ </code>
75
+ </b>
76
+ </small>
77
+ constant
78
+ </div>
79
+ </div>
80
+ <div
81
+ aria-checked="false"
82
+ aria-selected="false"
83
+ class="item"
84
+ role="option"
85
+ style="pointer-events: all;"
86
+ >
87
+ <div
88
+ class="text flex-center"
89
+ >
90
+ <small
91
+ style="margin-right: 5px;"
92
+ >
93
+ <b>
94
+ <code>
95
+ f(x)
96
+ </code>
97
+ </b>
98
+ </small>
99
+ function
100
+ </div>
101
+ </div>
102
+ </div>
103
+ </div>
104
+ <div
105
+ aria-expanded="false"
106
+ class="ui fluid selection dropdown"
107
+ role="listbox"
108
+ tabindex="0"
109
+ >
110
+ <i
111
+ aria-hidden="true"
112
+ class="dropdown icon"
113
+ />
114
+ <div
115
+ class="menu transition"
116
+ >
117
+ <div
118
+ aria-checked="false"
119
+ aria-selected="true"
120
+ class="selected item"
121
+ role="option"
122
+ style="pointer-events: all;"
123
+ >
124
+ <span
125
+ class="text"
126
+ >
127
+ true
128
+ </span>
129
+ </div>
130
+ <div
131
+ aria-checked="false"
132
+ aria-selected="false"
133
+ class="item"
134
+ role="option"
135
+ style="pointer-events: all;"
136
+ >
137
+ <span
138
+ class="text"
139
+ >
140
+ false
141
+ </span>
142
+ </div>
143
+ </div>
144
+ </div>
145
+ </div>
146
+ </div>
147
+ </div>
148
+ </div>
149
+ </li>
150
+ <li>
151
+ <div
152
+ class="flex-column"
153
+ >
154
+ <div
155
+ class="param-label-header"
156
+ >
157
+ <div
158
+ class="ui large image label"
159
+ >
160
+ <i
161
+ aria-hidden="true"
162
+ class="teal adjust fitted icon"
163
+ />
164
+ <div
165
+ class="detail"
166
+ >
167
+ arg2
168
+ </div>
169
+ </div>
170
+ <div
171
+ class="param-label-description"
172
+ />
173
+ </div>
174
+ <div
175
+ class="ui grid"
176
+ >
177
+ <div
178
+ class="sixteen wide column"
179
+ >
180
+ <div
181
+ class="expression-container"
182
+ >
183
+ <div
184
+ aria-expanded="false"
185
+ class="ui top left pointing dropdown"
186
+ role="listbox"
187
+ tabindex="0"
188
+ >
189
+ <div
190
+ class="shape-selector-trigger"
191
+ >
192
+ f(x)
193
+ </div>
194
+ <div
195
+ class="menu transition"
196
+ >
197
+ <div
198
+ aria-checked="false"
199
+ aria-selected="false"
200
+ class="item"
201
+ role="option"
202
+ style="pointer-events: all;"
203
+ >
204
+ <div
205
+ class="text flex-center"
206
+ >
207
+ <small
208
+ style="margin-right: 5px;"
209
+ >
210
+ <b>
211
+ <code>
212
+ [π]
213
+ </code>
214
+ </b>
215
+ </small>
216
+ constant
217
+ </div>
218
+ </div>
219
+ <div
220
+ aria-checked="true"
221
+ aria-selected="true"
222
+ class="active selected item"
223
+ role="option"
224
+ style="pointer-events: all;"
225
+ >
226
+ <div
227
+ class="text flex-center"
228
+ >
229
+ <small
230
+ style="margin-right: 5px;"
231
+ >
232
+ <b>
233
+ <code>
234
+ f(x)
235
+ </code>
236
+ </b>
237
+ </small>
238
+ function
239
+ </div>
240
+ </div>
241
+ </div>
242
+ </div>
243
+ <div
244
+ class="accordion ui fluid no-margin"
245
+ >
246
+ <div
247
+ class="active title no-padding"
248
+ >
249
+ <div
250
+ class="flex-center"
251
+ >
252
+ <i
253
+ aria-hidden="true"
254
+ class="dropdown icon"
255
+ />
256
+ <div
257
+ aria-expanded="false"
258
+ class="ui fluid search selection dropdown"
259
+ role="combobox"
260
+ >
261
+ <input
262
+ aria-autocomplete="list"
263
+ autocomplete="off"
264
+ class="search"
265
+ tabindex="0"
266
+ type="text"
267
+ value=""
268
+ />
269
+ <div
270
+ aria-atomic="true"
271
+ aria-live="polite"
272
+ class="divider text"
273
+ role="alert"
274
+ >
275
+ function.placeholder
276
+ </div>
277
+ <i
278
+ aria-hidden="true"
279
+ class="dropdown icon"
280
+ />
281
+ <div
282
+ class="menu transition"
283
+ role="listbox"
284
+ >
285
+ <div
286
+ aria-checked="false"
287
+ aria-selected="true"
288
+ class="selected item"
289
+ role="option"
290
+ style="pointer-events: all;"
291
+ >
292
+ <div
293
+ class="ui header"
294
+ >
295
+ <div
296
+ class="flex-center"
297
+ >
298
+ <div>
299
+ eq
300
+ </div>
301
+ <div
302
+ class="function-params-label"
303
+ >
304
+ <div
305
+ class="ui teal label"
306
+ >
307
+ <i
308
+ aria-hidden="true"
309
+ class="adjust icon"
310
+ />
311
+ arg1
312
+ </div>
313
+ <div
314
+ class="ui teal label"
315
+ >
316
+ <i
317
+ aria-hidden="true"
318
+ class="adjust icon"
319
+ />
320
+ arg2
321
+ </div>
322
+ </div>
323
+ </div>
324
+ </div>
325
+ <div
326
+ class="sub header"
327
+ />
328
+ </div>
329
+ </div>
330
+ </div>
331
+ </div>
332
+ </div>
333
+ <div
334
+ class="content active no-padding"
335
+ />
336
+ </div>
337
+ </div>
338
+ </div>
339
+ </div>
340
+ </div>
341
+ </li>
342
+ </ul>
343
+ </div>
344
+ `;
@@ -19,7 +19,7 @@ exports[`<ParamSelector /> deleting param will clean field 1`] = `
19
19
  </div>
20
20
  <div
21
21
  aria-expanded="false"
22
- class="ui fluid selection dropdown"
22
+ class="ui error fluid selection dropdown"
23
23
  role="listbox"
24
24
  tabindex="0"
25
25
  >
@@ -56,8 +56,8 @@ exports[`<ParamSelector /> matches the latest snapshot 1`] = `
56
56
  exports[`<ParamSelector /> user interaction 1`] = `
57
57
  <div>
58
58
  <div
59
- aria-expanded="false"
60
- class="ui fluid selection dropdown"
59
+ aria-expanded="true"
60
+ class="ui active visible fluid selection dropdown"
61
61
  role="listbox"
62
62
  tabindex="0"
63
63
  >
@@ -74,7 +74,7 @@ exports[`<ParamSelector /> user interaction 1`] = `
74
74
  class="dropdown icon"
75
75
  />
76
76
  <div
77
- class="menu transition"
77
+ class="visible menu transition"
78
78
  >
79
79
  <div
80
80
  aria-checked="true"
@@ -10,20 +10,21 @@ exports[`<ShapeSelector /> matches the latest snapshot 1`] = `
10
10
  >
11
11
  <div
12
12
  class="shape-selector-trigger"
13
- />
13
+ >
14
+ f(x)
15
+ </div>
14
16
  <div
15
17
  class="menu transition"
16
18
  >
17
19
  <div
18
20
  aria-checked="false"
19
- aria-selected="true"
20
- class="selected item"
21
+ aria-selected="false"
22
+ class="item"
21
23
  role="option"
22
24
  style="pointer-events: all;"
23
25
  >
24
26
  <div
25
- class="text"
26
- style="display: flex; align-items: center;"
27
+ class="text flex-center"
27
28
  >
28
29
  <small
29
30
  style="margin-right: 5px;"
@@ -38,15 +39,14 @@ exports[`<ShapeSelector /> matches the latest snapshot 1`] = `
38
39
  </div>
39
40
  </div>
40
41
  <div
41
- aria-checked="false"
42
- aria-selected="false"
43
- class="item"
42
+ aria-checked="true"
43
+ aria-selected="true"
44
+ class="active selected item"
44
45
  role="option"
45
46
  style="pointer-events: all;"
46
47
  >
47
48
  <div
48
- class="text"
49
- style="display: flex; align-items: center;"
49
+ class="text flex-center"
50
50
  >
51
51
  <small
52
52
  style="margin-right: 5px;"
@@ -89,8 +89,7 @@ exports[`<ShapeSelector /> user interaction select constant 1`] = `
89
89
  style="pointer-events: all;"
90
90
  >
91
91
  <div
92
- class="text"
93
- style="display: flex; align-items: center;"
92
+ class="text flex-center"
94
93
  >
95
94
  <small
96
95
  style="margin-right: 5px;"
@@ -112,8 +111,7 @@ exports[`<ShapeSelector /> user interaction select constant 1`] = `
112
111
  style="pointer-events: all;"
113
112
  >
114
113
  <div
115
- class="text"
116
- style="display: flex; align-items: center;"
114
+ class="text flex-center"
117
115
  >
118
116
  <small
119
117
  style="margin-right: 5px;"
@@ -156,8 +154,7 @@ exports[`<ShapeSelector /> user interaction select function 1`] = `
156
154
  style="pointer-events: all;"
157
155
  >
158
156
  <div
159
- class="text"
160
- style="display: flex; align-items: center;"
157
+ class="text flex-center"
161
158
  >
162
159
  <small
163
160
  style="margin-right: 5px;"
@@ -179,8 +176,7 @@ exports[`<ShapeSelector /> user interaction select function 1`] = `
179
176
  style="pointer-events: all;"
180
177
  >
181
178
  <div
182
- class="text"
183
- style="display: flex; align-items: center;"
179
+ class="text flex-center"
184
180
  >
185
181
  <small
186
182
  style="margin-right: 5px;"
@@ -223,8 +219,7 @@ exports[`<ShapeSelector /> user interaction select param 1`] = `
223
219
  style="pointer-events: all;"
224
220
  >
225
221
  <div
226
- class="text"
227
- style="display: flex; align-items: center;"
222
+ class="text flex-center"
228
223
  >
229
224
  <small
230
225
  style="margin-right: 5px;"
@@ -246,8 +241,7 @@ exports[`<ShapeSelector /> user interaction select param 1`] = `
246
241
  style="pointer-events: all;"
247
242
  >
248
243
  <div
249
- class="text"
250
- style="display: flex; align-items: center;"
244
+ class="text flex-center"
251
245
  >
252
246
  <small
253
247
  style="margin-right: 5px;"
@@ -269,8 +263,7 @@ exports[`<ShapeSelector /> user interaction select param 1`] = `
269
263
  style="pointer-events: all;"
270
264
  >
271
265
  <div
272
- class="text"
273
- style="display: flex; align-items: center;"
266
+ class="text flex-center"
274
267
  >
275
268
  <small
276
269
  style="margin-right: 5px;"
@@ -0,0 +1,44 @@
1
+ import React, { useContext } from "react";
2
+ import { useIntl } from "react-intl";
3
+ import { useFormContext, Controller } from "react-hook-form";
4
+ import { TypeSelector } from "@truedat/qx/components/common";
5
+ import QxContext from "@truedat/qx/components/QxContext";
6
+ const ConstantSelector = React.lazy(() => import("../ConstantSelector"));
7
+
8
+ export default function AnySelector() {
9
+ const { formatMessage } = useIntl();
10
+ const context = useContext(QxContext);
11
+ const { field } = context;
12
+ const { watch, control, setValue } = useFormContext();
13
+ const type = watch(`${field}.value.type`);
14
+
15
+ return (
16
+ <>
17
+ <Controller
18
+ control={control}
19
+ name={`${field}.value.type`}
20
+ rules={{
21
+ required: formatMessage({ id: "functions.form.required" }),
22
+ }}
23
+ render={({ field: { onBlur, onChange }, fieldState: { error } }) => (
24
+ <TypeSelector
25
+ onBlur={onBlur}
26
+ value={type}
27
+ error={error?.message}
28
+ onChange={(_e, { value }) => {
29
+ setValue(`${field}.value.value`, "");
30
+ onChange(value);
31
+ }}
32
+ withoutTypeAny
33
+ />
34
+ )}
35
+ />
36
+
37
+ {type ? (
38
+ <QxContext.Provider value={{ ...context, type }}>
39
+ <ConstantSelector />
40
+ </QxContext.Provider>
41
+ ) : null}
42
+ </>
43
+ );
44
+ }
@@ -4,30 +4,37 @@ import userEvent from "@testing-library/user-event";
4
4
  import TestFormWrapper from "@truedat/qx/components/common/TestFormWrapper";
5
5
  import AnySelector from "../AnySelector";
6
6
 
7
+ const renderOpts = {
8
+ messages: {
9
+ en: {
10
+ "functions.expression.constant.false": "false",
11
+ "functions.expression.constant.true": "true",
12
+ "functions.form.required": "required",
13
+ "expressions.data_type.timestamp": "timestamp",
14
+ "expressions.data_type.date": "date",
15
+ "expressions.data_type.number": "number",
16
+ "expressions.data_type.string": "string",
17
+ "expressions.data_type.boolean": "boolean",
18
+ "expressions.data_type.any": "any",
19
+ },
20
+ },
21
+ fallback: "lazy",
22
+ };
23
+
24
+ const watcher = jest.fn();
25
+
7
26
  describe("<AnySelector />", () => {
8
27
  it("matches the latest snapshot", () => {
9
28
  const { container } = render(
10
29
  <TestFormWrapper>
11
30
  <AnySelector />
12
- </TestFormWrapper>
31
+ </TestFormWrapper>,
32
+ renderOpts
13
33
  );
14
34
  expect(container).toMatchSnapshot();
15
35
  });
16
36
 
17
37
  it("user interaction", async () => {
18
- const renderOpts = {
19
- messages: {
20
- en: {
21
- "functions.expression.constant.false": "false",
22
- "functions.expression.constant.true": "true",
23
- "functions.form.required": "required",
24
- },
25
- },
26
- fallback: "lazy",
27
- };
28
-
29
- const watcher = jest.fn();
30
-
31
38
  const { container, findByText } = render(
32
39
  <TestFormWrapper watcher={watcher}>
33
40
  <AnySelector />
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
2
  import { render } from "@truedat/test/render";
3
+ import { act } from "react-dom/test-utils";
3
4
  import userEvent from "@testing-library/user-event";
4
5
  import TestFormWrapper from "@truedat/qx/components/common/TestFormWrapper";
5
6
  import DefaultSelector from "../DefaultSelector";
@@ -34,14 +35,16 @@ describe("<DefaultSelector />", () => {
34
35
  <TestFormWrapper
35
36
  watcher={watcher}
36
37
  defaultValues={defaultValues}
37
- field={field}
38
+ context={{ field }}
38
39
  >
39
40
  <DefaultSelector />
40
41
  </TestFormWrapper>,
41
42
  renderOpts
42
43
  );
43
44
 
44
- userEvent.type(await findByRole("textbox"), "text");
45
+ await act(async () => {
46
+ userEvent.type(await findByRole("textbox"), "text");
47
+ });
45
48
 
46
49
  expect(watcher).lastCalledWith({
47
50
  test: {
@@ -64,7 +64,7 @@ exports[`<AnySelector /> matches the latest snapshot 1`] = `
64
64
  <span
65
65
  class="text"
66
66
  >
67
- numeric
67
+ number
68
68
  </span>
69
69
  </div>
70
70
  <div
@@ -179,7 +179,7 @@ exports[`<AnySelector /> user interaction 1`] = `
179
179
  <span
180
180
  class="text"
181
181
  >
182
- numeric
182
+ number
183
183
  </span>
184
184
  </div>
185
185
  <div
@@ -0,0 +1,4 @@
1
+ import Clauses from "./Clauses";
2
+ import Expression from "./Expression";
3
+
4
+ export { Clauses, Expression };